Salome HOME
Imrove multi-selector control to provide items multi-selection. Division of the opera...
authornds <nds@opencascade.com>
Fri, 15 Jan 2016 15:41:43 +0000 (18:41 +0300)
committerdbv <dbv@opencascade.com>
Tue, 16 Feb 2016 14:03:05 +0000 (17:03 +0300)
src/ModuleBase/ModuleBase_IModule.h
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/PartSet/PartSet_CustomPrs.cpp
src/PartSet/PartSet_CustomPrs.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationPrs.cpp
src/PartSet/PartSet_OperationPrs.h
src/XGUI/XGUI_WorkshopListener.cpp

index 45c895ded35147f81ab5f3727f49997f4773b8cc..55a0e8b5cc8dab94ca88742a212ff2e0d80633f5 100755 (executable)
@@ -35,8 +35,7 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
   /// enumeration to know which objects should be customized\r
   enum ModuleBase_CustomizeFlag {\r
     CustomizeDependedAndResults = 0x00000000,\r
-    CustomizeHighlightedObjects = 0x00000001,\r
-    CustomizeAllObjects = CustomizeDependedAndResults | CustomizeHighlightedObjects\r
+    CustomizeHighlightedObjects = 0x00000001\r
   };\r
 \r
    /// Constructor\r
index 09071536151acd0d81ed841f1faac1229287fc22..38bc5c9c8fdd2b3f81e151a2f9218caa612c4962 100755 (executable)
@@ -357,7 +357,6 @@ bool ModuleBase_WidgetMultiSelector::processDelete()
 
     restoreValue();
     myWorkshop->setSelected(getAttributeSelection());
-    myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeAllObjects, true);
   }
   return aDone;
 }
index e43ccc980fd091230a4caf2f5d0de63cb2bee6f0..a449d8da66c18dfc3e6c760a2f95c21bda71293e 100755 (executable)
@@ -14,6 +14,7 @@
 
 #include <ModuleBase_IWorkshop.h>
 #include <ModuleBase_IViewer.h>
+#include <ModuleBase_Tools.h>
 
 #include <Config_PropManager.h>
 
 
 //#define DO_NOT_VISUALIZE_CUSTOM_PRESENTATION
 
-#define OPERATION_PARAMETER_COLOR "255, 255, 0"
-
 PartSet_CustomPrs::PartSet_CustomPrs(ModuleBase_IWorkshop* theWorkshop)
   : myWorkshop(theWorkshop), myIsActive(false)
 {
-  initPrs();
+  initPresentation(ModuleBase_IModule::CustomizeDependedAndResults);
+  initPresentation(ModuleBase_IModule::CustomizeHighlightedObjects);
 }
 
 bool PartSet_CustomPrs::isActive()
 {
   return myIsActive;
-  /*Handle(PartSet_OperationPrs) anOperationPrs = getPresentation();
-  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
-
-  return !aContext.IsNull() && aContext->IsDisplayed(anOperationPrs);*/
 }
 
 bool PartSet_CustomPrs::activate(const FeaturePtr& theFeature, const bool theUpdateViewer)
