Salome HOME
A new event Visual Attributes Changed is defined for performance sake.
authorvsv <vsv@opencascade.com>
Tue, 15 Oct 2019 12:33:31 +0000 (15:33 +0300)
committervsv <vsv@opencascade.com>
Tue, 15 Oct 2019 12:33:47 +0000 (15:33 +0300)
47 files changed:
src/Config/Config_Keywords.h
src/Model/Model_AttributeIntArray.cpp
src/Model/Model_AttributeIntArray.h
src/ModelAPI/ModelAPI_AttributeIntArray.h
src/ModelAPI/ModelAPI_Events.h
src/ModelAPI/ModelAPI_Tools.cpp
src/ModelAPI/ModelAPI_Tools.h
src/ModuleBase/ModuleBase_IModule.cpp
src/ModuleBase/ModuleBase_IModule.h
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_Tools.cpp
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/PartSet/PartSet_CustomPrs.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OverconstraintListener.cpp
src/PartSet/PartSet_OverconstraintListener.h
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Tools.h
src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistanceAlongDir.cpp
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp
src/SketchPlugin/SketchPlugin_Fillet.cpp
src/SketchPlugin/SketchPlugin_MacroArc.cpp
src/SketchPlugin/SketchPlugin_MacroCircle.cpp
src/SketchPlugin/SketchPlugin_MacroEllipse.cpp
src/SketchPlugin/SketchPlugin_MacroEllipticArc.cpp
src/SketchPlugin/SketchPlugin_Projection.cpp
src/SketchPlugin/SketchPlugin_Sketch.h
src/SketchPlugin/SketchPlugin_SketchEntity.h
src/SketchPlugin/SketchPlugin_Tools.cpp
src/SketchPlugin/SketchPlugin_Tools.h
src/SketchPlugin/plugin-Sketch.xml
src/XGUI/CMakeLists.txt
src/XGUI/XGUI_CustomPrs.cpp [deleted file]
src/XGUI/XGUI_CustomPrs.h [deleted file]
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_ObjectsBrowser.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_WorkshopListener.cpp
src/XGUI/XGUI_WorkshopListener.h

index 0a8f4aba4f06bbc7a154385ca958a818146a6951..32132a196ae9e6ceddf68367e570e4f8d8ca49e8 100644 (file)
@@ -104,6 +104,7 @@ const static char* ATTR_GREED = "greed";
 const static char* ATTR_MODIFIED_IN_EDIT = "modified_in_edit";
 const static char* ATTR_MAIN_ARG = "main_argument";
 const static char* ATTR_GEOMETRICAL_SELECTION = "geometrical_selection";
+const static char* ATTR_VISUAL_CHANGED = "change_visual_attributes";
 
 
 // WDG_INFO properties
index 3ee99ee6af12816746d0d9833473e54c1333b34b..b8da1694554e8dd85b36f4e86399e15f7eebef67 100644 (file)
@@ -68,11 +68,13 @@ void Model_AttributeIntArray::setSize(const int theSize)
 }
 
 void Model_AttributeIntArray::setValue(const int theIndex,
-                                       const int theValue)
+                                       const int theValue,
+                                       bool sendUpdated)
 {
   if (myArray->Value(theIndex) != theValue) {
     myArray->SetValue(theIndex, theValue);
-    owner()->data()->sendAttributeUpdated(this);
+    if (sendUpdated)
+      owner()->data()->sendAttributeUpdated(this);
   }
 }
 
index 1243a14ceb9a6fda73f7baa576cfc2be2ed4a5c6..1c7d10166bc49133baaedbdbb50fbd26d944c293 100644 (file)
@@ -51,7 +51,8 @@ class Model_AttributeIntArray : public ModelAPI_AttributeIntArray
 
   /// Defines the value of the array by index [0; size-1]
   MODEL_EXPORT virtual void setValue(const int theIndex,
-                                     const int theValue);
+                                     const int theValue,
+                                     bool sendUpdated = true);
 
   /// Returns the value by the index
   MODEL_EXPORT virtual int value(const int theIndex);
index d0fd38c50a84dfc32a45b10039d34d1e3b4984d3..b8b146ff2b5532b094ecb3c29287e89b833c9704 100644 (file)
@@ -44,7 +44,8 @@ class ModelAPI_AttributeIntArray : public ModelAPI_Attribute
 
   /// Defines the value of the array by index [0; size-1]
   MODELAPI_EXPORT virtual void setValue(const int theIndex,
-                                         const int theValue) = 0;
+                                        const int theValue,
+                                        bool sendUpdated = true) = 0;
 
   /// Returns the value by the index
   MODELAPI_EXPORT virtual int value(const int theIndex) = 0;
index f424d421437025642b8766c8f37e16085effc3c5..0b250ebd53e24493c8f0b4b93e42841d71b53aa4 100644 (file)
@@ -107,6 +107,9 @@ static const char * EVENT_GET_DOF_OBJECTS = "GetDoFObjects";
 /// Event ID that provides a request for list of non-fixed objects necessary for DoF = 0
 static const char * EVENT_DOF_OBJECTS = "DoFObjects";
 
+/// Event ID that requests updates visual attributes for presentations
+static const char * EVENT_VISUAL_ATTRIBUTES = "UpdateVisualAttributes";
+
 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
 class MODELAPI_EXPORT ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup
 {
index c6b8a6f7257df6ba4933747cb038402399502a87..728c009513157c5dc0a85f7d75be2e4d074a352a 100644 (file)
@@ -29,6 +29,7 @@
 #include <ModelAPI_ResultPart.h>
 #include <ModelAPI_AttributeDocRef.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_AttributeIntArray.h>
 #include <list>
 #include <map>
 #include <iostream>
@@ -784,4 +785,50 @@ void removeResults(const std::list<ResultPtr>& theResults)
   }
 }
 
+double getDeflection(const std::shared_ptr<ModelAPI_Result>& theResult)
+{
+  double aDeflection = -1;
+  // get deflection from the attribute of the result
+  if (theResult.get() != NULL &&
+    theResult->data()->attribute(ModelAPI_Result::DEFLECTION_ID()).get() != NULL) {
+    AttributeDoublePtr aDoubleAttr = theResult->data()->real(ModelAPI_Result::DEFLECTION_ID());
+    if (aDoubleAttr.get() && aDoubleAttr->isInitialized()) {
+      double aValue = aDoubleAttr->value();
+      if (aValue > 0) /// zero value should not be used as a deflection(previous studies)
+        aDeflection = aDoubleAttr->value();
+    }
+  }
+  return aDeflection;
+}
+
+
+void getColor(const std::shared_ptr<ModelAPI_Result>& theResult, std::vector<int>& theColor)
+{
+  theColor.clear();
+  // get color from the attribute of the result
+  if (theResult.get() != NULL &&
+    theResult->data()->attribute(ModelAPI_Result::COLOR_ID()).get() != NULL) {
+    AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID());
+    if (aColorAttr.get() && aColorAttr->size()) {
+      theColor.push_back(aColorAttr->value(0));
+      theColor.push_back(aColorAttr->value(1));
+      theColor.push_back(aColorAttr->value(2));
+    }
+  }
+}
+
+double getTransparency(const std::shared_ptr<ModelAPI_Result>& theResult)
+{
+  double aTransparency = -1;
+  // get transparency from the attribute of the result
+  if (theResult.get() != NULL &&
+    theResult->data()->attribute(ModelAPI_Result::TRANSPARENCY_ID()).get() != NULL) {
+    AttributeDoublePtr aDoubleAttr = theResult->data()->real(ModelAPI_Result::TRANSPARENCY_ID());
+    if (aDoubleAttr.get() && aDoubleAttr->isInitialized()) {
+      aTransparency = aDoubleAttr->value();
+    }
+  }
+  return aTransparency;
+}
+
 } // namespace ModelAPI_Tools
index 6b4d31f8401cdd34a2c1e8403833400ab37e7f09..83fbdb888b0b3cf2d2accda2296a09603b1172cb 100644 (file)
@@ -209,6 +209,26 @@ MODELAPI_EXPORT std::set<std::shared_ptr<ModelAPI_Feature> >
 /*! Creates a remove result features with the given results
 */
 MODELAPI_EXPORT void removeResults(const std::list<std::shared_ptr<ModelAPI_Result> >& theResults);
+
+/*! Returns current deflection in the given result
+* \param theResult a result object
+* \return a deflection value or -1 if it was not defined
+*/
+MODELAPI_EXPORT double getDeflection(const std::shared_ptr<ModelAPI_Result>& theResult);
+
+/*! Returns current color of the current result
+* \param[in] theResult a result object
+* \param[out] theColor a color values if it is defined
+*/
+MODELAPI_EXPORT void getColor(const std::shared_ptr<ModelAPI_Result>& theResult,
+  std::vector<int>& theColor);
+
+/*! Returns current transparency in the given result
+* \param theResult a result object
+* \return a transparency value or -1 if it was not defined
+*/
+MODELAPI_EXPORT double getTransparency(const std::shared_ptr<ModelAPI_Result>& theResult);
+
 }
 
 #endif
index 03abb8233950ce89c26d887b94dd8c5206dc5b36..f3314ca2a27a1c186a11c2d01a1f636ce6a3da29 100644 (file)
@@ -159,9 +159,9 @@ void ModuleBase_IModule::launchOperation(const QString& theCmdId,
   }
 }
 
-Handle(AIS_InteractiveObject) ModuleBase_IModule::createPresentation(const ObjectPtr& theResult)
+AISObjectPtr ModuleBase_IModule::createPresentation(const ObjectPtr& theResult)
 {
-  return Handle(AIS_InteractiveObject)();
+  return AISObjectPtr();
 }
 
 bool ModuleBase_IModule::canBeShaded(Handle(AIS_InteractiveObject) theAIS) const
@@ -186,13 +186,6 @@ ModuleBase_Operation* ModuleBase_IModule::getNewOperation(const std::string& the
   return new ModuleBase_OperationFeature(theFeatureId.c_str(), this);
 }
 
-bool ModuleBase_IModule::customizeObject(ObjectPtr theObject,
-                              const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
-                              const bool theUpdateViewer)
-{
-  return false;
-}
-
 ModuleBase_Operation* ModuleBase_IModule::createOperation(const std::string& theFeatureId)
 {
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
index b748d6a148c2721b89fd659551cc38cf50f11c82..d2ce9c4a9832a52b2b5c877268f49690a4b2ef24 100644 (file)
@@ -277,14 +277,14 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
                                    const bool theUpdateViewer) {}
 
   /// Modifies the given presentation in the custom way.
-  virtual bool customisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
-                                     AISObjectPtr thePrs,
-                                     GeomCustomPrsPtr theCustomPrs) { return false; };
+  //virtual bool customisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
+  //                                   AISObjectPtr thePrs,
+  //                                   GeomCustomPrsPtr theCustomPrs) { return false; };
 
-  /// Modifies the given presentation in the custom way after usual customize is performed.
-  virtual bool afterCustomisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
-                                     AISObjectPtr thePrs,
-                                     GeomCustomPrsPtr theCustomPrs) { return false; };
+  ///// Modifies the given presentation in the custom way after usual customize is performed.
+  //virtual bool afterCustomisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
+  //                                   AISObjectPtr thePrs,
+  //                                   GeomCustomPrsPtr theCustomPrs) { return false; };
 
   /// 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,
@@ -294,8 +294,10 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
   /// should be updated(e.g. only highlighted elements)
   /// \param theUpdateViewer the parameter whether the viewer should be update immediately
   /// \returns true if the object is modified
-  virtual bool customizeObject(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag,
-                               const bool theUpdateViewer);
+  virtual bool customizeFeature(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag,
+    const bool theUpdateViewer) {
+    return false;
+  }
 
   /// Disable displaying of custom mode
   /// \param theMode a mode to disable
@@ -312,10 +314,16 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
   /// \param theCmdId the operation name
   virtual ModuleBase_Operation* createOperation(const std::string& theCmdId);
 
-  /// Create specific for the module presentation
+  /// Create specific for the module presentation. The presentation has to be
+  /// customized accordingly to the object.
   /// \param theResult an object for presentation
   /// \return created presentation or NULL(default value)
-  virtual Handle(AIS_InteractiveObject) createPresentation(const ObjectPtr& theResult);
+  virtual AISObjectPtr createPresentation(const ObjectPtr& theResult);
+
+  /// Customize presentation according to objects attributes
+  /// \param theObject an object for presentation
+  /// \param thePrs a presentation object
+  virtual void customizePresentation(const ObjectPtr& theObject, const AISObjectPtr& thePrs) const {}
 
   //! Returns data object by AIS
   virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const = 0;
index 89546edfd4bacde2ac2f40b91a4258dbcef1a299..a563c277981ff7cf1ca87f8a0174cd535209eac2 100644 (file)
 
 //**************************************************************
 ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent,
-                                               const Config_WidgetAPI* theData)
-    : QWidget(theParent),
-      myIsEditing(false),
-      myState(Stored),
-      myIsValueStateBlocked(false),
-      myFlushUpdateBlocked(false),
-      myWidgetValidator(0)
+  const Config_WidgetAPI* theData)
+  : QWidget(theParent),
+  myIsEditing(false),
+  myState(Stored),
+  myIsValueStateBlocked(false),
+  myFlushUpdateBlocked(false),
+  myWidgetValidator(0)
 {
 #ifdef DEBUG_WIDGET_INSTANCE
   qDebug("ModuleBase_ModelWidget::ModuleBase_ModelWidget");
@@ -68,6 +68,8 @@ ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent,
 
   myIsModifiedInEdit = theData->getProperty(ATTR_MODIFIED_IN_EDIT);
 
+  myUpdateVisualAttributes = theData->getBooleanAttribute(ATTR_VISUAL_CHANGED, false);
+
   myDefaultValue = theData->getProperty(ATTR_DEFAULT);
   myUseReset = theData->getBooleanAttribute(ATTR_USE_RESET, true);
   myIsComputedDefault = theData->getProperty(ATTR_DEFAULT) == DOUBLE_WDG_DEFAULT_COMPUTED;
@@ -437,6 +439,10 @@ void ModuleBase_ModelWidget::updateObject(ObjectPtr theObject)
 #ifdef DEBUG_WIDGET_INSTANCE
     qDebug("ModuleBase_ModelWidget::updateObject");
 #endif
+    if (myFeature.get() && myUpdateVisualAttributes) {
+      static const Events_ID anEvent = Events_Loop::eventByName(EVENT_VISUAL_ATTRIBUTES);
+      ModelAPI_EventCreator::get()->sendUpdated(myFeature, anEvent);
+    }
     ModuleBase_Tools::flushUpdated(theObject);
     emit objectUpdated();
   }
