| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #include "qg_pentoolbar.h" |
| |
|
| | #include "qg_colorbox.h" |
| | #include "qg_widthbox.h" |
| | #include "qg_linetypebox.h" |
| | #include "rs_graphic.h" |
| | #include "rs_graphicview.h" |
| | #include "rs_layer.h" |
| | #include "rs_pen.h" |
| |
|
| | |
| | |
| | |
| | QG_PenToolBar::QG_PenToolBar( const QString & title, QWidget * parent ) |
| | : QToolBar(title, parent) |
| | , m_currentPen(new RS_Pen{}) |
| | , m_colorBox(new QG_ColorBox{true, false, this, "colorbox"}) |
| | , m_widthBox(new QG_WidthBox{true, false, this, "widthbox"}) |
| | , m_lineTypeBox(new QG_LineTypeBox{true, false, this, "lineTypebox"}) |
| | { |
| | m_colorBox->setToolTip(tr("Line color")); |
| | connect(m_colorBox.get(), &QG_ColorBox::colorChanged, this, &QG_PenToolBar::slotColorChanged); |
| |
|
| | m_widthBox->setToolTip(tr("Line width")); |
| | connect(m_widthBox.get(), &QG_WidthBox::widthChanged,this, &QG_PenToolBar::slotWidthChanged); |
| |
|
| | m_lineTypeBox->setToolTip(tr("Line type")); |
| | connect(m_lineTypeBox.get(), &QG_LineTypeBox::lineTypeChanged,this,&QG_PenToolBar::slotLineTypeChanged); |
| |
|
| | m_currentPen->setColor(m_colorBox->getColor()); |
| | m_currentPen->setWidth(m_widthBox->getWidth()); |
| | m_currentPen->setLineType(m_lineTypeBox->getLineType()); |
| |
|
| | addWidget(m_colorBox.get()); |
| | addWidget(m_widthBox.get()); |
| | addWidget(m_lineTypeBox.get()); |
| | } |
| |
|
| | |
| | |
| | |
| | QG_PenToolBar::~QG_PenToolBar() = default; |
| |
|
| | void QG_PenToolBar::updateByLayer(RS_Layer* l) { |
| | if (l==nullptr) return; |
| | m_colorBox->setLayerColor(l->getPen().getColor()); |
| | m_widthBox->setLayerWidth(l->getPen().getWidth()); |
| | m_lineTypeBox->setLayerLineType(l->getPen().getLineType()); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | void QG_PenToolBar::layerActivated(RS_Layer* l) { |
| | updateByLayer(l); |
| | } |
| |
|
| | void QG_PenToolBar::setLayerColor(RS_Color color, bool updateSelection){ |
| | m_colorBox->setLayerColor(color); |
| | if (updateSelection){ |
| | m_colorBox->setCurrentIndex(0); |
| | } |
| | m_currentPen->setColor(color); |
| | emitPenChanged(); |
| | } |
| |
|
| | void QG_PenToolBar::setColor(RS_Color color){ |
| | m_colorBox->setColor(color); |
| | } |
| |
|
| | void QG_PenToolBar::setLayerLineType(RS2::LineType lineType, bool updateSelection){ |
| | m_lineTypeBox->setLayerLineType(lineType); |
| | if (updateSelection){ |
| | m_lineTypeBox->setCurrentIndex(0); |
| | } |
| | m_currentPen->setLineType(lineType); |
| | emitPenChanged(); |
| | } |
| |
|
| | void QG_PenToolBar::setLineType(RS2::LineType lineType){ |
| | m_lineTypeBox->setLineType(lineType); |
| | } |
| |
|
| | void QG_PenToolBar::setLayerWidth(RS2::LineWidth width, bool updateSelection){ |
| | m_widthBox->setLayerWidth(width); |
| | if (updateSelection){ |
| | m_widthBox->setCurrentIndex(0); |
| | } |
| | m_currentPen->setWidth(width); |
| | emitPenChanged(); |
| | } |
| |
|
| | void QG_PenToolBar::setWidth(RS2::LineWidth width){ |
| | m_widthBox->setWidth(width); |
| | } |
| |
|
| | void QG_PenToolBar::emitPenChanged(){ |
| | emit penChanged(*m_currentPen); |
| | } |
| |
|
| | void QG_PenToolBar::setLayerList(RS_LayerList* ll) { |
| | if (m_layerList != nullptr) { |
| | m_layerList->removeListener(this); |
| | } |
| | m_layerList = ll; |
| | if (ll != nullptr) { |
| | m_layerList->addListener(this); |
| | auto activeLayer = m_layerList->getActive(); |
| | if (activeLayer != nullptr) { |
| | updateByLayer(activeLayer); |
| | } |
| | } |
| | } |
| |
|
| | void QG_PenToolBar::setGraphicView(RS_GraphicView* gv) { |
| | if (gv == nullptr) { |
| | setLayerList(nullptr); |
| | } |
| | else { |
| | auto graphic = gv->getGraphic(); |
| | if (graphic == nullptr) { |
| | setLayerList(nullptr); |
| | } |
| | else { |
| | auto layerList = graphic->getLayerList(); |
| | setLayerList(layerList); |
| | } |
| | } |
| | } |
| |
|
| | RS_Pen QG_PenToolBar::getPen() const { |
| | return *m_currentPen; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | void QG_PenToolBar::layerEdited(RS_Layer* l) { updateByLayer(l); } |
| |
|
| | |
| | |
| | |
| | void QG_PenToolBar::slotColorChanged(const RS_Color& color) { |
| | m_currentPen->setColor(color); |
| | |
| |
|
| | emit penChanged(*m_currentPen); |
| | } |
| |
|
| | |
| | |
| | |
| | void QG_PenToolBar::slotWidthChanged(RS2::LineWidth w) { |
| | m_currentPen->setWidth(w); |
| | |
| |
|
| | emit penChanged(*m_currentPen); |
| | } |
| |
|
| | |
| | |
| | |
| | void QG_PenToolBar::slotLineTypeChanged(RS2::LineType w) { |
| | m_currentPen->setLineType(w); |
| | |
| |
|
| | emit penChanged(*m_currentPen); |
| | } |
| |
|