-
Notifications
You must be signed in to change notification settings - Fork 0
/
Layer.h
278 lines (236 loc) · 14.9 KB
/
Layer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
//----------------------------------------------------------------------------//
// *** ДВИЖОК ГЕОИНФОРМАЦИОННОЙ СИСТЕМЫ *** //
// //
// Файл Layer.h //
// //
// *** TLAYER КАРТОГРАФИЧЕСКИЙ СЛОЙ *** //
// //
// Автор ГЛУЩЕНКО Сергей //
// //
// Москва //
//----------------------------------------------------------------------------//
#ifndef LayerH
#define LayerH
#include <string>
#include <QPen>
#include <QBrush>
#include <QGraphicsRectItem>
#include <QGraphicsEllipseItem>
#include <QGraphicsPolygonItem>
#include <QGraphicsPathItem>
#include "../Multitude/Multitude.h"
class TLayer
{
public:
//Тип символа, изображающего объект "точка" в слое
enum TTypeSymbol
{
NONE_SYMBOL = 0, //Не задан
CIRCLE_SYMBOL = 1, //Круг
RECT_SYMBOL = 2 //Квадрат
};
//Тип объекта в слое
enum TTypeObj
{
NONE_OBJ = 0, //Не задан
POINT_OBJ = 1, //Точка
POLYLINE_OBJ = 2, //Полилиния
REGION_OBJ = 3 //Регион
};
//Полушарие Земли, в котором располагается объект
enum THemisphere
{
NONE_HEM = 0, //Не задано
NORTH_HEM = 1, //Северное полушарие
SOUTH_HEM = 2, //Южное полушарие
BOTH_HEM = 3 //Оба полушария (северное и южное)
};
//Тип описывает параметры объекта "точка" в слое
struct ObjPoint
{
ObjPoint() : Type(NONE_SYMBOL), Pen(NULL), Brush(NULL) {}
TTypeSymbol Type; //Тип символа, изображающего объект "точка"
TMultitude::TOnePoint Point; //Геодезические координаты объекта "точка"
QPen *Pen; //Перо для рисования объекта "точка"
QBrush *Brush; //Заливка для рисования объекта "точка"
};
typedef struct ObjPoint TObjPoint;
//Тип описывает параметры объекта "полилиния" в слое
struct ObjPolyLine
{
ObjPolyLine() : Pen(NULL) {}
TMultitude::TSpot Spot; //Геодезические координаты узловых точек полилинии
QPen *Pen; //Перо для рисования объекта "полилиния"
};
typedef struct ObjPolyLine TObjPolyLine;
//Тип описывает параметры объекта "регион" в слое
struct ObjRegion
{
ObjRegion() : Pen(NULL), Brush(NULL) {}
TMultitude::TSpot Spot; //Геодезические координаты узловых точек региона
QPen *Pen; //Перо для рисования объекта "регион"
QBrush *Brush; //Заливка для рисования объекта "регион"
};
typedef struct ObjRegion TObjRegion;
//Тип описывает заголовок одного объекта в слое
struct HeaderOfObj
{
HeaderOfObj() : ID(0), Name("") {}
unsigned int ID; //Идентификатор объекта
std::string Name; //Наименование объекта
};
typedef struct HeaderOfObj THeaderOfObj;
//Тип описывает все заголовки объектов в слое
typedef std::vector<THeaderOfObj> THeadersObjects;
//Тип описывает параметры одного объекта в слое
struct Obj
{
Obj() : HandlePointAsEllipse(NULL), HandlePointAsRect(NULL), HandleRegion(NULL), HandlePolyLine(NULL),
Hemisphere(NONE_HEM), Type(NONE_OBJ) {}
QGraphicsEllipseItem *HandlePointAsEllipse; //Указатель на item кружочка, помещенного на сцену. Пользователь не заполняет
QGraphicsRectItem *HandlePointAsRect; //Указатель на item квадрата, помещенного на сцену. Пользователь не заполняет
QGraphicsPolygonItem *HandleRegion; //Указатель на item полигона, помещенного на сцену. Пользователь не заполняет
QGraphicsPathItem *HandlePolyLine; //Указатель на item полилинии, помещенной на сцену. Пользователь не заполняет
THeaderOfObj Header; //Заголовок объекта
THemisphere Hemisphere; //Полушарие Земли, в котором располагается объект
TTypeObj Type; //Тип объекта
TObjPoint Point; //Тип объекта POINT_OBJ - "точка"
TObjPolyLine PolyLine; //Тип объекта POLYLINE_OBJ - "полилиния"
TObjRegion Region; //Тип объекта REGION_OBJ - "регион"
};
typedef struct Obj TObj;
//Тип описывает параметры всех объектов в слое
typedef std::vector<TObj> TObjects;
private:
//Возвращает название полушария Земли, в котором располагается объект
THemisphere GetHemisphere(TMultitude::TSpot Spot);
bool Visible; //Признак визуализации слоя
public:
TLayer(void);
virtual ~TLayer(void);
//Переводит цвета R, G, B в код цвета MapInfo
// На вход подаются:
// - красный;
// - зеленый;
// - синий.
// На выходе можно получить:
// - цвет в формате MapInfo
void RGBToMI(int R, int G, int B, int* MI);
//Переводит цвета R, G, B в код цвета MapInfo
// На вход подаются:
// - цвет в формате MapInfo.
// На выходе можно получить:
// - красный;
// - зеленый;
// - синий
void MIToRGB(int MI, int* R, int* G, int* B);
//Переводит перо формата MapInfo в формат QPen
// На вход подаются:
// - ширина линии в формате MapInfo;
// - тип линии в формате MapInfo;
// - цвет линии в формате MapInfo.
// На выходе можно получить:
// - перо QPen
QPen PenMIToQPen(int WidthMI, int PatternMI, int ColorMI);
//Переводит заливку формата MapInfo в формат QBrush
// На вход подаются:
// - тип штриховки в формате MapInfo;
// - цвет штриховки в формате MapInfo.
// На выходе можно получить:
// - заливку QBrush
QBrush BrushMIToQBrush(int PatternMI, int ColorMI);
//Быстро перерисовать слой
void RePaint(void);
//Перерисовать слой путем удаления и создания всех его объектов
void CoolRePaint(void);
//Скрыть (девизуализировать) слой
void Hide(void);
//Показать (визуализировать) слой
void Show(void);
//Возвращает признак визуализации слоя
bool GetVisible(void);
//Возвращает строку (содержащую имя слоя и имя объекта) по указателю, если такой объект найдется в слое
std::string GetStringObj(QGraphicsItem* ID);
//Возвращает заголовок объекта по указателю, если такой объект найдется в слое
THeaderOfObj GetHeaderObj(QGraphicsItem* ID);
//Возвращает минимальное свободное значение идентификатора для размещения нового объекта в слое
// На выходе можно получить:
// - свободное значение идентификатора объекта
unsigned int GetFreeID(void);
//Возвращает список заголовков объектов в слое
THeadersObjects GetObjList(void);
//Добавляет в слой объект типа "полилиния"
// !!! Добавление объекта в слой не вызывает перерисовку слоя. Следует пользоваться методом RePaint !!!
// На вход подаются:
// - идентификатор объекта;
// - наименование объекта;
// - геодезические координаты узловых точек полилинии на эллипсоиде ПЗ-90 [рад];
// - перо для рисования объекта "полилиния"
void AddPolyLineQuick(unsigned int ID, std::string Name, TMultitude::TSpot Spot, QPen Pen);
//Добавляет в слой объект типа "регион"
// !!! Добавление объекта в слой не вызывает перерисовку слоя. Следует пользоваться методом RePaint !!!
// На вход подаются:
// - идентификатор объекта;
// - наименование объекта;
// - геодезические координаты узловых точек региона на эллипсоиде ПЗ-90 [рад];
// - перо для рисования объекта "регион";
// - заливка для рисования объекта "регион"
void AddRegionQuick(unsigned int ID, std::string Name, TMultitude::TSpot Spot, QPen Pen, QBrush Brush);
//Добавляет в слой объект типа "точка"
// !!! Добавление объекта в слой не вызывает перерисовку слоя. Следует пользоваться методом RePaint !!!
// На вход подаются:
// - идентификатор объекта;
// - наименование объекта;
// - тип символа, изображающего объект "точка";
// - геодезические координаты объекта "точка" на эллипсоиде ПЗ-90 [рад];
// - перо для рисования объекта "точка";
// - заливка для рисования объекта "точка"
void AddPointQuick(unsigned int ID, std::string Name, TTypeSymbol Type, TMultitude::TOnePoint Point, QPen Pen, QBrush Brush);
//Добавляет в слой объект типа "точка"
// !!! Добавление объекта в слой не вызывает перерисовку слоя. Следует пользоваться методом RePaint !!!
// На вход подаются:
// - идентификатор объекта;
// - наименование объекта;
// - тип символа, изображающего объект "точка";
// - геодезические координаты объекта "точка" на эллипсоиде ПЗ-90 [рад];
// - перо для рисования объекта "точка";
// - заливка для рисования объекта "точка".
// На выходе можно получить:
// - true в случае успешного выполнения процедуры;
// - false в случае какой-либо ошибки
bool AddPoint(unsigned int ID, std::string Name, TTypeSymbol Type, TMultitude::TOnePoint Point, QPen Pen, QBrush Brush);
//Добавляет в слой объект типа "полилиния"
// !!! Добавление объекта в слой не вызывает перерисовку слоя. Следует пользоваться методом RePaint !!!
// На вход подаются:
// - идентификатор объекта;
// - наименование объекта;
// - геодезические координаты узловых точек полилинии на эллипсоиде ПЗ-90 [рад];
// - перо для рисования объекта "полилиния".
// На выходе можно получить:
// - true в случае успешного выполнения процедуры;
// - false в случае какой-либо ошибки
bool AddPolyLine(unsigned int ID, std::string Name, TMultitude::TSpot Spot, QPen Pen);
//Добавляет в слой объект типа "регион"
// !!! Добавление объекта в слой не вызывает перерисовку слоя. Следует пользоваться методом RePaint !!!
// На вход подаются:
// - идентификатор объекта;
// - наименование объекта;
// - геодезические координаты узловых точек региона на эллипсоиде ПЗ-90 [рад];
// - перо для рисования объекта "регион";
// - заливка для рисования объекта "регион".
// На выходе можно получить:
// - true в случае успешного выполнения процедуры;
// - false в случае какой-либо ошибки
bool AddRegion(unsigned int ID, std::string Name, TMultitude::TSpot Spot, QPen Pen, QBrush Brush);
//Удаляет объект любого типа из слоя
// На вход подаются:
// - идентификатор объекта.
// На выходе можно получить:
// - true в случае успешного выполнения процедуры;
// - false в случае какой-либо ошибки
bool DelObj(unsigned int ID);
TObjects Objects; //Объекты, содержащиеся в слое
std::string Name; //Имя слоя обязательно к заполнению
void* OWNER; //Обязателен к заполнению
};
#endif