107 lines
3.3 KiB
C++
107 lines
3.3 KiB
C++
#include <QVBoxLayout>
|
|
#include "camerasetup.h"
|
|
|
|
|
|
SingleCamera::SingleCamera (QWidget *parent) :
|
|
CameraSetup(parent),
|
|
camera1Preview(nullptr) {
|
|
this->setLayout(new QVBoxLayout(this));
|
|
camera1Preview = new CameraPreview();
|
|
this->layout()->addWidget(camera1Preview);
|
|
}
|
|
|
|
|
|
CameraLayout SingleCamera::cameraLayout(){
|
|
CameraLayout l;
|
|
qDebug() << "Request layout";
|
|
l.mode = CameraMode::single;
|
|
l.layout = Layout::horizontal;
|
|
l.devices.push_back(camera1Preview->device().toStdString());
|
|
l.rois.push_back(camera1Preview->getRoi());
|
|
return l;
|
|
}
|
|
|
|
|
|
SingleCamera::~SingleCamera(){
|
|
if (camera1Preview != nullptr) {
|
|
delete camera1Preview;
|
|
camera1Preview = nullptr;
|
|
}
|
|
}
|
|
|
|
|
|
DualCamera::DualCamera (QWidget *parent) :
|
|
CameraSetup(parent),
|
|
camera1Preview(nullptr),
|
|
camera2Preview(nullptr),
|
|
primary_device("") {
|
|
qDebug() << "DualCamera View constructor... ";
|
|
std::cerr << "DualCamera View constructor... " << std::endl;
|
|
this->setLayout(new QHBoxLayout(this));
|
|
camera1Preview = new CameraPreview();
|
|
camera2Preview = new CameraPreview();
|
|
this->layout()->addWidget(camera1Preview);
|
|
this->layout()->addWidget(camera2Preview);
|
|
connect(camera1Preview, SIGNAL(roiUpdated(int, int, int, int)), this, SLOT(updateROI1(int, int, int, int)));
|
|
connect(camera2Preview, SIGNAL(roiUpdated(int, int, int, int)), SLOT(updateROI2(int, int, int, int)));
|
|
qDebug() << "... created";
|
|
}
|
|
|
|
|
|
void DualCamera::updateROI1(int x, int y, int w, int h) {
|
|
qDebug() << "Update ROI1: x " << x << " y " << y << " w " << w << " h " << h;
|
|
if (camera2Preview != nullptr) {
|
|
camera2Preview->setSize(w, h);
|
|
}
|
|
}
|
|
|
|
void DualCamera::updateROI2(int x, int y, int w, int h) {
|
|
qDebug() << "Update ROI2: x " << x << " y " << y << " w " << w << " h " << h;
|
|
if (camera1Preview != nullptr) {
|
|
camera1Preview->setSize(w, h);
|
|
}
|
|
}
|
|
|
|
void DualCamera::switchArrangement() {
|
|
qDebug() << "switch camera arrangement";
|
|
QHBoxLayout *hbox = (QHBoxLayout*)this->layout();
|
|
if (hbox->direction() == QBoxLayout::LeftToRight) {
|
|
hbox->setDirection(QBoxLayout::RightToLeft);
|
|
primary_device = camera2Preview->device();
|
|
} else {
|
|
hbox->setDirection(QBoxLayout::LeftToRight);
|
|
primary_device = camera1Preview->device();
|
|
}
|
|
}
|
|
|
|
CameraLayout DualCamera::cameraLayout() {
|
|
CameraLayout l;
|
|
qDebug() << "Request layout";
|
|
l.mode = CameraMode::dual;
|
|
l.layout = Layout::horizontal;
|
|
if (camera1Preview->device() == primary_device) {
|
|
l.rois.push_back(camera1Preview->getRoi());
|
|
l.rois.push_back(camera2Preview->getRoi());
|
|
l.devices.push_back(camera1Preview->device().toStdString());
|
|
l.devices.push_back(camera2Preview->device().toStdString());
|
|
} else {
|
|
l.rois.push_back(camera2Preview->getRoi());
|
|
l.rois.push_back(camera1Preview->getRoi());
|
|
l.devices.push_back(camera2Preview->device().toStdString());
|
|
l.devices.push_back(camera1Preview->device().toStdString());
|
|
}
|
|
return l;
|
|
}
|
|
|
|
|
|
DualCamera::~DualCamera(){
|
|
if (camera1Preview != nullptr) {
|
|
delete camera1Preview;
|
|
camera1Preview = nullptr;
|
|
}
|
|
if (camera2Preview != nullptr) {
|
|
delete camera2Preview;
|
|
camera2Preview = nullptr;
|
|
}
|
|
}
|