]> SALOME platform Git repositories - samples/atomic.git/blob - src/ATOMICGUI/ATOMICGUI_Operation.cxx
Salome HOME
e5748c6a5ed641691e5200f37069155f3afcc822
[samples/atomic.git] / src / ATOMICGUI / ATOMICGUI_Operation.cxx
1 //  Copyright (C) 2007-2010  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.
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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21
22 #include <ATOMICGUI_Operation.h>
23 #include <ATOMICGUI_DataModel.h>
24 #include <ATOMICGUI.h>
25
26 #include <LightApp_Application.h>
27 #include <LightApp_Dialog.h>
28
29 /*! Constructor */
30 ATOMICGUI_Operation::ATOMICGUI_Operation()
31 : LightApp_Operation()
32 {
33 }
34
35 /*! Destructor */
36 ATOMICGUI_Operation::~ATOMICGUI_Operation()
37 {
38 }
39
40 /*! Called when Operation is started. */
41 void ATOMICGUI_Operation::startOperation()
42 {
43   if( dlg() )
44   {
45     disconnect( dlg(), SIGNAL( dlgOk() ),     this, SLOT( onOk() ) );
46     disconnect( dlg(), SIGNAL( dlgApply() ),  this, SLOT( onApply() ) );
47     disconnect( dlg(), SIGNAL( dlgClose() ),  this, SLOT( onClose() ) );
48
49     connect( dlg(), SIGNAL( dlgOk() ),     this, SLOT( onOk() ) );
50     connect( dlg(), SIGNAL( dlgApply() ),  this, SLOT( onApply() ) );
51     connect( dlg(), SIGNAL( dlgClose() ),  this, SLOT( onClose() ) );
52
53     dlg()->show();
54   }
55 }
56
57 /*! Called when Operation is aborted. */
58 void ATOMICGUI_Operation::abortOperation()
59 {
60   finish();
61 }
62
63 /*! Called when Operation is committed (normally ended). */
64 void ATOMICGUI_Operation::commitOperation()
65 {
66   finish();
67 }
68
69 /*! Called when Operation is done. Finalization steps. */
70 void ATOMICGUI_Operation::finish()
71 {
72   if( dlg() )
73     dlg()->hide();
74     
75   module()->getApp()->updateObjectBrowser();
76 }
77
78 /*! Returns a Data Model. */
79 ATOMICGUI_DataModel* ATOMICGUI_Operation::dataModel() const
80 {
81   return dynamic_cast<ATOMICGUI_DataModel*>( module()->dataModel() );
82 }
83
84 /*! Returns ATOMICGUI class instance. */
85 ATOMICGUI* ATOMICGUI_Operation::atomModule() const
86 {
87   return dynamic_cast<ATOMICGUI*>( module() );
88 }
89
90 /*! slot. Called when user presses OK button of the dialog (if it was set). */
91 void ATOMICGUI_Operation::onOk()
92 {
93   onApply();
94   commit();
95 }
96
97 /*! slot. Called when user presses Apply button of the dialog (if it was set). */
98 void ATOMICGUI_Operation::onApply()
99 {
100 }
101
102 /*! slot. Called when user presses Close button of the dialog (if it was set). */
103 void ATOMICGUI_Operation::onClose()
104 {
105   commit();
106 }