qwt_abstract_scale.cpp
Go to the documentation of this file.
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
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 #include <qevent.h>
17 
19 {
20 public:
22  maxMajor( 5 ),
23  maxMinor( 3 ),
24  stepSize( 0.0 )
25  {
27  scaleDraw = new QwtScaleDraw();
28  }
29 
31  {
32  delete scaleEngine;
33  delete scaleDraw;
34  }
35 
38 
39  int maxMajor;
40  int maxMinor;
41  double stepSize;
42 };
43 
57  QWidget( parent )
58 {
59  d_data = new PrivateData;
60  rescale( 0.0, 100.0, d_data->stepSize );
61 }
62 
65 {
66  delete d_data;
67 }
68 
78 void QwtAbstractScale::setLowerBound( double value )
79 {
80  setScale( value, upperBound() );
81 }
82 
87 double QwtAbstractScale::lowerBound() const
88 {
89  return d_data->scaleDraw->scaleDiv().lowerBound();
90 }
91 
102 {
103  setScale( lowerBound(), value );
104 }
105 
110 double QwtAbstractScale::upperBound() const
111 {
112  return d_data->scaleDraw->scaleDiv().upperBound();
113 }
114 
130 {
131  rescale( lowerBound, upperBound, d_data->stepSize );
132 }
133 
145 {
146  setScale( interval.minValue(), interval.maxValue() );
147 }
148 
158 {
159  if ( scaleDiv != d_data->scaleDraw->scaleDiv() )
160  {
161 #if 1
162  if ( d_data->scaleEngine )
163  {
166  }
167 #endif
168 
169  d_data->scaleDraw->setScaleDiv( scaleDiv );
170 
171  scaleChange();
172  }
173 }
174 
189 {
190  if ( ticks != d_data->maxMajor )
191  {
192  d_data->maxMajor = ticks;
193  updateScaleDraw();
194  }
195 }
196 
202 {
203  return d_data->maxMajor;
204 }
205 
219 {
220  if ( ticks != d_data->maxMinor )
221  {
222  d_data->maxMinor = ticks;
223  updateScaleDraw();
224  }
225 }
226 
232 {
233  return d_data->maxMinor;
234 }
235 
250 void QwtAbstractScale::setScaleStepSize( double stepSize )
251 {
252  if ( stepSize != d_data->stepSize )
253  {
254  d_data->stepSize = stepSize;
255  updateScaleDraw();
256  }
257 }
258 
263 double QwtAbstractScale::scaleStepSize() const
264 {
265  return d_data->stepSize;
266 }
267 
277 {
278  if ( scaleDraw == NULL || scaleDraw == d_data->scaleDraw )
279  return;
280 
281  if ( d_data->scaleDraw != NULL )
282  scaleDraw->setScaleDiv( d_data->scaleDraw->scaleDiv() );
283 
284  delete d_data->scaleDraw;
285  d_data->scaleDraw = scaleDraw;
286 }
287 
293 {
294  return d_data->scaleDraw;
295 }
296 
302 {
303  return d_data->scaleDraw;
304 }
305 
316 {
317  if ( scaleEngine != NULL && scaleEngine != d_data->scaleEngine )
318  {
319  delete d_data->scaleEngine;
321  }
322 }
323 
329 {
330  return d_data->scaleEngine;
331 }
332 
338 {
339  return d_data->scaleEngine;
340 }
341 
349 {
350  return d_data->scaleDraw->scaleDiv();
351 }
352 
357 {
358  return d_data->scaleDraw->scaleMap();
359 }
360 
368 int QwtAbstractScale::transform( double value ) const
369 {
370  return qRound( d_data->scaleDraw->scaleMap().transform( value ) );
371 }
372 
380 double QwtAbstractScale::invTransform( int value ) const
381 {
382  return d_data->scaleDraw->scaleMap().invTransform( value );
383 }
384 
390 {
391  return d_data->scaleDraw->scaleMap().isInverting();
392 }
393 
399 {
400  return qMin( d_data->scaleDraw->scaleDiv().lowerBound(),
402 }
403 
409 {
410  return qMax( d_data->scaleDraw->scaleDiv().lowerBound(),
412 }
413 
416 {
417 }
418 
429  double lowerBound, double upperBound, double stepSize )
430 {
432  lowerBound, upperBound, d_data->maxMajor, d_data->maxMinor, stepSize );
433 
434  if ( scaleDiv != d_data->scaleDraw->scaleDiv() )
435  {
436 #if 1
439 #endif
440 
441  d_data->scaleDraw->setScaleDiv( scaleDiv );
442  scaleChange();
443  }
444 }
445 
452 void QwtAbstractScale::changeEvent( QEvent *event )
453 {
454  if ( event->type() == QEvent::LocaleChange )
455  {
457  }
458 
459  QWidget::changeEvent( event );
460 }
461 
466 {
469 }
A abstract base class for drawing scales.
void setScale(double lowerBound, double upperBound)
Specify a scale.
void setScaleEngine(QwtScaleEngine *)
Set a scale engine.
QwtAbstractScaleDraw * scaleDraw
void setAbstractScaleDraw(QwtAbstractScaleDraw *)
Set a scale draw.
virtual void scaleChange()
Notify changed scale.
int scaleMaxMinor() const
int transform(double) const
A class representing an interval.
Definition: qwt_interval.h:26
double minValue() const
Definition: qwt_interval.h:193
double scaleStepSize() const
const QwtScaleMap & scaleMap() const
void setScaleStepSize(double stepSize)
Set the step size used for calculating a scale division.
A class representing a scale division.
Definition: qwt_scale_div.h:36
const QwtScaleMap & scaleMap() const
void setLowerBound(double value)
QwtTransform * transformation() const
double maxValue() const
Definition: qwt_interval.h:199
double upperBound() const
void setScaleMaxMajor(int ticks)
Set the maximum number of major tick intervals.
double minimum() const
double invTransform(int) const
const QwtScaleDiv & scaleDiv() const
const QwtScaleDiv & scaleDiv() const
double lowerBound() const
PrivateData * d_data
const QwtAbstractScaleDraw * abstractScaleDraw() const
void setScaleMaxMinor(int ticks)
Set the maximum number of minor tick intervals.
A scale map.
Definition: qwt_scale_map.h:30
double invTransform(double p) const
bool isInverted() const
virtual void changeEvent(QEvent *)
const QwtScaleEngine * scaleEngine() const
double lowerBound() const
int scaleMaxMajor() const
void setScaleDiv(const QwtScaleDiv &s)
void setTransformation(QwtTransform *)
double maximum() const
A class for drawing scales.
A scale engine for linear scales.
bool isInverting() const
double transform(double s) const
virtual ~QwtAbstractScale()
Destructor.
virtual QwtScaleDiv divideScale(double x1, double x2, int maxMajorSteps, int maxMinorSteps, double stepSize=0.0) const =0
Calculate a scale division.
void rescale(double lowerBound, double upperBound, double stepSize)
void setUpperBound(double value)
double upperBound() const
QwtAbstractScale(QWidget *parent=NULL)
Base class for scale engines.


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:17