Selaa lähdekoodia

BUG: ctkTransferFunctionWidgetTest were not auto shutting down, the timer was destroyed before.

Julien Finet 15 vuotta sitten
vanhempi
commit
30fdebe10a

+ 1 - 1
Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkTransferFunctionWidgetTest1.cpp

@@ -57,9 +57,9 @@ int ctkTransferFunctionWidgetTest1(int argc, char * argv [] )
 
   //ctf->AddRGBPoint(0.7, 0.0,0.0,0.0);
   //ctkTransferFunctionWidget* toto = new ctkTransferFunctionWidget();
+  QTimer autoExit;
   if (argc < 2 || QString(argv[1]) != "-I")
     {
-    QTimer autoExit;
     QObject::connect(&autoExit, SIGNAL(timeout()), &app, SLOT(quit()));
     autoExit.start(1000);
     }

+ 1 - 1
Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkTransferFunctionWidgetTest2.cpp

@@ -56,9 +56,9 @@ int ctkTransferFunctionWidgetTest2(int argc, char * argv [] )
   // the widget is not really shown here, only when app.exec() is called
   transferFunctionWidget.show();
 
+  QTimer autoExit;
   if (argc < 2 || QString(argv[1]) != "-I")
     {
-    QTimer autoExit;
     QObject::connect(&autoExit, SIGNAL(timeout()), &app, SLOT(quit()));
     autoExit.start(1000);
     }

+ 1 - 1
Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkTransferFunctionWidgetTest3.cpp

@@ -55,9 +55,9 @@ int ctkTransferFunctionWidgetTest3(int argc, char * argv [] )
   // the widget is not really shown here, only when app.exec() is called
   transferFunctionWidget.show();
 
+  QTimer autoExit;
   if (argc < 2 || QString(argv[1]) != "-I")
     {
-    QTimer autoExit;
     QObject::connect(&autoExit, SIGNAL(timeout()), &app, SLOT(quit()));
     autoExit.start(1000);
     }

+ 1 - 1
Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkTransferFunctionWidgetTest4.cpp

@@ -65,9 +65,9 @@ int ctkTransferFunctionWidgetTest4(int argc, char * argv [] )
   // the widget is not really shown here, only when app.exec() is called
   transferFunctionWidget.show();
 
+  QTimer autoExit;
   if (argc < 2 || QString(argv[1]) != "-I")
     {
-    QTimer autoExit;
     QObject::connect(&autoExit, SIGNAL(timeout()), &app, SLOT(quit()));
     autoExit.start(1000);
     }

+ 13 - 6
Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkTransferFunctionWidgetTest5.cpp

@@ -25,7 +25,9 @@
 
 // CTK includes
 #include "ctkTransferFunction.h"
+#include "ctkTransferFunctionBarsItem.h"
 #include "ctkTransferFunctionWidget.h"
+#include "ctkTransferFunctionScene.h"
 #include "ctkVTKHistogram.h"
 
 // VTK includes
@@ -43,23 +45,28 @@ int ctkTransferFunctionWidgetTest5(int argc, char * argv [] )
   vtkSmartPointer<vtkIntArray> intArray = 
     vtkSmartPointer<vtkIntArray>::New();
   intArray->SetNumberOfComponents(1);
-  intArray->SetNumberOfTuples(2000);
-  for (int i = 0; i < 2000; ++i)
+  intArray->SetNumberOfTuples(20000);
+  for (int i = 0; i < 20000; ++i)
     {
-    intArray->SetValue(i, qrand() % 30);
+    intArray->SetValue(i, rand() % 10);
     }
   QSharedPointer<ctkVTKHistogram> histogram = 
     QSharedPointer<ctkVTKHistogram>(new ctkVTKHistogram(intArray));
   histogram->build();
-  ctkTransferFunctionWidget transferFunctionWidget(histogram.data(), 0);
+  //ctkTransferFunctionWidget transferFunctionWidget(histogram.data(), 0);
+  ctkTransferFunctionWidget transferFunctionWidget;
   // the widget is not really shown here, only when app.exec() is called
   transferFunctionWidget.show();
+  ctkTransferFunctionBarsItem * histogramItem = new ctkTransferFunctionBarsItem;
+  histogramItem->setTransferFunction(histogram.data());
+  qobject_cast<ctkTransferFunctionScene*>(transferFunctionWidget.scene())->setTransferFunction(histogram.data());
+  transferFunctionWidget.scene()->addItem(histogramItem);
 
+  QTimer autoExit;
   if (argc < 2 || QString(argv[1]) != "-I")
     {
-    QTimer autoExit;
     QObject::connect(&autoExit, SIGNAL(timeout()), &app, SLOT(quit()));
-    autoExit.start(1000);
+    autoExit.start(100);
     }
 
   return app.exec();