forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkApplyColors.h
245 lines (212 loc) · 9.43 KB
/
vtkApplyColors.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
/*=========================================================================
Program: Visualization Toolkit
Module: vtkApplyColors.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*-------------------------------------------------------------------------
Copyright 2008 Sandia Corporation.
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------*/
// .NAME vtkApplyColors - apply colors to a data set.
//
// .SECTION Description
// vtkApplyColors performs a coloring of the dataset using default colors,
// lookup tables, annotations, and/or a selection. The output is a
// four-component vtkUnsignedCharArray containing RGBA tuples for each
// element in the dataset. The first input is the dataset to be colored, which
// may be a vtkTable, vtkGraph subclass, or vtkDataSet subclass. The API
// of this algorithm refers to "points" and "cells". For vtkGraph, the
// "points" refer to the graph vertices and "cells" refer to graph edges.
// For vtkTable, "points" refer to table rows. For vtkDataSet subclasses, the
// meaning is obvious.
//
// The second (optional) input is a vtkAnnotationLayers object, which stores
// a list of annotation layers, with each layer holding a list of
// vtkAnnotation objects. The annotation specifies a subset of data along with
// other properties, including color. For annotations with color properties,
// this algorithm will use the color to color elements, using a "top one wins"
// strategy.
//
// The third (optional) input is a vtkSelection object, meant for specifying
// the current selection. You can control the color of the selection.
//
// The algorithm takes two input arrays, specified with
// SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, name)
// and
// SetInputArrayToProcess(1, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, name).
// These set the point and cell data arrays to use to color the data with
// the associated lookup table. For vtkGraph, vtkTable inputs, you would use
// FIELD_ASSOCIATION_VERTICES, FIELD_ASSOCIATION_EDGES, or
// FIELD_ASSOCIATION_ROWS as appropriate.
//
// To use the color array generated here, you should do the following:
//
// mapper->SetScalarModeToUseCellFieldData();
// mapper->SelectColorArray("vtkApplyColors color");
// mapper->SetScalarVisibility(true);
//
// Colors are assigned with the following priorities:
// <ol>
// <li> If an item is part of the selection, it is colored with that color.
// <li> Otherwise, if the item is part of an annotation, it is colored
// with the color of the final (top) annotation in the set of layers.
// <li> Otherwise, if the lookup table is used, it is colored using the
// lookup table color for the data value of the element.
// <li> Otherwise it will be colored with the default color.
// </ol>
//
// Note: The opacity of an unselected item is defined by the multiplication
// of default opacity, lookup table opacity, and annotation opacity, where
// opacity is taken as a number from 0 to 1. So items will never be more opaque
// than any of these three opacities. Selected items are always given the
// selection opacity directly.
#ifndef vtkApplyColors_h
#define vtkApplyColors_h
#include "vtkViewsInfovisModule.h" // For export macro
#include "vtkPassInputTypeAlgorithm.h"
class vtkScalarsToColors;
class vtkUnsignedCharArray;
class VTKVIEWSINFOVIS_EXPORT vtkApplyColors : public vtkPassInputTypeAlgorithm
{
public:
static vtkApplyColors *New();
vtkTypeMacro(vtkApplyColors, vtkPassInputTypeAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// The lookup table to use for point colors. This is only used if
// input array 0 is set and UsePointLookupTable is on.
virtual void SetPointLookupTable(vtkScalarsToColors* lut);
vtkGetObjectMacro(PointLookupTable, vtkScalarsToColors);
// Description:
// If on, uses the point lookup table to set the colors of unannotated,
// unselected elements of the data.
vtkSetMacro(UsePointLookupTable, bool);
vtkGetMacro(UsePointLookupTable, bool);
vtkBooleanMacro(UsePointLookupTable, bool);
// Description:
// If on, uses the range of the data to scale the lookup table range.
// Otherwise, uses the range defined in the lookup table.
vtkSetMacro(ScalePointLookupTable, bool);
vtkGetMacro(ScalePointLookupTable, bool);
vtkBooleanMacro(ScalePointLookupTable, bool);
// Description:
// The default point color for all unannotated, unselected elements
// of the data. This is used if UsePointLookupTable is off.
vtkSetVector3Macro(DefaultPointColor, double);
vtkGetVector3Macro(DefaultPointColor, double);
// Description:
// The default point opacity for all unannotated, unselected elements
// of the data. This is used if UsePointLookupTable is off.
vtkSetMacro(DefaultPointOpacity, double);
vtkGetMacro(DefaultPointOpacity, double);
// Description:
// The point color for all selected elements of the data.
// This is used if the selection input is available.
vtkSetVector3Macro(SelectedPointColor, double);
vtkGetVector3Macro(SelectedPointColor, double);
// Description:
// The point opacity for all selected elements of the data.
// This is used if the selection input is available.
vtkSetMacro(SelectedPointOpacity, double);
vtkGetMacro(SelectedPointOpacity, double);
// Description:
// The output array name for the point color RGBA array.
// Default is "vtkApplyColors color".
vtkSetStringMacro(PointColorOutputArrayName);
vtkGetStringMacro(PointColorOutputArrayName);
// Description:
// The lookup table to use for cell colors. This is only used if
// input array 1 is set and UseCellLookupTable is on.
virtual void SetCellLookupTable(vtkScalarsToColors* lut);
vtkGetObjectMacro(CellLookupTable, vtkScalarsToColors);
// Description:
// If on, uses the cell lookup table to set the colors of unannotated,
// unselected elements of the data.
vtkSetMacro(UseCellLookupTable, bool);
vtkGetMacro(UseCellLookupTable, bool);
vtkBooleanMacro(UseCellLookupTable, bool);
// Description:
// If on, uses the range of the data to scale the lookup table range.
// Otherwise, uses the range defined in the lookup table.
vtkSetMacro(ScaleCellLookupTable, bool);
vtkGetMacro(ScaleCellLookupTable, bool);
vtkBooleanMacro(ScaleCellLookupTable, bool);
// Description:
// The default cell color for all unannotated, unselected elements
// of the data. This is used if UseCellLookupTable is off.
vtkSetVector3Macro(DefaultCellColor, double);
vtkGetVector3Macro(DefaultCellColor, double);
// Description:
// The default cell opacity for all unannotated, unselected elements
// of the data. This is used if UseCellLookupTable is off.
vtkSetMacro(DefaultCellOpacity, double);
vtkGetMacro(DefaultCellOpacity, double);
// Description:
// The cell color for all selected elements of the data.
// This is used if the selection input is available.
vtkSetVector3Macro(SelectedCellColor, double);
vtkGetVector3Macro(SelectedCellColor, double);
// Description:
// The cell opacity for all selected elements of the data.
// This is used if the selection input is available.
vtkSetMacro(SelectedCellOpacity, double);
vtkGetMacro(SelectedCellOpacity, double);
// Description:
// The output array name for the cell color RGBA array.
// Default is "vtkApplyColors color".
vtkSetStringMacro(CellColorOutputArrayName);
vtkGetStringMacro(CellColorOutputArrayName);
// Description:
// Use the annotation to color the current annotation
// (i.e. the current selection). Otherwise use the selection
// color attributes of this filter.
vtkSetMacro(UseCurrentAnnotationColor, bool);
vtkGetMacro(UseCurrentAnnotationColor, bool);
vtkBooleanMacro(UseCurrentAnnotationColor, bool);
// Description:
// Retrieve the modified time for this filter.
virtual long unsigned int GetMTime();
protected:
vtkApplyColors();
~vtkApplyColors();
// Description:
// Convert the vtkGraph into vtkPolyData.
int RequestData(
vtkInformation *, vtkInformationVector **, vtkInformationVector *);
// Description:
// Set the input type of the algorithm to vtkGraph.
int FillInputPortInformation(int port, vtkInformation* info);
void ProcessColorArray(
vtkUnsignedCharArray* colorArr,
vtkScalarsToColors* lut,
vtkAbstractArray* arr,
unsigned char color[4],
bool scale);
vtkScalarsToColors* PointLookupTable;
vtkScalarsToColors* CellLookupTable;
double DefaultPointColor[3];
double DefaultPointOpacity;
double DefaultCellColor[3];
double DefaultCellOpacity;
double SelectedPointColor[3];
double SelectedPointOpacity;
double SelectedCellColor[3];
double SelectedCellOpacity;
bool ScalePointLookupTable;
bool ScaleCellLookupTable;
bool UsePointLookupTable;
bool UseCellLookupTable;
char* PointColorOutputArrayName;
char* CellColorOutputArrayName;
bool UseCurrentAnnotationColor;
private:
vtkApplyColors(const vtkApplyColors&); // Not implemented.
void operator=(const vtkApplyColors&); // Not implemented.
};
#endif