| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #include "qg_widgetpen.h" |
| |
|
| | #include <qevent.h> |
| |
|
| | #include "rs_debug.h" |
| | #include "rs_entity.h" |
| | #include "rs_layer.h" |
| |
|
| | |
| | |
| | |
| | |
| | QG_WidgetPen::QG_WidgetPen(QWidget* parent, Qt::WindowFlags fl) |
| | : QWidget(parent, fl) |
| | { |
| | setupUi(this); |
| | connect(cbColor, &QG_ColorBox::colorChanged, this, &QG_WidgetPen::onColorChanged); |
| | connect(cbWidth, &QG_WidthBox::widthChanged, this, &QG_WidgetPen::onWidthChanged); |
| | connect(cbLineType, &QG_LineTypeBox::lineTypeChanged, this, &QG_WidgetPen::onLineTypeChanged); |
| | |
| | |
| | |
| | |
| | |
| | } |
| |
|
| | void QG_WidgetPen::disableVerticalSpacer() { |
| | vsSpacerVertical->changeSize(0,0); |
| | } |
| |
|
| | void QG_WidgetPen::onColorChanged([[maybe_unused]]const RS_Color& color) { |
| | notifyPenChanged(); |
| | } |
| |
|
| | void QG_WidgetPen::onWidthChanged(RS2::LineWidth) { |
| | notifyPenChanged(); |
| | } |
| |
|
| | void QG_WidgetPen::onLineTypeChanged(RS2::LineType) { |
| | notifyPenChanged(); |
| | } |
| |
|
| | void QG_WidgetPen::notifyPenChanged() { |
| | emit penChanged(); |
| | } |
| |
|
| | void QG_WidgetPen::setPen(RS_Pen pen, bool showByLayer, |
| | bool showUnchanged, const QString& title) { |
| | if (!m_initialized) { |
| | cbColor->init(showByLayer, showUnchanged); |
| | cbWidth->init(showByLayer, showUnchanged); |
| | cbLineType->init(showByLayer, showUnchanged); |
| | m_initialized = true; |
| | } |
| | if (!showUnchanged) { |
| | cbColor->setColor(pen.getColor()); |
| | cbWidth->setWidth(pen.getWidth()); |
| | cbLineType->setLineType(pen.getLineType()); |
| | } |
| |
|
| | if (!title.isEmpty()) { |
| | bgPen->setTitle(title); |
| | } |
| | } |
| |
|
| | void QG_WidgetPen::setPen(RS_Entity* entity, RS_Layer* layer, const QString &title){ |
| | RS_Pen entityPen = entity->getPen(false); |
| | RS_Pen entityResolvedPen = entity->getPen(true); |
| |
|
| | RS_Color originalColor = entityPen.getColor(); |
| | RS_Color resolvedColor = entityResolvedPen.getColor(); |
| | resolvedColor.applyFlags(originalColor); |
| | entityResolvedPen.setColor(resolvedColor); |
| |
|
| | entityResolvedPen.setLineType(entityPen.getLineType()); |
| | entityResolvedPen.setWidth(entityPen.getWidth()); |
| |
|
| | setPen(entityResolvedPen, layer, title); |
| | } |
| |
|
| | void QG_WidgetPen::setPen(RS_Pen pen, RS_Layer* layer, bool showUnchanged, const QString &title){ |
| | setPen(pen, true, showUnchanged, title); |
| | if (layer != nullptr){ |
| | RS_Pen layerPen = layer->getPen(); |
| | RS_Color layerColor = layerPen.getColor(); |
| | cbColor->setLayerColor(layerColor); |
| | } |
| | } |
| | void QG_WidgetPen::setPen(RS_Pen pen, RS_Layer* layer, const QString &title){ |
| | setPen(pen, layer, false, title); |
| | } |
| |
|
| | RS_Pen QG_WidgetPen::getPen() { |
| | RS_Pen pen; |
| |
|
| | pen.setColor(cbColor->getColor()); |
| | pen.setWidth(cbWidth->getWidth()); |
| | pen.setLineType(cbLineType->getLineType()); |
| |
|
| | return pen; |
| | } |
| |
|
| | bool QG_WidgetPen::isColorUnchanged() { |
| | return cbColor->isUnchanged(); |
| | } |
| |
|
| | bool QG_WidgetPen::isLineTypeUnchanged() { |
| | return cbLineType->isUnchanged(); |
| | } |
| |
|
| | bool QG_WidgetPen::isWidthUnchanged() { |
| | return cbWidth->isUnchanged(); |
| | } |
| |
|
| | |
| | |
| | |
| | QG_WidgetPen::~QG_WidgetPen() { |
| | |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | void QG_WidgetPen::languageChange(){ |
| | retranslateUi(this); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | void QG_WidgetPen::focusInEvent(QFocusEvent* event) { |
| | int reason = event->reason(); |
| | RS_DEBUG->print(RS_Debug::D_ERROR, "QG_WidgetPen::focusInEvent, reason '%d'", reason); |
| | |
| | |
| | |
| | |
| | } |
| |
|
| | void QG_WidgetPen::focusOutEvent(QFocusEvent *event){ |
| | int reason = event->reason(); |
| | RS_DEBUG->print(RS_Debug::D_ERROR,"QG_WidgetPen::focusOutEvent, reason '%d'",reason); |
| | } |
| |
|