Salome HOME
Initialisation de la base KERNEL avec la version operationnelle de KERNEL_SRC issue...
[modules/kernel.git] / src / SALOMEGUI / QAD_Operation.cxx
1 using namespace std;
2 //  File      : QAD_Operation.cxx
3 //  Created   : UI team, 22.09.00
4 //  Descrip   : Base class for operations in QAD-based application
5 //  Author    : UI team
6 //  Project   : SALOME
7 //  Module    : SALOMEGUI
8 //  Copyright : Open CASCADE 2001
9 //  $Header$
10
11 /*!
12   \class QAD_Operation QAD_Operation.h
13   \brief Base class for OCAF operations in QAD-based application.
14 */
15
16 #include "QAD.h"
17 #include "QAD_Operation.h"
18 #include "QAD_Study.h"
19 #include "QAD_Application.h"
20
21 // QT Include
22 #include <qapplication.h>
23
24 /*!
25     Constructor 
26 */
27 QAD_Operation::QAD_Operation (QAD_Study* doc) :
28 myDoc ( doc )
29 {
30   /* this class is useless without valid doc */
31   QAD_ASSERT_DEBUG_ONLY( myDoc );
32 }
33
34 /*!
35     Destructor 
36 */
37 QAD_Operation::~QAD_Operation ()
38 {
39 }
40
41 /*!
42     Returns reference to the document
43 */
44 QAD_Study* QAD_Operation::getDoc() const
45 {
46   return myDoc;
47 }
48
49 /*!
50     Returns reference to the application
51 */
52 QAD_Application* QAD_Operation::getApp() const
53 {
54   return myDoc->getApp();
55 }
56
57 /*!
58     Checks compatibility with the other launched operations.
59     Returns \true if appointed operation can be performed.
60     By default returns \false for all operations.
61 */
62 bool QAD_Operation::compatibleWith( QAD_Operation* op ) const
63 {
64   return false; 
65 }
66
67 /*!
68     Returns true if operation can be aborted by pressing "Escape" key
69     (default behaviour).
70 */
71 bool QAD_Operation::supportCancelByEscape() const
72 {
73   return true;
74 }
75
76 /*!
77     Returns true if operation changes document data. In this case it won't be
78     launched if document is opened as "read only". Value by default is true.
79 */
80 bool QAD_Operation::changesData() const
81 {
82   return true;
83 }
84
85 /*!
86     Starts this operation.
87 */
88 bool QAD_Operation::start()
89 {    
90   /* open transaction */
91   if ( !myDoc->onOperationStarted( this ) ) 
92     return false;
93   
94   /* started OK */
95   onStartOperation();                     
96   return true;
97 }
98
99 /*!
100     Called after operation started. Does nothing by default. 
101     Override to set a desired behaviour.
102 */
103 void QAD_Operation::onStartOperation()
104 {
105 }
106
107 /*!
108     Ends the operation.
109 */
110 void QAD_Operation::finish()
111 {    
112   QApplication::setOverrideCursor( Qt::waitCursor );    
113   
114   onFinishOperation();                /* customization */    
115   myDoc->onOperationFinished( this ); /* close transaction */
116   
117   QApplication::restoreOverrideCursor();
118 }
119
120 /*!
121     Called after operation finished. Does nothing by default. 
122     Override to set a desired behaviour.
123 */
124 void QAD_Operation::onFinishOperation()
125 {
126 }
127
128 /*!
129     Suspends operation process when the document is deactivated.
130 */
131 void QAD_Operation::suspend()
132 {    
133   onSuspendOperation();                /* customization */
134   myDoc->onOperationSuspended( this ); /* notification */
135 }
136
137 /*!
138     Called after operation suspended. Does nothing by default. 
139     Override to set a desired behaviour.
140 */
141 void QAD_Operation::onSuspendOperation()
142 {
143 }
144
145 /*!
146     Resumes operation performing process when the document became active
147     (if the operation wasn't aborted earlier).
148 */
149 void QAD_Operation::resume()
150 {
151   onResumeOperation();                /* customization */
152   myDoc->onOperationResumed( this );  /* notification */
153 }
154
155 /*!
156     Called after operation resumed. Does nothing by default. 
157     Override to set a desired behaviour.
158 */
159 void QAD_Operation::onResumeOperation()
160 {
161 }
162
163 /*!
164     Cancels operation performing process without ending.
165 */
166 void QAD_Operation::abort()
167 {
168   QApplication::setOverrideCursor( Qt::waitCursor );    
169   
170   onAbortOperation();                 /* customization */    
171   myDoc->onOperationAborted( this );  /* abort transaction */
172   
173   QApplication::restoreOverrideCursor();
174 }
175
176 /*!
177     Called after operation aborted. Does nothing by default. 
178     Override to set a desired behaviour.
179 */
180 void QAD_Operation::onAbortOperation()
181 {
182 }