Salome HOME
52be9dc8a5399f722102f5b8643d7037cdb5783d
[samples/atomic.git] / src / ATOMICGUI / ATOMICGUI_Operation.cxx
1 // Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "ATOMICGUI_Operation.h"
21 #include "ATOMICGUI_DataModel.h"
22 #include "ATOMICGUI.h"
23
24 #include <LightApp_Application.h>
25 #include <LightApp_Dialog.h>
26
27 /*! Constructor */
28 ATOMICGUI_Operation::ATOMICGUI_Operation()
29 : LightApp_Operation()
30 {
31 }
32
33 /*! Destructor */
34 ATOMICGUI_Operation::~ATOMICGUI_Operation()
35 {
36 }
37
38 /*! Called when Operation is started. */
39 void ATOMICGUI_Operation::startOperation()
40 {
41   if( dlg() )
42   {
43     disconnect( dlg(), SIGNAL( dlgOk() ),     this, SLOT( onOk() ) );
44     disconnect( dlg(), SIGNAL( dlgApply() ),  this, SLOT( onApply() ) );
45     disconnect( dlg(), SIGNAL( dlgClose() ),  this, SLOT( onClose() ) );
46
47     connect( dlg(), SIGNAL( dlgOk() ),     this, SLOT( onOk() ) );
48     connect( dlg(), SIGNAL( dlgApply() ),  this, SLOT( onApply() ) );
49     connect( dlg(), SIGNAL( dlgClose() ),  this, SLOT( onClose() ) );
50
51     dlg()->show();
52   }
53 }
54
55 /*! Called when Operation is aborted. */
56 void ATOMICGUI_Operation::abortOperation()
57 {
58   finish();
59 }
60
61 /*! Called when Operation is committed (normally ended). */
62 void ATOMICGUI_Operation::commitOperation()
63 {
64   finish();
65 }
66
67 /*! Called when Operation is done. Finalization steps. */
68 void ATOMICGUI_Operation::finish()
69 {
70   if( dlg() )
71     dlg()->hide();
72     
73   module()->getApp()->updateObjectBrowser();
74 }
75
76 /*! Returns a Data Model. */
77 ATOMICGUI_DataModel* ATOMICGUI_Operation::dataModel() const
78 {
79   return dynamic_cast<ATOMICGUI_DataModel*>( module()->dataModel() );
80 }
81
82 /*! Returns ATOMICGUI class instance. */
83 ATOMICGUI* ATOMICGUI_Operation::atomModule() const
84 {
85   return dynamic_cast<ATOMICGUI*>( module() );
86 }
87
88 /*! slot. Called when user presses OK button of the dialog (if it was set). */
89 void ATOMICGUI_Operation::onOk()
90 {
91   onApply();
92   commit();
93 }
94
95 /*! slot. Called when user presses Apply button of the dialog (if it was set). */
96 void ATOMICGUI_Operation::onApply()
97 {
98 }
99
100 /*! slot. Called when user presses Close button of the dialog (if it was set). */
101 void ATOMICGUI_Operation::onClose()
102 {
103   commit();
104 }