114 lines
3.7 KiB
C++
114 lines
3.7 KiB
C++
#include "editprofiledialog.h"
|
|
#include "ui_editprofiledialog.h"
|
|
#include <uvosled.h>
|
|
#include <QDebug>
|
|
|
|
#include "configurecameradialog.h"
|
|
|
|
EditProfileDialog::EditProfileDialog(Cameras* cameras, const Profile profile, QWidget *parent) :
|
|
QDialog(parent),
|
|
profile_(profile),
|
|
cameras_(cameras),
|
|
ui(new Ui::EditProfileDialog)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
ui->lineEditName->setText(profile_.getName());
|
|
ui->doubleSpinBoxBrightness->setValue(profile_.lighting.brightness*100.0);
|
|
ui->doubleSpinBoxExposure->setValue(profile_.exposureTime);
|
|
|
|
qDebug()<<"Mask: "<<profile_.lighting.mask<<" & "<<(profile_.lighting.mask & CHANNEL_A);
|
|
|
|
ui->checkBoxCh1->setChecked(profile_.lighting.mask & CHANNEL_A);
|
|
ui->checkBoxCh2->setChecked(profile_.lighting.mask & CHANNEL_B);
|
|
ui->checkBoxCh3->setChecked(profile_.lighting.mask & CHANNEL_C);
|
|
ui->checkBoxCh4->setChecked(profile_.lighting.mask & CHANNEL_D);
|
|
|
|
if(profile_.cameras.size() == 0)
|
|
profile_.setCamerasSetupsFromDescription(cameras_->getCameras());
|
|
|
|
connect(ui->doubleSpinBoxBrightness, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [this](double in){profile_.lighting.brightness = in/100.0;});
|
|
connect(ui->doubleSpinBoxExposure, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [this](double in){profile_.exposureTime = in;});
|
|
connect(ui->lineEditName, &QLineEdit::textChanged, [this](QString in){profile_.setName(in);});
|
|
connect(ui->checkBoxCh1, &QCheckBox::clicked, this, &EditProfileDialog::setMask);
|
|
connect(ui->checkBoxCh2, &QCheckBox::clicked, this, &EditProfileDialog::setMask);
|
|
connect(ui->checkBoxCh3, &QCheckBox::clicked, this, &EditProfileDialog::setMask);
|
|
connect(ui->checkBoxCh4, &QCheckBox::clicked, this, &EditProfileDialog::setMask);
|
|
connect(ui->pushButton, &QPushButton::clicked, this, &EditProfileDialog::configureCamera);
|
|
ui->listView->setCameras(cameras_->getCameras());
|
|
ui->listView->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
setConfigured();
|
|
}
|
|
|
|
void EditProfileDialog::setConfigured()
|
|
{
|
|
std::vector<cam::Camera::Description> descs = cameras_->getCameras();
|
|
std::vector<bool> configured(descs.size(), false);
|
|
|
|
for(size_t i = 0; i< profile_.cameras.size(); ++i)
|
|
{
|
|
auto& profileCamera = profile_.cameras[i];
|
|
if(profileCamera.remapMap.xMat.data)
|
|
{
|
|
for(auto& camera : descs)
|
|
{
|
|
if(camera.getHash() == profileCamera.id)
|
|
configured[i] = true;
|
|
}
|
|
}
|
|
}
|
|
ui->listView->setConfigured(configured);
|
|
}
|
|
|
|
void EditProfileDialog::invalidateCameras()
|
|
{
|
|
for(size_t i = 0; i< profile_.cameras.size(); ++i)
|
|
{
|
|
profile_.cameras[i].bgmask.release();
|
|
profile_.cameras[i].remapMap.xMat.release();
|
|
profile_.cameras[i].remapMap.yMat.release();
|
|
profile_.cameras[i].darkmap.release();
|
|
}
|
|
setConfigured();
|
|
}
|
|
|
|
void EditProfileDialog::configureCamera()
|
|
{
|
|
std::vector<cam::Camera::Description> descs = ui->listView->getSelectedDescriptions();
|
|
qDebug()<<"descs"<<descs.size();
|
|
if(!descs.empty())
|
|
{
|
|
size_t i = 0;
|
|
for(; i < profile_.cameras.size(); ++i)
|
|
{
|
|
if(profile_.cameras[i].id == descs[0].getHash())
|
|
{
|
|
std::shared_ptr<Camera> camera = cameras_->getCamera(profile_.cameras[i].id);
|
|
if(camera)
|
|
{
|
|
ConfigureCameraDialog diag(profile_.cameras[i], camera, profile_.exposureTime, this);
|
|
diag.show();
|
|
int ret = diag.exec();
|
|
if(ret == QDialog::Accepted)
|
|
profile_.cameras[i] = diag.getCameraSetup();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void EditProfileDialog::setMask()
|
|
{
|
|
uint8_t mask = (ui->checkBoxCh1->isChecked() ? CHANNEL_A : 0) |
|
|
(ui->checkBoxCh2->isChecked() ? CHANNEL_B : 0) |
|
|
(ui->checkBoxCh3->isChecked() ? CHANNEL_C : 0) |
|
|
(ui->checkBoxCh4->isChecked() ? CHANNEL_D : 0);
|
|
profile_.lighting.mask = mask;
|
|
invalidateCameras();
|
|
}
|
|
|
|
EditProfileDialog::~EditProfileDialog()
|
|
{
|
|
delete ui;
|
|
}
|