Salome HOME
DCQ : New Architecture
[modules/geom.git] / src / GEOMBase / GEOMBase_Skeleton.cxx
1 //  GEOM GEOMGUI : GUI for Geometry component
2 //
3 //  Copyright (C) 2003  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 //
23 //
24 //  File   : GEOMBase_Skeleton.cxx
25 //  Author : Damien COQUERET
26 //  Module : GEOM
27 //  $Header: 
28
29 using namespace std;
30 #include "GEOMBase_Skeleton.h"
31
32 //=================================================================================
33 // class    : GEOMBase_Skeleton()
34 // purpose  : Constructs a GEOMBase_Skeleton which is a child of 'parent', with the 
35 //            name 'name' and widget flags set to 'f'.
36 //            The dialog will by default be modeless, unless you set 'modal' to
37 //            TRUE to construct a modal dialog.
38 //=================================================================================
39 GEOMBase_Skeleton::GEOMBase_Skeleton(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl)
40   :DlgRef_Skeleton_QTD(parent, name, modal, fl)
41 {
42   if (!name)
43     setName("GEOMBase_Skeleton");
44
45   buttonCancel->setText(tr("GEOM_BUT_CLOSE"));
46   buttonOk->setText(tr("GEOM_BUT_OK"));
47   buttonApply->setText(tr("GEOM_BUT_APPLY"));
48
49   GroupMedium->close(TRUE);
50   resize(0, 0);
51
52   Init(Sel);
53 }
54
55
56 //=================================================================================
57 // function : ~GEOMBase_Skeleton()
58 // purpose  : Destroys the object and frees any allocated resources
59 //=================================================================================
60 GEOMBase_Skeleton::~GEOMBase_Skeleton()
61 {
62   // no need to delete child widgets, Qt does it all for us
63   this->destroy(TRUE, TRUE);
64 }
65
66
67 //=================================================================================
68 // function : Init()
69 // purpose  :
70 //=================================================================================
71 void GEOMBase_Skeleton::Init(SALOME_Selection* Sel)
72 {
73   /* init variables */
74   mySelection = Sel;
75   mySimulationTopoDs.Nullify();
76
77   myGeomBase = new GEOMBase();
78   myGeomGUI = GEOMContext::GetGeomGUI();
79   myGeomGUI->SetActiveDialogBox((QDialog*)this);
80   myGeom = myGeomGUI->myComponentGeom;
81
82   /* signals and slots connections */
83   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
84   connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
85   connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
86
87   /* Move widget on the botton right corner of main widget */
88 //   int x, y;
89 //   myGeomBase->DefineDlgPosition( this, x, y );
90
91   /* displays Dialog */
92   RadioButton1->setChecked(TRUE);
93
94   return;
95 }
96
97
98 //=================================================================================
99 // function : ClickOnCancel()
100 // purpose  :
101 //=================================================================================
102 void GEOMBase_Skeleton::ClickOnCancel()
103 {
104   myGeomBase->EraseSimulationShape();
105   mySimulationTopoDs.Nullify();
106
107   mySelection->ClearFilters();
108   disconnect(mySelection, 0, this, 0);
109
110   //myGeomGUI->ResetState();
111   reject();
112
113   return;
114 }
115
116
117 //=================================================================================
118 // function : LineEditReturnPressed()
119 // purpose  :
120 //=================================================================================
121 void GEOMBase_Skeleton::LineEditReturnPressed()
122 {
123   /* User name of object input management                          */
124   /* If successfull the selection is changed and signal emitted... */
125   /* so SelectionIntoArgument() is automatically called.           */
126   const QString objectUserName = myEditCurrentArgument->text();
127   QWidget* thisWidget = (QWidget*)this;
128   if(myGeomBase->SelectionByNameInDialogs(thisWidget, objectUserName, mySelection))
129     myEditCurrentArgument->setText(objectUserName);
130
131   return;
132 }
133
134
135 //=================================================================================
136 // function : DeactivateActiveDialog()
137 // purpose  :
138 //=================================================================================
139 void GEOMBase_Skeleton::DeactivateActiveDialog()
140 {
141   this->setEnabled(false);
142   mySelection->ClearFilters();
143   //myGeomGUI->ResetState();
144   disconnect(mySelection, 0, this, 0);
145   myGeomBase->EraseSimulationShape();
146   myGeomGUI->SetActiveDialogBox(0);
147   return;
148 }
149
150
151 //=================================================================================
152 // function : ActivateThisDialog()
153 // purpose  :
154 //=================================================================================
155 void GEOMBase_Skeleton::ActivateThisDialog()
156 {
157   /* Emit a signal to deactivate the active dialog */
158   myGeomGUI->EmitSignalDeactivateDialog();
159   this->setEnabled(true);
160   myGeomGUI->SetActiveDialogBox((QDialog*)this);
161   return;
162 }
163
164
165 //=================================================================================
166 // function : closeEvent()
167 // purpose  :
168 //=================================================================================
169 void GEOMBase_Skeleton::closeEvent(QCloseEvent* e)
170 {
171   /* same than click on cancel button */
172   this->ClickOnCancel();
173   return;
174 }