Salome HOME
Fix for registering of parameters in command line.
[modules/shaper.git] / src / PartSet / PartSet_CustomPrs.h
index 1785818b9228d0b7520c34d586bb20367f864d18..1902c0139afd169f0147e65f7394249140dd2737 100755 (executable)
@@ -16,6 +16,8 @@
 #include <ModelAPI_Result.h>
 #include <ModelAPI_Feature.h>
 
+#include <Events_Listener.h>
+
 #include <GeomAPI_ICustomPrs.h>
 #include <GeomAPI_AISObject.h>
 #include <GeomAPI_Shape.h>
@@ -27,7 +29,7 @@ class XGUI_Workshop;
  * This is the module custom presentation, which manage an AIS presentation, that can be filled
  * by a feature and visualized in the viewer additionally to usual workshop objects.
 */
-class PartSet_CustomPrs
+class PartSet_CustomPrs : public Events_Listener
 {
 public:
   /// Returns yellow color
@@ -35,9 +37,10 @@ public:
   /// 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"; }
+  static const std::string OPERATION_HIGHLIGHT_COLOR() { return "128, 0, 0"; }
 
+  /// Returns color lighter than sketch feature entity : pink
+  static const std::string OPERATION_REMOVE_FEATURE_COLOR() { return "255, 174, 201"; }
 public:
   /// Constructor
   /// \param theWorkshop a reference to workshop
@@ -45,18 +48,24 @@ public:
   PARTSET_EXPORT virtual ~PartSet_CustomPrs() {};
 
   /// Returns true if the presentation is active
-  bool isActive();
+  /// \param theFlag an object AIS presentation type
+  bool isActive(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
 
   /// Initializes the operation presentation by the parameter object and display the presentation
   /// \param theObject an operation feature source to fill the presentation
+  /// \param theFlag an object AIS presentation type
   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
   /// \returns true if the presentation is displayed
-  bool activate(const FeaturePtr& theObject, const bool theUpdateViewer);
+  bool activate(const FeaturePtr& theObject,
+                const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
+                const bool theUpdateViewer);
 
   /// Initializes the operation presentation by empty object and erase the presentation
   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
+  /// \param theFlag an object AIS presentation type
   /// \returns true if the presentation has been displayed and now it is erased
-  bool deactivate(const bool theUpdateViewer);
+  bool deactivate(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
+                  const bool theUpdateViewer);
 
   /// If the presentation is active[displayed], the shapes of the presentation is recomputed
   /// and the presentation is redisplayed.
@@ -73,16 +82,20 @@ public:
   /// it caused erroneus case because the presentation has linkage to the previous context.
   void clearPrs();
 
+  //! Redefinition of Events_Listener method to listen a moment that the presentation becomes empty
+  virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
+
 private:
   /// Creates the AIS operation presentation
   /// \param theFlag an object AIS presentation type
   void initPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
 
-  /// Gets an AIS presentation by the flag
+  /// Gets an AIS presentation by the flag or create new if there is no a 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);
+  /// \param theToCreate a flag if a new presentation should be created
+  /// \return wrap of AIS prsentation
+  AISObjectPtr getPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
+                               const bool theToCreate);
 
   //! Returns workshop
   XGUI_Workshop* workshop() const;
@@ -97,7 +110,8 @@ private:
   /// 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 ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
+  /// \param returns whether the presentation is erased
+  bool erasePresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
                          const bool theUpdateViewer);
 
   /// Nullify the operation presentation. For example, it can be useful when the viewer/context
@@ -106,18 +120,19 @@ private:
   /// \param theFlag an object AIS presentation type
   void clearPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
 
-  /// Returns presentation colors according to the flag
+  /// Returns presentation color 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);
+  /// \return theShapeColor a color
+  Quantity_Color getShapeColor(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
 
 private:
-  bool myIsActive;
+  bool myPresentationIsEmpty; /// Boolean state about empty presentation
+  FeaturePtr myFeature; /// Reference to a feature object
   ModuleBase_IWorkshop* myWorkshop; /// current workshop
   /// map of presentation type to AIS object
   QMap<ModuleBase_IModule::ModuleBase_CustomizeFlag, AISObjectPtr> myPresentations;
+  /// State whether the presentation is activated/deactivated
+  QMap<ModuleBase_IModule::ModuleBase_CustomizeFlag, bool> myIsActive;
 };
 
 #endif