Back to index

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