X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FBasicGUI%2FBasicGUI_PointDlg.cxx;h=9d92f5b99c917ed22331aa72e3add89c7038cf9b;hb=adc67f3fdfb1c37fcd426b58d24b7aa1e7596ed3;hp=df16f8730900db53f5788348ee3630e55e044f80;hpb=e180c20f73ffa96c2d039106f2a2a868c8bc0df1;p=modules%2Fgeom.git diff --git a/src/BasicGUI/BasicGUI_PointDlg.cxx b/src/BasicGUI/BasicGUI_PointDlg.cxx index df16f8730..9d92f5b99 100644 --- a/src/BasicGUI/BasicGUI_PointDlg.cxx +++ b/src/BasicGUI/BasicGUI_PointDlg.cxx @@ -1,31 +1,30 @@ -// GEOM GEOMGUI : GUI for Geometry component +// Copyright (C) 2007-2008 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 // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// 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 +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // +// You should have received a copy of the GNU Lesser General Public +// 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 +// +// GEOM GEOMGUI : GUI for Geometry component // File : BasicGUI_PointDlg.cxx // Author : Lucien PIGNOLONI // Module : GEOM // $Header$ - +// #include "BasicGUI_PointDlg.h" #include "SUIT_Session.h" @@ -49,10 +48,12 @@ #include #include + using namespace std; + //================================================================================= // class : BasicGUI_PointDlg() -// purpose : Constructs a BasicGUI_PointDlg which is a child of 'parent', with the +// purpose : Constructs a BasicGUI_PointDlg 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. @@ -65,6 +66,8 @@ BasicGUI_PointDlg::BasicGUI_PointDlg(GeometryGUI* theGeometryGUI, QWidget* paren QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_POINT_EDGE"))); QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT"))); QPixmap image3(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_POINT_REF"))); + QPixmap image4(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_POINT_LINES"))); + QPixmap image5(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_POINT_FACE"))); setCaption(tr("GEOM_POINT_TITLE")); @@ -77,6 +80,10 @@ BasicGUI_PointDlg::BasicGUI_PointDlg(GeometryGUI* theGeometryGUI, QWidget* paren RadioButton1->setPixmap(image0); RadioButton2->setPixmap(image3); RadioButton3->setPixmap(image1); + RadioButton4->show(); + RadioButton4->setPixmap(image4); + RadioButton5->show(); + RadioButton5->setPixmap(image5); GroupXYZ = new DlgRef_3Spin( aFrame, "GroupXYZ" ); GroupXYZ->GroupBox1->setTitle(tr("GEOM_COORDINATES")); @@ -90,6 +97,13 @@ BasicGUI_PointDlg::BasicGUI_PointDlg(GeometryGUI* theGeometryGUI, QWidget* paren GroupOnCurve->TextLabel2->setText(tr("GEOM_PARAMETER")); GroupOnCurve->PushButton1->setPixmap(image2); + GroupOnSurface = new DlgRef_1Sel2Spin( aFrame, "GroupOnSurface" ); + GroupOnSurface->GroupBox1->setTitle(tr("GEOM_PARAM_POINT")); + GroupOnSurface->TextLabel1->setText(tr("GEOM_FACE")); + GroupOnSurface->TextLabel2->setText(tr("GEOM_UPARAMETER")); + GroupOnSurface->TextLabel3->setText(tr("GEOM_VPARAMETER")); + GroupOnSurface->PushButton1->setPixmap(image2); + GroupRefPoint = new DlgRef_1Sel3Spin( aFrame, "GoupRefPoint" ); GroupRefPoint->GroupBox1->setTitle(tr("GEOM_REF_POINT")); GroupRefPoint->TextLabel1->setText(tr("GEOM_POINT")); @@ -98,6 +112,13 @@ BasicGUI_PointDlg::BasicGUI_PointDlg(GeometryGUI* theGeometryGUI, QWidget* paren GroupRefPoint->TextLabel3->setText(tr("GEOM_DY")); GroupRefPoint->TextLabel4->setText(tr("GEOM_DZ")); + GroupLineIntersection = new DlgRef_2Sel_QTD (aFrame, "GroupLineIntersection"); + GroupLineIntersection->GroupBox1->setTitle(tr("GEOM_LINE_INTERSECTION")); + GroupLineIntersection->TextLabel1->setText(tr("GEOM_LINE1")); + GroupLineIntersection->PushButton1->setPixmap(image2); + GroupLineIntersection->TextLabel2->setText(tr("GEOM_LINE2")); + GroupLineIntersection->PushButton2->setPixmap(image2); + Layout1->addWidget( aFrame, 2, 0 ); /***************************************************************/ @@ -123,12 +144,11 @@ BasicGUI_PointDlg::BasicGUI_PointDlg(GeometryGUI* theGeometryGUI, QWidget* paren myY->setPalette( aPal ); myZ->setPalette( aPal ); - setHelpFileName("point.htm"); - + setHelpFileName("create_point_page.html"); + Init(); } - //================================================================================= // function : ~BasicGUI_PointDlg() // purpose : Destructor @@ -137,7 +157,6 @@ BasicGUI_PointDlg::~BasicGUI_PointDlg() { } - //================================================================================= // function : Init() // purpose : @@ -145,7 +164,10 @@ BasicGUI_PointDlg::~BasicGUI_PointDlg() void BasicGUI_PointDlg::Init() { GroupOnCurve->LineEdit1->setReadOnly( true ); + GroupOnSurface->LineEdit1->setReadOnly( true ); GroupRefPoint->LineEdit1->setReadOnly( true ); + GroupLineIntersection->LineEdit1->setReadOnly( true ); + GroupLineIntersection->LineEdit2->setReadOnly( true ); myEdge = GEOM::GEOM_Object::_nil(); myRefPoint = GEOM::GEOM_Object::_nil(); @@ -155,26 +177,31 @@ void BasicGUI_PointDlg::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 */ - GroupXYZ->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); - GroupXYZ->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); - GroupXYZ->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupXYZ->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); + GroupXYZ->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); + GroupXYZ->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); GroupXYZ->SpinBox_DX->SetValue(0.0); GroupXYZ->SpinBox_DY->SetValue(0.0); GroupXYZ->SpinBox_DZ->SetValue(0.0); - GroupRefPoint->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); - GroupRefPoint->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); - GroupRefPoint->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupRefPoint->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); + GroupRefPoint->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); + GroupRefPoint->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); GroupRefPoint->SpinBox_DX->SetValue(0.0); GroupRefPoint->SpinBox_DY->SetValue(0.0); GroupRefPoint->SpinBox_DZ->SetValue(0.0); step = 0.1; - GroupOnCurve->SpinBox_DX->RangeStepAndValidator(0., 1., step, 3); + GroupOnCurve->SpinBox_DX->RangeStepAndValidator(0., 1., step, DBL_DIGITS_DISPLAY); GroupOnCurve->SpinBox_DX->SetValue( 0.5 ); + GroupOnSurface->SpinBox_DX->RangeStepAndValidator(0., 1., step, DBL_DIGITS_DISPLAY); + GroupOnSurface->SpinBox_DX->SetValue( 0.5 ); + GroupOnSurface->SpinBox_DY->RangeStepAndValidator(0., 1., step, DBL_DIGITS_DISPLAY); + GroupOnSurface->SpinBox_DY->SetValue( 0.5 ); + /* signals and slots connections */ connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); @@ -186,8 +213,16 @@ void BasicGUI_PointDlg::Init() connect(GroupOnCurve->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupOnCurve->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupOnSurface->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupOnSurface->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupLineIntersection->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupLineIntersection->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupLineIntersection->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupLineIntersection->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupOnCurve->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupOnSurface->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupOnSurface->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); connect(GroupXYZ->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); connect(GroupXYZ->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); connect(GroupXYZ->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); @@ -195,40 +230,52 @@ void BasicGUI_PointDlg::Init() connect(GroupRefPoint->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); connect(GroupRefPoint->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupOnCurve->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupXYZ->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupXYZ->SpinBox_DY, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupXYZ->SpinBox_DZ, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupRefPoint->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupRefPoint->SpinBox_DY, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupRefPoint->SpinBox_DZ, SLOT(SetStep(double))); - - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupOnCurve->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupOnSurface->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupOnSurface->SpinBox_DY, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupXYZ->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupXYZ->SpinBox_DY, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupXYZ->SpinBox_DZ, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupRefPoint->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupRefPoint->SpinBox_DY, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), + GroupRefPoint->SpinBox_DZ, SLOT(SetStep(double))); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + initName( tr("GEOM_VERTEX") ); - + ConstructorsClicked( 0 ); } - //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) -{ - switch ( constructorId ) +void BasicGUI_PointDlg::ConstructorsClicked (int constructorId) +{ + globalSelection(); // close local contexts, if any + + switch (constructorId) { case 0: { - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); GroupRefPoint->hide(); GroupOnCurve->hide(); - + GroupLineIntersection->hide(); GroupXYZ->show(); - + GroupOnSurface->hide(); myCoordGrp->hide(); break; } @@ -238,13 +285,13 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) myEditCurrentArgument->setText(""); myRefPoint = GEOM::GEOM_Object::_nil(); - globalSelection( GEOM_POINT ); + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); GroupXYZ->hide(); GroupOnCurve->hide(); - GroupRefPoint->show(); - + GroupLineIntersection->hide(); + GroupOnSurface->hide(); myCoordGrp->show(); break; } @@ -254,13 +301,47 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) myEditCurrentArgument->setText(""); myEdge = GEOM::GEOM_Object::_nil(); - globalSelection( GEOM_EDGE ); + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); GroupXYZ->hide(); GroupRefPoint->hide(); - GroupOnCurve->show(); - + GroupLineIntersection->hide(); + GroupOnSurface->hide(); + myCoordGrp->show(); + break; + } + case 3: + { + myEditCurrentArgument = GroupLineIntersection->LineEdit1; + GroupLineIntersection->LineEdit1->setText(""); + GroupLineIntersection->LineEdit2->setText(""); + myLine1 = GEOM::GEOM_Object::_nil(); + myLine2 = GEOM::GEOM_Object::_nil(); + + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); + + GroupXYZ->hide(); + GroupRefPoint->hide(); + GroupOnCurve->hide(); + GroupLineIntersection->show(); + GroupOnSurface->hide(); + myCoordGrp->hide(); + break; + } + case 4: + { + myEditCurrentArgument = GroupOnSurface->LineEdit1; + myEditCurrentArgument->setText(""); + myFace = GEOM::GEOM_Object::_nil(); + + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_FACE); + + GroupXYZ->hide(); + GroupRefPoint->hide(); + GroupOnCurve->hide(); + GroupLineIntersection->hide(); + GroupOnSurface->show(); myCoordGrp->show(); break; } @@ -277,33 +358,30 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) SelectionIntoArgument(); } - //================================================================================= // function : ClickOnOk() // purpose : //================================================================================= void BasicGUI_PointDlg::ClickOnOk() { - if ( onAccept() ) + if (onAccept()) ClickOnCancel(); } - //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= bool BasicGUI_PointDlg::ClickOnApply() { - if ( !onAccept() ) + if (!onAccept()) return false; - + initName(); - ConstructorsClicked( getConstructorId() ); + ConstructorsClicked(getConstructorId()); return true; } - //================================================================================= // function : ClickOnCancel() // purpose : @@ -313,7 +391,6 @@ void BasicGUI_PointDlg::ClickOnCancel() GEOMBase_Skeleton::ClickOnCancel(); } - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed (for constructors not using local context) @@ -322,65 +399,98 @@ void BasicGUI_PointDlg::SelectionIntoArgument() { const int id = getConstructorId(); - if ( ( id == 1 || id == 2 ) && myEditCurrentArgument != 0 ) + if ((id == 1 || id == 2 || id == 4 ) && myEditCurrentArgument != 0) { myEditCurrentArgument->setText(""); myX->setText( "" ); myY->setText( "" ); myZ->setText( "" ); - myRefPoint = myEdge = GEOM::GEOM_Object::_nil(); + myRefPoint = myEdge = myFace = GEOM::GEOM_Object::_nil(); } - if ( IObjectCount() == 1 ) + if (IObjectCount() == 1) { Standard_Boolean aRes = Standard_False; Handle(SALOME_InteractiveObject) anIO = firstIObject(); - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); - if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(anIO, aRes); + if (!CORBA::is_nil(aSelectedObject) && aRes) { - if ( id == 0 ) + QString aName = GEOMBase::GetName(aSelectedObject); + TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; + TopoDS_Shape aShape; + if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) { - // get CORBA reference to data object - TopoDS_Shape aShape = myGeomGUI->GetShapeReader().GetShape - ( myGeomGUI->GetGeomGen(), aSelectedObject ); - if ( aShape.IsNull() ) - return; - - if ( aShape.ShapeType() != TopAbs_VERTEX ) + if (id == 2 || id == 3) + aNeedType = TopAbs_EDGE; + if(id == 4) + aNeedType = TopAbs_FACE; + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes(firstIObject(), aMap); + if (aMap.Extent() == 1) // Local Selection { - TColStd_IndexedMapOfInteger aMap; - LightApp_Application* anApp = - (LightApp_Application*)(SUIT_Session::session()->activeApplication()); - anApp->selectionMgr()->GetIndexes( anIO, aMap ); - - if ( aMap.Extent() == 1 ) - { - int anIndex = aMap( 1 ); - TopTools_IndexedMapOfShape aShapes; - TopExp::MapShapes( aShape, aShapes ); - aShape = aShapes.FindKey( anIndex ); - - if ( aShape.IsNull() || aShape.ShapeType() != TopAbs_VERTEX ) - return; - } + int anIndex = aMap(1); + if (aNeedType == TopAbs_EDGE) + aName += QString(":edge_%1").arg(anIndex); else - return; + 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 + GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE); + } + else // Global Selection + { + if (aShape.ShapeType() != aNeedType) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + if (id == 0) return; + } } + } + if (id == 0) + { + if (aShape.IsNull() || aShape.ShapeType() != aNeedType) + return; gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); GroupXYZ->SpinBox_DX->SetValue( aPnt.X() ); GroupXYZ->SpinBox_DY->SetValue( aPnt.Y() ); GroupXYZ->SpinBox_DZ->SetValue( aPnt.Z() ); } - else if ( id == 1 ) + else if (id == 1) { myRefPoint = aSelectedObject; - GroupRefPoint->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) ); + GroupRefPoint->LineEdit1->setText(aName); } - else if ( id == 2 ) + else if (id == 2) { myEdge = aSelectedObject; - GroupOnCurve->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) ); + GroupOnCurve->LineEdit1->setText(aName); + } + else if (id == 3) + { + if (myEditCurrentArgument == GroupLineIntersection->LineEdit1) { + myLine1 = aSelectedObject; + myEditCurrentArgument->setText(aName); + } + else if (myEditCurrentArgument == GroupLineIntersection->LineEdit2) { + myLine2 = aSelectedObject; + myEditCurrentArgument->setText(aName); + } + } + else if (id == 4) + { + myFace = aSelectedObject; + GroupOnSurface->LineEdit1->setText(aName); } } } @@ -388,7 +498,6 @@ void BasicGUI_PointDlg::SelectionIntoArgument() displayPreview(); } - //================================================================================= // function : LineEditReturnPressed() // purpose : @@ -396,38 +505,61 @@ void BasicGUI_PointDlg::SelectionIntoArgument() void BasicGUI_PointDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if ( send == GroupRefPoint->LineEdit1 || send == GroupOnCurve->LineEdit1 ) - { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } + if ( send == GroupRefPoint->LineEdit1 || send == GroupOnCurve->LineEdit1 || + send == GroupLineIntersection->LineEdit1 || send == GroupLineIntersection->LineEdit2 ) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } - //================================================================================= // function : SetEditCurrentArgument() // purpose : //================================================================================= void BasicGUI_PointDlg::SetEditCurrentArgument() { + globalSelection(); // close local contexts, if any + QPushButton* send = (QPushButton*)sender(); + globalSelection( GEOM_POINT); // to break previous local selection if ( send == GroupRefPoint->PushButton1 ) { GroupRefPoint->LineEdit1->setFocus(); myEditCurrentArgument = GroupRefPoint->LineEdit1; - - globalSelection( GEOM_POINT ); + + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); } else if ( send == GroupOnCurve->PushButton1 ) { GroupOnCurve->LineEdit1->setFocus(); myEditCurrentArgument = GroupOnCurve->LineEdit1; - - globalSelection( GEOM_EDGE ); + + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } -} + else if ( send == GroupOnSurface->PushButton1 ) + { + GroupOnSurface->LineEdit1->setFocus(); + myEditCurrentArgument = GroupOnSurface->LineEdit1; + + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE ); + } + else if ( send == GroupLineIntersection->PushButton1 ) + { + GroupLineIntersection->LineEdit1->setFocus(); + myEditCurrentArgument = GroupLineIntersection->LineEdit1; + + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + } + else if ( send == GroupLineIntersection->PushButton2 ) + { + GroupLineIntersection->LineEdit2->setFocus(); + myEditCurrentArgument = GroupLineIntersection->LineEdit2; + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + } +} //================================================================================= // function : enterEvent() @@ -439,7 +571,6 @@ void BasicGUI_PointDlg::enterEvent(QEvent* e) ActivateThisDialog(); } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -451,7 +582,6 @@ void BasicGUI_PointDlg::ActivateThisDialog( ) ConstructorsClicked( getConstructorId() ); } - //================================================================================= // function : DeactivateActiveDialog() // purpose : public slot to deactivate if active @@ -462,7 +592,6 @@ void BasicGUI_PointDlg::DeactivateActiveDialog() GEOMBase_Skeleton::DeactivateActiveDialog(); } - //================================================================================= // function : ValueChangedInSpinBox() // purpose : @@ -481,6 +610,27 @@ double BasicGUI_PointDlg::getParameter() const return GroupOnCurve->SpinBox_DX->GetValue(); } + +//================================================================================= +// funcion : getUParameter() +// purpose : +//================================================================================= +double BasicGUI_PointDlg::getUParameter() const +{ + return GroupOnSurface->SpinBox_DX->GetValue(); +} + + +//================================================================================= +// funcion : getVParameter() +// purpose : +//================================================================================= +double BasicGUI_PointDlg::getVParameter() const +{ + return GroupOnSurface->SpinBox_DY->GetValue(); +} + + //================================================================================= // function : OnPointSelected // purpose : @@ -519,6 +669,10 @@ bool BasicGUI_PointDlg::isValid( QString& msg ) return !myRefPoint->_is_nil(); else if ( id == 2 ) return !myEdge->_is_nil(); + else if ( id == 3) + return ( !myLine1->_is_nil() && !myLine2->_is_nil() ); + else if ( id == 4 ) + return !myFace->_is_nil(); return false; } @@ -539,7 +693,7 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) double x = GroupXYZ->SpinBox_DX->GetValue(); double y = GroupXYZ->SpinBox_DY->GetValue(); double z = GroupXYZ->SpinBox_DZ->GetValue(); - + anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePointXYZ( x,y,z ); res = true; break; @@ -549,7 +703,7 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) double dx = GroupRefPoint->SpinBox_DX->GetValue(); double dy = GroupRefPoint->SpinBox_DY->GetValue(); double dz = GroupRefPoint->SpinBox_DZ->GetValue(); - + anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )-> MakePointWithReference( myRefPoint, dx, dy, dz ); res = true; @@ -560,26 +714,35 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) MakePointOnCurve( myEdge, getParameter() ); res = true; break; + case 3 : + anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )-> + MakePointOnLinesIntersection( myLine1, myLine2 ); + res = true; + break; + case 4 : + anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )-> + MakePointOnSurface( myFace, getUParameter(), getVParameter() ); + res = true; + break; } - if ( getConstructorId() == 1 || getConstructorId() == 2 ) - { + if ( getConstructorId() == 1 || getConstructorId() == 2 || + getConstructorId() == 4 ) { TopoDS_Shape aShape; - if ( GEOMBase::GetShape( anObj, aShape ) && !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) - { + if ( GEOMBase::GetShape( anObj, aShape ) && !aShape.IsNull() && + aShape.ShapeType() == TopAbs_VERTEX ) { gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); myX->setText( QString( "%1" ).arg( aPnt.X() ) ); myY->setText( QString( "%1" ).arg( aPnt.Y() ) ); myZ->setText( QString( "%1" ).arg( aPnt.Z() ) ); } - else - { + else { myX->setText( "" ); myY->setText( "" ); myZ->setText( "" ); } } - + if ( !anObj->_is_nil() ) { //printf( "--> a valid point is created\n" ); @@ -597,3 +760,32 @@ void BasicGUI_PointDlg::closeEvent( QCloseEvent* e ) { GEOMBase_Skeleton::closeEvent( e ); } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void BasicGUI_PointDlg::addSubshapesToStudy() +{ + QMap objMap; + + switch (getConstructorId()) + { + case 0: + break; + case 1: + objMap[GroupRefPoint->LineEdit1->text()] = myRefPoint; + break; + case 2: + objMap[GroupOnCurve->LineEdit1->text()] = myEdge; + break; + case 3: + objMap[GroupLineIntersection->LineEdit1->text()] = myLine1; + objMap[GroupLineIntersection->LineEdit2->text()] = myLine2; + break; + case 4: + objMap[GroupOnSurface->LineEdit1->text()] = myFace; + break; + } + addSubshapesToFather( objMap ); +}