Salome HOME
Issue #591 - Highlight of the first argument of constraints
authornds <natalia.donis@opencascade.com>
Fri, 3 Jul 2015 05:47:16 +0000 (08:47 +0300)
committernds <natalia.donis@opencascade.com>
Fri, 3 Jul 2015 05:47:42 +0000 (08:47 +0300)
14 files changed:
src/GeomAPI/GeomAPI_AISObject.cpp
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Operation.h
src/PartSet/PartSet_CustomPrs.cpp
src/PartSet/PartSet_CustomPrs.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationPrs.cpp
src/PartSet/PartSet_OperationPrs.h
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Tools.h
src/PartSet/PartSet_WidgetShapeSelector.cpp
src/XGUI/XGUI_Displayer.cpp

index 2365746655bf4d095c096c00aae855a4a703e0ad..fc34c50ae49953337cbd8279ae2a070a8b2eb488 100644 (file)
@@ -272,7 +272,6 @@ void GeomAPI_AISObject::setColor(const int& theColor)
   if (anAIS.IsNull())
     return;
   Quantity_Color aColor((Quantity_NameOfColor) theColor);
-  anAIS->SetColor(aColor);
   Handle(AIS_Dimension) aDimAIS = Handle(AIS_Dimension)::DownCast(anAIS);
   if (!aDimAIS.IsNull()) {
     aDimAIS->DimensionAspect()->SetCommonColor(aColor);
@@ -305,7 +304,6 @@ bool GeomAPI_AISObject::setColor(int theR, int theG, int theB)
   if (aColor.IsEqual(aCurrentColor))
     return false;
 
-  anAIS->SetColor(aColor);
   Handle(AIS_Dimension) aDimAIS = Handle(AIS_Dimension)::DownCast(anAIS);
   if (!aDimAIS.IsNull()) {
     aDimAIS->DimensionAspect()->SetCommonColor(aColor);
index 7484ff28dd7e5798e57643126dd19de9eaffc644..58891e564d2bb1c9bec7a299fcdf7b7c3b2c1c52 100644 (file)
@@ -136,6 +136,7 @@ bool ModuleBase_Operation::hasObject(ObjectPtr theObj) const
 
 void ModuleBase_Operation::start()
 {
+  myIsModified = false;
   QString anId = getDescription()->operationId();
   if (myIsEditing) {
     anId = anId.append(EditSuffix());
@@ -255,6 +256,11 @@ void ModuleBase_Operation::setRunning(bool theState)
   emit triggered(theState);
 }
 
+void ModuleBase_Operation::onValuesChanged()
+{
+  myIsModified = true;
+}
+
 //TODO: nds stabilization hotfix
 void ModuleBase_Operation::commitOperation()
 {
@@ -375,6 +381,15 @@ void ModuleBase_Operation::setPropertyPanel(ModuleBase_IPropertyPanel* theProp)
   myPropertyPanel = theProp; 
   myPropertyPanel->setEditingMode(isEditOperation());
 
+  if (myPropertyPanel) {
+    const QList<ModuleBase_ModelWidget*>& aWidgets = myPropertyPanel->modelWidgets();
+    QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
+    for (aWIt = aWidgets.constBegin(); aWIt != aWidgets.constEnd(); ++aWIt) {
+      ModuleBase_ModelWidget* aWgt = (*aWIt);
+      connect(aWgt, SIGNAL(valuesChanged()), this, SLOT(onValuesChanged()));
+    }
+  }
+
   // Do not activate widgets by default if the current operation is editing operation
   // Because we don't know which widget is going to be edited. 
   if (!isEditOperation())
index c20391185f3ca203baf9b33025696a415dcabcef..9d304e715b2fedd09c42c2d6edeb7eeb63063289 100644 (file)
@@ -76,6 +76,9 @@ Q_OBJECT
   /// Returns True if data of its feature was modified during operation
   virtual bool isModified() const { return myIsModified; }
 
+  /// Change the modified state of the operation
+  void setIsModified(const bool theIsModified) { myIsModified = theIsModified;  }
+
   /// Returns True id the current operation is launched in editing mode
   bool isEditOperation() const { return myIsEditing; }
 
@@ -191,6 +194,9 @@ signals:
   /// \param theState th flag to abort, if it is true, do nothing, overwise abort
   void setRunning(bool theState);
 
+  /// Changes the modified flag of the operation
+  void onValuesChanged();
+
  protected:
   /// Virtual method called when operation started (see start() method for more description)
   /// Default impl calls corresponding slot and commits immediately.
index 2990969e94f9d4c6355deb77b5b44c6aadcc44b1..a90b634ac4b71ed3399f5c8d5903dc9e2f4fdb80 100755 (executable)
@@ -5,6 +5,8 @@
 // Author:      Natalia ERMOLAEVA
 
 #include <PartSet_CustomPrs.h>
+#include <PartSet_Module.h>
+#include "PartSet_OperationPrs.h"
 
 #include <XGUI_ModuleConnector.h>
 #include <XGUI_Workshop.h>
 #include <Config_PropManager.h>
 
 #include <AIS_InteractiveContext.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <Prs3d_PointAspect.hxx>
 
 #define OPERATION_PARAMETER_COLOR "255, 255, 0"
 
 PartSet_CustomPrs::PartSet_CustomPrs(ModuleBase_IWorkshop* theWorkshop)
   : myWorkshop(theWorkshop)
 {
-  Handle(PartSet_OperationPrs) myOperationPrs = new PartSet_OperationPrs(); /// AIS presentation for the feature of operation
+  myOperationPrs = AISObjectPtr(new GeomAPI_AISObject());
+  myOperationPrs->setImpl(new Handle(AIS_InteractiveObject)(new PartSet_OperationPrs(theWorkshop)));
+
+  std::vector<int> aColor = Config_PropManager::color("Visualization", "operation_parameter_color",
+                                                      OPERATION_PARAMETER_COLOR);
+  myOperationPrs->setColor(aColor[0], aColor[1], aColor[2]);
+
+  myOperationPrs->setPointMarker(5, 2.);
+  myOperationPrs->setWidth(1);
 }
 
-void PartSet_CustomPrs::setCustomized(const FeaturePtr& theFeature)
+bool PartSet_CustomPrs::isActive() const
 {
+  Handle(PartSet_OperationPrs) anOperationPrs = getPresentation();
+  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+
+  return aContext->IsDisplayed(anOperationPrs);
+}
 
-  myOperationPrs->setFeature(theFeature);
-  /*  QMap<ResultPtr, QList<GeomShapePtr> > aNewCustomized;
+void PartSet_CustomPrs::activate(const FeaturePtr& theFeature)
+{
+  Handle(PartSet_OperationPrs) anOperationPrs = getPresentation();
 
-  QList<GeomShapePtr> aShapeList;
-  ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
-  if (aResult.get()) {
-    aNewCustomized[aResult] = aShapeList;
-  }
-  else {
-    FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
-    if (aFeature.get()) {
-      std::list<AttributePtr> anAttributes = aFeature->data()->attributes("");
-      std::list<AttributePtr>::const_iterator anIt = anAttributes.begin(), aLast = anAttributes.end();
-      for (; anIt != aLast; anIt++) {
-        AttributePtr anAttribute = *anIt;
-        ObjectPtr anObject = GeomValidators_Tools::getObject(anAttribute);
-        if (anObject.get()) {
-          ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
-          if (aResult.get())
-            aNewCustomized[aResult] = aShapeList;
-        }
-        else if (anAttribute->attributeType() == ModelAPI_AttributeSelectionList::typeId()) {
-          std::shared_ptr<ModelAPI_AttributeSelectionList> aCurSelList = 
-                  std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(anAttribute);
-          for(int i = 0; i < aCurSelList->size(); i++) {
-            std::shared_ptr<ModelAPI_AttributeSelection> aSelAttribute = aCurSelList->value(i);
-            ObjectPtr anObject = GeomValidators_Tools::getObject(aSelAttribute);
-            if (anObject.get()) {
-              ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
-              if (aResult.get())
-                aNewCustomized[aResult] = aShapeList;
-            }
-          }
-        }
-      }
-    }
+  if (anOperationPrs->canActivate(theFeature)) {
+    anOperationPrs->setFeature(theFeature);
+    if (theFeature.get())
+      displayPresentation();
   }
+}
+
+void PartSet_CustomPrs::deactivate()
+{
+  Handle(PartSet_OperationPrs) anOperationPrs = getPresentation();
+  anOperationPrs->setFeature(FeaturePtr());
+
+  erasePresentation();
+}
+
+
+void PartSet_CustomPrs::displayPresentation()
+{
+  Handle(PartSet_OperationPrs) anOperationPrs = getPresentation();
 
-  bool isDone = false;
-  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
-  XGUI_Workshop* aWorkshop = aConnector->workshop();
-  XGUI_Displayer* aDisplayer = aWorkshop->displayer();
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
-  // find objects which are not customized anymore
-  QMap<ResultPtr, QList<GeomShapePtr> > aNotCustomized;
-  QMap<ResultPtr, QList<GeomShapePtr> >::const_iterator anIt = myCustomized.begin(),
-                                                        aLast = myCustomized.end();
-  for (; anIt != aLast; anIt++) {
-    ResultPtr aResult = anIt.key();
-    if (!aNewCustomized.contains(aResult))
-      aNotCustomized[aResult] = aShapeList;
+  if (!aContext->IsDisplayed(anOperationPrs)) {
+    PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+    aContext->Display(anOperationPrs);
+    aContext->SetZLayer(anOperationPrs, aModule->getVisualLayerId());
   }
+  else
+    anOperationPrs->Redisplay();
+}
 
-  myCustomized.clear();
-  // restore the previous state of the object if there is no such object in the new map
-  for (anIt = aNotCustomized.begin(), aLast = aNotCustomized.end(); anIt != aLast; anIt++) {
-    ResultPtr aResult = anIt.key();
-    AISObjectPtr anAISObj = aDisplayer->getAISObject(aResult);
-    if (anAISObj.get()) {
-      Handle(AIS_InteractiveObject) anAISIO = anAISObj->impl<Handle(AIS_InteractiveObject)>();
-      aContext->Redisplay(anAISIO, false);
-    }
-    isDone = aDisplayer->customizeObject(aResult);
-  }
+void PartSet_CustomPrs::erasePresentation()
+{
+  Handle(AIS_InteractiveObject) anOperationPrs = myOperationPrs->impl<Handle(AIS_InteractiveObject)>();
+  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+  if (aContext->IsDisplayed(anOperationPrs))
+    aContext->Remove(anOperationPrs);
+}
+
+Handle(PartSet_OperationPrs) PartSet_CustomPrs::getPresentation() const
+{
+  Handle(AIS_InteractiveObject) anAISIO = myOperationPrs->impl<Handle(AIS_InteractiveObject)>();
+  return Handle(PartSet_OperationPrs)::DownCast(anAISIO);
+}
+
+bool PartSet_CustomPrs::customize(const ObjectPtr& theObject)
+{
+  // the presentation should be recomputed if the previous AIS depend on the result
+  // [it should be hiddend] or the new AIS depend on it [it should be visualized]
+  Handle(PartSet_OperationPrs) anOperationPrs = getPresentation();
+  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+  if (aContext->IsDisplayed(anOperationPrs)) {
+    bool aChanged = anOperationPrs->dependOn(theObject);
 
-  // set customized for the new objects
-  myCustomized = aNewCustomized;
-  for (anIt = myCustomized.begin(), aLast = myCustomized.end(); anIt != aLast; anIt++) {
-    ResultPtr aResult = anIt.key();
-    AISObjectPtr anAISObj = aDisplayer->getAISObject(aResult);
-    if (anAISObj.get())
-      isDone = customisePresentation(aResult, anAISObj, 0) || isDone;
+    anOperationPrs->updateShapes();
+    aChanged = aChanged || anOperationPrs->dependOn(theObject);
+
+    //if (aChanged)
+    anOperationPrs->Redisplay();
   }
-  if (isDone)
-    aDisplayer->updateViewer();*/
+  return false;
 }
 
-/*#include <AIS_InteractiveObject.hxx>
-#include <AIS_Shape.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <StdPrs_ShadedShape.hxx>
-#include <StdPrs_WFDeflectionShape.hxx>*/
 bool PartSet_CustomPrs::customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
                                               std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs)
 {
-  bool isDone = false;
-  /*if (myCustomized.contains(theResult)) {
-    std::vector<int> aColor = Config_PropManager::color("Visualization", "operation_parameter_color",
-                                                        OPERATION_PARAMETER_COLOR);
-    isDone = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
-    /*
-    Handle(AIS_InteractiveObject) anAISIO = thePrs->impl<Handle(AIS_InteractiveObject)>();
-
-    const Handle(Prs3d_Presentation)& aPresentation = anAISIO->Presentation();
-    if (!aPresentation.IsNull()) {
-      Handle(AIS_Shape) aShapeAIS = Handle(AIS_Shape)::DownCast(anAISIO);
-      if (!aShapeAIS.IsNull()) {
-        TopExp_Explorer anExp(aShapeAIS->Shape(), TopAbs_VERTEX);
-        Handle(Prs3d_Drawer) aDrawer = aShapeAIS->Attributes();
-        for (; anExp.More(); anExp.Next()) {
-          const TopoDS_Vertex& aVertex = (const TopoDS_Vertex&)anExp.Current();
-          StdPrs_WFDeflectionShape::Add(aPresentation, aVertex, aDrawer);
-        }
-      }
-    }
-    thePrs->setPointMarker(5, 5.); // Set point as a '+' symbol*+/
-  }
-  /*
-  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();
-  }
-  return !aColor.empty() && thePrs->setColor(aColor[0], aColor[1], aColor[2]);*/
-  return isDone;
+  return false;
 }
index 6d23847da06499aba618bd1afad6c66e11d87b61..6a34fbb2af4d94d0307c453adc32fa63fd8da240 100755 (executable)
@@ -8,6 +8,7 @@
 #define PartSet_CustomPrs_H
 
 #include "PartSet.h"
+
 #include "PartSet_OperationPrs.h"
 
 #include <ModelAPI_Object.h>
@@ -18,9 +19,6 @@
 #include <GeomAPI_AISObject.h>
 #include <GeomAPI_Shape.h>
 
-#include <QMap>
-#include <QList>
-
 class ModuleBase_IWorkshop;
 
 /**
@@ -33,17 +31,34 @@ public:
   PARTSET_EXPORT PartSet_CustomPrs(ModuleBase_IWorkshop* theWorkshop);
   PARTSET_EXPORT virtual ~PartSet_CustomPrs() {};
 
-  /// Set the feature is customized
-  /// \param theObject a feature object
-  void setCustomized(const FeaturePtr& theObject);
+  /// Returns true if the presentation is active
+  bool isActive() const;
+
+  /// Initializes the presentation by the parameter object
+  void activate(const FeaturePtr& theObject);
+
+  void deactivate();
+
+  /// Modifies the given presentation in the custom way.
+  bool customize(const ObjectPtr& theObject);
 
   /// Modifies the given presentation in the custom way.
   virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
                                      std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs);
+private:
+  /// Returns the AIS presentation
+  Handle(PartSet_OperationPrs) getPresentation() const;
+
+  /// Displays the internal presentation in the viewer of workshop
+  void displayPresentation();
+  /// Erases the internal presentation from the viewer of workshop
+  void erasePresentation();
+  /// Sets color, point size and width of the presentation
+  void customizePresentation();
+
 private:
   ModuleBase_IWorkshop* myWorkshop; /// current workshop
-  Handle(PartSet_OperationPrs) myOperationPrs; /// AIS presentation for the feature of operation
-  //QMap<ResultPtr, QList<GeomShapePtr> > myCustomized; /// objects, which are customized
+  AISObjectPtr myOperationPrs; /// the AIS presentation, which is displayed/erased in the viewer
 };
 
 #endif
index cc9afc0d8ca1ae5e90cf096f0b1ad4d887c85eb5..e997f05cf97a1c967fb30473753308a9ae390008 100644 (file)
@@ -267,27 +267,37 @@ void PartSet_Module::onOperationAborted(ModuleBase_Operation* theOperation)
 
 void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
 {
+  // z layer is created for all started operations in order to visualize operation AIS presentation
+  // over the object
+  Handle(V3d_Viewer) aViewer = myWorkshop->viewer()->AISContext()->CurrentViewer();
+  aViewer->AddZLayer(myVisualLayerId);
+
   if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
-    Handle(V3d_Viewer) aViewer = myWorkshop->viewer()->AISContext()->CurrentViewer();
-    aViewer->AddZLayer(myVisualLayerId);
     mySketchMgr->startSketch(theOperation);
   }
   else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
     mySketchMgr->startNestedSketch(theOperation);
   }
+
+  std::shared_ptr<PartSet_CustomPrs> aCustomPrs =
+                        std::dynamic_pointer_cast<PartSet_CustomPrs>(myCustomPrs);
+  aCustomPrs->activate(theOperation->feature());
 }
 
 void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
 {
   if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
     mySketchMgr->stopSketch(theOperation);
-    Handle(V3d_Viewer) aViewer = myWorkshop->viewer()->AISContext()->CurrentViewer();
-    aViewer->RemoveZLayer(myVisualLayerId);
-    myVisualLayerId = 0;
   }
   else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
     mySketchMgr->stopNestedSketch(theOperation);
   }
+  Handle(V3d_Viewer) aViewer = myWorkshop->viewer()->AISContext()->CurrentViewer();
+  aViewer->RemoveZLayer(myVisualLayerId);
+  myVisualLayerId = 0;
+  std::shared_ptr<PartSet_CustomPrs> aCustomPrs =
+                        std::dynamic_pointer_cast<PartSet_CustomPrs>(myCustomPrs);
+  aCustomPrs->deactivate();
 }
 
 ModuleBase_Operation* PartSet_Module::currentOperation() const
@@ -720,24 +730,14 @@ void PartSet_Module::onViewTransformed(int theTrsfType)
     aDisplayer->updateViewer();
 }
 
-void PartSet_Module::setCustomized(const FeaturePtr& theFeature)
-{
- std::shared_ptr<PartSet_CustomPrs> aCustomPrs =
-                        std::dynamic_pointer_cast<PartSet_CustomPrs>(myCustomPrs);
- if (aCustomPrs.get())
-   aCustomPrs->setCustomized(theFeature);
-}
-
 bool PartSet_Module::customizeObject(ObjectPtr theObject)
 {
- ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
-
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
- XGUI_Workshop* aWorkshop = aConnector->workshop();
- XGUI_Displayer* aDisplayer = aWorkshop->displayer();
-
- AISObjectPtr anAISObj = aDisplayer->getAISObject(aResult);
- return myCustomPrs->customisePresentation(aResult, anAISObj, myCustomPrs);
+  std::shared_ptr<PartSet_CustomPrs> aCustomPrs =
+                          std::dynamic_pointer_cast<PartSet_CustomPrs>(myCustomPrs);
+  bool isCustomized = false;
+  if (aCustomPrs->isActive())
+    isCustomized = aCustomPrs->customize(theObject);
+  return isCustomized;
 }
 
 void PartSet_Module::customizeObjectBrowser(QWidget* theObjectBrowser)
index ee0595b132bb9708b9b73abeefb5d555ea752f2b..f946512a52baa89365b7b5d5a7bac916339b609b 100644 (file)
@@ -31,6 +31,7 @@
 class ModuleBase_Operation;
 class ModuleBase_IViewWindow;
 class PartSet_MenuMgr;
+class PartSet_CustomPrs;
 class PartSet_SketcherMgr;
 
 class QAction;
@@ -160,6 +161,9 @@ public:
   /// \param theObjectBrowser a pinter on Object Browser widget
   virtual void customizeObjectBrowser(QWidget* theObjectBrowser);
 
+  /// Returns the viewer Z layer
+  int getVisualLayerId() const { return myVisualLayerId; }
+
 public slots:
   /// SLOT, that is called by no more widget signal emitted by property panel
   /// Set a specific flag to restart the sketcher operation
index 4539ebbd2129e573d619ebb1b3a3dd399373b148..1f9bd11b5d057a1ea217f755a0591c8f3e708c0e 100755 (executable)
 // Author:      Natalia ERMOLAEVA
 
 #include "PartSet_OperationPrs.h"
+#include "PartSet_Tools.h"
 
-//#include <ModelAPI_Tools.h>
-//#include <ModelAPI_ResultConstruction.h>
-//#include <GeomAPI_PlanarEdges.h>
+#include <ModelAPI_Result.h>
+#include <ModelAPI_Attribute.h>
+#include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_AttributeReference.h>
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeSelectionList.h>
+#include <GeomValidators_Tools.h>
 
-//#include <BRep_Builder.hxx>
-//#include <Prs3d_IsoAspect.hxx>
-//#include <TopoDS_Builder.hxx>
+#include <StdPrs_WFDeflectionShape.hxx>
+
+#include <QList>
 
 IMPLEMENT_STANDARD_HANDLE(PartSet_OperationPrs, ViewerData_AISShape);
 IMPLEMENT_STANDARD_RTTIEXT(PartSet_OperationPrs, ViewerData_AISShape);
 
-PartSet_OperationPrs::PartSet_OperationPrs()
-  : ViewerData_AISShape(TopoDS_Shape()), myFeature(FeaturePtr())
+PartSet_OperationPrs::PartSet_OperationPrs(ModuleBase_IWorkshop* theWorkshop)
+  : ViewerData_AISShape(TopoDS_Shape()), myFeature(FeaturePtr()), myWorkshop(theWorkshop)
 {
 }
 
-void PartSet_OperationPrs::setFeature(FeaturePtr theFeature)
+bool PartSet_OperationPrs::canActivate(const FeaturePtr& theFeature)
 {
-/*  std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(theResult);
-  std::shared_ptr<GeomAPI_PlanarEdges> aWirePtr = 
-    std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aShapePtr);
-  if (aWirePtr) {
-    if (aWirePtr->hasPlane() ) {
-      // If this is a wire with plane defined thin it is a sketch-like object
-      // It must have invisible faces
-      myIsSketchMode = true;
-    }
-  }
-  Set(aShapePtr->impl<TopoDS_Shape>());
-*/
+  bool aHasSelectionAttribute = false;
+
+  std::list<AttributePtr> anAttributes = theFeature->data()->attributes("");
+  std::list<AttributePtr>::const_iterator anIt = anAttributes.begin(), aLast = anAttributes.end();
+  for (; anIt != aLast && !aHasSelectionAttribute; anIt++)
+    aHasSelectionAttribute = isSelectionAttribute(*anIt);
+
+  return aHasSelectionAttribute;
 }
 
+void PartSet_OperationPrs::setFeature(const FeaturePtr& theFeature)
+{
+  myFeature = theFeature;
+  updateShapes();
+}
+
+bool PartSet_OperationPrs::dependOn(const ObjectPtr& theResult)
+{
+  return myFeatureShapes.contains(theResult);
+}
+
+void PartSet_OperationPrs::updateShapes()
+{
+  myFeatureShapes.clear();
+  getFeatureShapes(myFeatureShapes);
+}
 
-/*#include <TopExp_Explorer.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <StdPrs_ShadedShape.hxx>
-#include <StdPrs_WFDeflectionShape.hxx>
-*/
 void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
                                    const Handle(Prs3d_Presentation)& thePresentation, 
                                    const Standard_Integer theMode)
 {
-/*  std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(myResult);
-  if (!aShapePtr)
-    return;
-  if (myIsSketchMode) {
-    myFacesList.clear();
-    ResultConstructionPtr aConstruction = 
-      std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(myResult);
-    if (aConstruction.get()) {
-      int aFacesNum = aConstruction->facesNum();
-      for(int aFaceIndex = 0; aFaceIndex < aFacesNum; aFaceIndex++) {
-        myFacesList.push_back(aConstruction->face(aFaceIndex));
-      }
+  thePresentation->Clear();
+
+  // create presentations on the base of the shapes
+  Handle(Prs3d_Drawer) aDrawer = Attributes();
+  QMap<ObjectPtr, QList<GeomShapePtr> >::const_iterator anIt = myFeatureShapes.begin(),
+                                                        aLast = myFeatureShapes.end();
+  for (; anIt != aLast; anIt++) {
+    QList<GeomShapePtr> aShapes = anIt.value();
+    QList<GeomShapePtr>::const_iterator aShIt = aShapes.begin(), aShLast = aShapes.end();
+    for (; aShIt != aShLast; aShIt++) {
+      GeomShapePtr aGeomShape = *aShIt;
+      TopoDS_Shape aShape = aGeomShape->impl<TopoDS_Shape>();
+      StdPrs_WFDeflectionShape::Add(thePresentation, aShape, aDrawer);
     }
   }
-  myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
-  if (!myOriginalShape.IsNull()) {
-    Set(myOriginalShape);
-
-    AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
-    /*
-    TopExp_Explorer anExp(myOriginalShape, TopAbs_VERTEX);
-    Handle(Prs3d_Drawer) aDrawer = Attributes();
-    for (; anExp.More(); anExp.Next()) {
-      const TopoDS_Vertex& aVertex = (const TopoDS_Vertex&)anExp.Current();
-      StdPrs_WFDeflectionShape::Add(thePresentation, aVertex, aDrawer);
-    }*|/
-  }*/
 }
 
