VTK
dox/Views/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 "vtkRenderedRepresentation.h"
00035 #include "vtkSmartPointer.h" // for SP ivars
00036 
00037 class vtkActor;
00038 class vtkApplyColors;
00039 class vtkApplyIcons;
00040 class vtkEdgeCenters;
00041 class vtkEdgeLayout;
00042 class vtkEdgeLayoutStrategy;
00043 class vtkGraphLayout;
00044 class vtkGraphLayoutStrategy;
00045 class vtkGraphToGlyphs;
00046 class vtkGraphToPoints;
00047 class vtkGraphToPolyData;
00048 class vtkIconGlyphFilter;
00049 class vtkInformation;
00050 class vtkInformationVector;
00051 class vtkLookupTable;
00052 class vtkPerturbCoincidentVertices;
00053 class vtkPointSetToLabelHierarchy;
00054 class vtkPolyData;
00055 class vtkPolyDataMapper;
00056 class vtkPolyDataMapper2D;
00057 class vtkRemoveHiddenData;
00058 class vtkRenderView;
00059 class vtkScalarBarWidget;
00060 class vtkScalarsToColors;
00061 class vtkTextProperty;
00062 class vtkTexturedActor2D;
00063 class vtkTransformCoordinateSystems;
00064 class vtkVertexDegree;
00065 class vtkView;
00066 class vtkViewTheme;
00067 
00068 class VTK_VIEWS_EXPORT vtkRenderedGraphRepresentation : public vtkRenderedRepresentation
00069 {
00070 public:
00071   static vtkRenderedGraphRepresentation* New();
00072   vtkTypeMacro(vtkRenderedGraphRepresentation, vtkRenderedRepresentation);
00073   void PrintSelf(ostream& os, vtkIndent indent);
00074 
00075   // ------------------------------------------------------------------------
00076   // Vertex labels
00077 
00078   virtual void SetVertexLabelArrayName(const char* name);
00079   virtual const char* GetVertexLabelArrayName();
00080   virtual void SetVertexLabelPriorityArrayName(const char* name);
00081   virtual const char* GetVertexLabelPriorityArrayName();
00082   virtual void SetVertexLabelVisibility(bool b);
00083   virtual bool GetVertexLabelVisibility();
00084   vtkBooleanMacro(VertexLabelVisibility, bool);
00085   virtual void SetVertexLabelTextProperty(vtkTextProperty* p);
00086   virtual vtkTextProperty* GetVertexLabelTextProperty();
00087   vtkSetStringMacro(VertexHoverArrayName);
00088   vtkGetStringMacro(VertexHoverArrayName);
00090 
00092   vtkSetMacro(HideVertexLabelsOnInteraction, bool)
00093   vtkGetMacro(HideVertexLabelsOnInteraction, bool)
00094   vtkBooleanMacro(HideVertexLabelsOnInteraction, bool)
00096 
00097   // ------------------------------------------------------------------------
00098   // Edge labels
00099 
00100   virtual void SetEdgeLabelArrayName(const char* name);
00101   virtual const char* GetEdgeLabelArrayName();
00102   virtual void SetEdgeLabelPriorityArrayName(const char* name);
00103   virtual const char* GetEdgeLabelPriorityArrayName();
00104   virtual void SetEdgeLabelVisibility(bool b);
00105   virtual bool GetEdgeLabelVisibility();
00106   vtkBooleanMacro(EdgeLabelVisibility, bool);
00107   virtual void SetEdgeLabelTextProperty(vtkTextProperty* p);
00108   virtual vtkTextProperty* GetEdgeLabelTextProperty();
00109   vtkSetStringMacro(EdgeHoverArrayName);
00110   vtkGetStringMacro(EdgeHoverArrayName);
00112 
00114   vtkSetMacro(HideEdgeLabelsOnInteraction, bool)
00115   vtkGetMacro(HideEdgeLabelsOnInteraction, bool)
00116   vtkBooleanMacro(HideEdgeLabelsOnInteraction, bool)
00118 
00119   // ------------------------------------------------------------------------
00120   // Vertex icons
00121 
00122   virtual void SetVertexIconArrayName(const char* name);
00123   virtual const char* GetVertexIconArrayName();
00124   virtual void SetVertexIconPriorityArrayName(const char* name);
00125   virtual const char* GetVertexIconPriorityArrayName();
00126   virtual void SetVertexIconVisibility(bool b);
00127   virtual bool GetVertexIconVisibility();
00128   vtkBooleanMacro(VertexIconVisibility, bool);
00129   virtual void AddVertexIconType(const char* name, int type);
00130   virtual void ClearVertexIconTypes();
00131   virtual void SetUseVertexIconTypeMap(bool b);
00132   virtual bool GetUseVertexIconTypeMap();
00133   vtkBooleanMacro(UseVertexIconTypeMap, bool);
00134   virtual void SetVertexIconAlignment(int align);
00135   virtual int GetVertexIconAlignment();
00136   virtual void SetVertexSelectedIcon(int icon);
00137   virtual int GetVertexSelectedIcon();
00138 
00140 
00145   virtual void SetVertexIconSelectionMode(int mode);
00146   virtual int GetVertexIconSelectionMode();
00147   virtual void SetVertexIconSelectionModeToSelectedIcon()
00148     { this->SetVertexIconSelectionMode(0); }
00149   virtual void SetVertexIconSelectionModeToSelectedOffset()
00150     { this->SetVertexIconSelectionMode(1); }
00151   virtual void SetVertexIconSelectionModeToAnnotationIcon()
00152     { this->SetVertexIconSelectionMode(2); }
00153   virtual void SetVertexIconSelectionModeToIgnoreSelection()
00154     { this->SetVertexIconSelectionMode(3); }
00156 
00157   // ------------------------------------------------------------------------
00158   // Edge icons
00159 
00160   virtual void SetEdgeIconArrayName(const char* name);
00161   virtual const char* GetEdgeIconArrayName();
00162   virtual void SetEdgeIconPriorityArrayName(const char* name);
00163   virtual const char* GetEdgeIconPriorityArrayName();
00164   virtual void SetEdgeIconVisibility(bool b);
00165   virtual bool GetEdgeIconVisibility();
00166   vtkBooleanMacro(EdgeIconVisibility, bool);
00167   virtual void AddEdgeIconType(const char* name, int type);
00168   virtual void ClearEdgeIconTypes();
00169   virtual void SetUseEdgeIconTypeMap(bool b);
00170   virtual bool GetUseEdgeIconTypeMap();
00171   vtkBooleanMacro(UseEdgeIconTypeMap, bool);
00172   virtual void SetEdgeIconAlignment(int align);
00173   virtual int GetEdgeIconAlignment();
00174 
00175   // ------------------------------------------------------------------------
00176   // Vertex colors
00177 
00178   virtual void SetColorVerticesByArray(bool b);
00179   virtual bool GetColorVerticesByArray();
00180   vtkBooleanMacro(ColorVerticesByArray, bool);
00181   virtual void SetVertexColorArrayName(const char* name);
00182   virtual const char* GetVertexColorArrayName();
00183 
00184   // ------------------------------------------------------------------------
00185   // Edge colors
00186 
00187   virtual void SetColorEdgesByArray(bool b);
00188   virtual bool GetColorEdgesByArray();
00189   vtkBooleanMacro(ColorEdgesByArray, bool);
00190   virtual void SetEdgeColorArrayName(const char* name);
00191   virtual const char* GetEdgeColorArrayName();
00192 
00193   // ------------------------------------------------------------------------
00194   // Enabled vertices
00195 
00196   virtual void SetEnableVerticesByArray(bool b);
00197   virtual bool GetEnableVerticesByArray();
00198   vtkBooleanMacro(EnableVerticesByArray, bool);
00199   virtual void SetEnabledVerticesArrayName(const char* name);
00200   virtual const char* GetEnabledVerticesArrayName();
00201 
00202   // ------------------------------------------------------------------------
00203   // Enabled edges
00204 
00205   virtual void SetEnableEdgesByArray(bool b);
00206   virtual bool GetEnableEdgesByArray();
00207   vtkBooleanMacro(EnableEdgesByArray, bool);
00208   virtual void SetEnabledEdgesArrayName(const char* name);
00209   virtual const char* GetEnabledEdgesArrayName();
00210 
00211   virtual void SetEdgeVisibility(bool b);
00212   virtual bool GetEdgeVisibility();
00213   vtkBooleanMacro(EdgeVisibility, bool);
00214 
00215   // ------------------------------------------------------------------------
00216   // Vertex layout strategy
00217 
00219 
00220   virtual void SetLayoutStrategy(vtkGraphLayoutStrategy* strategy);
00221   virtual vtkGraphLayoutStrategy* GetLayoutStrategy();
00223 
00225 
00226   virtual void SetLayoutStrategy(const char* name);
00227   vtkGetStringMacro(LayoutStrategyName);
00229 
00231 
00232   void SetLayoutStrategyToRandom()
00233     { this->SetLayoutStrategy("Random"); }
00234   void SetLayoutStrategyToForceDirected()
00235     { this->SetLayoutStrategy("Force Directed"); }
00236   void SetLayoutStrategyToSimple2D()
00237     { this->SetLayoutStrategy("Simple 2D"); }
00238   void SetLayoutStrategyToClustering2D()
00239     { this->SetLayoutStrategy("Clustering 2D"); }
00240   void SetLayoutStrategyToCommunity2D()
00241     { this->SetLayoutStrategy("Community 2D"); }
00242   void SetLayoutStrategyToFast2D()
00243     { this->SetLayoutStrategy("Fast 2D"); }
00244   void SetLayoutStrategyToPassThrough()
00245     { this->SetLayoutStrategy("Pass Through"); }
00246   void SetLayoutStrategyToCircular()
00247     { this->SetLayoutStrategy("Circular"); }
00248   void SetLayoutStrategyToTree()
00249     { this->SetLayoutStrategy("Tree"); }
00250   void SetLayoutStrategyToCosmicTree()
00251     { this->SetLayoutStrategy("Cosmic Tree"); }
00252   void SetLayoutStrategyToCone()
00253     { this->SetLayoutStrategy("Cone"); }
00254   void SetLayoutStrategyToSpanTree()
00255     { this->SetLayoutStrategy("Span Tree"); }
00257 
00259 
00261   virtual void SetLayoutStrategyToAssignCoordinates(
00262     const char* xarr, const char* yarr = 0, const char* zarr = 0);
00264 
00266 
00275   virtual void SetLayoutStrategyToTree(
00276     bool radial,
00277     double angle = 90,
00278     double leafSpacing = 0.9,
00279     double logSpacing = 1.0);
00281 
00283 
00292   virtual void SetLayoutStrategyToCosmicTree(
00293     const char* nodeSizeArrayName,
00294     bool sizeLeafNodesOnly = true,
00295     int layoutDepth = 0,
00296     vtkIdType layoutRoot = -1);
00298 
00299   // ------------------------------------------------------------------------
00300   // Edge layout strategy
00301 
00303 
00304   virtual void SetEdgeLayoutStrategy(vtkEdgeLayoutStrategy* strategy);
00305   virtual vtkEdgeLayoutStrategy* GetEdgeLayoutStrategy();
00306   void SetEdgeLayoutStrategyToArcParallel()
00307     { this->SetEdgeLayoutStrategy("Arc Parallel"); }
00308   void SetEdgeLayoutStrategyToPassThrough()
00309     { this->SetEdgeLayoutStrategy("Pass Through"); }
00311 
00314   virtual void SetEdgeLayoutStrategyToGeo(double explodeFactor = 0.2);
00315 
00317 
00318   virtual void SetEdgeLayoutStrategy(const char* name);
00319   vtkGetStringMacro(EdgeLayoutStrategyName);
00321 
00322   // ------------------------------------------------------------------------
00323   // Miscellaneous
00324 
00326   virtual void ApplyViewTheme(vtkViewTheme* theme);
00327 
00329 
00330   virtual void SetGlyphType(int type);
00331   virtual int GetGlyphType();
00333 
00335 
00336   virtual void SetScaling(bool b);
00337   virtual bool GetScaling();
00338   vtkBooleanMacro(Scaling, bool);
00340 
00342 
00343   virtual void SetScalingArrayName(const char* name);
00344   virtual const char* GetScalingArrayName();
00346 
00348 
00349   virtual void SetVertexScalarBarVisibility(bool b);
00350   virtual bool GetVertexScalarBarVisibility();
00351   virtual void SetEdgeScalarBarVisibility(bool b);
00352   virtual bool GetEdgeScalarBarVisibility();
00354 
00356   virtual bool IsLayoutComplete();
00357 
00359   virtual void UpdateLayout();
00360 
00362   void ComputeSelectedGraphBounds( double bounds[6] );
00363 
00364 protected:
00365   vtkRenderedGraphRepresentation();
00366   ~vtkRenderedGraphRepresentation();
00367 
00369 
00370   virtual bool AddToView(vtkView* view);
00371   virtual bool RemoveFromView(vtkView* view);
00373 
00374   virtual void PrepareForRendering(vtkRenderView* view);
00375   
00376   virtual vtkSelection* ConvertSelection(vtkView* view, vtkSelection* sel);
00377 
00378   //BTX
00379   virtual vtkUnicodeString GetHoverTextInternal(vtkSelection* sel);
00380   //ETX
00381 
00383 
00384   virtual int RequestData(
00385     vtkInformation* request,
00386     vtkInformationVector** inputVector,
00387     vtkInformationVector* outputVector);
00389 
00390   //BTX
00392 
00393   vtkSmartPointer<vtkApplyColors>          ApplyColors;
00394   vtkSmartPointer<vtkVertexDegree>         VertexDegree;
00395   vtkSmartPointer<vtkPolyData>             EmptyPolyData;
00396   vtkSmartPointer<vtkEdgeCenters>          EdgeCenters;
00397   vtkSmartPointer<vtkGraphToPoints>        GraphToPoints;
00398   vtkSmartPointer<vtkPointSetToLabelHierarchy> VertexLabelHierarchy;
00399   vtkSmartPointer<vtkPointSetToLabelHierarchy> EdgeLabelHierarchy;
00400   vtkSmartPointer<vtkGraphLayout>          Layout;
00401   vtkSmartPointer<vtkPerturbCoincidentVertices> Coincident;
00402   vtkSmartPointer<vtkEdgeLayout>           EdgeLayout;
00403   vtkSmartPointer<vtkGraphToPolyData>      GraphToPoly;
00404   vtkSmartPointer<vtkPolyDataMapper>       EdgeMapper;
00405   vtkSmartPointer<vtkActor>                EdgeActor;
00406   vtkSmartPointer<vtkGraphToGlyphs>        VertexGlyph;
00407   vtkSmartPointer<vtkPolyDataMapper>       VertexMapper;
00408   vtkSmartPointer<vtkActor>                VertexActor;
00409   vtkSmartPointer<vtkGraphToGlyphs>        OutlineGlyph;
00410   vtkSmartPointer<vtkPolyDataMapper>       OutlineMapper;
00411   vtkSmartPointer<vtkActor>                OutlineActor;
00412   vtkSmartPointer<vtkScalarBarWidget>      VertexScalarBar;
00413   vtkSmartPointer<vtkScalarBarWidget>      EdgeScalarBar;
00414   vtkSmartPointer<vtkRemoveHiddenData>     RemoveHiddenGraph;
00415   vtkSmartPointer<vtkApplyIcons>           ApplyVertexIcons;
00416   vtkSmartPointer<vtkGraphToPoints>        VertexIconPoints;
00417   vtkSmartPointer<vtkTransformCoordinateSystems> VertexIconTransform;
00418   vtkSmartPointer<vtkIconGlyphFilter>      VertexIconGlyph;
00419   vtkSmartPointer<vtkPolyDataMapper2D>     VertexIconMapper;
00420   vtkSmartPointer<vtkTexturedActor2D>      VertexIconActor;
00421   //ETX
00423 
00424   char* VertexHoverArrayName;
00425   char* EdgeHoverArrayName;
00426 
00427   vtkSetStringMacro(VertexColorArrayNameInternal);
00428   vtkGetStringMacro(VertexColorArrayNameInternal);
00429   char* VertexColorArrayNameInternal;
00430 
00431   vtkSetStringMacro(EdgeColorArrayNameInternal);
00432   vtkGetStringMacro(EdgeColorArrayNameInternal);
00433   char* EdgeColorArrayNameInternal;
00434 
00435   vtkSetStringMacro(ScalingArrayNameInternal);
00436   vtkGetStringMacro(ScalingArrayNameInternal);
00437   char* ScalingArrayNameInternal;
00438 
00439   vtkSetStringMacro(LayoutStrategyName);
00440   char* LayoutStrategyName;
00441   vtkSetStringMacro(EdgeLayoutStrategyName);
00442   char* EdgeLayoutStrategyName;
00443   bool HideVertexLabelsOnInteraction;
00444   bool HideEdgeLabelsOnInteraction;
00445 
00446 private:
00447   vtkRenderedGraphRepresentation(const vtkRenderedGraphRepresentation&); // Not implemented
00448   void operator=(const vtkRenderedGraphRepresentation&);   // Not implemented
00449 };
00450 
00451 #endif
00452