Page Index Toggle Pages: [1] 2 3  Send TopicPrint
Very Hot Topic (More than 25 Replies) SVG export (Read 16724 times)
Dexter
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 62
Joined: Jun 25th, 2009
SVG export
Sep 2nd, 2009 at 12:47pm
Print Post  
I am testing the svg exporter. I export a diagram to svg and it is ugly, very ugly.  Here is how I export the diagram.
Code
Select All
SvgExporter exporter = new SvgExporter();
			  exporter.Export(diagram, saveFileDialog.FileName);
 



And here is what has exit:

http://a.imagehost.org/download/0734/test

Please let me know if I am doing something wrong or not doing something

Best regards
  
Back to top
 
IP Logged
 
Dexter
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 62
Joined: Jun 25th, 2009
Re: SVG export
Reply #1 - Oct 26th, 2009 at 2:43pm
Print Post  
Hi there! does any body knows an answer to this? please is very important stuff....

Regards,
Dexter
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: SVG export
Reply #2 - Oct 26th, 2009 at 2:49pm
Print Post  
Are you exporting from the Silverlight version and opening the diagram using the diagramming.dll for ASP.NET?
  
Back to top
 
IP Logged
 
Dexter
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 62
Joined: Jun 25th, 2009
Re: SVG export
Reply #3 - Oct 26th, 2009 at 3:05pm
Print Post  
No. I am using dll's from the win forms distribution
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: SVG export
Reply #4 - Oct 26th, 2009 at 3:18pm
Print Post  
Could you call debug.print() for the nodes' font sizes and units after loading the diagram? What values can you see printed?
  
Back to top
 
IP Logged
 
Dexter
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 62
Joined: Jun 25th, 2009
Re: SVG export
Reply #5 - Oct 26th, 2009 at 3:32pm
Print Post  
Font size = 2,333333; font units = Millimeter
Font size = 2,333333; font units = Millimeter
Font size = 2,333333; font units = Millimeter
Font size = 2,333333; font units = Millimeter
Font size = 2,333333; font units = Millimeter
Font size = 2,333333; font units = Millimeter
Font size = 2,333333; font units = Millimeter
Font size = 2,333333; font units = Millimeter
Font size = 2,333333; font units = Millimeter

this is the result after loading all items on the diagram. the svg is the following
http://h.imagehost.org/download/0202/test
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: SVG export
Reply #6 - Oct 26th, 2009 at 3:39pm
Print Post  
And what is the Diagram.MeasureUnit value?
  
Back to top
 
IP Logged
 
Dexter
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 62
Joined: Jun 25th, 2009
Re: SVG export
Reply #7 - Oct 26th, 2009 at 3:41pm
Print Post  
Millimeter
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: SVG export
Reply #8 - Oct 26th, 2009 at 4:08pm
Print Post  
It worked fine for me:
http://mindfusion.eu/_samples/svg_233mm.svg

Could you save the diagram to xml and email it to support@mindfusion.eu?
  
Back to top
 
IP Logged
 
Dexter
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 62
Joined: Jun 25th, 2009
Re: SVG export
Reply #9 - Oct 27th, 2009 at 7:58am
Print Post  
I have send the xml file to the support. The subject contains a link to this forum thread and is addressed to you. I am waiting to see if I am doing something wrong there.

Best regards,
Dexter
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: SVG export
Reply #10 - Oct 27th, 2009 at 11:57am
Print Post  
There are some custom types and custom-drawn tables and cells in that file. Could you copy here any custom-drawing code you are using? The exported SVG looked fine when we replaced the custom nodes with standard ShapeNodes and TableNodes.

Stoyan
  
Back to top
 
IP Logged
 
Dexter
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 62
Joined: Jun 25th, 2009
Re: SVG export
Reply #11 - Oct 27th, 2009 at 12:46pm
Print Post  
The table nod has the following custom draw mechanism:
Code
Select All
	  public override void Draw(IGraphics graphics, RenderOptions options)
	  {
		Rows[1].Height = Bounds.Height - Rows[0].Height - Pen.Width;

		base.Draw(graphics, options);
	  }

public void DrawCell(DrawCellEventArgs e)
	  {
		IGraphics g = e.Graphics;
		TableNode.Cell cell = e.Cell;

		StringFormat format = cell.TextFormat;

		RectangleF r = e.Bounds;

		if (e.Cell.Equals(nameCell))
		{
		    float newWidth = CalculateWitdth(e.Cell.Text, Font, r.Width, e.Cell.TextFormat, r.Height);

		    if (newWidth > r.Width)
		    {
			  r.X = r.X - (newWidth - r.Width) / 2;
		    }

		    r.Width = newWidth;


		    g.DrawString(cell.Text,
			  cell.Font ?? e.Table.Font, Brushes.Black, r, format);

		    return;

		}

		g.DrawString(cell.Text, cell.Font ?? e.Table.Font, Brushes.Black, r, format);
	  }
 



