mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-28 10:20:34 +05:00
PAL11054 - crash if user enters "-8" as density function with exponent conversion
PAL11055 - it is impossible to enter negative function value in case, when exponent conversion is applied some remarks from PAL8238
This commit is contained in:
parent
584d5262ff
commit
f1dec40ab1
@ -19,8 +19,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 +28,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 +201,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 +218,33 @@ 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();
|
||||
|
||||
OSD::SetSignal( true );
|
||||
CASCatch_CatchSignals aCatchSignals;
|
||||
aCatchSignals.Activate();
|
||||
|
||||
CASCatch_TRY
|
||||
{
|
||||
replot();
|
||||
}
|
||||
CASCatch_CATCH(CASCatch_Failure)
|
||||
{
|
||||
aCatchSignals.Deactivate();
|
||||
Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught();
|
||||
}
|
||||
aCatchSignals.Deactivate();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ private:
|
||||
bool myIsTable;
|
||||
Conversion myConv;
|
||||
SMESH::double_array myTableFunc;
|
||||
long myCurve1, myCurve2, myMsg;
|
||||
long myDensity, myDistr, myMsg;
|
||||
Handle(ExprIntrp_GenExp) myExpr;
|
||||
Expr_Array1OfNamedUnknown myVars;
|
||||
TColStd_Array1OfReal myValues;
|
||||
|
@ -26,9 +26,10 @@
|
||||
// $Header$
|
||||
|
||||
#include "StdMeshersGUI_DistrTable.h"
|
||||
#include <QtxDblValidator.h>
|
||||
|
||||
#include <qlayout.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qvalidator.h>
|
||||
#include <qlineedit.h>
|
||||
|
||||
//=================================================================================
|
||||
@ -40,8 +41,8 @@ StdMeshersGUI_DistrTable::StdMeshersGUI_DistrTable( const int rows, QWidget* par
|
||||
{
|
||||
horizontalHeader()->setLabel( 0, "t" );
|
||||
horizontalHeader()->setLabel( 1, "f(t)" );
|
||||
myArgV = new QDoubleValidator( 0.0, 1.0, 3, this );
|
||||
myFuncV = new QDoubleValidator( 0.0, 1E10, 3, this );
|
||||
myArgV = new QtxDblValidator( 0.0, 1.0, 3, this );
|
||||
myFuncV = new QtxDblValidator( 0.0, 1E20, 3, this );
|
||||
}
|
||||
|
||||
StdMeshersGUI_DistrTable::~StdMeshersGUI_DistrTable()
|
||||
@ -265,8 +266,24 @@ void StdMeshersGUI_DistrTable::setData( const SMESH::double_array& d )
|
||||
{
|
||||
stopEditing( false );
|
||||
setNumRows( d.length()/2 );
|
||||
QString val;
|
||||
for( int i=0; i<d.length(); i++ )
|
||||
setText( i/2, i%2, QString( "%1" ).arg( d[i] ) );
|
||||
{
|
||||
QtxDblValidator* v = i%2==0 ? myArgV : myFuncV;
|
||||
val = QString::number( d[i] );
|
||||
v->fixup( val );
|
||||
setText( i/2, i%2, val );
|
||||
}
|
||||
}
|
||||
|
||||
QtxDblValidator* StdMeshersGUI_DistrTable::argValidator() const
|
||||
{
|
||||
return myArgV;
|
||||
}
|
||||
|
||||
QtxDblValidator* StdMeshersGUI_DistrTable::funcValidator() const
|
||||
{
|
||||
return myFuncV;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
@ -346,3 +363,4 @@ void StdMeshersGUI_DistrTableFrame::onButtonClicked()
|
||||
else if( sender()==button( REMOVE_ROW ) )
|
||||
emit toEdit( REMOVE_ROW, table()->currentRow() );
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include CORBA_SERVER_HEADER(SMESH_Mesh)
|
||||
|
||||
class QButton;
|
||||
class QDoubleValidator;
|
||||
class QtxDblValidator;
|
||||
|
||||
/*!
|
||||
* \brief Values corresponding to buttons for table resize
|
||||
@ -65,6 +65,9 @@ public:
|
||||
void data( SMESH::double_array& );
|
||||
void setData( const SMESH::double_array& );
|
||||
|
||||
QtxDblValidator* argValidator() const;
|
||||
QtxDblValidator* funcValidator() const;
|
||||
|
||||
protected:
|
||||
virtual QWidget* createEditor( int, int, bool ) const;
|
||||
virtual bool eventFilter( QObject*, QEvent* );
|
||||
@ -75,7 +78,7 @@ private slots:
|
||||
void onEdit( TableButton, int );
|
||||
|
||||
private:
|
||||
QDoubleValidator *myArgV, *myFuncV;
|
||||
QtxDblValidator *myArgV, *myFuncV;
|
||||
};
|
||||
|
||||
|
||||
@ -122,6 +125,5 @@ private:
|
||||
StdMeshersGUI_DistrTable *myTable;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include <QtxIntSpinBox.h>
|
||||
#include <QtxComboBox.h>
|
||||
#include <QtxDblValidator.h>
|
||||
#include <SMESHGUI_SpinBox.h>
|
||||
|
||||
#include <qlabel.h>
|
||||
@ -142,7 +143,7 @@ QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame()
|
||||
myConv->setColumnLayout( 0, Qt::Vertical );
|
||||
QGridLayout* convLay = new QGridLayout( myConv->layout() );
|
||||
convLay->addWidget( new QRadioButton( tr( "SMESH_EXP_MODE" ), myConv ), 0, 0 );
|
||||
convLay->addWidget( new QRadioButton( tr( "SMESH_CUT_NEG_MODE" ), myConv ), 1, 0 );
|
||||
convLay->addWidget( myCutNeg = new QRadioButton( tr( "SMESH_CUT_NEG_MODE" ), myConv ), 1, 0 );
|
||||
myGroupLayout->addWidget( myConv, row, 1 );
|
||||
row++;
|
||||
|
||||
@ -312,6 +313,19 @@ void StdMeshersGUI_NbSegmentsCreator::onValueChanged()
|
||||
{
|
||||
int distr = myDistr->currentItem();
|
||||
|
||||
/* if( distr==2 ) //table func
|
||||
myCutNeg->setText( tr( "SMESH_NO_CONV" ) );
|
||||
else if( distr==3 )
|
||||
myCutNeg->setText( tr( "SMESH_CUT_NEG_MODE" ) );*/
|
||||
|
||||
if( distr==2 ) //table func
|
||||
{
|
||||
myTable->table()->funcValidator()->setBottom( myConv->id( myConv->selected() )==0 ? -1E20 : 0 );
|
||||
SMESH::double_array arr;
|
||||
myTable->table()->data( arr );
|
||||
myTable->table()->setData( arr ); //update data in table
|
||||
}
|
||||
|
||||
myScale->setShown( distr==1 );
|
||||
myLScale->setShown( distr==1 );
|
||||
|
||||
|
@ -15,6 +15,7 @@ class StdMeshersGUI_DistrPreview;
|
||||
class QLineEdit;
|
||||
class QButtonGroup;
|
||||
class QGridLayout;
|
||||
class QRadioButton;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -59,6 +60,7 @@ private:
|
||||
QLabel *myLScale, *myLTable, *myLExpr, *myLConv, *myInfo;
|
||||
QGridLayout* myGroupLayout;
|
||||
int myTableRow, myPreviewRow;
|
||||
QRadioButton* myCutNeg;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -47,6 +47,12 @@ msgstr "Distribution with analitic density"
|
||||
msgid "SMESH_NB_SEGMENTS_SCALE_PARAM"
|
||||
msgstr "Scale Factor"
|
||||
|
||||
msgid "SMESH_DENSITY_FUNC"
|
||||
msgstr "Density function"
|
||||
|
||||
msgid "SMESH_DISTR"
|
||||
msgstr "Distribution"
|
||||
|
||||
msgid "SMESH_TAB_FUNC"
|
||||
msgstr "Table function"
|
||||
|
||||
@ -65,6 +71,9 @@ msgstr "Exponent"
|
||||
msgid "SMESH_CUT_NEG_MODE"
|
||||
msgstr "Cut negative"
|
||||
|
||||
msgid "SMESH_NO_CONV"
|
||||
msgstr "No conversion"
|
||||
|
||||
msgid "SMESH_INSERT_ROW"
|
||||
msgstr "Insert row"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user