]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Imrove multi-selector control to provide items multi-selection. Preferences color...
authornds <nds@opencascade.com>
Fri, 15 Jan 2016 15:58:34 +0000 (18:58 +0300)
committerdbv <dbv@opencascade.com>
Tue, 16 Feb 2016 14:03:06 +0000 (17:03 +0300)
src/PartSet/PartSet_CustomPrs.cpp
src/PartSet/PartSet_CustomPrs.h

index a449d8da66c18dfc3e6c760a2f95c21bda71293e..b466171c3c3f0e7a93f2c2f67caaea68ca2cb5ca 100755 (executable)
@@ -88,6 +88,11 @@ bool PartSet_CustomPrs::displayPresentation(const ModuleBase_IModule::ModuleBase
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
   if (!aContext.IsNull() && !aContext->IsDisplayed(anOperationPrs)) {
     if (anOperationPrs->hasShapes()) {
+      // set color here because it can be changed in preferences
+      Quantity_Color aShapeColor, aResultColor;
+      getAISColors(theFlag, aShapeColor, aResultColor);
+      anOperationPrs->setColors(aShapeColor, aResultColor);
+
       PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
       XGUI_Workshop* aWorkshop = workshop();
       aWorkshop->displayer()->displayAIS(myPresentations[theFlag], false/*load object in selection*/,
@@ -162,23 +167,10 @@ void PartSet_CustomPrs::initPresentation(const ModuleBase_IModule::ModuleBase_Cu
   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();
   }
 
@@ -186,6 +178,23 @@ void PartSet_CustomPrs::initPresentation(const ModuleBase_IModule::ModuleBase_Cu
     myPresentations[theFlag] = anOperationPrs;
 }
 
+void PartSet_CustomPrs::getAISColors(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
+                                     Quantity_Color& theShapeColor, Quantity_Color& theResultColor)
+{
+  if (theFlag == ModuleBase_IModule::CustomizeDependedAndResults) {
+    theShapeColor = ModuleBase_Tools::color("Visualization", "operation_parameter_color",
+                                            OPERATION_PARAMETER_COLOR());
+    theResultColor = ModuleBase_Tools::color("Visualization", "operation_result_color",
+                                             OPERATION_RESULT_COLOR());
+  }
+  else if (theFlag == ModuleBase_IModule::CustomizeHighlightedObjects) {
+    theShapeColor = ModuleBase_Tools::color("Visualization", "operation_highlight_color",
+                                            OPERATION_HIGHLIGHT_COLOR());
+    theResultColor = ModuleBase_Tools::color("Visualization", "operation_result_color",
+                                             OPERATION_RESULT_COLOR());
+  }
+}
+
 XGUI_Workshop* PartSet_CustomPrs::workshop() const
 {
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
index b235e19c0f3287af11c524394a9627260cee8878..1785818b9228d0b7520c34d586bb20367f864d18 100755 (executable)
@@ -103,8 +103,16 @@ private:
   /// 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.
+  /// \param theFlag an object AIS presentation type
   void clearPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
 
+  /// Returns presentation colors according to the flag
+  /// \param theFlag an object AIS presentation type
+  /// \param theShapeColor a color for shapes
+  /// \param theShapeColor a color for results
+  void getAISColors(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
+                    Quantity_Color& theShapeColor, Quantity_Color& theResultColor);
+
 private:
   bool myIsActive;
   ModuleBase_IWorkshop* myWorkshop; /// current workshop