]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
EDF 1337 : Sketcher 3D improvement
authorrnc <rnc@opencascade.com>
Wed, 1 Aug 2012 15:18:17 +0000 (15:18 +0000)
committerrnc <rnc@opencascade.com>
Wed, 1 Aug 2012 15:18:17 +0000 (15:18 +0000)
Truncate displayed length and angles to a number of significant digits

src/EntityGUI/EntityGUI_3DSketcherDlg.cxx
src/EntityGUI/EntityGUI_3DSketcherDlg.h

index 89e33f30f30536dd7c4f56f17dad26a6c0bd4e0c..cc1110d91dbea7f20174f943e3316eee2123c943 100755 (executable)
@@ -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<std::string>(theAngle1);
-  std::string Angle2_str = boost::lexical_cast<std::string>(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<std::string>(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();
+}
index 76a46e9e9c81108de4d6abc845adcb342aeb2364..3c23a480aa7cad5e499b39cf7f15265371f53ace 100755 (executable)
@@ -94,6 +94,8 @@ private:
   XYZ                                getLastPoint() const;
   XYZ                                getPenultimatePoint() const;
   XYZ                                getCurrentPoint() const;
+  
+  std::string                        doubleToString( double );
 
 private:
   XYZList                            myPointsList;