Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_interval_symbol.cpp
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_interval_symbol.cpp (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_interval_symbol.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_math.h" 13 13 14 #include <qpainter.h> 14 15 #if QT_VERSION < 0x040601 16 #define qAtan2(y, x) ::atan2(y, x) 17 #define qFastSin(x) qSin(x) 18 #define qFastCos(x) qCos(x) 19 #endif 15 #include <qmath.h> 20 16 21 17 class QwtIntervalSymbol::PrivateData 22 18 { 23 public: 24 PrivateData() :25 style( QwtIntervalSymbol::NoSymbol ) ,26 width( 6 ) 19 public: 20 PrivateData() 21 : style( QwtIntervalSymbol::NoSymbol ) 22 , width( 6 ) 27 23 { 28 24 } 29 25 30 bool operator==( const PrivateData &other ) const26 bool operator==( const PrivateData& other ) const 31 27 { 32 28 return ( style == other.style ) 33 && ( width == other.width ) 34 && ( brush == other.brush ) 35 && ( pen == other.pen ); 29 && ( width == other.width ) 30 && ( brush == other.brush ) 31 && ( pen == other.pen ); 36 32 } 37 33 … … 44 40 45 41 /*! 46 Constructor 47 48 \param style Style of the symbol 49 \sa setStyle(), style(), Style 50 */ 42 Constructor 43 44 \param style Style of the symbol 45 \sa setStyle(), style(), Style 46 */ 51 47 QwtIntervalSymbol::QwtIntervalSymbol( Style style ) 52 48 { 53 d_data = new PrivateData();54 d_data->style = style;49 m_data = new PrivateData(); 50 m_data->style = style; 55 51 } 56 52 57 53 //! Copy constructor 58 QwtIntervalSymbol::QwtIntervalSymbol( const QwtIntervalSymbol &other )59 { 60 d_data = new PrivateData();61 * d_data = *other.d_data;54 QwtIntervalSymbol::QwtIntervalSymbol( const QwtIntervalSymbol& other ) 55 { 56 m_data = new PrivateData(); 57 *m_data = *other.m_data; 62 58 } 63 59 … … 65 61 QwtIntervalSymbol::~QwtIntervalSymbol() 66 62 { 67 delete d_data;63 delete m_data; 68 64 } 69 65 70 66 //! \brief Assignment operator 71 QwtIntervalSymbol &QwtIntervalSymbol::operator=(72 const QwtIntervalSymbol &other )73 { 74 * d_data = *other.d_data;67 QwtIntervalSymbol& QwtIntervalSymbol::operator=( 68 const QwtIntervalSymbol& other ) 69 { 70 *m_data = *other.m_data; 75 71 return *this; 76 72 } … … 78 74 //! \brief Compare two symbols 79 75 bool QwtIntervalSymbol::operator==( 80 const QwtIntervalSymbol &other ) const81 { 82 return * d_data == *other.d_data;76 const QwtIntervalSymbol& other ) const 77 { 78 return *m_data == *other.m_data; 83 79 } 84 80 85 81 //! \brief Compare two symbols 86 82 bool QwtIntervalSymbol::operator!=( 87 const QwtIntervalSymbol &other ) const88 { 89 return !( * d_data == *other.d_data );90 } 91 92 /*! 93 Specify the symbol style 94 95 \param style Style 96 \sa style(), Style 97 */ 83 const QwtIntervalSymbol& other ) const 84 { 85 return !( *m_data == *other.m_data ); 86 } 87 88 /*! 89 Specify the symbol style 90 91 \param style Style 92 \sa style(), Style 93 */ 98 94 void QwtIntervalSymbol::setStyle( Style style ) 99 95 { 100 d_data->style = style;101 } 102 103 /*! 104 \return Current symbol style 105 \sa setStyle() 106 */ 96 m_data->style = style; 97 } 98 99 /*! 100 \return Current symbol style 101 \sa setStyle() 102 */ 107 103 QwtIntervalSymbol::Style QwtIntervalSymbol::style() const 108 104 { 109 return d_data->style;110 } 111 112 /*! 113 Specify the width of the symbol 114 It is used depending on the style. 115 116 \param width Width 117 \sa width(), setStyle() 118 */ 105 return m_data->style; 106 } 107 108 /*! 109 Specify the width of the symbol 110 It is used depending on the style. 111 112 \param width Width 113 \sa width(), setStyle() 114 */ 119 115 void QwtIntervalSymbol::setWidth( int width ) 120 116 { 121 d_data->width = width;122 } 123 124 /*! 125 \return Width of the symbol. 126 \sa setWidth(), setStyle() 127 */ 117 m_data->width = width; 118 } 119 120 /*! 121 \return Width of the symbol. 122 \sa setWidth(), setStyle() 123 */ 128 124 int QwtIntervalSymbol::width() const 129 125 { 130 return d_data->width;131 } 132 133 /*! 134 \brief Assign a brush 135 136 The brush is used for the Box style. 137 138 \param brush Brush 139 \sa brush() 140 */ 141 void QwtIntervalSymbol::setBrush( const QBrush &brush )142 { 143 d_data->brush = brush;144 } 145 146 /*! 147 \return Brush 148 \sa setBrush() 149 */ 126 return m_data->width; 127 } 128 129 /*! 130 \brief Assign a brush 131 132 The brush is used for the Box style. 133 134 \param brush Brush 135 \sa brush() 136 */ 137 void QwtIntervalSymbol::setBrush( const QBrush& brush ) 138 { 139 m_data->brush = brush; 140 } 141 142 /*! 143 \return Brush 144 \sa setBrush() 145 */ 150 146 const QBrush& QwtIntervalSymbol::brush() const 151 147 { 152 return d_data->brush;153 } 154 155 /*! 156 Build and assign a pen 157 158 In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it 159 non cosmetic ( see QPen::isCosmetic() ). This method has been introduced 160 to hide this incompatibility. 161 162 \param color Pen color 163 \param width Pen width 164 \param style Pen style 165 166 \sa pen(), brush() 167 */ 168 void QwtIntervalSymbol::setPen( const QColor &color,148 return m_data->brush; 149 } 150 151 /*! 152 Build and assign a pen 153 154 In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it 155 non cosmetic ( see QPen::isCosmetic() ). This method has been introduced 156 to hide this incompatibility. 157 158 \param color Pen color 159 \param width Pen width 160 \param style Pen style 161 162 \sa pen(), brush() 163 */ 164 void QwtIntervalSymbol::setPen( const QColor& color, 169 165 qreal width, Qt::PenStyle style ) 170 166 { … … 173 169 174 170 /*! 175 Assign a pen 176 177 \param pen Pen 178 \sa pen(), setBrush() 179 */ 180 void QwtIntervalSymbol::setPen( const QPen &pen )181 { 182 d_data->pen = pen;183 } 184 185 /*! 186 \return Pen 187 \sa setPen(), brush() 188 */ 171 Assign a pen 172 173 \param pen Pen 174 \sa pen(), setBrush() 175 */ 176 void QwtIntervalSymbol::setPen( const QPen& pen ) 177 { 178 m_data->pen = pen; 179 } 180 181 /*! 182 \return Pen 183 \sa setPen(), brush() 184 */ 189 185 const QPen& QwtIntervalSymbol::pen() const 190 186 { 191 return d_data->pen;192 } 193 194 /*! 195 Draw a symbol depending on its style 196 197 \param painter Painter 198 \param orientation Orientation 199 \param from Start point of the interval in target device coordinates 200 \param to End point of the interval in target device coordinates 201 202 \sa setStyle() 203 */ 204 void QwtIntervalSymbol::draw( QPainter *painter, Qt::Orientation orientation,205 const QPointF &from, const QPointF&to ) const206 { 207 const qreal pw = qMax( painter->pen().widthF(), qreal( 1.0) );187 return m_data->pen; 188 } 189 190 /*! 191 Draw a symbol depending on its style 192 193 \param painter Painter 194 \param orientation Orientation 195 \param from Start point of the interval in target device coordinates 196 \param to End point of the interval in target device coordinates 197 198 \sa setStyle() 199 */ 200 void QwtIntervalSymbol::draw( QPainter* painter, Qt::Orientation orientation, 201 const QPointF& from, const QPointF& to ) const 202 { 203 const qreal pw = QwtPainter::effectivePenWidth( painter->pen() ); 208 204 209 205 QPointF p1 = from; … … 215 211 } 216 212 217 switch ( d_data->style )213 switch ( m_data->style ) 218 214 { 219 215 case QwtIntervalSymbol::Bar: 220 216 { 221 217 QwtPainter::drawLine( painter, p1, p2 ); 222 if ( d_data->width > pw )218 if ( m_data->width > pw ) 223 219 { 224 220 if ( ( orientation == Qt::Horizontal ) 225 221 && ( p1.y() == p2.y() ) ) 226 222 { 227 const double sw = d_data->width;223 const double sw = m_data->width; 228 224 229 225 const double y = p1.y() - sw / 2; … … 236 232 && ( p1.x() == p2.x() ) ) 237 233 { 238 const double sw = d_data->width;234 const double sw = m_data->width; 239 235 240 236 const double x = p1.x() - sw / 2; … … 246 242 else 247 243 { 248 const double sw = d_data->width;244 const double sw = m_data->width; 249 245 250 246 const double dx = p2.x() - p1.x(); 251 247 const double dy = p2.y() - p1.y(); 252 const double angle = qAtan2( dy, dx ) + M_PI_2;248 const double angle = std::atan2( dy, dx ) + M_PI_2; 253 249 double dw2 = sw / 2.0; 254 250 … … 268 264 case QwtIntervalSymbol::Box: 269 265 { 270 if ( d_data->width <= pw )266 if ( m_data->width <= pw ) 271 267 { 272 268 QwtPainter::drawLine( painter, p1, p2 ); … … 277 273 && ( p1.y() == p2.y() ) ) 278 274 { 279 const double sw = d_data->width;280 281 const double y = p1.y() - d_data->width / 2;275 const double sw = m_data->width; 276 277 const double y = p1.y() - m_data->width / 2; 282 278 QwtPainter::drawRect( painter, 283 279 p1.x(), y, p2.x() - p1.x(), sw ); … … 286 282 && ( p1.x() == p2.x() ) ) 287 283 { 288 const double sw = d_data->width;289 290 const double x = p1.x() - d_data->width / 2;284 const double sw = m_data->width; 285 286 const double x = p1.x() - m_data->width / 2; 291 287 QwtPainter::drawRect( painter, 292 288 x, p1.y(), sw, p2.y() - p1.y() ); … … 294 290 else 295 291 { 296 const double sw = d_data->width;292 const double sw = m_data->width; 297 293 298 294 const double dx = p2.x() - p1.x(); 299 295 const double dy = p2.y() - p1.y(); 300 const double angle = qAtan2( dy, dx ) + M_PI_2;296 const double angle = std::atan2( dy, dx ) + M_PI_2; 301 297 double dw2 = sw / 2.0; 302 298
Note:
See TracChangeset
for help on using the changeset viewer.
