ctkVTKThumbnailViewTest1.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. // QT includes
  15. #include <QApplication>
  16. #include <QTimer>
  17. // qMRML includes
  18. #include "ctkVTKThumbnailView.h"
  19. // VTK includes
  20. #include <vtkSmartPointer.h>
  21. #include <vtkActor.h>
  22. #include <vtkCubeSource.h>
  23. #include <vtkPolyDataMapper.h>
  24. #include <vtkRenderer.h>
  25. #include <vtkRenderWindow.h>
  26. #include <vtkRenderWindowInteractor.h>
  27. #include <vtkVersion.h>
  28. // STD includes
  29. #include <cstdlib>
  30. #include <iostream>
  31. int ctkVTKThumbnailViewTest1(int argc, char * argv [] )
  32. {
  33. QApplication app(argc, argv);
  34. ctkVTKThumbnailView thumbnailView;
  35. thumbnailView.setWindowTitle("Thumbnail view");
  36. ctkVTKRenderView renderView;
  37. renderView.setWindowTitle("Render view");
  38. vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
  39. vtkCubeSource *cube= vtkCubeSource::New();
  40. #if (VTK_MAJOR_VERSION <= 5)
  41. mapper->SetInput(cube->GetOutput());
  42. #else
  43. mapper->SetInputConnection(cube->GetOutputPort());
  44. #endif
  45. cube->Delete();
  46. vtkActor *actor = vtkActor::New();
  47. actor->SetMapper(mapper);
  48. mapper->Delete();
  49. renderView.renderer()->AddActor(actor);
  50. actor->Delete();
  51. thumbnailView.setRendererToListen(renderView.renderer());
  52. thumbnailView.show();
  53. renderView.show();
  54. if (argc < 2 || QString(argv[1]) != "-I" )
  55. {
  56. QTimer::singleShot(200, &app, SLOT(quit()));
  57. }
  58. return app.exec();
  59. }