From: jfa Date: Tue, 19 Jun 2007 11:28:38 +0000 (+0000) Subject: NPAL16160,NPAL16123: Unify dialogs behaviour, enlarge precision of double numbers... X-Git-Tag: V3_2_7~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=efc0d6c141145d71258cfd871417b3e3f0c7216c;p=modules%2Fgeom.git NPAL16160,NPAL16123: Unify dialogs behaviour, enlarge precision of double numbers displaying. --- diff --git a/src/BasicGUI/BasicGUI_ArcDlg.cxx b/src/BasicGUI/BasicGUI_ArcDlg.cxx index fec43e01e..86ea68832 100644 --- a/src/BasicGUI/BasicGUI_ArcDlg.cxx +++ b/src/BasicGUI/BasicGUI_ArcDlg.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -35,17 +35,10 @@ #include -#include -#include -#include -#include - #include "GEOMImpl_Types.hxx" #include "utilities.h" -using namespace std; - //================================================================================= // class : BasicGUI_ArcDlg() // purpose : Constructs a BasicGUI_ArcDlg which is a child of 'parent', with the @@ -58,9 +51,10 @@ BasicGUI_ArcDlg::BasicGUI_ArcDlg(GeometryGUI* theGeometryGUI, QWidget* parent, : GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_ARC"))); - QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_ARC_CENTER"))); - QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT"))); + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + QPixmap image0(aResMgr->loadPixmap("GEOM",tr("ICON_DLG_ARC"))); + QPixmap image1(aResMgr->loadPixmap("GEOM",tr("ICON_DLG_ARC_CENTER"))); + QPixmap image2(aResMgr->loadPixmap("GEOM",tr("ICON_SELECT"))); setCaption(tr("GEOM_ARC_TITLE")); @@ -98,11 +92,12 @@ BasicGUI_ArcDlg::BasicGUI_ArcDlg(GeometryGUI* theGeometryGUI, QWidget* parent, Group3Pnts2->PushButton1->setPixmap(image2); Group3Pnts2->PushButton2->setPixmap(image2); Group3Pnts2->PushButton3->setPixmap(image2); - + Group3Pnts2->radioButton4->setText(tr("GEOM_REVERSE")); Layout1->addWidget( Group3Pnts, 2, 0 ); Layout1->addWidget( Group3Pnts2, 2, 0 ); + /***************************************************************/ setHelpFileName("arc.htm"); @@ -126,13 +121,7 @@ BasicGUI_ArcDlg::~BasicGUI_ArcDlg() void BasicGUI_ArcDlg::Init() { /* init variables */ - // myGeomGUI->SetState( 0 ); - globalSelection( GEOM_POINT ); - - myConstructorId = -1; myEditCurrentArgument = Group3Pnts->LineEdit1; - myEditCurrentArgument->setFocus(); - myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); Group3Pnts2->radioButton4->setChecked(FALSE); @@ -140,9 +129,9 @@ void BasicGUI_ArcDlg::Init() connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); - + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); - + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); @@ -153,7 +142,7 @@ void BasicGUI_ArcDlg::Init() connect(Group3Pnts->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(Group3Pnts->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(Group3Pnts->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - + connect(Group3Pnts2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(Group3Pnts2->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(Group3Pnts2->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); @@ -161,36 +150,80 @@ void BasicGUI_ArcDlg::Init() connect(Group3Pnts2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(Group3Pnts2->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(Group3Pnts2->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - + connect(Group3Pnts2->radioButton4, SIGNAL(stateChanged(int)), this, SLOT(ReverseSense(int))); connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - initName( tr( "GEOM_ARC" )); - - + initName( tr( "GEOM_ARC" )); ConstructorsClicked( 0 ); } //================================================================================= -// function : ClickOnOk() -// purpose : +// function : ConstructorsClicked() +// purpose : Radio button management //================================================================================= -void BasicGUI_ArcDlg::ClickOnOk() +void BasicGUI_ArcDlg::ConstructorsClicked (int constructorId) { - if ( ClickOnApply() ) - ClickOnCancel(); + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + + switch (constructorId) + { + case 0: + { + globalSelection( GEOM_POINT ); + + Group3Pnts->show(); + resize(0, 0); + Group3Pnts2->hide(); + + Group3Pnts->LineEdit1->setText(Group3Pnts2->LineEdit1->text()); + Group3Pnts->LineEdit2->setText(Group3Pnts2->LineEdit2->text()); + Group3Pnts->LineEdit3->setText(Group3Pnts2->LineEdit3->text()); + + myEditCurrentArgument = Group3Pnts->LineEdit1; + + break; + } + case 1: + { + globalSelection( GEOM_POINT ); + + Group3Pnts->hide(); + resize(0, 0); + Group3Pnts2->show(); + + Group3Pnts2->LineEdit1->setText(Group3Pnts->LineEdit1->text()); + Group3Pnts2->LineEdit2->setText(Group3Pnts->LineEdit2->text()); + Group3Pnts2->LineEdit3->setText(Group3Pnts->LineEdit3->text()); + + myEditCurrentArgument = Group3Pnts2->LineEdit1; + + break; + } + } + + myEditCurrentArgument->setFocus(); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + + if (CORBA::is_nil(myPoint1)) + SelectionIntoArgument(); + + displayPreview(); } + //================================================================================= -// function : ClickOnCancel() +// function : ClickOnOk() // purpose : //================================================================================= -void BasicGUI_ArcDlg::ClickOnCancel() +void BasicGUI_ArcDlg::ClickOnOk() { - GEOMBase_Skeleton::ClickOnCancel(); + if ( ClickOnApply() ) + ClickOnCancel(); } //================================================================================= @@ -203,19 +236,6 @@ bool BasicGUI_ArcDlg::ClickOnApply() return false; initName(); - - // reset - myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); - Group3Pnts->LineEdit1->setText( "" ); - Group3Pnts->LineEdit2->setText( "" ); - Group3Pnts->LineEdit3->setText( "" ); - Group3Pnts2->LineEdit1->setText( "" ); - Group3Pnts2->LineEdit2->setText( "" ); - Group3Pnts2->LineEdit3->setText( "" ); - if (getConstructorId() == 0) myEditCurrentArgument = Group3Pnts->LineEdit1; - if (getConstructorId() == 1) myEditCurrentArgument = Group3Pnts2->LineEdit1; - - ConstructorsClicked( getConstructorId() ); return true; } @@ -228,21 +248,23 @@ void BasicGUI_ArcDlg::SelectionIntoArgument() { if ((getConstructorId() != 0) && (getConstructorId() != 1)) return; - + myEditCurrentArgument->setText(""); - if ( IObjectCount() != 1 ){ + + if ( IObjectCount() != 1 ) + { switch (getConstructorId()) { - case 0: - { - if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); - else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil(); - return; - break; + case 0: + { + if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil(); + return; + break; } - case 1: - { + case 1: + { if ( myEditCurrentArgument == Group3Pnts2->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == Group3Pnts2->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == Group3Pnts2->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil(); @@ -250,7 +272,8 @@ void BasicGUI_ArcDlg::SelectionIntoArgument() break; } } - } + } + // nbSel == 1 Standard_Boolean aRes = Standard_False; GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes ); @@ -281,6 +304,22 @@ void BasicGUI_ArcDlg::SelectionIntoArgument() } +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BasicGUI_ArcDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if (send == Group3Pnts->LineEdit1 || send == Group3Pnts->LineEdit2 || send == Group3Pnts->LineEdit3 || + send == Group3Pnts2->LineEdit1 || send == Group3Pnts2->LineEdit2 || send == Group3Pnts2->LineEdit3) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } +} + + //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -310,22 +349,6 @@ void BasicGUI_ArcDlg::SetEditCurrentArgument() } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void BasicGUI_ArcDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if ( send == Group3Pnts->LineEdit1 || send == Group3Pnts->LineEdit2 || send == Group3Pnts->LineEdit3 || - send == Group3Pnts2->LineEdit1 || send == Group3Pnts2->LineEdit2 || send == Group3Pnts2->LineEdit3 ) - { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } -} - - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -333,33 +356,13 @@ void BasicGUI_ArcDlg::LineEditReturnPressed() void BasicGUI_ArcDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - // myGeomGUI->SetState( 0 ); - globalSelection( GEOM_POINT ); - - myEditCurrentArgument = Group3Pnts->LineEdit1; - myEditCurrentArgument->setFocus(); - Group3Pnts->LineEdit1->setText( "" ); - Group3Pnts->LineEdit2->setText( "" ); - Group3Pnts->LineEdit3->setText( "" ); - myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); + connect(myGeomGUI->getApp()->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); ConstructorsClicked( getConstructorId() ); - } -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : public slot to deactivate if active -//================================================================================= -void BasicGUI_ArcDlg::DeactivateActiveDialog() -{ - // myGeomGUI->SetState( -1 ); - GEOMBase_Skeleton::DeactivateActiveDialog(); -} //================================================================================= // function : enterEvent() @@ -367,10 +370,11 @@ void BasicGUI_ArcDlg::DeactivateActiveDialog() //================================================================================= void BasicGUI_ArcDlg::enterEvent(QEvent* e) { - if ( !GroupConstructors->isEnabled() ) + if (!GroupConstructors->isEnabled()) ActivateThisDialog(); } + //================================================================================= // function : createOperation // purpose : @@ -410,71 +414,33 @@ bool BasicGUI_ArcDlg::execute( ObjectList& objects ) switch (getConstructorId()) { - case 0: + case 0: + { + if ( !CORBA::is_nil(myPoint1) && !CORBA::is_nil(myPoint2) &&!CORBA::is_nil(myPoint3) ) { - if ( !CORBA::is_nil(myPoint1) && !CORBA::is_nil(myPoint2) &&!CORBA::is_nil(myPoint3) ){ - anObj = GEOM::GEOM_ICurvesOperations::_narrow(getOperation())->MakeArc(myPoint1, myPoint2, myPoint3); - res = true; - } - break; + anObj = GEOM::GEOM_ICurvesOperations::_narrow(getOperation())-> + MakeArc(myPoint1, myPoint2, myPoint3); + res = true; } - case 1: - { - bool Sense; - (Group3Pnts2->radioButton4->isChecked()) ? Sense=true : Sense = false; - if ( !CORBA::is_nil(myPoint1) && !CORBA::is_nil(myPoint2) &&!CORBA::is_nil(myPoint3) ){ - anObj = GEOM::GEOM_ICurvesOperations::_narrow(getOperation())->MakeArcCenter(myPoint1, myPoint2, myPoint3,Sense); - res = true; - } - break; - } - } - if ( !anObj->_is_nil() ){ - objects.push_back( anObj._retn() ); - } - return res; -} - -//================================================================================= -// function : closeEvent -// purpose : -//================================================================================= -void BasicGUI_ArcDlg::closeEvent( QCloseEvent* e ) -{ - GEOMBase_Skeleton::closeEvent( e ); -} - -//================================================================================= -// function : ConstructorsClicked() -// purpose : Radio button management -//================================================================================= -void BasicGUI_ArcDlg::ConstructorsClicked( int constructorId ) -{ - - disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0); - - switch (constructorId) - { - case 0: - { - Group3Pnts->show(); - resize(0, 0); - Group3Pnts2->hide(); - - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break; } - case 1: + case 1: { - Group3Pnts->hide(); - resize(0, 0); - Group3Pnts2->show(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - + bool Sense; + (Group3Pnts2->radioButton4->isChecked()) ? Sense = true : Sense = false; + if ( !CORBA::is_nil(myPoint1) && !CORBA::is_nil(myPoint2) &&!CORBA::is_nil(myPoint3) ) + { + anObj = GEOM::GEOM_ICurvesOperations::_narrow(getOperation())-> + MakeArcCenter(myPoint1, myPoint2, myPoint3, Sense); + res = true; + } break; } } - displayPreview(); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return res; } //================================================================================= diff --git a/src/BasicGUI/BasicGUI_ArcDlg.h b/src/BasicGUI/BasicGUI_ArcDlg.h index a63d04cdc..d2fa847b7 100644 --- a/src/BasicGUI/BasicGUI_ArcDlg.h +++ b/src/BasicGUI/BasicGUI_ArcDlg.h @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -37,6 +37,7 @@ #else #define BASICGUI_WNT_EXPORT #endif + //================================================================================= // class : BasicGUI_ArcDlg // purpose : @@ -56,12 +57,10 @@ protected: virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - virtual void closeEvent( QCloseEvent* e ); - -private : +private: void Init(); void enterEvent(QEvent* e); - int myConstructorId; + GEOM::GEOM_Object_var myPoint1, myPoint2, myPoint3; DlgRef_3Sel_QTD* Group3Pnts; @@ -69,12 +68,10 @@ private : private slots: void ClickOnOk(); - void ClickOnCancel(); bool ClickOnApply(); - + void ActivateThisDialog(); - void DeactivateActiveDialog(); - void ConstructorsClicked( int ); + void ConstructorsClicked(int); void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); diff --git a/src/BasicGUI/BasicGUI_CircleDlg.cxx b/src/BasicGUI/BasicGUI_CircleDlg.cxx index ce76529d0..42c3e5aa5 100644 --- a/src/BasicGUI/BasicGUI_CircleDlg.cxx +++ b/src/BasicGUI/BasicGUI_CircleDlg.cxx @@ -125,7 +125,7 @@ void BasicGUI_CircleDlg::Init() double aStep = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100); /* min, max, step and decimals for spin boxes & initial values */ - GroupPntVecR->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, aStep, 3); + GroupPntVecR->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, aStep, DBL_DIGITS_DISPLAY); GroupPntVecR->SpinBox_DX->SetValue( 100 ); /* signals and slots connections */ diff --git a/src/BasicGUI/BasicGUI_EllipseDlg.cxx b/src/BasicGUI/BasicGUI_EllipseDlg.cxx index ba6db7d30..7103838b5 100644 --- a/src/BasicGUI/BasicGUI_EllipseDlg.cxx +++ b/src/BasicGUI/BasicGUI_EllipseDlg.cxx @@ -114,8 +114,8 @@ void BasicGUI_EllipseDlg::Init() double aMajorR( 200. ), aMinorR( 100. ); /* min, max, step and decimals for spin boxes & initial values */ - GroupPoints->SpinBox_DX->RangeStepAndValidator( 0.001, COORD_MAX, step, 3 ); - GroupPoints->SpinBox_DY->RangeStepAndValidator( 0.001, COORD_MAX, step, 3 ); + GroupPoints->SpinBox_DX->RangeStepAndValidator( 0.001, COORD_MAX, step, DBL_DIGITS_DISPLAY ); + GroupPoints->SpinBox_DY->RangeStepAndValidator( 0.001, COORD_MAX, step, DBL_DIGITS_DISPLAY ); GroupPoints->SpinBox_DX->SetValue( aMajorR ); GroupPoints->SpinBox_DY->SetValue( aMinorR ); diff --git a/src/BasicGUI/BasicGUI_MarkerDlg.cxx b/src/BasicGUI/BasicGUI_MarkerDlg.cxx index 99e7ff9a5..17f6d25b4 100644 --- a/src/BasicGUI/BasicGUI_MarkerDlg.cxx +++ b/src/BasicGUI/BasicGUI_MarkerDlg.cxx @@ -176,7 +176,7 @@ void BasicGUI_MarkerDlg::Init() for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter ) { - anIter.data()->RangeStepAndValidator( COORD_MIN, COORD_MAX, step, 3 ); + anIter.data()->RangeStepAndValidator( COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY ); connect( anIter.data(), SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged( double ) ) ); } diff --git a/src/BasicGUI/BasicGUI_PlaneDlg.cxx b/src/BasicGUI/BasicGUI_PlaneDlg.cxx index a48162902..62711faa6 100644 --- a/src/BasicGUI/BasicGUI_PlaneDlg.cxx +++ b/src/BasicGUI/BasicGUI_PlaneDlg.cxx @@ -138,11 +138,11 @@ void BasicGUI_PlaneDlg::Init() double aTrimSize = 2000.0; /* min, max, step and decimals for spin boxes */ - GroupPntDir->SpinBox_DX->RangeStepAndValidator( 0.001, COORD_MAX, aStep, 3 ); + GroupPntDir->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, aStep, DBL_DIGITS_DISPLAY); GroupPntDir->SpinBox_DX->SetValue( aTrimSize ); - Group3Pnts->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, aStep, 3); + Group3Pnts->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, aStep, DBL_DIGITS_DISPLAY); Group3Pnts->SpinBox_DX->SetValue( aTrimSize ); - GroupFace->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, aStep, 3); + GroupFace->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, aStep, DBL_DIGITS_DISPLAY); GroupFace->SpinBox_DX->SetValue( aTrimSize ); /* signals and slots connections */ diff --git a/src/BasicGUI/BasicGUI_VectorDlg.cxx b/src/BasicGUI/BasicGUI_VectorDlg.cxx index 48fb526cd..79a4f90c2 100644 --- a/src/BasicGUI/BasicGUI_VectorDlg.cxx +++ b/src/BasicGUI/BasicGUI_VectorDlg.cxx @@ -118,9 +118,9 @@ void BasicGUI_VectorDlg::Init() double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100); /* min, max, step and decimals for spin boxes */ - GroupDimensions->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3); - GroupDimensions->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3); - GroupDimensions->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3); + GroupDimensions->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); + GroupDimensions->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); + GroupDimensions->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); double dx( 0. ), dy( 0. ), dz( 200. ); GroupDimensions->SpinBox_DX->SetValue( dx ); diff --git a/src/GenerationGUI/GenerationGUI_PrismDlg.cxx b/src/GenerationGUI/GenerationGUI_PrismDlg.cxx index 1c56672f9..c1b1ffe5a 100644 --- a/src/GenerationGUI/GenerationGUI_PrismDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_PrismDlg.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -42,7 +42,7 @@ //================================================================================= // class : GenerationGUI_PrismDlg() -// purpose : Constructs a GenerationGUI_PrismDlg which is a child of 'parent', with the +// purpose : Constructs a GenerationGUI_PrismDlg which is a child of 'parent', with the // name 'name' and widget flags set to 'f'. // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. @@ -103,7 +103,7 @@ GenerationGUI_PrismDlg::GenerationGUI_PrismDlg(GeometryGUI* theGeometryGUI, QWid // purpose : Destroys the object and frees any allocated resources //================================================================================= GenerationGUI_PrismDlg::~GenerationGUI_PrismDlg() -{ +{ // no need to delete child widgets, Qt does it all for us } @@ -123,14 +123,15 @@ void GenerationGUI_PrismDlg::Init() GroupPoints2->LineEdit2->setReadOnly( true ); GroupPoints2->LineEdit3->setReadOnly( true ); + myPoint1 = myPoint2 = myBase = myVec = GEOM::GEOM_Object::_nil(); myOkBase = myOkVec = myOkPnt1 = myOkPnt2 = false; - + /* Get setting of step value from file configuration */ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100); /* min, max, step and decimals for spin boxes & initial values */ - GroupPoints->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3); + GroupPoints->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); GroupPoints->SpinBox_DX->SetValue(100.0); /* signals and slots connections */ @@ -146,9 +147,10 @@ void GenerationGUI_PrismDlg::Init() connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupPoints->SpinBox_DX, SLOT(SetStep(double))); - connect(GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(onReverse())); + connect(GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(onReverse())); connect(GroupPoints2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); @@ -160,8 +162,8 @@ void GenerationGUI_PrismDlg::Init() connect(GroupPoints2->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + connect(myGeomGUI->getApp()->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); initName(tr("GEOM_EXTRUSION")); ConstructorsClicked(0); @@ -178,50 +180,48 @@ void GenerationGUI_PrismDlg::ConstructorsClicked(int constructorId) disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); switch (constructorId) + { + case 0: { - case 0: - { - globalSelection( GEOM_POINT ); - - GroupPoints2->hide(); - resize(0, 0); - GroupPoints->show(); - - myEditCurrentArgument = GroupPoints->LineEdit1; - GroupPoints->LineEdit1->setText(""); - GroupPoints->LineEdit2->setText(""); - GroupPoints2->LineEdit1->setText(""); - GroupPoints2->LineEdit2->setText(""); - GroupPoints2->LineEdit3->setText(""); - myPoint1 = myPoint2 = myBase = myVec = GEOM::GEOM_Object::_nil(); - myOkBase = myOkVec = myOkPnt1 = myOkPnt2 = false; - - break; - } - case 1: - { - globalSelection( GEOM_ALLSHAPES ); - - GroupPoints->hide(); - resize(0, 0); - GroupPoints2->show(); - - myEditCurrentArgument = GroupPoints2->LineEdit1; - GroupPoints2->LineEdit1->setText(""); - GroupPoints2->LineEdit2->setText(""); - GroupPoints2->LineEdit3->setText(""); - myPoint1 = myPoint2 = myBase = myVec = GEOM::GEOM_Object::_nil(); - myOkBase = myOkVec = myOkPnt1 = myOkPnt2 = false; - GroupPoints->LineEdit1->setText(""); - GroupPoints->LineEdit2->setText(""); - - break; - } + globalSelection( GEOM_ALLSHAPES ); + + GroupPoints2->hide(); + resize(0, 0); + GroupPoints->show(); + + myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setText(GroupPoints2->LineEdit1->text()); // keep base + GroupPoints->LineEdit2->setText(""); + myVec = GEOM::GEOM_Object::_nil(); + myOkVec = false; + + break; } + case 1: + { + globalSelection( GEOM_ALLSHAPES ); + + GroupPoints->hide(); + resize(0, 0); + GroupPoints2->show(); + + myEditCurrentArgument = GroupPoints2->LineEdit1; + GroupPoints2->LineEdit1->setText(GroupPoints->LineEdit1->text()); // keep base + GroupPoints2->LineEdit2->setText(""); + GroupPoints2->LineEdit3->setText(""); + myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); + myOkPnt1 = myOkPnt2 = false; + + break; + } + } myEditCurrentArgument->setFocus(); - connect(myGeomGUI->getApp()->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + if (!myOkBase) + SelectionIntoArgument(); } @@ -287,7 +287,6 @@ void GenerationGUI_PrismDlg::SelectionIntoArgument() } myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject)); - displayPreview(); } else // getConstructorId()==1 - extrusion using 2 points { @@ -327,8 +326,9 @@ void GenerationGUI_PrismDlg::SelectionIntoArgument() } myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject)); - displayPreview(); } + + displayPreview(); } @@ -398,7 +398,7 @@ void GenerationGUI_PrismDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(myGeomGUI->getApp()->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); ConstructorsClicked( getConstructorId() ); @@ -450,7 +450,12 @@ GEOM::GEOM_IOperations_ptr GenerationGUI_PrismDlg::createOperation() //================================================================================= bool GenerationGUI_PrismDlg::isValid( QString& ) { - return myOkBase && ( myOkVec || (myOkPnt1 && myOkPnt2) ); + if (getConstructorId() == 0) + // by vector and height + return (myOkBase && myOkVec); + + // by two points + return (myOkBase && myOkPnt1 && myOkPnt2); } //================================================================================= @@ -461,10 +466,10 @@ bool GenerationGUI_PrismDlg::execute( ObjectList& objects ) { GEOM::GEOM_Object_var anObj; - switch ( getConstructorId() ) + switch ( getConstructorId() ) { case 0: - { + { anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())-> MakePrismVecH(myBase, myVec, getHeight()); break; diff --git a/src/GenerationGUI/GenerationGUI_PrismDlg.h b/src/GenerationGUI/GenerationGUI_PrismDlg.h index 1d5f308fc..cf6efe6f4 100644 --- a/src/GenerationGUI/GenerationGUI_PrismDlg.h +++ b/src/GenerationGUI/GenerationGUI_PrismDlg.h @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -51,15 +51,15 @@ protected: virtual bool isValid( QString& msg ); virtual bool execute( ObjectList& objects ); -private : +private: void Init(); void enterEvent(QEvent* e); double getHeight() const; - + GEOM::GEOM_Object_var myBase; /* Base shape */ GEOM::GEOM_Object_var myVec; /* Vector, defining the direction */ - GEOM::GEOM_Object_var myPoint1, myPoint2; /* Points for extrusion */ - + GEOM::GEOM_Object_var myPoint1, myPoint2; /* Points for extrusion */ + bool myOkBase; bool myOkVec; bool myOkPnt1; @@ -71,11 +71,12 @@ private : private slots: void ClickOnOk(); bool ClickOnApply(); + void ActivateThisDialog(); + void ConstructorsClicked(int); void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); - void ConstructorsClicked(int); void ValueChangedInSpinBox(); void onReverse(); }; diff --git a/src/GenerationGUI/GenerationGUI_RevolDlg.cxx b/src/GenerationGUI/GenerationGUI_RevolDlg.cxx index e8a6608ad..1956395ac 100644 --- a/src/GenerationGUI/GenerationGUI_RevolDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_RevolDlg.cxx @@ -114,7 +114,7 @@ void GenerationGUI_RevolDlg::Init() double SpecificStep = 5; /* min, max, step and decimals for spin boxes & initial values */ - GroupPoints->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, SpecificStep, 3); + GroupPoints->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY); GroupPoints->SpinBox_DX->SetValue(45.0); /* signals and slots connections */ diff --git a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx index 23e9ce46a..7230ca6a5 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx @@ -117,9 +117,9 @@ void PrimitiveGUI_BoxDlg::Init() double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100); /* min, max, step and decimals for spin boxes */ - GroupDimensions->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3); - GroupDimensions->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3); - GroupDimensions->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3); + GroupDimensions->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); + GroupDimensions->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); + GroupDimensions->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); double initValue = 200.0; GroupDimensions->SpinBox_DX->SetValue(initValue); diff --git a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx index 7de92356e..fd7f05cd6 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx @@ -119,12 +119,12 @@ void PrimitiveGUI_ConeDlg::Init() double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100); /* min, max, step and decimals for spin boxes & initial values */ - GroupPoints->SpinBox_DX->RangeStepAndValidator(0.000, COORD_MAX, step, 3); - GroupPoints->SpinBox_DY->RangeStepAndValidator(0.000, COORD_MAX, step, 3); - GroupPoints->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3); - GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.000, COORD_MAX, step, 3); - GroupDimensions->SpinBox_DY->RangeStepAndValidator(0.000, COORD_MAX, step, 3); - GroupDimensions->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3); + GroupPoints->SpinBox_DX->RangeStepAndValidator(0.000, COORD_MAX, step, DBL_DIGITS_DISPLAY); + GroupPoints->SpinBox_DY->RangeStepAndValidator(0.000, COORD_MAX, step, DBL_DIGITS_DISPLAY); + GroupPoints->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); + GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.000, COORD_MAX, step, DBL_DIGITS_DISPLAY); + GroupDimensions->SpinBox_DY->RangeStepAndValidator(0.000, COORD_MAX, step, DBL_DIGITS_DISPLAY); + GroupDimensions->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); double aRadius1(100.0), aRadius2(0.0), aHeight(300.0); GroupPoints->SpinBox_DX->SetValue(aRadius1); diff --git a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx index 503211cf2..6c2b1b726 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx @@ -118,13 +118,13 @@ void PrimitiveGUI_CylinderDlg::Init() /* min, max, step and decimals for spin boxes & initial values */ /* First constructor : radius */ - GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, step, 3); + GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, step, DBL_DIGITS_DISPLAY); /* First constructor : algebric height */ - GroupPoints->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3); + GroupPoints->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); /* Second constructor : radius */ - GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, step, 3); + GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, step, DBL_DIGITS_DISPLAY); /* Second constructor : algebric height */ - GroupDimensions->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3); + GroupDimensions->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); GroupPoints->SpinBox_DX->SetValue(100.0); GroupPoints->SpinBox_DY->SetValue(300.0); diff --git a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx index f52f0822a..f7a79b152 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx @@ -112,8 +112,8 @@ void PrimitiveGUI_SphereDlg::Init() double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100); /* min, max, step and decimals for spin boxes */ - GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, step, 3); - GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, step, 3); + GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, step, DBL_DIGITS_DISPLAY); + GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, step, DBL_DIGITS_DISPLAY); GroupPoints->SpinBox_DX->SetValue(100.0); GroupDimensions->SpinBox_DX->SetValue(100.0); diff --git a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx index 7ab9ca465..1f4279bca 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -39,23 +39,22 @@ #include "utilities.h" -using namespace std; - //================================================================================= // class : PrimitiveGUI_TorusDlg() -// purpose : Constructs a PrimitiveGUI_TorusDlg which is a child of 'parent', with the +// purpose : Constructs a PrimitiveGUI_TorusDlg which is a child of 'parent', with the // name 'name' and widget flags set to 'f'. // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= PrimitiveGUI_TorusDlg::PrimitiveGUI_TorusDlg(GeometryGUI* theGeometryGUI, QWidget* parent, const char* name, bool modal, WFlags fl) - :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize | - WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) + : GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize | + WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_TORUS_PV"))); - QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_TORUS_DXYZ"))); - QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT"))); + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + QPixmap image0(aResMgr->loadPixmap("GEOM", tr("ICON_DLG_TORUS_PV"))); + QPixmap image1(aResMgr->loadPixmap("GEOM", tr("ICON_DLG_TORUS_DXYZ"))); + QPixmap image2(aResMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); setCaption(tr("GEOM_TORUS_TITLE")); @@ -83,8 +82,8 @@ PrimitiveGUI_TorusDlg::PrimitiveGUI_TorusDlg(GeometryGUI* theGeometryGUI, QWidge Layout1->addWidget(GroupDimensions, 2, 0); /***************************************************************/ - setHelpFileName("turus.htm"); - + setHelpFileName("turus.htm"); + Init(); } @@ -109,7 +108,7 @@ void PrimitiveGUI_TorusDlg::Init() myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit2->setReadOnly( true ); - + myPoint = myDir = GEOM::GEOM_Object::_nil(); /* Get setting of step value from file configuration */ @@ -117,10 +116,10 @@ void PrimitiveGUI_TorusDlg::Init() double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100); /* min, max, step and decimals for spin boxes & initial values */ - GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, step, 3); - GroupPoints->SpinBox_DY->RangeStepAndValidator(0.001, COORD_MAX, step, 3); - GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, step, 3); - GroupDimensions->SpinBox_DY->RangeStepAndValidator(0.001, COORD_MAX, step, 3); + GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, step, DBL_DIGITS_DISPLAY); + GroupPoints->SpinBox_DY->RangeStepAndValidator(0.001, COORD_MAX, step, DBL_DIGITS_DISPLAY); + GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, step, DBL_DIGITS_DISPLAY); + GroupDimensions->SpinBox_DY->RangeStepAndValidator(0.001, COORD_MAX, step, DBL_DIGITS_DISPLAY); GroupPoints->SpinBox_DX->SetValue(300.0); GroupPoints->SpinBox_DY->SetValue(100.0); @@ -130,6 +129,7 @@ void PrimitiveGUI_TorusDlg::Init() /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); @@ -143,14 +143,18 @@ void PrimitiveGUI_TorusDlg::Init() connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DY, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DY, SLOT(SetStep(double))); - - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupPoints->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupPoints->SpinBox_DY, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupDimensions->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupDimensions->SpinBox_DY, SLOT(SetStep(double))); + + connect(myGeomGUI->getApp()->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + initName( tr( "GEOM_TORUS" ) ); ConstructorsClicked(0); } @@ -162,36 +166,39 @@ void PrimitiveGUI_TorusDlg::Init() //================================================================================= void PrimitiveGUI_TorusDlg::ConstructorsClicked(int constructorId) { - disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0); - - switch(constructorId) - { - case 0 : - { - globalSelection( GEOM_LINE ); - - GroupDimensions->hide(); - resize(0, 0); - GroupPoints->show(); - - myEditCurrentArgument = GroupPoints->LineEdit1; - GroupPoints->LineEdit1->setText(tr("")); - GroupPoints->LineEdit2->setText(tr("")); - myPoint = myDir = GEOM::GEOM_Object::_nil(); - - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - break ; - } - case 1 : - { - GroupPoints->hide(); - resize( 0, 0 ); - GroupDimensions->show(); - - break ; - } + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + + switch (constructorId) + { + case 0: + { + globalSelection( GEOM_POINT ); + + GroupDimensions->hide(); + resize(0, 0); + GroupPoints->show(); + + myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setText(tr("")); + GroupPoints->LineEdit2->setText(tr("")); + myPoint = myDir = GEOM::GEOM_Object::_nil(); + + connect(myGeomGUI->getApp()->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + SelectionIntoArgument(); + + break; + } + case 1: + { + GroupPoints->hide(); + resize(0, 0); + GroupDimensions->show(); + + break; } + } + displayPreview(); } @@ -217,21 +224,10 @@ bool PrimitiveGUI_TorusDlg::ClickOnApply() return false; initName(); - ConstructorsClicked( getConstructorId() ); return true; } -//======================================================================= -// function : ClickOnCancel() -// purpose : -//======================================================================= -void PrimitiveGUI_TorusDlg::ClickOnCancel() -{ - GEOMBase_Skeleton::ClickOnCancel(); -} - - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed or other case @@ -240,36 +236,51 @@ void PrimitiveGUI_TorusDlg::SelectionIntoArgument() { if ( getConstructorId() != 0 ) return; - + myEditCurrentArgument->setText(""); - - if(IObjectCount() != 1) - { - if(myEditCurrentArgument == GroupPoints->LineEdit1) - myPoint = GEOM::GEOM_Object::_nil(); - else if(myEditCurrentArgument == GroupPoints->LineEdit2) - myDir = GEOM::GEOM_Object::_nil(); - return; - } - - + + if (IObjectCount() != 1) + { + if (myEditCurrentArgument == GroupPoints->LineEdit1) + myPoint = GEOM::GEOM_Object::_nil(); + else if (myEditCurrentArgument == GroupPoints->LineEdit2) + myDir = GEOM::GEOM_Object::_nil(); + return; + } + /* nbSel == 1 */ Standard_Boolean testResult = Standard_False; GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult ); - - if(!testResult || CORBA::is_nil( aSelectedObject )) + + if (!testResult || CORBA::is_nil( aSelectedObject )) return; - - if(myEditCurrentArgument == GroupPoints->LineEdit1) + + if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint = aSelectedObject; - else if(myEditCurrentArgument == GroupPoints->LineEdit2) + else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir = aSelectedObject; - + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); displayPreview(); } +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void PrimitiveGUI_TorusDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if (send == GroupPoints->LineEdit1 || + send == GroupPoints->LineEdit2) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } +} + + //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -277,37 +288,21 @@ void PrimitiveGUI_TorusDlg::SelectionIntoArgument() void PrimitiveGUI_TorusDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - - if(send == GroupPoints->PushButton1) { + + if (send == GroupPoints->PushButton1) { myEditCurrentArgument = GroupPoints->LineEdit1; globalSelection( GEOM_POINT ); } - else if(send == GroupPoints->PushButton2) { + else if (send == GroupPoints->PushButton2) { myEditCurrentArgument = GroupPoints->LineEdit2; globalSelection( GEOM_LINE ); } - + myEditCurrentArgument->setFocus(); SelectionIntoArgument(); } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void PrimitiveGUI_TorusDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1 || - send == GroupPoints->LineEdit2) - { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } -} - - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -315,9 +310,10 @@ void PrimitiveGUI_TorusDlg::LineEditReturnPressed() void PrimitiveGUI_TorusDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - + ConstructorsClicked( getConstructorId() ); } @@ -333,16 +329,6 @@ void PrimitiveGUI_TorusDlg::enterEvent(QEvent* e) } -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : public slot to deactivate if active -//================================================================================= -void PrimitiveGUI_TorusDlg::DeactivateActiveDialog() -{ - GEOMBase_Skeleton::DeactivateActiveDialog(); -} - - //================================================================================= // function : ValueChangedInSpinBox // purpose : @@ -380,22 +366,25 @@ bool PrimitiveGUI_TorusDlg::isValid( QString& msg ) bool PrimitiveGUI_TorusDlg::execute( ObjectList& objects ) { bool res = false; - + GEOM::GEOM_Object_var anObj; - switch ( getConstructorId() ) - { - case 0 : + switch ( getConstructorId() ) { - if (!CORBA::is_nil( myPoint ) && !CORBA::is_nil( myDir )){ - anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeTorusPntVecRR(myPoint, myDir, getRadius1(), getRadius2()); - res = true; + case 0: + { + if (!CORBA::is_nil( myPoint ) && !CORBA::is_nil( myDir )) + { + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )-> + MakeTorusPntVecRR(myPoint, myDir, getRadius1(), getRadius2()); + res = true; + } + break; } - break; - } - case 1 : + case 1: { - anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeTorusRR(getRadius1(), getRadius2()); + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )-> + MakeTorusRR(getRadius1(), getRadius2()); res = true; break; } @@ -408,16 +397,6 @@ bool PrimitiveGUI_TorusDlg::execute( ObjectList& objects ) } -//================================================================================= -// function : closeEvent -// purpose : -//================================================================================= -void PrimitiveGUI_TorusDlg::closeEvent( QCloseEvent* e ) -{ - GEOMBase_Skeleton::closeEvent( e ); -} - - //================================================================================= // function : getRadius1() // purpose : diff --git a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h index 00d6a46b6..08e86ced1 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -52,11 +52,10 @@ protected: virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - virtual void closeEvent( QCloseEvent* e ); - private: void Init(); void enterEvent(QEvent* e); + double getRadius1() const; double getRadius2() const; @@ -65,12 +64,11 @@ private: DlgRef_2Sel2Spin* GroupPoints; DlgRef_2Spin* GroupDimensions; - private slots: +private slots: void ClickOnOk(); bool ClickOnApply(); - void ClickOnCancel(); + void ActivateThisDialog(); - void DeactivateActiveDialog(); void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument();