10 #ifndef smtk_extension_paraview_representation_vtkSMTKResourceRepresentation_h
11 #define smtk_extension_paraview_representation_vtkSMTKResourceRepresentation_h
13 #include <vtkProperty.h>
14 #include <vtkSmartPointer.h>
16 #include <vtkPVDataRepresentation.h>
19 #include "smtk/common/UUID.h"
20 #include "smtk/extension/paraview/server/smtkPVServerExtModule.h"
21 #include "smtk/extension/vtk/filter/vtkApplyTransforms.h"
22 #include "smtk/view/SelectionObserver.h"
27 #include <unordered_map>
32 class vtkCompositeDataSet;
33 class vtkCompositeDataDisplayAttributes;
34 class vtkCompositePolyDataMapper2;
36 class vtkGlyph3DMapper;
38 class vtkMultiBlockDataSet;
39 class vtkScalarsToColors;
98 void PrintSelf(ostream& os, vtkIndent indent)
override;
121 int ProcessViewRequest(
122 vtkInformationRequestKey* request_type,
123 vtkInformation* inInfo,
124 vtkInformation* outInfo)
override;
125 int RequestData(vtkInformation* info, vtkInformationVector** inVec, vtkInformationVector* outVec)
127 bool AddToView(vtkView* view)
override;
128 bool RemoveFromView(vtkView* view)
override;
129 void SetVisibility(
bool val)
override;
135 void SetMapScalars(
int val);
136 void SetInterpolateScalarsBeforeMapping(
int val);
137 void SetPointSize(
double val);
138 void SetLineWidth(
double val);
139 void SetLineColor(
double r,
double g,
double b);
140 void SetLookupTable(vtkScalarsToColors* val);
141 void SetEdgeVisibility(
int val);
142 void SetRenderLinesAsTubes(
int val);
143 void SetRenderPointsAsSpheres(
int val);
144 void SetVertexVisibility(
int val);
150 virtual void SetDefaultEdgeColor(
double r,
double g,
double b);
151 virtual void SetDefaultEdgeColor(
const double* rgb);
152 virtual double* GetDefaultEdgeColor();
154 virtual void SetDefaultFaceColor(
double r,
double g,
double b);
155 virtual void SetDefaultFaceColor(
const double* rgb);
156 virtual double* GetDefaultFaceColor();
158 vtkSetVector3Macro(SelectionColor,
double);
159 vtkGetVector3Macro(SelectionColor,
double);
160 vtkSetVector3Macro(HoverColor,
double);
161 vtkGetVector3Macro(HoverColor,
double);
162 void SetSelectionPointSize(
double val);
163 void SetSelectionLineWidth(
double val);
164 void SetSelectionRenderStyle(
int style);
165 void SetOpacity(
double val);
166 void SetPosition(
double x,
double y,
double z);
167 void SetScale(
double x,
double y,
double z);
168 void SetOrientation(
double x,
double y,
double z);
169 void SetOrigin(
double x,
double y,
double z);
170 void SetUserTransform(
const double matrix[16]);
171 void SetSpecularPower(
double val);
172 void SetSpecular(
double val);
173 void SetDiffuse(
double val);
174 void SetAmbient(
double val);
175 void SetPickable(
int val);
176 void SetTexture(vtkTexture* val);
178 vtkSetStringMacro(ActiveAssembly);
179 vtkGetStringMacro(ActiveAssembly);
186 void SetBlockVisibility(
unsigned int index,
bool visible);
187 bool GetBlockVisibility(
unsigned int index)
const;
188 void RemoveBlockVisibility(
unsigned int index,
bool =
true);
189 void RemoveBlockVisibilities();
190 void SetBlockColor(
unsigned int index,
double r,
double g,
double b);
191 void SetBlockColor(
unsigned int index,
double* color);
192 double* GetBlockColor(
unsigned int index);
193 void RemoveBlockColor(
unsigned int index);
194 void RemoveBlockColors();
195 void SetBlockOpacity(
unsigned int index,
double opacity);
196 void SetBlockOpacity(
unsigned int index,
double* opacity);
197 double GetBlockOpacity(
unsigned int index);
198 void RemoveBlockOpacity(
unsigned int index);
199 void RemoveBlockOpacities();
214 void SetSelectedState(vtkDataObject* data,
int selectionValue,
bool isGlyph);
221 void SetInstanceVisibility(
unsigned int index,
bool visible);
222 bool GetInstanceVisibility(
unsigned int index)
const;
223 void RemoveInstanceVisibility(
unsigned int index,
bool);
224 void RemoveInstanceVisibilities();
225 void SetInstanceColor(
unsigned int index,
double r,
double g,
double b);
226 void SetInstanceColor(
unsigned int index,
double* color);
227 double* GetInstanceColor(
unsigned int index);
228 void RemoveInstanceColor(
unsigned int index);
229 void RemoveInstanceColors();
240 WIREFRAME = VTK_WIREFRAME,
241 SURFACE = VTK_SURFACE,
242 SURFACE_WITH_EDGES = 3
245 vtkSetClampMacro(Representation,
int, POINTS, SURFACE_WITH_EDGES);
246 vtkGetMacro(Representation,
int);
251 void SetRepresentation(
const char* type);
265 vtkSetClampMacro(ColorBy,
int, ENTITY, FIELD);
266 vtkGetMacro(ColorBy,
int);
271 void SetColorBy(
const char* type);
276 void SelectionModified();
281 void SetUseInternalAttributes(
bool enable);
284 virtual void SetWrapper(vtkSMTKWrapper*);
285 vtkGetObjectMacro(Wrapper, vtkSMTKWrapper);
290 void GetEntityVisibilities(std::map<smtk::common::UUID, int>& visdata);
308 RenderableDataMap& renderables,
311 static bool ApplyDefaultStyle(
313 RenderableDataMap& renderables,
317 bool SelectComponentFootprint(
320 RenderableDataMap& renderables);
323 bool SelectComponentFootprint(
326 RenderableDataMap& renderables);
347 vtkCompositeDataDisplayAttributes* GetEntityMapperDisplayAttributes();
348 vtkCompositeDataDisplayAttributes* GetSelectedEntityMapperDisplayAttributes();
356 vtkSmartPointer<vtkActor> GetSelectedEntitiesActor() {
return this->SelectedEntities; }
357 vtkSmartPointer<vtkActor> GetGlyphEntitiesActor() {
return this->GlyphEntities; }
358 vtkSmartPointer<vtkActor> GetSelectedGlyphEntitiesActor() {
return this->SelectedGlyphEntities; }
364 int FillInputPortInformation(
int port, vtkInformation* info)
override;
365 void SetupDefaults();
366 void SetOutputExtent(vtkAlgorithmOutput* output, vtkInformation* inInfo);
367 void ConfigureGlyphMapper(vtkGlyph3DMapper* mapper);
369 void UpdateRenderableData(vtkMultiBlockDataSet* modelData, vtkMultiBlockDataSet* instanceData);
370 void UpdateDisplayAttributesFromSelection(
371 vtkMultiBlockDataSet* modelData,
372 vtkMultiBlockDataSet* instanceData);
373 void UpdateSelection(
374 vtkMultiBlockDataSet* data,
375 vtkCompositeDataDisplayAttributes* blockAttr,
387 void ClearSelection(vtkMapper* mapper);
392 void UpdateColoringParameters(vtkDataObject* data);
397 void UpdateRepresentationSubtype();
403 void ColorByVolume(vtkMultiBlockDataSet* data);
404 void ColorByEntity(vtkMultiBlockDataSet* data);
417 void ApplyInternalBlockAttributes();
418 void ApplyEntityAttributes(vtkMapper* mapper);
419 void ApplyGlyphBlockAttributes(vtkGlyph3DMapper* mapper);
427 bool GetModelBounds();
428 bool GetEntityBounds(
429 vtkDataObject* dataObject,
431 vtkCompositeDataDisplayAttributes* cdAttributes);
441 vtkSMTKWrapper* Wrapper{
nullptr };
453 double DataBounds[6];
454 int Representation = SURFACE;
456 bool UpdateColorBy =
false;
457 bool UseInternalAttributes =
false;
459 vtkNew<vtkApplyTransforms> ApplyTransforms;
460 vtkNew<vtkMultiBlockDataSet> CurrentData;
461 vtkSmartPointer<vtkCompositePolyDataMapper2> EntityMapper;
462 vtkSmartPointer<vtkCompositePolyDataMapper2> SelectedEntityMapper;
464 vtkSmartPointer<vtkGlyph3DMapper> GlyphMapper;
465 vtkSmartPointer<vtkGlyph3DMapper> SelectedGlyphMapper;
467 vtkSmartPointer<vtkActor> Entities;
468 vtkSmartPointer<vtkActor> SelectedEntities;
469 vtkSmartPointer<vtkActor> GlyphEntities;
470 vtkSmartPointer<vtkActor> SelectedGlyphEntities;
473 int EntitiesActorPickId{ -1 };
474 int SelectedEntitiesActorPickId{ -1 };
475 int GlyphEntitiesActorPickId{ -1 };
476 int SelectedGlyphEntitiesActorPickId{ -1 };
484 double Specular = 0.;
486 double DefaultEdgeColor[3] = { 0., 0., 0. };
487 double DefaultFaceColor[3] = { 1., 1., 1. };
488 double SelectionColor[3] = { 1., 0.48235, 0.0 };
489 double HoverColor[3] = { 0.7, 0.483, 0.5873 };
495 bool BlockAttrChanged =
false;
496 vtkTimeStamp BlockAttributeTime;
497 std::unordered_map<unsigned int, bool> BlockVisibilities;
498 std::unordered_map<unsigned int, double> BlockOpacities;
499 std::unordered_map<unsigned int, std::array<double, 3>> BlockColors;
506 bool InstanceAttrChanged =
false;
507 vtkTimeStamp InstanceAttributeTime;
508 std::unordered_map<unsigned int, bool> InstanceVisibilities;
509 std::unordered_map<unsigned int, std::array<double, 3>> InstanceColors;
522 char* ActiveAssembly{
nullptr };