Changeset 8127 in ntrip for trunk/BNC/qwt/qwt_plot_magnifier.cpp
- Timestamp:
- May 10, 2017, 3:20:54 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_plot_magnifier.cpp
r4271 r8127 9 9 10 10 #include "qwt_plot.h" 11 #include "qwt_plot_canvas.h"12 11 #include "qwt_scale_div.h" 13 12 #include "qwt_plot_magnifier.h" … … 30 29 \param canvas Plot canvas to be magnified 31 30 */ 32 QwtPlotMagnifier::QwtPlotMagnifier( Q wtPlotCanvas*canvas ):31 QwtPlotMagnifier::QwtPlotMagnifier( QWidget *canvas ): 33 32 QwtMagnifier( canvas ) 34 33 { … … 76 75 77 76 //! Return observed plot canvas 78 Q wtPlotCanvas*QwtPlotMagnifier::canvas()77 QWidget *QwtPlotMagnifier::canvas() 79 78 { 80 return qobject_cast<QwtPlotCanvas *>( parent());79 return parentWidget(); 81 80 } 82 81 83 82 //! Return Observed plot canvas 84 const Q wtPlotCanvas*QwtPlotMagnifier::canvas() const83 const QWidget *QwtPlotMagnifier::canvas() const 85 84 { 86 return qobject_cast<const QwtPlotCanvas *>( parent());85 return parentWidget(); 87 86 } 88 87 … … 90 89 QwtPlot *QwtPlotMagnifier::plot() 91 90 { 92 Q wtPlotCanvas*w = canvas();91 QWidget *w = canvas(); 93 92 if ( w ) 94 return w->plot();93 w = w->parentWidget(); 95 94 96 return NULL;95 return qobject_cast<QwtPlot *>( w ); 97 96 } 98 97 … … 100 99 const QwtPlot *QwtPlotMagnifier::plot() const 101 100 { 102 const Q wtPlotCanvas*w = canvas();101 const QWidget *w = canvas(); 103 102 if ( w ) 104 return w->plot();103 w = w->parentWidget(); 105 104 106 return NULL;105 return qobject_cast<const QwtPlot *>( w ); 107 106 } 108 107 … … 113 112 void QwtPlotMagnifier::rescale( double factor ) 114 113 { 114 QwtPlot* plt = plot(); 115 if ( plt == NULL ) 116 return; 117 115 118 factor = qAbs( factor ); 116 119 if ( factor == 1.0 || factor == 0.0 ) … … 118 121 119 122 bool doReplot = false; 120 QwtPlot* plt = plot();121 123 122 124 const bool autoReplot = plt->autoReplot(); … … 125 127 for ( int axisId = 0; axisId < QwtPlot::axisCnt; axisId++ ) 126 128 { 127 const QwtScaleDiv *scaleDiv = plt->axisScaleDiv( axisId ); 128 if ( isAxisEnabled( axisId ) && scaleDiv->isValid() ) 129 if ( isAxisEnabled( axisId ) ) 129 130 { 130 const double center = 131 scaleDiv->lowerBound() + scaleDiv->range() / 2; 132 const double width_2 = scaleDiv->range() / 2 * factor; 131 const QwtScaleMap scaleMap = plt->canvasMap( axisId ); 133 132 134 plt->setAxisScale( axisId, center - width_2, center + width_2 ); 133 double v1 = scaleMap.s1(); 134 double v2 = scaleMap.s2(); 135 136 if ( scaleMap.transformation() ) 137 { 138 // the coordinate system of the paint device is always linear 139 140 v1 = scaleMap.transform( v1 ); // scaleMap.p1() 141 v2 = scaleMap.transform( v2 ); // scaleMap.p2() 142 } 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 ); 135 157 doReplot = true; 136 158 }
Note:
See TracChangeset
for help on using the changeset viewer.