New version of Ab2d.ReaderSvg available

by abenedik 1. August 2011 10:19

I am happy to announce that the new version of Ab2d.ReaderSvg library is available.

The version adds improved support for svg use and embedded svg elements. Those two svg elements are now correctly placed and have the correct size.

The new version also provides two new properties that can be used to fix problems that are caused by the differences between WPF and svg.

The first new property is SwitchElementProcessingType. It specifies which children of the svg switch element will be imported and shown. The switch element in svg file defines children that are shown based on the conditions defined in switch element. Because it is not possible to process svg conditions in WPF, it is possible to choose how the children will be imported and which children will be shown. The possible values for SwitchElementProcessingType are:

  • Disabled - svg switch element will not be imported.
  • ShowFirstDiscardOthers - only the first switch child will be imported. Other children will not be imported.
  • ShowFirstHideOthers - all switch children will be imported. Only the first element will be shown. Other children will have their Visibility set to Hidden.
  • ShowFirstCollapseOthers (default) - all switch children will be imported. Only the first element will be shown. Other children will have their Visibility set to Collapsed.
  • ShowAll - all switch children will be imported and shown.

 

The second new property is OverrideMiterLimit. The property has been added because WPF renders miter limit line cab differently as they are defined in svg specifications. The miter lime cabs show sharp line edges. But when the two lines meet at low angle, the sharp edge could extend very far away from the line junction. Therefore the miter limit can limit the sharp edges. In WPF the miter limit is used to specify how far away the sharp edge is allowed to go. In svg, the miter limit defined at which angle the miter limit is converted into beveled edge. This difference can lead to some anomalies when importing svg files. In this case the OverrideMiterLimit can be used to override the miter limit specified in the svg file and use value 1 or 2 instead.

For more information about the differences please see forum thread about this.

For backwards compatibility by default the miter limit defined in svg file is used (OverrideMiterLimit = 0).

 

Both new properties can be also set in the new ViewerSvg (here the default OverrideMiterLimit is set to 2 - miter limit of 2 is used by default).

Tags: , , ,

ReaderSvg

New version of ZoomPanel with tons of new features is available

by abenedik 26. June 2011 22:31

I am really happy to announce that the highly anticipated new version of ZoomPanel library is finally released.

ZoomPanel

The new version brings tons of great new features:

  • Added ZoomPanelNavigator, NavigationCircle and NavigationSlider controls. They can be used to move around zoom area and set zoom factor with slider (shown in the upper left corner in the image above).
  • Added ZoomPanelMiniMap, ViewboxExMiniMap and BaseMiniMap controls. The ZoomPanelMiniMap can be used to preview which part of the content is shown. It also enables moving the shown content and zooming in and out with mouse wheel (shown in the bottom right corner in the image above).
  • Added Stretch property to ZoomPanel - before only Uniform stretch was used. Now it is also possible to use other stretch values: None, Fill, Uniform or UniformToFill.
  • Added IsZoomPositionPreserved property to ZoomPanel - it controls if mouse wheel zooms at the mouse position or at the center of the ZoomPanel.
  • Added RotationAngle property to ZoomPanel.
  • Added ZoomFactor, CenterPosition and CenterPositionUnits properties to ZoomPanel. Before the area that is shown with ZoomPanel was controller by Viewbox property. The usage of this property was sometimes quite complex. Therefore ZoomFactor and CenterPosition were added. They are much simpler to understand and use.
  • Added support to save and navigate through the ZoomPanel history.
  • Added ActualViewbox to ZoomPanel - it describes the actually shown viewbox (the difference is created because of different aspect ratio).
  • Added SetZoom method to ZoomPanel with many overloads to simplify setting which part of the content is shown.
  • Added ZoomAtMousePosition and ZoomAtRelativeMousePosition methods to ZoomPanel.
  • Added IsAutoZoomPanelFindingEnabled property to ZoomController - now it is possible to disable automatically finding the ZoomPanel in case we need to set it manually.
  • Improved design time support when setting Viewbox value for ZoomPanel. Now it is allowed to temporary set the value of Width and Height to 0 (before when 1 was changed the 0.5 the designer throw an exception when 1 was replaced with 0).
  • Added MultiTouchZoomPanel control with full source code.
  • BREAKING CHANGE: When using custom content: Now ZoomFactor is used instead of zoomLevel (in CustomContentProvider callback).

