void LC_MakerCamSVG::writeEntity(RS_Entity* entity) { RS_DEBUG->print("RS_MakerCamSVG::writeEntity: Found entity ..."); switch (entity->rtti()) { case RS2::EntityInsert: writeInsert((RS_Insert*)entity); break; case RS2::EntityPoint: writePoint((RS_Point*)entity); break; case RS2::EntityLine: writeLine((RS_Line*)entity); break; case RS2::EntityPolyline: writePolyline((RS_Polyline*)entity); break; case RS2::EntityCircle: writeCircle((RS_Circle*)entity); break; case RS2::EntityArc: writeArc((RS_Arc*)entity); break; case RS2::EntityEllipse: writeEllipse((RS_Ellipse*)entity); break; default: RS_DEBUG->print("RS_MakerCamSVG::writeEntity: Entity with type '%d' not yet implemented", (int)entity->rtti()); break; } }
void QgsDxfExport::writeLine( const QgsPoint& pt1, const QgsPoint& pt2, const QString& layer, const QString& lineStyleName, int color, double width ) { QgsPolyline line( 2 ); line[0] = pt1; line[1] = pt2; writePolyline( line, layer, lineStyleName, color, width, false ); }
/** writes a surface value. */ void iom_file::writeSurface(XmlWriter &out, IomObject &obj) { /* object: MULTISURFACE [INCOMPLETE] surface // if incomplete; multi surface values object: SURFACE boundary object: BOUNDARY polyline object: POLYLINE <SURFACE> <BOUNDARY> <POLYLINE .../> <POLYLINE .../> </BOUNDARY> <BOUNDARY> <POLYLINE .../> <POLYLINE .../> </BOUNDARY> </SURFACE> */ out.startElement(tags::get_SURFACE(),0,0); bool clipped=obj->getConsistency()==IOM_INCOMPLETE; for(int surfacei=0;surfacei<obj->getAttrValueCount(tags::get_surface());surfacei++){ if(clipped){ out.startElement(tags::get_CLIPPED(),0,0); }else{ // an unclipped surface should have only one surface element if(surfacei>0){ iom_issueerr("unclipped surface with multi 'surface' elements"); break; } } IomObject surface=obj->getAttrObj(tags::get_surface(),surfacei); for(int boundaryi=0;boundaryi<surface->getAttrValueCount(tags::get_boundary());boundaryi++){ IomObject boundary=surface->getAttrObj(tags::get_boundary(),boundaryi); out.startElement(tags::get_BOUNDARY(),0,0); for(int polylinei=0;polylinei<boundary->getAttrValueCount(tags::get_polyline());polylinei++){ IomObject polyline=boundary->getAttrObj(tags::get_polyline(),polylinei); writePolyline(out,polyline,true); } out.endElement(/*BOUNDARY*/); } if(clipped){ out.endElement(/*CLIPPED*/); } } out.endElement(/*SURFACE*/); }
void QgsDxfExport::addFeature( const QgsSymbolV2RenderContext& ctx, const QString& layer, const QgsSymbolLayerV2* symbolLayer, const QgsSymbolV2* symbol ) { const QgsFeature* fet = ctx.feature(); if ( !fet ) { return; } QgsGeometry* geom = fet->geometry(); if ( geom ) { int c = 0; if ( mSymbologyExport != NoSymbology ) { c = colorFromSymbolLayer( symbolLayer, ctx ); } double width = -1; if ( mSymbologyExport != NoSymbology && symbolLayer ) { width = symbolLayer->dxfWidth( *this, ctx ); } QString lineStyleName = "CONTINUOUS"; if ( mSymbologyExport != NoSymbology ) { lineStyleName = lineStyleFromSymbolLayer( symbolLayer ); } QGis::WkbType geometryType = geom->wkbType(); //single point if ( geometryType == QGis::WKBPoint || geometryType == QGis::WKBPoint25D ) { writePoint( geom->asPoint(), layer, c, fet, symbolLayer, symbol ); } //multipoint if ( geometryType == QGis::WKBMultiPoint || geometryType == QGis::WKBMultiPoint25D ) { QgsMultiPoint multiPoint = geom->asMultiPoint(); QgsMultiPoint::const_iterator it = multiPoint.constBegin(); for ( ; it != multiPoint.constEnd(); ++it ) { writePoint( *it, layer, c, fet, symbolLayer, symbol ); } } //single line if ( geometryType == QGis::WKBLineString || geometryType == QGis::WKBLineString25D ) { writePolyline( geom->asPolyline(), layer, lineStyleName, c, width, false ); } //multiline if ( geometryType == QGis::WKBMultiLineString || geometryType == QGis::WKBMultiLineString25D ) { QgsMultiPolyline multiLine = geom->asMultiPolyline(); QgsMultiPolyline::const_iterator lIt = multiLine.constBegin(); for ( ; lIt != multiLine.constEnd(); ++lIt ) { writePolyline( *lIt, layer, lineStyleName, c, width, false ); } } //polygon if ( geometryType == QGis::WKBPolygon || geometryType == QGis::WKBPolygon25D ) { QgsPolygon polygon = geom->asPolygon(); QgsPolygon::const_iterator polyIt = polygon.constBegin(); for ( ; polyIt != polygon.constEnd(); ++polyIt ) //iterate over rings { writePolyline( *polyIt, layer, lineStyleName, c, width, true ); } } //multipolygon or polygon if ( geometryType == QGis::WKBMultiPolygon || geometryType == QGis::WKBMultiPolygon25D ) { QgsMultiPolygon mp = geom->asMultiPolygon(); QgsMultiPolygon::const_iterator mpIt = mp.constBegin(); for ( ; mpIt != mp.constEnd(); ++mpIt ) { QgsPolygon::const_iterator polyIt = mpIt->constBegin(); for ( ; polyIt != mpIt->constEnd(); ++polyIt ) { writePolyline( *polyIt, layer, lineStyleName, c, width, true ); } } } } }
void iom_file::writeAttr(XmlWriter &out, IomObject &obj,int attr) { int valueCount=obj->getAttrValueCount(attr); if(valueCount>0){ const XMLCh *val=obj->getAttrPrim(attr,0); // not a primitive? if(!val){ IomObject child=obj->getAttrObj(attr,0); // some special cases if(child->getTag()==tags::get_COORD()){ // COORD out.startElement(attr,0,0); writeCoord(out,child); out.endElement(/*attr*/); if(valueCount>1){ iom_issueerr("max one COORD value allowed"); } }else if(child->getTag()==tags::get_POLYLINE()){ // POLYLINE out.startElement(attr,0,0); writePolyline(out,child,false); out.endElement(/*attr*/); if(valueCount>1){ iom_issueerr("max one POLYLINE value allowed"); } }else if(child->getTag()==tags::get_MULTISURFACE()){ // MULTISURFACE out.startElement(attr,0,0); writeSurface(out,child); out.endElement(/*attr*/); if(valueCount>1){ iom_issueerr("max one MULTISURFACE value allowed"); } }else{ // normal case const XMLCh *ref=child->getRefOid(); bool isRef= ref ? true : false; // Reference-attribute or Role or EmbeddedLink? if(isRef){ const XMLCh *extref=0; const XMLCh *bid=0; XMLCh itoabuf[40]; const XMLCh *orderpos=0; if(ref){ if(child->getRefOrderPos()>0){ XMLString::binToText( child->getRefOrderPos(),itoabuf,sizeof(itoabuf)-1,10); orderpos=itoabuf; } } bid=child->getRefBid(); if(bid){ extref=ref; ref=0; } XmlWrtAttr refAttr[]={ XmlWrtAttr(ref ? ustrings::get_REF() :0, ref,true) ,XmlWrtAttr(extref ? ustrings::get_EXTREF() :0, extref,true) ,XmlWrtAttr(bid ? ustrings::get_BID() :0, bid,true) ,XmlWrtAttr(orderpos ? ustrings::get_ORDER_POS():0, orderpos) }; out.startElement(attr,refAttr,sizeof(refAttr)/sizeof(refAttr[0])); if(child->getAttrCount()>0){ out.startElement(child->getTag(),0,0); writeAttrs(out,child); out.endElement(/*child*/); } out.endElement(/*attr*/); if(valueCount>1){ iom_issueerr("max one reference value allowed"); } }else{ // struct out.startElement(attr,0,0); int valuei=0; while(1){ out.startElement(child->getTag(),0,0); writeAttrs(out,child); out.endElement(/*child*/); valuei++; if(valuei>=valueCount){ break; } child=obj->getAttrObj(attr,valuei); } out.endElement(/*attr*/); } } }else{ out.startElement(attr,0,0); out.characters(val); out.endElement(/*attr*/); if(valueCount>1){ iom_issueerr("max one primitive-type value allowed"); } } } }