@@ -46,13 +42,15 @@ bool PartSet_CustomPrs::activate(const FeaturePtr& theFeature, const bool theUpd
   return false;
 #endif
 
-  bool isModified = false;
-  Handle(PartSet_OperationPrs) anOperationPrs = getPresentation();
-
   myIsActive = true;
-  anOperationPrs->setFeature(theFeature);
+
+
+  bool isModified = false;
+  getPresentation(ModuleBase_IModule::CustomizeDependedAndResults)->setFeature(theFeature);
+  getPresentation(ModuleBase_IModule::CustomizeHighlightedObjects)->setFeature(theFeature);
   if (theFeature.get()) {
-    displayPresentation(theUpdateViewer);
+    displayPresentation(ModuleBase_IModule::CustomizeDependedAndResults, theUpdateViewer);
+    displayPresentation(ModuleBase_IModule::CustomizeHighlightedObjects, theUpdateViewer);
     isModified = true;
   }
   return isModified;
@@ -63,37 +61,44 @@ bool PartSet_CustomPrs::deactivate(const bool theUpdateViewer)
   myIsActive = false;
   bool isModified = false;
 
-  Handle(PartSet_OperationPrs) anOperationPrs = getPresentation();
-  anOperationPrs->setFeature(FeaturePtr());
+  getPresentation(ModuleBase_IModule::CustomizeDependedAndResults)->setFeature(FeaturePtr());
+  getPresentation(ModuleBase_IModule::CustomizeHighlightedObjects)->setFeature(FeaturePtr());
 
-  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
-  if (!aContext.IsNull() && aContext->IsDisplayed(anOperationPrs)) {
-    erasePresentation(theUpdateViewer);
-    isModified = true;
-  }
+  erasePresentation(ModuleBase_IModule::CustomizeDependedAndResults, theUpdateViewer);
+  erasePresentation(ModuleBase_IModule::CustomizeHighlightedObjects, theUpdateViewer);
+  isModified = true;
 
   return isModified;
 }
 
