KChart

KChartAbstractCoordinatePlane.h
1 /*
2  * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3  *
4  * This file is part of the KD Chart library.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef KCHARTABSTRACTCOORDINATEPLANE_H
21 #define KCHARTABSTRACTCOORDINATEPLANE_H
22 
23 #include <QObject>
24 #include <QList>
25 
26 #include "KChartAbstractArea.h"
27 #include "KChartAbstractDiagram.h"
28 #include "KChartEnums.h"
29 
30 namespace KChart {
31 
32  class Chart;
33  class GridAttributes;
34  class DataDimension;
35 
36  typedef QList<DataDimension> DataDimensionsList;
37 
41  class KCHART_EXPORT AbstractCoordinatePlane : public AbstractArea
42  {
43  Q_OBJECT
44 
45  KCHART_DECLARE_PRIVATE_DERIVED_PARENT( AbstractCoordinatePlane, Chart* )
46 
47  friend class AbstractGrid;
48 
49  public:
50  enum AxesCalcMode { Linear, Logarithmic };
51 
52  protected:
53  explicit AbstractCoordinatePlane( Chart* parent = nullptr );
54 
55  public:
56  virtual ~AbstractCoordinatePlane();
57 
64  virtual void addDiagram( AbstractDiagram* diagram );
65 
83  virtual void replaceDiagram( AbstractDiagram* diagram, AbstractDiagram* oldDiagram = nullptr );
84 
93  virtual void takeDiagram( AbstractDiagram* diagram );
94 
98  AbstractDiagram* diagram();
99 
103  AbstractDiagramList diagrams();
104 
108  ConstAbstractDiagramList diagrams() const;
109 
113  virtual void layoutDiagrams() = 0;
114 
121  virtual const QPointF translate( const QPointF& diagramPoint ) const = 0;
122 
126  bool isRubberBandZoomingEnabled() const;
127 
131  void setRubberBandZoomingEnabled( bool enable );
132 
137  virtual qreal zoomFactorX() const { return 1.0; }
138 
143  virtual qreal zoomFactorY() const { return 1.0; }
144 
149  virtual void setZoomFactors( qreal factorX, qreal factorY ) { Q_UNUSED( factorX ); Q_UNUSED( factorY ); }
150 
156  virtual void setZoomFactorX( qreal factor ) { Q_UNUSED( factor ); }
157 
163  virtual void setZoomFactorY( qreal factor ) { Q_UNUSED( factor ); }
164 
169  virtual QPointF zoomCenter() const { return QPointF(0.0, 0.0); }
170 
176  virtual void setZoomCenter( const QPointF& center ) { Q_UNUSED( center ); }
177 
189  void setGlobalGridAttributes( const GridAttributes & );
190 
196  GridAttributes globalGridAttributes() const;
197 
216  DataDimensionsList gridDimensionsList();
217 
225  void setReferenceCoordinatePlane( AbstractCoordinatePlane * plane );
226 
242  AbstractCoordinatePlane * referenceCoordinatePlane() const;
243 
248  bool isCornerSpacersEnabled() const;
249 
253  void setCornerSpacersEnabled( bool enable );
254 
255  virtual AbstractCoordinatePlane* sharedAxisMasterPlane( QPainter* p = nullptr ); // KChart 3: const method?
256 
257 
259  bool isEmpty() const override;
261  Qt::Orientations expandingDirections() const override;
263  QSize maximumSize() const override;
265  QSize minimumSize() const override;
267  QSize sizeHint() const override;
274  void setGeometry( const QRect& r ) override;
276  QRect geometry() const override;
277 
278  virtual void mousePressEvent( QMouseEvent* event );
279  virtual void mouseDoubleClickEvent( QMouseEvent* event );
280  virtual void mouseMoveEvent( QMouseEvent* event );
281  virtual void mouseReleaseEvent( QMouseEvent* event );
282 
286  void setParent( Chart* parent );
287  Chart* parent();
288  const Chart* parent() const;
289 
295 #if defined(Q_COMPILER_MANGLES_RETURN_TYPE)
296  const bool isVisiblePoint( const QPointF& point ) const;
297 #else
298  bool isVisiblePoint( const QPointF& point ) const;
299 #endif
300 
301  public Q_SLOTS:
305  void update();
309  void relayout();
313  void layoutPlanes();
317  void setGridNeedsRecalculate();
318 
319  Q_SIGNALS:
321  void destroyedCoordinatePlane( AbstractCoordinatePlane* );
322 
324  void needUpdate();
325 
327  void needRelayout();
328 
330  void needLayoutPlanes();
331 
333  void propertiesChanged();
334 
335  void boundariesChanged();
336 
342  void geometryChanged( QRect, QRect );
343 
344  private:
345  Q_SIGNALS:
346  // Emitted from inside the setGeometry()
347  // This is connected via QueuedConnection to the geometryChanged() Signal
348  // that users can connect to safely then.
349  void internal_geometryChanged( QRect, QRect );
351  void viewportCoordinateSystemChanged();
352 
353  protected:
354  virtual DataDimensionsList getDataDimensionsList() const = 0;
355 
356  //KCHART_DECLARE_PRIVATE_DERIVED( AbstractCoordinatePlane )
357  };
358 
376  public:
377  DataDimension()
378  : start( 1.0 )
379  , end( 10.0 )
380  , isCalculated( false )
381  , calcMode( AbstractCoordinatePlane::Linear )
382  , sequence( KChartEnums::GranularitySequence_10_20 )
383  , stepWidth( 1.0 )
384  , subStepWidth( 0.0 )
385  {}
386  DataDimension( qreal start_,
387  qreal end_,
388  bool isCalculated_,
389  AbstractCoordinatePlane::AxesCalcMode calcMode_,
391  qreal stepWidth_=0.0,
392  qreal subStepWidth_=0.0 )
393  : start( start_ )
394  , end( end_ )
395  , isCalculated( isCalculated_ )
396  , calcMode( calcMode_ )
397  , sequence( sequence_ )
398  , stepWidth( stepWidth_ )
399  , subStepWidth( subStepWidth_ )
400  {}
408  qreal distance() const
409  {
410  return end-start;
411  }
412 
413  bool operator==( const DataDimension& r ) const
414  {
415  return
416  (start == r.start) &&
417  (end == r.end) &&
418  (sequence == r.sequence) &&
419  (isCalculated == r.isCalculated) &&
420  (calcMode == r.calcMode) &&
421  (stepWidth == r.stepWidth) &&
422  (subStepWidth == r.subStepWidth);
423  }
424 
425  bool operator!=( const DataDimension& other ) const
426  { return !operator==( other ); }
427 
428 
429  qreal start;
430  qreal end;
431  bool isCalculated;
432  AbstractCoordinatePlane::AxesCalcMode calcMode;
434  qreal stepWidth;
435  qreal subStepWidth;
436  };
437 
438 #if !defined(QT_NO_DEBUG_STREAM)
439  QDebug operator<<( QDebug stream, const DataDimension& r );
440 #endif
441 
442 }
443 #endif
Helper class for one dimension of data, e.g.
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.
virtual void setZoomFactors(qreal factorX, qreal factorY)
Sets both zoom factors in one go.
Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane, TernaryCoordinatePlane.
GranularitySequence
GranularitySequence specifies the values, that may be applied, to determine a step width within a giv...
Definition: KChartEnums.h:92
An area in the chart with a background, a frame, etc.
QDataStream & operator<<(QDataStream &out, const KDateTime::Spec &spec)
Definition of global enums.
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...
virtual void setZoomCenter(const QPointF &center)
Set the point (in value coordinates) to be used as the center point in zoom operations.
A chart with one or more diagrams.
Definition: KChartChart.h:95
typedef Orientations
Global namespace.
virtual void setZoomFactorY(qreal factor)
Sets the zoom factor in vertical direction, that is applied to all coordinate transformations.
Abstract base class for grid classes: cartesian, polar, ...
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Sep 29 2020 22:42:40 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.