Salome HOME
Remove some methods of GEOMBase_Helper (IObjectCount(), firstIObject(), lastIObject...
[modules/geom.git] / src / GenerationGUI / GenerationGUI_PrismDlg.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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File   : GenerationGUI_PrismDlg.cxx
23 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
24 //
25
26 #include "GenerationGUI_PrismDlg.h"
27
28 #include <DlgRef.h>
29 #include <GeometryGUI.h>
30 #include <GEOMBase.h>
31
32 #include <SUIT_ResourceMgr.h>
33 #include <SUIT_Session.h>
34 #include <SalomeApp_Application.h>
35 #include <LightApp_SelectionMgr.h>
36
37 #include <TopoDS_Shape.hxx>
38 #include <TopoDS_Edge.hxx>
39 #include <TopoDS.hxx>
40 #include <TopExp.hxx>
41 #include <TColStd_IndexedMapOfInteger.hxx>
42 #include <TopTools_IndexedMapOfShape.hxx>
43
44 #include <GEOMImpl_Types.hxx>
45
46 //=================================================================================
47 // class    : GenerationGUI_PrismDlg()
48 // purpose  : Constructs a GenerationGUI_PrismDlg which is a child of 'parent', with the 
49 //            name 'name' and widget flags set to 'f'.
50 //            The dialog will by default be modeless, unless you set 'modal' to
51 //            TRUE to construct a modal dialog.
52 //=================================================================================
53 GenerationGUI_PrismDlg::GenerationGUI_PrismDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
54                                                 bool modal, Qt::WindowFlags fl )
55   : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
56 {
57   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
58   QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_PRISM" ) ) );
59   QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
60   QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_PRISM_2P" ) ) );
61   QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_PRISM_DXDYDZ" ) ) );
62
63   setWindowTitle( tr( "GEOM_EXTRUSION_TITLE" ) );
64
65   /***************************************************************/
66   mainFrame()->GroupConstructors->setTitle( tr( "GEOM_EXTRUSION" ) );
67   mainFrame()->RadioButton1->setIcon( image0 );
68   mainFrame()->RadioButton2->setIcon( image2 );
69   mainFrame()->RadioButton3->setIcon( image3 );
70
71   mainFrame()->RadioButton1->setChecked( true );
72   myBothway = myBothway2 = myBothway3 = false;
73
74   GroupPoints = new DlgRef_2Sel1Spin2Check( centralWidget() );
75   GroupPoints->GroupBox1->setTitle( tr( "GEOM_EXTRUSION_BSV" ) );
76   GroupPoints->TextLabel1->setText( tr( "GEOM_BASE" ) );
77   GroupPoints->TextLabel2->setText( tr( "GEOM_VECTOR" ) );
78   GroupPoints->TextLabel3->setText( tr( "GEOM_HEIGHT" ) );
79   GroupPoints->PushButton1->setIcon( image1 );
80   GroupPoints->PushButton2->setIcon( image1 );
81   GroupPoints->LineEdit1->setReadOnly( true );
82   GroupPoints->LineEdit2->setReadOnly( true );
83   GroupPoints->CheckButton1->setText( tr( "GEOM_BOTHWAY" ) );
84   GroupPoints->CheckButton1->setChecked( myBothway );
85   GroupPoints->CheckButton2->setText( tr( "GEOM_REVERSE" ) );
86
87   GroupPoints2 = new DlgRef_3Sel1Check( centralWidget() );
88   GroupPoints2->GroupBox1->setTitle( tr( "GEOM_EXTRUSION_BSV_2P" ) );
89   GroupPoints2->TextLabel1->setText( tr( "GEOM_BASE" ) );
90   GroupPoints2->TextLabel2->setText( tr( "GEOM_POINT_I" ).arg( 1 ) );
91   GroupPoints2->TextLabel3->setText( tr( "GEOM_POINT_I" ).arg( 2 ) );
92   GroupPoints2->PushButton1->setIcon( image1 );
93   GroupPoints2->PushButton2->setIcon( image1 );
94   GroupPoints2->PushButton3->setIcon( image1 );
95   GroupPoints2->CheckButton1->setText( tr( "GEOM_BOTHWAY" ) );
96   GroupPoints2->CheckButton1->setChecked( myBothway2 );
97
98   GroupPoints3 = new DlgRef_1Sel3Spin1Check( centralWidget() );
99   GroupPoints3->GroupBox1->setTitle(tr("GEOM_EXTRUSION_DXDYDZ"));
100   GroupPoints3->TextLabel1->setText(tr("GEOM_BASE"));
101   GroupPoints3->PushButton1->setIcon(image1);
102   GroupPoints3->TextLabel2->setText(tr("GEOM_DX"));
103   GroupPoints3->TextLabel3->setText(tr("GEOM_DY"));
104   GroupPoints3->TextLabel4->setText(tr("GEOM_DZ"));
105   GroupPoints3->CheckButton1->setText( tr( "GEOM_BOTHWAY" ) );
106   GroupPoints3->CheckButton1->setChecked( myBothway3 );
107
108   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
109   layout->setMargin( 0 ); layout->setSpacing( 6 );
110   layout->addWidget( GroupPoints );
111   layout->addWidget( GroupPoints2 );
112   layout->addWidget( GroupPoints3);
113   /***************************************************************/
114
115   setHelpFileName( "create_extrusion_page.html" );
116
117   Init();
118 }
119
120
121 //=================================================================================
122 // function : ~GenerationGUI_PrismDlg()
123 // purpose  : Destroys the object and frees any allocated resources
124 //=================================================================================
125 GenerationGUI_PrismDlg::~GenerationGUI_PrismDlg()
126 {  
127   // no need to delete child widgets, Qt does it all for us
128 }
129
130
131 //=================================================================================
132 // function : Init()
133 // purpose  :
134 //=================================================================================
135 void GenerationGUI_PrismDlg::Init()
136 {
137   /* init variables */
138   myEditCurrentArgument = GroupPoints->LineEdit1;
139   GroupPoints->LineEdit1->setReadOnly( true );
140   GroupPoints->LineEdit2->setReadOnly( true );
141
142   GroupPoints2->LineEdit1->setReadOnly( true );
143   GroupPoints2->LineEdit2->setReadOnly( true );
144   GroupPoints2->LineEdit3->setReadOnly( true );
145
146   GroupPoints3->LineEdit1->setReadOnly( true );
147
148   myPoint1 = myPoint2 = myBase = myVec = GEOM::GEOM_Object::_nil();
149   myOkBase = myOkVec = myOkPnt1 = myOkPnt2 = false;
150   
151   /* Get setting of step value from file configuration */
152   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
153   double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
154
155   /* min, max, step and decimals for spin boxes & initial values */
156   initSpinBox( GroupPoints3->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
157   initSpinBox( GroupPoints3->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
158   initSpinBox( GroupPoints3->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
159   GroupPoints3->SpinBox_DX->setValue( 0.0 );
160   GroupPoints3->SpinBox_DY->setValue( 0.0 );
161   GroupPoints3->SpinBox_DZ->setValue( 0.0 );
162
163   initSpinBox( GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
164   GroupPoints->SpinBox_DX->setValue( 100.0 );
165
166   /* signals and slots connections */
167   connect( buttonOk(),    SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
168   connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
169
170   connect( this,          SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
171
172   connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
173   connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
174
175   connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
176   connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
177
178   connect( GroupPoints->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
179   connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
180
181   connect( GroupPoints->CheckButton1,  SIGNAL( toggled( bool ) ), this, SLOT( onBothway() ) );
182   connect( GroupPoints->CheckButton2,  SIGNAL( toggled( bool ) ), this, SLOT( onReverse() ) );
183
184   connect( GroupPoints2->PushButton1,  SIGNAL( clicked() ),       this, SLOT( SetEditCurrentArgument() ) );
185   connect( GroupPoints2->PushButton2,  SIGNAL( clicked() ),       this, SLOT( SetEditCurrentArgument() ) );
186   connect( GroupPoints2->PushButton3,  SIGNAL( clicked() ),       this, SLOT( SetEditCurrentArgument() ) );
187   connect( GroupPoints2->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( onBothway() ) );
188
189   connect( GroupPoints2->LineEdit1,    SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
190   connect( GroupPoints2->LineEdit2,    SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
191   connect( GroupPoints2->LineEdit3,    SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
192
193   connect( GroupPoints3->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
194   connect( GroupPoints3->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
195   connect( GroupPoints3->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
196   connect( GroupPoints3->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
197   connect( GroupPoints3->SpinBox_DZ, SIGNAL( valueChanged ( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
198   connect( GroupPoints3->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( onBothway() ) );
199
200   connect( myGeomGUI->getApp()->selectionMgr(),
201            SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
202
203   initName( tr( "GEOM_EXTRUSION" ) );
204
205   ConstructorsClicked( 0 );
206 }
207
208 //=================================================================================
209 // function : SetDoubleSpinBoxStep()
210 // purpose  : Double spin box management
211 //=================================================================================
212 void GenerationGUI_PrismDlg::SetDoubleSpinBoxStep( double step )
213 {
214   GroupPoints->SpinBox_DX->setSingleStep(step);
215   GroupPoints3->SpinBox_DX->setSingleStep(step);
216   GroupPoints3->SpinBox_DY->setSingleStep(step);
217   GroupPoints3->SpinBox_DZ->setSingleStep(step);
218 }
219
220
221 //=================================================================================
222 // function : ConstructorsClicked()
223 // purpose  : Radio button management
224 //=================================================================================
225 void GenerationGUI_PrismDlg::ConstructorsClicked( int constructorId )
226 {
227   erasePreview();
228   disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
229
230   switch ( constructorId ) {
231   case 0:
232     {
233       globalSelection( GEOM_ALLSHAPES );
234
235       GroupPoints2->hide();
236       GroupPoints3->hide();
237       GroupPoints->show();
238       
239       myEditCurrentArgument = GroupPoints->LineEdit1;
240       GroupPoints->LineEdit1->setText( GroupPoints2->LineEdit1->text() ); // keep base
241       GroupPoints->LineEdit2->setText( "" );
242       myVec = GEOM::GEOM_Object::_nil();
243       myOkVec = false;
244       
245       break;
246     }
247   case 1:
248     {
249       globalSelection( GEOM_ALLSHAPES );
250
251       GroupPoints->hide();
252       GroupPoints2->show();
253       GroupPoints3->hide();
254       
255       myEditCurrentArgument = GroupPoints2->LineEdit1;
256       GroupPoints2->LineEdit1->setText( GroupPoints->LineEdit1->text() ); // keep base
257       GroupPoints2->LineEdit2->setText( "" );
258       GroupPoints2->LineEdit3->setText( "" );
259       myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
260       myOkPnt1 = myOkPnt2 = false;
261       
262       break;
263     }
264   case 2:
265     {
266       globalSelection( GEOM_ALLSHAPES );
267
268       GroupPoints->hide();
269       GroupPoints2->hide();
270       GroupPoints3->show();
271
272       myEditCurrentArgument = GroupPoints3->LineEdit1;
273       GroupPoints3->LineEdit1->setText( GroupPoints->LineEdit1->text() ); // keep base
274     }
275   }
276
277   qApp->processEvents();
278   updateGeometry();
279   resize( minimumSize() );
280
281   myEditCurrentArgument->setFocus();
282   connect( myGeomGUI->getApp()->selectionMgr(),
283            SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
284
285   if ( !myOkBase )
286     SelectionIntoArgument();
287 }
288
289
290 //=================================================================================
291 // function : ClickOnOk()
292 // purpose  :
293 //=================================================================================
294 void GenerationGUI_PrismDlg::ClickOnOk()
295 {
296   if ( ClickOnApply() )
297     ClickOnCancel();
298 }
299
300
301 //=================================================================================
302 // function : ClickOnApply()
303 // purpose  :
304 //=================================================================================
305 bool GenerationGUI_PrismDlg::ClickOnApply()
306 {
307   if ( !onAccept() )
308     return false;
309
310   initName();
311   return true;
312 }
313
314
315 //=================================================================================
316 // function : SelectionIntoArgument()
317 // purpose  : Called when selection has changed
318 //=================================================================================
319 void GenerationGUI_PrismDlg::SelectionIntoArgument()
320 {
321   erasePreview();
322   myEditCurrentArgument->setText( "" );
323
324   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
325   SALOME_ListIO aSelList;
326   aSelMgr->selectedObjects(aSelList);
327
328   if (getConstructorId() == 0)
329   {
330     if (aSelList.Extent() != 1) {
331       if (myEditCurrentArgument == GroupPoints->LineEdit1)
332         myOkBase = false;
333       else if (myEditCurrentArgument == GroupPoints->LineEdit2)
334         myOkVec = false;
335       return;
336     }
337
338     // nbSel == 1
339     Standard_Boolean testResult = Standard_False;
340     GEOM::GEOM_Object_var aSelectedObject =
341       GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
342     if (!testResult)
343       return;
344
345     bool myOk = true;
346     TopoDS_Shape aShape;
347     QString aName = GEOMBase::GetName( aSelectedObject );    
348     if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
349       TColStd_IndexedMapOfInteger aMap;
350       aSelMgr->GetIndexes(aSelList.First(), aMap);
351       if (aMap.Extent() == 1) {
352         int anIndex = aMap(1);
353         aName.append( ":edge_" + QString::number( anIndex ) );
354         
355         //Find SubShape Object in Father
356         GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName );
357         
358         if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
359           GEOM::GEOM_IShapesOperations_var aShapesOp =
360             getGeomEngine()->GetIShapesOperations( getStudyId() );
361           aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
362         }
363         else {
364           aSelectedObject = aFindedObject; // get Object from study           
365         }
366       }
367       else {
368         if ( aShape.ShapeType() != TopAbs_EDGE && myEditCurrentArgument == GroupPoints->LineEdit2 ) {
369           aSelectedObject = GEOM::GEOM_Object::_nil();
370           aName = "";
371           myOk = false;
372         }
373       }
374     }
375     
376     if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
377       myBase = aSelectedObject;
378       myOkBase = true;
379     }
380     else if ( myEditCurrentArgument == GroupPoints->LineEdit2 && myOk ) {
381       myOkVec = true;      
382       myVec = aSelectedObject;
383     }
384     myEditCurrentArgument->setText( aName );
385   }
386   else if (getConstructorId() == 1) { // getConstructorId()==1 - extrusion using 2 points
387     if (aSelList.Extent() != 1) {
388       if (myEditCurrentArgument == GroupPoints2->LineEdit1)
389         myOkBase = false;
390       else if (myEditCurrentArgument == GroupPoints2->LineEdit2) {
391         myPoint1 = GEOM::GEOM_Object::_nil();
392         myOkPnt1 = false;
393       }
394       else if (myEditCurrentArgument == GroupPoints2->LineEdit3) {
395         myPoint2 = GEOM::GEOM_Object::_nil();
396         myOkPnt2 = false;
397       }
398       return;
399     }
400
401     // nbSel == 1
402     Standard_Boolean testResult = Standard_False;
403     GEOM::GEOM_Object_var aSelectedObject =
404       GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
405
406     if (!testResult || CORBA::is_nil(aSelectedObject))
407       return;
408
409     QString aName = GEOMBase::GetName(aSelectedObject);
410     TopoDS_Shape aShape;
411     bool myOk = true;
412     if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) {
413       TColStd_IndexedMapOfInteger aMap;
414       aSelMgr->GetIndexes(aSelList.First(), aMap );
415       if (aMap.Extent() == 1) {
416         int anIndex = aMap(1);
417         aName.append( ":vertex_" + QString::number( anIndex ) );
418
419         //Find SubShape Object in Father
420         GEOM::GEOM_Object_var aFindedObject = findObjectInFather( aSelectedObject, aName );
421         
422         if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
423           GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
424           aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
425         }
426         else {
427           aSelectedObject = aFindedObject;
428         }
429       }
430       else {
431         if ( ( aShape.ShapeType() != TopAbs_VERTEX && myEditCurrentArgument == GroupPoints2->LineEdit2 ) ||
432              ( aShape.ShapeType() != TopAbs_VERTEX && myEditCurrentArgument == GroupPoints2->LineEdit3 ) ) {
433           aSelectedObject = GEOM::GEOM_Object::_nil();
434           aName = "";
435           myOk = false;
436         }
437       }
438     }
439
440     myEditCurrentArgument->setText( aName );
441
442     if ( myEditCurrentArgument == GroupPoints2->LineEdit1 ) {
443       myOkBase = true;
444       myBase = aSelectedObject;
445     }
446     else if ( myEditCurrentArgument == GroupPoints2->LineEdit2 && myOk ) {
447       myOkPnt1 = true;
448       myPoint1 = aSelectedObject;
449     }
450     else if ( myEditCurrentArgument == GroupPoints2->LineEdit3 && myOk ) {
451       myOkPnt2 = true;
452       myPoint2 = aSelectedObject;
453     }
454   }
455   else if (getConstructorId() == 2) { // extrusion using dx dy dz
456     Standard_Boolean testResult = Standard_False;
457     GEOM::GEOM_Object_var aSelectedObject =
458       GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
459
460     if (!testResult || CORBA::is_nil(aSelectedObject))
461       return;
462
463     QString aName = GEOMBase::GetName(aSelectedObject);
464     myBase = aSelectedObject;
465     myEditCurrentArgument->setText(aName);
466   }
467
468   displayPreview();
469 }
470
471 //=================================================================================
472 // function : SetEditCurrentArgument()
473 // purpose  :
474 //=================================================================================
475 void GenerationGUI_PrismDlg::SetEditCurrentArgument()
476 {
477   QPushButton* send = (QPushButton*)sender();
478   globalSelection( GEOM_ALLSHAPES );
479
480   if ( send == GroupPoints->PushButton1 ) {
481     GroupPoints->LineEdit1->setFocus();
482     myEditCurrentArgument = GroupPoints->LineEdit1;
483   }
484   else if ( send == GroupPoints->PushButton2 ) {
485     GroupPoints->LineEdit2->setFocus();
486     myEditCurrentArgument = GroupPoints->LineEdit2;
487     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
488   }
489   else if ( send == GroupPoints2->PushButton1 ) {
490     GroupPoints2->LineEdit1->setFocus();
491     myEditCurrentArgument = GroupPoints2->LineEdit1;
492   }
493   else if ( send == GroupPoints2->PushButton2 ) {
494     GroupPoints2->LineEdit2->setFocus();
495     myEditCurrentArgument = GroupPoints2->LineEdit2;
496     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
497   }
498   else if ( send == GroupPoints2->PushButton3 ) {
499     GroupPoints2->LineEdit3->setFocus();
500     myEditCurrentArgument = GroupPoints2->LineEdit3;
501     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
502   }
503   else   if ( send == GroupPoints3->PushButton1 ) {
504     GroupPoints3->LineEdit1->setFocus();
505     myEditCurrentArgument = GroupPoints3->LineEdit1;
506   }
507
508   myEditCurrentArgument->setFocus();
509   SelectionIntoArgument();
510 }
511
512
513 //=================================================================================
514 // function : LineEditReturnPressed()
515 // purpose  :
516 //=================================================================================
517 void GenerationGUI_PrismDlg::LineEditReturnPressed()
518 {
519   QLineEdit* send = (QLineEdit*)sender();
520   if ( send == GroupPoints->LineEdit1 ||
521        send == GroupPoints->LineEdit2 ||
522        send == GroupPoints2->LineEdit1 ||
523        send == GroupPoints2->LineEdit2 ||
524        send == GroupPoints2->LineEdit3 ||
525        send == GroupPoints3->LineEdit1) {
526     myEditCurrentArgument = send;
527     GEOMBase_Skeleton::LineEditReturnPressed();
528   }
529 }
530
531 //=================================================================================
532 // function : enterEvent()
533 // purpose  : when mouse enter onto the QWidget
534 //=================================================================================
535 void GenerationGUI_PrismDlg::enterEvent( QEvent* )
536 {
537   if ( !mainFrame()->GroupConstructors->isEnabled() )
538     ActivateThisDialog();
539 }
540
541
542 //=================================================================================
543 // function : ActivateThisDialog()
544 // purpose  :
545 //=================================================================================
546 void GenerationGUI_PrismDlg::ActivateThisDialog()
547 {
548   GEOMBase_Skeleton::ActivateThisDialog();
549
550   connect( myGeomGUI->getApp()->selectionMgr(),
551            SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
552
553   ConstructorsClicked( getConstructorId() );
554 }
555
556
557 //=================================================================================
558 // function : ValueChangedInSpinBox()
559 // purpose  :
560 //=================================================================================
561 void GenerationGUI_PrismDlg::ValueChangedInSpinBox()
562 {
563   displayPreview();
564 }
565
566
567 //=================================================================================
568 // function : getHeight()
569 // purpose  :
570 //=================================================================================
571 double GenerationGUI_PrismDlg::getHeight() const
572 {
573   return GroupPoints->SpinBox_DX->value();
574 }
575
576 //=================================================================================
577 // function : createOperation
578 // purpose  :
579 //=================================================================================
580 GEOM::GEOM_IOperations_ptr GenerationGUI_PrismDlg::createOperation()
581 {
582   return getGeomEngine()->GetI3DPrimOperations( getStudyId() );
583 }
584
585 //=================================================================================
586 // function : isValid
587 // purpose  :
588 //=================================================================================
589 bool GenerationGUI_PrismDlg::isValid( QString& )
590 {
591   if ( getConstructorId() == 0 )
592     return ( myOkBase && myOkVec );     // by vector and height
593   else if ( getConstructorId() == 1 )
594     return ( myOkBase && myOkPnt1 && myOkPnt2 );   // by two points
595   else if ( getConstructorId() == 2 )
596     return true;
597 }
598
599 //=================================================================================
600 // function : execute
601 // purpose  :
602 //=================================================================================
603 bool GenerationGUI_PrismDlg::execute( ObjectList& objects )
604 {
605   GEOM::GEOM_Object_var anObj;
606
607   switch ( getConstructorId() ) {
608   case 0 :
609     if ( !myBothway ) {
610       anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->
611         MakePrismVecH( myBase, myVec, getHeight() );
612     }
613     else {
614       anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->
615         MakePrismVecH2Ways( myBase, myVec, getHeight() );
616     }
617     break;
618   case 1 :
619     if ( !myBothway2 ) {
620       anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->
621         MakePrismTwoPnt( myBase, myPoint1, myPoint2 );
622     }
623     else {
624       anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->
625         MakePrismTwoPnt2Ways( myBase, myPoint1, myPoint2 );
626     }
627     break;
628   case 2 :
629     double dx = GroupPoints3->SpinBox_DX->value();
630     double dy = GroupPoints3->SpinBox_DY->value();
631     double dz = GroupPoints3->SpinBox_DZ->value();
632
633     if ( !myBothway3 ) {
634       anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->
635         MakePrismDXDYDZ( myBase, dx, dy, dz );
636     }
637     else {
638       anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->
639         MakePrismDXDYDZ2Ways( myBase, dx, dy, dz );
640     }
641     break;
642   }
643   if ( !anObj->_is_nil() )
644     objects.push_back( anObj._retn() );
645
646   return true;
647 }
648
649
650 //=================================================================================
651 // function :  onReverse()
652 // purpose  :
653 //=================================================================================
654 void GenerationGUI_PrismDlg::onReverse()
655 {
656   double anOldValue = GroupPoints->SpinBox_DX->value();
657   GroupPoints->SpinBox_DX->setValue( -anOldValue );
658 }
659
660 //=================================================================================
661 // function :  onBothway()
662 // purpose  :  
663 //=================================================================================
664 void GenerationGUI_PrismDlg::onBothway()
665 {
666   bool anOldValue;
667   switch ( getConstructorId() ) {
668   case 0:
669     anOldValue = myBothway;
670     myBothway = !anOldValue;
671     GroupPoints->CheckButton2->setEnabled( !myBothway );
672     displayPreview();
673     break;
674   case 1:
675     anOldValue = myBothway2;
676     myBothway2 = !anOldValue;
677     displayPreview();
678     break;
679   case 2:
680     anOldValue = myBothway3;
681     myBothway3 = !anOldValue;
682     displayPreview();
683     break;
684   }
685 }
686
687 //=================================================================================
688 // function : addSubshapeToStudy
689 // purpose  : virtual method to add new SubObjects if local selection
690 //=================================================================================
691 void GenerationGUI_PrismDlg::addSubshapesToStudy()
692 {
693   QMap<QString, GEOM::GEOM_Object_var> objMap;
694
695   switch ( getConstructorId() ) {
696   case 0:
697     objMap[GroupPoints->LineEdit2->text()] = myVec;
698     break;
699   case 1:
700     objMap[GroupPoints2->LineEdit2->text()] = myPoint1;
701     objMap[GroupPoints2->LineEdit3->text()] = myPoint2;
702     break;
703   }
704   addSubshapesToFather( objMap );
705 }