index fdd467481bf79cf5439a99b6b28834b411f507f2..4fb4ad55249d3381aa2c59a7acce5d79f9e6c9e3 100644 (file)
@@ -445,6 +445,8 @@ private:
   bool myIsValueStateBlocked;
   /// do not flush updated signal
   bool myFlushUpdateBlocked;
+
+  bool myUpdateVisualAttributes;
 };
 
 #endif
index 2d6e806705cf5f35ceb4808ecab2c8dfc2fa6528..b8f595cb36a8f0b72563e75493b6ed89201436c6 100644 (file)
@@ -760,6 +760,7 @@ void flushUpdated(ObjectPtr theObject)
   // (for the sketch result) to start processing of the sketch in the solver.
   // TODO: these flushes should be moved in a separate method provided by Model
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_VISUAL_ATTRIBUTES));
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
 
index 43b380cf7a7fb69f41702d7c66cf187d61abc48c..bb68bed954b7c4443d72cbd58a709a5c5c9ec2a6 100644 (file)
@@ -409,7 +409,7 @@ bool ModuleBase_WidgetMultiSelector::setSelection(QList<ModuleBase_ViewerPrsPtr>
     theValues.append(anInvalidValues);
 
   if (isDone) // may be the feature's result is not displayed, but attributes should be
-    myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeArguments,
+    myWorkshop->module()->customizeFeature(myFeature, ModuleBase_IModule::CustomizeArguments,
                              true);/// hope that something is redisplayed by object updated
 
   return isDone;
@@ -553,7 +553,7 @@ bool ModuleBase_WidgetMultiSelector::processDelete()
     myWorkshop->setSelected(getAttributeSelection());
 
     // may be the feature's result is not displayed, but attributes should be
-    myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeArguments,
+    myWorkshop->module()->customizeFeature(myFeature, ModuleBase_IModule::CustomizeArguments,
                               true); /// hope that something is redisplayed by object updated
   }
 
@@ -616,7 +616,7 @@ void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()
   restoreValue();
   myWorkshop->setSelected(getAttributeSelection());
   // may be the feature's result is not displayed, but attributes should be
-  myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeArguments,
+  myWorkshop->module()->customizeFeature(myFeature, ModuleBase_IModule::CustomizeArguments,
                             true); /// hope that something is redisplayed by object updated
   // clear history should follow after set selected to do not increase history by setSelected
   clearSelectedHistory();
@@ -853,8 +853,8 @@ void ModuleBase_WidgetMultiSelector::onDeleteItem()
 //********************************************************************
 void ModuleBase_WidgetMultiSelector::onListSelection()
 {
-  myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeHighlightedObjects,
-                                        true);
+  myWorkshop->module()->customizeFeature(myFeature, ModuleBase_IModule::CustomizeHighlightedObjects,
+                                         true);
 }
 
 //********************************************************************
index 21465eb1cb133887e2a96caf458beb7fe9b87fd6..e18ca5bb063b58a5716997908d3c8b078328ac4d 100644 (file)
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-#include <PartSet_CustomPrs.h>
-#include <PartSet_Module.h>
+#include "PartSet_CustomPrs.h"
+#include "PartSet_Module.h"
 #include "PartSet_OperationPrs.h"
 #include "PartSet_OverconstraintListener.h"
+#include "PartSet_SketcherMgr.h"
 
 #include <XGUI_ModuleConnector.h>
 #include <XGUI_Workshop.h>
@@ -30,6 +31,9 @@
 #include <ModuleBase_IViewer.h>
 #include <ModuleBase_Tools.h>
 
+#include <ModelAPI_Tools.h>
+#include <SketchPlugin_Sketch.h>
+
 #include <Config_PropManager.h>
 #include <Events_Loop.h>
 #include <ModelAPI_Events.h>
@@ -68,12 +72,22 @@ bool PartSet_CustomPrs::activate(const FeaturePtr& theFeature,
 #ifdef DO_NOT_VISUALIZE_CUSTOM_PRESENTATION
   return false;
 #endif
+  bool isModified = false;
 
-  myIsActive[theFlag] = true;
-  myFeature = theFeature;
+  // Do not call customisation for sketcher and all its sub-objects
+  if (theFeature->getKind() == SketchPlugin_Sketch::ID())
+    return isModified;
+
+  FeaturePtr aParent = ModelAPI_Tools::compositeOwner(theFeature);
+  if (aParent.get()) {
+    std::string aType = aParent->getKind();
+    if (aType == SketchPlugin_Sketch::ID())
+      return isModified;
+  }
 
-  bool isModified = false;
   if (theFeature.get()) {
+    myIsActive[theFlag] = true;
+    myFeature = theFeature;
     displayPresentation(theFlag, theUpdateViewer);
     isModified = true;
   }
index 0ad3ce8f22bf20accb23f184853d37930ddd21ac..5245438e5abd441500d7ef6e4fb546ae597551a8 100644 (file)
@@ -67,8 +67,9 @@
 #include <ModuleBase_WidgetFactory.h>
 #include <ModuleBase_OperationDescription.h>
 #include <ModuleBase_ViewerPrs.h>
-#include <ModelAPI_ResultField.h>
+#include <ModuleBase_ResultPrs.h>
 
+#include <ModelAPI_ResultField.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Validator.h>
@@ -80,6 +81,7 @@
 #include <ModelAPI_Tools.h>
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_AttributeIntArray.h>
+#include <ModelAPI_ResultGroup.h>
 
 #include <GeomDataAPI_Point2D.h>
 #include <GeomDataAPI_Point.h>
@@ -89,7 +91,6 @@
 #include <XGUI_ActiveControlSelector.h>
 #include <XGUI_ActionsMgr.h>
 #include <XGUI_ContextMenuMgr.h>
-#include <XGUI_CustomPrs.h>
 #include <XGUI_DataModel.h>
 #include <XGUI_Displayer.h>
 #include <XGUI_ErrorMgr.h>
@@ -191,6 +192,26 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
 
   setDefaultConstraintShown();
 
+  //Config_PropManager::registerProp("Visualization", "object_default_color", "Object color",
+  //                                 Config_Prop::Color, "225,225,225");
+
+  Config_PropManager::registerProp("Visualization", "result_body_color", "Result color",
+    Config_Prop::Color, ModelAPI_ResultBody::DEFAULT_COLOR());
+
+  Config_PropManager::registerProp("Visualization", "result_group_color", "Group color",
+    Config_Prop::Color, ModelAPI_ResultGroup::DEFAULT_COLOR());
+
+  Config_PropManager::registerProp("Visualization", "result_construction_color",
+    "Construction color",
+    Config_Prop::Color,
+    ModelAPI_ResultConstruction::DEFAULT_COLOR());
+
+  Config_PropManager::registerProp("Visualization", "result_part_color", "Part color",
+    Config_Prop::Color, ModelAPI_ResultPart::DEFAULT_COLOR());
+
+  Config_PropManager::registerProp("Visualization", "result_field_color", "Field color",
+    Config_Prop::Color, ModelAPI_ResultField::DEFAULT_COLOR());
+
   Config_PropManager::registerProp("Visualization", "operation_parameter_color",
                           "Reference shape wireframe color in operation", Config_Prop::Color,
                           PartSet_CustomPrs::OPERATION_PARAMETER_COLOR());
@@ -1166,75 +1187,75 @@ void PartSet_Module::deactivateCustomPrs(const ModuleBase_CustomizeFlag& theFlag
 }
 
 //******************************************************
-bool PartSet_Module::customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
-                                           std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs)
-{
-  bool aCustomized = false;
-
-  XGUI_Workshop* aWorkshop = getWorkshop();
-  XGUI_Displayer* aDisplayer = aWorkshop->displayer();
-  ObjectPtr anObject = aDisplayer->getObject(thePrs);
-  if (!anObject)
-    return aCustomized;
-
-  if (!theResult.get()) {
-    std::vector<int> aColor;
-    XGUI_CustomPrs::getDefaultColor(anObject, true, aColor);
-    if (!aColor.empty()) {
-      aCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
-    }
-  }
-  // customize dimentional constrains
-  sketchMgr()->customizePresentation(anObject);
-
-  return aCustomized;
-}
-
-//******************************************************
-bool PartSet_Module::afterCustomisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
-                                                AISObjectPtr thePrs,
-                                                GeomCustomPrsPtr theCustomPrs)
-{
-  bool aCustomized = false;
-
-  XGUI_Workshop* aWorkshop = getWorkshop();
-  XGUI_Displayer* aDisplayer = aWorkshop->displayer();
-  ObjectPtr anObject = aDisplayer->getObject(thePrs);
-  if (!anObject)
-    return aCustomized;
-
-  std::vector<int> aColor;
-  bool aUseCustomColor = true;
-  if (aUseCustomColor)
-    myOverconstraintListener->getCustomColor(anObject, aColor);
-  // customize sketch symbol presentation
-  Handle(AIS_InteractiveObject) anAISIO = thePrs->impl<Handle(AIS_InteractiveObject)>();
-  if (!anAISIO.IsNull()) {
-    if (!Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO).IsNull()) {
-      Handle(SketcherPrs_SymbolPrs) aPrs = Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO);
-      if (!aPrs.IsNull()) {
-        aPrs->SetCustomColor(aColor);
-        aCustomized = true;
-      }
-    } else if (!Handle(SketcherPrs_Coincident)::DownCast(anAISIO).IsNull()) {
-      Handle(SketcherPrs_Coincident) aPrs = Handle(SketcherPrs_Coincident)::DownCast(anAISIO);
-      if (!aPrs.IsNull()) {
-        aPrs->SetCustomColor(aColor);
-        aCustomized = true;
-      }
-    }
-  }
-  // customize sketch dimension constraint presentation
-  if (!aCustomized) {
-    if (!aColor.empty()) { // otherwise presentation has the default color
-      aCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
-    }
-  }
-  return aCustomized;
-}
-
-//******************************************************
-bool PartSet_Module::customizeObject(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag,
+//bool PartSet_Module::customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
+//                                           std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs)
+//{
+//  bool aCustomized = false;
+//
+//  XGUI_Workshop* aWorkshop = getWorkshop();
+//  XGUI_Displayer* aDisplayer = aWorkshop->displayer();
+//  ObjectPtr anObject = aDisplayer->getObject(thePrs);
+//  if (!anObject)
+//    return aCustomized;
+//
+//  if (!theResult.get()) {
+//    std::vector<int> aColor;
+//    XGUI_CustomPrs::getDefaultColor(anObject, true, aColor);
+//    if (!aColor.empty()) {
+//      aCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+//    }
+//  }
+//  // customize dimentional constrains
+//  sketchMgr()->customisePresentation(anObject);
+//
+//  return aCustomized;
+//}
+//
+////******************************************************
+//bool PartSet_Module::afterCustomisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
+//                                                AISObjectPtr thePrs,
+//                                                GeomCustomPrsPtr theCustomPrs)
+//{
+//  bool aCustomized = false;
+//
+//  XGUI_Workshop* aWorkshop = getWorkshop();
+//  XGUI_Displayer* aDisplayer = aWorkshop->displayer();
+//  ObjectPtr anObject = aDisplayer->getObject(thePrs);
+//  if (!anObject)
+//    return aCustomized;
+//
+//  std::vector<int> aColor;
+//  bool aUseCustomColor = true;
+//  if (aUseCustomColor)
+//    myOverconstraintListener->getCustomColor(anObject, aColor);
+//  // customize sketch symbol presentation
+//  Handle(AIS_InteractiveObject) anAISIO = thePrs->impl<Handle(AIS_InteractiveObject)>();
+//  if (!anAISIO.IsNull()) {
+//    if (!Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO).IsNull()) {
+//      Handle(SketcherPrs_SymbolPrs) aPrs = Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO);
+//      if (!aPrs.IsNull()) {
+//        aPrs->SetCustomColor(aColor);
+//        aCustomized = true;
+//      }
+//    } else if (!Handle(SketcherPrs_Coincident)::DownCast(anAISIO).IsNull()) {
+//      Handle(SketcherPrs_Coincident) aPrs = Handle(SketcherPrs_Coincident)::DownCast(anAISIO);
+//      if (!aPrs.IsNull()) {
+//        aPrs->SetCustomColor(aColor);
+//        aCustomized = true;
+//      }
+//    }
+//  }
+//  // customize sketch dimension constraint presentation
+//  if (!aCustomized) {
+//    if (!aColor.empty()) { // otherwise presentation has the default color
+//      aCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+//    }
+//  }
+//  return aCustomized;
+//}
+
+//******************************************************
+bool PartSet_Module::customizeFeature(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag,
                                      const bool theUpdateViewer)
 {
   bool isRedisplayed = false;
@@ -1279,21 +1300,100 @@ void PartSet_Module::onActiveDocPopup(const QPoint& thePnt)
 }
 
 //******************************************************
-Handle(AIS_InteractiveObject) PartSet_Module::createPresentation(const ObjectPtr& theObject)
+AISObjectPtr PartSet_Module::createPresentation(const ObjectPtr& theObject)
+{
+  Handle(AIS_InteractiveObject) anAISPrs = mySketchMgr->createPresentation(theObject);
+  if (anAISPrs.IsNull()) {
+    ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+    if (aResult.get()) {
+      std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
+      if (aShapePtr.get() != NULL)
+        anAISPrs = new ModuleBase_ResultPrs(aResult);
+    }
+    else {
+      FieldStepPtr aStep =
+        std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(theObject);
+      if (aStep.get()) {
+        anAISPrs = new PartSet_FieldStepPrs(aStep);
+      }
+    }
+  }
+  AISObjectPtr anAIS;
+  if (!anAISPrs.IsNull()) {
+    Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(anAISPrs);
+    if (!aShapePrs.IsNull())
+      ModuleBase_Tools::setPointBallHighlighting((AIS_Shape*)aShapePrs.get());
+
+    anAIS = AISObjectPtr(new GeomAPI_AISObject());
+    anAIS->setImpl(new Handle(AIS_InteractiveObject)(anAISPrs));
+    customizePresentation(theObject, anAIS);
+  }
+  return anAIS;
+}
+
+//******************************************************
+void getResultColor(const ResultPtr& theResult, std::vector<int>& theColor)
 {
-  ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
-  if (aResult.get())
-    return mySketchMgr->createPresentation(aResult);
+  ModelAPI_Tools::getColor(theResult, theColor);
+  if (theColor.empty())
+    PartSet_Tools::getDefaultColor(theResult, false, theColor);
+}
+
+//******************************************************
+double getResultDeflection(const ResultPtr& theResult)
+{
+  double aDeflection = ModelAPI_Tools::getDeflection(theResult);
+  if (aDeflection < 0)
+    aDeflection = PartSet_Tools::getDefaultDeflection(theResult);
+  return aDeflection;
+}
+
+//******************************************************
+double getResultTransparency(const ResultPtr& theResult)
+{
+  double aTransparency = ModelAPI_Tools::getTransparency(theResult);
+  if (aTransparency < 0)
+    aTransparency = PartSet_Tools::getDefaultTransparency();
+  return aTransparency;
+}
+
+
+//******************************************************
+void PartSet_Module::customizePresentation(const ObjectPtr& theObject, const AISObjectPtr& thePrs) const
+{
+  if (mySketchMgr->isSketchStarted()) {
+    mySketchMgr->customizeSketchPresentation(theObject, thePrs);
+  }
   else {
-    FieldStepPtr aStep =
-      std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(theObject);
-    if (aStep.get()) {
-      return new PartSet_FieldStepPrs(aStep);
+    ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+    if (aResult.get()) {
+      std::vector<int> aColor;
+      getResultColor(aResult, aColor);
+
+      SessionPtr aMgr = ModelAPI_Session::get();
+      if (aMgr->activeDocument() != aResult->document()) {
+        QColor aQColor(aColor[0], aColor[1], aColor[2]);
+        QColor aNewColor =
+          QColor::fromHsvF(aQColor.hueF(), aQColor.saturationF() / 3., aQColor.valueF());
+        aColor[0] = aNewColor.red();
+        aColor[1] = aNewColor.green();
+        aColor[2] = aNewColor.blue();
+      }
+      thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+
+      thePrs->setDeflection(getResultDeflection(aResult));
+
+      thePrs->setTransparency(getResultTransparency(aResult));
+    }
+    FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+    if (aFeature.get()) {
+      if (aFeature->getKind() == SketchPlugin_Sketch::ID())
+        thePrs->setWidth(2);
     }
   }
-  return Handle(AIS_InteractiveObject)();
 }
 
+
 //******************************************************
 ObjectPtr PartSet_Module::findPresentedObject(const AISObjectPtr& theAIS) const
 {
index bcd16ee1771476c5a5cfd3854f611d087bcfb479..5a6d25cc7276bcbddd215b37ade99819309574f9 100644 (file)
@@ -290,14 +290,14 @@ public:
                                    const bool theUpdateViewer);
 
   /// Modifies the given presentation in the custom way.
-  virtual bool customisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
-                                     AISObjectPtr thePrs,
-                                     std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs);
+  //virtual bool customisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
+  //                                   AISObjectPtr thePrs,
+  //                                   std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs);
 
-  /// Modifies the given presentation in the custom way after usual customize is performed.
-  virtual bool afterCustomisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
-                                          AISObjectPtr thePrs,
-                                          GeomCustomPrsPtr theCustomPrs);
+  ///// Modifies the given presentation in the custom way after usual customize is performed.
+  //virtual bool afterCustomisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
+  //                                        AISObjectPtr thePrs,
+  //                                        GeomCustomPrsPtr theCustomPrs);
 
   /// 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,
