/*========================================================================= Program: Visualization Toolkit Module: TestProgressBarWidget.cxx 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 vtkProgressBarWidget. // First include the required header files for the VTK classes we are using. #include "vtkActor.h" #include "vtkCommand.h" #include "vtkConeSource.h" #include "vtkCylinderSource.h" #include "vtkInteractorStyleTrackballCamera.h" #include "vtkNew.h" #include "vtkPolyDataMapper.h" #include "vtkProgressBarRepresentation.h" #include "vtkProgressBarWidget.h" #include "vtkRenderWindow.h" #include "vtkRenderWindowInteractor.h" #include "vtkRenderer.h" #include "vtkSphereSource.h" #include "vtkTestUtilities.h" int TestProgressBarWidget(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) { // Create the RenderWindow, Renderer and both Actors // vtkNew ren1; vtkNew renWin; renWin->AddRenderer(ren1); vtkNew style; vtkNew iren; iren->SetRenderWindow(renWin); iren->SetInteractorStyle(style); // Create a test pipeline // vtkNew ss; vtkNew mapper; mapper->SetInputConnection(ss->GetOutputPort()); vtkNew sph; sph->SetMapper(mapper); vtkNew cs; vtkNew csMapper; csMapper->SetInputConnection(cs->GetOutputPort()); vtkNew cyl; cyl->SetMapper(csMapper); cyl->AddPosition(5, 0, 0); vtkNew coneSource; vtkNew coneMapper; coneMapper->SetInputConnection(coneSource->GetOutputPort()); vtkNew cone; cone->SetMapper(coneMapper); cone->AddPosition(0, 5, 0); // Create the widget vtkNew rep; vtkNew widget; widget->SetInteractor(iren); widget->SetRepresentation(rep); // Create the widget vtkNew widget2; widget2->SetInteractor(iren); widget2->CreateDefaultRepresentation(); vtkProgressBarRepresentation* rep2 = vtkProgressBarRepresentation::SafeDownCast(widget2->GetRepresentation()); // Add the actors to the renderer, set the background and size // ren1->AddActor(sph); ren1->AddActor(cyl); ren1->AddActor(cone); ren1->SetBackground(0.1, 0.2, 0.4); renWin->SetSize(300, 300); // render the image // iren->Initialize(); rep->SetProgressRate(0.4); rep->SetPosition(0.4, 0.4); rep->SetProgressBarColor(0.2, 0.4, 0); rep->SetBackgroundColor(1, 1, 0.5); rep->DrawBackgroundOff(); rep2->SetProgressRate(0.8); rep2->SetProgressBarColor(0.1, 0.8, 0); rep2->SetBackgroundColor(1, 1, 0.5); rep2->DrawBackgroundOn(); renWin->Render(); widget->On(); widget2->On(); renWin->Render(); iren->Start(); return EXIT_SUCCESS; }