X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FStdMeshersGUI%2FStdMeshersGUI_DistrPreview.cxx;h=fc3787b9e5ced9b857475817e641d1e99d7d3348;hp=460dfb4d54e2848f7162a789e53e2e4317abfeeb;hb=3f36c66f5af4129d370f7b2b289954ca0314f301;hpb=85b1cfc1f07d0b93d88803c6c0ccadf8f3349719 diff --git a/src/StdMeshersGUI/StdMeshersGUI_DistrPreview.cxx b/src/StdMeshersGUI/StdMeshersGUI_DistrPreview.cxx index 460dfb4d5..fc3787b9e 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_DistrPreview.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_DistrPreview.cxx @@ -17,9 +17,21 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// File : StdMeshersGUI_DistrPreview.cxx +// Author : Open CASCADE S.A.S. +// +// SMESH includes #include "StdMeshersGUI_DistrPreview.h" +// Qwt includes +#include +#include +#include +#include +#include + +// OCCT includes #include #include @@ -45,25 +57,44 @@ StdMeshersGUI_DistrPreview::StdMeshersGUI_DistrPreview( QWidget* p, StdMeshers:: { myHypo = StdMeshers::StdMeshers_NumberOfSegments::_duplicate( h ); myVars.ChangeValue( 1 ) = new Expr_NamedUnknown( "t" ); - myDensity = insertCurve( QString() ); - myDistr = insertCurve( QString() ); - myMsg = insertMarker( new QwtPlotMarker( this ) ); - setMarkerPos( myMsg, 0.5, 0.5 ); - setMarkerLabelPen( myMsg, QPen( Qt::red, 1 ) ); - QFont f = markerFont( myMsg ); - f.setPointSize( 14 ); - f.setBold( true ); - setMarkerFont( myMsg, f ); - setCurvePen( myDensity, QPen( Qt::red, 1 ) ); + myDensity = new QwtPlotCurve( QString() ); + myDensity->attach( this ); + myDistr = new QwtPlotCurve( QString() ); + myDistr->attach( this ); + myMsg = new QwtPlotMarker(); + myMsg->attach( this ); + myMsg->setValue( 0.5, 0.5 ); + QwtText mt = myMsg->label(); + mt.setBackgroundPen( QPen( Qt::red, 1 ) ); + QFont f = mt.font(); + f.setPointSize( 14 ); f.setBold( true ); + mt.setFont( f ); + myMsg->setLabel( mt ); + myDensity->setPen( QPen( Qt::red, 1 ) ); QColor dc = Qt::blue; - 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" ) ); + myDistr->setPen( QPen( dc, 1 ) ); + myDistr->setSymbol( QwtSymbol( QwtSymbol::XCross, QBrush( dc ), QPen( dc ), QSize( 5, 5 ) ) ); + + QwtLegend* l = legend(); + if ( !l ) { + l = new QwtLegend( this ); + l->setFrameStyle( QFrame::Box | QFrame::Sunken ); + } + insertLegend( l, QwtPlot::BottomLegend ); + + myDensity->setTitle( tr( "SMESH_DENSITY_FUNC" ) ); + myDistr->setTitle( tr( "SMESH_DISTR" ) ); + + QwtPlotGrid* aGrid = new QwtPlotGrid(); + QPen aMajPen = aGrid->majPen(); + aMajPen.setStyle( Qt::DashLine ); + aGrid->setPen( aMajPen ); + + aGrid->enableX( true ); + aGrid->enableY( true ); + + aGrid->attach( this ); } StdMeshersGUI_DistrPreview::~StdMeshersGUI_DistrPreview() @@ -184,7 +215,7 @@ void StdMeshersGUI_DistrPreview::update() if( isTableFunc() ) arr = h->BuildDistributionTab( myTableFunc, myNbSeg, ( int )myConv ); else - arr = h->BuildDistributionExpr( myFunction.latin1(), myNbSeg, ( int )myConv ); + arr = h->BuildDistributionExpr( myFunction.toLatin1().data(), myNbSeg, ( int )myConv ); if( arr ) { distr = *arr; @@ -200,7 +231,11 @@ void StdMeshersGUI_DistrPreview::update() return; } else - setMarkerLabel( myMsg, QString() ); + { + QwtText mt = myMsg->label(); + mt.setText( QString() ); + myMsg->setLabel( mt ); + } int size = graph.length()/2; double* x = new double[size], *y = new double[size]; @@ -227,9 +262,9 @@ void StdMeshersGUI_DistrPreview::update() max_x = x[i]; } - 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 ); + setAxisScale( myDensity->xAxis(), min_x, max_x ); + setAxisScale( myDensity->yAxis(), std::min( 0.0, min_y ), std::max( 0.0, max_y ) ); + myDensity->setData( x, y, size ); if( x ) delete[] x; if( y ) @@ -244,7 +279,7 @@ void StdMeshersGUI_DistrPreview::update() x[i] = distr[i]; y[i] = 0; } - setCurveData( myDistr, x, y, size ); + myDistr->setData( x, y, size ); delete[] x; delete[] y; x = y = 0; @@ -261,11 +296,13 @@ void StdMeshersGUI_DistrPreview::update() void StdMeshersGUI_DistrPreview::showError() { - 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" ) ); + setAxisScale( myDensity->xAxis(), 0.0, 1.0 ); + setAxisScale( myDensity->yAxis(), 0.0, 1.0 ); + myDensity->setData( 0, 0, 0 ); + myDistr->setData( 0, 0, 0 ); + QwtText mt = myMsg->label(); + mt.setText( tr( "SMESH_INVALID_FUNCTION" ) ); + myMsg->setLabel( mt ); replot(); } @@ -299,7 +336,7 @@ bool StdMeshersGUI_DistrPreview::init( const QString& str ) OCC_CATCH_SIGNALS; #endif myExpr = ExprIntrp_GenExp::Create(); - myExpr->Process( ( Standard_CString ) str.latin1() ); + myExpr->Process( ( Standard_CString ) str.toLatin1().data() ); } catch(Standard_Failure) { Handle(Standard_Failure) aFail = Standard_Failure::Caught(); parsed_ok = false;