Skip to content
Snippets Groups Projects
Commit a0b95b71 authored by Fabien Mottier's avatar Fabien Mottier
Browse files

generate border edition

parent d0979a40
No related branches found
No related tags found
No related merge requests found
Showing
with 110 additions and 24 deletions
......@@ -17,11 +17,13 @@ DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
main.cpp \
mainwindow.cpp
mainwindow.cpp \
reactivelabel.cpp
HEADERS += \
../sandbox/sandbox.h \
mainwindow.h
mainwindow.h \
reactivelabel.h
FORMS += \
mainwindow.ui
......
......@@ -19,7 +19,10 @@ MainWindow::MainWindow(QWidget *parent)
parent->connect(ui->btnReload, SIGNAL (released()),this, SLOT(reloadListRealSenseDevices()));
parent->connect(ui->btnSave, SIGNAL (released()),this, SLOT(saveConfiguration()));
parent->connect(ui->btnConfig, SIGNAL (released()),this, SLOT(configure()));
//parent->connect(ui->lblImage, SIGNAL (mousePressed()),this, SLOT(selectEdgeBorder()));
parent->connect(ui->lblImage, SIGNAL (mousePos()),this, SLOT(moveEdgeBorder()));
parent->connect(ui->lblImage, SIGNAL (mouseLeft()),this, SLOT(deselectEdgeBorder()));
//parent->connect(ui->MainWindow, SIGNAL (mousePressEvent(QMouseEvent*)),this, SLOT(test(QMouseEvent*)));
// init cursor for console
pteConsole_cursor = QTextCursor(ui->pteConsole->document());
pteConsole_cursor.movePosition(QTextCursor::End);
......@@ -115,5 +118,40 @@ void MainWindow::saveConfiguration() {
* Launch the process to configure the matrix
*/
void MainWindow::configure() {
sandbox.configure(ui->lblImage);
Mat coloredFrame = sandbox.generateBorder();
ui->lblImage->setPixmap(QPixmap::fromImage(QImage(coloredFrame.data, coloredFrame.cols, coloredFrame.rows, coloredFrame.step, QImage::Format_RGB888)));
pteConsole_cursor.insertText("Ready to init\n");
borderEdition = true;
}
void MainWindow::selectEdgeBorder()
{
if (borderEdition) {
selectedPoint = sandbox.findEdgeBorder(ui->lblImage->x, ui->lblImage->y);
}
}
void MainWindow::moveEdgeBorder() {
pteConsole_cursor.insertText(QString::number(ui->lblImage->x));
pteConsole_cursor.insertText(" ");
pteConsole_cursor.insertText(QString::number(ui->lblImage->y));
pteConsole_cursor.insertText("\n");
if (borderEdition) {
if (selectedPoint == -1) {
selectedPoint = sandbox.findEdgeBorder(ui->lblImage->x, ui->lblImage->y);
//pteConsole_cursor.insertText(QString::number(selectedPoint));
//pteConsole_cursor.insertText("\n");
} else {
pteConsole_cursor.insertText(QString::number(selectedPoint));
pteConsole_cursor.insertText("\n");
Mat coloredFrame = sandbox.editEdgeBorder(selectedPoint,ui->lblImage->x, ui->lblImage->y);
ui->lblImage->setPixmap(QPixmap::fromImage(QImage(coloredFrame.data, coloredFrame.cols, coloredFrame.rows, coloredFrame.step, QImage::Format_RGB888)));
}
}
}
void MainWindow::deselectEdgeBorder() {
if (borderEdition) {
selectedPoint = -1;
}
}
......@@ -10,6 +10,7 @@
#include "sandbox.h"
#include <string>
#include <iostream>
#include "reactivelabel.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
......@@ -33,6 +34,8 @@ private:
context ctx;
device_list listRealSenseDevices;
Sandbox sandbox;
int selectedPoint = -1;
bool borderEdition = false;
// Methods
void showListRealSenseDevices();
......@@ -44,5 +47,8 @@ private slots:
void reloadListRealSenseDevices();
void saveConfiguration();
void configure();
void selectEdgeBorder();
void moveEdgeBorder();
void deselectEdgeBorder();
};
#endif // MAINWINDOW_H
......@@ -103,13 +103,7 @@
</spacer>
</item>
<item>
<widget class="QLabel" name="lblImage">
<property name="minimumSize">
<size>
<width>1400</width>
<height>1050</height>
</size>
</property>
<widget class="ReactiveLabel" name="lblImage">
<property name="styleSheet">
<string notr="true">border-color: rgb(46, 52, 54);
border-width: 1px;
......@@ -137,19 +131,19 @@ border-style: solid;</string>
</item>
<item>
<layout class="QVBoxLayout" name="layoutRight">
<item>
<spacer name="topRightSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<spacer name="topRightSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lblConsole">
<property name="text">
......
#include "reactivelabel.h"
ReactiveLabel::ReactiveLabel(QWidget *parent) : QLabel(parent)
{
}
void ReactiveLabel::mouseMoveEvent(QMouseEvent *ev){
this->x = ev->x();
this->y = ev->y();
emit mousePos();
}
void ReactiveLabel::mousePressEvent(QMouseEvent *){
emit mousePressed();
}
void ReactiveLabel::mouseReleaseEvent(QMouseEvent *){
emit mouseLeft();
}
#ifndef REACTIVELABEL_H
#define REACTIVELABEL_H
#include <QLabel>
#include <QMouseEvent>
class ReactiveLabel : public QLabel
{
Q_OBJECT
public:
explicit ReactiveLabel(QWidget *parent = 0);
void mouseMoveEvent(QMouseEvent *ev);
void mousePressEvent(QMouseEvent *ev);
void mouseReleaseEvent(QMouseEvent *ev);
int x, y = 0;
signals:
void mousePressed();
void mousePos();
void mouseLeft();
};
#endif // REACTIVELABEL_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment