]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_MenuMgr.h
Salome HOME
Compsolid creation in extrusion
[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 PartSet_Module;
19 class QAction;
20 class QMenu;
21
22 /**
23 * \ingroup Modules
24 * A class for management of module specific menu
25 */
26 class PartSet_MenuMgr: public QObject
27 {
28   Q_OBJECT
29 public:
30   /// Constructor
31   /// \param theModule a parent module
32   PartSet_MenuMgr(PartSet_Module* theModule);
33
34
35   /// Returns action according to the given ID
36   /// \param theId an action identifier, it should be uniqued in the bounds of the module
37   QAction* action(const QString& theId) const;
38
39   /// Add menu atems for viewer into the given menu
40   /// \param theMenu a popup menu to be shown in the viewer
41   /// \param theStdActions a map of standard actions
42   /// \return true if items are added and there is no necessity to provide standard menu
43   bool addViewerMenu(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const;
44
45   /// Update state of pop-up menu items in viewer
46   /// \param theStdActions - a map of standard actions
47   void updateViewerMenu(const QMap<QString, QAction*>& theStdActions); 
48
49 public slots:
50   /// Processes the context menu action click
51   /// \param isChecked a state of toggle if the action is checkable
52   void onAction(bool isChecked);
53
54 private slots:
55
56   /// A slot which is called on selection of menu item coresponding to line with coincedence
57   /// \param theAction an action of the selected item
58   void onLineHighlighted(QAction* theAction);
59
60   /// A slot which is called on hiding Detach menu
61   void onDetachMenuHide();
62
63   /// A slot which is called on selection an Item in Detach menu
64   /// \param theAction an action of the selected item
65   void onLineDetach(QAction* theAction);
66
67   /// A slot called on Part activation command
68   void onActivatePart(bool);
69
70   /// A slot called on PartSet activation command
71   void onActivatePartSet(bool);
72
73   /// A slot called on edit of feature
74   void onEdit(bool);
75
76 private:
77   /// Returns true if the current operation is sketch entity create operation
78   /// \param theValue the current auxiliary value
79   /// \return the boolean result
80   bool canSetAuxiliary(bool& theValue) const;
81   
82   /// Changes the sketcher entity construction argument value
83   /// \param isChecked if true, the feature is a construction
84   void setAuxiliary(const bool isChecked);
85
86   /// Create all actions for context menus. It is called on creation of module
87   /// Put the created actions into an internal map
88   void createActions();
89
90   /// Add action to the internal map
91   /// \param theId - string ID of the item
92   /// \param theAction - action to add
93   void addAction(const QString& theId, QAction* theAction);
94
95   /// Set color on presentation of result listed in myCoinsideLines
96   /// \param theId object Id in myCoinsideLines list
97   /// \param theColor a color which has to be set
98   /// \param theUpdate update viewer flag
99   /// \return previously defined color on the object
100   QColor setLineColor(int theId, const QColor theColor, bool theUpdate);
101
102   /// Reference to a parent module
103   PartSet_Module* myModule;
104
105   /// the popup menu actions
106   QMap<QString, QAction*> myActions; 
107
108   /// List of lines coincided in a one point
109   mutable QList<FeaturePtr> myCoinsideLines;
110
111   /// A Coincedence feature selected by user for detaching
112   mutable FeaturePtr mySelectedFeature;
113
114   /// Id of menu item in Detach menu previously selected
115   int myPrevId;
116
117   /// Original color of highlighted line 
118   QColor myColor;
119 };
120
121 #endif