Back to index

salome-geom  6.5.0
GenerationGUI_PrismDlg.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   : GenerationGUI_PrismDlg.cxx
00025 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
00026 
00027 #include "GenerationGUI_PrismDlg.h"
00028 
00029 #include <DlgRef.h>
00030 #include <GeometryGUI.h>
00031 #include <GEOMBase.h>
00032 
00033 #include <SUIT_Session.h>
00034 #include <SUIT_ResourceMgr.h>
00035 #include <SalomeApp_Application.h>
00036 #include <LightApp_SelectionMgr.h>
00037 
00038 // OCCT Includes
00039 #include <TopoDS_Shape.hxx>
00040 #include <TopoDS_Edge.hxx>
00041 #include <TopoDS.hxx>
00042 #include <TopExp.hxx>
00043 #include <TColStd_IndexedMapOfInteger.hxx>
00044 #include <TopTools_IndexedMapOfShape.hxx>
00045 #include <Precision.hxx>
00046 
00047 #include <GEOMImpl_Types.hxx>
00048 
00049 //=================================================================================
00050 // class    : GenerationGUI_PrismDlg()
00051 // purpose  : Constructs a GenerationGUI_PrismDlg which is a child of 'parent', with the
00052 //            name 'name' and widget flags set to 'f'.
00053 //            The dialog will by default be modeless, unless you set 'modal' to
00054 //            TRUE to construct a modal dialog.
00055 //=================================================================================
00056 GenerationGUI_PrismDlg::GenerationGUI_PrismDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
00057                                                 bool modal, Qt::WindowFlags fl)
00058   : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl)
00059 {
00060   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
00061   QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_PRISM")));
00062   QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
00063   QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_PRISM_2P")));
00064   QPixmap image3 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_PRISM_DXDYDZ")));
00065 
00066   setWindowTitle(tr("GEOM_EXTRUSION_TITLE"));
00067 
00068   /***************************************************************/
00069   mainFrame()->GroupConstructors->setTitle(tr("GEOM_EXTRUSION"));
00070   mainFrame()->RadioButton1->setIcon(image0);
00071   mainFrame()->RadioButton2->setIcon(image2);
00072   mainFrame()->RadioButton3->setIcon(image3);
00073 
00074   mainFrame()->RadioButton1->setChecked(true);
00075 
00076   GroupVecH = new DlgRef_2Sel1Spin3Check1Spin(centralWidget());
00077   GroupVecH->GroupBox1->setTitle(tr("GEOM_EXTRUSION_BSV"));
00078   GroupVecH->TextLabel1->setText(tr("GEOM_BASE"));
00079   GroupVecH->TextLabel2->setText(tr("GEOM_VECTOR"));
00080   GroupVecH->TextLabel3->setText(tr("GEOM_HEIGHT"));
00081   GroupVecH->TextLabel4->setText(tr("GEOM_SCALE_FACTOR"));
00082   GroupVecH->PushButton1->setIcon(image1);
00083   GroupVecH->PushButton2->setIcon(image1);
00084   GroupVecH->LineEdit1->setReadOnly(true);
00085   GroupVecH->LineEdit2->setReadOnly(true);
00086   GroupVecH->CheckBox1->setText(tr("GEOM_BOTHWAY"));
00087   GroupVecH->CheckBox2->setText(tr("GEOM_REVERSE"));
00088   GroupVecH->CheckBox3->setText(tr("GEOM_SCALE_PRISM"));
00089 
00090   Group2Points = new DlgRef_3Sel2Check3Spin(centralWidget());
00091   Group2Points->GroupBox1->setTitle(tr("GEOM_EXTRUSION_BSV_2P"));
00092   Group2Points->TextLabel1->setText(tr("GEOM_BASE"));
00093   Group2Points->TextLabel2->setText(tr("GEOM_POINT_I").arg(1));
00094   Group2Points->TextLabel3->setText(tr("GEOM_POINT_I").arg(2));
00095   Group2Points->TextLabel4->setText(tr("GEOM_SCALE_FACTOR"));
00096   Group2Points->PushButton1->setIcon(image1);
00097   Group2Points->PushButton2->setIcon(image1);
00098   Group2Points->PushButton3->setIcon(image1);
00099   Group2Points->CheckBox1->setText(tr("GEOM_BOTHWAY"));
00100   Group2Points->CheckBox2->setText(tr("GEOM_SCALE_PRISM"));
00101 
00102   GroupDXDYDZ = new DlgRef_1Sel3Spin2Check1Spin(centralWidget());
00103   GroupDXDYDZ->GroupBox1->setTitle(tr("GEOM_EXTRUSION_DXDYDZ"));
00104   GroupDXDYDZ->TextLabel1->setText(tr("GEOM_BASE"));
00105   GroupDXDYDZ->PushButton1->setIcon(image1);
00106   GroupDXDYDZ->TextLabel2->setText(tr("GEOM_DX"));
00107   GroupDXDYDZ->TextLabel3->setText(tr("GEOM_DY"));
00108   GroupDXDYDZ->TextLabel4->setText(tr("GEOM_DZ"));
00109   GroupDXDYDZ->TextLabel5->setText(tr("GEOM_SCALE_FACTOR"));
00110   GroupDXDYDZ->CheckBox1->setText(tr("GEOM_BOTHWAY"));
00111   GroupDXDYDZ->CheckBox2->setText(tr("GEOM_SCALE_PRISM"));
00112 
00113   QVBoxLayout* layout = new QVBoxLayout(centralWidget());
00114   layout->setMargin(0); layout->setSpacing(6);
00115   layout->addWidget(GroupVecH);
00116   layout->addWidget(Group2Points);
00117   layout->addWidget(GroupDXDYDZ);
00118   /***************************************************************/
00119 
00120   setHelpFileName("create_extrusion_page.html");
00121 
00122   Init();
00123 }
00124 
00125 //=================================================================================
00126 // function : ~GenerationGUI_PrismDlg()
00127 // purpose  : Destroys the object and frees any allocated resources
00128 //=================================================================================
00129 GenerationGUI_PrismDlg::~GenerationGUI_PrismDlg()
00130 {
00131   // no need to delete child widgets, Qt does it all for us
00132 }
00133 
00134 //=================================================================================
00135 // function : Init()
00136 // purpose  :
00137 //=================================================================================
00138 void GenerationGUI_PrismDlg::Init()
00139 {
00140   // Get setting of step value from file configuration
00141   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
00142   double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
00143 
00144   // min, max, step and decimals for spin boxes & initial values
00145   double aScaleFactor = 2.0;
00146   double aScaleStep = 0.5;
00147   double aScaleMin = Precision::Confusion() * 10.0;
00148 
00149   initSpinBox(GroupVecH->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
00150   GroupVecH->SpinBox_DX->setValue(100.0);
00151 
00152   initSpinBox(GroupDXDYDZ->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
00153   initSpinBox(GroupDXDYDZ->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
00154   initSpinBox(GroupDXDYDZ->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
00155   GroupDXDYDZ->SpinBox_DX->setValue(0.0);
00156   GroupDXDYDZ->SpinBox_DY->setValue(0.0);
00157   GroupDXDYDZ->SpinBox_DZ->setValue(0.0);
00158 
00159   initSpinBox(GroupVecH->SpinBox_DY, aScaleMin, COORD_MAX, aScaleStep, "parametric_precision" );
00160   initSpinBox(Group2Points->SpinBox1, aScaleMin, COORD_MAX, aScaleStep, "parametric_precision" );
00161   initSpinBox(GroupDXDYDZ->SpinBox_SC, aScaleMin, COORD_MAX, aScaleStep, "parametric_precision" );
00162 
00163   GroupVecH->SpinBox_DY->setValue(aScaleFactor);
00164   Group2Points->SpinBox1->setValue(aScaleFactor);
00165   GroupDXDYDZ->SpinBox_SC->setValue(aScaleFactor);
00166 
00167   // hide not used controls
00168   Group2Points->TextLabel5->hide();
00169   Group2Points->TextLabel6->hide();
00170 
00171   Group2Points->SpinBox2->hide();
00172   Group2Points->SpinBox3->hide();
00173 
00174   // init variables
00175   myEditCurrentArgument = GroupVecH->LineEdit1;
00176   GroupVecH->LineEdit1->setReadOnly(true);
00177   GroupVecH->LineEdit2->setReadOnly(true);
00178 
00179   Group2Points->LineEdit1->setReadOnly(true);
00180   Group2Points->LineEdit2->setReadOnly(true);
00181   Group2Points->LineEdit3->setReadOnly(true);
00182 
00183   GroupDXDYDZ->LineEdit1->setReadOnly(true);
00184 
00185   GroupVecH->LineEdit1->setText("");
00186   GroupVecH->LineEdit2->setText("");
00187 
00188   Group2Points->LineEdit1->setText("");
00189   Group2Points->LineEdit2->setText("");
00190   Group2Points->LineEdit3->setText("");
00191 
00192   GroupDXDYDZ->LineEdit1->setText("");
00193 
00194   myBaseObjects.clear();
00195   myPoint1.nullify();
00196   myPoint2.nullify();
00197   myVec.nullify();
00198 
00199   showOnlyPreviewControl();
00200     
00201   // signals and slots connections
00202   connect(buttonOk(),    SIGNAL(clicked()), this, SLOT(ClickOnOk()));
00203   connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
00204 
00205   connect(this,          SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
00206 
00207   connect(GroupVecH->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
00208   connect(GroupVecH->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
00209 
00210   connect(GroupVecH->SpinBox_DX, SIGNAL(valueChanged(double)),    this, SLOT(ValueChangedInSpinBox()));
00211   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
00212 
00213   connect(GroupVecH->CheckBox1,  SIGNAL(toggled(bool)), this, SLOT(onBothway()));
00214   connect(GroupVecH->CheckBox2,  SIGNAL(toggled(bool)), this, SLOT(onReverse()));
00215   connect(GroupVecH->CheckBox3,  SIGNAL(toggled(bool)), this, SLOT(onScalePrism()));
00216   connect(GroupVecH->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
00217 
00218   connect(Group2Points->PushButton1, SIGNAL(clicked()),       this, SLOT(SetEditCurrentArgument()));
00219   connect(Group2Points->PushButton2, SIGNAL(clicked()),       this, SLOT(SetEditCurrentArgument()));
00220   connect(Group2Points->PushButton3, SIGNAL(clicked()),       this, SLOT(SetEditCurrentArgument()));
00221   connect(Group2Points->CheckBox1,   SIGNAL(toggled(bool)),   this, SLOT(onBothway()));
00222   connect(Group2Points->CheckBox2,   SIGNAL(toggled(bool)),   this, SLOT(onScalePrism()));
00223   connect(Group2Points->SpinBox1,    SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
00224 
00225   connect(GroupDXDYDZ->PushButton1, SIGNAL(clicked()),            this, SLOT(SetEditCurrentArgument()));
00226   connect(GroupDXDYDZ->SpinBox_DX,  SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
00227   connect(GroupDXDYDZ->SpinBox_DY,  SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
00228   connect(GroupDXDYDZ->SpinBox_DZ,  SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
00229   connect(GroupDXDYDZ->SpinBox_SC,  SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
00230   connect(GroupDXDYDZ->CheckBox1,   SIGNAL(toggled(bool)),        this, SLOT(onBothway()));
00231   connect(GroupDXDYDZ->CheckBox2,   SIGNAL(toggled(bool)),        this, SLOT(onScalePrism()));
00232 
00233   initName(tr("GEOM_EXTRUSION"));
00234 
00235   ConstructorsClicked(0);
00236   onBothway();
00237 }
00238 
00239 //=================================================================================
00240 // function : SetDoubleSpinBoxStep()
00241 // purpose  : Double spin box management
00242 //=================================================================================
00243 void GenerationGUI_PrismDlg::SetDoubleSpinBoxStep (double step)
00244 {
00245   GroupVecH->SpinBox_DX->setSingleStep(step);
00246   GroupDXDYDZ->SpinBox_DX->setSingleStep(step);
00247   GroupDXDYDZ->SpinBox_DY->setSingleStep(step);
00248   GroupDXDYDZ->SpinBox_DZ->setSingleStep(step);
00249 }
00250 
00251 //=================================================================================
00252 // function : ConstructorsClicked()
00253 // purpose  : Radio button management
00254 //=================================================================================
00255 void GenerationGUI_PrismDlg::ConstructorsClicked (int constructorId)
00256 {
00257   switch (constructorId) {
00258   case 0:
00259     Group2Points->hide();
00260     GroupDXDYDZ->hide();
00261     GroupVecH->show();
00262 
00263     GroupVecH->LineEdit2->setText("");
00264     myVec.nullify();
00265 
00266     GroupVecH->PushButton1->click();
00267     break;
00268   case 1:
00269     GroupVecH->hide();
00270     Group2Points->show();
00271     GroupDXDYDZ->hide();
00272 
00273     Group2Points->LineEdit2->setText("");
00274     Group2Points->LineEdit3->setText("");
00275     myPoint1.nullify();
00276     myPoint2.nullify();
00277 
00278     Group2Points->PushButton1->click();
00279     break;
00280   case 2:
00281     GroupVecH->hide();
00282     Group2Points->hide();
00283     GroupDXDYDZ->show();
00284 
00285     GroupDXDYDZ->PushButton1->click();
00286     break;
00287   default:
00288     break;
00289   }
00290 
00291   qApp->processEvents();
00292   updateGeometry();
00293   resize(minimumSizeHint());
00294 
00295   SelectionIntoArgument();
00296   processPreview();
00297 }
00298 
00299 //=================================================================================
00300 // function : ClickOnOk()
00301 // purpose  :
00302 //=================================================================================
00303 void GenerationGUI_PrismDlg::ClickOnOk()
00304 {
00305   setIsApplyAndClose( true );
00306   if (ClickOnApply())
00307     ClickOnCancel();
00308 }
00309 
00310 //=================================================================================
00311 // function : ClickOnApply()
00312 // purpose  :
00313 //=================================================================================
00314 bool GenerationGUI_PrismDlg::ClickOnApply()
00315 {
00316   if (!onAccept())
00317     return false;
00318 
00319   initName();
00320   // activate selection and connect selection manager
00321   ConstructorsClicked(getConstructorId());
00322   return true;
00323 }
00324 
00325 //=================================================================================
00326 // function : SelectionIntoArgument()
00327 // purpose  : Called when selection is changed or on dialog initialization or activation
00328 //=================================================================================
00329 void GenerationGUI_PrismDlg::SelectionIntoArgument()
00330 {
00331   erasePreview();
00332   myEditCurrentArgument->setText("");
00333 
00334   if ( myEditCurrentArgument == GroupVecH->LineEdit1  ||
00335        myEditCurrentArgument == Group2Points->LineEdit1 ||
00336        myEditCurrentArgument == GroupDXDYDZ->LineEdit1 ) {
00337     myBaseObjects.clear();
00338     QList<GEOM::GeomObjPtr> objects = getSelected( TopAbs_SHAPE, -1 );
00339     for ( int i = 0; i < objects.count(); i++ ) {
00340       GEOM::shape_type stype = objects[i]->GetMaxShapeType();
00341       if ( stype < GEOM::SHELL || stype > GEOM::VERTEX )
00342         continue;
00343       myBaseObjects << objects[i];
00344     }
00345     if ( !myBaseObjects.isEmpty() ) {
00346       QString aName = myBaseObjects.count() > 1 ? QString( "%1_objects").arg( myBaseObjects.count() ) : GEOMBase::GetName( myBaseObjects[0].get() );
00347       GroupVecH->LineEdit1->setText( aName );
00348       Group2Points->LineEdit1->setText( aName );
00349       GroupDXDYDZ->LineEdit1->setText( aName );
00350     }
00351     else {
00352       GroupVecH->LineEdit1->setText( "" );
00353       Group2Points->LineEdit1->setText( "" );
00354       GroupDXDYDZ->LineEdit1->setText( "" );
00355     }
00356   }
00357   else if ( myEditCurrentArgument == GroupVecH->LineEdit2 ) {
00358     myVec = getSelected( TopAbs_EDGE );
00359     if ( myVec ) {
00360       QString aName = GEOMBase::GetName( myVec.get() );
00361       myEditCurrentArgument->setText( aName );
00362       if ( myBaseObjects.isEmpty() )
00363         GroupVecH->PushButton1->click();
00364     }
00365   }
00366   if ( myEditCurrentArgument == Group2Points->LineEdit2 ) {
00367     myPoint1 = getSelected( TopAbs_VERTEX );
00368     if ( myPoint1 ) {
00369       QString aName = GEOMBase::GetName( myPoint1.get() );
00370       myEditCurrentArgument->setText( aName );
00371       if ( !myPoint2 )
00372         Group2Points->PushButton3->click();
00373       else if ( myBaseObjects.isEmpty() )
00374         Group2Points->PushButton1->click();
00375     }
00376   }
00377   if ( myEditCurrentArgument == Group2Points->LineEdit3 ) {
00378     myPoint2 = getSelected( TopAbs_VERTEX );
00379     if ( myPoint2 ) {
00380       QString aName = GEOMBase::GetName( myPoint2.get() );
00381       myEditCurrentArgument->setText( aName );
00382       if ( myBaseObjects.isEmpty() )
00383         Group2Points->PushButton1->click();
00384       else if ( !myPoint1 )
00385         Group2Points->PushButton2->click();
00386     }
00387   }
00388 
00389   processPreview();
00390 }
00391 
00392 //=================================================================================
00393 // function : SetEditCurrentArgument()
00394 // purpose  :
00395 //=================================================================================
00396 void GenerationGUI_PrismDlg::SetEditCurrentArgument()
00397 {
00398   QPushButton* send = (QPushButton*)sender();
00399 
00400   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
00401   globalSelection(GEOM_ALLSHAPES);
00402   if (send == GroupVecH->PushButton1) {
00403     myEditCurrentArgument = GroupVecH->LineEdit1;
00404     GroupVecH->PushButton2->setDown(false);
00405     GroupVecH->LineEdit2->setEnabled(false);
00406   }
00407   else if (send == GroupVecH->PushButton2) {
00408     myEditCurrentArgument = GroupVecH->LineEdit2;
00409     GroupVecH->PushButton1->setDown(false);
00410     GroupVecH->LineEdit1->setEnabled(false);
00411     localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
00412   }
00413   else if (send == Group2Points->PushButton1) {
00414     myEditCurrentArgument = Group2Points->LineEdit1;
00415     Group2Points->PushButton2->setDown(false);
00416     Group2Points->PushButton3->setDown(false);
00417     Group2Points->LineEdit2->setEnabled(false);
00418     Group2Points->LineEdit3->setEnabled(false);
00419   }
00420   else if (send == Group2Points->PushButton2) {
00421     myEditCurrentArgument = Group2Points->LineEdit2;
00422     Group2Points->PushButton1->setDown(false);
00423     Group2Points->PushButton3->setDown(false);
00424     Group2Points->LineEdit1->setEnabled(false);
00425     Group2Points->LineEdit3->setEnabled(false);
00426     localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
00427   }
00428   else if (send == Group2Points->PushButton3) {
00429     myEditCurrentArgument = Group2Points->LineEdit3;
00430     Group2Points->PushButton1->setDown(false);
00431     Group2Points->PushButton2->setDown(false);
00432     Group2Points->LineEdit1->setEnabled(false);
00433     Group2Points->LineEdit2->setEnabled(false);
00434     localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
00435   }
00436   else   if (send == GroupDXDYDZ->PushButton1) {
00437     myEditCurrentArgument = GroupDXDYDZ->LineEdit1;
00438   }
00439   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
00440           this, SLOT(SelectionIntoArgument()));
00441 
00442   // enable line edit
00443   myEditCurrentArgument->setEnabled(true);
00444   myEditCurrentArgument->setFocus();
00445   // after setFocus(), because it will be setDown(false) when loses focus
00446   send->setDown(true);
00447 
00448   // seems we need it only to avoid preview disappearing, caused by selection mode change
00449   processPreview();
00450 }
00451 
00452 //=================================================================================
00453 // function : ActivateThisDialog()
00454 // purpose  :
00455 //=================================================================================
00456 void GenerationGUI_PrismDlg::ActivateThisDialog()
00457 {
00458   GEOMBase_Skeleton::ActivateThisDialog();
00459 
00460   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
00461            this, SLOT( SelectionIntoArgument() ) );
00462 
00463   ConstructorsClicked( getConstructorId() );
00464 }
00465 
00466 //=================================================================================
00467 // function : enterEvent()
00468 // purpose  : when mouse enter onto the QWidget
00469 //=================================================================================
00470 void GenerationGUI_PrismDlg::enterEvent (QEvent*)
00471 {
00472   if (!mainFrame()->GroupConstructors->isEnabled())
00473     ActivateThisDialog();
00474 }
00475 
00476 //=================================================================================
00477 // function : ValueChangedInSpinBox()
00478 // purpose  :
00479 //=================================================================================
00480 void GenerationGUI_PrismDlg::ValueChangedInSpinBox()
00481 {
00482   processPreview();
00483 }
00484 
00485 //=================================================================================
00486 // function : createOperation
00487 // purpose  :
00488 //=================================================================================
00489 GEOM::GEOM_IOperations_ptr GenerationGUI_PrismDlg::createOperation()
00490 {
00491   return getGeomEngine()->GetI3DPrimOperations(getStudyId());
00492 }
00493 
00494 //=================================================================================
00495 // function : isValid
00496 // purpose  :
00497 //=================================================================================
00498 bool GenerationGUI_PrismDlg::isValid (QString& msg)
00499 {
00500   bool ok = false;
00501   switch ( getConstructorId() ) {
00502   case 0:
00503     ok = GroupVecH->SpinBox_DX->isValid( msg, !IsPreview() ) &&
00504          !myBaseObjects.isEmpty() && myVec;
00505     break;
00506   case 1:
00507     ok = !myBaseObjects.isEmpty() && myPoint1 && myPoint2;
00508     break;
00509   case 2:
00510     ok = GroupDXDYDZ->SpinBox_DX->isValid( msg, !IsPreview() ) &&
00511          GroupDXDYDZ->SpinBox_DY->isValid( msg, !IsPreview() ) &&
00512          GroupDXDYDZ->SpinBox_DZ->isValid( msg, !IsPreview() ) &&
00513          !myBaseObjects.isEmpty();
00514     break;
00515   default:
00516     break;
00517   }
00518 
00519   return ok;
00520 }
00521 
00522 //=================================================================================
00523 // function : onReverse()
00524 // purpose  :
00525 //=================================================================================
00526 void GenerationGUI_PrismDlg::onReverse()
00527 {
00528   double anOldValue = GroupVecH->SpinBox_DX->value();
00529   GroupVecH->SpinBox_DX->setValue(-anOldValue);
00530 }
00531 
00532 //=================================================================================
00533 // function : onBothway()
00534 // purpose  :
00535 //=================================================================================
00536 void GenerationGUI_PrismDlg::onBothway()
00537 {
00538   GroupVecH->CheckBox2->setEnabled(!GroupVecH->CheckBox1->isChecked()); // is reversed
00539   GroupVecH->CheckBox3->setEnabled(!GroupVecH->CheckBox1->isChecked()); // is scaled
00540   GroupVecH->TextLabel4->setEnabled(!GroupVecH->CheckBox1->isChecked() &&
00541                                     GroupVecH->CheckBox3->isChecked()); // scale factor
00542   GroupVecH->SpinBox_DY->setEnabled(!GroupVecH->CheckBox1->isChecked() &&
00543                                     GroupVecH->CheckBox3->isChecked()); // scale factor
00544 
00545   Group2Points->CheckBox2->setEnabled(!Group2Points->CheckBox1->isChecked()); // is scaled
00546   Group2Points->TextLabel4->setEnabled(!Group2Points->CheckBox1->isChecked() &&
00547                                        Group2Points->CheckBox2->isChecked()); // scale factor
00548   Group2Points->SpinBox1->setEnabled(!Group2Points->CheckBox1->isChecked() &&
00549                                      Group2Points->CheckBox2->isChecked()); // scale factor
00550 
00551   GroupDXDYDZ->CheckBox2->setEnabled(!GroupDXDYDZ->CheckBox1->isChecked()); // is scaled
00552   GroupDXDYDZ->TextLabel5->setEnabled(!GroupDXDYDZ->CheckBox1->isChecked() &&
00553                                       GroupDXDYDZ->CheckBox2->isChecked()); // scale factor
00554   GroupDXDYDZ->SpinBox_SC->setEnabled(!GroupDXDYDZ->CheckBox1->isChecked() &&
00555                                       GroupDXDYDZ->CheckBox2->isChecked()); // scale factor
00556 
00557   processPreview();
00558 }
00559 
00560 //=================================================================================
00561 // function : onScalePrism()
00562 // purpose  :
00563 //=================================================================================
00564 void GenerationGUI_PrismDlg::onScalePrism()
00565 {
00566   GroupVecH->TextLabel4->setEnabled(GroupVecH->CheckBox3->isChecked());
00567   GroupVecH->SpinBox_DY->setEnabled(GroupVecH->CheckBox3->isChecked());
00568 
00569   Group2Points->TextLabel4->setEnabled(Group2Points->CheckBox2->isChecked());
00570   Group2Points->SpinBox1->setEnabled(Group2Points->CheckBox2->isChecked());
00571 
00572   GroupDXDYDZ->TextLabel5->setEnabled(GroupDXDYDZ->CheckBox2->isChecked());
00573   GroupDXDYDZ->SpinBox_SC->setEnabled(GroupDXDYDZ->CheckBox2->isChecked());
00574 
00575   processPreview();
00576 }
00577 
00578 //=================================================================================
00579 // function : execute
00580 // purpose  :
00581 //=================================================================================
00582 bool GenerationGUI_PrismDlg::execute (ObjectList& objects)
00583 {
00584   QStringList aParameters;
00585   GEOM::GEOM_Object_var anObj;
00586 
00587   GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
00588 
00589   for (int i = 0; i < myBaseObjects.count(); i++) {
00590     switch (getConstructorId()) {
00591     case 0:
00592       if (GroupVecH->CheckBox1->isChecked())
00593         anObj = anOper->MakePrismVecH2Ways(myBaseObjects[i].get(), myVec.get(),
00594                                            GroupVecH->SpinBox_DX->value());
00595       else {
00596         if (GroupVecH->CheckBox3->isChecked())
00597           anObj = anOper->MakePrismVecHWithScaling(myBaseObjects[i].get(), myVec.get(),
00598                                                    GroupVecH->SpinBox_DX->value(),
00599                                                    GroupVecH->SpinBox_DY->value());
00600         else
00601           anObj = anOper->MakePrismVecH(myBaseObjects[i].get(), myVec.get(),
00602                                         GroupVecH->SpinBox_DX->value());
00603       }
00604 
00605       if (!anObj->_is_nil() && !IsPreview()) {
00606         aParameters << GroupVecH->SpinBox_DX->text();
00607         anObj->SetParameters(aParameters.join(":").toLatin1().constData());
00608       }
00609       break;
00610     case 1:
00611       if (Group2Points->CheckBox1->isChecked())
00612         anObj = anOper->MakePrismTwoPnt2Ways(myBaseObjects[i].get(), myPoint1.get(), myPoint2.get());
00613       else {
00614         if (Group2Points->CheckBox2->isChecked())
00615           anObj = anOper->MakePrismTwoPntWithScaling(myBaseObjects[i].get(), myPoint1.get(),
00616                                                      myPoint2.get(), Group2Points->SpinBox1->value());
00617         else
00618           anObj = anOper->MakePrismTwoPnt(myBaseObjects[i].get(), myPoint1.get(), myPoint2.get());
00619       }
00620       break;
00621     case 2:
00622       double dx = GroupDXDYDZ->SpinBox_DX->value();
00623       double dy = GroupDXDYDZ->SpinBox_DY->value();
00624       double dz = GroupDXDYDZ->SpinBox_DZ->value();
00625 
00626       if (GroupDXDYDZ->CheckBox1->isChecked())
00627         anObj = anOper->MakePrismDXDYDZ2Ways(myBaseObjects[i].get(), dx, dy, dz);
00628       else {
00629         if (GroupDXDYDZ->CheckBox2->isChecked())
00630           anObj = anOper->MakePrismDXDYDZWithScaling(myBaseObjects[i].get(), dx, dy, dz,
00631                                                      GroupDXDYDZ->SpinBox_SC->value());
00632         else
00633           anObj = anOper->MakePrismDXDYDZ(myBaseObjects[i].get(), dx, dy, dz);
00634       }
00635 
00636       if (!anObj->_is_nil() && !IsPreview()) {
00637         aParameters << GroupDXDYDZ->SpinBox_DX->text();
00638         aParameters << GroupDXDYDZ->SpinBox_DY->text();
00639         aParameters << GroupDXDYDZ->SpinBox_DZ->text();
00640         anObj->SetParameters(aParameters.join(":").toLatin1().constData());
00641       }
00642       break;
00643     }
00644 
00645     if (!anObj->_is_nil())
00646       objects.push_back(anObj._retn());
00647   }
00648 
00649   return true;
00650 }
00651 
00652 //=================================================================================
00653 // function : addSubshapeToStudy
00654 // purpose  : virtual method to add new SubObjects if local selection
00655 //=================================================================================
00656 void GenerationGUI_PrismDlg::addSubshapesToStudy()
00657 {
00658   switch (getConstructorId()) {
00659   case 0:
00660     GEOMBase::PublishSubObject( myVec.get() );
00661     break;
00662   case 1:
00663     GEOMBase::PublishSubObject( myPoint1.get() );
00664     GEOMBase::PublishSubObject( myPoint2.get() );
00665     break;
00666   default:
00667     break;
00668   }
00669 }
00670 
00671 //=================================================================================
00672 // function : extractPrefix
00673 // purpose  : redefined from GEOMBase_Helper class
00674 //=================================================================================
00675 bool GenerationGUI_PrismDlg::extractPrefix() const
00676 {
00677   return myBaseObjects.count() > 1;
00678 }