Version: 6.3.1

src/SMESHGUI/SMESHGUI_RevolutionDlg.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_RevolutionDlg.cxx
00025 // Author : Michael ZORIN, Open CASCADE S.A.S.
00026 // SMESH includes
00027 //
00028 #include "SMESHGUI_RevolutionDlg.h"
00029 
00030 #include "SMESHGUI.h"
00031 #include "SMESHGUI_SpinBox.h"
00032 #include "SMESHGUI_Utils.h"
00033 #include "SMESHGUI_VTKUtils.h"
00034 #include "SMESHGUI_MeshUtils.h"
00035 #include "SMESHGUI_IdValidator.h"
00036 #include "SMESHGUI_MeshEditPreview.h"
00037 #include "SMESHGUI_FilterDlg.h"
00038 
00039 #include <SMESH_Actor.h>
00040 #include <SMESH_TypeFilter.hxx>
00041 #include <SMESH_LogicalFilter.hxx>
00042 #include <SMDS_Mesh.hxx>
00043 
00044 // SALOME GUI includes
00045 #include <SUIT_ResourceMgr.h>
00046 #include <SUIT_Session.h>
00047 #include <SUIT_MessageBox.h>
00048 #include <SUIT_Desktop.h>
00049 #include <SUIT_OverrideCursor.h>
00050 
00051 #include <LightApp_Application.h>
00052 #include <LightApp_SelectionMgr.h>
00053 #include <SalomeApp_Application.h>
00054 #include <SalomeApp_IntSpinBox.h>
00055 
00056 #include <SVTK_ViewWindow.h>
00057 #include <SVTK_Selector.h>
00058 #include <SALOME_ListIO.hxx>
00059 #include <VTKViewer_CellLocationsArray.h>
00060 
00061 // OCCT includes
00062 #include <TColStd_MapOfInteger.hxx>
00063 
00064 // Qt includes
00065 #include <QApplication>
00066 #include <QButtonGroup>
00067 #include <QGroupBox>
00068 #include <QLabel>
00069 #include <QLineEdit>
00070 #include <QPushButton>
00071 #include <QRadioButton>
00072 #include <QCheckBox>
00073 #include <QHBoxLayout>
00074 #include <QVBoxLayout>
00075 #include <QGridLayout>
00076 #include <QKeyEvent>
00077 #include <QMenu>
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 // class    : SMESHGUI_RevolutionDlg()
00089 // purpose  :
00090 //=================================================================================
00091 SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
00092   : SMESHGUI_PreviewDlg( theModule ),
00093     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
00094     myVectorDefinition(NONE_SELECT),
00095     myFilterDlg( 0 ),
00096     mySelectedObject(SMESH::SMESH_IDSource::_nil()),
00097     myActor(0)
00098 {
00099   mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
00100 
00101   SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
00102   QPixmap image0 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
00103   QPixmap image1 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
00104   QPixmap image2 ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
00105 
00106   setModal(false);
00107   setAttribute(Qt::WA_DeleteOnClose, true);
00108   setWindowTitle(tr("REVOLUTION_AROUND_AXIS"));
00109   setSizeGripEnabled(true);
00110   
00111   QVBoxLayout* SMESHGUI_RevolutionDlgLayout = new QVBoxLayout(this);
00112   SMESHGUI_RevolutionDlgLayout->setSpacing(SPACING);
00113   SMESHGUI_RevolutionDlgLayout->setMargin(MARGIN);
00114 
00115   /***************************************************************/
00116   ConstructorsBox = new QGroupBox(tr("SMESH_REVOLUTION"), this);
00117   GroupConstructors = new QButtonGroup(this);
00118   QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
00119   ConstructorsBoxLayout->setSpacing(SPACING);
00120   ConstructorsBoxLayout->setMargin(MARGIN);
00121 
00122   RadioButton1 = new QRadioButton(ConstructorsBox);
00123   RadioButton1->setIcon(image0);
00124   RadioButton2 = new QRadioButton(ConstructorsBox);
00125   RadioButton2->setIcon(image1);
00126 
00127   ConstructorsBoxLayout->addWidget(RadioButton1);
00128   ConstructorsBoxLayout->addWidget(RadioButton2);
00129   GroupConstructors->addButton(RadioButton1, 0);
00130   GroupConstructors->addButton(RadioButton2, 1);
00131 
00132   /***************************************************************/
00133   GroupArguments = new QGroupBox(tr("REVOLUTION_1D"), this);
00134   QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
00135   GroupArgumentsLayout->setSpacing(SPACING);
00136   GroupArgumentsLayout->setMargin(MARGIN);
00137 
00138   myIdValidator = new SMESHGUI_IdValidator(this);
00139 
00140   // Controls for elements selection
00141   TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
00142 
00143   SelectElementsButton = new QPushButton(GroupArguments);
00144   SelectElementsButton->setIcon(image2);
00145 
00146   LineEditElements  = new QLineEdit(GroupArguments);
00147   LineEditElements->setValidator(myIdValidator);
00148   LineEditElements->setMaxLength(-1);
00149   myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
00150   connect(myFilterBtn,   SIGNAL(clicked()), this, SLOT(setFilters()));
00151 
00152   // Control for the whole mesh selection
00153   CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
00154 
00155   // Controls for axis defining
00156   GroupAxis = new QGroupBox(tr("SMESH_AXIS"), GroupArguments);
00157   QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis);
00158   GroupAxisLayout->setSpacing(SPACING);
00159   GroupAxisLayout->setMargin(MARGIN);
00160 
00161   TextLabelPoint = new QLabel(tr("SMESH_POINT"), GroupAxis);
00162   SelectPointButton  = new QPushButton(GroupAxis);
00163   SelectPointButton->setIcon(image2);
00164 
00165   TextLabelX = new QLabel(tr("SMESH_X"), GroupAxis);
00166   SpinBox_X = new SMESHGUI_SpinBox(GroupAxis);
00167 
00168   TextLabelY = new QLabel(tr("SMESH_Y"), GroupAxis);
00169   SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis);
00170 
00171   TextLabelZ = new QLabel(tr("SMESH_Z"), GroupAxis);
00172   SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis);
00173 
00174   TextLabelVector = new QLabel(tr("SMESH_VECTOR"), GroupAxis);
00175   SelectVectorButton = new QPushButton(GroupAxis);
00176   SelectVectorButton->setIcon(image2);
00177 
00178   TextLabelDX = new QLabel(tr("SMESH_DX"), GroupAxis);
00179   SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis);
00180 
00181   TextLabelDY = new QLabel(tr("SMESH_DY"), GroupAxis);
00182   SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis);
00183 
00184   TextLabelDZ = new QLabel(tr("SMESH_DZ"), GroupAxis);
00185   SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis);
00186 
00187   GroupAxisLayout->addWidget(TextLabelPoint,     0, 0);
00188   GroupAxisLayout->addWidget(SelectPointButton,  0, 1);
00189   GroupAxisLayout->addWidget(TextLabelX,         0, 2);
00190   GroupAxisLayout->addWidget(SpinBox_X,          0, 3);
00191   GroupAxisLayout->addWidget(TextLabelY,         0, 4);
00192   GroupAxisLayout->addWidget(SpinBox_Y,          0, 5);
00193   GroupAxisLayout->addWidget(TextLabelZ,         0, 6);
00194   GroupAxisLayout->addWidget(SpinBox_Z,          0, 7);
00195   GroupAxisLayout->addWidget(TextLabelVector,    1, 0);
00196   GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
00197   GroupAxisLayout->addWidget(TextLabelDX,        1, 2);
00198   GroupAxisLayout->addWidget(SpinBox_DX,         1, 3);
00199   GroupAxisLayout->addWidget(TextLabelDY,        1, 4);
00200   GroupAxisLayout->addWidget(SpinBox_DY,         1, 5);
00201   GroupAxisLayout->addWidget(TextLabelDZ,        1, 6);
00202   GroupAxisLayout->addWidget(SpinBox_DZ,         1, 7);
00203 
00204   // Controls for angle defining & number of steps defining
00205   GroupAngleBox = new QGroupBox(tr("SMESH_ANGLE"), GroupArguments);
00206   GroupAngle = new QButtonGroup(GroupAngleBox);
00207   QGridLayout* GroupAngleLayout = new QGridLayout(GroupAngleBox);
00208   GroupAngleLayout->setSpacing(6);
00209   GroupAngleLayout->setMargin(11);
00210 
00211   RadioButton3 = new QRadioButton(tr("ANGLE_BY_STEP"), GroupAngleBox);
00212   RadioButton4 = new QRadioButton(tr("TOTAL_ANGLE"),   GroupAngleBox);
00213   GroupAngle->addButton(RadioButton3, 0);
00214   GroupAngle->addButton(RadioButton4, 1);
00215 
00216   TextLabelAngle = new QLabel(tr("SMESH_ANGLE"), GroupAngleBox);
00217   SpinBox_Angle = new SMESHGUI_SpinBox(GroupAngleBox);
00218 
00219   TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupAngleBox);
00220   SpinBox_NbSteps = new SalomeApp_IntSpinBox(GroupAngleBox);
00221 
00222   GroupAngleLayout->addWidget(RadioButton3,     0, 0);
00223   GroupAngleLayout->addWidget(RadioButton4,     0, 1);
00224   GroupAngleLayout->addWidget(TextLabelAngle,   1, 0);
00225   GroupAngleLayout->addWidget(SpinBox_Angle,    1, 1);
00226   GroupAngleLayout->addWidget(TextLabelNbSteps, 2, 0);
00227   GroupAngleLayout->addWidget(SpinBox_NbSteps,  2, 1);
00228 
00229   // Controls for tolerance defining
00230   TextLabelTolerance = new QLabel(tr("SMESH_TOLERANCE"), GroupArguments);
00231   SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments);
00232 
00233   // Control for mesh preview
00234   myPreviewCheckBox = new QCheckBox(tr("PREVIEW"), GroupArguments);
00235 
00236   // CheckBox for groups generation
00237   MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
00238   MakeGroupsCheck->setChecked(true);
00239 
00240   GroupArgumentsLayout->addWidget(TextLabelElements,    0, 0);
00241   GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
00242   GroupArgumentsLayout->addWidget(LineEditElements,     0, 2);
00243   GroupArgumentsLayout->addWidget(myFilterBtn,          0, 3);
00244   GroupArgumentsLayout->addWidget(CheckBoxMesh,         1, 0, 1, 4);
00245   GroupArgumentsLayout->addWidget(GroupAxis,            2, 0, 1, 4);
00246   GroupArgumentsLayout->addWidget(GroupAngleBox,        3, 0, 1, 4);
00247   GroupArgumentsLayout->addWidget(TextLabelTolerance,   4, 0, 1, 2);
00248   GroupArgumentsLayout->addWidget(SpinBox_Tolerance,    4, 2, 1, 2);
00249   GroupArgumentsLayout->addWidget(myPreviewCheckBox,    5, 0, 1, 4);
00250   GroupArgumentsLayout->addWidget(MakeGroupsCheck,      6, 0, 1, 4);
00251 
00252   /***************************************************************/
00253   GroupButtons = new QGroupBox(this);
00254   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
00255   GroupButtonsLayout->setSpacing(SPACING);
00256   GroupButtonsLayout->setMargin(MARGIN);
00257   
00258   buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
00259   buttonOk->setAutoDefault(true);
00260   buttonOk->setDefault(true);
00261   buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
00262   buttonApply->setAutoDefault(true);
00263   buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
00264   buttonCancel->setAutoDefault(true);
00265   buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
00266   buttonHelp->setAutoDefault(true);
00267 
00268   GroupButtonsLayout->addWidget(buttonOk);
00269   GroupButtonsLayout->addSpacing(10);
00270   GroupButtonsLayout->addWidget(buttonApply);
00271   GroupButtonsLayout->addSpacing(10);
00272   GroupButtonsLayout->addStretch();
00273   GroupButtonsLayout->addWidget(buttonCancel);
00274   GroupButtonsLayout->addWidget(buttonHelp);
00275 
00276   /***************************************************************/
00277   SMESHGUI_RevolutionDlgLayout->addWidget(ConstructorsBox);
00278   SMESHGUI_RevolutionDlgLayout->addWidget(GroupArguments);
00279   SMESHGUI_RevolutionDlgLayout->addWidget(GroupButtons);
00280 
00281   /* Initialisations */
00282   SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
00283   SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
00284   SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
00285   SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
00286   SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
00287   SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
00288 
00289   RadioButton3->setChecked(true);
00290 
00291   SpinBox_Angle->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5.0, "angle_precision");
00292 
00293   SpinBox_NbSteps->setRange(1, 999999);
00294 
00295   SpinBox_Tolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.00001, "len_tol_precision");
00296 
00297   RadioButton1->setChecked(true);
00298 
00299   mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
00300 
00301   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
00302 
00303   // Costruction of the logical filter
00304   SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
00305   SMESH_TypeFilter* aSmeshGroupFilter    = new SMESH_TypeFilter (GROUP);
00306 
00307   QList<SUIT_SelectionFilter*> aListOfFilters;
00308   if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
00309   if (aSmeshGroupFilter)    aListOfFilters.append(aSmeshGroupFilter);
00310 
00311   myMeshOrSubMeshOrGroupFilter =
00312     new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
00313 
00314   myHelpFileName = "revolution_page.html";
00315 
00316   Init();
00317 
00318   /*Create menu to vector selection*/
00319   SelectVectorMenu = new QMenu(this);
00320   myMenuActions[SelectVectorMenu->addAction( tr( "MEN_POINT_SELECT" ) )] = POINT_SELECT;
00321   myMenuActions[SelectVectorMenu->addAction( tr( "MEN_FACE_SELECT" ) )] = FACE_SELECT;
00322   connect( SelectVectorMenu, SIGNAL( triggered( QAction* ) ), SLOT( onSelectVectorMenu( QAction* ) ) );
00323 
00324   /* signals and slots connections */
00325   connect(buttonOk,     SIGNAL(clicked()), this, SLOT(ClickOnOk()));
00326   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
00327   connect(buttonApply,  SIGNAL(clicked()), this, SLOT(ClickOnApply()));
00328   connect(buttonHelp,   SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
00329   connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
00330 
00331   connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
00332   connect(SelectPointButton,    SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
00333   connect(SelectVectorButton,   SIGNAL(clicked()), this, SLOT(onSelectVectorButton()));
00334 
00335   connect(SpinBox_X,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
00336   connect(SpinBox_Y,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
00337   connect(SpinBox_Z,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
00338 
00339   connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
00340   connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
00341   connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
00342 
00343   connect(mySMESHGUI,     SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
00344   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()),      this, SLOT(SelectionIntoArgument()));
00345   /* to close dialog if study change */
00346   connect(mySMESHGUI,       SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
00347   connect(LineEditElements, SIGNAL(textChanged(const QString&)),   SLOT(onTextChange(const QString&)));
00348   connect(CheckBoxMesh,     SIGNAL(toggled(bool)),                 SLOT(onSelectMesh(bool)));
00349 
00350   connect(GroupAngle,        SIGNAL(buttonClicked(int)),   this, SLOT(toDisplaySimulation()));
00351   connect(SpinBox_Angle,     SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
00352   connect(SpinBox_NbSteps,   SIGNAL(valueChanged(int)),    this, SLOT(toDisplaySimulation()));
00353   connect(SpinBox_Tolerance, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
00354 
00355   //To Connect preview check box
00356   connectPreviewControl();
00357 
00358   connect(SpinBox_Angle, SIGNAL(textChanged(const QString&)), this, SLOT(onAngleTextChange(const QString&)));
00359 
00360   ConstructorsClicked(0);
00361   SelectionIntoArgument();
00362 }
00363 
00364 //=================================================================================
00365 // function : ~SMESHGUI_RevolutionDlg()
00366 // purpose  : Destroys the object and frees any allocated resources
00367 //=================================================================================
00368 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
00369 {
00370   delete mySimulation;
00371   if ( myFilterDlg ) {
00372     myFilterDlg->setParent( 0 );
00373     delete myFilterDlg;
00374     myFilterDlg = 0;
00375   }
00376 }
00377 
00378 //=================================================================================
00379 // function : Init()
00380 // purpose  :
00381 //=================================================================================
00382 void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
00383 {
00384   myBusy = false;
00385 
00386   myEditCurrentArgument = 0;
00387   LineEditElements->clear();
00388   myElementsId = "";
00389   myNbOkElements = 0;
00390   myIDs.clear();
00391 
00392   myActor = 0;
00393   myMesh = SMESH::SMESH_Mesh::_nil();
00394 
00395   if (ResetControls) {
00396     SpinBox_X->SetValue(0.0);
00397     SpinBox_Y->SetValue(0.0);
00398     SpinBox_Z->SetValue(0.0);
00399     SpinBox_DX->SetValue(0.0);
00400     SpinBox_DY->SetValue(0.0);
00401     SpinBox_DZ->SetValue(0.0);
00402 
00403     SpinBox_Angle->SetValue(45);
00404     SpinBox_NbSteps->setValue(1);
00405     SpinBox_Tolerance->SetValue(1e-05);
00406 
00407     CheckBoxMesh->setChecked(false);
00408     onSelectMesh(false);
00409     myPreviewCheckBox->setChecked(false);
00410     onDisplaySimulation(false);
00411   }
00412 }
00413 
00414 //=================================================================================
00415 // function : ConstructorsClicked()
00416 // purpose  : Radio button management
00417 //=================================================================================
00418 void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
00419 {
00420   disconnect(mySelectionMgr, 0, this, 0);
00421 
00422   /*  SALOME_ListIO io;
00423   mySelectionMgr->selectedObjects( io );
00424   SALOME_ListIO aList;
00425   mySelectionMgr->setSelectedObjects( aList );*/
00426 
00427   buttonApply->setEnabled(false);
00428   buttonOk->setEnabled(false);
00429   mySimulation->SetVisibility(false);
00430 
00431   Selection_Mode aSelMode = ActorSelection;
00432 
00433   switch (constructorId) {
00434   case 0:
00435     {
00436       GroupArguments->setTitle(tr("REVOLUTION_1D"));
00437       aSelMode = EdgeSelection;
00438       break;
00439     }
00440   case 1:
00441     {
00442       GroupArguments->setTitle(tr("REVOLUTION_2D"));
00443       aSelMode = FaceSelection;
00444       break;
00445     }
00446   }
00447 
00448   if (myEditCurrentArgument != (QWidget*)LineEditElements) {
00449     SMESH::SetPointRepresentation(false);
00450   }
00451 
00452   if (!CheckBoxMesh->isChecked())
00453     {
00454       LineEditElements->clear();
00455       myIDs.clear();
00456       myNbOkElements = 0;
00457       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00458         aViewWindow->SetSelectionMode(aSelMode);
00459     }
00460 
00461   myEditCurrentArgument = (QWidget*)LineEditElements;
00462   LineEditElements->setFocus();
00463 
00464   if (CheckBoxMesh->isChecked())
00465     onSelectMesh(true);
00466 
00467   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
00468   //  mySelectionMgr->setSelectedObjects( io );
00469 }
00470 
00471 //=================================================================================
00472 // function : ClickOnApply()
00473 // purpose  :
00474 //=================================================================================
00475 bool SMESHGUI_RevolutionDlg::ClickOnApply()
00476 {
00477   if (mySMESHGUI->isActiveStudyLocked())
00478     return false;
00479 
00480   if (!isValid())
00481     return false;
00482 
00483   if (myNbOkElements && IsAxisOk()) {
00484     QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
00485 
00486     SMESH::long_array_var anElementsId = new SMESH::long_array;
00487 
00488     anElementsId->length(aListElementsId.count());
00489     for (int i = 0; i < aListElementsId.count(); i++)
00490       anElementsId[i] = aListElementsId[i].toInt();
00491 
00492     SMESH::AxisStruct anAxis;
00493 
00494     anAxis.x =  SpinBox_X->GetValue();
00495     anAxis.y =  SpinBox_Y->GetValue();
00496     anAxis.z =  SpinBox_Z->GetValue();;
00497     anAxis.vx = SpinBox_DX->GetValue();
00498     anAxis.vy = SpinBox_DY->GetValue();
00499     anAxis.vz = SpinBox_DZ->GetValue();
00500 
00501     double anAngle = (SpinBox_Angle->GetValue())*PI/180;
00502     long aNbSteps = (long)SpinBox_NbSteps->value();
00503     double aTolerance = SpinBox_Tolerance->GetValue();
00504 
00505     if ( GroupAngle->checkedId() == 1 )
00506       anAngle = anAngle/aNbSteps;
00507 
00508     QStringList aParameters;
00509     aParameters << SpinBox_X->text();
00510     aParameters << SpinBox_Y->text();
00511     aParameters << SpinBox_Z->text();
00512     aParameters << SpinBox_DX->text();
00513     aParameters << SpinBox_DY->text();
00514     aParameters << SpinBox_DZ->text();
00515     aParameters << SpinBox_Angle->text();
00516     aParameters << SpinBox_NbSteps->text();
00517     aParameters << SpinBox_Tolerance->text();
00518 
00519     try {
00520       SUIT_OverrideCursor aWaitCursor;
00521       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
00522       
00523       if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
00524         if( CheckBoxMesh->isChecked() ) {
00525           if( GetConstructorId() == 0 )
00526             SMESH::ListOfGroups_var groups = 
00527               aMeshEditor->RotationSweepObject1DMakeGroups(mySelectedObject, anAxis,
00528                                                            anAngle, aNbSteps, aTolerance);
00529           else
00530             SMESH::ListOfGroups_var groups = 
00531               aMeshEditor->RotationSweepObject2DMakeGroups(mySelectedObject, anAxis,
00532                                                            anAngle, aNbSteps, aTolerance);
00533         }
00534         else
00535           SMESH::ListOfGroups_var groups = 
00536             aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis,
00537                                                  anAngle, aNbSteps, aTolerance);
00538       }
00539       else {
00540         if( CheckBoxMesh->isChecked() ) {
00541           if( GetConstructorId() == 0 )
00542             aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
00543           else
00544             aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
00545         }
00546         else
00547           aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
00548       }
00549 
00550       myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
00551     } catch (...) {
00552     }
00553 
00554     SMESH::UpdateView();
00555     SMESH::Update(myIO, SMESH::eDisplay);
00556     if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
00557       mySMESHGUI->updateObjBrowser(true); // new groups may appear
00558     Init(false);
00559     ConstructorsClicked(GetConstructorId());
00560     mySelectedObject = SMESH::SMESH_IDSource::_nil();
00561     SelectionIntoArgument();
00562 
00563     SMESHGUI::Modified();
00564   }
00565 
00566   return true;
00567 }
00568 
00569 //=================================================================================
00570 // function : ClickOnOk()
00571 // purpose  :
00572 //=================================================================================
00573 void SMESHGUI_RevolutionDlg::ClickOnOk()
00574 {
00575   if( ClickOnApply() )
00576     ClickOnCancel();
00577 }
00578 
00579 //=================================================================================
00580 // function : ClickOnCancel()
00581 // purpose  :
00582 //=================================================================================
00583 void SMESHGUI_RevolutionDlg::ClickOnCancel()
00584 {
00585   reject();
00586 }
00587 
00588 void SMESHGUI_RevolutionDlg::reject()
00589 {
00590   close();
00591 }
00592 
00593 //=================================================================================
00594 // function : ClickOnHelp()
00595 // purpose  :
00596 //=================================================================================
00597 void SMESHGUI_RevolutionDlg::ClickOnHelp()
00598 {
00599   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
00600   if (app) 
00601     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
00602   else {
00603     QString platform;
00604 #ifdef WIN32
00605     platform = "winapplication";
00606 #else
00607     platform = "application";
00608 #endif
00609     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
00610                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
00611                              arg(app->resourceMgr()->stringValue("ExternalBrowser", 
00612                                                                  platform)).
00613                              arg(myHelpFileName));
00614   }
00615 }
00616 
00617 //=======================================================================
00618 // function : onAngleTextChange()
00619 // purpose  :
00620 //=======================================================================
00621 void SMESHGUI_RevolutionDlg::onAngleTextChange (const QString& theNewText)
00622 {
00623   bool isNumber;
00624   SpinBox_Angle->text().toDouble( &isNumber );
00625   if( !isNumber )
00626     RadioButton3->setChecked( true );
00627   RadioButton4->setEnabled( isNumber );
00628 }
00629 
00630 //=======================================================================
00631 // function : onTextChange()
00632 // purpose  :
00633 //=======================================================================
00634 void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
00635 {
00636   QLineEdit* send = (QLineEdit*)sender();
00637 
00638   if (myBusy) return;
00639   myBusy = true;
00640 
00641   if (send == LineEditElements)
00642     myNbOkElements = 0;
00643 
00644   buttonOk->setEnabled(false);
00645   buttonApply->setEnabled(false);
00646 
00647   // hilight entered elements
00648   SMDS_Mesh* aMesh = 0;
00649   if (myActor)
00650     aMesh = myActor->GetObject()->GetMesh();
00651 
00652   if (aMesh) {
00653     if (send == LineEditElements) {
00654       Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
00655 
00656       TColStd_MapOfInteger newIndices;
00657 
00658       QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
00659       
00660       for (int i = 0; i < aListId.count(); i++) {
00661         const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
00662         if (e)
00663           newIndices.Add(e->GetID());
00664         myNbOkElements++;
00665       }
00666 
00667       mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
00668       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00669         aViewWindow->highlight( myActor->getIO(), true, true );
00670       
00671       myElementsId = theNewText;
00672     }
00673   }
00674 
00675   if (myNbOkElements && IsAxisOk()) {
00676     buttonOk->setEnabled(true);
00677     buttonApply->setEnabled(true);
00678   }
00679   onDisplaySimulation(true);
00680 
00681   myBusy = false;
00682 }
00683 
00684 //=================================================================================
00685 // function : SelectionIntoArgument()
00686 // purpose  : Called when selection as changed or other case
00687 //=================================================================================
00688 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
00689 {
00690   if (myBusy) return;
00691 
00692   // clear
00693   QString aString = "";
00694 
00695   myBusy = true;
00696   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
00697     LineEditElements->setText(aString);
00698     myNbOkElements = 0;
00699     buttonOk->setEnabled(false);
00700     buttonApply->setEnabled(false);
00701   }
00702   myBusy = false;
00703 
00704   if (!GroupButtons->isEnabled()) // inactive
00705     return;
00706 
00707   // get selected mesh
00708   const SALOME_ListIO& aList = mySelector->StoredIObjects();
00709 
00710   int nbSel = aList.Extent();
00711   if (nbSel != 1) 
00712     return;
00713 
00714   Handle(SALOME_InteractiveObject) IO = aList.First();
00715   SMESH::SMESH_Mesh_var aMeshVar = SMESH::GetMeshByIO(IO);
00716   if (aMeshVar->_is_nil())
00717     return;
00718 
00719   SMESH_Actor* anActor = SMESH::FindActorByObject(aMeshVar);
00720   if (!anActor)
00721     anActor = SMESH::FindActorByEntry(IO->getEntry());
00722   if (!anActor && !CheckBoxMesh->isChecked())
00723     return;
00724 
00725   int aNbUnits = 0;
00726 
00727   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
00728     myElementsId = "";
00729     myMesh = aMeshVar;
00730     myActor = anActor;
00731     myIO = IO;
00732 
00733     // MakeGroups is available if there are groups
00734     if ( myMesh->NbGroups() == 0 ) {
00735       MakeGroupsCheck->setChecked(false);
00736       MakeGroupsCheck->setEnabled(false);
00737     } else {
00738       MakeGroupsCheck->setEnabled(true);
00739     }
00740 
00741     if (CheckBoxMesh->isChecked()) {
00742       SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
00743 
00744       if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
00745         mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
00746       else
00747         return;
00748     } else {
00749       aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
00750       myElementsId = aString;
00751       if (aNbUnits < 1)
00752         return;
00753     }
00754     myNbOkElements = true;
00755   } else {
00756 
00757     SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
00758     if (!aMesh)
00759       return;
00760 
00761     bool isNodeSelected = (myEditCurrentArgument == (QWidget*)SpinBox_X ||
00762                            (myEditCurrentArgument == (QWidget*)SpinBox_DX && 
00763                             myVectorDefinition==POINT_SELECT));
00764 
00765     bool isFaceSelected = (myEditCurrentArgument == (QWidget*)SpinBox_DX && 
00766                            myVectorDefinition==FACE_SELECT);
00767 
00768     if(isNodeSelected) {
00769       aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
00770     }
00771     else if(isFaceSelected){
00772       aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
00773     }
00774     
00775     if (aNbUnits != 1)
00776       return;
00777 
00778     if(isNodeSelected) {
00779       const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
00780       if (!n)
00781         return;
00782 
00783       double x = n->X();
00784       double y = n->Y();
00785       double z = n->Z();
00786 
00787       if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
00788         SpinBox_X->SetValue(x);
00789         SpinBox_Y->SetValue(y);
00790         SpinBox_Z->SetValue(z);
00791       } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
00792         SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
00793         SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
00794         SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
00795       }
00796     }
00797     else if(isFaceSelected){
00798       const SMDS_MeshFace* face = dynamic_cast<const SMDS_MeshFace*>(aMesh->FindElement(aString.toInt()));
00799       if (!face)
00800         return;
00801       
00802       gp_XYZ aNormale = SMESH::getNormale(face);
00803       SpinBox_DX->SetValue(aNormale.X());
00804       SpinBox_DY->SetValue(aNormale.Y());
00805       SpinBox_DZ->SetValue(aNormale.Z());
00806       
00807     }
00808   }
00809 
00810   myBusy = true;
00811   if (myEditCurrentArgument == (QWidget*)LineEditElements)
00812     LineEditElements->setText(aString);
00813   myBusy = false;
00814 
00815   // OK
00816   if (myNbOkElements && IsAxisOk()) {
00817     buttonOk->setEnabled(true);
00818     buttonApply->setEnabled(true);
00819   }
00820 
00821   onDisplaySimulation(true);
00822 }
00823 
00824 //=================================================================================
00825 // function : SetEditCurrentArgument()
00826 // purpose  :
00827 //=================================================================================
00828 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
00829 {
00830   QPushButton* send = (QPushButton*)sender();
00831 
00832   disconnect(mySelectionMgr, 0, this, 0);
00833   mySelectionMgr->clearSelected();
00834   mySelectionMgr->clearFilters();
00835 
00836   if (send == SelectElementsButton) {
00837     mySimulation->SetVisibility(false);
00838     myEditCurrentArgument = (QWidget*)LineEditElements;
00839     SMESH::SetPointRepresentation(false);
00840     if (CheckBoxMesh->isChecked()) {
00841       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00842         aViewWindow->SetSelectionMode(ActorSelection);
00843       mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
00844     } else {
00845       int aConstructorId = GetConstructorId();
00846       if (aConstructorId == 0)
00847         {
00848           if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00849             aViewWindow->SetSelectionMode(EdgeSelection);
00850         }
00851       else if (aConstructorId == 1)
00852         {
00853           if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00854             aViewWindow->SetSelectionMode(FaceSelection);
00855         }
00856     }
00857   } else if (send == SelectPointButton) {
00858     myEditCurrentArgument = (QWidget*)SpinBox_X;
00859     SMESH::SetPointRepresentation(true);
00860     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00861       aViewWindow->SetSelectionMode(NodeSelection);
00862   }
00863 
00864   myEditCurrentArgument->setFocus();
00865   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
00866   SelectionIntoArgument();
00867 }
00868 
00869 //=================================================================================
00870 // function : DeactivateActiveDialog()
00871 // purpose  :
00872 //=================================================================================
00873 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
00874 {
00875   if (ConstructorsBox->isEnabled()) {
00876     ConstructorsBox->setEnabled(false);
00877     GroupArguments->setEnabled(false);
00878     GroupButtons->setEnabled(false);
00879     mySMESHGUI->ResetState();
00880     mySMESHGUI->SetActiveDialogBox(0);
00881   }
00882 }
00883 
00884 //=================================================================================
00885 // function : ActivateThisDialog()
00886 // purpose  :
00887 //=================================================================================
00888 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
00889 {
00890   /* Emit a signal to deactivate the active dialog */
00891   mySMESHGUI->EmitSignalDeactivateDialog();
00892   ConstructorsBox->setEnabled(true);
00893   GroupArguments->setEnabled(true);
00894   GroupButtons->setEnabled(true);
00895 
00896   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
00897 
00898   ConstructorsClicked(GetConstructorId());
00899   SelectionIntoArgument();
00900 }
00901 
00902 //=================================================================================
00903 // function : enterEvent()
00904 // purpose  :
00905 //=================================================================================
00906 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
00907 {
00908   if (!ConstructorsBox->isEnabled())
00909     ActivateThisDialog();
00910 }
00911 
00912 //=================================================================================
00913 // function : closeEvent()
00914 // purpose  :
00915 //=================================================================================
00916 void SMESHGUI_RevolutionDlg::closeEvent (QCloseEvent*)
00917 {
00918   /* same than click on cancel button */
00919   disconnect(mySelectionMgr, 0, this, 0);
00920   mySelectionMgr->clearFilters();
00921   //mySelectionMgr->clearSelected();
00922   if (SMESH::GetCurrentVtkView()) {
00923     SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
00924     SMESH::SetPointRepresentation(false);
00925   }
00926   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00927     aViewWindow->SetSelectionMode(ActorSelection);
00928   mySMESHGUI->ResetState();
00929 }
00930 
00931 //=======================================================================
00932 //function : onSelectMesh
00933 //purpose  :
00934 //=======================================================================
00935 void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
00936 {
00937   if (toSelectMesh) {
00938     myIDs = LineEditElements->text();
00939     TextLabelElements->setText(tr("SMESH_NAME"));
00940   }
00941   else
00942     TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
00943   myFilterBtn->setEnabled(!toSelectMesh);
00944 
00945   if (myEditCurrentArgument != LineEditElements) {
00946     LineEditElements->clear();
00947     mySimulation->SetVisibility(false);
00948     return;
00949   }
00950 
00951   mySelectionMgr->clearFilters();
00952   SMESH::SetPointRepresentation(false);
00953 
00954   if (toSelectMesh) {
00955     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00956       aViewWindow->SetSelectionMode(ActorSelection);
00957     mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
00958     LineEditElements->setReadOnly(true);
00959     LineEditElements->setValidator(0);
00960   } else {
00961     int aConstructorId = GetConstructorId();
00962     if (aConstructorId == 0)
00963       {
00964         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00965           aViewWindow->SetSelectionMode(EdgeSelection);
00966       }
00967     else if (aConstructorId == 1)
00968       {
00969         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00970           aViewWindow->SetSelectionMode(FaceSelection);
00971       }
00972 
00973     LineEditElements->setReadOnly(false);
00974     LineEditElements->setValidator(myIdValidator);
00975     onTextChange(LineEditElements->text());
00976     mySimulation->SetVisibility(false);
00977   }
00978 
00979   SelectionIntoArgument();
00980 
00981   if (!toSelectMesh)
00982     LineEditElements->setText( myIDs );
00983 }
00984 
00985 //=================================================================================
00986 // function : GetConstructorId()
00987 // purpose  :
00988 //=================================================================================
00989 int SMESHGUI_RevolutionDlg::GetConstructorId()
00990 {
00991   return GroupConstructors->checkedId();
00992 }
00993 
00994 //=================================================================================
00995 // function : IsAxisOk()
00996 // purpose  :
00997 //=================================================================================
00998 bool SMESHGUI_RevolutionDlg::IsAxisOk()
00999 {
01000   return (SpinBox_DX->GetValue() != 0 ||
01001           SpinBox_DY->GetValue() != 0 ||
01002           SpinBox_DZ->GetValue() != 0);
01003 }
01004 
01005 //=================================================================================
01006 // function : onVectorChanged()
01007 // purpose  :
01008 //=================================================================================
01009 void SMESHGUI_RevolutionDlg::onVectorChanged()
01010 {
01011   if (IsAxisOk()) {
01012     buttonOk->setEnabled(true);
01013     buttonApply->setEnabled(true);
01014   } else {
01015     buttonOk->setEnabled(false);
01016     buttonApply->setEnabled(false);
01017   }
01018   onDisplaySimulation(true);
01019 }
01020 
01021 //=================================================================================
01022 // function : keyPressEvent()
01023 // purpose  :
01024 //=================================================================================
01025 void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
01026 {
01027   QDialog::keyPressEvent( e );
01028   if ( e->isAccepted() )
01029     return;
01030 
01031   if ( e->key() == Qt::Key_F1 ) {
01032     e->accept();
01033     ClickOnHelp();
01034   }
01035 }
01036 
01037 //=================================================================================
01038 // function : onDisplaySimulation()
01039 // purpose  : Show/Hide preview
01040 //=================================================================================
01041 void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview)
01042 {
01043   if (myPreviewCheckBox->isChecked() && toDisplayPreview)
01044   {
01045     //display preview
01046     if (myNbOkElements && IsAxisOk())
01047     {
01048       QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
01049       
01050       SMESH::long_array_var anElementsId = new SMESH::long_array;
01051       
01052       anElementsId->length(aListElementsId.count());
01053       for (int i = 0; i < aListElementsId.count(); i++)
01054         anElementsId[i] = aListElementsId[i].toInt();
01055       
01056       SMESH::AxisStruct anAxis;
01057       
01058       anAxis.x =  SpinBox_X->GetValue();
01059       anAxis.y =  SpinBox_Y->GetValue();
01060       anAxis.z =  SpinBox_Z->GetValue();
01061       anAxis.vx = SpinBox_DX->GetValue();
01062       anAxis.vy = SpinBox_DY->GetValue();
01063       anAxis.vz = SpinBox_DZ->GetValue();
01064       
01065       double anAngle = (SpinBox_Angle->GetValue())*PI/180;
01066       long aNbSteps = (long)SpinBox_NbSteps->value();
01067       double aTolerance = SpinBox_Tolerance->GetValue();
01068       
01069       if (GroupAngle->checkedId() == 1)
01070         anAngle = anAngle/aNbSteps;
01071       
01072       try {
01073         SUIT_OverrideCursor aWaitCursor;
01074         SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
01075         if( CheckBoxMesh->isChecked() ) {
01076           if( GetConstructorId() == 0 )
01077             aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis,
01078                                                anAngle, aNbSteps, aTolerance);
01079           else
01080             aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis,
01081                                                anAngle, aNbSteps, aTolerance);
01082         }
01083         else
01084           aMeshEditor->RotationSweep(anElementsId.inout(), 
01085                                      anAxis, 
01086                                      anAngle, 
01087                                      aNbSteps, 
01088                                      aTolerance);
01089         SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
01090         mySimulation->SetData(aMeshPreviewStruct._retn());
01091       } catch (...) {}
01092     }
01093     else
01094     {
01095       mySimulation->SetVisibility(false);
01096     }
01097   }
01098   else
01099   {
01100     //erase preview
01101     mySimulation->SetVisibility(false);
01102   }
01103 }
01104 
01105 //=================================================================================
01106 // function : onSelectVectorButton()
01107 // purpose  : [slot]
01108 //=================================================================================
01109 void SMESHGUI_RevolutionDlg::onSelectVectorButton(){
01110   if(SelectVectorMenu) {
01111     SelectVectorMenu->exec( QCursor::pos() );
01112   }
01113 }
01114 
01115 //=================================================================================
01116 // function : onSelectVectorMenu()
01117 // purpose  : [slot]
01118 //=================================================================================
01119 void SMESHGUI_RevolutionDlg::onSelectVectorMenu( QAction* action){
01120   if(!action)
01121     return;
01122 
01123   disconnect(mySelectionMgr, 0, this, 0);
01124 
01125   switch(myMenuActions[action]) {
01126   case POINT_SELECT: 
01127     SMESH::SetPointRepresentation(true);
01128     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
01129       aViewWindow->SetSelectionMode(NodeSelection);
01130     break;
01131     
01132   case FACE_SELECT: 
01133     SMESH::SetPointRepresentation(false);
01134     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
01135       aViewWindow->SetSelectionMode(FaceSelection);
01136     break;
01137   }
01138 
01139   myVectorDefinition = myMenuActions[action];
01140   myEditCurrentArgument = (QWidget*)SpinBox_DX;
01141   myEditCurrentArgument->setFocus();
01142   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
01143   SelectionIntoArgument();
01144 }
01145 
01146 //=================================================================================
01147 // function : setFilters()
01148 // purpose  : SLOT. Called when "Filter" button pressed.
01149 //=================================================================================
01150 void SMESHGUI_RevolutionDlg::setFilters()
01151 {
01152   if(myMesh->_is_nil()) {
01153     SUIT_MessageBox::critical(this,
01154                               tr("SMESH_ERROR"),
01155                               tr("NO_MESH_SELECTED"));
01156    return;
01157   }
01158   if ( !myFilterDlg )
01159   {
01160     QList<int> types;  
01161     types.append( SMESH::EDGE );
01162     types.append( SMESH::FACE );
01163     myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
01164   }
01165   myFilterDlg->Init( GetConstructorId() ? SMESH::FACE : SMESH::EDGE );
01166 
01167   myFilterDlg->SetSelection();
01168   myFilterDlg->SetMesh( myMesh );
01169   myFilterDlg->SetSourceWg( LineEditElements );
01170 
01171   myFilterDlg->show();
01172 }
01173 
01174 //=================================================================================
01175 // function : isValid
01176 // purpose  :
01177 //=================================================================================
01178 bool SMESHGUI_RevolutionDlg::isValid()
01179 {
01180   QString msg;
01181   bool ok = true;
01182   ok = SpinBox_X->isValid( msg, true ) && ok;
01183   ok = SpinBox_Y->isValid( msg, true ) && ok;
01184   ok = SpinBox_Z->isValid( msg, true ) && ok;
01185   ok = SpinBox_DX->isValid( msg, true ) && ok;
01186   ok = SpinBox_DY->isValid( msg, true ) && ok;
01187   ok = SpinBox_DZ->isValid( msg, true ) && ok;
01188   ok = SpinBox_Angle->isValid( msg, true ) && ok;
01189   ok = SpinBox_NbSteps->isValid( msg, true ) && ok;
01190   ok = SpinBox_Tolerance->isValid( msg, true ) && ok;
01191 
01192   if( !ok ) {
01193     QString str( tr( "SMESH_INCORRECT_INPUT" ) );
01194     if ( !msg.isEmpty() )
01195       str += "\n" + msg;
01196     SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
01197     return false;
01198   }
01199   return true;
01200 }
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