{
if ( !curve )
return;
+ // san -- Protection against QwtCurve bug in Qwt 0.4.x:
+ // it crashes if switched to X/Y logarithmic mode, when one or more points have
+ // non-positive X/Y coordinate
+ if ( myXMode && curve->getMinX() <= 0. )
+ setHorScaleMode( 0, false );
+ if ( myYMode && curve->getMinY() <= 0. )
+ setVerScaleMode( 0, false );
+
+
if ( hasCurve( curve ) ) {
updateCurve( curve, update );
}
bool xMinorEnabled, const int xMinorMax,
bool update )
{
- if( xMinorMax>=xMajorMax )
- return;
-
myXGridMajorEnabled = xMajorEnabled;
myXGridMinorEnabled = xMinorEnabled;
myXGridMaxMajor = xMajorMax;
*/
void Plot2d_ViewFrame::setHorScaleMode( const int mode, bool update )
{
+ // san -- Protection against QwtCurve bug in Qwt 0.4.x:
+ // it crashes if switched to X/Y logarithmic mode, when one or more points have
+ // non-positive X/Y coordinate
+ if ( mode && !isXLogEnabled() ){
+ SUIT_MessageBox::warn1(this, tr("WARNING"), tr("WRN_XLOG_NOT_ALLOWED"), tr("BUT_OK"));
+ return;
+ }
+
myXMode = mode;
if ( myXMode == 0 ) // linear
myPlot->changeAxisOptions( QwtPlot::xBottom, QwtAutoScale::Logarithmic, false );
*/
void Plot2d_ViewFrame::setVerScaleMode( const int mode, bool update )
{
+ // san -- Protection against QwtCurve bug in Qwt 0.4.x:
+ // it crashes if switched to X/Y logarithmic mode, when one or more points have
+ // non-positive X/Y coordinate
+ if ( mode && !isYLogEnabled() ){
+ SUIT_MessageBox::warn1(this, tr("WARNING"), tr("WRN_YLOG_NOT_ALLOWED"), tr("BUT_OK"));
+ return;
+ }
+
myYMode = mode;
if ( myYMode == 0 ) { // linear
myPlot->changeAxisOptions( QwtPlot::yLeft, QwtAutoScale::Logarithmic, false );
qApp->installEventFilter( this );
}
+/*!
+ Precaution for logarithmic X scale
+*/
+bool Plot2d_ViewFrame::isXLogEnabled() const
+{
+ bool allPositive = true;
+ QIntDictIterator<Plot2d_Curve> it( myCurves );
+ for ( ; allPositive && it.current(); ++it ) {
+ allPositive = ( it.current()->getMinX() > 0. );
+ }
+ return allPositive;
+}
+
+/*!
+ Precaution for logarithmic Y scale
+*/
+bool Plot2d_ViewFrame::isYLogEnabled() const
+{
+ bool allPositive = true;
+ QIntDictIterator<Plot2d_Curve> it( myCurves );
+ for ( ; allPositive && it.current(); ++it ) {
+ allPositive = ( it.current()->getMinY() > 0. );
+ }
+ return allPositive;
+}
+
//=================================================================================
// Plot2d_Plot2d implementation
//=================================================================================