/************************************************************************** C U R V D R I V E R . C ***************************************************************************/ /* Filename : curvdriver.c FUNCTION: a driver for curvature functions ***************************************************************************/ #include #include #include #include #include #include #include "piece.h" #include "statline.h" #include "isthdefs.h" extern int smooth_it; extern int row,col; extern int topf; /* top of function window commands */ extern int botf; /* bottom of function window commands */ extern int quit; extern int flagit; /* a flag for initialization of functions. */ extern int maxgreyy,maxgrey; extern WINDOW *funcwin; extern int inverse_isthmus; char string[70]; int gphabs,sharp; u_short minx,miny,maxx,maxy; /* minimun and maximum points of image found by findtarget in initmat(). */ int draw_isthmii_on = YES; /************************************************************************** This module supports the function menu window that allows the user to execute curvature functions. It should be called via a main "rootdriver" -- runner -- program. Movement in the windows is done with the arrow keys on the keyboard. The initial positions of the box and cursor are also defined. Actions are performed upon hitting the space bar. The program is terminated when the EXIT option is chosen. ***************************************************************************/ curvdriver() { int c; quit = 0; flagit = 0; topf = 5; /* top of function window commands */ botf = 16; /* bottom of function window commands */ row = topf; exp_curv_comms(); printstat(0,0,0); do { box(funcwin,VERTCH,HORZCH); wrefresh(funcwin); hghlite(); c = wgetch(funcwin); switch( c ) { case 'e' : quit = 1; break; case 'r' : rotate_piece (currpiece, M_PI); break; case 't' : try_match(); break; case 'm' : redscrn(); match_controller(); break; case '1' : draw_all_pieces (1, 4, NO); break; case 'd' : draw_all_pieces (5, piecenum, NO); break; case 'a' : draw_all_pieces (1, piecenum, NO); break; case 'i' : draw_isthmii_on = (draw_isthmii_on == YES) ? NO:YES; break; case 'S' : scale_all_pieces(); break; case SPACE : mkcurvcalls(row); break; case ESC : if ( wgetch(funcwin) == LBRACKET ) { switch( wgetch(funcwin) ) { case UPC: mveup(); break; case DOWNC: mvedown(); break; default : BELL; break; } } break; default : BELL; break; } } while ( !quit ); wstandend(funcwin); wclear(funcwin); wrefresh(funcwin); } /* end main program loop */ /*************************************************************************** mkcurvcalls ******************************************************************************/ mkcurvcalls(row) int row; { int i; int index; char gwbuff[81]; gphabs = 250; switch( row ) { case 5 : redscrn(); /*sprintf (string, "CORRELATION OF IDF FUNCTIONS"); sprintf (string, "piece matching"); alph( string, 'b', 100, 35 ); */ break; case 6 : read_new_info(currpiece); /* Read piece info in from file */ printit("DONE Reading Piece Info into data structure"); flagit = 0; break; case 7 : drawpiece (currpiece, 255); if (draw_isthmii_on) { draw_all_isthmii (currpiece, 255, 255, NO); draw_skeleton(currpiece, 3); } wrefresh(funcwin); printit("Done drawing Isthmus points"); break; case 8 : gph_isth_dist (currpiece, 1); break; case 9 : draw_inv_skeleton(currpiece, 3); break; case 10 : rotatep (currpiece, UNDRAW); drawpiece (currpiece, 255); draw_all_isthmii (currpiece, 255, 255, NO); draw_skeleton(currpiece, 3); break; case 11: transp (currpiece, UNDRAW); drawpiece (currpiece, 255); draw_all_isthmii (currpiece, 255, 255, NO); draw_skeleton(currpiece, 3); break; case 12 : calc_all_skel_dist(); break; case 13 : #ifdef ROGER seltresl(&resl); printstat(0,0,0); #endif selt_pos_neg(&index); graph_one (currpiece, index, (inverse_isthmus == 1) ? 5:6 ); break; case 14 : inverse_isthmus = (inverse_isthmus == 1) ? 0:1; printstat(0,0,0); break; case 15 : seltpiece(&currpiece); printstat(0,0,0); break; case 16 :quit = 1; break; default : break; } /* end case */ } /* end makecalls */ /*************************************************************************** This procedure will instruct the user how to select a command to be performed. ****************************************************************************/ exp_curv_comms() { wmove(funcwin,1,20); waddstr(funcwin," "); wmove(funcwin,2,24); waddstr(funcwin,"MACHINE VISION LAB"); wmove(funcwin,3,19); waddstr(funcwin,"Graphical Representation "); wmove(funcwin,5,2); waddstr(funcwin," Clear Screen a -> draw all pieces "); wmove(funcwin,6,2); waddstr(funcwin," Load piece info d -> draw 5 to 8 "); wmove(funcwin,7,2); waddstr(funcwin," Draw Piece Isthmii i -> isthmii toggle "); wmove(funcwin,8,2); waddstr(funcwin," Graph the Distance Function S -> scale all pieces"); wmove(funcwin,9,2); waddstr(funcwin," Draw Inverse Skeleton m -> match controller"); wmove(funcwin,10,2); waddstr(funcwin," Rotate the Piece t -> try match "); wmove(funcwin,11,2); waddstr(funcwin," Translate the Piece r -> rotate 180 "); wmove(funcwin,12,2); waddstr(funcwin," Calc all Isthmus Distance Functions "); wmove(funcwin,13,2); waddstr(funcwin," Graph one part (must calc all SDF above first) "); wmove(funcwin,14,2); waddstr(funcwin," Change Inverse Isthmus or not s -> skeleton toggle"); wmove(funcwin,15,2); waddstr(funcwin," Change Piece number "); wmove(funcwin,16,2); waddstr(funcwin," EXIT "); wmove(funcwin,19,20); waddstr(funcwin,"USE ARROWS TO MOVE CURSOR"); wmove(funcwin,20,18); waddstr(funcwin,"PUSH SPACE TO EXECUTE COMMAND"); wmove(funcwin,8,5); wrefresh(funcwin); } printstat(ldist, skeldist, euclid) int ldist, skeldist, euclid; { char gak[79]; int i,j,k; i = currpiece; if (ldist == 0) { sprintf(gak,"Pc#:%d Inv:%s Resl:%d ", i, (inverse_isthmus == 1)?"Yes":"No ", resl ); } else { sprintf(gak,"Pc#:%d Inv:%s Resl:%d ldis:%d skel:%d Eucl:%d ", i, (inverse_isthmus == 1)?"Yes":"No ", resl, ldist, skeldist, euclid ); } wmove(funcwin,1,1); waddstr(funcwin," "); wmove(funcwin,1,1); wstandout(funcwin); waddstr(funcwin,gak); wrefresh(funcwin); wstandend(funcwin); wrefresh(funcwin); } /************************************************************************* selt_pos_neg **************************************************************************/ selt_pos_neg(posneg) int *posneg; { int g; echo(); wstandend(funcwin); wmove(funcwin,19,15); waddstr(funcwin,"Enter the pos/neg# "); wrefresh(funcwin); wscanw(funcwin,"%d",&g); wrefresh(funcwin); wmove(funcwin,19,15); waddstr(funcwin," "); wrefresh(funcwin); *posneg = g; noecho(); }