1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkXImageWindow.h,v $
6 Date: $Date: 2001/11/13 14:17:36 $
7 Version: $Revision: 1.27 $
8 Thanks: Thanks to Matt Turek who developed this class.
10 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
16 * Redistributions of source code must retain the above copyright notice,
17 this list of conditions and the following disclaimer.
19 * Redistributions in binary form must reproduce the above copyright notice,
20 this list of conditions and the following disclaimer in the documentation
21 and/or other materials provided with the distribution.
23 * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
24 of any contributors may be used to endorse or promote products derived
25 from this software without specific prior written permission.
27 * Modified source versions must be plainly marked as such, and must not be
28 misrepresented as being the original software.
30 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
31 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
34 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
36 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
37 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
38 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 =========================================================================*/
42 // .NAME vtkXImageWindow - 2D display window for X
43 // .SECTION Description
44 // vtkXImageWindow is a concrete subclass of vtkImageWindow to support
45 // 2D rendering in vtk.
50 #ifndef __vtkXImageWindow_h
51 #define __vtkXImageWindow_h
54 #include <X11/Xutil.h>
55 #include <X11/cursorfont.h>
57 #include <X11/keysym.h>
59 #include "vtkImageWindow.h"
61 class VTK_RENDERING_EXPORT vtkXImageWindow : public vtkImageWindow
64 static vtkXImageWindow *New();
65 vtkTypeMacro(vtkXImageWindow,vtkImageWindow);
66 void PrintSelf(ostream& os, vtkIndent indent);
69 // Implements SetWindowName for a X window
70 void SetWindowName(char* name);
73 // Gets the number of colors in the pseudo color map.
74 vtkGetMacro(NumberOfColors,int);
77 // Gets the windows depth. For the templated function.
78 vtkGetMacro(VisualDepth,int);
81 // Gets the windows visual class. For the templated function.
82 vtkGetMacro(VisualClass,int);
85 // These are here for using a tk window.
87 void SetParentId(Window);
88 void SetParentId(void *);
89 void SetDisplayId(Display *);
90 void SetDisplayId(void *);
91 void SetWindowId(Window);
92 void SetWindowId(void *);
94 Display *GetDisplayId();
98 // Set/Get the position of the window.
100 void GetPosition(int* x, int* y) {this->vtkImageWindow::GetPosition(x, y);};
101 void SetPosition(int,int);
102 void SetPosition(int a[2]) { this->SetPosition(a[0],a[1]); };
105 // Set/Get the size of the window.
107 void GetSize(int* x, int* y) {this->vtkImageWindow::GetSize(x, y);};
108 void SetSize(int x, int y);
109 void SetSize(int a[2]) { this->SetSize(a[0], a[1]); };
112 // The GetGenericXXX functions are necessary to draw into
114 void *GetGenericDisplayId() {return (void*) this->DisplayId;};
115 void *GetGenericWindowId() {return (void*) this->WindowId;};
116 void *GetGenericParentId() {return (void*) this->ParentId;};
117 void *GetGenericContext() {return (void*) this->Gc;};
118 void *GetGenericDrawable();
121 // Swaps the 2D drawing buffers. The user should not need to
122 // use this call. To invoke double buffering, call DoubleBufferOn
126 // Flush the buffer and swap buffers if necessary.
130 // Determine the desired depth of the window.
131 virtual int GetDesiredDepth();
134 // Determine the desired colormap of the window.
135 virtual Colormap GetDesiredColormap();
138 // Determine the desired visual for the window
139 virtual Visual *GetDesiredVisual();
142 // Return the id of the visual we are using
143 Visual *GetVisualId() {return VisualId;};
146 // Set the background color of the window.
147 void SetBackgroundColor(float r, float g, float b);
150 // Erase the contents of the window.
154 // Get the pixel data of an image, transmitted as RGBRGBRGB.
155 // It is the caller's responsibility to delete the resulting
156 // array. It is very important to realize that the memory in this array
157 // is organized from the bottom of the window to the top. The origin
158 // of the screen is in the lower left corner. The y axis increases as
159 // you go up the screen. So the storage of pixels is from left to right
160 // and from bottom to top. To maintain the same prototype as in
161 // vtkRenderWindow, the last argument is provided, but currently not used.
162 unsigned char *GetPixelData(int x1, int y1, int x2, int y2, int);
165 // Set this ImageWindow's X window id to a pre-existing window.
166 void SetWindowInfo(char *info);
169 // Sets the X window id of the window that WILL BE created.
170 void SetParentInfo(char *info);
194 void MakeDefaultWindow();
195 void GetDefaultVisualInfo(XVisualInfo *info);
196 Colormap MakeColorMap(Visual *visual);
197 void AllocateDirectColorMap();
198 void GetShiftsScalesAndMasks(int &rshift, int &gshift, int &bshift,
199 int &rscale, int &gscale, int &bscale,
200 unsigned long &rmask, unsigned long &gmask,
201 unsigned long &bmask);
203 vtkXImageWindow(const vtkXImageWindow&); // Not implemented.
204 void operator=(const vtkXImageWindow&); // Not implemented.