// QT includes #include #include #include #include #include #include #include // QtTesting includes #include "pqTestUtility.h" #include "pqEventObserver.h" #include "pqEventSource.h" // VTK includes #include #include #include #include #include #include #include #include #include #include #include #include #include // CTK includes #include "ctkQtTestingMainWindow.h" #include "ctkXMLEventObserver.h" #include "ctkXMLEventSource.h" //----------------------------------------------------------------------------- ctkQtTestingMainWindow::ctkQtTestingMainWindow() { this->Ui.setupUi(this); QObject::connect(Ui.RecordButton, SIGNAL(toggled(bool)), this, SLOT(record(bool))); QObject::connect(Ui.PlayBackButton, SIGNAL(clicked()), this, SLOT(play())); this->TestUtility = new ctkQtTestingUtility(this); this->TestUtility->addEventObserver("xml", new ctkXMLEventObserver(this->TestUtility)); this->TestUtility->addEventSource("xml", new ctkXMLEventSource(this->TestUtility)); Ui.renderView->setBackgroundColor(QColor(Qt::gray)); Ui.renderView->setBackgroundColor2(QColor(Qt::darkBlue)); Ui.renderView->setGradientBackground(true); Ui.renderView->setCornerAnnotationText("ctk Qt test"); // Create a cube. vtkSmartPointer cubeSource = vtkSmartPointer::New(); // Create a mapper and actor. vtkSmartPointer mapper = vtkSmartPointer::New(); mapper->SetInputConnection(cubeSource->GetOutputPort()); vtkSmartPointer actor = vtkSmartPointer::New(); actor->SetMapper(mapper); // Add the actors to the scene Ui.renderView->renderer()->AddActor(actor); // vtkSmartPointer boxWidget = // vtkSmartPointer::New(); // boxWidget->SetInteractor(Ui.renderView->interactor()); // boxWidget->SetPlaceFactor(1.0); // boxWidget->PlaceWidget(); // boxWidget->On(); Ui.renderView->resetCamera(); } //----------------------------------------------------------------------------- ctkQtTestingMainWindow::~ctkQtTestingMainWindow() { if(TestUtility) { delete this->TestUtility; } } //----------------------------------------------------------------------------- void ctkQtTestingMainWindow::record(bool start) { if (start) { QString filename = QFileDialog::getSaveFileName (this, "Test File Name", QString(), "XML Files (*.xml)"); if (!filename.isEmpty()) { qDebug() << "Start recording"; QFileInfo fileInfo(filename); if (fileInfo.suffix() != "xml") { filename += ".xml"; } this->TestUtility->recordTests(filename); } } else { qDebug() << "Stop recording"; this->TestUtility->stopRecords(1); } } //----------------------------------------------------------------------------- void ctkQtTestingMainWindow::play() { qDebug() << "Start Playback"; QString filename = QFileDialog::getOpenFileName (this, "Test File Name", QString(), "XML Files (*.xml)"); if (!filename.isEmpty()) { this->TestUtility->playTests(filename); } qDebug() << "End Playback"; }