From 9a00eb28aa31a90da7e5bda8a768d96457bdd703 Mon Sep 17 00:00:00 2001 From: rnc Date: Wed, 25 Apr 2012 15:08:19 +0000 Subject: [PATCH] Added a test on selected input faces in sketcher dlg to check if they are planar. --- src/EntityGUI/EntityGUI_SketcherDlg.cxx | 26 ++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/EntityGUI/EntityGUI_SketcherDlg.cxx b/src/EntityGUI/EntityGUI_SketcherDlg.cxx index 593544d2c..6b117c091 100644 --- a/src/EntityGUI/EntityGUI_SketcherDlg.cxx +++ b/src/EntityGUI/EntityGUI_SketcherDlg.cxx @@ -38,6 +38,8 @@ #include #include +#include + #include #include #include @@ -1370,13 +1372,26 @@ void EntityGUI_SketcherDlg::SelectionIntoArgument() && !aShape.IsNull()) { QString aName = GEOMBase::GetName( aSelectedObject.get() ); - myEditCurrentArgument->setText(aName); if (myEditCurrentArgument==WPlaneLineEdit) { - AddLocalCS(aSelectedObject.get()); - selButton->setDown(false); - WPlaneLineEdit->setEnabled(false); - TypeClicked( myConstructorId ); + // Check if the face is planar + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aShape)); + GeomLib_IsPlanarSurface aPlanarCheck(aSurf, Precision::Confusion()); + + if (aPlanarCheck.IsPlanar()) + { + myEditCurrentArgument->setText(aName); + AddLocalCS(aSelectedObject.get()); + selButton->setDown(false); + WPlaneLineEdit->setEnabled(false); + TypeClicked( myConstructorId ); + } + else + { + myEditCurrentArgument->setText(tr("GEOM_SKETCHER_WPLANE")); + // The following leads to crash TODO : find a way to return a warning +// Standard_Failure::Raise(tr("GEOM_SKETCHER_NOT_PLANAR").toStdString().c_str()); + } } else { @@ -1390,6 +1405,7 @@ void EntityGUI_SketcherDlg::SelectionIntoArgument() gp_Pnt aPnt; if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) { + myEditCurrentArgument->setText(aName); myX = aPnt.X(); myY = aPnt.Y(); double Xcoord = myX; -- 2.39.2