206 lines
5.7 KiB
C++
Executable File
206 lines
5.7 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* Interface-Implementation of HitLine
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
// Own
|
|
#include "line_of_sight_impl.h"
|
|
#include <MapImpl/map_impl.h>
|
|
#include <GraphicalObjects/graphical_object_path.h>
|
|
#include <GraphicalObjects/graphical_object_text.h>
|
|
|
|
#include <Symbology/sidc_codec.h>
|
|
|
|
// ESRI
|
|
|
|
|
|
// Qt
|
|
|
|
|
|
#include <cassert>
|
|
|
|
|
|
namespace SituationMap
|
|
{
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class LineOfSightImpl
|
|
//-----------------------------------------------------------------------------
|
|
LineOfSightImpl::LineOfSightImpl(const QString &debugInfo)
|
|
: LineOfSight() // Interface
|
|
, BaseClass(debugInfo) // Implementation
|
|
, m_logger(getLogger("LineOfSightImpl"))
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
m_extensionLineCoordinate.setMapObjectImpl(this);
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
LineOfSightImpl::~LineOfSightImpl()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
delete m_extensionLine;
|
|
m_extensionLine = nullptr;
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
QString LineOfSightImpl::identifier() const
|
|
{
|
|
return this->textOnSegment(0);
|
|
}
|
|
void LineOfSightImpl::setIdentifier(const QString &identifier)
|
|
{
|
|
this->setTextOnSegment(0, identifier);
|
|
}
|
|
|
|
void LineOfSightImpl::setPoints(const Point3D &observer,
|
|
const Point3D &obstacle,
|
|
const Point3D &target,
|
|
const QColor &visibleColor, // green,
|
|
const QColor &obstructedColor) // red
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START"
|
|
<< " observer=" << observer
|
|
<< " obstacle=" << obstacle
|
|
<< " target=" << target
|
|
<< " visibleColor=" << visibleColor
|
|
<< " obstructedColor=" << obstructedColor;
|
|
|
|
// some checks
|
|
if (observer.isNull() || target.isNull())
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " start of end is null";
|
|
return;
|
|
}
|
|
|
|
if (obstacle.isNull())
|
|
{
|
|
// no obstacle -> just a single (green) line:
|
|
m_positions.setPositions(PositionCont() << observer << target);
|
|
m_extensionLineCoordinate.clear();
|
|
}
|
|
else
|
|
{
|
|
// obstacle -> first (green) line:
|
|
m_positions.setPositions(PositionCont() << observer << obstacle);
|
|
m_extensionLineCoordinate.setOrigin(target);
|
|
}
|
|
|
|
// handle color:
|
|
if (visibleColor.isValid())
|
|
{
|
|
LineStyle ls = this->lineStyle();
|
|
ls.setLineColor(visibleColor);
|
|
this->setLineStyle(ls);
|
|
}
|
|
|
|
if (obstructedColor.isValid())
|
|
m_extensionLineColor = obstructedColor;
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
|
|
bool LineOfSightImpl::updateViewImpl()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START"
|
|
<< " symbol=" << m_symbol.value().sidc
|
|
<< " visibility=" << m_visibility
|
|
<< " visiTechn=" << m_visibilityTechnical
|
|
<< " visiTact=" << m_visibilityTactical
|
|
<< " m_positions=" << m_positions.positions()
|
|
<< " m_additionalCoordinate=" << m_extensionLineCoordinate.origin();
|
|
|
|
//
|
|
//
|
|
// maybe the line(s) are densified @ GraphicalObjectPath::updateViewImpl()
|
|
// to use more vertices (for 3D) !?
|
|
//
|
|
//
|
|
|
|
|
|
bool success = BaseClass::updateViewImpl();
|
|
|
|
updateExtensionLine();
|
|
|
|
if (!success)
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " updateViewImpl failed";
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END, success=" << success;
|
|
return success;
|
|
}
|
|
|
|
void LineOfSightImpl::updateExtensionLine()
|
|
{
|
|
if (!m_extensionLineCoordinate.isEmpty())
|
|
{
|
|
if (!m_extensionLine)
|
|
{
|
|
QString debugInfo = QStringLiteral("%1#ExtensionLine").arg(m_debugInfo);
|
|
m_extensionLine = new GraphicalObjectPath(GraphicalObjectPathType::Polyline,
|
|
m_mapImpl->getEsriGeoView(),
|
|
m_graphicsLayer,
|
|
debugInfo,
|
|
m_uniqueMapId);
|
|
}
|
|
|
|
m_extensionLine->setVisibility(m_visibility && m_visibilityTechnical);
|
|
m_extensionLine->setScale(m_mainGraphicalObject->scale());
|
|
m_extensionLine->setDrawOrder(m_mainGraphicalObject->drawOrder());
|
|
|
|
LineStyle ls = m_mainGraphicalObject->lineStyle();
|
|
ls.setLineColor(m_extensionLineColor);
|
|
m_extensionLine->setLineStyle(ls);
|
|
|
|
// positions:
|
|
PositionsTranslated tempPosTrans;
|
|
tempPosTrans.setPositionsTranslated(PositionCont() <<
|
|
m_extensionLineCoordinate.originTranslated() // obstaclePosition
|
|
<< m_positions.positionsTranslated()[1]); // end/targetPosition
|
|
|
|
m_extensionLine->setPositions(tempPosTrans.positionsTranslated());
|
|
|
|
m_extensionLine->updateView();
|
|
|
|
}
|
|
else
|
|
{
|
|
// no m_extensionLineCoordinate -> remove extensionLine
|
|
delete m_extensionLine;
|
|
m_extensionLine = nullptr;
|
|
}
|
|
}
|
|
|
|
bool LineOfSightImpl::init(MapImpl *mapImpl, const QString &logicalLayerName)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
bool success = BaseClass::init(mapImpl, logicalLayerName, GraphicalObjectPathType::Polyline);
|
|
|
|
if (!success)
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " init failed";
|
|
|
|
// default: green, 3px
|
|
LineStyle ls = this->lineStyle();
|
|
ls.setLineColor(Qt::green);
|
|
ls.setLineWidth(3);
|
|
this->setLineStyle(ls);
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END, success=" << success;
|
|
return success;
|
|
}
|
|
|
|
|
|
bool LineOfSightImpl::setPositions(const PositionCont &)
|
|
{
|
|
FATAL_LOG(m_logger) << LOGFUNCTION << " DO NOT CALL!!!";
|
|
assert(false);
|
|
return false;
|
|
}
|
|
|
|
|
|
} // namespace SituationMap
|