1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkCaptionRepresentation.h 5 6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 7 All rights reserved. 8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 9 10 This software is distributed WITHOUT ANY WARRANTY; without even 11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 12 PURPOSE. See the above copyright notice for more information. 13 14 =========================================================================*/ 15 // .NAME vtkCaptionRepresentation - represents vtkCaptionWidget in the scene 16 // .SECTION Description 17 // This class represents vtkCaptionWidget. A caption is defined by some text 18 // with a leader (e.g., arrow) that points from the text to a point in the 19 // scene. The caption is defined by an instance of vtkCaptionActor2D. It uses 20 // the event bindings of its superclass (vtkBorderWidget) to control the 21 // placement of the text, and adds the ability to move the attachment point 22 // around. In addition, when the caption text is selected, the widget emits a 23 // ActivateEvent that observers can watch for. This is useful for opening GUI 24 // dialogoues to adjust font characteristics, etc. (Please see the superclass 25 // for a description of event bindings.) 26 // 27 // Note that this widget extends the behavior of its superclass 28 // vtkBorderRepresentation. 29 30 // .SECTION See Also 31 // vtkCaptionWidget vtkBorderWidget vtkBorderRepresentation vtkCaptionActor 32 33 34 #ifndef vtkCaptionRepresentation_h 35 #define vtkCaptionRepresentation_h 36 37 #include "vtkInteractionWidgetsModule.h" // For export macro 38 #include "vtkBorderRepresentation.h" 39 40 class vtkRenderer; 41 class vtkCaptionActor2D; 42 class vtkConeSource; 43 class vtkPointHandleRepresentation3D; 44 45 46 class VTKINTERACTIONWIDGETS_EXPORT vtkCaptionRepresentation : public vtkBorderRepresentation 47 { 48 public: 49 // Description: 50 // Instantiate this class. 51 static vtkCaptionRepresentation *New(); 52 53 // Description: 54 // Standard VTK class methods. 55 vtkTypeMacro(vtkCaptionRepresentation,vtkBorderRepresentation); 56 void PrintSelf(ostream& os, vtkIndent indent); 57 58 // Description: 59 // Specify the position of the anchor (i.e., the point that the caption is anchored to). 60 // Note that the position should be specified in world coordinates. 61 void SetAnchorPosition(double pos[3]); 62 void GetAnchorPosition(double pos[3]); 63 64 // Description: 65 // Specify the vtkCaptionActor2D to manage. If not specified, then one 66 // is automatically created. 67 void SetCaptionActor2D(vtkCaptionActor2D *captionActor); 68 vtkGetObjectMacro(CaptionActor2D,vtkCaptionActor2D); 69 70 // Description: 71 // Set and get the instances of vtkPointHandleRepresention3D used to implement this 72 // representation. Normally default representations are created, but you can 73 // specify the ones you want to use. 74 void SetAnchorRepresentation(vtkPointHandleRepresentation3D*); 75 vtkGetObjectMacro(AnchorRepresentation,vtkPointHandleRepresentation3D); 76 77 // Description: 78 // Satisfy the superclasses API. 79 virtual void BuildRepresentation(); GetSize(double size[2])80 virtual void GetSize(double size[2]) 81 {size[0]=2.0; size[1]=2.0;} 82 83 // Description: 84 // These methods are necessary to make this representation behave as 85 // a vtkProp. 86 virtual void GetActors2D(vtkPropCollection*); 87 virtual void ReleaseGraphicsResources(vtkWindow*); 88 virtual int RenderOverlay(vtkViewport*); 89 virtual int RenderOpaqueGeometry(vtkViewport*); 90 virtual int RenderTranslucentPolygonalGeometry(vtkViewport*); 91 virtual int HasTranslucentPolygonalGeometry(); 92 93 // Description: 94 // Set/Get the factor that controls the overall size of the fonts 95 // of the caption when the text actor's ScaledText is OFF 96 vtkSetClampMacro(FontFactor, double, 0.1, 10.0); 97 vtkGetMacro(FontFactor, double); 98 99 protected: 100 vtkCaptionRepresentation(); 101 ~vtkCaptionRepresentation(); 102 103 // the text to manage 104 vtkCaptionActor2D *CaptionActor2D; 105 vtkConeSource *CaptionGlyph; 106 107 int PointWidgetState; 108 int DisplayAttachmentPoint[2]; 109 double FontFactor; 110 111 // Internal representation for the anchor 112 vtkPointHandleRepresentation3D *AnchorRepresentation; 113 114 // Check and adjust boundaries according to the size of the caption text 115 virtual void AdjustCaptionBoundary(); 116 117 private: 118 vtkCaptionRepresentation(const vtkCaptionRepresentation&); //Not implemented 119 void operator=(const vtkCaptionRepresentation&); //Not implemented 120 }; 121 122 #endif 123