VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkQtChartLegend.h,v $ 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 /*------------------------------------------------------------------------- 00016 Copyright 2008 Sandia Corporation. 00017 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00018 the U.S. Government retains certain rights in this software. 00019 -------------------------------------------------------------------------*/ 00020 00023 00024 #ifndef _vtkQtChartLegend_h 00025 #define _vtkQtChartLegend_h 00026 00027 00028 #include "vtkQtChartExport.h" 00029 #include <QWidget> 00030 00031 class vtkQtChartLegendInternal; 00032 class vtkQtChartLegendModel; 00033 class QFont; 00034 class QPainter; 00035 class QPoint; 00036 class QRect; 00037 00038 00047 class VTKQTCHART_EXPORT vtkQtChartLegend : public QWidget 00048 { 00049 Q_OBJECT 00050 00051 public: 00052 enum LegendLocation 00053 { 00054 Left = 0, 00055 Top, 00056 Right, 00057 Bottom 00058 }; 00059 00060 enum ItemFlow 00061 { 00062 LeftToRight = 0, 00063 TopToBottom 00064 }; 00065 00066 public: 00070 vtkQtChartLegend(QWidget *parent=0); 00071 virtual ~vtkQtChartLegend(); 00072 00074 00075 00076 00077 00078 00079 vtkQtChartLegendModel *getModel() const {return this->Model;} 00080 00085 LegendLocation getLocation() const {return this->Location;} 00086 00095 void setLocation(LegendLocation location); 00096 00101 ItemFlow getFlow() const {return this->Flow;} 00102 00111 void setFlow(ItemFlow flow); 00113 00118 int getOffset() const; 00119 00124 virtual QSize sizeHint() const {return this->Bounds;} 00125 00129 void drawLegend(QPainter &painter); 00130 00131 signals: 00133 void locationChanged(); 00134 00135 public slots: 00137 void reset(); 00138 00143 void setEntryVisible(int index, bool visible); 00144 00150 void setEntriesVisible(int first, int last, bool visible); 00151 00159 void setOffset(int offset); 00160 00161 protected slots: 00165 void insertEntry(int index); 00166 00170 void startEntryRemoval(int index); 00171 00175 void finishEntryRemoval(int index); 00176 00180 void updateEntryText(int index); 00181 00182 protected: 00188 virtual bool event(QEvent *e); 00189 00193 virtual void paintEvent(QPaintEvent *e); 00194 00198 virtual void resizeEvent(QResizeEvent *e); 00199 00206 virtual void mousePressEvent(QMouseEvent *e); 00207 00214 virtual void mouseMoveEvent(QMouseEvent *e); 00215 00222 virtual void mouseReleaseEvent(QMouseEvent *e); 00223 00224 private: 00226 void calculateSize(); 00227 00229 void updateMaximum(); 00230 00231 private: 00232 vtkQtChartLegendInternal *Internal; 00233 vtkQtChartLegendModel *Model; 00234 LegendLocation Location; 00235 ItemFlow Flow; 00236 QSize Bounds; 00237 int IconSize; 00238 int TextSpacing; 00239 int Margin; 00240 00241 private: 00242 vtkQtChartLegend(const vtkQtChartLegend &); 00243 vtkQtChartLegend &operator=(const vtkQtChartLegend &); 00244 }; 00245 00246 #endif