Version: 6.3.1

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