ScummVM API documentation
qd_contour.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef QDENGINE_QDCORE_QD_CONTOUR_H
23#define QDENGINE_QDCORE_QD_CONTOUR_H
24
25#include "qdengine/parser/xml_fwd.h"
26#include "qdengine/xmath.h"
27
28namespace Common {
29class WriteStream;
30}
31
32namespace QDEngine {
33
35
39class qdContour {
40public:
48 };
49
51 qdContour(const qdContour &ct);
52 virtual ~qdContour();
53
54 qdContour &operator = (const qdContour &ct);
55
58 return _contour_type;
59 }
62 _contour_type = tp;
63 }
64
66 int size_x() const {
67 return _size.x;
68 }
70 int size_y() const {
71 return _size.y;
72 }
73
75 bool is_inside(const Vect2s &pos) const;
76
78 virtual bool save_script(Common::WriteStream &fh, int indent = 0) const;
80 virtual bool load_script(const xml::tag *p);
81
83
86 void add_contour_point(const Vect2s &pt);
88
91 void insert_contour_point(const Vect2s &pt, int insert_pos = 0);
93 bool remove_contour_point(int pos);
95 bool update_contour_point(const Vect2s &pt, int pos);
96
99 _contour.clear();
100 }
101
103 void divide_contour(int shift = 1);
105 void mult_contour(int shift = 1);
107 void shift_contour(int dx, int dy);
108
110 const Vect2s &get_point(int pos) const {
111 return _contour[pos];
112 }
113
114 void createMaskOld(int x0, int y0, int x1, int y1);
115
116 const byte *maskData() const {
117 return &*_mask.begin();
118 }
119
121 const Vect2s &mask_size() const {
122 return _size;
123 }
124
126 const Vect2s &mask_pos() const {
127 return _mask_pos;
128 }
129
131 int contour_size() const {
132 return _contour.size();
133 }
136 return _contour;
137 }
138
139 bool is_mask_empty() const {
140 return _contour.empty();
141 }
142
143 bool update_contour();
144
145 // можно ли замкнуть текущий контур.
146 // для типов контура CONTOUR_CIRCLE и CONTOUR_RECTANGLE
147 // всегда возвращается false
148 bool can_be_closed() const;
149
151 bool is_contour_empty() const;
152
153private:
155 qdContourType _contour_type;
156
158 Vect2s _size;
159
160 Vect2s _mask_pos;
161
162 Std::vector<byte> _mask;
163
165
168 Std::vector<Vect2s> _contour;
169};
170
171} // namespace QDEngine
172
173#endif // QDENGINE_QDCORE_QD_CONTOUR_H
iterator begin()
Definition: array.h:375
Definition: stream.h:77
Definition: xmath.h:419
Контур.
Definition: qd_contour.h:39
const Std::vector< Vect2s > & get_contour() const
Возвращает массив точек контура.
Definition: qd_contour.h:135
int size_x() const
Возвращает горизонтальный размер контура.
Definition: qd_contour.h:66
void clear_contour()
Удаляет все точки из контура.
Definition: qd_contour.h:98
bool is_inside(const Vect2s &pos) const
Возвращает true, если точка с координатами pos лежит внутри контура.
const Vect2s & get_point(int pos) const
Возвращает координаты точки контура номер pos.
Definition: qd_contour.h:110
void shift_contour(int dx, int dy)
Добавляет к соответствующим координатам dx, dy.
bool is_contour_empty() const
Возвращает true, если контур пустой.
virtual bool save_script(Common::WriteStream &fh, int indent=0) const
Запись данных в скрипт.
qdContourType
Definition: qd_contour.h:41
@ CONTOUR_RECTANGLE
Прямоугольник
Definition: qd_contour.h:43
@ CONTOUR_POLYGON
Произвольный многоугольник
Definition: qd_contour.h:47
@ CONTOUR_CIRCLE
Окружность
Definition: qd_contour.h:45
void mult_contour(int shift=1)
Умножает координаты контура на 2 в степени shift.
void insert_contour_point(const Vect2s &pt, int insert_pos=0)
Вставляет точку в контур.
const Vect2s & mask_pos() const
Возвращает координаты центра маски.
Definition: qd_contour.h:126
int size_y() const
Возвращает вертикальный размер контура.
Definition: qd_contour.h:70
bool update_contour_point(const Vect2s &pt, int pos)
Присваивает точке номер pos контура координаты pt.
bool remove_contour_point(int pos)
Удаляет точку номер pos из контура.
const Vect2s & mask_size() const
Возвращает размеры маски.
Definition: qd_contour.h:121
void divide_contour(int shift=1)
Делит координаты контура на 2 в степени shift.
virtual bool load_script(const xml::tag *p)
Чтение данных из скрипта.
int contour_size() const
Возвращает количество точек в контуре.
Definition: qd_contour.h:131
void add_contour_point(const Vect2s &pt)
Добавляет точку в контур.
qdContourType contour_type() const
Возвращает тип контура.
Definition: qd_contour.h:57
void set_contour_type(qdContourType tp)
Устанавливает тип контура.
Definition: qd_contour.h:61
XML тег.
Definition: xml_tag.h:33
Definition: vector.h:39
Definition: algorithm.h:29
Базовый класс для игровых ресурсов.
Definition: console.h:28