]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 11 Mar 2015 09:33:51 +0000 (12:33 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 11 Mar 2015 09:33:51 +0000 (12:33 +0300)
69 files changed:
src/Config/Config_PropManager.cpp
src/Config/Config_PropManager.h
src/Config/Config_WidgetAPI.cpp
src/Config/Config_WidgetAPI.h
src/ExchangePlugin/ExchangePlugin_Plugin.cpp
src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.cpp
src/Model/CMakeLists.txt
src/Model/Model_AttributeIntArray.cpp [new file with mode: 0644]
src/Model/Model_AttributeIntArray.h [new file with mode: 0644]
src/Model/Model_Data.cpp
src/Model/Model_Data.h
src/Model/Model_Document.cpp
src/Model/Model_ResultBody.cpp
src/Model/Model_ResultBody.h
src/Model/Model_ResultConstruction.cpp
src/Model/Model_ResultConstruction.h
src/Model/Model_ResultGroup.cpp
src/Model/Model_ResultGroup.h
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI_AttributeIntArray.cpp [new file with mode: 0644]
src/ModelAPI/ModelAPI_AttributeIntArray.h [new file with mode: 0644]
src/ModelAPI/ModelAPI_Data.h
src/ModelAPI/ModelAPI_Feature.h
src/ModelAPI/ModelAPI_Object.h
src/ModelAPI/ModelAPI_Result.h
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_IModule.h
src/ModuleBase/ModuleBase_PageBase.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_PageBase.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_PageGroupBox.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_PageGroupBox.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_PageWidget.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_PageWidget.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_Preferences.cpp
src/ModuleBase/ModuleBase_WidgetFactory.cpp
src/ModuleBase/ModuleBase_WidgetFactory.h
src/ModuleBase/ModuleBase_WidgetSwitch.cpp
src/ModuleBase/ModuleBase_WidgetSwitch.h
src/ModuleBase/ModuleBase_WidgetToolbox.cpp
src/ModuleBase/ModuleBase_WidgetToolbox.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/PartSet/PartSet_icons.qrc
src/PartSet/icons/color.png [new file with mode: 0644]
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_Arc.cpp
src/SketchPlugin/SketchPlugin_Arc.h
src/SketchPlugin/SketchPlugin_Circle.cpp
src/SketchPlugin/SketchPlugin_Circle.h
src/SketchPlugin/SketchPlugin_Feature.h
src/SketchPlugin/SketchPlugin_Line.cpp
src/SketchPlugin/SketchPlugin_Line.h
src/SketchPlugin/SketchPlugin_Point.cpp
src/SketchPlugin/SketchPlugin_Point.h
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_SketchEntity.cpp [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_SketchEntity.h [new file with mode: 0644]
src/SketchPlugin/plugin-Sketch.xml
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_PropertyPanel.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 82ec43f5871c82fba052e124ee830189943d53ef..ad5ceca9b779bb2a0b0c3865c6625219646e1b86 100644 (file)
@@ -9,6 +9,7 @@
 std::vector<int> stringToRGB(const std::string& theColor);
 int stringToInteger(const std::string& theInt);
 double stringToDouble(const std::string& theDouble);
+bool stringToBoolean(const std::string& theInt);
 
 Config_Properties Config_PropManager::myProps;
 
@@ -121,6 +122,14 @@ double Config_PropManager::real(const std::string& theSection, const std::string
   return stringToDouble(aStr);
 }
 
+bool Config_PropManager::boolean(const std::string& theSection,
+                                 const std::string& theName,
+                                 const std::string& theDefault)
+{
+  std::string aStr = string(theSection, theName, theDefault);
+  return stringToBoolean(aStr);
+}
+
 std::vector<int> stringToRGB(const std::string& theColor)
 {
   std::vector<int> aRes(3);
@@ -173,3 +182,8 @@ double stringToDouble(const std::string& theDouble)
   char* p;
   return strtod(theDouble.c_str(), &p);
 }
+
+bool stringToBoolean(const std::string& theBoolean)
+{
+  return theBoolean == "true";
+}
index c6bba0810a4311ff0bad110bbe7df34a72b18231..9b2ced3eafdf41b28ec17b152c9c459eb04d39f8 100644 (file)
@@ -60,6 +60,10 @@ class Config_PropManager
   CONFIG_EXPORT static double real(const std::string& theSection,
                                    const std::string& theName,
                                    const std::string& theDefault);
+  //! Returns boolean by given section and name
+  CONFIG_EXPORT static bool boolean(const std::string& theSection,
+                                   const std::string& theName,
+                                   const std::string& theDefault);
 
  private:
   CONFIG_EXPORT static Config_Properties myProps; ///< List of all stored properties
index bcf543bd17e21d93e81cfa832545a3672d594d8c..1249f9ab817ecd59e05b037d57a0390ad19caa40 100644 (file)
@@ -72,16 +72,16 @@ std::string Config_WidgetAPI::widgetType() const
   return result;
 }
 
-bool Config_WidgetAPI::isContainerWidget() const
+bool Config_WidgetAPI::isGroupBoxWidget() const
 {
   return isNode(myCurrentNode, WDG_GROUP, WDG_CHECK_GROUP,
-  NULL);
+                NULL);
 }
 
 bool Config_WidgetAPI::isPagedWidget() const
 {
   return isNode(myCurrentNode, WDG_TOOLBOX, WDG_SWITCH,
-  NULL);
+                NULL);
 }
 
 std::string Config_WidgetAPI::getProperty(const char* thePropName) const
index a44ce55a42cae5ab7ee18d7469b7d7e6fdcb258e..e9531e49fb7af27c9615c666c2e172a0a7af2df9 100644 (file)
@@ -40,7 +40,7 @@ class CONFIG_EXPORT Config_WidgetAPI
   //! Returns name of widget's node (attribute)
   std::string widgetType() const;
   //! Returns true if widget has container type, which means it able to contain other widgets
-  bool isContainerWidget() const;
+  bool isGroupBoxWidget() const;
   //! Returns true if widget has page type;
   //! Page is container widget with combo box control to switch between pages
   bool isPagedWidget() const;
index cf32016859c4088cd15224867e8eddfc2122478b..e2b1ee20f7f69c890a3d86d1e05f007ae3fa6f6a 100644 (file)
@@ -32,6 +32,10 @@ ExchangePlugin_Plugin::ExchangePlugin_Plugin()
   // register construction properties
   Config_PropManager::registerProp("Visualization", "import_feature_color", "Imported feature color",
                                    Config_Prop::Color, IMPORTED_FEATURE_COLOR);
+
+  // register random result color properties
+  Config_PropManager::registerProp("Visualization", "random_result_color", "Use random color for results",
+                                   Config_Prop::Bool, "true");
 }
 
 FeaturePtr ExchangePlugin_Plugin::createFeature(string theFeatureID)
index 86c7b0a228059201fde6a5a2530aa90933fd8aab..61e28412aab9d44a70420e17db223e8cee585566 100644 (file)
@@ -23,6 +23,9 @@ const TopoDS_Shape GeomAlgoAPI_DFLoader::refineResult(const  TopoDS_Shape& theRe
     if (nbSubResults == 1) {
       itr.Initialize(theResult);
       if (itr.More()) aResult = itr.Value();
+    } else {
+      /// MPV: store compound anyway: it may be Boolean operation that produces two solids from one
+      aResult = theResult;
     }
   }
   return aResult;
index 4865602acdf89002d21df797244afb7402ac605c..ef4c82c12077d0ba4b2d4067fcf226634c746b2b 100644 (file)
@@ -14,6 +14,7 @@ SET(PROJECT_HEADERS
     Model_AttributeRefAttr.h
     Model_AttributeRefList.h
     Model_AttributeBoolean.h
+    Model_AttributeIntArray.h
     Model_AttributeString.h
     Model_AttributeInteger.h
     Model_AttributeSelection.h
@@ -39,6 +40,7 @@ SET(PROJECT_SOURCES
     Model_AttributeRefAttr.cpp
     Model_AttributeRefList.cpp
     Model_AttributeBoolean.cpp
+    Model_AttributeIntArray.cpp
     Model_AttributeString.cpp
     Model_AttributeInteger.cpp
     Model_AttributeSelection.cpp
diff --git a/src/Model/Model_AttributeIntArray.cpp b/src/Model/Model_AttributeIntArray.cpp
new file mode 100644 (file)
index 0000000..8f21a42
--- /dev/null
@@ -0,0 +1,70 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        Model_AttributeIntArray.cpp
+// Created:     6 Mar 2015
+// Author:      Natalia ERMOLAEVA
+
+#include <Model_AttributeIntArray.h>
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_Attribute.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Object.h>
+
+#include <Standard_TypeDef.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TDataStd_Integer.hxx>
+#include <TDataStd_Name.hxx>
+
+#include <string>
+
+int Model_AttributeIntArray::size()
+{
+  return myArray.IsNull() ? 0 : myArray->Length();
+}
+
+void Model_AttributeIntArray::setSize(const int theSize)
+{
+  if (myArray.IsNull()) { // create array if it is not done yet
+    if (theSize != 0) { // if size is zero, nothing to do (null array means there is no array)
+      myArray = TDataStd_IntegerArray::Set(myLab, 0, theSize);
+      owner()->data()->sendAttributeUpdated(this);
+    }
+  } else { // reset the old array
+    if (theSize) {
+      if (theSize != myArray->Length()) { // old data is not keept, a new array is created
+        Handle(TColStd_HArray1OfInteger) aNewArray = new TColStd_HArray1OfInteger(0, theSize - 1);
+        myArray->ChangeArray(aNewArray);
+        owner()->data()->sendAttributeUpdated(this);
+      }
+    } else { // size is zero => array must be erased
+      if (!myArray.IsNull()) {
+        myArray.Nullify();
+        myLab.ForgetAttribute(TDataStd_IntegerArray::GetID());
+        owner()->data()->sendAttributeUpdated(this);
+      }
+    }
+  }
+}
+
+void Model_AttributeIntArray::setValue(const int theIndex,
+                                       const int theValue)
+{
+  if (myArray->Value(theIndex) != theValue) {
+    myArray->SetValue(theIndex, theValue);
+    owner()->data()->sendAttributeUpdated(this);
+  }
+}
+
+int Model_AttributeIntArray::value(const int theIndex)
+{
+  return myArray->Value(theIndex);
+}
+
+Model_AttributeIntArray::Model_AttributeIntArray(TDF_Label& theLabel)
+{
+  myLab = theLabel;
+  // check the attribute could be already presented in this doc (after load document)
+  myIsInitialized = 
+    myLab.FindAttribute(TDataStd_IntegerArray::GetID(), myArray) == Standard_True;
+}
diff --git a/src/Model/Model_AttributeIntArray.h b/src/Model/Model_AttributeIntArray.h
new file mode 100644 (file)
index 0000000..82808f5
--- /dev/null
@@ -0,0 +1,54 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        Model_AttributeIntArray.h
+// Created:     6 Mar 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef MODEL_ATTRIBUTEINTARRAY_H_
+#define MODEL_ATTRIBUTEINTARRAY_H_
+
+#include <Model.h>
+#include <ModelAPI_AttributeIntArray.h>
+
+#include <TDF_Label.hxx>
+#include <TDataStd_IntegerArray.hxx>
+
+#include <string>
+
+/**\class Model_AttributeIntArray
+ * \ingroup DataModel
+ * \brief API for the attribute that contains several integers in the array inside.
+ * Used for RGB color storage for an example. By default size is one, zero-based.
+ * Represented as array in OCCT. Empty array means that this attribute does not exists.
+ */
+
+class Model_AttributeIntArray : public ModelAPI_AttributeIntArray
+{
+  /// The OCCT array that keeps all values. 
+  Handle_TDataStd_IntegerArray myArray;
+  /// Stores the label as a field to set array if size is not null (null array is buggy in OCAF)
+  TDF_Label myLab;
+ public:
+
+  /// Returns the size of the array (zero means that it is empty)
+  MODEL_EXPORT virtual int size();
+
+  /// Sets the new size of the array. The previous data is erased.
+  MODEL_EXPORT virtual void setSize(const int theSize);
+
+  /// Defines the value of the array by index [0; size-1]
+  MODEL_EXPORT virtual void setValue(const int theIndex,
+                                     const int theValue);
+
+  /// Returns the value by the index
+  MODEL_EXPORT virtual int value(const int theIndex);
+
+
+ protected:
+  /// Initializes attibutes
+  Model_AttributeIntArray(TDF_Label& theLabel);
+
+  friend class Model_Data;
+};
+
+#endif
index e13eaa406e5b6199c198ebf86dfb074140c5130a..b8aeabaffbba9e19dd2c04e33422da9bb9c59cea 100644 (file)
@@ -15,6 +15,7 @@
 #include <Model_AttributeString.h>
 #include <Model_AttributeSelection.h>
 #include <Model_AttributeSelectionList.h>
+#include <Model_AttributeIntArray.h>
 #include <Model_Events.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Result.h>
@@ -90,6 +91,8 @@ void Model_Data::addAttribute(const std::string& theID, const std::string theAtt
     anAttr = new Model_AttributeRefAttr(anAttrLab);
   } else if (theAttrType == ModelAPI_AttributeRefList::type()) {
     anAttr = new Model_AttributeRefList(anAttrLab);
+  } else if (theAttrType == ModelAPI_AttributeIntArray::type()) {
+    anAttr = new Model_AttributeIntArray(anAttrLab);
   } 
   // create also GeomData attributes here because only here the OCAF strucure is known
   else if (theAttrType == GeomData_Point::type()) {
@@ -130,6 +133,7 @@ GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeSelection, selection);
 GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeSelectionList, selectionList);
 GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeRefAttr, refattr);
 GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeRefList, reflist);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeIntArray, intArray);
 
 std::shared_ptr<ModelAPI_Attribute> Model_Data::attribute(const std::string& theID)
 {
index 6604e86e8a246dfce43bccf065e6944fb5637dfc..1787b2a9e0c2aa9fe9f5a3da79a1f9c7c7c690de 100644 (file)
@@ -17,6 +17,7 @@
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_AttributeRefList.h>
 #include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeIntArray.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Object.h>
@@ -100,6 +101,10 @@ class Model_Data : public ModelAPI_Data
   /// Returns the attribute that contains real value with double precision
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeString>
     string(const std::string& theID);
+  /// Returns the attribute that contains integer values array
+  MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeIntArray>
+    intArray(const std::string& theID);
+
   /// Returns the generic attribute by identifier
   /// \param theID identifier of the attribute
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Attribute> attribute(const std::string& theID);
index 32ae6102648ffdb3c727c403ae78acb019d19c2b..fb00ed5bf3f3c43e29ecf690de1d39317e8ca79b 100644 (file)
@@ -893,8 +893,8 @@ void Model_Document::initData(ObjectPtr theObj, TDF_Label theLab, const int theT
   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObj);
   if (aFeature) {
     setUniqueName(aFeature);  // must be before "initAttributes" because duplicate part uses name
-    aFeature->initAttributes();
   }
+  theObj->initAttributes();
 }
 
 void Model_Document::synchronizeFeatures(const bool theMarkUpdated, const bool theUpdateReferences)
