1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
|
/*=========================================================================
Program: Visualization Toolkit
Module: vtkIOSRenderWindowInteractor.mm
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkOpenGLRenderWindow.h"
#import "vtkIOSRenderWindowInteractor.h"
#import "vtkIOSRenderWindow.h"
#import "vtkCommand.h"
#import "vtkObjectFactory.h"
//----------------------------------------------------------------------------
vtkStandardNewMacro(vtkIOSRenderWindowInteractor);
//----------------------------------------------------------------------------
void (*vtkIOSRenderWindowInteractor::ClassExitMethod)(void *) = (void (*)(void *))NULL;
void *vtkIOSRenderWindowInteractor::ClassExitMethodArg = (void *)NULL;
void (*vtkIOSRenderWindowInteractor::ClassExitMethodArgDelete)(void *) = (void (*)(void *))NULL;
//----------------------------------------------------------------------------
vtkIOSRenderWindowInteractor::vtkIOSRenderWindowInteractor()
{
}
//----------------------------------------------------------------------------
vtkIOSRenderWindowInteractor::~vtkIOSRenderWindowInteractor()
{
this->Enabled = 0;
}
//----------------------------------------------------------------------------
void vtkIOSRenderWindowInteractor::StartEventLoop()
{
}
//----------------------------------------------------------------------------
// Begin processing keyboard strokes.
void vtkIOSRenderWindowInteractor::Initialize()
{
// make sure we have a RenderWindow and camera
if ( !this->RenderWindow )
{
vtkErrorMacro(<<"No renderer defined!");
return;
}
if (this->Initialized)
{
return;
}
this->Initialized = 1;
// get the info we need from the RenderingWindow
vtkIOSRenderWindow *renWin = (vtkIOSRenderWindow *)(this->RenderWindow);
renWin->Start();
int *size = renWin->GetSize();
renWin->GetPosition(); // update values of this->Position[2]
this->Enable();
this->Size[0] = size[0];
this->Size[1] = size[1];
}
//----------------------------------------------------------------------------
void vtkIOSRenderWindowInteractor::Enable()
{
if (this->Enabled)
{
return;
}
// Set the RenderWindow's interactor so that when the vtkIOSGLView tries
// to handle events from the OS it will either handle them or ignore them
this->GetRenderWindow()->SetInteractor(this);
this->Enabled = 1;
this->Modified();
}
//----------------------------------------------------------------------------
void vtkIOSRenderWindowInteractor::Disable()
{
if (!this->Enabled)
{
return;
}
#ifdef VTK_USE_TDX
if(this->Device->GetInitialized())
{
this->Device->Close();
}
#endif
// Set the RenderWindow's interactor so that when the vtkIOSGLView tries
// to handle events from the OS it will either handle them or ignore them
this->GetRenderWindow()->SetInteractor(NULL);
this->Enabled = 0;
this->Modified();
}
//----------------------------------------------------------------------------
void vtkIOSRenderWindowInteractor::TerminateApp()
{
}
//----------------------------------------------------------------------------
int vtkIOSRenderWindowInteractor::InternalCreateTimer(int timerId,
int timerType, unsigned long duration)
{
// In this implementation, timerId and platformTimerId are the same
int platformTimerId = timerId;
return platformTimerId;
}
//----------------------------------------------------------------------------
int vtkIOSRenderWindowInteractor::InternalDestroyTimer(int platformTimerId)
{
// In this implementation, timerId and platformTimerId are the same;
// but calling this anyway is more correct
int timerId = this->GetVTKTimerId(platformTimerId);
return 0; // fail
}
//----------------------------------------------------------------------------
// Specify the default function to be called when an interactor needs to exit.
// This callback is overridden by an instance ExitMethod that is defined.
void vtkIOSRenderWindowInteractor::SetClassExitMethod(void (*f)(void *),void *arg)
{
if ( f != vtkIOSRenderWindowInteractor::ClassExitMethod
|| arg != vtkIOSRenderWindowInteractor::ClassExitMethodArg)
{
// delete the current arg if there is a delete method
if ((vtkIOSRenderWindowInteractor::ClassExitMethodArg)
&& (vtkIOSRenderWindowInteractor::ClassExitMethodArgDelete))
{
(*vtkIOSRenderWindowInteractor::ClassExitMethodArgDelete)
(vtkIOSRenderWindowInteractor::ClassExitMethodArg);
}
vtkIOSRenderWindowInteractor::ClassExitMethod = f;
vtkIOSRenderWindowInteractor::ClassExitMethodArg = arg;
// no call to this->Modified() since this is a class member function
}
}
//----------------------------------------------------------------------------
// Set the arg delete method. This is used to free user memory.
void vtkIOSRenderWindowInteractor::SetClassExitMethodArgDelete(void (*f)(void *))
{
if (f != vtkIOSRenderWindowInteractor::ClassExitMethodArgDelete)
{
vtkIOSRenderWindowInteractor::ClassExitMethodArgDelete = f;
// no call to this->Modified() since this is a class member function
}
}
//----------------------------------------------------------------------------
void vtkIOSRenderWindowInteractor::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
}
//----------------------------------------------------------------------------
void vtkIOSRenderWindowInteractor::ExitCallback()
{
if (this->HasObserver(vtkCommand::ExitEvent))
{
this->InvokeEvent(vtkCommand::ExitEvent,NULL);
}
else if (this->ClassExitMethod)
{
(*this->ClassExitMethod)(this->ClassExitMethodArg);
}
this->TerminateApp();
}
|