Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_plot_zoneitem.cpp
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_plot_zoneitem.cpp (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_plot_zoneitem.cpp
r9383 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 11 11 #include "qwt_painter.h" 12 12 #include "qwt_scale_map.h" 13 #include "qwt_text.h" 14 #include "qwt_interval.h" 15 13 16 #include <qpainter.h> 14 17 15 18 class QwtPlotZoneItem::PrivateData 16 19 { 17 public: 18 PrivateData() :19 orientation( Qt::Vertical ) ,20 pen( Qt::NoPen ) 20 public: 21 PrivateData() 22 : orientation( Qt::Vertical ) 23 , pen( Qt::NoPen ) 21 24 { 22 25 QColor c( Qt::darkGray ); … … 44 47 45 48 \sa QwtPlotItem::setItemAttribute(), QwtPlotItem::setZ() 46 */ 47 QwtPlotZoneItem::QwtPlotZoneItem() :48 QwtPlotItem( QwtText( "Zone" ) ) 49 { 50 d_data = new PrivateData;49 */ 50 QwtPlotZoneItem::QwtPlotZoneItem() 51 : QwtPlotItem( QwtText( "Zone" ) ) 52 { 53 m_data = new PrivateData; 51 54 52 55 setItemAttribute( QwtPlotItem::AutoScale, false ); … … 59 62 QwtPlotZoneItem::~QwtPlotZoneItem() 60 63 { 61 delete d_data;64 delete m_data; 62 65 } 63 66 … … 69 72 70 73 /*! 71 Build and assign a pen 72 73 In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it 74 non cosmetic ( see QPen::isCosmetic() ). This method has been introduced 75 to hide this incompatibility. 76 77 \param color Pen color 78 \param width Pen width 79 \param style Pen style 80 81 \sa pen(), brush() 82 */ 83 void QwtPlotZoneItem::setPen( const QColor &color, qreal width, Qt::PenStyle style )74 Build and assign a pen 75 76 In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it 77 non cosmetic ( see QPen::isCosmetic() ). This method has been introduced 78 to hide this incompatibility. 79 80 \param color Pen color 81 \param width Pen width 82 \param style Pen style 83 84 \sa pen(), brush() 85 */ 86 void QwtPlotZoneItem::setPen( const QColor& color, qreal width, Qt::PenStyle style ) 84 87 { 85 88 setPen( QPen( color, width, style ) ); … … 87 90 88 91 /*! 89 \brief Assign a pen 90 91 The pen is used to draw the border lines of the zone 92 93 \param pen Pen 94 \sa pen(), setBrush() 95 */ 96 void QwtPlotZoneItem::setPen( const QPen &pen )97 { 98 if ( d_data->pen != pen )99 { 100 d_data->pen = pen;92 \brief Assign a pen 93 94 The pen is used to draw the border lines of the zone 95 96 \param pen Pen 97 \sa pen(), setBrush() 98 */ 99 void QwtPlotZoneItem::setPen( const QPen& pen ) 100 { 101 if ( m_data->pen != pen ) 102 { 103 m_data->pen = pen; 101 104 itemChanged(); 102 105 } … … 104 107 105 108 /*! 106 \return Pen used to draw the border lines 107 \sa setPen(), brush() 108 */ 109 const QPen &QwtPlotZoneItem::pen() const110 { 111 return d_data->pen;112 } 113 114 /*! 115 \brief Assign a brush 116 117 The brush is used to fill the zone 118 119 \param brush Brush 120 \sa pen(), setBrush() 121 */ 122 void QwtPlotZoneItem::setBrush( const QBrush &brush )123 { 124 if ( d_data->brush != brush )125 { 126 d_data->brush = brush;109 \return Pen used to draw the border lines 110 \sa setPen(), brush() 111 */ 112 const QPen& QwtPlotZoneItem::pen() const 113 { 114 return m_data->pen; 115 } 116 117 /*! 118 \brief Assign a brush 119 120 The brush is used to fill the zone 121 122 \param brush Brush 123 \sa pen(), setBrush() 124 */ 125 void QwtPlotZoneItem::setBrush( const QBrush& brush ) 126 { 127 if ( m_data->brush != brush ) 128 { 129 m_data->brush = brush; 127 130 itemChanged(); 128 131 } … … 130 133 131 134 /*! 132 \return Brush used to fill the zone 133 \sa setPen(), brush() 134 */ 135 const QBrush &QwtPlotZoneItem::brush() const136 { 137 return d_data->brush;138 } 139 140 /*! 141 \brief Set the orientation of the zone 142 143 A horizontal zone highlights an interval of the y axis, 144 a vertical zone of the x axis. It is unbounded in the 145 opposite direction. 146 147 \sa orientation(), QwtPlotItem::setAxes() 148 */ 135 \return Brush used to fill the zone 136 \sa setPen(), brush() 137 */ 138 const QBrush& QwtPlotZoneItem::brush() const 139 { 140 return m_data->brush; 141 } 142 143 /*! 144 \brief Set the orientation of the zone 145 146 A horizontal zone highlights an interval of the y axis, 147 a vertical zone of the x axis. It is unbounded in the 148 opposite direction. 149 150 \sa orientation(), QwtPlotItem::setAxes() 151 */ 149 152 void QwtPlotZoneItem::setOrientation( Qt::Orientation orientation ) 150 153 { 151 if ( d_data->orientation != orientation )152 { 153 d_data->orientation = orientation;154 if ( m_data->orientation != orientation ) 155 { 156 m_data->orientation = orientation; 154 157 itemChanged(); 155 158 } … … 157 160 158 161 /*! 159 \return Orientation of the zone 160 \sa setOrientation() 161 */ 162 Qt::Orientation QwtPlotZoneItem::orientation() 163 { 164 return d_data->orientation;165 } 166 167 /*! 168 Set the interval of the zone 169 170 For a horizontal zone the interval is related to the y axis, 171 for a vertical zone it is related to the x axis. 172 173 \param min Minimum of the interval 174 \param max Maximum of the interval 175 176 \sa interval(), setOrientation() 162 \return Orientation of the zone 163 \sa setOrientation() 164 */ 165 Qt::Orientation QwtPlotZoneItem::orientation() const 166 { 167 return m_data->orientation; 168 } 169 170 /*! 171 Set the interval of the zone 172 173 For a horizontal zone the interval is related to the y axis, 174 for a vertical zone it is related to the x axis. 175 176 \param min Minimum of the interval 177 \param max Maximum of the interval 178 179 \sa interval(), setOrientation() 177 180 */ 178 181 void QwtPlotZoneItem::setInterval( double min, double max ) … … 182 185 183 186 /*! 184 Set the interval of the zone 185 186 For a horizontal zone the interval is related to the y axis, 187 for a vertical zone it is related to the x axis. 188 189 \param interval Zone interval 190 191 \sa interval(), setOrientation() 192 */ 193 void QwtPlotZoneItem::setInterval( const QwtInterval &interval )194 { 195 if ( d_data->interval != interval )196 { 197 d_data->interval = interval;187 Set the interval of the zone 188 189 For a horizontal zone the interval is related to the y axis, 190 for a vertical zone it is related to the x axis. 191 192 \param interval Zone interval 193 194 \sa interval(), setOrientation() 195 */ 196 void QwtPlotZoneItem::setInterval( const QwtInterval& interval ) 197 { 198 if ( m_data->interval != interval ) 199 { 200 m_data->interval = interval; 198 201 itemChanged(); 199 202 } … … 201 204 202 205 /*! 203 \return Zone interval 204 \sa setInterval(), orientation() 206 \return Zone interval 207 \sa setInterval(), orientation() 205 208 */ 206 209 QwtInterval QwtPlotZoneItem::interval() const 207 210 { 208 return d_data->interval;209 } 210 211 /*! 212 Draw the zone 213 214 \param painter Painter 215 \param xMap x Scale Map 216 \param yMap y Scale Map 217 \param canvasRect Contents rectangle of the canvas in painter coordinates 218 */ 219 220 void QwtPlotZoneItem::draw( QPainter *painter,221 const QwtScaleMap &xMap, const QwtScaleMap&yMap,222 const QRectF &canvasRect ) const223 { 224 if ( ! d_data->interval.isValid() )211 return m_data->interval; 212 } 213 214 /*! 215 Draw the zone 216 217 \param painter Painter 218 \param xMap x Scale Map 219 \param yMap y Scale Map 220 \param canvasRect Contents rectangle of the canvas in painter coordinates 221 */ 222 223 void QwtPlotZoneItem::draw( QPainter* painter, 224 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 225 const QRectF& canvasRect ) const 226 { 227 if ( !m_data->interval.isValid() ) 225 228 return; 226 229 227 QPen pen = d_data->pen;230 QPen pen = m_data->pen; 228 231 pen.setCapStyle( Qt::FlatCap ); 229 232 230 233 const bool doAlign = QwtPainter::roundingAlignment( painter ); 231 234 232 if ( d_data->orientation == Qt::Horizontal )233 { 234 double y1 = yMap.transform( d_data->interval.minValue() );235 double y2 = yMap.transform( d_data->interval.maxValue() );235 if ( m_data->orientation == Qt::Horizontal ) 236 { 237 double y1 = yMap.transform( m_data->interval.minValue() ); 238 double y2 = yMap.transform( m_data->interval.maxValue() ); 236 239 237 240 if ( doAlign ) … … 244 247 r = r.normalized(); 245 248 246 if ( ( d_data->brush.style() != Qt::NoBrush ) && ( y1 != y2 ) )247 { 248 QwtPainter::fillRect( painter, r, d_data->brush );249 } 250 251 if ( d_data->pen.style() != Qt::NoPen )252 { 253 painter->setPen( d_data->pen );249 if ( ( m_data->brush.style() != Qt::NoBrush ) && ( y1 != y2 ) ) 250 { 251 QwtPainter::fillRect( painter, r, m_data->brush ); 252 } 253 254 if ( m_data->pen.style() != Qt::NoPen ) 255 { 256 painter->setPen( m_data->pen ); 254 257 255 258 QwtPainter::drawLine( painter, r.left(), r.top(), r.right(), r.top() ); … … 259 262 else 260 263 { 261 double x1 = xMap.transform( d_data->interval.minValue() );262 double x2 = xMap.transform( d_data->interval.maxValue() );264 double x1 = xMap.transform( m_data->interval.minValue() ); 265 double x2 = xMap.transform( m_data->interval.maxValue() ); 263 266 264 267 if ( doAlign ) … … 271 274 r = r.normalized(); 272 275 273 if ( ( d_data->brush.style() != Qt::NoBrush ) && ( x1 != x2 ) )274 { 275 QwtPainter::fillRect( painter, r, d_data->brush );276 } 277 278 if ( d_data->pen.style() != Qt::NoPen )279 { 280 painter->setPen( d_data->pen );276 if ( ( m_data->brush.style() != Qt::NoBrush ) && ( x1 != x2 ) ) 277 { 278 QwtPainter::fillRect( painter, r, m_data->brush ); 279 } 280 281 if ( m_data->pen.style() != Qt::NoPen ) 282 { 283 painter->setPen( m_data->pen ); 281 284 282 285 QwtPainter::drawLine( painter, r.left(), r.top(), r.left(), r.bottom() ); … … 287 290 288 291 /*! 289 The bounding rectangle is build from the interval in one direction 290 and something invalid for the opposite direction. 291 292 \return An invalid rectangle with valid boundaries in one direction 293 */ 292 The bounding rectangle is build from the interval in one direction 293 and something invalid for the opposite direction. 294 295 \return An invalid rectangle with valid boundaries in one direction 296 */ 294 297 QRectF QwtPlotZoneItem::boundingRect() const 295 298 { 296 299 QRectF br = QwtPlotItem::boundingRect(); 297 300 298 const QwtInterval &intv =d_data->interval;301 const QwtInterval& intv = m_data->interval; 299 302 300 303 if ( intv.isValid() ) 301 304 { 302 if ( d_data->orientation == Qt::Horizontal )305 if ( m_data->orientation == Qt::Horizontal ) 303 306 { 304 307 br.setTop( intv.minValue() );
Note:
See TracChangeset
for help on using the changeset viewer.