For a shape node the drawing is the following

Code
Select All
 public override void Draw(MindFusion.Drawing.IGraphics graphics, RenderOptions options)
	  {
		System.Drawing.Pen pen = Pen.CreateGdiPen(Bounds);

		graphics.DrawRectangle(pen, InternalBounds.X, InternalBounds.Y, InternalBounds.Width, InternalBounds.Height);
		pen.Dispose();

		SizeF textSize = graphics.MeasureString(Text, Font, 0, TextFormat);
		textSize.Width += 2;

		RectangleF textOutline = new RectangleF(
						    InternalBounds.X + (InternalBounds.Width - textSize.Width) / 2,
						    InternalBounds.Y - textSize.Height / 2,
						    textSize.Width,
						    textSize.Height);

		System.Drawing.Brush brush = new SolidBrush(Color.White);
		graphics.FillRectangle(brush, textOutline);
		brush.Dispose();

		graphics.DrawString(Text, Font, new SolidBrush(TextColor), textOutline, TextFormat);
	  }

	  public override void DrawHandles(MindFusion.Drawing.IGraphics graphics, Color color)
	  {
		if (Parent != null)
		{
		    RectangleF rc = Utilities.NormalizeRect(InternalBounds);

		    InternalUtils.DrawSelHandles(graphics, color, Parent.DisabledHandlesColor, rc, RotationAngle, this.EnabledHandles, Parent.ShowDisabledHandles, this.HandlesStyle, Parent.AdjustmentHandlesSize);
		}
	  }
 



A shape node in the xml file has the following shape defined:
Code
Select All
public static Shape TransactionKind
	  {
		get
		{
		    return new Shape(
		     Shapes.Ellipse.Outline,
		     Shapes.Decision.Outline,
		     null,
		     FillMode.Winding, "TK");
		}
	  }
 



and one custom link has the following draw method
Code
Select All
		Pen pen;
		Brush brush;

		if (base.ShouldRender())
		{
		    pen = base.Pen.CreateGdiPen();
		    brush = new SolidBrush(pen.Color);

		    //determine where the diamond should be drawn at the origin or destination
		    //depending from where the user start drawing

		    int diamondPosition = 0;

		    if (!(this.Origin is ActorRoleView))
		    {
			  diamondPosition = ControlPoints.Count - 1;
		    }

		    PointF e = ControlPoints[diamondPosition];

		    RectangleF bounds = new RectangleF(e.X - diamondSize / 2, e.Y - diamondSize / 2, diamondSize, diamondSize);

		    GraphicsPath path = new GraphicsPath();
		    path.AddRectangle(bounds);

		    Matrix r = new Matrix();
		    r.RotateAt(45, e);
		    path.Transform(r);

		    graphics.FillPath(brush, path);

		    pen.Dispose();
		    brush.Dispose();
		}
		else
		{
		    return;
		}

		base.Draw(graphics, options);
 



  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: SVG export
Reply #12 - Oct 27th, 2009 at 4:19pm
Print Post  
I couldn't reproduce it. Could you also post the svg export code? Are you using the latest WinForm version?
  
Back to top
 
IP Logged
 
Dexter
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 62
Joined: Jun 25th, 2009
Re: SVG export
Reply #13 - Oct 28th, 2009 at 6:58am
Print Post  
The dll used in the application has the following attributes:
Runtime Version: v2.0.50727 and Version: 5.3.2.23161 but I am using a trial version of flow chart .net.

The code used to export the diagram is the following:

Code
Select All
SvgExporter svgExporter = new SvgExporter();
				svgExporter.ExternalImages = false;
				svgExporter.Export(diagram.DiagramDocument, saveFileDialog.FileName);
 



there the DiagramDocument is a property that returns the diagram where the painting happens.

Du to the fact that I have custom shapes defined must I set some custom draw properties for the shapes concerned? Because now I have only the CellCustomDraw set to Aditional.

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: SVG export
Reply #14 - Oct 28th, 2009 at 8:42am
Print Post  
Should we test all this in a Windows Forms application? You have posted in the Silverlight forum so I assumed you are sending the diagram to an ASP.NET page and exporting from there. Could you send us a test app or site that contains your custom classes (at least the drawing code), and have all diagram / diagramview properties from your main project?

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 3 
Send TopicPrint