QTfrontend/drawmapscene.cpp
changeset 13203 eaa494f0b19e
parent 11046 47a8c19ecb60
child 13204 9565569e410c
equal deleted inserted replaced
13202:2fe85d497e0f 13203:eaa494f0b19e
    32 
    32 
    33 DrawMapScene::DrawMapScene(QObject *parent) :
    33 DrawMapScene::DrawMapScene(QObject *parent) :
    34     QGraphicsScene(parent),
    34     QGraphicsScene(parent),
    35     m_pen(Qt::yellow),
    35     m_pen(Qt::yellow),
    36     m_brush(Qt::yellow),
    36     m_brush(Qt::yellow),
    37     m_cursor(new QGraphicsEllipseItem(-0.5, -0.5, 1, 1))
    37     m_cursor(new QGraphicsEllipseItem(-5, -5, 5, 5))
    38 {
    38 {
    39     setSceneRect(0, 0, 4096, 2048);
    39     setSceneRect(0, 0, 4096, 2048);
    40 
    40 
    41     QLinearGradient gradient(0, 0, 0, 2048);
    41     QLinearGradient gradient(0, 0, 0, 2048);
    42     gradient.setColorAt(0, QColor(60, 60, 155));
    42     gradient.setColorAt(0, QColor(60, 60, 155));
    52     m_pen.setJoinStyle(Qt::RoundJoin);
    52     m_pen.setJoinStyle(Qt::RoundJoin);
    53     m_pen.setCapStyle(Qt::RoundCap);
    53     m_pen.setCapStyle(Qt::RoundCap);
    54     m_currPath = 0;
    54     m_currPath = 0;
    55 
    55 
    56     m_isCursorShown = false;
    56     m_isCursorShown = false;
    57     m_cursor->setPen(QPen(Qt::green));
    57     QPen cursorPen = QPen(Qt::green);
       
    58     cursorPen.setJoinStyle(Qt::RoundJoin);
       
    59     cursorPen.setCapStyle(Qt::RoundCap);
       
    60     cursorPen.setWidth(m_pen.width());
       
    61     m_cursor->setPen(cursorPen);
    58     m_cursor->setZValue(1);
    62     m_cursor->setZValue(1);
    59     m_cursor->setScale(m_pen.width());
       
    60 }
    63 }
    61 
    64 
    62 void DrawMapScene::mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent)
    65 void DrawMapScene::mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent)
    63 {
    66 {
    64     if(m_currPath && (mouseEvent->buttons() & Qt::LeftButton))
    67     if(m_currPath && (mouseEvent->buttons() & Qt::LeftButton))
   183     if(wheelEvent->delta() > 0 && m_pen.width() < 516)
   186     if(wheelEvent->delta() > 0 && m_pen.width() < 516)
   184         m_pen.setWidth(m_pen.width() + 10);
   187         m_pen.setWidth(m_pen.width() + 10);
   185     else if(wheelEvent->delta() < 0 && m_pen.width() >= 16)
   188     else if(wheelEvent->delta() < 0 && m_pen.width() >= 16)
   186         m_pen.setWidth(m_pen.width() - 10);
   189         m_pen.setWidth(m_pen.width() - 10);
   187 
   190 
   188     m_cursor->setScale(m_pen.width());
   191     QPen cursorPen = m_cursor->pen();
       
   192     cursorPen.setWidth(m_pen.width());
       
   193     m_cursor->setPen(cursorPen);
   189 
   194 
   190     if(m_currPath)
   195     if(m_currPath)
   191     {
   196     {
   192         m_currPath->setPen(m_pen);
   197         m_currPath->setPen(m_pen);
   193         paths.first().width = serializePenWidth(m_pen.width());
   198         paths.first().width = serializePenWidth(m_pen.width());