User:Marcus.hanwell: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
<source lang="cpp">
== 2D API ==
class Test : public vtkObject
 
{
The 2D API is currently made of of two levels, a concreate class called vtk2DPainter that is called by the paint functions of components operating within the 2D API, and a vtk2DPaintDevice which is called by the vtk2DPainter to actually draw to a context. The vtk2DPainter contains a pointer to the derived class of the vtk2DPaintDevice to do low level painting. This is the class that must be implemented for a new backend to be supported. The vtk2DPainter builds up more complex 2D constructs on top of the basic constructs implemented in the device.
public:
  Test();
  ~Test();
};
</source>


<graphviz renderer='neato' caption='Chart Classes'>
<graphviz renderer='neato' caption='2D API'>
digraph Charts {
digraph TWOD {
   node [
   node [
     fontsize = 10
     fontsize = 10
Line 23: Line 18:


   // Classes
   // Classes
  vtk2DActor
   vtk2DPainter
   vtk2DPainter


   vtkChart
   vtk2DPaintDevice
   vtkChartXY
   vtk2DGLPaintDevice
   vtkChartParallel
   vtk2DQtPaintDevice
   vtkChartPie
   vtk2DCairoPaintDevice
 
  vtkPlot
  vtkPlotLine
  vtkPlotStacked
  vtkPlotBar
 
  vtkPlotGrid
  vtkAxis
  vtkLegend


//
// Subclass relationships
// Subclass relationships
//
//
// A -> B means
// A -> B means
// A is the superclass of B
// A is the superclass of B
Line 50: Line 37:
   arrowhead = none
   arrowhead = none
]
]
  vtkChart -> vtkChartXY
  vtkChart -> vtkChartParallel
  vtkChart -> vtkChartPie


   vtkPlot -> vtkPlotLine
   vtk2DPaintDevice -> vtk2DGLPaintDevice
   vtkPlot -> vtkPlotStacked
   vtk2DPaintDevice -> vtk2DQtPaintDevice
   vtkPlot -> vtkPlotBar
   vtk2DPaintDevice -> vtk2DCairoPaintDevice


//
// "owns the lifetime of"
// "owns the lifetime of"
//
edge [
edge [
   arrowtail = diamond
   arrowtail = diamond
Line 64: Line 51:
]
]


//
// "has a pointer to"
// "has a pointer to"
//
edge [
edge [
   arrowtail = odiamond
   arrowtail = odiamond
Line 70: Line 60:
]
]


   vtkChartXY -> vtkPlot
   vtk2DPainter -> vtk2DPaintDevice
  vtkChartXY -> vtkPlotGrid
  vtkChartXY -> vtkAxis
  vtkChartXY -> vtkLegend
 
  vtk2DActor -> vtkChart
  vtk2DActor -> vtk2DPainter
}
}
</graphviz>
</graphviz>


