diff --git a/camconfig.cpp b/camconfig.cpp index 4899938..bd399a2 100644 --- a/camconfig.cpp +++ b/camconfig.cpp @@ -1,4 +1,6 @@ #include "camconfig.h" +#include "mylogger.h" +#include "util.h" CamConfigurator::CamConfigurator(Pylon::DeviceInfoList_t &deviceList, QWidget *parent) : deviceList(deviceList), QDialog(parent) { @@ -45,9 +47,12 @@ CamConfigurator::CamConfigurator(Pylon::DeviceInfoList_t &deviceList, QWidget *p connect(buttonbox, &QDialogButtonBox::rejected, this, &QDialog::reject); vbox->addWidget(buttonbox); //this->setLayout(vbox); + // qInfo() << "Create Camera configuration!"; } QWidget* CamConfigurator::singleCameraView() { + qInfo() << "Create Camera configuration!"; + QWidget *w = new QWidget(this); QVBoxLayout *l = new QVBoxLayout(w); l->setParent(w); @@ -80,6 +85,18 @@ void CamConfigurator::primaryDeviceChanged(int idx) { } } +CameraLayout CamConfigurator::layout(){ + CameraLayout l; + if (mode_combo->currentText() == "single camera") { + l.mode = CameraMode::single; + l.layout = Layout::horizontal; + l.devices.push_back(device_combo->currentText().toStdString()); + l.rois.push_back(singleCamPreview->getRoi()); + } else { + qWarning() << "not implemented yet"; + } + return l; +} CamConfigurator::~CamConfigurator() { delete singleCamPreview; diff --git a/camconfig.h b/camconfig.h index adc0ed9..72e63c5 100644 --- a/camconfig.h +++ b/camconfig.h @@ -8,9 +8,10 @@ #include #include #include - #include "camerapreview.h" +class ROI; + namespace Ui { class CamConfigurator; } @@ -23,6 +24,8 @@ public: explicit CamConfigurator(Pylon::DeviceInfoList_t &deviceList, QWidget *parent = 0); ~CamConfigurator(); + CameraLayout layout(); + public slots: void modeChanged(int idx); void primaryDeviceChanged(int idx); diff --git a/camerapreview.cpp b/camerapreview.cpp index f0a0c88..3db0a92 100644 --- a/camerapreview.cpp +++ b/camerapreview.cpp @@ -126,6 +126,17 @@ void CameraPreview::updateROI(QString v){ // FIXME same for y offset and height // FIXME initialize the cameras +ROI CameraPreview::getRoi() { + ROI r; + r.x = xoffs->value(); + r.y = yoffs->value(); + r.width = width->value(); + r.height = height->value(); + r.height = r.height > 1536 ? 1536 - r.y : r.height; + r.width = r.width > 2048 ? 2048 - r.x : r.width; + return r; +} + CameraPreview::~CameraPreview(){ std::cerr << "cameraPreview destructor" << std::endl; if (camera != nullptr){ diff --git a/camerapreview.h b/camerapreview.h index 169f02b..f3e427c 100644 --- a/camerapreview.h +++ b/camerapreview.h @@ -13,7 +13,7 @@ #include #include "pylonwrapper.h" - +#include "util.h" namespace Ui { class CameraPreview; } @@ -26,6 +26,8 @@ public: explicit CameraPreview(QString &devicename, QWidget *parent = 0); ~CameraPreview(); + ROI getRoi(); + public slots: void updateCamera(QString &device); void updateROI(QString v); diff --git a/pylonrecorder.cpp b/pylonrecorder.cpp index e573dcc..3629a10 100644 --- a/pylonrecorder.cpp +++ b/pylonrecorder.cpp @@ -21,7 +21,7 @@ #include #include #include -#include "camconfig.h" +#include "util.h" #if defined(QT_PRINTSUPPORT_LIB) # include @@ -548,6 +548,7 @@ void PylonRecorder::createActions() { void PylonRecorder::updateActions() { + qInfo() << "Update Actions"; saveAsAct->setEnabled(!image.isNull()); copyAct->setEnabled(!image.isNull()); zoomInAct->setEnabled(!fitToWindowAct->isChecked()); @@ -581,15 +582,13 @@ void PylonRecorder::applyScaling(){ void PylonRecorder::quitApplication() { - std::cerr << "Quit Application!" << std::endl; - // if (pyloncam->isOpen()) { - // std::cerr << "Cam is open!" << std::endl; - std::cerr << "Stop grabbing" << std::endl; + qDebug() << "Quit Application!"; if (grabbing) { + qDebug() << "QuitApplication: Stop grabbing"; stopRecording(); } - std::cerr << "done!" << std::endl; + qDebug() << "QuitApplication done!"; this->close(); } @@ -609,6 +608,8 @@ void PylonRecorder::cameraConfiguration(){ void PylonRecorder::camerasetup() { std::cerr << "camera settings accepted" << std::endl; std::cerr << d->result() << std::endl; + CameraLayout l = d->layout(); + delete d; } @@ -619,23 +620,22 @@ void PylonRecorder::connectCamera() { QString msg = "

