TADiagram - Lazarus Library lazarus / 39-Graphics ---------------------------------------------------------------------- Researching · 2020-02-01 04:16 Want to create a Diagram Library for Lazarus. Initial requirements: SHAPES                    : FlowChart, mind map, PROPERTIES             : texts, comments for nodes and links, SAVE AS/IMPORT      :  TXT, XML, CSV Any suggestions? Any unwaited, unobvoius problems from your experience... Greately appreciated: 1. high level concepts: properties of a "perfect library" //? entry points, interfaces... 2. low level concepts: requirements to make the library HW efficient // and OS-portable in what depends on code, not on compiler 3. 3D advices: to make it 3d capable in the future. 4. possible open source candidates and/or other libraries. ---------------------------------------------------------------------- HeavyUser · 2020-02-01 09:51 there where two components posted in this forums if you search for them. 1) was a port of an old delphi library (simple graph, draw objects or something) 2) the other a new library written from one of the forum attendants. Sorry I can't remember more details, search the forums. ---------------------------------------------------------------------- Researching · 2020-02-01 10:05 As far as understand for now... (supposed to be converted to OOP class hierarchy): Needed objects: entity [,,,,]; entity.type    ::=   |||; content         ::=   ,,; diagram        ==    diagramField;              //as drawing area, *recursive package        ::=   set; shape           :=   [*entity*\+,]; link               :=   [*entity*+,]; // shape=: structure(value | M ) | comment ----------- Any suggestions on this? ---------------------------------------------------------------------- HeavyUser · 2020-02-01 11:15 Quote from: Researching on February 01, 2020, 11:05:04 amAs far as understand for now... (supposed to be converted to OOP class hierarchy): Needed objects: entity [,,,,]; entity.type    ::=   |||; content         ::=   ,,; diagram        ==    diagramField;              //as drawing area, *recursive package        ::=   set; shape           :=   [*entity*\+,]; link               :=   [*entity*+,]; // shape=: structure(value | M ) | comment ----------- Any suggestions on this? simple graph is a single component with the ability to draw a number of objects move and resize them as needed using the mouse. There is no support for specific logic entities, uml, erd or flaw charts. It has the ability to link them through a link object but since it is based on the "simple graph" theory where link back to ones self is not allowed you can't use it to link back to any type of graph. It supports a number of different shapes for graph and multi line links but thats about it. Draw objects is the opposite a number of different shapes that can be moved/resized etc at run time, with a couple of specific links (lines between them) like L shaped link Z shaped link etc but no container (ee diagram) you need to provide your own, a simple Tscrollbox should do the trick. If I remember correctly it has already been used on a open source flaw charting application, I think there is a link for the application in this forum somewhere. I can not search now my self but if you can't find anything post a request and I will try to locate the app from home later today. As for the requirements of the diagramming you seem to ask for input I would say start with a very specific type of diagram something simple like an hierarchy diagram of shorts with very specific shapes and roules of interactivity as an example 1) supported shapes are circles and rectangles 2) they auto center on the working area, 3) the children should auto auto center to their parent etc. Do not try to define a generic structure at this point just the simplest you might need and then build on top of it as you go along. Good luck. ---------------------------------------------------------------------- wp · 2020-02-01 12:31 The name of your diagram library, TADiagram, reminds me that the same exists within TAChart. Alexander Klenin, the former maintainer, started it with some units, but I think it is not complete - I never used it. Maybe you can find out how to use it and what is missing. ---------------------------------------------------------------------- Researching · 2020-02-02 13:17 Wp, do you mean that there is some unfinished functionality in TAChart? To every one: what could be more promising?: * build my own base for library? * build on top of some one's source? ---------------------------------------------------------------------- HeavyUser · 2020-02-02 17:20 Quote from: Researching on February 02, 2020, 02:17:42 pmTo every one: what could be more promising?: * build my own base for library? * build on top of some one's source? I would choose on top of an existing library that gives me the most abilities I need and the freedom to add/remove features easily. From the known libraries I would go with something like the simple graph. It has the base to be extended in both directions ee drawing engines/canvas etc and the entities, links. As far as I remember it supports saving/loading, copy/paste, bezier links and export in bitmaps. It would be easier to focus on your entities, logic etc. Printing might be as simple as exporting the graph to bitmap and sending that to the printer. Well you get the idea I hope but most important is what will make you more productive not only today but in the future too ee is it faster to reinvent the wheel or learn to balance on some one else's wheel. ---------------------------------------------------------------------- sstvmaster · 2020-02-02 18:39 @Researching Look at here https://svn.freepascal.org/cgi- bin/viewvc.cgi/trunk/components/tachart/?root=lazarus, there are 3 files: - tadiagram.pas - tadiagramdrawing.pas - tadiagramlayout.pas It's all in TAChart. ---------------------------------------------------------------------- nsl · 2020-02-03 14:48 Researching, you may also like to look at the TECSheme control in the Eye-Candy controls package https://wiki.lazarus.freepascal.org/Eye- Candy_Controls#TECScheme ---------------------------------------------------------------------- PeterEvans · 2020-02-03 23:12 Hello Researching, Here are some of my ideas for a general purpose diagram library. SHAPES : Square, Rectangle, Circle. DIAGRAM : Flow Chart, Mind Map, Family Tree. SAVE AS/IMPORT : TXT, XML, CSV, JPG, PDF. (1) I would like to be able to create my diagram programmatically. Then display it. I would like to define the dimensions of the Shape. For example, 100 pixels wide. (2) I would like to see shapes on the screen and be able to select them. (3) I would like to be able to create my own shape and be able to add it to the screen so that the user can select it. For example, a simple Square shape in which I place the text %NAME% At run time I would substitute a person's name into the square. (4) All text to be Unicode. The names of the shapes can be Unicode. For example, Japanese text, Russian text. (5) Connections between shapes. Consider a simple Square shape. I want a connection at top centre, right centre, bottom centre, left centre. I want the connection to be a single line or double line. Better still to be of varying widths. ---------------------------------------------------------------------- HeavyUser · 2020-02-05 05:52 Quote from: PeterEvans on February 04, 2020, 12:12:31 amHello Researching, Here are some of my ideas for a general purpose diagram library. SHAPES : Square, Rectangle, Circle. DIAGRAM : Flow Chart, Mind Map, Family Tree. SAVE AS/IMPORT : TXT, XML, CSV, JPG, PDF. (1) I would like to be able to create my diagram programmatically. Then display it. I would like to define the dimensions of the Shape. For example, 100 pixels wide. (2) I would like to see shapes on the screen and be able to select them. (3) I would like to be able to create my own shape and be able to add it to the screen so that the user can select it. For example, a simple Square shape in which I place the text %NAME% At run time I would substitute a person's name into the square. (4) All text to be Unicode. The names of the shapes can be Unicode. For example, Japanese text, Russian text. (5) Connections between shapes. Consider a simple Square shape. I want a connection at top centre, right centre, bottom centre, left centre. I want the connection to be a single line or double line. Better still to be of varying widths. Simple Graph supports all all of them it comes with a demo program that show cases the designer. I think you can find it on github or the online package manager. ---------------------------------------------------------------------- Researching · 2020-02-05 10:18 After PeterEvans: SHAPE EDITOR + SHAPE BASKET//WITH CATHEGORIES + RECENT SHAPES BASIC: Circle, Polygon LINK    EDITOR + LINK    BASKET//WITH CATHEGORIES + RECENT DIAGRAM STRUCTURES EDITOR DIAGRAM STRUCTURES BASIC: Flow Chart, Mind Map, Tree SAVE AS/IMPORT :XML, CSV, TXT, (ACTUALLY - INTERNAL FORMATS) EXPORT : *.ODT(!IMPORTANT), JPG, pdf. // sorry: either there is already a PDF writing library, which I just include, or this functionality will lack. After sstvmaster, HeavyUser, nsl Will be taken to consideration:  https://svn.freepascal.org/cgi- bin/viewvc.cgi/trunk/components/tachart/?root=lazarus, there are 3 files: - tadiagram.pas - tadiagramdrawing.pas - tadiagramlayout.pas SimpleGraph https://wiki.lazarus.freepascal.org/Eye-Candy_Controls#TECScheme ---------------------------------------------------------------------- PeterEvans · 2020-02-05 23:49 Thank you HeavyUser and Researching for your responses. I found under a Lazarus Package - EvsSimpleGraph. This is based on TSimpleGraph v2.80 by Kambiz R. Khojasteh. Going to http://www.delphiarea.com/products/delphi- components/simplegraph/ one finds that is at v2.91 of 25 Jan 2014. On 2 Feb 2014 Kambix Khojasteh stated  "I am sorry but I have no plan to extend SimpleGraph. It is a while that I’ve stopped programming in Delphi. I only maintain the components/packages on this site.". When was EvsSimpleGraph updated? Unfortunately the Lazarus Package page does not give the release date. This would be a useful addition to the Lazarus Package page. Does EvsSimpleGraph have the changes v2.80 through 2.91 of TSimpleGraph? Unfortunately I do not know. ---------------------------------------------------------------------- HeavyUser · 2020-02-06 00:50 Quote from: PeterEvans on February 06, 2020, 12:49:27 amThank you HeavyUser and Researching for your responses. I found under a Lazarus Package - EvsSimpleGraph. This is based on TSimpleGraph v2.80 by Kambiz R. Khojasteh. Going to http://www.delphiarea.com/products/delphi- components/simplegraph/ one finds that is at v2.91 of 25 Jan 2014. On 2 Feb 2014 Kambix Khojasteh stated  "I am sorry but I have no plan to extend SimpleGraph. It is a while that I’ve stopped programming in Delphi. I only maintain the components/packages on this site.". When was EvsSimpleGraph updated? Unfortunately the Lazarus Package page does not give the release date. This would be a useful addition to the Lazarus Package page. Does EvsSimpleGraph have the changes v2.80 through 2.91 of TSimpleGraph? Unfortunately I do not know. I have no idea but this is the wrong question. What do you need that is not supported by the component and is that feature part of the newer version? ---------------------------------------------------------------------- Researching · 2020-02-06 20:06 Inspiring replies, colleagues. What I'm up to: begin really get introduced to meant packages. Question: what is the best or just efficient approach of investigating unknown code? In the past, what I did: use refactoring features to rename semantically every one identifier. Rather boring and time-consuming task. Is there any better approach or a way to do this quickly? ---------------------------------------------------------------------- Researching · 2020-02-06 21:25 Another point is: Ifthere are many entities on the drawing space, what approach is preferable for placing of each? 1. drawing space knows of placement 2. Each object knows his place.. What pattern of OOP seems to be the most efficient for this task? ---------------------------------------------------------------------- HeavyUser · 2020-02-07 07:07 Quote from: Researching on February 06, 2020, 10:25:35 pmAnother point is: Ifthere are many entities on the drawing space, what approach is preferable for placing of each? 1. drawing space knows of placement 2. Each object knows his place.. What pattern of OOP seems to be the most efficient for this task? both approaches are valid for different reasons. an ERD diagram requires that each entity knows its place and can be moved around freely. An auto balancing hierarchical diagram or a mind map needs to be able to place the entities in the correct position and stay there the user can only influence its position in the list not on the screen so moving with the mouse will actually move it between items on the list or between different lists that means that the position is calculated every time a change is made or a draw is required depending on the design. So the middle solution is: each entity saves its own position on screen and a mechanism must be put in placed to restrict or translate the movement of each entity and update the entities internal position variables. ---------------------------------------------------------------------- HeavyUser · 2020-02-07 07:07 Quote from: Researching on February 06, 2020, 10:25:35 pmAnother point is: Ifthere are many entities on the drawing space, what approach is preferable for placing of each? 1. drawing space knows of placement 2. Each object knows his place.. What pattern of OOP seems to be the most efficient for this task? both approaches are valid for different reasons. an ERD diagram requires that each entity knows its place and can be moved around freely. An auto balancing hierarchical diagram or a mind map needs to be able to place the entities in the correct position and stay there the user can only influence its position in the list not on the screen so moving with the mouse will actually move it between items on the list or between different lists that means that the position is calculated every time a change is made or a draw is required depending on the design. So the middle solution is: each entity saves its own position on screen and a mechanism must be put in placed to restrict or translate the movement of each entity and update the entity's internal position variables. ---------------------------------------------------------------------- wp · 2020-02-07 09:23 Maybe not exactly what you need, but it should be mentioned that a similar tool, TLvlGraphControl, is installed in the IDE by default, palette "LazControls". It is used to display the "Package Graph" (menu "Package"). Rather intimidating, I admit, but there is a tutorial on http://www.pp4s.co.uk/main/tu-form-level-graph.html from which I learned to create the TAChart class hierarchies shown on https://wiki.lazarus.freepascal.org/TAChart_documentation#Series.