// 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::warning(this, tr("WARNING"), tr("WRN_XLOG_NOT_ALLOWED"));
- return;
+ if ( mode && !isXLogEnabled() ) {
+ int answer = SUIT_MessageBox::question( this, tr( "TITLE_LOG_NOT_ALLOWED" ),
+ tr( "QUESTION_XLOG_NOT_ALLOWED" ),
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No );
+ if( answer == SUIT_MessageBox::No )
+ return;
+
+ doXLogEnabled();
}
myXMode = mode;
// 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::warning(this, tr("WARNING"), tr("WRN_YLOG_NOT_ALLOWED"));
+ int answer = SUIT_MessageBox::question( this, tr( "TITLE_LOG_NOT_ALLOWED" ),
+ tr( "QUESTION_YLOG_NOT_ALLOWED" ),
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No );
+ if( answer == SUIT_MessageBox::No )
+ return;
+
+ doYLogEnabled();
return;
}
return allPositive;
}
+/*!
+ Remove all non-positive abscissa values
+*/
+void Plot2d_ViewFrame::doXLogEnabled()
+{
+ doLogEnabled( true );
+}
+
/*!
Precaution for logarithmic Y scale
*/
return allPositive;
}
+/*!
+ Remove all non-positive ordinate values
+*/
+void Plot2d_ViewFrame::doYLogEnabled()
+{
+ doLogEnabled( false );
+}
+
+/*!
+ Remove all non-positive abscissa or ordinate values
+*/
+void Plot2d_ViewFrame::doLogEnabled( const bool theIsAbscissa )
+{
+ CurveDict::ConstIterator it = myPlot->getCurves().begin();
+ for ( ; it != myPlot->getCurves().end(); it++ )
+ {
+ Plot2d_CurvePtr aCurve = it.value();
+ pointList aPointList = aCurve->getPointList();
+
+ bool isHasNegative = false;
+ pointList::iterator aPointIt = aPointList.begin();
+ for ( ; aPointIt != aPointList.end(); )
+ {
+ if( ( theIsAbscissa ? aPointIt->x : aPointIt->y ) > 0 )
+ {
+ aPointIt++;
+ continue;
+ }
+
+ aPointIt = aPointList.erase( aPointIt );
+ isHasNegative = true;
+ }
+
+ if( !isHasNegative )
+ continue;
+
+ aCurve->setPointList( aPointList );
+ updateCurve( aCurve, false );
+ }
+
+ myPlot->replot();
+}
+
class Plot2d_QwtPlotZoomer : public QwtPlotZoomer
{
public:
// it crashes if switched to X/Y logarithmic mode, when one or more points have
// non-positive X/Y coordinate
bool isXLogEnabled() const;
+ void doXLogEnabled();
+
bool isYLogEnabled() const;
+ void doYLogEnabled();
virtual bool print( const QString& file = QString::null,
const QString& format = QString::null ) const;
QwtPlotCurve* getPlotCurve( Plot2d_Curve* curve );
bool hasPlotCurve( Plot2d_Curve* curve );
void setCurveType( QwtPlotCurve* curve, int curveType );
+ void doLogEnabled( const bool theIsAbscissa );
public slots:
void onViewPan();
<translation>Background color:</translation>
</message>
<message>
- <source>WRN_XLOG_NOT_ALLOWED</source>
+ <source>TITLE_LOG_NOT_ALLOWED</source>
+ <translation>Logarithmic scaling not allowed</translation>
+ </message>
+ <message>
+ <source>QUESTION_XLOG_NOT_ALLOWED</source>
<translation>Some points with non-positive abscissa values have been detected.
-Logarithmic scale for abscissa axis is not allowed.</translation>
+It is necessary to remove these points before Logarithmic scaling
+will be allowed. Some information will be lost.
+Are you sure you want to continue?</translation>
</message>
<message>
- <source>WRN_YLOG_NOT_ALLOWED</source>
+ <source>QUESTION_YLOG_NOT_ALLOWED</source>
<translation>Some points with non-positive ordinate values have been detected.
-Logarithmic scale for ordinate axis is not allowed.</translation>
+It is necessary to remove these points before Logarithmic scaling
+will be allowed. Some information will be lost.
+Are you sure you want to continue?</translation>
</message>
<message>
<source>DSC_FITRECT</source>