1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "AdvancedGUI_PipeTShapeDlg.h"
23 #include <GeometryGUI.h>
26 #include <SUIT_Session.h>
27 #include <SUIT_ResourceMgr.h>
28 #include <SUIT_OverrideCursor.h>
29 #include <LightApp_SelectionMgr.h>
30 #include <SalomeApp_Application.h>
31 #include <SalomeApp_Tools.h>
34 #include <BRep_Tool.hxx>
35 #include <TopTools_IndexedMapOfShape.hxx>
36 #include <TopoDS_Shape.hxx>
39 #include <TColStd_IndexedMapOfInteger.hxx>
44 #include <GEOMImpl_Types.hxx>
46 //=================================================================================
48 //=================================================================================
49 AdvancedGUI_PipeTShapeDlg::AdvancedGUI_PipeTShapeDlg (GeometryGUI* theGeometryGUI, QWidget* parent)
50 : GEOMBase_Skeleton(theGeometryGUI, parent, false)
52 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
53 //QPixmap imageOp = aResMgr->loadPixmap("GEOM", tr("ICON_DLG_PIPETSHAPE"));
54 QPixmap imageSel = aResMgr->loadPixmap("GEOM", tr("ICON_SELECT"));
55 QPixmap imageImp = aResMgr->loadPixmap("GEOM", tr("ICO_PIPETSHAPE_IMPORT"));
56 imagePipeTShape = aResMgr->loadPixmap("GEOM", tr("DLG_PIPETSHAPE"));
57 imageReduction = aResMgr->loadPixmap("GEOM", tr("IMG_PIPETSHAPE_SECT"));
59 setWindowTitle(tr("GEOM_PIPE_TSHAPE_TITLE"));
61 /***************************************************************/
62 mainFrame()->GroupConstructors->setAttribute(Qt::WA_DeleteOnClose);
63 mainFrame()->GroupConstructors->close();
65 QTabWidget* aTabWidget = new QTabWidget (centralWidget());
67 QGridLayout* myMainLayout = new QGridLayout (centralWidget());
68 myMainLayout->setMargin(0);
69 myMainLayout->setSpacing(6);
72 QGroupBox* GroupMain = new QGroupBox();
73 QGridLayout* layoutGroupMain = new QGridLayout (GroupMain);
75 MainTubeGroupParams = new DlgRef_3Spin();
76 MainTubeGroupParams->GroupBox1->setTitle(tr("GEOM_PIPE_TSHAPE_MPIPE"));
77 MainTubeGroupParams->TextLabel1->setText(tr("GEOM_PIPE_TSHAPE_R"));
78 MainTubeGroupParams->TextLabel2->setText(tr("GEOM_PIPE_TSHAPE_W"));
79 MainTubeGroupParams->TextLabel3->setText(tr("GEOM_PIPE_TSHAPE_L"));
80 MainTubeGroupParams->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); // ??
82 IncidentTubeGroupParams = new DlgRef_3Spin();
83 IncidentTubeGroupParams->GroupBox1->setTitle(tr("GEOM_PIPE_TSHAPE_IPIPE"));
84 IncidentTubeGroupParams->TextLabel1->setText(tr("GEOM_PIPE_TSHAPE_R"));
85 IncidentTubeGroupParams->TextLabel2->setText(tr("GEOM_PIPE_TSHAPE_W"));
86 IncidentTubeGroupParams->TextLabel3->setText(tr("GEOM_PIPE_TSHAPE_L"));
88 ChamferGroupParams = new DlgRef_2Spin();
89 ChamferGroupParams->GroupBox1->setCheckable(true);
90 ChamferGroupParams->GroupBox1->setChecked(false);
91 ChamferGroupParams->GroupBox1->setTitle(tr("GEOM_PIPE_TSHAPE_CHAMFER"));
92 ChamferGroupParams->TextLabel1->setText(tr("GEOM_PIPE_TSHAPE_CHAMFER_H"));
93 ChamferGroupParams->TextLabel2->setText(tr("GEOM_PIPE_TSHAPE_CHAMFER_W"));
95 FilletGroupParams = new DlgRef_1Spin();
96 FilletGroupParams->GroupBox1->setCheckable(true);
97 FilletGroupParams->GroupBox1->setChecked(false);
98 FilletGroupParams->GroupBox1->setTitle(tr("GEOM_PIPE_TSHAPE_FILLET"));
99 FilletGroupParams->TextLabel1->setText(tr("GEOM_PIPE_TSHAPE_R"));
101 HexMeshCheckBox = new QCheckBox();
102 HexMeshCheckBox->setText(tr("GEOM_PIPE_TSHAPE_HEX"));
103 HexMeshCheckBox->setChecked(true);
105 LabelImgPipeTShape = new QLabel();
106 LabelImgPipeTShape->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
107 LabelImgPipeTShape->setAlignment(Qt::AlignCenter);
108 LabelImgPipeTShape->setMinimumSize(300, 300);
110 layoutGroupMain->addWidget(MainTubeGroupParams, 0, 0, 1, 1);
111 layoutGroupMain->addWidget(IncidentTubeGroupParams, 1, 0, 1, 1);
112 layoutGroupMain->addWidget(ChamferGroupParams, 2, 0, 1, 1);
113 layoutGroupMain->addWidget(FilletGroupParams, 3, 0, 1, 1);
114 layoutGroupMain->addWidget(HexMeshCheckBox, 4, 0, 1, 1);
116 layoutGroupMain->addWidget(LabelImgPipeTShape, 0, 1, 5, 1);
117 layoutGroupMain->setColumnStretch(1, 1); // stretch of column 0 is supposed 0 by default
119 // Thickness reduction parameters
120 QGroupBox* GroupReduct = new QGroupBox();
121 QGridLayout* layoutGroupReduct = new QGridLayout (GroupReduct);
123 LReductionGroupParams = new AdvancedGUI_4Spin();
124 LReductionGroupParams->GroupBox1->setCheckable(true);
125 LReductionGroupParams->GroupBox1->setChecked(false);
126 LReductionGroupParams->GroupBox1->setTitle(tr("GEOM_PIPE_TSHAPE_LEFT_TR"));
127 LReductionGroupParams->TextLabel1->setText(tr("GEOM_PIPE_TSHAPE_TR_R").arg("L"));
128 LReductionGroupParams->TextLabel2->setText(tr("GEOM_PIPE_TSHAPE_TR_W").arg("L"));
129 LReductionGroupParams->TextLabel3->setText(tr("GEOM_PIPE_TSHAPE_TR_L_TRANS").arg("L"));
130 LReductionGroupParams->TextLabel4->setText(tr("GEOM_PIPE_TSHAPE_TR_L_THIN").arg("L"));
132 RReductionGroupParams = new AdvancedGUI_4Spin();
133 RReductionGroupParams->GroupBox1->setCheckable(true);
134 RReductionGroupParams->GroupBox1->setChecked(false);
135 RReductionGroupParams->GroupBox1->setTitle(tr("GEOM_PIPE_TSHAPE_RIGHT_TR"));
136 RReductionGroupParams->TextLabel1->setText(tr("GEOM_PIPE_TSHAPE_TR_R").arg("R"));
137 RReductionGroupParams->TextLabel2->setText(tr("GEOM_PIPE_TSHAPE_TR_W").arg("R"));
138 RReductionGroupParams->TextLabel3->setText(tr("GEOM_PIPE_TSHAPE_TR_L_TRANS").arg("R"));
139 RReductionGroupParams->TextLabel4->setText(tr("GEOM_PIPE_TSHAPE_TR_L_THIN").arg("R"));
141 IReductionGroupParams = new AdvancedGUI_4Spin();
142 IReductionGroupParams->GroupBox1->setCheckable(true);
143 IReductionGroupParams->GroupBox1->setChecked(false);
144 IReductionGroupParams->GroupBox1->setTitle(tr("GEOM_PIPE_TSHAPE_INCI_TR"));
145 IReductionGroupParams->TextLabel1->setText(tr("GEOM_PIPE_TSHAPE_TR_R").arg("I"));
146 IReductionGroupParams->TextLabel2->setText(tr("GEOM_PIPE_TSHAPE_TR_W").arg("I"));
147 IReductionGroupParams->TextLabel3->setText(tr("GEOM_PIPE_TSHAPE_TR_L_TRANS").arg("I"));
148 IReductionGroupParams->TextLabel4->setText(tr("GEOM_PIPE_TSHAPE_TR_L_THIN").arg("I"));
150 LabelImgReduction = new QLabel();
151 LabelImgReduction->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
152 LabelImgReduction->setAlignment(Qt::AlignCenter);
153 LabelImgReduction->setMinimumSize(300, 300);
155 layoutGroupReduct->addWidget(LReductionGroupParams->GroupBox1, 0, 0, 1, 1);
156 layoutGroupReduct->addWidget(RReductionGroupParams->GroupBox1, 1, 0, 1, 1);
157 layoutGroupReduct->addWidget(IReductionGroupParams->GroupBox1, 2, 0, 1, 1);
159 layoutGroupReduct->addWidget(LabelImgReduction, 0, 1, 3, 1);
160 layoutGroupReduct->setColumnStretch(1, 1); // stretch of column 0 is supposed 0 by default
162 // Position parameters
163 QGroupBox* GroupPos = new QGroupBox();
164 QVBoxLayout* layoutGroupPos = new QVBoxLayout (GroupPos);
166 JunctionPointsSel = new DlgRef_6Sel();
167 JunctionPointsSel->GroupBox1->setTitle(tr("GEOM_PIPE_TSHAPE_POSITION"));
168 JunctionPointsSel->GroupBox1->setCheckable(true);
169 JunctionPointsSel->GroupBox1->setChecked(false);
170 JunctionPointsSel->PushButton1->setIcon(imageSel);
171 JunctionPointsSel->LineEdit1->setReadOnly(true);
172 JunctionPointsSel->LineEdit1->setText("");
173 JunctionPointsSel->TextLabel1->setText(tr("GEOM_PIPE_TSHAPE_POSITION_P1"));
175 JunctionPointsSel->PushButton2->setIcon(imageSel);
176 JunctionPointsSel->LineEdit2->setReadOnly(true);
177 JunctionPointsSel->LineEdit2->setText("");
178 JunctionPointsSel->TextLabel2->setText(tr("GEOM_PIPE_TSHAPE_POSITION_P2"));
180 JunctionPointsSel->PushButton3->setIcon(imageSel);
181 JunctionPointsSel->LineEdit3->setReadOnly(true);
182 JunctionPointsSel->LineEdit3->setText("");
183 JunctionPointsSel->TextLabel3->setText(tr("GEOM_PIPE_TSHAPE_POSITION_P3"));
185 JunctionPointsSel->PushButton4->setIcon(imageImp);
186 JunctionPointsSel->LineEdit4->setReadOnly(true);
187 JunctionPointsSel->LineEdit4->setText("");
188 JunctionPointsSel->TextLabel4->setText(tr("GEOM_PIPE_TSHAPE_POSITION_LBL_L1"));
190 JunctionPointsSel->PushButton5->setIcon(imageImp);
191 JunctionPointsSel->LineEdit5->setReadOnly(true);
192 JunctionPointsSel->LineEdit5->setText("");
193 JunctionPointsSel->TextLabel5->setText(tr("GEOM_PIPE_TSHAPE_POSITION_LBL_L2"));
195 JunctionPointsSel->PushButton6->setAttribute(Qt::WA_DeleteOnClose);
196 JunctionPointsSel->PushButton6->close();
197 JunctionPointsSel->LineEdit6->setAttribute(Qt::WA_DeleteOnClose);
198 JunctionPointsSel->LineEdit6->close();
199 JunctionPointsSel->TextLabel6->setAttribute(Qt::WA_DeleteOnClose);
200 JunctionPointsSel->TextLabel6->close();
202 layoutGroupPos->addWidget(JunctionPointsSel);
203 layoutGroupPos->addStretch();
205 //aTabWidget->addTab(GroupMain, imageOp, tr("GEOM_PIPETSHAPE_GROUPMAIN"));
206 aTabWidget->addTab(GroupMain, tr("GEOM_PIPETSHAPE_GROUPMAIN"));
207 aTabWidget->addTab(GroupReduct, tr("GEOM_PIPETSHAPE_GROUPREDUCT"));
208 aTabWidget->addTab(GroupPos, tr("GEOM_PIPETSHAPE_GROUPPOS"));
210 myMainLayout->addWidget(aTabWidget, 0, 0, 1, 1);
211 connect(aTabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
212 /***************************************************************/
214 setHelpFileName("create_pipetshape_page.html");
219 //=================================================================================
221 //=================================================================================
222 AdvancedGUI_PipeTShapeDlg::~AdvancedGUI_PipeTShapeDlg() {
223 // no need to delete child widgets, Qt does it all for us
226 //=================================================================================
229 //=================================================================================
230 void AdvancedGUI_PipeTShapeDlg::Init()
232 // Get setting of step value from file configuration
233 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
234 double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
235 double minValue = Precision::Approximation();
237 myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
238 myOkPoint1 = myOkPoint2 = myOkPoint3 = false;
240 pipeTShapeGroupObjects.clear();
242 // min, max, step and decimals for spin boxes
243 initSpinBox(MainTubeGroupParams->SpinBox_DX, minValue, COORD_MAX, step, "length_precision");
244 initSpinBox(MainTubeGroupParams->SpinBox_DY, minValue, COORD_MAX, step, "length_precision");
245 initSpinBox(MainTubeGroupParams->SpinBox_DZ, minValue, COORD_MAX, step, "length_precision");
246 initSpinBox(IncidentTubeGroupParams->SpinBox_DX, minValue, COORD_MAX, step, "length_precision");
247 initSpinBox(IncidentTubeGroupParams->SpinBox_DY, minValue, COORD_MAX, step, "length_precision");
248 initSpinBox(IncidentTubeGroupParams->SpinBox_DZ, minValue, COORD_MAX, step, "length_precision");
249 initSpinBox(ChamferGroupParams->SpinBox_DX, minValue, COORD_MAX, step, "length_precision");
250 initSpinBox(ChamferGroupParams->SpinBox_DY, minValue, COORD_MAX, step, "length_precision");
251 initSpinBox(FilletGroupParams->SpinBox_DX, minValue, COORD_MAX, step, "length_precision");
253 initSpinBox(LReductionGroupParams->SpinBox1, minValue, COORD_MAX, step, "length_precision");
254 initSpinBox(LReductionGroupParams->SpinBox2, minValue, COORD_MAX, step, "length_precision");
255 initSpinBox(LReductionGroupParams->SpinBox3, minValue, COORD_MAX, step, "length_precision");
256 initSpinBox(LReductionGroupParams->SpinBox4, 0., COORD_MAX, step, "length_precision");
258 initSpinBox(RReductionGroupParams->SpinBox1, minValue, COORD_MAX, step, "length_precision");
259 initSpinBox(RReductionGroupParams->SpinBox2, minValue, COORD_MAX, step, "length_precision");
260 initSpinBox(RReductionGroupParams->SpinBox3, minValue, COORD_MAX, step, "length_precision");
261 initSpinBox(RReductionGroupParams->SpinBox4, 0., COORD_MAX, step, "length_precision");
263 initSpinBox(IReductionGroupParams->SpinBox1, minValue, COORD_MAX, step, "length_precision");
264 initSpinBox(IReductionGroupParams->SpinBox2, minValue, COORD_MAX, step, "length_precision");
265 initSpinBox(IReductionGroupParams->SpinBox3, minValue, COORD_MAX, step, "length_precision");
266 initSpinBox(IReductionGroupParams->SpinBox4, 0., COORD_MAX, step, "length_precision");
269 MainTubeGroupParams->SpinBox_DX->setValue(80);
270 MainTubeGroupParams->SpinBox_DY->setValue(20);
271 MainTubeGroupParams->SpinBox_DZ->setValue(200);
272 IncidentTubeGroupParams->SpinBox_DX->setValue(50);
273 IncidentTubeGroupParams->SpinBox_DY->setValue(20);
274 IncidentTubeGroupParams->SpinBox_DZ->setValue(200);
275 ChamferGroupParams->SpinBox_DX->setValue(20);
276 ChamferGroupParams->SpinBox_DY->setValue(10);
277 FilletGroupParams->SpinBox_DX->setValue(20);
279 LReductionGroupParams->SpinBox1->setValue(60);
280 LReductionGroupParams->SpinBox2->setValue(30);
281 LReductionGroupParams->SpinBox3->setValue(40);
282 LReductionGroupParams->SpinBox4->setValue(20);
284 RReductionGroupParams->SpinBox1->setValue(60);
285 RReductionGroupParams->SpinBox2->setValue(30);
286 RReductionGroupParams->SpinBox3->setValue(40);
287 RReductionGroupParams->SpinBox4->setValue(20);
289 IReductionGroupParams->SpinBox1->setValue(40);
290 IReductionGroupParams->SpinBox2->setValue(10);
291 IReductionGroupParams->SpinBox3->setValue(30);
292 IReductionGroupParams->SpinBox4->setValue(15);
294 CssNormal = QString("QDoubleSpinBox {");
295 CssNormal.append(MainTubeGroupParams->SpinBox_DZ->styleSheet());
296 CssNormal.append("}");
297 CssNormal.append("\nQPushButton {");
298 CssNormal.append(JunctionPointsSel->PushButton4->styleSheet());
299 CssNormal.append("}");
300 CssAcceptable = "QDoubleSpinBox, QPushButton {background-color: rgb(85, 170, 127)}";
301 CssRefused = "QDoubleSpinBox, QPushButton {background-color: rgb(255, 0, 0)}";
303 showOnlyPreviewControl();
305 // Signal/slot connections
306 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
307 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
308 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
309 //connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
310 // ValueChangedInSpinBox
311 connect(MainTubeGroupParams->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
312 connect(MainTubeGroupParams->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
313 connect(MainTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
314 connect(IncidentTubeGroupParams->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
315 connect(IncidentTubeGroupParams->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
316 connect(IncidentTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
317 connect(ChamferGroupParams->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
318 connect(ChamferGroupParams->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
319 connect(FilletGroupParams->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
321 connect(ChamferGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(ChamferOrFillet(bool)));
322 connect(FilletGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(ChamferOrFillet(bool)));
323 // Thickness reduction:
325 connect(LReductionGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(processPreview()));
326 connect(LReductionGroupParams->SpinBox1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
327 connect(LReductionGroupParams->SpinBox2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
328 connect(LReductionGroupParams->SpinBox3, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
329 connect(LReductionGroupParams->SpinBox4, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
331 connect(RReductionGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(processPreview()));
332 connect(RReductionGroupParams->SpinBox1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
333 connect(RReductionGroupParams->SpinBox2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
334 connect(RReductionGroupParams->SpinBox3, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
335 connect(RReductionGroupParams->SpinBox4, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
337 connect(IReductionGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(processPreview()));
338 connect(IReductionGroupParams->SpinBox1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
339 connect(IReductionGroupParams->SpinBox2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
340 connect(IReductionGroupParams->SpinBox3, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
341 connect(IReductionGroupParams->SpinBox4, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
343 connect(JunctionPointsSel->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(SetPosition(bool)));
344 connect(JunctionPointsSel->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
345 connect(JunctionPointsSel->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
346 connect(JunctionPointsSel->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
347 // ApplyNewDimensions
348 connect(JunctionPointsSel->PushButton4, SIGNAL(clicked()), this, SLOT(ApplyNewDimensions()));
349 connect(JunctionPointsSel->PushButton5, SIGNAL(clicked()), this, SLOT(ApplyNewDimensions()));
350 connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(UpdatePicture(QWidget*, QWidget*)));
351 //@@ put additional signal/slot connections here @@//
353 initName(tr("GEOM_PIPE_TSHAPE"));
355 qApp->processEvents();
357 resize(minimumSizeHint());
359 updateLabelImgPipeTShape();
360 LabelImgReduction->setPixmap(imageReduction.scaled(LabelImgReduction->size(),
362 Qt::SmoothTransformation));
366 //=================================================================================
367 // function : currentChanged()
368 // purpose : Tab widget management
369 //=================================================================================
370 void AdvancedGUI_PipeTShapeDlg::currentChanged (int tabId)
372 if (tabId == 0 || tabId == 1)
376 //=================================================================================
377 // function : ApplyNewDimensions()
379 //=================================================================================
380 void AdvancedGUI_PipeTShapeDlg::ApplyNewDimensions()
382 QPushButton* send = (QPushButton*) sender();
386 if (send == JunctionPointsSel->PushButton4) {
387 if (!JunctionPointsSel->LineEdit4->text().isEmpty()) {
388 newVal = JunctionPointsSel->LineEdit4->text().toDouble(&ok);
390 disconnect(MainTubeGroupParams->SpinBox_DZ, 0, this, 0);
391 MainTubeGroupParams->SpinBox_DZ->setValue(newVal);
392 connect(MainTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
393 MainTubeGroupParams->SpinBox_DZ->setToolTip("");
394 MainTubeGroupParams->SpinBox_DZ->setStyleSheet("background-color: rgb(255, 255, 255);");
395 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
400 else if (send == JunctionPointsSel->PushButton5) {
401 if (!JunctionPointsSel->LineEdit5->text().isEmpty()) {
402 newVal = JunctionPointsSel->LineEdit5->text().toDouble(&ok);
404 disconnect(IncidentTubeGroupParams->SpinBox_DZ, 0, this, 0);
405 IncidentTubeGroupParams->SpinBox_DZ->setValue(newVal);
406 connect(IncidentTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
407 IncidentTubeGroupParams->SpinBox_DZ->setToolTip("");
408 IncidentTubeGroupParams->SpinBox_DZ->setStyleSheet("background-color: rgb(255, 255, 255);");
409 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
416 //=================================================================================
417 // function : UpdatePicture()
419 //=================================================================================
420 void AdvancedGUI_PipeTShapeDlg::UpdatePicture (QWidget* old, QWidget* now)
422 if (ChamferGroupParams->GroupBox1->isChecked())
423 if (now == MainTubeGroupParams->SpinBox_DX)
424 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_R1"));
425 else if (now == MainTubeGroupParams->SpinBox_DY)
426 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_W1"));
427 else if (now == MainTubeGroupParams->SpinBox_DZ)
428 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_L1"));
429 else if (now == IncidentTubeGroupParams->SpinBox_DX)
430 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_R2"));
431 else if (now == IncidentTubeGroupParams->SpinBox_DY)
432 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_W2"));
433 else if (now == IncidentTubeGroupParams->SpinBox_DZ)
434 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_L2"));
435 else if (now == ChamferGroupParams->SpinBox_DX)
436 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_H"));
437 else if (now == ChamferGroupParams->SpinBox_DY)
438 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_W"));
440 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER"));
441 else if (FilletGroupParams->GroupBox1->isChecked())
442 if (now == MainTubeGroupParams->SpinBox_DX)
443 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_R1"));
444 else if (now == MainTubeGroupParams->SpinBox_DY)
445 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_W1"));
446 else if (now == MainTubeGroupParams->SpinBox_DZ)
447 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_L1"));
448 else if (now == IncidentTubeGroupParams->SpinBox_DX)
449 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_R2"));
450 else if (now == IncidentTubeGroupParams->SpinBox_DY)
451 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_W2"));
452 else if (now == IncidentTubeGroupParams->SpinBox_DZ)
453 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_L2"));
454 else if (now == FilletGroupParams->SpinBox_DX)
455 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_RF"));
457 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET"));
459 if (now == MainTubeGroupParams->SpinBox_DX)
460 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_R1"));
461 else if (now == MainTubeGroupParams->SpinBox_DY)
462 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_W1"));
463 else if (now == MainTubeGroupParams->SpinBox_DZ)
464 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_L1"));
465 else if (now == IncidentTubeGroupParams->SpinBox_DX)
466 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_R2"));
467 else if (now == IncidentTubeGroupParams->SpinBox_DY)
468 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_W2"));
469 else if (now == IncidentTubeGroupParams->SpinBox_DZ)
470 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_L2"));
472 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE"));
474 updateLabelImgPipeTShape();
477 //=================================================================================
478 // function : SetPosition()
480 //=================================================================================
481 void AdvancedGUI_PipeTShapeDlg::SetPosition (bool isChecked)
485 JunctionPointsSel->LineEdit4->setText("");
486 JunctionPointsSel->LineEdit5->setText("");
487 //connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(
488 //SelectionIntoArgument()));
489 JunctionPointsSel->PushButton1->click();
490 SelectionIntoArgument();
493 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
494 JunctionPointsSel->LineEdit4->setText("");
495 JunctionPointsSel->LineEdit5->setText("");
500 //=================================================================================
501 // function : ValueChangedInSpinBox()
503 //=================================================================================
504 void AdvancedGUI_PipeTShapeDlg::ValueChangedInSpinBox (double newValue)
506 if (JunctionPointsSel->GroupBox1->isChecked() && myOkPoint1 && myOkPoint2 && myOkPoint3)
507 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
511 //=================================================================================
512 // function : SelectionIntoArgument()
513 // purpose : Called when selection as changed or other case
514 //=================================================================================
515 void AdvancedGUI_PipeTShapeDlg::SelectionIntoArgument()
518 //myEditCurrentArgument->setText("");
520 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
521 SALOME_ListIO aSelList;
522 aSelMgr->selectedObjects(aSelList);
524 if (aSelList.Extent() != 1) {
525 if (myEditCurrentArgument == JunctionPointsSel->LineEdit1)
527 else if (myEditCurrentArgument == JunctionPointsSel->LineEdit2)
529 else if (myEditCurrentArgument == JunctionPointsSel->LineEdit3)
532 myEditCurrentArgument->setText("");
536 if (aSelList.Extent() == 1) {
537 Handle(SALOME_InteractiveObject) anIO = aSelList.First();
538 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(anIO);
539 if (!CORBA::is_nil(aSelectedObject)) {
540 QString aName = GEOMBase::GetName(aSelectedObject);
542 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) {
544 TColStd_IndexedMapOfInteger aMap;
545 aSelMgr->GetIndexes(anIO, aMap);
546 if (aMap.Extent() == 1) { // Local Selection
547 int anIndex = aMap(1);
548 aName += QString(":vertex_%1").arg(anIndex);
550 //Find SubShape Object in Father
551 GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
553 if (aFindedObject->_is_nil()) { // Object not found in study
554 GEOM::GEOM_IShapesOperations_var aShapesOp =
555 getGeomEngine()->GetIShapesOperations(getStudyId());
556 aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
559 aSelectedObject = aFindedObject; // get Object from study
561 GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE);
562 } else { // Global Selection
563 if (aShape.ShapeType() != TopAbs_VERTEX) {
564 aSelectedObject = GEOM::GEOM_Object::_nil();
570 if (aShape.IsNull() || aShape.ShapeType() != TopAbs_VERTEX) {
573 myEditCurrentArgument->setText(aName);
574 if (myEditCurrentArgument == JunctionPointsSel->LineEdit1) {
575 myPoint1 = aSelectedObject;
578 JunctionPointsSel->PushButton2->click();
579 } else if (myEditCurrentArgument == JunctionPointsSel->LineEdit2) {
580 myPoint2 = aSelectedObject;
583 JunctionPointsSel->PushButton3->click();
584 } else if (myEditCurrentArgument == JunctionPointsSel->LineEdit3) {
585 myPoint3 = aSelectedObject;
588 JunctionPointsSel->PushButton1->click();
593 if (myOkPoint1 && myOkPoint2 && myOkPoint3) {
594 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
599 //=================================================================================
600 // function : SetEditCurrentArgument()
602 //=================================================================================
603 void AdvancedGUI_PipeTShapeDlg::SetEditCurrentArgument()
605 QPushButton* send = (QPushButton*) sender();
607 if (send == JunctionPointsSel->PushButton1) {
608 myEditCurrentArgument = JunctionPointsSel->LineEdit1;
609 JunctionPointsSel->PushButton2->setDown(false);
610 JunctionPointsSel->LineEdit2->setEnabled(false);
611 JunctionPointsSel->PushButton3->setDown(false);
612 JunctionPointsSel->LineEdit3->setEnabled(false);
614 else if (send == JunctionPointsSel->PushButton2) {
615 myEditCurrentArgument = JunctionPointsSel->LineEdit2;
616 JunctionPointsSel->PushButton1->setDown(false);
617 JunctionPointsSel->LineEdit1->setEnabled(false);
618 JunctionPointsSel->PushButton3->setDown(false);
619 JunctionPointsSel->LineEdit3->setEnabled(false);
621 else if (send == JunctionPointsSel->PushButton3) {
622 myEditCurrentArgument = JunctionPointsSel->LineEdit3;
623 JunctionPointsSel->PushButton1->setDown(false);
624 JunctionPointsSel->LineEdit1->setEnabled(false);
625 JunctionPointsSel->PushButton2->setDown(false);
626 JunctionPointsSel->LineEdit2->setEnabled(false);
630 myEditCurrentArgument->setEnabled(true);
631 myEditCurrentArgument->setFocus();
632 myEditCurrentArgument->setText("");
633 // after setFocus(), because it will be setDown(false) when loses focus
636 JunctionPointsSel->LineEdit4->setText("");
637 JunctionPointsSel->LineEdit5->setText("");
639 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
640 //globalSelection(GEOM_POINT);
641 globalSelection(); // close local contexts, if any
642 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
643 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
644 this, SLOT(SelectionIntoArgument()));
647 //=================================================================================
648 // function : SetDoubleSpinBoxStep()
649 // purpose : Double spin box management
650 //=================================================================================
651 void AdvancedGUI_PipeTShapeDlg::SetDoubleSpinBoxStep (double step)
653 MainTubeGroupParams->SpinBox_DX->setSingleStep(step);
654 MainTubeGroupParams->SpinBox_DY->setSingleStep(step);
655 MainTubeGroupParams->SpinBox_DZ->setSingleStep(step);
656 IncidentTubeGroupParams->SpinBox_DX->setSingleStep(step);
657 IncidentTubeGroupParams->SpinBox_DY->setSingleStep(step);
658 IncidentTubeGroupParams->SpinBox_DZ->setSingleStep(step);
659 ChamferGroupParams->SpinBox_DX->setSingleStep(step);
660 ChamferGroupParams->SpinBox_DY->setSingleStep(step);
661 FilletGroupParams->SpinBox_DX->setSingleStep(step);
663 LReductionGroupParams->SpinBox1->setSingleStep(step);
664 LReductionGroupParams->SpinBox2->setSingleStep(step);
665 LReductionGroupParams->SpinBox3->setSingleStep(step);
666 LReductionGroupParams->SpinBox4->setSingleStep(step);
668 RReductionGroupParams->SpinBox1->setSingleStep(step);
669 RReductionGroupParams->SpinBox2->setSingleStep(step);
670 RReductionGroupParams->SpinBox3->setSingleStep(step);
671 RReductionGroupParams->SpinBox4->setSingleStep(step);
673 IReductionGroupParams->SpinBox1->setSingleStep(step);
674 IReductionGroupParams->SpinBox2->setSingleStep(step);
675 IReductionGroupParams->SpinBox3->setSingleStep(step);
676 IReductionGroupParams->SpinBox4->setSingleStep(step);
679 //=================================================================================
680 // function : ClickOnOk()
682 //=================================================================================
683 void AdvancedGUI_PipeTShapeDlg::ClickOnOk()
685 setIsApplyAndClose( true );
690 //=================================================================================
691 // function : ClickOnApply()
693 //=================================================================================
694 bool AdvancedGUI_PipeTShapeDlg::ClickOnApply()
701 if (!isApplyAndClose())
706 //=================================================================================
707 // function : ActivateThisDialog()
709 //=================================================================================
710 void AdvancedGUI_PipeTShapeDlg::ActivateThisDialog()
712 GEOMBase_Skeleton::ActivateThisDialog();
713 //globalSelection( GEOM_POINT);
714 //connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(
715 // currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
716 if (myOkPoint1 && myOkPoint2 && myOkPoint3)
717 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
721 //=================================================================================
722 // function : enterEvent [REDEFINED]
724 //=================================================================================
725 void AdvancedGUI_PipeTShapeDlg::enterEvent (QEvent*)
727 if (!mainFrame()->GroupButtons->isEnabled())
728 ActivateThisDialog();
731 //=================================================================================
732 // function : resizeEvent [REDEFINED]
734 //=================================================================================
735 void AdvancedGUI_PipeTShapeDlg::resizeEvent (QResizeEvent */*event*/)
737 QSize scaledSize1 = imagePipeTShape.size();
738 scaledSize1.scale(LabelImgPipeTShape->size(), Qt::KeepAspectRatio);
739 if (!LabelImgPipeTShape->pixmap() || scaledSize1 != LabelImgPipeTShape->pixmap()->size())
740 updateLabelImgPipeTShape();
742 QSize scaledSize2 = imageReduction.size();
743 scaledSize2.scale(LabelImgReduction->size(), Qt::KeepAspectRatio);
744 if (!LabelImgReduction->pixmap() || scaledSize2 != LabelImgReduction->pixmap()->size())
745 LabelImgReduction->setPixmap(imageReduction.scaled(LabelImgReduction->size(),
747 Qt::SmoothTransformation));
750 //=================================================================================
751 // function : updateLabelImgPipeTShape
753 //=================================================================================
754 void AdvancedGUI_PipeTShapeDlg::updateLabelImgPipeTShape()
756 LabelImgPipeTShape->setPixmap(imagePipeTShape.scaled(LabelImgPipeTShape->size(),
758 Qt::SmoothTransformation));
761 //=================================================================================
762 // function : ChamferOrFillet()
764 //=================================================================================
765 void AdvancedGUI_PipeTShapeDlg::ChamferOrFillet (bool)
767 QGroupBox* send = (QGroupBox*) sender();
769 if (send == ChamferGroupParams->GroupBox1) {
770 if (send->isChecked()) {
771 disconnect(FilletGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, 0);
772 FilletGroupParams->GroupBox1->setChecked(false);
773 connect(FilletGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(ChamferOrFillet(bool)));
774 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER"));
777 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE"));
779 updateLabelImgPipeTShape();
780 if (myOkPoint1 && myOkPoint2 && myOkPoint3)
781 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
784 else if (send == FilletGroupParams->GroupBox1) {
785 if (send->isChecked()) {
786 disconnect(ChamferGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, 0);
787 ChamferGroupParams->GroupBox1->setChecked(!send->isChecked());
788 connect(ChamferGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(ChamferOrFillet(bool)));
789 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET"));
792 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE"));
794 updateLabelImgPipeTShape();
795 if (myOkPoint1 && myOkPoint2 && myOkPoint3)
796 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
801 //=================================================================================
802 // function : DisplayPreview()
804 //=================================================================================
805 void AdvancedGUI_PipeTShapeDlg::DisplayPreview (const bool activate, const bool update,
806 const bool toRemoveFromEngine, const double lineWidth,
807 const int displayMode, const int color)
811 erasePreview(update);
818 SUIT_OverrideCursor wc;
820 bool hexMeshState = HexMeshCheckBox->isChecked();
821 HexMeshCheckBox->setChecked(false);
822 if (!executeNoCheck(objects) || !getOperation()->IsDone()) {
826 ObjectList::iterator it = objects.begin();
827 GEOM::GEOM_Object_var obj = *it;
828 displayPreview(obj, true, activate, false, lineWidth, displayMode, color);
829 if (toRemoveFromEngine)
832 HexMeshCheckBox->setChecked(hexMeshState);
833 } catch (const SALOME::SALOME_Exception& e) {
834 SalomeApp_Tools::QtCatchCorbaException(e);
841 //=================================================================================
842 // function : createOperation
844 //=================================================================================
845 GEOM::GEOM_IOperations_ptr AdvancedGUI_PipeTShapeDlg::createOperation()
847 //return getGeomEngine()->GetIAdvancedOperations(getStudyId());
848 return getGeomEngine()->GetPluginOperations(getStudyId(), "AdvancedEngine");
851 //=================================================================================
852 // function : isValid
854 //=================================================================================
855 bool AdvancedGUI_PipeTShapeDlg::isValid (QString& msg)
859 ok = MainTubeGroupParams->SpinBox_DX->isValid(msg, !IsPreview()) && ok;
860 ok = MainTubeGroupParams->SpinBox_DY->isValid(msg, !IsPreview()) && ok;
861 ok = MainTubeGroupParams->SpinBox_DZ->isValid(msg, !IsPreview()) && ok;
862 ok = IncidentTubeGroupParams->SpinBox_DX->isValid(msg, !IsPreview()) && ok;
863 ok = IncidentTubeGroupParams->SpinBox_DY->isValid(msg, !IsPreview()) && ok;
864 ok = IncidentTubeGroupParams->SpinBox_DZ->isValid(msg, !IsPreview()) && ok;
865 ok = ChamferGroupParams->SpinBox_DX->isValid(msg, !IsPreview()) && ok;
866 ok = ChamferGroupParams->SpinBox_DY->isValid(msg, !IsPreview()) && ok;
867 ok = FilletGroupParams->SpinBox_DX->isValid(msg, !IsPreview()) && ok;
869 if (LReductionGroupParams->GroupBox1->isChecked()) {
870 ok = LReductionGroupParams->SpinBox1->isValid(msg, !IsPreview()) && ok;
871 ok = LReductionGroupParams->SpinBox2->isValid(msg, !IsPreview()) && ok;
872 ok = LReductionGroupParams->SpinBox3->isValid(msg, !IsPreview()) && ok;
873 ok = LReductionGroupParams->SpinBox4->isValid(msg, !IsPreview()) && ok;
874 if(MainTubeGroupParams->SpinBox_DX->value() == LReductionGroupParams->SpinBox1->value()) {
875 msg += tr("GEOM_PIPETSHAPE_ERR_EQUAL_RADII_L") + "\n";
878 if(MainTubeGroupParams->SpinBox_DX->value() + MainTubeGroupParams->SpinBox_DY->value() ==
879 LReductionGroupParams->SpinBox1->value() + LReductionGroupParams->SpinBox2->value()) {
880 msg += tr("GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_L") + "\n";
884 if (RReductionGroupParams->GroupBox1->isChecked()) {
885 ok = RReductionGroupParams->SpinBox1->isValid(msg, !IsPreview()) && ok;
886 ok = RReductionGroupParams->SpinBox2->isValid(msg, !IsPreview()) && ok;
887 ok = RReductionGroupParams->SpinBox3->isValid(msg, !IsPreview()) && ok;
888 ok = RReductionGroupParams->SpinBox4->isValid(msg, !IsPreview()) && ok;
889 if(MainTubeGroupParams->SpinBox_DX->value() == RReductionGroupParams->SpinBox1->value()) {
890 msg += tr("GEOM_PIPETSHAPE_ERR_EQUAL_RADII_R") + "\n";
893 if(MainTubeGroupParams->SpinBox_DX->value() + MainTubeGroupParams->SpinBox_DY->value() ==
894 RReductionGroupParams->SpinBox1->value() + RReductionGroupParams->SpinBox2->value()) {
895 msg += tr("GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_R") + "\n";
899 if (IReductionGroupParams->GroupBox1->isChecked()) {
900 ok = IReductionGroupParams->SpinBox1->isValid(msg, !IsPreview()) && ok;
901 ok = IReductionGroupParams->SpinBox2->isValid(msg, !IsPreview()) && ok;
902 ok = IReductionGroupParams->SpinBox3->isValid(msg, !IsPreview()) && ok;
903 ok = IReductionGroupParams->SpinBox4->isValid(msg, !IsPreview()) && ok;
904 if(IncidentTubeGroupParams->SpinBox_DX->value() == IReductionGroupParams->SpinBox1->value()) {
905 msg += tr("GEOM_PIPETSHAPE_ERR_EQUAL_RADII_I") + "\n";
908 if(IncidentTubeGroupParams->SpinBox_DX->value() + IncidentTubeGroupParams->SpinBox_DY->value() ==
909 IReductionGroupParams->SpinBox1->value() + IReductionGroupParams->SpinBox2->value()) {
910 msg += tr("GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_I") + "\n";
915 ok = fabs(MainTubeGroupParams->SpinBox_DX->value()) > Precision::Confusion() && ok;
916 ok = fabs(MainTubeGroupParams->SpinBox_DY->value()) > Precision::Confusion() && ok;
917 ok = fabs(MainTubeGroupParams->SpinBox_DZ->value()) > Precision::Confusion() && ok;
918 ok = fabs(IncidentTubeGroupParams->SpinBox_DX->value()) > Precision::Confusion() && ok;
919 ok = fabs(IncidentTubeGroupParams->SpinBox_DY->value()) > Precision::Confusion() && ok;
920 ok = fabs(IncidentTubeGroupParams->SpinBox_DZ->value()) > Precision::Confusion() && ok;
921 ok = fabs(ChamferGroupParams->SpinBox_DX->value()) > Precision::Confusion() && ok;
922 ok = fabs(ChamferGroupParams->SpinBox_DY->value()) > Precision::Confusion() && ok;
923 ok = fabs(FilletGroupParams->SpinBox_DX->value()) > Precision::Confusion() && ok;
925 if (JunctionPointsSel->GroupBox1->isChecked())
926 ok = myOkPoint1 && myOkPoint2 && myOkPoint3 && ok;
931 //=================================================================================
932 // function : CheckCompatiblePosition()
934 //=================================================================================
935 bool AdvancedGUI_PipeTShapeDlg::CheckCompatiblePosition
936 (GEOM::GEOM_Object_var theP1, GEOM::GEOM_Object_var theP2, GEOM::GEOM_Object_var theP3,
939 MainTubeGroupParams->SpinBox_DZ->setStyleSheet(CssNormal);
940 IncidentTubeGroupParams->SpinBox_DZ->setStyleSheet(CssNormal);
941 JunctionPointsSel->PushButton4->setStyleSheet(CssNormal);
942 JunctionPointsSel->PushButton5->setStyleSheet(CssNormal);
944 CORBA::Double theL1 = MainTubeGroupParams->SpinBox_DZ->value();
945 CORBA::Double theL2 = IncidentTubeGroupParams->SpinBox_DZ->value();
947 JunctionPointsSel->LineEdit4->setText("");
948 JunctionPointsSel->LineEdit5->setText("");
950 MainTubeGroupParams->SpinBox_DZ->setToolTip("");
951 IncidentTubeGroupParams->SpinBox_DZ->setToolTip("");
955 if ( GEOMBase::GetShape( theP1, aShape ) && !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
956 P1 = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
960 if ( GEOMBase::GetShape( theP2, aShape ) && !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
961 P2 = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
965 if ( GEOMBase::GetShape( theP3, aShape ) && !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
966 P3 = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
970 double d12 = P1.Distance(P2);
971 double d13 = P1.Distance(P3);
972 double d23 = P2.Distance(P3);
974 if (Abs(d12) <= Precision::Confusion()) {
975 //SetErrorCode("Junctions points P1 and P2 are identical");
978 if (Abs(d13) <= Precision::Confusion()) {
979 //SetErrorCode("Junctions points P1 and P3 are identical");
982 if (Abs(d23) <= Precision::Confusion()) {
983 //SetErrorCode("Junctions points P2 and P3 are identical");
987 long double newL1 = 0.5 * d12;
988 long double newL2 = sqrt(pow(d13,2)-pow(newL1,2));
990 JunctionPointsSel->LineEdit4->setText(QString::number(newL1,'f',7));
991 JunctionPointsSel->LineEdit5->setText(QString::number(newL2,'f',7));
993 if (fabs(newL1 - theL1) > Precision::Approximation()) {
994 if ((newL1 * (1 - theTolerance) - theL1 <= Precision::Approximation()) &&
995 (newL1 * (1 + theTolerance) - theL1 >= Precision::Approximation())) {
996 disconnect(MainTubeGroupParams->SpinBox_DZ, 0, this, 0);
997 MainTubeGroupParams->SpinBox_DZ->setValue(newL1);
998 connect(MainTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged(double)),
999 this, SLOT(ValueChangedInSpinBox(double)));
1000 MainTubeGroupParams->SpinBox_DZ->setToolTip("Value was recomputed to fit with position");
1001 MainTubeGroupParams->SpinBox_DZ->setStyleSheet(CssAcceptable);
1002 JunctionPointsSel->PushButton4->setStyleSheet(CssAcceptable);
1005 MainTubeGroupParams->SpinBox_DZ->setToolTip("Value is incompatible with position");
1006 MainTubeGroupParams->SpinBox_DZ->setStyleSheet(CssRefused);
1007 JunctionPointsSel->PushButton4->setStyleSheet(CssRefused);
1011 MainTubeGroupParams->SpinBox_DZ->setStyleSheet(CssNormal);
1012 JunctionPointsSel->PushButton4->setStyleSheet(CssNormal);
1015 if (fabs(newL2 - theL2) > Precision::Approximation()) {
1016 if ((newL2 * (1 - theTolerance) - theL2 <= Precision::Approximation()) &&
1017 (newL2 * (1 + theTolerance) - theL2 >= Precision::Approximation())) {
1018 disconnect(IncidentTubeGroupParams->SpinBox_DZ, 0, this, 0);
1019 IncidentTubeGroupParams->SpinBox_DZ->setValue(newL2);
1020 connect(IncidentTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
1021 IncidentTubeGroupParams->SpinBox_DZ->setToolTip("Value was recomputed to fit with position");
1022 IncidentTubeGroupParams->SpinBox_DZ->setStyleSheet(CssAcceptable);
1023 JunctionPointsSel->PushButton5->setStyleSheet(CssAcceptable);
1026 IncidentTubeGroupParams->SpinBox_DZ->setToolTip("Value is incompatible with position");
1027 IncidentTubeGroupParams->SpinBox_DZ->setStyleSheet(CssRefused);
1028 JunctionPointsSel->PushButton5->setStyleSheet(CssRefused);
1032 IncidentTubeGroupParams->SpinBox_DZ->setStyleSheet(CssNormal);
1033 JunctionPointsSel->PushButton5->setStyleSheet(CssNormal);
1039 //=================================================================================
1040 // function : execute
1042 //=================================================================================
1043 bool AdvancedGUI_PipeTShapeDlg::execute (ObjectList& objects)
1045 if (JunctionPointsSel->GroupBox1->isChecked() && myOkPoint1 && myOkPoint2 && myOkPoint3)
1046 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
1048 return executeNoCheck(objects);
1051 //=================================================================================
1052 // function : executeNoCheck
1054 //=================================================================================
1055 bool AdvancedGUI_PipeTShapeDlg::executeNoCheck (ObjectList& objects)
1059 // GEOM::GEOM_Object_var anObj;
1060 GEOM::ListOfGO_var anObj;
1062 GEOM::GEOM_IAdvancedOperations_var anOper = GEOM::GEOM_IAdvancedOperations::_narrow(getOperation());
1064 //@@ retrieve input values from the widgets here @@//
1065 CORBA::Double theR1 = MainTubeGroupParams->SpinBox_DX->value();
1066 CORBA::Double theW1 = MainTubeGroupParams->SpinBox_DY->value();
1067 CORBA::Double theL1 = MainTubeGroupParams->SpinBox_DZ->value();
1068 CORBA::Double theR2 = IncidentTubeGroupParams->SpinBox_DX->value();
1069 CORBA::Double theW2 = IncidentTubeGroupParams->SpinBox_DY->value();
1070 CORBA::Double theL2 = IncidentTubeGroupParams->SpinBox_DZ->value();
1071 CORBA::Double theH = ChamferGroupParams->SpinBox_DX->value();
1072 CORBA::Double theW = ChamferGroupParams->SpinBox_DY->value();
1073 CORBA::Double theRF = FilletGroupParams->SpinBox_DX->value();
1074 CORBA::Boolean theHexMesh = HexMeshCheckBox->isChecked();
1076 // Thickness reductions
1077 CORBA::Double theRL = 0., theWL = 0., theLtransL = 0., theLthinL = 0.;
1078 CORBA::Double theRR = 0., theWR = 0., theLtransR = 0., theLthinR = 0.;
1079 CORBA::Double theRI = 0., theWI = 0., theLtransI = 0., theLthinI = 0.;
1081 if (LReductionGroupParams->GroupBox1->isChecked()) {
1082 theRL = LReductionGroupParams->SpinBox1->value();
1083 theWL = LReductionGroupParams->SpinBox2->value();
1084 theLtransL = LReductionGroupParams->SpinBox3->value();
1085 theLthinL = LReductionGroupParams->SpinBox4->value();
1087 if (RReductionGroupParams->GroupBox1->isChecked()) {
1088 theRR = RReductionGroupParams->SpinBox1->value();
1089 theWR = RReductionGroupParams->SpinBox2->value();
1090 theLtransR = RReductionGroupParams->SpinBox3->value();
1091 theLthinR = RReductionGroupParams->SpinBox4->value();
1093 if (IReductionGroupParams->GroupBox1->isChecked()) {
1094 theRI = IReductionGroupParams->SpinBox1->value();
1095 theWI = IReductionGroupParams->SpinBox2->value();
1096 theLtransI = IReductionGroupParams->SpinBox3->value();
1097 theLthinI = IReductionGroupParams->SpinBox4->value();
1100 //if (JunctionPointsSel->GroupBox1->isChecked()) {
1101 // CheckCompatiblePosition(theL1, theL2, myPoint1, myPoint2, myPoint3, 0.01);
1102 // theL1 = MainTubeGroupParams->SpinBox_DZ->value();
1103 // theL2 = IncidentTubeGroupParams->SpinBox_DZ->value();
1106 // call engine function
1107 if (ChamferGroupParams->GroupBox1->isChecked()) {
1108 if (JunctionPointsSel->GroupBox1->isChecked())
1109 anObj = anOper->MakePipeTShapeTRChamferWithPosition(theR1, theW1, theL1, theR2, theW2, theL2,
1110 theRL, theWL, theLtransL, theLthinL,
1111 theRR, theWR, theLtransR, theLthinR,
1112 theRI, theWI, theLtransI, theLthinI,
1113 theH, theW, theHexMesh, myPoint1, myPoint2, myPoint3);
1115 anObj = anOper->MakePipeTShapeTRChamfer(theR1, theW1, theL1, theR2, theW2, theL2,
1116 theRL, theWL, theLtransL, theLthinL,
1117 theRR, theWR, theLtransR, theLthinR,
1118 theRI, theWI, theLtransI, theLthinI,
1119 theH, theW, theHexMesh);
1121 else if (FilletGroupParams->GroupBox1->isChecked()) {
1122 if (JunctionPointsSel->GroupBox1->isChecked())
1123 anObj = anOper->MakePipeTShapeTRFilletWithPosition(theR1, theW1, theL1, theR2, theW2, theL2,
1124 theRL, theWL, theLtransL, theLthinL,
1125 theRR, theWR, theLtransR, theLthinR,
1126 theRI, theWI, theLtransI, theLthinI,
1127 theRF, theHexMesh, myPoint1, myPoint2, myPoint3);
1129 anObj = anOper->MakePipeTShapeTRFillet(theR1, theW1, theL1, theR2, theW2, theL2,
1130 theRL, theWL, theLtransL, theLthinL,
1131 theRR, theWR, theLtransR, theLthinR,
1132 theRI, theWI, theLtransI, theLthinI,
1136 if (JunctionPointsSel->GroupBox1->isChecked())
1137 anObj = anOper->MakePipeTShapeTRWithPosition(theR1, theW1, theL1, theR2, theW2, theL2,
1138 theRL, theWL, theLtransL, theLthinL,
1139 theRR, theWR, theLtransR, theLthinR,
1140 theRI, theWI, theLtransI, theLthinI,
1141 theHexMesh, myPoint1, myPoint2, myPoint3);
1143 anObj = anOper->MakePipeTShapeTR(theR1, theW1, theL1, theR2, theW2, theL2,
1144 theRL, theWL, theLtransL, theLthinL,
1145 theRR, theWR, theLtransR, theLthinR,
1146 theRI, theWI, theLtransI, theLthinI,
1150 res = anObj->length();
1154 //res = !anObj->_is_nil();
1155 if (res && !IsPreview()) {
1156 QStringList aParameters;
1157 //@@ put stringified input parameters to the string list here to store in the data model for notebook @@//
1158 aParameters << MainTubeGroupParams->SpinBox_DX->text(); // R1 parameter
1159 aParameters << MainTubeGroupParams->SpinBox_DY->text(); // W1 parameter
1160 aParameters << MainTubeGroupParams->SpinBox_DZ->text(); // L1 parameter
1161 aParameters << IncidentTubeGroupParams->SpinBox_DX->text(); // R2 parameter
1162 aParameters << IncidentTubeGroupParams->SpinBox_DY->text(); // W2 parameter
1163 aParameters << IncidentTubeGroupParams->SpinBox_DZ->text(); // L2 parameter
1165 if (ChamferGroupParams->GroupBox1->isChecked()) { // Chamfer parameter
1166 aParameters << ChamferGroupParams->SpinBox_DX->text(); // H parameter
1167 aParameters << ChamferGroupParams->SpinBox_DY->text(); // W parameter
1169 if (FilletGroupParams->GroupBox1->isChecked()) // Fillet parameter
1170 aParameters << FilletGroupParams->SpinBox_DX->text(); // RF parameter
1172 // Thickness reductions
1173 if (LReductionGroupParams->GroupBox1->isChecked()) {
1174 aParameters << LReductionGroupParams->SpinBox1->text();
1175 aParameters << LReductionGroupParams->SpinBox2->text();
1176 aParameters << LReductionGroupParams->SpinBox3->text();
1177 aParameters << LReductionGroupParams->SpinBox4->text();
1180 aParameters << "0" << "0" << "0" << "0";
1182 if (RReductionGroupParams->GroupBox1->isChecked()) {
1183 aParameters << RReductionGroupParams->SpinBox1->text();
1184 aParameters << RReductionGroupParams->SpinBox2->text();
1185 aParameters << RReductionGroupParams->SpinBox3->text();
1186 aParameters << RReductionGroupParams->SpinBox4->text();
1189 aParameters << "0" << "0" << "0" << "0";
1191 if (IReductionGroupParams->GroupBox1->isChecked()) {
1192 aParameters << IReductionGroupParams->SpinBox1->text();
1193 aParameters << IReductionGroupParams->SpinBox2->text();
1194 aParameters << IReductionGroupParams->SpinBox3->text();
1195 aParameters << IReductionGroupParams->SpinBox4->text();
1198 aParameters << "0" << "0" << "0" << "0";
1201 if (aParameters.count() > 0)
1202 anObj[0]->SetParameters(aParameters.join(":").toLatin1().constData());
1205 objects.push_back(anObj[0]._retn());
1206 pipeTShapeGroupObjects.clear();
1207 for (int i = 1, n = anObj->length(); i < n; i++) {
1208 pipeTShapeGroupObjects.push_back(anObj[i]._retn());
1211 return objects.size() > 0;
1214 //=================================================================================
1215 // function : restoreSubShapes
1217 //=================================================================================
1218 void AdvancedGUI_PipeTShapeDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
1219 SALOMEDS::SObject_ptr theSObject)
1221 SALOMEDS::GenericAttribute_var anAttr;
1222 if (!theSObject->FindAttribute(anAttr, "AttributeIOR"))
1225 SALOMEDS::AttributeIOR_var anAttrIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1226 CORBA::String_var anIORso = anAttrIOR->Value();
1228 // get Object from SObject
1229 GEOM::GEOM_Object_var theFather =
1230 GEOM::GEOM_Object::_narrow(myGeomGUI->getApp()->orb()->string_to_object(anIORso));
1231 if (CORBA::is_nil(theFather))
1234 ObjectList::iterator it = pipeTShapeGroupObjects.begin();
1236 for (int i = 0; it != pipeTShapeGroupObjects.end(); it++, i++) {
1237 getGeomEngine()->AddInStudy(theStudy, (*it), tr((*it)->GetName()).toStdString().c_str(), theFather);
1241 //=================================================================================
1242 // function : processPreview()
1243 // purpose : Display preview if CheckBoxPreview is checked
1244 //=================================================================================
1245 void AdvancedGUI_PipeTShapeDlg::processPreview()
1247 if (mainFrame()->CheckBoxPreview->isChecked())
1253 //=================================================================================
1254 // function : AdvancedGUI_4Spin
1256 //=================================================================================
1257 AdvancedGUI_4Spin::AdvancedGUI_4Spin()
1259 GroupBox1 = new QGroupBox ();
1261 gridLayout1 = new QGridLayout (GroupBox1);
1262 gridLayout1->setSpacing(6);
1263 gridLayout1->setContentsMargins(11, 11, 11, 11);
1264 gridLayout1->setHorizontalSpacing(6);
1265 gridLayout1->setVerticalSpacing(6);
1266 gridLayout1->setContentsMargins(9, 9, 9, 9);
1268 TextLabel1 = new QLabel (GroupBox1);
1269 TextLabel2 = new QLabel (GroupBox1);
1270 TextLabel3 = new QLabel (GroupBox1);
1271 TextLabel4 = new QLabel (GroupBox1);
1273 SpinBox1 = new SalomeApp_DoubleSpinBox (GroupBox1);
1274 SpinBox2 = new SalomeApp_DoubleSpinBox (GroupBox1);
1275 SpinBox3 = new SalomeApp_DoubleSpinBox (GroupBox1);
1276 SpinBox4 = new SalomeApp_DoubleSpinBox (GroupBox1);
1278 SpinBox1->setMinimumWidth(60);
1279 SpinBox2->setMinimumWidth(60);
1280 SpinBox3->setMinimumWidth(60);
1281 SpinBox4->setMinimumWidth(60);
1283 gridLayout1->addWidget(TextLabel1, 0, 0, 1, 1);
1284 gridLayout1->addWidget(TextLabel2, 1, 0, 1, 1);
1285 gridLayout1->addWidget(TextLabel3, 2, 0, 1, 1);
1286 gridLayout1->addWidget(TextLabel4, 3, 0, 1, 1);
1288 gridLayout1->addWidget(SpinBox1, 0, 1, 1, 1);
1289 gridLayout1->addWidget(SpinBox2, 1, 1, 1, 1);
1290 gridLayout1->addWidget(SpinBox3, 2, 1, 1, 1);
1291 gridLayout1->addWidget(SpinBox4, 3, 1, 1, 1);
1294 //=================================================================================
1295 // function : ~AdvancedGUI_4Spin()
1296 // purpose : Destroys the object and frees any allocated resources
1297 //=================================================================================
1298 AdvancedGUI_4Spin::~AdvancedGUI_4Spin()
1300 // no need to delete child widgets, Qt does it all for us