Files
qt5-legatus-legacy/Lts/Viewer/SituationMap/Map/geometry_model_renderer.h
T
2026-08-13 18:33:10 +02:00

198 lines
5.1 KiB
C++
Executable File

/**
* @RDE_HEADER@
* GeometryModel - Renderer
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
// Own
#include <GeometryModel/geometry_model.h>
#include "situation_map_export.h"
#include <Map/situation_map_types.h>
#include <Map/map.h>
#include <Common/situation_map_logging.h>
// Qt
#include <QElapsedTimer>
#include <QObject>
#include <QPointer>
class PESettings;
class QDomElement;
class QTime;
namespace SituationMap
{
class AbstractMapObject;
using LOGGER_T = SituationMap::LOGGER_T;
/**
* @brief The GeometryModelRenderer class is an interface for the redndering of a geometry model.
*/
class SITUATIONMAP_EXPORT GeometryModelRenderer : public QObject
{
Q_OBJECT
public:
/*! \name Construction, Destruction */
//@{
explicit GeometryModelRenderer(Map *map, const QString &layerName, GeometryModel &geoModel, QObject *parent = nullptr);
virtual ~GeometryModelRenderer() = default;
//@}
/**
Returns unique id of map object associated with node.
@param node node of geometry model
*/
virtual UniqueMapId getIdFromNode(const GeometryModel::Node &node) const = 0;
/*! \name Rendering */
//@{
/**
* Render to map and update layer if model changes.
* \sa setNodesPickable()
*/
virtual bool render() = 0;
/**
* @brief Render single node
* @param node to render
* @return True on success, otherwise false.
* \sa setNodesPickable()
*/
virtual bool renderNode(const GeometryModel::Node &node) = 0;
/**
* @brief Render one drawable
* @param drawable to render
* @return True on success, otherwise false.
* \sa setNodesPickable()
*/
virtual bool render(QPixmap &drawable) = 0;
virtual GeometryModel::Node getAssociatedNode(const AbstractMapObject *mapObject) = 0;
/**
* @brief Get flag 'nodesPickable'
* @return flag 'nodesPickable'
*/
virtual bool getNodesPickable() const = 0;
/**
* @brief Set flag 'nodesPickable'. Should be set BEFORE render is called (and objects creation).
* @param New state
*/
virtual void setNodesPickable(bool nodesPickable) = 0;
/**
* @brief Get flag 'editorMode'
* @return value of flag 'editorMode'
*/
virtual bool editorMode() const = 0;
/**
* @brief Set flag 'editorMode' to switch on additional graphic elements
* @return value of flag 'editorMode'
*
* If the editor mode ist switched on, some additional graphic is drawn e.g. anchor points of text lines. Per default the editor mode is switched off.
*/
virtual void setEditorMode(bool on) = 0;
//@}
protected:
//! Create unique SIM-ID for GDW
//! \param useID: Use this for creating a previously created simID again
// static GDW::SimObjectId createSimID(int useID = -1);
//! Print the timing-stats to the info-channel
void printStats();
protected:
//! Collect Timing- and Draw-Statistic in this Struct
struct States
{
QElapsedTimer m_timer;
// Count method-calls
int m_drawCount = 0;
int m_drawElementsRecursiveCount = 0;
int m_drawParticipantSymbolCount = 0;
int m_drawDictionarySymbolCount = 0;
int m_drawEllipseCount = 0;
int m_drawLineCount = 0;
int m_drawPolylineCount = 0;
int m_drawRectangleCount = 0;
int m_drawSplineCount = 0;
int m_drawSymbolCount = 0;
int m_drawTextCount = 0;
int m_drawNodeCount = 0;
// Total time of method use in milliseconds
int m_msDictionarySymbol = 0;
int m_msEllipse = 0;
int m_msLine = 0;
int m_msPolyline = 0;
int m_msRectangle = 0;
int m_msSpline = 0;
int m_msSymbol = 0;
int m_msText = 0;
int m_msNode = 0;
// max time of method use in milliseconds
int m_msDictionarySymbolMax = 0;
int m_msEllipseMax = 0;
int m_msLineMax = 0;
int m_msPolylineMax = 0;
int m_msRectangleMax = 0;
int m_msSplineMax = 0;
int m_msSymbolMax = 0;
int m_msTextMax = 0;
int m_msNodeMax = 0;
// min time of method use in milliseconds
int m_msDictionarySymbolMin = 0;
int m_msEllipseMin = 0;
int m_msLineMin = 0;
int m_msPolylineMin = 0;
int m_msRectangleMin = 0;
int m_msSplineMin = 0;
int m_msSymbolMin = 0;
int m_msTextMin = 0;
int m_msNodeMin = 0;
}; // States
States m_stats;
void resetStats();
bool m_nodesPickable; //! PlanEditor -> true, Displaying -> false
bool m_enableRedraw; //! Bool to temporarily disable redraws (on multiple changes to GeometryModel)
QPointer<Map> m_map;
QString m_layerName;
GeometryModel &m_geometryModel; //!< The current Plan
protected:
//! Interface to the Logging-Facility
LOGGER_T m_logger;
LOGGER_T m_loggerStats;
}; // GeometryModelRenderer
}