]> SALOME platform Git repositories - modules/geom.git/blob - src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx
Salome HOME
DCQ : Add Multi-Wire for MakeFace
[modules/geom.git] / src / TransformationGUI / TransformationGUI_MultiTranslationDlg.cxx
1 //  GEOM GEOMGUI : GUI for Geometry component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : TransformationGUI_MultiTranslationDlg.cxx
25 //  Author : Damien COQUERET
26 //  Module : GEOM
27 //  $Header$
28
29 using namespace std;
30 #include "TransformationGUI_MultiTranslationDlg.h"
31
32 #include <gp_Lin.hxx>
33 #include <BRepBuilderAPI_MakeVertex.hxx>
34 #include <BRepBuilderAPI_Transform.hxx>
35 #include <BRepAdaptor_Curve.hxx>
36 #include <BRep_Builder.hxx>
37 #include <BRepGProp.hxx>
38 #include <GProp_GProps.hxx>
39 #include <TopoDS_Compound.hxx>
40 #include "QAD_Config.h"
41
42 //=================================================================================
43 // class    : TransformationGUI_MultiTranslationDlg()
44 // purpose  : Constructs a TransformationGUI_MultiTranslationDlg which is a child of 'parent', with the 
45 //            name 'name' and widget flags set to 'f'.
46 //            The dialog will by default be modeless, unless you set 'modal' to
47 //            TRUE to construct a modal dialog.
48 //=================================================================================
49 TransformationGUI_MultiTranslationDlg::TransformationGUI_MultiTranslationDlg(QWidget* parent,  const char* name, TransformationGUI* theTransformationGUI, SALOME_Selection* Sel, bool modal, WFlags fl)
50   :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
51 {
52   QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_MULTITRANSLATION_SIMPLE")));
53   QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_MULTITRANSLATION_DOUBLE")));
54   QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT")));
55
56   setCaption(tr("GEOM_MULTITRANSLATION_TITLE"));
57
58   /***************************************************************/
59   GroupConstructors->setTitle(tr("GEOM_MULTITRANSLATION"));
60   RadioButton1->setPixmap(image0);
61   RadioButton2->setPixmap(image1);
62   RadioButton3->close(TRUE);
63
64   GroupPoints = new DlgRef_2Sel2Spin1Check(this, "GroupPoints");
65   GroupPoints->GroupBox1->setTitle(tr("GEOM_MULTITRANSLATION_SIMPLE"));
66   GroupPoints->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
67   GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR_U"));
68   GroupPoints->TextLabel3->setText(tr("GEOM_STEP_U"));
69   GroupPoints->TextLabel4->setText(tr("GEOM_NB_TIMES_U"));
70   GroupPoints->CheckButton1->setText(tr("GEOM_REVERSE_U"));
71   GroupPoints->PushButton1->setPixmap(image2);
72   GroupPoints->PushButton2->setPixmap(image2);
73
74   GroupDimensions = new DlgRef_3Sel4Spin2Check(this, "GroupDimensions");
75   GroupDimensions->GroupBox1->setTitle(tr("GEOM_MULTITRANSLATION_DOUBLE"));
76   GroupDimensions->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
77   GroupDimensions->TextLabel2->setText(tr("GEOM_VECTOR_U"));
78   GroupDimensions->TextLabel3->setText(tr("GEOM_VECTOR_V"));
79   GroupDimensions->TextLabel4->setText(tr("GEOM_STEP_U"));
80   GroupDimensions->TextLabel5->setText(tr("GEOM_NB_TIMES_U"));
81   GroupDimensions->TextLabel6->setText(tr("GEOM_STEP_V"));
82   GroupDimensions->TextLabel7->setText(tr("GEOM_NB_TIMES_V"));
83   GroupDimensions->CheckButton1->setText(tr("GEOM_REVERSE_U"));
84   GroupDimensions->CheckButton2->setText(tr("GEOM_REVERSE_V"));
85   GroupDimensions->PushButton1->setPixmap(image2);
86   GroupDimensions->PushButton2->setPixmap(image2);
87   GroupDimensions->PushButton3->setPixmap(image2);
88
89   Layout1->addWidget(GroupPoints, 1, 0);
90   Layout1->addWidget(GroupDimensions, 1, 0);
91   /***************************************************************/
92
93   /* Initialisations */
94   myTransformationGUI = theTransformationGUI;
95   Init();
96 }
97
98
99 //=================================================================================
100 // function : ~TransformationGUI_MultiTranslationDlg()
101 // purpose  : Destroys the object and frees any allocated resources
102 //=================================================================================
103 TransformationGUI_MultiTranslationDlg::~TransformationGUI_MultiTranslationDlg()
104 {
105   // no need to delete child widgets, Qt does it all for us
106 }
107
108
109 //=================================================================================
110 // function : Init()
111 // purpose  :
112 //=================================================================================
113 void TransformationGUI_MultiTranslationDlg::Init()
114 {
115   /* init variables */
116   myConstructorId = 0;
117   myEditCurrentArgument = GroupPoints->LineEdit1;
118
119   myStep1 = 50.0;
120   myStep2 = 50.0;
121   myNbTimes1 = 2;
122   myNbTimes2 = 2;
123   myOkBase = myOkDir1 = myOkDir2 = false;
124
125   myEdgeFilter = new GEOM_ShapeTypeFilter(TopAbs_EDGE, myGeom);
126
127   /* Get setting of step value from file configuration */
128   QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep");
129   step = St.toDouble();
130
131   double SpecificStep = 1;
132   /* min, max, step and decimals for spin boxes & initial values */
133   GroupPoints->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3);
134   GroupPoints->SpinBox_DY->RangeStepAndValidator(1.0, 999.999, SpecificStep, 3);
135   GroupPoints->SpinBox_DX->SetValue(myStep1);
136   GroupPoints->SpinBox_DY->SetValue(myNbTimes1);
137
138   GroupDimensions->SpinBox_DX1->RangeStepAndValidator(-999.999, 999.999, step, 3);
139   GroupDimensions->SpinBox_DY1->RangeStepAndValidator(1.0, 999.999, SpecificStep, 3);
140   GroupDimensions->SpinBox_DX2->RangeStepAndValidator(-999.999, 999.999, step, 3);
141   GroupDimensions->SpinBox_DY2->RangeStepAndValidator(1.0, 999.999, SpecificStep, 3);
142   GroupDimensions->SpinBox_DX1->SetValue(myStep1);
143   GroupDimensions->SpinBox_DY1->SetValue(myNbTimes1);
144   GroupDimensions->SpinBox_DX2->SetValue(myStep2);
145   GroupDimensions->SpinBox_DY2->SetValue(myNbTimes2);
146
147   /* signals and slots connections */
148   connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
149   connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
150   connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int)));
151
152   connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
153   connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
154   connect(GroupDimensions->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
155   connect(GroupDimensions->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
156   connect(GroupDimensions->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
157
158   connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
159   connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
160   connect(GroupDimensions->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
161   connect(GroupDimensions->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
162   connect(GroupDimensions->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
163
164   connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
165   connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
166   connect(GroupDimensions->SpinBox_DX1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
167   connect(GroupDimensions->SpinBox_DY1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
168   connect(GroupDimensions->SpinBox_DX2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
169   connect(GroupDimensions->SpinBox_DY2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
170
171   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double)));
172   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DY, SLOT(SetStep(double)));
173   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DX1, SLOT(SetStep(double)));
174   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DY1, SLOT(SetStep(double)));
175   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DX2, SLOT(SetStep(double)));
176   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DY2, SLOT(SetStep(double)));
177
178   connect(GroupPoints->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(ReverseAngle1(int)));
179   connect(GroupDimensions->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(ReverseAngle1(int)));
180   connect(GroupDimensions->CheckButton2, SIGNAL(stateChanged(int)), this, SLOT(ReverseAngle2(int)));
181   
182   connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
183
184   /* displays Dialog */
185   GroupDimensions->hide();
186   GroupPoints->show();
187   this->show();
188
189   return;
190 }
191
192
193 //=================================================================================
194 // function : ConstructorsClicked()
195 // purpose  : Radio button management
196 //=================================================================================
197 void TransformationGUI_MultiTranslationDlg::ConstructorsClicked(int constructorId)
198 {
199   myConstructorId = constructorId;
200   mySelection->ClearFilters();
201   myGeomBase->EraseSimulationShape();
202   mySimulationTopoDs.Nullify();
203   disconnect(mySelection, 0, this, 0);
204   myStep1 = 50.0;
205   myStep2 = 50.0;
206   myNbTimes1 = 2;
207   myNbTimes2 = 2;
208   myOkBase = myOkDir1 = myOkDir2  = false;
209
210   switch (constructorId)
211     {
212     case 0: /* Translate simple */
213       {
214         GroupDimensions->hide();
215         resize(0, 0);
216         GroupPoints->show();
217
218         myEditCurrentArgument = GroupPoints->LineEdit1;
219         GroupPoints->LineEdit1->setText("");
220         GroupPoints->LineEdit2->setText("");
221
222         GroupPoints->SpinBox_DX->SetValue(myStep1);
223         GroupPoints->SpinBox_DY->SetValue(myNbTimes1);
224
225         /* filter for next selection */
226         connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
227         break;
228       }
229     case 1: /* Translate double */
230       {
231         GroupPoints->hide();
232         resize(0, 0);
233         GroupDimensions->show();
234
235         myEditCurrentArgument = GroupDimensions->LineEdit1;
236         GroupDimensions->LineEdit1->setText("");
237         GroupDimensions->LineEdit2->setText("");
238         GroupDimensions->LineEdit3->setText("");
239
240         GroupDimensions->SpinBox_DX1->SetValue(myStep1);
241         GroupDimensions->SpinBox_DY1->SetValue(myNbTimes1);
242         GroupDimensions->SpinBox_DX2->SetValue(myStep2);
243         GroupDimensions->SpinBox_DY2->SetValue(myNbTimes2);
244
245         /* filter for next selection */
246         connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
247         break;
248       }
249     }
250   return;
251 }
252
253
254 //=================================================================================
255 // function : ClickOnOk()
256 // purpose  :
257 //=================================================================================
258 void TransformationGUI_MultiTranslationDlg::ClickOnOk()
259 {
260   this->ClickOnApply();
261   ClickOnCancel();
262   return;
263 }
264
265
266 //=================================================================================
267 // function : ClickOnApply()
268 // purpose  :
269 //=================================================================================
270 void TransformationGUI_MultiTranslationDlg::ClickOnApply()
271 {
272   QAD_Application::getDesktop()->putInfo(tr(""));
273   if (mySimulationTopoDs.IsNull())
274     return;
275   myGeomBase->EraseSimulationShape();
276   mySimulationTopoDs.Nullify();
277
278   if(myConstructorId == 0) {
279     if(myOkBase && myOkDir1)
280       myTransformationGUI->MakeMultiTranslation1DAndDisplay(myGeomShape, myDir1, myStep1, myNbTimes1);
281   }
282   else if(myConstructorId == 1) {
283     if(myOkBase && myOkDir1 && myOkDir2)
284       myTransformationGUI->MakeMultiTranslation2DAndDisplay(myGeomShape, myDir1, myStep1, myNbTimes1, myDir2, myStep2, myNbTimes2);
285   }
286   return;
287 }
288
289
290 //=================================================================================
291 // function : SelectionIntoArgument()
292 // purpose  : Called when selection as changed or other case
293 //=================================================================================
294 void TransformationGUI_MultiTranslationDlg::SelectionIntoArgument()
295 {
296   myGeomBase->EraseSimulationShape();
297   mySimulationTopoDs.Nullify();
298   myEditCurrentArgument->setText("");
299   QString aString = ""; /* name of selection */
300
301   int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString);
302   if(nbSel != 1) {
303     if(myEditCurrentArgument == GroupPoints->LineEdit1 || myEditCurrentArgument == GroupDimensions->LineEdit1)
304       myOkBase = false;
305     else if(myEditCurrentArgument == GroupPoints->LineEdit2 || myEditCurrentArgument == GroupDimensions->LineEdit2)
306       myOkDir1 = false;
307     else if(myEditCurrentArgument == GroupDimensions->LineEdit3)
308       myOkDir2 = false;
309     return;
310   }
311
312   // nbSel == 1
313   TopoDS_Shape S; 
314   Standard_Boolean testResult;
315   Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
316   if(!myGeomBase->GetTopoFromSelection(mySelection, S))
317     return;
318
319   switch(myConstructorId)
320     {
321     case 0 :
322       {
323         if(myEditCurrentArgument == GroupPoints->LineEdit1) {
324           myGeomShape = myGeomBase->ConvertIOinGEOMShape(IO, testResult);
325           if(!testResult)
326             return;
327           myEditCurrentArgument->setText(aString);
328           myBase = S;
329           myOkBase = true;
330         }    
331         else if(myEditCurrentArgument == GroupPoints->LineEdit2) {
332           BRepAdaptor_Curve curv(TopoDS::Edge(S));
333           myDir1 = curv.Line().Direction();
334           myEditCurrentArgument->setText(aString);
335           myOkDir1 = true;
336         }
337
338         if(myOkBase && myOkDir1)
339           this->MakeMultiTranslationSimulationAndDisplay();
340         break;
341       }
342     case 1 :
343       { 
344         if(myEditCurrentArgument == GroupDimensions->LineEdit1) {
345           myGeomShape = myGeomBase->ConvertIOinGEOMShape(IO, testResult);
346           if(!testResult)
347             return;
348           myEditCurrentArgument->setText(aString);
349           myBase = S;
350           myOkBase = true;
351         }    
352         else if(myEditCurrentArgument == GroupDimensions->LineEdit2) {
353           BRepAdaptor_Curve curv(TopoDS::Edge(S));
354           myDir1 = curv.Line().Direction();
355           myEditCurrentArgument->setText(aString);
356           myOkDir1 = true;
357         }
358         else if(myEditCurrentArgument == GroupDimensions->LineEdit3) {
359           BRepAdaptor_Curve curv(TopoDS::Edge(S));
360           myDir2 = curv.Line().Direction();
361           myEditCurrentArgument->setText(aString);
362           myOkDir2 = true;
363         }
364
365         if(myOkBase && myOkDir1 && myOkDir2)
366           this->MakeMultiTranslationSimulationAndDisplay();
367         break;
368       }
369     }
370   return;
371 }
372
373
374 //=================================================================================
375 // function : SetEditCurrentArgument()
376 // purpose  :
377 //=================================================================================
378 void TransformationGUI_MultiTranslationDlg::SetEditCurrentArgument()
379 {
380   QPushButton* send = (QPushButton*)sender();
381   mySelection->ClearFilters();
382
383   if(send == GroupPoints->PushButton1) {
384     GroupPoints->LineEdit1->setFocus();
385     myEditCurrentArgument = GroupPoints->LineEdit1;
386   }
387   else if(send == GroupPoints->PushButton2) {
388     GroupPoints->LineEdit2->setFocus();
389     myEditCurrentArgument = GroupPoints->LineEdit2;
390     mySelection->AddFilter(myEdgeFilter);
391   }
392   else if(send == GroupDimensions->PushButton1) {
393     GroupDimensions->LineEdit1->setFocus();
394     myEditCurrentArgument = GroupDimensions->LineEdit1;
395   }
396   else if(send == GroupDimensions->PushButton2) {
397     GroupDimensions->LineEdit2->setFocus();
398     myEditCurrentArgument = GroupDimensions->LineEdit2;
399     mySelection->AddFilter(myEdgeFilter);
400   }
401   else if(send == GroupDimensions->PushButton3) {
402     GroupDimensions->LineEdit3->setFocus();
403     myEditCurrentArgument = GroupDimensions->LineEdit3;
404     mySelection->AddFilter(myEdgeFilter);
405   }
406   this->SelectionIntoArgument();
407
408   return;
409 }
410
411
412 //=================================================================================
413 // function : LineEditReturnPressed()
414 // purpose  :
415 //=================================================================================
416 void TransformationGUI_MultiTranslationDlg::LineEditReturnPressed()
417 {
418   QLineEdit* send = (QLineEdit*)sender();
419   if(send == GroupPoints->LineEdit1)
420     myEditCurrentArgument = GroupPoints->LineEdit1;
421   else if (send == GroupPoints->LineEdit2)
422     myEditCurrentArgument = GroupPoints->LineEdit2;
423   else if (send == GroupDimensions->LineEdit1)
424     myEditCurrentArgument = GroupDimensions->LineEdit1;
425   else if (send == GroupDimensions->LineEdit2)
426     myEditCurrentArgument = GroupDimensions->LineEdit2;
427   else if (send == GroupDimensions->LineEdit3)
428     myEditCurrentArgument = GroupDimensions->LineEdit3;
429   else
430     return;
431
432   GEOMBase_Skeleton::LineEditReturnPressed();
433   return;
434 }
435
436
437 //=================================================================================
438 // function : ActivateThisDialog()
439 // purpose  :
440 //=================================================================================
441 void TransformationGUI_MultiTranslationDlg::ActivateThisDialog()
442 {
443   GEOMBase_Skeleton::ActivateThisDialog();
444   connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
445
446   if(myConstructorId == 0) {
447     GroupPoints->LineEdit1->setFocus();
448     myEditCurrentArgument = GroupPoints->LineEdit1;
449   }
450   else if(myConstructorId == 1) {
451     GroupDimensions->LineEdit1->setFocus();
452     myEditCurrentArgument = GroupDimensions->LineEdit1;
453   }
454
455   if(!mySimulationTopoDs.IsNull())
456     myGeomBase->DisplaySimulationShape(mySimulationTopoDs);
457   return;
458 }
459
460
461 //=================================================================================
462 // function : enterEvent()
463 // purpose  :
464 //=================================================================================
465 void TransformationGUI_MultiTranslationDlg::enterEvent(QEvent* e)
466 {
467   if (GroupConstructors->isEnabled())
468     return;
469   this->ActivateThisDialog();
470   return;
471 }
472
473
474 //=================================================================================
475 // function : ValueChangedInSpinBox()
476 // purpose  :
477 //=================================================================================
478 void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox(double newValue)
479 {
480   myGeomBase->EraseSimulationShape();
481   mySimulationTopoDs.Nullify();
482   QObject* send = (QObject*)sender();
483
484   switch(myConstructorId)
485     {
486     case 0 :
487       { 
488         if(send == GroupPoints->SpinBox_DX)
489           myStep1 = newValue;
490         else if(send == GroupPoints->SpinBox_DY)
491           myNbTimes1 = newValue;
492         if(myOkBase && myOkDir1)
493           this->MakeMultiTranslationSimulationAndDisplay();
494         break;
495       }
496     case 1 :
497       { 
498         if(send == GroupDimensions->SpinBox_DX1)
499           myStep1 = newValue;
500         else if(send == GroupDimensions->SpinBox_DY1)
501           myNbTimes1 = newValue;
502         else if(send == GroupDimensions->SpinBox_DX2)
503           myStep2 = newValue;
504         else if(send == GroupDimensions->SpinBox_DY2)
505           myNbTimes2 = newValue;
506         if(myOkBase && myOkDir1 && myOkDir2)
507           this->MakeMultiTranslationSimulationAndDisplay();
508         break;
509       }
510     }
511   return;
512 }
513
514
515 //=================================================================================
516 // function : ReverseAngle1()
517 // purpose  : 'state' not used here
518 //=================================================================================
519 void TransformationGUI_MultiTranslationDlg::ReverseAngle1(int state)
520 {
521   myStep1 = -myStep1;
522   if(myConstructorId == 0) {
523     GroupPoints->SpinBox_DX->SetValue(myStep1);
524     if(myOkBase && myOkDir1)
525       this->MakeMultiTranslationSimulationAndDisplay();
526   }
527   else if(myConstructorId == 1) {
528     GroupDimensions->SpinBox_DX1->SetValue(myStep1);
529     if(myOkBase && myOkDir1 && myOkDir2)
530       this->MakeMultiTranslationSimulationAndDisplay();
531   }
532   return;
533 }
534
535
536 //=================================================================================
537 // function : ReverseAngle2()
538 // purpose  : 'state' not used here
539 //=================================================================================
540 void TransformationGUI_MultiTranslationDlg::ReverseAngle2(int state)
541 {
542   myStep2 = -myStep2;
543   GroupDimensions->SpinBox_DX2->SetValue(myStep2);
544   if(myOkBase && myOkDir1 && myOkDir2)
545     MakeMultiTranslationSimulationAndDisplay();
546   return;
547 }
548
549
550 //=================================================================================
551 // function : MakeMultiTranslationSimulationAndDisplay()
552 // purpose  :
553 //=================================================================================
554 void TransformationGUI_MultiTranslationDlg::MakeMultiTranslationSimulationAndDisplay() 
555 {
556   myGeomBase->EraseSimulationShape();
557   mySimulationTopoDs.Nullify();
558
559   int i, j;
560   Standard_Real DX, DY, DZ;
561   gp_Trsf theTransformation;
562   GProp_GProps System;
563   TopoDS_Compound compound;
564
565   BRep_Builder B;
566   B.MakeCompound(compound);
567     
568   try {
569     BRepGProp::LinearProperties(myBase, System);
570     gp_Pnt myPoint = System.CentreOfMass();
571     TopoDS_Shape S = BRepBuilderAPI_MakeVertex(myPoint).Shape();
572
573     switch (myConstructorId)
574       {
575       case 0 :
576         { 
577           gp_Vec Vec(myDir1);
578           Vec.Normalize();
579
580           for(i = 0; i < myNbTimes1; i++) {
581             DX = i * myStep1 * Vec.X();
582             DY = i * myStep1 * Vec.Y();
583             DZ = i * myStep1 * Vec.Z();
584             myVec.SetCoord(DX, DY, DZ);
585             
586             theTransformation.SetTranslation(myVec);
587             BRepBuilderAPI_Transform myBRepTransformation(S, theTransformation, Standard_False);
588             B.Add(compound, myBRepTransformation.Shape());
589           }
590           mySimulationTopoDs = compound;
591           myGeomBase->DisplaySimulationShape(mySimulationTopoDs);
592           break;
593         }
594       case 1 :
595         {       
596           gp_Vec Vec1(myDir1);
597           Vec1.Normalize();
598           gp_Vec Vec2(myDir2);
599           Vec2.Normalize();
600
601           for(i = 0; i < myNbTimes1; i++) {
602             for(j = 0; j < myNbTimes2; j++) {
603               DX = i * myStep1 * Vec1.X() + j * myStep2 * Vec2.X();
604               DY = i * myStep1 * Vec1.Y() + j * myStep2 * Vec2.Y();
605               DZ = i * myStep1 * Vec1.Z() + j * myStep2 * Vec2.Z();
606               myVec.SetCoord(DX, DY, DZ);
607               
608               theTransformation.SetTranslation(myVec);
609               BRepBuilderAPI_Transform myBRepTransformation(S, theTransformation, Standard_False);
610               B.Add(compound, myBRepTransformation.Shape());
611             }
612           }
613           mySimulationTopoDs = compound;
614           myGeomBase->DisplaySimulationShape(mySimulationTopoDs);
615           break;
616         }
617       }
618   }
619   catch(Standard_Failure) {
620     MESSAGE("Exception catched in MakeMultitranslationSimulationAndDisplay");
621     return;
622   }
623   return;
624 }