index 44b4bdbec6fc1be206bf079efa2be6214be1560a..784eff153c53703fa6c1e4cb4cbca58b5e721d51 100644 (file)
@@ -7,6 +7,7 @@
 #include <Model_ResultBody.h>
 #include <Model_Data.h>
 #include <Model_Document.h>
+#include <ModelAPI_AttributeIntArray.h>
 #include <TNaming_Builder.hxx>
 #include <TNaming_NamedShape.hxx>
 #include <TDataStd_Name.hxx>
@@ -30,6 +31,7 @@
 #include <BRep_Tool.hxx>
 #include <GeomAPI_Shape.h>
 #include <GeomAlgoAPI_MakeShape.h>
+#include <Config_PropManager.h>
 // DEB
 //#include <TCollection_AsciiString.hxx>
 //#include <TDF_Tool.hxx>
@@ -40,6 +42,20 @@ Model_ResultBody::Model_ResultBody()
   setIsConcealed(false);
 }
 
+void Model_ResultBody::initAttributes()
+{
+  // append the color attribute
+  DataPtr aData = data();
+  aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::type());
+  AttributeIntArrayPtr aColorAttr = aData->intArray(COLOR_ID());
+  std::vector<int> aRGB;
+  aRGB = Config_PropManager::color("Visualization", "result_body_color", DEFAULT_COLOR());
+  aColorAttr->setSize(3);
+  aColorAttr->setValue(0, aRGB[0]);
+  aColorAttr->setValue(1, aRGB[1]);
+  aColorAttr->setValue(2, aRGB[2]);
+}
+
 void Model_ResultBody::store(const std::shared_ptr<GeomAPI_Shape>& theShape)
 {
   std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
index f4fbb7b1f36feaccf10aa9ad5ef8dae5d996efa4..e7fdcb5ca5ab53b310ef4a88ef7158655c9cbd12 100644 (file)
@@ -29,6 +29,16 @@ class Model_ResultBody : public ModelAPI_ResultBody
   /// label; index in vector corresponds to the label tag
   std::vector<TNaming_Builder*> myBuilders;
 public:
+  /// default color for a result body
+  inline static const std::string& DEFAULT_COLOR()
+  {
+    static const std::string RESULT_BODY_COLOR("#E0A01B");
+    return RESULT_BODY_COLOR;
+  }
+
+  /// Request for initialization of data model of the result: adding all attributes
+  virtual void initAttributes();
+
   /// Stores the shape (called by the execution method).
   MODEL_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape);
 
index aaade70ff23d3364b2fb930b5c1bc61081d5eac2..97f2b4fcd3808b381aad63b2d71c63cb8b06531c 100644 (file)
@@ -6,6 +6,23 @@
 
 #include <Model_ResultConstruction.h>
 
