]> SALOME platform Git repositories - modules/geom.git/blob - src/BasicGUI/BasicGUI_PlaneDlg.cxx
Salome HOME
DCQ : New Architecture
[modules/geom.git] / src / BasicGUI / BasicGUI_PlaneDlg.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   : BasicGUI_PlaneDlg.cxx
25 //  Author : Lucien PIGNOLONI
26 //  Module : GEOM
27 //  $Header$
28
29 using namespace std;
30 #include "BasicGUI_PlaneDlg.h"
31
32 #include <BRepBuilderAPI_MakeFace.hxx>
33 #include <BRepAdaptor_Surface.hxx>
34 #include <gp_Pln.hxx>
35 #include <gp_Ax1.hxx>
36 #include <gp_Dir.hxx>
37 #include <Precision.hxx>
38 #include "QAD_Config.h"
39
40 //=================================================================================
41 // class    : BasicGUI_PlaneDlg()
42 // purpose  : Constructs a BasicGUI_PlaneDlg which is a child of 'parent', with the 
43 //            name 'name' and widget flags set to 'f'.
44 //            The dialog will by default be modeless, unless you set 'modal' to
45 //            TRUE to construct a modal dialog.
46 //=================================================================================
47 BasicGUI_PlaneDlg::BasicGUI_PlaneDlg(QWidget* parent, const char* name, BasicGUI* theBasicGUI, SALOME_Selection* Sel, bool modal, WFlags fl)
48   :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
49 {
50   QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_PLANE_PV")));
51   QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_PLANE_DXYZ")));
52   QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_PLANE_FACE")));
53   QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
54
55   setCaption(tr("GEOM_PLANE_TITLE"));
56
57   /***************************************************************/
58   GroupConstructors->setTitle(tr("GEOM_PLANE"));
59   RadioButton1->setPixmap(image0);
60   RadioButton2->setPixmap(image1);
61   RadioButton3->setPixmap(image2);
62
63   GroupPointDirection = new DlgRef_2Sel1Spin(this, "GroupPointDirection");
64   GroupPointDirection->GroupBox1->setTitle(tr("GEOM_PLANE_PV"));
65   GroupPointDirection->TextLabel1->setText(tr("GEOM_POINT"));
66   GroupPointDirection->TextLabel2->setText(tr("GEOM_VECTOR"));
67   GroupPointDirection->TextLabel3->setText(tr("GEOM_PLANE_SIZE"));
68   GroupPointDirection->PushButton1->setPixmap(image3);
69   GroupPointDirection->PushButton2->setPixmap(image3);
70
71   GroupPointPlusCoordinates = new DlgRef_1Sel4Spin(this, "GroupPointPlusCoordinates" );
72   GroupPointPlusCoordinates->GroupBox1->setTitle(tr("GEOM_PLANE_PVC"));
73   GroupPointPlusCoordinates->TextLabel1->setText(tr("GEOM_POINT"));
74   GroupPointPlusCoordinates->TextLabel2->setText(tr("GEOM_COOR"));
75   GroupPointPlusCoordinates->TextLabel3->setText(tr("GEOM_DX"));
76   GroupPointPlusCoordinates->TextLabel4->setText(tr("GEOM_DY"));
77   GroupPointPlusCoordinates->TextLabel5->setText(tr("GEOM_DZ"));
78   GroupPointPlusCoordinates->TextLabel6->setText(tr("GEOM_PLANE_SIZE"));
79   GroupPointPlusCoordinates->PushButton1->setPixmap(image3);
80
81   GroupFace = new DlgRef_1Sel1Spin(this, "GroupFace");
82   GroupFace->GroupBox1->setTitle(tr("GEOM_FACE"));
83   GroupFace->TextLabel1->setText(tr("GEOM_SELECTION"));
84   GroupFace->TextLabel2->setText(tr("GEOM_PLANE_SIZE"));
85   GroupFace->PushButton1->setPixmap(image3);
86     
87   Layout1->addWidget(GroupPointDirection, 1, 0);
88   Layout1->addWidget(GroupPointPlusCoordinates, 1, 0);
89   Layout1->addWidget(GroupFace, 1, 0);
90   /***************************************************************/
91
92   /* Initialisation */
93   myBasicGUI = theBasicGUI;
94   Init();
95 }
96
97
98 //=================================================================================
99 // function : ~BasicGUI_PlaneDlg()
100 // purpose  : Destroys the object and frees any allocated resources
101 //=================================================================================
102 BasicGUI_PlaneDlg::~BasicGUI_PlaneDlg()
103 {  
104   /* no need to delete child widgets, Qt does it all for us */
105 }
106
107
108 //=================================================================================
109 // function : Init()
110 // purpose  :
111 //=================================================================================
112 void BasicGUI_PlaneDlg::Init()
113 {
114   /* init variables */
115   myConstructorId = 0;
116   myEditCurrentArgument = GroupPointDirection->LineEdit1;
117
118   myPoint1.SetCoord(0.0, 0.0, 0.0);
119   myOkPoint1 = myOkDirection = myOkCoordinates = myOkPlanarFace = false;
120
121   /* Filters definition */
122   myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom);
123   myEdgeFilter = new GEOM_ShapeTypeFilter(TopAbs_EDGE, myGeom);
124   myFaceFilter = new GEOM_FaceFilter(StdSelect_Plane, myGeom);
125   /* Filter for the next selection */
126   mySelection->AddFilter(myVertexFilter);
127
128   /* Get setting of step value from file configuration */
129   QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep");
130   step = St.toDouble();
131   this->myTrimSize = 2000.0;
132   
133   /* min, max, step and decimals for spin boxes */
134   GroupPointDirection->SpinBox_DX->RangeStepAndValidator(0.001, 10000000.0, step, 3);
135   GroupPointDirection->SpinBox_DX->SetValue(myTrimSize);
136
137   double SpecificStep = 1;
138   GroupPointPlusCoordinates->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, SpecificStep, 3);
139   GroupPointPlusCoordinates->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, SpecificStep, 3);
140   GroupPointPlusCoordinates->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, SpecificStep, 3);
141   GroupPointPlusCoordinates->SpinBox_DX->SetValue(0.0);
142   GroupPointPlusCoordinates->SpinBox_DY->SetValue(0.0);
143   GroupPointPlusCoordinates->SpinBox_DZ->SetValue(1.0); 
144   GroupPointPlusCoordinates->SpinBox_S->RangeStepAndValidator(0.001, 10000000.0, step, 3);
145   GroupPointPlusCoordinates->SpinBox_S->SetValue(myTrimSize) ;
146
147   GroupFace->SpinBox_DX->RangeStepAndValidator(0.001, 10000000.0, step, 3);
148   GroupFace->SpinBox_DX->SetValue(myTrimSize);
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)), SLOT(ConstructorsClicked(int)));
154
155   connect(GroupPointDirection->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
156   connect(GroupPointDirection->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
157   connect(GroupPointPlusCoordinates->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
158   connect(GroupFace->PushButton1, SIGNAL(clicked()), this, SLOT( SetEditCurrentArgument()));
159
160   connect(GroupPointDirection->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
161   connect(GroupPointDirection->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
162   connect(GroupPointPlusCoordinates->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
163   connect(GroupFace->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
164
165   connect(GroupPointPlusCoordinates->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
166   connect(GroupPointPlusCoordinates->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
167   connect(GroupPointPlusCoordinates->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
168   connect(GroupPointPlusCoordinates->SpinBox_S, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
169   connect(GroupPointDirection->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
170   connect(GroupFace->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
171
172   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPointPlusCoordinates->SpinBox_DX, SLOT(SetStep(double)));
173   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPointPlusCoordinates->SpinBox_DY, SLOT(SetStep(double)));
174   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPointPlusCoordinates->SpinBox_DZ, SLOT(SetStep(double)));
175   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPointPlusCoordinates->SpinBox_S, SLOT(SetStep(double)));
176   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPointDirection->SpinBox_DX, SLOT(SetStep(double)));
177   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupFace->SpinBox_DX, SLOT(SetStep(double)));
178
179   connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
180
181   /* Displays Dialog */
182   GroupPointPlusCoordinates->hide();
183   GroupFace->hide();
184   GroupPointDirection->show();
185   this->show();
186
187   return ;
188 }
189
190
191 //=================================================================================
192 // function : ConstructorsClicked()
193 // purpose  : Radio button management
194 //=================================================================================
195 void BasicGUI_PlaneDlg::ConstructorsClicked(int constructorId)
196 {
197   myConstructorId = constructorId;
198   mySelection->ClearFilters();
199   myGeomBase->EraseSimulationShape();
200   mySimulationTopoDs.Nullify();
201   connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
202   myOkPoint1 = myOkDirection = myOkCoordinates = myOkPlanarFace = false;
203
204   switch (constructorId)
205     {
206     case 0: /* plane from a point and a direction (vector, edge...) */
207       { 
208         GroupPointPlusCoordinates->hide();
209         GroupFace->hide();
210         resize(0, 0);
211         GroupPointDirection->show();
212
213         myEditCurrentArgument = GroupPointDirection->LineEdit1;
214         GroupPointDirection->LineEdit1->setText(tr(""));
215         GroupPointDirection->LineEdit2->setText(tr(""));
216
217         /* for the first argument */
218         mySelection->AddFilter(myVertexFilter);
219         break;
220       }
221     case 1: /* plane from a point and vector coordinates */
222       {
223         GroupPointDirection->hide();
224         GroupFace->hide();
225         resize(0, 0);
226         GroupPointPlusCoordinates->show();
227
228         myEditCurrentArgument = GroupPointPlusCoordinates->LineEdit1;
229         GroupPointPlusCoordinates->LineEdit1->setText(tr(""));
230         GroupPointPlusCoordinates->SpinBox_DX->SetValue(0.0);
231         GroupPointPlusCoordinates->SpinBox_DY->SetValue(0.0);
232         GroupPointPlusCoordinates->SpinBox_DZ->SetValue(1.0);
233         myOkCoordinates = true;
234
235         /* for the first argument */
236         mySelection->AddFilter(myVertexFilter);
237         break;
238       } 
239     case 2: /* plane from a planar face selection */
240       {
241         GroupPointDirection->hide();
242         GroupPointPlusCoordinates->hide();
243         resize(0, 0);
244         GroupFace->show();
245
246         myEditCurrentArgument = GroupFace->LineEdit1;
247         GroupFace->LineEdit1->setText(tr(""));
248
249         /* for the first argument */
250         mySelection->AddFilter(myFaceFilter);
251         break;
252       }
253     }
254   return;
255 }
256
257
258 //=================================================================================
259 // function : ClickOnOk()
260 // purpose  :
261 //=================================================================================
262 void BasicGUI_PlaneDlg::ClickOnOk()
263 {
264   this->ClickOnApply();
265   ClickOnCancel();
266   return ;
267 }
268
269
270 //=================================================================================
271 // function : ClickOnApply()
272 // purpose  :
273 //=================================================================================
274 void BasicGUI_PlaneDlg::ClickOnApply()
275 {
276   QAD_Application::getDesktop()->putInfo(tr(""));
277   if (mySimulationTopoDs.IsNull())
278     return;
279   myGeomBase->EraseSimulationShape();
280   mySimulationTopoDs.Nullify();
281
282   switch(myConstructorId)
283     { 
284     case 0 : /* args are myPoint1 and myDx, myDy, myDz from a vector(edge) */
285       { 
286         if(myOkPoint1 && myOkDirection)
287           myBasicGUI->MakePlaneAndDisplay(myPoint1, myDx, myDy, myDz, myTrimSize);
288         break;
289       }
290     case 1 : /* args are myPoint1 and myDx, myDy, myDz from a Spin Box */
291       { 
292         if(myOkPoint1)
293           myBasicGUI->MakePlaneAndDisplay(myPoint1, myDx, myDy, myDz, myTrimSize);
294         break;
295       }
296     case 2 :  /* arg is a planar face selection */
297       {
298         if(myOkPlanarFace)
299           myBasicGUI->MakePlaneAndDisplay(myPoint1, myDx, myDy, myDz, myTrimSize);
300         break;
301       }
302     }
303   return;
304 }
305
306
307 //=================================================================================
308 // function : SelectionIntoArgument()
309 // purpose  : Called when selection has changed
310 //=================================================================================
311 void BasicGUI_PlaneDlg::SelectionIntoArgument()
312 {
313   myGeomBase->EraseSimulationShape(); 
314   mySimulationTopoDs.Nullify();
315   QString aString = "";
316   
317   int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString);
318   if(nbSel != 1) {
319     switch (myConstructorId) 
320       {
321        case 0:
322          {
323            if(myEditCurrentArgument == GroupPointDirection->LineEdit1) {
324              GroupPointDirection->LineEdit1->setText("");
325              myOkPoint1 = false ;
326            }
327            else if(myEditCurrentArgument == GroupPointDirection->LineEdit2) {
328              GroupPointDirection->LineEdit2->setText("");
329              myOkDirection = false ;
330            }
331            break;
332          }
333       case 1:
334         {
335           if(myEditCurrentArgument == GroupPointPlusCoordinates->LineEdit1) {
336             GroupPointPlusCoordinates->LineEdit1->setText("") ;
337             myOkPoint1 = false ;
338           }
339           break;
340         }
341       case 2:
342         {
343           if(myEditCurrentArgument == GroupFace->LineEdit1) {
344             GroupFace->LineEdit1->setText("") ;
345             if(aString.compare("") == 0)
346               myOkPlanarFace = false;
347             else
348               myOkPlanarFace = true;
349           }
350           break;
351         }
352       }
353     return ;
354   }
355
356   /*  nbSel == 1  */ 
357   TopoDS_Shape S; 
358   if(!myGeomBase->GetTopoFromSelection(mySelection, S))
359     return ;
360  
361   /* FIRST CONSTRUCTOR */
362   if(myEditCurrentArgument == GroupPointDirection->LineEdit1 && myGeomBase->VertexToPoint(S, myPoint1)) {
363     GroupPointDirection->LineEdit1->setText(aString);
364     myOkPoint1 = true;
365   }
366   else if( myEditCurrentArgument == GroupPointDirection->LineEdit2) {
367     /* We verify if the selection is a linear edge */
368     gp_Pnt Pfirst, Plast;
369     if( myGeomBase->LinearEdgeExtremities(S, Pfirst, Plast)) {    
370       myGeomBase->GetBipointDxDyDz(Pfirst, Plast, myDx, myDy, myDz);
371       GroupPointDirection->LineEdit2->setText(aString);
372       myOkDirection = true;
373       myTrimSize = GroupPointDirection->SpinBox_DX->GetValue();
374     }
375   }
376   
377   /* SECOND CONSTRUCTOR */
378   else if(myEditCurrentArgument == GroupPointPlusCoordinates->LineEdit1 && myGeomBase->VertexToPoint(S, myPoint1)) {
379     GroupPointPlusCoordinates->LineEdit1->setText(aString);
380     /* Get arguments */
381     myDx = GroupPointPlusCoordinates->SpinBox_DX->GetValue();
382     myDy = GroupPointPlusCoordinates->SpinBox_DY->GetValue();
383     myDz = GroupPointPlusCoordinates->SpinBox_DZ->GetValue();
384     myTrimSize = GroupPointPlusCoordinates->SpinBox_S->GetValue();
385     myOkPoint1 = true;    
386     myOkCoordinates = true;
387   }
388  
389   /* THIRD CONSTRUCTOR */
390   else if(myEditCurrentArgument == GroupFace->LineEdit1) {
391     if(myOkPlanarFace) {
392       GroupFace->LineEdit1->setText(aString);
393       BRepAdaptor_Surface surf(TopoDS::Face(S));
394       gp_Pln Plane = surf.Plane();
395
396       gp_Pnt myPoint1 = Plane.Location();
397       gp_Ax1 ax = Plane.Axis();
398       myDx = (ax.Direction()).X();
399       myDy = (ax.Direction()).Y();
400       myDz = (ax.Direction()).Z();
401       myTrimSize = GroupFace->SpinBox_DX->GetValue();
402     }
403   }
404
405   /* Call method simulation */    
406   if((myOkPoint1 && myOkDirection) || (myOkPoint1 && myOkCoordinates) || myOkPlanarFace) {
407     if(myDx*myDx + myDy*myDy + myDz*myDz > Precision::Confusion()*Precision::Confusion())
408       this->MakePlaneSimulationAndDisplay();
409   }
410   return;
411 }
412
413
414 //=================================================================================
415 // function : SetEditCurrentArgument()
416 // purpose  :
417 //=================================================================================
418 void BasicGUI_PlaneDlg::SetEditCurrentArgument()
419 {
420   QPushButton* send = (QPushButton*)sender();  
421   mySelection->ClearFilters();
422
423   switch(myConstructorId)
424     {
425     case 0:
426       { 
427         if(send == GroupPointDirection->PushButton1) {
428           GroupPointDirection->LineEdit1->setFocus();
429           myEditCurrentArgument = GroupPointDirection->LineEdit1;
430           mySelection->AddFilter(myVertexFilter);
431         }
432         else if(send == GroupPointDirection->PushButton2) {
433           GroupPointDirection->LineEdit2->setFocus();
434           myEditCurrentArgument = GroupPointDirection->LineEdit2;       
435           /* Edge filter here */
436           mySelection->AddFilter(myEdgeFilter);
437         }       
438         break;
439       }
440     case 1:
441       { 
442         if(send == GroupPointPlusCoordinates->PushButton1) {
443           GroupPointPlusCoordinates->LineEdit1->setFocus();
444           myEditCurrentArgument = GroupPointPlusCoordinates->LineEdit1;
445           /* Vertex filter here */
446           mySelection->AddFilter(myVertexFilter);
447         }
448         break;
449       }
450     case 2:
451       {
452         if(send == GroupFace->PushButton1) {
453           GroupFace->LineEdit1->setFocus();
454           myEditCurrentArgument = GroupFace->LineEdit1;
455           /* Face filter here */
456           mySelection->AddFilter(myFaceFilter);
457         }
458         break;
459       }
460     }
461   this->SelectionIntoArgument();
462   return;
463 }
464
465
466 //=================================================================================
467 // function : LineEditReturnPressed()
468 // purpose  :
469 //=================================================================================
470 void BasicGUI_PlaneDlg::LineEditReturnPressed()
471 {
472   QLineEdit* send = (QLineEdit*)sender();  
473   if(send == GroupPointDirection->LineEdit1)
474     myEditCurrentArgument = GroupPointDirection->LineEdit1;
475   else if (send == GroupPointDirection->LineEdit2)
476     myEditCurrentArgument = GroupPointDirection->LineEdit2; 
477   else if (send == GroupPointPlusCoordinates->LineEdit1)
478     myEditCurrentArgument = GroupPointPlusCoordinates->LineEdit1;
479   else if (send == GroupFace->LineEdit1)
480     myEditCurrentArgument = GroupFace->LineEdit1;
481   else
482     return;
483
484   GEOMBase_Skeleton::LineEditReturnPressed();
485   return ;
486 }
487
488
489 //=================================================================================
490 // function : ActivateThisDialog()
491 // purpose  :
492 //=================================================================================
493 void BasicGUI_PlaneDlg::ActivateThisDialog()
494 {
495   GEOMBase_Skeleton::ActivateThisDialog();
496   connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
497   switch(myConstructorId)
498     {
499     case 0:
500       { 
501         GroupPointDirection->LineEdit1->setFocus();
502         myEditCurrentArgument = GroupPointDirection->LineEdit1;
503         mySelection->AddFilter(myVertexFilter);
504         break;
505       }
506     case 1:
507       { 
508         GroupPointPlusCoordinates->LineEdit1->setFocus();
509         myEditCurrentArgument = GroupPointPlusCoordinates->LineEdit1;
510         mySelection->AddFilter(myVertexFilter);
511         break;
512       }
513     case 2:
514       {
515         GroupFace->LineEdit1->setFocus();
516         myEditCurrentArgument = GroupFace->LineEdit1;
517         mySelection->AddFilter(myFaceFilter);
518         break;
519       }
520     }
521   if(!mySimulationTopoDs.IsNull())
522     myGeomBase->DisplaySimulationShape(mySimulationTopoDs);
523   return;
524 }
525
526
527 //=================================================================================
528 // function : enterEvent()
529 // purpose  :
530 //=================================================================================
531 void BasicGUI_PlaneDlg::enterEvent(QEvent* e)
532 {
533   if (GroupConstructors->isEnabled())
534     return;  
535   this->ActivateThisDialog();
536   return;
537 }
538
539
540 //=================================================================================
541 // function : ValueChangedInSpinBox()
542 // purpose  :
543 //=================================================================================
544 void BasicGUI_PlaneDlg::ValueChangedInSpinBox(double newValue)
545 {
546   QObject* send = (QObject*)sender(); 
547   
548   if(send == GroupPointPlusCoordinates->SpinBox_DX)
549     myDx = newValue;
550   else if(send == GroupPointPlusCoordinates->SpinBox_DY) 
551     myDy = newValue;
552   else if(send == GroupPointPlusCoordinates->SpinBox_DZ)
553     myDz = newValue;
554   else if(send == GroupPointDirection->SpinBox_DX || send == GroupPointPlusCoordinates->SpinBox_S || send == GroupFace->SpinBox_DX) {
555     myTrimSize = newValue;
556   } else
557     return;
558
559   if((myOkPoint1 && myOkDirection) || (myOkPoint1 && myOkCoordinates) || myOkPlanarFace) {
560     if(myDx*myDx + myDy*myDy + myDz*myDz > Precision::Confusion() * Precision::Confusion())
561       this->MakePlaneSimulationAndDisplay();
562   }
563   return;
564 }
565
566
567 //=================================================================================
568 // function : MakePlaneSimulationAndDisplay(()
569 // purpose  :
570 //=================================================================================
571 void BasicGUI_PlaneDlg::MakePlaneSimulationAndDisplay()
572 {
573   myGeomBase->EraseSimulationShape();
574   mySimulationTopoDs.Nullify();
575
576   try {
577     gp_Dir aDirection(myDx, myDy, myDz);
578     /* We make a trimmed plane */
579     gp_Pln gplane(myPoint1, aDirection);
580     mySimulationTopoDs = BRepBuilderAPI_MakeFace(gplane, -myTrimSize, +myTrimSize, -myTrimSize, +myTrimSize);
581     myGeomBase->DisplaySimulationShape(mySimulationTopoDs);
582   }
583   catch(Standard_Failure) {
584     MESSAGE( "Exception catched in MakePlaneSimulation" << endl );
585     return;
586   }
587   return;
588 }