Qt6 Migration: Complete migration with DDS/RTI support and build validation
Major Changes:
- Merged latest Qt5 devel content from dlbo (292 files changed, 7 new dirs)
- Consolidated forward-declarations and include folders
- Removed unneeded modules per Niklas' repo check list
Build System Fixes:
- Fixed CMake VERSION_GREATER syntax in ParticipantManagement/CMakeLists.txt
- Added VLC packages (libvlc-dev, vlc-plugin-base) to docker_build.sh
- Added PostgreSQL dev packages (libpq-dev, postgresql-server-dev-all) to Dockerfile
- Fixed locale warnings (ANSI_X3.4-1968 → C.UTF-8)
- Fixed ArcGIS SDK path warnings when BUILD_ARCGIS=OFF
Code Generation Fixes:
- Fixed IDL enum collisions (PortType→CorePortType/DdsutPortType, PdmEventType)
- Fixed Grantlee template svc_translation.cpp.grantlee:
- Changed {{ idl_enum.name }}_def:: to {{ idl_enum.name }}::
- Fixed .underlying() calls for C++11 scoped enums (enum class)
- Removed generated files from repo (moc_*, *_dtc.h, *_ftc.h)
Validation:
- BUILD_RTI=ON: SUCCESS
- BUILD_RTI=OFF: SUCCESS
- C++17 standard maintained for RTI 7.7 compatibility
- Ubuntu 26.04 Docker environment verified
Remaining Warnings (expected):
- BgViewer, KDChart, KDReports, Poppler-Qt6 not found (optional features)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
18662 files changed
+4115092
-5435
No files matched your search
@@ -0,0 +1,127 @@
|
||||
#
|
||||
# THP-Viewer
|
||||
#
|
||||
ADD_SUBDIRECTORY(THP-Starter)
|
||||
FIND_PACKAGE(VLC REQUIRED)
|
||||
|
||||
SET(thp_viewer_SRCS
|
||||
main.cpp
|
||||
thp_plugin_provider.cpp
|
||||
thp_plugin_provider.h
|
||||
thp_situation_filter_interface_impl.cpp
|
||||
thp_situation_filter_interface_impl.h
|
||||
thp_viewer.cpp
|
||||
thp_viewer.h
|
||||
|
||||
thpwidgets/thp_audio_video_widget.cpp
|
||||
thpwidgets/thp_audio_video_widget.h
|
||||
thpwidgets/thp_audio_video_widget_p.h
|
||||
thpwidgets/thp_building_settings.cpp
|
||||
thpwidgets/thp_building_settings.h
|
||||
thpwidgets/thp_building_widget.cpp
|
||||
thpwidgets/thp_building_widget.h
|
||||
thpwidgets/thp_html_widget.cpp
|
||||
thpwidgets/thp_html_widget.h
|
||||
thpwidgets/thp_pdf_widget.cpp
|
||||
thpwidgets/thp_pdf_widget.h
|
||||
thpwidgets/thp_situation_building_base.h
|
||||
thpwidgets/thp_situation_building_base.cpp
|
||||
thpwidgets/thp_situation_filter_aes.cpp
|
||||
thpwidgets/thp_situation_filter_aes.h
|
||||
thpwidgets/thp_situation_filter_building_components.cpp
|
||||
thpwidgets/thp_situation_filter_building_components.h
|
||||
thpwidgets/thp_situation_filter_collapse_expand.cpp
|
||||
thpwidgets/thp_situation_filter_collapse_expand.h
|
||||
thpwidgets/thp_situation_filter_symbol_appearance.cpp
|
||||
thpwidgets/thp_situation_filter_symbol_appearance.h
|
||||
thpwidgets/thp_situation_filter_types.cpp
|
||||
thpwidgets/thp_situation_filter_types.h
|
||||
thpwidgets/thp_situation_widget.cpp
|
||||
thpwidgets/thp_situation_widget.h
|
||||
thpwidgets/thp_zoom_slider.cpp
|
||||
thpwidgets/thp_zoom_slider.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(thp_viewer_SRCS
|
||||
thp_viewer.ui
|
||||
thpwidgets/thp_audio_video_widget.ui
|
||||
thpwidgets/thp_building_settings.ui
|
||||
thpwidgets/thp_html_widget.ui
|
||||
thpwidgets/thp_pdf_widget.ui
|
||||
thpwidgets/thp_situation_building_base.ui
|
||||
)
|
||||
IF(WIN32)
|
||||
SET(JBN ${JENKINS_BUILD_NUMBER})
|
||||
IF (NOT JENKINS_BUILD_NUMBER)
|
||||
SET(JBN "0")
|
||||
ENDIF()
|
||||
SET(THP_VERSION_INFO "${LTS_VERSION_MAJOR}, ${LTS_VERSION_MINOR}, ${JBN}, ${LTS_VERSION_PATCH}")
|
||||
CONFIGURE_FILE(thp_viewer.rc.cmake ${CMAKE_CURRENT_BINARY_DIR}/thp_viewer.rc)
|
||||
LIST(APPEND thp_viewer_SRCS ${CMAKE_CURRENT_BINARY_DIR}/thp_viewer.rc)
|
||||
ENDIF(WIN32)
|
||||
NGL_ADD_APP_ICON(thp_viewer_SRCS)
|
||||
|
||||
NGL_ADD_EXECUTABLE(WS thp_viewer WIN32 ${thp_viewer_SRCS})
|
||||
NGL_INSTALL_TARGET(thp_viewer)
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(thp_viewer
|
||||
PRIVATE
|
||||
${VLC_INCLUDE_DIR}
|
||||
)
|
||||
NGL_TARGET_COMPILE_DEFINITIONS(thp_viewer
|
||||
PRIVATE
|
||||
${VLC_DEFINES}
|
||||
)
|
||||
NGL_TARGET_LINK_LIBRARIES(thp_viewer
|
||||
ArcGISQt5Hack # make sure it's loaded *before* libEsriCommonQt.so
|
||||
|
||||
${VLC_LIBRARIES}
|
||||
Qt5::Core
|
||||
Qt5::Gui
|
||||
Qt5::PrintSupport
|
||||
Qt5::Svg
|
||||
Qt5::WebEngineCore
|
||||
Qt5::WebEngineWidgets
|
||||
Qt5::Widgets
|
||||
Qt5::Xml
|
||||
|
||||
RmeLightStyleQrc
|
||||
|
||||
AsbData
|
||||
AsbForeignDataPluginThp
|
||||
BuildingViewerCommon
|
||||
FltAesGuiCommon
|
||||
FltAesWidget
|
||||
FltBldgCmpntWidget
|
||||
FltParticipantWidget
|
||||
IsmDataPluginThp
|
||||
LtsCoordTrans
|
||||
LtsCommandLineParser
|
||||
NGLLogger
|
||||
nglsingleapplication
|
||||
ngltools
|
||||
ngltranslator
|
||||
nglwidgets
|
||||
PdmComboBoxGui
|
||||
PpmComboBoxGui
|
||||
SitmapDds
|
||||
SituationReplaySqlite
|
||||
|
||||
svcFlmCommon
|
||||
|
||||
svcAesClient
|
||||
svcBldClient
|
||||
svcCesClient
|
||||
svcGimClient
|
||||
svcIsmClient
|
||||
svcPpmClient
|
||||
svcPdmClient
|
||||
svcAlmClient
|
||||
)
|
||||
IF(WIN32)
|
||||
# NGL_INSTALL(WS FILES autorun.inf DESTINATION bin)
|
||||
# NGL_INSTALL(WS FILES readme.win32.en_US.txt DESTINATION bin)
|
||||
# NGL_INSTALL(WS FILES readme.win32.de_DE.txt DESTINATION bin)
|
||||
ENDIF()
|
||||
NGL_INSTALL(WS FILES log4cxx_thp_viewer.props DESTINATION bin)
|
||||
|
||||
ADD_SUBDIRECTORY(SitMapReplayTest)
|
||||
@@ -0,0 +1,101 @@
|
||||
#
|
||||
# Hinweise für das THP
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
N. Thoden, 12.03.2020
|
||||
|
||||
Das TakeHomePackage (für Windows) besteht aus 3 Komponenten:
|
||||
============================================================
|
||||
|
||||
1) den THP-Viewer / THP-Starter
|
||||
(inkl. Qt ; ohne MSVCRuntime, z.B. msvcr120.dll, in C:\Windows\system32 !?)
|
||||
http://jenkins-master.sl.defence-elec.de:8080/job/ahtc_OC-Tablet/
|
||||
thp.tgz
|
||||
2) die Kartendaten
|
||||
(evtl. für den Datenträger reduziert in Bezug auf die Speichergröße)
|
||||
3) die Topic-Daten (Video, Audio, DB-Abzug...)
|
||||
|
||||
|
||||
Woher kommt was?
|
||||
================
|
||||
1) Der THP-Viewer / THP-Starter
|
||||
Kann aus der CI-Umgebung (Jenkins) heruntergeladen werden (thp.tgz)
|
||||
Am besten mit 7Zip entpackt werden:
|
||||
(tgz -> gepackt und anschliessend komprimiert)
|
||||
- Per Kontext-Menue "entpacken nach hier"
|
||||
- die resultierende Datei "thp' "entpacken nach thp~".
|
||||
Dann sollte ein Verzeichnis "thp" MIT diversen Unterverzeichnissen entstehen.
|
||||
|
||||
Das THP-Verzeichnis wird auf jeder Workstation im Ordner /opt/THP als Quelle für den USB-Datentraeger bereitgestellt.
|
||||
|
||||
2) Diese werden manuell für das THP bereitgestellt (meist als tpk-Datei).
|
||||
|
||||
3) Die Topic-Daten werden in der OpApp mit "Präsentation exportieren" erzeugt.
|
||||
Sie werden unter /tmp/THP-Export generiert.
|
||||
|
||||
|
||||
Woher kommt das Verzeichnis 'Maps'?
|
||||
===================================
|
||||
Der Verzeichnisname 'Maps' ist fest und darf nicht verändert werden.
|
||||
Es müssen die für das Medium (CD, DVD, Stick..) passenden Basiskarten/Kartendaten hinein.
|
||||
Das sind also z.B.
|
||||
- 2020-03-03_UaeAerial_32639_Lvl6.tpk
|
||||
- 2020-03-03_UaeAerial_WebMerc_Lvl15.tpk
|
||||
- 2020-03-03_UaeTopo_32639_Lvl6.tpk
|
||||
- 2020-03-03_UaeTopo_WebMerc_Lvl15.tpk
|
||||
- AHTC_utm_dgm_surface_wgs84.tif
|
||||
|
||||
Das layerMapping.json hat nun die Aufgabe, diese (für das Übungsgebiet) spezifischen
|
||||
Dateinamen zu abstrahieren.
|
||||
Die bei der Ausführung des THPs geforderten Basiskarten (Annahme: eine Topo und zwei Aerial)
|
||||
können mit Hilfe der layerMapping.json auf eine geringere Anzahl Dateien gemappt werden.
|
||||
|
||||
Basiskarten: Mapping per layerMapping.json
|
||||
in der WS-App: Dateien in Dir 'Maps'
|
||||
-------------- ---------------------
|
||||
- Aerial2 -> 2020-03-03_UaeAerial_32639_Lvl6.tpk
|
||||
- Aerial1 -> 2020-03-03_UaeAerial_32639_Lvl6.tpk
|
||||
- Topo -> 2020-03-03_UaeTopo_32639_Lvl6.tpk
|
||||
|
||||
Best Practise:
|
||||
Daher ergibt es Sinn, eine layerMapping.json in dem Verzeichnis 'Maps' vorzubereiten
|
||||
und beim Zusammengefügen in die darüberliegende Dateiebene zu kopieren.
|
||||
|
||||
|
||||
Wie müssen die 3 Komponenten zusammengefügt werden?
|
||||
===================================================
|
||||
|
||||
Device:
|
||||
- Excersise_6
|
||||
- 1 <- Übungsdaten (Komponenten 3)
|
||||
- ...
|
||||
- index.html <- Übungsdaten (Komponenten 3)
|
||||
- ... <- Übungsdaten (Komponenten 3)
|
||||
|
||||
- Maps <- Kartendaten (Komponenten 2)
|
||||
- *.tpk
|
||||
- [layerMapping.json] <- Sonderfall AHTC 03/2020: Diese Datei in
|
||||
die darüberliegende Ebenen verschieben.
|
||||
- layerMapping.json <- Übungsdaten (Komponenten 2/3)
|
||||
(generiert, Sonderfall AHTC 03/2020:
|
||||
aus 'Maps' hierher transferieren)
|
||||
|
||||
- thp <- thp (Komponenten 1)
|
||||
- resources <- thp (Komponenten 1), hat mal gefehlt)
|
||||
- thv_viewer.exe <- thp (Komponenten 1)
|
||||
- vc.redist.x64.exe <- thp (Komponenten 1), für MSVCRuntime
|
||||
- thp_starter.exe <- thp (Komponenten 1)
|
||||
- autorun.inf <- thp (Komponenten 1)
|
||||
- [wappen.png] <- thp (Komponenten 1 oder 3) optional !?
|
||||
|
||||
|
||||
Logfiles zuir Fehlersuche
|
||||
=========================
|
||||
Ein Logfile befindet sich unter ~Benutzer\AppData\Local\Temp\.
|
||||
Bsp: C:\User\thoden\AppData\Local\Temp\thoden_thp.log
|
||||
C:\User\thoden\AppData\Local\Temp\thoden_thp.log.1
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#
|
||||
# SitMapReplayTest
|
||||
#
|
||||
SET(SRPTEST_SRCS
|
||||
srp_main.cpp
|
||||
srp_main_window.cpp
|
||||
srp_main_window.h
|
||||
../thp_plugin_provider.cpp
|
||||
../thp_plugin_provider.h
|
||||
../thp_situation_filter_interface_impl.cpp
|
||||
../thp_situation_filter_interface_impl.h
|
||||
)
|
||||
NGL_WRAP_UI(SRPTEST_SRCS
|
||||
srp_main_window.ui
|
||||
)
|
||||
NGL_ADD_EXECUTABLE(WS SitMapReplayTest ${SRPTEST_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(SitMapReplayTest
|
||||
SituationReplaySqlite
|
||||
|
||||
ddsconnector
|
||||
Qt5::Core
|
||||
nglapplication
|
||||
SitmapDds
|
||||
|
||||
AsbForeignDataPluginThp
|
||||
BuildingViewerCommon
|
||||
FltAesGuiCommon
|
||||
IsmDataPluginThp
|
||||
|
||||
svcFlmCommon
|
||||
|
||||
svcAesClient
|
||||
svcBldClient
|
||||
svcCesClient
|
||||
svcGimClient
|
||||
svcIsmClient
|
||||
svcPpmClient
|
||||
svcPdmClient
|
||||
)
|
||||
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Main for SitMapReplayTest
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#include <nglapplication/nglapplication.h>
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <DDS/QosProfile/DDS_DefaultQos.h>
|
||||
#include <QNetworkProxy>
|
||||
#include <SituationReplay/main_handler_sqlite.h>
|
||||
#include <SituationMap/situation_map_init.h>
|
||||
#include <SituationMap/Utils/movement_track_manager.h>
|
||||
#include "../thp_plugin_provider.h"
|
||||
#include "srp_main_window.h"
|
||||
#include "ui_srp_main_window.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QNetworkProxy::setApplicationProxy(QNetworkProxy());
|
||||
NGLApplication app(argc, argv);
|
||||
app.createLogger("SRP");
|
||||
app.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
|
||||
SituationReplay::ConnectionParams connParams;
|
||||
connParams.domainId = 1;
|
||||
connParams.partitionId = 1;
|
||||
std::shared_ptr<SituationReplay::MainHandlerSqlite> srpMainHandler(new SituationReplay::MainHandlerSqlite);
|
||||
if (!srpMainHandler->initDds(connParams))
|
||||
return 1;
|
||||
// TODO: fixme or trash me
|
||||
SituationReplay::ReplayInformation ri;
|
||||
ri.databaseFilePath = QStringLiteral("dump.sqlite");
|
||||
ri.replayConfigPath = QStringLiteral("dump.json");
|
||||
if (!srpMainHandler->initDb(ri, {}, {}))
|
||||
return 2;
|
||||
|
||||
std::shared_ptr<DDSConnector::DdsConnector> ddsConn = srpMainHandler->ddsReplay();
|
||||
THP::SitMapPluginProvider *pp = new THP::SitMapPluginProvider;
|
||||
pp->init(ddsConn);
|
||||
|
||||
SituationMap::SituationMapInit *smi = new SituationMap::SituationMapInit(nullptr);
|
||||
smi->initPluginProvider(pp);
|
||||
|
||||
QPointer<SituationMap::MovementTrackManager> movementTrackMgr =
|
||||
QPointer<SituationMap::MovementTrackManager>(new SituationMap::MovementTrackManager(smi));
|
||||
|
||||
smi->initAdapter(movementTrackMgr, false);
|
||||
smi->initMap(true, SituationMap::Mode::Mode_2D);
|
||||
|
||||
SituationReplay::MainWindow *mw = new SituationReplay::MainWindow(smi, srpMainHandler->handlerSrp());
|
||||
mw->show();
|
||||
|
||||
int ret = app.exec();
|
||||
|
||||
delete mw;
|
||||
delete smi;
|
||||
delete pp;
|
||||
ddsConn.reset();
|
||||
return ret;
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* MainWindow for SitMapReplayTest
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#include "srp_main_window.h"
|
||||
#include "ui_srp_main_window.h"
|
||||
#include <SituationMap/situation_map_init.h>
|
||||
#include <SituationReplay/handler_situation_replay_sqlite.h>
|
||||
|
||||
namespace SituationReplay
|
||||
{
|
||||
MainWindow::MainWindow(SituationMap::SituationMapInit *sitMap,
|
||||
const std::shared_ptr<HandlerSituationReplaySqlite> &srpHandler,
|
||||
QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, m_srpHandler(srpHandler)
|
||||
, m_ui(new Ui::SrpMainWindow)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setCentralWidget(sitMap->getWidget());
|
||||
connect(m_ui->actionStart_Replay, &QAction::triggered, this, &MainWindow::onStartReplay);
|
||||
connect(m_ui->actionStop_Replay, &QAction::triggered, this, &MainWindow::onStopReplay);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void MainWindow::onStartReplay()
|
||||
{
|
||||
const qint64 begin = (time(nullptr) - 60 * 60 * 30) * 1000;
|
||||
const qint64 end = 0;
|
||||
const double pace = 1;
|
||||
m_srpHandler->onStartReplayRequest(begin, end, pace);
|
||||
}
|
||||
|
||||
void MainWindow::onStopReplay()
|
||||
{
|
||||
m_srpHandler->onStopReplayRequest();
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* MainWindow for SitMapReplayTest
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <memory>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class SrpMainWindow;
|
||||
}
|
||||
namespace SituationMap
|
||||
{
|
||||
class SituationMapInit;
|
||||
}
|
||||
namespace SituationReplay
|
||||
{
|
||||
class HandlerSituationReplaySqlite;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainWindow(SituationMap::SituationMapInit *sitMap,
|
||||
const std::shared_ptr<HandlerSituationReplaySqlite> &srpHandler,
|
||||
QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
protected slots:
|
||||
void onStartReplay();
|
||||
void onStopReplay();
|
||||
private:
|
||||
std::shared_ptr<HandlerSituationReplaySqlite> m_srpHandler;
|
||||
Ui::SrpMainWindow *m_ui;
|
||||
};
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SrpMainWindow</class>
|
||||
<widget class="QMainWindow" name="SrpMainWindow">
|
||||
<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"/>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
<property name="title">
|
||||
<string>Fi&le</string>
|
||||
</property>
|
||||
<addaction name="actionStart_Replay"/>
|
||||
<addaction name="actionStop_Replay"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="actionStart_Replay">
|
||||
<property name="text">
|
||||
<string>Start Replay</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionStop_Replay">
|
||||
<property name="text">
|
||||
<string>Stop Replay</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
IF(WIN32)
|
||||
# static msvc runtime
|
||||
FOREACH(flag_var
|
||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
IF(${flag_var} MATCHES "/MD")
|
||||
STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
SET(THP_ICO "${CMAKE_SOURCE_DIR}/Lts/Common/LtsWidgets/resources/rde_icon_256.ico")
|
||||
CONFIGURE_FILE(thp_starter.rc.cmake ${CMAKE_CURRENT_BINARY_DIR}/thp_starter.rc)
|
||||
|
||||
NGL_ADD_EXECUTABLE(WS thp_starter WIN32 thp_starter.cpp ${CMAKE_CURRENT_BINARY_DIR}/thp_starter.rc)
|
||||
NGL_TARGET_LINK_LIBRARIES(thp_starter user32.lib opengl32.lib gdi32.lib)
|
||||
NGL_INSTALL_TARGET(thp_starter)
|
||||
ENDIF(WIN32)
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Small wrapper to automatically start thp_viewer
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <gl/gl.h>
|
||||
#include <gl/glu.h>
|
||||
|
||||
static void* getGLExtensionFuncPtr(const char *funcName, const char *fallbackFuncName)
|
||||
{
|
||||
void* ptr = wglGetProcAddress(funcName);
|
||||
if (ptr)
|
||||
return ptr;
|
||||
return wglGetProcAddress(fallbackFuncName);
|
||||
}
|
||||
|
||||
static int checkOpenGL(HWND hWnd)
|
||||
{
|
||||
HDC hDC = GetDC( hWnd );
|
||||
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
ZeroMemory( &pfd, sizeof( pfd ) );
|
||||
pfd.nSize = sizeof( pfd );
|
||||
pfd.nVersion = 1;
|
||||
pfd.dwFlags = PFD_DRAW_TO_WINDOW |
|
||||
PFD_SUPPORT_OPENGL |
|
||||
PFD_DOUBLEBUFFER |
|
||||
PFD_SWAP_EXCHANGE;
|
||||
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||
pfd.cColorBits = 32;
|
||||
pfd.cRedBits = 8;
|
||||
pfd.cGreenBits = 8;
|
||||
pfd.cBlueBits = 8;
|
||||
pfd.cAlphaBits = 8;
|
||||
pfd.cDepthBits = 0;
|
||||
pfd.iLayerType = PFD_MAIN_PLANE;
|
||||
int iFormat = ChoosePixelFormat( hDC, &pfd );
|
||||
if( !SetPixelFormat( hDC, iFormat, &pfd ) ) {
|
||||
DWORD dw = GetLastError();
|
||||
int ret = MessageBox(NULL,
|
||||
L"Your system does not support some mandatory OpenGL Functions.\nThe THP-Viewer may not display all things correct!\nDo you really want to start the THP-viewer?",
|
||||
L"THP-Viewer startup",
|
||||
MB_ICONWARNING|MB_YESNO);
|
||||
if(ret == IDNO) {
|
||||
ReleaseDC( hWnd, hDC );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
HGLRC hRC = wglCreateContext( hDC );
|
||||
|
||||
DWORD dw = wglMakeCurrent( hDC, hRC );
|
||||
void *_glCompressedTexImage2D = getGLExtensionFuncPtr( "glCompressedTexImage2D", "glCompressedTexImage2DARB" );
|
||||
if(!_glCompressedTexImage2D) {
|
||||
int ret = MessageBox(NULL,
|
||||
L"Your system does not support the mandatory OpenGL Function glCompressedTexImage2D.\nThe THP-Viewer may not display all things correct!\nDo you really want to start the THP-viewer?",
|
||||
L"THP-Viewer startup",
|
||||
MB_ICONWARNING|MB_YESNO);
|
||||
if(ret == IDNO) {
|
||||
wglDeleteContext( hRC );
|
||||
ReleaseDC( hWnd, hDC );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
wglDeleteContext( hRC );
|
||||
ReleaseDC( hWnd, hDC );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int startThpViewer(HINSTANCE hInstance)
|
||||
{
|
||||
TCHAR fn[MAX_PATH*10];
|
||||
DWORD len = GetModuleFileName(hInstance, fn, sizeof(fn));
|
||||
|
||||
for(int i = len - 1; i >= 0; --i) {
|
||||
if(fn[i] == '\\')
|
||||
break;
|
||||
fn[i] = '\0';
|
||||
}
|
||||
wcscat(fn, L"thp\\thp_viewer.exe");
|
||||
|
||||
STARTUPINFO si; ZeroMemory(&si, sizeof(si));
|
||||
PROCESS_INFORMATION pi; ZeroMemory(&pi, sizeof(pi));
|
||||
si.cb = sizeof(si);
|
||||
|
||||
DWORD ret = CreateProcess(fn,
|
||||
NULL, // lpCommandLine
|
||||
NULL, // lpProcessAttributes
|
||||
NULL, // lpThreadAttributes
|
||||
NULL, // bInheritHandles
|
||||
0, // dwCreationFlags
|
||||
NULL, // lpEnvironment
|
||||
NULL, // lpCurrentDirectory
|
||||
&si, // lpStartupInfo
|
||||
&pi); // lpProcessInformation
|
||||
|
||||
if(ret == 0) {
|
||||
MessageBox(NULL,
|
||||
L"Error starting the THP-Viewer!",
|
||||
L"THP-Viewer startup",
|
||||
MB_ICONWARNING|MB_OK);
|
||||
return 1;
|
||||
}
|
||||
// Wait until child process exits.
|
||||
WaitForSingleObject( pi.hProcess, INFINITE );
|
||||
|
||||
// Close process and thread handles.
|
||||
CloseHandle( pi.hProcess );
|
||||
CloseHandle( pi.hThread );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
return DefWindowProc( hWnd, message, wParam, lParam );
|
||||
}
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
WNDCLASS wc;
|
||||
ZeroMemory( &wc, sizeof(wc) );
|
||||
// register window class
|
||||
wc.style = CS_OWNDC;
|
||||
wc.lpfnWndProc = WndProc;
|
||||
wc.hInstance = hInstance;
|
||||
wc.lpszClassName = L"THP_Viewer_startup";
|
||||
RegisterClass( &wc );
|
||||
|
||||
// create main window
|
||||
HWND hWnd = CreateWindow(L"THP_Viewer_startup",
|
||||
L"THP-Viewer startup",
|
||||
WS_CAPTION | WS_POPUPWINDOW,
|
||||
0, 0, 256, 256,
|
||||
NULL, NULL, hInstance, NULL );
|
||||
|
||||
int iRet = checkOpenGL(hWnd);
|
||||
if(iRet != 0)
|
||||
return iRet;
|
||||
return startThpViewer(hInstance);
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
IDI_ICON1 ICON DISCARDABLE "@THP_ICO@"
|
||||
@@ -0,0 +1,6 @@
|
||||
[autorun]
|
||||
OPEN=thp\bin\thp_viewer.exe
|
||||
ICON=thp\bin\thp_viewer.exe,0
|
||||
SHELL=readit
|
||||
SHELL\readit="THP-Viewer starten"
|
||||
SHELL\readit\command=thp\bin\thp_viewer.exe
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
log4j.reset=true
|
||||
log4j.rootLogger=WARN, file
|
||||
|
||||
#log4j.logger.GDW=WARN
|
||||
#log4j.logger.GDW_CTC=WARN
|
||||
#log4j.logger.KALA=WARN
|
||||
#
|
||||
# THP
|
||||
#
|
||||
#log4j.logger.THP=WARN
|
||||
#log4j.logger.THP.AudioVideoWidget=WARN
|
||||
#log4j.logger.THP.PlanFilter=WARN
|
||||
#log4j.logger.THP.SymbolLoaderThread=WARN
|
||||
#log4j.logger.THP.SHMFileHandler=WARN
|
||||
|
||||
# Appender
|
||||
############
|
||||
log4j.appender.file=Lts::RollingFileAppender
|
||||
log4j.appender.file.MaxFileSize=1MB
|
||||
log4j.appender.file.MaxBackupIndex=9
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=%d %-5p %c |#| %m (%.50F:%L) %n
|
||||
|
||||
# Appnd_Console
|
||||
###########################################################
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d %-5p %c |#| %m (%.50F:%L) %n
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Main entry for thp viewer
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#include <nglapplication/nglsingleapplication.h>
|
||||
#include <QUrl>
|
||||
#include <QDir>
|
||||
#include <QMessageBox>
|
||||
#include <QNetworkProxy>
|
||||
#include <QSplashScreen>
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
|
||||
#include "thp_viewer.h"
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <ngltranslator/ngltranslator.h>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
||||
{
|
||||
public:
|
||||
CmdLineParser()
|
||||
: LtsCommandLineParser(ProvideCommandLineParameterOptions::None)
|
||||
{
|
||||
addOption({{QStringLiteral("l"), QStringLiteral("lang")},
|
||||
QStringLiteral("Language iso code to use (de_DE, en_GB, en_US)"),
|
||||
QStringLiteral("<locale iso code>")
|
||||
});
|
||||
addOption({{QStringLiteral("t"), QStringLiteral("alwaysontop")},
|
||||
QStringLiteral("Set as always on top window")
|
||||
});
|
||||
}
|
||||
bool useAsAlwaysOnTop() const
|
||||
{
|
||||
return isSet(QStringLiteral("t"));
|
||||
}
|
||||
QString langIsoCode() const { return value(QStringLiteral("l")); }
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QNetworkProxy::setApplicationProxy(QNetworkProxy());
|
||||
|
||||
NGLSingleApplication app(argc, argv);
|
||||
app.createLogger("THP", "log4cxx_thp_viewer.props");
|
||||
app.setOrganizationName(QStringLiteral("RME"));
|
||||
app.setApplicationName(QStringLiteral("thp_viewer"));
|
||||
app.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
|
||||
QDir::setSearchPaths(QLatin1String("icon"), QStringList(QLatin1String(":/style/")));
|
||||
Q_INIT_RESOURCE(rme_light_style);
|
||||
|
||||
// Parse Options
|
||||
CmdLineParser options;
|
||||
if (!options.init())
|
||||
return -1;
|
||||
|
||||
// Set Translation
|
||||
QString langIsoCode = options.langIsoCode();
|
||||
if (langIsoCode.isEmpty())
|
||||
langIsoCode = QLocale::system().name();
|
||||
NGL::setTranslationLocale(langIsoCode.toLatin1());
|
||||
|
||||
//check for optional alyways on top flag
|
||||
bool alwaysOnTop = options.useAsAlwaysOnTop();
|
||||
|
||||
QString index;
|
||||
const QStringList args = options.positionalArguments();
|
||||
|
||||
// QString searchDir = QCoreApplication::applicationDirPath();
|
||||
QString searchDir(QDir::currentPath());
|
||||
|
||||
if (args.count() == 1)
|
||||
{
|
||||
QFileInfo fi(args.first());
|
||||
if (fi.isDir())
|
||||
searchDir = fi.absolutePath();
|
||||
else
|
||||
index = fi.absoluteFilePath();
|
||||
}
|
||||
|
||||
if (index.isEmpty())
|
||||
{
|
||||
const auto indexFiles = { QStringLiteral("index_%1.html").arg(langIsoCode),
|
||||
QStringLiteral("index.html") };
|
||||
for (const QString &indexFile : indexFiles)
|
||||
{
|
||||
QDir d(searchDir);
|
||||
index = d.absoluteFilePath(indexFile);
|
||||
while (!d.exists(index))
|
||||
{
|
||||
if (!d.cdUp())
|
||||
break;
|
||||
index = d.absoluteFilePath(indexFile);
|
||||
}
|
||||
if (d.exists(index))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QFileInfo fi(index);
|
||||
QString basePath = fi.path() + QLatin1Char('/');
|
||||
if (!fi.exists() || !fi.isFile())
|
||||
{
|
||||
fprintf(stderr, "%s <path_to_html> basePath=%s\n", argv[0], basePath.toStdString().c_str());
|
||||
QMessageBox::critical(nullptr,
|
||||
QObject::tr("File missing"),
|
||||
QObject::tr("Could not find a valid index.html - aborting"));
|
||||
return -1;
|
||||
}
|
||||
index = fi.absoluteFilePath();
|
||||
|
||||
if (app.sendMessage(index))
|
||||
return 0;
|
||||
|
||||
int ret = 1;
|
||||
{
|
||||
QString splashfile = basePath;
|
||||
static const auto extension = {QStringLiteral("gif"),
|
||||
QStringLiteral("jpg"),
|
||||
QStringLiteral("png")};
|
||||
for (const auto &ext : extension)
|
||||
{
|
||||
const QString fn = splashfile + QStringLiteral("/wappen.") + ext;
|
||||
if (!QFile::exists(fn))
|
||||
continue;
|
||||
splashfile = fn;
|
||||
break;
|
||||
}
|
||||
|
||||
const QPixmap splashPixmap(splashfile);
|
||||
QSplashScreen splash((splashPixmap));
|
||||
if (!splashPixmap.isNull())
|
||||
splash.show();
|
||||
|
||||
#ifdef BUILD_STATIC_LIBRARIES
|
||||
Q_INIT_RESOURCE(libsymbol);
|
||||
Q_INIT_RESOURCE(nglresources);
|
||||
#endif
|
||||
|
||||
NGL::ThpViewer view(QUrl::fromLocalFile(index));
|
||||
if (alwaysOnTop)
|
||||
{
|
||||
view.setWindowFlag(Qt::WindowStaysOnTopHint, true);
|
||||
view.setWindowFlag(Qt::WindowMinimizeButtonHint, false);
|
||||
}
|
||||
|
||||
if (!view.init())
|
||||
return ret;
|
||||
view.center();
|
||||
|
||||
QObject::connect(&app, &NGLSingleApplication::messageReceived,
|
||||
&view, &NGL::ThpViewer::onNewThp);
|
||||
view.show();
|
||||
splash.finish(&view);
|
||||
|
||||
ret = app.exec();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Plugin Provider for standalone SRP / THP
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#include "thp_plugin_provider.h"
|
||||
#include <AreaEffectSimulation/aes_dtc.h>
|
||||
#include <AdvancedSymbology/Data/asb_foreign_interface_impl.h>
|
||||
#include <Buildings/bld_dtc.h>
|
||||
#include <CentralEffectSimulation/ces_dtc.h>
|
||||
#include <GuezIedManagement/gim_dtc.h>
|
||||
#include <InfrastructureManagement/ism_dtc.h>
|
||||
#include <InfrastructureManagement/Data/ism_foreign_data_plugin.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <ProjectDataManagement/pdm_dtc.h>
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
|
||||
#include "thp_situation_filter_interface_impl.h"
|
||||
|
||||
namespace THP
|
||||
{
|
||||
|
||||
QString SitMapPluginProvider::toString() const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool SitMapPluginProvider::init(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector)
|
||||
{
|
||||
m_ddsConnector = ddsConnector;
|
||||
|
||||
m_buildingPluginProvider = std::make_shared<BuildingPluginProvider>();
|
||||
|
||||
m_aesDtc = AreaEffectSimulation::Interface::Dtc::create(ddsConnector);
|
||||
m_aesDtc->enableAll();
|
||||
m_bldDtc = Buildings::Interface::Dtc::create(ddsConnector);
|
||||
m_bldDtc->enableAll();
|
||||
m_cesDtc = CentralEffectSimulation::Interface::Dtc::create(ddsConnector);
|
||||
m_cesDtc->enableAll();
|
||||
m_gimDtc = GuezIedManagement::Interface::Dtc::create(ddsConnector);
|
||||
m_gimDtc->enableAll();
|
||||
// m_ismDtc = InfrastructureManagement::Interface::Dtc::create(ddsConnector);
|
||||
// m_ismDtc->enableAll();
|
||||
// m_ismForeign = std::make_shared<InfrastructureManagement::ForeignInterfaceImpl>(m_ismDtc);
|
||||
m_ppmDtc = ParticipantManagement::Interface::Dtc::create(ddsConnector);
|
||||
m_ppmDtc->enableAll();
|
||||
m_pdmDtc = ProjectDataManagement::Interface::Dtc::create(ddsConnector);
|
||||
m_pdmDtc->enableAll();
|
||||
|
||||
// needs m_ppmDtc
|
||||
m_fltParticipantIfc = std::make_shared<FilterManagement::ThpFilterInterfaceImpl>(m_ppmDtc);
|
||||
m_fltAesIfc = std::make_shared<FilterManagement::ThpFilterInterfaceImpl>(m_ppmDtc);
|
||||
m_fltBuildingComponentIfc = std::make_shared<FilterManagement::ThpFilterInterfaceImpl>(m_ppmDtc);
|
||||
// m_fltParticipantIfc = m_fltAesIfc; // Not sure, lets try
|
||||
|
||||
return m_buildingPluginProvider->init(ddsConnector, this);
|
||||
}
|
||||
|
||||
|
||||
bool BuildingPluginProvider::init(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector,
|
||||
SitMapPluginProvider *smPluginProvider)
|
||||
{
|
||||
Q_ASSERT(smPluginProvider);
|
||||
m_smPluginProvider = smPluginProvider;
|
||||
connect(m_smPluginProvider, &SitMapPluginProvider::partitionTimeChanged,
|
||||
this, &BuildingPluginProvider::partitionTimeChanged);
|
||||
|
||||
m_connectionParams.domainId = ddsConnector->getDomainId();
|
||||
m_connectionParams.partitionId = ddsConnector->getPartitionId();
|
||||
m_connectionParams.exerciseId = ddsConnector->getPartitionId();
|
||||
m_connectionParams.tcpConnectionUrl = ddsConnector->getTcpConnectionUrl();
|
||||
|
||||
m_asbIfc = std::make_shared<AdvancedSymbology::ForeignInterfaceImpl>(m_smPluginProvider->ppmDtc(),
|
||||
m_smPluginProvider->aesDtc(),
|
||||
m_smPluginProvider->gimDtc());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<InfrastructureManagement::ForeignDataInterface> SitMapPluginProvider::ismDataIfc() const
|
||||
{
|
||||
if (!m_ismForeign)
|
||||
m_ismForeign = std::make_shared<InfrastructureManagement::ForeignInterfaceImpl>(ismDtc());
|
||||
|
||||
return m_ismForeign;
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> SitMapPluginProvider::ismDtc() const
|
||||
{
|
||||
if (!m_ismDtc)
|
||||
{
|
||||
m_ismDtc = InfrastructureManagement::Interface::Dtc::create(m_ddsConnector);
|
||||
m_ismDtc->enableAll();
|
||||
}
|
||||
|
||||
return m_ismDtc;
|
||||
}
|
||||
|
||||
} // namespace THP
|
||||
@@ -0,0 +1,149 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Plugin Provider for standalone SRP / THP
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <SituationMap/AdapterDds/plugin_provider.h>
|
||||
#include <BuildingViewer/Common/bdv_plugin_provider.h>
|
||||
#include <AlarmManagement/alm_info_gui_plugin_interface.h>
|
||||
#include <LtsAppDescriptor/lts_app_descriptor.h>
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
#include <QVector>
|
||||
|
||||
namespace DDSConnector
|
||||
{
|
||||
class DdsConnector;
|
||||
}
|
||||
namespace THP
|
||||
{
|
||||
class BuildingPluginProvider;
|
||||
class SitMapPluginProvider final : public SituationMap::PluginProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using SituationMap::PluginProvider::PluginProvider;
|
||||
|
||||
QString toString() const override;
|
||||
|
||||
bool init(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector);
|
||||
|
||||
void emitPartitionTimeChanged(qint64 curTime) { m_curPartitionTime = curTime; emit partitionTimeChanged(curTime); }
|
||||
|
||||
void setExerciseId(int exerciseId) { m_exerciseId = exerciseId; }
|
||||
int exerciseId() const override { return m_exerciseId; }
|
||||
bool isSessionValid() const override { return true; }
|
||||
qint64 partitionTime() const override { return m_curPartitionTime; }
|
||||
int partitionId() const override { return -1; }
|
||||
int operatorId() const override { return 42; }
|
||||
LtsAppDescriptor::App appId() const override { return LtsAppDescriptor::App::ThpSituationReplay; }
|
||||
|
||||
bool isVisibleParty(int) const override { return true; }
|
||||
QString workspaceId() const override { return {}; }
|
||||
bool isReplayPartition() const override { return false; }
|
||||
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> aesDtc() const override { return m_aesDtc; }
|
||||
std::shared_ptr<AreaEffectSimulation::ForeignInfoGuiInterface> aesInfoIfc() const override { return {}; }
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> almDtc() const override { return {}; }
|
||||
std::shared_ptr<AlarmManagement::Interface::Ftc> almFtc() const override { return {}; }
|
||||
std::shared_ptr<AlarmManagement::ForeignInfoGuiInterface> almInfoIfc() const override { return {}; }
|
||||
std::shared_ptr<AssetManagement::Interface::Dtc> asmDtc() const override { return {}; }
|
||||
std::shared_ptr<AssetManagement::Interface::Ftc> asmFtc() const override { return {}; }
|
||||
std::shared_ptr<Buildings::Interface::Dtc> bldDtc() const override { return m_bldDtc; }
|
||||
std::shared_ptr<Buildings::Interface::Ftc> bldFtc() const override { return {}; }
|
||||
std::shared_ptr<Buildings::ForeignInfoGuiInterface> bldInfoIfc() const override { return {}; }
|
||||
std::shared_ptr<CentralEffectSimulation::Interface::Dtc> cesDtc() const override { return m_cesDtc; }
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> exmDtc() const override { return {}; }
|
||||
std::shared_ptr<ExerciseManagement::Interface::Ftc> exmFtc() const override { return {}; }
|
||||
std::shared_ptr<FilterManagement::Interface::Dtc> fltDtc() const override { return {}; }
|
||||
std::shared_ptr<FilterManagement::Interface::Ftc> fltFtc() const override { return {}; }
|
||||
std::shared_ptr<FilterManagement::ForeignFltParticipantGuiInterface> fltParticipantIfc() const override { return m_fltParticipantIfc; }
|
||||
std::shared_ptr<FilterManagement::ForeignAesGuiInterface> fltAesIfc() const override { return m_fltAesIfc; }
|
||||
std::shared_ptr<FilterManagement::ForeignFltBuildingComponentGuiInterface> fltBuildingComponentIfc() const override { return m_fltBuildingComponentIfc; }
|
||||
std::shared_ptr<GuezIedManagement::Interface::Dtc> gimDtc() const override { return m_gimDtc; }
|
||||
std::shared_ptr<GuezIedManagement::ForeignGuiInterface> gimIfc() const override { return {}; }
|
||||
std::shared_ptr<GuezNasat::Interface::Dtc> gnaDtc() const override { return {}; }
|
||||
std::shared_ptr<GuezNasat::ForeignGuiInterface> gnaIfc() const override { return {}; }
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc() const override;
|
||||
std::shared_ptr<InfrastructureManagement::ForeignDataInterface> ismDataIfc() const override;
|
||||
std::shared_ptr<InfrastructureManagement::ForeignResourceManagementGuiInterface> ismGuiIfc() const override { return {}; }
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> opmDtc() const override { return {}; }
|
||||
std::shared_ptr<OperatorManagement::Interface::Ftc> opmFtc() const override { return {}; }
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> ppmDtc() const override { return m_ppmDtc; }
|
||||
std::shared_ptr<ParticipantManagement::Interface::Ftc> ppmFtc() const override { return {}; }
|
||||
std::shared_ptr<ParticipantManagement::ForeignParticipantInfoGuiInterface> ppmParticipantInfoIfc() const override { return {}; }
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> pdmDtc() const override { return m_pdmDtc; }
|
||||
std::shared_ptr<SituationReplay::Interface::Dtc> srpDtc() const override { return m_srpDtc; }
|
||||
std::shared_ptr<OcSituationClient::ForeignParticipantInfoGuiInterface> ocParticipantInfoIfc() const override { return {}; }
|
||||
std::shared_ptr<ServiceMonitor::ForeignGuiInterface> smoServiceMonitorIfc() const override { return {}; }
|
||||
std::shared_ptr<TargetManagement::Interface::Dtc> tgtDtc() const override { return {}; }
|
||||
std::shared_ptr<ComponentMonitor::Interface::Dtc> cmoDtc() const override { return {}; }
|
||||
|
||||
// for BuildingPluginProvider
|
||||
BuildingPluginProvider *buildingPluginProvider() { return m_buildingPluginProvider.get(); }
|
||||
|
||||
private:
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
||||
std::shared_ptr<Buildings::Interface::Dtc> m_bldDtc;
|
||||
std::shared_ptr<CentralEffectSimulation::Interface::Dtc> m_cesDtc;
|
||||
std::shared_ptr<FilterManagement::ForeignFltParticipantGuiInterface> m_fltParticipantIfc;
|
||||
std::shared_ptr<FilterManagement::ForeignAesGuiInterface> m_fltAesIfc;
|
||||
std::shared_ptr<FilterManagement::ForeignFltBuildingComponentGuiInterface> m_fltBuildingComponentIfc;
|
||||
std::shared_ptr<GuezIedManagement::Interface::Dtc> m_gimDtc;
|
||||
mutable std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
mutable std::shared_ptr<InfrastructureManagement::ForeignDataInterface> m_ismForeign;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<SituationReplay::Interface::Dtc> m_srpDtc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
|
||||
qint64 m_curPartitionTime = 0;
|
||||
int m_exerciseId = 0;
|
||||
|
||||
std::shared_ptr<BuildingPluginProvider> m_buildingPluginProvider;
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
};
|
||||
|
||||
class BuildingPluginProvider final : public BuildingViewer::PluginProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using BuildingViewer::PluginProvider::PluginProvider;
|
||||
|
||||
BuildingPluginProvider() = default;
|
||||
|
||||
QString toString() const override { return m_smPluginProvider->toString(); }
|
||||
|
||||
bool init(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector,
|
||||
SitMapPluginProvider *smPluginProvider);
|
||||
|
||||
void emitPartitionTimeChanged(qint64 curTime) { m_smPluginProvider->emitPartitionTimeChanged(curTime); }
|
||||
|
||||
int exerciseId() const override { return m_smPluginProvider->exerciseId(); }
|
||||
qint64 partitionTime() const override { return m_smPluginProvider->partitionTime(); }
|
||||
bool isReplayPartition() const override { return false; }
|
||||
bool isVisibleParty(int partyId) const override { return m_smPluginProvider->isVisibleParty(partyId); }
|
||||
LtsSession::DdsConnectionParams connParams() const override { return m_connectionParams; }
|
||||
|
||||
std::shared_ptr<AdvancedSymbology::ForeignDataInterface> asbIfc() const override { return m_asbIfc; }
|
||||
std::shared_ptr<AudioVideoManagement::ForeignDataInterface> avmDataIfc() const override { return nullptr; } // optional
|
||||
std::shared_ptr<Buildings::Interface::Dtc> bldDtc() const override { return m_smPluginProvider->bldDtc(); }
|
||||
std::shared_ptr<Buildings::ForeignInfoGuiInterface> bldInfoIfc() const override { return m_smPluginProvider->bldInfoIfc(); } // optional
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc() const override { return m_smPluginProvider->ismDtc(); }
|
||||
std::shared_ptr<InfrastructureManagement::ForeignDataInterface> ismDataIfc() const override { return m_smPluginProvider->ismDataIfc(); }
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> aesDtc() const override { return m_smPluginProvider->aesDtc(); } // optional
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> ppmDtc() const override { return m_smPluginProvider->ppmDtc(); } // optional
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> pdmDtc() const override { return m_smPluginProvider->pdmDtc(); } // optional
|
||||
std::shared_ptr<SituationReplay::Interface::Dtc> srpDtc() const override { return m_smPluginProvider->srpDtc(); } // optional
|
||||
std::shared_ptr<ParticipantManagement::ForeignParticipantInfoGuiInterface> ppmParticipantInfoIfc() const override { return m_smPluginProvider->ppmParticipantInfoIfc(); } // optional
|
||||
|
||||
private:
|
||||
SitMapPluginProvider *m_smPluginProvider{nullptr};
|
||||
std::shared_ptr<AdvancedSymbology::ForeignDataInterface> m_asbIfc;
|
||||
LtsSession::DdsConnectionParams m_connectionParams;
|
||||
};
|
||||
}
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Simple implmentation of FilterHandling for THP
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#include "thp_situation_filter_interface_impl.h"
|
||||
#include <FilterManagement/Gui/Aes/Common/symbol_appearance_settings_impl.h>
|
||||
#include <FilterManagement/Gui/Aes/Common/aes_display_filter_impl.h>
|
||||
#include <FilterManagement/Gui/Aes/Common/building_cmpnt_settings_impl.h>
|
||||
|
||||
namespace FilterManagement
|
||||
{
|
||||
ThpFilterInterfaceImpl::ThpFilterInterfaceImpl(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &dtcPpm)
|
||||
: m_fltSymbols(std::make_shared<SymbolAppearanceSettingsImpl>(dtcPpm))
|
||||
, m_fltAes(std::make_shared<AesDisplayFilterImpl>())
|
||||
, m_fltBuildingComponentSettings(std::make_shared<BuildingComponentSettingsImpl>())
|
||||
{
|
||||
m_fltAes->setVisiblePartiesCheck([](int) -> bool { return true; });
|
||||
}
|
||||
|
||||
std::shared_ptr<SymbolAppearanceSettings> ThpFilterInterfaceImpl::symbolAppearanceForOperator(int operatorId, const QString &context)
|
||||
{
|
||||
Q_UNUSED(operatorId);
|
||||
Q_UNUSED(context);
|
||||
return m_fltSymbols;
|
||||
}
|
||||
|
||||
std::shared_ptr<AesDisplayFilter> ThpFilterInterfaceImpl::aesFilterForOperator(int operatorId, const QString &context)
|
||||
{
|
||||
Q_UNUSED(operatorId);
|
||||
Q_UNUSED(context);
|
||||
return m_fltAes;
|
||||
}
|
||||
|
||||
std::shared_ptr<BuildingComponentSettings> ThpFilterInterfaceImpl::buildingComponentSettingsForOperator(int operatorId, const QString &context)
|
||||
{
|
||||
Q_UNUSED(operatorId);
|
||||
Q_UNUSED(context);
|
||||
return m_fltBuildingComponentSettings;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Simple implmentation of FilterHandling for THP
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <FilterManagement/flt_participant_plugin_interface.h>
|
||||
#include <FilterManagement/flt_aes_plugin_interface.h>
|
||||
#include <FilterManagement/flt_building_cmpnt_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
|
||||
namespace FilterManagement
|
||||
{
|
||||
class ThpFilterInterfaceImpl : public ForeignFltParticipantGuiInterface,
|
||||
public ForeignAesGuiInterface,
|
||||
public ForeignFltBuildingComponentGuiInterface
|
||||
{
|
||||
public:
|
||||
explicit ThpFilterInterfaceImpl(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &dtcPpm);
|
||||
|
||||
// from Participant
|
||||
std::shared_ptr<SymbolAppearanceSettings> symbolAppearanceForOperator(int operatorId, const QString &context) override;
|
||||
|
||||
// from Aes
|
||||
std::shared_ptr<AesDisplayFilter> aesFilterForOperator(int operatorId, const QString &context) override;
|
||||
|
||||
// from BuildingComponent
|
||||
std::shared_ptr<BuildingComponentSettings> buildingComponentSettingsForOperator(int operatorId, const QString &context) override;
|
||||
|
||||
|
||||
private:
|
||||
std::shared_ptr<SymbolAppearanceSettings> m_fltSymbols;
|
||||
std::shared_ptr<AesDisplayFilter> m_fltAes;
|
||||
std::shared_ptr<BuildingComponentSettings> m_fltBuildingComponentSettings;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,686 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Main thp viewer widget
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#include "thp_viewer.h"
|
||||
#include "ui_thp_viewer.h"
|
||||
#include "thp_plugin_provider.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QKeyEvent>
|
||||
#include <QPrintDialog>
|
||||
#include <QPrinter>
|
||||
#include <QPainter>
|
||||
#include <QMessageBox>
|
||||
#include <QTextDocument>
|
||||
#include <QScreen>
|
||||
#include <QDesktopServices>
|
||||
#include <QDomElement>
|
||||
#include <QDomDocument>
|
||||
#include <QUrl>
|
||||
#include <QRect>
|
||||
#include <QSize>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QSettings>
|
||||
#include <QInputDialog>
|
||||
#include <QDir>
|
||||
|
||||
#include <ngltranslator/ngltranslator.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
/*
|
||||
* ThpViewer base class
|
||||
*/
|
||||
ThpViewer::ThpViewer(const QUrl &url, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::thpViewer)
|
||||
, m_scaleFactor(1.0)
|
||||
, m_homeLink(url)
|
||||
, m_homePath(QFileInfo(m_homeLink.toLocalFile()).absolutePath())
|
||||
, m_trainingName(QString())
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("ThpViewer"))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->audioWidget->setAV(true);
|
||||
ui->videoWidget->setAV(false);
|
||||
|
||||
/*
|
||||
TODO
|
||||
if (!conffile.isEmpty())
|
||||
{
|
||||
QSettings thpsettings(conffile, QSettings::IniFormat, this);
|
||||
|
||||
// needed?
|
||||
const char timeZone = thpsettings.value(QStringLiteral("Time/Timezone"), QStringLiteral("Z")).toString().at(0).toLatin1();
|
||||
DTG::setTimezone(timeZone, true);
|
||||
}
|
||||
*/
|
||||
|
||||
QString basedir(url.toLocalFile());
|
||||
basedir = basedir.left(basedir.lastIndexOf(QLatin1Char('/')));
|
||||
|
||||
DEBUG_LOG(m_logger) << "url: " << url.toString() << " basedir: " << basedir;
|
||||
|
||||
QFont f = ui->mainLabel->font();
|
||||
f.setBold(true);
|
||||
f.setPointSizeF(f.pointSizeF() * 1.2);
|
||||
ui->mainLabel->setFont(f);
|
||||
|
||||
connect(ui->closeButton, &QToolButton::clicked, this, &ThpViewer::close);
|
||||
connect(ui->backButton, &QToolButton::clicked, this, &ThpViewer::onBack);
|
||||
connect(ui->homeButton, &QToolButton::clicked, this, &ThpViewer::onHome);
|
||||
connect(ui->helpButton, &QToolButton::clicked, this, &ThpViewer::onHelp);
|
||||
connect(ui->printButton, &QToolButton::clicked, this, &ThpViewer::onPrint);
|
||||
connect(ui->fullScreenButton, &QToolButton::clicked, this, &ThpViewer::onFullScreen);
|
||||
connect(ui->htmlWidget, &THP::HtmlWidget::linkClicked, this, &ThpViewer::onLinkClicked);
|
||||
connect(ui->htmlWidget, &THP::HtmlWidget::urlChanged, this, &ThpViewer::onUrlChanged);
|
||||
connect(ui->htmlWidget, &THP::HtmlWidget::titleChanged, this, &ThpViewer::onTitleChanged);
|
||||
|
||||
ui->backButton->setEnabled(false);
|
||||
ui->helpButton->setVisible(false); // Help disabled for now
|
||||
#ifndef Q_WS_WIN
|
||||
setWindowIcon(QIcon(QStringLiteral(":icons/16x16/rde.ico")));
|
||||
#endif
|
||||
setWindowTitle(tr("Combat Training Center"));
|
||||
}
|
||||
|
||||
ThpViewer::~ThpViewer()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
bool ThpViewer::init()
|
||||
{
|
||||
QFile file(m_homePath + QStringLiteral("/data.json"));
|
||||
int exerciseId = 0;
|
||||
if (file.exists() && file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
const auto obj = QJsonDocument::fromJson(file.readAll()).object();
|
||||
exerciseId = obj.value(QLatin1String("exerciseId")).toInt();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
QFile file2(m_homePath + QStringLiteral("/../data.json"));
|
||||
if (file2.exists() && file2.open(QIODevice::ReadOnly))
|
||||
{
|
||||
const auto obj = QJsonDocument::fromJson(file2.readAll()).object();
|
||||
exerciseId = obj.value(QLatin1String("exerciseId")).toInt();
|
||||
}
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Use EXERCISE" << exerciseId;
|
||||
|
||||
if (!ui->situationWidget->init(m_homePath, exerciseId))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not init situation widget - abort";
|
||||
return false;
|
||||
}
|
||||
if (!ui->buildingWidget->init(ui->situationWidget->replayHandler(),
|
||||
ui->situationWidget->pluginProvider()->buildingPluginProvider(),
|
||||
m_homePath))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not init situation widget - abort";
|
||||
return false;
|
||||
}
|
||||
|
||||
onZoomChanged();
|
||||
onLinkClicked(m_homeLink);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ThpViewer::center()
|
||||
{
|
||||
QRect rect = QGuiApplication::primaryScreen()->availableGeometry();
|
||||
// 80 %
|
||||
int width = rect.width() * 4 / 5;
|
||||
int height = rect.height() * 4 / 5;
|
||||
int x = rect.width() / 2 - width / 2;
|
||||
int y = rect.height() / 2 - height / 2;
|
||||
resize(width, height);
|
||||
move(x, y);
|
||||
}
|
||||
|
||||
void ThpViewer::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
// explicit delete those two widgets here, otherwise we may get in trouble
|
||||
// on windows when the app is closed with the 'X' button from the window frame
|
||||
delete ui->buildingWidget;
|
||||
ui->buildingWidget = nullptr;
|
||||
delete ui->situationWidget;
|
||||
ui->situationWidget = nullptr;
|
||||
QWidget::closeEvent(event);
|
||||
}
|
||||
|
||||
void ThpViewer::onNewThp(const QString &index)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onNewThp: " << index;
|
||||
|
||||
if (index.isEmpty())
|
||||
return;
|
||||
m_homeLink = QUrl::fromLocalFile(index);
|
||||
m_homePath = QFileInfo(m_homeLink.toLocalFile()).absolutePath();
|
||||
DEBUG_LOG(m_logger) << "home: " << m_homeLink.toString();
|
||||
onLinkClicked(m_homeLink);
|
||||
ui->backButton->setEnabled(false);
|
||||
this->raise();
|
||||
}
|
||||
|
||||
void ThpViewer::onTitleChanged(const QString &title)
|
||||
{
|
||||
if (title.endsWith(QLatin1String("html")) ||
|
||||
title.endsWith(QLatin1String("html#!/")))
|
||||
return;
|
||||
if (m_trainingName.isEmpty())
|
||||
m_trainingName = title;
|
||||
ui->mainLabel->setText(m_trainingName == title ? m_trainingName : QStringLiteral("%1 - %2").arg(m_trainingName, title));
|
||||
}
|
||||
|
||||
void ThpViewer::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
switch (e->key())
|
||||
{
|
||||
case Qt::Key_Backspace:
|
||||
onBack();
|
||||
break;
|
||||
case Qt::Key_Plus:
|
||||
if (ui->stackedWidget->isVisible() && ui->stackedWidget->currentWidget() == ui->situationWidget)
|
||||
return;
|
||||
if (m_scaleFactor < 10)
|
||||
{
|
||||
m_scaleFactor *= 1.5;
|
||||
onZoomChanged();
|
||||
}
|
||||
break;
|
||||
case Qt::Key_M:
|
||||
{
|
||||
if (QApplication::queryKeyboardModifiers() == Qt::ControlModifier)
|
||||
onLinkClicked(QUrl::fromLocalFile(QDir::currentPath() + QStringLiteral("/") + QInputDialog::getText(this, {}, QStringLiteral("href_local"))));
|
||||
break;
|
||||
}
|
||||
case Qt::Key_Minus:
|
||||
if (ui->stackedWidget->isVisible() && ui->stackedWidget->currentWidget() == ui->situationWidget)
|
||||
return;
|
||||
if (m_scaleFactor > 0.05)
|
||||
{
|
||||
m_scaleFactor /= 1.5;
|
||||
onZoomChanged();
|
||||
}
|
||||
break;
|
||||
case Qt::Key_F1:
|
||||
onHelp();
|
||||
break;
|
||||
case Qt::Key_Escape:
|
||||
if (isFullScreen())
|
||||
onFullScreen();
|
||||
break;
|
||||
default:
|
||||
QWidget::keyPressEvent(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ThpViewer::onHelp()
|
||||
{
|
||||
QFileInfo f(QStringLiteral("%1/../DATA/help/%2/help.html").arg(QCoreApplication::applicationDirPath(), QString::fromLatin1(NGL::translationLocale())));
|
||||
if (f.exists())
|
||||
onLinkClicked(QUrl::fromLocalFile(f.absoluteFilePath())); // TODO Pfad anpassen!
|
||||
else
|
||||
{
|
||||
f.setFile(qApp->applicationDirPath() + QStringLiteral("/../DATA/help/en_US/help.html")); // TODO Pfad anpassen!
|
||||
if (f.exists())
|
||||
onLinkClicked(QUrl::fromLocalFile(f.absoluteFilePath()));
|
||||
}
|
||||
}
|
||||
|
||||
void ThpViewer::onZoomChanged()
|
||||
{
|
||||
ui->pdfWidget->setZoomFactor(m_scaleFactor);
|
||||
ui->htmlWidget->setZoomFactor(m_scaleFactor);
|
||||
|
||||
// double zoom = ( int ) ( m_scaleFactor * 100. + 0.5 );
|
||||
// ui->statusbar->showMessage ( tr ( "zoom: %1 %" ).arg ( zoom ) );
|
||||
}
|
||||
|
||||
void ThpViewer::onLinkClicked(const QUrl &url)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "url: " << url.toString();
|
||||
|
||||
const QString path = url.path();
|
||||
const QString lpath = path.toLower();
|
||||
|
||||
const QStringRef ext = lpath.splitRef(QLatin1Char('.')).last();
|
||||
const QStringRef ext2Chars = ext.left(2);
|
||||
|
||||
ui->audioWidget->stop();
|
||||
ui->videoWidget->stop();
|
||||
// Video-only
|
||||
if (lpath.endsWith(QLatin1String("video.pls")) ||
|
||||
ext == QLatin1String("mpg") ||
|
||||
ext == QLatin1String("avi") ||
|
||||
ext == QLatin1String("ogg"))
|
||||
{
|
||||
ui->videoWidget->play(url);
|
||||
|
||||
ui->stackedWidget->hide();
|
||||
ui->videoWidget->show();
|
||||
ui->audioWidget->hide();
|
||||
|
||||
ui->backButton->setEnabled(true);
|
||||
// Audio-only
|
||||
}
|
||||
else if (lpath.endsWith(QLatin1String("audio.pls")) ||
|
||||
ext == QLatin1String("mp3"))
|
||||
{
|
||||
ui->audioWidget->play(url);
|
||||
|
||||
// Ermitteln der Groesse des AudioWidgets
|
||||
QSize sizeAudio = ui->audioWidget->sizeHint();
|
||||
QSize sizeStack = ui->stackedWidget->sizeHint();
|
||||
sizeStack -= sizeAudio;
|
||||
QList<int> l;
|
||||
l << sizeStack.height() << sizeAudio.height();
|
||||
ui->splitter_1->setSizes(l);
|
||||
|
||||
ui->stackedWidget->show(); // hier können wir html mit anzeigen
|
||||
ui->videoWidget->hide();
|
||||
ui->audioWidget->show();
|
||||
|
||||
ui->backButton->setEnabled(true);
|
||||
// PDF-only
|
||||
}
|
||||
else if (ext == QLatin1String("pdf"))
|
||||
{
|
||||
if (ui->pdfWidget->showPDF(url))
|
||||
{
|
||||
|
||||
ui->stackedWidget->setCurrentWidget(ui->pdfWidget);
|
||||
ui->stackedWidget->show();
|
||||
ui->pdfWidget->resizePdfToWidth();
|
||||
ui->videoWidget->hide();
|
||||
ui->audioWidget->hide();
|
||||
|
||||
ui->backButton->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::warning(this,
|
||||
tr("Opening PDF file"),
|
||||
tr("Can not open PDF file %1 - missing or corrupt file!").arg(url.toString()));
|
||||
}
|
||||
}
|
||||
else if (lpath.endsWith(QLatin1String("sitmap.json"), Qt::CaseInsensitive))
|
||||
{
|
||||
|
||||
// 2D oder 3D ?
|
||||
{
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " lpath = '" << lpath << "'";
|
||||
// peek into <lpath>/sitreplay.json:
|
||||
|
||||
QFileInfo fi(path);
|
||||
const QString basePath = fi.absolutePath();
|
||||
const QString replayConfigFile = basePath + QDir::separator() + QStringLiteral("sitreplay.json"); // aka replayConfigPath
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " replayConfigFile = '" << replayConfigFile << "'";
|
||||
}
|
||||
|
||||
// Lage-only
|
||||
QString localFile = url.toLocalFile();
|
||||
QString basePath = localFile;
|
||||
int idx = basePath.lastIndexOf(QLatin1Char('/'));
|
||||
idx = basePath.lastIndexOf(QLatin1Char('/'), idx - 1);
|
||||
if (idx >= 0)
|
||||
basePath.chop(basePath.size() - idx - 1);
|
||||
|
||||
ui->situationWidget->showSituation(url.toLocalFile(),
|
||||
basePath);
|
||||
|
||||
ui->stackedWidget->setCurrentWidget(ui->situationWidget);
|
||||
ui->stackedWidget->show();
|
||||
ui->videoWidget->hide();
|
||||
ui->audioWidget->hide();
|
||||
|
||||
ui->backButton->setEnabled(true);
|
||||
}
|
||||
else if (lpath.endsWith(QLatin1String("buildingViewer.json"), Qt::CaseInsensitive))
|
||||
{
|
||||
// BuildingViewer-only
|
||||
QString localFile = url.toLocalFile();
|
||||
QString basePath = localFile;
|
||||
int idx = basePath.lastIndexOf(QLatin1Char('/'));
|
||||
idx = basePath.lastIndexOf(QLatin1Char('/'), idx - 1);
|
||||
if (idx >= 0)
|
||||
basePath.chop(basePath.size() - idx - 1);
|
||||
ui->buildingWidget->showSituation(url.toLocalFile(),
|
||||
basePath);
|
||||
|
||||
ui->stackedWidget->setCurrentWidget(ui->buildingWidget);
|
||||
ui->stackedWidget->show();
|
||||
ui->videoWidget->hide();
|
||||
ui->audioWidget->hide();
|
||||
|
||||
ui->backButton->setEnabled(true);
|
||||
}
|
||||
else if (ext == QLatin1String("html") &&
|
||||
lpath.midRef(lpath.lastIndexOf(QLatin1Char('/')) + 1).startsWith(QLatin1String("combined_")))
|
||||
{
|
||||
// Kombiniert
|
||||
QHash<QString, QUrl> urls = getCombinedPlaybackDetails(url);
|
||||
|
||||
if (urls.isEmpty())
|
||||
return;
|
||||
|
||||
if (urls.contains(QLatin1String("audio")))
|
||||
{
|
||||
ui->audioWidget->show();
|
||||
ui->audioWidget->play(urls[QLatin1String("audio")]);
|
||||
}
|
||||
if (urls.contains(QLatin1String("video")))
|
||||
{
|
||||
ui->videoWidget->show();
|
||||
ui->videoWidget->play(urls[QLatin1String("video")]);
|
||||
}
|
||||
|
||||
// Einer von dreien:
|
||||
if (urls.contains(QLatin1String("pdf")))
|
||||
{
|
||||
ui->stackedWidget->setCurrentWidget(ui->pdfWidget);
|
||||
ui->pdfWidget->showPDF(urls[QLatin1String("pdf")]);
|
||||
ui->stackedWidget->show();
|
||||
}
|
||||
else if (urls.contains(QLatin1String("html")))
|
||||
{
|
||||
ui->stackedWidget->setCurrentWidget(ui->htmlWidget);
|
||||
ui->htmlWidget->showHTML(urls[QLatin1String("html")]);
|
||||
ui->stackedWidget->show();
|
||||
}
|
||||
else if (urls.contains(QLatin1String("jpg")))
|
||||
{
|
||||
ui->stackedWidget->setCurrentWidget(ui->htmlWidget);
|
||||
ui->htmlWidget->showHTML(urls[QLatin1String("jpg")]);
|
||||
ui->stackedWidget->show();
|
||||
}
|
||||
else if (urls.contains(QLatin1String("png")))
|
||||
{
|
||||
ui->stackedWidget->setCurrentWidget(ui->htmlWidget);
|
||||
ui->htmlWidget->showHTML(urls[QLatin1String("png")]);
|
||||
ui->stackedWidget->show();
|
||||
}
|
||||
else
|
||||
ui->stackedWidget->hide();
|
||||
ui->backButton->setEnabled(true);
|
||||
}
|
||||
else if (ext2Chars == QLatin1String("do") ||
|
||||
ext2Chars == QLatin1String("xl") ||
|
||||
ext2Chars == QLatin1String("pp"))
|
||||
QDesktopServices::openUrl(url);
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Trying to open url: " << url.toString();
|
||||
ui->htmlWidget->showHTML(url);
|
||||
|
||||
ui->stackedWidget->setCurrentWidget(ui->htmlWidget);
|
||||
ui->stackedWidget->show();
|
||||
ui->videoWidget->hide();
|
||||
ui->audioWidget->hide();
|
||||
|
||||
ui->backButton->setEnabled(url != m_homeLink);
|
||||
}
|
||||
}
|
||||
/********************************************************************************************
|
||||
* Parsed eine HTML-Dateinach allen Links, die sich direkt unterhalb des BODY-Tags befinden
|
||||
* und liefert die entsprechenden Link-URLs zurück, wenn diese das Tag ID besitzen.
|
||||
*
|
||||
* Von der aufrufenden Funktion derzeit ausgewertete Werte für ID sind:
|
||||
* html, audio, video, lage, pdf (alles klein geschrieben!)
|
||||
*/
|
||||
QHash<QString, QUrl> ThpViewer::getCombinedPlaybackDetails(const QUrl &url) const
|
||||
{
|
||||
QHash<QString, QUrl> hash;
|
||||
QFile file(url.toLocalFile());
|
||||
QDomDocument doc(QStringLiteral("RSS"));
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
return hash;
|
||||
QString errorStr;
|
||||
int errorLine, errorColumn;
|
||||
if (!doc.setContent(&file, true, &errorStr, &errorLine, &errorColumn))
|
||||
{
|
||||
file.close();
|
||||
return hash;
|
||||
}
|
||||
QDomElement domel = doc.documentElement();
|
||||
domel = domel.firstChildElement(QStringLiteral("BODY"));
|
||||
domel = domel.firstChildElement(QStringLiteral("A"));
|
||||
|
||||
while (!domel.isNull())
|
||||
{
|
||||
if (!domel.attribute(QStringLiteral("id")).isEmpty())
|
||||
{
|
||||
QUrl linkurl(domel.attribute(QStringLiteral("HREF")));
|
||||
if (linkurl.isRelative())
|
||||
linkurl = url.resolved(linkurl);
|
||||
DEBUG_LOG(m_logger) << "attr: " << domel.attribute(QStringLiteral("id")).toLower() << " url: " << linkurl.toString();
|
||||
hash[domel.attribute(QStringLiteral("id")).toLower()] = linkurl;
|
||||
}
|
||||
domel = domel.nextSiblingElement(QStringLiteral("A"));
|
||||
}
|
||||
file.close();
|
||||
return hash;
|
||||
}
|
||||
|
||||
void ThpViewer::onPrint()
|
||||
{
|
||||
if (ui->stackedWidget->isVisible())
|
||||
{
|
||||
if (ui->stackedWidget->currentWidget() == ui->situationWidget)
|
||||
{
|
||||
QImage image = ui->situationWidget->grabFrameBuffer();
|
||||
|
||||
QPrinter printer;
|
||||
QPrintDialog *dialog = new QPrintDialog(&printer, this);
|
||||
dialog->setWindowTitle(tr("Print Document"));
|
||||
if (dialog->exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
QPainter painter;
|
||||
painter.begin(&printer);
|
||||
|
||||
QRectF rect = painter.viewport();
|
||||
|
||||
double mmH = printer.logicalDpiY() / 25.4; // 25.4 = mm/inch
|
||||
double mmW = printer.logicalDpiX() / 25.4;
|
||||
|
||||
painter.setFont(QFont(QStringLiteral("Arial"), 30));
|
||||
QString title = tr("Combat Training Center");
|
||||
QRectF textBox = painter.boundingRect(QRectF(), Qt::AlignLeft & Qt::TextSingleLine, title);
|
||||
textBox.setWidth(painter.viewport().width());
|
||||
painter.drawText(textBox, Qt::AlignCenter & Qt::TextSingleLine, title);
|
||||
QPointF underImage;
|
||||
|
||||
if (printer.orientation() == QPrinter::Portrait)
|
||||
{
|
||||
const QPointF textBlockBegin = QPointF(0 * mmW, 25 * mmH); // Baseline 25mm unter Seitenbeginn
|
||||
|
||||
// Noch mal schauen, welches (auch übersetzt!) der breiteste Bezeichner (also 1. Spalte) ist!
|
||||
painter.setFont(QFont(QStringLiteral("Arial"), 14, QFont::Bold, false));
|
||||
textBox = painter.boundingRect(QRect(), Qt::AlignLeft & Qt::TextSingleLine, tr("Center point:\nExercise:\nTime:"));
|
||||
|
||||
// Textbox hat 3 Zeilen, also ist der Faktor pro Zeile 0.33 = 1/3
|
||||
// Spalte 1
|
||||
painter.drawText(textBlockBegin, tr("Exercise:"));
|
||||
painter.drawText(textBlockBegin + QPointF(0, 0.33 * textBox.height()), tr("Time:"));
|
||||
painter.drawText(textBlockBegin + QPointF(0, 0.66 * textBox.height()), tr("Center point:"));
|
||||
|
||||
// Zwischen Spalte 1 und Spalte 2 noch 3mm Platz lassen
|
||||
// Spalte 2
|
||||
painter.setFont(QFont(QStringLiteral("Arial"), 14, QFont::Normal, false));
|
||||
painter.drawText(textBlockBegin + QPointF(textBox.width() + 3 * mmW, 0), m_trainingName);
|
||||
painter.drawText(textBlockBegin + QPointF(textBox.width() + 3 * mmW, 0.33 * textBox.height()), ui->situationWidget->currentDTGTime());
|
||||
painter.drawText(textBlockBegin + QPointF(textBox.width() + 3 * mmW, 0.66 * textBox.height()), ui->situationWidget->centerPointString());
|
||||
|
||||
// Das Bild soll formatfüllend angezeigt werden, das Rechteck muss 45mm "flacher" sein, da es erst ab 45mm gedruckt werden soll.
|
||||
QSizeF size = image.size();
|
||||
rect.adjust(0, 0, 0, -45 * mmH);
|
||||
size.scale(rect.size(), Qt::KeepAspectRatio);
|
||||
|
||||
// Und ab 45mm von oben drucken:
|
||||
QRectF imgrect = QRectF(QPointF(0 * mmW, 45 * mmH), size);
|
||||
painter.drawImage(imgrect, image);
|
||||
|
||||
// Untere linke Ecke des Bildes
|
||||
underImage = imgrect.bottomLeft();
|
||||
|
||||
}
|
||||
else // Landscape
|
||||
{
|
||||
// Noch mal schauen, welches (auch übersetzt!) der breiteste Bezeichner oder variable Text ist!
|
||||
painter.setFont(QFont(QStringLiteral("Arial"), 14, QFont::Bold, false));
|
||||
textBox = painter.boundingRect(QRect(), Qt::AlignLeft, tr("Center point:\n%1\n\nTime:\n%2\n\nExercise:\n%3")
|
||||
.arg(m_trainingName,
|
||||
ui->situationWidget->currentDTGTime(),
|
||||
ui->situationWidget->centerPointString()));
|
||||
|
||||
// TextBlock fängt an: Notwendige Breite von rechts und 15 mm + 1 Zeilenhöhe (=1/8 der Textboxhöhe) von oben.
|
||||
// Die Zeilenhöhe ist notwendig weil drawText(QPoint, QString) den QPoint auf die Baseline setzt!
|
||||
QPointF textBlockBegin = QPointF(painter.viewport().width() - textBox.width(), 15 * mmH + 0.125 * textBox.height());
|
||||
|
||||
// Die Textbox hat 8 Zeilen, also ist der Faktor pro Zeile 1/8 = 0.125
|
||||
// Übung
|
||||
painter.setFont(QFont(QStringLiteral("Arial"), 14, QFont::Bold, false));
|
||||
painter.drawText(textBlockBegin, tr("Exercise:"));
|
||||
painter.setFont(QFont(QStringLiteral("Arial"), 14, QFont::Normal, false));
|
||||
painter.drawText(textBlockBegin + QPointF(0, 0.125 * textBox.height()), m_trainingName);
|
||||
|
||||
painter.setFont(QFont(QStringLiteral("Arial"), 14, QFont::Bold, false));
|
||||
painter.drawText(textBlockBegin + QPointF(0, 0.375 * textBox.height()), tr("Time:"));
|
||||
painter.setFont(QFont(QStringLiteral("Arial"), 14, QFont::Normal, false));
|
||||
painter.drawText(textBlockBegin + QPointF(0, 0.500 * textBox.height()), ui->situationWidget->currentDTGTime());
|
||||
|
||||
painter.setFont(QFont(QStringLiteral("Arial"), 14, QFont::Bold, false));
|
||||
painter.drawText(textBlockBegin + QPointF(0, 0.750 * textBox.height()), tr("Center point:"));
|
||||
painter.setFont(QFont(QStringLiteral("Arial"), 14, QFont::Normal, false));
|
||||
painter.drawText(textBlockBegin + QPointF(0, 0.875 * textBox.height()), ui->situationWidget->centerPointString());
|
||||
|
||||
// Das Bild soll formatfüllend angezeigt werden, das Rechteck muss 15mm "flacher" sein, da es erst ab 15mm gedruckt werden soll.
|
||||
// Ausserdem müssen in der Breite die Textboxbreite und 3mm Luft dazwischen abgezogen werden.
|
||||
QSizeF size = image.size();
|
||||
rect.adjust(0, 0, -textBox.width() - 3 * mmW, -15 * mmH);
|
||||
size.scale(rect.size(), Qt::KeepAspectRatio);
|
||||
|
||||
// Und ab 15mm von oben drucken:
|
||||
QRectF imgrect = QRectF(QPointF(0 * mmW, 15 * mmH), size);
|
||||
painter.drawImage(imgrect, image);
|
||||
|
||||
// Untere linke Ecke des Bildes
|
||||
underImage = imgrect.bottomLeft();
|
||||
}
|
||||
|
||||
painter.setFont(QFont(QStringLiteral("Arial"), 12));
|
||||
// String für Breite und Höhe erstellen
|
||||
const QRectF extent = ui->situationWidget->extentMgrs();
|
||||
QString areasize = tr("Width: %1m, Height: %2m").arg(extent.width()).arg(extent.height());
|
||||
// Die Größe herausfinden
|
||||
textBox = painter.boundingRect(QRect(), Qt::AlignLeft & Qt::TextSingleLine, areasize);
|
||||
// Einen Dot vergrößern (siehe QRect: Die Rahmenpixel unten und rechts sind nicht Teil der Rechteckgröße)
|
||||
textBox.adjust(0, 0, 1, 1);
|
||||
// An die richtige Stelle bugsieren
|
||||
textBox.moveBottomLeft(underImage);
|
||||
// Und mit weiß und 50% Deckkraft vollmalen.
|
||||
painter.fillRect(textBox, QColor(255, 255, 255, 128));
|
||||
//Dann den Text drüberlegen
|
||||
painter.drawText(underImage, areasize);
|
||||
|
||||
painter.end();
|
||||
}
|
||||
else if (ui->stackedWidget->currentWidget() == ui->pdfWidget)
|
||||
{
|
||||
QPrinter printer;
|
||||
QPrintDialog *dialog = new QPrintDialog(&printer, this);
|
||||
dialog->setWindowTitle(tr("Print Document"));
|
||||
if (dialog->exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
QVector<QImage> images = ui->pdfWidget->getPrintableImages(printer.resolution());
|
||||
int lastItem = images.size() - 1;
|
||||
|
||||
QPainter painter;
|
||||
painter.begin(&printer);
|
||||
for (int i = 0; i < images.size(); ++i)
|
||||
{
|
||||
QRect rect = painter.viewport();
|
||||
QSize size = images.at(i).size();
|
||||
size.scale(rect.size(), Qt::KeepAspectRatio);
|
||||
painter.setViewport(rect.x(), rect.y(),
|
||||
size.width(), size.height());
|
||||
painter.setWindow(images.at(i).rect());
|
||||
painter.drawImage(0, 0, images.at(i));
|
||||
if (i != lastItem)
|
||||
printer.newPage();
|
||||
}
|
||||
painter.end();
|
||||
}
|
||||
else if (ui->stackedWidget->currentWidget() == ui->htmlWidget)
|
||||
{
|
||||
QPrinter printer;
|
||||
QPrintDialog *dialog = new QPrintDialog(&printer, this);
|
||||
dialog->setWindowTitle(tr("Print Document"));
|
||||
if (dialog->exec() != QDialog::Accepted)
|
||||
return;
|
||||
ui->htmlWidget->print(&printer);
|
||||
}
|
||||
else // Audio/Video-Widget
|
||||
{
|
||||
}
|
||||
}
|
||||
else // nur HTML sichtbar...
|
||||
{
|
||||
QPrinter printer;
|
||||
QPrintDialog *dialog = new QPrintDialog(&printer, this);
|
||||
dialog->setWindowTitle(tr("Print Document"));
|
||||
if (dialog->exec() != QDialog::Accepted)
|
||||
return;
|
||||
ui->htmlWidget->print(&printer);
|
||||
}
|
||||
}
|
||||
|
||||
void ThpViewer::onBack()
|
||||
{
|
||||
ui->audioWidget->stop();
|
||||
ui->videoWidget->stop();
|
||||
ui->situationWidget->stop();
|
||||
|
||||
ui->audioWidget->hide();
|
||||
ui->videoWidget->hide();
|
||||
if (ui->stackedWidget->currentWidget() == ui->htmlWidget &&
|
||||
ui->stackedWidget->isVisible())
|
||||
ui->htmlWidget->back();
|
||||
ui->stackedWidget->show();
|
||||
ui->stackedWidget->setCurrentWidget(ui->htmlWidget);
|
||||
onUrlChanged(ui->htmlWidget->url());
|
||||
}
|
||||
|
||||
void ThpViewer::onHome()
|
||||
{
|
||||
ui->htmlWidget->show();
|
||||
onLinkClicked(m_homeLink);
|
||||
}
|
||||
|
||||
void ThpViewer::onFullScreen()
|
||||
{
|
||||
setWindowState(windowState() ^ Qt::WindowFullScreen);
|
||||
}
|
||||
|
||||
void ThpViewer::onUrlChanged(const QUrl &url)
|
||||
{
|
||||
ui->backButton->setEnabled(url != m_homeLink);
|
||||
}
|
||||
|
||||
} // namespace NGL
|
||||
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Main thp viewer widget
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QUrl>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class thpViewer;
|
||||
}
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class ThpViewer : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ThpViewer(const QUrl &url, QWidget *parent = nullptr);
|
||||
~ThpViewer();
|
||||
|
||||
bool init();
|
||||
void center();
|
||||
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
protected:
|
||||
QHash<QString, QUrl> getCombinedPlaybackDetails(const QUrl &url) const;
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onLinkClicked(const QUrl &url);
|
||||
void onZoomChanged();
|
||||
void onBack();
|
||||
void onHome();
|
||||
void onHelp();
|
||||
void onPrint();
|
||||
void onFullScreen();
|
||||
void onTitleChanged(const QString &title);
|
||||
void onUrlChanged(const QUrl &url);
|
||||
public Q_SLOTS:
|
||||
void onNewThp(const QString &index);
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
protected:
|
||||
Ui::thpViewer *ui;
|
||||
double m_scaleFactor;
|
||||
QUrl m_homeLink;
|
||||
QString m_homePath;
|
||||
QString m_trainingName;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
} // namespace NGL
|
||||
@@ -0,0 +1,30 @@
|
||||
#include <WINVER.H>
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION @THP_VERSION_INFO@
|
||||
PRODUCTVERSION @THP_VERSION_INFO@
|
||||
FILEFLAGSMASK 0x0L
|
||||
FILEFLAGS 0x0L
|
||||
FILEOS VOS_NT_WINDOWS32
|
||||
FILETYPE VFT_APP
|
||||
FILESUBTYPE VFT2_UNKNOWN
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040704b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Rheinmetall Electronics GmbH"
|
||||
VALUE "FileDescription", "Take Home Package Viewer"
|
||||
VALUE "FileVersion", "@THP_VERSION_INFO@"
|
||||
VALUE "InternalName", "THP"
|
||||
VALUE "LegalCopyright", "Copyright © 2018 Rheinmetall Electronics GmbH. Alle Rechte vorbehalten"
|
||||
VALUE "OriginalFilename", "thp_viewer.exe"
|
||||
VALUE "ProductName", "Take Home Package Viewer (THP)"
|
||||
VALUE "ProductVersion", "@THP_VERSION_INFO@"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x407, 1200
|
||||
END
|
||||
END
|
||||
@@ -0,0 +1,216 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>thpViewer</class>
|
||||
<widget class="QWidget" name="thpViewer">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>793</width>
|
||||
<height>675</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>793</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">MainWindow</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QToolButton" name="backButton">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:icons/16x16/go-previous.png</normaloff>:icons/16x16/go-previous.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="fullScreenButton">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:icons/16x16/view-fullscreen.png</normaloff>:icons/16x16/view-fullscreen.png</iconset>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>F11</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="homeButton">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:icons/16x16/go-home.png</normaloff>:icons/16x16/go-home.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="mainLabel">
|
||||
<property name="text">
|
||||
<string notr="true">THP-Viewer</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QToolButton" name="printButton">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:icons/16x16/document-print.png</normaloff>:icons/16x16/document-print.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="helpButton">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:icons/16x16/system-help.png</normaloff>:icons/16x16/system-help.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="closeButton">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:icons/16x16/dialog-close.png</normaloff>:icons/16x16/dialog-close.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter_1">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QSplitter" name="splitter_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="THP::AudioVideoWidget" name="videoWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<widget class="THP::HtmlWidget" name="htmlWidget"/>
|
||||
<widget class="THP::BuildingWidget" name="buildingWidget"/>
|
||||
<widget class="THP::PdfWidget" name="pdfWidget"/>
|
||||
<widget class="THP::SituationWidget" name="situationWidget"/>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="THP::AudioVideoWidget" name="audioWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>THP::AudioVideoWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>thpwidgets/thp_audio_video_widget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>THP::PdfWidget</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>thpwidgets/thp_pdf_widget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>THP::HtmlWidget</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>thpwidgets/thp_html_widget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>THP::SituationWidget</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>thpwidgets/thp_situation_widget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>THP::BuildingWidget</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>thpwidgets/thp_building_widget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+629
@@ -0,0 +1,629 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Handle Audio/Video output for thp through libvlc
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#include "thp_audio_video_widget.h"
|
||||
#include "thp_audio_video_widget_p.h"
|
||||
#include "ui_thp_audio_video_widget.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
#include <QMutex>
|
||||
#include <QScreen>
|
||||
#include <QTimer>
|
||||
#include <QUrl>
|
||||
#include <QGuiApplication>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <vlc/libvlc_version.h>
|
||||
|
||||
namespace THP
|
||||
{
|
||||
|
||||
static const float s_speedArray[] =
|
||||
{
|
||||
1. / 8.,
|
||||
1. / 4.,
|
||||
1. / 2.,
|
||||
1.,
|
||||
2.,
|
||||
4.,
|
||||
8.
|
||||
};
|
||||
|
||||
/**
|
||||
* AudioVideoWidget::Private
|
||||
*/
|
||||
AudioVideoWidget::Private::Private(QFrame *parent)
|
||||
: m_vlcinstance(nullptr)
|
||||
, m_mPlayer(nullptr)
|
||||
, m_mListPlayer(nullptr)
|
||||
, m_mediaList(nullptr)
|
||||
, currentSpeedIdx(3)
|
||||
, m_parent(parent)
|
||||
, m_timer(new QTimer)
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("THP.AudioVideoWidget"))
|
||||
{
|
||||
init();
|
||||
|
||||
connect(ui->btnSlower, &QToolButton::clicked, this, &AudioVideoWidget::Private::onSlower);
|
||||
connect(ui->btnFaster, &QToolButton::clicked, this, &AudioVideoWidget::Private::onFaster);
|
||||
connect(ui->btn100pct, &QToolButton::clicked, this, &AudioVideoWidget::Private::on100pct);
|
||||
connect(ui->btnPlay, &QToolButton::clicked, this, &AudioVideoWidget::Private::onPlay);
|
||||
connect(ui->btnStop, &QToolButton::clicked, this, &AudioVideoWidget::Private::onStop);
|
||||
connect(ui->sldPosition, &QSlider::sliderMoved, this, &AudioVideoWidget::Private::onPositionChanged);
|
||||
connect(ui->sldVolume, &QSlider::sliderMoved, this, &AudioVideoWidget::Private::onVolumeChanged);
|
||||
connect(m_timer, &QTimer::timeout, this, &AudioVideoWidget::Private::onUpdateGUI);
|
||||
|
||||
m_initThread = new AudioVideoInitThread(this);
|
||||
connect(m_initThread, &AudioVideoInitThread::finished, this, &AudioVideoWidget::Private::onVLCInstanceInitializd);
|
||||
m_initThread->start(QThread::LowPriority);
|
||||
}
|
||||
|
||||
AudioVideoWidget::Private::~Private()
|
||||
{
|
||||
uninitVLCPlayer();
|
||||
uninitVLCInstance();
|
||||
delete ui;
|
||||
delete m_timer;
|
||||
}
|
||||
|
||||
bool AudioVideoWidget::Private::init()
|
||||
{
|
||||
if (!m_parent)
|
||||
return false;
|
||||
ui = new Ui::audioVideoWidget();
|
||||
ui->setupUi(m_parent);
|
||||
|
||||
QPixmap pm(10, 10);
|
||||
pm.fill(Qt::black);
|
||||
ui->outputWidget->setPixmap(pm);
|
||||
ui->outputWidget->setScaledContents(true);
|
||||
|
||||
ui->sldPosition->setMaximum(1000);
|
||||
ui->sldVolume->setMaximum(100);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AudioVideoWidget::Private::onVLCInstanceInitializd()
|
||||
{
|
||||
m_initThread->deleteLater();
|
||||
m_initThread = nullptr;
|
||||
}
|
||||
|
||||
void AudioVideoWidget::Private::setAV(bool isAudio)
|
||||
{
|
||||
if (isAudio)
|
||||
{
|
||||
delete ui->btn100pct;
|
||||
delete ui->btnFaster;
|
||||
delete ui->btnSlower;
|
||||
delete ui->outputWidget;
|
||||
ui->outputWidget = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
// delete ui->verticalSpacer; ui->verticalSpacer = 0;
|
||||
delete ui->lblAudio;
|
||||
}
|
||||
}
|
||||
|
||||
static QMutex *serializeVLCInit()
|
||||
{
|
||||
static QMutex s_serializeVLCInit;
|
||||
return &s_serializeVLCInit;
|
||||
}
|
||||
|
||||
bool AudioVideoWidget::Private::initVLCInstance(bool bInInitThread)
|
||||
{
|
||||
QMutexLocker l(serializeVLCInit());
|
||||
|
||||
if (!bInInitThread && m_initThread != nullptr)
|
||||
{
|
||||
QLabel myLabel;
|
||||
myLabel.setWindowTitle(tr("Loading VLC player..."));
|
||||
myLabel.setText(tr("Waiting until VLC player is loaded"));
|
||||
QRect r = QGuiApplication::primaryScreen()->availableGeometry();
|
||||
myLabel.show();
|
||||
myLabel.move(r.width() / 2 - myLabel.width() / 2, r.height() / 2 - myLabel.height() / 2);
|
||||
myLabel.setWindowIcon(QIcon(QLatin1String(":icons/16x16/rde.ico")));
|
||||
|
||||
while (m_initThread)
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
if (m_vlcinstance != nullptr)
|
||||
return true;
|
||||
|
||||
//preparation of the vlc command
|
||||
const char *vlc_argv[20];
|
||||
int iCount = 0;
|
||||
vlc_argv[iCount++] = "-I";
|
||||
vlc_argv[iCount++] = "dummy"; // Don't use any interface
|
||||
// vlc_argv[iCount++] = "--ignore-config"; // Don't use VLC's config
|
||||
#ifdef LTS_DEBUG
|
||||
vlc_argv[iCount++] = "--extraintf=logger"; // log anything
|
||||
vlc_argv[iCount++] = "--verbose=2"; // be much more verbose then normal for debugging purpose
|
||||
#else
|
||||
vlc_argv[iCount++] = "--quiet";
|
||||
#endif
|
||||
if (bInInitThread)
|
||||
vlc_argv[iCount++] = "--no-media-library";
|
||||
vlc_argv[iCount++] = "--";
|
||||
vlc_argv[iCount] = nullptr;
|
||||
|
||||
//Initialize an instance of vlc
|
||||
//create a new libvlc instance
|
||||
m_vlcinstance = libvlc_new(iCount, vlc_argv); //tricky calculation of the char space used
|
||||
if (!m_vlcinstance)
|
||||
ERROR_LOG(m_logger) << "Error initializing libVLC - unable to play audio or video";
|
||||
|
||||
return (m_vlcinstance != nullptr);
|
||||
}
|
||||
|
||||
bool AudioVideoWidget::Private::uninitVLCInstance()
|
||||
{
|
||||
QMutexLocker l(serializeVLCInit());
|
||||
|
||||
if (!uninitVLCPlayer())
|
||||
return false;
|
||||
|
||||
if (m_vlcinstance)
|
||||
{
|
||||
libvlc_release(m_vlcinstance);
|
||||
m_vlcinstance = nullptr;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioVideoWidget::Private::initVLCPlayer()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Initializing libVLC";
|
||||
if (m_mPlayer)
|
||||
{
|
||||
if (!ui)
|
||||
return false;
|
||||
ui->sldVolume->setValue(libvlc_audio_get_volume(m_mPlayer));
|
||||
return true;
|
||||
}
|
||||
|
||||
initVLCInstance();
|
||||
|
||||
//Initialize an instance of vlc
|
||||
//Create a media player playing environement
|
||||
m_mPlayer = libvlc_media_player_new(m_vlcinstance);
|
||||
m_mListPlayer = libvlc_media_list_player_new(m_vlcinstance);
|
||||
m_mediaList = libvlc_media_list_new(m_vlcinstance);
|
||||
|
||||
libvlc_media_list_player_set_media_player(m_mListPlayer, m_mPlayer);
|
||||
libvlc_media_list_player_set_media_list(m_mListPlayer, m_mediaList);
|
||||
|
||||
ui->sldVolume->setValue(libvlc_audio_get_volume(m_mPlayer));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioVideoWidget::Private::uninitVLCPlayer()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Uninitializing libVLC";
|
||||
|
||||
if (m_mListPlayer)
|
||||
{
|
||||
/* Stop playing */
|
||||
libvlc_media_list_player_stop(m_mListPlayer);
|
||||
/* Free the media_player */
|
||||
libvlc_media_list_player_release(m_mListPlayer);
|
||||
m_mListPlayer = nullptr;
|
||||
}
|
||||
if (m_mediaList)
|
||||
{
|
||||
clearMediaList();
|
||||
libvlc_media_list_release(m_mediaList);
|
||||
m_mediaList = nullptr;
|
||||
}
|
||||
if (m_mPlayer)
|
||||
{
|
||||
/* Stop playing */
|
||||
libvlc_media_player_stop(m_mPlayer);
|
||||
/* Free the media_player */
|
||||
libvlc_media_player_release(m_mPlayer);
|
||||
|
||||
m_mPlayer = nullptr;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AudioVideoWidget::Private::clearMediaList()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Clearing current playlist";
|
||||
|
||||
if (!m_mediaList)
|
||||
return;
|
||||
libvlc_media_list_lock(m_mediaList);
|
||||
const int cnt = libvlc_media_list_count(m_mediaList);
|
||||
for (int i = cnt - 1; i >= 0; --i)
|
||||
libvlc_media_list_remove_index(m_mediaList, i);
|
||||
libvlc_media_list_unlock(m_mediaList);
|
||||
}
|
||||
|
||||
bool AudioVideoWidget::Private::playVLC(const QUrl &url)
|
||||
{
|
||||
if (!ui)
|
||||
return false;
|
||||
|
||||
DEBUG_LOG(m_logger) << "Try to play " << url.toString();
|
||||
|
||||
const QString path = url.toLocalFile();
|
||||
if (path.isEmpty())
|
||||
return false;
|
||||
|
||||
clearMediaList();
|
||||
|
||||
libvlc_media_list_lock(m_mediaList);
|
||||
QFileInfo fi(path);
|
||||
DEBUG_LOG(m_logger) << "path: " << path << " isFile: " << fi.isFile();
|
||||
if (fi.isFile() && path.endsWith(QLatin1String(".pls")))
|
||||
{
|
||||
// pls parsing scheint nicht mehr richtig zu funktionieren - selbst machen
|
||||
DEBUG_LOG(m_logger) << "Parse Playlist";
|
||||
QFile f(path);
|
||||
if (f.open(QIODevice::ReadOnly))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Parse Playlist2 " << f.canReadLine();
|
||||
QMap<int, QByteArray> fileMap;
|
||||
QByteArray baAll = f.readAll();
|
||||
const QList<QByteArray> lines = baAll.split('\n');
|
||||
for (const QByteArray &line : lines)
|
||||
{
|
||||
QByteArray ba = line.trimmed();
|
||||
DEBUG_LOG(m_logger) << "ba: " << ba;
|
||||
if (!ba.startsWith("File "))
|
||||
continue;
|
||||
ba = ba.mid(qstrlen("File "));
|
||||
int idx = ba.indexOf('=');
|
||||
DEBUG_LOG(m_logger) << "idx: " << idx;
|
||||
if (idx < 0)
|
||||
continue;
|
||||
bool bOk;
|
||||
int id = ba.left(idx).toInt(&bOk);
|
||||
DEBUG_LOG(m_logger) << "id: " << id << " bOk: " << bOk << " str: " << ba.left(idx);
|
||||
if (!bOk)
|
||||
continue;
|
||||
QByteArray filename = ba.mid(idx + 1);
|
||||
DEBUG_LOG(m_logger) << "filename: " << filename;
|
||||
fileMap.insertMulti(id, fi.absolutePath().toLocal8Bit() + '/' + filename);
|
||||
}
|
||||
for (const QByteArray &fn : fileMap)
|
||||
{
|
||||
const QByteArray pNative = QDir::toNativeSeparators(QString::fromLocal8Bit(fn)).toLocal8Bit();
|
||||
DEBUG_LOG(m_logger) << "pNative: " << pNative;
|
||||
libvlc_media_t *media = libvlc_media_new_path(m_vlcinstance, pNative.data());
|
||||
if (!media)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error setting media to " << pNative;
|
||||
return false;
|
||||
}
|
||||
//add option to disable hardware acceleration
|
||||
libvlc_media_add_option(media, ":avcodec-hw=none");
|
||||
libvlc_media_list_add_media(m_mediaList, media);
|
||||
#if LIBVLC_VERSION_MAJOR > 2
|
||||
libvlc_media_parse_with_options(media, libvlc_media_parse_local, 0);
|
||||
#else
|
||||
libvlc_media_parse(media);
|
||||
#endif
|
||||
libvlc_media_release(media); // libvlc_media_new_location(), ref-counting!
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (fi.isFile())
|
||||
{
|
||||
const QByteArray pNative = QDir::toNativeSeparators(path).toLocal8Bit();
|
||||
libvlc_media_t *media = libvlc_media_new_path(m_vlcinstance, pNative.data());
|
||||
if (!media)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error setting media to '" << pNative << "'";
|
||||
return false;
|
||||
}
|
||||
libvlc_media_list_add_media(m_mediaList, media);
|
||||
libvlc_media_release(media); // libvlc_media_new_location(), ref-counting!
|
||||
}
|
||||
else if (fi.isDir())
|
||||
{
|
||||
QDirIterator dirIt(fi.absoluteFilePath());
|
||||
while (dirIt.hasNext())
|
||||
{
|
||||
const QString fn = dirIt.next();
|
||||
fi.setFile(fn);
|
||||
if (!fi.isFile())
|
||||
continue;
|
||||
const QByteArray pNative = QDir::toNativeSeparators(fn).toLocal8Bit();
|
||||
libvlc_media_t *media = libvlc_media_new_path(m_vlcinstance, pNative.data());
|
||||
if (!media)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error setting media to " << pNative;
|
||||
return false;
|
||||
}
|
||||
libvlc_media_list_add_media(m_mediaList, media);
|
||||
#if LIBVLC_VERSION_MAJOR > 2
|
||||
libvlc_media_parse_with_options(media, libvlc_media_parse_local, 0);
|
||||
#else
|
||||
libvlc_media_parse(media);
|
||||
#endif
|
||||
libvlc_media_release(media); // libvlc_media_new_location(), ref-counting!
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Unknown media given: " << path;
|
||||
libvlc_media_list_unlock(m_mediaList);
|
||||
return false;
|
||||
}
|
||||
libvlc_media_list_unlock(m_mediaList);
|
||||
|
||||
if (ui->outputWidget)
|
||||
{
|
||||
#if defined(Q_OS_WIN)
|
||||
libvlc_media_player_set_hwnd(m_mPlayer, (HWND)ui->outputWidget->winId());
|
||||
#elif defined(Q_OS_MAC)
|
||||
libvlc_media_player_set_agl(m_mPlayer, ui->outputWidget->winId()) ;
|
||||
#else //Linux
|
||||
libvlc_media_player_set_xwindow(m_mPlayer, ui->outputWidget->winId());
|
||||
#endif
|
||||
}
|
||||
|
||||
ui->btnPlay->setIcon(QIcon(QStringLiteral(":icons/16x16/media-playback-start.png")));
|
||||
ui->btnPlay->setEnabled(true);
|
||||
ui->sldPosition->setEnabled(false);
|
||||
ui->btnStop->setEnabled(true);
|
||||
|
||||
currentSpeedIdx = 3;
|
||||
|
||||
QTimer::singleShot(0, this, &AudioVideoWidget::Private::onPlay);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioVideoWidget::Private::stopVLC()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Stop playing";
|
||||
|
||||
QTimer::singleShot(0, this, &AudioVideoWidget::Private::onStop);
|
||||
return true;
|
||||
}
|
||||
|
||||
void AudioVideoWidget::Private::setRate()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Setting speed to " << s_speedArray[currentSpeedIdx];
|
||||
|
||||
libvlc_state_t state = getState();
|
||||
if (state == libvlc_Playing || state == libvlc_Paused)
|
||||
libvlc_media_player_set_rate(m_mPlayer, s_speedArray[currentSpeedIdx]);
|
||||
}
|
||||
|
||||
libvlc_state_t AudioVideoWidget::Private::getState() const
|
||||
{
|
||||
libvlc_state_t s = libvlc_media_list_player_get_state(m_mListPlayer);
|
||||
static libvlc_state_t lastState = libvlc_NothingSpecial;
|
||||
if (s == lastState)
|
||||
return s;
|
||||
lastState = s;
|
||||
if (s == libvlc_Error)
|
||||
ERROR_LOG(m_logger) << "libVLC error: " << libvlc_errmsg();
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
void AudioVideoWidget::Private::onSlower()
|
||||
{
|
||||
if (currentSpeedIdx == 0)
|
||||
return;
|
||||
--currentSpeedIdx;
|
||||
setRate();
|
||||
onUpdateGUI();
|
||||
}
|
||||
|
||||
void AudioVideoWidget::Private::onFaster()
|
||||
{
|
||||
if (currentSpeedIdx == 6)
|
||||
return;
|
||||
++currentSpeedIdx;
|
||||
setRate();
|
||||
onUpdateGUI();
|
||||
}
|
||||
|
||||
void AudioVideoWidget::Private::on100pct()
|
||||
{
|
||||
currentSpeedIdx = 3;
|
||||
setRate();
|
||||
onUpdateGUI();
|
||||
}
|
||||
|
||||
void AudioVideoWidget::Private::onPlay()
|
||||
{
|
||||
if (libvlc_media_list_player_is_playing(m_mListPlayer))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Pause playing";
|
||||
libvlc_media_list_player_pause(m_mListPlayer);
|
||||
ui->btnPlay->setIcon(QIcon(QStringLiteral(":icons/16x16/media-playback-start.png")));
|
||||
m_timer->stop();
|
||||
onUpdateGUIWithState(libvlc_Paused);
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Start playing";
|
||||
ui->btnPlay->setIcon(QIcon(QStringLiteral(":icons/16x16/media-playback-pause.png")));
|
||||
ui->sldPosition->setEnabled(true);
|
||||
|
||||
libvlc_media_list_player_play(m_mListPlayer);
|
||||
setRate();
|
||||
|
||||
m_timer->start(100);
|
||||
onUpdateGUIWithState(libvlc_Playing);
|
||||
}
|
||||
}
|
||||
|
||||
void AudioVideoWidget::Private::onStop()
|
||||
{
|
||||
if (!m_mListPlayer)
|
||||
return;
|
||||
|
||||
libvlc_state_t state = getState();
|
||||
|
||||
if (state == libvlc_Stopped)
|
||||
return;
|
||||
|
||||
DEBUG_LOG(m_logger) << "Stop playing";
|
||||
|
||||
libvlc_media_list_player_stop(m_mListPlayer);
|
||||
onUpdateGUI();
|
||||
}
|
||||
|
||||
void AudioVideoWidget::Private::onPositionChanged(int newPosition)
|
||||
{
|
||||
libvlc_state_t state = getState();
|
||||
|
||||
DEBUG_LOG(m_logger) << "Slider changed - going to new position";
|
||||
|
||||
if (state != libvlc_Playing && state != libvlc_Paused)
|
||||
return;
|
||||
|
||||
// Position geht von 0..1, Slider hat 1000 Steps
|
||||
libvlc_media_player_set_position(m_mPlayer, newPosition / 1000.);
|
||||
onUpdateGUI();
|
||||
}
|
||||
|
||||
void AudioVideoWidget::Private::onVolumeChanged(int newVol)
|
||||
{
|
||||
libvlc_audio_set_volume(m_mPlayer, newVol);
|
||||
onUpdateGUI();
|
||||
}
|
||||
|
||||
void AudioVideoWidget::Private::onUpdateGUI()
|
||||
{
|
||||
onUpdateGUIWithState(libvlc_NothingSpecial);
|
||||
}
|
||||
|
||||
void AudioVideoWidget::Private::onUpdateGUIWithState(libvlc_state_t overwrite_state)
|
||||
{
|
||||
libvlc_state_t state = overwrite_state;
|
||||
if (state == libvlc_NothingSpecial)
|
||||
state = getState();
|
||||
DEBUG_LOG(m_logger) << "onUpdateGUI for state " << state;
|
||||
|
||||
if (state == libvlc_Playing || state == libvlc_Paused)
|
||||
{
|
||||
double maxTime = libvlc_media_player_get_length(m_mPlayer) / 1000.;
|
||||
if (maxTime > 0.1)
|
||||
{
|
||||
libvlc_media_list_lock(m_mediaList);
|
||||
const int cnt = libvlc_media_list_count(m_mediaList);
|
||||
for (int i = cnt - 1; i >= 0; --i)
|
||||
{
|
||||
libvlc_media_t *media = libvlc_media_list_item_at_index(m_mediaList, i);
|
||||
DEBUG_LOG(m_logger) << "Duration: " << libvlc_media_get_duration(media);
|
||||
libvlc_media_release(media);
|
||||
}
|
||||
libvlc_media_list_unlock(m_mediaList);
|
||||
|
||||
}
|
||||
double curTime = libvlc_media_player_get_time(m_mPlayer) / 1000.;
|
||||
auto curPos = libvlc_media_player_get_position(m_mPlayer);
|
||||
// Slider ist in 1000 Schritte eingeteilt
|
||||
ui->sldPosition->setValue(qRound(curPos * 1000));
|
||||
|
||||
const int minutesCur = floor(curTime / 60.);
|
||||
const int secondsCur = curTime - 60 * minutesCur;
|
||||
const int minutesAbs = floor(maxTime / 60.);
|
||||
const int secondsAbs = maxTime - 60 * minutesAbs;
|
||||
char timeStr[64];
|
||||
snprintf(timeStr, sizeof(timeStr), "%02d:%02d / %02d:%02d", minutesCur, secondsCur, minutesAbs, secondsAbs);
|
||||
ui->lblPosition->setText(QString::fromLatin1(timeStr));
|
||||
|
||||
}
|
||||
else if (state == libvlc_Stopped || state == libvlc_Ended)
|
||||
{
|
||||
// wir können nicht onStop() aufrufen -> rekursion!
|
||||
bool bStop = true;
|
||||
if (state == libvlc_Ended)
|
||||
{
|
||||
// Timer und VLC *nicht* stoppen da der aktuelle State ggf. genau zwischen den einzelnen
|
||||
// Video-Schnipseln einer Playlist abgefragt wurde
|
||||
// --> prüfen, ob es das letzte Video der Playlist war
|
||||
libvlc_media_t *media = libvlc_media_player_get_media(m_mPlayer);
|
||||
if (media != nullptr)
|
||||
{
|
||||
const int cnt = libvlc_media_list_count(m_mediaList);
|
||||
if (cnt > 0)
|
||||
{
|
||||
libvlc_media_t *media2 = libvlc_media_list_item_at_index(m_mediaList, cnt - 1);
|
||||
bStop = (media2 == media);
|
||||
libvlc_media_release(media2);
|
||||
}
|
||||
libvlc_media_release(media);
|
||||
}
|
||||
if (bStop)
|
||||
libvlc_media_list_player_stop(m_mListPlayer);
|
||||
}
|
||||
if (bStop)
|
||||
{
|
||||
ui->btnPlay->setIcon(QIcon(QStringLiteral(":icons/16x16/media-playback-start.png")));
|
||||
ui->sldPosition->setEnabled(false);
|
||||
m_timer->stop();
|
||||
ui->sldPosition->setValue(0);
|
||||
ui->lblPosition->setText(QLatin1String("--:-- / --:--"));
|
||||
}
|
||||
}
|
||||
|
||||
QString speedStr = QStringLiteral("%1x").arg(s_speedArray[currentSpeedIdx], 4, 'f', 2);
|
||||
ui->lblSpeed->setText(speedStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* AudioVideoInitThread
|
||||
*/
|
||||
AudioVideoInitThread::AudioVideoInitThread(AudioVideoWidget::Private *p)
|
||||
: m_private(p)
|
||||
{}
|
||||
|
||||
void AudioVideoInitThread::run()
|
||||
{
|
||||
m_private->initVLCInstance(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* AudioVideoWidget
|
||||
*/
|
||||
AudioVideoWidget::AudioVideoWidget(QWidget *parent)
|
||||
: QFrame(parent)
|
||||
, d(new Private(this))
|
||||
{}
|
||||
|
||||
AudioVideoWidget::~AudioVideoWidget()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool AudioVideoWidget::play(const QUrl &file)
|
||||
{
|
||||
d->initVLCPlayer();
|
||||
return d->playVLC(file);
|
||||
}
|
||||
|
||||
bool AudioVideoWidget::stop()
|
||||
{
|
||||
return d->stopVLC();
|
||||
}
|
||||
|
||||
void AudioVideoWidget::setAV(bool isAudio)
|
||||
{
|
||||
d->setAV(isAudio);
|
||||
}
|
||||
|
||||
} // namespace THP
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Handle Audio/Video output for thp through libvlc
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
class QUrl;
|
||||
|
||||
namespace THP
|
||||
{
|
||||
class AudioVideoWidget : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AudioVideoWidget(QWidget *parent = nullptr);
|
||||
~AudioVideoWidget();
|
||||
|
||||
bool play(const QUrl &file);
|
||||
bool stop();
|
||||
void setAV(bool isAudio = false);
|
||||
|
||||
private:
|
||||
class Private;
|
||||
Private *const d;
|
||||
friend class AudioVideoInitThread;
|
||||
};
|
||||
} // namespace THP
|
||||
+254
@@ -0,0 +1,254 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>audioVideoWidget</class>
|
||||
<widget class="QFrame" name="audioVideoWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>911</width>
|
||||
<height>563</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Form</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="outputWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblAudio">
|
||||
<property name="text">
|
||||
<string>Audio</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="sldPosition">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblPosition">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>70</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">55:55 / 55:55</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnPlay">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Z/src/nglwidgets/nglresources.qrc">
|
||||
<normaloff>:icons/16x16/media-playback-start.png</normaloff>:icons/16x16/media-playback-start.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnStop">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Z/src/nglwidgets/nglresources.qrc">
|
||||
<normaloff>:icons/16x16/media-playback-stop.png</normaloff>:icons/16x16/media-playback-stop.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnSlower">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Z/src/nglwidgets/nglresources.qrc">
|
||||
<normaloff>:icons/16x16/media-play-slower.png</normaloff>:icons/16x16/media-play-slower.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btn100pct">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Z/src/nglwidgets/nglresources.qrc">
|
||||
<normaloff>:icons/16x16/media-play-normal.png</normaloff>:icons/16x16/media-play-normal.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnFaster">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Z/src/nglwidgets/nglresources.qrc">
|
||||
<normaloff>:icons/16x16/media-play-faster.png</normaloff>:icons/16x16/media-play-faster.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>5</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblSpeed">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">100 %</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Volume:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="sldVolume">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>60</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../../Z/src/nglwidgets/nglresources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Handle Audio/Video output for thp through libvlc, private data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// no ssize_t with msdn...
|
||||
#include <BaseTsd.h>
|
||||
typedef SSIZE_T ssize_t;
|
||||
#endif
|
||||
|
||||
#include <vlc/vlc.h>
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include "thp_audio_video_widget.h"
|
||||
|
||||
class QUrl;
|
||||
class QFrame;
|
||||
class QTimer;
|
||||
namespace Ui
|
||||
{
|
||||
class audioVideoWidget;
|
||||
}
|
||||
|
||||
namespace THP
|
||||
{
|
||||
class AudioVideoInitThread;
|
||||
class AudioVideoWidget::Private : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Private(QFrame *parent);
|
||||
~Private();
|
||||
|
||||
bool initVLCInstance(bool bInInitThread = false);
|
||||
bool uninitVLCInstance();
|
||||
bool initVLCPlayer();
|
||||
bool uninitVLCPlayer();
|
||||
bool playVLC(const QUrl &url);
|
||||
bool stopVLC();
|
||||
void setAV(bool isAudio);
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onSlower();
|
||||
void onFaster();
|
||||
void on100pct();
|
||||
void onPlay();
|
||||
void onStop();
|
||||
void onPositionChanged(int);
|
||||
void onVolumeChanged(int);
|
||||
void onUpdateGUI();
|
||||
void onVLCInstanceInitializd();
|
||||
|
||||
protected:
|
||||
void clearMediaList();
|
||||
void playVLCInternal();
|
||||
void onUpdateGUIWithState(libvlc_state_t overwrite_state);
|
||||
bool init();
|
||||
void setRate();
|
||||
libvlc_state_t getState() const;
|
||||
|
||||
libvlc_instance_t *m_vlcinstance;
|
||||
libvlc_media_player_t *m_mPlayer;
|
||||
libvlc_media_list_player_t *m_mListPlayer;
|
||||
libvlc_media_list_t *m_mediaList;
|
||||
|
||||
int currentSpeedIdx;
|
||||
|
||||
QFrame *m_parent;
|
||||
QTimer *m_timer;
|
||||
AudioVideoInitThread *m_initThread;
|
||||
|
||||
Ui::audioVideoWidget *ui;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
class AudioVideoInitThread final : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AudioVideoInitThread(AudioVideoWidget::Private *p);
|
||||
protected:
|
||||
void run() override;
|
||||
protected:
|
||||
AudioVideoWidget::Private *m_private;
|
||||
};
|
||||
} // namespace THP
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for MeteoDataManagement - Meteo Data Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10-05
|
||||
*/
|
||||
|
||||
#include "thp_building_settings.h"
|
||||
#include "ui_thp_building_settings.h"
|
||||
#include <Common/bdv_controller.h>
|
||||
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
namespace THP
|
||||
{
|
||||
static QVariant getSetting(const QString &key, const QVariant &def)
|
||||
{
|
||||
return LtsUtils::OperatorSettings::getInstance()->value(QStringLiteral("BgViewer"), key, def);
|
||||
}
|
||||
|
||||
static void setSetting(const QString &key, const QVariant &val)
|
||||
{
|
||||
LtsUtils::OperatorSettings::getInstance()->setValue(QStringLiteral("BgViewer"), key, val);
|
||||
}
|
||||
|
||||
BgViewerSettingsView::BgViewerSettingsView(BuildingViewer::BgViewerController *pBgvController,
|
||||
QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_ui(new Ui::BgViewerSettingsUI)
|
||||
, m_pBgvController(pBgvController)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->m_pCheckBoxGlobalIsoMode, &QCheckBox::clicked, this, &BgViewerSettingsView::onViewModeChanged);
|
||||
connect(m_ui->m_pCheckBoxUseDotsMode, &QCheckBox::clicked, this, &BgViewerSettingsView::onPlayerDisplayModeChanged);
|
||||
connect(m_ui->m_pSliderGlobalTransparency, &QSlider::valueChanged, this, &BgViewerSettingsView::onTransparencyChanged);
|
||||
connect(m_ui->m_pSliderPlayerSymbolSize, &QSlider::valueChanged, this, &BgViewerSettingsView::onSymbolSizeChanged);
|
||||
connect(m_ui->m_slider_SymbolFlashing, &QSlider::valueChanged, this, &BgViewerSettingsView::onSymbolFireEventFlashingChanged);
|
||||
connect(m_ui->m_slider_HitlineDuration, &QSlider::valueChanged, this, &BgViewerSettingsView::onHitLineDisplayLengthChanged);
|
||||
|
||||
resetValues();
|
||||
onSymbolFireEventFlashingChanged(m_ui->m_slider_HitlineDuration->value());
|
||||
onHitLineDisplayLengthChanged(m_ui->m_slider_SymbolFlashing->value());
|
||||
|
||||
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &BgViewerSettingsView::accept);
|
||||
connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &BgViewerSettingsView::reject);
|
||||
}
|
||||
|
||||
|
||||
BgViewerSettingsView::~BgViewerSettingsView()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void BgViewerSettingsView::accept()
|
||||
{
|
||||
setSetting(QStringLiteral("GlobalTransparency"), m_ui->m_pSliderGlobalTransparency->value());
|
||||
setSetting(QStringLiteral("UseIsoMode"), m_ui->m_pCheckBoxGlobalIsoMode->isChecked());
|
||||
setSetting(QStringLiteral("UseDotsMode"), m_ui->m_pCheckBoxUseDotsMode->isChecked());
|
||||
setSetting(QStringLiteral("PlayerSymbolSize"), m_ui->m_pSliderPlayerSymbolSize->value());
|
||||
setSetting(QStringLiteral("maxHitlineDurationTime_s"), m_ui->m_slider_HitlineDuration->value());
|
||||
setSetting(QStringLiteral("GearFlashTime_s"), m_ui->m_slider_SymbolFlashing->value());
|
||||
setSetting(QStringLiteral("maxGearFlashTime_s"), m_ui->m_slider_SymbolFlashing->maximum());
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void BgViewerSettingsView::reject()
|
||||
{
|
||||
resetValues();
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
void BgViewerSettingsView::resetValues()
|
||||
{
|
||||
m_ui->m_pSliderGlobalTransparency->setValue(getSetting(QStringLiteral("GlobalTransparency"), 75).toInt());
|
||||
m_ui->m_pCheckBoxGlobalIsoMode->setChecked(getSetting(QStringLiteral("UseIsoMode"), false).toBool());
|
||||
m_ui->m_pCheckBoxUseDotsMode->setChecked(getSetting(QStringLiteral("UseDotsMode"), false).toBool()) ;
|
||||
m_ui->m_pSliderPlayerSymbolSize->setValue(getSetting(QStringLiteral("PlayerSymbolSize"), 20).toInt());
|
||||
m_ui->m_slider_HitlineDuration->setValue(getSetting(QStringLiteral("maxHitlineDurationTime_s"), 10).toInt());
|
||||
m_ui->m_slider_SymbolFlashing->setValue(getSetting(QStringLiteral("GearFlashTime_s"), 10).toInt());
|
||||
}
|
||||
|
||||
void BgViewerSettingsView::onViewModeChanged()
|
||||
{
|
||||
m_pBgvController->excSetGlobalViewMode(m_ui->m_pCheckBoxGlobalIsoMode->isChecked());
|
||||
}
|
||||
|
||||
void BgViewerSettingsView::onPlayerDisplayModeChanged()
|
||||
{
|
||||
m_pBgvController->excSetGlobalDotsMode(m_ui->m_pCheckBoxUseDotsMode->isChecked());
|
||||
}
|
||||
|
||||
void BgViewerSettingsView::onSymbolSizeChanged()
|
||||
{
|
||||
m_pBgvController->updatePlayerSymbols(m_ui->m_pSliderPlayerSymbolSize->value());
|
||||
}
|
||||
|
||||
void BgViewerSettingsView::onTransparencyChanged()
|
||||
{
|
||||
m_pBgvController->excSetGlobalTransparency(m_ui->m_pSliderGlobalTransparency->value());
|
||||
}
|
||||
|
||||
void BgViewerSettingsView::onSymbolFireEventFlashingChanged(int val)
|
||||
{
|
||||
// only modified per config setting...
|
||||
m_ui->m_label_durationSymbolFlashing->setText(tr("%1 sec").arg(val));
|
||||
}
|
||||
|
||||
void BgViewerSettingsView::onHitLineDisplayLengthChanged(int val)
|
||||
{
|
||||
m_pBgvController->excSetHitlineDuration(val);
|
||||
m_ui->m_label_HitlineDuration->setText(tr("%1 sec").arg(val));
|
||||
}
|
||||
|
||||
} // namespace BuildingViewer
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for MeteoDataManagement - Meteo Data Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10-05
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class BgViewerSettingsUI;
|
||||
}
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
class BgViewerController;
|
||||
}
|
||||
|
||||
namespace THP
|
||||
{
|
||||
class BgViewerSettingsView final : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BgViewerSettingsView(BuildingViewer::BgViewerController *pBgvController,
|
||||
QWidget *parent = nullptr);
|
||||
~BgViewerSettingsView();
|
||||
|
||||
private slots:
|
||||
void onViewModeChanged();
|
||||
void onPlayerDisplayModeChanged();
|
||||
void onTransparencyChanged();
|
||||
void onSymbolSizeChanged();
|
||||
void onSymbolFireEventFlashingChanged(int val);
|
||||
void onHitLineDisplayLengthChanged(int val);
|
||||
|
||||
private:
|
||||
void accept() override;
|
||||
void reject() override;
|
||||
void resetValues();
|
||||
|
||||
Ui::BgViewerSettingsUI *m_ui;
|
||||
BuildingViewer::BgViewerController *m_pBgvController;
|
||||
};
|
||||
|
||||
} // namespace BuildingViewer
|
||||
+181
@@ -0,0 +1,181 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BgViewerSettingsUI</class>
|
||||
<widget class="QWidget" name="BgViewerSettingsUI">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">General Settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2" columnstretch="2">
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QSlider" name="m_pSliderGlobalTransparency">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>75</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="m_pCheckBoxGlobalIsoMode">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use orthographic view mode</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Player symbol size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QLabel" name="m_label_durationSymbolFlashing">
|
||||
<property name="text">
|
||||
<string>%1 sec</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QLabel" name="m_label_HitlineDuration">
|
||||
<property name="text">
|
||||
<string>%1 sec</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Symbol fire event flashing:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSlider" name="m_pSliderPlayerSymbolSize">
|
||||
<property name="minimum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>45</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Transparency value:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Hit line display length:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QSlider" name="m_slider_HitlineDuration">
|
||||
<property name="maximum">
|
||||
<number>120</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="m_pCheckBoxUseDotsMode">
|
||||
<property name="text">
|
||||
<string>Use dots mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QSlider" name="m_slider_SymbolFlashing">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>120</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Handle bulding display in thp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "thp_building_widget.h"
|
||||
#include "ui_thp_situation_building_base.h"
|
||||
#include "thp_building_settings.h"
|
||||
#include "thp_plugin_provider.h"
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
#include <BuildingViewer/Common/bdv_controller.h>
|
||||
#include <BuildingViewer/Common/bdv_plugin_provider.h>
|
||||
#include <LtsScriptTimeline/track_entry.h>
|
||||
#include <LtsWidgets/lts_dialog_helper.h>
|
||||
|
||||
#include <SituationReplay/handler_situation_replay_sqlite.h>
|
||||
|
||||
namespace THP
|
||||
{
|
||||
using namespace SituationReplay;
|
||||
|
||||
BuildingWidget::BuildingWidget(QWidget *parent)
|
||||
: SituationBuildingBase("THP.BuildingWidget", parent)
|
||||
{
|
||||
QMenu *m = new QMenu(m_ui->btnFilter);
|
||||
m->addAction(tr("Global Settings"), this, &BuildingWidget::onGlobalSettings);
|
||||
m_ui->btnFilter->setMenu(m);
|
||||
}
|
||||
|
||||
BuildingWidget::~BuildingWidget()
|
||||
{
|
||||
delete m_bgvController;
|
||||
}
|
||||
|
||||
bool BuildingWidget::init(SituationReplay::MainHandlerSqlite *mhs, BuildingPluginProvider *pp, const QString &homePath)
|
||||
{
|
||||
if (!SituationBuildingBase::init(mhs))
|
||||
return false;
|
||||
m_replayHandler = mhs;
|
||||
m_pluginProvider = pp;
|
||||
|
||||
// parse json, create xml, init buildingviewer
|
||||
delete m_bgvController;
|
||||
m_bgvController = new BuildingViewer::BgViewerController(this);
|
||||
if (!m_bgvController->init(m_pluginProvider, true, homePath + QStringLiteral("/BuildingModels/")))
|
||||
return false;
|
||||
|
||||
auto w = m_bgvController->getBgViewerWidget();
|
||||
w->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
m_ui->vLayout->insertWidget(0, w);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BuildingWidget::showSituationInternal()
|
||||
{
|
||||
m_bgvController->excRestoreViewState(m_attributes[QStringLiteral("arrBuildingStates")]);
|
||||
if (!SituationBuildingBase::showSituationInternal())
|
||||
return false;
|
||||
onInitDone();
|
||||
return true;
|
||||
}
|
||||
|
||||
void BuildingWidget::emitPartitionTimeChanged(qint64 curTime)
|
||||
{
|
||||
m_pluginProvider->emitPartitionTimeChanged(curTime);
|
||||
}
|
||||
|
||||
void BuildingWidget::onGlobalSettings()
|
||||
{
|
||||
if (!m_globalSettingsDialog)
|
||||
m_globalSettingsDialog = new BgViewerSettingsView(m_bgvController, this);
|
||||
m_globalSettingsDialog->show();
|
||||
}
|
||||
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Handle bulding display in thp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <SituationReplay/main_handler_sqlite.h>
|
||||
#include "thp_situation_building_base.h"
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
class BgViewerController;
|
||||
}
|
||||
namespace Ui
|
||||
{
|
||||
class BuildingWidget;
|
||||
}
|
||||
namespace THP
|
||||
{
|
||||
class BuildingPluginProvider;
|
||||
class BgViewerSettingsView;
|
||||
class BuildingWidget : public SituationBuildingBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
BuildingWidget(QWidget *parent = nullptr);
|
||||
~BuildingWidget();
|
||||
|
||||
bool init(SituationReplay::MainHandlerSqlite *mhs,
|
||||
BuildingPluginProvider *pp,
|
||||
const QString &homePath);
|
||||
|
||||
protected:
|
||||
bool showSituationInternal() override;
|
||||
void emitPartitionTimeChanged(qint64 curTime) override;
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onGlobalSettings();
|
||||
virtual void applyCurentFilter(const SituationReplay::FilterInformation &) override {}
|
||||
virtual void applyNewOverlay(int) override {}
|
||||
virtual void removeOverlay(int) override {}
|
||||
private:
|
||||
BuildingPluginProvider *m_pluginProvider = nullptr;
|
||||
BuildingViewer::BgViewerController *m_bgvController = nullptr;
|
||||
BgViewerSettingsView *m_globalSettingsDialog = nullptr;
|
||||
};
|
||||
} // namespace THP
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Handle HTML output for thp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#include "thp_html_widget.h"
|
||||
#include "ui_thp_html_widget.h"
|
||||
|
||||
#include <QUrl>
|
||||
#include <QWebEnginePage>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
|
||||
namespace THP
|
||||
{
|
||||
|
||||
class MyQWebEnginePage : public QWebEnginePage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MyQWebEnginePage(NGL::INGLLogger &logger, QObject *parent = nullptr)
|
||||
: QWebEnginePage(parent)
|
||||
, m_logger(logger)
|
||||
{}
|
||||
MyQWebEnginePage(NGL::INGLLogger &logger, QWebEngineProfile *profile, QObject *parent = nullptr)
|
||||
: QWebEnginePage(profile, parent)
|
||||
, m_logger(logger)
|
||||
{}
|
||||
|
||||
bool needsToBeOpenedExternally(const QUrl &url)
|
||||
{
|
||||
const QString lpath = url.toString();
|
||||
const QStringRef ext = lpath.splitRef(QLatin1Char('.')).last();
|
||||
const QStringRef ext2Chars = ext.left(2);
|
||||
if (ext == QLatin1String("html") &&
|
||||
lpath.midRef(lpath.lastIndexOf(QLatin1Char('/')) + 1).startsWith(QLatin1String("combined_")))
|
||||
return true;
|
||||
// PDF
|
||||
if (ext == QLatin1String("pdf"))
|
||||
return true;
|
||||
// A/V playlist
|
||||
if (ext == QLatin1String("pls"))
|
||||
return true;
|
||||
// Situation
|
||||
if (ext == QLatin1String("json"))
|
||||
return true;
|
||||
// Word/Excel/PowerPoint
|
||||
if (ext2Chars == QLatin1String("do") ||
|
||||
ext2Chars == QLatin1String("xl") ||
|
||||
ext2Chars == QLatin1String("pp"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool acceptNavigationRequest(const QUrl &url,
|
||||
QWebEnginePage::NavigationType type,
|
||||
bool isMainFrame) override
|
||||
{
|
||||
Q_UNUSED(isMainFrame)
|
||||
if (type == QWebEnginePage::NavigationTypeLinkClicked)
|
||||
{
|
||||
if (needsToBeOpenedExternally(url))
|
||||
{
|
||||
emit linkClicked(url);
|
||||
DEBUG_LOG(m_logger) << "acceptNavigationRequest denied for " << url.toString();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "acceptNavigationRequest allowed for " << url.toString();
|
||||
return true;
|
||||
}
|
||||
|
||||
Q_SIGNALS:
|
||||
void linkClicked(const QUrl &url);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
|
||||
HtmlWidget::HtmlWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::HtmlWidget)
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("THP.HtmlWidget"))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
auto webEnginePage = new MyQWebEnginePage(m_logger, this);
|
||||
ui->html->setPage(webEnginePage);
|
||||
connect(webEnginePage, &MyQWebEnginePage::linkClicked, this, &HtmlWidget::linkClicked);
|
||||
connect(ui->html, &QWebEngineView::loadFinished, this, &HtmlWidget::loadFinished);
|
||||
connect(ui->html, &QWebEngineView::urlChanged, this, &HtmlWidget::urlChanged);
|
||||
connect(ui->html, &QWebEngineView::titleChanged, this, &HtmlWidget::titleChanged);
|
||||
}
|
||||
|
||||
HtmlWidget::~HtmlWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void HtmlWidget::back()
|
||||
{
|
||||
ui->html->back();
|
||||
}
|
||||
|
||||
QString HtmlWidget::title() const
|
||||
{
|
||||
return ui->html->title();
|
||||
}
|
||||
|
||||
QUrl HtmlWidget::url() const
|
||||
{
|
||||
return ui->html->url();
|
||||
}
|
||||
|
||||
bool HtmlWidget::showHTML(const QUrl &url)
|
||||
{
|
||||
if (!url.isValid())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Invalid url: " << url.toString();
|
||||
return false;
|
||||
}
|
||||
ui->html->load(url);
|
||||
return true;
|
||||
}
|
||||
|
||||
void HtmlWidget::setZoomFactor(double newZoomFactor)
|
||||
{
|
||||
ui->html->setZoomFactor(newZoomFactor);
|
||||
}
|
||||
|
||||
void HtmlWidget::print(QPrinter *printer) const
|
||||
{
|
||||
ui->html->page()->print(printer, [](bool) {});
|
||||
}
|
||||
|
||||
} // namespace THP
|
||||
|
||||
#include "thp_html_widget.moc"
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Handle HTML output for thp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
#include <QWidget>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
class QUrl;
|
||||
class QPrinter;
|
||||
namespace Ui
|
||||
{
|
||||
class HtmlWidget;
|
||||
}
|
||||
|
||||
namespace THP
|
||||
{
|
||||
class HtmlWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit HtmlWidget(QWidget *parent = nullptr);
|
||||
~HtmlWidget();
|
||||
|
||||
void back();
|
||||
void print(QPrinter *printer) const;
|
||||
void setZoomFactor(double newZoomFactor);
|
||||
QString title() const;
|
||||
QUrl url() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
bool showHTML(const QUrl &url);
|
||||
|
||||
Q_SIGNALS:
|
||||
void linkClicked(const QUrl &link);
|
||||
void loadFinished(bool);
|
||||
void urlChanged(const QUrl &url);
|
||||
void titleChanged(const QString &title);
|
||||
protected:
|
||||
Ui::HtmlWidget *ui;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
} // namespace THP
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>HtmlWidget</class>
|
||||
<widget class="QWidget" name="HtmlWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>719</width>
|
||||
<height>540</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWebEngineView" name="html">
|
||||
<property name="url">
|
||||
<url>
|
||||
<string>about:blank</string>
|
||||
</url>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QWebEngineView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">QtWebEngineWidgets/QWebEngineView</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Handle PDF output for thp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#include "thp_pdf_widget.h"
|
||||
#include "ui_thp_pdf_widget.h"
|
||||
|
||||
namespace THP
|
||||
{
|
||||
|
||||
PdfWidget::PdfWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::PdfWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->previousPage, &QToolButton::clicked, this, &PdfWidget::onPreviousPage);
|
||||
connect(ui->nextPage, &QToolButton::clicked, this, &PdfWidget::onNextPage);
|
||||
connect(ui->pdfDocument, &NGL::PDFDocument::currentPageChanged, this, &PdfWidget::pageChanged);
|
||||
}
|
||||
|
||||
PdfWidget::~PdfWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
bool PdfWidget::showPDF(const QUrl &pdf)
|
||||
{
|
||||
return ui->pdfDocument->showPDF(pdf);
|
||||
}
|
||||
|
||||
void PdfWidget::setZoomFactor(double newZoomFactor)
|
||||
{
|
||||
ui->pdfDocument->setZoomFactor(newZoomFactor);
|
||||
}
|
||||
|
||||
void PdfWidget::onPreviousPage()
|
||||
{
|
||||
ui->pdfDocument->previousPage();
|
||||
}
|
||||
|
||||
void PdfWidget::onNextPage()
|
||||
{
|
||||
ui->pdfDocument->nextPage();
|
||||
}
|
||||
|
||||
QVector<QImage> PdfWidget::getPrintableImages(int resolution)
|
||||
{
|
||||
return ui->pdfDocument->getPrintableImages(resolution);
|
||||
}
|
||||
|
||||
void PdfWidget::resizePdfToWidth()
|
||||
{
|
||||
ui->pdfDocument->resizePdfToWidth();
|
||||
}
|
||||
|
||||
void PdfWidget::pageChanged(int cur, int max)
|
||||
{
|
||||
ui->pageLabel->setText(tr("Page %1 of %2").arg(cur).arg(max));
|
||||
ui->nextPage->setEnabled(cur < max);
|
||||
ui->previousPage->setEnabled(cur > 1);
|
||||
}
|
||||
|
||||
} // namespace THP
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Handle PDF output for thp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
class QUrl;
|
||||
namespace Ui
|
||||
{
|
||||
class PdfWidget;
|
||||
}
|
||||
|
||||
namespace THP
|
||||
{
|
||||
class PdfWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PdfWidget(QWidget *parent = nullptr);
|
||||
~PdfWidget();
|
||||
|
||||
bool showPDF(const QUrl &pdf);
|
||||
void setZoomFactor(double newZoomFactor);
|
||||
QVector<QImage> getPrintableImages(int resolution = 300);
|
||||
void resizePdfToWidth();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onPreviousPage();
|
||||
void onNextPage();
|
||||
void pageChanged(int cur, int max);
|
||||
protected:
|
||||
|
||||
Ui::PdfWidget *ui;
|
||||
};
|
||||
} // namespace THP
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PdfWidget</class>
|
||||
<widget class="QWidget" name="PdfWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>580</width>
|
||||
<height>396</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="NGL::PDFDocument" name="pdfDocument" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>202</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QToolButton" name="previousPage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:icons/16x16/go-previous.png</normaloff>:icons/16x16/go-previous.png</iconset>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+P</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>5</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="pageLabel">
|
||||
<property name="text">
|
||||
<string>page %1 of %2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>5</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="nextPage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:icons/16x16/go-next.png</normaloff>:icons/16x16/go-next.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+N</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>201</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>NGL::PDFDocument</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">nglwidgets/nglpdfdocument.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Executable
+488
@@ -0,0 +1,488 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Handle situation display in thp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "thp_situation_building_base.h"
|
||||
#include "ui_thp_situation_building_base.h"
|
||||
|
||||
#include "thp_situation_filter_aes.h"
|
||||
#include "thp_situation_filter_symbol_appearance.h"
|
||||
#include "thp_situation_filter_collapse_expand.h"
|
||||
#include "thp_situation_filter_types.h"
|
||||
#include "thp_plugin_provider.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonParseError>
|
||||
#include <QTimer>
|
||||
#include <LtsScriptTimeline/track_entry.h>
|
||||
#include <LtsUtilsCore/qpoint3d.h>
|
||||
|
||||
#include <SituationReplay/handler_situation_replay_sqlite.h>
|
||||
#include <PlanOverlays/Gui/plan_overlay_model.h>
|
||||
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
namespace THP
|
||||
{
|
||||
|
||||
using namespace SituationReplay;
|
||||
|
||||
SituationBuildingBase::SituationBuildingBase(const char *loggerName,
|
||||
QWidget *parent)
|
||||
: QFrame(parent)
|
||||
, m_playTimer(new QTimer(this))
|
||||
, m_ui(new Ui::SituationBuildingBase)
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger(loggerName))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->zoomSlider->hide();
|
||||
m_ui->sldPosition->setMinimum(0);
|
||||
m_ui->sldPosition->setMaximum(s_sliderMax);
|
||||
|
||||
m_playTimer->setSingleShot(true);
|
||||
connect(m_playTimer, &QTimer::timeout, this, &SituationBuildingBase::onPlay);
|
||||
|
||||
connect(m_ui->btnSlower, &QToolButton::clicked, this, &SituationBuildingBase::onSlower);
|
||||
connect(m_ui->btnFaster, &QToolButton::clicked, this, &SituationBuildingBase::onFaster);
|
||||
connect(m_ui->btn100pct, &QToolButton::clicked, this, &SituationBuildingBase::on100pct);
|
||||
connect(m_ui->btnPlay, &QToolButton::clicked, this, &SituationBuildingBase::onPlay);
|
||||
connect(m_ui->btnStop, &QToolButton::clicked, this, &SituationBuildingBase::onStop);
|
||||
|
||||
connect(m_ui->sldPosition, &QSlider::sliderPressed, this, &SituationBuildingBase::onSliderPressed);
|
||||
connect(m_ui->sldPosition, &QSlider::sliderMoved, this, &SituationBuildingBase::onSliderPositionChanged);
|
||||
connect(m_ui->sldPosition, &QSlider::sliderReleased, this, &SituationBuildingBase::onSliderReleased);
|
||||
|
||||
connect(m_ui->cbPlaybackParts, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, &SituationBuildingBase::onCbPlaybackPartsChanged);
|
||||
}
|
||||
|
||||
SituationBuildingBase::~SituationBuildingBase()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool SituationBuildingBase::init(SituationReplay::MainHandlerSqlite *replayHandler)
|
||||
{
|
||||
if (m_replayHandler)
|
||||
m_replayHandler->disconnect(this);
|
||||
m_replayHandler = replayHandler;
|
||||
connect(m_replayHandler, &SituationReplay::MainHandlerSqlite::initialReplaySpeed,
|
||||
this, &SituationBuildingBase::setSpeed);
|
||||
connect(m_replayHandler, &SituationReplay::MainHandlerSqlite::applyCurentFilter,
|
||||
this, &SituationBuildingBase::applyCurentFilter);
|
||||
connect(m_replayHandler, &SituationReplay::MainHandlerSqlite::applyNewOverlay,
|
||||
this, &SituationBuildingBase::applyNewOverlay);
|
||||
connect(m_replayHandler, &SituationReplay::MainHandlerSqlite::removeOverlay,
|
||||
this, &SituationBuildingBase::removeOverlay);
|
||||
connect(m_replayHandler, &SituationReplay::MainHandlerSqlite::fileContentAvailable,
|
||||
this, &SituationBuildingBase::onFileContentAvailable);
|
||||
updatePositionLabel(LtsUtils::QPoint3D(), false);
|
||||
updateSpeedLabel();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SituationBuildingBase::showSituation(const QString &sitReplayDescription,
|
||||
const QString &basePath)
|
||||
{
|
||||
// read ReplayInformation from sitmap.json (key 'replays')
|
||||
|
||||
QFile f(sitReplayDescription); // ...Exercise_123//n/m/sitmap.json
|
||||
if (!f.open(QIODevice::ReadOnly))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Can not open file '" << sitReplayDescription << "': " << f.errorString();
|
||||
return false;
|
||||
}
|
||||
|
||||
QFileInfo fi(f);
|
||||
m_scriptPath = fi.absolutePath();
|
||||
|
||||
QJsonParseError jError;
|
||||
const QByteArray ba = f.readAll();
|
||||
QJsonDocument doc(QJsonDocument::fromJson(ba, &jError));
|
||||
if (jError.error)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Can not parse json document: " << jError.errorString();
|
||||
return false;
|
||||
}
|
||||
const QJsonObject rootObj = doc.object();
|
||||
const QJsonArray arrReplays(rootObj[QStringLiteral("replays")].toArray());
|
||||
QVector<ReplayInformation> replayInformation;
|
||||
replayInformation.reserve(arrReplays.size());
|
||||
for (const auto &val : arrReplays)
|
||||
{
|
||||
const QJsonObject obj = val.toObject();
|
||||
const QJsonObject objPb = obj[QStringLiteral("playbackTime")].toObject();
|
||||
const QJsonObject objSqlite = obj[QStringLiteral("replayInformation")].toObject();
|
||||
const QJsonObject objTip = objSqlite[QStringLiteral("timeInPresentation")].toObject();
|
||||
ReplayInformation info;
|
||||
info.id = obj[QStringLiteral("id")].toInt();
|
||||
info.timeSpan = TimeSpan::fromJson(objPb);
|
||||
info.relativeTimeSpan = TimeSpan::fromJson(objTip);
|
||||
const int sqliteFolderId = objSqlite[QStringLiteral("id")].toInt();
|
||||
info.databaseFilePath = QStringLiteral("%1/%2/sitreplay.sqlite").arg(basePath).arg(sqliteFolderId);
|
||||
info.replayConfigPath = QStringLiteral("%1/%2/sitreplay.json").arg(basePath).arg(sqliteFolderId);
|
||||
if (info.relativeTimeSpan.begin < 0 ||
|
||||
info.relativeTimeSpan.end <= info.relativeTimeSpan.begin ||
|
||||
sqliteFolderId == 0)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Can not parse json document: " << QJsonDocument(obj).toJson();
|
||||
return false;
|
||||
}
|
||||
replayInformation.push_back(std::move(info));
|
||||
}
|
||||
const QJsonObject attributes(rootObj[QStringLiteral("attributes")].toObject());
|
||||
const QJsonArray arrFilters1(attributes[QStringLiteral("Filters")].toArray());
|
||||
QVector<FilterInformation> filterInformation;
|
||||
QVector<FilterInformation> overlayInformation;
|
||||
|
||||
for (const auto &arrVal : arrFilters1)
|
||||
{
|
||||
// const QJsonArray arrFilters2(arrVal.toArray());
|
||||
// for (const auto &val : arrFilters2)
|
||||
// {
|
||||
FilterInformation filter;
|
||||
const QJsonObject obj = arrVal.toObject();
|
||||
LtsScriptTimeline::TrackEntry te;
|
||||
te.fromJson(obj);
|
||||
if (te.m_topicId <= 0)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Can not load filter information from '" << QJsonDocument(obj).toJson() << "'";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (te.m_type != LtsScriptTimeline::TrackEntryType::SituationMapFilter &&
|
||||
te.m_type != LtsScriptTimeline::TrackEntryType::TacticalPlan)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Unknown Filter type " << te.m_type << " - ignoring: " << QJsonDocument(obj).toJson() << "'";
|
||||
continue;
|
||||
}
|
||||
|
||||
filter.id = te.m_topicId;
|
||||
filter.relativeTimeSpan.begin = te.m_startTime * 1000LL;
|
||||
filter.relativeTimeSpan.end = te.m_length * 1000LL + filter.relativeTimeSpan.begin;
|
||||
const QJsonObject details = obj[QStringLiteral("detailData")].toObject();
|
||||
if (te.m_type == LtsScriptTimeline::TrackEntryType::SituationMapFilter)
|
||||
{
|
||||
const QJsonObject filters = te.m_detailData[QStringLiteral("filters")].toObject();
|
||||
filter.aesFilters = filters[QStringLiteral("AesFilterJson")].toObject();
|
||||
filter.symbolSettings = filters[QStringLiteral("SymbolAppearanceJson")].toObject();
|
||||
filter.buildingComponentSettings = filters[QStringLiteral("BuildingComponentSettingsJson")].toObject();
|
||||
filter.mapSettings = details[QStringLiteral("settings")].toObject();
|
||||
|
||||
if (filter.relativeTimeSpan.begin < 0 || filter.aesFilters.isEmpty() || filter.symbolSettings.isEmpty())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Can not parse json document - can not read filter data " << QJsonDocument(obj).toJson();
|
||||
return false;
|
||||
}
|
||||
if (filter.buildingComponentSettings.isEmpty())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Can not parse json document - can not read filter data 'BuildingComponentSettingsJson', json= " << QJsonDocument(obj).toJson();
|
||||
// return false; // support older thps with this thpViewer
|
||||
}
|
||||
|
||||
|
||||
filterInformation.push_back(std::move(filter));
|
||||
}
|
||||
else if (te.m_type == LtsScriptTimeline::TrackEntryType::TacticalPlan)
|
||||
{
|
||||
if (filter.relativeTimeSpan.begin < 0)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Can not parse json document - can not read filter data " << QJsonDocument(obj).toJson();
|
||||
return false;
|
||||
}
|
||||
|
||||
// old version (before 2020/02)
|
||||
filter.overlayId = details[QStringLiteral("FileId")].toInt(-1);
|
||||
if (filter.overlayId >= 0)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Add overlay with id " << filter.overlayId;
|
||||
overlayInformation.push_back(std::move(filter));
|
||||
continue;
|
||||
}
|
||||
const QJsonArray arr = details[QStringLiteral("PlanItems")].toArray();
|
||||
if (arr.isEmpty())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "No PlanItems given - " << QJsonDocument(details).toJson();
|
||||
}
|
||||
for (const auto &ele : arr)
|
||||
{
|
||||
const auto pi = PlanOverlaysPlugin::PlanOverlayModel::PlanItem::fromJson(ele.toObject());
|
||||
if (!pi.isValid() || pi.m_fileId <= 0)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Can not parse json document - can not read filter data " << QJsonDocument(ele.toObject()).toJson();
|
||||
return false;
|
||||
}
|
||||
filter.overlayId = pi.m_fileId;
|
||||
DEBUG_LOG(m_logger) << "Add overlay with id " << filter.overlayId;
|
||||
overlayInformation.push_back(filter);
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
m_replayInformation = replayInformation;
|
||||
m_filterInformation = filterInformation;
|
||||
m_overlayInformation = overlayInformation;
|
||||
m_attributes = rootObj[QStringLiteral("attributes")].toObject();
|
||||
return showSituationInternal();
|
||||
}
|
||||
|
||||
bool SituationBuildingBase::showSituationInternal()
|
||||
{
|
||||
m_ui->cbPlaybackParts->setVisible(m_replayInformation.size() > 1);
|
||||
if (m_replayInformation.isEmpty())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "No replay information given...";
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString sqliteDb = m_replayInformation.first().databaseFilePath;
|
||||
if (sqliteDb.isEmpty())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "No database given...";
|
||||
return false;
|
||||
}
|
||||
QFileInfo fi(sqliteDb);
|
||||
if (!fi.exists() || !fi.isFile() || !fi.isReadable())
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
WARNING_LOG(m_logger) << "Can not access sqlite database '" << fi.absoluteFilePath() << "'";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ui->cbPlaybackParts->clear();
|
||||
m_ui->cbPlaybackParts->blockSignals(true);
|
||||
for (int i = 0; i < m_replayInformation.size(); ++i)
|
||||
{
|
||||
const ReplayInformation &info = m_replayInformation.at(i);
|
||||
m_ui->cbPlaybackParts->addItem(QStringLiteral("%1: %2 - %3").arg(i+1).arg(DTG::toStringMSec(info.timeSpan.begin, DTG::Long),
|
||||
DTG::toStringMSec(info.timeSpan.end, DTG::Long)), i);
|
||||
}
|
||||
m_ui->cbPlaybackParts->setCurrentIndex(0);
|
||||
m_ui->cbPlaybackParts->blockSignals(false);
|
||||
onCbPlaybackPartsChanged(); // creates replayHandler for correct db etc.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SituationBuildingBase::setSpeed(double newSpeed)
|
||||
{
|
||||
m_speedVal = qBound(0.0, newSpeed, 16.0);
|
||||
if (m_replayHandler->handlerSrp())
|
||||
m_replayHandler->handlerSrp()->onPaceChangeRequest(m_speedVal);
|
||||
|
||||
updateSpeedLabel();
|
||||
}
|
||||
|
||||
void SituationBuildingBase::onSlower()
|
||||
{
|
||||
// cur speed = 9 -> new speed = 7
|
||||
// cur speed = 4 -> new speed = 3
|
||||
int diff = lrint(sqrt(m_speedVal) - 1);
|
||||
if (diff < 1)
|
||||
diff = 1;
|
||||
setSpeed(m_speedVal - diff);
|
||||
}
|
||||
|
||||
void SituationBuildingBase::onFaster()
|
||||
{
|
||||
int diff = lrint(sqrt(m_speedVal) - 1);
|
||||
if (diff < 1)
|
||||
diff = 1;
|
||||
setSpeed(m_speedVal + diff);
|
||||
}
|
||||
|
||||
void SituationBuildingBase::on100pct()
|
||||
{
|
||||
setSpeed(1.0);
|
||||
}
|
||||
|
||||
void SituationBuildingBase::onPlay()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "OnPlay " << int(m_state);
|
||||
switch (m_state)
|
||||
{
|
||||
case State::PS_STOP:
|
||||
m_state = State::PS_PLAY;
|
||||
if (m_replayHandler->handlerSrp())
|
||||
m_replayHandler->handlerSrp()->onStartReplayRequest(m_speedVal);
|
||||
break;
|
||||
case State::PS_PAUSE:
|
||||
m_state = State::PS_PLAY;
|
||||
if (m_replayHandler->handlerSrp())
|
||||
m_replayHandler->handlerSrp()->onResumeReplayRequest();
|
||||
break;
|
||||
case State::PS_PLAY:
|
||||
m_state = State::PS_PAUSE;
|
||||
if (m_replayHandler->handlerSrp())
|
||||
m_replayHandler->handlerSrp()->onPauseReplayRequest();
|
||||
break;
|
||||
case State::PS_UNDEFINED:
|
||||
// dürfte nicht vorkommen
|
||||
break;
|
||||
}
|
||||
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
void SituationBuildingBase::onStop()
|
||||
{
|
||||
auto srp = m_replayHandler->handlerSrp();
|
||||
if (srp)
|
||||
{
|
||||
srp->onStopReplayRequest();
|
||||
onUpdateTimeSlider(srp->beginTime());
|
||||
}
|
||||
m_state = State::PS_STOP;
|
||||
updateButtons();
|
||||
m_ui->sldPosition->setValue(0);
|
||||
}
|
||||
|
||||
void SituationBuildingBase::onSliderPressed()
|
||||
{
|
||||
if (m_replayHandler->handlerSrp())
|
||||
m_replayHandler->handlerSrp()->onPauseReplayRequest();
|
||||
m_state = State::PS_PAUSE;
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
void SituationBuildingBase::onSliderPositionChanged(int newPosition)
|
||||
{
|
||||
if (!m_replayHandler->handlerSrp())
|
||||
return;
|
||||
auto srp = m_replayHandler->handlerSrp();
|
||||
const double len = (srp->endTime() - srp->beginTime());
|
||||
const double ofs = newPosition * len / s_sliderMax;
|
||||
m_sliderMoveTime = qRound64(srp->beginTime() + ofs);
|
||||
|
||||
m_currentTimeDTGString = DTG::toStringMSec(m_sliderMoveTime, DTG::Long);
|
||||
m_ui->lblPosition->setText(m_currentTimeDTGString);
|
||||
}
|
||||
|
||||
void SituationBuildingBase::onSliderReleased()
|
||||
{
|
||||
if (m_replayHandler->handlerSrp())
|
||||
m_replayHandler->handlerSrp()->onStartReplayRequest(m_sliderMoveTime,
|
||||
m_replayHandler->handlerSrp()->endTime(),
|
||||
m_speedVal);
|
||||
m_state = State::PS_PLAY;
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
void SituationBuildingBase::onUpdateTimeSlider(qint64 curTime)
|
||||
{
|
||||
if (!m_replayHandler->handlerSrp() || m_state == State::PS_STOP)
|
||||
return;
|
||||
const auto srp = m_replayHandler->handlerSrp();
|
||||
const double len = (srp->endTime() - srp->beginTime());
|
||||
const double ofs = (curTime - srp->beginTime());
|
||||
double pos = ofs / len * s_sliderMax;
|
||||
if (pos < 0)
|
||||
pos = 0;
|
||||
if (pos >= s_sliderMax)
|
||||
{
|
||||
onStop();
|
||||
return;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "onUpdateTimeSlider: " << curTime << ", pos: " << pos;
|
||||
m_ui->sldPosition->setValue(qRound(pos));
|
||||
|
||||
m_currentTimeDTGString = DTG::toStringMSec(curTime, DTG::Long);
|
||||
m_ui->lblPosition->setText(m_currentTimeDTGString);
|
||||
emitPartitionTimeChanged(curTime);
|
||||
}
|
||||
|
||||
void SituationBuildingBase::onCbPlaybackPartsChanged()
|
||||
{
|
||||
onStop();
|
||||
int idx = m_ui->cbPlaybackParts->currentData().toInt();
|
||||
if (idx < 0 || idx >= m_replayInformation.size())
|
||||
return;
|
||||
const ReplayInformation &info = m_replayInformation.at(idx);
|
||||
if (!m_replayHandler->initDb(info, m_filterInformation, m_overlayInformation))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Can not initialize replay handler (" << info.databaseFilePath << ")";
|
||||
return;
|
||||
}
|
||||
|
||||
// currently after initDb since there handlerSrp is (re)created
|
||||
connect(m_replayHandler->handlerSrp().get(), &SituationReplay::HandlerSituationReplaySqlite::replayTimeChanged,
|
||||
this, &SituationBuildingBase::onUpdateTimeSlider, Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
void SituationBuildingBase::updateSpeedLabel()
|
||||
{
|
||||
QString speedStr = QStringLiteral("%1x").arg(m_speedVal, 4, 'f', 2);
|
||||
m_ui->lblSpeed->setText(speedStr);
|
||||
}
|
||||
|
||||
void SituationBuildingBase::updatePositionLabel(const LtsUtils::QPoint3D &geoPos, bool isValid)
|
||||
{
|
||||
if (isValid)
|
||||
{
|
||||
const LtsCoordTrans::UtmCoordinate coord(LtsCoordTrans::UtmCoordinate::fromGeographic(geoPos.x(), geoPos.y()));
|
||||
m_ui->lblCursorPos->setText(coord.mgrs());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->lblCursorPos->setText(QString());
|
||||
}
|
||||
}
|
||||
|
||||
QString SituationBuildingBase::currentDTGTime() const
|
||||
{
|
||||
return m_currentTimeDTGString;
|
||||
}
|
||||
|
||||
void SituationBuildingBase::updateButtons()
|
||||
{
|
||||
switch (m_state)
|
||||
{
|
||||
case State::PS_UNDEFINED:
|
||||
m_ui->btnStop->setEnabled(false);
|
||||
m_ui->btnPlay->setEnabled(false);
|
||||
m_ui->btnPlay->setIcon(QIcon(QStringLiteral(":icons/16x16/media-playback-start.png")));
|
||||
m_ui->sldPosition->setEnabled(false);
|
||||
break;
|
||||
case State::PS_STOP:
|
||||
m_ui->btnStop->setEnabled(false);
|
||||
m_ui->btnPlay->setEnabled(true);
|
||||
m_ui->btnPlay->setIcon(QIcon(QStringLiteral(":icons/16x16/media-playback-start.png")));
|
||||
m_ui->sldPosition->setEnabled(true);
|
||||
break;
|
||||
case State::PS_PLAY:
|
||||
m_ui->btnStop->setEnabled(true);
|
||||
m_ui->btnPlay->setEnabled(true);
|
||||
m_ui->btnPlay->setIcon(QIcon(QStringLiteral(":icons/16x16/media-playback-pause.png")));
|
||||
m_ui->sldPosition->setEnabled(true);
|
||||
break;
|
||||
case State::PS_PAUSE:
|
||||
m_ui->btnStop->setEnabled(true);
|
||||
m_ui->btnPlay->setEnabled(true);
|
||||
m_ui->btnPlay->setIcon(QIcon(QStringLiteral(":icons/16x16/media-playback-start.png")));
|
||||
m_ui->sldPosition->setEnabled(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool SituationBuildingBase::stop()
|
||||
{
|
||||
onStop();
|
||||
return true;
|
||||
}
|
||||
|
||||
void SituationBuildingBase::onInitDone()
|
||||
{
|
||||
m_state = State::PS_STOP;
|
||||
m_playTimer->start();
|
||||
}
|
||||
|
||||
} // namespace THP
|
||||
Executable
+105
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Handle situation / building display in thp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QFrame>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <SituationReplay/main_handler_sqlite.h>
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
namespace Database
|
||||
{
|
||||
struct FlmFileContent;
|
||||
}
|
||||
}
|
||||
|
||||
namespace SituationReplay
|
||||
{
|
||||
class MainHandlerSqlite;
|
||||
}
|
||||
namespace LtsUtils
|
||||
{
|
||||
class QPoint3D;
|
||||
}
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class SituationBuildingBase;
|
||||
}
|
||||
namespace THP
|
||||
{
|
||||
enum class State
|
||||
{
|
||||
PS_UNDEFINED = 0,
|
||||
PS_STOP = 1,
|
||||
PS_PLAY = 2,
|
||||
PS_PAUSE = 3
|
||||
};
|
||||
constexpr int s_sliderMax = 1000; // 0 .. 1000
|
||||
|
||||
class SituationBuildingBase : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SituationBuildingBase(const char *loggerName,
|
||||
QWidget *parent = nullptr);
|
||||
~SituationBuildingBase();
|
||||
|
||||
bool init(SituationReplay::MainHandlerSqlite *replayHandler);
|
||||
bool showSituation(const QString &sitReplayDescription, const QString &basePath);
|
||||
|
||||
void updateButtons();
|
||||
bool stop();
|
||||
QString currentDTGTime() const;
|
||||
|
||||
protected:
|
||||
virtual bool showSituationInternal();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void setSpeed(double newSpeed);
|
||||
virtual void applyCurentFilter(const SituationReplay::FilterInformation &filter) = 0;
|
||||
virtual void applyNewOverlay(int overlayId) = 0;
|
||||
virtual void removeOverlay(int overlayId) = 0;
|
||||
void onSlower();
|
||||
void onFaster();
|
||||
void on100pct();
|
||||
void onPlay();
|
||||
void onStop();
|
||||
|
||||
void onSliderPressed();
|
||||
void onSliderPositionChanged(int newPosition);
|
||||
void onSliderReleased();
|
||||
void updateSpeedLabel();
|
||||
void onUpdateTimeSlider(qint64 curTime);
|
||||
void onCbPlaybackPartsChanged();
|
||||
void updatePositionLabel(const LtsUtils::QPoint3D &geoPos, bool isValid);
|
||||
virtual void updateZoomSlider() {}
|
||||
|
||||
virtual void onInitDone();
|
||||
virtual void emitPartitionTimeChanged(qint64 curTime) = 0;
|
||||
|
||||
virtual void onFileContentAvailable(const FileManagement::Database::FlmFileContent &) {}
|
||||
protected:
|
||||
QVector<SituationReplay::ReplayInformation> m_replayInformation;
|
||||
QVector<SituationReplay::FilterInformation> m_filterInformation;
|
||||
QVector<SituationReplay::FilterInformation> m_overlayInformation;
|
||||
QJsonObject m_attributes;
|
||||
QString m_scriptPath; // sitmap.json
|
||||
double m_speedVal = 1;
|
||||
State m_state = State::PS_STOP;
|
||||
QTimer *m_playTimer = nullptr;
|
||||
SituationReplay::MainHandlerSqlite *m_replayHandler = nullptr;
|
||||
|
||||
QString m_currentTimeDTGString;
|
||||
qint64 m_sliderMoveTime = 0;
|
||||
|
||||
Ui::SituationBuildingBase *m_ui;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
} // namespace THP
|
||||
Executable
+234
@@ -0,0 +1,234 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SituationBuildingBase</class>
|
||||
<widget class="QFrame" name="SituationBuildingBase">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>911</width>
|
||||
<height>563</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Form</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="vLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="THP::ZoomSlider" name="zoomSlider" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="sldPosition">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblPosition">
|
||||
<property name="text">
|
||||
<string notr="true">--:-- / --:--</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnPlay">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:icons/16x16/media-playback-start.png</normaloff>:icons/16x16/media-playback-start.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnStop">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:icons/16x16/media-playback-stop.png</normaloff>:icons/16x16/media-playback-stop.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnSlower">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:icons/16x16/media-play-slower.png</normaloff>:icons/16x16/media-play-slower.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btn100pct">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:icons/16x16/media-play-normal.png</normaloff>:icons/16x16/media-play-normal.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnFaster">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:icons/16x16/media-play-faster.png</normaloff>:icons/16x16/media-play-faster.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>5</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblSpeed">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">100 %</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>5</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbPlaybackParts">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblCursorPos">
|
||||
<property name="text">
|
||||
<string notr="true">MGRS</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnFilter">
|
||||
<property name="text">
|
||||
<string>Filter</string>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::InstantPopup</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>THP::ZoomSlider</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>thpwidgets/thp_zoom_slider.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Executable
+75
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AES filter dialog for situation map/thp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "thp_situation_filter_aes.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QFrame>
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <FilterManagement/flt_aes_plugin_interface.h>
|
||||
#include <FilterManagement/Gui/Aes/flt_aes_filter_widget.h>
|
||||
#include <ProjectDataManagement/Gui/PdmComboBox/pdm_combobox_foreign_gui_interface_impl.h>
|
||||
#include <ParticipantManagement/Gui/PpmComboBox/ppm_combobox_foreign_gui_interface_impl.h>
|
||||
|
||||
namespace THP
|
||||
{
|
||||
SituatationFilterAes::SituatationFilterAes(const std::shared_ptr<FilterManagement::AesDisplayFilter> &aesFilter,
|
||||
SitMapPluginProvider *pluginProvider,
|
||||
QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_filterWidget(new FilterManagement::AesFilterWidget(this))
|
||||
{
|
||||
setWindowTitle(tr("Area Effect Simulation filter settings"));
|
||||
QGridLayout *gl = new QGridLayout(this);
|
||||
m_filterWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
gl->addWidget(m_filterWidget, 0, 0);
|
||||
QFrame *line = new QFrame(this);
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
gl->addWidget(line, 1, 0);
|
||||
QDialogButtonBox *bb = new QDialogButtonBox(this);
|
||||
gl->addWidget(bb, 2, 0);
|
||||
|
||||
|
||||
bb->setStandardButtons(QDialogButtonBox::Apply | QDialogButtonBox::Close | QDialogButtonBox::Cancel);
|
||||
connect(bb->button(QDialogButtonBox::Apply), &QPushButton::clicked,
|
||||
m_filterWidget, &FilterManagement::AesFilterWidget::apply);
|
||||
connect(bb->button(QDialogButtonBox::Close), &QPushButton::clicked,
|
||||
this, &SituatationFilterAes::accept);
|
||||
connect(bb->button(QDialogButtonBox::Cancel), &QPushButton::clicked,
|
||||
this, &SituatationFilterAes::reject);
|
||||
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterfaceImpl>
|
||||
ifcPpmCbx(std::make_shared<ParticipantManagement::ForeignGuiComboboxInterfaceImpl>());
|
||||
ifcPpmCbx->init(pluginProvider->ppmDtc());
|
||||
|
||||
std::shared_ptr<ProjectDataManagement::ForeignGuiInterfaceImpl>
|
||||
ifcPdmCbx(std::make_shared<ProjectDataManagement::ForeignGuiInterfaceImpl>());
|
||||
ifcPdmCbx->init(pluginProvider->pdmDtc());
|
||||
|
||||
m_filterWidget->init(ifcPpmCbx, ifcPdmCbx, aesFilter);
|
||||
// make sure to update ui when filter changes
|
||||
connect(m_filterWidget, &FilterManagement::AesFilterWidget::unknownChangesRecognized,
|
||||
m_filterWidget, &FilterManagement::AesFilterWidget::updateGuiToFilter);
|
||||
}
|
||||
|
||||
void SituatationFilterAes::accept()
|
||||
{
|
||||
m_filterWidget->apply();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void SituatationFilterAes::reject()
|
||||
{
|
||||
m_filterWidget->dialogCanceled();
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AES filter dialog for situation map/thp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "thp_plugin_provider.h"
|
||||
#include <QDialog>
|
||||
|
||||
namespace FilterManagement
|
||||
{
|
||||
class AesFilterWidget;
|
||||
class AesDisplayFilter;
|
||||
}
|
||||
namespace THP
|
||||
{
|
||||
class SitMapPluginProvider;
|
||||
class SituatationFilterAes final : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SituatationFilterAes(const std::shared_ptr<FilterManagement::AesDisplayFilter> &aesFilter,
|
||||
SitMapPluginProvider *pluginProvider,
|
||||
QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
void accept() override;
|
||||
void reject() override;
|
||||
private:
|
||||
FilterManagement::AesFilterWidget *m_filterWidget;
|
||||
};
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Type filter dialog for situation map/thp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "thp_situation_filter_building_components.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QFrame>
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <FilterManagement/flt_building_cmpnt_plugin_interface.h>
|
||||
#include <FilterManagement/Gui/BuildingComponents/flt_building_component_settings_widget.h>
|
||||
|
||||
namespace THP
|
||||
{
|
||||
SituationFilterBuildingComponent::SituationFilterBuildingComponent(const std::shared_ptr<FilterManagement::BuildingComponentSettings> &bcs,
|
||||
SitMapPluginProvider *pluginProvider,
|
||||
QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_filterWidget(new FilterManagement::BuildingComponentSettingsWidget(this))
|
||||
{
|
||||
setWindowTitle(tr("Building / Component filter settings"));
|
||||
QGridLayout *gl = new QGridLayout(this);
|
||||
m_filterWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
gl->addWidget(m_filterWidget, 0, 0);
|
||||
QFrame *line = new QFrame(this);
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
gl->addWidget(line, 1, 0);
|
||||
QDialogButtonBox *bb = new QDialogButtonBox(this);
|
||||
gl->addWidget(bb, 2, 0);
|
||||
|
||||
|
||||
bb->setStandardButtons(QDialogButtonBox::Apply | QDialogButtonBox::Close | QDialogButtonBox::Cancel);
|
||||
connect(bb->button(QDialogButtonBox::Apply), &QPushButton::clicked,
|
||||
m_filterWidget, &FilterManagement::BuildingComponentSettingsWidget::apply);
|
||||
connect(bb->button(QDialogButtonBox::Close), &QPushButton::clicked,
|
||||
this, &SituationFilterBuildingComponent::accept);
|
||||
connect(bb->button(QDialogButtonBox::Cancel), &QPushButton::clicked,
|
||||
this, &SituationFilterBuildingComponent::reject);
|
||||
|
||||
m_filterWidget->init(bcs, pluginProvider->ismDtc());
|
||||
}
|
||||
|
||||
void SituationFilterBuildingComponent::accept()
|
||||
{
|
||||
m_filterWidget->apply();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void SituationFilterBuildingComponent::reject()
|
||||
{
|
||||
m_filterWidget->dialogCanceled();
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Type filter dialog for situation map/thp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "thp_plugin_provider.h"
|
||||
#include <QDialog>
|
||||
|
||||
namespace FilterManagement
|
||||
{
|
||||
class BuildingComponentSettings;
|
||||
class BuildingComponentSettingsWidget;
|
||||
}
|
||||
namespace THP
|
||||
{
|
||||
class SitMapPluginProvider;
|
||||
class SituationFilterBuildingComponent final : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SituationFilterBuildingComponent(const std::shared_ptr<FilterManagement::BuildingComponentSettings> &bcs,
|
||||
SitMapPluginProvider *pluginProvider,
|
||||
QWidget *parent = nullptr);
|
||||
protected:
|
||||
void accept() override;
|
||||
void reject() override;
|
||||
private:
|
||||
FilterManagement::BuildingComponentSettingsWidget *m_filterWidget{nullptr};
|
||||
};
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AES filter dialog for situation map/thp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "thp_situation_filter_collapse_expand.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QFrame>
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <AdvancedSymbology/Data/asb_foreign_interface_impl.h>
|
||||
#include <FilterManagement/flt_aes_plugin_interface.h>
|
||||
#include <FilterManagement/Gui/Participant/flt_collapse_expand_participants_widget.h>
|
||||
#include <ParticipantManagement/Gui/PpmComboBox/ppm_combobox_foreign_gui_interface_impl.h>
|
||||
|
||||
namespace THP
|
||||
{
|
||||
SituatationFilterCollapseExpand::SituatationFilterCollapseExpand(const std::shared_ptr<FilterManagement::SymbolAppearanceSettings> &sas,
|
||||
SitMapPluginProvider *pluginProvider,
|
||||
QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_filterWidget(new FilterManagement::CollapseExpandParticipantWidget(this))
|
||||
{
|
||||
setWindowTitle(tr("Collapse/Expand Participant filter settings"));
|
||||
QGridLayout *gl = new QGridLayout(this);
|
||||
m_filterWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
gl->addWidget(m_filterWidget, 0, 0);
|
||||
QFrame *line = new QFrame(this);
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
gl->addWidget(line, 1, 0);
|
||||
QDialogButtonBox *bb = new QDialogButtonBox(this);
|
||||
gl->addWidget(bb, 2, 0);
|
||||
|
||||
|
||||
bb->setStandardButtons(QDialogButtonBox::Apply | QDialogButtonBox::Close | QDialogButtonBox::Cancel);
|
||||
connect(bb->button(QDialogButtonBox::Apply), &QPushButton::clicked,
|
||||
m_filterWidget, &FilterManagement::CollapseExpandParticipantWidget::apply);
|
||||
connect(bb->button(QDialogButtonBox::Close), &QPushButton::clicked,
|
||||
this, &SituatationFilterCollapseExpand::accept);
|
||||
connect(bb->button(QDialogButtonBox::Cancel), &QPushButton::clicked,
|
||||
this, &SituatationFilterCollapseExpand::reject);
|
||||
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterfaceImpl>
|
||||
ifcPpmCbx(std::make_shared<ParticipantManagement::ForeignGuiComboboxInterfaceImpl>());
|
||||
ifcPpmCbx->init(pluginProvider->ppmDtc());
|
||||
|
||||
std::shared_ptr<AdvancedSymbology::ForeignInterfaceImpl>
|
||||
ifcAsb(std::make_shared<AdvancedSymbology::ForeignInterfaceImpl>(pluginProvider->ppmDtc(),
|
||||
pluginProvider->aesDtc(),
|
||||
pluginProvider->gimDtc()));
|
||||
|
||||
m_filterWidget->init(pluginProvider->ppmDtc(),
|
||||
ifcPpmCbx,
|
||||
ifcAsb,
|
||||
// pluginProvider->fltParticipantIfc(),
|
||||
sas);
|
||||
}
|
||||
|
||||
void SituatationFilterCollapseExpand::accept()
|
||||
{
|
||||
m_filterWidget->apply();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void SituatationFilterCollapseExpand::reject()
|
||||
{
|
||||
m_filterWidget->dialogCanceled();
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
}
|
||||
qt6-after/qt6-migrated-legatus/Lts/Application/THP/thpwidgets/thp_situation_filter_collapse_expand.h
Executable
+34
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Collapse/Expand filter dialog for situation map/thp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "thp_plugin_provider.h"
|
||||
#include <QDialog>
|
||||
|
||||
namespace FilterManagement
|
||||
{
|
||||
class CollapseExpandParticipantWidget;
|
||||
class SymbolAppearanceSettings;
|
||||
}
|
||||
namespace THP
|
||||
{
|
||||
class SitMapPluginProvider;
|
||||
class SituatationFilterCollapseExpand final : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SituatationFilterCollapseExpand(const std::shared_ptr<FilterManagement::SymbolAppearanceSettings> &sas,
|
||||
SitMapPluginProvider *pluginProvider,
|
||||
QWidget *parent = nullptr);
|
||||
protected:
|
||||
void accept() override;
|
||||
void reject() override;
|
||||
private:
|
||||
FilterManagement::CollapseExpandParticipantWidget *m_filterWidget;
|
||||
};
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AES filter dialog for situation map/thp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "thp_situation_filter_symbol_appearance.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QFrame>
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <FilterManagement/flt_aes_plugin_interface.h>
|
||||
#include <FilterManagement/Gui/Participant/flt_symbol_appearance_widget.h>
|
||||
|
||||
namespace THP
|
||||
{
|
||||
SituatationFilterSymbolAppearance::SituatationFilterSymbolAppearance(const std::shared_ptr<FilterManagement::SymbolAppearanceSettings> &sas,
|
||||
SitMapPluginProvider *pluginProvider,
|
||||
QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_filterWidget(new FilterManagement::SymbolAppearanceWidget(this))
|
||||
{
|
||||
setWindowTitle(tr("Symbol Appearance filter settings"));
|
||||
QGridLayout *gl = new QGridLayout(this);
|
||||
m_filterWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
gl->addWidget(m_filterWidget, 0, 0);
|
||||
QFrame *line = new QFrame(this);
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
gl->addWidget(line, 1, 0);
|
||||
QDialogButtonBox *bb = new QDialogButtonBox(this);
|
||||
gl->addWidget(bb, 2, 0);
|
||||
|
||||
|
||||
bb->setStandardButtons(QDialogButtonBox::Apply | QDialogButtonBox::Close | QDialogButtonBox::Cancel);
|
||||
connect(bb->button(QDialogButtonBox::Apply), &QPushButton::clicked,
|
||||
m_filterWidget, &FilterManagement::SymbolAppearanceWidget::apply);
|
||||
connect(bb->button(QDialogButtonBox::Close), &QPushButton::clicked,
|
||||
this, &SituatationFilterSymbolAppearance::accept);
|
||||
connect(bb->button(QDialogButtonBox::Cancel), &QPushButton::clicked,
|
||||
this, &SituatationFilterSymbolAppearance::reject);
|
||||
|
||||
m_filterWidget->init(pluginProvider->ppmDtc()->partys(), sas);
|
||||
}
|
||||
|
||||
void SituatationFilterSymbolAppearance::accept()
|
||||
{
|
||||
m_filterWidget->apply();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void SituatationFilterSymbolAppearance::reject()
|
||||
{
|
||||
m_filterWidget->dialogCanceled();
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Symbol Appearance filter dialog for situation map/thp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "thp_plugin_provider.h"
|
||||
#include <QDialog>
|
||||
|
||||
namespace FilterManagement
|
||||
{
|
||||
class SymbolAppearanceSettings;
|
||||
class SymbolAppearanceWidget;
|
||||
}
|
||||
namespace THP
|
||||
{
|
||||
class SitMapPluginProvider;
|
||||
class SituatationFilterSymbolAppearance final : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SituatationFilterSymbolAppearance(const std::shared_ptr<FilterManagement::SymbolAppearanceSettings> &sas,
|
||||
SitMapPluginProvider *pluginProvider,
|
||||
QWidget *parent = nullptr);
|
||||
protected:
|
||||
void accept() override;
|
||||
void reject() override;
|
||||
private:
|
||||
FilterManagement::SymbolAppearanceWidget *m_filterWidget;
|
||||
};
|
||||
}
|
||||
Executable
+69
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Type filter dialog for situation map/thp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "thp_situation_filter_types.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QFrame>
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <FilterManagement/flt_aes_plugin_interface.h>
|
||||
#include <FilterManagement/Gui/Participant/flt_type_filter_widget.h>
|
||||
#include <ParticipantManagement/Gui/PpmComboBox/ppm_combobox_foreign_gui_interface_impl.h>
|
||||
|
||||
namespace THP
|
||||
{
|
||||
SituatationFilterTypes::SituatationFilterTypes(const std::shared_ptr<FilterManagement::SymbolAppearanceSettings> &sas,
|
||||
SitMapPluginProvider *pluginProvider,
|
||||
QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_filterWidget(new FilterManagement::TypeFilterWidget(this))
|
||||
{
|
||||
setWindowTitle(tr("Type filter settings"));
|
||||
QGridLayout *gl = new QGridLayout(this);
|
||||
m_filterWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
gl->addWidget(m_filterWidget, 0, 0);
|
||||
QFrame *line = new QFrame(this);
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
gl->addWidget(line, 1, 0);
|
||||
QDialogButtonBox *bb = new QDialogButtonBox(this);
|
||||
gl->addWidget(bb, 2, 0);
|
||||
|
||||
|
||||
bb->setStandardButtons(QDialogButtonBox::Apply | QDialogButtonBox::Close | QDialogButtonBox::Cancel);
|
||||
connect(bb->button(QDialogButtonBox::Apply), &QPushButton::clicked,
|
||||
m_filterWidget, &FilterManagement::TypeFilterWidget::apply);
|
||||
connect(bb->button(QDialogButtonBox::Close), &QPushButton::clicked,
|
||||
this, &SituatationFilterTypes::accept);
|
||||
connect(bb->button(QDialogButtonBox::Cancel), &QPushButton::clicked,
|
||||
this, &SituatationFilterTypes::reject);
|
||||
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterfaceImpl>
|
||||
ifcPpmCbx(std::make_shared<ParticipantManagement::ForeignGuiComboboxInterfaceImpl>());
|
||||
ifcPpmCbx->init(pluginProvider->ppmDtc());
|
||||
|
||||
m_filterWidget->init(pluginProvider->ppmDtc(),
|
||||
ifcPpmCbx,
|
||||
sas);
|
||||
}
|
||||
|
||||
void SituatationFilterTypes::accept()
|
||||
{
|
||||
m_filterWidget->apply();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void SituatationFilterTypes::reject()
|
||||
{
|
||||
m_filterWidget->dialogCanceled();
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Type filter dialog for situation map/thp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "thp_plugin_provider.h"
|
||||
#include <QDialog>
|
||||
|
||||
namespace FilterManagement
|
||||
{
|
||||
class SymbolAppearanceSettings;
|
||||
class TypeFilterWidget;
|
||||
}
|
||||
namespace THP
|
||||
{
|
||||
class SitMapPluginProvider;
|
||||
class SituatationFilterTypes final : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SituatationFilterTypes(const std::shared_ptr<FilterManagement::SymbolAppearanceSettings> &sas,
|
||||
SitMapPluginProvider *pluginProvider,
|
||||
QWidget *parent = nullptr);
|
||||
protected:
|
||||
void accept() override;
|
||||
void reject() override;
|
||||
private:
|
||||
FilterManagement::TypeFilterWidget *m_filterWidget;
|
||||
};
|
||||
}
|
||||
+650
@@ -0,0 +1,650 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Handle situation display in thp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "thp_situation_widget.h"
|
||||
#include "ui_thp_situation_building_base.h"
|
||||
|
||||
#include "thp_situation_filter_aes.h"
|
||||
#include "thp_situation_filter_symbol_appearance.h"
|
||||
#include "thp_situation_filter_collapse_expand.h"
|
||||
#include "thp_situation_filter_types.h"
|
||||
#include "thp_situation_filter_building_components.h"
|
||||
#include "thp_plugin_provider.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonParseError>
|
||||
#include <QKeyEvent>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QPainter>
|
||||
#include <QSvgRenderer>
|
||||
#include <QTimer>
|
||||
#include <QThread>
|
||||
#include <FileManagement/flm_db_structs.h>
|
||||
#include <FilterManagement/flt_participant_plugin_interface.h>
|
||||
#include <FilterManagement/flt_aes_plugin_interface.h>
|
||||
#include <FilterManagement/flt_building_cmpnt_plugin_interface.h>
|
||||
#include <FilterManagement/flt_building_cmpnt_settings.h>
|
||||
#include <FilterManagement/Gui/Aes/Common/aes_display_filter_impl.h>
|
||||
#include <FilterManagement/Gui/Aes/Common/symbol_appearance_settings_impl.h>
|
||||
|
||||
#include <SituationReplay/handler_situation_replay_sqlite.h>
|
||||
|
||||
#include <SituationMap/situation_map_init.h>
|
||||
#include <SituationMap/Utils/movement_track_manager.h>
|
||||
#include <SituationMap/Map/grid.h>
|
||||
#include <SituationMap/Map/point3D.h>
|
||||
#include <SituationMap/Map/map_initializer.h>
|
||||
#include <SituationMap/Map/map_notifier.h>
|
||||
#include <SituationMap/Map/operator_map_settings.h>
|
||||
#include <SituationMap/Map/overlay_handler.h>
|
||||
#include <SituationMap/Symbology/sidc_codec.h>
|
||||
#include <PlanOverlays/Gui/plan_overlay_model.h>
|
||||
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
namespace THP
|
||||
{
|
||||
|
||||
class MySitMapIinit final : public SituationMap::SituationMapInit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using SituationMap::SituationMapInit::SituationMapInit;
|
||||
|
||||
bool trainingAreaExists() const override { return true; }
|
||||
SituationMap::MapSettingsJson getMapSettingsFromService() const override { return m_mapSettingsJson; }
|
||||
void setMapSettingsJson(const SituationMap::MapSettingsJson &settings) { m_mapSettingsJson = settings; }
|
||||
const SituationMap::MapSettingsJson & getMapSettingsJson() const { return m_mapSettingsJson; }
|
||||
|
||||
private:
|
||||
SituationMap::MapSettingsJson m_mapSettingsJson;
|
||||
};
|
||||
|
||||
using namespace SituationReplay;
|
||||
|
||||
SituationWidget::SituationWidget(QWidget *parent)
|
||||
: SituationBuildingBase("THP.SituationWidget", parent)
|
||||
, m_pluginProvider(new SitMapPluginProvider)
|
||||
, m_situationMapInit(new MySitMapIinit(nullptr))
|
||||
{
|
||||
QMenu *m = new QMenu(m_ui->btnFilter);
|
||||
m->addAction(tr("AES Filter"), this, &SituationWidget::onFilterAes);
|
||||
// 29.09.2022, Norbert Thoden
|
||||
// SWPÄ 2:22 GUEZE-1477 Kartenfilter für Komponenten:
|
||||
// Es wurde der Komponenten Filter eingeführt.
|
||||
// in der LiveLage werden allerdings nur MountingPoints angezeigt, die auch eine
|
||||
// zugeordnetes Asset haben. Die Zuordnug befindet sich in der Tabelle ism.sim_mounting_point_asset.
|
||||
// ism.sim_mounting_point_asset wird derzeit nicht in die sitreplay.sqlite
|
||||
// überführt. Es koennen also keine Komponenten angezeigt / gefiltert werden...
|
||||
// FilterDialog nicht anzeigen:
|
||||
// m->addAction(tr("Building / Component"), this, &SituationWidget::onFilterBuildingComponent);
|
||||
|
||||
m->addAction(tr("Symbol Appearance"), this, &SituationWidget::onFilterSymbolAppearance);
|
||||
m->addAction(tr("Collpase/Expand"), this, &SituationWidget::onFilterCollapseExpand);
|
||||
m->addAction(tr("Type filter"), this, &SituationWidget::onFilterTypes);
|
||||
m_ui->btnFilter->setMenu(m);
|
||||
}
|
||||
|
||||
SituationWidget::~SituationWidget()
|
||||
{
|
||||
if (m_replayHandler->handlerSrp())
|
||||
m_replayHandler->handlerSrp()->onStopReplayRequest();
|
||||
delete m_situationMapInit;
|
||||
delete m_pluginProvider;
|
||||
delete m_replayHandler;
|
||||
}
|
||||
|
||||
bool SituationWidget::init(const QString &homePath, int exerciseId)
|
||||
{
|
||||
m_pluginProvider->setExerciseId(exerciseId);
|
||||
delete m_replayHandler;
|
||||
m_replayHandler = new SituationReplay::MainHandlerSqlite;
|
||||
|
||||
if (!SituationBuildingBase::init(m_replayHandler))
|
||||
return false;
|
||||
|
||||
loadLayerMappings(homePath);
|
||||
|
||||
SituationReplay::ConnectionParams connParams;
|
||||
connParams.domainId = 1;
|
||||
connParams.partitionId = 1;
|
||||
if (!m_replayHandler->initDds(connParams))
|
||||
return false;
|
||||
|
||||
if (!m_pluginProvider->init(m_replayHandler->ddsReplay()))
|
||||
return false;
|
||||
if (!m_situationMapInit->initPluginProvider(m_pluginProvider))
|
||||
return false;
|
||||
|
||||
QPointer<SituationMap::MovementTrackManager> movementTrackMgr =
|
||||
QPointer<SituationMap::MovementTrackManager>(new SituationMap::MovementTrackManager(m_situationMapInit));
|
||||
|
||||
FATAL_LOG(m_logger) << LOGFUNCTION << " XXXX initMap....";
|
||||
|
||||
if (!m_situationMapInit->initMap(false, SituationMap::Mode::Mode_2D))
|
||||
return false;
|
||||
|
||||
if (!m_situationMapInit->initAdapter(movementTrackMgr, false))
|
||||
return false;
|
||||
|
||||
SituationMap::Map *map = m_situationMapInit->getWidget();
|
||||
if (!map)
|
||||
return false;
|
||||
|
||||
connect(map, &SituationMap::Map::mouseGeoPositionChanged,
|
||||
this, &SituationWidget::updatePositionLabel,
|
||||
Qt::UniqueConnection);
|
||||
connect(map, &SituationMap::Map::extentChanged,
|
||||
this, &SituationWidget::updateZoomSlider);
|
||||
|
||||
map->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
m_ui->vLayout->insertWidget(0, map);
|
||||
|
||||
m_aesDisplayFilter = m_pluginProvider->fltAesIfc()->aesFilterForOperator(0, QString());
|
||||
m_symbolAppaearanceSettings = m_pluginProvider->fltParticipantIfc()->symbolAppearanceForOperator(0, QString());
|
||||
m_buildingComponentSettings = m_pluginProvider->fltBuildingComponentIfc()->buildingComponentSettingsForOperator(0, QString());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SituationWidget::showSituationInternal()
|
||||
{
|
||||
// cleanup 'old' map:
|
||||
// remove old overlays from former session:
|
||||
{
|
||||
SituationMap::Map *map = m_situationMapInit->getWidget();
|
||||
if (map)
|
||||
map->overlayHandler().removeAllOverlays();
|
||||
}
|
||||
|
||||
|
||||
m_ui->cbPlaybackParts->setVisible(m_replayInformation.size() > 1);
|
||||
|
||||
// MAYBE there are filter to be applied:
|
||||
applyFilterFromReplayConfigFile();
|
||||
|
||||
if (m_replayInformation.isEmpty())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "No replay information given...";
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString sqliteDb = m_replayInformation.first().databaseFilePath;
|
||||
if (sqliteDb.isEmpty())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "No database given...";
|
||||
return false;
|
||||
}
|
||||
QFileInfo fi(sqliteDb);
|
||||
if (!fi.exists() || !fi.isFile() || !fi.isReadable())
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
WARNING_LOG(m_logger) << "Can not access sqlite database '" << fi.absoluteFilePath() << "'";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ui->cbPlaybackParts->clear();
|
||||
m_ui->cbPlaybackParts->blockSignals(true);
|
||||
for (int i = 0; i < m_replayInformation.size(); ++i)
|
||||
{
|
||||
const ReplayInformation &info = m_replayInformation.at(i);
|
||||
m_ui->cbPlaybackParts->addItem(QStringLiteral("%1: %2 - %3").arg(i+1).arg(DTG::toStringMSec(info.timeSpan.begin, DTG::Long),
|
||||
DTG::toStringMSec(info.timeSpan.end, DTG::Long)), i);
|
||||
}
|
||||
m_ui->cbPlaybackParts->setCurrentIndex(0);
|
||||
m_ui->cbPlaybackParts->blockSignals(false);
|
||||
onCbPlaybackPartsChanged(); // creates replayHandler for correct db etc.
|
||||
|
||||
SituationMap::Map *map = m_situationMapInit->getWidget();
|
||||
if (map->isReady())
|
||||
QTimer::singleShot(0, this, &SituationWidget::onInitDone);
|
||||
else
|
||||
connect(map, &SituationMap::Map::mapReady,
|
||||
this, &SituationWidget::onInitDone, Qt::QueuedConnection);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SituationWidget::applyFilterFromReplayConfigFile()
|
||||
{
|
||||
// Maybe the Situation topic has own Filter (AesFilter, SymbolAppearance; OperatorMapSettings)
|
||||
// Read and apply them:
|
||||
if (m_replayInformation.isEmpty())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "No replay information given...";
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString replayConfigFile = m_replayInformation.first().replayConfigPath; // sitreplay.json
|
||||
if (replayConfigFile.isEmpty())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "No replayConfigFile given...";
|
||||
return false;
|
||||
}
|
||||
|
||||
QFileInfo fi(replayConfigFile);
|
||||
if (!fi.exists() || !fi.isFile() || !fi.isReadable())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Can not access replayConfigFile '" << fi.absoluteFilePath() << "'";
|
||||
return false;
|
||||
}
|
||||
|
||||
QFile f(replayConfigFile);
|
||||
if (!f.open(QIODevice::ReadOnly))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Can not open replayConfigFile '" << fi.absoluteFilePath() << "': " << f.errorString();
|
||||
return false;
|
||||
}
|
||||
|
||||
QJsonParseError jError;
|
||||
const QByteArray ba = f.readAll();
|
||||
QJsonDocument doc(QJsonDocument::fromJson(ba, &jError));
|
||||
if (jError.error)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Can not parse json document: "
|
||||
<< ", replayConfigFile '" << fi.absoluteFilePath() << "'"
|
||||
<< ", errorString= " << jError.errorString();
|
||||
return false;
|
||||
}
|
||||
|
||||
const QJsonObject &rootObj = doc.object();
|
||||
const QJsonObject &filters = rootObj[QStringLiteral("filters")].toObject(); // optional!!!
|
||||
|
||||
if (filters.isEmpty())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "no 'filters' provided at "
|
||||
<< " replayConfigFile '" << fi.absoluteFilePath() << "'";
|
||||
return false;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " XXXX replayConfigFile='" << fi.absoluteFilePath() << "'"
|
||||
<< " doc.toJson = " << doc.toJson();
|
||||
|
||||
// fine, put together
|
||||
FilterInformation filterInfo;
|
||||
filterInfo.aesFilters = filters[QStringLiteral("AesFilterJson")].toObject();
|
||||
filterInfo.symbolSettings = filters[QStringLiteral("SymbolAppearanceJson")].toObject();
|
||||
filterInfo.buildingComponentSettings = filters[QStringLiteral("BuildingComponentSettingsJson")].toObject();
|
||||
|
||||
filterInfo.mapSettings = rootObj[QStringLiteral("settings")].toObject();
|
||||
|
||||
applyCurentFilter(filterInfo);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SituationWidget::applyCurentFilter(const SituationReplay::FilterInformation &filter)
|
||||
{
|
||||
m_aesDisplayFilter->setFilterFromData(filter.aesFilters);
|
||||
m_symbolAppaearanceSettings->setSettings(filter.symbolSettings, FilterManagement::SymbolAppearanceSettings::Part::All);
|
||||
m_buildingComponentSettings->setBldCmpSettings(filter.buildingComponentSettings);
|
||||
|
||||
SituationMap::OperatorMapSettings oms;
|
||||
oms.fromJsonObject(filter.mapSettings);
|
||||
if (oms.isEmpty() || oms.mode == SituationMap::Mode::Undefined)
|
||||
return;
|
||||
|
||||
|
||||
if (oms.mode != m_situationMapInit->getWidget()->mode())
|
||||
{
|
||||
INFO_LOG(m_logger) << " Switching to new mode : " << oms.mode;
|
||||
|
||||
SituationMap::MapSettingsJson savedMapSettingsJson;
|
||||
if (m_situationMapInit)
|
||||
{
|
||||
savedMapSettingsJson = m_situationMapInit->getMapSettingsJson(); // containing path from layerMappping.json
|
||||
m_situationMapInit->stopDisplay();
|
||||
m_situationMapInit->clearObjects();
|
||||
}
|
||||
delete m_situationMapInit;
|
||||
m_situationMapInit = new MySitMapIinit(nullptr);
|
||||
m_situationMapInit->setMapSettingsJson(savedMapSettingsJson);
|
||||
m_situationMapInit->initPluginProvider(m_pluginProvider);
|
||||
|
||||
m_situationMapInit->initMap(false, oms.mode);
|
||||
|
||||
QPointer<SituationMap::MovementTrackManager> movementTrackMgr =
|
||||
QPointer<SituationMap::MovementTrackManager>(new SituationMap::MovementTrackManager(m_situationMapInit));
|
||||
if (!m_situationMapInit->initAdapter(movementTrackMgr, false))
|
||||
return;
|
||||
|
||||
SituationMap::Map *map = m_situationMapInit->getWidget();
|
||||
if (map)
|
||||
{
|
||||
connect(map, &SituationMap::Map::mouseGeoPositionChanged,
|
||||
this, &SituationWidget::updatePositionLabel,
|
||||
Qt::UniqueConnection);
|
||||
connect(map, &SituationMap::Map::extentChanged,
|
||||
this, &SituationWidget::updateZoomSlider);
|
||||
|
||||
map->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
m_ui->vLayout->insertWidget(0, map);
|
||||
|
||||
|
||||
static bool s_waitFlag = true;
|
||||
|
||||
QPointer<SituationMap::MapNotifier> mapNotifier = map->createMapNotifier();
|
||||
if (mapNotifier)
|
||||
{
|
||||
connect(mapNotifier.data(), &SituationMap::MapNotifier::mapReadyAndSymbolDictionaryLoaded, this, [this, oms]()
|
||||
{
|
||||
s_waitFlag = false;
|
||||
if (!restoreOperatorMapSettingsOverlays(oms))
|
||||
WARNING_LOG(m_logger) << "restoreOperatorMapSettingsOverlays failed";
|
||||
|
||||
});
|
||||
mapNotifier->run();
|
||||
|
||||
// snyc wait :-(
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " WAIT_SYNC BEGIN";
|
||||
int i=0;
|
||||
while(i<100 && s_waitFlag) // 100 * 50ms = 5000ms
|
||||
{
|
||||
qApp->processEvents(QEventLoop::ExcludeUserInputEvents|QEventLoop::ExcludeSocketNotifiers, 50);
|
||||
QThread::msleep(50);
|
||||
++i;
|
||||
DEBUG_LOG(m_logger) << " WAIT_SYNC ..., i=" << i;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << " WAIT_SYNC ...DONE, i=" << i;
|
||||
DEBUG_LOG(m_logger) << " WAIT_SYNC, m_situationMapInit->getWidget()->mode()" << m_situationMapInit->getWidget()->mode();
|
||||
m_situationMapInit->startDisplay();
|
||||
}
|
||||
} // if (mapNotifier)
|
||||
}
|
||||
} else {
|
||||
if (!restoreOperatorMapSettingsOverlays(oms))
|
||||
WARNING_LOG(m_logger) << "restoreOperatorMapSettingsOverlays failed";
|
||||
}
|
||||
}
|
||||
|
||||
bool SituationWidget::restoreOperatorMapSettingsOverlays(const SituationMap::OperatorMapSettings &oms)
|
||||
{
|
||||
if (!m_situationMapInit || !m_situationMapInit->getWidget() || oms.isEmpty())
|
||||
return false;
|
||||
|
||||
if (!m_situationMapInit->getWidget()->restoreOperatorMapSettings(oms))
|
||||
WARNING_LOG(m_logger) << LOGFUNCTION << " restoreOperatorMapSettings failed";
|
||||
|
||||
// continue!!! maybe just LayerOrder failed.... ToDo
|
||||
|
||||
// 2. handle Overlays :
|
||||
// SituationMap can`t restore the overlays on it´s own:
|
||||
// So we have to do it here:
|
||||
const QList<int> &orderedOverlayIds = oms.orderedOverlays;
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " restore OverlayIds...";
|
||||
for (auto overlayId : qAsConst(orderedOverlayIds))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " applyNewOverlay , overlayId=" << overlayId;
|
||||
applyNewOverlay(overlayId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void SituationWidget::applyNewOverlay(int overlayId)
|
||||
{
|
||||
const QString filename = QStringLiteral("%1/%2.TacticalPlan").arg(m_scriptPath).arg(overlayId);
|
||||
QFile f(filename);
|
||||
if (!f.open(QIODevice::ReadOnly))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Can not open tactical plan '" << filename << "': " << f.errorString();
|
||||
return;
|
||||
}
|
||||
SituationMap::OverlayHandler &overlayHandler = m_situationMapInit->getWidget()->overlayHandler();
|
||||
if (!overlayHandler.setOverlay(overlayId, tr("Plan '%1'").arg(overlayId), f.readAll(), false))
|
||||
WARNING_LOG(m_logger) << "can not display overlay " << filename;
|
||||
|
||||
}
|
||||
|
||||
void SituationWidget::removeOverlay(int overlayId)
|
||||
{
|
||||
SituationMap::OverlayHandler &overlayHandler = m_situationMapInit->getWidget()->overlayHandler();
|
||||
overlayHandler.removeOverlay(overlayId);
|
||||
}
|
||||
|
||||
void SituationWidget::onFilterAes()
|
||||
{
|
||||
if (!m_filterAesDialog)
|
||||
m_filterAesDialog = new SituatationFilterAes(m_aesDisplayFilter,
|
||||
m_pluginProvider, this);
|
||||
m_filterAesDialog->show();
|
||||
}
|
||||
|
||||
void SituationWidget::onFilterSymbolAppearance()
|
||||
{
|
||||
if (!m_filterSymbolAppearanceDialog)
|
||||
m_filterSymbolAppearanceDialog = new SituatationFilterSymbolAppearance(m_symbolAppaearanceSettings,
|
||||
m_pluginProvider, this);
|
||||
m_filterSymbolAppearanceDialog->show();
|
||||
}
|
||||
|
||||
void SituationWidget::onFilterCollapseExpand()
|
||||
{
|
||||
if (!m_filterCollapseExpandDialog)
|
||||
m_filterCollapseExpandDialog = new SituatationFilterCollapseExpand(m_symbolAppaearanceSettings,
|
||||
m_pluginProvider, this);
|
||||
m_filterCollapseExpandDialog->show();
|
||||
}
|
||||
|
||||
void SituationWidget::onFilterTypes()
|
||||
{
|
||||
if (!m_filterTypesDialog)
|
||||
m_filterTypesDialog = new SituatationFilterTypes(m_symbolAppaearanceSettings,
|
||||
m_pluginProvider, this);
|
||||
m_filterTypesDialog->show();
|
||||
}
|
||||
|
||||
void SituationWidget::onFilterBuildingComponent()
|
||||
{
|
||||
if (!m_filterBuildingComponentDialog)
|
||||
m_filterBuildingComponentDialog = new SituationFilterBuildingComponent(m_buildingComponentSettings,
|
||||
m_pluginProvider, this);
|
||||
m_filterBuildingComponentDialog->show();
|
||||
}
|
||||
|
||||
void SituationWidget::emitPartitionTimeChanged(qint64 curTime)
|
||||
{
|
||||
m_pluginProvider->emitPartitionTimeChanged(curTime);
|
||||
}
|
||||
|
||||
void SituationWidget::updateZoomSlider()
|
||||
{
|
||||
// this is not really what we want to display... but currently we hide the slider anyway
|
||||
m_ui->zoomSlider->setZoomValue(m_situationMapInit->getWidget()->scale() / 1000);
|
||||
}
|
||||
|
||||
|
||||
QString SituationWidget::centerPointString() const
|
||||
{
|
||||
const QPointF center = m_situationMapInit->getWidget()->centerPoint();
|
||||
LtsCoordTrans::UtmCoordinate coord(LtsCoordTrans::UtmCoordinate::fromGeographic(center.x(), center.y()));
|
||||
return coord.mgrs();
|
||||
}
|
||||
|
||||
QRectF SituationWidget::extentMgrs() const
|
||||
{
|
||||
const QRectF r = m_situationMapInit->getWidget()->extent();
|
||||
LtsCoordTrans::UtmCoordinate topLeft(LtsCoordTrans::UtmCoordinate::fromGeographic(r.left(), r.top()));
|
||||
LtsCoordTrans::UtmCoordinate bottomRight(LtsCoordTrans::UtmCoordinate::fromGeographic(r.right(), r.bottom(), topLeft.zone));
|
||||
return QRectF(QPointF(topLeft.x, topLeft.y), QPointF(bottomRight.x, bottomRight.y));
|
||||
}
|
||||
|
||||
QImage SituationWidget::grabFrameBuffer() const
|
||||
{
|
||||
return m_situationMapInit->getWidget()->grab().toImage();
|
||||
}
|
||||
|
||||
void SituationWidget::onInitDone()
|
||||
{
|
||||
SituationBuildingBase::onInitDone();
|
||||
m_situationMapInit->startDisplay();
|
||||
}
|
||||
|
||||
void SituationWidget::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
switch (event->key())
|
||||
{
|
||||
case Qt::Key_F10:
|
||||
onMgrsGrid();
|
||||
break;
|
||||
case Qt::Key_PageUp:
|
||||
onRotate(10);
|
||||
break;
|
||||
case Qt::Key_PageDown:
|
||||
onRotate(-10);
|
||||
break;
|
||||
default:
|
||||
QFrame::keyPressEvent(event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SituationWidget::onMgrsGrid()
|
||||
{
|
||||
SituationMap::Map *m = m_situationMapInit->getWidget();
|
||||
m->grid().setVisible(!m->grid().isVisible());
|
||||
}
|
||||
|
||||
void SituationWidget::onRotate(int degrees)
|
||||
{
|
||||
SituationMap::Map *m = m_situationMapInit->getWidget();
|
||||
m->setRotation(m->rotation() + degrees);
|
||||
}
|
||||
|
||||
void SituationWidget::onFileContentAvailable(const FileManagement::Database::FlmFileContent &data)
|
||||
{
|
||||
if (data.fileTypeId != FileManagement::FileType::OperatorDefinedSymbol ||
|
||||
data.fileStatusId != FileManagement::FileStatus::Valid ||
|
||||
data.content.size() == 0)
|
||||
return;
|
||||
|
||||
QColor colorToBeReplaced;
|
||||
bool bIsXml = false;
|
||||
|
||||
if (!data.properties.isEmpty())
|
||||
{
|
||||
QJsonParseError parseError;
|
||||
const QJsonDocument jDoc(QJsonDocument::fromJson(data.properties.toUtf8(), &parseError));
|
||||
const QJsonObject obj(jDoc.object());
|
||||
const QLatin1String imageFormatKey("imageFormat");
|
||||
bIsXml = obj.value(imageFormatKey).toString() == QLatin1String("xml");
|
||||
if (!bIsXml)
|
||||
{
|
||||
// partyColor
|
||||
const QLatin1String partyColorStr("partyColor");
|
||||
if (obj.contains(partyColorStr))
|
||||
{
|
||||
const QJsonObject partyColor = obj[partyColorStr].toObject();
|
||||
if (partyColor.size() == 3) // r, g, b
|
||||
{
|
||||
// update map:
|
||||
colorToBeReplaced.setRgb(
|
||||
partyColor[QLatin1String("r")].toInt(),
|
||||
partyColor[QLatin1String("g")].toInt(),
|
||||
partyColor[QLatin1String("b")].toInt());
|
||||
} // if (partyColor.size() == 3)
|
||||
} // if (obj.contains(partyColorStr))
|
||||
}
|
||||
}
|
||||
|
||||
AdvancedSymbology::SymbologyType symType = AdvancedSymbology::SymbolDictionary::defaultSymbologyType();
|
||||
AdvancedSymbology::SymbolDictionary &dict =
|
||||
AdvancedSymbology::SymbolDictionary::dictionary(symType);
|
||||
if (bIsXml)
|
||||
{
|
||||
dict.setXmlSymbol(data.id, data.name, QStringLiteral("OperatorName"), 0, QString::fromUtf8(data.content), AdvancedSymbology::SymbolProperties());
|
||||
}
|
||||
else
|
||||
{
|
||||
QImage image;
|
||||
QSvgRenderer svgRenderer;
|
||||
if (!svgRenderer.load(data.content))
|
||||
return;
|
||||
|
||||
// prepare Image:
|
||||
constexpr int size = 200; // pixel
|
||||
QImage imageOut(size, size, QImage::Format_ARGB32);
|
||||
imageOut.fill(Qt::transparent);
|
||||
|
||||
// render
|
||||
QPainter painter(&imageOut);
|
||||
svgRenderer.render(&painter);
|
||||
painter.end();
|
||||
|
||||
AdvancedSymbology::SymbolProperties symProps;
|
||||
symProps.setKey(data.name);
|
||||
symProps.setSidc(AdvancedSymbology::SidcCodec::encodeCivilEts(data.name));
|
||||
symProps.setName(data.name);
|
||||
symProps.setSymbolClass(QLatin1String("3")); // 18.10.2016, N.Thoden: 3 == PointSymbol (mil2525d.stylx - QuartzRelease)
|
||||
symProps.setGeometryType(AdvancedSymbology::GeometryType::Point); // ETS-Symbols are always Points
|
||||
symProps.setTags({data.name});
|
||||
symProps.setColorToBeReplaced(colorToBeReplaced);
|
||||
|
||||
dict.setEtsSymbol(data.id, data.name, symProps, image);
|
||||
}
|
||||
}
|
||||
|
||||
void SituationWidget::loadLayerMappings(const QString &homePath)
|
||||
{
|
||||
const QString mappingsFile = homePath + QStringLiteral("/layerMapping.json");
|
||||
|
||||
QFile f(mappingsFile);
|
||||
if (!f.open(QIODevice::ReadOnly))
|
||||
{
|
||||
fprintf(stderr, "Could not load layer mappings from '%s' - %s\n", mappingsFile.toStdString().c_str(), f.errorString().toStdString().c_str());
|
||||
WARNING_LOG(m_logger) << "Could not load layer mappings from " << mappingsFile << ": " << f.errorString();
|
||||
return;
|
||||
}
|
||||
m_layerMapping.clear();
|
||||
const QJsonObject obj = QJsonDocument::fromJson(f.readAll()).object();
|
||||
|
||||
SituationMap::MapSettingsJson settings;
|
||||
if (!settings.fromJsonObject(obj))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not parse layer mappings from " << mappingsFile;
|
||||
return;
|
||||
}
|
||||
|
||||
settings.setMapUrls(fixupUrls(settings.getMapUrls(), homePath));
|
||||
settings.setSceneUrls(fixupUrls(settings.getSceneUrls(), homePath));
|
||||
settings.setSceneObjectUrls(fixupUrls(settings.getSceneObjectUrls(), homePath));
|
||||
settings.setElevationUrls(fixupUrls(settings.getElevationUrls(), homePath));
|
||||
|
||||
m_situationMapInit->setMapSettingsJson(settings);
|
||||
}
|
||||
|
||||
QVector<SituationMap::BaseUrl> SituationWidget::fixupUrls(const QVector<SituationMap::BaseUrl> &in,
|
||||
const QString &homePath)
|
||||
{
|
||||
QVector<SituationMap::BaseUrl> out;
|
||||
for (auto url : in)
|
||||
{
|
||||
const QString fn = QStringLiteral("%1/Maps/%2").arg(homePath, url.url());
|
||||
if (!QFile::exists(fn))
|
||||
{
|
||||
fprintf(stderr, "Can not find map data file '%s'\n", fn.toStdString().c_str());
|
||||
QMessageBox::warning(this, tr("Can not find map data"),
|
||||
tr("Can not find map data file '%1' - can't start application").arg(fn));
|
||||
QCoreApplication::quit();
|
||||
return out;
|
||||
}
|
||||
url.setUrl(QUrl::fromLocalFile(fn).toString());
|
||||
out.push_back(std::move(url));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace THP
|
||||
|
||||
#include "thp_situation_widget.moc"
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Handle situation display in thp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <SituationReplay/main_handler_sqlite.h>
|
||||
#include "thp_situation_building_base.h"
|
||||
|
||||
namespace SituationReplay
|
||||
{
|
||||
class HandlerSituationReplaySqlite;
|
||||
}
|
||||
namespace SituationMap
|
||||
{
|
||||
class BaseUrl;
|
||||
struct OperatorMapSettings;
|
||||
}
|
||||
namespace FilterManagement
|
||||
{
|
||||
class AesDisplayFilter;
|
||||
class SymbolAppearanceSettings;
|
||||
class BuildingComponentSettings;
|
||||
}
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class SituationWidget;
|
||||
}
|
||||
namespace THP
|
||||
{
|
||||
class SitMapPluginProvider;
|
||||
class SituatationFilterAes;
|
||||
class SituatationFilterSymbolAppearance;
|
||||
class SituatationFilterCollapseExpand;
|
||||
class SituatationFilterTypes;
|
||||
class SituationFilterBuildingComponent;
|
||||
class MySitMapIinit;
|
||||
|
||||
class SituationWidget : public SituationBuildingBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SituationWidget(QWidget *parent = nullptr);
|
||||
~SituationWidget();
|
||||
|
||||
bool init(const QString &homePath, int exerciseId);
|
||||
|
||||
SituationReplay::MainHandlerSqlite *replayHandler() { return m_replayHandler; }
|
||||
SitMapPluginProvider *pluginProvider() { return m_pluginProvider; }
|
||||
|
||||
|
||||
QImage grabFrameBuffer() const;
|
||||
QString centerPointString() const;
|
||||
QRectF extentMgrs() const; // mgrs
|
||||
|
||||
protected:
|
||||
bool showSituationInternal() override;
|
||||
bool applyFilterFromReplayConfigFile();
|
||||
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void loadLayerMappings(const QString &homePath);
|
||||
QVector<SituationMap::BaseUrl> fixupUrls(const QVector<SituationMap::BaseUrl> &in,
|
||||
const QString &homePath);
|
||||
|
||||
bool restoreOperatorMapSettingsOverlays(const SituationMap::OperatorMapSettings &oms);
|
||||
|
||||
private Q_SLOTS:
|
||||
void applyCurentFilter(const SituationReplay::FilterInformation &filter) override;
|
||||
void applyNewOverlay(int overlayId) override;
|
||||
void removeOverlay(int overlayId) override;
|
||||
|
||||
void onFilterAes();
|
||||
void onFilterSymbolAppearance();
|
||||
void onFilterCollapseExpand();
|
||||
void onFilterTypes();
|
||||
void onFilterBuildingComponent();
|
||||
|
||||
void updateZoomSlider() override;
|
||||
|
||||
void onInitDone() override;
|
||||
void emitPartitionTimeChanged(qint64 curTime) override;
|
||||
void onMgrsGrid();
|
||||
void onRotate(int degrees);
|
||||
|
||||
void onFileContentAvailable(const FileManagement::Database::FlmFileContent &data) override;
|
||||
private:
|
||||
QVector<QPair<QString, QString>> m_layerMapping;
|
||||
|
||||
SitMapPluginProvider *m_pluginProvider{nullptr};
|
||||
MySitMapIinit *m_situationMapInit{nullptr};
|
||||
SituatationFilterAes *m_filterAesDialog{nullptr};
|
||||
SituatationFilterSymbolAppearance *m_filterSymbolAppearanceDialog{nullptr};
|
||||
SituatationFilterCollapseExpand *m_filterCollapseExpandDialog{nullptr};
|
||||
SituatationFilterTypes *m_filterTypesDialog{nullptr};
|
||||
SituationFilterBuildingComponent *m_filterBuildingComponentDialog{nullptr};
|
||||
|
||||
std::shared_ptr<FilterManagement::AesDisplayFilter> m_aesDisplayFilter;
|
||||
std::shared_ptr<FilterManagement::SymbolAppearanceSettings> m_symbolAppaearanceSettings;
|
||||
std::shared_ptr<FilterManagement::BuildingComponentSettings> m_buildingComponentSettings;
|
||||
|
||||
};
|
||||
} // namespace THP
|
||||
+237
@@ -0,0 +1,237 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* A special slider for zooming
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "thp_zoom_slider.h"
|
||||
#include <QLabel>
|
||||
#include <QSlider>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace THP
|
||||
{
|
||||
|
||||
ZoomSlider::ZoomSlider(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_InternalMin(0.1)
|
||||
, m_InternalMax(100)
|
||||
, m_LowerThreshold(1)
|
||||
, m_UpperThreshold(10)
|
||||
, m_MinRange(0)
|
||||
, m_MaxRange(280)
|
||||
, m_Slider(nullptr)
|
||||
, m_lbl(nullptr)
|
||||
, m_text(nullptr)
|
||||
, m_ZoomValue(-1)
|
||||
, m_curSliderVal(-1)
|
||||
{
|
||||
setShowDescriptionLabel(true);
|
||||
setShowValueLabel(true);
|
||||
m_Slider = new QSlider(this);
|
||||
|
||||
connect(m_Slider, &QSlider::valueChanged, this, &ZoomSlider::calcZoomFromSlider);
|
||||
connect(this, &ZoomSlider::valueChanged, this, &ZoomSlider::updateLabel);
|
||||
|
||||
m_Slider->setRange(m_MinRange, m_MaxRange);
|
||||
m_Slider->setSingleStep(1);
|
||||
m_Slider->setPageStep(1);
|
||||
|
||||
setOrientation(Qt::Horizontal);
|
||||
//Initial calculation
|
||||
calcZoomFromSlider(m_Slider->value());
|
||||
|
||||
}
|
||||
|
||||
void ZoomSlider::setZoomValue(double zoomValue)
|
||||
{
|
||||
if (qFuzzyCompare(m_ZoomValue, zoomValue))
|
||||
return;
|
||||
//ignore values outside Min/Max boundaries.
|
||||
if (zoomValue < m_InternalMin || zoomValue > m_InternalMax)
|
||||
return;
|
||||
m_ZoomValue = zoomValue;
|
||||
|
||||
if (zoomValue < m_LowerThreshold)
|
||||
{
|
||||
//Range is 0..50%
|
||||
double l_Range = (m_MaxRange - m_MinRange) / 2;
|
||||
|
||||
double l_ValToSet = l_Range / static_cast<double>(m_LowerThreshold - m_InternalMin) * (zoomValue - m_InternalMin);
|
||||
//qDebug() << "Value1 = " << l_ValToSet;
|
||||
m_curSliderVal = static_cast<int>(l_ValToSet);
|
||||
|
||||
}
|
||||
else if (zoomValue < m_UpperThreshold)
|
||||
{
|
||||
//Range is 50%..75%
|
||||
double l_Range = (m_MaxRange - m_MinRange) / 4;
|
||||
double l_ValToSet = l_Range / static_cast<double>(m_UpperThreshold - m_LowerThreshold) * (zoomValue - m_LowerThreshold);
|
||||
l_ValToSet += l_Range * 2;
|
||||
//qDebug() << "Value2 = " << l_ValToSet;
|
||||
m_curSliderVal = static_cast<int>(l_ValToSet);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//Range is 75%..100%
|
||||
double l_Range = (m_MaxRange - m_MinRange) / 4;
|
||||
double l_ValToSet = l_Range / static_cast<double>(m_InternalMax - m_UpperThreshold) * (zoomValue - m_UpperThreshold);
|
||||
l_ValToSet += l_Range * 3;
|
||||
//qDebug() << "Value3 = " << l_ValToSet;
|
||||
m_curSliderVal = static_cast<int>(l_ValToSet);
|
||||
|
||||
}
|
||||
m_Slider->setValue(m_curSliderVal);
|
||||
updateLabel(m_ZoomValue);
|
||||
}
|
||||
|
||||
double ZoomSlider::getZoomValue() const
|
||||
{
|
||||
return m_ZoomValue;
|
||||
}
|
||||
|
||||
void ZoomSlider::setOrientation(Qt::Orientation a_orientation)
|
||||
{
|
||||
if (!m_Slider)
|
||||
return;
|
||||
|
||||
m_Slider->setOrientation(a_orientation);
|
||||
QBoxLayout *l_Layout;
|
||||
if (a_orientation == Qt::Horizontal)
|
||||
{
|
||||
m_Slider->setMinimumWidth(40);
|
||||
m_Slider->setMinimumHeight(0);
|
||||
l_Layout = new QHBoxLayout;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Slider->setMinimumWidth(0);
|
||||
m_Slider->setMinimumHeight(40);
|
||||
l_Layout = new QVBoxLayout;
|
||||
}
|
||||
l_Layout->setContentsMargins(0, 0, 0, 0);
|
||||
if (m_text)
|
||||
l_Layout->addWidget(m_text);
|
||||
if (m_Slider)
|
||||
l_Layout->addWidget(m_Slider);
|
||||
if (m_lbl)
|
||||
l_Layout->addWidget(m_lbl);
|
||||
delete layout();
|
||||
setLayout(l_Layout);
|
||||
}
|
||||
|
||||
Qt::Orientation ZoomSlider::getOrientation() const
|
||||
{
|
||||
if (m_Slider)
|
||||
return m_Slider->orientation();
|
||||
return Qt::Horizontal;
|
||||
}
|
||||
|
||||
bool ZoomSlider::getShowDescriptionLabel() const
|
||||
{
|
||||
return (m_text != nullptr);
|
||||
}
|
||||
|
||||
void ZoomSlider::setShowDescriptionLabel(bool bVisible)
|
||||
{
|
||||
if (getShowDescriptionLabel() == bVisible)
|
||||
return;
|
||||
if (bVisible)
|
||||
{
|
||||
m_text = new QLabel(this);
|
||||
m_text->setText(tr("Zoom:"));
|
||||
}
|
||||
else
|
||||
{
|
||||
delete m_text;
|
||||
m_text = nullptr;
|
||||
}
|
||||
setOrientation(getOrientation());
|
||||
}
|
||||
|
||||
bool ZoomSlider::getShowValueLabel() const
|
||||
{
|
||||
return (m_lbl != nullptr);
|
||||
}
|
||||
|
||||
void ZoomSlider::setShowValueLabel(bool bVisible)
|
||||
{
|
||||
if (getShowValueLabel() == bVisible)
|
||||
return;
|
||||
if (bVisible)
|
||||
m_lbl = new QLabel(this);
|
||||
else
|
||||
{
|
||||
delete m_lbl;
|
||||
m_lbl = nullptr;
|
||||
}
|
||||
setOrientation(getOrientation());
|
||||
updateLabel(m_ZoomValue);
|
||||
}
|
||||
|
||||
|
||||
void ZoomSlider::calcZoomFromSlider(int a_value)
|
||||
{
|
||||
if (m_curSliderVal == a_value)
|
||||
return;
|
||||
m_curSliderVal = a_value;
|
||||
|
||||
if (a_value < (m_MaxRange - m_MinRange) / 2)
|
||||
{
|
||||
//Range 0% - 50%
|
||||
double l_R1 = (m_MaxRange - m_MinRange) / 2;
|
||||
double l_R2 = (m_LowerThreshold - m_InternalMin);
|
||||
double l_ValToSet = l_R2 / l_R1 * a_value;
|
||||
l_ValToSet += m_InternalMin;
|
||||
//qDebug() << "Value4 = " << l_ValToSet;
|
||||
m_ZoomValue = l_ValToSet;
|
||||
}
|
||||
else if (a_value < 3 * (m_MaxRange - m_MinRange) / 4)
|
||||
{
|
||||
//Range 50% - 75%
|
||||
double l_R1 = (m_MaxRange - m_MinRange) / 4;
|
||||
double l_R2 = (m_UpperThreshold - m_LowerThreshold);
|
||||
double l_SliderVal = a_value - (m_MaxRange - m_MinRange) / 2;
|
||||
double l_ValToSet = l_R2 / l_R1 * l_SliderVal;
|
||||
l_ValToSet += static_cast<double>(m_LowerThreshold);
|
||||
//qDebug() << "Value5 = " << l_ValToSet;
|
||||
m_ZoomValue = l_ValToSet;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Range 75% - 100%
|
||||
double l_R1 = (m_MaxRange - m_MinRange) / 4;
|
||||
double l_R2 = (m_InternalMax - m_UpperThreshold);
|
||||
double l_SliderVal = a_value - (m_MaxRange - m_MinRange) / 4 * 3;
|
||||
double l_ValToSet = l_R2 / l_R1 * l_SliderVal;
|
||||
|
||||
l_ValToSet += static_cast<double>(m_UpperThreshold);
|
||||
//qDebug() << "Value6 = " << l_ValToSet;
|
||||
m_ZoomValue = l_ValToSet;
|
||||
}
|
||||
emit valueChanged(m_ZoomValue);
|
||||
}
|
||||
|
||||
void ZoomSlider::updateLabel(double newValue)
|
||||
{
|
||||
if (!m_lbl)
|
||||
return;
|
||||
m_lbl->setText(formatValue(newValue));
|
||||
}
|
||||
|
||||
QString ZoomSlider::formatValue(double value) const
|
||||
{
|
||||
if (value < m_LowerThreshold)
|
||||
return QStringLiteral("%1x").arg(value, 4, 'f', 2);
|
||||
if (value < m_UpperThreshold)
|
||||
return QStringLiteral("%1x").arg(value, 4, 'f', 1);
|
||||
|
||||
return QStringLiteral("%1x").arg(value, 4, 'f', 0);
|
||||
}
|
||||
|
||||
} // namespace THP
|
||||
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* A special slider for zooming
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
class QSlider;
|
||||
|
||||
namespace THP
|
||||
{
|
||||
/**
|
||||
* An specialized QSlider
|
||||
* This slider has a special, fixed range from 0.1 - 100 which is mapped to
|
||||
* suitable map scales used in the GUEZ.
|
||||
* The scale is not linear - instead it has a model behind. in smaller scales -
|
||||
* slider's going to 0.1 - it's resolution is finer than on larger scales -
|
||||
* slider's going to 100.
|
||||
* The slider accpets only values within the range 0.1....100. Other values are ignored.
|
||||
*/
|
||||
class ZoomSlider : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(Qt::Orientation Orientation READ getOrientation WRITE setOrientation)
|
||||
Q_PROPERTY(bool showDescriptionLabel READ getShowDescriptionLabel WRITE setShowDescriptionLabel)
|
||||
Q_PROPERTY(bool showValueLabel READ getShowValueLabel WRITE setShowValueLabel)
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
explicit ZoomSlider(QWidget *parent = nullptr);
|
||||
|
||||
/**
|
||||
* get the actual Zoom value.
|
||||
* @return float with the zoom value
|
||||
*/
|
||||
double getZoomValue() const;
|
||||
|
||||
/**
|
||||
* Sets the Orientation.
|
||||
* @param a_orientation The slider's orientation.
|
||||
*/
|
||||
void setOrientation(Qt::Orientation a_orientation);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
Qt::Orientation getOrientation() const;
|
||||
|
||||
bool getShowDescriptionLabel() const;
|
||||
void setShowDescriptionLabel(bool bVisible);
|
||||
|
||||
bool getShowValueLabel() const;
|
||||
void setShowValueLabel(bool bVisible);
|
||||
|
||||
/**
|
||||
* format the given value as it would be shown in the zoom label
|
||||
*/
|
||||
QString formatValue(double value) const;
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* set the slider's actual zoom value. This is a QT-Slot.
|
||||
* The slider accpet only values within it's range 0.1...100.
|
||||
* Other values are ignored.
|
||||
* @param a_zoomValue the new zoom value.
|
||||
*/
|
||||
void setZoomValue(double zoomValue);
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* A QT-Signal which is emitted whenever the slider's value has changed.
|
||||
* The newly set zoom value is delivered as argument.
|
||||
*/
|
||||
void valueChanged(double a_value);
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
/**
|
||||
* Update the label text
|
||||
*/
|
||||
void updateLabel(double newValue);
|
||||
private:
|
||||
|
||||
/**
|
||||
* Contains the slider's minimum zoom value
|
||||
*/
|
||||
const double m_InternalMin;
|
||||
/**
|
||||
* Contains the slider's maximum zoom value
|
||||
*/
|
||||
const double m_InternalMax;
|
||||
/**
|
||||
* Contains the slider's lower threshold value.
|
||||
* The lower threshold is at 50% of the sliders range.
|
||||
*/
|
||||
const int m_LowerThreshold;
|
||||
/**
|
||||
* Contains the slider's upper threshold value.
|
||||
* The upper threshold is at 75% of the sliders range.
|
||||
*/
|
||||
const int m_UpperThreshold;
|
||||
/**
|
||||
* Contains the slider's range minimum value
|
||||
*/
|
||||
const int m_MinRange;
|
||||
/**
|
||||
* Contains the slider's range maximum value
|
||||
*/
|
||||
const int m_MaxRange;
|
||||
|
||||
/**
|
||||
* The QSlider
|
||||
*/
|
||||
QSlider *m_Slider;
|
||||
|
||||
/**
|
||||
* The label for showing the exact slider value.
|
||||
*/
|
||||
QLabel *m_lbl;
|
||||
|
||||
/**
|
||||
* The label for showing the 'zoom' text
|
||||
*/
|
||||
QLabel *m_text;
|
||||
|
||||
/**
|
||||
* contains the zoom value
|
||||
*/
|
||||
double m_ZoomValue;
|
||||
|
||||
/**
|
||||
* The current value of the slider to avoid loops
|
||||
*/
|
||||
int m_curSliderVal;
|
||||
|
||||
private slots :
|
||||
/**
|
||||
* Calculates the zoom value from the slider's position
|
||||
*/
|
||||
void calcZoomFromSlider(int a_value);
|
||||
|
||||
};
|
||||
} // namespace THP
|
||||
@@ -4,54 +4,30 @@
|
||||
# $Author$
|
||||
#
|
||||
|
||||
message(STATUS "Lts/Common: Entering CodeGen")
|
||||
ADD_SUBDIRECTORY(CodeGen)
|
||||
message(STATUS "Lts/Common: Entering httq")
|
||||
ADD_SUBDIRECTORY(httq)
|
||||
#ADD_SUBDIRECTORY(LtsBotan)
|
||||
message(STATUS "Lts/Common: Entering LtsCommandLineParser")
|
||||
ADD_SUBDIRECTORY(LtsCommandLineParser)
|
||||
message(STATUS "Lts/Common: Entering LtsCoordTrans")
|
||||
ADD_SUBDIRECTORY(LtsCoordTrans)
|
||||
message(STATUS "Lts/Common: Entering LtsCoordinate")
|
||||
ADD_SUBDIRECTORY(LtsCoordinate)
|
||||
message(STATUS "Lts/Common: Entering LtsElevation")
|
||||
ADD_SUBDIRECTORY(LtsElevation)
|
||||
message(STATUS "Lts/Common: Entering LtsLicence")
|
||||
ADD_SUBDIRECTORY(LtsLicence)
|
||||
message(STATUS "Lts/Common: Entering LtsPluginManager")
|
||||
ADD_SUBDIRECTORY(LtsPluginManager)
|
||||
message(STATUS "Lts/Common: Entering LtsSession")
|
||||
ADD_SUBDIRECTORY(LtsSession)
|
||||
message(STATUS "Lts/Common: Entering LtsUtils")
|
||||
ADD_SUBDIRECTORY(LtsUtils)
|
||||
message(STATUS "Lts/Common: Entering LtsWidgets")
|
||||
ADD_SUBDIRECTORY(LtsWidgets)
|
||||
ADD_SUBDIRECTORY(LtsAppDescriptor)
|
||||
ADD_SUBDIRECTORY(LtsAppManager)
|
||||
ADD_SUBDIRECTORY(LtsMultiMonitor)
|
||||
ADD_SUBDIRECTORY(LtsCommandLineParser)
|
||||
ADD_SUBDIRECTORY(LtsCoordinate)
|
||||
ADD_SUBDIRECTORY(LtsCoordTrans)
|
||||
ADD_SUBDIRECTORY(LtsElevation)
|
||||
ADD_SUBDIRECTORY(LtsLicence)
|
||||
ADD_SUBDIRECTORY(LtsLogin)
|
||||
ADD_SUBDIRECTORY(LtsMultiMonitor)
|
||||
ADD_SUBDIRECTORY(LtsNotification)
|
||||
ADD_SUBDIRECTORY(LtsTimeline)
|
||||
ADD_SUBDIRECTORY(LtsTimelineClassic)
|
||||
ADD_SUBDIRECTORY(LtsPluginManager)
|
||||
ADD_SUBDIRECTORY(LtsPrinting)
|
||||
ADD_SUBDIRECTORY(LtsSerialPortQuerry)
|
||||
IF(BUILD_RTI)
|
||||
ADD_SUBDIRECTORY(LtsScriptTimeline)
|
||||
ENDIF()
|
||||
IF(BUILD_LTSWEBSOCKET)
|
||||
ADD_SUBDIRECTORY(LtsWebSocket)
|
||||
ENDIF()
|
||||
ADD_SUBDIRECTORY(LtsProjectionWorkstation)
|
||||
ADD_SUBDIRECTORY(LtsRestClient)
|
||||
ADD_SUBDIRECTORY(LtsScriptTimeline)
|
||||
ADD_SUBDIRECTORY(LtsSerialPortQuerry)
|
||||
ADD_SUBDIRECTORY(LtsSession)
|
||||
ADD_SUBDIRECTORY(LtsTimeline)
|
||||
ADD_SUBDIRECTORY(LtsUtils)
|
||||
ADD_SUBDIRECTORY(LtsVirtualKeyboard)
|
||||
ADD_SUBDIRECTORY(LtsWebSocket)
|
||||
ADD_SUBDIRECTORY(LtsWidgets)
|
||||
ADD_SUBDIRECTORY(PluginInterfaces)
|
||||
ADD_SUBDIRECTORY(ProjectConfig)
|
||||
ADD_SUBDIRECTORY(TopicEditorBase) # TODO: rename / move ?
|
||||
#ADD_SUBDIRECTORY(LtsEventTimeline)
|
||||
#ADD_SUBDIRECTORY(LtsTranslator)
|
||||
|
||||
# Placeholder test scaffolding for incremental migration
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/CommonUnitTestsPlaceholder/CMakeLists.txt")
|
||||
add_subdirectory(CommonUnitTestsPlaceholder)
|
||||
endif()
|
||||
|
||||
ADD_SUBDIRECTORY(TopicEditorBase)
|
||||
@@ -1,54 +1,62 @@
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Generate cpp structs from xml
|
||||
* $Id: DaoGeneratorGrantlee.cpp 50446 2020-03-18 10:29:57Z ehrlicher $
|
||||
* $HeadURL: svn://192.168.133.21/TDS/branches/product/features/25_02_refactoring/Lts/Common/CodeGen/DaoGeneratorGrantlee.cpp $
|
||||
* $Author: ehrlicher $
|
||||
*/
|
||||
|
||||
#include "DaoGeneratorGrantlee.h"
|
||||
|
||||
#include "StructBuilder.h"
|
||||
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <ktexttemplate/context.h>
|
||||
#include <grantlee/context.h>
|
||||
|
||||
using namespace CodeGen;
|
||||
|
||||
DaoGeneratorGrantlee::DaoGeneratorGrantlee() : GeneratorGrantleeBase("CodeGen.DaoGeneratorGrantlee") {}
|
||||
DaoGeneratorGrantlee::DaoGeneratorGrantlee()
|
||||
: GeneratorGrantleeBase("CodeGen.DaoGeneratorGrantlee")
|
||||
{}
|
||||
|
||||
bool DaoGeneratorGrantlee::init(const XmlReader* reader, StructBuilder* structBuilder)
|
||||
bool DaoGeneratorGrantlee::init(const XmlReader *reader,
|
||||
StructBuilder *structBuilder)
|
||||
{
|
||||
if (!GeneratorGrantleeBase::initInternal(reader, structBuilder))
|
||||
return false;
|
||||
if (!GeneratorGrantleeBase::initInternal(reader, structBuilder))
|
||||
return false;
|
||||
|
||||
if (reader->isServiceExerciseIndependent())
|
||||
m_ctx->insert(QStringLiteral("isExerciseIndependent"), QLatin1String("1"));
|
||||
// Is Service exercise-independent?
|
||||
if (reader->isServiceExerciseIndependent())
|
||||
m_ctx->insert(QStringLiteral("isExerciseIndependent"), QLatin1String("1"));
|
||||
|
||||
bool bHasDbNotifications = false;
|
||||
QVector<DbStructWrapper*> vlServiceStructs;
|
||||
QVector<DbStructWrapper*> vlStaticDataStructs;
|
||||
const QVector<CompleteStructInformation> csiData = structBuilder->structInformations();
|
||||
vlServiceStructs.reserve(csiData.size());
|
||||
vlStaticDataStructs.reserve(csiData.size());
|
||||
for (const CompleteStructInformation& csi : csiData)
|
||||
{
|
||||
DbStructWrapper* dbStructWrapper(new DbStructWrapper(csi, this));
|
||||
bool bHasDbNotifications = false;
|
||||
QVector<DbStructWrapper *> vlServiceStructs;
|
||||
QVector<DbStructWrapper *> vlStaticDataStructs;
|
||||
const QVector<CompleteStructInformation> csiData = structBuilder->structInformations();
|
||||
vlServiceStructs.reserve(csiData.size());
|
||||
vlStaticDataStructs.reserve(csiData.size());
|
||||
for (const CompleteStructInformation &csi : csiData)
|
||||
{
|
||||
DbStructWrapper *dbStructWrapper(new DbStructWrapper(csi, this));
|
||||
|
||||
if (csi.hasStaticContent)
|
||||
vlStaticDataStructs += dbStructWrapper;
|
||||
else
|
||||
vlServiceStructs += dbStructWrapper;
|
||||
if (!csi.dbNotifications.isEmpty())
|
||||
bHasDbNotifications = true;
|
||||
}
|
||||
if (csi.hasStaticContent)
|
||||
vlStaticDataStructs += dbStructWrapper;
|
||||
else
|
||||
vlServiceStructs += dbStructWrapper;
|
||||
if (!csi.dbNotifications.isEmpty())
|
||||
bHasDbNotifications = true;
|
||||
}
|
||||
|
||||
if (structBuilder->needPoint3d())
|
||||
m_ctx->insert(QStringLiteral("need_point3d"), QLatin1String("1"));
|
||||
if (structBuilder->needPgArrayInclude())
|
||||
m_ctx->insert(QStringLiteral("need_pgarray"), QLatin1String("1"));
|
||||
m_ctx->insert(QStringLiteral("cpp_structs"), QVariant::fromValue(vlServiceStructs));
|
||||
m_ctx->insert(QStringLiteral("data_structs"), QVariant::fromValue(vlStaticDataStructs));
|
||||
if (bHasDbNotifications)
|
||||
m_ctx->insert(QStringLiteral("has_db_notifications"), QLatin1String("1"));
|
||||
if (structBuilder->needPoint3d())
|
||||
m_ctx->insert(QStringLiteral("need_point3d"), QLatin1String("1"));
|
||||
if (structBuilder->needPgArrayInclude())
|
||||
m_ctx->insert(QStringLiteral("need_pgarray"), QLatin1String("1"));
|
||||
m_ctx->insert(QStringLiteral("cpp_structs"), QVariant::fromValue(vlServiceStructs));
|
||||
m_ctx->insert(QStringLiteral("data_structs"), QVariant::fromValue(vlStaticDataStructs));
|
||||
if (bHasDbNotifications)
|
||||
m_ctx->insert(QStringLiteral("has_db_notifications"), QLatin1String("1"));
|
||||
|
||||
m_ctx->insert(QStringLiteral("library_target"), QStringLiteral("COMMON"));
|
||||
m_ctx->insert(QStringLiteral("library_target"), QStringLiteral("COMMON"));
|
||||
|
||||
exportUsedServices(reader);
|
||||
exportUsedServices(reader);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
@@ -1,11 +1,16 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Generate cpp structs from xml
|
||||
* $Id: DaoGeneratorGrantlee.h 50446 2020-03-18 10:29:57Z ehrlicher $
|
||||
* $HeadURL: svn://192.168.133.21/TDS/branches/product/features/25_02_refactoring/Lts/Common/CodeGen/DaoGeneratorGrantlee.h $
|
||||
* $Author: ehrlicher $
|
||||
*/
|
||||
#pragma once
|
||||
#include "GeneratorGrantleeBase.h"
|
||||
#include "GrantleeWrappers.h"
|
||||
#include "StructBuilder.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include "GeneratorGrantleeBase.h"
|
||||
#include "StructBuilder.h"
|
||||
#include "GrantleeWrappers.h"
|
||||
#include "codegen_export.h"
|
||||
|
||||
namespace CodeGen
|
||||
{
|
||||
@@ -13,12 +18,13 @@ struct CompleteStructInformation;
|
||||
class StructBuilder;
|
||||
class XmlReader;
|
||||
|
||||
|
||||
class DaoGeneratorGrantlee final : public GeneratorGrantleeBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DaoGeneratorGrantlee();
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DaoGeneratorGrantlee();
|
||||
|
||||
bool init(const XmlReader* reader, StructBuilder* structBuilder) override;
|
||||
bool init(const XmlReader *reader, StructBuilder *structBuilder) override;
|
||||
};
|
||||
} // namespace CodeGen
|
||||
@@ -20,9 +20,9 @@ namespace {{ namespace }}
|
||||
//
|
||||
QString toString({{ idl_enum.name }} state)
|
||||
{
|
||||
switch(static_cast<int>(state))
|
||||
switch(state)
|
||||
{{% for idl_member in idl_enum.member %}
|
||||
case static_cast<int>({{ idl_enum.name }}::{{ idl_member.key }}): return QCoreApplication::translate("{{ idl_enum.name }}", "{{ idl_member.key }}");
|
||||
case {{ idl_enum.name }}::{{ idl_member.key }}: return QCoreApplication::translate("{{ idl_enum.name }}", "{{ idl_member.key }}");
|
||||
{% endfor %}
|
||||
default: break;
|
||||
}
|
||||
|
||||
@@ -1,95 +1,104 @@
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* App Descriptor - Class to modify App Descriptor JSON Documents
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2016-10-24
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QVector>
|
||||
#include <QVector>
|
||||
#include <QStringList>
|
||||
|
||||
#ifndef LTSAPPDESCRIPTOR_EXPORT
|
||||
#ifdef BUILD_STATIC_LIBRARIES
|
||||
#define LTSAPPDESCRIPTOR_EXPORT
|
||||
#else
|
||||
#if defined(MAKE_LTSAPPDESCRIPTOR_LIB)
|
||||
#define LTSAPPDESCRIPTOR_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
#define LTSAPPDESCRIPTOR_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define LTSAPPDESCRIPTOR_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_LTSAPPDESCRIPTOR_LIB)
|
||||
# define LTSAPPDESCRIPTOR_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define LTSAPPDESCRIPTOR_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
namespace LtsAppDescriptor
|
||||
{
|
||||
|
||||
enum class App {
|
||||
Login = -1,
|
||||
Situation = 0,
|
||||
ResourceManager = 1,
|
||||
PlanEditor = 2,
|
||||
BuildingViewer = 3,
|
||||
OC = 4,
|
||||
OrgChart = 5,
|
||||
Scripts = 6,
|
||||
|
||||
Snapshot = 8,
|
||||
SystemMonitor = 9,
|
||||
Timeline = 10,
|
||||
SymbolEditor = 11,
|
||||
ScriptEditorEssentialsView = 12,
|
||||
BaseDownloader = 13,
|
||||
OnlineHelp = 14,
|
||||
ThpSituationReplay = 15,
|
||||
SituationTablet = 17,
|
||||
SilhouetteEditor = 18,
|
||||
Shootback = 19,
|
||||
SAAs = 20,
|
||||
enum class App
|
||||
{
|
||||
Login = -1,
|
||||
Situation = 0,
|
||||
ResourceManager = 1,
|
||||
PlanEditor = 2,
|
||||
BuildingViewer = 3,
|
||||
OC = 4,
|
||||
OrgChart = 5,
|
||||
Scripts = 6,
|
||||
// merged into Scripts (aka. ScriptEditor) ScriptPlayer = 7,
|
||||
Snapshot = 8,
|
||||
SystemMonitor = 9,
|
||||
Timeline = 10,
|
||||
SymbolEditor = 11,
|
||||
ScriptEditorEssentialsView = 12,
|
||||
BaseDownloader = 13,
|
||||
OnlineHelp = 14,
|
||||
ThpSituationReplay = 15,
|
||||
SituationTablet = 17,
|
||||
SilhouetteEditor = 18, // for L400P2
|
||||
Shootback = 19, // for L400P2
|
||||
SAAs = 20, //Schnittstelle Adapter Adler
|
||||
};
|
||||
|
||||
struct PluginInfo
|
||||
{
|
||||
enum class PluginType {
|
||||
UNKNOWN,
|
||||
DATA,
|
||||
GUI,
|
||||
};
|
||||
enum class PluginType
|
||||
{
|
||||
UNKNOWN,
|
||||
DATA,
|
||||
GUI,
|
||||
GUI_ELEMENT,
|
||||
};
|
||||
|
||||
enum class Flag {
|
||||
UNKNOWN = 1 << 0,
|
||||
ACTIONS = 1 << 1,
|
||||
MAIN = 1 << 2,
|
||||
PAYLOAD = 1 << 3,
|
||||
OPTION = 1 << 4,
|
||||
};
|
||||
enum class Flag
|
||||
{
|
||||
UNKNOWN = 1 << 0,
|
||||
ACTIONS = 1 << 1,
|
||||
MAIN = 1 << 2,
|
||||
PAYLOAD = 1 << 3,
|
||||
OPTION = 1 << 4,
|
||||
};
|
||||
|
||||
PluginType type = PluginType::UNKNOWN;
|
||||
QString iid;
|
||||
QFlags<Flag> flags;
|
||||
QStringList options;
|
||||
PluginType type = PluginType::UNKNOWN;
|
||||
QString iid;
|
||||
QFlags<Flag> flags;
|
||||
QStringList options;
|
||||
};
|
||||
|
||||
struct AppDescription
|
||||
{
|
||||
App id = App::Login;
|
||||
bool active = false;
|
||||
bool visible = true;
|
||||
QString appName;
|
||||
QVector<int> requiredAcls;
|
||||
QVector<PluginInfo> pluginInfos;
|
||||
App id = App::Login;
|
||||
bool active = false;
|
||||
bool visible = true;
|
||||
QString appName;
|
||||
QVector<int> requiredAcls;
|
||||
QVector<PluginInfo> pluginInfos;
|
||||
|
||||
bool isValid() const
|
||||
{
|
||||
return !appName.isEmpty();
|
||||
}
|
||||
bool isValid() const { return !appName.isEmpty(); }
|
||||
};
|
||||
|
||||
typedef QVector<AppDescription> AppDescriptionVector;
|
||||
|
||||
namespace LtsAppDescriptor
|
||||
|
||||
namespace LtsAppDescriptor // TODO: make qobject class singleton - for tr
|
||||
{
|
||||
LTSAPPDESCRIPTOR_EXPORT App appFromInteger(int i);
|
||||
LTSAPPDESCRIPTOR_EXPORT AppDescriptionVector getAppDescriptionVector(const QByteArray& jsonDocument,
|
||||
QStringList& lastErrors,
|
||||
const QStringList& ignoredPlugins,
|
||||
QString& loginPluginIid);
|
||||
} // namespace LtsAppDescriptor
|
||||
LTSAPPDESCRIPTOR_EXPORT AppDescriptionVector getAppDescriptionVector(const QByteArray &jsonDocument, QStringList &lastErrors,
|
||||
const QStringList &ignoredPlugins, QString &loginPluginIid);
|
||||
}
|
||||
|
||||
} // namespace LtsAppDescriptor
|
||||
+398
-350
@@ -1,416 +1,464 @@
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* plugin loader helper function
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#include "lts_plugin_loader.h"
|
||||
|
||||
#include <LtsAppDescriptor/lts_app_descriptor.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QDebug>
|
||||
#include <LtsAppDescriptor/lts_app_descriptor.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDirIterator>
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QFileInfo>
|
||||
#include <QJsonObject>
|
||||
#include <QPluginLoader>
|
||||
#include <QMutableListIterator>
|
||||
#include <QtCore/QPluginLoader>
|
||||
#include <utility>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
namespace LtsPluginManager
|
||||
{
|
||||
|
||||
struct LtsPluginLoaderHandler
|
||||
{
|
||||
LtsPluginLoader ltsPluginLoader;
|
||||
|
||||
static NGL::INGLLogger& logger()
|
||||
{
|
||||
return NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("LtsPluginLoader");
|
||||
}
|
||||
|
||||
static void cleanupPluginLoader();
|
||||
LtsPluginLoader ltsPluginLoader;
|
||||
static NGL::INGLLogger &logger() { return NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("LtsPluginLoader"); }
|
||||
static void cleanupPluginLoader();
|
||||
};
|
||||
Q_GLOBAL_STATIC(LtsPluginLoaderHandler, s_ltsPluginLoader)
|
||||
|
||||
void LtsPluginLoaderHandler::cleanupPluginLoader()
|
||||
{
|
||||
if (s_ltsPluginLoader.exists())
|
||||
s_ltsPluginLoader->ltsPluginLoader.unloadAllPlugins();
|
||||
if (s_ltsPluginLoader.exists())
|
||||
s_ltsPluginLoader->ltsPluginLoader.unloadAllPlugins();
|
||||
}
|
||||
|
||||
LtsPluginLoader* LtsPluginLoader::getInstance()
|
||||
|
||||
LtsPluginLoader *LtsPluginLoader::getInstance()
|
||||
{
|
||||
if (!s_ltsPluginLoader.exists())
|
||||
qAddPostRoutine(&LtsPluginLoaderHandler::cleanupPluginLoader);
|
||||
return &s_ltsPluginLoader->ltsPluginLoader;
|
||||
if (!s_ltsPluginLoader.exists())
|
||||
qAddPostRoutine(&LtsPluginLoaderHandler::cleanupPluginLoader);
|
||||
return &s_ltsPluginLoader->ltsPluginLoader;
|
||||
}
|
||||
|
||||
|
||||
LtsPluginLoader::~LtsPluginLoader()
|
||||
{
|
||||
unloadAllPlugins();
|
||||
unloadAllPlugins();
|
||||
}
|
||||
|
||||
void LtsPluginLoader::unloadAllPlugins()
|
||||
{
|
||||
for (auto& pi : std::as_const(m_loadedPlugins))
|
||||
{
|
||||
QPluginLoader* pluginLoader = pi.pluginLoader;
|
||||
for (auto &pi : qAsConst(m_loadedPlugins))
|
||||
{
|
||||
QPluginLoader *pluginLoader = pi.pluginLoader;
|
||||
|
||||
delete pluginLoader->instance();
|
||||
delete pluginLoader->instance();
|
||||
|
||||
if (!pluginLoader->unload())
|
||||
qWarning() << "~LtsPluginLoader: could not unload" << pi.pluginName << pluginLoader->errorString();
|
||||
if (!pluginLoader->unload())
|
||||
qWarning() << "~LtsPluginLoader: could not unload" << pi.pluginName << pluginLoader->errorString();
|
||||
|
||||
delete pluginLoader;
|
||||
}
|
||||
m_loadedPlugins.clear();
|
||||
delete pluginLoader;
|
||||
}
|
||||
m_loadedPlugins.clear();
|
||||
}
|
||||
|
||||
void LtsPluginLoader::checkPlugins(const QVector<LtsAppDescriptor::AppDescription>& appVector, QStringList& errors)
|
||||
|
||||
void LtsPluginLoader::checkPlugins(const QVector<LtsAppDescriptor::AppDescription> &appVector,
|
||||
QStringList &errors /* out */)
|
||||
{
|
||||
NGL::INGLLogger& logger = LtsPluginLoaderHandler::logger();
|
||||
|
||||
if (appVector.isEmpty())
|
||||
{
|
||||
errors += QStringLiteral("No Apps available");
|
||||
return;
|
||||
}
|
||||
|
||||
QVector<PluginInstance> dataPlugins;
|
||||
QVector<PluginInstance> guiPlugins;
|
||||
auto addDataPluginFn = [&](const PluginInstance& pi) {
|
||||
dataPlugins.append(pi);
|
||||
return true;
|
||||
};
|
||||
auto addGuiPluginFn = [&](const PluginInstance& pi) {
|
||||
guiPlugins.append(pi);
|
||||
return true;
|
||||
};
|
||||
|
||||
if (!loadPlugins(PluginType::DATA, addDataPluginFn))
|
||||
{
|
||||
errors += QStringLiteral("failed to load data plugins");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!loadPlugins(PluginType::GUI, addGuiPluginFn))
|
||||
{
|
||||
errors += QStringLiteral("failed to load gui plugins");
|
||||
return;
|
||||
}
|
||||
|
||||
auto checkDuplicateIidsFn = [&](const QVector<PluginInstance>& plugins, const QString& pluginType) {
|
||||
typedef QMap<QString, QString> IidMap;
|
||||
IidMap iids;
|
||||
|
||||
for (auto i3 = plugins.constBegin(); i3 != plugins.constEnd(); ++i3)
|
||||
{
|
||||
const PluginInstance& pin = *i3;
|
||||
auto iidFound = iids.constFind(pin.pluginName);
|
||||
|
||||
if (iidFound != iids.constEnd())
|
||||
errors += QStringLiteral("Iid duplicate for %1 plugin '%2'").arg(pluginType, pin.pluginName);
|
||||
else
|
||||
iids.insert(pin.pluginName, pin.fullFileName);
|
||||
}
|
||||
};
|
||||
|
||||
checkDuplicateIidsFn(dataPlugins, QStringLiteral("data"));
|
||||
checkDuplicateIidsFn(guiPlugins, QStringLiteral("gui"));
|
||||
|
||||
QVector<PluginInstance> plugins(dataPlugins + guiPlugins);
|
||||
|
||||
for (auto i1 = appVector.constBegin(); i1 != appVector.constEnd(); ++i1)
|
||||
{
|
||||
const LtsAppDescriptor::AppDescription& app = *i1;
|
||||
|
||||
const QVector<LtsAppDescriptor::PluginInfo>& piVector = app.pluginInfos;
|
||||
|
||||
for (auto i2 = piVector.constBegin(); i2 != piVector.constEnd(); i2++)
|
||||
{
|
||||
const LtsAppDescriptor::PluginInfo& pi = *i2;
|
||||
bool found = false;
|
||||
|
||||
for (auto i3 = plugins.constBegin(); i3 != plugins.constEnd(); ++i3)
|
||||
{
|
||||
const PluginInstance& pin = *i3;
|
||||
|
||||
if (pi.iid == pin.pluginName)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
ERROR_LOG(logger) << "Plugin with iid '" << pi.iid << "' was requested but was not loaded!";
|
||||
errors +=
|
||||
QStringLiteral("App '%1' requires plugin '%2' that could not be found.").arg(app.appName, pi.iid);
|
||||
}
|
||||
}
|
||||
}
|
||||
NGL::INGLLogger &logger = LtsPluginLoaderHandler::logger();
|
||||
|
||||
if (appVector.isEmpty())
|
||||
{
|
||||
errors += QStringLiteral("No Apps available");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QVector<PluginInstance> dataPlugins;
|
||||
QVector<PluginInstance> guiPlugins;
|
||||
auto addDataPluginFn = [&](const PluginInstance &pi)
|
||||
{
|
||||
dataPlugins.append(pi);
|
||||
return true;
|
||||
};
|
||||
auto addGuiPluginFn = [&](const PluginInstance &pi)
|
||||
{
|
||||
guiPlugins.append(pi);
|
||||
return true;
|
||||
};
|
||||
|
||||
if (!loadPlugins(PluginType::DATA, addDataPluginFn))
|
||||
{
|
||||
errors += QStringLiteral("failed to load data plugins");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!loadPlugins(PluginType::GUI, addGuiPluginFn))
|
||||
{
|
||||
errors += QStringLiteral("failed to load gui plugins");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// check for duplicate iids per plugin type
|
||||
auto checkDuplicateIidsFn = [&](const QVector<PluginInstance> &plugins, const QString &pluginType)
|
||||
{
|
||||
typedef QMap<QString /*iid*/, QString /*filename*/> IidMap;
|
||||
IidMap iids;
|
||||
|
||||
for (auto i3 = plugins.constBegin(); i3 != plugins.constEnd(); ++i3)
|
||||
{
|
||||
const PluginInstance &pin = *i3;
|
||||
auto iidFound = iids.constFind(pin.pluginName);
|
||||
|
||||
if (iidFound != iids.constEnd())
|
||||
errors += QStringLiteral("Iid duplicate for %1 plugin '%2'").arg(pluginType, pin.pluginName);
|
||||
else
|
||||
iids.insert(pin.pluginName, pin.fullFileName);
|
||||
}
|
||||
};
|
||||
|
||||
checkDuplicateIidsFn(dataPlugins, QStringLiteral("data"));
|
||||
checkDuplicateIidsFn(guiPlugins, QStringLiteral("gui"));
|
||||
|
||||
|
||||
|
||||
QVector<PluginInstance> plugins(dataPlugins + guiPlugins);
|
||||
|
||||
|
||||
// check if all in apps.json requested plugins are available
|
||||
for (auto i1 = appVector.constBegin(); i1 != appVector.constEnd(); ++i1) // Apps
|
||||
{
|
||||
const LtsAppDescriptor::AppDescription &app = *i1;
|
||||
|
||||
//WARNING_LOG(logger) << "Checking app '"<<app.appName<<"'";
|
||||
|
||||
const QVector<LtsAppDescriptor::PluginInfo> &piVector = app.pluginInfos;
|
||||
|
||||
for (auto i2 = piVector.constBegin(); i2 != piVector.constEnd(); i2++) // App's Required Plugins
|
||||
{
|
||||
const LtsAppDescriptor::PluginInfo &pi = *i2;
|
||||
bool found = false;
|
||||
|
||||
for (auto i3 = plugins.constBegin(); i3 != plugins.constEnd(); ++i3) // Available Plugins
|
||||
{
|
||||
const PluginInstance &pin = *i3;
|
||||
|
||||
if (pi.iid == pin.pluginName)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
ERROR_LOG(logger) << "Plugin with iid '" << pi.iid << "' was requested but was not loaded!";
|
||||
errors += QStringLiteral("App '%1' requires plugin '%2' that could not be found.").arg(app.appName, pi.iid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
|
||||
const std::function<bool(const PluginInstance&)>& loadPlugin,
|
||||
const QStringList& requiredPlugins, const QString& specialTopicTypeFilter,
|
||||
const QStringList& optionalPlugins)
|
||||
const std::function<bool(const PluginInstance &)> &loadPlugin,
|
||||
const QStringList &requiredPlugins,
|
||||
const QString &specialTopicTypeFilter,
|
||||
const QStringList &optionalPlugins)
|
||||
{
|
||||
NGL::INGLLogger& logger = LtsPluginLoaderHandler::logger();
|
||||
Q_ASSERT(requestedPluginType != PluginType::UNKNOWN);
|
||||
NGL::INGLLogger &logger = LtsPluginLoaderHandler::logger();
|
||||
Q_ASSERT(requestedPluginType != PluginType::UNKNOWN); // do not allow to look for unknown
|
||||
|
||||
QStringList requiredPluginsList = requiredPlugins;
|
||||
QStringList optionalPluginsList = optionalPlugins;
|
||||
bool checkPluginsLists = (!requiredPluginsList.isEmpty()) || (!optionalPluginsList.isEmpty());
|
||||
QStringList requiredPluginsList = requiredPlugins; // copy ...
|
||||
QStringList optionalPluginsList = optionalPlugins; // copy ...
|
||||
bool checkPluginsLists = (!requiredPluginsList.isEmpty()) || (!optionalPluginsList.isEmpty());
|
||||
|
||||
if (checkPluginsLists && !m_loadedPlugins.isEmpty())
|
||||
if (checkPluginsLists && !m_loadedPlugins.isEmpty()) // only lookup of there is something to lookup TODO: faster to NOT do that check?
|
||||
{
|
||||
{
|
||||
QMutableListIterator<QString> i1(requiredPluginsList); // delete all plugins from the to-load list that were cached
|
||||
|
||||
while (i1.hasNext())
|
||||
{
|
||||
const QString pluginName = i1.next().toLower();
|
||||
|
||||
QMap<PluginKey, PluginInstance>::iterator i2 = m_loadedPlugins.find(PluginKey(requestedPluginType, pluginName));
|
||||
|
||||
if (i2 != m_loadedPlugins.end())
|
||||
{
|
||||
QMutableListIterator<QString> i1(requiredPluginsList);
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " already loaded, using that instance";
|
||||
|
||||
while (i1.hasNext())
|
||||
{
|
||||
const QString pluginName = i1.next().toLower();
|
||||
if (loadPlugin)
|
||||
loadPlugin(i2.value());
|
||||
|
||||
QMap<PluginKey, PluginInstance>::iterator i2 =
|
||||
m_loadedPlugins.find(PluginKey(requestedPluginType, pluginName));
|
||||
|
||||
if (i2 != m_loadedPlugins.end())
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " already loaded, using that instance";
|
||||
|
||||
if (loadPlugin)
|
||||
loadPlugin(i2.value());
|
||||
|
||||
i1.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
QMutableListIterator<QString> i1(optionalPluginsList);
|
||||
|
||||
while (i1.hasNext())
|
||||
{
|
||||
const QString pluginName = i1.next().toLower();
|
||||
|
||||
QMap<PluginKey, PluginInstance>::iterator i2 =
|
||||
m_loadedPlugins.find(PluginKey(requestedPluginType, pluginName));
|
||||
|
||||
if (i2 != m_loadedPlugins.end())
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " already loaded, using that instance";
|
||||
|
||||
if (loadPlugin)
|
||||
loadPlugin(i2.value());
|
||||
|
||||
i1.remove();
|
||||
}
|
||||
}
|
||||
i1.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QFileInfo libPathInfo(QCoreApplication::applicationDirPath() + QStringLiteral("/../lib/"));
|
||||
QString libPath(libPathInfo.absolutePath());
|
||||
if (!libPathInfo.exists())
|
||||
{
|
||||
|
||||
libPathInfo.setFile(QCoreApplication::applicationFilePath());
|
||||
libPath = libPathInfo.absolutePath();
|
||||
{
|
||||
QMutableListIterator<QString> i1(optionalPluginsList); // delete all plugins from the to-load list that were cached
|
||||
|
||||
while (i1.hasNext())
|
||||
{
|
||||
const QString pluginName = i1.next().toLower();
|
||||
|
||||
QMap<PluginKey, PluginInstance>::iterator i2 = m_loadedPlugins.find(PluginKey(requestedPluginType, pluginName));
|
||||
|
||||
if (i2 != m_loadedPlugins.end())
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " already loaded, using that instance";
|
||||
|
||||
if (loadPlugin)
|
||||
loadPlugin(i2.value());
|
||||
|
||||
i1.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QFileInfo libPathInfo(QCoreApplication::applicationDirPath() + QStringLiteral("/../lib/"));
|
||||
QString libPath(libPathInfo.absolutePath());
|
||||
if (!libPathInfo.exists())
|
||||
{
|
||||
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* In case of windows systems all libs are located in application directory. But can't
|
||||
* use QCoreApplication::applicationDirPath here, because it points some times to the
|
||||
* wrong directory.
|
||||
* 2016/10/18 JT
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
|
||||
libPathInfo.setFile(QCoreApplication::applicationFilePath());
|
||||
libPath = libPathInfo.absolutePath();
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
const QStringList nameFilter = QStringList(QStringLiteral("*Plugin*.dll"));
|
||||
const QStringList nameFilter = QStringList(QStringLiteral("*Plugin*.dll"));
|
||||
#else
|
||||
const QStringList nameFilter = QStringList(QStringLiteral("*Plugin*.so"));
|
||||
const QStringList nameFilter = QStringList(QStringLiteral("*Plugin*.so"));
|
||||
#endif
|
||||
|
||||
static const QStringList pluginTypes({QStringLiteral("data"), QStringLiteral("gui"), QStringLiteral("topic_type"),
|
||||
QStringLiteral("project"), QStringLiteral("style"),
|
||||
QStringLiteral("special")});
|
||||
static const QStringList pluginTypes({QStringLiteral("data"),
|
||||
QStringLiteral("gui"),
|
||||
QStringLiteral("topic_type"),
|
||||
QStringLiteral("project"),
|
||||
QStringLiteral("style"),
|
||||
QStringLiteral("special"),
|
||||
QStringLiteral("gui_element")}); // #warning TODO: recordreplay is a data plugin ?
|
||||
|
||||
QDirIterator pluginDir(libPath, nameFilter, QDir::Files);
|
||||
while (pluginDir.hasNext())
|
||||
QDirIterator pluginDir(libPath, nameFilter, QDir::Files);
|
||||
while (pluginDir.hasNext())
|
||||
{
|
||||
pluginDir.next();
|
||||
const QString filename = pluginDir.fileName();
|
||||
if (filename.contains(QStringLiteral("PluginInterface"), Qt::CaseSensitive))
|
||||
continue;
|
||||
|
||||
const QString absoluteFilePath = pluginDir.filePath();
|
||||
|
||||
DEBUG_LOG(logger) << "File Path: " << absoluteFilePath;
|
||||
|
||||
// if (!filename.contains(type))
|
||||
// {
|
||||
// pluginInfo.resultType = ResultType::WRONG_TYPE;
|
||||
// pluginInfos.append(pluginInfo);
|
||||
// continue;
|
||||
// }
|
||||
|
||||
QScopedPointer<QPluginLoader> pluginLoader(new QPluginLoader);
|
||||
pluginLoader->setFileName(absoluteFilePath);
|
||||
|
||||
const QJsonObject jObj = pluginLoader->metaData();
|
||||
QJsonObject::const_iterator iid = jObj.find(QStringLiteral("IID"));
|
||||
|
||||
if (iid == jObj.end())
|
||||
{
|
||||
pluginDir.next();
|
||||
const QString filename = pluginDir.fileName();
|
||||
if (filename.contains(QStringLiteral("PluginInterface"), Qt::CaseSensitive))
|
||||
continue;
|
||||
|
||||
const QString absoluteFilePath = pluginDir.filePath();
|
||||
|
||||
DEBUG_LOG(logger) << "File Path: " << absoluteFilePath;
|
||||
|
||||
QScopedPointer<QPluginLoader> pluginLoader(new QPluginLoader);
|
||||
pluginLoader->setFileName(absoluteFilePath);
|
||||
|
||||
const QJsonObject jObj = pluginLoader->metaData();
|
||||
QJsonObject::const_iterator iid = jObj.find(QStringLiteral("IID"));
|
||||
|
||||
if (iid == jObj.end())
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin '" << filename << "' has no IID !";
|
||||
continue;
|
||||
}
|
||||
|
||||
const QString jsonIid = iid.value().toString().toLower();
|
||||
const QStringList iidParameters = QString(jsonIid).split(QLatin1Char(':'));
|
||||
|
||||
DEBUG_LOG(logger) << "Plugin " << absoluteFilePath << " provides iid '" << jsonIid;
|
||||
|
||||
if (iidParameters.count() != 3)
|
||||
{
|
||||
WARNING_LOG(logger) << "Invalid iid " << jsonIid << " for plugin " << filename;
|
||||
continue;
|
||||
}
|
||||
|
||||
bool ok = false;
|
||||
int pluginLoaderVersion = iidParameters.at(1).toInt(&ok);
|
||||
|
||||
if (!ok || pluginLoaderVersion != PLUGIN_LOADER_VERSION)
|
||||
{
|
||||
WARNING_LOG(logger) << "Invalid plugin loader version" << pluginLoaderVersion << "for plugin:" << filename;
|
||||
continue;
|
||||
}
|
||||
|
||||
PluginType pluginType = PluginType::UNKNOWN;
|
||||
|
||||
const QString pluginName = iidParameters.at(2);
|
||||
const QString pluginTypeString = iidParameters.at(0);
|
||||
switch (pluginTypes.indexOf(pluginTypeString))
|
||||
{
|
||||
case 0:
|
||||
pluginType = PluginType::DATA;
|
||||
break;
|
||||
case 1:
|
||||
pluginType = PluginType::GUI;
|
||||
break;
|
||||
case 2:
|
||||
pluginType = PluginType::TOPIC_TYPE;
|
||||
break;
|
||||
case 3:
|
||||
pluginType = PluginType::PROJECT;
|
||||
break;
|
||||
case 4:
|
||||
pluginType = PluginType::STYLE;
|
||||
break;
|
||||
case 5:
|
||||
pluginType = PluginType::SPECIAL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (pluginType != requestedPluginType)
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin provides not the requested type " << (int)requestedPluginType
|
||||
<< " is: " << (int)pluginType;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pluginType == PluginType::SPECIAL && !specialTopicTypeFilter.isEmpty())
|
||||
{
|
||||
if (!pluginName.startsWith(specialTopicTypeFilter))
|
||||
{
|
||||
DEBUG_LOG(logger) << "Special plugin, but filter does not match: " << pluginName << " - "
|
||||
<< specialTopicTypeFilter;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkPluginsLists)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
{
|
||||
QMutableListIterator<QString> i(requiredPluginsList);
|
||||
|
||||
while (i.hasNext())
|
||||
{
|
||||
const QString requiredPlugin = i.next().toLower();
|
||||
|
||||
if (pluginName == requiredPlugin)
|
||||
{
|
||||
found = true;
|
||||
i.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
for (auto i = optionalPluginsList.constBegin(); i != optionalPluginsList.constEnd(); i++)
|
||||
{
|
||||
const QString optionalPlugin = (*i).toLower();
|
||||
|
||||
if (pluginName == optionalPlugin)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " was not requested";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (loadPlugin && !m_loadedPlugins.isEmpty())
|
||||
{
|
||||
QMap<PluginKey, PluginInstance>::iterator i =
|
||||
m_loadedPlugins.find(PluginKey(requestedPluginType, pluginName));
|
||||
|
||||
if (i != m_loadedPlugins.end())
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " already loaded, using that instance ("
|
||||
<< i.value().plugin->metaObject()->className() << ")";
|
||||
|
||||
loadPlugin(i.value());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
QObject* plugin = pluginLoader->instance();
|
||||
|
||||
if (!plugin)
|
||||
{
|
||||
ERROR_LOG(logger) << "Failed to load " << filename << " - " << pluginLoader->errorString();
|
||||
continue;
|
||||
}
|
||||
|
||||
PluginInstance pi;
|
||||
pi.pluginName = pluginName;
|
||||
pi.fileName = filename;
|
||||
pi.fullFileName = absoluteFilePath;
|
||||
pi.plugin = plugin;
|
||||
pi.pluginLoader = pluginLoader.data();
|
||||
|
||||
if (loadPlugin && !loadPlugin(pi))
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " unloaded";
|
||||
delete pluginLoader->instance();
|
||||
pluginLoader->unload();
|
||||
continue;
|
||||
}
|
||||
pi.pluginLoader = pluginLoader.take();
|
||||
|
||||
m_loadedPlugins.insert(PluginKey(requestedPluginType, pluginName), pi);
|
||||
|
||||
DEBUG_LOG(logger) << "Loaded " << jsonIid << " - File: " << filename;
|
||||
DEBUG_LOG(logger) << "Plugin '" << filename << "' has no IID !";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (checkPluginsLists && !requiredPluginsList.isEmpty())
|
||||
const QString jsonIid = iid.value().toString().toLower(); // LOWERCASE ! (pun intended)
|
||||
const QVector<QStringRef> iidParameters = jsonIid.splitRef(QLatin1Char(':'));
|
||||
|
||||
DEBUG_LOG(logger) << "Plugin " << absoluteFilePath << " provides iid '" << jsonIid;
|
||||
|
||||
if (iidParameters.count() != 3)
|
||||
{
|
||||
WARNING_LOG(logger) << "These plugins could not be found for Plugin Type " << (int)requestedPluginType << ": "
|
||||
<< requiredPluginsList.join(QStringLiteral(", "));
|
||||
return false;
|
||||
WARNING_LOG(logger) << "Invalid iid "<<jsonIid<<" for plugin " << filename;
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
bool ok = false;
|
||||
int pluginLoaderVersion = iidParameters.at(1).toInt(&ok);
|
||||
|
||||
if (!ok || pluginLoaderVersion != PLUGIN_LOADER_VERSION)
|
||||
{
|
||||
WARNING_LOG(logger) << "Invalid plugin loader version" << pluginLoaderVersion << "for plugin:" << filename;
|
||||
continue;
|
||||
}
|
||||
|
||||
PluginType pluginType = PluginType::UNKNOWN;
|
||||
|
||||
const QString pluginName = iidParameters.at(2).toString();
|
||||
const QString pluginTypeString = iidParameters.at(0).toString();
|
||||
switch (pluginTypes.indexOf(pluginTypeString))
|
||||
{
|
||||
case 0: // data
|
||||
pluginType = PluginType::DATA;
|
||||
break;
|
||||
case 1: // gui
|
||||
pluginType = PluginType::GUI;
|
||||
break;
|
||||
case 2: // topic_type
|
||||
pluginType = PluginType::TOPIC_TYPE;
|
||||
break;
|
||||
case 3: // project
|
||||
pluginType = PluginType::PROJECT;
|
||||
break;
|
||||
case 4: // style
|
||||
pluginType = PluginType::STYLE;
|
||||
break;
|
||||
case 5: // special
|
||||
pluginType = PluginType::SPECIAL;
|
||||
break;
|
||||
case 6: // gui_element
|
||||
pluginType = PluginType::GUI_ELEMENT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (pluginType != requestedPluginType)
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin provides not the requested type " << (int)requestedPluginType << " is: " << (int)pluginType;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pluginType == PluginType::SPECIAL && !specialTopicTypeFilter.isEmpty())
|
||||
{
|
||||
if (!pluginName.startsWith(specialTopicTypeFilter))
|
||||
{
|
||||
DEBUG_LOG(logger) << "Special plugin, but filter does not match: " << pluginName << " - " << specialTopicTypeFilter;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkPluginsLists)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
{
|
||||
QMutableListIterator<QString> i (requiredPluginsList);
|
||||
|
||||
while (i.hasNext())
|
||||
{
|
||||
const QString requiredPlugin = i.next().toLower();
|
||||
|
||||
if (pluginName == requiredPlugin)
|
||||
{
|
||||
found = true;
|
||||
i.remove();
|
||||
break; // no need to look further, just a waste of time, like writing this long unnecessary explanation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!found)
|
||||
{
|
||||
for (auto i = optionalPluginsList.constBegin(); i != optionalPluginsList.constEnd(); i++)
|
||||
{
|
||||
const QString optionalPlugin = (*i).toLower();
|
||||
|
||||
if (pluginName == optionalPlugin)
|
||||
{
|
||||
found = true;
|
||||
break; // no need to look further, just a waste of time, like writing this long unnecessary explanation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!found)
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " was not requested";
|
||||
continue; // plugin was not requested to be loaded
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// before we create a new instance of a plugin, which is not needed as one instance is perfectly fine to use for many apps, look it up in the loaded plugins list
|
||||
|
||||
if (loadPlugin && !m_loadedPlugins.isEmpty()) // only lookup if there is something to lookup TODO: faster to NOT do that check?
|
||||
{
|
||||
QMap<PluginKey, PluginInstance>::iterator i = m_loadedPlugins.find(PluginKey(requestedPluginType, pluginName));
|
||||
|
||||
if (i != m_loadedPlugins.end())
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " already loaded, using that instance ("<<i.value().plugin->metaObject()->className()<<")";
|
||||
|
||||
loadPlugin(i.value());
|
||||
continue; // found, next plugin!
|
||||
}
|
||||
}
|
||||
|
||||
// plugin not already loaded:
|
||||
QObject *plugin = pluginLoader->instance();
|
||||
|
||||
if (!plugin)
|
||||
{
|
||||
ERROR_LOG(logger) << "Failed to load " << filename << " - " << pluginLoader->errorString();
|
||||
continue;
|
||||
}
|
||||
|
||||
PluginInstance pi;
|
||||
pi.pluginName = pluginName;
|
||||
pi.fileName = filename;
|
||||
pi.fullFileName = absoluteFilePath;
|
||||
pi.plugin = plugin;
|
||||
pi.pluginLoader = pluginLoader.data();
|
||||
|
||||
if (loadPlugin && !loadPlugin(pi)) // does the dev want this plugin? if no, unload it! TODO: really unload? or still cache it??
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " unloaded";
|
||||
delete pluginLoader->instance();
|
||||
pluginLoader->unload();
|
||||
continue; // next plugin
|
||||
}
|
||||
pi.pluginLoader = pluginLoader.take();
|
||||
|
||||
// the dev decided to use that plugin, so cache it
|
||||
m_loadedPlugins.insert(PluginKey(requestedPluginType, pluginName), pi);
|
||||
|
||||
// if (m_loadedPlugins.count() > 100)
|
||||
// WARNING_LOG(logger) << "There are more than 100 plugins cached!";
|
||||
|
||||
DEBUG_LOG(logger) << "Loaded " << jsonIid << " - File: " << filename;
|
||||
} // end of >> pluginDir.hasNext();
|
||||
|
||||
|
||||
if (checkPluginsLists && !requiredPluginsList.isEmpty())
|
||||
{
|
||||
WARNING_LOG(logger) << "These plugins could not be found for Plugin Type " << (int)requestedPluginType << ": " << requiredPluginsList.join(QStringLiteral(", "));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace LtsPluginManager
|
||||
@@ -1,24 +1,32 @@
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* plugin loader helper function
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define PLUGIN_LOADER_VERSION 3
|
||||
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QPair>
|
||||
#include <functional>
|
||||
#include <qglobal.h>
|
||||
#include <functional>
|
||||
#include <QMap>
|
||||
#include <QPair>
|
||||
|
||||
#ifndef LTSPLUGINLOADER_EXPORT
|
||||
#ifdef BUILD_STATIC_LIBRARIES
|
||||
#define LTSPLUGINLOADER_EXPORT
|
||||
#else
|
||||
#if defined(MAKE_LTSPLUGINLOADER_LIB)
|
||||
#define LTSPLUGINLOADER_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
#define LTSPLUGINLOADER_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define LTSPLUGINLOADER_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_LTSPLUGINLOADER_LIB)
|
||||
# define LTSPLUGINLOADER_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define LTSPLUGINLOADER_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
class QObject;
|
||||
@@ -32,49 +40,55 @@ struct AppDescription;
|
||||
namespace LtsPluginManager
|
||||
{
|
||||
|
||||
enum class PluginType {
|
||||
UNKNOWN = 0,
|
||||
DATA,
|
||||
GUI,
|
||||
TOPIC_TYPE,
|
||||
PROJECT,
|
||||
STYLE,
|
||||
SPECIAL,
|
||||
enum class PluginType
|
||||
{
|
||||
UNKNOWN = 0, // should not happen
|
||||
DATA, // 1
|
||||
GUI, // 2
|
||||
TOPIC_TYPE,
|
||||
PROJECT,
|
||||
STYLE,
|
||||
SPECIAL, // TODO: rm
|
||||
GUI_ELEMENT,
|
||||
|
||||
};
|
||||
|
||||
struct PluginInstance
|
||||
|
||||
struct PluginInstance // one instance for one plugin
|
||||
{
|
||||
QString pluginName;
|
||||
QString fullFileName;
|
||||
QString fileName;
|
||||
QObject* plugin = nullptr;
|
||||
QPluginLoader* pluginLoader = nullptr;
|
||||
QString pluginName;
|
||||
QString fullFileName;
|
||||
QString fileName;
|
||||
QObject *plugin = nullptr;
|
||||
QPluginLoader *pluginLoader = nullptr;
|
||||
};
|
||||
|
||||
|
||||
class LTSPLUGINLOADER_EXPORT LtsPluginLoader
|
||||
{
|
||||
public:
|
||||
static LtsPluginLoader* getInstance();
|
||||
public:
|
||||
static LtsPluginLoader *getInstance();
|
||||
|
||||
void unloadAllPlugins();
|
||||
void unloadAllPlugins();
|
||||
|
||||
void checkPlugins(const QVector<LtsAppDescriptor::AppDescription>& appVector, QStringList& errors);
|
||||
void checkPlugins(const QVector<LtsAppDescriptor::AppDescription> &appVector,
|
||||
QStringList &errors /* out */);
|
||||
|
||||
bool loadPlugins(PluginType requestedPluginType,
|
||||
const std::function<bool(const PluginInstance& pluginInstance)>& loadPlugin,
|
||||
const QStringList& requiredPlugins = QStringList(),
|
||||
const QString& specialTopicTypeFilter = QString(),
|
||||
const QStringList& optionalPlugins = QStringList());
|
||||
bool loadPlugins(PluginType requestedPluginType,
|
||||
const std::function<bool(const PluginInstance &pluginInstance)> &loadPlugin,
|
||||
const QStringList &requiredPlugins = QStringList(), /* leave empty to get all plugins of the given type */
|
||||
const QString &specialTopicTypeFilter = QString(),
|
||||
const QStringList &optionalPlugins = QStringList());
|
||||
|
||||
typedef QPair<PluginType, QString> PluginKey;
|
||||
typedef QPair<PluginType, QString> PluginKey;
|
||||
|
||||
private:
|
||||
friend struct LtsPluginLoaderHandler;
|
||||
private:
|
||||
friend struct LtsPluginLoaderHandler;
|
||||
|
||||
LtsPluginLoader() = default;
|
||||
~LtsPluginLoader();
|
||||
LtsPluginLoader() = default;
|
||||
~LtsPluginLoader();
|
||||
|
||||
QMap<PluginKey, PluginInstance> m_loadedPlugins;
|
||||
QMap<PluginKey, PluginInstance> m_loadedPlugins; // TODO: meh...
|
||||
};
|
||||
|
||||
} // namespace LtsPluginManager
|
||||
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# Lightweight REST Client Framework
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Hannes Fritsche, ESZS, 2026-08-21
|
||||
|
||||
#
|
||||
# --- Library LtsRestClient --------------------------------------------------------------------------------
|
||||
#
|
||||
SET(LtsRestClient_SRCS
|
||||
lts_rest_client.cpp
|
||||
lts_rest_client.h
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY2(ALL LtsRestClient SHARED ${LtsRestClient_SRCS})
|
||||
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(LtsRestClient
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(LtsRestClient
|
||||
PUBLIC
|
||||
Qt5::Core
|
||||
Qt5::Network
|
||||
)
|
||||
@@ -0,0 +1,172 @@
|
||||
/**
|
||||
* Lightweight REST Client Framework
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Fritsche, ESZS, 2026-08-21
|
||||
*/
|
||||
|
||||
#include "lts_rest_client.h"
|
||||
#include <QTimer>
|
||||
#include <QUrl>
|
||||
#include <QtNetwork/QNetworkAccessManager>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
#include <QtNetwork/QNetworkRequest>
|
||||
|
||||
namespace LtsCommon
|
||||
{
|
||||
|
||||
LtsRestClient::LtsRestClient(const QString &baseUrl, QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_baseUrl(baseUrl)
|
||||
, m_manager(new QNetworkAccessManager(this))
|
||||
{
|
||||
}
|
||||
|
||||
void LtsRestClient::ping(PingSuccessCallback onSuccess, ErrorCallback onError, int timeoutMs)
|
||||
{
|
||||
const QNetworkRequest request((QUrl(m_baseUrl)));
|
||||
QNetworkReply *reply = m_manager->head(request);
|
||||
|
||||
if (!reply)
|
||||
{
|
||||
if (onError)
|
||||
onError(QStringLiteral("Failed to initiate ping."));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 1. Setup the timer (parented to reply for auto-cleanup)
|
||||
QTimer *timeoutTimer = new QTimer(reply);
|
||||
timeoutTimer->setSingleShot(true);
|
||||
|
||||
// 2. Connect the timeout signal to abort the request
|
||||
connect(timeoutTimer, &QTimer::timeout, this, [reply]()
|
||||
{
|
||||
if (reply && reply->isRunning())
|
||||
reply->abort(); // Triggers finished() with OperationCanceledError
|
||||
});
|
||||
|
||||
// 3. Connect the finished signal to handle the response
|
||||
connect(reply,
|
||||
&QNetworkReply::finished,
|
||||
this,
|
||||
[reply, timeoutTimer, onSuccess, onError]()
|
||||
{
|
||||
timeoutTimer->stop();
|
||||
reply->deleteLater();
|
||||
|
||||
if (reply->error() != QNetworkReply::NoError)
|
||||
{
|
||||
if (onError)
|
||||
{
|
||||
if (reply->error() == QNetworkReply::OperationCanceledError)
|
||||
onError(QStringLiteral("Ping timed out."));
|
||||
else
|
||||
onError(reply->errorString());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
|
||||
if (onSuccess)
|
||||
onSuccess(statusCode);
|
||||
});
|
||||
|
||||
// 4. Start the timer only after all connections are successfully established
|
||||
timeoutTimer->start(timeoutMs);
|
||||
}
|
||||
|
||||
void LtsRestClient::get(const QString &endpoint, SuccessCallback onSuccess, ErrorCallback onError)
|
||||
{
|
||||
sendRequest(QStringLiteral("GET"), endpoint, QByteArray(), onSuccess, onError);
|
||||
}
|
||||
|
||||
void LtsRestClient::post(const QString &endpoint, const QJsonDocument &json, SuccessCallback onSuccess, ErrorCallback onError)
|
||||
{
|
||||
sendRequest(QStringLiteral("POST"), endpoint, json.toJson(), onSuccess, onError);
|
||||
}
|
||||
|
||||
void LtsRestClient::put(const QString &endpoint, const QJsonDocument &json, SuccessCallback onSuccess, ErrorCallback onError)
|
||||
{
|
||||
sendRequest(QStringLiteral("PUT"), endpoint, json.toJson(), onSuccess, onError);
|
||||
}
|
||||
|
||||
void LtsRestClient::del(const QString &endpoint, SuccessCallback onSuccess, ErrorCallback onError)
|
||||
{
|
||||
sendRequest(QStringLiteral("DELETE"), endpoint, QByteArray(), onSuccess, onError);
|
||||
}
|
||||
|
||||
void LtsRestClient::sendRequest(const QString &method, const QString &endpoint, const QByteArray &data, SuccessCallback onSuccess, ErrorCallback onError)
|
||||
{
|
||||
QUrl url(m_baseUrl);
|
||||
url.setPath(url.path() + endpoint);
|
||||
|
||||
QNetworkRequest request(url);
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/json"));
|
||||
|
||||
QNetworkReply *reply = nullptr;
|
||||
|
||||
if (method == QStringLiteral("GET"))
|
||||
reply = m_manager->get(request);
|
||||
else if (method == QStringLiteral("POST"))
|
||||
reply = m_manager->post(request, data);
|
||||
else if (method == QStringLiteral("PUT"))
|
||||
reply = m_manager->put(request, data);
|
||||
else if (method == QStringLiteral("DELETE"))
|
||||
reply = m_manager->deleteResource(request);
|
||||
|
||||
if (!reply)
|
||||
{
|
||||
if (onError)
|
||||
onError(QStringLiteral("Failed to initiate request."));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
connect(reply,
|
||||
&QNetworkReply::finished,
|
||||
this,
|
||||
[reply, onSuccess, onError]()
|
||||
{
|
||||
reply->deleteLater();
|
||||
|
||||
// Handle network errors
|
||||
if (reply->error() != QNetworkReply::NoError)
|
||||
{
|
||||
if (onError)
|
||||
onError(reply->errorString());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle HTTP errors
|
||||
const int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
if (statusCode >= 400)
|
||||
{
|
||||
if (onError)
|
||||
onError(QStringLiteral("HTTP Error %1").arg(statusCode));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse JSON safely
|
||||
QJsonParseError parseError;
|
||||
const QJsonDocument doc = QJsonDocument::fromJson(reply->readAll(), &parseError);
|
||||
|
||||
if (parseError.error != QJsonParseError::NoError)
|
||||
{
|
||||
if (onError)
|
||||
onError(QStringLiteral("JSON Parse Error: ") + parseError.errorString());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (onSuccess)
|
||||
onSuccess(doc);
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace LtsCommon
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Lightweight REST Client Framework
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Fritsche, ESZS, 2026-08-21
|
||||
*/
|
||||
|
||||
// Short documentation on how to use it can be found at https://confluence-classified.rh-int.de/spaces/LEG/pages/207915647/HOWTO+LtsRestClient
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <functional>
|
||||
#include <LtsRestClient/ltsrestclient_export.h>
|
||||
|
||||
class QNetworkAccessManager;
|
||||
|
||||
namespace LtsCommon
|
||||
{
|
||||
|
||||
class LTSRESTCLIENT_EXPORT LtsRestClient : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LtsRestClient(const QString &baseUrl, QObject *parent = nullptr);
|
||||
|
||||
// type aliases
|
||||
using PingSuccessCallback = std::function<void(int statusCode)>;
|
||||
using SuccessCallback = std::function<void(const QJsonDocument &)>;
|
||||
using ErrorCallback = std::function<void(const QString &)>;
|
||||
|
||||
// HTTP Header Ping to m_baseUrl to check server availability
|
||||
void ping(PingSuccessCallback onSuccess, ErrorCallback onError = nullptr, int timeoutMs = 3000);
|
||||
|
||||
// HTTP Methods
|
||||
void get(const QString &endpoint, SuccessCallback onSuccess, ErrorCallback onError = nullptr);
|
||||
void post(const QString &endpoint, const QJsonDocument &json, SuccessCallback onSuccess, ErrorCallback onError = nullptr);
|
||||
void put(const QString &endpoint, const QJsonDocument &json, SuccessCallback onSuccess, ErrorCallback onError = nullptr);
|
||||
void del(const QString &endpoint, SuccessCallback onSuccess, ErrorCallback onError = nullptr);
|
||||
|
||||
private:
|
||||
void sendRequest(const QString &method, const QString &endpoint, const QByteArray &data, SuccessCallback onSuccess, ErrorCallback onError);
|
||||
|
||||
QString m_baseUrl;
|
||||
QNetworkAccessManager *m_manager;
|
||||
}; // class RestClient
|
||||
} // namespace LtsCommon
|
||||
@@ -10,209 +10,292 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QUrl>
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
#include <QUrl>
|
||||
#include <memory>
|
||||
|
||||
#include <QtCore/QMap>
|
||||
|
||||
// Export macro for shared library
|
||||
#include "ltssessiondatadds_export.h"
|
||||
|
||||
#ifdef BUILD_RTI
|
||||
#include <dds/domain/DomainParticipant.hpp>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <DDS/Core/core_dtc_types.h>
|
||||
//#include <NGLLogger/INGLLogger.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include "Core/core.hpp"
|
||||
#include "Core/core_dtc_types.h"
|
||||
#include "Lts/Common/ProjectConfig/project_defines.h"
|
||||
#include <Common/ProjectConfig/project_defines.h>
|
||||
#include <LtsSession/ltssessiondatadds_export.h>
|
||||
|
||||
|
||||
namespace DataPluginBase { class Interface; }
|
||||
namespace DDSConnector { class DdsConnector; }
|
||||
namespace DataPluginBase { class Interface; }
|
||||
namespace GuiPluginBase { class Interface; }
|
||||
#else
|
||||
// Forward declarations for stub types
|
||||
namespace DataPluginBase { class Interface; }
|
||||
namespace GuiPluginBase { class Interface; }
|
||||
#endif
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
struct DdsConnectionParams
|
||||
{
|
||||
int domainId = -1;
|
||||
int partitionId = 0;
|
||||
int exerciseId = 0;
|
||||
IDL::PartitionType partitionType = IDL::PartitionType::Any;
|
||||
QUrl tcpConnectionUrl;
|
||||
QStringList qos_file;
|
||||
|
||||
// Stub enum for PartitionType
|
||||
enum class PartitionType {
|
||||
Any = 0,
|
||||
Exercise,
|
||||
Replay,
|
||||
AllExercises,
|
||||
Global,
|
||||
Invalid = -1
|
||||
DdsConnectionParams() = default;
|
||||
explicit DdsConnectionParams(const Core::ReplayPartition &rp)
|
||||
: domainId(rp.domainId())
|
||||
, partitionId(rp.id())
|
||||
, exerciseId(rp.exerciseId())
|
||||
, partitionType(IDL::PartitionType::Replay)
|
||||
{
|
||||
setTcpConnectionUrl(rp.tcpConnectionUrl());
|
||||
}
|
||||
|
||||
bool isValid() const { return domainId >= 0 && partitionType != IDL::PartitionType::Any; }
|
||||
bool hasSameDomainParams(const DdsConnectionParams &o) const
|
||||
{
|
||||
return domainId == o.domainId &&
|
||||
tcpConnectionUrl == o.tcpConnectionUrl;
|
||||
}
|
||||
bool operator==(const DdsConnectionParams &o) const
|
||||
{
|
||||
return domainId == o.domainId &&
|
||||
partitionId == o.partitionId &&
|
||||
exerciseId == o.exerciseId &&
|
||||
qos_file == o.qos_file &&
|
||||
partitionType == o.partitionType &&
|
||||
tcpConnectionUrl == o.tcpConnectionUrl;
|
||||
}
|
||||
bool operator !=(const DdsConnectionParams &o) const
|
||||
{
|
||||
return !operator==(o);
|
||||
}
|
||||
bool operator <(const DdsConnectionParams &o) const
|
||||
{
|
||||
if (domainId != o.domainId)
|
||||
return domainId < o.domainId;
|
||||
if (partitionId != o.partitionId)
|
||||
return partitionId < o.partitionId;
|
||||
if (exerciseId != o.exerciseId)
|
||||
return exerciseId < o.exerciseId;
|
||||
if (qos_file != o.qos_file)
|
||||
return qos_file < o.qos_file;
|
||||
if (partitionType != o.partitionType)
|
||||
return partitionType < o.partitionType;
|
||||
return tcpConnectionUrl.toString() < o.tcpConnectionUrl.toString();
|
||||
}
|
||||
|
||||
void setTcpConnectionUrl(const std::string &url)
|
||||
{
|
||||
tcpConnectionUrl = QUrl::fromUserInput(QString::fromStdString(url));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Fetcher;
|
||||
|
||||
struct DdsConnectionParams
|
||||
|
||||
class LTSSESSIONDATADDS_EXPORT LtsSessionDataDds /* FIXME: Name ist irrefuehrend. "LtsSessionData" hat mit "LtsSessionDataDds" nichts zu tun, klingen aber fast identisch. */
|
||||
: public QObject
|
||||
{
|
||||
int domainId = -1;
|
||||
int partitionId = 0;
|
||||
int exerciseId = 0;
|
||||
PartitionType partitionType = PartitionType::Any;
|
||||
QUrl tcpConnectionUrl;
|
||||
QStringList qos_file;
|
||||
Q_OBJECT
|
||||
protected:
|
||||
// only used from LtsSession, no direct instantiation
|
||||
explicit LtsSessionDataDds(QObject *parent = nullptr);
|
||||
public:
|
||||
~LtsSessionDataDds();
|
||||
|
||||
DdsConnectionParams() = default;
|
||||
bool init(const DdsConnectionParams &connParams);
|
||||
bool init(const dds::domain::DomainParticipant &dp,
|
||||
const DdsConnectionParams &connParams);
|
||||
|
||||
bool isValid() const
|
||||
std::shared_ptr<DDSConnector::DdsConnector> ddsConnector() { return m_ddsConnector; }
|
||||
std::shared_ptr<DDSConnector::DdsConnector> ddsConnectorGlobal() { return m_ddsConnectorGlobal; }
|
||||
int domainId() const;
|
||||
int exerciseId() const;
|
||||
int partitionId() const;
|
||||
QStringList qosFile() const;
|
||||
IDL::PartitionType partitionType() const;
|
||||
static QString partitionTypeString(IDL::PartitionType partitionType);
|
||||
bool isExercisePartition() const { return (partitionType() == IDL::PartitionType::Exercise); }
|
||||
bool isReplayPartition() const { return (partitionType() == IDL::PartitionType::Replay); }
|
||||
QString toString() const;
|
||||
Fetcher *fetcher(const QString &yourPluginsName);
|
||||
|
||||
QUrl tcpConnectionUrl() const;
|
||||
DdsConnectionParams connParams() const;
|
||||
|
||||
qint64 partitionTime() const { return m_curMSecSinceEpoch; }
|
||||
|
||||
// retrieve DTC/FTC inside DataPlugin::createDataInterface()
|
||||
template<typename T>
|
||||
bool createTopicClient(std::shared_ptr<T> &member, bool bEnableAll = false, bool bGlobal = false)
|
||||
{
|
||||
member = T::create(bGlobal ? m_ddsConnectorGlobal : m_ddsConnector);
|
||||
if ( bEnableAll && !member->enableAll())
|
||||
{
|
||||
return domainId >= 0 && partitionType != PartitionType::Any;
|
||||
}
|
||||
|
||||
bool operator==(const DdsConnectionParams& o) const
|
||||
{
|
||||
return domainId == o.domainId && partitionId == o.partitionId && exerciseId == o.exerciseId &&
|
||||
qos_file == o.qos_file && partitionType == o.partitionType && tcpConnectionUrl == o.tcpConnectionUrl;
|
||||
}
|
||||
|
||||
bool operator!=(const DdsConnectionParams& o) const
|
||||
{
|
||||
return !operator==(o);
|
||||
}
|
||||
|
||||
bool operator<(const DdsConnectionParams& o) const
|
||||
{
|
||||
if (domainId != o.domainId)
|
||||
return domainId < o.domainId;
|
||||
if (partitionId != o.partitionId)
|
||||
return partitionId < o.partitionId;
|
||||
if (exerciseId != o.exerciseId)
|
||||
return exerciseId < o.exerciseId;
|
||||
if (qos_file != o.qos_file)
|
||||
return qos_file < o.qos_file;
|
||||
if (partitionType != o.partitionType)
|
||||
return partitionType < o.partitionType;
|
||||
return tcpConnectionUrl.toString() < o.tcpConnectionUrl.toString();
|
||||
}
|
||||
|
||||
#ifdef BUILD_RTI
|
||||
bool hasSameDomainParams(const DdsConnectionParams& o) const
|
||||
{
|
||||
return domainId == o.domainId && partitionType == o.partitionType;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
// Base class for session DDS data - always compiled, but RTI functionality guarded
|
||||
class LTSSESSIONDATADDS_EXPORT LtsSessionDataDds : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LtsSessionDataDds(QObject* parent = nullptr);
|
||||
~LtsSessionDataDds();
|
||||
|
||||
// Initialization
|
||||
#ifdef BUILD_RTI
|
||||
bool init(const DdsConnectionParams& connParams);
|
||||
bool init(const dds::domain::DomainParticipant& dp, const DdsConnectionParams& connParams);
|
||||
Fetcher* fetcher(const QString& yourPluginsName);
|
||||
#else
|
||||
virtual bool init(const DdsConnectionParams& connParams);
|
||||
virtual bool init(const void* dp, const DdsConnectionParams& connParams);
|
||||
virtual void* fetcher(const QString& yourPluginsName);
|
||||
#endif
|
||||
|
||||
// Accessors
|
||||
int domainId() const;
|
||||
int exerciseId() const;
|
||||
int partitionId() const;
|
||||
PartitionType partitionType() const;
|
||||
static QString partitionTypeString(PartitionType partitionType);
|
||||
QStringList qosFile() const;
|
||||
QUrl tcpConnectionUrl() const;
|
||||
DdsConnectionParams connParams() const;
|
||||
|
||||
bool isExercisePartition() const { return partitionType() == PartitionType::Exercise; }
|
||||
bool isReplayPartition() const { return partitionType() == PartitionType::Replay; }
|
||||
|
||||
QString toString() const;
|
||||
|
||||
qint64 partitionTime() const { return m_emittedTime; }
|
||||
|
||||
// Data plugin interfaces
|
||||
#ifdef BUILD_RTI
|
||||
QMap<QString, std::shared_ptr<DataPluginBase::Interface>> availableDataPluginInterfaces() const;
|
||||
void addAvailablaeDataPluginInterfaces(const QMap<QString, std::shared_ptr<DataPluginBase::Interface>>& dataPlugins);
|
||||
#else
|
||||
QMap<QString, void*> availableDataPluginInterfaces() const { return QMap<QString, void*>(); }
|
||||
void addAvailablaeDataPluginInterfaces(const QMap<QString, void*>& /*dataPlugins*/) {}
|
||||
#endif
|
||||
// retrieve DTC/FTC inside DataPlugin::createDataInterface() - always available
|
||||
template<typename T>
|
||||
bool createTopicClient(std::shared_ptr<T> &member, bool bEnableAll = false, bool bGlobal = false);
|
||||
|
||||
template<typename T, typename S>
|
||||
bool createTopicClient(std::shared_ptr<T> &dtc, std::shared_ptr<S> &ftc, bool bEnableAll = false, bool bGlobal = false);
|
||||
|
||||
template<typename T, typename S>
|
||||
bool getDtc(std::shared_ptr<S> &val) const;
|
||||
|
||||
// Foreign GUI interface retrieval - used by Fetcher helper class
|
||||
template<typename S>
|
||||
bool getForeignGuiInterface(std::shared_ptr<S> &val) const
|
||||
{
|
||||
#ifdef BUILD_RTI
|
||||
for (const auto &i : m_guiPluginInterfaces)
|
||||
{
|
||||
val = std::dynamic_pointer_cast<S>(i);
|
||||
if (val)
|
||||
return true;
|
||||
}
|
||||
val.reset();
|
||||
if (m_logger.isDebugEnabled())
|
||||
DEBUG_LOG(m_logger) << "Cannot find foreign gui ifc " << typeid(S).name() << " in " << toString();
|
||||
#else
|
||||
val.reset();
|
||||
#endif
|
||||
member = nullptr;
|
||||
ERROR_LOG(m_logger) << "Error initializing dtc/ftc for service " << T::identifier();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
signals:
|
||||
void partitionTimeChanged(qint64 newPartitionTime);
|
||||
void partitionTimeChangedInternal();
|
||||
template<typename T, typename S>
|
||||
bool createTopicClient(std::shared_ptr<T> &dtc, std::shared_ptr<S> &ftc, bool bEnableAll = false, bool bGlobal = false)
|
||||
{
|
||||
dtc = T::create(bGlobal ? m_ddsConnectorGlobal : m_ddsConnector);
|
||||
ftc = S::create(bGlobal ? m_ddsConnectorGlobal : m_ddsConnector);
|
||||
if ( (bEnableAll && !dtc->enableAll()) || !ftc->enableAll())
|
||||
{
|
||||
dtc = nullptr;
|
||||
ftc = nullptr;
|
||||
ERROR_LOG(m_logger) << "Error initializing dtc/ftc for service " << T::identifier();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
#ifdef BUILD_RTI
|
||||
bool initInternal();
|
||||
void onPartitionTimeChangedInternal();
|
||||
static LtsSession::PartitionType toPartitionType(IDL::PartitionType idlType);
|
||||
static IDL::PartitionType toIdlPartitionType(LtsSession::PartitionType type);
|
||||
template<typename T, typename S>
|
||||
bool getDtc(std::shared_ptr<S> &val) const
|
||||
{
|
||||
for (const auto &i : m_dataPluginInterfaces)
|
||||
{
|
||||
auto ifc = std::dynamic_pointer_cast<T>(i);
|
||||
if (ifc)
|
||||
{
|
||||
val = ifc->getDtc();
|
||||
return val != nullptr;
|
||||
}
|
||||
}
|
||||
val.reset();
|
||||
DEBUG_LOG(m_logger) << "Trying to load dtc " << typeid(T).name() << " - " << typeid(S).name() << " failed!"
|
||||
<< ", m_dataPluginInterfaces.size() = " << m_dataPluginInterfaces.size() << " - " << this;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Member variables - only with RTI
|
||||
int m_exerciseId;
|
||||
qint64 m_emittedTime;
|
||||
qint64 m_curMSecSinceEpoch;
|
||||
bool m_active;
|
||||
Fetcher* m_fetcher;
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnectorGlobal;
|
||||
std::shared_ptr<DTC::PartitionTime> m_dtcPartitionTime;
|
||||
NGL::INGLLogger& m_logger;
|
||||
QMap<QString, std::shared_ptr<DataPluginBase::Interface>> m_dataPluginInterfaces;
|
||||
QMap<QString, std::shared_ptr<GuiPluginBase::Interface>> m_guiPluginInterfaces;
|
||||
QStringList m_qosFileList;
|
||||
#else
|
||||
// Stub implementation - minimal members
|
||||
bool initInternal();
|
||||
void onPartitionTimeChangedInternal();
|
||||
// TODO: merge with getDtc() --> std::is_same, std::enable_if
|
||||
template<typename T, typename S>
|
||||
bool getFtc(std::shared_ptr<S> &val) const
|
||||
{
|
||||
for (const auto &i : m_dataPluginInterfaces)
|
||||
{
|
||||
auto ifc = std::dynamic_pointer_cast<T>(i);
|
||||
if (ifc)
|
||||
{
|
||||
val = ifc->getFtc();
|
||||
return val != nullptr;
|
||||
}
|
||||
}
|
||||
val.reset();
|
||||
DEBUG_LOG(m_logger) << "Trying to load ftc " << typeid(T).name() << " - " << typeid(S).name() << " failed!"
|
||||
<< ", m_dataPluginInterfaces.size() = " << m_dataPluginInterfaces.size() << " - " << this;
|
||||
return false;
|
||||
}
|
||||
|
||||
int m_exerciseId;
|
||||
qint64 m_emittedTime;
|
||||
qint64 m_curMSecSinceEpoch;
|
||||
bool m_active;
|
||||
void* m_fetcher;
|
||||
#endif
|
||||
|
||||
// TODO: merge with getDtc() --> std::is_same, std::enable_if
|
||||
template<typename T, typename S>
|
||||
bool getForeignDataInterface(std::shared_ptr<S> &val) const
|
||||
{
|
||||
//qWarning() << "getForeignDataInterface is deprecated! get the plugin's dtc/ftc directly with getDtc or getFtc!";
|
||||
|
||||
for (const auto &i : m_dataPluginInterfaces)
|
||||
{
|
||||
auto ifc = std::dynamic_pointer_cast<T>(i);
|
||||
if (ifc)
|
||||
{
|
||||
val = ifc->getForeignDataInterface();
|
||||
return val != nullptr;
|
||||
}
|
||||
}
|
||||
val.reset();
|
||||
DEBUG_LOG(m_logger) << "Trying to load foreign data ifc " << typeid(T).name() << " - " << typeid(S).name() << " failed!"
|
||||
<< ", m_dataPluginInterfaces.size() = " << m_dataPluginInterfaces.size() << " - " << this;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* MWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMW */
|
||||
/* MW DEPRECATED - DO NOT USE IN NEW IMPLEMENTATIONS - CAN BE REMOVED AT ANY TIME WITHOUT WARNING ! MW */
|
||||
/* MWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMW */
|
||||
/* MW */ /* MW */
|
||||
/* MW */ template<typename S> /* MW */
|
||||
/* MW */ bool getForeignDataInterface_NEW(std::shared_ptr<S> &val) const /* MW */
|
||||
/* MW */ { /* MW */
|
||||
/* MW */ //qWarning() << "getForeignDataInterface is deprecated! get the plugin's dtc/ftc directly with getDtc or getFtc!"; /* MW */
|
||||
/* MW */ /* MW */
|
||||
/* MW */ for (const auto &i : m_dataPluginInterfaces) /* MW */
|
||||
/* MW */ { /* MW */
|
||||
/* MW */ val = std::dynamic_pointer_cast<S>(i); /* MW */
|
||||
/* MW */ if (val) /* MW */
|
||||
/* MW */ return true; /* MW */
|
||||
/* MW */ } /* MW */
|
||||
/* MW */ val.reset(); /* MW */
|
||||
/* MW */ DEBUG_LOG(m_logger) << "Trying to load foreign data ifc " << typeid(S).name() << " failed!" /* MW */
|
||||
/* MW */ << ", m_guiPluginInterfaces.size() = " << m_guiPluginInterfaces.size() << " - " << this; /* MW */
|
||||
/* MW */ return false; /* MW */
|
||||
/* MW */ } /* MW */
|
||||
/* MW */ /* MW */
|
||||
/* MWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMW */
|
||||
|
||||
|
||||
template<typename S>
|
||||
bool getForeignGuiInterface(std::shared_ptr<S> &val) const
|
||||
{
|
||||
for (const auto &i : m_guiPluginInterfaces)
|
||||
{
|
||||
val = std::dynamic_pointer_cast<S>(i);
|
||||
if (val)
|
||||
return true;
|
||||
}
|
||||
val.reset();
|
||||
DEBUG_LOG(m_logger) << "Cannot find foreign gui ifc " << typeid(S).name() << " in " << toString();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<typename T, typename S>
|
||||
bool interfaceFromGui(std::shared_ptr<S> &val) const // for generic gui interfaces
|
||||
{
|
||||
for (const auto &i : m_guiPluginInterfaces)
|
||||
{
|
||||
val = std::dynamic_pointer_cast<T>(i);
|
||||
if (val)
|
||||
return true;
|
||||
}
|
||||
val.reset();
|
||||
DEBUG_LOG(m_logger) << "Trying to load foreign gui ifc #2 " << typeid(S).name() << " failed!"
|
||||
<< ", m_guiPluginInterfaces.size() = " << m_guiPluginInterfaces.size() << " - " << this;
|
||||
return false;
|
||||
}
|
||||
|
||||
signals:
|
||||
void partitionTimeChanged(qint64 newPartitionTime);
|
||||
void partitionTimeChangedInternal();
|
||||
|
||||
private:
|
||||
void onPartitionTimeChangedInternal();
|
||||
bool initInternal();
|
||||
|
||||
protected:
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnectorGlobal;
|
||||
int m_exerciseId;
|
||||
std::shared_ptr<DTC::PartitionTime> m_dtcPartitionTime;
|
||||
qint64 m_emittedTime;
|
||||
qint64 m_curMSecSinceEpoch;
|
||||
bool m_active;
|
||||
void setInactive() { m_active = false; }
|
||||
|
||||
|
||||
QMap<QString, std::shared_ptr<DataPluginBase::Interface>> availableDataPluginInterfaces() const;
|
||||
void addAvailablaeDataPluginInterfaces(const QMap<QString, std::shared_ptr<DataPluginBase::Interface>> &dataPlugins);
|
||||
QMap<QString, std::shared_ptr<DataPluginBase::Interface>> m_dataPluginInterfaces;
|
||||
QMap<QString, std::shared_ptr<GuiPluginBase::Interface>> m_guiPluginInterfaces;
|
||||
QMap<QString, std::shared_ptr<GuiPluginBase::Interface>> m_initializeThesePlugins;
|
||||
Fetcher *m_fetcher;
|
||||
QStringList m_qosFileList;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
#ifdef BUILD_RTI
|
||||
|
||||
class Fetcher
|
||||
{
|
||||
public:
|
||||
@@ -269,77 +352,5 @@ public:
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace LtsSession
|
||||
|
||||
// Template method implementations - must be in header
|
||||
#ifdef BUILD_RTI
|
||||
template<typename T>
|
||||
bool LtsSession::LtsSessionDataDds::createTopicClient(std::shared_ptr<T> &member, bool bEnableAll, bool bGlobal)
|
||||
{
|
||||
member = T::create(bGlobal ? m_ddsConnectorGlobal : m_ddsConnector);
|
||||
if ( bEnableAll && !member->enableAll())
|
||||
{
|
||||
member = nullptr;
|
||||
if (m_logger.isErrorEnabled())
|
||||
NGL::LogStreamHelper(m_logger, NGL::LogLevel::Error, __FILE__, __LINE__, Q_FUNC_INFO) << "Error initializing dtc/ftc for service " << T::identifier();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T, typename S>
|
||||
bool LtsSession::LtsSessionDataDds::createTopicClient(std::shared_ptr<T> &dtc, std::shared_ptr<S> &ftc, bool bEnableAll, bool bGlobal)
|
||||
{
|
||||
dtc = T::create(bGlobal ? m_ddsConnectorGlobal : m_ddsConnector);
|
||||
ftc = S::create(bGlobal ? m_ddsConnectorGlobal : m_ddsConnector);
|
||||
if ( (bEnableAll && !dtc->enableAll()) || !ftc->enableAll())
|
||||
{
|
||||
dtc = nullptr;
|
||||
ftc = nullptr;
|
||||
if (m_logger.isErrorEnabled())
|
||||
NGL::LogStreamHelper(m_logger, NGL::LogLevel::Error, __FILE__, __LINE__, Q_FUNC_INFO) << "Error initializing dtc/ftc for service " << T::identifier();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T, typename S>
|
||||
bool LtsSession::LtsSessionDataDds::getDtc(std::shared_ptr<S> &val) const
|
||||
{
|
||||
for (const auto &i : m_dataPluginInterfaces)
|
||||
{
|
||||
auto ifc = std::dynamic_pointer_cast<T>(i);
|
||||
if (ifc)
|
||||
{
|
||||
val = ifc->getDtc();
|
||||
return val != nullptr;
|
||||
}
|
||||
}
|
||||
val.reset();
|
||||
if (m_logger.isDebugEnabled())
|
||||
NGL::LogStreamHelper(m_logger, NGL::LogLevel::Debug, __FILE__, __LINE__, Q_FUNC_INFO) << "Trying to load dtc " << typeid(T).name() << " - " << typeid(S).name() << " failed!"
|
||||
<< ", m_dataPluginInterfaces.size() = " << m_dataPluginInterfaces.size() << " - " << this;
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
// Stub implementations for non-BUILD_RTI
|
||||
template<typename T>
|
||||
bool LtsSession::LtsSessionDataDds::createTopicClient(std::shared_ptr<T> &/*member*/, bool /*bEnableAll*/, bool /*bGlobal*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename T, typename S>
|
||||
bool LtsSession::LtsSessionDataDds::createTopicClient(std::shared_ptr<T> &/*dtc*/, std::shared_ptr<S> &/*ftc*/, bool /*bEnableAll*/, bool /*bGlobal*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename T, typename S>
|
||||
bool LtsSession::LtsSessionDataDds::getDtc(std::shared_ptr<S> &/*val*/) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif // BUILD_RTI
|
||||
@@ -1,159 +1,106 @@
|
||||
#pragma once
|
||||
|
||||
// STUB - RTI DDS not available
|
||||
// This stub provides minimal functionality for building without RTI Connext DDS
|
||||
|
||||
#include <LtsSession/ltssession_export.h>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QString>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <DDS/Core/core_ftc.h>
|
||||
|
||||
#include <QPointer>
|
||||
#include <memory>
|
||||
|
||||
// Forward declaration - actual type from LtsWidgets
|
||||
namespace LtsWidgets {
|
||||
struct TopicInfo {
|
||||
// Minimal stub for TopicInfo
|
||||
QString topicName;
|
||||
int entityId{0};
|
||||
};
|
||||
}
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
|
||||
/*
|
||||
Anmerkungen:
|
||||
slotTryLock
|
||||
-> slotTryLock
|
||||
-> tryLockEntityRequest
|
||||
<- onTryLockEntityReply
|
||||
emit signalLockDialog | emit signalUnlockDialog
|
||||
|
||||
PpmGuiPlugin:
|
||||
- ParticipantOrganisationDialog (asSupportService==false)
|
||||
a) avoid disabling by overloading ::lock() -> yes
|
||||
b) use tryLockTopicNew -> yes
|
||||
|
||||
- ParticipantEdit (asSupportService==false||true)
|
||||
a) avoid disabling by overloading ::lock() -> yes
|
||||
b) use tryLockTopicNew -> yes
|
||||
|
||||
3 TacticalOrganisation
|
||||
-> left and right <-
|
||||
onReinitLeft, onReinitRight
|
||||
*/
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
|
||||
// STUB: TopicLockHandler - minimal implementation without RTI DDS
|
||||
class LTSSESSION_EXPORT TopicLockHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TopicLockHandler() = default;
|
||||
~TopicLockHandler() = default;
|
||||
Q_OBJECT
|
||||
public:
|
||||
TopicLockHandler();
|
||||
~TopicLockHandler();
|
||||
|
||||
bool init(void* coreFtc, int exerciseId)
|
||||
{
|
||||
Q_UNUSED(coreFtc);
|
||||
Q_UNUSED(exerciseId);
|
||||
return false; // RTI not available
|
||||
}
|
||||
bool init(const std::shared_ptr<Core::Interface::Ftc> &coreFtc, int exerciseId);
|
||||
|
||||
bool isLocked() const
|
||||
{
|
||||
return m_locked;
|
||||
}
|
||||
bool isLocked() const { return m_locked; }
|
||||
LtsWidgets::TopicInfo getTopicInfo() const { return m_topicInfo; }
|
||||
|
||||
LtsWidgets::TopicInfo getTopicInfo() const
|
||||
{
|
||||
return m_topicInfo;
|
||||
}
|
||||
public slots:
|
||||
void slotTryLock(const LtsWidgets::TopicInfo &topicInfo);
|
||||
bool slotUnlock();
|
||||
void slotFinalize(); // unlock, finally delete
|
||||
|
||||
public slots:
|
||||
void slotTryLock(const LtsWidgets::TopicInfo& topicInfo)
|
||||
{
|
||||
Q_UNUSED(topicInfo);
|
||||
// STUB: no-op
|
||||
}
|
||||
|
||||
bool slotUnlock()
|
||||
{
|
||||
return false; // STUB: cannot unlock without RTI
|
||||
}
|
||||
|
||||
void slotFinalize()
|
||||
{
|
||||
// STUB: no-op
|
||||
}
|
||||
signals:
|
||||
void signalLockDialog(const QString &lockedBy);
|
||||
void signalUnlockDialog();
|
||||
|
||||
signals:
|
||||
void signalLockDialog(const QString& lockedBy);
|
||||
void signalUnlockDialog();
|
||||
private:
|
||||
bool lock();
|
||||
bool unlock();
|
||||
std::string objStateAsString() const;
|
||||
|
||||
private:
|
||||
bool lock()
|
||||
{
|
||||
return false; // STUB
|
||||
}
|
||||
|
||||
bool unlock()
|
||||
{
|
||||
return false; // STUB
|
||||
}
|
||||
|
||||
std::string objStateAsString() const
|
||||
{
|
||||
return "STUB";
|
||||
}
|
||||
std::shared_ptr<Core::Interface::Ftc> m_coreFtc;
|
||||
|
||||
void* m_coreFtc{nullptr}; // STUB: was std::shared_ptr<Core::Interface::Ftc>
|
||||
LtsWidgets::TopicInfo m_topicInfo;
|
||||
int m_lockEntityId{0};
|
||||
int m_exerciseId{0};
|
||||
bool m_locked{false};
|
||||
bool m_askedForLock{false};
|
||||
bool m_deleteAfterAnswer{false};
|
||||
LtsWidgets::TopicInfo m_topicInfo;
|
||||
int m_lockEntityId{0}; // reply.id(); / set by reply of ddsCall
|
||||
|
||||
int m_exerciseId{0};
|
||||
bool m_locked{false};
|
||||
bool m_askedForLock{false}; // reply does not tell..
|
||||
bool m_deleteAfterAnswer{false};
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
// STUB: TopicLockHanderData - minimal implementation without RTI DDS
|
||||
|
||||
class LTSSESSION_EXPORT TopicLockHanderData : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TopicLockHanderData() = default;
|
||||
~TopicLockHanderData() = default;
|
||||
|
||||
void init(void* coreFtc, int exerciseId)
|
||||
{
|
||||
Q_UNUSED(coreFtc);
|
||||
Q_UNUSED(exerciseId);
|
||||
}
|
||||
public:
|
||||
TopicLockHanderData();
|
||||
~TopicLockHanderData();
|
||||
void init(const std::shared_ptr<Core::Interface::Ftc> &coreFtc, int exerciseId);
|
||||
|
||||
void unlock()
|
||||
{
|
||||
// STUB: no-op
|
||||
}
|
||||
|
||||
void slotTryLock(const LtsWidgets::TopicInfo& topicInfo)
|
||||
{
|
||||
Q_UNUSED(topicInfo);
|
||||
// STUB: no-op
|
||||
}
|
||||
|
||||
bool isLocked() const
|
||||
{
|
||||
return false; // STUB
|
||||
}
|
||||
|
||||
LtsWidgets::TopicInfo getTopicInfo() const
|
||||
{
|
||||
return LtsWidgets::TopicInfo{}; // STUB
|
||||
}
|
||||
void unlock();
|
||||
void slotTryLock(const LtsWidgets::TopicInfo &topicInfo);
|
||||
bool isLocked() const;
|
||||
LtsWidgets::TopicInfo getTopicInfo() const;
|
||||
const QString &getLockedBy() const { return m_lockedBy; }
|
||||
|
||||
const QString& getLockedBy() const
|
||||
{
|
||||
return m_lockedBy;
|
||||
}
|
||||
Q_SIGNALS:
|
||||
void lockDataChanged();
|
||||
|
||||
Q_SIGNALS:
|
||||
void lockDataChanged();
|
||||
|
||||
public:
|
||||
QString m_debugName;
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotLock(const QString& lockedBy)
|
||||
{
|
||||
Q_UNUSED(lockedBy);
|
||||
// STUB: no-op
|
||||
}
|
||||
|
||||
void slotUnlock()
|
||||
{
|
||||
// STUB: no-op
|
||||
}
|
||||
|
||||
private:
|
||||
// STUB: No actual TopicLockHandler without RTI
|
||||
QObject* m_topicLockHandler{nullptr}; // Was QPointer<TopicLockHandler>
|
||||
QString m_lockedBy;
|
||||
private Q_SLOTS:
|
||||
void slotLock(const QString &lockedBy);
|
||||
void slotUnlock();
|
||||
public:
|
||||
QString m_debugName;
|
||||
private:
|
||||
QPointer<TopicLockHandler> m_topicLockHandler;
|
||||
QString m_lockedBy;
|
||||
};
|
||||
|
||||
|
||||
} // namespace LtsSession
|
||||
+100
-79
@@ -1,119 +1,140 @@
|
||||
|
||||
/**
|
||||
* Helper class for simple function topic request handling
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef REQUEST_HELPER_WITH_GUI
|
||||
#include "ltsutilsdds_export.h"
|
||||
#include <LtsUtilsGuiDds/ltsutilsguidds_export.h>
|
||||
#define LTSUTILSGUIDDS_INTERNAL_EXPORT LTSUTILSGUIDDS_EXPORT
|
||||
#else
|
||||
#include "ltsutilsdds_export.h"
|
||||
#include <LtsUtilsGuiDds/ltsutilsdds_export.h>
|
||||
#define LTSUTILSGUIDDS_INTERNAL_EXPORT LTSUTILSDDS_EXPORT
|
||||
#endif
|
||||
|
||||
#include <Core/core_types.h>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QPair>
|
||||
#include <QtCore/QVector>
|
||||
#include <DDS/Core/function_reply_object.h>
|
||||
#include <DDS/Core/core.hpp> // Core::FunctionReply (base reply)
|
||||
|
||||
#include <QObject>
|
||||
#include <QVector>
|
||||
#include <QPair>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
|
||||
// BUILD_RTI wird immer definiert sein (ON oder OFF)
|
||||
// Type alias für FunctionReply - immer Core::FunctionReply verwenden
|
||||
// Bei BUILD_RTI=ON wird in der .cpp auf dds::core::Reference gecastet
|
||||
using FunctionReplyType = Core::FunctionReply;
|
||||
|
||||
namespace LtsUtils
|
||||
{
|
||||
|
||||
class LTSUTILSGUIDDS_INTERNAL_EXPORT RequestHelper : public QObject
|
||||
template<typename T>
|
||||
dds::core::optional<T> toOptional(T inVal)
|
||||
{
|
||||
Q_OBJECT
|
||||
return inVal != T() ? dds::core::optional<T>(inVal) : dds::core::optional<T>();
|
||||
}
|
||||
|
||||
public:
|
||||
static bool s_debug;
|
||||
template<typename T>
|
||||
dds::core::optional<T> optional()
|
||||
{
|
||||
return dds::core::optional<T>();
|
||||
}
|
||||
|
||||
explicit RequestHelper(
|
||||
QObject* parent = nullptr, bool quiet = false,
|
||||
|
||||
const std::function<void(void)>& success = []() {}, const std::function<void(void)>& failure = []() {});
|
||||
~RequestHelper() = default;
|
||||
class LTSUTILSGUIDDS_INTERNAL_EXPORT RequestHelper : public QObject // TODO: DOC !!!
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
bool quiet() const
|
||||
{
|
||||
return m_quiet;
|
||||
}
|
||||
public:
|
||||
static bool s_debug;
|
||||
|
||||
void setQuiet(bool quiet)
|
||||
{
|
||||
m_quiet = quiet;
|
||||
}
|
||||
explicit RequestHelper(QObject *parent = nullptr, bool quiet = false,
|
||||
// for non-blocking
|
||||
const std::function<void (void)> &success = [](){},
|
||||
const std::function<void (void)> &failure = [](){});
|
||||
~RequestHelper() = default;
|
||||
|
||||
void addRequest(const std::function<int64_t()>& requestFunction,
|
||||
const std::function<void(const FunctionReplyType& baseReply)>& baseReplyHandler = nullptr);
|
||||
bool startRequests();
|
||||
bool quiet() const { return m_quiet; }
|
||||
void setQuiet(bool quiet) { m_quiet = quiet; }
|
||||
void addRequest(const std::function<int64_t()> &requestFunction,
|
||||
const std::function<void(const Core::FunctionReply &baseReply)> &baseReplyHandler = nullptr);
|
||||
bool startRequests(); // blocks!
|
||||
|
||||
bool
|
||||
startSingleRequest(const std::function<int64_t(void)>& requestFunction,
|
||||
const std::function<void(const FunctionReplyType& baseReply)>& baseReplyHandler = nullptr);
|
||||
// do not throw a message if this method fails, as this method does this already // blocks!
|
||||
bool startSingleRequest(const std::function<int64_t(void)> &requestFunction,
|
||||
const std::function<void(const Core::FunctionReply &baseReply)> &baseReplyHandler = nullptr // for replies that return a custom FunctionReply, which has to be handled >>after successful execution<<
|
||||
);
|
||||
|
||||
void startSingleBackgroundRequest(
|
||||
const std::function<int64_t()>& requestFunction,
|
||||
const std::function<void(const FunctionReplyType& baseReply)>& baseReplyHandler = nullptr);
|
||||
// non-blocking !
|
||||
/**
|
||||
* @brief startSingleBackgroundRequest << you cannot reuse this request helper after using background requests! Only use if your REALLY need it.
|
||||
* @param requestFunction
|
||||
* @param baseReplyHandler
|
||||
*/
|
||||
void startSingleBackgroundRequest(const std::function<int64_t()> &requestFunction,
|
||||
const std::function<void(const Core::FunctionReply &baseReply)> &baseReplyHandler = nullptr);
|
||||
/**
|
||||
* @brief startBackgroundRequests << you cannot reuse this request helper after using background requests! Only use if your REALLY need it.
|
||||
*/
|
||||
void startBackgroundRequests(); // non-blocking !
|
||||
|
||||
void startBackgroundRequests();
|
||||
bool requestReply(const Core::FunctionReply &baseReply); // if you have a custom FunctionReply, pass the base ptr
|
||||
bool requestReply(const Core::FunctionReplyObject &replyObject);
|
||||
|
||||
bool requestReply(const FunctionReplyType& baseReply);
|
||||
bool requestReply(const Core::FunctionReplyObject& replyObject);
|
||||
/**
|
||||
* @brief hasRequests are requests is added?
|
||||
* @return True if a request is added, otherwise false
|
||||
*/
|
||||
bool hasRequests() const { return !m_requestFunctions.isEmpty(); }
|
||||
|
||||
bool hasRequests() const
|
||||
{
|
||||
return !m_requestFunctions.isEmpty();
|
||||
}
|
||||
|
||||
int getRepliedId() const
|
||||
{
|
||||
return m_repliedId;
|
||||
}
|
||||
/**
|
||||
* @brief getRepliedId returns the Return-ID of the ReplyObject you gave to the method 'requestReply' - which is mostly the ID for the new Table Entry (Unique ID)
|
||||
* @return the Return-ID or -1 on error (not set)
|
||||
*/
|
||||
int getRepliedId() const { return m_repliedId; }
|
||||
|
||||
QString getErrorString() const
|
||||
{
|
||||
return m_errorString;
|
||||
}
|
||||
/**
|
||||
* @brief getErrorString returns the error string set by an ftc reply
|
||||
* @return
|
||||
*/
|
||||
QString getErrorString() const { return m_errorString; }
|
||||
|
||||
void setCustomWaitMessage(const QString& customWaitMessage);
|
||||
/**
|
||||
* @brief setCustomWaitMessage changes the default 'Waiting for server reply ...' message with a custom one (NOTE: " ..." is automagically added to the custom text)
|
||||
* After a request was started, the custom wait message is immediately reset, so that the next call to start a request, shows the default message again
|
||||
* @param customWaitMessage the wait message to replace the default message with (note that " ..." is added to the text)
|
||||
*/
|
||||
void setCustomWaitMessage(const QString &customWaitMessage);
|
||||
|
||||
bool failed() const
|
||||
{
|
||||
return m_failed;
|
||||
}
|
||||
bool failed() const { return m_failed; }
|
||||
void failure();
|
||||
|
||||
void failure();
|
||||
private:
|
||||
using RequestFunctionContainer = QPair<std::function<int64_t()>, std::function<void(const Core::FunctionReply &)>>;
|
||||
|
||||
private:
|
||||
using RequestFunctionContainer = QPair<std::function<int64_t()>, std::function<void(const FunctionReplyType&)>>;
|
||||
QVector<RequestFunctionContainer> m_requestFunctions;
|
||||
bool m_failed;
|
||||
int m_repliedId;
|
||||
std::function<void(const Core::FunctionReply &)> m_singleRequestCustomFunctionReply;
|
||||
bool m_quiet;
|
||||
bool m_blockingCall;
|
||||
std::function<void (void)> m_successFn;
|
||||
std::function<void (void)> m_failureFn;
|
||||
QString m_errorString;
|
||||
QString m_customWaitMessage;
|
||||
|
||||
QVector<RequestFunctionContainer> m_requestFunctions;
|
||||
bool m_failed;
|
||||
int m_repliedId;
|
||||
std::function<void(const FunctionReplyType&)> m_singleRequestCustomFunctionReply;
|
||||
bool m_quiet;
|
||||
bool m_blockingCall;
|
||||
std::function<void(void)> m_successFn;
|
||||
std::function<void(void)> m_failureFn;
|
||||
QString m_errorString;
|
||||
QString m_customWaitMessage;
|
||||
void done();
|
||||
bool _requestReply(const Core::FunctionReplyObject &fro, const Core::FunctionReply *baseReply);
|
||||
|
||||
void done();
|
||||
bool _requestReply(const Core::FunctionReplyObject& fro, const FunctionReplyType* baseReply);
|
||||
signals:
|
||||
void signalNextRequest();
|
||||
void signalQuitLoop();
|
||||
void signalSuccess();
|
||||
void signalFailed();
|
||||
|
||||
signals:
|
||||
void signalNextRequest();
|
||||
void signalQuitLoop();
|
||||
void signalSuccess();
|
||||
void signalFailed();
|
||||
private slots:
|
||||
void slotNextRequest();
|
||||
|
||||
private slots:
|
||||
void slotNextRequest();
|
||||
};
|
||||
|
||||
} // namespace LtsUtils
|
||||
@@ -8,21 +8,6 @@
|
||||
# Lts Widgets library
|
||||
#
|
||||
|
||||
# Make ${Qt6_Gui} optional
|
||||
if(QT6_GUI_AVAILABLE AND TARGET Qt6::Gui)
|
||||
set(Qt6_Gui ${Qt6_Gui})
|
||||
else()
|
||||
set(Qt6_Gui "")
|
||||
endif()
|
||||
|
||||
# Make ${Qt6_Widgets} optional
|
||||
if(QT6_GUI_AVAILABLE AND TARGET Qt6::Widgets)
|
||||
set(Qt6_Widgets ${Qt6_Widgets})
|
||||
else()
|
||||
set(Qt6_Widgets "")
|
||||
endif()
|
||||
|
||||
|
||||
SET(ltswidgets_SRCS
|
||||
#lts_abstract_table_model.h
|
||||
#lts_checkable_table_model.h
|
||||
@@ -123,6 +108,8 @@ SET(ltswidgets_SRCS
|
||||
lts_text_editor2.h
|
||||
lts_text_editor2.cpp
|
||||
|
||||
|
||||
|
||||
LtsImageCropper/lts_image_cropper.cpp
|
||||
)
|
||||
|
||||
@@ -160,54 +147,41 @@ NGL_WRAP_UI(ltswidgets_SRCS
|
||||
lts_date_time_edit_touch.ui
|
||||
)
|
||||
|
||||
# ui_requirement.cpp/h sind normale C++ Dateien, keine UI-Dateien
|
||||
# CMAKE_AUTOUIC komplett deaktivieren da ui_requirement.h wie eine UI-Datei aussieht
|
||||
set(CMAKE_AUTOUIC OFF)
|
||||
|
||||
NGL_ADD_BIG_RESOURCES(ltswidgets_SRCS resources/lts_resources.qrc)
|
||||
NGL_ADD_LIBRARY(WS TOOLSWS TOOLSSV LtsWidgets SHARED ${ltswidgets_SRCS})
|
||||
|
||||
# Qt6 Dependencies immer setzen (auch wenn BUILD_RTI=OFF)
|
||||
# Die Library wird gebaut, aber nur bei BUILD_RTI=ON installiert/verwendet
|
||||
if(QT6_GUI_AVAILABLE)
|
||||
NGL_TARGET_LINK_LIBRARIES(LtsWidgets
|
||||
PRIVATE
|
||||
Qt6::Network # for QHostInfo - for portability
|
||||
Qt6::Svg
|
||||
ngltools
|
||||
ngltranslator
|
||||
TabBarTabStyle
|
||||
LtsSessionData
|
||||
NGLLogger
|
||||
PUBLIC
|
||||
LtsUtilsCore
|
||||
LtsUtilsSettings
|
||||
Qt6::Core
|
||||
${Qt6_Widgets}
|
||||
${Qt6_Gui}
|
||||
)
|
||||
endif()
|
||||
|
||||
# Include directories needed for all builds (not just BUILD_RTI)
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(LtsWidgets
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
)
|
||||
|
||||
IF(BUILD_RTI)
|
||||
NGL_TARGET_LINK_LIBRARIES(LtsWidgets
|
||||
PRIVATE
|
||||
Qt5::Network # for QHostInfo - for portability
|
||||
Qt5::Svg
|
||||
ngltools
|
||||
ngltranslator
|
||||
TabBarTabStyle
|
||||
LtsSessionData
|
||||
LtsUtilsSettings
|
||||
PUBLIC
|
||||
LtsUtilsCore
|
||||
Qt5::Core
|
||||
Qt5::Widgets
|
||||
Qt5::Gui
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(LtsWidgets)
|
||||
ENDIF()
|
||||
|
||||
#
|
||||
# Designer-Plugin
|
||||
#
|
||||
IF(BUILD_RTI)
|
||||
SET(ltswidgetsplugin_SRCS ltswidgetsplugin.cpp ltswidgetsplugin.json)
|
||||
NGL_ADD_LIBRARY(WS ltswidgetsplugin MODULE ${ltswidgetsplugin_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(ltswidgetsplugin LtsWidgets ltsCoordWidget LtsDataView LtsFileDialog LtsReportDisplay svcFlmCommon)
|
||||
NGL_SET_TARGET_PROPERTIES(ltswidgetsplugin PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/designer)
|
||||
NGL_INSTALL_TARGET(ltswidgetsplugin DESTINATION lib/designer COMPONENT Devel)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_TESTING)
|
||||
# picture_editing_test
|
||||
|
||||
@@ -1,27 +1,23 @@
|
||||
|
||||
/**
|
||||
* The Pacemaker class implements functionality to publish Service states in DDS.
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 29.02.2016
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "svccoreclient_export.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QThread>
|
||||
|
||||
// Forward declarations for moc compatibility (moc doesn't see BUILD_RTI guards)
|
||||
namespace Core { enum class RunningState; enum class CorePortType; }
|
||||
namespace DTS { class CurrentRunningStateImpl; }
|
||||
|
||||
#if BUILD_RTI
|
||||
#include <dds/core/core_dts_types.h>
|
||||
#include <dds/core/types/CurrentRunningState.h>
|
||||
#endif
|
||||
#include <DDS/Core/core_dts_types.h>
|
||||
#include "core_export.h"
|
||||
|
||||
namespace DDSConnector
|
||||
{
|
||||
class DdsConnector;
|
||||
}
|
||||
class QTimer;
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
@@ -31,51 +27,36 @@ namespace Core
|
||||
{
|
||||
class CORE_CLIENT_EXPORT Pacemaker final : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
#if BUILD_RTI
|
||||
explicit Pacemaker(const std::shared_ptr<DDSConnector::DdsConnector>& ddsConnector) : Pacemaker(ddsConnector.get())
|
||||
{
|
||||
}
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Pacemaker(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector)
|
||||
: Pacemaker(ddsConnector.get())
|
||||
{}
|
||||
|
||||
explicit Pacemaker(DDSConnector::DdsConnector* ddsConnector);
|
||||
#else
|
||||
explicit Pacemaker(void* /*ddsConnector*/) {}
|
||||
explicit Pacemaker() {}
|
||||
#endif
|
||||
~Pacemaker();
|
||||
explicit Pacemaker(DDSConnector::DdsConnector *ddsConnector);
|
||||
~Pacemaker();
|
||||
|
||||
#if BUILD_RTI
|
||||
void startTimer();
|
||||
#endif
|
||||
void startTimer();
|
||||
|
||||
public Q_SLOTS:
|
||||
#if BUILD_RTI
|
||||
void setNewState(Core::RunningState newState, const QString& errorString = QString());
|
||||
void addPort(unsigned short number, Core::CorePortType portType, const QString& properties = QStringLiteral(""));
|
||||
public Q_SLOTS:
|
||||
void setNewState(Core::RunningState newState, const QString &errorString = QString());
|
||||
void addPort(unsigned short number, Core::PortType portType, const QString &properties = QStringLiteral(""));
|
||||
|
||||
void publishState();
|
||||
#endif
|
||||
// only public for special purposes, not needed to call explicitly by default
|
||||
void publishState();
|
||||
|
||||
private:
|
||||
#if BUILD_RTI
|
||||
NGL::INGLLogger& m_logger;
|
||||
void init(DDSConnector::DdsConnector* ddsConnector);
|
||||
void setNewStateInternal(Core::RunningState newState, const QString& errorString = QString());
|
||||
void addPortInternal(unsigned short number, Core::CorePortType portType,
|
||||
const QString& properties = QStringLiteral(""));
|
||||
private:
|
||||
void init(DDSConnector::DdsConnector *ddsConnector);
|
||||
void setNewStateInternal(Core::RunningState newState, const QString &errorString = QString());
|
||||
void addPortInternal(unsigned short number, Core::PortType portType, const QString &properties = QStringLiteral(""));
|
||||
private:
|
||||
static constexpr const int m_publishTimerDelay = 3000;
|
||||
|
||||
CurrentRunningState m_state;
|
||||
DTS::CurrentRunningStateImpl* m_dtsCurrentRunningState = nullptr;
|
||||
#else
|
||||
void* m_reserved1 = nullptr;
|
||||
void* m_reserved2 = nullptr;
|
||||
void* m_reserved3 = nullptr;
|
||||
void* m_reserved4 = nullptr;
|
||||
void* m_reserved5 = nullptr;
|
||||
#endif
|
||||
static constexpr const int m_publishTimerDelay = 3000;
|
||||
QTimer* m_publishTimer = nullptr;
|
||||
QThread* m_paceThread = nullptr;
|
||||
CurrentRunningState m_state;
|
||||
QTimer *m_publishTimer = nullptr;
|
||||
QThread *m_paceThread = nullptr;
|
||||
|
||||
DTS::CurrentRunningStateImpl *m_dtsCurrentRunningState;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
} // namespace Core
|
||||
@@ -1,9 +1,14 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* FTC GenericFTC_Interface
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Core/core.hpp>
|
||||
#include <DDS/Core/core.hpp>
|
||||
|
||||
#include <future>
|
||||
|
||||
@@ -11,7 +16,7 @@ class Request2;
|
||||
|
||||
namespace FTC
|
||||
{
|
||||
|
||||
// uses FTC (static)
|
||||
template <typename RequestTopicType, typename ReplyTopicType>
|
||||
class GenericFtc
|
||||
{
|
||||
@@ -25,4 +30,4 @@ public:
|
||||
int &uniqueId) = 0;
|
||||
virtual std::future<ReplyTopicType> requestDataModern(const RequestTopicType &requestTopic, Request2 *requestWatcher) = 0;
|
||||
};
|
||||
}
|
||||
} // namespace FTC
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,20 +1,24 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Generic Function Topic Server (FTS Replier)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#if BUILD_RTI
|
||||
#include <DDS/Core/core.hpp>
|
||||
|
||||
#include "connext.h"
|
||||
#include "generic_fts_internal.h"
|
||||
|
||||
#include <Core/core.hpp>
|
||||
#include "connext.h"
|
||||
#include <DDS/Generic/wait_set_handler.h>
|
||||
#include <DDS/Generic/generic_base.h>
|
||||
#include <DDS/Generic/generic_logger.h>
|
||||
#include <DDS/Generic/wait_set_handler.h>
|
||||
|
||||
#include <queue>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
#include <typeinfo>
|
||||
#include <sstream>
|
||||
|
||||
#ifndef tr_lts
|
||||
#define tr_lts(ctx, t) (t)
|
||||
@@ -22,240 +26,290 @@
|
||||
|
||||
namespace FTS
|
||||
{
|
||||
template <class C> class HasStatusFunction
|
||||
template <class C>
|
||||
class HasStatusFunction
|
||||
{
|
||||
template <class T> static std::true_type testSignature(void (T::*)(const Core::FtReplyState&));
|
||||
template <class T>
|
||||
static std::true_type testSignature(void (T::*)(const Core::FtReplyState&));
|
||||
|
||||
template <class T> static decltype(testSignature(&T::replyState)) test(std::nullptr_t);
|
||||
template <class T>
|
||||
static decltype(testSignature(&T::replyState)) test(std::nullptr_t);
|
||||
|
||||
template <class T> static std::false_type test(...);
|
||||
template <class T>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
using type = decltype(test<C>(nullptr));
|
||||
static const bool value = type::value;
|
||||
public:
|
||||
using type = decltype(test<C>(nullptr));
|
||||
static const bool value = type::value;
|
||||
};
|
||||
|
||||
template <typename GENERIC_FTS> struct TopicNames;
|
||||
template<typename GENERIC_FTS>
|
||||
struct TopicNames;
|
||||
|
||||
template <typename TOPICTYPE_REQUEST, typename TOPICTYPE_REPLY, typename DUMMY>
|
||||
class GenericFtsImpl final : public GenericFts<TOPICTYPE_REQUEST, TOPICTYPE_REPLY>, public GenericFtsInternal
|
||||
template<typename TOPICTYPE_REQUEST, typename TOPICTYPE_REPLY, typename DUMMY>
|
||||
class GenericFtsImpl final : public GenericFts<TOPICTYPE_REQUEST,TOPICTYPE_REPLY>
|
||||
, public GenericFtsInternal
|
||||
{
|
||||
public:
|
||||
using RequestTopic = TOPICTYPE_REQUEST;
|
||||
using ReplyTopic = TOPICTYPE_REPLY;
|
||||
using TopicNameHelper = TopicNames<GenericFtsImpl<RequestTopic, ReplyTopic, DUMMY>>;
|
||||
public:
|
||||
using RequestTopic = TOPICTYPE_REQUEST;
|
||||
using ReplyTopic = TOPICTYPE_REPLY;
|
||||
using TopicNameHelper = TopicNames<GenericFtsImpl<RequestTopic, ReplyTopic, DUMMY>>;
|
||||
private:
|
||||
using SubscriberCallback = std::function<void(const rti::core::SampleIdentity&, const RequestTopic&)>;
|
||||
|
||||
private:
|
||||
using SubscriberCallback = std::function<void(const rti::core::SampleIdentity&, const RequestTopic&)>;
|
||||
template <typename T = ReplyTopic, typename std::enable_if<HasStatusFunction<T>::value, int>::type = 0>
|
||||
void sendReplyState(Core::FtReplyState replyState, const rti::core::SampleIdentity &requestSampleIdentity)
|
||||
{
|
||||
connext::WriteSample<ReplyTopic> reply;
|
||||
reply.data().replyState(replyState);
|
||||
|
||||
template <typename T = ReplyTopic, typename std::enable_if<HasStatusFunction<T>::value, int>::type = 0>
|
||||
void sendReplyState(Core::FtReplyState replyState, const rti::core::SampleIdentity& requestSampleIdentity)
|
||||
bool bLastTelegram = ((replyState != Core::FtReplyState_def::InProgress) &&
|
||||
(replyState != Core::FtReplyState_def::NotStarted));
|
||||
m_replier->send_reply(reply, requestSampleIdentity, bLastTelegram);
|
||||
}
|
||||
|
||||
template <typename T = ReplyTopic, typename std::enable_if<!HasStatusFunction<T>::value, int>::type = 0>
|
||||
void sendReplyState(Core::FtReplyState, const rti::core::SampleIdentity &)
|
||||
{
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
template <typename T, typename std::enable_if<HasStatusFunction<T>::value, int>::type = 0>
|
||||
void setReply(T &data, Core::FtReplyState status)
|
||||
{
|
||||
data.replyState(status);
|
||||
}
|
||||
|
||||
template <typename T, typename std::enable_if<!HasStatusFunction<T>::value, int>::type = 0>
|
||||
void setReply(T &, Core::FtReplyState)
|
||||
{
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
public:
|
||||
GenericFtsImpl(const dds::domain::DomainParticipant &domainParticipant,
|
||||
const dds::pub::Publisher &ddsPublisher,
|
||||
const dds::sub::Subscriber &ddsSubscriber,
|
||||
DDSGeneric::WaitSetHandler *wsHandler)
|
||||
: GenericFts<RequestTopic,ReplyTopic>()
|
||||
, GenericFtsInternal()
|
||||
, m_wsHandler(wsHandler)
|
||||
, m_subscriberCallback(nullptr)
|
||||
, m_logger(DDS::getLogger(TopicNameHelper::functionTopicName(), DDS::DataType::FUNCTION_TOPIC_SERVER))
|
||||
{
|
||||
Q_ASSERT(domainParticipant != nullptr);
|
||||
Q_ASSERT(ddsPublisher != nullptr);
|
||||
Q_ASSERT(ddsSubscriber != nullptr);
|
||||
Q_ASSERT(wsHandler != nullptr);
|
||||
|
||||
qRegisterMetaType<RequestTopic> (TopicNameHelper::requestTopicTypeName());
|
||||
|
||||
connext::ReplierParams<RequestTopic,ReplyTopic> replierParams(domainParticipant);
|
||||
|
||||
//DEBUG_LOG(m_logger) << "m_domainParticipant: " << m_domainParticipant;
|
||||
|
||||
//requesterParams.service_name("FunctionTopic");
|
||||
replierParams.request_topic_name(TopicNameHelper::requestTopicName());
|
||||
replierParams.reply_topic_name(TopicNameHelper::replyTopicName());
|
||||
replierParams.publisher(ddsPublisher);
|
||||
replierParams.subscriber(ddsSubscriber);
|
||||
replierParams.datareader_qos(readerQos(m_logger));
|
||||
replierParams.datawriter_qos(writerQos(m_logger));
|
||||
|
||||
//DEBUG_LOG(m_logger) << "=> Static request using request/reply topic names: "
|
||||
// << requestTopicName << ", reply: " << replyTopicName;
|
||||
|
||||
m_replier = new connext::Replier<RequestTopic, ReplyTopic>(replierParams);
|
||||
m_readCondition = new dds::sub::cond::ReadCondition(m_replier->get_request_datareader(), dds::sub::status::SampleState::not_read());
|
||||
|
||||
m_wsHandler->attachWaitSet(*m_readCondition, this);
|
||||
}
|
||||
|
||||
~GenericFtsImpl()
|
||||
{
|
||||
m_wsHandler->detachWaitSet(*m_readCondition, this);
|
||||
delete m_readCondition;
|
||||
delete m_replier;
|
||||
}
|
||||
|
||||
bool setSubscriberCallback(const SubscriberCallback &subscriberCallback)
|
||||
{
|
||||
if (m_subscriberCallback)
|
||||
{
|
||||
connext::WriteSample<ReplyTopic> reply;
|
||||
reply.data().replyState(replyState);
|
||||
|
||||
bool bLastTelegram =
|
||||
((replyState != Core::FtReplyState_def::InProgress) && (replyState != Core::FtReplyState_def::NotStarted));
|
||||
m_replier->send_reply(reply, requestSampleIdentity, bLastTelegram);
|
||||
WARNING_LOG(m_logger) << "Can not set subscriber callback - already set ...";
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename T = ReplyTopic, typename std::enable_if<!HasStatusFunction<T>::value, int>::type = 0>
|
||||
void sendReplyState(Core::FtReplyState, const rti::core::SampleIdentity&)
|
||||
m_subscriberCallback = subscriberCallback;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* Send a single reply back to the requester
|
||||
*
|
||||
* @param requestIdentity
|
||||
* @param replyData
|
||||
*/
|
||||
bool sendReply(const rti::core::SampleIdentity &requestSampleIdentity, const ReplyTopic &replyData) override final
|
||||
{
|
||||
connext::WriteSampleRef<ReplyTopic> reply;
|
||||
rti::pub::WriteParams replyParams;
|
||||
|
||||
reply.set_data(const_cast<ReplyTopic*>(&replyData));
|
||||
reply.set_info(&replyParams);
|
||||
|
||||
m_replier->send_reply(reply, requestSampleIdentity);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* Send a block of reply informations back to the requester
|
||||
* The replies will have a correctly set replyState member (all will have InProgress, the last on Completed)
|
||||
*
|
||||
* @param requestIdentity
|
||||
* @param replyData
|
||||
*/
|
||||
bool sendReply(const rti::core::SampleIdentity &requestIdentity, const QVector<ReplyTopic> &replyData) override final
|
||||
{
|
||||
DEBUG_LOG(m_logger) << TopicNameHelper::requestTopicName() << " - IN sendReply";
|
||||
|
||||
for(int i = 0; i < replyData.size(); ++i)
|
||||
{
|
||||
if (HasStatusFunction<ReplyTopic>::value)
|
||||
{
|
||||
ReplyTopic rt = replyData.at(i);
|
||||
setReply(rt, i == replyData.size() - 1 ? Core::FtReplyState::Completed : Core::FtReplyState::InProgress);
|
||||
if (!sendReply(requestIdentity, rt))
|
||||
return false;
|
||||
} else {
|
||||
if (!sendReply(requestIdentity, replyData.at(i)))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename std::enable_if<HasStatusFunction<T>::value, int>::type = 0>
|
||||
void setReply(T& data, Core::FtReplyState status)
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
// -------------------------------------------------------------------------------------------------------------------
|
||||
// FunctionTopics => defined in *.idl
|
||||
// -------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief
|
||||
* Get the requested data and send them on to the object that will supply the data
|
||||
*
|
||||
* @param request topic data
|
||||
*/
|
||||
void processRequest(const connext::Sample<RequestTopic> &request)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << TopicNameHelper::requestTopicName() << " - processRequest: "
|
||||
<< connext::DebugInfo::toReadable(request.identity());
|
||||
|
||||
qint64 age = qAbs(qint64(request.info().source_timestamp().to_secs()) - time(nullptr));
|
||||
|
||||
if (age > 10) // sec
|
||||
{
|
||||
data.replyState(status);
|
||||
std::ostringstream ss;
|
||||
ss << request.data();
|
||||
std::string s = ss.str();
|
||||
int slen = s.length();
|
||||
|
||||
static int max_slen = 1024;
|
||||
if (slen > max_slen)
|
||||
{
|
||||
s.resize(max_slen);
|
||||
s.append("...");
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "received a request for topic "
|
||||
<< TopicNameHelper::requestTopicName()
|
||||
<< " but it was outdated - ignoring. "
|
||||
<< " local time: " << (time(nullptr) - 10) << "[s], source timestamp: "
|
||||
<< qint64(request.info().source_timestamp().to_secs())
|
||||
<< "[s], -> age: " << age
|
||||
<< "[s], data: " << s;
|
||||
ReplyTopic rt;
|
||||
rt.errorString(tr_lts("dds", "Topic %1 was outdated and therefore ignored. Does the client time match the server time?"));
|
||||
rt.errorParams({TopicNameHelper::requestTopicName()});
|
||||
sendReply(request.identity(), rt);
|
||||
return;
|
||||
}
|
||||
|
||||
template <typename T, typename std::enable_if<!HasStatusFunction<T>::value, int>::type = 0>
|
||||
void setReply(T&, Core::FtReplyState)
|
||||
sendReplyState(Core::FtReplyState::InProgress, request.identity());
|
||||
|
||||
m_subscriberCallback(request.identity(), request.data());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* This method waits for requests from a FTC.
|
||||
* When it receives a request topic, it will get the requested data
|
||||
* and send it via DDS Replier back to the FTC
|
||||
*
|
||||
*/
|
||||
void processRequests() override
|
||||
{
|
||||
DEBUG_LOG(m_logger) << TopicNameHelper::requestTopicName() << " - processRequests";
|
||||
|
||||
while (true)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
GenericFtsImpl(const dds::domain::DomainParticipant& domainParticipant, const dds::pub::Publisher& ddsPublisher,
|
||||
const dds::sub::Subscriber& ddsSubscriber, DDSGeneric::WaitSetHandler* wsHandler)
|
||||
: GenericFts<RequestTopic, ReplyTopic>(), GenericFtsInternal(), m_wsHandler(wsHandler),
|
||||
m_subscriberCallback(nullptr),
|
||||
m_logger(DDS::getLogger(TopicNameHelper::functionTopicName(), DDS::DataType::FUNCTION_TOPIC_SERVER))
|
||||
{
|
||||
Q_ASSERT(domainParticipant != nullptr);
|
||||
Q_ASSERT(ddsPublisher != nullptr);
|
||||
Q_ASSERT(ddsSubscriber != nullptr);
|
||||
Q_ASSERT(wsHandler != nullptr);
|
||||
|
||||
qRegisterMetaType<RequestTopic>(TopicNameHelper::requestTopicTypeName());
|
||||
|
||||
connext::ReplierParams<RequestTopic, ReplyTopic> replierParams(domainParticipant);
|
||||
|
||||
replierParams.request_topic_name(TopicNameHelper::requestTopicName());
|
||||
replierParams.reply_topic_name(TopicNameHelper::replyTopicName());
|
||||
replierParams.publisher(ddsPublisher);
|
||||
replierParams.subscriber(ddsSubscriber);
|
||||
replierParams.datareader_qos(readerQos(m_logger));
|
||||
replierParams.datawriter_qos(writerQos(m_logger));
|
||||
|
||||
m_replier = new connext::Replier<RequestTopic, ReplyTopic>(replierParams);
|
||||
m_readCondition = new dds::sub::cond::ReadCondition(m_replier->get_request_datareader(),
|
||||
dds::sub::status::SampleState::not_read());
|
||||
|
||||
m_wsHandler->attachWaitSet(*m_readCondition, this);
|
||||
}
|
||||
|
||||
~GenericFtsImpl()
|
||||
{
|
||||
m_wsHandler->detachWaitSet(*m_readCondition, this);
|
||||
delete m_readCondition;
|
||||
delete m_replier;
|
||||
}
|
||||
|
||||
bool setSubscriberCallback(const SubscriberCallback& subscriberCallback)
|
||||
{
|
||||
if (m_subscriberCallback)
|
||||
connext::Sample<RequestTopic> request;
|
||||
{
|
||||
std::lock_guard<std::mutex> l(m_requestMutex);
|
||||
if (m_requests.empty())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Can not set subscriber callback - already set ...";
|
||||
return false;
|
||||
DEBUG_LOG(m_logger) << "No more requests";
|
||||
return;
|
||||
}
|
||||
|
||||
m_subscriberCallback = subscriberCallback;
|
||||
return true;
|
||||
DEBUG_LOG(m_logger) << TopicNameHelper::requestTopicName() << " - read one request for ";
|
||||
request = m_requests.front();
|
||||
m_requests.pop();
|
||||
}
|
||||
if (!request.info().valid())
|
||||
{
|
||||
WARNING_LOG(m_logger) << TopicNameHelper::requestTopicName() << " - No valid data";
|
||||
continue;
|
||||
}
|
||||
processRequest(request);
|
||||
}
|
||||
DEBUG_LOG(m_logger) << TopicNameHelper::requestTopicName() << " - processRequests finished";
|
||||
}
|
||||
|
||||
bool sendReply(const rti::core::SampleIdentity& requestSampleIdentity, const ReplyTopic& replyData) override final
|
||||
bool enqueueRequests() override
|
||||
{
|
||||
bool bValidDataRead = false;
|
||||
connext::Sample<RequestTopic> request;
|
||||
while (m_replier->receive_request(request))
|
||||
{
|
||||
connext::WriteSampleRef<ReplyTopic> reply;
|
||||
rti::pub::WriteParams replyParams;
|
||||
|
||||
reply.set_data(const_cast<ReplyTopic*>(&replyData));
|
||||
reply.set_info(&replyParams);
|
||||
|
||||
m_replier->send_reply(reply, requestSampleIdentity);
|
||||
return true;
|
||||
if (!request.info().valid())
|
||||
continue;
|
||||
bValidDataRead = true;
|
||||
std::lock_guard<std::mutex> l(m_requestMutex);
|
||||
m_requests.push(request);
|
||||
}
|
||||
return bValidDataRead;
|
||||
}
|
||||
|
||||
bool sendReply(const rti::core::SampleIdentity& requestIdentity,
|
||||
const QVector<ReplyTopic>& replyData) override final
|
||||
{
|
||||
DEBUG_LOG(m_logger) << TopicNameHelper::requestTopicName() << " - IN sendReply";
|
||||
private:
|
||||
// Replier (with request and reply topic (see above)
|
||||
connext::Replier<RequestTopic, ReplyTopic> *m_replier;
|
||||
dds::sub::cond::ReadCondition *m_readCondition;
|
||||
|
||||
for (int i = 0; i < replyData.size(); ++i)
|
||||
{
|
||||
if (HasStatusFunction<ReplyTopic>::value)
|
||||
{
|
||||
ReplyTopic rt = replyData.at(i);
|
||||
setReply(rt,
|
||||
i == replyData.size() - 1 ? Core::FtReplyState::Completed : Core::FtReplyState::InProgress);
|
||||
if (!sendReply(requestIdentity, rt))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!sendReply(requestIdentity, replyData.at(i)))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// no ownership
|
||||
DDSGeneric::WaitSetHandler *m_wsHandler;
|
||||
|
||||
return true;
|
||||
}
|
||||
std::queue<connext::Sample<RequestTopic>> m_requests;
|
||||
std::mutex m_requestMutex;
|
||||
|
||||
protected:
|
||||
void processRequest(const connext::Sample<RequestTopic>& request)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << TopicNameHelper::requestTopicName()
|
||||
<< " - processRequest: " << connext::DebugInfo::toReadable(request.identity());
|
||||
// Callback for data processing
|
||||
SubscriberCallback m_subscriberCallback;
|
||||
|
||||
qint64 age = qAbs(qint64(request.info().source_timestamp().to_secs()) - time(nullptr));
|
||||
|
||||
if (age > 10)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << request.data();
|
||||
std::string s = ss.str();
|
||||
int slen = s.length();
|
||||
|
||||
static int max_slen = 1024;
|
||||
if (slen > max_slen)
|
||||
{
|
||||
s.resize(max_slen);
|
||||
s.append("...");
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "received a request for topic " << TopicNameHelper::requestTopicName()
|
||||
<< " but it was outdated - ignoring. "
|
||||
<< " local time: " << (time(nullptr) - 10)
|
||||
<< "[s], source timestamp: " << qint64(request.info().source_timestamp().to_secs())
|
||||
<< "[s], -> age: " << age << "[s], data: " << s;
|
||||
ReplyTopic rt;
|
||||
rt.errorString(tr_lts(
|
||||
"dds", "Topic %1 was outdated and therefore ignored. Does the client time match the server time?"));
|
||||
rt.errorParams({TopicNameHelper::requestTopicName()});
|
||||
sendReply(request.identity(), rt);
|
||||
return;
|
||||
}
|
||||
|
||||
sendReplyState(Core::FtReplyState::InProgress, request.identity());
|
||||
|
||||
m_subscriberCallback(request.identity(), request.data());
|
||||
}
|
||||
|
||||
void processRequests() override
|
||||
{
|
||||
DEBUG_LOG(m_logger) << TopicNameHelper::requestTopicName() << " - processRequests";
|
||||
|
||||
while (true)
|
||||
{
|
||||
connext::Sample<RequestTopic> request;
|
||||
{
|
||||
std::lock_guard<std::mutex> l(m_requestMutex);
|
||||
if (m_requests.empty())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "No more requests";
|
||||
return;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << TopicNameHelper::requestTopicName() << " - read one request for ";
|
||||
request = m_requests.front();
|
||||
m_requests.pop();
|
||||
}
|
||||
if (!request.info().valid())
|
||||
{
|
||||
WARNING_LOG(m_logger) << TopicNameHelper::requestTopicName() << " - No valid data";
|
||||
continue;
|
||||
}
|
||||
processRequest(request);
|
||||
}
|
||||
DEBUG_LOG(m_logger) << TopicNameHelper::requestTopicName() << " - processRequests finished";
|
||||
}
|
||||
|
||||
bool enqueueRequests() override
|
||||
{
|
||||
bool bValidDataRead = false;
|
||||
connext::Sample<RequestTopic> request;
|
||||
while (m_replier->receive_request(request))
|
||||
{
|
||||
if (!request.info().valid())
|
||||
continue;
|
||||
bValidDataRead = true;
|
||||
std::lock_guard<std::mutex> l(m_requestMutex);
|
||||
m_requests.push(request);
|
||||
}
|
||||
return bValidDataRead;
|
||||
}
|
||||
|
||||
private:
|
||||
connext::Replier<RequestTopic, ReplyTopic>* m_replier;
|
||||
dds::sub::cond::ReadCondition* m_readCondition;
|
||||
|
||||
DDSGeneric::WaitSetHandler* m_wsHandler;
|
||||
|
||||
std::queue<connext::Sample<RequestTopic>> m_requests;
|
||||
std::mutex m_requestMutex;
|
||||
|
||||
SubscriberCallback m_subscriberCallback;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
} // namespace FTS
|
||||
|
||||
#endif // BUILD_RTI
|
||||
+95
-73
@@ -1,8 +1,14 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectSimulation - Explosions Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Steve Tougnia, SLTE, 2023-09-05
|
||||
*/
|
||||
|
||||
#include "aes_explosions_edit_adler.h"
|
||||
|
||||
// #include "aes_explosions_edit_helper.h"
|
||||
#include "aes_effector.h"
|
||||
#include "ui_aes_explosions_edit_adler.h"
|
||||
|
||||
@@ -10,18 +16,18 @@
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <AreaEffectSimulation/Base/aes_base_model.h>
|
||||
#include <SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <AreaEffectSimulation/Utils/aes_helper.h>
|
||||
#include <AreaEffectSimulation/Utils/polygons.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_model.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <Services/AreaEffectSimulation/Utils/aes_helper.h>
|
||||
#include <Services/AreaEffectSimulation/Utils/polygons.h>
|
||||
#include <Services/ParticipantManagement/ppm_translation.h>
|
||||
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <AreaEffectSimulation/settings.h>
|
||||
#include <Services/AreaEffectSimulation/settings.h>
|
||||
|
||||
#include <AdvancedSymbology/asb_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/Gui/ParticipantSelection/participant_selection.h>
|
||||
#include <Plugins/AdvancedSymbology/asb_data_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/Gui/ParticipantSelection/participant_selection.h>
|
||||
|
||||
#include <AreaEffectSimulation/aes_translation.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
@@ -33,20 +39,23 @@
|
||||
#include <ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <LtsElevation/lts_elevation_manager.h>
|
||||
|
||||
#include <QtWidgets/QButtonGroup>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtWidgets/QSpinBox>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QButtonGroup>
|
||||
#include <QDateTime>
|
||||
#include <QHash>
|
||||
#include <QJsonDocument>
|
||||
#include <QSpinBox>
|
||||
#include <QTimer>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
static const char *const VALUE_VALID_PROPERTY_NAME = "VALUE_VALID";
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \brief ExplosionsEditAdler::ExplosionsEditAdler
|
||||
* \param menuGroup
|
||||
* \param parent
|
||||
*/
|
||||
QString ExplosionsEditAdler::toString(ExplosionsEditAdler::FlighDurationOrPeakHeight val)
|
||||
{
|
||||
switch (val)
|
||||
@@ -64,12 +73,12 @@ QString ExplosionsEditAdler::toString(ExplosionsEditAdler::FlighDurationOrPeakHe
|
||||
return QStringLiteral("PHFD_Unknow");
|
||||
}
|
||||
|
||||
|
||||
// Maximaler Winkel fuer untere Winkelgruppe
|
||||
static double maxAngleUW = 45.0;
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// class ExplosionsEditAdler
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ExplosionsEditAdler::ExplosionsEditAdler(const QString &menuGroup, QWidget *parent)
|
||||
: BaseEdit(menuGroup, QStringLiteral("ExplosionsEditAdler"), parent)
|
||||
@@ -86,11 +95,11 @@ ExplosionsEditAdler::ExplosionsEditAdler(const QString &menuGroup, QWidget *pare
|
||||
m_geometrieButtonGroup->addButton(m_ui->geometrieRadialBtn, static_cast<int>(AreaEffectSimulation::AesExplosionGeometry_def::EgRadial));
|
||||
m_geometrieButtonGroup->setExclusive(true);
|
||||
|
||||
m_gearClassFilter = {ProjectDataManagement::GearClass::GearClass_Artillery, ProjectDataManagement::GearClass::GearClass_Mortar};
|
||||
m_gearClassFilter = {ProjectDataManagement::GearClass::Artillery, ProjectDataManagement::GearClass::Mortar};
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableRocket = ps->value(QStringLiteral("aes"), QStringLiteral("enableRocket"), false).toBool();
|
||||
if (enableRocket)
|
||||
m_gearClassFilter += ProjectDataManagement::GearClass::GearClass_Rocket;
|
||||
m_gearClassFilter += ProjectDataManagement::GearClass::Rocket;
|
||||
|
||||
m_uiRequirements->addRequirement(
|
||||
{m_ui->lbxActors,
|
||||
@@ -98,21 +107,21 @@ ExplosionsEditAdler::ExplosionsEditAdler(const QString &menuGroup, QWidget *pare
|
||||
|
||||
connect(m_ui->pbClear, &QPushButton::clicked, m_ui->positionEdit, &LtsCoordWidget::LtsCoordWidget::clear);
|
||||
|
||||
|
||||
// "Einschießen" is hidden for now
|
||||
m_ui->lblFire->hide();
|
||||
m_ui->einschlJaBtn->hide();
|
||||
m_ui->einschlNoBtn->hide();
|
||||
|
||||
|
||||
// "Wirkungsfeuer" is hidden for now
|
||||
m_ui->lblFire_2->hide();
|
||||
m_ui->wirkungJaBtn->hide();
|
||||
m_ui->wirkungNoBtn->hide();
|
||||
|
||||
|
||||
|
||||
// DMF EffectMarkingInTa hide currently always true
|
||||
// m_ui->cbEffectMarkingInTa->hide();
|
||||
|
||||
m_ui->rbAngleGroupLower->setChecked(true);
|
||||
|
||||
// disable Tab Additional/Charge for now
|
||||
m_ui->tabWidget->setTabEnabled(1, false);
|
||||
m_ui->tabWidget->setTabEnabled(2, false);
|
||||
|
||||
@@ -121,8 +130,9 @@ ExplosionsEditAdler::ExplosionsEditAdler(const QString &menuGroup, QWidget *pare
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \brief ExplosionsEditAdler::~ExplosionsEditAdler
|
||||
*/
|
||||
ExplosionsEditAdler::~ExplosionsEditAdler()
|
||||
{
|
||||
if (m_sitMapGuiIfc)
|
||||
@@ -130,8 +140,12 @@ ExplosionsEditAdler::~ExplosionsEditAdler()
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \brief AreaEffectSimulation::ExplosionsEditAdler::init
|
||||
* \param aesItemId
|
||||
* \param session
|
||||
* \return
|
||||
*/
|
||||
bool ExplosionsEditAdler::init(int aesItemId, bool copy, LtsSession::LtsSession *session)
|
||||
{
|
||||
|
||||
@@ -146,7 +160,7 @@ bool ExplosionsEditAdler::init(int aesItemId, bool copy, LtsSession::LtsSession
|
||||
if (!session->getForeignGuiInterface(m_esmActorCbx))
|
||||
return false;
|
||||
|
||||
|
||||
// P _D_ M
|
||||
if (!m_session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << " failed to get pdmDtc";
|
||||
@@ -162,7 +176,7 @@ bool ExplosionsEditAdler::init(int aesItemId, bool copy, LtsSession::LtsSession
|
||||
m_dtc->waitForHistoricalDataExplosionCluster(1000);
|
||||
m_ftc->enableAcknowledgeExternalAesItem();
|
||||
|
||||
|
||||
// P _P_ M
|
||||
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << " failed to get ppmDtc";
|
||||
@@ -177,7 +191,7 @@ bool ExplosionsEditAdler::init(int aesItemId, bool copy, LtsSession::LtsSession
|
||||
setEffectClusterData(ecData);
|
||||
|
||||
setPbStateChangeName();
|
||||
m_ui->gbEffectMarkingInTa->setChecked(m_aesItem.effectMarkingInTa());
|
||||
m_ui->gbEffectMarkingInTa->setChecked(m_aesItem.effectMarkingInTa()); // always true for explosion cluster
|
||||
}
|
||||
|
||||
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::effectClusterChanged, this, &ExplosionsEditAdler::onEffectClusterChanged, Qt::UniqueConnection);
|
||||
@@ -196,11 +210,12 @@ bool ExplosionsEditAdler::init(int aesItemId, bool copy, LtsSession::LtsSession
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \brief ExplosionsEditAdlerStandAlone::showPreviewObject
|
||||
*/
|
||||
void ExplosionsEditAdler::showPreviewObject()
|
||||
{
|
||||
if (!has2DMap(false))
|
||||
if (!has2DMap(false)) // showMsgBoxIfNot2D
|
||||
return;
|
||||
|
||||
switch (m_currentGeometry.underlying())
|
||||
@@ -232,16 +247,16 @@ void ExplosionsEditAdler::showPreviewObject()
|
||||
|
||||
bool ExplosionsEditAdler::isDataSufficiant()
|
||||
{
|
||||
|
||||
// identifier:
|
||||
if (m_ui->lblZpNumber->text().isEmpty())
|
||||
return false;
|
||||
|
||||
|
||||
// originator:
|
||||
bool hasParticipant = !m_ui->lblParticipantUnits->text().isEmpty();
|
||||
if (!hasParticipant)
|
||||
return false;
|
||||
|
||||
|
||||
// target:
|
||||
bool bHasTargetArea = !m_coord.isNull();
|
||||
switch (m_currentGeometry.underlying())
|
||||
{
|
||||
@@ -255,7 +270,7 @@ bool ExplosionsEditAdler::isDataSufficiant()
|
||||
if (!bHasTargetArea)
|
||||
return false;
|
||||
|
||||
|
||||
// ammo
|
||||
const bool bHasAmmo = !m_ui->lblChargeType->text().isEmpty();
|
||||
if (!bHasAmmo)
|
||||
return false;
|
||||
@@ -285,7 +300,7 @@ void ExplosionsEditAdler::setEffectClusterData(const EffectCluster &ecData)
|
||||
|
||||
m_ui->dteEffectStart->setMsecsSinceEpoch(effectStart);
|
||||
|
||||
|
||||
// Geometry/Area
|
||||
const AreaEffectSimulation::AesExplosionGeometry_def::type geometryType = ecData.explosionGeometry().underlying();
|
||||
switch (geometryType)
|
||||
{
|
||||
@@ -305,24 +320,24 @@ void ExplosionsEditAdler::setEffectClusterData(const EffectCluster &ecData)
|
||||
m_ui->geometrieRadialBtn->setChecked(true);
|
||||
break;
|
||||
default:
|
||||
|
||||
// empty
|
||||
break;
|
||||
}
|
||||
} // switch
|
||||
|
||||
if (ecData.effectDuration() == DEFAULT_EFFECT_DURATION)
|
||||
m_ui->lblDuration->setText(QStringLiteral("---"));
|
||||
else
|
||||
m_ui->lblDuration->setText(QString::number(ecData.effectDuration() / 1000));
|
||||
m_ui->lblDuration->setText(QString::number(ecData.effectDuration() / 1000)); // msecs -> secs
|
||||
|
||||
|
||||
// 1st GearClass
|
||||
ProjectDataManagement::GearClass gc = m_pdmDtc->gearClassFromChargeTypeId(ecData.chargeStruct().chargeTypeId());
|
||||
m_ui->lblGearClass->setText(ProjectDataManagement::toString(gc));
|
||||
|
||||
|
||||
// 2nd Party
|
||||
if (ecData.partyId().is_set())
|
||||
m_ui->lblParty->setText(ParticipantManagement::trPartyName(m_ppmDtc->party(ecData.partyId().get()).name()));
|
||||
|
||||
|
||||
// 3rd Originator
|
||||
if (ecData.participantId().is_set())
|
||||
m_ui->lblParticipantUnits->setText(QString::fromStdString(m_ppmDtc->participant(ecData.participantId().get()).name()));
|
||||
|
||||
@@ -332,7 +347,7 @@ void ExplosionsEditAdler::setEffectClusterData(const EffectCluster &ecData)
|
||||
|
||||
int impactCount = 0;
|
||||
|
||||
|
||||
// delete existing widgets
|
||||
QLayoutItem *item = nullptr;
|
||||
while((item = m_ui->layoutEffectors->takeAt(0)) != nullptr)
|
||||
{
|
||||
@@ -350,7 +365,7 @@ void ExplosionsEditAdler::setEffectClusterData(const EffectCluster &ecData)
|
||||
m_ui->lblCannons->setText(QString::number(impactCount));
|
||||
m_ui->lblFirePurpose->setText(m_pdmDtc->trFirePurposeName(ecData.firePurposeId()));
|
||||
|
||||
m_ui->lblZog->setText(QString::number(ecData.tla()));
|
||||
m_ui->lblZog->setText(QString::number(ecData.tla())); // tla == zog
|
||||
|
||||
const AreaEffectSimulation::Area &areaRef = ecData.area();
|
||||
const QPointF bottomLeft(areaRef.cornerBottomLeft().lon(), areaRef.cornerBottomLeft().lat());
|
||||
@@ -387,7 +402,7 @@ void ExplosionsEditAdler::setEffectClusterData(const EffectCluster &ecData)
|
||||
if (ecData.effectors().size())
|
||||
setOWUWFromTrajectory(ecData.effectors().at(0).trajectoryRelative());
|
||||
|
||||
|
||||
// enable second Actor if possible
|
||||
const int amountFireMarker = m_pdmDtc->getAmountFireMarkers(ecData.firePurposeId());
|
||||
m_ui->cbActors_2->setEnabled(amountFireMarker > 1);
|
||||
|
||||
@@ -408,8 +423,10 @@ void ExplosionsEditAdler::setEffector(int participantId, const AreaEffectSimulat
|
||||
m_effectorNumber++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \brief ExplosionsEditAdler::dialogIdentifier
|
||||
* \return
|
||||
*/
|
||||
QString ExplosionsEditAdler::dialogIdentifier() const
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "dialogIdentifier";
|
||||
@@ -445,7 +462,7 @@ void ExplosionsEditAdler::onEffectClusterChanged(const EffectCluster &ecData, Da
|
||||
if (m_effectClusterData.effectDuration() == DEFAULT_EFFECT_DURATION)
|
||||
m_ui->lblDuration->setText(QStringLiteral("---"));
|
||||
else
|
||||
m_ui->lblDuration->setText(QString::number(m_effectClusterData.effectDuration() / 1000));
|
||||
m_ui->lblDuration->setText(QString::number(m_effectClusterData.effectDuration() / 1000)); // msec -> sec
|
||||
|
||||
enableUiElements();
|
||||
if (unchangeable())
|
||||
@@ -453,6 +470,8 @@ void ExplosionsEditAdler::onEffectClusterChanged(const EffectCluster &ecData, Da
|
||||
m_ui->pbStateChange->setEnabled(false);
|
||||
m_ui->gbEffectMarkingInTa->setEnabled(false);
|
||||
}
|
||||
|
||||
__unchange__();
|
||||
}
|
||||
|
||||
QPointF ExplosionsEditAdler::centerOfFiringUnitGeo(int particpantUnitId)
|
||||
@@ -467,7 +486,7 @@ QPointF ExplosionsEditAdler::centerOfFiringUnitGeo(int particpantUnitId)
|
||||
const LtsUtils::QPoint3D ¢erCoordGeo = Polygons::calculateFiringUnitCenterNonRecursive(m_ppmDtc, particpantUnitId, singlePositionsOut_unused, m_logger);
|
||||
if (centerCoordGeo.isNull() || std::isnan(centerCoordGeo.x()))
|
||||
{
|
||||
|
||||
// may happen in real life: so WARNING_LOG to DEBUG_LOG
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " calculateFiringUnitCenterNonRecursive failed, particpantUnitId = " << particpantUnitId;
|
||||
return {};
|
||||
}
|
||||
@@ -499,11 +518,12 @@ void ExplosionsEditAdler::showCenterOfFiringUnit(int particpantUnitId)
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " END particpantUnitId: " << particpantUnitId;
|
||||
m_sitMapGuiIfc->objectIndicatorToPoint(centerFiringUnitGeo);
|
||||
m_sitMapGuiIfc->objectIndicatorToPoint(centerFiringUnitGeo); // you can provide a duration: lifetimeMsec = -1
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \brief ExplosionsEditAdler::retranslate
|
||||
*/
|
||||
void ExplosionsEditAdler::retranslate()
|
||||
{
|
||||
QString title = tr("ADLER Artillery");
|
||||
@@ -542,13 +562,15 @@ void ExplosionsEditAdler::enableUiElements(bool enable)
|
||||
m_ui->pbStateChange->setEnabled(m_effectClusterData.effectorState() != AreaEffectSimulation::AesEffectorState::EsReadyToFire);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \brief ExplosionsEditAdler::apply
|
||||
* \return
|
||||
*/
|
||||
bool ExplosionsEditAdler::apply()
|
||||
{
|
||||
|
||||
int esmParticipantId1 = m_ui->cbActors->currentData().toInt();
|
||||
int esmParticipantId2 = m_ui->cbActors_2->currentData().toInt();
|
||||
// DMF (Actors)
|
||||
int esmParticipantId1 = m_ui->cbActors->currentData().toInt(); // participant ID
|
||||
int esmParticipantId2 = m_ui->cbActors_2->currentData().toInt(); // participant ID
|
||||
|
||||
EffectClusterModifyActorRequest request;
|
||||
request.aesId(m_aesItem.id());
|
||||
@@ -568,7 +590,7 @@ bool ExplosionsEditAdler::apply()
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
//
|
||||
void ExplosionsEditAdler::setPbStateChangeName()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onPbStateChangeName: AesEffectState: " << m_aesItem.effectStateId();
|
||||
@@ -599,7 +621,7 @@ void ExplosionsEditAdler::onPbStateChangeClicked()
|
||||
if (m_ui->gbEffectMarkingInTa->isChecked())
|
||||
apply();
|
||||
|
||||
|
||||
// Re-Enable PB, so we can call it another time, if it does not react...
|
||||
QTimer::singleShot(2000, [this]() { m_ui->pbStateChange->setEnabled(m_effectClusterData.effectorState() != AreaEffectSimulation::AesEffectorState::EsReadyToFire); });
|
||||
|
||||
if (m_aesItem.effectStateId() == AesEffectState_def::EsReceived)
|
||||
@@ -648,8 +670,8 @@ void ExplosionsEditAdler::onEffectorChanged(const AreaEffectSimulation::Effector
|
||||
|
||||
bool ExplosionsEditAdler::isOnlyNameModifiable() const
|
||||
{
|
||||
|
||||
|
||||
// BaseClass::isOnlyNameModifiable() -> EsPaused || EsActivated
|
||||
// m_effectClusterData.isObjectModifiable -> since PreStart and s_calculationOffsetMSec
|
||||
const bool ret = BaseClass::isOnlyNameModifiable() || !m_effectClusterData.isObjectModifiable();
|
||||
return ret;
|
||||
}
|
||||
@@ -658,7 +680,7 @@ void ExplosionsEditAdler::resetTempAndAnnotationStr()
|
||||
{
|
||||
INFO_LOG(m_logger) << " RESET resetTempAndAnnotationStr";
|
||||
m_temporaryData.reset();
|
||||
|
||||
// updateAnnotationStr();
|
||||
}
|
||||
|
||||
void ExplosionsEditAdler::addAnnotationStr(const QString &newAnno)
|
||||
@@ -740,4 +762,4 @@ void ExplosionsEditAdler::setEffectClusterDataFromJson(const std::string &proper
|
||||
m_ui->lblFiringType->setText(AreaEffectSimulation::toString(firingType));
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
+537
-378
File diff suppressed because it is too large.
Load diff
+31
-23
@@ -1,18 +1,24 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Namespace for rocket related functions
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Fritsche, ESZS, 2026-06-03
|
||||
*/
|
||||
|
||||
#include "aes_rocket_utility.h"
|
||||
|
||||
#include <QtWidgets/QComboBox>
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QtGui/QStandardItemModel>
|
||||
#include <QComboBox>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
#include <AreaEffectSimulation/aes.hpp>
|
||||
#include <AreaEffectSimulation/Trajectory/trajectory_generator.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <LtsUtils/LtsUtilsCore/qpoint3d.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <ProjectDataManagement/pdm_enums.hpp>
|
||||
#include <Proxies/TrainingAreaBase/Plugins/AdlerJson/telegrams.h>
|
||||
|
||||
@@ -41,7 +47,7 @@ void enaDisaWirkmittel(QComboBox *wirkmittelCombobox, AesExplosionGeometry::type
|
||||
const QVariant currentData = wirkmittelCombobox->itemData(indexCounter);
|
||||
const ProjectDataManagement::GearClass::type currentGearClass = static_cast<ProjectDataManagement::GearClass::type>(currentData.toInt());
|
||||
|
||||
if (currentGearClass == ProjectDataManagement::GearClass::GearClass_Rocket)
|
||||
if (currentGearClass == ProjectDataManagement::GearClass::Rocket)
|
||||
{
|
||||
QStandardItem *item = cboModel->item(indexCounter);
|
||||
|
||||
@@ -50,7 +56,7 @@ void enaDisaWirkmittel(QComboBox *wirkmittelCombobox, AesExplosionGeometry::type
|
||||
|
||||
item->setFlags(item->flags() | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||
|
||||
|
||||
// we do not break the loop here because there may be more rocket wirkmittel in the future
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -64,7 +70,7 @@ void enaDisaWirkmittel(QComboBox *wirkmittelCombobox, AesExplosionGeometry::type
|
||||
const QVariant currentData = wirkmittelCombobox->itemData(indexCounter);
|
||||
const ProjectDataManagement::GearClass::type currentGearClass = static_cast<ProjectDataManagement::GearClass::type>(currentData.toInt());
|
||||
|
||||
if (currentGearClass == ProjectDataManagement::GearClass::GearClass_Rocket)
|
||||
if (currentGearClass == ProjectDataManagement::GearClass::Rocket)
|
||||
{
|
||||
QStandardItem *item = cboModel->item(indexCounter);
|
||||
|
||||
@@ -73,14 +79,14 @@ void enaDisaWirkmittel(QComboBox *wirkmittelCombobox, AesExplosionGeometry::type
|
||||
|
||||
item->setFlags(item->flags() & ~Qt::ItemIsEnabled & ~Qt::ItemIsSelectable);
|
||||
|
||||
|
||||
// if rocket ist currently selected, we have to set another index
|
||||
if (indexCounter == currentIndex && wirkmittelCombobox->count() > 1)
|
||||
{
|
||||
const int newIndex = currentIndex == 0 ? 1 : 0;
|
||||
|
||||
wirkmittelCombobox->setCurrentIndex(newIndex);
|
||||
}
|
||||
|
||||
// we do not break the loop here because there may be more rocket wirkmittel in the future
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -132,18 +138,18 @@ void addRocketPropertiesForLinearGeometry(EffectClusterModifyRequest &request, c
|
||||
wirkmittel.geschoss.anzahl = currentEffector.chargeAmount();
|
||||
treffpunkt.anzahl = wirkmittel.geschoss.anzahl;
|
||||
|
||||
|
||||
// calculate local x
|
||||
double xLocal = request.area().width() * (static_cast<double>(mhpSliceCounter++) / (request.effectors().size() + 1));
|
||||
|
||||
|
||||
// transform local point to UTM
|
||||
const QPointF localPoint(xLocal, yLocal);
|
||||
const QPointF utmPoint = transform.map(localPoint);
|
||||
|
||||
|
||||
// tranform utm point to geographic WGS84 coordinate
|
||||
const UtmCoordinate currentUtm(areaBottomLeftUtm.zone, utmPoint.x(), utmPoint.y());
|
||||
const QPointF mhpGeo = currentUtm.geographic();
|
||||
|
||||
|
||||
// treffpunkt
|
||||
currentEffector.mhpPosition().lon(mhpGeo.x());
|
||||
currentEffector.mhpPosition().lat(mhpGeo.y());
|
||||
treffpunkt.koordinate.koordinate.longitude = currentEffector.mhpPosition().lon() * LtsCoordTrans::rad2deg();
|
||||
@@ -157,14 +163,14 @@ void addRocketPropertiesForLinearGeometry(EffectClusterModifyRequest &request, c
|
||||
|
||||
currentEffector.properties(QJsonDocument(wirkmittelObj).toJson().toStdString());
|
||||
|
||||
|
||||
// trajectory
|
||||
const ParticipantManagement::ParticipantPosition &participantPosition = ppmDtc->participantPosition(currentEffector.participantId());
|
||||
const LtsUtils::QPoint3D trajectoryStart(participantPosition.pos().lon(),
|
||||
participantPosition.pos().lat(),
|
||||
participantPosition.pos().z());
|
||||
const LtsUtils::QPoint3D trajectoryEnd(currentEffector.mhpPosition().lon(),
|
||||
currentEffector.mhpPosition().lat(),
|
||||
currentEffector.mhpPosition().z());
|
||||
currentEffector.mhpPosition().z()); // TODO
|
||||
TrajectoryGeoPosition trajectoryWithoutTime;
|
||||
|
||||
TrajectoryGenerator::getInstance()->generateTrajectoryBiedziak(trajectoryStart, trajectoryEnd, 45.0, trajectoryWithoutTime);
|
||||
@@ -173,6 +179,7 @@ void addRocketPropertiesForLinearGeometry(EffectClusterModifyRequest &request, c
|
||||
const double flightTimeStep = currentEffector.flightTime() / static_cast<double>(trajectoryWithoutTime.size());
|
||||
double currentFlightTime = 0.0;
|
||||
|
||||
currentEffector.trajectoryRelative().clear(); // LS_711_akkumulierende_flugkurven_bei_rakete
|
||||
const LtsCoordTrans::UtmCoordinate utmStartPos = LtsCoordTrans::UtmCoordinate::fromGeographic(participantPosition.pos().lon(), participantPosition.pos().lat());
|
||||
for (const Core::GeoPosition &pos : trajectoryWithoutTime)
|
||||
{
|
||||
@@ -204,7 +211,7 @@ void addRocketPropertiesForPointGeometry(EffectClusterModifyRequest &request, co
|
||||
wirkmittel.geschoss.anzahl = currentEffector.chargeAmount();
|
||||
treffpunkt.anzahl = wirkmittel.geschoss.anzahl;
|
||||
|
||||
|
||||
// treffpunkt
|
||||
currentEffector.mhpPosition().lon(areaCenterGeo.x());
|
||||
currentEffector.mhpPosition().lat(areaCenterGeo.y());
|
||||
treffpunkt.koordinate.koordinate.longitude = currentEffector.mhpPosition().lon() * LtsCoordTrans::rad2deg();
|
||||
@@ -218,7 +225,7 @@ void addRocketPropertiesForPointGeometry(EffectClusterModifyRequest &request, co
|
||||
|
||||
currentEffector.properties(QJsonDocument(wirkmittelObj).toJson().toStdString());
|
||||
|
||||
|
||||
// trajectory
|
||||
const ParticipantManagement::ParticipantPosition &participantPosition = ppmDtc->participantPosition(currentEffector.participantId());
|
||||
const LtsUtils::QPoint3D trajectoryStart(participantPosition.pos().lon(),
|
||||
participantPosition.pos().lat(),
|
||||
@@ -234,6 +241,7 @@ void addRocketPropertiesForPointGeometry(EffectClusterModifyRequest &request, co
|
||||
const double flightTimeStep = currentEffector.flightTime() / static_cast<double>(trajectoryWithoutTime.size());
|
||||
double currentFlightTime = 0.0;
|
||||
|
||||
currentEffector.trajectoryRelative().clear(); // LS_711_akkumulierende_flugkurven_bei_rakete
|
||||
const LtsCoordTrans::UtmCoordinate utmStartPos = LtsCoordTrans::UtmCoordinate::fromGeographic(participantPosition.pos().lon(), participantPosition.pos().lat());
|
||||
for (const Core::GeoPosition &pos : trajectoryWithoutTime)
|
||||
{
|
||||
@@ -244,8 +252,8 @@ void addRocketPropertiesForPointGeometry(EffectClusterModifyRequest &request, co
|
||||
|
||||
currentFlightTime += flightTimeStep;
|
||||
}
|
||||
}
|
||||
} // for (EffectorData ¤tEffector : request.effectors())
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace RocketUtility
|
||||
} // namespace AreaEffectSimulation
|
||||
+181
-141
@@ -1,224 +1,264 @@
|
||||
#include "flm_hq_report_converter.h"
|
||||
|
||||
#include <AreaEffectSimulation/Utils/polygons.h>
|
||||
#include <flm_data_plugin_interface.h>
|
||||
#include <Lts/Services/FileManagement/flm_ftc.h>
|
||||
#include <FileManagement/flm_data_plugin_interface.h>
|
||||
#include <FileManagement/flm_ftc.h>
|
||||
#include <FileManagement/flm_ftc_types.h>
|
||||
#include <GeometryModel/geometry_model_factory.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtils/LtsUtilsCore/dds_vector.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
#include <Symbology/sidc_builder_base.h>
|
||||
#include <Symbology/sidc_codec.h>
|
||||
#include <Symbology/symbol_dictionary.h>
|
||||
#include <SymbologyXML/symbol_types.h>
|
||||
|
||||
#include <GeometryModel/geometry_model_factory.h>
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsCore/dds_vector.h>
|
||||
|
||||
#include <AreaEffectSimulation/Utils/polygons.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
|
||||
FlmHqReportConverter::FlmHqReportConverter() : m_logger(getLogger("HQReportConverter"))
|
||||
FlmHqReportConverter::FlmHqReportConverter()
|
||||
: m_logger(getLogger("HQReportConverter"))
|
||||
{
|
||||
connect(this, &FlmHqReportConverter::allRequestsFinished, this, &FlmHqReportConverter::onRequestsFinished);
|
||||
connect(this, &FlmHqReportConverter::allRequestsFinished, this, &FlmHqReportConverter::onRequestsFinished);
|
||||
}
|
||||
|
||||
bool FlmHqReportConverter::init(LtsSession::LtsSession* session, int currentPartyId)
|
||||
bool FlmHqReportConverter::init(LtsSession::LtsSession *session, int currentPartyId)
|
||||
{
|
||||
if (session == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got invalid session";
|
||||
if (session == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got invalid session";
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
m_session = session;
|
||||
m_session = session;
|
||||
|
||||
if (!m_session->getDtc<DataInterface>(m_flmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Dtc.";
|
||||
if (!m_session->getDtc<DataInterface>(m_flmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Dtc.";
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_session->getFtc<DataInterface>(m_flmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Ftc.";
|
||||
if (!m_session->getFtc<DataInterface>(m_flmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Ftc.";
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get PPM Dtc.";
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get PPM Dtc.";
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_flmFtc->enableFileContentModify())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could enable fileContentModify.";
|
||||
if (!m_flmFtc->enableFileContentModify())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could enable fileContentModify.";
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
m_flmDtc->enableFileContent();
|
||||
m_flmDtc->enableFolder();
|
||||
m_flmDtc->enableFileContent();
|
||||
m_flmDtc->enableFolder();
|
||||
|
||||
if (m_geometryModel != nullptr)
|
||||
{
|
||||
delete m_geometryModel;
|
||||
m_geometryModel = nullptr;
|
||||
}
|
||||
if (m_geometryModel != nullptr)
|
||||
{
|
||||
delete m_geometryModel;
|
||||
m_geometryModel = nullptr;
|
||||
}
|
||||
|
||||
m_geometryModel = SituationMap::GeometryModelFactory::singleton()->create();
|
||||
m_geometryModel = SituationMap::GeometryModelFactory::singleton()->create();
|
||||
|
||||
m_partyId = currentPartyId;
|
||||
m_partyId = currentPartyId;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::addHqToPlanIds(const QMap<int, QList<int>>& hqToPlanIds)
|
||||
void FlmHqReportConverter::addHqToPlanIds(const QMap<int, QSet<int>> &hqToPlanIds)
|
||||
{
|
||||
for (auto it = hqToPlanIds.constBegin(); it != hqToPlanIds.constEnd(); ++it)
|
||||
for (auto it = hqToPlanIds.constBegin(); it != hqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
int planFileId = it.key();
|
||||
const QSet<int> &hqMessageIds = it.value();
|
||||
|
||||
for (int id : hqMessageIds)
|
||||
{
|
||||
m_hqToPlanIds[it.key()].append(it.value());
|
||||
if (id == planFileId) // Eventueller Eintrag in Map wegen QTreeView verhindern
|
||||
continue;
|
||||
|
||||
m_hqToPlanIds[planFileId].append(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::processCollectedHqs()
|
||||
{
|
||||
for (auto it = m_hqToPlanIds.constBegin(); it != m_hqToPlanIds.constEnd(); ++it)
|
||||
for (auto it = m_hqToPlanIds.constBegin(); it != m_hqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
int planId = it.key();
|
||||
for (int id : it.value())
|
||||
m_pendingRequests++;
|
||||
}
|
||||
|
||||
for (auto it = m_hqToPlanIds.constBegin(); it != m_hqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
int planId = it.key();
|
||||
const QList<int> &hqMessageIds = it.value();
|
||||
|
||||
for (int id : hqMessageIds)
|
||||
{
|
||||
m_pendingRequests += it.value().size();
|
||||
}
|
||||
|
||||
for (auto it = m_hqToPlanIds.constBegin(); it != m_hqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
int planId = it.key();
|
||||
const QList<int>& reportIds = it.value();
|
||||
|
||||
for (int id : reportIds)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Request File with ID: " << id << " from plan with ID: " << planId;
|
||||
FileManagement::GetFileContentDataRequest request(id);
|
||||
m_flmFtc->getFileContentDataRequest(request, this);
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Request File with ID: " << id << " from plan with ID: " << planId;
|
||||
FileManagement::GetFileContentDataRequest request(id);
|
||||
m_flmFtc->getFileContentDataRequest(request, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::createGeometryFromReport(const HqReportData& data)
|
||||
{
|
||||
m_symbolFactory.build(data.art, data, m_geometryModel);
|
||||
}
|
||||
void FlmHqReportConverter::createGeometryFromReport(const HqReportData &data) { m_symbolFactory.build(data.art, data, m_geometryModel); }
|
||||
|
||||
void FlmHqReportConverter::checkIfAllFinished()
|
||||
{
|
||||
if (m_pendingRequests <= 0)
|
||||
emit allRequestsFinished();
|
||||
if (m_pendingRequests <= 0)
|
||||
emit allRequestsFinished();
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::onGetFileContentDataReply(const FileManagement::GetFileContentDataReply& reply)
|
||||
void FlmHqReportConverter::onGetFileContentDataReply(const FileManagement::GetFileContentDataReply &reply)
|
||||
{
|
||||
m_pendingRequests--;
|
||||
m_pendingRequests--;
|
||||
|
||||
if (reply.errorString().size() > 0)
|
||||
const int id = static_cast<int>(reply.id());
|
||||
int planId = -1;
|
||||
|
||||
for (auto it = m_hqToPlanIds.constBegin(); it != m_hqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
if (it.value().contains(id))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got onGetFileContentDataReply error: " << reply.errorString();
|
||||
return;
|
||||
planId = it.key();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int id = static_cast<int>(reply.id());
|
||||
int planId = -1;
|
||||
DEBUG_LOG(m_logger) << "Reply File with ID: " << id << " from plan with ID: " << planId;
|
||||
INFO_LOG(m_logger) << "Got reply with id " << id;
|
||||
|
||||
DEBUG_LOG(m_logger) << "Reply File with ID: " << id << " from plan with ID: " << planId;
|
||||
QByteArray fileContent = QByteArray::fromRawData(reinterpret_cast<const char *>(reply.content().data()), reply.content().size());
|
||||
|
||||
INFO_LOG(m_logger) << "Got reply with id " << id << " and errorString " << reply.errorString();
|
||||
DEBUG_LOG(m_logger) << "fileContent: " << fileContent;
|
||||
|
||||
QByteArray fileContent = QByteArray(reinterpret_cast<const char*>(reply.content().data()), reply.content().size());
|
||||
FileManagement::FileContent flc = m_flmDtc->fileContent(reply.id());
|
||||
|
||||
FlmHqReportJsonParser m_parser = FlmHqReportJsonParser();
|
||||
DEBUG_LOG(m_logger) << "FlmHqReportConverter::onGetFileContentDataReply FILECONTENTNAME: " << flc.name();
|
||||
|
||||
HqReportData data = m_parser.parse(fileContent);
|
||||
data.contentFileId = id;
|
||||
HqReportData data = m_parser.parse(fileContent);
|
||||
data.contentFileId = id;
|
||||
data.name = QString::fromStdString(flc.name());
|
||||
|
||||
DEBUG_LOG(m_logger) << "Party: " << m_partyId
|
||||
<< " has Color: " << QColor::fromRgb(QRgb(m_ppmDtc->party(m_partyId).color())).value();
|
||||
data.partyColor = QColor::fromRgb(m_ppmDtc->party(m_partyId).color());
|
||||
|
||||
data.partyColor = QColor::fromRgb(QRgb(m_ppmDtc->party(m_partyId).color()));
|
||||
m_convertedHqToPlanIds[planId].append(std::move(data));
|
||||
|
||||
for (auto it = m_hqToPlanIds.constBegin(); it != m_hqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
if (it.value().contains(id))
|
||||
{
|
||||
planId = it.key();
|
||||
break;
|
||||
}
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Content size: " << reply.content().size();
|
||||
|
||||
m_convertedHqToPlanIds[planId].append(data);
|
||||
|
||||
DEBUG_LOG(m_logger) << "Content size: " << reply.content().size();
|
||||
|
||||
checkIfAllFinished();
|
||||
checkIfAllFinished();
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::onFileContentModifyReply(const Core::FunctionReplyObject& reply)
|
||||
void FlmHqReportConverter::onFileContentModifyReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Got FileContentModify Reply: " << reply.translated();
|
||||
DEBUG_LOG(m_logger) << "Got FileContentModify Reply: " << reply.translated();
|
||||
|
||||
if (reply.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error while insert HX Message: " << reply.translated() << ", error: " << reply.error();
|
||||
}
|
||||
if (reply.error())
|
||||
ERROR_LOG(m_logger) << "Error while insert HX Message: " << reply.translated() << ", error: " << reply.error();
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::onFileContentRemoveReply(const Core::FunctionReplyObject& reply)
|
||||
void FlmHqReportConverter::onFileContentRemoveReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Got FileContentRemove Reply: " << reply.translated();
|
||||
DEBUG_LOG(m_logger) << "Got FileContentRemove Reply: " << reply.translated();
|
||||
|
||||
if (reply.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error while insert HX Message: " << reply.translated() << ", error: " << reply.error();
|
||||
}
|
||||
if (reply.error())
|
||||
ERROR_LOG(m_logger) << "Error while insert HX Message: " << reply.translated() << ", error: " << reply.error();
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::onRequestsFinished()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "ALL REQUESTS FINISHED";
|
||||
DEBUG_LOG(m_logger) << "ALL REQUESTS FINISHED -> STARTING CONTENT FETCH";
|
||||
|
||||
for (auto it = m_convertedHqToPlanIds.constBegin(); it != m_convertedHqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
int planId = it.key();
|
||||
const QList<HqReportData>& reportDatas = it.value();
|
||||
for (auto it = m_convertedHqToPlanIds.constBegin(); it != m_convertedHqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
int planId = it.key();
|
||||
QList<HqReportData> reportDatas = it.value();
|
||||
const FileManagement::FileContent flc = m_flmDtc->fileContent(planId);
|
||||
FileManagement::GetFileContentDataRequest req;
|
||||
req.fileContentId(planId);
|
||||
|
||||
for (auto& reportData : reportDatas)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "createGeometryFromReport :" << reportData.art;
|
||||
createGeometryFromReport(reportData);
|
||||
}
|
||||
m_flmFtc->getFileContentDataRequest(req,
|
||||
[this, planId, reportDatas = std::move(reportDatas), flc = std::move(flc)](const FileManagement::GetFileContentDataReply &reply)
|
||||
{
|
||||
const auto &fetchedFlc = reply;
|
||||
if (fetchedFlc.content().size() > 0)
|
||||
{
|
||||
QByteArray existingContent
|
||||
= QByteArray::fromRawData(reinterpret_cast<const char *>(fetchedFlc.content().data()), fetchedFlc.content().size());
|
||||
|
||||
const FileManagement::FileContent& flc = m_flmDtc->fileContent(planId);
|
||||
if (!m_geometryModel->fromByteArray(existingContent))
|
||||
WARNING_LOG(m_logger) << "Could not load existing geometry content for planId" << planId;
|
||||
}
|
||||
|
||||
FileManagement::FileContentModifyRequest data;
|
||||
QJsonArray jsonNameArray;
|
||||
QJsonDocument existingDocs = QJsonDocument::fromJson(QByteArray::fromRawData(flc.properties().data(), flc.properties().size()));
|
||||
|
||||
DEBUG_LOG(m_logger) << "FILE CONTENT: " << flc.name() << " " << flc.folderId();
|
||||
if (existingDocs.isArray())
|
||||
jsonNameArray = existingDocs.array();
|
||||
|
||||
data.id(flc.id());
|
||||
data.name(flc.name());
|
||||
data.isTemplate(false);
|
||||
data.isHidden(false);
|
||||
data.folderId(flc.folderId());
|
||||
data.fileStatus(FileManagement::FileStatus::Valid);
|
||||
data.fileCategory(FileManagement::FileCategory::Exercise);
|
||||
data.fileType(FileManagement::FileType::TacticalPlan);
|
||||
data.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
data.lastModified(QDateTime::currentMSecsSinceEpoch());
|
||||
data.content(LtsUtils::convert<std::vector<uint8_t>>(m_geometryModel->toByteArray()));
|
||||
data.exerciseId(m_session->exerciseId());
|
||||
for (const auto &reportData : reportDatas)
|
||||
{
|
||||
|
||||
m_flmFtc->fileContentModifyRequest(data, this);
|
||||
bool alreadyExists = false;
|
||||
for (const QJsonValue &value : jsonNameArray)
|
||||
{
|
||||
if (value.toString() == reportData.name)
|
||||
{
|
||||
alreadyExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_geometryModel->clearModel();
|
||||
}
|
||||
if (!alreadyExists)
|
||||
{
|
||||
createGeometryFromReport(reportData);
|
||||
jsonNameArray.append(reportData.name);
|
||||
}
|
||||
}
|
||||
|
||||
QJsonDocument jsonDoc(jsonNameArray);
|
||||
QString combinedNames = QString::fromUtf8(jsonDoc.toJson(QJsonDocument::Compact));
|
||||
|
||||
FileManagement::FileContentModifyRequest data;
|
||||
|
||||
DEBUG_LOG(m_logger) << "FILE CONTENT: " << flc.name() << " " << flc.folderId();
|
||||
|
||||
data.id(flc.id());
|
||||
data.name(flc.name());
|
||||
data.isTemplate(false);
|
||||
data.isHidden(false);
|
||||
data.folderId(flc.folderId());
|
||||
data.fileStatus(FileManagement::FileStatus::Valid);
|
||||
data.fileCategory(FileManagement::FileCategory::Exercise);
|
||||
data.fileType(FileManagement::FileType::TacticalPlan);
|
||||
data.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
data.lastModified(QDateTime::currentMSecsSinceEpoch());
|
||||
data.content(LtsUtils::convert<std::vector<uint8_t>>(m_geometryModel->toByteArray()));
|
||||
data.exerciseId(m_session->exerciseId());
|
||||
data.properties(combinedNames.toStdString());
|
||||
m_flmFtc->fileContentModifyRequest(data, this);
|
||||
m_geometryModel->clearModel();
|
||||
});
|
||||
}
|
||||
}
|
||||
} // namespace FileManagement
|
||||
+50
-39
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
#include <FileManagement/logger.h>
|
||||
#include <GeometryModel/geometry_model.h>
|
||||
|
||||
#include "flm_hq_report_json_parser.h"
|
||||
#include "flm_hq_report_symbol_factory.h"
|
||||
|
||||
#include <Lts/Services/FileManagement/logger.h>
|
||||
#include <GeometryModel/geometry_model.h>
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
@@ -18,53 +18,64 @@ class Dtc;
|
||||
class Ftc;
|
||||
} // namespace Interface
|
||||
|
||||
class FlmHqReportConverter : public QObject,
|
||||
public Interface::Ftc::GetFileContentDataReplyHandler,
|
||||
public Interface::Ftc::FileContentModifyReplyHandler,
|
||||
public Interface::Ftc::FileContentRemoveReplyHandler
|
||||
class FlmHqReportConverter
|
||||
: public QObject
|
||||
, public Interface::Ftc::GetFileContentDataReplyHandler
|
||||
, public Interface::Ftc::FileContentModifyReplyHandler
|
||||
, public Interface::Ftc::FileContentRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
FlmHqReportConverter();
|
||||
~FlmHqReportConverter() = default;
|
||||
FlmHqReportConverter();
|
||||
~FlmHqReportConverter() = default;
|
||||
|
||||
bool init(LtsSession::LtsSession* session, int currentPartyId);
|
||||
|
||||
void addHqToPlanIds(const QMap<int, QList<int>>& hqToPlanIds);
|
||||
|
||||
void processCollectedHqs();
|
||||
|
||||
void createGeometryFromReport(const HqReportData& data);
|
||||
bool init(LtsSession::LtsSession *session, int currentPartyId);
|
||||
/**
|
||||
* @brief add hqToPlanIds to m_hqToPlanIds
|
||||
* @param const QMap<int, QList<int>> &hqToPlanIds -> <planId, QList<HqIds>>
|
||||
*/
|
||||
void addHqToPlanIds(const QMap<int, QSet<int>> &hqToPlanIds);
|
||||
/**
|
||||
* @brief Iterate and send GetFileContentDataRequest to get File Information HQ
|
||||
*/
|
||||
void processCollectedHqs();
|
||||
/**
|
||||
* @brief create GeometryModel from HQ Report
|
||||
* @param {data} HQ Report Data
|
||||
*/
|
||||
void createGeometryFromReport(const HqReportData &data);
|
||||
|
||||
private:
|
||||
void checkIfAllFinished();
|
||||
void checkIfAllFinished();
|
||||
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void onGetFileContentDataReply(const FileManagement::GetFileContentDataReply& reply) override;
|
||||
void onFileContentModifyReply(const Core::FunctionReplyObject& reply) override;
|
||||
void onFileContentRemoveReply(const Core::FunctionReplyObject& reply) override;
|
||||
void onGetFileContentDataReply(const FileManagement::GetFileContentDataReply &reply) override;
|
||||
void onFileContentModifyReply(const Core::FunctionReplyObject &reply) override;
|
||||
void onFileContentRemoveReply(const Core::FunctionReplyObject &reply) override;
|
||||
public slots:
|
||||
void onRequestsFinished();
|
||||
void onRequestsFinished();
|
||||
signals:
|
||||
|
||||
void allRequestsFinished();
|
||||
/**
|
||||
* @brief checks if all getFileContentDataRequests are finished
|
||||
*/
|
||||
void allRequestsFinished();
|
||||
|
||||
private:
|
||||
LtsSession::LtsSession* m_session{nullptr};
|
||||
std::shared_ptr<Interface::Dtc> m_flmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_flmFtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
LOGGER_T m_logger;
|
||||
LtsSession::LtsSession *m_session{nullptr};
|
||||
std::shared_ptr<Interface::Dtc> m_flmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_flmFtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
|
||||
SituationMap::GeometryModel* m_geometryModel{nullptr};
|
||||
QList<SituationMap::GeometryModel::Node> m_planNodes;
|
||||
SymbolFactory m_symbolFactory;
|
||||
SituationMap::GeometryModel *m_geometryModel{nullptr};
|
||||
QList<SituationMap::GeometryModel::Node> m_planNodes;
|
||||
SymbolFactory m_symbolFactory;
|
||||
|
||||
int m_partyId;
|
||||
int m_pendingRequests{0};
|
||||
|
||||
QMap<int, QList<int>> m_hqToPlanIds;
|
||||
QMap<int, int> m_hqToPlanIdsLookup;
|
||||
QMap<int, QList<HqReportData>> m_convertedHqToPlanIds;
|
||||
};
|
||||
int m_partyId;
|
||||
int m_pendingRequests{0};
|
||||
FlmHqReportJsonParser m_parser;
|
||||
QMap<int, QList<int>> m_hqToPlanIds; /// Map<planIds, QList<HQMessageId>>
|
||||
QMap<int, int> m_hqToPlanIdsLookup; /// Map<planIds, HQMessageId> for Lookup
|
||||
QMap<int, QList<HqReportData>> m_convertedHqToPlanIds; /// Map<planIds, QList<convertedHqMessage>>
|
||||
}; // class FlmHqReportConverter
|
||||
} // namespace FileManagement
|
||||
+254
-278
@@ -1,385 +1,361 @@
|
||||
#include "flm_hq_report_edit.h"
|
||||
|
||||
#include "flm_hq_report_model.h"
|
||||
#include "ui_flm_hq_report_edit.h"
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtils/LtsUtilsCore/dds_vector.h>
|
||||
#include <ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <flm_data_plugin_interface.h>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtWidgets/QInputDialog>
|
||||
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QInputDialog>
|
||||
|
||||
#include <SituationMap/GeometryModel/geometry_model.h>
|
||||
#include <SituationMap/GeometryModel/geometry_model_factory.h>
|
||||
|
||||
#include <LtsUtils/LtsUtilsCore/dds_vector.h>
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
|
||||
HQReportEdit::HQReportEdit(const QString& menuGroup, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel), m_ui(new Ui::HQReportEdit),
|
||||
m_menuGroup(menuGroup)
|
||||
HQReportEdit::HQReportEdit(const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ui(new Ui::HQReportEdit)
|
||||
, m_logger(getLogger("HQReportEdit"))
|
||||
, m_menuGroup(menuGroup)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Add)->setText(tr("New Plan"));
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &HQReportEdit::onCreateNewPlanClicked);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Add)->setText(tr("New Plan"));
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &HQReportEdit::onCreateNewPlanClicked);
|
||||
|
||||
connect(m_ui->pbShift, &QPushButton::clicked, this, &HQReportEdit::onShiftClicked);
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-HQReport"));
|
||||
connect(m_ui->pbShift, &QPushButton::clicked, this, &HQReportEdit::onShiftClicked);
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-HQReport"));
|
||||
}
|
||||
|
||||
HQReportEdit::~HQReportEdit()
|
||||
HQReportEdit::~HQReportEdit() { delete m_ui; }
|
||||
|
||||
bool HQReportEdit::init(LtsSession::LtsSession *session, int partyId)
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
if (session == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got invalid session";
|
||||
|
||||
bool HQReportEdit::init(LtsSession::LtsSession* session, int partyId)
|
||||
{
|
||||
if (session == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got invalid session";
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
m_session = session;
|
||||
|
||||
m_session = session;
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> partyCboInterface;
|
||||
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> partyCboInterface;
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(partyCboInterface))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get Party Combobox Interface.";
|
||||
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(partyCboInterface))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get Party Combobox Interface.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!partyCboInterface->fillPartyComboBox(m_ui->cboParties) || m_ui->cboParties->count() == 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not fill Parties.";
|
||||
|
||||
if (!partyCboInterface->fillPartyComboBox(m_ui->cboParties) || m_ui->cboParties->count() == 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not fill Parties.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getDtc<DataInterface>(m_flmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Dtc.";
|
||||
|
||||
if (!m_session->getDtc<DataInterface>(m_flmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Dtc.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getFtc<DataInterface>(m_flmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Ftc.";
|
||||
|
||||
if (!m_session->getFtc<DataInterface>(m_flmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Ftc.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!m_flmFtc->enableFileContentModify())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could enable fileContentModify.";
|
||||
|
||||
if (!m_flmFtc->enableFileContentModify())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could enable fileContentModify.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
// init models
|
||||
qDeleteAll(m_hqModels);
|
||||
m_hqModels.clear();
|
||||
|
||||
qDeleteAll(m_hqModels);
|
||||
m_hqModels.clear();
|
||||
qDeleteAll(m_planModels);
|
||||
m_planModels.clear();
|
||||
|
||||
qDeleteAll(m_planModels);
|
||||
m_planModels.clear();
|
||||
|
||||
for (int index = 0; index < m_ui->cboParties->count(); ++index)
|
||||
{
|
||||
const int partyId = m_ui->cboParties->itemData(index).toInt();
|
||||
const int partyFolderId = m_flmDtc->getPartyFolderId(m_session->exerciseId(), partyId);
|
||||
|
||||
FlmHQReportModel* planModel = new FlmHQReportModel(m_ui->listViewPlan);
|
||||
|
||||
if (!planModel->init(m_session, partyFolderId, FileType::inner_enum::TacticalPlan))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not init planModel for partyId " << partyId;
|
||||
|
||||
delete planModel;
|
||||
planModel = nullptr;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
const int hqReportFolderId = m_flmDtc->findFolder(partyFolderId, QStringLiteral("Messages"));
|
||||
|
||||
FlmHQReportModel* hqReportModel = new FlmHQReportModel(m_ui->listViewMessage);
|
||||
|
||||
if (!hqReportModel->init(m_session, hqReportFolderId, FileType::inner_enum::AdlerJson))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not init hqReportModel for partyId " << partyId;
|
||||
|
||||
delete planModel;
|
||||
planModel = nullptr;
|
||||
|
||||
delete hqReportModel;
|
||||
hqReportModel = nullptr;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
connect(planModel, &FlmHQReportModel::dataAddedOrRemoved, this, &HQReportEdit::slotChangesMade);
|
||||
|
||||
m_planModels.insert(partyId, planModel);
|
||||
m_hqModels.insert(partyId, hqReportModel);
|
||||
}
|
||||
|
||||
m_ui->listViewPlan->setDragDropMode(QAbstractItemView::DropOnly);
|
||||
m_ui->listViewPlan->setDefaultDropAction(Qt::CopyAction);
|
||||
m_ui->listViewPlan->setDropIndicatorShown(true);
|
||||
|
||||
m_ui->listViewMessage->setDragDropMode(QAbstractItemView::DragOnly);
|
||||
m_ui->listViewMessage->setDefaultDropAction(Qt::CopyAction);
|
||||
m_ui->listViewMessage->setDropIndicatorShown(true);
|
||||
|
||||
onPartyChanged();
|
||||
|
||||
if (!m_flmFtc->enableFileContentModify())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could enable fileContentModify.";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
qDeleteAll(m_hqModels);
|
||||
m_hqModels.clear();
|
||||
|
||||
qDeleteAll(m_planModels);
|
||||
m_planModels.clear();
|
||||
|
||||
for (int index = 0; index < m_ui->cboParties->count(); ++index)
|
||||
{
|
||||
const int partyId = m_ui->cboParties->itemData(index).toInt();
|
||||
createModels(partyId);
|
||||
}
|
||||
|
||||
m_ui->listViewPlan->setDragDropMode(QAbstractItemView::DropOnly);
|
||||
m_ui->listViewPlan->setDefaultDropAction(Qt::MoveAction);
|
||||
m_ui->listViewPlan->setDropIndicatorShown(true);
|
||||
|
||||
m_ui->listViewMessage->setDragDropMode(QAbstractItemView::DragOnly);
|
||||
m_ui->listViewMessage->setDefaultDropAction(Qt::MoveAction);
|
||||
m_ui->listViewMessage->setDropIndicatorShown(true);
|
||||
|
||||
onPartyChanged();
|
||||
|
||||
connect(m_ui->cboParties, qOverload<int>(&QComboBox::currentIndexChanged), this, &HQReportEdit::onPartyChanged);
|
||||
|
||||
int partyIndex = m_ui->cboParties->findData(partyId);
|
||||
m_ui->cboParties->setCurrentIndex(partyIndex < 0 ? 0 : partyIndex);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void HQReportEdit::createModels(const int partyId)
|
||||
{
|
||||
for (int index = 0; index < m_ui->cboParties->count(); ++index)
|
||||
{
|
||||
const int partyId = m_ui->cboParties->itemData(index).toInt();
|
||||
const int partyFolderId = m_flmDtc->getPartyFolderId(m_session->exerciseId(), partyId);
|
||||
if (partyFolderId == 0)
|
||||
|
||||
FlmHQReportModel *planModel = new FlmHQReportModel(m_ui->listViewPlan);
|
||||
|
||||
if (!planModel->init(m_session, partyFolderId, FileType::inner_enum::TacticalPlan))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "No partyFolderId found for partyId " << partyId;
|
||||
return;
|
||||
WARNING_LOG(m_logger) << "Could not init planModel for partyId " << partyId;
|
||||
|
||||
delete planModel;
|
||||
planModel = nullptr;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
const int hqReportFolderId = m_flmDtc->findFolder(partyFolderId, QStringLiteral("Messages"));
|
||||
|
||||
auto* planModel = new FlmHQReportModel(m_ui->listViewPlan);
|
||||
if (!planModel->init(m_session, partyFolderId, FileType::inner_enum::TacticalPlan))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not init planModel for partyId " << partyId;
|
||||
delete planModel;
|
||||
return;
|
||||
}
|
||||
FlmHQReportModel *hqReportModel = new FlmHQReportModel(m_ui->listViewMessage);
|
||||
|
||||
auto* hqReportModel = new FlmHQReportModel(m_ui->listViewMessage);
|
||||
if (!hqReportModel->init(m_session, hqReportFolderId, FileType::inner_enum::AdlerJson))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not init hqReportModel for partyId " << partyId;
|
||||
delete planModel;
|
||||
delete hqReportModel;
|
||||
return;
|
||||
WARNING_LOG(m_logger) << "Could not init hqReportModel for partyId " << partyId;
|
||||
|
||||
delete planModel;
|
||||
planModel = nullptr;
|
||||
|
||||
delete hqReportModel;
|
||||
hqReportModel = nullptr;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
connect(planModel, &FlmHQReportModel::dataAddedOrRemoved, this, &HQReportEdit::slotChangesMade);
|
||||
|
||||
m_planModels.insert(partyId, planModel);
|
||||
m_hqModels.insert(partyId, hqReportModel);
|
||||
}
|
||||
|
||||
// configure listViewPlan
|
||||
m_ui->listViewPlan->setDragDropMode(QAbstractItemView::DropOnly);
|
||||
m_ui->listViewPlan->setDefaultDropAction(Qt::CopyAction);
|
||||
m_ui->listViewPlan->setDropIndicatorShown(true);
|
||||
m_ui->listViewPlan->setHeaderHidden(true);
|
||||
// configure listViewMessage
|
||||
m_ui->listViewMessage->setDragDropMode(QAbstractItemView::DragOnly);
|
||||
m_ui->listViewMessage->setDefaultDropAction(Qt::CopyAction);
|
||||
m_ui->listViewMessage->setDropIndicatorShown(true);
|
||||
|
||||
onPartyChanged();
|
||||
|
||||
if (!m_flmFtc->enableFileContentModify())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could enable fileContentModify.";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
connect(m_ui->cboParties, qOverload<int>(&QComboBox::currentIndexChanged), this, &HQReportEdit::onPartyChanged);
|
||||
|
||||
int partyIndex = m_ui->cboParties->findData(partyId); // in case of notification: onPartyChanged() is called when index changes
|
||||
m_ui->cboParties->setCurrentIndex(partyIndex < 0 ? 0 : partyIndex);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void HQReportEdit::createModels(const int partyId)
|
||||
{
|
||||
const int partyFolderId = m_flmDtc->getPartyFolderId(m_session->exerciseId(), partyId);
|
||||
if (partyFolderId == 0)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "No partyFolderId found for partyId " << partyId;
|
||||
delete m_planModels.take(partyId);
|
||||
delete m_hqModels.take(partyId);
|
||||
return;
|
||||
}
|
||||
|
||||
const int hqReportFolderId = m_flmDtc->findFolder(partyFolderId, QStringLiteral("Messages"));
|
||||
|
||||
delete m_planModels.take(partyId);
|
||||
delete m_hqModels.take(partyId);
|
||||
|
||||
auto *planModel = new FlmHQReportModel(m_ui->listViewPlan);
|
||||
if (!planModel->init(m_session, partyFolderId, FileType::inner_enum::TacticalPlan))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not init planModel for partyId " << partyId;
|
||||
delete planModel;
|
||||
return;
|
||||
}
|
||||
|
||||
auto *hqReportModel = new FlmHQReportModel(m_ui->listViewMessage);
|
||||
if (!hqReportModel->init(m_session, hqReportFolderId, FileType::inner_enum::AdlerJson))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not init hqReportModel for partyId " << partyId;
|
||||
delete planModel;
|
||||
delete hqReportModel;
|
||||
return;
|
||||
}
|
||||
|
||||
connect(planModel, &FlmHQReportModel::dataAddedOrRemoved, this, &HQReportEdit::slotChangesMade);
|
||||
|
||||
m_planModels.insert(partyId, planModel);
|
||||
m_hqModels.insert(partyId, hqReportModel);
|
||||
}
|
||||
|
||||
bool HQReportEdit::apply()
|
||||
{
|
||||
QMap<int, QList<int>> allHqToPlanIds;
|
||||
QMap<int, QSet<int>> allHqToPlanIds;
|
||||
|
||||
for (auto it = m_planModels.begin(); it != m_planModels.end(); ++it)
|
||||
for (auto it = m_planModels.begin(); it != m_planModels.end(); ++it)
|
||||
{
|
||||
QMap<int, QSet<int>> hqToPlanIds = it.value()->getChangedPlans(); // <planId, hq-message ids>
|
||||
|
||||
for (auto it = hqToPlanIds.constBegin(); it != hqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
QMap<int, QList<int>> hqToPlanIds = it.value()->getHQToPlan();
|
||||
|
||||
for (auto planId : hqToPlanIds.keys())
|
||||
{
|
||||
allHqToPlanIds[planId].append(hqToPlanIds[planId]);
|
||||
|
||||
it.value()->clearMovedData();
|
||||
}
|
||||
allHqToPlanIds[it.key()] += it.value();
|
||||
}
|
||||
}
|
||||
|
||||
const int currentPartyId = m_ui->cboParties->currentData().toInt();
|
||||
FlmHqReportConverter* hqRepConv = new FlmHqReportConverter();
|
||||
const int currentPartyId = m_ui->cboParties->currentData().toInt();
|
||||
FlmHqReportConverter *hqRepConv = new FlmHqReportConverter();
|
||||
|
||||
if (hqRepConv->init(m_session, currentPartyId))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Add HQ to Converter";
|
||||
if (hqRepConv->init(m_session, currentPartyId))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Add HQ to Converter";
|
||||
|
||||
hqRepConv->addHqToPlanIds(allHqToPlanIds);
|
||||
hqRepConv->addHqToPlanIds(allHqToPlanIds);
|
||||
|
||||
hqRepConv->processCollectedHqs();
|
||||
}
|
||||
hqRepConv->processCollectedHqs();
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void HQReportEdit::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("HQ Report"));
|
||||
}
|
||||
void HQReportEdit::retranslate() { translate(m_ui, tr("HQ Report")); }
|
||||
|
||||
void HQReportEdit::onPartyChanged(int index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(index);
|
||||
const int currentPartyId = m_ui->cboParties->currentData().toInt();
|
||||
DEBUG_LOG(m_logger) << "onPartyChanged " << currentPartyId;
|
||||
|
||||
const int currentPartyId = m_ui->cboParties->currentData().toInt();
|
||||
createModels(currentPartyId);
|
||||
|
||||
if (!m_planModels.contains(currentPartyId) || !m_hqModels.contains(currentPartyId))
|
||||
{
|
||||
INFO_LOG(m_logger) << "Models for party" << currentPartyId << "not found. Attempting to create...";
|
||||
createModels(currentPartyId);
|
||||
}
|
||||
QAbstractItemModel *hqModel = m_hqModels.value(currentPartyId, nullptr);
|
||||
QAbstractItemModel *planModel = m_planModels.value(currentPartyId, nullptr);
|
||||
|
||||
QAbstractItemModel* hqModel = m_hqModels.value(currentPartyId, nullptr);
|
||||
QAbstractItemModel* planModel = m_planModels.value(currentPartyId, nullptr);
|
||||
if (m_ui->listViewMessage->selectionModel())
|
||||
{
|
||||
m_ui->listViewMessage->selectionModel()->disconnect(this);
|
||||
}
|
||||
if (m_ui->listViewPlan->selectionModel())
|
||||
{
|
||||
m_ui->listViewPlan->selectionModel()->disconnect(this);
|
||||
}
|
||||
|
||||
if (m_ui->listViewMessage->selectionModel())
|
||||
{
|
||||
m_ui->listViewMessage->selectionModel()->disconnect(this);
|
||||
}
|
||||
if (m_ui->listViewPlan->selectionModel())
|
||||
{
|
||||
m_ui->listViewPlan->selectionModel()->disconnect(this);
|
||||
}
|
||||
m_ui->listViewMessage->setModel(hqModel);
|
||||
m_ui->listViewPlan->setModel(planModel);
|
||||
|
||||
m_ui->listViewMessage->setModel(hqModel);
|
||||
m_ui->listViewPlan->setModel(planModel);
|
||||
|
||||
if (hqModel && planModel)
|
||||
{
|
||||
connect(m_ui->listViewMessage->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||
&HQReportEdit::onSelectionChanged);
|
||||
connect(m_ui->listViewPlan->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||
&HQReportEdit::onSelectionChanged);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Failed to switch to party" << currentPartyId << ": Models still missing.";
|
||||
}
|
||||
if (hqModel && planModel)
|
||||
{
|
||||
connect(m_ui->listViewMessage->selectionModel(), &QItemSelectionModel::selectionChanged, this, &HQReportEdit::onSelectionChanged);
|
||||
connect(m_ui->listViewPlan->selectionModel(), &QItemSelectionModel::selectionChanged, this, &HQReportEdit::onSelectionChanged);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Failed to switch to party" << currentPartyId << ": Models still missing.";
|
||||
}
|
||||
}
|
||||
|
||||
void HQReportEdit::onCreateNewPlanClicked()
|
||||
{
|
||||
bool ok = false;
|
||||
QString planName =
|
||||
QInputDialog::getText(this, tr("Enter Plan name"), tr("Name:"), QLineEdit::Normal, QString(), &ok);
|
||||
bool ok = false;
|
||||
QString planName = QInputDialog::getText(this, tr("Enter Plan name"), tr("Name:"), QLineEdit::Normal, QString(), &ok);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "No name for new plan entered.";
|
||||
if (!ok)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "No name for new plan entered.";
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
FlmHQReportModel* planModel = static_cast<FlmHQReportModel*>(m_ui->listViewPlan->model());
|
||||
FlmHQReportModel *planModel = static_cast<FlmHQReportModel *>(m_ui->listViewPlan->model());
|
||||
|
||||
if (planModel == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create plan --> no plan model present.";
|
||||
if (planModel == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create plan --> no plan model present.";
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
SituationMap::GeometryModel* geometryModel = SituationMap::GeometryModelFactory::singleton()->create();
|
||||
SituationMap::GeometryModel *geometryModel = SituationMap::GeometryModelFactory::singleton()->create();
|
||||
|
||||
if (geometryModel == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create plan --> not possible to create GeometryModel.";
|
||||
if (geometryModel == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create plan --> not possible to create GeometryModel.";
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_session == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create plan --> not possible to create GeometryModel.";
|
||||
if (m_session == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create plan --> not possible to create GeometryModel.";
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
FileManagement::FileContentModifyRequest data;
|
||||
FileManagement::FileContentModifyRequest data;
|
||||
|
||||
data.name(planName.toStdString());
|
||||
data.isTemplate(false);
|
||||
data.isHidden(false);
|
||||
data.folderId(planModel->folderId());
|
||||
data.fileStatus(FileManagement::FileStatus::Valid);
|
||||
data.fileCategory(FileManagement::FileCategory::Exercise);
|
||||
data.fileType(FileManagement::FileType::TacticalPlan);
|
||||
data.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
data.lastModified(QDateTime::currentMSecsSinceEpoch());
|
||||
data.content(LtsUtils::convert<std::vector<uint8_t>>(geometryModel->toByteArray()));
|
||||
data.exerciseId(m_session->exerciseId());
|
||||
data.name(planName.toStdString());
|
||||
data.isTemplate(false);
|
||||
data.isHidden(false);
|
||||
data.folderId(planModel->folderId());
|
||||
data.fileStatus(FileManagement::FileStatus::Valid);
|
||||
data.fileCategory(FileManagement::FileCategory::Exercise);
|
||||
data.fileType(FileManagement::FileType::TacticalPlan);
|
||||
data.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
data.lastModified(QDateTime::currentMSecsSinceEpoch());
|
||||
data.content(LtsUtils::convert<std::vector<uint8_t>>(geometryModel->toByteArray()));
|
||||
data.exerciseId(m_session->exerciseId());
|
||||
|
||||
m_flmFtc->fileContentModifyRequest(data, [this](const Core::FunctionReplyObject& reply) {
|
||||
if (reply.error())
|
||||
{
|
||||
const QString errorMessage = tr("Could not save plan: %1").arg(QString::fromStdString(reply.str()));
|
||||
m_flmFtc->fileContentModifyRequest(data,
|
||||
[this](const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
if (reply.error())
|
||||
{
|
||||
const QString errorMessage = tr("Could not save plan: %1").arg(QString::fromStdString(reply.str()));
|
||||
|
||||
ERROR_LOG(m_logger) << errorMessage;
|
||||
ERROR_LOG(m_logger) << errorMessage;
|
||||
|
||||
new LtsWidgets::LtsMessageDialogNew(this, errorMessage, tr("Save failed"));
|
||||
}
|
||||
});
|
||||
new LtsWidgets::LtsMessageDialogNew(this, errorMessage, tr("Save failed"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void HQReportEdit::onSelectionChanged(const QItemSelection&, const QItemSelection&)
|
||||
void HQReportEdit::onSelectionChanged(const QItemSelection &, const QItemSelection &)
|
||||
{
|
||||
m_ui->pbShift->setEnabled(m_ui->listViewMessage->selectionModel()->hasSelection() &&
|
||||
m_ui->listViewPlan->selectionModel()->hasSelection());
|
||||
m_ui->pbShift->setEnabled(m_ui->listViewMessage->selectionModel()->hasSelection() && m_ui->listViewPlan->selectionModel()->hasSelection());
|
||||
}
|
||||
|
||||
void HQReportEdit::onShiftClicked()
|
||||
{
|
||||
const int currentPartyId = m_ui->cboParties->currentData().toInt();
|
||||
const int currentPartyId = m_ui->cboParties->currentData().toInt();
|
||||
|
||||
FlmHQReportModel* messageModel = m_hqModels.value(currentPartyId);
|
||||
FlmHQReportModel* planModel = m_planModels.value(currentPartyId);
|
||||
FlmHQReportModel *messageModel = m_hqModels.value(currentPartyId);
|
||||
FlmHQReportModel *planModel = m_planModels.value(currentPartyId);
|
||||
|
||||
if (messageModel == nullptr || planModel == nullptr)
|
||||
return;
|
||||
if (messageModel == nullptr || planModel == nullptr)
|
||||
return;
|
||||
|
||||
const QModelIndex currentMessageIndex = m_ui->listViewMessage->currentIndex();
|
||||
const QModelIndex currentMessageIndex = m_ui->listViewMessage->currentIndex();
|
||||
|
||||
if (!currentMessageIndex.isValid())
|
||||
return;
|
||||
if (!currentMessageIndex.isValid())
|
||||
return;
|
||||
|
||||
QMimeData* mimeData = messageModel->mimeData({currentMessageIndex});
|
||||
QMimeData *mimeData = messageModel->mimeData({currentMessageIndex});
|
||||
|
||||
if (mimeData == nullptr)
|
||||
return;
|
||||
if (mimeData == nullptr)
|
||||
return;
|
||||
|
||||
if (!planModel->dropMimeData(mimeData, Qt::CopyAction, -1, 0, m_ui->listViewPlan->currentIndex()))
|
||||
return;
|
||||
if (!planModel->dropMimeData(mimeData, Qt::CopyAction, -1, 0, m_ui->listViewPlan->currentIndex()))
|
||||
return;
|
||||
|
||||
m_ui->listViewPlan->viewport()->update();
|
||||
m_ui->listViewPlan->viewport()->update();
|
||||
}
|
||||
|
||||
} // namespace FileManagement
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="2">
|
||||
<widget class="QListView" name="listViewPlan"/>
|
||||
<widget class="QTreeView" name="listViewPlan"/>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="lblPlans">
|
||||
|
||||
+325
-194
@@ -1,299 +1,430 @@
|
||||
#include "flm_hq_report_model.h"
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <flm_data_plugin_interface.h>
|
||||
|
||||
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
|
||||
namespace FileManagement
|
||||
{
|
||||
FlmHQReportModel::FlmHQReportModel(QObject* parent)
|
||||
: QAbstractListModel(parent), m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger())
|
||||
FlmHQReportModel::FlmHQReportModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
, m_logger(getLogger("HQReportModel"))
|
||||
{
|
||||
}
|
||||
|
||||
bool FlmHQReportModel::init(LtsSession::LtsSession* session, int contentFolderId, const FileType& fileType)
|
||||
bool FlmHQReportModel::init(LtsSession::LtsSession *session, int contentFolderId, const FileType &fileType)
|
||||
{
|
||||
if (!session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got invalid Session";
|
||||
if (!session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got invalid Session";
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!session->getDtc<FileManagement::DataInterface>(m_flmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Dtc";
|
||||
if (!session->getDtc<FileManagement::DataInterface>(m_flmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Dtc";
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
m_contentFolderId = contentFolderId;
|
||||
m_fileType = fileType;
|
||||
m_contentFolderId = contentFolderId;
|
||||
m_fileType = fileType;
|
||||
|
||||
m_flmDtc->enableFileContent();
|
||||
m_flmDtc->waitForHistoricalDataFileContent(3000);
|
||||
m_flmDtc->fileContents(
|
||||
[this](const FileContent& content) { onFileContentChanged(content, DataModification::eAdded); });
|
||||
m_flmDtc->enableFileContent();
|
||||
m_flmDtc->waitForHistoricalDataFileContent(3000);
|
||||
m_flmDtc->fileContents([this](const FileContent &content) { onFileContentChanged(content, DataModification::eAdded); });
|
||||
|
||||
connect(m_flmDtc.get(), &Interface::Dtc::fileContentChanged, this, &FlmHQReportModel::onFileContentChanged);
|
||||
connect(m_flmDtc.get(), &Interface::Dtc::fileContentChanged, this, &FlmHQReportModel::onFileContentChanged);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
int FlmHQReportModel::rowCount(const QModelIndex& parent) const
|
||||
int FlmHQReportModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid())
|
||||
return 0;
|
||||
if (!parent.isValid())
|
||||
return m_data.count();
|
||||
|
||||
if (parent.internalId() != 0)
|
||||
return 0;
|
||||
|
||||
if (parent.row() >= 0 && parent.row() < m_data.size())
|
||||
{
|
||||
const HQData &data = m_data.at(parent.row());
|
||||
auto it = m_movedData.constFind(data.id);
|
||||
if (it != m_movedData.constEnd())
|
||||
return it.value().count();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
QVariant FlmHQReportModel::data(const QModelIndex& index, int role) const
|
||||
QModelIndex FlmHQReportModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
return createText(index.row());
|
||||
if (!index.isValid())
|
||||
return QModelIndex();
|
||||
|
||||
return QVariant();
|
||||
quintptr internalId = index.internalId();
|
||||
|
||||
if (internalId == 0)
|
||||
return QModelIndex();
|
||||
|
||||
int parentRow = static_cast<int>(internalId) - 1;
|
||||
|
||||
return createIndex(parentRow, 0, quintptr(0));
|
||||
}
|
||||
|
||||
Qt::ItemFlags FlmHQReportModel::flags(const QModelIndex& index) const
|
||||
QVariant FlmHQReportModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
Qt::ItemFlags defaultFlags = QAbstractListModel::flags(index);
|
||||
if (!index.isValid())
|
||||
return {};
|
||||
|
||||
if (!index.isValid())
|
||||
return defaultFlags;
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
quintptr internalId = index.internalId();
|
||||
|
||||
return defaultFlags | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
|
||||
if (internalId == 0)
|
||||
{
|
||||
if (index.row() >= 0 && index.row() < m_data.size())
|
||||
return m_data.at(index.row()).name;
|
||||
}
|
||||
else // Child-Item
|
||||
{
|
||||
int parentRow = static_cast<int>(internalId) - 1;
|
||||
if (parentRow >= 0 && parentRow < m_data.size())
|
||||
{
|
||||
const HQData &parentData = m_data.at(parentRow);
|
||||
auto it = m_movedData.constFind(parentData.id);
|
||||
if (it != m_movedData.constEnd())
|
||||
{
|
||||
const QList<HQData> &children = it.value();
|
||||
if (index.row() >= 0 && index.row() < children.size())
|
||||
return children.at(index.row()).name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Qt::DropActions FlmHQReportModel::supportedDropActions() const
|
||||
Qt::ItemFlags FlmHQReportModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
return Qt::CopyAction;
|
||||
Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index);
|
||||
|
||||
if (!index.isValid())
|
||||
return defaultFlags;
|
||||
|
||||
return defaultFlags | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
|
||||
}
|
||||
|
||||
Qt::DropActions FlmHQReportModel::supportedDragActions() const
|
||||
{
|
||||
return Qt::CopyAction;
|
||||
}
|
||||
Qt::DropActions FlmHQReportModel::supportedDropActions() const { return Qt::CopyAction; }
|
||||
|
||||
Qt::DropActions FlmHQReportModel::supportedDragActions() const { return Qt::CopyAction; }
|
||||
|
||||
QStringList FlmHQReportModel::mimeTypes() const
|
||||
{
|
||||
QStringList types;
|
||||
types << mimeType;
|
||||
return types;
|
||||
QStringList types;
|
||||
types << mimeType;
|
||||
return types;
|
||||
}
|
||||
|
||||
bool FlmHQReportModel::removeRows(int row, int count, const QModelIndex& parent)
|
||||
bool FlmHQReportModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||
{
|
||||
if (parent.isValid() || row < 0 || row >= m_data.size() || (row + count) > m_data.size())
|
||||
return false;
|
||||
if (parent.isValid() || row < 0 || row >= m_data.size() || (row + count) > m_data.size())
|
||||
return false;
|
||||
|
||||
beginRemoveRows(QModelIndex(), row, row + count - 1);
|
||||
beginRemoveRows(QModelIndex(), row, row + count - 1);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
m_data.removeAt(row);
|
||||
for (int i = 0; i < count; ++i)
|
||||
m_data.removeAt(row);
|
||||
|
||||
endRemoveRows();
|
||||
endRemoveRows();
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
QMimeData* FlmHQReportModel::mimeData(const QList<QModelIndex>& indexes) const
|
||||
QMimeData *FlmHQReportModel::mimeData(const QList<QModelIndex> &indexes) const
|
||||
{
|
||||
QMimeData* mimeData = new QMimeData();
|
||||
QByteArray encodedData;
|
||||
QDataStream stream(&encodedData, QIODevice::WriteOnly);
|
||||
QMimeData *mimeData = new QMimeData();
|
||||
QByteArray encodedData;
|
||||
QDataStream stream(&encodedData, QIODevice::WriteOnly);
|
||||
|
||||
for (const QModelIndex& index : indexes)
|
||||
for (const QModelIndex &index : indexes)
|
||||
{
|
||||
if (index.isValid())
|
||||
{
|
||||
if (index.isValid())
|
||||
HQData md;
|
||||
QString visibleName = index.data(Qt::DisplayRole).toString();
|
||||
|
||||
if (index.internalId() != 0)
|
||||
{
|
||||
int parentRow = static_cast<int>(index.internalId()) - 1;
|
||||
if (parentRow >= 0 && parentRow < m_data.size())
|
||||
{
|
||||
HQData md = m_data.at(index.row());
|
||||
stream << md.id << md.name;
|
||||
const HQData &parentData = m_data.at(parentRow);
|
||||
const auto &children = m_movedData.value(parentData.id);
|
||||
if (index.row() >= 0 && index.row() < children.size())
|
||||
{
|
||||
md = children.at(index.row());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (index.row() >= 0 && index.row() < m_data.size())
|
||||
{
|
||||
const HQData &originalData = m_data.at(index.row());
|
||||
md.id = originalData.id;
|
||||
md.name = visibleName;
|
||||
md.properties = originalData.properties;
|
||||
}
|
||||
}
|
||||
md.name = visibleName;
|
||||
stream << md.id << md.name;
|
||||
}
|
||||
mimeData->setData(mimeType, encodedData);
|
||||
return mimeData;
|
||||
}
|
||||
mimeData->setData(mimeType, encodedData);
|
||||
return mimeData;
|
||||
}
|
||||
|
||||
bool FlmHQReportModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent)
|
||||
bool FlmHQReportModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
|
||||
{
|
||||
Q_UNUSED(row)
|
||||
Q_UNUSED(column)
|
||||
Q_UNUSED(row)
|
||||
Q_UNUSED(column)
|
||||
|
||||
if (!parent.isValid() || !data->hasFormat(mimeType) || action != Qt::CopyAction)
|
||||
return false;
|
||||
if (!parent.isValid() || !data->hasFormat(mimeType) || action != Qt::CopyAction)
|
||||
return false;
|
||||
|
||||
QByteArray encodedData = data->data(mimeType);
|
||||
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||
QByteArray encodedData = data->data(mimeType);
|
||||
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||
|
||||
while (!stream.atEnd())
|
||||
{
|
||||
HQData md;
|
||||
if (parent.isValid() && parent.row() >= 0 && parent.row() < m_data.size())
|
||||
DEBUG_LOG(m_logger) << "DROP ZIEL (Parent im Tree): " << m_data.at(parent.row()).name;
|
||||
|
||||
stream >> md.id >> md.name;
|
||||
while (!stream.atEnd())
|
||||
{
|
||||
HQData md;
|
||||
stream >> md.id >> md.name;
|
||||
|
||||
addMovedData(parent.row(), md);
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "DROP INHALT aus Stream -> ID: " << md.id << ", NAME: " << md.name;
|
||||
|
||||
emit dataAddedOrRemoved();
|
||||
addMovedData(parent, md);
|
||||
}
|
||||
|
||||
emit dataAddedOrRemoved();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FlmHQReportModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(row)
|
||||
Q_UNUSED(column)
|
||||
|
||||
if (!parent.isValid() || !data->hasFormat(mimeType) || action != Qt::CopyAction || parent.row() < 0 || parent.row() >= m_data.size())
|
||||
return false;
|
||||
|
||||
QByteArray encodedData = data->data(mimeType);
|
||||
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||
|
||||
const HQData ¤tParentData = m_data.at(parent.row());
|
||||
|
||||
if (!m_movedData.contains(currentParentData.id))
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FlmHQReportModel::canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) const
|
||||
{
|
||||
Q_UNUSED(row)
|
||||
Q_UNUSED(column)
|
||||
const QList<HQData> &existingChildren = m_movedData.value(currentParentData.id);
|
||||
|
||||
if (!parent.isValid() || !data->hasFormat(mimeType) || action != Qt::CopyAction || parent.row() < 0 ||
|
||||
parent.row() >= m_data.size())
|
||||
while (!stream.atEnd())
|
||||
{
|
||||
HQData incomingData;
|
||||
stream >> incomingData.id >> incomingData.name;
|
||||
|
||||
for (const HQData &child : existingChildren)
|
||||
{
|
||||
if (child.id == incomingData.id)
|
||||
return false;
|
||||
|
||||
QByteArray encodedData = data->data(mimeType);
|
||||
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||
const HQData& currentData = m_data.at(parent.row());
|
||||
|
||||
if (!m_movedData.contains(currentData.id))
|
||||
return true;
|
||||
|
||||
const QList<HQData>& movedDataListForCurrentData = m_movedData.value(currentData.id);
|
||||
|
||||
while (!stream.atEnd())
|
||||
{
|
||||
HQData movedData;
|
||||
|
||||
stream >> movedData.id >> movedData.name;
|
||||
|
||||
if (movedDataListForCurrentData.contains(movedData))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void FlmHQReportModel::addHQReportData(const HQData& data)
|
||||
QModelIndex FlmHQReportModel::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||
m_data.append(data);
|
||||
endInsertRows();
|
||||
if (!hasIndex(row, column, parent))
|
||||
return QModelIndex();
|
||||
|
||||
if (!parent.isValid())
|
||||
{
|
||||
if (row >= 0 && row < m_data.size())
|
||||
return createIndex(row, column, quintptr(0)); // internalId = 0 für Parents
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parent.internalId() == 0)
|
||||
{
|
||||
int parentRow = parent.row();
|
||||
return createIndex(row, column, quintptr(parentRow + 1));
|
||||
}
|
||||
}
|
||||
|
||||
return QModelIndex();
|
||||
}
|
||||
void FlmHQReportModel::addHQReportData(const HQData &data)
|
||||
{
|
||||
QList<HQData> childProperties;
|
||||
HQData copyData = data;
|
||||
|
||||
if (!data.properties.empty())
|
||||
{
|
||||
QJsonDocument doc = QJsonDocument::fromJson(QByteArray::fromStdString(data.properties));
|
||||
// Hole Einträge aus den properties
|
||||
if (doc.isArray())
|
||||
{
|
||||
QJsonArray jsonArray = doc.array();
|
||||
for (const QJsonValue &value : jsonArray)
|
||||
{
|
||||
QString prop = value.toString().trimmed();
|
||||
if (!prop.isEmpty() && prop != data.name)
|
||||
{
|
||||
HQData childData;
|
||||
childData.id = data.id;
|
||||
childData.name = prop;
|
||||
copyData.children.insert(childData.id);
|
||||
childProperties.append(childData);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QString prop = QString::fromStdString(data.properties).trimmed();
|
||||
if (!prop.isEmpty() && prop != data.name)
|
||||
{
|
||||
HQData childData;
|
||||
childData.id = data.id;
|
||||
childData.name = prop;
|
||||
childProperties.append(childData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
beginInsertRows(QModelIndex(), m_data.count(), m_data.count());
|
||||
m_data.append(copyData);
|
||||
|
||||
if (!childProperties.isEmpty())
|
||||
m_movedData.insert(data.id, childProperties);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void FlmHQReportModel::deleteHQReportData(const HQData& data)
|
||||
void FlmHQReportModel::deleteHQReportData(const HQData &data)
|
||||
{
|
||||
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||
endInsertRows();
|
||||
const int zeile = m_data.indexOf(data);
|
||||
|
||||
const int zeile = m_data.indexOf(data);
|
||||
|
||||
if (zeile == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
beginRemoveRows(QModelIndex(), zeile, zeile);
|
||||
m_data.removeAt(zeile);
|
||||
endRemoveRows();
|
||||
if (zeile == -1)
|
||||
return;
|
||||
|
||||
beginRemoveRows(QModelIndex(), zeile, zeile);
|
||||
m_data.removeAt(zeile);
|
||||
endRemoveRows();
|
||||
return;
|
||||
}
|
||||
|
||||
void FlmHQReportModel::onFileContentChanged(const FileContent& content, DataModification modType)
|
||||
void FlmHQReportModel::onFileContentChanged(const FileContent &content, DataModification modType)
|
||||
{
|
||||
HQData data;
|
||||
data.id = content.id();
|
||||
data.name = QString::fromStdString(content.name());
|
||||
if (content.folderId() != m_contentFolderId || content.fileType() != m_fileType)
|
||||
return;
|
||||
if (content.folderId() != m_contentFolderId || content.fileType() != m_fileType)
|
||||
return;
|
||||
|
||||
if (content.fileStatus() == FileStatus::Deleted)
|
||||
{
|
||||
if (modType == DataModification::eModified || modType == DataModification::eAdded)
|
||||
{
|
||||
deleteHQReportData(data);
|
||||
}
|
||||
}
|
||||
else if (modType == DataModification::eAdded)
|
||||
{
|
||||
addHQReportData(data);
|
||||
}
|
||||
HQData data;
|
||||
data.id = content.id();
|
||||
data.name = QString::fromStdString(content.name());
|
||||
data.properties = content.properties();
|
||||
|
||||
DEBUG_LOG(m_logger) << "FlmHQReportModel::onFileContentChanged " << "properties " << data.properties << " " << " Name: " << data.name;
|
||||
|
||||
if (content.fileStatus() == FileStatus::Deleted)
|
||||
{
|
||||
if (modType == DataModification::eModified || modType == DataModification::eAdded)
|
||||
deleteHQReportData(data);
|
||||
}
|
||||
else if (modType == DataModification::eAdded)
|
||||
{
|
||||
addHQReportData(data);
|
||||
}
|
||||
}
|
||||
|
||||
int FlmHQReportModel::folderId() const
|
||||
{
|
||||
return m_contentFolderId;
|
||||
}
|
||||
int FlmHQReportModel::folderId() const { return m_contentFolderId; }
|
||||
|
||||
QMap<int, QList<int>> FlmHQReportModel::getHQToPlan() const
|
||||
QMap<int, QSet<int>> FlmHQReportModel::getChangedPlans() const
|
||||
{
|
||||
QMap<int, QList<int>> hqToPlan;
|
||||
QMap<int, QSet<int>> hqToPlan;
|
||||
|
||||
for (auto it = m_movedData.constBegin(); it != m_movedData.constEnd(); ++it)
|
||||
for (auto it = m_movedData.constBegin(); it != m_movedData.constEnd(); ++it)
|
||||
{
|
||||
const QList<HQData> &movedData = it.value();
|
||||
QSet<int> hqIds;
|
||||
|
||||
hqIds.reserve(movedData.size());
|
||||
|
||||
for (const HQData ¤tData : movedData)
|
||||
hqIds.insert(currentData.id);
|
||||
|
||||
HQData myPlan;
|
||||
for (const auto &plan : m_data)
|
||||
{
|
||||
const QList<HQData>& movedData = it.value();
|
||||
QList<int> hqIds;
|
||||
|
||||
hqIds.reserve(movedData.size());
|
||||
|
||||
for (const HQData& currentData : movedData)
|
||||
hqIds.append(currentData.id);
|
||||
|
||||
hqToPlan.insert(it.key(), hqIds);
|
||||
if (plan.id == it.key())
|
||||
{
|
||||
myPlan = plan;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (myPlan.children != hqIds)
|
||||
hqToPlan.insert(it.key(), hqIds);
|
||||
}
|
||||
|
||||
return hqToPlan;
|
||||
return hqToPlan;
|
||||
}
|
||||
|
||||
void FlmHQReportModel::clearMovedData()
|
||||
{
|
||||
m_movedData.clear();
|
||||
if (m_movedData.isEmpty())
|
||||
return;
|
||||
|
||||
emit dataAddedOrRemoved();
|
||||
emit dataChanged(index(0, 0), index(rowCount() - 1, 0));
|
||||
beginResetModel();
|
||||
m_movedData.clear();
|
||||
endResetModel();
|
||||
|
||||
emit dataAddedOrRemoved();
|
||||
}
|
||||
|
||||
QString FlmHQReportModel::createText(int dataIndex) const
|
||||
void FlmHQReportModel::addMovedData(const QModelIndex &parentIndex, const HQData &movedData)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " dataIndex: " << dataIndex;
|
||||
int dataIndex = parentIndex.row();
|
||||
if (dataIndex < 0 || dataIndex >= m_data.size())
|
||||
return;
|
||||
|
||||
if (dataIndex < 0 || dataIndex >= m_data.size())
|
||||
return QString();
|
||||
const HQData &data = m_data.at(dataIndex);
|
||||
|
||||
const HQData& data = m_data.at(dataIndex);
|
||||
if (data.id == movedData.id)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "DROP ABGEWIESEN: PlanId entspricht der ReportId (" << data.id << ")";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_movedData.contains(data.id))
|
||||
if (!m_movedData.contains(data.id))
|
||||
m_movedData.insert(data.id, QList<HQData>());
|
||||
|
||||
const QList<HQData> &existingChildren = m_movedData[data.id];
|
||||
for (const HQData &child : existingChildren)
|
||||
{
|
||||
if (child.id == movedData.id || child.name.trimmed() == movedData.name.trimmed())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "No moved data for " << data.name;
|
||||
return data.name;
|
||||
DEBUG_LOG(m_logger) << "DROP ABGEWIESEN: Element '" << movedData.name << "' ist bereits vorhanden.";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const QList<HQData>& movedData = m_movedData.value(data.id);
|
||||
QStringList movedDataNames;
|
||||
int newRow = m_movedData[data.id].size();
|
||||
|
||||
movedDataNames.reserve(movedData.size());
|
||||
|
||||
for (const HQData& currentMovedData : movedData)
|
||||
movedDataNames.append(currentMovedData.name);
|
||||
|
||||
return QString(QStringLiteral("%1 (%2)")).arg(data.name).arg(movedDataNames.join(QLatin1Char(',')));
|
||||
beginInsertRows(parentIndex, newRow, newRow);
|
||||
m_movedData[data.id].append(movedData);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void FlmHQReportModel::addMovedData(int dataIndex, const HQData& movedData)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " dataIndex: " << dataIndex << ", movedData.id: " << movedData.id
|
||||
<< ", movedData.name: " << movedData.name;
|
||||
|
||||
if (dataIndex < 0 || dataIndex >= m_data.size())
|
||||
return;
|
||||
|
||||
const HQData& data = m_data.at(dataIndex);
|
||||
|
||||
if (!m_movedData.contains(data.id))
|
||||
m_movedData.insert(data.id, QList<HQData>());
|
||||
|
||||
m_movedData[data.id].append(movedData);
|
||||
}
|
||||
|
||||
} // namespace FileManagement
|
||||
+49
-48
@@ -1,21 +1,22 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <FileManagement/flm_enums.hpp>
|
||||
#include <Lts/Services/FileManagement/logger.h>
|
||||
#include <LtsUtils/LtsUtilsCore/data_modification_enum.h>
|
||||
#include <QtCore/QAbstractListModel>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QDataStream>
|
||||
#include <QtCore/QList>
|
||||
#include <QAbstractListModel>
|
||||
#include <QByteArray>
|
||||
#include <QDataStream>
|
||||
#include <QMimeData>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtGui/QStandardItemModel>
|
||||
#include <QObject>
|
||||
#include <QSet>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
#include <FileManagement/flm_enums.hpp>
|
||||
#include <FileManagement/logger.h>
|
||||
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
class FileContent;
|
||||
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
@@ -31,64 +32,64 @@ namespace FileManagement
|
||||
{
|
||||
struct HQData
|
||||
{
|
||||
int id;
|
||||
QString name;
|
||||
int id{0};
|
||||
QString name;
|
||||
std::string properties;
|
||||
QSet<int> children;
|
||||
|
||||
bool operator==(const HQData& other) const
|
||||
{
|
||||
return id == other.id && name == other.name;
|
||||
}
|
||||
bool operator==(const HQData &other) const { return id == other.id && name == other.name; }
|
||||
};
|
||||
|
||||
class FlmHQReportModel : public QAbstractListModel
|
||||
class FlmHQReportModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FlmHQReportModel(QObject* parent = nullptr);
|
||||
explicit FlmHQReportModel(QObject *parent = nullptr);
|
||||
|
||||
bool init(LtsSession::LtsSession* session, int contentFolderId, const FileManagement::FileType& fileType);
|
||||
bool init(LtsSession::LtsSession *session, int contentFolderId, const FileManagement::FileType &fileType);
|
||||
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
Qt::DropActions supportedDropActions() const override;
|
||||
Qt::DropActions supportedDragActions() const override;
|
||||
QStringList mimeTypes() const override;
|
||||
bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
Qt::DropActions supportedDropActions() const override;
|
||||
Qt::DropActions supportedDragActions() const override;
|
||||
QStringList mimeTypes() const override;
|
||||
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
|
||||
QMimeData* mimeData(const QList<QModelIndex>& indexes) const override;
|
||||
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) override;
|
||||
bool canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) const override;
|
||||
QMimeData *mimeData(const QList<QModelIndex> &indexes) const override;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
||||
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override { return 1; }
|
||||
QModelIndex parent(const QModelIndex &index) const override;
|
||||
|
||||
void addHQReportData(const HQData& data);
|
||||
void deleteHQReportData(const HQData& data);
|
||||
void addHQReportData(const HQData &data);
|
||||
void deleteHQReportData(const HQData &data);
|
||||
|
||||
int folderId() const;
|
||||
int folderId() const;
|
||||
|
||||
QMap<int, QList<int>> getHQToPlan() const;
|
||||
void clearMovedData();
|
||||
QMap<int, QSet<int>> getChangedPlans() const;
|
||||
void clearMovedData();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
QString createText(int dataIndex) const;
|
||||
void addMovedData(int dataIndex, const HQData& movedData);
|
||||
void addMovedData(const QModelIndex &parentIndex, const HQData &movedData);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onFileContentChanged(const FileContent& content, DataModification modType);
|
||||
void onFileContentChanged(const FileContent &content, DataModification modType);
|
||||
|
||||
Q_SIGNALS:
|
||||
void dataAddedOrRemoved();
|
||||
void dataAddedOrRemoved();
|
||||
|
||||
private:
|
||||
QList<HQData> m_data;
|
||||
QMap<int, QList<HQData>> m_movedData;
|
||||
const QString mimeType = QStringLiteral("application/x-custom-hqdata");
|
||||
int m_contentFolderId{-1};
|
||||
FileManagement::FileType m_fileType;
|
||||
std::shared_ptr<FileManagement::Interface::Dtc> m_flmDtc;
|
||||
QList<HQData> m_data;
|
||||
QMap<int, QList<HQData>> m_movedData;
|
||||
const QString mimeType = QStringLiteral("application/x-custom-hqdata");
|
||||
int m_contentFolderId{-1};
|
||||
FileManagement::FileType m_fileType;
|
||||
std::shared_ptr<FileManagement::Interface::Dtc> m_flmDtc;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
} // namespace FileManagement
|
||||
|
||||
|
||||
+27
-22
@@ -1,29 +1,35 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for MarkerManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <MarkerManagement/logger.h>
|
||||
#include <MarkerManagement/mrk_ftc.h>
|
||||
#include <MarkerManagement/mrk_dtc.h>
|
||||
#include <Lts/Services/FileManagement/flm_ftc.h>
|
||||
#include <FileManagement/flm_ftc.h>
|
||||
#include <FileManagement/flm_dtc.h>
|
||||
#include <OperatorManagement/opm_dtc.h>
|
||||
#include <Core/core_dtc.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <DDS/Core/core_dtc.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <MarkerManagement/mrk_data_plugin_interface.h>
|
||||
#include <MarkerManagement/mrk_gui_plugin_interface.h>
|
||||
#include <AudioVideoManagement/avm_data_plugin_interface.h>
|
||||
#include <SituationReplayManagement/srm_data_plugin_interface.h>
|
||||
#include <SituationReplay/srp_gui_plugin_interface.h>
|
||||
#include <SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <FilterManagement/flt_data_plugin_interface.h>
|
||||
#include <FilterManagement/flt_participant_plugin_interface.h>
|
||||
#include <FilterManagement/flt_aes_plugin_interface.h>
|
||||
#include <FilterManagement/flt_building_cmpnt_plugin_interface.h>
|
||||
#include <FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include <Plugins/MarkerManagement/mrk_data_plugin_interface.h>
|
||||
#include <Plugins/MarkerManagement/mrk_gui_plugin_interface.h>
|
||||
#include <Plugins/AudioVideoManagement/avm_data_plugin_interface.h>
|
||||
#include <Plugins/SituationReplayManagement/srm_data_plugin_interface.h>
|
||||
#include <Plugins/SituationReplay/srp_gui_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <Plugins/FilterManagement/flt_data_plugin_interface.h>
|
||||
#include <Plugins/FilterManagement/flt_participant_plugin_interface.h>
|
||||
#include <Plugins/FilterManagement/flt_aes_plugin_interface.h>
|
||||
#include <Plugins/FilterManagement/flt_building_cmpnt_plugin_interface.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
|
||||
|
||||
class QSortFilterProxyModel;
|
||||
@@ -64,7 +70,7 @@ public:
|
||||
NGL::INGLLogger &logger);
|
||||
~TopicReplayInterface();
|
||||
|
||||
|
||||
// Script Playback Controls:
|
||||
bool playbackInit(const QJsonObject &attributes) override;
|
||||
bool playbackStart(int secondsOffset) override;
|
||||
bool playbackPause() override;
|
||||
@@ -73,10 +79,9 @@ public:
|
||||
QVector<TopicEditorBase::TopicData> additionalTrackEntries(const QJsonObject &attributes) const override;
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<SituationReplay::ForeignGuiInterface> m_srpIfc;
|
||||
Snapshot m_snapshot;
|
||||
NGL::INGLLogger &m_logger;
|
||||
QByteArray m_originalMapSettings;
|
||||
MarkerManagement::ForeignGuiInterface *m_parentIfc;
|
||||
std::shared_ptr<MarkerManagement::Interface::Dtc> m_mrkDtc;
|
||||
@@ -103,10 +108,10 @@ public:
|
||||
MarkerManagement::SnapshotDialogModel *createSnapshotModel() override final;
|
||||
QSortFilterProxyModel *createSnapshotFilterProxyModel();
|
||||
|
||||
|
||||
// Script Editor Topic Editor:
|
||||
TopicEditorBase::TopicEditor *createTopicEditor(const TopicEditorBase::TopicData &data) override final;
|
||||
|
||||
|
||||
// Script Player:
|
||||
TopicReplay::Interface *createInterface(TopicEditorBase::TopicType) override final;
|
||||
|
||||
void showMarker(int markerId) override final;
|
||||
@@ -161,4 +166,4 @@ private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace MarkerManagement
|
||||
@@ -91,7 +91,7 @@ ADD_INTERFACE_LIBRARY(PpmDataPluginInterface
|
||||
svcPpmCommon
|
||||
)
|
||||
|
||||
IF(QT_VERSION VERSION_GREATER_EQUAL 6.0.0)
|
||||
IF(Qt5WebEngineWidgets_VERSION VERSION_GREATER 5.7.9)
|
||||
#
|
||||
# Combat Power Gui Plugin Interface
|
||||
#
|
||||
@@ -101,3 +101,11 @@ ADD_INTERFACE_LIBRARY(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
# GuiElementInterface
|
||||
ADD_INTERFACE_LIBRARY(
|
||||
GuiElementInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/participant_info_gui_element_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
Qt5::Core LtsWidgets
|
||||
)
|
||||
+28
-36
@@ -5,14 +5,6 @@
|
||||
# Created by Mike Wille, SLSE, 2016-05-05
|
||||
#
|
||||
|
||||
# Make ${Qt6_Widgets} optional
|
||||
if(QT6_GUI_AVAILABLE AND TARGET Qt6::Widgets)
|
||||
set(Qt6_Widgets ${Qt6_Widgets})
|
||||
else()
|
||||
set(Qt6_Widgets "")
|
||||
endif()
|
||||
|
||||
|
||||
SET(participant_info_gui_SRCS
|
||||
participant_info_gui_plugin.cpp
|
||||
participant_info_gui_plugin.h
|
||||
@@ -83,34 +75,34 @@ NGL_WRAP_UI(participant_info_gui_SRCS
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS PpmParticipantInfoGuiPlugin MODULE ${participant_info_gui_SRCS})
|
||||
if(QT6_GUI_AVAILABLE)
|
||||
NGL_TARGET_LINK_LIBRARIES(PpmParticipantInfoGuiPlugin
|
||||
NGLLogger
|
||||
LtsNotification
|
||||
ngltools
|
||||
nglwidgets
|
||||
LtsCoordTrans
|
||||
FltAesGuiPluginInterface
|
||||
PpmCommon
|
||||
PpmParticipantInfoGuiPluginInterface
|
||||
PpmDataPluginInterface
|
||||
PdmDataPluginInterface
|
||||
svcTgtClient
|
||||
PdmGuiPluginInterface
|
||||
${Qt6_Widgets}
|
||||
LtsWidgets
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
LtsUtilsSettings
|
||||
SituationMapGuiPluginInterface
|
||||
LtsUtilsGuiDds
|
||||
LtsUtilsSettings
|
||||
AsbDataPluginInterface
|
||||
AesDataPluginInterface
|
||||
LtsDataView
|
||||
IsmDataPluginInterface
|
||||
)
|
||||
endif()
|
||||
NGL_TARGET_LINK_LIBRARIES(PpmParticipantInfoGuiPlugin
|
||||
NGLLogger
|
||||
LtsNotification
|
||||
ngltools
|
||||
nglwidgets
|
||||
LtsCoordTrans
|
||||
FltAesGuiPluginInterface
|
||||
PpmCommon
|
||||
PpmParticipantInfoGuiPluginInterface
|
||||
PpmDataPluginInterface
|
||||
PdmDataPluginInterface
|
||||
svcTgtClient
|
||||
PdmGuiPluginInterface
|
||||
Qt5::Widgets
|
||||
LtsWidgets
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
LtsUtilsSettings
|
||||
SituationMapGuiPluginInterface
|
||||
LtsUtilsGuiDds
|
||||
LtsUtilsSettings
|
||||
AsbDataPluginInterface
|
||||
AesDataPluginInterface
|
||||
LtsDataView
|
||||
IsmDataPluginInterface
|
||||
LtsPluginLoader
|
||||
GuiElementInterface
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(PpmParticipantInfoGuiPlugin)
|
||||
|
||||
|
||||
+189
-126
@@ -1,5 +1,11 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ParticipantManagement - ParticipantInfoDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-06-01
|
||||
*/
|
||||
|
||||
#include "participant_info_dialog.h"
|
||||
#include "ui_participant_info_dialog.h"
|
||||
@@ -25,18 +31,20 @@
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtils/LtsUtilsCore/outdated_position.h>
|
||||
#include <LtsUtilsCore/outdated_position.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <LtsPluginManager/lts_plugin_loader.h>
|
||||
|
||||
#include <AreaEffectSimulation/Utils/polygons.h>
|
||||
#include <Services/AreaEffectSimulation/Utils/polygons.h>
|
||||
#include <ParticipantManagement/participant_info_gui_element_interface.h>
|
||||
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QJsonDocument>
|
||||
#include <QTableWidgetItem>
|
||||
#include <QtWidgets/QToolButton>
|
||||
#include <QtGui/QTransform>
|
||||
#include <QtWidgets/QMenu>
|
||||
#include <QtGui/QColor>
|
||||
#include <QtWidgets/QLabel>
|
||||
#include <QToolButton>
|
||||
#include <QTransform>
|
||||
#include <QMenu>
|
||||
#include <QColor>
|
||||
#include <QLabel>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
@@ -60,6 +68,7 @@ ParticipantInfoDialog::ParticipantInfoDialog(int participantId, const QString &m
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::ParticipantInfoDialog)
|
||||
, m_isTarget(false)
|
||||
, m_logger(getLogger("ParticipantInfoDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_oldSpacerSize.first = m_ui->vsBottom->maximumSize().width();
|
||||
@@ -88,7 +97,7 @@ ParticipantInfoDialog::ParticipantInfoDialog(int participantId, const QString &m
|
||||
|
||||
connect(m_ui->pbUnlockUas, &QToolButton::clicked, this, &ParticipantInfoDialog::onUnlockUAS);
|
||||
|
||||
|
||||
//hide first:
|
||||
m_ui->twGear->hide();
|
||||
m_ui->lblInfo->hide();
|
||||
m_ui->lblInfoText->hide();
|
||||
@@ -164,7 +173,7 @@ bool ParticipantInfoDialog::init(LtsSession::LtsSession *session,
|
||||
connect(m_dtc.get(), &Interface::Dtc::partyChanged,
|
||||
this, &ParticipantInfoDialog::updateCurrentIcon, Qt::UniqueConnection);
|
||||
|
||||
|
||||
// to handle race condition between DynamicParticipantData and DusMineState:
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::dusMineStateChanged,
|
||||
this, &ParticipantInfoDialog::updateCurrentIcon, Qt::UniqueConnection);
|
||||
|
||||
@@ -191,19 +200,20 @@ bool ParticipantInfoDialog::init(LtsSession::LtsSession *session,
|
||||
return setUiValues();
|
||||
}
|
||||
|
||||
|
||||
// private
|
||||
bool ParticipantInfoDialog::setUiValues()
|
||||
{
|
||||
|
||||
|
||||
/* NOTE: This is a hide-all-you-don't-need concept. Everything is shown,
|
||||
* so everything you don't want to show up must be hidden.
|
||||
* Plus, once hidden, widgets must not be shown again. */
|
||||
|
||||
DEBUG_LOG(m_logger) << "------------------setUiValues-----------------";
|
||||
|
||||
if (!m_dtc || !m_ftc || m_participant.id() < 0)
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
// m_showPvSan = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantInformation"),
|
||||
// QStringLiteral("HasPvSan"));
|
||||
|
||||
m_ui->pbTarget->setVisible(false);
|
||||
|
||||
@@ -211,18 +221,18 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
m_ui->pbSetInjury->setVisible(false);
|
||||
m_ui->pbSetSanitation->setVisible(false);
|
||||
|
||||
|
||||
//hide findOnMap if no interface available
|
||||
m_ui->pbFindOnMap->setVisible(m_sitMapGuiIfc != nullptr);
|
||||
m_ui->pbMovementTrack->setVisible(m_sitMapGuiIfc != nullptr);
|
||||
m_ui->tbNbc->setVisible(false);
|
||||
m_ui->tbNbc->setVisible(false); //show only if visible
|
||||
|
||||
|
||||
// m_participant.id() was given within ctor
|
||||
const Participant participantData = m_dtc->participant(m_participant.id());
|
||||
const Type type = m_dtc->type(participantData.typeId());
|
||||
m_typeClass = type.typeClass();
|
||||
|
||||
|
||||
|
||||
// uas stuff
|
||||
const bool isUas = m_dtc->isTypeUas(participantData.typeId());
|
||||
DEBUG_LOG(m_logger) << "------------------UAS-----------------"
|
||||
<< " isTypeUas" << isUas
|
||||
@@ -241,23 +251,23 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
m_ftc->enableModifyUasState();
|
||||
}
|
||||
|
||||
|
||||
// participant might not even be linked to a uas (which isn't even obvious for the operator), so in that case default texts would be shown
|
||||
m_ui->lblBatteryStatus->setText(QStringLiteral("-"));
|
||||
m_ui->lblOperatingMode->setText(QStringLiteral("-"));
|
||||
|
||||
onUasChanged(uas);
|
||||
|
||||
|
||||
// hide all widgets (and labels) that are not available for uas:
|
||||
m_ui->pbBite->setVisible(false);
|
||||
m_ui->pbMessage->setVisible(false);
|
||||
|
||||
|
||||
// these are not supported yet, therefore hidden:
|
||||
m_ui->lblBatteryStatus->setVisible(false);
|
||||
m_ui->lbBatteryStatus->setVisible(false);
|
||||
}
|
||||
else
|
||||
else // not a uas
|
||||
{
|
||||
|
||||
// hide all uas specific widgets (and labels):
|
||||
m_ui->lblBatteryStatus->setVisible(false);
|
||||
m_ui->lbBatteryStatus->setVisible(false);
|
||||
m_ui->lblOperatingMode->setVisible(false);
|
||||
@@ -267,9 +277,9 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
|
||||
|
||||
if (m_typeClass != TypeClass::Human)
|
||||
m_ui->lbKind->setText(tr("Damage Type:"));
|
||||
m_ui->lbKind->setText(tr("Damage Type:")); // translates "Beschaedigungs" for non-Humans.
|
||||
else
|
||||
m_ui->lbKind->setText(tr("Kind:"));
|
||||
m_ui->lbKind->setText(tr("Kind:")); // translates "Verwundung" for Humans.
|
||||
|
||||
bool bUpdateDynamicParticipantData = true;
|
||||
switch (m_typeClass.underlying())
|
||||
@@ -301,7 +311,7 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
const int32_t participantId = m_participant.id();
|
||||
|
||||
m_ui->pbMovementTrack->setChecked(m_sitMapGuiIfc->isMovementTrackEnabled(participantId));
|
||||
|
||||
// set MovementTrackCallback:
|
||||
std::function<void(const QVector<int32_t> &activeSimIds)> onMovementTrackChangedFunc = [this, participantId](const QVector<int32_t> &activeSimIds)
|
||||
{
|
||||
bool checkedNew = activeSimIds.contains(participantId);
|
||||
@@ -326,7 +336,7 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
m_symbolAppearanceSettings->addChangedCallback(this);
|
||||
}
|
||||
|
||||
|
||||
//a unit never has a history
|
||||
m_ui->pbHistory->hide();
|
||||
m_ui->lblEquipNr->hide();
|
||||
m_ui->lbEquipNr->hide();
|
||||
@@ -348,7 +358,7 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
}
|
||||
case TypeClass::Vessel:
|
||||
case TypeClass::Unknown:
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << m_typeClass;
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << m_typeClass;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -376,7 +386,7 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
m_typeClass != TypeClass::Unit &&
|
||||
m_typeClass != TypeClass::SupportUnit);
|
||||
|
||||
|
||||
//other connects
|
||||
connect(m_dtc.get(), &Interface::Dtc::typeChanged,
|
||||
this, &ParticipantInfoDialog::onTypeChanged, Qt::UniqueConnection);
|
||||
connect(m_dtc.get(), &Interface::Dtc::dynamicParticipantDataChanged,
|
||||
@@ -384,9 +394,9 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
connect(m_session, &LtsSession::LtsSession::partitionTimeChanged,
|
||||
this, &ParticipantInfoDialog::onPartitionTimeChanged, Qt::UniqueConnection);
|
||||
|
||||
if (m_session->app() == LtsAppDescriptor::App::OC)
|
||||
if (m_session->app() == LtsAppDescriptor::App::OC) // is the plugin loaded by the OC-App?
|
||||
{
|
||||
|
||||
// hide several unused Buttons
|
||||
m_ui->pbBite->hide();
|
||||
m_ui->pbHistory->hide();
|
||||
m_ui->pbMessage->hide();
|
||||
@@ -395,7 +405,7 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
m_ui->pbSetSanitation->hide();
|
||||
}
|
||||
|
||||
if (m_session->isReplayPartition())
|
||||
if (m_session->isReplayPartition()) // is replay?
|
||||
{
|
||||
m_ui->pbSetStatus->hide();
|
||||
m_ui->pbMessage->hide();
|
||||
@@ -421,8 +431,8 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
m_isTarget = (eqType.wmsTypeClass() == WmsTypeClass::TargetHuman ||
|
||||
eqType.wmsTypeClass() == WmsTypeClass::TargetVehicle);
|
||||
|
||||
|
||||
|
||||
// m_isTarget = 1;
|
||||
// initTargetConfigL400(/*m_isTarget*/ true);
|
||||
|
||||
initTargetConfig(m_isTarget);
|
||||
m_ui->twGear->setColumnHidden(0, m_isTarget);
|
||||
@@ -460,20 +470,50 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Unit"));
|
||||
break;
|
||||
case TypeClass::Unknown:
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << m_typeClass;
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << m_typeClass;
|
||||
}
|
||||
|
||||
#if LTS_DEBUG
|
||||
//-- start Test Gui Elment plugin
|
||||
|
||||
auto cb = [this](const LtsPluginManager::PluginInstance &pi) { return loadGuiElementPLugin(pi);};
|
||||
LtsPluginManager::LtsPluginLoader::getInstance()->loadPlugins(LtsPluginManager::PluginType::GUI_ELEMENT,
|
||||
cb,
|
||||
QStringList());
|
||||
|
||||
//-- end Test Gui Element plugin
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParticipantInfoDialog::loadGuiElementPLugin(const LtsPluginManager::PluginInstance &pi)
|
||||
{
|
||||
WARNING_LOG(m_logger)<<">>>> GUI Element pluginName: "<<pi.fileName;
|
||||
GuiElementInterface *guiElement = qobject_cast<GuiElementInterface *>(pi.plugin);
|
||||
|
||||
if (guiElement->pluginName() == QStringLiteral("KeyValueGuiElement_XY"))
|
||||
{
|
||||
if (!guiElement->init(m_session, m_participant.id()))
|
||||
return false;
|
||||
|
||||
m_ui->gridLayout_2->addWidget(guiElement->createGuiElement(this));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
//SLOTS
|
||||
|
||||
void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicParticipantData &data, DataModification modType)
|
||||
{
|
||||
if (data.participantId() != m_participant.id() && data.participantId() != 0)
|
||||
return;
|
||||
|
||||
|
||||
|
||||
// Do not continue on modType == DataModification::eRemove
|
||||
// otherwise for example the icon would look bad (clover with black on black...)
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
if (m_ui->lblIcon != nullptr)
|
||||
@@ -484,7 +524,7 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
if (m_ui->lblIcon != nullptr)
|
||||
m_ui->lblIcon->setEnabled(true);
|
||||
|
||||
|
||||
//Current State
|
||||
qWarning() << "stateHistory count" << data.stateHistory().size();
|
||||
bool contaminationListIsEmpty = true;
|
||||
if (!data.stateHistory().empty())
|
||||
@@ -493,9 +533,9 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
ProjectDataManagement::VulnerabilityClass_def::SoldierInjuries :
|
||||
ProjectDataManagement::VulnerabilityClass_def::VehicleDamages;
|
||||
|
||||
|
||||
//#define FAKE_HISTORY
|
||||
#ifdef FAKE_HISTORY
|
||||
|
||||
// fake history, where all sis have the same stateTime
|
||||
std::vector<ParticipantManagement::StateInformation> history;
|
||||
|
||||
if (!data.stateHistory().empty())
|
||||
@@ -513,9 +553,9 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
const auto &history = data.stateHistory();
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
StateInformation lastState = m_dtc->youngestStateInformation(history );;
|
||||
//LasState is the last "real" state, that has a VBG <=8 (Castastrophic)
|
||||
//It's not the last state received, as there can be other state changes like Sanitation, or NearMiss
|
||||
StateInformation lastState = m_dtc->youngestStateInformation(history/*, true*/ /* debug */);;
|
||||
StateInformation youngestState;
|
||||
youngestState.stateTime(0);
|
||||
for (const StateInformation &si : history)
|
||||
@@ -529,14 +569,14 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// const bool showPvSan = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantInformation"),
|
||||
// QStringLiteral("HasPvSan"));
|
||||
m_ui->lblStatus->setText(ProjectDataManagement::toString(lastState.vulnerabilityState(), vc));
|
||||
|
||||
//vitality
|
||||
DEBUG_LOG(m_logger)<<" >>> last state: "<<lastState.vitality() << "last kind: " <<lastState.vulnerabilityKindId();
|
||||
m_ui->lblVitality->setText(QString::number(lastState.vitality()) + QStringLiteral("%"));
|
||||
|
||||
|
||||
// Set Contamination
|
||||
const int NCONTAMINATION = 0x4000;
|
||||
const int BCONTAMINATION = 0x8000;
|
||||
const int CCONTAMINATION = 0x10000;
|
||||
@@ -582,24 +622,24 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
}
|
||||
|
||||
m_ui->lblContamination->setText(contaminationList.join(QStringLiteral("+")));
|
||||
|
||||
|
||||
if (lastState.vulnerabilityKindId() == 459286 && !((lastState.vulnerabilityBits() >> 7) & 1))
|
||||
// VBA
|
||||
//AG 40 HACK!
|
||||
if (lastState.vulnerabilityKindId() == 459286 && !((lastState.vulnerabilityBits() >> 7) & 1)) // VBG7 NOT set in history bits, but kind id still implying that VBG7 is still active
|
||||
m_ui->lblKind->setText(QLatin1String("-"));
|
||||
else
|
||||
m_ui->lblKind->setText(m_pdmDtc->trVulnerabilityKindName(lastState.vulnerabilityKindId(), vc));
|
||||
if (m_showPvSan && vc == ProjectDataManagement::VulnerabilityClass_def::SoldierInjuries )
|
||||
{
|
||||
if (lastState.vulnerabilityState() == ProjectDataManagement::VulnerabilityState::CombatReady )
|
||||
|
||||
if (lastState.vulnerabilityState() == ProjectDataManagement::VulnerabilityState::CombatReady ) //Maybe there is some side effect to this like
|
||||
//if (data.stateHistory().size() == 1 && lastState.vulnerabilityState() == ProjectDataManagement::VulnerabilityState::CombatReady)
|
||||
{
|
||||
QPalette pal = QApplication::palette(m_ui->lbKind);
|
||||
m_ui->lblKind->setPalette(pal);
|
||||
|
||||
// m_ui->lblVitality->setText(QString::number(100) + QStringLiteral("%")); fixed in PPM-Service
|
||||
}
|
||||
else
|
||||
{
|
||||
setSanitationLabelColor(data.stateHistory().at(data.stateHistory().size()-1).sanitationResult());
|
||||
setSanitationLabelColor(/*m_dtc->proceduresDone(data.stateHistory())*/data.stateHistory().at(data.stateHistory().size()-1).sanitationResult());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -618,7 +658,7 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
DEBUG_LOG(m_logger)<< "setBackgroundColor ="<< data.manipulation().size();
|
||||
setBackgroundColor(m_ui->lblEquipNr, Qt::red, data.manipulation().size());
|
||||
|
||||
|
||||
// Special Sensor State
|
||||
if (!data.specialSensorDataState())
|
||||
{
|
||||
m_ui->stackSpecialSensor->hide();
|
||||
@@ -628,8 +668,13 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
{
|
||||
if (m_typeClass == TypeClass_def::Aircraft)
|
||||
{
|
||||
|
||||
|
||||
/*
|
||||
CTC_Apache_Sensor_DiffCorrections = 0x01, // Has GPS Differential Corrections
|
||||
CTC_Apache_Sensor_RadarJammer = 0x02, // APR 39
|
||||
CTC_Apache_Sensor_IRJammer = 0x04, // ALQ 144
|
||||
CTC_Apache_Sensor_RadarDetector = 0x08, // ALQ 136
|
||||
CTC_Apache_Sensor_LaserSensor = 0x10 // AVR2A
|
||||
*/
|
||||
|
||||
m_ui->stackSpecialSensor->setCurrentWidget(m_ui->stackPageAircraft);
|
||||
m_ui->ledRadarJammer->setStatus(data.specialSensorDataState() & 0x02);
|
||||
@@ -646,11 +691,25 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
m_ui->stackSpecialSensor->show();
|
||||
}
|
||||
|
||||
|
||||
// Gear Tabelle für Steilfeuer allgemein verstecken //[GUEZE-2871]
|
||||
bool showForArtillery = true;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
#ifndef LTS_DEBUG
|
||||
const Participant participantData = m_dtc->participant(m_participant.id());
|
||||
const Type type = m_dtc->type(participantData.typeId());
|
||||
const QString jsData = QString::fromStdString(type.properties()).trimmed();
|
||||
DEBUG_LOG(m_logger)<<">>> >>> properties: "<<jsData<<" /// typeId: "<<type.id();
|
||||
if(!jsData.isEmpty())
|
||||
{
|
||||
const QJsonObject &typObj = QJsonDocument::fromJson(QByteArray::fromStdString(jsData.toStdString())).object();
|
||||
if (!typObj.isEmpty() && typObj[QStringLiteral("isArtillery")].toBool(false))
|
||||
{
|
||||
showForArtillery = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
//Gear
|
||||
if (data.gear().size() == 0 )
|
||||
{
|
||||
m_gearList.clear();
|
||||
@@ -665,7 +724,7 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
{
|
||||
m_gearList = data.gear();
|
||||
std::vector<GearInformation> tmpGearList = m_gearList;
|
||||
std::sort(tmpGearList.begin(), tmpGearList.end(), &compareGear);
|
||||
std::sort(tmpGearList.begin(), tmpGearList.end(), &compareGear); //sort
|
||||
|
||||
m_ui->twGear->show();
|
||||
m_ui->pbGearRanges->show();
|
||||
@@ -682,7 +741,7 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
for (const GearInformation &gearInfo : tmpGearList)
|
||||
{
|
||||
QTableWidgetItem *item = nullptr;
|
||||
if (gearInfo.chargeTypeId() == 0)
|
||||
if (gearInfo.chargeTypeId() == 0) //chargTypeId 0 is near miss code
|
||||
{
|
||||
rowCount--;
|
||||
continue;
|
||||
@@ -693,8 +752,8 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
item = new QTableWidgetItem(tr("Unknown gear id %1").arg(gearTypeId & ~unknownTasId));
|
||||
else if (gearTypeId == 0)
|
||||
{
|
||||
|
||||
|
||||
// Hack for old systems which neither send gearTasCode/gearType nor gearSerialNumber/gearId
|
||||
// 1 = Wanne, 2 = Turm
|
||||
switch (gearInfo.gearId())
|
||||
{
|
||||
case 1:
|
||||
@@ -717,27 +776,27 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
{
|
||||
item->setIcon(QIcon(QLatin1String("icon:service.svg")));
|
||||
}
|
||||
|
||||
// If it's the same gearId, don't set the item, but make a row span to the one(s) before.
|
||||
int rowStart = row - 1;
|
||||
while (rowStart >= 0)
|
||||
{
|
||||
QTableWidgetItem *oldItem = m_ui->twGear->item(rowStart, 0);
|
||||
if (oldItem == nullptr)
|
||||
QTableWidgetItem *oldItem = m_ui->twGear->item(rowStart, 0); //Item above
|
||||
if (oldItem == nullptr)// not set due to rowSpan...
|
||||
break;
|
||||
if (oldItem->data(Qt::UserRole).toInt() != gearInfo.gearId() ||
|
||||
oldItem->text() != item->text())
|
||||
if (oldItem->data(Qt::UserRole).toInt() != gearInfo.gearId() || // Different gearId
|
||||
oldItem->text() != item->text()) // Different Text (if gearId not set...)
|
||||
break;
|
||||
--rowStart;
|
||||
}
|
||||
if (rowStart + 1 < row)
|
||||
{
|
||||
m_ui->twGear->setItem(row, 0, item);
|
||||
m_ui->twGear->setItem(row, 0, item); //Need to be set, because of the check above
|
||||
m_ui->twGear->setSpan(rowStart + 1, 0, row - rowStart, 1);
|
||||
}
|
||||
else
|
||||
m_ui->twGear->setItem(row, 0, item);
|
||||
|
||||
if (gearInfo.chargeTypeId() != 0 && gearInfo.chargeTypeId() != -1)
|
||||
if (gearInfo.chargeTypeId() != 0 && gearInfo.chargeTypeId() != -1) // hat Charge (and ignore only chargecounts)
|
||||
{
|
||||
int chargeTypeId = gearInfo.chargeTypeId();
|
||||
if ((chargeTypeId & unknownTasId) == unknownTasId)
|
||||
@@ -750,12 +809,12 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
item->setToolTip(m_pdmDtc->trChargeTypeName(chargeTypeId, true));
|
||||
}
|
||||
m_ui->twGear->setItem(row, 1, item);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//ressourceCount
|
||||
//: Blank in this case refers to blank ammunition used for training
|
||||
// Chris didn't wanted the chargeCounting Flag like: If they don't make it right why should we do it?
|
||||
// presevred old mode so just in case..
|
||||
//UAE wepaons don't send needed telegrams.. so let's hack again..
|
||||
// in order to avoid the faulty SALTs let's hope they never send remaining ammunition below 100...
|
||||
#ifdef GUEZ_MODE
|
||||
item = new QTableWidgetItem((gearInfo.remain() < 0) ? tr("N/A", "Blank Ammunition") : QString::number(gearInfo.remain()));
|
||||
#else
|
||||
@@ -780,13 +839,13 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
}
|
||||
m_ui->twGear->setRowCount(rowCount);
|
||||
m_ui->twGear->resizeColumnsToContents();
|
||||
|
||||
// Avoid shrinking last column (2): It'll auto-stretch afterwards
|
||||
m_ui->twGear->horizontalHeader()->resizeSection(2, 42);
|
||||
|
||||
m_ui->twGear->setColumnHidden(0, m_isTarget);
|
||||
m_ui->twGear->setColumnHidden(1, m_isTarget);
|
||||
|
||||
}
|
||||
} //end Gear
|
||||
if (!showForArtillery)
|
||||
{
|
||||
m_ui->twGear->hide();
|
||||
@@ -797,7 +856,7 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
DEBUG_LOG(m_logger) << "### data.participantId(): " << data.participantId();
|
||||
DEBUG_LOG(m_logger) << "### data.sampleTime(): " << data.sampleTime();
|
||||
|
||||
|
||||
//sanMat
|
||||
if (data.sanitationMaterialStock().size() == 0)
|
||||
{
|
||||
m_sanMatStock.clear();
|
||||
@@ -817,7 +876,7 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
m_sanMatStock = data.sanitationMaterialStock();
|
||||
std::vector<SanitationMaterial> tmpSanMatStock = m_sanMatStock;
|
||||
|
||||
std::sort(tmpSanMatStock.begin(), tmpSanMatStock.end(), &compareSanMat);
|
||||
std::sort(tmpSanMatStock.begin(), tmpSanMatStock.end(), &compareSanMat); //sort
|
||||
|
||||
m_ui->twSanMat->clearContents();
|
||||
|
||||
@@ -942,7 +1001,7 @@ void ParticipantInfoDialog::showSpecialSensorData(int specialSensorData)
|
||||
if ((specialSensorData & (1 << 11)) != 0)
|
||||
strSpecialSensorData += QStringLiteral(" F");
|
||||
|
||||
if (specialSensorDataState == 66)
|
||||
if (specialSensorDataState == 66) // CSF Spürbetrieb
|
||||
{
|
||||
const int type = (specialSensorData >> 12) & 0x0F;
|
||||
strSpecialSensorData += QLatin1Char(' ');
|
||||
@@ -974,7 +1033,7 @@ void ParticipantInfoDialog::showSpecialSensorData(int specialSensorData)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (type == 4)
|
||||
if (type == 4) // CSF
|
||||
{
|
||||
const int nbcType = (specialSensorData >> 16) & 0x03;
|
||||
strSpecialSensorData += QLatin1Char(' ');
|
||||
@@ -1023,7 +1082,7 @@ void ParticipantInfoDialog::onPositionChanged(const ParticipantPosition &positio
|
||||
{
|
||||
if (room.id() == position.roomId())
|
||||
{
|
||||
|
||||
// In the case of external OPS transmitters, the building name was output twice
|
||||
if ( room.structureElementTypeId() != InfrastructureManagement::StructureElementType_def::Room )
|
||||
continue;
|
||||
roomName = QString::fromStdString(room.displayName());
|
||||
@@ -1060,7 +1119,7 @@ void ParticipantInfoDialog::onPositionChanged(const ParticipantPosition &positio
|
||||
connect(m_ui->pbMounted, &QToolButton::clicked, this, &ParticipantInfoDialog::onMountedParticipants);
|
||||
}
|
||||
|
||||
|
||||
// hide button when both are not set
|
||||
if (!position.mountedOn().is_set() && !position.mountedParticipants().is_set())
|
||||
m_ui->pbMounted->hide();
|
||||
|
||||
@@ -1112,8 +1171,8 @@ void ParticipantInfoDialog::onParticipantChanged(const Participant &participant,
|
||||
if (participant.id() != m_participant.id())
|
||||
return;
|
||||
|
||||
|
||||
|
||||
// Do not continue on modType == DataModification::eRemove
|
||||
// otherwise for example the icon would look bad (clover with black on black...)
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
|
||||
@@ -1121,7 +1180,7 @@ void ParticipantInfoDialog::onParticipantChanged(const Participant &participant,
|
||||
{
|
||||
m_ui->lblType->setText(ParticipantManagement::trTypeName(m_dtc->type(participant.typeId()).name()));
|
||||
TypeClass typeClass = m_dtc->type(participant.typeId()).typeClass();
|
||||
|
||||
// If TypeClass changes, close window. Shouldn't ever happen, but for initialization.
|
||||
if (m_typeClass != TypeClass_def::Unknown && m_typeClass != typeClass)
|
||||
{
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Close)->click();
|
||||
@@ -1146,7 +1205,7 @@ void ParticipantInfoDialog::onParticipantChanged(const Participant &participant,
|
||||
m_ui->lblEquipNr->setToolTip(QString::number(m_participant.id()));
|
||||
#endif
|
||||
|
||||
|
||||
//hide Info if not exists
|
||||
m_ui->lblInfoText->setText(QString::fromStdString(m_participant.info()));
|
||||
m_ui->lblInfoText->setVisible(m_participant.info().size() > 0);
|
||||
m_ui->lblInfo->setVisible(m_participant.info().size() > 0);
|
||||
@@ -1222,8 +1281,8 @@ void ParticipantInfoDialog::setSanitationLabelColor(SanitationResult proceduresD
|
||||
|
||||
void ParticipantInfoDialog::setKindVisible(bool bVisible)
|
||||
{
|
||||
|
||||
|
||||
// const bool showVulnerabilityKindProject = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantInformation"),
|
||||
// QStringLiteral("ShowVulnerabilityKind"));
|
||||
if (!m_showVulnerabilityKindProject)
|
||||
bVisible = false;
|
||||
|
||||
@@ -1231,8 +1290,12 @@ void ParticipantInfoDialog::setKindVisible(bool bVisible)
|
||||
m_ui->lbKind->setVisible(bVisible);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \brief ParticipantInfoDialog::setBottomSpacerVisibility
|
||||
* \param isOneListActive
|
||||
* \details If Weapon Table or/and SanMat table is visible -> Hide Bottom Spacer
|
||||
* \author Niklas Schmidt
|
||||
*/
|
||||
void ParticipantInfoDialog::setBottomSpacerVisibility(bool isOneListActive)
|
||||
{
|
||||
|
||||
@@ -1300,7 +1363,7 @@ void ParticipantInfoDialog::setBackgroundColor(QWidget *w, Qt::GlobalColor col
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// reset to default palette
|
||||
w->setPalette(QApplication::palette(w));
|
||||
w->setAutoFillBackground(false);
|
||||
}
|
||||
@@ -1338,14 +1401,14 @@ void ParticipantInfoDialog::onOpenHistory()
|
||||
if (!m_aesDtc)
|
||||
return;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// {
|
||||
// ParticipantTargetConfigurationDialog* diag = new ParticipantTargetConfigurationDialog(this);
|
||||
// if (diag->init(m_participant.id(), m_dtc, m_ftc, /*m_pdmDtc,*/ m_sitMapGuiIfc))
|
||||
// addDialog(diag, m_menuGroup, QStringLiteral("ParticipantHistory") + QString::number(m_participant.id()), LtsWidgets::LayoutArea::eDialogTab);
|
||||
// else
|
||||
// delete diag;
|
||||
// }
|
||||
// return;
|
||||
|
||||
|
||||
ParticipantHistoryDialog *diag = new ParticipantHistoryDialog(this);
|
||||
@@ -1431,9 +1494,9 @@ void ParticipantInfoDialog::onGearRanges()
|
||||
m_sitMapGuiIfc->enableGearRanges(m_participant.id(), m_ui->pbGearRanges->isChecked());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////
|
||||
/// Target
|
||||
///////////////////////////////////////////////
|
||||
bool ParticipantInfoDialog::initTargetConfig(bool bShow)
|
||||
{
|
||||
if (bShow)
|
||||
@@ -1443,13 +1506,13 @@ bool ParticipantInfoDialog::initTargetConfig(bool bShow)
|
||||
m_ui->pbSetInjury->hide();
|
||||
m_ui->pbSetSanitation->hide();
|
||||
|
||||
|
||||
|
||||
// Combobox Weapon:
|
||||
// TODO woher kommen die Waffen?
|
||||
m_ui->cbTargetWeapon->addItem(QStringLiteral("AK47"), 1);
|
||||
m_ui->cbTargetWeapon->addItem(QStringLiteral("Pistol"), 5);
|
||||
m_ui->cbTargetWeapon->addItem(QStringLiteral("Shotgun"), 7);
|
||||
|
||||
|
||||
// Combobox Mode:
|
||||
m_ui->cbTargetMode->addItem(TargetManagement::toString(TargetManagement::Mode_def::Deactivated),
|
||||
TargetManagement::Mode_def::Deactivated);
|
||||
m_ui->cbTargetMode->addItem(TargetManagement::toString(TargetManagement::Mode_def::ShootBack),
|
||||
@@ -1515,7 +1578,7 @@ void ParticipantInfoDialog::onTargetConfig()
|
||||
return m_tgtFtc->configureTargetRequest(request, this);
|
||||
};
|
||||
m_requestHelper->startSingleRequest(cb);
|
||||
}
|
||||
} // end of onTargetConfig
|
||||
|
||||
void ParticipantInfoDialog::onTargetConfigChanged(const TargetManagement::TargetConfig &data, DataModification modType)
|
||||
{
|
||||
@@ -1532,7 +1595,7 @@ void ParticipantInfoDialog::onTargetConfigChanged(const TargetManagement::Target
|
||||
m_ui->cbTargetWeapon->setVisible(true);
|
||||
m_ui->cbTargetMode->setCurrentIndex(m_ui->cbTargetMode->findData(data.mode().underlying()));
|
||||
m_ui->cbTargetWeapon->setCurrentIndex(m_ui->cbTargetWeapon->findData(data.weapon()));
|
||||
}
|
||||
} // end of onTargetConfigChanged
|
||||
|
||||
void ParticipantInfoDialog::onTargetModeChangeed()
|
||||
{
|
||||
@@ -1577,7 +1640,7 @@ void ParticipantInfoDialog::onTargetWeaponChanged()
|
||||
|
||||
void ParticipantInfoDialog::onOpenTargetConfigurationL400()
|
||||
{
|
||||
|
||||
// ParticipantTargetConfigurationDialog -> L400
|
||||
ParticipantTargetConfigurationDialog* diag = new ParticipantTargetConfigurationDialog(this);
|
||||
if (diag->init(m_participant.id(), m_dtc, m_ftc, m_sitMapGuiIfc))
|
||||
addDialog(diag, m_menuGroup, QStringLiteral("TargetConfigurationL400") + QString::number(m_participant.id()), LtsWidgets::LayoutArea::eDialogTab);
|
||||
@@ -1606,12 +1669,12 @@ void ParticipantInfoDialog::onContextMenuRequested(const QPoint &position)
|
||||
actions << restockNowAction;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// if (m_pdmDtc->canSetDefaults(gear.gearTypeId()))
|
||||
// {
|
||||
// QAction *restockDefaultsAction = new QAction(tr("Restock Defaults"), this);
|
||||
// connect(restockDefaultsAction, &QAction::triggered, this, [=](){ onRestockDefaults(gear.gearId(), gear.gearTypeId()); });
|
||||
// actions << restockDefaultsAction;
|
||||
// }
|
||||
|
||||
if (actions.isEmpty())
|
||||
return;
|
||||
@@ -1641,25 +1704,25 @@ void ParticipantInfoDialog::onRestockDefaults(int gearId, int gearTypeId)
|
||||
|
||||
void ParticipantInfoDialog::onUasChanged(const UAS &uas)
|
||||
{
|
||||
|
||||
// check if changed uas is this uas, on this participant, in this exercise
|
||||
if (uas.id() != m_uasId || uas.exerciseId() != m_session->exerciseId() || uas.participantId() != m_participant.id())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// set text & text color for uas operating mode
|
||||
const QString operatingMode(ProjectDataManagement::toString(uas.uasState()));
|
||||
static const QString textHtml { QStringLiteral("<font color='%1'>%2</font>") };
|
||||
|
||||
switch (uas.uasState().underlying())
|
||||
{
|
||||
case ProjectDataManagement::UasState::UasState_Auto:
|
||||
case ProjectDataManagement::UasState::Auto:
|
||||
{
|
||||
m_ui->lblOperatingMode->setText(textHtml.arg(QStringLiteral("green")).arg(operatingMode));
|
||||
break;
|
||||
}
|
||||
|
||||
case ProjectDataManagement::UasState::UasState_Manual:
|
||||
case ProjectDataManagement::UasState::Manual:
|
||||
{
|
||||
m_ui->lblOperatingMode->setText(textHtml.arg(QStringLiteral("orange")).arg(operatingMode));
|
||||
break;
|
||||
@@ -1700,4 +1763,4 @@ void ParticipantInfoDialog::onUnlockUAS()
|
||||
m_requestHelper->startSingleRequest(cb);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ParticipantManagement
|
||||
+31
-25
@@ -1,23 +1,29 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ParticipantManagement - TlnInfoDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
//Lts
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
|
||||
#include <AdvancedSymbology/asb_data_plugin_interface.h>
|
||||
|
||||
//Asb
|
||||
#include <Plugins/AdvancedSymbology/asb_data_plugin_interface.h>
|
||||
|
||||
|
||||
//ParticipantManagement
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <ParticipantManagement/ppm_participant_info_gui_plugin_interface.h>
|
||||
|
||||
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
//DDS
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <ParticipantManagement/ppm_ftc.h>
|
||||
#include <ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
|
||||
@@ -26,18 +32,18 @@
|
||||
#include <FilterManagement/flt_participant_plugin_interface.h>
|
||||
#include <FilterManagement/flt_symbol_appearance_settings.h>
|
||||
|
||||
//SituationMap
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
|
||||
#include <SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
|
||||
|
||||
//AES
|
||||
#include <AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
|
||||
|
||||
// TargetManagement
|
||||
#include <TargetManagement/tgt_dtc.h>
|
||||
#include <TargetManagement/tgt_ftc.h>
|
||||
#include <TargetManagement/tgt_ftc_types.h>
|
||||
|
||||
|
||||
//Qt
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -54,9 +60,9 @@ namespace ParticipantManagement
|
||||
|
||||
class ParticipantInfoLtdGearComponent;
|
||||
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------
|
||||
// ParticipantInfoDialog
|
||||
// --------------------------------------------------------
|
||||
class ParticipantInfoDialog final : public LtsWidgets::LtsDialog
|
||||
, protected FilterManagement::SymbolAppearanceSettings::SettingsChangedCallback
|
||||
, protected TargetManagement::Interface::Ftc::ConfigureTargetReplyHandler
|
||||
@@ -85,7 +91,6 @@ signals:
|
||||
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
bool setUiValues();
|
||||
static void setBackgroundColor(QWidget *w, Qt::GlobalColor color, bool bSetColor);
|
||||
@@ -101,10 +106,11 @@ private:
|
||||
void setMessageVisible(bool bVisible);
|
||||
void onSymbolAppearanceSettingsChanged(FilterManagement::SymbolAppearanceSettings::Part part) override;
|
||||
QString approachingAngle(const QPointF ¢erPoint, double direction, double distance, int mseId) const;
|
||||
|
||||
// Target (Qatar?)
|
||||
bool initTargetConfig(bool bShow);
|
||||
|
||||
// Target (L400)
|
||||
bool initTargetConfigL400(bool bShow);
|
||||
bool loadGuiElementPLugin(const LtsPluginManager::PluginInstance &pi);
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
@@ -137,19 +143,18 @@ private Q_SLOTS:
|
||||
void onRestockDefaults(int gearId,int gearTypeId);
|
||||
void onRestockNow(int gearId,int gearTypeId);
|
||||
|
||||
|
||||
// Target (Qatar?)
|
||||
void onTargetConfig();
|
||||
void onTargetConfigChanged(const TargetManagement::TargetConfig &data, DataModification modType);
|
||||
void onTargetModeChangeed();
|
||||
void onTargetWeaponChanged();
|
||||
|
||||
|
||||
// Target (L400)
|
||||
void onOpenTargetConfigurationL400();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
Participant m_participant;
|
||||
int m_uasId;
|
||||
int m_uasId; // Needed to release uas again.
|
||||
qint64 m_lastPositionMSec;
|
||||
TypeClass m_typeClass;
|
||||
std::vector<GearInformation> m_gearList;
|
||||
@@ -181,5 +186,6 @@ private:
|
||||
bool m_isTarget;
|
||||
bool m_showPvSan{false};
|
||||
bool m_showVulnerabilityKindProject{false};
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
}
|
||||
} // namespace ParticipantInfo
|
||||
+30
-23
@@ -1,20 +1,26 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ParticipantManagement - Party Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-11-11
|
||||
*/
|
||||
|
||||
#include "ppm_party_edit.h"
|
||||
#include "NGLLogger/INGLLogger.h"
|
||||
#include "ui_ppm_party_edit.h"
|
||||
|
||||
#include <QtWidgets/QColorDialog>
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtCore/QJsonArray>
|
||||
#include <QtWidgets/QMessageBox>
|
||||
#include <QColorDialog>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QMessageBox>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <AreaEffectSimulation/aes_operator_rights.h>
|
||||
#include <Services/AreaEffectSimulation/aes_operator_rights.h>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
@@ -34,20 +40,21 @@ PartyEdit::PartyEdit(QWidget *parent)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_session(nullptr)
|
||||
, m_ui(new Ui::PartyEdit)
|
||||
, m_logger(getLogger("PartyEdit"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
PartyEdit::~PartyEdit()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void PartyEdit::retranslate()
|
||||
{
|
||||
translate(m_ui, m_dtc->party(m_partyId), tr("Party"));
|
||||
translate(m_ui, m_dtc->party(m_partyId), trPartyName(m_dtc->party(m_partyId).name()), tr("Party"));
|
||||
m_ppmGuiCbxIfc->fillRoleComboBox(m_ui->cbRole);
|
||||
m_ppmGuiCbxIfc->fillHlaForceIdentifierComboBox(m_ui->cbHlaForceIdentifier);
|
||||
}
|
||||
@@ -88,7 +95,7 @@ bool PartyEdit::init(int partyId, LtsSession::LtsSession *session)
|
||||
|
||||
m_ppmGuiCbxIfc->fillRoleComboBox(m_ui->cbRole);
|
||||
m_ppmGuiCbxIfc->fillHlaForceIdentifierComboBox(m_ui->cbHlaForceIdentifier);
|
||||
if (m_partyId >= 0)
|
||||
if (m_partyId >= 0) // pool has id 0 so is a valid party
|
||||
{
|
||||
const Party &party = m_dtc->party(m_partyId);
|
||||
if(party.id() >= 0)
|
||||
@@ -107,7 +114,7 @@ bool PartyEdit::init(int partyId, LtsSession::LtsSession *session)
|
||||
m_ui->cbHlaForceIdentifier->hide();
|
||||
}
|
||||
|
||||
|
||||
// Could be filled programmatically later
|
||||
m_ui->cbAdlerNotification->setProperty("Notification", NotificationManagement::NotificationType::AdlerNotification);
|
||||
m_ui->cbCombatOrder->setProperty("Notification", NotificationManagement::NotificationType::CombatOrder);
|
||||
|
||||
@@ -132,7 +139,7 @@ bool PartyEdit::init(int partyId, LtsSession::LtsSession *session)
|
||||
connect(m_ui->tbResetAdlerConnection, &QToolButton::clicked, this, &PartyEdit::onResetAdlerConnectionClicked);
|
||||
connect(m_dtc.get(), &ParticipantManagement::Interface::Dtc::partyChanged, this, &PartyEdit::onPartyChanged);
|
||||
|
||||
|
||||
// check Notifications
|
||||
notificationCheck();
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Parties"));
|
||||
@@ -140,7 +147,7 @@ bool PartyEdit::init(int partyId, LtsSession::LtsSession *session)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//slots
|
||||
bool PartyEdit::apply()
|
||||
{
|
||||
if (!m_partiallyUnchangeable)
|
||||
@@ -253,7 +260,7 @@ void PartyEdit::onPartyChanged(const Party &data, DataModification modType)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//private
|
||||
|
||||
void PartyEdit::setData(const Party &party)
|
||||
{
|
||||
@@ -269,7 +276,7 @@ void PartyEdit::setData(const Party &party)
|
||||
|
||||
void PartyEdit::setColorToButton(QToolButton *button, const QColor &color)
|
||||
{
|
||||
button->setStyleSheet(QStringLiteral("QToolButton{ background: %1; }").arg(color.name()));
|
||||
button->setStyleSheet(QStringLiteral("QToolButton{ background: %1; }").arg(color.name())); // TODO: muss das sein?
|
||||
}
|
||||
|
||||
void PartyEdit::fillJsonSuppressNotifications( QJsonArray ¬if, NotificationManagement::NotificationType notifType)
|
||||
@@ -381,8 +388,8 @@ void PartyEdit::notificationCheck()
|
||||
m_ui->cbAdlerNotification->setCheckState(Qt::Checked);
|
||||
m_ui->cbCombatOrder->setCheckState(Qt::Checked);
|
||||
|
||||
|
||||
|
||||
// Here add another NotificationType, everything else will happen automatically
|
||||
// CheckBox insert in Ui
|
||||
const QList<NotificationManagement::NotificationType> notifTypes { NotificationManagement::NotificationType_def::AdlerNotification,
|
||||
NotificationManagement::NotificationType_def::CombatOrder};
|
||||
|
||||
@@ -407,11 +414,11 @@ void PartyEdit::notificationCheck()
|
||||
|
||||
void PartyEdit::modifyPartyProperties()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO;
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION;
|
||||
|
||||
ParticipantManagement::Party requestParty;
|
||||
requestParty = m_dtc->party(m_partyId);
|
||||
|
||||
// Get properties and then update them
|
||||
const QJsonObject &origObj = QJsonDocument::fromJson(requestParty.properties().c_str()).object();
|
||||
QJsonObject adlerPropertiesObj = origObj[QStringLiteral("Adler")].toObject();
|
||||
adlerPropertiesObj[QStringLiteral("saaConnectedState")] = ParticipantManagement::ConnectState::Disconnecting;
|
||||
|
||||
+22
-18
@@ -1,20 +1,26 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ParticipantManagement - Party Overview Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-11-11
|
||||
*/
|
||||
|
||||
#include "ppm_party_model.h"
|
||||
#include <OperatorManagement/opm_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <QtGui/QColor>
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QColor>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
//---------------------------------
|
||||
// PartyModel
|
||||
//---------------------------------
|
||||
PartyModel::PartyModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<ParticipantManagement::Party>({tr("Id"),
|
||||
tr("Name"),
|
||||
@@ -27,6 +33,7 @@ PartyModel::PartyModel(QObject *parent)
|
||||
tr("Szenar Name")},
|
||||
parent)
|
||||
, m_ppmDtc(nullptr)
|
||||
, m_logger(getLogger("PartyModel"))
|
||||
{}
|
||||
|
||||
bool PartyModel::initModel(LtsSession::LtsSession *session)
|
||||
@@ -49,7 +56,7 @@ bool PartyModel::initModel(LtsSession::LtsSession *session)
|
||||
m_operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
m_ppmDtc->partys([this](const ParticipantManagement::Party &party)
|
||||
{
|
||||
if (hasParty(party))
|
||||
if (hasParty(party)) // opm_operator_exercise -> visible_parties
|
||||
insertRow(party);
|
||||
});
|
||||
return true;
|
||||
@@ -98,14 +105,11 @@ QVariant PartyModel::data(const QModelIndex &index, int role) const
|
||||
QString connectState;
|
||||
switch (status.underlying())
|
||||
{
|
||||
case ParticipantManagement::ConnectState::Connected:
|
||||
connectState = tr("Connected");
|
||||
break;
|
||||
case ParticipantManagement::ConnectState::NoHeartbeat:
|
||||
connectState = tr("No Heartbeat");
|
||||
case ParticipantManagement::ConnectState::Undefined:
|
||||
connectState = QStringLiteral("");
|
||||
break;
|
||||
default:
|
||||
connectState = QStringLiteral("");
|
||||
connectState = ParticipantManagement::toString(status);
|
||||
break;
|
||||
}
|
||||
return connectState;
|
||||
@@ -150,7 +154,7 @@ bool PartyModel::hasParty(const Party &party) const
|
||||
{
|
||||
if (exerciseParties.exerciseId() != m_session->exerciseId())
|
||||
continue;
|
||||
if (!exerciseParties.visibleParties().is_set())
|
||||
if (!exerciseParties.visibleParties().is_set()) //has_value not support on windows yet so we need depricated is_set
|
||||
return false;
|
||||
for (const auto &partyId : exerciseParties.visibleParties().get())
|
||||
if (partyId == party.id())
|
||||
@@ -167,7 +171,7 @@ bool PartyModel::isPartyHidden(const Party &party) const
|
||||
{
|
||||
if (exerciseParties.exerciseId() != m_session->exerciseId())
|
||||
continue;
|
||||
if (!exerciseParties.hiddenParties().is_set())
|
||||
if (!exerciseParties.hiddenParties().is_set()) //has_value not support on windows yet so we need depricated is_set
|
||||
return false;
|
||||
for (const auto &partyId : exerciseParties.hiddenParties().get())
|
||||
if (partyId == party.id())
|
||||
@@ -176,4 +180,4 @@ bool PartyModel::isPartyHidden(const Party &party) const
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} // namespace ParticipantManagement
|
||||
+55
-46
@@ -1,5 +1,12 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* PresentationManagement - Script Editor
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-03-17
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -7,29 +14,29 @@
|
||||
#include "pre_journal_types.h"
|
||||
#include "pre_utils.h"
|
||||
|
||||
#include <Core/core_dtc.h>
|
||||
#include <DDS/Core/core_dtc.h>
|
||||
#include <LtsPluginManager/lts_plugin_manager.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <PluginInterfaces/topic_replay_interface.h>
|
||||
#include <PresentationManagement/Common/topic_assignment.h>
|
||||
#include <SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <SituationReplay/srp_gui_plugin_interface.h>
|
||||
#include <OperatorManagement/opm_dtc.h>
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
#include <PresentationManagement/pre_dtc.h>
|
||||
#include <PresentationManagement/pre_ftc.h>
|
||||
#include <SituationReplayManagement/srm_ftc.h>
|
||||
#include <Plugins/PresentationManagement/Gui/Common/topic_assignment.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <Plugins/SituationReplay/srp_gui_plugin_interface.h>
|
||||
#include <Services/OperatorManagement/opm_dtc.h>
|
||||
#include <Services/ExerciseManagement/exm_dtc.h>
|
||||
#include <Services/PresentationManagement/pre_dtc.h>
|
||||
#include <Services/PresentationManagement/pre_ftc.h>
|
||||
#include <Services/SituationReplayManagement/srm_ftc.h>
|
||||
#include <TopicEditorBase/topic_editor_utils.h>
|
||||
#include <LtsWidgets/lts_overlay_loading.h>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QMap>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QMap>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
|
||||
@@ -60,13 +67,13 @@ class CoolExporter;
|
||||
namespace Interface { class Ftc; }
|
||||
|
||||
|
||||
|
||||
//template<typename Type = void *>
|
||||
class Scope
|
||||
{
|
||||
public:
|
||||
explicit Scope(const std::function<void (void)> &ctor, const std::function<void (void)> &dtor)
|
||||
|
||||
|
||||
//: m_fn(fn)
|
||||
//: m_data(ctor())
|
||||
: m_dtor(dtor)
|
||||
{
|
||||
ctor();
|
||||
@@ -77,15 +84,15 @@ public:
|
||||
m_dtor();
|
||||
}
|
||||
|
||||
// Scope(const std::function<Type (void)> &ctor, const std::function<void (Type)> &dtor)
|
||||
// //: m_fn(fn)
|
||||
// : m_data({})
|
||||
// {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// }
|
||||
|
||||
private:
|
||||
|
||||
//Type m_data;
|
||||
std::function<void (void)> m_dtor;
|
||||
};
|
||||
|
||||
@@ -148,7 +155,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// LtsDialog override
|
||||
void retranslate() override;
|
||||
bool apply() override;
|
||||
void aboutToClose() override;
|
||||
@@ -163,16 +170,16 @@ private:
|
||||
);
|
||||
bool getTopicItems();
|
||||
void getSitMapApp() noexcept(false);
|
||||
void getPresentationContent();
|
||||
void getPresentationContent(); // tryAddTopics has to be called first to populate m_topicAssignments
|
||||
void getProjectionWidget(Screen **pointerToWidgetPointer, bool placeAutomatically = false);
|
||||
|
||||
|
||||
// dds stuff
|
||||
bool enableFireEventFlash(bool enable);
|
||||
|
||||
|
||||
// io stuff
|
||||
void exportPresentationContent(const Core::FunctionReply &baseReply);
|
||||
|
||||
|
||||
// ui stuff
|
||||
void disableSessionDialog(LtsSession::LtsSession *session, bool disable);
|
||||
void startEssentialsViewStage2(const Core::ReplayPartition &replay, bool openTopicEditor, int topicType, int topicItemId);
|
||||
static bool hasEssentialsViewTopicType(TopicEditorBase::TopicType topicType);
|
||||
@@ -192,15 +199,15 @@ private:
|
||||
void enaDisa();
|
||||
void startEssentialsView(int topicItemId = -1, int topicType = -1, bool openTopicEditor = false);
|
||||
|
||||
|
||||
// topic stuff
|
||||
void openContextMenu(QPoint pos, int topicItemId);
|
||||
void setTopicDescription(int topicItemId);
|
||||
void enableTopicEditors(bool enable);
|
||||
|
||||
|
||||
// replay stuff
|
||||
qint64 positionTime() const;
|
||||
void setPositionTime(qint64 time, bool setByUser = false);
|
||||
void setPositionTimeActive(qint64 time, bool setByUser = false);
|
||||
void setPositionTimeActive(qint64 time, bool setByUser = false); // setPositionTime, but, if playing, also ticks and resets timeout
|
||||
void playTopic(int topicItemId);
|
||||
void pause();
|
||||
void stop(bool ended = false, bool ignoreFireEventFlashing = false);
|
||||
@@ -208,7 +215,7 @@ private:
|
||||
qint64 nextTopicTime() const;
|
||||
bool hasPreviousTopic() const { return previousTopicTime() > -1; }
|
||||
bool hasNextTopic() const { return nextTopicTime() > -1; }
|
||||
void removeTopicItemFromPlaylist(int topicItemId);
|
||||
void removeTopicItemFromPlaylist(int topicItemId); // WARNING: use a mutable iterator while iterating over m_currentlyPlayingTopics and remove the entry before calling this method!
|
||||
|
||||
bool isTopicAlreadyOpened(const TopicEditorBase::TopicData &data);
|
||||
template <typename TopicEditorInterface>
|
||||
@@ -252,7 +259,7 @@ private:
|
||||
QStringList &resultList,
|
||||
const SpecialTopicType &specialTopicType = SpecialTopicType::Normal)
|
||||
{
|
||||
|
||||
// qWarning() << "mep" << QStringLiteral("%1:%2").arg(QString::fromUtf8(__FILE__).split(QStringLiteral("/")).last()).arg(__LINE__);
|
||||
|
||||
if (isTopicDisabled(topicType))
|
||||
return true;
|
||||
@@ -307,7 +314,7 @@ private slots:
|
||||
void onDiscard();
|
||||
void onNull(QObject *obj);
|
||||
|
||||
|
||||
// io stuff
|
||||
void onLoad();
|
||||
void onExport();
|
||||
void onExport2();
|
||||
@@ -315,7 +322,7 @@ private slots:
|
||||
void onBurnDvD(const QString &strExportPath);
|
||||
void onBurningFinished(bool success);
|
||||
|
||||
|
||||
// ui stuff
|
||||
void onPresentationContent(const GetPresentationContentReply &reply);
|
||||
void onEssentialsView();
|
||||
void onTopicItemPositionChanged(QWidget *previewWidget, int ignoreTopicForReplay);
|
||||
@@ -327,16 +334,16 @@ private slots:
|
||||
void onTopicDesignerChangesMade();
|
||||
void onTopicEditorChangesSaved(const TopicEditorBase::TopicData &data);
|
||||
|
||||
|
||||
// topic stuff
|
||||
void onGetTopicEditor(const TopicEditorBase::TopicData &data);
|
||||
void onEditSelectedTopicItem();
|
||||
void onEditTopicItem(int itemId);
|
||||
void onRemoveSelectedTopics();
|
||||
void onContextMenu(QPoint pos);
|
||||
// void onMergeTopics();
|
||||
// void onSplitTopic();
|
||||
|
||||
|
||||
|
||||
|
||||
// replay stuff
|
||||
void onTimeout();
|
||||
void onPlay();
|
||||
void onPause();
|
||||
@@ -348,7 +355,7 @@ private slots:
|
||||
void onShowStoryboard();
|
||||
void onShowJournal();
|
||||
|
||||
|
||||
// other stuff
|
||||
bool checkBuildingViewerAndEssentialsView();
|
||||
|
||||
signals:
|
||||
@@ -358,14 +365,14 @@ signals:
|
||||
void scriptTick(qint64 positionTime);
|
||||
|
||||
private:
|
||||
LtsSession::LtsSession *m_exerciseSession { nullptr };
|
||||
LtsSession::LtsSession *m_exerciseSession { nullptr }; // aka. script editor app
|
||||
LtsSession::LtsSession *m_replaySession { nullptr };
|
||||
LtsSession::LtsSession *m_sitMapSession { nullptr };
|
||||
LtsSession::LtsSession *m_essentialsViewSession { nullptr };
|
||||
LtsPluginManager::LtsPluginManager *m_essentialsViewApp { nullptr };
|
||||
LtsPluginManager::LtsPluginManager *m_sitMapApp { nullptr };
|
||||
LtsUtils::RequestHelper *m_requestHelper { nullptr };
|
||||
TakeHomePackageGenerator::ExportProcess *m_exportProcess { nullptr };
|
||||
TakeHomePackageGenerator::ExportProcess *m_exportProcess { nullptr }; // OLD exporter!
|
||||
|
||||
std::shared_ptr<Core::Interface::Dtc> m_coreDtc { nullptr };
|
||||
std::shared_ptr<PresentationManagement::Interface::Dtc> m_dtc { nullptr };
|
||||
@@ -402,7 +409,7 @@ private:
|
||||
int m_selectedTeId;
|
||||
QMap<QString, TopicAssignment> m_topicAssignments;
|
||||
QMap<TopicEditorBase::TopicType, TopicAssignment> m_trackEntryToTopicAssignment;
|
||||
QMultiMap<int, LtsScriptTimeline::TrackEntry *> m_topicMap;
|
||||
QMultiMap<int, LtsScriptTimeline::TrackEntry *> m_topicMap; // <seconds, trackEntry>
|
||||
|
||||
QTimer *m_presentationTimer { nullptr };
|
||||
qint64 m_firstTopicTime { -1 };
|
||||
@@ -431,7 +438,8 @@ private:
|
||||
|
||||
Ui::ScriptDialog *m_ui { nullptr };
|
||||
bool m_lastScriptHasEnded { false };
|
||||
QMap<TopicEditorBase::TopicType, int> m_avaibleTopics{};
|
||||
NGL::INGLLogger &m_logger;
|
||||
QMap<TopicEditorBase::TopicType, int> m_avaibleTopics{}; // <data.topicType, data.id>
|
||||
QVector<TopicEditorBase::TopicType> m_modifiedTopicTypesList;
|
||||
|
||||
LtsSession::LtsSession *m_session { nullptr };
|
||||
@@ -456,6 +464,7 @@ private:
|
||||
ScriptTimelineDialog &m_this;
|
||||
std::unique_ptr<LtsWidgets::LtsOverlayLoading> m_loading;
|
||||
bool m_stoppedPrematurely { false };
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace PresentationManagement
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Mike Wille, SLSE, 2016-03-30
|
||||
#
|
||||
|
||||
ADD_SUBDIRECTORY(Data)
|
||||
ADD_SUBDIRECTORY(Gui)
|
||||
|
||||
#
|
||||
# Gui Plugin Interface
|
||||
#
|
||||
ADD_INTERFACE_LIBRARY(ScmGuiPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/scm_gui_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
GuiPluginInterface
|
||||
)
|
||||
|
||||
#
|
||||
# Data Plugin Interface
|
||||
#
|
||||
ADD_INTERFACE_LIBRARY(ScmDataPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/scm_data_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
DataPluginInterface
|
||||
svcScmCommon
|
||||
)
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Mike Wille, SLSE, 2016-09-06
|
||||
#
|
||||
|
||||
#
|
||||
# Data Plugin
|
||||
#
|
||||
NGL_ADD_LIBRARY(WS ScmDataPlugin MODULE scm_data_plugin.cpp scm_data_plugin.h)
|
||||
NGL_TARGET_LINK_LIBRARIES(ScmDataPlugin
|
||||
Qt5::Core
|
||||
ScmDataPluginInterface
|
||||
svcScmClient
|
||||
NGLLogger
|
||||
LtsSessionDataDds
|
||||
)
|
||||
NGL_INSTALL_TARGET(ScmDataPlugin)
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Data Plugin for ServiceManangement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-03-30
|
||||
*/
|
||||
|
||||
#include "scm_data_plugin.h"
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
std::shared_ptr<DataPluginBase::Interface> DataPlugin::createDataInterface(LtsSession::LtsSessionDataDds *session)
|
||||
{
|
||||
std::shared_ptr<ServiceManagement::Interface::Dtc> dtc;
|
||||
std::shared_ptr<ServiceManagement::Interface::Ftc> ftc;
|
||||
if (!session->createTopicClient(dtc, ftc, false ,true))
|
||||
return std::shared_ptr<DataPluginBase::Interface>();
|
||||
return std::make_shared<DataInterfaceImpl>(dtc, ftc);
|
||||
}
|
||||
|
||||
DataInterfaceImpl::DataInterfaceImpl(const std::shared_ptr<ServiceManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ServiceManagement::Interface::Ftc> &ftc)
|
||||
: DataInterface()
|
||||
, m_dtc(dtc)
|
||||
, m_ftc(ftc)
|
||||
{}
|
||||
|
||||
} // namespace ServiceManagement
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ServiceManangement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-03-30
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/ServiceManagement/scm_data_plugin_interface.h>
|
||||
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
|
||||
class DataPlugin final : public QObject, public DataPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "data:3:scm")
|
||||
Q_INTERFACES(DataPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
DataPlugin() = default;
|
||||
~DataPlugin() = default;
|
||||
|
||||
QString pluginName() const override { return QStringLiteral("ServiceManagement"); }
|
||||
std::shared_ptr<DataPluginBase::Interface> createDataInterface(LtsSession::LtsSessionDataDds *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Global;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class DataInterfaceImpl final : public DataInterface
|
||||
{
|
||||
public:
|
||||
explicit DataInterfaceImpl(const std::shared_ptr<ServiceManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ServiceManagement::Interface::Ftc> &ftc);
|
||||
|
||||
std::shared_ptr<ServiceManagement::Interface::Dtc> getDtc() override { return m_dtc; }
|
||||
std::shared_ptr<ServiceManagement::Interface::Ftc> getFtc() override { return m_ftc; }
|
||||
|
||||
private:
|
||||
std::shared_ptr<ServiceManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ServiceManagement::Interface::Ftc> m_ftc;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ServiceManagement
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Mike Wille, SLSE, 2016-03-30
|
||||
#
|
||||
|
||||
ADD_SUBDIRECTORY(ServiceEdit)
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Mike Wille, SLSE, 2016-03-30
|
||||
#
|
||||
|
||||
SET(scm_edit_gui_SRCS
|
||||
scm_edit_gui_plugin.cpp
|
||||
scm_edit_gui_plugin.h
|
||||
scm_dialog.cpp
|
||||
scm_dialog.h
|
||||
scm_dialog_service.cpp
|
||||
scm_dialog_service.h
|
||||
scm_dialog_group.cpp
|
||||
scm_dialog_group.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(scm_edit_gui_SRCS
|
||||
scm_dialog.ui
|
||||
scm_dialog_service.ui
|
||||
scm_dialog_group.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS ScmEditGuiPlugin MODULE ${scm_edit_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(ScmEditGuiPlugin
|
||||
NGLLogger
|
||||
ScmGuiPluginInterface
|
||||
ScmDataPluginInterface
|
||||
LtsSession
|
||||
Qt5::Widgets
|
||||
LtsWidgets
|
||||
LtsUtilsGuiDds
|
||||
svcScmCommon
|
||||
svcExmClient
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(ScmEditGuiPlugin)
|
||||
Executable
+365
@@ -0,0 +1,365 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ExerciseManangement - Exercise Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-03-30
|
||||
*/
|
||||
|
||||
|
||||
#include "scm_dialog.h"
|
||||
#include "ui_scm_dialog.h"
|
||||
|
||||
#include "scm_dialog_group.h"
|
||||
#include "scm_dialog_service.h"
|
||||
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
//---------------------------------
|
||||
// ServiceManagementDialog
|
||||
//---------------------------------
|
||||
ServiceManagementDialog::ServiceManagementDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::ServiceManagementDialog)
|
||||
, m_dtcExm(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_logger(getLogger("ServiceManagementDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
// unused yet
|
||||
m_ui->lbGroupsIndicator->hide();
|
||||
m_ui->lbExercise->hide();
|
||||
m_ui->lbServer->hide();
|
||||
m_ui->cbServer->hide();
|
||||
m_ui->cbExercise->hide();
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Administrator-Service_Management"));
|
||||
}
|
||||
|
||||
ServiceManagementDialog::~ServiceManagementDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void ServiceManagementDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Service Management"));
|
||||
}
|
||||
|
||||
|
||||
bool ServiceManagementDialog::init(const std::shared_ptr<ServiceManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ServiceManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ExerciseManagement::Interface::Dtc> &dtcExm)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_dtcExm = dtcExm;
|
||||
|
||||
connect(m_dtc.get(), &Interface::Dtc::groupInformationChanged,
|
||||
this, &ServiceManagementDialog::slotGroupInformationChanged);
|
||||
|
||||
connect(m_dtc.get(), &Interface::Dtc::serviceInformationChanged,
|
||||
this, &ServiceManagementDialog::slotServiceInformationChanged);
|
||||
|
||||
const QMap<qint32, ServiceManagement::GroupInformation> groupInfo = m_dtc->groupInformations();
|
||||
|
||||
if (groupInfo.isEmpty())
|
||||
{
|
||||
INFO_LOG(m_logger) << "initModel - no groups!";
|
||||
return true;
|
||||
}
|
||||
|
||||
m_ui->lbNoServices->hide();
|
||||
|
||||
INFO_LOG(m_logger) << "initModel - #group information: " << groupInfo.size();
|
||||
|
||||
|
||||
// GROUPS
|
||||
QVector<int> servicesList;
|
||||
for (const ServiceManagement::GroupInformation &gi : groupInfo)
|
||||
{
|
||||
// now that all services of that group are represented by a widget, create the group widget which adds all service widgets
|
||||
//const int id = gi.id();
|
||||
const int server = gi.domainId();
|
||||
const int exercise = gi.exercisePartitionId();
|
||||
const int32_t replayPartitionId = gi.replayPartitionId();
|
||||
const QString groupName = groupEnumToGroupName(gi.type()); // QLatin1String("Group Name"); // TODO: get real group name
|
||||
long long timestamp = gi.timestamp();
|
||||
|
||||
servicesList.clear();
|
||||
servicesList.reserve(gi.services().size());
|
||||
for (auto service : gi.services())
|
||||
servicesList.append(service);
|
||||
|
||||
addGroup(gi.type(), server, exercise, replayPartitionId, groupName, timestamp, servicesList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// SERVICES
|
||||
auto cbSvc = [this](const ServiceManagement::ServiceInformation & svc) // create widgets for every service in the group
|
||||
{
|
||||
addService(svc);
|
||||
};
|
||||
m_dtc->serviceInformations(cbSvc); // needed to resolve services for the groups
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
GroupWidget *ServiceManagementDialog::addGroup(const Core::ServiceGroupType &groupType, int server, int exercise, int32_t replayPartitionId,
|
||||
const QString &groupName, long long timestamp, const QVector<int> &servicesList)
|
||||
{
|
||||
//qWarning() << "ServiceManagementDialog::addGroup: needed services:" << servicesList;
|
||||
|
||||
QString exName = QString::fromStdString(m_dtcExm.get()->exercise(exercise).name());
|
||||
GroupWidget *group = new GroupWidget(groupType, server, exercise, replayPartitionId, exName, timestamp, servicesList); // memleak!
|
||||
|
||||
QString groupObjectName = craftGroupName(server, exercise, groupName);
|
||||
group->setObjectName(groupObjectName);
|
||||
//qWarning() << "Group Object Name =" << groupObjectName;
|
||||
|
||||
connect(group, &GroupWidget::signalRestartGroup, this, &ServiceManagementDialog::slotRestartGroup); // direct connection for const ref on group type enum
|
||||
connect(group, &GroupWidget::signalStartGroup, this, &ServiceManagementDialog::slotStartGroup); // direct connection for const ref on group type enum
|
||||
connect(group, &GroupWidget::signalStopGroup, this, &ServiceManagementDialog::slotStopGroup); // direct connection for const ref on group type enum
|
||||
|
||||
QVBoxLayout *l = qobject_cast<QVBoxLayout *>(m_ui->groupLayoutWidget->layout());
|
||||
if (!l)
|
||||
WARNING_LOG(m_logger) << "ServiceManagementDialog::addGroup: group layout failed, cannot add group";
|
||||
else
|
||||
l->addWidget(group, 0, Qt::AlignTop);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
|
||||
void ServiceManagementDialog::slotRestartService(int serviceID)
|
||||
{
|
||||
const RestartServiceRequest req(serviceID);
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->restartServiceRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
static int s_requestId = 0;
|
||||
void ServiceManagementDialog::slotRestartGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId)
|
||||
{
|
||||
const GroupRequest req(groupType,
|
||||
exercise,
|
||||
server,
|
||||
replayPartitionId,
|
||||
++s_requestId,
|
||||
{});
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->restartGroupRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void ServiceManagementDialog::slotStartGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId)
|
||||
{
|
||||
const GroupRequest req(groupType,
|
||||
exercise,
|
||||
server,
|
||||
replayPartitionId,
|
||||
++s_requestId,
|
||||
{});
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->startGroupRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void ServiceManagementDialog::slotStopGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId)
|
||||
{
|
||||
const GroupRequest req(groupType,
|
||||
exercise,
|
||||
server,
|
||||
replayPartitionId,
|
||||
++s_requestId,
|
||||
{});
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->stopGroupRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// DTC Modifications
|
||||
void ServiceManagementDialog::slotGroupInformationChanged(ServiceManagement::GroupInformation info, DataModification mod)
|
||||
{
|
||||
//qWarning() << "slotGroupInformationChanged";
|
||||
|
||||
// find group
|
||||
int server = info.domainId();
|
||||
int exercise = info.exercisePartitionId();
|
||||
int32_t replayPartitionId = info.replayPartitionId();
|
||||
QString groupName = groupEnumToGroupName(info.type());
|
||||
long long timestamp = info.timestamp();
|
||||
|
||||
QString findGroupName = craftGroupName(server, exercise, groupName);
|
||||
|
||||
GroupWidget *gw = m_ui->groupLayoutWidget->findChild<GroupWidget *>(findGroupName);
|
||||
|
||||
if (!gw) // group does not exist? create it!
|
||||
{
|
||||
//qWarning() << "slotGroupInformationChanged: group not found, adding it";
|
||||
|
||||
QVector<int> servicesList;
|
||||
servicesList.reserve(info.services().size());
|
||||
for (auto service : info.services())
|
||||
servicesList << service;
|
||||
|
||||
m_ui->lbNoServices->hide();
|
||||
addGroup(info.type(), server, exercise, replayPartitionId, groupName, timestamp, servicesList);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (mod)
|
||||
{
|
||||
case DataModification::eAdded: // already exists, so it cant be added - but easily change data in existing group
|
||||
case DataModification::eModified:
|
||||
{
|
||||
//qWarning() << "slotGroupInformationChanged: group added or modified";
|
||||
|
||||
m_ui->lbNoServices->hide(); // added/modified = there are groups, which show services
|
||||
|
||||
gw->setType(info.type());
|
||||
gw->setServer(server);
|
||||
gw->setExercise(exercise);
|
||||
gw->setTimestamp(timestamp);
|
||||
break;
|
||||
}
|
||||
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
//qWarning() << "slotGroupInformationChanged: group removed";
|
||||
|
||||
if (m_ui->groupLayoutWidget->findChildren<GroupWidget *>().isEmpty()) // no groups to show services in?
|
||||
m_ui->lbNoServices->show();
|
||||
|
||||
delete gw; // then delete gw from layout
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ServiceManagementDialog::addService(const ServiceManagement::ServiceInformation &svc)
|
||||
{
|
||||
const int id = svc.id();
|
||||
const long long pid = svc.pid();
|
||||
const QString name(QString::fromStdString(svc.name()));
|
||||
const Core::RunningState &state = svc.state();
|
||||
const QString errorString(QString::fromStdString(svc.errorString()));
|
||||
|
||||
ServiceWidget *service = new ServiceWidget(id, pid, name, state, errorString);
|
||||
service->setObjectName(QLatin1String("service.") + QString::number(id));
|
||||
connect(service, &ServiceWidget::signalRestartService, this, &ServiceManagementDialog::slotRestartService);
|
||||
|
||||
|
||||
const auto groupList = findChildren<GroupWidget *>();
|
||||
for (GroupWidget *gw : groupList)
|
||||
gw->addService(service);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ServiceManagementDialog::slotServiceInformationChanged(ServiceManagement::ServiceInformation info, DataModification mod)
|
||||
{
|
||||
//qWarning() << "slotServiceInformationChanged";
|
||||
|
||||
// find services (because ONE service can be in MANY groups)
|
||||
|
||||
int32_t serviceId = info.id();
|
||||
QString errorString = QString::fromStdString(info.errorString());
|
||||
QString serviceName = QString::fromStdString(info.name());
|
||||
long long pid = info.pid();
|
||||
const Core::RunningState &state = info.state();
|
||||
long long timestamp = info.timestamp();
|
||||
|
||||
QString findServiceName = QLatin1String("service.") + QString::number(serviceId);
|
||||
|
||||
const auto serviceList = findChildren<ServiceWidget *>(findServiceName);
|
||||
|
||||
if (serviceList.isEmpty() || mod == DataModification::eAdded) // no service found or is going to be added? add it!
|
||||
{
|
||||
//qWarning() << "slotServiceInformationChanged: service not found, adding it";
|
||||
|
||||
addService(info);
|
||||
}
|
||||
|
||||
for (ServiceWidget *serviceWidget : serviceList)
|
||||
{
|
||||
switch (mod)
|
||||
{
|
||||
case DataModification::eModified:
|
||||
{
|
||||
//qWarning() << "slotServiceInformationChanged: service modified";
|
||||
|
||||
serviceWidget->setErrorString(errorString);
|
||||
serviceWidget->setName(serviceName);
|
||||
serviceWidget->setPid(pid);
|
||||
serviceWidget->setState(state);
|
||||
serviceWidget->setTimestamp(timestamp);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
//qWarning() << "slotServiceInformationChanged: service removed";
|
||||
|
||||
delete serviceWidget;
|
||||
serviceWidget = nullptr;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
//qWarning() << "ServiceManagementDialog::slotServiceInformationChanged: unknown or invalid modification!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// tell all groups to set their new statuses (bcuz service states may have changed) !!
|
||||
const auto groupList = findChildren<GroupWidget *>();
|
||||
for (GroupWidget *groupWidget : groupList)
|
||||
groupWidget->checkStatus();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace ServiceManagement
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Executable
+101
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ExerciseManangement - Exercise Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-03-30
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "scm_dialog_group.h"
|
||||
|
||||
#include <ServiceManagement/scm_ftc.h>
|
||||
#include <ServiceManagement/scm_dtc.h>
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
#include <ServiceManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ServiceManagementDialog;
|
||||
}
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
//class ExerciseManagementDialogModel;
|
||||
// --------------------------------------------------------
|
||||
// ExerciseManagementDialog
|
||||
// --------------------------------------------------------
|
||||
class ServiceManagementDialog : public LtsWidgets::LtsDialog
|
||||
, protected ServiceManagement::Interface::Ftc::RestartServiceReplyHandler
|
||||
, protected ServiceManagement::Interface::Ftc::RestartGroupReplyHandler
|
||||
, protected ServiceManagement::Interface::Ftc::StartGroupReplyHandler
|
||||
, protected ServiceManagement::Interface::Ftc::StopGroupReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ServiceManagementDialog(QWidget *parent = nullptr);
|
||||
~ServiceManagementDialog();
|
||||
|
||||
bool init(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ExerciseManagement::Interface::Dtc> &dtcExm);
|
||||
|
||||
virtual void onRestartServiceReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
virtual void onRestartGroupReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
virtual void onStartGroupReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
virtual void onStopGroupReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
|
||||
// TODO: raus, String soll gepublished werden
|
||||
static QString groupEnumToGroupName(const Core::ServiceGroupType &type)
|
||||
{
|
||||
QMap<QString, Core::ServiceGroupType_def::type> groupNameMapping;
|
||||
groupNameMapping.insert(QLatin1String("Master"), Core::ServiceGroupType_def::Master);
|
||||
groupNameMapping.insert(QLatin1String("Core"), Core::ServiceGroupType_def::Core);
|
||||
groupNameMapping.insert(QLatin1String("ExercisePreparation"), Core::ServiceGroupType_def::ExercisePreparation);
|
||||
groupNameMapping.insert(QLatin1String("ExerciseExecution"), Core::ServiceGroupType_def::ExerciseExecution);
|
||||
groupNameMapping.insert(QLatin1String("ExercisePaused"), Core::ServiceGroupType_def::ExercisePaused);
|
||||
groupNameMapping.insert(QLatin1String("ExerciseAfterActionReview"), Core::ServiceGroupType_def::ExerciseAfterActionReview);
|
||||
groupNameMapping.insert(QLatin1String("Playback"), Core::ServiceGroupType_def::Playback);
|
||||
|
||||
return groupNameMapping.key(type.underlying());
|
||||
}
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
|
||||
static QString craftBaseName(const QString &server, const QString &exercise) { return server + QLatin1Char('.') + exercise + QLatin1Char('.'); }
|
||||
|
||||
GroupWidget *addGroup(const Core::ServiceGroupType &groupType, int server, int exercise, int32_t replayPartitionId,
|
||||
const QString &groupName, long long timestamp, const QVector<int> &servicesList);
|
||||
void addService(const ServiceInformation &svc);
|
||||
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
public:
|
||||
static QString craftGroupName(int server, int exercise, const QString &groupName) { return craftBaseName(QString::number(server), QString::number(exercise)) + groupName; }
|
||||
static QString craftServiceName(int server, int exercise, const QString &groupName, int serviceId) { return craftGroupName(server, exercise, groupName) + QLatin1Char('.') + QString::number(serviceId); }
|
||||
static QString craftWildcardedServiceName(int serviceId) { return craftBaseName(QLatin1String("*"), QLatin1String("*")) + QString::number(serviceId); }
|
||||
|
||||
Ui::ServiceManagementDialog *m_ui;
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_dtcExm;
|
||||
std::shared_ptr<ServiceManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ServiceManagement::Interface::Ftc> m_ftc;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
|
||||
private slots:
|
||||
void slotRestartService(int serviceID);
|
||||
void slotRestartGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId);
|
||||
void slotStartGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId);
|
||||
void slotStopGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId);
|
||||
|
||||
void slotGroupInformationChanged(ServiceManagement::GroupInformation, DataModification);
|
||||
void slotServiceInformationChanged(ServiceManagement::ServiceInformation, DataModification);
|
||||
};
|
||||
}
|
||||
Executable
+95
@@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ServiceManagementDialog</class>
|
||||
<widget class="QWidget" name="ServiceManagementDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>500</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Service Management</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbServer">
|
||||
<property name="text">
|
||||
<string>Server:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QComboBox" name="cbServer">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lbExercise">
|
||||
<property name="text">
|
||||
<string>Exercise:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="cbExercise">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbNoServices">
|
||||
<property name="text">
|
||||
<string>There are no Services available to view.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbGroupsIndicator">
|
||||
<property name="text">
|
||||
<string>Groups of 'Server.Exercise':</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="groupLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>588</width>
|
||||
<height>376</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="spacing">
|
||||
<number>25</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Executable
+168
@@ -0,0 +1,168 @@
|
||||
#include "scm_dialog.h"
|
||||
#include "scm_dialog_group.h"
|
||||
#include "ui_scm_dialog_group.h"
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
GroupWidget::GroupWidget(const Core::ServiceGroupType &groupType, int server, int exercise,
|
||||
int32_t replayPartitionId,
|
||||
const QString &groupName /* TODO: groupName not needed */, long long timestamp,
|
||||
const QVector<int> &neededServices, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::GroupWidget)
|
||||
, m_status(ServiceWidget::UNKNOWN)
|
||||
, m_server(server)
|
||||
, m_exercise(exercise)
|
||||
, m_groupName(groupName)
|
||||
, m_replayPartitionId(replayPartitionId)
|
||||
, m_neededServices(neededServices)
|
||||
{
|
||||
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->pbRestart, &QToolButton::clicked, this, &GroupWidget::slotRestartGroup);
|
||||
connect(m_ui->pbStart, &QToolButton::clicked, this, &GroupWidget::slotStartGroup);
|
||||
connect(m_ui->pbStop, &QToolButton::clicked, this, &GroupWidget::slotStopGroup);
|
||||
|
||||
setType(groupType);
|
||||
setServer(server);
|
||||
setExercise(exercise);
|
||||
setTimestamp(timestamp);
|
||||
|
||||
if (getStatus() != ServiceWidget::STOPPED) // when not stopped (but unknown), then set as STARTED
|
||||
setStatus(ServiceWidget::STARTED);
|
||||
}
|
||||
|
||||
|
||||
GroupWidget::~GroupWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void GroupWidget::addService(ServiceWidget *service)
|
||||
{
|
||||
m_ui->lbNoServices->hide(); // min. 1 service available
|
||||
|
||||
//qWarning() << "GroupWidget::addService: ";
|
||||
|
||||
if (m_neededServices.contains(service->id())) // does this group need this service?
|
||||
{
|
||||
//qWarning() << "GroupWidget::addService: service needed";
|
||||
|
||||
if (!findChild<ServiceWidget *>(service->objectName())) // and the service was not found?
|
||||
{
|
||||
//qWarning() << "GroupWidget::addService: service currently not found, adding it";
|
||||
|
||||
m_ui->servicesLayout->addWidget(service);
|
||||
checkStatus();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//qWarning() << "GroupWidget::addService: I do not need" << service->id() << ", i need" << m_neededServices;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GroupWidget::checkStatus()
|
||||
{
|
||||
// get all service widgets from THIS widget and check our status by their status
|
||||
|
||||
m_status = ServiceWidget::UNKNOWN; // reset status
|
||||
|
||||
|
||||
const QList<ServiceWidget *> serviceList = findChildren<ServiceWidget *>();
|
||||
|
||||
if (serviceList.isEmpty())
|
||||
m_ui->lbNoServices->show(); // no services left (after deleting)
|
||||
|
||||
for (const ServiceWidget *serviceWidget : serviceList)
|
||||
{
|
||||
if (serviceWidget->getStatus() != ServiceWidget::STARTED)
|
||||
setStatus(ServiceWidget::STOPPED); // when a single service is not started, the whole group is stopped (or ERROR?)
|
||||
}
|
||||
|
||||
if (getStatus() != ServiceWidget::STOPPED) // when not stopped (but unknown), then set as STARTED
|
||||
setStatus(ServiceWidget::STARTED);
|
||||
}
|
||||
|
||||
|
||||
ServiceWidget::Status GroupWidget::getStatus() const
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
|
||||
|
||||
void GroupWidget::setStatus(ServiceWidget::Status status)
|
||||
{
|
||||
m_status = status;
|
||||
|
||||
QString newCss;
|
||||
switch (m_status)
|
||||
{
|
||||
case ServiceWidget::STARTED:
|
||||
newCss = QLatin1String("background-color: rgb(124, 189, 124);");
|
||||
break;
|
||||
case ServiceWidget::STOPPED:
|
||||
newCss = QLatin1String("background-color: rgb(189, 106, 98);");
|
||||
break;
|
||||
case ServiceWidget::STARTING:
|
||||
case ServiceWidget::STOPPING:
|
||||
case ServiceWidget::UNKNOWN:
|
||||
break;
|
||||
}
|
||||
m_ui->frStatus->setStyleSheet(newCss);
|
||||
}
|
||||
|
||||
|
||||
void GroupWidget::slotRestartGroup()
|
||||
{
|
||||
emit signalRestartGroup(m_groupType, m_exercise, m_server, m_replayPartitionId);
|
||||
}
|
||||
|
||||
|
||||
void GroupWidget::slotStartGroup()
|
||||
{
|
||||
emit signalStartGroup(m_groupType, m_exercise, m_server, m_replayPartitionId);
|
||||
}
|
||||
|
||||
|
||||
void GroupWidget::slotStopGroup()
|
||||
{
|
||||
emit signalStopGroup(m_groupType, m_exercise, m_server, m_replayPartitionId);
|
||||
}
|
||||
|
||||
|
||||
void GroupWidget::setType(Core::ServiceGroupType type)
|
||||
{
|
||||
m_groupType = type;
|
||||
m_ui->lbGroupName->setText(QStringLiteral("<html><head/><body><p>%1<span style='font-weight:600;'> %2</span></p></body></html>")
|
||||
.arg(tr("Services of %1").arg(ServiceManagement::ServiceManagementDialog::groupEnumToGroupName(type)), m_groupName));
|
||||
}
|
||||
|
||||
void GroupWidget::setServer(int server)
|
||||
{
|
||||
m_server = server;
|
||||
}
|
||||
|
||||
void GroupWidget::setExercise(int exercise)
|
||||
{
|
||||
m_exercise = exercise;
|
||||
}
|
||||
|
||||
void GroupWidget::setTimestamp(long long timestamp)
|
||||
{
|
||||
if (timestamp < 1)
|
||||
{
|
||||
m_ui->lbTimestamp->setText(QString());
|
||||
return;
|
||||
}
|
||||
|
||||
m_ui->lbTimestamp->setText(QStringLiteral("<html><head/><body><p>%1:<br/>%2</p></body></html>")
|
||||
.arg(tr("Last Heartbeat"), QDateTime::fromMSecsSinceEpoch(timestamp).toString()));
|
||||
}
|
||||
} // namespace ServiceManagement
|
||||
Executable
+59
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include "scm_dialog_service.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QVector>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class GroupWidget;
|
||||
}
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
class GroupWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GroupWidget(const Core::ServiceGroupType &groupType, int server, int exercise,
|
||||
int32_t replayPartitionId,
|
||||
const QString &groupName, long long timestamp,
|
||||
const QVector<int> &neededServices, QWidget *parent = nullptr);
|
||||
~GroupWidget();
|
||||
|
||||
void addService(ServiceWidget *service);
|
||||
|
||||
void setType(Core::ServiceGroupType type); // sets group name
|
||||
void setServer(int server);
|
||||
void setExercise(int exercise);
|
||||
void setTimestamp(long long timestamp);
|
||||
|
||||
ServiceWidget::Status getStatus() const;
|
||||
void setStatus(ServiceWidget::Status status);
|
||||
|
||||
void checkStatus();
|
||||
|
||||
private:
|
||||
Ui::GroupWidget *m_ui;
|
||||
ServiceWidget::Status m_status;
|
||||
Core::ServiceGroupType m_groupType;
|
||||
int m_server;
|
||||
int m_exercise;
|
||||
QString m_groupName;
|
||||
int32_t m_replayPartitionId;
|
||||
QVector<int> m_neededServices;
|
||||
|
||||
private slots:
|
||||
void slotRestartGroup();
|
||||
void slotStartGroup();
|
||||
void slotStopGroup();
|
||||
|
||||
signals:
|
||||
void signalRestartGroup(const Core::ServiceGroupType &groupType, int, int, int32_t replayPartitionId);
|
||||
void signalStartGroup(const Core::ServiceGroupType &groupType, int, int, const int32_t replayPartitionId);
|
||||
void signalStopGroup(const Core::ServiceGroupType &groupType, int, int, const int32_t replayPartitionId);
|
||||
};
|
||||
} // namespace ServiceManagement
|
||||
Executable
+222
@@ -0,0 +1,222 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GroupWidget</class>
|
||||
<widget class="QWidget" name="GroupWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>720</width>
|
||||
<height>55</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="frStatus">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbGroupName">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbTimestamp">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbRestart">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Restart this Group of Services (Restarts every Service inside this Group)</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">R</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Styles/Dark/resources/rme_dark_style.qrc">
|
||||
<normaloff>:/style/arrow_back.svg</normaloff>:/style/arrow_back.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbStart">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Start this Group of Services (Starts Services inside this Group, that are currently stopped)</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">S</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Styles/Dark/resources/rme_dark_style.qrc">
|
||||
<normaloff>:/style/media-play-slower.svg</normaloff>:/style/media-play-slower.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbStop">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Stop this Group of Services (Stops Services inside this Group, that are currently running / started)</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">E</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Styles/Dark/resources/rme_dark_style.qrc">
|
||||
<normaloff>:/style/application-exit.svg</normaloff>:/style/application-exit.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="servicesLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbNoServices">
|
||||
<property name="text">
|
||||
<string>No Services available in this Group.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../../Styles/Dark/resources/rme_dark_style.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
Loaded 100 of 18662 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user