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 Standard_Boolean testResult = Standard_False;
353 GEOM::GEOM_Object_var aSelectedObject =
354 GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
355 if (!testResult || CORBA::is_nil(aSelectedObject))
358 QString aName = GEOMBase::GetName(aSelectedObject);
360 // Get Selected object if selected subshape
363 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
365 TColStd_IndexedMapOfInteger aMap;
366 aSelMgr->GetIndexes(aSelList.First(), aMap);
367 if (aMap.Extent() == 1) {
368 int anIndex = aMap(1);
369 aName.append(":edge_" + QString::number(anIndex));
371 //Find SubShape Object in Father
372 GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
374 if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study
375 GEOM::GEOM_IShapesOperations_var aShapesOp =
376 getGeomEngine()->GetIShapesOperations(getStudyId());
377 aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
380 aSelectedObject = aFindedObject; // get Object from study
383 else { // Global Selection
384 if (aShape.ShapeType() != TopAbs_EDGE && myEditCurrentArgument == GroupPoints->LineEdit2) {
385 aSelectedObject = GEOM::GEOM_Object::_nil();
392 if (myEditCurrentArgument == GroupPoints->LineEdit2 && myOk) {
393 myEditCurrentArgument->setText(aName);
395 myVec = aSelectedObject;
398 else if (getConstructorId() == 1) { // getConstructorId()==1 - extrusion using 2 points
399 if (aSelList.Extent() != 1) {
400 if (myEditCurrentArgument == GroupPoints2->LineEdit2) {
401 myPoint1 = GEOM::GEOM_Object::_nil();
404 else if (myEditCurrentArgument == GroupPoints2->LineEdit3) {
405 myPoint2 = GEOM::GEOM_Object::_nil();
411 Standard_Boolean testResult = Standard_False;
412 GEOM::GEOM_Object_var aSelectedObject =
413 GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
415 if (!testResult || CORBA::is_nil(aSelectedObject))
418 QString aName = GEOMBase::GetName(aSelectedObject);
421 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) {
422 TColStd_IndexedMapOfInteger aMap;
423 aSelMgr->GetIndexes(aSelList.First(), aMap);
424 if (aMap.Extent() == 1) {
425 int anIndex = aMap(1);
426 aName.append(":vertex_" + QString::number(anIndex));
428 //Find SubShape Object in Father
429 GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName);
431 if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study
432 GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
433 aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
436 aSelectedObject = aFindedObject;
440 if ((aShape.ShapeType() != TopAbs_VERTEX && myEditCurrentArgument == GroupPoints2->LineEdit2) ||
441 (aShape.ShapeType() != TopAbs_VERTEX && myEditCurrentArgument == GroupPoints2->LineEdit3)) {
442 aSelectedObject = GEOM::GEOM_Object::_nil();
449 myEditCurrentArgument->setText(aName);
451 if (myEditCurrentArgument == GroupPoints2->LineEdit2 && myOk) {
453 myPoint1 = aSelectedObject;
455 GroupPoints2->PushButton3->click();
457 else if (myEditCurrentArgument == GroupPoints2->LineEdit3 && myOk) {
459 myPoint2 = aSelectedObject;
461 GroupPoints2->PushButton1->click();
468 //=================================================================================
469 // function : SetEditCurrentArgument()
471 //=================================================================================
472 void GenerationGUI_PrismDlg::SetEditCurrentArgument()
474 QPushButton* send = (QPushButton*)sender();
476 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
477 globalSelection(GEOM_ALLSHAPES);
478 if (send == GroupPoints->PushButton1) {
479 myEditCurrentArgument = GroupPoints->LineEdit1;
480 GroupPoints->PushButton2->setDown(false);
481 GroupPoints->LineEdit2->setEnabled(false);
483 else if (send == GroupPoints->PushButton2) {
484 myEditCurrentArgument = GroupPoints->LineEdit2;
485 GroupPoints->PushButton1->setDown(false);
486 GroupPoints->LineEdit1->setEnabled(false);
487 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
489 else if (send == GroupPoints2->PushButton1) {
490 myEditCurrentArgument = GroupPoints2->LineEdit1;
491 GroupPoints2->PushButton2->setDown(false);
492 GroupPoints2->PushButton3->setDown(false);
493 GroupPoints2->LineEdit2->setEnabled(false);
494 GroupPoints2->LineEdit3->setEnabled(false);
496 else if (send == GroupPoints2->PushButton2) {
497 myEditCurrentArgument = GroupPoints2->LineEdit2;
498 GroupPoints2->PushButton1->setDown(false);
499 GroupPoints2->PushButton3->setDown(false);
500 GroupPoints2->LineEdit1->setEnabled(false);
501 GroupPoints2->LineEdit3->setEnabled(false);
502 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
504 else if (send == GroupPoints2->PushButton3) {
505 myEditCurrentArgument = GroupPoints2->LineEdit3;
506 GroupPoints2->PushButton1->setDown(false);
507 GroupPoints2->PushButton2->setDown(false);
508 GroupPoints2->LineEdit1->setEnabled(false);
509 GroupPoints2->LineEdit2->setEnabled(false);
510 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
512 else if (send == GroupPoints3->PushButton1) {
513 myEditCurrentArgument = GroupPoints3->LineEdit1;
515 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
516 this, SLOT(SelectionIntoArgument()));
519 myEditCurrentArgument->setEnabled(true);
520 myEditCurrentArgument->setFocus();
521 // after setFocus(), because it will be setDown(false) when loses focus
524 // seems we need it only to avoid preview disappearing, caused by selection mode change
528 //=================================================================================
529 // function : LineEditReturnPressed()
531 //=================================================================================
532 void GenerationGUI_PrismDlg::LineEditReturnPressed()
534 QLineEdit* send = (QLineEdit*)sender();
535 if (send == GroupPoints->LineEdit1 ||
536 send == GroupPoints->LineEdit2 ||
537 send == GroupPoints2->LineEdit1 ||
538 send == GroupPoints2->LineEdit2 ||
539 send == GroupPoints2->LineEdit3 ||
540 send == GroupPoints3->LineEdit1) {
541 myEditCurrentArgument = send;
542 GEOMBase_Skeleton::LineEditReturnPressed();
546 //=================================================================================
547 // function : ActivateThisDialog()
549 //=================================================================================
550 void GenerationGUI_PrismDlg::ActivateThisDialog()
552 GEOMBase_Skeleton::ActivateThisDialog();
554 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
555 this, SLOT( SelectionIntoArgument() ) );
557 ConstructorsClicked( getConstructorId() );
560 //=================================================================================
561 // function : enterEvent()
562 // purpose : when mouse enter onto the QWidget
563 //=================================================================================
564 void GenerationGUI_PrismDlg::enterEvent (QEvent*)
566 if (!mainFrame()->GroupConstructors->isEnabled())
567 ActivateThisDialog();
570 //=================================================================================
571 // function : ValueChangedInSpinBox()
573 //=================================================================================
574 void GenerationGUI_PrismDlg::ValueChangedInSpinBox()
579 //=================================================================================
580 // function : getHeight()
582 //=================================================================================
583 double GenerationGUI_PrismDlg::getHeight() const
585 return GroupPoints->SpinBox_DX->value();
588 //=================================================================================
589 // function : createOperation
591 //=================================================================================
592 GEOM::GEOM_IOperations_ptr GenerationGUI_PrismDlg::createOperation()
594 return getGeomEngine()->GetI3DPrimOperations(getStudyId());
597 //=================================================================================
598 // function : isValid
600 //=================================================================================
601 bool GenerationGUI_PrismDlg::isValid (QString& msg)
604 if( getConstructorId() == 0 )
605 ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
606 else if( getConstructorId() == 2 )
608 ok = GroupPoints3->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
609 ok = GroupPoints3->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
610 ok = GroupPoints3->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
613 if (getConstructorId() == 0)
614 return (myOkBase && myOkVec) && ok; // by vector and height
615 else if (getConstructorId() == 1)
616 return (myOkBase && myOkPnt1 && myOkPnt2); // by two points
617 else if (getConstructorId() == 2)
618 return myOkBase && ok;
623 //=================================================================================
624 // function : execute
626 //=================================================================================
627 bool GenerationGUI_PrismDlg::execute (ObjectList& objects)
629 QStringList aParameters;
630 GEOM::GEOM_Object_var anObj, aBaseObj;
632 GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
634 for (int i=0; i < myBaseObjects.length(); i++) {
635 aBaseObj = myBaseObjects[i];
637 switch (getConstructorId()) {
640 anObj = anOper->MakePrismVecH(aBaseObj, myVec, getHeight());
642 anObj = anOper->MakePrismVecH2Ways(aBaseObj, myVec, getHeight());
644 if (!anObj->_is_nil() && !IsPreview()) {
645 aParameters << GroupPoints->SpinBox_DX->text();
646 anObj->SetParameters(aParameters.join(":").toLatin1().constData());
651 anObj = anOper->MakePrismTwoPnt(aBaseObj, myPoint1, myPoint2);
653 anObj = anOper->MakePrismTwoPnt2Ways(aBaseObj, myPoint1, myPoint2);
656 double dx = GroupPoints3->SpinBox_DX->value();
657 double dy = GroupPoints3->SpinBox_DY->value();
658 double dz = GroupPoints3->SpinBox_DZ->value();
661 anObj = anOper->MakePrismDXDYDZ(aBaseObj, dx, dy, dz);
663 anObj = anOper->MakePrismDXDYDZ2Ways(aBaseObj, dx, dy, dz);
665 if (!anObj->_is_nil() && !IsPreview()) {
666 aParameters << GroupPoints3->SpinBox_DX->text();
667 aParameters << GroupPoints3->SpinBox_DY->text();
668 aParameters << GroupPoints3->SpinBox_DZ->text();
669 anObj->SetParameters(aParameters.join(":").toLatin1().constData());
674 if (!anObj->_is_nil())
675 objects.push_back(anObj._retn());
681 //=================================================================================
682 // function : onReverse()
684 //=================================================================================
685 void GenerationGUI_PrismDlg::onReverse()
687 double anOldValue = GroupPoints->SpinBox_DX->value();
688 GroupPoints->SpinBox_DX->setValue(-anOldValue);
691 //=================================================================================
692 // function : onBothway()
694 //=================================================================================
695 void GenerationGUI_PrismDlg::onBothway()
698 switch (getConstructorId()) {
700 anOldValue = myBothway;
701 myBothway = !anOldValue;
702 GroupPoints->CheckButton2->setEnabled(!myBothway);
706 anOldValue = myBothway2;
707 myBothway2 = !anOldValue;
711 anOldValue = myBothway3;
712 myBothway3 = !anOldValue;
718 //=================================================================================
719 // function : addSubshapeToStudy
720 // purpose : virtual method to add new SubObjects if local selection
721 //=================================================================================
722 void GenerationGUI_PrismDlg::addSubshapesToStudy()
724 QMap<QString, GEOM::GEOM_Object_var> objMap;
726 switch (getConstructorId()) {
728 objMap[GroupPoints->LineEdit2->text()] = myVec;
731 objMap[GroupPoints2->LineEdit2->text()] = myPoint1;
732 objMap[GroupPoints2->LineEdit3->text()] = myPoint2;
735 addSubshapesToFather(objMap);
738 //=================================================================================
739 // function : extractPrefix
740 // purpose : redefined from GEOMBase_Helper class
741 //=================================================================================
742 bool GenerationGUI_PrismDlg::extractPrefix() const
744 return myBaseObjects.length() > 1;