Initial commit
This commit is contained in:
21
src/ui/cameradialog.cpp
Normal file
21
src/ui/cameradialog.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include "cameradialog.h"
|
||||
#include "ui_cameradialog.h"
|
||||
#include "../cameras.h"
|
||||
|
||||
CameraDialog::CameraDialog(const std::vector<cam::Camera::Description>& desc, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CameraDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->listView->setCameras(desc);
|
||||
}
|
||||
|
||||
CameraDialog::~CameraDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
std::vector<cam::Camera::Description> CameraDialog::getDescriptions()
|
||||
{
|
||||
return ui->listView->getSelectedDescriptions();
|
||||
}
|
26
src/ui/cameradialog.h
Normal file
26
src/ui/cameradialog.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef CAMERADIALOG_H
|
||||
#define CAMERADIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <vector>
|
||||
#include <uvoscam.h>
|
||||
#include <QSettings>
|
||||
|
||||
namespace Ui {
|
||||
class CameraDialog;
|
||||
}
|
||||
|
||||
class CameraDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CameraDialog(const std::vector<cam::Camera::Description>& desc, QWidget *parent = nullptr);
|
||||
~CameraDialog();
|
||||
std::vector<cam::Camera::Description> getDescriptions();
|
||||
|
||||
private:
|
||||
Ui::CameraDialog *ui;
|
||||
};
|
||||
|
||||
#endif // CAMERADIALOG_H
|
91
src/ui/cameradialog.ui
Normal file
91
src/ui/cameradialog.ui
Normal file
@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CameraDialog</class>
|
||||
<widget class="QDialog" name="CameraDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Select Cameras</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Select Cameras:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="CameraListWidget" name="listView"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonConfigure">
|
||||
<property name="text">
|
||||
<string>Configure Cameras</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>CameraListWidget</class>
|
||||
<extends>QListView</extends>
|
||||
<header location="global">cameralistwidget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CameraDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CameraDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
45
src/ui/cameralistwidget.cpp
Normal file
45
src/ui/cameralistwidget.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
#include "cameralistwidget.h"
|
||||
#include <QDebug>
|
||||
#include <QHeaderView>
|
||||
#include "../cameras.h"
|
||||
|
||||
CameraListWidget::CameraListWidget(QWidget* parent): QTableWidget(parent)
|
||||
{
|
||||
setColumnCount(1);
|
||||
setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
setHorizontalHeaderItem(0, new QTableWidgetItem("Camera"));
|
||||
setRowCount(desc_.size());
|
||||
horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
}
|
||||
|
||||
void CameraListWidget::setConfigured(std::vector<bool> configured)
|
||||
{
|
||||
setColumnCount(2);
|
||||
setHorizontalHeaderItem(1, new QTableWidgetItem("Configured"));
|
||||
for(size_t i = 0; i < desc_.size() && i < configured.size(); ++i)
|
||||
setItem(static_cast<int>(i), 0, new QTableWidgetItem("No"));
|
||||
}
|
||||
|
||||
void CameraListWidget::setCameras(const std::vector<cam::Camera::Description>& desc)
|
||||
{
|
||||
desc_ = desc;
|
||||
qDebug()<<"cameras: "<<desc_.size();
|
||||
setRowCount(static_cast<int>(desc_.size()));
|
||||
for(size_t i = 0; i < desc_.size(); ++i)
|
||||
{
|
||||
setItem(static_cast<int>(i), 0, new QTableWidgetItem((desc_[i].vendor + " " + desc_[i].model).c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<cam::Camera::Description> CameraListWidget::getSelectedDescriptions()
|
||||
{
|
||||
QList<QModelIndex> selected = selectedIndexes();
|
||||
std::vector<cam::Camera::Description> cameras;
|
||||
for(auto& selection : selected)
|
||||
{
|
||||
if(selection.column() == 0)
|
||||
cameras.push_back(desc_[selection.row()]);
|
||||
}
|
||||
return cameras;
|
||||
}
|
19
src/ui/cameralistwidget.h
Normal file
19
src/ui/cameralistwidget.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef CAMERALISTWIDGET_H
|
||||
#define CAMERALISTWIDGET_H
|
||||
|
||||
#include <vector>
|
||||
#include <uvoscam.h>
|
||||
#include <QTableWidget>
|
||||
|
||||
class CameraListWidget : public QTableWidget
|
||||
{
|
||||
private:
|
||||
std::vector<cam::Camera::Description> desc_;
|
||||
public:
|
||||
CameraListWidget(QWidget* parent);
|
||||
void setCameras(const std::vector<cam::Camera::Description>& desc);
|
||||
void setConfigured(std::vector<bool> configured);
|
||||
std::vector<cam::Camera::Description> getSelectedDescriptions();
|
||||
};
|
||||
|
||||
#endif // CAMERALISTWIDGET_H
|
36
src/ui/cvimageviewer.cpp
Normal file
36
src/ui/cvimageviewer.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
#include "cvimageviewer.h"
|
||||
#include <QPicture>
|
||||
#include <QDebug>
|
||||
|
||||
CvImageViewer::CvImageViewer(QWidget *parent, size_t lastId) :
|
||||
QWidget(parent),
|
||||
lastId_(lastId)
|
||||
{
|
||||
qimage_.load(":/images/noimage.png");
|
||||
}
|
||||
|
||||
CvImageViewer::~CvImageViewer()
|
||||
{
|
||||
}
|
||||
|
||||
void CvImageViewer::setImage(Camera::Image img)
|
||||
{
|
||||
image_ = img.mat;
|
||||
if(image_.type() == CV_8UC3 || image_.type() == CV_8SC3)
|
||||
qimage_ = QImage(image_.data, image_.cols, image_.rows, image_.step, QImage::Format_RGB888);
|
||||
else if(image_.type() == CV_8UC1 || image_.type() == CV_8SC1)
|
||||
qimage_ = QImage(image_.data, image_.cols, image_.rows, image_.step, QImage::Format_Grayscale8);
|
||||
else if(image_.type() == CV_32FC1 || image_.type() == CV_64FC1)
|
||||
img.mat.convertTo(image_, CV_8UC1, 255, 0);
|
||||
update();
|
||||
}
|
||||
|
||||
void CvImageViewer::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
QPainter painter(this);
|
||||
if(!fixedOnWidth_)
|
||||
painter.drawImage(QRect((rect().width()-rect().height())/2, rect().y(), rect().height(), rect().height()), qimage_);
|
||||
else
|
||||
painter.drawImage(QRect(rect().x(), (rect().height()-rect().width())/2, rect().width(), rect().width()), qimage_);
|
||||
}
|
30
src/ui/cvimageviewer.h
Normal file
30
src/ui/cvimageviewer.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef CVIMAGEVIEWER_H
|
||||
#define CVIMAGEVIEWER_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPainter>
|
||||
#include "../cameras.h"
|
||||
|
||||
class CvImageViewer : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
cv::Mat image_;
|
||||
QImage qimage_;
|
||||
bool fixedOnWidth_ = false;
|
||||
size_t lastId_;
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent* event) override;
|
||||
|
||||
public slots:
|
||||
void setImage(Camera::Image img);
|
||||
|
||||
public:
|
||||
explicit CvImageViewer(QWidget *parent = nullptr, size_t lastId = 0);
|
||||
void setFixedOnWidth(bool in){fixedOnWidth_ = in;}
|
||||
size_t lastId(){return lastId_;}
|
||||
~CvImageViewer();
|
||||
};
|
||||
|
||||
#endif // CVIMAGEVIEWER_H
|
28
src/ui/cvimageviewer.ui
Normal file
28
src/ui/cvimageviewer.ui
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CvImageViewer</class>
|
||||
<widget class="QWidget" name="CvImageViewer">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
16
src/ui/editprofiledialog.cpp
Normal file
16
src/ui/editprofiledialog.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include "editprofiledialog.h"
|
||||
#include "ui_editprofiledialog.h"
|
||||
|
||||
EditProfileDialog::EditProfileDialog(Cameras* cameras, Profile* profile, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
profile_(profile),
|
||||
cameras_(cameras),
|
||||
ui(new Ui::EditProfileDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
EditProfileDialog::~EditProfileDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
28
src/ui/editprofiledialog.h
Normal file
28
src/ui/editprofiledialog.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef EDDITPROFILEDIALOG_H
|
||||
#define EDDITPROFILEDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <profile.h>
|
||||
#include "../cameras.h"
|
||||
|
||||
namespace Ui {
|
||||
class EditProfileDialog;
|
||||
}
|
||||
|
||||
class EditProfileDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Profile* profile_;
|
||||
Cameras* cameras_;
|
||||
|
||||
|
||||
public:
|
||||
explicit EditProfileDialog(Cameras* cameras, Profile* profile, QWidget *parent = nullptr);
|
||||
Profile* getProfile(){return profile_;}
|
||||
~EditProfileDialog();
|
||||
|
||||
private:
|
||||
Ui::EditProfileDialog *ui;
|
||||
};
|
||||
|
||||
#endif // EDDITPROFILEDIALOG_H
|
228
src/ui/editprofiledialog.ui
Normal file
228
src/ui/editprofiledialog.ui
Normal file
@ -0,0 +1,228 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>EditProfileDialog</class>
|
||||
<widget class="QDialog" name="EditProfileDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>539</width>
|
||||
<height>485</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Profile Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEditName"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Cameras</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="CameraListWidget" name="listView"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Configure</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Exposure Time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxExposure">
|
||||
<property name="maximum">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>s</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Lights</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Brightness</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxBrightness"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>%</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Channels:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxCh1">
|
||||
<property name="text">
|
||||
<string>CH1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxCh2">
|
||||
<property name="text">
|
||||
<string>CH2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxCh3">
|
||||
<property name="text">
|
||||
<string>CH3</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxCh4">
|
||||
<property name="text">
|
||||
<string>CH4</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>CameraListWidget</class>
|
||||
<extends>QListView</extends>
|
||||
<header location="global">./src/ui/cameralistwidget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>EditProfileDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>EditProfileDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
31
src/ui/led.cpp
Normal file
31
src/ui/led.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
#include "led.h"
|
||||
#include <QPainter>
|
||||
|
||||
Led::Led(QWidget* parent): QWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool Led::lit() const
|
||||
{
|
||||
return lit_;
|
||||
}
|
||||
|
||||
void Led::setLit(bool lit)
|
||||
{
|
||||
if(lit != lit_)
|
||||
{
|
||||
lit_ = lit;
|
||||
stateChanged(lit_);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void Led::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
QPainter ledPainter(this);
|
||||
ledPainter.setPen(Qt::black);
|
||||
if(lit_) ledPainter.setBrush(Qt::red);
|
||||
else ledPainter.setBrush(Qt::NoBrush);
|
||||
ledPainter.drawEllipse(rect().adjusted(0, 0, -1, -1));
|
||||
}
|
29
src/ui/led.h
Normal file
29
src/ui/led.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef LED_H
|
||||
#define LED_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class Led : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
bool lit_ = false;
|
||||
|
||||
public:
|
||||
|
||||
Led(QWidget* parent = nullptr);
|
||||
bool lit() const;
|
||||
|
||||
public slots:
|
||||
|
||||
void setLit(bool lit);
|
||||
|
||||
signals:
|
||||
|
||||
void stateChanged(bool lit);
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent* event) override;
|
||||
|
||||
|
||||
};
|
||||
#endif // LED_H
|
69
src/ui/mainwindow.cpp
Normal file
69
src/ui/mainwindow.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
#include "mainwindow.h"
|
||||
#include "./ui_mainwindow.h"
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
#include <uvosled.h>
|
||||
|
||||
#include "../profile.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->statusbar->showMessage("idle");
|
||||
connect(ui->actionQuit, &QAction::triggered, [this](bool checked){(void)checked; close();});
|
||||
connect(ui->actionCameras, &QAction::triggered, [this](bool checked){(void)checked; sigChooseCameras();});
|
||||
connect(ui->comboBox, &QComboBox::currentTextChanged, this, &MainWindow::sigProfile);
|
||||
connect(ui->pushButtonCapture, &QPushButton::clicked, this, &MainWindow::sigCapture);
|
||||
ui->widget->setLit(true);
|
||||
refreshProfiles();
|
||||
}
|
||||
|
||||
void MainWindow::addCamera(std::shared_ptr<Camera> camera)
|
||||
{
|
||||
viewers_.push_back(new CvImageViewer(this, camera->id()));
|
||||
viewers_.back()->setFixedOnWidth(true);
|
||||
connect(camera.get(), &Camera::newImage, viewers_.back(), &CvImageViewer::setImage, Qt::QueuedConnection);
|
||||
ui->viewerLayout->addWidget(viewers_.back());
|
||||
}
|
||||
|
||||
void MainWindow::removeCamera(std::shared_ptr<Camera> camera)
|
||||
{
|
||||
for(size_t i = 0; i < viewers_.size(); ++i)
|
||||
{
|
||||
if(viewers_[i]->lastId() == camera->id())
|
||||
{
|
||||
ui->viewerLayout->removeWidget(viewers_[i]);
|
||||
delete viewers_[i];
|
||||
viewers_.erase(viewers_.begin()+i);
|
||||
--i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::refreshProfiles()
|
||||
{
|
||||
ui->comboBox->clear();
|
||||
QList<QString> profiles = Profile::avaiableProfiles();
|
||||
for(const QString& string : profiles)
|
||||
ui->comboBox->addItem(string);
|
||||
}
|
||||
|
||||
void MainWindow::profileInconpatible(QString message)
|
||||
{
|
||||
QMessageBox::warning(this, "Profile Incompatible", message);
|
||||
}
|
||||
|
||||
CvImageViewer* MainWindow::mainImageViewer()
|
||||
{
|
||||
return ui->mainViewer;
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
for(CvImageViewer* viewer : viewers_)
|
||||
delete viewer;
|
||||
delete ui;
|
||||
}
|
||||
|
39
src/ui/mainwindow.h
Normal file
39
src/ui/mainwindow.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <stdint.h>
|
||||
#include "../cameras.h"
|
||||
#include "cvimageviewer.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class MainWindow; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
std::vector<CvImageViewer*> viewers_;
|
||||
|
||||
signals:
|
||||
void sigCapture();
|
||||
void sigProfile(QString profileName);
|
||||
void sigChooseCameras();
|
||||
|
||||
public slots:
|
||||
|
||||
void addCamera(std::shared_ptr<Camera> camera);
|
||||
void refreshProfiles();
|
||||
void profileInconpatible(QString message);
|
||||
void removeCamera(std::shared_ptr<Camera> camera);
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
CvImageViewer* mainImageViewer();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
230
src/ui/mainwindow.ui
Normal file
230
src/ui/mainwindow.ui
Normal file
@ -0,0 +1,230 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="groupBoxCameras">
|
||||
<property name="title">
|
||||
<string>Cameras</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>278</width>
|
||||
<height>483</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="viewerLayout"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBoxResult">
|
||||
<property name="title">
|
||||
<string>Result</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea_2">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>467</width>
|
||||
<height>315</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="CvImageViewer" name="mainViewer" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Controles</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonCapture">
|
||||
<property name="text">
|
||||
<string>Capture</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Profile:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="Led" name="widget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Uncal</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
<property name="title">
|
||||
<string>File</string>
|
||||
</property>
|
||||
<addaction name="actionSave"/>
|
||||
<addaction name="actionQuit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuSetup">
|
||||
<property name="title">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<addaction name="actionCameras"/>
|
||||
<addaction name="actionCallibration"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuSetup"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="actionQuit">
|
||||
<property name="text">
|
||||
<string>Quit</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCameras">
|
||||
<property name="text">
|
||||
<string>Cameras</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCallibration">
|
||||
<property name="text">
|
||||
<string>Profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave">
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Led</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">./src/ui/led.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>CvImageViewer</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">./src/ui/cvimageviewer.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
37
src/ui/profiledialog.cpp
Normal file
37
src/ui/profiledialog.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include "profiledialog.h"
|
||||
#include "ui_profiledialog.h"
|
||||
#include "editprofiledialog.h"
|
||||
|
||||
ProfileDialog::ProfileDialog(Cameras* cameras, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
cameras_(cameras),
|
||||
ui(new Ui::ProfileDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->listWidget->addItems(Profile::avaiableProfiles());
|
||||
}
|
||||
|
||||
|
||||
ProfileDialog::~ProfileDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ProfileDialog::editProfile()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ProfileDialog::addProfile()
|
||||
{
|
||||
Profile newProfile;
|
||||
EditProfileDialog dialog(cameras_, &newProfile);
|
||||
dialog.show();
|
||||
int ret = dialog.exec();
|
||||
if(ret == QDialog::Accepted)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
29
src/ui/profiledialog.h
Normal file
29
src/ui/profiledialog.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef PROFILEDIALOG_H
|
||||
#define PROFILEDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "../cameras.h"
|
||||
|
||||
namespace Ui {
|
||||
class ProfileDialog;
|
||||
}
|
||||
|
||||
class ProfileDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Cameras* cameras_;
|
||||
|
||||
private slots:
|
||||
void addProfile();
|
||||
void editProfile();
|
||||
|
||||
public:
|
||||
explicit ProfileDialog(Cameras* cameras, QWidget *parent = nullptr);
|
||||
~ProfileDialog();
|
||||
|
||||
private:
|
||||
Ui::ProfileDialog *ui;
|
||||
};
|
||||
|
||||
#endif // PROFILEDIALOG_H
|
92
src/ui/profiledialog.ui
Normal file
92
src/ui/profiledialog.ui
Normal file
@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ProfileDialog</class>
|
||||
<widget class="QDialog" name="ProfileDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Profiles</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Profiles:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonEdit">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonAdd">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ProfileDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ProfileDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
Reference in New Issue
Block a user