1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : GenerationGUI_PrismDlg.cxx
25 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
27 #include "GenerationGUI_PrismDlg.h"
30 #include <GeometryGUI.h>
33 #include <SUIT_Session.h>
34 #include <SUIT_ResourceMgr.h>
35 #include <SalomeApp_Application.h>
36 #include <LightApp_SelectionMgr.h>
39 #include <TopoDS_Shape.hxx>
40 #include <TopoDS_Edge.hxx>
43 #include <TColStd_IndexedMapOfInteger.hxx>
44 #include <TopTools_IndexedMapOfShape.hxx>
46 #include <GEOMImpl_Types.hxx>
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),
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")));
66 setWindowTitle(tr("GEOM_EXTRUSION_TITLE"));
68 /***************************************************************/
69 mainFrame()->GroupConstructors->setTitle(tr("GEOM_EXTRUSION"));
70 mainFrame()->RadioButton1->setIcon(image0);
71 mainFrame()->RadioButton2->setIcon(image2);
72 mainFrame()->RadioButton3->setIcon(image3);
74 mainFrame()->RadioButton1->setChecked(true);
75 myBothway = myBothway2 = myBothway3 = false;
77 GroupPoints = new DlgRef_2Sel1Spin2Check(centralWidget());
78 GroupPoints->GroupBox1->setTitle(tr("GEOM_EXTRUSION_BSV"));
79 GroupPoints->TextLabel1->setText(tr("GEOM_BASE"));
80 GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR"));
81 GroupPoints->TextLabel3->setText(tr("GEOM_HEIGHT"));
82 GroupPoints->PushButton1->setIcon(image1);
83 GroupPoints->PushButton2->setIcon(image1);
84 GroupPoints->LineEdit1->setReadOnly(true);
85 GroupPoints->LineEdit2->setReadOnly(true);
86 GroupPoints->CheckButton1->setText(tr("GEOM_BOTHWAY"));
87 GroupPoints->CheckButton1->setChecked(myBothway);
88 GroupPoints->CheckButton2->setText(tr("GEOM_REVERSE"));
90 GroupPoints2 = new DlgRef_3Sel1Check(centralWidget());
91 GroupPoints2->GroupBox1->setTitle(tr("GEOM_EXTRUSION_BSV_2P"));
92 GroupPoints2->TextLabel1->setText(tr("GEOM_BASE"));
93 GroupPoints2->TextLabel2->setText(tr("GEOM_POINT_I").arg(1));
94 GroupPoints2->TextLabel3->setText(tr("GEOM_POINT_I").arg(2));
95 GroupPoints2->PushButton1->setIcon(image1);
96 GroupPoints2->PushButton2->setIcon(image1);
97 GroupPoints2->PushButton3->setIcon(image1);
98 GroupPoints2->CheckButton1->setText(tr("GEOM_BOTHWAY"));
99 GroupPoints2->CheckButton1->setChecked(myBothway2);
101 GroupPoints3 = new DlgRef_1Sel3Spin1Check(centralWidget());
102 GroupPoints3->GroupBox1->setTitle(tr("GEOM_EXTRUSION_DXDYDZ"));
103 GroupPoints3->TextLabel1->setText(tr("GEOM_BASE"));
104 GroupPoints3->PushButton1->setIcon(image1);
105 GroupPoints3->TextLabel2->setText(tr("GEOM_DX"));
106 GroupPoints3->TextLabel3->setText(tr("GEOM_DY"));
107 GroupPoints3->TextLabel4->setText(tr("GEOM_DZ"));
108 GroupPoints3->CheckButton1->setText(tr("GEOM_BOTHWAY"));
109 GroupPoints3->CheckButton1->setChecked(myBothway3);
111 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
112 layout->setMargin(0); layout->setSpacing(6);
113 layout->addWidget(GroupPoints);
114 layout->addWidget(GroupPoints2);
115 layout->addWidget(GroupPoints3);
116 /***************************************************************/
118 setHelpFileName("create_extrusion_page.html");
123 //=================================================================================
124 // function : ~GenerationGUI_PrismDlg()
125 // purpose : Destroys the object and frees any allocated resources
126 //=================================================================================
127 GenerationGUI_PrismDlg::~GenerationGUI_PrismDlg()
129 // no need to delete child widgets, Qt does it all for us
132 //=================================================================================
135 //=================================================================================
136 void GenerationGUI_PrismDlg::Init()
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);
142 // min, max, step and decimals for spin boxes & initial values
143 initSpinBox(GroupPoints3->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
144 initSpinBox(GroupPoints3->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
145 initSpinBox(GroupPoints3->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
146 GroupPoints3->SpinBox_DX->setValue(0.0);
147 GroupPoints3->SpinBox_DY->setValue(0.0);
148 GroupPoints3->SpinBox_DZ->setValue(0.0);
150 initSpinBox(GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
151 GroupPoints->SpinBox_DX->setValue(100.0);
154 myEditCurrentArgument = GroupPoints->LineEdit1;
155 GroupPoints->LineEdit1->setReadOnly(true);
156 GroupPoints->LineEdit2->setReadOnly(true);
158 GroupPoints2->LineEdit1->setReadOnly(true);
159 GroupPoints2->LineEdit2->setReadOnly(true);
160 GroupPoints2->LineEdit3->setReadOnly(true);
162 GroupPoints3->LineEdit1->setReadOnly(true);
164 GroupPoints->LineEdit1->setText("");
165 GroupPoints->LineEdit2->setText("");
167 GroupPoints2->LineEdit1->setText("");
168 GroupPoints2->LineEdit2->setText("");
169 GroupPoints2->LineEdit3->setText("");
171 GroupPoints3->LineEdit1->setText("");
173 myPoint1 = myPoint2 = myVec = GEOM::GEOM_Object::_nil();
174 myOkBase = myOkVec = myOkPnt1 = myOkPnt2 = false;
176 // signals and slots connections
177 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
178 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
180 connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
182 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
183 connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
185 connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
186 connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
188 connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
189 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
191 connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway()));
192 connect(GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(onReverse()));
194 connect(GroupPoints2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
195 connect(GroupPoints2->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
196 connect(GroupPoints2->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
197 connect(GroupPoints2->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway()));
199 connect(GroupPoints2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
200 connect(GroupPoints2->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
201 connect(GroupPoints2->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
203 connect(GroupPoints3->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
204 connect(GroupPoints3->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
205 connect(GroupPoints3->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
206 connect(GroupPoints3->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
207 connect(GroupPoints3->SpinBox_DZ, SIGNAL(valueChanged (double)), this, SLOT(ValueChangedInSpinBox()));
208 connect(GroupPoints3->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway()));
210 initName(tr("GEOM_EXTRUSION"));
212 ConstructorsClicked(0);
215 //=================================================================================
216 // function : SetDoubleSpinBoxStep()
217 // purpose : Double spin box management
218 //=================================================================================
219 void GenerationGUI_PrismDlg::SetDoubleSpinBoxStep (double step)
221 GroupPoints->SpinBox_DX->setSingleStep(step);
222 GroupPoints3->SpinBox_DX->setSingleStep(step);
223 GroupPoints3->SpinBox_DY->setSingleStep(step);
224 GroupPoints3->SpinBox_DZ->setSingleStep(step);
227 //=================================================================================
228 // function : ConstructorsClicked()
229 // purpose : Radio button management
230 //=================================================================================
231 void GenerationGUI_PrismDlg::ConstructorsClicked (int constructorId)
233 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
235 switch (constructorId) {
238 GroupPoints2->hide();
239 GroupPoints3->hide();
242 GroupPoints->LineEdit1->setText(GroupPoints2->LineEdit1->text()); // keep base
243 GroupPoints->LineEdit2->setText("");
244 myVec = GEOM::GEOM_Object::_nil();
247 GroupPoints->PushButton1->click();
253 GroupPoints2->show();
254 GroupPoints3->hide();
256 GroupPoints2->LineEdit1->setText(GroupPoints->LineEdit1->text()); // keep base
257 GroupPoints2->LineEdit2->setText("");
258 GroupPoints2->LineEdit3->setText("");
259 myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
260 myOkPnt1 = myOkPnt2 = false;
262 GroupPoints2->PushButton1->click();
268 GroupPoints2->hide();
269 GroupPoints3->show();
271 GroupPoints3->LineEdit1->setText(GroupPoints->LineEdit1->text()); // keep base
273 GroupPoints3->PushButton1->click();
278 qApp->processEvents();
280 resize(minimumSizeHint());
282 SelectionIntoArgument();
286 //=================================================================================
287 // function : ClickOnOk()
289 //=================================================================================
290 void GenerationGUI_PrismDlg::ClickOnOk()
296 //=================================================================================
297 // function : ClickOnApply()
299 //=================================================================================
300 bool GenerationGUI_PrismDlg::ClickOnApply()
306 // activate selection and connect selection manager
307 ConstructorsClicked(getConstructorId());
311 //=================================================================================
312 // function : SelectionIntoArgument()
313 // purpose : Called when selection is changed or on dialog initialization or activation
314 //=================================================================================
315 void GenerationGUI_PrismDlg::SelectionIntoArgument()
318 myEditCurrentArgument->setText("");
320 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
321 SALOME_ListIO aSelList;
322 aSelMgr->selectedObjects(aSelList);
324 QString aBaseName = ""; /* name of base object selection */
325 int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aBaseName, true);
328 aBaseName = QString( "%1_objects").arg( nbSel );
330 // Base Object(s) selected
331 if (myEditCurrentArgument == GroupPoints->LineEdit1 ||
332 myEditCurrentArgument == GroupPoints2->LineEdit1 ||
333 getConstructorId() == 2 ) {
336 GEOMBase::ConvertListOfIOInListOfGO(aSelList, myBaseObjects, true);
337 myEditCurrentArgument->setText( aBaseName );
344 if (getConstructorId() == 0)
346 if (aSelList.Extent() < 1) {
347 if (myEditCurrentArgument == GroupPoints->LineEdit2)
352 GEOM::GEOM_Object_var aSelectedObject =
353 GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
354 if ( CORBA::is_nil(aSelectedObject) )
357 QString aName = GEOMBase::GetName(aSelectedObject);
359 // Get Selected object if selected subshape
362 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
364 TColStd_IndexedMapOfInteger aMap;
365 aSelMgr->GetIndexes(aSelList.First(), aMap);
366 if (aMap.Extent() == 1) {
367 int anIndex = aMap(1);
368 aName.append(":edge_" + QString::number(anIndex));
370 //Find SubShape Object in Father
371 GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
373 if (aFindedObject->_is_nil()) { // Object not found in study
374 GEOM::GEOM_IShapesOperations_var aShapesOp =
375 getGeomEngine()->GetIShapesOperations(getStudyId());
376 aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
379 aSelectedObject = aFindedObject; // get Object from study
382 else { // Global Selection
383 if (aShape.ShapeType() != TopAbs_EDGE && myEditCurrentArgument == GroupPoints->LineEdit2) {
384 aSelectedObject = GEOM::GEOM_Object::_nil();
391 if (myEditCurrentArgument == GroupPoints->LineEdit2 && myOk) {
392 myEditCurrentArgument->setText(aName);
394 myVec = aSelectedObject;
397 else if (getConstructorId() == 1) { // getConstructorId()==1 - extrusion using 2 points
398 if (aSelList.Extent() != 1) {
399 if (myEditCurrentArgument == GroupPoints2->LineEdit2) {
400 myPoint1 = GEOM::GEOM_Object::_nil();
403 else if (myEditCurrentArgument == GroupPoints2->LineEdit3) {
404 myPoint2 = GEOM::GEOM_Object::_nil();
410 GEOM::GEOM_Object_var aSelectedObject =
411 GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
413 if ( CORBA::is_nil(aSelectedObject) )
416 QString aName = GEOMBase::GetName(aSelectedObject);
419 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) {
420 TColStd_IndexedMapOfInteger aMap;
421 aSelMgr->GetIndexes(aSelList.First(), aMap);
422 if (aMap.Extent() == 1) {
423 int anIndex = aMap(1);
424 aName.append(":vertex_" + QString::number(anIndex));
426 //Find SubShape Object in Father
427 GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName);
429 if (aFindedObject->_is_nil()) { // Object not found in study
430 GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
431 aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
434 aSelectedObject = aFindedObject;
438 if ((aShape.ShapeType() != TopAbs_VERTEX && myEditCurrentArgument == GroupPoints2->LineEdit2) ||
439 (aShape.ShapeType() != TopAbs_VERTEX && myEditCurrentArgument == GroupPoints2->LineEdit3)) {
440 aSelectedObject = GEOM::GEOM_Object::_nil();
447 myEditCurrentArgument->setText(aName);
449 if (myEditCurrentArgument == GroupPoints2->LineEdit2 && myOk) {
451 myPoint1 = aSelectedObject;
453 GroupPoints2->PushButton3->click();
455 else if (myEditCurrentArgument == GroupPoints2->LineEdit3 && myOk) {
457 myPoint2 = aSelectedObject;
459 GroupPoints2->PushButton1->click();
466 //=================================================================================
467 // function : SetEditCurrentArgument()
469 //=================================================================================
470 void GenerationGUI_PrismDlg::SetEditCurrentArgument()
472 QPushButton* send = (QPushButton*)sender();
474 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
475 globalSelection(GEOM_ALLSHAPES);
476 if (send == GroupPoints->PushButton1) {
477 myEditCurrentArgument = GroupPoints->LineEdit1;
478 GroupPoints->PushButton2->setDown(false);
479 GroupPoints->LineEdit2->setEnabled(false);
481 else if (send == GroupPoints->PushButton2) {
482 myEditCurrentArgument = GroupPoints->LineEdit2;
483 GroupPoints->PushButton1->setDown(false);
484 GroupPoints->LineEdit1->setEnabled(false);
485 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
487 else if (send == GroupPoints2->PushButton1) {
488 myEditCurrentArgument = GroupPoints2->LineEdit1;
489 GroupPoints2->PushButton2->setDown(false);
490 GroupPoints2->PushButton3->setDown(false);
491 GroupPoints2->LineEdit2->setEnabled(false);
492 GroupPoints2->LineEdit3->setEnabled(false);
494 else if (send == GroupPoints2->PushButton2) {
495 myEditCurrentArgument = GroupPoints2->LineEdit2;
496 GroupPoints2->PushButton1->setDown(false);
497 GroupPoints2->PushButton3->setDown(false);
498 GroupPoints2->LineEdit1->setEnabled(false);
499 GroupPoints2->LineEdit3->setEnabled(false);
500 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
502 else if (send == GroupPoints2->PushButton3) {
503 myEditCurrentArgument = GroupPoints2->LineEdit3;
504 GroupPoints2->PushButton1->setDown(false);
505 GroupPoints2->PushButton2->setDown(false);
506 GroupPoints2->LineEdit1->setEnabled(false);
507 GroupPoints2->LineEdit2->setEnabled(false);
508 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
510 else if (send == GroupPoints3->PushButton1) {
511 myEditCurrentArgument = GroupPoints3->LineEdit1;
513 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
514 this, SLOT(SelectionIntoArgument()));
517 myEditCurrentArgument->setEnabled(true);
518 myEditCurrentArgument->setFocus();
519 // after setFocus(), because it will be setDown(false) when loses focus
522 // seems we need it only to avoid preview disappearing, caused by selection mode change
526 //=================================================================================
527 // function : LineEditReturnPressed()
529 //=================================================================================
530 void GenerationGUI_PrismDlg::LineEditReturnPressed()
532 QLineEdit* send = (QLineEdit*)sender();
533 if (send == GroupPoints->LineEdit1 ||
534 send == GroupPoints->LineEdit2 ||
535 send == GroupPoints2->LineEdit1 ||
536 send == GroupPoints2->LineEdit2 ||
537 send == GroupPoints2->LineEdit3 ||
538 send == GroupPoints3->LineEdit1) {
539 myEditCurrentArgument = send;
540 GEOMBase_Skeleton::LineEditReturnPressed();
544 //=================================================================================
545 // function : ActivateThisDialog()
547 //=================================================================================
548 void GenerationGUI_PrismDlg::ActivateThisDialog()
550 GEOMBase_Skeleton::ActivateThisDialog();
552 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
553 this, SLOT( SelectionIntoArgument() ) );
555 ConstructorsClicked( getConstructorId() );
558 //=================================================================================
559 // function : enterEvent()
560 // purpose : when mouse enter onto the QWidget
561 //=================================================================================
562 void GenerationGUI_PrismDlg::enterEvent (QEvent*)
564 if (!mainFrame()->GroupConstructors->isEnabled())
565 ActivateThisDialog();
568 //=================================================================================
569 // function : ValueChangedInSpinBox()
571 //=================================================================================
572 void GenerationGUI_PrismDlg::ValueChangedInSpinBox()
577 //=================================================================================
578 // function : getHeight()
580 //=================================================================================
581 double GenerationGUI_PrismDlg::getHeight() const
583 return GroupPoints->SpinBox_DX->value();
586 //=================================================================================
587 // function : createOperation
589 //=================================================================================
590 GEOM::GEOM_IOperations_ptr GenerationGUI_PrismDlg::createOperation()
592 return getGeomEngine()->GetI3DPrimOperations(getStudyId());
595 //=================================================================================
596 // function : isValid
598 //=================================================================================
599 bool GenerationGUI_PrismDlg::isValid (QString& msg)
602 if( getConstructorId() == 0 )
603 ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
604 else if( getConstructorId() == 2 )
606 ok = GroupPoints3->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
607 ok = GroupPoints3->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
608 ok = GroupPoints3->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
611 if (getConstructorId() == 0)
612 return (myOkBase && myOkVec) && ok; // by vector and height
613 else if (getConstructorId() == 1)
614 return (myOkBase && myOkPnt1 && myOkPnt2); // by two points
615 else if (getConstructorId() == 2)
616 return myOkBase && ok;
621 //=================================================================================
622 // function : execute
624 //=================================================================================
625 bool GenerationGUI_PrismDlg::execute (ObjectList& objects)
627 QStringList aParameters;
628 GEOM::GEOM_Object_var anObj, aBaseObj;
630 GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
632 for (int i=0; i < myBaseObjects.length(); i++) {
633 aBaseObj = myBaseObjects[i];
635 switch (getConstructorId()) {
638 anObj = anOper->MakePrismVecH(aBaseObj, myVec, getHeight());
640 anObj = anOper->MakePrismVecH2Ways(aBaseObj, myVec, getHeight());
642 if (!anObj->_is_nil() && !IsPreview()) {
643 aParameters << GroupPoints->SpinBox_DX->text();
644 anObj->SetParameters(aParameters.join(":").toLatin1().constData());
649 anObj = anOper->MakePrismTwoPnt(aBaseObj, myPoint1, myPoint2);
651 anObj = anOper->MakePrismTwoPnt2Ways(aBaseObj, myPoint1, myPoint2);
654 double dx = GroupPoints3->SpinBox_DX->value();
655 double dy = GroupPoints3->SpinBox_DY->value();
656 double dz = GroupPoints3->SpinBox_DZ->value();
659 anObj = anOper->MakePrismDXDYDZ(aBaseObj, dx, dy, dz);
661 anObj = anOper->MakePrismDXDYDZ2Ways(aBaseObj, dx, dy, dz);
663 if (!anObj->_is_nil() && !IsPreview()) {
664 aParameters << GroupPoints3->SpinBox_DX->text();
665 aParameters << GroupPoints3->SpinBox_DY->text();
666 aParameters << GroupPoints3->SpinBox_DZ->text();
667 anObj->SetParameters(aParameters.join(":").toLatin1().constData());
672 if (!anObj->_is_nil())
673 objects.push_back(anObj._retn());
679 //=================================================================================
680 // function : onReverse()
682 //=================================================================================
683 void GenerationGUI_PrismDlg::onReverse()
685 double anOldValue = GroupPoints->SpinBox_DX->value();
686 GroupPoints->SpinBox_DX->setValue(-anOldValue);
689 //=================================================================================
690 // function : onBothway()
692 //=================================================================================
693 void GenerationGUI_PrismDlg::onBothway()
696 switch (getConstructorId()) {
698 anOldValue = myBothway;
699 myBothway = !anOldValue;
700 GroupPoints->CheckButton2->setEnabled(!myBothway);
704 anOldValue = myBothway2;
705 myBothway2 = !anOldValue;
709 anOldValue = myBothway3;
710 myBothway3 = !anOldValue;
716 //=================================================================================
717 // function : addSubshapeToStudy
718 // purpose : virtual method to add new SubObjects if local selection
719 //=================================================================================
720 void GenerationGUI_PrismDlg::addSubshapesToStudy()
722 QMap<QString, GEOM::GEOM_Object_var> objMap;
724 switch (getConstructorId()) {
726 objMap[GroupPoints->LineEdit2->text()] = myVec;
729 objMap[GroupPoints2->LineEdit2->text()] = myPoint1;
730 objMap[GroupPoints2->LineEdit3->text()] = myPoint2;
733 addSubshapesToFather(objMap);
736 //=================================================================================
737 // function : extractPrefix
738 // purpose : redefined from GEOMBase_Helper class
739 //=================================================================================
740 bool GenerationGUI_PrismDlg::extractPrefix() const
742 return myBaseObjects.length() > 1;