X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FBasicGUI%2FBasicGUI_VectorDlg.cxx;h=9408a0a3971f0e8bca95b1e0ebcd7e68f2b93dea;hb=b568e7744737ad193de8a49b27a5769a4777d7fd;hp=6dd3e27848780d967d5b73553eeecb4f47192ea2;hpb=496cc5f9ba9ea7ae0e2adc8960a697839c145c20;p=modules%2Fgeom.git diff --git a/src/BasicGUI/BasicGUI_VectorDlg.cxx b/src/BasicGUI/BasicGUI_VectorDlg.cxx index 6dd3e2784..9408a0a39 100644 --- a/src/BasicGUI/BasicGUI_VectorDlg.cxx +++ b/src/BasicGUI/BasicGUI_VectorDlg.cxx @@ -25,7 +25,7 @@ #include "BasicGUI_VectorDlg.h" -#include +#include #include #include @@ -34,18 +34,24 @@ #include #include +#include +#include +#include +#include +#include + #include //================================================================================= // class : BasicGUI_VectorDlg() -// purpose : Constructs a BasicGUI_VectorDlg which is a child of 'parent', with the +// purpose : Constructs a BasicGUI_VectorDlg 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. //================================================================================= BasicGUI_VectorDlg::BasicGUI_VectorDlg( GeometryGUI* theGeometryGUI, QWidget* parent, - const char* name, bool modal, Qt::WindowFlags fl ) - : GEOMBase_Skeleton( theGeometryGUI, parent, name, modal, fl ) + bool modal, Qt::WindowFlags fl ) + : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) { QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_VECTOR_2P" ) ) ); QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_VECTOR_DXYZ" ) ) ); @@ -84,8 +90,8 @@ BasicGUI_VectorDlg::BasicGUI_VectorDlg( GeometryGUI* theGeometryGUI, QWidget* pa layout->addWidget( GroupDimensions ); /***************************************************************/ - setHelpFileName( "vector.htm" ); - + setHelpFileName( "create_vector_page.html" ); + /* Initialisations */ Init(); } @@ -96,7 +102,7 @@ BasicGUI_VectorDlg::BasicGUI_VectorDlg( GeometryGUI* theGeometryGUI, QWidget* pa // purpose : Destroys the object and frees any allocated resources //================================================================================= BasicGUI_VectorDlg::~BasicGUI_VectorDlg() -{ +{ } @@ -115,11 +121,11 @@ void BasicGUI_VectorDlg::Init() /* 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 */ - initSpinBox( GroupDimensions->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); - initSpinBox( GroupDimensions->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); - initSpinBox( GroupDimensions->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 ); + initSpinBox( GroupDimensions->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY + initSpinBox( GroupDimensions->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY + initSpinBox( GroupDimensions->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY double dx( 0. ), dy( 0. ), dz( 200. ); GroupDimensions->SpinBox_DX->setValue( dx ); @@ -131,8 +137,7 @@ void BasicGUI_VectorDlg::Init() /* signals and slots connections */ connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ); connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ); - - connect( buttonCancel(), SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ); + connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); @@ -148,20 +153,28 @@ void BasicGUI_VectorDlg::Init() connect( GroupDimensions->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupDimensions->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - // VSR: TODO ->> - connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), GroupDimensions->SpinBox_DX, SLOT( SetStep( double ) ) ); - connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), GroupDimensions->SpinBox_DY, SLOT( SetStep( double ) ) ); - connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), GroupDimensions->SpinBox_DZ, SLOT( SetStep( double ) ) ); - // <<- + connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) ); connect( GroupDimensions->CheckButton1, SIGNAL( stateChanged( int ) ), this, SLOT( ReverseVector( int ) ) ); - 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_VECTOR") ); - ConstructorsClicked( 0 ); + setConstructorId( 1 ); // simplest constructor + ConstructorsClicked( 1 ); +} + +//================================================================================= +// function : SetDoubleSpinBoxStep() +// purpose : Double spin box management +//================================================================================= +void BasicGUI_VectorDlg::SetDoubleSpinBoxStep( double step ) +{ + GroupDimensions->SpinBox_DX->setSingleStep(step); + GroupDimensions->SpinBox_DY->setSingleStep(step); + GroupDimensions->SpinBox_DZ->setSingleStep(step); } @@ -171,7 +184,7 @@ void BasicGUI_VectorDlg::Init() //================================================================================= void BasicGUI_VectorDlg::ConstructorsClicked( int constructorId ) { - disconnect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), 0, this, 0 ); + disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); myPoint1 = GEOM::GEOM_Object::_nil(); myPoint2 = GEOM::GEOM_Object::_nil(); @@ -180,26 +193,28 @@ void BasicGUI_VectorDlg::ConstructorsClicked( int constructorId ) { GroupDimensions->hide(); GroupPoints->show(); - + myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setText( "" ); GroupPoints->LineEdit2->setText( "" ); - - globalSelection( GEOM_POINT ); - connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT(SelectionIntoArgument() ) ); + + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + connect( myGeomGUI->getApp()->selectionMgr(), + SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); break; } case 1: { GroupPoints->hide(); GroupDimensions->show(); - - double dx( 0. ), dy( 0. ), dz( 0. ); + globalSelection(); // close local contexts, if any + + double dx( 0. ), dy( 0. ), dz( 0. ); GroupDimensions->SpinBox_DX->setValue( dx ); GroupDimensions->SpinBox_DY->setValue( dy ); GroupDimensions->SpinBox_DZ->setValue( dz ); - + GroupDimensions->CheckButton1->setChecked( false ); break; } @@ -223,15 +238,6 @@ void BasicGUI_VectorDlg::ClickOnOk() ClickOnCancel(); } -//======================================================================= -// function : ClickOnCancel() -// purpose : -//======================================================================= -void BasicGUI_VectorDlg::ClickOnCancel() -{ - GEOMBase_Skeleton::ClickOnCancel(); -} - //================================================================================= // function : ClickOnApply() // purpose : @@ -266,11 +272,42 @@ void BasicGUI_VectorDlg::SelectionIntoArgument() return; } - // nbSel == 1 + // nbSel == 1 Standard_Boolean aRes = Standard_False; GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes ); if ( !CORBA::is_nil( aSelectedObject ) && aRes ) { - myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + QString aName = GEOMBase::GetName(aSelectedObject); + + TopoDS_Shape aShape; + if ( GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes( firstIObject(), aMap ); + if ( aMap.Extent() == 1 ) { // Local Selection + int anIndex = aMap( 1 ); + aName += QString( ":vertex_%1" ).arg( anIndex ); + + //Find SubShape Object in Father + GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName ); + + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); + aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex ); + } + else { + aSelectedObject = aFindedObject; // get Object from study + } + } + else { // Global Selection + if ( aShape.ShapeType() != TopAbs_VERTEX ) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + + myEditCurrentArgument->setText(aName); + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myPoint1 = aSelectedObject; else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) myPoint2 = aSelectedObject; } @@ -298,7 +335,7 @@ void BasicGUI_VectorDlg::SetEditCurrentArgument() // purpose : //================================================================================= void BasicGUI_VectorDlg::LineEditReturnPressed() -{ +{ QLineEdit* send = (QLineEdit*)sender(); if ( send == GroupPoints->LineEdit1 ) myEditCurrentArgument = GroupPoints->LineEdit1; else if ( send == GroupPoints->LineEdit2 ) myEditCurrentArgument = GroupPoints->LineEdit2; @@ -314,8 +351,8 @@ void BasicGUI_VectorDlg::LineEditReturnPressed() void BasicGUI_VectorDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), + this, SLOT( SelectionIntoArgument() ) ); ConstructorsClicked( getConstructorId() ); } @@ -326,7 +363,6 @@ void BasicGUI_VectorDlg::ActivateThisDialog() //================================================================================= void BasicGUI_VectorDlg::DeactivateActiveDialog() { - // myGeomGUI->SetState( -1 ); GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -362,7 +398,7 @@ void BasicGUI_VectorDlg::ReverseVector( int state ) GroupDimensions->SpinBox_DX->setValue( dx ); GroupDimensions->SpinBox_DY->setValue( dy ); GroupDimensions->SpinBox_DZ->setValue( dz ); - + displayPreview(); } @@ -391,7 +427,7 @@ bool BasicGUI_VectorDlg::isValid( QString& msg ) bool BasicGUI_VectorDlg::execute( ObjectList& objects ) { bool res = false; - + GEOM::GEOM_Object_var anObj; switch ( getConstructorId() ) { @@ -418,3 +454,21 @@ bool BasicGUI_VectorDlg::execute( ObjectList& objects ) return res; } +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void BasicGUI_VectorDlg::addSubshapesToStudy() +{ + QMap objMap; + + switch ( getConstructorId() ) { + case 0: + objMap[GroupPoints->LineEdit1->text()] = myPoint1; + objMap[GroupPoints->LineEdit2->text()] = myPoint2; + break; + case 1: + return; + } + addSubshapesToFather( objMap ); +}