Commit 838db4ef authored by Ken Martin's avatar Ken Martin

image viewer now uses a render window

parent a5e511ee
......@@ -45,7 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//------------------------------------------------------------------------------
//-----------------------------------------------------------------------------
vtkImageViewer* vtkImageViewer::New()
{
// First try to create the object from the vtkObjectFactory
......@@ -64,15 +64,16 @@ vtkImageViewer* vtkImageViewer::New()
//----------------------------------------------------------------------------
vtkImageViewer::vtkImageViewer()
{
this->ImageWindow = vtkImageWindow::New();
this->Imager = vtkImager::New();
this->RenderWindow = vtkRenderWindow::New();
this->Renderer = vtkRenderer::New();
this->ImageMapper = vtkImageMapper::New();
this->Actor2D = vtkActor2D::New();
// setup the pipeline
this->Actor2D->SetMapper(this->ImageMapper);
this->Imager->AddActor2D(this->Actor2D);
this->ImageWindow->AddImager(this->Imager);
this->Renderer->AddActor2D(this->Actor2D);
this->RenderWindow->AddRenderer(this->Renderer);
}
......@@ -81,17 +82,17 @@ vtkImageViewer::~vtkImageViewer()
{
this->ImageMapper->Delete();
this->Actor2D->Delete();
this->Imager->Delete();
this->ImageWindow->Delete();
this->RenderWindow->Delete();
this->Renderer->Delete();
}
//----------------------------------------------------------------------------
void vtkImageViewer::PrintSelf(ostream& os, vtkIndent indent)
{
vtkObject::PrintSelf(os, indent);
os << indent << *this->ImageWindow << endl;
os << indent << *this->Imager << endl;
os << indent << *this->ImageMapper << endl;
os << indent << *this->RenderWindow << endl;
os << indent << *this->Renderer << endl;
}
......@@ -111,7 +112,7 @@ void vtkImageViewer::SetPosition(int a[2])
void vtkImageViewer::Render()
{
// initialize the size if not set yet
if (this->ImageWindow->GetSize()[0] == 0 && this->ImageMapper->GetInput())
if (this->RenderWindow->GetSize()[0] == 0 && this->ImageMapper->GetInput())
{
// get the size from the mappers input
this->ImageMapper->GetInput()->UpdateInformation();
......@@ -119,9 +120,9 @@ void vtkImageViewer::Render()
// if it would be smaller than 100 by 100 then limit to 100 by 100
int xs = ext[1] - ext[0] + 1;
int ys = ext[3] - ext[2] + 1;
this->ImageWindow->SetSize(xs < 150 ? 150 : xs,
ys < 100 ? 100 : ys);
this->RenderWindow->SetSize(xs < 150 ? 150 : xs,
ys < 100 ? 100 : ys);
}
this->ImageWindow->Render();
this->RenderWindow->Render();
}
......@@ -56,10 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vtkObject.h"
#include "vtkImageWindow.h"
// For placement of origin in the viewer.
#define VTK_IMAGE_VIEWER_UPPER_LEFT 0
#define VTK_IMAGE_VIEWER_LOWER_LEFT 1
#include "vtkRenderWindow.h"
class VTK_RENDERING_EXPORT vtkImageViewer : public vtkObject
{
......@@ -71,7 +68,7 @@ public:
// Description:
// Get name of rendering window
char *GetWindowName() {return this->ImageWindow->GetWindowName();};
char *GetWindowName() {return this->RenderWindow->GetWindowName();};
// Description:
// Render the resulting image.
......@@ -101,44 +98,53 @@ public:
// Description:
// These are here for using a tk window.
void SetDisplayId(void *a) {this->ImageWindow->SetDisplayId(a);};
void SetWindowId(void *a) {this->ImageWindow->SetWindowId(a);};
void SetParentId(void *a) {this->ImageWindow->SetParentId(a);};
void SetDisplayId(void *a) {this->RenderWindow->SetDisplayId(a);};
void SetWindowId(void *a) {this->RenderWindow->SetWindowId(a);};
void SetParentId(void *a) {this->RenderWindow->SetParentId(a);};
// Description:
// By default this is a color viewer. GrayScaleHintOn will improve the
// appearance of gray scale images on some systems.
int GetGrayScaleHint() {return this->ImageWindow->GetGrayScaleHint();};
void SetGrayScaleHint(int a) {this->ImageWindow->SetGrayScaleHint(a);};
void GrayScaleHintOn() {this->ImageWindow->GrayScaleHintOn();};
void GrayScaleHintOff() {this->ImageWindow->GrayScaleHintOff();};
int GetGrayScaleHint()
{vtkWarningMacro("GetGrayScaleHint deprecated, not required anymore"); return 0;};
void SetGrayScaleHint(int a)
{vtkWarningMacro("SetGrayScaleHint deprecated, not required anymore");};
void GrayScaleHintOn()
{vtkWarningMacro("GrayScaleHintOn deprecated, not required anymore");};
void GrayScaleHintOff()
{vtkWarningMacro("GrayScaleHintOff deprecated, not required anymore");};
// Description:
// Set/Get the position in screen coordinates of the rendering window.
int *GetPosition() {return this->ImageWindow->GetPosition();};
void SetPosition(int a,int b) {this->ImageWindow->SetPosition(a,b);};
int *GetPosition() {return this->RenderWindow->GetPosition();};
void SetPosition(int a,int b) {this->RenderWindow->SetPosition(a,b);};
virtual void SetPosition(int a[2]);
// Description:
// Set/Get the size of the window in screen coordinates.
int *GetSize() {return this->ImageWindow->GetSize();};
void SetSize(int a,int b) {this->ImageWindow->SetSize(a,b);};
int *GetSize() {return this->RenderWindow->GetSize();};
void SetSize(int a,int b) {this->RenderWindow->SetSize(a,b);};
virtual void SetSize(int a[2]);
// Description:
// Get the internal Window Imager and Mapper
vtkImageWindow *GetImageWindow() {return this->ImageWindow;};
vtkImageWindow *GetImageWindow()
{vtkWarningMacro("GetImageWindow deprecated, use GetRenderWindow instead."); return NULL;};
vtkImager *GetImager()
{vtkWarningMacro("GetImager deprecated, use GetRenderer instead."); return NULL;};
vtkImageMapper *GetImageMapper() {return this->ImageMapper;};
vtkImager *GetImager() {return this->Imager;};
vtkActor2D *GetActor2D() {return this->Actor2D;};
vtkRenderWindow *GetRenderWindow() {return this->RenderWindow;};
vtkRenderer *GetRenderer() {return this->Renderer;};
protected:
vtkImageViewer();
~vtkImageViewer();
vtkRenderWindow *RenderWindow;
vtkRenderer *Renderer;
vtkImageMapper *ImageMapper;
vtkImageWindow *ImageWindow;
vtkImager *Imager;
vtkActor2D *Actor2D;
private:
vtkImageViewer(const vtkImageViewer&); // Not implemented.
......
......@@ -46,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifdef _WIN32
#pragma warning ( disable : 4273 )
#else
#include "vtkXImageWindow.h"
#include "vtkXOpenGLRenderWindow.h"
#endif
#define VTK_ALL_EVENTS_MASK \
......@@ -458,7 +458,7 @@ LRESULT APIENTRY vtkTkImageViewerWidgetProc(HWND hWnd, UINT message,
{
if (self->ImageViewer)
{
SetWindowLong(hWnd,GWL_USERDATA,(LONG)self->ImageViewer->GetImageWindow());
SetWindowLong(hWnd,GWL_USERDATA,(LONG)self->ImageViewer->GetRenderWindow());
SetWindowLong(hWnd,GWL_WNDPROC,(LONG)self->OldProc);
CallWindowProc(self->OldProc,hWnd,message,wParam,lParam);
}
......@@ -481,7 +481,7 @@ static int vtkTkImageViewerWidget_MakeImageViewer(struct vtkTkImageViewerWidget
vtkImageViewer *ImageViewer = NULL;
TkWinDrawable *twdPtr;
HWND parentWin;
vtkImageWindow *ImageWindow;
vtkRenderWindow *ImageWindow;
if (self->ImageViewer)
{
......@@ -555,7 +555,7 @@ static int vtkTkImageViewerWidget_MakeImageViewer(struct vtkTkImageViewerWidget
//ImageViewer->GetDesiredColormap());
self->ImageViewer->Render();
ImageWindow = self->ImageViewer->GetImageWindow();
ImageWindow = self->ImageViewer->GetRenderWindow();
#if(TK_MAJOR_VERSION >= 8)
twdPtr = (TkWinDrawable*)Tk_AttachHWND(self->TkWin, (HWND)ImageWindow->GetGenericWindowId());
......@@ -644,7 +644,7 @@ vtkTkImageViewerWidget_MakeImageViewer(struct vtkTkImageViewerWidget *self)
{
Display *dpy;
vtkImageViewer *ImageViewer;
vtkXImageWindow *ImageWindow;
vtkXOpenGLRenderWindow *ImageWindow;
if (self->ImageViewer)
{
......@@ -705,7 +705,7 @@ vtkTkImageViewerWidget_MakeImageViewer(struct vtkTkImageViewerWidget *self)
// get the window
ImageWindow = (vtkXImageWindow *)ImageViewer->GetImageWindow();
ImageWindow = static_cast<vtkXOpenGLRenderWindow *>(ImageViewer->GetRenderWindow());
// If the imageviewer has already created it's window, throw up our hands and quit...
if ( ImageWindow->GetWindowId() != (Window)NULL )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment