SHAPER 9.16.0
PartSet_WidgetPoint2d.h
1// Copyright (C) 2014-2026 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_WidgetPoint2D_H
21#define PartSet_WidgetPoint2D_H
22
23#include "PartSet.h"
24#include "PartSet_MouseProcessor.h"
25
26#include <ModelAPI_CompositeFeature.h>
27#include <ModuleBase_ModelWidget.h>
28#include <ModuleBase_ViewerPrs.h>
29
30#include <QObject>
31
32#include <TopoDS_Shape.hxx>
33#include <V3d_View.hxx>
34
43class GeomAPI_Pnt2d;
45
46class QGroupBox;
47class QMouseEvent;
48
57class PARTSET_EXPORT PartSet_WidgetPoint2D : public ModuleBase_ModelWidget,
59{
60Q_OBJECT
61 public:
66 PartSet_WidgetPoint2D(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
67 const Config_WidgetAPI* theData);
69 virtual ~PartSet_WidgetPoint2D();
70
74 virtual void selectionModes(int& theModuleSelectionModes, QIntList& theModes);
75
79 virtual bool isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
80
87 bool isValidSelectionForAttribute_(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue,
88 const std::shared_ptr<ModelAPI_Attribute>& theAttribute);
89
92 bool setSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
93
98 virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
99 const bool theToValidate);
100
102 //virtual void selectContent();
103
106 virtual QList<QWidget*> getControls() const;
107
108 //bool initFromPrevious(ObjectPtr theObject);
109
111 virtual void deactivate();
112
114 CompositeFeaturePtr sketch() const { return mySketch; }
115
117 void setSketch(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
118
123 bool setPoint(double theX, double theY);
124
126 double x() const;
127
129 double y() const;
130
132 virtual bool processEnter();
133
136 virtual bool useSelectedShapes() const;
137
141 virtual void mouseMoved(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
142
146 virtual void mouseReleased(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
147
149 //virtual void setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected);
150 virtual void setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected,
152 QMouseEvent* theEvent);
153
158 void getGeomSelection_(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue,
159 std::shared_ptr<ModelAPI_Object>& theObject,
160 std::shared_ptr<GeomAPI_Shape>& theShape);
161
164 PartSet_ExternalObjectsMgr* getExternalObjectMgr() const { return myExternalObjectMgr; }
165
166signals:
169
170protected:
173 virtual bool storeValueCustom();
174
176 virtual bool restoreValueCustom();
177
179 void storeCurentValue();
180
183 bool restoreCurentValue();
184
187 virtual bool resetCustom();
188
190 virtual void activateCustom();
191
193 virtual void setHighlighted(bool isHighlighted);
194
201 bool isFeatureContainsPoint(const FeaturePtr& theFeature, double theX, double theY);
202
203//private slots:
205 //void onValuesChanged();
206
212 virtual void initializeValueByActivate();
213
214 private:
218 bool setConstraintToPoint(double theClickedX, double theClickedY,
219 const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
220
224 bool setConstraintToObject(const ObjectPtr& theObject);
225
230 void processSelection(const ModuleBase_ViewerPrsPtr& theValue, double theX, double theY);
231
232public:
242 static bool isOrphanPoint(const FeaturePtr& theFeature, const CompositeFeaturePtr& theSketch,
243 double theX, double theY);
244
249 static bool shapeExploreHasVertex(const std::shared_ptr<GeomAPI_Shape>& theShape,
250 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint,
251 const CompositeFeaturePtr& theSketch);
252
257 static std::shared_ptr<GeomDataAPI_Point2D> findFirstEqualPointInArgumentFeatures(
258 const FeaturePtr& theFeature, const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
259
264 static std::shared_ptr<GeomDataAPI_Point2D> findFirstEqualPoint(const FeaturePtr& theFeature,
265 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
266
272 static std::shared_ptr<GeomDataAPI_Point2D> findFirstEqualPointInSketch(
273 const CompositeFeaturePtr& theSketch,
274 const FeaturePtr& theSkipFeature,
275 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
276
277private:
280 std::shared_ptr<ModelAPI_AttributeRefAttr> attributeRefAttr() const;
281
285 void fillRefAttribute(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
286 void fillRefAttribute(double theClickedX, double theClickedY,
287 const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
288 void fillRefAttribute(const ObjectPtr& theObject);
289
290 ObjectPtr getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
291
292protected:
294
295private:
296 QGroupBox* myGroupBox;
297 //ModuleBase_ParamSpinBox* myXSpin; ///< the spin box for the X coordinate
298 //ModuleBase_ParamSpinBox* myYSpin; ///< the spin box for the Y coordinate
299 ModuleBase_LabelValue* myXSpin;
300 ModuleBase_LabelValue* myYSpin;
301 PartSet_ExternalObjectsMgr* myExternalObjectMgr;
302
304 std::shared_ptr<ModuleBase_ViewerPrs> myPreSelected;
305
307 CompositeFeaturePtr mySketch;
308
309 std::string myRefAttribute;
310 bool myValueIsCashed;
311 bool myIsFeatureVisibleInCash;
312 double myXValueInCash;
313 double myYValueInCash;
314};
315
316#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
Attribute that contains 2D point coordinates.
Definition: GeomDataAPI_Point2D.h:37
Attribute that contains reference to an attribute of a feature or reference to a feature (switchable)
Definition: ModelAPI_AttributeRefAttr.h:33
Feature function that represents the particular functionality of this operation.
Definition: ModelAPI_Feature.h:41
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
Implementation of model widget for a label control.
Definition: ModuleBase_LabelValue.h:34
An abstract custom widget class.
Definition: ModuleBase_ModelWidget.h:60
virtual void selectionModes(int &theModuleSelectionModes, QIntList &theModes)
Fills given container with selection modes if the widget has it.
Definition: ModuleBase_ModelWidget.cpp:116
virtual void setHighlighted(bool isHighlighted)
Switch On/Off highlighting of the widget.
Definition: ModuleBase_ModelWidget.cpp:234
virtual void activateCustom()
The method called when widget is activated.
Definition: ModuleBase_ModelWidget.h:410
virtual bool isValidSelectionCustom(const std::shared_ptr< ModuleBase_ViewerPrs > &theValue)
Checks if the selection presentation is valid in widget.
Definition: ModuleBase_ModelWidget.h:176
virtual QList< QWidget * > getControls() const =0
Returns list of widget controls.
virtual bool processSelection()
Returns true if envent is processed. It applies workshop selection for the widget attribute.
Definition: ModuleBase_ModelWidget.cpp:515
virtual void initializeValueByActivate()
Compute the feature default value and fill the controls with it or store the control value to the fea...
Definition: ModuleBase_ModelWidget.cpp:315
virtual void deactivate()
The method called when widget is deactivated.
Definition: ModuleBase_ModelWidget.cpp:303
virtual bool storeValueCustom()=0
Saves the internal parameters to the given feature.
virtual bool restoreValueCustom()=0
Restore value from attribute data to the widget's control.
virtual bool setSelection(QList< std::shared_ptr< ModuleBase_ViewerPrs > > &theValues, const bool theToValidate)
Set the given wrapped value to the current widget This value should be processed in the widget accord...
Definition: ModuleBase_ModelWidget.h:163
virtual bool resetCustom()
Fills the widget with default values.
Definition: ModuleBase_ModelWidget.h:407
An extension of a double spin box which let to use parameters and expressions for value definition.
Definition: ModuleBase_ParamSpinBox.h:37
Customosation of ModuleBase_WidgetShapeSelector in order to provide working with sketch specific obje...
Definition: PartSet_ExternalObjectsMgr.h:43
Interface for mouse events processing.
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
Implementation of model widget to provide widget to input point 2d In XML can be defined as folloung:
Definition: PartSet_WidgetPoint2d.h:59
void setSketch(CompositeFeaturePtr theSketch)
Set sketch instance.
Definition: PartSet_WidgetPoint2d.h:117
ModuleBase_IWorkshop * myWorkshop
workshop
Definition: PartSet_WidgetPoint2d.h:293
void vertexSelected()
Signal about selection of an existing vertex from an object.
CompositeFeaturePtr sketch() const
Definition: PartSet_WidgetPoint2d.h:114
PartSet_ExternalObjectsMgr * getExternalObjectMgr() const
Return reference to external objects manager.
Definition: PartSet_WidgetPoint2d.h:164