-bool PartSet_CustomPrs::displayPresentation(const bool theUpdateViewer)
+bool PartSet_CustomPrs::displayPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
+                                            const bool theUpdateViewer)
 {
   bool isModified = false;
-  Handle(PartSet_OperationPrs) anOperationPrs = getPresentation();
-  anOperationPrs->updateShapes();
+  Handle(PartSet_OperationPrs) anOperationPrs = getPresentation(theFlag);
+  if (theFlag == ModuleBase_IModule::CustomizeDependedAndResults) {
+    PartSet_OperationPrs::getFeatureShapes(anOperationPrs->getFeature(), myWorkshop,
+                                           anOperationPrs->featureShapes());
+    anOperationPrs->updateShapes();
+  }
+  else if (theFlag == ModuleBase_IModule::CustomizeHighlightedObjects) {
+    PartSet_OperationPrs::getHighlightedShapes(myWorkshop, anOperationPrs->featureShapes());
+  }
 
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
   if (!aContext.IsNull() && !aContext->IsDisplayed(anOperationPrs)) {
     if (anOperationPrs->hasShapes()) {
       PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
       XGUI_Workshop* aWorkshop = workshop();
-      aWorkshop->displayer()->displayAIS(myOperationPrs, false/*load object in selection*/, theUpdateViewer);
+      aWorkshop->displayer()->displayAIS(myPresentations[theFlag], false/*load object in selection*/,
+                                         theUpdateViewer);
       aContext->SetZLayer(anOperationPrs, aModule->getVisualLayerId());
       isModified = true;
     }
   }
   else {
     if (!anOperationPrs->hasShapes()) {
-      erasePresentation(theUpdateViewer);
+      erasePresentation(theFlag, theUpdateViewer);
       isModified = true;
     }
     else {
@@ -106,18 +111,33 @@ bool PartSet_CustomPrs::displayPresentation(const bool theUpdateViewer)
   return isModified;
 }
 
-void PartSet_CustomPrs::erasePresentation(const bool theUpdateViewer)
+void PartSet_CustomPrs::erasePresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
+                                          const bool theUpdateViewer)
 {
   XGUI_Workshop* aWorkshop = workshop();
-  aWorkshop->displayer()->eraseAIS(myOperationPrs, theUpdateViewer);
+  aWorkshop->displayer()->eraseAIS(myPresentations[theFlag], theUpdateViewer);
 }
 
-Handle(PartSet_OperationPrs) PartSet_CustomPrs::getPresentation()
+void PartSet_CustomPrs::clearPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag)
 {
-  if (!myOperationPrs.get())
-    initPrs();
-  Handle(AIS_InteractiveObject) anAISIO = myOperationPrs->impl<Handle(AIS_InteractiveObject)>();
-  return Handle(PartSet_OperationPrs)::DownCast(anAISIO);
+  Handle(PartSet_OperationPrs) anOperationPrs = getPresentation(theFlag);
+  if (!anOperationPrs.IsNull())
+    anOperationPrs.Nullify();
+}
+
+Handle(PartSet_OperationPrs) PartSet_CustomPrs::getPresentation(
+                                         const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag)
+{
+  Handle(PartSet_OperationPrs) aPresentation;
+
+  if (myPresentations.contains(theFlag)) {
+    AISObjectPtr anOperationPrs = myPresentations[theFlag];
+    if (!anOperationPrs.get())
+      initPresentation(theFlag);
+    Handle(AIS_InteractiveObject) anAISIO = anOperationPrs->impl<Handle(AIS_InteractiveObject)>();
+    aPresentation = Handle(PartSet_OperationPrs)::DownCast(anAISIO);
+  }
+  return aPresentation;
 }
 
 bool PartSet_CustomPrs::redisplay(const ObjectPtr& theObject,
@@ -127,29 +147,43 @@ bool PartSet_CustomPrs::redisplay(const ObjectPtr& theObject,
 #ifdef DO_NOT_VISUALIZE_CUSTOM_PRESENTATION
   return false;
 #endif
-  return displayPresentation(theUpdateViewer);
+  return displayPresentation(theFlag, theUpdateViewer);
 }
 
 void PartSet_CustomPrs::clearPrs()
 {
-  Handle(PartSet_OperationPrs) anOperationPrs = getPresentation();
-  if (!anOperationPrs.IsNull())
-    anOperationPrs.Nullify();
-
-  myOperationPrs.reset();
+  clearPresentation(ModuleBase_IModule::CustomizeDependedAndResults);
+  clearPresentation(ModuleBase_IModule::CustomizeHighlightedObjects);
 }
 
-void PartSet_CustomPrs::initPrs()
+void PartSet_CustomPrs::initPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag)
 {
-  myOperationPrs = AISObjectPtr(new GeomAPI_AISObject());
-  myOperationPrs->setImpl(new Handle(AIS_InteractiveObject)(new PartSet_OperationPrs(myWorkshop)));
-
-  std::vector<int> aColor = Config_PropManager::color("Visualization", "operation_parameter_color",
-                                                      OPERATION_PARAMETER_COLOR);
-  myOperationPrs->setColor(aColor[0], aColor[1], aColor[2]);
+  AISObjectPtr anOperationPrs = AISObjectPtr(new GeomAPI_AISObject());
+  Handle(PartSet_OperationPrs) anAISPrs = new PartSet_OperationPrs(myWorkshop);
+  anOperationPrs->setImpl(new Handle(AIS_InteractiveObject)(anAISPrs));
+  if (theFlag == ModuleBase_IModule::CustomizeDependedAndResults) {
+    Quantity_Color aShapeColor = ModuleBase_Tools::color("Visualization", "operation_parameter_color",
+                                                         OPERATION_PARAMETER_COLOR());
+    Quantity_Color aResultColor = ModuleBase_Tools::color("Visualization", "operation_result_color",
+                                                         OPERATION_RESULT_COLOR());
+    anAISPrs->setColors(aShapeColor, aResultColor);
+
+    anOperationPrs->setPointMarker(5, 2.);
+    anOperationPrs->setWidth(1);
+  }
+  else if (theFlag == ModuleBase_IModule::CustomizeHighlightedObjects) {
+    Quantity_Color aShapeColor = ModuleBase_Tools::color("Visualization", "operation_highlight_color",
+                                                         OPERATION_HIGHLIGHT_COLOR());
+    Quantity_Color aResultColor = ModuleBase_Tools::color("Visualization", "operation_result_color",
+                                                          OPERATION_RESULT_COLOR());
+    anAISPrs->setColors(aShapeColor, aResultColor);
+    //in this presentation we show the shapes wireframe similar to their highlight by OCCT
+    //so, we need to use the source AIS object width for the presentation width
+    anAISPrs->useAISWidth();
+  }
 
-  myOperationPrs->setPointMarker(5, 2.);
-  myOperationPrs->setWidth(1);
+  if (anOperationPrs.get())
+    myPresentations[theFlag] = anOperationPrs;
 }
 
 XGUI_Workshop* PartSet_CustomPrs::workshop() const
