]> SALOME platform Git repositories - modules/smesh.git/blobdiff - src/StdMeshersGUI/StdMeshersGUI_DistrPreview.cxx
Salome HOME
Join modifications from branch OCC_development_for_3_2_0a2
[modules/smesh.git] / src / StdMeshersGUI / StdMeshersGUI_DistrPreview.cxx
index f763fbd9c27b032f4e0099c6eb16da0a9bddd268..e58be313b07e36bafe76793c031bc1e4c1465789 100644 (file)
@@ -1,11 +1,9 @@
 
 #include "StdMeshersGUI_DistrPreview.h"
+#include "CASCatch.hxx"
+
 #include <Expr_NamedUnknown.hxx>
 #include <Expr_GeneralExpression.hxx>
-#include <CASCatch_CatchSignals.hxx>
-#include <CASCatch_Failure.hxx> 
-#include <CASCatch_ErrorHandler.hxx>
-#include <OSD.hxx>
 
 StdMeshersGUI_DistrPreview::StdMeshersGUI_DistrPreview( QWidget* p, StdMeshers::StdMeshers_NumberOfSegments_ptr h )
 : QwtPlot( p ),
@@ -19,8 +17,8 @@ StdMeshersGUI_DistrPreview::StdMeshersGUI_DistrPreview( QWidget* p, StdMeshers::
 {
   myHypo = StdMeshers::StdMeshers_NumberOfSegments::_duplicate( h );
   myVars.ChangeValue( 1 ) = new Expr_NamedUnknown( "t" );
-  myCurve1 = insertCurve( QString() );
-  myCurve2 = insertCurve( QString() );
+  myDensity = insertCurve( QString() );
+  myDistr = insertCurve( QString() );
   myMsg = insertMarker( new QwtPlotMarker( this ) );
   setMarkerPos( myMsg, 0.5, 0.5 );
   setMarkerLabelPen( myMsg, QPen( Qt::red, 1 ) );
@@ -28,11 +26,16 @@ StdMeshersGUI_DistrPreview::StdMeshersGUI_DistrPreview( QWidget* p, StdMeshers::
   f.setPointSize( 14 );
   f.setBold( true );
   setMarkerFont( myMsg, f );
-  setCurvePen( myCurve1, QPen( Qt::red, 1 ) );
+  setCurvePen( myDensity, QPen( Qt::red, 1 ) );
 
   QColor dc = Qt::blue;
-  setCurvePen( myCurve2, QPen( dc, 1 ) );
-  setCurveSymbol( myCurve2, QwtSymbol( QwtSymbol::XCross, QBrush( dc ), QPen( dc ), QSize( 5, 5 ) ) );
+  setCurvePen( myDistr, QPen( dc, 1 ) );
+  setCurveSymbol( myDistr, QwtSymbol( QwtSymbol::XCross, QBrush( dc ), QPen( dc ), QSize( 5, 5 ) ) );
+  setAutoLegend( true );
+  enableLegend( true );
+  setLegendPos( Qwt::Bottom );
+  setCurveTitle( myDensity, tr( "SMESH_DENSITY_FUNC" ) );
+  setCurveTitle( myDistr, tr( "SMESH_DISTR" ) );
 }
 
 StdMeshersGUI_DistrPreview::~StdMeshersGUI_DistrPreview()
@@ -196,9 +199,9 @@ void StdMeshersGUI_DistrPreview::update()
       max_x = x[i];
   }
 
-  setAxisScale( curveXAxis( myCurve1 ), min_x, max_x );
-  setAxisScale( curveYAxis( myCurve1 ), min( 0.0, min_y ), max( 0.0, max_y ) );
-  setCurveData( myCurve1, x, y, size );
+  setAxisScale( curveXAxis( myDensity ), min_x, max_x );
+  setAxisScale( curveYAxis( myDensity ), min( 0.0, min_y ), max( 0.0, max_y ) );
+  setCurveData( myDensity, x, y, size );
   if( x )
     delete[] x;
   if( y )
@@ -213,19 +216,27 @@ void StdMeshersGUI_DistrPreview::update()
     x[i] = distr[i];
     y[i] = 0;
   }
