Exemplo n.º 1
0
/**
 * 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);

}
/**
 * Called when the linetype has changed. This method 
 * sets the current linetype to the value chosen or even
 * offers a dialog to the user that allows him/ her to
 * choose an individual linetype.
 */
void QG_LineTypeBox::slotLineTypeChanged(int index) {

    RS_DEBUG->print("QG_LineTypeBox::slotLineTypeChanged %d\n", index);
	
	unchanged = false;

    if (showByLayer) {
        switch (index) {
        case 0:
			if (showUnchanged) {
				unchanged = true;
			}
			else {
            	currentLineType = RS2::LineByLayer;
			}
            break;

        case 1:
			if (showUnchanged) {
				currentLineType = RS2::LineByLayer;
			}
			else {
            	currentLineType = RS2::LineByBlock;
			}
            break;
			
        default:
            currentLineType = (RS2::LineType)(index-2-(int)showUnchanged);
            break;
        }
    } else {
        currentLineType = 
			(RS2::LineType)(index-(int)showByLayer*2-(int)showUnchanged);
    }

    RS_DEBUG->print("Current linetype is (%d): %d\n",
                    index, currentLineType);

    emit lineTypeChanged(currentLineType);
}
Exemplo n.º 3
0
/**
 * 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());

}