void RenderTreeAsText::writeLayers(TextStream& ts, const RenderLayer* rootLayer, RenderLayer* layer, const LayoutRect& paintRect, int indent, RenderAsTextBehavior behavior) { // FIXME: Apply overflow to the root layer to not break every test. Complete hack. Sigh. LayoutRect paintDirtyRect(paintRect); if (rootLayer == layer) { paintDirtyRect.setWidth(max<LayoutUnit>(paintDirtyRect.width(), rootLayer->renderer()->layoutOverflowRect().maxX())); paintDirtyRect.setHeight(max<LayoutUnit>(paintDirtyRect.height(), rootLayer->renderer()->layoutOverflowRect().maxY())); } // Calculate the clip rects we should use. LayoutRect layerBounds; ClipRect damageRect; layer->clipper().calculateRects(ClipRectsContext(rootLayer, UncachedClipRects), paintDirtyRect, layerBounds, damageRect); // FIXME: Apply overflow to the root layer to not break every test. Complete hack. Sigh. if (rootLayer == layer) layerBounds.setSize(layer->size().expandedTo(pixelSnappedIntSize(layer->renderer()->maxLayoutOverflow(), LayoutPoint(0, 0)))); // Ensure our lists are up-to-date. layer->stackingNode()->updateLayerListsIfNeeded(); bool shouldPaint = (behavior & RenderAsTextShowAllLayers) ? true : layer->intersectsDamageRect(layerBounds, damageRect.rect(), rootLayer); if (shouldPaint) write(ts, *layer, layerBounds, damageRect.rect(), indent, behavior); if (Vector<RenderLayerStackingNode*>* normalFlowList = layer->stackingNode()->normalFlowList()) { int currIndent = indent; if (behavior & RenderAsTextShowLayerNesting) { writeIndent(ts, indent); ts << " normal flow list(" << normalFlowList->size() << ")\n"; ++currIndent; } for (unsigned i = 0; i != normalFlowList->size(); ++i) writeLayers(ts, rootLayer, normalFlowList->at(i)->layer(), paintDirtyRect, currIndent, behavior); } if (Vector<RenderLayerStackingNode*>* posList = layer->stackingNode()->zOrderList()) { int currIndent = indent; if (behavior & RenderAsTextShowLayerNesting) { writeIndent(ts, indent); ts << " positive z-order list(" << posList->size() << ")\n"; ++currIndent; } for (unsigned i = 0; i != posList->size(); ++i) writeLayers(ts, rootLayer, posList->at(i)->layer(), paintDirtyRect, currIndent, behavior); } }
void LC_MakerCamSVG::writeInsert(RS_Insert* insert) { RS_Block* block = insert->getBlockForInsert(); RS_Vector insertionpoint = convertToSvg(insert->getInsertionPoint()); if (writeBlocksInline) { RS_DEBUG->print("RS_MakerCamSVG::writeInsert: Writing insert inline ..."); offset.set(insertionpoint.x, insertionpoint.y - (max.y - min.y)); xmlWriter->addElement("g", NAMESPACE_URI_SVG); xmlWriter->addAttribute("blockname", qPrintable(block->getName()), NAMESPACE_URI_LC); writeLayers(block); xmlWriter->closeElement(); offset.set(0, 0); } else { RS_DEBUG->print("RS_MakerCamSVG::writeInsert: Writing insert as reference to block ..."); xmlWriter->addElement("use", NAMESPACE_URI_SVG); xmlWriter->addAttribute("x", numXml(insertionpoint.x)); xmlWriter->addAttribute("y", numXml(insertionpoint.y - (max.y - min.y))); xmlWriter->addAttribute("href", "#" + std::to_string(block->getId()), NAMESPACE_URI_XLINK); xmlWriter->closeElement(); } }
void LC_MakerCamSVG::writeBlock(RS_Block* block) { RS_DEBUG->print("RS_MakerCamSVG::writeBlock: Writing block with name '%s'", qPrintable(block->getName())); xmlWriter->addElement("g", NAMESPACE_URI_SVG); xmlWriter->addAttribute("id", std::to_string(block->getId())); xmlWriter->addAttribute("blockname", qPrintable(block->getName()), NAMESPACE_URI_LC); writeLayers(block); xmlWriter->closeElement(); }
void tDxfExport2::func(QString fName, tModel* m) { DL_Codes::version exportVersion = DL_Codes::AC1015; dw = dxf.out(fName.toStdString().data(), exportVersion); if (dw==NULL) { printf("Cannot open file 'myfile.dxf' for writing."); // abort function e.g. with return } //Prepare: writeHeader(); dw->sectionTables(); {//Initial Tables //a standard viewport dxf.writeVPort(*dw); //the linetypes writeDefaultLineTypes(); //all our jr-Layers writeLayers(m); writeDefaultTables(); writeDimentsions(); //Declare Blocks dxf.writeBlockRecord(*dw); //if there are further blocks in future... //dxf.writeBlockRecord(*dw, "myblock2"); dw->tableEnd(); } //Write Blocks dw->sectionBlocks(); writeDefaultBlocks(); // The Entities: writeEntities(m); //Finalize: dxf.writeObjects(*dw); dxf.writeObjectsEnd(*dw); dw->dxfEOF(); dw->close(); delete dw; }
void LC_MakerCamSVG::write(RS_Graphic* graphic) { RS_DEBUG->print("RS_MakerCamSVG::write: Writing root node ..."); graphic->calculateBorders(); min = graphic->getMin(); max = graphic->getMax(); RS2::Unit raw_unit = graphic->getUnit(); switch (raw_unit) { case RS2::Millimeter: unit = "mm"; break; case RS2::Centimeter: unit = "cm"; break; case RS2::Inch: unit = "in"; break; default: unit = ""; break; } xmlWriter->createRootElement("svg", NAMESPACE_URI_SVG); xmlWriter->addNamespaceDeclaration("lc", NAMESPACE_URI_LC); xmlWriter->addNamespaceDeclaration("xlink", NAMESPACE_URI_XLINK); xmlWriter->addAttribute("width", numXml(max.x - min.x) + unit); xmlWriter->addAttribute("height", numXml(max.y - min.y) + unit); xmlWriter->addAttribute("viewBox", "0 0 "+ numXml(max.x - min.x) + " " + numXml(max.y - min.y)); writeBlocks(graphic); writeLayers(graphic); }
void LC_MakerCamSVG::write(RS_Graphic* graphic) { RS_DEBUG->print("RS_MakerCamSVG::write: Writing root node ..."); graphic->calculateBorders(); min = graphic->getMin(); max = graphic->getMax(); RS2::Unit raw_unit = graphic->getUnit(); lengthFactor=1.; switch (raw_unit) { case RS2::Centimeter: unit = "cm"; break; case RS2::Inch: unit = "in"; break; default: lengthFactor=RS_Units::convert(1., raw_unit, RS2::Millimeter); //do not break here, default will use mm and convert length to mm case RS2::Millimeter: unit = "mm"; break; } xmlWriter->createRootElement("svg", NAMESPACE_URI_SVG); xmlWriter->addNamespaceDeclaration("lc", NAMESPACE_URI_LC); xmlWriter->addNamespaceDeclaration("xlink", NAMESPACE_URI_XLINK); xmlWriter->addAttribute("width", lengthXml(max.x - min.x) + unit); xmlWriter->addAttribute("height", lengthXml(max.y - min.y) + unit); xmlWriter->addAttribute("viewBox", "0 0 "+ lengthXml(max.x - min.x) + " " + lengthXml(max.y - min.y)); writeBlocks(graphic); writeLayers(graphic); }
String externalRepresentation(Frame* frame, RenderAsTextBehavior behavior) { PrintContext printContext(frame); if (behavior & RenderAsTextPrintingMode) { if (!frame->contentRenderer()) return String(); printContext.begin(frame->contentRenderer()->width()); } if (!(behavior & RenderAsTextDontUpdateLayout)) frame->document()->updateLayout(); RenderObject* o = frame->contentRenderer(); if (!o) return String(); TextStream ts; if (o->hasLayer()) { RenderLayer* l = toRenderBox(o)->layer(); writeLayers(ts, l, l, IntRect(l->x(), l->y(), l->width(), l->height()), 0, behavior); writeSelection(ts, o); } return ts.release(); }
static void writeLayers(TextStream& ts, const RenderLayer* rootLayer, RenderLayer* l, const IntRect& paintRect, int indent, RenderAsTextBehavior behavior) { // FIXME: Apply overflow to the root layer to not break every test. Complete hack. Sigh. IntRect paintDirtyRect(paintRect); if (rootLayer == l) { paintDirtyRect.setWidth(max(paintDirtyRect.width(), rootLayer->renderBox()->maxXLayoutOverflow())); paintDirtyRect.setHeight(max(paintDirtyRect.height(), rootLayer->renderBox()->maxYLayoutOverflow())); l->setWidth(max(l->width(), l->renderBox()->maxXLayoutOverflow())); l->setHeight(max(l->height(), l->renderBox()->maxYLayoutOverflow())); } // Calculate the clip rects we should use. IntRect layerBounds, damageRect, clipRectToApply, outlineRect; l->calculateRects(rootLayer, paintDirtyRect, layerBounds, damageRect, clipRectToApply, outlineRect, true); // Ensure our lists are up-to-date. l->updateZOrderLists(); l->updateNormalFlowList(); bool shouldPaint = (behavior & RenderAsTextShowAllLayers) ? true : l->intersectsDamageRect(layerBounds, damageRect, rootLayer); Vector<RenderLayer*>* negList = l->negZOrderList(); bool paintsBackgroundSeparately = negList && negList->size() > 0; if (shouldPaint && paintsBackgroundSeparately) write(ts, *l, layerBounds, damageRect, clipRectToApply, outlineRect, LayerPaintPhaseBackground, indent, behavior); if (negList) { int currIndent = indent; if (behavior & RenderAsTextShowLayerNesting) { writeIndent(ts, indent); ts << " negative z-order list(" << negList->size() << ")\n"; ++currIndent; } for (unsigned i = 0; i != negList->size(); ++i) writeLayers(ts, rootLayer, negList->at(i), paintDirtyRect, currIndent, behavior); } if (shouldPaint) write(ts, *l, layerBounds, damageRect, clipRectToApply, outlineRect, paintsBackgroundSeparately ? LayerPaintPhaseForeground : LayerPaintPhaseAll, indent, behavior); if (Vector<RenderLayer*>* normalFlowList = l->normalFlowList()) { int currIndent = indent; if (behavior & RenderAsTextShowLayerNesting) { writeIndent(ts, indent); ts << " normal flow list(" << normalFlowList->size() << ")\n"; ++currIndent; } for (unsigned i = 0; i != normalFlowList->size(); ++i) writeLayers(ts, rootLayer, normalFlowList->at(i), paintDirtyRect, currIndent, behavior); } if (Vector<RenderLayer*>* posList = l->posZOrderList()) { int currIndent = indent; if (behavior & RenderAsTextShowLayerNesting) { writeIndent(ts, indent); ts << " positive z-order list(" << posList->size() << ")\n"; ++currIndent; } for (unsigned i = 0; i != posList->size(); ++i) writeLayers(ts, rootLayer, posList->at(i), paintDirtyRect, currIndent, behavior); } }
void write(TextStream& ts, const RenderObject& o, int indent, RenderAsTextBehavior behavior) { #if ENABLE(SVG) if (o.isSVGPath()) { write(ts, *toRenderSVGPath(&o), indent); return; } if (o.isSVGGradientStop()) { writeSVGGradientStop(ts, *toRenderSVGGradientStop(&o), indent); return; } if (o.isSVGResourceContainer()) { writeSVGResourceContainer(ts, o, indent); return; } if (o.isSVGContainer()) { writeSVGContainer(ts, o, indent); return; } if (o.isSVGRoot()) { write(ts, *toRenderSVGRoot(&o), indent); return; } if (o.isSVGText()) { writeSVGText(ts, *toRenderBlock(&o), indent); return; } if (o.isSVGInlineText()) { writeSVGInlineText(ts, *toRenderText(&o), indent); return; } if (o.isSVGImage()) { writeSVGImage(ts, *toRenderSVGImage(&o), indent); return; } #endif writeIndent(ts, indent); RenderTreeAsText::writeRenderObject(ts, o, behavior); ts << "\n"; if (o.isText() && !o.isBR()) { const RenderText& text = *toRenderText(&o); for (InlineTextBox* box = text.firstTextBox(); box; box = box->nextTextBox()) { writeIndent(ts, indent + 1); writeTextRun(ts, text, *box); } } for (RenderObject* child = o.firstChild(); child; child = child->nextSibling()) { if (child->hasLayer()) continue; write(ts, *child, indent + 1, behavior); } if (o.isWidget()) { Widget* widget = toRenderWidget(&o)->widget(); if (widget && widget->isFrameView()) { FrameView* view = static_cast<FrameView*>(widget); RenderView* root = view->frame()->contentRenderer(); if (root) { view->layout(); RenderLayer* l = root->layer(); if (l) writeLayers(ts, l, l, IntRect(l->x(), l->y(), l->width(), l->height()), indent + 1, behavior); } } } }