minxomat

Realtime Node Framework (like Blenders Node Interface)

19 posts in this topic

#1 ·  Posted (edited)

Screenshot

 

 

 

nodes6d10.png

 

 

Description

 

This lets you create bezier nodes between GUI controls. See screenshot for features. This is not an UDF.

 

Download

https://gist.github.com/minxomat/be51ae55cdf25c99c692

Edited by minx
2 people like this

I will answer every single PM, and you are free to ask anything anytime.

Share this post


Link to post
Share on other sites



cool :thumbsup:

Share this post


Link to post
Share on other sites

Hi Minx, this is a great job.Thanks a lot for sharing.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

First, what would one generally use bezier nodes for?

To visualize a flow or connection of elements with different properties. Take a look at the Blender node system. This kind of visualisation is also used in a Color Grading (Davinci Resolve), Music Production (various synths) and VFX apps.

 

And second what is a bezier node?

A bezier connecting two nodes. It's control points are fixed at 50% width or height of the bezier.

Edited by minx
1 person likes this

I will answer every single PM, and you are free to ask anything anytime.

Share this post


Link to post
Share on other sites

Minx, I attempted to change it a bit to make it On Event, but without success.

I added:

 $aMovables[$Bound][0] = GUICtrlCreateButton($sText, $iLeft, $iTop, $iWidth, $iHeight, 0x2000)
 GUICtrlSetOnEvent(-1, "NodeControl")
 

and the NodeControl out of the main loop:

Func NodeControl()
    $cur = GUIGetCursorInfo()
    If Not IsArray($cur) Then Return
    If $cur[2] = 1 Then
        For $nCtrl = 0 To UBound($aMovables) - 1
            If $cur[4] = $aMovables[$nCtrl][0] Then
                $end = GUIGetCursorInfo()
                If Not IsArray($end) Then ContinueLoop
                $dx = $end[0] - $aMovables[$nCtrl][1]
                $dy = $end[1] - $aMovables[$nCtrl][2]
                $iDrawn = 0
                $iTimer = TimerInit()
                Do
                    $end = GUIGetCursorInfo()
                    $aMovables[$nCtrl][1] = $end[0] - $dx
                    $aMovables[$nCtrl][2] = $end[1] - $dy
                    If $aMovables[$nCtrl][1] <= 6 Then $aMovables[$nCtrl][1] = 6
                    If $aMovables[$nCtrl][2] <= 6 Then $aMovables[$nCtrl][2] = 6
                    If $aMovables[$nCtrl][1] + $aMovables[$nCtrl][3] >= ($iGUIWidth - 6) Then $aMovables[$nCtrl][1] = ($iGUIWidth - 6) - $aMovables[$nCtrl][3]
                    If $aMovables[$nCtrl][2] + $aMovables[$nCtrl][4] >= ($iGUIWidth - 26) Then $aMovables[$nCtrl][2] = ($iGUIHeight - 26) - $aMovables[$nCtrl][4]
                    $aMovables[$nCtrl][6] = 0x00FF00
                    $back = $g
                    $g = GUICtrlCreateGraphic(0, 0)
                    GUICtrlSetState(-1, 128)
                    DrawBounds()
                    For $tCtrl = 0 To UBound($aMovables) - 1
                        If $aMovables[$tCtrl][5] <> "" Then
                            $aNodes = StringSplit($aMovables[$tCtrl][5], ",", 3)
                            For $nConnection = 0 To UBound($aNodes) - 1
                                If Not IsNodeInObject($aNodes[$nConnection], $tCtrl) Then DrawConnection($tCtrl, $aNodes[$nConnection], $aMovables)
                                $iDrawn += 1
                            Next
                        EndIf
                    Next
                    GUICtrlDelete($back)
                    GUICtrlSetPos($aMovables[$nCtrl][0], $aMovables[$nCtrl][1], $aMovables[$nCtrl][2])
                    $aMovables[$nCtrl][6] = 0xFFFFFF
                Until $end[2] = 0
            EndIf
        Next
    EndIf
EndFunc   ;==>NodeControl

Share this post


Link to post
Share on other sites

Why would you do that? You can use OnEvent just fine with the handler in the main loop. If the user doesn't click anything, nothing will be redrawn (== no CPU time wasted).


I will answer every single PM, and you are free to ask anything anytime.

Share this post


Link to post
Share on other sites

It is just to combine with a program I made wich is actually On Event driven, to show the relationship among groups and users.

Share this post


Link to post
Share on other sites

No problem. You can have a Loop while using OnEvent. OnEvent only affects GUICtrl message handling.


I will answer every single PM, and you are free to ask anything anytime.

Share this post


Link to post
Share on other sites

OK, I'll make it.

Thanks a lot minx.

regards.

1 person likes this

Share this post


Link to post
Share on other sites

Very cool Minx!  I noticed the CPU is heavy when dragging nodes.  I inserted a sleep(10) (on line 120) after the for loops and it does not seem to have any major lag effect, but drops the CPU usage significantly.  I know a band-aid like this isn't desirable, but just thought I'd try and see what happens.  Regardless, Well done!

 

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

-snip-

Well, I altered the script already to make it easier to handle for the CPU. Eventually, it completely broke down under the load of a realistic Node layout. Thus, I'm redesigning it using OpenGL and chunk-based refreshing now.

