X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FPrimitiveGUI%2FPrimitiveGUI_SphereDlg.cxx;h=84230fdc63e8b5340eb5c5027e15f93d61e852c2;hb=46574ac4f48a11f2161e754fe7c8df8684bc2b78;hp=6fc293005d19334c908758395155505f43bb890a;hpb=392885c1a8d50369708bbe5e6b44033ed8b8ba51;p=modules%2Fgeom.git diff --git a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx index 6fc293005..84230fdc6 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -19,6 +19,7 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // GEOM GEOMGUI : GUI for Geometry component // File : PrimitiveGUI_SphereDlg.cxx // Author : Lucien PIGNOLONI, Open CASCADE S.A.S. @@ -50,7 +51,7 @@ // TRUE to construct a modal dialog. //================================================================================= PrimitiveGUI_SphereDlg::PrimitiveGUI_SphereDlg( GeometryGUI* theGeometryGUI, QWidget* parent, - bool modal, Qt::WindowFlags fl ) + bool modal, Qt::WindowFlags fl ) :GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl ) { QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_SPHERE_P" ) ) ); @@ -108,15 +109,15 @@ void PrimitiveGUI_SphereDlg::Init() myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setReadOnly( true ); - myPoint = GEOM::GEOM_Object::_nil(); + myPoint.nullify(); /* 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( GroupPoints->SpinBox_DX, 0.000001, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY - initSpinBox( GroupDimensions->SpinBox_DX, 0.000001, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY + initSpinBox( GroupPoints->SpinBox_DX, 0.000001, COORD_MAX, step, "length_precision" ); + initSpinBox( GroupDimensions->SpinBox_DX, 0.000001, COORD_MAX, step, "length_precision" ); GroupPoints->SpinBox_DX->setValue( 100.0 ); GroupDimensions->SpinBox_DX->setValue( 100.0 ); @@ -127,7 +128,6 @@ void PrimitiveGUI_SphereDlg::Init() connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) ); connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect( GroupDimensions->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) ); connect( GroupPoints->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) ); @@ -135,7 +135,7 @@ void PrimitiveGUI_SphereDlg::Init() connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) ); connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), - this, SLOT( SelectionIntoArgument() ) ); + this, SLOT( SelectionIntoArgument() ) ); initName( tr( "GEOM_SPHERE" ) ); @@ -172,10 +172,10 @@ void PrimitiveGUI_SphereDlg::ConstructorsClicked( int constructorId ) myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setText( "" ); - myPoint = GEOM::GEOM_Object::_nil(); + myPoint.nullify(); connect( myGeomGUI->getApp()->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); break; } case 1: @@ -192,8 +192,9 @@ void PrimitiveGUI_SphereDlg::ConstructorsClicked( int constructorId ) qApp->processEvents(); updateGeometry(); resize( minimumSizeHint() ); + SelectionIntoArgument(); - displayPreview(); + displayPreview(true); } @@ -239,66 +240,21 @@ void PrimitiveGUI_SphereDlg::SelectionIntoArgument() aSelMgr->selectedObjects(aSelList); if (aSelList.Extent() != 1) { - myPoint = GEOM::GEOM_Object::_nil(); + myPoint.nullify(); return; } - /* nbSel == 1 ! */ - Standard_Boolean testResult = Standard_False; - GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult); - - if ( !testResult || CORBA::is_nil( aSelectedObject ) ) - return; - - QString aName = GEOMBase::GetName( aSelectedObject ); + GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_VERTEX ); TopoDS_Shape aShape; - if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull() ) { - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes(aSelList.First(), 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 = ""; - } - } + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); + myEditCurrentArgument->setText( aName ); + myPoint = aSelectedObject; } - myEditCurrentArgument->setText( aName ); - myPoint = aSelectedObject; - - displayPreview(); + displayPreview(true); } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void PrimitiveGUI_SphereDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if ( send == GroupPoints->LineEdit1 ) { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } -} - - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -325,7 +281,7 @@ void PrimitiveGUI_SphereDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), - this, SLOT( SelectionIntoArgument() ) ); + this, SLOT( SelectionIntoArgument() ) ); ConstructorsClicked( getConstructorId() ); } @@ -358,7 +314,7 @@ void PrimitiveGUI_SphereDlg::enterEvent( QEvent* ) //================================================================================= void PrimitiveGUI_SphereDlg::ValueChangedInSpinBox() { - displayPreview(); + displayPreview(true); } @@ -378,12 +334,12 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_SphereDlg::createOperation() //================================================================================= bool PrimitiveGUI_SphereDlg::isValid( QString& msg ) { - bool ok = true; + bool ok = false; if( getConstructorId() == 0 ) - ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; + ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && myPoint; else if( getConstructorId() == 1 ) - ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - return getConstructorId() == 0 ? !myPoint->_is_nil() && ok : ok; + ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ); + return ok; } //================================================================================= @@ -396,29 +352,31 @@ bool PrimitiveGUI_SphereDlg::execute( ObjectList& objects ) GEOM::GEOM_Object_var anObj; + GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation()); + switch ( getConstructorId() ) { case 0 : { - if ( !CORBA::is_nil( myPoint ) ) { - anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeSpherePntR( myPoint, getRadius() ); - if (!anObj->_is_nil() && !IsPreview()) + if ( myPoint ) { + anObj = anOper->MakeSpherePntR( myPoint.get(), getRadius() ); + if (!anObj->_is_nil() && !IsPreview()) { - QStringList aParameters; - aParameters << GroupPoints->SpinBox_DX->text(); - anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); - } - res = true; + QStringList aParameters; + aParameters << GroupPoints->SpinBox_DX->text(); + anObj->SetParameters(aParameters.join(":").toLatin1().constData()); + } + res = true; } break; } case 1 : { - anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeSphereR( getRadius() ); + anObj = anOper->MakeSphereR( getRadius() ); if (!anObj->_is_nil() && !IsPreview()) { - QStringList aParameters; - aParameters << GroupDimensions->SpinBox_DX->text(); - anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); + QStringList aParameters; + aParameters << GroupDimensions->SpinBox_DX->text(); + anObj->SetParameters(aParameters.join(":").toLatin1().constData()); } res = true; break; @@ -452,14 +410,7 @@ double PrimitiveGUI_SphereDlg::getRadius() const //================================================================================= void PrimitiveGUI_SphereDlg::addSubshapesToStudy() { - QMap objMap; - - switch ( getConstructorId() ) { - case 0: - objMap[GroupPoints->LineEdit1->text()] = myPoint; - break; - case 1: - return; + if ( getConstructorId() == 0 ) { + GEOMBase::PublishSubObject( myPoint.get() ); } - addSubshapesToFather( objMap ); }