@@ -307,8 +307,8 @@ public:
   /// should be updated(e.g. only highlighted elements)
   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
   /// \returns true if the object is modified
-  virtual bool customizeObject(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag,
-                               const bool theUpdateViewer);
+  virtual bool customizeFeature(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag,
+                                const bool theUpdateViewer);
 
   /// Disable displaying of custom mode
   /// \param theMode a mode to disable
@@ -327,7 +327,12 @@ public:
   /// Create specific for the module presentation
   /// \param theResult an object for presentation
   /// \return created presentation or NULL(default value)
-  virtual Handle(AIS_InteractiveObject) createPresentation(const ObjectPtr& theResult);
+  virtual AISObjectPtr createPresentation(const ObjectPtr& theResult);
+
+  /// Customize presentation according to objects attributes
+  /// \param theObject an object for presentation
+  /// \param thePrs a presentation object
+  virtual void customizePresentation(const ObjectPtr& theObject, const AISObjectPtr& thePrs) const;
 
   //! Returns data object by AIS
   virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const;
index 59fbfa96edecbb2bb0b055177e1fca6800e81ecd..70c19725c8ff56b0221dc9c9e7d358bd78f668c3 100644 (file)
@@ -25,7 +25,6 @@
 #include <PartSet_SketcherMgr.h>
 #include <PartSet_SketcherReentrantMgr.h>
 
-#include "XGUI_CustomPrs.h"
 #include "XGUI_Displayer.h"
 #include "XGUI_ModuleConnector.h"
 #include "XGUI_OperationMgr.h"
@@ -284,7 +283,7 @@ void PartSet_OverconstraintListener::redisplayObjects(
 {
   static Events_Loop* aLoop = Events_Loop::loop();
 
-  static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+  static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_VISUAL_ATTRIBUTES);
   static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
 
   std::set<ObjectPtr>::const_iterator anIt = theObjects.begin(), aLast = theObjects.end();
index 5481f9d947d9e866a2454fce010d6136fb1ee8c6..a02dee98e5036150619507b34b019c66a607e661 100644 (file)
@@ -58,6 +58,14 @@ public:
   /// Redefinition of Events_Listener method
   virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
 
+
+  bool isConflictingObject(const ObjectPtr& theObject) const
+  {
+    return (myConflictingObjects.find(theObject) != myConflictingObjects.end());
+  }
+
+  bool isFullyConstrained() const { return myIsFullyConstrained; }
+
 protected:
   /// Append objects to the internal container of conflicting object, redisplay necessary objects
   /// \param theObjects a list of new conflicting objects
index aa639e247c9195493ef4968db6d95f3c5c5896ac..ea764c531ac7b6f9b05d57fc1b9210910b43aaa7 100644 (file)
@@ -172,7 +172,8 @@ PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule)
   : QObject(theModule), myModule(theModule), myIsEditLaunching(false), myIsDragging(false),
     myDragDone(false), myIsMouseOverWindow(false),
     myIsMouseOverViewProcessed(true), myPreviousUpdateViewerEnabled(true),