<graphviz renderer='neato' caption='2D API'>
The class relationship diagram is shown above. The headers for the two classes look as follows.
digraph TWOD {
 
<source lang="cpp">
class VTK_CHARTS_EXPORT vtk2DPainter : public vtkObject
{
public:
  vtkTypeRevisionMacro(vtk2DPainter, vtkObject);
  virtual void PrintSelf(ostream &os, vtkIndent indent);
  static vtk2DPainter *New();
 
  bool Begin(vtk2DPaintDevice *device);
  bool End();
 
  // Line drawing functions
  void DrawLine(float x1, float y1, float x2, float y2);
  void DrawLine(vtkPoints2D *points);
  void DrawPoly(float *x, float *y, int n);
  void DrawPoly(vtkPoints2D *points);
  void DrawRectangle(float x, float y, float width, float height);
  void DrawRectangle(float *p);
  void DrawRectangle(vtkPoints2D *points);
 
  // Point drawing functions
  void DrawPoint(float x, float y);
  void DrawPoints(float *x, float *y, int n);
  void DrawPoints(vtkPoints2D *points);
 
  // Manage the state of the painter
  void SetColor(int r, int g, int b, int a);
  void SetPointSize(float size);
  void SetLineWidth(float width);
 
protected:
  vtk2DPainter();
  ~vtk2DPainter();
 
};
</source>
 
<graphviz renderer='neato' caption='Chart Classes'>
digraph Charts {
   node [
   node [
     fontsize = 10
     fontsize = 10
Line 95: Line 118:


   // Classes
   // Classes
  vtk2DActor
   vtk2DPainter
   vtk2DPainter


   vtk2DPaintDevice
   vtkChart
   vtk2DGLPaintDevice
   vtkChartXY
   vtk2DQtPaintDevice
   vtkChartParallel
   vtk2DCairoPaintDevice
   vtkChartPie
 
  vtkPlot
  vtkPlotLine
  vtkPlotStacked
  vtkPlotBar
 
  vtkPlotGrid
  vtkAxis
  vtkLegend


//
// Subclass relationships
// Subclass relationships
//
//
// A -> B means
// A -> B means
// A is the superclass of B
// A is the superclass of B
Line 114: Line 145:
   arrowhead = none
   arrowhead = none
]
]
  vtkChart -> vtkChartXY
  vtkChart -> vtkChartParallel
  vtkChart -> vtkChartPie


   vtk2DPaintDevice -> vtk2DGLPaintDevice
   vtkPlot -> vtkPlotLine
   vtk2DPaintDevice -> vtk2DQtPaintDevice
   vtkPlot -> vtkPlotStacked
   vtk2DPaintDevice -> vtk2DCairoPaintDevice
   vtkPlot -> vtkPlotBar


//
// "owns the lifetime of"
// "owns the lifetime of"
//
edge [
edge [
   arrowtail = diamond
   arrowtail = diamond
Line 128: Line 159:
]
]


//
// "has a pointer to"
// "has a pointer to"
//
edge [
edge [
   arrowtail = odiamond
   arrowtail = odiamond
Line 137: Line 165:
]
]


   vtk2DPainter -> vtk2DPaintDevice
   vtkChartXY -> vtkPlot
  vtkChartXY -> vtkPlotGrid
  vtkChartXY -> vtkAxis
  vtkChartXY -> vtkLegend
 
  vtk2DActor -> vtkChart
  vtk2DActor -> vtk2DPainter
}
}
</graphviz>
</graphviz>

Revision as of 17:09, 21 October 2009

2D API

The 2D API is currently made of of two levels, a concreate class called vtk2DPainter that is called by the paint functions of components operating within the 2D API, and a vtk2DPaintDevice which is called by the vtk2DPainter to actually draw to a context. The vtk2DPainter contains a pointer to the derived class of the vtk2DPaintDevice to do low level painting. This is the class that must be implemented for a new backend to be supported. The vtk2DPainter builds up more complex 2D constructs on top of the basic constructs implemented in the device.

2D API

The class relationship diagram is shown above. The headers for the two classes look as follows.

<source lang="cpp"> class VTK_CHARTS_EXPORT vtk2DPainter : public vtkObject { public:

 vtkTypeRevisionMacro(vtk2DPainter, vtkObject);
 virtual void PrintSelf(ostream &os, vtkIndent indent);
 static vtk2DPainter *New();
 
 bool Begin(vtk2DPaintDevice *device);
 bool End();
 // Line drawing functions
 void DrawLine(float x1, float y1, float x2, float y2);
 void DrawLine(vtkPoints2D *points);
 void DrawPoly(float *x, float *y, int n);
 void DrawPoly(vtkPoints2D *points);
 void DrawRectangle(float x, float y, float width, float height);
 void DrawRectangle(float *p);
 void DrawRectangle(vtkPoints2D *points);
 // Point drawing functions
 void DrawPoint(float x, float y);
 void DrawPoints(float *x, float *y, int n);
 void DrawPoints(vtkPoints2D *points);
 // Manage the state of the painter
 void SetColor(int r, int g, int b, int a);
 void SetPointSize(float size);
 void SetLineWidth(float width);

protected:

 vtk2DPainter();
 ~vtk2DPainter();

}; </source>

Chart Classes