Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better visual debugging #71

Open
noinia opened this issue Dec 26, 2020 · 13 comments
Open

Better visual debugging #71

noinia opened this issue Dec 26, 2020 · 13 comments

Comments

@noinia
Copy link
Owner

noinia commented Dec 26, 2020

Debugging the algorithms is sometimes a bit of a hassle since the show instances are quite verbose. Ideally we would have some way of showing/rendering some image that shows the geometry in question. The best thing we have so far is to render ipe or svg images. But since those parts are now in separate packages, that is sometimes a bit cumbersome as well.

Ideally the user/developer can click points/polygons/segments to show whatever data is associated with them. I'm not sure what the best way is to implement any of that. I've fiddled a bit with miso (some web framework) and reflex-sdl before to try and build some interactive application to this end. But both seem a mountain of work, nor am I sure how/what I would want precisely.

Any thoughts on how we could improve the situation?

@lemmih
Copy link
Collaborator

lemmih commented Dec 26, 2020

Can we use hgeometry as an ipelet? I tried to find documentation for ipelets but didn't have any luck.

@noinia
Copy link
Owner Author

noinia commented Dec 26, 2020

ipe supports writing ipelets in lua and in c++. See e.g. the ipe manual (for whatever reason the official manual webpages are down, so I linked to some version on the archive). I investigated a bit on what the options are:

  1. I tried to write an ipelet in lua that directly called into haskell code using hslua. However, somehow I could not really get that to work (see the hgeometry-ipe/ipelet directory for some fiddling).

  2. I also considered going through c++ using the C-ffi. But somehow it didn't seem like that would be a very ergonomial solution/I didn't really know how I would get that to work precisely.

  3. The final thing I tried was to just have a haskell program that would read ipe data from an ipe file, and write its output to an ipe file again, and write a small ipelet in lua that would dump whatever was selected into a temporary file, call the haskell binary, and then load whatever was in the output file again. See my zeroset repository for details. This actually somewhat worked.

So out of these three things I think the third one would be most promising to produce an actual ipelet.

@lemmih
Copy link
Collaborator

lemmih commented Dec 27, 2020

I think option three is very promising. We want an hgeometry executable in any case. Wrapping the executable in an ipelet should be quite doable.

I'll give it a go. The Ipe manual is quite sparse but, apparently, I can put lua code in ~/.ipe/ipelets and have it loaded automatically.

@noinia
Copy link
Owner Author

noinia commented Dec 28, 2020

By the way, now that hgeometry-web compiles again we could also further investigate building some sort of interactive viewer that way. Here is a small demo that is in there (don't mind the horrible colors):

image

@lemmih
Copy link
Collaborator

lemmih commented Dec 29, 2020

hgeometry-web doesn't compile for me. It fails with:

src/Miso/Subscription/MouseExtra.hs:14:69: error:
    Not in scope: type constructor or class ‘Sub’
   |
14 | relativeMouseSub          :: MisoString -> ((Int,Int) -> action) -> Sub action
   |                                                                     ^^^

Maybe a version issue?

@noinia
Copy link
Owner Author

noinia commented Dec 29, 2020

when using GHC miso needs to be compiled with the '+jsaddle' flag

@lemmih
Copy link
Collaborator

lemmih commented Dec 29, 2020

How can I ask cabal to do that?

@noinia
Copy link
Owner Author

noinia commented Dec 29, 2020

I think 'cabal build miso -f jsaddle' should do. Or otherwise put

package miso
flags: +jsaddle

in your cabal.project.local file. (or maybe we should even put it in the cabal.project file)

@lemmih
Copy link
Collaborator

lemmih commented Dec 29, 2020

That worked, thanks.

Maybe building it without optimizations would be feasible on the CI servers.

@noinia noinia closed this as completed Dec 29, 2020
@noinia noinia reopened this Dec 29, 2020
@noinia
Copy link
Owner Author

noinia commented Dec 29, 2020

Ergh, I accidentally clicked the wrong button

That worked, thanks.

Maybe building it without optimizations would be feasible on the CI servers.

Hmm I guess we can try. I think it's mostly a memory issue though. My machine has 8GB RAM and 8GB swap, but I had to manually add an additional swap file to get jsaddle-dom to build (at least with stack and GHC <= 8.6), so I'm somewhat skeptical.

@lemmih
Copy link
Collaborator

lemmih commented Jan 10, 2021

How does Ipe compare with Inkscape? Would it make more sense to write an Inkscape extension? @noinia

@noinia
Copy link
Owner Author

noinia commented Jan 10, 2021

Hmm good question. I don't really know; I know ipe well because I use often use it for work (nice features being that it supports LaTeX well, and can directly store/edit pdfs). Those are not necessarily features we care about in the debugging perspective though.

@lemmih
Copy link
Collaborator

lemmih commented Jan 12, 2021

  • Ipe extension:
    • Ipe is less developed than Inkscape but maybe that's a good thing.
    • Ipe is poorly documented.
    • Ipe extensions have limited capabilities. I'd love to dynamically calculate visibility polygons according to the position of the cursor but it shouldn't be straightforward in Ipe. I believe it could be done by taking advantage of the paste tool functionality but it wouldn't be pretty.
  • Inkscape extension:
    • Extension system is extremely simple. Inkscape will pipe an SVG image to a script and read the new SVG from stdout.
    • Cannot do any kind of interactivity. Querying the mouse position is impossible.
  • hgeometry-web:
    • Can be extended to do everything we want.
    • Quite difficult to build.
  • reanimate:
    • No interactivity.

I'm obviously biased but I think using 'reanimate' is one of the better options. I'll look into adding interactivity to the browser viewer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants