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

425 lines
11 KiB
C++
Executable File

/**
* @RDE_HEADER@
* Interface of AbstractMapObject
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
// Own
#include "situation_map_types.h"
#include "situation_map_utils.h"
#include "text_style.h"
#include <Common/referenced.h>
#include <situation_map_export.h>
#include <MathUtils/geometry_engine.h>
// Qt
#include <QString>
#include <QColor>
#include <QList>
//----------------------------------------------------------------------------
namespace SituationMap
{
// forward:
class BoundingBox;
/**
* @brief The AbstractMapObject class is the baseclass of all MapObjects.
* (The class 'Referenced' is for the RefPointer only)
*
* This class supports main parameters like uniqueMapId, debugInfo and identifier
* to differentiate the objects.
*
* Second, the SymbolData can be set to use the TacticalAppearance of objects.
*
* Last but not least, visibility and drawOrder can be modified.
*
* An object has typically two Appearances:
* The Technical and the Tactical Appearance.
* Both can be switched on of off separatly,
* see setVisibility(ObjectAppearance appearance, bool visibility).
* @internal
* The AbstractMapObjectImpl has to be initialized (set the Map, Layer and so on).
* This call is done by the ObjectFactory.
*/
class SITUATIONMAP_EXPORT AbstractMapObject : virtual public Referenced
{
public:
/*! \name Construction, Destruction */
//@{
/// Constructor
AbstractMapObject() = default;
/// Destructor
virtual ~AbstractMapObject() = default;
virtual void removeMySelf() = 0;
//@}
/*! \name Emulate QObject::property */
//@{
/**
* @brief Set named property to value.
* @param name name.
* @param value value.
* @return True on success, otherwise false.
*/
virtual bool setProperty(const char *name, const QVariant &value) = 0;
/**
* @brief Get named property to value.
* @param name to retrieve
* @return Requested value.
*/
virtual QVariant property(const char *name) const = 0;
//@}
/*! \name Identification */
//@{
/**
* @brief Get uniqueMapId.
* @return uniqueMapId.
*/
virtual UniqueMapId uniqueMapId() const = 0;
/**
* @brief Get debugInfo.
* @return debugInfo.
*/
virtual QString debugInfo() const = 0;
/**
* @brief Set DebugInfo.
* @param debugInfo new value.
*/
virtual void setDebugInfo(const QString &debugInfo) = 0;
/**
* @brief toString delivers a string with some parameters.
* @return String with some parameters.
*/
virtual QString toString() const = 0;
/**
* @brief Get identifier.
* @return identifier.
*/
virtual QString identifier() const = 0;
/**
* @brief Set identifier of object to be displayed on the Map.
* @param identifier new value.
*/
virtual void setIdentifier(const QString &identifier) = 0;
virtual bool identifierVisible() const = 0;
virtual void setIdentifierVisible(bool identifierVisible) = 0;
//@}
/*! \name Direct and indirect assignment
* These values (partyId) has a high priority. Therefore it will overwrite
* some other values.
* \n An example is the line and fill color of an AreaFire.
* \n You can specify AreaFire::rLineStyle.setLineColor(Qt::blue) (== direct).
* \n But if a valid partyId is provided, this will overwrite the line and fill
* \n Exeption:
* \n If forcePartyColor is used, this has more priority than the partyId.
* parameter, color (== indirect).
*/
//@{
/**
* @brief Get partyId.
* @return partyId.
*/
virtual int partyId() const = 0;
/**
* @brief Check partyId
* @return True if partyId is valid, otherwise false.
*/
virtual bool isPartyIdValid() const = 0;
/**
* @brief Set PartyId
* @param partyId new value.
*/
virtual void setPartyId(int partyId) = 0;
/**
* @brief If the color of a party changes the partyId has to re-evaluated to the new color.
* @param partyColorToForce the color to be forced.
* This method set the internal flag, that the next updateView will take the new color.
*/
/**
* @brief If the color of a party changes the partyId has to re-evaluated to the new color.
* If relevant this method will set the internal flag, that the next updateView will take the new color.
* @param partyId causing the change, If less then 0, setting the internal flag is forced.
* @return true if relevant for this object, otherwise false
*/
virtual bool setPartyIdChanged(int partyId = -1) = 0;
/**
* @brief forcePartyColor to fulfill the flashing (e.g. of a participant)
* This forcedColor has more priority that than the partyId.
* @param partyColorToForce the color to be forced.
*/
virtual void forcePartyColor(const QColor &partyColorToBeForced) = 0;
//@}
/**
* @brief useLightColor Use the light party color instead the normal one
*/
virtual bool useLightColor() const = 0; ///< Only for Participants
virtual void setUseLightColor(bool useLightColor) = 0; ///< Only for Participants
//@}
//@{
/**
* @brief Get copy of textStyle.
* @return textStyle.
*/
virtual TextStyle textStyle() const = 0;
/**
* @brief Get reference to TextStyle (to modify easily).
* @return Reference to TextStyle.
* @note: Use this with caution. This will set the internal changed flag.
* Maybe you should prefer setTextStyle.
*/
virtual TextStyle &rTextStyle() = 0;
/**
* @brief Set TextStyle to be used for identifier.
* @param textStyle new value.
*/
virtual void setTextStyle(const TextStyle &textStyle) = 0;
//@}
/*! \name User scale */
//@{
/**
* @brief Get scale.
* @return scale
*/
virtual float scale() const = 0;
/**
* @brief Set scale of object.
* @param newScale new value.
*/
virtual void setScale(float newScale) = 0;
virtual bool isScaleEnabled() const = 0;
virtual void setScaleEnable(bool enabled) = 0;
//@}
/*! \name Layer and draworder */
//@{
/**
* @brief Get logical layername.
* @return logical layername.
*/
virtual QString layer() const = 0;
/**
* @brief Get drawOrder.
* @return drawOrder.
*/
virtual int drawOrder() const = 0;
/**
* @brief Set drawOrder.
* Caused by internal dependencies, the value MUST be within -3000...+3000. (INT_MAX=+32767 / 10 = 3276 -> ~3000).
* \n Otherwise the internal graphics will be disordered.
* \internal Background: Due to missing relative drawOrder an absolute drawOrder has to be used.\n
* To create an absolute drawOrder the specified drawOrder is multiplied with 10.
* The components (usually GraphicalObjects) receive that multiplied valued added by s small offset.
* drawOrder() is not influenced by this and will return the value you set before.
* @param drawOrder new value.
*/
virtual void setDrawOrder(int drawOrder) = 0;
//@}
/** \name Visibility
* If the object has to be invisible setVisibility() should be used.
*
* If only a single part has to be modified, remember the Technical and the Tactical ObjectAppearance.
* Both can be switch on or off separately.
*
* Attention: If the two ObjectAppearances are invisible setVisibility(true) will make them <B>NOT</B> visibile.
**/
//@{
// Visibility :
// Prio 1:
/**
* @brief Get visibility of the whole object (Prio 1).
* @return visibility of the whole object.
*/
virtual bool visibility() const = 0;
/**
* @brief Set visibility of the whole object (Prio 1).
* @param visibility new value.
*/
virtual void setVisibility(bool visibility) = 0;
// Prio 2
/**
* @brief Get visibility of a specific ObjectAppearance (Prio 2).
* @param appearance to be retrieved.
* @return Current value.
*/
virtual bool visibility(ObjectAppearance appearance) const = 0;
/**
* @brief Set Visibility of a specific ObjectAppearance (Prio 2).
* @param appearance to be modified.
* @param visibility new value.
*/
virtual void setVisibility(ObjectAppearance appearance, bool visibility) = 0;
/**
Calculates the intersection of map object another geometry
@param intersector_polyline Geometry to intersect with
@note: The geometry must be closed like a polyline. (not really sure)
*/
virtual bool geometryIntersect(const MathUtils::GeometryEngine::Geometry &intersector_polyline) const = 0;
/**
Calculates if the map object is inside another geometry.
@param hull_polygon Geometry to check against.
@note: The geometry must be closed like a polygon. (not really sure)
*/
virtual bool geometryIsInHull(const MathUtils::GeometryEngine::Geometry &hull_polygon) const = 0;
protected:
static int s_scaleHasVisibilityValue;
public:
static void setScaleHasVisibility(int scaleHasVisibility)
{
s_scaleHasVisibilityValue = scaleHasVisibility;
}
// : Visibility
//@}
/*! \name Selection, Picking */
//@{
/**
* @brief Get selected state.
* @return true if selected, otherwise false.
*/
virtual bool selected() const = 0;
/**
* @brief Set selected state.
* @param selected new state.
*/
virtual void setSelected(bool selected) = 0;
/**
* @brief Get pickable state.
* @return true if pickable, otherwise false.
*/
virtual bool pickable() const = 0;
/**
* @brief Set pickable state.
* @param pickable new state.
*/
virtual void setPickable(bool pickable) = 0;
//@}
/*! \name Symbol */
//@{
/**
* @brief Get current symbol.
* @return Current symbol.
*/
virtual SymbolData symbol() const = 0;
/**
* @brief Set new Symbol
* @param symbol new value.
*/
virtual void setSymbol(const SymbolData &symbol) = 0;
/**
* @brief reRenderSymbol
* Will set the changed flag to true, following updateView is required
*/
virtual void reRenderSymbol() = 0;
virtual SymbolDataToRender symbolDataToRender() const = 0;
/**
* @brief symbolImage returns an image, maybe to be used as preview icon.
* @return image of this MapObject.
*/
virtual SymbolImage symbolImage() const = 0;
virtual QImage previewImage() const = 0;
virtual QImage previewImageTypical() const = 0;
virtual QImage previewImageSpecific() const = 0;
//@}
/*! \name Common convenience methode, e.g. for MapObjectIndicator */
//@{
virtual void boundingBox(BoundingBox &bbox) const = 0;
virtual void setForceMajorColor(const QColor &majorColor) = 0;
virtual QColor majorColor() const = 0;
//@}
/*! \name Some methods regarding extrusion (renderer approach) */
//@{
virtual double extrusionHeight() const = 0;
virtual void setExtrusionHeight(double height = std::nan("")) = 0;
virtual const QString extrusionColorName() const = 0;
virtual void setExtrusionColorName(const QString &extrusionColorName) = 0;
//@}
/*! \name updateView */
//@{
/**
* @brief Transfer all values to view
* @return true on success
*/
virtual bool updateView() = 0;
//@}
};
//-----------------------------------------------------------------------------
// output operator:
//-----------------------------------------------------------------------------
/**
* @brief Output operator used fo all deriving classes.
* @param stream used to stream into.
* @param value to be streamed.
* @return appended stream.
*/
SITUATIONMAP_EXPORT std::ostream &operator<< (std::ostream &stream,
const AbstractMapObject &value);
} // namespace SituationMap