source: vtkvis/tags/1.7.1/Renderer.h @ 6307

Last change on this file since 6307 was 3993, checked in by ldelgass, 11 years ago

Add method to vtkvis renderer to set depth peeling parameters

  • Property svn:eol-style set to native
File size: 36.5 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright (C) 2004-2012  HUBzero Foundation, LLC
4 *
5 * Author: Leif Delgass <ldelgass@purdue.edu>
6 */
7
8#ifndef VTKVIS_RENDERER_H
9#define VTKVIS_RENDERER_H
10
11#include <string>
12#include <vector>
13#include <tr1/unordered_map>
14#include <typeinfo>
15
16#include <vtkSmartPointer.h>
17#ifdef USE_CUSTOM_AXES
18#include "vtkRpCubeAxesActor.h"
19#else
20#include <vtkCubeAxesActor.h>
21#endif
22#include <vtkAxesActor.h>
23#include <vtkAnnotatedCubeActor.h>
24#include <vtkScalarBarActor.h>
25#include <vtkRenderer.h>
26#include <vtkRenderWindow.h>
27#include <vtkUnsignedCharArray.h>
28
29#include "ColorMap.h"
30#include "Types.h"
31#include "DataSet.h"
32#include "Arc.h"
33#include "Arrow.h"
34#include "Box.h"
35#include "Cone.h"
36#include "Contour2D.h"
37#include "Contour3D.h"
38#include "Cutplane.h"
39#include "Cylinder.h"
40#include "Disk.h"
41#include "Glyphs.h"
42#include "Group.h"
43#include "HeightMap.h"
44#include "Image.h"
45#include "LIC.h"
46#include "Line.h"
47#include "Molecule.h"
48#include "Outline.h"
49#include "Parallelepiped.h"
50#include "PolyData.h"
51#include "Polygon.h"
52#include "PseudoColor.h"
53#include "Sphere.h"
54#include "Streamlines.h"
55#include "Text3D.h"
56#include "Volume.h"
57#include "Warp.h"
58#include "Trace.h"
59
60// Controls if TGA format is sent to client
61//#define RENDER_TARGA
62#define TARGA_BYTES_PER_PIXEL 3
63
64namespace VtkVis {
65
66/**
67 * \brief VTK Renderer
68 */
69class Renderer
70{
71public:
72    Renderer();
73    virtual ~Renderer();
74
75    enum AxisRangeMode {
76        RANGE_AUTO = 0,
77        RANGE_SCALE_BOUNDS,
78        RANGE_EXPLICIT
79    };
80
81    enum AxesFlyMode {
82        FLY_OUTER_EDGES = 0,
83        FLY_CLOSEST_TRIAD,
84        FLY_FURTHEST_TRIAD,
85        FLY_STATIC_EDGES,
86        FLY_STATIC_TRIAD
87    };
88
89    enum AxesTickPosition {
90        TICKS_INSIDE,
91        TICKS_OUTSIDE,
92        TICKS_BOTH
93    };
94
95    enum CameraMode {
96        PERSPECTIVE,
97        ORTHO,
98        IMAGE
99    };
100
101    enum Aspect {
102        ASPECT_NATIVE,
103        ASPECT_SQUARE,
104        ASPECT_WINDOW
105    };
106
107    enum LegendType {
108        LEGEND_SCALAR,
109        LEGEND_VECTOR_MAGNITUDE,
110        LEGEND_VECTOR_X,
111        LEGEND_VECTOR_Y,
112        LEGEND_VECTOR_Z
113    };
114
115    typedef std::string DataSetId;
116    typedef std::string ColorMapId;
117    typedef std::string FieldId;
118
119    // Data sets
120
121    void addDataSet(const DataSetId& id);
122
123    void deleteDataSet(const DataSetId& id);
124
125    DataSet *getDataSet(const DataSetId& id);
126
127    void getDataSetNames(std::vector<std::string>& names);
128
129    bool setData(const DataSetId& id, char *data, int nbytes);
130
131    bool setDataFile(const DataSetId& id, const char *filename);
132
133    bool setDataSetActiveScalars(const DataSetId& id, const char *scalarName);
134
135    bool setDataSetActiveVectors(const DataSetId& id, const char *vectorName);
136
137    bool getScalarValueAtPixel(const DataSetId& id, int x, int y, double *value);
138
139    bool getScalarValue(const DataSetId& id, double x, double y, double z, double *value);
140
141    bool getVectorValueAtPixel(const DataSetId& id, int x, int y, double vector[3]);
142
143    bool getVectorValue(const DataSetId& id, double x, double y, double z, double vector[3]);
144
145    void setDataSetOpacity(const DataSetId& id, double opacity);
146
147    void setDataSetVisibility(const DataSetId& id, bool state);
148
149    void setUseCumulativeDataRange(bool state, bool onlyVisible = false);
150
151    bool getUseCumulativeRange();
152
153    bool setCumulativeDataRange(double *range, const char *name,
154                                DataSet::DataAttributeType type,
155                                int numComponents,
156                                int component = -1);
157
158    bool getCumulativeDataRange(double *range, const char *name,
159                                int numComponents,
160                                int component = -1);
161
162    bool getCumulativeDataRange(double *range, const char *name,
163                                DataSet::DataAttributeType type,
164                                int numComponents,
165                                int component = -1);
166
167    // Render window
168
169    /// Get the VTK render window object this Renderer uses
170    vtkRenderWindow *getRenderWindow()
171    {
172        return _renderWindow;
173    }
174
175    void setWindowSize(int width, int height);
176
177    int getWindowWidth() const;
178
179    int getWindowHeight() const;
180
181    // Lights
182
183    int addLight(float pos[3]);
184
185    vtkLight *getLight(int lightIdx);
186
187    void setLightSwitch(int lightIdx, bool state);
188
189    // Camera controls
190
191    void setViewAngle(int height);
192
193    /// Return the VTK camera object this Renderer uses
194    vtkCamera *getVtkCamera()
195    {
196        if (_renderer != NULL)
197            return _renderer->GetActiveCamera();
198        else
199            return NULL;
200    }
201
202    bool isCameraMaximized()
203    {
204        return (_cameraZoomRatio == 1.0 &&
205                _cameraPan[0] == 0.0 &&
206                _cameraPan[1] == 0.0);
207    }
208
209    void getImageCameraSizes(int *imgWidthPx, int *imgHeightPx,
210                             int *_pxOffsetX = NULL, int *_pxOffsetY = NULL);
211
212    double getImageCameraAspect();
213
214    void setCameraMode(CameraMode mode);
215
216    CameraMode getCameraMode() const;
217
218    void setCameraAspect(Aspect aspect);
219
220    void resetVtkCamera(double *bounds = NULL);
221
222    void resetCamera(bool resetOrientation = true);
223
224    void resetCameraClippingRange();
225
226    bool setCameraZoomRegionPixels(int x, int y, int width, int height);
227
228    bool setCameraZoomRegion(double x, double y, double width, double height);
229
230    void getCameraZoomRegion(double xywh[4]) const;
231
232    void getScreenWorldCoords(double xywh[4]) const;
233
234    void rotateCamera(double yaw, double pitch, double roll);
235
236    void setCameraOrientation(const double quat[4], bool absolute = true);
237
238    void panCamera(double x, double y, bool absolute = true);
239
240    void zoomCamera(double z, bool absolute = true);
241
242    void setCameraOrientationAndPosition(const double position[3],
243                                         const double focalPoint[3],
244                                         const double viewUp[3]);
245
246    void getCameraOrientationAndPosition(double position[3],
247                                         double focalPoint[3],
248                                         double viewUp[3]);
249
250    void eventuallyResetCamera()
251    {
252        _needsCameraReset = true;
253    }
254
255    bool needsCameraReset()
256    {
257        return _needsCameraReset;
258    }
259
260    void eventuallyResetCameraClippingRange()
261    {
262        _needsCameraClippingRangeReset = true;
263    }
264
265    bool needsCameraClippingRangeReset()
266    {
267        return _needsCameraClippingRangeReset;
268    }
269
270    // Rendering an image
271
272    void setBackgroundColor(float color[3]);
273
274    void setClipPlane(Axis axis, double ratio, int direction);
275
276    void setUseTwoSidedLighting(bool state);
277
278    void setUseDepthPeeling(bool state);
279
280    void setDepthPeelingParams(double occlusionRatio = 0.0, int maxPeels = 0);
281
282    void eventuallyRender();
283
284    bool render();
285
286    void getRenderedFrame(vtkUnsignedCharArray *imgData);
287
288    // Axes
289
290    void setAxesOrigin(double x, double y, double z, bool useCustom = true);
291
292    void setAxesAutoBounds(bool state);
293
294    void setAxesBounds(double min, double max);
295
296    void setAxesAutoRange(bool state);
297
298    void setAxisBounds(Axis axis, double min, double max);
299
300    void setAxesScale(double scale);
301
302    void setAxesRange(double min, double max);
303
304    void setAxesLabelPowerScaling(int xPow, int yPow, int zPow, bool useCustom = true);
305
306    void setAxisAutoBounds(Axis axis, bool state);
307
308    void setAxisAutoRange(Axis axis, bool state);
309
310    void setAxisScale(Axis axis, double scale);
311
312    void setAxisRange(Axis axis, double min, double max);
313
314    void setAxesFlyMode(AxesFlyMode mode);
315
316    void setAxesVisibility(bool state);
317
318    void setAxesGridVisibility(bool state);
319
320    void setAxesInnerGridVisibility(bool state);
321
322    void setAxesGridpolysVisibility(bool state);
323
324    void setAxesLabelVisibility(bool state);
325
326    void setAxesTickVisibility(bool state);
327
328    void setAxesMinorTickVisibility(bool state);
329
330    void setAxesTickPosition(AxesTickPosition pos);
331
332    void setAxesColor(double color[3], double opacity = 1.0);
333
334    void setAxesTitleColor(double color[3], double opacity = 1.0);
335
336    void setAxesLabelColor(double color[3], double opacity = 1.0);
337
338    void setAxesLinesColor(double color[3], double opacity = 1.0);
339
340    void setAxesGridlinesColor(double color[3], double opacity = 1.0);
341
342    void setAxesInnerGridlinesColor(double color[3], double opacity = 1.0);
343
344    void setAxesGridpolysColor(double color[3], double opacity = 1.0);
345
346    void setAxesLabelScaling(bool autoScale, int xpow, int ypow, int zpow);
347
348    void setAxesPixelFontSize(double screenSize);
349
350    void setAxesTitleFont(const char *fontName);
351
352    void setAxesTitleFontSize(int sz);
353
354    void setAxesTitleOrientation(double orientation);
355
356    void setAxesLabelFont(const char *fontName);
357
358    void setAxesLabelFontSize(int sz);
359
360    void setAxesLabelOrientation(double orientation);
361
362    void setAxesLabelFormat(const char *format);
363
364    void setAxisVisibility(Axis axis, bool state);
365
366    void setAxisGridVisibility(Axis axis, bool state);
367
368    void setAxisInnerGridVisibility(Axis axis, bool state);
369
370    void setAxisGridpolysVisibility(Axis axis, bool state);
371
372    void setAxisLabelVisibility(Axis axis, bool state);
373
374    void setAxisTickVisibility(Axis axis, bool state);
375
376    void setAxisMinorTickVisibility(Axis axis, bool state);
377
378    void setAxisColor(Axis axis, double color[3], double opacity = 1.0);
379
380    void setAxisTitleColor(Axis axis, double color[3], double opacity = 1.0);
381
382    void setAxisLabelColor(Axis axis, double color[3], double opacity = 1.0);
383
384    void setAxisLinesColor(Axis axis, double color[3], double opacity = 1.0);
385
386    void setAxisGridlinesColor(Axis axis, double color[3], double opacity = 1.0);
387
388    void setAxisInnerGridlinesColor(Axis axis, double color[3], double opacity = 1.0);
389
390    void setAxisGridpolysColor(Axis axis, double color[3], double opacity = 1.0);
391
392    void setAxisTitle(Axis axis, const char *title);
393
394    void setAxisUnits(Axis axis, const char *units);
395
396    void setAxisTitleFont(Axis axis, const char *fontName);
397
398    void setAxisTitleFontSize(Axis axis, int sz);
399
400    void setAxisTitleOrientation(Axis axis, double orientation);
401
402    void setAxisLabelFont(Axis axis, const char *fontName);
403
404    void setAxisLabelFontSize(Axis axis, int sz);
405
406    void setAxisLabelOrientation(Axis axis, double orientation);
407
408    void setAxisLabelFormat(Axis axis, const char *format);
409
410    void eventuallyResetAxes()
411    {
412        _needsAxesReset = true;
413    }
414
415    bool needsAxesReset()
416    {
417        return _needsAxesReset;
418    }
419
420    // Colormaps
421
422    void addColorMap(const ColorMapId& id, ColorMap *colorMap);
423
424    void deleteColorMap(const ColorMapId& id);
425
426    ColorMap *getColorMap(const ColorMapId& id);
427
428    void setColorMapNumberOfTableEntries(const ColorMapId& id, int numEntries);
429
430    bool renderColorMap(const ColorMapId& id,
431                        int width, int height,
432                        bool opaque,
433                        vtkUnsignedCharArray *imgData);
434
435    bool renderColorMap(const ColorMapId& id,
436                        const DataSetId& dataSetID,
437                        LegendType legendType,
438                        const char *fieldName,
439                        DataSet::DataAttributeType type,
440                        std::string& title,
441                        double range[2],
442                        int width, int height,
443                        bool opaque,
444                        int numLabels,
445                        vtkUnsignedCharArray *imgData);
446
447    bool renderColorMap(const ColorMapId& id,
448                        const DataSetId& dataSetID,
449                        LegendType legendType,
450                        const char *fieldName,
451                        std::string& title,
452                        double range[2],
453                        int width, int height,
454                        bool opaque,
455                        int numLabels,
456                        vtkUnsignedCharArray *imgData);
457
458    bool renderColorMap(const ColorMapId& id,
459                        const DataSetId& dataSetID,
460                        LegendType legendType,
461                        std::string& title,
462                        double range[2],
463                        int width, int height,
464                        bool opaque,
465                        int numLabels,
466                        vtkUnsignedCharArray *imgData);
467
468    // Generic GraphicsObject methods
469
470    GraphicsObject *getGenericGraphicsObject(const DataSetId& id);
471
472    template<class T>
473    T *getGraphicsObject(const DataSetId& id);
474
475    template<class T>
476    bool addGraphicsObject(const DataSetId& id);
477
478    template<class T>
479    void deleteGraphicsObject(const DataSetId& id);
480
481    template<class T>
482    void deleteAllGraphicsObjects();
483
484    template<class T>
485    void mergeGraphicsObjectBounds(double *bounds, bool onlyVisible);
486
487    template<class T>
488    void mergeGraphicsObjectUnscaledBounds(double *bounds, bool onlyVisible);
489
490    template<class T>
491    void updateGraphicsObjectFieldRanges();
492
493    template<class T>
494    void setGraphicsObjectClippingPlanes(vtkPlaneCollection *planes);
495
496    template<class T>
497    void setGraphicsObjectAspect(double aspectRatio);
498
499    template<class T>
500    void setGraphicsObjectInterpolateBeforeMapping(const DataSetId& id, bool state);
501
502    template<class T>
503    void setGraphicsObjectColorMap(const DataSetId& id, const ColorMapId& colorMapId);
504
505    template<class T>
506    void updateGraphicsObjectColorMap(ColorMap *cmap);
507
508    template<class T>
509    bool graphicsObjectColorMapUsed(ColorMap *cmap);
510
511    template<class T>
512    void setGraphicsObjectVolumeSlice(const DataSetId& id, Axis axis, double ratio);
513
514    //   Prop/Prop3D properties
515
516    template<class T>
517    void setGraphicsObjectOrientation(const DataSetId& id, double quat[4]);
518
519    template<class T>
520    void setGraphicsObjectOrientation(const DataSetId& id, double angle, double axis[3]);
521
522    template<class T>
523    void setGraphicsObjectOrigin(const DataSetId& id, double origin[3]);
524
525    template<class T>
526    void setGraphicsObjectPosition(const DataSetId& id, double pos[3]);
527
528    template<class T>
529    void setGraphicsObjectAspect(const DataSetId& id, double aspect);
530
531    template<class T>
532    void setGraphicsObjectScale(const DataSetId& id, double scale[3]);
533
534    template<class T>
535    void setGraphicsObjectTransform(const DataSetId& id, vtkMatrix4x4 *trans);
536
537    template<class T>
538    void setGraphicsObjectVisibility(const DataSetId& id, bool state);
539
540    //   Actor properties
541
542    template<class T>
543    void setGraphicsObjectColor(const DataSetId& id, float color[3]);
544
545    template<class T>
546    void setGraphicsObjectCullFace(const DataSetId& id, GraphicsObject::CullFace state);
547
548    template<class T>
549    void setGraphicsObjectCulling(const DataSetId& id, bool state);
550
551    template<class T>
552    void setGraphicsObjectEdgeVisibility(const DataSetId& id, bool state);
553
554    template<class T>
555    void setGraphicsObjectEdgeColor(const DataSetId& id, float color[3]);
556
557    template<class T>
558    void setGraphicsObjectEdgeWidth(const DataSetId& id, float edgeWidth);
559
560    template<class T>
561    void setGraphicsObjectAmbient(const DataSetId& id, double coeff);
562
563    template<class T>
564    void setGraphicsObjectDiffuse(const DataSetId& id, double coeff);
565
566    template<class T>
567    void setGraphicsObjectShadingModel(const DataSetId& id, GraphicsObject::ShadingModel state);
568
569    template<class T>
570    void setGraphicsObjectSpecular(const DataSetId& id, double coeff, double power);
571
572    template<class T>
573    void setGraphicsObjectLighting(const DataSetId& id, bool state);
574
575    template<class T>
576    void setGraphicsObjectOpacity(const DataSetId& id, double opacity);
577
578    template<class T>
579    void setGraphicsObjectPointSize(const DataSetId& id, float size);
580
581    template<class T>
582    void setGraphicsObjectWireframe(const DataSetId& id, bool state);
583
584    // For Shapes:
585
586    template<class T>
587    void setGraphicsObjectFlipNormals(const DataSetId& id, bool state);
588
589    // Arcs
590
591    bool addArc(const DataSetId& id, double center[3], double pt1[3],
592                double normal[3], double angle);
593
594    void setArcResolution(const DataSetId& id, int res);
595
596    // Arrows
597
598    bool addArrow(const DataSetId& id, double tipRadius, double shaftRadius,
599                  double tipLength, bool flipNormals = false);
600
601    void setArrowResolution(const DataSetId& id, int resTip, int resShaft);
602
603    // Boxes
604
605    bool addBox(const DataSetId& id, double xLen, double yLen, double zLen,
606                bool flipNormals = false);
607
608    // Cones
609
610    bool addCone(const DataSetId& id, double radius, double height, bool cap,
611                 bool flipNormals = false);
612
613    void setConeResolution(const DataSetId& id, int res);
614
615    // 2D Contour plots
616
617    bool addContour2D(const DataSetId& id, int numContours);
618
619    bool addContour2D(const DataSetId& id, const std::vector<double>& contours);
620
621    void setContour2DContourField(const DataSetId& id, const char *fieldName);
622
623    void setContour2DNumContours(const DataSetId& id, int numContours);
624
625    void setContour2DContourList(const DataSetId& id, const std::vector<double>& contours);
626
627    void setContour2DColorMode(const DataSetId& id,
628                               Contour2D::ColorMode mode,
629                               const char *name, double range[2] = NULL);
630
631    void setContour2DColorMode(const DataSetId& id,
632                               Contour2D::ColorMode mode,
633                               DataSet::DataAttributeType type,
634                               const char *name, double range[2] = NULL);
635
636    // 3D Contour (isosurface) plots
637
638    bool addContour3D(const DataSetId& id, int numContours);
639
640    bool addContour3D(const DataSetId& id, const std::vector<double>& contours);
641
642    void setContour3DContourField(const DataSetId& id, const char *fieldName);
643
644    void setContour3DNumContours(const DataSetId& id, int numContours);
645
646    void setContour3DContourList(const DataSetId& id, const std::vector<double>& contours);
647
648    void setContour3DColorMode(const DataSetId& id,
649                               Contour3D::ColorMode mode,
650                               const char *name, double range[2] = NULL);
651
652    void setContour3DColorMode(const DataSetId& id,
653                               Contour3D::ColorMode mode,
654                               DataSet::DataAttributeType type,
655                               const char *name, double range[2] = NULL);
656
657    // Cutplanes
658
659    void setCutplaneCloudStyle(const DataSetId& id,
660                               Cutplane::CloudStyle style);
661
662    void setCutplaneOutlineVisibility(const DataSetId& id, bool state);
663
664    void setCutplaneSliceVisibility(const DataSetId& id, Axis axis, bool state);
665
666    void setCutplaneColorMode(const DataSetId& id,
667                              Cutplane::ColorMode mode,
668                              const char *name, double range[2] = NULL);
669
670    void setCutplaneColorMode(const DataSetId& id,
671                              Cutplane::ColorMode mode,
672                              DataSet::DataAttributeType type,
673                              const char *name, double range[2] = NULL);
674
675    // Cylinders
676
677    bool addCylinder(const DataSetId& id, double radius, double height, bool cap, bool flipNormals = false);
678
679    void setCylinderCapping(const DataSetId& id, bool state);
680
681    void setCylinderResolution(const DataSetId& id, int res);
682
683    // Disks
684
685    bool addDisk(const DataSetId& id, double innerRadius, double outerRadius, bool flipNormals = false);
686
687    void setDiskResolution(const DataSetId& id, int resRadial, int resCircum);
688
689    // Glyphs
690
691    bool addGlyphs(const DataSetId& id, Glyphs::GlyphShape shape);
692
693    void setGlyphsShape(const DataSetId& id, Glyphs::GlyphShape shape);
694
695    void setGlyphsOrientMode(const DataSetId& id, bool state, const char *name);
696
697    void setGlyphsQuality(const DataSetId& id, double quality);
698
699    void setGlyphsColorMode(const DataSetId& id,
700                            Glyphs::ColorMode mode,
701                            const char *name,
702                            double range[2] = NULL);
703
704    void setGlyphsScalingMode(const DataSetId& id,
705                              Glyphs::ScalingMode mode,
706                              const char *name,
707                              double range[2] = NULL);
708
709    void setGlyphsNormalizeScale(const DataSetId& id, bool normalize);
710
711    void setGlyphsScaleFactor(const DataSetId& id, double scale);
712
713    void setGlyphsMaximumNumberOfGlyphs(const DataSetId& id, int max,
714                                        bool random = true,
715                                        int offset = 0, int ratio = 1);
716
717    // Groups
718
719    bool addGroup(const DataSetId& id, const std::vector<Group::NodeId>& nodeList);
720
721    void addChildrenToGroup(const DataSetId& id, const std::vector<Group::NodeId>& nodeList);
722
723    void removeChildrenFromGroup(const DataSetId& id, const std::vector<Group::NodeId>& nodeList);
724
725    // Height maps
726
727    bool addHeightMap(const DataSetId& id, int numContours, double heightScale);
728
729    bool addHeightMap(const DataSetId& id, const std::vector<double>& contours, double heightScale);
730
731    void setHeightMapHeightScale(const DataSetId& id, double scale);
732
733    void setHeightMapCloudStyle(const DataSetId& id,
734                                HeightMap::CloudStyle style);
735
736    void setHeightMapNumContours(const DataSetId& id, int numContours);
737
738    void setHeightMapContourList(const DataSetId& id, const std::vector<double>& contours);
739
740    void setHeightMapContourSurfaceVisibility(const DataSetId& id, bool state);
741
742    void setHeightMapContourLineVisibility(const DataSetId& id, bool state);
743
744    void setHeightMapContourLineColorMapEnabled(const DataSetId& id, bool mode);
745
746    void setHeightMapContourEdgeColor(const DataSetId& id, float color[3]);
747
748    void setHeightMapContourEdgeWidth(const DataSetId& id, float edgeWidth);
749
750    void setHeightMapColorMode(const DataSetId& id,
751                               HeightMap::ColorMode mode,
752                               const char *name, double range[2] = NULL);
753
754    void setHeightMapColorMode(const DataSetId& id,
755                               HeightMap::ColorMode mode,
756                               DataSet::DataAttributeType type,
757                               const char *name, double range[2] = NULL);
758
759    // Images
760
761    void setImageBackground(const DataSetId& id, bool state);
762
763    void setImageBacking(const DataSetId& id, bool state);
764
765    void setImageBorder(const DataSetId& id, bool state);
766
767    void setImageExtents(const DataSetId& id, int extents[6]);
768
769    void setImageLevel(const DataSetId& id, double level);
770
771    void setImageWindow(const DataSetId& id, double window);
772
773    void setImageZSlice(const DataSetId& id, int z);
774
775    // Lines
776
777    bool addLine(const DataSetId& id, double pt1[3], double pt2[3]);
778
779    bool addLine(const DataSetId& id, std::vector<double> points);
780
781    // Molecules
782
783    void setMoleculeAtomQuality(const DataSetId& id, double quality);
784
785    void setMoleculeBondQuality(const DataSetId& id, double quality);
786
787    void setMoleculeAtomRadiusScale(const DataSetId& id, double scale);
788
789    void setMoleculeBondRadiusScale(const DataSetId& id, double scale);
790
791    void setMoleculeAtomScaling(const DataSetId& id, Molecule::AtomScaling scaling);
792
793    void setMoleculeAtomVisibility(const DataSetId& id, bool state);
794
795    void setMoleculeAtomLabelField(const DataSetId& id, const char *fieldName);
796
797    void setMoleculeAtomLabelVisibility(const DataSetId& id, bool state);
798
799    void setMoleculeBondVisibility(const DataSetId& id, bool state);
800
801    void setMoleculeBondStyle(const DataSetId& id, Molecule::BondStyle style);
802
803    void setMoleculeBondColorMode(const DataSetId& id, Molecule::BondColorMode mode);
804
805    void setMoleculeBondColor(const DataSetId& id, float color[3]);
806
807    void setMoleculeColorMode(const DataSetId& id,
808                              Molecule::ColorMode mode,
809                              const char *name, double range[2] = NULL);
810
811    void setMoleculeColorMode(const DataSetId& id,
812                              Molecule::ColorMode mode,
813                              DataSet::DataAttributeType type,
814                              const char *name, double range[2] = NULL);
815
816    // Parallelepipeds
817
818    bool addParallelepiped(const DataSetId& id, double vec1[3], double vec2[3], double vec3[3],
819                           bool flipNormals = false);
820
821    // PolyData meshes
822
823    void setPolyDataCloudStyle(const DataSetId& id,
824                               PolyData::CloudStyle style);
825
826    void setPolyDataColorMode(const DataSetId& id,
827                              PolyData::ColorMode mode,
828                              const char *name, double range[2] = NULL);
829
830    void setPolyDataColorMode(const DataSetId& id,
831                              PolyData::ColorMode mode,
832                              DataSet::DataAttributeType type,
833                              const char *name, double range[2] = NULL);
834
835    // N-sided Regular Polygons
836
837    bool addPolygon(const DataSetId& id, int numSides, double center[3], double normal[3], double radius);
838
839    // Color-mapped surfaces
840
841    void setPseudoColorCloudStyle(const DataSetId& id,
842                                  PseudoColor::CloudStyle style);
843
844    void setPseudoColorColorMode(const DataSetId& id,
845                                 PseudoColor::ColorMode mode,
846                                 const char *name, double range[2] = NULL);
847
848    void setPseudoColorColorMode(const DataSetId& id,
849                                 PseudoColor::ColorMode mode,
850                                 DataSet::DataAttributeType type,
851                                 const char *name, double range[2] = NULL);
852
853    // Spheres
854
855    bool addSphere(const DataSetId& id, double center[3], double radius, bool flipNormals = false);
856
857    void setSphereSection(const DataSetId& id,
858                          double thetaStart, double thetaEnd,
859                          double phiStart, double phiEnd);
860
861    void setSphereResolution(const DataSetId& id, int thetaRes, int phiRes);
862
863    // Streamlines
864
865    void setStreamlinesColorMode(const DataSetId& id,
866                                 Streamlines::ColorMode mode,
867                                 const char *name, double range[2] = NULL);
868
869    void setStreamlinesColorMode(const DataSetId& id,
870                                 Streamlines::ColorMode mode,
871                                 DataSet::DataAttributeType type,
872                                 const char *name, double range[2] = NULL);
873
874    void setStreamlinesLength(const DataSetId& id, double length);
875
876    void setStreamlinesNumberOfSeedPoints(const DataSetId& id, int numPoints);
877
878    void setStreamlinesSeedColor(const DataSetId& id, float color[3]);
879
880    void setStreamlinesSeedPointSize(const DataSetId& id, float size);
881
882    void setStreamlinesSeedToMeshPoints(const DataSetId& id,
883                                        int maxPoints = 500);
884
885    void setStreamlinesSeedToFilledMesh(const DataSetId& id, int numPoints);
886
887    bool setStreamlinesSeedToMeshPoints(const DataSetId& id,
888                                        char *data, size_t nbytes,
889                                        int maxPoints = 500);
890
891    bool setStreamlinesSeedToFilledMesh(const DataSetId& id,
892                                        char *data, size_t nbytes,
893                                        int numPoints);
894
895    void setStreamlinesSeedToRake(const DataSetId& id,
896                                  double start[3], double end[3],
897                                  int numPoints);
898
899    void setStreamlinesSeedToDisk(const DataSetId& id,
900                                  double center[3], double normal[3],
901                                  double radius, double innerRadius,
902                                  int numPoints);
903
904    void setStreamlinesSeedToPolygon(const DataSetId& id,
905                                     double center[3], double normal[3],
906                                     double angle, double radius,
907                                     int numSides);
908
909    void setStreamlinesSeedToFilledPolygon(const DataSetId& id,
910                                           double center[3], double normal[3],
911                                           double angle, double radius,
912                                           int numSides, int numPoints);
913
914    void setStreamlinesSeedVisibility(const DataSetId& id, bool state);
915
916    void setStreamlinesTerminalSpeed(const DataSetId& id, double speed);
917
918    void setStreamlinesTypeToLines(const DataSetId& id);
919
920    void setStreamlinesTypeToTubes(const DataSetId& id, int numSides, double radius);
921
922    void setStreamlinesTypeToRibbons(const DataSetId& id, double width, double angle);
923
924    // Text3Ds
925
926    bool addText3D(const DataSetId& id, const char *string,
927                   const char *fontFamily, int fontSize,
928                   bool bold = false, bool italic = false, bool shadow = false);
929
930    void setText3DBold(const DataSetId& id, bool state);
931
932    void setText3DFollowCamera(const DataSetId& id, bool state);
933
934    void setText3DFont(const DataSetId& id, const char *fontFamily);
935
936    void setText3DFontSize(const DataSetId& id, int size);
937
938    void setText3DItalic(const DataSetId& id, bool state);
939
940    void setText3DShadow(const DataSetId& id, bool state);
941
942    void setText3DText(const DataSetId& id, const char *text);
943
944    // Volumes
945
946    void setVolumeBlendMode(const DataSetId& id, Volume::BlendMode mode);
947
948    void setVolumeSampleDistance(const DataSetId& id, double distance);
949
950    // Warps
951
952    void setWarpCloudStyle(const DataSetId& id,
953                           Warp::CloudStyle style);
954
955    void setWarpColorMode(const DataSetId& id,
956                          Warp::ColorMode mode,
957                          const char *name, double range[2] = NULL);
958
959    void setWarpColorMode(const DataSetId& id,
960                          Warp::ColorMode mode,
961                          DataSet::DataAttributeType type,
962                          const char *name, double range[2] = NULL);
963
964
965    void setWarpWarpScale(const DataSetId& id, double scale);
966
967private:
968    typedef std::tr1::unordered_map<DataSetId, DataSet *> DataSetHashmap;
969    typedef std::tr1::unordered_map<FieldId, double *> FieldRangeHashmap;
970    typedef std::tr1::unordered_map<ColorMapId, ColorMap *> ColorMapHashmap;
971
972    typedef std::tr1::unordered_map<DataSetId, Arc *> ArcHashmap;
973    typedef std::tr1::unordered_map<DataSetId, Arrow *> ArrowHashmap;
974    typedef std::tr1::unordered_map<DataSetId, Box *> BoxHashmap;
975    typedef std::tr1::unordered_map<DataSetId, Cone *> ConeHashmap;
976    typedef std::tr1::unordered_map<DataSetId, Contour2D *> Contour2DHashmap;
977    typedef std::tr1::unordered_map<DataSetId, Contour3D *> Contour3DHashmap;
978    typedef std::tr1::unordered_map<DataSetId, Cutplane *> CutplaneHashmap;
979    typedef std::tr1::unordered_map<DataSetId, Cylinder *> CylinderHashmap;
980    typedef std::tr1::unordered_map<DataSetId, Disk *> DiskHashmap;
981    typedef std::tr1::unordered_map<DataSetId, Glyphs *> GlyphsHashmap;
982    typedef std::tr1::unordered_map<DataSetId, Group *> GroupHashmap;
983    typedef std::tr1::unordered_map<DataSetId, HeightMap *> HeightMapHashmap;
984    typedef std::tr1::unordered_map<DataSetId, Image *> ImageHashmap;
985    typedef std::tr1::unordered_map<DataSetId, LIC *> LICHashmap;
986    typedef std::tr1::unordered_map<DataSetId, Line *> LineHashmap;
987    typedef std::tr1::unordered_map<DataSetId, Molecule *> MoleculeHashmap;
988    typedef std::tr1::unordered_map<DataSetId, Outline *> OutlineHashmap;
989    typedef std::tr1::unordered_map<DataSetId, Parallelepiped *> ParallelepipedHashmap;
990    typedef std::tr1::unordered_map<DataSetId, PolyData *> PolyDataHashmap;
991    typedef std::tr1::unordered_map<DataSetId, Polygon *> PolygonHashmap;
992    typedef std::tr1::unordered_map<DataSetId, PseudoColor *> PseudoColorHashmap;
993    typedef std::tr1::unordered_map<DataSetId, Sphere *> SphereHashmap;
994    typedef std::tr1::unordered_map<DataSetId, Streamlines *> StreamlinesHashmap;
995    typedef std::tr1::unordered_map<DataSetId, Text3D *> Text3DHashmap;
996    typedef std::tr1::unordered_map<DataSetId, Volume *> VolumeHashmap;
997    typedef std::tr1::unordered_map<DataSetId, Warp *> WarpHashmap;
998
999    void _setCameraZoomRegionPixels(int x, int y, int width, int height);
1000
1001    void _setCameraZoomRegion(double x, double y, double width, double height);
1002
1003    //static void printCameraInfo(vtkCamera *camera);
1004
1005    static void setCameraFromMatrix(vtkCamera *camera, vtkMatrix4x4 &mat);
1006
1007    static void mergeBounds(double *boundsDest, const double *bounds1, const double *bounds2);
1008
1009    template<class T>
1010    std::tr1::unordered_map<DataSetId, T *>& getGraphicsObjectHashmap();
1011
1012    void setObjectAspects(double aspectRatio);
1013
1014    void collectBounds(double *bounds, bool onlyVisible);
1015
1016    void collectUnscaledBounds(double *bounds, bool onlyVisible);
1017
1018    void collectDataRanges();
1019
1020    void collectDataRanges(double *range, const char *name,
1021                           DataSet::DataAttributeType type,
1022                           int component, bool onlyVisible);
1023
1024    void clearFieldRanges();
1025
1026    void clearUserFieldRanges();
1027
1028    void initFieldRanges();
1029
1030    void updateFieldRanges();
1031
1032    void updateColorMap(ColorMap *cmap);
1033
1034    bool colorMapUsed(ColorMap *cmap);
1035
1036    void computeDisplayToWorld(double x, double y, double z, double worldPt[4]);
1037
1038    void computeWorldToDisplay(double x, double y, double z, double displayPt[3]);
1039
1040    void computeScreenWorldCoords();
1041
1042    bool is2D(const double bounds[6],
1043              PrincipalPlane *plane,
1044              double *offset) const;
1045
1046    void initCamera(bool initCameraMode = false);
1047
1048    void sceneBoundsChanged();
1049
1050    void initOrientationMarkers();
1051
1052    void initAxes();
1053
1054    void resetAxes(double bounds[6] = NULL);
1055
1056    void setAxesBounds(double bounds[6] = NULL);
1057
1058    void setAxesRanges();
1059
1060    void computeAxesScale();
1061
1062    void setCameraClippingPlanes();
1063
1064    bool _needsRedraw;
1065    bool _needsAxesReset;
1066    bool _needsCameraClippingRangeReset;
1067    bool _needsCameraReset;
1068
1069    int _windowWidth, _windowHeight;
1070    CameraMode _cameraMode;
1071    Aspect _cameraAspect;
1072    double _imgWorldOrigin[2];
1073    double _imgWorldDims[2];
1074    double _imgWindowWorldDims[2];
1075    double _userImgWorldOrigin[2];
1076    double _userImgWorldDims[2];
1077    PrincipalPlane _imgCameraPlane;
1078    double _imgCameraOffset;
1079    double _screenWorldCoords[4];
1080    double _cameraOrientation[4];
1081    double _cameraZoomRatio;
1082    double _cameraPan[2];
1083    float _bgColor[3];
1084    bool _useCumulativeRange;
1085    bool _cumulativeRangeOnlyVisible;
1086
1087    FieldRangeHashmap _scalarPointDataRange;
1088    FieldRangeHashmap _vectorPointDataRange;
1089    FieldRangeHashmap _vectorCompPointDataRange[3];
1090    FieldRangeHashmap _scalarCellDataRange;
1091    FieldRangeHashmap _vectorCellDataRange;
1092    FieldRangeHashmap _vectorCompCellDataRange[3];
1093    FieldRangeHashmap _scalarFieldDataRange;
1094    FieldRangeHashmap _vectorFieldDataRange;
1095    FieldRangeHashmap _vectorCompFieldDataRange[3];
1096
1097    FieldRangeHashmap _userScalarPointDataRange;
1098    FieldRangeHashmap _userVectorPointDataRange;
1099    FieldRangeHashmap _userVectorCompPointDataRange[3];
1100    FieldRangeHashmap _userScalarCellDataRange;
1101    FieldRangeHashmap _userVectorCellDataRange;
1102    FieldRangeHashmap _userVectorCompCellDataRange[3];
1103    FieldRangeHashmap _userScalarFieldDataRange;
1104    FieldRangeHashmap _userVectorFieldDataRange;
1105    FieldRangeHashmap _userVectorCompFieldDataRange[3];
1106
1107    bool _axesAutoBounds[3];
1108    double _axesUserBounds[6];
1109    AxisRangeMode _axesRangeMode[3];
1110    double _axesScale[3];
1111
1112    ColorMapHashmap _colorMaps;
1113    DataSetHashmap _dataSets;
1114    ArcHashmap _arcs;
1115    ArrowHashmap _arrows;
1116    BoxHashmap _boxes;
1117    ConeHashmap _cones;
1118    Contour2DHashmap _contour2Ds;
1119    Contour3DHashmap _contour3Ds;
1120    CutplaneHashmap _cutplanes;
1121    CylinderHashmap _cylinders;
1122    DiskHashmap _disks;
1123    GlyphsHashmap _glyphs;
1124    GroupHashmap _groups;
1125    HeightMapHashmap _heightMaps;
1126    ImageHashmap _images;
1127    LICHashmap _lics;
1128    LineHashmap _lines;
1129    MoleculeHashmap _molecules;
1130    OutlineHashmap _outlines;
1131    ParallelepipedHashmap _parallelepipeds;
1132    PolyDataHashmap _polyDatas;
1133    PolygonHashmap _polygons;
1134    PseudoColorHashmap _pseudoColors;
1135    SphereHashmap _spheres;
1136    StreamlinesHashmap _streamlines;
1137    Text3DHashmap _text3Ds;
1138    VolumeHashmap _volumes;
1139    WarpHashmap _warps;
1140
1141    vtkSmartPointer<vtkPlane> _cameraClipPlanes[4];
1142    vtkSmartPointer<vtkPlane> _userClipPlanes[6];
1143    vtkSmartPointer<vtkPlaneCollection> _activeClipPlanes;
1144#ifdef USE_CUSTOM_AXES
1145    vtkSmartPointer<vtkRpCubeAxesActor> _cubeAxesActor;
1146#else
1147    vtkSmartPointer<vtkCubeAxesActor> _cubeAxesActor;
1148#endif
1149    vtkSmartPointer<vtkAxesActor> _axesActor;
1150    vtkSmartPointer<vtkAnnotatedCubeActor> _annotatedCubeActor;
1151    vtkSmartPointer<vtkScalarBarActor> _scalarBarActor;
1152    vtkSmartPointer<vtkRenderer> _renderer;
1153    vtkSmartPointer<vtkRenderer> _legendRenderer;
1154    vtkSmartPointer<vtkRenderWindow> _renderWindow;
1155    vtkSmartPointer<vtkRenderWindow> _legendRenderWindow;
1156};
1157
1158}
1159
1160#endif
Note: See TracBrowser for help on using the repository browser.