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 : RepairGUI_SewingDlg.cxx
25 // Author : Lucien PIGNOLONI
30 #include "RepairGUI_SewingDlg.h"
32 #include "QAD_Config.h"
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)
44 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_SEWING")));
45 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
47 setCaption(tr("GEOM_SEWING_TITLE"));
49 /***************************************************************/
50 GroupConstructors->setTitle(tr("GEOM_SEWING"));
51 RadioButton1->setPixmap(image0);
52 RadioButton2->close(TRUE);
53 RadioButton3->close(TRUE);
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);
61 Layout1->addWidget(GroupPoints, 1, 0);
62 /***************************************************************/
65 myRepairGUI = theRepairGUI;
70 //=================================================================================
71 // function : ~RepairGUI_SewingDlg()
72 // purpose : Destroys the object and frees any allocated resources
73 //=================================================================================
74 RepairGUI_SewingDlg::~RepairGUI_SewingDlg()
76 // no need to delete child widgets, Qt does it all for us
80 //=================================================================================
83 //=================================================================================
84 void RepairGUI_SewingDlg::Init()
87 myEditCurrentArgument = GroupPoints->LineEdit1;
89 myOkListShapes = false;
90 myPrecision = 0.00001;
92 /* Get setting of step value from file configuration */
93 QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep");
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);
100 /* signals and slots connections */
101 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
102 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
104 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
106 connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
107 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double)));
109 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
111 /* displays Dialog */
119 //=================================================================================
120 // function : ClickOnOk()
122 //=================================================================================
123 void RepairGUI_SewingDlg::ClickOnOk()
125 this->ClickOnApply();
131 //=================================================================================
132 // function : ClickOnApply()
134 //=================================================================================
135 void RepairGUI_SewingDlg::ClickOnApply()
137 buttonApply->setFocus();
138 QAD_Application::getDesktop()->putInfo(tr(""));
140 myRepairGUI->MakeSewingAndDisplay(myListShapes, myPrecision);
145 //=================================================================================
146 // function : SelectionIntoArgument()
147 // purpose : Called when selection as changed or other case
148 //=================================================================================
149 void RepairGUI_SewingDlg::SelectionIntoArgument()
151 myEditCurrentArgument->setText("");
152 QString aString = ""; /* name of selection */
153 myOkListShapes = false;
155 int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString);
159 myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes);
160 myEditCurrentArgument->setText(aString);
161 myOkListShapes = true;
167 //=================================================================================
168 // function : SetEditCurrentArgument()
170 //=================================================================================
171 void RepairGUI_SewingDlg::SetEditCurrentArgument()
173 QPushButton* send = (QPushButton*)sender();
175 if(send == GroupPoints->PushButton1) {
176 GroupPoints->LineEdit1->setFocus();
177 myEditCurrentArgument = GroupPoints->LineEdit1;
178 this->SelectionIntoArgument();
184 //=================================================================================
185 // function : ActivateThisDialog()
187 //=================================================================================
188 void RepairGUI_SewingDlg::ActivateThisDialog()
190 GEOMBase_Skeleton::ActivateThisDialog();
191 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
196 //=================================================================================
197 // function : enterEvent()
199 //=================================================================================
200 void RepairGUI_SewingDlg::enterEvent(QEvent* e)
202 if(GroupConstructors->isEnabled())
204 this->ActivateThisDialog();
209 //=================================================================================
210 // function : ValueChangedInSpinBox()
212 //=================================================================================
213 void RepairGUI_SewingDlg::ValueChangedInSpinBox(double newValue)
215 myPrecision = newValue;