-
 void PartSet_OperationPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
                                             const Standard_Integer aMode)
 {
-/*  if (aMode > TopAbs_SHAPE)
-    // In order to avoid using custom selection modes
+  // the presentation is not used in the selection
+}
+
+void addValue(const ObjectPtr& theObject, const GeomShapePtr& theShape,
+              QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes)
+{
+  if (theObjectShapes.contains(theObject))
+    theObjectShapes[theObject].append(theShape);
+  else {
+    QList<GeomShapePtr> aShapes;
+    aShapes.append(theShape);
+    theObjectShapes[theObject] = aShapes;
+  }
+}
+
+void PartSet_OperationPrs::getFeatureShapes(QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes)
+{
+  if (!myFeature.get())
     return;
 
-  if (myIsSketchMode) {
-    if (aMode == TopAbs_FACE) {
-      BRep_Builder aBuilder;
-      TopoDS_Compound aComp;
-      aBuilder.MakeCompound(aComp);
-      aBuilder.Add(aComp, myOriginalShape);
-      std::list<std::shared_ptr<GeomAPI_Shape>>::const_iterator aIt;
-      for (aIt = myFacesList.cbegin(); aIt != myFacesList.cend(); ++aIt) {
-        TopoDS_Shape aFace = (*aIt)->impl<TopoDS_Shape>();
-        aBuilder.Add(aComp, aFace);
+  QList<GeomShapePtr> aShapes;
+  std::list<AttributePtr> anAttributes = myFeature->data()->attributes("");
+  std::list<AttributePtr>::const_iterator anIt = anAttributes.begin(), aLast = anAttributes.end();
+  for (; anIt != aLast; anIt++) {
+    AttributePtr anAttribute = *anIt;
+    if (!isSelectionAttribute(anAttribute))
+      continue;
+
+    std::string anAttrType = anAttribute->attributeType();
+
+    if (anAttrType == ModelAPI_AttributeSelectionList::typeId()) {
+      std::shared_ptr<ModelAPI_AttributeSelectionList> aCurSelList = 
+              std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(anAttribute);
+      for(int i = 0; i < aCurSelList->size(); i++) {
+        std::shared_ptr<ModelAPI_AttributeSelection> aSelAttribute = aCurSelList->value(i);
+        ResultPtr aResult = aSelAttribute->context();
+        GeomShapePtr aShape = aSelAttribute->value();
+        if (!aShape.get())
+          aShape = aResult->shape();
+        addValue(aResult, aShape, theObjectShapes);
+      }
+    }
+    else {
+      ObjectPtr anObject;
+      GeomShapePtr aShape;
+      if (anAttrType == ModelAPI_AttributeRefAttr::typeId()) {
+        AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(anAttribute);
+        if (anAttr->isObject()) {
+          anObject = anAttr->object();
+        }
+        else {
+          aShape = PartSet_Tools::findShapeBy2DPoint(anAttr, myWorkshop);
+          // the distance point is not found if the point is selected in the 2nd time
+          // TODO: after debug, this check can be removed
+          if (!aShape.get())
+            continue;
+          anObject = anAttr->attr()->owner();
+        }
+      }
+      if (anAttrType == ModelAPI_AttributeSelection::typeId()) {
+        AttributeSelectionPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(anAttribute);
+        anObject = anAttr->context();
+        aShape = anAttr->value();
+      }
+      if (anAttrType == ModelAPI_AttributeReference::typeId()) {
+        AttributeReferencePtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(anAttribute);
+        anObject = anAttr->value();
+      }
+
+      if (anObject.get()) {
+        if (!aShape.get()) {
+          ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
+          if (aResult.get())
+            aShape = aResult->shape();
+        }
+        addValue(anObject, aShape, theObjectShapes);
       }
-      Set(aComp);
-    } else {
-      Set(myOriginalShape);
     }
-  }*/
-  AIS_Shape::ComputeSelection(aSelection, aMode);
-}
\ No newline at end of file
+  }
+}
+
+bool PartSet_OperationPrs::isSelectionAttribute(const AttributePtr& theAttribute)
+{
+  std::string anAttrType = theAttribute->attributeType();
+
+  return anAttrType == ModelAPI_AttributeSelectionList::typeId() ||
+         anAttrType == ModelAPI_AttributeRefAttr::typeId() ||
+         anAttrType == ModelAPI_AttributeSelection::typeId() ||
+         anAttrType == ModelAPI_AttributeReference::typeId();
+}
index e1536510127c65221dd6f44e18463570e0608ac0..e296e7b1d9492e0f156ea79d67fb0a32390e3c8d 100755 (executable)
@@ -9,30 +9,50 @@
 
 #include "PartSet.h"
 
