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;
144 // min, max, step and decimals for spin boxes & initial values
145 initSpinBox(GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
146 initSpinBox(GroupPoints->SpinBox_DY, 1, 999, SpecificStep);
147 GroupPoints->SpinBox_DX->setValue(myStepU);
148 GroupPoints->SpinBox_DY->setValue(myNbTimesU);
150 initSpinBox(GroupDimensions->SpinBox_DX1, COORD_MIN, COORD_MAX, step, "length_precision" );
151 initSpinBox(GroupDimensions->SpinBox_DY1, 1, 999, SpecificStep);
152 initSpinBox(GroupDimensions->SpinBox_DX2, COORD_MIN, COORD_MAX, step, "length_precision" );
153 initSpinBox(GroupDimensions->SpinBox_DY2, 1, 999, SpecificStep);
154 GroupDimensions->SpinBox_DX1->setValue(myStepU);
155 GroupDimensions->SpinBox_DY1->setValue(myNbTimesU);
156 GroupDimensions->SpinBox_DX2->setValue(myStepV);
157 GroupDimensions->SpinBox_DY2->setValue(myNbTimesV);
160 myStepU = myStepV = 50.0;
161 myNbTimesU = myNbTimesV = 2;
163 GroupPoints->LineEdit1->setText("");
164 GroupPoints->LineEdit2->setText("");
166 GroupDimensions->LineEdit1->setText("");
167 GroupDimensions->LineEdit2->setText("");
168 GroupDimensions->LineEdit3->setText("");
170 myBase = myVectorU = myVectorV = GEOM::GEOM_Object::_nil();
172 mainFrame()->GroupBoxPublish->show();
174 // signals and slots connections
175 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
176 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
178 connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
180 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
181 connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
182 connect(GroupDimensions->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
183 connect(GroupDimensions->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
184 connect(GroupDimensions->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
186 connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
187 connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
188 connect(GroupDimensions->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
189 connect(GroupDimensions->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
190 connect(GroupDimensions->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
192 connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
193 connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
194 connect(GroupDimensions->SpinBox_DX1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
195 connect(GroupDimensions->SpinBox_DY1, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
196 connect(GroupDimensions->SpinBox_DX2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
197 connect(GroupDimensions->SpinBox_DY2, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
199 connect(GroupPoints->SpinBox_DX, SIGNAL(textChanged(const QString& )),
200 this, SLOT(TextValueChangedInSpinBox(const QString& )));
201 connect(GroupDimensions->SpinBox_DX1, SIGNAL(textChanged(const QString& )),
202 this, SLOT(TextValueChangedInSpinBox(const QString& )));
203 connect(GroupDimensions->SpinBox_DX2, SIGNAL(textChanged(const QString& )),
204 this, SLOT(TextValueChangedInSpinBox(const QString& )));
206 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
208 connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseStepU()));
209 connect(GroupDimensions->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseStepU()));
210 connect(GroupDimensions->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(ReverseStepV()));
212 initName(tr("GEOM_MULTITRANSLATION"));
214 ConstructorsClicked(0);
217 //=================================================================================
218 // function : SetDoubleSpinBoxStep()
219 // purpose : Double spin box management
220 //=================================================================================
221 void TransformationGUI_MultiTranslationDlg::SetDoubleSpinBoxStep (double step)
223 GroupPoints->SpinBox_DX->setSingleStep(step);
224 GroupDimensions->SpinBox_DX1->setSingleStep(step);
225 GroupDimensions->SpinBox_DX2->setSingleStep(step);
227 // san : Commented so as not to override specific step settings
228 //GroupPoints->SpinBox_DY->setSingleStep((int)step);
229 //GroupDimensions->SpinBox_DY1->setSingleStep((int)step);
230 //GroupDimensions->SpinBox_DY2->setSingleStep((int)step);
233 //=================================================================================
234 // function : ConstructorsClicked()
235 // purpose : Radio button management
236 //=================================================================================
237 void TransformationGUI_MultiTranslationDlg::ConstructorsClicked (int constructorId)
239 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
241 switch (constructorId) {
242 case 0: // Translate simple
244 GroupDimensions->hide();
247 GroupPoints->LineEdit1->setText("");
248 GroupPoints->LineEdit2->setText("");
249 myBase = myVectorU = GEOM::GEOM_Object::_nil();
251 GroupPoints->SpinBox_DX->setValue(myStepU);
252 GroupPoints->SpinBox_DY->setValue(myNbTimesU);
254 GroupPoints->PushButton1->click();
257 case 1: // Translate double
260 GroupDimensions->show();
262 GroupDimensions->LineEdit1->setText("");
263 GroupDimensions->LineEdit2->setText("");
264 GroupDimensions->LineEdit3->setText("");
265 myBase = myVectorU = myVectorV = GEOM::GEOM_Object::_nil();
267 GroupDimensions->SpinBox_DX1->setValue(myStepU);
268 GroupDimensions->SpinBox_DY1->setValue(myNbTimesU);
269 GroupDimensions->SpinBox_DX2->setValue(myStepV);
270 GroupDimensions->SpinBox_DY2->setValue(myNbTimesV);
272 GroupDimensions->PushButton1->click();
277 qApp->processEvents();
279 resize(minimumSizeHint());
283 SelectionIntoArgument();
290 //=================================================================================
291 // function : ClickOnOk()
293 //=================================================================================
294 void TransformationGUI_MultiTranslationDlg::ClickOnOk()
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()
322 myEditCurrentArgument->setText("");
324 if (myEditCurrentArgument == GroupPoints->LineEdit1 ||
325 myEditCurrentArgument == GroupDimensions->LineEdit1)
326 myBase = GEOM::GEOM_Object::_nil();
327 else if (myEditCurrentArgument == GroupPoints->LineEdit2 ||
328 myEditCurrentArgument == GroupDimensions->LineEdit2)
329 myVectorU = GEOM::GEOM_Object::_nil();
330 else if (myEditCurrentArgument == GroupDimensions->LineEdit3)
331 myVectorV = GEOM::GEOM_Object::_nil();
333 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
334 SALOME_ListIO aSelList;
335 aSelMgr->selectedObjects(aSelList);
337 if (aSelList.Extent() != 1)
341 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
343 if ( !GEOMBase::IsShape(aSelectedObject) )
346 QString aName = GEOMBase::GetName(aSelectedObject);
348 if (myEditCurrentArgument == GroupPoints->LineEdit1 ||
349 myEditCurrentArgument == GroupDimensions->LineEdit1)
350 myBase = aSelectedObject;
351 else if (myEditCurrentArgument == GroupPoints->LineEdit2 ||
352 myEditCurrentArgument == GroupDimensions->LineEdit2 ||
353 myEditCurrentArgument == GroupDimensions->LineEdit3) {
356 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) {
357 TColStd_IndexedMapOfInteger aMap;
358 aSelMgr->GetIndexes(aSelList.First(), aMap);
359 if (aMap.Extent() == 1) {
360 int anIndex = aMap(1);
361 aName += QString(":edge_%1").arg(anIndex);
363 //Find SubShape Object in Father
364 GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName);
366 if (aFindedObject->_is_nil()) { // Object not found in study
367 GEOM::GEOM_IShapesOperations_var aShapesOp =
368 getGeomEngine()->GetIShapesOperations(getStudyId());
369 if (myEditCurrentArgument == GroupDimensions->LineEdit3)
370 myVectorV = aShapesOp->GetSubShape(aSelectedObject, anIndex);
372 myVectorU = aShapesOp->GetSubShape(aSelectedObject, anIndex);
375 if (myEditCurrentArgument == GroupDimensions->LineEdit3)
376 myVectorV = aFindedObject;
378 myVectorU = aFindedObject;
382 if (aShape.ShapeType() != TopAbs_EDGE) {
383 aSelectedObject = GEOM::GEOM_Object::_nil();
386 if (myEditCurrentArgument == GroupDimensions->LineEdit3)
387 myVectorV = aSelectedObject;
389 myVectorU = aSelectedObject;
393 myEditCurrentArgument->setText(aName);
395 if (myEditCurrentArgument == GroupPoints->LineEdit1) {
396 if (!myBase->_is_nil() && myVectorU->_is_nil())
397 GroupPoints->PushButton2->click();
399 else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
400 if (!myVectorU->_is_nil() && myBase->_is_nil())
401 GroupPoints->PushButton1->click();
403 else if (myEditCurrentArgument == GroupDimensions->LineEdit1) {
404 if (!myBase->_is_nil() && myVectorU->_is_nil())
405 GroupDimensions->PushButton2->click();
407 else if (myEditCurrentArgument == GroupDimensions->LineEdit2) {
408 if (!myVectorU->_is_nil() && myVectorV->_is_nil())
409 GroupDimensions->PushButton3->click();
411 else if (myEditCurrentArgument == GroupDimensions->LineEdit3) {
412 if (!myVectorV->_is_nil() && myBase->_is_nil())
413 GroupDimensions->PushButton1->click();
417 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
418 myGeomGUI->getApp()->selectionMgr()->clearSelected();
419 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
420 this, SLOT(SelectionIntoArgument()));
425 //=================================================================================
426 // function : SetEditCurrentArgument()
428 //=================================================================================
429 void TransformationGUI_MultiTranslationDlg::SetEditCurrentArgument()
431 QPushButton* send = (QPushButton*)sender();
433 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
434 globalSelection(GEOM_ALLSHAPES);
436 if (send == GroupPoints->PushButton1) {
437 myEditCurrentArgument = GroupPoints->LineEdit1;
439 GroupPoints->PushButton2->setDown(false);
440 GroupPoints->LineEdit2->setEnabled(false);
442 else if (send == GroupPoints->PushButton2) {
443 myEditCurrentArgument = GroupPoints->LineEdit2;
445 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
447 GroupPoints->PushButton1->setDown(false);
448 GroupPoints->LineEdit1->setEnabled(false);
450 else if (send == GroupDimensions->PushButton1) {
451 myEditCurrentArgument = GroupDimensions->LineEdit1;
453 GroupDimensions->PushButton2->setDown(false);
454 GroupDimensions->PushButton3->setDown(false);
455 GroupDimensions->LineEdit2->setEnabled(false);
456 GroupDimensions->LineEdit3->setEnabled(false);
458 else if (send == GroupDimensions->PushButton2) {
459 myEditCurrentArgument = GroupDimensions->LineEdit2;
461 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
463 GroupDimensions->PushButton1->setDown(false);
464 GroupDimensions->PushButton3->setDown(false);
465 GroupDimensions->LineEdit1->setEnabled(false);
466 GroupDimensions->LineEdit3->setEnabled(false);
468 else if (send == GroupDimensions->PushButton3) {
469 myEditCurrentArgument = GroupDimensions->LineEdit3;
471 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
473 GroupDimensions->PushButton1->setDown(false);
474 GroupDimensions->PushButton2->setDown(false);
475 GroupDimensions->LineEdit1->setEnabled(false);
476 GroupDimensions->LineEdit2->setEnabled(false);
478 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
479 this, SLOT(SelectionIntoArgument()));
482 myEditCurrentArgument->setEnabled(true);
483 myEditCurrentArgument->setFocus();
484 // after setFocus(), because it will be setDown(false) when loses focus
487 // seems we need it only to avoid preview disappearing, caused by selection mode change
491 //=================================================================================
492 // function : LineEditReturnPressed()
494 //=================================================================================
495 void TransformationGUI_MultiTranslationDlg::LineEditReturnPressed()
497 QLineEdit* send = (QLineEdit*)sender();
498 if (send == GroupPoints->LineEdit1 || send == GroupDimensions->LineEdit1 ||
499 send == GroupPoints->LineEdit2 || send == GroupDimensions->LineEdit2 ||
500 send == GroupDimensions->LineEdit3) {
501 myEditCurrentArgument = send;
502 GEOMBase_Skeleton::LineEditReturnPressed();
506 //=================================================================================
507 // function : ActivateThisDialog()
509 //=================================================================================
510 void TransformationGUI_MultiTranslationDlg::ActivateThisDialog()
512 GEOMBase_Skeleton::ActivateThisDialog();
513 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
514 this, SLOT( SelectionIntoArgument() ) );
516 ConstructorsClicked( getConstructorId() );
519 //=================================================================================
520 // function : enterEvent()
522 //=================================================================================
523 void TransformationGUI_MultiTranslationDlg::enterEvent (QEvent*)
525 if (!mainFrame()->GroupConstructors->isEnabled())
526 ActivateThisDialog();
529 //=================================================================================
530 // function : TextValueChangedInSpinBox
532 //=================================================================================
533 void TransformationGUI_MultiTranslationDlg::TextValueChangedInSpinBox( const QString& s)
535 QObject* send = (QObject*)sender();
538 switch (getConstructorId()) {
540 GroupPoints->SpinBox_DX->text().toDouble(&isDigit);
542 GroupPoints->CheckButton1->setChecked(false);
544 GroupPoints->CheckButton1->setEnabled(isDigit);
547 if (send == GroupDimensions->SpinBox_DX1) {
548 GroupDimensions->SpinBox_DX1->text().toDouble(&isDigit);
550 GroupDimensions->CheckButton1->setChecked(false);
551 GroupDimensions->CheckButton1->setEnabled(isDigit);
553 else if(send == GroupDimensions->SpinBox_DX2){
554 GroupDimensions->SpinBox_DX2->text().toDouble(&isDigit);
556 GroupDimensions->CheckButton2->setChecked(false);
557 GroupDimensions->CheckButton2->setEnabled(isDigit);
563 //=================================================================================
564 // function : ValueChangedInSpinBox()
566 //=================================================================================
567 void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox (double newValue)
569 QObject* send = (QObject*)sender();
570 switch (getConstructorId()) {
572 if (send == GroupPoints->SpinBox_DX)
576 if (send == GroupDimensions->SpinBox_DX1)
578 else if (send == GroupDimensions->SpinBox_DX2)
586 //=================================================================================
587 // function : ValueChangedInSpinBox()
589 //=================================================================================
590 void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox (int newValue)
592 QObject* send = (QObject*)sender();
593 switch (getConstructorId()) {
595 if (send == GroupPoints->SpinBox_DY)
596 myNbTimesU = newValue;
599 if (send == GroupDimensions->SpinBox_DY1)
600 myNbTimesU = newValue;
601 else if (send == GroupDimensions->SpinBox_DY2)
602 myNbTimesV = newValue;
609 //=================================================================================
610 // function : ReverseStepU()
611 // purpose : 'state' not used here
612 //=================================================================================
613 void TransformationGUI_MultiTranslationDlg::ReverseStepU()
617 int aConstructorId = getConstructorId();
619 if (aConstructorId == 0)
620 GroupPoints->SpinBox_DX->setValue(myStepU);
621 else if (aConstructorId == 1)
622 GroupDimensions->SpinBox_DX1->setValue(myStepU);
627 //=================================================================================
628 // function : ReverseStepV
629 // purpose : 'state' not used here
630 //=================================================================================
631 void TransformationGUI_MultiTranslationDlg::ReverseStepV()
635 GroupDimensions->SpinBox_DX2->setValue(myStepV);
640 //=================================================================================
641 // function : createOperation
643 //=================================================================================
644 GEOM::GEOM_IOperations_ptr TransformationGUI_MultiTranslationDlg::createOperation()
646 return getGeomEngine()->GetITransformOperations(getStudyId());
649 //=================================================================================
650 // function : isValid
652 //=================================================================================
653 bool TransformationGUI_MultiTranslationDlg::isValid (QString& msg)
655 int aConstructorId = getConstructorId();
657 if (aConstructorId == 0) {
659 ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
660 ok = GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
661 return !(myBase->_is_nil() || myVectorU->_is_nil()) && ok;
663 else if (aConstructorId == 1) {
665 ok = GroupDimensions->SpinBox_DX1->isValid( msg, !IsPreview() ) && ok;
666 ok = GroupDimensions->SpinBox_DY1->isValid( msg, !IsPreview() ) && ok;
667 ok = GroupDimensions->SpinBox_DX2->isValid( msg, !IsPreview() ) && ok;
668 ok = GroupDimensions->SpinBox_DY2->isValid( msg, !IsPreview() ) && ok;
669 return !(myBase->_is_nil() || myVectorU->_is_nil() || myVectorV->_is_nil()) && ok;
674 //=================================================================================
675 // function : execute
677 //=================================================================================
678 bool TransformationGUI_MultiTranslationDlg::execute (ObjectList& objects)
682 GEOM::GEOM_Object_var anObj;
684 QStringList aParameters;
686 GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation());
688 switch (getConstructorId()) {
690 if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVectorU)) {
691 createPathPreview ( myVectorU );
692 anObj = anOper->MultiTranslate1D(myBase, myVectorU, myStepU, myNbTimesU);
694 aParameters<<GroupPoints->SpinBox_DX->text();
695 aParameters<<GroupPoints->SpinBox_DY->text();
701 if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVectorU) &&
702 !CORBA::is_nil(myVectorV)) {
703 createPathPreview ( myVectorU );
704 createPathPreview ( myVectorV );
705 anObj = anOper->MultiTranslate2D(myBase,
706 myVectorU, myStepU, myNbTimesU,
707 myVectorV, myStepV, myNbTimesV);
709 aParameters<<GroupDimensions->SpinBox_DX1->text();
710 aParameters<<GroupDimensions->SpinBox_DY1->text();
711 aParameters<<GroupDimensions->SpinBox_DX2->text();
712 aParameters<<GroupDimensions->SpinBox_DY2->text();
719 if (!anObj->_is_nil()) {
721 anObj->SetParameters(aParameters.join(":").toLatin1().constData());
722 objects.push_back(anObj._retn());
728 //=================================================================================
729 // function : addSubshapeToStudy
730 // purpose : virtual method to add new SubObjects if local selection
731 //=================================================================================
732 void TransformationGUI_MultiTranslationDlg::addSubshapesToStudy()
734 QMap<QString, GEOM::GEOM_Object_var> objMap;
736 switch (getConstructorId()) {
738 objMap[GroupPoints->LineEdit2->text()] = myVectorU;
741 objMap[GroupDimensions->LineEdit2->text()] = myVectorU;
742 objMap[GroupDimensions->LineEdit3->text()] = myVectorV;
745 addSubshapesToFather(objMap);
748 //=================================================================================
749 // function : restoreSubShapes
751 //=================================================================================
752 void TransformationGUI_MultiTranslationDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
753 SALOMEDS::SObject_ptr theSObject)
755 if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
756 // we pass here the first operation argument (object) through the list of arguments
757 // because the rotation operation place its arguments in the data structure in another order,
758 // and we need to point the first argument directly
759 GEOM::ListOfGO_var anArgs = new GEOM::ListOfGO;
762 getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs,
763 /*theFindMethod=*/GEOM::FSM_MultiTransformed,
764 /*theInheritFirstArg=*/true,
765 mainFrame()->CheckBoxAddPrefix->isChecked());
769 //=================================================================================
770 // function : createPathPreview
772 //=================================================================================
773 void TransformationGUI_MultiTranslationDlg::createPathPreview ( GEOM::GEOM_Object_var thePath )
777 GEOMBase::GetShape( thePath, aShape, TopAbs_SHAPE );
778 TopoDS_Edge anEdge = TopoDS::Edge( aShape );
779 ShapeAnalysis_Edge aShapeAnal;
780 TopoDS_Vertex aFirst = aShapeAnal.FirstVertex( anEdge );
781 TopoDS_Vertex aLast = aShapeAnal.LastVertex( anEdge );
782 TopoDS_Shape aVector = BRepBuilderAPI_MakeEdge(BRep_Tool::Pnt(aFirst), BRep_Tool::Pnt(aLast)).Shape();
783 const char* aName = "tmpVector";
784 Handle(GEOM_AISVector) anIO = new GEOM_AISVector( aVector, aName );
786 // add Prs to preview
787 SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
788 SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
790 aPrs->AddObject(anIO);
791 GEOMBase_Helper::displayPreview( aPrs, false, true );