]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom.git into Dev_1.1.0
authorsbh <sergey.belash@opencascade.com>
Fri, 6 Mar 2015 18:45:48 +0000 (21:45 +0300)
committersbh <sergey.belash@opencascade.com>
Fri, 6 Mar 2015 18:45:48 +0000 (21:45 +0300)
47 files changed:
src/Config/Config_PropManager.cpp
src/Config/Config_PropManager.h
src/ExchangePlugin/ExchangePlugin_Plugin.cpp
src/Model/CMakeLists.txt
src/Model/Model_AttributeColor.cpp [new file with mode: 0644]
src/Model/Model_AttributeColor.h [new file with mode: 0644]
src/Model/Model_Data.cpp
src/Model/Model_Document.cpp
src/Model/Model_ResultBody.cpp
src/Model/Model_ResultBody.h
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI_AttributeColor.cpp [new file with mode: 0644]
src/ModelAPI/ModelAPI_AttributeColor.h [new file with mode: 0644]
src/ModelAPI/ModelAPI_Feature.h
src/ModelAPI/ModelAPI_Object.h
src/ModelAPI/ModelAPI_Result.h
src/ModuleBase/ModuleBase_ModelWidget.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Validators.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_Plugin.cpp
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/SketchPlugin_Validators.cpp
src/SketchPlugin/SketchPlugin_Validators.h
src/SketchPlugin/plugin-Sketch.xml
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.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 cf32016859c4088cd15224867e8eddfc2122478b..11034f4f6b11d0ac072b0cd98a068ab9d666c2d1 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, "false");
 }
 
 FeaturePtr ExchangePlugin_Plugin::createFeature(string theFeatureID)
index 4865602acdf89002d21df797244afb7402ac605c..20c1c0b29733f0b0bddafad48ffc1ed7d61f2f86 100644 (file)
@@ -14,6 +14,7 @@ SET(PROJECT_HEADERS
     Model_AttributeRefAttr.h
     Model_AttributeRefList.h
     Model_AttributeBoolean.h
+    Model_AttributeColor.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_AttributeColor.cpp
     Model_AttributeString.cpp
     Model_AttributeInteger.cpp
     Model_AttributeSelection.cpp
diff --git a/src/Model/Model_AttributeColor.cpp b/src/Model/Model_AttributeColor.cpp
new file mode 100644 (file)
index 0000000..920e35a
--- /dev/null
@@ -0,0 +1,57 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        Model_AttributeColor.cpp
+// Created:     6 Mar 2015
+// Author:      Natalia ERMOLAEVA
+
+#include <Model_AttributeColor.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>
+
+void Model_AttributeColor::setValues(const int theRed,
+                                     const int theGreen,
+                                     const int theBlue)
+{
+  if (!myIsInitialized || myRed->Get() != theRed ||
+      myGreen->Get() != theGreen || myBlue->Get() != theBlue) {
+    myRed->Set(theRed);
+    myGreen->Set(theGreen);
+    myBlue->Set(theBlue);
+
+    owner()->data()->sendAttributeUpdated(this);
+  }
+}
+
+void Model_AttributeColor::setValuesRandom()
+{
+  setValues(300, 150, 40);
+}
+
+void Model_AttributeColor::values(int& theRed, int& theGreen, int& theBlue)
+{
+  theRed = myRed->Get();
+  theGreen = myGreen->Get();
+  theBlue = myBlue->Get();
+}
+
+Model_AttributeColor::Model_AttributeColor(TDF_Label& theLabel)
+{
+  // check the attribute could be already presented in this doc (after load document)
+  myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), myRed) == Standard_True;
+  if (!myIsInitialized) {
+    // create attribute: not initialized by value yet, just zero
+    myRed = TDataStd_Integer::Set(theLabel, 0);
+    myGreen = TDataStd_Integer::Set(theLabel, 0);
+    myBlue = TDataStd_Integer::Set(theLabel, 0);
+  }
+}
diff --git a/src/Model/Model_AttributeColor.h b/src/Model/Model_AttributeColor.h
new file mode 100644 (file)
index 0000000..7c5922d
--- /dev/null
@@ -0,0 +1,50 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        Model_AttributeColor.h
+// Created:     6 Mar 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef MODEL_ATTRIBUTECOLOR_H_
+#define MODEL_ATTRIBUTECOLOR_H_
+
+#include <Model.h>
+#include <ModelAPI_AttributeColor.h>
+
+#include <TDF_Label.hxx>
+#include <TDataStd_Integer.hxx>
+
+#include <string>
+
+/**\class Model_AttributeColor
+ * \ingroup DataModel
+ * \brief Attribute that contains three integer values which define the color.
+ */
+
+class Model_AttributeColor : public ModelAPI_AttributeColor
+{
+  Handle_TDataStd_Integer myRed;
+  Handle_TDataStd_Integer myGreen;
+  Handle_TDataStd_Integer myBlue;
+ public:
+  /// Defines the color value
+  /// \param theRed the red part of the color
+  /// \param theRed the green part of the color
+  /// \param theRed the blue part of the color
+  MODELAPI_EXPORT virtual void setValues(const int theRed,
+                                         const int theGreen,
+                                         const int theBlue);
+
+  /// Fills the attribute values by a random color
+  MODELAPI_EXPORT virtual void setValuesRandom();
+
+  /// Returns the color value
+  MODELAPI_EXPORT virtual void values(int& theRed, int& theGreen, int& theBlue);
+
+ protected:
+  /// Initializes attibutes
+  Model_AttributeColor(TDF_Label& theLabel);
+
+  friend class Model_Data;
+};
+
+#endif
index e13eaa406e5b6199c198ebf86dfb074140c5130a..4d0ed5d23bceac061d541d288830bf553acce213 100644 (file)
@@ -15,6 +15,7 @@
 #include <Model_AttributeString.h>
 #include <Model_AttributeSelection.h>
 #include <Model_AttributeSelectionList.h>
