From: dish Date: Fri, 8 Mar 2024 13:51:34 +0000 (+0000) Subject: [bos #35154][EDF](2023-T1) Edge thickness. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4d4e3edb3c1ca122a51ce1d9c59072491cd31f6e;p=modules%2Fshaper.git [bos #35154][EDF](2023-T1) Edge thickness. Add preview. --- diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 7ec56af30..3783346ad 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -403,8 +403,8 @@ bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer) // Set edge thickness const int aEdgeThickness = ModelAPI_Tools::getEdgeThickness(aResult); - std::cout << "aEdgeThickness " << aEdgeThickness << "\t"; - std::cout << "aAISObj->width() " << aAISObj->width() << std::endl; + // std::cout << "aEdgeThickness " << aEdgeThickness << "\t"; + // std::cout << "aAISObj->width() " << aAISObj->width() << std::endl; if ((aEdgeThickness > 0) && (aEdgeThickness != aAISObj->width())) aAISObj->setWidth(aEdgeThickness); diff --git a/src/XGUI/XGUI_EdgeThicknessWidget.cpp b/src/XGUI/XGUI_EdgeThicknessWidget.cpp index 7f86083cf..7fb5e7d21 100644 --- a/src/XGUI/XGUI_EdgeThicknessWidget.cpp +++ b/src/XGUI/XGUI_EdgeThicknessWidget.cpp @@ -33,13 +33,13 @@ XGUI_EdgeThicknessWidget::XGUI_EdgeThicknessWidget(QWidget* theParent) mySpinBox = new SalomeApp_IntSpinBox(); mySpinBox->setRange(1, 5); mySpinBox->setDefaultValue(1); - mySpinBox->setSingleStep(1); + mySpinBox->setSingleStep(1); mySpinBox->setObjectName("EdgeThicknessSpinBox"); mySpinBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); mySpinBox->setValue(1); aLayout->addWidget(mySpinBox, 0, Qt::AlignCenter); - connect(mySpinBox, SIGNAL(valueChanged(int)), this, SLOT(thicknessValueChanged(int))); + connect(mySpinBox, SIGNAL(valueChanged(int)), this, SIGNAL(thicknessValueChanged(int))); } void XGUI_EdgeThicknessWidget::setValue(int theValue) diff --git a/src/XGUI/XGUI_EdgeThicknessWidget.h b/src/XGUI/XGUI_EdgeThicknessWidget.h index be3786ae5..8b1822145 100644 --- a/src/XGUI/XGUI_EdgeThicknessWidget.h +++ b/src/XGUI/XGUI_EdgeThicknessWidget.h @@ -48,7 +48,7 @@ public: /// \return value int getValue() const; - signals: +signals: void thicknessValueChanged(); private: diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index ff3149b52..0e2aaa05e 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -159,6 +159,8 @@ #include #include +#include + #ifdef TINSPECTOR #include #include @@ -956,6 +958,49 @@ void XGUI_Workshop::setGrantedFeatures(ModuleBase_Operation* theOperation) aFOperation->setGrantedOperationIds(aGrantedIds); } +//****************************************************** +void XGUI_Workshop::applyEdgeThicknessToCanvas(const QMap>& theSelectedObjects, int theThickness) +{ + const bool isSubShapeWithEdgeThickness = Config_PropManager::boolean("Visualization", "result_subshape_with_edge_thickness"); + + // 3. Abort previous operation and start a new one. + SessionPtr session = ModelAPI_Session::get(); + QString description = contextMenuMgr()->action("EDGE_THICKNESS_CMD")->text(); + session->startOperation(description.toStdString()); + + // 4. Set new value to all results and subshapes of results. + foreach(ResultPtr result, theSelectedObjects.keys()) { + if (!result) + continue; + + ResultBodyPtr bodyResult = std::dynamic_pointer_cast(result); + foreach(GeomShapePtr shape, theSelectedObjects[result]) { + if (result->shape()->impl().IsEqual(shape->impl()) || !isSubShapeWithEdgeThickness) { + if (result) { + // Change edge thickness for all sub-solids. + std::list allSubResults; + ModelAPI_Tools::allSubs(bodyResult, allSubResults); + for (auto itSubRes = allSubResults.begin(); itSubRes != allSubResults.end(); itSubRes++) { + ModelAPI_Tools::setEdgeThickness(*itSubRes, theThickness); + } + + ModelAPI_Tools::setEdgeThickness(result, theThickness); + } + + if (!isSubShapeWithEdgeThickness) + break; + } + else if (!shape->isNull()) + ModelAPI_Tools::setSubShapeEdgeThickness(result, shape, theThickness); + } + } + + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); + session->finishOperation(); + updateCommandStatus(); + myViewerProxy->update(); +} + //****************************************************** void XGUI_Workshop::saveDocument(const QString& theName, std::list& theFileNames) { @@ -2944,55 +2989,21 @@ void XGUI_Workshop::changeEdgeThickness(const QMapsetWindowTitle(tr("Edge Thickness")); XGUI_EdgeThicknessWidget* edgeThicknessWidget = new XGUI_EdgeThicknessWidget(dialog); - connect(edgeThicknessWidget, SIGNAL(thicknessValueChanged()), this, SLOT(onEdgeThicknessValueChanged())); + mySelectedObjects = theSelectedObjects; + connect(edgeThicknessWidget, SIGNAL(thicknessValueChanged(int)), this, SLOT(onEdgeThicknessValueChanged(int))); dialog->setContent(edgeThicknessWidget); edgeThicknessWidget->setValue(thickness); if (dialog->exec() != QDialog::Accepted) - return; - - // 3. Abort previous operation and start a new one. - SessionPtr session = ModelAPI_Session::get(); - QString description = contextMenuMgr()->action("EDGE_THICKNESS_CMD")->text(); - session->startOperation(description.toStdString()); - - // 4. Set new value to all results and subshapes of results. - int newThickness = edgeThicknessWidget->getValue(); - foreach(ResultPtr result, theSelectedObjects.keys()) { - if (!result) - continue; - - ResultBodyPtr bodyResult = std::dynamic_pointer_cast(result); - foreach(GeomShapePtr shape, theSelectedObjects[result]) { - if (result->shape()->impl().IsEqual(shape->impl()) || !isSubShapeWithEdgeThickness) { - if (result) { - // Change edge thickness for all sub-solids. - std::list allSubResults; - ModelAPI_Tools::allSubs(bodyResult, allSubResults); - for (auto itSubRes = allSubResults.begin(); itSubRes != allSubResults.end(); itSubRes++) { - ModelAPI_Tools::setEdgeThickness(*itSubRes, newThickness); - } - - ModelAPI_Tools::setEdgeThickness(result, newThickness); - } - - if (!isSubShapeWithEdgeThickness) - break; - } - else if (!shape->isNull()) - ModelAPI_Tools::setSubShapeEdgeThickness(result, shape, newThickness); - } - } - - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); - session->finishOperation(); - updateCommandStatus(); - myViewerProxy->update(); + applyEdgeThicknessToCanvas(theSelectedObjects, thickness); } //************************************************************** -void XGUI_Workshop::onEdgeThicknessValueChanged() +void XGUI_Workshop::onEdgeThicknessValueChanged(int theThickness) { + // std::cout << "XGUI_Workshop::onEdgeThicknessValueChanged(" << theThickness << ")" << std::endl; + + /* XGUI_EdgeThicknessWidget* aWidget = (XGUI_EdgeThicknessWidget*)sender(); if (!aWidget) return; @@ -3003,6 +3014,10 @@ void XGUI_Workshop::onEdgeThicknessValueChanged() Events_Loop::loop()->flush(kRedisplayEvent); myViewerProxy->update(); + */ + + + applyEdgeThicknessToCanvas(mySelectedObjects, theThickness); } //****************************************************** diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 09ea4c266..f631f3f9e 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -458,7 +458,7 @@ signals: /// Apply the current transparency value if preview in transparency dialog is switched on void onTransparencyValueChanged(); - void onEdgeThicknessValueChanged(); + void onEdgeThicknessValueChanged(int theThickness); protected: /// Sets the granted operations for the parameter operation. Firstly, it finds the nested features @@ -467,6 +467,8 @@ signals: void setGrantedFeatures(ModuleBase_Operation* theOperation); private: + void applyEdgeThicknessToCanvas(const QMap>& theSelectedObjects, int theThickness); + /// Display results from document /// \param theDoc a document void displayDocumentResults(DocumentPtr theDoc); @@ -599,6 +601,8 @@ private: Config_DataModelReader* myDataModelXMLReader; ///< XML reader of data model XGUI_InspectionPanel* myInspectionPanel; ///< container of feature attributes widgets QTemporaryDir myTmpDir; ///< a direcory for uncompressed files + + QMap, QList>> mySelectedObjects; }; #endif