Back to index

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