SHAPER 9.16.0
PartSet_Module.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_Module_H
21#define PartSet_Module_H
22
23#include "PartSet.h"
24#include "PartSet_Tools.h"
25#include "PartSet_OverconstraintListener.h"
26#include "PartSet_SketcherMgr.h"
27
28#include <ModuleBase_IModule.h>
29#include <ModuleBase_Definitions.h>
30#include <ModelAPI_Feature.h>
31#include <ModelAPI_Attribute.h>
32#include <ModelAPI_CompositeFeature.h>
33
34#include <Events_Listener.h>
35
36//#include <StdSelect_FaceFilter.hxx>
37#include <TopoDS_Shape.hxx>
38#include <SelectMgr_ListOfFilter.hxx>
39#include <SelectMgr_Filter.hxx>
40
41#include <QMap>
42#include <QMenu>
43#include <QObject>
44#include <QModelIndex>
45
46#include <map>
47#include <memory>
48#include <string>
49
53
54class XGUI_Workshop;
55class PartSet_MenuMgr;
60class ModelAPI_Result;
61
62class QAction;
63
68class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule, public Events_Listener
69{
70Q_OBJECT
71
73enum RestartingMode {
74 RM_None,
75 RM_Forbided,
76 RM_LastFeatureUsed,
78 RM_EmptyFeatureUsed
79};
80
81public:
82
86 virtual ~PartSet_Module();
87
88 // Stores the current selection
89 virtual void storeSelection();
90
91 // Restores the current selection
92 virtual void restoreSelection();
93
95 virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
96 Config_WidgetAPI* theWidgetApi);
97
100 virtual ModuleBase_ModelWidget* activeWidget() const;
101
103 virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
104
112 virtual bool createWidgets(const FeaturePtr& theFeature, const QString& theXmlRepr,
113 QList<ModuleBase_ModelWidget*>& theWidgets) const;
114
117 virtual void editFeature(FeaturePtr theFeature);
118
121 virtual bool canCommitOperation() const;
122
127 virtual void launchOperation(const QString& theCmdId,
128 const bool& isStartAfterCommitOnly);
129
134 virtual void operationStarted(ModuleBase_Operation* theOperation);
135
139 virtual void operationResumed(ModuleBase_Operation* theOperation);
140
144 virtual void operationCommitted(ModuleBase_Operation* theOperation);
145
149 virtual void operationAborted(ModuleBase_Operation* theOperation);
150
154 virtual void operationStopped(ModuleBase_Operation* theOperation);
155
157 virtual ModuleBase_Operation* currentOperation() const;
158
161 virtual bool canUndo() const;
162
165 virtual bool canRedo() const;
166
171 virtual bool canApplyAction(const ObjectPtr& theObject, const QString& theActionId) const;
172
175 //virtual bool canCommitOperation() const;
176
180 virtual bool canEraseObject(const ObjectPtr& theObject) const;
181
186 virtual bool canDisplayObject(const ObjectPtr& theObject) const;
187
192 virtual bool canUsePreselection(const QString& thePreviousOperationKind,
193 const QString& theStartedOperationKind);
194
197 //virtual void processHiddenObject(const std::list<ObjectPtr>& theObjects);
198
203 virtual bool canActivateSelection(const ObjectPtr& theObject) const;
204
207 virtual void addObjectBrowserMenu(QMenu* theMenu) const;
208
214 virtual bool addViewerMenu(const QMap<QString, QAction*>& theStdActions,
215 QWidget* theParent,
216 QMap<int, QAction*>& theMenuActions) const;
217
220 virtual void activeSelectionModes(QIntList& theModes);
221
225 virtual void moduleSelectionModes(int theModesType, QIntList& theModes);
226
230 virtual void moduleSelectionFilters(const QIntList& theFilterTypes,
231 SelectMgr_ListOfFilter& theSelectionFilters);
232
233
236 bool isMouseOverWindow();
237
239 PartSet_SketcherMgr* sketchMgr() const { return mySketchMgr; }
240
242 PartSet_SketcherReentrantMgr* sketchReentranceMgr() const { return mySketchReentrantMgr; }
243
248 virtual void getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theSelected,
249 ObjectPtr& theObject, AttributePtr& theAttribute);
250
253 PartSet_OverconstraintListener* overconstraintListener() { return myOverconstraintListener; }
254
258 bool isSketchNeutralPointActivated() const;
259
261 virtual void closeDocument();
262
264 virtual void clearViewer();
265
268 virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
269
272 void setCustomized(const FeaturePtr& theFeature);
273
277 virtual bool isCustomPrsActivated(const ModuleBase_CustomizeFlag& theFlag) const;
278
283 virtual void activateCustomPrs(const FeaturePtr& theFeature,
284 const ModuleBase_CustomizeFlag& theFlag,
285 const bool theUpdateViewer);
286
290 virtual void deactivateCustomPrs(const ModuleBase_CustomizeFlag& theFlag,
291 const bool theUpdateViewer);
292
294 //virtual bool customisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
295 // AISObjectPtr thePrs,
296 // std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs);
297
299 //virtual bool afterCustomisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
300 // AISObjectPtr thePrs,
301 // GeomCustomPrsPtr theCustomPrs);
302
311 virtual bool customizeFeature(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag,
312 const bool theUpdateViewer);
313
316 virtual void disableCustomMode(ModuleBase_CustomizeFlag theMode);
317
319 virtual void enableCustomModes();
320
323 virtual void customizeObjectBrowser(QWidget* theObjectBrowser);
324
326 int getVisualLayerId() const { return myVisualLayerId; }
327
331 virtual AISObjectPtr createPresentation(const ObjectPtr& theResult);
332
336 virtual void customizePresentation(const ObjectPtr& theObject, const AISObjectPtr& thePrs) const;
337
339 virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const;
340
344 virtual bool canBeShaded(Handle(AIS_InteractiveObject) theAIS) const;
345
348 virtual void updateViewerMenu(const QMap<QString, QAction*>& theStdActions);
349
353 virtual bool isActionEnableStateFixed(const int theActionId) const;
354
358 virtual QString getFeatureError(const FeaturePtr& theFeature);
359
361 virtual void grantedOperationIds(ModuleBase_Operation* theOperation, QStringList& theIds) const;
362
365 virtual void widgetStateChanged(int thePreviousState);
366
369 virtual bool processEnter(const std::string& thePreviousAttributeID);
370
373 virtual void beforeOperationStopped(ModuleBase_Operation* theOperation);
374
378 virtual GeomShapePtr findShape(const AttributePtr& theAttribute);
379
384 virtual AttributePtr findAttribute(const ObjectPtr& theObject, const GeomShapePtr& theGeomShape);
385
387 virtual std::shared_ptr<Events_Message> reentrantMessage();
388
391 virtual void setReentrantPreSelection(const std::shared_ptr<Events_Message>& theMessage);
392
394 virtual ModuleBase_ITreeNode* rootNode() const;
395
397 XGUI_Workshop* getWorkshop() const;
398
400 virtual void createFeatures();
401
403 static void setTexture(const AISObjectPtr& thePrs, const ResultPtr& theResult);
404
405public slots:
409 virtual void onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS);
410
414 virtual void onBeforeObjectErase(ObjectPtr theObject, AISObjectPtr theAIS);
415
418 virtual void onViewTransformed(int theTrsfType = 2);
419
421 void onRemoveConflictingConstraints();
422
423protected slots:
425 virtual void onSelectionChanged();
426
430 void onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
431
433 void onViewCreated(ModuleBase_IViewWindow*);
434
439 void onChoiceChanged(ModuleBase_ModelWidget* theWidget, int theIndex);
440
441protected:
444 virtual void customSubShapesSelectionModes(QIntList& theModes);
445
449 void storeConstraintsState(const std::string& theFeatureKindId);
450
454 void updateConstraintsState(const std::string& theFeatureKind);
455
457 virtual void registerValidators();
458
462 virtual void connectToPropertyPanel(ModuleBase_ModelWidget* theWidget, const bool isToConnect);
463
466 void updateSketcherOnStart(ModuleBase_Operation* theOperation);
467
470 void updatePresentationsOnStart(ModuleBase_Operation* theOperation);
471
472 private slots:
473 void onTreeViewDoubleClick(const QModelIndex&);
474
475 void onActiveDocPopup(const QPoint&);
476
477 private:
479 virtual bool deleteObjects();
480
481 void setDefaultConstraintShown();
482
483private:
484 bool myIsOperationIsLaunched;
485
486 PartSet_SketcherMgr* mySketchMgr;
487 PartSet_SketcherReentrantMgr* mySketchReentrantMgr;
488 PartSet_MenuMgr* myMenuMgr;
490 PartSet_CustomPrs* myCustomPrs;
491 PartSet_OverconstraintListener* myOverconstraintListener;
492 int myVisualLayerId;
493
495 QMap<PartSet_Tools::ConstraintVisibleState, bool> myHasConstraintShown;
496
499 PartSet_SketcherMgr::FeatureToSelectionMap myCurrentSelection;
500 QModelIndex myActivePartIndex;
501
502 PartSet_RootNode* myRoot;
503};
504
505#endif
Provides low-level API for WidgetFactory for reading xml definitions of widgets.
Definition: Config_WidgetAPI.h:46
Base interface for any event listener.
Definition: Events_Listener.h:37
virtual EVENTS_EXPORT void processEvent(const std::shared_ptr< Events_Message > &theMessage)=0
This method is called by loop when the event is started to process.
The result of a feature.
Definition: ModelAPI_Result.h:37
Interface to a module.
Definition: ModuleBase_IModule.h:70
virtual bool canActivateSelection(const ObjectPtr &theObject) const
Make some functionality after the objects are hidden in viewer.
Definition: ModuleBase_IModule.cpp:337
virtual bool isCustomPrsActivated(const ModuleBase_CustomizeFlag &theFlag) const
Return true if the custom presentation is activated.
Definition: ModuleBase_IModule.h:271
virtual ModuleBase_ModelWidget * createWidgetByType(const std::string &theType, QWidget *theParent, Config_WidgetAPI *theWidgetApi)
Creates custom widgets for property panel.
Definition: ModuleBase_IModule.h:161
virtual void addObjectBrowserMenu(QMenu *theMenu) const
Add menu items for object browser into the given menu.
Definition: ModuleBase_IModule.h:150
virtual void grantedOperationIds(ModuleBase_Operation *theOperation, QStringList &theIds) const
Returns list of granted operation indices.
Definition: ModuleBase_IModule.cpp:180
virtual bool canUsePreselection(const QString &thePreviousOperationKind, const QString &theStartedOperationKind)
Returns whether the started operation may use preselection of the previous one Cases are: previous op...
Definition: ModuleBase_IModule.cpp:268
virtual void editFeature(FeaturePtr theFeature)
Launching of a edit operation on the feature.
Definition: ModuleBase_IModule.cpp:322
virtual AISObjectPtr createPresentation(const ObjectPtr &theResult)
Create specific for the module presentation.
Definition: ModuleBase_IModule.cpp:163
virtual void createFeatures()
Reads description of features from XML file.
Definition: ModuleBase_IModule.cpp:215
virtual void enableCustomModes()
Enables disabled custom mode.
Definition: ModuleBase_IModule.h:316
virtual bool canApplyAction(const ObjectPtr &theObject, const QString &theActionId) const =0
Returns true if the action can be applied to the object.
virtual ObjectPtr findPresentedObject(const AISObjectPtr &theAIS) const =0
Returns data object by AIS.
virtual void beforeOperationStopped(ModuleBase_Operation *theOperation)
Performs some GUI actions before an operation transaction is stopped Default realization is empty.
Definition: ModuleBase_IModule.h:382
virtual bool customizeFeature(ObjectPtr theObject, const ModuleBase_CustomizeFlag &theFlag, const bool theUpdateViewer)
Modifies the given presentation in the custom way.
Definition: ModuleBase_IModule.h:306
virtual AttributePtr findAttribute(const ObjectPtr &theObject, const GeomShapePtr &theGeomShape)=0
Finds an attribute by geom shape if it is possible.
virtual bool canUndo() const
Returns True if there are available Undos and there is not an active operation.
Definition: ModuleBase_IModule.cpp:285
virtual void storeSelection()
Stores the current selection.
Definition: ModuleBase_IModule.h:87
virtual void moduleSelectionFilters(const QIntList &theFilterTypes, SelectMgr_ListOfFilter &theSelectionFilters)=0
Appends into container of filters module filters corresponded to the modes type.
virtual void onBeforeObjectErase(ObjectPtr theObject, AISObjectPtr theAIS)
Slot called on before object erase.
Definition: ModuleBase_IModule.h:430
virtual void operationCommitted(ModuleBase_Operation *theOperation)
Realizes some functionality by an operation commit.
Definition: ModuleBase_IModule.h:130
virtual void operationAborted(ModuleBase_Operation *theOperation)
Realizes some functionality by an operation abort.
Definition: ModuleBase_IModule.h:133
virtual void clearViewer()=0
Clears specific presentations in the viewer.
virtual GeomShapePtr findShape(const AttributePtr &theAttribute)=0
Finds a shape by attribute if it is possible.
ModuleBase_CustomizeFlag
enumeration to know which objects should be customized
Definition: ModuleBase_IModule.h:74
virtual void connectToPropertyPanel(ModuleBase_ModelWidget *theWidget, const bool isToConnect)
Connects or disconnects to the value changed signal of the property panel widgets.
Definition: ModuleBase_IModule.h:370
virtual ModuleBase_ITreeNode * rootNode() const =0
Returns root tree node which represents a data model.
virtual void updateViewerMenu(const QMap< QString, QAction * > &theStdActions)
Update state of pop-up menu items in viewer.
Definition: ModuleBase_IModule.h:352
virtual void customizePresentation(const ObjectPtr &theObject, const AISObjectPtr &thePrs) const
Customize presentation according to objects attributes.
Definition: ModuleBase_IModule.h:335
virtual void operationResumed(ModuleBase_Operation *theOperation)
Realizes some functionality by an operation resume By default it emits operationResumed signal.
Definition: ModuleBase_IModule.cpp:344
virtual void moduleSelectionModes(int theModesType, QIntList &theModes)=0
Appends specific selection modes for the module to the list of types.
virtual ModuleBase_ModelWidget * activeWidget() const =0
Returns the active widget, by default it is the property panel active widget.
virtual void deactivateCustomPrs(const ModuleBase_CustomizeFlag &theFlag, const bool theUpdateViewer)
Deactivate custom presentation for the object.
Definition: ModuleBase_IModule.h:285
virtual ModuleBase_Operation * currentOperation() const =0
Realizes some functionality by an operation start.
virtual void onViewTransformed(int theTrsfType=2)
Called on transformation in current viewer.
Definition: ModuleBase_IModule.h:434
virtual bool canRedo() const
Returns True if there are available Redos and there is not an active operation.
Definition: ModuleBase_IModule.cpp:291
virtual void customizeObjectBrowser(QWidget *theObjectBrowser)
This method is called on object browser creation for customization of module specific features.
Definition: ModuleBase_IModule.h:320
virtual QString getFeatureError(const FeaturePtr &theFeature)
Returns the feature error if the current state of the feature in the module is not correct If the fea...
Definition: ModuleBase_IModule.cpp:173
virtual void operationStopped(ModuleBase_Operation *theOperation)
Realizes some functionality by an operation stop.
Definition: ModuleBase_IModule.h:127
virtual void restoreSelection()
Restores the current selection.
Definition: ModuleBase_IModule.h:90
virtual void operationStarted(ModuleBase_Operation *theOperation)
Realizes some functionality by an operation start.
Definition: ModuleBase_IModule.h:119
virtual void activateCustomPrs(const FeaturePtr &theFeature, const ModuleBase_CustomizeFlag &theFlag, const bool theUpdateViewer)
Activate custom presentation for the object.
Definition: ModuleBase_IModule.h:278
virtual bool addViewerMenu(const QMap< QString, QAction * > &theStdActions, QWidget *theParent, QMap< int, QAction * > &theMenuActions) const
Add menu items for viewer into the actions map.
Definition: ModuleBase_IModule.h:143
virtual bool canEraseObject(const ObjectPtr &theObject) const
Returns True if the current operation can be committed.
Definition: ModuleBase_IModule.cpp:258
virtual bool canDisplayObject(const ObjectPtr &theObject) const
Returns whether the object can be displayed.
Definition: ModuleBase_IModule.cpp:263
virtual void widgetStateChanged(int thePreviousState)
Validates the operation to change the "Apply" button state.
Definition: ModuleBase_IModule.h:374
virtual void registerValidators()
Register validators for this module.
Definition: ModuleBase_IModule.h:442
virtual bool deleteObjects()
Reacts to the delete action in module.
Definition: ModuleBase_IModule.h:230
virtual bool createWidgets(const FeaturePtr &theFeature, const QString &theXmlRepr, QList< ModuleBase_ModelWidget * > &theWidgets) const
Have an opportunity to create widgets for the current operation instead of standard creation in works...
Definition: ModuleBase_IModule.h:184
virtual bool isActionEnableStateFixed(const int theActionId) const
Returns true if the action should be always enabled.
Definition: ModuleBase_IModule.h:357
virtual void launchOperation(const QString &theCmdId, const bool &isStartAfterCommitOnly)
Creates an operation and send it to loop.
Definition: ModuleBase_IModule.cpp:108
virtual void propertyPanelDefined(ModuleBase_Operation *theOperation)
Call back forlast tuning of property panel before operation performance It is called as on clearing o...
Definition: ModuleBase_IModule.h:176
virtual void onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS)
Slot called on object display.
Definition: ModuleBase_IModule.h:425
virtual void setReentrantPreSelection(const std::shared_ptr< Events_Message > &theMessage)=0
Put current selection into reentrant message.
virtual bool processEnter(const std::string &thePreviousAttributeID)
Returns true if the event is processed.
Definition: ModuleBase_IModule.h:378
virtual std::shared_ptr< Events_Message > reentrantMessage()=0
Returns reentrant message if it was accepted.
virtual void disableCustomMode(ModuleBase_CustomizeFlag theMode)
Disable displaying of custom mode.
Definition: ModuleBase_IModule.h:313
virtual void activeSelectionModes(QIntList &theModes)
Returns a list of modes, where the AIS objects should be activated.
Definition: ModuleBase_IModule.h:240
virtual void closeDocument()=0
Performs functionality on closing document.
virtual void onSelectionChanged()
Called on selection changed event.
Definition: ModuleBase_IModule.h:438
virtual bool canBeShaded(Handle theAIS) const
Returns true if the presentation can be shown in shading mode.
Definition: ModuleBase_IModule.cpp:168
virtual bool canCommitOperation() const
Returns true if the operation can be committed.
Definition: ModuleBase_IModule.h:104
Definition: ModuleBase_ITreeNode.h:44
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
An abstract custom widget class.
Definition: ModuleBase_ModelWidget.h:60
Base class for all operations.
Definition: ModuleBase_Operation.h:53
Presentation.
Definition: ModuleBase_ViewerPrs.h:37
This is the module custom presentation, which manage an AIS presentation, that can be filled by a fea...
Definition: PartSet_CustomPrs.h:46
A class for management of module specific menu.
Definition: PartSet_MenuMgr.h:42
Implementation of Partset module.
Definition: PartSet_Module.h:69
PartSet_SketcherMgr * sketchMgr() const
Returns sketch manager object.
Definition: PartSet_Module.h:239
void setCustomized(const FeaturePtr &theFeature)
Set the object with the object results are customized.
int getVisualLayerId() const
Returns the viewer Z layer.
Definition: PartSet_Module.h:326
PartSet_SketcherReentrantMgr * sketchReentranceMgr() const
Returns sketch reentrant manager.
Definition: PartSet_Module.h:242
PartSet_OverconstraintListener * overconstraintListener()
Returns listener of overconstraint signal.
Definition: PartSet_Module.h:253
A class for processing overconstraint situation.
Definition: PartSet_OverconstraintListener.h:40
Implementation of Root node in data tree.
Definition: PartSet_TreeNodes.h:208
A class for management of sketch operations At the time of the sketcher operation active,...
Definition: PartSet_SketcherMgr.h:107
It provides reentrant create operations in sketch, that is when all inputs are valid,...
Definition: PartSet_SketcherReentrantMgr.h:57
Class which defines a configuration of the application (Workshop) and launches it.
Definition: XGUI_Workshop.h:83