Nix (Dev) 3.5.10
dev - 3.5.10 - 1af9301
Loading...
Searching...
No Matches
Mimic.hpp
Go to the documentation of this file.
1#ifndef IV_SRC_MODEL_DIAMAR_MIMIC_HPP_
2#define IV_SRC_MODEL_DIAMAR_MIMIC_HPP_
3
4#include "core/defines.hpp"
5#include "core/enums.hpp"
7#include "model/Revisions.hpp"
8#include "model/enums.hpp"
9#include "ui/cad/CDxf.hpp"
11
12#include <map>
13#include <memory>
14
15namespace iv::diamar
16{
17
18std::shared_ptr<iv::mimics::AbstractMimicElement> createMimicElement(iv::mimics::eMimicElementType mimicElementType);
19
20class Mimic : public std::vector<std::shared_ptr<iv::mimics::AbstractMimicElement>>
21{
22public:
23 Mimic();
24 void update(const Mimic &other, bool onlyElements = false);
25 bool load(const iv::file::xml::File &xml);
26 bool save(const std::shared_ptr<iv::file::xml::File> &xml) const;
27
28 std::shared_ptr<Mimic> clone() const;
29
30 void addElement(std::shared_ptr<iv::mimics::AbstractMimicElement> element);
31 void updateEnabledLanguages(const std::set<iv::eLanguage> &enabledLanguages);
32
33 // Graphics
34 void drawMimic(IGraphics *graphics, iv::eLanguage drawingLanguage) const;
35 void removeGraphicsObjects(IGraphics *graphics) const;
36
37 // Actions related
38 void handleEvent(CEventMotion *evtMotion) const;
39 void addBackGroundDxf(std::string_view nameFileBackGround);
41
42 std::shared_ptr<std::vector<std::weak_ptr<iv::channels::AbstractChannel>>> getChannels() const;
43 [[nodiscard]] std::unordered_set<iv::types::channelId> getRepeatedChannels() const;
45 std::optional<std::weak_ptr<iv::mimics::AbstractMimicElement>> isPointInMimic(double x, double y) const;
46 std::string toPdf();
47
48 // Panels
50
51private:
52 struct Sections
53 {
54 static constexpr std::string_view mimic {"Mimic"};
55 static constexpr std::string_view mimicNames {"Names"};
56 static constexpr std::string_view mimicName {"Name"};
57 static constexpr std::string_view mimicElements {"Elements"};
58 static constexpr std::string_view mimicElement {"Element"};
59 static constexpr std::string_view hiddenInStations {"HiddenInStations"};
60 static constexpr std::string_view hiddenInStation {"HiddenInStation"};
61 };
62 struct Keys
63 {
64 static constexpr std::string_view mimicId {"Id"};
65 static constexpr std::string_view mimicAspectRatio {"AspectRatio"};
66 static constexpr std::string_view path {"Path"};
67 static constexpr std::string_view pathBackground {"PathBackground"};
68 static constexpr std::string_view description {"Description"};
69 static constexpr std::string_view nameLanguage {"Language"};
70 static constexpr std::string_view name {"Name"};
71 static constexpr std::string_view stationId {"StationId"};
72 };
74 {
75 static constexpr std::string string {};
76 static constexpr std::string mimicAspectRatio {"SixteenByTen"};
77 static constexpr iv::eLanguage language {};
78 };
79
80public:
82
83 std::set<iv::types::stationId> m_hiddenInStations;
84
87 std::string m_pathBackground;
88 std::string m_description;
89
90private:
91 void drawControls(iv::mimics::eZDepth depth, IGraphics *pGraphics, iv::eLanguage drawingLanguage,
92 const std::optional<std::unordered_set<iv::types::channelId>> &channelsRepeatedOpt) const;
94 void prvCreateBackground(std::string_view pathFileBackground);
95 std::shared_ptr<CGeoCanvas> prvCreateGeoScreen() const;
96
97 mutable std::shared_ptr<CGeoCanvas> m_geoScreen;
98 std::vector<std::shared_ptr<CDxf>> m_backgroundDxf;
99 std::vector<iv::ui::resources::ImageResource> m_backgroundResources;
100};
101
102class Mimics : public std::map<iv::types::mimicId, std::shared_ptr<iv::diamar::Mimic>>
103{
104public:
105 void update(const iv::diamar::Mimics &other);
106 bool load(const iv::file::xml::node &nodeDataProject, std::string_view mimicsFolderPath);
107 bool save(iv::file::xml::node &nodeDataProject, std::string_view mimicsFolderPath,
108 const std::optional<std::shared_ptr<std::vector<std::shared_ptr<iv::file::xml::File>>>> &savingFilesOut =
109 std::nullopt) const;
110
111 // Mimics' mimic manipulation: Controller
112 bool createMimic(const iv::types::mimicId &mimicId, const std::map<iv::eLanguage, std::string> &mimicNames);
113 bool insertMimic(const std::shared_ptr<iv::diamar::Mimic> &mimic);
114
115 bool deleteMimic(const iv::types::mimicId &mimicId);
116
117 [[nodiscard]] std::shared_ptr<iv::diamar::Mimic> extractMimic(const iv::types::mimicId &mimicId);
118
119 bool changeId(const iv::types::mimicId &mimicId, const iv::types::mimicId &newMimicId);
120
121 [[nodiscard]] std::weak_ptr<iv::diamar::Mimic> getMimic(const iv::types::mimicId &mimicId) const;
122 [[nodiscard]] std::weak_ptr<iv::diamar::Mimic> getMimic(const uint64_t &index) const;
123 [[nodiscard]] std::weak_ptr<iv::diamar::Mimic> getMimicByOrder(iv::types::mimicOrder order) const;
124
125 [[nodiscard]] std::map<iv::types::order, std::shared_ptr<iv::diamar::Mimic>> getMimicsWithOrder() const;
126
127private:
128 struct Sections
129 {
130 static constexpr std::string_view mimics {"Mimics"};
131 static constexpr std::string_view mimic {"Mimic"};
132 };
133 struct Keys
134 {
135 static constexpr std::string_view mimicId {"Id"};
136 };
138 {
139 static constexpr std::string string {};
140 };
141};
142
143}// namespace iv::diamar
144
145#endif//IV_SRC_MODEL_DIAMAR_MIMIC_HPP_
Definition AbstractComponentGUI.hpp:30
Definition CEventMotion.hpp:15
Definition IGraphics.hpp:20
Definition Mimic.hpp:21
Mimic()
Definition Mimic.cpp:154
std::string m_description
Definition Mimic.hpp:88
iv::types::mimicId m_id
Definition Mimic.hpp:81
AbstractComponentGUI * panelSelectTypeScreenResolution()
Definition Mimic.cpp:438
std::shared_ptr< CGeoCanvas > prvCreateGeoScreen() const
Definition Mimic.cpp:498
std::set< iv::types::stationId > m_hiddenInStations
Definition Mimic.hpp:83
void addBackGroundDxf(std::string_view nameFileBackGround)
Definition Mimic.cpp:384
void updateControlsBackground()
Definition Mimic.cpp:412
iv::model::diamar::eMimicAspectRatio m_mimicAspectRatio
Definition Mimic.hpp:86
std::shared_ptr< std::vector< std::weak_ptr< iv::channels::AbstractChannel > > > getChannels() const
Definition Mimic.cpp:531
void drawControls(iv::mimics::eZDepth depth, IGraphics *pGraphics, iv::eLanguage drawingLanguage, const std::optional< std::unordered_set< iv::types::channelId > > &channelsRepeatedOpt) const
Definition Mimic.cpp:508
void addElement(std::shared_ptr< iv::mimics::AbstractMimicElement > element)
Definition Mimic.cpp:303
std::optional< std::weak_ptr< iv::mimics::AbstractMimicElement > > isPointInMimic(double x, double y) const
Definition Mimic.cpp:424
void removeBackgroundDxf()
Definition Mimic.cpp:398
iv::model::LocalizedText m_names
Definition Mimic.hpp:85
void update(const Mimic &other, bool onlyElements=false)
Definition Mimic.cpp:162
bool load(const iv::file::xml::File &xml)
Definition Mimic.cpp:186
std::shared_ptr< Mimic > clone() const
Definition Mimic.cpp:283
std::unordered_set< iv::types::channelId > getRepeatedChannels() const
Definition Mimic.cpp:543
std::shared_ptr< CGeoCanvas > m_geoScreen
Definition Mimic.hpp:97
void removeGraphicsObjects(IGraphics *graphics) const
Definition Mimic.cpp:360
void drawMimic(IGraphics *graphics, iv::eLanguage drawingLanguage) const
Definition Mimic.cpp:324
std::vector< std::shared_ptr< CDxf > > m_backgroundDxf
Definition Mimic.hpp:98
std::vector< iv::ui::resources::ImageResource > m_backgroundResources
Definition Mimic.hpp:99
std::string m_pathBackground
Definition Mimic.hpp:87
void prvCreateBackground(std::string_view pathFileBackground)
Definition Mimic.cpp:470
std::string toPdf()
Definition Mimic.cpp:571
void updateEnabledLanguages(const std::set< iv::eLanguage > &enabledLanguages)
Definition Mimic.cpp:308
void prvRemoveElements(iv::mimics::eZDepth depth)
Definition Mimic.cpp:452
void handleEvent(CEventMotion *evtMotion) const
Definition Mimic.cpp:368
bool save(const std::shared_ptr< iv::file::xml::File > &xml) const
Definition Mimic.cpp:253
Definition Mimic.hpp:103
std::map< iv::types::order, std::shared_ptr< iv::diamar::Mimic > > getMimicsWithOrder() const
Definition Mimic.cpp:796
std::weak_ptr< iv::diamar::Mimic > getMimicByOrder(iv::types::mimicOrder order) const
Definition Mimic.cpp:782
bool createMimic(const iv::types::mimicId &mimicId, const std::map< iv::eLanguage, std::string > &mimicNames)
Definition Mimic.cpp:694
std::shared_ptr< iv::diamar::Mimic > extractMimic(const iv::types::mimicId &mimicId)
Definition Mimic.cpp:736
bool load(const iv::file::xml::node &nodeDataProject, std::string_view mimicsFolderPath)
Definition Mimic.cpp:621
bool deleteMimic(const iv::types::mimicId &mimicId)
Definition Mimic.cpp:722
bool save(iv::file::xml::node &nodeDataProject, std::string_view mimicsFolderPath, const std::optional< std::shared_ptr< std::vector< std::shared_ptr< iv::file::xml::File > > > > &savingFilesOut=std::nullopt) const
Definition Mimic.cpp:648
std::weak_ptr< iv::diamar::Mimic > getMimic(const iv::types::mimicId &mimicId) const
Definition Mimic.cpp:762
void update(const iv::diamar::Mimics &other)
Definition Mimic.cpp:816
bool changeId(const iv::types::mimicId &mimicId, const iv::types::mimicId &newMimicId)
Definition Mimic.cpp:750
bool insertMimic(const std::shared_ptr< iv::diamar::Mimic > &mimic)
Definition Mimic.cpp:708
Definition xmlFile.hpp:128
Definition xmlFile.hpp:15
Definition DataLoggerManager.cpp:10
std::shared_ptr< iv::mimics::AbstractMimicElement > createMimicElement(const iv::mimics::eMimicElementType mimicElementType)
Definition Mimic.cpp:83
eMimicElementType
Definition enums.hpp:8
eZDepth
Definition enums.hpp:50
eMimicAspectRatio
Definition enums.hpp:33
std::string mimicId
Definition types.hpp:72
uint16_t mimicOrder
Definition types.hpp:73
eLanguage
Definition enums.hpp:37
Definition Mimic.hpp:74
static constexpr iv::eLanguage language
Definition Mimic.hpp:77
static constexpr std::string mimicAspectRatio
Definition Mimic.hpp:76
Definition Mimic.hpp:63
static constexpr std::string_view mimicId
Definition Mimic.hpp:64
static constexpr std::string_view mimicAspectRatio
Definition Mimic.hpp:65
static constexpr std::string_view nameLanguage
Definition Mimic.hpp:69
static constexpr std::string_view path
Definition Mimic.hpp:66
static constexpr std::string_view pathBackground
Definition Mimic.hpp:67
static constexpr std::string_view name
Definition Mimic.hpp:70
static constexpr std::string_view description
Definition Mimic.hpp:68
static constexpr std::string_view stationId
Definition Mimic.hpp:71
Definition Mimic.hpp:53
static constexpr std::string_view hiddenInStations
Definition Mimic.hpp:59
static constexpr std::string_view mimic
Definition Mimic.hpp:54
static constexpr std::string_view hiddenInStation
Definition Mimic.hpp:60
static constexpr std::string_view mimicElements
Definition Mimic.hpp:57
static constexpr std::string_view mimicElement
Definition Mimic.hpp:58
static constexpr std::string_view mimicNames
Definition Mimic.hpp:55
static constexpr std::string_view mimicName
Definition Mimic.hpp:56
Definition Mimic.hpp:138
Definition Mimic.hpp:134
static constexpr std::string_view mimicId
Definition Mimic.hpp:135
Definition Mimic.hpp:129
static constexpr std::string_view mimic
Definition Mimic.hpp:131
static constexpr std::string_view mimics
Definition Mimic.hpp:130
Definition structs.hpp:29