Salome HOME
Merge branch 'BR_IMPROVEMENTS' of ssh://git.salome-platform.org/modules/hydro into...
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Operation.h
1 // Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef HYDROGUI_OPERATION_H
24 #define HYDROGUI_OPERATION_H
25
26 #include <LightApp_Operation.h>
27
28 #include <QCursor>
29
30 class HYDROGUI_Module;
31 class HYDROGUI_InputPanel;
32 class HYDROGUI_Shape;
33
34 class SUIT_SelectionMgr;
35 class OCCViewer_ViewManager;
36
37 class Handle_HYDROData_Document;
38 class Handle_HYDROData_Object;
39
40 class HYDROGUI_Operation : public LightApp_Operation
41 {
42   Q_OBJECT
43
44 public:
45
46   HYDROGUI_Operation( HYDROGUI_Module* theModule );
47   virtual ~HYDROGUI_Operation();
48
49 public:
50
51   void                                setName( const QString& theName );
52   const QString&                      getName() const;
53
54   HYDROGUI_InputPanel*                inputPanel() const;
55   SUIT_SelectionMgr*                  selectionMgr() const;
56   HYDROGUI_Module*                    module() const;
57
58   int                                 getPreviewZLayer() const;
59   virtual void                        updatePreviewZLayer( int theLayer );
60
61 signals:
62   void                                helpContextModule( const QString&,
63                                                          const QString&,
64                                                          const QString& );
65
66 protected:
67   virtual void                        startOperation();
68   virtual void                        abortOperation();
69   virtual void                        commitOperation();
70   virtual void                        stopOperation();
71   virtual void                        setDialogActive( const bool );
72
73   virtual HYDROGUI_InputPanel*        createInputPanel() const;
74   virtual void                        closeInputPanel();
75
76   virtual bool                        processApply( int& theUpdateFlags, QString& theErrorMsg,
77                                                     QStringList& theBrowseObjectsEntries );
78   virtual void                        processCancel();
79
80   void                                startDocOperation();
81   void                                abortDocOperation();
82   void                                commitDocOperation();
83
84   Handle_HYDROData_Document           doc() const;
85
86   virtual bool                        isToAbortOnApply() const { return true; }
87
88   void                                printErrorMessage( const QString& theErrorMsg );
89   void                                setPrintErrorMessage( const bool theIsPrint );
90
91   void                                browseObjects( const QStringList& theBrowseObjectsEntries,
92                                                      const bool theIsApplyAndClose = true );
93
94 protected slots:
95
96   virtual void                        onApplyAndClose();
97   virtual void                        onApply();
98   virtual void                        onCancel();
99   virtual void                        onHelp();
100
101 protected:
102
103   QString                             getHelpComponent() const;
104   QString                             getHelpFile() const;
105   QString                             getHelpContext() const;
106
107   virtual void                        setPreviewZLayer( int theLayer );
108   virtual HYDROGUI_Shape*             getPreviewShape() const;
109   OCCViewer_ViewManager*              getPreviewManager();
110   void                                setPreviewManager( OCCViewer_ViewManager* theManager );
111
112   /**
113    * Set specific cursor chosen in preferences for edition operations.
114    */
115   virtual void                        setCursor();
116   /**
117    * Restore the default cursor.
118    */
119   virtual void                        restoreCursor();
120
121   /**
122    * Set flag indicating, if 'Apply and Close' button is clicked on input panel.
123    * @param theFlag a flag value to be set
124    */
125   virtual void                        setIsApplyAndClose( const bool theFlag );
126   /**
127    * Get flag indicating, if 'Apply and Close' button is clicked on input panel.
128    * \return a flag value
129    */
130   virtual bool                        isApplyAndClose() const;
131
132   /**
133    * Apply changes done by this operation.
134    */
135   virtual void                        apply();
136
137 private:
138
139   HYDROGUI_Module*                    myModule;
140   HYDROGUI_InputPanel*                myPanel;
141   OCCViewer_ViewManager*              myPreviewManager;
142   QString                             myName;
143   bool                                myIsPrintErrorMessage;
144   bool                                myIsTransactionOpened;
145   int                                 myPreviewZLayer;
146
147   QCursor                             myCursor;
148
149   bool                                myIsApplyAndClose;
150 };
151
152 #endif