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