Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic SvgNode support for non scaling stroke (Read 3945 times)
stefski
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 31
Location: Norway
Joined: Jul 17th, 2009
SvgNode support for non scaling stroke
Mar 12th, 2015 at 10:53am
Print Post  
Hello guys,

as a new requirement in our application our users should now be able to freely re-size (some of) the nodes in the diagram, i.e. potentially changing the aspect ratio of the nodes.

As the nodes are instances of SvgNode we now realize that we have an issue with the stroke lines on the SVG images, when the aspect ratio is significantly changed, as e.g. a horizontal stoke line might be significantly thicker than a vertical stoke line on the same image, if the node is being stretched along the vertical axis.

As far as I can see the SVG Tiny 1.2 standard has a "vector-effect" attribute, which seemingly could have provided the means to solve this issue.

Do you have any plans on supporting the SVG Tiny 1.2 standard, or might there be some other way for us to keep an absolute stroke line thickness regardless of aspect ratio of the diagram node?

  

Kind regards

Steffen Skov
OLGA Application Architect
Schlumberger Information Solutions AS
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: SvgNode support for non scaling stroke
Reply #1 - Mar 12th, 2015 at 11:54am
Print Post  
Hi,

We'll try to implement vector-effect='non-scaling-stroke' for the 6.3.3 release.

Regards,
Stoyan
  
Back to top
 
IP Logged
 
stefski
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 31
Location: Norway
Joined: Jul 17th, 2009
Re: SvgNode support for non scaling stroke
Reply #2 - Mar 12th, 2015 at 2:51pm
Print Post  
Thank you, Stoyan,

we are, hopefully, going to move over to the WPF version in a not too distant future (the licenses should be in place already), so I do not think an upgrade to the Winforms version 6.3.3 is in the plans.

If I recall correctly, the WPF version uses XAML instead of SVG, and we are including a task for converting our existing graphics from SVG to XAML in our plans.

Given that the WPF version is based on, well... WPF, will this whole issue simply be gone when we have moved to that version?

  

Kind regards

Steffen Skov
OLGA Application Architect
Schlumberger Information Solutions AS
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: SvgNode support for non scaling stroke
Reply #3 - Mar 13th, 2015 at 9:59am
Print Post  
Unfortunately it's not that simply gone Smiley WPF scales strokes too when you apply a scale transform, and I can't see any built-in options to stop scaling. If you just load a Xaml DrawingImage into ShapeNode, you will get attached result:

Code
Select All
<diag:ShapeNode x:Name="n1" Bounds="30,30,20,20" ImageAlign="Stretch">
	<diag:ShapeNode.Image>

		<!-- from DrawingImage example in MSDN -->
		<DrawingImage>
			<DrawingImage.Drawing>
				<GeometryDrawing>
					<GeometryDrawing.Geometry>
						<GeometryGroup>
							<EllipseGeometry Center="50,50" RadiusX="45" RadiusY="20" />
							<EllipseGeometry Center="50,50" RadiusX="20" RadiusY="45" />
						</GeometryGroup>
					</GeometryDrawing.Geometry>
					<GeometryDrawing.Brush>
						<LinearGradientBrush>
							<GradientStop Offset="0.0" Color="Blue" />
							<GradientStop Offset="1.0" Color="#CCCCFF" />
						</LinearGradientBrush>
					</GeometryDrawing.Brush>
					<GeometryDrawing.Pen>
						<Pen Thickness="10" Brush="Black" />
					</GeometryDrawing.Pen>
				</GeometryDrawing>
			</DrawingImage.Drawing>
		</DrawingImage>

	</diag:ShapeNode.Image>
</diag:ShapeNode> 



The WPF diagram doesn't parse Xaml itself but just calls the WPF's DrawImage(ImageSource, Rect) method and apparently it works by applying a ScaleTransform internally. So if you convert your SVG images to Xaml drawings you'll still get same results.

You should be able to work around it if you load only Geometry objects from Xaml instead of full DrawingImage, and custom-draw the geometries from a derived node class or Draw event by setting the Geometry.Transform property to a scale that would fill the node instead of scaling the whole image. Geometry.Transform is local to the Geometry object and only affects its coordinates, so the stroke you use to draw it will not be scaled.

Alternatively you might try converting your SVG drawings to Xaml data templates that bind to the node size and apply these templates to WpfDiagram's TemplatedNode. I.e. the geometry elements would specify coordinates through {Binding} expressions that bind to node's width or height instead of relying on scale transforms.

I hope that helps,
Stoyan
  

DrawingImage.png ( 16 KB | 138 Downloads )
DrawingImage.png
Back to top
 
IP Logged
 
stefski
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 31
Location: Norway
Joined: Jul 17th, 2009
Re: SvgNode support for non scaling stroke
Reply #4 - Mar 17th, 2015 at 8:33am
Print Post  
Hi Stoyan,

thank you for the detailed explanation. We will keep this in mind for when we move to WPF then. From the top of it, it seems like the XAML version gives a bit more flexibility in how the rendering is done.

  

Kind regards

Steffen Skov
OLGA Application Architect
Schlumberger Information Solutions AS
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint