1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : OperationGUI_ArchimedeDlg.cxx
25 // Author : Nicolas REJNERI
30 #include "OperationGUI_ArchimedeDlg.h"
32 #include "QAD_Config.h"
34 //=================================================================================
35 // class : OperationGUI_ArchimedeDlg()
36 // purpose : Constructs a OperationGUI_ArchimedeDlg 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 OperationGUI_ArchimedeDlg::OperationGUI_ArchimedeDlg(QWidget* parent, const char* name, OperationGUI* theOperationGUI, SALOME_Selection* Sel, bool modal, WFlags fl)
42 :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
44 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_ARCHIMEDE")));
45 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
47 setCaption(tr("GEOM_ARCHIMEDE_TITLE"));
49 /***************************************************************/
50 GroupConstructors->setTitle(tr("GEOM_ARCHIMEDE"));
51 RadioButton1->setPixmap(image0);
52 RadioButton2->close(TRUE);
53 RadioButton3->close(TRUE);
55 GroupPoints = new DlgRef_1Sel3Spin(this, "GroupPoints");
56 GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
57 GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS"));
58 GroupPoints->TextLabel2->setText(tr("GEOM_WEIGHT"));
59 GroupPoints->TextLabel3->setText(tr("GEOM_WATER_DENSITY"));
60 GroupPoints->TextLabel4->setText(tr("GEOM_MESHING_DEFLECTION"));
61 GroupPoints->PushButton1->setPixmap(image1);
63 Layout1->addWidget(GroupPoints, 1, 0);
64 /***************************************************************/
67 myOperationGUI = theOperationGUI;
72 //=================================================================================
73 // function : ~OperationGUI_ArchimedeDlg()
74 // purpose : Destroys the object and frees any allocated resources
75 //=================================================================================
76 OperationGUI_ArchimedeDlg::~OperationGUI_ArchimedeDlg()
78 // no need to delete child widgets, Qt does it all for us
82 //=================================================================================
85 //=================================================================================
86 void OperationGUI_ArchimedeDlg::Init()
89 myEditCurrentArgument = GroupPoints->LineEdit1;
93 myMeshingDeflection = 0.01;
96 /* Get setting of step value from file configuration */
97 QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep");
101 double SpecificStep1 = 0.1;
102 double SpecificStep2 = 0.01;
103 /* min, max, step and decimals for spin boxes & initial values */
104 GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3);
105 GroupPoints->SpinBox_DY->RangeStepAndValidator(0.001, 999.999, SpecificStep1, 3);
106 GroupPoints->SpinBox_DZ->RangeStepAndValidator(0.001, 999.999, SpecificStep2, 3);
108 GroupPoints->SpinBox_DX->SetValue(myWeight);
109 GroupPoints->SpinBox_DY->SetValue(myWaterDensity);
110 GroupPoints->SpinBox_DZ->SetValue(myMeshingDeflection);
112 /* signals and slots connections */
113 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
114 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
116 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
117 connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
119 connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
120 connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
121 connect(GroupPoints->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
123 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double)));
124 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DY, SLOT(SetStep(double)));
125 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DZ, SLOT(SetStep(double)));
127 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
129 /* displays Dialog */
137 //=================================================================================
138 // function : ClickOnOk()
140 //=================================================================================
141 void OperationGUI_ArchimedeDlg::ClickOnOk()
143 this->ClickOnApply();
149 //=================================================================================
150 // function : ClickOnApply()
152 //=================================================================================
153 void OperationGUI_ArchimedeDlg::ClickOnApply()
155 QAD_Application::getDesktop()->putInfo(tr(""));
157 myOperationGUI->Archimede(myIO, myWeight, myWaterDensity, myMeshingDeflection);
162 //=================================================================================
163 // function : SelectionIntoArgument()
164 // purpose : Called when selection as changed or other case
165 //=================================================================================
166 void OperationGUI_ArchimedeDlg::SelectionIntoArgument()
168 myEditCurrentArgument->setText("");
169 QString aString = ""; /* name of selection */
171 int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString);
177 myEditCurrentArgument->setText(aString);
178 myIO = mySelection->firstIObject();
185 //=================================================================================
186 // function : LineEditReturnPressed()
188 //=================================================================================
189 void OperationGUI_ArchimedeDlg::LineEditReturnPressed()
191 QLineEdit* send = (QLineEdit*)sender();
192 if(send == GroupPoints->LineEdit1)
193 myEditCurrentArgument = GroupPoints->LineEdit1;
197 GEOMBase_Skeleton::LineEditReturnPressed();
202 //=================================================================================
203 // function : SetEditCurrentArgument()
205 //=================================================================================
206 void OperationGUI_ArchimedeDlg::SetEditCurrentArgument()
208 QPushButton* send = (QPushButton*)sender();
210 if(send == GroupPoints->PushButton1) {
211 GroupPoints->LineEdit1->setFocus();
212 myEditCurrentArgument = GroupPoints->LineEdit1;
213 this->SelectionIntoArgument();
220 //=================================================================================
221 // function : ActivateThisDialog()
223 //=================================================================================
224 void OperationGUI_ArchimedeDlg::ActivateThisDialog()
226 GEOMBase_Skeleton::ActivateThisDialog();
227 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
232 //=================================================================================
233 // function : enterEvent()
235 //=================================================================================
236 void OperationGUI_ArchimedeDlg::enterEvent(QEvent* e)
238 if(GroupConstructors->isEnabled())
240 this->ActivateThisDialog();
245 //=================================================================================
246 // function : ValueChangedInSpinBox()
248 //=================================================================================
249 void OperationGUI_ArchimedeDlg::ValueChangedInSpinBox(double newValue)
251 QObject* send = (QObject*)sender();
253 if(send == GroupPoints->SpinBox_DX)
255 else if(send == GroupPoints->SpinBox_DY)
256 myWaterDensity = newValue;
257 else if(send == GroupPoints->SpinBox_DZ)
258 myMeshingDeflection = newValue;