-    myIsPopupMenuActive(false), myExternalPointsMgr(0), myNoDragMoving(false)
+    myIsPopupMenuActive(false), myExternalPointsMgr(0), myNoDragMoving(false),
+    myIsSketchStarted(false)
 {
   ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
   ModuleBase_IViewer* aViewer = anIWorkshop->viewer();
@@ -470,8 +471,9 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
 void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
 {
   ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+  ModuleBase_IViewer* aViewer = aWorkshop->viewer();
   if (myIsDragging)
-    aWorkshop->viewer()->enableDrawMode(myPreviousDrawModeEnabled);
+    aViewer->enableDrawMode(myPreviousDrawModeEnabled);
 
   bool aWasDragging = myIsDragging;
   myIsDragging = false;
@@ -483,11 +485,10 @@ void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouse
   if (!myIsMouseOverViewProcessed) {
     return;
   }
-  ModuleBase_IViewer* aViewer = aWorkshop->viewer();
   //if (!aViewer->canDragByMouse())
   //  return;
   ModuleBase_OperationFeature* aOp =
-      dynamic_cast<ModuleBase_OperationFeature*>(getCurrentOperation());
+    dynamic_cast<ModuleBase_OperationFeature*>(getCurrentOperation());
   if (aOp) {
     bool aStartNoDragOperation = !aViewer->canDragByMouse() && aOp->isEditOperation();
     if (aStartNoDragOperation || myNoDragMoving) {
@@ -887,13 +888,15 @@ void PartSet_SketcherMgr::sketchSelectionModes(const CompositeFeaturePtr& theSke
   theModes.append(TopAbs_EDGE);
 }
 
-Handle(AIS_InteractiveObject) PartSet_SketcherMgr::createPresentation(const ResultPtr& theResult)
+Handle(AIS_InteractiveObject) PartSet_SketcherMgr::createPresentation(const ObjectPtr& theObj)
 {
   Handle(AIS_InteractiveObject) aPrs;
 
-  FeaturePtr aFeature = ModelAPI_Feature::feature(theResult);
+  FeaturePtr aFeature = ModelAPI_Feature::feature(theObj);
   if (aFeature.get() && aFeature->getKind() == SketchPlugin_Sketch::ID()) {
-    aPrs = new PartSet_ResultSketchPrs(theResult);
+    ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObj);
+    if (aResult.get())
+      aPrs = new PartSet_ResultSketchPrs(aResult);
   }
   return aPrs;
 }
@@ -995,11 +998,15 @@ bool PartSet_SketcherMgr::isDistanceKind(std::string& theKind)
 
 void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
 {
+  static Events_ID EVENT_ATTR = Events_Loop::loop()->eventByName(EVENT_VISUAL_ATTRIBUTES);
+  static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
                                                                (getCurrentOperation());
   if (!aFOperation)
     return;
 
+  myIsSketchStarted = true;
   SketcherPrs_Tools::setPixelRatio(ModuleBase_Tools::currentPixelRatio());
 
   myModule->onViewTransformed();
@@ -1067,7 +1074,6 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
   myModule->overconstraintListener()->setActive(true);
   // Display sketcher objects
   QStringList anInfo;
-  Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
   const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
   aNumberOfSubs = myCurrentSketch->numberOfSubs();
   for (int i = 0; i < aNumberOfSubs; i++) {
@@ -1088,6 +1094,7 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
       aECreator->sendUpdated(aFeature, EVENT_DISP);
     else
       aFeature->setDisplayed(true);
+    aECreator->sendUpdated(aFeature, EVENT_ATTR);
   }
 #ifdef DEBUG_SKETCHER_ENTITIES
   QString anInfoStr = anInfo.join(";\t");
@@ -1104,7 +1111,8 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
   workshop()->selectionActivate()->updateSelectionFilters();
   workshop()->selectionActivate()->updateSelectionModes();
 
-  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+  Events_Loop::loop()->flush(EVENT_DISP);
+  Events_Loop::loop()->flush(EVENT_ATTR);
 
   myExternalPointsMgr = new PartSet_ExternalPointsMgr(myModule->workshop(), myCurrentSketch);
 
@@ -1121,6 +1129,8 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
   myModule->workshop()->viewer()->setFitter(0);
   delete aFitter;
 
+  myIsSketchStarted = false;
+
   myIsMouseOverWindow = false;
   myIsConstraintsShown[PartSet_Tools::Geometrical] = true;
   myIsConstraintsShown[PartSet_Tools::Dimensional] = true;
@@ -1779,26 +1789,26 @@ void PartSet_SketcherMgr::widgetStateChanged(int thePreviousState)
   }
 }
 
-void PartSet_SketcherMgr::customizePresentation(const ObjectPtr& theObject)
-{
-  ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
-                                                                           (getCurrentOperation());
-  if (aFOperation && (PartSet_SketcherMgr::isSketchOperation(aFOperation) ||
-                      isNestedSketchOperation(aFOperation)))
-    SketcherPrs_Tools::sendExpressionShownEvent(myIsConstraintsShown[PartSet_Tools::Expressions]);
-
-  // update entities selection priorities
-  FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
-  if (aFeature.get() && PartSet_SketcherMgr::isEntity(aFeature->getKind())) {
-    // update priority for feature
-    updateSelectionPriority(aFeature, aFeature);
-    // update priority for results of the feature
-    std::list<ResultPtr> aResults = aFeature->results();
-    std::list<ResultPtr>::const_iterator anIt = aResults.begin(), aLastIt = aResults.end();
-    for (; anIt != aLastIt; anIt++)
-      updateSelectionPriority(*anIt, aFeature);
-  }
-}
+//void PartSet_SketcherMgr::customisePresentation(const ObjectPtr& theObject)
+//{
+//  ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+//                                                                           (getCurrentOperation());
+//  if (aFOperation && (PartSet_SketcherMgr::isSketchOperation(aFOperation) ||
+//                      isNestedSketchOperation(aFOperation)))
+//    SketcherPrs_Tools::sendExpressionShownEvent(myIsConstraintsShown[PartSet_Tools::Expressions]);
+//
+//  // update entities selection priorities
+//  FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+//  if (aFeature.get() && PartSet_SketcherMgr::isEntity(aFeature->getKind())) {
+//    // update priority for feature
+//    updateSelectionPriority(aFeature, aFeature);
+//    // update priority for results of the feature
+//    std::list<ResultPtr> aResults = aFeature->results();
+//    std::list<ResultPtr>::const_iterator anIt = aResults.begin(), aLastIt = aResults.end();
+//    for (; anIt != aLastIt; anIt++)
+//      updateSelectionPriority(*anIt, aFeature);
+//  }
+//}
 
 ModuleBase_Operation* PartSet_SketcherMgr::getCurrentOperation() const
 {
@@ -2142,6 +2152,128 @@ void PartSet_SketcherMgr::processEvent(const std::shared_ptr<Events_Message>& th
   }
 }
 
+bool isExternal(const ObjectPtr& theObject)
+{
+  AttributeSelectionPtr aAttr =
+    theObject->data()->selection(SketchPlugin_SketchEntity::EXTERNAL_ID());
+  if (aAttr)
+    return aAttr->context().get() != NULL && !aAttr->isInvalid();
+  return false;
+}
+
+bool isCopy(const ObjectPtr& theObject)
+{
+  AttributeBooleanPtr anAttr = theObject->data()->boolean(SketchPlugin_SketchEntity::COPY_ID());
+  if (anAttr.get())
+    return anAttr->value();
+  return false;
+}
+
+bool isIncludeToResult(const ObjectPtr& theObject)
+{
+  AttributeBooleanPtr anAttr;
+  std::set<AttributePtr> aRefsToMe = theObject->data()->refsToMe();
+  std::set<AttributePtr>::const_iterator aIt;
+  for (aIt = aRefsToMe.cbegin(); aIt != aRefsToMe.cend(); ++aIt) {
+    if ((*aIt)->id() == SketchPlugin_Projection::PROJECTED_FEATURE_ID()) {
+      FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>((*aIt)->owner());
+      if (aFeature.get()) {
+        anAttr = aFeature->data()->boolean(SketchPlugin_Projection::INCLUDE_INTO_RESULT());
+        if (anAttr.get())
+          return anAttr->value();
+      }
+    }
+  }
+  return true;
+}
+
+
+void PartSet_SketcherMgr::customizeSketchPresentation(const ObjectPtr& theObject,
+  const AISObjectPtr& thePrs) const
+{
+  FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+  PartSet_OverconstraintListener* aOCListener = myModule->overconstraintListener();
+
+  // Check constraints objects
+  const QStringList& aConstrIds = constraintsIdList();
+  std::string aKind = aFeature->getKind();
+  if (aConstrIds.contains(QString(aKind.c_str()))) {
+    std::vector<int> aColor;
+    if (aOCListener->isConflictingObject(theObject))
+      aColor = Config_PropManager::color("Visualization", "sketch_overconstraint_color");
+    else if (isDistanceKind(aKind))
+      aColor = Config_PropManager::color("Visualization", "sketch_dimension_color");
+
+    if (!aColor.empty())
+      thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+    return;
+  }
+  int aShapeType = thePrs->getShapeType();
+  // a compound is processed like the edge because the
+  // arc feature uses the compound for presentable AIS
+  if (aShapeType != 6/*an edge*/ && aShapeType != 7/*a vertex*/ && aShapeType != 0/*compound*/)
+    return;
+
+  // set color from preferences
+  std::shared_ptr<ModelAPI_AttributeBoolean> anAuxiliaryAttr =
+    aFeature->data()->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID());
+  bool isConstruction = anAuxiliaryAttr.get() != NULL && anAuxiliaryAttr->value();
+
+  std::vector<int> aColor;
+  if (aOCListener->isFullyConstrained())
+    aColor = Config_PropManager::color("Visualization", "sketch_fully_constrained_color");
+  else if (aOCListener->isConflictingObject(theObject))
+    aColor = Config_PropManager::color("Visualization", "sketch_overconstraint_color");
+  else {
+    if (isConstruction)
+      aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color");
+    else if (isExternal(aFeature))
+      aColor = Config_PropManager::color("Visualization", "sketch_external_color");
+    else
+      aColor = Config_PropManager::color("Visualization", "sketch_entity_color");
+  }
+  if (!aColor.empty()) {
+    // The code below causes redisplay again
+    if (ModelAPI_Session::get()->isOperation()) {
+      AttributeIntArrayPtr aColorAttr = theObject->data()->intArray(ModelAPI_Result::COLOR_ID());
+      if (aColorAttr.get()) {
+        aColorAttr->setSize(3);
+        // Set the color attribute in order do not use default colors in the presentation object
+        for (int i = 0; i < 3; i++)
+          aColorAttr->setValue(i, aColor[i], false);
+      }
+    }
+    thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+  }
+
+  if (aShapeType == 6 || aShapeType == 0) { // if this is an edge or a compound
+    if (isConstruction) {
+      // Set axilliary line
+      thePrs->setWidth(SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH_AUXILIARY());
+      thePrs->setLineStyle(SketchPlugin_SketchEntity::SKETCH_LINE_STYLE_AUXILIARY());
+    }
+    else {
+      int aWidth = Config_PropManager::integer("Visualization", "sketch_line_width");
+      thePrs->setWidth(aWidth);
+      thePrs->setLineStyle(SketchPlugin_SketchEntity::SKETCH_LINE_STYLE());
+    }
+  }
+  else if (aShapeType == 7) { // otherwise this is a vertex
+                              // The width value do not have effect on the point presentation.
+                              // It is defined in order to extend selection area of the object.
+    thePrs->setWidth(17);
+    //  thePrs->setPointMarker(1, 1.); // Set point as a '+' symbol
+  }
+  if (isCopy(aFeature) && !isIncludeToResult(aFeature)) {
+    double aWidth = thePrs->width();
+    thePrs->setWidth(aWidth / 2.5);
+  }
+
+  double aDeflection = Config_PropManager::real("Visualization", "construction_deflection");
+  thePrs->setDeflection(aDeflection);
+}
+
+//*************************************************************************************
 void PartSet_Fitter::fitAll(Handle(V3d_View) theView)
 {
   CompositeFeaturePtr aSketch = mySketchMgr->activeSketch();
index 24e6347d16d58c37908fb6c4d48880c46f73dc86..9336fdbf2235f0f705e4b187cab07a8661c8681d 100644 (file)
@@ -36,6 +36,7 @@
 #include <ModuleBase_ModelWidget.h>
 
 #include <GeomAPI_Pln.h>
+#include <GeomAPI_AISObject.h>
 
 #ifdef HAVE_SALOME
   #include <OCCViewer_ViewModel.h>
@@ -344,7 +345,7 @@ public:
   /// Create specific for the module presentation
   /// \param theResult an object for presentation
   /// \return created presentation or NULL(default value)
-  virtual Handle(AIS_InteractiveObject) createPresentation(const ResultPtr& theResult);
+  Handle(AIS_InteractiveObject) createPresentation(const ObjectPtr& theResult);
 
   /// Connects or disconnects to the value changed signal of the property panel widgets
   /// \param theWidget a property contol widget
@@ -358,7 +359,9 @@ public:
   /// If the current operation is a dimention one, the style of dimension visualization is send for
   /// the current object
   /// \param theObject an object to be customized
-  void customizePresentation(const ObjectPtr& theObject);
+  //void customisePresentation(const ObjectPtr& theObject);
+
+  void customizeSketchPresentation(const ObjectPtr& theObject, const AISObjectPtr& thePrs) const;
 
   /// Update sketch presentations according to the the state
   /// \param theType a type of sketch visualization style
@@ -377,6 +380,9 @@ public:
   */
   virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
 
+  bool isSketchStarted() const { return myIsSketchStarted; }
+
+
 public slots:
   /// Process sketch plane selected event
   void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
@@ -502,6 +508,8 @@ private:
   QMap<ResultPtr, Handle(AIS_Shape)> myPointsHighlight;
 
   bool myNoDragMoving;
+
+  bool myIsSketchStarted;
 };
 
 
index 3ef5b735f9fd6124b25fce78ca250a7aff826e6d..376bce7ce3a62a0c79a6ad922d928adbd7fde5f1 100644 (file)
@@ -36,6 +36,7 @@
 #include <ModelGeomAlgo_Point2D.h>
 
 #include <Events_Loop.h>
+#include <Events_InfoMessage.h>
 
 #include <SketcherPrs_Tools.h>
 
@@ -53,6 +54,7 @@
 #include <GeomAPI_Pnt.h>
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Vertex.h>
+#include <GeomAPI_ShapeExplorer.h>
 
 #include <GeomAPI_Dir.h>
 #include <GeomAPI_XYZ.h>
@@ -790,3 +792,58 @@ void PartSet_Tools::getFirstAndLastIndexInFolder(const ObjectPtr& theFolder,
   theFirst = aDoc->index(aFirstFeatureInFolder);
   theLast = aDoc->index(aLastFeatureInFolder);
 }
+
+
+void PartSet_Tools::getDefaultColor(ObjectPtr theObject, const bool isEmptyColorValid,
+  std::vector<int>& theColor)
+{
+  theColor.clear();
+  // get default color from the preferences manager for the given result
+  if (theColor.empty()) {
+    std::string aSection, aName, aDefault;
+    theObject->colorConfigInfo(aSection, aName, aDefault);
+    if (!aSection.empty() && !aName.empty()) {
+      theColor = Config_PropManager::color(aSection, aName);
+    }
+  }
+  if (!isEmptyColorValid && theColor.empty()) {
+    // all AIS objects, where the color is not set, are in black.
+    // The color should be defined in XML or set in the attribute
+    theColor = Config_PropManager::color("Visualization", "object_default_color");
+    Events_InfoMessage("PartSet_Tools",
+      "A default color is not defined in the preferences for this result type").send();
+  }
+}
+
+double PartSet_Tools::getDefaultDeflection(const ObjectPtr& theObject)
+{
+  double aDeflection = -1;
+  ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+  if (aResult.get()) {
+    bool isConstruction = false;
+
+    std::string aResultGroup = aResult->groupName();
+    if (aResultGroup == ModelAPI_ResultConstruction::group())
+      isConstruction = true;
+    else if (aResultGroup == ModelAPI_ResultBody::group()) {
+      GeomShapePtr aGeomShape = aResult->shape();
+      if (aGeomShape.get()) {
+        // if the shape could not be exploded on faces, it contains only wires, edges, and vertices
+        // correction of deviation for them should not influence to the application performance
+        GeomAPI_ShapeExplorer anExp(aGeomShape, GeomAPI_Shape::FACE);
+        isConstruction = !anExp.more();
+      }
+    }
+    if (isConstruction)
+      aDeflection = Config_PropManager::real("Visualization", "construction_deflection");
+    else
+      aDeflection = Config_PropManager::real("Visualization", "body_deflection");
+  }
+  return aDeflection;
+}
+
+
+double PartSet_Tools::getDefaultTransparency()
+{
+  return Config_PropManager::integer("Visualization", "shaper_default_transparency") / 100.;
+}
index 0de36c1e24af8ca322a21f3a310043065f64f8ca..7f1c236abb474dc25a51394062dce820cc262cfe 100644 (file)
@@ -297,7 +297,26 @@ public:
                                                FeaturePtr& theCreatedFeature);
 
 
-  static void getFirstAndLastIndexInFolder(const ObjectPtr& theFolder, int& theFirst, int& theLast);
+  static void getFirstAndLastIndexInFolder(const ObjectPtr& theFolder,
+    int& theFirst, int& theLast);
+
+
+  /**
+  * Returns default color value for the given object
+  */
+  static void getDefaultColor(ObjectPtr theObject, const bool isEmptyColorValid,
+    std::vector<int>& theColor);
+
+  /**
+  * Returns default deflection value for the given object
+  */
+  static double getDefaultDeflection(const ObjectPtr& theObject);
+
+
+  /**
+  * Returns default transparency value
+  */
+  static double getDefaultTransparency();
 };
 
 #endif
index 2bfd5c34be1cdb0a4c8a782e840b44ec01fd823e..e769c019cbc17e1364328ab0f7305efca13f569f 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "SketchPlugin_ConstraintAngle.h"
 #include <SketchPlugin_Line.h>
+#include <SketchPlugin_Tools.h>
 #include <SketcherPrs_Tools.h>
 
 #include <ModelAPI_AttributeDouble.h>
@@ -117,6 +118,8 @@ AISObjectPtr SketchPlugin_ConstraintAngle::getAISObject(AISObjectPtr thePrevious
 
   AISObjectPtr anAIS = SketcherPrs_Factory::angleConstraint(this, sketch(),
                                                             thePrevious);
+  if (anAIS.get() && !thePrevious.get())
+    SketchPlugin_Tools::setDimensionColor(anAIS);
   return anAIS;
 }
 
index 16a0451d4044c1987e970bf4b56adea306ed4e8a..391c1016234ecb1702b235963af676b10f31544e 100644 (file)
@@ -21,6 +21,7 @@
 #include <SketchPlugin_Point.h>
 #include <SketchPlugin_Circle.h>
 #include <SketchPlugin_Line.h>
+#include <SketchPlugin_Tools.h>
 
 #include <SketcherPrs_Tools.h>
 #include <SketcherPrs_Factory.h>
@@ -95,6 +96,8 @@ AISObjectPtr SketchPlugin_ConstraintDistance::getAISObject(AISObjectPtr thePrevi
   AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this,
                                                                       sketch(),
                                                                       thePrevious);
+  if (anAIS.get() && !thePrevious.get())
+    SketchPlugin_Tools::setDimensionColor(anAIS);
   return anAIS;
 }
 
