myXGridMinorEnabled( false ), myYGridMinorEnabled( false ), myY2GridMinorEnabled( false ),
myXGridMaxMajor( 8 ), myYGridMaxMajor( 8 ), myY2GridMaxMajor( 8 ),
myXGridMaxMinor( 5 ), myYGridMaxMinor( 5 ), myY2GridMaxMinor( 5 ),
- myXMode( 0 ), myYMode( 0 ), mySecondY( false )
+ myXMode( 0 ), myYMode( 0 ), mySecondY( false ),
+ myViewIsClosing(false)
{
setObjectName( title );
/* Plot 2d View */
QMouseEvent m( QEvent::MouseButtonRelease, me->pos(), me->button(),
me->buttons(), me->modifiers() );
plotMouseReleased( m );
+ // YOB (le 22/09/10) : prevents from crash if the window has been closed
+ if(myViewIsClosing)
+ return true;
}
break;
}
}
myPlot->replot();
if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase();
+ emit fitAllDone();
}
/*!
QContextMenuEvent aEvent( QContextMenuEvent::Mouse,
me.pos(), me.globalPos() );
emit contextMenuRequested( &aEvent );
+ // YOB (le 22/09/10) : prevents from crash if the window has been closed
+ if(myViewIsClosing)
+ return;
}
myPlot->canvas()->setCursor( QCursor( Qt::CrossCursor ) );
myPlot->defaultPicker();
: QwtPlot( parent ),
myIsPolished( false )
{
- // Create alternative scales
- setAxisScaleDraw( QwtPlot::yLeft, new Plot2d_ScaleDraw() );
- setAxisScaleDraw( QwtPlot::xBottom, new Plot2d_ScaleDraw() );
- setAxisScaleDraw( QwtPlot::yRight, new Plot2d_ScaleDraw() );
myPlotZoomer = new Plot2d_QwtPlotZoomer( QwtPlot::xBottom, QwtPlot::yLeft, canvas() );
myPlotZoomer->setSelectionFlags( QwtPicker::DragSelection | QwtPicker::CornerToCorner );
defaultPicker();
+ // Create alternative scales
+ setAxisScaleDraw( QwtPlot::yLeft, new Plot2d_ScaleDraw() );
+ setAxisScaleDraw( QwtPlot::xBottom, new Plot2d_ScaleDraw() );
+ setAxisScaleDraw( QwtPlot::yRight, new Plot2d_ScaleDraw() );
+
// auto scaling by default
setAxisAutoScale( QwtPlot::yLeft );
setAxisAutoScale( QwtPlot::yRight );
{
CurveDict::iterator it = getCurves().begin();
QwtPlotCurve* aCurve;
- for ( ; it != getCurves().end(); it++ ) {
+
+ CurveDict::iterator closest;
+ double currentDistance;
+ int currentIndex;
+ index = -1;
+ for ( ; it != getCurves().end() ; it++ ) {
aCurve = it.key();
if ( !aCurve )
continue;
- index = aCurve->closestPoint( p, &distance );
- if ( index > -1 )
- return it.value();
+ currentIndex = aCurve->closestPoint( p, ¤tDistance );
+ if ( currentIndex > -1 ){
+ if ( it == getCurves().begin() ) { //init
+ distance = currentDistance;
+ closest = it;
+ index = currentIndex;
+ } else if ( currentDistance < distance ) {
+ distance = currentDistance;
+ closest = it;
+ index = currentIndex;
+ }
+ }
}
- return 0;
+ if ( index > -1 )
+ return closest.value();
+ else
+ return 0;
}
/*!