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