From 225d6f1701361554ace1069e200002c18cd83771 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me?= Date: Wed, 4 Nov 2020 18:37:19 +0100 Subject: [PATCH] CEA : Lot 2 - Auto Color for Groups --- src/ModelAPI/ModelAPI_Feature.cpp | 15 ++ src/ModelAPI/ModelAPI_Tools.cpp | 116 +++++++++++-- src/ModelAPI/ModelAPI_Tools.h | 12 +- src/PartSet/PartSet_Module.cpp | 10 +- src/XGUI/XGUI_ColorDialog.cpp | 99 +---------- src/XGUI/XGUI_ContextMenuMgr.cpp | 278 ++++++++++++++++-------------- src/XGUI/XGUI_Workshop.cpp | 155 ++++++++++++----- src/XGUI/XGUI_Workshop.h | 7 +- src/XGUI/XGUI_pictures.qrc | 1 + src/XGUI/pictures/autocolor.png | Bin 0 -> 801 bytes 10 files changed, 407 insertions(+), 286 deletions(-) create mode 100644 src/XGUI/pictures/autocolor.png diff --git a/src/ModelAPI/ModelAPI_Feature.cpp b/src/ModelAPI/ModelAPI_Feature.cpp index 14397b0fe..7e408e3a3 100644 --- a/src/ModelAPI/ModelAPI_Feature.cpp +++ b/src/ModelAPI/ModelAPI_Feature.cpp @@ -23,8 +23,11 @@ #include #include #include +#include +#include #include #include +#include void ModelAPI_Feature::setError(const std::string& theError, bool isSend, @@ -70,6 +73,18 @@ void ModelAPI_Feature::setResult(const std::shared_ptr& theResu // in any case result becomes enabled if (!isDisabled()) // disabled feature may be executed when it is added as not enabled (#2078) theResult->setDisabled(theResult, false); + + Config_Prop* aProp = Config_PropManager::findProp("Visualization", "result_group_auto_color"); + + if (aProp) { + bool anIsAutoColor = Config_PropManager::boolean("Visualization", "result_group_auto_color"); + + if (anIsAutoColor && theResult->groupName() == ModelAPI_ResultGroup::group()) { + std::vector aColor; + ModelAPI_Tools::findRandomColor(aColor); + ModelAPI_Tools::setColor(theResult, aColor); + } + } } void ModelAPI_Feature::setResult(const std::shared_ptr& theResult, diff --git a/src/ModelAPI/ModelAPI_Tools.cpp b/src/ModelAPI/ModelAPI_Tools.cpp index e15b280af..0dd1c1c8e 100644 --- a/src/ModelAPI/ModelAPI_Tools.cpp +++ b/src/ModelAPI/ModelAPI_Tools.cpp @@ -17,35 +17,37 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include "ModelAPI_Tools.h" -#include +#include +#include +#include +#include +#include #include #include +#include #include -#include -#include #include +#include +#include #include #include -#include -#include +#include +#include "ModelAPI_Tools.h" #include -#include -#include -#include -#include -#include -#include -#include +#include #include #include -#include -#include #include #include +#include +#include +#include +#include +#include + #define RECURSE_TOP_LEVEL 50 //#define DEBUG_REMOVE_FEATURES @@ -1116,6 +1118,90 @@ std::list referencedFeatures( return aResList; } +void setValues(std::vector& theRGB, const int theRed, const int theGreen, const int theBlue) +{ + theRGB.push_back(theRed); + theRGB.push_back(theGreen); + theRGB.push_back(theBlue); +} + +std::vector HSVtoRGB(int theH, int theS, int theV) +{ + std::vector aRGB; + if (theH < 0 || theH > 360 || + theS < 0 || theS > 100 || + theV < 0 || theV > 100) + return aRGB; + + int aHi = (int)theH/60; + double aV = theV; + double aVmin = (100 - theS)*theV/100; + double anA = (theV - aVmin)* (theH % 60) / 60; + double aVinc = aVmin + anA; + double aVdec = theV - anA; + double aPercentToValue = 255./100; + int aV_int = (int)(aV*aPercentToValue); + int aVinc_int = (int)(aVinc*aPercentToValue); + int aVmin_int = (int)(aVmin*aPercentToValue); + int aVdec_int = (int)(aVdec*aPercentToValue); + + switch(aHi) { + case 0: setValues(aRGB, aV_int, aVinc_int, aVmin_int); break; + case 1: setValues(aRGB, aVdec_int, aV_int, aVmin_int); break; + case 2: setValues(aRGB, aVmin_int, aV_int, aVinc_int); break; + case 3: setValues(aRGB, aVmin_int, aVdec_int, aV_int); break; + case 4: setValues(aRGB, aVinc_int, aVmin_int, aV_int); break; + case 5: setValues(aRGB, aV_int, aVmin_int, aVdec_int); break; + default: break; + } + return aRGB; +} + +std::array, 10> myColorTab = { + std::vector {255, 0, 0}, + std::vector {0, 255, 0}, + std::vector {0, 0, 255}, + std::vector {255, 255, 0}, + std::vector {0, 255, 255}, + std::vector {255, 0, 255}, + std::vector {255, 94, 0}, + std::vector {132, 255, 0}, + std::vector {132, 0, 255}, + std::vector {0, 0, 0}, +}; + +void findRandomColor(std::vector& theValues, bool theReset) +{ + static int i = 0; + static std::vector> usedGeneratedColor; + + // True when disabling auto-color + if ( theReset ) { + i = 0; + return; + } + + theValues.clear(); + if (i < myColorTab.size()) { + theValues = myColorTab[i++]; + } else { + int timeout = 0; + std::vector aHSVColor; + std::vector aRGBColor; + do { + aHSVColor = {rand() % 360 , rand() % (100 - 50 + 1) + 50, rand() % (100 - 50 + 1) + 50}; + aRGBColor = HSVtoRGB(aHSVColor[0], aHSVColor[1], aHSVColor[2]); + timeout++; + } while ( + timeout < 20 && + std::find(usedGeneratedColor.begin(), usedGeneratedColor.end(), aHSVColor) + != usedGeneratedColor.end() && + std::find(myColorTab.begin(), myColorTab.end(), aRGBColor) != myColorTab.end()); + usedGeneratedColor.push_back(aHSVColor); + theValues = aRGBColor; + } +} + // LCOV_EXCL_STOP } // namespace ModelAPI_Tools diff --git a/src/ModelAPI/ModelAPI_Tools.h b/src/ModelAPI/ModelAPI_Tools.h index e740cd1c9..79d4f4a8b 100644 --- a/src/ModelAPI/ModelAPI_Tools.h +++ b/src/ModelAPI/ModelAPI_Tools.h @@ -50,7 +50,7 @@ MODELAPI_EXPORT std::shared_ptr shape( MODELAPI_EXPORT std::string getFeatureError(const std::shared_ptr& theFeature); /*! - * Searches for variable with name \param theName in \param theDocument. + * Searches for variable with name \param theName in \param theDocument. * If found, set it value in the \param outValue and returns true. * theSearcher must be located later in the history than the found variable. */ @@ -302,6 +302,16 @@ MODELAPI_EXPORT void copyVisualizationAttrs(std::shared_ptr the MODELAPI_EXPORT std::list > referencedFeatures( std::shared_ptr theTarget, const std::string& theFeatureKind, const bool theSortResults); + + +/*! Returns a container with the current color value. +* These are tree int values for RGB definition. +* It returns the next random color. +* \param theValues vector of values +* \param theReset flag to call when disabling Auto-color +*/ +MODELAPI_EXPORT void findRandomColor(std::vector& theValues, bool theReset = false); + } #endif diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 78130efca..03809a1e6 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -202,9 +202,13 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) Config_PropManager::registerProp("Visualization", "result_group_color", "Group color", Config_Prop::Color, ModelAPI_ResultGroup::DEFAULT_COLOR()); - Config_PropManager::registerProp("Visualization", - ModelAPI_ResultConstruction::RESULT_COLOR_NAME(), - "Construction color", Config_Prop::Color, ModelAPI_ResultConstruction::DEFAULT_COLOR()); + Config_PropManager::registerProp("Visualization", "result_group_auto_color", "Auto color", + Config_Prop::Boolean, "false"); + + Config_PropManager::registerProp("Visualization", "result_construction_color", + "Construction color", + Config_Prop::Color, + ModelAPI_ResultConstruction::DEFAULT_COLOR()); Config_PropManager::registerProp("Visualization", "result_part_color", "Part color", Config_Prop::Color, ModelAPI_ResultPart::DEFAULT_COLOR()); diff --git a/src/XGUI/XGUI_ColorDialog.cpp b/src/XGUI/XGUI_ColorDialog.cpp index a3cabb6ff..a37df57fb 100644 --- a/src/XGUI/XGUI_ColorDialog.cpp +++ b/src/XGUI/XGUI_ColorDialog.cpp @@ -84,108 +84,13 @@ std::vector XGUI_ColorDialog::getColor() const return aValues; } -// contains global cash for integer index of the color -> RGB of this color -static std::map > myColorMap; - -void appendValues(std::vector& theRGB, const int theRed, const int theGreen, const int theBlue) -{ - theRGB.push_back(theRed); - theRGB.push_back(theGreen); - theRGB.push_back(theBlue); -} - -bool containsValues(std::map >& theColorMap, std::vector& theValues) -{ - std::map >::const_iterator anIt = theColorMap.begin(), - aLast = theColorMap.end(); - bool isFound = false; - for (; anIt != aLast && !isFound; anIt++) { - std::vector aValues = anIt->second; - isFound = aValues[0] == theValues[0] && - aValues[1] == theValues[1] && - aValues[2] == theValues[2]; - } - return isFound; -} - -std::vector HSVtoRGB(int theH, int theS, int theV) -{ - std::vector aRGB; - if (theH < 0 || theH > 360 || - theS < 0 || theS > 100 || - theV < 0 || theV > 100) - return aRGB; - - int aHi = (int)theH/60; - - double aV = theV; - double aVmin = (100 - theS)*theV/100; - - double anA = (theV - aVmin)* (theH % 60) / 60; - - double aVinc = aVmin + anA; - double aVdec = theV - anA; - - double aPercentToValue = 255./100; - int aV_int = (int)(aV*aPercentToValue); - int aVinc_int = (int)(aVinc*aPercentToValue); - int aVmin_int = (int)(aVmin*aPercentToValue); - int aVdec_int = (int)(aVdec*aPercentToValue); - - switch(aHi) { - case 0: appendValues(aRGB, aV_int, aVinc_int, aVmin_int); break; - case 1: appendValues(aRGB, aVdec_int, aV_int, aVmin_int); break; - case 2: appendValues(aRGB, aVmin_int, aV_int, aVinc_int); break; - case 3: appendValues(aRGB, aVmin_int, aVdec_int, aV_int); break; - case 4: appendValues(aRGB, aVinc_int, aVmin_int, aV_int); break; - case 5: appendValues(aRGB, aV_int, aVmin_int, aVdec_int); break; - default: break; - } - return aRGB; -} - - -void fillColorMap() -{ - if (!myColorMap.empty()) - return; - - int i = 0; - for (int s = 100; s > 0; s = s - 50) - { - for (int v = 100; v >= 40; v = v - 20) - { - for (int h = 0; h < 359 ; h = h + 60) - { - std::vector aColor = HSVtoRGB(h, s, v); - if (containsValues(myColorMap, aColor)) - continue; - myColorMap[i] = aColor; - i++; - } - } - } -} - -void findRandomColor(std::vector& theValues) -{ - theValues.clear(); - if (myColorMap.empty()) { - fillColorMap(); - } - - size_t aSize = myColorMap.size(); - int anIndex = rand() % aSize; - if (myColorMap.find(anIndex) != myColorMap.end()) { - theValues = myColorMap.at(anIndex); - } -} std::vector XGUI_ColorDialog::getRandomColor() const { std::vector aValues; if (isRandomColor()) { - findRandomColor(aValues); + ModelAPI_Tools::findRandomColor(aValues); } return aValues; } + diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 6e1d82e5d..4b8ff6d51 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -85,71 +85,74 @@ void XGUI_ContextMenuMgr::createActions() QMainWindow* aDesktop = myWorkshop->mainWindow(); #endif - QAction* aAction = ModuleBase_Tools::createAction(QIcon(":pictures/delete.png"), tr("Delete"), + QAction* anAction = ModuleBase_Tools::createAction(QIcon(":pictures/delete.png"), tr("Delete"), aDesktop); - aDesktop->addAction(aAction); + aDesktop->addAction(anAction); - addAction("DELETE_CMD", aAction); - aAction->setShortcutContext(Qt::ApplicationShortcut); + addAction("DELETE_CMD", anAction); + anAction->setShortcutContext(Qt::ApplicationShortcut); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/rename_edit.png"), tr("Rename"), + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/rename_edit.png"), tr("Rename"), aDesktop, this, SLOT(onRename())); - aAction->setShortcut(Qt::Key_F2); - addAction("RENAME_CMD", aAction); + anAction->setShortcut(Qt::Key_F2); + addAction("RENAME_CMD", anAction); #ifdef HAVE_SALOME - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/move_to_end.png"), + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/move_to_end.png"), XGUI_Workshop::MOVE_TO_END_COMMAND, this); - addAction("MOVE_CMD", aAction); + addAction("MOVE_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/move_to_end_split.png"), + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/move_to_end_split.png"), XGUI_Workshop::MOVE_TO_END_SPLIT_COMMAND, this); - addAction("MOVE_SPLIT_CMD", aAction); + addAction("MOVE_SPLIT_CMD", anAction); #endif - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/clean_history.png"), + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/clean_history.png"), tr("Clean history"), aDesktop); - addAction("CLEAN_HISTORY_CMD", aAction); + addAction("CLEAN_HISTORY_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/color.png"), tr("Color..."), aDesktop); - addAction("COLOR_CMD", aAction); + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/color.png"), tr("Color..."), aDesktop); + addAction("COLOR_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(""), tr("Deflection..."), aDesktop); - addAction("DEFLECTION_CMD", aAction); + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/autocolor.png"), tr("Auto color"), aDesktop); + addAction("AUTOCOLOR_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/transparency.png"), + anAction = ModuleBase_Tools::createAction(QIcon(""), tr("Deflection..."), aDesktop); + addAction("DEFLECTION_CMD", anAction); + + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/transparency.png"), tr("Transparency..."), aDesktop); - addAction("TRANSPARENCY_CMD", aAction); + addAction("TRANSPARENCY_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/eye_pencil.png"), tr("Show"), aDesktop); - addAction("SHOW_CMD", aAction); + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/eye_pencil.png"), tr("Show"), aDesktop); + addAction("SHOW_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/eye_pencil.png"), tr("Show only"), + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/eye_pencil.png"), tr("Show only"), aDesktop); - addAction("SHOW_ONLY_CMD", aAction); + addAction("SHOW_ONLY_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/eye_pencil_closed.png"), tr("Hide"), + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/eye_pencil_closed.png"), tr("Hide"), aDesktop); - addAction("HIDE_CMD", aAction); + addAction("HIDE_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/eye_pencil_closed.png"), tr("Hide all"), + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/eye_pencil_closed.png"), tr("Hide all"), aDesktop); - addAction("HIDEALL_CMD", aAction); + addAction("HIDEALL_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/shading.png"), tr("Shading"), aDesktop); - addAction("SHADING_CMD", aAction); + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/shading.png"), tr("Shading"), aDesktop); + addAction("SHADING_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/wireframe.png"), tr("Wireframe"), + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/wireframe.png"), tr("Wireframe"), aDesktop); - addAction("WIREFRAME_CMD", aAction); + addAction("WIREFRAME_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/iso_lines.png"), tr("Define Isos..."), + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/iso_lines.png"), tr("Define Isos..."), aDesktop); - addAction("ISOLINES_CMD", aAction); + addAction("ISOLINES_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(), tr("Show Isos"), aDesktop); - aAction->setCheckable(true); - addAction("SHOW_ISOLINES_CMD", aAction); + anAction = ModuleBase_Tools::createAction(QIcon(), tr("Show Isos"), aDesktop); + anAction->setCheckable(true); + addAction("SHOW_ISOLINES_CMD", anAction); mySeparator1 = ModuleBase_Tools::createAction(QIcon(), "", aDesktop); mySeparator1->setSeparator(true); @@ -160,69 +163,69 @@ void XGUI_ContextMenuMgr::createActions() mySeparator3 = ModuleBase_Tools::createAction(QIcon(), "", aDesktop); mySeparator3->setSeparator(true); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/vertex.png"), tr("Vertices"), aDesktop, + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/vertex.png"), tr("Vertices"), aDesktop, this, SLOT(onShapeSelection(bool))); - aAction->setCheckable(true); - addAction("SELECT_VERTEX_CMD", aAction); + anAction->setCheckable(true); + addAction("SELECT_VERTEX_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/edge.png"), tr("Edges"), aDesktop, + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/edge.png"), tr("Edges"), aDesktop, this, SLOT(onShapeSelection(bool))); - aAction->setCheckable(true); - addAction("SELECT_EDGE_CMD", aAction); + anAction->setCheckable(true); + addAction("SELECT_EDGE_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/face.png"), tr("Faces"), aDesktop, + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/face.png"), tr("Faces"), aDesktop, this, SLOT(onShapeSelection(bool))); - aAction->setCheckable(true); - addAction("SELECT_FACE_CMD", aAction); + anAction->setCheckable(true); + addAction("SELECT_FACE_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/result.png"), tr("Results"), aDesktop, + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/result.png"), tr("Results"), aDesktop, this, SLOT(onResultSelection(bool))); - aAction->setCheckable(true); - addAction("SELECT_RESULT_CMD", aAction); + anAction->setCheckable(true); + addAction("SELECT_RESULT_CMD", anAction); - aAction->setChecked(true); + anAction->setChecked(true); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/find_result.png"), + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/find_result.png"), tr("Select results"), aDesktop); - addAction("SHOW_RESULTS_CMD", aAction); + addAction("SHOW_RESULTS_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/find_result.png"), + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/find_result.png"), tr("Select parent feature"), aDesktop); - addAction("SHOW_FEATURE_CMD", aAction); + addAction("SHOW_FEATURE_CMD", anAction); #ifdef TINSPECTOR - aAction = ModuleBase_Tools::createAction(QIcon(), tr("TInspector"), aDesktop); - addAction("TINSPECTOR_VIEW", aAction); + anAction = ModuleBase_Tools::createAction(QIcon(), tr("TInspector"), aDesktop); + addAction("TINSPECTOR_VIEW", anAction); #endif // Features folders actions - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/create_folder.png"), + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/create_folder.png"), tr("Insert a folder before"), aDesktop); - addAction("INSERT_FOLDER_CMD", aAction); + addAction("INSERT_FOLDER_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/insert_folder_before.png"), + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/insert_folder_before.png"), tr("Move into the previous folder"), aDesktop); - addAction("ADD_TO_FOLDER_BEFORE_CMD", aAction); + addAction("ADD_TO_FOLDER_BEFORE_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/insert_folder_after.png"), + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/insert_folder_after.png"), tr("Move into the next folder"), aDesktop); - addAction("ADD_TO_FOLDER_AFTER_CMD", aAction); + addAction("ADD_TO_FOLDER_AFTER_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/move_out_before.png"), + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/move_out_before.png"), tr("Move out before the folder"), aDesktop); - addAction("ADD_OUT_FOLDER_BEFORE_CMD", aAction); + addAction("ADD_OUT_FOLDER_BEFORE_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/move_out_after.png"), + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/move_out_after.png"), tr("Move out after the folder"), aDesktop); - addAction("ADD_OUT_FOLDER_AFTER_CMD", aAction); + addAction("ADD_OUT_FOLDER_AFTER_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/normal-view-inversed.png"), + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/normal-view-inversed.png"), tr("Set view by inverted normal to face"), aDesktop); - addAction("SET_VIEW_INVERTEDNORMAL_CMD", aAction); + addAction("SET_VIEW_INVERTEDNORMAL_CMD", anAction); - aAction = ModuleBase_Tools::createAction(QIcon(":pictures/normal-view.png"), + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/normal-view.png"), tr("Set view by normal to face"), aDesktop); - addAction("SET_VIEW_NORMAL_CMD", aAction); + addAction("SET_VIEW_NORMAL_CMD", anAction); buildObjBrowserMenu(); buildViewerMenu(); @@ -261,8 +264,8 @@ QStringList XGUI_ContextMenuMgr::actionIds() const void XGUI_ContextMenuMgr::onAction(bool isChecked) { - QAction* aAction = static_cast(sender()); - emit actionTriggered(aAction->data().toString(), isChecked); + QAction* anAction = static_cast(sender()); + emit actionTriggered(anAction->data().toString(), isChecked); } void XGUI_ContextMenuMgr::updateCommandsStatus() @@ -293,8 +296,8 @@ void XGUI_ContextMenuMgr::onContextMenuRequest(QContextMenuEvent* theEvent) void XGUI_ContextMenuMgr::updateObjectBrowserMenu() { - foreach(QAction* aAction, myActions) - aAction->setEnabled(false); + foreach(QAction* anAction, myActions) + anAction->setEnabled(false); XGUI_SelectionMgr* aSelMgr = myWorkshop->selector(); QObjectPtrList aObjects = aSelMgr->selection()->selectedObjects(); @@ -506,6 +509,8 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() action("COLOR_CMD")->setEnabled(myWorkshop->canChangeProperty("COLOR_CMD")); action("DEFLECTION_CMD")->setEnabled(myWorkshop->canChangeProperty("DEFLECTION_CMD")); action("TRANSPARENCY_CMD")->setEnabled(myWorkshop->canChangeProperty("TRANSPARENCY_CMD")); + action("AUTOCOLOR_CMD")->setEnabled(myWorkshop->canChangeProperty("AUTOCOLOR_CMD")); + #ifdef _DEBUG #ifdef TINSPECTOR action("TINSPECTOR_VIEW")->setEnabled(true); @@ -520,8 +525,8 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() void XGUI_ContextMenuMgr::updateViewerMenu() { - foreach(QAction* aAction, myActions) - aAction->setEnabled(false); + foreach(QAction* anAction, myActions) + anAction->setEnabled(false); XGUI_SelectionMgr* aSelMgr = myWorkshop->selector(); XGUI_Displayer* aDisplayer = myWorkshop->displayer(); @@ -685,10 +690,31 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu() aList.append(action("DELETE_CMD")); myObjBrowserMenus[ModelAPI_ResultBody::group()] = aList; // Group menu - myObjBrowserMenus[ModelAPI_ResultGroup::group()] = aList; myObjBrowserMenus[ModelAPI_ResultField::group()] = aList; // Result part menu myObjBrowserMenus[ModelAPI_ResultPart::group()] = aList; + + aList.clear(); + aList.append(action("WIREFRAME_CMD")); + aList.append(action("SHADING_CMD")); + aList.append(mySeparator1); // this separator is not shown as this action is added after show only + // qt list container contains only one instance of the same action + aList.append(action("SHOW_CMD")); + aList.append(action("HIDE_CMD")); + aList.append(action("SHOW_ONLY_CMD")); + aList.append(mySeparator2); + aList.append(action("AUTOCOLOR_CMD")); + aList.append(action("RENAME_CMD")); + aList.append(action("COLOR_CMD")); + aList.append(action("DEFLECTION_CMD")); + aList.append(action("TRANSPARENCY_CMD")); + aList.append(action("SHOW_ISOLINES_CMD")); + aList.append(action("ISOLINES_CMD")); + aList.append(action("SHOW_FEATURE_CMD")); + aList.append(mySeparator3); + aList.append(action("DELETE_CMD")); + // Group menu + myObjBrowserMenus[ModelAPI_ResultGroup::group()] = aList; //------------------------------------- // Feature menu aList.clear(); @@ -786,43 +812,43 @@ void XGUI_ContextMenuMgr::addObjBrowserMenu(QMenu* theMenu) const XGUI_SelectionMgr* aSelMgr = myWorkshop->selector(); QObjectPtrList aObjects = aSelMgr->selection()->selectedObjects(); int aSelected = aObjects.size(); - QActionsList aActions; + QActionsList anActions; if (aSelected == 1) { ObjectPtr aObject = aObjects.first(); std::string aName = aObject->groupName(); if (myObjBrowserMenus.contains(aName)) - aActions = myObjBrowserMenus[aName]; + anActions = myObjBrowserMenus[aName]; } else if (aSelected > 1) { - aActions.append(action("WIREFRAME_CMD")); - aActions.append(action("SHADING_CMD")); - aActions.append(mySeparator1); - aActions.append(action("SHOW_CMD")); - aActions.append(action("HIDE_CMD")); - aActions.append(action("SHOW_ONLY_CMD")); - aActions.append(mySeparator2); - aActions.append(action("ADD_TO_FOLDER_BEFORE_CMD")); - aActions.append(action("ADD_TO_FOLDER_AFTER_CMD")); - aActions.append(action("ADD_OUT_FOLDER_BEFORE_CMD")); - aActions.append(action("ADD_OUT_FOLDER_AFTER_CMD")); - aActions.append(mySeparator3); - aActions.append(action("MOVE_CMD")); - aActions.append(action("MOVE_SPLIT_CMD")); - aActions.append(action("COLOR_CMD")); - aActions.append(action("DEFLECTION_CMD")); - aActions.append(action("TRANSPARENCY_CMD")); - aActions.append(action("SHOW_ISOLINES_CMD")); - aActions.append(action("ISOLINES_CMD")); - aActions.append(action("CLEAN_HISTORY_CMD")); - aActions.append(action("DELETE_CMD")); + anActions.append(action("WIREFRAME_CMD")); + anActions.append(action("SHADING_CMD")); + anActions.append(mySeparator1); + anActions.append(action("SHOW_CMD")); + anActions.append(action("HIDE_CMD")); + anActions.append(action("SHOW_ONLY_CMD")); + anActions.append(mySeparator2); + anActions.append(action("ADD_TO_FOLDER_BEFORE_CMD")); + anActions.append(action("ADD_TO_FOLDER_AFTER_CMD")); + anActions.append(action("ADD_OUT_FOLDER_BEFORE_CMD")); + anActions.append(action("ADD_OUT_FOLDER_AFTER_CMD")); + anActions.append(mySeparator3); + anActions.append(action("MOVE_CMD")); + anActions.append(action("MOVE_SPLIT_CMD")); + anActions.append(action("COLOR_CMD")); + anActions.append(action("DEFLECTION_CMD")); + anActions.append(action("TRANSPARENCY_CMD")); + anActions.append(action("SHOW_ISOLINES_CMD")); + anActions.append(action("ISOLINES_CMD")); + anActions.append(action("CLEAN_HISTORY_CMD")); + anActions.append(action("DELETE_CMD")); } #ifdef _DEBUG if (aSelected == 0) { #ifdef TINSPECTOR - aActions.append(action("TINSPECTOR_VIEW")); + anActions.append(action("TINSPECTOR_VIEW")); #endif } #endif - theMenu->addActions(aActions); + theMenu->addActions(anActions); addFeatures(theMenu); // It is commented out because Object Browser does not have actions @@ -836,7 +862,7 @@ void XGUI_ContextMenuMgr::addViewerMenu(QMenu* theMenu) const QList aPrsList = aSelMgr->selection()->getSelected(ModuleBase_ISelection::Viewer); int aSelected = aPrsList.size(); - QActionsList aActions; + QActionsList anActions; // Create selection menu XGUI_OperationMgr* aOpMgr = myWorkshop->operationMgr(); @@ -857,19 +883,19 @@ void XGUI_ContextMenuMgr::addViewerMenu(QMenu* theMenu) const if (aObject.get() != NULL) { std::string aName = aObject->groupName(); if (myViewerMenu.contains(aName)) - aActions = myViewerMenu[aName]; + anActions = myViewerMenu[aName]; } } else if (aSelected > 1) { - aActions.append(action("COLOR_CMD")); - aActions.append(action("DEFLECTION_CMD")); - aActions.append(action("TRANSPARENCY_CMD")); - aActions.append(mySeparator1); - aActions.append(action("SHOW_ONLY_CMD")); - aActions.append(action("HIDE_CMD")); + anActions.append(action("COLOR_CMD")); + anActions.append(action("DEFLECTION_CMD")); + anActions.append(action("TRANSPARENCY_CMD")); + anActions.append(mySeparator1); + anActions.append(action("SHOW_ONLY_CMD")); + anActions.append(action("HIDE_CMD")); } // hide all is shown always even if selection in the viewer is empty - aActions.append(action("HIDEALL_CMD")); - theMenu->addActions(aActions); + anActions.append(action("HIDEALL_CMD")); + theMenu->addActions(anActions); QMap aMenuActions; ModuleBase_IModule* aModule = myWorkshop->module(); @@ -880,12 +906,12 @@ void XGUI_ContextMenuMgr::addViewerMenu(QMenu* theMenu) const // insert the module menu items on specific positions in the popup menu: some actions should be // in the begin of the list, Delete action should be the last by #1343 issue - QList anActions = theMenu->actions(); - int anActionsSize = anActions.size(); - QAction* aFirstAction = anActions[0]; + QList anActionsList = theMenu->actions(); + int anActionsListSize = anActionsList.size(); + QAction* aFirstAction = anActionsList[0]; QMap::const_iterator anIt = aMenuActions.begin(), aLast = aMenuActions.end(); for (; anIt != aLast; anIt++) { - if (anIt.key() > anActionsSize) + if (anIt.key() > anActionsListSize) theMenu->addAction(anIt.value()); else theMenu->insertAction(aFirstAction, *anIt); @@ -935,10 +961,10 @@ void XGUI_ContextMenuMgr::onRename() void XGUI_ContextMenuMgr::addFeatures(QMenu* theMenu) const { SessionPtr aMgr = ModelAPI_Session::get(); - DocumentPtr aActiveDoc = aMgr->activeDocument(); + DocumentPtr anActiveDoc = aMgr->activeDocument(); XGUI_SelectionMgr* aSelMgr = myWorkshop->selector(); - XGUI_ActionsMgr* aActionMgr = myWorkshop->actionsMgr(); + XGUI_ActionsMgr* anActionMgr = myWorkshop->actionsMgr(); const Config_DataModelReader* aDataModelXML = myWorkshop->dataModelXMLReader(); QModelIndexList aSelectedIndexes = aSelMgr->selection()->selectedIndexes(); @@ -950,7 +976,7 @@ void XGUI_ContextMenuMgr::addFeatures(QMenu* theMenu) const if (aIdx.column() == 1) { aIsRoot = !aIdx.parent().isValid(); // Exit if the selected index belongs to non active document - if (aIsRoot && (aActiveDoc != aMgr->moduleDocument())) + if (aIsRoot && (anActiveDoc != aMgr->moduleDocument())) return; // Get name of the selected index @@ -966,9 +992,9 @@ void XGUI_ContextMenuMgr::addFeatures(QMenu* theMenu) const QStringList aFeturesList = QString(aFeaturesStr.c_str()).split(",", QString::SkipEmptyParts); foreach(QString aFea, aFeturesList) { - QAction* aAction = aActionMgr->action(aFea); - if (aAction) - theMenu->addAction(aAction); + QAction* anAction = anActionMgr->action(aFea); + if (anAction) + theMenu->addAction(anAction); } } } @@ -976,11 +1002,11 @@ void XGUI_ContextMenuMgr::addFeatures(QMenu* theMenu) const } #define UNCHECK_ACTION(NAME) \ -{ QAction* aAction = action(NAME); \ -bool isBlock = aAction->signalsBlocked(); \ -aAction->blockSignals(true); \ -aAction->setChecked(false); \ - aAction->blockSignals(isBlock); } +{ QAction* anAction = action(NAME); \ +bool isBlock = anAction->signalsBlocked(); \ +anAction->blockSignals(true); \ +anAction->setChecked(false); \ + anAction->blockSignals(isBlock); } void XGUI_ContextMenuMgr::onResultSelection(bool theChecked) diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 79ccfdc05..1be4d47c6 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -154,6 +154,7 @@ #include #include +#include #include #ifdef TINSPECTOR @@ -1055,8 +1056,8 @@ void XGUI_Workshop::openFile(const QString& theDirectory) if (aNewPart) { int aSize = aRootDoc->size(ModelAPI_ResultPart::group()); if (aSize > 0 ) { - ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), 0); - ResultPartPtr aPart = std::dynamic_pointer_cast(aObject); + ObjectPtr anObject = aRootDoc->object(ModelAPI_ResultPart::group(), 0); + ResultPartPtr aPart = std::dynamic_pointer_cast(anObject); if (aPart.get()) aPart->activate(); } @@ -1731,7 +1732,7 @@ ModuleBase_IViewer* XGUI_Workshop::salomeViewer() const //************************************************************** void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) { - QObjectPtrList aObjects = mySelector->selection()->selectedObjects(); + QObjectPtrList anObjects = mySelector->selection()->selectedObjects(); if (theId == "DELETE_CMD") deleteObjects(); else if (theId == "CLEAN_HISTORY_CMD") @@ -1739,11 +1740,13 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) else if (theId == "MOVE_CMD" || theId == "MOVE_SPLIT_CMD") moveObjects(theId == "MOVE_SPLIT_CMD"); else if (theId == "COLOR_CMD") - changeColor(aObjects); + changeColor(anObjects); + else if (theId == "AUTOCOLOR_CMD") + changeAutoColor(anObjects); else if (theId == "ISOLINES_CMD") - changeIsoLines(aObjects); + changeIsoLines(anObjects); else if (theId == "SHOW_ISOLINES_CMD") { - foreach(ObjectPtr aObj, aObjects) { + foreach(ObjectPtr aObj, anObjects) { ResultPtr aResult = std::dynamic_pointer_cast(aObj); if (aResult.get()) ModelAPI_Tools::showIsoLines(aResult, !ModelAPI_Tools::isShownIsoLines(aResult)); @@ -1752,27 +1755,27 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); } else if (theId == "DEFLECTION_CMD") - changeDeflection(aObjects); + changeDeflection(anObjects); else if (theId == "TRANSPARENCY_CMD") - changeTransparency(aObjects); + changeTransparency(anObjects); else if (theId == "SHOW_CMD") { - showObjects(aObjects, true); + showObjects(anObjects, true); mySelector->updateSelectionBy(ModuleBase_ISelection::Browser); updateCommandStatus(); } else if (theId == "HIDE_CMD") { - showObjects(aObjects, false); + showObjects(anObjects, false); updateCommandStatus(); } else if (theId == "SHOW_ONLY_CMD") { - showOnlyObjects(aObjects); + showOnlyObjects(anObjects); mySelector->updateSelectionBy(ModuleBase_ISelection::Browser); updateCommandStatus(); } else if (theId == "SHADING_CMD") - setDisplayMode(aObjects, XGUI_Displayer::Shading); + setDisplayMode(anObjects, XGUI_Displayer::Shading); else if (theId == "WIREFRAME_CMD") - setDisplayMode(aObjects, XGUI_Displayer::Wireframe); + setDisplayMode(anObjects, XGUI_Displayer::Wireframe); else if (theId == "HIDEALL_CMD") { QObjectPtrList aList = myDisplayer->displayedObjects(); foreach (ObjectPtr aObj, aList) { @@ -1809,9 +1812,9 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) setViewerSelectionMode(ModuleBase_ResultPrs::Sel_Result); setViewerSelectionMode(TopAbs_COMPSOLID); } else if (theId == "SHOW_RESULTS_CMD") { - highlightResults(aObjects); + highlightResults(anObjects); } else if (theId == "SHOW_FEATURE_CMD") { - highlightFeature(aObjects); + highlightFeature(anObjects); } else if (theId == "SET_VIEW_NORMAL_CMD") { setNormalView(); } else if (theId == "SET_VIEW_INVERTEDNORMAL_CMD") { @@ -2313,9 +2316,9 @@ std::list toCurrentFeatures(const ObjectPtr& theObject) DocumentPtr aDocument = theObject->document(); std::list anAllFeatures = allFeatures(aDocument); // find the object iterator - std::list::iterator aObjectIt = + std::list::iterator anObjectIt = std::find(anAllFeatures.begin(), anAllFeatures.end(), theObject); - if (aObjectIt == anAllFeatures.end()) + if (anObjectIt == anAllFeatures.end()) return aResult; // find the current feature iterator std::list::iterator aCurrentIt = @@ -2323,14 +2326,14 @@ std::list toCurrentFeatures(const ObjectPtr& theObject) if (aCurrentIt == anAllFeatures.end()) return aResult; // check the right order - if (std::distance(aObjectIt, anAllFeatures.end()) <= + if (std::distance(anObjectIt, anAllFeatures.end()) <= std::distance(aCurrentIt, anAllFeatures.end())) return aResult; // exclude the object - std::advance(aObjectIt, 1); + std::advance(anObjectIt, 1); // include the current feature std::advance(aCurrentIt, 1); - return std::list(aObjectIt, aCurrentIt); + return std::list(anObjectIt, aCurrentIt); } //****************************************************** @@ -2338,29 +2341,29 @@ bool XGUI_Workshop::canMoveFeature() { QString anActionId = "MOVE_CMD"; - QObjectPtrList aObjects = mySelector->selection()->selectedObjects(); + QObjectPtrList anObjects = mySelector->selection()->selectedObjects(); QObjectPtrList aValidatedObjects; - foreach (ObjectPtr aObject, aObjects) { - if (!myModule->canApplyAction(aObject, anActionId)) + foreach (ObjectPtr anObject, anObjects) { + if (!myModule->canApplyAction(anObject, anActionId)) continue; // To be moved feature should be in active document - if (aObject->document() != ModelAPI_Session::get()->activeDocument()) + if (anObject->document() != ModelAPI_Session::get()->activeDocument()) continue; - aValidatedObjects.append(aObject); + aValidatedObjects.append(anObject); } - if (aValidatedObjects.size() != aObjects.size()) - aObjects = aValidatedObjects; + if (aValidatedObjects.size() != anObjects.size()) + anObjects = aValidatedObjects; - bool aCanMove = !aObjects.empty(); + bool aCanMove = !anObjects.empty(); - QObjectPtrList::const_iterator anIt = aObjects.begin(), aLast = aObjects.end(); + QObjectPtrList::const_iterator anIt = anObjects.begin(), aLast = anObjects.end(); for (; anIt != aLast && aCanMove; anIt++) { - ObjectPtr aObject = *anIt; - if (!aObject.get() || !aObject->data().get() || !aObject->data()->isValid()) { + ObjectPtr anObject = *anIt; + if (!anObject.get() || !anObject->data().get() || !anObject->data()->isValid()) { aCanMove = false; break; } - FeaturePtr aFeat = std::dynamic_pointer_cast(aObject); + FeaturePtr aFeat = std::dynamic_pointer_cast(anObject); // only groups can be moved to the end for now (#2451) if (aFeat.get() && aFeat->getKind() != "Group") { aCanMove = false; @@ -2368,15 +2371,15 @@ bool XGUI_Workshop::canMoveFeature() } // 1. Get features placed between selected and current in the document - std::list aFeaturesBetween = toCurrentFeatures(aObject); - // if aFeaturesBetween is empty it means wrong order or aObject is the current feature + std::list aFeaturesBetween = toCurrentFeatures(anObject); + // if aFeaturesBetween is empty it means wrong order or anObject is the current feature if (aFeaturesBetween.empty()) aCanMove = false; else { std::set aPlacedFeatures(aFeaturesBetween.begin(), aFeaturesBetween.end()); // 2. Get all reference features to the selected object in the document std::set aRefFeatures; - ModuleBase_Tools::refsToFeatureInFeatureDocument(aObject, aRefFeatures); + ModuleBase_Tools::refsToFeatureInFeatureDocument(anObject, aRefFeatures); if (aRefFeatures.empty()) continue; @@ -2419,7 +2422,7 @@ bool XGUI_Workshop::canChangeProperty(const QString& theActionName) const if (theActionName == "COLOR_CMD" || theActionName == "DEFLECTION_CMD" || theActionName == "TRANSPARENCY_CMD") { - QObjectPtrList aObjects = mySelector->selection()->selectedObjects(); + QObjectPtrList anObjects = mySelector->selection()->selectedObjects(); std::set aTypes; aTypes.insert(ModelAPI_ResultGroup::group()); @@ -2427,7 +2430,16 @@ bool XGUI_Workshop::canChangeProperty(const QString& theActionName) const aTypes.insert(ModelAPI_ResultBody::group()); aTypes.insert(ModelAPI_ResultPart::group()); - return hasResults(aObjects, aTypes); + return hasResults(anObjects, aTypes); + } + if (theActionName == "AUTOCOLOR_CMD") { + + QObjectPtrList anObjects = mySelector->selection()->selectedObjects(); + + std::set aTypes; + aTypes.insert(ModelAPI_ResultGroup::group()); + + return hasResults(anObjects, aTypes); } return false; } @@ -2497,6 +2509,7 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects) // 3. abort the previous operation and start a new one SessionPtr aMgr = ModelAPI_Session::get(); QString aDescription = contextMenuMgr()->action("COLOR_CMD")->text(); + aMgr->startOperation(aDescription.toStdString()); // 4. set the value to all results @@ -2521,6 +2534,62 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects) myViewerProxy->update(); } +//************************************************************** +void XGUI_Workshop::changeAutoColor(const QObjectPtrList& theObjects) +{ + if (!abortAllOperations()) + return; + + std::vector aColor; + + // abort the previous operation and start a new one + SessionPtr aMgr = ModelAPI_Session::get(); + QString aDescription = contextMenuMgr()->action("AUTOCOLOR_CMD")->text(); + aMgr->startOperation(aDescription.toStdString()); + + Config_Prop* aProp = Config_PropManager::findProp("Visualization", "result_group_auto_color"); + + if (aProp) { + bool anIsAutoColor = Config_PropManager::boolean("Visualization", "result_group_auto_color"); + + if (anIsAutoColor) { + contextMenuMgr()->action("AUTOCOLOR_CMD")->setText(tr("Auto color")); + aProp->setValue("false"); + ModelAPI_Tools::findRandomColor(aColor, true); + } else { + // set the value to all results + foreach (ObjectPtr anObj, theObjects) { + DocumentPtr aDocument = anObj->document(); + std::list anAllFeatures = allFeatures(aDocument); + // find the object iterator + std::list::iterator anObjectIt = anAllFeatures.begin(); + for (; anObjectIt != anAllFeatures.end(); ++ anObjectIt) { + FeaturePtr aFeature = *anObjectIt; + if (aFeature.get()) { + std::list aResults; + ModelAPI_Tools::allResults(aFeature, aResults); + std::list >::const_iterator aIt; + for (aIt = aResults.cbegin(); aIt != aResults.cend(); aIt++) { + ResultPtr aGroupResult = *aIt; + if (aGroupResult.get() && + aGroupResult->groupName() == ModelAPI_ResultGroup::group()) { + ModelAPI_Tools::findRandomColor(aColor); + ModelAPI_Tools::setColor(aGroupResult, aColor); + } + } + } + } + } + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); + aMgr->finishOperation(); + updateCommandStatus(); + myViewerProxy->update(); + contextMenuMgr()->action("AUTOCOLOR_CMD")->setText(tr("Disable auto color")); + aProp->setValue("true"); + } + } +} + //************************************************************** void setTransparency(double theTransparency, const QObjectPtrList& theObjects) { @@ -2775,11 +2844,11 @@ void XGUI_Workshop::showOnlyObjects(const QObjectPtrList& theList) //************************************************************** void XGUI_Workshop::updateColorScaleVisibility() { - QObjectPtrList aObjects = mySelector->selection()->selectedObjects(); + QObjectPtrList anObjects = mySelector->selection()->selectedObjects(); viewer()->setColorScaleShown(false); - if (aObjects.size() == 1) { + if (anObjects.size() == 1) { FieldStepPtr aStep = - std::dynamic_pointer_cast(aObjects.first()); + std::dynamic_pointer_cast(anObjects.first()); if (aStep.get() && myDisplayer->isVisible(aStep)) { AISObjectPtr aAisPtr = myDisplayer->getAISObject(aStep); Handle(AIS_InteractiveObject) aIO = aAisPtr->impl(); @@ -3093,10 +3162,10 @@ void XGUI_Workshop::highlightFeature(const QObjectPtrList& theObjects) void XGUI_Workshop::insertFeatureFolder() { - QObjectPtrList aObjects = mySelector->selection()->selectedObjects(); - if (aObjects.isEmpty()) + QObjectPtrList anObjects = mySelector->selection()->selectedObjects(); + if (anObjects.isEmpty()) return; - ObjectPtr aObj = aObjects.first(); + ObjectPtr aObj = anObjects.first(); FeaturePtr aFeature = std::dynamic_pointer_cast(aObj); if (aFeature.get() == NULL) return; diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 7b996aaa4..3050590c0 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -203,6 +203,11 @@ Q_OBJECT /// theObjects a list of selected objects void changeColor(const QObjectPtrList& theObjects); + /// Change Autocolor of the results if it is possible + /// The operation is available for group results + /// theObjects a list of selected objects + void changeAutoColor(const QObjectPtrList& theObjects); + /// Change deflection of the results if it is possible /// The operation is available for construction, body and group results /// theObjects a list of selected objects @@ -440,7 +445,7 @@ signals: /// Sets the granted operations for the parameter operation. Firstly, it finds the nested features /// and set them into the operation. Secondly, it asks the module about ids of granted operations. /// \param theOperation an operation - void setGrantedFeatures(ModuleBase_Operation* theOperation); + void setGrantedFeatures(ModuleBase_Operation* theOperation); private: /// Display results from document diff --git a/src/XGUI/XGUI_pictures.qrc b/src/XGUI/XGUI_pictures.qrc index 1225bcc32..dd81c3b93 100644 --- a/src/XGUI/XGUI_pictures.qrc +++ b/src/XGUI/XGUI_pictures.qrc @@ -88,6 +88,7 @@ pictures/add.png pictures/reverce.png pictures/color.png + pictures/autocolor.png pictures/normal-view-inversed.png pictures/normal-view.png pictures/move_to_end.png diff --git a/src/XGUI/pictures/autocolor.png b/src/XGUI/pictures/autocolor.png new file mode 100644 index 0000000000000000000000000000000000000000..1248b0b9233d05c17ccfc66847df39876be87a45 GIT binary patch literal 801 zcmV++1K#|JP)EX>4Tx04R}tkv&MmKpe$iQ>9fZ4t6NwkfAzR5EXIMDionYs1;guFuC*#ni!H4 z7e~Rh;NZt%)xpJCR|i)?5c~jfb8}L3krMxx6k5c1aNLh~_a1le0HIN3n$)S(glehxvqHp#<}FOz%!#}HZw;YB^FB^taLCdn;P*Xaa`4O$`^7T ztDLtuYtq2l^-JVZ$W;L& z$2>NmL3aJ%fAG6ot2i<4B}I}z_lx6v3|w}Ff6wx;X>mpef0$&gLim4Y;dVi9;hqi@Os1Ghl$s@Gd)$1|AE6Hq_Vnuo)@#9&st-XKoUPi!z98CPcm!2IVX&-+u)(SjWH?LTCtFl*a)l~ zH0HSxJq4b-H-Q|zg?5e+X$}C3)w-pmcnmyuYn)uFwfgU&T^P-LxpGv}LV1Dbu1~T# zDFXl>D)wR!71pZtewHkR%Jo7!pXQu^*WUg04gfQ&V5xE}0kAY@_+$Qgfl$)m)5_(A ziF}v!B~SgX)A`*EG-$)RjD!|ve%HB4Jd!RJ4^Lvon9e+ymS#K{ fG(YaH+DZNm7j12@kcDpU00000NkvXXu0mjf0rO)> literal 0 HcmV?d00001 -- 2.39.2