1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkPainterPolyDataMapper.h
5 
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10      This software is distributed WITHOUT ANY WARRANTY; without even
11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12      PURPOSE.  See the above copyright notice for more information.
13 
14 =========================================================================*/
15 // .NAME vtkPainterPolyDataMapper - PolyDataMapper using painters
16 // .SECTION Description
17 // PolyDataMapper that uses painters to do the actual rendering.
18 // .SECTION Thanks
19 // Support for generic vertex attributes in VTK was contributed in
20 // collaboration with Stephane Ploix at EDF.
21 
22 #ifndef vtkPainterPolyDataMapper_h
23 #define vtkPainterPolyDataMapper_h
24 
25 #include "vtkRenderingOpenGLModule.h" // For export macro
26 #include "vtkPolyDataMapper.h"
27 
28 class vtkPainterPolyDataMapperObserver;
29 class vtkPainter;
30 
31 class VTKRENDERINGOPENGL_EXPORT vtkPainterPolyDataMapper : public vtkPolyDataMapper
32 {
33 public:
34   static vtkPainterPolyDataMapper* New();
35   vtkTypeMacro(vtkPainterPolyDataMapper, vtkPolyDataMapper);
36   void PrintSelf(ostream& os, vtkIndent indent);
37 
38   // Description:
39   // Implemented by sub classes. Actual rendering is done here.
40   virtual void RenderPiece(vtkRenderer *ren, vtkActor *act);
41 
42   // Description:
43   // Get/Set the painter used to do the actual rendering.
44   // By default, vtkDefaultPainter is used to build the rendering
45   // painter chain for color mapping/clipping etc. followed by
46   // a vtkChooserPainter which renders the primitives.
47   vtkGetObjectMacro(Painter, vtkPainter);
48   void SetPainter(vtkPainter*);
49 
50   // Description:
51   // Release any graphics resources that are being consumed by this mapper.
52   // The parameter window could be used to determine which graphic
53   // resources to release. Merely propagates the call to the painter.
54   void ReleaseGraphicsResources(vtkWindow *);
55 
56   // Description:
57   // Select a data array from the point/cell data
58   // and map it to a generic vertex attribute.
59   // vertexAttributeName is the name of the vertex attribute.
60   // dataArrayName is the name of the data array.
61   // fieldAssociation indicates when the data array is a point data array or
62   // cell data array (vtkDataObject::FIELD_ASSOCIATION_POINTS or
63   // (vtkDataObject::FIELD_ASSOCIATION_CELLS).
64   // componentno indicates which component from the data array must be passed as
65   // the attribute. If -1, then all components are passed.
66   virtual void MapDataArrayToVertexAttribute(
67     const char* vertexAttributeName,
68     const char* dataArrayName, int fieldAssociation, int componentno=-1);
69 
70   virtual void MapDataArrayToMultiTextureAttribute(
71     int unit,
72     const char* dataArrayName, int fieldAssociation, int componentno=-1);
73 
74   // Description:
75   // Remove a vertex attribute mapping.
76   virtual void RemoveVertexAttributeMapping(const char* vertexAttributeName);
77 
78   // Description:
79   // Remove all vertex attributes.
80   virtual void RemoveAllVertexAttributeMappings();
81 
82   // Description:
83   // Get/Set the painter used when rendering the selection pass.
84   vtkGetObjectMacro(SelectionPainter, vtkPainter);
85   void SetSelectionPainter(vtkPainter*);
86 
87   // Description:
88   // WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE
89   // DO NOT USE THIS METHOD OUTSIDE OF THE RENDERING PROCESS
90   // Used by vtkHardwareSelector to determine if the prop supports hardware
91   // selection.
GetSupportsSelection()92   virtual bool GetSupportsSelection()
93     { return (this->SelectionPainter != 0); }
94 
95   // Description:
96   // Returns if the mapper does not expect to have translucent geometry. This
97   // may happen when using ScalarMode is set to not map scalars i.e. render the
98   // scalar array directly as colors and the scalar array has opacity i.e. alpha
99   // component. Note that even if this method returns true, an actor may treat
100   // the geometry as translucent since a constant translucency is set on the
101   // property, for example.
102   // Overridden to use the actual data and ScalarMode to determine if we have
103   // opaque geometry.
104   virtual bool GetIsOpaque();
105 
106 protected:
107   vtkPainterPolyDataMapper();
108   ~vtkPainterPolyDataMapper();
109 
110   // Description:
111   // Called in GetBounds(). When this method is called, the consider the input
112   // to be updated depending on whether this->Static is set or not. This method
113   // simply obtains the bounds from the data-object and returns it.
114   virtual void ComputeBounds();
115 
116   // Description:
117   // Called when the PainterInformation becomes obsolete.
118   // It is called before UpdateBounds or Render is initiated on the Painter
119   virtual void UpdatePainterInformation();
120 
121   // Description:
122   // Take part in garbage collection.
123   virtual void ReportReferences(vtkGarbageCollector *collector);
124 
125   vtkInformation* PainterInformation;
126   vtkTimeStamp PainterUpdateTime;
127   vtkPainter* Painter;
128   // Painter used when rendering for hardware selection
129   // (look at vtkHardwareSelector).
130   vtkPainter* SelectionPainter;
131   vtkPainterPolyDataMapperObserver* Observer;
132 private:
133   vtkPainterPolyDataMapper(const vtkPainterPolyDataMapper&); // Not implemented.
134   void operator=(const vtkPainterPolyDataMapper&); // Not implemented.
135 };
136 
137 #endif
138