tools/drawMapTest/drawmapscene.cpp
changeset 4424 3225ea34e415
parent 4423 4391526e436e
child 4426 969e411c72aa
--- 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
+        );
+}