Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+10
@@ -0,0 +1,10 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
# Created by Hannes Baeuerle, SLSE, 2017-06-13
|
||||
#
|
||||
|
||||
add_subdirectory(SymbolEditor)
|
||||
add_subdirectory(SymbolProxy)
|
||||
@@ -0,0 +1,54 @@
|
||||
# CMake script for SymbolEditor
|
||||
|
||||
SET(symboleditor_SRCS
|
||||
asb_save_as_symbol.cpp
|
||||
asb_save_as_symbol.h
|
||||
asb_symbol_editor_gui_plugin.cpp
|
||||
asb_symbol_editor_gui_plugin.h
|
||||
asb_save_as_symbol.cpp
|
||||
asb_save_as_symbol.h
|
||||
asb_delete_elements_dialog.cpp
|
||||
asb_delete_elements_dialog.h
|
||||
asb_resize_dialog.cpp
|
||||
asb_resize_dialog.h
|
||||
asb_rotate_dialog.cpp
|
||||
asb_rotate_dialog.h
|
||||
asb_select_text_dialog.cpp
|
||||
asb_select_text_dialog.h
|
||||
asb_symbol_editor.cpp
|
||||
asb_symbol_editor.h
|
||||
asb_symbol_edit_scene.cpp
|
||||
asb_symbol_edit_scene.h
|
||||
flm_reply_handler.cpp
|
||||
flm_reply_handler.h
|
||||
)
|
||||
|
||||
SET(symboleditor_UICS
|
||||
forms/asb_select_text_dialog.ui
|
||||
forms/asb_delete_elements_dialog.ui
|
||||
forms/asb_symbol_editor.ui
|
||||
forms/asb_save_as_symbol.ui
|
||||
forms/asb_rotate_dialog.ui
|
||||
forms/asb_resize_dialog.ui
|
||||
)
|
||||
|
||||
# Fuer die Icons
|
||||
QT5_ADD_RESOURCES(symboleditor_SRCS application.qrc)
|
||||
NGL_WRAP_UI(symboleditor_SRCS ${symboleditor_UICS})
|
||||
|
||||
NGL_ADD_LIBRARY(WS AsbSymEditGuiPlugin MODULE ${symboleditor_SRCS} ${symboleditor_UICS})
|
||||
NGL_TARGET_LINK_LIBRARIES(AsbSymEditGuiPlugin
|
||||
NGLLogger
|
||||
LtsWidgets
|
||||
FlmDataPluginInterface
|
||||
PpmDataPluginInterface
|
||||
advancedSymbology
|
||||
advancedSymbologyXML
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
LtsUtilsGuiDds
|
||||
Qt5::Core
|
||||
Qt5::Gui
|
||||
Qt5::Widgets
|
||||
)
|
||||
NGL_INSTALL_TARGET(AsbSymEditGuiPlugin)
|
||||
BIN
Binary file not shown.
+11
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE symboltable SYSTEM "symbole.dtd">
|
||||
<symbol version="1.0" id="0x00001003" dimen="land_units" affil="enemy" bcdab="undefined" command_level="undefined" mob="wheel">
|
||||
<name>LinienOben</name>
|
||||
<graphic scale="1.0">
|
||||
<line transform="false" rotate="0" linewidth="0.1" linestyle="solid">
|
||||
<point x="1.1" y="1.9"/>
|
||||
<point x="1.1" y="1.9"/>
|
||||
</line>
|
||||
</graphic>
|
||||
</symbol>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE symboltable SYSTEM "symbole.dtd">
|
||||
<symbol version="1.0" id="0x00001003" dimen="undefined" affil="neutral" bcdab="undefined" command_level="undefined" mob="undefined">
|
||||
<name>LinienOben</name>
|
||||
<graphic scale="1">
|
||||
<line transform="false" rotate="0" linewidth="0.05" linestyle="solid">
|
||||
<point x="-1.6" y="1.6"/>
|
||||
<point x="-0.1" y="1.6"/>
|
||||
</line>
|
||||
<line transform="false" rotate="0" linewidth="0.05" linestyle="solid">
|
||||
<point x="0.1" y="1.6"/>
|
||||
<point x="1.6" y="1.6"/>
|
||||
</line>
|
||||
</graphic>
|
||||
</symbol>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE symboltable SYSTEM "symbole.dtd">
|
||||
<symbol version="1.0" id="0x00001011" dimen="undefined" affil="neutral" bcdab="undefined" command_level="undefined" mob="undefined">
|
||||
<name>Manipulation</name>
|
||||
<graphic scale="1">
|
||||
<line transform="false" rotate="0" color="#ffffffff" linewidth="0.1" linestyle="solid">
|
||||
<point x="-1.2" y="-1.4"/>
|
||||
<point x="1.2" y="-1.4"/>
|
||||
</line>
|
||||
<line transform="false" rotate="0" color="#000000ff" linewidth="0.1" linestyle="solid">
|
||||
<point x="-1.2" y="-1.5"/>
|
||||
<point x="1.2" y="-1.5"/>
|
||||
</line>
|
||||
</graphic>
|
||||
</symbol>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE symboltable SYSTEM "symbole.dtd">
|
||||
<symbol version="1.0" id="0x00001012" dimen="undefined" affil="neutral" bcdab="undefined" command_level="undefined" mob="undefined">
|
||||
<name>NoPosition</name>
|
||||
<graphic scale="1">
|
||||
<line transform="false" rotate="0" color="#ff0000ff" linewidth="0.1" linestyle="solid">
|
||||
<point x="-1.6" y="-1.6"/>
|
||||
<point x="1.6" y="-1.6"/>
|
||||
</line>
|
||||
</graphic>
|
||||
</symbol>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE symboltable SYSTEM "symbole.dtd">
|
||||
<symbol version="1.0" id="0x1000" dimen="land_units" affil="neutral" bcdab="crew" command_level="undefined" mob="wheel">
|
||||
<name>/shd/guez/int/WorkSpace/trunk/GDW/addOnSymbols/TestSymbol.xml</name>
|
||||
<branch class="infantry" />
|
||||
<text1 maxdatalength="9">
|
||||
<data align="center">Test</data>
|
||||
</text1>
|
||||
<graphic scale="0.5">
|
||||
<rect transform="false" rotate="45" linewidth="0.05" linestyle="dotted"
|
||||
fill="0" color="#FF0000FF">
|
||||
<point x="-0.543103" y="0.568966"/>
|
||||
<point x="0.577586" y="-0.551724"/>
|
||||
</rect>
|
||||
</graphic>
|
||||
</symbol>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE symboltable SYSTEM "symbole.dtd">
|
||||
<symbol version="1.0" id="0x00001002" dimen="undefined" affil="neutral" bcdab="undefined" command_level="undefined" mob="undefined">
|
||||
<name>vbgFireKill</name>
|
||||
<graphic scale="1">
|
||||
<line transform="false" rotate="0" linewidth="0.15" linestyle="solid">
|
||||
<point x="-1.6" y="-1.6"/>
|
||||
<point x="1.6" y="1.6"/>
|
||||
</line>
|
||||
</graphic>
|
||||
</symbol>
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE symboltable SYSTEM "symbole.dtd">
|
||||
<symbol version="1.0" id="0x00001001" dimen="undefined" affil="neutral" bcdab="undefined" command_level="undefined" mob="undefined">
|
||||
<name>vbgFireKill</name>
|
||||
<graphic scale="1">
|
||||
<line transform="false" rotate="0" linewidth="0.15" linestyle="solid">
|
||||
<point x="-1.6" y="1.6"/>
|
||||
<point x="1.6" y="-1.6"/>
|
||||
</line>
|
||||
</graphic>
|
||||
</symbol>
|
||||
@@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>icons/previewBackground.xpm</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SymbolEditor
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Chrsitian Roeskens, SLSE, 2017-04-12
|
||||
*/
|
||||
|
||||
#include "asb_delete_elements_dialog.h"
|
||||
#include "ui_asb_delete_elements_dialog.h"
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
DeleteElementsDialog::DeleteElementsDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsFramelessDialog(parent)
|
||||
, ui(new Ui_DeleteElementsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
initWidgets();
|
||||
enaDisa();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
DeleteElementsDialog::~DeleteElementsDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void DeleteElementsDialog::initWidgets()
|
||||
{
|
||||
connect(ui->checkBoxPrims, &QCheckBox::toggled, this, &DeleteElementsDialog::enaDisa);
|
||||
connect(ui->checkBoxPrimsSectorText, &QCheckBox::toggled, this, &DeleteElementsDialog::enaDisa);
|
||||
connect(ui->checkBoxAttributes, &QCheckBox::toggled, this, &DeleteElementsDialog::enaDisa);
|
||||
|
||||
connect(ui->buttonBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked, this, &DeleteElementsDialog::accept);
|
||||
connect(ui->buttonBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, this, &DeleteElementsDialog::reject);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void DeleteElementsDialog::enaDisa()
|
||||
{
|
||||
bool enabled = false;
|
||||
if (ui->checkBoxPrims->isChecked() ||
|
||||
ui->checkBoxPrimsSectorText->isChecked() ||
|
||||
ui->checkBoxAttributes->isChecked())
|
||||
enabled = true;
|
||||
ui->buttonBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(enabled);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void DeleteElementsDialog::getCheckedElements(bool &checkedPrims,
|
||||
bool &checkedPrimsSectorText,
|
||||
bool &checkedAttributes)
|
||||
{
|
||||
checkedPrims = ui->checkBoxPrims->isChecked();
|
||||
checkedPrimsSectorText = ui->checkBoxPrimsSectorText->isChecked();
|
||||
checkedAttributes = ui->checkBoxAttributes->isChecked();
|
||||
}
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SymbolEditor
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Chrsitian Roeskens, SLSE, 2017-04-12
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
|
||||
class Ui_DeleteElementsDialog;
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
class DeleteElementsDialog final : public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DeleteElementsDialog(QWidget *parent);
|
||||
~DeleteElementsDialog();
|
||||
void getCheckedElements(bool &checkedPrims,
|
||||
bool &checkedPrimsSectorText,
|
||||
bool &checkedAttributes);
|
||||
|
||||
private Q_SLOTS :
|
||||
void enaDisa();
|
||||
|
||||
protected:
|
||||
void initWidgets();
|
||||
|
||||
Ui_DeleteElementsDialog *ui;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SymbolEditor
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Chrsitian Roeskens, SLSE, 2017-04-12
|
||||
*/
|
||||
|
||||
#include "asb_resize_dialog.h"
|
||||
#include "asb_symbol_edit_scene.h"
|
||||
|
||||
#include "ui_asb_resize_dialog.h"
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
ResizeDialog::ResizeDialog(bool lockChecked, bool lockEnabled, QWidget *parent)
|
||||
: LtsWidgets::LtsFramelessDialog(parent, LtsWidgets::Behaviour::Popup)
|
||||
, m_ui(new Ui_ResizeDialog)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->sliderHScale, &QSlider::valueChanged, this, &ResizeDialog::handleChange);
|
||||
connect(m_ui->sliderVScale, &QSlider::valueChanged, this, &ResizeDialog::handleChange);
|
||||
|
||||
connect(m_ui->buttonBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, this, &LtsWidgets::LtsFramelessDialog::reject);
|
||||
connect(m_ui->buttonBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked, this, &LtsWidgets::LtsFramelessDialog::accept);
|
||||
|
||||
m_ui->checkBoxLock->setEnabled(lockEnabled);
|
||||
m_ui->checkBoxLock->setChecked(lockChecked);
|
||||
}
|
||||
|
||||
ResizeDialog::~ResizeDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ResizeDialog::handleChange(int val)
|
||||
{
|
||||
double hVal = double(val) / 100;
|
||||
double vVal = double(val) / 100;
|
||||
|
||||
if (!m_ui->checkBoxLock->isChecked())
|
||||
{
|
||||
hVal = double(m_ui->sliderHScale->value()) / 100;
|
||||
vVal = double(m_ui->sliderVScale->value()) / 100;
|
||||
}
|
||||
else
|
||||
sync(val);
|
||||
|
||||
m_ui->spinBoxHScale->setValue(hVal);
|
||||
m_ui->spinBoxVScale->setValue(vVal);
|
||||
|
||||
emit primitiveScaled(hVal, vVal);
|
||||
}
|
||||
|
||||
void ResizeDialog::sync(int val)
|
||||
{
|
||||
m_ui->sliderHScale->setValue(val);
|
||||
m_ui->sliderVScale->setValue(val);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SymbolEditor
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Chrsitian Roeskens, SLSE, 2017-04-12
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
|
||||
class Ui_ResizeDialog;
|
||||
/**
|
||||
@author Stephan Kuhagen <stephan.kuhagen@rheinmetall.com>
|
||||
*/
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
class ResizeDialog final : public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ResizeDialog(bool lockChecked, bool lockEnabled, QWidget *parent = nullptr);
|
||||
~ResizeDialog();
|
||||
|
||||
signals:
|
||||
void primitiveScaled(double xScale, double yScale);
|
||||
|
||||
private slots:
|
||||
void handleChange(int val);
|
||||
|
||||
private:
|
||||
void sync(int val);
|
||||
|
||||
Ui_ResizeDialog *m_ui;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SymbolEditor
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Chrsitian Roeskens, SLSE, 2017-04-12
|
||||
*/
|
||||
|
||||
#include "asb_rotate_dialog.h"
|
||||
|
||||
#include "ui_asb_rotate_dialog.h"
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
RotateDialog::RotateDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsFramelessDialog(parent, LtsWidgets::Behaviour::Popup)
|
||||
, m_ui(new Ui_RotateDialog)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->spinBoxDegree->setSuffix(QStringLiteral(" °"));
|
||||
|
||||
connect(m_ui->sliderHDegree, &QSlider::valueChanged, this, &RotateDialog::handleValue);
|
||||
connect(m_ui->spinBoxDegree, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &RotateDialog::handleValue);
|
||||
connect(m_ui->buttonBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, this, &LtsWidgets::LtsFramelessDialog::reject);
|
||||
connect(m_ui->buttonBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked, this, &LtsWidgets::LtsFramelessDialog::accept);
|
||||
}
|
||||
|
||||
RotateDialog::~RotateDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void RotateDialog::handleValue(double val)
|
||||
{
|
||||
sync(val);
|
||||
emit rotationValueChanged(val);
|
||||
}
|
||||
|
||||
void RotateDialog::sync(double val)
|
||||
{
|
||||
m_ui->sliderHDegree->setValue(int(val));
|
||||
m_ui->spinBoxDegree->setValue(val);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SymbolEditor
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Chrsitian Roeskens, SLSE, 2017-04-12
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
|
||||
class Ui_RotateDialog;
|
||||
/**
|
||||
@author Stephan Kuhagen <stephan.kuhagen@rheinmetall.com>
|
||||
*/
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
class RotateDialog final : public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RotateDialog(QWidget *parent = nullptr);
|
||||
~RotateDialog();
|
||||
|
||||
private slots:
|
||||
void handleValue(double val);
|
||||
|
||||
signals:
|
||||
void rotationValueChanged(double val);
|
||||
|
||||
private:
|
||||
void sync(double val);
|
||||
|
||||
Ui_RotateDialog *m_ui;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SymbolEditor
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Chrsitian Roeskens, SLSE, 2017-04-12
|
||||
*/
|
||||
|
||||
#include "asb_save_as_symbol.h"
|
||||
#include "ui_asb_save_as_symbol.h"
|
||||
#include <LtsWidgets/lts_dialog_button_box.h>
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
SaveAsSymbol::SaveAsSymbol(QVariant &dlgData, const std::shared_ptr<FileManagement::Interface::Dtc> &flmDtc, QWidget *parent)
|
||||
: LtsWidgets::LtsFramelessDialog(parent)
|
||||
, m_ui(new Ui_SaveAsSymbol)
|
||||
, m_buttonBox(new LtsWidgets::LtsDialogButtonBox(this))
|
||||
, m_flmDtc(flmDtc)
|
||||
, m_dlgData(dlgData)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->verticalLayout->addWidget(m_buttonBox);
|
||||
|
||||
connect(m_buttonBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked,
|
||||
this, &SaveAsSymbol::reject);
|
||||
connect(m_buttonBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked,
|
||||
this, &SaveAsSymbol::accept);
|
||||
connect(m_ui->leName, &QLineEdit::textChanged,
|
||||
this, &SaveAsSymbol::onInputChanged);
|
||||
connect(m_flmDtc.get(), &FileManagement::Interface::Dtc::fileContentChanged,
|
||||
this, &SaveAsSymbol::onFileContentChanged);
|
||||
|
||||
onInputChanged(m_ui->leName->text());
|
||||
|
||||
m_flmDtc->fileContents([this](const FileManagement::FileContent & data)
|
||||
{
|
||||
onFileContentChanged(data, DataModification::eAdded);
|
||||
});
|
||||
}
|
||||
|
||||
SaveAsSymbol::~SaveAsSymbol()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void SaveAsSymbol::accept()
|
||||
{
|
||||
m_symbolName = m_ui->leName->text();
|
||||
m_dlgData.setValue(m_symbolName);
|
||||
LtsFramelessDialog::accept();
|
||||
}
|
||||
|
||||
void SaveAsSymbol::onInputChanged(const QString &input)
|
||||
{
|
||||
if (input.isEmpty())
|
||||
{
|
||||
m_ui->lblNameError->setText(tr("Name must not be empty"));
|
||||
m_ui->lblNameError->setStyleSheet(QStringLiteral("color: rgb(255, 0, 0);"));
|
||||
}
|
||||
else if (m_takenNames.contains(input))
|
||||
{
|
||||
m_ui->lblNameError->setText(tr("Name is already taken"));
|
||||
m_ui->lblNameError->setStyleSheet(QStringLiteral("color: rgb(255, 0, 0);"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->lblNameError->setStyleSheet(QStringLiteral("color: rgb(0, 255, 0);"));
|
||||
m_ui->lblNameError->setText(tr("Name is ok"));
|
||||
}
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(!(input.isEmpty() || m_takenNames.contains(input)));
|
||||
}
|
||||
|
||||
void SaveAsSymbol::onFileContentChanged(const FileManagement::FileContent &data, DataModification modType)
|
||||
{
|
||||
if (data.fileType() != FileManagement::FileType::OperatorDefinedSymbol)
|
||||
return;
|
||||
|
||||
QString name = QString::fromStdString(data.name());
|
||||
|
||||
if (modType == DataModification::eRemoved)
|
||||
m_takenNames.removeAll(name);
|
||||
else
|
||||
m_takenNames.append(name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SymbolEditor
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Chrsitian Roeskens, SLSE, 2017-04-12
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
#include <FileManagement/flm_dtc.h>
|
||||
|
||||
class Ui_SaveAsSymbol;
|
||||
|
||||
namespace LtsWidgets
|
||||
{
|
||||
class LtsDialogButtonBox;
|
||||
}
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
class SaveAsSymbol final : public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SaveAsSymbol(QVariant &dlgData, const std::shared_ptr<FileManagement::Interface::Dtc> &flmDtc, QWidget *parent = nullptr);
|
||||
~SaveAsSymbol();
|
||||
QString symbolName() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void accept() override final;
|
||||
void onInputChanged(const QString &input);
|
||||
void onFileContentChanged(const FileManagement::FileContent &data, DataModification modType);
|
||||
|
||||
private: // attributes
|
||||
Ui_SaveAsSymbol *m_ui;
|
||||
QString m_symbolName;
|
||||
LtsWidgets::LtsDialogButtonBox *m_buttonBox;
|
||||
QStringList m_takenNames;
|
||||
std::shared_ptr<FileManagement::Interface::Dtc> m_flmDtc;
|
||||
QVariant &m_dlgData;
|
||||
};
|
||||
|
||||
} //namespace AdvancedSymbology
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SymbolEditor
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Chrsitian Roeskens, SLSE, 2017-04-12
|
||||
*/
|
||||
|
||||
|
||||
#include "asb_select_text_dialog.h"
|
||||
|
||||
#include "ui_asb_select_text_dialog.h"
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
SelectTextDialog::SelectTextDialog(QVariant &returnData, QWidget *parent)
|
||||
: LtsWidgets::LtsFramelessDialog(parent)
|
||||
, ui(new Ui_SelectTextDialog)
|
||||
, m_returnData(returnData)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->buttonBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, this, &SelectTextDialog::reject);
|
||||
connect(ui->buttonBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked, this, &SelectTextDialog::accept);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
SelectTextDialog::~SelectTextDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SelectTextDialog::accept()
|
||||
{
|
||||
QVariantMap vmap;
|
||||
vmap.insert(QStringLiteral("line_one"), ui->lineEdit1->text());
|
||||
vmap.insert(QStringLiteral("line_two"), ui->lineEdit2->text());
|
||||
m_returnData.setValue(vmap);
|
||||
LtsWidgets::LtsFramelessDialog::accept();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SymbolEditor
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Chrsitian Roeskens, SLSE, 2017-04-12
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QVariant>
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
|
||||
class Ui_SelectTextDialog;
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
class SelectTextDialog final : public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SelectTextDialog(QVariant &returnData, QWidget *parent);
|
||||
~SelectTextDialog();
|
||||
|
||||
protected:
|
||||
Ui_SelectTextDialog *ui;
|
||||
|
||||
private:
|
||||
//NGL::INGLLogger& m_logger;
|
||||
QVariant &m_returnData;
|
||||
|
||||
// QDialog interface
|
||||
public slots:
|
||||
void accept() override final;
|
||||
};
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,344 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SymbolEditor
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Chrsitian Roeskens, SLSE, 2017-04-12
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QGraphicsScene>
|
||||
#include <QPen>
|
||||
|
||||
#include <Viewer/SituationMap/SymbologyXML/primitive.h>
|
||||
|
||||
class QGraphicsItem;
|
||||
class QGraphicsRectItem;
|
||||
class QGraphicsSceneMouseEvent;
|
||||
class QLabel;
|
||||
class QPolygonF;
|
||||
|
||||
/**
|
||||
\brief Implements mouse-events for editing symbol-items.
|
||||
|
||||
Derived class for user interaction with the preview and draw area of the
|
||||
SymbolEditor.
|
||||
|
||||
@author Stephan Kuhagen <stephan.kuhagen@rheinmetall.com>
|
||||
*/
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
class SymbolEditScene final : public QGraphicsScene
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SymbolEditScene(QObject *parent = nullptr);
|
||||
|
||||
void setCoordsLabels(QLabel *xLabel, QLabel *yLabel, QLabel *zoomLabel)
|
||||
{
|
||||
m_labelCoordsX = xLabel;
|
||||
m_labelCoordsY = yLabel;
|
||||
m_labelZoom = zoomLabel;
|
||||
}
|
||||
|
||||
//! Return the current zoom-value
|
||||
double zoom() const
|
||||
{
|
||||
return m_zoom;
|
||||
}
|
||||
//! Set the current zoom-value and return it
|
||||
double setZoom(double zoom);
|
||||
|
||||
//! Return current min zoom-value
|
||||
double minZoom() const
|
||||
{
|
||||
return m_zoomMin;
|
||||
}
|
||||
//! Set min zoom-value
|
||||
void setMinZoom(double min)
|
||||
{
|
||||
if (min < m_zoomMax) m_zoomMin = min;
|
||||
}
|
||||
|
||||
//! Return current max zoom-value
|
||||
double maxZoom() const
|
||||
{
|
||||
return m_zoomMax;
|
||||
}
|
||||
//! Set max zoom-value
|
||||
void setMaxZoom(double max)
|
||||
{
|
||||
if (max > m_zoomMin) m_zoomMax = max;
|
||||
}
|
||||
|
||||
//! The DrawModes
|
||||
enum DrawMode
|
||||
{
|
||||
NONE,
|
||||
ELLIPSE_START,
|
||||
ELLIPSE_SET,
|
||||
ELLIPSE_SET_START,
|
||||
ELLIPSE_SET_EXTENT,
|
||||
LINE_START,
|
||||
LINE_SET,
|
||||
POLYLINE_START,
|
||||
POLYLINE_SET,
|
||||
POLYGON_START,
|
||||
POLYGON_SET,
|
||||
RECT_START,
|
||||
RECT_SET,
|
||||
ICON_START,
|
||||
ICON_SET,
|
||||
TEXT_START,
|
||||
TEXT_SET,
|
||||
ELEMENT_DELETE,
|
||||
ELEMENT_MOVE,
|
||||
ELEMENT_ROTATE,
|
||||
ELEMENT_PASTE,
|
||||
ELEMENT_SCALE,
|
||||
ELEMENT_SELECT
|
||||
};
|
||||
|
||||
/**
|
||||
Set the drawMode. This is used for Mouse-Interaction when the user draws
|
||||
or manipulates new Primitives.
|
||||
\param mode: the new DrawMode
|
||||
*/
|
||||
void setDrawMode(DrawMode mode);
|
||||
|
||||
/**
|
||||
Return the current DrawMode
|
||||
\return DrawMode
|
||||
*/
|
||||
DrawMode getDrawMode() const
|
||||
{
|
||||
return m_drawMode;
|
||||
}
|
||||
|
||||
/**
|
||||
If the scene manipulates the data, do not update the GraphicsViews
|
||||
*/
|
||||
bool updatesBlocked() const { return m_blockUpdates; }
|
||||
|
||||
/**
|
||||
Called from a SEPathItem, when its Primitive needs to tell the Editor,
|
||||
that it has been changed by user-interaction. Triggers emit primitiveChanged()
|
||||
*/
|
||||
void primitivePathItemChanged() { emit primitiveChanged(true); }
|
||||
|
||||
void setShowGrid(bool b);
|
||||
|
||||
void setShowDrawingArea(bool b);
|
||||
|
||||
void setGridWidth(double width);
|
||||
|
||||
void reset();
|
||||
public slots:
|
||||
/**
|
||||
Set the Pen for Draw/Edit-Operations
|
||||
*/
|
||||
void setPen(const QPen &pen)
|
||||
{
|
||||
m_pen = pen;
|
||||
}
|
||||
|
||||
void update(const QRectF &rect = QRectF());
|
||||
|
||||
//! Cancel the current action
|
||||
void cancelCurrentAction();
|
||||
|
||||
signals:
|
||||
/**
|
||||
Emit a signal, if the zoom value has changed.
|
||||
\param zoom: the new zoom value.
|
||||
*/
|
||||
void zoomChanged(double zoom);
|
||||
|
||||
/**
|
||||
Emit a signal to add a new Primitive to the current Symbol
|
||||
\param p: The new Primitive to add
|
||||
*/
|
||||
void addPrimitive(SymbologyXML::Primitive *p);
|
||||
|
||||
/**
|
||||
Emit a signal, if a Primitive has changed
|
||||
*/
|
||||
void primitiveChanged(bool changed);
|
||||
|
||||
/**
|
||||
Emit a signal, if a Primitive has been moved by user-interaction
|
||||
*/
|
||||
void primitiveMoved(QPointF diff);
|
||||
|
||||
/**
|
||||
Transform the selected primitive
|
||||
*/
|
||||
void transformSelection(int key, Qt::KeyboardModifiers modifiers);
|
||||
|
||||
protected:
|
||||
/**
|
||||
Process a QGraphicsSceneMouseEvent. Used for displaying coordinates and
|
||||
Primitive-Editing
|
||||
\param mouseEvent: The Event
|
||||
*/
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) override;
|
||||
/**
|
||||
Process a QKeyEvent. Used for zooming and shift-functions
|
||||
\param keyEvent: The Event
|
||||
*/
|
||||
void keyPressEvent(QKeyEvent *keyEvent) override;
|
||||
/**
|
||||
Process a QKeyEvent. Used for zooming and shift-functions
|
||||
\param keyEvent: The Event
|
||||
*/
|
||||
void keyReleaseEvent(QKeyEvent *keyEvent) override;
|
||||
|
||||
/**
|
||||
Process a QGraphicsSceneMouseEvent, used for adding new Primitives and
|
||||
manipulating existing Primitives.
|
||||
\param mouseEvent: The Event
|
||||
*/
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) override;
|
||||
|
||||
/**
|
||||
Process a QGraphicsSceneMouseEvent, used for announcing end of manipulation
|
||||
of Primitives.
|
||||
\param mouseEvent: The Event
|
||||
*/
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) override;
|
||||
|
||||
/**
|
||||
Process a QGraphicsSceneMouseEvent, used for announcing end of manipulation
|
||||
of Primitives, i.e. Polyline and Polygon.
|
||||
\param mouseEvent: The Event
|
||||
*/
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouseEvent) override;
|
||||
|
||||
// QGraphicsScene interface
|
||||
void drawForeground(QPainter *painter, const QRectF &rect) override final;
|
||||
|
||||
private:
|
||||
//! NGLLogger
|
||||
NGL::INGLLogger &logger;
|
||||
|
||||
/**
|
||||
Create a new Ellipse. The point is the start-point of the bounding rect.
|
||||
\param start: Startpoint of bounding rect.
|
||||
*/
|
||||
void newEllipse(const QPointF &start);
|
||||
/**
|
||||
Manipulate a new Ellipse
|
||||
\param point: Change the second point of the boundnig rect end to this point
|
||||
*/
|
||||
void setEllipse(const QPointF &point);
|
||||
/**
|
||||
Set Start-Angle of a Ellipse. A line is drawn from the center to the given
|
||||
point to indicate the start angle.
|
||||
\param point: Reference point for the line
|
||||
*/
|
||||
void ellipseSetAngleStart(const QPointF &point);
|
||||
/**
|
||||
Set Extent-Angle of a Ellipse. A line is drawn from the center to the given
|
||||
point to indicate the extent angle.
|
||||
\param point: Reference point for the line
|
||||
*/
|
||||
void ellipseSetAngleExtent(const QPointF &point);
|
||||
|
||||
/**
|
||||
Create a new Line starting from the given point
|
||||
\param start: Startpoint of new line
|
||||
*/
|
||||
void newLine(const QPointF &start);
|
||||
/**
|
||||
Manipulate a new line
|
||||
\param point: Change the line end to this point
|
||||
*/
|
||||
void setLine(const QPointF &point);
|
||||
|
||||
/**
|
||||
Create a new Polygon starting from the given point
|
||||
\param start: Startpoint of new polygon
|
||||
*/
|
||||
void newPolygon(const QPointF &start);
|
||||
/**
|
||||
Add new point to polygon
|
||||
\param next: Set the next point
|
||||
*/
|
||||
void addPointPolygon(const QPointF &next);
|
||||
/**
|
||||
Manipulate a new polygon
|
||||
\param point: Set the last point to this point
|
||||
*/
|
||||
void setPolygon(const QPointF &point);
|
||||
|
||||
|
||||
/**
|
||||
Create a new Rect.
|
||||
\param start: Startpoint
|
||||
*/
|
||||
void newRect(const QPointF &start);
|
||||
/**
|
||||
Manipulate a new rect
|
||||
\param end: Change the second point.
|
||||
*/
|
||||
void setRect(const QPointF &point);
|
||||
|
||||
/**
|
||||
Create a Primitive and emit a signal announcing it.
|
||||
\param type: Type of the new Primitive
|
||||
*/
|
||||
void sendNewItem(SymbologyXML::Primitive::t_primitive type);
|
||||
|
||||
/**
|
||||
Rotate the stacking-order and selection of primitives
|
||||
*/
|
||||
void rotateSelection();
|
||||
//! The currently drawn/edited graphicsItems
|
||||
QPointF m_currentItemStartPoint;
|
||||
QGraphicsItem *m_currentItem, *m_tmpItem;
|
||||
//! Visible bounding rect for some Primitives
|
||||
QGraphicsRectItem *m_boundingRect;
|
||||
//! temp polygon for constructing polygons and polylines
|
||||
QPolygonF m_tmpPolygon;
|
||||
//! Start and Extent for Ellipsis
|
||||
double m_ellipsisStart, m_ellipsisExtent;
|
||||
//! construct Ellipsis: transitions 1° <--> 360° adjustment
|
||||
double m_lastEllipseAngle, m_adjustAngle;
|
||||
//!
|
||||
double m_gridWidth;
|
||||
//! If false, the Ellipsis ignores the angles
|
||||
bool m_useAngles;
|
||||
//!
|
||||
bool m_showGrid;
|
||||
//!
|
||||
bool m_showDrawingArea;
|
||||
//! The current Pen
|
||||
QPen m_pen;
|
||||
//! The Pen for the bounding rect
|
||||
QPen m_rectPen;
|
||||
//! The current zoom value and upper/lower limit
|
||||
double m_zoom, m_zoomMin, m_zoomMax;
|
||||
//! Pointer to labels for displaying current mouse coordinates
|
||||
QLabel *m_labelCoordsX, *m_labelCoordsY, *m_labelZoom;
|
||||
//! The current DrawMode
|
||||
DrawMode m_drawMode;
|
||||
//! If shift or Alt is pressed, modify some drawing functions
|
||||
bool m_shiftPressed;
|
||||
bool m_altPressed;
|
||||
//! If the scene manipulates the data, do not update the GraphicsViews
|
||||
bool m_blockUpdates;
|
||||
//! The position of the mouse-pointer at the last click
|
||||
QPointF m_mousePos;
|
||||
//!
|
||||
QPointF m_lastMousePos;
|
||||
//!
|
||||
QPointF m_startPos;
|
||||
|
||||
|
||||
}; // class SymbolEditScene
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,236 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SymbolEditor
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Chrsitian Roeskens, SLSE, 2017-04-12
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
|
||||
#include <Viewer/SituationMap/SymbologyXML/symbol_types.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
class QGraphicsScene;
|
||||
class QComboBox;
|
||||
|
||||
namespace Ui { class SymbolEditor; }
|
||||
namespace FileManagement { class ForeignGuiInterface; }
|
||||
namespace SymbologyXML { class Symbol; class Primitive;}
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
class SymbolEditorPrivate;
|
||||
|
||||
class SymbolEditor final : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit SymbolEditor(LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
|
||||
~SymbolEditor();
|
||||
|
||||
bool init(const std::shared_ptr<FileManagement::Interface::Ftc> &flmFtc,
|
||||
const std::shared_ptr<FileManagement::Interface::Dtc> &flmDtc,
|
||||
const std::shared_ptr<FileManagement::ForeignGuiInterface> &flmGui,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
bool asApp = false);
|
||||
|
||||
void keyPressEvent(QKeyEvent *keyEvent) override final;
|
||||
void retranslate() override final;
|
||||
bool apply() override final;
|
||||
|
||||
bool writeFile(bool saveAsNew);
|
||||
|
||||
enum e_category
|
||||
{
|
||||
CATEGORY_UNDEFINED = 0,
|
||||
CATEGORY_HEADQUARTER,
|
||||
CATEGORY_DIMENSION,
|
||||
CATEGORY_AFFILIATION,
|
||||
CATEGORY_BCDAB,
|
||||
CATEGORY_COMMANDLEVEL,
|
||||
CATEGORY_MOBILITY,
|
||||
CATEGORY_BRANCH,
|
||||
CATEGORY_ICON_TYPE
|
||||
};
|
||||
|
||||
enum t_editMode
|
||||
{
|
||||
EDIT_NONE,
|
||||
EDIT_PICK,
|
||||
EDIT_MOVE,
|
||||
EDIT_ROTATE,
|
||||
EDIT_SCALE,
|
||||
EDIT_COPY,
|
||||
EDIT_PASTE,
|
||||
EDIT_DELETE,
|
||||
EDIT_EDIT
|
||||
};
|
||||
|
||||
public slots:
|
||||
|
||||
void movePrimitive(QPointF diff);
|
||||
bool createNewSymbol(const QString &symbolname);
|
||||
void setChanged(bool changed);
|
||||
void updateGraphicViews(bool editview = true, bool preview = true);
|
||||
void reset();
|
||||
void slotSaveAs();
|
||||
void slotSave();
|
||||
void slotSaveFinished();
|
||||
void slotImportTemplate();
|
||||
|
||||
signals:
|
||||
|
||||
void documentChanged(bool changed);
|
||||
void symbolSaved(bool saveToLib, bool saveToCurrent, bool saveToAll);
|
||||
void canceled();
|
||||
void helpRequested();
|
||||
void invokeHelp(const QString &context);
|
||||
void saveFinished();
|
||||
|
||||
private slots:
|
||||
|
||||
void transformSelection(int key, Qt::KeyboardModifiers modifiers);
|
||||
|
||||
void onToolButtonSelectClicked();
|
||||
void onToolButtonRotateClicked();
|
||||
void onToolButtonScaleClicked();
|
||||
void onToolButtonDeleteClicked();
|
||||
void onToolButtonClearClicked();
|
||||
void onToolButtonUndoClicked();
|
||||
void onToolButtonCopyClicked();
|
||||
void onToolButtonPasteClicked();
|
||||
void onToolButtonEllipseClicked();
|
||||
void onToolButtonLineClicked();
|
||||
void onToolButtonPolylineClicked();
|
||||
void onToolButtonPolygonClicked();
|
||||
void onToolButtonRectClicked();
|
||||
void onToolButtonTextClicked();
|
||||
|
||||
void onPushButtonFillColorClicked();
|
||||
|
||||
void onComboBoxDimenCurrentIndexChanged(int index);
|
||||
void onComboBoxAffilCurrentIndexChanged(int index);
|
||||
void onComboBoxBCDABCurrentIndexChanged(int index);
|
||||
void onComboBoxHeadquarterCurrentIndexChanged(int index);
|
||||
void onComboBoxCommandLevelCurrentIndexChanged(int index);
|
||||
void onComboBoxMobCurrentIndexChanged(int index);
|
||||
void onComboBoxVehicleCurrentIndexChanged(int index);
|
||||
void onComboBoxIntrinsicMobCurrentIndexChanged(int index);
|
||||
void onComboBoxIntrinsicMob2CurrentIndexChanged(int index);
|
||||
void onComboBoxArmingCurrentIndexChanged(int index);
|
||||
|
||||
void onListViewMiscItemSelectionChanged();
|
||||
|
||||
void onCheckBoxVehicleStateChanged(int state);
|
||||
void onCheckBoxArmingStateChanged(int state);
|
||||
void onCheckBoxMainStateChanged(int state);
|
||||
|
||||
void onComboBoxSector1CurrentIndexChanged(int index);
|
||||
void onComboBoxSectorMainCurrentIndexChanged(int index);
|
||||
|
||||
void onListViewSectorMainItemSelectionChanged();
|
||||
|
||||
void onComboBoxSector2CurrentIndexChanged(int index);
|
||||
|
||||
void help_on_ComboBoxIndexChanged(QComboBox *comboBox,
|
||||
int index, const QMap<int, QString> &contv,
|
||||
SymbologyXML::SymbolTypes::t_icon_type iconType,
|
||||
SymbologyXML::SymbolTypes::t_sector_position pos,
|
||||
SymbologyXML::SymbolTypes::t_sector_rectpos rectpos = SymbologyXML::SymbolTypes::SECTOR_RECTPOS_DEFAULT);
|
||||
|
||||
|
||||
void onComboBoxAlign1CurrentIndexChanged(int index);
|
||||
void onComboBoxAlign2CurrentIndexChanged(int index);
|
||||
void onComboBoxAlign3CurrentIndexChanged(int index);
|
||||
|
||||
void onComboBoxColorCurrentIndexChanged(int index);
|
||||
void onComboBoxLineStyleCurrentIndexChanged(int index);
|
||||
|
||||
void onLineEdit1TextChanged(const QString &text);
|
||||
void onLineEdit2TextChanged(const QString &text);
|
||||
void onLineEdit3TextChanged(const QString &text);
|
||||
|
||||
void onListViewTruppengattungItemSelectionChanged();
|
||||
|
||||
void onCheckBoxBackgroundStateChanged(int state);
|
||||
void onCheckBoxCopyValuesStateChanged(int state);
|
||||
void onCheckBoxFillStateChanged(int state);
|
||||
void onCheckBoxPlannedStateChanged(int state);
|
||||
void onCheckBoxDrawAreaStateChanged(int state);
|
||||
|
||||
void onSpinBoxRasterValueChanged(double d);
|
||||
void onSpinBoxLineWidthValueChanged(double d);
|
||||
void onSpinBoxScaleValueChanged(double d);
|
||||
|
||||
void onSliderTransparencyValueChanged(int value);
|
||||
|
||||
void setZoom(double zoom);
|
||||
|
||||
void addItem(SymbologyXML::Primitive *prim);
|
||||
|
||||
void selectionChanged();
|
||||
|
||||
private:
|
||||
|
||||
void resetGUI();
|
||||
void updateGUI();
|
||||
void updateSymbolAttributesWidgets();
|
||||
void updateTextProperties();
|
||||
void resetToolButtonGroupState();
|
||||
|
||||
void pushUndo();
|
||||
void popUndo();
|
||||
void clearUndo();
|
||||
|
||||
void restoreSelection(SymbologyXML::Primitive *prim);
|
||||
void copyFromSelectedPrimitive();
|
||||
void enableSelectMove(bool enable);
|
||||
|
||||
void setPushButtonFillColorBackground(QColor color);
|
||||
|
||||
QIcon getIcon(e_category category, SymbologyXML::SymbolTypes::t_icon_type iconType,
|
||||
int iconId, QSize iconSize);
|
||||
|
||||
int getFrameSymbolID(SymbologyXML::SymbolTypes::t_dimen dimen,
|
||||
SymbologyXML::SymbolTypes::t_affil affil);
|
||||
|
||||
void fillListWidget(const QMap<int, QString> &container, QWidget *widget,
|
||||
e_category category, SymbologyXML::SymbolTypes::t_icon_type iconType,
|
||||
bool withIcons = true, bool sort = true);
|
||||
|
||||
void widgetInsertItem(QWidget *widget, int index, const QString &text, int key,
|
||||
e_category category, SymbologyXML::SymbolTypes::t_icon_type iconType,
|
||||
bool withIcons);
|
||||
|
||||
void drawSymbol(const SymbologyXML::Symbol *symbol, QGraphicsScene *scene,
|
||||
const QColor &color, const QColor &fillColor,
|
||||
double z, bool isAttrib = false, bool updateMap = false, bool drawBoundRect = false);
|
||||
|
||||
void drawSymbolPrimitive(SymbologyXML::Primitive *primitive, QGraphicsScene *scene,
|
||||
const QColor &color, const QColor &fillColor,
|
||||
double z, bool isAttrib = false, bool drawBoundRect = false);
|
||||
|
||||
void copyElementsFromSymbol(const SymbologyXML::Symbol &tmpSymbol) const;
|
||||
|
||||
Ui::SymbolEditor *m_ui;
|
||||
SymbolEditorPrivate *m_internal;
|
||||
LtsSession::LtsSession *m_session;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SymbolEditor
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2016-11-02
|
||||
*/
|
||||
|
||||
#include "asb_symbol_editor_gui_plugin.h"
|
||||
#include "asb_symbol_editor.h"
|
||||
|
||||
#include <LtsWidgets/lts_splash.h>
|
||||
#include <Viewer/SituationMap/Symbology/symbol_dictionary.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
|
||||
: GuiPluginBase::Interface(session, NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("SymbolEditor"))
|
||||
{}
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
|
||||
m_flmDtc->enableFileContent();
|
||||
m_flmDtc->enableFolder();
|
||||
m_flmFtc->enableFileContentModify();
|
||||
|
||||
|
||||
LtsWidgets::PluginData plData;
|
||||
plData.menuGroup = menuGroup();
|
||||
plData.menuText = tr("Symbol Editor");
|
||||
plData.identifier = QLatin1String("AsbSymEditDialog");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:draw_symbol.svg"));
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eSpecial;
|
||||
|
||||
//as mainFlag
|
||||
if (getFlags().testFlag(LtsAppDescriptor::PluginInfo::Flag::MAIN))
|
||||
{
|
||||
plData.layoutArea = LtsWidgets::LayoutArea::eMainTab;
|
||||
plData.createInstant = LtsWidgets::CreateInstantType::CreateInstantAndDiscardAction;
|
||||
plData.createWidgetFunc = [this](QWidget * parent)
|
||||
{
|
||||
return LtsWidgets::initDialog(new SymbolEditor(m_session, parent),
|
||||
m_flmFtc, m_flmDtc, m_flmGui, m_ppmDtc, true);
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
plData.layoutArea = LtsWidgets::LayoutArea::eDialogTab;
|
||||
plData.createWidgetFunc = [this](QWidget * parent)
|
||||
{
|
||||
return LtsWidgets::initDialog(new SymbolEditor(m_session, parent),
|
||||
m_flmFtc, m_flmDtc, m_flmGui, m_ppmDtc, false);
|
||||
};
|
||||
}
|
||||
|
||||
ret.append(plData);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
void InterfaceImpl::init()
|
||||
{
|
||||
LtsWidgets::Splash::getInstance()->setMessage(tr("Loading Esri dictionary..."));
|
||||
|
||||
connect(this, &InterfaceImpl::signalInitDone,
|
||||
m_session, &LtsSession::LtsSession::slotPluginInitDone,
|
||||
static_cast<Qt::ConnectionType>(Qt::QueuedConnection | Qt::UniqueConnection));
|
||||
|
||||
if (LtsSession::LtsSession::s_valgrind)
|
||||
{
|
||||
qWarning() << "AES: skipped loading esri symbology dictionary";
|
||||
emit signalInitDone();
|
||||
return;
|
||||
}
|
||||
|
||||
AdvancedSymbology::SymbolDictionary &dict =
|
||||
AdvancedSymbology::SymbolDictionary::dictionary(AdvancedSymbology::SymbolDictionary::defaultSymbologyType());
|
||||
dict.load();
|
||||
|
||||
if (dict.isLoaded())
|
||||
{
|
||||
emit signalInitDone();
|
||||
return;
|
||||
}
|
||||
|
||||
QTimer::singleShot(250, this, &InterfaceImpl::init); // look again if not loaded yet
|
||||
}
|
||||
*/
|
||||
|
||||
bool InterfaceImpl::fetchInterfaces()
|
||||
{
|
||||
return m_session->getDtc<FileManagement::DataInterface>(m_flmDtc) &&
|
||||
m_session->getFtc<FileManagement::DataInterface>(m_flmFtc) &&
|
||||
m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc) &&
|
||||
m_session->getForeignGuiInterface(m_flmGui);
|
||||
}
|
||||
|
||||
|
||||
void InterfaceImpl::clearInterfaces()
|
||||
{
|
||||
m_flmDtc = nullptr;
|
||||
m_flmFtc = nullptr;
|
||||
m_flmGui = nullptr;
|
||||
m_ppmDtc = nullptr;
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<GuiPluginBase::Interface> GuiPlugin::createGuiInterface(LtsSession::LtsSession *session)
|
||||
{
|
||||
return std::make_shared<InterfaceImpl>(session);
|
||||
}
|
||||
|
||||
|
||||
} // namespace AdvancedSymbology
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SymbolEditor
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Chrsitian Roeskens, SLSE, 2017-04-12
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AdvancedSymbology/asb_gui_plugin_interface.h>
|
||||
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
namespace LtsUtils
|
||||
{
|
||||
class RequestHelper;
|
||||
}
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:asb.symedit")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return ForeignGuiInterface::pluginName(); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Exercise ||
|
||||
partition == IDL::PartitionType::Global ||
|
||||
partition == IDL::PartitionType::Replay;
|
||||
}
|
||||
};
|
||||
|
||||
class InterfaceImpl final
|
||||
: public QObject
|
||||
, public ForeignGuiInterface
|
||||
, public GuiPluginBase::Interface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
|
||||
QString menuGroup() const override { return tr("Advanced Symbology"); }
|
||||
bool fetchInterfaces() override;
|
||||
void clearInterfaces() override;
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
// void init() override;
|
||||
|
||||
signals:
|
||||
void signalInitDone();
|
||||
|
||||
private: // methods
|
||||
LtsWidgets::LtsDialog *onShowSymbolEditorDialog();
|
||||
|
||||
private: // attributes
|
||||
std::shared_ptr<FileManagement::Interface::Dtc> m_flmDtc;
|
||||
std::shared_ptr<FileManagement::Interface::Ftc> m_flmFtc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
};
|
||||
} // namespace AdvancedSymbology
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SymbolEditor
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Chrsitian Roeskens, SLSE, 2017-04-12
|
||||
*/
|
||||
|
||||
|
||||
#include "flm_reply_handler.h"
|
||||
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
FileManagementReplyHandler::FileManagementReplyHandler(LtsUtils::RequestHelper *rh, QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_requestHelper(rh)
|
||||
, m_id(-1)
|
||||
{
|
||||
qRegisterMetaType<Core::FunctionReply>("Core::FunctionReply");
|
||||
}
|
||||
|
||||
|
||||
void FileManagementReplyHandler::requestReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
emit signalFileContentModifyReplyReceived();
|
||||
}
|
||||
|
||||
|
||||
void FileManagementReplyHandler::onGetFileContentDataReply(const FileManagement::GetFileContentDataReply &replyObject)
|
||||
{
|
||||
m_content = replyObject.content();
|
||||
m_id = replyObject.id();
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SymbolEditor
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Chrsitian Roeskens, SLSE, 2017-04-12
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <FileManagement/flm_ftc.h>
|
||||
#include <FileManagement/flm_ftc_types.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
|
||||
namespace LtsUtils
|
||||
{
|
||||
class RequestHelper;
|
||||
}
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
class FileManagementReplyHandler final
|
||||
: public QObject
|
||||
, public FileManagement::Interface::Ftc::FileContentModifyReplyHandler
|
||||
, public FileManagement::Interface::Ftc::GetFileContentDataReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit FileManagementReplyHandler(LtsUtils::RequestHelper *rh, QObject *parent);
|
||||
|
||||
const std::vector<uint8_t> &getContent() const { return m_content; }
|
||||
int32_t getId() const { return m_id; }
|
||||
|
||||
signals:
|
||||
void signalFileContentModifyReplyReceived();
|
||||
|
||||
protected:
|
||||
|
||||
// file content
|
||||
void onFileContentModifyReply(const Core::FunctionReplyObject &replyObject) override final { requestReply(replyObject); }
|
||||
void onGetFileContentDataReply(const FileManagement::GetFileContentDataReply &replyObject) override final;
|
||||
|
||||
private:
|
||||
|
||||
void requestReply(const Core::FunctionReplyObject &replyObject);
|
||||
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
std::vector<uint8_t> m_content;
|
||||
int32_t m_id;
|
||||
|
||||
}; // FileManagementReplyHandler
|
||||
|
||||
} // namespace PlanEditorPlugin
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DeleteElementsDialog</class>
|
||||
<widget class="QWidget" name="DeleteElementsDialog">
|
||||
<property name="windowTitle">
|
||||
<string>Delete Elements</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Delete elements/attributes from Symbol</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxPrims">
|
||||
<property name="text">
|
||||
<string>Primitives</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxPrimsSectorText">
|
||||
<property name="text">
|
||||
<string>PrimsSectorText</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxAttributes">
|
||||
<property name="text">
|
||||
<string>Attributes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<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>
|
||||
<widget class="LtsWidgets::LtsDialogButtonBox" name="buttonBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsDialogButtonBox</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsWidgets/lts_dialog_button_box.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ResizeDialog</class>
|
||||
<widget class="QWidget" name="ResizeDialog">
|
||||
<property name="windowTitle">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QSlider" name="sliderHScale">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>400</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="spinBoxHScale">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>4.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QSlider" name="sliderVScale">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>400</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="spinBoxVScale">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>4.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="2" rowspan="2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxLock">
|
||||
<property name="text">
|
||||
<string>lock</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Horizontal:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Vertical:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<widget class="LtsWidgets::LtsDialogButtonBox" name="buttonBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsDialogButtonBox</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsWidgets/lts_dialog_button_box.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RotateDialog</class>
|
||||
<widget class="QWidget" name="RotateDialog">
|
||||
<property name="windowTitle">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="spinBoxDegree">
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::UpDownArrows</enum>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>360.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.100000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QSlider" name="sliderHDegree">
|
||||
<property name="maximum">
|
||||
<number>360</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="LtsWidgets::LtsDialogButtonBox" name="buttonBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsDialogButtonBox</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsWidgets/lts_dialog_button_box.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>sliderHDegree</tabstop>
|
||||
<tabstop>spinBoxDegree</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SaveAsSymbol</class>
|
||||
<widget class="QWidget" name="SaveAsSymbol">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>506</width>
|
||||
<height>76</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblName">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="leName">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblNameError">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 0, 0);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<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>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SelectTextDialog</class>
|
||||
<widget class="QWidget" name="SelectTextDialog">
|
||||
<property name="windowTitle">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Zeile 1:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit1"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Zeile 2:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit2"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="LtsWidgets::LtsDialogButtonBox" name="buttonBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsDialogButtonBox</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsWidgets/lts_dialog_button_box.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>lineEdit1</tabstop>
|
||||
<tabstop>lineEdit2</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+1599
File diff suppressed because it is too large.
Load diff
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
+8272
File diff suppressed because it is too large.
Load diff
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <getopt.h>
|
||||
#include <string>
|
||||
#include <nglapplication/nglapplication.h>
|
||||
#include <QString>
|
||||
#include <QDir>
|
||||
|
||||
#include "symboleditor.h"
|
||||
#include "nglsettings.h"
|
||||
|
||||
#include <LtsPluginManager/lts_plugin_loader.h>
|
||||
#include <PluginInterfaces/style_plugin_interface.h>
|
||||
#include <PluginInterfaces/project_plugin_interface.h>
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
NGLApplication app(argc, argv);
|
||||
app.createLogger("SymbolApp");
|
||||
|
||||
QCoreApplication::addLibraryPath(QString::fromLocal8Bit(qgetenv("GFS_PATH")) + QLatin1Literal("/lib"));
|
||||
// und auch in ../lib
|
||||
QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath() + QLatin1Literal("/../lib"));
|
||||
|
||||
// QString ini = QString::fromStdString(qgetenv("GFS_PATH").toStdString()) + QLatin1Literal("/gfs.cfg");
|
||||
// .. to keep some compatibility to old resource structure TODO: rm !
|
||||
|
||||
LtsPluginManager::LtsPluginLoader *pluginLoader = LtsPluginManager::LtsPluginLoader::getInstance();
|
||||
|
||||
pluginLoader->loadPlugins(LtsPluginManager::PluginType::STYLE, nullptr, QStringList() << QStringLiteral("rde.light"));
|
||||
pluginLoader->loadPlugins(LtsPluginManager::PluginType::PROJECT, nullptr, QStringList() << QStringLiteral("legatus"));
|
||||
|
||||
|
||||
QDir::setSearchPaths(QLatin1String("icon"), QStringList(QLatin1String(":/style/icons/")));
|
||||
QDir::setSearchPaths(QLatin1String("icon"), QStringList(QLatin1String(":/style/"))); // FIXME: does qt check for recursion ??
|
||||
|
||||
STARTUP_LOG(app.baseLogger());
|
||||
|
||||
SymbolEditor *edit = new SymbolEditor(QString(), QString(), QString(), false);
|
||||
if (!edit)
|
||||
return -1;
|
||||
|
||||
edit->show();
|
||||
|
||||
int result = app.exec();
|
||||
delete edit;
|
||||
SHUTDOWN_LOG(app.baseLogger());
|
||||
return result;
|
||||
} // int main(int argc, char *argv[])
|
||||
@@ -0,0 +1,37 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
# Created by Hannes Baeuerle, SLSE, 2017-06-14
|
||||
#
|
||||
|
||||
SET(AsbSymbolProxyGuiPlugin_SRCS
|
||||
asb_symbol_proxy_gui_plugin.h
|
||||
asb_symbol_proxy_gui_plugin.cpp
|
||||
asb_flm_subscriber.h
|
||||
asb_flm_subscriber.cpp
|
||||
flm_symbol_proxy.h
|
||||
flm_symbol_proxy.cpp
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(AsbSymbolProxyGuiPlugin_SRCS
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS AsbSymbolProxyGuiPlugin MODULE ${AsbSymbolProxyGuiPlugin_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(AsbSymbolProxyGuiPlugin
|
||||
AsbSymbolProxyGuiPluginInterface
|
||||
NGLLogger
|
||||
Qt5::Svg
|
||||
Qt5::Xml
|
||||
SituationMapGuiPluginInterface
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
FlmDataPluginInterface
|
||||
OpmDataPluginInterface
|
||||
advancedSymbology
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(AsbSymbolProxyGuiPlugin)
|
||||
|
||||
|
||||
@@ -0,0 +1,747 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Subscribe to file management service
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Norbert Thoden, NLE, 2019-04-15
|
||||
*/
|
||||
|
||||
#include "asb_flm_subscriber.h"
|
||||
|
||||
#include <LtsUtilsCore/dds_vector.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <Symbology/symbol_dictionary.h>
|
||||
#include <Symbology/sidc_codec.h>
|
||||
#include "flm_symbol_proxy.h"
|
||||
|
||||
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
|
||||
// Qt
|
||||
#include <QPointer>
|
||||
#include <QSet>
|
||||
#include <QSvgRenderer>
|
||||
#include <QImage>
|
||||
#include <QPainter>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QDomDocument>
|
||||
#include <QTimer>
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
uint qHash(SymbologyType type)
|
||||
{
|
||||
return static_cast<uint>(type);
|
||||
}
|
||||
|
||||
struct FileContentStruct
|
||||
{
|
||||
enum SymbolType { UnsupportedSymbol, EtsSymbol, XmlSymbol };
|
||||
enum ReplyState { Undefined, Requested, RequestFailure, ReplyReceived, ReplySuccess, ReplyFailure };
|
||||
|
||||
QString name;
|
||||
SymbolType type{UnsupportedSymbol};
|
||||
QString operatorName;
|
||||
int64_t lastModified{0};
|
||||
QStringList usrTags;
|
||||
QColor colorTobeReplaced;
|
||||
|
||||
struct Monitoring
|
||||
{
|
||||
qint64 requestTime{-1}; // sec
|
||||
int retryCnt{0};
|
||||
ReplyState replyState{Undefined};
|
||||
int replyContentSize{-1};
|
||||
};
|
||||
mutable Monitoring monitoring;
|
||||
};
|
||||
|
||||
qint64 getRequestTime()
|
||||
{
|
||||
return time(nullptr);
|
||||
}
|
||||
|
||||
QString toString(FileContentStruct::ReplyState rs)
|
||||
{
|
||||
switch (rs)
|
||||
{
|
||||
case FileContentStruct::Undefined:
|
||||
return QStringLiteral("Undefined");
|
||||
case FileContentStruct::Requested:
|
||||
return QStringLiteral("Requested");
|
||||
case FileContentStruct::RequestFailure:
|
||||
return QStringLiteral("RequestFailure");
|
||||
case FileContentStruct::ReplyReceived:
|
||||
return QStringLiteral("ReplyReceived");
|
||||
case FileContentStruct::ReplySuccess:
|
||||
return QStringLiteral("ReplySuccess");
|
||||
case FileContentStruct::ReplyFailure:
|
||||
return QStringLiteral("ReplyFailure");
|
||||
}
|
||||
return QStringLiteral("UnknownReplyState");
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
struct FlmSubscriber::Private
|
||||
{
|
||||
QHash<int32_t, FileContentStruct> m_fileContentMap; // fileContentId -> name
|
||||
QTimer *m_reFetchTimer{nullptr};
|
||||
FlmSymbolProxy m_symbolProxy;
|
||||
|
||||
QSet<SymbologyType> m_symbolDictionaryToUpdate;
|
||||
|
||||
std::shared_ptr<FileManagement::Interface::Dtc> m_flmDtc;
|
||||
std::shared_ptr<FileManagement::Interface::Ftc> m_flmFtc;
|
||||
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
|
||||
|
||||
static long m_counter;
|
||||
};
|
||||
long FlmSubscriber::Private::m_counter = 0;
|
||||
|
||||
|
||||
FlmSubscriber::FlmSubscriber(const std::shared_ptr<FileManagement::Interface::Dtc> &flmDtc,
|
||||
const std::shared_ptr<FileManagement::Interface::Ftc> &flmFtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc)
|
||||
: m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("AdvSymbology.FlmSubscriber"))
|
||||
, d(new Private())
|
||||
{
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " m_counter =" << ++d->m_counter;
|
||||
d->m_flmDtc = flmDtc;
|
||||
d->m_flmFtc = flmFtc;
|
||||
d->m_opmDtc = opmDtc;
|
||||
|
||||
d->m_reFetchTimer = new QTimer(this);
|
||||
d->m_reFetchTimer->setInterval(10000);
|
||||
connect(d->m_reFetchTimer, &QTimer::timeout,
|
||||
this, &FlmSubscriber::checkForReFetching);
|
||||
|
||||
// To enable QueuedConnection:
|
||||
qRegisterMetaType<FileManagement::FileContent>("FileManagement::FileContent");
|
||||
qRegisterMetaType<DataModification>("DataModification");
|
||||
}
|
||||
|
||||
FlmSubscriber::~FlmSubscriber()
|
||||
{
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " m_counter =" << d->m_counter--;
|
||||
|
||||
if (d->m_reFetchTimer)
|
||||
d->m_reFetchTimer->stop();
|
||||
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool FlmSubscriber::createFlmSymbolProxy(int type_placeholder)
|
||||
{
|
||||
Q_UNUSED(type_placeholder);
|
||||
if (!d->m_flmDtc || !d->m_flmFtc)
|
||||
return false;
|
||||
|
||||
d->m_flmDtc->enableFileContent();
|
||||
d->m_flmFtc->enableGetFileContentData();
|
||||
|
||||
//
|
||||
// 1 connect changed signals:
|
||||
//
|
||||
// avoid multiple connect
|
||||
connect(d->m_flmDtc.get(), &FileManagement::Interface::Dtc::fileContentChanged,
|
||||
this, &FlmSubscriber::onFileContentChanged, Qt::ConnectionType(Qt::QueuedConnection | Qt::UniqueConnection));
|
||||
|
||||
//
|
||||
// 2. retrieve FileContent
|
||||
//
|
||||
const auto cb = [this](const FileManagement::FileContent & data) -> void
|
||||
{
|
||||
updateFileContentMap(data);
|
||||
};
|
||||
if (!d->m_flmDtc->fileContents(cb))
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " Error performing fileContents";
|
||||
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " m_fileContentMap.size()=" << d->m_fileContentMap.size() ;
|
||||
|
||||
//
|
||||
// now we have all FileContentIds: -> retrieve contentDATA (svg data)
|
||||
//
|
||||
for (auto it = d->m_fileContentMap.cbegin(); it != d->m_fileContentMap.cend(); ++it)
|
||||
{
|
||||
const int fileContentId = it.key();
|
||||
FileManagement::GetFileContentDataRequest request(fileContentId);
|
||||
const FileContentStruct &fcsRef = it.value(); // monitoring is mutable
|
||||
|
||||
#ifdef LTS_DEBUG
|
||||
//#define SKIP_SOME_TO_TEST_REFETCHING
|
||||
#ifdef SKIP_SOME_TO_TEST_REFETCHING
|
||||
if (fileContentId>=98)
|
||||
request.fileContentId(-1);
|
||||
#endif // SKIP_SOME_TO_TEST_REFETCHING
|
||||
#endif // LTS_DEBUG
|
||||
|
||||
if (d->m_flmFtc->getFileContentDataRequest(request, this))
|
||||
{
|
||||
fcsRef.monitoring.requestTime = getRequestTime();
|
||||
fcsRef.monitoring.replyState = FileContentStruct::Requested;
|
||||
} else {
|
||||
fcsRef.monitoring.replyState = FileContentStruct::RequestFailure;
|
||||
ERROR_LOG(m_logger) << "Error requesting FileContentData, fileContentId=" << fileContentId;
|
||||
}
|
||||
|
||||
} // while
|
||||
|
||||
//
|
||||
// start reFetchTimer using rand to avoid heavy load at server side:
|
||||
//
|
||||
const int randomOffset = rand() % 10 + 5; // 5 .. 15
|
||||
QTimer::singleShot(randomOffset, this , [this]()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "start ReFetchingTimer";
|
||||
d->m_reFetchTimer->start(); // -> checkForReFetching
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void FlmSubscriber::onGetFileContentDataReply(const FileManagement::GetFileContentDataReply &reply)
|
||||
{
|
||||
const int32_t fileContentId = reply.id();
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START, " << fileContentId;
|
||||
|
||||
if (!d->m_fileContentMap.contains(fileContentId))
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " fileContentId unknown, fileContentId=" << fileContentId;
|
||||
return;
|
||||
}
|
||||
|
||||
const FileContentStruct &fcData = d->m_fileContentMap[fileContentId];
|
||||
fcData.monitoring.replyState = FileContentStruct::ReplyReceived;
|
||||
const QString &name = fcData.name;
|
||||
const QString &operatorName = fcData.operatorName;
|
||||
const qint64 lastModified = fcData.lastModified;
|
||||
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION
|
||||
<< " fileContentId=" << fileContentId
|
||||
<< " name=" << name
|
||||
<< " operatorName=" << operatorName
|
||||
<< " lastModified=" << lastModified
|
||||
<< " #bytes =" << reply.content().size();
|
||||
|
||||
fcData.monitoring.replyContentSize = reply.content().size(); // update ReplayState
|
||||
|
||||
switch (fcData.type)
|
||||
{
|
||||
case FileContentStruct::SymbolType::EtsSymbol:
|
||||
{
|
||||
QImage image;
|
||||
if (!svgToImage(QByteArray::fromRawData(reinterpret_cast<const char*>(&reply.content().at(0)), reply.content().size()), image))
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " svgToImage failed, fileContentId=" << fileContentId;
|
||||
fcData.monitoring.replyState = FileContentStruct::ReplyFailure; // update ReplayState
|
||||
return;
|
||||
}
|
||||
|
||||
// now we have metaData (fileContentId, name) and data (content/svg)
|
||||
|
||||
// transfer to symbolProxy:
|
||||
FlmSymbolProxy::SymbolData symbolData(name, image, fcData.colorTobeReplaced);
|
||||
|
||||
symbolData.setUsrTags(fcData.usrTags);
|
||||
|
||||
// store:
|
||||
d->m_symbolProxy.setSymbol(fileContentId, symbolData);
|
||||
fcData.monitoring.replyState = FileContentStruct::ReplySuccess; // update ReplayState
|
||||
break;
|
||||
}
|
||||
|
||||
case FileContentStruct::SymbolType::XmlSymbol:
|
||||
{
|
||||
FlmSymbolProxy::SymbolData symbolData(name, operatorName, lastModified, LtsUtils::toQByteArray(reply.content()));
|
||||
|
||||
if (symbolData.isXmlSymbol())
|
||||
{
|
||||
symbolData.setUsrTags(fcData.usrTags);
|
||||
// store it
|
||||
d->m_symbolProxy.setSymbol(fileContentId, symbolData);
|
||||
fcData.monitoring.replyState = FileContentStruct::ReplySuccess; // update ReplayState
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " xmlSymbolContent is empty, fileContentId=" << fileContentId;
|
||||
fcData.monitoring.replyState = FileContentStruct::ReplyFailure; // update ReplayState
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case FileContentStruct::SymbolType::UnsupportedSymbol:
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " unsupported symbol found, fileContentId=" << fileContentId;
|
||||
fcData.monitoring.replyState = FileContentStruct::ReplyFailure; // update ReplayState
|
||||
break;
|
||||
}
|
||||
|
||||
} // switch
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
bool FlmSubscriber::svgToImage(const QByteArray &svgByteArray, QImage &imageOut)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
|
||||
// load QByteArray
|
||||
QSvgRenderer svgRenderer;
|
||||
if (!svgRenderer.load(svgByteArray))
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " svgRenderer.load failed";
|
||||
return false;
|
||||
}
|
||||
|
||||
// prepare Image:
|
||||
int size = 200; // pixel
|
||||
imageOut = QImage(size, size, QImage::Format_ARGB32);
|
||||
imageOut.fill(Qt::transparent);
|
||||
|
||||
// render
|
||||
QPainter painter(&imageOut);
|
||||
svgRenderer.render(&painter);
|
||||
painter.end();
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
return true;
|
||||
}
|
||||
|
||||
QString FlmSubscriber::operatorName(int operatorId)
|
||||
{
|
||||
if (d->m_opmDtc)
|
||||
return QString::fromStdString(d->m_opmDtc->user(operatorId).name());
|
||||
return QStringLiteral("unknown user<%1>").arg(operatorId);
|
||||
}
|
||||
|
||||
|
||||
void FlmSubscriber::checkForReFetching()
|
||||
{
|
||||
// use own logging channel:
|
||||
LOGGER_T logger = NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("AdvSymbology.FlmSubscriber.ReFetch");
|
||||
|
||||
|
||||
DEBUG_LOG(logger) << "********** checkForReFetching START, size=" << d->m_fileContentMap.size();
|
||||
|
||||
int i{0};
|
||||
int unfinished{0};
|
||||
int reFetchCounter{0};
|
||||
static int s_reFetchCounter = 0;
|
||||
|
||||
const qint64 curTime = time(nullptr);
|
||||
|
||||
for (auto it = d->m_fileContentMap.cbegin(); it != d->m_fileContentMap.cend(); ++it)
|
||||
{
|
||||
const FileContentStruct &fcs = it.value();
|
||||
qint64 ageSec = curTime - fcs.monitoring.requestTime;
|
||||
|
||||
DEBUG_LOG(logger) << "***** dump i=" << ++i
|
||||
<< ", fileContentId=" << it.key()
|
||||
<< ", retryCnt=" << fcs.monitoring.retryCnt
|
||||
<< ", ageSec = " << ageSec
|
||||
<< ", replyState=" << toString(fcs.monitoring.replyState)
|
||||
<< ", replyContentSize=" << fcs.monitoring.replyContentSize
|
||||
<< ", name='" << fcs.name << "'"
|
||||
;
|
||||
|
||||
if (fcs.monitoring.replyState != FileContentStruct::ReplySuccess)
|
||||
{
|
||||
++unfinished;
|
||||
if ((ageSec > 30) && (fcs.monitoring.retryCnt < 3))
|
||||
{
|
||||
// retry / reFetch
|
||||
const int32_t fileContentId = it.key();
|
||||
INFO_LOG(logger) << "***** reFetch *** :"
|
||||
<< " ageSec = " << ageSec
|
||||
<< ", fileContentId=" << fileContentId
|
||||
<< ", replyState=" << toString(fcs.monitoring.replyState)
|
||||
<< ", replyContentSize=" << fcs.monitoring.replyContentSize
|
||||
<< ", name='" << fcs.name << "'"
|
||||
;
|
||||
FileManagement::GetFileContentDataRequest request(fileContentId);
|
||||
if (!d->m_flmFtc->getFileContentDataRequest(request, this)) // -> onGetFileContentDataReply -> ... -> setSymbol
|
||||
ERROR_LOG(logger) << LOGFUNCTION << "Error reading FileContentData, fileContentId=" << fileContentId;
|
||||
|
||||
fcs.monitoring.replyState = FileContentStruct::Requested;
|
||||
fcs.monitoring.requestTime = getRequestTime();
|
||||
++fcs.monitoring.retryCnt;
|
||||
// Server-Restart: Topic is removed and therefore the fcs is also removed from container -> retryCnt is fine
|
||||
|
||||
++reFetchCounter;
|
||||
++s_reFetchCounter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INFO_LOG(logger) << "***** checkForReFetching END"
|
||||
<< ", size=" << d->m_fileContentMap.size()
|
||||
<< ", unfinished=" << unfinished
|
||||
<< ", reFetchCounter=" << reFetchCounter
|
||||
<< ", s_reFetchCounter=" << s_reFetchCounter;
|
||||
}
|
||||
|
||||
void FlmSubscriber::onFileContentChanged(const FileManagement::FileContent &data, DataModification modType)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION
|
||||
<< " data.id=" << data.id()
|
||||
<< " data.fileStatus=" << data.fileStatus().underlying()
|
||||
<< " modType=" << modType
|
||||
<< " data.name='" << data.name().c_str() << "'";
|
||||
|
||||
if (!d->m_flmFtc)
|
||||
return;
|
||||
|
||||
if (data.isDeleted())
|
||||
return;
|
||||
|
||||
// check fileType
|
||||
if (data.fileType().underlying() != FileManagement::FileType::OperatorDefinedSymbol)
|
||||
return;
|
||||
|
||||
// check fileStatus in relation with modType:
|
||||
// (if modified to FileStatus::Deleted process as DataModification::eRemoved)
|
||||
if (data.fileStatus().underlying() == FileManagement::FileStatus::Deleted)
|
||||
{
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
return;
|
||||
case DataModification::eModified:
|
||||
modType = DataModification::eRemoved;
|
||||
break;
|
||||
case DataModification::eRemoved:
|
||||
// empty
|
||||
break;
|
||||
} // switch
|
||||
}
|
||||
|
||||
//
|
||||
// no check against ExerciseId, because we assume that all symbols are 'global'
|
||||
//
|
||||
|
||||
const int32_t fileContentId = data.id();
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
{
|
||||
// since it´s caused by an update/changed signal,
|
||||
// we have to update our own map, (to let onGetFileContentDataReply work)
|
||||
updateFileContentMap(data);
|
||||
|
||||
FileManagement::GetFileContentDataRequest request(fileContentId);
|
||||
if (!d->m_flmFtc->getFileContentDataRequest(request, this)) // -> onGetFileContentDataReply -> ... -> setSymbol
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << "Error reading FileContentData, fileContentId=" << fileContentId;
|
||||
break;
|
||||
}
|
||||
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION
|
||||
<< " modType=" << modType
|
||||
<< " fileContentId=" << fileContentId
|
||||
<< " fileContentName=" << data.name();
|
||||
|
||||
// update own container:
|
||||
d->m_fileContentMap.remove(fileContentId);
|
||||
|
||||
// remove:
|
||||
if (!d->m_symbolProxy.removeSymbol(fileContentId))
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " removeSymbol failed"
|
||||
<< " fileContentId=" << fileContentId
|
||||
<< " fileContentName='" << data.name() << "'"
|
||||
<< " contains=" << d->m_fileContentMap.contains(fileContentId);
|
||||
break;
|
||||
}
|
||||
} // switch
|
||||
} // void FlmSubscriber::onFileContentChanged(const FileManagement::FileContent &data, DataModification modType)
|
||||
|
||||
|
||||
void FlmSubscriber::updateFileContentMap(const FileManagement::FileContent &data)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START"
|
||||
<< " d->m_fileContentMap.size()=" << d->m_fileContentMap.size()
|
||||
<< " fileContentId=" << data.id()
|
||||
<< " data.isDeleted()=" <<data.isDeleted()
|
||||
<< " data.fileStatus().underlying()=" << data.fileStatus().underlying()
|
||||
<< " data.name='" <<QString::fromStdString(data.name()) << "'";
|
||||
|
||||
if (data.isDeleted())
|
||||
return;
|
||||
|
||||
if (data.fileStatus().underlying() == FileManagement::FileStatus::Deleted)
|
||||
return;
|
||||
|
||||
if (data.fileType() != FileManagement::FileType::OperatorDefinedSymbol)
|
||||
return;
|
||||
|
||||
// check exerciseId in future ???
|
||||
|
||||
const int32_t fileContentId = data.id();
|
||||
|
||||
FileContentStruct fcData;
|
||||
|
||||
fcData.name = QString::fromStdString(data.name());
|
||||
fcData.type = FileContentStruct::SymbolType::UnsupportedSymbol;
|
||||
fcData.operatorName = operatorName(data.operatorId());
|
||||
fcData.lastModified = data.lastModified();
|
||||
|
||||
fcData.usrTags << QStringLiteral("file-id=%1").arg(fileContentId);
|
||||
fcData.usrTags << QStringLiteral("exercise-id=%1").arg(data.exerciseId().is_set() ? data.exerciseId().get() : -1);
|
||||
fcData.usrTags << fcData.operatorName;
|
||||
|
||||
|
||||
// optional properties (containing 'imageFormat', 'partyColor')
|
||||
if (data.properties().size() != 0)
|
||||
{
|
||||
const QByteArray attributesJson(QByteArray::fromRawData(data.properties().c_str(), data.properties().size()));
|
||||
QJsonParseError parseError;
|
||||
QJsonDocument jDoc(QJsonDocument::fromJson(attributesJson, &parseError));
|
||||
|
||||
if (parseError.error == QJsonParseError::NoError)
|
||||
{
|
||||
const QJsonObject &obj = jDoc.object();
|
||||
const QLatin1String imageFormatKey("imageFormat");
|
||||
if (obj.contains(imageFormatKey))
|
||||
{
|
||||
const QString &imageFormatValue = obj[imageFormatKey].toString();
|
||||
if (QLatin1String("xml") == imageFormatValue)
|
||||
fcData.type = FileContentStruct::SymbolType::XmlSymbol;
|
||||
|
||||
if (QLatin1String("ets") == imageFormatValue)
|
||||
fcData.type = FileContentStruct::SymbolType::EtsSymbol;
|
||||
}
|
||||
else
|
||||
fcData.type = FileContentStruct::SymbolType::EtsSymbol;
|
||||
|
||||
if (FileContentStruct::SymbolType::EtsSymbol == fcData.type)
|
||||
{
|
||||
// partyColor
|
||||
const QLatin1String partyColorStr("partyColor");
|
||||
if (obj.contains(partyColorStr))
|
||||
{
|
||||
QJsonObject partyColor = obj[partyColorStr].toObject();
|
||||
if (partyColor.size() == 3) // r, g, b
|
||||
{
|
||||
// update map:
|
||||
fcData.colorTobeReplaced.setRgb(
|
||||
partyColor[QLatin1String("r")].toInt(),
|
||||
partyColor[QLatin1String("g")].toInt(),
|
||||
partyColor[QLatin1String("b")].toInt());
|
||||
} // if (partyColor.size() == 3)
|
||||
} // if (obj.contains(partyColorStr))
|
||||
} // if (FileContentStruct::SymbolType::EtsSymbol == fcRef.type)
|
||||
|
||||
} else {
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION
|
||||
<< " QJsonParseError->errorString: '" << parseError.errorString() << "'"
|
||||
<< ", offset: " << parseError.offset;
|
||||
} // if (parseError.error == QJsonParseError::NoError)
|
||||
} // if (data.attributes().is_set())
|
||||
|
||||
d->m_fileContentMap[fileContentId] = fcData;
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END"
|
||||
<< " d->m_fileContentMap.size()=" << d->m_fileContentMap.size()
|
||||
<< " fileContentId=" << data.id()
|
||||
<< " data.isDeleted()=" <<data.isDeleted()
|
||||
<< " data.fileStatus().underlying()=" << data.fileStatus().underlying()
|
||||
<< " data.name='" <<QString::fromStdString(data.name()) << "'";
|
||||
|
||||
} // void FlmSubscriber::updateFileContentMap(const FileManagement::FileContent &data)
|
||||
|
||||
|
||||
void FlmSubscriber::onLocalSymbolProxyEtsSymbolAdded(qint32 fileContentId,
|
||||
const QString &name,
|
||||
const QImage &image,
|
||||
const QColor &colorToBeReplaced,
|
||||
const QStringList &usrTags)
|
||||
{
|
||||
Q_UNUSED(fileContentId);
|
||||
for (const SymbologyType symbologyType : qAsConst(d->m_symbolDictionaryToUpdate))
|
||||
{
|
||||
AdvancedSymbology::SymbolDictionary &dict =
|
||||
AdvancedSymbology::SymbolDictionary::dictionary(symbologyType);
|
||||
this->setEtsSymbolToDict(dict, fileContentId, name, image, colorToBeReplaced, usrTags);
|
||||
}
|
||||
}
|
||||
|
||||
void FlmSubscriber::onLocalSymbolProxyEtsSymbolRemoved(qint32 fileContentId, const QString &name)
|
||||
{
|
||||
for (const SymbologyType &symbologyType : qAsConst(d->m_symbolDictionaryToUpdate))
|
||||
{
|
||||
AdvancedSymbology::SymbolDictionary &dict =
|
||||
AdvancedSymbology::SymbolDictionary::dictionary(symbologyType);
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " dict.removeEtsSymbol:"
|
||||
<< " symbologyType='" << (int)symbologyType << "'"
|
||||
<< ", name='" << name << "'"
|
||||
<< ", fileContentId=" << fileContentId;
|
||||
dict.removeEtsSymbol(fileContentId);
|
||||
dict.removeEtsSymbol(name);
|
||||
}
|
||||
}
|
||||
|
||||
void FlmSubscriber::onLocalSymbolProxyXmlSymbolAdded(qint32 fileContentId,
|
||||
const QString &operatorName,
|
||||
qint64 lastModified,
|
||||
const QString &name,
|
||||
const QString &xmlContent,
|
||||
const QStringList &usrTags)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START"
|
||||
<< " fileContentId=" << fileContentId
|
||||
<< " name='" << name << "'";
|
||||
|
||||
if (!xmlContent.isEmpty())
|
||||
{
|
||||
for (const SymbologyType &symbologyType : qAsConst(d->m_symbolDictionaryToUpdate))
|
||||
{
|
||||
AdvancedSymbology::SymbolDictionary &dict =
|
||||
AdvancedSymbology::SymbolDictionary::dictionary(symbologyType);
|
||||
if (!this->setXmlSymbolToDict(dict, fileContentId, operatorName, lastModified, name, xmlContent, usrTags))
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " dict.setXmlSymbolToDict failed"
|
||||
<< ", symbologyType='" << (int)symbologyType << "'"
|
||||
<< ", name='" << name << "'";
|
||||
}
|
||||
}
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END"
|
||||
<< " fileContentId=" << fileContentId
|
||||
<< " name='" << name << "'";
|
||||
}
|
||||
|
||||
void FlmSubscriber::onLocalSymbolProxyXmlSymbolRemoved(qint32 fileContentId)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START" << " fileContentId=" << fileContentId;
|
||||
|
||||
for (const SymbologyType &symbologyType : qAsConst(d->m_symbolDictionaryToUpdate))
|
||||
{
|
||||
AdvancedSymbology::SymbolDictionary &dict =
|
||||
AdvancedSymbology::SymbolDictionary::dictionary(symbologyType);
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " dict.removeXmlSymbol:"
|
||||
<< " symbologyType='" << symbologyType << "'"
|
||||
<< ", fileContentId=" << fileContentId;
|
||||
|
||||
const QString &skey = QString::number(fileContentId);
|
||||
const QString &sidc = SidcCodec::encodeCivilXml(skey);
|
||||
dict.removeXmlSymbol(sidc);
|
||||
dict.removeXmlSymbol(fileContentId);
|
||||
}
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END" << " fileContentId=" << fileContentId;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Proxy
|
||||
//
|
||||
|
||||
bool FlmSubscriber::connectFlmSymbolProxy(int type_placeholder, SymbologyType symbologyType)
|
||||
{
|
||||
Q_UNUSED(type_placeholder);
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " m_fileContentMap.size()=" << d->m_fileContentMap.size() ;
|
||||
|
||||
d->m_symbolDictionaryToUpdate.insert(symbologyType);
|
||||
|
||||
// ETS
|
||||
// connect to some signals like added, modified, removed:
|
||||
connect(&d->m_symbolProxy, &FlmSymbolProxy::etsSymbolAdded,
|
||||
this, &FlmSubscriber::onLocalSymbolProxyEtsSymbolAdded, Qt::QueuedConnection);
|
||||
connect(&d->m_symbolProxy, &FlmSymbolProxy::etsSymbolRemoved,
|
||||
this, &FlmSubscriber::onLocalSymbolProxyEtsSymbolRemoved, Qt::QueuedConnection);
|
||||
|
||||
// XML
|
||||
// connect to some signals like added, modified, removed:
|
||||
connect(&d->m_symbolProxy, &FlmSymbolProxy::xmlSymbolAdded,
|
||||
this, &FlmSubscriber::onLocalSymbolProxyXmlSymbolAdded, Qt::QueuedConnection);
|
||||
connect(&d->m_symbolProxy, &FlmSymbolProxy::xmlSymbolRemoved,
|
||||
this, &FlmSubscriber::onLocalSymbolProxyXmlSymbolRemoved, Qt::QueuedConnection);
|
||||
|
||||
|
||||
// continue?
|
||||
if (d->m_symbolProxy.isEmpty())
|
||||
return true;
|
||||
|
||||
AdvancedSymbology::SymbolDictionary &dict =
|
||||
AdvancedSymbology::SymbolDictionary::dictionary(symbologyType);
|
||||
|
||||
// Don´t use QSignalBlocker here!!!
|
||||
dict.blockSignals(true); // to make sure that set{Ets,Xml}SymbolToDict will NOT emit huge number of 'symbolAdded'
|
||||
for (auto mapIt = d->m_symbolProxy.getMap().begin(); mapIt != d->m_symbolProxy.getMap().end(); ++mapIt)
|
||||
{
|
||||
const int fileContentId = mapIt.key();
|
||||
const FlmSymbolProxy::SymbolData &symData = mapIt.value();
|
||||
if (symData.isXmlSymbol())
|
||||
setXmlSymbolToDict(dict, fileContentId, symData.operatorName(), symData.lastModified(), symData.name(), symData.xmlContent(), symData.usrTags());
|
||||
else
|
||||
setEtsSymbolToDict(dict, fileContentId, symData.name(), symData.image(), symData.colorToBeReplaced(), symData.usrTags());
|
||||
}
|
||||
dict.blockSignals(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool FlmSubscriber::setEtsSymbolToDict(SymbolDictionary &dict,
|
||||
qint32 fileContentId,
|
||||
const QString &name,
|
||||
const QImage &image,
|
||||
const QColor &colorToBeReplaced,
|
||||
const QStringList &usrTags)
|
||||
{
|
||||
// -> ETS_%1
|
||||
SymbolProperties symProps;
|
||||
symProps.setKey(name);
|
||||
symProps.setSidc(SidcCodec::encodeCivilEts(name));
|
||||
symProps.setName(name);
|
||||
// symProps.setCategory(); // maybe?
|
||||
symProps.setSymbolClass(QLatin1String("3")); // 18.10.2016, N.Thoden: 3 == PointSymbol (mil2525d.stylx - QuartzRelease)
|
||||
symProps.setGeometryType(GeometryType::Point); // ETS-Symbols are always Points
|
||||
symProps.setTags(QStringList() << name << usrTags);
|
||||
symProps.setColorToBeReplaced(colorToBeReplaced);
|
||||
|
||||
if (!dict.setEtsSymbol(fileContentId, symProps.sidc(), symProps, image))
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " dict.insertExtraSymbol failed"
|
||||
<< ", fileContentId=" << fileContentId << ", name='" << name << "'";
|
||||
return false;
|
||||
}
|
||||
else
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " dict.insertExtraSymbol done"
|
||||
<< ", fileContentId=" << fileContentId << ", name='" << name << "'";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FlmSubscriber::setXmlSymbolToDict(SymbolDictionary &dict,
|
||||
qint32 fileContentId,
|
||||
const QString &operatorName,
|
||||
qint64 lastModified,
|
||||
const QString &name,
|
||||
const QString &xmlContent,
|
||||
const QStringList &usrTags)
|
||||
{
|
||||
SymbolProperties symProps;
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* ToDo add more search infos to symProps
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
|
||||
symProps.setTags(QStringList() << name << usrTags);
|
||||
|
||||
|
||||
|
||||
bool success = dict.setXmlSymbol(fileContentId, name, operatorName, lastModified, xmlContent, symProps);
|
||||
|
||||
if (!success)
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " setXmlSymbol failed:"
|
||||
<< ", file-id=" << fileContentId
|
||||
<< ", filenameid='" << name << "'";
|
||||
return success;
|
||||
}
|
||||
|
||||
} // namespace AdvancedSymbology
|
||||
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Subscribe to file management service
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Norbert Thoden, NLE, 2019-04-15
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AdvancedSymbology/asb_symbol_proxy_gui_plugin_interface.h>
|
||||
|
||||
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
|
||||
#include <FileManagement/flm.hpp>
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace LtsUtils
|
||||
{
|
||||
class RequestHelper;
|
||||
}
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
class FlmSubscriber final
|
||||
: public QObject
|
||||
, public ForeignGuiFlmSymbolsProxyInterface
|
||||
, public FileManagement::Interface::Ftc::GetFileContentDataReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FlmSubscriber(const std::shared_ptr<FileManagement::Interface::Dtc> &flmDtc,
|
||||
const std::shared_ptr<FileManagement::Interface::Ftc> &flmFtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc);
|
||||
~FlmSubscriber();
|
||||
|
||||
|
||||
bool createFlmSymbolProxy(int type_placeholder) override; // type_placeholder: GlobalSymbols, ExerciseSymbols... to be prepared
|
||||
bool connectFlmSymbolProxy(int type_placeholder, SymbologyType symbologyType) override;
|
||||
|
||||
private: // methods
|
||||
bool setEtsSymbolToDict(SymbolDictionary &dict,
|
||||
qint32 fileContentId,
|
||||
const QString &name,
|
||||
const QImage &image,
|
||||
const QColor &colorToBeReplaced,
|
||||
const QStringList &usrTags);
|
||||
|
||||
bool setXmlSymbolToDict(SymbolDictionary &dict,
|
||||
qint32 fileContentId,
|
||||
const QString &operatorName,
|
||||
qint64 lastModified,
|
||||
const QString &name,
|
||||
const QString &xmlContent,
|
||||
const QStringList &usrTags);
|
||||
|
||||
protected slots:
|
||||
void onFileContentChanged(const FileManagement::FileContent &data, DataModification modType);
|
||||
void updateFileContentMap(const FileManagement::FileContent &data);
|
||||
|
||||
void onLocalSymbolProxyEtsSymbolAdded(qint32 fileContentId,
|
||||
const QString &name,
|
||||
const QImage &image,
|
||||
const QColor &colorToBeReplaced,
|
||||
const QStringList &usrTags);
|
||||
void onLocalSymbolProxyEtsSymbolRemoved(qint32 fileContentId, const QString &name);
|
||||
|
||||
void onLocalSymbolProxyXmlSymbolAdded(qint32 fileContentId,
|
||||
const QString &operatorName,
|
||||
qint64 lastModified,
|
||||
const QString &name,
|
||||
const QString &xmlContent,
|
||||
const QStringList &usrTags);
|
||||
void onLocalSymbolProxyXmlSymbolRemoved(qint32 fileContentId);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief onGetFileContentDataReply
|
||||
* @param reply contains the FileContentData to be processed (Symbol as SVG/ByteArray)
|
||||
*/
|
||||
void onGetFileContentDataReply(const FileManagement::GetFileContentDataReply &reply) override;
|
||||
|
||||
bool svgToImage(const QByteArray &svgByteArray, QImage &imageOut);
|
||||
|
||||
QString operatorName(int operatorId);
|
||||
|
||||
void checkForReFetching();
|
||||
|
||||
private: // attributes
|
||||
LOGGER_T m_logger; ///< Interface of the Logging-Facility
|
||||
|
||||
struct Private;
|
||||
/**
|
||||
* The private d->pointer to not break BC when changing internals of this class
|
||||
*/
|
||||
Private *d = nullptr;
|
||||
|
||||
};
|
||||
} // namespace AdvancedSymbology
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI proxy plugin to handle symbols via file management service
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2016-11-02
|
||||
*/
|
||||
|
||||
#include "asb_symbol_proxy_gui_plugin.h"
|
||||
#include "asb_flm_subscriber.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <Symbology/symbol_dictionary.h>
|
||||
#include <Symbology/sidc_codec.h>
|
||||
#include "flm_symbol_proxy.h"
|
||||
|
||||
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
std::shared_ptr<GuiPluginBase::Interface> FlmSymbolProxyGuiPlugin::createGuiInterface(LtsSession::LtsSession *session)
|
||||
{
|
||||
return std::make_shared<InterfaceImpl>(session);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
struct InterfaceImpl::Private
|
||||
{
|
||||
QSharedPointer<FlmSubscriber> getFlmSubscriber(int type_placeholder)
|
||||
{
|
||||
static QWeakPointer<FlmSubscriber> s_flmSubcriber;
|
||||
|
||||
m_flmSubscriber = s_flmSubcriber.toStrongRef();
|
||||
if (!m_flmSubscriber)
|
||||
{
|
||||
m_flmSubscriber = QSharedPointer<FlmSubscriber> (new FlmSubscriber(m_flmDtc, m_flmFtc, m_opmDtc));
|
||||
s_flmSubcriber = m_flmSubscriber.toWeakRef();
|
||||
m_flmSubscriber->createFlmSymbolProxy(type_placeholder);
|
||||
}
|
||||
|
||||
|
||||
return m_flmSubscriber;
|
||||
}
|
||||
|
||||
void clearFlmSubscriber()
|
||||
{
|
||||
m_flmSubscriber.clear();
|
||||
}
|
||||
|
||||
std::shared_ptr<FileManagement::Interface::Dtc> m_flmDtc;
|
||||
std::shared_ptr<FileManagement::Interface::Ftc> m_flmFtc;
|
||||
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
|
||||
|
||||
private:
|
||||
QSharedPointer<FlmSubscriber> m_flmSubscriber;
|
||||
};
|
||||
|
||||
|
||||
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
|
||||
: GuiPluginBase::Interface(session, NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("AdvSymbology.FlmSymbolProxy"))
|
||||
, d(new Private())
|
||||
{
|
||||
// To enable QueuedConnection:
|
||||
qRegisterMetaType<FileManagement::FileContent>("FileManagement::FileContent");
|
||||
qRegisterMetaType<DataModification>("DataModification");
|
||||
}
|
||||
|
||||
InterfaceImpl::~InterfaceImpl()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool InterfaceImpl::fetchInterfaces()
|
||||
{
|
||||
if (!m_session->getDtc<FileManagement::DataInterface>(d->m_flmDtc))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "getDtc for FileManagement::DataInterface failed.";
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getFtc<FileManagement::DataInterface>(d->m_flmFtc))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "getFtc for FileManagement::DataInterface failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_session->getDtc<OperatorManagement::DataInterface>(d->m_opmDtc))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "getDtc for OperatorManagement::DataInterface failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void InterfaceImpl::clearInterfaces()
|
||||
{
|
||||
d->m_flmDtc = nullptr;
|
||||
d->m_flmFtc = nullptr;
|
||||
d->m_opmDtc = nullptr;
|
||||
|
||||
// release dtc/ftc also at FlmSubscriber:
|
||||
d->clearFlmSubscriber();
|
||||
}
|
||||
|
||||
// type_placeholder: GlobalSymbols, ExerciseSymbols...
|
||||
bool InterfaceImpl::createFlmSymbolProxy(int type_placeholder)
|
||||
{
|
||||
Q_UNUSED(type_placeholder);
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
|
||||
if (!d->m_flmDtc || !d->m_flmFtc || !d->m_opmDtc)
|
||||
return false;
|
||||
|
||||
QSharedPointer<FlmSubscriber> flmSubscriber = d->getFlmSubscriber(type_placeholder);
|
||||
if (!flmSubscriber)
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " no FlmSubscriber";
|
||||
return false;
|
||||
}
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InterfaceImpl::connectFlmSymbolProxy(int type_placeholder, SymbologyType symbologyType)
|
||||
{
|
||||
Q_UNUSED(type_placeholder);
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
|
||||
QSharedPointer<FlmSubscriber> flmSubscriber = d->getFlmSubscriber(type_placeholder);
|
||||
if (!flmSubscriber)
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " no FlmSubscriber";
|
||||
return false;
|
||||
}
|
||||
flmSubscriber->connectFlmSymbolProxy(type_placeholder, symbologyType);
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace AdvancedSymbology
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI proxy plugin to handle symbols via file management service
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Hannes Baeuerle, SLSE, 2017-06-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AdvancedSymbology/asb_symbol_proxy_gui_plugin_interface.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace LtsUtils
|
||||
{
|
||||
class RequestHelper;
|
||||
}
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
class FlmSymbolProxyGuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "gui:3:asb.flmsymbolproxy")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
public:
|
||||
explicit FlmSymbolProxyGuiPlugin() = default;
|
||||
~FlmSymbolProxyGuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return ForeignGuiFlmSymbolsProxyInterface::pluginName(); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
Q_UNUSED(partition);
|
||||
return true;
|
||||
// return partition == IDL::PartitionType::Exercise ||
|
||||
// partition == IDL::PartitionType::Global ||
|
||||
// partition == IDL::PartitionType::Replay;
|
||||
}
|
||||
};
|
||||
|
||||
class InterfaceImpl final
|
||||
: public QObject
|
||||
, public ForeignGuiFlmSymbolsProxyInterface
|
||||
, public GuiPluginBase::Interface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
~InterfaceImpl();
|
||||
|
||||
bool fetchInterfaces() override;
|
||||
void clearInterfaces() override;
|
||||
|
||||
private: // methods
|
||||
bool createFlmSymbolProxy(int type_placeholder) override; // type_placeholder: GlobalSymbols, ExerciseSymbols... to be prepared
|
||||
bool connectFlmSymbolProxy(int type_placeholder, SymbologyType symbologyType) override;
|
||||
|
||||
protected slots:
|
||||
|
||||
private: // attributes
|
||||
|
||||
struct Private;
|
||||
/**
|
||||
* The private d->pointer to not break BC when changing internals of this class
|
||||
*/
|
||||
Private *d = nullptr;
|
||||
};
|
||||
} // namespace AdvancedSymbology
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Preprocess symbols of Filemanagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
// Own
|
||||
#include "flm_symbol_proxy.h"
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
FlmSymbolProxy::FlmSymbolProxy(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool FlmSymbolProxy::setSymbol(int32_t fileContentId, const SymbolData &symbolData)
|
||||
{
|
||||
m_imageMap[fileContentId] = symbolData;
|
||||
if (symbolData.isXmlSymbol())
|
||||
emit xmlSymbolAdded(fileContentId, symbolData.operatorName(), symbolData.lastModified(), symbolData.name(), symbolData.xmlContent(), symbolData.usrTags());
|
||||
else
|
||||
emit etsSymbolAdded(fileContentId, symbolData.name(), symbolData.image(), symbolData.colorToBeReplaced(), symbolData.usrTags());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FlmSymbolProxy::removeSymbol(qint32 fileContentId)
|
||||
{
|
||||
SymbolData symbolDat = m_imageMap[fileContentId];
|
||||
|
||||
bool ret = m_imageMap.remove(fileContentId) > 0;
|
||||
if (ret)
|
||||
{
|
||||
if (symbolDat.isXmlSymbol())
|
||||
emit xmlSymbolRemoved(fileContentId);
|
||||
else
|
||||
emit etsSymbolRemoved(fileContentId, symbolDat.name());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace AdvancedSymbology
|
||||
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Preprocess symbols of Filemanagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
// Own
|
||||
|
||||
|
||||
// Qt
|
||||
#include <QHash>
|
||||
#include <QString>
|
||||
#include <QImage>
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
|
||||
|
||||
class FlmSymbolProxy : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
class SymbolData
|
||||
{
|
||||
public:
|
||||
|
||||
SymbolData() = default;
|
||||
|
||||
SymbolData(const QString &name, const QImage &image, const QColor &colorToBeReplaced = QColor())
|
||||
: m_name(name), m_image(image), m_colorToBeReplaced(colorToBeReplaced), m_xmlContent()
|
||||
{}
|
||||
|
||||
SymbolData(const QString &name, const QString &operatorName, qint64 lastModified, const QByteArray &xmlContent)
|
||||
: m_name(name), m_operatorName(operatorName), m_lastModified(lastModified), m_image(), m_colorToBeReplaced(), m_xmlContent(QString::fromUtf8(xmlContent))
|
||||
{}
|
||||
|
||||
QString name() const { return m_name; }
|
||||
void setName(const QString &name) { m_name = name; }
|
||||
|
||||
QString operatorName() const { return m_operatorName; }
|
||||
void setOperatorName(const QString &operatorName) { m_operatorName = operatorName; }
|
||||
|
||||
qint64 lastModified() const { return m_lastModified; }
|
||||
void setLastModified(qint64 lastModified) { m_lastModified = lastModified; }
|
||||
|
||||
|
||||
QImage image() const { return m_image; }
|
||||
void setImage(const QImage &image) { m_image = image; if (!image.isNull()) m_xmlContent.clear(); }
|
||||
|
||||
QColor colorToBeReplaced() const { return m_colorToBeReplaced; }
|
||||
void setColorToBeReplaced(const QColor &colorToBeReplaced) { m_colorToBeReplaced = colorToBeReplaced; }
|
||||
|
||||
QString xmlContent() const { return m_xmlContent; }
|
||||
void setXmlContent(const QString &xmlContent) { m_xmlContent = xmlContent; }
|
||||
|
||||
bool isXmlSymbol() const { return (!m_xmlContent.isEmpty()); }
|
||||
|
||||
QStringList usrTags() const { return m_usrTags; }
|
||||
|
||||
void setUsrTags(const QStringList &usrTags) { m_usrTags = usrTags; }
|
||||
void addUsrTag(const QString &tag) { m_usrTags << tag; }
|
||||
void addUsrTag(const char *tag) { m_usrTags << QLatin1String(tag); }
|
||||
|
||||
void clearUsrTags() { m_usrTags.clear(); }
|
||||
|
||||
protected:
|
||||
|
||||
QString m_name; // file name of symbol from file mamangement service
|
||||
QString m_operatorName;
|
||||
qint64 m_lastModified = 0;
|
||||
QImage m_image; // m_image is defined in case of ETS symbols
|
||||
QColor m_colorToBeReplaced; // by concrete partyColor (context of ETS symbols)
|
||||
QString m_xmlContent; // in case of XML symbols image is empty and the m_xmlContent holds the xml description of the symbol
|
||||
QStringList m_usrTags; // List of tags to look for while searching symbols in dictionary
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*! \name Construction, Destruction */
|
||||
//@{
|
||||
explicit FlmSymbolProxy(QObject *parent = nullptr);
|
||||
|
||||
FlmSymbolProxy(const FlmSymbolProxy &other) = delete;
|
||||
FlmSymbolProxy &operator=(const FlmSymbolProxy &other) = delete;
|
||||
//@}
|
||||
|
||||
bool isEmpty() const { return m_imageMap.isEmpty(); }
|
||||
bool containsSymbol(qint32 fileContentId) const { return m_imageMap.contains(fileContentId); }
|
||||
const QHash<qint32, SymbolData> &getMap() const { return m_imageMap; }
|
||||
|
||||
bool setSymbol(int32_t fileContentId, const SymbolData &symbolData);
|
||||
bool removeSymbol(qint32 fileContentId);
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
void etsSymbolAdded(qint32 fileContentId, const QString &name, const QImage &image, const QColor &colorToBeReplaced, const QStringList &usrTags);
|
||||
void etsSymbolRemoved(qint32 fileContentId, const QString &name);
|
||||
|
||||
void xmlSymbolAdded(qint32 fileContentId, const QString & operatorName, qint64 lastModified, const QString &name, const QString &xmlContent, const QStringList &usrTags);
|
||||
void xmlSymbolRemoved(qint32 fileContentId);
|
||||
|
||||
private:
|
||||
QHash<qint32, SymbolData> m_imageMap; // fileContentId -> image
|
||||
};
|
||||
|
||||
} // namespace AdvancedSymbology
|
||||
|
||||
|
||||
Reference in new issue
Block a user