+#include <ModelAPI_AttributeIntArray.h>
+#include <Config_PropManager.h>
+
+void Model_ResultConstruction::initAttributes()
+{
+  // append the color attribute
+  DataPtr aData = data();
+  aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::type());
+  AttributeIntArrayPtr aColorAttr = aData->intArray(COLOR_ID());
+  std::vector<int> aRGB;
+  aRGB = Config_PropManager::color("Visualization", "result_construction_color", DEFAULT_COLOR());
+  aColorAttr->setSize(3);
+  aColorAttr->setValue(0, aRGB[0]);
+  aColorAttr->setValue(1, aRGB[1]);
+  aColorAttr->setValue(2, aRGB[2]);
+}
+
 void Model_ResultConstruction::setShape(std::shared_ptr<GeomAPI_Shape> theShape)
 {
   myShape = theShape;
index a66aeeb5a73eccebf1883dca7f04715774d5174b..2fb81219d9b9989271a16aa03e03c3a78b6157d0 100644 (file)
@@ -23,6 +23,16 @@ class Model_ResultConstruction : public ModelAPI_ResultConstruction
   std::shared_ptr<GeomAPI_Shape> myShape;  ///< shape of this result created "on the fly"
   bool myIsInHistory;
  public:
+  /// default color for a result construction
+  inline static const std::string& DEFAULT_COLOR()
+  {
+    static const std::string RESULT_CONSTRUCTION_COLOR("#000000");
+    return RESULT_CONSTRUCTION_COLOR;
+  }
+
+  /// Request for initialization of data model of the result: adding all attributes
+  virtual void initAttributes();
+
   /// By default object is displayed in the object browser.
   MODEL_EXPORT virtual bool isInHistory()
   {
index ebcdb9b437ff4915e0bfe66b11856f4efb0b16f3..a0a5922cd056249e7e3fbec64597e0d29d63dd08 100644 (file)
@@ -6,14 +6,32 @@
 
 #include <Model_ResultGroup.h>
 #include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_AttributeIntArray.h>
+
 #include <GeomAlgoAPI_CompoundBuilder.h>
 
+#include <Config_PropManager.h>
+
 Model_ResultGroup::Model_ResultGroup(std::shared_ptr<ModelAPI_Data> theOwnerData)
 {
   setIsConcealed(false);
   myOwnerData = theOwnerData;
 }
 
+void Model_ResultGroup::initAttributes()
+{
+  // append the color attribute
+  DataPtr aData = data();
+  aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::type());
+  AttributeIntArrayPtr aColorAttr = aData->intArray(COLOR_ID());
+  std::vector<int> aRGB;
+  aRGB = Config_PropManager::color("Visualization", "result_group_color", DEFAULT_COLOR());
+  aColorAttr->setSize(3);
+  aColorAttr->setValue(0, aRGB[0]);
+  aColorAttr->setValue(1, aRGB[1]);
+  aColorAttr->setValue(2, aRGB[2]);
+}
+
 std::shared_ptr<GeomAPI_Shape> Model_ResultGroup::shape()
 {
   std::shared_ptr<GeomAPI_Shape> aResult;
index 33b4351c9ac3e59bd7527528d6b8d5a0d6490272..33c0e17a74ba47245741359e4e8c9d50653826c7 100644 (file)
@@ -20,6 +20,15 @@ class Model_ResultGroup : public ModelAPI_ResultGroup
 {
   std::shared_ptr<ModelAPI_Data> myOwnerData;  ///< data of owner of this result
 public:
+  /// default color for a result body
+  inline static const std::string& DEFAULT_COLOR()
+  {
+    static const std::string RESULT_GROUP_COLOR("#E0A01B");
+    return RESULT_GROUP_COLOR;
+  }
+  /// Request for initialization of data model of the result: adding all attributes
+  virtual void initAttributes();
+
   /// Returns the compound of selected entities
   MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
 
index e8ef2bad290e75210907cb1e53a7561f1cdaad95..44602ce1c17ab5e8dbff136c9bab23e62280acb5 100644 (file)
@@ -9,6 +9,7 @@ SET(PROJECT_HEADERS
     ModelAPI.h
     ModelAPI_Attribute.h
     ModelAPI_AttributeBoolean.h
+    ModelAPI_AttributeIntArray.h
     ModelAPI_AttributeDocRef.h
     ModelAPI_AttributeDouble.h
     ModelAPI_AttributeInteger.h
@@ -44,6 +45,7 @@ SET(PROJECT_HEADERS
 SET(PROJECT_SOURCES
     ModelAPI_Attribute.cpp
     ModelAPI_AttributeBoolean.cpp
+    ModelAPI_AttributeIntArray.cpp
     ModelAPI_AttributeDocRef.cpp
     ModelAPI_AttributeDouble.cpp
     ModelAPI_AttributeInteger.cpp
diff --git a/src/ModelAPI/ModelAPI_AttributeIntArray.cpp b/src/ModelAPI/ModelAPI_AttributeIntArray.cpp
new file mode 100644 (file)
index 0000000..0e0304c
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModelAPI_AttributeIntArray.cpp
+// Created:     6 Mar 2015
+// Author:      Natalia ERMOLAEVA
+
+#include <ModelAPI_AttributeIntArray.h>
+
+
+std::string ModelAPI_AttributeIntArray::attributeType()
+{
+  return type();
+}
+
+/// To virtually destroy the fields of successors
+ModelAPI_AttributeIntArray::~ModelAPI_AttributeIntArray()
+{
+}
+
+ModelAPI_AttributeIntArray::ModelAPI_AttributeIntArray()
+{
+}
diff --git a/src/ModelAPI/ModelAPI_AttributeIntArray.h b/src/ModelAPI/ModelAPI_AttributeIntArray.h
new file mode 100644 (file)
index 0000000..177db04
--- /dev/null
@@ -0,0 +1,59 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModelAPI_AttributeIntArray.h
+// Created:     6 Mar 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef ModelAPI_AttributeIntArray_H_
+#define ModelAPI_AttributeIntArray_H_
+
+#include <ModelAPI.h>
+#include <ModelAPI_Attribute.h>
+
+#include <string>
+
+
+/**\class ModelAPI_AttributeIntArray
+ * \ingroup DataModel
+ * \brief API for the attribute that contains several integers in the array inside.
+ * Used for RGB color storage for an example. By default size is one, zero-based.
+ */
+
+class ModelAPI_AttributeIntArray : public ModelAPI_Attribute
+{
+ public:
+
+  /// Returns the size of the array (zero means that it is empty)
+  MODELAPI_EXPORT virtual int size() = 0;
+
+  /// Sets the new size of the array. The previous data is erased.
+  MODELAPI_EXPORT virtual void setSize(const int theSize) = 0;
+
+  /// Defines the value of the array by index [0; size-1]
+  MODELAPI_EXPORT virtual void setValue(const int theIndex,
+                                         const int theValue) = 0;
+
+  /// Returns the value by the index
+  MODELAPI_EXPORT virtual int value(const int theIndex) = 0;
+
+  /// Returns the type of this class of attributes
+  MODELAPI_EXPORT static std::string type()
+  {
+    return "IntArray";
+  }
+
+  /// Returns the type of this class of attributes, not static method
+  MODELAPI_EXPORT virtual std::string attributeType();
+
+  /// To virtually destroy the fields of successors
+  MODELAPI_EXPORT virtual ~ModelAPI_AttributeIntArray();
+
+ protected:
+  /// Objects are created for features automatically
+  MODELAPI_EXPORT ModelAPI_AttributeIntArray();
+};
+
+//! Pointer on double attribute
+typedef std::shared_ptr<ModelAPI_AttributeIntArray> AttributeIntArrayPtr;
+
+#endif
index bb532ce08bc51bb56e97357cceae56636489f3af..2d6baddb0d7c5b4f7bf59ed71a5647e22e6f5a40 100644 (file)
@@ -26,6 +26,7 @@ class ModelAPI_Attribute;
 class ModelAPI_Feature;
 class ModelAPI_AttributeSelection;
 class ModelAPI_AttributeSelectionList;
+class ModelAPI_AttributeIntArray;
 class ModelAPI_Object;
 class GeomAPI_Shape;
 
@@ -75,6 +76,8 @@ class MODELAPI_EXPORT ModelAPI_Data
   virtual std::shared_ptr<ModelAPI_AttributeBoolean> boolean(const std::string& theID) = 0;
   /// Returns the attribute that contains boolean value
   virtual std::shared_ptr<ModelAPI_AttributeString> string(const std::string& theID) = 0;
+  /// Returns the attribute that contains integer values array
+  virtual std::shared_ptr<ModelAPI_AttributeIntArray> intArray(const std::string& theID) = 0;
 
   /// Returns the generic attribute by identifier
   /// \param theID identifier of the attribute
index c7a57a01b3e62738ba9fd576a6d8975ba35c4f3d..e5701200fedbc8755f1c58c1f104aca8ffe4d825 100644 (file)
@@ -49,9 +49,6 @@ class ModelAPI_Feature : public ModelAPI_Object
     return group();
   }
 
-  /// Request for initialization of data model of the feature: adding all attributes
-  virtual void initAttributes() = 0;
-
   /// Computes or recomputes the results
   virtual void execute() = 0;
 
index 45932c039e2046212dd9fa32b6e360d438127a02..485cf2ee1bc3775906dea0052f0376dc240270e2 100644 (file)
@@ -44,6 +44,9 @@ class ModelAPI_Object
   /// Returns the group identifier of this object
   virtual std::string groupName() = 0;
 
+  /// Request for initialization of data model of the object: adding all attributes
+  virtual void initAttributes() = 0;
+
   /// Called on change of any argument-attribute of this object
   /// \param theID identifier of changed attribute
   // MODELAPI_EXPORT
index 28ea36645dd080cc73b63acc41651706e59daa06..776a2839153c4d64efb681044983402b4f8ba551 100644 (file)
@@ -22,7 +22,15 @@ class ModelAPI_Result : public ModelAPI_Object
 {
   bool myIsConcealed; ///< the result is concealed from the data tree (referenced by other objects)
  public:
-   /// Returns true if the result is concealed from the data tree (referenced by other objects)
+
+  /// Reference to the color of the result
+  inline static const std::string& COLOR_ID()
+  {
+    static const std::string MY_COLOR_ID("Color");
+    return MY_COLOR_ID;
+  }
+
+  /// Returns true if the result is concealed from the data tree (referenced by other objects)
   inline bool isConcealed()
   {
     return myIsConcealed;
@@ -34,6 +42,9 @@ class ModelAPI_Result : public ModelAPI_Object
     myIsConcealed = theValue;
   }
 
+  /// Request for initialization of data model of the result: adding all attributes
+  virtual void initAttributes() {};
+
   /// To virtually destroy the fields of successors
   MODELAPI_EXPORT virtual ~ModelAPI_Result();
 
index 8104818536889a5862e6e440cbbe911b93f91394..ea3235e1982f7c6642c5d1f815b5bcbda724631c 100644 (file)
@@ -45,6 +45,9 @@ SET(PROJECT_HEADERS
        ModuleBase_Preferences.h
        ModuleBase_ActionInfo.h
        ModuleBase_WidgetToolbox.h
+       ModuleBase_PageBase.h
+       ModuleBase_PageWidget.h 
+       ModuleBase_PageGroupBox.h
 )
 
 SET(PROJECT_SOURCES
@@ -80,6 +83,9 @@ SET(PROJECT_SOURCES
        ModuleBase_Preferences.cpp
        ModuleBase_ActionInfo.cpp
        ModuleBase_WidgetToolbox.cpp
+       ModuleBase_PageBase.cpp
+       ModuleBase_PageWidget.cpp
+       ModuleBase_PageGroupBox.cpp
 )
 
 SET(PROJECT_LIBRARIES
index 8d435b84fb5d5d5d74e96da91ed695103c377906..1e467d859cdf7fb1bc34dd87e96229bff441b3c4 100644 (file)
@@ -86,9 +86,8 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
   /// \param theWidgetApi the widget configuation. The attribute of the model widget is obtained from\r
   /// \param theParentId is Id of a parent of the current attribute\r
   /// \param theModelWidgets list of widget objects\r
-  virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,\r
-                                      Config_WidgetAPI* theWidgetApi, std::string theParentId,\r
-                                      QList<ModuleBase_ModelWidget*>& theModelWidgets)\r
+  virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType, QWidget* theParent,\r
+                                      Config_WidgetAPI* theWidgetApi, std::string theParentId)\r
   {\r
     return 0;\r
   }\r
diff --git a/src/ModuleBase/ModuleBase_PageBase.cpp b/src/ModuleBase/ModuleBase_PageBase.cpp
new file mode 100644 (file)
index 0000000..dac665e
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * ModuleBase_PageBase.cpp
+ *
+ *  Created on: Mar 4, 2015
+ *      Author: sbh
+ */
+
+#include <ModuleBase_PageBase.h>
+#include <ModuleBase_ModelWidget.h>
+
+#include <QLayout>
+
+class QWidget;
+
+ModuleBase_PageBase::ModuleBase_PageBase()
+{
+
+}
+
+ModuleBase_PageBase::~ModuleBase_PageBase()
+{
+
+}
+
+QWidget* ModuleBase_PageBase::pageWidget()
+{
+  return dynamic_cast<QWidget*>(this);
+}
+
+void ModuleBase_PageBase::addModelWidget(ModuleBase_ModelWidget* theWidget)
+{
+  placeModelWidget(theWidget);
+  myWidgetList.append(theWidget);
+}
+
+void ModuleBase_PageBase::addPageWidget(ModuleBase_PageBase* thePage)
+{
+  placePageWidget(thePage);
+}
+
+void ModuleBase_PageBase::clearPage()
+{
+  QLayoutItem *aChild;
+  while ((aChild = pageLayout()->takeAt(0)) != 0) {
+    if(aChild->widget()) {
+      aChild->widget()->deleteLater();
+    } else {
+      delete aChild;
+    }
+  }
+  myWidgetList.clear();
+}
+
+
+void ModuleBase_PageBase::takeFocus()
+{
+  if(myWidgetList.isEmpty())
+    return;
+
+  myWidgetList.first()->focusTo();
+}
+
+QList<ModuleBase_ModelWidget*> ModuleBase_PageBase::modelWidgets()
+{
+  return myWidgetList;
+}
+
+void ModuleBase_PageBase::alignToTop()
+{
+  bool hasExpanding = false;
+  QList<QWidget *> aListToCheck;
+  ModuleBase_ModelWidget* aModelWidget;
+  foreach(aModelWidget, myWidgetList) {
+    aListToCheck << aModelWidget->getControls();
+  }
+  foreach(QWidget* eachWidget, aListToCheck) {
+    QSizePolicy::Policy aVPolicy = eachWidget->sizePolicy().verticalPolicy();
+    if(aVPolicy & QSizePolicy::ExpandFlag) {
+      hasExpanding = true;
+      break;
+    }
+  }
+  if(!hasExpanding) {
+    addPageStretch();
+  }
+}
diff --git a/src/ModuleBase/ModuleBase_PageBase.h b/src/ModuleBase/ModuleBase_PageBase.h
new file mode 100644 (file)
index 0000000..7f8f054
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * ModuleBase_PageBase.h
+ *
+ *  Created on: Mar 4, 2015
+ *      Author: sbh
+ */
+
+#ifndef MODULEBASE_PAGEBASE_H_
+#define MODULEBASE_PAGEBASE_H_
+
+#include <ModuleBase.h>
+#include <ModuleBase_Tools.h>
+
+class ModuleBase_ModelWidget;
+class QLayout;
+class QWidget;
+
+/*!
+ * Represent a property panel's list of ModuleBase_ModelWidgets.
+ */
+class MODULEBASE_EXPORT ModuleBase_PageBase
+{
+ public:
+  ModuleBase_PageBase();
+  virtual ~ModuleBase_PageBase();
+  QWidget* pageWidget();
+
+  void addModelWidget(ModuleBase_ModelWidget* theWidget);
+  void addPageWidget(ModuleBase_PageBase* theWidget);
+
+  void clearPage();
+  void takeFocus();
+  QList<ModuleBase_ModelWidget*> modelWidgets();
+  void alignToTop();
+
+ protected:
+  virtual void placeModelWidget(ModuleBase_ModelWidget* theWidget) = 0;
+  virtual void placePageWidget(ModuleBase_PageBase* theWidget) = 0;
+  virtual QLayout* pageLayout() = 0;
+  virtual void addPageStretch() = 0;
+
+ private:
+  QList<ModuleBase_ModelWidget*> myWidgetList;
+
+};
+
+#endif /* MODULEBASE_PAGEBASE_H_ */
diff --git a/src/ModuleBase/ModuleBase_PageGroupBox.cpp b/src/ModuleBase/ModuleBase_PageGroupBox.cpp
new file mode 100644 (file)
index 0000000..f16e4d7
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * ModuleBase_PageGroupBox.cpp
+ *
+ *  Created on: Mar 4, 2015
+ *      Author: sbh
+ */
+
+#include <ModuleBase_PageGroupBox.h>
+#include <ModuleBase_ModelWidget.h>
+#include <ModuleBase_Tools.h>
+
+#include <QGridLayout>
+
+ModuleBase_PageGroupBox::ModuleBase_PageGroupBox(QWidget* theParent)
+: QGroupBox(theParent)
+{
+  myMainLayout = new QGridLayout(this);
+  ModuleBase_Tools::adjustMargins(myMainLayout);
+  setLayout(myMainLayout);
+}
+
+ModuleBase_PageGroupBox::~ModuleBase_PageGroupBox()
+{
+}
+
+void ModuleBase_PageGroupBox::addPageStretch()
+{
+}
+
+void ModuleBase_PageGroupBox::placeModelWidget(ModuleBase_ModelWidget* theWidget)
+{
+  const int kCol = 0;
+  const int kRow = myMainLayout->count();
+  myMainLayout->addWidget(theWidget, kRow, kCol, Qt::AlignTop | Qt::AlignLeft);
+}
+
+void ModuleBase_PageGroupBox::placePageWidget(ModuleBase_PageBase* theWidget)
+{
+  QWidget* aWidget = dynamic_cast<QWidget*>(theWidget);
+  if (!aWidget) {
+    #ifdef _DEBUG
+    std::cout << "ModuleBase_PageGroupBox::placePageWidget: can not cast page" << std::endl;
+    #endif
+    return;
+  }
+  const int kCol = 0;
+  const int kRow = myMainLayout->count();
+  myMainLayout->addWidget(aWidget, kRow, kCol, Qt::AlignTop | Qt::AlignLeft);
+}
+
+QLayout* ModuleBase_PageGroupBox::pageLayout()
+{
+  return myMainLayout;
+}
diff --git a/src/ModuleBase/ModuleBase_PageGroupBox.h b/src/ModuleBase/ModuleBase_PageGroupBox.h
new file mode 100644 (file)
index 0000000..fd10f00
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * ModuleBase_PageGroupBox.h
+ *
+ *  Created on: Mar 4, 2015
+ *      Author: sbh
+ */
+
+#ifndef MODULEBASE_PAGEGROUPBOX_H_
+#define MODULEBASE_PAGEGROUPBOX_H_
+
+#include <ModuleBase.h>
+#include <ModuleBase_PageBase.h>
+
+#include <QGroupBox>
+#include <QList>
+
+class ModuleBase_ModelWidget;
+class QGridLayout;
+
+
+/*!
+ * Represent a property panel's list of ModuleBase_ModelWidgets.
+ */
+class MODULEBASE_EXPORT ModuleBase_PageGroupBox : public QGroupBox, public ModuleBase_PageBase
+{
+ public:
+  explicit ModuleBase_PageGroupBox(QWidget* theParent = 0);
+  virtual ~ModuleBase_PageGroupBox();
+
+ protected:
+  virtual void placeModelWidget(ModuleBase_ModelWidget* theWidget);
+  virtual void placePageWidget(ModuleBase_PageBase* theWidget);
+  virtual QLayout* pageLayout();
+  virtual void addPageStretch();
+
+ private:
+  QGridLayout* myMainLayout;
+};
+
+#endif /* MODULEBASE_PAGEGROUPBOX_H_ */
diff --git a/src/ModuleBase/ModuleBase_PageWidget.cpp b/src/ModuleBase/ModuleBase_PageWidget.cpp
new file mode 100644 (file)
index 0000000..f49e53e
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * ModuleBase_PageWidget.cpp
+ *
+ *  Created on: Mar 4, 2015
+ *      Author: sbh
+ */
+
+#include <ModuleBase_PageWidget.h>
+#include <ModuleBase_ModelWidget.h>
+#include <ModuleBase_Tools.h>
+
+#include <QGridLayout>
+
+ModuleBase_PageWidget::ModuleBase_PageWidget(QWidget* theParent)
+: QFrame(theParent)
+{
+  myMainLayout = new QGridLayout(this);
+  ModuleBase_Tools::adjustMargins(myMainLayout);
+  setLayout(myMainLayout);
+}
+
+ModuleBase_PageWidget::~ModuleBase_PageWidget()
+{
+}
+
+void ModuleBase_PageWidget::addPageStretch()
+{
+  myMainLayout->setRowStretch(myMainLayout->rowCount(), 1);
+}
+
+void ModuleBase_PageWidget::placeModelWidget(ModuleBase_ModelWidget* theWidget)
+{
+  const int kCol = 0;
+  const int kRow = myMainLayout->count();
+  myMainLayout->addWidget(theWidget, kRow, kCol);
+}
+
+void ModuleBase_PageWidget::placePageWidget(ModuleBase_PageBase* theWidget)
+{
+  QWidget* aWidget = dynamic_cast<QWidget*>(theWidget);
+  if (!aWidget) {
+    #ifdef _DEBUG
+    std::cout << "ModuleBase_PageWidget::placePageWidget: can not cast page" << std::endl;
+    #endif
+    return;
+  }
+  const int kCol = 0;
+  const int kRow = myMainLayout->count();
+  myMainLayout->addWidget(aWidget, kRow, kCol);//, Qt::AlignTop | Qt::AlignLeft);
+}
+
+QLayout* ModuleBase_PageWidget::pageLayout()
+{
+  return myMainLayout;
+}
diff --git a/src/ModuleBase/ModuleBase_PageWidget.h b/src/ModuleBase/ModuleBase_PageWidget.h
new file mode 100644 (file)
index 0000000..eb21a6d
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * ModuleBase_PageWidget.h
+ *
+ *  Created on: Mar 4, 2015
+ *      Author: sbh
+ */
+
+#ifndef MODULEBASE_PAGEWIDGET_H_
+#define MODULEBASE_PAGEWIDGET_H_
+
+#include <ModuleBase.h>
+#include <ModuleBase_PageBase.h>
+
+#include <QFrame>
+#include <QList>
+
+class ModuleBase_ModelWidget;
+class QGridLayout;
+
+/*!
+ * Represent a property panel's list of ModuleBase_ModelWidgets.
+ */
+class MODULEBASE_EXPORT ModuleBase_PageWidget : public QFrame, public ModuleBase_PageBase
+{
+ public:
+  explicit ModuleBase_PageWidget(QWidget* theParent = 0);
+  virtual ~ModuleBase_PageWidget();
+
+ protected:
+  virtual void placeModelWidget(ModuleBase_ModelWidget* theWidget);
+  virtual void placePageWidget(ModuleBase_PageBase* theWidget);
+  virtual QLayout* pageLayout();
+  virtual void addPageStretch();
+
+ private:
+  QGridLayout* myMainLayout;
+};
+
+#endif /* MODULEBASE_PAGEWIDGET_H_ */
index 616e659e06c6a9c69bc0fbdb8ff39ea3470c54b0..4d4d1c78dbd20097353ddb1738fcb9a81142768e 100644 (file)
@@ -7,6 +7,10 @@
 #include "ModuleBase_Preferences.h"
 //#include "ModuleBase_Constants.h"
 
+#include <Model_ResultBody.h>
+#include <Model_ResultGroup.h>
+#include <Model_ResultConstruction.h>
+
 #include <Config_PropManager.h>
 
 #include <SUIT_ResourceMgr.h>
@@ -256,6 +260,13 @@ void ModuleBase_PreferencesDlg::createViewerPage(int thePageId)
   myPreferences->setItemProperty("texture_stretch_enabled", true, bgId);
   myPreferences->setItemProperty("custom_enabled", false, bgId);
   myPreferences->setItemProperty("image_formats", aImgFiles, bgId);
+
+  Config_PropManager::registerProp("Visualization", "result_body_color", "Body color",
+                                   Config_Prop::Color, Model_ResultBody::DEFAULT_COLOR());
+  Config_PropManager::registerProp("Visualization", "result_group_color", "Group color",
+                                   Config_Prop::Color, Model_ResultGroup::DEFAULT_COLOR());
+  Config_PropManager::registerProp("Visualization", "result_construction_color", "Construction color",
+                                   Config_Prop::Color, Model_ResultConstruction::DEFAULT_COLOR());
 }
 
 void ModuleBase_PreferencesDlg::createMenuPage(int thePageId)
index c5e6e58e8e0ab09104641196eaa4f74613ecdc3e..023c728a9820d246da78e29c69444f4a470fbdb3 100644 (file)
@@ -28,6 +28,9 @@
 #include <ModuleBase_WidgetMultiSelector.h>
 #include <ModuleBase_WidgetLabel.h>
 #include <ModuleBase_WidgetToolbox.h>
+#include <ModuleBase_PageBase.h>
+#include <ModuleBase_PageGroupBox.h>
+#include <ModuleBase_PageWidget.h>
 
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_Session.h>
@@ -64,216 +67,111 @@ ModuleBase_WidgetFactory::~ModuleBase_WidgetFactory()
   delete myWidgetApi;
 }
 
-void ModuleBase_WidgetFactory::createWidget(QWidget* theParent)
+void ModuleBase_WidgetFactory::createWidget(ModuleBase_PageBase* thePage)
 {
   myParentId = myWidgetApi->widgetId();
   if (!myWidgetApi->toChildWidget())
     return;
 
-  QVBoxLayout* aWidgetLay = new QVBoxLayout(theParent);
-  bool isStretchLayout = false;
   do {  //Iterate over each node
     std::string aWdgType = myWidgetApi->widgetType();
-    //Create a widget (doublevalue, groupbox, toolbox, etc.
-    QWidget* aWidget = createWidgetByType(aWdgType, theParent);
-    if (aWidget) {
-      if (!myWidgetApi->getBooleanAttribute(ATTR_INTERNAL, false)) {
-        aWidgetLay->addWidget(aWidget);
-      } else {
-        aWidget->setVisible(false);
-      }
-    }
-    if (myWidgetApi->isContainerWidget()) {
+    // Create PageGroup TODO: extract
+    if (myWidgetApi->isGroupBoxWidget()) {
       //if current widget is groupbox (container) process it's children recursively
       QString aGroupName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));
-      createWidget(aWidget);
-      ModuleBase_Tools::adjustMargins(aWidget);
-      QGroupBox* aGrBox = qobject_cast<QGroupBox*>(aWidget);
-      aGrBox->setTitle(aGroupName);
-    }
-    if (myWidgetApi->isPagedWidget()) {
-      //If current widget is toolbox or switch-casebox then fetch all
-      //it's pages recursively and setup into the widget.
-      myWidgetApi->toChildWidget();
-      do {
-        QString aPageName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));
-        QString aCaseId = qs(myWidgetApi->getProperty(_ID));
-        QWidget* aPage = new QWidget(aWidget);
-        createWidget(aPage);
-        ModuleBase_Tools::adjustMargins(aPage);
-        if (aWdgType == WDG_SWITCH) {
-          ModuleBase_WidgetSwitch* aSwitch = qobject_cast<ModuleBase_WidgetSwitch*>(aWidget);
-          aSwitch->addPage(aPage, aPageName);
-        } else if (aWdgType == WDG_TOOLBOX) {
-          ModuleBase_WidgetToolbox* aToolbox = qobject_cast<ModuleBase_WidgetToolbox*>(aWidget);
-          aToolbox->addPage(aPage, aPageName, aCaseId);
+      ModuleBase_PageGroupBox* aPage = new ModuleBase_PageGroupBox(thePage->pageWidget());
+      aPage->setTitle(aGroupName);
+      createWidget(aPage);
+      thePage->addPageWidget(aPage);
+    } else {
+      // Create a ModelWidget
+      ModuleBase_ModelWidget* aWidget = createWidgetByType(aWdgType, thePage->pageWidget());
+      if (aWidget) {
+        if (!myWidgetApi->getBooleanAttribute(ATTR_INTERNAL, false)) {
+          thePage->addModelWidget(aWidget);
+        } else {
+          aWidget->setVisible(false);
         }
-      } while (myWidgetApi->toNextWidget());
-    }
-    if (aWidget && !isStretchLayout) {
-      isStretchLayout = !hasExpandingControls(aWidget);
+      }
+      // Create PagedContainer TODO: extract
+      if (myWidgetApi->isPagedWidget()) {
+        //If current widget is toolbox or switch-casebox then fetch all
+        //it's pages recursively and setup into the widget.
+        myWidgetApi->toChildWidget();
+        do {
+          QString aPageName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));
+          QString aCaseId = qs(myWidgetApi->getProperty(_ID));
+          ModuleBase_PageBase* aPage = new ModuleBase_PageWidget(aWidget);
+          createWidget(aPage);
+          QWidget* aCasePageWidget = dynamic_cast<QWidget*>(aPage);
+          if (aWdgType == WDG_SWITCH) {
+            ModuleBase_WidgetSwitch* aSwitch = qobject_cast<ModuleBase_WidgetSwitch*>(aWidget);
+            aSwitch->addPage(aCasePageWidget, aPageName);
+          } else if (aWdgType == WDG_TOOLBOX) {
+            ModuleBase_WidgetToolbox* aToolbox = qobject_cast<ModuleBase_WidgetToolbox*>(aWidget);
+            aToolbox->addPage(aPage, aPageName, aCaseId);
+          }
+        } while (myWidgetApi->toNextWidget());
+      }
     }
   } while (myWidgetApi->toNextWidget());
-  if (isStretchLayout) {
-    aWidgetLay->addStretch(1);
-  }
-  theParent->setLayout(aWidgetLay);
-}
 
