89 lines
2.4 KiB
C++
Executable File
89 lines
2.4 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* SituationMap - Handler Terrain profile dialogs and requests
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Christian Ehrlicher, SLSE, 2018-05-15
|
|
*/
|
|
|
|
#include "terrain_profile_handler.h"
|
|
#include <LtsSession/lts_session.h>
|
|
|
|
#include <Map/map.h>
|
|
#include <Map/terrain_profile.h>
|
|
#include <Utils/terrain_profile_dialog.h>
|
|
|
|
namespace SituationMap
|
|
{
|
|
TerrainProfileHandler::TerrainProfileHandler(const QString &menuGroup)
|
|
: m_menuGroup(menuGroup)
|
|
, m_logger(getLogger("TerrainProfileHandler"))
|
|
{}
|
|
|
|
TerrainProfileHandler::~TerrainProfileHandler()
|
|
{
|
|
delete m_terrainProfileDialog;
|
|
}
|
|
|
|
bool TerrainProfileHandler::init(const QPointer<LtsSession::LtsSession> &session,
|
|
const QPointer<SituationMap::Map> &situationMap)
|
|
{
|
|
m_session = session;
|
|
m_situationMap = situationMap;
|
|
|
|
return true;
|
|
}
|
|
|
|
void TerrainProfileHandler::startTerrainProfile()
|
|
{
|
|
if (!m_situationMap)
|
|
return;
|
|
|
|
SituationMap::TerrainProfile &tp = m_situationMap->terrainProfile();
|
|
|
|
using namespace std::placeholders;
|
|
|
|
tp.setFinishedCallback(std::bind( std::mem_fn(&TerrainProfileHandler::showTerrainProfileResults), this, _1, _2));
|
|
|
|
m_situationMap->terrainProfile().create(); // no para -> start rubberband
|
|
}
|
|
|
|
void TerrainProfileHandler::clearTerrainProfile()
|
|
{
|
|
if (!m_situationMap)
|
|
return;
|
|
|
|
m_situationMap->terrainProfile().remove();
|
|
}
|
|
|
|
bool TerrainProfileHandler::showTerrainProfileResults(long id, const QVector<QPair<QPointF, double> > &results)
|
|
{
|
|
if (!m_situationMap || !m_session)
|
|
return false;
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " START" << " id=" << id << " results.size()=" << results.size();
|
|
|
|
const LtsWidgets::LayoutArea layoutArea = LtsWidgets::LayoutArea::eDialogTab;
|
|
const QString &identifier = QStringLiteral("TerrainProfile");
|
|
|
|
if (!m_terrainProfileDialog)
|
|
{
|
|
m_terrainProfileDialog = new SituationMap::TerrainProfileDialog;
|
|
m_session->addWidget(m_terrainProfileDialog.data(),
|
|
m_menuGroup,
|
|
identifier,
|
|
layoutArea);
|
|
} else {
|
|
m_terrainProfileDialog->focusDialog(m_menuGroup, identifier, layoutArea);
|
|
}
|
|
m_terrainProfileDialog->show();
|
|
|
|
// set dialog to according processor, so he can update data, marks etc on his own:
|
|
m_situationMap->terrainProfile().setTerrainProfileDialog(id, m_terrainProfileDialog);
|
|
|
|
return true;
|
|
}
|
|
|
|
} // namespace SituationMap
|