#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 ),
{
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 ) );
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()
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 )
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();
}
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() )
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;
}
bool StdMeshersGUI_DistrPreview::convert( double& v ) const
{
- CASCatch_CatchSignals aCatchSignals;
- aCatchSignals.Activate();
-
bool ok = true;
switch( myConv )
{
{
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;
}
v = 0;
break;
}
- aCatchSignals.Deactivate();
+
return ok;
}