chiark / gitweb /
page with the mouse to avoid the silly page-back-to-top effect
[ypp-sc-tools.main.git] / pctb / structure.c
index 85b8f86..ad95cb5 100644 (file)
@@ -256,7 +256,9 @@ static int commod_selector_matches(Rect search, const char *const *all,
   }
 
 void find_structure(CanonImage *im, int *max_relevant_y_r,
-                   Point *commod_focus_point_r) {
+                   Point *commod_focus_point_r,
+                   Point *commod_page_point_r,
+                   Point *commod_focuslast_point_r) {
   cim= im;
   
   Rect whole = { {0,0}, {cim->w-1,cim->h-1} };
@@ -293,6 +295,7 @@ void find_structure(CanonImage *im, int *max_relevant_y_r,
     Point csb_p;                                       \
     Rect csb_r;                                                \
     csb_p= mainr.tl;                                   \
+    csb_p.x++; csb_p.y++;                              \
     csb_p.xy= mainr.tlbr.xy;                           \
     if (get_p(csb_p)=='+') {                           \
       csb_r= mainr;                                    \
@@ -355,6 +358,23 @@ void find_structure(CanonImage *im, int *max_relevant_y_r,
   }
   MUST( colno >= MIN_COLUMNS, MI(colno);MR(mainr);MR(across); );
 
+  const int pagerh= 6;
+  Rect pager= {{ mainr.br.x,     mainr.br.y - (pagerh-1) },
+              { mainr.br.x + 1, mainr.br.y              }};
+
+  debug_rect("pager",__LINE__,pager);
+  ADJUST_BOX(pager, "o",>=,pagerh-2, whole.br.x,MUST, br,x,+1);
+  debug_rect("pager",__LINE__,pager);
+
+  pager.tl.x= pager.br.x;
+  pager.br.x= pager.br.x + 1;
+  debug_rect("pager",__LINE__,pager);
+  ADJUST_BOX(pager, "o",>=,pagerh-2, whole.br.x,MUST, br,x,+1);
+  debug_rect("pager",__LINE__,pager);
+
+  ADJUST_BOX(pager, "o",>=,RECT_W(pager)-2, mainr.tl.y,LIMIT_QUITEQ, tl,y,-1);
+  debug_rect("pager",__LINE__,pager);
+
 #define SET_ONCE(var,val) do{                                          \
     int v= (val);                                                      \
     if ((var)==-1) (var)= v;                                           \
@@ -371,6 +391,15 @@ void find_structure(CanonImage *im, int *max_relevant_y_r,
     commod_focus_point_r->x += 10;
     commod_focus_point_r->y += comminty/3;
   }
+  if (commod_focuslast_point_r) {
+    *commod_focuslast_point_r= mainr.br;
+    commod_focuslast_point_r->x -= 10;
+    commod_focuslast_point_r->y -= comminty/3;
+  }
+  if (commod_page_point_r) {
+    commod_page_point_r->x= (pager.tl.x + pager.br.x) / 2;
+    commod_page_point_r->y=  pager.tl.y - 1;
+  }
 
   MUST( text_h <= OCR_MAX_H, MI(text_h) );
 }                  
@@ -639,7 +668,7 @@ void analyse(FILE *tsv_output) {
   int page, tryrect, colno;
 
   for (page=0; page<npages; page++) {
-    find_structure(page_images[page], 0, 0);
+    find_structure(page_images[page], 0,0,0,0);
 
     if (!page)
       check_correct_commodities();
@@ -700,7 +729,7 @@ Rect find_sunshine_widget(void) {
 }
 
 void find_islandname(void) {
-  find_structure(page_images[0], 0, 0);
+  find_structure(page_images[0], 0,0,0,0);
 
   RgbImage *ri= alloc_rgb_image(page_images[0]->rgb->w,
                                page_images[0]->rgb->h);