Back to index

salome-geom  6.5.0
AdvancedGUI_PipeTShapeDlg.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "AdvancedGUI_PipeTShapeDlg.h"
00021 
00022 #include <DlgRef.h>
00023 #include <GeometryGUI.h>
00024 #include <GEOMBase.h>
00025 
00026 #include <SUIT_Session.h>
00027 #include <SUIT_ResourceMgr.h>
00028 #include <SUIT_OverrideCursor.h>
00029 #include <SalomeApp_Application.h>
00030 #include <SalomeApp_Tools.h>
00031 #include <LightApp_SelectionMgr.h>
00032 
00033 // OCCT Includes
00034 #include <TopoDS_Shape.hxx>
00035 #include <TopoDS.hxx>
00036 #include <TopExp.hxx>
00037 #include <TColStd_IndexedMapOfInteger.hxx>
00038 #include <TopTools_IndexedMapOfShape.hxx>
00039 #include <gp_Pnt.hxx>
00040 #include <BRep_Tool.hxx>
00041 
00042 #include <GEOMImpl_Types.hxx>
00043 
00044 //=================================================================================
00045 // Constructor
00046 //=================================================================================
00047 AdvancedGUI_PipeTShapeDlg::AdvancedGUI_PipeTShapeDlg(GeometryGUI* theGeometryGUI, QWidget* parent) :
00048        GEOMBase_Skeleton(theGeometryGUI, parent, false) {
00049        QPixmap imageOp(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_PIPETSHAPE")));
00050        QPixmap imageSel(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
00051        imageImp = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICO_PIPETSHAPE_IMPORT"));
00052        imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE"));
00053 
00054        setWindowTitle(tr("GEOM_PIPE_TSHAPE_TITLE"));
00055 
00056        /***************************************************************/
00057        mainFrame()->GroupConstructors->setTitle(tr("GEOM_PIPE_TSHAPE"));
00058        mainFrame()->RadioButton1->setIcon(imageOp);
00059        mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
00060        mainFrame()->RadioButton2->close();
00061        mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
00062        mainFrame()->RadioButton3->close();
00063 
00064        QGridLayout* myMainLayout = new QGridLayout(centralWidget());
00065        myMainLayout->setMargin(0);
00066        myMainLayout->setSpacing(6);
00067 
00068     tshapeScreenShotLabel = new QLabel();
00069     tshapeScreenShotLabel->setSizePolicy(QSizePolicy::Expanding,
00070                                          QSizePolicy::Expanding);
00071     tshapeScreenShotLabel->setAlignment(Qt::AlignCenter);
00072     tshapeScreenShotLabel->setMinimumSize(100, 100);
00073 
00074        MainTubeGroupParams = new DlgRef_3Spin();
00075        MainTubeGroupParams->GroupBox1->setTitle(tr("GEOM_PIPE_TSHAPE_MPIPE"));
00076        MainTubeGroupParams->TextLabel1->setText(tr("GEOM_PIPE_TSHAPE_R"));
00077        MainTubeGroupParams->TextLabel2->setText(tr("GEOM_PIPE_TSHAPE_W"));
00078        MainTubeGroupParams->TextLabel3->setText(tr("GEOM_PIPE_TSHAPE_L"));
00079 
00080        IncidentTubeGroupParams = new DlgRef_3Spin();
00081        IncidentTubeGroupParams->GroupBox1->setTitle(tr("GEOM_PIPE_TSHAPE_IPIPE"));
00082        IncidentTubeGroupParams->TextLabel1->setText(tr("GEOM_PIPE_TSHAPE_R"));
00083        IncidentTubeGroupParams->TextLabel2->setText(tr("GEOM_PIPE_TSHAPE_W"));
00084        IncidentTubeGroupParams->TextLabel3->setText(tr("GEOM_PIPE_TSHAPE_L"));
00085 
00086        ChamferGroupParams = new DlgRef_2Spin();
00087        ChamferGroupParams->GroupBox1->setCheckable(true);
00088        ChamferGroupParams->GroupBox1->setChecked(false);
00089        ChamferGroupParams->GroupBox1->setTitle(tr("GEOM_PIPE_TSHAPE_CHAMFER"));
00090        ChamferGroupParams->TextLabel1->setText(tr("GEOM_PIPE_TSHAPE_CHAMFER_H"));
00091        ChamferGroupParams->TextLabel2->setText(tr("GEOM_PIPE_TSHAPE_CHAMFER_W"));
00092 
00093        FilletGroupParams = new DlgRef_1Spin();
00094        FilletGroupParams->GroupBox1->setCheckable(true);
00095        FilletGroupParams->GroupBox1->setChecked(false);
00096        FilletGroupParams->GroupBox1->setTitle(tr("GEOM_PIPE_TSHAPE_FILLET"));
00097        FilletGroupParams->TextLabel1->setText(tr("GEOM_PIPE_TSHAPE_R"));
00098 
00099        HexMeshCheckBox = new QCheckBox();
00100        HexMeshCheckBox->setText(tr("GEOM_PIPE_TSHAPE_HEX"));
00101        HexMeshCheckBox->setChecked(true);
00102 
00103        JunctionPointsSel = new DlgRef_6Sel();
00104        JunctionPointsSel->GroupBox1->setTitle(tr("GEOM_PIPE_TSHAPE_POSITION"));
00105        JunctionPointsSel->GroupBox1->setCheckable(true);
00106        JunctionPointsSel->GroupBox1->setChecked(false);
00107        JunctionPointsSel->PushButton1->setIcon(imageSel);
00108        JunctionPointsSel->LineEdit1->setReadOnly(true);
00109        JunctionPointsSel->LineEdit1->setText("");
00110        JunctionPointsSel->TextLabel1->setText(tr("GEOM_PIPE_TSHAPE_POSITION_P1"));
00111 
00112        JunctionPointsSel->PushButton2->setIcon(imageSel);
00113        JunctionPointsSel->LineEdit2->setReadOnly(true);
00114        JunctionPointsSel->LineEdit2->setText("");
00115        JunctionPointsSel->TextLabel2->setText(tr("GEOM_PIPE_TSHAPE_POSITION_P2"));
00116 
00117        JunctionPointsSel->PushButton3->setIcon(imageSel);
00118        JunctionPointsSel->LineEdit3->setReadOnly(true);
00119        JunctionPointsSel->LineEdit3->setText("");
00120        JunctionPointsSel->TextLabel3->setText(tr("GEOM_PIPE_TSHAPE_POSITION_P3"));
00121 
00122     JunctionPointsSel->PushButton4->setIcon(imageImp);
00123     JunctionPointsSel->LineEdit4->setReadOnly(true);
00124     JunctionPointsSel->LineEdit4->setText("");
00125     JunctionPointsSel->TextLabel4->setText(tr("GEOM_PIPE_TSHAPE_POSITION_LBL_L1"));
00126 
00127     JunctionPointsSel->PushButton5->setIcon(imageImp);
00128     JunctionPointsSel->LineEdit5->setReadOnly(true);
00129     JunctionPointsSel->LineEdit5->setText("");
00130     JunctionPointsSel->TextLabel5->setText(tr("GEOM_PIPE_TSHAPE_POSITION_LBL_L2"));
00131 
00132     JunctionPointsSel->PushButton6->setAttribute(Qt::WA_DeleteOnClose);
00133     JunctionPointsSel->PushButton6->close();
00134     JunctionPointsSel->LineEdit6->setAttribute(Qt::WA_DeleteOnClose);
00135     JunctionPointsSel->LineEdit6->close();
00136     JunctionPointsSel->TextLabel6->setAttribute(Qt::WA_DeleteOnClose);
00137     JunctionPointsSel->TextLabel6->close();
00138 
00139        // 1st row, height = 1, colspan = 3
00140        int rowPict = 0, colPict = 0, rowspanPict = 1, colspanPict = 3;
00141        // 2nd row, height = 4, col 1
00142        int rowMain = rowspanPict,                           colMain = 0,      rowspanMain = 2,      colspanMain = 1;
00143        int rowCham = rowspanPict + rowspanMain,             colCham = 0,      rowspanCham = 2,      colspanCham = 1;
00144        // 2nd row, height = 4, col 2
00145        int rowInc = rowspanPict,                            colInc  = 1,      rowspanInc = 2,       colspanInc = 1;
00146        int rowFill = rowspanPict + rowspanInc,              colFill = 1,      rowspanFill = 1,      colspanFill = 1;
00147        int rowHex = rowspanPict + rowspanInc + rowspanFill, colHex  = 1,      rowspanHex = 1,       colspanHex = 1;
00148        // 2nd row, height = 4, col 3
00149        int rowNewPosVal = rowspanPict,                      colNewPosVal = 2, rowspanNewPosVal = 4, colspanNewPosVal = 1;
00150 
00151     myMainLayout->addWidget(tshapeScreenShotLabel, rowPict, colPict, rowspanPict, colspanPict);
00152 
00153        myMainLayout->addWidget(MainTubeGroupParams, rowMain, colMain, rowspanMain, colspanMain);
00154        myMainLayout->addWidget(FilletGroupParams, rowFill, colFill, rowspanFill, colspanFill);
00155        myMainLayout->addWidget(HexMeshCheckBox, rowHex, colHex, rowspanHex, colspanHex);
00156 
00157        myMainLayout->addWidget(IncidentTubeGroupParams, rowInc, colInc, rowspanInc, colspanInc);
00158        myMainLayout->addWidget(ChamferGroupParams, rowCham, colCham, rowspanCham, colspanCham);
00159 
00160        myMainLayout->addWidget(JunctionPointsSel, rowNewPosVal, colNewPosVal, rowspanNewPosVal, colspanNewPosVal);
00161        /***************************************************************/
00162 
00163        setHelpFileName("create_pipetshape_page.html");
00164 
00165        Init();
00166 }
00167 
00168 //=================================================================================
00169 // Destructor
00170 //=================================================================================
00171 AdvancedGUI_PipeTShapeDlg::~AdvancedGUI_PipeTShapeDlg() {
00172        // no need to delete child widgets, Qt does it all for us
00173 }
00174 
00175 //=================================================================================
00176 // function : Init()
00177 // purpose  :
00178 //=================================================================================
00179 void AdvancedGUI_PipeTShapeDlg::Init() {
00180        // Get setting of step value from file configuration
00181        SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
00182        double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
00183 
00184        myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
00185        myOkPoint1 = myOkPoint2 = myOkPoint3 = false;
00186 
00187        pipeTShapeGroupObjects.clear();
00188 
00189        // min, max, step and decimals for spin boxes
00190        initSpinBox(MainTubeGroupParams->SpinBox_DX, Precision::Approximation(), COORD_MAX, step, "length_precision");
00191        initSpinBox(MainTubeGroupParams->SpinBox_DY, Precision::Approximation(), COORD_MAX, step, "length_precision");
00192        initSpinBox(MainTubeGroupParams->SpinBox_DZ, Precision::Approximation(), COORD_MAX, step, "length_precision");
00193        initSpinBox(IncidentTubeGroupParams->SpinBox_DX, Precision::Approximation(), COORD_MAX, step, "length_precision");
00194        initSpinBox(IncidentTubeGroupParams->SpinBox_DY, Precision::Approximation(), COORD_MAX, step, "length_precision");
00195        initSpinBox(IncidentTubeGroupParams->SpinBox_DZ, Precision::Approximation(), COORD_MAX, step, "length_precision");
00196        initSpinBox(ChamferGroupParams->SpinBox_DX, Precision::Approximation(), COORD_MAX, step, "length_precision");
00197        initSpinBox(ChamferGroupParams->SpinBox_DY, Precision::Approximation(), COORD_MAX, step, "length_precision");
00198        initSpinBox(FilletGroupParams->SpinBox_DX, Precision::Approximation(), COORD_MAX, step, "length_precision");
00199 
00200        // init variables
00201        MainTubeGroupParams->SpinBox_DX->setValue(80);
00202        MainTubeGroupParams->SpinBox_DY->setValue(20);
00203        MainTubeGroupParams->SpinBox_DZ->setValue(200);
00204        IncidentTubeGroupParams->SpinBox_DX->setValue(50);
00205        IncidentTubeGroupParams->SpinBox_DY->setValue(20);
00206        IncidentTubeGroupParams->SpinBox_DZ->setValue(200);
00207        ChamferGroupParams->SpinBox_DX->setValue(20);
00208        ChamferGroupParams->SpinBox_DY->setValue(10);
00209        FilletGroupParams->SpinBox_DX->setValue(20);
00210 
00211     CssNormal = QString("QDoubleSpinBox {");
00212     CssNormal.append(MainTubeGroupParams->SpinBox_DZ->styleSheet());
00213     CssNormal.append("}");
00214     CssNormal.append("\nQPushButton {");
00215     CssNormal.append(JunctionPointsSel->PushButton4->styleSheet());
00216     CssNormal.append("}");
00217     CssAcceptable = "QDoubleSpinBox, QPushButton {background-color: rgb(85, 170, 127)}";
00218     CssRefused = "QDoubleSpinBox, QPushButton {background-color: rgb(255, 0, 0)}";
00219 
00220     showOnlyPreviewControl();
00221 
00222        // Signal/slot connections
00223        connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
00224        connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
00225        connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
00226        // ValueChangedInSpinBox
00227        connect(MainTubeGroupParams->SpinBox_DX, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
00228        connect(MainTubeGroupParams->SpinBox_DY, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
00229        connect(MainTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
00230        connect(IncidentTubeGroupParams->SpinBox_DX, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
00231        connect(IncidentTubeGroupParams->SpinBox_DY, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
00232        connect(IncidentTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
00233        connect(ChamferGroupParams->SpinBox_DX, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
00234        connect(ChamferGroupParams->SpinBox_DY, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
00235        connect(FilletGroupParams->SpinBox_DX, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
00236        // ChamferOrFillet
00237        connect(ChamferGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(ChamferOrFillet(bool)));
00238        connect(FilletGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(ChamferOrFillet(bool)));
00239        // Preview
00240 //     connect(PreviewPushButton, SIGNAL(clicked()), this, SLOT(DisplayPreview()));
00241        // Position
00242        connect(JunctionPointsSel->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(SetPosition(bool)));
00243        connect(JunctionPointsSel->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
00244        connect(JunctionPointsSel->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
00245        connect(JunctionPointsSel->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
00246     // ApplyNewDimensions
00247     connect(JunctionPointsSel->PushButton4, SIGNAL(clicked()), this, SLOT(ApplyNewDimensions()));
00248     connect(JunctionPointsSel->PushButton5, SIGNAL(clicked()), this, SLOT(ApplyNewDimensions()));
00249        connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(UpdatePicture(QWidget*, QWidget*)));
00250        //@@ put additional signal/slot connections here @@//
00251 
00252        initName(tr("GEOM_PIPE_TSHAPE"));
00253     updateTshapeScreenshotLabel();
00254     processPreview();
00255 }
00256 
00257 //=================================================================================
00258 // function : ApplyNewDimensions()
00259 // purpose  :
00260 //=================================================================================
00261 void AdvancedGUI_PipeTShapeDlg::ApplyNewDimensions() {
00262     QPushButton* send = (QPushButton*) sender();
00263 
00264     bool ok = false;
00265     double newVal;
00266     if (send == JunctionPointsSel->PushButton4) {
00267         if (!JunctionPointsSel->LineEdit4->text().isEmpty()) {
00268             newVal = JunctionPointsSel->LineEdit4->text().toDouble(&ok);
00269             if (ok) {
00270                 disconnect(MainTubeGroupParams->SpinBox_DZ, 0, this, 0);
00271                 MainTubeGroupParams->SpinBox_DZ->setValue(newVal);
00272                 connect(MainTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
00273                 MainTubeGroupParams->SpinBox_DZ->setToolTip("");
00274                 MainTubeGroupParams->SpinBox_DZ->setStyleSheet("background-color: rgb(255, 255, 255);");
00275                 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
00276               processPreview();
00277             }
00278         }
00279     }
00280     else if (send == JunctionPointsSel->PushButton5) {
00281         if (!JunctionPointsSel->LineEdit5->text().isEmpty()) {
00282             newVal = JunctionPointsSel->LineEdit5->text().toDouble(&ok);
00283             if (ok) {
00284                 disconnect(IncidentTubeGroupParams->SpinBox_DZ, 0, this, 0);
00285                 IncidentTubeGroupParams->SpinBox_DZ->setValue(newVal);
00286                 connect(IncidentTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
00287                 IncidentTubeGroupParams->SpinBox_DZ->setToolTip("");
00288                 IncidentTubeGroupParams->SpinBox_DZ->setStyleSheet("background-color: rgb(255, 255, 255);");
00289                 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
00290               processPreview();
00291             }
00292         }
00293     }
00294 }
00295 
00296 //=================================================================================
00297 // function : UpdatePicture()
00298 // purpose  :
00299 //=================================================================================
00300 void AdvancedGUI_PipeTShapeDlg::UpdatePicture(QWidget* old, QWidget* now) {
00301 
00302        if (ChamferGroupParams->GroupBox1->isChecked())
00303               if (now == MainTubeGroupParams->SpinBox_DX)
00304                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_R1"));
00305               else if (now == MainTubeGroupParams->SpinBox_DY)
00306                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_W1"));
00307               else if (now == MainTubeGroupParams->SpinBox_DZ)
00308                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_L1"));
00309               else if (now == IncidentTubeGroupParams->SpinBox_DX)
00310                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_R2"));
00311               else if (now == IncidentTubeGroupParams->SpinBox_DY)
00312                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_W2"));
00313               else if (now == IncidentTubeGroupParams->SpinBox_DZ)
00314                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_L2"));
00315               else if (now == ChamferGroupParams->SpinBox_DX)
00316                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_H"));
00317               else if (now == ChamferGroupParams->SpinBox_DY)
00318                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER_W"));
00319               else
00320                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER"));
00321        else if (FilletGroupParams->GroupBox1->isChecked())
00322               if (now == MainTubeGroupParams->SpinBox_DX)
00323                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_R1"));
00324               else if (now == MainTubeGroupParams->SpinBox_DY)
00325                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_W1"));
00326               else if (now == MainTubeGroupParams->SpinBox_DZ)
00327                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_L1"));
00328               else if (now == IncidentTubeGroupParams->SpinBox_DX)
00329                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_R2"));
00330               else if (now == IncidentTubeGroupParams->SpinBox_DY)
00331                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_W2"));
00332               else if (now == IncidentTubeGroupParams->SpinBox_DZ)
00333                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_L2"));
00334               else if (now == FilletGroupParams->SpinBox_DX)
00335                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET_RF"));
00336               else
00337                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET"));
00338        else
00339               if (now == MainTubeGroupParams->SpinBox_DX)
00340                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_R1"));
00341               else if (now == MainTubeGroupParams->SpinBox_DY)
00342                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_W1"));
00343               else if (now == MainTubeGroupParams->SpinBox_DZ)
00344                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_L1"));
00345               else if (now == IncidentTubeGroupParams->SpinBox_DX)
00346                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_R2"));
00347               else if (now == IncidentTubeGroupParams->SpinBox_DY)
00348                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_W2"));
00349               else if (now == IncidentTubeGroupParams->SpinBox_DZ)
00350                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_L2"));
00351               else
00352                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE"));
00353 
00354     updateTshapeScreenshotLabel();
00355 }
00356 
00357 //=================================================================================
00358 // function : SetPosition()
00359 // purpose  :
00360 //=================================================================================
00361 void AdvancedGUI_PipeTShapeDlg::SetPosition(bool isChecked) {
00362        if (isChecked) {
00363               erasePreview();
00364         JunctionPointsSel->LineEdit4->setText("");
00365         JunctionPointsSel->LineEdit5->setText("");
00366 //            connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(
00367 //                          SelectionIntoArgument()));
00368               JunctionPointsSel->PushButton1->click();
00369               SelectionIntoArgument();
00370        } else {
00371               disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
00372               JunctionPointsSel->LineEdit4->setText("");
00373               JunctionPointsSel->LineEdit5->setText("");
00374               processPreview();
00375        }
00376 }
00377 
00378 //=================================================================================
00379 // function : ValueChangedInSpinBox()
00380 // purpose  :
00381 //=================================================================================
00382 void AdvancedGUI_PipeTShapeDlg::ValueChangedInSpinBox(double newValue)
00383 {
00384     if (JunctionPointsSel->GroupBox1->isChecked() && myOkPoint1 && myOkPoint2 && myOkPoint3)
00385         CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
00386     processPreview();
00387 }
00388 
00389 //=================================================================================
00390 // function : SelectionIntoArgument()
00391 // purpose  : Called when selection as changed or other case
00392 //=================================================================================
00393 void AdvancedGUI_PipeTShapeDlg::SelectionIntoArgument() {
00394 
00395        erasePreview();
00396 //     myEditCurrentArgument->setText("");
00397 
00398        LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
00399        SALOME_ListIO aSelList;
00400        aSelMgr->selectedObjects(aSelList);
00401 
00402        if (aSelList.Extent() != 1) {
00403               if (myEditCurrentArgument == JunctionPointsSel->LineEdit1)
00404                      myOkPoint1 = false;
00405               else if (myEditCurrentArgument == JunctionPointsSel->LineEdit2)
00406                      myOkPoint2 = false;
00407               else if (myEditCurrentArgument == JunctionPointsSel->LineEdit3)
00408                      myOkPoint3 = false;
00409               return;
00410               myEditCurrentArgument->setText("");
00411        }
00412 
00413        // nbSel == 1
00414        if (aSelList.Extent() == 1) {
00415               Handle(SALOME_InteractiveObject) anIO = aSelList.First();
00416               GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(anIO);
00417               if (!CORBA::is_nil(aSelectedObject)) {
00418                      QString aName = GEOMBase::GetName(aSelectedObject);
00419                      TopoDS_Shape aShape;
00420                      if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) {
00421 
00422                             TColStd_IndexedMapOfInteger aMap;
00423                             aSelMgr->GetIndexes(anIO, aMap);
00424                             if (aMap.Extent() == 1) { // Local Selection
00425                                    int anIndex = aMap(1);
00426                                    aName += QString(":vertex_%1").arg(anIndex);
00427 
00428                                    //Find SubShape Object in Father
00429                                    GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
00430 
00431                                    if (aFindedObject->_is_nil()) { // Object not found in study
00432                                           GEOM::GEOM_IShapesOperations_var aShapesOp =
00433                                                         getGeomEngine()->GetIShapesOperations(getStudyId());
00434                                           aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
00435                                    } else {
00436                                           aSelectedObject = aFindedObject; // get Object from study
00437                                    }
00438                                    GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE);
00439                             } else { // Global Selection
00440                                    if (aShape.ShapeType() != TopAbs_VERTEX) {
00441                                           aSelectedObject = GEOM::GEOM_Object::_nil();
00442                                           aName = "";
00443                                    }
00444                             }
00445                      }
00446 
00447                      if (aShape.IsNull() || aShape.ShapeType() != TopAbs_VERTEX) {
00448                             return;
00449                      }
00450                      myEditCurrentArgument->setText(aName);
00451                      if (myEditCurrentArgument == JunctionPointsSel->LineEdit1) {
00452                             myPoint1 = aSelectedObject;
00453                             myOkPoint1 = true;
00454                             if (!myOkPoint2)
00455                                    JunctionPointsSel->PushButton2->click();
00456                      } else if (myEditCurrentArgument == JunctionPointsSel->LineEdit2) {
00457                             myPoint2 = aSelectedObject;
00458                             myOkPoint2 = true;
00459                             if (!myOkPoint3)
00460                                    JunctionPointsSel->PushButton3->click();
00461                      } else if (myEditCurrentArgument == JunctionPointsSel->LineEdit3) {
00462                             myPoint3 = aSelectedObject;
00463                             myOkPoint3 = true;
00464                             if (!myOkPoint1)
00465                                    JunctionPointsSel->PushButton1->click();
00466                      }
00467               }
00468        }
00469 
00470        if (myOkPoint1 && myOkPoint2 && myOkPoint3) {
00471         CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
00472        processPreview();
00473     }
00474 
00475 //     GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First());
00476 //     if (aSelectedObject->_is_nil())
00477 //            return;
00478 //
00479 //     myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject));
00480 //
00481 //     // clear selection
00482 //     disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
00483 //     myGeomGUI->getApp()->selectionMgr()->clearSelected();
00484 //     connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
00485 //
00486 //     if (myEditCurrentArgument == JunctionPointsSel->LineEdit1) {
00487 //            myPoint1 = aSelectedObject;
00488 //            myOkPoint1 = true;
00489 //            if (!myOkPoint2)
00490 //                   JunctionPointsSel->PushButton2->click();
00491 //            //                   P2GroupParams->PushButton1->click();
00492 //     } else if (myEditCurrentArgument == JunctionPointsSel->LineEdit2) {
00493 //            //     } else if (myEditCurrentArgument == P2GroupParams->LineEdit1) {
00494 //            myPoint2 = aSelectedObject;
00495 //            myOkPoint2 = true;
00496 //            if (!myOkPoint3)
00497 //                   JunctionPointsSel->PushButton3->click();
00498 //            //                   P3GroupParams->PushButton1->click();
00499 //     } else if (myEditCurrentArgument == JunctionPointsSel->LineEdit3) {
00500 //            //     } else if (myEditCurrentArgument == P3GroupParams->LineEdit1) {
00501 //            myPoint3 = aSelectedObject;
00502 //            myOkPoint3 = true;
00503 //            if (!myOkPoint1)
00504 //                   JunctionPointsSel->PushButton1->click();
00505 //     }
00506 }
00507 
00508 //=================================================================================
00509 // function : SetEditCurrentArgument()
00510 // purpose  :
00511 //=================================================================================
00512 void AdvancedGUI_PipeTShapeDlg::SetEditCurrentArgument() {
00513        QPushButton* send = (QPushButton*) sender();
00514 
00515        if (send == JunctionPointsSel->PushButton1) {
00516               myEditCurrentArgument = JunctionPointsSel->LineEdit1;
00517               JunctionPointsSel->PushButton2->setDown(false);
00518               JunctionPointsSel->LineEdit2->setEnabled(false);
00519               JunctionPointsSel->PushButton3->setDown(false);
00520               JunctionPointsSel->LineEdit3->setEnabled(false);
00521        } else if (send == JunctionPointsSel->PushButton2) {
00522               myEditCurrentArgument = JunctionPointsSel->LineEdit2;
00523               JunctionPointsSel->PushButton1->setDown(false);
00524               JunctionPointsSel->LineEdit1->setEnabled(false);
00525               JunctionPointsSel->PushButton3->setDown(false);
00526               JunctionPointsSel->LineEdit3->setEnabled(false);
00527        } else if (send == JunctionPointsSel->PushButton3) {
00528               myEditCurrentArgument = JunctionPointsSel->LineEdit3;
00529               JunctionPointsSel->PushButton1->setDown(false);
00530               JunctionPointsSel->LineEdit1->setEnabled(false);
00531               JunctionPointsSel->PushButton2->setDown(false);
00532               JunctionPointsSel->LineEdit2->setEnabled(false);
00533        }
00534 
00535        // enable line edit
00536        myEditCurrentArgument->setEnabled(true);
00537        myEditCurrentArgument->setFocus();
00538        myEditCurrentArgument->setText("");
00539        // after setFocus(), because it will be setDown(false) when loses focus
00540        send->setDown(true);
00541 
00542     JunctionPointsSel->LineEdit4->setText("");
00543     JunctionPointsSel->LineEdit5->setText("");
00544 
00545        disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
00546 //     globalSelection(GEOM_POINT);
00547     globalSelection(); // close local contexts, if any
00548     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
00549        connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
00550 }
00551 
00552 //=================================================================================
00553 // function : SetDoubleSpinBoxStep()
00554 // purpose  : Double spin box management
00555 //=================================================================================
00556 void AdvancedGUI_PipeTShapeDlg::SetDoubleSpinBoxStep(double step) {
00557        MainTubeGroupParams->SpinBox_DX->setSingleStep(step);
00558        MainTubeGroupParams->SpinBox_DY->setSingleStep(step);
00559        MainTubeGroupParams->SpinBox_DZ->setSingleStep(step);
00560        IncidentTubeGroupParams->SpinBox_DX->setSingleStep(step);
00561        IncidentTubeGroupParams->SpinBox_DY->setSingleStep(step);
00562        IncidentTubeGroupParams->SpinBox_DZ->setSingleStep(step);
00563        ChamferGroupParams->SpinBox_DX->setSingleStep(step);
00564        ChamferGroupParams->SpinBox_DY->setSingleStep(step);
00565        FilletGroupParams->SpinBox_DX->setSingleStep(step);
00566 }
00567 
00568 //=================================================================================
00569 // function : ClickOnOk()
00570 // purpose  :
00571 //=================================================================================
00572 void AdvancedGUI_PipeTShapeDlg::ClickOnOk() {
00573   setIsApplyAndClose( true );
00574        if (ClickOnApply())
00575               ClickOnCancel();
00576 }
00577 
00578 //=================================================================================
00579 // function : ClickOnApply()
00580 // purpose  :
00581 //=================================================================================
00582 bool AdvancedGUI_PipeTShapeDlg::ClickOnApply() {
00583        if (!onAccept())
00584               return false;
00585 
00586        initName();
00587 
00588        return true;
00589 }
00590 
00591 //=================================================================================
00592 // function : ActivateThisDialog()
00593 // purpose  :
00594 //=================================================================================
00595 void AdvancedGUI_PipeTShapeDlg::ActivateThisDialog() {
00596        GEOMBase_Skeleton::ActivateThisDialog();
00597        //     globalSelection( GEOM_POINT);
00598        //     connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(
00599        //                   currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
00600     if (myOkPoint1 && myOkPoint2 && myOkPoint3)
00601         CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
00602     processPreview();
00603 }
00604 
00605 //=================================================================================
00606 // function : enterEvent [REDEFINED]
00607 // purpose  :
00608 //=================================================================================
00609 void AdvancedGUI_PipeTShapeDlg::enterEvent(QEvent*) {
00610        if (!mainFrame()->GroupConstructors->isEnabled())
00611               ActivateThisDialog();
00612 }
00613 
00614 //=================================================================================
00615 // function : resizeEvent [REDEFINED]
00616 // purpose  :
00617 //=================================================================================
00618 void AdvancedGUI_PipeTShapeDlg::resizeEvent(QResizeEvent */*event*/) {
00619     QSize scaledSize = imagePipeTShape.size();
00620     scaledSize.scale(tshapeScreenShotLabel->size(), Qt::KeepAspectRatio);
00621     if (!tshapeScreenShotLabel->pixmap()
00622       || scaledSize != tshapeScreenShotLabel->pixmap()->size())
00623         updateTshapeScreenshotLabel();
00624 }
00625 
00626 //=================================================================================
00627 // function : updateTshapeScreenshotLabel
00628 // purpose  :
00629 //=================================================================================
00630 void AdvancedGUI_PipeTShapeDlg::updateTshapeScreenshotLabel() {
00631     tshapeScreenShotLabel->setPixmap(imagePipeTShape.scaled(tshapeScreenShotLabel->size(),
00632                                                       Qt::KeepAspectRatio,
00633                                                       Qt::SmoothTransformation));
00634 }
00635 
00636 //=================================================================================
00637 // function : ChamferOrFillet()
00638 // purpose  :
00639 //=================================================================================
00640 void AdvancedGUI_PipeTShapeDlg::ChamferOrFillet(bool) {
00641        QGroupBox* send = (QGroupBox*) sender();
00642 
00643        if (send == ChamferGroupParams->GroupBox1) {
00644               if (send->isChecked()) {
00645                      disconnect(FilletGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, 0);
00646                      FilletGroupParams->GroupBox1->setChecked(false);
00647                      connect(FilletGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(ChamferOrFillet(bool)));
00648                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_CHAMFER"));
00649               }
00650               else
00651                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE"));
00652         updateTshapeScreenshotLabel();
00653         if (myOkPoint1 && myOkPoint2 && myOkPoint3)
00654             CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
00655               processPreview();
00656        } else if (send == FilletGroupParams->GroupBox1) {
00657               if (send->isChecked()) {
00658                      disconnect(ChamferGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, 0);
00659                      ChamferGroupParams->GroupBox1->setChecked(!send->isChecked());
00660                      connect(ChamferGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(ChamferOrFillet(bool)));
00661                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE_FILLET"));
00662               }
00663               else
00664                      imagePipeTShape = SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("DLG_PIPETSHAPE"));
00665         updateTshapeScreenshotLabel();
00666         if (myOkPoint1 && myOkPoint2 && myOkPoint3)
00667             CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
00668                processPreview();
00669        }
00670 
00671 }
00672 
00673 //=================================================================================
00674 // function : DisplayPreview()
00675 // purpose  :
00676 //=================================================================================
00677 void AdvancedGUI_PipeTShapeDlg::DisplayPreview(const bool activate, const bool update, const bool toRemoveFromEngine,
00678               const double lineWidth, const int displayMode, const int color) {
00679        isPreview = true;
00680        QString msg;
00681        if (!isValid(msg)) {
00682               erasePreview(update);
00683               isPreview = false;
00684               return;
00685        }
00686 
00687        erasePreview(false);
00688 
00689        try {
00690               SUIT_OverrideCursor wc;
00691               ObjectList objects;
00692               bool hexMeshState = HexMeshCheckBox->isChecked();
00693               HexMeshCheckBox->setChecked(false);
00694               if (!executeNoCheck(objects) || !getOperation()->IsDone()) {
00695                      wc.suspend();
00696               } else {
00697                      ObjectList::iterator it = objects.begin();
00698                      GEOM::GEOM_Object_var obj = *it;
00699                      displayPreview(obj, true, activate, false, lineWidth, displayMode, color);
00700                      if (toRemoveFromEngine)
00701                             obj->UnRegister();
00702               }
00703               HexMeshCheckBox->setChecked(hexMeshState);
00704        } catch (const SALOME::SALOME_Exception& e) {
00705               SalomeApp_Tools::QtCatchCorbaException(e);
00706        }
00707 
00708        isPreview = false;
00709 
00710        if (update)
00711               updateViewer();
00712 }
00713 //=================================================================================
00714 // function : createOperation
00715 // purpose  :
00716 //=================================================================================
00717 GEOM::GEOM_IOperations_ptr AdvancedGUI_PipeTShapeDlg::createOperation() {
00718        return getGeomEngine()->GetIAdvancedOperations(getStudyId());
00719 }
00720 
00721 //=================================================================================
00722 // function : isValid
00723 // purpose  :
00724 //=================================================================================
00725 bool AdvancedGUI_PipeTShapeDlg::isValid(QString& msg) {
00726        bool ok = true;
00727 
00728        ok = MainTubeGroupParams->SpinBox_DX->isValid(msg, !IsPreview()) && ok;
00729        ok = MainTubeGroupParams->SpinBox_DY->isValid(msg, !IsPreview()) && ok;
00730        ok = MainTubeGroupParams->SpinBox_DZ->isValid(msg, !IsPreview()) && ok;
00731        ok = IncidentTubeGroupParams->SpinBox_DX->isValid(msg, !IsPreview()) && ok;
00732        ok = IncidentTubeGroupParams->SpinBox_DY->isValid(msg, !IsPreview()) && ok;
00733        ok = IncidentTubeGroupParams->SpinBox_DZ->isValid(msg, !IsPreview()) && ok;
00734        ok = ChamferGroupParams->SpinBox_DX->isValid(msg, !IsPreview()) && ok;
00735        ok = ChamferGroupParams->SpinBox_DY->isValid(msg, !IsPreview()) && ok;
00736        ok = FilletGroupParams->SpinBox_DX->isValid(msg, !IsPreview()) && ok;
00737 
00738        ok = fabs(MainTubeGroupParams->SpinBox_DX->value()) > Precision::Confusion() && ok;
00739        ok = fabs(MainTubeGroupParams->SpinBox_DY->value()) > Precision::Confusion() && ok;
00740        ok = fabs(MainTubeGroupParams->SpinBox_DZ->value()) > Precision::Confusion() && ok;
00741        ok = fabs(IncidentTubeGroupParams->SpinBox_DX->value()) > Precision::Confusion() && ok;
00742        ok = fabs(IncidentTubeGroupParams->SpinBox_DY->value()) > Precision::Confusion() && ok;
00743        ok = fabs(IncidentTubeGroupParams->SpinBox_DZ->value()) > Precision::Confusion() && ok;
00744        ok = fabs(ChamferGroupParams->SpinBox_DX->value()) > Precision::Confusion() && ok;
00745        ok = fabs(ChamferGroupParams->SpinBox_DY->value()) > Precision::Confusion() && ok;
00746        ok = fabs(FilletGroupParams->SpinBox_DX->value()) > Precision::Confusion() && ok;
00747 
00748        if (JunctionPointsSel->GroupBox1->isChecked())
00749               ok = myOkPoint1 && myOkPoint2 && myOkPoint3 && ok;
00750 
00751        return ok;
00752 }
00753 
00754 //=================================================================================
00755 // function : CheckCompatiblePosition()
00756 // purpose  :
00757 //=================================================================================
00758 bool AdvancedGUI_PipeTShapeDlg::CheckCompatiblePosition(GEOM::GEOM_Object_var theP1,
00759               GEOM::GEOM_Object_var theP2, GEOM::GEOM_Object_var theP3, double theTolerance) {
00760 
00761     MainTubeGroupParams->SpinBox_DZ->setStyleSheet(CssNormal);
00762     IncidentTubeGroupParams->SpinBox_DZ->setStyleSheet(CssNormal);
00763     JunctionPointsSel->PushButton4->setStyleSheet(CssNormal);
00764     JunctionPointsSel->PushButton5->setStyleSheet(CssNormal);
00765 
00766     CORBA::Double theL1 = MainTubeGroupParams->SpinBox_DZ->value();
00767     CORBA::Double theL2 = IncidentTubeGroupParams->SpinBox_DZ->value();
00768 
00769     JunctionPointsSel->LineEdit4->setText("");
00770     JunctionPointsSel->LineEdit5->setText("");
00771 
00772     MainTubeGroupParams->SpinBox_DZ->setToolTip("");
00773     IncidentTubeGroupParams->SpinBox_DZ->setToolTip("");
00774 
00775        TopoDS_Shape aShape;
00776        gp_Pnt P1, P2, P3;
00777        if ( GEOMBase::GetShape( theP1, aShape ) && !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
00778               P1 = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
00779        else
00780               return false;
00781 
00782        if ( GEOMBase::GetShape( theP2, aShape ) && !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
00783               P2 = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
00784        else
00785               return false;
00786 
00787        if ( GEOMBase::GetShape( theP3, aShape ) && !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
00788               P3 = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
00789        else
00790               return false;
00791 
00792     double d12 = P1.Distance(P2);
00793     double d13 = P1.Distance(P3);
00794     double d23 = P2.Distance(P3);
00795 
00796     if (Abs(d12) <= Precision::Confusion()) {
00797 //         SetErrorCode("Junctions points P1 and P2 are identical");
00798         return false;
00799     }
00800     if (Abs(d13) <= Precision::Confusion()) {
00801 //         SetErrorCode("Junctions points P1 and P3 are identical");
00802         return false;
00803     }
00804     if (Abs(d23) <= Precision::Confusion()) {
00805 //         SetErrorCode("Junctions points P2 and P3 are identical");
00806         return false;
00807     }
00808 
00809     long double newL1 = 0.5 * d12;
00810     long double newL2 = sqrt(pow(d13,2)-pow(newL1,2));
00811 
00812     JunctionPointsSel->LineEdit4->setText(QString::number(newL1,'f',7));
00813     JunctionPointsSel->LineEdit5->setText(QString::number(newL2,'f',7));
00814 
00815     if (fabs(newL1 - theL1) > Precision::Approximation()) {
00816               if ((newL1 * (1 - theTolerance) - theL1 <= Precision::Approximation()) &&
00817                             (newL1 * (1 + theTolerance) - theL1 >= Precision::Approximation())) {
00818             disconnect(MainTubeGroupParams->SpinBox_DZ, 0, this, 0);
00819                      MainTubeGroupParams->SpinBox_DZ->setValue(newL1);
00820             connect(MainTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
00821                      MainTubeGroupParams->SpinBox_DZ->setToolTip("Value was recomputed to fit with position");
00822             MainTubeGroupParams->SpinBox_DZ->setStyleSheet(CssAcceptable);
00823             JunctionPointsSel->PushButton4->setStyleSheet(CssAcceptable);
00824               }
00825               else {
00826                      MainTubeGroupParams->SpinBox_DZ->setToolTip("Value is incompatible with position");
00827             MainTubeGroupParams->SpinBox_DZ->setStyleSheet(CssRefused);
00828             JunctionPointsSel->PushButton4->setStyleSheet(CssRefused);
00829               }
00830        }
00831     else {
00832         MainTubeGroupParams->SpinBox_DZ->setStyleSheet(CssNormal);
00833         JunctionPointsSel->PushButton4->setStyleSheet(CssNormal);
00834     }
00835 
00836        if (fabs(newL2 - theL2) > Precision::Approximation()) {
00837               if ((newL2 * (1 - theTolerance) - theL2 <= Precision::Approximation()) &&
00838                             (newL2 * (1 + theTolerance) - theL2 >= Precision::Approximation())) {
00839             disconnect(IncidentTubeGroupParams->SpinBox_DZ, 0, this, 0);
00840                      IncidentTubeGroupParams->SpinBox_DZ->setValue(newL2);
00841             connect(IncidentTubeGroupParams->SpinBox_DZ, SIGNAL(valueChanged( double )), this, SLOT(ValueChangedInSpinBox(double)));
00842                      IncidentTubeGroupParams->SpinBox_DZ->setToolTip("Value was recomputed to fit with position");
00843             IncidentTubeGroupParams->SpinBox_DZ->setStyleSheet(CssAcceptable);
00844             JunctionPointsSel->PushButton5->setStyleSheet(CssAcceptable);
00845               }
00846               else {
00847                      IncidentTubeGroupParams->SpinBox_DZ->setToolTip("Value is incompatible with position");
00848             IncidentTubeGroupParams->SpinBox_DZ->setStyleSheet(CssRefused);
00849             JunctionPointsSel->PushButton5->setStyleSheet(CssRefused);
00850               }
00851        }
00852        else {
00853         IncidentTubeGroupParams->SpinBox_DZ->setStyleSheet(CssNormal);
00854         JunctionPointsSel->PushButton5->setStyleSheet(CssNormal);
00855     }
00856 
00857        return true;
00858 }
00859 
00860 bool AdvancedGUI_PipeTShapeDlg::execute(ObjectList& objects) {
00861 
00862     if (JunctionPointsSel->GroupBox1->isChecked() && myOkPoint1 && myOkPoint2 && myOkPoint3)
00863         CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
00864 
00865     return executeNoCheck(objects);
00866 }
00867 
00868 //=================================================================================
00869 // function : execute
00870 // purpose  :
00871 //=================================================================================
00872 bool AdvancedGUI_PipeTShapeDlg::executeNoCheck(ObjectList& objects) {
00873        bool res = false;
00874 
00875        //   GEOM::GEOM_Object_var anObj;
00876        GEOM::ListOfGO_var anObj;
00877 
00878        GEOM::GEOM_IAdvancedOperations_var anOper = GEOM::GEOM_IAdvancedOperations::_narrow(getOperation());
00879 
00880        //@@ retrieve input values from the widgets here @@//
00881        CORBA::Double theR1 = MainTubeGroupParams->SpinBox_DX->value();
00882        CORBA::Double theW1 = MainTubeGroupParams->SpinBox_DY->value();
00883        CORBA::Double theL1 = MainTubeGroupParams->SpinBox_DZ->value();
00884        CORBA::Double theR2 = IncidentTubeGroupParams->SpinBox_DX->value();
00885        CORBA::Double theW2 = IncidentTubeGroupParams->SpinBox_DY->value();
00886        CORBA::Double theL2 = IncidentTubeGroupParams->SpinBox_DZ->value();
00887        CORBA::Double theH = ChamferGroupParams->SpinBox_DX->value();
00888        CORBA::Double theW = ChamferGroupParams->SpinBox_DY->value();
00889        CORBA::Double theRF = FilletGroupParams->SpinBox_DX->value();
00890        CORBA::Boolean theHexMesh = HexMeshCheckBox->isChecked();
00891 
00892 //     if (JunctionPointsSel->GroupBox1->isChecked()) {
00893 //            CheckCompatiblePosition(theL1, theL2, myPoint1, myPoint2, myPoint3, 0.01);
00894 //            theL1 = MainTubeGroupParams->SpinBox_DZ->value();
00895 //            theL2 = IncidentTubeGroupParams->SpinBox_DZ->value();
00896 //     }
00897 
00898        // call engine function
00899        if (ChamferGroupParams->GroupBox1->isChecked()) {
00900               if (JunctionPointsSel->GroupBox1->isChecked())
00901                      anObj = anOper->MakePipeTShapeChamferWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, theH, theW,
00902                                    theHexMesh, myPoint1, myPoint2, myPoint3);
00903               else
00904                      anObj = anOper->MakePipeTShapeChamfer(theR1, theW1, theL1, theR2, theW2, theL2, theH, theW, theHexMesh);
00905        }
00906        else if (FilletGroupParams->GroupBox1->isChecked()) {
00907               if (JunctionPointsSel->GroupBox1->isChecked())
00908                      anObj = anOper->MakePipeTShapeFilletWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, theRF,
00909                                    theHexMesh, myPoint1, myPoint2, myPoint3);
00910               else
00911                      anObj = anOper->MakePipeTShapeFillet(theR1, theW1, theL1, theR2, theW2, theL2, theRF, theHexMesh);
00912        }
00913        else {
00914               if (JunctionPointsSel->GroupBox1->isChecked())
00915               anObj = anOper->MakePipeTShapeWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, theHexMesh, myPoint1,
00916                             myPoint2, myPoint3);
00917               else
00918                      anObj = anOper->MakePipeTShape(theR1, theW1, theL1, theR2, theW2, theL2, theHexMesh);
00919        }
00920 
00921        res = anObj->length();
00922        if (!res)
00923               return false;
00924 
00925        //   res = !anObj->_is_nil();
00926        if (res && !IsPreview()) {
00927               QStringList aParameters;
00928               //@@ put stringified input parameters to the string list here to store in the data model for notebook @@//
00929               aParameters << MainTubeGroupParams->SpinBox_DX->text(); // R1 parameter
00930               aParameters << MainTubeGroupParams->SpinBox_DY->text(); // W1 parameter
00931               aParameters << MainTubeGroupParams->SpinBox_DZ->text(); // L1 parameter
00932               aParameters << IncidentTubeGroupParams->SpinBox_DX->text(); // R2 parameter
00933               aParameters << IncidentTubeGroupParams->SpinBox_DY->text(); // W2 parameter
00934               aParameters << IncidentTubeGroupParams->SpinBox_DZ->text(); // L2 parameter
00935               if (ChamferGroupParams->GroupBox1->isChecked()) {// Chamfer parameter
00936                      aParameters << ChamferGroupParams->SpinBox_DX->text(); // H parameter
00937                      aParameters << ChamferGroupParams->SpinBox_DY->text(); // W parameter
00938               }
00939               if (FilletGroupParams->GroupBox1->isChecked()) // Fillet parameter
00940                      aParameters << FilletGroupParams->SpinBox_DX->text(); // RF parameter
00941 
00942               if (aParameters.count() > 0)
00943                      anObj[0]->SetParameters(aParameters.join(":").toLatin1().constData());
00944        }
00945 
00946        objects.push_back(anObj[0]._retn());
00947        pipeTShapeGroupObjects.clear();
00948        for (int i = 1, n = anObj->length(); i < n; i++) {
00949               pipeTShapeGroupObjects.push_back(anObj[i]._retn());
00950        }
00951 
00952        return objects.size() > 0;
00953 }
00954 
00955 //=================================================================================
00956 // function : restoreSubShapes
00957 // purpose  :
00958 //=================================================================================
00959 void AdvancedGUI_PipeTShapeDlg::restoreSubShapes(SALOMEDS::Study_ptr theStudy, SALOMEDS::SObject_ptr theSObject) {
00960        SALOMEDS::GenericAttribute_var anAttr;
00961        if (!theSObject->FindAttribute(anAttr, "AttributeIOR"))
00962               return;
00963 
00964        SALOMEDS::AttributeIOR_var anAttrIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
00965        CORBA::String_var anIORso = anAttrIOR->Value();
00966 
00967        // get Object from SObject
00968        GEOM::GEOM_Object_var theFather = GEOM::GEOM_Object::_narrow(myGeomGUI->getApp()->orb()->string_to_object(anIORso));
00969        if (CORBA::is_nil(theFather))
00970               return;
00971 
00972        ObjectList::iterator it = pipeTShapeGroupObjects.begin();
00973 
00974        for (int i = 0; it != pipeTShapeGroupObjects.end(); it++, i++) {
00975               getGeomEngine()->AddInStudy(theStudy, (*it), tr((*it)->GetName()).toStdString().c_str(), theFather);
00976        }
00977 
00978 }
00979 
00980 //=================================================================================
00981 // function : processPreview()
00982 // purpose  : Display preview if CheckBoxPreview is checked
00983 //=================================================================================
00984 void AdvancedGUI_PipeTShapeDlg::processPreview() {
00985   if(mainFrame()->CheckBoxPreview->isChecked())
00986     DisplayPreview();
00987   else
00988     erasePreview(true);
00989 }