]> SALOME platform Git repositories - modules/geom.git/blob - src/RepairGUI/RepairGUI_SewingDlg.cxx
Salome HOME
d36dedea09ab436b0ca0ca8f3f09abcb85d1e3cc
[modules/geom.git] / src / RepairGUI / RepairGUI_SewingDlg.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   : RepairGUI_SewingDlg.cxx
25 //  Author : Lucien PIGNOLONI
26 //  Module : GEOM
27 //  $Header$
28
29 using namespace std;
30 #include "RepairGUI_SewingDlg.h"
31
32 #include "QAD_Config.h"
33
34 //=================================================================================
35 // class    : RepairGUI_SewingDlg()
36 // purpose  : Constructs a RepairGUI_SewingDlg which is a child of 'parent', with the 
37 //            name 'name' and widget flags set to 'f'.
38 //            The dialog will by default be modeless, unless you set 'modal' to
39 //            TRUE to construct a modal dialog.
40 //=================================================================================
41 RepairGUI_SewingDlg::RepairGUI_SewingDlg(QWidget* parent,  const char* name, RepairGUI* theRepairGUI, SALOME_Selection* Sel, bool modal, WFlags fl)
42   :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
43 {
44   QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_SEWING")));
45   QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
46
47   setCaption(tr("GEOM_SEWING_TITLE"));
48
49   /***************************************************************/
50   GroupConstructors->setTitle(tr("GEOM_SEWING"));
51   RadioButton1->setPixmap(image0);
52   RadioButton2->close(TRUE);
53   RadioButton3->close(TRUE);
54
55   GroupPoints = new DlgRef_1Sel1Spin(this, "GroupPoints");
56   GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
57   GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS"));
58   GroupPoints->TextLabel2->setText(tr("GEOM_PRECISION"));
59   GroupPoints->PushButton1->setPixmap(image1);
60
61   Layout1->addWidget(GroupPoints, 1, 0);
62   /***************************************************************/
63
64   /* Initialisations */
65   myRepairGUI = theRepairGUI;
66   Init();
67 }
68
69
70 //=================================================================================
71 // function : ~RepairGUI_SewingDlg()
72 // purpose  : Destroys the object and frees any allocated resources
73 //=================================================================================
74 RepairGUI_SewingDlg::~RepairGUI_SewingDlg()
75 {
76   // no need to delete child widgets, Qt does it all for us
77 }
78
79
80 //=================================================================================
81 // function : Init()
82 // purpose  :
83 //=================================================================================
84 void RepairGUI_SewingDlg::Init()
85 {
86   /* init variables */
87   myEditCurrentArgument = GroupPoints->LineEdit1;
88
89   myOkListShapes = false;
90   myPrecision = 0.00001;
91
92   /* Get setting of step value from file configuration */
93   QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep");
94   step = St.toDouble();
95
96   /* min, max, step and decimals for spin boxes */
97   GroupPoints->SpinBox_DX->RangeStepAndValidator(0.00001, 999.99999, step, 5);
98   GroupPoints->SpinBox_DX->SetValue(myPrecision);
99   
100   /* signals and slots connections */
101   connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
102   connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
103
104   connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
105
106   connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
107   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double)));
108   
109   connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
110
111   /* displays Dialog */
112   GroupPoints->show();
113   this->show();
114
115   return;
116 }
117
118
119 //=================================================================================
120 // function : ClickOnOk()
121 // purpose  :
122 //=================================================================================
123 void RepairGUI_SewingDlg::ClickOnOk()
124 {
125   this->ClickOnApply();
126   ClickOnCancel();
127   return;
128 }
129
130
131 //=================================================================================
132 // function : ClickOnApply()
133 // purpose  :
134 //=================================================================================
135 void RepairGUI_SewingDlg::ClickOnApply()
136 {
137   buttonApply->setFocus();
138   QAD_Application::getDesktop()->putInfo(tr(""));
139   if(myOkListShapes)  
140     myRepairGUI->MakeSewingAndDisplay(myListShapes, myPrecision);
141   return;
142 }
143
144
145 //=================================================================================
146 // function : SelectionIntoArgument()
147 // purpose  : Called when selection as changed or other case
148 //=================================================================================
149 void RepairGUI_SewingDlg::SelectionIntoArgument()
150 {
151   myEditCurrentArgument->setText("");
152   QString aString = ""; /* name of selection */
153   myOkListShapes = false; 
154
155   int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString);
156   if(nbSel < 2)
157     return;
158
159   myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes);  
160   myEditCurrentArgument->setText(aString);
161   myOkListShapes = true;
162   /* no simulation */
163   return;
164 }
165
166
167 //=================================================================================
168 // function : SetEditCurrentArgument()
169 // purpose  :
170 //=================================================================================
171 void RepairGUI_SewingDlg::SetEditCurrentArgument()
172 {
173   QPushButton* send = (QPushButton*)sender();
174
175   if(send == GroupPoints->PushButton1) {
176     GroupPoints->LineEdit1->setFocus();
177     myEditCurrentArgument = GroupPoints->LineEdit1;
178     this->SelectionIntoArgument();
179   }
180   return;
181 }
182
183
184 //=================================================================================
185 // function : ActivateThisDialog()
186 // purpose  :
187 //=================================================================================
188 void RepairGUI_SewingDlg::ActivateThisDialog()
189 {
190   GEOMBase_Skeleton::ActivateThisDialog();
191   connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
192   return;
193 }
194
195
196 //=================================================================================
197 // function : enterEvent()
198 // purpose  :
199 //=================================================================================
200 void RepairGUI_SewingDlg::enterEvent(QEvent* e)
201 {
202   if(GroupConstructors->isEnabled())
203     return;
204   this->ActivateThisDialog();
205   return;
206 }
207
208
209 //=================================================================================
210 // function : ValueChangedInSpinBox()
211 // purpose  :
212 //=================================================================================
213 void RepairGUI_SewingDlg::ValueChangedInSpinBox(double newValue)
214 {
215   myPrecision = newValue;
216   return;
217 }