Salome HOME
rnc: EDF 1618 GEOM: changed the wrning message when building an arc from endpoint...
authorgdd <gdd>
Fri, 29 Apr 2011 14:54:11 +0000 (14:54 +0000)
committergdd <gdd>
Fri, 29 Apr 2011 14:54:11 +0000 (14:54 +0000)
src/EntityGUI/EntityGUI_4Spin1Check_QTD.ui
src/EntityGUI/EntityGUI_Skeleton_QTD.ui
src/EntityGUI/EntityGUI_SketcherDlg.cxx
src/GEOMGUI/GEOM_msg_en.ts
src/GEOMGUI/GEOM_msg_fr.ts
src/SKETCHER/Sketcher_Profile.cxx
src/SKETCHER/Sketcher_Profile.hxx

index fa876ac60118c2a5422072cba1e6bbf016b8bcdc..b298c7c9d1d614222697931e9db983a1e8a9f152 100644 (file)
        <widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DS"/>
       </item>
       <item row="4" column="0" colspan="3">
-       <layout class="QHBoxLayout" name="horizontalLayout">
+       <layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0">
         <item>
          <widget class="QCheckBox" name="checkBox">
           <property name="text">
           </property>
          </widget>
         </item>
+        <item>
+         <spacer name="horizontalSpacer">
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>40</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
        </layout>
       </item>
      </layout>
index 6f92ba864a3c8a185d61ffe4d7d9a85d96d53982..52fc0b94051a5e990bad81d699c146e5fa7c64a5 100644 (file)
@@ -6,10 +6,16 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>380</width>
+    <width>390</width>
     <height>236</height>
    </rect>
   </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
   <property name="windowTitle">
    <string>Form</string>
   </property>
@@ -62,7 +68,7 @@
         </property>
         <property name="sizeHint" stdset="0">
          <size>
-          <width>30</width>
+          <width>35</width>
           <height>0</height>
          </size>
         </property>
