mirror of
https://github.com/mapmapteam/mapmap.git
synced 2026-06-16 12:33:19 +02:00
Move active_vertex from Shape to MapperGLCanvas
This commit is contained in:
+7
-7
@@ -22,7 +22,7 @@
|
||||
#include "MainWindow.h"
|
||||
|
||||
MapperGLCanvas::MapperGLCanvas(QWidget* parent, const QGLWidget * shareWidget)
|
||||
: QGLWidget(parent, shareWidget), _mousepressed(false)
|
||||
: QGLWidget(parent, shareWidget), _mousepressed(false), _active_vertex(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ void MapperGLCanvas::mousePressEvent(QMouseEvent* event)
|
||||
dist = abs(xmouse - p.x) + abs(ymouse - p.y);
|
||||
if (dist < maxdist && dist < mindist)
|
||||
{
|
||||
shape->setActiveVertex(i);
|
||||
_active_vertex = i;
|
||||
mindist = dist;
|
||||
}
|
||||
}
|
||||
@@ -136,11 +136,11 @@ void MapperGLCanvas::mouseMoveEvent(QMouseEvent* event)
|
||||
Shape* shape = getCurrentShape();
|
||||
if (shape)
|
||||
{
|
||||
Point p = shape->getVertex(shape->getActiveVertex());
|
||||
Point p = shape->getVertex(_active_vertex);
|
||||
p.x = event->x();
|
||||
p.y = event->y();
|
||||
|
||||
shape->setVertex(shape->getActiveVertex(), p);
|
||||
shape->setVertex(_active_vertex, p);
|
||||
update();
|
||||
emit quadChanged();
|
||||
}
|
||||
@@ -159,7 +159,7 @@ void MapperGLCanvas::keyPressEvent(QKeyEvent* event)
|
||||
// else
|
||||
// {
|
||||
// Quad& quad = getQuad();
|
||||
// quad.setActiveVertex((quad.getActiveVertex() + 1) % 4);
|
||||
// _active_vertex = (_active_vertex + 1 ) % 4;
|
||||
// }
|
||||
// break;
|
||||
// case Qt::Key_Up:
|
||||
@@ -181,10 +181,10 @@ void MapperGLCanvas::keyPressEvent(QKeyEvent* event)
|
||||
// }
|
||||
//
|
||||
// Quad& quad = getQuad();
|
||||
// Point p = quad.getVertex(quad.getActiveVertex());
|
||||
// Point p = quad.getVertex(_active_vertex);
|
||||
// p.x += xMove;
|
||||
// p.y += yMove;
|
||||
// quad.setVertex(quad.getActiveVertex(), p);
|
||||
// quad.setVertex(_active_vertex, p);
|
||||
//
|
||||
// update();
|
||||
//
|
||||
|
||||
@@ -65,6 +65,7 @@ private:
|
||||
virtual void doDraw() = 0;
|
||||
void exitDraw();
|
||||
bool _mousepressed;
|
||||
int _active_vertex;
|
||||
|
||||
signals:
|
||||
void quadChanged();
|
||||
|
||||
@@ -41,11 +41,9 @@ class Shape
|
||||
public:
|
||||
typedef std::tr1::shared_ptr<Shape> ptr;
|
||||
std::vector<Point> vertices;
|
||||
int active_vertex;
|
||||
Shape() {}
|
||||
Shape(std::vector<Point> vertices_) :
|
||||
vertices(vertices_),
|
||||
active_vertex(0)
|
||||
vertices(vertices_)
|
||||
{}
|
||||
virtual ~Shape() {}
|
||||
|
||||
@@ -66,8 +64,6 @@ public:
|
||||
vertices[i].x = x;
|
||||
vertices[i].y = y;
|
||||
}
|
||||
void setActiveVertex(int x) {active_vertex = x;}
|
||||
int getActiveVertex() {return active_vertex;}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user