1 // Copyright (C) 2007-2011 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 // File : TransformationGUI_MultiTranslationDlg.cxx
23 // Author : Damien COQUERET, Open CASCADE S.A.S.
25 #include "TransformationGUI_MultiTranslationDlg.h"
28 #include <GeometryGUI.h>
31 #include <SUIT_Session.h>
32 #include <SUIT_ResourceMgr.h>
33 #include <SUIT_Desktop.h>
34 #include <SUIT_ViewWindow.h>
35 #include <SUIT_ViewManager.h>
36 #include <SalomeApp_Application.h>
37 #include <LightApp_SelectionMgr.h>
38 #include <GEOM_AISVector.hxx>
40 #include <SOCC_ViewModel.h>
43 #include <TopoDS_Shape.hxx>
44 #include <TopoDS_Edge.hxx>
47 #include <TColStd_IndexedMapOfInteger.hxx>
48 #include <TopTools_IndexedMapOfShape.hxx>
49 #include <ShapeAnalysis_Edge.hxx>
50 #include <BRep_Tool.hxx>
51 #include <BRepBuilderAPI_MakeEdge.hxx>
52 #include <BRep_Builder.hxx>
54 #include <GEOMImpl_Types.hxx>
56 //=================================================================================
57 // class : TransformationGUI_MultiTranslationDlg()
58 // purpose : Constructs a TransformationGUI_MultiTranslationDlg which is a child of 'parent', with the
59 // name 'name' and widget flags set to 'f'.
60 // The dialog will by default be modeless, unless you set 'modal' to
61 // TRUE to construct a modal dialog.
62 //=================================================================================
63 TransformationGUI_MultiTranslationDlg::TransformationGUI_MultiTranslationDlg
64 (GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl)
65 : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
68 SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
69 QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MULTITRANSLATION_SIMPLE")));
70 QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MULTITRANSLATION_DOUBLE")));
71 QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
73 setWindowTitle(tr("GEOM_MULTITRANSLATION_TITLE"));
75 /***************************************************************/
76 mainFrame()->GroupConstructors->setTitle(tr("GEOM_MULTITRANSLATION"));
77 mainFrame()->RadioButton1->setIcon(image0);
78 mainFrame()->RadioButton2->setIcon(image1);
79 mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
80 mainFrame()->RadioButton3->close();
82 GroupPoints = new DlgRef_2Sel2Spin1Check(centralWidget());
83 GroupPoints->GroupBox1->setTitle(tr("GEOM_MULTITRANSLATION_SIMPLE"));
84 GroupPoints->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
85 GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR_U"));
86 GroupPoints->TextLabel3->setText(tr("GEOM_STEP_U"));
87 GroupPoints->TextLabel4->setText(tr("GEOM_NB_TIMES_U"));
88 GroupPoints->CheckButton1->setText(tr("GEOM_REVERSE_U"));
89 GroupPoints->PushButton1->setIcon(image2);
90 GroupPoints->PushButton2->setIcon(image2);
91 GroupPoints->LineEdit1->setReadOnly(true);
92 GroupPoints->LineEdit2->setReadOnly(true);
94 GroupDimensions = new DlgRef_3Sel4Spin2Check(centralWidget());
95 GroupDimensions->GroupBox1->setTitle(tr("GEOM_MULTITRANSLATION_DOUBLE"));
96 GroupDimensions->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
97 GroupDimensions->TextLabel2->setText(tr("GEOM_VECTOR_U"));
98 GroupDimensions->TextLabel3->setText(tr("GEOM_VECTOR_V"));
99 GroupDimensions->TextLabel4->setText(tr("GEOM_STEP_U"));
100 GroupDimensions->TextLabel5->setText(tr("GEOM_NB_TIMES_U"));
101 GroupDimensions->TextLabel6->setText(tr("GEOM_STEP_V"));
102 GroupDimensions->TextLabel7->setText(tr("GEOM_NB_TIMES_V"));
103 GroupDimensions->CheckButton1->setText(tr("GEOM_REVERSE_U"));
104 GroupDimensions->CheckButton2->setText(tr("GEOM_REVERSE_V"));
105 GroupDimensions->PushButton1->setIcon(image2);
106 GroupDimensions->PushButton2->setIcon(image2);
107 GroupDimensions->PushButton3->setIcon(image2);
108 GroupDimensions->LineEdit1->setReadOnly(true);
109 GroupDimensions->LineEdit2->setReadOnly(true);
110 GroupDimensions->LineEdit3->setReadOnly(true);
112 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
113 layout->setMargin(0); layout->setSpacing(6);
114 layout->addWidget(GroupPoints);
115 layout->addWidget(GroupDimensions);
116 /***************************************************************/
118 setHelpFileName("multi_translation_operation_page.html");
123 //=================================================================================
124 // function : ~TransformationGUI_MultiTranslationDlg()
125 // purpose : Destroys the object and frees any allocated resources
126 //=================================================================================
127 TransformationGUI_MultiTranslationDlg::~TransformationGUI_MultiTranslationDlg()
129 // no need to delete child widgets, Qt does it all for us
132 //=================================================================================
135 //=================================================================================
136 void TransformationGUI_MultiTranslationDlg::Init()
138 // Get setting of step value from file configuration
139 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
140 double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
142 int SpecificStep = 1;
144 myStepU = myStepV = 50.0;
145 myNbTimesU = myNbTimesV = 2;
147 // min, max, step and decimals for spin boxes & initial values
148 initSpinBox(GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
149 initSpinBox(GroupPoints->SpinBox_DY, 1, 999, SpecificStep);
150 GroupPoints->SpinBox_DX->setValue(myStepU);
151 GroupPoints->SpinBox_DY->setValue(myNbTimesU);
153 initSpinBox(GroupDimensions->SpinBox_DX1, COORD_MIN, COORD_MAX, step, "length_precision" );
154 initSpinBox(GroupDimensions->SpinBox_DY1, 1, 999, SpecificStep);
155 initSpinBox(GroupDimensions->SpinBox_DX2, COORD_MIN, COORD_MAX, step, "length_precision" );
156 initSpinBox(GroupDimensions->SpinBox_DY2, 1, 999, SpecificStep);
157 GroupDimensions->SpinBox_DX1->setValue(myStepU);
158 GroupDimensions->SpinBox_DY1->setValue(myNbTimesU);
159 GroupDimensions->SpinBox_DX2->setValue(myStepV);
160 GroupDimensions->SpinBox_DY2->setValue(myNbTimesV);
162 GroupPoints->LineEdit1->setText("");
163 GroupPoints->LineEdit2->setText("");
165 GroupDimensions->LineEdit1->setText("");
166 GroupDimensions->LineEdit2->setText("");
167 GroupDimensions->LineEdit3->setText("");
173 mainFrame()->GroupBoxPublish->show();
175 // signals and slots connections
176 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
177 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
179 connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
181 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
182 connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
183 connect(GroupDimensions->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
184 connect(GroupDimensions->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
185 connect(GroupDimensions->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
187 connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
188 connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
189 connect(GroupDimensions->SpinBox_DX1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
190 connect(GroupDimensions->SpinBox_DY1, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
191 connect(GroupDimensions->SpinBox_DX2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
192 connect(GroupDimensions->SpinBox_DY2, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
194 connect(GroupPoints->SpinBox_DX, SIGNAL(textChanged(const QString& )),
195 this, SLOT(TextValueChangedInSpinBox(const QString& )));
196 connect(GroupDimensions->SpinBox_DX1, SIGNAL(textChanged(const QString& )),
197 this, SLOT(TextValueChangedInSpinBox(const QString& )));
198 connect(GroupDimensions->SpinBox_DX2, SIGNAL(textChanged(const QString& )),
199 this, SLOT(TextValueChangedInSpinBox(const QString& )));
201 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
203 connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseStepU()));
204 connect(GroupDimensions->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseStepU()));
205 connect(GroupDimensions->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(ReverseStepV()));
207 initName(tr("GEOM_MULTITRANSLATION"));
209 ConstructorsClicked(0);
212 //=================================================================================
213 // function : SetDoubleSpinBoxStep()
214 // purpose : Double spin box management
215 //=================================================================================
216 void TransformationGUI_MultiTranslationDlg::SetDoubleSpinBoxStep (double step)
218 GroupPoints->SpinBox_DX->setSingleStep(step);
219 GroupDimensions->SpinBox_DX1->setSingleStep(step);
220 GroupDimensions->SpinBox_DX2->setSingleStep(step);
222 // san : Commented so as not to override specific step settings
223 //GroupPoints->SpinBox_DY->setSingleStep((int)step);
224 //GroupDimensions->SpinBox_DY1->setSingleStep((int)step);
225 //GroupDimensions->SpinBox_DY2->setSingleStep((int)step);
228 //=================================================================================
229 // function : ConstructorsClicked()
230 // purpose : Radio button management
231 //=================================================================================
232 void TransformationGUI_MultiTranslationDlg::ConstructorsClicked (int constructorId)
234 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
236 switch (constructorId) {
237 case 0: // Translate simple
239 GroupDimensions->hide();
242 GroupPoints->LineEdit1->setText("");
243 GroupPoints->LineEdit2->setText("");
247 GroupPoints->SpinBox_DX->setValue(myStepU);
248 GroupPoints->SpinBox_DY->setValue(myNbTimesU);
250 GroupPoints->PushButton1->click();
253 case 1: // Translate double
256 GroupDimensions->show();
258 GroupDimensions->LineEdit1->setText("");
259 GroupDimensions->LineEdit2->setText("");
260 GroupDimensions->LineEdit3->setText("");
265 GroupDimensions->SpinBox_DX1->setValue(myStepU);
266 GroupDimensions->SpinBox_DY1->setValue(myNbTimesU);
267 GroupDimensions->SpinBox_DX2->setValue(myStepV);
268 GroupDimensions->SpinBox_DY2->setValue(myNbTimesV);
270 GroupDimensions->PushButton1->click();
275 qApp->processEvents();
277 resize(minimumSizeHint());
281 SelectionIntoArgument();
288 //=================================================================================
289 // function : ClickOnOk()
291 //=================================================================================
292 void TransformationGUI_MultiTranslationDlg::ClickOnOk()
294 setIsApplyAndClose( true );
299 //=================================================================================
300 // function : ClickOnApply()
302 //=================================================================================
303 bool TransformationGUI_MultiTranslationDlg::ClickOnApply()
309 // activate selection and connect selection manager
310 ConstructorsClicked(getConstructorId());
314 //=================================================================================
315 // function : SelectionIntoArgument()
316 // purpose : Called when selection is changed or on dialog initialization or activation
317 //=================================================================================
318 void TransformationGUI_MultiTranslationDlg::SelectionIntoArgument()
322 TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPoints->LineEdit2 ||
323 myEditCurrentArgument == GroupDimensions->LineEdit2 ||
324 myEditCurrentArgument == GroupDimensions->LineEdit3 ) ?
325 TopAbs_EDGE : TopAbs_SHAPE;
326 GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
328 if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
329 QString aName = GEOMBase::GetName( aSelectedObject.get() );
330 myEditCurrentArgument->setText( aName );
331 if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
332 myBase = aSelectedObject;
334 GroupPoints->PushButton2->click();
336 else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
337 myVectorU = aSelectedObject;
339 GroupPoints->PushButton1->click();
341 else if ( myEditCurrentArgument == GroupDimensions->LineEdit1 ) {
342 myBase = aSelectedObject;
344 GroupDimensions->PushButton2->click();
345 else if ( !myVectorV )
346 GroupDimensions->PushButton3->click();
348 else if ( myEditCurrentArgument == GroupDimensions->LineEdit2 ) {
349 myVectorU = aSelectedObject;
351 GroupDimensions->PushButton3->click();
353 GroupDimensions->PushButton1->click();
355 else if ( myEditCurrentArgument == GroupDimensions->LineEdit3 ) {
356 myVectorV = aSelectedObject;
358 GroupDimensions->PushButton1->click();
359 else if ( !myVectorU )
360 GroupDimensions->PushButton2->click();
364 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
365 myGeomGUI->getApp()->selectionMgr()->clearSelected();
366 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
367 this, SLOT(SelectionIntoArgument()));
370 if ( myEditCurrentArgument == GroupPoints->LineEdit1 ||
371 myEditCurrentArgument == GroupDimensions->LineEdit1 )
373 else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ||
374 myEditCurrentArgument == GroupDimensions->LineEdit2 )
376 else if ( myEditCurrentArgument == GroupDimensions->LineEdit3 )
378 myEditCurrentArgument->setText("");
384 //=================================================================================
385 // function : SetEditCurrentArgument()
387 //=================================================================================
388 void TransformationGUI_MultiTranslationDlg::SetEditCurrentArgument()
390 QPushButton* send = (QPushButton*)sender();
392 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
393 globalSelection(GEOM_ALLSHAPES);
395 if (send == GroupPoints->PushButton1) {
396 myEditCurrentArgument = GroupPoints->LineEdit1;
398 GroupPoints->PushButton2->setDown(false);
399 GroupPoints->LineEdit2->setEnabled(false);
401 else if (send == GroupPoints->PushButton2) {
402 myEditCurrentArgument = GroupPoints->LineEdit2;
404 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
406 GroupPoints->PushButton1->setDown(false);
407 GroupPoints->LineEdit1->setEnabled(false);
409 else if (send == GroupDimensions->PushButton1) {
410 myEditCurrentArgument = GroupDimensions->LineEdit1;
412 GroupDimensions->PushButton2->setDown(false);
413 GroupDimensions->PushButton3->setDown(false);
414 GroupDimensions->LineEdit2->setEnabled(false);
415 GroupDimensions->LineEdit3->setEnabled(false);
417 else if (send == GroupDimensions->PushButton2) {
418 myEditCurrentArgument = GroupDimensions->LineEdit2;
420 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
422 GroupDimensions->PushButton1->setDown(false);
423 GroupDimensions->PushButton3->setDown(false);
424 GroupDimensions->LineEdit1->setEnabled(false);
425 GroupDimensions->LineEdit3->setEnabled(false);
427 else if (send == GroupDimensions->PushButton3) {
428 myEditCurrentArgument = GroupDimensions->LineEdit3;
430 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
432 GroupDimensions->PushButton1->setDown(false);
433 GroupDimensions->PushButton2->setDown(false);
434 GroupDimensions->LineEdit1->setEnabled(false);
435 GroupDimensions->LineEdit2->setEnabled(false);
437 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
438 this, SLOT(SelectionIntoArgument()));
441 myEditCurrentArgument->setEnabled(true);
442 myEditCurrentArgument->setFocus();
443 // after setFocus(), because it will be setDown(false) when loses focus
446 // seems we need it only to avoid preview disappearing, caused by selection mode change
450 //=================================================================================
451 // function : ActivateThisDialog()
453 //=================================================================================
454 void TransformationGUI_MultiTranslationDlg::ActivateThisDialog()
456 GEOMBase_Skeleton::ActivateThisDialog();
457 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
458 this, SLOT( SelectionIntoArgument() ) );
460 ConstructorsClicked( getConstructorId() );
463 //=================================================================================
464 // function : enterEvent()
466 //=================================================================================
467 void TransformationGUI_MultiTranslationDlg::enterEvent (QEvent*)
469 if (!mainFrame()->GroupConstructors->isEnabled())
470 ActivateThisDialog();
473 //=================================================================================
474 // function : TextValueChangedInSpinBox
476 //=================================================================================
477 void TransformationGUI_MultiTranslationDlg::TextValueChangedInSpinBox( const QString& s)
479 QObject* send = (QObject*)sender();
482 switch (getConstructorId()) {
484 GroupPoints->SpinBox_DX->text().toDouble(&isDigit);
486 GroupPoints->CheckButton1->setChecked(false);
488 GroupPoints->CheckButton1->setEnabled(isDigit);
491 if (send == GroupDimensions->SpinBox_DX1) {
492 GroupDimensions->SpinBox_DX1->text().toDouble(&isDigit);
494 GroupDimensions->CheckButton1->setChecked(false);
495 GroupDimensions->CheckButton1->setEnabled(isDigit);
497 else if(send == GroupDimensions->SpinBox_DX2){
498 GroupDimensions->SpinBox_DX2->text().toDouble(&isDigit);
500 GroupDimensions->CheckButton2->setChecked(false);
501 GroupDimensions->CheckButton2->setEnabled(isDigit);
507 //=================================================================================
508 // function : ValueChangedInSpinBox()
510 //=================================================================================
511 void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox (double newValue)
513 QObject* send = (QObject*)sender();
514 switch (getConstructorId()) {
516 if (send == GroupPoints->SpinBox_DX)
520 if (send == GroupDimensions->SpinBox_DX1)
522 else if (send == GroupDimensions->SpinBox_DX2)
530 //=================================================================================
531 // function : ValueChangedInSpinBox()
533 //=================================================================================
534 void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox (int newValue)
536 QObject* send = (QObject*)sender();
537 switch (getConstructorId()) {
539 if (send == GroupPoints->SpinBox_DY)
540 myNbTimesU = newValue;
543 if (send == GroupDimensions->SpinBox_DY1)
544 myNbTimesU = newValue;
545 else if (send == GroupDimensions->SpinBox_DY2)
546 myNbTimesV = newValue;
553 //=================================================================================
554 // function : ReverseStepU()
555 // purpose : 'state' not used here
556 //=================================================================================
557 void TransformationGUI_MultiTranslationDlg::ReverseStepU()
561 int aConstructorId = getConstructorId();
563 if (aConstructorId == 0)
564 GroupPoints->SpinBox_DX->setValue(myStepU);
565 else if (aConstructorId == 1)
566 GroupDimensions->SpinBox_DX1->setValue(myStepU);
571 //=================================================================================
572 // function : ReverseStepV
573 // purpose : 'state' not used here
574 //=================================================================================
575 void TransformationGUI_MultiTranslationDlg::ReverseStepV()
579 GroupDimensions->SpinBox_DX2->setValue(myStepV);
584 //=================================================================================
585 // function : createOperation
587 //=================================================================================
588 GEOM::GEOM_IOperations_ptr TransformationGUI_MultiTranslationDlg::createOperation()
590 return getGeomEngine()->GetITransformOperations(getStudyId());
593 //=================================================================================
594 // function : isValid
596 //=================================================================================
597 bool TransformationGUI_MultiTranslationDlg::isValid (QString& msg)
600 switch ( getConstructorId() ) {
602 ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) &&
603 GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) &&
607 ok = GroupDimensions->SpinBox_DX1->isValid( msg, !IsPreview() ) &&
608 GroupDimensions->SpinBox_DY1->isValid( msg, !IsPreview() ) &&
609 GroupDimensions->SpinBox_DX2->isValid( msg, !IsPreview() ) &&
610 GroupDimensions->SpinBox_DY2->isValid( msg, !IsPreview() ) &&
611 myBase && myVectorU && myVectorV;
619 //=================================================================================
620 // function : execute
622 //=================================================================================
623 bool TransformationGUI_MultiTranslationDlg::execute (ObjectList& objects)
627 GEOM::GEOM_Object_var anObj;
629 QStringList aParameters;
631 GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation());
633 switch (getConstructorId()) {
635 if ( myBase && myVectorU ) {
636 createPathPreview ( myVectorU.get() );
637 anObj = anOper->MultiTranslate1D(myBase.get(), myVectorU.get(), myStepU, myNbTimesU);
639 aParameters<<GroupPoints->SpinBox_DX->text();
640 aParameters<<GroupPoints->SpinBox_DY->text();
646 if ( myBase && myVectorU && myVectorV ) {
647 createPathPreview ( myVectorU.get() );
648 createPathPreview ( myVectorV.get() );
649 anObj = anOper->MultiTranslate2D(myBase.get(),
650 myVectorU.get(), myStepU, myNbTimesU,
651 myVectorV.get(), myStepV, myNbTimesV);
653 aParameters<<GroupDimensions->SpinBox_DX1->text();
654 aParameters<<GroupDimensions->SpinBox_DY1->text();
655 aParameters<<GroupDimensions->SpinBox_DX2->text();
656 aParameters<<GroupDimensions->SpinBox_DY2->text();
663 if (!anObj->_is_nil()) {
665 anObj->SetParameters(aParameters.join(":").toLatin1().constData());
666 objects.push_back(anObj._retn());
672 //=================================================================================
673 // function : addSubshapeToStudy
674 // purpose : virtual method to add new SubObjects if local selection
675 //=================================================================================
676 void TransformationGUI_MultiTranslationDlg::addSubshapesToStudy()
678 switch (getConstructorId()) {
680 GEOMBase::PublishSubObject( myVectorU.get() );
683 GEOMBase::PublishSubObject( myVectorU.get() );
684 GEOMBase::PublishSubObject( myVectorV.get() );
691 //=================================================================================
692 // function : restoreSubShapes
694 //=================================================================================
695 void TransformationGUI_MultiTranslationDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
696 SALOMEDS::SObject_ptr theSObject)
698 if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
699 // we pass here the first operation argument (object) through the list of arguments
700 // because the rotation operation place its arguments in the data structure in another order,
701 // and we need to point the first argument directly
702 GEOM::ListOfGO_var anArgs = new GEOM::ListOfGO;
704 anArgs[0] = myBase.copy();
705 getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs,
706 /*theFindMethod=*/GEOM::FSM_MultiTransformed,
707 /*theInheritFirstArg=*/true,
708 mainFrame()->CheckBoxAddPrefix->isChecked());
712 //=================================================================================
713 // function : createPathPreview
715 //=================================================================================
716 void TransformationGUI_MultiTranslationDlg::createPathPreview ( GEOM::GEOM_Object_ptr thePath )
720 GEOMBase::GetShape( thePath, aShape, TopAbs_SHAPE );
721 TopoDS_Edge anEdge = TopoDS::Edge( aShape );
722 ShapeAnalysis_Edge aShapeAnal;
723 TopoDS_Vertex aFirst = aShapeAnal.FirstVertex( anEdge );
724 TopoDS_Vertex aLast = aShapeAnal.LastVertex( anEdge );
725 TopoDS_Shape aVector = BRepBuilderAPI_MakeEdge(BRep_Tool::Pnt(aFirst), BRep_Tool::Pnt(aLast)).Shape();
726 const char* aName = "tmpVector";
727 Handle(GEOM_AISVector) anIO = new GEOM_AISVector( aVector, aName );
729 // add Prs to preview
730 SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
731 SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
733 aPrs->AddObject(anIO);
734 GEOMBase_Helper::displayPreview( aPrs, false, true );