+#include <Model_AttributeColor.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_AttributeColor::type()) {
+    anAttr = new Model_AttributeColor(anAttrLab);
   } 
   // create also GeomData attributes here because only here the OCAF strucure is known
   else if (theAttrType == GeomData_Point::type()) {
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..edee5b1495958450a9af23e078d881b36aafb4c3 100644 (file)
@@ -7,6 +7,7 @@
 #include <Model_ResultBody.h>
 #include <Model_Data.h>
 #include <Model_Document.h>
+#include <ModelAPI_AttributeColor.h>
 #include <TNaming_Builder.hxx>
 #include <TNaming_NamedShape.hxx>
 #include <TDataStd_Name.hxx>
 #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>
 //#define DEB_IMPORT 1
 
+#define RESULT_BODY_COLOR "#ff0000"
+
 Model_ResultBody::Model_ResultBody()
 {
   setIsConcealed(false);
 }
 
+void Model_ResultBody::initAttributes()
+{
+  // append the color attribute
+  DataPtr aData = data();
+  aData->addAttribute(COLOR_ID(), ModelAPI_AttributeColor::type());
+  // set the default value
+  bool anIsRandomColor = Config_PropManager::boolean("Visualization", "random_result_color",
+                                                     "false");
+  AttributeColorPtr aColorAttr = std::dynamic_pointer_cast<ModelAPI_AttributeColor>
+                                                             (aData->attribute(COLOR_ID()));
+  if (anIsRandomColor)
+    aColorAttr->setValuesRandom();
+  else {
+    std::vector<int> aRGB;
+    aRGB = Config_PropManager::color("Visualization", "result_body_color", RESULT_BODY_COLOR);
+    aColorAttr->setValues(aRGB[0], aRGB[1], 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..5b849c620b50b64b8fa1b3bad68c0eb68052d0a6 100644 (file)
@@ -29,6 +29,9 @@ class Model_ResultBody : public ModelAPI_ResultBody
   /// label; index in vector corresponds to the label tag
   std::vector<TNaming_Builder*> myBuilders;
 public:
+  /// 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 e8ef2bad290e75210907cb1e53a7561f1cdaad95..497fe5365b604573f73a95f6bc306ea7b45b2ac8 100644 (file)
@@ -9,6 +9,7 @@ SET(PROJECT_HEADERS
     ModelAPI.h
     ModelAPI_Attribute.h
     ModelAPI_AttributeBoolean.h
+    ModelAPI_AttributeColor.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_AttributeColor.cpp
     ModelAPI_AttributeDocRef.cpp
     ModelAPI_AttributeDouble.cpp
     ModelAPI_AttributeInteger.cpp
diff --git a/src/ModelAPI/ModelAPI_AttributeColor.cpp b/src/ModelAPI/ModelAPI_AttributeColor.cpp
new file mode 100644 (file)
index 0000000..1909fc3
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModelAPI_AttributeColor.cpp
+// Created:     6 Mar 2015
+// Author:      Natalia ERMOLAEVA
+
+#include <ModelAPI_AttributeColor.h>
+
+
+std::string ModelAPI_AttributeColor::attributeType()
+{
+  return type();
+}
+
+/// To virtually destroy the fields of successors
+ModelAPI_AttributeColor::~ModelAPI_AttributeColor()
+{
+}
+
+ModelAPI_AttributeColor::ModelAPI_AttributeColor()
+{
+}
diff --git a/src/ModelAPI/ModelAPI_AttributeColor.h b/src/ModelAPI/ModelAPI_AttributeColor.h
new file mode 100644 (file)
index 0000000..6d3986a
--- /dev/null
@@ -0,0 +1,59 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModelAPI_AttributeColor.h
+// Created:     6 Mar 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef ModelAPI_AttributeColor_H_
+#define ModelAPI_AttributeColor_H_
+
+#include <ModelAPI.h>
+#include <ModelAPI_Attribute.h>
+
+#include <string>
+
+
+/**\class ModelAPI_AttributeColor
+ * \ingroup DataModel
+ * \brief API for the attribute that contains color (int, int, int). The color is in the range [0, 255]
+ * There is an opportunity to fill the attribute by a random color
+ */
+
+class ModelAPI_AttributeColor : public ModelAPI_Attribute
+{
+ public:
+  /// Defines the color value
+  /// \param theRed the red part of the color
+  /// \param theRed the green part of the color
+  /// \param theRed the blue part of the color
+  MODELAPI_EXPORT virtual void setValues(const int theRed,
+                                         const int theGreen,
+                                         const int theBlue) = 0;
+
+  /// Fills the attribute values by a random color
+  MODELAPI_EXPORT virtual void setValuesRandom() = 0;
+
+  /// Returns the color value
+  MODELAPI_EXPORT virtual void values(int& theRed, int& theGreen, int& theBlue) = 0;
+
+  /// Returns the type of this class of attributes
+  MODELAPI_EXPORT static std::string type()
+  {
+    return "Color";
+  }
+
+  /// 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_AttributeColor();
+
+ protected:
+  /// Objects are created for features automatically
+  MODELAPI_EXPORT ModelAPI_AttributeColor();
+};
+
+//! Pointer on double attribute
+typedef std::shared_ptr<ModelAPI_AttributeColor> AttributeColorPtr;
+
+#endif
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 80b1773a327d8c6a93ce7531d01f63619f90619c..87112716e66df14208c74b1a0d4f988cf2f3409e 100644 (file)
@@ -60,6 +60,10 @@ Q_OBJECT
   /// \return the boolean result
   std::string getDefaultValue() const { return myDefaultValue; }
 
+  /// Returns true, if the obligatory value of the widget is not defined in the XML or has true value
+  /// \return the boolean result
+  bool isObligatory() const { return myIsObligatory; }
+
   /// Defines if it is supposed that the widget should interact with the viewer.
   virtual bool isViewerSelector() { return false; }
 
index da9bc82816c4cced2b822e6cfed6ed605d26e854..abc1378b5926ce1adb66a4a39f26ec53c01db59c 100644 (file)
@@ -431,10 +431,19 @@ void PartSet_Module::onVertexSelected()
   if (aOperation->id().toStdString() == SketchPlugin_Line::ID()) {
     /// If last line finished on vertex the lines creation sequence has to be break
     ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
+    ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
     const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
-    if (aWidgets.last() == aPanel->activeWidget()) {
-      myRestartingMode = RM_Forbided;
+    QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
+    bool aFoundWidget = false;
+    bool aFoundObligatory = false;
+    for (; anIt != aLast && !aFoundObligatory; anIt++) {
+      if (!aFoundWidget)
+        aFoundWidget = *anIt == anActiveWidget;
+      else
+        aFoundObligatory = (*anIt)->isObligatory();
     }
+    if (!aFoundObligatory)
+      myRestartingMode = RM_Forbided;
   }
 }
 
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 278c3e637906497337b4230cf972e978c90ed773..92100792ede4fba1b1c3a64555721c790578786b 100644 (file)
@@ -164,7 +164,22 @@ bool PartSet_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature,
                                                 const std::list<std::string>& theArguments,
                                                 const AttributePtr& theAttribute) const
 {
-  return PartSet_DifferentObjectsValidator::isValid(theAttribute, theArguments);
+  if (PartSet_DifferentObjectsValidator::isValid(theAttribute, theArguments)) {
+    std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs = 
+      theFeature->data()->attributes(ModelAPI_AttributeRefAttr::type());
+    std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
+    for(; anAttr != anAttrs.end(); anAttr++) {
+      if (*anAttr) {
+        std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = 
+          std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttr);
+        // check the object is already presented
+        if (!aRef->isObject() && aRef->attr() == theAttribute)
+          return false;
+      }
+    }
+    return true;
+  }
+  return false;
 }
 
 bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute, 
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 3b9c8dc2647db13f5a63a381a4564c8fca62e806..d4efeee6c8c472a835e077d5d809ca171bf5c333 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 aeaba71c8199b8553d928c49b616de542fe7f333..88f062b69fb069f6c5aa1d797bf413070123b8e1 100644 (file)
@@ -46,8 +46,8 @@ SketchPlugin_Plugin::SketchPlugin_Plugin()
   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
   aFactory->registerValidator("SketchPlugin_DistanceAttr",
                               new SketchPlugin_DistanceAttrValidator);  
-  aFactory->registerValidator("SketchPlugin_DifferentObjects",
-                              new SketchPlugin_DifferentObjectsValidator);
+  //aFactory->registerValidator("SketchPlugin_DifferentObjects",
+  //                            new SketchPlugin_DifferentObjectsValidator);
   aFactory->registerValidator("SketchPlugin_ResultPoint", new SketchPlugin_ResultPointValidator);
   aFactory->registerValidator("SketchPlugin_ResultLine", new SketchPlugin_ResultLineValidator);
   aFactory->registerValidator("SketchPlugin_ResultArc", new SketchPlugin_ResultArcValidator);
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 f243c86c77aa0da8ca83cdd4beb837b5b2afb54f..c19e27114b2bb001425f78ae9f8b383f6031c5aa 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;
       }
 
@@ -262,9 +263,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 29bdf3c27310df0ba7abadc7ca882ea353ef4f85..1fcac300d526f2fdaedf7b1e180de44e4baf9145 100644 (file)
@@ -57,64 +57,64 @@ bool SketchPlugin_DistanceAttrValidator::isValid(const FeaturePtr& theFeature,
   return isValid(theAttribute, theArguments);
 }
 
-bool SketchPlugin_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature,
-                                                 const std::list<std::string>& theArguments,
-                                                 const ObjectPtr& theObject) const
-{
-  std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs = 
-    theFeature->data()->attributes(ModelAPI_AttributeRefAttr::type());
-  std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
-  for(; anAttr != anAttrs.end(); anAttr++) {
-    if (*anAttr) {
-      std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = 
-        std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttr);
-      // check the object is already presented
-      if (aRef->isObject() && aRef->object() == theObject)
-        return false;
-    }
-  }
-  return true;
-}
+//bool SketchPlugin_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature,
+//                                                 const std::list<std::string>& theArguments,
+//                                                 const ObjectPtr& theObject) const
+//{
+//  std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs = 
+//    theFeature->data()->attributes(ModelAPI_AttributeRefAttr::type());
+//  std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
+//  for(; anAttr != anAttrs.end(); anAttr++) {
+//    if (*anAttr) {
+//      std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = 
+//        std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttr);
+//      // check the object is already presented
+//      if (aRef->isObject() && aRef->object() == theObject)
+//        return false;
+//    }
+//  }
+//  return true;
+//}
 
