VTK
dox/GUISupport/Qt/Chart/vtkQtChartShapeLocator.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkQtChartShapeLocator.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 _vtkQtChartShapeLocator_h
00025 #define _vtkQtChartShapeLocator_h
00026 
00027 #include "vtkQtChartExport.h"
00028 #include <QLinkedList> // Needed for parameter.
00029 #include <QList> // Needed for parameter.
00030 
00031 class vtkQtChartShape;
00032 class QPointF;
00033 class QRectF;
00034 
00035 
00040 class VTKQTCHART_EXPORT vtkQtChartShapeLocatorNode
00041 {
00042 public:
00046   vtkQtChartShapeLocatorNode(vtkQtChartShape *element=0);
00047   ~vtkQtChartShapeLocatorNode();
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   vtkQtChartShape *getElement() const {return this->Element;}
00079 
00083   void setElement(vtkQtChartShape *element);
00084 
00089   vtkQtChartShapeLocatorNode *getParent() const {return this->Parent;}
00090 
00094   void setParent(vtkQtChartShapeLocatorNode *parent) {this->Parent = parent;}
00095 
00100   bool hasChildren() const {return this->Nodes.size() > 0;}
00101 
00106   const QList<vtkQtChartShapeLocatorNode *> &getNodes() const {return this->Nodes;}
00107 
00112   QList<vtkQtChartShapeLocatorNode *> &getNodes() {return this->Nodes;}
00113 
00119   void updateBounds();
00120 
00121 private:
00122   QRectF *Bounds;                            
00123   vtkQtChartShape *Element;                  
00124   vtkQtChartShapeLocatorNode *Parent;        
00125   QList<vtkQtChartShapeLocatorNode *> Nodes; 
00126 
00127 private:
00128   vtkQtChartShapeLocatorNode(const vtkQtChartShapeLocatorNode &);
00129   vtkQtChartShapeLocatorNode &operator=(const vtkQtChartShapeLocatorNode &);
00130 };
00131 
00132 
00142 class VTKQTCHART_EXPORT vtkQtChartShapeLocator
00143 {
00144 public:
00145   vtkQtChartShapeLocator();
00146   ~vtkQtChartShapeLocator();
00147 
00149   void clear();
00150 
00158   void build(const QList<QList<vtkQtChartShape *> > &table);
00159 
00170   void build(const QList<vtkQtChartShape *> &list);
00171 
00178   void update();
00179 
00185   QList<vtkQtChartShape *> getItemsAt(const QPointF &point) const;
00186 
00192   QList<vtkQtChartShape *> getItemsIn(const QRectF &area) const;
00193 
00198   vtkQtChartShapeLocatorNode *getLast();
00199 
00205   vtkQtChartShapeLocatorNode *getPrevious(vtkQtChartShapeLocatorNode *node);
00206 
00207 public:
00215   static void sort(QList<vtkQtChartShape *> &list);
00216 
00217 private:
00221   void build(QLinkedList<QLinkedList<vtkQtChartShapeLocatorNode *> > &table);
00222 
00223 private:
00224   vtkQtChartShapeLocatorNode *Root; 
00225 
00226 private:
00227   vtkQtChartShapeLocator(const vtkQtChartShapeLocator &);
00228   vtkQtChartShapeLocator &operator=(const vtkQtChartShapeLocator &);
00229 };
00230 
00231 #endif