--- /dev/null
+/*!
+
+\page create_3dsketcher_page 3D Sketcher
+
+3D Sketcher allows creating a closed or unclosed 3D wire from a list of points.
+
+To create a 3D Sketch, select in the main menu <em>New Entity -> 3D Sketch</em>.
+
+\image html 3dsketch2.png
+
+The position of each coordinates can be defined by absolute coordinates X, Y, Z or
+by relative coordinates DX, DY, DZ with respect to the previous Applied point.
+Type of coordinates can be selected by the <b>Coordinates Type</b> radio buttons.
+\n <b>"Sketch Validation"</b> button applies the whole wire.
+\n <b>"Sketch Closure"</b> button connects the first and the last points closing
+the contour and applies the closed wire.
+To make a closed wire using the TUI command, the first and the last point shoul
+have the same coordinates.
+
+The Result of the operation will be a \b GEOM_Object.
+
+<b>TUI Command:</b> <em>geompy.Make3DSketcher( [ PointsList ] )</em>
+This algorithm creates a wire, from the list of real values which define XYZ
+coordinates of points.
+
+<b>Example:</b>
+
+\image html 3dsketch1.png
+
+Our <b>TUI Scripts</b> provide you with useful examples of the use of
+\ref tui_3dsketcher_page "3D Sketcher".
+*/
<li>\subpage work_with_groups_page</li>
<li>\subpage build_by_blocks_page</li>
<li>\subpage create_sketcher_page</li>
+<li>\subpage create_3dsketcher_page</li>
<li>\subpage create_adv_obj_page</li>
<ul>
<li>\ref create_explode_page</li>
<li>\ref work_with_groups_page</li>
<li>\ref build_by_blocks_page</li>
<li>\ref create_sketcher_page</li>
+<li>\ref create_3dsketcher_page</li>
<li>\ref create_adv_obj_page</li>
<ul>
<li>\ref create_explode_page</li>
<li>\ref tui_working_with_groups_page</li>
<li>\ref tui_building_by_blocks_page</li>
<li>\ref tui_sketcher_page</li>
+<li>\ref tui_3dsketcher_page</li>
<li>\ref tui_advanced_geom_objs_page</li>
</ul>
<li>\ref tui_transformation_page</li>
--- /dev/null
+/*!
+
+\page tui_3dsketcher_page 3D Sketcher
+
+\code
+import geompy
+import salome
+gg = salome.ImportComponentGUI("GEOM")
+
+# create a 3D sketcher (wire) of the given points coordinates
+sketcher1 = geompy.Make3DSketcher([ 0,0,0, 50,50,50, 0,50,0, 50,0,50, 10,20,100, 0,0,0 ])
+
+# add object in the study
+id_sketcher1 = geompy.addToStudy(sketcher1,"Sketcher1")
+
+# display the sketcher
+gg.createAndDisplayGO(id_sketcher1)
+\endcode
+
+*/
\ No newline at end of file
* \return New GEOM_Object, containing the created wire.
*/
GEOM_Object MakeSketcher (in string theCommand, in ListOfDouble theWorkingPlane);
+
+ /*!
+ * Create a 3D sketcher, following the numerical description,
+ * passed through points created by \a theCoordinates argument. \n
+ * Format of the description string have to be the following:
+ *
+ * "Make3DSketcher[x1, y1, z1, x2, y2, z2, ..., xN, yN, zN]"
+ */
+
+ GEOM_Object Make3DSketcher (in ListOfDouble theCoordinates);
/*!
* Create a sketcher (wire or face), following the textual description,
<separator pos-id=""/>
<popup-item item-id="404" pos-id="" label-id="Sketch" icon-id="sketch.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="405" pos-id="" label-id="3D Sketch" icon-id="3dsketch.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<separator pos-id=""/>
<popup-item item-id="407" pos-id="" label-id="Explode" icon-id="subshape.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<submenu label-id="Build" item-id="408" pos-id="">
<endsubmenu />
<separator pos-id=""/>
<popup-item item-id="404" pos-id="" label-id="Sketch" icon-id="sketch.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="405" pos-id="" label-id="3D Sketch" icon-id="3dsketch.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="406" pos-id="" label-id="Spline" icon-id="spline.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<separator pos-id=""/>
<popup-item item-id="407" pos-id="" label-id="Exploser" icon-id="subshape.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
GEOMDS_Resources \
ImportExport \
ShHealing \
+3dsketch.png \
angle.png \
arc.png \
arccenter.png \
#include <TopoDS_Shape.hxx>
#include "EntityGUI_SketcherDlg.h" // Sketcher
+#include "EntityGUI_3DSketcherDlg.h" // Sketcher
#include "EntityGUI_SubShapeDlg.h" // Method SUBSHAPE
//=======================================================================
getGeometryGUI()->ActiveWorkingPlane();
aDlg = new EntityGUI_SketcherDlg( getGeometryGUI(), parent );
break;
+ case 405: // 3D SKETCHER
+ aDlg = new EntityGUI_3DSketcherDlg( getGeometryGUI(), parent );
+ break;
case 407: // EXPLODE : use ic
aDlg = new EntityGUI_SubShapeDlg( getGeometryGUI(), parent );
break;
--- /dev/null
+// GEOM GEOMGUI : GUI for Geometry component
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : EntityGUI_3DSketcherDlg.cxx
+// Author : DMV, OCN
+//
+
+#include "EntityGUI_3DSketcherDlg.h"
+#include "EntityGUI_Widgets.h"
+#include <QtxDoubleSpinBox.h>
+
+#include <GEOMBase.h>
+#include <GeometryGUI.h>
+#include <GEOMImpl_Types.hxx>
+#include <Precision.hxx>
+
+#include <DlgRef.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_Session.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_ResourceMgr.h>
+#include <SalomeApp_Application.h>
+#include <LightApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+
+#include <BRep_Tool.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <BRepBuilderAPI_Transform.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+
+class Locker
+{
+public:
+ Locker( bool& l ) : myLock( l ) { myLock = true; }
+ ~Locker() { myLock = false; }
+private:
+ bool& myLock;
+};
+
+//=================================================================================
+// class : EntityGUI_3DSketcherDlg()
+// purpose : Constructs a EntityGUI_3DSketcherDlg which is a child of 'parent', with the
+// name 'name' and widget flags set to 'f'.
+// The dialog will by default be modeless, unless you set 'modal' to
+// TRUE to construct a modal dialog.
+//=================================================================================
+EntityGUI_3DSketcherDlg::EntityGUI_3DSketcherDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
+ bool modal, Qt::WindowFlags fl )
+ : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
+{
+ 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" ) );
+
+ /***************************************************************/
+
+ mainFrame()->GroupConstructors->setTitle( tr( "GEOM_3DSKETCHER" ) );
+ mainFrame()->RadioButton1->setIcon( image3 );;
+ mainFrame()->RadioButton2->close();
+ mainFrame()->RadioButton3->close();
+
+ GroupType = new DlgRef_3Radio(centralWidget());
+ GroupType->GroupBox1->setTitle(tr("GEOM_COORDINATES_TYPE"));
+ GroupType->RadioButton1->setText(tr("GEOM_SKETCHER_ABS"));
+ GroupType->RadioButton2->setText(tr("GEOM_SKETCHER_REL"));
+ GroupType->RadioButton3->close();
+
+ 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" ) );
+
+ 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 );
+
+ setHelpFileName( "create_3dsketcher_page.html" );
+
+ resize(0,0);
+ Init();
+}
+
+
+
+//=================================================================================
+// function : ~EntityGUI_3DSketcherDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+EntityGUI_3DSketcherDlg::~EntityGUI_3DSketcherDlg()
+{
+ myGeomGUI->SetActiveDialogBox( 0 );
+}
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void EntityGUI_3DSketcherDlg::Init()
+{
+ myOK = false;
+
+ localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
+
+ /* Get setting of step value from file configuration */
+ 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, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+ initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+ initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+
+ /* signals and slots connections */
+ connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( PointClicked( int ) ) );
+
+ 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( GroupType->RadioButton1, SIGNAL( clicked() ), this, SLOT( TypeClicked() ) );
+ connect( GroupType->RadioButton2, SIGNAL( clicked() ), this, SLOT( TypeClicked() ) );
+
+ 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( 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();
+}
+
+//=================================================================================
+// function : TypeClicked()
+// purpose : Radio button management
+//=================================================================================
+void EntityGUI_3DSketcherDlg::TypeClicked()
+{
+ 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
+ double x, y, z;
+ GetLastPoints(x, y, z);
+ if ( GroupType->RadioButton1->isChecked() ) { // 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->setValue( x + Group3Spin->SpinBox_DX->value() );
+ Group3Spin->SpinBox_DY->setValue( y + Group3Spin->SpinBox_DY->value() );
+ Group3Spin->SpinBox_DZ->setValue( z + Group3Spin->SpinBox_DZ->value() );
+ Group3Spin->buttonApply->setFocus();
+ } else if ( GroupType->RadioButton2->isChecked() ) { // DXDY
+ Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
+ Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
+ Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_DZ2" ) );
+ Group3Spin->SpinBox_DX->setValue( Group3Spin->SpinBox_DX->value() - x );
+ Group3Spin->SpinBox_DY->setValue( Group3Spin->SpinBox_DY->value() - y );
+ Group3Spin->SpinBox_DZ->setValue( Group3Spin->SpinBox_DZ->value() - z );
+ Group3Spin->buttonApply->setFocus();
+ }
+ Group3Spin->SpinBox_DX->blockSignals(blocked);
+ Group3Spin->SpinBox_DY->blockSignals(blocked);
+ Group3Spin->SpinBox_DZ->blockSignals(blocked);
+}
+
+//=================================================================================
+// function : ClickOnAddPoint()
+// purpose : called when the point coordinates is Applyed
+//=================================================================================
+void EntityGUI_3DSketcherDlg::ClickOnAddPoint()
+{
+ double x, y, z;
+ GetCurrentPoints(x, y, z);
+ myPointsList.append(x);
+ myPointsList.append(y);
+ myPointsList.append(z);
+
+ /*if (myRedoList.size() >= 2) { // Remove this positions from Redo List
+ for (int i = 0; i <= 2; i++)
+ myRedoList.removeFirst();
+ }*/
+ myRedoList.clear();
+
+ if ( GroupType->RadioButton2->isChecked() ) {
+ Group3Spin->SpinBox_DX->setValue( 0.0 );
+ Group3Spin->SpinBox_DY->setValue( 0.0 );
+ Group3Spin->SpinBox_DZ->setValue( 0.0 );
+ }
+ UpdateButtonsState();
+ displayPreview();
+}
+
+//=================================================================================
+// function : UpdateButtonsState()
+// purpose :
+//=================================================================================
+void EntityGUI_3DSketcherDlg::UpdateButtonsState()
+{
+ if ( !myPointsList.count() )
+ GroupType->RadioButton1->setChecked( true );
+ GroupType->RadioButton2->setEnabled( myPointsList.count() > 2 );
+ Group3Spin->buttonUndo->setEnabled( myPointsList.count() > 2 );
+ Group3Spin->buttonRedo->setEnabled( myRedoList.count() > 2 );
+}
+
+//=================================================================================
+// function : ClickOnUndo()
+// purpose :
+//=================================================================================
+void EntityGUI_3DSketcherDlg::ClickOnUndo()
+{
+ if (myPointsList.count() > 2) {
+ double x, y, z;
+ GetLastPoints(x, y, z);
+ myRedoList.append(x);
+ myRedoList.append(y);
+ myRedoList.append(z);
+ myPointsList.removeLast();
+ myPointsList.removeLast();
+ myPointsList.removeLast();
+
+ UpdateButtonsState();
+ displayPreview();
+ }
+}
+
+//=================================================================================
+// function : ClickOnRedo()
+// purpose :
+//=================================================================================
+void EntityGUI_3DSketcherDlg::ClickOnRedo()
+{
+ int count = myRedoList.count();
+ if ( count > 2 ) {
+ myPointsList.append( myRedoList[count-3] );
+ myPointsList.append( myRedoList[count-2] );
+ myPointsList.append( myRedoList[count-1] );
+ myRedoList.removeLast();
+ myRedoList.removeLast();
+ myRedoList.removeLast();
+
+ UpdateButtonsState();
+ displayPreview();
+ }
+}
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection as changed
+//=================================================================================
+void EntityGUI_3DSketcherDlg::SelectionIntoArgument()
+{
+ LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+ SALOME_ListIO aSelList;
+ aSelMgr->selectedObjects(aSelList);
+
+ int nbSel = aSelList.Extent();
+ if ( nbSel == 1 ) {
+ Standard_Boolean aRes = Standard_False;
+ GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
+ if (!CORBA::is_nil(aSelectedObject) && aRes) {
+ TopoDS_Shape aShape;
+ 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);
+ }
+ }
+ bool isOk = true;
+ if ( aShape.ShapeType() != TopAbs_VERTEX )
+ isOk = GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX);
+ if (isOk) {
+ gp_Pnt aPnt;
+ if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
+ // set coordinates to the Spin Boxes
+ double aX, aY, aZ;
+ aX = aPnt.X();
+ aY = aPnt.Y();
+ aZ = aPnt.Z();
+ bool blocked = Group3Spin->SpinBox_DX->signalsBlocked();
+ 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() ) {
+ double x, y, z;
+ GetLastPoints(x, y, z);
+ Group3Spin->SpinBox_DX->setValue( aX - x );
+ Group3Spin->SpinBox_DY->setValue( aY - y );
+ Group3Spin->SpinBox_DZ->setValue( aZ - z );
+ }
+ Group3Spin->SpinBox_DX->blockSignals(blocked);
+ Group3Spin->SpinBox_DY->blockSignals(blocked);
+ Group3Spin->SpinBox_DZ->blockSignals(blocked);
+ }
+ }
+ }
+ }
+ displayPreview();
+}
+
+//=================================================================================
+// function : DeactivateActiveDialog()
+// purpose :
+//=================================================================================
+void EntityGUI_3DSketcherDlg::DeactivateActiveDialog()
+{
+ setEnabled( false );
+ globalSelection();
+ disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
+ myGeomGUI->SetActiveDialogBox( 0 );
+}
+
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void EntityGUI_3DSketcherDlg::ActivateThisDialog()
+{
+ myGeomGUI->EmitSignalDeactivateDialog();
+ setEnabled( true );
+ myGeomGUI->SetActiveDialogBox( this );
+
+ connect( myGeomGUI->getApp()->selectionMgr(),
+ SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+
+ localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
+ displayPreview();
+}
+
+
+//=================================================================================
+// function : ValueChangedInSpinBox()
+// purpose :
+//=================================================================================
+void EntityGUI_3DSketcherDlg::ValueChangedInSpinBox( double newValue )
+{
+ displayPreview();
+}
+
+//=================================================================================
+// function : enterEvent()
+// purpose :
+//=================================================================================
+void EntityGUI_3DSketcherDlg::enterEvent( QEvent* )
+{
+ if ( !mainFrame()->GroupConstructors->isEnabled() )
+ ActivateThisDialog();
+}
+
+//=================================================================================
+// function : createOperation
+// purpose :
+//=================================================================================
+GEOM::GEOM_IOperations_ptr EntityGUI_3DSketcherDlg::createOperation()
+{
+ return getGeomEngine()->GetICurvesOperations( getStudyId() );
+}
+
+//=================================================================================
+// function : isValid
+// purpose :
+//=================================================================================
+bool EntityGUI_3DSketcherDlg::isValid( QString& msg )
+{
+ int nbPoints = myPointsList.count()/3;
+ if ( myOK )
+ return nbPoints >= 2;
+ else
+ return nbPoints >= 1;
+}
+
+//=================================================================================
+// function : execute
+// purpose :
+//=================================================================================
+bool EntityGUI_3DSketcherDlg::execute( ObjectList& objects )
+{
+ GEOM::ListOfDouble_var aCoordsArray = new GEOM::ListOfDouble;
+ if (myOK)
+ aCoordsArray->length(myPointsList.size());
+ else
+ aCoordsArray->length(myPointsList.size()+3);
+
+ int i = 0;
+ QList<double>::const_iterator it;
+ for(it = myPointsList.begin(); it != myPointsList.end(); ++it ) {
+ aCoordsArray[i] = *it;
+ i++;
+ }
+
+ if (!myOK) {
+ double x, y, z;
+ GetCurrentPoints(x, y, z);
+ aCoordsArray[i] = x;
+ aCoordsArray[i+1] = y;
+ aCoordsArray[i+2] = z;
+ }
+
+ GEOM::GEOM_Object_var anObj =
+ GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->Make3DSketcher( aCoordsArray );
+
+ if ( !anObj->_is_nil() )
+ objects.push_back( anObj._retn() );
+
+ return true;
+}
+
+//=================================================================================
+// function : initSpinBox()
+// purpose :
+//=================================================================================
+
+void EntityGUI_3DSketcherDlg::initSpinBox( QDoubleSpinBox* spinBox,
+ double min, double max,
+ double step, int decimals )
+{
+ spinBox->setDecimals( decimals );
+ spinBox->setRange( min, max );
+ spinBox->setSingleStep( step );
+}
+
+//=================================================================================
+// function : SetDoubleSpinBoxStep()
+// purpose : Double spin box management
+//=================================================================================
+void EntityGUI_3DSketcherDlg::SetDoubleSpinBoxStep( double step )
+{
+ Group3Spin->SpinBox_DX->setSingleStep(step);
+ Group3Spin->SpinBox_DY->setSingleStep(step);
+ Group3Spin->SpinBox_DZ->setSingleStep(step);
+}
+
+//=================================================================================
+// function : isSameAsPrevious()
+// purpose : Compare Last point in the list with current selected point
+//=================================================================================
+/*bool EntityGUI_3DSketcherDlg::isSameAsPrevious() // Not used this time
+{
+ double curX, curY, curZ;
+ double lastX, lastY, lastZ;
+ GetCurrentPoints(curX, curY, curZ);
+ GetLastPoints(lastX, lastY, lastZ);
+ if ( abs(lastX - curX) < Precision::Confusion() &&
+ abs(lastY - curY) < Precision::Confusion() &&
+ abs(lastZ - curZ) < Precision::Confusion() )
+ return true;
+
+ return false;
+}*/
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void EntityGUI_3DSketcherDlg::ClickOnOk()
+{
+ Locker lock( myOK );
+
+ if ( !onAccept() )
+ return;
+
+ ClickOnCancel();
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+bool EntityGUI_3DSketcherDlg::ClickOnApply()
+{
+ if (myPointsList.count() > 3) {
+ myPointsList.append(myPointsList[0]);
+ myPointsList.append(myPointsList[1]);
+ myPointsList.append(myPointsList[2]);
+ }
+
+ Locker lock( myOK );
+
+ if ( !onAccept() )
+ return false;
+
+ ClickOnCancel();
+ return true;
+}
+
+//=================================================================================
+// function : GetLastPoints()
+// purpose : return last points from list
+//=================================================================================
+void EntityGUI_3DSketcherDlg::GetLastPoints(double& x, double& y, double& z)
+{
+ int count = myPointsList.count();
+ x = count > 2 ? myPointsList[count-3] : 0.0;
+ y = count > 2 ? myPointsList[count-2] : 0.0;
+ z = count > 2 ? myPointsList[count-1] : 0.0;
+}
+
+//=================================================================================
+// function : GetCurrentPoints()
+// purpose : returns current points
+//=================================================================================
+void EntityGUI_3DSketcherDlg::GetCurrentPoints(double& x, double& y, double& z)
+{
+ if ( GroupType->RadioButton1->isChecked() ) {
+ x = Group3Spin->SpinBox_DX->value();
+ y = Group3Spin->SpinBox_DY->value();
+ z = Group3Spin->SpinBox_DZ->value();
+ } else { // if (GroupType->RadioButton2->isChecked())
+ GetLastPoints(x, y, z);
+ x += Group3Spin->SpinBox_DX->value();
+ y += Group3Spin->SpinBox_DY->value();
+ z += Group3Spin->SpinBox_DZ->value();
+ }
+}
--- /dev/null
+// GEOM GEOMGUI : GUI for Geometry component
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : EntityGUI_3DSketcherDlg.h
+// Author : DMV, OCN
+//
+
+#ifndef ENTITYGUI_3DSKETCHERDLG_H
+#define ENTITYGUI_3DSKETCHERDLG_H
+
+#include <GEOMBase_Skeleton.h>
+
+class QDoubleSpinBox;
+class EntityGUI_3Spin;
+class DlgRef_3Radio;
+
+#ifndef COORD_MIN
+# define COORD_MIN -1e+15
+# define COORD_MAX +1e+15
+# define MAX_NUMBER 100000
+# define DBL_DIGITS_DISPLAY 16
+#endif // COORD_MIN
+
+//=================================================================================
+// class : EntityGUI_Dlg
+// purpose :
+//=================================================================================
+class EntityGUI_3DSketcherDlg : public GEOMBase_Skeleton
+{
+ Q_OBJECT
+
+public:
+ EntityGUI_3DSketcherDlg( GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0 );
+ ~EntityGUI_3DSketcherDlg();
+
+protected:
+ void initSpinBox( QDoubleSpinBox*,
+ double, double, double = 0.1,
+ int = 3 );
+
+ // redefined from GEOMBase_Helper
+ virtual GEOM::GEOM_IOperations_ptr createOperation();
+ virtual bool isValid( QString& );
+ virtual bool execute( ObjectList& );
+
+private:
+ void Init();
+ void enterEvent( QEvent* );
+
+private:
+ QList<double> myPointsList;
+ QList<double> myRedoList;
+
+ EntityGUI_3Spin* Group3Spin;
+ DlgRef_3Radio* GroupType;
+
+ bool myOK;
+
+private slots:
+ void ClickOnOk();
+ void ClickOnAddPoint();
+ bool ClickOnApply();
+ // bool isSameAsPrevious();
+ void UpdateButtonsState();
+ void GetLastPoints(double&, double&, double&);
+ void GetCurrentPoints(double&, double&, double&);
+
+ void ClickOnUndo();
+ void ClickOnRedo();
+
+ void SelectionIntoArgument();
+ void DeactivateActiveDialog();
+ void ActivateThisDialog();
+ void TypeClicked();
+ void ValueChangedInSpinBox( double );
+ void SetDoubleSpinBoxStep( double );
+};
+
+#endif // ENTITYGUI_SKETCHERDLG_H
EntityGUI.h \
EntityGUI_Widgets.h \
EntityGUI_SketcherDlg.h \
+ EntityGUI_3DSketcherDlg.h \
EntityGUI_SubShapeDlg.h
dist_libEntityGUI_la_SOURCES = \
EntityGUI.cxx \
EntityGUI_Widgets.cxx \
EntityGUI_SketcherDlg.cxx \
+ EntityGUI_3DSketcherDlg.cxx \
EntityGUI_SubShapeDlg.cxx
MOC_FILES = \
EntityGUI_Widgets_moc.cxx \
EntityGUI_SketcherDlg_moc.cxx \
+ EntityGUI_3DSketcherDlg_moc.cxx \
EntityGUI_SubShapeDlg_moc.cxx
nodist_libEntityGUI_la_SOURCES = \
<source>ICO_SKETCH</source>
<translation>sketch.png</translation>
</message>
+ <message>
+ <source>ICO_3DSKETCH</source>
+ <translation>3dsketch.png</translation>
+ </message>
<message>
<source>ICO_SOLID</source>
<translation>build_solid.png</translation>
<source>GEOM_SKETCHER_DY2</source>
<translation>DY :</translation>
</message>
+ <message>
+ <source>GEOM_SKETCHER_DZ2</source>
+ <translation>DZ :</translation>
+ </message>
<message>
<source>GEOM_SKETCHER_EL</source>
<translation>Element Type</translation>
<source>GEOM_SKETCHER_TITLE</source>
<translation>Sketch Construction</translation>
</message>
+ <message>
+ <source>GEOM_3DSKETCHER_TITLE</source>
+ <translation>3D Sketch Construction</translation>
+ </message>
<message>
<source>GEOM_SKETCHER_TYPE</source>
<translation>Type</translation>
<source>GEOM_SKETCHER_Y3</source>
<translation>Abs. Y :</translation>
</message>
+ <message>
+ <source>GEOM_SKETCHER_Z2</source>
+ <translation>Z :</translation>
+ </message>
+ <message>
+ <source>GEOM_3DSKETCHER</source>
+ <translation>3D Sketcher</translation>
+ </message>
+ <message>
+ <source>GEOM_COORDINATES_TYPE</source>
+ <translation>Coordinates Type</translation>
+ </message>
<message>
<source>GEOM_SOLID</source>
<translation>Solid</translation>
<source>MEN_SKETCH</source>
<translation>Sketch</translation>
</message>
+ <message>
+ <source>MEN_3DSKETCH</source>
+ <translation>3D Sketch</translation>
+ </message>
<message>
<source>MEN_SOLID</source>
<translation>Solid</translation>
#endif
}
else if( id == 404 || // MENU ENTITY - SKETCHER
+ id == 405 || // MENU ENTITY - 3D SKETCHER
id == 407 ) { // MENU ENTITY - EXPLODE
#ifndef WNT
library = getLibrary( "libEntityGUI.so" );
createGeomAction( 9999, "HEX_SOLID" );
createGeomAction( 404, "SKETCH" );
+ createGeomAction( 405, "3DSKETCH" );
createGeomAction( 407, "EXPLODE" );
createGeomAction( 4081, "EDGE" );
createMenu( separator(), newEntId, -1 );
createMenu( 404, newEntId, -1 );
+ createMenu( 405, newEntId, -1 );
createMenu( separator(), newEntId, -1 );
createMenu( 407, newEntId, -1 );
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include <Standard_Stream.hxx>
+
+#include <GEOMImpl_3DSketcherDriver.hxx>
+#include <GEOMImpl_I3DSketcher.hxx>
+#include <GEOMImpl_Types.hxx>
+#include <GEOM_Function.hxx>
+
+#include <GEOMImpl_IMeasureOperations.hxx>
+
+// OCCT Includes
+#include <BRepBuilderAPI_MakePolygon.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Wire.hxx>
+#include <gp_Pnt.hxx>
+
+#include <Standard_ConstructionError.hxx>
+
+//=======================================================================
+//function : GetID
+//purpose :
+//=======================================================================
+const Standard_GUID& GEOMImpl_3DSketcherDriver::GetID()
+{
+ static Standard_GUID a3DSketcherDriver("FF2BBB54-5D24-4df3-210B-3A678263EA26");
+ return a3DSketcherDriver;
+}
+
+
+//=======================================================================
+//function : GEOMImpl_3DSketcherDriver
+//purpose :
+//=======================================================================
+GEOMImpl_3DSketcherDriver::GEOMImpl_3DSketcherDriver()
+{
+}
+
+//=======================================================================
+//function : Execute
+//purpose :
+//=======================================================================
+Standard_Integer GEOMImpl_3DSketcherDriver::Execute(TFunction_Logbook& log) const
+{
+ 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();
+
+ BRepBuilderAPI_MakePolygon aMakePoly;
+ int anArrayLength = aCoordsArray->Length();
+ double x, y, z;
+ for (int i = 0; i <=(anArrayLength - 3); i+=3) {
+ x = aCoordsArray->Value(i+1);
+ y = aCoordsArray->Value(i+2);
+ z = aCoordsArray->Value(i+3);
+ gp_Pnt aPnt = gp_Pnt(x, y, z);
+ aMakePoly.Add(aPnt);
+ }
+ if (aCoordsArray->Value(1) == x && aCoordsArray->Value(2) == y && aCoordsArray->Value(3) == z)
+ aMakePoly.Close();
+
+ if (aMakePoly.IsDone())
+ aShape = aMakePoly.Wire();
+
+ if (aShape.IsNull()) return 0;
+
+ aFunction->SetValue(aShape);
+ log.SetTouched(Label());
+ return 1;
+}
+
+
+//=======================================================================
+//function : GEOMImpl_3DSketcherDriver_Type_
+//purpose :
+//=======================================================================
+Standard_EXPORT Handle_Standard_Type& GEOMImpl_3DSketcherDriver_Type_()
+{
+
+ static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
+ if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
+ static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
+ if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
+ static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
+ if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
+
+
+ static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
+ static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_3DSketcherDriver",
+ sizeof(GEOMImpl_3DSketcherDriver),
+ 1,
+ (Standard_Address)_Ancestors,
+ (Standard_Address)NULL);
+
+ return _aType;
+}
+
+//=======================================================================
+//function : DownCast
+//purpose :
+//=======================================================================
+const Handle(GEOMImpl_3DSketcherDriver) Handle(GEOMImpl_3DSketcherDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
+{
+ Handle(GEOMImpl_3DSketcherDriver) _anOtherObject;
+
+ if (!AnObject.IsNull()) {
+ if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_3DSketcherDriver))) {
+ _anOtherObject = Handle(GEOMImpl_3DSketcherDriver)((Handle(GEOMImpl_3DSketcherDriver)&)AnObject);
+ }
+ }
+
+ return _anOtherObject ;
+}
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : GEOMImpl_3DSketcherDriver.ixx
+// Module : GEOMImpl
+
+#ifndef _GEOMImpl_3DSketcherDriver_HeaderFile
+#define _GEOMImpl_3DSketcherDriver_HeaderFile
+
+#ifndef _TColStd_SequenceOfExtendedString_HeaderFile
+#include <TColStd_SequenceOfExtendedString.hxx>
+#endif
+#ifndef _Standard_TypeMismatch_HeaderFile
+#include <Standard_TypeMismatch.hxx>
+#endif
+
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+
+#ifndef _Standard_Macro_HeaderFile
+#include <Standard_Macro.hxx>
+#endif
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+#ifndef _Standard_GUID_HeaderFile
+#include <Standard_GUID.hxx>
+#endif
+
+#ifndef _Handle_TFunction_Driver_HeaderFile
+#include <Handle_TFunction_Driver.hxx>
+#endif
+
+class Standard_Transient;
+class Handle_Standard_Type;
+class Handle(TFunction_Driver);
+class GEOMImpl_3DSketcherDriver;
+
+Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_3DSketcherDriver);
+
+class Handle(GEOMImpl_3DSketcherDriver) : public Handle(TFunction_Driver) {
+ public:
+ inline void* operator new(size_t,void* anAddress)
+ {
+ return anAddress;
+ }
+ inline void* operator new(size_t size)
+ {
+ return Standard::Allocate(size);
+ }
+ inline void operator delete(void *anAddress)
+ {
+ if (anAddress) Standard::Free((Standard_Address&)anAddress);
+ }
+
+ Handle(GEOMImpl_3DSketcherDriver)():Handle(TFunction_Driver)() {}
+ Handle(GEOMImpl_3DSketcherDriver)(const Handle(GEOMImpl_3DSketcherDriver)& aHandle) : Handle(TFunction_Driver)(aHandle)
+ {
+ }
+
+ Handle(GEOMImpl_3DSketcherDriver)(const GEOMImpl_3DSketcherDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem)
+ {
+ }
+
+ Handle(GEOMImpl_3DSketcherDriver)& operator=(const Handle(GEOMImpl_3DSketcherDriver)& aHandle)
+ {
+ Assign(aHandle.Access());
+ return *this;
+ }
+
+ Handle(GEOMImpl_3DSketcherDriver)& operator=(const GEOMImpl_3DSketcherDriver* anItem)
+ {
+ Assign((Standard_Transient *)anItem);
+ return *this;
+ }
+
+ GEOMImpl_3DSketcherDriver* operator->()
+ {
+ return (GEOMImpl_3DSketcherDriver *)ControlAccess();
+ }
+
+ GEOMImpl_3DSketcherDriver* operator->() const
+ {
+ return (GEOMImpl_3DSketcherDriver *)ControlAccess();
+ }
+
+ Standard_EXPORT ~Handle(GEOMImpl_3DSketcherDriver)() {};
+
+ Standard_EXPORT static const Handle(GEOMImpl_3DSketcherDriver) DownCast(const Handle(Standard_Transient)& AnObject);
+};
+
+#ifndef _TFunction_Driver_HeaderFile
+#include <TFunction_Driver.hxx>
+#endif
+#ifndef _TFunction_Logbook_HeaderFile
+#include <TFunction_Logbook.hxx>
+#endif
+#ifndef _Standard_CString_HeaderFile
+#include <Standard_CString.hxx>
+#endif
+
+class TColStd_SequenceOfExtendedString;
+
+
+class GEOMImpl_3DSketcherDriver : public TFunction_Driver {
+
+public:
+
+ inline void* operator new(size_t,void* anAddress)
+ {
+ return anAddress;
+ }
+ inline void* operator new(size_t size)
+ {
+ return Standard::Allocate(size);
+ }
+ inline void operator delete(void *anAddress)
+ {
+ if (anAddress) Standard::Free((Standard_Address&)anAddress);
+ }
+
+ // Methods PUBLIC
+ //
+Standard_EXPORT GEOMImpl_3DSketcherDriver();
+Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const;
+Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {}
+Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; }
+Standard_EXPORT static const Standard_GUID& GetID();
+Standard_EXPORT ~GEOMImpl_3DSketcherDriver() {};
+
+
+ // Type management
+ //
+Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_3DSketcherDriver_Type_();
+Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_3DSketcherDriver) ; }
+Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_3DSketcherDriver) == AType || TFunction_Driver::IsKind(AType)); }
+
+
+};
+
+#endif
#include <GEOMImpl_PolylineDriver.hxx>
#include <GEOMImpl_SplineDriver.hxx>
#include <GEOMImpl_SketcherDriver.hxx>
+#include <GEOMImpl_3DSketcherDriver.hxx>
#include <GEOMImpl_BoxDriver.hxx>
#include <GEOMImpl_FaceDriver.hxx>
#include <GEOMImpl_DiskDriver.hxx>
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PolylineDriver::GetID(), new GEOMImpl_PolylineDriver());
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_SplineDriver::GetID(), new GEOMImpl_SplineDriver());
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_SketcherDriver::GetID(), new GEOMImpl_SketcherDriver());
+ TFunction_DriverTable::Get()->AddDriver(GEOMImpl_3DSketcherDriver::GetID(), new GEOMImpl_3DSketcherDriver());
// 3D Primitives
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_BoxDriver::GetID(), new GEOMImpl_BoxDriver());
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.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 <TColStd_HArray1OfReal.hxx>
+
+#define SKETCH_ARG_COORDS 1
+
+class GEOMImpl_I3DSketcher
+{
+ public:
+
+ GEOMImpl_I3DSketcher(Handle(GEOM_Function) theFunction): _func(theFunction) {}
+
+ void SetCoordinates(const Handle(TColStd_HArray1OfReal)& theValue)
+ { _func->SetRealArray(SKETCH_ARG_COORDS, theValue); }
+
+ Handle(TColStd_HArray1OfReal) GetCoordinates() { return _func->GetRealArray(SKETCH_ARG_COORDS); }
+
+ private:
+
+ Handle(GEOM_Function) _func;
+};
#include <GEOMImpl_ICurvesOperations.hxx>
+#include <TColStd_HArray1OfReal.hxx>
+
#include <GEOM_Function.hxx>
#include <GEOM_PythonDump.hxx>
#include <GEOMImpl_EllipseDriver.hxx>
#include <GEOMImpl_ArcDriver.hxx>
#include <GEOMImpl_SketcherDriver.hxx>
+#include <GEOMImpl_3DSketcherDriver.hxx>
#include <GEOMImpl_IPolyline.hxx>
#include <GEOMImpl_ICircle.hxx>
#include <GEOMImpl_IEllipse.hxx>
#include <GEOMImpl_IArc.hxx>
#include <GEOMImpl_ISketcher.hxx>
+#include <GEOMImpl_I3DSketcher.hxx>
#include "utilities.h"
return aSketcher;
}
+//=============================================================================
+/*!
+ * Make3DSketcher
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (list<double> 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(), GEOM_3DSKETCHER);
+ 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;
+ list<double>::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 {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ 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 << a3DSketcher << " = geompy.Make3DSketcher([";
+
+ it = theCoordinates.begin();
+ pd << (*it++);
+ while (it != theCoordinates.end()) {
+ pd << ", " << (*it++);
+ }
+ pd << "])";
+
+ SetErrorCode(OK);
+ return a3DSketcher;
+}
+
//=============================================================================
/*!
* MakeSketcherOnPlane
Standard_EXPORT Handle(GEOM_Object) MakeSketcher (const char* theCommand,
list<double> theWorkingPlane);
+ Standard_EXPORT Handle(GEOM_Object) Make3DSketcher (list<double> theCoordinates);
Standard_EXPORT Handle(GEOM_Object) MakeSketcherOnPlane (const char* theCommand,
Handle(GEOM_Object) theWorkingPlane);
};
#define GEOM_ELLIPSE_ARC 43
+#define GEOM_3DSKETCHER 44
//GEOM_Function types
GEOMImpl_IArchimede.hxx \
GEOMImpl_IArc.hxx \
GEOMImpl_ISketcher.hxx \
+ GEOMImpl_I3DSketcher.hxx \
GEOMImpl_IVector.hxx \
GEOMImpl_IDisk.hxx \
GEOMImpl_IFace.hxx \
GEOMImpl_ArcDriver.hxx \
GEOMImpl_SplineDriver.hxx \
GEOMImpl_SketcherDriver.hxx \
+ GEOMImpl_3DSketcherDriver.hxx \
GEOMImpl_FilletDriver.hxx \
GEOMImpl_ChamferDriver.hxx \
GEOMImpl_BooleanDriver.hxx \
GEOMImpl_ArcDriver.cxx \
GEOMImpl_SplineDriver.cxx \
GEOMImpl_SketcherDriver.cxx \
+ GEOMImpl_3DSketcherDriver.cxx \
GEOMImpl_FilletDriver.cxx \
GEOMImpl_ChamferDriver.cxx \
GEOMImpl_BooleanDriver.cxx \
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();
+ list<double> aCoords;
+ for (; ind < aLen; ind++)
+ aCoords.push_back(theCoordinates[ind]);
+
+ // Make Sketcher
+ Handle(GEOM_Object) anObject =
+ GetOperations()->Make3DSketcher(aCoords);
+ if (!GetOperations()->IsDone() || anObject.IsNull())
+ return GEOM::GEOM_Object::_nil();
+
+ return GetObject(anObject);
+}
//=============================================================================
/*!
GEOM::GEOM_Object_ptr MakeSplineInterpolation (const GEOM::ListOfGO& thePoints);
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);
return NULL;
}
+//=============================================================================
+// Make3DSketcher:
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_Superv_i::Make3DSketcher ( GEOM::GEOM_List_ptr theCoordinates)
+{
+ beginService( " GEOM_Superv_i::Make3DSketcher" );
+ MESSAGE("GEOM_Superv_i::Make3DSketcher");
+ if (GEOM_List_i<GEOM::ListOfDouble>* aListImpl =
+ dynamic_cast<GEOM_List_i<GEOM::ListOfDouble>*>(GetServant(theCoordinates, myPOA).in())) {
+ getCurvesOp();
+ GEOM::GEOM_Object_ptr anObj = myCurvesOp->Make3DSketcher(aListImpl->GetList());
+ endService( " GEOM_Superv_i::Make3DSketcher" );
+ return anObj;
+ }
+ endService( " GEOM_Superv_i::Make3DSketcher" );
+ return NULL;
+}
+
//=============================== LocalOperations =============================
//=============================================================================
// MakeFilletAll:
GEOM::GEOM_Object_ptr MakeSplineInterpolation (GEOM::GEOM_List_ptr thePoints);
GEOM::GEOM_Object_ptr MakeSketcher (const char* theCommand,
GEOM::GEOM_List_ptr theWorkingPlane);
+ GEOM::GEOM_Object_ptr Make3DSketcher (GEOM::GEOM_List_ptr theCoordinates);
//-----------------------------------------------------------//
// LocalOperations //
Interpol = geompy.MakeInterpol([px, py, p200, pxyz]) #(List of GEOM_Object_ptr)->GEOM_Object_ptr
Sketcher = geompy.MakeSketcher("Sketcher:F -100 -100:TT 250 -100:R 0:C 100 150:R 0:L 300:WW",
[100,0,0, 1,1,1, -1,1,0]) #(String, List of Doubles)->GEOM_Object_ptr
+ Sketcher3d = geompy.Make3DSketcher([0,0,0, 50,50,50, 0,50,50, 10,0,0])
#Test point on curve creation
p_on_arc = geompy.MakeVertexOnCurve(Arc, 0.25) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr
id_Bezier = geompy.addToStudy(Bezier, "Bezier")
id_Interpol = geompy.addToStudy(Interpol, "Interpol")
id_Sketcher = geompy.addToStudy(Sketcher, "Sketcher")
+ id_Sketcher3d = geompy.addToStudy(Sketcher3d, "Sketcher 3D")
id_p_on_arc = geompy.addToStudy(p_on_arc, "Vertex on Arc (0.25)")
id_p_on_l1l2 = geompy.addToStudy(p_on_l1l2, "Vertex on Lines Intersection")
anObj = self.CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane)
RaiseIfFailed("MakeSketcherOnPlane", self.CurvesOp)
return anObj
+
+ ## Create a sketcher wire, following the numerical description,
+ # passed through <VAR>theCoordinates</VAR> argument. \n
+ # @param theCoordinates double values, defining points to create a wire,
+ # passing from it.
+ # @return New GEOM_Object, containing the created wire.
+ #
+ # @ref tui_sketcher_page "Example"
+ def Make3DSketcher(self, theCoordinates):
+ anObj = self.CurvesOp.Make3DSketcher(theCoordinates)
+ RaiseIfFailed("Make3DSketcher", self.CurvesOp)
+ return anObj
# end of l3_sketcher
## @}