void SdfRenderer::draw_text(QDomElement &element) { parsestyle(element); pen.setStyle(Qt::SolidLine); painter->setPen(pen); float x1 = x1_def(element); float y1 = y1_def(element); QString str = element.text(); // delete "\n" from the beginning of the string if (str[0] == '\n') str.remove(0, 1); // delete "\n" from the end of the string if (str[str.length() - 1] == '\n') str.remove(str.length() - 1, 1); while (str.contains('\n')) { int i = str.indexOf('\n'); QString temp = str.left(i); str.remove(0, i + 1); painter->drawText(static_cast<int>(x1), static_cast<int>(y1), temp); y1 += painter->font().pixelSize() ; } QPointF point(x1, y1); painter->drawText(point, str); defaultstyle(); }
void SdfRenderer::background(QDomElement &element) { parsestyle(element); painter->setPen(brush.color()); painter->drawRect(painter->window()); defaultstyle(); }
void SdfRenderer::point(QDomElement &element) { parsestyle(element); float x = x1_def(element); float y = y1_def(element); QPointF pointf(x,y); painter->drawLine(QPointF(pointf.x()-0.1, pointf.y()-0.1), QPointF(pointf.x()+0.1, pointf.y()+0.1)); defaultstyle(); }
void SdfRenderer::rectangle(QDomElement &element) { float x1 = x1_def(element); float y1 = y1_def(element); float x2 = x2_def(element); float y2 = y2_def(element); QRectF rect; rect.adjust(x1, y1, x2, y2); parsestyle(element); painter->drawRect(rect); defaultstyle(); }
void SdfRenderer::polygon(QDomElement &element) { parsestyle(element); // FIXME: init points array here QPoint *points = NULL; int n = element.attribute("n").toInt(); if (!element.isNull()) { points = getpoints(element, n); } if (points != NULL) { // painter->drawConvexPolygon(points, n); delete[] points; } defaultstyle(); }