For example the following code is all that is needed to add zooming and panning to the ZoomPanel's content (12345 text in this sample), buttons to control the ZoomMode (ZoomController), zoom panel navigation with buttons and slider to change zoom factor (ZoomNavigator) and mini map that shows which part of the content is shown:

<Window x:Class="Ab2d.ZoomControlSample.ZoomPanelSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ab2d="clr-namespace:Ab2d.Controls;assembly=Ab2d.Controls.ZoomPanel">
  <Grid>
    <ab2d:ZoomPanel Name="myZoomPanel">
      <TextBlock>12345</TextBlock>
    </ab2d:ZoomPanel>
    <ab2d:ZoomController VerticalAlignment="Top"
                         HorizontalAlignment="Right"/>
    <ab2d:ZoomPanelNavigator VerticalAlignment="Top"
                             HorizontalAlignment="Left"/>
    <ab2d:ZoomPanelMiniMap VerticalAlignment="Bottom"
                           HorizontalAlignment="Right"/>
  </Grid>
</Window>

 

The new version comes with many new samples that demonstrate the new functionality. The following screenshot shows one of the samples (the list of all the samples is seen on the left side):

ZoomPanel

 

Even before version 3, the ZoomPanel was the most advanced zooming and panning control for WPF. With this release the control has become even better.

The current price for the Single developer license is only $69. Because so many new features were added to the library, the price will increase significantly on 11th July 2011 (more details are available on Purchase page). So now it is an ideal time to purchase the control, renew the updates subscription or purchase source code for the library.

As usual the new version can be downloaded from User Account page (for commercial users) or from my Downloads page (for evaluation version).

Tags: ,

ZoomPanel

Multi-Touch 3D camera sample added to a new version of Ab3d.PowerToys

by abenedik 7. May 2011 23:20

A new version of Ab3d.PowerToys was just published.

The work on a new version was started as a response to the user post on the forum that asked how it would be possible to control a 3D camera from Ab3d.PowerToys library with his fingers on a multi-touch tablet pc. This looked as a simple an interested task but ended with discovering a probable bug in .Net 4.0 and creating a workaround for it. Also a discovered problems with WPF Browser applications were also fixed.

The following is a short list of new things in this release:

  • Added multi-touch camera controller sample (for .Net 4.0).
  • Fixed using MaterialTypeConverter in .Net 4.0 applications (for example using the following in XAML: Materila="Blue").
  • Fixed problems in WPF Browser applications (fixed showing licensing windows in partially trusted environment).
  • Added Ab3d.PowerToys WPF Browser applications sample.

 

The following screenshot shows the working multi-touch camera sample.

Because the support for multi-touch devices is available in .Net Framework 4.0 I did not want to put the new code into the library as it would raise the requirements from .Net 3.5 to .Net 4.0. So I have decided to create a sample .Net 4.0. project that would reference Ab3d.PowerToys library and use the multi-touch capabilities of the framework to adjust the camera.

Cameras and camera controllers in Ab3d.PoweToys library are very extendable, so it was really easy to create a multi-touch camera controller.

The following code shows the event handler that handles the touch data:

void ViewportBorder_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
    ManipulationDelta delta = e.DeltaManipulation;

    if (delta.Scale.X != 1 || delta.Scale.Y != 1)
    {
        // Scale with adjusting camera distance
        Camera1.Distance *= 1 / ((delta.Scale.X + delta.Scale.Y) / 2);
                
        e.Handled = true;
    }

    if (delta.Translation.X != 0 || delta.Translation.Y != 0)
    {
        // Rotate and move with calling RotateCamera or MoveCamera methods on MouseCameraController1.
        // Both methods take mouse dx and dy as parameters.
        // The amount of rotation is controller by EventsSourceElementRotationChange property on MouseCameraController1: Gets or sets the double value that specifies for how many degrees the camera is rotates when the mouse moves from one side of the EventsSourceElement to another size. The default value is 270.
        // The amount of movement is calculated by MouseCameraController1 that tries to make the movements in 3D just as big to follow the mouse / hand movements
        if (RotateRadioButton.IsChecked ?? false)
            MouseCameraController1.RotateCamera(-delta.Translation.X, -delta.Translation.Y);
        else
            MouseCameraController1.MoveCamera(-delta.Translation.X, -delta.Translation.Y);

        e.Handled = true;
    }
}

