From fc76d37d6f96fa55666513f878d4ec3231f8d0d0 Mon Sep 17 00:00:00 2001 From: Adrian Insaurralde Avalos Date: Fri, 4 Nov 2022 20:28:35 -0300 Subject: [PATCH] Add button to set point color in Appearance task dialog --- src/Gui/DlgDisplayProperties.ui | 121 ++++++++++++++++++++++++---- src/Gui/DlgDisplayPropertiesImp.cpp | 78 ++++++++++++++---- src/Gui/DlgDisplayPropertiesImp.h | 2 + 3 files changed, 169 insertions(+), 32 deletions(-) diff --git a/src/Gui/DlgDisplayProperties.ui b/src/Gui/DlgDisplayProperties.ui index 4e1961c9b3..51b963f9fe 100644 --- a/src/Gui/DlgDisplayProperties.ui +++ b/src/Gui/DlgDisplayProperties.ui @@ -7,7 +7,7 @@ 0 0 290 - 487 + 680 @@ -20,7 +20,16 @@ Viewing mode - + + 11 + + + 11 + + + 11 + + 11 @@ -28,7 +37,16 @@ 6 - + + 0 + + + 0 + + + 0 + + 0 @@ -48,7 +66,16 @@ 6 - + + 0 + + + 0 + + + 0 + + 0 @@ -84,7 +111,16 @@ 6 - + + 0 + + + 0 + + + 0 + + 0 @@ -151,7 +187,17 @@ - + + + + Point color: + + + + + + + @@ -162,7 +208,16 @@ Display - + + 9 + + + 9 + + + 9 + + 9 @@ -173,7 +228,16 @@ 6 - + + 0 + + + 0 + + + 0 + + 0 @@ -191,7 +255,7 @@ QSizePolicy::Expanding - + 71 20 @@ -219,7 +283,16 @@ 6 - + + 0 + + + 0 + + + 0 + + 0 @@ -237,7 +310,7 @@ QSizePolicy::Expanding - + 71 20 @@ -272,7 +345,16 @@ 6 - + + 0 + + + 0 + + + 0 + + 0 @@ -303,7 +385,7 @@ - + Line transparency: @@ -315,7 +397,16 @@ 6 - + + 0 + + + 0 + + + 0 + + 0 @@ -340,7 +431,7 @@ - + diff --git a/src/Gui/DlgDisplayPropertiesImp.cpp b/src/Gui/DlgDisplayPropertiesImp.cpp index 1bd489930d..7eddddf916 100644 --- a/src/Gui/DlgDisplayPropertiesImp.cpp +++ b/src/Gui/DlgDisplayPropertiesImp.cpp @@ -75,6 +75,7 @@ DlgDisplayPropertiesImp::DlgDisplayPropertiesImp(bool floating, QWidget* parent, d->ui.textLabel1_3->hide(); d->ui.changePlot->hide(); d->ui.buttonLineColor->setModal(false); + d->ui.buttonPointColor->setModal(false); d->ui.buttonColor->setModal(false); d->floating = floating; @@ -85,6 +86,7 @@ DlgDisplayPropertiesImp::DlgDisplayPropertiesImp(bool floating, QWidget* parent, setColorPlot(views); setShapeColor(views); setLineColor(views); + setPointColor(views); setPointSize(views); setLineWidth(views); setTransparency(views); @@ -144,6 +146,7 @@ void DlgDisplayPropertiesImp::OnChange(Gui::SelectionSingleton::SubjectType &rCa setColorPlot(views); setShapeColor(views); setLineColor(views); + setPointColor(views); setPointSize(views); setLineWidth(views); setTransparency(views); @@ -172,18 +175,25 @@ void DlgDisplayPropertiesImp::slotChangedObject(const Gui::ViewProvider& obj, App::Color value = static_cast(prop).getValue(); if (prop_name == "ShapeColor") { bool blocked = d->ui.buttonColor->blockSignals(true); - d->ui.buttonColor->setColor(QColor((int)(255.0f*value.r), - (int)(255.0f*value.g), - (int)(255.0f*value.b))); + d->ui.buttonColor->setColor(QColor((int)(255.0f * value.r), + (int)(255.0f * value.g), + (int)(255.0f * value.b))); d->ui.buttonColor->blockSignals(blocked); } else if (prop_name == "LineColor") { bool blocked = d->ui.buttonLineColor->blockSignals(true); - d->ui.buttonLineColor->setColor(QColor((int)(255.0f*value.r), - (int)(255.0f*value.g), - (int)(255.0f*value.b))); + d->ui.buttonLineColor->setColor(QColor((int)(255.0f * value.r), + (int)(255.0f * value.g), + (int)(255.0f * value.b))); d->ui.buttonLineColor->blockSignals(blocked); } + else if (prop_name == "PointColor") { + bool blocked = d->ui.buttonPointColor->blockSignals(true); + d->ui.buttonPointColor->setColor(QColor((int)(255.0f * value.r), + (int)(255.0f * value.g), + (int)(255.0f * value.b))); + d->ui.buttonPointColor->blockSignals(blocked); + } } else if (prop.getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) { long value = static_cast(prop).getValue(); @@ -311,7 +321,7 @@ void DlgDisplayPropertiesImp::on_buttonColor_changed() { std::vector Provider = getSelection(); QColor s = d->ui.buttonColor->color(); - App::Color c(s.red()/255.0,s.green()/255.0,s.blue()/255.0); + App::Color c(s.red() / 255.0, s.green() / 255.0, s.blue() / 255.0); for (auto It= Provider.begin();It!=Provider.end();++It) { App::Property* prop = (*It)->getPropertyByName("ShapeColor"); if (prop && prop->getTypeId() == App::PropertyColor::getClassTypeId()) { @@ -370,12 +380,26 @@ void DlgDisplayPropertiesImp::on_buttonLineColor_changed() { std::vector Provider = getSelection(); QColor s = d->ui.buttonLineColor->color(); - App::Color c(s.red()/255.0,s.green()/255.0,s.blue()/255.0); + App::Color c(s.red() / 255.0, s.green() / 255.0, s.blue() / 255.0); for (const auto & It : Provider) { App::Property* prop = It->getPropertyByName("LineColor"); if (prop && prop->getTypeId() == App::PropertyColor::getClassTypeId()) { - auto ShapeColor = static_cast(prop); - ShapeColor->setValue(c); + auto LineColor = static_cast(prop); + LineColor->setValue(c); + } + } +} + +void DlgDisplayPropertiesImp::on_buttonPointColor_changed() +{ + std::vector Provider = getSelection(); + QColor s = d->ui.buttonPointColor->color(); + App::Color c(s.red() / 255.0, s.green() / 255.0, s.blue() / 255.0); + for (const auto & It : Provider) { + App::Property* prop = It->getPropertyByName("PointColor"); + if (prop && prop->getTypeId() == App::PropertyColor::getClassTypeId()) { + auto PointColor = static_cast(prop); + PointColor->setValue(c); } } } @@ -506,7 +530,7 @@ void DlgDisplayPropertiesImp::setShapeColor(const std::vectorgetTypeId() == App::PropertyColor::getClassTypeId()) { App::Color c = static_cast(prop)->getValue(); QColor shape; - shape.setRgb((int)(c.r*255.0f), (int)(c.g*255.0f),(int)(c.b*255.0f)); + shape.setRgb((int)(c.r * 255.0f), (int)(c.g * 255.0f), (int)(c.b * 255.0f)); bool blocked = d->ui.buttonColor->blockSignals(true); d->ui.buttonColor->setColor(shape); d->ui.buttonColor->blockSignals(blocked); @@ -520,22 +544,42 @@ void DlgDisplayPropertiesImp::setShapeColor(const std::vector& views) { - bool shapeColor = false; + bool lineColor = false; for (const auto & view : views) { App::Property* prop = view->getPropertyByName("LineColor"); if (prop && prop->getTypeId() == App::PropertyColor::getClassTypeId()) { App::Color c = static_cast(prop)->getValue(); - QColor shape; - shape.setRgb((int)(c.r*255.0f), (int)(c.g*255.0f),(int)(c.b*255.0f)); + QColor line; + line.setRgb((int)(c.r * 255.0f), (int)(c.g * 255.0f), (int)(c.b * 255.0f)); bool blocked = d->ui.buttonLineColor->blockSignals(true); - d->ui.buttonLineColor->setColor(shape); + d->ui.buttonLineColor->setColor(line); d->ui.buttonLineColor->blockSignals(blocked); - shapeColor = true; + lineColor = true; break; } } - d->ui.buttonLineColor->setEnabled(shapeColor); + d->ui.buttonLineColor->setEnabled(lineColor); +} + +void DlgDisplayPropertiesImp::setPointColor(const std::vector& views) +{ + bool pointColor = false; + for (const auto & view : views) { + App::Property* prop = view->getPropertyByName("PointColor"); + if (prop && prop->getTypeId() == App::PropertyColor::getClassTypeId()) { + App::Color c = static_cast(prop)->getValue(); + QColor point; + point.setRgb((int)(c.r * 255.0f), (int)(c.g * 255.0f), (int)(c.b * 255.0f)); + bool blocked = d->ui.buttonPointColor->blockSignals(true); + d->ui.buttonPointColor->setColor(point); + d->ui.buttonPointColor->blockSignals(blocked); + pointColor = true; + break; + } + } + + d->ui.buttonPointColor->setEnabled(pointColor); } void DlgDisplayPropertiesImp::setPointSize(const std::vector& views) diff --git a/src/Gui/DlgDisplayPropertiesImp.h b/src/Gui/DlgDisplayPropertiesImp.h index a634ac121d..1e7421fa86 100644 --- a/src/Gui/DlgDisplayPropertiesImp.h +++ b/src/Gui/DlgDisplayPropertiesImp.h @@ -72,6 +72,7 @@ private Q_SLOTS: void on_spinTransparency_valueChanged(int); void on_spinPointSize_valueChanged(int); void on_buttonLineColor_changed(); + void on_buttonPointColor_changed(); void on_spinLineWidth_valueChanged(int); void on_spinLineTransparency_valueChanged(int); void on_buttonUserDefinedMaterial_clicked(); @@ -88,6 +89,7 @@ private: void fillupMaterials(); void setShapeColor(const std::vector&); void setLineColor(const std::vector&); + void setPointColor(const std::vector&); void setPointSize(const std::vector&); void setLineWidth(const std::vector&); void setTransparency(const std::vector&);