Forum > LCL

Draw pathing line connecting two forms?

(1/2) > >>

I've been working with visual node-based software, it's so much nicer for visualizing connections since it, well, shows the connections that your UI has with the data itself. Rather than spreadsheet style IDs, which has 0 visualization of the connections.

This would actually be doable, except for 2 things:

1. There's no documented way of drawing a connection between two UI forms
2. There's no way of doing the above and making the line path around other forms

The closest I've been able to find is the Eye Candy Controls' TECScheme graph view, but that's a self-contained UI that just does a few floating shapes with its own connections. Rather than being something we can reuse with forms. E.g, drawing a line connection between a TEdit and a TCheckBox.

Here's an image of an existing program (the dialogue editor in Skyrim's Creation Kit software) showing the lines I'm talking about:


Other examples are Quadspinner's Gaea, Blender/3DS Max/Maya's material editor, Unreal Engine's blueprints.

Just 'Spitballing' here... Maybe it's possible to concuct some kind of collaboration between fpc/laz & "Castle Game Engine"?!?
CGE is written in pascal and can do all sorts of cool things...
I'm thinking, maybe ...just maybe  :D
Anyway, just 2 cents worth
Regards Benny

Man that'd be awesome if I had the skillset for that. But I don't think someone who is barely able to cludge together a couple TEdits is ready for something like that. Maybe one day!

I've been doing some reading, and apparently we can draw on the default window, Form1? By using Form1.Canvas. Haven't gotten it to draw the lines unfortunately. Here's what I've come up with:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls; type   { TForm1 }  TEditArray = array of TEdit;  TForm1 = class(TForm)    procedure FormShow(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormShow(Sender: TObject);var  arrayEdit: TEditArray;  editCurrent: TEdit;  iCounter, iPosX, iPosY, iDestX, iDestY: integer;begin   SetLength(arrayEdit, 6);  for iCounter := 0 to 5 do begin     arrayEdit[iCounter] := TEdit.Create(Form1);    editCurrent := arrayEdit[iCounter];    editCurrent.SetBounds(10 * (iCounter * 10), editCurrent.GetDefaultHeight * iCounter, 50, 30);    editCurrent.Text := 'Test! - ' + IntToStr(iCounter);    editCurrent.Parent := Form1;   end;   for iCounter := 1 to Length(arrayEdit) - 1 do begin       editCurrent := arrayEdit[iCounter - 1];      iPosX := editCurrent.Left + editCurrent.Width;      iPosY := editCurrent.Top + (editCurrent.Height div 2);       editCurrent := arrayEdit[iCounter];      iDestX := editCurrent.Left;      iDestY := editCurrent.Top + (editCurrent.Height div 2);       Form1.Canvas.Pen.Style := psSolid;      Form1.Canvas.Pen.Color := clBlack;      Form1.Canvas.Line(iPosX, iPosY, iDestX, iDestY);      //ShowMessage('PosX = ' + IntToStr(iPosX) + ', PosY = ' + IntToStr(iPosY) + ', DestX = ' + IntToStr(iDestX) + ', DestY = ' + IntToStr(iDestY));      Form1.Canvas.MoveTo(0,0);      Form1.Invalidate;   end; end; end. 
Really basic, just spawn a bunch of TEdits, reposition them, and draw lines. But they don't show, even with/without Form1.Canvas.Refresh or Form1.Canvas.Invalidate.

My idea right now is I'll just do basic 2 point lines, and redraw them all whenever one of the forms are changed.

A tree-graphing tool comes with Lazarus, the TLvlGraphControl. I used it to draw the class hierarchy of the series in TAChart ( - see attached project.

Maybe this simple code can give OP some ideas:,41036.msg284131.html#msg284131

The code in the link above has a bug, it will crash on certain conditions.


[0] Message Index

[#] Next page

Go to full version