1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef XGUI_SALOMECONNECTOR_H
21 #define XGUI_SALOMECONNECTOR_H
26 #include <QStringList>
28 #include <ModuleBase_ActionInfo.h>
31 class Config_FeatureMessage;
32 class ModuleBase_IViewer;
36 * An interface which provides a connection of XGUI functionality
37 * with functionality of SALOME module interface.
39 class XGUI_EXPORT XGUI_SalomeConnector
42 /// Default constructor
43 XGUI_SalomeConnector();
44 /// Virtual destructor
45 virtual ~XGUI_SalomeConnector();
47 //! Creates a feature (command) in SALOME desktop
48 //! \param theWBName - a workbench name
49 //! \param theTBName - a toolbar name
50 //! \param theId - an id of the feature
51 //! \param theTitle - a menu item string
52 //! \param theTip - a tooltip string (help)
53 //! \param theIcon - icon
54 //! \param isCheckable - is checkable or not
55 //! \param theKeys - hot keys
56 //! \param isAddSeparator boolean flag about adding separator after the action
57 //! returns created action
58 virtual QAction* addFeature(const QString& theWBName, const QString& theTBName,
60 const QString& theTitle, const QString& theTip,
62 const QKeySequence& theKeys, bool isCheckable,
63 const bool isAddSeparator,
64 const QString& theStatusTip) = 0;
66 //! Creates a feature (command) in SALOME desktop
67 //! \param theWBName - name of toolbar (workbench)
68 //! \param theInfo - information about action (icon, text, etc)
69 //! \param isAddSeparator boolean flag about adding separator after the action
70 virtual QAction* addFeature(const QString& theWBName,
71 const ActionInfo& theInfo, const bool isAddSeparator) = 0;
73 //! Creates a feature (command) in SALOME desktop
74 //! \param theWBName - name of toolbar (workbench)
75 //! \param theInfo - information about action (icon, text, etc)
76 //! \param theNestedActions a list of nested actions
77 virtual QAction* addFeatureOfNested(const QString& theWBName,
78 const ActionInfo& theInfo,
79 const QList<QAction*>& theNestedActions) = 0;
81 //! Returns true if the feature action is a nested action, in other words,
82 //! it is created by addFeatureOfNested().
83 //! \param theAction - an action of a feature
84 //! returns boolean result
85 virtual bool isFeatureOfNested(const QAction* theAction) = 0;
87 //! Creates a command in Edit menu of SALOME desktop
88 //! \param theId - an id of the feature
89 //! \param theTitle - a menu item string
90 //! \param theTip - a tooltip string (help)
91 //! \param theIcon - icon
92 //! \param isCheckable - is checkable or not
93 //! \param theKeys - hot keys
94 //! \param theMenuSourceText - a source text of the desktop menu
95 //! \param theSubMenu - a sub-menu name
96 //! \param theMenuPosition - a position of the command in the desktop menu
97 //! \param theSuibMenuPosition - a position of the sub-menu in the desktop menu
98 //! returns created action
99 virtual QAction* addDesktopCommand(const QString& theId, const QString& theTitle,
100 const QString& theTip, const QIcon& theIcon,
101 const QKeySequence& theKeys, bool isCheckable,
102 const char* theMenuSourceText,
103 const QString& theSubMenu = QString(),
104 const int theMenuPosition = 10,
105 const int theSuibMenuPosition = -1) = 0;
107 //! Insert separator into Edit menu of SALOME desktop
108 virtual void addDesktopMenuSeparator(const char* theMenuSourceText,
109 const int theMenuPosition = 10) = 0;
111 /// Add an action into tool bar
112 /// \param theAction the Action object
113 /// \param theToolBarTitle the toolbar name
114 virtual bool addActionInToolbar( QAction* theAction, const QString& theToolBarTitle ) = 0;
116 /// Creates menu/tool bar actions for loaded features stored in the menu manager
117 virtual void createFeatureActions() = 0;
119 //! Returns desktop window of SALOME
120 virtual QMainWindow* desktop() const = 0;
122 //! Returns list of defined actions (just by SHAPER module)
123 virtual QList<QAction*> commandList() const = 0;
125 //! Stores XML information for the feature kind
126 //! \param theFeatureId a feature kind
127 //! \param theMessage a container of the feature XML properties
128 virtual void setFeatureInfo(const QString& theFeatureId,
129 const std::shared_ptr<Config_FeatureMessage>& theMessage) = 0;
131 //! Returns XML information for the feature kind
132 //! \param theFeatureId a feature kind
133 //! \return theMessage a container of the feature XML properties
134 virtual std::shared_ptr<Config_FeatureMessage> featureInfo(const QString& theFeatureId) = 0;
136 //! Returns interface to Salome viewer
137 virtual ModuleBase_IViewer* viewer() const = 0;
139 //! Create preferences
140 virtual void createPreferences() = 0;
142 //! Shows the given text in status bar as a permanent text
143 //! \theInfo a string value
144 //! \theMsecs interval of msec milliseconds when the message will be hidden, if -1, it stays.
145 // If 0, default value is used, it is 3000
146 virtual void putInfo(const QString& theInfo, const int theMSecs = 0) = 0;