index ab82997a72817eb4489eadeb2e72a21f5cba4009..b235e19c0f3287af11c524394a9627260cee8878 100755 (executable)
@@ -29,6 +29,15 @@ class XGUI_Workshop;
 */
 class PartSet_CustomPrs
 {
+public:
+  /// Returns yellow color
+  static const std::string OPERATION_PARAMETER_COLOR() { return "255, 255, 0"; }
+  /// Returns green color
+  static const std::string OPERATION_RESULT_COLOR() { return "0,225, 0"; }
+  /// Returns color between white and color of highlight
+  /// highlight color is equal Quantity_Color(0.5,1,1) or QColor(122, 255,255) // 188
+  static const std::string OPERATION_HIGHLIGHT_COLOR() { return "188, 255, 255"; }
+
 public:
   /// Constructor
   /// \param theWorkshop a reference to workshop
@@ -52,38 +61,55 @@ public:
   /// If the presentation is active[displayed], the shapes of the presentation is recomputed
   /// and the presentation is redisplayed.
   /// \param theObject an object to redisplay
+  /// \param theFlag an object AIS presentation type
   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
   /// \returns true if the presentation is redisplayed
   bool redisplay(const ObjectPtr& theObject,
-                 const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag, const bool theUpdateViewer);
+                 const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
+                 const bool theUpdateViewer);
 
-  /// Nullify the operation presentation. For example, it can be useful when the viewer/context
+  /// Nullify all internal presentations. For example, it can be useful when the viewer/context
   /// is closed. If this is not performed and the presentation is assigned in another context,
   /// it caused erroneus case because the presentation has linkage to the previous context.
   void clearPrs();
 
 private:
   /// Creates the AIS operation presentation
-  void initPrs();
+  /// \param theFlag an object AIS presentation type
+  void initPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
 
-  /// Returns the AIS presentation
-  Handle(PartSet_OperationPrs) getPresentation();
+  /// Gets an AIS presentation by the flag
+  /// \param theFlag an object AIS presentation type
+  /// \return the AIS prsentation
+  Handle(PartSet_OperationPrs) getPresentation(
+                            const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
 
   //! Returns workshop
   XGUI_Workshop* workshop() const;
 
   /// Displays the internal presentation in the viewer of workshop
+  /// \param theFlag an object AIS presentation type
   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
-  bool displayPresentation(const bool theUpdateViewer);
+  /// \param returns whether the presentation is displayed/redisplayed
+  bool displayPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
+                           const bool theUpdateViewer);
 
   /// Erases the internal presentation from the viewer of workshop
+  /// \param theFlag an object AIS presentation type
   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
-  void erasePresentation(const bool theUpdateViewer);
+  void erasePresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
+                         const bool theUpdateViewer);
+
+  /// Nullify the operation presentation. For example, it can be useful when the viewer/context
+  /// is closed. If this is not performed and the presentation is assigned in another context,
+  /// it caused erroneus case because the presentation has linkage to the previous context.
+  void clearPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
 
 private:
   bool myIsActive;
   ModuleBase_IWorkshop* myWorkshop; /// current workshop
-  AISObjectPtr myOperationPrs; /// the AIS presentation, which is displayed/erased in the viewer
+  /// map of presentation type to AIS object
+  QMap<ModuleBase_IModule::ModuleBase_CustomizeFlag, AISObjectPtr> myPresentations;
 };
 
 #endif
