ctkVTKThumbnailViewTest1.cpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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.commontk.org/LICENSE
  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. /*==============================================================================
  15. Program: 3D Slicer
  16. Copyright (c) 2010 Kitware Inc.
  17. See Doc/copyright/copyright.txt
  18. or http://www.slicer.org/copyright/copyright.txt for details.
  19. Unless required by applicable law or agreed to in writing, software
  20. distributed under the License is distributed on an "AS IS" BASIS,
  21. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. See the License for the specific language governing permissions and
  23. limitations under the License.
  24. This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
  25. and was partially funded by NIH grant 3P41RR013218-12S1
  26. ==============================================================================*/
  27. // QT includes
  28. #include <QApplication>
  29. #include <QTimer>
  30. // qMRML includes
  31. #include "ctkVTKThumbnailView.h"
  32. // VTK includes
  33. #include <vtkSmartPointer.h>
  34. #include <vtkActor.h>
  35. #include <vtkCubeSource.h>
  36. #include <vtkPolyDataMapper.h>
  37. #include <vtkRenderer.h>
  38. #include <vtkRenderWindow.h>
  39. #include <vtkRenderWindowInteractor.h>
  40. // STD includes
  41. #include <cstdlib>
  42. #include <iostream>
  43. int ctkVTKThumbnailViewTest1(int argc, char * argv [] )
  44. {
  45. QApplication app(argc, argv);
  46. ctkVTKThumbnailView thumbnailView;
  47. thumbnailView.setWindowTitle("Thumbnail view");
  48. ctkVTKRenderView renderView;
  49. renderView.setWindowTitle("Render view");
  50. vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
  51. vtkCubeSource *cube= vtkCubeSource::New();
  52. mapper->SetInput(cube->GetOutput());
  53. cube->Delete();
  54. vtkActor *actor = vtkActor::New();
  55. actor->SetMapper(mapper);
  56. mapper->Delete();
  57. renderView.renderer()->AddActor(actor);
  58. actor->Delete();
  59. thumbnailView.setRendererToListen(renderView.renderer());
  60. thumbnailView.show();
  61. renderView.show();
  62. if (argc < 2 || QString(argv[1]) != "-I" )
  63. {
  64. QTimer::singleShot(200, &app, SLOT(quit()));
  65. }
  66. return app.exec();
  67. }