Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scene sync #10

Merged
merged 18 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 0 additions & 55 deletions Controllers/bottomtrackcontrolmenucontroller.cpp

This file was deleted.

11 changes: 0 additions & 11 deletions Core/drawutils.h

This file was deleted.

6 changes: 3 additions & 3 deletions DevHub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ void Device::putData(const QByteArray &data) {

#if !defined(Q_OS_ANDROID)
if(_parser.id() == ID_TIMESTAMP && _parser.ver() == v1) {
int timestamp = _parser.read<U4>();
int unix = _parser.read<U4>();
core.dataset()->addEvent(timestamp, 0, unix);
int t = static_cast<int>(_parser.read<U4>());
int u = static_cast<int>(_parser.read<U4>());
core.dataset()->addEvent(t, 0, u);
// core.consoleInfo(QString("Event time %1.%2").arg(unix).arg(timestamp));
}

Expand Down
2 changes: 1 addition & 1 deletion IDBinnary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <core.h>
extern Core core;

#if defined(Q_OS_ANDROID)
#if defined(Q_OS_ANDROID) || (defined Q_OS_LINUX)
template < typename T, size_t N >
size_t _countof( T const (&array)[ N ] ) { return N; }
#endif
Expand Down
17 changes: 14 additions & 3 deletions KoggerApp.pro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ QT += qml

#CONFIG += FLASHER

windows {
!android {
QT += serialport
}

Expand Down Expand Up @@ -57,6 +57,7 @@ SOURCES += \
consolelistmodel.cpp \
core.cpp \
filelist.cpp \
geometryengine.cpp \
graphicsscene3drenderer.cpp \
graphicsscene3dview.cpp \
logger.cpp \
Expand All @@ -68,6 +69,7 @@ SOURCES += \
ray.cpp \
raycaster.cpp \
streamlist.cpp \
textrenderer.cpp \
waterfall.cpp \

FLASHER {
Expand All @@ -85,6 +87,7 @@ SOURCES += \
}

RESOURCES += QML/qml.qrc \
resources.qrc \
shaders.qrc

# Additional import path used to resolve QML modules in Qt Creator's code model
Expand Down Expand Up @@ -120,6 +123,7 @@ HEADERS += \
filelist.h \
flasher.h \
core.h \
geometryengine.h \
graphicsscene3drenderer.h \
graphicsscene3dview.h \
logger.h \
Expand All @@ -129,6 +133,7 @@ HEADERS += \
ray.h \
raycaster.h \
streamlist.h \
textrenderer.h \
waterfall.h \
waterfallproxy.h \

Expand Down Expand Up @@ -201,16 +206,22 @@ DISTFILES += \
qtandroidserialport/src/qtandroidserialport.pri
}



windows {
LIBS += -lopengl32
}

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/libs/freetype/lib/mingw-x64/ -lfreetype
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/libs/freetype/lib/mingw-x64/ -lfreetype
else:unix:!macx: LIBS += -L$$PWD/libs/freetype/lib/gcc/ -lfreetype

INCLUDEPATH += $$PWD/libs/freetype/include
DEPENDPATH += $$PWD/libs/freetype/include

include ($$PWD/core/core.pri)
include ($$PWD/processors/processors.pri)
include ($$PWD/domain/domain.pri)
include ($$PWD/controllers/controllers.pri)
include ($$PWD/events/events.pri)


android {
Expand Down
1 change: 1 addition & 0 deletions Plot2D.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Plot2D.h"
#include <epochevent.h>

Plot2D::Plot2D() {
_echogram.setVisible(true);
Expand Down
32 changes: 25 additions & 7 deletions QML/BottomTrackControlMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,36 @@ Item {
text: "Show"
checkState: Qt.Checked
onCheckedChanged: root.controller.onVisibilityCheckBoxCheckedChanged(checked)

Component.onCompleted: {
if(controller.bottomTrack)
checkState = controller.bottomTrack.visible ? Qt.Checked : Qt.Unchecked
if(root.controller.bottomTrack)
visibilityCheckBox.checkState = controller.bottomTrack.visible ? Qt.Checked : Qt.Unchecked
}
}

KButton {
id: restoreBottomTrack
Layout.fillWidth: true
text: qsTr("Restore")
onClicked: root.controller.onRestoreBottomTrackButtonClicked()
KParamSetup {
paramName: "Visible channel: "

KCombo {
id: visibleChannelCombo
objectName: "visibleChannelCombo"
Layout.preferredWidth: 250
model: root.controller.channelList
onActivated: root.controller.onVisibleChannelComboBoxIndexChanged(currentIndex)

Component.onCompleted: {
visibleChannelCombo.currentIndex = controller.visibleChannelIndex
}
}
}
}
}

Connections {
target: root.controller
function onChannelListUpdated() {
visibleChannelCombo.currentIndex = controller.visibleChannelIndex
visibleChannelCombo.model = controller.channelList
}
}
}
3 changes: 3 additions & 0 deletions assets.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<RCC>
<qresource prefix="/"/>
</RCC>
Binary file added assets/fonts/arial.ttf
Binary file not shown.
91 changes: 91 additions & 0 deletions controllers/bottomtrackcontrolmenucontroller.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#include "bottomtrackcontrolmenucontroller.h"
#include <graphicsscene3dview.h>
#include <bottomtrack.h>
#include <maxpointsfilter.h>
#include <nearestpointfilter.h>
#include <QmlObjectNames.h>
#include <plotcash.h>

BottomTrackControlMenuController::BottomTrackControlMenuController(QObject* parent)
: QmlComponentController(parent)
{}

BottomTrackControlMenuController::~BottomTrackControlMenuController()
{}

void BottomTrackControlMenuController::onVisibilityCheckBoxCheckedChanged(bool checked)
{
if(!m_graphicsSceneView)
return;

auto bottomTrack = m_graphicsSceneView->bottomTrack();

QMetaObject::invokeMethod(reinterpret_cast <QObject*>(bottomTrack.get()), "setVisible", Q_ARG(bool, checked));
}

void BottomTrackControlMenuController::onVisibleChannelComboBoxIndexChanged(int index)
{
if(!m_graphicsSceneView)
return;

if(m_channelList.isEmpty())
return;

auto channelId = QString(m_channelList.at(index)).toInt();

m_graphicsSceneView->bottomTrack()->setVisibleChannel(channelId);
}

void BottomTrackControlMenuController::setGraphicsSceneView(GraphicsScene3dView *sceneView)
{
m_graphicsSceneView = sceneView;

if(!m_graphicsSceneView)
return;

QObject::connect(m_graphicsSceneView->bottomTrack().get(), &BottomTrack::epochListChanged,
this, &BottomTrackControlMenuController::updateChannelList);
}

BottomTrack *BottomTrackControlMenuController::bottomTrack() const
{
if(!m_graphicsSceneView)
return nullptr;

return m_graphicsSceneView->bottomTrack().get();
}

QStringList BottomTrackControlMenuController::channelList() const
{
return m_channelList;
}

int BottomTrackControlMenuController::visibleChannelIndex() const
{
if(!m_graphicsSceneView)
return -1;

auto ch = m_graphicsSceneView->bottomTrack()->visibleChannel();

return m_channelList.indexOf(QString::number(ch.channel));
}

void BottomTrackControlMenuController::updateChannelList()
{
m_channelList.clear();

if(!m_graphicsSceneView)
return;

auto channels = m_graphicsSceneView->bottomTrack()->channels();

for(const auto& channel : qAsConst(channels))
m_channelList << QString("%1").arg(channel.channel);

Q_EMIT channelListUpdated();
}

void BottomTrackControlMenuController::findComponent()
{
m_component = m_engine->findChild<QObject*>(QmlObjectNames::bottomTrackControlMenu);
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
#ifndef BOTTOMTRACKCONTROLMENUCONTROLLER_H
#define BOTTOMTRACKCONTROLMENUCONTROLLER_H

#include <memory>

#include <qmlcomponentcontroller.h>

#include <memory>

class BottomTrack;
class GraphicsScene3dView;
class BottomTrackControlMenuController : public QmlComponentController
{
Q_OBJECT
Q_PROPERTY(BottomTrack* bottomTrack READ bottomTrack CONSTANT)
Q_PROPERTY(QStringList channelList READ channelList CONSTANT)
Q_PROPERTY(int visibleChannelIndex READ visibleChannelIndex CONSTANT)

public:
BottomTrackControlMenuController(QObject* parent = nullptr);

virtual ~BottomTrackControlMenuController();

Q_INVOKABLE void onVisibilityCheckBoxCheckedChanged(bool checked);
Q_INVOKABLE void onRestoreBottomTrackButtonClicked();
Q_INVOKABLE void onVisibleChannelComboBoxIndexChanged(int index);

void setGraphicsSceneView(GraphicsScene3dView* sceneView);

Expand All @@ -27,9 +29,19 @@ class BottomTrackControlMenuController : public QmlComponentController

private:
BottomTrack* bottomTrack() const;
QStringList channelList() const;
int visibleChannelIndex() const;

private Q_SLOTS:
void updateChannelList();

Q_SIGNALS:
void channelListUpdated();

private:
GraphicsScene3dView* m_graphicsSceneView = nullptr;
QStringList m_channelList;

};

#endif // BOTTOMTRACKCONTROLMENUCONTROLLER_H
File renamed without changes.
2 changes: 2 additions & 0 deletions core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,8 @@ void Core::UILoad(QObject *object, const QUrl &url) {
for(int i = 0; i < _plots2d.size(); i++) {
if(_plots2d.at(i) != NULL) {
_plots2d.at(i)->setPlot(_dataset);
m_scene3dView->bottomTrack()->installEventFilter(_plots2d.at(i));
_plots2d.at(i)->installEventFilter( m_scene3dView->bottomTrack().get());
}
}

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion Core/core.pri → core/core.pri
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ DEPENDPATH *= $$PWD
HEADERS += \
$$PWD/QmlObjectNames.h \\
$$PWD/drawutils.h \
$$PWD/koggerglobal.h \
$$PWD/sceneobject.h \

SOURCES += \
$$PWD/drawutils.cpp \
$$PWD/sceneobject.cpp
Loading