From 89c42a4f37bca4013a3a9cdf7f0a9907975cc34e Mon Sep 17 00:00:00 2001 From: jfa Date: Thu, 6 Sep 2012 13:29:35 +0000 Subject: [PATCH] Mantis issue 0021392: EDF 1631 GEOM: Dump study of sketcher 3D with relatives coordinates. --- idl/GEOM_Gen.idl | 58 +- src/EntityGUI/EntityGUI_3DSketcherDlg.cxx | 992 ++++++++++---------- src/EntityGUI/EntityGUI_3DSketcherDlg.h | 12 +- src/GEOM/GEOM_Engine.cxx | 91 +- src/GEOMImpl/GEOMImpl_3DSketcherDriver.cxx | 248 ++++- src/GEOMImpl/GEOMImpl_I3DSketcher.hxx | 25 +- src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx | 142 ++- src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx | 12 +- src/GEOMImpl/GEOMImpl_Types.hxx | 6 +- src/GEOM_I/GEOM_ICurvesOperations_i.cc | 95 +- src/GEOM_I/GEOM_ICurvesOperations_i.hh | 61 +- src/GEOM_SWIG/geompyDC.py | 82 +- 12 files changed, 1165 insertions(+), 659 deletions(-) diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 7ff4315f8..8d5eb0b3c 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -2785,10 +2785,10 @@ module GEOM /*! * \brief Create a sketcher (wire or face), following the textual description, - * passed through \a theCommand argument. + * passed through \a theCommand argument. * * Edges of the resulting wire or face will be arcs of circles and/or linear segments. \n - * Format of the description string have to be the following: + * Format of the description string has to be the following: * * "Sketcher[:F x1 y1]:CMD[:CMD[:CMD...]]" * @@ -2816,32 +2816,60 @@ module GEOM * coordinates of the working plane. * \param theWorkingPlane Nine double values, defining origin, * OZ and OX directions of the working plane. - * \return New GEOM_Object, containing the created wire. + * \return New GEOM_Object, containing the created wire or face. */ GEOM_Object MakeSketcher (in string theCommand, in ListOfDouble theWorkingPlane); /*! - * \brief Create a 3D sketcher, following the numerical description, - * passed through points created by \a theCoordinates argument. + * \brief Create a sketcher (wire or face), following the textual description, + * passed through \a theCommand argument. * - * Format of the description string have to be the following: + * For format of the description string see the previous method.\n * - * "Make3DSketcher[x1, y1, z1, x2, y2, z2, ..., xN, yN, zN]" + * \param theCommand String, defining the sketcher in local + * coordinates of the working plane. + * \param theWorkingPlane Planar Face or LCS(Marker) of the working plane. + * \return New GEOM_Object, containing the created wire or face. */ + GEOM_Object MakeSketcherOnPlane (in string theCommand, in GEOM_Object theWorkingPlane); - GEOM_Object Make3DSketcher (in ListOfDouble theCoordinates); - - /*! - * \brief Create a sketcher (wire or face), following the textual description, - * passed through \a theCommand argument. + /*! + * \brief Create a 3D sketcher, following the textual description, + * passed through \a theCommand argument. + * + * Format of the description string has to be the following: + * + * "3DSketcher:CMD[:CMD[:CMD...]]" + * + * Where CMD is one of + * - "TT x y z" : Create segment by point at X & Y or set the first point + * - "T dx dy dz" : Create segment by point with DX & DY + * . + * \n + * - "OXY angleX angle2 length" : Create segment by two angles and length + * - "OYZ angleY angle2 length" : Create segment by two angles and length + * - "OXZ angleX angle2 length" : Create segment by two angles and length + * . + * \n + * - "WW" : Close Wire (to finish) * - * For format of the description string see the previous method.\n * \param theCommand String, defining the sketcher in local * coordinates of the working plane. - * \param theWorkingPlane Planar Face or LCS(Marker) of the working plane. * \return New GEOM_Object, containing the created wire. */ - GEOM_Object MakeSketcherOnPlane (in string theCommand, in GEOM_Object theWorkingPlane); + GEOM_Object Make3DSketcherCommand (in string theCommand); + + /*! + * \brief Create a 3D sketcher, made of a straight segments, joining points + * with coordinates passed through \a theCoordinates argument. + * + * Order of coordinates has to be the following: + * x1, y1, z1, x2, y2, z2, ..., xN, yN, zN + * + * \param theCoordinates List of double values. + * \return New GEOM_Object, containing the created wire. + */ + GEOM_Object Make3DSketcher (in ListOfDouble theCoordinates); }; // # GEOM_ILocalOperations: diff --git a/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx b/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx index 53b0694e9..1295b3e0d 100755 --- a/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx +++ b/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx @@ -15,12 +15,11 @@ // 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 : EntityGUI_3DSketcherDlg.cxx // Author : DMV, OCN -// + #include #include #include @@ -31,7 +30,7 @@ #include #include -#include +#include #include #include @@ -89,8 +88,8 @@ enum class Locker { public: - Locker( bool& l ) : myLock( l ) { myLock = true; } - ~Locker() { myLock = false; } + Locker(bool& l) : myLock(l) { myLock = true; } + ~Locker() { myLock = false; } private: bool& myLock; }; @@ -102,27 +101,27 @@ private: // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -EntityGUI_3DSketcherDlg::EntityGUI_3DSketcherDlg( GeometryGUI* theGeometryGUI, QWidget* parent, +EntityGUI_3DSketcherDlg::EntityGUI_3DSketcherDlg (GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl, - const double lineWidth ) - : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ), - myMode( -1 ), - myOK( false ), - myLineWidth( lineWidth ), - myGeometryGUI( theGeometryGUI ), + const double lineWidth) + : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl), + myMode(-1), + myOK(false), + myLineWidth(lineWidth), + myGeometryGUI(theGeometryGUI), myLengthIORedoList() { - QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); - QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) ); - QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) ); - QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICO_3DSKETCH" ) ) ); + QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT"))); + QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_UNDO"))); + QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_REDO"))); + QPixmap image3(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICO_3DSKETCH"))); - setWindowTitle( tr( "GEOM_3DSKETCHER_TITLE" ) ); + setWindowTitle(tr("GEOM_3DSKETCHER_TITLE")); /***************************************************************/ - mainFrame()->GroupConstructors->setTitle( tr( "GEOM_3DSKETCHER" ) ); - mainFrame()->RadioButton1->setIcon( image3 );; + mainFrame()->GroupConstructors->setTitle(tr("GEOM_3DSKETCHER")); + mainFrame()->RadioButton1->setIcon(image3);; mainFrame()->RadioButton2->close(); mainFrame()->RadioButton3->close(); @@ -132,48 +131,46 @@ EntityGUI_3DSketcherDlg::EntityGUI_3DSketcherDlg( GeometryGUI* theGeometryGUI, Q GroupType->RadioButton2->setText(tr("GEOM_SKETCHER_REL")); GroupType->RadioButton3->setText(tr("Angles")); //TODO translation // GroupType->RadioButton3->close(); - myTypeGroup = new QButtonGroup( this ); - myTypeGroup->addButton( GroupType->RadioButton1, 0 ); - myTypeGroup->addButton( GroupType->RadioButton2, 1 ); - myTypeGroup->addButton( GroupType->RadioButton3, 2 ); - - Group3Spin = new EntityGUI_3Spin( centralWidget() ); - Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) ); - Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) ); - Group3Spin->buttonUndo->setIcon( image1 ); - Group3Spin->buttonRedo->setIcon( image2 ); - Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) ); - Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) ); - Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Z2" ) ); - - GroupAngles = new EntityGUI_Angles( centralWidget() ); - GroupAngles->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) ); - GroupAngles->buttonUndo->setIcon( image1 ); - GroupAngles->buttonRedo->setIcon( image2 ); - GroupAngles->checkBox->setText( tr( "Angle 2" ) ); //TODO translation - - GroupControls = new EntityGUI_Controls( centralWidget() ); + myTypeGroup = new QButtonGroup(this); + myTypeGroup->addButton(GroupType->RadioButton1, 0); + myTypeGroup->addButton(GroupType->RadioButton2, 1); + myTypeGroup->addButton(GroupType->RadioButton3, 2); + + Group3Spin = new EntityGUI_3Spin(centralWidget()); + Group3Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES")); + Group3Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY")); + Group3Spin->buttonUndo->setIcon(image1); + Group3Spin->buttonRedo->setIcon(image2); + Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X2")); + Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y2")); + Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_Z2")); + + GroupAngles = new EntityGUI_Angles(centralWidget()); + GroupAngles->buttonApply->setText(tr("GEOM_SKETCHER_APPLY")); + GroupAngles->buttonUndo->setIcon(image1); + GroupAngles->buttonRedo->setIcon(image2); + GroupAngles->checkBox->setText(tr("Angle 2")); //TODO translation + + GroupControls = new EntityGUI_Controls(centralWidget()); GroupControls->GroupBox1->setTitle(tr("GEOM_CONTROLS")); - GroupControls->CheckBox1->setText( tr( "Show length dimensions" ) ); //TODO translation - GroupControls->CheckBox2->setText( tr( "Show angle dimensions" ) ); //TODO translation + GroupControls->CheckBox1->setText(tr("Show length dimensions")); //TODO translation + GroupControls->CheckBox2->setText(tr("Show angle dimensions")); //TODO translation - buttonOk()->setText( tr( "GEOM_BUT_END_SKETCH" ) ); - buttonApply()->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) ); - - QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); - layout->setMargin( 0 ); layout->setSpacing( 6 ); - layout->addWidget( GroupType ); - layout->addWidget( Group3Spin ); - layout->addWidget( GroupAngles ); - layout->addWidget( GroupControls ); + buttonOk()->setText(tr("GEOM_BUT_END_SKETCH")); + buttonApply()->setText(tr("GEOM_BUT_CLOSE_SKETCH")); - setHelpFileName( "create_3dsketcher_page.html" ); + QVBoxLayout* layout = new QVBoxLayout(centralWidget()); + layout->setMargin(0); layout->setSpacing(6); + layout->addWidget(GroupType); + layout->addWidget(Group3Spin); + layout->addWidget(GroupAngles); + layout->addWidget(GroupControls); + + setHelpFileName("create_3dsketcher_page.html"); resize(100,100); Init(); -} - - +} //================================================================================= // function : ~EntityGUI_3DSketcherDlg() @@ -181,7 +178,7 @@ EntityGUI_3DSketcherDlg::EntityGUI_3DSketcherDlg( GeometryGUI* theGeometryGUI, Q //================================================================================= EntityGUI_3DSketcherDlg::~EntityGUI_3DSketcherDlg() { - myGeomGUI->SetActiveDialogBox( 0 ); + myGeomGUI->SetActiveDialogBox(0); } //================================================================================= @@ -193,150 +190,152 @@ void EntityGUI_3DSketcherDlg::Init() myOK = false; myOrientation = 1; myPrsType = NONE; - + SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); myAnglePrs = dynamic_cast(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); myLengthPrs = dynamic_cast(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); - + //TEST - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); // globalSelection(GEOM_PREVIEW); /* Get setting of step value from file configuration */ - double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 ); + double step = SUIT_Session::session()->resourceMgr()->doubleValue("Geometry", "SettingsGeomStep", 100.0); /* min, max, step and decimals for spin boxes */ - initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" ); - initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" ); - initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" ); - - initSpinBox( GroupAngles->SpinBox_DA , -180.0, 180.0, step, "angular_precision" ); - initSpinBox( GroupAngles->SpinBox_DA2, -90.0, 90.0, step, "angular_precision" ); - initSpinBox( GroupAngles->SpinBox_DL , COORD_MIN, COORD_MAX, step, "length_precision" ); + initSpinBox(Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision"); + initSpinBox(Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision"); + initSpinBox(Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision"); + + initSpinBox(GroupAngles->SpinBox_DA , -180.0, 180.0, step, "angular_precision"); + initSpinBox(GroupAngles->SpinBox_DA2, -90.0, 90.0, step, "angular_precision"); + initSpinBox(GroupAngles->SpinBox_DL , COORD_MIN, COORD_MAX, step, "length_precision"); Group3Spin->SpinBox_DX->setValue(0.0); Group3Spin->SpinBox_DY->setValue(0.0); Group3Spin->SpinBox_DZ->setValue(0.0); - + GroupAngles->SpinBox_DA->setValue(0.0); GroupAngles->SpinBox_DA2->setValue(0.0); GroupAngles->SpinBox_DL->setValue(0.0); - + GroupAngles->radioButton_1->setChecked(true); GroupAngles->checkBox->setChecked(false); - GroupAngles->SpinBox_DA2->setEnabled(false); - - GroupControls->CheckBox1->setChecked( true ); - GroupControls->CheckBox2->setChecked( true ); + GroupAngles->SpinBox_DA2->setEnabled(false); + + GroupControls->CheckBox1->setChecked(true); + GroupControls->CheckBox2->setChecked(true); isLengthVisible = true; isAngleVisible = true; - + GroupAngles->hide(); /* signals and slots connections */ - connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); - - connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - - connect( Group3Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnAddPoint() ) ); - connect( Group3Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) ); - connect( Group3Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ; - - connect( GroupAngles->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnAddPoint() ) ); - connect( GroupAngles->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) ); - connect( GroupAngles->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ; - - connect( myTypeGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( TypeClicked( int ) ) ); - - connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - - connect( GroupAngles->SpinBox_DA, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - connect( GroupAngles->SpinBox_DA2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - connect( GroupAngles->SpinBox_DL, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); - - connect( GroupAngles->radioButton_1, SIGNAL( clicked ( bool ) ), this, SLOT( ButtonClicked(bool) ) ) ; - connect( GroupAngles->radioButton_2, SIGNAL( clicked ( bool ) ), this, SLOT( ButtonClicked(bool) ) ) ; - connect( GroupAngles->radioButton_3, SIGNAL( clicked ( bool ) ), this, SLOT( ButtonClicked(bool) ) ) ; - - connect( GroupAngles->checkBox, SIGNAL( clicked ( bool ) ), this, SLOT( BoxChecked (bool) ) ) ; - connect( GroupControls->CheckBox1, SIGNAL( clicked ( bool ) ), this, SLOT( BoxChecked (bool) ) ) ; - connect( GroupControls->CheckBox2, SIGNAL( clicked ( bool ) ), this, SLOT( BoxChecked (bool) ) ) ; - - connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) ); - - connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ); - connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ); - - initName( tr( "GEOM_3DSKETCHER" ) ); + connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + connect(Group3Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnAddPoint())); + connect(Group3Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo())); + connect(Group3Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo())) ; + + connect(GroupAngles->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnAddPoint())); + connect(GroupAngles->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo())); + connect(GroupAngles->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo())) ; + + connect(myTypeGroup, SIGNAL(buttonClicked(int)), this, SLOT(TypeClicked(int))); + + connect(Group3Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(Group3Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(Group3Spin->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + + connect(GroupAngles->SpinBox_DA, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupAngles->SpinBox_DA2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupAngles->SpinBox_DL, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + + connect(GroupAngles->radioButton_1, SIGNAL(clicked (bool)), this, SLOT(ButtonClicked(bool))) ; + connect(GroupAngles->radioButton_2, SIGNAL(clicked (bool)), this, SLOT(ButtonClicked(bool))) ; + connect(GroupAngles->radioButton_3, SIGNAL(clicked (bool)), this, SLOT(ButtonClicked(bool))) ; + + connect(GroupAngles->checkBox, SIGNAL(clicked (bool)), this, SLOT(BoxChecked (bool))) ; + connect(GroupControls->CheckBox1, SIGNAL(clicked (bool)), this, SLOT(BoxChecked (bool))) ; + connect(GroupControls->CheckBox2, SIGNAL(clicked (bool)), this, SLOT(BoxChecked (bool))) ; + + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double))); + + connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); + + initName(tr("GEOM_3DSKETCHER")); UpdateButtonsState(); - GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth ); + GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth); } //================================================================================= // function : TypeClicked() // purpose : Radio button management //================================================================================= -void EntityGUI_3DSketcherDlg::TypeClicked( int mode ) +void EntityGUI_3DSketcherDlg::TypeClicked (int mode) { - if ( mode == myMode ) return; + if (mode == myMode) return; GroupAngles->hide(); Group3Spin->show(); - + bool blocked = Group3Spin->SpinBox_DX->signalsBlocked(); Group3Spin->SpinBox_DX->blockSignals(true); Group3Spin->SpinBox_DY->blockSignals(true); Group3Spin->SpinBox_DZ->blockSignals(true); + // Get setting of step value from file configuration XYZ xyz = getLastPoint(); bool okx, oky, okz; - Group3Spin->SpinBox_DX->text().toDouble( &okx ); - Group3Spin->SpinBox_DY->text().toDouble( &oky ); - Group3Spin->SpinBox_DZ->text().toDouble( &okz ); - if ( mode == 0 ) { // XY - Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) ); - Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) ); - Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Z2" ) ); + Group3Spin->SpinBox_DX->text().toDouble(&okx); + Group3Spin->SpinBox_DY->text().toDouble(&oky); + Group3Spin->SpinBox_DZ->text().toDouble(&okz); + + if (mode == 0) { // XYZ + Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X2")); + Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y2")); + Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_Z2")); if (myMode == 1) { - if ( okx ) Group3Spin->SpinBox_DX->setValue( xyz.x + Group3Spin->SpinBox_DX->value() ); - if ( oky ) Group3Spin->SpinBox_DY->setValue( xyz.y + Group3Spin->SpinBox_DY->value() ); - if ( okz ) Group3Spin->SpinBox_DZ->setValue( xyz.z + Group3Spin->SpinBox_DZ->value() ); + if (okx) Group3Spin->SpinBox_DX->setValue(xyz.x + Group3Spin->SpinBox_DX->value()); + if (oky) Group3Spin->SpinBox_DY->setValue(xyz.y + Group3Spin->SpinBox_DY->value()); + if (okz) Group3Spin->SpinBox_DZ->setValue(xyz.z + Group3Spin->SpinBox_DZ->value()); } Group3Spin->buttonApply->setFocus(); } - else if ( mode == 1) { // DXDY - Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) ); - Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) ); - Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_DZ2" ) ); + else if (mode == 1) { // DXDYDZ + Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_DX2")); + Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_DY2")); + Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_DZ2")); if (myMode == 0) { - if ( okx ) Group3Spin->SpinBox_DX->setValue( Group3Spin->SpinBox_DX->value() - xyz.x ); - if ( oky ) Group3Spin->SpinBox_DY->setValue( Group3Spin->SpinBox_DY->value() - xyz.y ); - if ( okz ) Group3Spin->SpinBox_DZ->setValue( Group3Spin->SpinBox_DZ->value() - xyz.z ); + if (okx) Group3Spin->SpinBox_DX->setValue(Group3Spin->SpinBox_DX->value() - xyz.x); + if (oky) Group3Spin->SpinBox_DY->setValue(Group3Spin->SpinBox_DY->value() - xyz.y); + if (okz) Group3Spin->SpinBox_DZ->setValue(Group3Spin->SpinBox_DZ->value() - xyz.z); } Group3Spin->buttonApply->setFocus(); } - else if (mode == 2){ // Angles + else if (mode == 2) { // Angles and Length Group3Spin->hide(); GroupAngles->show(); GroupAngles->buttonApply->setFocus(); } - + Group3Spin->SpinBox_DX->blockSignals(blocked); Group3Spin->SpinBox_DY->blockSignals(blocked); Group3Spin->SpinBox_DZ->blockSignals(blocked); myMode = mode; - + updateGeometry(); resize(minimumSizeHint()); - - GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth ); + + GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth); } //================================================================================= @@ -346,70 +345,69 @@ void EntityGUI_3DSketcherDlg::TypeClicked( int mode ) void EntityGUI_3DSketcherDlg::ClickOnAddPoint() { QString msg; - if ( !isValid( msg ) ) { - showError( msg ); + if (!isValid(msg)) { + showError(msg); return; } - + // Display and store angle dimensions interactive objects in Prs - if( GroupType->RadioButton3->isChecked() ) + if (GroupType->RadioButton3->isChecked()) { double anAngle2 = 0.0; if (GroupAngles->checkBox->isChecked()) anAngle2 = GroupAngles->SpinBox_DA2->value(); - + // Store length dimensions displayLength(GroupAngles->SpinBox_DL->value(), /*store =*/true); // Store angle dimensions - displayAngle(GroupAngles->SpinBox_DA->value(), anAngle2, - GroupAngles->SpinBox_DL->value(), myOrientation, /*store =*/true); + displayAngle(GroupAngles->SpinBox_DA->value(), anAngle2, + GroupAngles->SpinBox_DL->value(), myOrientation, /*store =*/true); } - + // Display and store store length dimension interactive object in Prs if (GroupType->RadioButton1->isChecked() || GroupType->RadioButton2->isChecked()) { displayLength(-1, /*store=*/true); } - - myPointsList.append( getCurrentPoint() ); - myPrsTypeList.push_back( myPrsType ); - + + myPointsList.append(getCurrentPoint()); + myPrsTypeList.push_back(myPrsType); + // Clean redo lists myRedoList.clear(); myPrsTypeRedoList.clear(); myLengthIORedoList.Clear(); myAngleIORedoList.Clear(); - - if ( myMode == 1 ) { - Group3Spin->SpinBox_DX->setValue( 0.0 ); - Group3Spin->SpinBox_DY->setValue( 0.0 ); - Group3Spin->SpinBox_DZ->setValue( 0.0 ); + + if (myMode == 1) { + Group3Spin->SpinBox_DX->setValue(0.0); + Group3Spin->SpinBox_DY->setValue(0.0); + Group3Spin->SpinBox_DZ->setValue(0.0); } - else if ( myMode == 2 ) + else if (myMode == 2) { - GroupAngles->SpinBox_DA->setValue( 0.0 ); - GroupAngles->SpinBox_DL->setValue( 0.0 ); - GroupAngles->SpinBox_DA2->setValue( 0.0 ); + GroupAngles->SpinBox_DA->setValue(0.0); + GroupAngles->SpinBox_DL->setValue(0.0); + GroupAngles->SpinBox_DA2->setValue(0.0); } UpdateButtonsState(); - GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth ); - + GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth); } //================================================================================= // function : UpdateButtonsState() -// purpose : +// purpose : //================================================================================= void EntityGUI_3DSketcherDlg::UpdateButtonsState() { - if ( myPointsList.count() == 0 ) GroupType->RadioButton1->click(); - GroupType->RadioButton2->setEnabled( myPointsList.count() > 0 ); - GroupType->RadioButton3->setEnabled( myPointsList.count() > 0 ); - Group3Spin->buttonUndo->setEnabled( myPointsList.count() > 0 ); - Group3Spin->buttonRedo->setEnabled( myRedoList.count() > 0 ); - GroupAngles->buttonUndo->setEnabled( myPointsList.count() > 0 ); - GroupAngles->buttonRedo->setEnabled( myRedoList.count() > 0 ); + if (myPointsList.count() == 0) GroupType->RadioButton1->click(); + GroupType->RadioButton2->setEnabled(myPointsList.count() > 0); + GroupType->RadioButton3->setEnabled(myPointsList.count() > 0); + Group3Spin->buttonUndo->setEnabled(myPointsList.count() > 0); + Group3Spin->buttonRedo->setEnabled(myRedoList.count() > 0); + GroupAngles->buttonUndo->setEnabled(myPointsList.count() > 0); + GroupAngles->buttonRedo->setEnabled(myRedoList.count() > 0); } //================================================================================= @@ -419,42 +417,42 @@ void EntityGUI_3DSketcherDlg::UpdateButtonsState() void EntityGUI_3DSketcherDlg::ClickOnUndo() { if (myPointsList.count() > 0) { - myRedoList.append( myPointsList.takeLast() ); + myRedoList.append(myPointsList.takeLast()); UpdateButtonsState(); - GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth ); - + GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth); + // Erase dimensions presentations SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); - ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myLengthPrs, true); + ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myLengthPrs, true); ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myAnglePrs, true); - + if (myPrsTypeList.back() != NONE) { // Remove last prepended IO - removeLastIOFromPrs( TYPE_LENGTH ); - } - if ( myPrsTypeList.back() == TYPE_ANGLE || - myPrsTypeList.back() == TYPE_TWO_ANGLES ) + removeLastIOFromPrs(TYPE_LENGTH); + } + if (myPrsTypeList.back() == TYPE_ANGLE || + myPrsTypeList.back() == TYPE_TWO_ANGLES) { // Remove first Angle IO from presentation - removeLastIOFromPrs( TYPE_ANGLE ); - if ( myPrsTypeList.back() == TYPE_TWO_ANGLES ) + removeLastIOFromPrs(TYPE_ANGLE); + if (myPrsTypeList.back() == TYPE_TWO_ANGLES) { // Remove second Angle IO - removeLastIOFromPrs( TYPE_ANGLE ); + removeLastIOFromPrs(TYPE_ANGLE); } } - + // Erase last action type and store it in redo list myPrsTypeRedoList.push_back(myPrsTypeList.back()); myPrsTypeList.pop_back(); - + // Display modified presentation if (isLengthVisible) ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myLengthPrs); if (isAngleVisible) ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myAnglePrs); - + updateViewer(); } } @@ -465,41 +463,41 @@ void EntityGUI_3DSketcherDlg::ClickOnUndo() //================================================================================= void EntityGUI_3DSketcherDlg::ClickOnRedo() { - if ( myRedoList.count() > 0) { - myPointsList.append( myRedoList.takeLast() ); + if (myRedoList.count() > 0) { + myPointsList.append(myRedoList.takeLast()); UpdateButtonsState(); - GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth ); - + GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth); + // Erase dimensions presentations SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myLengthPrs, true); ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myAnglePrs, true); - - if ( myPrsTypeRedoList.back() != NONE ) - restoreLastIOToPrs( TYPE_LENGTH ); - - if ( myPrsTypeRedoList.back() == TYPE_ANGLE || - myPrsTypeRedoList.back() == TYPE_TWO_ANGLES ) + + if (myPrsTypeRedoList.back() != NONE) + restoreLastIOToPrs(TYPE_LENGTH); + + if (myPrsTypeRedoList.back() == TYPE_ANGLE || + myPrsTypeRedoList.back() == TYPE_TWO_ANGLES) { // Add a first IO from the Redo list - restoreLastIOToPrs( TYPE_ANGLE ); - if ( myPrsTypeRedoList.back() == TYPE_TWO_ANGLES ) + restoreLastIOToPrs(TYPE_ANGLE); + if (myPrsTypeRedoList.back() == TYPE_TWO_ANGLES) { // Add a second IO from the Redo list - restoreLastIOToPrs( TYPE_ANGLE ); + restoreLastIOToPrs(TYPE_ANGLE); } } - + // Record last prs type myPrsTypeList.push_back(myPrsTypeRedoList.back()); myPrsTypeRedoList.pop_back(); - + // Display modified presentation if (isLengthVisible) ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myLengthPrs); if (isAngleVisible) ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myAnglePrs); - + updateViewer(); } } @@ -508,40 +506,40 @@ void EntityGUI_3DSketcherDlg::ClickOnRedo() // function : removeLastIO() // purpose : //================================================================================= -void EntityGUI_3DSketcherDlg::removeLastIOFromPrs(int type) +void EntityGUI_3DSketcherDlg::removeLastIOFromPrs (int type) { AIS_ListOfInteractive anIOList; - + if (type == TYPE_LENGTH) { myLengthPrs->GetObjects(anIOList); myLengthIORedoList.Prepend(anIOList.First()); // Store last prepended Length IO in redo list myLengthPrs->RemoveFirst(); // Remove it from myLengthPrs - } + } if (type == TYPE_ANGLE) { myAnglePrs->GetObjects(anIOList); myAngleIORedoList.Prepend(anIOList.First()); // Store last prepended Angle IO in redo list myAnglePrs->RemoveFirst(); // Remove it from myAnglePrs - } + } } //================================================================================= // function : restoreLastIO() // purpose : //================================================================================= -void EntityGUI_3DSketcherDlg::restoreLastIOToPrs(int type) +void EntityGUI_3DSketcherDlg::restoreLastIOToPrs (int type) { if (type == TYPE_LENGTH) { myLengthPrs->PrependObject(myLengthIORedoList.First()); // Restore last removed IO myLengthIORedoList.RemoveFirst(); // Remove it from redo list - } + } if (type == TYPE_ANGLE) { myAnglePrs->PrependObject(myAngleIORedoList.First()); // Restore last removed IO myAngleIORedoList.RemoveFirst(); // Remove it from redo list - } + } } //================================================================================= @@ -555,26 +553,26 @@ void EntityGUI_3DSketcherDlg::SelectionIntoArgument() aSelMgr->selectedObjects(aSelList); int nbSel = aSelList.Extent(); - if ( nbSel == 1 ) { - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - if ( !CORBA::is_nil(aSelectedObject) ) { + if (nbSel == 1) { + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First()); + if (!CORBA::is_nil(aSelectedObject)) { TopoDS_Shape aShape; - if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE)) { // Explore the shape if its a local selection + if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE)) { + // Explore the shape if its a local selection TColStd_IndexedMapOfInteger aMap; aSelMgr->GetIndexes(aSelList.First(), aMap); - if (aMap.Extent() == 1) - { - int anIndex = aMap(1); - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - } + if (aMap.Extent() == 1) { + int anIndex = aMap(1); + GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } } bool isOk = true; - if ( aShape.ShapeType() != TopAbs_VERTEX ) + if (aShape.ShapeType() != TopAbs_VERTEX) isOk = GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX); if (isOk) { gp_Pnt aPnt; - if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) { + if (GEOMBase::VertexToPoint(aShape, aPnt)) { // set coordinates to the Spin Boxes double aX, aY, aZ; aX = aPnt.X(); @@ -584,15 +582,16 @@ void EntityGUI_3DSketcherDlg::SelectionIntoArgument() Group3Spin->SpinBox_DX->blockSignals(true); Group3Spin->SpinBox_DY->blockSignals(true); Group3Spin->SpinBox_DZ->blockSignals(true); - if ( GroupType->RadioButton1->isChecked() ) { - Group3Spin->SpinBox_DX->setValue( aX ); - Group3Spin->SpinBox_DY->setValue( aY ); - Group3Spin->SpinBox_DZ->setValue( aZ ); - } else if ( GroupType->RadioButton2->isChecked() ) { + if (GroupType->RadioButton1->isChecked()) { + Group3Spin->SpinBox_DX->setValue(aX); + Group3Spin->SpinBox_DY->setValue(aY); + Group3Spin->SpinBox_DZ->setValue(aZ); + } + else if (GroupType->RadioButton2->isChecked()) { XYZ xyz = getLastPoint(); - Group3Spin->SpinBox_DX->setValue( aX - xyz.x ); - Group3Spin->SpinBox_DY->setValue( aY - xyz.y ); - Group3Spin->SpinBox_DZ->setValue( aZ - xyz.z ); + Group3Spin->SpinBox_DX->setValue(aX - xyz.x); + Group3Spin->SpinBox_DY->setValue(aY - xyz.y); + Group3Spin->SpinBox_DZ->setValue(aZ - xyz.z); } Group3Spin->SpinBox_DX->blockSignals(blocked); Group3Spin->SpinBox_DY->blockSignals(blocked); @@ -601,7 +600,7 @@ void EntityGUI_3DSketcherDlg::SelectionIntoArgument() } } } - GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth ); + GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth); } //================================================================================= @@ -610,13 +609,12 @@ void EntityGUI_3DSketcherDlg::SelectionIntoArgument() //================================================================================= void EntityGUI_3DSketcherDlg::DeactivateActiveDialog() { - setEnabled( false ); + setEnabled(false); globalSelection(); - disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); - myGeomGUI->SetActiveDialogBox( 0 ); + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + myGeomGUI->SetActiveDialogBox(0); } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -624,43 +622,41 @@ void EntityGUI_3DSketcherDlg::DeactivateActiveDialog() void EntityGUI_3DSketcherDlg::ActivateThisDialog() { myGeomGUI->EmitSignalDeactivateDialog(); - setEnabled( true ); - myGeomGUI->SetActiveDialogBox( this ); + setEnabled(true); + myGeomGUI->SetActiveDialogBox(this); - connect( myGeomGUI->getApp()->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect(myGeomGUI->getApp()->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); - GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth ); + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); + GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth); } - //================================================================================= // function : ValueChangedInSpinBox() // purpose : //================================================================================= -void EntityGUI_3DSketcherDlg::ValueChangedInSpinBox( double newValue ) +void EntityGUI_3DSketcherDlg::ValueChangedInSpinBox (double newValue) { - GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth ); + GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth); } - //================================================================================= // function : BoxChecked() // purpose : ChecBoxes management //================================================================================= -void EntityGUI_3DSketcherDlg::BoxChecked( bool checked ) +void EntityGUI_3DSketcherDlg::BoxChecked (bool checked) { QCheckBox* send = (QCheckBox*) sender(); SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); - + if (send == GroupAngles->checkBox) - GroupAngles->SpinBox_DA2->setEnabled(checked); - + GroupAngles->SpinBox_DA2->setEnabled(checked); + else if (send == GroupControls->CheckBox1) { ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myLengthPrs, true); - if(checked){ + if (checked){ ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myLengthPrs); isLengthVisible=true; } @@ -669,8 +665,8 @@ void EntityGUI_3DSketcherDlg::BoxChecked( bool checked ) } else if (send == GroupControls->CheckBox2) { - ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myAnglePrs, true); - if(checked) + ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myAnglePrs, true); + if (checked) { ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myAnglePrs); isAngleVisible=true; @@ -679,32 +675,32 @@ void EntityGUI_3DSketcherDlg::BoxChecked( bool checked ) isAngleVisible=false; } - GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth ); + GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth); } //================================================================================= // function : ButtonClicked() // purpose : //================================================================================= -void EntityGUI_3DSketcherDlg::ButtonClicked( bool checked ) +void EntityGUI_3DSketcherDlg::ButtonClicked (bool checked) { if (GroupAngles->radioButton_1->isChecked()) myOrientation = 1; else if (GroupAngles->radioButton_2->isChecked()) myOrientation = 2; else - myOrientation = 3; - - GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth ); + myOrientation = 3; + + GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth); } //================================================================================= // function : enterEvent() // purpose : //================================================================================= -void EntityGUI_3DSketcherDlg::enterEvent( QEvent* ) +void EntityGUI_3DSketcherDlg::enterEvent (QEvent*) { - if ( !mainFrame()->GroupConstructors->isEnabled() ) + if (!mainFrame()->GroupConstructors->isEnabled()) ActivateThisDialog(); } @@ -714,19 +710,19 @@ void EntityGUI_3DSketcherDlg::enterEvent( QEvent* ) //================================================================================= GEOM::GEOM_IOperations_ptr EntityGUI_3DSketcherDlg::createOperation() { - return getGeomEngine()->GetICurvesOperations( getStudyId() ); + return getGeomEngine()->GetICurvesOperations(getStudyId()); } //================================================================================= // function : isValid // purpose : //================================================================================= -bool EntityGUI_3DSketcherDlg::isValid( QString& msg ) +bool EntityGUI_3DSketcherDlg::isValid (QString& msg) { bool ok = true; - ok = Group3Spin->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - ok = Group3Spin->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; - ok = Group3Spin->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok; + ok = Group3Spin->SpinBox_DX->isValid(msg, !IsPreview()) && ok; + ok = Group3Spin->SpinBox_DY->isValid(msg, !IsPreview()) && ok; + ok = Group3Spin->SpinBox_DZ->isValid(msg, !IsPreview()) && ok; return ok; } @@ -734,43 +730,44 @@ bool EntityGUI_3DSketcherDlg::isValid( QString& msg ) // function : execute // purpose : //================================================================================= -bool EntityGUI_3DSketcherDlg::execute( ObjectList& objects ) +bool EntityGUI_3DSketcherDlg::execute (ObjectList& objects) { - GEOM::ListOfDouble_var aCoordsArray = new GEOM::ListOfDouble; - if (!myOK || myPointsList.size() == 0) - aCoordsArray->length((myPointsList.size()+1)*3); - else - aCoordsArray->length(myPointsList.size()*3); - + //GEOM::ListOfDouble_var aCoordsArray = new GEOM::ListOfDouble; + //if (!myOK || myPointsList.size() == 0) + // aCoordsArray->length((myPointsList.size()+1)*3); + //else + // aCoordsArray->length(myPointsList.size()*3); + + QStringList aCommands; + aCommands << "3DSketcher"; QStringList aParameters; - int i = 0; + //int i = 0; QList::const_iterator it; - for(it = myPointsList.begin(); it != myPointsList.end(); ++it ) { - aCoordsArray[i++] = (*it).x; - aCoordsArray[i++] = (*it).y; - aCoordsArray[i++] = (*it).z; - aParameters << (*it).xt; - aParameters << (*it).yt; - aParameters << (*it).zt; + for (it = myPointsList.begin(); it != myPointsList.end(); ++it) { + //aCoordsArray[i++] = (*it).x; + //aCoordsArray[i++] = (*it).y; + //aCoordsArray[i++] = (*it).z; + aCommands << (*it).command; + aParameters << (*it).params; } if (!myOK || myPointsList.size() == 0) { XYZ xyz = getCurrentPoint(); - aCoordsArray[i++] = xyz.x; - aCoordsArray[i++] = xyz.y; - aCoordsArray[i++] = xyz.z; - aParameters << xyz.xt; - aParameters << xyz.yt; - aParameters << xyz.zt; - } + //aCoordsArray[i++] = xyz.x; + //aCoordsArray[i++] = xyz.y; + //aCoordsArray[i++] = xyz.z; + aCommands << xyz.command; + aParameters << xyz.params; + } GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation()); - GEOM::GEOM_Object_var anObj = anOper->Make3DSketcher( aCoordsArray ); + //GEOM::GEOM_Object_var anObj = anOper->Make3DSketcher(aCoordsArray); + GEOM::GEOM_Object_var anObj = anOper->Make3DSketcherCommand(aCommands.join(":").toLatin1().constData()); - if ( !anObj->_is_nil() ) { - if ( !IsPreview() ) anObj->SetParameters(aParameters.join(":").toLatin1().constData()); - objects.push_back( anObj._retn() ); + if (!anObj->_is_nil()) { + if (!IsPreview()) anObj->SetParameters(aParameters.join(":").toLatin1().constData()); + objects.push_back(anObj._retn()); } return true; @@ -780,7 +777,7 @@ bool EntityGUI_3DSketcherDlg::execute( ObjectList& objects ) // function : SetDoubleSpinBoxStep() // purpose : Double spin box management //================================================================================= -void EntityGUI_3DSketcherDlg::SetDoubleSpinBoxStep( double step ) +void EntityGUI_3DSketcherDlg::SetDoubleSpinBoxStep (double step) { Group3Spin->SpinBox_DX->setSingleStep(step); Group3Spin->SpinBox_DY->setSingleStep(step); @@ -796,9 +793,9 @@ void EntityGUI_3DSketcherDlg::SetDoubleSpinBoxStep( double step ) //================================================================================= void EntityGUI_3DSketcherDlg::ClickOnOk() { - Locker lock( myOK ); + Locker lock(myOK); - if ( !onAccept() ) + if (!onAccept()) return; ClickOnCancel(); @@ -811,19 +808,19 @@ void EntityGUI_3DSketcherDlg::ClickOnOk() bool EntityGUI_3DSketcherDlg::ClickOnApply() { QString msg; - if ( !isValid( msg ) ) { - showError( msg ); + if (!isValid(msg)) { + showError(msg); return false; } if (myPointsList.count() > 0) myPointsList.append(myPointsList[0]); - Locker lock( myOK ); + Locker lock(myOK); - if ( !onAccept() ) + if (!onAccept()) return false; - + ClickOnCancel(); return true; } @@ -849,59 +846,94 @@ EntityGUI_3DSketcherDlg::XYZ EntityGUI_3DSketcherDlg::getPenultimatePoint() cons //================================================================================= // function : getCurrentPoint() -// purpose : returns current points +// purpose : returns current point //================================================================================= EntityGUI_3DSketcherDlg::XYZ EntityGUI_3DSketcherDlg::getCurrentPoint() const { - XYZ xyz; - // Temporary way of doing this. To be changed with ordered improvement of the sketcher - if ( myMode == 2 ) - { - double anAngle = GroupAngles->SpinBox_DA->value() * M_PI/180.0; - double anAngle2 = 0.0; + XYZ xyz; + + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + int aPrecision = resMgr->integerValue("Geometry", "length_precision", 7); + + if (myMode == 2) { + if (GroupAngles->radioButton_1->isChecked()) + xyz.command = "OXY "; + else if (GroupAngles->radioButton_2->isChecked()) + xyz.command = "OYZ "; + else + xyz.command = "OXZ "; + + double anAngle = GroupAngles->SpinBox_DA->value(); double aLength = GroupAngles->SpinBox_DL->value(); - - if (GroupAngles->checkBox->isChecked()) - anAngle2 = GroupAngles->SpinBox_DA2->value() * M_PI/180.0; - + + double anAngle2 = 0.0; + QString da2 = "0"; + if (GroupAngles->checkBox->isChecked()) { + anAngle2 = GroupAngles->SpinBox_DA2->value(); + da2 = GroupAngles->SpinBox_DA2->text(); + } + + xyz.command += + QString::number(anAngle, 'g', aPrecision) + " " + + QString::number(anAngle2, 'g', aPrecision) + " " + + QString::number(aLength, 'g', aPrecision); + xyz.params = + GroupAngles->SpinBox_DA->text() + ":" + + da2 + ":" + + GroupAngles->SpinBox_DL->text(); + + // Calculate point coordinates for preview + anAngle = anAngle * M_PI/180.0; + anAngle2 = anAngle2 * M_PI/180.0; double aProjectedLength = aLength * cos(anAngle2); - - xyz = getLastPoint(); - if (GroupAngles->radioButton_1->isChecked()) + + XYZ xyzP = getLastPoint(); + if (GroupAngles->radioButton_1->isChecked()) // OXY { - xyz.x += aProjectedLength * cos(anAngle); - xyz.y += aProjectedLength * sin(anAngle); - xyz.z += aLength * sin(anAngle2); + xyz.x = xyzP.x + aProjectedLength * cos(anAngle); + xyz.y = xyzP.y + aProjectedLength * sin(anAngle); + xyz.z = xyzP.z + aLength * sin(anAngle2); } - else if (GroupAngles->radioButton_2->isChecked()) + else if (GroupAngles->radioButton_2->isChecked()) // OYZ { - xyz.y += aProjectedLength * cos(anAngle); - xyz.z += aProjectedLength * sin(anAngle); - xyz.x += aLength * sin(anAngle2); + xyz.y = xyzP.y + aProjectedLength * cos(anAngle); + xyz.z = xyzP.z + aProjectedLength * sin(anAngle); + xyz.x = xyzP.x + aLength * sin(anAngle2); } - else + else // OXZ { - xyz.z += aProjectedLength * sin(anAngle); - xyz.x += aProjectedLength * cos(anAngle); - xyz.y += aLength * sin(anAngle2); + xyz.z = xyzP.z + aProjectedLength * sin(anAngle); + xyz.x = xyzP.x + aProjectedLength * cos(anAngle); + xyz.y = xyzP.y + aLength * sin(anAngle2); } } - else - { - if ( myMode == 0 ) { + else { + if (myMode == 0) { // XYZ xyz.x = Group3Spin->SpinBox_DX->value(); xyz.y = Group3Spin->SpinBox_DY->value(); xyz.z = Group3Spin->SpinBox_DZ->value(); - } - else{ + xyz.command = "TT "; + } + else { // DXDYDZ xyz = getLastPoint(); xyz.x += Group3Spin->SpinBox_DX->value(); xyz.y += Group3Spin->SpinBox_DY->value(); xyz.z += Group3Spin->SpinBox_DZ->value(); + xyz.command = "T "; } - xyz.xt = Group3Spin->SpinBox_DX->text(); - xyz.yt = Group3Spin->SpinBox_DY->text(); - xyz.zt = Group3Spin->SpinBox_DZ->text(); + + double aX = Group3Spin->SpinBox_DX->value(); + double aY = Group3Spin->SpinBox_DY->value(); + double aZ = Group3Spin->SpinBox_DZ->value(); + + xyz.command += + QString::number(aX, 'g', aPrecision) + " " + + QString::number(aY, 'g', aPrecision) + " " + + QString::number(aZ, 'g', aPrecision); + xyz.params = + Group3Spin->SpinBox_DX->text() + ":" + + Group3Spin->SpinBox_DY->text() + ":" + + Group3Spin->SpinBox_DZ->text(); } return xyz; } @@ -911,97 +943,97 @@ EntityGUI_3DSketcherDlg::XYZ EntityGUI_3DSketcherDlg::getCurrentPoint() const // Purpose : Method for displaying preview of resulting shape // Redefined from GEOMBase_Helper. //================================================================ -void EntityGUI_3DSketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object, +void EntityGUI_3DSketcherDlg::displayPreview (GEOM::GEOM_Object_ptr object, const bool append, const bool activate, const bool update, const double lineWidth, const int displayMode, - const int color ) -{ - SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - + const int color) +{ + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + QColor aColor = resMgr->colorValue("Geometry","line_color",QColor(255,0,0)); - Quantity_NameOfColor line_color = SalomeApp_Tools::color( aColor ).Name(); - + Quantity_NameOfColor line_color = SalomeApp_Tools::color(aColor).Name(); + // set width of displayed shape int lw = lineWidth; - if(lw == -1) { + if (lw == -1) { lw = resMgr->integerValue("Geometry", "preview_edge_width", -1); } - getDisplayer()->SetWidth( lw ); + getDisplayer()->SetWidth(lw); // Disable activation of selection - getDisplayer()->SetToActivate( activate ); + getDisplayer()->SetToActivate(activate); // Make a reference to GEOM_Object - CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object ); - getDisplayer()->SetName( objStr.in() ); + CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string(object); + getDisplayer()->SetName(objStr.in()); // Create wire from applied object TopoDS_Shape anApplyedWire, aLastSegment; - if ( !createShapes( object, anApplyedWire, aLastSegment ) ) + if (!createShapes(object, anApplyedWire, aLastSegment)) return; // Set color for preview shape - getDisplayer()->SetColor( line_color ); - + getDisplayer()->SetColor(line_color); + // Build prs - SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire ); - if ( aPrs != 0 && !aPrs->IsNull() ) - GEOMBase_Helper::displayPreview( aPrs, append, update ); - - getDisplayer()->SetColor( Quantity_NOC_VIOLET ); - aPrs = getDisplayer()->BuildPrs( aLastSegment ); - - if ( aPrs != 0 && !aPrs->IsNull() ) - GEOMBase_Helper::displayPreview( aPrs, append, update ); - - getDisplayer()->SetColor( line_color ); - + SALOME_Prs* aPrs = getDisplayer()->BuildPrs(anApplyedWire); + if (aPrs != 0 && !aPrs->IsNull()) + GEOMBase_Helper::displayPreview(aPrs, append, update); + + getDisplayer()->SetColor(Quantity_NOC_VIOLET); + aPrs = getDisplayer()->BuildPrs(aLastSegment); + + if (aPrs != 0 && !aPrs->IsNull()) + GEOMBase_Helper::displayPreview(aPrs, append, update); + + getDisplayer()->SetColor(line_color); + // Display local trihedron if the mode is relatives coordinates or angles if (myMode == 1 || myMode == 2) displayTrihedron(2); - + // Display preview of suitable dimension presentations - if(myMode == 2) // ANGLES + if (myMode == 2) // ANGLES { double anAngle2 = 0.0; if (GroupAngles->checkBox->isChecked()) anAngle2 = GroupAngles->SpinBox_DA2->value(); - + displayAngle(GroupAngles->SpinBox_DA->value(), anAngle2, GroupAngles->SpinBox_DL->value(), myOrientation); - displayLength(GroupAngles->SpinBox_DL->value()); + displayLength(GroupAngles->SpinBox_DL->value()); } - if( myMode == 0 || myMode == 1 ) // COORDINATES - displayLength(); - + if (myMode == 0 || myMode == 1) // COORDINATES + displayLength(); + getDisplayer()->UnsetName(); // Enable activation of displayed objects - getDisplayer()->SetToActivate( true ); + getDisplayer()->SetToActivate(true); } //================================================================ // Function : displayTrihedron() // Purpose : Method for displaying trihedron //================================================================ -void EntityGUI_3DSketcherDlg::displayTrihedron(int selMode) +void EntityGUI_3DSketcherDlg::displayTrihedron (int selMode) { // Add trihedron to preview SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); - + gp_Pnt P(getLastPoint().x,getLastPoint().y,getLastPoint().z); Handle(Geom_Axis2Placement) anAxis = new Geom_Axis2Placement(P,gp::DZ(),gp::DX()); Handle(AIS_Trihedron) anIO = new AIS_Trihedron(anAxis); anIO->SetSelectionMode(selMode); - - SOCC_Prs* aSPrs = dynamic_cast(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); - - if (aSPrs) - { + + SOCC_Prs* aSPrs = dynamic_cast + (((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); + + if (aSPrs) { aSPrs->PrependObject(anIO); - GEOMBase_Helper::displayPreview( aSPrs, true, true ); + GEOMBase_Helper::displayPreview(aSPrs, true, true); } } @@ -1009,51 +1041,52 @@ void EntityGUI_3DSketcherDlg::displayTrihedron(int selMode) // Function : displayAngle() // Purpose : Method for displaying angle dimensions //================================================================ -void EntityGUI_3DSketcherDlg::displayAngle(double theAngle1, double theAngle2, double theLength, int theOrientation, bool store) +void EntityGUI_3DSketcherDlg::displayAngle (double theAngle1, double theAngle2, + double theLength, int theOrientation, bool store) { - if( Abs(theAngle2 - 90.0) < Precision::Angular() || - theLength < Precision::Confusion() ) + if (Abs(theAngle2 - 90.0) < Precision::Angular() || + theLength < Precision::Confusion()) return; - SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); - + SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); + XYZ Last = getLastPoint(); XYZ Current = getCurrentPoint(); - + gp_Pnt Last_Pnt(Last.x,Last.y,Last.z); gp_Pnt Current_Pnt(Current.x,Current.y,Current.z); gp_Pnt P1, P2; - + bool twoAngles = GroupAngles->checkBox->isChecked(); - + switch(theOrientation) { case 1: //OXY - { + { P1 = gp_Pnt(Last.x + theLength,Last.y,Last.z); // X direction P2 = gp_Pnt(Last.x + theLength * cos(theAngle1 * M_PI / 180.), Last.y + theLength * sin(theAngle1 * M_PI / 180.), - Last.z); + Last.z); break; } case 2: //OYZ { P1 = gp_Pnt(Last.x, Last.y + theLength,Last.z); // Y direction - P2 = gp_Pnt(Last.x, + P2 = gp_Pnt(Last.x, Last.y + theLength * cos(theAngle1 * M_PI / 180.), - Last.z + theLength * sin(theAngle1 * M_PI / 180.)); + Last.z + theLength * sin(theAngle1 * M_PI / 180.)); break; } case 3: //OXZ { - P1 = gp_Pnt( Last.x + theLength,Last.y,Last.z); // X direction - P2 = gp_Pnt( Last.x + theLength * cos(theAngle1 * M_PI / 180.) , + P1 = gp_Pnt(Last.x + theLength,Last.y,Last.z); // X direction + P2 = gp_Pnt(Last.x + theLength * cos(theAngle1 * M_PI / 180.) , Last.y, - Last.z + theLength * sin(theAngle1 * M_PI / 180.)); + Last.z + theLength * sin(theAngle1 * M_PI / 180.)); break; } } - + TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(P1); TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(P2); TopoDS_Vertex LastV = BRepBuilderAPI_MakeVertex(Last_Pnt); @@ -1061,77 +1094,80 @@ void EntityGUI_3DSketcherDlg::displayAngle(double theAngle1, double theAngle2, d TopoDS_Edge anEdge1 = BRepBuilderAPI_MakeEdge(LastV, V1); TopoDS_Edge anEdge2 = BRepBuilderAPI_MakeEdge(LastV, V2); TopoDS_Edge anEdge3 = BRepBuilderAPI_MakeEdge(LastV, CurV); - - gce_MakePln gce_MP(Last_Pnt, P1, P2); - Handle(Geom_Plane) aPlane = new Geom_Plane(gce_MP.Value()); - + + gce_MakePln gce_MP (Last_Pnt, P1, P2); + Handle(Geom_Plane) aPlane = new Geom_Plane(gce_MP.Value()); + // Covert angles to string std::string Angle1_str = doubleToString(theAngle1); std::string Angle2_str = doubleToString(theAngle2); - + // Create interactive object - Handle(AIS_AngleDimension) anAngleIO = new AIS_AngleDimension(anEdge1, anEdge2, aPlane, theAngle1 * M_PI / 180., - TCollection_ExtendedString(Angle1_str.c_str())); - anAngleIO->SetArrowSize( (theAngle1 * M_PI / 180) * (theLength/20) ); - + Handle(AIS_AngleDimension) anAngleIO = new AIS_AngleDimension + (anEdge1, anEdge2, aPlane, theAngle1 * M_PI / 180., + TCollection_ExtendedString(Angle1_str.c_str())); + anAngleIO->SetArrowSize((theAngle1 * M_PI / 180) * (theLength/20)); + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); int w = resMgr->integerValue("Geometry", "measures_line_width", 1); - + Handle(Prs3d_AngleAspect) asp = new Prs3d_AngleAspect(); asp->LineAspect()->SetWidth(w); anAngleIO->Attributes()->SetAngleAspect(asp); - - SOCC_Prs* aSPrs = dynamic_cast(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); - + + SOCC_Prs* aSPrs = dynamic_cast + (((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); + if (store) { // Erase dimensions presentations ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myAnglePrs, true); - + myAnglePrs->PrependObject(anAngleIO); myPrsType = TYPE_ANGLE; // Overwrite type with ANGLE - + // Display modified presentation if (isAngleVisible) ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myAnglePrs); } - else if(aSPrs) + else if (aSPrs) { aSPrs->AddObject(anAngleIO); } - + if (twoAngles) { gce_MakePln gce_MP2(Last_Pnt, P2, Current_Pnt); Handle(Geom_Plane) aPlane2 = new Geom_Plane(gce_MP2.Value()); - - Handle(AIS_AngleDimension) anAngle2IO = new AIS_AngleDimension(anEdge2, anEdge3, aPlane2, theAngle2 * M_PI / 180., - TCollection_ExtendedString(Angle2_str.c_str())); - anAngle2IO->SetArrowSize( (theAngle2 * M_PI / 180) * (theLength/20) ); - + + Handle(AIS_AngleDimension) anAngle2IO = + new AIS_AngleDimension(anEdge2, anEdge3, aPlane2, theAngle2 * M_PI / 180., + TCollection_ExtendedString(Angle2_str.c_str())); + anAngle2IO->SetArrowSize((theAngle2 * M_PI / 180) * (theLength/20)); + anAngle2IO->Attributes()->SetAngleAspect(asp); - + if (store) { // Erase dimensions presentations ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myAnglePrs, true); - + myAnglePrs->PrependObject(anAngle2IO); myPrsType = TYPE_TWO_ANGLES; // Overwrite type with TWO_ANGLES - + // Display modified presentation if (isAngleVisible) ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myAnglePrs); } else if (aSPrs) { - aSPrs->AddObject(anAngle2IO); + aSPrs->AddObject(anAngle2IO); } } - - if(!store && isAngleVisible) - { - GEOMBase_Helper::displayPreview( aSPrs, true, true ); + + if (!store && isAngleVisible) + { + GEOMBase_Helper::displayPreview(aSPrs, true, true); } } @@ -1139,116 +1175,118 @@ void EntityGUI_3DSketcherDlg::displayAngle(double theAngle1, double theAngle2, d // Function : displayLength() // Purpose : Method for displaying length dimensions //================================================================ -void EntityGUI_3DSketcherDlg::displayLength(double theLength, bool store) +void EntityGUI_3DSketcherDlg::displayLength (double theLength, bool store) { SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); - + XYZ Last = getLastPoint(); XYZ Current = getCurrentPoint(); XYZ Penultimate = getPenultimatePoint(); - + double aLength = 0.0; - - if( theLength < 0) // Calculate length if not given + + if (theLength < 0) // Calculate length if not given { aLength = sqrt((Last.x - Current.x)*(Last.x - Current.x) + - (Last.y - Current.y)*(Last.y - Current.y) + + (Last.y - Current.y)*(Last.y - Current.y) + (Last.z - Current.z)*(Last.z - Current.z)); } else aLength = theLength; - + if (aLength Precision::Confusion() ) +// else if (Abs(Normal.Dot(gp::DX())) > Precision::Confusion()) // { // MESSAGE("repere2") -// if ( Normal.Dot(gp::DX()) < 0.0 ){ +// if (Normal.Dot(gp::DX()) < 0.0){ // MESSAGE("REVERSE on OX basis") // Normal.Reverse(); // } // } -// else if ( Abs(Normal.Dot(gp::DY())) > Precision::Confusion() ) +// else if (Abs(Normal.Dot(gp::DY())) > Precision::Confusion()) // { // MESSAGE("repere3") -// if ( Normal.Dot(gp::DY()) < 0.0 ){ +// if (Normal.Dot(gp::DY()) < 0.0){ // MESSAGE("REVERSE on OY basis") // Normal.Reverse(); // } // } - + gce_MakePln gce_MP(P1, Normal); Handle(Geom_Plane) aPlane = new Geom_Plane(gce_MP.Value()); - - Handle(AIS_LengthDimension) anIO = new AIS_LengthDimension(aVert1, - aVert2, - aPlane, - aLength, - TCollection_ExtendedString(aLength_str.c_str())); + + Handle(AIS_LengthDimension) anIO = + new AIS_LengthDimension(aVert1, + aVert2, + aPlane, + aLength, + TCollection_ExtendedString(aLength_str.c_str())); anIO->SetArrowSize(aLength/20); - + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); int w = resMgr->integerValue("Geometry", "measures_line_width", 1); Handle(Prs3d_LengthAspect) asp = new Prs3d_LengthAspect(); asp->LineAspect()->SetWidth(w); anIO->Attributes()->SetLengthAspect(asp); - + if (store) { // Erase length dimensions presentation ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myLengthPrs, true); - + myLengthPrs->PrependObject(anIO); myPrsType = TYPE_LENGTH; - + // Display modified presentation if (isLengthVisible) ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myLengthPrs); } - else if( isLengthVisible ) + else if (isLengthVisible) { - SOCC_Prs* aSPrs = dynamic_cast(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); + SOCC_Prs* aSPrs = dynamic_cast + (((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); if (aSPrs) { aSPrs->PrependObject(anIO); - GEOMBase_Helper::displayPreview( aSPrs, true, true ); + GEOMBase_Helper::displayPreview(aSPrs, true, true); } } } @@ -1257,34 +1295,34 @@ void EntityGUI_3DSketcherDlg::displayLength(double theLength, bool store) // Function : createShapes // Purpose : Create applyed wire, and last segment from entry object //================================================================ -bool EntityGUI_3DSketcherDlg::createShapes( GEOM::GEOM_Object_ptr /*theObject*/, +bool EntityGUI_3DSketcherDlg::createShapes (GEOM::GEOM_Object_ptr /*theObject*/, TopoDS_Shape& theApplyedWire, - TopoDS_Shape& theLastSegment ) + TopoDS_Shape& theLastSegment) { QList points; - foreach( XYZ xyz, myPointsList) { + foreach (XYZ xyz, myPointsList) { gp_Pnt p(xyz.x, xyz.y, xyz.z); - if ( points.isEmpty() || points.last().Distance(p) > gp::Resolution()) + if (points.isEmpty() || points.last().Distance(p) > gp::Resolution()) points << p; - } - - if ( points.count() == 1 ) { + } + + if (points.count() == 1) { // only one point is created BRepBuilderAPI_MakeVertex mkVertex (points.last()); theApplyedWire = mkVertex.Shape(); } - else if ( points.count() > 1 ) { + else if (points.count() > 1) { // wire is created BRepBuilderAPI_MakePolygon mkWire; - foreach( gp_Pnt p, points ) + foreach(gp_Pnt p, points) mkWire.Add(p); theApplyedWire = mkWire.Shape(); } XYZ curxyz = getCurrentPoint(); gp_Pnt curpnt(curxyz.x, curxyz.y, curxyz.z); - - if ( points.isEmpty() || points.last().Distance(curpnt) <= gp::Resolution() ) { + + if (points.isEmpty() || points.last().Distance(curpnt) <= gp::Resolution()) { BRepBuilderAPI_MakeVertex mkVertex (curpnt); theLastSegment = mkVertex.Shape(); } @@ -1295,34 +1333,34 @@ bool EntityGUI_3DSketcherDlg::createShapes( GEOM::GEOM_Object_ptr /*theObject*/, /* VSR: old algorithm does not work properly, see bug 0020899 TopoDS_Shape aShape; - if ( !GEOMBase::GetShape( theObject, aShape ) ) + if (!GEOMBase::GetShape(theObject, aShape)) return false; - if( aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX ) + if (aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX) return false; theApplyedWire = aShape; - if ( myOK ) + if (myOK) return true; BRepBuilderAPI_MakeWire aBuilder; - TopExp_Explorer edgeExp( aShape, TopAbs_EDGE ); - while ( 1 ) { + TopExp_Explorer edgeExp(aShape, TopAbs_EDGE); + while (1) { TopoDS_Shape anEdge = edgeExp.Current(); edgeExp.Next(); - if ( edgeExp.More() ) // i.e. non-last edge - aBuilder.Add( TopoDS::Edge( anEdge ) ); + if (edgeExp.More()) // i.e. non-last edge + aBuilder.Add(TopoDS::Edge(anEdge)); else { theLastSegment = anEdge; break; } } - if ( aBuilder.IsDone() ) { + if (aBuilder.IsDone()) { theApplyedWire = aBuilder.Shape(); } - else if ( !theLastSegment.IsNull() ) { - TopExp_Explorer vertexExp( theLastSegment, TopAbs_VERTEX ); + else if (!theLastSegment.IsNull()) { + TopExp_Explorer vertexExp(theLastSegment, TopAbs_VERTEX); theApplyedWire = vertexExp.Current(); } */ @@ -1334,11 +1372,11 @@ bool EntityGUI_3DSketcherDlg::createShapes( GEOM::GEOM_Object_ptr /*theObject*/, // Function : doubleToString // Purpose : converts double to string //================================================================ -std::string EntityGUI_3DSketcherDlg::doubleToString(double num) +std::string EntityGUI_3DSketcherDlg::doubleToString (double num) { // truncate num int digNum = 5; char format = 'g'; // truncated to a number of significant digits - - return QString::number( num, format, digNum).toStdString(); + + return QString::number(num, format, digNum).toStdString(); } diff --git a/src/EntityGUI/EntityGUI_3DSketcherDlg.h b/src/EntityGUI/EntityGUI_3DSketcherDlg.h index af81a199d..1e790d110 100755 --- a/src/EntityGUI/EntityGUI_3DSketcherDlg.h +++ b/src/EntityGUI/EntityGUI_3DSketcherDlg.h @@ -15,12 +15,11 @@ // 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 : EntityGUI_3DSketcherDlg.h // Author : DMV, OCN -// + #ifndef ENTITYGUI_3DSKETCHERDLG_H #define ENTITYGUI_3DSKETCHERDLG_H @@ -53,14 +52,15 @@ class EntityGUI_3DSketcherDlg : public GEOMBase_Skeleton struct XYZ { - XYZ() { x = y = z = 0.0; xt = yt = zt = "0.0"; } - double x, y, z; - QString xt, yt, zt; + XYZ() { x = y = z = 0.0; command = params = ""; } + double x, y, z; // for preview only + QString command; + QString params; }; typedef QList XYZList; public: - EntityGUI_3DSketcherDlg( GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0, const double = 2. ); + EntityGUI_3DSketcherDlg (GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0, const double = 2.); ~EntityGUI_3DSketcherDlg(); protected: diff --git a/src/GEOM/GEOM_Engine.cxx b/src/GEOM/GEOM_Engine.cxx index dee9d3b54..22a5fe5c7 100644 --- a/src/GEOM/GEOM_Engine.cxx +++ b/src/GEOM/GEOM_Engine.cxx @@ -961,7 +961,7 @@ std::list GEOM_Engine::getAllTextures(int theDocID) //============================================================================= /*! - * ProcessFunction: Dump fucntion description into script + * ProcessFunction: Dump function description into script */ //============================================================================= bool ProcessFunction(Handle(GEOM_Function)& theFunction, @@ -1036,6 +1036,95 @@ bool ProcessFunction(Handle(GEOM_Function)& theFunction, //Replace parameter by notebook variables ReplaceVariables(aDescr,theVariables); + + //Process sketcher functions, replacing string command by calls to Sketcher interface + if (aDescr.Search( "Make3DSketcher" ) != -1) { + TCollection_AsciiString aNewDescr; + int i = 1; + TCollection_AsciiString aSubStr = aDescr.Token("\n\t", i); + for (; !aSubStr.IsEmpty(); aSubStr = aDescr.Token("\n\t", i)) { + if (aSubStr.Search( "Make3DSketcherCommand" ) != -1) { + TCollection_AsciiString aResult = aSubStr.Token(" ", 1); + // "3DSketcher:CMD[:CMD[:CMD...]]" + TCollection_AsciiString aCommand = aSubStr.Token("\"", 2); + + // Split the command string to separate CMDs + int icmd = 2; + TColStd_SequenceOfAsciiString aSequence; + if (aCommand.Length()) { + TCollection_AsciiString aToken = aCommand.Token(":", icmd); + while (aToken.Length() > 0) { + aSequence.Append(aToken); + aToken = aCommand.Token(":", ++icmd); + } + } + + if (aSequence.Length() > 0) { + if (i > 1) + aNewDescr += "\n\t"; + + aNewDescr += "sk = geompy.Sketcher3D()"; + int nbCMDs = aSequence.Length(); + for (icmd = 1; icmd <= nbCMDs; icmd++) { + aNewDescr += "\n\t"; + + TCollection_AsciiString aCMD = aSequence.Value(icmd); + + // Split the CMD into string values + TColStd_SequenceOfAsciiString aStrVals; + int ival = 1; + TCollection_AsciiString aToken = aCMD.Token(" ", ival); + while (aToken.Length() > 0) { + aStrVals.Append(aToken); + aToken = aCMD.Token(" ", ++ival); + } + + TCollection_AsciiString aCMDpref = aStrVals.Value(1); + if (aCMDpref == "TT") { + aNewDescr += "sk.addPointsAbsolute("; + aNewDescr += aStrVals.Value(2) + ", " + aStrVals.Value(3) + ", " + aStrVals.Value(4) + ")"; + } + else if (aCMDpref == "T") { + aNewDescr += "sk.addPointsRelative("; + aNewDescr += aStrVals.Value(2) + ", " + aStrVals.Value(3) + ", " + aStrVals.Value(4) + ")"; + } + else if (aCMDpref == "WW") { + aNewDescr += "sk.close()"; + } + else { + aNewDescr += "sk.addPointAnglesLength(\""; + aNewDescr += aCMDpref + "\", " + + aStrVals.Value(2) + ", " + aStrVals.Value(3) + ", " + aStrVals.Value(4) + ")"; + } + } + aNewDescr += "\n\t"; + aNewDescr += aResult + " = sk.wire()"; + } + } // Make3DSketcherCommand + else if (aSubStr.Search( "Make3DSketcher" ) != -1) { + TCollection_AsciiString aResult = aSubStr.Token(" ", 1); + TCollection_AsciiString aCommand = aSubStr.Token("[", 2); + aCommand = aCommand.Token("]", 1); + if (i > 1) + aNewDescr += "\n\t"; + aNewDescr += "sk = geompy.Sketcher3D()"; + aNewDescr += "\n\t"; + aNewDescr += "sk.addPointsAbsolute("; + aNewDescr += aCommand + ")"; + aNewDescr += "\n\t"; + aNewDescr += aResult + " = sk.wire()"; + } + else { + if (i > 1) + aNewDescr += "\n\t"; + aNewDescr += aSubStr; + } + + i++; + } + aDescr = aNewDescr; + } + if ( theIsDumpCollected ) { int i = 1; bool isBefore = true; diff --git a/src/GEOMImpl/GEOMImpl_3DSketcherDriver.cxx b/src/GEOMImpl/GEOMImpl_3DSketcherDriver.cxx index 5c00c4655..0dbdc320b 100755 --- a/src/GEOMImpl/GEOMImpl_3DSketcherDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_3DSketcherDriver.cxx @@ -15,7 +15,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -26,9 +25,13 @@ #include +#include + // OCCT Includes #include #include +#include +#include #include #include #include @@ -63,41 +66,232 @@ Standard_Integer GEOMImpl_3DSketcherDriver::Execute(TFunction_Logbook& log) cons { if (Label().IsNull()) return 0; Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); - + GEOMImpl_I3DSketcher aCI (aFunction); TopoDS_Shape aShape; - Handle(TColStd_HArray1OfReal) aCoordsArray = aCI.GetCoordinates(); - int anArrayLength = aCoordsArray->Length(); + if (aFunction->GetType() == SKETCHER3D_COORDS) { + Handle(TColStd_HArray1OfReal) aCoordsArray = aCI.GetCoordinates(); + int anArrayLength = aCoordsArray->Length(); - std::list points; - - for (int i = 0; i <= (anArrayLength-3); i += 3) { - gp_Pnt aPnt = gp_Pnt(aCoordsArray->Value(i+1), aCoordsArray->Value(i+2), aCoordsArray->Value(i+3)); - if (points.empty() || aPnt.Distance(points.back()) > gp::Resolution()) - points.push_back(aPnt); - } + std::list points; + + for (int i = 0; i <= (anArrayLength-3); i += 3) { + gp_Pnt aPnt = gp_Pnt(aCoordsArray->Value(i+1), aCoordsArray->Value(i+2), aCoordsArray->Value(i+3)); + if (points.empty() || aPnt.Distance(points.back()) > gp::Resolution()) + points.push_back(aPnt); + } + + if ( points.size() == 1) { // Only Start Point + BRepBuilderAPI_MakeVertex mkVertex (points.back()); + aShape = mkVertex.Shape(); + } + else if ( points.size() > 1) { // Make Wire + BRepBuilderAPI_MakePolygon aMakePoly; + std::list::iterator it; + for (it = points.begin(); it != points.end(); ++it) { + aMakePoly.Add(*it); + } - if ( points.size() == 1) { // Only Start Point - BRepBuilderAPI_MakeVertex mkVertex (points.back()); - aShape = mkVertex.Shape(); + if (points.size() > 2 && + points.back().X() == points.front().X() && + points.back().Y() == points.front().Y() && + points.back().Z() == points.front().Z()) + aMakePoly.Close(); + + if (aMakePoly.IsDone()) + aShape = aMakePoly.Wire(); + } } - else if ( points.size() > 1) { // Make Wire - BRepBuilderAPI_MakePolygon aMakePoly; - std::list::iterator it; - for (it = points.begin(); it != points.end(); ++it) { - aMakePoly.Add(*it); + else if (aFunction->GetType() == SKETCHER3D_COMMAND) { + Kernel_Utils::Localizer loc; + + TCollection_AsciiString aCommand = aCI.GetCommand(); + // "3DSketcher:CMD[:CMD[:CMD...]]" + + // Split the command string to separate CMDs + int icmd = 2; + TColStd_SequenceOfAsciiString aSequence; + if (aCommand.Length()) { + TCollection_AsciiString aToken = aCommand.Token(":", icmd); + while (aToken.Length() > 0) { + aSequence.Append(aToken); + aToken = aCommand.Token(":", ++icmd); + } + } + + int nbEdges = 0; + bool isFirstPointSet = false; + gp_XYZ p = gp::Origin().XYZ(); + BRepBuilderAPI_MakeVertex MV0 (p); + TopoDS_Vertex V = TopoDS::Vertex(MV0.Shape()); + + gp_XYZ p0 = p; + TopoDS_Vertex V0 = V; + + bool doClose = false; + BRepBuilderAPI_MakeWire MW; + + int nbCMDs = aSequence.Length(); + for (icmd = 1; icmd <= nbCMDs; icmd++) { + TCollection_AsciiString aCMD = aSequence.Value(icmd); + + // Split the CMD into string values + TColStd_SequenceOfAsciiString aStrVals; + int ival = 1; + TCollection_AsciiString aToken = aCMD.Token(" ", ival); + while (aToken.Length() > 0) { + aStrVals.Append(aToken); + aToken = aCMD.Token(" ", ++ival); + } + + // "TT x y z" : Create segment by point at X & Y or set the first point + // "T dx dy dz" : Create segment by point with DX & DY + // + // "OXY angleX angle2 length" : Create segment by two angles and length + // "OYZ angleY angle2 length" : Create segment by two angles and length + // "OXZ angleX angle2 length" : Create segment by two angles and length + // + // "WW" : Close Wire (to finish) + + switch (aStrVals.Value(1).Value(1)) + { + case 'T': + { + if (aStrVals.Length() != 4) + Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command."); + + gp_XYZ vp; + vp.SetX(aStrVals.Value(2).RealValue()); + vp.SetY(aStrVals.Value(3).RealValue()); + vp.SetZ(aStrVals.Value(4).RealValue()); + + if (aStrVals.Value(1) == "TT") { // absolute coordinates + if (!isFirstPointSet) { + p = vp; + BRepBuilderAPI_MakeVertex MV (p); + V = TopoDS::Vertex(MV.Shape()); + + p0 = p; + V0 = V; + + isFirstPointSet = true; + } + else { + if ((vp - p).SquareModulus() > Precision::Confusion()) { + BRepBuilderAPI_MakeVertex MV (vp); + TopoDS_Vertex VV = TopoDS::Vertex(MV.Shape()); + BRepBuilderAPI_MakeEdge ME (V, VV); + MW.Add(ME); + nbEdges++; + + p = vp; + V = VV; + } + } + } + else if (aStrVals.Value(1) == "T") { // relative coordinates + if (vp.SquareModulus() > Precision::Confusion()) { + vp = p + vp; + + BRepBuilderAPI_MakeVertex MV (vp); + TopoDS_Vertex VV = TopoDS::Vertex(MV.Shape()); + BRepBuilderAPI_MakeEdge ME (V, VV); + MW.Add(ME); + nbEdges++; + + p = vp; + V = VV; + } + } + else + Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command."); + } + break; + case 'O': + { + if (aStrVals.Length() != 4) + Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command."); + + double anAngle = aStrVals.Value(2).RealValue() * M_PI/180.0; + double anAngle2 = aStrVals.Value(3).RealValue() * M_PI/180.0; + double aLength = aStrVals.Value(4).RealValue(); + + double aProjectedLength = aLength * cos(anAngle2); + + gp_XYZ vp; + vp.SetX(aStrVals.Value(2).RealValue()); + vp.SetY(aStrVals.Value(3).RealValue()); + vp.SetZ(aStrVals.Value(4).RealValue()); + + if (aStrVals.Value(1) == "OXY") { + vp.SetX(p.X() + aProjectedLength * cos(anAngle)); + vp.SetY(p.Y() + aProjectedLength * sin(anAngle)); + vp.SetZ(p.Z() + aLength * sin(anAngle2)); + } + else if (aStrVals.Value(1) == "OYZ") { + vp.SetX(p.X() + aLength * sin(anAngle2)); + vp.SetY(p.Y() + aProjectedLength * cos(anAngle)); + vp.SetZ(p.Z() + aProjectedLength * sin(anAngle)); + } + else if (aStrVals.Value(1) == "OXZ") { + vp.SetX(p.X() + aProjectedLength * cos(anAngle)); + vp.SetY(p.Y() + aLength * sin(anAngle2)); + vp.SetZ(p.Z() + aProjectedLength * sin(anAngle)); + } + else + Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command."); + + BRepBuilderAPI_MakeVertex MV (vp); + TopoDS_Vertex VV = TopoDS::Vertex(MV.Shape()); + BRepBuilderAPI_MakeEdge ME (V, VV); + MW.Add(ME); + nbEdges++; + + p = vp; + V = VV; + } + break; + case 'W': + { + if (aStrVals.Length() != 1) + Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command."); + + if (aStrVals.Value(1) == "WW") + doClose = true; + else + Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command."); + } + break; + default: + { + Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command."); + } + } + } + + if (doClose && + nbEdges > 1 && // as 3D sketcher has only straight edges + (p - p0).SquareModulus() > Precision::Confusion()) { + BRepBuilderAPI_MakeEdge ME (V, V0); + MW.Add(ME); + nbEdges++; } - if (points.size() > 2 && - points.back().X() == points.front().X() && - points.back().Y() == points.front().Y() && - points.back().Z() == points.front().Z()) - aMakePoly.Close(); - - if (aMakePoly.IsDone()) - aShape = aMakePoly.Wire(); + if (nbEdges > 0) { + if (!MW.IsDone()) + Standard_ConstructionError::Raise("3D Sketcher error: Wire construction failed."); + + aShape = MW; + } + else { + if (isFirstPointSet) { + aShape = V0; + } + } + } + else { } if (aShape.IsNull()) return 0; diff --git a/src/GEOMImpl/GEOMImpl_I3DSketcher.hxx b/src/GEOMImpl/GEOMImpl_I3DSketcher.hxx index fa6e04639..4f4c9664d 100755 --- a/src/GEOMImpl/GEOMImpl_I3DSketcher.hxx +++ b/src/GEOMImpl/GEOMImpl_I3DSketcher.hxx @@ -15,28 +15,35 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// //NOTE: This is an interface to a function for the Sketcher creation. -// + #include "GEOM_Function.hxx" #include -#define SKETCH_ARG_COORDS 1 - class GEOMImpl_I3DSketcher { - public: +public: - GEOMImpl_I3DSketcher(Handle(GEOM_Function) theFunction): _func(theFunction) {} + GEOMImpl_I3DSketcher (Handle(GEOM_Function) theFunction): _func(theFunction) {} - void SetCoordinates(const Handle(TColStd_HArray1OfReal)& theValue) - { _func->SetRealArray(SKETCH_ARG_COORDS, theValue); } + void SetCoordinates (const Handle(TColStd_HArray1OfReal)& theValue) + { _func->SetRealArray(SKETCH_ARG_COORDS, theValue); } Handle(TColStd_HArray1OfReal) GetCoordinates() { return _func->GetRealArray(SKETCH_ARG_COORDS); } - private: + void SetCommand (const TCollection_AsciiString& theCommand) + { _func->SetString(SKETCH_ARG_COMMAND, theCommand); } + + TCollection_AsciiString GetCommand() { return _func->GetString(SKETCH_ARG_COMMAND); } + +private: + + enum { + SKETCH_ARG_COORDS = 1, + SKETCH_ARG_COMMAND = 2 + }; Handle(GEOM_Function) _func; }; diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx index ca1ac5db0..f4508d35b 100644 --- a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifdef WNT // E.A. : On windows with python 2.6, there is a conflict @@ -1168,39 +1167,36 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCom //============================================================================= /*! - * Make3DSketcher + * MakeSketcherOnPlane */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::list theCoordinates) +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane + (const char* theCommand, + Handle(GEOM_Object) theWorkingPlane) { SetErrorCode(KO); + if (!theCommand || strcmp(theCommand, "") == 0) return NULL; + //Add a new Sketcher object - Handle(GEOM_Object) a3DSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER); + Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER); //Add a new Sketcher function Handle(GEOM_Function) aFunction = - a3DSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), GEOM_3DSKETCHER); + aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_PLANE); if (aFunction.IsNull()) return NULL; //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL; - - GEOMImpl_I3DSketcher aCI (aFunction); - - int nbOfCoords = 0; - std::list::iterator it = theCoordinates.begin(); - for (; it != theCoordinates.end(); it++) - nbOfCoords++; + if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL; - Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, nbOfCoords); + GEOMImpl_ISketcher aCI (aFunction); - it = theCoordinates.begin(); - int ind = 1; - for (; it != theCoordinates.end(); it++, ind++) - aCoordsArray->SetValue(ind, *it); + TCollection_AsciiString aCommand((char*) theCommand); + aCI.SetCommand(aCommand); - aCI.SetCoordinates(aCoordsArray); + Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction(); + if (aRefPlane.IsNull()) return NULL; + aCI.SetWorkingPlane( aRefPlane ); //Compute the Sketcher value try { @@ -1208,7 +1204,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::listComputeFunction(aFunction)) { - SetErrorCode("3D Sketcher driver failed"); + SetErrorCode("Sketcher driver failed"); return NULL; } } @@ -1219,52 +1215,99 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::listAddObject(GetDocID(), GEOM_SKETCHER); + Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER); //Add a new Sketcher function Handle(GEOM_Function) aFunction = - aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_PLANE); + aSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), SKETCHER3D_COMMAND); if (aFunction.IsNull()) return NULL; //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL; + if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL; - GEOMImpl_ISketcher aCI (aFunction); + GEOMImpl_I3DSketcher aCI (aFunction); - TCollection_AsciiString aCommand((char*) theCommand); + TCollection_AsciiString aCommand ((char*) theCommand); aCI.SetCommand(aCommand); - Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction(); - if (aRefPlane.IsNull()) return NULL; - aCI.SetWorkingPlane( aRefPlane ); + //Compute the 3D Sketcher value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("3D Sketcher 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 pd (aFunction); + pd << aSketcher << " = geompy.Make3DSketcherCommand(\"" << aCommand.ToCString() << "\")"; + + SetErrorCode(OK); + return aSketcher; +} + +//============================================================================= +/*! + * Make3DSketcher + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::list theCoordinates) +{ + SetErrorCode(KO); + + //Add a new Sketcher object + Handle(GEOM_Object) a3DSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER); + + //Add a new Sketcher function + Handle(GEOM_Function) aFunction = + a3DSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), SKETCHER3D_COORDS); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL; + + GEOMImpl_I3DSketcher aCI (aFunction); + + int nbOfCoords = 0; + std::list::iterator it = theCoordinates.begin(); + for (; it != theCoordinates.end(); it++) + nbOfCoords++; + + Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, nbOfCoords); + + it = theCoordinates.begin(); + int ind = 1; + for (; it != theCoordinates.end(); it++, ind++) + aCoordsArray->SetValue(ind, *it); + + aCI.SetCoordinates(aCoordsArray); //Compute the Sketcher value try { @@ -1272,7 +1315,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane OCC_CATCH_SIGNALS; #endif if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("Sketcher driver failed"); + SetErrorCode("3D Sketcher driver failed"); return NULL; } } @@ -1283,9 +1326,16 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane } //Make a Python command - GEOM::TPythonDump (aFunction) << aSketcher << " = geompy.MakeSketcherOnPlane(\"" - << aCommand.ToCString() << "\", " << theWorkingPlane << " )"; + GEOM::TPythonDump pd (aFunction); + pd << a3DSketcher << " = geompy.Make3DSketcher(["; + + it = theCoordinates.begin(); + pd << (*it++); + while (it != theCoordinates.end()) { + pd << ", " << (*it++); + } + pd << "])"; SetErrorCode(OK); - return aSketcher; + return a3DSketcher; } diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx index 2e71bbd38..829f9cc5d 100644 --- a/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifndef _GEOMImpl_ICurvesOperations_HXX_ #define _GEOMImpl_ICurvesOperations_HXX_ @@ -78,16 +77,17 @@ class GEOMImpl_ICurvesOperations : public GEOM_IOperations { bool theIsClosed = false, bool theDoReordering = false); - Standard_EXPORT Handle(GEOM_Object) MakeCurveParametric(const char* thexExpr, const char* theyExpr, const char* thezExpr, - double theParamMin, double theParamMax, double theParamStep, - CurveType theCurveType, - int theParamNbStep=0, bool theNewMethod=false); + Standard_EXPORT Handle(GEOM_Object) MakeCurveParametric + (const char* thexExpr, const char* theyExpr, const char* thezExpr, + double theParamMin, double theParamMax, double theParamStep, + CurveType theCurveType, int theParamNbStep=0, bool theNewMethod=false); Standard_EXPORT Handle(GEOM_Object) MakeSketcher (const char* theCommand, std::list theWorkingPlane); - Standard_EXPORT Handle(GEOM_Object) Make3DSketcher (std::list theCoordinates); Standard_EXPORT Handle(GEOM_Object) MakeSketcherOnPlane (const char* theCommand, Handle(GEOM_Object) theWorkingPlane); + Standard_EXPORT Handle(GEOM_Object) Make3DSketcherCommand (const char* theCommand); + Standard_EXPORT Handle(GEOM_Object) Make3DSketcher (std::list theCoordinates); }; #endif diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index 2e5f871b8..991684548 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -18,7 +18,6 @@ // 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_Object types @@ -295,7 +294,10 @@ #define GLUE_EDGES_BY_LIST 4 #define SKETCHER_NINE_DOUBLS 1 -#define SKETCHER_PLANE 2 +#define SKETCHER_PLANE 2 + +#define SKETCHER3D_COORDS 1 +#define SKETCHER3D_COMMAND 2 // Measures #define CDG_MEASURE 1 diff --git a/src/GEOM_I/GEOM_ICurvesOperations_i.cc b/src/GEOM_I/GEOM_ICurvesOperations_i.cc index b5109c9bb..3f1a67800 100644 --- a/src/GEOM_I/GEOM_ICurvesOperations_i.cc +++ b/src/GEOM_I/GEOM_ICurvesOperations_i.cc @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -433,13 +432,15 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation * MakeCurveParametric */ //============================================================================= -GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametric(const char* thexExpr, const char* theyExpr, const char* thezExpr, - double theParamMin, double theParamMax, double theParamStep, - GEOM::curve_type theCurveType) { +GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametric + (const char* thexExpr, const char* theyExpr, const char* thezExpr, + double theParamMin, double theParamMax, double theParamStep, + GEOM::curve_type theCurveType) +{ GEOM::GEOM_Object_var aGEOMObject; //Set a not done flag GetOperations()->SetNotDone(); - + GEOMImpl_ICurvesOperations::CurveType aType; switch(theCurveType) { case GEOM::Polyline: @@ -453,18 +454,17 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametric(const char* break; default: break; - } - + } // Make Polyline Handle(GEOM_Object) anObject = - GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr, - theParamMin, theParamMax, - theParamStep, aType); - + GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr, + theParamMin, theParamMax, + theParamStep, aType); + if (!GetOperations()->IsDone() || anObject.IsNull()) - return aGEOMObject._retn(); - + return aGEOMObject._retn(); + return GetObject(anObject); } @@ -473,13 +473,15 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametric(const char* * MakeCurveParametricNew */ //============================================================================= -GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametricNew(const char* thexExpr, const char* theyExpr, const char* thezExpr, - double theParamMin, double theParamMax, CORBA::Long theParamNbStep, - GEOM::curve_type theCurveType) { +GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametricNew + (const char* thexExpr, const char* theyExpr, const char* thezExpr, + double theParamMin, double theParamMax, CORBA::Long theParamNbStep, + GEOM::curve_type theCurveType) +{ GEOM::GEOM_Object_var aGEOMObject; //Set a not done flag GetOperations()->SetNotDone(); - + GEOMImpl_ICurvesOperations::CurveType aType; switch(theCurveType) { case GEOM::Polyline: @@ -493,18 +495,17 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametricNew(const cha break; default: break; - } - + } // Make Polyline Handle(GEOM_Object) anObject = - GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr, - theParamMin, theParamMax, + GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr, + theParamMin, theParamMax, 0.0, aType, theParamNbStep, true); - + if (!GetOperations()->IsDone() || anObject.IsNull()) - return aGEOMObject._retn(); - + return aGEOMObject._retn(); + return GetObject(anObject); } @@ -536,24 +537,20 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher //============================================================================= /*! - * Make3DSketcher + * MakeSketcherOnPlane */ //============================================================================= -GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcher - (const GEOM::ListOfDouble& theCoordinates) +GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane + (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane) { //Set a not done flag GetOperations()->SetNotDone(); - int ind = 0; - int aLen = theCoordinates.length(); - std::list aCoords; - for (; ind < aLen; ind++) - aCoords.push_back(theCoordinates[ind]); + Handle(GEOM_Object) aWorkingPlane = GetObjectImpl(theWorkingPlane); // Make Sketcher Handle(GEOM_Object) anObject = - GetOperations()->Make3DSketcher(aCoords); + GetOperations()->MakeSketcherOnPlane(theCommand, aWorkingPlane); if (!GetOperations()->IsDone() || anObject.IsNull()) return GEOM::GEOM_Object::_nil(); @@ -562,20 +559,42 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcher //============================================================================= /*! - * MakeSketcherOnPlane + * Make3DSketcherCommand */ //============================================================================= -GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane - (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane) +GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcherCommand (const char* theCommand) { //Set a not done flag GetOperations()->SetNotDone(); - Handle(GEOM_Object) aWorkingPlane = GetObjectImpl(theWorkingPlane); + // Make 3D Sketcher + Handle(GEOM_Object) anObject = GetOperations()->Make3DSketcherCommand(theCommand); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return GEOM::GEOM_Object::_nil(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * Make3DSketcher + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcher + (const GEOM::ListOfDouble& theCoordinates) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + int ind = 0; + int aLen = theCoordinates.length(); + std::list aCoords; + for (; ind < aLen; ind++) + aCoords.push_back(theCoordinates[ind]); // Make Sketcher Handle(GEOM_Object) anObject = - GetOperations()->MakeSketcherOnPlane(theCommand, aWorkingPlane); + GetOperations()->Make3DSketcher(aCoords); if (!GetOperations()->IsDone() || anObject.IsNull()) return GEOM::GEOM_Object::_nil(); diff --git a/src/GEOM_I/GEOM_ICurvesOperations_i.hh b/src/GEOM_I/GEOM_ICurvesOperations_i.hh index 5fc09cc55..e50ab2111 100644 --- a/src/GEOM_I/GEOM_ICurvesOperations_i.hh +++ b/src/GEOM_I/GEOM_ICurvesOperations_i.hh @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifndef _GEOM_ICurvesOperations_i_HeaderFile #define _GEOM_ICurvesOperations_i_HeaderFile @@ -33,49 +32,49 @@ #include "GEOMImpl_ICurvesOperations.hxx" -class GEOM_I_EXPORT GEOM_ICurvesOperations_i : +class GEOM_I_EXPORT GEOM_ICurvesOperations_i : public virtual POA_GEOM::GEOM_ICurvesOperations, public virtual GEOM_IOperations_i { public: GEOM_ICurvesOperations_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, - ::GEOMImpl_ICurvesOperations* theImpl); + ::GEOMImpl_ICurvesOperations* theImpl); ~GEOM_ICurvesOperations_i(); GEOM::GEOM_Object_ptr MakeCirclePntVecR (GEOM::GEOM_Object_ptr theCenter, - GEOM::GEOM_Object_ptr theVector, - double theR); + GEOM::GEOM_Object_ptr theVector, + double theR); GEOM::GEOM_Object_ptr MakeCircleThreePnt (GEOM::GEOM_Object_ptr thePnt1, - GEOM::GEOM_Object_ptr thePnt2, - GEOM::GEOM_Object_ptr thePnt3); + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3); GEOM::GEOM_Object_ptr MakeCircleCenter2Pnt (GEOM::GEOM_Object_ptr thePnt1, - GEOM::GEOM_Object_ptr thePnt2, - GEOM::GEOM_Object_ptr thePnt3); + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3); GEOM::GEOM_Object_ptr MakeEllipse (GEOM::GEOM_Object_ptr theCenter, - GEOM::GEOM_Object_ptr theVector, - double theRMajor, double theRMinor); + GEOM::GEOM_Object_ptr theVector, + double theRMajor, double theRMinor); GEOM::GEOM_Object_ptr MakeEllipseVec (GEOM::GEOM_Object_ptr theCenter, - GEOM::GEOM_Object_ptr theVector, - double theRMajor, double theRMinor, - GEOM::GEOM_Object_ptr theVectorMajor); + GEOM::GEOM_Object_ptr theVector, + double theRMajor, double theRMinor, + GEOM::GEOM_Object_ptr theVectorMajor); GEOM::GEOM_Object_ptr MakeArc (GEOM::GEOM_Object_ptr thePnt1, - GEOM::GEOM_Object_ptr thePnt2, - GEOM::GEOM_Object_ptr thePnt3); - + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3); + GEOM::GEOM_Object_ptr MakeArcCenter (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2, GEOM::GEOM_Object_ptr thePnt3, bool theSense); GEOM::GEOM_Object_ptr MakeArcOfEllipse (GEOM::GEOM_Object_ptr thePnt1, - GEOM::GEOM_Object_ptr thePnt2, - GEOM::GEOM_Object_ptr thePnt3); - + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3); + GEOM::GEOM_Object_ptr MakePolyline (const GEOM::ListOfGO& thePoints, CORBA::Boolean theIsClosed); @@ -86,20 +85,24 @@ class GEOM_I_EXPORT GEOM_ICurvesOperations_i : CORBA::Boolean theIsClosed, CORBA::Boolean theDoReordering); - GEOM::GEOM_Object_ptr MakeCurveParametric(const char* thexExpr, const char* theyExpr, const char* thezExpr, - double theParamMin, double theParamMax, double theParamStep, - GEOM::curve_type theCurveType); - - GEOM::GEOM_Object_ptr MakeCurveParametricNew(const char* thexExpr, const char* theyExpr, const char* thezExpr, - double theParamMin, double theParamMax, CORBA::Long theParamNbStep, - GEOM::curve_type theCurveType); + GEOM::GEOM_Object_ptr MakeCurveParametric + (const char* thexExpr, const char* theyExpr, const char* thezExpr, + double theParamMin, double theParamMax, double theParamStep, + GEOM::curve_type theCurveType); + + GEOM::GEOM_Object_ptr MakeCurveParametricNew + (const char* thexExpr, const char* theyExpr, const char* thezExpr, + double theParamMin, double theParamMax, CORBA::Long theParamNbStep, + GEOM::curve_type theCurveType); GEOM::GEOM_Object_ptr MakeSketcher (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane); - - GEOM::GEOM_Object_ptr Make3DSketcher (const GEOM::ListOfDouble& theCoordinates); GEOM::GEOM_Object_ptr MakeSketcherOnPlane (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane); + GEOM::GEOM_Object_ptr Make3DSketcherCommand (const char* theCommand); + + GEOM::GEOM_Object_ptr Make3DSketcher (const GEOM::ListOfDouble& theCoordinates); + ::GEOMImpl_ICurvesOperations* GetOperations() { return (::GEOMImpl_ICurvesOperations*)GetImpl(); } }; diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index cb822d136..ab31173d6 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -1622,7 +1622,6 @@ class geompyDC(GEOM._objref_GEOM_Gen): # - "C radius length" : Create arc by direction, radius and length(in degree) # - "AA x y": Create arc by point at X & Y # - "A dx dy" : Create arc by point with DX & DY - # - "A dx dy" : Create arc by point with DX & DY # - "UU x y radius flag1": Create arc by point at X & Y with given radiUs # - "U dx dy radius flag1" : Create arc by point with DX & DY with given radiUs # - "EE x y xc yc flag1 flag2": Create arc by point at X & Y with given cEnter coordinates @@ -1672,7 +1671,6 @@ class geompyDC(GEOM._objref_GEOM_Gen): - "C radius length" : Create arc by direction, radius and length(in degree) - "AA x y": Create arc by point at X & Y - "A dx dy" : Create arc by point with DX & DY - - "A dx dy" : Create arc by point with DX & DY - "UU x y radius flag1": Create arc by point at X & Y with given radiUs - "U dx dy radius flag1" : Create arc by point with DX & DY with given radiUs - "EE x y xc yc flag1 flag2": Create arc by point at X & Y with given cEnter coordinates @@ -1729,8 +1727,10 @@ class geompyDC(GEOM._objref_GEOM_Gen): Returns: New GEOM.GEOM_Object, containing the created wire. """ + theCommand,Parameters = ParseSketcherCommand(theCommand) anObj = self.CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane) RaiseIfFailed("MakeSketcherOnPlane", self.CurvesOp) + anObj.SetParameters(Parameters) return anObj ## Create a sketcher wire, following the numerical description, @@ -1758,6 +1758,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj.SetParameters(Parameters) return anObj + ## Obtain a 3D sketcher interface + def Sketcher3D (self): + """ + Example of usage: + sk = geompy.Sketcher3D() + sk.addPointsAbsolute(0, 0, 0) + sk.addPointsAbsolute(70, 0, 0) + sk.addPointsRelative(0, 0, 130) + sk.addPointAnglesLength("OXY", 50, 0, 100) + sk.addPointAnglesLength("OXZ", 30, 80, 130) + a3D_Sketcher_1 = sk.makeWire() + """ + sk = Sketcher3D (self) + return sk + # end of l3_sketcher ## @} @@ -1771,7 +1786,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # # @return New GEOM.GEOM_Object, containing the created box. # @ref tui_creation_box "Example" - def MakeBox(self,x1,y1,z1,x2,y2,z2): + def MakeBox (self, x1,y1,z1, x2,y2,z2): """ Create a box by coordinates of two opposite vertices. @@ -8836,6 +8851,67 @@ class geompyDC(GEOM._objref_GEOM_Gen): RaiseIfFailed("AddTexture", self.InsertOp) return ID +## 3D Sketcher functionality +## Use geompy.Sketcher3D() to obtain an instance of this class +def printVar (var): + if isinstance(var, str): + return "\'%s\'"%var + else: + return "%.7f"%var + +class Sketcher3D: + def __init__(self, geompyD): + self.geompyD = geompyD + self.myCommand = "3DSketcher" + pass + + def addPointsAbsolute (self, *listCoords): + ii = 1 + for cc in listCoords: + if ii == 1: + self.myCommand = self.myCommand + ":TT" + #self.myCommand = self.myCommand + " %.7f"%cc + self.myCommand = self.myCommand + " %s"%printVar(cc) + if ii == 3: + ii = 1 + else: + ii = ii + 1 + pass + + def addPointsRelative (self, *listCoords): + ii = 1 + for cc in listCoords: + if ii == 1: + self.myCommand = self.myCommand + ":T" + #self.myCommand = self.myCommand + " %.7f"%cc + self.myCommand = self.myCommand + " %s"%printVar(cc) + if ii == 3: + ii = 1 + else: + ii = ii + 1 + pass + + ## axes can be: "OXY", "OYZ" or "OXZ" + def addPointAnglesLength (self, axes, angle1, angle2, length): + #self.myCommand = self.myCommand + ":%s %.7f %.7f %.7f" % (axes, angle1, angle2, length) + self.myCommand = self.myCommand + ":%s %s %s %s" % (axes, printVar(angle1), printVar(angle2), printVar(length)) + pass + + def close (self): + self.myCommand = self.myCommand + ":WW" + pass + + ## Obtain the sketcher result + def wire (self): + print "myCommand =", self.myCommand + Command,Parameters = ParseSketcherCommand(self.myCommand) + print "Command =", Command + wire = self.geompyD.CurvesOp.Make3DSketcherCommand(Command) + self.myCommand = "3DSketcher" + RaiseIfFailed("Sketcher3D", self.geompyD.CurvesOp) + wire.SetParameters(Parameters) + return wire + import omniORB #Register the new proxy for GEOM_Gen omniORB.registerObjref(GEOM._objref_GEOM_Gen._NP_RepositoryId, geompyDC) -- 2.39.2