SHAPER  9.12.0
PartSet_WidgetBSplinePoints.h
1 // Copyright (C) 2019-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_WidgetBSplinePoints_H
21 #define PartSet_WidgetBSplinePoints_H
22 
23 #include "PartSet.h"
24 #include "PartSet_MouseProcessor.h"
25 
26 #include <ModuleBase_ModelWidget.h>
27 
28 #include <QObject>
29 
30 class GeomAPI_Pnt2d;
34 class QGroupBox;
35 class QScrollArea;
36 
48 {
49 Q_OBJECT
50 public:
56  const Config_WidgetAPI* theData);
58  virtual ~PartSet_WidgetBSplinePoints();
59 
63  virtual void selectionModes(int& theModuleSelectionModes, QIntList& theModes);
64 
68  virtual bool isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
69 
76  bool isValidSelectionForAttribute_(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue,
77  const std::shared_ptr<ModelAPI_Attribute>& theAttribute);
78 
81  bool setSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
82 
85  virtual QList<QWidget*> getControls() const;
86 
88  virtual void deactivate();
89 
91  std::shared_ptr<ModelAPI_CompositeFeature> sketch() const { return mySketch; }
92 
94  void setSketch(std::shared_ptr<ModelAPI_CompositeFeature> theSketch) { mySketch = theSketch; }
95 
100  bool setPoint(double theX, double theY);
101 
103  virtual bool processEscape();
104 
107  virtual bool useSelectedShapes() const;
108 
112  virtual void mouseMoved(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
113 
117  virtual void mouseReleased(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
118 
119 protected:
122  virtual bool storeValueCustom();
123 
125  virtual bool restoreValueCustom();
126 
128  void storeCurentValue();
129 
132  bool restoreCurentValue();
133 
136  virtual bool resetCustom();
137 
138 private:
140  void createNextPoint();
142  void removeLastPoint();
143 
145  void storePolesAndWeights() const;
146 
149  std::shared_ptr<ModelAPI_AttributeRefAttrList> attributeRefAttrList() const;
150 
151  void fillRefAttribute(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
152  void fillRefAttribute(std::shared_ptr<GeomAPI_Pnt2d> theClickedPoint,
153  const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
154  void fillRefAttribute(const ObjectPtr& theObject);
155 
156  ObjectPtr getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
157 
158 protected:
160 
161 private:
162  QGroupBox* myBox;
163  QWidget* myGroupBox;
164  QScrollArea* myScrollArea;
165  std::vector<ModuleBase_LabelValue*> myXSpin;
166  std::vector<ModuleBase_LabelValue*> myYSpin;
167  PartSet_ExternalObjectsMgr* myExternalObjectMgr;
168 
170  std::shared_ptr<ModuleBase_ViewerPrs> myPreSelected;
171 
173  CompositeFeaturePtr mySketch;
174 
175  std::string myRefAttribute;
176 
177  bool myValueIsCashed;
178  bool myIsFeatureVisibleInCash;
179  std::vector<double> myXValueInCash;
180  std::vector<double> myYValueInCash;
181  std::vector<double> myWeightInCash;
182 
183  std::string myWeightsAttr;
184 
185  int myPointIndex;
186 
187  bool myFinished;
188 };
189 
190 #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
Feature that consists of other features: like sketcher with edges inside.
Definition: ModelAPI_CompositeFeature.h:33
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 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 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 resetCustom()
Fills the widget with default values.
Definition: ModuleBase_ModelWidget.h:407
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 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 a list of 2D poles of B-spline curve in ass...
Definition: PartSet_WidgetBSplinePoints.h:48
std::shared_ptr< ModelAPI_CompositeFeature > sketch() const
Definition: PartSet_WidgetBSplinePoints.h:91
ModuleBase_IWorkshop * myWorkshop
workshop
Definition: PartSet_WidgetBSplinePoints.h:159
void setSketch(std::shared_ptr< ModelAPI_CompositeFeature > theSketch)
Set sketch instance.
Definition: PartSet_WidgetBSplinePoints.h:94