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