QTfrontend/drawmapscene.cpp
changeset 6616 f77bb02b669f
parent 5858 1f4a8cf9efcb
child 6700 e04da46ee43c
equal deleted inserted replaced
6615:65602f1ef0f8 6616:f77bb02b669f
    56         {
    56         {
    57             int c = path.elementCount();
    57             int c = path.elementCount();
    58             QPointF pos = mouseEvent->scenePos();
    58             QPointF pos = mouseEvent->scenePos();
    59             path.setElementPositionAt(c - 1, pos.x(), pos.y());
    59             path.setElementPositionAt(c - 1, pos.x(), pos.y());
    60 
    60 
    61         } else
    61         }
       
    62         else
    62         {
    63         {
    63             path.lineTo(mouseEvent->scenePos());
    64             path.lineTo(mouseEvent->scenePos());
    64             paths.first().append(mouseEvent->scenePos().toPoint());
    65             paths.first().append(mouseEvent->scenePos().toPoint());
    65         }
    66         }
    66         m_currPath->setPath(path);
    67         m_currPath->setPath(path);
   125         return;
   126         return;
   126 
   127 
   127     oldItems.clear();
   128     oldItems.clear();
   128 
   129 
   129     // do this since clear() would _destroy_ all items
   130     // do this since clear() would _destroy_ all items
   130     while(items().size()) {
   131     while(items().size())
       
   132     {
   131         oldItems.push_front(items().first());
   133         oldItems.push_front(items().first());
   132         removeItem(items().first());
   134         removeItem(items().first());
   133     }
   135     }
   134 
   136 
   135     oldPaths = paths;
   137     oldPaths = paths;
   212     QPoint prevPoint = points.first();
   214     QPoint prevPoint = points.first();
   213     int i = 1;
   215     int i = 1;
   214     while(i < points.size())
   216     while(i < points.size())
   215     {
   217     {
   216         if( (i != points.size() - 1)
   218         if( (i != points.size() - 1)
   217             && (sqr(prevPoint.x() - points[i].x()) + sqr(prevPoint.y() - points[i].y()) < 1000)
   219                 && (sqr(prevPoint.x() - points[i].x()) + sqr(prevPoint.y() - points[i].y()) < 1000)
   218           )
   220           )
   219             points.removeAt(i);
   221             points.removeAt(i);
   220         else
   222         else
   221         {
   223         {
   222             prevPoint = points[i];
   224             prevPoint = points[i];
   244     {
   246     {
   245         QPointF p = points[0] + QPointF(0.01, 0.01);
   247         QPointF p = points[0] + QPointF(0.01, 0.01);
   246         path.moveTo(p);
   248         path.moveTo(p);
   247 
   249 
   248         foreach(QPoint p, points)
   250         foreach(QPoint p, points)
   249             path.lineTo(p);
   251         path.lineTo(p);
   250     }
   252     }
   251 
   253 
   252     return path;
   254     return path;
   253 }
   255 }