Back to index

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