KWWidgets
|
00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWCornerAnnotationEditor.h,v $ 00004 00005 Copyright (c) Kitware, Inc. 00006 All rights reserved. 00007 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00008 00009 This software is distributed WITHOUT ANY WARRANTY; without even 00010 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00011 PURPOSE. See the above copyright notice for more information. 00012 00013 =========================================================================*/ 00014 // .NAME vtkKWCornerAnnotationEditor - a corner annotation widget 00015 // .SECTION Description 00016 // A class that provides a UI for vtkCornerAnnotation. User can set the 00017 // text for each corner, set the color of the text, and turn the annotation 00018 // on and off. 00019 00020 #ifndef __vtkKWCornerAnnotationEditor_h 00021 #define __vtkKWCornerAnnotationEditor_h 00022 00023 #include "vtkKWCheckButtonWithPopupFrame.h" 00024 00025 class vtkCornerAnnotation; 00026 class vtkKWFrame; 00027 class vtkKWGenericComposite; 00028 class vtkKWLabel; 00029 class vtkKWPopupButtonWithLabel; 00030 class vtkKWTextWithLabel; 00031 class vtkKWRenderWidget; 00032 class vtkKWScaleWithEntry; 00033 class vtkKWTextPropertyEditor; 00034 00035 class KWWidgets_EXPORT vtkKWCornerAnnotationEditor : public vtkKWCheckButtonWithPopupFrame 00036 { 00037 public: 00038 static vtkKWCornerAnnotationEditor* New(); 00039 vtkTypeRevisionMacro(vtkKWCornerAnnotationEditor,vtkKWCheckButtonWithPopupFrame); 00040 void PrintSelf(ostream& os, vtkIndent indent); 00041 00042 // Description: 00043 // Makes the text property sub-widget popup (instead of displaying the 00044 // whole text property UI, which can be long). 00045 // This has to be called before Create(). Ignored if PopupMode is true. 00046 vtkSetMacro(PopupTextProperty, int); 00047 vtkGetMacro(PopupTextProperty, int); 00048 vtkBooleanMacro(PopupTextProperty, int); 00049 00050 // Description: 00051 // Set/Get the vtkKWView or the vtkKWRenderWidget that owns this annotation. 00052 // vtkKWView and vtkKWRenderWidget are two different frameworks, choose one 00053 // or the other (ParaView uses vtkKWView, VolView uses vtkKWRenderWidget). 00054 // Note that in vtkKWView mode, each view has a vtkKWCornerAnnotationEditor. 00055 // In vtkKWRenderWidget, each widget has a vtkCornerAnnotation, which is 00056 // controlled by a unique (decoupled) vtkKWCornerAnnotationEditor in the GUI. 00057 // It is not ref-counted. 00058 virtual void SetRenderWidget(vtkKWRenderWidget*); 00059 vtkGetObjectMacro(RenderWidget,vtkKWRenderWidget); 00060 00061 // Description: 00062 // Get the underlying vtkCornerAnnotation. 00063 // In vtkKWView mode, the CornerAnnotation is created automatically and 00064 // handled by this class (i.e. each vtkKWCornerAnnotationEditor has a 00065 // vtkCornerAnnotation). 00066 // In vtkKWRenderWidget, the corner prop is part of vtkKWRenderWidget, and 00067 // this method is just a gateway to vtkKWRenderWidget::GetCornerAnnotation(). 00068 vtkGetObjectMacro(CornerAnnotation, vtkCornerAnnotation); 00069 00070 // Description: 00071 // Set/Get the annotation visibility 00072 virtual void SetVisibility(int i); 00073 virtual int GetVisibility(); 00074 vtkBooleanMacro(Visibility, int); 00075 00076 // Description: 00077 // Set/Get corner text 00078 virtual void SetCornerText(const char *txt, int corner); 00079 virtual const char *GetCornerText(int i); 00080 00081 // Description: 00082 // Change the color of the annotation 00083 virtual void SetTextColor(double r, double g, double b); 00084 virtual void SetTextColor(double *rgb) 00085 { this->SetTextColor(rgb[0], rgb[1], rgb[2]); } 00086 virtual double *GetTextColor(); 00087 00088 // Description: 00089 // Set/Get the maximum line height. 00090 virtual void SetMaximumLineHeight(float); 00091 00092 // Description: 00093 // Set the event invoked when the anything in the annotation is changed. 00094 // Defaults to vtkKWEvent::ViewAnnotationChangedEvent 00095 vtkSetMacro(AnnotationChangedEvent, int); 00096 vtkGetMacro(AnnotationChangedEvent, int); 00097 00098 // Description: 00099 // Access to sub-widgets 00100 virtual vtkKWCheckButton* GetCornerVisibilityButton() 00101 { return this->GetCheckButton(); }; 00102 00103 // Description: 00104 // Update the GUI according to the value of the ivars 00105 virtual void Update(); 00106 00107 // Description: 00108 // When used with a vtkKWView, close out and remove any composites/props 00109 // prior to deletion. Has no impact when used with a vtkKWRenderWidget. 00110 virtual void Close(); 00111 00112 // Description: 00113 // Update the "enable" state of the object and its internal parts. 00114 // Depending on different Ivars (this->Enabled, the application's 00115 // Limited Edition Mode, etc.), the "enable" state of the object is updated 00116 // and propagated to its internal parts/subwidgets. This will, for example, 00117 // enable/disable parts of the widget UI, enable/disable the visibility 00118 // of 3D widgets, etc. 00119 virtual void UpdateEnableState(); 00120 00121 // Description: 00122 // Access to the TextPropertyWidget from a script. 00123 vtkGetObjectMacro(TextPropertyWidget, vtkKWTextPropertyEditor); 00124 00125 // Description: 00126 // Callbacks. Internal, do not use. 00127 virtual void CheckButtonCallback(int state); 00128 virtual void CornerTextCallback(int i); 00129 virtual void MaximumLineHeightCallback(double value); 00130 virtual void MaximumLineHeightEndCallback(double value); 00131 virtual void TextPropertyCallback(); 00132 00133 protected: 00134 vtkKWCornerAnnotationEditor(); 00135 ~vtkKWCornerAnnotationEditor(); 00136 00137 // Description: 00138 // Create the widget. 00139 virtual void CreateWidget(); 00140 00141 int AnnotationChangedEvent; 00142 00143 vtkCornerAnnotation *CornerAnnotation; 00144 00145 vtkKWRenderWidget *RenderWidget; 00146 00147 // GUI 00148 00149 int PopupTextProperty; 00150 00151 vtkKWFrame *CornerFrame; 00152 vtkKWTextWithLabel *CornerText[4]; 00153 vtkKWFrame *PropertiesFrame; 00154 vtkKWScaleWithEntry *MaximumLineHeightScale; 00155 vtkKWTextPropertyEditor *TextPropertyWidget; 00156 vtkKWPopupButtonWithLabel *TextPropertyPopupButton; 00157 00158 virtual void Render(); 00159 00160 // Get the value that should be used to set the checkbutton state 00161 // (i.e. depending on the value this checkbutton is supposed to reflect, 00162 // for example, an annotation visibility). 00163 // This does *not* return the state of the widget. 00164 virtual int GetCheckButtonState() { return this->GetVisibility(); }; 00165 00166 // Send an event representing the state of the widget 00167 virtual void SendChangedEvent(); 00168 00169 private: 00170 vtkKWCornerAnnotationEditor(const vtkKWCornerAnnotationEditor&); // Not implemented 00171 void operator=(const vtkKWCornerAnnotationEditor&); // Not Implemented 00172 }; 00173 00174 #endif 00175