PointProbe and point movement
This commit is contained in:
parent
4ae8031e88
commit
4148d42bfb
4 changed files with 71 additions and 13 deletions
|
|
@ -7,6 +7,20 @@
|
|||
#include <iostream>
|
||||
#include "line.h"
|
||||
|
||||
struct PointProbe
|
||||
{
|
||||
int ownerIndex = -1;
|
||||
bool isStart = true;
|
||||
bool inBounds = true;
|
||||
|
||||
PointProbe() {}
|
||||
|
||||
PointProbe(int owner, bool start = true, bool bounds = true):
|
||||
ownerIndex(owner),
|
||||
isStart(start),
|
||||
inBounds(bounds) {}
|
||||
};
|
||||
|
||||
class GridPreview : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -16,6 +30,7 @@ class GridPreview : public QWidget
|
|||
const QString tableTemplate = "return {\n width = %1,\n height = %2,\n lines = {\n%3\n }\n}";
|
||||
|
||||
bool mouseCaptured = false;
|
||||
PointProbe capturedProbe, lastProbe;
|
||||
public:
|
||||
explicit GridPreview(QWidget *parent = nullptr);
|
||||
void setSize(int newWidth, int newHeight);
|
||||
|
|
@ -30,6 +45,7 @@ public:
|
|||
int getWidth();
|
||||
int getHeight();
|
||||
const Line& getLine(int index);
|
||||
const PointProbe& getCapturedProbe();
|
||||
|
||||
const QString toLuaTable();
|
||||
void paintEvent(QPaintEvent* event);
|
||||
|
|
@ -42,8 +58,12 @@ public:
|
|||
const QPoint localMousePosition(QMouseEvent* event);
|
||||
const QPoint snapToGrid(const QPoint& global);
|
||||
|
||||
double isPointOccupied(const QPoint& point);
|
||||
double pointInBounds(const QPoint& point);
|
||||
bool isPointOccupied(const QPoint& point);
|
||||
bool pointInBounds(const QPoint& point);
|
||||
bool pointIsFree(PointProbe &pp);
|
||||
|
||||
int getPointOwner(const QPoint& point);
|
||||
const PointProbe probePoint(const QPoint& point);
|
||||
signals:
|
||||
void updatedContents();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue