void MainFrm::openRecentFile() { QAction *action = qobject_cast<QAction *>(sender()); if (action){ if (!readXMLFile(action->data().toString())) this->displayError(tr("Could not parse XML file! Are you sure it exists and is a valid project file?"),true); else loadTabs(); } }
void MainFrm::loadFile() { if (pFrmReports->isVisible()) closeSecondaryFrm(pFrmReports); QString fileName = QFileDialog::getOpenFileName(this, tr("Open Project"), tr(""), tr("Project Files (*.xml)")); if (!fileName.isEmpty()){ if (!readXMLFile(fileName)) this->displayError(tr("Could not parse XML file! Are you sure this is a valid project file?"),true); else loadTabs(); setCurrentFile(fileName); statusShow(tr("File loaded")); } }
bool DataReader::readFile(TFileType fileType, char* filename, char* dirname) { bool bOk = true; if (dirname) { bOk = readDicomFile(dirname); } else if (fileType == FT_VTI) { bOk = readXMLFile(filename); } else if (fileType == FT_MHA) { bOk = readMetaFile(filename); } else { cout << "Error! Not VTI or MHA!" << endl; exit(EXIT_FAILURE); } // Verify that we actually have a volume int dim[3]; input->GetDimensions(dim); if (dim[0] < 2 || dim[1] < 2 || dim[2] < 2) { cout << "Error loading data!" << endl; exit(EXIT_FAILURE); } outputPort = reader->GetOutputPort(); return bOk; }
//-------------------------------------------------------------------------------------- // Mwars::Mwars() // the Constructor //-------------------------------------------------------------------------------------- Mwars::Mwars(QWidget *parent) : QMainWindow(parent), ui(new Ui::mwarsForm) { ui->setupUi(this); // Ui:mwarsForm ui //*********** two timers QTimer *keepServerAliveTimer = new QTimer(this); // instantiate timer QTimer *testTimer = new QTimer(this); // a. TCP stream to scanner server // clientSocket: client socket sends stream to scanner. clientSocket already exists // Q_SIGNALS signals emitted by socket unimplemented: void hostFound() void connected() connect( &clientSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(clientSocketError(QAbstractSocket::SocketError)) ); connect( &clientSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(clientSocketState(QAbstractSocket::SocketState)) ); connect( &clientSocket, SIGNAL(readyRead()),this, SLOT(OnReadyRead()) ); connect( &clientSocket, SIGNAL(disconnected()), this, SLOT(disconnectedz()) ); // b. UDP stream from opencv / camera listenSocket = new QUdpSocket ( this ); listenSocket->bind(9988 ); connect( listenSocket, SIGNAL(readyRead()),this, SLOT(OnReadyRead()) ); //signals from within code connect( this, SIGNAL(connectScanner()), this, SLOT(connectToScanner())); // Constructor connect( keepServerAliveTimer, SIGNAL(timeout()), this, SLOT(keepServerAlive())); // connect( testTimer, SIGNAL(timeout()), this, SLOT(testSignal())); // signals from ui connect( ui->xSlider, SIGNAL(valueChanged(int)), this, SLOT(sendScanCmd())); connect( ui->ySlider, SIGNAL(valueChanged(int)), this, SLOT(sendScanCmd())); connect( ui->spinboxXCamTrim, SIGNAL(valueChanged(int)), this, SLOT(sendScanCmd())); connect( ui->spinboxYCamTrim, SIGNAL(valueChanged(int)), this, SLOT(sendScanCmd())); //connect( ui->pbLaserToggle, SIGNAL(clicked()), this, SLOT(laserToggle())); connect( ui->pushButtonLaserDisableToggle, SIGNAL(clicked()), this, SLOT(laserDisableToggle())); connect( ui->pushButtonScannerToggle, SIGNAL(clicked()), this, SLOT(scannerToggle())); connect( ui->pushButtonConnect, SIGNAL(clicked()), this, SLOT(connectToScanner())); connect( ui->radioButtonVerboseOn, SIGNAL(clicked()), this, SLOT(verboseOn())); connect( ui->radioButtonVerboseOff, SIGNAL(clicked()), this, SLOT(verboseOff())); connect( ui->pushButtonResetScanner, SIGNAL(clicked()), this, SLOT(resetScanner())); connect( ui->pushButtonCameraDataToggle, SIGNAL(clicked()), this, SLOT(cameraDataToggle())); connect( ui->pushButtonTestDataToggle, SIGNAL(clicked()), this, SLOT(testDataToggle())); //connect( ui->pbAlignBS, SIGNAL(clicked()), this, SLOT(alignBoresight())); connect( ui->pbCalibrateToggle, SIGNAL(clicked()), this, SLOT(calibrateToggle())); connect( ui->pbCalSetULHC, SIGNAL(clicked()), this, SLOT(calSetULHC())); connect( ui->pbCalSetLRHC, SIGNAL(clicked()), this, SLOT(calSetLRHC())); connect( ui->pbCalFullFrame, SIGNAL(clicked()), this, SLOT(calFullFrame())); connect( ui->pbCalHalfFrame, SIGNAL(clicked()), this, SLOT(calHalfFrame())); connect( ui->spinboxXCamTrim, SIGNAL(valueChanged(int)), this, SLOT(xCamTrim())); connect( ui->spinboxYCamTrim, SIGNAL(valueChanged(int)), this, SLOT(yCamTrim())); connect( ui->pbCamTrimOffset, SIGNAL(clicked()), this, SLOT(camTrimOffset())); connect( ui->sbXCamOffset, SIGNAL(valueChanged(int)), this, SLOT(xCamOffset())); connect( ui->sbYCamOffset, SIGNAL(valueChanged(int)), this, SLOT(yCamOffset())); connect( ui->pbCamOffset, SIGNAL(clicked()), this, SLOT(camScanOffset())); connect( ui->pbCalLaserBsight, SIGNAL(clicked()), this, SLOT(alignBoresight())); //connect( this, SIGNAL (testSignal()), this, SLOT (testSignal())); // temporary stuff to test parallax offset g_xLenWallFOV_mm = (1310 * 2); // measured width, x axis, of FOV at target distance = range (mm) g_yLenWallFOV_mm = (975 * 2); g_xSF_pixelTomm = (float)g_xLenWallFOV_mm / CAMERA_X_PIXELS; g_ySF_pixelTomm = (float)g_yLenWallFOV_mm / CAMERA_Y_PIXELS; range_mm = 2750; // measured range cam to target (mm) //overwritten when cam file is read g_xScanFOVOrigin_su = DAC_X_MIN; // scanner origin corresponding to x_camFOVOrigin (scan units) g_xScanFOVMax_su = DAC_X_MAX; // scanner max x corresponding to x_camFOVMax (scan units) // read camera to scanner calibration file. This reads the calibration parameters // and sets main slider and spin box values readXMLFile(); ui->spinboxXCamTrim->setRange(-5000, +5000); ui->spinboxYCamTrim->setRange(-5000, +5000); ui->radioButtonVerboseOff->setChecked(true); clearStateWidets(); // clear Server State widget text #ifdef FORCE_ENABLE_WIDGETS enableWidgets(); #else disableWidgets(); // control widgets get enabled when connected #endif verbose = false; // verbose OFF laserOnFlag = false; testDataEnableFlag = false; // set by TestData button to turn on test data stream cameraDataEnableFlag = false; // set by Camera Data button to turn on OpenCVcamera data stream laserDisableFlag = false; // set by Laser On/Off button scannerOnFlag = false; // set by Scanner On/Off button tcpConnected = false; // tcp connected serverReady = false; calibrateFlag = false; setWindowTitle(tr("MWARS SCANNER CONSOLE")); // =================== start scannerserver comms =============================== // a) UDP stream of co-ords and laser command from OpenCV Project mwars // b) TCP connection to server in the scanner unit // 1. connect to the TCP server in the laser scanner unit emit connectScanner(); //runs connectToScanner // ==================== timers ================================== // start the keep alivetimer. Used to get response to update Console keepServerAliveTimer->start(1000); //1000 = 1 sec //start the test signal timer for testSignal() // 1000 = 1 sec, 1 = 1mS //testTimer->start(100); // 5 Hz //testTimer->start(10); // 50 Hz //testTimer->start(20); // 25 Hz // testTimer->start(60); // 8 Hz // testTimer->start(50); // 10 Hz sendScanCmd(); // init scanner, slew to slider values rectangleIsRunning = false; }