Salome HOME
"2.11 Constraint with a point from the intersection between an outer edge and plane...
[modules/shaper.git] / src / PartSet / PartSet_MenuMgr.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_MenuMgr.h
4 // Created:     03 April 2015
5 // Author:      Vitaly SMETANNIKOV
6
7 #ifndef PartSet_MenuMgr_H
8 #define PartSet_MenuMgr_H
9
10 #include <ModelAPI_Feature.h>
11
12 #include <QObject>
13 #include <QMap>
14 #include <QString>
15 #include <QList>
16 #include <QColor>
17
18 class ModuleBase_Operation;
19 class PartSet_Module;
20 class QAction;
21 class QMenu;
22
23 /**
24 * \ingroup Modules
25 * A class for management of module specific menu
26 */
27 class PartSet_MenuMgr: public QObject
28 {
29   Q_OBJECT
30 public:
31   /// Constructor
32   /// \param theModule a parent module
33   PartSet_MenuMgr(PartSet_Module* theModule);
34
35
36   /// Returns action according to the given ID
37   /// \param theId an action identifier, it should be uniqued in the bounds of the module
38   QAction* action(const QString& theId) const;
39
40   /// Add menu atems for viewer into the given menu
41   /// \param theMenu a popup menu to be shown in the viewer
42   /// \param theStdActions a map of standard actions
43   /// \return true if items are added and there is no necessity to provide standard menu
44   bool addViewerMenu(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const;
45
46   /// Update state of pop-up menu items in viewer
47   /// \param theStdActions - a map of standard actions
48   void updateViewerMenu(const QMap<QString, QAction*>& theStdActions); 
49
50   /// Activates a PartSet document
51   void activatePartSet() const;
52
53   /// Returns list of granted operation indices
54   virtual void grantedOperationIds(ModuleBase_Operation* theOperation, QStringList& theIds) const;
55
56 public slots:
57   /// Processes the context menu action click
58   /// \param isChecked a state of toggle if the action is checkable
59   void onAction(bool isChecked);
60
61 private slots:
62
63   /// A slot which is called on selection of menu item coresponding to line with coincedence
64   /// \param theAction an action of the selected item
65   void onLineHighlighted(QAction* theAction);
66
67   /// A slot which is called on hiding Detach menu
68   void onDetachMenuHide();
69
70   /// A slot which is called on selection an Item in Detach menu
71   /// \param theAction an action of the selected item
72   void onLineDetach(QAction* theAction);
73
74   /// A slot called on Part activation command
75   void onActivatePart(bool);
76
77   /// A slot called on PartSet activation command
78   void onActivatePartSet(bool);
79
80   /// A slot called on edit of feature
81   void onEdit(bool);
82
83   void onSelectParentFeature();
84
85 protected:
86   bool eventFilter(QObject* theObj, QEvent* theEvent);
87
88 private:
89   /// Returns true if the current operation is sketch entity create operation
90   /// \param theValue the current auxiliary value
91   /// \return the boolean result
92   bool canSetAuxiliary(bool& theValue) const;
93   
94   /// Changes the sketcher entity construction argument value
95   /// \param isChecked if true, the feature is a construction
96   void setAuxiliary(const bool isChecked);
97
98   /// Create all actions for context menus. It is called on creation of module
99   /// Put the created actions into an internal map
100   void createActions();
101
102   /// Add action to the internal map
103   /// \param theId - string ID of the item
104   /// \param theAction - action to add
105   void addAction(const QString& theId, QAction* theAction);
106
107   /// Set color on presentation of result listed in myCoinsideLines
108   /// \param theId object Id in myCoinsideLines list
109   /// \param theColor a color which has to be set
110   /// \param theUpdate update viewer flag
111   /// \return previously defined color on the object
112   QColor setLineColor(int theId, const QColor theColor, bool theUpdate);
113
114   /// Reference to a parent module
115   PartSet_Module* myModule;
116
117   /// the popup menu actions
118   QMap<QString, QAction*> myActions; 
119
120   /// List of lines coincided in a one point
121   mutable QList<FeaturePtr> myCoinsideLines;
122
123   /// A Coincedence feature selected by user for detaching
124   mutable FeaturePtr mySelectedFeature;
125
126   /// Id of menu item in Detach menu previously selected
127   int myPrevId;
128
129   /// Original color of highlighted line 
130   QColor myColor;
131 };
132
133 #endif