150 lines
3.9 KiB
C++
Executable File
150 lines
3.9 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* Interface-Implementation of Text
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
// Own
|
|
#include "text_impl.h"
|
|
#include <MapImpl/map_impl.h>
|
|
#include <GraphicalObjects/graphical_object_path.h>
|
|
#include <GraphicalObjects/stub_graphical_object.h>
|
|
#include <GraphicalObjects/graphical_object_picture_marker.h>
|
|
#include <GraphicalObjects/graphical_object_text.h>
|
|
|
|
// ESRI
|
|
|
|
|
|
// Qt
|
|
#include <QString>
|
|
|
|
|
|
#include "position_marker.xpm"
|
|
|
|
|
|
namespace SituationMap
|
|
{
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// constants
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Utils:
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// class TextImpl
|
|
//-----------------------------------------------------------------------------
|
|
TextImpl::TextImpl(const QString &debugInfo)
|
|
: Text() // Interface
|
|
, BaseClass(debugInfo) // Implementation
|
|
, m_showAnchorMarker(false)
|
|
, m_anchorMarker(nullptr)
|
|
, m_logger(getLogger("TextImpl"))
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
m_visibilityScaleRange.resetToMax();
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
TextImpl::~TextImpl()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
delete m_anchorMarker;
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
|
|
void TextImpl::setShowAnchorMarker(bool on)
|
|
{
|
|
if (on == m_showAnchorMarker)
|
|
return;
|
|
|
|
m_showAnchorMarker = on;
|
|
if (on)
|
|
{
|
|
static QImage markerSymbol;
|
|
|
|
if (markerSymbol.isNull())
|
|
markerSymbol = QImage(position_marker_xpm);
|
|
|
|
m_anchorMarker = new GraphicalObjectPictureMarker(m_mapImpl->getEsriGeoView(),
|
|
m_graphicsLayer,
|
|
QLatin1String("AnchorMarker"),
|
|
INVALID_MAP_ID);
|
|
m_anchorMarker->setImage(markerSymbol);
|
|
}
|
|
else
|
|
{
|
|
delete m_anchorMarker;
|
|
m_anchorMarker = nullptr;
|
|
}
|
|
} // TextImpl::setShowAnchorMarker
|
|
|
|
|
|
bool TextImpl::showAnchorMarker() const { return m_showAnchorMarker; }
|
|
|
|
|
|
bool TextImpl::updateViewImpl()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START"
|
|
<< " visibility=" << m_visibility;
|
|
|
|
// put translated origin to stub. Later GOText will takeover the (translated) origin.
|
|
if (m_mainGraphicalObject) m_mainGraphicalObject->setOrigin(originTranslated());
|
|
|
|
bool success = BaseClass::updateViewImpl();
|
|
|
|
if (m_anchorMarker)
|
|
{
|
|
m_anchorMarker -> setSelected(m_selected);
|
|
m_anchorMarker -> setDrawOrder(m_internalDrawOrder);
|
|
m_anchorMarker -> setOrigin(m_mainGraphicalObjectText->origin());
|
|
m_anchorMarker -> setVisibility(m_mainGraphicalObjectText->visibility());
|
|
m_anchorMarker -> updateView();
|
|
}
|
|
|
|
|
|
if (!success)
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " updateViewImpl failed";
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END, success=" << success;
|
|
return success;
|
|
}
|
|
|
|
|
|
|
|
bool TextImpl::init(MapImpl *mapImpl, const QString &logicalLayerName)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
bool success = BaseClass::init(mapImpl, logicalLayerName);
|
|
|
|
if (success)
|
|
{
|
|
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
* Use the StubGraphicalObject, which is doing nothing of the work, because
|
|
* the text will be rendered using m_mainGraphicalObjectText
|
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
|
|
m_mainGraphicalObject = new StubGraphicalObject();
|
|
}
|
|
else
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " init failed";
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END, success=" << success;
|
|
return success;
|
|
}
|
|
|
|
|
|
} // namespace SituationMap
|