Exemplo n.º 1
0
QPair<QDomElement, Item::DomElementTypes> Curve::generateItem(QDomDocument &document, QPoint const &topLeftPicture)
{
	QDomElement curve = setPenBrushToDoc(document, "curve");

	qreal const x1 = scenePos().x() + mX1 - topLeftPicture.x();
	qreal const y1 = scenePos().y() + mY1- topLeftPicture.y();
	qreal const x2 = scenePos().x() + mX2 - topLeftPicture.x();
	qreal const y2 = scenePos().y() + mY2 - topLeftPicture.y();
	qreal const x3 = scenePos().x() + mC1.x() - topLeftPicture.x();
	qreal const y3 = scenePos().y() + mC1.y() - topLeftPicture.y();

	QDomElement start  = document.createElement("start");
	curve.appendChild(start);
	start.setAttribute("starty", y1);
	start.setAttribute("startx", x1);

	QDomElement end  = document.createElement("end");
	curve.appendChild(end);
	end.setAttribute("endy", y2);
	end.setAttribute("endx", x2);

	QDomElement ctrl  = document.createElement("ctrl");
	curve.appendChild(ctrl);
	ctrl.setAttribute("y", y3);
	ctrl.setAttribute("x", x3);

	return QPair<QDomElement, Item::DomElementTypes>(curve, mDomElementType);
}
Exemplo n.º 2
0
QPair<QDomElement, Item::DomElementTypes> Rectangle::generateItem(QDomDocument &document, QPoint const &topLeftPicture)
{
	QDomElement rectangle = setPenBrushToDoc(document, "rectangle");
	setXandY(rectangle, sceneBoundingRectCoord(topLeftPicture));

	return QPair<QDomElement, Item::DomElementTypes>(rectangle, mDomElementType);
}
Exemplo n.º 3
0
QPair<QDomElement, Item::DomElementTypes> Ellipse::generateItem(QDomDocument &document, QPointF const &topLeftPicture)
{
	QDomElement ellipse = setPenBrushToDoc(document, "ellipse");
	setXandY(ellipse, sceneBoundingRectCoord(topLeftPicture));

	return QPair<QDomElement, Item::DomElementTypes>(ellipse, mDomElementType);
}
Exemplo n.º 4
0
Arquivo: line.cpp Projeto: nfrey/qreal
QPair<QDomElement, Item::DomElementTypes> Line::generateItem(QDomDocument &document, QPointF const &topLeftPicture)
{
    qreal const x1 = scenePos().x() + line().x1() - topLeftPicture.x();
    qreal const y1 = scenePos().y() + line().y1() - topLeftPicture.y();
    qreal const x2 = scenePos().x() + line().x2() - topLeftPicture.x();
    qreal const y2 = scenePos().y() + line().y2() - topLeftPicture.y();

    QDomElement line = setPenBrushToDoc(document, "line");
    setXandY(line, QRectF(x1, y1, x2 - x1, y2 - y1));

    return QPair<QDomElement, Item::DomElementTypes>(line, mDomElementType);
}
Exemplo n.º 5
0
QPair<QDomElement, Item::DomElementTypes> Path::generateItem(QDomDocument &document, QPoint const &topLeftPicture)
{

	QDomElement path = setPenBrushToDoc(document, "path");

	int count = mPath.elementCount();
	QPainterPath::Element elem;
	path.setAttribute("int", count);

	QString text = "";
	for (int i = 0; i < count; ++i)
	{
		elem = mPath.elementAt(i);
		if (elem.type == QPainterPath::LineToElement)
		{
			text += " L ";
			text += QString::number(static_cast<float>(elem.x) + scenePos().x() - topLeftPicture.x());
			text += " ";
			text += QString::number(static_cast<float>(elem.y) + scenePos().y() - topLeftPicture.y());
		}
		else if (elem.type == QPainterPath::CurveToElement) {
			text += " C ";
			text += QString::number(static_cast<float>(elem.x) + scenePos().x() - topLeftPicture.x());
			text += " ";
			text += QString::number(static_cast<float>(elem.y) + scenePos().y() - topLeftPicture.y());
		}
		else if (elem.type == QPainterPath::MoveToElement)
		{
			text += " M ";
			text += QString::number(static_cast<float>(elem.x) + scenePos().x() - topLeftPicture.x());
			text += " ";
			text += QString::number(static_cast<float>(elem.y) + scenePos().y() - topLeftPicture.y());
		}
		else if (elem.type == QPainterPath::CurveToDataElement)
		{
			text += " ";
			text += QString::number(static_cast<float>(elem.x) + scenePos().x() - topLeftPicture.x());
			text += " ";
			text += QString::number(static_cast<float>(elem.y) + scenePos().y() - topLeftPicture.y());
		}
	}
	path.setAttribute("d", text);

	return QPair<QDomElement, Item::DomElementTypes>(path, mDomElementType);
}