1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // GEOM GEOMGUI : GUI for Geometry component
23 // File : TransformationGUI_MultiTranslationDlg.cxx
24 // Author : Damien COQUERET, Open CASCADE S.A.S.
26 #include "TransformationGUI_MultiTranslationDlg.h"
29 #include <GeometryGUI.h>
32 #include <SUIT_Session.h>
33 #include <SUIT_ResourceMgr.h>
34 #include <SUIT_Desktop.h>
35 #include <SUIT_ViewWindow.h>
36 #include <SUIT_ViewManager.h>
37 #include <SalomeApp_Application.h>
38 #include <LightApp_SelectionMgr.h>
39 #include <GEOM_AISVector.hxx>
41 #include <SOCC_ViewModel.h>
44 #include <TopoDS_Shape.hxx>
45 #include <TopoDS_Edge.hxx>
48 #include <TColStd_IndexedMapOfInteger.hxx>
49 #include <TopTools_IndexedMapOfShape.hxx>
50 #include <ShapeAnalysis_Edge.hxx>
51 #include <BRep_Tool.hxx>
52 #include <BRepBuilderAPI_MakeEdge.hxx>
53 #include <BRep_Builder.hxx>
55 #include <GEOMImpl_Types.hxx>
57 //=================================================================================
58 // class : TransformationGUI_MultiTranslationDlg()
59 // purpose : Constructs a TransformationGUI_MultiTranslationDlg which is a child of 'parent', with the
60 // name 'name' and widget flags set to 'f'.
61 // The dialog will by default be modeless, unless you set 'modal' to
62 // TRUE to construct a modal dialog.
63 //=================================================================================
64 TransformationGUI_MultiTranslationDlg::TransformationGUI_MultiTranslationDlg
65 (GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl)
66 : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
69 SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
70 QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MULTITRANSLATION_SIMPLE")));
71 QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MULTITRANSLATION_DOUBLE")));
72 QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
74 setWindowTitle(tr("GEOM_MULTITRANSLATION_TITLE"));
76 /***************************************************************/
77 mainFrame()->GroupConstructors->setTitle(tr("GEOM_MULTITRANSLATION"));
78 mainFrame()->RadioButton1->setIcon(image0);
79 mainFrame()->RadioButton2->setIcon(image1);
80 mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
81 mainFrame()->RadioButton3->close();
83 GroupPoints = new DlgRef_2Sel2Spin1Check(centralWidget());
84 GroupPoints->GroupBox1->setTitle(tr("GEOM_MULTITRANSLATION_SIMPLE"));
85 GroupPoints->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
86 GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR_U"));
87 GroupPoints->TextLabel3->setText(tr("GEOM_STEP_U"));
88 GroupPoints->TextLabel4->setText(tr("GEOM_NB_TIMES_U"));
89 GroupPoints->CheckButton1->setText(tr("GEOM_REVERSE_U"));
90 GroupPoints->PushButton1->setIcon(image2);
91 GroupPoints->PushButton2->setIcon(image2);
92 GroupPoints->LineEdit1->setReadOnly(true);
93 GroupPoints->LineEdit2->setReadOnly(true);
95 GroupDimensions = new DlgRef_3Sel4Spin2Check(centralWidget());
96 GroupDimensions->GroupBox1->setTitle(tr("GEOM_MULTITRANSLATION_DOUBLE"));
97 GroupDimensions->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
98 GroupDimensions->TextLabel2->setText(tr("GEOM_VECTOR_U"));
99 GroupDimensions->TextLabel3->setText(tr("GEOM_VECTOR_V"));
100 GroupDimensions->TextLabel4->setText(tr("GEOM_STEP_U"));
101 GroupDimensions->TextLabel5->setText(tr("GEOM_NB_TIMES_U"));
102 GroupDimensions->TextLabel6->setText(tr("GEOM_STEP_V"));
103 GroupDimensions->TextLabel7->setText(tr("GEOM_NB_TIMES_V"));
104 GroupDimensions->CheckButton1->setText(tr("GEOM_REVERSE_U"));
105 GroupDimensions->CheckButton2->setText(tr("GEOM_REVERSE_V"));
106 GroupDimensions->PushButton1->setIcon(image2);
107 GroupDimensions->PushButton2->setIcon(image2);
108 GroupDimensions->PushButton3->setIcon(image2);
109 GroupDimensions->LineEdit1->setReadOnly(true);
110 GroupDimensions->LineEdit2->setReadOnly(true);
111 GroupDimensions->LineEdit3->setReadOnly(true);
113 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
114 layout->setMargin(0); layout->setSpacing(6);
115 layout->addWidget(GroupPoints);
116 layout->addWidget(GroupDimensions);
117 /***************************************************************/
119 setHelpFileName("multi_translation_operation_page.html");
124 //=================================================================================
125 // function : ~TransformationGUI_MultiTranslationDlg()
126 // purpose : Destroys the object and frees any allocated resources
127 //=================================================================================
128 TransformationGUI_MultiTranslationDlg::~TransformationGUI_MultiTranslationDlg()
130 // no need to delete child widgets, Qt does it all for us
133 //=================================================================================
136 //=================================================================================
137 void TransformationGUI_MultiTranslationDlg::Init()
139 // Get setting of step value from file configuration
140 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
141 double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
143 int SpecificStep = 1;
145 myStepU = myStepV = 50.0;
146 myNbTimesU = myNbTimesV = 2;
148 // min, max, step and decimals for spin boxes & initial values
149 initSpinBox(GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
150 initSpinBox(GroupPoints->SpinBox_DY, 1, 999, SpecificStep);
151 GroupPoints->SpinBox_DX->setValue(myStepU);
152 GroupPoints->SpinBox_DY->setValue(myNbTimesU);
154 initSpinBox(GroupDimensions->SpinBox_DX1, COORD_MIN, COORD_MAX, step, "length_precision" );
155 initSpinBox(GroupDimensions->SpinBox_DY1, 1, 999, SpecificStep);
156 initSpinBox(GroupDimensions->SpinBox_DX2, COORD_MIN, COORD_MAX, step, "length_precision" );
157 initSpinBox(GroupDimensions->SpinBox_DY2, 1, 999, SpecificStep);
158 GroupDimensions->SpinBox_DX1->setValue(myStepU);
159 GroupDimensions->SpinBox_DY1->setValue(myNbTimesU);
160 GroupDimensions->SpinBox_DX2->setValue(myStepV);
161 GroupDimensions->SpinBox_DY2->setValue(myNbTimesV);
163 GroupPoints->LineEdit1->setText("");
164 GroupPoints->LineEdit2->setText("");
166 GroupDimensions->LineEdit1->setText("");
167 GroupDimensions->LineEdit2->setText("");
168 GroupDimensions->LineEdit3->setText("");
174 mainFrame()->GroupBoxPublish->show();
176 // signals and slots connections
177 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
178 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
180 connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
182 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
183 connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
184 connect(GroupDimensions->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
185 connect(GroupDimensions->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
186 connect(GroupDimensions->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
188 connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
189 connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
190 connect(GroupDimensions->SpinBox_DX1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
191 connect(GroupDimensions->SpinBox_DY1, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
192 connect(GroupDimensions->SpinBox_DX2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
193 connect(GroupDimensions->SpinBox_DY2, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
195 connect(GroupPoints->SpinBox_DX, SIGNAL(textChanged(const QString& )),
196 this, SLOT(TextValueChangedInSpinBox(const QString& )));
197 connect(GroupDimensions->SpinBox_DX1, SIGNAL(textChanged(const QString& )),
198 this, SLOT(TextValueChangedInSpinBox(const QString& )));
199 connect(GroupDimensions->SpinBox_DX2, SIGNAL(textChanged(const QString& )),
200 this, SLOT(TextValueChangedInSpinBox(const QString& )));
202 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
204 connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseStepU()));
205 connect(GroupDimensions->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseStepU()));
206 connect(GroupDimensions->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(ReverseStepV()));
208 initName(tr("GEOM_MULTITRANSLATION"));
210 ConstructorsClicked(0);
213 //=================================================================================
214 // function : SetDoubleSpinBoxStep()
215 // purpose : Double spin box management
216 //=================================================================================
217 void TransformationGUI_MultiTranslationDlg::SetDoubleSpinBoxStep (double step)
219 GroupPoints->SpinBox_DX->setSingleStep(step);
220 GroupDimensions->SpinBox_DX1->setSingleStep(step);
221 GroupDimensions->SpinBox_DX2->setSingleStep(step);
223 // san : Commented so as not to override specific step settings
224 //GroupPoints->SpinBox_DY->setSingleStep((int)step);
225 //GroupDimensions->SpinBox_DY1->setSingleStep((int)step);
226 //GroupDimensions->SpinBox_DY2->setSingleStep((int)step);
229 //=================================================================================
230 // function : ConstructorsClicked()
231 // purpose : Radio button management
232 //=================================================================================
233 void TransformationGUI_MultiTranslationDlg::ConstructorsClicked (int constructorId)
235 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
237 switch (constructorId) {
238 case 0: // Translate simple
240 GroupDimensions->hide();
243 GroupPoints->LineEdit1->setText("");
244 GroupPoints->LineEdit2->setText("");
248 GroupPoints->SpinBox_DX->setValue(myStepU);
249 GroupPoints->SpinBox_DY->setValue(myNbTimesU);
251 GroupPoints->PushButton1->click();
254 case 1: // Translate double
257 GroupDimensions->show();
259 GroupDimensions->LineEdit1->setText("");
260 GroupDimensions->LineEdit2->setText("");
261 GroupDimensions->LineEdit3->setText("");
266 GroupDimensions->SpinBox_DX1->setValue(myStepU);
267 GroupDimensions->SpinBox_DY1->setValue(myNbTimesU);
268 GroupDimensions->SpinBox_DX2->setValue(myStepV);
269 GroupDimensions->SpinBox_DY2->setValue(myNbTimesV);
271 GroupDimensions->PushButton1->click();
276 qApp->processEvents();
278 resize(minimumSizeHint());
282 SelectionIntoArgument();
289 //=================================================================================
290 // function : ClickOnOk()
292 //=================================================================================
293 void TransformationGUI_MultiTranslationDlg::ClickOnOk()
295 setIsApplyAndClose( true );
300 //=================================================================================
301 // function : ClickOnApply()
303 //=================================================================================
304 bool TransformationGUI_MultiTranslationDlg::ClickOnApply()
310 // activate selection and connect selection manager
311 ConstructorsClicked(getConstructorId());
315 //=================================================================================
316 // function : SelectionIntoArgument()
317 // purpose : Called when selection is changed or on dialog initialization or activation
318 //=================================================================================
319 void TransformationGUI_MultiTranslationDlg::SelectionIntoArgument()
323 TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPoints->LineEdit2 ||
324 myEditCurrentArgument == GroupDimensions->LineEdit2 ||
325 myEditCurrentArgument == GroupDimensions->LineEdit3 ) ?
326 TopAbs_EDGE : TopAbs_SHAPE;
327 GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
329 if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
330 QString aName = GEOMBase::GetName( aSelectedObject.get() );
331 myEditCurrentArgument->setText( aName );
332 if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
333 myBase = aSelectedObject;
335 GroupPoints->PushButton2->click();
337 else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
338 myVectorU = aSelectedObject;
340 GroupPoints->PushButton1->click();
342 else if ( myEditCurrentArgument == GroupDimensions->LineEdit1 ) {
343 myBase = aSelectedObject;
345 GroupDimensions->PushButton2->click();
346 else if ( !myVectorV )
347 GroupDimensions->PushButton3->click();
349 else if ( myEditCurrentArgument == GroupDimensions->LineEdit2 ) {
350 myVectorU = aSelectedObject;
352 GroupDimensions->PushButton3->click();
354 GroupDimensions->PushButton1->click();
356 else if ( myEditCurrentArgument == GroupDimensions->LineEdit3 ) {
357 myVectorV = aSelectedObject;
359 GroupDimensions->PushButton1->click();
360 else if ( !myVectorU )
361 GroupDimensions->PushButton2->click();
365 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
366 myGeomGUI->getApp()->selectionMgr()->clearSelected();
367 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
368 this, SLOT(SelectionIntoArgument()));
371 if ( myEditCurrentArgument == GroupPoints->LineEdit1 ||
372 myEditCurrentArgument == GroupDimensions->LineEdit1 )
374 else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ||
375 myEditCurrentArgument == GroupDimensions->LineEdit2 )
377 else if ( myEditCurrentArgument == GroupDimensions->LineEdit3 )
379 myEditCurrentArgument->setText("");
385 //=================================================================================
386 // function : SetEditCurrentArgument()
388 //=================================================================================
389 void TransformationGUI_MultiTranslationDlg::SetEditCurrentArgument()
391 QPushButton* send = (QPushButton*)sender();
393 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
394 globalSelection(GEOM_ALLSHAPES);
396 if (send == GroupPoints->PushButton1) {
397 myEditCurrentArgument = GroupPoints->LineEdit1;
399 GroupPoints->PushButton2->setDown(false);
400 GroupPoints->LineEdit2->setEnabled(false);
402 else if (send == GroupPoints->PushButton2) {
403 myEditCurrentArgument = GroupPoints->LineEdit2;
405 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
407 GroupPoints->PushButton1->setDown(false);
408 GroupPoints->LineEdit1->setEnabled(false);
410 else if (send == GroupDimensions->PushButton1) {
411 myEditCurrentArgument = GroupDimensions->LineEdit1;
413 GroupDimensions->PushButton2->setDown(false);
414 GroupDimensions->PushButton3->setDown(false);
415 GroupDimensions->LineEdit2->setEnabled(false);
416 GroupDimensions->LineEdit3->setEnabled(false);
418 else if (send == GroupDimensions->PushButton2) {
419 myEditCurrentArgument = GroupDimensions->LineEdit2;
421 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
423 GroupDimensions->PushButton1->setDown(false);
424 GroupDimensions->PushButton3->setDown(false);
425 GroupDimensions->LineEdit1->setEnabled(false);
426 GroupDimensions->LineEdit3->setEnabled(false);
428 else if (send == GroupDimensions->PushButton3) {
429 myEditCurrentArgument = GroupDimensions->LineEdit3;
431 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
433 GroupDimensions->PushButton1->setDown(false);
434 GroupDimensions->PushButton2->setDown(false);
435 GroupDimensions->LineEdit1->setEnabled(false);
436 GroupDimensions->LineEdit2->setEnabled(false);
438 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
439 this, SLOT(SelectionIntoArgument()));
442 myEditCurrentArgument->setEnabled(true);
443 myEditCurrentArgument->setFocus();
444 // after setFocus(), because it will be setDown(false) when loses focus
447 // seems we need it only to avoid preview disappearing, caused by selection mode change
451 //=================================================================================
452 // function : ActivateThisDialog()
454 //=================================================================================
455 void TransformationGUI_MultiTranslationDlg::ActivateThisDialog()
457 GEOMBase_Skeleton::ActivateThisDialog();
458 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
459 this, SLOT( SelectionIntoArgument() ) );
461 ConstructorsClicked( getConstructorId() );
464 //=================================================================================
465 // function : enterEvent()
467 //=================================================================================
468 void TransformationGUI_MultiTranslationDlg::enterEvent (QEvent*)
470 if (!mainFrame()->GroupConstructors->isEnabled())
471 ActivateThisDialog();
474 //=================================================================================
475 // function : TextValueChangedInSpinBox
477 //=================================================================================
478 void TransformationGUI_MultiTranslationDlg::TextValueChangedInSpinBox( const QString& s)
480 QObject* send = (QObject*)sender();
483 switch (getConstructorId()) {
485 GroupPoints->SpinBox_DX->text().toDouble(&isDigit);
487 GroupPoints->CheckButton1->setChecked(false);
489 GroupPoints->CheckButton1->setEnabled(isDigit);
492 if (send == GroupDimensions->SpinBox_DX1) {
493 GroupDimensions->SpinBox_DX1->text().toDouble(&isDigit);
495 GroupDimensions->CheckButton1->setChecked(false);
496 GroupDimensions->CheckButton1->setEnabled(isDigit);
498 else if(send == GroupDimensions->SpinBox_DX2){
499 GroupDimensions->SpinBox_DX2->text().toDouble(&isDigit);
501 GroupDimensions->CheckButton2->setChecked(false);
502 GroupDimensions->CheckButton2->setEnabled(isDigit);
508 //=================================================================================
509 // function : ValueChangedInSpinBox()
511 //=================================================================================
512 void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox (double newValue)
514 QObject* send = (QObject*)sender();
515 switch (getConstructorId()) {
517 if (send == GroupPoints->SpinBox_DX)
521 if (send == GroupDimensions->SpinBox_DX1)
523 else if (send == GroupDimensions->SpinBox_DX2)
531 //=================================================================================
532 // function : ValueChangedInSpinBox()
534 //=================================================================================
535 void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox (int newValue)
537 QObject* send = (QObject*)sender();
538 switch (getConstructorId()) {
540 if (send == GroupPoints->SpinBox_DY)
541 myNbTimesU = newValue;
544 if (send == GroupDimensions->SpinBox_DY1)
545 myNbTimesU = newValue;
546 else if (send == GroupDimensions->SpinBox_DY2)
547 myNbTimesV = newValue;
554 //=================================================================================
555 // function : ReverseStepU()
556 // purpose : 'state' not used here
557 //=================================================================================
558 void TransformationGUI_MultiTranslationDlg::ReverseStepU()
562 int aConstructorId = getConstructorId();
564 if (aConstructorId == 0)
565 GroupPoints->SpinBox_DX->setValue(myStepU);
566 else if (aConstructorId == 1)
567 GroupDimensions->SpinBox_DX1->setValue(myStepU);
572 //=================================================================================
573 // function : ReverseStepV
574 // purpose : 'state' not used here
575 //=================================================================================
576 void TransformationGUI_MultiTranslationDlg::ReverseStepV()
580 GroupDimensions->SpinBox_DX2->setValue(myStepV);
585 //=================================================================================
586 // function : createOperation
588 //=================================================================================
589 GEOM::GEOM_IOperations_ptr TransformationGUI_MultiTranslationDlg::createOperation()
591 return getGeomEngine()->GetITransformOperations(getStudyId());
594 //=================================================================================
595 // function : isValid
597 //=================================================================================
598 bool TransformationGUI_MultiTranslationDlg::isValid (QString& msg)
601 switch ( getConstructorId() ) {
603 ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) &&
604 GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) &&
608 ok = GroupDimensions->SpinBox_DX1->isValid( msg, !IsPreview() ) &&
609 GroupDimensions->SpinBox_DY1->isValid( msg, !IsPreview() ) &&
610 GroupDimensions->SpinBox_DX2->isValid( msg, !IsPreview() ) &&
611 GroupDimensions->SpinBox_DY2->isValid( msg, !IsPreview() ) &&
612 myBase && myVectorU && myVectorV;
620 //=================================================================================
621 // function : execute
623 //=================================================================================
624 bool TransformationGUI_MultiTranslationDlg::execute (ObjectList& objects)
628 GEOM::GEOM_Object_var anObj;
630 QStringList aParameters;
632 GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation());
634 switch (getConstructorId()) {
636 if ( myBase && myVectorU ) {
637 createPathPreview ( myVectorU.get() );
638 anObj = anOper->MultiTranslate1D(myBase.get(), myVectorU.get(), myStepU, myNbTimesU);
640 aParameters<<GroupPoints->SpinBox_DX->text();
641 aParameters<<GroupPoints->SpinBox_DY->text();
647 if ( myBase && myVectorU && myVectorV ) {
648 createPathPreview ( myVectorU.get() );
649 createPathPreview ( myVectorV.get() );
650 anObj = anOper->MultiTranslate2D(myBase.get(),
651 myVectorU.get(), myStepU, myNbTimesU,
652 myVectorV.get(), myStepV, myNbTimesV);
654 aParameters<<GroupDimensions->SpinBox_DX1->text();
655 aParameters<<GroupDimensions->SpinBox_DY1->text();
656 aParameters<<GroupDimensions->SpinBox_DX2->text();
657 aParameters<<GroupDimensions->SpinBox_DY2->text();
664 if (!anObj->_is_nil()) {
666 anObj->SetParameters(aParameters.join(":").toLatin1().constData());
667 objects.push_back(anObj._retn());
673 //=================================================================================
674 // function : addSubshapeToStudy
675 // purpose : virtual method to add new SubObjects if local selection
676 //=================================================================================
677 void TransformationGUI_MultiTranslationDlg::addSubshapesToStudy()
679 switch (getConstructorId()) {
681 GEOMBase::PublishSubObject( myVectorU.get() );
684 GEOMBase::PublishSubObject( myVectorU.get() );
685 GEOMBase::PublishSubObject( myVectorV.get() );
692 //=================================================================================
693 // function : restoreSubShapes
695 //=================================================================================
696 void TransformationGUI_MultiTranslationDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
697 SALOMEDS::SObject_ptr theSObject)
699 if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
700 // we pass here the first operation argument (object) through the list of arguments
701 // because the rotation operation place its arguments in the data structure in another order,
702 // and we need to point the first argument directly
703 GEOM::ListOfGO_var anArgs = new GEOM::ListOfGO;
705 anArgs[0] = myBase.copy();
706 getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs,
707 /*theFindMethod=*/GEOM::FSM_MultiTransformed,
708 /*theInheritFirstArg=*/true,
709 mainFrame()->CheckBoxAddPrefix->isChecked());
713 //=================================================================================
714 // function : createPathPreview
716 //=================================================================================
717 void TransformationGUI_MultiTranslationDlg::createPathPreview ( GEOM::GEOM_Object_ptr thePath )
721 GEOMBase::GetShape( thePath, aShape, TopAbs_SHAPE );
722 TopoDS_Edge anEdge = TopoDS::Edge( aShape );
723 ShapeAnalysis_Edge aShapeAnal;
724 TopoDS_Vertex aFirst = aShapeAnal.FirstVertex( anEdge );
725 TopoDS_Vertex aLast = aShapeAnal.LastVertex( anEdge );
726 TopoDS_Shape aVector = BRepBuilderAPI_MakeEdge(BRep_Tool::Pnt(aFirst), BRep_Tool::Pnt(aLast)).Shape();
727 const char* aName = "tmpVector";
728 Handle(GEOM_AISVector) anIO = new GEOM_AISVector( aVector, aName );
730 // add Prs to preview
731 SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
732 SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
734 aPrs->AddObject(anIO);
735 GEOMBase_Helper::displayPreview( aPrs, false, true );