Wednesday, 24 February 2010

Thundax P-Zaggy v1.2 beta

This week I've been stressed-out in some projects that I'm doing (I'll talk about them this year, but for now it's like a secret - it also depends on the confidentiality agreement that I've signed to keep these projects hidden until they are finished). That's a big deal because I'm preparing a lot of documentation about them but it's impossible to publish it. Anyway, we'll talk about this other day, but not so far.

In this post I'm writing about the next release of Thundax P-Zaggy v1.2. I know that I've been releasing versions very fast, but I need this program done (means tested and documented) by the end of the year, in order to go on with my future plans. This new version is an improvement of the last one with a lot of refactoring. I've changed all the property system applying a template method pattern.

Now, if we take a look at the properties, we can notice:

There are new properties and I've tweaked the buttons to give a better presentation to the application. Now all the property forms have this new image:

I've also changed some forms to give the user more information:

And I've improved the visualization of the "load project" where the user can see a little preview of the document. Now the user can guess what's inside at a glance:

I hope you enjoy!.

Related Articles:

OLE Automation with Delphi part I

Today I'm going to publish about a little application I've been developing recently for one of my clients. This little application pretends to use the Microsoft word OLE Automation to build a document with incrustation of images in it. But Why have I used OLE automation instead of working with the TLB functionality?. That's simple, because working with the OLE can help me with any of the Microsoft documents, and I recommend to work with the TLB when you are sure that you'll be working with a concrete package of Microsoft Office. For example, with the Office 2007, you can use the version 12.0 of the Object Library for your own purpose (but having in mind that you have to follow the license rules) .

The major problem working with OLE is that's difficult to know how exactly do the things that you want. In my case I wanted to insert some stretched pictures inside a word document in a correct position. After seeking out all the information, I've managed to build this little application that will help you to encrust images inside the document.

If we load all the images and try to generate the document, the selected images will be encrusted like the next image:

Notice that It works with word 2003 or 2007 (but I've found some problems with the 2007). Anyway, the little code for encrust an image to a word document would be like this:

procedure EncrustImage();
   WordApplication, WordDocument, CurrentPic: Variant;
   cnt, rgn: variant;
       WordApplication := CreateOleObject('Word.Application');
       WordDocument := WordApplication.Documents.Open(Edit1.Text);

       //get to the last position of the caret
       cnt := WordDocument.Characters.Count;
       cnt := cnt - 1;
       rgn := WordDocument.Range(Start := cnt, end := cnt);

       if path1.text <> '' then
           CurrentPic := WordApplication.ActiveDocument.InlineShapes.Item(1);
           Currentpic.Height := 170.0; // points
           Currentpic.Width := 225.0;

       cnt := WordDocument.Characters.Count;
       cnt := cnt - 1;
       rgn := WordDocument.Range(Start := cnt, end := cnt);

       if path2.text <> '' then
           CurrentPic := WordApplication.ActiveDocument.InlineShapes.Item(2);
           Currentpic.Height := 170.0; // points
           Currentpic.Width := 225.0;

       cnt := WordDocument.Characters.Count;
       cnt := cnt - 1;
       rgn := WordDocument.Range(Start := cnt, end := cnt);
       rgn.Text := chr(13) + chr(10);

       WordDocument.SaveAs(FileName := Edit2.text + '\out' + ExtractFileName(Edit1.text), AddToRecentFiles := False);

You can find this little application here:
Related Articles:

Sunday, 21 February 2010

Augmented Reality, immersive cutting edge Technologies

On 22nd January, took place the 10th Innovation Forum theme based on Augmented Reality (AR), where a team of experts presented the possibilities and advantages of this new technology as well as a few cases or actual experiences developed with it. (I'm sorry because the video is in Catalan)

You can find a more information about the forum here and here.

Here I've posted the different videos showed at the conference:

Another interesting videos showing the application of the Augmented Reality:

Friday, 19 February 2010

Thundax P-Zaggy v1.1 beta (Bugs Fixed)

After few days working with the Application I've discovered some interesting bugs that needed to be fixed as soon as possible in order to increase the productivity of using the program. That's why I'm releasing the version 1.1 with very good improvements. I've also tested the efficiency of the drawing system creating a graph with more than 400 nodes and 800 edges. And it was totally successful without any feeling of loosing power. You can see the list of bugs into the bug tracker, and add one if you've noticed that anything goes wrong.

In the next video you'll see the power of the application trying to solve a large of complicated connected nodes that are composing a net. You can test by yourselves by downloading this simple test "test.txt" from SourceForge and going to Graph -> Graph Script Implementator and copying the downloaded list. After that you only have to click on the red bolt, but before that be sure to have configured correctly all the parameters referring to the layout system.

As for this example, my configuration is the following one:

I've also fixed the correct drawing of the imported images. Now you'll see the images with a transparent background:

I've changed the background colour to one that's known, for example fuchsia, and then I only need to get the pixel located in the [0,0 coordinates] and use it as the transparent colour. After that, we only need to scan the picture and change the colour of the pixel.

The coding of the transparent image would be something similar to this:

if (FImage <> '') then
Bitmap := Graphics.TBitmap.Create;
Bitmap.LoadFromFile(ExtractFilePath(ParamStr(0)) + Self.FImage);
Bitmap.Transparent := true;
Bitmap.TransparentColor := Bitmap.canvas.Pixels[0, 0];
Bitmap.TransparentMode := tmFixed;
canvas.Draw(ClientToGraph(Vertex1).x, ClientToGraph(Vertex1).y, Bitmap);
I hope you enjoy!. Don't forget to leave a comment if you've tested the application!.
  • Related Articles:
Thundax P-Zaggy v1.0 Released!.
Automation Object Library for Vijeo Citect.

Tuesday, 16 February 2010

Thundax P-Zaggy v1.0 released!

I'm so proud to announce the release of my last application Thundax P-Zaggy v1.0 that implements the VLO Framework v2.0. You can get it from sourceforge download page. I'm working on the user documentation that will help you with the basic parameters of the program. In few weeks I'll release a little presentation that explains all the evolution of the application and where the idea comes from. This new version that merges the working of the Thundax Box Manager and Test Canvas Framework lets you work with the next modules:
  • Graph module (properties and layout scripting)
  • Algorithm module (Dijkstra)
  • Path module (Algorithm to find the path graph)
  • Vijeo Citect module (Scan a vijeo citect page)
  • Export module (module of data exportation)
Every of these modules have their own purpose, and are created to fulfil every of the previous requirements that it was aimed to. The final goal of the project is to scan a vijeo citect scada page with all the objects instantiated and then with my application, get all this objects that are modelling a system (this would be, for example, a transport routing system). When I have all these objects, I can work with them because I've translated from one side to the other, and now I can create a little graph and calculate all the different routes or paths that exists into the modelled system. It's difficult to explain, but you'll understand better with the following videos.

Tuesday, 9 February 2010

Parsing and drawing molecular structures with delphi part II

Today I've released the last version of my program with several changes into the graph script implementation. This new version has a little windows with a simple syntax highlighting system with the usually tokens that I use in my script. The scripting language is very easy to use and very intuitive instead of only writing numbers with no sense. Now we can create and manipulate the way the graphs are created by simple commands. I'm working on the syntax checker that will tell you the error line and a little description of the problem.

Now we can write:

layout.node(x).ToNode(y).parameters := [EdgeType = SimpleArrowEdge, SizeBox = 20, LineColor = clRed, PenWidth = 2];


layout, is the canvas where we need to create our node or to look for our node. node(x) is the first node to need to be created and this will be connected to toNode(y). We can finish this sentence here (with a semicolon mark ";") or going on calling the parameters. Where we have, the EdgeType, SizeBox, LineColor and PenWidth parameters. On the EdgeType parameter, we can use this list:
  • SimpleEdge
  • SimpleArrowEdge
  • SimpleDoubleArrowEdge
  • SimpleDoubleLinkedArrowEdge
  • DottedEdge
  • DottedArrowEdge
  • DottedDoubleArrowEdge
  • DottedDoubleLinkedArrowEdge
Each of one of these edges, will draw a different kind of component into the layout. For the SizeBox we can specify an integer number in pixels to build or resize the length of every box inside the command. The line colour is a typical delphi constant like clRed, clBlue, clYellow, etc. and the last property as an integer number as well as the SizeBox, PenWidth, that will change the width of the line drawn.

This script will generate the next diagram:

I'll try to finish all the things that I have in mind this week in order to focus on other parts of the application. Due to the last petitions into the post "Automation Object Library for Vijeo Citect", I'm being forced to show you (willingly) my last achievements into this field. I'm still merging my last application "Thundax Box Manager" with the last version of my "Canvas test Framework", and I'm very keen on releasing the new application "Thundax P-zaggy" that will contain all the modules to work with graphs.

You can now download the last released version from SourceForge:
I hope you enjoy!.

Friday, 5 February 2010

Parsing and drawing molecular structures with delphi part I

After being very busy in several projects that I'm enrolled. I've managed to get some time extra to go on in my little project. This week I've been working on a little scripting language that let me build different structures by using it. I still have to fix some bugs and I have a very long list of new features. By using this little structure, we can modify the different nodes and edges that we are building. For example if we have this:

node(1).ToNode(2).parameters := [EdgeType = SimpleArrowEdge, SizeBox = 20, LineColor = clRed, PenWidth = 2];
node(2).ToNode(3).parameters := [EdgeType = SimpleArrowEdge, SizeBox = 20, LineColor = clRed, PenWidth = 2];
node(3).ToNode(4).parameters := [EdgeType = SimpleArrowEdge, SizeBox = 20, LineColor = clRed, PenWidth = 2];
node(4).ToNode(5).parameters := [EdgeType = SimpleArrowEdge, SizeBox = 20, LineColor = clRed, PenWidth = 2];
node(5).ToNode(6).parameters := [EdgeType = SimpleArrowEdge, SizeBox = 20, LineColor = clRed, PenWidth = 2];
node(6).ToNode(1).parameters := [EdgeType = SimpleArrowEdge, SizeBox = 20, LineColor = clRed, PenWidth = 2];

The application will build the next structure:

Well, at this point, how can we manage molecular structures? In this case, we only need the adjacent list and parse it to let the application force the position by using its force-directed graph layout. It's amazing the all kind of structures that the system can process and work with.

Tuesday, 2 February 2010

Dijkstra algorithm with Delphi

Today I'm going to show you the improved algorithm to find the shortest path using Dijkstra. My older application Thundax Box manager was implementing this algorithm but with several restrictions. Now, with the release of the TestFramework v2.0.0 build 745 you can test this new functionality. I also fixed other bugs, and I would be grateful that if you find any bug, report it to the bug tracker into the Sourceforge. The same for a feature request or a support request. Sometimes it is difficult to find bugs even using TDD. I've checked all my classes but sometimes I skip part of them in order to focus on the part I'm interested in.

Anyway, in this version you would be able to:
  • Draw a graph (n-connections).
  • Connect the nodes and add some weight to the edges.
  • label the nodes.
  • set multiple destinations (Origin and Target/s).
  • calculate the shortest path using Dijkstra.
With all of this, we can do the following:
We can mark the initial node (green) and the final nodes or destination nodes (fuchsia) and then, calculate the shortest path by going to Algorithms -> Apply Dijkstra Algorithm.