/** * Sets the pixmap showing the linetype of the "By Layer" item. * * @todo needs an update, but not used currently */ void QG_LineTypeBox::setLayerLineType(RS2::LineType t) { if (showByLayer) { QPixmap pixmap; switch(t) { case RS2::NoPen: pixmap = QPixmap(linetype00_xpm); break; default: case RS2::SolidLine: pixmap = QPixmap(linetype01_xpm); break; case RS2::DashLine: pixmap = QPixmap(linetype02_xpm); break; case RS2::DotLine: pixmap = QPixmap(linetype03_xpm); break; case RS2::DashDotLine: pixmap = QPixmap(linetype04_xpm); break; case RS2::DivideLine: pixmap = QPixmap(linetype05_xpm); break; } changeItem(pixmap, tr("By Layer"), 0); // needed for the first time a layer is added: slotLineTypeChanged(currentItem()); } }
/** * Constructor. */ QG_PenToolBar::QG_PenToolBar( const QString & title, QWidget * parent ) : QToolBar(title, parent) { this->setMinimumWidth(300); this->setMaximumWidth(420); colorBox = new QG_ColorBox(true, false, this, "colorbox"); colorBox->setMinimumWidth(64); colorBox->setToolTip(tr("Line color")); connect(colorBox, SIGNAL(colorChanged(const RS_Color&)), this, SLOT(slotColorChanged(const RS_Color&))); widthBox = new QG_WidthBox(true, false, this, "widthbox"); widthBox->setMinimumWidth(64); widthBox->setToolTip(tr("Line width")); connect(widthBox, SIGNAL(widthChanged(RS2::LineWidth)), this, SLOT(slotWidthChanged(RS2::LineWidth))); lineTypeBox = new QG_LineTypeBox(true, false, this, "lineTypebox"); lineTypeBox->setMinimumWidth(64); lineTypeBox->setToolTip(tr("Line type")); connect(lineTypeBox, SIGNAL(lineTypeChanged(RS2::LineType)), this, SLOT(slotLineTypeChanged(RS2::LineType))); currentPen.setColor(colorBox->getColor()); currentPen.setWidth(widthBox->getWidth()); currentPen.setLineType(lineTypeBox->getLineType()); addWidget(colorBox); addWidget(widthBox); addWidget(lineTypeBox); }
/** * Constructor. */ QG_PenToolBar::QG_PenToolBar( const QString & title, QWidget * parent ) : QToolBar(title, parent) , currentPen(new RS_Pen{}) , colorBox(new QG_ColorBox{true, false, this, "colorbox"}) , widthBox(new QG_WidthBox{true, false, this, "widthbox"}) , lineTypeBox(new QG_LineTypeBox{true, false, this, "lineTypebox"}) { #if QT_VERSION >= 0x050500 int const dPxlRatio=devicePixelRatio(); #else int const dPxlRatio=1; #endif setMinimumWidth(300 * dPxlRatio); setMaximumWidth(420 * dPxlRatio); colorBox->setMinimumWidth(64 * dPxlRatio); colorBox->setToolTip(tr("Line color")); connect(colorBox.get(), SIGNAL(colorChanged(const RS_Color&)), this, SLOT(slotColorChanged(const RS_Color&))); widthBox->setMinimumWidth(64 * dPxlRatio); widthBox->setToolTip(tr("Line width")); connect(widthBox.get(), SIGNAL(widthChanged(RS2::LineWidth)), this, SLOT(slotWidthChanged(RS2::LineWidth))); lineTypeBox->setMinimumWidth(64 * dPxlRatio); lineTypeBox->setToolTip(tr("Line type")); connect(lineTypeBox.get(), SIGNAL(lineTypeChanged(RS2::LineType)), this, SLOT(slotLineTypeChanged(RS2::LineType))); currentPen->setColor(colorBox->getColor()); currentPen->setWidth(widthBox->getWidth()); currentPen->setLineType(lineTypeBox->getLineType()); addWidget(colorBox.get()); addWidget(widthBox.get()); addWidget(lineTypeBox.get()); }
/** * Initialisation (called from constructor or manually but only * once). * * @param showByLayer true: Show attribute ByLayer, ByBlock. */ void QG_LineTypeBox::init(bool showByLayer, bool showUnchanged) { this->showByLayer = showByLayer; this->showUnchanged = showUnchanged; if (showUnchanged) { insertItem(QPixmap(linetype00_xpm), tr("- Unchanged -")); } if (showByLayer) { insertItem(QPixmap(linetype00_xpm), tr("By Layer")); insertItem(QPixmap(linetype00_xpm), tr("By Block")); } insertItem(QPixmap(linetype00_xpm), tr("No Pen")); insertItem(QPixmap(linetype01_xpm), tr("Continuous")); insertItem(QPixmap(linetype02_xpm), tr("Dot")); insertItem(QPixmap(linetype02_xpm), tr("Dot (small)")); insertItem(QPixmap(linetype02_xpm), tr("Dot (large)")); insertItem(QPixmap(linetype03_xpm), tr("Dash")); insertItem(QPixmap(linetype03_xpm), tr("Dash (small)")); insertItem(QPixmap(linetype03_xpm), tr("Dash (large)")); insertItem(QPixmap(linetype04_xpm), tr("Dash Dot")); insertItem(QPixmap(linetype04_xpm), tr("Dash Dot (small)")); insertItem(QPixmap(linetype04_xpm), tr("Dash Dot (large)")); insertItem(QPixmap(linetype05_xpm), tr("Divide")); insertItem(QPixmap(linetype05_xpm), tr("Divide (small)")); insertItem(QPixmap(linetype05_xpm), tr("Divide (large)")); insertItem(QPixmap(linetype06_xpm), tr("Center")); insertItem(QPixmap(linetype06_xpm), tr("Center (small)")); insertItem(QPixmap(linetype06_xpm), tr("Center (large)")); insertItem(QPixmap(linetype07_xpm), tr("Border")); insertItem(QPixmap(linetype07_xpm), tr("Border (small)")); insertItem(QPixmap(linetype07_xpm), tr("Border (large)")); connect(this, SIGNAL(activated(int)), this, SLOT(slotLineTypeChanged(int))); setCurrentItem(0); slotLineTypeChanged(currentItem()); }
/** * Sets the currently selected linetype item to the given linetype. */ void QG_LineTypeBox::setLineType(RS2::LineType t) { RS_DEBUG->print("QG_LineTypeBox::setLineType %d\n", (int)t); int offset = (int)showByLayer*2 + (int)showUnchanged; switch (t) { case RS2::LineByLayer: if (showByLayer) { setCurrentItem(0 + (int)showUnchanged); } else { RS_DEBUG->print(RS_Debug::D_WARNING, "QG_LineTypeBox::setLineType: " "Combobox doesn't support linetype BYLAYER"); } break; case RS2::LineByBlock: if (showByLayer) { setCurrentItem(1 + (int)showUnchanged); } else { RS_DEBUG->print(RS_Debug::D_WARNING, "QG_LineTypeBox::setLineType: " "Combobox doesn't support linetype BYBLOCK"); } break; case RS2::SolidLine: setCurrentItem(1 + offset); break; case RS2::DotLine: setCurrentItem(2 + offset); break; case RS2::DotLine2: setCurrentItem(3 + offset); break; case RS2::DotLineX2: setCurrentItem(4 + offset); break; case RS2::DashLine: setCurrentItem(5 + offset); break; case RS2::DashLine2: setCurrentItem(6 + offset); break; case RS2::DashLineX2: setCurrentItem(7 + offset); break; case RS2::DashDotLine: setCurrentItem(8 + offset); break; case RS2::DashDotLine2: setCurrentItem(9 + offset); break; case RS2::DashDotLineX2: setCurrentItem(10 + offset); break; case RS2::DivideLine: setCurrentItem(11 + offset); break; case RS2::DivideLine2: setCurrentItem(12 + offset); break; case RS2::DivideLineX2: setCurrentItem(13 + offset); break; case RS2::CenterLine: setCurrentItem(14 + offset); break; case RS2::CenterLine2: setCurrentItem(15 + offset); break; case RS2::CenterLineX2: setCurrentItem(16 + offset); break; case RS2::BorderLine: setCurrentItem(17 + offset); break; case RS2::BorderLine2: setCurrentItem(18 + offset); break; case RS2::BorderLineX2: setCurrentItem(19 + offset); break; default: break; } slotLineTypeChanged(currentItem()); }