SHAPER  9.12.0
PartSet_WidgetFeaturePointSelector.h
1 // Copyright (C) 2014-2023 CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef PartSet_WidgetFeaturePointSelector_H
21 #define PartSet_WidgetFeaturePointSelector_H
22 
23 #include <ModelAPI_CompositeFeature.h>
24 #include <ModuleBase_WidgetShapeSelector.h>
25 #include <ModuleBase_ViewerPrs.h>
26 
27 #include "PartSet.h"
28 #include "PartSet_MouseProcessor.h"
29 
30 #include <Quantity_Color.hxx>
31 
32 #include <QObject>
33 
34 #include <string>
35 
37 class Config_WidgetAPI;
41 
42 class GeomAPI_Pnt;
43 class GeomAPI_Pnt2d;
45 
46 class QWidget;
47 class QMouseEvent;
48 
57 {
58 Q_OBJECT
59  public:
65  const Config_WidgetAPI* theData);
66 
68 
75  virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
76 
79  void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
80 
82  CompositeFeaturePtr sketch() const { return mySketch; }
83 
85  virtual void deactivate();
86 
90  virtual void mouseMoved(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
91 
95  virtual void mouseReleased(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
96 
97 
100  virtual bool setSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs);
101 
103  virtual void setPreSelection(const ModuleBase_ViewerPrsPtr& thePreSelected,
104  ModuleBase_IViewWindow* theWnd,
105  QMouseEvent* theEvent);
106 protected:
110  virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
111 
113  virtual void activateCustom();
114 
119  virtual void getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
120  ObjectPtr& theObject, GeomShapePtr& theShape);
121 
127  void restoreAttributeValue(const AttributePtr& theAttribute, const bool theValid);
128 
129 protected:
130  bool fillFeature();
131 
133  CompositeFeaturePtr mySketch;
134  Quantity_Color myHighlightColor;
135  Quantity_Color mySelectionColor;
136 
137  std::string mySelectedObjectAttribute;
138  std::string mySelectedPointAttribute;
139  std::string myPreviewObjectAttribute;
140  std::string myPreviewPointAttribute;
141 
142  bool myHasPreview;
143  std::shared_ptr<ModelAPI_Object> myPreviewObject;
144  std::shared_ptr<GeomAPI_Pnt2d> myPreviewPoint;
146 };
147 
148 #endif
Provides low-level API for WidgetFactory for reading xml definitions of widgets.
Definition: Config_WidgetAPI.h:46
2D point defined by two coordinates
Definition: GeomAPI_Pnt2d.h:36
3D point defined by three coordinates
Definition: GeomAPI_Pnt.h:38
Attribute that contains 2D point coordinates.
Definition: GeomDataAPI_Point2D.h:37
Interface to ViewWindow object which contains 3d scene.
Definition: ModuleBase_IViewWindow.h:34
Class which provides access to Workshop object services.
Definition: ModuleBase_IWorkshop.h:48
Presentation.
Definition: ModuleBase_ViewerPrs.h:37
virtual void activateCustom()
The methiod called when widget is activated.
Definition: ModuleBase_WidgetSelector.cpp:215
virtual void getGeomSelection(const std::shared_ptr< ModuleBase_ViewerPrs > &thePrs, ObjectPtr &theObject, GeomShapePtr &theShape)
Return an object and geom shape by the viewer presentation.
Definition: ModuleBase_WidgetSelector.cpp:65
virtual bool setSelectionCustom(const std::shared_ptr< ModuleBase_ViewerPrs > &thePrs)
Fills the attribute with the value of the selected owner.
Definition: ModuleBase_WidgetSelector.cpp:242
virtual void deactivate()
The methiod called when widget is deactivated.
Definition: ModuleBase_WidgetSelector.cpp:254
Implementation of widget for shapes selection.
Definition: ModuleBase_WidgetShapeSelector.h:71
virtual QList< std::shared_ptr< ModuleBase_ViewerPrs > > getAttributeSelection() const
Return the attribute values wrapped in a list of viewer presentations.
Definition: ModuleBase_WidgetShapeSelector.cpp:149
virtual bool isValidSelection(const std::shared_ptr< ModuleBase_ViewerPrs > &theValue)
Checks all widget validator if the owner is valid.
Definition: ModuleBase_WidgetValidated.cpp:256
virtual void restoreAttributeValue(const AttributePtr &theAttribute, const bool theValid)
Creates a backup of the current values of the attribute It should be realized in the specific widget ...
Definition: ModuleBase_WidgetValidated.cpp:92
Customosation of ModuleBase_WidgetShapeSelector in order to provide working with sketch specific obje...
Definition: PartSet_ExternalObjectsMgr.h:43
This is an interface to allow processing of mouse events.
Definition: PartSet_MouseProcessor.h:40
virtual void mouseMoved(ModuleBase_IViewWindow *theWindow, QMouseEvent *theEvent)
Processing the mouse move event in the viewer.
Definition: PartSet_MouseProcessor.h:45
virtual void setPreSelection(const std::shared_ptr< ModuleBase_ViewerPrs > &thePreSelected, ModuleBase_IViewWindow *theWnd, QMouseEvent *theEvent)
Fill preselection used in mouseReleased.
Definition: PartSet_MouseProcessor.h:64
virtual void mouseReleased(ModuleBase_IViewWindow *theWindow, QMouseEvent *theEvent)
Processing the mouse release event in the viewer.
Definition: PartSet_MouseProcessor.h:55
Customosation of PartSet_WidgetFeaturePointSelector in order to visualize sub-shape by mouse move ove...
Definition: PartSet_WidgetFeaturePointSelector.h:57
CompositeFeaturePtr sketch() const
Retrurns installed sketcher.
Definition: PartSet_WidgetFeaturePointSelector.h:82
void setSketcher(CompositeFeaturePtr theSketch)
Set sketcher.
Definition: PartSet_WidgetFeaturePointSelector.h:79
PartSet_ExternalObjectsMgr * myExternalObjectMgr
reference to external objects manager
Definition: PartSet_WidgetFeaturePointSelector.h:145
CompositeFeaturePtr mySketch
Pointer to a sketch.
Definition: PartSet_WidgetFeaturePointSelector.h:133