As the code shows the pinch zooming is represented as Scale in the DeltaManipulation. The scale is simply used to adjust the camera's distance.

Handling of the translation depends on the state of the RadioButtons that specify if we are rotating or moving the camera. In case of rotating, the RotateCamera method on camera controller is called. It takes the mouse difference as input parameter. In case a camera movement mode is selected, MoveCamera method is called - again it accepts mouse changes.

When I wanted to test the fist version of the code that would rotate a simple box, I got a runtime error that the value "#247589" cannot be assigned to Material. The error pointed to the following line of xaml:

<visuals:BoxVisual3D CenterPosition="0 20 0" Size="40 40 40" Material="#247589"/>

The xaml was copied from other samples for Ab3d.PowerToys library. When the project with other samples was started, there was no runtime exception. But in the new multi-touch sample the same line suddenly produces an exception. This is very strange.

The line defines a 3D box with specified center position, its size and material color. The material color is set by a help of the MaterialTypeConverter that comes with Ab3d.PowerToys library and enables setting the material by simply writing the name of the color (Blue), its hex number (#247589) or specifying image file name that should be used as texture. Without the MaterialTypeConverter the previous line should be written:

<visuals:BoxVisual3D CenterPosition="0 20 0" Size="40 40 40">
    <visuals:BoxVisual3D.Material>
        <DiffuseMaterial>
            <DiffuseMaterial.Brush>
                <SolidColorBrush Color="#247589"/>
            </DiffuseMaterial.Brush>
        </DiffuseMaterial>
    </visuals:BoxVisual3D.Material>
</visuals:BoxVisual3D>

I have removed the Material="#247589" and use the standard WPF was to set the material (as written above). This time the sample worked without errors.

The difference between the working and not working project was the target framework version. The not working was using 4.0.

It looked like that the baml parser (parser that reads the compiled xaml) in .Net 4.0 works does not want to use the custom type converter (MaterialTypeConverter). It was time to search the web. There were many problems with custom type converters, but none was similar to mine. The web did not have a clue about my problems. To make things easier, I created two new project were I wanted to reproduce the problem with as less code as possible. The first attemp showed that type converters on properties and dependancy properties work correctly in .Net 4.0. After some additional checking I have discovered that the Material property in Ab3d.PowerToys library was not created from stretch with Register method, but was created with AddOwner method - I wanted to reuse the already defined property on my own class. That was a breakthrough. When I changed the Register method with the AddOwner on a simplified project, the same error occurred.

After that discovery the workaround was simple - define the Material property from stretch.

This showed a case where assemblies that are created for .Net 3.5 does not work the same when they run with .Net 4.0. I think this should not happen. I am going to report this as a bug to Microsoft Connect.

So a rather simple task lead to interesting discoveries.

 

 

The multi-touch sample is available with the new version of Ab3d.PowerToys library. If you already have the library and do not want to upgrade to latest version just to see the sample, you can also download just the sample from the following link: Ab3d.PowerToys.Multitouch.zip (remember to uncomment the old style 3d box definition in xaml).

EDIT:

From Ab3d.PowerToys version 5.2 on, the multi-touch support is already build into the core Ab3d.PowerToys library into its .Net 4.0 version. This means that you do not need to use special MultiTouchMouseCameraController class for that. All you need to do is to make sure that you are referencing the .Net 4 version of the library from the ".NET 4" subfolder (the .Net 3.5 version does not support multi-touch).

Tags:

Ab3d.PowerToys

New maintenance release with many improvements for metafile reader

by abenedik 20. April 2011 23:42

This release brings many improvements to almost all our products.

The metafile reader (Ab2d.ReaderWmf) library got most of the changes. The svg reader (Ab2d.ReaderSvg) also got a few new features. There were also some improvements that affected all the products except ZoomPanel. ZoomPanel control was left out of this release because the library is waiting for a major upgrade. Now when this release is out I will finally start working on it (many things are already prepared - like mini map, rotate the content, zoom slider, etc. - they just need to be polished and tested).

Let me first describe the changes that affected all the products (except ZoomPanel):

  • The licensing dialogs are now created in WPF and not in Windows Forms as before (this skips loading Windows Forms and other related assemblies and therefore speeds up the application start - especially in evaluation version).
  • Improved commercial license code that tries to find embedded resources - this code is now much faster.
  • Added splash screens to all of the converter applications.

Besides the changes above the Ab3d.Reader3ds and Ab3d.PowerToys libraries did not get any new features.

 

But as mentioned before the Ab2d.ReaderWmf library was improved quite significantly. The code that transformed positions data from metafile into WPF was rewritten from ground up. The new version now enables to specify in which units the read positions will be - they can be in Pixels, Millimeters, Inches or GdiCompatable units. This can be useful when the drawing for example in Microsoft Visio is created in millimeters, the WPF elements that are created with pasting the drawing into Paste2Xaml can be also defined in millimeters. When the default Pixel units are used, the size of the read metafile is now the same as the size that is shown when the metafile is opened by Windows.

This is the list of changes in Ab2d.ReaderWmf library:

  • Added MetafileUnits property. It specifies the units in which the metafile is read. By default its value is set to Pixel. It can be also set to Millimeter, Inch or GdiCompatable. This can be useful to preserve the positions and other properties when the drawing is created in millimeter or inch units.
  • Added AutoSize property - defines if size of the root canvas is get from metafiles bounds or its frame. When bounds is used, the root canvas size is just as big as its containing objects.
  • Added GetSize(units) method that can be used to get the size of the read metafile in the specified units.
  • The size of the read metafile is now by default (if MetafileUnits is Pixel) the same as the size shown when metafile is opened by Window.
  • Improved reading metafiles that use MM_LOMETRIC, MM_HIMETRIC, MM_LOENGLISH, MM_HIENGLISH or MM_TWIPS mapping mode.
  • When reading polyline from a metafile and it has only 2 points a Line is used instead of a Polyline.
  • Added UsedMinLineWidthFactor to get the used minimal line width.
  • Improved Ab2d.Utility.ReaderWmf.ResourceDictionaryWriter - now the process of creating ResourceDictionary from metafiles can be better customized by creating a derived class.
  • Removed obsolete Ab2d.WmfViewbox control - the control has been obsolete for a few versions - Ab2d.Controls.WmfViewbox should be used instead. This also removes the need for Designer assemblies to remove the obsolete control from Designer ToolBox.

The Paste2Xaml application that can be used to simply copy objects from drawing application and paste them into XAML was also improved - support for the new features of the Ab2d.ReaderWmd library was added.

 

Some of the changes were also made in Ab2d.ReaderSvg library:

  • Markers (arrows and other line endings) are now correctly show on line and polyline elements (before they worked only on path elements).
  • markerWidth and markerHeight attributes are now correctly handled.
  • Removed obsolete Ab2d.SvgViewbox control - the control has been obsolete for a few versions - Ab2d.Controls.SvgViewbox should be used instead. This also removes the need for Designer assemblies to remove the obsolete control from Designer ToolBox.

 

Now I have to put together the new version of ZoomPanel.

Than a new exciting area awaits - Silverlght 5 with its 3D.

Tags: , , ,

Ab3d.PowerToys | Reader3ds | ReaderSvg | ReaderWmf

New maintenance release for Ab2d.Reader3ds and Ab3d.PowerToys

by abenedik 3. March 2011 21:37

A minor update for Ab2d.Reader3ds and Ab3d.PowerToys libraries is available.

The update fixes licensing code for WPF Browser applications (partially trusted) - before it was not possible to use both Ab3d.Reader3ds and Ab3d.PowerToys the same WPF Browser application.

The update also fixes problems with reading some tga files with Ab3d.Reader3ds. Because some older 3ds files use tga files for textures quite often, the internal tga file reader was added to version 7.0. This version had problems with some tga files. This problems are now fixed.


Some of you have already noticed that the evaluation version has a brand new installer that enables installing any product from only one installer (before each product has to be installed separately). With the new versions the new installers are now available also for commercial products.

Because of the new installers there are also new commercial versions of Ab2d.ReaderSvg and Ab2d.ReaderWmf libraries available to commercial users. Those versions contain just small changes made for the new installation process and do not bring any new functionality.

Tags: , ,

Ab3d.PowerToys | Reader3ds

New versions of 3D libraries bring WPF 3D to a completely new level

by abenedik 16. December 2010 18:19

With the release of Ab3d.Reader3ds v7.0 and Ab3d.PowerToys v2.0 a new milestone in 3D programming was reached.

The first version of WPF brought us simplified programming with 3D. With WPF there is no need any more to deal with C++, DirectX and graphics drivers. Now programmers can use xaml and managed code to define the 3D scene. Besides this WPF can use high end graphic cards when they are available and can fallback to software rendering when the computer does not have an accelerated graphics.

Of course WPF does not provide all the features of DirectX, so it is not capable of running high end 3D games. But my customers have already proven that it is very capable of showing very complex 3D scenes with models with several hundred thousands triangles.

But WPF still lacks many features to make programming with 3D easy.

Now with Ab3d.Reader3ds and Ab3d.PowerToys users have the ultimate framework to work with WPF 3D.

The Ab3d.PowerToys includes advanced cameras, camera controllers (rotate and move the camera with the mouse, etc.), 3D objects (Box, Sphere, Cone, etc.), 3D lines, 3D text and classes to simplify using mouse events on 3D objects.

With Ab3d.Reader3ds and Viewer3ds it is possible to define 3D models in almost any 3D modeling application (3D Studio Max, Maya, AutoCad, etc.), save the objects into 3ds file and use the 3D models in your WPF application.

The libraries gives you a complete solution for:

  • creating monitoring systems with 3D models,
  • displaying 3D simulations and mathematical models,
  • displaying 3D models of your products or prototypes,
  • creating designing and configuration applications in reality-like 3D scenes,
  • creating interesting 3D effects,
  • etc.

 

That was a short overview. Now to the details about the libraries and more information about new features.

Viewer3ds

The new version of Viewer3ds application (3ds to xaml converter) that comes with Ab3d.Reader3ds library brings many new improvements.

The application is now using the Ab3d.PowerToys library. Therefore it was really easy to add camera rotation and movement. Among other changes I would also like to mention the new possibility to get detailed information about selected objects (sizes, materials, detailed mesh information, etc.).

 

The Ab3d.Reader3ds library also got many improvements.

The biggest enhancement is great performance improvement - because of optimized algorithm and multi-threaded processing some 3ds files are read 80% faster. But reading some very large 3ds files can still take a few seconds. To improve user experiance it is now possible to get progress reports while reading the file. The samples that came with the library demonstrate how to show progress window on another thread or read the 3ds file on another thread and show the progress on the main thread.

Let me also mention some other important changes:

  • Improved handling of texture files with simplified notifications about missing texture files.
  • Added GetXaml method to Reader3ds class to get formatted xaml text of the read 3ds file.
  • Improved reading FiledOfView and SpecularMaterials.
  • Improved support for running in partially trusted environment.
  • Added Lights collection.

Complete list of changes can be seen here.

 

Viewer3ds

I am really proud of the features and capabilities the Ab3d.PowerToys library. They really bring WPF 3D to a completely new level.

The library makes Visual Studio a simple 3D modeling application as all the 3D objects and cameras that are defined in xaml are immediately seen in designer window. This way it is very easy to arrange the objects, set camera or otherwise define the scene.

Already the previous version of the library had advanced cameras (SceneCamera, FirstPersonCamera, ThirdPersonCamera) that enable setting the camera with simply setting heading, attitude and bank angles and defining some other properties like distance. The cameras can be simply rotated with the mouse or camera control panel. The new version goes further with enabling moving the camera. Now any camera can be rotated and moved around. And it is possible to assign rotation and movement of the camera to any mouse button and to any keyboard modifiers. For example the following two lines of xaml add a SceneCamera to the scene and enable rotationg the camera with right mouse button and moving the camera with right mouse button and alt key pressed:

<cameras:SceneCamera Heading="30" Attitude="-20" Distance="200"/>
<ab3dControls:MouseCameraController RotateCameraConditions="RightMouseButtonPressed"
                                    MoveCameraConditions="RightMouseButtonPressed, AltKey"/>

The previous version of Ab3d.PowerToys already included many basic 3D objects (Box, Sphere, Cone, etc), 3D Lines and simplified mouse event handling on 3D objects.

Besides improved cameras the following are the main improvements of the new version:

  • Added support for 3D text.
  • Improved PolyLines - they are now correctly connected to each other.
  • Added MultiMaterialBox where each side of the box can have its own material.
  • Added CreateFrom method to all Ab3d.Cameras - it can be used to create any Ab3d.Camera from existing WPF's Camera (or camera read from 3ds file with Ab3d.Reader3ds).
  • Added CameraAxisPanel - a predefined panel that shows the axis orientation for the target camera.
  • Added RectangleVisual3D, WireBoxVisual3, WireCrossVisual3D, VerticalPlaneVisual3D and LineArcVisual3D.
  • Added IsVisible property to all 3D models derived from Visual3D.
  • Added CreateWireframe method that takes Model3D to create wireframe from Model3DGroup or GeometryModel3D.
  • Fixed for using in partially trusted environment - before creating custom cursor was not allowed - now a Hand cursor is used instead.
  • BREAKING CHANGE: Fixed Bank - now the positive bank values rotate the camera in the clockwise direction (before the direction was counter-clockwise). For example bank angle 30 means that the Camera is rotated as a head would be bended to the right.

The complete list of changes is really long - it can be seen on Abd3.PowerToys web page.

 

A quick preview of cameras and 3D objects can be seen from two cheat sheets (prepared with WPF; full source code is included with the samples that come with the library):
Cameras cheat sheet
Cameras cheat sheet


Objects cheat sheet
3D Objects cheat sheet

 

The following are a few screenshots (click on xaml link to see the xaml source code):

[xaml] [xaml] [xaml]
 
 
[xaml] [xaml]  

 

To see more screenshots and details about the library see Abd3.PowerToys web page.

 

Ab3d.Reader3ds and Ab3d.PowerToys are separate products, but when the Ab3d.Reader3ds pro library license is purchased, the price for Ab3d.PowerToys library is ONLY 1 USD.

 

I am already planning to add a few new exciting features to the library. If you have any recommendation and other comments you are most welcome to post them to the library’s forum.

 

As usual the new version can be downloaded from User Account page (for commercial users) or from my Downloads page (for evaluation version).

 

PS: For the customers of Ab3d.Reader3ds with expired updates subscription I am preparing a very special offer to renew the subscription – detailed information will be sent to your email in the following days.

Tags: , , , ,

Ab3d.PowerToys | Reader3ds

Business transfered to a new company - AB4D d.o.o.

by abenedik 6. December 2010 21:18

Today is a great day!

After almost a month of dealing with bureaucracy I am happy to announce that today I have made the final step in establishing a new company AB4D d.o.o.

Until today all the products from www.ab4d.com were developed and sold in behalf of Andrej Benedik s.p. – a legal form of a sole proprietor.

Because the business has grown, the limitations of sole proprietor legal form have become too tight. So it was time for a step forward – to establish a real company in a form of limited liability company (d.o.o.).

After registering the company, opening a new bank account, registering for Euro VAT ID, opening new accounts on PayPal and Gate2Shop, adjusting the invoices and other content on web site, today, as the final step, the production web site (www.ab4d.com) was updated. Today the company had made its first breath of air.

Thank you for all your great feedback and support. I will do my best that under the new company your satisfaction will be even bigger.

To begin with I am planning to release a new version of Reader3ds and Ab3d.PowerToys in the next week. The new libraries will make programming with 3D so easy that even your grandma could do it (without even knowing that there are heavy C++ and DirectX books).

 

PS:

Where did the name of the company came from?

The users of the libraries will quicky guess that it came from the names of the namespaces used in my libraries (Ab2d and Ab3d). But wait - in this case the name should be AB5D. Ah, screw math - AB4D sounds better :)

Tags:

Web Page