diff --git a/doc/salome/gui/GEOM/input/creating_3dsketcher.doc b/doc/salome/gui/GEOM/input/creating_3dsketcher.doc
index c3f847d2d..73712a0d0 100755
--- a/doc/salome/gui/GEOM/input/creating_3dsketcher.doc
+++ b/doc/salome/gui/GEOM/input/creating_3dsketcher.doc
@@ -11,9 +11,8 @@ To create a 3D Sketch, select in the main menu New Entity -> 3D Sketch .
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 Coordinates Type radio buttons.
-\n "Sketch Validation" button applies the whole wire.
-\n "Sketch Closure" button connects the first and the last points closing
-the contour and applies the closed wire.
+\n "Sketch Validation" button applies the wire, only red part will be built by "Sketch Validation".
+\n "Sketch Closure" will close the Sketch by straight line from last red part and apply it.
To make a closed wire using the TUI command, the first and the last point shoul
have the same coordinates.
diff --git a/doc/salome/gui/GEOM/input/creating_sketcher.doc b/doc/salome/gui/GEOM/input/creating_sketcher.doc
index 88629274f..1d19b83f9 100644
--- a/doc/salome/gui/GEOM/input/creating_sketcher.doc
+++ b/doc/salome/gui/GEOM/input/creating_sketcher.doc
@@ -52,6 +52,11 @@ is predefined and is equal to 90 degrees);
Parameters of an element (for segment : length or target X or Y coordinate value, for arc : radius and angle).
+\b Buttons:
+
+"Sketch Validation" button applies the wire, only red part will be built by "Sketch Validation".
+\n "Sketch Closure" will close the Sketch by straight line from last red part and apply it.
+
\n Dialog Box:
\image html neo-scetcher1.png
diff --git a/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx b/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx
index e10e6e692..134cbd3cf 100755
--- a/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx
+++ b/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx
@@ -67,8 +67,11 @@ private:
// 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 )
+ bool modal, Qt::WindowFlags fl,
+ const double lineWidth )
+ : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ),
+ myGeometryGUI( theGeometryGUI ),
+ myLineWidth( lineWidth )
{
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
@@ -169,6 +172,7 @@ void EntityGUI_3DSketcherDlg::Init()
initName( tr( "GEOM_3DSKETCHER" ) );
UpdateButtonsState();
+ GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
}
//=================================================================================
@@ -212,16 +216,14 @@ void EntityGUI_3DSketcherDlg::TypeClicked()
//=================================================================================
void EntityGUI_3DSketcherDlg::ClickOnAddPoint()
{
+ Locker lock( myOK );
+
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() ) {
@@ -229,8 +231,8 @@ void EntityGUI_3DSketcherDlg::ClickOnAddPoint()
Group3Spin->SpinBox_DY->setValue( 0.0 );
Group3Spin->SpinBox_DZ->setValue( 0.0 );
}
+ GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
UpdateButtonsState();
- displayPreview();
}
//=================================================================================
@@ -263,7 +265,7 @@ void EntityGUI_3DSketcherDlg::ClickOnUndo()
myPointsList.removeLast();
UpdateButtonsState();
- displayPreview();
+ GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
}
}
@@ -283,7 +285,7 @@ void EntityGUI_3DSketcherDlg::ClickOnRedo()
myRedoList.removeLast();
UpdateButtonsState();
- displayPreview();
+ GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
}
}
@@ -346,7 +348,7 @@ void EntityGUI_3DSketcherDlg::SelectionIntoArgument()
}
}
}
- displayPreview();
+ GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
}
//=================================================================================
@@ -376,7 +378,7 @@ void EntityGUI_3DSketcherDlg::ActivateThisDialog()
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
- displayPreview();
+ GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
}
@@ -386,7 +388,7 @@ void EntityGUI_3DSketcherDlg::ActivateThisDialog()
//=================================================================================
void EntityGUI_3DSketcherDlg::ValueChangedInSpinBox( double newValue )
{
- displayPreview();
+ GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
}
//=================================================================================
@@ -414,11 +416,7 @@ GEOM::GEOM_IOperations_ptr EntityGUI_3DSketcherDlg::createOperation()
//=================================================================================
bool EntityGUI_3DSketcherDlg::isValid( QString& msg )
{
- int nbPoints = myPointsList.count()/3;
- if ( myOK )
- return nbPoints >= 2;
- else
- return nbPoints >= 1;
+ return true;
}
//=================================================================================
@@ -428,10 +426,10 @@ bool EntityGUI_3DSketcherDlg::isValid( QString& msg )
bool EntityGUI_3DSketcherDlg::execute( ObjectList& objects )
{
GEOM::ListOfDouble_var aCoordsArray = new GEOM::ListOfDouble;
- if (myOK)
- aCoordsArray->length(myPointsList.size());
- else
+ if (!myOK || myPointsList.size() == 0)
aCoordsArray->length(myPointsList.size()+3);
+ else
+ aCoordsArray->length(myPointsList.size());
int i = 0;
QList::const_iterator it;
@@ -440,16 +438,15 @@ bool EntityGUI_3DSketcherDlg::execute( ObjectList& objects )
i++;
}
- if (!myOK) {
+ if (!myOK || myPointsList.size() == 0) {
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 );
+ GEOM::GEOM_Object_var anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->Make3DSketcher( aCoordsArray );
if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() );
@@ -482,24 +479,6 @@ void EntityGUI_3DSketcherDlg::SetDoubleSpinBoxStep( double 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 :
@@ -564,3 +543,87 @@ void EntityGUI_3DSketcherDlg::GetCurrentPoints(double& x, double& y, double& z)
z += Group3Spin->SpinBox_DZ->value();
}
}
+
+//================================================================
+// Function : displayPreview
+// Purpose : Method for displaying preview of resulting shape
+// Redefined from GEOMBase_Helper.
+//================================================================
+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 )
+{
+ // Set color for preview shape
+ getDisplayer()->SetColor( Quantity_NOC_RED );
+
+ // set width of displayed shape
+ getDisplayer()->SetWidth( (lineWidth == -1)?myLineWidth:lineWidth );
+
+ // Disable activation of selection
+ getDisplayer()->SetToActivate( activate );
+
+ // Make a reference to GEOM_Object
+ CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
+ getDisplayer()->SetName( objStr.in() );
+
+ // Create wire from applayed object
+ TopoDS_Shape anApplyedWire, aLastSegment;
+ if ( !createShapes( object, anApplyedWire, aLastSegment ) )
+ return;
+
+ // 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()->UnsetName();
+
+ // Enable activation of displayed objects
+ getDisplayer()->SetToActivate( true );
+}
+
+//================================================================
+// Function : createShapes
+// Purpose : Create applyed wire, and last segment from entry object
+//================================================================
+bool EntityGUI_3DSketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
+ TopoDS_Shape& theApplyedWire,
+ TopoDS_Shape& theLastSegment )
+{
+ TopoDS_Shape aShape;
+ if ( !GEOMBase::GetShape( theObject, aShape ) ||
+ aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX )
+ return false;
+
+ if ( myOK ) {
+ theApplyedWire = aShape;
+ return true;
+ }
+
+ BRepBuilderAPI_MakeWire aBuilder;
+ TopExp_Explorer anExp( aShape, TopAbs_EDGE );
+ while ( 1 ) {
+ TopoDS_Shape anEdge = anExp.Current();
+ anExp.Next();
+ if ( anExp.More() ) // i.e. non-last edge
+ aBuilder.Add( TopoDS::Edge( anEdge ) );
+ else {
+ theLastSegment = anEdge;
+ break;
+ }
+ }
+
+ if ( aBuilder.IsDone() )
+ theApplyedWire = aBuilder.Shape();
+
+ return true;
+}
diff --git a/src/EntityGUI/EntityGUI_3DSketcherDlg.h b/src/EntityGUI/EntityGUI_3DSketcherDlg.h
index 8c2544f45..19cdb327d 100755
--- a/src/EntityGUI/EntityGUI_3DSketcherDlg.h
+++ b/src/EntityGUI/EntityGUI_3DSketcherDlg.h
@@ -48,7 +48,7 @@ class EntityGUI_3DSketcherDlg : public GEOMBase_Skeleton
Q_OBJECT
public:
- EntityGUI_3DSketcherDlg( GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0 );
+ EntityGUI_3DSketcherDlg( GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0, const double = 2. );
~EntityGUI_3DSketcherDlg();
protected:
@@ -64,7 +64,19 @@ protected:
private:
void Init();
void enterEvent( QEvent* );
-
+
+ virtual void displayPreview( GEOM::GEOM_Object_ptr,
+ const bool = false,
+ const bool = false,
+ const bool = true,
+ const double = -1,
+ const int = -1,
+ const int = -1);
+
+ bool createShapes( GEOM::GEOM_Object_ptr,
+ TopoDS_Shape&,
+ TopoDS_Shape& );
+
private:
QList myPointsList;
QList myRedoList;
@@ -73,6 +85,8 @@ private:
DlgRef_3Radio* GroupType;
bool myOK;
+ double myLineWidth;
+ GeometryGUI* myGeometryGUI;
private slots:
void ClickOnOk();
diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts
index 981368ec5..fecc64b84 100644
--- a/src/GEOMGUI/GEOM_msg_en.ts
+++ b/src/GEOMGUI/GEOM_msg_en.ts
@@ -3614,7 +3614,7 @@ Please, select face, shell or solid and try again
GEOM_PLANAR_FACE
- Planar face
+ Planar Face
GEOM_POLYGON
diff --git a/src/GEOMImpl/GEOMImpl_3DSketcherDriver.cxx b/src/GEOMImpl/GEOMImpl_3DSketcherDriver.cxx
index 27603fe0f..ccf53fdfb 100755
--- a/src/GEOMImpl/GEOMImpl_3DSketcherDriver.cxx
+++ b/src/GEOMImpl/GEOMImpl_3DSketcherDriver.cxx
@@ -29,6 +29,7 @@
// OCCT Includes
#include
+#include
#include
#include
#include
@@ -73,18 +74,25 @@ Standard_Integer GEOMImpl_3DSketcherDriver::Execute(TFunction_Logbook& log) cons
BRepBuilderAPI_MakePolygon aMakePoly;
int anArrayLength = aCoordsArray->Length();
double x, y, z;
+ gp_Pnt aPnt;
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);
+ 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 ( anArrayLength == 3) { // Only Start Point
+ BRepBuilderAPI_MakeVertex mkVertex (aPnt);
+ aShape = mkVertex.Shape();
+ }
+ else { // Make Wire
+ 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;