/*========================================================================= Program: Visualization Toolkit Module: $RCSfile: TestPlaybackWidget.cxx,v $ 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. =========================================================================*/ // // This example tests the vtkPlaybackWidget. // First include the required header files for the VTK classes we are using. #include "vtkPlaybackWidget.h" #include "vtkPlaybackRepresentation.h" #include "vtkSphereSource.h" #include "vtkPolyDataMapper.h" #include "vtkActor.h" #include "vtkRenderer.h" #include "vtkRenderWindow.h" #include "vtkRenderWindowInteractor.h" #include "vtkCommand.h" #include "vtkInteractorEventRecorder.h" #include "vtkRegressionTestImage.h" #include "vtkDebugLeaks.h" class vtkSubclassPlaybackRepresentation : public vtkPlaybackRepresentation { public: static vtkSubclassPlaybackRepresentation *New() {return new vtkSubclassPlaybackRepresentation;} virtual void Play() {cout << "play\n";} virtual void Stop() {cout << "stop\n";} virtual void ForwardOneFrame() {cout << "forward one frame\n";} virtual void BackwardOneFrame() {cout << "backward one frame\n";} virtual void JumpToBeginning() {cout << "jump to beginning\n";} virtual void JumpToEnd() {cout << "jump to end\n";} }; int main( int argc, char *argv[] ) { // Create the RenderWindow, Renderer and both Actors // vtkRenderer *ren1 = vtkRenderer::New(); vtkRenderWindow *renWin = vtkRenderWindow::New(); renWin->AddRenderer(ren1); vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New(); iren->SetRenderWindow(renWin); // Create a test pipeline // vtkSphereSource *ss = vtkSphereSource::New(); vtkPolyDataMapper *mapper = vtkPolyDataMapper::New(); mapper->SetInput(ss->GetOutput()); vtkActor *actor = vtkActor::New(); actor->SetMapper(mapper); // Create the widget vtkSubclassPlaybackRepresentation *rep = vtkSubclassPlaybackRepresentation::New(); vtkPlaybackWidget *widget = vtkPlaybackWidget::New(); widget->SetInteractor(iren); widget->SetRepresentation(rep); widget->KeyPressActivationOff(); // Add the actors to the renderer, set the background and size // ren1->AddActor(actor); ren1->SetBackground(0.1, 0.2, 0.4); renWin->SetSize(300, 300); // render the image // iren->Initialize(); renWin->Render(); widget->On(); widget->EnabledOn(); iren->Start(); ss->Delete(); mapper->Delete(); actor->Delete(); widget->Off(); widget->Delete(); rep->Delete(); iren->Delete(); renWin->Delete(); ren1->Delete(); //recorder->Delete(); return 0; }