index 7883d527907c1939ad3abe19cf838d55646aa02b..ea2740d626dfcfffe7ab44dd75f3e7fc9d8cf172 100755 (executable)
@@ -142,6 +142,16 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
 
   myHasConstraintShown[PartSet_Tools::Geometrical] = true;
   myHasConstraintShown[PartSet_Tools::Dimensional] = true;
+
+  Config_PropManager::registerProp("Visualization", "operation_parameter_color",
+                          "Reference shape wireframe color in operation", Config_Prop::Color,
+                          PartSet_CustomPrs::OPERATION_PARAMETER_COLOR());
+  Config_PropManager::registerProp("Visualization", "operation_result_color",
+                          "Result shape wireframe color in operation", Config_Prop::Color,
+                          PartSet_CustomPrs::OPERATION_RESULT_COLOR());
+  Config_PropManager::registerProp("Visualization", "operation_highlight_color",
+                          "Multi selector item color in operation", Config_Prop::Color,
+                          PartSet_CustomPrs::OPERATION_HIGHLIGHT_COLOR());
 }
 
 PartSet_Module::~PartSet_Module()
index af1f3ae4b972fafbe5a9d54082c816a923c5c876..6858e0a143e3134b1985a17b915b26c9658c74fe 100755 (executable)
@@ -37,7 +37,8 @@ IMPLEMENT_STANDARD_HANDLE(PartSet_OperationPrs, ViewerData_AISShape);
 IMPLEMENT_STANDARD_RTTIEXT(PartSet_OperationPrs, ViewerData_AISShape);
 
 PartSet_OperationPrs::PartSet_OperationPrs(ModuleBase_IWorkshop* theWorkshop)
-  : ViewerData_AISShape(TopoDS_Shape()), myFeature(FeaturePtr()), myWorkshop(theWorkshop)
+: ViewerData_AISShape(TopoDS_Shape()), myFeature(FeaturePtr()), myWorkshop(theWorkshop),
+ myUseAISWidth(false)
 {
   myShapeColor = ModuleBase_Tools::color("Visualization", "construction_plane_color", "1,1,0");
   myResultColor = ModuleBase_Tools::color("Visualization", "construction_plane_color", "0,1,0");
@@ -50,9 +51,6 @@ void PartSet_OperationPrs::setFeature(const FeaturePtr& theFeature)
 
 void PartSet_OperationPrs::updateShapes()
 {
-  myFeatureShapes.clear();
-  getFeatureShapes(myFeatureShapes);
-
   myFeatureResults.clear();
   if (myFeature)
     myFeatureResults = myFeature->results();
@@ -83,6 +81,17 @@ bool PartSet_OperationPrs::hasShapes()
   return aHasShapes;
 }
 
+void PartSet_OperationPrs::setColors(const Quantity_Color& theShapeColor, const Quantity_Color& theResultColor)
+{
+  myShapeColor = theShapeColor;
+  myResultColor = theResultColor;
+}
+
+void PartSet_OperationPrs::useAISWidth()
+{
+  myUseAISWidth = true;
+}
+
 void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
                                    const Handle(Prs3d_Presentation)& thePresentation, 
                                    const Standard_Integer theMode)
@@ -94,15 +103,13 @@ void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
   if (!myWorkshop->module()->canDisplayObject(myFeature))
     return;
 
-  Quantity_Color aColor(1., 1., 0., Quantity_TOC_RGB); // yellow
-  SetColor(aColor);
-
+  SetColor(myShapeColor);
   thePresentation->Clear();
   XGUI_Displayer* aDisplayer = workshop()->displayer();
 
-  // create presentations on the base of the shapes
   Handle(Prs3d_Drawer) aDrawer = Attributes();
 