index f01a072d42d024e3933f0d6ba7afa037ba1934b8..c47afb1a460c74d8782e7216f5fe3e458b80fd3b 100644 (file)
@@ -1964,6 +1964,13 @@ bool EntityGUI_SketcherDlg::isValid( QString& msg )
 //=================================================================================
 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
 {
+  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+  int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
+  int DigNum = qAbs(aPrecision);                   // options for the format of numbers in  myNewCommand
+  char Format = 'f';
+  if ( aPrecision < 0 )                            // f --> DigNum is the number of digits after the decimal point
+    Format = 'g';                                  // g --> DigNum is the maximum number of significant digits 
+    
   QString aParameters;
 
   if ( mySketchState == FIRST_POINT ) {
@@ -1988,16 +1995,25 @@ bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
     Sketcher_Profile aProfile2( Command2.toAscii() );
 
     //Error Message
-    if ( mySketchType == PT_ABS_CENTER || 
-        mySketchType == PT_REL_CENTER  ){
-      Group4Spin->label->show();
-      Group4Spin->label->setText( tr( aProfile2.ErrMsg().c_str() ) );
+    if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER  ){
+      if (aProfile2.Error() > Precision::Confusion()){
+        Group4Spin->label->show();
+        Group4Spin->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
+      }
+      else{
+        Group4Spin->label->hide();
+      } 
     }
     else 
       Group4Spin->label->hide();
     if ( mySketchType == PT_SEL_CENTER ){
-      Group2Sel->label->show();
-      Group2Sel->label->setText( tr( aProfile2.ErrMsg().c_str() ) );   
+      if (aProfile2.Error() > Precision::Confusion()){
+        Group2Sel->label->show();
+        Group2Sel->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
+      }
+      else{
+        Group2Sel->label->hide();
+      } 
     }
     else 
       Group2Sel->label->hide();
index ab1af6650d125296f5e5891349caabc8d91e6eb3..2ee69bbde9550c0dce30e5249023e6f44da94dcf 100644 (file)
@@ -1563,7 +1563,7 @@ Please, select face, shell or solid and try again</translation>
     </message>
     <message>
         <source>GEOM_SKETCHER_WARNING</source>
-        <translation>Warning : The specified End Point is not on the Arc</translation>
+        <translation>Warning: End point not on the arc, distance = </translation>
     </message>
     <message>
         <source>GEOM_SKETCHER_CENTER_X</source>
index 6645b3d5aeec5e5a01a51bc70fed2e09c5d8443a..4d1985a3a30150d40f5c568edb24a21d53a6bba6 100644 (file)
@@ -235,7 +235,7 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
     </message>
     <message>
         <source>GEOM_BUT_CLOSE_SKETCH</source>
-        <translation>Fermer le contour et valider</translation>
+        <translation>Fermer le contour</translation>
     </message>
     <message>
         <source>GEOM_BUT_END_SKETCH</source>
@@ -1543,7 +1543,7 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
     </message>
     <message>
         <source>GEOM_SKETCHER_WARNING</source>
-        <translation>Attention : Le point final choisi n'est pas sur l'arc</translation>
+        <translation>Attention : Point final distant de l'arc de : </translation>
     </message>
     <message>
         <source>GEOM_SKETCHER_CENTER_X</source>
index 2f62f13eb654e52c38461b90e14df9aed9615b3c..eeead8051d3b270504c59b096657d3760ca9a957 100644 (file)
@@ -67,7 +67,6 @@ Sketcher_Profile::Sketcher_Profile()
 //=======================================================================
 Sketcher_Profile::Sketcher_Profile(const char* aCmd)
 {
-  myErrMsg = "";
   enum {line, circle, point, none} move;
 
   Standard_Integer i = 1;
@@ -91,6 +90,7 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd)
   Handle(Geom_Surface) Surface;
 
   myOK = Standard_False;
+  myError = 0;
 
   //TCollection_AsciiString aCommand(CORBA::string_dup(aCmd));
   TCollection_AsciiString aCommand ((char*)aCmd);
@@ -252,106 +252,104 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd)
       case 'A':                                // TAngential arc by end point   
         { 
           if (n1 != 3) goto badargs;
-         Standard_Real vx = a(1).RealValue();
+          Standard_Real vx = a(1).RealValue();
           Standard_Real vy = a(2).RealValue(); 
-         if (a(0) == "AA") {
+          if (a(0) == "AA") {
             vx -= x;
             vy -= y;
           }
-         Standard_Real det = dx * vy - dy * vx;
-         if ( Abs(det) > Precision::Confusion()) {
-           Standard_Real c = (dx * vx + dy * vy)                                            
-                             / Sqrt((dx * dx + dy * dy) * (vx * vx + vy * vy));                 // Cosine of alpha = arc of angle / 2 , alpha in [0,Pi]
+          Standard_Real det = dx * vy - dy * vx;
+          if ( Abs(det) > Precision::Confusion()) {
+            Standard_Real c = (dx * vx + dy * vy)                                            
+                              / Sqrt((dx * dx + dy * dy) * (vx * vx + vy * vy));                 // Cosine of alpha = arc of angle / 2 , alpha in [0,Pi]
             radius = (vx * vx + vy * vy)* Sqrt(dx * dx + dy * dy)                                // radius = distance between start and end point / 2 * sin(alpha)  
-                    / (2.0 * det);                                                              // radius is > 0 or < 0
-           if (Abs(radius) > Precision::Confusion()) {
-             angle = 2.0 * acos(c);                                                             // angle in [0,2Pi]  
-             move = circle;
+                     / (2.0 * det);                                                                 // radius is > 0 or < 0
+            if (Abs(radius) > Precision::Confusion()) {
+              angle = 2.0 * acos(c);                                                            // angle in [0,2Pi]  
+              move = circle;
             }
-           else
-             move = none;
-           break;
+            else
+              move = none;
+            break;
           } 
           else
             move = none;
           break;
-        }       
+        } 
       case 'U':                                // Arc by end point and radiUs
         { 
-         if (n1 != 5) goto badargs;
-         Standard_Real vx = a(1).RealValue();
+          if (n1 != 5) goto badargs;
+          Standard_Real vx = a(1).RealValue();
           Standard_Real vy = a(2).RealValue();
-         radius  = a(3).RealValue();
-         reversed = a(4).IntegerValue();
-         if (a(0) == "UU") {                 // Absolute
+          radius  = a(3).RealValue();
+          reversed = a(4).IntegerValue();
+          if (a(0) == "UU") {                 // Absolute
             vx -= x;
             vy -= y;
           }
-         Standard_Real length = Sqrt(vx * vx + vy * vy);
-         if ( (4.0 - (vx * vx + vy * vy) / (radius * radius) >= 0.0 ) && (length > Precision::Confusion()) ) {
-           Standard_Real c = 0.5 * Sqrt(4.0 - (vx * vx + vy * vy) / (radius * radius));        // Cosine of alpha = arc angle / 2 , alpha in [0,Pi/2]
-           angle = 2.0 * acos(c);                                                              // angle in [0,Pi]
-           if ( reversed == 2 )
-             angle = angle - 2 * PI; 
-           dx =    0.5 * (  vy * 1.0/radius 
-                          + vx * Sqrt(4.0  / (vx * vx + vy * vy) - 1.0 / (radius * radius)));    
+          Standard_Real length = Sqrt(vx * vx + vy * vy);
+          if ( (4.0 - (vx * vx + vy * vy) / (radius * radius) >= 0.0 ) && (length > Precision::Confusion()) ) {
+            Standard_Real c = 0.5 * Sqrt(4.0 - (vx * vx + vy * vy) / (radius * radius));        // Cosine of alpha = arc angle / 2 , alpha in [0,Pi/2]
+            angle = 2.0 * acos(c);                                                                 // angle in [0,Pi]
+            if ( reversed == 2 )
+              angle = angle - 2 * PI; 
+            dx =    0.5 * (  vy * 1.0/radius 
+                           + vx * Sqrt(4.0  / (vx * vx + vy * vy) - 1.0 / (radius * radius)));    
             dy = -  0.5 * (  vx * 1.0/radius 
-                          - vy * Sqrt(4.0  / (vx * vx + vy * vy) - 1.0 / (radius * radius)));    
-           move = circle;
+                           - vy * Sqrt(4.0  / (vx * vx + vy * vy) - 1.0 / (radius * radius)));    
+            move = circle;
           }
-         else{
-           move = none;
-         }
-         break;
+          else{
+            move = none;
+          }
+          break;
         }       
       case 'E':                                // Arc by end point and cEnter
         { 
-         myErrMsg = "";
-         if (n1 != 7) goto badargs;
-         Standard_Real vx = a(1).RealValue();
+          if (n1 != 7) goto badargs;
+          Standard_Real vx = a(1).RealValue();
           Standard_Real vy = a(2).RealValue();
-         Standard_Real vxc  = a(3).RealValue();
-         Standard_Real vyc  = a(4).RealValue();
-         reversed = a(5).IntegerValue();
-         control_Tolerance = a(6).IntegerValue();
+          Standard_Real vxc  = a(3).RealValue();
+          Standard_Real vyc  = a(4).RealValue();
+          reversed = a(5).IntegerValue();
+          control_Tolerance = a(6).IntegerValue();
 
-         if (a(0) == "EE") {                 // Absolute
+          if (a(0) == "EE") {                 // Absolute
             vx -= x;
             vy -= y;
-           vxc -= x;
-           vyc -= y; 
+            vxc -= x;
+            vyc -= y; 
+          }
+          radius = Sqrt( vxc * vxc + vyc * vyc );
+          Standard_Real det = vx * vyc - vy * vxc;
+          Standard_Real length = Sqrt(vx * vx + vy * vy);
+          Standard_Real length2 = Sqrt((vx-vxc) * (vx-vxc) + (vy-vyc) * (vy-vyc));
+          Standard_Real length3 = Sqrt(vxc * vxc + vyc * vyc);
+          Standard_Real error = Abs(length2 - radius);
+          myError = error;
+          if ( error > Precision::Confusion() ){
+            MESSAGE("Warning : The specified end point is not on the Arc, distance = "<<error);
+          }
+          if ( error > Precision::Confusion() && control_Tolerance == 1)                      // Don't create the arc if the end point 
+            move = none;                                                                      // is too far from it
+          else if ( (length > Precision::Confusion()) && 
+                    (length2 > Precision::Confusion()) && 
+                    (length3 > Precision::Confusion()) ) {
+            Standard_Real c = ( radius * radius - (vx * vxc + vy * vyc) ) 
+                            / ( radius * Sqrt((vx-vxc) * (vx-vxc) + (vy-vyc) * (vy-vyc)) ) ;  // Cosine of arc angle 
+            angle = acos(c);                                                                  // angle in [0,Pi] 
+            if ( reversed == 2 )
+              angle = angle - 2 * PI;
+            if (det < 0)
+              angle = -angle; 
+            dx =  vyc / radius;
+            dy = -vxc / radius; 
+            move = circle;
           }
-         radius = Sqrt( vxc * vxc + vyc * vyc );
-         Standard_Real det = vx * vyc - vy * vxc;
-         Standard_Real length = Sqrt(vx * vx + vy * vy);
-         Standard_Real length2 = Sqrt((vx-vxc) * (vx-vxc) + (vy-vyc) * (vy-vyc));
-         Standard_Real length3 = Sqrt(vxc * vxc + vyc * vyc);
-         Standard_Real error = Abs(length2 - radius);
-         if ( error > Precision::Confusion() ){
-           MESSAGE("Warning : The specified end point is not on the Arc, distance = "<<error);
-           myErrMsg = "GEOM_SKETCHER_WARNING";//"Warning : The specified End Point is not on the Arc";
-         }
-          if ( error > Precision::Confusion() &&                                                // Don't create the arc if the end point 
-              control_Tolerance == 1)                                                          // is too far from it
-           move = none;
-         else if ( (length > Precision::Confusion()) && 
-                   (length2 > Precision::Confusion()) && 
-                   (length3 > Precision::Confusion()) ) {
-           Standard_Real c = ( radius * radius - (vx * vxc + vy * vyc) ) 
-                             / ( radius * Sqrt((vx-vxc) * (vx-vxc) + (vy-vyc) * (vy-vyc)) ) ;  // Cosine of arc angle 
-           angle = acos(c);                                                                    // angle in [0,Pi] 
-           if ( reversed == 2 )
-             angle = angle - 2 * PI;
-           if (det < 0)
-             angle = -angle; 
-           dx =  vyc / radius;
-           dy = -vxc / radius; 
-           move = circle;
-         }
-         else {
-           move = none;
-         }
-         break;
+          else {
+            move = none;
+          }
+          break;
         }      
       case 'I':
         {
index e68e2ebfed2f4e04c791fdea3c929912d7c51f4f..97c41c54a2ac8f0756328dcfbdd40823e81c1462 100644 (file)
@@ -45,6 +45,7 @@ private:
   TopoDS_Shape myShape;
   bool myOK;
   std::string myErrMsg;
+  double myError;
 
 public:
   Standard_EXPORT gp_Pnt GetLastPoint(){return myLastPoint;};
@@ -53,5 +54,6 @@ public:
   Standard_EXPORT const TopoDS_Shape& GetShape(){return myShape;};
   Standard_EXPORT bool IsDone(){return myOK;};
   Standard_EXPORT std::string ErrMsg(){return myErrMsg;};
+  Standard_EXPORT double Error(){return myError;};
 
 };