mitushkin-infa/FigureList.h

51 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Менеджер фигур: хранит все фигуры поля, линии между ними и работает с файлом
#ifndef FigureListH
#define FigureListH
#include <vector>
#include "BaseFigure.h"
// линия соединения двух фигур, у каждой линии свой цвет и толщина
struct TFigLink
{
TFigure *from;
TFigure *to;
TColor color;
int width;
};
class TFigureManager
{
private:
std::vector<TFigure*> list; // фигуры в порядке наложения (последняя - сверху)
std::vector<TFigLink*> links; // линии соединения
int lastNum; // последний выданный номер
TFigure* MakeFigure(String type, int aNum);
void FreeAll();
bool Joined(TFigure *a, TFigure *b);
public:
TFigureManager();
~TFigureManager();
TFigure* Add(String type, int ax, int ay, int aw, int ah, TColor fill, TColor line);
void Delete(TFigure *f);
void Clear();
int Count();
TFigure* FindAt(int px, int py);
void FindInRect(TRect r, std::vector<TFigure*> &out);
bool ToTop(std::vector<TFigure*> &figs);
bool Join(std::vector<TFigure*> &figs);
bool Unjoin(std::vector<TFigure*> &figs);
bool AnyLinks(std::vector<TFigure*> &figs);
TFigLink* LinkAt(int px, int py);
void DeleteLink(TFigLink *l);
void PaintAll(TCanvas *c);
void Save(String fileName);
void Load(String fileName);
};
#endif