10 #ifndef smtk_extension_paraview_representation_vtkSMTKResourceRepresentation_h
11 #define smtk_extension_paraview_representation_vtkSMTKResourceRepresentation_h
12 #include <unordered_map>
14 #include <vtkProperty.h>
15 #include <vtkSmartPointer.h>
17 #include <vtkPVDataRepresentation.h>
20 #include "smtk/common/UUID.h"
21 #include "smtk/extension/paraview/server/smtkPVServerExtModule.h"
22 #include "smtk/extension/vtk/filter/vtkApplyTransforms.h"
23 #include "smtk/view/SelectionObserver.h"
28 #include <unordered_map>
33 class vtkCompositeDataSet;
34 class vtkCompositeDataDisplayAttributes;
35 class vtkCompositePolyDataMapper2;
37 class vtkGlyph3DMapper;
39 class vtkMultiBlockDataSet;
40 class vtkScalarsToColors;
99 void PrintSelf(ostream& os, vtkIndent indent)
override;
122 int ProcessViewRequest(
123 vtkInformationRequestKey* request_type,
124 vtkInformation* inInfo,
125 vtkInformation* outInfo)
override;
126 int RequestData(vtkInformation* info, vtkInformationVector** inVec, vtkInformationVector* outVec)
128 bool AddToView(vtkView* view)
override;
129 bool RemoveFromView(vtkView* view)
override;
130 void SetVisibility(
bool val)
override;
136 void SetMapScalars(
int val);
137 void SetInterpolateScalarsBeforeMapping(
int val);
138 void SetPointSize(
double val);
139 void SetLineWidth(
double val);
140 void SetLineColor(
double r,
double g,
double b);
141 void SetLookupTable(vtkScalarsToColors* val);
142 void SetEdgeVisibility(
int val);
143 void SetRenderLinesAsTubes(
int val);
144 void SetRenderPointsAsSpheres(
int val);
145 void SetVertexVisibility(
int val);
151 virtual void SetDefaultEdgeColor(
double r,
double g,
double b);
152 virtual void SetDefaultEdgeColor(
const double* rgb);
153 virtual double* GetDefaultEdgeColor();
155 virtual void SetDefaultFaceColor(
double r,
double g,
double b);
156 virtual void SetDefaultFaceColor(
const double* rgb);
157 virtual double* GetDefaultFaceColor();
159 vtkSetVector3Macro(SelectionColor,
double);
160 vtkGetVector3Macro(SelectionColor,
double);
161 vtkSetVector3Macro(HoverColor,
double);
162 vtkGetVector3Macro(HoverColor,
double);
163 void SetSelectionPointSize(
double val);
164 void SetSelectionLineWidth(
double val);
165 void SetSelectionRenderStyle(
int style);
166 void SetOpacity(
double val);
167 void SetPosition(
double x,
double y,
double z);
168 void SetScale(
double x,
double y,
double z);
169 void SetOrientation(
double x,
double y,
double z);
170 void SetOrigin(
double x,
double y,
double z);
171 void SetUserTransform(
const double matrix[16]);
172 void SetSpecularPower(
double val);
173 void SetSpecular(
double val);
174 void SetDiffuse(
double val);
175 void SetAmbient(
double val);
176 void SetPickable(
int val);
177 void SetTexture(vtkTexture* val);
184 void SetBlockVisibility(
unsigned int index,
bool visible);
185 bool GetBlockVisibility(
unsigned int index)
const;
186 void RemoveBlockVisibility(
unsigned int index,
bool =
true);
187 void RemoveBlockVisibilities();
188 void SetBlockColor(
unsigned int index,
double r,
double g,
double b);
189 void SetBlockColor(
unsigned int index,
double* color);
190 double* GetBlockColor(
unsigned int index);
191 void RemoveBlockColor(
unsigned int index);
192 void RemoveBlockColors();
193 void SetBlockOpacity(
unsigned int index,
double opacity);
194 void SetBlockOpacity(
unsigned int index,
double* opacity);
195 double GetBlockOpacity(
unsigned int index);
196 void RemoveBlockOpacity(
unsigned int index);
197 void RemoveBlockOpacities();
212 void SetSelectedState(vtkDataObject* data,
int selectionValue,
bool isGlyph);
219 void SetInstanceVisibility(
unsigned int index,
bool visible);
220 bool GetInstanceVisibility(
unsigned int index)
const;
221 void RemoveInstanceVisibility(
unsigned int index,
bool);
222 void RemoveInstanceVisibilities();
223 void SetInstanceColor(
unsigned int index,
double r,
double g,
double b);
224 void SetInstanceColor(
unsigned int index,
double* color);
225 double* GetInstanceColor(
unsigned int index);
226 void RemoveInstanceColor(
unsigned int index);
227 void RemoveInstanceColors();
238 WIREFRAME = VTK_WIREFRAME,
239 SURFACE = VTK_SURFACE,
240 SURFACE_WITH_EDGES = 3
243 vtkSetClampMacro(Representation,
int, POINTS, SURFACE_WITH_EDGES);
244 vtkGetMacro(Representation,
int);
249 void SetRepresentation(
const char* type);
263 vtkSetClampMacro(ColorBy,
int, ENTITY, FIELD);
264 vtkGetMacro(ColorBy,
int);
269 void SetColorBy(
const char* type);
274 void SelectionModified();
279 void SetUseInternalAttributes(
bool enable);
282 virtual void SetWrapper(vtkSMTKWrapper*);
283 vtkGetObjectMacro(Wrapper, vtkSMTKWrapper);
288 void GetEntityVisibilities(std::map<smtk::common::UUID, int>& visdata);
306 RenderableDataMap& renderables,
309 static bool ApplyDefaultStyle(
311 RenderableDataMap& renderables,
315 bool SelectComponentFootprint(
318 RenderableDataMap& renderables);
321 bool SelectComponentFootprint(
324 RenderableDataMap& renderables);
345 vtkCompositeDataDisplayAttributes* GetEntityMapperDisplayAttributes();
346 vtkCompositeDataDisplayAttributes* GetSelectedEntityMapperDisplayAttributes();
354 vtkSmartPointer<vtkActor> GetSelectedEntitiesActor() {
return this->SelectedEntities; }
355 vtkSmartPointer<vtkActor> GetGlyphEntitiesActor() {
return this->GlyphEntities; }
356 vtkSmartPointer<vtkActor> GetSelectedGlyphEntitiesActor() {
return this->SelectedGlyphEntities; }
362 int FillInputPortInformation(
int port, vtkInformation* info)
override;
363 void SetupDefaults();
364 void SetOutputExtent(vtkAlgorithmOutput* output, vtkInformation* inInfo);
365 void ConfigureGlyphMapper(vtkGlyph3DMapper* mapper);
367 void UpdateRenderableData(vtkMultiBlockDataSet* modelData, vtkMultiBlockDataSet* instanceData);
368 void UpdateDisplayAttributesFromSelection(
369 vtkMultiBlockDataSet* modelData,
370 vtkMultiBlockDataSet* instanceData);
371 void UpdateSelection(
372 vtkMultiBlockDataSet* data,
373 vtkCompositeDataDisplayAttributes* blockAttr,
385 void ClearSelection(vtkMapper* mapper);
390 void UpdateColoringParameters(vtkDataObject* data);
395 void UpdateRepresentationSubtype();
401 void ColorByVolume(vtkMultiBlockDataSet* data);
402 void ColorByEntity(vtkMultiBlockDataSet* data);
415 void ApplyInternalBlockAttributes();
416 void ApplyEntityAttributes(vtkMapper* mapper);
417 void ApplyGlyphBlockAttributes(vtkGlyph3DMapper* mapper);
425 bool GetModelBounds();
426 bool GetEntityBounds(
427 vtkDataObject* dataObject,
429 vtkCompositeDataDisplayAttributes* cdAttributes);
439 vtkSMTKWrapper* Wrapper{
nullptr };
451 double DataBounds[6];
452 int Representation = SURFACE;
454 bool UpdateColorBy =
false;
455 bool UseInternalAttributes =
false;
457 vtkNew<vtkApplyTransforms> ApplyTransforms;
458 vtkNew<vtkMultiBlockDataSet> CurrentData;
459 vtkSmartPointer<vtkCompositePolyDataMapper2> EntityMapper;
460 vtkSmartPointer<vtkCompositePolyDataMapper2> SelectedEntityMapper;
462 vtkSmartPointer<vtkGlyph3DMapper> GlyphMapper;
463 vtkSmartPointer<vtkGlyph3DMapper> SelectedGlyphMapper;
465 vtkSmartPointer<vtkActor> Entities;
466 vtkSmartPointer<vtkActor> SelectedEntities;
467 vtkSmartPointer<vtkActor> GlyphEntities;
468 vtkSmartPointer<vtkActor> SelectedGlyphEntities;
471 int EntitiesActorPickId{ -1 };
472 int SelectedEntitiesActorPickId{ -1 };
473 int GlyphEntitiesActorPickId{ -1 };
474 int SelectedGlyphEntitiesActorPickId{ -1 };
482 double Specular = 0.;
484 double DefaultEdgeColor[3] = { 0., 0., 0. };
485 double DefaultFaceColor[3] = { 1., 1., 1. };
486 double SelectionColor[3] = { 1., 0.48235, 0.0 };
487 double HoverColor[3] = { 0.7, 0.483, 0.5873 };
493 bool BlockAttrChanged =
false;
494 vtkTimeStamp BlockAttributeTime;
495 std::unordered_map<unsigned int, bool> BlockVisibilities;
496 std::unordered_map<unsigned int, double> BlockOpacities;
497 std::unordered_map<unsigned int, std::array<double, 3>> BlockColors;
504 bool InstanceAttrChanged =
false;
505 vtkTimeStamp InstanceAttributeTime;
506 std::unordered_map<unsigned int, bool> InstanceVisibilities;
507 std::unordered_map<unsigned int, std::array<double, 3>> InstanceColors;