コード例 #1
0
ファイル: perimeterWindow.cpp プロジェクト: lmjakt/dvreader
vector<int> PerimeterWindow::boundaryFromPolygon(QPolygon poly, int xo, int yo, int gw){
    // not sure of the best way of doing this, but lets have a go..
    vector<int> points;
    if(poly.size() < 2){
	cerr << "PerimeterWindow::boundaryFromPolygon, points is too small (less than 2) " << poly.size() << endl;
	return(points);
    }
    for(uint i=1; i < poly.size(); i++){   
	// Fill in the points from i-1 to i
	QPoint p1 = poly[i-1];
	QPoint p2 = poly[i];
//	points.push_back((p1.y() + yo) * gw + p1.x() + xo);
	// then work out how to get the other points..
	int dx = p2.x() - p1.x();
	int dy = p2.y() - p1.y();
	int stepNo = abs(dx) > abs(dy) ? abs(dx) : abs(dy);  
        // in the funny world of pixels a diagonal is only as long as the longer side..
	for(int i=0; i < stepNo; i++){
	    int lx = p1.x() + (i * dx)/stepNo;
	    int ly = p1.y() + (i * dy)/stepNo;
	    // then convert and push back..
	    points.push_back((ly + yo) * gw + lx + xo);
	}
    }
    // but at this point we have not added the last point so we need to do that..
    QPoint p = poly.back();
    points.push_back( (p.y() + yo) * gw + p.x() + xo);
    return(points);
}
コード例 #2
0
ファイル: kpCommandSize.cpp プロジェクト: KDE/kolourpaint
// public static
kpCommandSize::SizeType kpCommandSize::PolygonSize (const QPolygon &points)
{
#if DEBUG_KP_COMMAND_SIZE && 1
    qCDebug(kpLogCommands) << "kpCommandSize::PolygonSize() points.size="
               << points.size ()
               << " sizeof(QPoint)=" << sizeof (QPoint)
               << endl;
#endif

    return ((SizeType) points.size () * sizeof (QPoint));
}
コード例 #3
0
ファイル: rs_infoarea.cpp プロジェクト: CERobertson/LibreCAD
double RS_InfoArea::getArea(const QPolygon& polygon)
{
    double ret= 0.0;
    if(polygon.size()<3) return ret;

    for(int i=0;i<polygon.size(); ++i){
        const QPoint& p0=polygon.at(i);
        const QPoint& p1=polygon.at((i+1)%polygon.size());
        ret += p0.x()*p1.y()-p0.y()*p1.x();
    }
    return 0.5*fabs(ret);
}
コード例 #4
0
ファイル: mapmatrix.cpp プロジェクト: Exadios/Cumulus
// The new function using fixed point multiplication
QPolygon MapMatrix::map(const QPolygon &a) const
{
  int size = a.size();
  int64_t fx;
  int64_t fy;
  int32_t curx;
  int32_t cury;
  int32_t lastx = 0;
  int32_t lasty = 0;

  QPolygon p;

  for( int i = 0; i < size; i++ )
    {
      a.point(i, &curx, &cury);
      fx = itofp24p8( curx );
      fy = itofp24p8( cury );
      // some cheating involved; multiplication with the "wrong" macro
      // after "left shifting" the "m" value in createMatrix
      curx = fp24p8toi( mulfp8p24(m11,fx) + mulfp8p24(m21,fy) + dx);
      cury = fp24p8toi( mulfp8p24(m22,fy) + mulfp8p24(m12,fx) + dy);

      if ( (i==0) | ( ((curx - lastx) | (cury - lasty)) != 0) )
        {
          p.append(QPoint(curx, cury));
          lastx = curx;
          lasty = cury;
        }
    }

  return p;
}
コード例 #5
0
ファイル: draw_Base.cpp プロジェクト: Broentech/sdraw
void CDrawBase::drawAidPolygon(QPolygon _polygon, QPen *pen)
{
   if(!aidBufferRegistered)
   {
      return;
   }

   if(_polygon.size() >= 2)
   {
      // draw new aid polyline
      QPainter painter(m_aidBuffer);

      QPen usePen;
      if (0 != pen)
      {
         usePen = *pen;
      }
      else
      {
         usePen = QPen(Qt::lightGray, 1);
         usePen.setStyle(Qt::DashLine);
      }
      painter.setPen(usePen);
      painter.drawPolygon(_polygon);
   }

   emit requestUpdate();
}
コード例 #6
0
ファイル: RectPicker.cpp プロジェクト: qimo601/FCS
//将位置转换成字符串
QwtText RectPicker::trackerTextF(const QPointF &pos) const
{
	QwtText text;

	const QPolygon points = selection();//选择的点
	if (!points.isEmpty())
	{
		QString num;
		QPoint point = points[0];
		QPointF point2 = invTransform(point);
		num = QString("(%1,%2),(,)").arg(point2.x()).arg(point2.y());
		QColor bg(Qt::white);
		bg.setAlpha(200);
		if (points.size() == 2)
		{

			QPointF point0 = invTransform(points[0]);
			QPointF point1 = invTransform(points[1]);
			num = QString("(%1,%2),(%3,%4)").arg(point0.x()).arg(point0.y()).arg(point1.x()).arg(point1.y());
		}
		text.setBackgroundBrush(QBrush(bg));
		text.setText(num);
	}
	return text;
}
コード例 #7
0
QRect toRect(QPolygon polygon)
{
    if(polygon.size() != 4)
        return QRect();

    return QRect(polygon.first(), polygon.at(2));
}
コード例 #8
0
ファイル: graph_clipper.cpp プロジェクト: ongbe/xchart
inline void GraphPolygonClipper::addPoint(
    QPolygon &pa, uint pos, const QPoint &point) const
{
    if ( uint(pa.size()) <= pos ) 
        pa.resize(pos + 5);

    pa.setPoint(pos, point);
}
コード例 #9
0
ファイル: zoomer.cpp プロジェクト: Broentech/sdraw
QPolygon Zoomer::getZoomedPolygon(const QPolygon &poly)
{
   QPolygon newPoly;
   for(int i=0; i<poly.size(); i++)
   {
      newPoly << getZoomedPoint(poly.at(i));
   }
   return newPoly;
}
コード例 #10
0
ファイル: convert.cpp プロジェクト: NickSpyrison/qtbase
SEXP to_sexp(QPolygon polygon) {
  SEXP rpolygon = allocMatrix(INTSXP, polygon.size(), 2);
  int nr = nrows(rpolygon);
  for (int i = 0; i < nr; i++) {
    INTEGER(rpolygon)[i] = polygon[i].x();
    INTEGER(rpolygon)[i + nr] = polygon[i].y();
  }
  return rpolygon;
}
コード例 #11
0
ファイル: RegionMask.cpp プロジェクト: lopespt/PhD-Thesis
RegionMask::RegionMask(int height, int width, const QPolygon &boundary, const QList<QPolygon> &holes) : Mat(height,
                                                                                                            width,
                                                                                                            CV_8UC1, cvScalarAll(0)),
                                                                                                        boundary(
                                                                                                                boundary),
                                                                                                        holes(holes) {
    assert(boundary.size() > 0);
    QPolygon2Mask(*this, boundary, holes);
}
コード例 #12
0
QRegion::QRegion(const QPolygon &a, Qt::FillRule fillRule)
{
    if (a.size() < 3) {
        d = &shared_empty;
        d->ref.ref();
    } else {
        d = new QRegionData;
        d->ref = 1;
        d->rgn = qt_tryCreatePolygonRegion(a, fillRule);
    }
}
コード例 #13
0
//! Wrapper for QPainter::drawPolyline()
void QwtPainter::drawPolyline( QPainter *painter, const QPolygon &polygon )
{
    QRectF clipRect;
    const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect );

    QPolygon cpa = polygon;
    if ( deviceClipping )
        cpa = QwtClipper::clipPolygon( clipRect, cpa );

    qwtDrawPolyline<QPoint>( painter,
        cpa.constData(), cpa.size(), d_polylineSplitting );
}
コード例 #14
0
ファイル: qmatrix.cpp プロジェクト: 12307/VLC-for-VS2010
QPolygon QMatrix::map(const QPolygon &a) const
{
    int size = a.size();
    int i;
    QPolygon p(size);
    const QPoint *da = a.constData();
    QPoint *dp = p.data();
    for(i = 0; i < size; i++) {
        MAPINT(da[i].x(), da[i].y(), dp[i].rx(), dp[i].ry());
    }
    return p;
}
コード例 #15
0
HRGN qt_tryCreatePolygonRegion(const QPolygon &a, Qt::FillRule fillRule)
{
    const int tries = 10;
    for (int i = 0; i < tries; ++i) {
        HRGN region = CreatePolygonRgn(reinterpret_cast<const POINT*>(a.data()), a.size(),
                                       fillRule == Qt::OddEvenFill ? ALTERNATE : WINDING);
        if (region) {
            if (GetRegionData(region, 0, 0))
                return region;
            else
                DeleteObject(region);
        }
    }
    return 0;
}
コード例 #16
0
/*!
 * \see drawBoundingBoxes(QPainter *aPainter, QPen *aPen)
 * \see drawPolygons(QPainter *aPainter, QPen *aPen)
 *
 * It contains drawing of the confirmed and not confirmed selections either.
 */