-bool SketchPlugin_DifferentObjectsValidator::isValid(
-  const AttributePtr& theAttribute, const std::list<std::string>& theArguments ) const
-{
-  std::shared_ptr<ModelAPI_AttributeRefAttr> anOrigAttr = 
-    std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
-  if (anOrigAttr && anOrigAttr->isObject()) {
-    const ObjectPtr& anObj = theAttribute->owner();
-    const FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObj);
+//bool SketchPlugin_DifferentObjectsValidator::isValid(
+//  const AttributePtr& theAttribute, const std::list<std::string>& theArguments ) const
+//{
+//  std::shared_ptr<ModelAPI_AttributeRefAttr> anOrigAttr = 
+//    std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+//  if (anOrigAttr && anOrigAttr->isObject()) {
+//    const ObjectPtr& anObj = theAttribute->owner();
+//    const FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObj);
+//
+//    std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs = 
+//      aFeature->data()->attributes(ModelAPI_AttributeRefAttr::type());
+//    std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
+//    for(; anAttr != anAttrs.end(); anAttr++) {
+//      if (*anAttr && *anAttr != theAttribute) {
+//        std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = 
+//          std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttr);
+//        // check the object is already presented
+//        if (aRef->isObject() && aRef->object() == anOrigAttr->object())
+//          return false;
+//      }
+//    }
+//  }
+//  return true;
+//}
 
-    std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs = 
-      aFeature->data()->attributes(ModelAPI_AttributeRefAttr::type());
-    std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
-    for(; anAttr != anAttrs.end(); anAttr++) {
-      if (*anAttr && *anAttr != theAttribute) {
-        std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = 
-          std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttr);
-        // check the object is already presented
-        if (aRef->isObject() && aRef->object() == anOrigAttr->object())
-          return false;
-      }
-    }
-  }
-  return true;
-}
-
-bool SketchPlugin_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature,
-  const std::list<std::string>& theArguments, const AttributePtr& theAttribute) const
-{
-  std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs = 
-    theFeature->data()->attributes(ModelAPI_AttributeRefAttr::type());
-  std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
-  for(; anAttr != anAttrs.end(); anAttr++) {
-    if (*anAttr) {
-      std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = 
-        std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttr);
-      // check the object is already presented
-      if (!aRef->isObject() && aRef->attr() == theAttribute)
-        return false;
-    }
-  }
-  return true;
-}
+//bool SketchPlugin_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature,
+//  const std::list<std::string>& theArguments, const AttributePtr& theAttribute) const
+//{
+//  std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs = 
+//    theFeature->data()->attributes(ModelAPI_AttributeRefAttr::type());
+//  std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
+//  for(; anAttr != anAttrs.end(); anAttr++) {
+//    if (*anAttr) {
+//      std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = 
+//        std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttr);
+//      // check the object is already presented
+//      if (!aRef->isObject() && aRef->attr() == theAttribute)
+//        return false;
+//    }
+//  }
+//  return true;
+//}
index d6368a1eb3e30ba13697582c7c57f30a34187993..61553fea865450b327c40cd3b312ce6bd17d065b 100644 (file)
@@ -39,20 +39,21 @@ class SketchPlugin_DistanceAttrValidator : public ModelAPI_RefAttrValidator
  * Check that there is no same object was already selected in the feature.
  * For an example: to avoid perpendicularity on line and the same line.
  */
