Back to index

salome-geom  6.5.0
OperationGUI_FilletDlg.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // GEOM GEOMGUI : GUI for Geometry component
00024 // File   : OperationGUI_FilletDlg.cxx
00025 // Author : Damien COQUERET, Open CASCADE S.A.S.
00026 //
00027 #include "OperationGUI_FilletDlg.h"
00028 
00029 #include <DlgRef.h>
00030 #include <GeometryGUI.h>
00031 #include <GEOMBase.h>
00032 
00033 #include <SUIT_Desktop.h>
00034 #include <SUIT_Session.h>
00035 #include <SUIT_ResourceMgr.h>
00036 #include <SUIT_ViewWindow.h>
00037 #include <SUIT_ViewManager.h>
00038 #include <SalomeApp_Application.h>
00039 #include <LightApp_SelectionMgr.h>
00040 #include <OCCViewer_ViewModel.h>
00041 
00042 // OCCT Includes
00043 #include <TColStd_MapOfInteger.hxx>
00044 #include <TColStd_IndexedMapOfInteger.hxx>
00045 
00046 #include <GEOMImpl_Types.hxx>
00047 
00048 //=================================================================================
00049 // class    : OperationGUI_FilletDlg()
00050 // purpose  : Constructs a OperationGUI_FilletDlg which is a child of 'parent', with the
00051 //            name 'name' and widget flags set to 'f'.
00052 //            The dialog will by default be modeless, unless you set 'modal' to
00053 //            TRUE to construct a modal dialog.
00054 //=================================================================================
00055 OperationGUI_FilletDlg::OperationGUI_FilletDlg (GeometryGUI* theGeometryGUI, QWidget* parent)
00056   : GEOMBase_Skeleton(theGeometryGUI, parent, false),
00057     myInitial(true)
00058 {
00059   SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
00060   QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_FILLET_ALL")));
00061   QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_FILLET_EDGE")));
00062   QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_FILLET_FACE")));
00063 
00064   QPixmap iconSelect (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
00065 
00066   setWindowTitle(tr("GEOM_FILLET_TITLE"));
00067 
00068   /***************************************************************/
00069   mainFrame()->GroupConstructors->setTitle(tr("GEOM_FILLET"));
00070   mainFrame()->RadioButton1->setIcon(image0);
00071   mainFrame()->RadioButton2->setIcon(image1);
00072   mainFrame()->RadioButton3->setIcon(image2);
00073 
00074   Group1 = new DlgRef_1Sel1Spin(centralWidget());
00075   Group1->GroupBox1->setTitle(tr("GEOM_FILLET_ALL"));
00076   Group1->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
00077   Group1->TextLabel2->setText(tr("GEOM_RADIUS"));
00078   Group1->PushButton1->setIcon(iconSelect);
00079   Group1->LineEdit1->setReadOnly(true);
00080 
00081   Group2 = new DlgRef_2Sel3Spin2Rb(centralWidget());
00082   Group2->GroupBox1->setTitle(tr("GEOM_FILLET_EDGES"));
00083   Group2->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
00084   Group2->TextLabel2->setText(tr("SELECTED_EDGES"));
00085   Group2->TextLabel3->setText(tr("GEOM_RADIUS"));
00086   Group2->TextLabel4->setText(tr("GEOM_R1"));
00087   Group2->TextLabel5->setText(tr("GEOM_R2"));
00088   Group2->PushButton1->setIcon(iconSelect);
00089   Group2->PushButton2->setIcon(iconSelect);
00090   Group2->LineEdit1->setReadOnly(true);
00091   Group2->LineEdit2->setReadOnly(true);
00092 
00093   Group3 = new DlgRef_2Sel3Spin2Rb(centralWidget());
00094   Group3->GroupBox1->setTitle(tr("GEOM_FILLET_FACES"));
00095   Group3->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
00096   Group3->TextLabel2->setText(tr("SELECTED_FACES"));
00097   Group3->TextLabel3->setText(tr("GEOM_RADIUS"));
00098   Group3->TextLabel4->setText(tr("GEOM_R1"));
00099   Group3->TextLabel5->setText(tr("GEOM_R2"));
00100   Group3->PushButton1->setIcon(iconSelect);
00101   Group3->PushButton2->setIcon(iconSelect);
00102   Group3->LineEdit1->setReadOnly(true);
00103   Group3->LineEdit2->setReadOnly(true);
00104 
00105   QVBoxLayout* layout = new QVBoxLayout(centralWidget());
00106   layout->setMargin(0); layout->setSpacing(6);
00107   layout->addWidget(Group1);
00108   layout->addWidget(Group2);
00109   layout->addWidget(Group3);
00110   /***************************************************************/
00111 
00112   // Set range of spinboxes
00113   double SpecificStep = 10.0;
00114   initSpinBox(Group1->SpinBox_DX, 0.001, COORD_MAX, SpecificStep, "length_precision" );
00115   initSpinBox(Group2->SpinBox_DX, 0.001, COORD_MAX, SpecificStep, "length_precision" );
00116   initSpinBox(Group2->SpinBox_DY, 0.001, COORD_MAX, SpecificStep, "length_precision" );
00117   initSpinBox(Group2->SpinBox_DZ, 0.001, COORD_MAX, SpecificStep, "length_precision" );
00118   initSpinBox(Group3->SpinBox_DX, 0.001, COORD_MAX, SpecificStep, "length_precision" );
00119   initSpinBox(Group3->SpinBox_DY, 0.001, COORD_MAX, SpecificStep, "length_precision" );
00120   initSpinBox(Group3->SpinBox_DZ, 0.001, COORD_MAX, SpecificStep, "length_precision" );
00121 
00122   setHelpFileName("fillet_operation_page.html");
00123 
00124   // Initialisation
00125   Init();
00126 }
00127 
00128 //=================================================================================
00129 // function : ~OperationGUI_FilletDlg()
00130 // purpose  : Destroys the object and frees any allocated resources
00131 //=================================================================================
00132 OperationGUI_FilletDlg::~OperationGUI_FilletDlg()
00133 {
00134 }
00135 
00136 //=================================================================================
00137 // function : Init()
00138 // purpose  :
00139 //=================================================================================
00140 void OperationGUI_FilletDlg::Init()
00141 {
00142   // Set Initial values of spinboxes
00143   Group1->SpinBox_DX->setValue(5);
00144   Group2->SpinBox_DX->setValue(5);
00145   Group2->SpinBox_DY->setValue(5);
00146   Group2->SpinBox_DZ->setValue(5);
00147   Group3->SpinBox_DX->setValue(5);
00148   Group3->SpinBox_DY->setValue(5);
00149   Group3->SpinBox_DZ->setValue(5);
00150 
00151   // Clear line edits
00152   Group1->LineEdit1->setText("");
00153   Group2->LineEdit1->setText("");
00154   Group2->LineEdit2->setText("");
00155   Group3->LineEdit1->setText("");
00156   Group3->LineEdit2->setText("");
00157 
00158   myShape = GEOM::GEOM_Object::_nil();
00159 
00160   myFaces.Clear();
00161   myEdges.Clear();
00162 
00163   showOnlyPreviewControl();
00164 
00165   // signals and slots connections
00166 
00167   // main buttons
00168   connect(buttonOk(),    SIGNAL(clicked()), this, SLOT(ClickOnOk()   ));
00169   connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
00170 
00171   // group box
00172   connect(this,          SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
00173 
00174   // push buttons
00175   connect(Group1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
00176   connect(Group2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
00177   connect(Group3->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
00178   connect(Group2->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
00179   connect(Group3->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
00180 
00181   // line edits
00182   connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
00183   connect(Group2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
00184   connect(Group3->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
00185 
00186   // spin boxes
00187   connect(Group1->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
00188   connect(Group2->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
00189   connect(Group2->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
00190   connect(Group2->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
00191   connect(Group3->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
00192   connect(Group3->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
00193   connect(Group3->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
00194 
00195   // radio buttons
00196   connect(Group2->RadioButton1, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
00197   connect(Group2->RadioButton2, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
00198   connect(Group3->RadioButton1, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
00199   connect(Group3->RadioButton2, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
00200 
00201   initName(tr("GEOM_FILLET"));
00202 
00203   myConstructorId = -1;
00204   ConstructorsClicked(0);
00205 }
00206 
00207 //=================================================================================
00208 // function : ConstructorsClicked()
00209 // purpose  : Radio button management
00210 //=================================================================================
00211 void OperationGUI_FilletDlg::ConstructorsClicked (int constructorId)
00212 {
00213   if (myGeomGUI->getApp()->desktop()->activeWindow()->getViewManager()->getType()
00214       != OCCViewer_Viewer::Type()) {
00215     mainFrame()->RadioButton1->setChecked(true);
00216     return;
00217   }
00218 
00219   if (myConstructorId == constructorId)
00220     return;
00221 
00222   // Get radius from previous widget
00223   QString R = "5", R1 = "5", R2 = "5";
00224   if      (myConstructorId == 0) {
00225     R = Group1->SpinBox_DX->text();
00226   }
00227   else if (myConstructorId == 1) {
00228     R = Group2->SpinBox_DX->text();
00229     R1 = Group2->SpinBox_DY->text();
00230     R2 = Group2->SpinBox_DZ->text();
00231   }
00232   else {
00233     R = Group3->SpinBox_DX->text();
00234     R1 = Group3->SpinBox_DY->text();
00235     R2 = Group3->SpinBox_DZ->text();
00236   }
00237 
00238   myConstructorId = constructorId;
00239 
00240   switch (constructorId) {
00241   case 0:
00242     Group2->hide();
00243     Group3->hide();
00244     Group1->show();
00245     Group1->SpinBox_DX->setText(R);
00246     break;
00247   case 1:
00248     Group1->hide();
00249     Group3->hide();
00250     Group2->show();
00251     Group2->SpinBox_DX->setText(R);
00252     Group2->SpinBox_DY->setText(R1);
00253     Group2->SpinBox_DZ->setText(R2);
00254     break;
00255   case 2:
00256     Group1->hide();
00257     Group2->hide();
00258     Group3->show();
00259     Group3->SpinBox_DX->setText(R);
00260     Group3->SpinBox_DY->setText(R1);
00261     Group3->SpinBox_DZ->setText(R2);
00262     break;
00263   default:
00264     break;
00265   }
00266 
00267   if      (constructorId == 0) Group1->PushButton1->click();
00268   else if (constructorId == 1) Group2->PushButton1->click();
00269   else                         Group3->PushButton1->click();
00270 
00271   enableWidgets();
00272 
00273   if (myInitial) {
00274     myInitial = false;
00275     SelectionIntoArgument();
00276   }
00277   else {
00278     if (!myShape->_is_nil()) {
00279       myEditCurrentArgument->setText(GEOMBase::GetName(myShape));
00280       GEOMBase_Skeleton::LineEditReturnPressed();
00281       switch (getConstructorId()) {
00282       case 1:
00283         if (myEdges.Extent() == 0)
00284           Group2->PushButton2->click();
00285         break;
00286       case 2:
00287         if (myFaces.Extent() == 0)
00288           Group3->PushButton2->click();
00289         break;
00290       default:
00291         break;
00292       }
00293     }
00294     else
00295       myEditCurrentArgument->setText("");
00296 
00297     processPreview();
00298   }
00299 
00300   qApp->processEvents();
00301   updateGeometry();
00302   resize(minimumSizeHint());
00303 }
00304 
00305 //=================================================================================
00306 // function : ClickOnOk()
00307 // purpose  :
00308 //=================================================================================
00309 void OperationGUI_FilletDlg::ClickOnOk()
00310 {
00311   setIsApplyAndClose( true );
00312   if (ClickOnApply())
00313     ClickOnCancel();
00314 }
00315 
00316 //=================================================================================
00317 // function : ClickOnApply()
00318 // purpose  :
00319 //=================================================================================
00320 bool OperationGUI_FilletDlg::ClickOnApply()
00321 {
00322   if (!onAccept())
00323     return false;
00324 
00325   initName();
00326   // activate selection and connect selection manager
00327   ConstructorsClicked(getConstructorId());
00328   return true;
00329 }
00330 
00331 //=================================================================================
00332 // function : SelectionIntoArgument()
00333 // purpose  : Called when selection is changed or on dialog initialization or activation
00334 //=================================================================================
00335 void OperationGUI_FilletDlg::SelectionIntoArgument()
00336 {
00337   erasePreview();
00338   myEditCurrentArgument->setText("");
00339 
00340   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
00341   SALOME_ListIO aSelList;
00342   aSelMgr->selectedObjects(aSelList);
00343 
00344   // If selection of main object is activated
00345   if (myEditCurrentArgument == Group1->LineEdit1 ||
00346       myEditCurrentArgument == Group2->LineEdit1 ||
00347       myEditCurrentArgument == Group3->LineEdit1)
00348   {
00349     myShape = GEOM::GEOM_Object::_nil();
00350     if (aSelList.Extent() == 1) {
00351       GEOM::GEOM_Object_var anObj =
00352         GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
00353 
00354       if ( !anObj->_is_nil() ) {
00355         myShape = anObj;
00356         myEditCurrentArgument->setText(GEOMBase::GetName(anObj));
00357         processPreview();
00358       }
00359     }
00360 
00361     enableWidgets();
00362   }
00363   // If face or edge selection is activated
00364   else if (myEditCurrentArgument == Group2->LineEdit2 ||
00365            myEditCurrentArgument == Group3->LineEdit2)
00366   {
00367     if (myEditCurrentArgument == Group2->LineEdit2) myEdges.Clear();
00368     else myFaces.Clear();
00369     if (aSelList.Extent() == 1) {
00370       GEOM::GEOM_Object_var anObj =
00371         GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
00372 
00373       if ( !anObj->_is_nil() ) {
00374         TColStd_IndexedMapOfInteger anIndexes;
00375         aSelMgr->GetIndexes(aSelList.First(), anIndexes);
00376 
00377         if (anIndexes.Extent() > 0) {
00378           QString aName;
00379           if (anIndexes.Extent() == 1) {
00380             int anIndex = anIndexes(1);
00381 
00382             aName = QString(GEOMBase::GetName(anObj)) + QString(":%1").arg(anIndex);
00383           }
00384           else {
00385             aName = tr("GEOM_MEN_POPUP_NAME").arg(anIndexes.Extent());
00386           }
00387 
00388           myEditCurrentArgument->setText(aName);
00389 
00390           if (myConstructorId == 1)
00391             myEdges = anIndexes;
00392           else
00393             myFaces = anIndexes;
00394 
00395           processPreview();
00396         }
00397       }
00398     }
00399   }
00400 
00401   // clear selection of the faces or edges
00402   if (!(myEditCurrentArgument == Group2->LineEdit2 ||
00403         myEditCurrentArgument == Group3->LineEdit2)) {
00404     disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
00405     myGeomGUI->getApp()->selectionMgr()->clearSelected();
00406     connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
00407             this, SLOT(SelectionIntoArgument()));
00408   }
00409 
00410   switch (getConstructorId()) {
00411   case 1:
00412     if (myEditCurrentArgument == Group2->LineEdit1) {
00413       if (!myShape->_is_nil() && myEdges.Extent() == 0)
00414         Group2->PushButton2->click();
00415     }
00416     break;
00417   case 2:
00418     if (myEditCurrentArgument == Group3->LineEdit1) {
00419       if (!myShape->_is_nil() && myFaces.Extent() == 0)
00420         Group3->PushButton2->click();
00421     }
00422     break;
00423   default:
00424     break;
00425   }
00426 
00427   //rnv: To fix the bug IPAL22041 TC5.1.5: "Fillet Construcion" dialog loses current selection.
00428   // Restore selection of the main shape, if need,
00429   // because it was canceled.
00430   aSelMgr->selectedObjects(aSelList);
00431   if (aSelList.Extent() == 0 && !myShape->_is_nil()) {
00432     disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
00433     ObjectList list;
00434        list.push_back(myShape);
00435     selectObjects(list);
00436     connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
00437             this, SLOT(SelectionIntoArgument()));
00438   }
00439 }
00440 
00441 //=================================================================================
00442 // function : SetEditCurrentArgument()
00443 // purpose  :
00444 //=================================================================================
00445 void OperationGUI_FilletDlg::SetEditCurrentArgument()
00446 {
00447   QPushButton* send = (QPushButton*)sender();
00448 
00449   if (send == Group1->PushButton1) {
00450     myEditCurrentArgument = Group1->LineEdit1;
00451   }
00452   else if (send == Group2->PushButton1) {
00453     myEditCurrentArgument = Group2->LineEdit1;
00454     Group2->PushButton2->setDown(false);
00455     Group2->LineEdit2->setEnabled(false);
00456   }
00457   else if (send == Group2->PushButton2) {
00458     myEditCurrentArgument = Group2->LineEdit2;
00459     Group2->PushButton1->setDown(false);
00460     Group2->LineEdit1->setEnabled(false);
00461   }
00462   else if (send == Group3->PushButton1) {
00463     myEditCurrentArgument = Group3->LineEdit1;
00464     Group3->PushButton2->setDown(false);
00465     Group3->LineEdit2->setEnabled(false);
00466   }
00467   else if (send == Group3->PushButton2) {
00468     myEditCurrentArgument = Group3->LineEdit2;
00469     Group3->PushButton1->setDown(false);
00470     Group3->LineEdit1->setEnabled(false);
00471   }
00472 
00473   // enable line edit
00474   myEditCurrentArgument->setEnabled(true);
00475   myEditCurrentArgument->setFocus();
00476   // after setFocus(), because it will be setDown(false) when loses focus
00477   send->setDown(true);
00478 
00479   activateSelection();
00480 
00481   // seems we need it only to avoid preview disappearing, caused by selection mode change
00482   processPreview();
00483 }
00484 
00485 //=================================================================================
00486 // function : LineEditReturnPressed()
00487 // purpose  :
00488 //=================================================================================
00489 void OperationGUI_FilletDlg::LineEditReturnPressed()
00490 {
00491   QLineEdit* send = (QLineEdit*)sender();
00492 
00493   if (send == Group1->LineEdit1)
00494     myEditCurrentArgument = Group1->LineEdit1;
00495   else if (send == Group2->LineEdit1)
00496     myEditCurrentArgument = Group2->LineEdit1;
00497   else if (send == Group3->LineEdit1)
00498     myEditCurrentArgument = Group3->LineEdit1;
00499   else
00500     return;
00501 
00502   GEOMBase_Skeleton::LineEditReturnPressed();
00503 }
00504 
00505 //=================================================================================
00506 // function : ActivateThisDialog()
00507 // purpose  :
00508 //=================================================================================
00509 void OperationGUI_FilletDlg::ActivateThisDialog()
00510 {
00511   GEOMBase_Skeleton::ActivateThisDialog();
00512   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
00513            this, SLOT( SelectionIntoArgument() ) );
00514 
00515   ConstructorsClicked( getConstructorId() );
00516 }
00517 
00518 //=================================================================================
00519 // function : enterEvent()
00520 // purpose  :
00521 //=================================================================================
00522 void OperationGUI_FilletDlg::enterEvent (QEvent*)
00523 {
00524   if (!mainFrame()->GroupConstructors->isEnabled())
00525     this->ActivateThisDialog();
00526 }
00527 
00528 //=================================================================================
00529 // function : ValueChangedInSpinBox()
00530 // purpose  :
00531 //=================================================================================
00532 void OperationGUI_FilletDlg::ValueChangedInSpinBox (double)
00533 {
00534   processPreview();
00535 }
00536 
00537 //=================================================================================
00538 // function : activateSelection
00539 // purpose  : Activate selection in accordance with myEditCurrentArgument
00540 //=================================================================================
00541 void OperationGUI_FilletDlg::activateSelection()
00542 {
00543   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
00544 
00545   if (!myShape->_is_nil() && myEditCurrentArgument == Group2->LineEdit2)
00546     localSelection(myShape, TopAbs_EDGE);
00547   else if (!myShape->_is_nil() && myEditCurrentArgument == Group3->LineEdit2)
00548     localSelection(myShape, TopAbs_FACE);
00549   else {
00550     TColStd_MapOfInteger aMap;
00551     aMap.Add(GEOM_SHELL);
00552     aMap.Add(GEOM_SOLID);
00553     aMap.Add(GEOM_COMPOUND);
00554     globalSelection(aMap);
00555   }
00556 
00557   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
00558           this, SLOT(SelectionIntoArgument()));
00559 }
00560 
00561 //=================================================================================
00562 // function : enableWidgets
00563 // purpose  : Enable widgets of faces in accordance with value of main object
00564 //=================================================================================
00565 void OperationGUI_FilletDlg::enableWidgets()
00566 {
00567   int anId = getConstructorId();
00568 
00569   bool toEnable = !myShape->_is_nil();
00570 
00571   if (anId == 1) {
00572     //Group2->LineEdit2->setEnabled(toEnable);
00573     Group2->PushButton2->setEnabled(toEnable);
00574 
00575     if (!toEnable) {
00576       Group2->LineEdit2->setText("");
00577       myEdges.Clear();
00578     }
00579   }
00580   else if (anId == 2) {
00581     //Group3->LineEdit2->setEnabled(toEnable);
00582     Group3->PushButton2->setEnabled(toEnable);
00583 
00584     if (!toEnable) {
00585       Group3->LineEdit2->setText("");
00586       myFaces.Clear();
00587     }
00588   }
00589 }
00590 
00591 //=================================================================================
00592 // function : createOperation
00593 // purpose  :
00594 //=================================================================================
00595 GEOM::GEOM_IOperations_ptr OperationGUI_FilletDlg::createOperation()
00596 {
00597   return getGeomEngine()->GetILocalOperations(getStudyId());
00598 }
00599 
00600 //=================================================================================
00601 // function : isValid()
00602 // purpose  : Verify validity of input data
00603 //=================================================================================
00604 bool OperationGUI_FilletDlg::isValid (QString& msg)
00605 {
00606   bool ok = true;
00607   switch (getConstructorId())
00608   {
00609     case 0:
00610       ok = Group1->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
00611       return !myShape->_is_nil() && ok;
00612     case 1:
00613       if (Group2->RadioButton1->isChecked())
00614         ok = Group2->SpinBox_DX->isValid( msg, !IsPreview() );
00615       else
00616       {
00617         ok = Group2->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
00618         ok = Group2->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
00619       }
00620       return !myShape->_is_nil() && myEdges.Extent() > 0 && ok;
00621     case 2:
00622       if (Group3->RadioButton1->isChecked())
00623         ok = Group3->SpinBox_DX->isValid( msg, !IsPreview() );
00624       else
00625       {
00626         ok = Group3->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
00627         ok = Group3->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
00628       }
00629       return !myShape->_is_nil() && myFaces.Extent() > 0 && ok;
00630     default: return false;
00631   }
00632 }
00633 
00634 //=================================================================================
00635 // function : execute
00636 // purpose  :
00637 //=================================================================================
00638 bool OperationGUI_FilletDlg::execute (ObjectList& objects)
00639 {
00640   QStringList aParameters;
00641   GEOM::GEOM_Object_var anObj;
00642 
00643   int anId = getConstructorId();
00644 
00645   GEOM::GEOM_ILocalOperations_var anOper = GEOM::GEOM_ILocalOperations::_narrow(getOperation());
00646 
00647   if (anId == 0) {
00648     anObj = anOper->MakeFilletAll(myShape, getRadius());
00649     if (!anObj->_is_nil())
00650       aParameters << Group1->SpinBox_DX->text();
00651   }
00652   else if (anId == 1) {
00653     GEOM::ListOfLong_var aList = new GEOM::ListOfLong;
00654     aList->length(myEdges.Extent());
00655 
00656     for (int i = 1, n = myEdges.Extent(); i <= n; i++)
00657       aList[ i - 1 ] = myEdges(i);
00658 
00659     if (Group2->RadioButton1->isChecked())
00660     {
00661       anObj = anOper->MakeFilletEdges(myShape, getRadius(), aList);
00662       if (!anObj->_is_nil())
00663         aParameters << Group2->SpinBox_DX->text();
00664     }
00665     else
00666     {
00667       anObj = anOper->MakeFilletEdgesR1R2(myShape,
00668                                           Group2->SpinBox_DY->value(),
00669                                           Group2->SpinBox_DZ->value(),
00670                                           aList);
00671       if (!anObj->_is_nil())
00672       {
00673         aParameters << Group2->SpinBox_DY->text();
00674         aParameters << Group2->SpinBox_DZ->text();
00675       }
00676     }
00677   }
00678   else if (anId == 2) {
00679     GEOM::ListOfLong_var aList = new GEOM::ListOfLong;
00680     aList->length(myFaces.Extent());
00681 
00682     for (int i = 1, n = myFaces.Extent(); i <= n; i++)
00683       aList[ i - 1 ] = myFaces(i);
00684 
00685     if (Group3->RadioButton1->isChecked()) {
00686       anObj = anOper->MakeFilletFaces(myShape, getRadius(), aList);
00687       if (!anObj->_is_nil())
00688         aParameters << Group3->SpinBox_DX->text();
00689     }
00690     else {
00691       anObj = anOper->MakeFilletFacesR1R2(myShape,
00692                                           Group3->SpinBox_DY->value(),
00693                                           Group3->SpinBox_DZ->value(), aList);
00694       if (!anObj->_is_nil())
00695       {
00696         aParameters << Group3->SpinBox_DY->text();
00697         aParameters << Group3->SpinBox_DZ->text();
00698       }
00699     }
00700   }
00701 
00702   if (!anObj->_is_nil())
00703   {
00704     if (!IsPreview())
00705       anObj->SetParameters(aParameters.join(":").toLatin1().constData());
00706     objects.push_back(anObj._retn());
00707   }
00708 
00709   return true;
00710 }
00711 
00712 //=================================================================================
00713 // function : getRadius
00714 // purpose  : Get radius
00715 //=================================================================================
00716 double OperationGUI_FilletDlg::getRadius() const
00717 {
00718   int anId = getConstructorId();
00719   if      (anId == 0) return Group1->SpinBox_DX->value();
00720   else if (anId == 1) return Group2->SpinBox_DX->value();
00721   else                return Group3->SpinBox_DX->value();
00722 }
00723 
00724 //=================================================================================
00725 // function : RadiobuttonClicked
00726 // purpose  :
00727 //=================================================================================
00728 void OperationGUI_FilletDlg::RadioButtonClicked()
00729 {
00730   const QObject* s = sender();
00731 
00732   bool flag = s == Group2->RadioButton1 || s == Group3->RadioButton1;
00733 
00734   Group2->RadioButton1->blockSignals(true);
00735   Group2->RadioButton2->blockSignals(true);
00736   Group3->RadioButton1->blockSignals(true);
00737   Group3->RadioButton2->blockSignals(true);
00738 
00739   Group2->SpinBox_DX->setEnabled(flag);
00740   Group2->SpinBox_DY->setEnabled(!flag);
00741   Group2->SpinBox_DZ->setEnabled(!flag);
00742   Group2->RadioButton1->setChecked(flag);
00743   Group2->RadioButton2->setChecked(!flag);
00744   Group3->SpinBox_DX->setEnabled(flag);
00745   Group3->SpinBox_DY->setEnabled(!flag);
00746   Group3->SpinBox_DZ->setEnabled(!flag);
00747   Group3->RadioButton1->setChecked(flag);
00748   Group3->RadioButton2->setChecked(!flag);
00749 
00750   Group2->RadioButton1->blockSignals(false);
00751   Group2->RadioButton2->blockSignals(false);
00752   Group3->RadioButton1->blockSignals(false);
00753   Group3->RadioButton2->blockSignals(false);
00754 
00755   processPreview();
00756 }