159 lines
3.8 KiB
C++
Executable File
159 lines
3.8 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* Interface of PixelBasedTextBoxHandler
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
// Own
|
|
#include "situation_map_types.h"
|
|
#include <GeometryModel/geometry_pixelTextBox.h>
|
|
#include <situation_map_export.h>
|
|
|
|
|
|
// Qt
|
|
#include <QObject>
|
|
#include <QString>
|
|
#include <QPointF>
|
|
|
|
class QTextEdit;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
namespace SituationMap
|
|
{
|
|
|
|
static const char *const PBTB_ID_PROPERTY_NAME = "PBTB_ID_PROPERTY";
|
|
|
|
//
|
|
// PBTB_ID - PixelBasedTextBox_Identifier
|
|
//
|
|
class SITUATIONMAP_EXPORT PBTB_ID
|
|
{
|
|
public:
|
|
PBTB_ID() = default;
|
|
~PBTB_ID() = default;
|
|
|
|
explicit PBTB_ID(int parentId, long uid = -1)
|
|
: m_parentId(parentId), m_uid(uid)
|
|
{}
|
|
|
|
void init()
|
|
{
|
|
m_parentId = -1; // >0 -> planFileId
|
|
m_uid = -1;
|
|
}
|
|
|
|
static long getNextId()
|
|
{
|
|
static long s_uid{0};
|
|
++s_uid;
|
|
return s_uid;
|
|
}
|
|
|
|
bool isValid() const
|
|
{
|
|
return (m_uid > 0);
|
|
}
|
|
|
|
QString toString() const
|
|
{
|
|
return QString(QStringLiteral("'parentId_%1:uid_%2'")).arg(m_parentId).arg(m_uid);
|
|
}
|
|
|
|
static PBTB_ID fromString(QString str)
|
|
{
|
|
str.remove(QStringLiteral("'"));
|
|
const QStringList &sl = str.split(QStringLiteral(":"));
|
|
if (sl.size() != 2)
|
|
return {};
|
|
|
|
PBTB_ID idRet;
|
|
{
|
|
QString temp = sl.first();
|
|
QStringList sl2 = temp.split(QStringLiteral("_"));
|
|
if (sl2.size() == 2)
|
|
idRet.m_parentId = sl2.last().toInt();
|
|
}
|
|
{
|
|
QString temp = sl.last();
|
|
QStringList sl3 = temp.split(QStringLiteral("_"));
|
|
if (sl3.size() == 2)
|
|
idRet.m_uid = sl3.last().toLong();
|
|
}
|
|
return idRet;
|
|
}
|
|
|
|
|
|
bool operator==(const PBTB_ID &o) const
|
|
{
|
|
return m_parentId == o.m_parentId && m_uid == o.m_uid;
|
|
}
|
|
bool operator!=(const PBTB_ID &o) const
|
|
{
|
|
return !operator==(o);
|
|
}
|
|
|
|
bool operator<(const PBTB_ID &o) const
|
|
{
|
|
if (m_parentId != o.m_parentId)
|
|
return m_parentId < o.m_parentId;
|
|
return m_uid < o.m_uid;
|
|
}
|
|
|
|
|
|
int m_parentId{-1} ; // >0 -> planFileId
|
|
long m_uid{-1};
|
|
};
|
|
|
|
|
|
/**
|
|
* @brief The PixelBasedTextBoxHandler class handles the create, modify and remove of pixel-based textboxes on the QGraphicsScene on top ot the ESRI layer.
|
|
*/
|
|
class SITUATIONMAP_EXPORT PixelBasedTextBoxHandler : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
using BaseClass = QObject;
|
|
|
|
public:
|
|
PixelBasedTextBoxHandler() = default; ///< Contructor
|
|
virtual ~PixelBasedTextBoxHandler() = default; ///< Destructor
|
|
|
|
PixelBasedTextBoxHandler(const PixelBasedTextBoxHandler &other) = delete;
|
|
PixelBasedTextBoxHandler &operator=(PixelBasedTextBoxHandler &other) = delete;
|
|
|
|
virtual QTextEdit *createTextBox(PBTB_ID &pbtbIdRef, const PixelTextBoxData &ptbd, bool enableGeometryModifications = true) = 0;
|
|
virtual QTextEdit *updateTextBox(const PBTB_ID &pbtbId, const PixelTextBoxData &ptbd) = 0;
|
|
virtual QTextEdit *getTextBox(const PBTB_ID &pbtbId) = 0;
|
|
|
|
virtual QVector<PBTB_ID> getAllIdsOfParent(const PBTB_ID &pbtbId) const = 0;
|
|
virtual PixelTextBoxData getPixelTextBoxData(const PBTB_ID &pbtbId) const = 0;
|
|
|
|
virtual void removeSelection() = 0;
|
|
virtual bool setSelected(const PBTB_ID &pbtbId) = 0;
|
|
|
|
virtual bool removeTextBox(const PBTB_ID &pbtbId) = 0;
|
|
virtual bool removeAllTextBoxesOfParent(int parentId) = 0;
|
|
|
|
Q_SIGNALS:
|
|
void pixelBasedTextBoxDoubleClickEvent(SituationMap::PBTB_ID pbtbId);
|
|
void pixelBasedTextBoxGeometryChanged(SituationMap::PBTB_ID pbtbId);
|
|
void pixelBasedTextBoxRemoveRequestedEvent(SituationMap::PBTB_ID pbtbId);
|
|
|
|
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// output operator:
|
|
//-----------------------------------------------------------------------------
|
|
SITUATIONMAP_EXPORT std::ostream &operator<< (std::ostream &, const PBTB_ID &);
|
|
|
|
|
|
} // namespace SituationMap
|
|
|