]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'nrn/Lot2/AutoColor' into master
authorazv <azv@opencascade.com>
Wed, 13 Oct 2021 06:43:57 +0000 (09:43 +0300)
committerazv <azv@opencascade.com>
Wed, 13 Oct 2021 06:43:57 +0000 (09:43 +0300)
14 files changed:
doc/gui/General/Introduction.rst
doc/gui/images/popup_menu_object_browser_group.png [new file with mode: 0644]
src/Config/Config_PropManager.cpp
src/Config/Config_PropManager.h
src/ModelAPI/ModelAPI_Feature.cpp
src/ModelAPI/ModelAPI_Tools.cpp
src/ModelAPI/ModelAPI_Tools.h
src/PartSet/PartSet_Module.cpp
src/XGUI/XGUI_ColorDialog.cpp
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h
src/XGUI/XGUI_pictures.qrc
src/XGUI/pictures/autocolor.png [new file with mode: 0644]

index 2260fbf14c13e6f6373be407a53ea7126af4fb2c..35e17284c3f8df4180ac7fb4ebe704862081b62a 100644 (file)
@@ -8,11 +8,11 @@ SHAPER module of SALOME is destined for:
 
 - import and export of geometrical models in IGES, BREP, STEP and XAO formats;
 - parametric construction of geometrical objects using a wide range of functions:
-    
+
   - creation of complex 2D sections using :ref:`sketchPlugin` with consequent extrusion or revolution (see :ref:`featuresPlugin`);
   - construction of model using primitives defined in :ref:`primitivesPlugin`;
   - usage of Boolean operations (see :ref:`featuresPlugin`);
-  
+
 - viewing geometrical objects in the OCC viewer;
 - transformation of geometrical objects using various algorithms.
 
@@ -28,16 +28,16 @@ SHAPER module works with one study containing several documents:
 - one or several parts.
 
 Only one document can be active. In complicated models partset consists of several parts. Parts in partset may be copied, positioned relatively to each other, or simply translated.
-  
+
 A new study contains only a partset with 7 default constructions, which cannot be deleted:
-  
+
 - one point **Origin** coinciding with the origin of the coordinate system;
 - three axes **OX**, **OY**, **OZ**  coinciding with coordinate axes;
-- three planes **YOZ**, **XOZ**, **XOY**  coinciding with coordinate planes.    
+- three planes **YOZ**, **XOZ**, **XOY**  coinciding with coordinate planes.
 
 Only  points, axis, planes (see  :ref:`constructionPlugin`) and sketches (see  :ref:`sketchPlugin`) can be added into Partset to be used in any part later.
 :ref:`parameter_usage` can be used both in Partset and any Part.
-    
+
 A new Part can be created as described in :ref:`partPlugin`.
 
 Double click or pop-up menu can be used to activate existing document.
@@ -50,17 +50,17 @@ The main window of the application consists of the following components:
 - :ref:`main_menu`;
 - :ref:`doc_windows`;
 - :ref:`viewer`;
-- :ref:`toolbar`;    
-- status bar.    
+- :ref:`toolbar`;
+- status bar.
 
 .. figure:: /images/main_window.png
    :align: center
 
    Main window of SHAPER module
-  
+
 .. _main_menu:
 
-Main menu 
+Main menu
 ---------
 
 Main menu provides access to all commands of the application.
@@ -78,7 +78,7 @@ Main menu includes standard Salome items:
 - Tools;
 - Window;
 - Help;
-    
+
 and items specific for SHAPER module:
 
 - Part (see :ref:`partPlugin`);
@@ -86,8 +86,8 @@ and items specific for SHAPER module:
 - Construction (see :ref:`constructionPlugin`);
 - Build (see :ref:`buildPlugin`);
 - Primitives (see :ref:`primitivesPlugin`);
-- Features (see :ref:`featuresPlugin`);  
-- Macros. 
+- Features (see :ref:`featuresPlugin`);
+- Macros.
 
  .. _toolbar:
 
