From: rnc Date: Wed, 1 Aug 2012 15:18:17 +0000 (+0000) Subject: EDF 1337 : Sketcher 3D improvement X-Git-Tag: V6_6_0a1~57 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=35a548b486b525c4215cee7819265cecce69b99a;p=modules%2Fgeom.git EDF 1337 : Sketcher 3D improvement Truncate displayed length and angles to a number of significant digits --- diff --git a/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx b/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx index 89e33f30f..cc1110d91 100755 --- a/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx +++ b/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx @@ -153,8 +153,9 @@ EntityGUI_3DSketcherDlg::EntityGUI_3DSketcherDlg( GeometryGUI* theGeometryGUI, Q 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->CheckBox2->setText( tr( "Show angle dimensions" ) ); //TODO translation buttonOk()->setText( tr( "GEOM_BUT_END_SKETCH" ) ); buttonApply()->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) ); @@ -1063,8 +1064,8 @@ void EntityGUI_3DSketcherDlg::displayAngle(double theAngle1, double theAngle2, d Handle(Geom_Plane) aPlane = new Geom_Plane(gce_MP.Value()); // Covert angles to string - std::string Angle1_str = boost::lexical_cast(theAngle1); - std::string Angle2_str = boost::lexical_cast(theAngle2); + std::string Angle1_str = doubleToString(theAngle1); + std::string Angle2_str = doubleToString(theAngle2); Handle(AIS_AngleDimension) anAngleIO = new AIS_AngleDimension(anEdge1, anEdge2, aPlane, theAngle1 * M_PI / 180., TCollection_ExtendedString(Angle1_str.c_str())); @@ -1156,7 +1157,7 @@ void EntityGUI_3DSketcherDlg::displayLength(double theLength, bool store) TopoDS_Vertex aVert2 = BRepBuilderAPI_MakeVertex(P2); // Convert length to string - std::string aLength_str = boost::lexical_cast(aLength); + std::string aLength_str = doubleToString(aLength); // Plane for the presentation if ( Abs(Vec1.CrossMagnitude(Vec2)) < Precision::Confusion() ) // Check colinearity @@ -1306,3 +1307,16 @@ bool EntityGUI_3DSketcherDlg::createShapes( GEOM::GEOM_Object_ptr /*theObject*/, return true; } + +//================================================================ +// Function : doubleToString +// Purpose : converts double to string +//================================================================ +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(); +} diff --git a/src/EntityGUI/EntityGUI_3DSketcherDlg.h b/src/EntityGUI/EntityGUI_3DSketcherDlg.h index 76a46e9e9..3c23a480a 100755 --- a/src/EntityGUI/EntityGUI_3DSketcherDlg.h +++ b/src/EntityGUI/EntityGUI_3DSketcherDlg.h @@ -94,6 +94,8 @@ private: XYZ getLastPoint() const; XYZ getPenultimatePoint() const; XYZ getCurrentPoint() const; + + std::string doubleToString( double ); private: XYZList myPointsList;