-#include <ModelAPI_Result.h>
+#include <ModelAPI_Object.h>
 #include <ModelAPI_Feature.h>
+#include <ModelAPI_Attribute.h>
+
+#include <ModuleBase_IWorkshop.h>
+
+#include <GeomAPI_Shape.h>
 
 #include <ViewerData_AISShape.hxx>
 #include <Standard_DefineHandle.hxx>
 
+#include <QMap>
+#include <QList>
+
 DEFINE_STANDARD_HANDLE(PartSet_OperationPrs, ViewerData_AISShape)
 
 /**
 * \ingroup GUI
-* A redefinition of standard AIS Interactive Object in order to provide specific behaviour 
-* for wire presentations based in a one plane
+* A redefinition of standard AIS Interactive Object in order to provide colored presentation of
+* a list of shapes. It contains a shapes where the parameter feature refers. It processes the following
+* types of attributes: ModelAPI_AttributeSelectionList, ModelAPI_AttributeRefAttr,
+* ModelAPI_AttributeSelection and ModelAPI_AttributeReference.
+* The selection for this presentation is absent.
 */
 class PartSet_OperationPrs : public ViewerData_AISShape
 {
 public:
   /// Constructor
-  /// \param theResult a result object
-  Standard_EXPORT PartSet_OperationPrs();
+  Standard_EXPORT PartSet_OperationPrs(ModuleBase_IWorkshop* theWorkshop);
+
+  /// Returns true if the feature contains attributes, which has references to other features
+  /// \param theFeature a feature
+  /// \return boolean result
+  bool canActivate(const FeaturePtr& theFeature);
 
-  /// set the operation feature. It is used in Compute method to group the feature parameter shapes
+  /// Sets the operation feature. It is used in Compute method to group the feature parameter shapes
   /// theFeature a feature
-  void setFeature(FeaturePtr theFeature);
+  void setFeature(const FeaturePtr& theFeature);
 
+  /// Returns true if the presentation 
+  bool dependOn(const ObjectPtr& theObject);
+
+  // Recompute internal list of shaped dependent on the current feature
+  void updateShapes();
 
   DEFINE_STANDARD_RTTI(PartSet_OperationPrs)
 
@@ -46,8 +66,20 @@ protected:
   Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
                                                 const Standard_Integer aMode) ;
 private:
