Back to index

salome-smesh  6.5.0
SMESHGUI_RevolutionDlg.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  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())*M_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       myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
00524 
00525       if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
00526         if( CheckBoxMesh->isChecked() ) {
00527           if( GetConstructorId() == 0 )
00528             SMESH::ListOfGroups_var groups = 
00529               aMeshEditor->RotationSweepObject1DMakeGroups(mySelectedObject, anAxis,
00530                                                            anAngle, aNbSteps, aTolerance);
00531           else
00532             SMESH::ListOfGroups_var groups = 
00533               aMeshEditor->RotationSweepObject2DMakeGroups(mySelectedObject, anAxis,
00534                                                            anAngle, aNbSteps, aTolerance);
00535         }
00536         else
00537           SMESH::ListOfGroups_var groups = 
00538             aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis,
00539                                                  anAngle, aNbSteps, aTolerance);
00540       }
00541       else {
00542         if( CheckBoxMesh->isChecked() ) {
00543           if( GetConstructorId() == 0 )
00544             aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
00545           else
00546             aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
00547         }
00548         else
00549           aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
00550       }
00551 
00552     } catch (...) {
00553     }
00554 
00555     SMESH::UpdateView();
00556     SMESH::Update(myIO, SMESH::eDisplay);
00557     if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
00558       mySMESHGUI->updateObjBrowser(true); // new groups may appear
00559     Init(false);
00560     ConstructorsClicked(GetConstructorId());
00561     mySelectedObject = SMESH::SMESH_IDSource::_nil();
00562     SelectionIntoArgument();
00563 
00564     SMESHGUI::Modified();
00565   }
00566 
00567   return true;
00568 }
00569 
00570 //=================================================================================
00571 // function : ClickOnOk()
00572 // purpose  :
00573 //=================================================================================
00574 void SMESHGUI_RevolutionDlg::ClickOnOk()
00575 {
00576   if( ClickOnApply() )
00577     ClickOnCancel();
00578 }
00579 
00580 //=================================================================================
00581 // function : ClickOnCancel()
00582 // purpose  :
00583 //=================================================================================
00584 void SMESHGUI_RevolutionDlg::ClickOnCancel()
00585 {
00586   reject();
00587 }
00588 
00589 void SMESHGUI_RevolutionDlg::reject()
00590 {
00591   close();
00592 }
00593 
00594 //=================================================================================
00595 // function : ClickOnHelp()
00596 // purpose  :
00597 //=================================================================================
00598 void SMESHGUI_RevolutionDlg::ClickOnHelp()
00599 {
00600   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
00601   if (app) 
00602     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
00603   else {
00604     QString platform;
00605 #ifdef WIN32
00606     platform = "winapplication";
00607 #else
00608     platform = "application";
00609 #endif
00610     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
00611                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
00612                              arg(app->resourceMgr()->stringValue("ExternalBrowser", 
00613                                                                  platform)).
00614                              arg(myHelpFileName));
00615   }
00616 }
00617 
00618 //=======================================================================
00619 // function : onAngleTextChange()
00620 // purpose  :
00621 //=======================================================================
00622 void SMESHGUI_RevolutionDlg::onAngleTextChange (const QString& theNewText)
00623 {
00624   bool isNumber;
00625   SpinBox_Angle->text().toDouble( &isNumber );
00626   if( !isNumber )
00627     RadioButton3->setChecked( true );
00628   RadioButton4->setEnabled( isNumber );
00629 }
00630 
00631 //=======================================================================
00632 // function : onTextChange()
00633 // purpose  :
00634 //=======================================================================
00635 void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
00636 {
00637   QLineEdit* send = (QLineEdit*)sender();
00638 
00639   if (myBusy) return;
00640   myBusy = true;
00641 
00642   if (send == LineEditElements)
00643     myNbOkElements = 0;
00644 
00645   buttonOk->setEnabled(false);
00646   buttonApply->setEnabled(false);
00647 
00648   // hilight entered elements
00649   SMDS_Mesh* aMesh = 0;
00650   if (myActor)
00651     aMesh = myActor->GetObject()->GetMesh();
00652 
00653   if (aMesh) {
00654     if (send == LineEditElements) {
00655       Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
00656 
00657       TColStd_MapOfInteger newIndices;
00658 
00659       QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
00660       
00661       for (int i = 0; i < aListId.count(); i++) {
00662         const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
00663         if (e)
00664           newIndices.Add(e->GetID());
00665         myNbOkElements++;
00666       }
00667 
00668       mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
00669       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00670         aViewWindow->highlight( myActor->getIO(), true, true );
00671       
00672       myElementsId = theNewText;
00673     }
00674   }
00675 
00676   if (myNbOkElements && IsAxisOk()) {
00677     buttonOk->setEnabled(true);
00678     buttonApply->setEnabled(true);
00679   }
00680   onDisplaySimulation(true);
00681 
00682   myBusy = false;
00683 }
00684 
00685 //=================================================================================
00686 // function : SelectionIntoArgument()
00687 // purpose  : Called when selection as changed or other case
00688 //=================================================================================
00689 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
00690 {
00691   if (myBusy) return;
00692 
00693   // clear
00694   QString aString = "";
00695 
00696   myBusy = true;
00697   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
00698     LineEditElements->setText(aString);
00699     myNbOkElements = 0;
00700     buttonOk->setEnabled(false);
00701     buttonApply->setEnabled(false);
00702   }
00703   myBusy = false;
00704 
00705   if (!GroupButtons->isEnabled()) // inactive
00706     return;
00707 
00708   // get selected mesh
00709   const SALOME_ListIO& aList = mySelector->StoredIObjects();
00710 
00711   int nbSel = aList.Extent();
00712   if (nbSel != 1) 
00713     return;
00714 
00715   Handle(SALOME_InteractiveObject) IO = aList.First();
00716   SMESH::SMESH_Mesh_var aMeshVar = SMESH::GetMeshByIO(IO);
00717   if (aMeshVar->_is_nil())
00718     return;
00719 
00720   SMESH_Actor* anActor = SMESH::FindActorByObject(aMeshVar);
00721   if (!anActor)
00722     anActor = SMESH::FindActorByEntry(IO->getEntry());
00723   if (!anActor && !CheckBoxMesh->isChecked())
00724     return;
00725 
00726   int aNbUnits = 0;
00727 
00728   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
00729     myElementsId = "";
00730     myMesh = aMeshVar;
00731     myActor = anActor;
00732     myIO = IO;
00733 
00734     // MakeGroups is available if there are groups
00735     if ( myMesh->NbGroups() == 0 ) {
00736       MakeGroupsCheck->setChecked(false);
00737       MakeGroupsCheck->setEnabled(false);
00738     } else {
00739       MakeGroupsCheck->setEnabled(true);
00740     }
00741 
00742     if (CheckBoxMesh->isChecked()) {
00743       SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
00744 
00745       if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
00746         mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
00747       else
00748         return;
00749     } else {
00750       aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
00751       myElementsId = aString;
00752       if (aNbUnits < 1)
00753         return;
00754     }
00755     myNbOkElements = true;
00756   } else {
00757 
00758     SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
00759     if (!aMesh)
00760       return;
00761 
00762     bool isNodeSelected = (myEditCurrentArgument == (QWidget*)SpinBox_X ||
00763                            (myEditCurrentArgument == (QWidget*)SpinBox_DX && 
00764                             myVectorDefinition==POINT_SELECT));
00765 
00766     bool isFaceSelected = (myEditCurrentArgument == (QWidget*)SpinBox_DX && 
00767                            myVectorDefinition==FACE_SELECT);
00768 
00769     if(isNodeSelected) {
00770       aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
00771     }
00772     else if(isFaceSelected){
00773       aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
00774     }
00775     
00776     if (aNbUnits != 1)
00777       return;
00778 
00779     if(isNodeSelected) {
00780       const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
00781       if (!n)
00782         return;
00783 
00784       double x = n->X();
00785       double y = n->Y();
00786       double z = n->Z();
00787 
00788       if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
00789         SpinBox_X->SetValue(x);
00790         SpinBox_Y->SetValue(y);
00791         SpinBox_Z->SetValue(z);
00792       } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
00793         SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
00794         SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
00795         SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
00796       }
00797     }
00798     else if(isFaceSelected){
00799       const SMDS_MeshFace* face = dynamic_cast<const SMDS_MeshFace*>(aMesh->FindElement(aString.toInt()));
00800       if (!face)
00801         return;
00802       
00803       gp_XYZ aNormale = SMESH::getNormale(face);
00804       SpinBox_DX->SetValue(aNormale.X());
00805       SpinBox_DY->SetValue(aNormale.Y());
00806       SpinBox_DZ->SetValue(aNormale.Z());
00807       
00808     }
00809   }
00810 
00811   myBusy = true;
00812   if (myEditCurrentArgument == (QWidget*)LineEditElements)
00813     LineEditElements->setText(aString);
00814   myBusy = false;
00815 
00816   // OK
00817   if (myNbOkElements && IsAxisOk()) {
00818     buttonOk->setEnabled(true);
00819     buttonApply->setEnabled(true);
00820   }
00821 
00822   onDisplaySimulation(true);
00823 }
00824 
00825 //=================================================================================
00826 // function : SetEditCurrentArgument()
00827 // purpose  :
00828 //=================================================================================
00829 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
00830 {
00831   QPushButton* send = (QPushButton*)sender();
00832 
00833   disconnect(mySelectionMgr, 0, this, 0);
00834   mySelectionMgr->clearSelected();
00835   mySelectionMgr->clearFilters();
00836 
00837   if (send == SelectElementsButton) {
00838     mySimulation->SetVisibility(false);
00839     myEditCurrentArgument = (QWidget*)LineEditElements;
00840     SMESH::SetPointRepresentation(false);
00841     if (CheckBoxMesh->isChecked()) {
00842       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00843         aViewWindow->SetSelectionMode(ActorSelection);
00844       mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
00845     } else {
00846       int aConstructorId = GetConstructorId();
00847       if (aConstructorId == 0)
00848         {
00849           if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00850             aViewWindow->SetSelectionMode(EdgeSelection);
00851         }
00852       else if (aConstructorId == 1)
00853         {
00854           if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00855             aViewWindow->SetSelectionMode(FaceSelection);
00856         }
00857     }
00858   } else if (send == SelectPointButton) {
00859     myEditCurrentArgument = (QWidget*)SpinBox_X;
00860     SMESH::SetPointRepresentation(true);
00861     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00862       aViewWindow->SetSelectionMode(NodeSelection);
00863   }
00864 
00865   myEditCurrentArgument->setFocus();
00866   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
00867   SelectionIntoArgument();
00868 }
00869 
00870 //=================================================================================
00871 // function : DeactivateActiveDialog()
00872 // purpose  :
00873 //=================================================================================
00874 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
00875 {
00876   if (ConstructorsBox->isEnabled()) {
00877     ConstructorsBox->setEnabled(false);
00878     GroupArguments->setEnabled(false);
00879     GroupButtons->setEnabled(false);
00880     mySMESHGUI->ResetState();
00881     mySMESHGUI->SetActiveDialogBox(0);
00882   }
00883 }
00884 
00885 //=================================================================================
00886 // function : ActivateThisDialog()
00887 // purpose  :
00888 //=================================================================================
00889 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
00890 {
00891   /* Emit a signal to deactivate the active dialog */
00892   mySMESHGUI->EmitSignalDeactivateDialog();
00893   ConstructorsBox->setEnabled(true);
00894   GroupArguments->setEnabled(true);
00895   GroupButtons->setEnabled(true);
00896 
00897   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
00898 
00899   ConstructorsClicked(GetConstructorId());
00900   SelectionIntoArgument();
00901 }
00902 
00903 //=================================================================================
00904 // function : enterEvent()
00905 // purpose  :
00906 //=================================================================================
00907 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
00908 {
00909   if (!ConstructorsBox->isEnabled())
00910     ActivateThisDialog();
00911 }
00912 
00913 //=================================================================================
00914 // function : closeEvent()
00915 // purpose  :
00916 //=================================================================================
00917 void SMESHGUI_RevolutionDlg::closeEvent (QCloseEvent*)
00918 {
00919   /* same than click on cancel button */
00920   disconnect(mySelectionMgr, 0, this, 0);
00921   mySelectionMgr->clearFilters();
00922   //mySelectionMgr->clearSelected();
00923   if (SMESH::GetCurrentVtkView()) {
00924     SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
00925     SMESH::SetPointRepresentation(false);
00926   }
00927   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00928     aViewWindow->SetSelectionMode(ActorSelection);
00929   mySMESHGUI->ResetState();
00930 }
00931 
00932 //=======================================================================
00933 //function : onSelectMesh
00934 //purpose  :
00935 //=======================================================================
00936 void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
00937 {
00938   if (toSelectMesh) {
00939     myIDs = LineEditElements->text();
00940     TextLabelElements->setText(tr("SMESH_NAME"));
00941   }
00942   else
00943     TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
00944   myFilterBtn->setEnabled(!toSelectMesh);
00945 
00946   if (myEditCurrentArgument != LineEditElements) {
00947     LineEditElements->clear();
00948     mySimulation->SetVisibility(false);
00949     return;
00950   }
00951 
00952   mySelectionMgr->clearFilters();
00953   SMESH::SetPointRepresentation(false);
00954 
00955   if (toSelectMesh) {
00956     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00957       aViewWindow->SetSelectionMode(ActorSelection);
00958     mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
00959     LineEditElements->setReadOnly(true);
00960     LineEditElements->setValidator(0);
00961   } else {
00962     int aConstructorId = GetConstructorId();
00963     if (aConstructorId == 0)
00964       {
00965         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00966           aViewWindow->SetSelectionMode(EdgeSelection);
00967       }
00968     else if (aConstructorId == 1)
00969       {
00970         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00971           aViewWindow->SetSelectionMode(FaceSelection);
00972       }
00973 
00974     LineEditElements->setReadOnly(false);
00975     LineEditElements->setValidator(myIdValidator);
00976     onTextChange(LineEditElements->text());
00977     mySimulation->SetVisibility(false);
00978   }
00979 
00980   SelectionIntoArgument();
00981 
00982   if (!toSelectMesh)
00983     LineEditElements->setText( myIDs );
00984 }
00985 
00986 //=================================================================================
00987 // function : GetConstructorId()
00988 // purpose  :
00989 //=================================================================================
00990 int SMESHGUI_RevolutionDlg::GetConstructorId()
00991 {
00992   return GroupConstructors->checkedId();
00993 }
00994 
00995 //=================================================================================
00996 // function : IsAxisOk()
00997 // purpose  :
00998 //=================================================================================
00999 bool SMESHGUI_RevolutionDlg::IsAxisOk()
01000 {
01001   return (SpinBox_DX->GetValue() != 0 ||
01002           SpinBox_DY->GetValue() != 0 ||
01003           SpinBox_DZ->GetValue() != 0);
01004 }
01005 
01006 //=================================================================================
01007 // function : onVectorChanged()
01008 // purpose  :
01009 //=================================================================================
01010 void SMESHGUI_RevolutionDlg::onVectorChanged()
01011 {
01012   if (IsAxisOk()) {
01013     buttonOk->setEnabled(true);
01014     buttonApply->setEnabled(true);
01015   } else {
01016     buttonOk->setEnabled(false);
01017     buttonApply->setEnabled(false);
01018   }
01019   onDisplaySimulation(true);
01020 }
01021 
01022 //=================================================================================
01023 // function : keyPressEvent()
01024 // purpose  :
01025 //=================================================================================
01026 void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
01027 {
01028   QDialog::keyPressEvent( e );
01029   if ( e->isAccepted() )
01030     return;
01031 
01032   if ( e->key() == Qt::Key_F1 ) {
01033     e->accept();
01034     ClickOnHelp();
01035   }
01036 }
01037 
01038 //=================================================================================
01039 // function : onDisplaySimulation()
01040 // purpose  : Show/Hide preview
01041 //=================================================================================
01042 void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview)
01043 {
01044   if (myPreviewCheckBox->isChecked() && toDisplayPreview)
01045   {
01046     //display preview
01047     if (myNbOkElements && IsAxisOk())
01048     {
01049       QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
01050       
01051       SMESH::long_array_var anElementsId = new SMESH::long_array;
01052       
01053       anElementsId->length(aListElementsId.count());
01054       for (int i = 0; i < aListElementsId.count(); i++)
01055         anElementsId[i] = aListElementsId[i].toInt();
01056       
01057       SMESH::AxisStruct anAxis;
01058       
01059       anAxis.x =  SpinBox_X->GetValue();
01060       anAxis.y =  SpinBox_Y->GetValue();
01061       anAxis.z =  SpinBox_Z->GetValue();
01062       anAxis.vx = SpinBox_DX->GetValue();
01063       anAxis.vy = SpinBox_DY->GetValue();
01064       anAxis.vz = SpinBox_DZ->GetValue();
01065 
01066       double anAngle = (SpinBox_Angle->GetValue())*M_PI/180.;
01067       long aNbSteps = (long)SpinBox_NbSteps->value();
01068       double aTolerance = SpinBox_Tolerance->GetValue();
01069       
01070       if (GroupAngle->checkedId() == 1)
01071         anAngle = anAngle/aNbSteps;
01072       
01073       try {
01074         SUIT_OverrideCursor aWaitCursor;
01075         SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
01076         if( CheckBoxMesh->isChecked() ) {
01077           if( GetConstructorId() == 0 )
01078             aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis,
01079                                                anAngle, aNbSteps, aTolerance);
01080           else
01081             aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis,
01082                                                anAngle, aNbSteps, aTolerance);
01083         }
01084         else
01085           aMeshEditor->RotationSweep(anElementsId.inout(), 
01086                                      anAxis, 
01087                                      anAngle, 
01088                                      aNbSteps, 
01089                                      aTolerance);
01090         SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
01091         mySimulation->SetData(aMeshPreviewStruct._retn());
01092       } catch (...) {}
01093     }
01094     else
01095     {
01096       mySimulation->SetVisibility(false);
01097     }
01098   }
01099   else
01100   {
01101     //erase preview
01102     mySimulation->SetVisibility(false);
01103   }
01104 }
01105 
01106 //=================================================================================
01107 // function : onSelectVectorButton()
01108 // purpose  : [slot]
01109 //=================================================================================
01110 void SMESHGUI_RevolutionDlg::onSelectVectorButton(){
01111   if(SelectVectorMenu) {
01112     SelectVectorMenu->exec( QCursor::pos() );
01113   }
01114 }
01115 
01116 //=================================================================================
01117 // function : onSelectVectorMenu()
01118 // purpose  : [slot]
01119 //=================================================================================
01120 void SMESHGUI_RevolutionDlg::onSelectVectorMenu( QAction* action){
01121   if(!action)
01122     return;
01123 
01124   disconnect(mySelectionMgr, 0, this, 0);
01125 
01126   switch(myMenuActions[action]) {
01127   case POINT_SELECT: 
01128     SMESH::SetPointRepresentation(true);
01129     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
01130       aViewWindow->SetSelectionMode(NodeSelection);
01131     break;
01132     
01133   case FACE_SELECT: 
01134     SMESH::SetPointRepresentation(false);
01135     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
01136       aViewWindow->SetSelectionMode(FaceSelection);
01137     break;
01138   }
01139 
01140   myVectorDefinition = myMenuActions[action];
01141   myEditCurrentArgument = (QWidget*)SpinBox_DX;
01142   myEditCurrentArgument->setFocus();
01143   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
01144   SelectionIntoArgument();
01145 }
01146 
01147 //=================================================================================
01148 // function : setFilters()
01149 // purpose  : SLOT. Called when "Filter" button pressed.
01150 //=================================================================================
01151 void SMESHGUI_RevolutionDlg::setFilters()
01152 {
01153   if(myMesh->_is_nil()) {
01154     SUIT_MessageBox::critical(this,
01155                               tr("SMESH_ERROR"),
01156                               tr("NO_MESH_SELECTED"));
01157    return;
01158   }
01159   if ( !myFilterDlg )
01160   {
01161     QList<int> types;  
01162     types.append( SMESH::EDGE );
01163     types.append( SMESH::FACE );
01164     myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
01165   }
01166   myFilterDlg->Init( GetConstructorId() ? SMESH::FACE : SMESH::EDGE );
01167 
01168   myFilterDlg->SetSelection();
01169   myFilterDlg->SetMesh( myMesh );
01170   myFilterDlg->SetSourceWg( LineEditElements );
01171 
01172   myFilterDlg->show();
01173 }
01174 
01175 //=================================================================================
01176 // function : isValid
01177 // purpose  :
01178 //=================================================================================
01179 bool SMESHGUI_RevolutionDlg::isValid()
01180 {
01181   QString msg;
01182   bool ok = true;
01183   ok = SpinBox_X->isValid( msg, true ) && ok;
01184   ok = SpinBox_Y->isValid( msg, true ) && ok;
01185   ok = SpinBox_Z->isValid( msg, true ) && ok;
01186   ok = SpinBox_DX->isValid( msg, true ) && ok;
01187   ok = SpinBox_DY->isValid( msg, true ) && ok;
01188   ok = SpinBox_DZ->isValid( msg, true ) && ok;
01189   ok = SpinBox_Angle->isValid( msg, true ) && ok;
01190   ok = SpinBox_NbSteps->isValid( msg, true ) && ok;
01191   ok = SpinBox_Tolerance->isValid( msg, true ) && ok;
01192 
01193   if( !ok ) {
01194     QString str( tr( "SMESH_INCORRECT_INPUT" ) );
01195     if ( !msg.isEmpty() )
01196       str += "\n" + msg;
01197     SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
01198     return false;
01199   }
01200   return true;
01201 }