1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PartSet_MenuMgr.h
4 // Created: 03 April 2015
5 // Author: Vitaly SMETANNIKOV
7 #ifndef PartSet_MenuMgr_H
8 #define PartSet_MenuMgr_H
10 #include <ModelAPI_Feature.h>
11 #include <ModelAPI_ResultPart.h>
19 class ModuleBase_Operation;
26 * A class for management of module specific menu
28 class PartSet_MenuMgr: public QObject
33 /// \param theModule a parent module
34 PartSet_MenuMgr(PartSet_Module* theModule);
37 /// Returns action according to the given ID
38 /// \param theId an action identifier, it should be uniqued in the bounds of the module
39 QAction* action(const QString& theId) const;
41 /// Add menu items for viewer into the actions map
42 /// \param theStdActions a map of standard actions
43 /// \param theParent a parent widget for the
44 /// \param theMenuActions map of action/menu for the desirable index in the viewer menu
45 /// \return true if items are added and there is no necessity to provide standard menu
46 bool addViewerMenu(const QMap<QString, QAction*>& theStdActions,
48 QMap<int, QAction*>& theMenuActions) const;
50 /// Update state of pop-up menu items in viewer
51 /// \param theStdActions - a map of standard actions
52 void updateViewerMenu(const QMap<QString, QAction*>& theStdActions);
54 /// Activates a PartSet document
55 void activatePartSet() const;
57 /// Returns list of granted operation indices
58 virtual void grantedOperationIds(ModuleBase_Operation* theOperation, QStringList& theIds) const;
60 /// Activates a Part document
61 void activatePart(ResultPartPtr thePart) const;
64 /// Processes the context menu action click
65 /// \param isChecked a state of toggle if the action is checkable
66 void onAction(bool isChecked);
70 /// A slot which is called on selection of menu item coresponding to line with coincedence
71 /// \param theAction an action of the selected item
72 void onLineHighlighted(QAction* theAction);
74 /// A slot which is called on hiding Detach menu
75 void onDetachMenuHide();
77 /// A slot which is called on selection an Item in Detach menu
78 /// \param theAction an action of the selected item
79 void onLineDetach(QAction* theAction);
81 /// A slot called on Part activation command
82 void onActivatePart(bool);
84 /// A slot called on PartSet activation command
85 void onActivatePartSet(bool);
87 /// A slot called on edit of feature
91 /// Redefinition of virtual method
92 /// \param theObj an object
93 /// \param theEvent an event
94 virtual bool eventFilter(QObject* theObj, QEvent* theEvent);
97 /// Returns true if the current operation is sketch entity create operation
98 /// \param theValue the current auxiliary value
99 /// \return the boolean result
100 bool canSetAuxiliary(bool& theValue) const;
102 /// Changes the sketcher entity construction argument value
103 /// \param isChecked if true, the feature is a construction
104 void setAuxiliary(const bool isChecked);
106 /// Create all actions for context menus. It is called on creation of module
107 /// Put the created actions into an internal map
108 void createActions();
110 /// Add action to the internal map
111 /// \param theId - string ID of the item
112 /// \param theAction - action to add
113 void addAction(const QString& theId, QAction* theAction);
115 /// Set color on presentation of result listed in myCoinsideLines
116 /// \param theId object Id in myCoinsideLines list
117 /// \param theColor a color which has to be set
118 /// \param theUpdate update viewer flag
119 /// \return previously defined color on the object
120 QColor setLineColor(int theId, const QColor theColor, bool theUpdate);
122 /// Reference to a parent module
123 PartSet_Module* myModule;
125 /// the popup menu actions
126 QMap<QString, QAction*> myActions;
128 /// List of lines coincided in a one point
129 mutable QList<FeaturePtr> myCoinsideLines;
131 /// A Coincedence feature selected by user for detaching
132 mutable FeaturePtr mySelectedFeature;
134 /// Id of menu item in Detach menu previously selected
137 /// Original color of highlighted line