KWWidgets
|
00001 /*========================================================================= 00002 00003 Copyright (c) 1998-2003 Kitware Inc. 469 Clifton Corporate Parkway, 00004 Clifton Park, NY, 12065, USA. 00005 All rights reserved. 00006 00007 Redistribution and use in source and binary forms, with or without 00008 modification, are permitted provided that the following conditions are met: 00009 00010 * Redistributions of source code must retain the above copyright notice, 00011 this list of conditions and the following disclaimer. 00012 00013 * Redistributions in binary form must reproduce the above copyright notice, 00014 this list of conditions and the following disclaimer in the documentation 00015 and/or other materials provided with the distribution. 00016 00017 * Neither the name of Kitware nor the names of any contributors may be used 00018 to endorse or promote products derived from this software without specific 00019 prior written permission. 00020 00021 * Modified source versions must be plainly marked as such, and must not be 00022 misrepresented as being the original software. 00023 00024 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' 00025 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00027 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR 00028 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 00035 =========================================================================*/ 00036 // .NAME vtkKWCanvas - canvas widget 00037 // .SECTION Description 00038 // A simple widget that represents a canvas. 00039 // .SECTION Thanks 00040 // This work is part of the National Alliance for Medical Image 00041 // Computing (NAMIC), funded by the National Institutes of Health 00042 // through the NIH Roadmap for Medical Research, Grant U54 EB005149. 00043 // Information on the National Centers for Biomedical Computing 00044 // can be obtained from http://nihroadmap.nih.gov/bioinformatics. 00045 00046 #ifndef __vtkKWCanvas_h 00047 #define __vtkKWCanvas_h 00048 00049 #include "vtkKWCoreWidget.h" 00050 00051 class vtkColorTransferFunction; 00052 00053 class KWWidgets_EXPORT vtkKWCanvas : public vtkKWCoreWidget 00054 { 00055 public: 00056 static vtkKWCanvas* New(); 00057 vtkTypeRevisionMacro(vtkKWCanvas,vtkKWCoreWidget); 00058 void PrintSelf(ostream& os, vtkIndent indent); 00059 00060 // Description: 00061 // Set the width and height of the canvas. 00062 // No effect before Create() is called. 00063 virtual void SetWidth(int); 00064 virtual int GetWidth(); 00065 virtual void SetHeight(int); 00066 virtual int GetHeight(); 00067 00068 // Description: 00069 // Add horizontal or vertical gradient (constrained to a rectange). 00070 // The arguments x1, y1, x2, and y2 give the coordinates of two diagonally 00071 // opposite corners of the rectangle. 00072 virtual int AddHorizontalGradient(vtkColorTransferFunction *ctf, 00073 int x1, int y1, int x2, int y2, 00074 const char *tag); 00075 virtual int AddHorizontalRGBGradient(double r1, double g1, double b1, 00076 double r2, double g2, double b2, 00077 int x1, int y1, int x2, int y2, 00078 const char *tag); 00079 virtual int AddVerticalGradient(vtkColorTransferFunction *ctf, 00080 int x1, int y1, int x2, int y2, 00081 const char *tag); 00082 virtual int AddVerticalRGBGradient(double r1, double g1, double b1, 00083 double r2, double g2, double b2, 00084 int x1, int y1, int x2, int y2, 00085 const char *tag); 00086 00087 // Description: 00088 // Query if the canvas has a tag 00089 virtual int HasTag(const char *tag); 00090 00091 // Description: 00092 // Delete a tag in the canvas 00093 virtual void DeleteTag(const char *tag); 00094 00095 // Description: 00096 // Set/Get the background color of the widget. 00097 virtual void GetBackgroundColor(double *r, double *g, double *b); 00098 virtual double* GetBackgroundColor(); 00099 virtual void SetBackgroundColor(double r, double g, double b); 00100 virtual void SetBackgroundColor(double rgb[3]) 00101 { this->SetBackgroundColor(rgb[0], rgb[1], rgb[2]); }; 00102 00103 // Description: 00104 // Set/Get the highlight thickness, a non-negative value indicating the 00105 // width of the highlight rectangle to draw around the outside of the 00106 // widget when it has the input focus. 00107 virtual void SetHighlightThickness(int); 00108 virtual int GetHighlightThickness(); 00109 00110 // Description: 00111 // Set/Get the border width, a non-negative value indicating the width 00112 // of the 3-D border to draw around the outside of the widget (if such 00113 // a border is being drawn; the Relief option typically determines this). 00114 virtual void SetBorderWidth(int); 00115 virtual int GetBorderWidth(); 00116 00117 // Description: 00118 // Set/Get the 3-D effect desired for the widget. 00119 // The value indicates how the interior of the widget should appear 00120 // relative to its exterior. 00121 // Valid constants can be found in vtkKWOptions::ReliefType. 00122 virtual void SetRelief(int); 00123 virtual int GetRelief(); 00124 virtual void SetReliefToRaised(); 00125 virtual void SetReliefToSunken(); 00126 virtual void SetReliefToFlat(); 00127 virtual void SetReliefToRidge(); 00128 virtual void SetReliefToSolid(); 00129 virtual void SetReliefToGroove(); 00130 00131 // Description: 00132 // Set/add/remove a binding to all items matching a tag in the canvas widget; 00133 // that command is invoked whenever the 'event' is triggered on the tag. 00134 // SetBinding will replace any old bindings, whereas AddBinding will 00135 // add the binding to the list of bindings already defined for that event. 00136 // RemoveBinding can remove a specific binding or all bindings for an event. 00137 // The 'object' argument is the object that will have the method called on 00138 // it. The 'method' argument is the name of the method to be called and any 00139 // arguments in string form. If the object is NULL, the method is still 00140 // evaluated as a simple command. 00141 virtual void SetCanvasBinding( 00142 const char *tag, const char *event, vtkObject *object, const char *method); 00143 virtual void SetCanvasBinding( 00144 const char *tag, const char *event, const char *command); 00145 virtual const char* GetCanvasBinding(const char *tag, const char *event); 00146 virtual void AddCanvasBinding( 00147 const char *tag, const char *event, vtkObject *object, const char *method); 00148 virtual void AddCanvasBinding( 00149 const char *tag, const char *event, const char *command); 00150 virtual void RemoveCanvasBinding(const char *tag, const char *event); 00151 virtual void RemoveCanvasBinding( 00152 const char *tag, const char *event, vtkObject *object, const char *method); 00153 00154 // Description: 00155 // Update the "enable" state of the object and its internal parts. 00156 // Depending on different Ivars (this->Enabled, the application's 00157 // Limited Edition Mode, etc.), the "enable" state of the object is updated 00158 // and propagated to its internal parts/subwidgets. This will, for example, 00159 // enable/disable parts of the widget UI, enable/disable the visibility 00160 // of 3D widgets, etc. 00161 virtual void UpdateEnableState(); 00162 00163 protected: 00164 vtkKWCanvas() {}; 00165 ~vtkKWCanvas() {}; 00166 00167 // Description: 00168 // Create the widget. 00169 virtual void CreateWidget(); 00170 00171 // Description: 00172 // Add gradient. 00173 virtual int AddGradient(vtkColorTransferFunction *ctf, 00174 int x1, int y1, int x2, int y2, 00175 const char *tag, 00176 int horizontal); 00177 00178 private: 00179 vtkKWCanvas(const vtkKWCanvas&); // Not implemented 00180 void operator=(const vtkKWCanvas&); // Not implemented 00181 }; 00182 00183 00184 #endif 00185 00186 00187