-  setCurveData( myCurve2, x, y, size );
+  setCurveData( myDistr, x, y, size );
   delete[] x;
   delete[] y;
   x = y = 0;
-  replot();
+
+  CASCatch_TRY
+  {   
+    replot();
+  }
+  CASCatch_CATCH(Standard_Failure)
+  {
+    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+  }
 }
 
 void StdMeshersGUI_DistrPreview::showError()
 {
-  setAxisScale( curveXAxis( myCurve1 ), 0.0, 1.0 );
-  setAxisScale( curveYAxis( myCurve1 ), 0.0, 1.0 );
-  setCurveData( myCurve1, 0, 0, 0 );
-  setCurveData( myCurve2, 0, 0, 0 );
+  setAxisScale( curveXAxis( myDensity ), 0.0, 1.0 );
+  setAxisScale( curveYAxis( myDensity ), 0.0, 1.0 );
+  setCurveData( myDensity, 0, 0, 0 );
+  setCurveData( myDistr, 0, 0, 0 );
   setMarkerLabel( myMsg, tr( "SMESH_INVALID_FUNCTION" ) );
   replot();
 }
@@ -254,22 +265,17 @@ bool isCorrectArg( const Handle( Expr_GeneralExpression )& expr )
 
 bool StdMeshersGUI_DistrPreview::init( const QString& str )
 {
-  CASCatch_CatchSignals aCatchSignals;
-  aCatchSignals.Activate();
-
   bool parsed_ok = true;
   CASCatch_TRY
   {
     myExpr = ExprIntrp_GenExp::Create();
     myExpr->Process( ( Standard_CString ) str.latin1() );
   }
-  CASCatch_CATCH(CASCatch_Failure)
+  CASCatch_CATCH(Standard_Failure)
   {
-    aCatchSignals.Deactivate();
-    Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught();
+    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
     parsed_ok = false;
   }
-  aCatchSignals.Deactivate();
 
   bool syntax = false, args = false;
   if( parsed_ok && myExpr->IsDone() )
@@ -299,23 +305,18 @@ double StdMeshersGUI_DistrPreview::funcValue( const double t, bool& ok )
 
 double StdMeshersGUI_DistrPreview::calc( bool& ok )
 {
-  OSD::SetSignal( true );
   double res = 0.0;
 
-  CASCatch_CatchSignals aCatchSignals;
-  aCatchSignals.Activate();
-
   ok = true;
   CASCatch_TRY {   
     res = myExpr->Expression()->Evaluate( myVars, myValues );
   }
-  CASCatch_CATCH(CASCatch_Failure) {
-    aCatchSignals.Deactivate();
-    Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught();
+  CASCatch_CATCH(Standard_Failure) {
+    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
     ok = false;
     res = 0.0;
   }
-  aCatchSignals.Deactivate();
+
   return res;
 }
 
@@ -326,9 +327,6 @@ bool StdMeshersGUI_DistrPreview::isDone() const
 
 bool StdMeshersGUI_DistrPreview::convert( double& v ) const
 {
-  CASCatch_CatchSignals aCatchSignals;
-  aCatchSignals.Activate();
-
   bool ok = true;
   switch( myConv )
   {
@@ -336,12 +334,15 @@ bool StdMeshersGUI_DistrPreview::convert( double& v ) const
     {
       CASCatch_TRY
       { 
+       // in StdMeshers_NumberOfSegments.cc
+       // const double PRECISION = 1e-7;
+       //
+       if(v < -7) v = -7.0;
        v = pow( 10.0, v );
       }
-      CASCatch_CATCH(CASCatch_Failure)
+      CASCatch_CATCH(Standard_Failure)
       {
-       aCatchSignals.Deactivate();
-       Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught();
+       Handle(Standard_Failure) aFail = Standard_Failure::Caught();
        v = 0.0;
        ok = false;
       }
@@ -353,6 +354,6 @@ bool StdMeshersGUI_DistrPreview::convert( double& v ) const
       v = 0;
     break;
   }
-  aCatchSignals.Deactivate();
+
   return ok;
 }