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)));
324 //connect(PreviewPushButton, SIGNAL(clicked()), this, SLOT(DisplayPreview()));
326 connect(JunctionPointsSel->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(SetPosition(bool)));
327 connect(JunctionPointsSel->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
328 connect(JunctionPointsSel->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
329 connect(JunctionPointsSel->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
330 // ApplyNewDimensions
331 connect(JunctionPointsSel->PushButton4, SIGNAL(clicked()), this, SLOT(ApplyNewDimensions()));
332 connect(JunctionPointsSel->PushButton5, SIGNAL(clicked()), this, SLOT(ApplyNewDimensions()));
333 connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(UpdatePicture(QWidget*, QWidget*)));
334 //@@ put additional signal/slot connections here @@//
336 initName(tr("GEOM_PIPE_TSHAPE"));
338 qApp->processEvents();
340 resize(minimumSizeHint());
342 updateLabelImgPipeTShape();
343 LabelImgReduction->setPixmap(imageReduction.scaled(LabelImgReduction->size(),
345 Qt::SmoothTransformation));
349 //=================================================================================
350 // function : currentChanged()
351 // purpose : Tab widget management
352 //=================================================================================
353 void AdvancedGUI_PipeTShapeDlg::currentChanged (int tabId)
355 if (tabId == 0 || tabId == 1)
359 //=================================================================================
360 // function : ApplyNewDimensions()
362 //=================================================================================
363 void AdvancedGUI_PipeTShapeDlg::ApplyNewDimensions()
365 QPushButton* send = (QPushButton*) sender();
369 if (send == JunctionPointsSel->PushButton4) {
370 if (!JunctionPointsSel->LineEdit4->text().isEmpty()) {
371 newVal = JunctionPointsSel->LineEdit4->text().toDouble(&ok);
373 disconnect(MainTubeGroupParams->SpinBox_DZ, 0, this, 0);
374 MainTubeGroupParams->SpinBox_DZ->setValue(newVal);
375 connect(MainTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
376 MainTubeGroupParams->SpinBox_DZ->setToolTip("");
377 MainTubeGroupParams->SpinBox_DZ->setStyleSheet("background-color: rgb(255, 255, 255);");
378 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
383 else if (send == JunctionPointsSel->PushButton5) {
384 if (!JunctionPointsSel->LineEdit5->text().isEmpty()) {
385 newVal = JunctionPointsSel->LineEdit5->text().toDouble(&ok);
387 disconnect(IncidentTubeGroupParams->SpinBox_DZ, 0, this, 0);
388 IncidentTubeGroupParams->SpinBox_DZ->setValue(newVal);
389 connect(IncidentTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
390 IncidentTubeGroupParams->SpinBox_DZ->setToolTip("");
391 IncidentTubeGroupParams->SpinBox_DZ->setStyleSheet("background-color: rgb(255, 255, 255);");
392 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
399 //=================================================================================
400 // function : UpdatePicture()
402 //=================================================================================
403 void AdvancedGUI_PipeTShapeDlg::UpdatePicture (QWidget* old, QWidget* now)
405 if (ChamferGroupParams->GroupBox1->isChecked())
406 if (now == MainTubeGroupParams->SpinBox_DX)
407 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_R1"));
408 else if (now == MainTubeGroupParams->SpinBox_DY)
409 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_W1"));
410 else if (now == MainTubeGroupParams->SpinBox_DZ)
411 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_L1"));
412 else if (now == IncidentTubeGroupParams->SpinBox_DX)
413 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_R2"));
414 else if (now == IncidentTubeGroupParams->SpinBox_DY)
415 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_W2"));
416 else if (now == IncidentTubeGroupParams->SpinBox_DZ)
417 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_L2"));
418 else if (now == ChamferGroupParams->SpinBox_DX)
419 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_H"));
420 else if (now == ChamferGroupParams->SpinBox_DY)
421 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_W"));
423 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER"));
424 else if (FilletGroupParams->GroupBox1->isChecked())
425 if (now == MainTubeGroupParams->SpinBox_DX)
426 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_R1"));
427 else if (now == MainTubeGroupParams->SpinBox_DY)
428 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_W1"));
429 else if (now == MainTubeGroupParams->SpinBox_DZ)
430 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_L1"));
431 else if (now == IncidentTubeGroupParams->SpinBox_DX)
432 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_R2"));
433 else if (now == IncidentTubeGroupParams->SpinBox_DY)
434 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_W2"));
435 else if (now == IncidentTubeGroupParams->SpinBox_DZ)
436 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_L2"));
437 else if (now == FilletGroupParams->SpinBox_DX)
438 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_RF"));
440 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET"));
442 if (now == MainTubeGroupParams->SpinBox_DX)
443 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_R1"));
444 else if (now == MainTubeGroupParams->SpinBox_DY)
445 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_W1"));
446 else if (now == MainTubeGroupParams->SpinBox_DZ)
447 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_L1"));
448 else if (now == IncidentTubeGroupParams->SpinBox_DX)
449 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_R2"));
450 else if (now == IncidentTubeGroupParams->SpinBox_DY)
451 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_W2"));
452 else if (now == IncidentTubeGroupParams->SpinBox_DZ)
453 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_L2"));
455 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE"));
457 updateLabelImgPipeTShape();
460 //=================================================================================
461 // function : SetPosition()
463 //=================================================================================
464 void AdvancedGUI_PipeTShapeDlg::SetPosition (bool isChecked)
468 JunctionPointsSel->LineEdit4->setText("");
469 JunctionPointsSel->LineEdit5->setText("");
470 //connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(
471 //SelectionIntoArgument()));
472 JunctionPointsSel->PushButton1->click();
473 SelectionIntoArgument();
476 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
477 JunctionPointsSel->LineEdit4->setText("");
478 JunctionPointsSel->LineEdit5->setText("");
483 //=================================================================================
484 // function : ValueChangedInSpinBox()
486 //=================================================================================
487 void AdvancedGUI_PipeTShapeDlg::ValueChangedInSpinBox (double newValue)
489 if (JunctionPointsSel->GroupBox1->isChecked() && myOkPoint1 && myOkPoint2 && myOkPoint3)
490 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
494 //=================================================================================
495 // function : SelectionIntoArgument()
496 // purpose : Called when selection as changed or other case
497 //=================================================================================
498 void AdvancedGUI_PipeTShapeDlg::SelectionIntoArgument()
501 //myEditCurrentArgument->setText("");
503 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
504 SALOME_ListIO aSelList;
505 aSelMgr->selectedObjects(aSelList);
507 if (aSelList.Extent() != 1) {
508 if (myEditCurrentArgument == JunctionPointsSel->LineEdit1)
510 else if (myEditCurrentArgument == JunctionPointsSel->LineEdit2)
512 else if (myEditCurrentArgument == JunctionPointsSel->LineEdit3)
515 myEditCurrentArgument->setText("");
519 if (aSelList.Extent() == 1) {
520 Handle(SALOME_InteractiveObject) anIO = aSelList.First();
521 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(anIO);
522 if (!CORBA::is_nil(aSelectedObject)) {
523 QString aName = GEOMBase::GetName(aSelectedObject);
525 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) {
527 TColStd_IndexedMapOfInteger aMap;
528 aSelMgr->GetIndexes(anIO, aMap);
529 if (aMap.Extent() == 1) { // Local Selection
530 int anIndex = aMap(1);
531 aName += QString(":vertex_%1").arg(anIndex);
533 //Find SubShape Object in Father
534 GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
536 if (aFindedObject->_is_nil()) { // Object not found in study
537 GEOM::GEOM_IShapesOperations_var aShapesOp =
538 getGeomEngine()->GetIShapesOperations(getStudyId());
539 aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
542 aSelectedObject = aFindedObject; // get Object from study
544 GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE);
545 } else { // Global Selection
546 if (aShape.ShapeType() != TopAbs_VERTEX) {
547 aSelectedObject = GEOM::GEOM_Object::_nil();
553 if (aShape.IsNull() || aShape.ShapeType() != TopAbs_VERTEX) {
556 myEditCurrentArgument->setText(aName);
557 if (myEditCurrentArgument == JunctionPointsSel->LineEdit1) {
558 myPoint1 = aSelectedObject;
561 JunctionPointsSel->PushButton2->click();
562 } else if (myEditCurrentArgument == JunctionPointsSel->LineEdit2) {
563 myPoint2 = aSelectedObject;
566 JunctionPointsSel->PushButton3->click();
567 } else if (myEditCurrentArgument == JunctionPointsSel->LineEdit3) {
568 myPoint3 = aSelectedObject;
571 JunctionPointsSel->PushButton1->click();
576 if (myOkPoint1 && myOkPoint2 && myOkPoint3) {
577 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
582 //=================================================================================
583 // function : SetEditCurrentArgument()
585 //=================================================================================
586 void AdvancedGUI_PipeTShapeDlg::SetEditCurrentArgument()
588 QPushButton* send = (QPushButton*) sender();
590 if (send == JunctionPointsSel->PushButton1) {
591 myEditCurrentArgument = JunctionPointsSel->LineEdit1;
592 JunctionPointsSel->PushButton2->setDown(false);
593 JunctionPointsSel->LineEdit2->setEnabled(false);
594 JunctionPointsSel->PushButton3->setDown(false);
595 JunctionPointsSel->LineEdit3->setEnabled(false);
597 else if (send == JunctionPointsSel->PushButton2) {
598 myEditCurrentArgument = JunctionPointsSel->LineEdit2;
599 JunctionPointsSel->PushButton1->setDown(false);
600 JunctionPointsSel->LineEdit1->setEnabled(false);
601 JunctionPointsSel->PushButton3->setDown(false);
602 JunctionPointsSel->LineEdit3->setEnabled(false);
604 else if (send == JunctionPointsSel->PushButton3) {
605 myEditCurrentArgument = JunctionPointsSel->LineEdit3;
606 JunctionPointsSel->PushButton1->setDown(false);
607 JunctionPointsSel->LineEdit1->setEnabled(false);
608 JunctionPointsSel->PushButton2->setDown(false);
609 JunctionPointsSel->LineEdit2->setEnabled(false);
613 myEditCurrentArgument->setEnabled(true);
614 myEditCurrentArgument->setFocus();
615 myEditCurrentArgument->setText("");
616 // after setFocus(), because it will be setDown(false) when loses focus
619 JunctionPointsSel->LineEdit4->setText("");
620 JunctionPointsSel->LineEdit5->setText("");
622 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
623 //globalSelection(GEOM_POINT);
624 globalSelection(); // close local contexts, if any
625 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
626 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
627 this, SLOT(SelectionIntoArgument()));
630 //=================================================================================
631 // function : SetDoubleSpinBoxStep()
632 // purpose : Double spin box management
633 //=================================================================================
634 void AdvancedGUI_PipeTShapeDlg::SetDoubleSpinBoxStep (double step)
636 MainTubeGroupParams->SpinBox_DX->setSingleStep(step);
637 MainTubeGroupParams->SpinBox_DY->setSingleStep(step);
638 MainTubeGroupParams->SpinBox_DZ->setSingleStep(step);
639 IncidentTubeGroupParams->SpinBox_DX->setSingleStep(step);
640 IncidentTubeGroupParams->SpinBox_DY->setSingleStep(step);
641 IncidentTubeGroupParams->SpinBox_DZ->setSingleStep(step);
642 ChamferGroupParams->SpinBox_DX->setSingleStep(step);
643 ChamferGroupParams->SpinBox_DY->setSingleStep(step);
644 FilletGroupParams->SpinBox_DX->setSingleStep(step);
646 LReductionGroupParams->SpinBox1->setSingleStep(step);
647 LReductionGroupParams->SpinBox2->setSingleStep(step);
648 LReductionGroupParams->SpinBox3->setSingleStep(step);
649 LReductionGroupParams->SpinBox4->setSingleStep(step);
651 RReductionGroupParams->SpinBox1->setSingleStep(step);
652 RReductionGroupParams->SpinBox2->setSingleStep(step);
653 RReductionGroupParams->SpinBox3->setSingleStep(step);
654 RReductionGroupParams->SpinBox4->setSingleStep(step);
656 IReductionGroupParams->SpinBox1->setSingleStep(step);
657 IReductionGroupParams->SpinBox2->setSingleStep(step);
658 IReductionGroupParams->SpinBox3->setSingleStep(step);
659 IReductionGroupParams->SpinBox4->setSingleStep(step);
662 //=================================================================================
663 // function : ClickOnOk()
665 //=================================================================================
666 void AdvancedGUI_PipeTShapeDlg::ClickOnOk()
668 setIsApplyAndClose( true );
673 //=================================================================================
674 // function : ClickOnApply()
676 //=================================================================================
677 bool AdvancedGUI_PipeTShapeDlg::ClickOnApply()
687 //=================================================================================
688 // function : ActivateThisDialog()
690 //=================================================================================
691 void AdvancedGUI_PipeTShapeDlg::ActivateThisDialog()
693 GEOMBase_Skeleton::ActivateThisDialog();
694 //globalSelection( GEOM_POINT);
695 //connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(
696 // currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
697 if (myOkPoint1 && myOkPoint2 && myOkPoint3)
698 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
702 //=================================================================================
703 // function : enterEvent [REDEFINED]
705 //=================================================================================
706 void AdvancedGUI_PipeTShapeDlg::enterEvent (QEvent*)
708 if (!mainFrame()->GroupButtons->isEnabled())
709 ActivateThisDialog();
712 //=================================================================================
713 // function : resizeEvent [REDEFINED]
715 //=================================================================================
716 void AdvancedGUI_PipeTShapeDlg::resizeEvent (QResizeEvent */*event*/)
718 QSize scaledSize1 = imagePipeTShape.size();
719 scaledSize1.scale(LabelImgPipeTShape->size(), Qt::KeepAspectRatio);
720 if (!LabelImgPipeTShape->pixmap() || scaledSize1 != LabelImgPipeTShape->pixmap()->size())
721 updateLabelImgPipeTShape();
723 QSize scaledSize2 = imageReduction.size();
724 scaledSize2.scale(LabelImgReduction->size(), Qt::KeepAspectRatio);
725 if (!LabelImgReduction->pixmap() || scaledSize2 != LabelImgReduction->pixmap()->size())
726 LabelImgReduction->setPixmap(imageReduction.scaled(LabelImgReduction->size(),
728 Qt::SmoothTransformation));
731 //=================================================================================
732 // function : updateLabelImgPipeTShape
734 //=================================================================================
735 void AdvancedGUI_PipeTShapeDlg::updateLabelImgPipeTShape()
737 LabelImgPipeTShape->setPixmap(imagePipeTShape.scaled(LabelImgPipeTShape->size(),
739 Qt::SmoothTransformation));
742 //=================================================================================
743 // function : ChamferOrFillet()
745 //=================================================================================
746 void AdvancedGUI_PipeTShapeDlg::ChamferOrFillet (bool)
748 QGroupBox* send = (QGroupBox*) sender();
750 if (send == ChamferGroupParams->GroupBox1) {
751 if (send->isChecked()) {
752 disconnect(FilletGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, 0);
753 FilletGroupParams->GroupBox1->setChecked(false);
754 connect(FilletGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(ChamferOrFillet(bool)));
755 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER"));
758 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE"));
760 updateLabelImgPipeTShape();
761 if (myOkPoint1 && myOkPoint2 && myOkPoint3)
762 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
765 else if (send == FilletGroupParams->GroupBox1) {
766 if (send->isChecked()) {
767 disconnect(ChamferGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, 0);
768 ChamferGroupParams->GroupBox1->setChecked(!send->isChecked());
769 connect(ChamferGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(ChamferOrFillet(bool)));
770 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET"));
773 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE"));
775 updateLabelImgPipeTShape();
776 if (myOkPoint1 && myOkPoint2 && myOkPoint3)
777 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
782 //=================================================================================
783 // function : DisplayPreview()
785 //=================================================================================
786 void AdvancedGUI_PipeTShapeDlg::DisplayPreview (const bool activate, const bool update,
787 const bool toRemoveFromEngine, const double lineWidth,
788 const int displayMode, const int color)
792 erasePreview(update);
799 SUIT_OverrideCursor wc;
801 bool hexMeshState = HexMeshCheckBox->isChecked();
802 HexMeshCheckBox->setChecked(false);
803 if (!executeNoCheck(objects) || !getOperation()->IsDone()) {
807 ObjectList::iterator it = objects.begin();
808 GEOM::GEOM_Object_var obj = *it;
809 displayPreview(obj, true, activate, false, lineWidth, displayMode, color);
810 if (toRemoveFromEngine)
813 HexMeshCheckBox->setChecked(hexMeshState);
814 } catch (const SALOME::SALOME_Exception& e) {
815 SalomeApp_Tools::QtCatchCorbaException(e);
822 //=================================================================================
823 // function : createOperation
825 //=================================================================================
826 GEOM::GEOM_IOperations_ptr AdvancedGUI_PipeTShapeDlg::createOperation()
828 return getGeomEngine()->GetIAdvancedOperations(getStudyId());
831 //=================================================================================
832 // function : isValid
834 //=================================================================================
835 bool AdvancedGUI_PipeTShapeDlg::isValid (QString& msg)
839 ok = MainTubeGroupParams->SpinBox_DX->isValid(msg, !IsPreview()) && ok;
840 ok = MainTubeGroupParams->SpinBox_DY->isValid(msg, !IsPreview()) && ok;
841 ok = MainTubeGroupParams->SpinBox_DZ->isValid(msg, !IsPreview()) && ok;
842 ok = IncidentTubeGroupParams->SpinBox_DX->isValid(msg, !IsPreview()) && ok;
843 ok = IncidentTubeGroupParams->SpinBox_DY->isValid(msg, !IsPreview()) && ok;
844 ok = IncidentTubeGroupParams->SpinBox_DZ->isValid(msg, !IsPreview()) && ok;
845 ok = ChamferGroupParams->SpinBox_DX->isValid(msg, !IsPreview()) && ok;
846 ok = ChamferGroupParams->SpinBox_DY->isValid(msg, !IsPreview()) && ok;
847 ok = FilletGroupParams->SpinBox_DX->isValid(msg, !IsPreview()) && ok;
849 if (LReductionGroupParams->GroupBox1->isChecked()) {
850 ok = LReductionGroupParams->SpinBox1->isValid(msg, !IsPreview()) && ok;
851 ok = LReductionGroupParams->SpinBox2->isValid(msg, !IsPreview()) && ok;
852 ok = LReductionGroupParams->SpinBox3->isValid(msg, !IsPreview()) && ok;
853 ok = LReductionGroupParams->SpinBox4->isValid(msg, !IsPreview()) && ok;
855 if (RReductionGroupParams->GroupBox1->isChecked()) {
856 ok = RReductionGroupParams->SpinBox1->isValid(msg, !IsPreview()) && ok;
857 ok = RReductionGroupParams->SpinBox2->isValid(msg, !IsPreview()) && ok;
858 ok = RReductionGroupParams->SpinBox3->isValid(msg, !IsPreview()) && ok;
859 ok = RReductionGroupParams->SpinBox4->isValid(msg, !IsPreview()) && ok;
861 if (IReductionGroupParams->GroupBox1->isChecked()) {
862 ok = IReductionGroupParams->SpinBox1->isValid(msg, !IsPreview()) && ok;
863 ok = IReductionGroupParams->SpinBox2->isValid(msg, !IsPreview()) && ok;
864 ok = IReductionGroupParams->SpinBox3->isValid(msg, !IsPreview()) && ok;
865 ok = IReductionGroupParams->SpinBox4->isValid(msg, !IsPreview()) && ok;
868 ok = fabs(MainTubeGroupParams->SpinBox_DX->value()) > Precision::Confusion() && ok;
869 ok = fabs(MainTubeGroupParams->SpinBox_DY->value()) > Precision::Confusion() && ok;
870 ok = fabs(MainTubeGroupParams->SpinBox_DZ->value()) > Precision::Confusion() && ok;
871 ok = fabs(IncidentTubeGroupParams->SpinBox_DX->value()) > Precision::Confusion() && ok;
872 ok = fabs(IncidentTubeGroupParams->SpinBox_DY->value()) > Precision::Confusion() && ok;
873 ok = fabs(IncidentTubeGroupParams->SpinBox_DZ->value()) > Precision::Confusion() && ok;
874 ok = fabs(ChamferGroupParams->SpinBox_DX->value()) > Precision::Confusion() && ok;
875 ok = fabs(ChamferGroupParams->SpinBox_DY->value()) > Precision::Confusion() && ok;
876 ok = fabs(FilletGroupParams->SpinBox_DX->value()) > Precision::Confusion() && ok;
878 if (JunctionPointsSel->GroupBox1->isChecked())
879 ok = myOkPoint1 && myOkPoint2 && myOkPoint3 && ok;
884 //=================================================================================
885 // function : CheckCompatiblePosition()
887 //=================================================================================
888 bool AdvancedGUI_PipeTShapeDlg::CheckCompatiblePosition
889 (GEOM::GEOM_Object_var theP1, GEOM::GEOM_Object_var theP2, GEOM::GEOM_Object_var theP3,
892 MainTubeGroupParams->SpinBox_DZ->setStyleSheet(CssNormal);
893 IncidentTubeGroupParams->SpinBox_DZ->setStyleSheet(CssNormal);
894 JunctionPointsSel->PushButton4->setStyleSheet(CssNormal);
895 JunctionPointsSel->PushButton5->setStyleSheet(CssNormal);
897 CORBA::Double theL1 = MainTubeGroupParams->SpinBox_DZ->value();
898 CORBA::Double theL2 = IncidentTubeGroupParams->SpinBox_DZ->value();
900 JunctionPointsSel->LineEdit4->setText("");
901 JunctionPointsSel->LineEdit5->setText("");
903 MainTubeGroupParams->SpinBox_DZ->setToolTip("");
904 IncidentTubeGroupParams->SpinBox_DZ->setToolTip("");
908 if ( GEOMBase::GetShape( theP1, aShape ) && !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
909 P1 = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
913 if ( GEOMBase::GetShape( theP2, aShape ) && !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
914 P2 = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
918 if ( GEOMBase::GetShape( theP3, aShape ) && !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
919 P3 = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
923 double d12 = P1.Distance(P2);
924 double d13 = P1.Distance(P3);
925 double d23 = P2.Distance(P3);
927 if (Abs(d12) <= Precision::Confusion()) {
928 //SetErrorCode("Junctions points P1 and P2 are identical");
931 if (Abs(d13) <= Precision::Confusion()) {
932 //SetErrorCode("Junctions points P1 and P3 are identical");
935 if (Abs(d23) <= Precision::Confusion()) {
936 //SetErrorCode("Junctions points P2 and P3 are identical");
940 long double newL1 = 0.5 * d12;
941 long double newL2 = sqrt(pow(d13,2)-pow(newL1,2));
943 JunctionPointsSel->LineEdit4->setText(QString::number(newL1,'f',7));
944 JunctionPointsSel->LineEdit5->setText(QString::number(newL2,'f',7));
946 if (fabs(newL1 - theL1) > Precision::Approximation()) {
947 if ((newL1 * (1 - theTolerance) - theL1 <= Precision::Approximation()) &&
948 (newL1 * (1 + theTolerance) - theL1 >= Precision::Approximation())) {
949 disconnect(MainTubeGroupParams->SpinBox_DZ, 0, this, 0);
950 MainTubeGroupParams->SpinBox_DZ->setValue(newL1);
951 connect(MainTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged(double)),
952 this, SLOT(ValueChangedInSpinBox(double)));
953 MainTubeGroupParams->SpinBox_DZ->setToolTip("Value was recomputed to fit with position");
954 MainTubeGroupParams->SpinBox_DZ->setStyleSheet(CssAcceptable);
955 JunctionPointsSel->PushButton4->setStyleSheet(CssAcceptable);
958 MainTubeGroupParams->SpinBox_DZ->setToolTip("Value is incompatible with position");
959 MainTubeGroupParams->SpinBox_DZ->setStyleSheet(CssRefused);
960 JunctionPointsSel->PushButton4->setStyleSheet(CssRefused);
964 MainTubeGroupParams->SpinBox_DZ->setStyleSheet(CssNormal);
965 JunctionPointsSel->PushButton4->setStyleSheet(CssNormal);
968 if (fabs(newL2 - theL2) > Precision::Approximation()) {
969 if ((newL2 * (1 - theTolerance) - theL2 <= Precision::Approximation()) &&
970 (newL2 * (1 + theTolerance) - theL2 >= Precision::Approximation())) {
971 disconnect(IncidentTubeGroupParams->SpinBox_DZ, 0, this, 0);
972 IncidentTubeGroupParams->SpinBox_DZ->setValue(newL2);
973 connect(IncidentTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
974 IncidentTubeGroupParams->SpinBox_DZ->setToolTip("Value was recomputed to fit with position");
975 IncidentTubeGroupParams->SpinBox_DZ->setStyleSheet(CssAcceptable);
976 JunctionPointsSel->PushButton5->setStyleSheet(CssAcceptable);
979 IncidentTubeGroupParams->SpinBox_DZ->setToolTip("Value is incompatible with position");
980 IncidentTubeGroupParams->SpinBox_DZ->setStyleSheet(CssRefused);
981 JunctionPointsSel->PushButton5->setStyleSheet(CssRefused);
985 IncidentTubeGroupParams->SpinBox_DZ->setStyleSheet(CssNormal);
986 JunctionPointsSel->PushButton5->setStyleSheet(CssNormal);
992 //=================================================================================
993 // function : execute
995 //=================================================================================
996 bool AdvancedGUI_PipeTShapeDlg::execute (ObjectList& objects)
998 if (JunctionPointsSel->GroupBox1->isChecked() && myOkPoint1 && myOkPoint2 && myOkPoint3)
999 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
1001 return executeNoCheck(objects);
1004 //=================================================================================
1005 // function : executeNoCheck
1007 //=================================================================================
1008 bool AdvancedGUI_PipeTShapeDlg::executeNoCheck (ObjectList& objects)
1012 // GEOM::GEOM_Object_var anObj;
1013 GEOM::ListOfGO_var anObj;
1015 GEOM::GEOM_IAdvancedOperations_var anOper = GEOM::GEOM_IAdvancedOperations::_narrow(getOperation());
1017 //@@ retrieve input values from the widgets here @@//
1018 CORBA::Double theR1 = MainTubeGroupParams->SpinBox_DX->value();
1019 CORBA::Double theW1 = MainTubeGroupParams->SpinBox_DY->value();
1020 CORBA::Double theL1 = MainTubeGroupParams->SpinBox_DZ->value();
1021 CORBA::Double theR2 = IncidentTubeGroupParams->SpinBox_DX->value();
1022 CORBA::Double theW2 = IncidentTubeGroupParams->SpinBox_DY->value();
1023 CORBA::Double theL2 = IncidentTubeGroupParams->SpinBox_DZ->value();
1024 CORBA::Double theH = ChamferGroupParams->SpinBox_DX->value();
1025 CORBA::Double theW = ChamferGroupParams->SpinBox_DY->value();
1026 CORBA::Double theRF = FilletGroupParams->SpinBox_DX->value();
1027 CORBA::Boolean theHexMesh = HexMeshCheckBox->isChecked();
1029 // Thickness reductions
1030 CORBA::Double theRL = 0., theWL = 0., theLtransL = 0., theLthinL = 0.;
1031 CORBA::Double theRR = 0., theWR = 0., theLtransR = 0., theLthinR = 0.;
1032 CORBA::Double theRI = 0., theWI = 0., theLtransI = 0., theLthinI = 0.;
1034 if (LReductionGroupParams->GroupBox1->isChecked()) {
1035 theRL = LReductionGroupParams->SpinBox1->value();
1036 theWL = LReductionGroupParams->SpinBox2->value();
1037 theLtransL = LReductionGroupParams->SpinBox3->value();
1038 theLthinL = LReductionGroupParams->SpinBox4->value();
1040 if (RReductionGroupParams->GroupBox1->isChecked()) {
1041 theRR = RReductionGroupParams->SpinBox1->value();
1042 theWR = RReductionGroupParams->SpinBox2->value();
1043 theLtransR = RReductionGroupParams->SpinBox3->value();
1044 theLthinR = RReductionGroupParams->SpinBox4->value();
1046 if (IReductionGroupParams->GroupBox1->isChecked()) {
1047 theRI = IReductionGroupParams->SpinBox1->value();
1048 theWI = IReductionGroupParams->SpinBox2->value();
1049 theLtransI = IReductionGroupParams->SpinBox3->value();
1050 theLthinI = IReductionGroupParams->SpinBox4->value();
1053 //if (JunctionPointsSel->GroupBox1->isChecked()) {
1054 // CheckCompatiblePosition(theL1, theL2, myPoint1, myPoint2, myPoint3, 0.01);
1055 // theL1 = MainTubeGroupParams->SpinBox_DZ->value();
1056 // theL2 = IncidentTubeGroupParams->SpinBox_DZ->value();
1059 // call engine function
1060 if (ChamferGroupParams->GroupBox1->isChecked()) {
1061 if (JunctionPointsSel->GroupBox1->isChecked())
1062 anObj = anOper->MakePipeTShapeTRChamferWithPosition(theR1, theW1, theL1, theR2, theW2, theL2,
1063 theRL, theWL, theLtransL, theLthinL,
1064 theRR, theWR, theLtransR, theLthinR,
1065 theRI, theWI, theLtransI, theLthinI,
1066 theH, theW, theHexMesh, myPoint1, myPoint2, myPoint3);
1068 anObj = anOper->MakePipeTShapeTRChamfer(theR1, theW1, theL1, theR2, theW2, theL2,
1069 theRL, theWL, theLtransL, theLthinL,
1070 theRR, theWR, theLtransR, theLthinR,
1071 theRI, theWI, theLtransI, theLthinI,
1072 theH, theW, theHexMesh);
1074 else if (FilletGroupParams->GroupBox1->isChecked()) {
1075 if (JunctionPointsSel->GroupBox1->isChecked())
1076 anObj = anOper->MakePipeTShapeTRFilletWithPosition(theR1, theW1, theL1, theR2, theW2, theL2,
1077 theRL, theWL, theLtransL, theLthinL,
1078 theRR, theWR, theLtransR, theLthinR,
1079 theRI, theWI, theLtransI, theLthinI,
1080 theRF, theHexMesh, myPoint1, myPoint2, myPoint3);
1082 anObj = anOper->MakePipeTShapeTRFillet(theR1, theW1, theL1, theR2, theW2, theL2,
1083 theRL, theWL, theLtransL, theLthinL,
1084 theRR, theWR, theLtransR, theLthinR,
1085 theRI, theWI, theLtransI, theLthinI,
1089 if (JunctionPointsSel->GroupBox1->isChecked())
1090 anObj = anOper->MakePipeTShapeTRWithPosition(theR1, theW1, theL1, theR2, theW2, theL2,
1091 theRL, theWL, theLtransL, theLthinL,
1092 theRR, theWR, theLtransR, theLthinR,
1093 theRI, theWI, theLtransI, theLthinI,
1094 theHexMesh, myPoint1, myPoint2, myPoint3);
1096 anObj = anOper->MakePipeTShapeTR(theR1, theW1, theL1, theR2, theW2, theL2,
1097 theRL, theWL, theLtransL, theLthinL,
1098 theRR, theWR, theLtransR, theLthinR,
1099 theRI, theWI, theLtransI, theLthinI,
1103 res = anObj->length();
1107 //res = !anObj->_is_nil();
1108 if (res && !IsPreview()) {
1109 QStringList aParameters;
1110 //@@ put stringified input parameters to the string list here to store in the data model for notebook @@//
1111 aParameters << MainTubeGroupParams->SpinBox_DX->text(); // R1 parameter
1112 aParameters << MainTubeGroupParams->SpinBox_DY->text(); // W1 parameter
1113 aParameters << MainTubeGroupParams->SpinBox_DZ->text(); // L1 parameter
1114 aParameters << IncidentTubeGroupParams->SpinBox_DX->text(); // R2 parameter
1115 aParameters << IncidentTubeGroupParams->SpinBox_DY->text(); // W2 parameter
1116 aParameters << IncidentTubeGroupParams->SpinBox_DZ->text(); // L2 parameter
1118 if (ChamferGroupParams->GroupBox1->isChecked()) { // Chamfer parameter
1119 aParameters << ChamferGroupParams->SpinBox_DX->text(); // H parameter
1120 aParameters << ChamferGroupParams->SpinBox_DY->text(); // W parameter
1122 if (FilletGroupParams->GroupBox1->isChecked()) // Fillet parameter
1123 aParameters << FilletGroupParams->SpinBox_DX->text(); // RF parameter
1125 // Thickness reductions
1126 if (LReductionGroupParams->GroupBox1->isChecked()) {
1127 aParameters << LReductionGroupParams->SpinBox1->text();
1128 aParameters << LReductionGroupParams->SpinBox2->text();
1129 aParameters << LReductionGroupParams->SpinBox3->text();
1130 aParameters << LReductionGroupParams->SpinBox4->text();
1133 aParameters << "0" << "0" << "0" << "0";
1135 if (RReductionGroupParams->GroupBox1->isChecked()) {
1136 aParameters << RReductionGroupParams->SpinBox1->text();
1137 aParameters << RReductionGroupParams->SpinBox2->text();
1138 aParameters << RReductionGroupParams->SpinBox3->text();
1139 aParameters << RReductionGroupParams->SpinBox4->text();
1142 aParameters << "0" << "0" << "0" << "0";
1144 if (IReductionGroupParams->GroupBox1->isChecked()) {
1145 aParameters << IReductionGroupParams->SpinBox1->text();
1146 aParameters << IReductionGroupParams->SpinBox2->text();
1147 aParameters << IReductionGroupParams->SpinBox3->text();
1148 aParameters << IReductionGroupParams->SpinBox4->text();
1151 aParameters << "0" << "0" << "0" << "0";
1154 if (aParameters.count() > 0)
1155 anObj[0]->SetParameters(aParameters.join(":").toLatin1().constData());
1158 objects.push_back(anObj[0]._retn());
1159 pipeTShapeGroupObjects.clear();
1160 for (int i = 1, n = anObj->length(); i < n; i++) {
1161 pipeTShapeGroupObjects.push_back(anObj[i]._retn());
1164 return objects.size() > 0;
1167 //=================================================================================
1168 // function : restoreSubShapes
1170 //=================================================================================
1171 void AdvancedGUI_PipeTShapeDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
1172 SALOMEDS::SObject_ptr theSObject)
1174 SALOMEDS::GenericAttribute_var anAttr;
1175 if (!theSObject->FindAttribute(anAttr, "AttributeIOR"))
1178 SALOMEDS::AttributeIOR_var anAttrIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1179 CORBA::String_var anIORso = anAttrIOR->Value();
1181 // get Object from SObject
1182 GEOM::GEOM_Object_var theFather =
1183 GEOM::GEOM_Object::_narrow(myGeomGUI->getApp()->orb()->string_to_object(anIORso));
1184 if (CORBA::is_nil(theFather))
1187 ObjectList::iterator it = pipeTShapeGroupObjects.begin();
1189 for (int i = 0; it != pipeTShapeGroupObjects.end(); it++, i++) {
1190 getGeomEngine()->AddInStudy(theStudy, (*it), tr((*it)->GetName()).toStdString().c_str(), theFather);
1194 //=================================================================================
1195 // function : processPreview()
1196 // purpose : Display preview if CheckBoxPreview is checked
1197 //=================================================================================
1198 void AdvancedGUI_PipeTShapeDlg::processPreview()
1200 if (mainFrame()->CheckBoxPreview->isChecked())
1206 //=================================================================================
1207 // function : AdvancedGUI_4Spin
1209 //=================================================================================
1210 AdvancedGUI_4Spin::AdvancedGUI_4Spin()
1212 GroupBox1 = new QGroupBox ();
1214 gridLayout1 = new QGridLayout (GroupBox1);
1215 gridLayout1->setSpacing(6);
1216 gridLayout1->setContentsMargins(11, 11, 11, 11);
1217 gridLayout1->setHorizontalSpacing(6);
1218 gridLayout1->setVerticalSpacing(6);
1219 gridLayout1->setContentsMargins(9, 9, 9, 9);
1221 TextLabel1 = new QLabel (GroupBox1);
1222 TextLabel2 = new QLabel (GroupBox1);
1223 TextLabel3 = new QLabel (GroupBox1);
1224 TextLabel4 = new QLabel (GroupBox1);
1226 SpinBox1 = new SalomeApp_DoubleSpinBox (GroupBox1);
1227 SpinBox2 = new SalomeApp_DoubleSpinBox (GroupBox1);
1228 SpinBox3 = new SalomeApp_DoubleSpinBox (GroupBox1);
1229 SpinBox4 = new SalomeApp_DoubleSpinBox (GroupBox1);
1231 SpinBox1->setMinimumWidth(60);
1232 SpinBox2->setMinimumWidth(60);
1233 SpinBox3->setMinimumWidth(60);
1234 SpinBox4->setMinimumWidth(60);
1236 gridLayout1->addWidget(TextLabel1, 0, 0, 1, 1);
1237 gridLayout1->addWidget(TextLabel2, 1, 0, 1, 1);
1238 gridLayout1->addWidget(TextLabel3, 2, 0, 1, 1);
1239 gridLayout1->addWidget(TextLabel4, 3, 0, 1, 1);
1241 gridLayout1->addWidget(SpinBox1, 0, 1, 1, 1);
1242 gridLayout1->addWidget(SpinBox2, 1, 1, 1, 1);
1243 gridLayout1->addWidget(SpinBox3, 2, 1, 1, 1);
1244 gridLayout1->addWidget(SpinBox4, 3, 1, 1, 1);
1247 //=================================================================================
1248 // function : ~AdvancedGUI_4Spin()
1249 // purpose : Destroys the object and frees any allocated resources
1250 //=================================================================================
1251 AdvancedGUI_4Spin::~AdvancedGUI_4Spin()
1253 // no need to delete child widgets, Qt does it all for us