qwt_abstract_scale.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * Qwt Widget Library
3  * Copyright (C) 1997 Josef Wilgen
4  * Copyright (C) 2002 Uwe Rathmann
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the Qwt License, Version 1.0
8  *****************************************************************************/
9 
10 #include "qwt_abstract_scale.h"
11 #include "qwt_scale_engine.h"
12 #include "qwt_scale_draw.h"
13 #include "qwt_scale_div.h"
14 #include "qwt_scale_map.h"
15 #include "qwt_interval.h"
16 
17 #include <qcoreevent.h>
18 
20 {
21  public:
22  PrivateData():
23  maxMajor( 5 ),
24  maxMinor( 3 ),
25  stepSize( 0.0 )
26  {
28  scaleDraw = new QwtScaleDraw();
29  }
30 
31  ~PrivateData()
32  {
33  delete scaleEngine;
34  delete scaleDraw;
35  }
36 
39 
40  int maxMajor;
41  int maxMinor;
42  double stepSize;
43 };
44 
58  : QWidget( parent )
59 {
60  m_data = new PrivateData;
61  rescale( 0.0, 100.0, m_data->stepSize );
62 }
63 
66 {
67  delete m_data;
68 }
69 
79 void QwtAbstractScale::setLowerBound( double value )
80 {
81  setScale( value, upperBound() );
82 }
83 
88 double QwtAbstractScale::lowerBound() const
89 {
90  return m_data->scaleDraw->scaleDiv().lowerBound();
91 }
92 
103 {
104  setScale( lowerBound(), value );
105 }
106 
111 double QwtAbstractScale::upperBound() const
112 {
113  return m_data->scaleDraw->scaleDiv().upperBound();
114 }
115 
130 void QwtAbstractScale::setScale( double lowerBound, double upperBound )
131 {
133 }
134 
146 {
147  setScale( interval.minValue(), interval.maxValue() );
148 }
149 
159 {
160  if ( scaleDiv != m_data->scaleDraw->scaleDiv() )
161  {
162 #if 1
163  if ( m_data->scaleEngine )
164  {
167  }
168 #endif
169 
171 
172  scaleChange();
173  }
174 }
175 
190 {
191  if ( ticks != m_data->maxMajor )
192  {
193  m_data->maxMajor = ticks;
194  updateScaleDraw();
195  }
196 }
197 
203 {
204  return m_data->maxMajor;
205 }
206 
220 {
221  if ( ticks != m_data->maxMinor )
222  {
223  m_data->maxMinor = ticks;
224  updateScaleDraw();
225  }
226 }
227 
233 {
234  return m_data->maxMinor;
235 }
236 
251 void QwtAbstractScale::setScaleStepSize( double stepSize )
252 {
253  if ( stepSize != m_data->stepSize )
254  {
255  m_data->stepSize = stepSize;
256  updateScaleDraw();
257  }
258 }
259 
264 double QwtAbstractScale::scaleStepSize() const
265 {
266  return m_data->stepSize;
267 }
268 
278 {
279  if ( scaleDraw == NULL || scaleDraw == m_data->scaleDraw )
280  return;
281 
282  if ( m_data->scaleDraw != NULL )
283  scaleDraw->setScaleDiv( m_data->scaleDraw->scaleDiv() );
284 
285  delete m_data->scaleDraw;
286  m_data->scaleDraw = scaleDraw;
287 }
288 
294 {
295  return m_data->scaleDraw;
296 }
297 
303 {
304  return m_data->scaleDraw;
305 }
306 
317 {
318  if ( scaleEngine != NULL && scaleEngine != m_data->scaleEngine )
319  {
320  delete m_data->scaleEngine;
322  }
323 }
324 
330 {
331  return m_data->scaleEngine;
332 }
333 
339 {
340  return m_data->scaleEngine;
341 }
342 
350 {
351  return m_data->scaleDraw->scaleDiv();
352 }
353 
358 {
359  return m_data->scaleDraw->scaleMap();
360 }
361 
369 int QwtAbstractScale::transform( double value ) const
370 {
371  return qRound( m_data->scaleDraw->scaleMap().transform( value ) );
372 }
373 
381 double QwtAbstractScale::invTransform( int value ) const
382 {
383  return m_data->scaleDraw->scaleMap().invTransform( value );
384 }
385 
391 {
392  return m_data->scaleDraw->scaleMap().isInverting();
393 }
394 
400 {
401  return qMin( m_data->scaleDraw->scaleDiv().lowerBound(),
403 }
404 
410 {
411  return qMax( m_data->scaleDraw->scaleDiv().lowerBound(),
413 }
414 
417 {
418 }
419 
430  double lowerBound, double upperBound, double stepSize )
431 {
434 
435  if ( scaleDiv != m_data->scaleDraw->scaleDiv() )
436  {
437 #if 1
440 #endif
441 
443  scaleChange();
444  }
445 }
446 
453 void QwtAbstractScale::changeEvent( QEvent* event )
454 {
455  if ( event->type() == QEvent::LocaleChange )
456  {
458  }
459 
460  QWidget::changeEvent( event );
461 }
462 
467 {
470 }
471 
472 #if QWT_MOC_INCLUDE
473 #include "moc_qwt_abstract_scale.cpp"
474 #endif
QwtScaleDraw
A class for drawing scales.
Definition: qwt_scale_draw.h:35
QwtAbstractScale::PrivateData::maxMajor
int maxMajor
Definition: qwt_abstract_scale.cpp:47
QwtAbstractScaleDraw::setTransformation
void setTransformation(QwtTransform *)
Definition: qwt_abstract_scale_draw.cpp:115
QwtScaleMap::invTransform
double invTransform(double p) const
Definition: qwt_scale_map.h:154
QwtAbstractScale::scaleMap
const QwtScaleMap & scaleMap() const
Definition: qwt_abstract_scale.cpp:357
qwt_scale_div.h
QwtAbstractScale::~QwtAbstractScale
virtual ~QwtAbstractScale()
Destructor.
Definition: qwt_abstract_scale.cpp:65
QwtAbstractScale::PrivateData::stepSize
double stepSize
Definition: qwt_abstract_scale.cpp:49
QwtInterval::minValue
double minValue() const
Definition: qwt_interval.h:192
QwtAbstractScaleDraw::scaleMap
const QwtScaleMap & scaleMap() const
Definition: qwt_abstract_scale_draw.cpp:121
QwtAbstractScaleDraw::setScaleDiv
void setScaleDiv(const QwtScaleDiv &)
Definition: qwt_abstract_scale_draw.cpp:104
QwtAbstractScale::scaleEngine
const QwtScaleEngine * scaleEngine() const
Definition: qwt_abstract_scale.cpp:329
QwtAbstractScale::setLowerBound
void setLowerBound(double value)
Definition: qwt_abstract_scale.cpp:79
QwtScaleEngine::transformation
QwtTransform * transformation() const
Definition: qwt_scale_engine.cpp:265
QwtAbstractScale::maximum
double maximum() const
Definition: qwt_abstract_scale.cpp:409
QwtAbstractScaleDraw::invalidateCache
void invalidateCache()
Definition: qwt_abstract_scale_draw.cpp:420
QwtAbstractScaleDraw::scaleDiv
const QwtScaleDiv & scaleDiv() const
Definition: qwt_abstract_scale_draw.cpp:133
qwt_interval.h
QwtScaleDiv::lowerBound
double lowerBound() const
Definition: qwt_scale_div.cpp:131
QwtLinearScaleEngine
A scale engine for linear scales.
Definition: qwt_scale_engine.h:151
QwtAbstractScale::lowerBound
double lowerBound
Definition: qwt_abstract_scale.h:40
QwtAbstractScale::rescale
void rescale(double lowerBound, double upperBound, double stepSize)
Definition: qwt_abstract_scale.cpp:429
QwtAbstractScale::upperBound
double upperBound
Definition: qwt_abstract_scale.h:41
QwtScaleMap::isInverting
bool isInverting() const
Definition: qwt_scale_map.h:164
QwtAbstractScale::PrivateData::maxMinor
int maxMinor
Definition: qwt_abstract_scale.cpp:48
QwtAbstractScale::setAbstractScaleDraw
void setAbstractScaleDraw(QwtAbstractScaleDraw *)
Set a scale draw.
Definition: qwt_abstract_scale.cpp:277
QwtAbstractScale::scaleChange
virtual void scaleChange()
Notify changed scale.
Definition: qwt_abstract_scale.cpp:416
qwt_abstract_scale.h
QwtAbstractScale::setScaleStepSize
void setScaleStepSize(double stepSize)
Set the step size used for calculating a scale division.
Definition: qwt_abstract_scale.cpp:251
QwtInterval
A class representing an interval.
Definition: qwt_interval.h:22
QwtAbstractScale::setScaleMaxMajor
void setScaleMaxMajor(int ticks)
Set the maximum number of major tick intervals.
Definition: qwt_abstract_scale.cpp:189
QwtAbstractScale::invTransform
double invTransform(int) const
Definition: qwt_abstract_scale.cpp:381
qwt_scale_map.h
QwtAbstractScale::PrivateData::scaleEngine
QwtScaleEngine * scaleEngine
Definition: qwt_abstract_scale.cpp:44
QwtAbstractScale::transform
int transform(double) const
Definition: qwt_abstract_scale.cpp:369
QwtAbstractScale::scaleDiv
const QwtScaleDiv & scaleDiv() const
Definition: qwt_abstract_scale.cpp:349
QwtScaleDiv::upperBound
double upperBound() const
Definition: qwt_scale_div.cpp:151
QwtAbstractScale::minimum
double minimum() const
Definition: qwt_abstract_scale.cpp:399
QwtAbstractScale::setUpperBound
void setUpperBound(double value)
Definition: qwt_abstract_scale.cpp:102
QwtAbstractScale::updateScaleDraw
void updateScaleDraw()
Definition: qwt_abstract_scale.cpp:466
qwt_scale_draw.h
QwtAbstractScale::setScaleMaxMinor
void setScaleMaxMinor(int ticks)
Set the maximum number of minor tick intervals.
Definition: qwt_abstract_scale.cpp:219
QwtAbstractScaleDraw
A abstract base class for drawing scales.
Definition: qwt_abstract_scale_draw.h:31
QwtScaleEngine::divideScale
virtual QwtScaleDiv divideScale(double x1, double x2, int maxMajorSteps, int maxMinorSteps, double stepSize=0.0) const =0
Calculate a scale division.
QwtAbstractScale::scaleStepSize
double scaleStepSize
Definition: qwt_abstract_scale.h:46
QwtScaleMap::transform
double transform(double s) const
Definition: qwt_scale_map.h:137
QwtScaleMap
A scale map.
Definition: qwt_scale_map.h:26
QwtScaleEngine
Base class for scale engines.
Definition: qwt_scale_engine.h:45
QwtAbstractScale::PrivateData::PrivateData
PrivateData()
Definition: qwt_abstract_scale.cpp:29
QwtAbstractScale::scaleMaxMajor
int scaleMaxMajor
Definition: qwt_abstract_scale.h:43
QwtAbstractScale::QwtAbstractScale
QwtAbstractScale(QWidget *parent=NULL)
Definition: qwt_abstract_scale.cpp:57
qwt_scale_engine.h
QwtAbstractScale::scaleMaxMinor
int scaleMaxMinor
Definition: qwt_abstract_scale.h:44
QwtAbstractScale::abstractScaleDraw
const QwtAbstractScaleDraw * abstractScaleDraw() const
Definition: qwt_abstract_scale.cpp:293
QwtAbstractScale::setScale
void setScale(double lowerBound, double upperBound)
Specify a scale.
Definition: qwt_abstract_scale.cpp:130
QwtInterval::maxValue
double maxValue() const
Definition: qwt_interval.h:198
QwtAbstractScale::m_data
PrivateData * m_data
Definition: qwt_abstract_scale.h:102
QwtAbstractScale::setScaleEngine
void setScaleEngine(QwtScaleEngine *)
Set a scale engine.
Definition: qwt_abstract_scale.cpp:316
QwtScaleDiv
A class representing a scale division.
Definition: qwt_scale_div.h:33
QwtAbstractScale::isInverted
bool isInverted() const
Definition: qwt_abstract_scale.cpp:390
QwtAbstractScale::changeEvent
virtual void changeEvent(QEvent *) QWT_OVERRIDE
Definition: qwt_abstract_scale.cpp:453
QwtAbstractScale::PrivateData
Definition: qwt_abstract_scale.cpp:19
QwtAbstractScale::PrivateData::~PrivateData
~PrivateData()
Definition: qwt_abstract_scale.cpp:38
QwtAbstractScale::PrivateData::scaleDraw
QwtAbstractScaleDraw * scaleDraw
Definition: qwt_abstract_scale.cpp:45


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:45