OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I386LINUX / util / I386LINUX / include / vtk / vtkXImageWindow.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkXImageWindow.h,v $
5   Language:  C++
6   Date:      $Date: 2001/11/13 14:17:36 $
7   Version:   $Revision: 1.27 $
8   Thanks:    Thanks to Matt Turek who developed this class.
9
10 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
11 All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
15
16  * Redistributions of source code must retain the above copyright notice,
17    this list of conditions and the following disclaimer.
18
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.
22
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.
26
27  * Modified source versions must be plainly marked as such, and must not be
28    misrepresented as being the original software.
29
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.
40
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. 
46
47 // .SECTION See Also
48 // vtkImageWindow
49
50 #ifndef __vtkXImageWindow_h
51 #define __vtkXImageWindow_h
52
53 #include        <X11/Xlib.h>
54 #include        <X11/Xutil.h>
55 #include        <X11/cursorfont.h>
56 #include        <X11/X.h>
57 #include        <X11/keysym.h>
58
59 #include        "vtkImageWindow.h"
60
61 class VTK_RENDERING_EXPORT vtkXImageWindow : public vtkImageWindow
62 {
63 public:
64   static vtkXImageWindow *New();
65   vtkTypeMacro(vtkXImageWindow,vtkImageWindow);
66   void PrintSelf(ostream& os, vtkIndent indent);
67
68   // Description:
69   // Implements SetWindowName for a X window
70   void SetWindowName(char* name);
71   
72   // Description:
73   // Gets the number of colors in the pseudo color map.
74   vtkGetMacro(NumberOfColors,int);
75   
76   // Description:
77   // Gets the windows depth. For the templated function.
78   vtkGetMacro(VisualDepth,int);
79   
80   // Description:
81   // Gets the windows visual class. For the templated function.
82   vtkGetMacro(VisualClass,int);
83   
84   // Description:
85   // These are here for using a tk window.
86   Window   GetParentId();
87   void     SetParentId(Window);
88   void     SetParentId(void *);
89   void     SetDisplayId(Display *);
90   void     SetDisplayId(void *);
91   void     SetWindowId(Window);
92   void     SetWindowId(void *);
93   Window   GetWindowId();
94   Display *GetDisplayId();
95   GC       GetGC();
96
97   // Description:
98   // Set/Get the position of the window.
99   int     *GetPosition();
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]); };
103  
104   // Description:
105   // Set/Get the size of the window.
106   int     *GetSize();
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]); };
110   
111   // Description:
112   // The GetGenericXXX functions are necessary to draw into
113   // a VTKWindow.
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();
119
120   // Description:
121   // Swaps the 2D drawing buffers.  The user should not need to 
122   // use this call.  To invoke double buffering, call DoubleBufferOn
123   void SwapBuffers();
124
125   // Description:
126   // Flush the buffer and swap buffers if necessary.
127   void Frame();
128
129   // Description:
130   // Determine the desired depth of the window.
131   virtual int      GetDesiredDepth();
132   
133   // Description:
134   // Determine the desired colormap of the window.
135   virtual Colormap GetDesiredColormap();
136
137   // Description:
138   // Determine the desired visual for the window
139   virtual Visual  *GetDesiredVisual();
140
141   // Description:
142   // Return the id of the visual we are using
143   Visual *GetVisualId() {return VisualId;};
144
145   // Description:
146   // Set the background color of the window.
147   void SetBackgroundColor(float r, float g, float b);
148
149   // Description:
150   // Erase the contents of the window.
151   void EraseWindow();
152
153   // Description:
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);
163
164   // Description:
165   // Set this ImageWindow's X window id to a pre-existing window.
166   void     SetWindowInfo(char *info);
167
168   // Description:
169   // Sets the X window id of the window that WILL BE created.
170   void     SetParentInfo(char *info);
171
172 protected:
173   vtkXImageWindow();
174   ~vtkXImageWindow();
175
176   // X stuff
177   Window               ParentId;
178   Window               WindowId;
179   Display             *DisplayId;
180   Visual              *VisualId;
181   int                  VisualDepth;
182   int                  VisualClass;
183   Colormap             ColorMap;
184   GC                   Gc;
185   int                  Offset;
186   XColor               Colors[256];
187   int                  NumberOfColors;
188   Pixmap               Drawable;
189   int                  OwnDisplay;
190   int                  PixmapWidth;
191   int                  PixmapHeight;
192
193   
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);
202 private:
203   vtkXImageWindow(const vtkXImageWindow&);  // Not implemented.
204   void operator=(const vtkXImageWindow&);  // Not implemented.
205 };
206
207 #endif
208
209
210
211
212