SHAPER  9.12.0
ModuleBase_WidgetMultiSelector.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 MODULEBASE_WIDGETMULTISELECTOR_H_
21 #define MODULEBASE_WIDGETMULTISELECTOR_H_
22 
23 #include <ModuleBase.h>
24 #include <ModuleBase_WidgetSelector.h>
25 
26 #include <GeomAPI_Shape.h>
27 #include <ModelAPI_Result.h>
28 
29 #include <NCollection_List.hxx>
30 #include <TopoDS_Shape.hxx>
31 
32 #include <QList>
33 #include <QString>
34 #include <QStringList>
35 #include <QPair>
36 #include <QMap>
37 
38 class QWidget;
39 class QCheckBox;
40 class QPushButton;
41 class QVBoxLayout;
46 
62 {
63  Q_OBJECT
64  public:
70  ModuleBase_IWorkshop* theWorkshop,
71  const Config_WidgetAPI* theData);
73 
76  virtual QList<QWidget*> getControls() const;
77 
79  virtual void deactivate();
80 
82  virtual void updateAfterDeactivation();
83 
85  virtual void updateAfterActivation();
86 
91  virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
92  const bool theToValidate);
93 
96  virtual void getHighlighted(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
97 
101  virtual bool canProcessAction(ModuleBase_ActionType theActionType, bool& isActionEnabled);
102 
104  virtual bool processAction(ModuleBase_ActionType theActionType,
105  const ActionParamPtr& theParam = ActionParamPtr());
106 
110  virtual bool isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
111 
114  virtual QList<ActionInfo> actionsList(ModuleBase_ActionType theActionType) const;
115 
117  virtual void onFeatureAccepted();
118 
120  virtual bool isModified() const;
121 
122  virtual void setReadOnly(bool isReadOnly);
123 
124 public slots:
126  void onSelectionTypeChanged();
127 
128 protected:
131  virtual bool processSelection();
132 
133 protected slots:
135  void onDeleteItem();
136 
138  void onListSelection();
139 
140  void onListActivated();
141 
142  void onSameTopology(bool theOn);
143 
144  void onShowOnly(bool);
145 
146 protected:
148  virtual bool processDelete();
149 
151  virtual void activateCustom();
152 
155  virtual bool storeValueCustom();
156 
158  virtual bool restoreValueCustom();
159 
161  virtual void appendFirstSelectionInHistory();
162 
165  void appendSelectionInHistory();
166 
168  void clearSelectedHistory();
169 
171  virtual void updateFocus();
172 
174  virtual void updateSelectionName();
175 
178  virtual void updateOnSelectionChanged(const bool theDone);
179 
182  virtual QIntList shapeTypes() const;
183 
185  void setCurrentShapeType(const QString& theShapeType);
186 
190  virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
191 
193  void updateSelectionList();
194 
197  std::string validatorType(const QString& theType) const;
198 
200  void clearSelection();
201 
202 protected:
205  void getSelectedAttributeIndices(std::set<int>& theIndices);
206 
211  void convertIndicesToViewerSelection(std::set<int> theAttributeIds,
212  QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues) const;
213 
217  virtual bool removeUnusedAttributeObjects(
218  QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
219 
223  std::map<ObjectPtr, std::set<GeomShapePtr> > convertSelection
224  (QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
225 
232  static bool findInSelection(const ObjectPtr& theObject,
233  GeomShapePtr theShape,
234  const std::map<ObjectPtr, std::set<GeomShapePtr> >& theGeomSelection,
235  ModuleBase_IWorkshop* theWorkshop);
236 
237 protected:
239 
241 
242  QStringList myShapeTypes;
243 
246 
249 
252 
254  QList<QList<std::shared_ptr<ModuleBase_ViewerPrs> > > mySelectedHistoryValues;
255 
258 
259  bool myIsFirst;
260  std::string myDefMode;
261 
262  QVBoxLayout* myMainLayout;
263  QCheckBox* myGeomCheck;
264  ModuleBase_FilterStarter* myFiltersWgt;
265  QPushButton* myShowOnlyBtn;
266 
267  QObjectPtrList myVisibleObjects;
268  QStringList myAllowedObjects;
269  QStringList myTmpAllowed;
270  std::string myUseFilters;
271 };
272 
273 #endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */
Provides low-level API for WidgetFactory for reading xml definitions of widgets.
Definition: Config_WidgetAPI.h:46
A Choice control.
Definition: ModuleBase_ChoiceCtrl.h:42
An object which lets to start a Filters operation as a sub-operation of the current one.
Definition: ModuleBase_WidgetSelectionFilter.h:54
Class which provides access to Workshop object services.
Definition: ModuleBase_IWorkshop.h:48
An extension of QListWidget to provide Undo/Redo functionality.
Definition: ModuleBase_ListView.h:94
virtual bool processAction(ModuleBase_ActionType theActionType, const ActionParamPtr &theParam=ActionParamPtr())
Returns true if the event is processed. The default implementation is empty, returns false.
Definition: ModuleBase_ModelWidget.cpp:475
virtual QList< QWidget * > getControls() const =0
Returns list of widget controls.
virtual bool canProcessAction(ModuleBase_ActionType theActionType, bool &isActionEnabled)
Returns true if the action can be processed.
Definition: ModuleBase_ModelWidget.cpp:458
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 void updateAfterDeactivation()
Opportunity to do something after the active widget of the property panel changed.
Definition: ModuleBase_ModelWidget.h:207
virtual bool isModified() const
Returns True if data of its attribute was modified.
Definition: ModuleBase_ModelWidget.h:325
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 void getHighlighted(QList< std::shared_ptr< ModuleBase_ViewerPrs >> &theValues)
Returns values which should be highlighted when the whidget is active.
Definition: ModuleBase_ModelWidget.h:171
virtual void onFeatureAccepted()
It is called when user press Ok or OkPlus buttons in the parent property panel By default this slot d...
Definition: ModuleBase_ModelWidget.h:315
virtual QList< ActionInfo > actionsList(ModuleBase_ActionType theActionType) const
Returns list of accessible actions for Undo/Redo commands.
Definition: ModuleBase_ModelWidget.h:289
virtual void updateAfterActivation()
Opportunity to do something after the active widget of the property panel changed.
Definition: ModuleBase_ModelWidget.h:209
Implementation of widget for shapes selection.
Definition: ModuleBase_WidgetMultiSelector.h:62
QStringList myShapeTypes
List of Shape types defined in XML.
Definition: ModuleBase_WidgetMultiSelector.h:242
int myCurrentHistoryIndex
Position in a container of selected values.
Definition: ModuleBase_WidgetMultiSelector.h:257
bool myIsUseChoice
A flag to store use_choice parameter state.
Definition: ModuleBase_WidgetMultiSelector.h:240
QList< QList< std::shared_ptr< ModuleBase_ViewerPrs > > > mySelectedHistoryValues
A container of selected objects.
Definition: ModuleBase_WidgetMultiSelector.h:254
ModuleBase_ChoiceCtrl * myTypeCtrl
Control for types.
Definition: ModuleBase_WidgetMultiSelector.h:245
bool myIsSetSelectionBlocked
A flag to block set selection perform if the method is in process.
Definition: ModuleBase_WidgetMultiSelector.h:251
ModuleBase_ListView * myListView
List control.
Definition: ModuleBase_WidgetMultiSelector.h:238
bool myIsNeutralPointClear
A flag to clear selection by click in empty place in the viewer.
Definition: ModuleBase_WidgetMultiSelector.h:248
Implementation of widget for selection.
Definition: ModuleBase_WidgetSelector.h:43
virtual bool isValidSelectionCustom(const std::shared_ptr< ModuleBase_ViewerPrs > &thePrs)
Checks the widget validity.
Definition: ModuleBase_WidgetSelector.cpp:224
virtual QIntList shapeTypes() const =0
Retunrs a list of possible shape types.
virtual bool processSelection()
Returns true if envent is processed. The default implementation is empty, returns false.
Definition: ModuleBase_WidgetSelector.cpp:88
virtual void activateCustom()
The methiod called when widget is activated.
Definition: ModuleBase_WidgetSelector.cpp:215
virtual void updateOnSelectionChanged(const bool theDone)
Emits model changed info, updates the current control by selection change.
Definition: ModuleBase_WidgetSelector.cpp:102
virtual void deactivate()
The methiod called when widget is deactivated.
Definition: ModuleBase_WidgetSelector.cpp:254
virtual QList< std::shared_ptr< ModuleBase_ViewerPrs > > getAttributeSelection() const
Return the attribute values wrapped in a list of viewer presentations.
Definition: ModuleBase_WidgetSelector.cpp:134
virtual void updateFocus()
Update focus after the attribute value change.
Definition: ModuleBase_WidgetSelector.h:96
virtual void updateSelectionName()
Computes and updates name of selected object in the widget.
Definition: ModuleBase_WidgetSelector.h:108