@@ -130,7 +130,7 @@ Visibility of SHAPER toolbar sections is managed using *View -> Toolbar* :ref:`m
 Dock windows
 ------------
 
-Standard dock windows are: 
+Standard dock windows are:
 
 - :ref:`object_browser`
 - :ref:`inspection_panel`
@@ -139,9 +139,9 @@ Standard dock windows are:
 - :ref:`property_panel`
 
 Dock windows can be placed in three dock areas using drag-and-drop:
-  
-- left, 
-- right, 
+
+- left,
+- right,
 - bottom.
 
 By default Object browser window is placed at the left dock area, Inspection panel at the right dock area and Python console at the bottom dock area of the main window.
@@ -159,12 +159,12 @@ Each dock window can be closed using **Cross** window button and opened again us
 
    Pop-up menu for visibility of windows and toolbars
 
-.. _object_browser: 
+.. _object_browser:
 
 Object browser
 ^^^^^^^^^^^^^^
 
-Object browser contains all documents created in the current study. 
+Object browser contains all documents created in the current study.
 
 Each document includes standard branches where created objects are placed.
 
@@ -179,7 +179,7 @@ Partset includes three branches:
 
 - Parameters;
 - Constructions;
-- Features    
+- Features
 
 Part includes the following branches:
 
@@ -187,11 +187,11 @@ Part includes the following branches:
 - Constructions;
 - Results;
 - Fields;
-- Groups;   
-- Features.    
+- Groups;
+- Features.
 
 New part contains only 3 empty branches:
+
 - Parameters;
 - Constructions;
 - Results.
@@ -199,7 +199,7 @@ New part contains only 3 empty branches:
 Features are placed one after another in the active document with default names and their results are placed into the corresponding branch.
 
 Examples of default names assigned automatically for :ref:`box_feature` are:
+
 * **Box_1**, **Box_2**, ... for Feature;
 * **Box_1_1**, **Box_2_1**, ... for Result.
 
@@ -226,6 +226,11 @@ Each feature, result, construction, group, field, parameter can be renamed using
 
    **Construction** pop-up menu
 
+.. figure:: /images/popup_menu_object_browser_group.png
+   :align: center
+
+   **Group** pop-up menu
+
 The order of features can be changed using *Move to the end* and *Move to the end and split* pop-up menu commands. They work only for Group features. The selected group or several groups will be moved to the end of features list. The *Move to the end and split* also splits the resulting group in several groups: one group per one selection.
 
 Folders can be used to arrange long Tree View for features.
@@ -264,7 +269,7 @@ Note that all features using the removed feature and their results will be remov
    :align: center
 
    **Delete feature** dialog box
-   
+
 .. _property_panel:
 
 Property panel
@@ -278,21 +283,21 @@ Property panel consists of two parts:
 
 - controls a container for input of parameters for the current operation;
 - buttons panel containing standard buttons:
+
    | |ok_btn| **Ok/Apply** executes operation with defined parameters,
-   | |cancel_btn| **Cancel/Close** calls **Abort operation** dialog box to confirm  operation abort, 
+   | |cancel_btn| **Cancel/Close** calls **Abort operation** dialog box to confirm  operation abort,
    | |help_btn| **Help** calls User's guide opened on page describing the current operation.
 
    .. figure:: /images/abort_operation.png
       :align: center
-     
+
       **Abort operation** dialog box
 
 |ok_btn| **OK/Apply**  button is disabled if not all input parameters are defined or some errors are found. Error is shown as tooltip and in status bar.
 
-.. _inspection_panel: 
+.. _inspection_panel:
 
-Inspection panel 
+Inspection panel
 ^^^^^^^^^^^^^^^^
 
 Inspection panel provides the list of types and quantities of all topological entities, composing the selected result, construction or feature.
@@ -305,20 +310,20 @@ Inspection panel provides the list of types and quantities of all topological en
 **Object** displays name of the selected result, construction  or feature.
 
 **Type** characterizes the whole shape.
-   
+
 The information about Point, Axis or Edge  additionally shows coordinates of point / end points.
 
 .. figure:: /images/inspection_panel_line.png
    :align: center
 
    **Inspection panel** for Axis
-   
+
 The information about  Plane, Face additionally shows coordinates of center point and direction of normal.
 
 .. figure:: /images/inspection_panel_face.png
    :align: center
 
-   **Inspection panel** for Face 
+   **Inspection panel** for Face
 
 .. _hidefaces_panel:
 
@@ -333,7 +338,7 @@ Hide Faces panel
    **Hide Faces** panel
 
 - If this panel is activated it "listens" user selection.
-- If a face is selected then its name will be shown in the panel's list and hidden in the viewer. 
+- If a face is selected then its name will be shown in the panel's list and hidden in the viewer.
 - If user selects a group of faces (or at least a one face of this group) then whole group will be hidden and also all faces from all objects referenced by this group.
 - If user will display the hidden group again (by a show operation) then the group will be removed from Hide Faces list and visibility of all referenced faces will be restored.
 
@@ -357,8 +362,8 @@ Pop-up menu gives the possibility to:
 - Paste the text from clipboard to Python console ;
 - Clear Python console;
 - Dump commands from console into the specified file;
-- Start/Stop writing log into the specified file.    
+- Start/Stop writing log into the specified file.
+
 .. figure:: /images/python_console_popup.png
    :align: center
 
@@ -386,7 +391,7 @@ The description of OCC 3D Viewer architecture and functionality is provided in G
 
 .. _parameter_usage:
 
-Parameters 
+Parameters
 ----------
 
 Model parametrization can be done using parameters.
@@ -405,14 +410,14 @@ The list of features using parameters is given in **Parameters** dialog box:
    :align: center
 
    Parameters dialog box
-  
+
 If a parameter value is changed, then all features where it is used are rebuilt.
 
 A parameter name should be unique in the active document.
 
 However, partset and part can have parameters with the same name. If parameter names in Partset and Part are identical, then Part parameter has a higher priority and its value will be used in the features of this part.
 
-In contrast to features (see :ref:`object_browser`), there is an additional option when parameters are deleted.   
+In contrast to features (see :ref:`object_browser`), there is an additional option when parameters are deleted.
 
 .. figure:: /images/delete_parameter.png
    :align: center
@@ -456,7 +461,7 @@ SHAPER preferences contains the following tabs:
 Visualization tab is activated by default when **Preferences** dialog box is opened in the active SHAPER module.
 
 Other tabs are activated by click on tab header.
-  
+
 .. _visualization_preferences:
 
 Visualization tab
@@ -475,7 +480,7 @@ This tab defines presentation of objects displayed in OCC 3D viewer.
 - **Result color** selects default shading color for objects from **Results** branch;
 - **Group color** selects default color for objects from **Groups** branch;
 - **Construction color** selects default color for objects from **Constructions** branch;
-- **Part color** selects default color for parts shown in Partset;  
+- **Part color** selects default color for parts shown in Partset;
 - **Field color** selects default color for objects from **Fields** branch;
 - **Body deflection coefficient** defines default deflection coefficient for objects from **Results** branch. A smaller coefficient provides better quality of a shape in the viewer;
 - **Construction deflection coefficient** defines default deflection coefficient for objects from **Constructions** branch. A smaller coefficient provides better quality of a shape in the viewer;
@@ -485,11 +490,11 @@ This tab defines presentation of objects displayed in OCC 3D viewer.
 - **Color of removed feature in operation** selects default color used for visualization of sketch entities to be removed during **Trim/Split** operations;
 - **Color of sketch plane** selects default shading color for sketch plane;
 - **Hidden faces transparency** defines default transparency value for hidden faces;
-- **Dimension arrow size**  defines default size of arrows for extension line showing dimensional constraint;  
+- **Dimension arrow size**  defines default size of arrows for extension line showing dimensional constraint;
 - **Dimension font** defines font used for value of dimensional constraint;
 - **Dimension value size**  defines default size of value for dimensional constraint;
-- **Sketch dimension color**  defines default color of dimensional constraint; 
-- **Construction plane color** selects default color for Construction planes;  
+- **Sketch dimension color**  defines default color of dimensional constraint;
+- **Construction plane color** selects default color for Construction planes;
 - **Sketch entity color** selects default color for sketch objects;
 - **Sketch external entity color** selects default color for external objects selected as reference during sketch creation/edition;
 - **Sketch auxiliary entity color** selects default color for sketch auxiliary objects;
@@ -497,18 +502,18 @@ This tab defines presentation of objects displayed in OCC 3D viewer.
 - **Sketch fully constraint color** selects default color for a sketch with zero degrees of freedom.
 - **Zoom trihedron arrows** if this control is checked then arrows of a view trihedron will be scaled according to current view scale
 - **Axis arrow size** relative size of trihedron arrows. It has effect only in case if **Zoom trihedron arrows** is On.
-  
+
 To redefine any color click on the corresponding line to access **Select color** dialog box
 
 .. figure:: /images/select_color.png
    :align: center
 
    **Preferences**: **Select color** dialog box
-   
+
 Preferences for sketch are applicable  during sketch creation/edition operation.
-   
+
 .. _plugins_preferences:
-   
+
 Plugins tab
 ^^^^^^^^^^^
 Plugins tab defines folders where plugins and resources are located.
@@ -533,10 +538,10 @@ Plugins tab defines folders where plugins and resources are located.
    :align: center
 
    **Find directory** dialog box
-    
-   
+
+
 .. _shortcuts_preferences:
-   
+
 Shortcuts tab
 ^^^^^^^^^^^^^
 
@@ -546,9 +551,9 @@ Shortcuts tab defines shortcut keys for different operations.
    :align: center
 
    **Preferences**: Shortcuts tab
-   
+
 - **Add parameter in parameters manager dialog** defines shortcut keys for adding parameter in parameters manager dialog box.
-   
+
 .. _windows_preferences:
 
 Windows tab
@@ -578,24 +583,24 @@ Sketch tab defines properties of coordinate planes shown for selection of sketch
 **Input fields**:
 
 - **Size** defines size of coordinate planes;
-- **Thickness**  defines thickness of coordinate plane borders; 
-- **Rotate to plane when selected** check-box turns on/off automatic switch the viewer to the top view for the selected sketch plane.  
+- **Thickness**  defines thickness of coordinate plane borders;
+- **Rotate to plane when selected** check-box turns on/off automatic switch the viewer to the top view for the selected sketch plane.
 - **Angular tolerance** defines defines an angular tolerance for automatic creation of horizontal and vertical constraints;
 - **Default spline weight** defines default weight for B-spline nodes during creation. The default value can be changed by editing of the spline;
 - **Cursor for sketch operation** defines a cursor which indicates a launched sketcher sub-operation.
 - **Create sketch entities by dragging** defines a style of sketch etities creation. It concerns creation of lines, rectangles, circles, arcs, ellipses, elliptic arcs. If it is switched ON then points of objects have to be defined by mouse press - mouse move - mouse release. Otherwise every point of an object has to be defined by mouse click;
-   
+
 .. _viewer_preferences:
-   
+
 Viewer tab
 ^^^^^^^^^^
 
-Viewer tab defines selection in OCC 3D viewer properties. 
+Viewer tab defines selection in OCC 3D viewer properties.
 
 .. figure:: /images/viewer_preferences.png
    :align: center
 
-   **Preferences**: Viewer tab   
+   **Preferences**: Viewer tab
 
 **Input fields**:
 
@@ -607,8 +612,8 @@ Viewer tab defines selection in OCC 3D viewer properties.
 
 - **Selection sensitivity** defines size of area around object in pixels, in which  mouse click selects object inside this area:
 
-  - **Vertex** defines selection  sensitivity for vertices; 
-  - **Edge**  defines selection  sensitivity for edges.  
+  - **Vertex** defines selection  sensitivity for vertices;
+  - **Edge**  defines selection  sensitivity for edges.
 
 .. _toolbars_management:
 
@@ -619,7 +624,7 @@ Toolbars management
 
 **Toolbars** dialog box
 ^^^^^^^^^^^^^^^^^^^^^^^
-To edit the current tool bars structure select in the Main Menu *Edit - > Edit toolbars* item. 
+To edit the current tool bars structure select in the Main Menu *Edit - > Edit toolbars* item.
 The following dialog box with existing toolbars appears:
 
 .. figure:: /images/Toolbars.png
@@ -641,7 +646,7 @@ The following dialog box with existing toolbars appears:
    :align: center
 
    Warning dialog box
-   
+
 .. _create_toolbar:
 
 **Create toolbar** dialog box
@@ -677,7 +682,7 @@ The following dialog box with existing toolbars appears:
 
 - **Toolbar name** non-editable field displays  name of modified tool bar;
 - **Out of toolbars** window contains list of commands which are not included into any tool bar and separator definition "------";
-- **In the toolbar** window contains list of commands which are defined in the current tool bar. Items in this window are listed according to order of commands in the toolbar; 
+- **In the toolbar** window contains list of commands which are defined in the current tool bar. Items in this window are listed according to order of commands in the toolbar;
 - **Right arrow** button transfers currently selected item from  **Out of toolbars** window to **In the toolbar** window and puts new item before the selected item in **In the toolbar** window.
     If there is no selected item in **In the toolbar**  window then new item will be added at the end of items list. In order to clear current selection it is necessary to click in empty space of the window.
 - **Left arrow** button transfers currently selected item from **In the toolbar** window into **Out of toolbars** window;
diff --git a/doc/gui/images/popup_menu_object_browser_group.png b/doc/gui/images/popup_menu_object_browser_group.png
new file mode 100644 (file)
index 0000000..432c728
Binary files /dev/null and b/doc/gui/images/popup_menu_object_browser_group.png differ
index aff1787ed6ad3ff0f05597cb734f54da1123f2f2..17ad00b5377db2cca95dc8b1cb81b9961af763e5 100644 (file)
@@ -19,6 +19,8 @@
 
 #include "Config_PropManager.h"
 
+bool Config_PropManager::autoColorStatus = false;
+
 std::vector<int> stringToRGB(const std::string& theColor);
 int stringToInteger(const std::string& theInt);
 bool stringToBoolean(const std::string& theInt);
@@ -28,6 +30,15 @@ Config_Properties& Config_PropManager::props() {
   return *confProps;
 }
 
+bool Config_PropManager::getAutoColorStatus()
+{
+    return Config_PropManager::autoColorStatus;
+}
+
+void Config_PropManager::setAutoColorStatus(const bool theValue)
+{
+    Config_PropManager::autoColorStatus = theValue;
+}
 
 Config_Prop* Config_PropManager::registerProp(const std::string& theSection,
                                               const std::string& theName,
index da20cd731ccbdec79066299a72431e4eacf83ccd..256bca493dc753aad966bc8ac3902cb501e06552 100644 (file)
@@ -36,7 +36,7 @@ class Config_PropManager
 {
  public:
 
-  /** 
+  /**
    * Registers property parameters
    * \param theSection - name of section (domain of using) of the property.
    * \param theName - name (title) of the value.
@@ -89,7 +89,17 @@ class Config_PropManager
   //! \return double result or zero
   CONFIG_EXPORT static double stringToDouble(const std::string& theDouble);
 
+  //! Returns Auto-color status as a Boolean
+  CONFIG_EXPORT static bool getAutoColorStatus();
+
+  //! Set Auto-color boolean value
+  //! \param theValue a value to use
+  CONFIG_EXPORT static void setAutoColorStatus(const bool theValue);
+
  private:
+
+  CONFIG_EXPORT static bool autoColorStatus; // Auto-color status
+
   CONFIG_EXPORT static Config_Properties& props(); ///< List of all stored properties
 };
 
index 14397b0fea7efed0e0c42ee1af67e89196f375c8..3c1e2bec8fb2304a7ad0ded67d2dddb5ee889bff 100644 (file)
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Session.h>
+#include <ModelAPI_Tools.h>
+#include <ModelAPI_ResultGroup.h>
 #include <Events_Loop.h>
 #include <Config_Translator.h>
+#include <Config_PropManager.h>
 
 void ModelAPI_Feature::setError(const std::string& theError,
                                 bool isSend,
@@ -70,6 +73,13 @@ void ModelAPI_Feature::setResult(const std::shared_ptr<ModelAPI_Result>& 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);
+
+    if (Config_PropManager::getAutoColorStatus()
+                            && theResult->groupName() == ModelAPI_ResultGroup::group()) {
+      std::vector<int> aColor;
+      ModelAPI_Tools::findRandomColor(aColor);
+      ModelAPI_Tools::setColor(theResult,  aColor);
+    }
 }
 
 void ModelAPI_Feature::setResult(const std::shared_ptr<ModelAPI_Result>& theResult,
index e15b280afe3e0a8303c5a71dbbe701388de8e254..0dd1c1c8eca884b38805aa741acaa4e54f548fd5 100644 (file)
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-#include "ModelAPI_Tools.h"
-#include <ModelAPI_Session.h>
+#include <ModelAPI_AttributeBoolean.h>
+#include <ModelAPI_AttributeDocRef.h>
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeIntArray.h>
+#include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_CompositeFeature.h>
 #include <ModelAPI_Document.h>
+#include <ModelAPI_Events.h>
 #include <ModelAPI_Object.h>
-#include <ModelAPI_AttributeDouble.h>
-#include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_ResultGroup.h>
 #include <ModelAPI_ResultParameter.h>
 #include <ModelAPI_ResultPart.h>
-#include <ModelAPI_ResultGroup.h>
-#include <ModelAPI_AttributeDocRef.h>
+#include <ModelAPI_Session.h>
+#include "ModelAPI_Tools.h"
 #include <ModelAPI_Validator.h>
-#include <ModelAPI_AttributeIntArray.h>
-#include <ModelAPI_ResultConstruction.h>
-#include <ModelAPI_AttributeBoolean.h>
-#include <list>
-#include <map>
-#include <iostream>
-#include <sstream>
 
+#include <Config_Translator.h>
 #include <Events_Loop.h>
 #include <Locale_Convert.h>
-#include <ModelAPI_Events.h>
-#include <Config_Translator.h>
 
 #include <GeomAPI_ShapeHierarchy.h>
 #include <GeomAPI_ShapeIterator.h>
 
+#include <algorithm>
+#include <iostream>
+#include <list>
+#include <map>
+#include <sstream>
+
 #define RECURSE_TOP_LEVEL 50
 
 //#define DEBUG_REMOVE_FEATURES
@@ -1116,6 +1118,90 @@ std::list<FeaturePtr> referencedFeatures(
   return aResList;
 }
 
+void setValues(std::vector<int>& theRGB, const int theRed, const int theGreen, const int theBlue)
+{
+  theRGB.push_back(theRed);
+  theRGB.push_back(theGreen);
+  theRGB.push_back(theBlue);
+}
+
+std::vector<int> HSVtoRGB(int theH, int theS, int theV)
+{
+  std::vector<int> 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<std::vector<int>, 10> myColorTab = {
+  std::vector<int> {255, 0, 0},
+  std::vector<int> {0, 255, 0},
+  std::vector<int> {0, 0, 255},
+  std::vector<int> {255, 255, 0},
+  std::vector<int> {0, 255, 255},
+  std::vector<int> {255, 0, 255},
+  std::vector<int> {255, 94, 0},
+  std::vector<int> {132, 255, 0},
+  std::vector<int> {132, 0, 255},
+  std::vector<int> {0, 0, 0},
+};
+
+void findRandomColor(std::vector<int>& theValues, bool theReset)
+{
+  static int i = 0;
+  static std::vector<std::vector<int>> 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<int> aHSVColor;
+      std::vector<int> 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
index e740cd1c95c59801de766a54963eb8fc1f01fcf5..79d4f4a8b65d3909761cf3e031ff65bfcec5d1aa 100644 (file)
@@ -50,7 +50,7 @@ MODELAPI_EXPORT std::shared_ptr<GeomAPI_Shape> shape(
 MODELAPI_EXPORT std::string getFeatureError(const std::shared_ptr<ModelAPI_Feature>& 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<ModelAPI_Result> the
 MODELAPI_EXPORT std::list<std::shared_ptr<ModelAPI_Feature> > referencedFeatures(
   std::shared_ptr<ModelAPI_Result> 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<int>& theValues, bool theReset = false);
+
 }
 
 #endif
index 3999ae85e8778acfb834a6fbd78cec5f635ddcfd..a3095a374c5735baed2d52c0136cd790d74e6518 100644 (file)
@@ -204,9 +204,10 @@ 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_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());
index a3cabb6ff7250c02679f6a224f97d55b3abd66fa..a37df57fbfd3d83498a18d3bd739365657219974 100644 (file)
@@ -84,108 +84,13 @@ std::vector<int> XGUI_ColorDialog::getColor() const
 
   return aValues;
 }
-// contains global cash for integer index of the color -> RGB of this color
-static std::map<int, std::vector<int> > myColorMap;
-
-void appendValues(std::vector<int>& 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<int, std::vector<int> >& theColorMap, std::vector<int>& theValues)
-{
-  std::map<int, std::vector<int> >::const_iterator anIt = theColorMap.begin(),
-                                                   aLast = theColorMap.end();
-  bool isFound = false;
-  for (; anIt != aLast && !isFound; anIt++) {
-    std::vector<int> aValues = anIt->second;
-    isFound = aValues[0] == theValues[0] &&
-              aValues[1] == theValues[1] &&
-              aValues[2] == theValues[2];
-  }
-  return isFound;
-}
-
-std::vector<int> HSVtoRGB(int theH, int theS, int theV)
-{
-  std::vector<int> 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<int> aColor = HSVtoRGB(h, s, v);
-        if (containsValues(myColorMap, aColor))
-          continue;
-        myColorMap[i] = aColor;
-        i++;
-      }
-    }
-  }
-}
-
-void findRandomColor(std::vector<int>& 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<int> XGUI_ColorDialog::getRandomColor() const
 {
   std::vector<int> aValues;
   if (isRandomColor()) {
-    findRandomColor(aValues);
+    ModelAPI_Tools::findRandomColor(aValues);
   }
   return aValues;
 }
+
index 6e1d82e5dc8bb97059d40fcdac5d7760bef14b58..10a1f7f36997aa21374f8a617101de073441b7d9 100644 (file)
@@ -85,71 +85,77 @@ 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"),
-                                           aDesktop);
-  addAction("SHOW_ONLY_CMD", aAction);
+  anAction = ModuleBase_Tools::createAction(QIcon(":pictures/eye_pencil.png"),
+                                            tr("Show only"), aDesktop);
+  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"),
-                                           aDesktop);
-  addAction("HIDEALL_CMD", aAction);
+  anAction = ModuleBase_Tools::createAction(QIcon(":pictures/eye_pencil_closed.png"),
+                                            tr("Hide all"), aDesktop);
+  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 +166,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 +267,8 @@ QStringList XGUI_ContextMenuMgr::actionIds() const
 
 void XGUI_ContextMenuMgr::onAction(bool isChecked)
 {
-  QAction* aAction = static_cast<QAction*>(sender());
-  emit actionTriggered(aAction->data().toString(), isChecked);
+  QAction* anAction = static_cast<QAction*>(sender());
+  emit actionTriggered(anAction->data().toString(), isChecked);
 }
 
 void XGUI_ContextMenuMgr::updateCommandsStatus()
@@ -293,8 +299,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 +512,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 +528,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 +693,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 +815,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 +865,7 @@ void XGUI_ContextMenuMgr::addViewerMenu(QMenu* theMenu) const
   QList<ModuleBase_ViewerPrsPtr> 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 +886,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<int, QAction*> aMenuActions;
   ModuleBase_IModule* aModule = myWorkshop->module();
@@ -880,12 +909,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<QAction*> anActions = theMenu->actions();
-  int anActionsSize = anActions.size();
-  QAction* aFirstAction = anActions[0];
+  QList<QAction*> anActionsList = theMenu->actions();
+  int anActionsListSize = anActionsList.size();
+  QAction* aFirstAction = anActionsList[0];
   QMap<int, QAction*>::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 +964,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 +979,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 +995,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 +1005,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)
index 14756f93490871bfffff23a4189df4ca556d3f5f..4342023ae4653ec085b1b1636606393714314c04 100644 (file)
 #include <QSpinBox>
 #include <QDialogButtonBox>
 
+#include <sstream>
 #include <iterator>
 
 #ifdef TINSPECTOR
@@ -1058,8 +1059,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<ModelAPI_ResultPart>(aObject);
+      ObjectPtr anObject = aRootDoc->object(ModelAPI_ResultPart::group(), 0);
+      ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(anObject);
       if (aPart.get())
         aPart->activate();
     }
@@ -1734,7 +1735,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")
@@ -1742,11 +1743,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<ModelAPI_Result>(aObj);
       if (aResult.get())
         ModelAPI_Tools::showIsoLines(aResult, !ModelAPI_Tools::isShownIsoLines(aResult));
@@ -1755,27 +1758,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) {
@@ -1812,9 +1815,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") {
@@ -2316,9 +2319,9 @@ std::list<FeaturePtr> toCurrentFeatures(const ObjectPtr& theObject)
   DocumentPtr aDocument = theObject->document();
   std::list<FeaturePtr> anAllFeatures = allFeatures(aDocument);
   // find the object iterator
-  std::list<FeaturePtr>::iterator aObjectIt =
+  std::list<FeaturePtr>::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<FeaturePtr>::iterator aCurrentIt =
@@ -2326,14 +2329,14 @@ std::list<FeaturePtr> 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<FeaturePtr>(aObjectIt, aCurrentIt);
+  return std::list<FeaturePtr>(anObjectIt, aCurrentIt);
 }
 
 //******************************************************
@@ -2341,29 +2344,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<ModelAPI_Feature>(aObject);
+    FeaturePtr aFeat = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
     // only groups can be moved to the end for now (#2451)
     if (aFeat.get() && aFeat->getKind() != "Group") {
       aCanMove = false;
@@ -2371,15 +2374,15 @@ bool XGUI_Workshop::canMoveFeature()
     }
 
     // 1. Get features placed between selected and current in the document
-    std::list<FeaturePtr> aFeaturesBetween = toCurrentFeatures(aObject);
-    // if aFeaturesBetween is empty it means wrong order or aObject is the current feature
+    std::list<FeaturePtr> 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<FeaturePtr> aPlacedFeatures(aFeaturesBetween.begin(), aFeaturesBetween.end());
       // 2. Get all reference features to the selected object in the document
       std::set<FeaturePtr> aRefFeatures;
-      ModuleBase_Tools::refsToFeatureInFeatureDocument(aObject, aRefFeatures);
+      ModuleBase_Tools::refsToFeatureInFeatureDocument(anObject, aRefFeatures);
 
       if (aRefFeatures.empty())
         continue;
@@ -2422,7 +2425,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<std::string> aTypes;
     aTypes.insert(ModelAPI_ResultGroup::group());
@@ -2430,7 +2433,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<std::string> aTypes;
+    aTypes.insert(ModelAPI_ResultGroup::group());
+
+    return hasResults(anObjects, aTypes);
   }
   return false;
 }
@@ -2500,6 +2512,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
@@ -2524,6 +2537,56 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects)
   myViewerProxy->update();
 }
 
+//**************************************************************
+void XGUI_Workshop::changeAutoColor(const QObjectPtrList& theObjects)
+{
+  if (!abortAllOperations())
+  return;
+
+  std::vector<int> 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());
+
+    if (Config_PropManager::getAutoColorStatus()) {
+      contextMenuMgr()->action("AUTOCOLOR_CMD")->setText(tr("Auto color"));
+      Config_PropManager::setAutoColorStatus(false);
+      ModelAPI_Tools::findRandomColor(aColor, true);
+    } else {
+      // set the value to all results
+      foreach (ObjectPtr anObj, theObjects) {
+        DocumentPtr aDocument = anObj->document();
+        std::list<FeaturePtr> anAllFeatures = allFeatures(aDocument);
+        // find the object iterator
+        std::list<FeaturePtr>::iterator anObjectIt = anAllFeatures.begin();
+        for (; anObjectIt !=  anAllFeatures.end(); ++ anObjectIt) {
+          FeaturePtr aFeature = *anObjectIt;
+          if (aFeature.get()) {
+            std::list<ResultPtr> aResults;
+            ModelAPI_Tools::allResults(aFeature, aResults);
+            std::list<std::shared_ptr<ModelAPI_Result> >::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"));
+      Config_PropManager::setAutoColorStatus(true);
+    }
+}
+
 //**************************************************************
 void setTransparency(double theTransparency, const QObjectPtrList& theObjects)
 {
@@ -2778,11 +2841,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<ModelAPI_ResultField::ModelAPI_FieldStep>(aObjects.first());
+      std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(anObjects.first());
     if (aStep.get() && myDisplayer->isVisible(aStep)) {
       AISObjectPtr aAisPtr = myDisplayer->getAISObject(aStep);
       Handle(AIS_InteractiveObject) aIO = aAisPtr->impl<Handle(AIS_InteractiveObject)>();
@@ -3096,10 +3159,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<ModelAPI_Feature>(aObj);
   if (aFeature.get() == NULL)
     return;
index 7b996aaa49268e6292d1770014f5284fd971163e..3050590c0f7209caabade14539286425008036c7 100644 (file)
@@ -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
index 1225bcc3205411410d31cc2b11a1982605738a30..dd81c3b936f2788d7268d571a1b24c169b61725b 100644 (file)
@@ -88,6 +88,7 @@
      <file>pictures/add.png</file>
      <file>pictures/reverce.png</file>
      <file>pictures/color.png</file>
+     <file>pictures/autocolor.png</file>
      <file>pictures/normal-view-inversed.png</file>
      <file>pictures/normal-view.png</file>
      <file>pictures/move_to_end.png</file>
diff --git a/src/XGUI/pictures/autocolor.png b/src/XGUI/pictures/autocolor.png
new file mode 100644 (file)
index 0000000..1248b0b
Binary files /dev/null and b/src/XGUI/pictures/autocolor.png differ