1 // Copyright (C) 2007-2021 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, or (at your option) any later version.
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"
22 #include <SALOMEconfig.h>
23 #include CORBA_SERVER_HEADER(AdvancedGEOM)
26 #include <GeometryGUI.h>
29 #include <SUIT_Session.h>
30 #include <SUIT_ResourceMgr.h>
31 #include <SUIT_OverrideCursor.h>
32 #include <LightApp_SelectionMgr.h>
33 #include <SalomeApp_Application.h>
34 #include <SalomeApp_Tools.h>
37 #include <BRep_Tool.hxx>
38 #include <TopTools_IndexedMapOfShape.hxx>
39 #include <TopoDS_Shape.hxx>
42 #include <TColStd_IndexedMapOfInteger.hxx>
47 #include <GEOMImpl_Types.hxx>
49 //=================================================================================
51 //=================================================================================
52 AdvancedGUI_PipeTShapeDlg::AdvancedGUI_PipeTShapeDlg (GeometryGUI* theGeometryGUI, QWidget* parent)
53 : GEOMBase_Skeleton(theGeometryGUI, parent, false)
55 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
56 //QPixmap imageOp = aResMgr->loadPixmap("GEOM", tr("ICON_DLG_PIPETSHAPE"));
57 QPixmap imageSel = aResMgr->loadPixmap("GEOM", tr("ICON_SELECT"));
58 QPixmap imageImp = aResMgr->loadPixmap("GEOM", tr("ICO_PIPETSHAPE_IMPORT"));
59 imagePipeTShape = aResMgr->loadPixmap("GEOM", tr("DLG_PIPETSHAPE"));
60 imageReduction = aResMgr->loadPixmap("GEOM", tr("IMG_PIPETSHAPE_SECT"));
62 setWindowTitle(tr("GEOM_PIPE_TSHAPE_TITLE"));
64 /***************************************************************/
65 mainFrame()->GroupConstructors->setAttribute(Qt::WA_DeleteOnClose);
66 mainFrame()->GroupConstructors->close();
68 QTabWidget* aTabWidget = new QTabWidget (centralWidget());
70 QGridLayout* myMainLayout = new QGridLayout (centralWidget());
71 myMainLayout->setMargin(0);
72 myMainLayout->setSpacing(6);
75 QGroupBox* GroupMain = new QGroupBox();
76 QGridLayout* layoutGroupMain = new QGridLayout (GroupMain);
78 MainTubeGroupParams = new DlgRef_3Spin();
79 MainTubeGroupParams->GroupBox1->setTitle(tr("GEOM_PIPE_TSHAPE_MPIPE"));
80 MainTubeGroupParams->TextLabel1->setText(tr("GEOM_PIPE_TSHAPE_R"));
81 MainTubeGroupParams->TextLabel2->setText(tr("GEOM_PIPE_TSHAPE_W"));
82 MainTubeGroupParams->TextLabel3->setText(tr("GEOM_PIPE_TSHAPE_L"));
83 MainTubeGroupParams->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); // ??
85 IncidentTubeGroupParams = new DlgRef_3Spin();
86 IncidentTubeGroupParams->GroupBox1->setTitle(tr("GEOM_PIPE_TSHAPE_IPIPE"));
87 IncidentTubeGroupParams->TextLabel1->setText(tr("GEOM_PIPE_TSHAPE_R"));
88 IncidentTubeGroupParams->TextLabel2->setText(tr("GEOM_PIPE_TSHAPE_W"));
89 IncidentTubeGroupParams->TextLabel3->setText(tr("GEOM_PIPE_TSHAPE_L"));
91 ChamferGroupParams = new DlgRef_2Spin();
92 ChamferGroupParams->GroupBox1->setCheckable(true);
93 ChamferGroupParams->GroupBox1->setChecked(false);
94 ChamferGroupParams->GroupBox1->setTitle(tr("GEOM_PIPE_TSHAPE_CHAMFER"));
95 ChamferGroupParams->TextLabel1->setText(tr("GEOM_PIPE_TSHAPE_CHAMFER_H"));
96 ChamferGroupParams->TextLabel2->setText(tr("GEOM_PIPE_TSHAPE_CHAMFER_W"));
98 FilletGroupParams = new DlgRef_1Spin();
99 FilletGroupParams->GroupBox1->setCheckable(true);
100 FilletGroupParams->GroupBox1->setChecked(false);
101 FilletGroupParams->GroupBox1->setTitle(tr("GEOM_PIPE_TSHAPE_FILLET"));
102 FilletGroupParams->TextLabel1->setText(tr("GEOM_PIPE_TSHAPE_R"));
104 HexMeshCheckBox = new QCheckBox();
105 HexMeshCheckBox->setText(tr("GEOM_PIPE_TSHAPE_HEX"));
106 HexMeshCheckBox->setChecked(true);
108 LabelImgPipeTShape = new QLabel();
109 LabelImgPipeTShape->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
110 LabelImgPipeTShape->setAlignment(Qt::AlignCenter);
111 LabelImgPipeTShape->setMinimumSize(300, 300);
113 layoutGroupMain->addWidget(MainTubeGroupParams, 0, 0, 1, 1);
114 layoutGroupMain->addWidget(IncidentTubeGroupParams, 1, 0, 1, 1);
115 layoutGroupMain->addWidget(ChamferGroupParams, 2, 0, 1, 1);
116 layoutGroupMain->addWidget(FilletGroupParams, 3, 0, 1, 1);
117 layoutGroupMain->addWidget(HexMeshCheckBox, 4, 0, 1, 1);
119 layoutGroupMain->addWidget(LabelImgPipeTShape, 0, 1, 5, 1);
120 layoutGroupMain->setColumnStretch(1, 1); // stretch of column 0 is supposed 0 by default
122 // Thickness reduction parameters
123 QGroupBox* GroupReduct = new QGroupBox();
124 QGridLayout* layoutGroupReduct = new QGridLayout (GroupReduct);
126 LReductionGroupParams = new AdvancedGUI_4Spin();
127 LReductionGroupParams->GroupBox1->setCheckable(true);
128 LReductionGroupParams->GroupBox1->setChecked(false);
129 LReductionGroupParams->GroupBox1->setTitle(tr("GEOM_PIPE_TSHAPE_LEFT_TR"));
130 LReductionGroupParams->TextLabel1->setText(tr("GEOM_PIPE_TSHAPE_TR_R").arg("L"));
131 LReductionGroupParams->TextLabel2->setText(tr("GEOM_PIPE_TSHAPE_TR_W").arg("L"));
132 LReductionGroupParams->TextLabel3->setText(tr("GEOM_PIPE_TSHAPE_TR_L_TRANS").arg("L"));
133 LReductionGroupParams->TextLabel4->setText(tr("GEOM_PIPE_TSHAPE_TR_L_THIN").arg("L"));
135 RReductionGroupParams = new AdvancedGUI_4Spin();
136 RReductionGroupParams->GroupBox1->setCheckable(true);
137 RReductionGroupParams->GroupBox1->setChecked(false);
138 RReductionGroupParams->GroupBox1->setTitle(tr("GEOM_PIPE_TSHAPE_RIGHT_TR"));
139 RReductionGroupParams->TextLabel1->setText(tr("GEOM_PIPE_TSHAPE_TR_R").arg("R"));
140 RReductionGroupParams->TextLabel2->setText(tr("GEOM_PIPE_TSHAPE_TR_W").arg("R"));
141 RReductionGroupParams->TextLabel3->setText(tr("GEOM_PIPE_TSHAPE_TR_L_TRANS").arg("R"));
142 RReductionGroupParams->TextLabel4->setText(tr("GEOM_PIPE_TSHAPE_TR_L_THIN").arg("R"));
144 IReductionGroupParams = new AdvancedGUI_4Spin();
145 IReductionGroupParams->GroupBox1->setCheckable(true);
146 IReductionGroupParams->GroupBox1->setChecked(false);
147 IReductionGroupParams->GroupBox1->setTitle(tr("GEOM_PIPE_TSHAPE_INCI_TR"));
148 IReductionGroupParams->TextLabel1->setText(tr("GEOM_PIPE_TSHAPE_TR_R").arg("I"));
149 IReductionGroupParams->TextLabel2->setText(tr("GEOM_PIPE_TSHAPE_TR_W").arg("I"));
150 IReductionGroupParams->TextLabel3->setText(tr("GEOM_PIPE_TSHAPE_TR_L_TRANS").arg("I"));
151 IReductionGroupParams->TextLabel4->setText(tr("GEOM_PIPE_TSHAPE_TR_L_THIN").arg("I"));
153 LabelImgReduction = new QLabel();
154 LabelImgReduction->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
155 LabelImgReduction->setAlignment(Qt::AlignCenter);
156 LabelImgReduction->setMinimumSize(300, 300);
158 layoutGroupReduct->addWidget(LReductionGroupParams->GroupBox1, 0, 0, 1, 1);
159 layoutGroupReduct->addWidget(RReductionGroupParams->GroupBox1, 1, 0, 1, 1);
160 layoutGroupReduct->addWidget(IReductionGroupParams->GroupBox1, 2, 0, 1, 1);
162 layoutGroupReduct->addWidget(LabelImgReduction, 0, 1, 3, 1);
163 layoutGroupReduct->setColumnStretch(1, 1); // stretch of column 0 is supposed 0 by default
165 // Position parameters
166 QGroupBox* GroupPos = new QGroupBox();
167 QVBoxLayout* layoutGroupPos = new QVBoxLayout (GroupPos);
169 JunctionPointsSel = new DlgRef_6Sel();
170 JunctionPointsSel->GroupBox1->setTitle(tr("GEOM_PIPE_TSHAPE_POSITION"));
171 JunctionPointsSel->GroupBox1->setCheckable(true);
172 JunctionPointsSel->GroupBox1->setChecked(false);
173 JunctionPointsSel->PushButton1->setIcon(imageSel);
174 JunctionPointsSel->LineEdit1->setReadOnly(true);
175 JunctionPointsSel->LineEdit1->setText("");
176 JunctionPointsSel->TextLabel1->setText(tr("GEOM_PIPE_TSHAPE_POSITION_P1"));
178 JunctionPointsSel->PushButton2->setIcon(imageSel);
179 JunctionPointsSel->LineEdit2->setReadOnly(true);
180 JunctionPointsSel->LineEdit2->setText("");
181 JunctionPointsSel->TextLabel2->setText(tr("GEOM_PIPE_TSHAPE_POSITION_P2"));
183 JunctionPointsSel->PushButton3->setIcon(imageSel);
184 JunctionPointsSel->LineEdit3->setReadOnly(true);
185 JunctionPointsSel->LineEdit3->setText("");
186 JunctionPointsSel->TextLabel3->setText(tr("GEOM_PIPE_TSHAPE_POSITION_P3"));
188 JunctionPointsSel->PushButton4->setIcon(imageImp);
189 JunctionPointsSel->LineEdit4->setReadOnly(true);
190 JunctionPointsSel->LineEdit4->setText("");
191 JunctionPointsSel->TextLabel4->setText(tr("GEOM_PIPE_TSHAPE_POSITION_LBL_L1"));
193 JunctionPointsSel->PushButton5->setIcon(imageImp);
194 JunctionPointsSel->LineEdit5->setReadOnly(true);
195 JunctionPointsSel->LineEdit5->setText("");
196 JunctionPointsSel->TextLabel5->setText(tr("GEOM_PIPE_TSHAPE_POSITION_LBL_L2"));
198 JunctionPointsSel->PushButton6->setAttribute(Qt::WA_DeleteOnClose);
199 JunctionPointsSel->PushButton6->close();
200 JunctionPointsSel->LineEdit6->setAttribute(Qt::WA_DeleteOnClose);
201 JunctionPointsSel->LineEdit6->close();
202 JunctionPointsSel->TextLabel6->setAttribute(Qt::WA_DeleteOnClose);
203 JunctionPointsSel->TextLabel6->close();
205 layoutGroupPos->addWidget(JunctionPointsSel);
206 layoutGroupPos->addStretch();
208 //aTabWidget->addTab(GroupMain, imageOp, tr("GEOM_PIPETSHAPE_GROUPMAIN"));
209 aTabWidget->addTab(GroupMain, tr("GEOM_PIPETSHAPE_GROUPMAIN"));
210 aTabWidget->addTab(GroupReduct, tr("GEOM_PIPETSHAPE_GROUPREDUCT"));
211 aTabWidget->addTab(GroupPos, tr("GEOM_PIPETSHAPE_GROUPPOS"));
213 myMainLayout->addWidget(aTabWidget, 0, 0, 1, 1);
214 connect(aTabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
215 /***************************************************************/
217 setHelpFileName("create_pipetshape_page.html");
222 //=================================================================================
224 //=================================================================================
225 AdvancedGUI_PipeTShapeDlg::~AdvancedGUI_PipeTShapeDlg() {
226 // no need to delete child widgets, Qt does it all for us
229 //=================================================================================
232 //=================================================================================
233 void AdvancedGUI_PipeTShapeDlg::Init()
235 // Get setting of step value from file configuration
236 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
237 double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
238 double minValue = Precision::Approximation();
240 myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
241 myOkPoint1 = myOkPoint2 = myOkPoint3 = false;
243 pipeTShapeGroupObjects.clear();
245 // min, max, step and decimals for spin boxes
246 initSpinBox(MainTubeGroupParams->SpinBox_DX, minValue, COORD_MAX, step, "length_precision");
247 initSpinBox(MainTubeGroupParams->SpinBox_DY, minValue, COORD_MAX, step, "length_precision");
248 initSpinBox(MainTubeGroupParams->SpinBox_DZ, minValue, COORD_MAX, step, "length_precision");
249 initSpinBox(IncidentTubeGroupParams->SpinBox_DX, minValue, COORD_MAX, step, "length_precision");
250 initSpinBox(IncidentTubeGroupParams->SpinBox_DY, minValue, COORD_MAX, step, "length_precision");
251 initSpinBox(IncidentTubeGroupParams->SpinBox_DZ, minValue, COORD_MAX, step, "length_precision");
252 initSpinBox(ChamferGroupParams->SpinBox_DX, minValue, COORD_MAX, step, "length_precision");
253 initSpinBox(ChamferGroupParams->SpinBox_DY, minValue, COORD_MAX, step, "length_precision");
254 initSpinBox(FilletGroupParams->SpinBox_DX, minValue, COORD_MAX, step, "length_precision");
256 initSpinBox(LReductionGroupParams->SpinBox1, minValue, COORD_MAX, step, "length_precision");
257 initSpinBox(LReductionGroupParams->SpinBox2, minValue, COORD_MAX, step, "length_precision");
258 initSpinBox(LReductionGroupParams->SpinBox3, minValue, COORD_MAX, step, "length_precision");
259 initSpinBox(LReductionGroupParams->SpinBox4, 0., COORD_MAX, step, "length_precision");
261 initSpinBox(RReductionGroupParams->SpinBox1, minValue, COORD_MAX, step, "length_precision");
262 initSpinBox(RReductionGroupParams->SpinBox2, minValue, COORD_MAX, step, "length_precision");
263 initSpinBox(RReductionGroupParams->SpinBox3, minValue, COORD_MAX, step, "length_precision");
264 initSpinBox(RReductionGroupParams->SpinBox4, 0., COORD_MAX, step, "length_precision");
266 initSpinBox(IReductionGroupParams->SpinBox1, minValue, COORD_MAX, step, "length_precision");
267 initSpinBox(IReductionGroupParams->SpinBox2, minValue, COORD_MAX, step, "length_precision");
268 initSpinBox(IReductionGroupParams->SpinBox3, minValue, COORD_MAX, step, "length_precision");
269 initSpinBox(IReductionGroupParams->SpinBox4, 0., COORD_MAX, step, "length_precision");
272 MainTubeGroupParams->SpinBox_DX->setValue(80);
273 MainTubeGroupParams->SpinBox_DY->setValue(20);
274 MainTubeGroupParams->SpinBox_DZ->setValue(200);
275 IncidentTubeGroupParams->SpinBox_DX->setValue(50);
276 IncidentTubeGroupParams->SpinBox_DY->setValue(20);
277 IncidentTubeGroupParams->SpinBox_DZ->setValue(200);
278 ChamferGroupParams->SpinBox_DX->setValue(20);
279 ChamferGroupParams->SpinBox_DY->setValue(10);
280 FilletGroupParams->SpinBox_DX->setValue(20);
282 LReductionGroupParams->SpinBox1->setValue(60);
283 LReductionGroupParams->SpinBox2->setValue(30);
284 LReductionGroupParams->SpinBox3->setValue(40);
285 LReductionGroupParams->SpinBox4->setValue(20);
287 RReductionGroupParams->SpinBox1->setValue(60);
288 RReductionGroupParams->SpinBox2->setValue(30);
289 RReductionGroupParams->SpinBox3->setValue(40);
290 RReductionGroupParams->SpinBox4->setValue(20);
292 IReductionGroupParams->SpinBox1->setValue(40);
293 IReductionGroupParams->SpinBox2->setValue(10);
294 IReductionGroupParams->SpinBox3->setValue(30);
295 IReductionGroupParams->SpinBox4->setValue(15);
297 CssNormal = QString("QDoubleSpinBox {");
298 CssNormal.append(MainTubeGroupParams->SpinBox_DZ->styleSheet());
299 CssNormal.append("}");
300 CssNormal.append("\nQPushButton {");
301 CssNormal.append(JunctionPointsSel->PushButton4->styleSheet());
302 CssNormal.append("}");
303 CssAcceptable = "QDoubleSpinBox, QPushButton {background-color: rgb(85, 170, 127)}";
304 CssRefused = "QDoubleSpinBox, QPushButton {background-color: rgb(255, 0, 0)}";
306 showOnlyPreviewControl();
308 // Signal/slot connections
309 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
310 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
311 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
312 //connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
313 // ValueChangedInSpinBox
314 connect(MainTubeGroupParams->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
315 connect(MainTubeGroupParams->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
316 connect(MainTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
317 connect(IncidentTubeGroupParams->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
318 connect(IncidentTubeGroupParams->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
319 connect(IncidentTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
320 connect(ChamferGroupParams->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
321 connect(ChamferGroupParams->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
322 connect(FilletGroupParams->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
324 connect(ChamferGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(ChamferOrFillet(bool)));
325 connect(FilletGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(ChamferOrFillet(bool)));
326 // Thickness reduction:
328 connect(LReductionGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(processPreview()));
329 connect(LReductionGroupParams->SpinBox1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
330 connect(LReductionGroupParams->SpinBox2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
331 connect(LReductionGroupParams->SpinBox3, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
332 connect(LReductionGroupParams->SpinBox4, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
334 connect(RReductionGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(processPreview()));
335 connect(RReductionGroupParams->SpinBox1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
336 connect(RReductionGroupParams->SpinBox2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
337 connect(RReductionGroupParams->SpinBox3, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
338 connect(RReductionGroupParams->SpinBox4, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
340 connect(IReductionGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(processPreview()));
341 connect(IReductionGroupParams->SpinBox1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
342 connect(IReductionGroupParams->SpinBox2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
343 connect(IReductionGroupParams->SpinBox3, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
344 connect(IReductionGroupParams->SpinBox4, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
346 connect(JunctionPointsSel->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(SetPosition(bool)));
347 connect(JunctionPointsSel->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
348 connect(JunctionPointsSel->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
349 connect(JunctionPointsSel->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
350 // ApplyNewDimensions
351 connect(JunctionPointsSel->PushButton4, SIGNAL(clicked()), this, SLOT(ApplyNewDimensions()));
352 connect(JunctionPointsSel->PushButton5, SIGNAL(clicked()), this, SLOT(ApplyNewDimensions()));
353 connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(UpdatePicture(QWidget*, QWidget*)));
354 //@@ put additional signal/slot connections here @@//
356 initName(tr("GEOM_PIPE_TSHAPE"));
358 qApp->processEvents();
360 resize(minimumSizeHint());
362 updateLabelImgPipeTShape();
363 LabelImgReduction->setPixmap(imageReduction.scaled(LabelImgReduction->size(),
365 Qt::SmoothTransformation));
369 //=================================================================================
370 // function : currentChanged()
371 // purpose : Tab widget management
372 //=================================================================================
373 void AdvancedGUI_PipeTShapeDlg::currentChanged (int tabId)
375 if (tabId == 0 || tabId == 1)
379 //=================================================================================
380 // function : ApplyNewDimensions()
382 //=================================================================================
383 void AdvancedGUI_PipeTShapeDlg::ApplyNewDimensions()
385 QPushButton* send = (QPushButton*) sender();
389 if (send == JunctionPointsSel->PushButton4) {
390 if (!JunctionPointsSel->LineEdit4->text().isEmpty()) {
391 newVal = JunctionPointsSel->LineEdit4->text().toDouble(&ok);
393 disconnect(MainTubeGroupParams->SpinBox_DZ, 0, this, 0);
394 MainTubeGroupParams->SpinBox_DZ->setValue(newVal);
395 connect(MainTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
396 MainTubeGroupParams->SpinBox_DZ->setToolTip("");
397 MainTubeGroupParams->SpinBox_DZ->setStyleSheet("background-color: rgb(255, 255, 255);");
398 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
403 else if (send == JunctionPointsSel->PushButton5) {
404 if (!JunctionPointsSel->LineEdit5->text().isEmpty()) {
405 newVal = JunctionPointsSel->LineEdit5->text().toDouble(&ok);
407 disconnect(IncidentTubeGroupParams->SpinBox_DZ, 0, this, 0);
408 IncidentTubeGroupParams->SpinBox_DZ->setValue(newVal);
409 connect(IncidentTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
410 IncidentTubeGroupParams->SpinBox_DZ->setToolTip("");
411 IncidentTubeGroupParams->SpinBox_DZ->setStyleSheet("background-color: rgb(255, 255, 255);");
412 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
419 //=================================================================================
420 // function : UpdatePicture()
422 //=================================================================================
423 void AdvancedGUI_PipeTShapeDlg::UpdatePicture (QWidget* /*old*/, QWidget* now)
425 if (ChamferGroupParams->GroupBox1->isChecked())
426 if (now == MainTubeGroupParams->SpinBox_DX)
427 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_R1"));
428 else if (now == MainTubeGroupParams->SpinBox_DY)
429 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_W1"));
430 else if (now == MainTubeGroupParams->SpinBox_DZ)
431 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_L1"));
432 else if (now == IncidentTubeGroupParams->SpinBox_DX)
433 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_R2"));
434 else if (now == IncidentTubeGroupParams->SpinBox_DY)
435 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_W2"));
436 else if (now == IncidentTubeGroupParams->SpinBox_DZ)
437 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_L2"));
438 else if (now == ChamferGroupParams->SpinBox_DX)
439 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_H"));
440 else if (now == ChamferGroupParams->SpinBox_DY)
441 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_W"));
443 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER"));
444 else if (FilletGroupParams->GroupBox1->isChecked())
445 if (now == MainTubeGroupParams->SpinBox_DX)
446 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_R1"));
447 else if (now == MainTubeGroupParams->SpinBox_DY)
448 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_W1"));
449 else if (now == MainTubeGroupParams->SpinBox_DZ)
450 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_L1"));
451 else if (now == IncidentTubeGroupParams->SpinBox_DX)
452 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_R2"));
453 else if (now == IncidentTubeGroupParams->SpinBox_DY)
454 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_W2"));
455 else if (now == IncidentTubeGroupParams->SpinBox_DZ)
456 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_L2"));
457 else if (now == FilletGroupParams->SpinBox_DX)
458 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_RF"));
460 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET"));
462 if (now == MainTubeGroupParams->SpinBox_DX)
463 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_R1"));
464 else if (now == MainTubeGroupParams->SpinBox_DY)
465 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_W1"));
466 else if (now == MainTubeGroupParams->SpinBox_DZ)
467 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_L1"));
468 else if (now == IncidentTubeGroupParams->SpinBox_DX)
469 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_R2"));
470 else if (now == IncidentTubeGroupParams->SpinBox_DY)
471 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_W2"));
472 else if (now == IncidentTubeGroupParams->SpinBox_DZ)
473 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_L2"));
475 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE"));
477 updateLabelImgPipeTShape();
480 //=================================================================================
481 // function : SetPosition()
483 //=================================================================================
484 void AdvancedGUI_PipeTShapeDlg::SetPosition (bool isChecked)
488 JunctionPointsSel->LineEdit4->setText("");
489 JunctionPointsSel->LineEdit5->setText("");
490 //connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(
491 //SelectionIntoArgument()));
492 JunctionPointsSel->PushButton1->click();
493 SelectionIntoArgument();
496 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
497 JunctionPointsSel->LineEdit4->setText("");
498 JunctionPointsSel->LineEdit5->setText("");
503 //=================================================================================
504 // function : ValueChangedInSpinBox()
506 //=================================================================================
507 void AdvancedGUI_PipeTShapeDlg::ValueChangedInSpinBox (double /*newValue*/)
509 if (JunctionPointsSel->GroupBox1->isChecked() && myOkPoint1 && myOkPoint2 && myOkPoint3)
510 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
514 //=================================================================================
515 // function : SelectionIntoArgument()
516 // purpose : Called when selection as changed or other case
517 //=================================================================================
518 void AdvancedGUI_PipeTShapeDlg::SelectionIntoArgument()
521 //myEditCurrentArgument->setText("");
523 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
524 SALOME_ListIO aSelList;
525 aSelMgr->selectedObjects(aSelList);
527 if (aSelList.Extent() != 1) {
528 if (myEditCurrentArgument == JunctionPointsSel->LineEdit1)
530 else if (myEditCurrentArgument == JunctionPointsSel->LineEdit2)
532 else if (myEditCurrentArgument == JunctionPointsSel->LineEdit3)
535 myEditCurrentArgument->setText("");
539 if (aSelList.Extent() == 1) {
540 Handle(SALOME_InteractiveObject) anIO = aSelList.First();
541 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(anIO);
542 if (!CORBA::is_nil(aSelectedObject)) {
543 QString aName = GEOMBase::GetName(aSelectedObject);
545 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) {
547 TColStd_IndexedMapOfInteger aMap;
548 aSelMgr->GetIndexes(anIO, aMap);
549 if (aMap.Extent() == 1) { // Local Selection
550 int anIndex = aMap(1);
551 aName += QString(":vertex_%1").arg(anIndex);
553 //Find SubShape Object in Father
554 GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
556 if (aFindedObject->_is_nil()) { // Object not found in study
557 GEOM::GEOM_IShapesOperations_var aShapesOp =
558 getGeomEngine()->GetIShapesOperations();
559 aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
562 aSelectedObject = aFindedObject; // get Object from study
564 GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE);
565 } else { // Global Selection
566 if (aShape.ShapeType() != TopAbs_VERTEX) {
567 aSelectedObject = GEOM::GEOM_Object::_nil();
573 if (aShape.IsNull() || aShape.ShapeType() != TopAbs_VERTEX) {
576 myEditCurrentArgument->setText(aName);
577 if (myEditCurrentArgument == JunctionPointsSel->LineEdit1) {
578 myPoint1 = aSelectedObject;
581 JunctionPointsSel->PushButton2->click();
582 } else if (myEditCurrentArgument == JunctionPointsSel->LineEdit2) {
583 myPoint2 = aSelectedObject;
586 JunctionPointsSel->PushButton3->click();
587 } else if (myEditCurrentArgument == JunctionPointsSel->LineEdit3) {
588 myPoint3 = aSelectedObject;
591 JunctionPointsSel->PushButton1->click();
596 if (myOkPoint1 && myOkPoint2 && myOkPoint3) {
597 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
602 //=================================================================================
603 // function : SetEditCurrentArgument()
605 //=================================================================================
606 void AdvancedGUI_PipeTShapeDlg::SetEditCurrentArgument()
608 QPushButton* send = (QPushButton*) sender();
610 if (send == JunctionPointsSel->PushButton1) {
611 myEditCurrentArgument = JunctionPointsSel->LineEdit1;
612 JunctionPointsSel->PushButton2->setDown(false);
613 JunctionPointsSel->LineEdit2->setEnabled(false);
614 JunctionPointsSel->PushButton3->setDown(false);
615 JunctionPointsSel->LineEdit3->setEnabled(false);
617 else if (send == JunctionPointsSel->PushButton2) {
618 myEditCurrentArgument = JunctionPointsSel->LineEdit2;
619 JunctionPointsSel->PushButton1->setDown(false);
620 JunctionPointsSel->LineEdit1->setEnabled(false);
621 JunctionPointsSel->PushButton3->setDown(false);
622 JunctionPointsSel->LineEdit3->setEnabled(false);
624 else if (send == JunctionPointsSel->PushButton3) {
625 myEditCurrentArgument = JunctionPointsSel->LineEdit3;
626 JunctionPointsSel->PushButton1->setDown(false);
627 JunctionPointsSel->LineEdit1->setEnabled(false);
628 JunctionPointsSel->PushButton2->setDown(false);
629 JunctionPointsSel->LineEdit2->setEnabled(false);
633 myEditCurrentArgument->setEnabled(true);
634 myEditCurrentArgument->setFocus();
635 myEditCurrentArgument->setText("");
636 // after setFocus(), because it will be setDown(false) when loses focus
639 JunctionPointsSel->LineEdit4->setText("");
640 JunctionPointsSel->LineEdit5->setText("");
642 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
643 //globalSelection(GEOM_POINT);
644 globalSelection(); // close local contexts, if any
645 localSelection( TopAbs_VERTEX );
646 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
647 this, SLOT(SelectionIntoArgument()));
650 //=================================================================================
651 // function : SetDoubleSpinBoxStep()
652 // purpose : Double spin box management
653 //=================================================================================
654 void AdvancedGUI_PipeTShapeDlg::SetDoubleSpinBoxStep (double step)
656 MainTubeGroupParams->SpinBox_DX->setSingleStep(step);
657 MainTubeGroupParams->SpinBox_DY->setSingleStep(step);
658 MainTubeGroupParams->SpinBox_DZ->setSingleStep(step);
659 IncidentTubeGroupParams->SpinBox_DX->setSingleStep(step);
660 IncidentTubeGroupParams->SpinBox_DY->setSingleStep(step);
661 IncidentTubeGroupParams->SpinBox_DZ->setSingleStep(step);
662 ChamferGroupParams->SpinBox_DX->setSingleStep(step);
663 ChamferGroupParams->SpinBox_DY->setSingleStep(step);
664 FilletGroupParams->SpinBox_DX->setSingleStep(step);
666 LReductionGroupParams->SpinBox1->setSingleStep(step);
667 LReductionGroupParams->SpinBox2->setSingleStep(step);
668 LReductionGroupParams->SpinBox3->setSingleStep(step);
669 LReductionGroupParams->SpinBox4->setSingleStep(step);
671 RReductionGroupParams->SpinBox1->setSingleStep(step);
672 RReductionGroupParams->SpinBox2->setSingleStep(step);
673 RReductionGroupParams->SpinBox3->setSingleStep(step);
674 RReductionGroupParams->SpinBox4->setSingleStep(step);
676 IReductionGroupParams->SpinBox1->setSingleStep(step);
677 IReductionGroupParams->SpinBox2->setSingleStep(step);
678 IReductionGroupParams->SpinBox3->setSingleStep(step);
679 IReductionGroupParams->SpinBox4->setSingleStep(step);
682 //=================================================================================
683 // function : ClickOnOk()
685 //=================================================================================
686 void AdvancedGUI_PipeTShapeDlg::ClickOnOk()
688 setIsApplyAndClose( true );
693 //=================================================================================
694 // function : ClickOnApply()
696 //=================================================================================
697 bool AdvancedGUI_PipeTShapeDlg::ClickOnApply()
704 if (!isApplyAndClose())
709 //=================================================================================
710 // function : ActivateThisDialog()
712 //=================================================================================
713 void AdvancedGUI_PipeTShapeDlg::ActivateThisDialog()
715 GEOMBase_Skeleton::ActivateThisDialog();
716 //globalSelection( GEOM_POINT);
717 //connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(
718 // currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
719 if (myOkPoint1 && myOkPoint2 && myOkPoint3)
720 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
724 //=================================================================================
725 // function : enterEvent [REDEFINED]
727 //=================================================================================
728 void AdvancedGUI_PipeTShapeDlg::enterEvent (QEvent*)
730 if (!mainFrame()->GroupButtons->isEnabled())
731 ActivateThisDialog();
734 //=================================================================================
735 // function : resizeEvent [REDEFINED]
737 //=================================================================================
738 void AdvancedGUI_PipeTShapeDlg::resizeEvent (QResizeEvent */*event*/)
740 QSize scaledSize1 = imagePipeTShape.size();
741 scaledSize1.scale(LabelImgPipeTShape->size(), Qt::KeepAspectRatio);
742 if (!LabelImgPipeTShape->pixmap() || scaledSize1 != LabelImgPipeTShape->pixmap()->size())
743 updateLabelImgPipeTShape();
745 QSize scaledSize2 = imageReduction.size();
746 scaledSize2.scale(LabelImgReduction->size(), Qt::KeepAspectRatio);
747 if (!LabelImgReduction->pixmap() || scaledSize2 != LabelImgReduction->pixmap()->size())
748 LabelImgReduction->setPixmap(imageReduction.scaled(LabelImgReduction->size(),
750 Qt::SmoothTransformation));
753 //=================================================================================
754 // function : updateLabelImgPipeTShape
756 //=================================================================================
757 void AdvancedGUI_PipeTShapeDlg::updateLabelImgPipeTShape()
759 LabelImgPipeTShape->setPixmap(imagePipeTShape.scaled(LabelImgPipeTShape->size(),
761 Qt::SmoothTransformation));
764 //=================================================================================
765 // function : ChamferOrFillet()
767 //=================================================================================
768 void AdvancedGUI_PipeTShapeDlg::ChamferOrFillet (bool)
770 QGroupBox* send = (QGroupBox*) sender();
772 if (send == ChamferGroupParams->GroupBox1) {
773 if (send->isChecked()) {
774 disconnect(FilletGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, 0);
775 FilletGroupParams->GroupBox1->setChecked(false);
776 connect(FilletGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(ChamferOrFillet(bool)));
777 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER"));
780 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE"));
782 updateLabelImgPipeTShape();
783 if (myOkPoint1 && myOkPoint2 && myOkPoint3)
784 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
787 else if (send == FilletGroupParams->GroupBox1) {
788 if (send->isChecked()) {
789 disconnect(ChamferGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, 0);
790 ChamferGroupParams->GroupBox1->setChecked(!send->isChecked());
791 connect(ChamferGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(ChamferOrFillet(bool)));
792 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET"));
795 imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE"));
797 updateLabelImgPipeTShape();
798 if (myOkPoint1 && myOkPoint2 && myOkPoint3)
799 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
804 //=================================================================================
805 // function : DisplayPreview()
807 //=================================================================================
808 void AdvancedGUI_PipeTShapeDlg::DisplayPreview (const bool activate, const bool update,
809 const bool toRemoveFromEngine, const double lineWidth,
810 const int displayMode, const int color)
814 erasePreview(update);
821 SUIT_OverrideCursor wc;
823 bool hexMeshState = HexMeshCheckBox->isChecked();
824 HexMeshCheckBox->setChecked(false);
825 if (!executeNoCheck(objects) || !getOperation()->IsDone()) {
829 ObjectList::iterator it = objects.begin();
830 GEOM::GEOM_Object_var obj = *it;
831 displayPreview(obj, true, activate, false, lineWidth, displayMode, color);
832 if (toRemoveFromEngine)
835 HexMeshCheckBox->setChecked(hexMeshState);
836 } catch (const SALOME::SALOME_Exception& e) {
837 SalomeApp_Tools::QtCatchCorbaException(e);
844 //=================================================================================
845 // function : createOperation
847 //=================================================================================
848 GEOM::GEOM_IOperations_ptr AdvancedGUI_PipeTShapeDlg::createOperation()
850 return getGeomEngine()->GetPluginOperations("AdvancedEngine");
853 //=================================================================================
854 // function : isValid
856 //=================================================================================
857 bool AdvancedGUI_PipeTShapeDlg::isValid (QString& msg)
861 ok = MainTubeGroupParams->SpinBox_DX->isValid(msg, !IsPreview()) && ok;
862 ok = MainTubeGroupParams->SpinBox_DY->isValid(msg, !IsPreview()) && ok;
863 ok = MainTubeGroupParams->SpinBox_DZ->isValid(msg, !IsPreview()) && ok;
864 ok = IncidentTubeGroupParams->SpinBox_DX->isValid(msg, !IsPreview()) && ok;
865 ok = IncidentTubeGroupParams->SpinBox_DY->isValid(msg, !IsPreview()) && ok;
866 ok = IncidentTubeGroupParams->SpinBox_DZ->isValid(msg, !IsPreview()) && ok;
867 ok = ChamferGroupParams->SpinBox_DX->isValid(msg, !IsPreview()) && ok;
868 ok = ChamferGroupParams->SpinBox_DY->isValid(msg, !IsPreview()) && ok;
869 ok = FilletGroupParams->SpinBox_DX->isValid(msg, !IsPreview()) && ok;
871 if (LReductionGroupParams->GroupBox1->isChecked()) {
872 ok = LReductionGroupParams->SpinBox1->isValid(msg, !IsPreview()) && ok;
873 ok = LReductionGroupParams->SpinBox2->isValid(msg, !IsPreview()) && ok;
874 ok = LReductionGroupParams->SpinBox3->isValid(msg, !IsPreview()) && ok;
875 ok = LReductionGroupParams->SpinBox4->isValid(msg, !IsPreview()) && ok;
876 if(MainTubeGroupParams->SpinBox_DX->value() == LReductionGroupParams->SpinBox1->value()) {
877 msg += tr("GEOM_PIPETSHAPE_ERR_EQUAL_RADII_L") + "\n";
880 if(MainTubeGroupParams->SpinBox_DX->value() + MainTubeGroupParams->SpinBox_DY->value() ==
881 LReductionGroupParams->SpinBox1->value() + LReductionGroupParams->SpinBox2->value()) {
882 msg += tr("GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_L") + "\n";
886 if (RReductionGroupParams->GroupBox1->isChecked()) {
887 ok = RReductionGroupParams->SpinBox1->isValid(msg, !IsPreview()) && ok;
888 ok = RReductionGroupParams->SpinBox2->isValid(msg, !IsPreview()) && ok;
889 ok = RReductionGroupParams->SpinBox3->isValid(msg, !IsPreview()) && ok;
890 ok = RReductionGroupParams->SpinBox4->isValid(msg, !IsPreview()) && ok;
891 if(MainTubeGroupParams->SpinBox_DX->value() == RReductionGroupParams->SpinBox1->value()) {
892 msg += tr("GEOM_PIPETSHAPE_ERR_EQUAL_RADII_R") + "\n";
895 if(MainTubeGroupParams->SpinBox_DX->value() + MainTubeGroupParams->SpinBox_DY->value() ==
896 RReductionGroupParams->SpinBox1->value() + RReductionGroupParams->SpinBox2->value()) {
897 msg += tr("GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_R") + "\n";
901 if (IReductionGroupParams->GroupBox1->isChecked()) {
902 ok = IReductionGroupParams->SpinBox1->isValid(msg, !IsPreview()) && ok;
903 ok = IReductionGroupParams->SpinBox2->isValid(msg, !IsPreview()) && ok;
904 ok = IReductionGroupParams->SpinBox3->isValid(msg, !IsPreview()) && ok;
905 ok = IReductionGroupParams->SpinBox4->isValid(msg, !IsPreview()) && ok;
906 if(IncidentTubeGroupParams->SpinBox_DX->value() == IReductionGroupParams->SpinBox1->value()) {
907 msg += tr("GEOM_PIPETSHAPE_ERR_EQUAL_RADII_I") + "\n";
910 if(IncidentTubeGroupParams->SpinBox_DX->value() + IncidentTubeGroupParams->SpinBox_DY->value() ==
911 IReductionGroupParams->SpinBox1->value() + IReductionGroupParams->SpinBox2->value()) {
912 msg += tr("GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_I") + "\n";
917 ok = fabs(MainTubeGroupParams->SpinBox_DX->value()) > Precision::Confusion() && ok;
918 ok = fabs(MainTubeGroupParams->SpinBox_DY->value()) > Precision::Confusion() && ok;
919 ok = fabs(MainTubeGroupParams->SpinBox_DZ->value()) > Precision::Confusion() && ok;
920 ok = fabs(IncidentTubeGroupParams->SpinBox_DX->value()) > Precision::Confusion() && ok;
921 ok = fabs(IncidentTubeGroupParams->SpinBox_DY->value()) > Precision::Confusion() && ok;
922 ok = fabs(IncidentTubeGroupParams->SpinBox_DZ->value()) > Precision::Confusion() && ok;
923 ok = fabs(ChamferGroupParams->SpinBox_DX->value()) > Precision::Confusion() && ok;
924 ok = fabs(ChamferGroupParams->SpinBox_DY->value()) > Precision::Confusion() && ok;
925 ok = fabs(FilletGroupParams->SpinBox_DX->value()) > Precision::Confusion() && ok;
927 if (JunctionPointsSel->GroupBox1->isChecked())
928 ok = myOkPoint1 && myOkPoint2 && myOkPoint3 && ok;
933 //=================================================================================
934 // function : CheckCompatiblePosition()
936 //=================================================================================
937 bool AdvancedGUI_PipeTShapeDlg::CheckCompatiblePosition
938 (GEOM::GEOM_Object_var theP1, GEOM::GEOM_Object_var theP2, GEOM::GEOM_Object_var theP3,
941 MainTubeGroupParams->SpinBox_DZ->setStyleSheet(CssNormal);
942 IncidentTubeGroupParams->SpinBox_DZ->setStyleSheet(CssNormal);
943 JunctionPointsSel->PushButton4->setStyleSheet(CssNormal);
944 JunctionPointsSel->PushButton5->setStyleSheet(CssNormal);
946 CORBA::Double theL1 = MainTubeGroupParams->SpinBox_DZ->value();
947 CORBA::Double theL2 = IncidentTubeGroupParams->SpinBox_DZ->value();
949 JunctionPointsSel->LineEdit4->setText("");
950 JunctionPointsSel->LineEdit5->setText("");
952 MainTubeGroupParams->SpinBox_DZ->setToolTip("");
953 IncidentTubeGroupParams->SpinBox_DZ->setToolTip("");
957 if ( GEOMBase::GetShape( theP1, aShape ) && !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
958 P1 = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
962 if ( GEOMBase::GetShape( theP2, aShape ) && !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
963 P2 = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
967 if ( GEOMBase::GetShape( theP3, aShape ) && !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
968 P3 = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
972 double d12 = P1.Distance(P2);
973 double d13 = P1.Distance(P3);
974 double d23 = P2.Distance(P3);
976 if (Abs(d12) <= Precision::Confusion()) {
977 //SetErrorCode("Junctions points P1 and P2 are identical");
980 if (Abs(d13) <= Precision::Confusion()) {
981 //SetErrorCode("Junctions points P1 and P3 are identical");
984 if (Abs(d23) <= Precision::Confusion()) {
985 //SetErrorCode("Junctions points P2 and P3 are identical");
989 long double newL1 = 0.5 * d12;
990 long double newL2 = sqrt(pow(d13,2)-pow(newL1,2));
992 JunctionPointsSel->LineEdit4->setText(QString::number(newL1,'f',7));
993 JunctionPointsSel->LineEdit5->setText(QString::number(newL2,'f',7));
995 if (fabs(newL1 - theL1) > Precision::Approximation()) {
996 if ((newL1 * (1 - theTolerance) - theL1 <= Precision::Approximation()) &&
997 (newL1 * (1 + theTolerance) - theL1 >= Precision::Approximation())) {
998 disconnect(MainTubeGroupParams->SpinBox_DZ, 0, this, 0);
999 MainTubeGroupParams->SpinBox_DZ->setValue(newL1);
1000 connect(MainTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged(double)),
1001 this, SLOT(ValueChangedInSpinBox(double)));
1002 MainTubeGroupParams->SpinBox_DZ->setToolTip("Value was recomputed to fit with position");
1003 MainTubeGroupParams->SpinBox_DZ->setStyleSheet(CssAcceptable);
1004 JunctionPointsSel->PushButton4->setStyleSheet(CssAcceptable);
1007 MainTubeGroupParams->SpinBox_DZ->setToolTip("Value is incompatible with position");
1008 MainTubeGroupParams->SpinBox_DZ->setStyleSheet(CssRefused);
1009 JunctionPointsSel->PushButton4->setStyleSheet(CssRefused);
1013 MainTubeGroupParams->SpinBox_DZ->setStyleSheet(CssNormal);
1014 JunctionPointsSel->PushButton4->setStyleSheet(CssNormal);
1017 if (fabs(newL2 - theL2) > Precision::Approximation()) {
1018 if ((newL2 * (1 - theTolerance) - theL2 <= Precision::Approximation()) &&
1019 (newL2 * (1 + theTolerance) - theL2 >= Precision::Approximation())) {
1020 disconnect(IncidentTubeGroupParams->SpinBox_DZ, 0, this, 0);
1021 IncidentTubeGroupParams->SpinBox_DZ->setValue(newL2);
1022 connect(IncidentTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
1023 IncidentTubeGroupParams->SpinBox_DZ->setToolTip("Value was recomputed to fit with position");
1024 IncidentTubeGroupParams->SpinBox_DZ->setStyleSheet(CssAcceptable);
1025 JunctionPointsSel->PushButton5->setStyleSheet(CssAcceptable);
1028 IncidentTubeGroupParams->SpinBox_DZ->setToolTip("Value is incompatible with position");
1029 IncidentTubeGroupParams->SpinBox_DZ->setStyleSheet(CssRefused);
1030 JunctionPointsSel->PushButton5->setStyleSheet(CssRefused);
1034 IncidentTubeGroupParams->SpinBox_DZ->setStyleSheet(CssNormal);
1035 JunctionPointsSel->PushButton5->setStyleSheet(CssNormal);
1041 //=================================================================================
1042 // function : execute
1044 //=================================================================================
1045 bool AdvancedGUI_PipeTShapeDlg::execute (ObjectList& objects)
1047 if (JunctionPointsSel->GroupBox1->isChecked() && myOkPoint1 && myOkPoint2 && myOkPoint3)
1048 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
1050 return executeNoCheck(objects);
1053 //=================================================================================
1054 // function : executeNoCheck
1056 //=================================================================================
1057 bool AdvancedGUI_PipeTShapeDlg::executeNoCheck (ObjectList& objects)
1061 // GEOM::GEOM_Object_var anObj;
1062 GEOM::ListOfGO_var anObj;
1064 GEOM::IAdvancedOperations_var anOper = GEOM::IAdvancedOperations::_narrow(getOperation());
1066 //@@ retrieve input values from the widgets here @@//
1067 CORBA::Double theR1 = MainTubeGroupParams->SpinBox_DX->value();
1068 CORBA::Double theW1 = MainTubeGroupParams->SpinBox_DY->value();
1069 CORBA::Double theL1 = MainTubeGroupParams->SpinBox_DZ->value();
1070 CORBA::Double theR2 = IncidentTubeGroupParams->SpinBox_DX->value();
1071 CORBA::Double theW2 = IncidentTubeGroupParams->SpinBox_DY->value();
1072 CORBA::Double theL2 = IncidentTubeGroupParams->SpinBox_DZ->value();
1073 CORBA::Double theH = ChamferGroupParams->SpinBox_DX->value();
1074 CORBA::Double theW = ChamferGroupParams->SpinBox_DY->value();
1075 CORBA::Double theRF = FilletGroupParams->SpinBox_DX->value();
1076 CORBA::Boolean theHexMesh = HexMeshCheckBox->isChecked();
1078 // Thickness reductions
1079 CORBA::Double theRL = 0., theWL = 0., theLtransL = 0., theLthinL = 0.;
1080 CORBA::Double theRR = 0., theWR = 0., theLtransR = 0., theLthinR = 0.;
1081 CORBA::Double theRI = 0., theWI = 0., theLtransI = 0., theLthinI = 0.;
1083 if (LReductionGroupParams->GroupBox1->isChecked()) {
1084 theRL = LReductionGroupParams->SpinBox1->value();
1085 theWL = LReductionGroupParams->SpinBox2->value();
1086 theLtransL = LReductionGroupParams->SpinBox3->value();
1087 theLthinL = LReductionGroupParams->SpinBox4->value();
1089 if (RReductionGroupParams->GroupBox1->isChecked()) {
1090 theRR = RReductionGroupParams->SpinBox1->value();
1091 theWR = RReductionGroupParams->SpinBox2->value();
1092 theLtransR = RReductionGroupParams->SpinBox3->value();
1093 theLthinR = RReductionGroupParams->SpinBox4->value();
1095 if (IReductionGroupParams->GroupBox1->isChecked()) {
1096 theRI = IReductionGroupParams->SpinBox1->value();
1097 theWI = IReductionGroupParams->SpinBox2->value();
1098 theLtransI = IReductionGroupParams->SpinBox3->value();
1099 theLthinI = IReductionGroupParams->SpinBox4->value();
1102 //if (JunctionPointsSel->GroupBox1->isChecked()) {
1103 // CheckCompatiblePosition(theL1, theL2, myPoint1, myPoint2, myPoint3, 0.01);
1104 // theL1 = MainTubeGroupParams->SpinBox_DZ->value();
1105 // theL2 = IncidentTubeGroupParams->SpinBox_DZ->value();
1108 // call engine function
1109 if (ChamferGroupParams->GroupBox1->isChecked()) {
1110 if (JunctionPointsSel->GroupBox1->isChecked())
1111 anObj = anOper->MakePipeTShapeTRChamferWithPosition(theR1, theW1, theL1, theR2, theW2, theL2,
1112 theRL, theWL, theLtransL, theLthinL,
1113 theRR, theWR, theLtransR, theLthinR,
1114 theRI, theWI, theLtransI, theLthinI,
1115 theH, theW, theHexMesh, myPoint1, myPoint2, myPoint3);
1117 anObj = anOper->MakePipeTShapeTRChamfer(theR1, theW1, theL1, theR2, theW2, theL2,
1118 theRL, theWL, theLtransL, theLthinL,
1119 theRR, theWR, theLtransR, theLthinR,
1120 theRI, theWI, theLtransI, theLthinI,
1121 theH, theW, theHexMesh);
1123 else if (FilletGroupParams->GroupBox1->isChecked()) {
1124 if (JunctionPointsSel->GroupBox1->isChecked())
1125 anObj = anOper->MakePipeTShapeTRFilletWithPosition(theR1, theW1, theL1, theR2, theW2, theL2,
1126 theRL, theWL, theLtransL, theLthinL,
1127 theRR, theWR, theLtransR, theLthinR,
1128 theRI, theWI, theLtransI, theLthinI,
1129 theRF, theHexMesh, myPoint1, myPoint2, myPoint3);
1131 anObj = anOper->MakePipeTShapeTRFillet(theR1, theW1, theL1, theR2, theW2, theL2,
1132 theRL, theWL, theLtransL, theLthinL,
1133 theRR, theWR, theLtransR, theLthinR,
1134 theRI, theWI, theLtransI, theLthinI,
1138 if (JunctionPointsSel->GroupBox1->isChecked())
1139 anObj = anOper->MakePipeTShapeTRWithPosition(theR1, theW1, theL1, theR2, theW2, theL2,
1140 theRL, theWL, theLtransL, theLthinL,
1141 theRR, theWR, theLtransR, theLthinR,
1142 theRI, theWI, theLtransI, theLthinI,
1143 theHexMesh, myPoint1, myPoint2, myPoint3);
1145 anObj = anOper->MakePipeTShapeTR(theR1, theW1, theL1, theR2, theW2, theL2,
1146 theRL, theWL, theLtransL, theLthinL,
1147 theRR, theWR, theLtransR, theLthinR,
1148 theRI, theWI, theLtransI, theLthinI,
1152 res = anObj->length();
1156 //res = !anObj->_is_nil();
1157 if (res && !IsPreview()) {
1158 QStringList aParameters;
1159 //@@ put stringified input parameters to the string list here to store in the data model for notebook @@//
1160 aParameters << MainTubeGroupParams->SpinBox_DX->text(); // R1 parameter
1161 aParameters << MainTubeGroupParams->SpinBox_DY->text(); // W1 parameter
1162 aParameters << MainTubeGroupParams->SpinBox_DZ->text(); // L1 parameter
1163 aParameters << IncidentTubeGroupParams->SpinBox_DX->text(); // R2 parameter
1164 aParameters << IncidentTubeGroupParams->SpinBox_DY->text(); // W2 parameter
1165 aParameters << IncidentTubeGroupParams->SpinBox_DZ->text(); // L2 parameter
1167 if (ChamferGroupParams->GroupBox1->isChecked()) { // Chamfer parameter
1168 aParameters << ChamferGroupParams->SpinBox_DX->text(); // H parameter
1169 aParameters << ChamferGroupParams->SpinBox_DY->text(); // W parameter
1171 if (FilletGroupParams->GroupBox1->isChecked()) // Fillet parameter
1172 aParameters << FilletGroupParams->SpinBox_DX->text(); // RF parameter
1174 // Thickness reductions
1175 if (LReductionGroupParams->GroupBox1->isChecked()) {
1176 aParameters << LReductionGroupParams->SpinBox1->text();
1177 aParameters << LReductionGroupParams->SpinBox2->text();
1178 aParameters << LReductionGroupParams->SpinBox3->text();
1179 aParameters << LReductionGroupParams->SpinBox4->text();
1182 aParameters << "0" << "0" << "0" << "0";
1184 if (RReductionGroupParams->GroupBox1->isChecked()) {
1185 aParameters << RReductionGroupParams->SpinBox1->text();
1186 aParameters << RReductionGroupParams->SpinBox2->text();
1187 aParameters << RReductionGroupParams->SpinBox3->text();
1188 aParameters << RReductionGroupParams->SpinBox4->text();
1191 aParameters << "0" << "0" << "0" << "0";
1193 if (IReductionGroupParams->GroupBox1->isChecked()) {
1194 aParameters << IReductionGroupParams->SpinBox1->text();
1195 aParameters << IReductionGroupParams->SpinBox2->text();
1196 aParameters << IReductionGroupParams->SpinBox3->text();
1197 aParameters << IReductionGroupParams->SpinBox4->text();
1200 aParameters << "0" << "0" << "0" << "0";
1203 if (aParameters.count() > 0)
1204 anObj[0]->SetParameters(aParameters.join(":").toUtf8().constData());
1207 objects.push_back(anObj[0]._retn());
1208 pipeTShapeGroupObjects.clear();
1209 for (int i = 1, n = anObj->length(); i < n; i++) {
1210 pipeTShapeGroupObjects.push_back(anObj[i]._retn());
1213 return objects.size() > 0;
1216 //=================================================================================
1217 // function : restoreSubShapes
1219 //=================================================================================
1220 void AdvancedGUI_PipeTShapeDlg::restoreSubShapes (SALOMEDS::SObject_ptr theSObject)
1222 SALOMEDS::GenericAttribute_var anAttr;
1223 if (!theSObject->FindAttribute(anAttr, "AttributeIOR"))
1226 SALOMEDS::AttributeIOR_var anAttrIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1227 CORBA::String_var anIORso = anAttrIOR->Value();
1229 // get Object from SObject
1230 GEOM::GEOM_Object_var theFather =
1231 GEOM::GEOM_Object::_narrow(myGeomGUI->getApp()->orb()->string_to_object(anIORso));
1232 if (CORBA::is_nil(theFather))
1235 ObjectList::iterator it = pipeTShapeGroupObjects.begin();
1237 for (int i = 0; it != pipeTShapeGroupObjects.end(); it++, i++) {
1238 getGeomEngine()->AddInStudy((*it), tr((*it)->GetName()).toStdString().c_str(), theFather);
1242 //=================================================================================
1243 // function : processPreview()
1244 // purpose : Display preview if CheckBoxPreview is checked
1245 //=================================================================================
1246 void AdvancedGUI_PipeTShapeDlg::processPreview()
1248 if (mainFrame()->CheckBoxPreview->isChecked())
1254 //=================================================================================
1255 // function : getSourceObjects
1256 // purpose : virtual method to get source objects
1257 //=================================================================================
1258 QList<GEOM::GeomObjPtr> AdvancedGUI_PipeTShapeDlg::getSourceObjects()
1260 QList<GEOM::GeomObjPtr> res;
1261 GEOM::GeomObjPtr aGeomObjPtr1(myPoint1), aGeomObjPtr2(myPoint2), aGeomObjPtr3(myPoint3);
1262 res << aGeomObjPtr1 << aGeomObjPtr2 << aGeomObjPtr3;
1266 //=================================================================================
1267 // function : AdvancedGUI_4Spin
1269 //=================================================================================
1270 AdvancedGUI_4Spin::AdvancedGUI_4Spin()
1272 GroupBox1 = new QGroupBox ();
1274 gridLayout1 = new QGridLayout (GroupBox1);
1275 gridLayout1->setSpacing(6);
1276 gridLayout1->setContentsMargins(11, 11, 11, 11);
1277 gridLayout1->setHorizontalSpacing(6);
1278 gridLayout1->setVerticalSpacing(6);
1279 gridLayout1->setContentsMargins(9, 9, 9, 9);
1281 TextLabel1 = new QLabel (GroupBox1);
1282 TextLabel2 = new QLabel (GroupBox1);
1283 TextLabel3 = new QLabel (GroupBox1);
1284 TextLabel4 = new QLabel (GroupBox1);
1286 SpinBox1 = new SalomeApp_DoubleSpinBox (GroupBox1);
1287 SpinBox2 = new SalomeApp_DoubleSpinBox (GroupBox1);
1288 SpinBox3 = new SalomeApp_DoubleSpinBox (GroupBox1);
1289 SpinBox4 = new SalomeApp_DoubleSpinBox (GroupBox1);
1291 SpinBox1->setMinimumWidth(60);
1292 SpinBox2->setMinimumWidth(60);
1293 SpinBox3->setMinimumWidth(60);
1294 SpinBox4->setMinimumWidth(60);
1296 gridLayout1->addWidget(TextLabel1, 0, 0, 1, 1);
1297 gridLayout1->addWidget(TextLabel2, 1, 0, 1, 1);
1298 gridLayout1->addWidget(TextLabel3, 2, 0, 1, 1);
1299 gridLayout1->addWidget(TextLabel4, 3, 0, 1, 1);
1301 gridLayout1->addWidget(SpinBox1, 0, 1, 1, 1);
1302 gridLayout1->addWidget(SpinBox2, 1, 1, 1, 1);
1303 gridLayout1->addWidget(SpinBox3, 2, 1, 1, 1);
1304 gridLayout1->addWidget(SpinBox4, 3, 1, 1, 1);
1307 //=================================================================================
1308 // function : ~AdvancedGUI_4Spin()
1309 // purpose : Destroys the object and frees any allocated resources
1310 //=================================================================================
1311 AdvancedGUI_4Spin::~AdvancedGUI_4Spin()
1313 // no need to delete child widgets, Qt does it all for us