VTK
dox/Views/Infovis/vtkRenderedGraphRepresentation.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkRenderedGraphRepresentation.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 /*-------------------------------------------------------------------------
00016   Copyright 2008 Sandia Corporation.
00017   Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00018   the U.S. Government retains certain rights in this software.
00019 -------------------------------------------------------------------------*/
00031 #ifndef __vtkRenderedGraphRepresentation_h
00032 #define __vtkRenderedGraphRepresentation_h
00033 
00034 #include "vtkViewsInfovisModule.h" // For export macro
00035 #include "vtkRenderedRepresentation.h"
00036 #include "vtkSmartPointer.h" // for SP ivars
00037 
00038 class vtkActor;
00039 class vtkApplyColors;
00040 class vtkApplyIcons;
00041 class vtkEdgeCenters;
00042 class vtkEdgeLayout;
00043 class vtkEdgeLayoutStrategy;
00044 class vtkGraphLayout;
00045 class vtkGraphLayoutStrategy;
00046 class vtkGraphToGlyphs;
00047 class vtkGraphToPoints;
00048 class vtkGraphToPolyData;
00049 class vtkIconGlyphFilter;
00050 class vtkInformation;
00051 class vtkInformationVector;
00052 class vtkLookupTable;
00053 class vtkPerturbCoincidentVertices;
00054 class vtkPointSetToLabelHierarchy;
00055 class vtkPolyData;
00056 class vtkPolyDataMapper;
00057 class vtkPolyDataMapper2D;
00058 class vtkRemoveHiddenData;
00059 class vtkRenderView;
00060 class vtkScalarBarWidget;
00061 class vtkScalarsToColors;
00062 class vtkTextProperty;
00063 class vtkTexturedActor2D;
00064 class vtkTransformCoordinateSystems;
00065 class vtkVertexDegree;
00066 class vtkView;
00067 class vtkViewTheme;
00068 
00069 class VTKVIEWSINFOVIS_EXPORT vtkRenderedGraphRepresentation : public vtkRenderedRepresentation
00070 {
00071 public:
00072   static vtkRenderedGraphRepresentation* New();
00073   vtkTypeMacro(vtkRenderedGraphRepresentation, vtkRenderedRepresentation);
00074   void PrintSelf(ostream& os, vtkIndent indent);
00075 
00076   // ------------------------------------------------------------------------
00077   // Vertex labels
00078 
00079   virtual void SetVertexLabelArrayName(const char* name);
00080   virtual const char* GetVertexLabelArrayName();
00081   virtual void SetVertexLabelPriorityArrayName(const char* name);
00082   virtual const char* GetVertexLabelPriorityArrayName();
00083   virtual void SetVertexLabelVisibility(bool b);
00084   virtual bool GetVertexLabelVisibility();
00085   vtkBooleanMacro(VertexLabelVisibility, bool);
00086   virtual void SetVertexLabelTextProperty(vtkTextProperty* p);
00087   virtual vtkTextProperty* GetVertexLabelTextProperty();
00088   vtkSetStringMacro(VertexHoverArrayName);
00089   vtkGetStringMacro(VertexHoverArrayName);
00091 
00093   vtkSetMacro(HideVertexLabelsOnInteraction, bool)
00094   vtkGetMacro(HideVertexLabelsOnInteraction, bool)
00095   vtkBooleanMacro(HideVertexLabelsOnInteraction, bool)
00097 
00098   // ------------------------------------------------------------------------
00099   // Edge labels
00100 
00101   virtual void SetEdgeLabelArrayName(const char* name);
00102   virtual const char* GetEdgeLabelArrayName();
00103   virtual void SetEdgeLabelPriorityArrayName(const char* name);
00104   virtual const char* GetEdgeLabelPriorityArrayName();
00105   virtual void SetEdgeLabelVisibility(bool b);
00106   virtual bool GetEdgeLabelVisibility();
00107   vtkBooleanMacro(EdgeLabelVisibility, bool);
00108   virtual void SetEdgeLabelTextProperty(vtkTextProperty* p);
00109   virtual vtkTextProperty* GetEdgeLabelTextProperty();
00110   vtkSetStringMacro(EdgeHoverArrayName);
00111   vtkGetStringMacro(EdgeHoverArrayName);
00113 
00115   vtkSetMacro(HideEdgeLabelsOnInteraction, bool)
00116   vtkGetMacro(HideEdgeLabelsOnInteraction, bool)
00117   vtkBooleanMacro(HideEdgeLabelsOnInteraction, bool)
00119 
00120   // ------------------------------------------------------------------------
00121   // Vertex icons
00122 
00123   virtual void SetVertexIconArrayName(const char* name);
00124   virtual const char* GetVertexIconArrayName();
00125   virtual void SetVertexIconPriorityArrayName(const char* name);
00126   virtual const char* GetVertexIconPriorityArrayName();
00127   virtual void SetVertexIconVisibility(bool b);
00128   virtual bool GetVertexIconVisibility();
00129   vtkBooleanMacro(VertexIconVisibility, bool);
00130   virtual void AddVertexIconType(const char* name, int type);
00131   virtual void ClearVertexIconTypes();
00132   virtual void SetUseVertexIconTypeMap(bool b);
00133   virtual bool GetUseVertexIconTypeMap();
00134   vtkBooleanMacro(UseVertexIconTypeMap, bool);
00135   virtual void SetVertexIconAlignment(int align);
00136   virtual int GetVertexIconAlignment();
00137   virtual void SetVertexSelectedIcon(int icon);
00138   virtual int GetVertexSelectedIcon();
00139   virtual void SetVertexDefaultIcon(int icon);
00140   virtual int GetVertexDefaultIcon();
00141 
00143 
00148   virtual void SetVertexIconSelectionMode(int mode);
00149   virtual int GetVertexIconSelectionMode();
00150   virtual void SetVertexIconSelectionModeToSelectedIcon()
00151     { this->SetVertexIconSelectionMode(0); }
00152   virtual void SetVertexIconSelectionModeToSelectedOffset()
00153     { this->SetVertexIconSelectionMode(1); }
00154   virtual void SetVertexIconSelectionModeToAnnotationIcon()
00155     { this->SetVertexIconSelectionMode(2); }
00156   virtual void SetVertexIconSelectionModeToIgnoreSelection()
00157     { this->SetVertexIconSelectionMode(3); }
00159 
00160   // ------------------------------------------------------------------------
00161   // Edge icons
00162 
00163   virtual void SetEdgeIconArrayName(const char* name);
00164   virtual const char* GetEdgeIconArrayName();
00165   virtual void SetEdgeIconPriorityArrayName(const char* name);
00166   virtual const char* GetEdgeIconPriorityArrayName();
00167   virtual void SetEdgeIconVisibility(bool b);
00168   virtual bool GetEdgeIconVisibility();
00169   vtkBooleanMacro(EdgeIconVisibility, bool);
00170   virtual void AddEdgeIconType(const char* name, int type);
00171   virtual void ClearEdgeIconTypes();
00172   virtual void SetUseEdgeIconTypeMap(bool b);
00173   virtual bool GetUseEdgeIconTypeMap();
00174   vtkBooleanMacro(UseEdgeIconTypeMap, bool);
00175   virtual void SetEdgeIconAlignment(int align);
00176   virtual int GetEdgeIconAlignment();
00177 
00178   // ------------------------------------------------------------------------
00179   // Vertex colors
00180 
00181   virtual void SetColorVerticesByArray(bool b);
00182   virtual bool GetColorVerticesByArray();
00183   vtkBooleanMacro(ColorVerticesByArray, bool);
00184   virtual void SetVertexColorArrayName(const char* name);
00185   virtual const char* GetVertexColorArrayName();
00186 
00187   // ------------------------------------------------------------------------
00188   // Edge colors
00189 
00190   virtual void SetColorEdgesByArray(bool b);
00191   virtual bool GetColorEdgesByArray();
00192   vtkBooleanMacro(ColorEdgesByArray, bool);
00193   virtual void SetEdgeColorArrayName(const char* name);
00194   virtual const char* GetEdgeColorArrayName();
00195 
00196   // ------------------------------------------------------------------------
00197   // Enabled vertices
00198 
00199   virtual void SetEnableVerticesByArray(bool b);
00200   virtual bool GetEnableVerticesByArray();
00201   vtkBooleanMacro(EnableVerticesByArray, bool);
00202   virtual void SetEnabledVerticesArrayName(const char* name);
00203   virtual const char* GetEnabledVerticesArrayName();
00204 
00205   // ------------------------------------------------------------------------
00206   // Enabled edges
00207 
00208   virtual void SetEnableEdgesByArray(bool b);
00209   virtual bool GetEnableEdgesByArray();
00210   vtkBooleanMacro(EnableEdgesByArray, bool);
00211   virtual void SetEnabledEdgesArrayName(const char* name);
00212   virtual const char* GetEnabledEdgesArrayName();
00213 
00214   virtual void SetEdgeVisibility(bool b);
00215   virtual bool GetEdgeVisibility();
00216   vtkBooleanMacro(EdgeVisibility, bool);
00217 
00218   void SetEdgeSelection(bool b);
00219   bool GetEdgeSelection();
00220 
00221   // ------------------------------------------------------------------------
00222   // Vertex layout strategy
00223 
00225 
00226   virtual void SetLayoutStrategy(vtkGraphLayoutStrategy* strategy);
00227   virtual vtkGraphLayoutStrategy* GetLayoutStrategy();
00229 
00231 
00232   virtual void SetLayoutStrategy(const char* name);
00233   vtkGetStringMacro(LayoutStrategyName);
00235 
00237 
00238   void SetLayoutStrategyToRandom()
00239     { this->SetLayoutStrategy("Random"); }
00240   void SetLayoutStrategyToForceDirected()
00241     { this->SetLayoutStrategy("Force Directed"); }
00242   void SetLayoutStrategyToSimple2D()
00243     { this->SetLayoutStrategy("Simple 2D"); }
00244   void SetLayoutStrategyToClustering2D()
00245     { this->SetLayoutStrategy("Clustering 2D"); }
00246   void SetLayoutStrategyToCommunity2D()
00247     { this->SetLayoutStrategy("Community 2D"); }
00248   void SetLayoutStrategyToFast2D()
00249     { this->SetLayoutStrategy("Fast 2D"); }
00250   void SetLayoutStrategyToPassThrough()
00251     { this->SetLayoutStrategy("Pass Through"); }
00252   void SetLayoutStrategyToCircular()
00253     { this->SetLayoutStrategy("Circular"); }
00254   void SetLayoutStrategyToTree()
00255     { this->SetLayoutStrategy("Tree"); }
00256   void SetLayoutStrategyToCosmicTree()
00257     { this->SetLayoutStrategy("Cosmic Tree"); }
00258   void SetLayoutStrategyToCone()
00259     { this->SetLayoutStrategy("Cone"); }
00260   void SetLayoutStrategyToSpanTree()
00261     { this->SetLayoutStrategy("Span Tree"); }
00263 
00265 
00267   virtual void SetLayoutStrategyToAssignCoordinates(
00268     const char* xarr, const char* yarr = 0, const char* zarr = 0);
00270 
00272 
00281   virtual void SetLayoutStrategyToTree(
00282     bool radial,
00283     double angle = 90,
00284     double leafSpacing = 0.9,
00285     double logSpacing = 1.0);
00287 
00289 
00298   virtual void SetLayoutStrategyToCosmicTree(
00299     const char* nodeSizeArrayName,
00300     bool sizeLeafNodesOnly = true,
00301     int layoutDepth = 0,
00302     vtkIdType layoutRoot = -1);
00304 
00305   // ------------------------------------------------------------------------
00306   // Edge layout strategy
00307 
00309 
00310   virtual void SetEdgeLayoutStrategy(vtkEdgeLayoutStrategy* strategy);
00311   virtual vtkEdgeLayoutStrategy* GetEdgeLayoutStrategy();
00312   void SetEdgeLayoutStrategyToArcParallel()
00313     { this->SetEdgeLayoutStrategy("Arc Parallel"); }
00314   void SetEdgeLayoutStrategyToPassThrough()
00315     { this->SetEdgeLayoutStrategy("Pass Through"); }
00317 
00320   virtual void SetEdgeLayoutStrategyToGeo(double explodeFactor = 0.2);
00321 
00323 
00324   virtual void SetEdgeLayoutStrategy(const char* name);
00325   vtkGetStringMacro(EdgeLayoutStrategyName);
00327 
00328   // ------------------------------------------------------------------------
00329   // Miscellaneous
00330 
00332   virtual void ApplyViewTheme(vtkViewTheme* theme);
00333 
00335 
00336   virtual void SetGlyphType(int type);
00337   virtual int GetGlyphType();
00339 
00341 
00342   virtual void SetScaling(bool b);
00343   virtual bool GetScaling();
00344   vtkBooleanMacro(Scaling, bool);
00346 
00348 
00349   virtual void SetScalingArrayName(const char* name);
00350   virtual const char* GetScalingArrayName();
00352 
00354 
00355   virtual void SetVertexScalarBarVisibility(bool b);
00356   virtual bool GetVertexScalarBarVisibility();
00357   virtual void SetEdgeScalarBarVisibility(bool b);
00358   virtual bool GetEdgeScalarBarVisibility();
00360 
00362 
00364   virtual vtkScalarBarWidget* GetVertexScalarBar();
00365   virtual vtkScalarBarWidget* GetEdgeScalarBar();
00367 
00369   virtual bool IsLayoutComplete();
00370 
00372   virtual void UpdateLayout();
00373 
00375   void ComputeSelectedGraphBounds( double bounds[6] );
00376 
00377 protected:
00378   vtkRenderedGraphRepresentation();
00379   ~vtkRenderedGraphRepresentation();
00380 
00382 
00383   virtual bool AddToView(vtkView* view);
00384   virtual bool RemoveFromView(vtkView* view);
00386 
00387   virtual void PrepareForRendering(vtkRenderView* view);
00388 
00389   virtual vtkSelection* ConvertSelection(vtkView* view, vtkSelection* sel);
00390 
00391   virtual vtkUnicodeString GetHoverTextInternal(vtkSelection* sel);
00392 
00394 
00395   virtual int RequestData(
00396     vtkInformation* request,
00397     vtkInformationVector** inputVector,
00398     vtkInformationVector* outputVector);
00400 
00401   //BTX
00403 
00404   vtkSmartPointer<vtkApplyColors>          ApplyColors;
00405   vtkSmartPointer<vtkVertexDegree>         VertexDegree;
00406   vtkSmartPointer<vtkPolyData>             EmptyPolyData;
00407   vtkSmartPointer<vtkEdgeCenters>          EdgeCenters;
00408   vtkSmartPointer<vtkGraphToPoints>        GraphToPoints;
00409   vtkSmartPointer<vtkPointSetToLabelHierarchy> VertexLabelHierarchy;
00410   vtkSmartPointer<vtkPointSetToLabelHierarchy> EdgeLabelHierarchy;
00411   vtkSmartPointer<vtkGraphLayout>          Layout;
00412   vtkSmartPointer<vtkPerturbCoincidentVertices> Coincident;
00413   vtkSmartPointer<vtkEdgeLayout>           EdgeLayout;
00414   vtkSmartPointer<vtkGraphToPolyData>      GraphToPoly;
00415   vtkSmartPointer<vtkPolyDataMapper>       EdgeMapper;
00416   vtkSmartPointer<vtkActor>                EdgeActor;
00417   vtkSmartPointer<vtkGraphToGlyphs>        VertexGlyph;
00418   vtkSmartPointer<vtkPolyDataMapper>       VertexMapper;
00419   vtkSmartPointer<vtkActor>                VertexActor;
00420   vtkSmartPointer<vtkGraphToGlyphs>        OutlineGlyph;
00421   vtkSmartPointer<vtkPolyDataMapper>       OutlineMapper;
00422   vtkSmartPointer<vtkActor>                OutlineActor;
00423   vtkSmartPointer<vtkScalarBarWidget>      VertexScalarBar;
00424   vtkSmartPointer<vtkScalarBarWidget>      EdgeScalarBar;
00425   vtkSmartPointer<vtkRemoveHiddenData>     RemoveHiddenGraph;
00426   vtkSmartPointer<vtkApplyIcons>           ApplyVertexIcons;
00427   vtkSmartPointer<vtkGraphToPoints>        VertexIconPoints;
00428   vtkSmartPointer<vtkTransformCoordinateSystems> VertexIconTransform;
00429   vtkSmartPointer<vtkIconGlyphFilter>      VertexIconGlyph;
00430   vtkSmartPointer<vtkPolyDataMapper2D>     VertexIconMapper;
00431   vtkSmartPointer<vtkTexturedActor2D>      VertexIconActor;
00432   //ETX
00434 
00435   char* VertexHoverArrayName;
00436   char* EdgeHoverArrayName;
00437 
00438   vtkSetStringMacro(VertexColorArrayNameInternal);
00439   vtkGetStringMacro(VertexColorArrayNameInternal);
00440   char* VertexColorArrayNameInternal;
00441 
00442   vtkSetStringMacro(EdgeColorArrayNameInternal);
00443   vtkGetStringMacro(EdgeColorArrayNameInternal);
00444   char* EdgeColorArrayNameInternal;
00445 
00446   vtkSetStringMacro(ScalingArrayNameInternal);
00447   vtkGetStringMacro(ScalingArrayNameInternal);
00448   char* ScalingArrayNameInternal;
00449 
00450   vtkSetStringMacro(LayoutStrategyName);
00451   char* LayoutStrategyName;
00452   vtkSetStringMacro(EdgeLayoutStrategyName);
00453   char* EdgeLayoutStrategyName;
00454   bool HideVertexLabelsOnInteraction;
00455   bool HideEdgeLabelsOnInteraction;
00456 
00457   bool EdgeSelection;
00458 
00459 private:
00460   vtkRenderedGraphRepresentation(const vtkRenderedGraphRepresentation&); // Not implemented
00461   void operator=(const vtkRenderedGraphRepresentation&);   // Not implemented
00462 };
00463 
00464 #endif
00465