diff --git a/doc/salome/gui/GEOM/images/neo-scetcher1.png b/doc/salome/gui/GEOM/images/neo-scetcher1.png index 23ec1f3e6..d0d5d7132 100755 Binary files a/doc/salome/gui/GEOM/images/neo-scetcher1.png and b/doc/salome/gui/GEOM/images/neo-scetcher1.png differ diff --git a/doc/salome/gui/GEOM/images/neo-scetcher2.png b/doc/salome/gui/GEOM/images/neo-scetcher2.png index 837031035..9097ffc07 100755 Binary files a/doc/salome/gui/GEOM/images/neo-scetcher2.png and b/doc/salome/gui/GEOM/images/neo-scetcher2.png differ diff --git a/doc/salome/gui/GEOM/images/plane1.png b/doc/salome/gui/GEOM/images/plane1.png index aaf7f12d5..e336b7a2e 100755 Binary files a/doc/salome/gui/GEOM/images/plane1.png and b/doc/salome/gui/GEOM/images/plane1.png differ diff --git a/doc/salome/gui/GEOM/images/plane2.png b/doc/salome/gui/GEOM/images/plane2.png index 3644d6b38..5c202409e 100755 Binary files a/doc/salome/gui/GEOM/images/plane2.png and b/doc/salome/gui/GEOM/images/plane2.png differ diff --git a/doc/salome/gui/GEOM/images/plane3.png b/doc/salome/gui/GEOM/images/plane3.png index b815f8d0d..18c9f8088 100755 Binary files a/doc/salome/gui/GEOM/images/plane3.png and b/doc/salome/gui/GEOM/images/plane3.png differ diff --git a/doc/salome/gui/GEOM/images/plane4.png b/doc/salome/gui/GEOM/images/plane4.png new file mode 100644 index 000000000..41b00fe53 Binary files /dev/null and b/doc/salome/gui/GEOM/images/plane4.png differ diff --git a/doc/salome/gui/GEOM/images/plane5.png b/doc/salome/gui/GEOM/images/plane5.png new file mode 100644 index 000000000..76c668a83 Binary files /dev/null and b/doc/salome/gui/GEOM/images/plane5.png differ diff --git a/doc/salome/gui/GEOM/input/creating_basic_go.doc b/doc/salome/gui/GEOM/input/creating_basic_go.doc index 49e3b2f34..0553bffd1 100644 --- a/doc/salome/gui/GEOM/input/creating_basic_go.doc +++ b/doc/salome/gui/GEOM/input/creating_basic_go.doc @@ -14,7 +14,6 @@ geometrical objects as:
  • \subpage create_curve_page
  • \subpage create_vector_page
  • \subpage create_plane_page
  • -
  • \subpage create_wplane_page
  • \subpage create_lcs_page
  • diff --git a/doc/salome/gui/GEOM/input/creating_plane.doc b/doc/salome/gui/GEOM/input/creating_plane.doc index c6116021b..518d64867 100644 --- a/doc/salome/gui/GEOM/input/creating_plane.doc +++ b/doc/salome/gui/GEOM/input/creating_plane.doc @@ -26,15 +26,25 @@ of the plane). \image html plane2.png -\n Finally, you can define a \b Plane by another \b Plane or Local -Coordinate System and a Size of the Plane. To change selection type cilck the corresponding -radio button "Face" or "Local Coordinate System". +\n Also, you can define a \b Plane by another \b Plane or Face and a Size of the Plane. \n TUI Command: geompy.MakePlaneFace(Face, TrimSize) -\n Arguments: Name + 1 face + 1 value (to define the size of -the plane). +\n Arguments: Name + 1 face + 1 value (to define the size of the plane). \image html plane3.png +\n Also, you can define a \b Plane by two Vectors. The first vector defines the center point and the direction, +the second vector defines the normal to the Plane. +\n TUI Command: geompy.MakePlane2Vec(Vec1, Vec2, TrimSize) +\n Arguments: Name + 2 vectors + 1 value (to define the size of the plane). + +\image html plane4.png + +\n Finally, you can define a \b Plane by the Local Coordinate System and the orientation (OXY, OYZ, OZX). +\n TUI Command: geompy.MakePlaneLCS(LCS, TrimSize, [1, 2, or 3]) +\n Arguments: Name + LCS + 1 value (to define the size of the plane) + 1 value (to define the orientation) + +\image html plane5.png + Examples: \image html planes1.png diff --git a/doc/salome/gui/GEOM/input/creating_sketcher.doc b/doc/salome/gui/GEOM/input/creating_sketcher.doc index ce1a6e78d..f7be15bb6 100644 --- a/doc/salome/gui/GEOM/input/creating_sketcher.doc +++ b/doc/salome/gui/GEOM/input/creating_sketcher.doc @@ -11,9 +11,8 @@ only) or destination direction coupled with length of a segment or angle and radius of an arc. \n Sketcher is able to create planar curves only. Therefore, it is -necessary to select a working plane before starting a sketch (by -default, XOY plane is used). Sketcher creates curves lying in the -current working plane (New Entity -> Basic -> Working Plane). +necessary to select coordinate system (Global or Local) before starting +a sketch. Sketcher creates curves lying in the XOY plane of the selected Coordinate System. \n This functionality is available from the main menu via New Entity / Sketch. @@ -26,13 +25,14 @@ textual description, passed through the Command argument. The edges of the resulting wire or face will be arcs of circles and/or linear segments. \n \em Command is a string, defining the sketcher by the coordinates of -points in the local working plane. -\n WorkingPlane can be a plane or a planar face. The plane is +points in the current LCS. +\n WorkingPlane can be a Local CS, a plane, or a planar face. The plane is defined by the XYZ coordinates of three non-coincident points. The planar face is an existing GEOM_Object. \n Arguments:
      +
    1. Coordinate system (Local or Global CS can be selected)
    2. Element type (segment or arc).
    3. Destination type (point or direction).
    4. Destination point by means of:
    5. diff --git a/doc/salome/gui/GEOM/input/creating_wplane.doc b/doc/salome/gui/GEOM/input/creating_wplane.doc deleted file mode 100644 index bb453c8a6..000000000 --- a/doc/salome/gui/GEOM/input/creating_wplane.doc +++ /dev/null @@ -1,40 +0,0 @@ -/*! - -\page create_wplane_page Working Plane - -Definition of a Working Plane is necessary for work with -\ref create_sketcher_page "Sketcher". - -\n To create a Working Plane in the Main Menu select -New Entity - > Basic - > Working Plane - -\n There is a number of algorithms to set the Working Plane and the -Camera Position. - -\n Firstly, you can select a \b Plane, a Planar Face or a Local Coordinate System to be your Working Plane. -\n Arguments: Name + 1 selection (plane or planar face). - -\image html workplane4.png - -\n Secondly, you can define a Working Plane by two Vectors. -\n Arguments: Name + 2 vectors. - -\image html workplane5.png - -\n Finally, you can select one of three basic projections of XYZ -coordinate system to be your Working Plane. - -\image html workplane6.png - -Reverse the plane normal checkbox allows changing the direction -of the working plane. - -Example: Working plane on the upper face of a box. - -\image html image36.gif -
      Normal Direction
      - -\image html image47.gif -
      Reversed Direction
      - -*/ diff --git a/doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc b/doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc index 51da40037..a6eb9bf18 100644 --- a/doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc +++ b/doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc @@ -268,8 +268,9 @@ p3 = geompy.MakeVertex(200., 200., 200.) p4 = geompy.MakeVertex(100., 100., 0.) p5 = geompy.MakeVertex(0. , 100., 0.) -# create a vector from the given components -vector = geompy.MakeVectorDXDYDZ(100., 100., 100.) +# create a vectors from the given components +vector1 = geompy.MakeVectorDXDYDZ(100., 100., 100.) +vector2 = geompy.MakeVectorDXDYDZ(-100., 0., 100.) # create a vector from two points vector_arc = geompy.MakeVector(p2, p5) @@ -285,8 +286,12 @@ isPlanarWanted = 1 face = geompy.MakeFace(wire, isPlanarWanted) trimsize = 1000. +# create a Local Coordinate System + +LCS = geompy.MakeMarker(100., 100., 101., 1, 0, 0, 0, 1, 0) + # create a plane from a point, a vector and a trimsize -plane1 = geompy.MakePlane(p1, vector, trimsize) +plane1 = geompy.MakePlane(p1, vector1, trimsize) # create a plane from three points and a trimsize plane2 = geompy.MakePlaneThreePnt(p1, p2, p3, trimsize) @@ -294,23 +299,37 @@ plane2 = geompy.MakePlaneThreePnt(p1, p2, p3, trimsize) # create a plane from the given face plane3 = geompy.MakePlaneFace(face, trimsize) +# create a plane from two vectors and a trimsize +plane4 = geompy.MakePlane2Vec(vector1, vector2, trimsize) + +# create a plane with the Local Coordinate System and a trimsize +plane5 = geompy.MakePlaneLCS(LCS, trimsize, 1) + # add objects in the study id_face = geompy.addToStudy(face, "Face") id_plane1 = geompy.addToStudy(plane1,"Plane1") id_plane2 = geompy.addToStudy(plane2,"Plane2") id_plane3 = geompy.addToStudy(plane3,"Plane3") +id_plane4 = geompy.addToStudy(plane4,"Plane4") +id_plane5 = geompy.addToStudy(plane5,"Plane5") # display the points and the vectors gg.createAndDisplayGO(id_face) gg.createAndDisplayGO(id_plane1) gg.createAndDisplayGO(id_plane2) gg.createAndDisplayGO(id_plane3) +gg.createAndDisplayGO(id_plane4) +gg.createAndDisplayGO(id_plane5) gg.setDisplayMode(id_plane1,1) gg.setTransparency(id_plane1,0.5) gg.setDisplayMode(id_plane2,1) gg.setTransparency(id_plane2,0.5) gg.setDisplayMode(id_plane3,1) -gg.setTransparency(id_plane3,0.5) +gg.setTransparency(id_plane3,0.5) +gg.setDisplayMode(id_plane4,1) +gg.setTransparency(id_plane4,0.5) +gg.setDisplayMode(id_plane5,1) +gg.setTransparency(id_plane5,0.5) \endcode */ diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 7c840499a..04aa32a40 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -435,6 +435,28 @@ module GEOM */ GEOM_Object MakePlaneFace (in GEOM_Object theFace, in double theTrimSize); + + /*! + * Create a plane, by two vectors. + * \param theVec1 Vector1, the plane has to pass through first point of this vector. + * \param theVec Vector2, defining the plane normal direction. + * \param theTrimSize Half size of a side of quadrangle face, representing the plane. + * \return New GEOM_Object, containing the created plane. + */ + GEOM_Object MakePlane2Vec (in GEOM_Object theVec1, + in GEOM_Object theVec2, + in double theTrimSize); + + /*! + * Create a plane, defined by local coordinate system. + * \param theLCS Referenced LCS(Marker). + * \param theTrimSize Half size of a side of quadrangle face, representing the plane. + * \param theOrientation OXY, OYZ or OZX orientation = (1, 2 or 3). + * \return New GEOM_Object, containing the created plane. + */ + GEOM_Object MakePlaneLCS (in GEOM_Object theLCS, + in double theTrimSize, + in double theOrientation); /*! * Create a local coordinate system. diff --git a/idl/GEOM_Superv.idl b/idl/GEOM_Superv.idl index 1ee41d642..ed4334994 100644 --- a/idl/GEOM_Superv.idl +++ b/idl/GEOM_Superv.idl @@ -94,6 +94,12 @@ module GEOM in double theTrimSize) ; GEOM_Object MakePlaneFace (in GEOM_Object theFace, in double theTrimSize) ; + GEOM_Object MakePlane2Vec (in GEOM_Object theVec1, + in GEOM_Object theVec2, + in double theTrimSize) ; + GEOM_Object MakePlaneLCS (in GEOM_Object theLCS, + in double theTrimSize, + in double theOrientation) ; GEOM_Object MakeMarker (in double theOX , in double theOY , in double theOZ, in double theXDX, in double theXDY, in double theXDZ, in double theYDX, in double theYDY, in double theYDZ) ; diff --git a/src/BasicGUI/BasicGUI.cxx b/src/BasicGUI/BasicGUI.cxx index 47c7e1135..ab7c09429 100644 --- a/src/BasicGUI/BasicGUI.cxx +++ b/src/BasicGUI/BasicGUI.cxx @@ -102,9 +102,9 @@ bool BasicGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) case 4017: // PLANE aDlg = new BasicGUI_PlaneDlg( getGeometryGUI(), parent ); break; - case 4018: // WORKING PLANE +/* case 4018: // WORKING PLANE aDlg = new BasicGUI_WorkingPlaneDlg( getGeometryGUI(), parent ); - break; + break;*/ // DEPRECATED! case 4019: // CURVE aDlg = new BasicGUI_CurveDlg( getGeometryGUI(), parent ); break; diff --git a/src/BasicGUI/BasicGUI_PlaneDlg.cxx b/src/BasicGUI/BasicGUI_PlaneDlg.cxx index 8d5b14f37..b98ba15de 100644 --- a/src/BasicGUI/BasicGUI_PlaneDlg.cxx +++ b/src/BasicGUI/BasicGUI_PlaneDlg.cxx @@ -60,6 +60,8 @@ BasicGUI_PlaneDlg::BasicGUI_PlaneDlg( GeometryGUI* theGeometryGUI, QWidget* pare QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_PLANE_3PNTS" ) ) ); QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_PLANE_FACE" ) ) ); QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); + QPixmap image4( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_WPLANE_VECTOR" ) ) ); + QPixmap image5( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_WPLANE_ORIGIN" ) ) ); setWindowTitle( tr( "GEOM_PLANE_TITLE" ) ); @@ -68,6 +70,10 @@ BasicGUI_PlaneDlg::BasicGUI_PlaneDlg( GeometryGUI* theGeometryGUI, QWidget* pare mainFrame()->RadioButton1->setIcon( image0 ); mainFrame()->RadioButton2->setIcon( image1 ); mainFrame()->RadioButton3->setIcon( image2 ); + mainFrame()->RadioButton4->show(); + mainFrame()->RadioButton4->setIcon( image4 ); + mainFrame()->RadioButton5->show(); + mainFrame()->RadioButton5->setIcon( image5 ); GroupPntDir = new DlgRef_2Sel1Spin( centralWidget() ); GroupPntDir->GroupBox1->setTitle( tr( "GEOM_PLANE_PV" ) ); @@ -100,12 +106,8 @@ BasicGUI_PlaneDlg::BasicGUI_PlaneDlg( GeometryGUI* theGeometryGUI, QWidget* pare Group3Pnts->LineEdit2->setEnabled( false ); Group3Pnts->LineEdit3->setEnabled( false ); - GroupFace = new DlgRef_3Radio1Sel1Spin( centralWidget() ); - GroupFace->RadioButton1->setText(tr("GEOM_FACE")); - GroupFace->RadioButton2->setText(tr("GEOM_LCS")); - GroupFace->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); - GroupFace->RadioButton3->close(); - GroupFace->GroupBox1->setTitle( tr( "GEOM_FACE_OR_LCS" ) ); + GroupFace = new DlgRef_1Sel1Spin( centralWidget() ); + GroupFace->GroupBox1->setTitle( tr( "GEOM_FACE" ) ); GroupFace->TextLabel1->setText( tr( "GEOM_SELECTION" ) ); GroupFace->TextLabel2->setText( tr( "GEOM_PLANE_SIZE" ) ); GroupFace->PushButton1->setIcon( image3 ); @@ -113,11 +115,37 @@ BasicGUI_PlaneDlg::BasicGUI_PlaneDlg( GeometryGUI* theGeometryGUI, QWidget* pare GroupFace->LineEdit1->setReadOnly( true ); + Group2Vec = new DlgRef_2Sel1Spin( centralWidget() ); + + Group2Vec->GroupBox1->setTitle( tr( "GEOM_WPLANE_VECTOR" ) ); + Group2Vec->TextLabel1->setText( tr( "GEOM_WPLANE_VX" ) ); + Group2Vec->TextLabel2->setText( tr( "GEOM_WPLANE_VZ" ) ); + Group2Vec->PushButton1->setIcon( image3 ); + Group2Vec->PushButton2->setIcon( image3 ); + Group2Vec->LineEdit1->setReadOnly( true ); + Group2Vec->LineEdit2->setReadOnly( true ); + Group2Vec->PushButton1->setDown( true ); + Group2Vec->LineEdit1->setEnabled( true ); + Group2Vec->LineEdit2->setEnabled( false ); + Group2Vec->TextLabel3->setText( tr( "GEOM_PLANE_SIZE" ) ); + + GroupLCS = new DlgRef_3Radio1Sel1Spin( centralWidget() ); + GroupLCS->GroupBox1->setTitle( tr( "GEOM_LCS" ) ); + GroupLCS->TextLabel1->setText( tr( "GEOM_SELECTION" ) ); + GroupLCS->TextLabel2->setText( tr( "GEOM_PLANE_SIZE" ) ); + GroupLCS->RadioButton1->setText( tr( "GEOM_WPLANE_OXY" ) ); + GroupLCS->RadioButton2->setText( tr( "GEOM_WPLANE_OYZ" ) ); + GroupLCS->RadioButton3->setText( tr( "GEOM_WPLANE_OZX" ) ); + GroupLCS->PushButton1->setIcon( image3 ); + GroupLCS->PushButton1->setDown( true ); + QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->addWidget( GroupPntDir ); layout->addWidget( Group3Pnts ); layout->addWidget( GroupFace ); + layout->addWidget( Group2Vec ); + layout->addWidget( GroupLCS ); /***************************************************************/ setHelpFileName( "create_plane_page.html" ); @@ -143,11 +171,11 @@ void BasicGUI_PlaneDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPntDir->LineEdit1; - GroupFace->RadioButton1->setChecked(true); myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = myFace = GEOM::GEOM_Object::_nil(); // myGeomGUI->SetState( 0 ); + myOriginType = 1; /* Get setting of step value from file configuration */ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); @@ -162,6 +190,10 @@ void BasicGUI_PlaneDlg::Init() Group3Pnts->SpinBox_DX->setValue( aTrimSize ); initSpinBox( GroupFace->SpinBox_DX, 0.000001, COORD_MAX, aStep, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY GroupFace->SpinBox_DX->setValue( aTrimSize ); + initSpinBox( Group2Vec->SpinBox_DX, 0.000001, COORD_MAX, aStep, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY + Group2Vec->SpinBox_DX->setValue( aTrimSize ); + initSpinBox( GroupLCS->SpinBox_DX, 0.000001, COORD_MAX, aStep, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY + GroupLCS->SpinBox_DX->setValue( aTrimSize ); /* signals and slots connections */ connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ); @@ -178,6 +210,12 @@ void BasicGUI_PlaneDlg::Init() connect( Group3Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( Group3Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupFace->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + connect( Group2Vec->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + connect( Group2Vec->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + + connect( GroupLCS->RadioButton1, SIGNAL( clicked() ), this, SLOT( GroupClicked() ) ); + connect( GroupLCS->RadioButton2, SIGNAL( clicked() ), this, SLOT( GroupClicked() ) ); + connect( GroupLCS->RadioButton3, SIGNAL( clicked() ), this, SLOT( GroupClicked() ) ); connect( GroupPntDir->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect( GroupPntDir->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); @@ -185,12 +223,14 @@ void BasicGUI_PlaneDlg::Init() connect( Group3Pnts->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect( Group3Pnts->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect( GroupFace->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect( GroupFace->RadioButton1,SIGNAL( clicked() ), this, SLOT( SelectionTypeClicked() ) ); - connect( GroupFace->RadioButton2,SIGNAL( clicked() ), this, SLOT( SelectionTypeClicked() ) ); + connect( Group2Vec->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); + connect( Group2Vec->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect( GroupPntDir->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( Group3Pnts->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupFace->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + connect( Group2Vec->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + connect( GroupLCS->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) ); @@ -210,28 +250,10 @@ void BasicGUI_PlaneDlg::SetDoubleSpinBoxStep( double step ) GroupPntDir->SpinBox_DX->setSingleStep(step); Group3Pnts->SpinBox_DX->setSingleStep(step); GroupFace->SpinBox_DX->setSingleStep(step); + Group2Vec->SpinBox_DX->setSingleStep(step); + GroupLCS->SpinBox_DX->setSingleStep(step); } -//================================================================================= -// function : SelectionTypeClicked() -// purpose : Selection type radio buttons managment -//================================================================================= -void BasicGUI_PlaneDlg::SelectionTypeClicked() -{ - myFace = GEOM::GEOM_Object::_nil(); - if ( GroupFace->RadioButton1->isChecked()) { - globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE ); - } else if ( GroupFace->RadioButton2->isChecked()) { - TColStd_MapOfInteger aMap; - aMap.Add( GEOM_PLANE ); - aMap.Add( GEOM_MARKER ); - globalSelection( aMap ); - } - displayPreview(); -} - - //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management @@ -247,6 +269,8 @@ void BasicGUI_PlaneDlg::ConstructorsClicked( int constructorId ) Group3Pnts->hide(); GroupFace->hide(); GroupPntDir->show(); + Group2Vec->hide(); + GroupLCS->hide(); myEditCurrentArgument = GroupPntDir->LineEdit1; GroupPntDir->LineEdit1->setText( "" ); @@ -266,6 +290,8 @@ void BasicGUI_PlaneDlg::ConstructorsClicked( int constructorId ) GroupPntDir->hide(); GroupFace->hide(); Group3Pnts->show(); + Group2Vec->hide(); + GroupLCS->hide(); myEditCurrentArgument = Group3Pnts->LineEdit1; Group3Pnts->LineEdit1->setText( "" ); @@ -283,25 +309,53 @@ void BasicGUI_PlaneDlg::ConstructorsClicked( int constructorId ) localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); break; } - case 2: /* plane from a planar face or LSC selection */ + case 2: /* plane from a planar face */ { GroupPntDir->hide(); Group3Pnts->hide(); GroupFace->show(); + Group2Vec->hide(); + GroupLCS->hide(); myEditCurrentArgument = GroupFace->LineEdit1; GroupFace->LineEdit1->setText( "" ); GroupFace->PushButton1->setDown( true ); - if ( GroupFace->RadioButton1->isChecked()) { - globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE ); - } else if ( GroupFace->RadioButton2->isChecked()) { - TColStd_MapOfInteger aMap; - aMap.Add( GEOM_PLANE ); - aMap.Add( GEOM_MARKER ); - globalSelection( aMap ); - } + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE ); + break; + } + case 3: /* plane from a 2 Vectors */ + { + GroupPntDir->hide(); + Group3Pnts->hide(); + GroupFace->hide(); + Group2Vec->show(); + GroupLCS->hide(); + + myEditCurrentArgument = Group2Vec->LineEdit1; + Group2Vec->LineEdit1->setText( "" ); + Group2Vec->PushButton1->setDown( true ); + + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + break; + } + case 4: /* plane from a LCS */ + { + GroupPntDir->hide(); + Group3Pnts->hide(); + GroupFace->hide(); + Group2Vec->hide(); + GroupLCS->show(); + + myEditCurrentArgument = GroupLCS->LineEdit1; + GroupLCS->LineEdit1->setText( "" ); + GroupLCS->PushButton1->setDown( true ); + GroupLCS->RadioButton1->setChecked( true ); + myOriginType = 1; + + globalSelection(GEOM_MARKER); break; } } @@ -313,6 +367,7 @@ void BasicGUI_PlaneDlg::ConstructorsClicked( int constructorId ) myEditCurrentArgument->setFocus(); connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + displayPreview(); } @@ -341,6 +396,23 @@ bool BasicGUI_PlaneDlg::ClickOnApply() return true; } +//================================================================================= +// function : GroupClicked() +// purpose : OX OY OZ Radio button management +//================================================================================= +void BasicGUI_PlaneDlg::GroupClicked() +{ + QRadioButton* send = (QRadioButton*)sender(); + + if ( send == GroupLCS->RadioButton1 ) + myOriginType = 1; + else if ( send == GroupLCS->RadioButton2 ) + myOriginType = 2; + else if ( send == GroupLCS->RadioButton3 ) + myOriginType = 3; + displayPreview(); +} + //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection has changed @@ -360,6 +432,10 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument() else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) myFace = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) myVec1 = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) myVec2 = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) myLCS = GEOM::GEOM_Object::_nil(); + displayPreview(); return; } @@ -369,10 +445,12 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument() if ( !CORBA::is_nil( aSelectedObject ) && aRes ) { QString aName = GEOMBase::GetName( aSelectedObject ); TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; - if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) + if ( myEditCurrentArgument == GroupPntDir->LineEdit2 || myEditCurrentArgument == Group2Vec->LineEdit1 || myEditCurrentArgument == Group2Vec->LineEdit2) aNeedType = TopAbs_EDGE; else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) aNeedType = TopAbs_FACE; + else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) + aNeedType = TopAbs_FACE; TopoDS_Shape aShape; if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { @@ -447,6 +525,17 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument() } else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) myFace = aSelectedObject; + else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) { + myVec1 = aSelectedObject; + if ( !myVec1->_is_nil() && myVec2->_is_nil() ) + Group2Vec->PushButton2->click(); + } else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) { + myVec2 = aSelectedObject; + if ( !myVec2->_is_nil() && myVec1->_is_nil() ) + Group2Vec->PushButton1->click(); + } else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) + myLCS = aSelectedObject; + } displayPreview(); @@ -501,18 +590,34 @@ void BasicGUI_PlaneDlg::SetEditCurrentArgument() else if ( send == GroupFace->PushButton1 ) { myEditCurrentArgument = GroupFace->LineEdit1; GroupFace->PushButton1->setDown( true ); + } else if ( send == Group2Vec->PushButton1 ) { + myEditCurrentArgument = Group2Vec->LineEdit1; + Group2Vec->PushButton2->setDown( false ); + Group2Vec->LineEdit1->setEnabled( true ); + Group2Vec->LineEdit2->setEnabled( false ); + } else if ( send == Group2Vec->PushButton2 ) { + myEditCurrentArgument = Group2Vec->LineEdit2; + Group2Vec->PushButton1->setDown( false ); + Group2Vec->LineEdit1->setEnabled( false ); + Group2Vec->LineEdit2->setEnabled( true ); + } else if ( send == GroupLCS->PushButton1 ) { + myEditCurrentArgument = GroupLCS->LineEdit1; + GroupLCS->LineEdit1->setEnabled( true ); } myEditCurrentArgument->setFocus(); - if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) { + if ( myEditCurrentArgument == GroupPntDir->LineEdit2 || + myEditCurrentArgument == Group2Vec->LineEdit1 || + myEditCurrentArgument == Group2Vec->LineEdit2 ) { localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); - } - else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) { + } else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) { TColStd_MapOfInteger aMap; aMap.Add( GEOM_PLANE ); aMap.Add( GEOM_MARKER ); globalSelection( aMap ); + } else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) { + globalSelection( GEOM_MARKER ); } else { // 3 Pnts localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); @@ -537,7 +642,10 @@ void BasicGUI_PlaneDlg::LineEditReturnPressed() send == Group3Pnts->LineEdit1 || send == Group3Pnts->LineEdit2 || send == Group3Pnts->LineEdit3 || - send == GroupFace->LineEdit1 ) { + send == GroupFace->LineEdit1 || + send == Group2Vec->LineEdit1 || + send == Group2Vec->LineEdit2 || + send == GroupLCS->LineEdit1 ) { myEditCurrentArgument = send; GEOMBase_Skeleton::LineEditReturnPressed(); } @@ -555,6 +663,7 @@ void BasicGUI_PlaneDlg::ActivateThisDialog() this, SLOT( SelectionIntoArgument() ) ); ConstructorsClicked( getConstructorId() ); + SelectionIntoArgument(); } //================================================================================= @@ -596,6 +705,8 @@ double BasicGUI_PlaneDlg::getSize() const case 0 : return GroupPntDir->SpinBox_DX->value(); case 1 : return Group3Pnts->SpinBox_DX->value(); case 2 : return GroupFace->SpinBox_DX->value(); + case 3 : return Group2Vec->SpinBox_DX->value(); + case 4 : return GroupLCS->SpinBox_DX->value(); } return 0.; } @@ -610,6 +721,7 @@ QString BasicGUI_PlaneDlg::getSizeAsString() const case 0 : return GroupPntDir->SpinBox_DX->text(); case 1 : return Group3Pnts->SpinBox_DX->text(); case 2 : return GroupFace->SpinBox_DX->text(); + case 3 : return Group2Vec->SpinBox_DX->text(); } return QString(); } @@ -656,6 +768,12 @@ bool BasicGUI_PlaneDlg::isValid( QString& msg ) else if ( id == 2 ) { bool ok = GroupFace->SpinBox_DX->isValid( msg, !IsPreview() ); return !CORBA::is_nil( myFace ) && ok; + } else if ( id == 3 ) { + bool ok = Group2Vec->SpinBox_DX->isValid( msg, !IsPreview() ); + return !CORBA::is_nil( myVec1 ) && !CORBA::is_nil( myVec2 ) && !isEqual( myVec1, myVec2 ) && ok; + } else if ( id == 4 ) { + bool ok = GroupLCS->SpinBox_DX->isValid( msg, !IsPreview() ); + return ok; } return false; } @@ -683,6 +801,14 @@ bool BasicGUI_PlaneDlg::execute( ObjectList& objects ) anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePlaneFace( myFace, getSize() ); res = true; break; + case 3 : + anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePlane2Vec( myVec1, myVec2, getSize() ); + res = true; + break; + case 4 : + anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePlaneLCS( myLCS, getSize(), myOriginType ); + res = true; + break; } if ( !anObj->_is_nil() ) { @@ -713,6 +839,10 @@ void BasicGUI_PlaneDlg::addSubshapesToStudy() case 2: objMap[GroupFace->LineEdit1->text()] = myFace; break; + case 3: + objMap[Group2Vec->LineEdit1->text()] = myVec1; + objMap[Group2Vec->LineEdit2->text()] = myVec2; + break; } addSubshapesToFather( objMap ); } diff --git a/src/BasicGUI/BasicGUI_PlaneDlg.h b/src/BasicGUI/BasicGUI_PlaneDlg.h index 5d83df4e3..d8a0f2663 100644 --- a/src/BasicGUI/BasicGUI_PlaneDlg.h +++ b/src/BasicGUI/BasicGUI_PlaneDlg.h @@ -57,13 +57,16 @@ private: void enterEvent( QEvent* ); double getSize() const; QString getSizeAsString() const; + int myOriginType; private: - GEOM::GEOM_Object_var myPoint, myDir, myPoint1, myPoint2, myPoint3, myFace; + GEOM::GEOM_Object_var myPoint, myDir, myPoint1, myPoint2, myPoint3, myFace, myVec1, myVec2, myLCS; DlgRef_2Sel1Spin* GroupPntDir; DlgRef_3Sel1Spin* Group3Pnts; - DlgRef_3Radio1Sel1Spin* GroupFace; + DlgRef_1Sel1Spin* GroupFace; + DlgRef_2Sel1Spin* Group2Vec; + DlgRef_3Radio1Sel1Spin* GroupLCS; private slots: void ClickOnOk(); @@ -79,6 +82,7 @@ private slots: void ValueChangedInSpinBox( double ); void SetDoubleSpinBoxStep( double ); void SelectionTypeClicked(); + void GroupClicked(); }; #endif // BASICGUI_PLANEDLG_H diff --git a/src/DlgRef/DlgRef_3Radio1Sel1Spin_QTD.ui b/src/DlgRef/DlgRef_3Radio1Sel1Spin_QTD.ui index 74e1d6bcc..f6f82c007 100644 --- a/src/DlgRef/DlgRef_3Radio1Sel1Spin_QTD.ui +++ b/src/DlgRef/DlgRef_3Radio1Sel1Spin_QTD.ui @@ -37,7 +37,7 @@ - + @@ -62,6 +62,41 @@ + + + + + 0 + 0 + + + + TL2 + + + false + + + + + + + + + + Qt::Vertical + + + + 256 + 19 + + + + + + + @@ -91,42 +126,15 @@ - - - - - - - - 0 - 0 - - - - TL2 - - - false - - - - - - - - - - Qt::Vertical - - - - 256 - 19 - - - - + TextLabel2 + SpinBox_DX + RadioButton1 + RadioButton2 + RadioButton3 + LineEdit1 + TextLabel1 + PushButton1 @@ -141,8 +149,6 @@ - PushButton1 - LineEdit1 SpinBox_DX diff --git a/src/EntityGUI/EntityGUI_SketcherDlg.cxx b/src/EntityGUI/EntityGUI_SketcherDlg.cxx index 140592cf2..d2b0db330 100644 --- a/src/EntityGUI/EntityGUI_SketcherDlg.cxx +++ b/src/EntityGUI/EntityGUI_SketcherDlg.cxx @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include @@ -50,6 +52,10 @@ #include #include +#include + +#include + //================================================================================= // class : EntityGUI_SketcherDlg() // purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the @@ -75,7 +81,6 @@ EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent, MainWidget = new EntityGUI_Skeleton( this ); QVBoxLayout* topLayout = new QVBoxLayout( this ); topLayout->setMargin( 9 ); topLayout->setSpacing( 6 ); - topLayout->addWidget( MainWidget ); MainWidget->buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) ); MainWidget->buttonEnd->setText( tr( "GEOM_BUT_END_SKETCH" ) ); @@ -97,6 +102,18 @@ EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent, MainWidget->RB_Dest2->setText( tr( "GEOM_SKETCHER_DIR" ) ); /***************************************************************/ + + GroupBox1 = new QGroupBox(tr("GEOM_CS"), this); + QGridLayout* OwnLayout = new QGridLayout(GroupBox1); + OwnLayout->setSpacing(6); + OwnLayout->setMargin(11); + + ComboBox1 = new QComboBox(GroupBox1); + OwnLayout->addWidget(ComboBox1); + + topLayout->addWidget(GroupBox1); + topLayout->addWidget( MainWidget ); + GroupPt = new EntityGUI_Point( MainWidget->DestCnt ); GroupPt->GroupPoint->setTitle( tr( "GEOM_SKETCHER_POINT" ) ); @@ -214,6 +231,8 @@ EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent, connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( SelectionIntoArgument() ) ); + connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) ); connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ); @@ -329,6 +348,8 @@ void EntityGUI_SketcherDlg::Init() resize(100,100); TypeClicked( 0 ); + FindLocalCS(); + GEOMBase_Helper::displayPreview( false, true, true, myLineWidth ); } @@ -879,7 +900,7 @@ void EntityGUI_SketcherDlg::SelectionIntoArgument() TopoDS_Shape aShape; if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) { gp_Trsf aTrans; - gp_Ax3 aWPlane = myGeometryGUI->GetWorkingPlane(); + gp_Ax3 aWPlane = GetActiveLocalCS(); aTrans.SetTransformation(aWPlane); BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False); @@ -1445,7 +1466,7 @@ bool EntityGUI_SketcherDlg::execute( ObjectList& objects ) } } - gp_Ax3 myWPlane = myGeometryGUI->GetWorkingPlane(); + gp_Ax3 myWPlane = GetActiveLocalCS(); GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble; WPlane->length( 9 ); WPlane[0] = myWPlane.Location().X(); @@ -1607,3 +1628,85 @@ void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step ) Group4Spin->SpinBox_DZ->setSingleStep(step); Group4Spin->SpinBox_DS->setSingleStep(step); } + +//================================================================================= +// function : FindLocalCS() +// purpose : Find All Coordinates systems in study +//================================================================================= +void EntityGUI_SketcherDlg::FindLocalCS() +{ + ComboBox1->clear(); + myLCSList.clear(); + SalomeApp_Application* app = + dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if ( !app ) + return; + + SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); + if ( !appStudy ) + return; + + _PTR(Study) aStudy = appStudy->studyDS(); + + //add Global CS + ComboBox1->addItem(tr("GEOM_GCS")); + gp_Pnt aOrigin = gp_Pnt(0, 0, 0); + gp_Dir aDirZ = gp_Dir(0, 0, 1); + gp_Dir aDirX = gp_Dir(1, 0, 0); + gp_Ax3 globalCS = gp_Ax3(aOrigin, aDirZ, aDirX); + myLCSList.push_back(globalCS); + + // get GEOM component + CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() ); + _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() ); + if (!obj) + return; + _PTR(SComponent) fc = obj->GetFatherComponent(); + QString geomComp = fc->GetID().c_str(); + _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() ); + if ( !comp ) + return; + + // browse through all GEOM data tree + _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) ); + for ( it->InitEx( true ); it->More(); it->Next() ) { + _PTR(SObject) child( it->Value() ); + CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child ); + GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj ); + if( CORBA::is_nil( geomObj ) ) + continue; + if (geomObj->GetType() == GEOM_MARKER) { + ComboBox1->addItem(geomObj->GetName()); + TopoDS_Shape aShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), geomObj); + + gp_Ax3 aLCS; + aLCS.Transform(aShape.Location().Transformation()); + if (aShape.ShapeType() == TopAbs_FACE) { + Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aShape)); + if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) { + Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS); + gp_Pln aPln = aGPlane->Pln(); + aLCS = aPln.Position(); + } + } + myLCSList.push_back(aLCS); + } + } +} + +//================================================================================= +// function : GetActiveLocalCS() +// purpose : Find All Coordinates systems in study +//================================================================================= +gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS() +{ + int ind = ComboBox1->currentIndex(); + if (ind == -1) + return myGeometryGUI->GetWorkingPlane(); + + gp_Ax3 aLCS = myLCSList.at(ind); + + myGeometryGUI->SetWorkingPlane( aLCS ); + myGeometryGUI->ActiveWorkingPlane(); + return aLCS; +} diff --git a/src/EntityGUI/EntityGUI_SketcherDlg.h b/src/EntityGUI/EntityGUI_SketcherDlg.h index 3a304abf1..774068fc1 100644 --- a/src/EntityGUI/EntityGUI_SketcherDlg.h +++ b/src/EntityGUI/EntityGUI_SketcherDlg.h @@ -28,8 +28,12 @@ #include +#include +#include #include +#include + class QLineEdit; class SalomeApp_DoubleSpinBox; class EntityGUI_1Sel; @@ -138,12 +142,17 @@ private: EntityGUI_3Spin* Group3Spin; EntityGUI_4Spin* Group4Spin; + QGroupBox* GroupBox1; + QComboBox* ComboBox1; + GeometryGUI* myGeometryGUI; QString myHelpFileName; double myLineWidth; + QList myLCSList; + private: enum SketchState { FIRST_POINT, NEXT_POINT }; @@ -172,6 +181,8 @@ private slots: void Dir2Clicked( int ); void ValueChangedInSpinBox( double ); void SetDoubleSpinBoxStep( double ); + void FindLocalCS(); + gp_Ax3 GetActiveLocalCS(); }; #endif // ENTITYGUI_SKETCHERDLG_H diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 37b3c8b49..be3e9ca46 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -417,7 +417,7 @@ void GeometryGUI::OnGUIEvent( int id ) id == 4015 || // MENU BASIC - ARC id == 4016 || // MENU BASIC - VECTOR id == 4017 || // MENU BASIC - PLANE - id == 4018 || // MENU BASIC - WPLANE +// id == 4018 || // MENU BASIC - WPLANE // DEPRECATED id == 4019 || // MENU BASIC - CURVE id == 4020 ) { // MENU BASIC - REPAIR #ifndef WNT @@ -783,7 +783,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( 4019, "CURVE" ); createGeomAction( 4016, "VECTOR" ); createGeomAction( 4017, "PLANE" ); - createGeomAction( 4018, "WORK_PLANE" ); +// createGeomAction( 4018, "WORK_PLANE" ); DEPRECATED createGeomAction( 4020, "LOCAL_CS" ); createGeomAction( 4021, "BOX" ); @@ -928,7 +928,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( separator(), basicId, -1 ); createMenu( 4016, basicId, -1 ); createMenu( 4017, basicId, -1 ); - createMenu( 4018, basicId, -1 ); +// createMenu( 4018, basicId, -1 ); DEPRECATED createMenu( 4020, basicId, -1 ); int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 ); @@ -1086,7 +1086,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( 4019, basicTbId ); createTool( 4016, basicTbId ); createTool( 4017, basicTbId ); - createTool( 4018, basicTbId ); +// createTool( 4018, basicTbId ); DEPRECATED createTool( 4020, basicTbId ); int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) ); diff --git a/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx index 1594f5827..140a887f6 100644 --- a/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx @@ -840,6 +840,117 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace return aPlane; } +//============================================================================= +/*! + * MakePlane2Vec + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlane2Vec + (Handle(GEOM_Object) theVec1, Handle(GEOM_Object) theVec2, + double theSize) +{ + SetErrorCode(KO); + + if (theVec1.IsNull() || theVec2.IsNull()) return NULL; + + //Add a new Plane object + Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE); + + //Add a new Plane function + Handle(GEOM_Function) aFunction = + aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_2_VEC); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL; + + GEOMImpl_IPlane aPI (aFunction); + + Handle(GEOM_Function) aRefVec1 = theVec1->GetLastFunction(); + Handle(GEOM_Function) aRefVec2 = theVec2->GetLastFunction(); + if (aRefVec1.IsNull() || aRefVec2.IsNull()) return NULL; + + aPI.SetVector1(aRefVec1); + aPI.SetVector2(aRefVec2); + aPI.SetSize(theSize); + + //Compute the Plane value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Plane driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane2Vec(" + << theVec1 << ", " << theVec2 << ", " << theSize << ")"; + + SetErrorCode(OK); + return aPlane; +} + +//============================================================================= +/*! + * MakePlaneLCS + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneLCS + (Handle(GEOM_Object) theLCS, double theSize, int theOrientation) +{ + SetErrorCode(KO); + + //Add a new Plane object + Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE); + + //Add a new Plane function + Handle(GEOM_Function) aFunction = + aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_LCS); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL; + + GEOMImpl_IPlane aPI (aFunction); + + if ( !theLCS.IsNull() ) { + Handle(GEOM_Function) aRef = theLCS->GetLastFunction(); + aPI.SetLCS(aRef); + } + + aPI.SetSize(theSize); + aPI.SetOrientation(theOrientation); + + //Compute the Plane value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Plane driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneLCS(" + << theLCS << ", " << theSize << ", " << theOrientation << ")"; + + SetErrorCode(OK); + return aPlane; +} + //============================================================================= /*! diff --git a/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx b/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx index 16c4af6ea..0d211770e 100644 --- a/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx @@ -79,6 +79,12 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations { double theSize); Standard_EXPORT Handle(GEOM_Object) MakePlaneFace (Handle(GEOM_Object) theFace, double theSize); + + Standard_EXPORT Handle(GEOM_Object) MakePlane2Vec (Handle(GEOM_Object) theVec1, + Handle(GEOM_Object) theVec2, + double theSize); + + Standard_EXPORT Handle(GEOM_Object) MakePlaneLCS (Handle(GEOM_Object) theFace, double theSize, int theOrientation); // Marker Standard_EXPORT Handle(GEOM_Object) MakeMarker (double theOX, double theOY, double theOZ, diff --git a/src/GEOMImpl/GEOMImpl_IPlane.hxx b/src/GEOMImpl/GEOMImpl_IPlane.hxx index fbd97d705..cdbd5aae2 100644 --- a/src/GEOMImpl/GEOMImpl_IPlane.hxx +++ b/src/GEOMImpl/GEOMImpl_IPlane.hxx @@ -37,6 +37,13 @@ #define PLN_ARG_PARAM_V 8 +#define PLN_ARG_VEC1 9 +#define PLN_ARG_VEC2 10 + +#define PLN_ARG_ORIENT 11 + +#define PLN_ARG_LCS 12 + class GEOMImpl_IPlane { public: @@ -46,11 +53,18 @@ class GEOMImpl_IPlane void SetSize(double theSize) { _func->SetReal(PLN_ARG_SIZE, theSize); } double GetSize() { return _func->GetReal(PLN_ARG_SIZE); } + + void SetOrientation(double theOrientation) { _func->SetReal(PLN_ARG_ORIENT, theOrientation); } + + double GetOrientation() { return _func->GetReal(PLN_ARG_ORIENT); } void SetPoint (Handle(GEOM_Function) theRef) { _func->SetReference(PLN_ARG_PNT1, theRef); } void SetVector(Handle(GEOM_Function) theRef) { _func->SetReference(PLN_ARG_VEC , theRef); } + void SetVector1(Handle(GEOM_Function) theRef) { _func->SetReference(PLN_ARG_VEC1 , theRef); } + void SetVector2(Handle(GEOM_Function) theRef) { _func->SetReference(PLN_ARG_VEC2 , theRef); } void SetFace (Handle(GEOM_Function) theRef) { _func->SetReference(PLN_ARG_REF , theRef); } + void SetLCS (Handle(GEOM_Function) theRef) { _func->SetReference(PLN_ARG_LCS , theRef); } void SetPoint1(Handle(GEOM_Function) theRef) { _func->SetReference(PLN_ARG_PNT1, theRef); } void SetPoint2(Handle(GEOM_Function) theRef) { _func->SetReference(PLN_ARG_PNT2, theRef); } @@ -58,8 +72,11 @@ class GEOMImpl_IPlane Handle(GEOM_Function) GetPoint () { return _func->GetReference(PLN_ARG_PNT1); } Handle(GEOM_Function) GetVector() { return _func->GetReference(PLN_ARG_VEC ); } + Handle(GEOM_Function) GetVector1() { return _func->GetReference(PLN_ARG_VEC1 ); } + Handle(GEOM_Function) GetVector2() { return _func->GetReference(PLN_ARG_VEC2 ); } Handle(GEOM_Function) GetFace () { return _func->GetReference(PLN_ARG_REF ); } + Handle(GEOM_Function) GetLCS () { return _func->GetReference(PLN_ARG_LCS ); } Handle(GEOM_Function) GetPoint1() { return _func->GetReference(PLN_ARG_PNT1); } Handle(GEOM_Function) GetPoint2() { return _func->GetReference(PLN_ARG_PNT2); } diff --git a/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx b/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx index 534fc8565..9000b30ac 100644 --- a/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx @@ -174,6 +174,58 @@ Standard_Integer GEOMImpl_PlaneDriver::Execute(TFunction_Logbook& log) const if(aTool.IsDone()) aShape = aTool.Shape(); } + else if (aType == PLANE_2_VEC) { + Handle(GEOM_Function) aRefVec1 = aPI.GetVector1(); + Handle(GEOM_Function) aRefVec2 = aPI.GetVector2(); + TopoDS_Shape aShape1 = aRefVec1->GetValue(); + TopoDS_Shape aShape2 = aRefVec2->GetValue(); + if (aShape1.ShapeType() != TopAbs_EDGE || + aShape2.ShapeType() != TopAbs_EDGE) return 0; + TopoDS_Edge aVectX = TopoDS::Edge(aShape1); + TopoDS_Edge aVectZ = TopoDS::Edge(aShape2); + + TopoDS_Vertex VX1, VX2, VZ1, VZ2; + TopExp::Vertices( aVectX, VX1, VX2, Standard_True ); + TopExp::Vertices( aVectZ, VZ1, VZ2, Standard_True ); + + gp_Vec aVX = gp_Vec( BRep_Tool::Pnt( VX1 ), BRep_Tool::Pnt( VX2 ) ); + gp_Vec aVZ = gp_Vec( BRep_Tool::Pnt( VZ1 ), BRep_Tool::Pnt( VZ2 ) ); + + if ( aVX.Magnitude() < Precision::Confusion() || aVZ.Magnitude() < Precision::Confusion()) + Standard_TypeMismatch::Raise("Invalid vector selected"); + + gp_Dir aDirX = gp_Dir( aVX.X(), aVX.Y(), aVX.Z() ); + gp_Dir aDirZ = gp_Dir( aVZ.X(), aVZ.Y(), aVZ.Z() ); + + if ( aDirX.IsParallel( aDirZ, Precision::Angular() ) ) + Standard_TypeMismatch::Raise("Parallel vectors selected"); + + gp_Ax3 aPlane = gp_Ax3( BRep_Tool::Pnt( VX1 ), aDirZ, aDirX ); + BRepBuilderAPI_MakeFace aTool(aPlane, -aSize, +aSize, -aSize, +aSize); + if(aTool.IsDone()) + aShape = aTool.Shape(); + } else if (aType == PLANE_LCS) { + Handle(GEOM_Function) aRef = aPI.GetLCS(); + double anOrientation = aPI.GetOrientation(); + gp_Ax3 anAx3; + if (aRef.IsNull()) { + gp_Ax2 anAx2 = gp::XOY(); + anAx3 = gp_Ax3( anAx2 ); + } else { + TopoDS_Shape aRefShape = aRef->GetValue(); + if (aRefShape.ShapeType() != TopAbs_FACE) + return 0; + anAx3 = GEOMImpl_IMeasureOperations::GetPosition(aRefShape); + } + + if ( anOrientation == 2) + anAx3 = gp_Ax3(anAx3.Location(), anAx3.XDirection(), anAx3.YDirection() ); + else if ( anOrientation == 3 ) + anAx3 = gp_Ax3(anAx3.Location(), anAx3.YDirection(), anAx3.XDirection() ); + + gp_Pln aPln(anAx3); + aShape = BRepBuilderAPI_MakeFace(aPln, -aSize, +aSize, -aSize, +aSize).Shape(); + } else { } diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index 49cf5542f..01c24ccb0 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -112,10 +112,12 @@ #define VECTOR_TANGENT_CURVE_PAR 3 #define VECTOR_FACE_NORMALE 4 -#define PLANE_PNT_VEC 1 -#define PLANE_FACE 2 -#define PLANE_THREE_PNT 3 +#define PLANE_PNT_VEC 1 +#define PLANE_FACE 2 +#define PLANE_THREE_PNT 3 #define PLANE_TANGENT_FACE 4 +#define PLANE_2_VEC 5 +#define PLANE_LCS 6 #define LINE_TWO_PNT 1 #define LINE_PNT_DIR 2 diff --git a/src/GEOM_I/GEOM_IBasicOperations_i.cc b/src/GEOM_I/GEOM_IBasicOperations_i.cc index b4c3b9f8e..f79e65308 100644 --- a/src/GEOM_I/GEOM_IBasicOperations_i.cc +++ b/src/GEOM_I/GEOM_IBasicOperations_i.cc @@ -422,6 +422,59 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneFace return GetObject(anObject); } +//============================================================================= +/*! + * MakePlane2Vec + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlane2Vec + (GEOM::GEOM_Object_ptr theVec1, GEOM::GEOM_Object_ptr theVec2, + CORBA::Double theTrimSize) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the references + Handle(GEOM_Object) aRef1 = GetObjectImpl(theVec1); + Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec2); + if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn(); + + //Create the plane + Handle(GEOM_Object) anObject = + GetOperations()->MakePlane2Vec(aRef1, aRef2, theTrimSize); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakePlaneLCS + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneLCS + (GEOM::GEOM_Object_ptr theLCS, CORBA::Double theTrimSize, + CORBA::Double theOrientation) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the references + Handle(GEOM_Object) aRef1 = GetObjectImpl(theLCS); + + //Create the plane + Handle(GEOM_Object) anObject = + GetOperations()->MakePlaneLCS(aRef1, theTrimSize, theOrientation); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} //============================================================================= /*! diff --git a/src/GEOM_I/GEOM_IBasicOperations_i.hh b/src/GEOM_I/GEOM_IBasicOperations_i.hh index cc44faafc..0cf59342f 100644 --- a/src/GEOM_I/GEOM_IBasicOperations_i.hh +++ b/src/GEOM_I/GEOM_IBasicOperations_i.hh @@ -91,6 +91,14 @@ class GEOM_I_EXPORT GEOM_IBasicOperations_i : GEOM::GEOM_Object_ptr MakePlaneFace (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize); + + GEOM::GEOM_Object_ptr MakePlane2Vec (GEOM::GEOM_Object_ptr theVec1, + GEOM::GEOM_Object_ptr theVec2, + CORBA::Double theTrimSize); + + GEOM::GEOM_Object_ptr MakePlaneLCS (GEOM::GEOM_Object_ptr theLCS, + CORBA::Double theTrimSize, + CORBA::Double theOrientation ); GEOM::GEOM_Object_ptr MakeMarker (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ, CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ, diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index 094b6e99f..8d9dd3272 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -690,6 +690,36 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePlaneFace (GEOM::GEOM_Object_ptr theFac return anObj; } +//============================================================================= +// MakePlane2Vec: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePlane2Vec (GEOM::GEOM_Object_ptr theVec1, + GEOM::GEOM_Object_ptr theVec2, + CORBA::Double theTrimSize) +{ + beginService( " GEOM_Superv_i::MakePlane2Vec" ); + MESSAGE("GEOM_Superv_i::MakePlane2Vec"); + getBasicOp(); + GEOM::GEOM_Object_ptr anObj = myBasicOp->MakePlane2Vec(theVec1, theVec2, theTrimSize); + endService( " GEOM_Superv_i::MakePlane2Vec" ); + return anObj; +} + +//============================================================================= +// MakePlaneLCS: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePlaneLCS (GEOM::GEOM_Object_ptr theLCS, + CORBA::Double theTrimSize, + CORBA::Double theOrientation) +{ + beginService( " GEOM_Superv_i::MakePlaneLCS" ); + MESSAGE("GEOM_Superv_i::MakePlaneLCS"); + getBasicOp(); + GEOM::GEOM_Object_ptr anObj = myBasicOp->MakePlaneLCS(theLCS, theTrimSize, theOrientation); + endService( " GEOM_Superv_i::MakePlaneLCS" ); + return anObj; +} + //============================================================================= // MakeMarker: //============================================================================= diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index e9e2dd242..e5c37fe14 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -166,6 +166,12 @@ public: CORBA::Double theTrimSize); GEOM::GEOM_Object_ptr MakePlaneFace (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize); + GEOM::GEOM_Object_ptr MakePlane2Vec (GEOM::GEOM_Object_ptr theVec1, + GEOM::GEOM_Object_ptr theVec2, + CORBA::Double theTrimSize); + GEOM::GEOM_Object_ptr MakePlaneLCS (GEOM::GEOM_Object_ptr theLCS, + CORBA::Double theTrimSize, + CORBA::Double theOrientation); GEOM::GEOM_Object_ptr MakeMarker (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ, CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ, CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ); diff --git a/src/GEOM_SWIG/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py index df4fcbc63..0a2983b40 100644 --- a/src/GEOM_SWIG/GEOM_TestAll.py +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -89,6 +89,8 @@ def TestAll (geompy, math): Line2 = geompy.MakeLineTwoPnt(pxyz, pz) #(2 GEOM_Object_ptr)->GEOM_Object_ptr Plane = geompy.MakePlane(pz, vxyz, trimsize) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr Plane1 = geompy.MakePlaneThreePnt(px, pz, p200, trimsize) #(4 Doubles)->GEOM_Object_ptr + Plane2 = geompy.MakePlane2Vec(vx, vz, trimsize) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr + Plane3 = geompy.MakePlaneLCS(cs1, trimsize, 3) #(1 GEOM_Object_ptr, 2 Double)->GEOM_Object_ptr Arc = geompy.MakeArc(py, pz, px) #(3 GEOM_Object_ptr)->GEOM_Object_ptr Arc2 = geompy.MakeArcCenter(py, pz, px,0) #(3 GEOM_Object_ptr,Boolean)->GEOM_Object_ptr @@ -303,6 +305,8 @@ def TestAll (geompy, math): id_Line3 = geompy.addToStudy(Line3, "Line on Two Faces Intersection") id_Plane = geompy.addToStudy(Plane, "Plane") id_Plane1 = geompy.addToStudy(Plane1, "Plane by 3 points") + id_Plane2 = geompy.addToStudy(Plane2, "Plane by 2 vectors") + id_Plane3 = geompy.addToStudy(Plane3, "Plane by LCS") id_Arc = geompy.addToStudy(Arc, "Arc") id_Arc2 = geompy.addToStudy(Arc2, "Arc2") diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 8214e3403..72beea22a 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -525,6 +525,37 @@ class geompyDC(GEOM._objref_GEOM_Gen): RaiseIfFailed("MakePlaneFace", self.BasicOp) anObj.SetParameters(Parameters) return anObj + + ## Create a plane, passing through the 2 vectors + # with center in a start point of the first vector. + # @param theVec1 Vector, defining center point and plane direction. + # @param theVec2 Vector, defining the plane normal direction. + # @param theTrimSize Half size of a side of quadrangle face, representing the plane. + # @return New GEOM_Object, containing the created plane. + # + # @ref tui_creation_plane "Example" + def MakePlane2Vec(self,theVec1, theVec2, theTrimSize): + # Example: see GEOM_TestAll.py + theTrimSize, Parameters = ParseParameters(theTrimSize); + anObj = self.BasicOp.MakePlane2Vec(theVec1, theVec2, theTrimSize) + RaiseIfFailed("MakePlane2Vec", self.BasicOp) + anObj.SetParameters(Parameters) + return anObj + + ## Create a plane, based on a Local coordinate system. + # @param theLCS coordinate system, defining plane. + # @param theTrimSize Half size of a side of quadrangle face, representing the plane. + # @param theOrientation OXY, OYZ or OZX orientation - (1, 2 or 3) + # @return New GEOM_Object, containing the created plane. + # + # @ref tui_creation_plane "Example" + def MakePlaneLCS(self,theLCS, theTrimSize, theOrientation): + # Example: see GEOM_TestAll.py + theTrimSize, Parameters = ParseParameters(theTrimSize); + anObj = self.BasicOp.MakePlaneLCS(theLCS, theTrimSize, theOrientation) + RaiseIfFailed("MakePlaneLCS", self.BasicOp) + anObj.SetParameters(Parameters) + return anObj ## Create a local coordinate system. # @param OX,OY,OZ Three coordinates of coordinate system origin.