index 3357d5819f52c9e97f0d48dd055a097894243242..bd45029bafd3d17f65b1185a07f45b8d6af34fbe 100644 (file)
@@ -22,6 +22,7 @@
 // Author:  Artem ZHIDKOV
 
 #include <SketchPlugin_ConstraintDistanceAlongDir.h>
+#include <SketchPlugin_Tools.h>
 
 #include <SketcherPrs_Tools.h>
 #include <SketcherPrs_Factory.h>
@@ -84,6 +85,8 @@ AISObjectPtr SketchPlugin_ConstraintDistanceAlongDir::getAISObject(AISObjectPtr
   AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this,
                                                                       sketch(),
                                                                       thePrevious);
+  if (anAIS.get() && !thePrevious.get())
+    SketchPlugin_Tools::setDimensionColor(anAIS);
   return anAIS;
 }
 
index 1ba4aa081ff9e54a91a7af1b61fb40fd824aa74a..ad6ee92b540721d4df98d217917d2eee2c9efc47 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "SketchPlugin_ConstraintLength.h"
 #include <SketchPlugin_Line.h>
+#include <SketchPlugin_Tools.h>
 
 #include <GeomDataAPI_Point2D.h>
 
@@ -171,6 +172,8 @@ AISObjectPtr SketchPlugin_ConstraintLength::getAISObject(AISObjectPtr thePreviou
 
   AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this,
     sketch(), thePrevious);
+  if (anAIS.get() && !thePrevious.get())
+    SketchPlugin_Tools::setDimensionColor(anAIS);
   return anAIS;
 }
 
index b27190e0a556f406ca0325e778b407da433d139c..a58609b2dcc64e814effe66c84f71c77367e46c6 100644 (file)
@@ -22,6 +22,7 @@
 #include <SketchPlugin_Arc.h>
 #include <SketchPlugin_Circle.h>
 #include <SketchPlugin_Point.h>
+#include <SketchPlugin_Tools.h>
 
 #include <SketcherPrs_Factory.h>
 #include <SketcherPrs_Tools.h>
@@ -177,6 +178,8 @@ AISObjectPtr SketchPlugin_ConstraintRadius::getAISObject(AISObjectPtr thePreviou
 
   AISObjectPtr anAIS = SketcherPrs_Factory::radiusConstraint(this, sketch(),
                                                              thePrevious);
+  if (anAIS.get() && !thePrevious.get())
+    SketchPlugin_Tools::setDimensionColor(anAIS);
   return anAIS;
 }
 
index e076f47c2454d2b1ba6081c6dc91f7fb6e9b8f43..9507cad1a9970b0b557863383d559d498b114031 100644 (file)
@@ -193,6 +193,11 @@ AISObjectPtr SketchPlugin_Fillet::getAISObject(AISObjectPtr thePrevious)
     anAISObject = AISObjectPtr(new GeomAPI_AISObject);
   }
   anAISObject->createShape(anArcShape);
+  bool isAxiliary = false;
+  AttributeBooleanPtr aAttr = boolean(AUXILIARY_ID());
+  if (aAttr.get())
+    isAxiliary = aAttr->value();
+  SketchPlugin_Tools::customizeFeaturePrs(anAISObject, isAxiliary);
   return anAISObject;
 }
 
index f0379c4618eac92385f15b151b3f1eaedd048e20..eab082403538c41a9c7ecd59a2450a87759c4f0f 100644 (file)
@@ -297,6 +297,7 @@ AISObjectPtr SketchPlugin_MacroArc::getAISObject(AISObjectPtr thePrevious)
     anAIS.reset(new GeomAPI_AISObject());
   }
   anAIS->createShape(aCompound);
+  SketchPlugin_Tools::customizeFeaturePrs(anAIS, boolean(AUXILIARY_ID())->value());
   return anAIS;
 }
 
index 0bcabf4ff4731a90b7d26c7f2f34fffe07ca4cc9..7a0572702e263fd4c8d020120995af46bc7a3fc8 100644 (file)
@@ -389,6 +389,10 @@ AISObjectPtr SketchPlugin_MacroCircle::getAISObject(AISObjectPtr thePrevious)
     anAIS.reset(new GeomAPI_AISObject());
   }
   anAIS->createShape(aCompound);
+
+  // Modify attributes
+  SketchPlugin_Tools::customizeFeaturePrs(anAIS, boolean(AUXILIARY_ID())->value());
+
   return anAIS;
 }
 
index e1e79e3aedac61736e6a65b37a920ec6cba00d3e..2cf1cbc7f011bcf9ff4c7a6e314d46c57f395705 100644 (file)
@@ -380,5 +380,9 @@ AISObjectPtr SketchPlugin_MacroEllipse::getAISObject(AISObjectPtr thePrevious)
   if (!anAIS)
     anAIS.reset(new GeomAPI_AISObject());
   anAIS->createShape(aCompound);
+
+  // Modify attributes
+  SketchPlugin_Tools::customizeFeaturePrs(anAIS, boolean(AUXILIARY_ID())->value());
+
   return anAIS;
 }
index 984a759261cd1ace2416455d69f18a2531452b50..bd8290c0c5db33c4d749befe5146c0bfb09049a9 100644 (file)
@@ -350,6 +350,7 @@ AISObjectPtr SketchPlugin_MacroEllipticArc::getAISObject(AISObjectPtr thePreviou
   if (!anAIS)
     anAIS.reset(new GeomAPI_AISObject());
   anAIS->createShape(aCompound);
+  SketchPlugin_Tools::customizeFeaturePrs(anAIS, boolean(AUXILIARY_ID())->value());
   return anAIS;
 }
 
index 79eb675ca240ca273480dd8d6d4c92ed3b8f08d9..e04031fee6db7cee731dd447ce225900018759b9 100644 (file)
@@ -35,6 +35,9 @@
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_Tools.h>
+#include <ModelAPI_Events.h>
+
+#include <Events_Loop.h>
 
 #include <GeomAPI_Circ.h>
 #include <GeomAPI_Edge.h>
@@ -51,6 +54,7 @@
 
 static const double tolerance = 1.e-7;
 
+
 SketchPlugin_Projection::SketchPlugin_Projection()
     : SketchPlugin_SketchEntity(),
       myIsComputing(false)
@@ -371,6 +375,9 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID)
       setResult(aResult);
       GeomShapePtr anEmptyVal;
       aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), anEmptyVal);
+
+      static const Events_ID anEvent = Events_Loop::eventByName(EVENT_VISUAL_ATTRIBUTES);
+      ModelAPI_EventCreator::get()->sendUpdated(aProjection, anEvent, false);
     }
   }
 }
index 7f63c5bb2ca4643eee898b0878d9ba81f3528389..6feda008dd89d3a607d48306566c0f362184592f 100644 (file)
@@ -43,7 +43,7 @@
  * \ingroup Plugins
  * \brief Feature for creation of the new part in PartSet.
  */
-class SketchPlugin_Sketch : public ModelAPI_CompositeFeature, public GeomAPI_ICustomPrs
+class SketchPlugin_Sketch : public ModelAPI_CompositeFeature//, public GeomAPI_ICustomPrs
 {
  public:
   /// Sketch feature kind
@@ -257,18 +257,18 @@ class SketchPlugin_Sketch : public ModelAPI_CompositeFeature, public GeomAPI_ICu
   static std::shared_ptr<GeomAPI_Ax3> plane(SketchPlugin_Sketch* theSketch);
 
   /// Customize presentation of the feature
-  virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
-                                     std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs)
-  {
-    bool isCustomized = false;
-    // apply the color of the result to the presentation
-    if (theDefaultPrs.get())
-      isCustomized = theDefaultPrs->customisePresentation(theResult, thePrs, theDefaultPrs);
-    // set the sketch presentation bold
-    isCustomized = thePrs->setWidth(2) || isCustomized;
-
-    return isCustomized;
-  }
+  //virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
+  //                                   std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs)
+  //{
+  //  bool isCustomized = false;
+  //  // apply the color of the result to the presentation
+  //  if (theDefaultPrs.get())
+  //    isCustomized = theDefaultPrs->customisePresentation(theResult, thePrs, theDefaultPrs);
+  //  // set the sketch presentation bold
+  //  isCustomized = thePrs->setWidth(2) || isCustomized;
+
+  //  return isCustomized;
+  //}
 
 private:
   /// Substitute all links to external objects by newly created features.
index b915d8540e92b53c074e379a8eb96ea269647c53..cae07149d584e95a8f10981f29115882bea2069e 100644 (file)
@@ -41,7 +41,7 @@
  * 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
+class SketchPlugin_SketchEntity : public SketchPlugin_Feature //, public GeomAPI_ICustomPrs
 {
  public:
   /// Reference to the construction type of the feature
@@ -66,13 +66,13 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
   }
 
   /// Width of the auxiliary line
-  inline static const double SKETCH_LINE_WIDTH_AUXILIARY()
+  inline static const int SKETCH_LINE_WIDTH_AUXILIARY()
   {
     return 2;
   }
 
   /// Width of the line
-  inline static const double SKETCH_LINE_WIDTH()
+  inline static const int SKETCH_LINE_WIDTH()
   {
     return Config_PropManager::integer("Visualization", "sketch_line_width");
   }
@@ -111,105 +111,105 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
     return false;
   }
 
-  virtual bool isIncludeToResult() const
-  {
-    AttributeBooleanPtr anAttr;
-    std::set<AttributePtr> aRefsToMe = data()->refsToMe();
-    std::set<AttributePtr>::const_iterator aIt;
-    for (aIt = aRefsToMe.cbegin(); aIt != aRefsToMe.cend(); ++aIt) {
-      if ((*aIt)->id() == "ProjectedFeature") {
-        FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>((*aIt)->owner());
-        if (aFeature.get()) {
-          anAttr = aFeature->data()->boolean("IncludeToResult");
-          if (anAttr.get())
-            return anAttr->value();
-        }
-      }
-    }
-    return true;
-  }
+  //virtual bool isIncludeToResult() const
+  //{
+  //  AttributeBooleanPtr anAttr;
+  //  std::set<AttributePtr> aRefsToMe = data()->refsToMe();
+  //  std::set<AttributePtr>::const_iterator aIt;
+  //  for (aIt = aRefsToMe.cbegin(); aIt != aRefsToMe.cend(); ++aIt) {
+  //    if ((*aIt)->id() == "ProjectedFeature") {
+  //      FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>((*aIt)->owner());
+  //      if (aFeature.get()) {
+  //        anAttr = aFeature->data()->boolean("IncludeToResult");
+  //        if (anAttr.get())
+  //          return anAttr->value();
+  //      }
+  //    }
+  //  }
+  //  return true;
+  //}
 
 // LCOV_EXCL_START
   /// Customize presentation of the feature