+  // create presentations on the base of the shapes
   QMap<ObjectPtr, QList<GeomShapePtr> >::const_iterator anIt = myFeatureShapes.begin(),
                                                         aLast = myFeatureShapes.end();
   for (; anIt != aLast; anIt++) {
@@ -118,13 +125,21 @@ void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
       TopoDS_Shape aShape = aGeomShape->impl<TopoDS_Shape>();
       // change deviation coefficient to provide more precise circle
       ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, aDrawer);
+
+      if (myUseAISWidth) {
+        AISObjectPtr anAISPtr = aDisplayer->getAISObject(anObject);
+        if (anAISPtr.get()) {
+          Handle(AIS_InteractiveObject) anIO = anAISPtr->impl<Handle(AIS_InteractiveObject)>();
+          if (!anIO.IsNull())
+            setWidth(aDrawer, anIO->Width());
+        }
+      }
       StdPrs_WFDeflectionShape::Add(thePresentation, aShape, aDrawer);
     }
   }
 
-  aColor = Quantity_Color(0., 1., 0., Quantity_TOC_RGB); // green
-  SetColor(aColor);
-
+  // create presentations on the base of the results
+  SetColor(myResultColor);
   std::list<ResultPtr>::const_iterator aRIt = myFeatureResults.begin(),
                                        aRLast = myFeatureResults.end();
   for (; aRIt != aRLast; aRIt++) {
@@ -147,37 +162,6 @@ void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
       aWidget->getHighlighted(aValues);
     }
   }
-
-  Standard_Real aPreviousWidth = Width();
-  setWidth(aDrawer, aPreviousWidth+3);
-  Handle(AIS_InteractiveContext) aContext = GetContext();
-  Quantity_NameOfColor anHColor = aContext->HilightColor();
-
-  aColor = Quantity_Color(anHColor);
-  aColor = Quantity_Color((1. + aColor.Red())/2., (1. + aColor.Green())/2.,
-                          (1. + aColor.Blue())/2., Quantity_TOC_RGB);
-  SetColor(aColor);
-
-  QList<ModuleBase_ViewerPrs>::const_iterator anIIt = aValues.begin(),
-                                              aILast = aValues.end();
-  for (; anIIt != aILast; anIIt++) {
-    ModuleBase_ViewerPrs aPrs = *anIIt;
-    ObjectPtr anObject = aPrs.object();
-    TopoDS_Shape aShape = aPrs.shape();
-    if (aShape.IsNull()) {
-      ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
-      if (aResult.get()) {
-        GeomShapePtr aGeomShape = aResult->shape();
-        if (aGeomShape.get())
-          aShape = aGeomShape->impl<TopoDS_Shape>();
-      }
-    }
-    if (!aShape.IsNull()) {
-      ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, aDrawer);
-      StdPrs_WFDeflectionShape::Add(thePresentation, aShape, aDrawer);
-    }
-  }
-  setWidth(aDrawer, aPreviousWidth);
 }
 
 void PartSet_OperationPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
@@ -255,22 +239,25 @@ void addValue(const ObjectPtr& theObject, const GeomShapePtr& theShape,
   }
 }
 
