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