Salome HOME
Incorrect dumping of parts with user-defined names (issue #1804)
[modules/shaper.git] / src / PartSet / PartSet_WidgetSubShapeSelector.h
index 4c094579948f9078025575d63f4b2672a31a77c9..b20cf882d50f55abe7a2e7951a2b9e38426810be 100644 (file)
@@ -9,9 +9,11 @@
 #define PartSet_WidgetSubShapeSelector_H
 
 #include "PartSet.h"
+#include "PartSet_MouseProcessor.h"
 
-#include <PartSet_WidgetShapeSelector.h>
-#include <PartSet_MouseProcessor.h>
+#include <ModuleBase_WidgetShapeSelector.h>
+
+#include <ModelAPI_CompositeFeature.h>
 
 #include <QObject>
 
@@ -23,6 +25,9 @@ class Config_WidgetAPI;
 class ModuleBase_IViewWindow;
 class ModuleBase_ViewerPrs;
 
+class GeomAPI_Pnt;
+class GeomDataAPI_Point2D;
+
 class QWidget;
 class QMouseEvent;
 
@@ -32,7 +37,7 @@ class QMouseEvent;
 * by mouse move over shape in the viewer. Split of the object is performed by
 * coincident points to the object. Segment between nearest coincidence is highlighted
 */
-class PARTSET_EXPORT PartSet_WidgetSubShapeSelector: public PartSet_WidgetShapeSelector,
+class PARTSET_EXPORT PartSet_WidgetSubShapeSelector: public ModuleBase_WidgetShapeSelector,
                                                      public PartSet_MouseProcessor
 {
 Q_OBJECT
@@ -46,6 +51,16 @@ Q_OBJECT
 
   virtual ~PartSet_WidgetSubShapeSelector();
 
+  /// Set sketcher
+  /// \param theSketch a sketcher object
+  void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
+
+  /// Retrurns installed sketcher
+  CompositeFeaturePtr sketch() const { return mySketch; }
+
+  /// The methiod called when widget is deactivated
+  virtual void deactivate();
+
   /// Processing the mouse move event in the viewer
   /// \param theWindow a view window
   /// \param theEvent a mouse event
@@ -55,6 +70,15 @@ Q_OBJECT
   /// \param theValues a list of presentations
   virtual void getHighlighted(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
 
+  /// Set the given wrapped value to the current widget
+  /// This value should be processed in the widget according to the needs
+  /// The method is called by the current operation to process the operation preselection.
+  /// It is redefined to fill attributes responsible for the sub selection
+  /// \param theValues the wrapped selection values
+  /// \param theToValidate a flag on validation of the values
+  virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
+                            const bool theToValidate);
+
 protected:
   /// Checks the widget validity. By default, it returns true.
   /// \param thePrs a selected presentation in the view
@@ -70,9 +94,33 @@ protected:
   //                              GeomShapePtr& theShape);
   void fillObjectShapes(const ObjectPtr& theObject);
 
+  /// Return an object and geom shape by the viewer presentation
+  /// \param thePrs a selection
+  /// \param theObject an output object
+  /// \param theShape a shape of the selection
+  virtual void getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
+                                ObjectPtr& theObject,
+                                GeomShapePtr& theShape);
+
+  /// Return the attribute values wrapped in a list of viewer presentations
+  /// \return a list of viewer presentations, which contains an attribute result and
+  /// a shape. If the attribute do not uses the shape, it is empty
+  virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
+
+protected:
+  /// The methiod called when widget is activated
+  virtual void activateCustom();
+
 protected:
   std::shared_ptr<ModuleBase_ViewerPrs> myCurrentSubShape;
   std::map<ObjectPtr, std::set<GeomShapePtr> > myCashedShapes;
+
+  typedef std::map<std::shared_ptr<GeomDataAPI_Point2D>,
+                   std::shared_ptr<GeomAPI_Pnt> > PntToAttributesMap;
+  std::map<ObjectPtr, PntToAttributesMap> myCashedReferences;
+
+  /// Pointer to a sketch 
+  CompositeFeaturePtr mySketch;
 };
 
 #endif
\ No newline at end of file