413 lines
15 KiB
Objective-C
Executable File
413 lines
15 KiB
Objective-C
Executable File
/**
|
|
**
|
|
** @RDE_HEADER@
|
|
** plan_editor.h
|
|
** $Id$
|
|
** $HeadURL$
|
|
** $Author$
|
|
**
|
|
** -----------------------------------------------------------------------------------------------
|
|
**
|
|
** Hardware-Environment: Intel-PC
|
|
** Software-Environment: Windows 7, Qt 5.4. ArcGIS 10.2.5
|
|
**
|
|
** Language ........: C++ 11
|
|
**
|
|
** -----------------------------------------------------------------------------------------------
|
|
**
|
|
** Author ...........: Jörg Turla, SPD G, Tel. 3132
|
|
**
|
|
** -----------------------------------------------------------------------------------------------
|
|
**
|
|
** Notes .........:
|
|
**
|
|
** 09.12.2015, JT : First edition for use with Qt5
|
|
**
|
|
** -----------------------------------------------------------------------------------------------
|
|
*/
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <GeometryModel/geometry_model.h>
|
|
|
|
#include <QtCore/QObject>
|
|
#include <QtCore/QString>
|
|
|
|
#include <Map/map.h>
|
|
#include <MapObjects/participant.h>
|
|
#include <Common/simple_value.h>
|
|
|
|
#include <functional>
|
|
#include <memory>
|
|
|
|
#include "plan_editor_export.h"
|
|
|
|
class QListWidgetItem;
|
|
class QTreeWidget;
|
|
class QTransform;
|
|
class QTextEdit;
|
|
|
|
namespace SituationMap
|
|
{
|
|
class Map;
|
|
class PBTB_ID;
|
|
namespace RB
|
|
{
|
|
class RubberbandBase;
|
|
class Rubberband;
|
|
}
|
|
}
|
|
|
|
|
|
namespace LtsWidgets
|
|
{
|
|
class LtsBaseLayoutWidget;
|
|
class LtsFramelessDialog;
|
|
class LtsDialog;
|
|
} // namespace LtsWidgets
|
|
|
|
|
|
namespace LtsSession
|
|
{
|
|
class LtsSession;
|
|
} // LtsSession
|
|
|
|
|
|
namespace PlanEditor
|
|
{
|
|
|
|
class PlanEditorSession;
|
|
|
|
/**
|
|
@class PlanEditor
|
|
@brief Implementation of an editor to create and modify geometry models for plans
|
|
|
|
The PlanEditor serves as editor to create and modifiy plan. These plan can be displayed as single layer in situation map display.
|
|
|
|
@see PlanEditorGuiPlugin::PlanEditorGuiPlugin
|
|
*/
|
|
class PLANEDITOR_EXPORT PlanEditor : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
friend class LookupSymbolManager;
|
|
friend class ModelTreeWidget;
|
|
friend class FavouritesActionManager;
|
|
|
|
public:
|
|
|
|
/**
|
|
@name Construction & Destruction
|
|
@{
|
|
*/
|
|
|
|
/**
|
|
Constructs a PlanEditor plugin for use with a situation map.
|
|
@param map Instance of situation map class
|
|
@param ltsbaseWidget Lts toplevel main widget to plugin the editor gui
|
|
|
|
*/
|
|
PlanEditor(SituationMap::Map *map, LtsWidgets::LtsBaseLayoutWidget *ltsbaseWidget);
|
|
|
|
/**
|
|
Constructs a PlanEditor plugin for use with a situation map.
|
|
@param map Instance of situation map class
|
|
@param ltsSession LtsSession to integrate the plan editor with Lts-Framework
|
|
|
|
*/
|
|
PlanEditor(SituationMap::Map *map, LtsSession::LtsSession *ltsSession);
|
|
|
|
virtual ~PlanEditor();
|
|
/** @} */
|
|
|
|
|
|
bool event( QEvent *e) override;
|
|
|
|
/**
|
|
When the map is not ready many of the situation map function will not work correctly. The function checks
|
|
the base map and returns true if all is fine, otherwise false.
|
|
*/
|
|
bool readyForUse() const;
|
|
|
|
/**
|
|
Returns toplevel widget of PlanEditor plugin. This toplevel widget has been defined a second parameter of ctor
|
|
*/
|
|
QWidget *topLevelWidget() const;
|
|
|
|
/**
|
|
Provides a window title. Can be used in toplevel widget
|
|
*/
|
|
QString title() const;
|
|
|
|
|
|
QString planDefaultDirectory() const; /**< default directory to save files */
|
|
void setPlanDefaultDirectory(const QString &dir); /**< set default directory */
|
|
|
|
/**
|
|
@brief Set or import content of plan from file management service. The plan content is here defined by a XML structure.
|
|
@{
|
|
*/
|
|
bool setPlan(const QByteArray &xmlContent); /**< Set content of a plan. Is used to load plans from file management service. */
|
|
bool importPlan( const QByteArray &xmlContent); /**< Import content of a plan to current plan. Function is used to import plans from file management service */
|
|
/** @} */
|
|
|
|
void setNameOfPlan(const QString & planName); /**< Set name of plan to display in application window */
|
|
|
|
void saveToFile(const QString &filePath); /**< Save current plan to file */
|
|
void loadFromFile(const QString &filePath); /**< Read file from file. */
|
|
|
|
void setSelected(SituationMap::UniqueMapId, bool on = true, bool enableShowDialogTab = true); /**< Set selection flag of a map feature. */
|
|
void setSelected(const SituationMap::GeometryModel::Node &, bool on = true, bool enableShowDialogTab = true); /**< Set selection flag of a map feature associated with GeometryModel::Node. */
|
|
|
|
bool isSelected(SituationMap::UniqueMapId); /**< Check a map feature for selection. */
|
|
bool isSelected(const SituationMap::GeometryModel::Node &); /**< Check a geometry model node for selection (it is the same as checking the UniqueMapId). */
|
|
|
|
/**
|
|
Provides unique Id of the map feature associated with GeometryModel::Node
|
|
*/
|
|
SituationMap::UniqueMapId getIdFromNode(const SituationMap::GeometryModel::Node &p) const;
|
|
|
|
SituationMap::GeometryModel::Node buildTextNode(const QPointF &loc); /**< Create text node to display text. */
|
|
|
|
void buildTextBoxPixelNode(const QPointF &locPixel); /**< Create pixel-based textbox */
|
|
void writeTextBoxDataToModel();
|
|
|
|
void setParticipantsSidcsInUse(const QSet<QString> &sidcs);
|
|
|
|
/**
|
|
Initialize symbol favourites. Is used to recover favourite settings from file management service.
|
|
@param xmlContent XML based description symbol favourites buttons.
|
|
*/
|
|
void setAllSymbolFavourites(const QString &xmlContent);
|
|
|
|
/**
|
|
Returns a XML based description symbol favourites buttons. Is used to store favourite settings it with file management service.
|
|
*/
|
|
QString allSymbolFavouritesToString() const;
|
|
|
|
/**
|
|
@brief Emit signals to request function call of file mamagement service from PlanEditorGuiPlugin
|
|
@{
|
|
*/
|
|
void requestFileServiceReadDefaultSymbolFavourites() { emit fileServiceReadDefaultSymbolFavourites(); }
|
|
void requestFileServiceReadSymbolFavourites(QString &xmlString) { emit fileServiceReadSymbolFavourites(xmlString); }
|
|
void requestFileServiceStoreSymbolFavourites(const QString &xmlString) { emit fileServiceStoreSymbolFavourites(xmlString); }
|
|
/** @} */
|
|
|
|
|
|
/**
|
|
Returns true if symbology symbol model has been loaded completly, otherwise false.
|
|
*/
|
|
bool isSymbolModelValid() const;
|
|
|
|
|
|
/**
|
|
Set a functor that will be called to save plan data at end of running plan editor (see PlanEditor::onAskSaveChanges()). If saveFunction
|
|
functor is undefined ( = nullptr) the local file system is used to save the current plan as file.
|
|
*/
|
|
void installSaveFunction(const std::function<void()> &saveFunction = nullptr);
|
|
|
|
void checkFromEmptyPlan();
|
|
|
|
class InternalData; // must be public here, because of some internal classes in PlanEditor.cpp
|
|
|
|
std::unique_ptr<InternalData> m_internal;
|
|
|
|
public slots:
|
|
|
|
void onEnablePlanEditor();
|
|
void onDisablePlanEditor();
|
|
|
|
void onEnableSymbolWidgets();
|
|
|
|
void onRubberbandAction();
|
|
|
|
void onHideDialogTab();
|
|
void onShowDialogTab(const SituationMap::GeometryModel::Node &node = SituationMap::GeometryModel::Node());
|
|
|
|
void onTextEditDialogRequested(const SituationMap::PBTB_ID &pbtbId);
|
|
void onTextEditGeometryChanged(const SituationMap::PBTB_ID &pbtbId);
|
|
void onTextEditRemoveRequested(const SituationMap::PBTB_ID &pbtbId);
|
|
|
|
void onMapObjectClicked(const SituationMap::Map::RefPointerMapObjectList &mapObjList);
|
|
|
|
void onContextMenuRequested(const SituationMap::Map::RefPointerMapObjectList &mapObjList, const QPointF &viewportPosition);
|
|
|
|
void onAskSaveChanges();
|
|
void onAskRejectChanges(bool &reject);
|
|
void onSignalClose();
|
|
|
|
void onQuit();
|
|
void onViewHelp();
|
|
void onShowHelp();
|
|
void onViewAbout();
|
|
|
|
void onGeoModelModified(unsigned int modifyCount);
|
|
|
|
void onNoticeGeoModelTypeError(const QString &);
|
|
void onNoticeGeoModelAttributeError(const QString &);
|
|
void onNoticeGeoModelModelError(const QString &);
|
|
void onNoticeGeoModelError(const QString &);
|
|
|
|
void onNoticeGeoModelUpdate(const SituationMap::GeometryModel::Node &node, SituationMap::GeometryModel::Attribute att, bool coordsChanged);
|
|
|
|
void onPlanReset();
|
|
|
|
void onPlanCreate();
|
|
void onPlanLoad();
|
|
|
|
void onPlanSave();
|
|
void onPlanSaveAs();
|
|
void onPlanAutoSave();
|
|
void onPlanImport();
|
|
void onPlanSaveSelected();
|
|
void onPlanPrint();
|
|
void onMetaData();
|
|
|
|
void onUndo();
|
|
void onRedo();
|
|
void onUndoHistory();
|
|
void onRedoHistory();
|
|
|
|
void onDelete();
|
|
|
|
void onCopy();
|
|
void onCut();
|
|
void onPaste();
|
|
|
|
void onGroup();
|
|
void onUngroup();
|
|
|
|
void onEditAttributes();
|
|
void onEditGraphicGeometry();
|
|
void onMoveGraphicGeometry();
|
|
void onRotateGraphicGeometry();
|
|
void onScaleGraphicGeometry();
|
|
|
|
void onChooseSymbol();
|
|
|
|
void onRubberbandAbort(SituationMap::RB::RubberbandBase *rubberband);
|
|
void onSymbolCreate(SituationMap::RB::RubberbandBase *rubberband, bool createParticipant = false);
|
|
void onLineCreate(SituationMap::RB::RubberbandBase *rubberband);
|
|
void onPolylineCreate(SituationMap::RB::RubberbandBase *rubberband);
|
|
void onPolygonCreate(SituationMap::RB::RubberbandBase *rubberband);
|
|
void onRectangleCreate(SituationMap::RB::RubberbandBase *rubberband);
|
|
void onTextLineCreate(SituationMap::RB::RubberbandBase *rubberband);
|
|
|
|
void onTextBoxPixelCreate(SituationMap::RB::RubberbandBase *rubberband);
|
|
void onTextBoxPixelTextChanged(const QString &htmlText);
|
|
void onTextBoxPixelBackgroundColorChanged(const QColor &backgroundColor);
|
|
void onTextBoxPixelTextApplied(const QString &htmlText);
|
|
void onTextBoxPixelCanceled();
|
|
void onTextBoxPixelClosed();
|
|
|
|
void onTransformMove(SituationMap::RB::RubberbandBase *rubberband);
|
|
void onTransformRotate(SituationMap::RB::RubberbandBase *rubberband);
|
|
void onTransformScale(SituationMap::RB::RubberbandBase *rubberband);
|
|
|
|
SituationMap::RB::Rubberband *onSymbolCreateRubberband(const QString ¤tSidc, bool createParticipant);
|
|
|
|
SituationMap::RB::Rubberband *onLineCreateRubberband();
|
|
SituationMap::RB::Rubberband *onPolylineCreateRubberband();
|
|
SituationMap::RB::Rubberband *onPolygonCreateRubberband();
|
|
SituationMap::RB::Rubberband *onRectangleCreateRubberband();
|
|
SituationMap::RB::Rubberband *onSmoothLineCreateRubberband();
|
|
SituationMap::RB::Rubberband *onEllipseCreateRubberband();
|
|
SituationMap::RB::Rubberband *onTextLineCreateRubberband();
|
|
SituationMap::RB::Rubberband *onTextBoxPixelCreateRubberband();
|
|
|
|
|
|
void onClearSelection();
|
|
|
|
void onCenterViewSelected();
|
|
|
|
void onSymbolModified( AdvancedSymbology::SymbologyType symbologyType
|
|
, const QString &sidcPattern
|
|
, const QString &symbolAttributes
|
|
, const SituationMap::SimpleValue<AdvancedSymbology::Injury> &participantState
|
|
, const SituationMap::SimpleValue<int> &participantPartyId
|
|
, const SituationMap::SimpleValue<int> &participantDamageId
|
|
, const QMap<SituationMap::Participant::TextModifier, SituationMap::SimpleValue<QString>> &participantTextModifier );
|
|
|
|
void onSymbolXmlAttrModified(const QString & undoToken, SituationMap::GeometryModel::Attribute attribute, const QVariant &value);
|
|
|
|
void onUpdateView();
|
|
|
|
void onTransformRubberband();
|
|
|
|
void updateSelectedFeature(const QString &undoToken);
|
|
|
|
void addStyleAttributes(const SituationMap::GeometryModel::Node &, bool prepareUndo = true, bool changedAttrOnly = true);
|
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
|
|
|
void initializePlan();
|
|
void initializePlanTextBoxPixel();
|
|
|
|
void buildSelectionModeBox(const PlanEditorSession &, bool retranslate = false);
|
|
void buildFileBox(const PlanEditorSession &, bool retranslate = false);
|
|
void buildEditBox(const PlanEditorSession &, bool retranslate = false);
|
|
void buildCreateBox(const PlanEditorSession &, bool retranslate = false);
|
|
void buildHelpBox(const PlanEditorSession &, bool retranslate = false);
|
|
|
|
LtsWidgets::LtsDialog *buildDebugBox(QWidget *parent);
|
|
|
|
void importFromFile(const QString &filePath);
|
|
void saveSelectedToFile(const QString &filePath);
|
|
|
|
void doPicking(const SituationMap::Map::RefPointerMapObjectList &mapObjList);
|
|
|
|
|
|
void getSymbolAttributes(const SituationMap::GeometryModel::Node &);
|
|
|
|
void removeFeature(SituationMap::UniqueMapId itemId, bool prepareUndo = true);
|
|
|
|
SituationMap::GeometryModel::Node addGeoModelPrimitive(SituationMap::GeometryModel::PrimitiveType type
|
|
, const QList<QPointF> &points
|
|
, const QList<QPair<SituationMap::GeometryModel::Attribute, QVariant>> &attributes
|
|
, int userData = SituationMap::IdHandler::BadId
|
|
, const QString &textData = QString()
|
|
, SituationMap::GeometryModel::HorizontalAlign textAlign = SituationMap::GeometryModel::HorizontalAlign::Left);
|
|
|
|
template<class RubberbandTransformClass> void createTransformRubberband();
|
|
|
|
void showHistory(QPointer<LtsWidgets::LtsFramelessDialog> &dlgHistory
|
|
, QTreeWidget *&lwHistory
|
|
, const QString &title
|
|
, const QStringList &history);
|
|
|
|
qulonglong createSymbolDropEvent(const QString &sidc);
|
|
|
|
private:
|
|
|
|
void init();
|
|
|
|
void abortCurrentBboxRubberband();
|
|
|
|
void setSelected(const SituationMap::GeometryModel::Node &, bool on, bool checkParents, bool enableShowDialogTab);
|
|
|
|
void getChildNodes(const SituationMap::GeometryModel::Node &node, SituationMap::GeometryModel::NodeList &childNodes);
|
|
|
|
signals:
|
|
|
|
void modifyFeatureStyle(const QString &undoToken); /**< Internal signal to indicate that a feature has been changed. */
|
|
|
|
/**
|
|
@name Signals uses to interchange with PlanEditorGuiPlugin
|
|
@{
|
|
*/
|
|
void quitPlanEditor(); /**< The PlanEditor has been closed, close the PlanEditorGuiPlugin also. */
|
|
void fileServiceReadDefaultSymbolFavourites(); /**< Read default symbol favourites settings from file management service. */
|
|
void fileServiceReadSymbolFavourites(QString &xmlString); /**< Read a scope of symbol favourites settings from file management service. */
|
|
void fileServiceStoreSymbolFavourites(const QString &); /**< Store a scope of symbol favourites settings with file management service. */
|
|
/** @} */
|
|
|
|
void symbolModelLoaded();
|
|
|
|
}; // PlanEditor
|
|
|
|
} // namespace PlanEditor
|