diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..f2da2398 --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +*.o +Makefile +*.a +src/xournal +stamp* +*.Po +*.gmo +compile +autom4te.cache/ +*.log +*.guess +ar-lib +*.status + +# specific files +config.h +config.sub +configure +po/Makefile.in +po/Makefile.in.in +po/POTFILES +src/Makefile.in +src/ttsubset/Makefile.in +Makefile.in +aclocal.m4 + diff --git a/README.org b/README.org new file mode 100644 index 00000000..7f2fe5ee --- /dev/null +++ b/README.org @@ -0,0 +1,133 @@ +#+STARTUP: showall + +* This is a testing repository for new features of Xournal + +This is a mirror of the git repository of Xournal +(http://xournal.sourceforge.net) and contains experimental code that +is not yet in the official repo. Its purpose is to help in the +development of new features + +It should *not be used* for code intended for further distribution. + +* Xournal + +Xournal is hosted in sourceforge at [[http://sourceforge.net/projects/xournal/][http://xournal.sourceforge.net/]] +with a mailing list located at sourceforge too +[[http://sourceforge.net/p/xournal/mailman/]] + +The latest official version of xournal can always be found at +[[http://xournal.sourceforge.net/]] + +* Where to find the code + +** Official Repository + +The official repository of xournal is managed under git. It can be +found in sourceforge at: [[git://git.code.sf.net/p/xournal/code%20xournal-code][git://git.code.sf.net/p/xournal/code +xournal-code]] + +For compatibility reasons a CVS repo is still maintained and it mirrors the +git repository, but its use is deprecated. + +** Experimental repository + +The Xournal development team has an experimental repository where new +features of Xournal are tested before they are incorporated into the +official version. These features are not considered to be +stable enough for wider distributions and should be considered as +unstable and prone to crash. + +The experimental repository is hosted at github in the +following repository [[https://github.com/dmgerman/xournal]] + +Currently this repository contains the following [[https://github.com/dmgerman/xournal/branches][branches]]: + +1. [[https://github.com/dmgerman/xournal][Master]]. *DO NOT* use this branch as the basis of your code. +1. [[https://github.com/dmgerman/xournal/tree/upstream][upstream]]. Its purpose is to mirror the official repository. Use + this branch as the basis to develop your new features. +2. for-denis. This branch is expected to be merged into the official + repository. It contains features that are ready to be included in + his repository. +3. [[https://github.com/dmgerman/xournal/tree/next][next]]. This branch is for integration of several features that have + been considered solid, but not yet incorporated into the official + repository. +4. [[https://github.com/dmgerman/xournal/tree/gtk3][gtk3]]. It is an advanced effort towards porting xournal to + gtk3+. Currently Xournal uses gtk2+ +5. Other experimental branches. They will contain features that are + being tested before they are deployed to a wider audience. + +The repository is likely to contain other branches with other +experimental features. + +** Summary of experimental branches + +These branches are reliable and do not break compatibility with Xournal: + +| Name | Purpose | Rebased to head | Integrated into next | +|------------------------+-------------------------------------------------------------------------------------+------------------+----------------------| +| Master | Identical to upstream except for this file | <2016-04-20 Wed> | yes | +| Upstream | Identical to Denis repo | <2016-04-20 Wed> | yes | +|------------------------+-------------------------------------------------------------------------------------+------------------+----------------------| +| fix-update-width | Fixes annoyance: when rest the width of selected strokes, keep their variable width | <2016-04-20 Wed> | yes | +| glade | Uses XML glade interface for configuration files | <2016-04-20 Wed> | yes | +| horizontal-scroll-lock | Option to Lock the scroll horizontally | <2016-04-20 Wed> | yes | +| layers | Option to see layers above the current one | <2016-04-20 Wed> | yes | +| message | Add a pop up warning that you are using my code (used by next, useless stand alone) | <2016-04-20 Wed> | yes | +| mru | Update the Most-Recently-Used list with the currently opened page | <2016-04-20 Wed> | yes | +| popupmenu | Add a menu to right click on next/prev page to improve stylus navigation | <2016-04-20 Wed> | yes | +| snap-to-grid | Defines a grid to which any annotation is snapped to. | <2016-04-20 Wed> | yes | +| quick-zoom | Quickly zoom-in/zoom-out to a predefined zoom factor | <2016-04-20 Wed> | yes | +|------------------------+-------------------------------------------------------------------------------------+------------------+----------------------| +| next | This branch integrates all the branches above plus current xournal code | <2016-04-20 Wed> | | +|------------------------+-------------------------------------------------------------------------------------+------------------+----------------------| +| cl-options | Command line options management | <2016-04-20 Wed> | NO | +| snap-to-grid | Any annotation snaps to grid | <2016-04-20 Wed> | NO | + +Some experimental branches, they are incomplete or break compatibility: + +| Name | Purpose | Todo | +|-----------------+---------------------------------------------------------+--------------------------| +| bookmarks | Tries to implement bookmarks | Code is a bit outdated | +| cmake | Replaces autogen/automake with cmake | Problems detecting glade | +| dot-paper-style | Implements dotted paper style, breaks XOJ compatibility | Fully implemented | +| gtk3 | Attempts to replace gtk2 with gtk3 | Performance issues | + + +** + +** How to contribute + +One of the features that characterizes Xournal is its +robustness. Features that make it to the official repository should be +rock-solid and error-free (to the extent that this is feasible). In +order to guarantee this we propose the following workflow: + +1. New ideas should be posted as a short proposal to the mailing list + (xournal-devel@lists.sourceforge.net, you can subscribe here + http://sourceforge.net/p/xournal/mailman/). Xournal developers will + be able to comment whether the idea fits within the vision of + xournal. They might also provide valuable comments and advice, and + direct to existing code (such as experimental branches). +2. Make a clone of the *upstream* branch of the github repo + https://github.com/dmgerman/xournal/tree/upstream +3. Develop your feature, test it. +4. When it is ready, submit a pull-request to Daniel (github user + dmgerman). Make sure your commits are rebased to the upstream + branch to facilitate integration. Submit only one feature per + request. +5. If the feature aligns with the short and long term goals of + Xournal, Daniel will incorporate your changes as a branch, where + they will be tested by others. At this point it becomes an + experimental feature. The name of the branch will reflect the + feature. Ideally each independent feature should be incorporated + into a separate branch. That will facilitate testing and code + review. Daniel will make sure the feature is continuously rebased + to the front of official. +6. Daniel will evaluate the feature for inclusion into next, where it + can be used along many other features not yet in official (and + further tested). +7. Simultaneously, Denis will evaluate the feature for inclusion in + official. If he accepts the feature, it will be submitted to him + via the for-denis branch. +8. Once the feature is merged into official (and hence into next) the + branch is removed. diff --git a/src/xo-shapes.c b/src/xo-shapes.c index f8d978e3..2a517a4e 100644 --- a/src/xo-shapes.c +++ b/src/xo-shapes.c @@ -540,6 +540,103 @@ gboolean try_closed_polygon(int nsides) return TRUE; } +// this only checks lines, therefore can be slightly more generous in checking for deviations +// it detects my own lines quite reliably. I suck at drawing straight lines :-P +gboolean check_line(struct Item *it) { +/* struct RecoSegment *rs;*/ + GnomeCanvasPoints *points; + int num_points; + double *coords; + int n; + float x0, y0, xN, yN, xm, ym, a, b, l, invsqrt1plusbsquared, lastDistance; + float x, y, thisDistance, perpDistance; + +/* printf("it->type %i\n", it->type);*/ + points = it->path; + num_points = points->num_points; + coords = points->coords; + // what we will do is assume the line is between the first and last points + // since those points will tend to be well-defined by the person who is drawing them + // (I reckon; certainly they are for me; whereas the bits in between are all over the place :-P ) + // then we measure the mean perpendicular squared loss, something like + // http://mathworld.wolfram.com/LeastSquaresFittingPerpendicularOffsets.html + // then we figure out how large this is compared to things like, how long is the line + + if(num_points < 3) { + // not much point in doing anything with only 2 points... + return FALSE; + } + + x0 = coords[0]; + y0 = coords[1]; + xN = coords[(num_points-1)*2]; + yN = coords[(num_points-2)*2+1]; + + // get equation of a line, hope it's not vertical for now... + if(x0 == xN) { + // we dont handle vertical lines yet... + return FALSE; + } + // for y = a + xb + b = (yN - y0) / (xN - x0); + xm = (x0 + xN) / 2.0f; // mean point between lines + ym = (y0 + yN) / 2.0f; + a = ym - b * xm; + + l = sqrt((yN-y0)*(yN-y0) + (xN-x0)*(xN-x0)); // line length + + printf("%f,%f %f,%f y = %f + %f x l=%f\n", + x0, y0, xN, yN, a, b, l); + + invsqrt1plusbsquared = 1.0f / sqrt(1 + b * b); + // if too big, we're vertical, just abort... + if(abs(invsqrt1plusbsquared > 1e8)) { +/* printf("too vertical\n");*/ + return FALSE; + } + lastDistance = 0.0f; + for(n = 1; n < num_points; n++) { +/* printf("%.2f,%.2f\n", coords[i * 2], coords[i*2+1]);*/ + x = coords[n*2]; + y = coords[n*2+1]; + // actually, we should check that distance from first point is always increasing + // if not, immediately return + thisDistance = sqrt((x-x0)*(x-x0) + (y-y0)*(y-y0)); + if(thisDistance <= lastDistance) { +/* printf("backwards...\n");*/ + return FALSE; + } + perpDistance = abs(y - (a + b * x)) * invsqrt1plusbsquared; +/* printf("%i/%i thisDistance %f perpdistance %f\n", n, num_points, thisDistance, perpDistance);*/ + if(perpDistance > l / 10.0f) { +/* printf("too deviant\n");*/ + return FALSE; + } + } + // its a line ... update it.. somehow +/* points->num_points = 2;*/ +/* coords[2] = xN;*/ +/* coords[3] = yN;*/ + +/* rs = recognizer_queue;*/ + + realloc_cur_path(2); + ui.cur_path.num_points = 2; + ui.cur_path.coords[0] = x0; + ui.cur_path.coords[1] = y0; + ui.cur_path.coords[2] = xN; + ui.cur_path.coords[3] = yN; + recognizer_queue[0].item = it; +/* remove_recognized_strokes(rs, 1);*/ + remove_recognized_strokes(recognizer_queue, 1); + insert_recognized_curpath(); + + printf("updated :-)\n"); + return TRUE; + +/* return FALSE;*/ +} + /* the main pattern recognition function, called after finalize_stroke() */ void recognize_patterns(void) { @@ -562,6 +659,10 @@ void recognize_patterns(void) s.mass, center_x(s), center_y(s), I_xx(s), I_yy(s), I_xy(s), I_rad(s), I_det(s)); #endif + if(check_line(it)) { + return; + } + // first see if it's a polygon n = find_polygonal(it->path->coords, 0, it->path->num_points-1, MAX_POLYGON_SIDES, brk, ss); if (n>0) {