Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_plot_abstract_barchart.cpp
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_plot_abstract_barchart.cpp (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_plot_abstract_barchart.cpp
r9383 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 10 10 #include "qwt_plot_abstract_barchart.h" 11 11 #include "qwt_scale_map.h" 12 #include "qwt_math.h" 12 13 13 14 static inline double qwtTransformWidth( 14 const QwtScaleMap &map, double value, double width )15 const QwtScaleMap& map, double value, double width ) 15 16 { 16 17 const double w2 = 0.5 * width; … … 24 25 class QwtPlotAbstractBarChart::PrivateData 25 26 { 26 public: 27 PrivateData() :28 layoutPolicy( QwtPlotAbstractBarChart::AutoAdjustSamples ) ,29 layoutHint( 0.5 ) ,30 spacing( 10 ) ,31 margin( 5 ) ,32 baseline( 0.0 ) 27 public: 28 PrivateData() 29 : layoutPolicy( QwtPlotAbstractBarChart::AutoAdjustSamples ) 30 , layoutHint( 0.5 ) 31 , spacing( 10 ) 32 , margin( 5 ) 33 , baseline( 0.0 ) 33 34 { 34 35 } … … 42 43 43 44 /*! 44 Constructor 45 \param title Title of the chart 46 */ 47 QwtPlotAbstractBarChart::QwtPlotAbstractBarChart( const QwtText &title ):48 QwtPlotSeriesItem( title ) 49 { 50 d_data = new PrivateData;45 Constructor 46 \param title Title of the chart 47 */ 48 QwtPlotAbstractBarChart::QwtPlotAbstractBarChart( const QwtText& title ) 49 : QwtPlotSeriesItem( title ) 50 { 51 m_data = new PrivateData; 51 52 52 53 setItemAttribute( QwtPlotItem::Legend, true ); … … 59 60 QwtPlotAbstractBarChart::~QwtPlotAbstractBarChart() 60 61 { 61 delete d_data;62 } 63 64 /*! 65 The combination of layoutPolicy() and layoutHint() define how the width 66 of the bars is calculated 67 68 \param policy Layout policy 69 70 \sa layoutPolicy(), layoutHint() 62 delete m_data; 63 } 64 65 /*! 66 The combination of layoutPolicy() and layoutHint() define how the width 67 of the bars is calculated 68 69 \param policy Layout policy 70 71 \sa layoutPolicy(), layoutHint() 71 72 */ 72 73 void QwtPlotAbstractBarChart::setLayoutPolicy( LayoutPolicy policy ) 73 74 { 74 if ( policy != d_data->layoutPolicy )75 { 76 d_data->layoutPolicy = policy;77 itemChanged(); 78 } 79 } 80 81 /*! 82 The combination of layoutPolicy() and layoutHint() define how the width 83 of the bars is calculated 84 85 \return Layout policy of the chart item 86 \sa setLayoutPolicy(), layoutHint() 75 if ( policy != m_data->layoutPolicy ) 76 { 77 m_data->layoutPolicy = policy; 78 itemChanged(); 79 } 80 } 81 82 /*! 83 The combination of layoutPolicy() and layoutHint() define how the width 84 of the bars is calculated 85 86 \return Layout policy of the chart item 87 \sa setLayoutPolicy(), layoutHint() 87 88 */ 88 89 QwtPlotAbstractBarChart::LayoutPolicy QwtPlotAbstractBarChart::layoutPolicy() const 89 90 { 90 return d_data->layoutPolicy;91 } 92 93 /*! 94 The combination of layoutPolicy() and layoutHint() define how the width 95 of the bars is calculated 96 97 \param hint Layout hint 98 99 \sa LayoutPolicy, layoutPolicy(), layoutHint() 91 return m_data->layoutPolicy; 92 } 93 94 /*! 95 The combination of layoutPolicy() and layoutHint() define how the width 96 of the bars is calculated 97 98 \param hint Layout hint 99 100 \sa LayoutPolicy, layoutPolicy(), layoutHint() 100 101 */ 101 102 void QwtPlotAbstractBarChart::setLayoutHint( double hint ) 102 103 { 103 hint = q Max( 0.0, hint );104 if ( hint != d_data->layoutHint )105 { 106 d_data->layoutHint = hint;107 itemChanged(); 108 } 109 } 110 111 /*! 112 The combination of layoutPolicy() and layoutHint() define how the width 113 of the bars is calculated 114 115 \return Layout policy of the chart item 116 \sa LayoutPolicy, setLayoutHint(), layoutPolicy() 117 */ 104 hint = qwtMaxF( 0.0, hint ); 105 if ( hint != m_data->layoutHint ) 106 { 107 m_data->layoutHint = hint; 108 itemChanged(); 109 } 110 } 111 112 /*! 113 The combination of layoutPolicy() and layoutHint() define how the width 114 of the bars is calculated 115 116 \return Layout policy of the chart item 117 \sa LayoutPolicy, setLayoutHint(), layoutPolicy() 118 */ 118 119 double QwtPlotAbstractBarChart::layoutHint() const 119 120 { 120 return d_data->layoutHint;121 } 122 123 /*! 124 \brief Set the spacing 125 126 The spacing is the distance between 2 samples ( bars for QwtPlotBarChart or 127 a group of bars for QwtPlotMultiBarChart ) in paint device coordinates. 128 129 \sa spacing() 121 return m_data->layoutHint; 122 } 123 124 /*! 125 \brief Set the spacing 126 127 The spacing is the distance between 2 samples ( bars for QwtPlotBarChart or 128 a group of bars for QwtPlotMultiBarChart ) in paint device coordinates. 129 130 \sa spacing() 130 131 */ 131 132 void QwtPlotAbstractBarChart::setSpacing( int spacing ) 132 133 { 133 134 spacing = qMax( spacing, 0 ); 134 if ( spacing != d_data->spacing )135 { 136 d_data->spacing = spacing;137 itemChanged(); 138 } 139 } 140 141 /*! 142 \return Spacing between 2 samples ( bars or groups of bars ) 143 \sa setSpacing(), margin() 135 if ( spacing != m_data->spacing ) 136 { 137 m_data->spacing = spacing; 138 itemChanged(); 139 } 140 } 141 142 /*! 143 \return Spacing between 2 samples ( bars or groups of bars ) 144 \sa setSpacing(), margin() 144 145 */ 145 146 int QwtPlotAbstractBarChart::spacing() const 146 147 { 147 return d_data->spacing;148 } 149 /*! 150 \brief Set the margin 151 152 The margin is the distance between the outmost bars and the contentsRect() 153 of the canvas. The default setting is 5 pixels. 154 155 \param margin Margin 156 157 \sa spacing(), margin() 148 return m_data->spacing; 149 } 150 /*! 151 \brief Set the margin 152 153 The margin is the distance between the outmost bars and the contentsRect() 154 of the canvas. The default setting is 5 pixels. 155 156 \param margin Margin 157 158 \sa spacing(), margin() 158 159 */ 159 160 void QwtPlotAbstractBarChart::setMargin( int margin ) 160 161 { 161 162 margin = qMax( margin, 0 ); 162 if ( margin != d_data->margin )163 { 164 d_data->margin = margin;165 itemChanged(); 166 } 167 } 168 169 /*! 170 \return Margin between the outmost bars and the contentsRect() 171 of the canvas. 172 173 \sa setMargin(), spacing() 163 if ( margin != m_data->margin ) 164 { 165 m_data->margin = margin; 166 itemChanged(); 167 } 168 } 169 170 /*! 171 \return Margin between the outmost bars and the contentsRect() 172 of the canvas. 173 174 \sa setMargin(), spacing() 174 175 */ 175 176 int QwtPlotAbstractBarChart::margin() const 176 177 { 177 return d_data->margin;178 return m_data->margin; 178 179 } 179 180 … … 191 192 192 193 \sa baseline(), QwtPlotSeriesItem::orientation() 193 */ 194 */ 194 195 void QwtPlotAbstractBarChart::setBaseline( double value ) 195 196 { 196 if ( value != d_data->baseline )197 { 198 d_data->baseline = value;197 if ( value != m_data->baseline ) 198 { 199 m_data->baseline = value; 199 200 itemChanged(); 200 201 } … … 207 208 double QwtPlotAbstractBarChart::baseline() const 208 209 { 209 return d_data->baseline;210 return m_data->baseline; 210 211 } 211 212 … … 221 222 \return Sample width 222 223 \sa layoutPolicy(), layoutHint() 223 */ 224 double QwtPlotAbstractBarChart::sampleWidth( const QwtScaleMap &map,224 */ 225 double QwtPlotAbstractBarChart::sampleWidth( const QwtScaleMap& map, 225 226 double canvasSize, double boundingSize, double value ) const 226 227 { 227 228 double width; 228 229 229 switch( d_data->layoutPolicy )230 switch( m_data->layoutPolicy ) 230 231 { 231 232 case ScaleSamplesToAxes: 232 233 { 233 width = qwtTransformWidth( map, value, d_data->layoutHint );234 width = qwtTransformWidth( map, value, m_data->layoutHint ); 234 235 break; 235 236 } 236 237 case ScaleSampleToCanvas: 237 238 { 238 width = canvasSize * d_data->layoutHint;239 width = canvasSize * m_data->layoutHint; 239 240 break; 240 241 } 241 242 case FixedSampleSize: 242 243 { 243 width = d_data->layoutHint;244 width = m_data->layoutHint; 244 245 break; 245 246 } … … 256 257 257 258 width = qwtTransformWidth( map, value, w ); 258 width -= d_data->spacing;259 width = q Max( width,d_data->layoutHint );259 width -= m_data->spacing; 260 width = qwtMaxF( width, m_data->layoutHint ); 260 261 } 261 262 } … … 281 282 \param bottom Returns the bottom margin 282 283 283 \return Margin284 285 284 \sa layoutPolicy(), layoutHint(), QwtPlotItem::Margins 286 285 QwtPlot::getCanvasMarginsHint(), QwtPlot::updateCanvasMargins() 287 286 */ 288 void QwtPlotAbstractBarChart::getCanvasMarginHint( const QwtScaleMap &xMap,289 const QwtScaleMap &yMap, const QRectF&canvasRect,290 double &left, double&top, double&right, double&bottom ) const287 void QwtPlotAbstractBarChart::getCanvasMarginHint( const QwtScaleMap& xMap, 288 const QwtScaleMap& yMap, const QRectF& canvasRect, 289 double& left, double& top, double& right, double& bottom ) const 291 290 { 292 291 double hint = -1.0; … … 297 296 { 298 297 if ( orientation() == Qt::Vertical ) 299 hint = 0.5 * canvasRect.width() * d_data->layoutHint;298 hint = 0.5 * canvasRect.width() * m_data->layoutHint; 300 299 else 301 hint = 0.5 * canvasRect.height() * d_data->layoutHint;300 hint = 0.5 * canvasRect.height() * m_data->layoutHint; 302 301 303 302 break; … … 305 304 case FixedSampleSize: 306 305 { 307 hint = 0.5 * d_data->layoutHint;306 hint = 0.5 * m_data->layoutHint; 308 307 break; 309 308 } … … 324 323 if ( layoutPolicy() == ScaleSamplesToAxes ) 325 324 { 326 sampleWidthS = q Max( d_data->layoutHint, 0.0 );325 sampleWidthS = qwtMaxF( m_data->layoutHint, 0.0 ); 327 326 } 328 327 else 329 328 { 330 spacing = d_data->spacing;329 spacing = m_data->spacing; 331 330 332 331 if ( numSamples > 1 ) … … 352 351 353 352 hint = 0.5 * sampleWidthP; 354 hint += qMax( d_data->margin, 0 );353 hint += qMax( m_data->margin, 0 ); 355 354 } 356 355 }
Note:
See TracChangeset
for help on using the changeset viewer.
