SHAPER 9.16.0
ModuleBase_WidgetMultiSelector.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 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
38class QWidget;
39class QCheckBox;
40class QPushButton;
41class 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
124public slots:
126 void onSelectionTypeChanged();
127
128protected:
131 virtual bool processSelection();
132
133protected 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 // Slot is called when filters are removed
147 void onRemoveFilters();
148
149protected:
151 virtual bool processDelete();
152
154 virtual void activateCustom();
155
158 virtual bool storeValueCustom();
159
161 virtual bool restoreValueCustom();
162
164 virtual void appendFirstSelectionInHistory();
165
168 void appendSelectionInHistory();
169
171 void clearSelectedHistory();
172
174 virtual void updateFocus();
175
177 virtual void updateSelectionName();
178
181 virtual void updateOnSelectionChanged(const bool theDone);
182
185 virtual QIntList shapeTypes() const;
186
188 void setCurrentShapeType(const QString& theShapeType);
189
193 virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
194
196 void updateSelectionList();
197
200 std::string validatorType(const QString& theType) const;
201
203 void clearSelection();
204
205protected:
208 void getSelectedAttributeIndices(std::set<int>& theIndices);
209
214 void convertIndicesToViewerSelection(std::set<int> theAttributeIds,
215 QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues) const;
216
220 virtual bool removeUnusedAttributeObjects(
221 QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
222
226 std::map<ObjectPtr, std::set<GeomShapePtr> > convertSelection
227 (QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
228
235 static bool findInSelection(const ObjectPtr& theObject,
236 GeomShapePtr theShape,
237 const std::map<ObjectPtr, std::set<GeomShapePtr> >& theGeomSelection,
238 ModuleBase_IWorkshop* theWorkshop);
239
240protected:
242
244
245 QStringList myShapeTypes;
246
249
252
255
257 QList<QList<std::shared_ptr<ModuleBase_ViewerPrs> > > mySelectedHistoryValues;
258
261
262 bool myIsFirst;
263 std::string myDefMode;
264
265 QVBoxLayout* myMainLayout;
266 QCheckBox* myGeomCheck;
267 ModuleBase_FilterStarter* myFiltersWgt;
268 QPushButton* myShowOnlyBtn;
269 QPushButton* myRemoveFiltersBtn;
270
271 QObjectPtrList myVisibleObjects;
272 QStringList myAllowedObjects;
273 QStringList myTmpAllowed;
274 std::string myUseFilters;
275};
276
277#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 void updateAfterDeactivation()
Opportunity to do something after the active widget of the property panel changed.
Definition: ModuleBase_ModelWidget.h:207
virtual QList< ActionInfo > actionsList(ModuleBase_ActionType theActionType) const
Returns list of accessible actions for Undo/Redo commands.
Definition: ModuleBase_ModelWidget.h:289
virtual bool isModified() const
Returns True if data of its attribute was modified.
Definition: ModuleBase_ModelWidget.h:325
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 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 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 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 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:245
int myCurrentHistoryIndex
Position in a container of selected values.
Definition: ModuleBase_WidgetMultiSelector.h:260
bool myIsUseChoice
A flag to store use_choice parameter state.
Definition: ModuleBase_WidgetMultiSelector.h:243
QList< QList< std::shared_ptr< ModuleBase_ViewerPrs > > > mySelectedHistoryValues
A container of selected objects.
Definition: ModuleBase_WidgetMultiSelector.h:257
ModuleBase_ChoiceCtrl * myTypeCtrl
Control for types.
Definition: ModuleBase_WidgetMultiSelector.h:248
bool myIsSetSelectionBlocked
A flag to block set selection perform if the method is in process.
Definition: ModuleBase_WidgetMultiSelector.h:254
ModuleBase_ListView * myListView
List control.
Definition: ModuleBase_WidgetMultiSelector.h:241
bool myIsNeutralPointClear
A flag to clear selection by click in empty place in the viewer.
Definition: ModuleBase_WidgetMultiSelector.h:251
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
Returns 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