Salome HOME
updated copyright message
[modules/shaper.git] / src / PartSet / PartSet_WidgetFeaturePointSelector.h
index 176638c5128b3dcee56768f0685896b1958b9c43..7280875aedf469a0915e5f796c2c6ace7c6f194d 100644 (file)
@@ -1,15 +1,28 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        PartSet_WidgetFeaturePointSelector.h
-// Created:     28 Feb 2017
-// Author:      Natalia ERMOLAEVA
-
+// Copyright (C) 2014-2023  CEA, EDF
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #ifndef PartSet_WidgetFeaturePointSelector_H
 #define PartSet_WidgetFeaturePointSelector_H
 
 #include <ModelAPI_CompositeFeature.h>
 #include <ModuleBase_WidgetShapeSelector.h>
+#include <ModuleBase_ViewerPrs.h>
 
 #include "PartSet.h"
 #include "PartSet_MouseProcessor.h"
@@ -24,8 +37,10 @@ class ModuleBase_IWorkshop;
 class Config_WidgetAPI;
 class ModuleBase_IViewWindow;
 class ModuleBase_ViewerPrs;
+class PartSet_ExternalObjectsMgr;
 
 class GeomAPI_Pnt;
+class GeomAPI_Pnt2d;
 class GeomDataAPI_Point2D;
 
 class QWidget;
@@ -59,10 +74,6 @@ Q_OBJECT
   /// \return a boolean value
   virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
 
-  /// Activate or deactivate selection and selection filters
-  /// \return true if the selection filter of the widget is activated in viewer context
-  virtual bool activateSelectionAndFilters(bool toActivate);
-
   /// Set sketcher
   /// \param theSketch a sketcher object
   void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
@@ -83,17 +94,13 @@ Q_OBJECT
   /// \param theEvent a mouse event
   virtual void mouseReleased(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
 
-  /// 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);
+
+  /// Fills the attribute with the value of the selected owner
+  /// \param thePrs a selected owner
+  virtual bool setSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs);
 
   /// Fill preselection used in mouseReleased
-  virtual void setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected,
+  virtual void setPreSelection(const ModuleBase_ViewerPrsPtr& thePreSelected,
                                ModuleBase_IViewWindow* theWnd,
                                QMouseEvent* theEvent);
 protected:
@@ -102,14 +109,25 @@ protected:
   /// 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();
 
+  /// 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);
+
+  /// Creates a backup of the current values of the attribute
+  /// It should be realized in the specific widget because of different
+  /// parameters of the current attribute
+  /// \param theAttribute an attribute
+  /// \param theValid a boolean flag, if restore happens for valid parameters
+  void restoreAttributeValue(const AttributePtr& theAttribute, const bool theValid);
+
 protected:
-  bool fillFeature(const std::shared_ptr<ModuleBase_ViewerPrs>& theSelectedPrs,
-                   ModuleBase_IViewWindow* theWnd,
-                   QMouseEvent* theEvent);
+  bool fillFeature();
 
   /// Pointer to a sketch
   CompositeFeaturePtr mySketch;
@@ -120,6 +138,11 @@ protected:
   std::string mySelectedPointAttribute;
   std::string myPreviewObjectAttribute;
   std::string myPreviewPointAttribute;
+
+  bool myHasPreview;
+  std::shared_ptr<ModelAPI_Object> myPreviewObject;
+  std::shared_ptr<GeomAPI_Pnt2d>   myPreviewPoint;
+  PartSet_ExternalObjectsMgr* myExternalObjectMgr; ///< reference to external objects manager
 };
 
 #endif
\ No newline at end of file