KWWidgets
vtkKWCanvas.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Copyright (c) 1998-2003 Kitware Inc. 469 Clifton Corporate Parkway,
4 Clifton Park, NY, 12065, USA.
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10  * Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13  * Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17  * Neither the name of Kitware nor the names of any contributors may be used
18  to endorse or promote products derived from this software without specific
19  prior written permission.
20 
21  * Modified source versions must be plainly marked as such, and must not be
22  misrepresented as being the original software.
23 
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
25 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
28 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 
35 =========================================================================*/
36 // .NAME vtkKWCanvas - canvas widget
37 // .SECTION Description
38 // A simple widget that represents a canvas.
39 // .SECTION Thanks
40 // This work is part of the National Alliance for Medical Image
41 // Computing (NAMIC), funded by the National Institutes of Health
42 // through the NIH Roadmap for Medical Research, Grant U54 EB005149.
43 // Information on the National Centers for Biomedical Computing
44 // can be obtained from http://nihroadmap.nih.gov/bioinformatics.
45 
46 #ifndef __vtkKWCanvas_h
47 #define __vtkKWCanvas_h
48 
49 #include "vtkKWCoreWidget.h"
50 
51 class vtkColorTransferFunction;
52 
54 {
55 public:
56  static vtkKWCanvas* New();
57  vtkTypeRevisionMacro(vtkKWCanvas,vtkKWCoreWidget);
58  void PrintSelf(ostream& os, vtkIndent indent);
59 
60  // Description:
61  // Set the width and height of the canvas.
62  // No effect before Create() is called.
63  virtual void SetWidth(int);
64  virtual int GetWidth();
65  virtual void SetHeight(int);
66  virtual int GetHeight();
67 
68  // Description:
69  // Add horizontal or vertical gradient (constrained to a rectange).
70  // The arguments x1, y1, x2, and y2 give the coordinates of two diagonally
71  // opposite corners of the rectangle.
72  virtual int AddHorizontalGradient(vtkColorTransferFunction *ctf,
73  int x1, int y1, int x2, int y2,
74  const char *tag);
75  virtual int AddHorizontalRGBGradient(double r1, double g1, double b1,
76  double r2, double g2, double b2,
77  int x1, int y1, int x2, int y2,
78  const char *tag);
79  virtual int AddVerticalGradient(vtkColorTransferFunction *ctf,
80  int x1, int y1, int x2, int y2,
81  const char *tag);
82  virtual int AddVerticalRGBGradient(double r1, double g1, double b1,
83  double r2, double g2, double b2,
84  int x1, int y1, int x2, int y2,
85  const char *tag);
86 
87  // Description:
88  // Query if the canvas has a tag
89  virtual int HasTag(const char *tag);
90 
91  // Description:
92  // Delete a tag in the canvas
93  virtual void DeleteTag(const char *tag);
94 
95  // Description:
96  // Set/Get the background color of the widget.
97  virtual void GetBackgroundColor(double *r, double *g, double *b);
98  virtual double* GetBackgroundColor();
99  virtual void SetBackgroundColor(double r, double g, double b);
100  virtual void SetBackgroundColor(double rgb[3])
101  { this->SetBackgroundColor(rgb[0], rgb[1], rgb[2]); };
102 
103  // Description:
104  // Set/Get the highlight thickness, a non-negative value indicating the
105  // width of the highlight rectangle to draw around the outside of the
106  // widget when it has the input focus.
107  virtual void SetHighlightThickness(int);
108  virtual int GetHighlightThickness();
109 
110  // Description:
111  // Set/Get the border width, a non-negative value indicating the width
112  // of the 3-D border to draw around the outside of the widget (if such
113  // a border is being drawn; the Relief option typically determines this).
114  virtual void SetBorderWidth(int);
115  virtual int GetBorderWidth();
116 
117  // Description:
118  // Set/Get the 3-D effect desired for the widget.
119  // The value indicates how the interior of the widget should appear
120  // relative to its exterior.
121  // Valid constants can be found in vtkKWOptions::ReliefType.
122  virtual void SetRelief(int);
123  virtual int GetRelief();
124  virtual void SetReliefToRaised();
125  virtual void SetReliefToSunken();
126  virtual void SetReliefToFlat();
127  virtual void SetReliefToRidge();
128  virtual void SetReliefToSolid();
129  virtual void SetReliefToGroove();
130 
131  // Description:
132  // Set/add/remove a binding to all items matching a tag in the canvas widget;
133  // that command is invoked whenever the 'event' is triggered on the tag.
134  // SetBinding will replace any old bindings, whereas AddBinding will
135  // add the binding to the list of bindings already defined for that event.
136  // RemoveBinding can remove a specific binding or all bindings for an event.
137  // The 'object' argument is the object that will have the method called on
138  // it. The 'method' argument is the name of the method to be called and any
139  // arguments in string form. If the object is NULL, the method is still
140  // evaluated as a simple command.
141  virtual void SetCanvasBinding(
142  const char *tag, const char *event, vtkObject *object, const char *method);
143  virtual void SetCanvasBinding(
144  const char *tag, const char *event, const char *command);
145  virtual const char* GetCanvasBinding(const char *tag, const char *event);
146  virtual void AddCanvasBinding(
147  const char *tag, const char *event, vtkObject *object, const char *method);
148  virtual void AddCanvasBinding(
149  const char *tag, const char *event, const char *command);
150  virtual void RemoveCanvasBinding(const char *tag, const char *event);
151  virtual void RemoveCanvasBinding(
152  const char *tag, const char *event, vtkObject *object, const char *method);
153 
154  // Description:
155  // Update the "enable" state of the object and its internal parts.
156  // Depending on different Ivars (this->Enabled, the application's
157  // Limited Edition Mode, etc.), the "enable" state of the object is updated
158  // and propagated to its internal parts/subwidgets. This will, for example,
159  // enable/disable parts of the widget UI, enable/disable the visibility
160  // of 3D widgets, etc.
161  virtual void UpdateEnableState();
162 
163 protected:
166 
167  // Description:
168  // Create the widget.
169  virtual void CreateWidget();
170 
171  // Description:
172  // Add gradient.
173  virtual int AddGradient(vtkColorTransferFunction *ctf,
174  int x1, int y1, int x2, int y2,
175  const char *tag,
176  int horizontal);
177 
178 private:
179  vtkKWCanvas(const vtkKWCanvas&); // Not implemented
180  void operator=(const vtkKWCanvas&); // Not implemented
181 };
182 
183 
184 #endif
185 
186 
187