ctkTransferFunctionWidgetTest1.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*=========================================================================
  2. Library: qCTK
  3. Copyright (c) Kitware Inc.
  4. All rights reserved.
  5. Distributed under a BSD License. See LICENSE.txt file.
  6. This software is distributed "AS IS" WITHOUT ANY WARRANTY; without even
  7. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the above copyright notice for more information.
  9. =========================================================================*/
  10. // Qt includes
  11. #include <QApplication>
  12. #include <QSharedPointer>
  13. #include <QTimer>
  14. // CTK includes
  15. #include "ctkTransferFunction.h"
  16. #include "ctkTransferFunctionWidget.h"
  17. #include "ctkVTKColorTransferFunction.h"
  18. // VTK includes
  19. #include <vtkColorTransferFunction.h>
  20. #include <vtkSmartPointer.h>
  21. // STD includes
  22. #include <iostream>
  23. //-----------------------------------------------------------------------------
  24. int ctkTransferFunctionWidgetTest1(int argc, char * argv [] )
  25. {
  26. QApplication app(argc, argv);
  27. vtkSmartPointer<vtkColorTransferFunction> ctf =
  28. vtkSmartPointer<vtkColorTransferFunction>::New();
  29. //
  30. ctf->AddRGBPoint(0., 1.,0.,0., 0.5, 0.);
  31. //ctf->AddRGBPoint(0.5, 0.,0.,1.);
  32. ctf->AddRGBPoint(1., 0.,1.,0.);
  33. //ctf->AddHSVPoint(0., 0.,1.,1.);
  34. //ctf->AddHSVPoint(1., 0.66666,1.,1.);
  35. QSharedPointer<ctkTransferFunction> transferFunction =
  36. QSharedPointer<ctkTransferFunction>(new ctkVTKColorTransferFunction(ctf));
  37. ctkTransferFunctionWidget transferFunctionWidget(transferFunction.data(), 0);
  38. // the widget is not really shown here, only when app.exec() is called
  39. transferFunctionWidget.show();
  40. //ctf->AddRGBPoint(0.7, 0.0,0.0,0.0);
  41. //ctkTransferFunctionWidget* toto = new ctkTransferFunctionWidget();
  42. QTimer autoExit;
  43. QObject::connect(&autoExit, SIGNAL(timeout()), &app, SLOT(quit()));
  44. //autoExit.start(1000);
  45. return app.exec();
  46. }