VTK
vtkQtChartLegend.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkQtChartLegend.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 _vtkQtChartLegend_h
25 #define _vtkQtChartLegend_h
26 
27 
28 #include "vtkQtChartExport.h"
29 #include <QWidget>
30 
31 class vtkQtChartLegendInternal;
33 class QFont;
34 class QPainter;
35 class QPoint;
36 class QRect;
37 
38 
47 class VTKQTCHART_EXPORT vtkQtChartLegend : public QWidget
48 {
49  Q_OBJECT
50 
51 public:
53  {
54  Left = 0,
55  Top,
57  Bottom
58  };
59 
60  enum ItemFlow
61  {
62  LeftToRight = 0,
63  TopToBottom
64  };
65 
66 public:
70  vtkQtChartLegend(QWidget *parent=0);
71  virtual ~vtkQtChartLegend();
72 
74 
75 
76 
77 
78 
79  vtkQtChartLegendModel *getModel() const {return this->Model;}
80 
85  LegendLocation getLocation() const {return this->Location;}
86 
95  void setLocation(LegendLocation location);
96 
101  ItemFlow getFlow() const {return this->Flow;}
102 
111  void setFlow(ItemFlow flow);
113 
118  int getOffset() const;
119 
124  virtual QSize sizeHint() const {return this->Bounds;}
125 
129  void drawLegend(QPainter &painter);
130 
131 signals:
133  void locationChanged();
134 
135 public slots:
137  void reset();
138 
146  void setOffset(int offset);
147 
148 protected slots:
152  void insertEntry(int index);
153 
157  void startEntryRemoval(int index);
158 
162  void finishEntryRemoval(int index);
163 
167  void updateEntryText(int index);
168 
172  void updateEntryVisible(int index);
173 
174 protected:
180  virtual bool event(QEvent *e);
181 
185  virtual void paintEvent(QPaintEvent *e);
186 
190  virtual void resizeEvent(QResizeEvent *e);
191 
198  virtual void mousePressEvent(QMouseEvent *e);
199 
206  virtual void mouseMoveEvent(QMouseEvent *e);
207 
214  virtual void mouseReleaseEvent(QMouseEvent *e);
215 
216 private:
218  void calculateSize();
219 
221  void updateMaximum();
222 
223 private:
224  vtkQtChartLegendInternal *Internal;
225  vtkQtChartLegendModel *Model;
226  LegendLocation Location;
227  ItemFlow Flow;
228  QSize Bounds;
229  int IconSize;
230  int TextSpacing;
231  int Margin;
232 
233 private:
235  vtkQtChartLegend &operator=(const vtkQtChartLegend &);
236 };
237 
238 #endif