10#include "qwt_plot_zoomer.h" 
   12#include "qwt_scale_div.h" 
   13#include "qwt_scale_map.h" 
   14#include "qwt_interval.h" 
   15#include "qwt_picker_machine.h" 
   19static QwtInterval qwtExpandedZoomInterval( 
double v1, 
double v2,
 
   25    if ( max - min < minRange )
 
   27        min = 0.5 * ( min + max - minRange );
 
   35            double minBounded = transform->
bounded( min );
 
   36            double maxBounded = transform->
bounded( max );
 
   38            if ( minBounded != min )
 
   40                maxBounded = transform->
bounded( minBounded + minRange );
 
   42            else if ( maxBounded != max )
 
   44                minBounded = transform->
bounded( maxBounded - minRange );
 
   55static QRectF qwtExpandedZoomRect( 
const QRectF& zoomRect, 
const QSizeF& minSize,
 
   60    if ( minSize.width() > r.width() )
 
   63            r.left(), r.right(), minSize.width(), transformX );
 
   69    if ( minSize.height() > r.height() )
 
   72            zoomRect.top(), zoomRect.bottom(), minSize.height(), transformY );
 
   81class QwtPlotZoomer::PrivateData
 
  134        QWidget* canvas, 
bool doReplot )
 
 
  142void QwtPlotZoomer::init( 
bool doReplot )
 
  144    m_data = 
new PrivateData;
 
  146    m_data->maxStackDepth = -1;
 
  152    if ( doReplot && 
plot() )
 
  158QwtPlotZoomer::~QwtPlotZoomer()
 
  176    m_data->maxStackDepth = depth;
 
  183            m_data->zoomStack.count() - 1 - depth; 
 
  188            for ( 
int i = m_data->zoomStack.count() - 1;
 
  189                i > int( m_data->zoomRectIndex ); i-- )
 
  191                ( void )m_data->zoomStack.pop(); 
 
 
  203    return m_data->maxStackDepth;
 
 
  214    return m_data->zoomStack;
 
 
  223    return m_data->zoomStack[0];
 
 
  244    m_data->zoomStack.clear();
 
  246    m_data->zoomRectIndex = 0;
 
 
  268    const QRectF bRect = base | sRect;
 
  270    m_data->zoomStack.clear();
 
  271    m_data->zoomStack.push( bRect );
 
  272    m_data->zoomRectIndex = 0;
 
  276        m_data->zoomStack.push( sRect );
 
  277        m_data->zoomRectIndex++;
 
 
  289    return m_data->zoomStack[m_data->zoomRectIndex];
 
 
  297    return m_data->zoomRectIndex;
 
 
  312    if ( m_data->maxStackDepth >= 0 &&
 
  313        int( m_data->zoomRectIndex ) >= m_data->maxStackDepth )
 
  318    const QRectF 
zoomRect = rect.normalized();
 
  319    if ( 
zoomRect != m_data->zoomStack[m_data->zoomRectIndex] )
 
  321        for ( uint i = m_data->zoomStack.count() - 1;
 
  322            i > m_data->zoomRectIndex; i-- )
 
  324            ( void )m_data->zoomStack.pop();
 
  328        m_data->zoomRectIndex++;
 
 
  357        newIndex = m_data->zoomRectIndex + offset;
 
  358        newIndex = qBound( 0, newIndex, m_data->zoomStack.count() - 1 );
 
  361    if ( newIndex != 
static_cast< int >( m_data->zoomRectIndex ) )
 
  363        m_data->zoomRectIndex = newIndex;
 
 
  389    if ( m_data->maxStackDepth >= 0 &&
 
  390        zoomStack.count() > m_data->maxStackDepth )
 
  395    if ( zoomRectIndex < 0 || zoomRectIndex > 
zoomStack.count() )
 
 
  422    const QRectF& rect = m_data->zoomStack[m_data->zoomRectIndex];
 
  428        double x1 = rect.left();
 
  429        double x2 = rect.right();
 
  435        double y1 = rect.top();
 
  436        double y2 = rect.bottom();
 
 
  522    const QRectF& rect = m_data->zoomStack[m_data->zoomRectIndex];
 
  523    moveTo( QPointF( rect.left() + dx, rect.top() + dy ) );
 
 
  551        m_data->zoomStack[m_data->zoomRectIndex].moveTo( x, y );
 
 
  569    if ( pa.count() < 2 )
 
  572    QRect rect = QRect( pa.first(), pa.last() );
 
  573    rect = rect.normalized();
 
  575    const int minSize = 2;
 
  576    if ( rect.width() < minSize && rect.height() < minSize )
 
  581    const QPoint center = rect.center();
 
  583    rect.moveCenter( center );
 
  586    pa[0] = rect.topLeft();
 
  587    pa[1] = rect.bottomRight();
 
 
  599    return QSizeF( m_data->zoomStack[0].width() / 10e4,
 
  600        m_data->zoomStack[0].height() / 10e4 );
 
 
  611    if ( m_data->maxStackDepth >= 0 )
 
  613        if ( m_data->zoomRectIndex >= uint( m_data->maxStackDepth ) )
 
  618    if ( minSize.isValid() )
 
  621            m_data->zoomStack[m_data->zoomRectIndex].size() * 0.9999;
 
  623        if ( minSize.width() >= sz.width() &&
 
  624            minSize.height() >= sz.height() )
 
 
  654    if ( pa.count() < 2 )
 
  657    QRect rect = QRect( pa.first(), pa.last() );
 
  658    rect = rect.normalized();
 
 
  673#include "moc_qwt_plot_zoomer.cpp" 
bool mouseMatch(MousePatternCode, const QMouseEvent *) const
Compare a mouse event with an event pattern.
bool keyMatch(KeyPatternCode, const QKeyEvent *) const
Compare a key event with an event pattern.
A class representing an interval.
A state machine for rectangle selections.
@ ActiveOnly
Display only when the selection is active.
void setStateMachine(QwtPickerMachine *)
void setRubberBand(RubberBand)
void setTrackerMode(DisplayMode)
Set the display mode of the tracker.
@ RectRubberBand
A rectangle ( only for QwtPickerMachine::RectSelection )
virtual void widgetMouseReleaseEvent(QMouseEvent *)
virtual void widgetKeyPressEvent(QKeyEvent *)
QPolygon selection() const
void setAxisScale(QwtAxisId, double min, double max, double stepSize=0)
Disable autoscaling and specify a fixed scale for a selected axis.
virtual void replot()
Redraw the plot.
void setAutoReplot(bool=true)
Set or reset the autoReplot option.
virtual QwtScaleMap canvasMap(QwtAxisId) const
const QwtScaleDiv & axisScaleDiv(QwtAxisId) const
Return the scale division of a specified axis.
QwtPlotPicker provides selections on a plot canvas.
virtual bool end(bool ok=true) override
QwtAxisId yAxis() const
Return y axis.
QwtAxisId xAxis() const
Return x axis.
virtual void setAxes(QwtAxisId xAxisId, QwtAxisId yAxisId)
virtual void widgetKeyPressEvent(QKeyEvent *) override
void moveBy(double dx, double dy)
const QStack< QRectF > & zoomStack() const
QwtPlotZoomer(QWidget *, bool doReplot=true)
Create a zoomer for a plot canvas.
void setMaxStackDepth(int)
Limit the number of recursive zoom operations to depth.
virtual void moveTo(const QPointF &)
virtual void widgetMouseReleaseEvent(QMouseEvent *) override
virtual void setZoomBase(bool doReplot=true)
virtual void begin() override
virtual void setAxes(QwtAxisId xAxis, QwtAxisId yAxis) override
uint zoomRectIndex() const
int maxStackDepth() const
virtual bool accept(QPolygon &) const override
Check and correct a selected rectangle.
virtual bool end(bool ok=true) override
virtual QSizeF minZoomSize() const
Limit zooming by a minimum rectangle.
void zoomed(const QRectF &rect)
void setZoomStack(const QStack< QRectF > &, int zoomRectIndex=-1)
Assign a zoom stack.
virtual void zoom(const QRectF &)
Zoom in.
const QwtTransform * transformation() const
Get the transformation.
double invTransform(double p) const