void
ImageHolder::paintEvent(QPaintEvent *anEvent)
{
	QLabel::paintEvent(anEvent);

	QPainter painter(this);
	painter.setRenderHint(QPainter::Antialiasing);
	//painter.setRenderHint(QPainter::SmoothPixmapTransform);
	QPen pen;

	if (NoTool != tool_) {
		pen.setWidth(1);
		pen.setColor(QColor(Qt::black));
		pen.setStyle(Qt::DashLine);
		painter.setPen(pen);

		if (BoundingBoxTool == tool_) {
			/* scaling */
			QRect bbox = bounding_box_.rect;
			QPoint bboxTopLeft = bbox.topLeft() * scale_;
			QPoint bboxBottomRight = bbox.bottomRight() * scale_;

			bbox.setTopLeft(bboxTopLeft);
			bbox.setBottomRight(bboxBottomRight);

			painter.drawRect(bbox);
		}
		else if (PolygonTool == tool_) {
			/* scaling */
			QPoint point;
			QPolygon poly = polygon_.poly;
			for (int i = 0; i < poly.size(); i++) {
				point.setX(poly.at(i).x());
				point.setY(poly.at(i).y());
				point *= scale_;
				poly.remove(i);
				poly.insert(i, point);
			}
			painter.drawPolygon(poly);
		}
	}

	/* drawing bounding boxes */
	drawBoundingBoxes(&painter, &pen);
	drawPolygons(&painter, &pen);
}
コード例 #17
0
ファイル: graph_clipper.cpp プロジェクト: ongbe/xchart
//! Sutherland-Hodgman polygon clipping
QPolygon GraphPolygonClipper::clipPolygon(const QPolygon &pa) const
{
    if ( contains( pa.boundingRect() ) )
        return pa;

    QPolygon cpa(pa.size());

    clipEdge((Edge)0, pa, cpa);

    for ( uint edge = 1; edge < NEdges; edge++ ) 
    {
        const QPolygon rpa = cpa;
        clipEdge((Edge)edge, rpa, cpa);
    }

    return cpa;
}
コード例 #18
0
ファイル: tst_qpolygon.cpp プロジェクト: KDE/android-qt
void tst_QPolygon::makeEllipse()
{
    // create an ellipse with R1 = R2 = R, i.e. a circle
    QPolygon pa;
    const int R = 50; // radius
    QPainterPath path;
    path.addEllipse(0, 0, 2*R, 2*R);
    pa = path.toSubpathPolygons().at(0).toPolygon();

    int i;
    // make sure that all points are R+-1 away from the center
    bool err = FALSE;
    for (i = 1; i < pa.size(); i++) {
        QPoint p = pa.at( i );
        double r = sqrt( pow( double(p.x() - R), 2.0 ) + pow( double(p.y() - R), 2.0 ) );
        // ### too strict ? at least from visual inspection it looks
        // quite odd around the main axes. 2.0 passes easily.
        err |= ( qAbs( r - double(R) ) > 2.0 );
    }
    QVERIFY( !err );
}
コード例 #19
0
ファイル: graph_clipper.cpp プロジェクト: ongbe/xchart
void GraphPolygonClipper::clipEdge(Edge edge, 
    const QPolygon &pa, QPolygon &cpa) const
{
    if ( pa.count() == 0 )
    {
        cpa.resize(0);
        return;
    }

    unsigned int count = 0;

    QPoint p1 = pa.point(0);
    if ( insideEdge(p1, edge) )
        addPoint(cpa, count++, p1);

    const uint nPoints = pa.size();
    for ( uint i = 1; i < nPoints; i++ )
    {
        const QPoint p2 = pa.point(i);
        if ( insideEdge(p2, edge) )
        {
            if ( insideEdge(p1, edge) )
                addPoint(cpa, count++, p2);
            else
            {
                addPoint(cpa, count++, intersectEdge(p1, p2, edge));
                addPoint(cpa, count++, p2);
            }
        }
        else
        {
            if ( insideEdge(p1, edge) )
                addPoint(cpa, count++, intersectEdge(p1, p2, edge));
        }
        p1 = p2;
    }
    cpa.resize(count);
}
コード例 #20
0
ファイル: nodeElement.cpp プロジェクト: Antropovi/qreal
void NodeElement::updateData()
{
	Element::updateData();
	if (!mMoving) {
		QPointF newpos = mGraphicalAssistApi.position(id());
		QPolygon newpoly = mGraphicalAssistApi.configuration(id());

		QRectF newRect; // Use default ((0,0)-(0,0))
		// QPolygon::boundingRect is buggy :-(
		if (!newpoly.isEmpty()) {
			int minx = newpoly[0].x();
			int miny = newpoly[0].y();
			int maxx = newpoly[0].x();
			int maxy = newpoly[0].y();
			for (int i = 1; i < newpoly.size(); ++i) {
				if (minx > newpoly[i].x()) {
					minx = newpoly[i].x();
				}
				if (maxx < newpoly[i].x()) {
					maxx = newpoly[i].x();
				}
				if (miny > newpoly[i].y()) {
					miny = newpoly[i].y();
				}
				if (maxy < newpoly[i].y()) {
					maxy = newpoly[i].y();
				}
			}
			newRect = QRectF(QPoint(minx, miny), QSize(maxx - minx, maxy - miny));
		}

		setGeometry(newRect.translated(newpos));
	}
	mElementImpl->updateData(this);
	updateLabels();
	update();
}
コード例 #21
0
ファイル: saxsview_image.cpp プロジェクト: emblsaxs/saxsview
void SaxsviewMask::Private::setValue(SaxsviewMask *mask, const QPolygonF& p, double value) {
  if (SaxsviewFrameData *d = (SaxsviewFrameData*)(mask->data())) {
    // QPolygonF::toPolygon() internally uses toPoint() rounding, see above.
    QPolygon polygon;
    foreach (QPointF pt, p)
      polygon << QPoint((int)pt.x(), (int)pt.y());

    const QRect r = polygon.boundingRect();

    if (polygon.size() > 2) {
      for (int x = r.x(); x <= r.x() + r.width(); ++x)
        for (int y = r.y(); y <= r.y() + r.height(); ++y)
          if (polygon.containsPoint(QPoint(x, y), Qt::OddEvenFill))
            d->setValue(x, y, value);

    } else
      bresenham(polygon[0].x(), polygon[0].y(),
                polygon[1].x(), polygon[1].y(),
                d, value);

    modified = true;
    mask->plot()->replot();
  }
}
コード例 #22
0
ファイル: datamanager.cpp プロジェクト: UFOID/UFO-Detector
bool DataManager::readDetectionAreaFile(bool clipToCamera) {
    QFile areaFile(m_config->detectionAreaFile());
    QDomDocument doc;
    QDomElement root;
    int x = 0;
    int y = 0;
    int cameraId = m_config->cameraIndex();
    int cameraWidth = m_config->cameraWidth();
    int cameraHeight = m_config->cameraHeight();
    QPolygon cameraRectangle;
    bool polygonsClipped = false;
    bool polygonWasClosed = false;

    if(!areaFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
        QString errorMsg = tr("Failed to open the detection area file %1. Please create it in Settings dialog or manually.").arg(areaFile.fileName());
        emit messageBroadcasted(errorMsg);
        return false;
    }

    if(!doc.setContent(&areaFile)) {
        QString errorMsg = tr("Error reading the detection area file %1").arg(areaFile.fileName());
        areaFile.close();
        emit messageBroadcasted(errorMsg);
        return false;
    }

    areaFile.close();
    root = doc.documentElement();
    if (root.nodeName() != "detectionarealist") {
        QString errorMsg = tr("Expected <detectionarealist> tag in detection area file but not found");
        emit messageBroadcasted(errorMsg);
        return false;
    }
    QDomNodeList areaList = root.childNodes();

    if (areaList.count() > 1) {
        QString errorMsg = tr("More than one detection areas defined, combining all together");
        emit messageBroadcasted(errorMsg);
    }

    for (int i = 0; i < areaList.count(); i++) {
        QDomNode area = areaList.at(i);
        QDomNodeList areaNodes = area.childNodes();

        if (area.nodeName() != "detectionarea") {
            QString errorMsg = tr("Expected <detectionarea> tag in detection area file but not found.");
            emit messageBroadcasted(errorMsg);
            return false;
        }

        QDomNodeList cameraList = area.toElement().elementsByTagName("camera");

        if (cameraList.count() != 1) {
            QString errorMsg = tr("Expected single <camera> tag in detection area. Assuming camera index 0.");
            emit messageBroadcasted(errorMsg);
        }
        for (int c = 0; c < cameraList.count(); c++) {
            QDomElement cameraElement = cameraList.at(c).toElement();
            cameraId = cameraElement.attribute("id").toInt();
            cameraWidth = cameraElement.attribute("width").toInt();
            cameraHeight = cameraElement.attribute("height").toInt();
            if (cameraId == m_config->cameraIndex()) {
                break;
            }
        }

        cameraRectangle << QPoint(0, 0) << QPoint(0, cameraHeight - 1)
                        << QPoint(cameraWidth - 1, cameraHeight - 1) << QPoint(cameraWidth - 1, 0);

        while (!m_detectionAreaPolygons.isEmpty()) {
            QPolygon* polygon = m_detectionAreaPolygons.takeLast();
            delete polygon;
        }

        for (int a = 0; a < areaNodes.count(); a++) {
            QDomNode areaSubNode = areaNodes.at(a);

            if (areaSubNode.nodeName() == "polygon") {
                QDomNodeList pointList = areaSubNode.childNodes();
                QPolygon* polygon = new QPolygon();

                for (int p = 0; p < pointList.count(); p++) {
                    QDomElement pointElement = pointList.at(p).toElement();
                    if (pointElement.nodeName() == "point") {
                        x = pointElement.attribute("x").toInt();
                        y = pointElement.attribute("y").toInt();
                        polygon->append(QPoint(x, y));
                    }
                }
                if (clipToCamera && polygon->size() &&
                    !cameraRectangle.boundingRect().contains(polygon->boundingRect()))
                {
                    if (polygon->first() == polygon->last()) {
                        polygonWasClosed = true;
                    }
                    *polygon = polygon->intersected(cameraRectangle);
                    polygonsClipped = true;
                    if (!polygonWasClosed) {
                        // intersected() treats polygon as implicitly closed
                        // so extra node is added: remove it
                        if (polygon->first() == polygon->last()) {
                            polygon->removeLast();
                        }
                    }
                }
                m_detectionAreaPolygons.append(polygon);
            }
        }
    }
    if (polygonsClipped) {
        QString warningMsg = tr("Detection area was clipped in order to fit the camera size.");
        emit messageBroadcasted(warningMsg);
    }
    return true;
}
コード例 #23
0
ファイル: SvmParser.cpp プロジェクト: ChrisJong/krita
bool SvmParser::parse(const QByteArray &data)
{
    // Check the signature "VCLMTF"
    if (!data.startsWith("VCLMTF"))
        return false;

    QBuffer buffer((QByteArray *) &data);
    buffer.open(QIODevice::ReadOnly);

    QDataStream mainStream(&buffer);
    mainStream.setByteOrder(QDataStream::LittleEndian);

    // Start reading from the stream: read past the signature and get the header.
    soakBytes(mainStream, 6);
    SvmHeader header(mainStream);
#if DEBUG_SVMPARSER
    debugVectorImage << "================ SVM HEADER ================";
    debugVectorImage << "version, length:" << header.versionCompat.version << header.versionCompat.length;
    debugVectorImage << "compressionMode:" << header.compressionMode;
    debugVectorImage << "mapMode:" << "Origin" << header.mapMode.origin
                  << "scaleX"
                  << header.mapMode.scaleX.numerator << header.mapMode.scaleX.denominator
                  << (qreal(header.mapMode.scaleX.numerator) / header.mapMode.scaleX.denominator)
                  << "scaleY"
                  << header.mapMode.scaleY.numerator << header.mapMode.scaleY.denominator
                  << (qreal(header.mapMode.scaleY.numerator) / header.mapMode.scaleY.denominator);
    debugVectorImage << "size:" << header.width << header.height;
    debugVectorImage << "actionCount:" << header.actionCount;
    debugVectorImage << "================ SVM HEADER ================";
#endif    

    mBackend->init(header);

#if DEBUG_SVMPARSER
    {
        QPolygon polygon;
        polygon << QPoint(0, 0);
        polygon << QPoint(header.width, header.height);
        mBackend->polyLine(mContext, polygon);
    }
#endif

    // Parse all actions and call the appropriate backend callback for
    // the graphics drawing actions.  The context actions will
    // manipulate the graphics context, which is maintained here.
    for (uint action = 0; action < header.actionCount; ++action) {
        quint16  actionType;
        quint16  version;
        quint32  totalSize;

        // Here starts the Action itself. The first two bytes is the action type. 
        mainStream >> actionType;

        // The VersionCompat object
        mainStream >> version;
        mainStream >> totalSize;
        
        char *rawData = new char[totalSize];
        mainStream.readRawData(rawData, totalSize);
        QByteArray dataArray(rawData, totalSize);
        QDataStream stream(&dataArray, QIODevice::ReadOnly);
        stream.setByteOrder(QDataStream::LittleEndian);

        // Debug
#if DEBUG_SVMPARSER
        {
            QString name;
            if (actionType == 0)
                name = actionNames[0].actionName;
            else if (100 <= actionType && actionType <= META_LAST_ACTION)
                name = actionNames[actionType - 99].actionName;
            else if (actionType == 512)
                name = "META_COMMENT_ACTION";
            else
                name = "(out of bounds)";

            debugVectorImage << name << "(" << actionType << ")" << "version" << version
                          << "totalSize" << totalSize;
        }
#endif

        // Parse all actions.
        switch (actionType) {
        case META_NULL_ACTION:
            break;
        case META_PIXEL_ACTION:
            break;
        case META_POINT_ACTION:
            break;
        case META_LINE_ACTION:
            break;
        case META_RECT_ACTION:
            {
                QRect  rect;

                parseRect(stream, rect);
                debugVectorImage << "Rect:"  << rect;
                mBackend->rect(mContext, rect);
            }
            break;
        case META_ROUNDRECT_ACTION:
            break;
        case META_ELLIPSE_ACTION:
            break;
        case META_ARC_ACTION:
            break;
        case META_PIE_ACTION:
            break;
        case META_CHORD_ACTION:
            break;
        case META_POLYLINE_ACTION:
            {
                QPolygon  polygon;

                parsePolygon(stream, polygon);
                debugVectorImage << "Polyline:"  << polygon;
                mBackend->polyLine(mContext, polygon);

                // FIXME: Version 2: Lineinfo, Version 3: polyflags
                if (version > 1)
                    soakBytes(stream, totalSize - 2 - 4 * 2 * polygon.size());
            }
            break;
        case META_POLYGON_ACTION:
            {
                QPolygon  polygon;

                parsePolygon(stream, polygon);
                debugVectorImage << "Polygon:"  << polygon;
                mBackend->polygon(mContext, polygon);

                // FIXME: Version 2: Lineinfo, Version 3: polyflags
                if (version > 1)
                    soakBytes(stream, totalSize - 2 - 4 * 2 * polygon.size());
            }
            break;
        case META_POLYPOLYGON_ACTION:
            {
                quint16 polygonCount;
                stream >> polygonCount;
                //debugVectorImage << "Number of polygons:"  << polygonCount;

                QList<QPolygon> polygons;
                for (quint16 i = 0 ; i < polygonCount ; i++) {
                    QPolygon polygon;
                    parsePolygon(stream, polygon);
                    polygons << polygon;
                    //debugVectorImage << "Polygon:"  << polygon;
                }
                
                if (version > 1) {
                    quint16 complexPolygonCount;
                    stream >> complexPolygonCount;
                    //debugVectorImage << "Number of complex polygons:"  << complexPolygonCount;

                    // Parse the so called "complex polygons". For
                    // each one, there is an index and a polygon.  The
                    // index tells which of the original polygons to
                    // replace.
                    for (quint16 i = 0; i < complexPolygonCount; i++) {
                        quint16 complexPolygonIndex;
                        stream >> complexPolygonIndex;

                        QPolygon polygon;
                        parsePolygon(stream, polygon);
                        //debugVectorImage << "polygon index:"  << complexPolygonIndex << polygon;

                        // FIXME: The so called complex polygons have something to do
                        //        with modifying the polygons, but I have not yet been
                        //        able to understand how.  So until I do, we'll disable
                        //        this.
                        //polygons[complexPolygonIndex] = polygon;
                    }
                }
                
                mBackend->polyPolygon(mContext, polygons);
            }
            break;
        case META_TEXT_ACTION:
            break;
        case META_TEXTARRAY_ACTION:
            {
                QPoint   startPoint;
                QString  string;
                quint16  startIndex;
                quint16  len;
                quint32  dxArrayLen;
                qint32  *dxArray = 0;

                stream >> startPoint;
                parseString(stream, string);
                stream >> startIndex;
                stream >> len;
                stream >> dxArrayLen;
                if (dxArrayLen > 0) {
                    quint32 maxDxArrayLen = totalSize - stream.device()->pos();
                    if (dxArrayLen > maxDxArrayLen) {
                        debugVectorImage << "Defined dxArrayLen= " << dxArrayLen << "exceeds availalable size" << maxDxArrayLen;
                        dxArrayLen = maxDxArrayLen;
                    }

                    dxArray = new qint32[dxArrayLen];

                    for (uint i = 0; i < dxArrayLen; ++i)
                        stream >> dxArray[i];
                }

                if (version > 1) {
                    quint16  len2;

                    stream >> len2;
                    // FIXME: More here
                }

#if 0
                debugVectorImage << "Text: " << startPoint << string
                              << startIndex << len;
                if (dxArrayLen > 0) {
                    debugVectorImage << "dxArrayLen:" << dxArrayLen;
                    for (uint i = 0; i < dxArrayLen; ++i)
                        debugVectorImage << dxArray[i];
                }
                else
                    debugVectorImage << "dxArrayLen = 0";
#endif
                mBackend->textArray(mContext, startPoint, string, startIndex, len,
                                    dxArrayLen, dxArray);

                if (dxArrayLen)
                    delete[] dxArray;
            }
コード例 #24
0
ファイル: storage.cpp プロジェクト: RISK46kaf/Practise
void Storage::paintEvent(QPaintEvent *anEvent)
{
    QLabel::paintEvent(anEvent);

    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    //painter.setRenderHint(QPainter::SmoothPixmapTransform);
    QPen pen;

    if (NoTool != tool_) {
        pen.setWidth(5);
        pen.setColor(QColor(Qt::white));
        pen.setStyle(Qt::DashLine);
        painter.setPen(pen);

        if (BoundingBoxTool == tool_) {
            /* с учётом масштаба */
            QRect bbox = rect.getCoordinates();
            QPoint bboxTopLeft = bbox.topLeft() * scale_;
            QPoint bboxBottomRight = bbox.bottomRight() * scale_;

            bbox.setTopLeft(bboxTopLeft);
            bbox.setBottomRight(bboxBottomRight);

            painter.drawRect(bbox);
        }
        else if (EllipseTool == tool_) {
            /* с учётом масштаба */
            QRect elli = ell.getCoordinates().normalized();
            QPoint ellTopLeft = elli.topLeft() * scale_;
            QPoint ellBottomRight = elli.bottomRight() * scale_;

            elli.setTopLeft(ellTopLeft);
            elli.setBottomRight(ellBottomRight);

            if(1 < elli.height() && 1 < elli.width() )
            {
                painter.drawEllipse(elli);
            }
//            painter.drawRect(ell);
        }
        else if (ArrowTool == tool_) {
            /* с учётом масштаба */
            QLineF line = arrow.getCoordinates();
            QPointF p1 = line.p1() * scale_;
            QPointF p2 = line.p2() * scale_;

            line.setP1(p1);
            line.setP2(p2);

            if(1 < line.length())
            {
                double angle = ::acos(line.dx() / line.length());
                qreal Pi = atan(1)*4;
                if (line.dy() >= 0)
                    angle = (Pi * 2) - angle;

                QPointF arrowP1 = line.p1() + QPointF(sin(angle + Pi / 3) * arrow_size_,
                                                cos(angle + Pi / 3) * arrow_size_);
                QPointF arrowP2 = line.p1() + QPointF(sin(angle + Pi - Pi / 3) * arrow_size_,
                                                cos(angle + Pi - Pi / 3) * arrow_size_);

                QPolygonF arrowTop;
                arrowTop.clear();
                arrowTop << line.p1() << arrowP1 << arrowP2;

                painter.drawLine(line);
                painter.drawPolygon(arrowTop);///111
                qDebug() << "arrowTop" << arrowTop;
                arrow_top_ = arrowTop;
            }

            }
        else if (PolygonTool == tool_) {
            /* с учётом масштаба */
            QPoint point;
            QPolygon pol = poly.getCoordinates();
            for (int i = 0; i < pol.size(); i++) {
                point.setX(pol.at(i).x());
                point.setY(pol.at(i).y());
                point *= scale_;
                pol.remove(i);
                pol.insert(i, point);
            }
            painter.drawPolygon(pol);
        }
    }

    /* рисуем фигуры */
    drawBoundingBoxes(&painter, &pen);
    drawPolygons(&painter, &pen);
    drawEllipses(&painter, &pen);
    drawArrows(&painter, &pen);
}
コード例 #25
0
ファイル: rs_hatch.cpp プロジェクト: rmamba/LibreCAD
/**
 * Overrides drawing of subentities. This is only ever called for solid fills.
 */
void RS_Hatch::draw(RS_Painter* painter, RS_GraphicView* view, double& /*patternOffset*/) {

    if (!data.solid) {
		for(auto se: entities){

            view->drawEntity(painter,se);
        }
        return;
    }

    //area of solid fill. Use polygon approximation, except trivial cases
    QPainterPath path;
    QList<QPolygon> paClosed;
    QPolygon pa;
//    QPolygon jp;   // jump points

    // loops:
    if (needOptimization==true) {
		for(auto l: entities){

            if (l->rtti()==RS2::EntityContainer) {
                RS_EntityContainer* loop = (RS_EntityContainer*)l;

                loop->optimizeContours();
            }
        }
        needOptimization = false;
    }

    // loops:
	for(auto l: entities){
        l->setLayer(getLayer());

        if (l->rtti()==RS2::EntityContainer) {
            RS_EntityContainer* loop = (RS_EntityContainer*)l;

            // edges:
			for(auto e: *loop){

                e->setLayer(getLayer());
                switch (e->rtti()) {
                case RS2::EntityLine: {
                    QPoint pt1(RS_Math::round(view->toGuiX(e->getStartpoint().x)),
                               RS_Math::round(view->toGuiY(e->getStartpoint().y)));
                    QPoint pt2(RS_Math::round(view->toGuiX(e->getEndpoint().x)),
                               RS_Math::round(view->toGuiY(e->getEndpoint().y)));

//                    if (! (pa.size()>0 && (pa.last() - pt1).manhattanLength()<=2)) {
//                        jp<<pt1;
//                    }
                    if(pa.size() && (pa.last()-pt1).manhattanLength()>=1)
                        pa<<pt1;
                    pa<<pt2;
                }
                    break;

                case RS2::EntityArc: {
//                    QPoint pt1(RS_Math::round(view->toGuiX(e->getStartpoint().x)),
//                               RS_Math::round(view->toGuiY(e->getStartpoint().y)));
//                    if (! (pa.size()>0 && (pa.last() - pt1).manhattanLength()<=2)) {
//                        jp<<pt1;
//                    }

                    QPolygon pa2;
                    RS_Arc* arc=static_cast<RS_Arc*>(e);

                    painter->createArc(pa2, view->toGui(arc->getCenter()),
                                       view->toGuiDX(arc->getRadius())
                                       ,arc->getAngle1(),arc->getAngle2(),arc->isReversed());
                    if(pa.size() &&pa2.size()&&(pa.last()-pa2.first()).manhattanLength()<1)
                        pa2.remove(0,1);
                    pa<<pa2;

                }
                    break;

                case RS2::EntityCircle: {
                    RS_Circle* circle = static_cast<RS_Circle*>(e);
//                    QPoint pt1(RS_Math::round(view->toGuiX(circle->getCenter().x+circle->getRadius())),
//                               RS_Math::round(view->toGuiY(circle->getCenter().y)));
//                    if (! (pa.size()>0 && (pa.last() - pt1).manhattanLength()<=2)) {
//                        jp<<pt1;
//                    }

                    RS_Vector c=view->toGui(circle->getCenter());
                    double r=view->toGuiDX(circle->getRadius());
#if QT_VERSION >= 0x040400
                    path.addEllipse(QPoint(c.x,c.y),r,r);
#else
                    path.addEllipse(c.x - r, c.y + r, 2.*r, 2.*r);
//                    QPolygon pa2;
//                    painter->createArc(pa2, view->toGui(circle->getCenter()),
//                                       view->toGuiDX(circle->getRadius()),
//                                       0.0,
//                                       2*M_PI,
//                                       false);
//                    pa<<pa2;
#endif
                }
                    break;
                case RS2::EntityEllipse:
                if(static_cast<RS_Ellipse*>(e)->isArc()) {
                    QPolygon pa2;
                    auto ellipse=static_cast<RS_Ellipse*>(e);

                    painter->createEllipse(pa2,
                                           view->toGui(ellipse->getCenter()),
                                           view->toGuiDX(ellipse->getMajorRadius()),
                                           view->toGuiDX(ellipse->getMinorRadius()),
                                           ellipse->getAngle()
                                           ,ellipse->getAngle1(),ellipse->getAngle2(),ellipse->isReversed()
                                           );
//                    qDebug()<<"ellipse: "<<ellipse->getCenter().x<<","<<ellipse->getCenter().y;
//                    qDebug()<<"ellipse: pa2.size()="<<pa2.size();
//                    qDebug()<<"ellipse: pa2="<<pa2;
                    if(pa.size() && pa2.size()&&(pa.last()-pa2.first()).manhattanLength()<1)
                        pa2.remove(0,1);
                    pa<<pa2;
                }else{
                    QPolygon pa2;
                    auto ellipse=static_cast<RS_Ellipse*>(e);
                    painter->createEllipse(pa2,
                                           view->toGui(ellipse->getCenter()),
                                           view->toGuiDX(ellipse->getMajorRadius()),
                                           view->toGuiDX(ellipse->getMinorRadius()),
                                           ellipse->getAngle(),
                                           ellipse->getAngle1(), ellipse->getAngle2(),
                                           ellipse->isReversed()
                                           );
                    path.addPolygon(pa2);
                }
                    break;
                default:
                    break;
                }
//                qDebug()<<"pa="<<pa;
                if( pa.size()>2 && pa.first() == pa.last()) {
                    paClosed<<pa;
                    pa.clear();
                }

            }

        }
    }
    if(pa.size()>2){
        pa<<pa.first();
        paClosed<<pa;
    }

    for(auto& p:paClosed){
        path.addPolygon(p);
    }

    //bug#474, restore brush after solid fill
    const QBrush brush(painter->brush());
    const RS_Pen pen=painter->getPen();
    painter->setBrush(pen.getColor());
    painter->disablePen();
    painter->drawPath(path);
    painter->setBrush(brush);
    painter->setPen(pen);


}
コード例 #26
0
ファイル: qlcdnumber.cpp プロジェクト: venkatarajasekhar/Qt
static void addPoint(QPolygon &a, const QPoint &p)
{
    uint n = a.size();
    a.resize(n + 1);
    a.setPoint(n, p);
}
コード例 #27
0
ファイル: draw_2D.cpp プロジェクト: Broentech/sdraw
C2DPixmapSegment* CDraw2D::doFill(QPoint pt)
{
   if(!hasRegisteredBuffer())
   {
      return 0;
   }

   QImage img = m_buffer->toImage();
   blankAidBuffer();

   if (!checkGradientPoints())
   {
      return 0;
   }

   

   QPainterPath paintPath;
   QPolygon polygon = algorithm->polygonizeBorder(pt, *m_buffer).toPolygon();
   QRect boundingRect = polygon.boundingRect();

   QPointF normalizedCenter = CDrawSettings_2D::getInstance()->brushSettings().gradientCenterPoint();
   normalizedCenter.setX(normalizedCenter.x() - boundingRect.topLeft().x());
   normalizedCenter.setY(normalizedCenter.y() - boundingRect.topLeft().y());
   if (normalizedCenter.y() < 0)
   {
      normalizedCenter.setY(0);
   }
   if (normalizedCenter.y() > boundingRect.height())
   {
      normalizedCenter.setY(boundingRect.height());
   }
   if (normalizedCenter.x() < 0)
   {
      normalizedCenter.setX(0);
   }
   if (normalizedCenter.x() > boundingRect.width())
   {
      normalizedCenter.setX(boundingRect.width());
   }

   CBrushSettings brs = CDrawSettings_2D::getInstance()->brushSettings();
   brs.setGradientCenter(normalizedCenter);

   QPointF normalizedFocal = CDrawSettings_2D::getInstance()->brushSettings().gradientFocalPoint();
   normalizedFocal.setX(normalizedFocal.x() - boundingRect.topLeft().x());
   normalizedFocal.setY(normalizedFocal.y() - boundingRect.topLeft().y());
   if (normalizedFocal.y() < 0)
   {
      normalizedFocal.setY(0);
   }
   if (normalizedFocal.y() > boundingRect.height())
   {
      normalizedFocal.setY(boundingRect.height());
   }
   if (normalizedFocal.x() < 0)
   {
      normalizedFocal.setX(0);
   }
   if (normalizedFocal.x() > boundingRect.width())
   {
      normalizedFocal.setX(boundingRect.width());
   }

   brs.setGradientFocal(normalizedFocal);
   CDrawSettings_2D::getInstance()->setBrushSettings(brs);

   QPolygon normalizedPolygon = normalizePolygon(polygon, 0);
   if (normalizedPolygon.size() > 1)
   {
      paintPath.addPolygon(normalizedPolygon);
   }
   else
   {
      paintPath.addRect(0, 0, m_buffer->width(), m_buffer->height());
   }
   paintPath.closeSubpath();

   QSize segmentSize(boundingRect.size().width(), boundingRect.size().height());
   QPixmap segmentContent(segmentSize);
   segmentContent.fill(Qt::transparent);
   QPainter segmentPainter(&segmentContent);
   segmentPainter.setRenderHint(QPainter::Antialiasing, _settings.getAntialiasing());

   QBrush brush = CDrawSettings_2D::getInstance()->brushSettings().getBrush();
   QString summ = explainBrush(brush);
   //segmentPainter.fillRect(paintPath.boundingRect(), brush);
   segmentPainter.setPen(CDrawSettings_2D::getInstance()->penSettings().getPen());
   segmentPainter.setBrush(brush);

   segmentPainter.drawPath(paintPath);
   segmentPainter.end();

   //DebugImageDialog DBG(segmentContent);
   //DBG.exec();

   C2DPixmapSegment *segment = new C2DPixmapSegment(&segmentContent, &boundingRect, 1, 0);
   return segment;
}
コード例 #28
0
ファイル: draw_2D.cpp プロジェクト: Broentech/sdraw
C2DPixmapSegment* CDraw2D::createSubpixmapFromPolygon(QPolygon &polygon, EPolygonConversion conv)
{
   if(polygon.size() < 2)
   {
      return 0;
   }

   

   int sizeOffset = qFloor(static_cast<qreal>(CDrawSettings_2D::getInstance()->penSettings().getWidth())/2.);

   // get the polygons relative to its bounding rectangle
   QPolygon normalizedPolygon = normalizePolygon(polygon, sizeOffset);
   QRect boundingRect = polygon.boundingRect();
   QRect normalizedBoundingRect = normalizedPolygon.boundingRect();
   QSize segmentSize(
      boundingRect.size().width() +  2 * sizeOffset + 1, 
      boundingRect.size().height() + 2 * sizeOffset + 1
      );

   // create segment
   QPixmap segmentContent(segmentSize);
   segmentContent.fill(Qt::transparent);
   QPainter segmentPainter(&segmentContent);
   segmentPainter.setPen(CDrawSettings_2D::getInstance()->penSettings().getPen());
   segmentPainter.setRenderHint(QPainter::Antialiasing,_settings.getAntialiasing());
   
   QPoint firstPt;
   QPoint secondPt;
   switch(conv)
   {
   case(NO_CONVERSION):
      segmentPainter.drawPolyline(normalizedPolygon);
      break;

   case(TO_LINES):
      firstPt = normalizedPolygon.at(0);
      for (int i = 1; i<normalizedPolygon.size(); i++)
      {
         secondPt = normalizedPolygon.at(i);
         if(firstPt == secondPt)
         {
            continue;
         }
         segmentPainter.drawLine(firstPt, secondPt);
         firstPt = secondPt;
      }
      break;

   case(TO_RECT):
      segmentPainter.drawRect(normalizedBoundingRect);
      break;

   case(TO_ROUNDED_RECT):
      segmentPainter.drawRoundedRect(
      normalizedBoundingRect,
      CDrawSettings_2D::getInstance()->getRoundedRectRadius_X(),
      CDrawSettings_2D::getInstance()->getRoundedRectRadius_Y()
      );
      break;

   case(TO_ELLIPSE):
      segmentPainter.drawEllipse(normalizedBoundingRect);
      break;

   case(TO_PIE):
      segmentPainter.drawPie(normalizedBoundingRect, alphaDegrees * 16, betaDegrees * 16);
      break;

   case(TO_ARC):
      segmentPainter.drawArc(normalizedBoundingRect, alphaDegrees * 16, betaDegrees * 16);
      break;

   case(TO_CHORD):
      segmentPainter.drawChord(normalizedBoundingRect, alphaDegrees * 16, betaDegrees * 16);
      break;

   default:
      segmentPainter.drawPolyline(normalizedPolygon);
      break;
   }

   segmentPainter.end();

   //DebugImageDialog DBG(segmentContent);
   //DBG.exec();

   C2DPixmapSegment *segment = new C2DPixmapSegment(&segmentContent, &boundingRect, 1, sizeOffset);
   return segment;
}
コード例 #29
0
ファイル: tobarchart.cpp プロジェクト: nguyentienlong/tora
void toBarChart::paintChart(QPainter *p, QRect &rect)
{
    QFontMetrics fm = p->fontMetrics();

    if (!Zooming)
    {
        if (MinAuto)
        {
            bool first = true;
            std::list<std::list<double> >::reverse_iterator i = Values.rbegin();
            if (i != Values.rend())
            {
                for (std::list<double>::iterator j = (*i).begin(); j != (*i).end(); j++)
                {
                    if (first)
                    {
                        first = false;
                        zMinValue = *j;
                    }
                    else if (zMinValue > *j)
                        zMinValue = *j;
                }
            }
        }
        if (MaxAuto)
        {
            bool first = true;
            std::list<double> total;
            std::list<bool>::iterator e = Enabled.begin();
            {
                for (std::list<std::list<double> >::iterator i = Values.begin(); i != Values.end(); i++)
                {
                    std::list<double>::iterator k = total.begin();
                    if (e == Enabled.end() || *e)
                    {
                        for (std::list<double>::iterator j = (*i).begin(); j != (*i).end(); j++)
                        {
                            if (k == total.end())
                            {
                                total.insert(total.end(), *j);
                                k = total.end();
                            }
                            else
                            {
                                *k += *j;
                                k++;
                            }
                        }
                    }
                    if (e != Enabled.end())
                        e++;
                }
            }
            for (std::list<double>::iterator i = total.begin(); i != total.end(); i++)
            {
                if (first)
                {
                    first = false;
                    zMaxValue = *i;
                }
                else if (zMaxValue < *i)
                    zMaxValue = *i;
            }
        }
        if (!MinAuto)
            zMinValue = MinValue;
        else
        {
            zMinValue = round(zMinValue, false);
            MinValue = zMinValue;
        }
        if (!MaxAuto)
            zMaxValue = MaxValue;
        else
        {
            zMaxValue = round(zMaxValue, true);
            MaxValue = zMaxValue;
        }
    }

    paintTitle(p, rect);
    paintLegend(p, rect);
    paintAxis(p, rect);

    std::list<QPolygon> Points;
    int cp = 0;
    int samples = countSamples();
    int zeroy = int(rect.height() - 2 - ( -zMinValue / (zMaxValue - zMinValue) * (rect.height() - 4)));
    if (samples > 1)
    {
        const QMatrix &mtx = p->worldMatrix();
        p->setClipRect(int(mtx.dx() + 2), int(mtx.dy() + 2), rect.width() - 3, rect.height() - 3);
        if (Zooming)
            p->drawText(2, 2, rect.width() - 4, rect.height() - 4,
                        Qt::AlignLeft | Qt::AlignTop, tr("Zoom"));
        std::list<bool>::reverse_iterator e = Enabled.rbegin();
        for (std::list<std::list<double> >::reverse_iterator i = Values.rbegin(); i != Values.rend(); i++)
        {
            if (e == Enabled.rend() || *e)
            {
                std::list<double> &val = *i;
                int count = 0;
                int skip = SkipSamples;
                QPolygon a(samples + 10);
                int x = rect.width() - 2;
                for (std::list<double>::reverse_iterator j = val.rbegin(); j != val.rend() && x >=
                        2;
                        j++)
                {
                    if (skip > 0)
                        skip--;
                    else
                    {
                        int val = int(rect.height() - 2 - ((*j - zMinValue) / (zMaxValue - zMinValue) * (rect.height() - 4)));
                        x = rect.width() - 2 - count * (rect.width() - 4) / (samples - 1);
                        a.setPoint(count, x, val);
                        count++;
                        if (count >= samples)
                            break;
                    }
                }
                a.resize(count * 2);
                Points.insert(Points.end(), a);
            }
            cp++;
            if (e != Enabled.rend())
                e++;
        }
    }

    std::map<int, int> Bottom;
    std::list<bool>::reverse_iterator e = Enabled.rbegin();
    for (std::list<QPolygon>::iterator i = Points.begin(); i != Points.end();)
    {
        while (e != Enabled.rend() && !*e)
        {
            cp--;
            e++;
        }
        if (e != Enabled.rend())
            e++;
        cp--;

        QPolygon a = *i;
        int lx = 0;
        int lb = 0;
        for (int j = 0; j < a.size() / 2; j++)
        {
            int x, y;
            a.point(j, &x, &y);
            if (Bottom.find(x) == Bottom.end())
                Bottom[x] = 0;
            if (lx != x)
                lb = Bottom[x];
            a.setPoint(a.size() - 1 - j, x, zeroy - lb);
            y -= lb;
            a.setPoint(j, x, y);
            Bottom[x] = zeroy - y;
            lx = x;
        }

        p->save();
        QBrush brush(Utils::toChartBrush(cp));
        p->setBrush(brush.color());
        p->drawPolygon(a);
        if (brush.style() != Qt::SolidPattern)
        {
            p->setBrush(QBrush(Qt::white, brush.style()));
            p->drawPolygon(a);
        }
        p->restore();
        i++;
    }
}
コード例 #30
0
ファイル: rs_hatch.cpp プロジェクト: dvstrom/LibreCAD
/**
 * Overrides drawing of subentities. This is only ever called for solid fills.
 */
void RS_Hatch::draw(RS_Painter* painter, RS_GraphicView* view, double& /*patternOffset*/) {

    if (!data.solid) {
        for (RS_Entity* se=firstEntity();
                se!=NULL;
                se = nextEntity()) {

            view->drawEntity(painter,se);
        }
        return;
    }

    QPainterPath path;
    QList<QPolygon> paClosed;
    QPolygon pa;
//    QPolygon jp;   // jump points

    // loops:
    if (needOptimization==true) {
        for (RS_Entity* l=firstEntity(RS2::ResolveNone);
                l!=NULL;
                l=nextEntity(RS2::ResolveNone)) {

            if (l->rtti()==RS2::EntityContainer) {
                RS_EntityContainer* loop = (RS_EntityContainer*)l;

                loop->optimizeContours();
            }
        }
        needOptimization = false;
    }

    // loops:
    for (RS_Entity* l=firstEntity(RS2::ResolveNone);
         l!=NULL;
         l=nextEntity(RS2::ResolveNone)) {

        l->setLayer(getLayer());

        if (l->rtti()==RS2::EntityContainer) {
            RS_EntityContainer* loop = (RS_EntityContainer*)l;

            // edges:
            for (RS_Entity* e=loop->firstEntity(RS2::ResolveNone);
                 e!=NULL;
                 e=loop->nextEntity(RS2::ResolveNone)) {

                e->setLayer(getLayer());
                switch (e->rtti()) {
                case RS2::EntityLine: {
                    QPoint pt1(RS_Math::round(view->toGuiX(e->getStartpoint().x)),
                               RS_Math::round(view->toGuiY(e->getStartpoint().y)));
                    QPoint pt2(RS_Math::round(view->toGuiX(e->getEndpoint().x)),
                               RS_Math::round(view->toGuiY(e->getEndpoint().y)));

//                    if (! (pa.size()>0 && (pa.last() - pt1).manhattanLength()<=2)) {
//                        jp<<pt1;
//                    }

                    pa<<pt1<<pt2;
                }
                    break;

                case RS2::EntityArc: {
//                    QPoint pt1(RS_Math::round(view->toGuiX(e->getStartpoint().x)),
//                               RS_Math::round(view->toGuiY(e->getStartpoint().y)));
//                    if (! (pa.size()>0 && (pa.last() - pt1).manhattanLength()<=2)) {
//                        jp<<pt1;
//                    }

                    QPolygon pa2;
                    RS_Arc* arc=static_cast<RS_Arc*>(e);
                    painter->createArc(pa2, view->toGui(arc->getCenter()),
                                       view->toGuiDX(arc->getRadius()),
                                       arc->getAngle1(),
                                       arc->getAngle2(),
                                       arc->isReversed());
                    pa<<pa2;

                }
                    break;

                case RS2::EntityCircle: {
                    RS_Circle* circle = static_cast<RS_Circle*>(e);
//                    QPoint pt1(RS_Math::round(view->toGuiX(circle->getCenter().x+circle->getRadius())),
//                               RS_Math::round(view->toGuiY(circle->getCenter().y)));
//                    if (! (pa.size()>0 && (pa.last() - pt1).manhattanLength()<=2)) {
//                        jp<<pt1;
//                    }

                    RS_Vector c=view->toGui(circle->getCenter());
                    double r=view->toGuiDX(circle->getRadius());
#if QT_VERSION >= 0x040400
                    path.addEllipse(QPoint(c.x,c.y),r,r);
#else
                    path.addEllipse(c.x - r, c.y + r, 2.*r, 2.*r);
//                    QPolygon pa2;
//                    painter->createArc(pa2, view->toGui(circle->getCenter()),
//                                       view->toGuiDX(circle->getRadius()),
//                                       0.0,
//                                       2*M_PI,
//                                       false);
//                    pa<<pa2;
#endif
                }
                    break;
                case RS2::EntityEllipse:
                if(static_cast<RS_Ellipse*>(e)->isArc()) {
                    QPolygon pa2;
                    auto ellipse=static_cast<RS_Ellipse*>(e);
                    painter->createEllipse(pa2,
                                           view->toGui(ellipse->getCenter()),
                                           view->toGuiDX(ellipse->getMajorRadius()),
                                           view->toGuiDX(ellipse->getMinorRadius()),
                                           ellipse->getAngle(),
                                           ellipse->getAngle1(), ellipse->getAngle2(),
                                           ellipse->isReversed()
                                           );
                    pa<<pa2;
                }else{
                    QPolygon pa2;
                    auto ellipse=static_cast<RS_Ellipse*>(e);
                    painter->createEllipse(pa2,
                                           view->toGui(ellipse->getCenter()),
                                           view->toGuiDX(ellipse->getMajorRadius()),
                                           view->toGuiDX(ellipse->getMinorRadius()),
                                           ellipse->getAngle(),
                                           ellipse->getAngle1(), ellipse->getAngle2(),
                                           ellipse->isReversed()
                                           );
                    path.addPolygon(pa2);
                }
                    break;
                default:
                    break;
                }
                if( pa.size()>2 && pa.first() == pa.last()) {
                    paClosed<<pa;
                    pa.clear();
                }

            }

        }
    }
    if(pa.size()>2){
        pa<<pa.first();
        paClosed<<pa;
    }
    for(int i=0;i<paClosed.size();i++){
        path.addPolygon(paClosed.at(i));
    }
        painter->setBrush(painter->getPen().getColor());
        painter->disablePen();
        painter->drawPath(path);

//    pa<<jp;

//    painter->setBrush(painter->getPen().getColor());
//    painter->disablePen();
//    painter->drawPolygon(pa);

}