-bool ModuleBase_WidgetFactory::hasExpandingControls(QWidget* theParent)
-{
-  bool result = false;
-  QList<QWidget *> aListToCheck;
-  aListToCheck << theParent;
-  ModuleBase_ModelWidget* aModelWidget = qobject_cast<ModuleBase_ModelWidget*>(theParent);
-  if(aModelWidget) {
-    aListToCheck << aModelWidget->getControls();
-  }
-  foreach(QWidget* eachWidget, aListToCheck) {
-    QSizePolicy::Policy aVPolicy = eachWidget->sizePolicy().verticalPolicy();
-    if(aVPolicy & QSizePolicy::ExpandFlag) {
-      result = true;
-    }
-  }
-  return result;
+  thePage->alignToTop();
 }
 
-QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType,
-                                                      QWidget* theParent)
+ModuleBase_ModelWidget* ModuleBase_WidgetFactory
+::createWidgetByType(const std::string& theType, QWidget* theParent)
 {
-  QWidget* result = NULL;
-  if (theType == WDG_DOUBLEVALUE) {
-    result = doubleSpinBoxControl(theParent);
+  ModuleBase_ModelWidget* result = NULL;
+
+  if (theType == WDG_INFO) {
+    result = new ModuleBase_WidgetLabel(theParent, myWidgetApi, myParentId);
 
-  } else if (theType == WDG_INFO) {
-    result = labelControl(theParent);
+  } else if (theType == WDG_DOUBLEVALUE) {
+    result = new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi, myParentId);
 
   } else if (theType == WDG_SHAPE_SELECTOR) {
-    result = shapeSelectorControl(theParent);
+    result =  new ModuleBase_WidgetShapeSelector(theParent, myWorkshop, myWidgetApi, myParentId);
 
   } else if (theType == WDG_BOOLVALUE) {
-    result = booleanControl(theParent);
+    result = new ModuleBase_WidgetBoolValue(theParent, myWidgetApi, myParentId);
 
   } else if (theType == WDG_DOUBLEVALUE_EDITOR) {
-    result = doubleValueEditor(theParent);
+    result = new ModuleBase_WidgetEditor(theParent, myWidgetApi, myParentId);
 
   } else if (theType == WDG_FILE_SELECTOR) {
-    result = fileSelectorControl(theParent);
+    result = new ModuleBase_WidgetFileSelector(theParent, myWidgetApi, myParentId);
 
   } else if (theType == WDG_CHOICE) {
-    result = choiceControl(theParent);
+    result = new ModuleBase_WidgetChoice(theParent, myWidgetApi,myParentId);
 
   } else if (theType == WDG_STRINGVALUE) {
-    result = lineEditControl(theParent);
+    result = new ModuleBase_WidgetLineEdit(theParent, myWidgetApi,myParentId);
 
   } else if (theType == WDG_MULTISELECTOR) {
-    result = multiSelectorControl(theParent);
+    result = new ModuleBase_WidgetMultiSelector(theParent, myWorkshop, myWidgetApi,myParentId);
 
-  } else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) {
-    result = createContainer(theType, theParent);
+  } else if (theType == WDG_TOOLBOX) {
+    result = new ModuleBase_WidgetToolbox(theParent, myWidgetApi, myParentId);
+
+  } else if (theType == WDG_SWITCH) {
+    result = new ModuleBase_WidgetSwitch(theParent, myWidgetApi, myParentId);
+    return result;
+
+  } else if (theType == WDG_TOOLBOX_BOX || theType == WDG_SWITCH_CASE) {
+    // Do nothing for "box" and "case"
+    result = NULL;
   } else {
     result = myWorkshop->module()->createWidgetByType(theType, theParent, myWidgetApi,
-                                                      myParentId, myModelWidgets);
+                                                      myParentId);
 #ifdef _DEBUG
     if (!result) {qDebug("ModuleBase_WidgetFactory::fillWidget: find bad widget type");}
 #endif
   }
-  return result;
-}
-
-QWidget* ModuleBase_WidgetFactory::createContainer(const std::string& theType, QWidget* theParent)
-{
-  QWidget* aResult = NULL;
-  if (theType == WDG_GROUP || theType == WDG_CHECK_GROUP) {
-    QGroupBox* aGroupBox = new QGroupBox(theParent);
-    aGroupBox->setCheckable(theType == WDG_CHECK_GROUP);
-    aResult = aGroupBox;
-  } else if (theType == WDG_TOOLBOX) {
-    ModuleBase_WidgetToolbox* aWdg = new ModuleBase_WidgetToolbox(theParent, myWidgetApi, myParentId);
-    myModelWidgets.append(aWdg);
-    aResult = aWdg;
-  } else if (theType == WDG_SWITCH) {
-    aResult = new ModuleBase_WidgetSwitch(theParent);
-  } else if (theType == WDG_TOOLBOX_BOX || theType == WDG_SWITCH_CASE) {
-    // Do nothing for "box" and "case"
-    aResult = NULL;
+  if (result) {
+    myModelWidgets.append(result);
   }
-#ifdef _DEBUG
-  else {qDebug() << "ModuleBase_WidgetFactory::fillWidget: find bad container type";}
-#endif
-  return aResult;
-}
-
-QWidget* ModuleBase_WidgetFactory::labelControl(QWidget* theParent)
-{
-  ModuleBase_WidgetLabel* aWgt =
-      new ModuleBase_WidgetLabel(theParent, myWidgetApi, myParentId);
-  myModelWidgets.append(aWgt);
-  return aWgt;
-}
-
-QWidget* ModuleBase_WidgetFactory::doubleSpinBoxControl(QWidget* theParent)
-{
-  ModuleBase_WidgetDoubleValue* aDblWgt =
-      new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi, myParentId);
-  myModelWidgets.append(aDblWgt);
-  return aDblWgt;
-}
-
-QWidget* ModuleBase_WidgetFactory::doubleValueEditor(QWidget* theParent)
-{
-  ModuleBase_WidgetEditor* aWidget =
-      new ModuleBase_WidgetEditor(theParent, myWidgetApi, myParentId);
-  myModelWidgets.append(aWidget);
-  return aWidget;
-}
-
-QWidget* ModuleBase_WidgetFactory::shapeSelectorControl(QWidget* theParent)
-{
-  ModuleBase_WidgetShapeSelector* aSelector =
-      new ModuleBase_WidgetShapeSelector(theParent, myWorkshop, myWidgetApi, myParentId);
-  myModelWidgets.append(aSelector);
-  return aSelector;
-}
-
-QWidget* ModuleBase_WidgetFactory::booleanControl(QWidget* theParent)
-{
-  ModuleBase_WidgetBoolValue* aBoolWgt =
-      new ModuleBase_WidgetBoolValue(theParent, myWidgetApi, myParentId);
-  myModelWidgets.append(aBoolWgt);
-  return aBoolWgt;
-}
-
-QWidget* ModuleBase_WidgetFactory::fileSelectorControl(QWidget* theParent)
-{
-  ModuleBase_WidgetFileSelector* aFileSelectorWgt =
-      new ModuleBase_WidgetFileSelector(theParent, myWidgetApi, myParentId);
-  myModelWidgets.append(aFileSelectorWgt);
-  return aFileSelectorWgt;
-}
-
-QWidget* ModuleBase_WidgetFactory::choiceControl(QWidget* theParent)
-{
-  ModuleBase_WidgetChoice* aChoiceWgt =
-      new ModuleBase_WidgetChoice(theParent, myWidgetApi,myParentId);
-  myModelWidgets.append(aChoiceWgt);
-  return aChoiceWgt;
-}
-
-QWidget* ModuleBase_WidgetFactory::lineEditControl(QWidget* theParent)
-{
-  ModuleBase_WidgetLineEdit* aLineEditWgt =
-      new ModuleBase_WidgetLineEdit(theParent, myWidgetApi,myParentId);
-  myModelWidgets.append(aLineEditWgt);
-  return aLineEditWgt;
-}
-
-QWidget* ModuleBase_WidgetFactory::multiSelectorControl(QWidget* theParent)
-{
-  ModuleBase_WidgetMultiSelector* aMultiselectorWgt =
-      new ModuleBase_WidgetMultiSelector(theParent, myWorkshop, myWidgetApi,myParentId);
-  myModelWidgets.append(aMultiselectorWgt);
-  return aMultiselectorWgt;
+  return result;
 }
 
 QString ModuleBase_WidgetFactory::qs(const std::string& theStdString)
index 71834e86d3db0d8bfe80e377eff9eef5c6400c14..1e1f29fa76e8dfc54e6de9b682f1efc2881cc0f5 100644 (file)
@@ -7,11 +7,11 @@
  *      Author: sbh
  */
 
