mainny ui improcements
This commit is contained in:
parent
50777fe056
commit
86ec50575b
25 changed files with 819 additions and 264 deletions
|
|
@ -2,6 +2,8 @@
|
|||
#include "ui_editprofiledialog.h"
|
||||
#include <uvosled.h>
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "configurecameradialog.h"
|
||||
|
||||
|
|
@ -24,26 +26,91 @@ EditProfileDialog::EditProfileDialog(Cameras* cameras, const Profile profile, QW
|
|||
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());
|
||||
ui->checkBoxNodistort->setChecked(profile_.nodistort);
|
||||
|
||||
std::vector<cam::Camera::Description> descs = cameras_->getCameras();
|
||||
profile_.setCamerasSetupsFromDescription(descs);
|
||||
|
||||
if(profile_.cameras.size() > 0)
|
||||
{
|
||||
uint64_t min, max;
|
||||
std::shared_ptr<Camera> cam = cameras_->getCamera(profile_.cameras[0].id);
|
||||
if(cam)
|
||||
{
|
||||
cam->cam()->getExposureTimeLimits(min, max);
|
||||
ui->doubleSpinBoxExposure->setMaximum(max/1000000.0);
|
||||
ui->doubleSpinBoxExposure->setMinimum(min/1000000.0);
|
||||
}
|
||||
}
|
||||
|
||||
ui->calLed->setLit(profile_.calcurve.data);
|
||||
|
||||
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->doubleSpinBoxExposure, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [this](double in){profile_.exposureTime = in; invalidateCameras();});
|
||||
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);
|
||||
connect(ui->checkBoxNodistort, &QCheckBox::stateChanged, [this](int state){profile_.nodistort = state == Qt::Checked ?: false; setConfigured();});
|
||||
connect(ui->pushButtonCalLoad, &QPushButton::clicked, this, &EditProfileDialog::loadCalcurve);
|
||||
connect(ui->pushButtonLightmapLoad, &QPushButton::clicked, this, &EditProfileDialog::loadCalcurve);
|
||||
ui->listView->setCameras(cameras_->getCameras());
|
||||
ui->listView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
setConfigured();
|
||||
}
|
||||
|
||||
void EditProfileDialog::setConfigured()
|
||||
void EditProfileDialog::loadLightmap()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, "Open Lightmap", "./", "*.mat");
|
||||
if(!fileName.isEmpty())
|
||||
{
|
||||
profile_.calcurve.release();
|
||||
cv::FileStorage matf(fileName.toStdString(), cv::FileStorage::READ);
|
||||
matf["image"]>>profile_.lightmap;
|
||||
|
||||
if(matf.isOpened() && (!profile_.calcurve.data || profile_.calcurve.type() != CV_32FC1))
|
||||
{
|
||||
profile_.lightmap.release();
|
||||
QMessageBox::warning(this, "Invalid file", "File selected dose not contain a valid lightmap");
|
||||
}
|
||||
else if(!profile_.calcurve.data)
|
||||
{
|
||||
QMessageBox::warning(this, "Can no open", "Can not open file selected");
|
||||
}
|
||||
matf.release();
|
||||
ui->ledLightmap->setLit(profile_.lightmap.data);
|
||||
}
|
||||
}
|
||||
|
||||
void EditProfileDialog::loadCalcurve()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, "Open Cal Curve", "./", "*.mat");
|
||||
if(!fileName.isEmpty())
|
||||
{
|
||||
profile_.calcurve.release();
|
||||
cv::FileStorage matf(fileName.toStdString(), cv::FileStorage::READ);
|
||||
matf["cal"]>>profile_.calcurve;
|
||||
|
||||
if(matf.isOpened() && (!profile_.calcurve.data || profile_.calcurve.type() != CV_32FC1 || profile_.calcurve.rows != 2))
|
||||
{
|
||||
profile_.calcurve.release();
|
||||
QMessageBox::warning(this, "Invalid file", "File selected dose not contain a valid cal curve");
|
||||
}
|
||||
else if(!profile_.calcurve.data)
|
||||
{
|
||||
QMessageBox::warning(this, "Can no open", "Can not open file selected");
|
||||
}
|
||||
matf.release();
|
||||
ui->calLed->setLit(profile_.calcurve.data);
|
||||
}
|
||||
}
|
||||
|
||||
bool EditProfileDialog::setConfigured()
|
||||
{
|
||||
std::vector<cam::Camera::Description> descs = cameras_->getCameras();
|
||||
std::vector<bool> configured(descs.size(), false);
|
||||
std::vector<bool> configured(descs.size(), profile_.nodistort);
|
||||
|
||||
for(size_t i = 0; i< profile_.cameras.size(); ++i)
|
||||
{
|
||||
|
|
@ -52,12 +119,19 @@ void EditProfileDialog::setConfigured()
|
|||
{
|
||||
for(auto& camera : descs)
|
||||
{
|
||||
if(camera.getHash() == profileCamera.id)
|
||||
if(camera.getId() == profileCamera.id)
|
||||
configured[i] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
ui->listView->setConfigured(configured);
|
||||
bool fullyConfigured = true;
|
||||
for(bool config : configured)
|
||||
{
|
||||
if(!config)
|
||||
fullyConfigured = false;
|
||||
}
|
||||
return fullyConfigured;
|
||||
}
|
||||
|
||||
void EditProfileDialog::invalidateCameras()
|
||||
|
|
@ -78,10 +152,12 @@ void EditProfileDialog::configureCamera()
|
|||
qDebug()<<"descs"<<descs.size();
|
||||
if(!descs.empty())
|
||||
{
|
||||
qDebug()<<"want to edit id"<<descs[0].getId();
|
||||
size_t i = 0;
|
||||
for(; i < profile_.cameras.size(); ++i)
|
||||
{
|
||||
if(profile_.cameras[i].id == descs[0].getHash())
|
||||
qDebug()<<"test"<<profile_.cameras[i].id ;
|
||||
if(profile_.cameras[i].id == descs[0].getId())
|
||||
{
|
||||
std::shared_ptr<Camera> camera = cameras_->getCamera(profile_.cameras[i].id);
|
||||
if(camera)
|
||||
|
|
@ -94,9 +170,18 @@ void EditProfileDialog::configureCamera()
|
|||
}
|
||||
}
|
||||
}
|
||||
setConfigured();
|
||||
}
|
||||
}
|
||||
|
||||
void EditProfileDialog::accept()
|
||||
{
|
||||
if(!setConfigured())
|
||||
QMessageBox::information(this, "Unfinished", "Can not accept with unconfigured cameras");
|
||||
else
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void EditProfileDialog::setMask()
|
||||
{
|
||||
uint8_t mask = (ui->checkBoxCh1->isChecked() ? CHANNEL_A : 0) |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue