TrueTransform added to ReaderSvg and ReaderWmf

by abenedik 21. June 2013 10:16

For quite some time it was possible to transform the read objects in ViewerSvg and Paste2Xaml. I am not talking about simply adding a transformation to read objects but to actually change all coordinates, sizes and other values with the specified transformation.

For example after reading a svg file we get the following xaml (some common properties were removed to simplify the xaml):

<Canvas Width="422.425" Height="208.895">
    <TextBlock Text="text1" FontSize="10" Canvas.Left="68.571" Canvas.Top="103.145"/>
    <Path Stroke="Black" StrokeThickness="3" StrokeMiterLimit="2" 
          Data="M366.43,67.029C358.951,54.888 368.807,24.872 384.677,34.264 394.346,39.986 389.365,72.847 384.677,80.68 384.384,71.342 374.133,66.51 366.43,67.029z"/>

In Export dialog in ViewerSvg it was possible to transform this with specifying custom width (instead of 422.425) we could set the width to 100. After transformation the xaml is:

<Canvas Width="100" Height="49.5">
    <TextBlock Text="text1" FontSize="2.368" Canvas.Left="16.233" Canvas.Top="24.441"/>
    <Path Stroke="Black" StrokeThickness="0.711" StrokeMiterLimit="2" 
          Data="M86.744,15.883C84.974,13.006 87.307,5.894 91.064,8.119 93.353,9.475 92.174,17.262 91.064,19.118 90.995,16.905 88.568,15.76 86.744,15.883z"/>

 
As seen from xaml, the transformation changed the FontSize, position in canvas, StrokeThickness and also path data. ViewerSvg and Paste2Xaml used an internal TrueTransform class that performed the transformation.

This can be very useful in many cases:

  • When creating graphics for WPF, Silverlight or WinRT the graphics elements can be created in a drawing application and can have any possible dimension. But if your application needs graphics element that would have size 100 x 100, it is very convenient to transform the graphics into the required dimensions.
  • Some drawing applications (for example Inkscape) allow users to draw in real units (in mm), but when the drawing is saved into svg file, all the units are converted to pixels. With using TrueTransform it is possible to convert the coordinates and other data back to mm units.


Now this functionally is available in Ab2d.ReaderSvg and Ab2d.ReaderWmf libraries also. This means that you can now also use TrueTransform in your applications.

The simplest way to use TrueTransform is to use Transform or TransformFromPixelsToMM methods on ReaderSvg or ReaderWmf class. The Transform needs two parameters: the first one is a Transform object (can be ScaleTransform, TranslateTransform, TransformGroup, or any other Transform); the second is a Boolean that specifies if the LastReadViewbox (property of ReaderSvg and ReaderWmf) is also changed – if true this means that GetXaml method will return the xaml of the transformed objects. The TransformFromPixelsToMM method can be used to transform from pixel to real units.

It is not only possible to transform the objects that are read from svg or metafiles but also almost any other objects – this can be done with Ab2d.Common.ReaderSvg.TrueTransform (or Ab2d.Common.ReaderWmf.TrueTransform) class.
 

ReaderSvg also got a new property – SvgCreator. It is an enum that is set after reading svg file and specifies the application that was used to create svg file. Currently the following applications are recognized: Microsoft Visio, CorelDraw, Adobe Illustrator and Inkscape.

 

There is also a new sample that come with ReaderSvg that demonstrates the new transformations.


As always if you are new to our tools, you are most welcome to download a 60-day trial from the Download page. Existing customers can get the updated versions from their User Account page.

Tags: ,

ReaderSvg | ReaderWmf

Maintenance releases for Ab2d.ReaderSvg and Ab2d.ReaderWmf are now available

by abenedik 15. May 2013 21:05

I am happy to inform you that a new version of Ab2d.ReaderSvg (svg reader for WPF) and Ab2d.ReaderWmf (metafile reader for WPF) have been published.

Ab2d.ReaderSvg got the following improvements:

  • Fixed reading numbers defined with em unit (for example: "123.45em")
  • Fixed writing Image.Stretch into XAML
  • Added writing HorizontalAlignment and VerticalAlignment into XAML when exporting Image (when using preserveAspectRatio svg element)

Ab2d.ReaderWmf got the following improvement:

  • Improved positioning some elements (in case ViewPortExtentX or ViewPortExtentY is set)

 

All those fixes are based on the user's feedback. The small number of reported issues and fixes shows that both products are very mature and work very well for the customers.

Tags: ,

ReaderSvg | ReaderWmf

Improved version of ZoomPanel available

by abenedik 20. March 2013 22:13