-#ifndef ModuleBase_WidgetFactory_H_
-#define ModuleBase_WidgetFactory_H_
+#ifndef MODULEBASE_WIDGETFACTORY_H_
+#define MODULEBASE_WIDGETFACTORY_H_
 
-#include "ModuleBase.h"
-#include "ModuleBase_ModelWidget.h"
+#include <ModuleBase.h>
+#include <ModuleBase_ModelWidget.h>
 
 #include <QString>
 #include <QList>
@@ -20,6 +20,7 @@ class QObject;
 class QWidget;
 class Config_WidgetAPI;
 class ModuleBase_IWorkshop;
+class ModuleBase_PageBase;
 
 /**
 * \ingroup GUI
@@ -38,7 +39,7 @@ class MODULEBASE_EXPORT ModuleBase_WidgetFactory
 
   /// Creates content widget for property panel
   /// \param theParent a parent widget
-  void createWidget(QWidget* theParent);
+  void createWidget(ModuleBase_PageBase* theParent);
 
 
   /// Returns list of model widgets
@@ -53,48 +54,8 @@ class MODULEBASE_EXPORT ModuleBase_WidgetFactory
    /// Create widget by its type
    /// \param theType a type
    /// \param theParent a parent widget
-  QWidget* createWidgetByType(const std::string& theType, QWidget* theParent = NULL);
-
-   /// Create a widget of container type
-   /// \param theType a type
-   /// \param theParent a parent widget
-  QWidget* createContainer(const std::string& theType, QWidget* theParent);
-
-  /// Create label widget
-  /// \param theParent a parent widget
-  QWidget* labelControl(QWidget* theParent);
-
-  /// Create double spin box widget
-  /// \param theParent a parent widget
-  QWidget* doubleSpinBoxControl(QWidget* theParent);
-
-  /// Create double value editor widget
-  /// \param theParent a parent widget
-  QWidget* doubleValueEditor(QWidget* theParent);
-
-  /// Create shape selector widget
-  /// \param theParent a parent widget
-  QWidget* shapeSelectorControl(QWidget* theParent);
-
-  /// Create boolean input widget
-  /// \param theParent a parent widget
-  QWidget* booleanControl(QWidget* theParent);
-
-  /// Create file selector widget
-  /// \param theParent a parent widget
-  QWidget* fileSelectorControl(QWidget* theParent);
-
-  /// Create choice widget (combo box)
-  /// \param theParent a parent widget
-  QWidget* choiceControl(QWidget* theParent);
-
-  /// Create line edit widget
-  /// \param theParent a parent widget
-  QWidget* lineEditControl(QWidget* theParent);
-
-  /// Create multi selector widget
-  /// \param theParent a parent widget
-  QWidget* multiSelectorControl(QWidget* theParent);
+  ModuleBase_ModelWidget* createWidgetByType(const std::string& theType,
+                                             QWidget* theParent = NULL);
 
   /// Convert STD string to QT string
   /// \param theStdString is STD string
index e1571cab161848fa45b510b48aa75cbc410ca996..aec77a6b99403faccf2023d2ce21d5c00184cada 100644 (file)
@@ -8,20 +8,24 @@
  */
 
 #include <ModuleBase_WidgetSwitch.h>
+#include <ModuleBase_ModelWidget.h>
+#include <ModuleBase_PageBase.h>
 
 #include <QComboBox>
 #include <QVBoxLayout>
 #include <QSpacerItem>
 
-ModuleBase_WidgetSwitch::ModuleBase_WidgetSwitch(QWidget* parent)
-    : QFrame(parent)
+
+ModuleBase_WidgetSwitch::ModuleBase_WidgetSwitch(QWidget* theParent, const Config_WidgetAPI* theData,
+                                                 const std::string& theParentId)
+: ModuleBase_ModelWidget(theParent, theData, theParentId)
 {
   myMainLay = new QVBoxLayout(this);
   myMainLay->setContentsMargins(2, 4, 2, 2);
   myCombo = new QComboBox(this);
   myCombo->hide();
   myMainLay->addWidget(myCombo);
-  this->setFrameShape(QFrame::StyledPanel);
+  //this->setFrameShape(QFrame::StyledPanel);
   connect(myCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setCurrentIndex(int)));
   connect(myCombo, SIGNAL(currentIndexChanged(int)), this, SIGNAL(currentPageChanged(int)));
 
@@ -31,6 +35,13 @@ ModuleBase_WidgetSwitch::~ModuleBase_WidgetSwitch()
 {
 }
 
+QList<QWidget*> ModuleBase_WidgetSwitch::getControls() const
+{
+  QList<QWidget*> aList;
+  aList << myCombo;
+  return aList;
+}
+
 int ModuleBase_WidgetSwitch::addPage(QWidget* theWidget, const QString& theName)
 {
   return insertPage(count(), theWidget, theName);
index f105bc6fda25ba4c75eb4220ecc5f581f445c5bc..1f10c2eead1072a7116d95eeaf2e156248d7a4d8 100644 (file)
@@ -11,7 +11,7 @@
 #define ModuleBase_WidgetSwitch_H_
 
 #include <ModuleBase.h>
-#include <QFrame>
+#include <ModuleBase_ModelWidget.h>
 
 class QComboBox;
 class QVBoxLayout;
@@ -20,19 +20,31 @@ class QVBoxLayout;
 * \ingroup GUI
 * Implements a model widget for swithch as a container widget. It can be defined in XML with "switch" keyword
 */
-class MODULEBASE_EXPORT ModuleBase_WidgetSwitch : public QFrame
+class MODULEBASE_EXPORT ModuleBase_WidgetSwitch : public ModuleBase_ModelWidget
 {
-Q_OBJECT
+  Q_OBJECT
  public:
    /// Constructor
    /// \param parent a parent widget
-  ModuleBase_WidgetSwitch(QWidget* parent = NULL);
+  ModuleBase_WidgetSwitch(QWidget* theParent,
+                          const Config_WidgetAPI* theData,
+                          const std::string& theParentId);
   virtual ~ModuleBase_WidgetSwitch();
 
+  virtual bool restoreValue() {
+    return false;
+  }
+
+  virtual QList<QWidget*> getControls() const;
+
+  virtual bool focusTo() {
+    return false;
+  }
+
   /// Add a page to the widget
   /// \param theWidget a page widget
   /// \param theName a name of page
-  int addPage(QWidget * theWidget, const QString & theName);
+  int addPage(QWidget* theWidget, const QString & theName);
 
   /// Returns count of pages
   int count() const;
@@ -94,6 +106,9 @@ signals:
   void currentPageChanged(int);
 
  protected:
+  virtual bool storeValueCustom() const {
+    return false;
+  }
   /// Update widget
   void refresh();
 
index 220be9b70616faf476bf0e9e85f41cff02907350..616a5c357972c3468911cdf69d6017799ec64d66 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include <ModuleBase_WidgetToolbox.h>
+#include <ModuleBase_PageBase.h>
 #include <ModuleBase_Tools.h>
 
 #include <ModelAPI_AttributeString.h>
@@ -28,9 +29,6 @@ ModuleBase_WidgetToolbox::ModuleBase_WidgetToolbox(QWidget* theParent, const Con
                               "border-color:#fff #505050 #505050 #fff;}";
   myToolBox->setStyleSheet(css);
   // default vertical size policy is preferred
-  QSizePolicy aSizePolicy = myToolBox->sizePolicy();
-  aSizePolicy.setVerticalPolicy(QSizePolicy::MinimumExpanding);
-  myToolBox->setSizePolicy(aSizePolicy);
   aMainLayout->addWidget(myToolBox);
 
   connect(myToolBox, SIGNAL(currentChanged(int)), this, SLOT(onPageChanged()));
@@ -40,11 +38,15 @@ ModuleBase_WidgetToolbox::~ModuleBase_WidgetToolbox()
 {
 }
 
-int ModuleBase_WidgetToolbox::addPage(QWidget* theWidget,
+int ModuleBase_WidgetToolbox::addPage(ModuleBase_PageBase* thePage,
                                       const QString& theName, const QString& theCaseId)
 {
   myCaseIds << theCaseId;
-  return myToolBox->addItem(theWidget, theName);
+  myPages << thePage;
+  QFrame* aFrame = dynamic_cast<QFrame*>(thePage);
+  aFrame->setFrameShape(QFrame::Box);
+  aFrame->setFrameStyle(QFrame::Sunken);
+  return myToolBox->addItem(aFrame, theName);
 }
 
 bool ModuleBase_WidgetToolbox::restoreValue()
@@ -61,6 +63,7 @@ bool ModuleBase_WidgetToolbox::restoreValue()
   bool isSignalsBlocked = myToolBox->blockSignals(true);
   myToolBox->setCurrentIndex(idx);
   myToolBox->blockSignals(isSignalsBlocked);
+  focusTo();
   return true;
 }
 
@@ -71,6 +74,20 @@ QList<QWidget*> ModuleBase_WidgetToolbox::getControls() const
   return aList;
 }
 
+bool ModuleBase_WidgetToolbox::focusTo()
+{
+  int idx = myToolBox->currentIndex();
+  if (idx > myPages.count())
+    return false;
+  myPages[idx]->takeFocus();
+  repaint();
+  return true;
+}
+
+void ModuleBase_WidgetToolbox::activateCustom()
+{
+}
+
 bool ModuleBase_WidgetToolbox::storeValueCustom() const
 {
   // A rare case when plugin was not loaded.
@@ -86,4 +103,5 @@ bool ModuleBase_WidgetToolbox::storeValueCustom() const
 void ModuleBase_WidgetToolbox::onPageChanged()
 {
   storeValue();
+  focusTo();
 }
index c57c75e02d625061ab943ebb23e93d3ce179939f..2e106a720903b35294ad6a48600260e28b3ca633 100644 (file)
@@ -12,6 +12,8 @@
 
 #include <QToolBox>
 
+class ModuleBase_PageBase;
+
 class ModuleBase_WidgetToolbox : public ModuleBase_ModelWidget
 {
   Q_OBJECT
@@ -22,10 +24,13 @@ class ModuleBase_WidgetToolbox : public ModuleBase_ModelWidget
 
   virtual bool restoreValue();
   virtual QList<QWidget*> getControls() const;
+  virtual bool focusTo();
 
-  int addPage(QWidget* theWidget, const QString& theName, const QString& theCaseId);
+  int addPage(ModuleBase_PageBase* theWidget,
+              const QString& theName, const QString& theCaseId);
 
  protected:
+  virtual void activateCustom();
   virtual bool storeValueCustom() const;
 
  protected slots:
@@ -34,6 +39,7 @@ class ModuleBase_WidgetToolbox : public ModuleBase_ModelWidget
  private:
   QToolBox* myToolBox;
   QStringList myCaseIds;
+  QList<ModuleBase_PageBase*> myPages;
 };
 
 #endif /* MODULEBASE_WIDGETTOOLBOX_H_ */
index 68a69ad97c4b7d30a67ee6373f35759cf4769d60..abc1378b5926ce1adb66a4a39f26ec53c01db59c 100644 (file)
@@ -447,9 +447,8 @@ void PartSet_Module::onVertexSelected()
   }
 }
 
-QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
-                                            Config_WidgetAPI* theWidgetApi, std::string theParentId,
-                                            QList<ModuleBase_ModelWidget*>& theModelWidgets)
+ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
+                                            Config_WidgetAPI* theWidgetApi, std::string theParentId)
 {
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
   XGUI_Workshop* aWorkshop = aConnector->workshop();
@@ -482,8 +481,6 @@ QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget*
     aConstraintShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
     aWgt = aConstraintShapeSelectorWgt;
   }
-  if(aWgt)
-    theModelWidgets.append(aWgt);
   return aWgt;
 }
 
index 67484a6d7f985e07bb7ed8360166f803906515a6..138ffb3de55b36efdd68503bc2084213ced3b74e 100644 (file)
@@ -52,9 +52,8 @@ public:
   virtual ~PartSet_Module();
 
   /// Creates custom widgets for property panel
-  virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
-                                      Config_WidgetAPI* theWidgetApi, std::string theParentId,
-                                      QList<ModuleBase_ModelWidget*>& theModelWidgets);
+  virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
+                                                     Config_WidgetAPI* theWidgetApi, std::string theParentId);
 
   /// Call back forlast tuning of property panel before operation performance
   virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
index 3b9e813c2ba6efa80b0280ed04dc5973c70c4943..8ecc6bde02b07a9e6968e518ac3558a97e61778f 100644 (file)
@@ -116,7 +116,8 @@ void fillFeature2Attribute(const QList<ModuleBase_ViewerPrs>& theList,
 PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule)
   : QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false),
     myIsPropertyPanelValueChanged(false), myIsMouseOverWindow(false),
