OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I386LINUX / util / I386LINUX / include / vtk / vtkImageWindow.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkImageWindow.h,v $
5   Language:  C++
6   Date:      $Date: 2001/10/11 13:38:10 $
7   Version:   $Revision: 1.28 $
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 vtkImageWindow - a 2D display window
43 // .SECTION Description
44 // vtkImageWindow contains 2D rendering in vtk. Typically a vtkImageWindow
45 // has some vtkImagers within it.  The imagers in turn display images, Text
46 // etc. The concept is very similar to that of a RenderWindow for 3d.
47
48 // .SECTION See Also
49 // vtkImager vtkWindow vtkRenderWindow
50
51 #ifndef __vtkImageWindow_h
52 #define __vtkImageWindow_h
53
54 #include "vtkWindow.h"
55 #include "vtkActor2D.h"
56 #include "vtkImager.h"
57 #include "vtkImageMapper.h"
58 #include "vtkImagerCollection.h"
59 #include "vtkWindow.h"
60
61
62 class VTK_RENDERING_EXPORT vtkImageWindow : public vtkWindow
63 {
64 public:
65   // Description:
66   // Creates a vtkImageWindow with 
67   // background erasing disabled and gray scale hint off
68   static vtkImageWindow *New();
69
70   void PrintSelf(ostream& os, vtkIndent indent);
71   vtkTypeMacro(vtkImageWindow,vtkWindow);
72
73   // Description:
74   // Set the position of the window on the screen
75   virtual void SetPosition(int x, int y) = 0;
76   virtual void SetPosition(int a[2]) { this->SetPosition(a[0],a[1]); };
77  
78   // Description:
79   // Get the position of the window on the screen
80   virtual int* GetPosition() = 0;
81   virtual void GetPosition(int* x, int* y);
82
83   // Description:
84   // Sets the size of a window in pixels.
85   virtual void SetSize(int , int ) = 0;
86   virtual void SetSize(int a[2]) { this->SetSize(a[0], a[1]); };
87   
88   // Description:
89   // Returns the size of a window in pixels
90   virtual int* GetSize() = 0;
91   virtual void GetSize(int *x, int *y);
92
93   // Description:
94   // These are here for using a tk window.
95   virtual void SetDisplayId(void *) = 0;
96   virtual void SetWindowId(void *) = 0;
97   virtual void SetParentId(void *) = 0;
98   virtual void *GetGenericDisplayId() = 0;
99   virtual void *GetGenericWindowId() = 0;
100   virtual void *GetGenericParentId() = 0;
101   virtual void *GetGenericContext()   = 0;
102   virtual void *GetGenericDrawable() {return NULL;};
103
104   // Description:
105   // Swap the front and back buffers.  This function
106   // is used to implement double buffering.  The user
107   // shouldn't need to call this function.  To enable
108   // double buffering, invoke DoubleBufferOn
109   virtual void SwapBuffers() = 0;
110
111   // Description:
112   // Flush the buffer and swap if necessary.
113   virtual void Frame() = 0;
114   
115   // Description:
116   // useful for scripting languages
117   virtual void SetWindowInfo(char *) 
118       { vtkErrorMacro(<<"vtkImageWindow::SetWindowInfo - Not implemented"); };
119   virtual void SetParentInfo(char *)
120       { vtkErrorMacro(<<"vtkImageWindow::SetParentInfo - Not implemented"); };
121
122   // Description:
123   // By default this is a color viewer.  GrayScaleHintOn will improve the
124   // appearance of gray scale images on some systems.
125   vtkSetMacro(GrayScaleHint, int);
126   vtkGetMacro(GrayScaleHint, int);
127   vtkBooleanMacro(GrayScaleHint, int);
128
129   // Description:
130   // Add an imager to the window's list of imagers
131   // to be rendered.
132   void AddImager(vtkImager* im);
133
134   // Description:
135   // Return the collection of imagers for this window.
136   vtkImagerCollection *GetImagers() {return this->Imagers;};
137
138   // Description:
139   // Remove an imager from the window
140   void RemoveImager(vtkImager* im);
141   
142   // Description:
143   // Draw the contents of the window
144   virtual void Render();
145
146   // Description:
147   // Erase the window contents 
148   virtual void EraseWindow();
149
150   // Description:
151   // Save the current image as a PPM file.
152   virtual void SaveImageAsPPM();
153
154   // Description:
155   // Open/Write/Close a PPM file
156   virtual  int OpenPPMImageFile();
157   virtual void WritePPMImageFile();
158   virtual void ClosePPMImageFile();
159
160   // Description:
161   // Set/Get the FileName used for saving images. See the SaveImageAsPPM 
162   // method.
163   vtkSetStringMacro(FileName);
164   vtkGetStringMacro(FileName);
165
166   // Description:
167   // Make this window current. Overridden in subclasses to do, for
168   // example, glXMakeCurrent or wglMakeCurrent
169   virtual void MakeCurrent() {};
170
171 protected:
172   vtkImageWindow();
173   ~vtkImageWindow();
174
175   vtkImagerCollection *Imagers;
176   int WindowCreated;
177   int GrayScaleHint;
178   virtual void MakeDefaultWindow() = 0;
179   char *FileName;
180   FILE* PPMImageFilePtr;
181
182 private:
183   vtkImageWindow(const vtkImageWindow&);  // Not implemented.
184   void operator=(const vtkImageWindow&);  // Not implemented.
185 };
186
187
188 #endif
189
190
191
192