VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkChart.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 00029 #ifndef __vtkChart_h 00030 #define __vtkChart_h 00031 00032 #include "vtkChartsCoreModule.h" // For export macro 00033 #include "vtkContextItem.h" 00034 #include "vtkRect.h" // For vtkRectf 00035 #include "vtkStdString.h" // For vtkStdString ivars 00036 #include "vtkSmartPointer.h" // For SP ivars 00037 00038 class vtkTransform2D; 00039 class vtkContextScene; 00040 class vtkPlot; 00041 class vtkAxis; 00042 class vtkBrush; 00043 class vtkTextProperty; 00044 class vtkChartLegend; 00045 00046 class vtkInteractorStyle; 00047 class vtkAnnotationLink; 00048 00049 class VTKCHARTSCORE_EXPORT vtkChart : public vtkContextItem 00050 { 00051 public: 00052 vtkTypeMacro(vtkChart, vtkContextItem); 00053 virtual void PrintSelf(ostream &os, vtkIndent indent); 00054 00055 //BTX 00057 00058 enum { 00059 LINE, 00060 POINTS, 00061 BAR, 00062 STACKED}; 00064 00066 00067 enum { 00068 PAN = 0, 00069 ZOOM, 00070 SELECT, 00071 SELECT_RECTANGLE = SELECT, 00072 SELECT_POLYGON, 00073 NOTIFY 00074 }; 00076 00078 00079 enum EventIds { 00080 UpdateRange = 1002 00081 }; 00082 //ETX 00084 00087 virtual bool Paint(vtkContext2D *painter) = 0; 00088 00090 virtual vtkPlot* AddPlot(int type); 00091 00094 virtual vtkIdType AddPlot(vtkPlot* plot); 00095 00098 virtual bool RemovePlot(vtkIdType index); 00099 00103 virtual bool RemovePlotInstance(vtkPlot* plot); 00104 00106 virtual void ClearPlots(); 00107 00110 virtual vtkPlot* GetPlot(vtkIdType index); 00111 00113 virtual vtkIdType GetNumberOfPlots(); 00114 00118 virtual vtkAxis* GetAxis(int axisIndex); 00119 00121 virtual vtkIdType GetNumberOfAxes(); 00122 00126 virtual void RecalculateBounds(); 00127 00129 00134 enum { 00135 SELECTION_ROWS, 00136 SELECTION_PLOTS 00137 }; 00139 00141 00146 virtual void SetSelectionMethod(int method); 00147 virtual int GetSelectionMethod(); 00149 00151 virtual void SetAnnotationLink(vtkAnnotationLink *link); 00152 00154 00155 vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink); 00157 00159 00160 vtkSetVector2Macro(Geometry, int); 00161 vtkGetVector2Macro(Geometry, int); 00163 00165 00166 vtkSetVector2Macro(Point1, int); 00167 vtkGetVector2Macro(Point1, int); 00169 00171 00172 vtkSetVector2Macro(Point2, int); 00173 vtkGetVector2Macro(Point2, int); 00175 00177 00178 virtual void SetShowLegend(bool visible); 00179 virtual bool GetShowLegend(); 00181 00184 virtual vtkChartLegend * GetLegend(); 00185 00187 00188 virtual void SetTitle(const vtkStdString &title); 00189 virtual vtkStdString GetTitle(); 00191 00193 00195 vtkGetObjectMacro(TitleProperties, vtkTextProperty); 00197 00199 00200 void SetBottomBorder(int border); 00201 void SetTopBorder(int border); 00202 void SetLeftBorder(int border); 00203 void SetRightBorder(int border); 00205 00207 void SetBorders(int left, int bottom, int right, int top); 00208 00212 void SetSize(const vtkRectf &rect); 00213 00215 vtkRectf GetSize(); 00216 00218 00219 enum { 00220 FILL_SCENE, // Attempt to fill the entire scene. 00221 FILL_RECT, // Attempt to supply the supplied vtkRectf in Size. 00222 AXES_TO_RECT // Put the corners of the axes on the vtkRectf in Size. 00223 }; 00225 00227 00230 vtkSetMacro(LayoutStrategy, int); 00231 vtkGetMacro(LayoutStrategy, int); 00233 00235 00237 virtual void SetAutoSize(bool isAutoSized) 00238 { 00239 this->LayoutStrategy = isAutoSized ? vtkChart::FILL_SCENE : 00240 vtkChart::FILL_RECT; 00241 } 00242 virtual bool GetAutoSize() 00243 { 00244 return this->LayoutStrategy == vtkChart::FILL_SCENE ? true : false; 00245 } 00247 00249 00254 vtkSetMacro(RenderEmpty, bool); 00255 vtkGetMacro(RenderEmpty, bool); 00257 00265 virtual void SetActionToButton(int action, int button); 00266 00270 virtual int GetActionToButton(int action); 00271 00275 virtual void SetClickActionToButton(int action, int button); 00276 00280 virtual int GetClickActionToButton(int action); 00281 00283 00284 void SetBackgroundBrush(vtkBrush *brush); 00285 vtkBrush* GetBackgroundBrush(); 00287 00289 00293 virtual void SetSelectionMode(int); 00294 vtkGetMacro(SelectionMode, int); 00296 00297 protected: 00298 vtkChart(); 00299 ~vtkChart(); 00300 00302 00306 bool CalculatePlotTransform(vtkAxis *x, vtkAxis *y, 00307 vtkTransform2D *transform); 00309 00312 void AttachAxisRangeListener(vtkAxis*); 00313 00314 void AxisRangeForwarderCallback(vtkObject*,unsigned long, void*); 00315 00317 vtkAnnotationLink *AnnotationLink; 00318 00320 int Geometry[2]; 00321 00323 int Point1[2]; 00324 00326 int Point2[2]; 00327 00329 bool ShowLegend; 00330 00332 vtkStdString Title; 00333 00335 vtkTextProperty* TitleProperties; 00336 00337 vtkRectf Size; 00338 // The layout strategy to employ when fitting the chart into the space. 00339 int LayoutStrategy; 00340 bool RenderEmpty; 00341 00343 vtkSmartPointer<vtkBrush> BackgroundBrush; 00344 00345 // The mode when the chart is doing selection. 00346 int SelectionMode; 00347 00348 // How plot selections are handled, SELECTION_ROWS (default) or 00349 // SELECTION_PLOTS - based on the plot that created the selection. 00350 int SelectionMethod; 00351 00353 00354 class MouseActions 00355 { 00356 public: 00357 MouseActions(); 00358 enum { MaxAction = 4 }; 00359 short& Pan() { return Data[0]; } 00360 short& Zoom() { return Data[1]; } 00361 short& Select() { return Data[2]; } 00362 short& SelectPolygon() { return Data[3]; } 00363 short& operator[](int index) { return Data[index]; } 00364 short Data[MaxAction]; 00365 }; 00366 class MouseClickActions 00367 { 00368 public: 00369 MouseClickActions(); 00370 short& Notify() { return Data[0]; } 00371 short& Select() { return Data[1]; } 00372 short& operator[](int index) { return Data[index]; } 00373 short Data[2]; 00374 }; 00376 00377 MouseActions Actions; 00378 MouseClickActions ActionsClick; 00379 00380 private: 00381 vtkChart(const vtkChart &); // Not implemented. 00382 void operator=(const vtkChart &); // Not implemented. 00383 }; 00384 00385 #endif //__vtkChart_h