1 // Copyright (C) 2007-2008 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
22 // GEOM GEOMGUI : GUI for Geometry component
23 // File : GenerationGUI_PrismDlg.cxx
24 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
26 #include "GenerationGUI_PrismDlg.h"
29 #include <GeometryGUI.h>
32 #include <SUIT_Session.h>
33 #include <SUIT_ResourceMgr.h>
34 #include <SalomeApp_Application.h>
35 #include <LightApp_SelectionMgr.h>
38 #include <TopoDS_Shape.hxx>
39 #include <TopoDS_Edge.hxx>
42 #include <TColStd_IndexedMapOfInteger.hxx>
43 #include <TopTools_IndexedMapOfShape.hxx>
45 #include <GEOMImpl_Types.hxx>
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),
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")));
65 setWindowTitle(tr("GEOM_EXTRUSION_TITLE"));
67 /***************************************************************/
68 mainFrame()->GroupConstructors->setTitle(tr("GEOM_EXTRUSION"));
69 mainFrame()->RadioButton1->setIcon(image0);
70 mainFrame()->RadioButton2->setIcon(image2);
71 mainFrame()->RadioButton3->setIcon(image3);
73 mainFrame()->RadioButton1->setChecked(true);
74 myBothway = myBothway2 = myBothway3 = false;
76 GroupPoints = new DlgRef_2Sel1Spin2Check(centralWidget());
77 GroupPoints->GroupBox1->setTitle(tr("GEOM_EXTRUSION_BSV"));
78 GroupPoints->TextLabel1->setText(tr("GEOM_BASE"));
79 GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR"));
80 GroupPoints->TextLabel3->setText(tr("GEOM_HEIGHT"));
81 GroupPoints->PushButton1->setIcon(image1);
82 GroupPoints->PushButton2->setIcon(image1);
83 GroupPoints->LineEdit1->setReadOnly(true);
84 GroupPoints->LineEdit2->setReadOnly(true);
85 GroupPoints->CheckButton1->setText(tr("GEOM_BOTHWAY"));
86 GroupPoints->CheckButton1->setChecked(myBothway);
87 GroupPoints->CheckButton2->setText(tr("GEOM_REVERSE"));
89 GroupPoints2 = new DlgRef_3Sel1Check(centralWidget());
90 GroupPoints2->GroupBox1->setTitle(tr("GEOM_EXTRUSION_BSV_2P"));
91 GroupPoints2->TextLabel1->setText(tr("GEOM_BASE"));
92 GroupPoints2->TextLabel2->setText(tr("GEOM_POINT_I").arg(1));
93 GroupPoints2->TextLabel3->setText(tr("GEOM_POINT_I").arg(2));
94 GroupPoints2->PushButton1->setIcon(image1);
95 GroupPoints2->PushButton2->setIcon(image1);
96 GroupPoints2->PushButton3->setIcon(image1);
97 GroupPoints2->CheckButton1->setText(tr("GEOM_BOTHWAY"));
98 GroupPoints2->CheckButton1->setChecked(myBothway2);
100 GroupPoints3 = new DlgRef_1Sel3Spin1Check(centralWidget());
101 GroupPoints3->GroupBox1->setTitle(tr("GEOM_EXTRUSION_DXDYDZ"));
102 GroupPoints3->TextLabel1->setText(tr("GEOM_BASE"));
103 GroupPoints3->PushButton1->setIcon(image1);
104 GroupPoints3->TextLabel2->setText(tr("GEOM_DX"));
105 GroupPoints3->TextLabel3->setText(tr("GEOM_DY"));
106 GroupPoints3->TextLabel4->setText(tr("GEOM_DZ"));
107 GroupPoints3->CheckButton1->setText(tr("GEOM_BOTHWAY"));
108 GroupPoints3->CheckButton1->setChecked(myBothway3);
110 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
111 layout->setMargin(0); layout->setSpacing(6);
112 layout->addWidget(GroupPoints);
113 layout->addWidget(GroupPoints2);
114 layout->addWidget(GroupPoints3);
115 /***************************************************************/
117 setHelpFileName("create_extrusion_page.html");
122 //=================================================================================
123 // function : ~GenerationGUI_PrismDlg()
124 // purpose : Destroys the object and frees any allocated resources
125 //=================================================================================
126 GenerationGUI_PrismDlg::~GenerationGUI_PrismDlg()
128 // no need to delete child widgets, Qt does it all for us
131 //=================================================================================
134 //=================================================================================
135 void GenerationGUI_PrismDlg::Init()
137 // Get setting of step value from file configuration
138 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
139 double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
141 // min, max, step and decimals for spin boxes & initial values
142 initSpinBox(GroupPoints3->SpinBox_DX, COORD_MIN, COORD_MAX, step, 6); // VSR:TODO : DBL_DIGITS_DISPLAY
143 initSpinBox(GroupPoints3->SpinBox_DY, COORD_MIN, COORD_MAX, step, 6); // VSR:TODO : DBL_DIGITS_DISPLAY
144 initSpinBox(GroupPoints3->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 6); // VSR:TODO : DBL_DIGITS_DISPLAY
145 GroupPoints3->SpinBox_DX->setValue(0.0);
146 GroupPoints3->SpinBox_DY->setValue(0.0);
147 GroupPoints3->SpinBox_DZ->setValue(0.0);
149 initSpinBox(GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, step, 6); // VSR: TODO: DBL_DIGITS_DISPLAY
150 GroupPoints->SpinBox_DX->setValue(100.0);
153 myEditCurrentArgument = GroupPoints->LineEdit1;
154 GroupPoints->LineEdit1->setReadOnly(true);
155 GroupPoints->LineEdit2->setReadOnly(true);
157 GroupPoints2->LineEdit1->setReadOnly(true);
158 GroupPoints2->LineEdit2->setReadOnly(true);
159 GroupPoints2->LineEdit3->setReadOnly(true);
161 GroupPoints3->LineEdit1->setReadOnly(true);
163 GroupPoints->LineEdit1->setText("");
164 GroupPoints->LineEdit2->setText("");
166 GroupPoints2->LineEdit1->setText("");
167 GroupPoints2->LineEdit2->setText("");
168 GroupPoints2->LineEdit3->setText("");
170 GroupPoints3->LineEdit1->setText("");
172 myPoint1 = myPoint2 = myVec = GEOM::GEOM_Object::_nil();
173 myOkBase = myOkVec = myOkPnt1 = myOkPnt2 = false;
175 // signals and slots connections
176 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
177 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
179 connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
181 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
182 connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
184 connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
185 connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
187 connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
188 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
190 connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway()));
191 connect(GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(onReverse()));
193 connect(GroupPoints2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
194 connect(GroupPoints2->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
195 connect(GroupPoints2->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
196 connect(GroupPoints2->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway()));
198 connect(GroupPoints2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
199 connect(GroupPoints2->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
200 connect(GroupPoints2->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
202 connect(GroupPoints3->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
203 connect(GroupPoints3->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
204 connect(GroupPoints3->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
205 connect(GroupPoints3->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
206 connect(GroupPoints3->SpinBox_DZ, SIGNAL(valueChanged (double)), this, SLOT(ValueChangedInSpinBox()));
207 connect(GroupPoints3->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway()));
209 initName(tr("GEOM_EXTRUSION"));
211 ConstructorsClicked(0);
214 //=================================================================================
215 // function : SetDoubleSpinBoxStep()
216 // purpose : Double spin box management
217 //=================================================================================
218 void GenerationGUI_PrismDlg::SetDoubleSpinBoxStep (double step)
220 GroupPoints->SpinBox_DX->setSingleStep(step);
221 GroupPoints3->SpinBox_DX->setSingleStep(step);
222 GroupPoints3->SpinBox_DY->setSingleStep(step);
223 GroupPoints3->SpinBox_DZ->setSingleStep(step);
226 //=================================================================================
227 // function : ConstructorsClicked()
228 // purpose : Radio button management
229 //=================================================================================
230 void GenerationGUI_PrismDlg::ConstructorsClicked (int constructorId)
232 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
234 switch (constructorId) {
237 GroupPoints2->hide();
238 GroupPoints3->hide();
241 GroupPoints->LineEdit1->setText(GroupPoints2->LineEdit1->text()); // keep base
242 GroupPoints->LineEdit2->setText("");
243 myVec = GEOM::GEOM_Object::_nil();
246 GroupPoints->PushButton1->click();
252 GroupPoints2->show();
253 GroupPoints3->hide();
255 GroupPoints2->LineEdit1->setText(GroupPoints->LineEdit1->text()); // keep base
256 GroupPoints2->LineEdit2->setText("");
257 GroupPoints2->LineEdit3->setText("");
258 myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
259 myOkPnt1 = myOkPnt2 = false;
261 GroupPoints2->PushButton1->click();
267 GroupPoints2->hide();
268 GroupPoints3->show();
270 GroupPoints3->LineEdit1->setText(GroupPoints->LineEdit1->text()); // keep base
272 GroupPoints3->PushButton1->click();
277 qApp->processEvents();
279 resize(minimumSizeHint());
281 SelectionIntoArgument();
285 //=================================================================================
286 // function : ClickOnOk()
288 //=================================================================================
289 void GenerationGUI_PrismDlg::ClickOnOk()
295 //=================================================================================
296 // function : ClickOnApply()
298 //=================================================================================
299 bool GenerationGUI_PrismDlg::ClickOnApply()
305 // activate selection and connect selection manager
306 ConstructorsClicked(getConstructorId());
310 //=================================================================================
311 // function : SelectionIntoArgument()
312 // purpose : Called when selection is changed or on dialog initialization or activation
313 //=================================================================================
314 void GenerationGUI_PrismDlg::SelectionIntoArgument()
317 myEditCurrentArgument->setText("");
319 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
320 SALOME_ListIO aSelList;
321 aSelMgr->selectedObjects(aSelList);
323 QString aBaseName = ""; /* name of base object selection */
324 int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aBaseName, true);
327 aBaseName = QString( "%1_objects").arg( nbSel );
329 // Base Object(s) selected
330 if (myEditCurrentArgument == GroupPoints->LineEdit1 ||
331 myEditCurrentArgument == GroupPoints2->LineEdit1 ||
332 getConstructorId() == 2 ) {
335 GEOMBase::ConvertListOfIOInListOfGO(aSelList, myBaseObjects, true);
336 myEditCurrentArgument->setText( aBaseName );
343 if (getConstructorId() == 0)
345 if (aSelList.Extent() < 1) {
346 if (myEditCurrentArgument == GroupPoints->LineEdit2)
351 Standard_Boolean testResult = Standard_False;
352 GEOM::GEOM_Object_var aSelectedObject =
353 GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
354 if (!testResult || 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 == GEOM::GEOM_Object::_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 Standard_Boolean testResult = Standard_False;
411 GEOM::GEOM_Object_var aSelectedObject =
412 GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
414 if (!testResult || CORBA::is_nil(aSelectedObject))
417 QString aName = GEOMBase::GetName(aSelectedObject);
420 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) {
421 TColStd_IndexedMapOfInteger aMap;
422 aSelMgr->GetIndexes(aSelList.First(), aMap);
423 if (aMap.Extent() == 1) {
424 int anIndex = aMap(1);
425 aName.append(":vertex_" + QString::number(anIndex));
427 //Find SubShape Object in Father
428 GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName);
430 if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study
431 GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
432 aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
435 aSelectedObject = aFindedObject;
439 if ((aShape.ShapeType() != TopAbs_VERTEX && myEditCurrentArgument == GroupPoints2->LineEdit2) ||
440 (aShape.ShapeType() != TopAbs_VERTEX && myEditCurrentArgument == GroupPoints2->LineEdit3)) {
441 aSelectedObject = GEOM::GEOM_Object::_nil();
448 myEditCurrentArgument->setText(aName);
450 if (myEditCurrentArgument == GroupPoints2->LineEdit2 && myOk) {
452 myPoint1 = aSelectedObject;
454 GroupPoints2->PushButton3->click();
456 else if (myEditCurrentArgument == GroupPoints2->LineEdit3 && myOk) {
458 myPoint2 = aSelectedObject;
460 GroupPoints2->PushButton1->click();
467 //=================================================================================
468 // function : SetEditCurrentArgument()
470 //=================================================================================
471 void GenerationGUI_PrismDlg::SetEditCurrentArgument()
473 QPushButton* send = (QPushButton*)sender();
475 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
476 globalSelection(GEOM_ALLSHAPES);
477 if (send == GroupPoints->PushButton1) {
478 myEditCurrentArgument = GroupPoints->LineEdit1;
479 GroupPoints->PushButton2->setDown(false);
480 GroupPoints->LineEdit2->setEnabled(false);
482 else if (send == GroupPoints->PushButton2) {
483 myEditCurrentArgument = GroupPoints->LineEdit2;
484 GroupPoints->PushButton1->setDown(false);
485 GroupPoints->LineEdit1->setEnabled(false);
486 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
488 else if (send == GroupPoints2->PushButton1) {
489 myEditCurrentArgument = GroupPoints2->LineEdit1;
490 GroupPoints2->PushButton2->setDown(false);
491 GroupPoints2->PushButton3->setDown(false);
492 GroupPoints2->LineEdit2->setEnabled(false);
493 GroupPoints2->LineEdit3->setEnabled(false);
495 else if (send == GroupPoints2->PushButton2) {
496 myEditCurrentArgument = GroupPoints2->LineEdit2;
497 GroupPoints2->PushButton1->setDown(false);
498 GroupPoints2->PushButton3->setDown(false);
499 GroupPoints2->LineEdit1->setEnabled(false);
500 GroupPoints2->LineEdit3->setEnabled(false);
501 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
503 else if (send == GroupPoints2->PushButton3) {
504 myEditCurrentArgument = GroupPoints2->LineEdit3;
505 GroupPoints2->PushButton1->setDown(false);
506 GroupPoints2->PushButton2->setDown(false);
507 GroupPoints2->LineEdit1->setEnabled(false);
508 GroupPoints2->LineEdit2->setEnabled(false);
509 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
511 else if (send == GroupPoints3->PushButton1) {
512 myEditCurrentArgument = GroupPoints3->LineEdit1;
514 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
515 this, SLOT(SelectionIntoArgument()));
518 myEditCurrentArgument->setEnabled(true);
519 myEditCurrentArgument->setFocus();
520 // after setFocus(), because it will be setDown(false) when loses focus
523 // seems we need it only to avoid preview disappearing, caused by selection mode change
527 //=================================================================================
528 // function : LineEditReturnPressed()
530 //=================================================================================
531 void GenerationGUI_PrismDlg::LineEditReturnPressed()
533 QLineEdit* send = (QLineEdit*)sender();
534 if (send == GroupPoints->LineEdit1 ||
535 send == GroupPoints->LineEdit2 ||
536 send == GroupPoints2->LineEdit1 ||
537 send == GroupPoints2->LineEdit2 ||
538 send == GroupPoints2->LineEdit3 ||
539 send == GroupPoints3->LineEdit1) {
540 myEditCurrentArgument = send;
541 GEOMBase_Skeleton::LineEditReturnPressed();
545 //=================================================================================
546 // function : ActivateThisDialog()
548 //=================================================================================
549 void GenerationGUI_PrismDlg::ActivateThisDialog()
551 GEOMBase_Skeleton::ActivateThisDialog();
553 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
554 this, SLOT( SelectionIntoArgument() ) );
556 ConstructorsClicked( getConstructorId() );
559 //=================================================================================
560 // function : enterEvent()
561 // purpose : when mouse enter onto the QWidget
562 //=================================================================================
563 void GenerationGUI_PrismDlg::enterEvent (QEvent*)
565 if (!mainFrame()->GroupConstructors->isEnabled())
566 ActivateThisDialog();
569 //=================================================================================
570 // function : ValueChangedInSpinBox()
572 //=================================================================================
573 void GenerationGUI_PrismDlg::ValueChangedInSpinBox()
578 //=================================================================================
579 // function : getHeight()
581 //=================================================================================
582 double GenerationGUI_PrismDlg::getHeight() const
584 return GroupPoints->SpinBox_DX->value();
587 //=================================================================================
588 // function : createOperation
590 //=================================================================================
591 GEOM::GEOM_IOperations_ptr GenerationGUI_PrismDlg::createOperation()
593 return getGeomEngine()->GetI3DPrimOperations(getStudyId());
596 //=================================================================================
597 // function : isValid
599 //=================================================================================
600 bool GenerationGUI_PrismDlg::isValid (QString& msg)
603 if( getConstructorId() == 0 )
604 ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
605 else if( getConstructorId() == 2 )
607 ok = GroupPoints3->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
608 ok = GroupPoints3->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
609 ok = GroupPoints3->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
612 if (getConstructorId() == 0)
613 return (myOkBase && myOkVec) && ok; // by vector and height
614 else if (getConstructorId() == 1)
615 return (myOkBase && myOkPnt1 && myOkPnt2); // by two points
616 else if (getConstructorId() == 2)
617 return myOkBase && ok;
622 //=================================================================================
623 // function : execute
625 //=================================================================================
626 bool GenerationGUI_PrismDlg::execute (ObjectList& objects)
628 QStringList aParameters;
629 GEOM::GEOM_Object_var anObj, aBaseObj;
631 GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
633 for (int i=0; i < myBaseObjects.length(); i++) {
634 aBaseObj = myBaseObjects[i];
636 switch (getConstructorId()) {
639 anObj = anOper->MakePrismVecH(aBaseObj, myVec, getHeight());
641 anObj = anOper->MakePrismVecH2Ways(aBaseObj, myVec, getHeight());
643 if (!anObj->_is_nil() && !IsPreview()) {
644 aParameters << GroupPoints->SpinBox_DX->text();
645 anObj->SetParameters(aParameters.join(":").toLatin1().constData());
650 anObj = anOper->MakePrismTwoPnt(aBaseObj, myPoint1, myPoint2);
652 anObj = anOper->MakePrismTwoPnt2Ways(aBaseObj, myPoint1, myPoint2);
655 double dx = GroupPoints3->SpinBox_DX->value();
656 double dy = GroupPoints3->SpinBox_DY->value();
657 double dz = GroupPoints3->SpinBox_DZ->value();
660 anObj = anOper->MakePrismDXDYDZ(aBaseObj, dx, dy, dz);
662 anObj = anOper->MakePrismDXDYDZ2Ways(aBaseObj, dx, dy, dz);
664 if (!anObj->_is_nil() && !IsPreview()) {
665 aParameters << GroupPoints3->SpinBox_DX->text();
666 aParameters << GroupPoints3->SpinBox_DY->text();
667 aParameters << GroupPoints3->SpinBox_DZ->text();
668 anObj->SetParameters(aParameters.join(":").toLatin1().constData());
673 if (!anObj->_is_nil())
674 objects.push_back(anObj._retn());
680 //=================================================================================
681 // function : onReverse()
683 //=================================================================================
684 void GenerationGUI_PrismDlg::onReverse()
686 double anOldValue = GroupPoints->SpinBox_DX->value();
687 GroupPoints->SpinBox_DX->setValue(-anOldValue);
690 //=================================================================================
691 // function : onBothway()
693 //=================================================================================
694 void GenerationGUI_PrismDlg::onBothway()
697 switch (getConstructorId()) {
699 anOldValue = myBothway;
700 myBothway = !anOldValue;
701 GroupPoints->CheckButton2->setEnabled(!myBothway);
705 anOldValue = myBothway2;
706 myBothway2 = !anOldValue;
710 anOldValue = myBothway3;
711 myBothway3 = !anOldValue;
717 //=================================================================================
718 // function : addSubshapeToStudy
719 // purpose : virtual method to add new SubObjects if local selection
720 //=================================================================================
721 void GenerationGUI_PrismDlg::addSubshapesToStudy()
723 QMap<QString, GEOM::GEOM_Object_var> objMap;
725 switch (getConstructorId()) {
727 objMap[GroupPoints->LineEdit2->text()] = myVec;
730 objMap[GroupPoints2->LineEdit2->text()] = myPoint1;
731 objMap[GroupPoints2->LineEdit3->text()] = myPoint2;
734 addSubshapesToFather(objMap);