I am happy to say that a new version of ZoomPanel control is available.

After some straggling to fix some problems with using ViewboxLimits, FitToHeight and FitToWidth I have decided to rewrite part of the code again. Hopefully this time the ZoomPanel should work regardless of the ViewboxLimits, content size and available ZoomPanel size.

There are no new features in this version. I think that ZoomPanel already has many great features and is a complete solution for any possible scenario that needs zooming and panning.

As always the existing customers can download the new version from their User Account page. Others can try the new version with downloaded the new evaluation version.

Tags:

ZoomPanel

Minor improvements for Ab3d.Reader3ds, Ab2d.ReaderWmf and Ab2d.ReaderSvg published

by abenedik 15. January 2013 13:54

I would like to inform you that new versions for Ab3d.Reader3ds, Ab2d.ReaderWmf and Ab2d.ReaderSvg has been published.

The new version contains a fix for generating object names for exported XAML. A bug in one of the previous version prevented the exporter code to check and fix the object's name.

There is also an additional minor improvement in Ab2d.ReaderWmf library that now correctly position text is some of the rare cases.

Tags: , ,

Reader3ds | ReaderSvg | ReaderWmf

WPF 3D and Ab3d.PowerToys Performance Tips and Tricks

by abenedik 15. January 2013 13:48

As mentioned in the previous blog post, a new "Tips and Tricks" section has been added to the Ab3d.PowerToys help file.

This section contains some basic tricks to improve performance in WPF 3D and Ab3d.PowerToys. The following is the content of the section:

 

Ab3d.PowerToys performance tips:

When the position or size of the 3D objects created from Ab3d.PowerToys Visual3D or UIElement3D are changed frequently (for example CenterPosition or Size of the BoxVisual3D), it is recommended to use TranslateTransform3D and ScaleTransform3D and change transformations instead. When Position or Size properties are changed, the MeshGeometry3D that defines the 3D object is regenerated. This is not good for performance and memory usage (Garbage collector will have a lot of work to recycle all unsued geometries).

For example when you need to change position of BoxVisual3D, you can change its CenterPosition property. But it is much better to define BoxVisual3D with CenterPosition at (0, 0, 0), add TranslateTransform3D to the BoxVisual3D and then change OffsetX, OffsetY or OffsetZ on the BoxVisual3D. This advice is even more important when changing more complex 3D object - for example SphereVisual3D with lots of segments.

When multiple properties are changed at once on Ab3d.PowerToys cameras or 3D objects it is recommended to call BeginInit() before applying the changes. After that call EndInit(). This will update the object just once and not after each single change.

WPF 3D does not support hardware accelerated 3D lines. Therefore Ab3d.PowerToys simulates 3D lines with creating each line from 2 triangles. To correctly show the lines, their geometry must be updated after the camera is changes. Because updating lines involves some heavy 3D calculations, this can affect performance when many lines or complex wireframe needs to be updated. It is possible to slightly improve performance with manually calling Refresh method on LinesUpdater class (see LinesStressTest sample for more info).

General WPF 3D performance tips:

Freeze 3D object that you will not modify (call Freeze method on Model3DGroup, GeometryModel3D or MeshGeometry3D). If you will change only material or transformation, you can still freeze the MeshGeometry3D.

If you want to create 3D objects on another thread (to free the UI thred), you need to Freeze the created 3D object before "passing" the result to the UI thread (see "Multithreaded Sample" from Ab3d.Reader3ds samples).

When modifying collections in MeshGeometry3D please follow the advices described in Tim Cahill's blog Optimizing 3D Collections in WPF (http://blogs.msdn.com/b/timothyc/archive/2006/08/31/734308.aspx). Two most important performance advices from that blog post are:

Initialize collections with specifying the capacity in the constructor (predefining the size to prevent resizing the collection multiple times when the items are added). For example, if you know that you will add 1000 position than instead of:

    position = new Point3DCollection();

    use

    position = new Point3DCollection(1000);

   

"Disconnect" the collection before changing it:

    var positions = myMeshGeometry.Positions;
   myMeshGeometry.Positions = null; // disconnect;

   // change the positions

   myMeshGeometry.Positions = positions; // connect positions back to MeshGeometry3D

Tags:

Ab3d.PowerToys

New version of our products brings improved support for Windows 8 and some other goodies

by abenedik 28. December 2012 10:55

I am very happy to announce that a new version of all our products is available.

The biggest improvement of the new version is better support for Window 8. This includes improved installer that now works correctly without .Net 2.0 installed on the system. Also the Viewer3ds, ViewerSvg and Paste2Xaml applications are now build on .Net 4.0 framework and do not require .Net 3.5 any more. The applications also use different obfuscation method - the previous obfuscation crashed the applications on startup in Windows 8.