-  virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
-                                     std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs)
-  {
-    /// Store previous color values of the presentation to check it after setting specific entity
-    /// color. Default color is set into presentation to have not modified isCustomized state
-    /// after default customize prs is completed.
-    std::vector<int> aPrevColor;
-    aPrevColor.resize(3);
-    thePrs->getColor(aPrevColor[0], aPrevColor[1], aPrevColor[2]);
-    if (theResult.get()) {
-      std::string aSection, aName, aDefault;
-      theResult->colorConfigInfo(aSection, aName, aDefault);
-      std::vector<int> aColor;
-      aColor = Config_PropManager::color(aSection, aName);
-      thePrs->setColor(aColor[0], aColor[1], aColor[2]);
-    }
-
-    bool isCustomized = theDefaultPrs.get() != NULL &&
-                        theDefaultPrs->customisePresentation(theResult, thePrs, theDefaultPrs);
-    int aShapeType = thePrs->getShapeType();
-    // a compound is processed like the edge because the
-    // arc feature uses the compound for presentable AIS
-    if (aShapeType != 6/*an edge*/ && aShapeType != 7/*a vertex*/ && aShapeType != 0/*compound*/)
-      return false;
-
-    // set color from preferences
-    std::vector<int> aColor;
-    std::shared_ptr<ModelAPI_AttributeBoolean> anAuxiliaryAttr =
-                                    data()->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID());
-    bool isConstruction = anAuxiliaryAttr.get() != NULL && anAuxiliaryAttr->value();
-    if (isConstruction) {
-      aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color");
-    }
-    else if (isExternal()) {
-      aColor = Config_PropManager::color("Visualization", "sketch_external_color");
-    }
-    else {
-      aColor = Config_PropManager::color("Visualization", "sketch_entity_color");
-    }
-    if (!aColor.empty()) {
-      if (theResult.get() && ModelAPI_Session::get()->isOperation()) {
-        AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID());
-        aColorAttr->setSize(3);
-        // Set the color attribute in order do not use default colors in the presentation object
-        for (int i = 0; i < 3; i++)
-          aColorAttr->setValue(i, aColor[i]);
-      }
-      thePrs->setColor(aColor[0], aColor[1], aColor[2]);
-      for (int i = 0; i < 3 && !isCustomized; i++)
-        isCustomized = aColor[i] != aPrevColor[i];
-    }
-
-    if (aShapeType == 6 || aShapeType == 0) { // if this is an edge or a compound
-      if (isConstruction) {
-        isCustomized = thePrs->setWidth(SKETCH_LINE_WIDTH_AUXILIARY()) || isCustomized;
-        isCustomized = thePrs->setLineStyle(SKETCH_LINE_STYLE_AUXILIARY()) || isCustomized;
-      }
-      else {
-        isCustomized = thePrs->setWidth(SKETCH_LINE_WIDTH()) || isCustomized;
-        isCustomized = thePrs->setLineStyle(SKETCH_LINE_STYLE()) || isCustomized;
-      }
-    }
-    else if (aShapeType == 7) { // otherwise this is a vertex
-      // The width value do not have effect on the point presentation.
-      // It is defined in order to extend selection area of the object.
-      thePrs->setWidth(17);
-    //  thePrs->setPointMarker(1, 1.); // Set point as a '+' symbol
-    }
-    if(isCopy() && !isIncludeToResult()) {
-      double aWidth = thePrs->width();
-      isCustomized = thePrs->setWidth(aWidth / 2.5) || isCustomized;
-    }
-
-    if (!theResult.get()) {
-      double aDeflection = Config_PropManager::real("Visualization", "construction_deflection");
-      thePrs->setDeflection(aDeflection);
-    }
-    return isCustomized;
-  }
+  //virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
+  //                                   std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs)
+  //{
+  //  /// Store previous color values of the presentation to check it after setting specific entity
+  //  /// color. Default color is set into presentation to have not modified isCustomized state
+  //  /// after default customize prs is completed.
+  //  std::vector<int> aPrevColor;
+  //  aPrevColor.resize(3);
+  //  thePrs->getColor(aPrevColor[0], aPrevColor[1], aPrevColor[2]);
+  //  if (theResult.get()) {
+  //    std::string aSection, aName, aDefault;
+  //    theResult->colorConfigInfo(aSection, aName, aDefault);
+  //    std::vector<int> aColor;
+  //    aColor = Config_PropManager::color(aSection, aName);
+  //    thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+  //  }
+
+  //  bool isCustomized = theDefaultPrs.get() != NULL &&
+  //                      theDefaultPrs->customisePresentation(theResult, thePrs, theDefaultPrs);
+  //  int aShapeType = thePrs->getShapeType();
+  //  // a compound is processed like the edge because the
+  //  // arc feature uses the compound for presentable AIS
+  //  if (aShapeType != 6/*an edge*/ && aShapeType != 7/*a vertex*/ && aShapeType != 0/*compound*/)
+  //    return false;
+
+  //  // set color from preferences
+  //  std::vector<int> aColor;
+  //  std::shared_ptr<ModelAPI_AttributeBoolean> anAuxiliaryAttr =
+  //                                  data()->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID());
+  //  bool isConstruction = anAuxiliaryAttr.get() != NULL && anAuxiliaryAttr->value();
+  //  if (isConstruction) {
+  //    aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color");
+  //  }
+  //  else if (isExternal()) {
+  //    aColor = Config_PropManager::color("Visualization", "sketch_external_color");
+  //  }
+  //  else {
+  //    aColor = Config_PropManager::color("Visualization", "sketch_entity_color");
+  //  }
+  //  if (!aColor.empty()) {
+  //    if (theResult.get() && ModelAPI_Session::get()->isOperation()) {
+  //      AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID());
+  //      aColorAttr->setSize(3);
+  //      // Set the color attribute in order do not use default colors in the presentation object
+  //      for (int i = 0; i < 3; i++)
+  //        aColorAttr->setValue(i, aColor[i]);
+  //    }
+  //    thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+  //    for (int i = 0; i < 3 && !isCustomized; i++)
+  //      isCustomized = aColor[i] != aPrevColor[i];
+  //  }
+
+  //  if (aShapeType == 6 || aShapeType == 0) { // if this is an edge or a compound
+  //    if (isConstruction) {
+  //      isCustomized = thePrs->setWidth(SKETCH_LINE_WIDTH_AUXILIARY()) || isCustomized;
+  //      isCustomized = thePrs->setLineStyle(SKETCH_LINE_STYLE_AUXILIARY()) || isCustomized;
+  //    }
+  //    else {
+  //      isCustomized = thePrs->setWidth(SKETCH_LINE_WIDTH()) || isCustomized;
+  //      isCustomized = thePrs->setLineStyle(SKETCH_LINE_STYLE()) || isCustomized;
+  //    }
+  //  }
+  //  else if (aShapeType == 7) { // otherwise this is a vertex
+  //    // The width value do not have effect on the point presentation.
+  //    // It is defined in order to extend selection area of the object.
+  //    thePrs->setWidth(17);
+  //  //  thePrs->setPointMarker(1, 1.); // Set point as a '+' symbol
+  //  }
+  //  if(isCopy() && !isIncludeToResult()) {
+  //    double aWidth = thePrs->width();
+  //    isCustomized = thePrs->setWidth(aWidth / 2.5) || isCustomized;
+  //  }
+
+  //  if (!theResult.get()) {
+  //    double aDeflection = Config_PropManager::real("Visualization", "construction_deflection");
+  //    thePrs->setDeflection(aDeflection);
+  //  }
+  //  return isCustomized;
+  //}
 // LCOV_EXCL_STOP
 
 protected:
index a285ea2431c1e7b8a2364b91047292a88f43e56e..0147ba521d38ed1f2be00ff5aa870a3d85f3f6a3 100644 (file)
@@ -537,6 +537,32 @@ GeomPnt2dPtr flyoutPointCoordinates(const ConstraintPtr& theConstraint)
   return GeomPnt2dPtr(new GeomAPI_Pnt2d(X, Y));
 }
 
+
+void customizeFeaturePrs(const AISObjectPtr& thePrs, bool isAxiliary)
+{
+  std::vector<int> aColor;
+  int aWidth = 1;
+  if (isAxiliary) {
+    thePrs->setLineStyle(SketchPlugin_SketchEntity::SKETCH_LINE_STYLE_AUXILIARY());
+    aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color");
+    aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH_AUXILIARY();
+  }
+  else {
+    thePrs->setLineStyle(SketchPlugin_SketchEntity::SKETCH_LINE_STYLE());
+    aColor = Config_PropManager::color("Visualization", "sketch_entity_color");
+    aWidth = Config_PropManager::integer("Visualization", "sketch_line_width");
+  }
+  thePrs->setWidth(aWidth);
+  thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+}
+
+void setDimensionColor(const AISObjectPtr& theDimPrs)
+{
+  std::vector<int> aColor = Config_PropManager::color("Visualization", "sketch_dimension_color");
+  if (aColor.size() == 3)
+    theDimPrs->setColor(aColor[0], aColor[1], aColor[2]);
+}
+
 } // namespace SketchPlugin_Tools
 
 
index f29e192dffa83622bd7b849635dd80738fe1c194..a45ecf05a85899eeef033f8964028dabdc8e3e9c 100644 (file)
@@ -26,6 +26,7 @@
 #include <ModelAPI_Attribute.h>
 #include <ModelAPI_AttributeRefAttr.h>
 #include <GeomAPI_Shape.h>
+#include <GeomAPI_AISObject.h>
 #include <GeomDataAPI_Point2D.h>
 #include <GeomAlgoAPI_ShapeTools.h>
 
@@ -135,9 +136,16 @@ void convertRefAttrToPointOrTangentCurve(const AttributeRefAttrPtr&      theRefA
                                          std::shared_ptr<GeomAPI_Shape>& theTangentCurve,
                                          std::shared_ptr<GeomAPI_Pnt2d>& thePassingPoint);
 
-
 /// Calculate global coordinates for flyout point of Length constraint
 GeomPnt2dPtr flyoutPointCoordinates(const std::shared_ptr<SketchPlugin_Constraint>& theConstraint);
+
+/// Sets attributes of feature presentation
+/// \param[in] thePrs a presentation
+/// \param[in] isAxiliary is axiliary flag
+void customizeFeaturePrs(const AISObjectPtr& thePrs, bool isAxiliary);
+
+void setDimensionColor(const AISObjectPtr& theDimPrs);
+
 }; // namespace SketchPlugin_Tools
 
 namespace SketchPlugin_SegmentationTools
index 1476a14926570dc655e341a8be0bb9b4a7d2b8ad..69f43adf8bd64b79c84df3149e7d6ced24075970 100644 (file)
@@ -35,7 +35,7 @@
                 helpfile="pointFeature.html">
         <sketch-2dpoint_selector id="PointCoordinates" accept_expressions="0" title="Point" tooltip="Point coordinates"
                                  enable_value="enable_by_preferences"/>
-        <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
+        <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0" change_visual_attributes="true"/>
       </feature>
 
       <!-- SketchLine -->
@@ -47,7 +47,7 @@
                                  enable_value="enable_by_preferences"/>
         <labelvalue id="LineLength" accept_expressions="0" label="Length" default="computed" icon="icons/Sketch/distance_value.png"
                      tooltip="Line length" obligatory="0" enable_value="false"/>
-        <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
+        <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0" change_visual_attributes="true"/>
         <validator id="GeomValidators_Different" parameters="StartPoint,EndPoint"/>
       </feature>
     </group>
@@ -71,7 +71,7 @@
                     accept_expressions="0"
                     enable_value="enable_by_preferences">
         </labelvalue>
-        <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
+        <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0" change_visual_attributes="true"/>
       </feature>
       <!-- SketchMacroCircle -->
       <feature id="SketchMacroCircle"
                    tooltip="Construction element"
                    label="Auxiliary"
                    default="false"
-                   obligatory="0"/>
+                   obligatory="0"
+                   change_visual_attributes="true"/>
       </feature>
 
       <!-- SketchArc -->
                    label="Auxiliary"
                    tooltip="Construction element"
                    default="false"
-                   obligatory="0"/>
+                   obligatory="0"
+                   change_visual_attributes="true"/>
       </feature>
 
       <!-- SketchMacroArc -->
                    label="Auxiliary"
                    tooltip="Construction element"
                    default="false"
-                   obligatory="0"/>
+                   obligatory="0"
+                   change_visual_attributes="true"/>
       </feature>
 
       <!--  SketchFillet  -->
                     accept_expressions="0"
                     enable_value="enable_by_preferences">
         </labelvalue>
-        <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
+        <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0" change_visual_attributes="true"/>
       </feature>
       <!-- SketchMacroEllipse -->
       <feature id="SketchMacroEllipse"
                    tooltip="Construction element"
                    label="Auxiliary"
                    default="false"
-                   obligatory="0"/>
+                   obligatory="0"
+                   change_visual_attributes="true"/>
       </feature>
 
       <!-- SketchEllipticArc is a hidden feature. It is created inside SketchMacroEllipse. -->
                     accept_expressions="0"
                     enable_value="enable_by_preferences">
         </labelvalue>
-        <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
+        <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0" change_visual_attributes="true"/>
       </feature>
       <!-- SketchMacroEllipticArc -->
       <feature id="SketchMacroEllipticArc"
                    tooltip="Construction element"
                    label="Auxiliary"
                    default="false"
-                   obligatory="0"/>
+                   obligatory="0"
+                   change_visual_attributes="true"/>
       </feature>
     </group>
 
               use_sketch_plane="false">
           <validator id="SketchPlugin_ProjectionValidator"/>
         </sketch_shape_selector>
-        <boolvalue id="IncludeToResult" label="Include into the sketch result" default="true" tooltip="Include projected feature into the sketch result"/>
+        <boolvalue id="IncludeToResult" label="Include into the sketch result" default="true" tooltip="Include projected feature into the sketch result"
+                   change_visual_attributes="true"/>
         <validator id="PartSet_ProjectionSelection"/>
       </feature>
 
               use_sketch_plane="false">
           <validator id="SketchPlugin_IntersectionValidator"/>
         </sketch_shape_selector>
-        <boolvalue id="IncludeToResult" label="Include into the sketch result" default="true" tooltip="Include projected feature into the sketch result"/>
+        <boolvalue id="IncludeToResult" label="Include into the sketch result" default="true" tooltip="Include projected feature into the sketch result"
+                   change_visual_attributes="true"/>
         <validator id="PartSet_IntersectionSelection"/>
       </feature>
     </group>
