X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FTransformationGUI%2FTransformationGUI_TranslationDlg.cxx;h=979cf2242ff60cd34ee4078d6de14bb3c3d049f2;hb=04f3d723da1ae9133d108921c8f10338a9656d12;hp=b7c9432626ba097036b26d44451ae8249bd7e3bc;hpb=f70f07e7dbec1c3068bb2f5ffd6ce0ca41798091;p=modules%2Fgeom.git diff --git a/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx b/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx index b7c943262..979cf2242 100644 --- a/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx @@ -25,7 +25,7 @@ #include "TransformationGUI_TranslationDlg.h" -#include +#include #include #include @@ -34,6 +34,13 @@ #include #include +#include +#include +#include +#include +#include +#include + #include //================================================================================= @@ -79,7 +86,7 @@ TransformationGUI_TranslationDlg::TransformationGUI_TranslationDlg layout->addWidget( GroupPoints ); /***************************************************************/ - setHelpFileName( "translation.htm" ); + setHelpFileName( "translation_operation_page.html" ); Init(); } @@ -118,9 +125,9 @@ void TransformationGUI_TranslationDlg::Init() double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 ); /* min, max, step and decimals for spin boxes & initial values */ - initSpinBox( GroupPoints->SpinBox1, COORD_MIN, COORD_MAX, step, 3 ); - initSpinBox( GroupPoints->SpinBox2, COORD_MIN, COORD_MAX, step, 3 ); - initSpinBox( GroupPoints->SpinBox3, COORD_MIN, COORD_MAX, step, 3 ); + initSpinBox( GroupPoints->SpinBox1, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY + initSpinBox( GroupPoints->SpinBox2, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY + initSpinBox( GroupPoints->SpinBox3, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY GroupPoints->SpinBox1->setValue( 0.0 ); GroupPoints->SpinBox2->setValue( 0.0 ); @@ -165,6 +172,7 @@ void TransformationGUI_TranslationDlg::Init() //================================================================================= void TransformationGUI_TranslationDlg::ConstructorsClicked( int constructorId ) { + erasePreview(); disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); myEditCurrentArgument = GroupPoints->LineEdit1; @@ -229,7 +237,7 @@ bool TransformationGUI_TranslationDlg::ClickOnApply() return false; initName(); - ConstructorsClicked( getConstructorId() ); + return true; } @@ -271,14 +279,49 @@ void TransformationGUI_TranslationDlg::SelectionIntoArgument() if ( !testResult || CORBA::is_nil( aSelectedObject ) ) return; + TopoDS_Shape aShape; + aName = GEOMBase::GetName( aSelectedObject ); + if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { + TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; + if ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2 ) + aNeedType = TopAbs_EDGE; + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes( firstIObject(), aMap ); + if ( aMap.Extent() == 1 ) { + int anIndex = aMap( 1 ); + if ( aNeedType == TopAbs_EDGE ) + aName += QString( ":edge_%1" ).arg( anIndex ); + else + aName += QString( ":vertex_%1" ).arg( anIndex ); + + //Find SubShape Object in Father + GEOM::GEOM_Object_var aFindedObject = 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; + } + } + else { // Global Selection + if ( aShape.ShapeType() != aNeedType ) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + if ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1 ) myPoint1 = aSelectedObject; else if ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2 ) myVector = aSelectedObject; else if ( myEditCurrentArgument == GroupPoints->LineEdit3 ) - myPoint2 = aSelectedObject; - - aName = GEOMBase::GetName( aSelectedObject ); + myPoint2 = aSelectedObject; } myEditCurrentArgument->setText( aName ); @@ -308,19 +351,21 @@ void TransformationGUI_TranslationDlg::LineEditReturnPressed() void TransformationGUI_TranslationDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + globalSelection(); if ( send == GroupPoints->PushButton1 ) { myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection(); } else if ( send == GroupPoints->PushButton2 ) { myEditCurrentArgument = GroupPoints->LineEdit2; - getConstructorId() == 1 ? globalSelection( GEOM_POINT ) : - globalSelection( GEOM_LINE ); + if ( getConstructorId() == 1 ) + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + else + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } else if ( send == GroupPoints->PushButton3 ) { myEditCurrentArgument = GroupPoints->LineEdit3; - globalSelection( GEOM_POINT ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); } myEditCurrentArgument->setFocus(); @@ -335,6 +380,7 @@ void TransformationGUI_TranslationDlg::SetEditCurrentArgument() void TransformationGUI_TranslationDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); + connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); @@ -369,7 +415,7 @@ void TransformationGUI_TranslationDlg::ValueChangedInSpinBox() //================================================================================= GEOM::GEOM_IOperations_ptr TransformationGUI_TranslationDlg::createOperation() { - return myGeomGUI->GetGeomGen()->GetITransformOperations( getStudyId() ); + return getGeomEngine()->GetITransformOperations( getStudyId() ); } @@ -476,21 +522,35 @@ bool TransformationGUI_TranslationDlg::execute( ObjectList& objects ) //================================================================================= -// function : closeEvent +// function : CreateCopyModeChanged() // purpose : //================================================================================= -void TransformationGUI_TranslationDlg::closeEvent( QCloseEvent* e ) +void TransformationGUI_TranslationDlg::CreateCopyModeChanged( bool isCreateCopy ) { - // myGeomGUI->SetState( -1 ); - GEOMBase_Skeleton::closeEvent( e ); + mainFrame()->GroupBoxName->setEnabled( isCreateCopy ); } - //================================================================================= -// function : CreateCopyModeChanged() -// purpose : +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection //================================================================================= -void TransformationGUI_TranslationDlg::CreateCopyModeChanged( bool isCreateCopy ) +void TransformationGUI_TranslationDlg::addSubshapesToStudy() { - mainFrame()->GroupBoxName->setEnabled( isCreateCopy ); + bool toCreateCopy = IsPreview() || GroupPoints->CheckBox1->isChecked(); + if ( toCreateCopy ) { + QMap objMap; + + switch ( getConstructorId() ) { + case 0: + return; + case 1: + objMap[GroupPoints->LineEdit2->text()] = myPoint1; + objMap[GroupPoints->LineEdit3->text()] = myPoint2; + break; + case 2: + objMap[GroupPoints->LineEdit2->text()] = myVector; + break; + } + addSubshapesToFather( objMap ); + } }