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