X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPrimitiveGUI%2FPrimitiveGUI_SphereDlg.cxx;h=8b0dbb107526521b67a65eca33012403319bdf39;hb=a6b86fc40dddf212f4e71821d6156f298939c7ca;hp=debdb9a8551d7afd8d4baaf3feafc2ae457f32a3;hpb=e180c20f73ffa96c2d039106f2a2a868c8bc0df1;p=modules%2Fgeom.git diff --git a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx index debdb9a85..8b0dbb107 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -33,6 +33,12 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" +#include +#include +#include +#include +#include + #include #include "GEOMImpl_Types.hxx" @@ -79,12 +85,11 @@ PrimitiveGUI_SphereDlg::PrimitiveGUI_SphereDlg(GeometryGUI* theGeometryGUI, QWid Layout1->addWidget(GroupDimensions, 2, 0); /***************************************************************/ - setHelpFileName("sphere.htm"); + setHelpFileName("create_sphere_page.html"); Init(); } - //================================================================================= // function : ~PrimitiveGUI_SphereDlg() // purpose : Destroys the object and frees any allocated resources @@ -94,7 +99,6 @@ PrimitiveGUI_SphereDlg::~PrimitiveGUI_SphereDlg() /* no need to delete child widgets, Qt does it all for us */ } - //================================================================================= // function : Init() // purpose : @@ -112,8 +116,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, 999.999, step, 3); - GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, 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); @@ -128,30 +132,32 @@ void PrimitiveGUI_SphereDlg::Init() connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); 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)), GroupDimensions->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupPoints->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupDimensions->SpinBox_DX, SLOT(SetStep(double))); - 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_SPHERE")); ConstructorsClicked(0); } - //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void PrimitiveGUI_SphereDlg::ConstructorsClicked(int constructorId) +void PrimitiveGUI_SphereDlg::ConstructorsClicked (int constructorId) { - disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0); - + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + switch (constructorId) { case 0: { - globalSelection( GEOM_POINT ); + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); GroupDimensions->hide(); resize(0, 0); GroupPoints->show(); @@ -160,13 +166,14 @@ void PrimitiveGUI_SphereDlg::ConstructorsClicked(int constructorId) GroupPoints->LineEdit1->setText(""); myPoint = GEOM::GEOM_Object::_nil(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break; } case 1: { GroupPoints->hide(); + globalSelection(); // close local contexts, if any resize(0, 0); GroupDimensions->show(); @@ -176,7 +183,6 @@ void PrimitiveGUI_SphereDlg::ConstructorsClicked(int constructorId) displayPreview(); } - //================================================================================= // function : ClickOnOk() // purpose : @@ -187,7 +193,6 @@ void PrimitiveGUI_SphereDlg::ClickOnOk() ClickOnCancel(); } - //================================================================================= // function : ClickOnApply() // purpose : @@ -202,49 +207,77 @@ bool PrimitiveGUI_SphereDlg::ClickOnApply() return true; } - - -//======================================================================= +//================================================================================= // function : ClickOnCancel() // purpose : -//======================================================================= +//================================================================================= void PrimitiveGUI_SphereDlg::ClickOnCancel() { GEOMBase_Skeleton::ClickOnCancel(); } - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed or other case //================================================================================= void PrimitiveGUI_SphereDlg::SelectionIntoArgument() { - if ( getConstructorId() != 0 ) + if (getConstructorId() != 0) return; - + myEditCurrentArgument->setText(""); - - if(IObjectCount() != 1) - { - myPoint = GEOM::GEOM_Object::_nil(); - return; - } - + + if (IObjectCount() != 1) + { + myPoint = GEOM::GEOM_Object::_nil(); + return; + } + /* nbSel == 1 ! */ Standard_Boolean testResult = Standard_False; - GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult ); - - if (!testResult || CORBA::is_nil( aSelectedObject )) + GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult); + + if (!testResult || CORBA::is_nil(aSelectedObject)) return; - + + 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.append( ":vertex_" + QString::number( 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; // get Object from study + } + else // Global Selection + { + if (aShape.ShapeType() != TopAbs_VERTEX) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + + myEditCurrentArgument->setText(aName); myPoint = aSelectedObject; - myEditCurrentArgument->setText( GEOMBase::GetName( myPoint ) ); - + displayPreview(); } - //================================================================================= // function : LineEditReturnPressed() // purpose : @@ -259,7 +292,6 @@ void PrimitiveGUI_SphereDlg::LineEditReturnPressed() } } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -268,15 +300,15 @@ void PrimitiveGUI_SphereDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - if(send == GroupPoints->PushButton1) { + if (send == GroupPoints->PushButton1) { GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; - globalSelection( GEOM_POINT ); + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); SelectionIntoArgument(); } } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -284,12 +316,11 @@ void PrimitiveGUI_SphereDlg::SetEditCurrentArgument() void PrimitiveGUI_SphereDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - ConstructorsClicked( getConstructorId() ); -} + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + ConstructorsClicked(getConstructorId()); +} //================================================================================= // function : DeactivateActiveDialog() @@ -300,7 +331,6 @@ void PrimitiveGUI_SphereDlg::DeactivateActiveDialog() GEOMBase_Skeleton::DeactivateActiveDialog(); } - //================================================================================= // function : enterEvent() // purpose : @@ -311,7 +341,6 @@ void PrimitiveGUI_SphereDlg::enterEvent(QEvent* e) ActivateThisDialog(); } - //================================================================================= // function : ValueChangedInSpinBox() // purpose : @@ -321,7 +350,6 @@ void PrimitiveGUI_SphereDlg::ValueChangedInSpinBox() displayPreview(); } - //================================================================================= // function : createOperation // purpose : @@ -331,7 +359,6 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_SphereDlg::createOperation() return getGeomEngine()->GetI3DPrimOperations( getStudyId() ); } - //================================================================================= // function : isValid // purpose : @@ -345,33 +372,35 @@ bool PrimitiveGUI_SphereDlg::isValid( QString& msg ) // function : execute // purpose : //================================================================================= -bool PrimitiveGUI_SphereDlg::execute( ObjectList& objects ) +bool PrimitiveGUI_SphereDlg::execute (ObjectList& objects) { bool res = false; - + GEOM::GEOM_Object_var anObj; - switch ( getConstructorId() ) + switch (getConstructorId()) { - case 0 : + case 0: { - if ( !CORBA::is_nil( myPoint ) ) { - anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeSpherePntR( myPoint, getRadius() ); + if (!CORBA::is_nil(myPoint)) { + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )-> + MakeSpherePntR(myPoint, getRadius()); res = true; } break; } - case 1 : + case 1: { - anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeSphereR( getRadius() ); + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )-> + MakeSphereR(getRadius()); res = true; break; } } - - if ( !anObj->_is_nil() ) - objects.push_back( anObj._retn() ); - + + if (!anObj->_is_nil()) + objects.push_back(anObj._retn()); + return res; } @@ -381,12 +410,9 @@ bool PrimitiveGUI_SphereDlg::execute( ObjectList& objects ) //================================================================================= void PrimitiveGUI_SphereDlg::closeEvent( QCloseEvent* e ) { - //myGeomGUI->SetState( -1 ); GEOMBase_Skeleton::closeEvent( e ); } - - //================================================================================= // function : getRadius() // purpose : @@ -400,3 +426,22 @@ double PrimitiveGUI_SphereDlg::getRadius() const return GroupDimensions->SpinBox_DX->GetValue(); return 0; } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void PrimitiveGUI_SphereDlg::addSubshapesToStudy() +{ + QMap objMap; + +switch (getConstructorId()) + { + case 0: + objMap[GroupPoints->LineEdit1->text()] = myPoint; + break; + case 1: + return; + } + addSubshapesToFather( objMap ); +}