-void PartSet_OperationPrs::getFeatureShapes(QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes)
+void PartSet_OperationPrs::getFeatureShapes(const FeaturePtr& theFeature,
+                                            ModuleBase_IWorkshop* theWorkshop,
+                                            QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes)
 {
-  if (!myFeature.get())
+  theObjectShapes.clear();
+  if (!theFeature.get())
     return;
 
   ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
 
   QList<GeomShapePtr> aShapes;
-  std::list<AttributePtr> anAttributes = myFeature->data()->attributes("");
+  std::list<AttributePtr> anAttributes = theFeature->data()->attributes("");
   std::list<AttributePtr>::const_iterator anIt = anAttributes.begin(), aLast = anAttributes.end();
   for (; anIt != aLast; anIt++) {
     AttributePtr anAttribute = *anIt;
     if (!isSelectionAttribute(anAttribute))
       continue;
 
-    if (!aValidators->isCase(myFeature, anAttribute->id()))
+    if (!aValidators->isCase(theFeature, anAttribute->id()))
       continue; // this attribute is not participated in the current case
 
     std::string anAttrType = anAttribute->attributeType();
@@ -282,7 +269,7 @@ void PartSet_OperationPrs::getFeatureShapes(QMap<ObjectPtr, QList<GeomShapePtr>
         std::shared_ptr<ModelAPI_AttributeSelection> aSelAttribute = aCurSelList->value(i);
         ResultPtr aResult = aSelAttribute->context();
         GeomShapePtr aShape = aSelAttribute->value();
-        addValue(aResult, aShape, myFeature, theObjectShapes);
+        addValue(aResult, aShape, theFeature, theObjectShapes);
       }
     }
     if (anAttrType == ModelAPI_AttributeRefList::typeId()) {
@@ -290,7 +277,7 @@ void PartSet_OperationPrs::getFeatureShapes(QMap<ObjectPtr, QList<GeomShapePtr>
         std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttribute);
       for (int i = 0; i < aCurSelList->size(); i++) {
         GeomShapePtr aShape;
-        addValue(aCurSelList->object(i), aShape, myFeature, theObjectShapes);
+        addValue(aCurSelList->object(i), aShape, theFeature, theObjectShapes);
       }
     }
     else {
@@ -302,7 +289,7 @@ void PartSet_OperationPrs::getFeatureShapes(QMap<ObjectPtr, QList<GeomShapePtr>
           anObject = anAttr->object();
         }
         else {
-          aShape = PartSet_Tools::findShapeBy2DPoint(anAttr, myWorkshop);
+          aShape = PartSet_Tools::findShapeBy2DPoint(anAttr, theWorkshop);
           // 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())
@@ -319,11 +306,57 @@ void PartSet_OperationPrs::getFeatureShapes(QMap<ObjectPtr, QList<GeomShapePtr>
         AttributeReferencePtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(anAttribute);
         anObject = anAttr->value();
       }
-      addValue(anObject, aShape, myFeature, theObjectShapes);
+      addValue(anObject, aShape, theFeature, theObjectShapes);
     }
   }
 }
 
+void PartSet_OperationPrs::getHighlightedShapes(ModuleBase_IWorkshop* theWorkshop,
+                                                QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes)
+{
+  theObjectShapes.clear();
+
+  QList<ModuleBase_ViewerPrs> aValues;
+  ModuleBase_IPropertyPanel* aPanel = theWorkshop->propertyPanel();
+  if (aPanel) {
+    ModuleBase_ModelWidget* aWidget = aPanel->activeWidget();
+    if (aWidget) {
+      aWidget->getHighlighted(aValues);
+    }
+  }
+
+  QList<GeomShapePtr> aShapes;
+  QList<ModuleBase_ViewerPrs>::const_iterator anIIt = aValues.begin(),
+                                              aILast = aValues.end();
+  for (; anIIt != aILast; anIIt++) {
+    ModuleBase_ViewerPrs aPrs = *anIIt;
+    ObjectPtr anObject = aPrs.object();
+
+    GeomShapePtr aGeomShape;
+
+    TopoDS_Shape aShape = aPrs.shape();
+    if (!aShape.IsNull()) {
+      aGeomShape = GeomShapePtr(new GeomAPI_Shape());
+      aGeomShape->setImpl(new TopoDS_Shape(aShape));
+    }
+    else {
+      ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
+      if (aResult.get()) {
+        aGeomShape = aResult->shape();
+      }
+    }
+
+    if (theObjectShapes.contains(anObject))
+      theObjectShapes[anObject].append(aGeomShape);
+    else {
+      QList<GeomShapePtr> aShapes;
+      aShapes.append(aGeomShape);
+      theObjectShapes[anObject] = aShapes;
+    }
+  }
+}
+
+
 bool PartSet_OperationPrs::isSelectionAttribute(const AttributePtr& theAttribute)
 {
   std::string anAttrType = theAttribute->attributeType();
index 8bb9d36c88b6c52aafd7e231233a72b12e3efa8b..89d2c252ed795adcab9a8ae1a817b510a775e9ed 100755 (executable)
@@ -57,6 +57,14 @@ public:
   /// Returns true if the feature contains shapes or results
   bool hasShapes();
 
+  /// Sets the colors for the presentation compute
+  /// \param theShapeColor an argument shapes color
+  /// \param theResultColor a color for operation result
+  void setColors(const Quantity_Color& theShapeColor, const Quantity_Color& theResultColor);
+
+  /// Switch on using of the AIS presentation with of the shape object increased on the delta
+  void useAISWidth();
+
   DEFINE_STANDARD_RTTI(PartSet_OperationPrs)
 
 protected:
@@ -68,6 +76,15 @@ protected:
   /// Redefinition of virtual function
   Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
                                                 const Standard_Integer aMode) ;
