KD Chart 2  [rev.2.7]
KDChartAbstractCoordinatePlane.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2001-2020 Klaralvdalens Datakonsult AB. All rights reserved.
3 **
4 ** This file is part of the KD Chart library.
5 **
6 ** Licensees holding valid commercial KD Chart licenses may use this file in
7 ** accordance with the KD Chart Commercial License Agreement provided with
8 ** the Software.
9 **
10 **
11 ** This file may be distributed and/or modified under the terms of the
12 ** GNU General Public License version 2 and version 3 as published by the
13 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included.
14 **
15 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17 **
18 ** Contact info@kdab.com if any conditions of this licensing are not
19 ** clear to you.
20 **
21 **********************************************************************/
22 
23 #ifndef KDCHARTABSTRACTCOORDINATEPLANE_H
24 #define KDCHARTABSTRACTCOORDINATEPLANE_H
25 
26 #include <QObject>
27 #include <QList>
28 
29 #include "KDChartAbstractArea.h"
30 #include "KDChartAbstractDiagram.h"
31 #include "KDChartEnums.h"
32 
33 namespace KDChart {
34 
35  class Chart;
36  class GridAttributes;
38 
40 
44  class KDCHART_EXPORT AbstractCoordinatePlane : public AbstractArea
45  {
46  Q_OBJECT
47 
49 
50  friend class AbstractGrid;
51 
52  public:
53  enum AxesCalcMode { Linear, Logarithmic };
54 
55  protected:
56  explicit AbstractCoordinatePlane( Chart* parent = 0 );
57 
58  public:
59  ~AbstractCoordinatePlane() override;
60 
67  virtual void addDiagram( AbstractDiagram* diagram );
68 
86  virtual void replaceDiagram( AbstractDiagram* diagram, AbstractDiagram* oldDiagram = 0 );
87 
96  virtual void takeDiagram( AbstractDiagram* diagram );
97 
101  AbstractDiagram* diagram();
102 
106  AbstractDiagramList diagrams();
107 
111  ConstAbstractDiagramList diagrams() const;
112 
116  virtual void layoutDiagrams() = 0;
117 
124  virtual const QPointF translate( const QPointF& diagramPoint ) const = 0;
125 
129  bool isRubberBandZoomingEnabled() const;
130 
134  void setRubberBandZoomingEnabled( bool enable );
135 
140  virtual qreal zoomFactorX() const { return 1.0; }
141 
146  virtual qreal zoomFactorY() const { return 1.0; }
147 
152  virtual void setZoomFactors( qreal factorX, qreal factorY ) { Q_UNUSED( factorX ); Q_UNUSED( factorY ); }
153 
159  virtual void setZoomFactorX( qreal factor ) { Q_UNUSED( factor ); }
160 
166  virtual void setZoomFactorY( qreal factor ) { Q_UNUSED( factor ); }
167 
172  virtual QPointF zoomCenter() const { return QPointF(0.0, 0.0); }
173 
179  virtual void setZoomCenter( const QPointF& center ) { Q_UNUSED( center ); }
180 
192  void setGlobalGridAttributes( const GridAttributes & );
193 
199  GridAttributes globalGridAttributes() const;
200 
219  DataDimensionsList gridDimensionsList();
220 
228  void setReferenceCoordinatePlane( AbstractCoordinatePlane * plane );
229 
245  AbstractCoordinatePlane * referenceCoordinatePlane() const;
246 
251  bool isCornerSpacersEnabled() const;
252 
256  void setCornerSpacersEnabled( bool enable );
257 
258  virtual AbstractCoordinatePlane* sharedAxisMasterPlane( QPainter* p = 0 ); // KDChart 3: const method?
259 
260 
262  bool isEmpty() const override;
264  Qt::Orientations expandingDirections() const override;
266  QSize maximumSize() const override;
268  QSize minimumSize() const override;
270  QSize sizeHint() const override;
277  void setGeometry( const QRect& r ) override;
279  QRect geometry() const override;
280 
281  virtual void mousePressEvent( QMouseEvent* event );
282  virtual void mouseDoubleClickEvent( QMouseEvent* event );
283  virtual void mouseMoveEvent( QMouseEvent* event );
284  virtual void mouseReleaseEvent( QMouseEvent* event );
285 
289  void setParent( Chart* parent );
290  Chart* parent();
291  const Chart* parent() const;
292 
298 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)
299  const bool isVisiblePoint( const QPointF& point ) const;
300 #else
301  bool isVisiblePoint( const QPointF& point ) const;
302 #endif
303 
304  public Q_SLOTS:
308  void update();
312  void relayout();
316  void layoutPlanes();
320  void setGridNeedsRecalculate();
321 
322  Q_SIGNALS:
324  void destroyedCoordinatePlane( AbstractCoordinatePlane* );
325 
327  void needUpdate();
328 
330  void needRelayout();
331 
333  void needLayoutPlanes();
334 
336  void propertiesChanged();
337 
338  void boundariesChanged();
339 
345  void geometryChanged( QRect, QRect );
346 
347  private:
348  Q_SIGNALS:
349  // Emitted from inside the setGeometry()
350  // This is connected via QueuedConnection to the geometryChanged() Signal
351  // that users can connect to safely then.
352  void internal_geometryChanged( QRect, QRect );
354  void viewportCoordinateSystemChanged();
355 
356  protected:
357  virtual DataDimensionsList getDataDimensionsList() const = 0;
358 
359  //KDCHART_DECLARE_PRIVATE_DERIVED( AbstractCoordinatePlane )
360  };
361 
379  public:
381  : start( 1.0 )
382  , end( 10.0 )
383  , isCalculated( false )
384  , calcMode( AbstractCoordinatePlane::Linear )
385  , sequence( KDChartEnums::GranularitySequence_10_20 )
386  , stepWidth( 1.0 )
387  , subStepWidth( 0.0 )
388  {}
389  DataDimension( qreal start_,
390  qreal end_,
391  bool isCalculated_,
394  qreal stepWidth_=0.0,
395  qreal subStepWidth_=0.0 )
396  : start( start_ )
397  , end( end_ )
398  , isCalculated( isCalculated_ )
399  , calcMode( calcMode_ )
400  , sequence( sequence_ )
401  , stepWidth( stepWidth_ )
402  , subStepWidth( subStepWidth_ )
403  {}
411  qreal distance() const
412  {
413  return end-start;
414  }
415 
416  bool operator==( const DataDimension& r ) const
417  {
418  return
419  (start == r.start) &&
420  (end == r.end) &&
421  (sequence == r.sequence) &&
422  (isCalculated == r.isCalculated) &&
423  (calcMode == r.calcMode) &&
424  (stepWidth == r.stepWidth) &&
425  (subStepWidth == r.subStepWidth);
426  }
427 
428  bool operator!=( const DataDimension& other ) const
429  { return !operator==( other ); }
430 
431 
432  qreal start;
433  qreal end;
437  qreal stepWidth;
439  };
440 
441 #if !defined(QT_NO_DEBUG_STREAM)
442  QDebug operator<<( QDebug stream, const DataDimension& r );
443 #endif
444 
445 }
446 #endif
Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane, TernaryCoordinatePlane.
Project global class providing some enums needed both by KDChartParams and by KDChartCustomBox.
Definition: KDChartEnums.h:40
bool operator==(const Span &s1, const Span &s2)
An area in the chart with a background, a frame, etc.
A chart with one or more diagrams.
Definition: KDChartChart.h:98
Definition of global enums.
DataDimension(qreal start_, qreal end_, bool isCalculated_, AbstractCoordinatePlane::AxesCalcMode calcMode_, KDChartEnums::GranularitySequence sequence_, qreal stepWidth_=0.0, qreal subStepWidth_=0.0)
bool operator!=(const DataDimension &other) const
KDChartEnums::GranularitySequence sequence
AbstractDiagram defines the interface for diagram classes.
virtual void setZoomFactorX(qreal factor)
Sets the zoom factor in horizontal direction, that is applied to all coordinate transformations.
GranularitySequence
GranularitySequence specifies the values, that may be applied, to determine a step width within a giv...
Definition: KDChartEnums.h:95
QList< DataDimension > DataDimensionsList
virtual void setZoomFactorY(qreal factor)
Sets the zoom factor in vertical direction, that is applied to all coordinate transformations.
bool operator==(const DataDimension &r) const
QPointF translate(const TernaryPoint &point)
A set of attributes controlling the appearance of grids.
qreal distance() const
Returns the size of the distance, equivalent to the width() (or height(), resp.) of a QRectF...
QDebug operator<<(QDebug stream, const DataDimension &r)
virtual void setZoomFactors(qreal factorX, qreal factorY)
Sets both zoom factors in one go.
AbstractCoordinatePlane::AxesCalcMode calcMode
Helper class for one dimension of data, e.g.
virtual void setZoomCenter(const QPointF &center)
Set the point (in value coordinates) to be used as the center point in zoom operations.
#define KDCHART_DECLARE_PRIVATE_DERIVED_PARENT(X, ParentType)
Definition: KDChartGlobal.h:58

Klarälvdalens Datakonsult AB (KDAB)
Qt-related services and products
https://www.kdab.com/
https://www.kdab.com/products/kd-chart/