Before (pure AutoIt (also no GDI+)):

old3e08.png

After (early prototype, using a better spring algorithm). OpenGL

new5b38.png

Edited by minx

I will answer every single PM, and you are free to ask anything anytime.

Share this post


Link to post
Share on other sites

Before (pure AutoIt (also no GDI+)):

 source share please

Share this post


Link to post
Share on other sites

Before (pure AutoIt (also no GDI+)):

 source share please

It's a mess. Not my usual mess, a messy mess. Using 5 Nodes already pushes the limit. I implemented auto-resizing canvas, canvas dragging, Node selection etc. before givin up on this approach. The new version won't be much different, but the performance will be (a whole) lot better.

1 person likes this

I will answer every single PM, and you are free to ask anything anytime.

Share this post


Link to post
Share on other sites

Hello Minx,

This is really great !!  :king:

I see lot's of applications using this in practice.

Speed and performance improvements are always welcome. 

I can imaging that the GDI wizard (UEZ) can be of big help here.

Great addition for AU3.

Thanks a lot for sharing, looking forward for the next release

rgds

ptrex

Share this post


Link to post
Share on other sites

Nah, OpenGL is the way to go here. There are inbuilt tools for chunk management. GDI+ is slower than GDI in most cases, which is why it doesn't make much sense here.


I will answer every single PM, and you are free to ask anything anytime.

Share this post


Link to post
Share on other sites

Very cool script, Minx.  ^_^


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

@ minx,

Hi, I was amazed when I came across your posting. :sorcerer:

I didn't know that AutoIt was capable of doing this sort of thing at all.

It seemed like it may be the answer to what I have been looking for for some time now.

I downloaded it and played about with it and then I realised "Whoa! I am like a caveman playing about with a smartphone, I can see what it is doing but am unable to comprehend how it does what it does." :(

But picking my way through it I tried to see if it would do as I would like it to and it wouldn't (or more probably, I stuffed up and cannot get it to do what I want!)

 

Perhaps you could tell me if the following is possible? :idea:

* To have the bezier curve change colour depending upon which direction the link goes in.

 i.e. in your example clicking on 'Render Framework' node lights up green to 3 nodes (SunX, AmbientLight &SunRed) going 'down' from 'Init' but if I click on any of the 3 nodes they go down further (green) and while I would still like to show those further 'down' links as green etc I would also like to show the 'upward' (back) links as say red or what ever.

My Very Limited understanding of the way it behaved when I tinkered with it suggests that it can only display one-way links.

I would need it to be able to display 3 types of links (3 colours) 1 for 'Up' links, 2 for 'Down' links & 3 for (Sideways/Parallel) links to a node that has an equivalent weight or value as the node being clicked on.

e.g. If it was for instance to display a family tree like the following:

[Mam]----[son1]----[Grandson]

|                  |

|              [son2]

[Dad]

Then Clicking on:

Mam should link blue to Dad, green to Son1 & Son2

Dad should link blue to Mam, green to Son1 & Son2

Son1 should link green to Grandson, Red back to Mam & Dad, then blue to Son2

(My usage will Not be for family trees but it seemed the simplest example of what linking I would like to perform.)

Hopefully I have explained it clearly enough.

* If the above is possible, how difficult would it be to create a UDF that could be called with the details and it would then display the linkages and return the ID of the node clicked on?

Say you had the above data in an array:

  ID     txt       Up       Same       Dwn

+----+------+-------+-----------+---------+

|   0  | Mam|          |       1      |   2, 3    |

+----+------+-------+-----------+---------+

|   1  | Dad |          |       0      |   2, 3    |

+----+------+-------+-----------+---------+

|   2  |Son1|   0, 1 |        3     |     4      |

+----+------+-------+-----------+---------+

|   3  |Son2|  0, 1  |        2     |             |

+----+------+-------+-----------+---------+

|   4  |Gson|     2   |               |             |

+----+------+-------+-----------+---------+

Then calling the UDF with array ID = 2 would read the array row 2 and populate the node freamework with the title 'Son1' and the other nodes 0, 1, 3, & 4. and colour the link apporpriately.

Thank You for the script and for letting me know if the above is possible.

br. DeMo.


Quote of the week:"BASIC programmers never die, they GOSUB and don't RETURN." -- UnknownWisdom of the ages:

  

  • I'd be unstoppable... if not for law enforcement and physics.
  • Marriage, the number 1 cause of divorce.
  • Don't steal... the government hates competition.
  • Irish Government Motto: We’ve got what it takes to take what you’ve got.
  • Birthdays are good for you. Statistics show that the people who have the most live the longest.
  • Failure is not an option. It comes bundled with your Microsoft product.-- Ferenc Mantfeld
  • If you learn from your mistakes, then why ain't I a genius?! -- Anonymous
  • Remember, live every day as if it was your last day! one day you will be right.
  • How is it one careless match can start a forest fire, but it takes a whole box to start a campfire?
  • Sure my system is secure, it just locked up again.
  • I haven't lost my mind; I have a tape back-up somewhere.  ~Author Unknown

Share this post


Link to post
Share on other sites
It is absolutely wonderful.
Surprising as it is simple and small.
Many times I thought about something like that, but there was no time to implement.
 
Thanks for sharing.
5*
 
Best regards,
mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now