public virtual void Write(Shape aShape, Point aPosition, int aChannel) { // write paths or mid-cricle var circle = new SvgCircle(); var radius = aShape.Radius - aShape.Width / 2; circle.Fill = SvgPaintServer.None; circle.CenterX = new SvgUnit(SvgUnitType.Millimeter, aPosition.X); circle.Radius = new SvgUnit(SvgUnitType.Millimeter, radius); if (aChannel == 0) { circle.CenterY = new SvgUnit(SvgUnitType.Millimeter, aPosition.Y - aShape.Radius - 1); } else { circle.CenterY = new SvgUnit(SvgUnitType.Millimeter, aPosition.Y + aShape.Radius + 1); } circle.Stroke = new SvgColourServer(System.Drawing.Color.Black); circle.StrokeWidth = new SvgUnit(SvgUnitType.Millimeter, aShape.Width); iGroup.Children.Add(circle); }
public override void Write(Shape aShape, Point aPosition, int aChannel) { if (aShape.Width == iWidth && aShape.Depth == iDepth) { // write paths for the outer circle var circle = new SvgCircle(); circle.Fill = SvgPaintServer.None; circle.CenterX = new SvgUnit(SvgUnitType.Millimeter, aPosition.X); circle.Radius = new SvgUnit(SvgUnitType.Millimeter, aShape.Radius); if (aChannel == 0) { circle.CenterY = new SvgUnit(SvgUnitType.Millimeter, aPosition.Y - aShape.Radius - 1); } else { circle.CenterY = new SvgUnit(SvgUnitType.Millimeter, aPosition.Y + aShape.Radius + 1); } iGroup.Children.Add(circle); } }
public static void DrawOrDiscardEntity(BlockTableRecord btr, Transaction tx, Matrix3d transform, Svg.SvgGroup group)//, int upscale) { foreach (oid oid in btr) { switch (oid.ObjectClass.Name) { case "AcDbLine": //prdDbg(oid.ObjectClass.Name); Line line = oid.Go <Line>(tx); using (Line newLine = new Line(line.StartPoint, line.EndPoint)) { newLine.TransformBy(transform); SvgLine sline = new Svg.SvgLine { StartX = ts(newLine.StartPoint.X), StartY = ts(-newLine.StartPoint.Y), EndX = ts(newLine.EndPoint.X), EndY = ts(-newLine.EndPoint.Y), StrokeWidth = ts(0.1), Stroke = new Svg.SvgColourServer(System.Drawing.Color.Black) }; //if (flip != Flip.PP) //{ // sline.Transforms = AddTransforms(flip, // sline.StartX + sline.EndX, // sline.StartY + sline.EndY); //} group.Children.Add(sline); //mSpc.AppendEntity(newLine); //tx.AddNewlyCreatedDBObject(newLine, true); } break; case "AcDbPolyline": //prdDbg(oid.ObjectClass.Name); Polyline pline = oid.Go <Polyline>(tx); using (Polyline newPline = new Polyline(pline.NumberOfVertices)) { for (int i = 0; i < pline.NumberOfVertices; i++) { newPline.AddVertexAt(i, pline.GetPoint2dAt(i), 0, 0, 0); } newPline.TransformBy(transform); Extents3d bbox = newPline.GeometricExtents; //Prepare for Svg.Transforms SvgPointCollection pcol = new SvgPointCollection(); for (int i = 0; i < newPline.NumberOfVertices; i++) { Point2d p2d = newPline.GetPoint2dAt(i); pcol.Add(ts(p2d.X)); pcol.Add(ts(-p2d.Y)); } SvgPolyline sPline = new SvgPolyline(); sPline.Points = pcol; if (pline.NumberOfVertices == 2) { sPline.StrokeWidth = ts(0.1); sPline.Stroke = new SvgColourServer(System.Drawing.Color.Black); } else { sPline.Fill = new SvgColourServer(System.Drawing.Color.Black); } //if (flip != Flip.PP) //{ // sPline.Transforms = AddTransforms(flip, // ts(bbox.MinPoint.X + bbox.MaxPoint.X), // ts(bbox.MinPoint.Y + bbox.MaxPoint.Y)); //} group.Children.Add(sPline); } break; case "AcDbCircle": //prdDbg(oid.ObjectClass.Name); Circle circle = oid.Go <Circle>(tx); using (Circle newCircle = new Circle()) { newCircle.SetDatabaseDefaults(); newCircle.Center = circle.Center; newCircle.Radius = circle.Radius; newCircle.TransformBy(transform); SvgCircle sCircle = new Svg.SvgCircle { CenterX = ts(newCircle.Center.X), CenterY = ts(-newCircle.Center.Y), Radius = ts(newCircle.Radius), Fill = new Svg.SvgColourServer(System.Drawing.Color.Black), }; //if (flip != Flip.PP) //{ // sCircle.Transforms = AddTransforms(flip, // 2 * sCircle.CenterX, // 2 * sCircle.CenterY); //} group.Children.Add(sCircle); //mSpc.AppendEntity(newCircle); //tx.AddNewlyCreatedDBObject(newCircle, true); } break; case "AcDbMText": prdDbg(oid.ObjectClass.Name); MText mText = oid.Go <MText>(tx); string text = mText.Contents; using (DBText newText = new DBText()) { newText.SetDatabaseDefaults(); newText.TextString = text; newText.Position = mText.Location; newText.Rotation = mText.Rotation; //newText.TransformBy(transform); SvgText sText = new SvgText(newText.TextString); prdDbg(ts(newText.Position.X).ToString()); prdDbg(ts(newText.Position.Y).ToString()); sText.X.Add(ts(newText.Position.X)); sText.Y.Add(ts(newText.Position.Y + 0.1)); sText.FontFamily = "Arial"; sText.FontSize = ts(0.50); prdDbg(ts(newText.Rotation * (180 / Math.PI)).ToString()); sText.Rotate = ts(newText.Rotation * (180 / Math.PI)).ToString(); sText.Fill = new SvgColourServer(System.Drawing.Color.Black); group.Children.Add(sText); } break; case "AcDbBlockReference": DrawOrDiscardEntity(tx.GetObject(oid, OpenMode.ForRead) as BlockReference, tx, group); //, upscale); break; default: //prdDbg("Not implemented: " + oid.ObjectClass.Name); break; } } }