index 28eda1784f06b1d376d927984b0f73bffbd414f7..2d9b66911da9c5bef275acb654db63115a987749 100644 (file)
@@ -36,7 +36,6 @@ SET(PROJECT_HEADERS
     XGUI_ActiveControlSelector.h
     XGUI_ColorDialog.h
     XGUI_ContextMenuMgr.h
-    XGUI_CustomPrs.h
     XGUI_DataModel.h
     XGUI_DeflectionDialog.h
     XGUI_Displayer.h
@@ -104,7 +103,6 @@ SET(PROJECT_SOURCES
     XGUI_ActiveControlMgr.cpp
     XGUI_ColorDialog.cpp
     XGUI_ContextMenuMgr.cpp
-    XGUI_CustomPrs.cpp
     XGUI_DataModel.cpp
     XGUI_DeflectionDialog.cpp
     XGUI_Displayer.cpp
diff --git a/src/XGUI/XGUI_CustomPrs.cpp b/src/XGUI/XGUI_CustomPrs.cpp
deleted file mode 100644 (file)
index f3bd683..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include <XGUI_CustomPrs.h>
-#include <XGUI_Workshop.h>
-#include <XGUI_Displayer.h>
-
-#include <ModuleBase_IModule.h>
-
-#include <ModelAPI_AttributeIntArray.h>
-#include <ModelAPI_AttributeDouble.h>
-#include <ModelAPI_Session.h>
-#include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultConstruction.h>
-
-#include <GeomAPI_ShapeExplorer.h>
-
-#include <Config_PropManager.h>
-
-#include <Events_InfoMessage.h>
-
-#include <vector>
-#include <QColor>
-
-double getDeflection(const ResultPtr& theResult)
-{
-  double aDeflection = -1;
-  // get deflection from the attribute of the result
-  if (theResult.get() != NULL &&
-      theResult->data()->attribute(ModelAPI_Result::DEFLECTION_ID()).get() != NULL) {
-    AttributeDoublePtr aDoubleAttr = theResult->data()->real(ModelAPI_Result::DEFLECTION_ID());
-    if (aDoubleAttr.get() && aDoubleAttr->isInitialized()) {
-      double aValue = aDoubleAttr->value();
-      if (aValue > 0) /// zero value should not be used as a deflection(previous studies)
-        aDeflection = aDoubleAttr->value();
-    }
-  }
-  return aDeflection;
-}
-
-void getColor(const ResultPtr& theResult, std::vector<int>& theColor)
-{
-  theColor.clear();
-  // get color from the attribute of the result
-  if (theResult.get() != NULL &&
-      theResult->data()->attribute(ModelAPI_Result::COLOR_ID()).get() != NULL) {
-    AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID());
-    if (aColorAttr.get() && aColorAttr->size()) {
-      theColor.push_back(aColorAttr->value(0));
-      theColor.push_back(aColorAttr->value(1));
-      theColor.push_back(aColorAttr->value(2));
-    }
-  }
-}
-
-void XGUI_CustomPrs::getDefaultColor(ObjectPtr theObject, const bool isEmptyColorValid,
-                                     std::vector<int>& theColor)
-{
-  theColor.clear();
-  // get default color from the preferences manager for the given result
-  if (theColor.empty()) {
-    std::string aSection, aName, aDefault;
-    theObject->colorConfigInfo(aSection, aName, aDefault);
-    if (!aSection.empty() && !aName.empty()) {
-      theColor = Config_PropManager::color(aSection, aName);
-    }
-  }
-  if (!isEmptyColorValid && theColor.empty()) {
-    // all AIS objects, where the color is not set, are in black.
-    // The color should be defined in XML or set in the attribute
-    theColor = Config_PropManager::color("Visualization", "object_default_color");
-    Events_InfoMessage("XGUI_CustomPrs",
-      "A default color is not defined in the preferences for this kind of result").send();
-  }
-}
-
-double XGUI_CustomPrs::getDefaultDeflection(const ObjectPtr& theObject)
-{
-  double aDeflection = -1;
-  ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
-  if (aResult.get()) {
-    bool isConstruction = false;
-
-    std::string aResultGroup = aResult->groupName();
-    if (aResultGroup == ModelAPI_ResultConstruction::group())
-      isConstruction = true;
-    else if (aResultGroup == ModelAPI_ResultBody::group()) {
-      GeomShapePtr aGeomShape = aResult->shape();
-      if (aGeomShape.get()) {
-        // if the shape could not be exploded on faces, it contains only wires, edges, and vertices
-        // correction of deviation for them should not influence to the application performance
-        GeomAPI_ShapeExplorer anExp(aGeomShape, GeomAPI_Shape::FACE);
-        isConstruction = !anExp.more();
-      }
-    }
-    if (isConstruction)
-      aDeflection = Config_PropManager::real("Visualization", "construction_deflection");
-    else
-      aDeflection = Config_PropManager::real("Visualization", "body_deflection");
-  }
-  return aDeflection;
-}
-
-double getTransparency(const ResultPtr& theResult)
-{
-  double aTransparency = -1;
-  // get transparency from the attribute of the result
-  if (theResult.get() != NULL &&
-      theResult->data()->attribute(ModelAPI_Result::TRANSPARENCY_ID()).get() != NULL) {
-    AttributeDoublePtr aDoubleAttr = theResult->data()->real(ModelAPI_Result::TRANSPARENCY_ID());
-    if (aDoubleAttr.get() && aDoubleAttr->isInitialized()) {
-      aTransparency = aDoubleAttr->value();
-    }
-  }
-  return aTransparency;
-}
-
-double getDefaultTransparency(const ResultPtr& theResult)
-{
-  return Config_PropManager::integer("Visualization", "shaper_default_transparency") / 100.;
-}
-
-XGUI_CustomPrs::XGUI_CustomPrs(XGUI_Workshop* theWorkshop)
-: myWorkshop(theWorkshop)
-{
-}
-
-void XGUI_CustomPrs::getResultColor(const ResultPtr& theResult, std::vector<int>& theColor)
-{
-  getColor(theResult, theColor);
-  if (theColor.empty())
-    getDefaultColor(theResult, false, theColor);
-}
-
-double XGUI_CustomPrs::getResultDeflection(const ResultPtr& theResult)
-{
-  double aDeflection = getDeflection(theResult);
-  if (aDeflection < 0)
-    aDeflection = getDefaultDeflection(theResult);
-  return aDeflection;
-}
-
-double XGUI_CustomPrs::getResultTransparency(const ResultPtr& theResult)
-{
-  double aTransparency = getTransparency(theResult);
-  if (aTransparency < 0)
-    aTransparency = getDefaultTransparency(theResult);
-  return aTransparency;
-}
-
-bool XGUI_CustomPrs::customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
-                                           std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs)
-{
-  bool aCustomized = false;
-  if (theResult.get()) {
-    std::vector<int> aColor;
-    getResultColor(theResult, aColor);
-
-    SessionPtr aMgr = ModelAPI_Session::get();
-    if (aMgr->activeDocument() != theResult->document()) {
-      QColor aQColor(aColor[0], aColor[1], aColor[2]);
-      QColor aNewColor =
-        QColor::fromHsvF(aQColor.hueF(), aQColor.saturationF()/3., aQColor.valueF());
-      aColor[0] = aNewColor.red();
-      aColor[1] = aNewColor.green();
-      aColor[2] = aNewColor.blue();
-    }
-    aCustomized = !aColor.empty() && thePrs->setColor(aColor[0], aColor[1], aColor[2]);
-
-    aCustomized = thePrs->setDeflection(getResultDeflection(theResult)) | aCustomized;
-
-    aCustomized = thePrs->setTransparency(getResultTransparency(theResult)) | aCustomized;
-  }
-  ModuleBase_IModule* aModule = myWorkshop->module();
-  aCustomized = aModule->customisePresentation(theResult, thePrs, theCustomPrs) || aCustomized;
-  return aCustomized;
-}
diff --git a/src/XGUI/XGUI_CustomPrs.h b/src/XGUI/XGUI_CustomPrs.h
deleted file mode 100644 (file)
index 62d18d3..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef XGUI_CustomPrs_H
-#define XGUI_CustomPrs_H
-
-#include "XGUI.h"
-#include <GeomAPI_ICustomPrs.h>
-#include <GeomAPI_AISObject.h>
-#include <ModelAPI_Result.h>
-
-class XGUI_Workshop;
-
-/**
-* Interface of a class which can provide specific customization of
-* object presentation
-*/ 
-class XGUI_CustomPrs : public GeomAPI_ICustomPrs
-{
-public:
-  /// Constructor
-  /// \param theWorkshop the current workshop instance
-  XGUI_EXPORT XGUI_CustomPrs(XGUI_Workshop* theWorkshop);
-
-  XGUI_EXPORT virtual ~XGUI_CustomPrs() {};
-
-  /// Modifies the given presentation in the custom way.
-  virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
-                                     std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs);
-
-  /// Returns color of a result object
-  /// \param theResult a result object
-  /// \param theColor a color in form of RGB vector
-  static void getResultColor(const ResultPtr& theResult, std::vector<int>& theColor);
-
-  /// Returns deflection of a result object
-  /// \param theResult a result object
-  /// \return theDeflection a real value
-  static double getResultDeflection(const ResultPtr& theResult);
-
-  /// Returns transparency of a result object
-  /// \param theResult a result object
-  /// \return theTransparency a real value
-  static double getResultTransparency(const ResultPtr& theResult);
-
-  /// Returns the default object color. It obtains colorConfigInfo of the object
-  /// and find it in preferences. If there are no this color in preference and an empty
-  /// color is interpreted as invalid, it shows error message
-  /// \param theObject an investigated object
-  /// \param isEmptyColorValid boolean state about interpretation of empty color
-  /// \param theColor the result color
-  static void XGUI_EXPORT getDefaultColor(ObjectPtr theObject, const bool isEmptyColorValid,
-                                          std::vector<int>& theColor);
-
-  /// Returns the default deflection value. The value is obtained from the application preferences
-  /// \param theObject an investigated object
-  /// \return deflection value
-  static double XGUI_EXPORT getDefaultDeflection(const ObjectPtr& theObject);
-
-protected:
-  XGUI_Workshop* myWorkshop; ///< the current workshop
-};
-
-#endif
index ccad93e0e2325f4d0a776c4c8a9044ebb5b3af85..c96dd3e7c5da6069654347f5919aa02fd7961f97 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "XGUI_Displayer.h"
 
-#include "XGUI_CustomPrs.h"
 #include "XGUI_FacesPanel.h"
 #include "XGUI_Selection.h"
 #include "XGUI_SelectionActivate.h"
@@ -42,7 +41,6 @@
 #include <ModuleBase_BRepOwner.h>
 #include <ModuleBase_IModule.h>
 #include <ModuleBase_Preferences.h>
-#include <ModuleBase_ResultPrs.h>
 #include <ModuleBase_Tools.h>
 #include <ModuleBase_ViewerPrs.h>
 #include <ModuleBase_IViewer.h>
@@ -125,7 +123,6 @@ XGUI_Displayer::XGUI_Displayer(XGUI_Workshop* theWorkshop)
 : myWorkshop(theWorkshop), myNeedUpdate(false),
   myViewerBlockedRecursiveCount(0), myIsFirstAISContextUse(true)
 {
-  myCustomPrs = std::shared_ptr<GeomAPI_ICustomPrs>(new XGUI_CustomPrs(theWorkshop));
 }
 
 //**************************************************************
@@ -157,25 +154,10 @@ bool XGUI_Displayer::display(ObjectPtr theObject, bool theUpdateViewer)
       }
       anAIS = aPrs->getAISObject(anAIS);
     } else {
-      Handle(AIS_InteractiveObject) anAISPrs =
-        myWorkshop->module()->createPresentation(theObject);
-      if (anAISPrs.IsNull()) {
-        ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
-        if (aResult.get() != NULL) {
-          std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
-          if (aShapePtr.get() != NULL) {
-             anAISPrs = new ModuleBase_ResultPrs(aResult);
-          }
-        }
-      }
-      Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(anAISPrs);
-      if (!aShapePrs.IsNull())
-        ModuleBase_Tools::setPointBallHighlighting((AIS_Shape*)aShapePrs.get());
-      anAIS = AISObjectPtr(new GeomAPI_AISObject());
-      anAIS->setImpl(new Handle(AIS_InteractiveObject)(anAISPrs));
+      anAIS = myWorkshop->module()->createPresentation(theObject);
       isShading = true;
     }
-    if (anAIS)
+    if (anAIS.get())
       aDisplayed = display(theObject, anAIS, isShading, theUpdateViewer);
   }
   return aDisplayed;
@@ -215,7 +197,7 @@ bool XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS,
   if (!anAISIO.IsNull()) {
     appendResultObject(theObject, theAIS);
 
-    bool isCustomized = customizeObject(theObject);
+    //bool isCustomized = customizeObject(theObject);
 
     int aDispMode = isShading? Shading : Wireframe;
     if (isShading)
@@ -278,11 +260,15 @@ bool XGUI_Displayer::erase(ObjectPtr theObject, const bool theUpdateViewer)
 bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer)
 {
   bool aRedisplayed = false;
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  if (aContext.IsNull())
+    return aRedisplayed;
+
   if (!isVisible(theObject))
     return aRedisplayed;
 
   AISObjectPtr aAISObj = getAISObject(theObject);
-  Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+  Handle(AIS_InteractiveObject) aAISIO;
 
   GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
   if (aPrs) {
@@ -302,9 +288,11 @@ bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer)
     }
     aAISIO = aAIS_Obj->impl<Handle(AIS_InteractiveObject)>();
   }
+  else {
+    aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+  }
 
-  Handle(AIS_InteractiveContext) aContext = AISContext();
-  if (!aContext.IsNull() && !aAISIO.IsNull()) {
+  if (!aAISIO.IsNull()) {
     // Check that the visualized shape is the same and the redisplay is not necessary
     // Redisplay of AIS object leads to this object selection compute and the selection
     // in the browser is lost
@@ -312,54 +300,56 @@ bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer)
     // before and after the values modification.
     // Moreother, this check avoids customize and redisplay presentation if the presentable
     // parameter is changed.
-    bool isEqualShapes = false;
-    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()) {
-        std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
-        if (aShapePtr.get()) {
-          const TopoDS_Shape& aOldShape = aShapePrs->Shape();
-          if (!aOldShape.IsNull())
-            isEqualShapes = aOldShape.IsEqual(aShapePtr->impl<TopoDS_Shape>());
-        }
-      }
-    }
+    //bool isEqualShapes = false;
+    //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()) {
+    //    std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
+    //    if (aShapePtr.get()) {
+    //      const TopoDS_Shape& aOldShape = aShapePrs->Shape();
+    //      if (!aOldShape.IsNull())
+    //        isEqualShapes = aOldShape.IsEqual(aShapePtr->impl<TopoDS_Shape>());
+    //    }
+    //  }
+    //}
     // Customization of presentation
-    bool isCustomized = customizeObject(theObject);
+    //bool isCustomized = customizeObject(theObject);
     #ifdef DEBUG_FEATURE_REDISPLAY
-      qDebug(QString("Redisplay: %1, isEqualShapes=%2, isCustomized=%3").
-        arg(!isEqualShapes || isCustomized).arg(isEqualShapes)
-        .arg(isCustomized).toStdString().c_str());
+      qDebug(QString("Redisplay: %1, isEqualShapes=%2").
+        arg(!isEqualShapes/* || isCustomized*/).arg(isEqualShapes)
+        .toStdString().c_str());
     #endif
