KD Chart 2  [rev.2.5.1]
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
KDChartAbstractCoordinatePlane.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2001-2013 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  virtual ~AbstractCoordinatePlane();
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  virtual bool isEmpty() const;
264  virtual Qt::Orientations expandingDirections() const;
266  virtual QSize maximumSize() const;
268  virtual QSize minimumSize() const;
270  virtual QSize sizeHint() const;
277  virtual void setGeometry( const QRect& r );
279  virtual QRect geometry() const;
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

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