-class SketchPlugin_DifferentObjectsValidator : public ModelAPI_RefAttrValidator
-{
- public:
-  //! returns true if attribute is valid
-  //! \param theAttribute the checked attribute
-  //! \param theArguments arguments of the attribute
-  virtual bool isValid(
-    const AttributePtr& theAttribute, const std::list<std::string>& theArguments) const;
-  //! Returns true if object is good for the feature attribute
-  virtual bool isValid(const FeaturePtr& theFeature, const std::list<std::string>& theArguments,
-                       const ObjectPtr& theObject) const;
-  //! Returns true if the attribute is good for the feature attribute
-  virtual bool isValid(const FeaturePtr& theFeature, const std::list<std::string>& theArguments,
-                       const AttributePtr& theAttribute) const;
-};
+// Use PartSet_DifferentObjectsValidator
+//class SketchPlugin_DifferentObjectsValidator : public ModelAPI_RefAttrValidator
+//{
+// public:
+//  //! returns true if attribute is valid
+//  //! \param theAttribute the checked attribute
+//  //! \param theArguments arguments of the attribute
+//  virtual bool isValid(
+//    const AttributePtr& theAttribute, const std::list<std::string>& theArguments) const;
+//  //! Returns true if object is good for the feature attribute
+//  virtual bool isValid(const FeaturePtr& theFeature, const std::list<std::string>& theArguments,
+//                       const ObjectPtr& theObject) const;
+//  //! Returns true if the attribute is good for the feature attribute
+//  virtual bool isValid(const FeaturePtr& theFeature, const std::list<std::string>& theArguments,
+//                       const AttributePtr& theAttribute) const;
+//};
 
 #endif
