reference/ocr-simple/status_message.cc
changeset 0 6b8091ca909a
equal deleted inserted replaced
-1:000000000000 0:6b8091ca909a
       
     1 #include "tcl_interface.h"
       
     2 #include "status_message.h"
       
     3 
       
     4 /* these are ugly, but who cares? */
       
     5 
       
     6 /* you must reset this to 0 if you want to use these fxns */
       
     7 double last_status = 0.0;
       
     8 
       
     9 void set_string_status(char* s, int partial, int full)
       
    10 {
       
    11   set_string_status(s, (double)partial, (double)full);
       
    12 }
       
    13 
       
    14 void set_string_status(char* s, double partial, double full)
       
    15 {
       
    16   double fraction = (double)partial / (double)full;
       
    17   if(fraction > 0.9 && last_status < 0.9)
       
    18       {
       
    19 	set_status("%s: 90%%...", s);
       
    20 	last_status = 0.9;
       
    21       }
       
    22   else if(fraction > 0.8 && last_status < 0.8)
       
    23       {
       
    24       set_status("%s: 80%%...", s);
       
    25 	last_status = 0.8;
       
    26       }
       
    27   else if(fraction > 0.7 && last_status < 0.7)
       
    28       {
       
    29 	set_status("%s: 70%%...", s);
       
    30 	last_status = 0.7;
       
    31       }
       
    32   else if(fraction > 0.6 && last_status < 0.6)
       
    33       {
       
    34 	set_status("%s: 60%%...", s);
       
    35 	last_status = 0.6;
       
    36       }
       
    37   else if(fraction > 0.5 && last_status < 0.5)
       
    38       {
       
    39 	set_status("%s: 50%%...", s);
       
    40 	last_status = 0.5;
       
    41       }
       
    42   else if(fraction > 0.4 && last_status < 0.4)
       
    43       {
       
    44 	set_status("%s: 40%%...", s);
       
    45 	last_status = 0.4;
       
    46       }
       
    47   else if(fraction > 0.3 && last_status < 0.3)
       
    48       {
       
    49 	set_status("%s: 30%%...", s);
       
    50 	last_status = 0.3;
       
    51       }
       
    52   else if(fraction > 0.2 && last_status < 0.2)
       
    53       {
       
    54 	set_status("%s: 20%%...", s);
       
    55 	last_status = 0.2;
       
    56       }
       
    57   else if(fraction > 0.1 && last_status < 0.1)
       
    58       {
       
    59 	set_status("%s: 10%%...", s);
       
    60 	last_status = 0.1;
       
    61       }
       
    62 }
       
    63 
       
    64 void set_display_status(double partial, double full)
       
    65 {
       
    66   set_string_status("Displaying Image", partial, full);
       
    67 }
       
    68 
       
    69 void set_display_status(int partial, int full)
       
    70 {
       
    71   set_string_status("Displaying Image", partial, full);
       
    72 }
       
    73 
       
    74 void set_read_status(double partial, double full)
       
    75 {
       
    76   set_string_status("Reading Image", partial, full);
       
    77 }
       
    78 
       
    79 void set_read_status(int partial, int full)
       
    80 {
       
    81   set_string_status("Reading Image", partial, full);
       
    82 }
       
    83 
       
    84 void set_rotation_status(double partial, double full)
       
    85 {
       
    86   set_string_status("Rotating Image", partial, full);
       
    87 }
       
    88 
       
    89 void set_rotation_status(int partial, int full)
       
    90 {
       
    91   set_string_status("Rotating Image", partial, full);
       
    92 }
       
    93 
       
    94 void set_recognize_status(int p, int f)
       
    95 {
       
    96   set_string_status("Recognizing Characters", p, f);
       
    97 }
       
    98 void set_extract_status(int p, int f)
       
    99 {
       
   100   set_string_status("Extracting Words", p, f);
       
   101 }
       
   102 void set_component_status(int p, int f)
       
   103 {
       
   104   set_string_status("Extracting Characters", p, f);
       
   105 }
       
   106 
       
   107 void set_text_display_status(int p, int f)
       
   108 {
       
   109   set_string_status("Displaying text", p, f);
       
   110 }
       
   111 
       
   112 void set_spellcheck_status(int p, int f)
       
   113 {
       
   114   set_string_status("Spellchecking", p, f);
       
   115 }