What is more, the ViewerSvg and Paste2Xaml now fully support exporting XAML for Windows Store applications (Windows Runtime). This means that you can use almost any svg file, metafile or get drawing from clipboard and use ViewerSvg or Paste2Xaml to create vector graphics for Windows Store applications.

With this release all libraries now target .Net 3.5 Client profile (before some of them targered .Net 3.0).
As before all the libraries also contain an additional assembly that is built on .Net 4.0 framework.


This version also brings some additional improvements to Ab3d.PowerToys, Ab3d.Reader3ds and ZoomPanel libraries.

The following are the changed in the Ab3d.PowerToys:

  • Added GetCameraPosition method to BaseCamera.
  • Fixed creating geometry for Visual 3D objects when no property is changed on the visual (for example if default size is used).
  • Fixed showing long 3D lines that cross the near camera plane (before such lines were not correctly shown).
  • Improved measuring size of CameraControlPanel - now it is possible to define only desired Width or Height and the control automatically sets the other (Height or Width).
  • In MouseCameraController the StartMouseProcessing and EndMouseProcessing are now protected virtual and can be overriden (before they were private).
  • Improved creation of sphere mesh - before some triangles were defined in such a way that they represented a line instead of triangle (two positions in the triangle were defined in the same position in space).
  • Added possibility to create a slightly improved sphere mesh when there is no need to create texture coordinates (this can be done with specifying generateTextureCoordinates as false in the Ab3d.Meshes.SphereMesh3D constructor).
  • Added DumpMatrix3D to Dumper class.
  • Improved FpsMeter when custom DisplayFormatString property is set.
  • Fixed creating PolyLines when they are created with duplicate positions - Index out of range exception was thrown before.


Scene editor in Ab3d.PowerToys samples

There is also a new and very interesting sample available with the new Ab3d.PowerToys. A screenshot from the sample is shown in the image above. The sample is showing how to create a simple 3D editor. It allows the user to create 3D boxes with the mouse (the current position of the mouse in the 3D scene is shown with two green lines). The box is created by first defining the base rectangle with dragging the mouse and then defining the height with moving the mouse up and clicking at desired height. The sample also shows how to create simple snap to grid. User can rotate or move the camera around. It is also possible to change camera to show all the objects (zoom to content).

The Ab3d.PowerToys help has also been improved. It now contains the "Quick start tutorial" that is basically the content of one of my previous blog posts. What is more, there is also a "Tips and Tricks" help section that describes some techniques that can help or improve working with WPF 3D. I will write the content of that help section in my next post.


And the following are two additional changed in Ab3d.Reader3ds:

  • Added CreateTextureCallback delegate to Reader3ds - it can be used to customize the process of creating the texture images.
  • Fixed reading 3ds files that define material with names longer than 17 characters (the 3ds documentation defines max length of material name to be 17 characters - but it looks that in reality the material names can be longer).


As mentioned before, ZoomPanel also has an improvement. But not in the library itself but as an additional sample that describes how to limit the zoom to specific zoom factor.


As always if you are new to our tools, you are most welcome to download a 60-day trial from the Download page. Existing customers can get the updated versions from their User Account page.

Tags: , , , ,

Ab3d.PowerToys | Reader3ds | ReaderSvg | ReaderWmf | ZoomPanel

Improved support for VS 2012 and some other fixes available for Ab3d.PowerToys and ZoomPanel

by abenedik 1. October 2012 08:52

A new maintenance release for Ab3d.PowerToys and ZoomPanel is available.

It fixes an issue with new designer in Visual Studio 2012. This was most noticeable when a camera from Ab3d.PowerToys was not manually connected to Viewport3D. In that case the code in the camera automatically checks the objects hierarchy and tries to find the Viewport3D automatically. But because the designer in VS 2012 is changed, the code did not find the Viewport3D and therefore the preview of 3D scene in the designer did not show the scene from the specified position.

The new version of Ab3d.PowerToys library also has the following changes:

  • Fixed a typo with renaming the WireBoxVisual3 into WireBoxVisual3D (BREAKING CHANGE!)
  • Improved 3D Text - now ? character is correctly displayed instead of a character that does not have its 3D shape defined
  • Fixed problem with displaying 3D Text in Visual Studio designer

 

A new version of ZoomPanel library also fixes an issue where a "Reference not set to an object" exception was thrown when ZoomPanelMiniMap was added to controls tree but was visible and then the user changed zoom mode on the ZoomController.

Tags: ,

Ab3d.PowerToys | ZoomPanel