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