-    myIsMouseOverViewProcessed(true), myPreviousUpdateViewerEnabled(true)
+    myIsMouseOverViewProcessed(true), myPreviousUpdateViewerEnabled(true),
+    myIsPopupMenuActive(false)
 {
   ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
   ModuleBase_IViewer* aViewer = anIWorkshop->viewer();
@@ -236,6 +237,8 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
 {
   get2dPoint(theWnd, theEvent, myClickedPoint);
 
+  myIsPopupMenuActive = theEvent->buttons() & Qt::RightButton;
+
   if (!(theEvent->buttons() & Qt::LeftButton))
     return;
 
@@ -315,6 +318,9 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
 
 void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
 {
+  if (myIsPopupMenuActive)
+    myIsPopupMenuActive = false;
+
   ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
   ModuleBase_IViewer* aViewer = aWorkshop->viewer();
   if (!aViewer->canDragByMouse())
@@ -727,6 +733,8 @@ bool PartSet_SketcherMgr::canDisplayObject() const
       return aCanDisplay;
     }
   }
+  if (myIsPopupMenuActive)
+    return aCanDisplay;
 
   // during a nested create operation, the feature is redisplayed only if the mouse over view
   // of there was a value modified in the property panel after the mouse left the view
@@ -768,7 +776,7 @@ bool PartSet_SketcherMgr::canChangeConstruction(bool& isConstruction) const
         std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
                             std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
         if (aSketchFeature.get() != NULL) {
-          std::string anAttribute = SketchPlugin_Feature::CONSTRUCTION_ID();
+          std::string anAttribute = SketchPlugin_SketchEntity::CONSTRUCTION_ID();
 
           std::shared_ptr<ModelAPI_AttributeBoolean> aConstructionAttr = 
             std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(aSketchFeature->data()->attribute(anAttribute));
@@ -821,7 +829,7 @@ void PartSet_SketcherMgr::setConstruction(const bool isChecked)
         std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
                             std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
         if (aSketchFeature.get() != NULL) {
-          std::string anAttribute = SketchPlugin_Feature::CONSTRUCTION_ID();
+          std::string anAttribute = SketchPlugin_SketchEntity::CONSTRUCTION_ID();
 
           std::shared_ptr<ModelAPI_AttributeBoolean> aConstructionAttr = 
             std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(aSketchFeature->data()->attribute(anAttribute));
index 57f17840fda7e640a7901c350c246531a5483b48..6f7cbc8f510b4b352b6d0dd9f65fa4259706f734 100644 (file)
@@ -251,6 +251,7 @@ private:
   bool myIsPropertyPanelValueChanged; /// the state that value in the property panel is changed
   bool myIsMouseOverWindow; /// the state that the mouse over the view
   bool myIsMouseOverViewProcessed; /// the state whether the over view state is processed by mouseMove method
+  bool myIsPopupMenuActive; /// the state of the popup menu is shown
   Point myCurrentPoint;
   Point myClickedPoint;
 
index d77f86d1e03562d02f6a10cafd07c764099f4355..56f1ac3fc83708bdb32db18c07286b58c225aa4b 100644 (file)
@@ -462,7 +462,7 @@ ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShap
       DataPtr aData = aMyFeature->data();
       AttributeSelectionPtr anAttr = 
         std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
-        (aData->attribute(SketchPlugin_Feature::EXTERNAL_ID()));
+        (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
 
       ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
       if (anAttr && aRes) {
@@ -495,7 +495,7 @@ ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShap
       DataPtr aData = aMyFeature->data();
       AttributeSelectionPtr anAttr = 
         std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
-        (aData->attribute(SketchPlugin_Feature::EXTERNAL_ID()));
+        (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
 
       ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
       if (anAttr && aRes) {
index 5925437ed68ebcdf91fe921535220636c0141e50..1a20133b41d30f23f6d306a6def256f63a7057ca 100644 (file)
@@ -7,6 +7,8 @@
 #include "PartSet_WidgetSketchLabel.h"
 #include "PartSet_Tools.h"
 
+#include "SketchPlugin_SketchEntity.h"
+
 #include <XGUI_Workshop.h>
 #include <XGUI_Displayer.h>
 #include <XGUI_SelectionMgr.h>
@@ -91,7 +93,7 @@ void PartSet_WidgetSketchLabel::onPlaneSelected()
           DataPtr aData = feature()->data();
           AttributeSelectionPtr aSelAttr = 
             std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
-            (aData->attribute(SketchPlugin_Feature::EXTERNAL_ID()));
+            (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
           if (aSelAttr) {
             ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aPrs.object());
             if (aRes) {
index 796ec88ef9ccfdc1f81f2ec25c7355ab86cc9f95..d580c0de6a89753e55cecf9f5d1dd217bab46a1b 100644 (file)
@@ -2,6 +2,7 @@
  <qresource>
      <file>icons/arc.png</file>
      <file>icons/circle.png</file>
+     <file>icons/color.png</file>
      <file>icons/point.png</file>
      <file>icons/plane.png</file>
      <file>icons/axis.png</file>
diff --git a/src/PartSet/icons/color.png b/src/PartSet/icons/color.png
new file mode 100644 (file)
index 0000000..41b0b8c
Binary files /dev/null and b/src/PartSet/icons/color.png differ
index 15bbb1fb7281c5a4d3f6cf05e63f117b1ea42903..01c640568d5617ede4b48ae4725b6f6af098850f 100644 (file)
@@ -8,6 +8,7 @@ SET(PROJECT_HEADERS
     SketchPlugin_Feature.h
     SketchPlugin_Plugin.h
     SketchPlugin_Sketch.h
+    SketchPlugin_SketchEntity.h
     SketchPlugin_Line.h
     SketchPlugin_Point.h
     SketchPlugin_Circle.h
@@ -30,6 +31,7 @@ SET(PROJECT_SOURCES
     SketchPlugin_Feature.cpp
     SketchPlugin_Plugin.cpp
     SketchPlugin_Sketch.cpp
+    SketchPlugin_SketchEntity.cpp
     SketchPlugin_Line.cpp
     SketchPlugin_Point.cpp
     SketchPlugin_Circle.cpp
index deb2b2faeb4df9d9c5a40f08aa6fd5039b362e9d..f4bc7f93e3e5aca6c75a8b88e3d620cbcc6ab5fd 100644 (file)
@@ -23,7 +23,7 @@
 const double tolerance = 1e-7;
 
 SketchPlugin_Arc::SketchPlugin_Arc()
-    : SketchPlugin_Feature()
+    : SketchPlugin_SketchEntity()
 {
   myStartUpdate = false;
   myEndUpdate = false;
@@ -31,6 +31,8 @@ SketchPlugin_Arc::SketchPlugin_Arc()
 
 void SketchPlugin_Arc::initAttributes()
 {
+  SketchPlugin_SketchEntity::initAttributes();
+
   data()->addAttribute(CENTER_ID(), GeomDataAPI_Point2D::type());
   data()->addAttribute(START_ID(), GeomDataAPI_Point2D::type());
   data()->addAttribute(END_ID(), GeomDataAPI_Point2D::type());
index 044d074627efede8d9e5d561e4912573078d0603..47a9f9dd45d2d089d1f2c469478ba1631d2b1b17 100644 (file)
@@ -8,7 +8,7 @@
 #define SketchPlugin_Arc_H_
 
 #include "SketchPlugin.h"
-#include <SketchPlugin_Feature.h>
+#include <SketchPlugin_SketchEntity.h>
 #include <SketchPlugin_Sketch.h>
 #include <GeomAPI_IPresentable.h>
 
@@ -19,7 +19,7 @@
  * calculated when there is non-initialized attributes of the arc. The second is a result and
  * it is calculated if all attributes are initialized.
  */
-class SketchPlugin_Arc : public SketchPlugin_Feature, public GeomAPI_IPresentable
+class SketchPlugin_Arc : public SketchPlugin_SketchEntity, public GeomAPI_IPresentable
 {
   /// to avoid cyclic dependencies in automatic updates: they mean that 
   /// update is performed right now and automatic updates are not needed
index e880df9afc2f7e47e06ddb185ae6ea4ce449c4ca..50b387414b82402e10bec366908b2d2d856f24fa 100644 (file)
 #include <GeomAlgoAPI_CompoundBuilder.h>
 
 SketchPlugin_Circle::SketchPlugin_Circle()
-    : SketchPlugin_Feature()
+    : SketchPlugin_SketchEntity()
 {
 }
 
 void SketchPlugin_Circle::initAttributes()
 {
+  SketchPlugin_SketchEntity::initAttributes();
+
   data()->addAttribute(CENTER_ID(), GeomDataAPI_Point2D::type());
   data()->addAttribute(RADIUS_ID(), ModelAPI_AttributeDouble::type());
   data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
index f3434d4b52566d187f150e99915de9cc9a06f509..e4f705e76300fe56dee16c4ab913127247f1b77a 100644 (file)
@@ -8,7 +8,7 @@
 #define SketchPlugin_Circle_H_
 
 #include "SketchPlugin.h"
-#include <SketchPlugin_Feature.h>
+#include <SketchPlugin_SketchEntity.h>
 #include <SketchPlugin_Sketch.h>
 #include <GeomAPI_IPresentable.h>
 
@@ -16,7 +16,7 @@
  * \ingroup Plugins
  * \brief Feature for creation of the new circle in PartSet.
  */
-class SketchPlugin_Circle : public SketchPlugin_Feature 
+class SketchPlugin_Circle : public SketchPlugin_SketchEntity 
 {
  public:
   /// Circle feature kind
index 4be01f0a671d9f67e746adb41159ae4526716c93..b8437dcbcaf7c3674d2399bc47ac87a5d4171668 100644 (file)
 #include <ModelAPI_Document.h>
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeBoolean.h>
-#include <GeomAPI_ICustomPrs.h>
 
 #include <Config_PropManager.h>
 
-#define SKETCH_EDGE_COLOR "#ff0000"
-#define SKETCH_POINT_COLOR "#ff0000"
-#define SKETCH_EXTERNAL_EDGE_COLOR "#00ff00"
-#define SKETCH_CONSTRUCTION_COLOR "#000000"
-
 class SketchPlugin_Sketch;
 class GeomAPI_Pnt2d;
 class Handle_AIS_InteractiveObject;
@@ -32,25 +26,17 @@ class Handle_AIS_InteractiveObject;
  * \brief Feature for creation of the new feature in PartSet. This is an abstract class to give
  * an interface to create the sketch feature preview.
  */
-class SketchPlugin_Feature : public ModelAPI_Feature, public GeomAPI_ICustomPrs
+class SketchPlugin_Feature : public ModelAPI_Feature
 {
  public:
-  /// Reference to the construction type of the feature
-  inline static const std::string& CONSTRUCTION_ID()
-  {
-    static const std::string MY_CONSTRUCTION_ID("Construction");
-    return MY_CONSTRUCTION_ID;
-  }
-
-  /// Reference to the external edge or vertex as a AttributeSelection
-  inline static const std::string& EXTERNAL_ID()
+  /// Returns true if this feature must be displayed in the history (top level of Part tree)
+  SKETCHPLUGIN_EXPORT virtual bool isInHistory()
   {
-    static const std::string MY_EXTERNAL_ID("External");
-    return MY_EXTERNAL_ID;
+    return false;
   }
 
-  /// Returns true if this feature must be displayed in the history (top level of Part tree)
-  SKETCHPLUGIN_EXPORT virtual bool isInHistory()
+  /// Returns true of the feature is created basing on the external shape of not-this-sketch object
+  SKETCHPLUGIN_EXPORT virtual bool isExternal() const
   {
     return false;
   }
@@ -70,60 +56,6 @@ class SketchPlugin_Feature : public ModelAPI_Feature, public GeomAPI_ICustomPrs
   /// Returns true is sketch element is under the rigid constraint
   SKETCHPLUGIN_EXPORT virtual bool isFixed() {return false;}
 
-  /// Returns true of the feature is created basing on the external shape of not-this-sketch object
-  inline bool isExternal() const
-  {
-    AttributeSelectionPtr aAttr = data()->selection(EXTERNAL_ID());
-    if (aAttr)
-      return aAttr->context().get() != NULL;
-    return false;
-  }
-
-  /// Customize presentation of the feature
-  virtual void customisePresentation(AISObjectPtr thePrs)
-  {
-    std::vector<int> aRGB;
-  
-    int aShapeType = thePrs->getShapeType();
-    if (aShapeType != 6/*an edge*/ && aShapeType != 7/*a vertex*/)
-      return;
-
-    std::shared_ptr<ModelAPI_AttributeBoolean> aConstructionAttr =
-                                   data()->boolean(SketchPlugin_Feature::CONSTRUCTION_ID());
-    bool isConstruction = aConstructionAttr.get() != NULL && aConstructionAttr->value();
-    if (aShapeType == 6) { // if this is an edge
-      if (isConstruction) {
-        thePrs->setWidth(1);
-        thePrs->setLineStyle(3);
-        aRGB = Config_PropManager::color("Visualization", "sketch_construction_color",
-                                         SKETCH_CONSTRUCTION_COLOR);
-      }
-      else {
-        thePrs->setWidth(3);
-        thePrs->setLineStyle(0);
-        if (isExternal()) {
-          // Set color from preferences
-          aRGB = Config_PropManager::color("Visualization", "sketch_external_color",
-                                           SKETCH_EXTERNAL_EDGE_COLOR);
-        }
-        else {
-          // Set color from preferences
-          aRGB = Config_PropManager::color("Visualization", "sketch_edge_color",
-                                           SKETCH_EDGE_COLOR);
-        }
-      }
-    }
-    else if (aShapeType == 7) { // otherwise this is a vertex
-      //  thePrs->setPointMarker(6, 2.);
-      // Set color from preferences
-      aRGB = Config_PropManager::color("Visualization", "sketch_point_color",
-                                       SKETCH_POINT_COLOR);
-    }
-
-    if (!aRGB.empty())
-      thePrs->setColor(aRGB[0], aRGB[1], aRGB[2]);
-  }
-
   /// Returns the sketch of this feature
   SketchPlugin_Sketch* sketch();
 protected:
index ee7193e72b5d7b24ecda26152b6fe58134500c4f..f0c76538a92ff0973a46813f32945c8299bf854c 100644 (file)
 using namespace std;
 
 SketchPlugin_Line::SketchPlugin_Line()
-    : SketchPlugin_Feature()
+    : SketchPlugin_SketchEntity()
 {}
 
 void SketchPlugin_Line::initAttributes()
 {
+  SketchPlugin_SketchEntity::initAttributes();
+
   data()->addAttribute(START_ID(), GeomDataAPI_Point2D::type());
   data()->addAttribute(END_ID(), GeomDataAPI_Point2D::type());
-  data()->addAttribute(CONSTRUCTION_ID(), ModelAPI_AttributeBoolean::type());
   data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
 }
index 1984f8368997b73e299588a6a4a008804c419a48..05d94cc65e59bd582bd6290920a1d7820d995e4a 100644 (file)
@@ -8,7 +8,7 @@
 #define SketchPlugin_Line_H_
 
 #include "SketchPlugin.h"
-#include <SketchPlugin_Feature.h>
+#include <SketchPlugin_SketchEntity.h>
 #include <SketchPlugin_Sketch.h>
 #include <list>
 
@@ -16,7 +16,7 @@
  * \ingroup Plugins
  * \brief Feature for creation of the new part in PartSet.
  */
-class SketchPlugin_Line : public SketchPlugin_Feature
+class SketchPlugin_Line : public SketchPlugin_SketchEntity
 {
  public:
   /// Arc feature kind
index 3fd71b5609e3429a5102ac7b9e314d69982802d2..798140611b2755a7b86248a055617fa84aed4e44 100644 (file)
 using namespace std;
 
 SketchPlugin_Point::SketchPlugin_Point()
+    : SketchPlugin_SketchEntity()
 {
 }
 
 void SketchPlugin_Point::initAttributes()
 {
+  SketchPlugin_SketchEntity::initAttributes();
+
   data()->addAttribute(SketchPlugin_Point::COORD_ID(), GeomDataAPI_Point2D::type());
   data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
index 27a288763194468b636a996a8b723212b0c977a3..4c774715757edc8463ee320102c7699d01f70ed7 100644 (file)
@@ -9,14 +9,14 @@
 
 #include "SketchPlugin.h"
 #include <SketchPlugin_Sketch.h>
-#include "SketchPlugin_Feature.h"
+#include "SketchPlugin_SketchEntity.h"
 #include <list>
 
 /**\class SketchPlugin_Point
  * \ingroup Plugins
  * \brief Feature for creation of a new point.
  */
-class SketchPlugin_Point : public SketchPlugin_Feature
+class SketchPlugin_Point : public SketchPlugin_SketchEntity
 {
  public:
   /// Point feature kind
index fdaff1d845dc23e5acf05d4a15f65631af23b661..58ab7cb98af9708399f88d172a257094dd8a7839 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <SketchPlugin_Sketch.h>
 #include <SketchPlugin_Feature.h>
+#include <SketchPlugin_SketchEntity.h>
 
 #include <memory>
 
@@ -49,9 +50,9 @@ void SketchPlugin_Sketch::initAttributes()
   data()->addAttribute(SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir::type());
   data()->addAttribute(SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList::type());
   // the selected face, base for the sketcher plane, not obligatory
-  data()->addAttribute(SketchPlugin_Feature::EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
+  data()->addAttribute(SketchPlugin_SketchEntity::EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
   ModelAPI_Session::get()->validators()->registerNotObligatory(
-    getKind(), SketchPlugin_Feature::EXTERNAL_ID());
+    getKind(), SketchPlugin_SketchEntity::EXTERNAL_ID());
 }
 
 void SketchPlugin_Sketch::execute()
@@ -83,13 +84,13 @@ void SketchPlugin_Sketch::execute()
       if (!aFeature->sketch()) // on load document the back references are missed
         aFeature->setSketch(this);
       // do not include the external edges into the result
-      if (aFeature->data()->attribute(SketchPlugin_Feature::EXTERNAL_ID())) {
-        if (aFeature->data()->selection(SketchPlugin_Feature::EXTERNAL_ID())->value())
+      if (aFeature->data()->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())) {
+        if (aFeature->data()->selection(SketchPlugin_SketchEntity::EXTERNAL_ID())->value())
           continue;
       }
       // do not include the construction entities in the result
-      if (aFeature->data()->attribute(SketchPlugin_Feature::CONSTRUCTION_ID())) {
-        if (aFeature->data()->boolean(SketchPlugin_Feature::CONSTRUCTION_ID())->value())
+      if (aFeature->data()->attribute(SketchPlugin_SketchEntity::CONSTRUCTION_ID())) {
+        if (aFeature->data()->boolean(SketchPlugin_SketchEntity::CONSTRUCTION_ID())->value())
           continue;
       }
 
@@ -274,9 +275,9 @@ void SketchPlugin_Sketch::erase()
 }
 
 void SketchPlugin_Sketch::attributeChanged(const std::string& theID) {
-  if (theID == SketchPlugin_Feature::EXTERNAL_ID()) {
+  if (theID == SketchPlugin_SketchEntity::EXTERNAL_ID()) {
     std::shared_ptr<GeomAPI_Shape> aSelection = 
-      data()->selection(SketchPlugin_Feature::EXTERNAL_ID())->value();
+      data()->selection(SketchPlugin_SketchEntity::EXTERNAL_ID())->value();
     if (aSelection) { // update arguments due to the selection value
       // update the sketch plane
       std::shared_ptr<GeomAPI_Pln> aPlane = GeomAlgoAPI_FaceBuilder::plane(aSelection);
diff --git a/src/SketchPlugin/SketchPlugin_SketchEntity.cpp b/src/SketchPlugin/SketchPlugin_SketchEntity.cpp
new file mode 100644 (file)
index 0000000..1e7c4de
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+#include "SketchPlugin_SketchEntity.h"
+
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
+
+SketchPlugin_SketchEntity::SketchPlugin_SketchEntity()
+: SketchPlugin_Feature()
+{
+}
+
+void SketchPlugin_SketchEntity::initAttributes()
+{
+  data()->addAttribute(CONSTRUCTION_ID(), ModelAPI_AttributeBoolean::type());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), CONSTRUCTION_ID());
+}
diff --git a/src/SketchPlugin/SketchPlugin_SketchEntity.h b/src/SketchPlugin/SketchPlugin_SketchEntity.h
new file mode 100644 (file)
index 0000000..c0c0925
--- /dev/null
@@ -0,0 +1,112 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        SketchPlugin_SketchEntity.h
+// Created:     05 Mar 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef SketchPlugin_SketchEntity_H_
+#define SketchPlugin_SketchEntity_H_
+
+#include "SketchPlugin.h"
+#include "SketchPlugin_Feature.h"
+
+#include <ModelAPI_CompositeFeature.h>
+#include <GeomAPI_Shape.h>
+#include <GeomAPI_AISObject.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeBoolean.h>
+#include <GeomAPI_ICustomPrs.h>
+
+#include <Config_PropManager.h>
+
+#define SKETCH_EDGE_COLOR "#ff0000"
+#define SKETCH_POINT_COLOR "#ff0000"
+#define SKETCH_EXTERNAL_EDGE_COLOR "#00ff00"
+#define SKETCH_CONSTRUCTION_COLOR "#000000"
+
+/**\class SketchPlugin_SketchEntity
+ * \ingroup Plugins
+ * \brief Sketch Entity for creation of the new feature in PartSet. This is an abstract class to give
+ * an interface to create the entity features such as line, circle, arc and point.
+ */
+class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_ICustomPrs
+{
+ public:
+  /// Reference to the construction type of the feature
+  inline static const std::string& CONSTRUCTION_ID()
+  {
+    static const std::string MY_CONSTRUCTION_ID("Construction");
+    return MY_CONSTRUCTION_ID;
+  }
+
+  /// Reference to the external edge or vertex as a AttributeSelection
+  inline static const std::string& EXTERNAL_ID()
+  {
+    static const std::string MY_EXTERNAL_ID("External");
+    return MY_EXTERNAL_ID;
+  }
+
+  /// Request for initialization of data model of the feature: adding all attributes
+  virtual void initAttributes();
+
+  /// Returns true of the feature is created basing on the external shape of not-this-sketch object
+  virtual bool isExternal() const
+  {
+    AttributeSelectionPtr aAttr = data()->selection(EXTERNAL_ID());
+    if (aAttr)
+      return aAttr->context().get() != NULL;
+    return false;
+  }
+
+  /// Customize presentation of the feature
+  virtual void customisePresentation(AISObjectPtr thePrs)
+  {
+    std::vector<int> aRGB;
+  
+    int aShapeType = thePrs->getShapeType();
+    if (aShapeType != 6/*an edge*/ && aShapeType != 7/*a vertex*/)
+      return;
+
+    std::shared_ptr<ModelAPI_AttributeBoolean> aConstructionAttr =
+                                   data()->boolean(SketchPlugin_SketchEntity::CONSTRUCTION_ID());
+    bool isConstruction = aConstructionAttr.get() != NULL && aConstructionAttr->value();
+    if (aShapeType == 6) { // if this is an edge
+      if (isConstruction) {
+        thePrs->setWidth(1);
+        thePrs->setLineStyle(3);
+        aRGB = Config_PropManager::color("Visualization", "sketch_construction_color",
+                                         SKETCH_CONSTRUCTION_COLOR);
+      }
+      else {
+        thePrs->setWidth(3);
+        thePrs->setLineStyle(0);
+        if (isExternal()) {
+          // Set color from preferences
+          aRGB = Config_PropManager::color("Visualization", "sketch_external_color",
+                                           SKETCH_EXTERNAL_EDGE_COLOR);
+        }
+        else {
+          // Set color from preferences
+          aRGB = Config_PropManager::color("Visualization", "sketch_edge_color",
+                                           SKETCH_EDGE_COLOR);
+        }
+      }
+    }
+    else if (aShapeType == 7) { // otherwise this is a vertex
+      //  thePrs->setPointMarker(6, 2.);
+      // Set color from preferences
+      aRGB = Config_PropManager::color("Visualization", "sketch_point_color",
+                                       SKETCH_POINT_COLOR);
+    }
+
+    if (!aRGB.empty())
+      thePrs->setColor(aRGB[0], aRGB[1], aRGB[2]);
+  }
+
+protected:
+  /// initializes mySketch
+  SketchPlugin_SketchEntity();
+};
+
+#endif
index 3c763c26b17f17e3b1767d4bbb5e054bec3bdf54..3875aa213b0b802f92030f0f09dc56edcacb113e 100644 (file)
@@ -15,6 +15,7 @@
       </feature>
       <feature id="SketchPoint" title="Point" tooltip="Create a new point" icon=":icons/point.png">
         <sketch-2dpoint_selector id="PointCoordindates" title="Point" tooltip="Point coordinates"/>
+        <boolvalue id="Construction" label="Construction" default="false" tooltip="Construction element" obligatory="0"/>
       </feature>
       <feature id="SketchLine" title="Line" tooltip="Create a new line" icon=":icons/line.png">
         <sketch-2dpoint_selector id="StartPoint" title="Start point" tooltip="Start point coordinates" previous_feature_param="EndPoint"/>
         <point2ddistance id="CircleRadius" first_point="CircleCenter" label="Radius:" min="0" step="1.0" default="0" icon=":icons/radius.png" tooltip="Set radius">
           <validator id="GeomValidators_Positive"/>
         </point2ddistance>
+        <boolvalue id="Construction" label="Construction" default="false" tooltip="Construction element" obligatory="0"/>
       </feature>
       <feature id="SketchArc" title="Arc" tooltip="Create a new arc" icon=":icons/arc.png">
         <sketch-2dpoint_selector id="ArcCenter" title="Center" tooltip="Center of a circle"/>
         <sketch-2dpoint_selector id="ArcStartPoint" title="Start point" tooltip="Start point"/>
         <sketch-2dpoint_selector id="ArcEndPoint" title="End point" tooltip="End point"/>
+        <boolvalue id="Construction" label="Construction" default="false" tooltip="Construction element" obligatory="0"/>
       </feature>
     </group>
       
index 2f2ff1206a37483e2afef3f205299847835b4ea3..ece5d2d2bafb64b118d6c1ea1e006ff4ef1452c2 100644 (file)
@@ -53,10 +53,14 @@ void XGUI_ContextMenuMgr::createActions()
   if (!aDesktop)
     aDesktop = myWorkshop->salomeConnector()->desktop();
   aDesktop->addAction(aAction);
+
   addAction("DELETE_CMD", aAction);
   aAction->setShortcut(Qt::Key_Delete);
   aAction->setShortcutContext(Qt::ApplicationShortcut);
 
+  aAction = new QAction(QIcon(":pictures/color.png"), tr("Color"), this);
+  addAction("COLOR_CMD", aAction);
+
   aAction = new QAction(QIcon(":pictures/eye_pencil.png"), tr("Show"), this);
   addAction("SHOW_CMD", aAction);
 
@@ -188,6 +192,9 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const
     if (hasFeature)
       aMenu->addAction(action("DELETE_CMD"));
   }
+  if (myWorkshop->canChangeColor())
+    aMenu->addAction(action("COLOR_CMD"));
+
   aMenu->addSeparator();
   aMenu->addActions(myWorkshop->objectBrowser()->actions());
 
@@ -257,6 +264,8 @@ void XGUI_ContextMenuMgr::addViewerItems(QMenu* theMenu) const
       aSubMenu->addActions(aMDI->actions());
     }
   }
+  if (myWorkshop->canChangeColor())
+    theMenu->addAction(action("COLOR_CMD"));
 
   ModuleBase_IModule* aModule = myWorkshop->module();
   if (aModule)
index 6135ea32d39b0fe1d6d1f9013e6f63d4864c5d7f..9d6884b929cf0ce4749daeb8a52ad28ffaf22674 100644 (file)
@@ -16,6 +16,7 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Tools.h>
+#include <ModelAPI_AttributeIntArray.h>
 
 #include <ModuleBase_ResultPrs.h>
 
@@ -157,13 +158,8 @@ void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS,
     aContext->Display(anAISIO, false);
 
     aContext->SetDisplayMode(anAISIO, isShading? Shading : Wireframe, false);
-    // Customization of presentation
-    FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
-    if (aFeature.get() != NULL) {
-      GeomCustomPrsPtr aCustPrs = std::dynamic_pointer_cast<GeomAPI_ICustomPrs>(aFeature);
-      if (aCustPrs.get() != NULL)
-        aCustPrs->customisePresentation(theAIS);
-    }
+
+    customizeObject(theObject);
     if (aCanBeShaded) {
       openLocalContext();
       activateObjects(myActiveSelectionModes);
@@ -243,12 +239,7 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer)
       }
     }
     // Customization of presentation
-    FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
-    if (aFeature.get() != NULL) {
-      GeomCustomPrsPtr aCustPrs = std::dynamic_pointer_cast<GeomAPI_ICustomPrs>(aFeature);
-      if (aCustPrs.get() != NULL)
-        aCustPrs->customisePresentation(aAISObj);
-    }
+    customizeObject(theObject);
 
     aContext->Redisplay(aAISIO, false);
     if (isUpdateViewer)
@@ -766,3 +757,26 @@ void XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO,
     }
   }
 }
+
+void XGUI_Displayer::customizeObject(ObjectPtr theObject)
+{
+  AISObjectPtr anAISObj = getAISObject(theObject);
+  // correct the result's color it it has the attribute
+  ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+  if (aResult.get() != NULL && aResult->data()->attribute(ModelAPI_Result::COLOR_ID()).get() != NULL) {
+    AttributeIntArrayPtr aColorAttr = aResult->data()->intArray(ModelAPI_Result::COLOR_ID());
+    if (aColorAttr.get() && aColorAttr->size()) {
+      int aRed = aColorAttr->value(0);
+      int aGreen = aColorAttr->value(1);
+      int aBlue = aColorAttr->value(2);
+      anAISObj->setColor(aRed, aGreen, aBlue);
+    }
+  }
+  // Customization of presentation
+  FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+  if (aFeature.get() != NULL) {
+    GeomCustomPrsPtr aCustPrs = std::dynamic_pointer_cast<GeomAPI_ICustomPrs>(aFeature);
+    if (aCustPrs.get() != NULL)
+      aCustPrs->customisePresentation(anAISObj);
+  }
+}
index 85900ddb30cd44942786e9f49e8ce58083b0da35..e5ea6fd05d7995b7bf8d080aad56af2cc1512add 100644 (file)
@@ -214,6 +214,13 @@ class XGUI_EXPORT XGUI_Displayer
   /// Opens local context. Does nothing if it is already opened.
   void openLocalContext();
 
+  /** Update the object presentable properties such as color, lines width and other
+   * If the object is result with the color attribute value set, it is used,
+   * otherwise the customize is applyed to the object's feature if it is a custom prs
+   * \param theObject an object instance
+   */
+  void customizeObject(ObjectPtr theObject);
+
  protected:
    /// Reference to workshop
   XGUI_Workshop* myWorkshop;
index 1779431f5511a3dc204568139f8b334c7e9f72eb..0e5fcdf6008302f0de157cacc66a63239eea714c 100644 (file)
@@ -12,6 +12,8 @@
 //#include <AppElements_Constants.h>
 #include <ModuleBase_WidgetMultiSelector.h>
 #include <ModuleBase_Tools.h>
+#include <ModuleBase_PageBase.h>
+#include <ModuleBase_PageWidget.h>
 
 #include <QEvent>
 #include <QFrame>
@@ -31,7 +33,8 @@
 
 XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent)
     : ModuleBase_IPropertyPanel(theParent), 
-    myActiveWidget(NULL)
+    myActiveWidget(NULL),
+    myPanelPage(NULL)
 {
   this->setWindowTitle(tr("Property Panel"));
   QAction* aViewAct = this->toggleViewAction();
@@ -39,10 +42,10 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent)
   setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }");
 
   QWidget* aContent = new QWidget(this);
-  myMainLayout = new QGridLayout(aContent);
+  QGridLayout* aMainLayout = new QGridLayout(aContent);
   const int kPanelColumn = 0;
   int aPanelRow = 0;
-  myMainLayout->setContentsMargins(3, 3, 3, 3);
+  aMainLayout->setContentsMargins(3, 3, 3, 3);
   this->setWidget(aContent);
 
   QFrame* aFrm = new QFrame(aContent);
@@ -50,7 +53,7 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent)
   aFrm->setFrameShape(QFrame::Panel);
   QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
   ModuleBase_Tools::zeroMargins(aBtnLay);
-  myMainLayout->addWidget(aFrm, aPanelRow++, kPanelColumn);
+  aMainLayout->addWidget(aFrm, aPanelRow++, kPanelColumn);
 
   QStringList aBtnNames;
   aBtnNames << QString(PROP_PANEL_HELP)
@@ -64,10 +67,9 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent)
   }
   aBtnLay->insertStretch(1, 1);
 
-  myCustomWidget = new QWidget(aContent);
-  myCustomWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
-  myMainLayout->addWidget(myCustomWidget, aPanelRow, kPanelColumn);
-  setStretchEnabled(true);
+  myPanelPage = new ModuleBase_PageWidget(aContent);
+  myPanelPage->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
+  aMainLayout->addWidget(myPanelPage, aPanelRow, kPanelColumn);
 }
 
 XGUI_PropertyPanel::~XGUI_PropertyPanel()
@@ -79,7 +81,7 @@ void XGUI_PropertyPanel::cleanContent()
   if (myActiveWidget)
     myActiveWidget->deactivate();
   myWidgets.clear();
-  qDeleteAll(myCustomWidget->children());
+  myPanelPage->clearPage();
   myActiveWidget = NULL;
   setWindowTitle(tr("Property Panel"));
 }
@@ -116,9 +118,10 @@ const QList<ModuleBase_ModelWidget*>& XGUI_PropertyPanel::modelWidgets() const
   return myWidgets;
 }
 
-QWidget* XGUI_PropertyPanel::contentWidget()
+ModuleBase_PageBase* XGUI_PropertyPanel::contentWidget()
 {
-  return myCustomWidget;
+
+  return static_cast<ModuleBase_PageBase*>(myPanelPage);
 }
 
 void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature)
@@ -128,8 +131,7 @@ void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature)
     return;
   if (theFeature->isAction() || !theFeature->data())
     return;
-  foreach(ModuleBase_ModelWidget* eachWidget, myWidgets)
-  {
+  foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) {
     eachWidget->setFeature(theFeature);
     eachWidget->restoreValue();
   }
@@ -162,14 +164,6 @@ void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget)
   //}
 }
 
-void XGUI_PropertyPanel::setStretchEnabled(bool isEnabled)
-{
-  int aStretchIdx = myMainLayout->rowCount() - 1;
-  if (aStretchIdx < 0)
-    return;
-  myMainLayout->setRowStretch(aStretchIdx, isEnabled ? 1 : 0);
-}
-
 void XGUI_PropertyPanel::activateNextWidget()
 {
   activateNextWidget(myActiveWidget);
index 5d17060424687a4b5187498deb8a9841c9752665..cc9ba8aeb45453793c1b5cf1f08d4e9c64cedfa1 100644 (file)
@@ -20,6 +20,8 @@
 class XGUI_ActionsMgr;
 class QKeyEvent;
 class QGridLayout;
+class ModuleBase_PageBase;
+class ModuleBase_PageWidget;
 
 /// Internal name of property panel widget
 const static char* PROP_PANEL = "property_panel_dock";
@@ -50,7 +52,7 @@ Q_OBJECT
 
   /// Returns main widget of the property panel, which children will be created
   /// by WidgetFactory using the XML definition
-  QWidget* contentWidget();
+  ModuleBase_PageBase* contentWidget();
 
   /// Brings back all widget created by widget factory for signal/slot
   /// connections and further processing
@@ -72,9 +74,6 @@ Q_OBJECT
   /// Activate the next from current widget in the property panel
   virtual void activateNextWidget();
 
-  /// \brief Enable/Disable stretch area in the panel
-  void setStretchEnabled(bool isEnabled);
-
   /// Set Enable/Disable state of Cancel button
   /// \param theEnabled Enable/Disable state of Cancel button
   virtual void setCancelEnabled(bool theEnabled);
@@ -104,9 +103,8 @@ Q_OBJECT
   virtual void activateWidget(ModuleBase_ModelWidget* theWidget);
 
  private:
-  QWidget* myCustomWidget;
+  ModuleBase_PageWidget* myPanelPage;
   QList<ModuleBase_ModelWidget*> myWidgets;
-  QGridLayout* myMainLayout;
 
   /// Currently active widget
   ModuleBase_ModelWidget* myActiveWidget;
index 02fe22ef83ce679d0bbc46b6ea8ef752abde5d61..45f12d0d571c8b32b0b65b9b20ab790d4bd4c0f7 100644 (file)
 #include <ModelAPI_AttributeDocRef.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_ResultGroup.h>
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_ResultBody.h>
+#include <ModelAPI_AttributeIntArray.h>
 
 //#include <PartSetPlugin_Part.h>
 
@@ -53,6 +55,7 @@
 #include <ModuleBase_Tools.h>
 #include <ModuleBase_IViewer.h>
 #include<ModuleBase_FilterFactory.h>
+#include <ModuleBase_PageBase.h>
 
 #include <Config_Common.h>
 #include <Config_FeatureMessage.h>
 #include <QMenu>
 #include <QToolButton>
 #include <QAction>
+#include <QDialog>
+#include <QDialogButtonBox>
+#include <QHBoxLayout>
+#include <QtxColorButton.h>
 
 #ifdef _DEBUG
 #include <QDebug>
@@ -646,7 +653,6 @@ void XGUI_Workshop::setPropertyPanel(ModuleBase_Operation* theOperation)
 
   myPropertyPanel->cleanContent();
   aFactory.createWidget(myPropertyPanel->contentWidget());
-  ModuleBase_Tools::zeroMargins(myPropertyPanel->contentWidget());
 
   QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
   foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
@@ -1239,6 +1245,8 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
     activatePart(ResultPartPtr());
   else if (theId == "DELETE_CMD")
     deleteObjects(aObjects);
+  else if (theId == "COLOR_CMD")
+    changeColor(aObjects);
   else if (theId == "SHOW_CMD")
     showObjects(aObjects, true);
   else if (theId == "HIDE_CMD")
@@ -1332,7 +1340,6 @@ These features will be deleted also. Would you like to continue?")).arg(aNames),
       return;
   }
 
-  SessionPtr aMgr = ModelAPI_Session::get();
   QString aDescription = tr("Delete %1");
   QStringList aObjectNames;
   foreach (ObjectPtr aObj, theList) {
@@ -1341,6 +1348,7 @@ These features will be deleted also. Would you like to continue?")).arg(aNames),
     aObjectNames << QString::fromStdString(aObj->data()->name());
   }
   aDescription = aDescription.arg(aObjectNames.join(", "));
+  SessionPtr aMgr = ModelAPI_Session::get();
   aMgr->startOperation(aDescription.toStdString());
   std::set<FeaturePtr>::const_iterator anIt = aRefFeatures.begin(),
                                        aLast = aRefFeatures.end();
@@ -1372,6 +1380,111 @@ These features will be deleted also. Would you like to continue?")).arg(aNames),
   updateCommandStatus();
 }
 
+bool hasResults(QObjectPtrList theObjects, const std::set<std::string>& theTypes)
+{
+  bool isFoundResultType = false;
+  foreach(ObjectPtr anObj, theObjects)
+  {
+    ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
+    if (aResult.get() == NULL)
+      continue;
+
+    isFoundResultType = theTypes.find(aResult->groupName()) != theTypes.end();
+    if (isFoundResultType)
+      break;
+  }
+  return isFoundResultType;
+}
+
+//**************************************************************
+bool XGUI_Workshop::canChangeColor() const
+{
+  QObjectPtrList aObjects = mySelector->selection()->selectedObjects();
+
+  std::set<std::string> aTypes;
+  aTypes.insert(ModelAPI_ResultGroup::group());
+  aTypes.insert(ModelAPI_ResultConstruction::group());
+  aTypes.insert(ModelAPI_ResultBody::group());
+  return hasResults(aObjects, aTypes);
+}
+
+//**************************************************************
+void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects)
+{
+  // 1. find the initial value of the color
+  AttributeIntArrayPtr aColorAttr;
+  foreach(ObjectPtr anObj, theObjects) {
+    ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
+    if (aResult.get() != NULL) {
+      aColorAttr = aResult->data()->intArray(ModelAPI_Result::COLOR_ID());
+    }
+  }
+  // there is no object with the color attribute
+  if (aColorAttr.get() == NULL || aColorAttr->size() == 0)
+    return;
+  int aRed = aColorAttr->value(0);
+  int aGreen = aColorAttr->value(1);
+  int aBlue = aColorAttr->value(2);
+
+  // 2. show the dialog to change the value
+  QDialog* aDlg = new QDialog();
+  QVBoxLayout* aLay = new QVBoxLayout(aDlg);
+
+  QtxColorButton* aColorBtn = new QtxColorButton(aDlg);
+  aColorBtn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+
+  aLay->addWidget(aColorBtn);
+  aColorBtn->setColor(QColor(aRed, aGreen, aBlue));
+
+  QDialogButtonBox* aButtons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
+                                                    Qt::Horizontal, aDlg);
+  connect(aButtons, SIGNAL(accepted()), aDlg, SLOT(accept()));
+  connect(aButtons, SIGNAL(rejected()), aDlg, SLOT(reject()));
+  aLay->addWidget(aButtons);
+
+  aDlg->move(QCursor::pos());
+  bool isDone = aDlg->exec() == QDialog::Accepted;
+  if (!isDone)
+    return;
+
+  QColor aColorResult = aColorBtn->color();
+  int aRedResult = aColorResult.red(),
+      aGreenResult = aColorResult.green(),
+      aBlueResult = aColorResult.blue();
+
+  if (aRedResult == aRed && aGreenResult == aGreen && aBlueResult == aBlue)
+    return;
+
+  // 3. abort the previous operation and start a new one
+  SessionPtr aMgr = ModelAPI_Session::get();
+  bool aWasOperation = aMgr->isOperation(); // keep this value
+  if (!aWasOperation) {
+    QString aDescription = contextMenuMgr()->action("DELETE_CMD")->text();
+    aMgr->startOperation(aDescription.toStdString());
+  }
+
+  // 4. set the value to all results
+  static Events_ID EVENT_DISP = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
+  foreach(ObjectPtr anObj, theObjects) {
+    ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
+    if (aResult.get() != NULL) {
+      aColorAttr = aResult->data()->intArray(ModelAPI_Result::COLOR_ID());
+      if (aColorAttr.get() != NULL) {
+        if (!aColorAttr->size()) {
+          aColorAttr->setSize(3);
+        }
+        aColorAttr->setValue(0, aRedResult);
+        aColorAttr->setValue(1, aGreenResult);
+        aColorAttr->setValue(2, aBlueResult);
+        ModelAPI_EventCreator::get()->sendUpdated(anObj, EVENT_DISP);
+      }
+    }
+  }
+  if (!aWasOperation)
+    aMgr->finishOperation();
+  updateCommandStatus();
+}
+
 //**************************************************************
 void XGUI_Workshop::showObjects(const QObjectPtrList& theList, bool isVisible)
 {
index 3f5d8f2c1f10fb7afe73e430aa7bca542bc4b590..c2b067741db3bb8162dd48b7565ab87046036251 100644 (file)
@@ -166,6 +166,15 @@ Q_OBJECT
   //! Delete features
   void deleteObjects(const QObjectPtrList& theList);
 
+  //! Returns true if there is at least one selected body/construction/group result
+  //! \return boolean value
+  bool canChangeColor() const;
+
+  //! Change color of the features if it is possible
+  //! The operation is available for construction, body and group results
+  //! theObjects a list of selected objects
+  void changeColor(const QObjectPtrList& theObjects);
+
   //! Show the given features in 3d Viewer
   void showObjects(const QObjectPtrList& theList, bool isVisible);