index ff6c30559b749debe6de24c602257285d68b6ac3..9eb94b38ff2f2fa300e0c0d0a16e4beedfc10f46 100644 (file)
@@ -60,7 +60,7 @@
           label="Last object" 
           tooltip="Select point, line end point, line, center of circle or arc." 
                 shape_types="edge vertex">
-          <validator id="SketchPlugin_DifferentObjects"/>
+          <validator id="PartSet_DifferentObjects"/>
           <validator id="SketchPlugin_DistanceAttr" parameters="ConstraintEntityA"/>
           <validator id="SketchPlugin_ShapeValidator" parameters="ConstraintEntityB"/>
           <selection_filter id="MultiFilter" parameters="line,vertex"/>
         <sketch_constraint_shape_selector id="ConstraintEntityB" label="Last line" tooltip="Select a line" 
             shape_types="edge">
             <selection_filter id="EdgeFilter" parameters="line"/>
-            <validator id="SketchPlugin_DifferentObjects"/>
+            <validator id="PartSet_DifferentObjects"/>
             <validator id="SketchPlugin_ShapeValidator" parameters="ConstraintEntityA"/>
         </sketch_constraint_shape_selector>
         
         <sketch_constraint_shape_selector id="ConstraintEntityB" 
             label="Last line" tooltip="Select an line" 
             shape_types="edge">
