Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_plot_spectrocurve.cpp
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_plot_spectrocurve.cpp (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_plot_spectrocurve.cpp
r9383 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 12 12 #include "qwt_scale_map.h" 13 13 #include "qwt_painter.h" 14 #include "qwt_text.h" 15 14 16 #include <qpainter.h> 15 17 16 18 class QwtPlotSpectroCurve::PrivateData 17 19 { 18 public: 19 PrivateData() :20 colorRange( 0.0, 1000.0 ) ,21 penWidth( 0.0),22 paintAttributes( QwtPlotSpectroCurve::ClipPoints ) 20 public: 21 PrivateData() 22 : colorRange( 0.0, 1000.0 ) 23 , penWidth( 0.0 ) 24 , paintAttributes( QwtPlotSpectroCurve::ClipPoints ) 23 25 { 24 26 colorMap = new QwtLinearColorMap(); … … 30 32 } 31 33 32 QwtColorMap *colorMap;34 QwtColorMap* colorMap; 33 35 QwtInterval colorRange; 34 QVector< QRgb> colorTable;36 QVector< QRgb > colorTable; 35 37 double penWidth; 36 38 QwtPlotSpectroCurve::PaintAttributes paintAttributes; … … 38 40 39 41 /*! 40 Constructor 41 \param title Title of the curve 42 */ 43 QwtPlotSpectroCurve::QwtPlotSpectroCurve( const QwtText &title ):44 QwtPlotSeriesItem( title ) 42 Constructor 43 \param title Title of the curve 44 */ 45 QwtPlotSpectroCurve::QwtPlotSpectroCurve( const QwtText& title ) 46 : QwtPlotSeriesItem( title ) 45 47 { 46 48 init(); … … 48 50 49 51 /*! 50 Constructor 51 \param title Title of the curve 52 */ 53 QwtPlotSpectroCurve::QwtPlotSpectroCurve( const QString &title ):54 QwtPlotSeriesItem( QwtText( title ) ) 52 Constructor 53 \param title Title of the curve 54 */ 55 QwtPlotSpectroCurve::QwtPlotSpectroCurve( const QString& title ) 56 : QwtPlotSeriesItem( QwtText( title ) ) 55 57 { 56 58 init(); … … 60 62 QwtPlotSpectroCurve::~QwtPlotSpectroCurve() 61 63 { 62 delete d_data;63 } 64 65 /*! 66 \brief Initialize data members 67 */ 64 delete m_data; 65 } 66 67 /*! 68 \brief Initialize data members 69 */ 68 70 void QwtPlotSpectroCurve::init() 69 71 { … … 71 73 setItemAttribute( QwtPlotItem::AutoScale ); 72 74 73 d_data = new PrivateData;75 m_data = new PrivateData; 74 76 setData( new QwtPoint3DSeriesData() ); 75 77 … … 84 86 85 87 /*! 86 Specify an attribute how to draw the curve 87 88 \param attribute Paint attribute 89 \param on On/Off 90 /sa PaintAttribute, testPaintAttribute() 91 */ 88 Specify an attribute how to draw the curve 89 90 \param attribute Paint attribute 91 \param on On/Off 92 /sa PaintAttribute, testPaintAttribute() 93 */ 92 94 void QwtPlotSpectroCurve::setPaintAttribute( PaintAttribute attribute, bool on ) 93 95 { 94 96 if ( on ) 95 d_data->paintAttributes |= attribute;97 m_data->paintAttributes |= attribute; 96 98 else 97 d_data->paintAttributes &= ~attribute;99 m_data->paintAttributes &= ~attribute; 98 100 } 99 101 … … 101 103 \return True, when attribute is enabled 102 104 \sa PaintAttribute, setPaintAttribute() 103 */ 105 */ 104 106 bool QwtPlotSpectroCurve::testPaintAttribute( PaintAttribute attribute ) const 105 107 { 106 return ( d_data->paintAttributes & attribute );107 } 108 109 /*! 110 Initialize data with an array of samples. 111 \param samples Vector of points 112 */ 113 void QwtPlotSpectroCurve::setSamples( const QVector<QwtPoint3D > &samples )108 return ( m_data->paintAttributes & attribute ); 109 } 110 111 /*! 112 Initialize data with an array of samples. 113 \param samples Vector of points 114 */ 115 void QwtPlotSpectroCurve::setSamples( const QVector< QwtPoint3D >& samples ) 114 116 { 115 117 setData( new QwtPoint3DSeriesData( samples ) ); … … 117 119 118 120 /*! 119 Assign a series of samples 120 121 setSamples() is just a wrapper for setData() without any additional 122 value - beside that it is easier to find for the developer. 123 124 \param data Data 125 \warning The item takes ownership of the data object, deleting 121 Assign a series of samples 122 123 setSamples() is just a wrapper for setData() without any additional 124 value - beside that it is easier to find for the developer. 125 126 \param data Data 127 \warning The item takes ownership of the data object, deleting 126 128 it when its not used anymore. 127 */ 129 */ 128 130 void QwtPlotSpectroCurve::setSamples( 129 QwtSeriesData<QwtPoint3D > *data )131 QwtSeriesData< QwtPoint3D >* data ) 130 132 { 131 133 setData( data ); … … 133 135 134 136 /*! 135 Change the color map 136 137 Often it is useful to display the mapping between intensities and 138 colors as an additional plot axis, showing a color bar. 139 140 \param colorMap Color Map 141 142 \sa colorMap(), setColorRange(), QwtColorMap::color(), 137 Change the color map 138 139 Often it is useful to display the mapping between intensities and 140 colors as an additional plot axis, showing a color bar. 141 142 \param colorMap Color Map 143 144 \sa colorMap(), setColorRange(), QwtColorMap::color(), 143 145 QwtScaleWidget::setColorBarEnabled(), QwtScaleWidget::setColorMap() 144 */ 145 void QwtPlotSpectroCurve::setColorMap( QwtColorMap *colorMap )146 { 147 if ( colorMap != d_data->colorMap )148 { 149 delete d_data->colorMap;150 d_data->colorMap = colorMap;146 */ 147 void QwtPlotSpectroCurve::setColorMap( QwtColorMap* colorMap ) 148 { 149 if ( colorMap != m_data->colorMap ) 150 { 151 delete m_data->colorMap; 152 m_data->colorMap = colorMap; 151 153 } 152 154 … … 158 160 \return Color Map used for mapping the intensity values to colors 159 161 \sa setColorMap(), setColorRange(), QwtColorMap::color() 160 */ 161 const QwtColorMap *QwtPlotSpectroCurve::colorMap() const162 { 163 return d_data->colorMap;162 */ 163 const QwtColorMap* QwtPlotSpectroCurve::colorMap() const 164 { 165 return m_data->colorMap; 164 166 } 165 167 … … 171 173 172 174 \sa colorRange(), setColorMap(), QwtColorMap::color() 173 */ 174 void QwtPlotSpectroCurve::setColorRange( const QwtInterval &interval )175 { 176 if ( interval != d_data->colorRange )177 { 178 d_data->colorRange = interval;175 */ 176 void QwtPlotSpectroCurve::setColorRange( const QwtInterval& interval ) 177 { 178 if ( interval != m_data->colorRange ) 179 { 180 m_data->colorRange = interval; 179 181 180 182 legendChanged(); … … 184 186 185 187 /*! 186 \return Value interval, that corresponds to the color map 187 \sa setColorRange(), setColorMap(), QwtColorMap::color() 188 */ 189 QwtInterval &QwtPlotSpectroCurve::colorRange() const190 { 191 return d_data->colorRange;192 } 193 194 /*! 195 Assign a pen width 196 197 \param penWidth New pen width 198 \sa penWidth() 199 */ 188 \return Value interval, that corresponds to the color map 189 \sa setColorRange(), setColorMap(), QwtColorMap::color() 190 */ 191 QwtInterval& QwtPlotSpectroCurve::colorRange() const 192 { 193 return m_data->colorRange; 194 } 195 196 /*! 197 Assign a pen width 198 199 \param penWidth New pen width 200 \sa penWidth() 201 */ 200 202 void QwtPlotSpectroCurve::setPenWidth(double penWidth) 201 203 { … … 203 205 penWidth = 0.0; 204 206 205 if ( d_data->penWidth != penWidth )206 { 207 d_data->penWidth = penWidth;207 if ( m_data->penWidth != penWidth ) 208 { 209 m_data->penWidth = penWidth; 208 210 209 211 legendChanged(); … … 213 215 214 216 /*! 215 \return Pen width used to draw a dot 216 \sa setPenWidth() 217 */ 217 \return Pen width used to draw a dot 218 \sa setPenWidth() 219 */ 218 220 double QwtPlotSpectroCurve::penWidth() const 219 221 { 220 return d_data->penWidth;221 } 222 223 /*! 224 Draw a subset of the points 225 226 \param painter Painter 227 \param xMap Maps x-values into pixel coordinates. 228 \param yMap Maps y-values into pixel coordinates. 229 \param canvasRect Contents rectangle of the canvas 230 \param from Index of the first sample to be painted 231 \param to Index of the last sample to be painted. If to < 0 the 222 return m_data->penWidth; 223 } 224 225 /*! 226 Draw a subset of the points 227 228 \param painter Painter 229 \param xMap Maps x-values into pixel coordinates. 230 \param yMap Maps y-values into pixel coordinates. 231 \param canvasRect Contents rectangle of the canvas 232 \param from Index of the first sample to be painted 233 \param to Index of the last sample to be painted. If to < 0 the 232 234 series will be painted to its last sample. 233 235 234 \sa drawDots() 235 */ 236 void QwtPlotSpectroCurve::drawSeries( QPainter *painter,237 const QwtScaleMap &xMap, const QwtScaleMap&yMap,238 const QRectF &canvasRect, int from, int to ) const236 \sa drawDots() 237 */ 238 void QwtPlotSpectroCurve::drawSeries( QPainter* painter, 239 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 240 const QRectF& canvasRect, int from, int to ) const 239 241 { 240 242 if ( !painter || dataSize() <= 0 ) … … 254 256 255 257 /*! 256 Draw a subset of the points 257 258 \param painter Painter 259 \param xMap Maps x-values into pixel coordinates. 260 \param yMap Maps y-values into pixel coordinates. 261 \param canvasRect Contents rectangle of the canvas 262 \param from Index of the first sample to be painted 263 \param to Index of the last sample to be painted. If to < 0 the 258 Draw a subset of the points 259 260 \param painter Painter 261 \param xMap Maps x-values into pixel coordinates. 262 \param yMap Maps y-values into pixel coordinates. 263 \param canvasRect Contents rectangle of the canvas 264 \param from Index of the first sample to be painted 265 \param to Index of the last sample to be painted. If to < 0 the 264 266 series will be painted to its last sample. 265 267 266 \sa drawSeries() 267 */ 268 void QwtPlotSpectroCurve::drawDots( QPainter *painter,269 const QwtScaleMap &xMap, const QwtScaleMap&yMap,270 const QRectF &canvasRect, int from, int to ) const271 { 272 if ( ! d_data->colorRange.isValid() )268 \sa drawSeries() 269 */ 270 void QwtPlotSpectroCurve::drawDots( QPainter* painter, 271 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 272 const QRectF& canvasRect, int from, int to ) const 273 { 274 if ( !m_data->colorRange.isValid() ) 273 275 return; 274 276 275 277 const bool doAlign = QwtPainter::roundingAlignment( painter ); 276 278 277 const QwtColorMap::Format format = d_data->colorMap->format();279 const QwtColorMap::Format format = m_data->colorMap->format(); 278 280 if ( format == QwtColorMap::Indexed ) 279 d_data->colorTable =d_data->colorMap->colorTable( d_data->colorRange);280 281 const QwtSeriesData<QwtPoint3D > *series = data();281 m_data->colorTable = m_data->colorMap->colorTable256(); 282 283 const QwtSeriesData< QwtPoint3D >* series = data(); 282 284 283 285 for ( int i = from; i <= to; i++ ) … … 293 295 } 294 296 295 if ( d_data->paintAttributes & QwtPlotSpectroCurve::ClipPoints )297 if ( m_data->paintAttributes & QwtPlotSpectroCurve::ClipPoints ) 296 298 { 297 299 if ( !canvasRect.contains( xi, yi ) ) … … 301 303 if ( format == QwtColorMap::RGB ) 302 304 { 303 const QRgb rgb = d_data->colorMap->rgb(304 d_data->colorRange, sample.z() );305 306 painter->setPen( QPen( QColor::fromRgba( rgb ), d_data->penWidth ) );305 const QRgb rgb = m_data->colorMap->rgb( 306 m_data->colorRange, sample.z() ); 307 308 painter->setPen( QPen( QColor::fromRgba( rgb ), m_data->penWidth ) ); 307 309 } 308 310 else 309 311 { 310 const unsigned char index = d_data->colorMap->colorIndex(311 d_data->colorRange, sample.z() );312 313 painter->setPen( QPen( QColor::fromRgba( d_data->colorTable[index] ),314 d_data->penWidth ) );312 const unsigned char index = m_data->colorMap->colorIndex( 313 256, m_data->colorRange, sample.z() ); 314 315 painter->setPen( QPen( QColor::fromRgba( m_data->colorTable[index] ), 316 m_data->penWidth ) ); 315 317 } 316 318 … … 318 320 } 319 321 320 d_data->colorTable.clear();321 } 322 m_data->colorTable.clear(); 323 }
Note:
See TracChangeset
for help on using the changeset viewer.
