Commit bfc80d7e authored by roangel's avatar roangel
Browse files

Added fit in view complete support. Also added Fit All in view. Now we have...

Added fit in view complete support. Also added Fit All in view. Now we have personalised tab widgets that allow us to start expanding the information displayed and actions that will be taken in each tab
parent c311a011
#include <crazyFlyZoneTab.h>
#include <QLayout>
crazyFlyZoneTab::crazyFlyZoneTab(int index, QWidget *parent)
: QWidget(parent)
{
_index = index;
center_button = new QPushButton("Fit view");
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(center_button);
setLayout(mainLayout);
QObject::connect(center_button, SIGNAL(clicked()), this, SLOT(centerButtonClicked()));
qDebug("tab widget created, index: %d", _index);
}
void crazyFlyZoneTab::centerButtonClicked()
{
qDebug("index clicked: %d", _index);
emit centerButtonClickedSignal(_index);
}
#ifndef CRAZYFLYZONETAB_H
#define CRAZYFLYZONETAB_H
#include <QObject>
#include <QWidget>
#include <QPushButton>
class crazyFlyZoneTab : public QWidget
{
Q_OBJECT
public:
explicit crazyFlyZoneTab(int index, QWidget *parent = 0);
QPushButton* center_button;
private:
int _index;
signals:
void centerButtonClickedSignal(int index);
public slots:
void centerButtonClicked();
};
#endif
#include "mainguiwindow.h"
#include "ui_mainguiwindow.h"
#include "crazyFlyZoneTab.h"
#include <QObject>
#include <QDoubleSpinBox>
......@@ -48,7 +49,9 @@ void MainGUIWindow::set_tabs(int n)
str = "CrazyFly ";
str += std::to_string(i+1);
QString qstr(str.c_str());
ui->tabWidget->addTab(new QWidget(), qstr);
crazyFlyZoneTab* widget = new crazyFlyZoneTab(i);
ui->tabWidget->addTab(widget, qstr);
connect(widget, SIGNAL(centerButtonClickedSignal(int)), this, SLOT(centerViewIndex(int)));
}
}
......@@ -1090,6 +1093,18 @@ void MainGUIWindow::on_tabWidget_currentChanged(int index)
if(index >= 0)
{
scene->setSelectedCrazyFlyZone(index);
ui->graphicsView->fitInView(scene->getRectFCrazyFlyZone(index));
}
}
void MainGUIWindow::centerViewIndex(int index)
{
ui->graphicsView->fitInView(scene->getRectFCrazyFlyZone(index), Qt::KeepAspectRatio);
ui->graphicsView->scale(0.95, 0.95); // A bit back zoom, so we can see everything better
}
void MainGUIWindow::on_pushButton_fitAll_clicked()
{
ui->graphicsView->fitInView(scene->itemsBoundingRect(), Qt::KeepAspectRatio);
ui->graphicsView->scale(0.95, 0.95); // A bit back zoom, so we can see everything better
}
......@@ -148,6 +148,10 @@ private slots:
void on_tabWidget_currentChanged(int index);
void centerViewIndex(int index);
void on_pushButton_fitAll_clicked();
private:
Ui::MainGUIWindow *ui;
......
......@@ -260,6 +260,19 @@
</property>
</widget>
</widget>
<widget class="QPushButton" name="pushButton_fitAll">
<property name="geometry">
<rect>
<x>800</x>
<y>410</y>
<width>51</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string>Fit All</string>
</property>
</widget>
</widget>
<widget class="QFrame" name="frame_3">
<property name="geometry">
......
/****************************************************************************
** Meta object code from reading C++ file 'crazyFlyZoneTab.h'
**
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.7.0)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "crazyFlyZoneTab.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'crazyFlyZoneTab.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.7.0. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
struct qt_meta_stringdata_crazyFlyZoneTab_t {
QByteArrayData data[5];
char stringdata0[69];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_crazyFlyZoneTab_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_crazyFlyZoneTab_t qt_meta_stringdata_crazyFlyZoneTab = {
{
QT_MOC_LITERAL(0, 0, 15), // "crazyFlyZoneTab"
QT_MOC_LITERAL(1, 16, 25), // "centerButtonClickedSignal"
QT_MOC_LITERAL(2, 42, 0), // ""
QT_MOC_LITERAL(3, 43, 5), // "index"
QT_MOC_LITERAL(4, 49, 19) // "centerButtonClicked"
},
"crazyFlyZoneTab\0centerButtonClickedSignal\0"
"\0index\0centerButtonClicked"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_crazyFlyZoneTab[] = {
// content:
7, // revision
0, // classname
0, 0, // classinfo
2, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
1, // signalCount
// signals: name, argc, parameters, tag, flags
1, 1, 24, 2, 0x06 /* Public */,
// slots: name, argc, parameters, tag, flags
4, 0, 27, 2, 0x0a /* Public */,
// signals: parameters
QMetaType::Void, QMetaType::Int, 3,
// slots: parameters
QMetaType::Void,
0 // eod
};
void crazyFlyZoneTab::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
crazyFlyZoneTab *_t = static_cast<crazyFlyZoneTab *>(_o);
Q_UNUSED(_t)
switch (_id) {
case 0: _t->centerButtonClickedSignal((*reinterpret_cast< int(*)>(_a[1]))); break;
case 1: _t->centerButtonClicked(); break;
default: ;
}
} else if (_c == QMetaObject::IndexOfMethod) {
int *result = reinterpret_cast<int *>(_a[0]);
void **func = reinterpret_cast<void **>(_a[1]);
{
typedef void (crazyFlyZoneTab::*_t)(int );
if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&crazyFlyZoneTab::centerButtonClickedSignal)) {
*result = 0;
return;
}
}
}
}
const QMetaObject crazyFlyZoneTab::staticMetaObject = {
{ &QWidget::staticMetaObject, qt_meta_stringdata_crazyFlyZoneTab.data,
qt_meta_data_crazyFlyZoneTab, qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
};
const QMetaObject *crazyFlyZoneTab::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *crazyFlyZoneTab::qt_metacast(const char *_clname)
{
if (!_clname) return Q_NULLPTR;
if (!strcmp(_clname, qt_meta_stringdata_crazyFlyZoneTab.stringdata0))
return static_cast<void*>(const_cast< crazyFlyZoneTab*>(this));
return QWidget::qt_metacast(_clname);
}
int crazyFlyZoneTab::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 2)
qt_static_metacall(this, _c, _id, _a);
_id -= 2;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 2)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 2;
}
return _id;
}
// SIGNAL 0
void crazyFlyZoneTab::centerButtonClickedSignal(int _t1)
{
void *_a[] = { Q_NULLPTR, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 0, _a);
}
QT_END_MOC_NAMESPACE
......@@ -19,8 +19,8 @@
QT_BEGIN_MOC_NAMESPACE
struct qt_meta_stringdata_MainGUIWindow_t {
QByteArrayData data[18];
char stringdata0[344];
QByteArrayData data[20];
char stringdata0[389];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
......@@ -46,7 +46,9 @@ QT_MOC_LITERAL(13, 224, 24), // "on_checkBox_grid_toggled"
QT_MOC_LITERAL(14, 249, 25), // "on_checkBox_table_toggled"
QT_MOC_LITERAL(15, 275, 34), // "on_checkBox_crazyfly_zones_to..."
QT_MOC_LITERAL(16, 310, 27), // "on_tabWidget_currentChanged"
QT_MOC_LITERAL(17, 338, 5) // "index"
QT_MOC_LITERAL(17, 338, 5), // "index"
QT_MOC_LITERAL(18, 344, 15), // "centerViewIndex"
QT_MOC_LITERAL(19, 360, 28) // "on_pushButton_fitAll_clicked"
},
"MainGUIWindow\0set_tabs\0\0n\0transitionToMode\0"
......@@ -58,7 +60,8 @@ QT_MOC_LITERAL(17, 338, 5) // "index"
"on_checkBox_grid_toggled\0"
"on_checkBox_table_toggled\0"
"on_checkBox_crazyfly_zones_toggled\0"
"on_tabWidget_currentChanged\0index"
"on_tabWidget_currentChanged\0index\0"
"centerViewIndex\0on_pushButton_fitAll_clicked"
};
#undef QT_MOC_LITERAL
......@@ -68,7 +71,7 @@ static const uint qt_meta_data_MainGUIWindow[] = {
7, // revision
0, // classname
0, 0, // classinfo
11, 14, // methods
13, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
......@@ -76,17 +79,19 @@ static const uint qt_meta_data_MainGUIWindow[] = {
0, // signalCount
// slots: name, argc, parameters, tag, flags
1, 1, 69, 2, 0x08 /* Private */,
4, 1, 72, 2, 0x08 /* Private */,
6, 0, 75, 2, 0x08 /* Private */,
7, 1, 76, 2, 0x08 /* Private */,
9, 1, 79, 2, 0x08 /* Private */,
10, 1, 82, 2, 0x08 /* Private */,
12, 1, 85, 2, 0x08 /* Private */,
13, 1, 88, 2, 0x08 /* Private */,
14, 1, 91, 2, 0x08 /* Private */,
15, 1, 94, 2, 0x08 /* Private */,
16, 1, 97, 2, 0x08 /* Private */,
1, 1, 79, 2, 0x08 /* Private */,
4, 1, 82, 2, 0x08 /* Private */,
6, 0, 85, 2, 0x08 /* Private */,
7, 1, 86, 2, 0x08 /* Private */,
9, 1, 89, 2, 0x08 /* Private */,
10, 1, 92, 2, 0x08 /* Private */,
12, 1, 95, 2, 0x08 /* Private */,
13, 1, 98, 2, 0x08 /* Private */,
14, 1, 101, 2, 0x08 /* Private */,
15, 1, 104, 2, 0x08 /* Private */,
16, 1, 107, 2, 0x08 /* Private */,
18, 1, 110, 2, 0x08 /* Private */,
19, 0, 113, 2, 0x08 /* Private */,
// slots: parameters
QMetaType::Void, QMetaType::Int, 3,
......@@ -100,6 +105,8 @@ static const uint qt_meta_data_MainGUIWindow[] = {
QMetaType::Void, QMetaType::Bool, 8,
QMetaType::Void, QMetaType::Bool, 8,
QMetaType::Void, QMetaType::Int, 17,
QMetaType::Void, QMetaType::Int, 17,
QMetaType::Void,
0 // eod
};
......@@ -121,6 +128,8 @@ void MainGUIWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _i
case 8: _t->on_checkBox_table_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 9: _t->on_checkBox_crazyfly_zones_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 10: _t->on_tabWidget_currentChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
case 11: _t->centerViewIndex((*reinterpret_cast< int(*)>(_a[1]))); break;
case 12: _t->on_pushButton_fitAll_clicked(); break;
default: ;
}
}
......@@ -151,13 +160,13 @@ int MainGUIWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 11)
if (_id < 13)
qt_static_metacall(this, _c, _id, _a);
_id -= 11;
_id -= 13;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 11)
if (_id < 13)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 11;
_id -= 13;
}
return _id;
}
......
......@@ -294,7 +294,7 @@ void myGraphicsScene::showCrazyFlyZones()
QRectF myGraphicsScene::getRectFCrazyFlyZone(int index)
{
QRectF rect(crazyfly_zones[index]->rect());
QRectF rect(crazyfly_zones[index]->sceneBoundingRect());
return rect;
}
......
......@@ -20,7 +20,7 @@ void myGraphicsView::wheelEvent(QWheelEvent *event)
double scaleFactor = 1.15;
if(event->delta() > 0) {
// Zoom in
this-> scale(scaleFactor, scaleFactor);
this->scale(scaleFactor, scaleFactor);
} else {
// Zooming out
......
......@@ -47,6 +47,7 @@ public:
QCheckBox *checkBox_vicon_markers;
QCheckBox *checkBox_grid;
QCheckBox *checkBox_table;
QPushButton *pushButton_fitAll;
QFrame *frame_3;
QMenuBar *menuBar;
QToolBar *mainToolBar;
......@@ -123,6 +124,9 @@ public:
checkBox_table->setGeometry(QRect(10, 80, 101, 20));
checkBox_table->setFont(font);
checkBox_table->setChecked(true);
pushButton_fitAll = new QPushButton(frame_drawing);
pushButton_fitAll->setObjectName(QStringLiteral("pushButton_fitAll"));
pushButton_fitAll->setGeometry(QRect(800, 410, 51, 51));
frame_3 = new QFrame(centralWidget);
frame_3->setObjectName(QStringLiteral("frame_3"));
frame_3->setGeometry(QRect(990, 20, 481, 469));
......@@ -161,6 +165,7 @@ public:
checkBox_vicon_markers->setText(QApplication::translate("MainGUIWindow", "Show Markers", 0));
checkBox_grid->setText(QApplication::translate("MainGUIWindow", "Show Grid", 0));
checkBox_table->setText(QApplication::translate("MainGUIWindow", "Show Table", 0));
pushButton_fitAll->setText(QApplication::translate("MainGUIWindow", "Fit All", 0));
} // retranslateUi
};
......
......@@ -19,7 +19,8 @@ SOURCES += main.cpp\
cornergrabber.cpp \
myGraphicsView.cpp \
crazyFlyZone.cpp \
tablePiece.cpp
tablePiece.cpp \
crazyFlyZoneTab.cpp
HEADERS += mainguiwindow.h \
myGraphicsScene.h \
......@@ -27,6 +28,7 @@ HEADERS += mainguiwindow.h \
cornergrabber.h \
myGraphicsView.h \
crazyFlyZone.h \
tablePiece.h
tablePiece.h \
crazyFlyZoneTab.h
FORMS += mainguiwindow.ui
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment