Back to index

salome-geom  6.5.0
TransformationGUI_TranslationDlg.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // GEOM GEOMGUI : GUI for Geometry component
00024 // File   : TransformationGUI_TranslationDlg.cxx
00025 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
00026 //
00027 #include "TransformationGUI_TranslationDlg.h"
00028 
00029 #include <DlgRef.h>
00030 #include <GeometryGUI.h>
00031 #include <GEOMBase.h>
00032 
00033 #include <SUIT_Session.h>
00034 #include <SUIT_ResourceMgr.h>
00035 #include <SUIT_Desktop.h>
00036 #include <SUIT_ViewWindow.h>
00037 #include <SUIT_ViewManager.h>
00038 #include <SalomeApp_Application.h>
00039 #include <LightApp_SelectionMgr.h>
00040 #include <GEOM_AISVector.hxx>
00041 #include <SOCC_Prs.h>
00042 #include <SOCC_ViewModel.h>
00043 
00044 // OCCT Includes
00045 #include <TopoDS_Shape.hxx>
00046 #include <TopoDS_Edge.hxx>
00047 #include <TopoDS_Vertex.hxx>
00048 #include <TopoDS.hxx>
00049 #include <TopExp.hxx>
00050 #include <TColStd_IndexedMapOfInteger.hxx>
00051 #include <TopTools_IndexedMapOfShape.hxx>
00052 #include <ShapeAnalysis_Edge.hxx>
00053 #include <BRep_Tool.hxx>
00054 #include <BRepBuilderAPI_MakeEdge.hxx>
00055 #include <BRep_Builder.hxx>
00056 
00057 #include <GEOMImpl_Types.hxx>
00058 
00059 //=================================================================================
00060 // class    : TransformationGUI_TranslationDlg()
00061 // purpose  : Constructs a TransformationGUI_TranslationDlg which is a child of 'parent', with the
00062 //            name 'name' and widget flags set to 'f'.
00063 //            The dialog will by default be modeless, unless you set 'modal' to
00064 //            TRUE to construct a modal dialog.
00065 //=================================================================================
00066 TransformationGUI_TranslationDlg::TransformationGUI_TranslationDlg
00067 (GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl)
00068   : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
00069     myInitial(true)
00070 {
00071   SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
00072   QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_TRANSLATION_DXYZ")));
00073   QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_TRANSLATION_POINTS")));
00074   QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_TRANSLATION_VECTOR")));
00075   QPixmap image3 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
00076 
00077   setWindowTitle(tr("GEOM_TRANSLATION_TITLE"));
00078 
00079   /***************************************************************/
00080   mainFrame()->GroupConstructors->setTitle(tr("GEOM_TRANSLATION"));
00081   mainFrame()->RadioButton1->setIcon(image0);
00082   mainFrame()->RadioButton2->setIcon(image1);
00083   mainFrame()->RadioButton3->setIcon(image2);
00084   mainFrame()->RadioButton1->setChecked(true);
00085 
00086   GroupPoints = new DlgRef_3Sel3Spin2Check(centralWidget());
00087   GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
00088   GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS"));
00089   GroupPoints->TextLabel3->setText(tr("GEOM_POINT_I").arg(2));
00090   GroupPoints->TextLabel4->setText(tr("GEOM_DX"));
00091   GroupPoints->TextLabel5->setText(tr("GEOM_DY"));
00092   GroupPoints->TextLabel6->setText(tr("GEOM_DZ"));
00093   GroupPoints->PushButton1->setIcon(image3);
00094   GroupPoints->PushButton2->setIcon(image3);
00095   GroupPoints->PushButton3->setIcon(image3);
00096   GroupPoints->CheckBox1->setText(tr("Activate Distance"));
00097   GroupPoints->CheckBox2->setText(tr("GEOM_CREATE_COPY"));
00098 
00099   QVBoxLayout* layout = new QVBoxLayout(centralWidget());
00100   layout->setMargin(0); layout->setSpacing(6);
00101   layout->addWidget(GroupPoints);
00102   /***************************************************************/
00103 
00104   setHelpFileName("translation_operation_page.html");
00105 
00106   // Activate Create a Copy mode
00107   GroupPoints->CheckBox2->setChecked(true);
00108   CreateCopyModeChanged();
00109 
00110   Init();
00111 }
00112 
00113 //=================================================================================
00114 // function : ~TransformationGUI_TranslationDlg()
00115 // purpose  : Destroys the object and frees any allocated resources
00116 //=================================================================================
00117 TransformationGUI_TranslationDlg::~TransformationGUI_TranslationDlg()
00118 {
00119   // no need to delete child widgets, Qt does it all for us
00120 }
00121 
00122 //=================================================================================
00123 // function : Init()
00124 // purpose  :
00125 //=================================================================================
00126 void TransformationGUI_TranslationDlg::Init()
00127 {
00128   // Get setting of step value from file configuration
00129   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
00130   double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
00131 
00132   // min, max, step and decimals for spin boxes & initial values
00133   initSpinBox(GroupPoints->SpinBox1, COORD_MIN, COORD_MAX, step, "length_precision" );
00134   initSpinBox(GroupPoints->SpinBox2, COORD_MIN, COORD_MAX, step, "length_precision" );
00135   initSpinBox(GroupPoints->SpinBox3, COORD_MIN, COORD_MAX, step, "length_precision" );
00136 
00137   GroupPoints->SpinBox1->setValue(0.0);
00138   GroupPoints->SpinBox2->setValue(0.0);
00139   GroupPoints->SpinBox3->setValue(0.0);
00140 
00141   // init variables
00142   GroupPoints->LineEdit1->setReadOnly(true);
00143   GroupPoints->LineEdit2->setReadOnly(true);
00144   GroupPoints->LineEdit3->setReadOnly(true);
00145 
00146   GroupPoints->LineEdit1->setText("");
00147   GroupPoints->LineEdit2->setText("");
00148   GroupPoints->LineEdit3->setText("");
00149 
00150   myObjects.clear();
00151   myVector.nullify();
00152   myPoint1.nullify();
00153   myPoint2.nullify();
00154 
00155   mainFrame()->GroupBoxPublish->show();
00156 
00157   // signals and slots connections
00158   connect(buttonOk(),    SIGNAL(clicked()), this, SLOT(ClickOnOk()));
00159   connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
00160 
00161   connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
00162 
00163   connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
00164   connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
00165   connect(GroupPoints->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
00166 
00167   connect(GroupPoints->SpinBox1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
00168   connect(GroupPoints->SpinBox2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
00169   connect(GroupPoints->SpinBox3, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
00170 
00171   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
00172 
00173   connect(GroupPoints->CheckBox1, SIGNAL(toggled(bool)), this, SLOT(ActivateDistanceChanged()));
00174   connect(GroupPoints->CheckBox2, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged()));
00175 
00176   initName(tr("GEOM_TRANSLATION"));
00177 
00178   ConstructorsClicked(0);
00179 }
00180 
00181 //=================================================================================
00182 // function : SetDoubleSpinBoxStep()
00183 // purpose  : Double spin box management
00184 //=================================================================================
00185 void TransformationGUI_TranslationDlg::SetDoubleSpinBoxStep (double step)
00186 {
00187   GroupPoints->SpinBox1->setSingleStep(step);
00188   GroupPoints->SpinBox2->setSingleStep(step);
00189   GroupPoints->SpinBox3->setSingleStep(step);
00190 }
00191 
00192 //=================================================================================
00193 // function : ConstructorsClicked()
00194 // purpose  : Radio button management
00195 //=================================================================================
00196 void TransformationGUI_TranslationDlg::ConstructorsClicked (int constructorId)
00197 {
00198   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
00199 
00200   switch (constructorId) {
00201   case 0: // translation an object by dx, dy, dz
00202     {
00203       GroupPoints->ShowRows(1, 2, false);
00204       GroupPoints->ShowRows(3, 5, true);
00205 
00206       GroupPoints->TextLabel6->setText(tr("GEOM_DZ"));
00207       GroupPoints->SpinBox3->setEnabled(true);
00208 
00209       GroupPoints->CheckBox1->hide();
00210 
00211       GroupPoints->PushButton1->click();
00212     }
00213     break;
00214   case 1: // translation an object by 2 points
00215     {
00216       GroupPoints->ShowRows(3, 5, false);
00217       GroupPoints->ShowRows(0, 2, true);
00218 
00219       GroupPoints->TextLabel6->setText(tr("GEOM_DZ"));
00220       GroupPoints->TextLabel2->setText(tr("GEOM_POINT_I").arg(1));
00221       GroupPoints->LineEdit2->clear();
00222       GroupPoints->LineEdit3->clear();
00223       GroupPoints->SpinBox3->setEnabled(true);
00224 
00225       GroupPoints->CheckBox1->hide();
00226 
00227       myPoint1.nullify();
00228       myPoint2.nullify();
00229 
00230       GroupPoints->PushButton1->click();
00231     }
00232     break;
00233   case 2: // translation an object by vector
00234     {
00235       GroupPoints->ShowRows(0, 1, true);
00236       GroupPoints->ShowRows(2, 4, false);
00237       GroupPoints->ShowRows(5, 5, true);
00238 
00239       GroupPoints->TextLabel6->setText(tr("GEOM_DISTANCE"));
00240       GroupPoints->SpinBox3->setValue(0.0);
00241       GroupPoints->SpinBox3->setEnabled(false);
00242       GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR"));
00243       GroupPoints->LineEdit2->clear();
00244 
00245       GroupPoints->CheckBox1->show();
00246 
00247       myVector.nullify();
00248       ActivateDistanceChanged();
00249 
00250       GroupPoints->PushButton1->click();
00251     }
00252     break;
00253   }
00254 
00255   qApp->processEvents();
00256   updateGeometry();
00257   resize(minimumSizeHint());
00258 
00259   if (myInitial) {
00260     myInitial = false;
00261     SelectionIntoArgument();
00262   }
00263   else {
00264     processPreview();
00265   }
00266 }
00267 
00268 //=================================================================================
00269 // function : ClickOnOk()
00270 // purpose  :
00271 //=================================================================================
00272 void TransformationGUI_TranslationDlg::ClickOnOk()
00273 {
00274   setIsApplyAndClose( true );
00275   if (ClickOnApply())
00276     ClickOnCancel();
00277 }
00278 
00279 //=================================================================================
00280 // function : ClickOnApply()
00281 // purpose  :
00282 //=================================================================================
00283 bool TransformationGUI_TranslationDlg::ClickOnApply()
00284 {
00285   if (!onAccept(GroupPoints->CheckBox2->isChecked()))
00286     return false;
00287 
00288   initName();
00289 
00290   // activate selection and connect selection manager
00291   ConstructorsClicked(getConstructorId());
00292   SelectionIntoArgument();
00293 
00294   return true;
00295 }
00296 
00297 //=================================================================================
00298 // function : SelectionIntoArgument()
00299 // purpose  : Called when selection is changed or on dialog initialization or activation
00300 //=================================================================================
00301 void TransformationGUI_TranslationDlg::SelectionIntoArgument()
00302 {
00303   erasePreview();
00304 
00305   if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
00306     myObjects = getSelected( TopAbs_SHAPE, -1 );
00307     if ( !myObjects.isEmpty() ) {
00308       QString aName = myObjects.count() > 1 ? QString( "%1_objects").arg( myObjects.count() ) : GEOMBase::GetName( myObjects[0].get() );
00309       myEditCurrentArgument->setText( aName );
00310     }
00311     else {
00312       myEditCurrentArgument->setText("");
00313     }
00314   }
00315   else {
00316     TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2 ) ?
00317       TopAbs_EDGE : TopAbs_VERTEX;
00318     GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
00319     TopoDS_Shape aShape;
00320     if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
00321       QString aName = GEOMBase::GetName( aSelectedObject.get() );
00322       myEditCurrentArgument->setText( aName );
00323       if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
00324        if ( getConstructorId() == 1 ) {
00325          myPoint1 = aSelectedObject;
00326          if ( !myPoint2 )
00327            GroupPoints->PushButton3->click();
00328          else if ( myObjects.isEmpty() )
00329            GroupPoints->PushButton1->click();
00330        }
00331        else if ( getConstructorId() == 2 ) {
00332          myVector = aSelectedObject;
00333          if ( myObjects.isEmpty() )
00334            GroupPoints->PushButton1->click();
00335        }
00336       }
00337       else if ( myEditCurrentArgument == GroupPoints->LineEdit3 ) {
00338        myPoint2 = aSelectedObject;
00339        if ( myObjects.isEmpty() )
00340          GroupPoints->PushButton1->click();
00341        else if ( !myPoint1 )
00342          GroupPoints->PushButton2->click();
00343       }
00344     }
00345     else {
00346       if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
00347        if ( getConstructorId() == 1 ) myPoint1.nullify();
00348        else myVector.nullify();
00349       }
00350       else if ( myEditCurrentArgument == GroupPoints->LineEdit3 ) {
00351        myPoint2.nullify();
00352       }
00353       myEditCurrentArgument->setText("");
00354     }
00355   }
00356 
00357   processPreview();
00358 }
00359 
00360 //=================================================================================
00361 // function : SetEditCurrentArgument()
00362 // purpose  :
00363 //=================================================================================
00364 void TransformationGUI_TranslationDlg::SetEditCurrentArgument()
00365 {
00366   QPushButton* send = (QPushButton*)sender();
00367 
00368   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
00369   globalSelection();
00370 
00371   if (send == GroupPoints->PushButton1) {
00372     myEditCurrentArgument = GroupPoints->LineEdit1;
00373 
00374     GroupPoints->PushButton2->setDown(false);
00375     GroupPoints->PushButton3->setDown(false);
00376     GroupPoints->LineEdit2->setEnabled(false);
00377     GroupPoints->LineEdit3->setEnabled(false);
00378   }
00379   else if (send == GroupPoints->PushButton2) {
00380     myEditCurrentArgument = GroupPoints->LineEdit2;
00381 
00382     GroupPoints->PushButton1->setDown(false);
00383     GroupPoints->PushButton3->setDown(false);
00384     GroupPoints->LineEdit1->setEnabled(false);
00385     GroupPoints->LineEdit3->setEnabled(false);
00386 
00387     if (getConstructorId() == 1)
00388       localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
00389     else
00390       localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
00391   }
00392   else if (send == GroupPoints->PushButton3) {
00393     myEditCurrentArgument = GroupPoints->LineEdit3;
00394 
00395     GroupPoints->PushButton1->setDown(false);
00396     GroupPoints->PushButton2->setDown(false);
00397     GroupPoints->LineEdit1->setEnabled(false);
00398     GroupPoints->LineEdit2->setEnabled(false);
00399 
00400     localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
00401   }
00402   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
00403           this, SLOT(SelectionIntoArgument()));
00404 
00405   // enable line edit
00406   myEditCurrentArgument->setEnabled(true);
00407   myEditCurrentArgument->setFocus();
00408   // after setFocus(), because it will be setDown(false) when loses focus
00409   send->setDown(true);
00410 
00411   // seems we need it only to avoid preview disappearing, caused by selection mode change
00412   processPreview();
00413 }
00414 
00415 //=================================================================================
00416 // function : ActivateThisDialog()
00417 // purpose  :
00418 //=================================================================================
00419 void TransformationGUI_TranslationDlg::ActivateThisDialog()
00420 {
00421   GEOMBase_Skeleton::ActivateThisDialog();
00422   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
00423            this, SLOT( SelectionIntoArgument() ) );
00424 
00425   ConstructorsClicked( getConstructorId() );
00426 }
00427 
00428 //=================================================================================
00429 // function : enterEvent()
00430 // purpose  :
00431 //=================================================================================
00432 void TransformationGUI_TranslationDlg::enterEvent (QEvent*)
00433 {
00434   if (!mainFrame()->GroupConstructors->isEnabled())
00435     ActivateThisDialog();
00436 }
00437 
00438 //=================================================================================
00439 // function : ValueChangedInSpinBox()
00440 // purpose  :
00441 //=================================================================================
00442 void TransformationGUI_TranslationDlg::ValueChangedInSpinBox()
00443 {
00444   processPreview();
00445 }
00446 
00447 //=================================================================================
00448 // function : createOperation
00449 // purpose  :
00450 //=================================================================================
00451 GEOM::GEOM_IOperations_ptr TransformationGUI_TranslationDlg::createOperation()
00452 {
00453   return getGeomEngine()->GetITransformOperations(getStudyId());
00454 }
00455 
00456 //=================================================================================
00457 // function : isValid
00458 // purpose  :
00459 //=================================================================================
00460 bool TransformationGUI_TranslationDlg::isValid (QString& msg)
00461 {
00462   bool ok = false;
00463   switch (getConstructorId()) {
00464   case 0: 
00465     ok = GroupPoints->SpinBox1->isValid( msg, !IsPreview() ) &&
00466          GroupPoints->SpinBox2->isValid( msg, !IsPreview() ) &&
00467          GroupPoints->SpinBox3->isValid( msg, !IsPreview() ) &&
00468          !myObjects.isEmpty();
00469     break;
00470   case 1:
00471     ok = myPoint1 && myPoint2 && !myObjects.isEmpty();
00472     break;
00473   case 2:
00474       ok = GroupPoints->SpinBox3->isValid( msg, !IsPreview() ) &&
00475           myVector && !myObjects.isEmpty();
00476     break;
00477   default:
00478     break;
00479   }
00480   return ok;
00481 }
00482 
00483 //=================================================================================
00484 // function : execute
00485 // purpose  :
00486 //=================================================================================
00487 bool TransformationGUI_TranslationDlg::execute (ObjectList& objects)
00488 {
00489   bool res = false;
00490   bool toCreateCopy = IsPreview() || GroupPoints->CheckBox2->isChecked();
00491 
00492   GEOM::GEOM_Object_var anObj;
00493 
00494   GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation());
00495 
00496   switch (getConstructorId()) {
00497   case 0:
00498     {
00499       double dx = GroupPoints->SpinBox1->value();
00500       double dy = GroupPoints->SpinBox2->value();
00501       double dz = GroupPoints->SpinBox3->value();
00502 
00503       QStringList aParameters;
00504       aParameters<<GroupPoints->SpinBox1->text();
00505       aParameters<<GroupPoints->SpinBox2->text();
00506       aParameters<<GroupPoints->SpinBox3->text();
00507 
00508       if (toCreateCopy) {
00509         for (int i = 0; i < myObjects.count(); i++) {
00510           myCurrObject = myObjects[i];
00511           anObj = anOper->TranslateDXDYDZCopy(myObjects[i].get(), dx, dy, dz);
00512           if (!anObj->_is_nil()) {
00513             if(!IsPreview())
00514               anObj->SetParameters(aParameters.join(":").toLatin1().constData());
00515             objects.push_back(anObj._retn());
00516           }
00517         }
00518       }
00519       else {
00520         for (int i = 0; i < myObjects.count(); i++) {
00521           myCurrObject = myObjects[i];
00522           anObj = anOper->TranslateDXDYDZ(myObjects[i].get(), dx, dy, dz);
00523           if (!anObj->_is_nil()) {
00524             if(!IsPreview()) {
00525               anObj->SetParameters(aParameters.join(":").toLatin1().constData());
00526               updateAttributes(anObj, aParameters);
00527             }
00528             objects.push_back(anObj._retn());
00529           }
00530         }
00531       }
00532       res = true;
00533       break;
00534     }
00535   case 1:
00536     {
00537       if (toCreateCopy) {
00538         for (int i = 0; i < myObjects.count(); i++) {
00539           myCurrObject = myObjects[i];
00540           anObj = anOper->TranslateTwoPointsCopy(myObjects[i].get(), myPoint1.get(), myPoint2.get());
00541           if (!anObj->_is_nil())
00542             objects.push_back(anObj._retn());
00543         }
00544       }
00545       else {
00546         for (int i = 0; i < myObjects.count(); i++) {
00547           myCurrObject = myObjects[i];
00548           anObj = anOper->TranslateTwoPoints(myObjects[i].get(), myPoint1.get(), myPoint2.get());
00549           if (!anObj->_is_nil())
00550             objects.push_back(anObj._retn());
00551         }
00552       }
00553       res = true;
00554       break;
00555     }
00556   case 2:
00557     {
00558       QStringList aParameters;
00559       aParameters<<GroupPoints->SpinBox3->text();
00560       bool byDistance = GroupPoints->CheckBox1->isChecked();
00561       createPathPreview( myVector.get() );
00562 
00563       if (byDistance) {
00564         double aDistance = GroupPoints->SpinBox3->value();
00565         for (int i = 0; i < myObjects.count(); i++) {
00566           myCurrObject = myObjects[i];
00567           anObj = anOper->TranslateVectorDistance(myObjects[i].get(), myVector.get(), aDistance, toCreateCopy);
00568           if (!anObj->_is_nil()) {
00569             if(!IsPreview()) {
00570               anObj->SetParameters(aParameters.join(":").toLatin1().constData());
00571               if (!toCreateCopy)
00572                 updateAttributes(anObj, aParameters);
00573             }
00574             objects.push_back(anObj._retn());
00575           }
00576         }
00577       }
00578       else {
00579         if (toCreateCopy) {
00580           for (int i = 0; i < myObjects.count(); i++) {
00581             myCurrObject = myObjects[i];
00582             anObj = anOper->TranslateVectorCopy(myObjects[i].get(), myVector.get());
00583             if (!anObj->_is_nil())
00584               objects.push_back(anObj._retn());
00585           }
00586         }
00587         else {
00588           for (int i = 0; i < myObjects.count(); i++) {
00589             myCurrObject = myObjects[i];
00590             anObj = anOper->TranslateVector(myObjects[i].get(), myVector.get());
00591             if (!anObj->_is_nil())
00592               objects.push_back(anObj._retn());
00593           }
00594         }
00595       }
00596       res = true;
00597       break;
00598     }
00599   }
00600   return res;
00601 }
00602 
00603 //=================================================================================
00604 // function : restoreSubShapes
00605 // purpose  :
00606 //=================================================================================
00607 void TransformationGUI_TranslationDlg::restoreSubShapes (SALOMEDS::Study_ptr   theStudy,
00608                                                          SALOMEDS::SObject_ptr theSObject)
00609 {
00610   if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
00611     // we pass here the first operation argument (object) through the list of arguments
00612     // because the rotation operation place its arguments in the data structure in another order,
00613     // and we need to point the first argument directly
00614     GEOM::ListOfGO_var anArgs = new GEOM::ListOfGO;
00615     anArgs->length(1);
00616     anArgs[0] = myCurrObject.copy();
00617     getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs,
00618                                         /*theFindMethod=*/GEOM::FSM_Transformed,
00619                                         /*theInheritFirstArg=*/true,
00620                                         mainFrame()->CheckBoxAddPrefix->isChecked());
00621   }
00622 }
00623 
00624 //=================================================================================
00625 // function :  CreateCopyModeChanged()
00626 // purpose  :
00627 //=================================================================================
00628 void TransformationGUI_TranslationDlg::CreateCopyModeChanged()
00629 {
00630   mainFrame()->GroupBoxName->setEnabled(GroupPoints->CheckBox2->isChecked());
00631 }
00632 
00633 //=================================================================================
00634 // function :  ActivateDistanceChanged()
00635 // purpose  :
00636 //=================================================================================
00637 void TransformationGUI_TranslationDlg::ActivateDistanceChanged()
00638 {
00639   GroupPoints->SpinBox3->setEnabled( GroupPoints->CheckBox1->isChecked() );
00640   processPreview();
00641 }
00642 
00643 //=================================================================================
00644 // function : addSubshapeToStudy
00645 // purpose  : virtual method to add new SubObjects if local selection
00646 //=================================================================================
00647 void TransformationGUI_TranslationDlg::addSubshapesToStudy()
00648 {
00649   bool toCreateCopy = IsPreview() || GroupPoints->CheckBox2->isChecked();
00650   if (toCreateCopy) {
00651     switch (getConstructorId()) {
00652     case 1:
00653       GEOMBase::PublishSubObject( myPoint1.get() );
00654       GEOMBase::PublishSubObject( myPoint2.get() );
00655       break;
00656     case 2:
00657       GEOMBase::PublishSubObject( myVector.get() );
00658       break;
00659     default:
00660       break;
00661     }
00662   }
00663 }
00664 
00665 //=================================================================================
00666 // function : createPathPreview
00667 // purpose  :
00668 //=================================================================================
00669 void TransformationGUI_TranslationDlg::createPathPreview ( GEOM::GEOM_Object_ptr thePath )
00670 {
00671   if ( IsPreview() ) {
00672     TopoDS_Shape aShape;
00673     GEOMBase::GetShape( thePath, aShape, TopAbs_SHAPE );
00674     TopoDS_Edge anEdge = TopoDS::Edge( aShape );
00675     ShapeAnalysis_Edge aShapeAnal;
00676     TopoDS_Vertex aFirst = aShapeAnal.FirstVertex( anEdge );
00677     TopoDS_Vertex aLast = aShapeAnal.LastVertex( anEdge );
00678     TopoDS_Shape aVector = BRepBuilderAPI_MakeEdge(BRep_Tool::Pnt(aFirst), BRep_Tool::Pnt(aLast)).Shape();
00679     const char* aName = "tmpVector";
00680     Handle(GEOM_AISVector) anIO = new GEOM_AISVector( aVector, aName );
00681     
00682     // add Prs to preview
00683     SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
00684     SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
00685     if (aPrs)
00686       aPrs->AddObject(anIO);
00687     GEOMBase_Helper::displayPreview( aPrs, false, true );
00688   }
00689 }