[evince] Ink Annotations Toy Implementation



Hi all,

I have been working recently on a toy project to get ink annotations
working in Evince.

My end goal is actually to develop a Cairo-based alternative to
Xournal (which is currently based on the obsoleted libgnomecanvas and
doesn't do cool stuff like highlights properly).

To this end, I have done the following

- Implemented a loose quadtree
(https://www.cs.umd.edu/users/hjs/pubs/sigmod13-header.pdf) for ink
annotation segments
- Added Ink Annotation support to Poppler-glib

The code can be found at:

https://github.com/xkjyeah/evince_ink
https://github.com/xkjyeah/poppler_ink

At its current state, you can click on ink annotations and modify
their contents. You cannot select annotations or draw new annotations
yet.

At this point, I would like to ask the more experienced developers how
to progress from here.

- To meet my goal, I need extensions to PDF -- variable line width,
different compositing operators (multiply for highlights). Is this a
viable alternative? Could it be saved as a different file format, e.g.
"PDF with Evince annotations"?

- It boggles my mind that Evince uses the poppler_glib backend, which
is itself an intermediate layer written in C to the C++ poppler
backend. The poppler_glib backend is not complete. The reason I
mention this is that it would be nice to be able to write the
abstraction layers once and not twice -- once for poppler_glib and
once for evince. In any case, the files in backend/pdf are written in
C++, so I why wasn't the Poppler C++ backend used here? This is just
an annoying detail.

- I foresee having to rewrite the hit-detection to use a quadtree

Ink annotations (as well as circles, polygons etc. if they are
implemented in the future) are quite a different beast from nice
rectangles, because selecting them requires clicking on their *filled*
sections and not simply on their bounding boxes.

Current hit-detection algorithm f : (x,y) -->
link/annotation/clickable/etc. works as follows:

Prereq: Each ink annotation has a quadtree implementation
Input: (x,y)
1. Find (x,y) relative to page
2. Find *one* annotation at (x,y) by bounding box
3. If annotation is and Ink, detect if (x,y) is within width/2 of one
of the segments
4. Return annotation

It would need to be reworked to:

Prereq: Each *page* has a quadtree implementation
1. Find (x,y) relative to page
2. Find ALL annotations parts at (x,y) using quadtree sorted by z-index
3. Return top-most annotation

Any comments?

Regards,
Daniel


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]