Version: 6.3.1

src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // SMESH SMESHGUI : GUI for SMESH component
00024 // File   : SMESHGUI_ExtrusionDlg.cxx
00025 // Author : Michael ZORIN, Open CASCADE S.A.S.
00026 // SMESH includes
00027 //
00028 #include "SMESHGUI_ExtrusionDlg.h"
00029 
00030 #include "SMESHGUI.h"
00031 #include "SMESHGUI_Utils.h"
00032 #include "SMESHGUI_VTKUtils.h"
00033 #include "SMESHGUI_MeshUtils.h"
00034 #include "SMESHGUI_SpinBox.h"
00035 #include "SMESHGUI_IdValidator.h"
00036 #include "SMESHGUI_FilterDlg.h"
00037 #include "SMESHGUI_MeshEditPreview.h"
00038 
00039 #include <SMESH_Actor.h>
00040 #include <SMESH_TypeFilter.hxx>
00041 #include <SMESH_LogicalFilter.hxx>
00042 
00043 #include <SMDS_Mesh.hxx>
00044 
00045 // SALOME GUI includes
00046 #include <SUIT_ResourceMgr.h>
00047 #include <SUIT_Desktop.h>
00048 #include <SUIT_MessageBox.h>
00049 #include <SUIT_Session.h>
00050 #include <SUIT_OverrideCursor.h>
00051 
00052 #include <LightApp_Application.h>
00053 #include <LightApp_SelectionMgr.h>
00054 
00055 #include <SVTK_ViewModel.h>
00056 #include <SVTK_ViewWindow.h>
00057 
00058 #include <SalomeApp_IntSpinBox.h>
00059 
00060 // OCCT includes
00061 #include <TColStd_MapOfInteger.hxx>
00062 #include <TColStd_IndexedMapOfInteger.hxx>
00063 #include <gp_XYZ.hxx>
00064 
00065 // Qt includes
00066 #include <QApplication>
00067 #include <QButtonGroup>
00068 #include <QGroupBox>
00069 #include <QLabel>
00070 #include <QLineEdit>
00071 #include <QPushButton>
00072 #include <QRadioButton>
00073 #include <QCheckBox>
00074 #include <QHBoxLayout>
00075 #include <QVBoxLayout>
00076 #include <QGridLayout>
00077 #include <QKeyEvent>
00078 
00079 // IDL includes
00080 #include <SALOMEconfig.h>
00081 #include CORBA_SERVER_HEADER(SMESH_Group)
00082 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
00083 
00084 #define SPACING 6
00085 #define MARGIN  11
00086 
00087 //=================================================================================
00088 // function : SMESHGUI_ExtrusionDlg()
00089 // purpose  : constructor
00090 //=================================================================================
00091 SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule)
00092   : SMESHGUI_PreviewDlg( theModule ),
00093     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
00094     myFilterDlg( 0 ),
00095     mySelectedObject(SMESH::SMESH_IDSource::_nil())
00096 {
00097   QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
00098   QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
00099   QPixmap image2 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
00100 
00101   setModal( false );
00102   setAttribute( Qt::WA_DeleteOnClose, true );
00103   setWindowTitle(tr("EXTRUSION_ALONG_LINE"));
00104   setSizeGripEnabled(true);
00105 
00106   QVBoxLayout* SMESHGUI_ExtrusionDlgLayout = new QVBoxLayout(this);
00107   SMESHGUI_ExtrusionDlgLayout->setSpacing(SPACING);
00108   SMESHGUI_ExtrusionDlgLayout->setMargin(MARGIN);
00109 
00110   /***************************************************************/
00111   ConstructorsBox = new QGroupBox(tr("SMESH_EXTRUSION"), this);
00112   GroupConstructors = new QButtonGroup(this);
00113   QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
00114   ConstructorsBoxLayout->setSpacing(SPACING);
00115   ConstructorsBoxLayout->setMargin(MARGIN);
00116 
00117   RadioButton1= new QRadioButton(ConstructorsBox);
00118   RadioButton1->setIcon(image0);
00119   RadioButton2= new QRadioButton(ConstructorsBox);
00120   RadioButton2->setIcon(image1);
00121 
00122   ConstructorsBoxLayout->addWidget(RadioButton1);
00123   ConstructorsBoxLayout->addWidget(RadioButton2);
00124 
00125   GroupConstructors->addButton(RadioButton1, 0);
00126   GroupConstructors->addButton(RadioButton2, 1);
00127 
00128   /***************************************************************/
00129   GroupButtons = new QGroupBox(this);
00130   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
00131   GroupButtonsLayout->setSpacing(SPACING);
00132   GroupButtonsLayout->setMargin(MARGIN);
00133 
00134   buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
00135   buttonOk->setAutoDefault(true);
00136   buttonOk->setDefault(true);
00137   buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
00138   buttonApply->setAutoDefault(true);
00139   buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
00140   buttonCancel->setAutoDefault(true);
00141   buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
00142   buttonHelp->setAutoDefault(true);
00143 
00144   GroupButtonsLayout->addWidget(buttonOk);
00145   GroupButtonsLayout->addSpacing(10);
00146   GroupButtonsLayout->addWidget(buttonApply);
00147   GroupButtonsLayout->addSpacing(10);
00148   GroupButtonsLayout->addStretch();
00149   GroupButtonsLayout->addWidget(buttonCancel);
00150   GroupButtonsLayout->addWidget(buttonHelp);
00151 
00152   /***************************************************************/
00153   GroupArguments = new QGroupBox(tr("EXTRUSION_1D"), this);
00154   QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
00155   GroupArgumentsLayout->setSpacing(SPACING);
00156   GroupArgumentsLayout->setMargin(MARGIN);
00157 
00158   myIdValidator = new SMESHGUI_IdValidator(this);
00159 
00160   // Controls for elements selection
00161   TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
00162 
00163   SelectElementsButton = new QPushButton(GroupArguments);
00164   SelectElementsButton->setIcon(image2);
00165 
00166   LineEditElements = new QLineEdit(GroupArguments);
00167   LineEditElements->setValidator(myIdValidator);
00168   LineEditElements->setMaxLength(-1);
00169   myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
00170   connect(myFilterBtn,   SIGNAL(clicked()), this, SLOT(setFilters()));
00171 
00172   // Control for the whole mesh selection
00173   CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
00174 
00175   RadioButton3 = new QRadioButton(GroupArguments);
00176   RadioButton3->setText( tr("SMESH_EXTRUSION_TO_DISTANCE") );
00177   RadioButton4 = new QRadioButton(GroupArguments);
00178   RadioButton4->setText( tr("SMESH_EXTRUSION_ALONG_VECTOR") );
00179 
00180   //Control for the Distance selection
00181   TextLabelDistance = new QLabel(tr("SMESH_DISTANCE"), GroupArguments);
00182   
00183   TextLabelDx = new QLabel(tr("SMESH_X"), GroupArguments);
00184   SpinBox_Dx = new SMESHGUI_SpinBox(GroupArguments);
00185   
00186   TextLabelDy = new QLabel(tr("SMESH_Y"), GroupArguments);
00187   SpinBox_Dy = new SMESHGUI_SpinBox(GroupArguments);
00188 
00189   TextLabelDz = new QLabel(tr("SMESH_Z"), GroupArguments);
00190   SpinBox_Dz = new SMESHGUI_SpinBox(GroupArguments);
00191 
00192   // Controls for vector selection
00193 
00194   TextLabelVector = new QLabel(tr("SMESH_VECTOR"), GroupArguments);
00195 
00196   SelectVectorButton = new QPushButton(GroupArguments);
00197   SelectVectorButton->setIcon(image2);
00198 
00199   TextLabelVx = new QLabel(tr("SMESH_DX"), GroupArguments);
00200   SpinBox_Vx = new SMESHGUI_SpinBox(GroupArguments);
00201 
00202   TextLabelVy = new QLabel(tr("SMESH_DY"), GroupArguments);
00203   SpinBox_Vy = new SMESHGUI_SpinBox(GroupArguments);
00204 
00205   TextLabelVz = new QLabel(tr("SMESH_DZ"), GroupArguments);
00206   SpinBox_Vz = new SMESHGUI_SpinBox(GroupArguments);
00207 
00208   TextLabelDist = new QLabel(tr("SMESH_DISTANCE"), GroupArguments);
00209   SpinBox_VDist = new SMESHGUI_SpinBox(GroupArguments);
00210 
00211   // Controls for nb. steps defining
00212   TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupArguments);
00213   SpinBox_NbSteps = new SalomeApp_IntSpinBox(GroupArguments);
00214 
00215   // CheckBox for groups generation
00216   MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
00217 
00218   //Preview check box
00219   myPreviewCheckBox = new QCheckBox(tr("PREVIEW"), GroupArguments);
00220 
00221   GroupArgumentsLayout->addWidget(TextLabelElements,    0, 0);
00222   GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
00223   GroupArgumentsLayout->addWidget(LineEditElements,     0, 2, 1, 5);
00224   GroupArgumentsLayout->addWidget(myFilterBtn,          0, 7);
00225   GroupArgumentsLayout->addWidget(CheckBoxMesh,         1, 0, 1, 8);
00226   GroupArgumentsLayout->addWidget(RadioButton3,         2, 1, 1, 3);
00227   GroupArgumentsLayout->addWidget(RadioButton4,         2, 5, 1, 3);
00228   GroupArgumentsLayout->addWidget(TextLabelDistance,    3, 0);
00229   GroupArgumentsLayout->addWidget(TextLabelDx,          3, 2);
00230   GroupArgumentsLayout->addWidget(SpinBox_Dx,           3, 3);
00231   GroupArgumentsLayout->addWidget(TextLabelDy,          3, 4);
00232   GroupArgumentsLayout->addWidget(SpinBox_Dy,           3, 5);
00233   GroupArgumentsLayout->addWidget(TextLabelDz,          3, 6);
00234   GroupArgumentsLayout->addWidget(SpinBox_Dz,           3, 7);
00235   GroupArgumentsLayout->addWidget(TextLabelVector,      4, 0);
00236   GroupArgumentsLayout->addWidget(SelectVectorButton,   4, 1);
00237   GroupArgumentsLayout->addWidget(TextLabelVx,          4, 2);
00238   GroupArgumentsLayout->addWidget(SpinBox_Vx,           4, 3);
00239   GroupArgumentsLayout->addWidget(TextLabelVy,          4, 4);
00240   GroupArgumentsLayout->addWidget(SpinBox_Vy,           4, 5);
00241   GroupArgumentsLayout->addWidget(TextLabelVz,          4, 6);
00242   GroupArgumentsLayout->addWidget(SpinBox_Vz,           4, 7);
00243   GroupArgumentsLayout->addWidget(TextLabelDist,        5, 0);
00244   GroupArgumentsLayout->addWidget(SpinBox_VDist,         5, 3);
00245   GroupArgumentsLayout->addWidget(TextLabelNbSteps,     6, 0, 1, 3);
00246   GroupArgumentsLayout->addWidget(SpinBox_NbSteps,      6, 3);
00247   GroupArgumentsLayout->addWidget(myPreviewCheckBox,    7, 0, 1, 8);
00248   GroupArgumentsLayout->addWidget(MakeGroupsCheck,      8, 0, 1, 8);
00249   GroupArgumentsLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding), 8, 0);
00250 
00251 
00252   /***************************************************************/
00253   SMESHGUI_ExtrusionDlgLayout->addWidget(ConstructorsBox);
00254   SMESHGUI_ExtrusionDlgLayout->addWidget(GroupArguments);
00255   SMESHGUI_ExtrusionDlgLayout->addWidget(GroupButtons);
00256 
00257   /* Initialisations */
00258   SpinBox_Vx->RangeStepAndValidator(COORD_MIN, COORD_MAX, 0.01, "length_precision");
00259   SpinBox_Vy->RangeStepAndValidator(COORD_MIN, COORD_MAX, 0.01, "length_precision");
00260   SpinBox_Vz->RangeStepAndValidator(COORD_MIN, COORD_MAX, 0.01, "length_precision");
00261 
00262   SpinBox_Dx->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
00263   SpinBox_Dy->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
00264   SpinBox_Dz->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
00265   
00266   SpinBox_NbSteps->setRange(1, 999999);
00267   SpinBox_VDist->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
00268 
00269   RadioButton1->setChecked(true);
00270   RadioButton3->setChecked(true);
00271   MakeGroupsCheck->setChecked(true);
00272 
00273   mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
00274 
00275   mySMESHGUI->SetActiveDialogBox(this);
00276 
00277   // Costruction of the logical filter for the elements: mesh/sub-mesh/group
00278   SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
00279   SMESH_TypeFilter* aSmeshGroupFilter    = new SMESH_TypeFilter (GROUP);
00280 
00281   QList<SUIT_SelectionFilter*> aListOfFilters;
00282   if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
00283   if (aSmeshGroupFilter)    aListOfFilters.append(aSmeshGroupFilter);
00284 
00285   myMeshOrSubMeshOrGroupFilter =
00286     new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
00287 
00288   myHelpFileName = "extrusion_page.html";
00289 
00290   Init();
00291 
00292   /***************************************************************/
00293   // signals and slots connections
00294   connect(buttonOk,     SIGNAL(clicked()), this, SLOT(ClickOnOk()));
00295   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
00296   connect(buttonApply,  SIGNAL(clicked()), this, SLOT(ClickOnApply()));
00297   connect(buttonHelp,   SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
00298 
00299   connect(RadioButton3, SIGNAL(clicked()), this, SLOT(ClickOnRadio()));
00300   connect(RadioButton4, SIGNAL(clicked()), this, SLOT(ClickOnRadio()));
00301 
00302   // to update state of the Ok & Apply buttons
00303   connect(SpinBox_Vx, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
00304   connect(SpinBox_Vy, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
00305   connect(SpinBox_Vz, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
00306   connect(SpinBox_Dx, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
00307   connect(SpinBox_Dy, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
00308   connect(SpinBox_Dz, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
00309 
00310   connect(GroupConstructors,    SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
00311   connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
00312   connect(SelectVectorButton,   SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
00313   connect(mySMESHGUI,           SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
00314   connect(mySelectionMgr,       SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
00315   /* to close dialog if study change */
00316   connect(mySMESHGUI,           SIGNAL(SignalCloseAllDialogs()),   this, SLOT(ClickOnCancel()));
00317   connect(LineEditElements,     SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
00318   connect(CheckBoxMesh,         SIGNAL(toggled(bool)),               SLOT(onSelectMesh(bool)));
00319 
00320   connect(SpinBox_Dx,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
00321   connect(SpinBox_Dy,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
00322   connect(SpinBox_Dz,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
00323   connect(SpinBox_Vx,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
00324   connect(SpinBox_Vy,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
00325   connect(SpinBox_Vz,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
00326   connect(SpinBox_VDist,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
00327   connect(SpinBox_NbSteps,  SIGNAL(valueChanged(int)), this, SLOT(toDisplaySimulation()));
00328 
00329   //To Connect preview check box
00330   connectPreviewControl();
00331 
00332   /***************************************************************/
00333   
00334   ConstructorsClicked(0);
00335   ClickOnRadio();
00336   SelectionIntoArgument();
00337 }
00338 
00339 //=================================================================================
00340 // function : ~SMESHGUI_ExtrusionDlg()
00341 // purpose  : destructor
00342 //=================================================================================
00343 SMESHGUI_ExtrusionDlg::~SMESHGUI_ExtrusionDlg()
00344 {
00345   if ( myFilterDlg != 0 ) {
00346     myFilterDlg->setParent( 0 );
00347     delete myFilterDlg;
00348   }
00349 }
00350 
00351 //=================================================================================
00352 // function : Init()
00353 // purpose  : initialization
00354 //=================================================================================
00355 void SMESHGUI_ExtrusionDlg::Init (bool ResetControls)
00356 {
00357   myBusy = false;
00358   myIDs.clear();
00359 
00360   LineEditElements->clear();
00361   myNbOkElements = 0;
00362 
00363   myActor = 0;
00364   myMesh = SMESH::SMESH_Mesh::_nil();
00365 
00366   if (ResetControls) {
00367     SpinBox_NbSteps->setValue(1);
00368     SpinBox_VDist->setValue(10);
00369     SpinBox_Dx->SetValue(0);
00370     SpinBox_Dy->SetValue(0);
00371     SpinBox_Dz->SetValue(0);
00372     SpinBox_Vx->SetValue(0);
00373     SpinBox_Vy->SetValue(0);
00374     SpinBox_Vz->SetValue(0);
00375 
00376     CheckBoxMesh->setChecked(false);
00377     onSelectMesh(false);
00378     myPreviewCheckBox->setChecked(false);
00379     onDisplaySimulation(false);
00380   }
00381 
00382   CheckIsEnable();
00383 }
00384 
00385 //=================================================================================
00386 // function : CheckIsEnable()
00387 // purpose  : Check whether the Ok and Apply buttons should be enabled or not
00388 //=================================================================================
00389 void SMESHGUI_ExtrusionDlg::CheckIsEnable()
00390 {  
00391   bool anIsEnable = myNbOkElements > 0 && isValuesValid();
00392 
00393   buttonOk->setEnabled(anIsEnable);
00394   buttonApply->setEnabled(anIsEnable);
00395 }
00396 
00397 //=================================================================================
00398 // function : isValuesValid()
00399 // purpose  : Return true in case if values entered into dialog are valid
00400 //=================================================================================
00401 bool SMESHGUI_ExtrusionDlg::isValuesValid() {
00402   double aX, aY, aZ, aModule = 0;
00403   if ( RadioButton3->isChecked() ) {
00404     aX = SpinBox_Dx->GetValue();
00405     aY = SpinBox_Dy->GetValue();
00406     aZ = SpinBox_Dz->GetValue();
00407     aModule = sqrt(aX*aX + aY*aY + aZ*aZ);
00408   } else   if ( RadioButton4->isChecked() ) {
00409     aX = SpinBox_Vx->GetValue();
00410     aY = SpinBox_Vy->GetValue();
00411     aZ = SpinBox_Vz->GetValue();
00412     aModule = sqrt(aX*aX + aY*aY + aZ*aZ);
00413   }
00414   return aModule > 1.0E-38;
00415 }
00416 
00417 //=================================================================================
00418 // function : ConstructorsClicked()
00419 // purpose  : Radio button management
00420 //=================================================================================
00421 void SMESHGUI_ExtrusionDlg::ConstructorsClicked (int constructorId)
00422 {
00423   disconnect(mySelectionMgr, 0, this, 0);
00424 
00425   hidePreview();
00426 
00427   switch (constructorId) {
00428   case 0:
00429     {
00430       GroupArguments->setTitle(tr("EXTRUSION_1D"));
00431       if (!CheckBoxMesh->isChecked())
00432         {
00433           LineEditElements->clear();
00434           myIDs.clear();
00435           if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00436             aViewWindow->SetSelectionMode(EdgeSelection);
00437         }
00438       break;
00439     }
00440   case 1:
00441     {
00442       GroupArguments->setTitle(tr("EXTRUSION_2D"));
00443       if (!CheckBoxMesh->isChecked())
00444         {
00445           LineEditElements->clear();
00446           myIDs.clear();
00447           if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00448             aViewWindow->SetSelectionMode(FaceSelection);
00449         }
00450       break;
00451     }
00452   }
00453 
00454   myEditCurrentArgument = (QWidget*)LineEditElements;
00455   LineEditElements->setFocus();
00456 
00457   if (CheckBoxMesh->isChecked())
00458     onSelectMesh(true);
00459 
00460   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
00461 }
00462 
00463 //=================================================================================
00464 // function : ConstructorsClicked()
00465 // purpose  : Radio button management
00466 //=================================================================================
00467 void SMESHGUI_ExtrusionDlg::ClickOnRadio()
00468 {
00469   if ( RadioButton3->isChecked() ) {
00470     TextLabelDistance->show();
00471     TextLabelDx->show();
00472     SpinBox_Dx->show();
00473     TextLabelDy->show();
00474     SpinBox_Dy->show();
00475     TextLabelDz->show();
00476     SpinBox_Dz->show();
00477 
00478     TextLabelVector->hide();
00479     TextLabelVx->hide();
00480     SpinBox_Vx->hide();
00481     TextLabelVy->hide();
00482     SpinBox_Vy->hide();
00483     TextLabelVz->hide();
00484     SpinBox_Vz->hide();
00485     TextLabelDist->hide();
00486     SpinBox_VDist->hide();
00487     SelectVectorButton->hide();
00488   } else if ( RadioButton4->isChecked() ) {
00489     TextLabelDistance->hide();
00490     TextLabelDx->hide();
00491     SpinBox_Dx->hide();
00492     TextLabelDy->hide();
00493     SpinBox_Dy->hide();
00494     TextLabelDz->hide();
00495     SpinBox_Dz->hide();
00496 
00497     TextLabelVector->show();
00498     TextLabelVx->show();
00499     SpinBox_Vx->show();
00500     TextLabelVy->show();
00501     SpinBox_Vy->show();
00502     TextLabelVz->show();
00503     SpinBox_Vz->show();
00504     TextLabelDist->show();
00505     SpinBox_VDist->show();
00506     SelectVectorButton->show();
00507   }
00508   onDisplaySimulation(true);
00509   // AdjustSize
00510   qApp->processEvents();
00511   updateGeometry();
00512   resize( minimumSizeHint() );
00513 }
00514 
00515 //=================================================================================
00516 // function : ClickOnApply()
00517 // purpose  : Called when user presses <Apply> button
00518 //=================================================================================
00519 bool SMESHGUI_ExtrusionDlg::ClickOnApply()
00520 {
00521   if (mySMESHGUI->isActiveStudyLocked())
00522     return false;
00523 
00524   if (!isValid())
00525     return false;
00526 
00527   if (myNbOkElements) {
00528 
00529     SMESH::DirStruct aVector;
00530     getExtrusionVector(aVector);
00531     
00532     QStringList aParameters;
00533     if ( RadioButton3->isChecked() ) {
00534       aParameters << SpinBox_Dx->text();
00535       aParameters << SpinBox_Dy->text();
00536       aParameters << SpinBox_Dz->text();
00537     } else if ( RadioButton4->isChecked() ) {
00538       aParameters << SpinBox_Vx->text();
00539       aParameters << SpinBox_Vy->text();
00540       aParameters << SpinBox_Vz->text();
00541       aParameters << SpinBox_VDist->text();
00542     }
00543 
00544     long aNbSteps = (long)SpinBox_NbSteps->value();
00545 
00546     aParameters << SpinBox_NbSteps->text();
00547 
00548     try {
00549       SUIT_OverrideCursor aWaitCursor;
00550       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
00551 
00552       if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
00553         if( CheckBoxMesh->isChecked() ) {
00554           if( GetConstructorId() == 0 )
00555             SMESH::ListOfGroups_var groups = 
00556               aMeshEditor->ExtrusionSweepObject1DMakeGroups(mySelectedObject, aVector, aNbSteps);
00557           else
00558             SMESH::ListOfGroups_var groups = 
00559               aMeshEditor->ExtrusionSweepObject2DMakeGroups(mySelectedObject, aVector, aNbSteps);
00560         }
00561         else
00562           SMESH::ListOfGroups_var groups = 
00563             aMeshEditor->ExtrusionSweepMakeGroups(myElementsId.inout(), aVector, aNbSteps);
00564       }
00565       else {
00566         if( CheckBoxMesh->isChecked() ) {
00567           if( GetConstructorId() == 0 )
00568             aMeshEditor->ExtrusionSweepObject1D(mySelectedObject, aVector, aNbSteps);
00569           else
00570             aMeshEditor->ExtrusionSweepObject2D(mySelectedObject, aVector, aNbSteps);
00571         }
00572         else
00573           aMeshEditor->ExtrusionSweep(myElementsId.inout(), aVector, aNbSteps);
00574       }
00575 
00576       myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
00577 
00578     } catch (...) {
00579     }
00580 
00581     SMESH::Update(myIO, SMESH::eDisplay);
00582     if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
00583       mySMESHGUI->updateObjBrowser(true); // new groups may appear
00584     Init(false);
00585     ConstructorsClicked(GetConstructorId());
00586     mySelectionMgr->clearSelected();
00587     mySelectedObject = SMESH::SMESH_IDSource::_nil();
00588     SelectionIntoArgument();
00589 
00590     SMESHGUI::Modified();
00591   }
00592   return true;
00593 }
00594 
00595 //=================================================================================
00596 // function : ClickOnOk()
00597 // purpose  : Called when user presses <OK> button
00598 //=================================================================================
00599 void SMESHGUI_ExtrusionDlg::ClickOnOk()
00600 {
00601   if (ClickOnApply())
00602     ClickOnCancel();
00603 }
00604 
00605 //=================================================================================
00606 // function : ClickOnCancel()
00607 // purpose  : Called when dialog box is closed
00608 //=================================================================================
00609 void SMESHGUI_ExtrusionDlg::ClickOnCancel()
00610 {
00611   reject();
00612 }
00613 
00614 //=================================================================================
00615 // function : ClickOnHelp()
00616 // purpose  :
00617 //=================================================================================
00618 void SMESHGUI_ExtrusionDlg::ClickOnHelp()
00619 {
00620   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
00621   if (app) 
00622     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
00623   else {
00624     QString platform;
00625 #ifdef WIN32
00626     platform = "winapplication";
00627 #else
00628     platform = "application";
00629 #endif
00630     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
00631                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
00632                              arg(app->resourceMgr()->stringValue("ExternalBrowser", 
00633                                                                  platform)).
00634                              arg(myHelpFileName));
00635   }
00636 }
00637 
00638 //=================================================================================
00639 // function : onTextChange()
00640 // purpose  :
00641 //=================================================================================
00642 void SMESHGUI_ExtrusionDlg::onTextChange (const QString& theNewText)
00643 {
00644   QLineEdit* send = (QLineEdit*)sender();
00645 
00646   // return if busy
00647   if (myBusy) return;
00648 
00649   // set busy flag
00650   myBusy = true;
00651 
00652   if (send == LineEditElements)
00653     myNbOkElements = 0;
00654 
00655   // hilight entered elements/nodes
00656 
00657   if (!myIO.IsNull()) {
00658     QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
00659 
00660     if (send == LineEditElements)
00661     {
00662       SMDS_Mesh* aMesh = myActor ? myActor->GetObject()->GetMesh() : 0;
00663       SMESH::ElementType SMESHType = GetConstructorId() ? SMESH::FACE : SMESH::EDGE;
00664       SMDSAbs_ElementType SMDSType = GetConstructorId() ? SMDSAbs_Face: SMDSAbs_Edge;
00665 
00666       myElementsId = new SMESH::long_array;
00667       myElementsId->length( aListId.count() );
00668       TColStd_MapOfInteger newIndices;
00669       for (int i = 0; i < aListId.count(); i++) {
00670         int id = aListId[ i ].toInt();
00671         bool validId = false;
00672         if ( id > 0 ) {
00673           if ( aMesh ) {
00674             const SMDS_MeshElement * e = aMesh->FindElement( id );
00675             validId = ( e && e->GetType() == SMDSType );
00676           } else {
00677             validId = ( myMesh->GetElementType( id, true ) == SMESHType );
00678           }
00679         }
00680         if ( validId && newIndices.Add( id ))
00681           myElementsId[ newIndices.Extent()-1 ] = id;
00682       }
00683       myElementsId->length( myNbOkElements = newIndices.Extent() );
00684       mySelector->AddOrRemoveIndex(myIO, newIndices, false);
00685       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00686         aViewWindow->highlight( myIO, true, true );
00687     }
00688   }
00689 
00690   CheckIsEnable();
00691 
00692   onDisplaySimulation(true);
00693 
00694   myBusy = false;
00695 }
00696 
00697 //=================================================================================
00698 // function : SelectionIntoArgument()
00699 // purpose  : Called when selection as changed or other case
00700 //=================================================================================
00701 void SMESHGUI_ExtrusionDlg::SelectionIntoArgument()
00702 {
00703   if (myBusy) return;
00704 
00705   // return if dialog box is inactive
00706   if (!GroupButtons->isEnabled())
00707     return;
00708 
00709   // clear
00710   if(myEditCurrentArgument != (QWidget*)SpinBox_Vx) {
00711     myActor = 0;
00712     Handle(SALOME_InteractiveObject) resIO = myIO;
00713     myIO.Nullify();
00714   }
00715 
00716   QString aString = "";
00717   // set busy flag
00718   if(myEditCurrentArgument == (QWidget*)LineEditElements) {
00719     myBusy = true;
00720     LineEditElements->setText(aString);
00721     myNbOkElements = 0;
00722     myBusy = false;
00723   }
00724   // get selected mesh
00725   SALOME_ListIO aList;
00726   mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
00727   int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
00728   if (nbSel != 1)
00729     return;
00730 
00731   Handle(SALOME_InteractiveObject) IO = aList.First();
00732 
00733   if(myEditCurrentArgument != (QWidget*)SpinBox_Vx) {
00734     myMesh = SMESH::GetMeshByIO(IO);
00735     if (myMesh->_is_nil())
00736       return;
00737     myIO = IO;
00738     myActor = SMESH::FindActorByObject(myMesh);
00739   }
00740 
00741   if (myEditCurrentArgument == (QWidget*)LineEditElements) {    
00742     int aNbElements = 0;
00743 
00744     // MakeGroups is available if there are groups
00745     if ( myMesh->NbGroups() == 0 ) {
00746       MakeGroupsCheck->setChecked(false);
00747       MakeGroupsCheck->setEnabled(false);
00748     } else {
00749       MakeGroupsCheck->setEnabled(true);
00750     }
00751 
00752     if (CheckBoxMesh->isChecked()) {
00753       SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
00754 
00755       if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
00756         mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
00757       else
00758         return;
00759     } else {
00760       // get indices of selcted elements
00761       TColStd_IndexedMapOfInteger aMapIndex;
00762       mySelector->GetIndex(IO,aMapIndex);
00763       aNbElements = aMapIndex.Extent();
00764 
00765       if (aNbElements < 1)
00766         return;
00767 
00768       myElementsId = new SMESH::long_array;
00769       myElementsId->length( aNbElements );
00770       aString = "";
00771       for ( int i = 0; i < aNbElements; ++i )
00772         aString += QString(" %1").arg( myElementsId[ i ] = aMapIndex( i+1 ) );
00773     }
00774 
00775     myNbOkElements = true;
00776 
00777     myBusy = true;
00778     ((QLineEdit*)myEditCurrentArgument)->setText(aString);
00779     myBusy = false;
00780   }
00781   else if(myEditCurrentArgument == (QWidget*)SpinBox_Vx){
00782     TColStd_IndexedMapOfInteger aMapIndex;
00783     mySelector->GetIndex(IO,aMapIndex);
00784     int aNbElements = aMapIndex.Extent();
00785     SMESH::SMESH_Mesh_var aMesh_var = SMESH::GetMeshByIO(IO);
00786     SMESH_Actor* anActor = SMESH::FindActorByObject(aMesh_var);
00787     SMDS_Mesh* aMesh =  anActor ? anActor->GetObject()->GetMesh() : 0;
00788 
00789     if(aNbElements != 1 || !aMesh)
00790       return;
00791     
00792     const SMDS_MeshFace* face = dynamic_cast<const SMDS_MeshFace*>(aMesh->FindElement(aMapIndex(aNbElements)));
00793 
00794     if (!face)
00795       return;
00796 
00797     gp_XYZ aNormale = SMESH::getNormale(face);
00798     SpinBox_Vx->SetValue(aNormale.X());
00799     SpinBox_Vy->SetValue(aNormale.Y());
00800     SpinBox_Vz->SetValue(aNormale.Z());
00801     
00802   }
00803   
00804   onDisplaySimulation(true);
00805   
00806   // OK
00807   CheckIsEnable();
00808 }
00809 
00810 //=================================================================================
00811 // function : SetEditCurrentArgument()
00812 // purpose  :
00813 //=================================================================================
00814 void SMESHGUI_ExtrusionDlg::SetEditCurrentArgument()
00815 {
00816   QPushButton* send = (QPushButton*)sender();
00817 
00818   disconnect(mySelectionMgr, 0, this, 0);
00819   mySelectionMgr->clearSelected();
00820   mySelectionMgr->clearFilters();
00821 
00822   if (send == SelectElementsButton) {
00823     myEditCurrentArgument = (QWidget*)LineEditElements;
00824     if (CheckBoxMesh->isChecked()) {
00825       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00826         aViewWindow->SetSelectionMode(ActorSelection);
00827       mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
00828     } else {
00829       int aConstructorId = GetConstructorId();
00830       if (aConstructorId == 0)
00831         {
00832           if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00833             aViewWindow->SetSelectionMode(EdgeSelection);
00834         }
00835       else if (aConstructorId == 1)
00836         {
00837           if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00838             aViewWindow->SetSelectionMode(FaceSelection);
00839         }
00840     }
00841   }
00842   else if (send == SelectVectorButton){
00843     myEditCurrentArgument = (QWidget*)SpinBox_Vx;
00844     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00845       aViewWindow->SetSelectionMode(FaceSelection);
00846   }
00847   
00848   myEditCurrentArgument->setFocus();
00849   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
00850   SelectionIntoArgument();
00851 }
00852 
00853 //=================================================================================
00854 // function : DeactivateActiveDialog()
00855 // purpose  : Deactivates this dialog
00856 //=================================================================================
00857 void SMESHGUI_ExtrusionDlg::DeactivateActiveDialog()
00858 {
00859   if (ConstructorsBox->isEnabled()) {
00860     ConstructorsBox->setEnabled(false);
00861     GroupArguments->setEnabled(false);
00862     GroupButtons->setEnabled(false);
00863     mySMESHGUI->ResetState();
00864     mySMESHGUI->SetActiveDialogBox(0);
00865   }
00866 }
00867 
00868 //=================================================================================
00869 // function : ActivateThisDialog()
00870 // purpose  : Activates this dialog
00871 //=================================================================================
00872 void SMESHGUI_ExtrusionDlg::ActivateThisDialog()
00873 {
00874   // Emit a signal to deactivate the active dialog
00875   mySMESHGUI->EmitSignalDeactivateDialog();
00876   ConstructorsBox->setEnabled(true);
00877   GroupArguments->setEnabled(true);
00878   GroupButtons->setEnabled(true);
00879 
00880   mySMESHGUI->SetActiveDialogBox(this);
00881 
00882   ConstructorsClicked(GetConstructorId());
00883   SelectionIntoArgument();
00884 }
00885 
00886 //=================================================================================
00887 // function : enterEvent()
00888 // purpose  : Mouse enter event
00889 //=================================================================================
00890 void SMESHGUI_ExtrusionDlg::enterEvent (QEvent*)
00891 {
00892   if (!ConstructorsBox->isEnabled())
00893     ActivateThisDialog();
00894 }
00895 
00896 //=================================================================================
00897 // function : closeEvent()
00898 // purpose  :
00899 //=================================================================================
00900 void SMESHGUI_ExtrusionDlg::closeEvent( QCloseEvent* )
00901 {
00902   /* same than click on cancel button */
00903   disconnect(mySelectionMgr, 0, this, 0);
00904   mySelectionMgr->clearFilters();
00905   //mySelectionMgr->clearSelected();
00906   if (SMESH::GetCurrentVtkView()) {
00907     SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
00908     SMESH::SetPointRepresentation(false);
00909     SMESH::SetPickable();
00910   }
00911   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00912     aViewWindow->SetSelectionMode(ActorSelection);
00913   mySMESHGUI->ResetState();
00914 }
00915 
00916 void SMESHGUI_ExtrusionDlg::reject()
00917 {
00918   QDialog::reject();
00919   close();
00920 }
00921 
00922 //=================================================================================
00923 // function : onSelectMesh()
00924 // purpose  :
00925 //=================================================================================
00926 void SMESHGUI_ExtrusionDlg::onSelectMesh (bool toSelectMesh)
00927 {
00928   if (toSelectMesh) {
00929     myIDs = LineEditElements->text();
00930     TextLabelElements->setText(tr("SMESH_NAME"));
00931   }
00932   else
00933     TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
00934 
00935   myFilterBtn->setEnabled(!toSelectMesh);
00936 
00937   if (myEditCurrentArgument != LineEditElements) {
00938     LineEditElements->clear();
00939     return;
00940   }
00941 
00942   mySelectionMgr->clearFilters();
00943 
00944   if (toSelectMesh) {
00945     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00946       aViewWindow->SetSelectionMode(ActorSelection);
00947     mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
00948     LineEditElements->setReadOnly(true);
00949     LineEditElements->setValidator(0);
00950   } else {
00951     int aConstructorId = GetConstructorId();
00952     if (aConstructorId == 0)
00953       {
00954         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00955           aViewWindow->SetSelectionMode(EdgeSelection);
00956       }
00957     else if (aConstructorId == 1)
00958       {
00959         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00960           aViewWindow->SetSelectionMode(FaceSelection);
00961       }
00962 
00963     LineEditElements->setReadOnly(false);
00964     LineEditElements->setValidator(myIdValidator);
00965     onTextChange(LineEditElements->text());
00966   }
00967 
00968   SelectionIntoArgument();
00969 
00970   if (!toSelectMesh)
00971     LineEditElements->setText( myIDs );
00972 }
00973 
00974 //=================================================================================
00975 // function : GetConstructorId()
00976 // purpose  :
00977 //=================================================================================
00978 int SMESHGUI_ExtrusionDlg::GetConstructorId()
00979 {
00980   return GroupConstructors->checkedId();
00981 }
00982 
00983 //=================================================================================
00984 // function : keyPressEvent()
00985 // purpose  :
00986 //=================================================================================
00987 void SMESHGUI_ExtrusionDlg::keyPressEvent( QKeyEvent* e )
00988 {
00989   QDialog::keyPressEvent( e );
00990   if ( e->isAccepted() )
00991     return;
00992 
00993   if ( e->key() == Qt::Key_F1 ) {
00994     e->accept();
00995     ClickOnHelp();
00996   }
00997 }
00998 
00999 //=================================================================================
01000 // function : setFilters()
01001 // purpose  : SLOT. Called when "Filter" button pressed.
01002 //=================================================================================
01003 void SMESHGUI_ExtrusionDlg::setFilters()
01004 {
01005   if(myMesh->_is_nil()) {
01006     SUIT_MessageBox::critical(this,
01007                               tr("SMESH_ERROR"),
01008                               tr("NO_MESH_SELECTED"));
01009    return;
01010   }
01011   if ( !myFilterDlg )
01012   {
01013     QList<int> types;  
01014     types.append( SMESH::EDGE );
01015     types.append( SMESH::FACE );
01016     myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
01017   }
01018   myFilterDlg->Init( GetConstructorId() ? SMESH::FACE : SMESH::EDGE );
01019 
01020   myFilterDlg->SetSelection();
01021   myFilterDlg->SetMesh( myMesh );
01022   myFilterDlg->SetSourceWg( LineEditElements );
01023 
01024   myFilterDlg->show();
01025 }
01026 
01027 //=================================================================================
01028 // function : isValid
01029 // purpose  :
01030 //=================================================================================
01031 bool SMESHGUI_ExtrusionDlg::isValid()
01032 {
01033   QString msg;
01034   bool ok = true;
01035   if ( RadioButton3->isChecked() ) {
01036     ok = SpinBox_Dx->isValid( msg, true ) && ok;
01037     ok = SpinBox_Dy->isValid( msg, true ) && ok;
01038     ok = SpinBox_Dz->isValid( msg, true ) && ok;
01039   } else if ( RadioButton4->isChecked() ) {
01040     ok = SpinBox_Vx->isValid( msg, true ) && ok;
01041     ok = SpinBox_Vy->isValid( msg, true ) && ok;
01042     ok = SpinBox_Vz->isValid( msg, true ) && ok;
01043     ok = SpinBox_VDist->isValid( msg, true ) && ok;
01044   }
01045   ok = SpinBox_NbSteps->isValid( msg, true ) && ok;
01046 
01047   if( !ok ) {
01048     QString str( tr( "SMESH_INCORRECT_INPUT" ) );
01049     if ( !msg.isEmpty() )
01050       str += "\n" + msg;
01051     SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
01052     return false;
01053   }
01054   return true;
01055 }
01056 
01057 //=================================================================================
01058 // function : onDisplaySimulation
01059 // purpose  : Show/Hide preview
01060 //=================================================================================
01061 void SMESHGUI_ExtrusionDlg::onDisplaySimulation( bool toDisplayPreview ) {
01062   if (myPreviewCheckBox->isChecked() && toDisplayPreview) {
01063     if (myNbOkElements && isValid() && isValuesValid()) {
01064       //Get input vector
01065       SMESH::DirStruct aVector;
01066       getExtrusionVector(aVector);
01067 
01068       //Get Number of the steps 
01069       long aNbSteps = (long)SpinBox_NbSteps->value();
01070       
01071       try {
01072         SUIT_OverrideCursor aWaitCursor;
01073         SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
01074         if( CheckBoxMesh->isChecked() ) {
01075           if( GetConstructorId() == 0 )
01076             aMeshEditor->ExtrusionSweepObject1D(mySelectedObject, aVector, aNbSteps);
01077           else
01078             aMeshEditor->ExtrusionSweepObject2D(mySelectedObject, aVector, aNbSteps);
01079         }
01080         else
01081           aMeshEditor->ExtrusionSweep(myElementsId.inout(), aVector, aNbSteps);
01082         
01083         SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
01084         mySimulation->SetData(aMeshPreviewStruct._retn());
01085       } catch (...) {
01086         hidePreview();
01087       }
01088     } else {
01089       hidePreview();
01090     }
01091   } else {
01092     hidePreview();
01093   }
01094 }
01095 
01096 //=================================================================================
01097 // function : getExtrusionVector()
01098 // purpose  : get direction of the extrusion
01099 //=================================================================================
01100 void SMESHGUI_ExtrusionDlg::getExtrusionVector(SMESH::DirStruct& aVector) {
01101   if ( RadioButton3->isChecked() ) {
01102     aVector.PS.x = SpinBox_Dx->GetValue();
01103     aVector.PS.y = SpinBox_Dy->GetValue();
01104     aVector.PS.z = SpinBox_Dz->GetValue();      
01105   } else if ( RadioButton4->isChecked() ) {
01106     gp_XYZ aNormale(SpinBox_Vx->GetValue(),
01107                     SpinBox_Vy->GetValue(),
01108                     SpinBox_Vz->GetValue());
01109     
01110     
01111     aNormale /= aNormale.Modulus();
01112     long aVDist = (long)SpinBox_VDist->value();
01113     
01114     aVector.PS.x = aNormale.X()*aVDist;
01115     aVector.PS.y = aNormale.Y()*aVDist;
01116     aVector.PS.z = aNormale.Z()*aVDist;
01117   }
01118 }
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS