Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_plot_magnifier.cpp
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_plot_magnifier.cpp (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_plot_magnifier.cpp
r8127 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 9 9 10 10 #include "qwt_plot.h" 11 #include "qwt_scale_ div.h"11 #include "qwt_scale_map.h" 12 12 #include "qwt_plot_magnifier.h" 13 #include <qevent.h>14 13 15 14 class QwtPlotMagnifier::PrivateData 16 15 { 17 public: 16 public: 18 17 PrivateData() 19 18 { 20 for ( int axis = 0; axis < Qwt Plot::axisCnt; axis++ )19 for ( int axis = 0; axis < QwtAxis::AxisPositions; axis++ ) 21 20 isAxisEnabled[axis] = true; 22 21 } 23 22 24 bool isAxisEnabled[Qwt Plot::axisCnt];23 bool isAxisEnabled[QwtAxis::AxisPositions]; 25 24 }; 26 25 … … 28 27 Constructor 29 28 \param canvas Plot canvas to be magnified 30 */ 31 QwtPlotMagnifier::QwtPlotMagnifier( QWidget *canvas ):32 QwtMagnifier( canvas ) 29 */ 30 QwtPlotMagnifier::QwtPlotMagnifier( QWidget* canvas ) 31 : QwtMagnifier( canvas ) 33 32 { 34 d_data = new PrivateData();33 m_data = new PrivateData(); 35 34 } 36 35 … … 38 37 QwtPlotMagnifier::~QwtPlotMagnifier() 39 38 { 40 delete d_data;39 delete m_data; 41 40 } 42 41 … … 47 46 All other axes will remain unchanged. 48 47 49 \param axis Axis, see QwtPlot::Axis48 \param axisId Axis 50 49 \param on On/Off 51 50 52 51 \sa isAxisEnabled() 53 */ 54 void QwtPlotMagnifier::setAxisEnabled( int axis, bool on )52 */ 53 void QwtPlotMagnifier::setAxisEnabled( QwtAxisId axisId, bool on ) 55 54 { 56 if ( axis >= 0 && axis < QwtPlot::axisCnt)57 d_data->isAxisEnabled[axis] = on;55 if ( QwtAxis::isValid( axisId ) ) 56 m_data->isAxisEnabled[axisId] = on; 58 57 } 59 58 … … 61 60 Test if an axis is enabled 62 61 63 \param axis Axis, see QwtPlot::Axis62 \param axisId Axis 64 63 \return True, if the axis is enabled 65 64 66 65 \sa setAxisEnabled() 67 */ 68 bool QwtPlotMagnifier::isAxisEnabled( int axis) const66 */ 67 bool QwtPlotMagnifier::isAxisEnabled( QwtAxisId axisId ) const 69 68 { 70 if ( axis >= 0 && axis < QwtPlot::axisCnt)71 return d_data->isAxisEnabled[axis];69 if ( QwtAxis::isValid( axisId ) ) 70 return m_data->isAxisEnabled[axisId]; 72 71 73 72 return true; … … 75 74 76 75 //! Return observed plot canvas 77 QWidget *QwtPlotMagnifier::canvas()76 QWidget* QwtPlotMagnifier::canvas() 78 77 { 79 78 return parentWidget(); … … 81 80 82 81 //! Return Observed plot canvas 83 const QWidget *QwtPlotMagnifier::canvas() const82 const QWidget* QwtPlotMagnifier::canvas() const 84 83 { 85 84 return parentWidget(); … … 87 86 88 87 //! Return plot widget, containing the observed plot canvas 89 QwtPlot *QwtPlotMagnifier::plot()88 QwtPlot* QwtPlotMagnifier::plot() 90 89 { 91 QWidget *w = canvas();90 QWidget* w = canvas(); 92 91 if ( w ) 93 92 w = w->parentWidget(); 94 93 95 return qobject_cast<QwtPlot *>( w );94 return qobject_cast< QwtPlot* >( w ); 96 95 } 97 96 98 97 //! Return plot widget, containing the observed plot canvas 99 const QwtPlot *QwtPlotMagnifier::plot() const98 const QwtPlot* QwtPlotMagnifier::plot() const 100 99 { 101 const QWidget *w = canvas();100 const QWidget* w = canvas(); 102 101 if ( w ) 103 102 w = w->parentWidget(); 104 103 105 return qobject_cast<const QwtPlot *>( w );104 return qobject_cast< const QwtPlot* >( w ); 106 105 } 107 106 … … 109 108 Zoom in/out the axes scales 110 109 \param factor A value < 1.0 zooms in, a value > 1.0 zooms out. 111 */ 110 */ 112 111 void QwtPlotMagnifier::rescale( double factor ) 113 112 { … … 125 124 plt->setAutoReplot( false ); 126 125 127 for ( int axis Id= 0; axisId < QwtPlot::axisCnt; axisId++ )126 for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ ) 128 127 { 129 if ( isAxisEnabled( axisId ) )130 128 { 131 const Qwt ScaleMap scaleMap = plt->canvasMap(axisId );129 const QwtAxisId axisId( axisPos ); 132 130 133 double v1 = scaleMap.s1(); 134 double v2 = scaleMap.s2(); 131 if ( isAxisEnabled( axisId ) ) 132 { 133 const QwtScaleMap scaleMap = plt->canvasMap( axisId ); 135 134 136 if ( scaleMap.transformation() ) 137 { 138 // the coordinate system of the paint device is always linear 135 double v1 = scaleMap.s1(); 136 double v2 = scaleMap.s2(); 139 137 140 v1 = scaleMap.transform( v1 ); // scaleMap.p1() 141 v2 = scaleMap.transform( v2 ); // scaleMap.p2() 138 if ( scaleMap.transformation() ) 139 { 140 // the coordinate system of the paint device is always linear 141 142 v1 = scaleMap.transform( v1 ); // scaleMap.p1() 143 v2 = scaleMap.transform( v2 ); // scaleMap.p2() 144 } 145 146 const double center = 0.5 * ( v1 + v2 ); 147 const double width_2 = 0.5 * ( v2 - v1 ) * factor; 148 149 v1 = center - width_2; 150 v2 = center + width_2; 151 152 if ( scaleMap.transformation() ) 153 { 154 v1 = scaleMap.invTransform( v1 ); 155 v2 = scaleMap.invTransform( v2 ); 156 } 157 158 plt->setAxisScale( axisId, v1, v2 ); 159 doReplot = true; 142 160 } 143 144 const double center = 0.5 * ( v1 + v2 );145 const double width_2 = 0.5 * ( v2 - v1 ) * factor;146 147 v1 = center - width_2;148 v2 = center + width_2;149 150 if ( scaleMap.transformation() )151 {152 v1 = scaleMap.invTransform( v1 );153 v2 = scaleMap.invTransform( v2 );154 }155 156 plt->setAxisScale( axisId, v1, v2 );157 doReplot = true;158 161 } 159 162 } … … 164 167 plt->replot(); 165 168 } 169 170 #include "moc_qwt_plot_magnifier.cpp"
Note:
See TracChangeset
for help on using the changeset viewer.