-  /// Reference to a feature object
-  FeaturePtr myFeature;
+  /// Fills the map by the feature object and shapes, which should be visuaziled
+  /// Gets the feature attribute, collect objects to whom the attribute refers
+  /// \param theObjectShape an output map of objects
+  void getFeatureShapes(QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
+
+  /// Returns true if the attribute type belong to reference attribute
+  /// \param theAttribute an attribute
+  /// \return a boolean value
+  static bool isSelectionAttribute(const AttributePtr& theAttribute);
+
+private:
+  ModuleBase_IWorkshop* myWorkshop;
+  FeaturePtr myFeature; /// Reference to a feature object
+  QMap<ObjectPtr, QList<GeomShapePtr> > myFeatureShapes;
 };
 
 
index e0c1940c944aefe70469436fd39e228aa56184bb..1385c097030fa9f7895880d1167e75811f4ce912 100644 (file)
@@ -290,12 +290,6 @@ void PartSet_SketcherMgr::onAfterValuesChangedInPropertyPanel()
 
 void PartSet_SketcherMgr::onValuesChangedInPropertyPanel()
 {
-  ModuleBase_Operation* anOperation = getCurrentOperation();
-  bool isSketchOp = isSketchOperation(anOperation);
-  bool isNestedSketchOp = isNestedSketchOperation(anOperation);
-  if (isSketchOp || isNestedSketchOp)
-    myModule->setCustomized(anOperation->feature());
-
   if (!isNestedCreateOperation(getCurrentOperation()))
     return;
 
@@ -824,7 +818,6 @@ void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation)
     onShowConstraintsToggle(true);
   }
   connectToPropertyPanel(true);
