Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/geom.git] / src / GEOMGUI / GeometryGUI_OrientationDlg.cxx
1 using namespace std;
2 //  File      : GeometryGUI_OrientationDlg.cxx
3 //  Created   :
4 //  Author    : Lucien PIGNOLONI
5 //  Project   : SALOME
6 //  Module    : GeometryGUI
7 //  Copyright : OPEN CASCADE
8 //  $Header$
9
10 #include "GeometryGUI_OrientationDlg.h"
11
12 #include "GeometryGUI.h"
13 #include "QAD_Application.h"
14 #include "QAD_Desktop.h"
15 #include "QAD_Config.h"
16 #include "utilities.h"
17
18 #include <TopoDS_Compound.hxx>
19 #include <BRep_Builder.hxx>
20 #include <BRepBuilderAPI_MakeEdge.hxx>
21 #include <BRepAdaptor_Surface.hxx>
22 #include <TopExp_Explorer.hxx>
23
24 #include <qbuttongroup.h>
25 #include <qcheckbox.h>
26 #include <qgroupbox.h>
27 #include <qlabel.h>
28 #include <qlineedit.h>
29 #include <qpushbutton.h>
30 #include <qradiobutton.h>
31 #include <qlayout.h>
32 #include <qvariant.h>
33 #include <qtooltip.h>
34 #include <qvalidator.h>
35 #include <qwhatsthis.h>
36 #include <qimage.h>
37 #include <qpixmap.h>
38
39 //=================================================================================
40 // class    : GeometryGUI_OrientationDlg()
41 // purpose  : Constructs a GeometryGUI_OrientationDlg which is a child of 'parent', with the 
42 //            name 'name' and widget flags set to 'f'.
43 //            The dialog will by default be modeless, unless you set 'modal' to
44 //            TRUE to construct a modal dialog.
45 //=================================================================================
46 GeometryGUI_OrientationDlg::GeometryGUI_OrientationDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
47     : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
48 {
49     QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_ORIENTATION")));
50     QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT")));
51     if ( !name )
52         setName( "GeometryGUI_OrientationDlg" );
53     resize( 303, 242 ); 
54     setCaption( tr( "GEOM_ORIENTATION_TITLE"  ) );
55     setSizeGripEnabled( TRUE );
56     GeometryGUI_OrientationDlgLayout = new QGridLayout( this ); 
57     GeometryGUI_OrientationDlgLayout->setSpacing( 6 );
58     GeometryGUI_OrientationDlgLayout->setMargin( 11 );
59     
60     /***************************************************************/
61     GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
62     GroupConstructors->setTitle( tr( "GEOM_ORIENTATION"  ) );
63     GroupConstructors->setExclusive( TRUE );
64     GroupConstructors->setColumnLayout(0, Qt::Vertical );
65     GroupConstructors->layout()->setSpacing( 0 );
66     GroupConstructors->layout()->setMargin( 0 );
67     GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
68     GroupConstructorsLayout->setAlignment( Qt::AlignTop );
69     GroupConstructorsLayout->setSpacing( 6 );
70     GroupConstructorsLayout->setMargin( 11 );
71     Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
72     Constructor1->setText( tr( ""  ) );
73     Constructor1->setPixmap( image0 );
74     Constructor1->setChecked( TRUE );
75     Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
76     Constructor1->setMinimumSize( QSize( 50, 0 ) );
77     GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
78     QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
79     GroupConstructorsLayout->addItem( spacer, 0, 1 );
80     GeometryGUI_OrientationDlgLayout->addWidget( GroupConstructors, 0, 0 );    
81     
82     /***************************************************************/
83     GroupButtons = new QGroupBox( this, "GroupButtons" );
84     GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); 
85     GroupButtons->setTitle( tr( ""  ) );
86     GroupButtons->setColumnLayout(0, Qt::Vertical );
87     GroupButtons->layout()->setSpacing( 0 );
88     GroupButtons->layout()->setMargin( 0 );
89     GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
90     GroupButtonsLayout->setAlignment( Qt::AlignTop );
91     GroupButtonsLayout->setSpacing( 6 );
92     GroupButtonsLayout->setMargin( 11 );
93     buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
94     buttonCancel->setText( tr( "GEOM_BUT_CLOSE"  ) );
95     buttonCancel->setAutoDefault( TRUE );
96     GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
97     buttonApply = new QPushButton( GroupButtons, "buttonApply" );
98     buttonApply->setText( tr( "GEOM_BUT_APPLY"  ) );
99     buttonApply->setAutoDefault( TRUE );
100     GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
101     QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
102     GroupButtonsLayout->addItem( spacer_9, 0, 2 );
103     buttonOk = new QPushButton( GroupButtons, "buttonOk" );
104     buttonOk->setText( tr( "GEOM_BUT_OK"  ) );
105     buttonOk->setAutoDefault( TRUE );
106     buttonOk->setDefault( TRUE );
107     GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
108     GeometryGUI_OrientationDlgLayout->addWidget( GroupButtons, 2, 0 );
109
110     /***************************************************************/
111     GroupC1 = new QGroupBox( this, "GroupC1" );
112     GroupC1->setTitle( tr( "GEOM_ARGUMENTS"  ) );
113     GroupC1->setMinimumSize( QSize( 0, 0 ) );
114     GroupC1->setFrameShape( QGroupBox::Box );
115     GroupC1->setFrameShadow( QGroupBox::Sunken );
116     GroupC1->setColumnLayout(0, Qt::Vertical );
117     GroupC1->layout()->setSpacing( 0 );
118     GroupC1->layout()->setMargin( 0 );
119     GroupC1Layout = new QGridLayout( GroupC1->layout() );
120     GroupC1Layout->setAlignment( Qt::AlignTop );
121     GroupC1Layout->setSpacing( 6 );
122     GroupC1Layout->setMargin( 11 );
123     LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
124     GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
125
126     /* Spin box construction */
127     SpinBox_C1A2 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A2" ) ;
128     GroupC1Layout->addWidget( SpinBox_C1A2, 1, 2 );
129     
130     SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
131     SelectButtonC1A1->setText( tr( ""  ) );
132     SelectButtonC1A1->setPixmap( image1 );
133     SelectButtonC1A1->setToggleButton( FALSE );
134     GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
135     TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
136     TextLabelC1A1->setText( tr( "GEOM_OBJECT"  ) );
137     TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
138     TextLabelC1A1->setFrameShape( QLabel::NoFrame );
139     TextLabelC1A1->setFrameShadow( QLabel::Plain );
140     GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
141     TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
142     TextLabelC1A2->setText( tr( "GEOM_VECTOR_LENGTH"  ) );
143     TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
144     GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
145     CheckBoxReverse = new QCheckBox( GroupC1, "CheckBoxReverse" );
146     CheckBoxReverse->setText( tr( "GEOM_ORIENTATION_OPT"  ) );
147     GroupC1Layout->addMultiCellWidget( CheckBoxReverse, 2, 2, 0, 2 );
148     GeometryGUI_OrientationDlgLayout->addWidget( GroupC1, 1, 0 );
149     /***************************************************************/
150
151     Init(Sel) ; /* Initialisations */
152
153 }
154
155 //=================================================================================
156 // function : ~GeometryGUI_OrientationDlg()
157 // purpose  : Destroys the object and frees any allocated resources
158 //=================================================================================
159 GeometryGUI_OrientationDlg::~GeometryGUI_OrientationDlg()
160 {
161     // no need to delete child widgets, Qt does it all for us
162 }
163
164
165 //=================================================================================
166 // function : Init()
167 // purpose  :
168 //=================================================================================
169 void GeometryGUI_OrientationDlg::Init( SALOME_Selection* Sel )
170 {
171
172   double step ;
173   QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
174   step = St.toDouble() ;
175
176   /* min, max, step and decimals for spin boxes */
177   SpinBox_C1A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
178   SpinBox_C1A2->SetValue( 25.0 ) ; /* = myLength */
179
180   GroupC1->show();
181   myConstructorId = 0 ;
182   Constructor1->setChecked( TRUE );
183   CheckBoxReverse->setChecked( FALSE );
184   myEditCurrentArgument = LineEditC1A1 ;        
185   mySelection = Sel;
186   myGeomGUI = GeometryGUI::GetGeometryGUI() ;
187
188   myLength = 25.0 ;
189   myOkShape = false ;
190   myOkLength = true;
191   mySimulationTopoDs.Nullify() ;
192   myShape.Nullify() ;
193   myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
194
195   // TODO : previous selection into argument ?
196
197   /* Filter definitions */
198   Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM");
199   myGeom = GEOM::GEOM_Gen::_narrow(comp);
200
201   /* signals and slots connections */
202   connect( buttonOk, SIGNAL( clicked() ),     this, SLOT( ClickOnOk() ) );
203   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
204   connect( buttonApply, SIGNAL( clicked() ),  this, SLOT(ClickOnApply() ) );
205   connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );  
206   connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
207   connect( CheckBoxReverse, SIGNAL (stateChanged(int) ), this, SLOT( ReverseOrientation(int) ) ) ;
208
209   connect( LineEditC1A1, SIGNAL ( returnPressed() ),                   this, SLOT( LineEditReturnPressed() ) ) ;
210   connect( SpinBox_C1A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
211
212   connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;  
213   connect( mySelection, SIGNAL( currentSelectionChanged() ),     this, SLOT( SelectionIntoArgument() ) );
214   /* to close dialog if study change */
215   connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
216  
217   /* Move widget on the botton right corner of main widget */
218   int x, y ;
219   myGeomGUI->DefineDlgPosition( this, x, y ) ;
220   this->move( x, y ) ;
221   this->show() ; /* displays Dialog */
222
223   return ;
224 }
225
226
227 //=================================================================================
228 // function : ConstructorsClicked()
229 // purpose  : Radio button management
230 //=================================================================================
231 void GeometryGUI_OrientationDlg::ConstructorsClicked(int constructorId)
232 {
233   return ;
234 }
235
236 //=================================================================================
237 // function : ClickOnOk()
238 // purpose  :
239 //=================================================================================
240 void GeometryGUI_OrientationDlg::ClickOnOk()
241 {
242   this->ClickOnApply() ;
243   this->ClickOnCancel() ;
244
245   return ;
246 }
247
248 //=================================================================================
249 // function : ClickOnApply()
250 // purpose  :
251 //=================================================================================
252 void GeometryGUI_OrientationDlg::ClickOnApply()
253 {
254   /* Leave simulation display in this method ! */
255   myGeomGUI->GetDesktop()->putInfo( tr("") ) ; 
256   
257   switch(myConstructorId)
258     { 
259     case 0 :
260       { 
261         if(myOkShape && CheckBoxReverse->isChecked() && myOkLength == true ) {    
262           myGeomGUI->MakeOrientationChangeAndDisplay( myGeomShape ) ;
263           CheckBoxReverse->setChecked( FALSE );
264         }
265         break ;
266       }
267     }
268   // accept();
269   return ;
270 }
271
272
273 //=================================================================================
274 // function : ClickOnCancel()
275 // purpose  :
276 //=================================================================================
277 void GeometryGUI_OrientationDlg::ClickOnCancel()
278 {
279   myGeomGUI->EraseSimulationShape() ;
280   mySimulationTopoDs.Nullify() ;
281   disconnect( mySelection, 0, this, 0 );
282   myGeomGUI->ResetState() ;
283   reject() ;
284   return ;
285 }
286
287 //=================================================================================
288 // function : LineEditReturnPressed()
289 // purpose  :
290 //=================================================================================
291 void GeometryGUI_OrientationDlg::LineEditReturnPressed()
292 {
293   QLineEdit* send = (QLineEdit*)sender();  
294   if( send == LineEditC1A1 )
295     myEditCurrentArgument = LineEditC1A1 ;
296   else
297     return ;
298   
299   /* User name of object input management                          */
300   /* If successfull the selection is changed and signal emitted... */
301   /* so SelectionIntoArgument() is automatically called.           */
302   const QString objectUserName = myEditCurrentArgument->text() ;
303   QWidget* thisWidget = (QWidget*)this ;
304   if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
305     myEditCurrentArgument->setText( objectUserName ) ;
306   }
307   return ;
308 }
309
310
311
312 //=================================================================================
313 // function : SelectionIntoArgument()
314 // purpose  : Called when selection as changed or other case
315 //=================================================================================
316 void GeometryGUI_OrientationDlg::SelectionIntoArgument()
317 {
318   myGeomGUI->EraseSimulationShape() ; 
319   this->mySimulationTopoDs.Nullify() ;
320   
321   /* Name of future selection */
322   QString aString = "";
323
324   int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
325   if ( nbSel != 1 ) {
326     if ( myEditCurrentArgument == LineEditC1A1 ) {
327       LineEditC1A1->setText("") ;
328       this->myOkShape = false ;
329     }
330     return ;
331   }
332   
333   /* nbSel == 1 ! */
334   TopoDS_Shape S;
335   Standard_Boolean testResult ;
336   Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
337   if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
338     return ;  
339   
340   /* Constructor */
341   if ( myEditCurrentArgument == LineEditC1A1 ) { 
342     myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
343     if( !testResult )
344       return ;
345     LineEditC1A1->setText(aString) ;
346     myShape = S ;
347     myOkShape = true ;
348   }
349   
350   if( myOkShape && myOkLength ) {
351     MakeOrientationSimulationAndDisplay( this->myShape, this->myLength ) ;
352   }
353   return ;
354 }
355
356
357 //=================================================================================
358 // function : SetEditCurrentArgument()
359 // purpose  :
360 //=================================================================================
361 void GeometryGUI_OrientationDlg::SetEditCurrentArgument()
362 {
363   QPushButton* send = (QPushButton*)sender();
364   switch (myConstructorId)
365     {
366     case 0: /* default constructor */
367       { 
368         if(send == SelectButtonC1A1) {
369           LineEditC1A1->setFocus() ;
370           myEditCurrentArgument = LineEditC1A1 ;
371         }
372         SelectionIntoArgument() ;
373         break;
374       }
375     }
376   return ;
377 }
378
379
380 //=================================================================================
381 // function : ValueChangedInSpinBox()
382 // purpose  :
383 //=================================================================================
384 void GeometryGUI_OrientationDlg::ValueChangedInSpinBox( double newValue )
385
386   myGeomGUI->EraseSimulationShape() ;
387   mySimulationTopoDs.Nullify() ;
388   
389   QObject* send = (QObject*)sender() ; 
390   if( send == SpinBox_C1A2 ) {
391     this->myLength = newValue ;
392     myOkLength = true ;
393   } 
394   
395   if ( myConstructorId == 0 && myOkShape && myOkLength == true ) {
396     MakeOrientationSimulationAndDisplay( this->myShape, this->myLength ) ;
397   }
398   return ;
399 }
400
401
402 //=================================================================================
403 // function : DeactivateActiveDialog()
404 // purpose  :
405 //=================================================================================
406 void GeometryGUI_OrientationDlg::DeactivateActiveDialog()
407 {
408   if ( GroupConstructors->isEnabled() ) {
409     GroupConstructors->setEnabled(false) ;
410     GroupButtons->setEnabled(false) ;
411     GroupC1->setEnabled(false) ;
412     disconnect( mySelection, 0, this, 0 );
413     myGeomGUI->EraseSimulationShape() ;
414   }
415   return ;
416 }
417
418
419 //=================================================================================
420 // function : ActivateThisDialog()
421 // purpose  :
422 //=================================================================================
423 void GeometryGUI_OrientationDlg::ActivateThisDialog()
424 {
425   /* Emit a signal to deactivate the active dialog */
426   myGeomGUI->EmitSignalDeactivateDialog() ;
427   GroupConstructors->setEnabled(true) ;
428   GroupButtons->setEnabled(true) ;
429   GroupC1->setEnabled(true) ;
430   
431   connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
432   if( !mySimulationTopoDs.IsNull() )
433     myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
434
435   return ;
436 }
437
438
439 //=================================================================================
440 // function : enterEvent()
441 // purpose  :
442 //=================================================================================
443 void GeometryGUI_OrientationDlg::enterEvent(QEvent* e)
444 {
445   if ( GroupConstructors->isEnabled() )
446     return ;  
447   ActivateThisDialog() ;
448   return ;
449 }
450
451
452
453 //=================================================================================
454 // function : closeEvent()
455 // purpose  :
456 //=================================================================================
457 void GeometryGUI_OrientationDlg::closeEvent( QCloseEvent* e )
458 {
459   /* same than click on cancel button */
460   this->ClickOnCancel() ;
461   return ;
462 }
463
464
465
466 //===========================================================================================
467 // function : ReverseOrientation()
468 // purpose  :
469 //===========================================================================================
470 void GeometryGUI_OrientationDlg::ReverseOrientation(int state)
471 {
472   if( this->myOkShape && myOkLength == true ) {
473     MakeOrientationSimulationAndDisplay( this->myShape, this-> myLength ) ;
474   }
475   return ;
476 }
477
478
479 //===========================================================================================
480 // function : MakeOrientationSimulationAndDisplay()
481 // purpose  : Create 'aCompound1' and 'aCompound2' each contains edges oriented
482 //          : respectively FORWARD and REVERSE for all faces of 'aTopoDS'
483 //          : These edges represent normal vectors on faces of 'aTopoDS'
484 //          : For a unique edge an arrow is displayed to show its orientation.
485 //===========================================================================================
486 void GeometryGUI_OrientationDlg::MakeOrientationSimulationAndDisplay(const TopoDS_Shape& aTopoDS, Standard_Real length )
487 {
488   myGeomGUI->EraseSimulationShape() ; 
489   mySimulationTopoDs.Nullify() ;
490   
491   TopoDS_Compound aCompound1, aCompound2 ;
492   TopoDS_Compound NullComp ;
493   BRep_Builder aBuilder1, aBuilder2;
494   aCompound1 = aCompound2 = NullComp ;
495   aBuilder1.MakeCompound(aCompound1) ;
496   aBuilder2.MakeCompound(aCompound2) ;
497   
498   if( aTopoDS.IsNull() )
499     return ;
500   
501   /* Case of an edge */
502   if( aTopoDS.ShapeType() == TopAbs_EDGE ) {
503     /* Try to display a cone simulation shape to show direction of edge */
504     TopoDS_Shape tmpShape = aTopoDS ;
505     if( this->CheckBoxReverse->isChecked() ) {
506       if( aTopoDS.Orientation() == TopAbs_FORWARD)
507         tmpShape.Orientation(TopAbs_REVERSED) ;
508       else
509         tmpShape.Orientation(TopAbs_FORWARD) ;
510     }
511     if( myGeomGUI->CreateArrowForLinearEdge( tmpShape, mySimulationTopoDs ) ) {
512       myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
513     }
514     return ;
515   }
516   
517
518   gp_Pnt P1, P2 ;
519   gp_Vec V, V1, V2 ;
520   TopExp_Explorer ex( aTopoDS, TopAbs_FACE );
521   int test = 0 ;
522   while (ex.More()) {
523     
524     const TopoDS_Face& F = TopoDS::Face(ex.Current());
525     /* find the center of the minmax */
526     BRepAdaptor_Surface SF(F);
527     Standard_Real u, v, x;
528     
529     u = SF.FirstUParameter();
530     x = SF.LastUParameter();
531     if ( Precision::IsInfinite(u) ) {
532       if( Precision::IsInfinite(x) ) u = 0.0 ;  else u = x ;
533     }
534     else if ( !Precision::IsInfinite(x) )
535       u = (u+x) / 2.0 ;
536     
537     v = SF.FirstVParameter();
538     x = SF.LastVParameter();
539     if ( Precision::IsInfinite(v) ) {
540       if ( Precision::IsInfinite(x) ) v = 0.0 ;  else v = x ;
541     }
542     else if ( !Precision::IsInfinite(x) )
543       v = (v+x) / 2.0 ;
544     
545     SF.D1( u, v, P1, V1, V2 );
546     V = V1.Crossed(V2);
547     x = V.Magnitude();
548     if ( x > 1.e-10 )
549       V.Multiply( length/x );
550     else {
551       V.SetCoord( length/2.0, 0.0, 0.0 ) ;
552       MESSAGE ("Null normal in Orientation " << endl ) ;
553     }
554     
555     P2 = P1;
556     /* test orientation of each face and displays forward (aCompound1) */
557     if( F.Orientation() == TopAbs_FORWARD )
558       P2.Translate(V);
559     else
560       P2.Translate(-V) ;    
561     BRepBuilderAPI_MakeEdge anEdge(P1, P2) ;
562     aBuilder1.Add( aCompound1, anEdge ) ;
563     
564     P2 = P1;
565     /* test orientation of each face and displays forward (aCompound2) */
566     if( F.Orientation() == TopAbs_FORWARD )
567       P2.Translate(-V);
568     else
569       P2.Translate(V) ;    
570     anEdge = BRepBuilderAPI_MakeEdge(P1, P2) ;
571     aBuilder2.Add( aCompound2, anEdge ) ;
572     
573     ex.Next();
574     test++ ;
575   }
576   
577   /* display simulation compounds */
578   if( test > 0 && this->CheckBoxReverse->isChecked() ) {
579     mySimulationTopoDs = aCompound1 ;    
580   }
581   else if ( test > 0 && !CheckBoxReverse->isChecked() ) {
582     mySimulationTopoDs = aCompound2 ;
583   }
584   if(!mySimulationTopoDs.IsNull() )
585     myGeomGUI->DisplaySimulationShape(mySimulationTopoDs) ;
586   
587   return ;
588 }