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
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : TransformationGUI_MultiTranslationDlg.cxx
25 // Author : Damien COQUERET, Open CASCADE S.A.S.
27 #include "TransformationGUI_MultiTranslationDlg.h"
30 #include <GeometryGUI.h>
33 #include <SUIT_Session.h>
34 #include <SUIT_ResourceMgr.h>
35 #include <SalomeApp_Application.h>
36 #include <LightApp_SelectionMgr.h>
39 #include <TopoDS_Shape.hxx>
40 #include <TopoDS_Edge.hxx>
43 #include <TColStd_IndexedMapOfInteger.hxx>
44 #include <TopTools_IndexedMapOfShape.hxx>
46 #include <GEOMImpl_Types.hxx>
48 //=================================================================================
49 // class : TransformationGUI_MultiTranslationDlg()
50 // purpose : Constructs a TransformationGUI_MultiTranslationDlg which is a child of 'parent', with the
51 // name 'name' and widget flags set to 'f'.
52 // The dialog will by default be modeless, unless you set 'modal' to
53 // TRUE to construct a modal dialog.
54 //=================================================================================
55 TransformationGUI_MultiTranslationDlg::TransformationGUI_MultiTranslationDlg
56 (GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl)
57 : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
60 SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
61 QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MULTITRANSLATION_SIMPLE")));
62 QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MULTITRANSLATION_DOUBLE")));
63 QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
65 setWindowTitle(tr("GEOM_MULTITRANSLATION_TITLE"));
67 /***************************************************************/
68 mainFrame()->GroupConstructors->setTitle(tr("GEOM_MULTITRANSLATION"));
69 mainFrame()->RadioButton1->setIcon(image0);
70 mainFrame()->RadioButton2->setIcon(image1);
71 mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
72 mainFrame()->RadioButton3->close();
74 GroupPoints = new DlgRef_2Sel2Spin1Check(centralWidget());
75 GroupPoints->GroupBox1->setTitle(tr("GEOM_MULTITRANSLATION_SIMPLE"));
76 GroupPoints->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
77 GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR_U"));
78 GroupPoints->TextLabel3->setText(tr("GEOM_STEP_U"));
79 GroupPoints->TextLabel4->setText(tr("GEOM_NB_TIMES_U"));
80 GroupPoints->CheckButton1->setText(tr("GEOM_REVERSE_U"));
81 GroupPoints->PushButton1->setIcon(image2);
82 GroupPoints->PushButton2->setIcon(image2);
83 GroupPoints->LineEdit1->setReadOnly(true);
84 GroupPoints->LineEdit2->setReadOnly(true);
86 GroupDimensions = new DlgRef_3Sel4Spin2Check(centralWidget());
87 GroupDimensions->GroupBox1->setTitle(tr("GEOM_MULTITRANSLATION_DOUBLE"));
88 GroupDimensions->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
89 GroupDimensions->TextLabel2->setText(tr("GEOM_VECTOR_U"));
90 GroupDimensions->TextLabel3->setText(tr("GEOM_VECTOR_V"));
91 GroupDimensions->TextLabel4->setText(tr("GEOM_STEP_U"));
92 GroupDimensions->TextLabel5->setText(tr("GEOM_NB_TIMES_U"));
93 GroupDimensions->TextLabel6->setText(tr("GEOM_STEP_V"));
94 GroupDimensions->TextLabel7->setText(tr("GEOM_NB_TIMES_V"));
95 GroupDimensions->CheckButton1->setText(tr("GEOM_REVERSE_U"));
96 GroupDimensions->CheckButton2->setText(tr("GEOM_REVERSE_V"));
97 GroupDimensions->PushButton1->setIcon(image2);
98 GroupDimensions->PushButton2->setIcon(image2);
99 GroupDimensions->PushButton3->setIcon(image2);
100 GroupDimensions->LineEdit1->setReadOnly(true);
101 GroupDimensions->LineEdit2->setReadOnly(true);
102 GroupDimensions->LineEdit3->setReadOnly(true);
104 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
105 layout->setMargin(0); layout->setSpacing(6);
106 layout->addWidget(GroupPoints);
107 layout->addWidget(GroupDimensions);
108 /***************************************************************/
110 setHelpFileName("multi_translation_operation_page.html");
115 //=================================================================================
116 // function : ~TransformationGUI_MultiTranslationDlg()
117 // purpose : Destroys the object and frees any allocated resources
118 //=================================================================================
119 TransformationGUI_MultiTranslationDlg::~TransformationGUI_MultiTranslationDlg()
121 // no need to delete child widgets, Qt does it all for us
124 //=================================================================================
127 //=================================================================================
128 void TransformationGUI_MultiTranslationDlg::Init()
130 // Get setting of step value from file configuration
131 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
132 double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
134 int SpecificStep = 1;
135 // min, max, step and decimals for spin boxes & initial values
136 initSpinBox(GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
137 initSpinBox(GroupPoints->SpinBox_DY, 1, 999, SpecificStep);
138 GroupPoints->SpinBox_DX->setValue(myStepU);
139 GroupPoints->SpinBox_DY->setValue(myNbTimesU);
141 initSpinBox(GroupDimensions->SpinBox_DX1, COORD_MIN, COORD_MAX, step, "length_precision" );
142 initSpinBox(GroupDimensions->SpinBox_DY1, 1, 999, SpecificStep);
143 initSpinBox(GroupDimensions->SpinBox_DX2, COORD_MIN, COORD_MAX, step, "length_precision" );
144 initSpinBox(GroupDimensions->SpinBox_DY2, 1, 999, SpecificStep);
145 GroupDimensions->SpinBox_DX1->setValue(myStepU);
146 GroupDimensions->SpinBox_DY1->setValue(myNbTimesU);
147 GroupDimensions->SpinBox_DX2->setValue(myStepV);
148 GroupDimensions->SpinBox_DY2->setValue(myNbTimesV);
151 myStepU = myStepV = 50.0;
152 myNbTimesU = myNbTimesV = 2;
154 GroupPoints->LineEdit1->setText("");
155 GroupPoints->LineEdit2->setText("");
157 GroupDimensions->LineEdit1->setText("");
158 GroupDimensions->LineEdit2->setText("");
159 GroupDimensions->LineEdit3->setText("");
161 myBase = myVectorU = myVectorV = GEOM::GEOM_Object::_nil();
163 // signals and slots connections
164 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
165 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
167 connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
169 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
170 connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
171 connect(GroupDimensions->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
172 connect(GroupDimensions->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
173 connect(GroupDimensions->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
175 connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
176 connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
177 connect(GroupDimensions->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
178 connect(GroupDimensions->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
179 connect(GroupDimensions->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
181 connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
182 connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
183 connect(GroupDimensions->SpinBox_DX1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
184 connect(GroupDimensions->SpinBox_DY1, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
185 connect(GroupDimensions->SpinBox_DX2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
186 connect(GroupDimensions->SpinBox_DY2, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
188 connect(GroupPoints->SpinBox_DX, SIGNAL(textChanged(const QString& )),
189 this, SLOT(TextValueChangedInSpinBox(const QString& )));
190 connect(GroupDimensions->SpinBox_DX1, SIGNAL(textChanged(const QString& )),
191 this, SLOT(TextValueChangedInSpinBox(const QString& )));
192 connect(GroupDimensions->SpinBox_DX2, SIGNAL(textChanged(const QString& )),
193 this, SLOT(TextValueChangedInSpinBox(const QString& )));
195 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
197 connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseStepU()));
198 connect(GroupDimensions->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseStepU()));
199 connect(GroupDimensions->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(ReverseStepV()));
201 initName(tr("GEOM_MULTITRANSLATION"));
203 ConstructorsClicked(0);
206 //=================================================================================
207 // function : SetDoubleSpinBoxStep()
208 // purpose : Double spin box management
209 //=================================================================================
210 void TransformationGUI_MultiTranslationDlg::SetDoubleSpinBoxStep (double step)
212 GroupPoints->SpinBox_DX->setSingleStep(step);
213 GroupDimensions->SpinBox_DX1->setSingleStep(step);
214 GroupDimensions->SpinBox_DX2->setSingleStep(step);
216 // san : Commented so as not to override specific step settings
217 //GroupPoints->SpinBox_DY->setSingleStep((int)step);
218 //GroupDimensions->SpinBox_DY1->setSingleStep((int)step);
219 //GroupDimensions->SpinBox_DY2->setSingleStep((int)step);
222 //=================================================================================
223 // function : ConstructorsClicked()
224 // purpose : Radio button management
225 //=================================================================================
226 void TransformationGUI_MultiTranslationDlg::ConstructorsClicked (int constructorId)
228 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
230 switch (constructorId) {
231 case 0: // Translate simple
233 GroupDimensions->hide();
236 GroupPoints->LineEdit1->setText("");
237 GroupPoints->LineEdit2->setText("");
238 myBase = myVectorU = GEOM::GEOM_Object::_nil();
240 GroupPoints->SpinBox_DX->setValue(myStepU);
241 GroupPoints->SpinBox_DY->setValue(myNbTimesU);
243 GroupPoints->PushButton1->click();
246 case 1: // Translate double
249 GroupDimensions->show();
251 GroupDimensions->LineEdit1->setText("");
252 GroupDimensions->LineEdit2->setText("");
253 GroupDimensions->LineEdit3->setText("");
254 myBase = myVectorU = myVectorV = GEOM::GEOM_Object::_nil();
256 GroupDimensions->SpinBox_DX1->setValue(myStepU);
257 GroupDimensions->SpinBox_DY1->setValue(myNbTimesU);
258 GroupDimensions->SpinBox_DX2->setValue(myStepV);
259 GroupDimensions->SpinBox_DY2->setValue(myNbTimesV);
261 GroupDimensions->PushButton1->click();
266 qApp->processEvents();
268 resize(minimumSizeHint());
272 SelectionIntoArgument();
279 //=================================================================================
280 // function : ClickOnOk()
282 //=================================================================================
283 void TransformationGUI_MultiTranslationDlg::ClickOnOk()
289 //=================================================================================
290 // function : ClickOnApply()
292 //=================================================================================
293 bool TransformationGUI_MultiTranslationDlg::ClickOnApply()
299 // activate selection and connect selection manager
300 ConstructorsClicked(getConstructorId());
304 //=================================================================================
305 // function : SelectionIntoArgument()
306 // purpose : Called when selection is changed or on dialog initialization or activation
307 //=================================================================================
308 void TransformationGUI_MultiTranslationDlg::SelectionIntoArgument()
311 myEditCurrentArgument->setText("");
313 if (myEditCurrentArgument == GroupPoints->LineEdit1 ||
314 myEditCurrentArgument == GroupDimensions->LineEdit1)
315 myBase = GEOM::GEOM_Object::_nil();
316 else if (myEditCurrentArgument == GroupPoints->LineEdit2 ||
317 myEditCurrentArgument == GroupDimensions->LineEdit2)
318 myVectorU = GEOM::GEOM_Object::_nil();
319 else if (myEditCurrentArgument == GroupDimensions->LineEdit3)
320 myVectorV = GEOM::GEOM_Object::_nil();
322 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
323 SALOME_ListIO aSelList;
324 aSelMgr->selectedObjects(aSelList);
326 if (aSelList.Extent() != 1)
330 Standard_Boolean testResult = Standard_False;;
331 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
333 if (!testResult || CORBA::is_nil(aSelectedObject) || !GEOMBase::IsShape(aSelectedObject))
336 QString aName = GEOMBase::GetName(aSelectedObject);
338 if (myEditCurrentArgument == GroupPoints->LineEdit1 ||
339 myEditCurrentArgument == GroupDimensions->LineEdit1)
340 myBase = aSelectedObject;
341 else if (myEditCurrentArgument == GroupPoints->LineEdit2 ||
342 myEditCurrentArgument == GroupDimensions->LineEdit2 ||
343 myEditCurrentArgument == GroupDimensions->LineEdit3) {
346 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) {
347 TColStd_IndexedMapOfInteger aMap;
348 aSelMgr->GetIndexes(aSelList.First(), aMap);
349 if (aMap.Extent() == 1) {
350 int anIndex = aMap(1);
351 aName += QString(":edge_%1").arg(anIndex);
353 //Find SubShape Object in Father
354 GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName);
356 if (aFindedObject->_is_nil()) { // Object not found in study
357 GEOM::GEOM_IShapesOperations_var aShapesOp =
358 getGeomEngine()->GetIShapesOperations(getStudyId());
359 if (myEditCurrentArgument == GroupDimensions->LineEdit3)
360 myVectorV = aShapesOp->GetSubShape(aSelectedObject, anIndex);
362 myVectorU = aShapesOp->GetSubShape(aSelectedObject, anIndex);
365 if (myEditCurrentArgument == GroupDimensions->LineEdit3)
366 myVectorV = aFindedObject;
368 myVectorU = aFindedObject;
372 if (aShape.ShapeType() != TopAbs_EDGE) {
373 aSelectedObject = GEOM::GEOM_Object::_nil();
376 if (myEditCurrentArgument == GroupDimensions->LineEdit3)
377 myVectorV = aSelectedObject;
379 myVectorU = aSelectedObject;
383 myEditCurrentArgument->setText(aName);
385 if (myEditCurrentArgument == GroupPoints->LineEdit1) {
386 if (!myBase->_is_nil() && myVectorU->_is_nil())
387 GroupPoints->PushButton2->click();
389 else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
390 if (!myVectorU->_is_nil() && myBase->_is_nil())
391 GroupPoints->PushButton1->click();
393 else if (myEditCurrentArgument == GroupDimensions->LineEdit1) {
394 if (!myBase->_is_nil() && myVectorU->_is_nil())
395 GroupDimensions->PushButton2->click();
397 else if (myEditCurrentArgument == GroupDimensions->LineEdit2) {
398 if (!myVectorU->_is_nil() && myVectorV->_is_nil())
399 GroupDimensions->PushButton3->click();
401 else if (myEditCurrentArgument == GroupDimensions->LineEdit3) {
402 if (!myVectorV->_is_nil() && myBase->_is_nil())
403 GroupDimensions->PushButton1->click();
407 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
408 myGeomGUI->getApp()->selectionMgr()->clearSelected();
409 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
410 this, SLOT(SelectionIntoArgument()));
415 //=================================================================================
416 // function : SetEditCurrentArgument()
418 //=================================================================================
419 void TransformationGUI_MultiTranslationDlg::SetEditCurrentArgument()
421 QPushButton* send = (QPushButton*)sender();
423 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
424 globalSelection(GEOM_ALLSHAPES);
426 if (send == GroupPoints->PushButton1) {
427 myEditCurrentArgument = GroupPoints->LineEdit1;
429 GroupPoints->PushButton2->setDown(false);
430 GroupPoints->LineEdit2->setEnabled(false);
432 else if (send == GroupPoints->PushButton2) {
433 myEditCurrentArgument = GroupPoints->LineEdit2;
435 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
437 GroupPoints->PushButton1->setDown(false);
438 GroupPoints->LineEdit1->setEnabled(false);
440 else if (send == GroupDimensions->PushButton1) {
441 myEditCurrentArgument = GroupDimensions->LineEdit1;
443 GroupDimensions->PushButton2->setDown(false);
444 GroupDimensions->PushButton3->setDown(false);
445 GroupDimensions->LineEdit2->setEnabled(false);
446 GroupDimensions->LineEdit3->setEnabled(false);
448 else if (send == GroupDimensions->PushButton2) {
449 myEditCurrentArgument = GroupDimensions->LineEdit2;
451 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
453 GroupDimensions->PushButton1->setDown(false);
454 GroupDimensions->PushButton3->setDown(false);
455 GroupDimensions->LineEdit1->setEnabled(false);
456 GroupDimensions->LineEdit3->setEnabled(false);
458 else if (send == GroupDimensions->PushButton3) {
459 myEditCurrentArgument = GroupDimensions->LineEdit3;
461 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
463 GroupDimensions->PushButton1->setDown(false);
464 GroupDimensions->PushButton2->setDown(false);
465 GroupDimensions->LineEdit1->setEnabled(false);
466 GroupDimensions->LineEdit2->setEnabled(false);
468 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
469 this, SLOT(SelectionIntoArgument()));
472 myEditCurrentArgument->setEnabled(true);
473 myEditCurrentArgument->setFocus();
474 // after setFocus(), because it will be setDown(false) when loses focus
477 // seems we need it only to avoid preview disappearing, caused by selection mode change
481 //=================================================================================
482 // function : LineEditReturnPressed()
484 //=================================================================================
485 void TransformationGUI_MultiTranslationDlg::LineEditReturnPressed()
487 QLineEdit* send = (QLineEdit*)sender();
488 if (send == GroupPoints->LineEdit1 || send == GroupDimensions->LineEdit1 ||
489 send == GroupPoints->LineEdit2 || send == GroupDimensions->LineEdit2 ||
490 send == GroupDimensions->LineEdit3) {
491 myEditCurrentArgument = send;
492 GEOMBase_Skeleton::LineEditReturnPressed();
496 //=================================================================================
497 // function : ActivateThisDialog()
499 //=================================================================================
500 void TransformationGUI_MultiTranslationDlg::ActivateThisDialog()
502 GEOMBase_Skeleton::ActivateThisDialog();
503 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
504 this, SLOT( SelectionIntoArgument() ) );
506 ConstructorsClicked( getConstructorId() );
509 //=================================================================================
510 // function : enterEvent()
512 //=================================================================================
513 void TransformationGUI_MultiTranslationDlg::enterEvent (QEvent*)
515 if (!mainFrame()->GroupConstructors->isEnabled())
516 ActivateThisDialog();
519 //=================================================================================
520 // function : TextValueChangedInSpinBox
522 //=================================================================================
523 void TransformationGUI_MultiTranslationDlg::TextValueChangedInSpinBox( const QString& s)
525 QObject* send = (QObject*)sender();
528 switch (getConstructorId()) {
530 GroupPoints->SpinBox_DX->text().toDouble(&isDigit);
532 GroupPoints->CheckButton1->setChecked(false);
534 GroupPoints->CheckButton1->setEnabled(isDigit);
537 if (send == GroupDimensions->SpinBox_DX1) {
538 GroupDimensions->SpinBox_DX1->text().toDouble(&isDigit);
540 GroupDimensions->CheckButton1->setChecked(false);
541 GroupDimensions->CheckButton1->setEnabled(isDigit);
543 else if(send == GroupDimensions->SpinBox_DX2){
544 GroupDimensions->SpinBox_DX2->text().toDouble(&isDigit);
546 GroupDimensions->CheckButton2->setChecked(false);
547 GroupDimensions->CheckButton2->setEnabled(isDigit);
553 //=================================================================================
554 // function : ValueChangedInSpinBox()
556 //=================================================================================
557 void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox (double newValue)
559 QObject* send = (QObject*)sender();
560 switch (getConstructorId()) {
562 if (send == GroupPoints->SpinBox_DX)
566 if (send == GroupDimensions->SpinBox_DX1)
568 else if (send == GroupDimensions->SpinBox_DX2)
576 //=================================================================================
577 // function : ValueChangedInSpinBox()
579 //=================================================================================
580 void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox (int newValue)
582 QObject* send = (QObject*)sender();
583 switch (getConstructorId()) {
585 if (send == GroupPoints->SpinBox_DY)
586 myNbTimesU = newValue;
589 if (send == GroupDimensions->SpinBox_DY1)
590 myNbTimesU = newValue;
591 else if (send == GroupDimensions->SpinBox_DY2)
592 myNbTimesV = newValue;
599 //=================================================================================
600 // function : ReverseStepU()
601 // purpose : 'state' not used here
602 //=================================================================================
603 void TransformationGUI_MultiTranslationDlg::ReverseStepU()
607 int aConstructorId = getConstructorId();
609 if (aConstructorId == 0)
610 GroupPoints->SpinBox_DX->setValue(myStepU);
611 else if (aConstructorId == 1)
612 GroupDimensions->SpinBox_DX1->setValue(myStepU);
617 //=================================================================================
618 // function : ReverseStepV
619 // purpose : 'state' not used here
620 //=================================================================================
621 void TransformationGUI_MultiTranslationDlg::ReverseStepV()
625 GroupDimensions->SpinBox_DX2->setValue(myStepV);
630 //=================================================================================
631 // function : createOperation
633 //=================================================================================
634 GEOM::GEOM_IOperations_ptr TransformationGUI_MultiTranslationDlg::createOperation()
636 return getGeomEngine()->GetITransformOperations(getStudyId());
639 //=================================================================================
640 // function : isValid
642 //=================================================================================
643 bool TransformationGUI_MultiTranslationDlg::isValid (QString& msg)
645 int aConstructorId = getConstructorId();
647 if (aConstructorId == 0) {
649 ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
650 ok = GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
651 return !(myBase->_is_nil() || myVectorU->_is_nil()) && ok;
653 else if (aConstructorId == 1) {
655 ok = GroupDimensions->SpinBox_DX1->isValid( msg, !IsPreview() ) && ok;
656 ok = GroupDimensions->SpinBox_DY1->isValid( msg, !IsPreview() ) && ok;
657 ok = GroupDimensions->SpinBox_DX2->isValid( msg, !IsPreview() ) && ok;
658 ok = GroupDimensions->SpinBox_DY2->isValid( msg, !IsPreview() ) && ok;
659 return !(myBase->_is_nil() || myVectorU->_is_nil() || myVectorV->_is_nil()) && ok;
664 //=================================================================================
665 // function : execute
667 //=================================================================================
668 bool TransformationGUI_MultiTranslationDlg::execute (ObjectList& objects)
672 GEOM::GEOM_Object_var anObj;
674 QStringList aParameters;
676 GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation());
678 switch (getConstructorId()) {
680 if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVectorU)) {
681 anObj = anOper->MultiTranslate1D(myBase, myVectorU, myStepU, myNbTimesU);
683 aParameters<<GroupPoints->SpinBox_DX->text();
684 aParameters<<GroupPoints->SpinBox_DY->text();
690 if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVectorU) &&
691 !CORBA::is_nil(myVectorV)) {
692 anObj = anOper->MultiTranslate2D(myBase,
693 myVectorU, myStepU, myNbTimesU,
694 myVectorV, myStepV, myNbTimesV);
696 aParameters<<GroupDimensions->SpinBox_DX1->text();
697 aParameters<<GroupDimensions->SpinBox_DY1->text();
698 aParameters<<GroupDimensions->SpinBox_DX2->text();
699 aParameters<<GroupDimensions->SpinBox_DY2->text();
706 if (!anObj->_is_nil()) {
708 anObj->SetParameters(aParameters.join(":").toLatin1().constData());
709 objects.push_back(anObj._retn());
715 //=================================================================================
716 // function : addSubshapeToStudy
717 // purpose : virtual method to add new SubObjects if local selection
718 //=================================================================================
719 void TransformationGUI_MultiTranslationDlg::addSubshapesToStudy()
721 QMap<QString, GEOM::GEOM_Object_var> objMap;
723 switch (getConstructorId()) {
725 objMap[GroupPoints->LineEdit2->text()] = myVectorU;
728 objMap[GroupDimensions->LineEdit2->text()] = myVectorU;
729 objMap[GroupDimensions->LineEdit3->text()] = myVectorV;
732 addSubshapesToFather(objMap);