# HG changeset patch # User unc0rr # Date 1290891339 -10800 # Node ID 3225ea34e4159572c10395e22458019bfade64f1 # Parent 4391526e436e38d65f6cf329d36442f9f9351db9 Some basic functionality diff -r 4391526e436e -r 3225ea34e415 tools/drawMapTest/drawmapscene.cpp --- a/tools/drawMapTest/drawmapscene.cpp Sat Nov 27 22:40:29 2010 +0300 +++ b/tools/drawMapTest/drawmapscene.cpp Sat Nov 27 23:55:39 2010 +0300 @@ -4,23 +4,49 @@ #include "drawmapscene.h" DrawMapScene::DrawMapScene(QObject *parent) : - QGraphicsScene(parent) + QGraphicsScene(parent), + m_pen(Qt::black), + m_brush(Qt::black) { setSceneRect(0, 0, 4096, 2048); + + QLinearGradient gradient(0, 0, 0, 2048); + gradient.setColorAt(0, QColor(160, 160, 255)); + gradient.setColorAt(1, QColor(255, 255, 160)); + setBackgroundBrush(QBrush(gradient)); + + m_halfWidth = 67; } void DrawMapScene::mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent) { qDebug() << "move" << mouseEvent->scenePos(); + + if(mouseEvent->buttons() && Qt::LeftButton) + drawFigure(mouseEvent->scenePos()); } void DrawMapScene::mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent) { qDebug() << "press" << mouseEvent->scenePos(); + + drawFigure(mouseEvent->scenePos()); } void DrawMapScene::mouseReleaseEvent(QGraphicsSceneMouseEvent * mouseEvent) { qDebug() << "release" << mouseEvent->scenePos(); } + +void DrawMapScene::drawFigure(const QPointF & point) +{ + addEllipse( + point.x() - m_halfWidth, + point.y() - m_halfWidth, + m_halfWidth * 2, + m_halfWidth * 2, + m_pen, + m_brush + ); +} diff -r 4391526e436e -r 3225ea34e415 tools/drawMapTest/drawmapscene.h --- a/tools/drawMapTest/drawmapscene.h Sat Nov 27 22:40:29 2010 +0300 +++ b/tools/drawMapTest/drawmapscene.h Sat Nov 27 23:55:39 2010 +0300 @@ -14,9 +14,15 @@ public slots: private: + qreal m_halfWidth; + QPen m_pen; + QBrush m_brush; + virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent); virtual void mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * mouseEvent); + + void drawFigure(const QPointF & point); }; #endif // DRAWMAPSCENE_H