QString Ruler::retrieveSvg(ViewLayer::ViewLayerID viewLayerID, QHash<QString, QString> & svgHash, bool blackOnly, double dpi) { double w = TextUtils::convertToInches(m_modelPart->prop("width").toString()); if (w != 0) { QString xml; switch (viewLayerID) { case ViewLayer::BreadboardRuler: case ViewLayer::SchematicRuler: case ViewLayer::PcbRuler: xml = makeSvg(w); break; default: break; } if (!xml.isEmpty()) { QString xmlName = ViewLayer::viewLayerXmlNameFromID(viewLayerID); SvgFileSplitter splitter; bool result = splitter.splitString(xml, xmlName); if (!result) { return ""; } result = splitter.normalize(dpi, xmlName, blackOnly); if (!result) { return ""; } return splitter.elementString(xmlName); } } return PaletteItemBase::retrieveSvg(viewLayerID, svgHash, blackOnly, dpi); }
QString X2Svg::offsetMin(const QString & svg) { if (m_minX == 0 && m_minY == 0) return svg; QString errorStr; int errorLine; int errorColumn; QDomDocument domDocument; if (!domDocument.setContent(svg, true, &errorStr, &errorLine, &errorColumn)) { throw QObject::tr("failure in svg conversion 1: %1 %2 %3").arg(errorStr).arg(errorLine).arg(errorColumn); } QDomElement root = domDocument.documentElement(); if (root.isNull()) { throw QObject::tr("failure in svg conversion 2: %1 %2 %3").arg(errorStr).arg(errorLine).arg(errorColumn); } SvgFileSplitter splitter; splitter.shiftChild(root, -m_minX, -m_minY, true); return TextUtils::removeXMLEntities(domDocument.toString()); }
QString Resistor::retrieveSvg(ViewLayer::ViewLayerID viewLayerID, QHash<QString, QString> & svgHash, bool blackOnly, double dpi) { switch (viewLayerID) { case ViewLayer::Breadboard: case ViewLayer::Icon: break; default: return Capacitor::retrieveSvg(viewLayerID, svgHash, blackOnly, dpi); } QString svg = makeSvg(m_ohms, viewLayerID); QString xmlName = ViewLayer::viewLayerXmlNameFromID(viewLayerID); SvgFileSplitter splitter; bool result = splitter.splitString(svg, xmlName); if (!result) { return ""; } result = splitter.normalize(dpi, xmlName, blackOnly); if (!result) { return ""; } return splitter.elementString(xmlName); }