VTK
vtkQtChartAxis.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkQtChartAxis.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16  Copyright 2008 Sandia Corporation.
17  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18  the U.S. Government retains certain rights in this software.
19 -------------------------------------------------------------------------*/
20 
23 
24 #ifndef _vtkQtChartAxis_h
25 #define _vtkQtChartAxis_h
26 
27 #include "vtkQtChartExport.h"
28 #include <QObject>
29 #include <QGraphicsItem>
30 
31 #include "vtkQtChartGraphicsItemTypes.h" // needed for enum
32 
33 class vtkQtChartAxisInternal;
38 class QGraphicsLineItem;
39 class QVariant;
40 
41 
45 class VTKQTCHART_EXPORT vtkQtChartAxis : public QObject, public QGraphicsItem
46 {
47  Q_OBJECT
48 
49 public:
51  {
52  Left = 0,
55  Top
56  };
57 
59  {
60  UnsupportedDomain = -1,
61  Number = 0,
62  Date,
63  Time,
64  String
65  };
66 
67  enum {Type = vtkQtChart_AxisType};
68 
69 public:
74  vtkQtChartAxis(AxisLocation location, QGraphicsItem *parent=0);
75  virtual ~vtkQtChartAxis();
76 
77  virtual int type() const {return vtkQtChartAxis::Type;}
78 
80 
81 
82 
83 
84 
85  AxisLocation getLocation() const {return this->Location;}
86 
91  vtkQtChartAxisModel *getModel() const {return this->Model;}
92 
96  void setModel(vtkQtChartAxisModel *model);
97 
107  void setNeigbors(const vtkQtChartAxis *atMin, const vtkQtChartAxis *atMax);
108 
112  void setParallelAxis(const vtkQtChartAxis *across);
113 
117  void setContentsSpace(const vtkQtChartContentsSpace *contents);
118 
128  void setDataAvailable(bool available);
129 
135  bool isBestFitGenerated() const;
136 
141  void setBestFitGenerated(bool on);
142 
147  void getBestFitRange(QVariant &min, QVariant &max) const;
148 
153  void setBestFitRange(const QVariant &min, const QVariant &max);
154 
164  bool isRangePaddingUsed() const;
165 
169  void setRangePaddingUsed(bool padRange);
170 
181  bool isExpansionToZeroUsed() const;
182 
186  void setExpansionToZeroUsed(bool expand);
187 
199  bool isExtraSpaceUsed() const;
200 
206  void setExtraSpaceUsed(bool addSpace);
207 
212  bool isSpaceTooSmall() const;
213 
217  void setSpaceTooSmall(bool tooSmall);
219 
221 
222 
223 
224 
225 
226  vtkQtChartAxisOptions *getOptions() const {return this->Options;}
227 
235  void setOptions(const vtkQtChartAxisOptions &options);
237 
239 
240 
241 
242 
243 
244 
245 
246  void layoutAxis(const QRectF &area);
247 
254  void adjustAxisLayout();
255 
266  float getPreferredSpace() const;
267 
272  float getFontHeight() const;
273 
281  float getMaxLabelWidth() const;
282 
287  float getTickLength() const;
288 
293  float getSmallTickLength() const;
294 
299  float getTickLabelSpacing() const;
300 
305  bool isLogScaleAvailable() const;
306 
312  virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
313  QWidget *widget=0);
315 
317 
318  virtual QRectF boundingRect() const;
319 
328  QRectF getBounds() const;
329 
335  bool isLabelTickVisible(int index) const;
336 
342  float getLabelLocation(int index) const;
343 
348  AxisDomain getAxisDomain() const;
349 
355  bool isValueInDomain(const QVariant &value) const;
356 
365  float getPixel(const QVariant &value) const;
366 
376  float getZeroPixel() const;
378 
386  static bool isLogScaleValid(const QVariant &min, const QVariant &max);
387 
388 signals:
390  void layoutNeeded();
391 
399  void pixelScaleChanged();
400 
401 public slots:
403  void reset();
404 
408  void setOffset(float offset);
409 
410 private slots:
412  void handleFontChange();
413 
415  void handlePresentationChange();
416 
418  void handleColorChange();
419 
421  void handleAxisScaleChange();
422 
426  void insertLabel(int index);
427 
431  void startLabelRemoval(int index);
432 
436  void finishLabelRemoval(int index);
437 
438 private:
449  float getLabelWidthGuess(const QVariant &minimum,
450  const QVariant &maximum) const;
451 
455  void generateLabels(const QRectF &contents);
456 
460  void generateLogLabels(const QRectF &contents);
461 
462 public:
463  static const double MinLogValue;
464 
465 private:
466  vtkQtChartAxisInternal *Internal;
467  vtkQtChartAxisOptions *Options;
468  vtkQtChartAxisModel *Model;
469  const vtkQtChartAxis *AtMin;
470  const vtkQtChartAxis *AtMax;
471  const vtkQtChartAxis *Across;
472  const vtkQtChartContentsSpace *Zoom;
473  AxisLocation Location;
474 };
475 
476 #endif