-    if (!isEqualShapes || isCustomized) {
-      /// if shapes are equal and presentation are customized, selection should be restored
-      bool aNeedToRestoreSelection = isEqualShapes && isCustomized;
-      if (aNeedToRestoreSelection)
-        myWorkshop->module()->storeSelection();
+    //if (!isEqualShapes/* || isCustomized*/) {
+    //  /// if shapes are equal and presentation are customized, selection should be restored
+    //  bool aNeedToRestoreSelection = isEqualShapes/* && isCustomized*/;
+    //  if (aNeedToRestoreSelection)
+      if (aAISObj.get() && myWorkshop->facesPanel())
+        myWorkshop->facesPanel()->customizeObject(theObject, aAISObj);
+
+    myWorkshop->module()->storeSelection();
 
 #ifdef CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
-      myWorkshop->selector()->deselectPresentation(aAISIO);
+    myWorkshop->selector()->deselectPresentation(aAISIO);
 #endif
-      if (aContext->IsDisplayed(aAISIO))
-        aContext->Redisplay(aAISIO, false);
-      else
-        aContext->Display(aAISIO, false);
-
+    if (aContext->IsDisplayed(aAISIO))
+      aContext->Redisplay(aAISIO, false);
+    else {
+      aContext->Display(aAISIO, false);
+    }
       #ifdef TINSPECTOR
       if (getCallBack()) getCallBack()->Redisplay(aAISIO);
       #endif
 
-      if (aNeedToRestoreSelection)
-        myWorkshop->module()->restoreSelection();
+      //if (aNeedToRestoreSelection)
+    myWorkshop->module()->restoreSelection();
 
-      aRedisplayed = true;
-      #ifdef DEBUG_FEATURE_REDISPLAY
-        qDebug("  Redisplay happens");
-      #endif
-      if (theUpdateViewer)
-        updateViewer();
-    }
+    aRedisplayed = true;
+    #ifdef DEBUG_FEATURE_REDISPLAY
+      qDebug("  Redisplay happens");
+    #endif
+    if (theUpdateViewer)
+      updateViewer();
   }
   return aRedisplayed;
 }
@@ -886,37 +876,37 @@ bool XGUI_Displayer::canBeShaded(ObjectPtr theObject) const
 }
 
 //**************************************************************
-bool 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);
-
-  // Customization of presentation
-  GeomCustomPrsPtr aCustomPrs;
-  FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
-  if (aFeature.get() != NULL) {
-    GeomCustomPrsPtr aCustPrs = std::dynamic_pointer_cast<GeomAPI_ICustomPrs>(aFeature);
-    if (aCustPrs.get() != NULL)
-      aCustomPrs = aCustPrs;
-  }
-  if (aCustomPrs.get() == NULL) {
-    GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
-    // we ignore presentable not customized objects
-    if (aPrs.get() == NULL)
-      aCustomPrs = myCustomPrs;
-  }
-  bool isCustomized = aCustomPrs.get() &&
-                      aCustomPrs->customisePresentation(aResult, anAISObj, myCustomPrs);
-  isCustomized = myWorkshop->module()->afterCustomisePresentation(aResult, anAISObj, myCustomPrs)
-                 || isCustomized;
-
-  // update presentation state if faces panel is active
-  if (anAISObj.get() && myWorkshop->facesPanel())
-    isCustomized = myWorkshop->facesPanel()->customizeObject(theObject, anAISObj) || isCustomized;
-
-  return isCustomized;
-}
+//bool 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);
+//
+//  // Customization of presentation
+//  GeomCustomPrsPtr aCustomPrs;
+//  FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+//  if (aFeature.get() != NULL) {
+//    GeomCustomPrsPtr aCustPrs = std::dynamic_pointer_cast<GeomAPI_ICustomPrs>(aFeature);
+//    if (aCustPrs.get() != NULL)
+//      aCustomPrs = aCustPrs;
+//  }
+//  if (aCustomPrs.get() == NULL) {
+//    GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
+//    // we ignore presentable not customized objects
+//    if (aPrs.get() == NULL)
+//      aCustomPrs = myCustomPrs;
+//  }
+//  bool isCustomized = aCustomPrs.get() &&
+//                      aCustomPrs->customisePresentation(aResult, anAISObj, myCustomPrs);
+//  isCustomized = myWorkshop->module()->afterCustomisePresentation(aResult, anAISObj, myCustomPrs)
+//                 || isCustomized;
+//
+//  // update presentation state if faces panel is active
+//  if (anAISObj.get() && myWorkshop->facesPanel())
+//    isCustomized = myWorkshop->facesPanel()->customizeObject(theObject, anAISObj) || isCustomized;
+//
+//  return isCustomized;
+//}
 
 //**************************************************************
 QColor XGUI_Displayer::setObjectColor(ObjectPtr theObject,
index 45ea2eecbc7ba1f6dcafc3a6055b9537f84bca61..b9d13642c220e6f43cca2977a50516589df4164b 100644 (file)
@@ -23,7 +23,6 @@
 #include "XGUI.h"
 
 #include <GeomAPI_AISObject.h>
-#include <GeomAPI_ICustomPrs.h>
 #include <GeomAPI_Pln.h>
 
 #include <ModelAPI_Result.h>
@@ -453,10 +452,6 @@ private:
 #endif
   Handle(SelectMgr_AndFilter) myAndFilter; ///< A container for selection filters
 
-  /// A default custom presentation, which is used if the displayed feature is not
-  /// a custom presentation
-  GeomCustomPrsPtr myCustomPrs;
-
   /// Definition of a type of map which defines correspondance between objects and presentations
 #ifdef OPTIMIZE_PRS
   XGUI_TwoSidePresentationMap myResult2AISObjectMap; ///< A map of displayed objects
index df92b7e2add92a68463f4aefda658b1302265697..75543ff5c9d92d572f1c6357e80a01c3429c264e 100644 (file)
@@ -31,6 +31,7 @@
 #include <ModuleBase_ITreeNode.h>
 
 #include <XGUI_Workshop.h>
+#include <XGUI_Displayer.h>
 
 #include <QLayout>
 #include <QLineEdit>
@@ -227,6 +228,8 @@ void XGUI_DataTree::processHistoryChange(const QModelIndex& theIndex)
     update(aModel->index(i, 1, aParent));
     update(aModel->index(i, 2, aParent));
   }
+  XGUI_ObjectsBrowser* aObjBrowser = qobject_cast<XGUI_ObjectsBrowser*>(parent());
+  aObjBrowser->workshop()->displayer()->updateViewer();
 }
 
 void XGUI_DataTree::processEyeClick(const QModelIndex& theIndex)
index 2c6787a1972f3032076019be00cc33d7fca060c8..ed0e8c950e5c61ccc5d6b7a9b6486d73aa579719 100644 (file)
@@ -45,7 +45,6 @@
 #include "XGUI_Tools.h"
 #include "XGUI_ViewerProxy.h"
 #include "XGUI_WorkshopListener.h"
-#include <XGUI_CustomPrs.h>
 #include <XGUI_HistoryMenu.h>
 #include <XGUI_QtEvents.h>
 #include <XGUI_DataModel.h>
@@ -279,22 +278,6 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
   connect(myEventsListener, SIGNAL(errorOccurred(std::shared_ptr<Events_InfoMessage>)),
           myErrorDlg, SLOT(addError(std::shared_ptr<Events_InfoMessage>)));
 
-  //Config_PropManager::registerProp("Visualization", "object_default_color", "Object color",
-  //                                 Config_Prop::Color, "225,225,225");
-
-  Config_PropManager::registerProp("Visualization", "result_body_color", "Result color",
-                                   Config_Prop::Color, ModelAPI_ResultBody::DEFAULT_COLOR());
-  Config_PropManager::registerProp("Visualization", "result_group_color", "Group color",
-                                   Config_Prop::Color, ModelAPI_ResultGroup::DEFAULT_COLOR());
-  Config_PropManager::registerProp("Visualization", "result_construction_color",
-                                   "Construction color",
-                                   Config_Prop::Color,
-                                   ModelAPI_ResultConstruction::DEFAULT_COLOR());
-  Config_PropManager::registerProp("Visualization", "result_part_color", "Part color",
-                                   Config_Prop::Color, ModelAPI_ResultPart::DEFAULT_COLOR());
-  Config_PropManager::registerProp("Visualization", "result_field_color", "Field color",
-                                   Config_Prop::Color, ModelAPI_ResultField::DEFAULT_COLOR());
-
   if (ModuleBase_Preferences::resourceMgr()->booleanValue("Viewer", "face-selection", true))
     myViewerSelMode.append(TopAbs_FACE);
   if (ModuleBase_Preferences::resourceMgr()->booleanValue("Viewer", "edge-selection", true))
@@ -2299,7 +2282,7 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects)
   foreach(ObjectPtr anObject, theObjects) {
     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
     if (aResult.get()) {
-      XGUI_CustomPrs::getResultColor(aResult, aColor);
+      ModelAPI_Tools::getColor(aResult, aColor);
     }
     else {
       // TODO: remove the obtaining a color from the AIS object
@@ -2412,7 +2395,7 @@ void XGUI_Workshop::changeDeflection(const QObjectPtrList& theObjects)
   foreach(ObjectPtr anObject, theObjects) {
     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
     if (aResult.get()) {
-      aDeflection = XGUI_CustomPrs::getResultDeflection(aResult);
+      aDeflection = ModelAPI_Tools::getDeflection(aResult);
     }
     else {
       // TODO: remove the obtaining a property from the AIS object
@@ -2475,7 +2458,7 @@ void XGUI_Workshop::changeTransparency(const QObjectPtrList& theObjects)
   foreach(ObjectPtr anObject, theObjects) {
     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
     if (aResult.get()) {
-      aCurrentValue = XGUI_CustomPrs::getResultTransparency(aResult);
+      aCurrentValue = ModelAPI_Tools::getTransparency(aResult);
     }
     if (aCurrentValue > 0)
       break;
index e420a5aec4814eb9666bf2eb4eb07e7780967bf5..6ec62aba90d20ed11338b7a168406cf857fea6d3 100644 (file)
@@ -103,6 +103,7 @@ void XGUI_WorkshopListener::initializeEventListening()
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_VISUAL_ATTRIBUTES));
   aLoop->registerListener(this, Events_LongOp::eventID());
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_PLUGIN_LOADED));
 
@@ -149,8 +150,32 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr<Events_Message>&
   // Redisplay feature
   else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {
     std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
-        std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
+      std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
     onFeatureRedisplayMsg(aUpdMsg);
+  }
+  else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_VISUAL_ATTRIBUTES)) {
+    std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
+      std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
+    std::set<ObjectPtr> aObjList = aUpdMsg->objects();
+    std::set<ObjectPtr>::const_iterator aIt;
+    std::list<ResultPtr>::const_iterator aResIt;
+    XGUI_Displayer* aDisplayer = workshop()->displayer();
+    AISObjectPtr aAIS;
+    for (aIt = aObjList.begin(); aIt != aObjList.end(); ++aIt) {
+      FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*aIt);
+      if (aFeature) {
+        aAIS = aDisplayer->getAISObject(aFeature);
+        if (aAIS.get())
+          workshop()->module()->customizePresentation(aFeature, aAIS);
+
+        std::list<ResultPtr> aResults = aFeature->results();
+        for (aResIt = aResults.begin(); aResIt != aResults.end(); ++aResIt) {
+          aAIS = aDisplayer->getAISObject(*aResIt);
+          if (aAIS.get())
+            workshop()->module()->customizePresentation(*aResIt, aAIS);
+        }
+      }
+    }
   } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION)) {
     std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
         std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
@@ -354,7 +379,7 @@ void XGUI_WorkshopListener::
   //if (aHiddenObjects.size() > 0)
   //  myWorkshop->module()->processHiddenObject(aHiddenObjects);
 
-  bool isCustomized = customizeCurrentObject(anObjects, aRedisplayed);
+  bool isCustomized = customizeFeature(anObjects, aRedisplayed);
   if (aRedisplayed || isCustomized) {
     Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION));
 
@@ -423,7 +448,7 @@ void XGUI_WorkshopListener::
     }
   }
 
-  bool isCustomized = customizeCurrentObject(anObjects, aDisplayed);
+  bool isCustomized = customizeFeature(anObjects, aDisplayed);
 
   //if (myObjectBrowser)
   //  myObjectBrowser->processEvent(theMsg);
@@ -501,7 +526,7 @@ bool XGUI_WorkshopListener::displayObject(ObjectPtr theObj)
   return aDisplayer->display(theObj, false);
 }
 
-bool XGUI_WorkshopListener::customizeCurrentObject(const std::set<ObjectPtr>& theObjects,
+bool XGUI_WorkshopListener::customizeFeature(const std::set<ObjectPtr>& theObjects,
                                                    bool theForceRedisplay)
 {
   XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
@@ -521,11 +546,11 @@ bool XGUI_WorkshopListener::customizeCurrentObject(const std::set<ObjectPtr>& th
     // the feature is hidden, but arguments of the feature are modified
     // e.g. extrusion is hidden(h=0) but sketch is chosen
     if (theForceRedisplay || theObjects.find(aCurrentFeature) != theObjects.end()) {
-      aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
+      aCustomized = myWorkshop->module()->customizeFeature(aCurrentFeature,
                                  ModuleBase_IModule::CustomizeArguments, false) || aCustomized;
-      aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
+      aCustomized = myWorkshop->module()->customizeFeature(aCurrentFeature,
                                    ModuleBase_IModule::CustomizeResults, false) || aCustomized;
-      aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
+      aCustomized = myWorkshop->module()->customizeFeature(aCurrentFeature,
                         ModuleBase_IModule::CustomizeHighlightedObjects, false) || aCustomized;
     }
   }
index f6ab5a6ef8f312622b9c918756cb2551cf59aa32..e2d548c461b34c71b38f90d7d37cd05044f7dc11 100644 (file)
@@ -97,7 +97,7 @@ protected:
   ///                   if forced redisplay is false
   /// \param theForceRedisplay a flag to customize object even always
   /// \return true if the object is modified
-  bool customizeCurrentObject(const std::set<ObjectPtr>& theObjects, bool theForceRedisplay);
+  bool customizeFeature(const std::set<ObjectPtr>& theObjects, bool theForceRedisplay);
 
   /// Returns the workshop
   XGUI_Workshop* workshop() const;