1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkImageWindow.h,v $
6 Date: $Date: 2001/10/11 13:38:10 $
7 Version: $Revision: 1.28 $
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 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.
49 // vtkImager vtkWindow vtkRenderWindow
51 #ifndef __vtkImageWindow_h
52 #define __vtkImageWindow_h
54 #include "vtkWindow.h"
55 #include "vtkActor2D.h"
56 #include "vtkImager.h"
57 #include "vtkImageMapper.h"
58 #include "vtkImagerCollection.h"
59 #include "vtkWindow.h"
62 class VTK_RENDERING_EXPORT vtkImageWindow : public vtkWindow
66 // Creates a vtkImageWindow with
67 // background erasing disabled and gray scale hint off
68 static vtkImageWindow *New();
70 void PrintSelf(ostream& os, vtkIndent indent);
71 vtkTypeMacro(vtkImageWindow,vtkWindow);
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]); };
79 // Get the position of the window on the screen
80 virtual int* GetPosition() = 0;
81 virtual void GetPosition(int* x, int* y);
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]); };
89 // Returns the size of a window in pixels
90 virtual int* GetSize() = 0;
91 virtual void GetSize(int *x, int *y);
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;};
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;
112 // Flush the buffer and swap if necessary.
113 virtual void Frame() = 0;
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"); };
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);
130 // Add an imager to the window's list of imagers
132 void AddImager(vtkImager* im);
135 // Return the collection of imagers for this window.
136 vtkImagerCollection *GetImagers() {return this->Imagers;};
139 // Remove an imager from the window
140 void RemoveImager(vtkImager* im);
143 // Draw the contents of the window
144 virtual void Render();
147 // Erase the window contents
148 virtual void EraseWindow();
151 // Save the current image as a PPM file.
152 virtual void SaveImageAsPPM();
155 // Open/Write/Close a PPM file
156 virtual int OpenPPMImageFile();
157 virtual void WritePPMImageFile();
158 virtual void ClosePPMImageFile();
161 // Set/Get the FileName used for saving images. See the SaveImageAsPPM
163 vtkSetStringMacro(FileName);
164 vtkGetStringMacro(FileName);
167 // Make this window current. Overridden in subclasses to do, for
168 // example, glXMakeCurrent or wglMakeCurrent
169 virtual void MakeCurrent() {};
175 vtkImagerCollection *Imagers;
178 virtual void MakeDefaultWindow() = 0;
180 FILE* PPMImageFilePtr;
183 vtkImageWindow(const vtkImageWindow&); // Not implemented.
184 void operator=(const vtkImageWindow&); // Not implemented.