-            <validator id="SketchPlugin_DifferentObjects"/>
+            <validator id="PartSet_DifferentObjects"/>
           <validator id="SketchPlugin_ShapeValidator" parameters="ConstraintEntityA"/>
           <selection_filter id="EdgeFilter" parameters="line"/>
     </sketch_constraint_shape_selector>
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 6fc47e170982976ac55392ddddb624d2b90f9ced..88e8d599c3856ec43e16a4f2500976eecc6fd70e 100644 (file)
@@ -16,6 +16,7 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Tools.h>
+#include <ModelAPI_AttributeColor.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);
@@ -227,7 +223,7 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer)
     // before and after the values modification.
     // Moreother, this check avoids customize and redisplay presentation if the presentable
     // parameter is changed.
-    /*ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+    ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
     if (aResult.get() != NULL) {
       Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(aAISIO);
       if (!aShapePrs.IsNull()) {
@@ -241,14 +237,9 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer)
             return;
         }
       }
-    }*/
-    // 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);
     }
+    // Customization of presentation
+    customizeObject(theObject);
 
     aContext->Redisplay(aAISIO, false);
     if (isUpdateViewer)
@@ -766,3 +757,27 @@ 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) {
+    int aRed, aGreen, aBlue;
+
+    AttributeColorPtr aColorAttr = std::dynamic_pointer_cast<ModelAPI_AttributeColor>(
+                                              aResult->data()->attribute(ModelAPI_Result::COLOR_ID()));
+    aColorAttr->values(aRed, aGreen, aBlue);
+    anAISObj->setColor(aRed, aGreen, aBlue);
+  }
+  else {
+    // 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 b50412cc798ec06e62fd5e15a12fd5c3bd87b9ab..70b6c615654dee1e67bea0d7c5dc1f746c546d46 100644 (file)
@@ -36,6 +36,7 @@
 #include <ModelAPI_AttributeDocRef.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_ResultGroup.h>
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_ResultBody.h>
 
@@ -1239,6 +1240,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")
@@ -1372,6 +1375,98 @@ 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);
+}
+
+//**************************************************************
+#include <QDialog>
+#include <QHBoxLayout>
+#include <QtxColorButton.h>
+#include <ModelAPI_AttributeColor.h>
+void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects)
+{
+  // 1. find the initial value of the color
+  AttributeColorPtr aColorAttr;
+  foreach(ObjectPtr anObj, theObjects) {
+    ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
+    if (aResult.get() != NULL) {
+      AttributePtr anAttr = aResult->data()->attribute(ModelAPI_Result::COLOR_ID());
+      if (anAttr.get() != NULL)
+        aColorAttr = std::dynamic_pointer_cast<ModelAPI_AttributeColor>(anAttr);
+    }
+  }
+  // there is no object with the color attribute
+  if (aColorAttr.get() == NULL)
+    return;
+  int aRed, aGreen, aBlue;
+  aColorAttr->values(aRed, aGreen, aBlue);
+
+  // 2. show the dialog to change the value
+  QDialog aDlg;
+  QHBoxLayout* aLay = new QHBoxLayout(&aDlg);
+
+  QtxColorButton* aColorBtn = new QtxColorButton(&aDlg);
+  aLay->addWidget(aColorBtn);
+  aColorBtn->setColor(QColor(aRed, aGreen, aBlue));
+
+  QPoint aPoint = QCursor::pos();
+  aDlg.move(aPoint);
+
+  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
+  if(!isActiveOperationAborted())
+    return;
+
+  // 4. set the value to all results
+  foreach(ObjectPtr anObj, theObjects) {
+    ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
+    if (aResult.get() != NULL) {
+      AttributePtr anAttr = aResult->data()->attribute(ModelAPI_Result::COLOR_ID());
+      if (anAttr.get() != NULL) {
+        aColorAttr = std::dynamic_pointer_cast<ModelAPI_AttributeColor>(anAttr);
+        if (aColorAttr.get() != NULL)
+          aColorAttr->setValues(aRedResult, aGreenResult, aBlueResult);
+      }
+    }
+  }
+}
+
 //**************************************************************
 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);