+
+protected:
+  /// Reference to a feature object
+  FeaturePtr getFeature() { return myFeature; }
+
+  /// Returns map of feature shapes to be able to fill it outside this class, e.g. in friend
+  /// \return a map of object to shape
+  QMap<ObjectPtr, QList<GeomShapePtr> >& featureShapes() { return myFeatureShapes; }
+
 private:
   /// Return true if the object is visible. If the object is feature, it returns true
   /// if all results of the feature are shown
@@ -77,9 +94,22 @@ private:
   bool isVisible(XGUI_Displayer* theDislayer, const ObjectPtr& theObject);
 
   /// Fills the map by the feature object and shapes, which should be visuaziled
-  /// Gets the feature attribute, collect objects to whom the attribute refers
+  /// Gets feature attributes, collect objects to whom the attributes refer
+  /// \param theFeature a current feature
+  /// \param theWorkshop a current workshop
+  /// \param theObjectShapes an output map
   /// \param theObjectShape an output map of objects
-  void getFeatureShapes(QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
+  static void getFeatureShapes(const FeaturePtr& theFeature,
+                               ModuleBase_IWorkshop* theWorkshop,
+                               QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
+
+  /// Fills the map by the feature object and shapes, which should be visuaziled
+  /// Gets the active widget, obtain the highlighted presentations if it has such and
+  /// fill map by object and shapes
+  /// \param theWorkshop a current workshop
+  /// \param theObjectShapes an output map of objects
+  static void getHighlightedShapes(ModuleBase_IWorkshop* theWorkshop,
+                                   QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
 
   /// Returns true if the attribute type belong to reference attribute
   /// \param theAttribute an attribute
@@ -98,6 +128,10 @@ private:
 
   Quantity_Color myShapeColor; /// color of feature depended shapes
   Quantity_Color myResultColor; /// color of feature result
+
+  bool myUseAISWidth; /// flag if the width of a shape object should be used for the shape visualization
+
+  friend class PartSet_CustomPrs;
 };
 
 
index f9c006199f5451df6edbf880d3d93792deb599af..d8934f2da7c14d455a1122de8a410ca25d40b953 100755 (executable)
@@ -581,9 +581,12 @@ bool XGUI_WorkshopListener::customizeCurrentObject(const std::set<ObjectPtr>& th
     // if a list of message objects contains the operation feature for case when
     // 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())
+    if (theForceRedisplay || theObjects.find(aCurrentFeature) != theObjects.end()) {
       aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
-                                           ModuleBase_IModule::CustomizeAllObjects, false);
+                                           ModuleBase_IModule::CustomizeDependedAndResults, false);
+      aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
+                                           ModuleBase_IModule::CustomizeHighlightedObjects, false);
+    }
   }
   return aCustomized;
 }