Lisp HUG Maillist Archive

Drawing diagrams: CAPI or OpenGL?

I would like to draw diagrams like http://gojs.net.

I would need to be able to pan and zoom the canvas, as well as drag
and drop the elements.

Should I go with OpenGL or use CAPI's draw-path?

    Thanks, Joel

-- 
for hire: iOS apps&servers
http://wagerlabs.com/about

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Re: Drawing diagrams: CAPI or OpenGL?

You may want to consider - instead of one giant canvas that draws everything - using a pinboard-layout with child drawn-pinboard-objects on it. Those would be regular output-panes (using CAPI to draw to them), but only those that need refreshed would actually be drawn.

If what you end up drawing is mostly static in nature (the nodes wouldn't be changing much), then each drawn-pinboard-object could have a pixmap image that is drawn to instead and each display-callback would literally look like this:

(defmethod display-node-object ((port node-object) x y w h)
  (with-slots (cached-image modified-p)
      port
    (when modified-p
      (redraw-to-cached-image port)
      (setf modified-p nil))
    (gp:draw-image port image 0 0)))

That would likely give you the performance you are looking for and the flexibility (and ease) of CAPI drawing.

Jeff M.
Joel Reymont
Thursday, February 27, 2014 10:23 AM
I would like to draw diagrams like http://gojs.net.

I would need to be able to pan and zoom the canvas, as well as drag
and drop the elements.

Should I go with OpenGL or use CAPI's draw-path?

Thanks, Joel

Re: Drawing diagrams: CAPI or OpenGL?

Hi Joel,

[This is just a guts feeling, I am sorry I can’t think of a formal justification right now]

I would recommend using the CAPI functions.  If I had to use an operating system’s functions for that I would choose Quartz on Mac OS X, which is -- I believe -- what CAPI uses internally.

If you chose OpenGL, there would be a lot of things you would need to implement manually, like fonts handling.  It looks pretty easy to do all that with CAPI, and the setup is minimal.  Beware of gp:font-description portability problems if you target several OSes.


Cam



On 27 Feb 2014, at 17:23, Joel Reymont <joelr1@gmail.com> wrote:

> 
> I would like to draw diagrams like http://gojs.net.
> 
> I would need to be able to pan and zoom the canvas, as well as drag
> and drop the elements.
> 
> Should I go with OpenGL or use CAPI's draw-path?
> 
>    Thanks, Joel
> 
> -- 
> for hire: iOS apps&servers
> http://wagerlabs.com/about
> 
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> lisp-hug@lispworks.com
> http://www.lispworks.com/support/lisp-hug.html
> 


_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Re: Drawing diagrams: CAPI or OpenGL?

It is certainly possible to do this in CAPI.

Here's a sample of a diagram editor done with CAPI:

http://www.youtube.com/watch?v=8vZ8Pi32oMo

I didn't implement zoom (iirc), but CAPI does have methods for altering 
the graphics context which, I think, would result in zoom.

I can't comment much on the OpenGL side.  I did experiment with it a 
bit, but not in a full project.

pt

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


(unknown)

Unable to parse email body. Email id is 12896

Updated at: 2020-12-10 08:34 UTC