KWWidgets
vtkKWCornerAnnotationEditor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWCornerAnnotationEditor.h,v $
4 
5  Copyright (c) Kitware, Inc.
6  All rights reserved.
7  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 // .NAME vtkKWCornerAnnotationEditor - a corner annotation widget
15 // .SECTION Description
16 // A class that provides a UI for vtkCornerAnnotation. User can set the
17 // text for each corner, set the color of the text, and turn the annotation
18 // on and off.
19 
20 #ifndef __vtkKWCornerAnnotationEditor_h
21 #define __vtkKWCornerAnnotationEditor_h
22 
24 
25 class vtkCornerAnnotation;
26 class vtkKWFrame;
27 class vtkKWGenericComposite;
28 class vtkKWLabel;
30 class vtkKWTextWithLabel;
31 class vtkKWRenderWidget;
34 
36 {
37 public:
40  void PrintSelf(ostream& os, vtkIndent indent);
41 
42  // Description:
43  // Makes the text property sub-widget popup (instead of displaying the
44  // whole text property UI, which can be long).
45  // This has to be called before Create(). Ignored if PopupMode is true.
46  vtkSetMacro(PopupTextProperty, int);
47  vtkGetMacro(PopupTextProperty, int);
48  vtkBooleanMacro(PopupTextProperty, int);
49 
50  // Description:
51  // Set/Get the vtkKWView or the vtkKWRenderWidget that owns this annotation.
52  // vtkKWView and vtkKWRenderWidget are two different frameworks, choose one
53  // or the other (ParaView uses vtkKWView, VolView uses vtkKWRenderWidget).
54  // Note that in vtkKWView mode, each view has a vtkKWCornerAnnotationEditor.
55  // In vtkKWRenderWidget, each widget has a vtkCornerAnnotation, which is
56  // controlled by a unique (decoupled) vtkKWCornerAnnotationEditor in the GUI.
57  // It is not ref-counted.
58  virtual void SetRenderWidget(vtkKWRenderWidget*);
59  vtkGetObjectMacro(RenderWidget,vtkKWRenderWidget);
60 
61  // Description:
62  // Get the underlying vtkCornerAnnotation.
63  // In vtkKWView mode, the CornerAnnotation is created automatically and
64  // handled by this class (i.e. each vtkKWCornerAnnotationEditor has a
65  // vtkCornerAnnotation).
66  // In vtkKWRenderWidget, the corner prop is part of vtkKWRenderWidget, and
67  // this method is just a gateway to vtkKWRenderWidget::GetCornerAnnotation().
68  vtkGetObjectMacro(CornerAnnotation, vtkCornerAnnotation);
69 
70  // Description:
71  // Set/Get the annotation visibility
72  virtual void SetVisibility(int i);
73  virtual int GetVisibility();
74  vtkBooleanMacro(Visibility, int);
75 
76  // Description:
77  // Set/Get corner text
78  virtual void SetCornerText(const char *txt, int corner);
79  virtual const char *GetCornerText(int i);
80 
81  // Description:
82  // Change the color of the annotation
83  virtual void SetTextColor(double r, double g, double b);
84  virtual void SetTextColor(double *rgb)
85  { this->SetTextColor(rgb[0], rgb[1], rgb[2]); }
86  virtual double *GetTextColor();
87 
88  // Description:
89  // Set/Get the maximum line height.
90  virtual void SetMaximumLineHeight(float);
91 
92  // Description:
93  // Set the event invoked when the anything in the annotation is changed.
94  // Defaults to vtkKWEvent::ViewAnnotationChangedEvent
95  vtkSetMacro(AnnotationChangedEvent, int);
96  vtkGetMacro(AnnotationChangedEvent, int);
97 
98  // Description:
99  // Access to sub-widgets
100  virtual vtkKWCheckButton* GetCornerVisibilityButton()
101  { return this->GetCheckButton(); };
102 
103  // Description:
104  // Update the GUI according to the value of the ivars
105  virtual void Update();
106 
107  // Description:
108  // When used with a vtkKWView, close out and remove any composites/props
109  // prior to deletion. Has no impact when used with a vtkKWRenderWidget.
110  virtual void Close();
111 
112  // Description:
113  // Update the "enable" state of the object and its internal parts.
114  // Depending on different Ivars (this->Enabled, the application's
115  // Limited Edition Mode, etc.), the "enable" state of the object is updated
116  // and propagated to its internal parts/subwidgets. This will, for example,
117  // enable/disable parts of the widget UI, enable/disable the visibility
118  // of 3D widgets, etc.
119  virtual void UpdateEnableState();
120 
121  // Description:
122  // Access to the TextPropertyWidget from a script.
123  vtkGetObjectMacro(TextPropertyWidget, vtkKWTextPropertyEditor);
124 
125  // Description:
126  // Callbacks. Internal, do not use.
127  virtual void CheckButtonCallback(int state);
128  virtual void CornerTextCallback(int i);
129  virtual void MaximumLineHeightCallback(double value);
130  virtual void MaximumLineHeightEndCallback(double value);
131  virtual void TextPropertyCallback();
132 
133 protected:
136 
137  // Description:
138  // Create the widget.
139  virtual void CreateWidget();
140 
141  int AnnotationChangedEvent;
142 
143  vtkCornerAnnotation *CornerAnnotation;
144 
145  vtkKWRenderWidget *RenderWidget;
146 
147  // GUI
148 
149  int PopupTextProperty;
150 
151  vtkKWFrame *CornerFrame;
152  vtkKWTextWithLabel *CornerText[4];
153  vtkKWFrame *PropertiesFrame;
154  vtkKWScaleWithEntry *MaximumLineHeightScale;
155  vtkKWTextPropertyEditor *TextPropertyWidget;
156  vtkKWPopupButtonWithLabel *TextPropertyPopupButton;
157 
158  virtual void Render();
159 
160  // Get the value that should be used to set the checkbutton state
161  // (i.e. depending on the value this checkbutton is supposed to reflect,
162  // for example, an annotation visibility).
163  // This does *not* return the state of the widget.
164  virtual int GetCheckButtonState() { return this->GetVisibility(); };
165 
166  // Send an event representing the state of the widget
167  virtual void SendChangedEvent();
168 
169 private:
170  vtkKWCornerAnnotationEditor(const vtkKWCornerAnnotationEditor&); // Not implemented
171  void operator=(const vtkKWCornerAnnotationEditor&); // Not Implemented
172 };
173 
174 #endif
175