Salome HOME
89a11bfb3f070ff5a67e40c07670264b05bcef88
[modules/geom.git] / src / GenerationGUI / GenerationGUI_PrismDlg.cxx
1 // Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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, or (at your option) any later version.
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
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File   : GenerationGUI_PrismDlg.cxx
25 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
26
27 #include "GenerationGUI_PrismDlg.h"
28
29 #include <DlgRef.h>
30 #include <GeometryGUI.h>
31 #include <GEOMBase.h>
32
33 #include <SUIT_Session.h>
34 #include <SUIT_ResourceMgr.h>
35 #include <SalomeApp_Application.h>
36 #include <LightApp_SelectionMgr.h>
37
38 // OCCT Includes
39 #include <TopoDS_Shape.hxx>
40 #include <TopoDS_Edge.hxx>
41 #include <TopoDS.hxx>
42 #include <TopExp.hxx>
43 #include <TColStd_IndexedMapOfInteger.hxx>
44 #include <TopTools_IndexedMapOfShape.hxx>
45 #include <Precision.hxx>
46
47 #include <GEOMImpl_Types.hxx>
48
49 //=================================================================================
50 // class    : GenerationGUI_PrismDlg()
51 // purpose  : Constructs a GenerationGUI_PrismDlg which is a child of 'parent', with the
52 //            name 'name' and widget flags set to 'f'.
53 //            The dialog will by default be modeless, unless you set 'modal' to
54 //            TRUE to construct a modal dialog.
55 //=================================================================================
56 GenerationGUI_PrismDlg::GenerationGUI_PrismDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
57                                                 bool modal, Qt::WindowFlags fl)
58   : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl)
59 {
60   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
61   QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_PRISM")));
62   QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
63   QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_PRISM_2P")));
64   QPixmap image3 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_PRISM_DXDYDZ")));
65
66   setWindowTitle(tr("GEOM_EXTRUSION_TITLE"));
67
68   /***************************************************************/
69   mainFrame()->GroupConstructors->setTitle(tr("GEOM_EXTRUSION"));
70   mainFrame()->RadioButton1->setIcon(image0);
71   mainFrame()->RadioButton2->setIcon(image2);
72   mainFrame()->RadioButton3->setIcon(image3);
73
74   mainFrame()->RadioButton1->setChecked(true);
75
76   GroupVecH = new DlgRef_2Sel1Spin3Check1Spin(centralWidget());
77   GroupVecH->GroupBox1->setTitle(tr("GEOM_EXTRUSION_BSV"));
78   GroupVecH->TextLabel1->setText(tr("GEOM_BASE"));
79   GroupVecH->TextLabel2->setText(tr("GEOM_VECTOR"));
80   GroupVecH->TextLabel3->setText(tr("GEOM_HEIGHT"));
81   GroupVecH->TextLabel4->setText(tr("GEOM_SCALE_FACTOR"));
82   GroupVecH->PushButton1->setIcon(image1);
83   GroupVecH->PushButton2->setIcon(image1);
84   GroupVecH->LineEdit1->setReadOnly(true);
85   GroupVecH->LineEdit2->setReadOnly(true);
86   GroupVecH->CheckBox1->setText(tr("GEOM_BOTHWAY"));
87   GroupVecH->CheckBox2->setText(tr("GEOM_REVERSE"));
88   GroupVecH->CheckBox3->setText(tr("GEOM_SCALE_PRISM"));
89
90   Group2Points = new DlgRef_3Sel2Check3Spin(centralWidget());
91   Group2Points->GroupBox1->setTitle(tr("GEOM_EXTRUSION_BSV_2P"));
92   Group2Points->TextLabel1->setText(tr("GEOM_BASE"));
93   Group2Points->TextLabel2->setText(tr("GEOM_POINT_I").arg(1));
94   Group2Points->TextLabel3->setText(tr("GEOM_POINT_I").arg(2));
95   Group2Points->TextLabel4->setText(tr("GEOM_SCALE_FACTOR"));
96   Group2Points->PushButton1->setIcon(image1);
97   Group2Points->PushButton2->setIcon(image1);
98   Group2Points->PushButton3->setIcon(image1);
99   Group2Points->CheckBox1->setText(tr("GEOM_BOTHWAY"));
100   Group2Points->CheckBox2->setText(tr("GEOM_SCALE_PRISM"));
101
102   GroupDXDYDZ = new DlgRef_1Sel3Spin2Check1Spin(centralWidget());
103   GroupDXDYDZ->GroupBox1->setTitle(tr("GEOM_EXTRUSION_DXDYDZ"));
104   GroupDXDYDZ->TextLabel1->setText(tr("GEOM_BASE"));
105   GroupDXDYDZ->PushButton1->setIcon(image1);
106   GroupDXDYDZ->TextLabel2->setText(tr("GEOM_DX"));
107   GroupDXDYDZ->TextLabel3->setText(tr("GEOM_DY"));
108   GroupDXDYDZ->TextLabel4->setText(tr("GEOM_DZ"));
109   GroupDXDYDZ->TextLabel5->setText(tr("GEOM_SCALE_FACTOR"));
110   GroupDXDYDZ->CheckBox1->setText(tr("GEOM_BOTHWAY"));
111   GroupDXDYDZ->CheckBox2->setText(tr("GEOM_SCALE_PRISM"));
112   
113   GroupThickening = new DlgRef_1Check1Spin1Check(centralWidget());
114   GroupThickening->GroupBox1->setTitle(tr("GEOM_THICKENING"));
115   GroupThickening->checkButton1->setText(tr("GEOM_ADD_THICKNESS")); // "Add thickness (edges or wires only)"
116   GroupThickening->checkButton2->setText(tr("GEOM_TOWARDS_INSIDE")); // "Thicken towards the inside"
117   GroupThickening->TextLabel1->setText(tr("GEOM_THICKNESS"));
118
119   QVBoxLayout* layout = new QVBoxLayout(centralWidget());
120   layout->setMargin(0); layout->setSpacing(6);
121   layout->addWidget(GroupVecH);
122   layout->addWidget(Group2Points);
123   layout->addWidget(GroupDXDYDZ);
124   layout->addWidget(GroupThickening);
125   /***************************************************************/
126
127   setHelpFileName("create_extrusion_page.html");
128
129   Init();
130 }
131
132 //=================================================================================
133 // function : ~GenerationGUI_PrismDlg()
134 // purpose  : Destroys the object and frees any allocated resources
135 //=================================================================================
136 GenerationGUI_PrismDlg::~GenerationGUI_PrismDlg()
137 {
138   // no need to delete child widgets, Qt does it all for us
139 }
140
141 //=================================================================================
142 // function : Init()
143 // purpose  :
144 //=================================================================================
145 void GenerationGUI_PrismDlg::Init()
146 {
147   // Get setting of step value from file configuration
148   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
149   double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
150
151   // min, max, step and decimals for spin boxes & initial values
152   double aScaleFactor = 2.0;
153   double aScaleStep = 0.5;
154   double aScaleMin = Precision::Confusion() * 10.0;
155   
156   double aThickness = 10;
157   double aThicknessMin = Precision::Confusion() * 10.0;
158
159   initSpinBox(GroupVecH->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
160   GroupVecH->SpinBox_DX->setValue(100.0);
161
162   initSpinBox(GroupDXDYDZ->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
163   initSpinBox(GroupDXDYDZ->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
164   initSpinBox(GroupDXDYDZ->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
165   GroupDXDYDZ->SpinBox_DX->setValue(0.0);
166   GroupDXDYDZ->SpinBox_DY->setValue(0.0);
167   GroupDXDYDZ->SpinBox_DZ->setValue(0.0);
168
169   initSpinBox(GroupVecH->SpinBox_DY, aScaleMin, COORD_MAX, aScaleStep, "parametric_precision" );
170   initSpinBox(Group2Points->SpinBox1, aScaleMin, COORD_MAX, aScaleStep, "parametric_precision" );
171   initSpinBox(GroupDXDYDZ->SpinBox_SC, aScaleMin, COORD_MAX, aScaleStep, "parametric_precision" );
172
173   GroupVecH->SpinBox_DY->setValue(aScaleFactor);
174   Group2Points->SpinBox1->setValue(aScaleFactor);
175   GroupDXDYDZ->SpinBox_SC->setValue(aScaleFactor);
176   
177   initSpinBox(GroupThickening->SpinBox_DX, aThicknessMin, COORD_MAX, step, "length_precision" );
178   GroupThickening->SpinBox_DX->setValue(aThickness);
179
180   // hide not used controls
181   Group2Points->TextLabel5->hide();
182   Group2Points->TextLabel6->hide();
183
184   Group2Points->SpinBox2->hide();
185   Group2Points->SpinBox3->hide();
186
187   // init variables
188   myEditCurrentArgument = GroupVecH->LineEdit1;
189   GroupVecH->LineEdit1->setReadOnly(true);
190   GroupVecH->LineEdit2->setReadOnly(true);
191
192   Group2Points->LineEdit1->setReadOnly(true);
193   Group2Points->LineEdit2->setReadOnly(true);
194   Group2Points->LineEdit3->setReadOnly(true);
195
196   GroupDXDYDZ->LineEdit1->setReadOnly(true);
197
198   GroupVecH->LineEdit1->setText("");
199   GroupVecH->LineEdit2->setText("");
200
201   Group2Points->LineEdit1->setText("");
202   Group2Points->LineEdit2->setText("");
203   Group2Points->LineEdit3->setText("");
204
205   GroupDXDYDZ->LineEdit1->setText("");
206   
207   GroupThickening->SpinBox_DX->hide();
208   GroupThickening->checkButton2->hide();
209   GroupThickening->TextLabel1->hide();
210   
211   GroupVecH->TextLabel4->hide();
212   GroupVecH->SpinBox_DY->hide();
213
214   Group2Points->TextLabel4->hide();
215   Group2Points->SpinBox1->hide();
216
217   GroupDXDYDZ->TextLabel5->hide();
218   GroupDXDYDZ->SpinBox_SC->hide();
219
220   myBaseObjects.clear();
221   myPoint1.nullify();
222   myPoint2.nullify();
223   myVec.nullify();
224
225   showOnlyPreviewControl();
226     
227   // signals and slots connections
228   connect(buttonOk(),    SIGNAL(clicked()), this, SLOT(ClickOnOk()));
229   connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
230
231   connect(this,          SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
232
233   connect(GroupVecH->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
234   connect(GroupVecH->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
235
236   connect(GroupVecH->SpinBox_DX, SIGNAL(valueChanged(double)),    this, SLOT(ValueChangedInSpinBox()));
237   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
238
239   connect(GroupVecH->CheckBox1,  SIGNAL(toggled(bool)), this, SLOT(onBothway()));
240   connect(GroupVecH->CheckBox2,  SIGNAL(toggled(bool)), this, SLOT(onReverse()));
241   connect(GroupVecH->CheckBox3,  SIGNAL(toggled(bool)), this, SLOT(onScalePrism(bool)));
242   connect(GroupVecH->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
243
244   connect(Group2Points->PushButton1, SIGNAL(clicked()),       this, SLOT(SetEditCurrentArgument()));
245   connect(Group2Points->PushButton2, SIGNAL(clicked()),       this, SLOT(SetEditCurrentArgument()));
246   connect(Group2Points->PushButton3, SIGNAL(clicked()),       this, SLOT(SetEditCurrentArgument()));
247   connect(Group2Points->CheckBox1,   SIGNAL(toggled(bool)),   this, SLOT(onBothway()));
248   connect(Group2Points->CheckBox2,   SIGNAL(toggled(bool)),   this, SLOT(onScalePrism(bool)));
249   connect(Group2Points->SpinBox1,    SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
250
251   connect(GroupDXDYDZ->PushButton1, SIGNAL(clicked()),            this, SLOT(SetEditCurrentArgument()));
252   connect(GroupDXDYDZ->SpinBox_DX,  SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
253   connect(GroupDXDYDZ->SpinBox_DY,  SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
254   connect(GroupDXDYDZ->SpinBox_DZ,  SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
255   connect(GroupDXDYDZ->SpinBox_SC,  SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
256   connect(GroupDXDYDZ->CheckBox1,   SIGNAL(toggled(bool)),        this, SLOT(onBothway()));
257   connect(GroupDXDYDZ->CheckBox2,   SIGNAL(toggled(bool)),        this, SLOT(onScalePrism(bool)));
258   
259   connect(GroupThickening->SpinBox_DX,   SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
260   connect(GroupThickening->checkButton1, SIGNAL(toggled(bool)),        this, SLOT(onAddThickening(bool)));
261   connect(GroupThickening->checkButton2, SIGNAL(toggled(bool)),        this, SLOT(onChangeDirection(bool)));
262
263   initName(tr("GEOM_EXTRUSION"));
264
265   ConstructorsClicked(0);
266   onBothway();
267 }
268
269 //=================================================================================
270 // function : SetDoubleSpinBoxStep()
271 // purpose  : Double spin box management
272 //=================================================================================
273 void GenerationGUI_PrismDlg::SetDoubleSpinBoxStep (double step)
274 {
275   GroupVecH->SpinBox_DX->setSingleStep(step);
276   GroupDXDYDZ->SpinBox_DX->setSingleStep(step);
277   GroupDXDYDZ->SpinBox_DY->setSingleStep(step);
278   GroupDXDYDZ->SpinBox_DZ->setSingleStep(step);
279 }
280
281 //=================================================================================
282 // function : ConstructorsClicked()
283 // purpose  : Radio button management
284 //=================================================================================
285 void GenerationGUI_PrismDlg::ConstructorsClicked (int constructorId)
286 {
287   switch (constructorId) {
288   case 0:
289     Group2Points->hide();
290     GroupDXDYDZ->hide();
291     GroupVecH->show();
292
293     GroupVecH->LineEdit2->setText("");
294     myVec.nullify();
295
296     GroupVecH->PushButton1->click();
297     break;
298   case 1:
299     GroupVecH->hide();
300     Group2Points->show();
301     GroupDXDYDZ->hide();
302
303     Group2Points->LineEdit2->setText("");
304     Group2Points->LineEdit3->setText("");
305     myPoint1.nullify();
306     myPoint2.nullify();
307
308     Group2Points->PushButton1->click();
309     break;
310   case 2:
311     GroupVecH->hide();
312     Group2Points->hide();
313     GroupDXDYDZ->show();
314
315     GroupDXDYDZ->PushButton1->click();
316     break;
317   default:
318     break;
319   }
320
321   qApp->processEvents();
322   updateGeometry();
323   resize(minimumSizeHint());
324
325   SelectionIntoArgument();
326   processPreview();
327 }
328
329 //=================================================================================
330 // function : ClickOnOk()
331 // purpose  :
332 //=================================================================================
333 void GenerationGUI_PrismDlg::ClickOnOk()
334 {
335   setIsApplyAndClose( true );
336   if (ClickOnApply())
337     ClickOnCancel();
338 }
339
340 //=================================================================================
341 // function : ClickOnApply()
342 // purpose  :
343 //=================================================================================
344 bool GenerationGUI_PrismDlg::ClickOnApply()
345 {
346   if (!onAccept())
347     return false;
348
349   initName();
350   // activate selection and connect selection manager
351   ConstructorsClicked(getConstructorId());
352   return true;
353 }
354
355 //=================================================================================
356 // function : SelectionIntoArgument()
357 // purpose  : Called when selection is changed or on dialog initialization or activation
358 //=================================================================================
359 void GenerationGUI_PrismDlg::SelectionIntoArgument()
360 {
361   erasePreview();
362   myEditCurrentArgument->setText("");
363
364   if ( myEditCurrentArgument == GroupVecH->LineEdit1  ||
365        myEditCurrentArgument == Group2Points->LineEdit1 ||
366        myEditCurrentArgument == GroupDXDYDZ->LineEdit1 ) {
367     myBaseObjects.clear();
368     GroupThickening->checkButton1->setEnabled(true);
369   
370     QList<GEOM::GeomObjPtr> objects = getSelected( TopAbs_SHAPE, -1 );
371     for ( int i = 0; i < objects.count(); i++ ) {
372       GEOM::shape_type stype = objects[i]->GetMaxShapeType();
373       if ( stype < GEOM::SHELL || stype > GEOM::VERTEX )
374         continue;
375       if ( stype > GEOM::EDGE || stype < GEOM::WIRE )
376       {
377         GroupThickening->checkButton1->setChecked(false);
378         GroupThickening->checkButton1->setEnabled(false);
379       }
380         
381       myBaseObjects << objects[i];
382     }
383     if ( !myBaseObjects.isEmpty() ) {
384       QString aName = myBaseObjects.count() > 1 ? QString( "%1_objects").arg( myBaseObjects.count() ) : GEOMBase::GetName( myBaseObjects[0].get() );
385       GroupVecH->LineEdit1->setText( aName );
386       Group2Points->LineEdit1->setText( aName );
387       GroupDXDYDZ->LineEdit1->setText( aName );
388     }
389     else {
390       GroupVecH->LineEdit1->setText( "" );
391       Group2Points->LineEdit1->setText( "" );
392       GroupDXDYDZ->LineEdit1->setText( "" );
393     }
394   }
395   else if ( myEditCurrentArgument == GroupVecH->LineEdit2 ) {
396     myVec = getSelected( TopAbs_EDGE );
397     if ( myVec ) {
398       QString aName = GEOMBase::GetName( myVec.get() );
399       myEditCurrentArgument->setText( aName );
400       if ( myBaseObjects.isEmpty() )
401         GroupVecH->PushButton1->click();
402     }
403   }
404   if ( myEditCurrentArgument == Group2Points->LineEdit2 ) {
405     myPoint1 = getSelected( TopAbs_VERTEX );
406     if ( myPoint1 ) {
407       QString aName = GEOMBase::GetName( myPoint1.get() );
408       myEditCurrentArgument->setText( aName );
409       if ( !myPoint2 )
410         Group2Points->PushButton3->click();
411       else if ( myBaseObjects.isEmpty() )
412         Group2Points->PushButton1->click();
413     }
414   }
415   if ( myEditCurrentArgument == Group2Points->LineEdit3 ) {
416     myPoint2 = getSelected( TopAbs_VERTEX );
417     if ( myPoint2 ) {
418       QString aName = GEOMBase::GetName( myPoint2.get() );
419       myEditCurrentArgument->setText( aName );
420       if ( myBaseObjects.isEmpty() )
421         Group2Points->PushButton1->click();
422       else if ( !myPoint1 )
423         Group2Points->PushButton2->click();
424     }
425   }
426
427   processPreview();
428 }
429
430 //=================================================================================
431 // function : SetEditCurrentArgument()
432 // purpose  :
433 //=================================================================================
434 void GenerationGUI_PrismDlg::SetEditCurrentArgument()
435 {
436   QPushButton* send = (QPushButton*)sender();
437
438   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
439   globalSelection(GEOM_ALLSHAPES);
440   if (send == GroupVecH->PushButton1) {
441     myEditCurrentArgument = GroupVecH->LineEdit1;
442     GroupVecH->PushButton2->setDown(false);
443     GroupVecH->LineEdit2->setEnabled(false);
444   }
445   else if (send == GroupVecH->PushButton2) {
446     myEditCurrentArgument = GroupVecH->LineEdit2;
447     GroupVecH->PushButton1->setDown(false);
448     GroupVecH->LineEdit1->setEnabled(false);
449     localSelection(TopAbs_EDGE);
450   }
451   else if (send == Group2Points->PushButton1) {
452     myEditCurrentArgument = Group2Points->LineEdit1;
453     Group2Points->PushButton2->setDown(false);
454     Group2Points->PushButton3->setDown(false);
455     Group2Points->LineEdit2->setEnabled(false);
456     Group2Points->LineEdit3->setEnabled(false);
457   }
458   else if (send == Group2Points->PushButton2) {
459     myEditCurrentArgument = Group2Points->LineEdit2;
460     Group2Points->PushButton1->setDown(false);
461     Group2Points->PushButton3->setDown(false);
462     Group2Points->LineEdit1->setEnabled(false);
463     Group2Points->LineEdit3->setEnabled(false);
464     localSelection(TopAbs_VERTEX);
465   }
466   else if (send == Group2Points->PushButton3) {
467     myEditCurrentArgument = Group2Points->LineEdit3;
468     Group2Points->PushButton1->setDown(false);
469     Group2Points->PushButton2->setDown(false);
470     Group2Points->LineEdit1->setEnabled(false);
471     Group2Points->LineEdit2->setEnabled(false);
472     localSelection(TopAbs_VERTEX);
473   }
474   else   if (send == GroupDXDYDZ->PushButton1) {
475     myEditCurrentArgument = GroupDXDYDZ->LineEdit1;
476   }
477   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
478           this, SLOT(SelectionIntoArgument()));
479
480   // enable line edit
481   myEditCurrentArgument->setEnabled(true);
482   myEditCurrentArgument->setFocus();
483   // after setFocus(), because it will be setDown(false) when loses focus
484   send->setDown(true);
485
486   // seems we need it only to avoid preview disappearing, caused by selection mode change
487   processPreview();
488 }
489
490 //=================================================================================
491 // function : ActivateThisDialog()
492 // purpose  :
493 //=================================================================================
494 void GenerationGUI_PrismDlg::ActivateThisDialog()
495 {
496   GEOMBase_Skeleton::ActivateThisDialog();
497
498   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
499            this, SLOT( SelectionIntoArgument() ) );
500
501   ConstructorsClicked( getConstructorId() );
502 }
503
504 //=================================================================================
505 // function : enterEvent()
506 // purpose  : when mouse enter onto the QWidget
507 //=================================================================================
508 void GenerationGUI_PrismDlg::enterEvent (QEvent*)
509 {
510   if (!mainFrame()->GroupConstructors->isEnabled())
511     ActivateThisDialog();
512 }
513
514 //=================================================================================
515 // function : ValueChangedInSpinBox()
516 // purpose  :
517 //=================================================================================
518 void GenerationGUI_PrismDlg::ValueChangedInSpinBox()
519 {
520   processPreview();
521 }
522
523 //=================================================================================
524 // function : createOperation
525 // purpose  :
526 //=================================================================================
527 GEOM::GEOM_IOperations_ptr GenerationGUI_PrismDlg::createOperation()
528 {
529   return getGeomEngine()->GetI3DPrimOperations();
530 }
531
532 //=================================================================================
533 // function : isValid
534 // purpose  :
535 //=================================================================================
536 bool GenerationGUI_PrismDlg::isValid (QString& msg)
537 {
538   bool ok = false;
539   switch ( getConstructorId() ) {
540   case 0:
541     ok = GroupVecH->SpinBox_DX->isValid( msg, !IsPreview() ) &&
542          !myBaseObjects.isEmpty() && myVec;
543     break;
544   case 1:
545     ok = !myBaseObjects.isEmpty() && myPoint1 && myPoint2;
546     break;
547   case 2:
548     ok = GroupDXDYDZ->SpinBox_DX->isValid( msg, !IsPreview() ) &&
549          GroupDXDYDZ->SpinBox_DY->isValid( msg, !IsPreview() ) &&
550          GroupDXDYDZ->SpinBox_DZ->isValid( msg, !IsPreview() ) &&
551          !myBaseObjects.isEmpty();
552     break;
553   default:
554     break;
555   }
556
557   return ok;
558 }
559
560 //=================================================================================
561 // function : onReverse()
562 // purpose  :
563 //=================================================================================
564 void GenerationGUI_PrismDlg::onReverse()
565 {
566   double anOldValue = GroupVecH->SpinBox_DX->value();
567   GroupVecH->SpinBox_DX->setValue(-anOldValue);
568 }
569
570 //=================================================================================
571 // function : onBothway()
572 // purpose  :
573 //=================================================================================
574 void GenerationGUI_PrismDlg::onBothway()
575 {
576   GroupVecH->CheckBox2->setEnabled(!GroupVecH->CheckBox1->isChecked()); // is reversed
577   GroupVecH->CheckBox3->setEnabled(!GroupVecH->CheckBox1->isChecked()); // is scaled
578   GroupVecH->TextLabel4->setEnabled(!GroupVecH->CheckBox1->isChecked() &&
579                                     GroupVecH->CheckBox3->isChecked()); // scale factor
580   GroupVecH->SpinBox_DY->setEnabled(!GroupVecH->CheckBox1->isChecked() &&
581                                     GroupVecH->CheckBox3->isChecked()); // scale factor
582
583   Group2Points->CheckBox2->setEnabled(!Group2Points->CheckBox1->isChecked()); // is scaled
584   Group2Points->TextLabel4->setEnabled(!Group2Points->CheckBox1->isChecked() &&
585                                        Group2Points->CheckBox2->isChecked()); // scale factor
586   Group2Points->SpinBox1->setEnabled(!Group2Points->CheckBox1->isChecked() &&
587                                      Group2Points->CheckBox2->isChecked()); // scale factor
588
589   GroupDXDYDZ->CheckBox2->setEnabled(!GroupDXDYDZ->CheckBox1->isChecked()); // is scaled
590   GroupDXDYDZ->TextLabel5->setEnabled(!GroupDXDYDZ->CheckBox1->isChecked() &&
591                                       GroupDXDYDZ->CheckBox2->isChecked()); // scale factor
592   GroupDXDYDZ->SpinBox_SC->setEnabled(!GroupDXDYDZ->CheckBox1->isChecked() &&
593                                       GroupDXDYDZ->CheckBox2->isChecked()); // scale factor
594
595   processPreview();
596 }
597
598 //=================================================================================
599 // function : onScalePrism()
600 // purpose  :
601 //=================================================================================
602 void GenerationGUI_PrismDlg::onScalePrism(bool isChecked)
603 {
604   GroupVecH->TextLabel4->setVisible(isChecked);
605   GroupVecH->SpinBox_DY->setVisible(isChecked);
606
607   Group2Points->TextLabel4->setVisible(isChecked);
608   Group2Points->SpinBox1->setVisible(isChecked);
609
610   GroupDXDYDZ->TextLabel5->setVisible(isChecked);
611   GroupDXDYDZ->SpinBox_SC->setVisible(isChecked);
612   
613   GroupVecH->TextLabel4->setEnabled(isChecked);
614   GroupVecH->SpinBox_DY->setEnabled(isChecked);
615
616   Group2Points->TextLabel4->setEnabled(isChecked);
617   Group2Points->SpinBox1->setEnabled(isChecked);
618
619   GroupDXDYDZ->TextLabel5->setEnabled(isChecked);
620   GroupDXDYDZ->SpinBox_SC->setEnabled(isChecked);
621
622   processPreview();
623 }
624
625 //=================================================================================
626 // function : onAddThickening(bool)
627 // purpose  :
628 //=================================================================================
629 void GenerationGUI_PrismDlg::onAddThickening(bool isChecked)
630 {
631   GroupThickening->SpinBox_DX->setVisible(isChecked);
632   GroupThickening->checkButton2->setVisible(isChecked);
633   GroupThickening->TextLabel1->setVisible(isChecked);
634  
635   updateGeometry();
636   resize(minimumSizeHint());
637   processPreview();
638 }
639
640 //=================================================================================
641 // function : onChangeDirection(bool)
642 // purpose  :
643 //=================================================================================
644 void GenerationGUI_PrismDlg::onChangeDirection(bool /*isChecked*/)
645 {
646   processPreview();
647 }
648
649 //=================================================================================
650 // function : execute
651 // purpose  :
652 //=================================================================================
653 bool GenerationGUI_PrismDlg::execute (ObjectList& objects)
654 {
655   QStringList aParameters;
656   GEOM::GEOM_Object_var anObj;
657
658   GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
659   GEOM::GEOM_I3DPrimOperations_var anotherOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
660
661   for (int i = 0; i < myBaseObjects.count(); i++) {
662     switch (getConstructorId()) {
663     case 0:
664       if (GroupVecH->CheckBox1->isChecked())
665         anObj = anOper->MakePrismVecH2Ways(myBaseObjects[i].get(), myVec.get(),
666                                            GroupVecH->SpinBox_DX->value());
667       else {
668         if (GroupVecH->CheckBox3->isChecked())
669           anObj = anOper->MakePrismVecHWithScaling(myBaseObjects[i].get(), myVec.get(),
670                                                    GroupVecH->SpinBox_DX->value(),
671                                                    GroupVecH->SpinBox_DY->value());
672         else
673           anObj = anOper->MakePrismVecH(myBaseObjects[i].get(), myVec.get(),
674                                         GroupVecH->SpinBox_DX->value());
675       }
676
677       if (!anObj->_is_nil() && !IsPreview()) {
678         aParameters << GroupVecH->SpinBox_DX->text();
679         anObj->SetParameters(aParameters.join(":").toUtf8().constData());
680       }
681       break;
682     case 1:
683       if (Group2Points->CheckBox1->isChecked())
684         anObj = anOper->MakePrismTwoPnt2Ways(myBaseObjects[i].get(), myPoint1.get(), myPoint2.get());
685       else {
686         if (Group2Points->CheckBox2->isChecked())
687           anObj = anOper->MakePrismTwoPntWithScaling(myBaseObjects[i].get(), myPoint1.get(),
688                                                      myPoint2.get(), Group2Points->SpinBox1->value());
689         else
690           anObj = anOper->MakePrismTwoPnt(myBaseObjects[i].get(), myPoint1.get(), myPoint2.get());
691       }
692       break;
693     case 2:
694       double dx = GroupDXDYDZ->SpinBox_DX->value();
695       double dy = GroupDXDYDZ->SpinBox_DY->value();
696       double dz = GroupDXDYDZ->SpinBox_DZ->value();
697
698       if (GroupDXDYDZ->CheckBox1->isChecked())
699         anObj = anOper->MakePrismDXDYDZ2Ways(myBaseObjects[i].get(), dx, dy, dz);
700       else {
701         if (GroupDXDYDZ->CheckBox2->isChecked())
702           anObj = anOper->MakePrismDXDYDZWithScaling(myBaseObjects[i].get(), dx, dy, dz,
703                                                      GroupDXDYDZ->SpinBox_SC->value());
704         else
705           anObj = anOper->MakePrismDXDYDZ(myBaseObjects[i].get(), dx, dy, dz);
706       }
707
708       if (!anObj->_is_nil() && !IsPreview()) {
709         aParameters << GroupDXDYDZ->SpinBox_DX->text();
710         aParameters << GroupDXDYDZ->SpinBox_DY->text();
711         aParameters << GroupDXDYDZ->SpinBox_DZ->text();
712         anObj->SetParameters(aParameters.join(":").toUtf8().constData());
713       }
714       break;
715     }
716     
717     if(GroupThickening->checkButton1->isChecked())
718     { 
719       double aThickness = GroupThickening->SpinBox_DX->value();
720       bool isInside = GroupThickening->checkButton2->isChecked();
721
722       GEOM::ListOfLong_var anArray = new GEOM::ListOfLong;
723
724       anObj = anotherOper->MakeThickening
725         (anObj, anArray, aThickness, /*copy=*/false, isInside);
726
727       if (!anObj->_is_nil() && !IsPreview())
728         anObj->SetParameters(GroupThickening->SpinBox_DX->text().toUtf8().constData());
729     }
730     
731     if (!anObj->_is_nil())
732       objects.push_back(anObj._retn());
733   }
734
735   return true;
736 }
737
738 //=================================================================================
739 // function : addSubshapeToStudy
740 // purpose  : virtual method to add new SubObjects if local selection
741 //=================================================================================
742 void GenerationGUI_PrismDlg::addSubshapesToStudy()
743 {
744   switch (getConstructorId()) {
745   case 0:
746     GEOMBase::PublishSubObject( myVec.get() );
747     break;
748   case 1:
749     GEOMBase::PublishSubObject( myPoint1.get() );
750     GEOMBase::PublishSubObject( myPoint2.get() );
751     break;
752   default:
753     break;
754   }
755 }
756
757 //=================================================================================
758 // function : extractPrefix
759 // purpose  : redefined from GEOMBase_Helper class
760 //=================================================================================
761 bool GenerationGUI_PrismDlg::extractPrefix() const
762 {
763   return myBaseObjects.count() > 1;
764 }
765
766 //=================================================================================
767 // function : getSourceObjects
768 // purpose  : virtual method to get source objects
769 //=================================================================================
770 QList<GEOM::GeomObjPtr> GenerationGUI_PrismDlg::getSourceObjects()
771 {
772   QList<GEOM::GeomObjPtr> res(myBaseObjects);
773   res << myVec << myPoint1 << myPoint2 ;
774   return res;
775 }