Structured Graphics in guiserver

Guiserver, GTK-server, OpenGL, PostScript,
HTML 5, MIDI, IDE

Structured Graphics in guiserver

Postby Gaius » Mon Mar 29, 2010 9:43 pm

Hi everyone,

I'm returning to programming after a break of many years in order to scratch an itch (as they say) in my current non-technical position.

Basically, I want to build an application that will allow me interactively to create and edit large directed acyclical graphs. The nodes of the DAG represent objects (of a variety of different classes) and the arcs the relationships between them.

Last time I did any professional programming it was in C, with the graphics implemented using GKS (well that dates it, doesn't it!). I was looking for a programming environment that is clean, elegant and productive and came across newLISP. In particular I've was impressed by the quality of its documentation (many thanks to Cormullion et al.) in comparison to so many other languages and projects.

What I'm concerned about - and the real thrust of this ramble - is whether Guiserver is appropriate for building interactive graphics? Reading the documentation gs:canvas seems very low level. Is there a graphics programming toolkit that sits on top of it? Three things spring to mind:

(1) GKS (and I believe also OpenGL, although I've never used it) provided a means of establishing "world co-ordinate" systems, transforming them to "normalised device co-ordinates" and setting up "viewports" that were windows into NDC space. Graphic primitives could also be clipped to these viewports.

(2) GKS provided "segments" comprising lists of primitives that could be transformed collectively as a single object.

(3) GKS could feed graphical events directly into the application event queue - for example a mouse click inside the canvas would be pre-processed to determine if location corresponded to a graphics segment and, if so, a "pick event" returned rather than just the device co-ordinates of the mouse.

I know that newLISP has a binding to GLUT, which would I think do the job, but can GLUT be bound to gs:canvas?

I'd be most grateful for comments and suggestions, including entirely different strategies. I did think of trying an AJAX interface using SVG, but learning both newLISP and Javascript seemed a bit over the top and pouring out screeds of XML everytime something needed redrawing seemed horribly inefficient. Again, this may just be ignorance.

Thanks in advance for your help.
Gaius
 
Posts: 2
Joined: Mon Mar 29, 2010 8:58 pm

Re: Structured Graphics in guiserver

Postby Lutz » Tue Mar 30, 2010 5:36 pm

NewLISP 's Java based Guiserver (with gs:canvas) is well suited for interactive graphics for low to medium speed. If you need higher performance, e.g. for games or 3D, try interfacing with OpenGL/GLUT, there is an example here:

http://www.newlisp.org/syntax.cgi?downl ... mo-lsp.txt

also included in the examples directory of the source distribution.

If you are on Windows, Mac OS X, Linux or any other Unix, you should also consider GTK. There are examples here:

http://www.newlisp.org/downloads/GTK/

Last not least you could interface with Tcl/Tk:

http://www.newlisp.org/index.cgi?page=Tk_and_newLISP

Also linked from:

http://www.newlisp.org/index.cgi?Tips_and_Tricks

For your application, I suggest starting with Guiserver, part of any of the binary distributions. It gives you an easy to program high level 2D API, and your application can run out of the box on all major platforms. You find many programming examples in the Help menu option, when running newLISP-GS.

Using the OpenGL or GTK C-libraries requires good C knowledge when using newLISP 'import' to interface with the C-library.
Lutz
 
Posts: 5258
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: Structured Graphics in guiserver

Postby cormullion » Tue Mar 30, 2010 5:47 pm

Hi Gaius! (I only did the Introductory tutorial on wikibooks - everything else is mostly Lutz...)

I think you should write a simple app in newLISP-GS, doing some easy graphical selections... If that works out well, you can plan a larger application. If not, you've lost little, and gained some understanding of the problems.

I've not done much in the way of interactive graphics - the nearest I got was in reversi.lsp - selecting big squares!
cormullion
 
Posts: 2037
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W

Re: Structured Graphics in guiserver

Postby Gaius » Tue Mar 30, 2010 9:10 pm

Thanks for the help. I've been tinkering with Guiserver. It's certainly very easy to build a "conventional" user interface with it; very clean, I really like the declarative style.

I've not managed to get any graphics working yet, so the examples will be most useful. However, two quick questions:

1. Is there anywhere in the documentation an explanation of the canvas co-ordinate system? I'm assuming the origin is top left of the canvas itself (not the root container of the application), the units are pixels and the Y-axis is down the screen. Only my lines aren't drawing, which is odd. Or does the canvas delay rendering until it's told?

2. Can I use the same "tag" symbol for multiple canvas drawing primitives in order to group them into a single transformable object?

I may well be trying to run before I can walk here, so if the answers RTFM I'll meekly accept a pointer to the right web page!

Thanks again
Gaius
 
Posts: 2
Joined: Mon Mar 29, 2010 8:58 pm

Re: Structured Graphics in guiserver

Postby Lutz » Tue Mar 30, 2010 9:49 pm

1.) Yes, the coordinate starts top left, but the origin can be moved using gs:set-translation and you scale using gs:set-scale. Study the code for shapes-demo.lsp and stroke-demo.lsp. Both have both commands out-commented. Commenting them in will show you the effect. Study also image-demo.lsp for interactive translating and scaling.

Rendering is delayed until gs:set-visible is issued.

2.) Yes, tags can be used to group objects. Tags don't need to be symbols, they can be strings too, symbols are just a shortcut, saving a bit of typing.

Tagged objects can be: hidden, shown, moved, rotated, scaled, sheared and deleted. There is a whole bunch of functions gs:xxx-tags, where xxx stands for certain functionality.

Examples for tagged behavior are shapes-demo.lsp and stroke-demo.lsp and also drag-demo.lsp for dragging objects (important for your interactive app., I guess) and image-demo.lsp for interactive scaling.

Study each of the examples! They all show different aspects of the API.

For a more complex application study the code of newlisp-edit(.lsp), it contains the IDE (Integrated Development Environment).

Read also the Guiserver documentation here:

http://www.newlisp.org/guiserver/guiserver.lsp.html

But also installed on your computer (what platform are your using?)

Last not least an important point frequently overlooked by beginners: You don't need the newLISP-GS editor to create or run GS (or any other newLISP-) programs. You can just use your own editor and run programs outside of the shipped IDE. But for beginner's exploration and quick experimentation when you are more advanced, the IDE is quite nice.
Lutz
 
Posts: 5258
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California


Return to newLISP Graphics & Sound

Who is online

Users browsing this forum: No registered users and 1 guest

cron