Back to index

salome-gui  6.5.0
LightApp_Operation.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  File   : LightApp_Operation.h
00024 //  Author : Sergey LITONIN
00025 //  Module : LightApp
00026 //
00027 #include "LightApp_Operation.h"
00028 #include "LightApp_Module.h"
00029 #include "LightApp_Application.h"
00030 #include "LightApp_SelectionMgr.h"
00031 #include "LightApp_Dialog.h"
00032 
00033 #include <SUIT_Desktop.h>
00034 #include <SUIT_Study.h>
00035 
00041 LightApp_Operation::LightApp_Operation()
00042 : SUIT_Operation( 0 ),
00043   myModule( 0 ),
00044   myIsAutoResumed( true )
00045 {
00046 }
00047 
00053 LightApp_Operation::~LightApp_Operation()
00054 {
00055   
00056 }
00057 
00065 LightApp_Module* LightApp_Operation::module() const
00066 {
00067   return myModule;
00068 }
00069 
00070 
00078 void LightApp_Operation::setModule( LightApp_Module* theModule )
00079 {
00080   myModule = theModule;
00081   setApplication( myModule ? myModule->application() : 0 );
00082   setStudy( application() ? application()->activeStudy() : 0 );
00083 }
00084 
00092 SUIT_Desktop* LightApp_Operation::desktop() const
00093 {
00094   return application() != 0 ? application()->desktop() : 0;
00095 }
00096 
00103 void LightApp_Operation::resumeOperation()
00104 {
00105   SUIT_Operation::resumeOperation();
00106   setDialogActive( true );
00107 }
00108 
00115 void LightApp_Operation::startOperation()
00116 {
00117   if( selectionMgr() )
00118     connect( selectionMgr(), SIGNAL( selectionChanged() ), SLOT( onSelectionDone() ) );
00119     
00120   //If suspended operation was stopped during starting other operation,
00121   //the dialog is inactive now, We must activate it
00122   setDialogActive( true );
00123 }
00124 
00131 void LightApp_Operation::suspendOperation()
00132 {
00133   SUIT_Operation::suspendOperation();
00134   setDialogActive( false );
00135 }
00136 
00143 void LightApp_Operation::abortOperation()
00144 {
00145   SUIT_Operation::abortOperation();
00146   setDialogActive( true );
00147   if ( dlg() )
00148     dlg()->hide();
00149 
00150   if( selectionMgr() )
00151     disconnect( selectionMgr(), SIGNAL( selectionChanged() ), this, SLOT( onSelectionDone() ) );
00152 }
00153 
00160 void LightApp_Operation::commitOperation()
00161 {
00162   SUIT_Operation::commitOperation();
00163   setDialogActive( true );
00164   if ( dlg() )
00165     dlg()->hide();
00166 
00167   if( selectionMgr() )
00168     disconnect( selectionMgr(), SIGNAL( selectionChanged() ), this, SLOT( onSelectionDone() ) );
00169 }
00170 
00181 LightApp_Dialog* LightApp_Operation::dlg() const
00182 {
00183   return 0;
00184 }
00185 
00192 void LightApp_Operation::activateSelection()
00193 {
00194 }
00195 
00202 void LightApp_Operation::selectionDone()
00203 {
00204 }
00205 
00211 SUIT_Operation* LightApp_Operation::activeOperation() const
00212 {
00213   return study() != 0 ? study()->activeOperation() : 0;
00214 }
00215 
00221 LightApp_SelectionMgr* LightApp_Operation::selectionMgr() const
00222 {
00223   SUIT_Application* app = application();
00224   if ( app != 0 && app->inherits( "LightApp_Application" ) )
00225     return ( (LightApp_Application*)app )->selectionMgr();
00226   else
00227     return 0;
00228 }
00229 
00236 void LightApp_Operation::onSelectionDone()
00237 {
00238   if ( isActive() )
00239     selectionDone();
00240 }
00241 
00249 void LightApp_Operation::update( const int flags )
00250 {
00251   if ( myModule != 0 )
00252     myModule->update( flags );
00253 }
00254 
00262 void LightApp_Operation::setDialogActive( const bool active )
00263 {
00264   if( dlg() )
00265   {
00266     if( active )
00267     {
00268       activateSelection();
00269       dlg()->activateWindow();
00270     }
00271   }
00272 }
00273 
00284 bool LightApp_Operation::isAutoResumed() const
00285 {
00286   return myIsAutoResumed;
00287 }
00288 
00296 void LightApp_Operation::setAutoResumed( const bool on )
00297 {
00298   myIsAutoResumed = on;
00299 }