-  myModule->setCustomized(getCurrentOperation()->feature());
 }
 
 void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOp)
@@ -833,8 +826,6 @@ void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOp)
   myIsResetCurrentValue = false;
   myIsMouseOverViewProcessed = true;
   operationMgr()->onValidateOperation();
-
-  myModule->setCustomized(FeaturePtr());
 }
 
 void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation)
index f5dbff31826de43fb9ec1d77887839a8f57fc89f..843bda304937888fdec9104674ca0f3bd1e7a897 100644 (file)
@@ -5,6 +5,8 @@
 // Author:      Natalia ERMOLAEVA
 
 #include <PartSet_Tools.h>
+#include <PartSet_Module.h>
+#include <PartSet_SketcherMgr.h>
 
 #include <ModelAPI_Data.h>
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_ResultConstruction.h>
 
+#include <XGUI_ModuleConnector.h>
+#include <XGUI_Displayer.h>
+#include <XGUI_Workshop.h>
+#include <XGUI_SelectionMgr.h>
+#include <XGUI_Selection.h>
+
 #include <GeomDataAPI_Point.h>
 #include <GeomDataAPI_Dir.h>
 #include <GeomDataAPI_Point2D.h>
@@ -38,6 +46,7 @@
 #include <SketchPlugin_Line.h>
 #include <SketchPlugin_Point.h>
 
