1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 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 // File : OperationGUI_ChamferDlg.cxx
23 // Author : Damien COQUERET, Open CASCADE S.A.S.
26 #include "OperationGUI_ChamferDlg.h"
29 #include <GeometryGUI.h>
32 #include <SUIT_Desktop.h>
33 #include <SUIT_Session.h>
34 #include <SUIT_ResourceMgr.h>
35 #include <SUIT_ViewWindow.h>
36 #include <SUIT_ViewManager.h>
37 #include <SalomeApp_Application.h>
38 #include <LightApp_SelectionMgr.h>
39 #include <OCCViewer_ViewModel.h>
42 #include <TColStd_MapOfInteger.hxx>
44 #include <GEOMImpl_Types.hxx>
46 //=================================================================================
47 // class : OperationGUI_ChamferDlg()
48 // purpose : Constructs a OperationGUI_ChamferDlg which is a child of 'parent', with the
49 // name 'name' and widget flags set to 'f'.
50 // The dialog will by default be modeless, unless you set 'modal' to
51 // TRUE to construct a modal dialog.
52 //=================================================================================
53 OperationGUI_ChamferDlg::OperationGUI_ChamferDlg (GeometryGUI* theGeometryGUI, QWidget* parent)
54 : GEOMBase_Skeleton(theGeometryGUI, parent, false),
57 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
58 QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_CHAMFER_ALL")));
59 QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_CHAMFER_EDGE_FROM_FACE")));
60 QPixmap image3 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_CHAMFER_FACE")));
61 QPixmap image4 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_CHAMFER_EDGE")));
63 QPixmap iconSelect (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
65 setWindowTitle(tr("GEOM_CHAMFER_TITLE"));
67 /***************************************************************/
68 mainFrame()->GroupConstructors->setTitle(tr("GEOM_CHAMFER"));
70 mainFrame()->RadioButton1->setIcon(image1);
71 mainFrame()->RadioButton2->setIcon(image2);
72 mainFrame()->RadioButton3->setIcon(image3);
73 mainFrame()->RadioButton4->show();
74 mainFrame()->RadioButton4->setIcon(image4);
78 myGrp1 = new QGroupBox(tr("GEOM_CHAMFER_ALL"), centralWidget());
80 QGridLayout* aLayout = new QGridLayout(myGrp1);
81 aLayout->setMargin(9); aLayout->setSpacing(6);
83 createSelWg(tr("GEOM_MAIN_OBJECT"), iconSelect, myGrp1, aLayout, MainObj1);
85 int row = aLayout->rowCount();
86 aLayout->addWidget(new QLabel(tr("D"), myGrp1), row, 0);
87 aLayout->addWidget((mySpinBox[ SpinBox1 ] = new QDoubleSpinBox(myGrp1)), row++, 2);
88 aLayout->setRowStretch(row, 10);
90 // Create second group
92 myGrp2 = new QGroupBox(tr("GEOM_CHAMFER_EDGES"), centralWidget());
94 aLayout = new QGridLayout(myGrp2);
95 aLayout->setMargin(9); aLayout->setSpacing(6);
97 createSelWg(tr("GEOM_MAIN_OBJECT"), iconSelect, myGrp2, aLayout, MainObj2);
98 createSelWg(tr("FACE_1"), iconSelect, myGrp2, aLayout, Face1);
99 createSelWg(tr("FACE_2"), iconSelect, myGrp2, aLayout, Face2);
101 createRadioWg(tr("GEOM_D1"), tr("GEOM_D2"), myGrp2, aLayout, RadioButton21, SpinBox21, SpinBox22);
102 createRadioWg(tr("GEOM_D"), tr("GEOM_ANGLE"), myGrp2, aLayout, RadioButton22, SpinBox23, SpinBox24);
104 aLayout->setRowStretch(aLayout->rowCount(), 10);
106 // Create third group
108 myGrp3 = new QGroupBox(tr("GEOM_CHAMFER_FACES"), centralWidget());
110 aLayout = new QGridLayout(myGrp3);
111 aLayout->setMargin(9); aLayout->setSpacing(6);
113 createSelWg(tr("GEOM_MAIN_OBJECT"), iconSelect, myGrp3, aLayout, MainObj3);
114 createSelWg(tr("SELECTED_FACES"), iconSelect, myGrp3, aLayout, Faces);
116 createRadioWg(tr("GEOM_D1"), tr("GEOM_D2"), myGrp3, aLayout, RadioButton31, SpinBox31, SpinBox32);
117 createRadioWg(tr("GEOM_D"), tr("GEOM_ANGLE"), myGrp3, aLayout, RadioButton32, SpinBox33, SpinBox34);
119 aLayout->setRowStretch(aLayout->rowCount(), 10);
121 // Create fourth group
123 myGrp4 = new QGroupBox(tr("GEOM_CHAMFER_EDGE"), centralWidget());
125 aLayout = new QGridLayout(myGrp4);
126 aLayout->setMargin(9); aLayout->setSpacing(6);
128 createSelWg(tr("GEOM_MAIN_OBJECT"), iconSelect, myGrp4, aLayout, MainObj4);
129 createSelWg(tr("SELECTED_EDGE"), iconSelect, myGrp4, aLayout, Edges);
131 createRadioWg(tr("GEOM_D1"), tr("GEOM_D2"), myGrp4, aLayout, RadioButton41, SpinBox41, SpinBox42);
132 createRadioWg(tr("GEOM_D"), tr("GEOM_ANGLE"), myGrp4, aLayout, RadioButton42, SpinBox43, SpinBox44);
134 aLayout->setRowStretch(aLayout->rowCount(), 10);
136 // Add groups to layout
138 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
139 layout->setMargin(0); layout->setSpacing(6);
140 layout->addWidget(myGrp1);
141 layout->addWidget(myGrp2);
142 layout->addWidget(myGrp3);
143 layout->addWidget(myGrp4);
144 /***************************************************************/
146 // Set range of spinboxes
147 double SpecificStep = 10.0;
148 QMap< int, QDoubleSpinBox* >::iterator anIter;
149 for (anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter) {
150 if (anIter.key() == SpinBox44 || anIter.key() == SpinBox34 || anIter.key() == SpinBox24)
151 initSpinBox(anIter.value(), 0.001, 89.999, 5, 0);
153 initSpinBox(anIter.value(), 0.001, COORD_MAX, SpecificStep, 3);
156 setHelpFileName("chamfer_operation_page.html");
160 myRadioButton[ RadioButton21 ]->click();
163 //=================================================================================
164 // function : ~OperationGUI_ChamferDlg()
165 // purpose : Destroys the object and frees any allocated resources
166 //=================================================================================
167 OperationGUI_ChamferDlg::~OperationGUI_ChamferDlg()
171 //=================================================================================
174 //=================================================================================
175 void OperationGUI_ChamferDlg::Init()
177 // Set Initial values of spinboxes
178 QMap< int, QDoubleSpinBox* >::iterator anIter;
179 for (anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter)
180 anIter.value()->setValue(5);
183 QMap< int, QLineEdit* >::iterator anIterLE;
184 for (anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE)
185 anIterLE.value()->setText("");
187 myShape = GEOM::GEOM_Object::_nil();
191 myFace[ Face1 ] = -1;
192 myFace[ Face2 ] = -1;
194 // signals and slots connections
197 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk() ));
198 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
201 connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
204 QMap< int, QPushButton* >::iterator anIterBtn;
205 for (anIterBtn = mySelBtn.begin(); anIterBtn != mySelBtn.end(); ++anIterBtn)
206 connect(anIterBtn.value(), SIGNAL(clicked()),
207 this, SLOT(SetEditCurrentArgument()));
210 QMap< int, QLineEdit* >::iterator anIterLE2;
211 for (anIterLE2 = mySelName.begin(); anIterLE2 != mySelName.end(); ++anIterLE2)
212 connect(anIterLE2.value(), SIGNAL(returnPressed()),
213 this, SLOT(LineEditReturnPressed()));
216 QMap< int, QDoubleSpinBox* >::iterator anIterSpin;
217 for (anIterSpin = mySpinBox.begin(); anIterSpin != mySpinBox.end(); ++anIterSpin)
218 connect(anIterSpin.value(), SIGNAL(valueChanged(double)),
219 this, SLOT(ValueChangedInSpinBox(double)));
222 QMap< int, QRadioButton* >::iterator anIterRadio;
223 for (anIterRadio = myRadioButton.begin(); anIterRadio != myRadioButton.end(); ++anIterRadio)
224 connect(anIterRadio.value(), SIGNAL(clicked()),
225 this, SLOT(RadioButtonPressed()));
227 initName(tr("GEOM_CHAMFER"));
229 myConstructorId = -1;
230 ConstructorsClicked(0);
233 //=================================================================================
234 // function : ConstructorsClicked()
235 // purpose : Radio button management
236 //=================================================================================
237 void OperationGUI_ChamferDlg::ConstructorsClicked (int constructorId)
239 // Activate next widget
240 if (myGeomGUI->getApp()->desktop()->activeWindow()->getViewManager()->getType()
241 != OCCViewer_Viewer::Type()) {
242 mainFrame()->RadioButton1->setChecked(true);
246 if (myConstructorId == constructorId)
249 //disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
251 // Get values from previous widget
252 double D1 = 5, D2 = 5, D = 5, Angle = 5;
253 if (myConstructorId == 0)
254 D1 = D2 = mySpinBox[ SpinBox1 ]->value();
255 else if (myConstructorId == 1) {
256 D1 = mySpinBox[ SpinBox21 ]->value();
257 D2 = mySpinBox[ SpinBox22 ]->value();
258 D = mySpinBox[ SpinBox23 ]->value();
259 Angle = mySpinBox[ SpinBox24 ]->value();
261 else if (myConstructorId == 2) {
262 D1 = mySpinBox[ SpinBox31 ]->value();
263 D2 = mySpinBox[ SpinBox32 ]->value();
264 D = mySpinBox[ SpinBox33 ]->value();
265 Angle = mySpinBox[ SpinBox34 ]->value();
267 else if (myConstructorId == 3) {
268 D1 = mySpinBox[ SpinBox41 ]->value();
269 D2 = mySpinBox[ SpinBox42 ]->value();
270 D = mySpinBox[ SpinBox43 ]->value();
271 Angle = mySpinBox[ SpinBox44 ]->value();
274 myConstructorId = constructorId;
276 switch (constructorId) {
282 mySpinBox[ SpinBox1 ]->setValue(D1);
289 mySpinBox[ SpinBox21 ]->setValue(D1);
290 mySpinBox[ SpinBox22 ]->setValue(D2);
291 mySpinBox[ SpinBox23 ]->setValue(D);
292 mySpinBox[ SpinBox24 ]->setValue(Angle);
299 mySpinBox[ SpinBox31 ]->setValue(D1);
300 mySpinBox[ SpinBox32 ]->setValue(D2);
301 mySpinBox[ SpinBox32 ]->setValue(D2);
302 mySpinBox[ SpinBox33 ]->setValue(D);
303 mySpinBox[ SpinBox34 ]->setValue(Angle);
310 mySpinBox[ SpinBox41 ]->setValue(D1);
311 mySpinBox[ SpinBox42 ]->setValue(D2);
312 mySpinBox[ SpinBox43 ]->setValue(D);
313 mySpinBox[ SpinBox44 ]->setValue(Angle);
319 if (constructorId == 0) mySelBtn[ MainObj1 ]->click();
320 else if (constructorId == 1) mySelBtn[ MainObj2 ]->click();
321 else if (constructorId == 2) mySelBtn[ MainObj3 ]->click();
322 else mySelBtn[ MainObj4 ]->click();
328 SelectionIntoArgument();
331 if (!myShape->_is_nil()) {
332 myEditCurrentArgument->setText(GEOMBase::GetName(myShape));
333 GEOMBase_Skeleton::LineEditReturnPressed();
334 switch (getConstructorId()) {
336 if (myFace[ Face1 ] == -1)
337 mySelBtn[ Face1 ]->click();
340 if (myFaces.Extent() == 0)
341 mySelBtn[ Faces ]->click();
344 if (myEdges.Extent() == 0)
345 mySelBtn[ Edges ]->click();
352 myEditCurrentArgument->setText("");
358 qApp->processEvents();
360 resize(minimumSize());
363 //=================================================================================
364 // function : ClickOnOk()
366 //=================================================================================
367 void OperationGUI_ChamferDlg::ClickOnOk()
373 //=================================================================================
374 // function : ClickOnApply()
376 //=================================================================================
377 bool OperationGUI_ChamferDlg::ClickOnApply()
383 // activate selection and connect selection manager
384 ConstructorsClicked(getConstructorId());
388 //=================================================================================
389 // function : SelectionIntoArgument()
390 // purpose : Called when selection is changed or on dialog initialization or activation
391 //=================================================================================
392 void OperationGUI_ChamferDlg::SelectionIntoArgument()
395 myEditCurrentArgument->setText("");
397 // Get index of current selection focus
399 QMap< int, QLineEdit* >::iterator anIter;
400 for (anIter = mySelName.begin(); anIter != mySelName.end(); ++anIter) {
401 if (myEditCurrentArgument == anIter.value()) {
402 aCurrFocus = anIter.key();
407 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
408 SALOME_ListIO aSelList;
409 aSelMgr->selectedObjects(aSelList);
411 // If selection of main object is activated
412 if (aCurrFocus == MainObj1 || aCurrFocus == MainObj2 || aCurrFocus == MainObj3 || aCurrFocus == MainObj4)
414 myShape = GEOM::GEOM_Object::_nil();
415 if (aSelList.Extent() == 1) {
416 Standard_Boolean aResult = Standard_False;
417 GEOM::GEOM_Object_var anObj =
418 GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
420 if (aResult && !anObj->_is_nil()) {
422 myEditCurrentArgument->setText(GEOMBase::GetName(anObj));
429 // If face selection of second tab is activated
430 else if (aCurrFocus == Face1 || aCurrFocus == Face2)
432 myFace[ aCurrFocus ] = -1;
433 if (aSelList.Extent() == 1) {
434 Standard_Boolean aResult = Standard_False;
435 GEOM::GEOM_Object_var anObj =
436 GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
438 if (aResult && !anObj->_is_nil()) {
439 TColStd_IndexedMapOfInteger anIndexes;
440 aSelMgr->GetIndexes(aSelList.First(), anIndexes);
442 if (anIndexes.Extent() == 1) {
443 int anIndex = anIndexes(1);
444 QString aFaceName = QString(GEOMBase::GetName(anObj)) + ":%1";
445 myEditCurrentArgument->setText(aFaceName.arg(anIndex));
446 myFace[ aCurrFocus ] = anIndex;
452 // If face selection of third or fourth tab is activated
453 else if (aCurrFocus == Faces || aCurrFocus == Edges) {
454 if (aCurrFocus == Faces) myFaces.Clear();
455 else myEdges.Clear();
456 if (aSelList.Extent() == 1) {
457 Standard_Boolean aResult = Standard_False;
458 GEOM::GEOM_Object_var anObj =
459 GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
461 if (aResult && !anObj->_is_nil()) {
462 TColStd_IndexedMapOfInteger anIndexes;
463 aSelMgr->GetIndexes(aSelList.First(), anIndexes);
465 if (anIndexes.Extent() > 0) {
467 if (anIndexes.Extent() == 1) {
468 int anIndex = anIndexes(1);
470 aName = QString(GEOMBase::GetName(anObj)) + QString(":%1").arg(anIndex);
473 aName = tr("GEOM_MEN_POPUP_NAME").arg(anIndexes.Extent());
476 myEditCurrentArgument->setText(aName);
477 int aConstructorId = getConstructorId();
478 if (aConstructorId == 2)
480 else if (aConstructorId == 3)
490 if (aCurrFocus != Faces && aCurrFocus != Edges) {
491 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
492 myGeomGUI->getApp()->selectionMgr()->clearSelected();
493 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
494 this, SLOT(SelectionIntoArgument()));
497 switch (getConstructorId()) {
499 if (aCurrFocus == MainObj2) {
500 if (!myShape->_is_nil() && myFace[ Face1 ] == -1)
501 mySelBtn[ Face1 ]->click();
503 else if (aCurrFocus == Face1) {
504 if (myFace[ Face1 ] != -1 && myFace[ Face2 ] == -1)
505 mySelBtn[ Face2 ]->click();
507 else if (aCurrFocus == Face2) {
508 if (myFace[ Face2 ] != -1 && myShape->_is_nil())
509 mySelBtn[ MainObj2 ]->click();
513 if (aCurrFocus == MainObj3) {
514 if (!myShape->_is_nil() && myFaces.Extent() == 0)
515 mySelBtn[ Faces ]->click();
519 if (aCurrFocus == MainObj4) {
520 if (!myShape->_is_nil() && myEdges.Extent() == 0)
521 mySelBtn[ Edges ]->click();
529 //=================================================================================
530 // function : SetEditCurrentArgument()
532 //=================================================================================
533 void OperationGUI_ChamferDlg::SetEditCurrentArgument()
535 QPushButton* send = (QPushButton*)sender();
537 QMap< int, QPushButton* >::iterator anIter;
538 for (anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter) {
539 if (anIter.value() == send) {
540 mySelName[ anIter.key() ]->setFocus();
541 myEditCurrentArgument = mySelName[ anIter.key() ];
544 anIter.value()->setDown(false);
545 mySelName[ anIter.key() ]->setEnabled(false);
550 myEditCurrentArgument->setEnabled(true);
551 myEditCurrentArgument->setFocus();
552 // after setFocus(), because it will be setDown(false) when loses focus
557 // seems we need it only to avoid preview disappearing, caused by selection mode change
561 //=================================================================================
562 // function : LineEditReturnPressed()
564 //=================================================================================
565 void OperationGUI_ChamferDlg::LineEditReturnPressed()
567 QLineEdit* send = (QLineEdit*)sender();
569 QMap< int, QLineEdit* >::iterator anIterLE;
570 for (anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE)
571 if (anIterLE.value() == send)
572 myEditCurrentArgument = anIterLE.value();
574 GEOMBase_Skeleton::LineEditReturnPressed();
577 //=================================================================================
578 // function : ActivateThisDialog()
580 //=================================================================================
581 void OperationGUI_ChamferDlg::ActivateThisDialog()
583 GEOMBase_Skeleton::ActivateThisDialog();
585 // reinit, because some selected objects could be removed
589 //=================================================================================
590 // function : enterEvent()
592 //=================================================================================
593 void OperationGUI_ChamferDlg::enterEvent (QEvent*)
595 if (!mainFrame()->GroupConstructors->isEnabled())
596 this->ActivateThisDialog();
599 //=================================================================================
600 // function : ValueChangedInSpinBox()
602 //=================================================================================
603 void OperationGUI_ChamferDlg::ValueChangedInSpinBox (double)
608 //=================================================================================
609 // function : createSelWg()
611 //=================================================================================
612 void OperationGUI_ChamferDlg::createSelWg (const QString& theLbl,
615 QGridLayout* theLayout,
618 QLabel* lab = new QLabel(theLbl, theParent);
619 mySelBtn[ theId ] = new QPushButton(theParent);
620 mySelBtn[ theId ]->setIcon(thePix);
621 mySelName[ theId ] = new QLineEdit(theParent);
622 mySelName[ theId ]->setReadOnly(true);
623 int row = theLayout->rowCount();
624 theLayout->addWidget(lab, row, 0);
625 theLayout->addWidget(mySelBtn[ theId ], row, 1);
626 theLayout->addWidget(mySelName[ theId ], row, 2, 1, 4); // take into account createRadioWg()
629 //=================================================================================
630 // function : createRadioWg()
632 //=================================================================================
633 void OperationGUI_ChamferDlg::createRadioWg(const QString& theLbl1,
634 const QString& theLbl2,
636 QGridLayout* theLayout,
638 const int theSpin1Id,
639 const int theSpin2Id)
641 myRadioButton[ theRbId ] = new QRadioButton(theParent);
642 QLabel* lab1 = new QLabel(theLbl1, theParent);
643 QLabel* lab2 = new QLabel(theLbl2, theParent);
644 mySpinBox[ theSpin1Id ] = new QDoubleSpinBox(theParent);
645 mySpinBox[ theSpin2Id ] = new QDoubleSpinBox(theParent);
646 int row = theLayout->rowCount();
647 theLayout->addWidget(myRadioButton[ theRbId ], row, 0);
648 theLayout->addWidget(lab1, row, 2);
649 theLayout->addWidget(mySpinBox[ theSpin1Id ], row, 3);
650 theLayout->addWidget(lab2, row, 4);
651 theLayout->addWidget(mySpinBox[ theSpin2Id ], row, 5);
654 //=================================================================================
655 // function : activateSelection
656 // purpose : Activate selection in accordance with myEditCurrentArgument
657 //=================================================================================
658 void OperationGUI_ChamferDlg::activateSelection()
660 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
662 if (!myShape->_is_nil() &&
663 (myEditCurrentArgument == mySelName[ Face1 ] ||
664 myEditCurrentArgument == mySelName[ Face2 ] ||
665 myEditCurrentArgument == mySelName[ Faces ])) {
666 localSelection(myShape, TopAbs_FACE);
668 else if (!myShape->_is_nil() && myEditCurrentArgument == mySelName[ Edges ]) {
669 localSelection(myShape, TopAbs_EDGE);
672 TColStd_MapOfInteger aMap;
673 aMap.Add(GEOM_SHELL);
674 aMap.Add(GEOM_SOLID);
675 aMap.Add(GEOM_COMPOUND);
676 globalSelection(aMap);
679 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
680 this, SLOT(SelectionIntoArgument()));
683 //=================================================================================
684 // function : enableWidgets
685 // purpose : Enable widgets of faces in accordance with value of main object
686 //=================================================================================
687 void OperationGUI_ChamferDlg::enableWidgets()
689 int anId = getConstructorId();
691 bool toEnable = !myShape->_is_nil();
695 //mySelName[ Face1 ]->setEnabled(toEnable);
696 //mySelName[ Face2 ]->setEnabled(toEnable);
697 mySelBtn[ Face1 ]->setEnabled(toEnable);
698 mySelBtn[ Face2 ]->setEnabled(toEnable);
702 mySelName[ Face1 ]->setText("");
703 mySelName[ Face2 ]->setText("");
704 myFace[ Face1 ] = -1;
705 myFace[ Face2 ] = -1;
710 //mySelName[ Faces ]->setEnabled(toEnable);
711 mySelBtn[ Faces ]->setEnabled(toEnable);
713 mySelName[ Faces ]->setText("");
717 else if (anId == 3) {
718 //mySelName[ Edges ]->setEnabled(toEnable);
719 mySelBtn[ Edges ]->setEnabled(toEnable);
722 mySelName[ Edges ]->setText("");
728 //=================================================================================
729 // function : createOperation
731 //=================================================================================
732 GEOM::GEOM_IOperations_ptr OperationGUI_ChamferDlg::createOperation()
734 return getGeomEngine()->GetILocalOperations(getStudyId());
737 //=================================================================================
738 // function : isValid()
739 // purpose : Verify validity of input data
740 //=================================================================================
741 bool OperationGUI_ChamferDlg::isValid (QString&)
743 switch (getConstructorId())
745 case 0: return !myShape->_is_nil();
746 case 1: return !myShape->_is_nil() && myFace[ Face1 ] > 0 && myFace[ Face2 ] > 0;
747 case 2: return !myShape->_is_nil() && myFaces.Extent() > 0;
748 case 3: return !myShape->_is_nil() && myEdges.Extent() > 0;
749 default: return false;
753 //=================================================================================
754 // function : execute
756 //=================================================================================
757 bool OperationGUI_ChamferDlg::execute (ObjectList& objects)
759 GEOM::GEOM_Object_var anObj;
760 bool flag = (myRadioButton[ RadioButton21 ]->isChecked() &&
761 myRadioButton[ RadioButton31 ]->isChecked() &&
762 myRadioButton[ RadioButton41 ]->isChecked());
764 int anId = getConstructorId();
766 anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
767 MakeChamferAll(myShape, mySpinBox[ SpinBox1 ]->value());
769 else if (anId == 1) {
771 anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
772 MakeChamferEdge(myShape,
773 mySpinBox[ SpinBox21 ]->value(),
774 mySpinBox[ SpinBox22 ]->value(),
779 anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
780 MakeChamferEdgeAD(myShape,
781 mySpinBox[ SpinBox23 ]->value(),
782 mySpinBox[ SpinBox24 ]->value() * PI180,
789 GEOM::ListOfLong_var anArray = new GEOM::ListOfLong;
790 anArray->length(myFaces.Extent());
792 for (int i = 1, n = myFaces.Extent(); i <= n; i++)
793 anArray[ i - 1 ] = myFaces(i);
796 anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
797 MakeChamferFaces(myShape,
798 mySpinBox[ SpinBox31 ]->value(),
799 mySpinBox[ SpinBox32 ]->value(),
802 anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
803 MakeChamferFacesAD(myShape,
804 mySpinBox[ SpinBox33 ]->value(),
805 mySpinBox[ SpinBox34 ]->value() * PI180,
808 else if (anId == 3) {
809 GEOM::ListOfLong_var anArray = new GEOM::ListOfLong;
810 anArray->length(myEdges.Extent());
811 for (int i = 1, n = myEdges.Extent(); i <= n; i++)
812 anArray[ i - 1 ] = myEdges(i);
814 anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
815 MakeChamferEdges(myShape,
816 mySpinBox[ SpinBox41 ]->value(),
817 mySpinBox[ SpinBox42 ]->value(),
821 anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
822 MakeChamferEdgesAD(myShape,
823 mySpinBox[ SpinBox43 ]->value(),
824 mySpinBox[ SpinBox44 ]->value() * PI180,
829 if (!anObj->_is_nil())
830 objects.push_back(anObj._retn());
835 //=================================================================================
836 // function : RadioButtonPressed()
838 //=================================================================================
839 void OperationGUI_ChamferDlg::RadioButtonPressed()
841 const QObject* s = sender();
842 bool flag = s == myRadioButton[ RadioButton21 ] ||
843 s == myRadioButton[ RadioButton31 ] ||
844 s == myRadioButton[ RadioButton41 ];
846 myRadioButton[ RadioButton21 ]->blockSignals(true);
847 myRadioButton[ RadioButton22 ]->blockSignals(true);
848 myRadioButton[ RadioButton31 ]->blockSignals(true);
849 myRadioButton[ RadioButton32 ]->blockSignals(true);
850 myRadioButton[ RadioButton41 ]->blockSignals(true);
851 myRadioButton[ RadioButton42 ]->blockSignals(true);
853 myRadioButton[ RadioButton21 ]->setChecked(flag);
854 myRadioButton[ RadioButton31 ]->setChecked(flag);
855 myRadioButton[ RadioButton41 ]->setChecked(flag);
856 myRadioButton[ RadioButton22 ]->setChecked(!flag);
857 myRadioButton[ RadioButton32 ]->setChecked(!flag);
858 myRadioButton[ RadioButton42 ]->setChecked(!flag);
859 mySpinBox[ SpinBox21 ]->setEnabled(flag);
860 mySpinBox[ SpinBox22 ]->setEnabled(flag);
861 mySpinBox[ SpinBox31 ]->setEnabled(flag);
862 mySpinBox[ SpinBox32 ]->setEnabled(flag);
863 mySpinBox[ SpinBox41 ]->setEnabled(flag);
864 mySpinBox[ SpinBox42 ]->setEnabled(flag);
865 mySpinBox[ SpinBox23 ]->setEnabled(!flag);
866 mySpinBox[ SpinBox24 ]->setEnabled(!flag);
867 mySpinBox[ SpinBox33 ]->setEnabled(!flag);
868 mySpinBox[ SpinBox34 ]->setEnabled(!flag);
869 mySpinBox[ SpinBox43 ]->setEnabled(!flag);
870 mySpinBox[ SpinBox44 ]->setEnabled(!flag);
872 myRadioButton[ RadioButton21 ]->blockSignals(false);
873 myRadioButton[ RadioButton22 ]->blockSignals(false);
874 myRadioButton[ RadioButton31 ]->blockSignals(false);
875 myRadioButton[ RadioButton32 ]->blockSignals(false);
876 myRadioButton[ RadioButton41 ]->blockSignals(false);
877 myRadioButton[ RadioButton42 ]->blockSignals(false);