1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkApplyIcons.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 /*-------------------------------------------------------------------------
16   Copyright 2008 Sandia Corporation.
17   Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18   the U.S. Government retains certain rights in this software.
19 -------------------------------------------------------------------------*/
20 /**
21  * @class   vtkApplyIcons
22  * @brief   apply icons to a data set.
23  *
24  *
25  * vtkApplyIcons performs a iconing of the dataset using default icons,
26  * lookup tables, annotations, and/or a selection. The output is a
27  * vtkIntArray containing the icon index for each
28  * element in the dataset. The first input is the dataset to be iconed, which
29  * may be a vtkTable, vtkGraph subclass, or vtkDataSet subclass.
30  *
31  * The second (optional) input is a vtkAnnotationLayers object, which stores
32  * a list of annotation layers, with each layer holding a list of
33  * vtkAnnotation objects. The annotation specifies a subset of data along with
34  * other properties, including icon. For annotations with icon properties,
35  * this algorithm will use the icon index of annotated elements,
36  * using a "top one wins" strategy.
37  *
38  * The third (optional) input is a vtkSelection object, meant for specifying
39  * the current selection. You can control the icon of the selection, or whether
40  * there is a set of selected icons at a particular offset in the icon sheet.
41  *
42  * The algorithm takes an input array, specified with
43  * SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, name)
44  * This sets data arrays to use to icon the data with
45  * the associated lookup table. For vtkGraph and vtkTable inputs, you would use
46  * FIELD_ASSOCIATION_VERTICES, FIELD_ASSOCIATION_EDGES, or
47  * FIELD_ASSOCIATION_ROWS as appropriate. The icon array will be added to the same
48  * set of attributes that the input array came from. If there is no input array,
49  * the icon array will be applied to the attributes associated with the
50  * AttributeType parameter.
51  *
52  * Icons are assigned with the following priorities:
53  * <ol>
54  * <li> If an item is part of the selection, it is glyphed with that icon.
55  * <li> Otherwise, if the item is part of an annotation, it is glyphed
56  *      with the icon of the final (top) annotation in the set of layers.
57  * <li> Otherwise, if a lookup table is used, it is glyphed using the
58  *      lookup table icon for the data value of the element.
59  * <li> Otherwise it will be glyphed with the default icon.
60  * </ol>
61  */
62 
63 #ifndef vtkApplyIcons_h
64 #define vtkApplyIcons_h
65 
66 #include "vtkPassInputTypeAlgorithm.h"
67 #include "vtkVariant.h"            // For variant arguments.
68 #include "vtkViewsInfovisModule.h" // For export macro
69 
70 class VTKVIEWSINFOVIS_EXPORT vtkApplyIcons : public vtkPassInputTypeAlgorithm
71 {
72 public:
73   static vtkApplyIcons* New();
74   vtkTypeMacro(vtkApplyIcons, vtkPassInputTypeAlgorithm);
75   void PrintSelf(ostream& os, vtkIndent indent) override;
76 
77   ///@{
78   /**
79    * Edits the lookup table to use for point icons. This is only used if
80    * input array 0 is set and UsePointLookupTable is on.
81    */
82   void SetIconType(vtkVariant v, int icon);
SetIconType(double v,int icon)83   void SetIconType(double v, int icon) { this->SetIconType(vtkVariant(v), icon); }
SetIconType(const char * v,int icon)84   void SetIconType(const char* v, int icon) { this->SetIconType(vtkVariant(v), icon); }
85   void ClearAllIconTypes();
86   ///@}
87 
88   ///@{
89   /**
90    * If on, uses the point lookup table to set the colors of unannotated,
91    * unselected elements of the data.
92    */
93   vtkSetMacro(UseLookupTable, bool);
94   vtkGetMacro(UseLookupTable, bool);
95   vtkBooleanMacro(UseLookupTable, bool);
96   ///@}
97 
98   ///@{
99   /**
100    * The default point icon for all unannotated, unselected elements
101    * of the data. This is used if UsePointLookupTable is off.
102    */
103   vtkSetMacro(DefaultIcon, int);
104   vtkGetMacro(DefaultIcon, int);
105   ///@}
106 
107   ///@{
108   /**
109    * The point icon for all selected elements of the data.
110    * This is used if the annotation input has a current selection.
111    */
112   vtkSetMacro(SelectedIcon, int);
113   vtkGetMacro(SelectedIcon, int);
114   ///@}
115 
116   ///@{
117   /**
118    * The output array name for the point icon index array.
119    * Default is "vtkApplyIcons icon".
120    */
121   vtkSetStringMacro(IconOutputArrayName);
122   vtkGetStringMacro(IconOutputArrayName);
123   ///@}
124 
125   enum
126   {
127     SELECTED_ICON,
128     SELECTED_OFFSET,
129     ANNOTATION_ICON,
130     IGNORE_SELECTION
131   };
132 
133   ///@{
134   /**
135    * Changes the behavior of the icon to use for selected items.
136    * <ul>
137    * <li>SELECTED_ICON uses SelectedIcon as the icon for all selected elements.
138    * <li>SELECTED_OFFSET uses SelectedIcon as an offset to add to all selected elements.
139    * <li>ANNOTATION_ICON uses the ICON_INDEX() property of the current annotation.
140    * <li>IGNORE_SELECTION does not change the icon based on the current selection.
141    * </ul>
142    * The default is IGNORE_SELECTION.
143    */
144   vtkSetMacro(SelectionMode, int);
145   vtkGetMacro(SelectionMode, int);
SetSelectionModeToSelectedIcon()146   virtual void SetSelectionModeToSelectedIcon() { this->SetSelectionMode(SELECTED_ICON); }
SetSelectionModeToSelectedOffset()147   virtual void SetSelectionModeToSelectedOffset() { this->SetSelectionMode(SELECTED_OFFSET); }
SetSelectionModeToAnnotationIcon()148   virtual void SetSelectionModeToAnnotationIcon() { this->SetSelectionMode(ANNOTATION_ICON); }
SetSelectionModeToIgnoreSelection()149   virtual void SetSelectionModeToIgnoreSelection() { this->SetSelectionMode(IGNORE_SELECTION); }
150   ///@}
151 
152   ///@{
153   /**
154    * The attribute type to append the icon array to, used only if the
155    * input array is not specified or does not exist. This is set to one
156    * of the AttributeTypes enum in vtkDataObject (e.g. POINT, CELL, VERTEX
157    * EDGE, FIELD).
158    */
159   vtkSetMacro(AttributeType, int);
160   vtkGetMacro(AttributeType, int);
161   ///@}
162 
163 protected:
164   vtkApplyIcons();
165   ~vtkApplyIcons() override;
166 
167   /**
168    * Convert the vtkGraph into vtkPolyData.
169    */
170   int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
171 
172   /**
173    * Set the input type of the algorithm to vtkGraph.
174    */
175   int FillInputPortInformation(int port, vtkInformation* info) override;
176 
177   int DefaultIcon;
178   int SelectedIcon;
179   bool UseLookupTable;
180   char* IconOutputArrayName;
181   int SelectionMode;
182   int AttributeType;
183 
184   class Internals;
185   Internals* Implementation;
186 
187 private:
188   vtkApplyIcons(const vtkApplyIcons&) = delete;
189   void operator=(const vtkApplyIcons&) = delete;
190 };
191 
192 #endif
193