+#include <ModuleBase_IWorkshop.h>
 #include <ModuleBase_ViewerPrs.h>
 
 #include <V3d_View.hxx>
@@ -51,6 +60,9 @@
 #include <TopoDS.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Vertex.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <StdSelect_BRepOwner.hxx>
+#include <SelectMgr_IndexedMapOfOwner.hxx>
 
 #ifdef _DEBUG
 #include <QDebug>
@@ -632,6 +644,63 @@ bool PartSet_Tools::hasVertexShape(const ModuleBase_ViewerPrs& thePrs, FeaturePt
   return aHasVertex;
 }
 
+GeomShapePtr PartSet_Tools::findShapeBy2DPoint(const AttributePtr& theAttribute,
+                                               ModuleBase_IWorkshop* theWorkshop)
+{
+  // 1. find an attribute value in attribute reference attribute value
+  GeomShapePtr aShape;
+  AttributeRefAttrPtr aRefAttr =
+    std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+  if (aRefAttr) {
+    if (!aRefAttr->isObject()) {
+      AttributePtr theAttribute = aRefAttr->attr();
+      if (theAttribute.get()) {
+        XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
+        XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
+
+        // 2. find visualized vertices of the attribute and if the attribute of the vertex is
+        // the same, return it
+        FeaturePtr anAttributeFeature = ModelAPI_Feature::feature(theAttribute->owner());
+        // 2.1 get visualized results of the feature
+        const std::list<ResultPtr>& aResList = anAttributeFeature->results();
+        std::list<ResultPtr>::const_iterator anIt = aResList.begin(), aLast = aResList.end();
+        for (; anIt != aLast; anIt++) {
+          AISObjectPtr aAISObj = aDisplayer->getAISObject(*anIt);
+          if (aAISObj.get() != NULL) {
+            Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+            // 2.2 find selected owners of a visualizedd object
+            SelectMgr_IndexedMapOfOwner aSelectedOwners;
+            aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
+            for (Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++) {
+              Handle(SelectMgr_EntityOwner) anOwner = aSelectedOwners(i);
+              if (!anOwner.IsNull()) {
+                Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast(anOwner);
+                if (!aBRepOwner.IsNull() && aBRepOwner->HasShape()) {
+                  const TopoDS_Shape& aBRepShape = aBRepOwner->Shape();
+                  if (aBRepShape.ShapeType() == TopAbs_VERTEX) {
+                    // 2.3 if the owner is vertex and an attribute of the vertex is equal to the initial
+                    // attribute, returns the shape
+                    PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(theWorkshop->module());
+                    PartSet_SketcherMgr* aSketchMgr = aModule->sketchMgr();
+                    AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(anAttributeFeature,
+                                                             aBRepShape, aSketchMgr->activeSketch());
+                    if (aPntAttr.get() != NULL && aPntAttr == theAttribute) {
+                      aShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape);
+                      aShape->setImpl(new TopoDS_Shape(aBRepShape));
+                      break;
+                    }
+                  }
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+  return aShape;
+}
+
 AttributePtr PartSet_Tools::findAttributeBy2dPoint(ObjectPtr theObj, 
                                                    const TopoDS_Shape theShape, 
                                                    FeaturePtr theSketch)
index 1aaf66401d9856d6ff054e49187bbe82221566ff..54c8b8978d7da3147079e4af7deb427de268f16d 100644 (file)
@@ -25,6 +25,7 @@
 
 class Handle_V3d_View;
 class ModuleBase_ViewerPrs;
+class ModuleBase_IWorkshop;
 class GeomDataAPI_Point2D;
 class GeomAPI_Pln;
 class GeomAPI_Pnt2d;
@@ -205,7 +206,16 @@ class PARTSET_EXPORT PartSet_Tools
   * \param theShape - a Shape
   * \param theSketch - a Sketch to get a plane of converting to 2d
   */
-  static AttributePtr findAttributeBy2dPoint(ObjectPtr theObj, const TopoDS_Shape theShape, FeaturePtr theSketch);
+  static AttributePtr findAttributeBy2dPoint(ObjectPtr theObj, const TopoDS_Shape theShape,
+                                             FeaturePtr theSketch);
+
+  /**
+  * Finds an attribute value in attribute reference attribute value
+  * \param theAttribute - an attribure reference filled with an attribute
+  * \return a geometry shape
+  */
+  static GeomShapePtr findShapeBy2DPoint(const AttributePtr& theAttribute,
+                                         ModuleBase_IWorkshop* theWorkshop);
 
 protected:
   /// Returns an object that is under the mouse point. Firstly it checks the highlighting,
index ae4a295126edfe8d2b31cfc2d765cae26dd90387..488a265680a1bd4a756d938ac269666d245cd000 100644 (file)
@@ -109,58 +109,10 @@ void PartSet_WidgetShapeSelector::getGeomSelection(const ModuleBase_ViewerPrs& t
 GeomShapePtr PartSet_WidgetShapeSelector::getShape() const
 {
   // an empty shape by default
-  GeomShapePtr aShape;
-
-  // 1. find an attribute value in attribute reference attribute value
   DataPtr aData = myFeature->data();
-  AttributePtr aAttr = aData->attribute(attributeID());
-  AttributeRefAttrPtr aRefAttr = 
-    std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aAttr);
-  if (aRefAttr) {
-    if (!aRefAttr->isObject()) {
-      AttributePtr anAttribute = aRefAttr->attr();
-      if (anAttribute.get()) {
-        XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
-        XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
-
-        // 2. find visualized vertices of the attribute and if the attribute of the vertex is
-        // the same, return it
-        FeaturePtr anAttributeFeature = ModelAPI_Feature::feature(anAttribute->owner());
-        // 2.1 get visualized results of the feature
-        const std::list<ResultPtr>& aResList = anAttributeFeature->results();
-        std::list<ResultPtr>::const_iterator anIt = aResList.begin(), aLast = aResList.end();
-        for (; anIt != aLast; anIt++) {
-          AISObjectPtr aAISObj = aDisplayer->getAISObject(*anIt);
-          if (aAISObj.get() != NULL) {
-            Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
-            // 2.2 find selected owners of a visualizedd object
-            SelectMgr_IndexedMapOfOwner aSelectedOwners;  
-            aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
-            for  (Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++) {
-              Handle(SelectMgr_EntityOwner) anOwner = aSelectedOwners(i);
-              if (!anOwner.IsNull()) {
-                Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast(anOwner);
-                if (!aBRepOwner.IsNull() && aBRepOwner->HasShape()) {
-                  const TopoDS_Shape& aBRepShape = aBRepOwner->Shape();
-                  if (aBRepShape.ShapeType() == TopAbs_VERTEX) {
-                    // 2.3 if the owner is vertex and an attribute of the vertex is equal to the initial
-                    // attribute, returns the shape
-                    AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(anAttributeFeature,
-                                                                                  aBRepShape, sketch());
-                    if (aPntAttr.get() != NULL && aPntAttr == anAttribute) {
-                      aShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape);
-                      aShape->setImpl(new TopoDS_Shape(aBRepShape));
-                      break;
-                    }
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-  }
+  AttributePtr anAttribute = aData->attribute(attributeID());
+  GeomShapePtr aShape = PartSet_Tools::findShapeBy2DPoint(anAttribute, myWorkshop);
+
   if (!aShape.get())
     aShape = ModuleBase_WidgetShapeSelector::getShape();
   return aShape;
index efd6481ec88c340f61e509ad72a8442b47b91792..c202b4f6d39e2d398dac34dcd405c3acb96cff3b 100644 (file)
@@ -861,6 +861,7 @@ bool XGUI_Displayer::customizeObject(ObjectPtr theObject)
   ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
 
   // Customization of presentation
+  bool isPresentable = false;
   GeomCustomPrsPtr aCustomPrs;
   FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
   if (aFeature.get() != NULL) {
@@ -871,11 +872,12 @@ bool XGUI_Displayer::customizeObject(ObjectPtr theObject)
   if (aCustomPrs.get() == NULL) {
     // we ignore presentable not customized objects
     GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
-    if (aPrs.get() != NULL)
-      return false;
+    isPresentable = aPrs.get() != NULL;
     aCustomPrs = myCustomPrs;
   }
-  bool isCustomized = aCustomPrs->customisePresentation(aResult, anAISObj, myCustomPrs);
+  bool isCustomized = false;
+  if (!isPresentable)
+    aCustomPrs->customisePresentation(aResult, anAISObj, myCustomPrs);
   isCustomized = myWorkshop->module()->customizeObject(theObject) || isCustomized;
   return isCustomized;
 }