No camera device found!


Connect camera and try again!

"; msgBox.setText(msg); msgBox.exec(); - } else if (deviceList.size() == 1) { - std::string cname = (std::string)deviceList[0].GetFullName(); - pyloncam = new PylonWrapper(cname); - std::string message; - bool success = pyloncam->openCamera(message); - if (success) { - cameraConnectedLabel->setText("connected"); - cameraConnectedLabel->setStyleSheet("QLabel { font-size: 10px;font-family: Arial;color: green;}"); - } else { - QMessageBox msgBox; - QString msg = "

Could not open camera device!

" + QString::fromStdString(message) + "

"; - msgBox.setText(msg); - msgBox.exec(); - } - statusBar()->showMessage(QString::fromStdString(message)); - updateActions(); - } else { // more than 1 camera + } else { + // std::string cname = (std::string)deviceList[0].GetFullName(); + // pyloncam = new PylonWrapper(cname); + // std::string message; + // bool success = pyloncam->openCamera(message); + // if (success) { + // cameraConnectedLabel->setText("connected"); + // cameraConnectedLabel->setStyleSheet("QLabel { font-size: 10px;font-family: Arial;color: green;}"); + // } else { + // QMessageBox msgBox; + // QString msg = "

Could not open camera device!

" + QString::fromStdString(message) + "

"; + // msgBox.setText(msg); + // msgBox.exec(); + // } + // statusBar()->showMessage(QString::fromStdString(message)); + // updateActions(); cameraConfiguration(); } } @@ -700,37 +700,30 @@ void PylonRecorder::startRecording() { void PylonRecorder::stopRecording() { - std::cerr << "StopRecording!" << std::endl; - + qDebug() << "StopRecording!"; if (!stopRequest) { - std::cerr << "StopRecording2!" << std::endl; - + qDebug() << "StopRecording: stop frame timer!"; frameTimer->stop(); - std::cerr << "StopRecording3!" << std::endl; + qDebug() << "StopRecording: stop grabber!"; if (grabber !=nullptr) grabber->requestStop(); - std::cerr << "StopRecording4!" << std::endl; + qDebug() << "StopRecording: stop writer!"; if (writer != nullptr) writer->requestStop(); - std::cerr << "StopRecording5!" << std::endl; grabbing = false; stopRequest = true; grab_stop_action->setEnabled(false); - std::cerr << "stop recording buffer" << buffer << std::endl; + qDebug() << "StopRecording: clear buffer!"; if(buffer != nullptr) { - std::cerr << "stop recording buffer" << buffer << std::endl; buffer->clear(); writerDone(); } } - std::cerr << "StopRecording done!" << std::endl; - + qDebug() << "StopRecording done!"; } void PylonRecorder::writerDone() { - std::cerr << "writerDone slot!" << std::endl; - preassureTimer->stop(); preassureBar->reset(); loadBar->reset(); @@ -741,8 +734,7 @@ void PylonRecorder::writerDone() { writer->wait(10000); writing = false; updateActions(); - std::cerr << "writerDone slot done!" << std::endl; - + qInfo() << "writer is Done!"; }