00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkQtChartBarLocator.h 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 _vtkQtChartBarLocator_h 00025 #define _vtkQtChartBarLocator_h 00026 00027 #include "vtkQtChartExport.h" 00028 #include <QLinkedList> // Needed for parameter. 00029 #include <QList> // Needed for parameter. 00030 00031 class vtkQtChartBar; 00032 class QPointF; 00033 class QRectF; 00034 00035 00040 class VTKQTCHART_EXPORT vtkQtChartBarLocatorNode 00041 { 00042 public: 00046 vtkQtChartBarLocatorNode(vtkQtChartBar *element=0); 00047 ~vtkQtChartBarLocatorNode(); 00048 00054 bool contains(const QPointF &point) const; 00055 00061 bool intersects(const QRectF &area) const; 00062 00067 const QRectF &getBounds() const {return *this->Bounds;} 00068 00072 void setBounds(const QRectF &bounds); 00073 00078 vtkQtChartBar *getElement() const {return this->Element;} 00079 00083 void setElement(vtkQtChartBar *element); 00084 00089 vtkQtChartBarLocatorNode *getParent() const {return this->Parent;} 00090 00094 void setParent(vtkQtChartBarLocatorNode *parent) {this->Parent = parent;} 00095 00100 bool hasChildren() const {return this->First || this->Second;} 00101 00106 vtkQtChartBarLocatorNode *getFirst() const {return this->First;} 00107 00111 void setFirst(vtkQtChartBarLocatorNode *first) {this->First = first;} 00112 00117 vtkQtChartBarLocatorNode *getSecond() const {return this->Second;} 00118 00122 void setSecond(vtkQtChartBarLocatorNode *second) {this->Second = second;} 00123 00129 void updateBounds(); 00130 00131 private: 00132 QRectF *Bounds; 00133 vtkQtChartBar *Element; 00134 vtkQtChartBarLocatorNode *Parent; 00135 vtkQtChartBarLocatorNode *First; 00136 vtkQtChartBarLocatorNode *Second; 00137 00138 private: 00139 vtkQtChartBarLocatorNode(const vtkQtChartBarLocatorNode &); 00140 vtkQtChartBarLocatorNode &operator=(const vtkQtChartBarLocatorNode &); 00141 }; 00142 00143 00152 class VTKQTCHART_EXPORT vtkQtChartBarLocator 00153 { 00154 public: 00155 vtkQtChartBarLocator(); 00156 ~vtkQtChartBarLocator(); 00157 00159 void clear(); 00160 00168 void build(const QList<vtkQtChartBar *> &list); 00169 00176 void update(); 00177 00183 vtkQtChartBar *getItemAt(const QPointF &point) const; 00184 00190 QList<vtkQtChartBar *> getItemsIn(const QRectF &area) const; 00191 00196 vtkQtChartBarLocatorNode *getLast(); 00197 00203 vtkQtChartBarLocatorNode *getPrevious(vtkQtChartBarLocatorNode *node); 00204 00205 private: 00209 void buildTree(QLinkedList<vtkQtChartBarLocatorNode *> &list) const; 00210 00211 private: 00212 vtkQtChartBarLocatorNode *Root; 00213 QList<vtkQtChartBarLocatorNode *> Items; 00214 00215 private: 00216 vtkQtChartBarLocator(const vtkQtChartBarLocator &); 00217 vtkQtChartBarLocator &operator=(const vtkQtChartBarLocator &); 00218 }; 00219 00220 #endif