3 // Copyright (C) 2005 CEA/DEN, EDF R&D
7 // File : LightApp_Operation.h
8 // Author : Sergey LITONIN
11 #include <LightApp_Operation.h>
12 #include <LightApp_Module.h>
13 #include <LightApp_Application.h>
14 #include <LightApp_Operation.h>
15 #include <LightApp_SelectionMgr.h>
16 #include <LightApp_Dialog.h>
18 #include <SUIT_Desktop.h>
20 #include <qapplication.h>
26 * Constructor sets myModule in NULL and myIsAutoResumed in TRUE
28 LightApp_Operation::LightApp_Operation()
29 : SUIT_Operation( 0 ),
31 myIsAutoResumed( true )
38 * Destructor does nothing
40 LightApp_Operation::~LightApp_Operation()
46 * \brief Gets module of operation
47 * \return Pointer to the module
49 * Gets pointer to the module or NULL if module was not set. It is strongly recomended to
50 * set valid pointer on the module before start of operation
52 LightApp_Module* LightApp_Operation::module() const
59 * \brief Sets module of operation
60 * \param theModule - module to be set
62 * Sets pointer to the module. It is strongly recomended to set valid pointer on the
63 * module before start of operation
65 void LightApp_Operation::setModule( LightApp_Module* theModule )
68 setApplication( myModule ? myModule->application() : 0 );
69 setStudy( application() ? application()->activeStudy() : 0 );
73 * \brief Gets desktop of operation
74 * \return Pointer to the desktop
76 * Gets pointer to the desktop or NULL if application was not set. It is strongly recomended
77 * to set valid pointer on the application before start of operation
79 SUIT_Desktop* LightApp_Operation::desktop() const
81 return application() != 0 ? application()->desktop() : 0;
85 * \brief Enable dialog of operation
87 * Virtual method redefined from the base class. Enable dialog if it was desabled (in
88 * suspend method) and activate selection
90 void LightApp_Operation::resumeOperation()
92 SUIT_Operation::resumeOperation();
93 setDialogActive( true );
97 * \brief Performs actions needed for starting operation
99 * Virtual method redefined from the base class. Connect signal of selection manager to
100 * onSelectionDone() slot
102 void LightApp_Operation::startOperation()
105 connect( selectionMgr(), SIGNAL( selectionChanged() ), SLOT( onSelectionDone() ) );
107 //If suspended operation was stopped during starting other operation,
108 //the dialog is inactive now, We must activate it
109 setDialogActive( true );
113 * \brief Performs actions needed for suspending operation
115 * Virtual method redefined from the base class. This implementation calls corresponding
116 * method of base class and cals setDialogActive( false )
118 void LightApp_Operation::suspendOperation()
120 SUIT_Operation::suspendOperation();
121 setDialogActive( false );
125 * \brief Performs actions needed for aborting operation
127 * Virtual method redefined from the base class calls corresponding method of base class
128 * and hides dialog box (if it is exists), disconnect slots from selection manager
130 void LightApp_Operation::abortOperation()
132 SUIT_Operation::abortOperation();
133 setDialogActive( true );
138 disconnect( selectionMgr(), SIGNAL( selectionChanged() ), this, SLOT( onSelectionDone() ) );
142 * \brief Performs actions needed for committing operation
144 * Virtual method redefined from the base class calls corresponding method of base class
145 * and hides dialog box (if it is exists), disconnect slots from selection manager
147 void LightApp_Operation::commitOperation()
149 SUIT_Operation::commitOperation();
150 setDialogActive( true );
155 disconnect( selectionMgr(), SIGNAL( selectionChanged() ), this, SLOT( onSelectionDone() ) );
160 * \return Pointer to the dialog of this operation or NULL if it does not exist
162 * This method should be redefined in derived classes if they use dialogs. If this
163 * function returns pointer to dialog then dialog will be correctly
164 * -# deactivated in suspendOperation method
165 * -# activated in resumeOperation method
166 * -# hidden in abortOperation and commitOperation methods
168 LightApp_Dialog* LightApp_Operation::dlg() const
174 * \brief Activates selection
176 * Virtual method should be redefined in derived classes if they use own selection modes
177 * (different from default)
179 void LightApp_Operation::activateSelection()
184 * \brief Virtual method called when selection is changed
186 * Virtual method should be redefined in derived classes if they works with selection
187 * to provide reaction on the change of selection
189 void LightApp_Operation::selectionDone()
194 * \brief Gets active operation
196 * This method provided for convinience calls SUIT_Study::activeOperation() one
198 SUIT_Operation* LightApp_Operation::activeOperation() const
200 return study() != 0 ? study()->activeOperation() : 0;
204 * \brief Gets selection manager
206 * This method provided for convinience calls LightApp_Application::selectionMgr() one
208 LightApp_SelectionMgr* LightApp_Operation::selectionMgr() const
210 SUIT_Application* app = application();
211 if ( app != 0 && app->inherits( "LightApp_Application" ) )
212 return ( (LightApp_Application*)app )->selectionMgr();
218 * \brief Call selectionDone() method
220 * Call selectionDone() method if operator is an active one (see selectionDone() for more
223 void LightApp_Operation::onSelectionDone()
230 * \brief Update object browser or/and viewer etc.
231 * \param flags - update flags
233 * This method provided for convinience calls LightApp_Module::update() one (see
234 * LightApp_Module::update() for more description)
236 void LightApp_Operation::update( const int flags )
239 myModule->update( flags );
243 * \brief Activate/Deactivate dialog of operation
244 * \param active - State of the dialog to be set
246 * Activate/Deactivate dialog of operation. This method called from startOperation(),
247 * suspendOperation() ones and so on
249 void LightApp_Operation::setDialogActive( const bool active )
256 dlg()->setActiveWindow();
262 * \brief Gets autoresume property
263 * \return Autoresume property.
265 * Autoresume property is used during automatic resuming operation. If operation is
266 * suspended and cursor is moved above dialog of the operation then operation is resumed
267 * automatically (if possible). It can be resumed only program call otherwise (see
268 * LightApp_SwitchOp for more description). This property is TRUE by default and may be
269 * changed with setAutoResumed() method call.
271 bool LightApp_Operation::isAutoResumed() const
273 return myIsAutoResumed;
277 * \brief Sets autoresume property
278 * \param on - Value to be set
279 * \return Autoresume property.
281 * Sets autoresume property (see isAutoResumed() for more description)
283 void LightApp_Operation::setAutoResumed( const bool on )
285 myIsAutoResumed = on;