/* * ***************************************************************** * * * * * Copyright (c) Fast Corporation, 1997 * * * * * * All Rights Reserved. Unpublished rights reserved under * * * the copyright laws of the Japan. * * * * * * The software contained on this media is proprietary to * * * and embodies the confidential technology of Fast * * * Corporation. Possession, use, duplication or * * * dissemination of the software and media is authorized only * * * pursuant to a valid written license from Fast Corporation. * * * * * ***************************************************************** */ /* CSC90X 1点マッチング(相関値計測) サンプル GSPCOR.C */ /*[作成者]H.Yagi */ /* 目的: 関数: 履歴: Ver 1.0 97/08/26 注記:m_menu.hをインクルードして下さい。 m_menu.c及びm_note.cをリンクして下さい。 */ /* * Include compiler runtime library */ #include #include /* * Include CSC90X library */ #include "f_stdlib.h" #include "f_time.h" #include "f_gui.h" #include "f_stdio.h" #include "f_graph.h" #include "f_image.h" #include "f_pinf.h" #include "f_video.h" #include "f_system.h" #include "f_search.h" /* * Include CSC90X common local */ #include "m_menu.h" /* * プロトタイプ宣言 */ void main( void ); void main_menu_disp( void ); void disp_help( void ); void ptn_reg( void ); void ptn_disp( void ); void exe_pcorr( void ); void box_pos_set( int *, int *, int *, int * ); extern int message_note( void ); /* * メニュー項目 */ #define LANG_N 2 #define MAIN_MENU_N 4 static const char *str_main_menu[MAIN_MENU_N][LANG_N] = { { " ENTRY ", " 登 録 " }, { " DISP ", " 表\ 示 " }, { " EXEC ", "相関値計測" }, { " PROC4 ", " 処理4 " } }; #define INIT_CUR_POS_X 255 #define INIT_CUR_POS_Y 239 static char ss[70]; int name; int ptn_xsize; int ptn_ysize; /* * メイン */ void main( void ) { int sts; int xpos; int ypos; int s_xpos; int s_ypos; /* 初期メッセージ表示 */ if( NORMAL_RETURN != message_note() ) return; /* パラメタ初期化 */ xpos = INIT_CUR_POS_X; ypos = INIT_CUR_POS_Y; s_xpos = INIT_CUR_POS_X; s_ypos = INIT_CUR_POS_Y; name = 0x314e5450; /* PTN1 */ /* 入力ビデオ制御 */ Lib_input_video_control( GRAY_PLANE ); /* ビデオ出力表示項目制御 */ Lib_display_control( GRAY_PLANE | LINE_PLANE | CHAR_PLANE ); /* ビデオ表示項目クリア */ Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); /* カーソル初期化 */ Lib_init_cursor(); /* メインメニューの表示 */ main_menu_disp(); /* マウスカーソルの表示 */ Lib_draw_cursor( INIT_CUR_POS_X, INIT_CUR_POS_Y ); /*GRAY_PTN.SYSを使用する*/ if ( NORMAL_RETURN == Lib_gs_open_data_file( CONTINUE_PTN_AREA ) ) { /* メニュー制御 */ for (;;) { sts = 0; /* マウス位置読みとり */ sts = Lib_see_current_position( &xpos, &ypos ); if ( s_xpos != xpos || s_ypos != ypos ) { /* マウス表示位置移動 */ Lib_move_cursor( xpos, ypos ); s_xpos = xpos; s_ypos = ypos; } /* 処理振り分け */ if( CURSOR_EXECUTE == sts ) { if ( xpos > MENU_1_XS && xpos < MENU_1_XE && ypos > MENU_1_YS && ypos < MENU_1_YE ) { Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); ptn_reg(); /* パタン登録 */ main_menu_disp(); } else if ( xpos > MENU_2_XS && xpos < MENU_2_XE && ypos > MENU_2_YS && ypos < MENU_2_YE ) { Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); ptn_disp(); /* パタン表示 */ main_menu_disp(); } else if ( xpos > MENU_3_XS && xpos < MENU_3_XE && ypos > MENU_3_YS && ypos < MENU_3_YE ) { Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); exe_pcorr(); /* 1点マッチング(相関値計測) */ main_menu_disp(); } else if ( xpos > MENU_H_XS && xpos < MENU_H_XE && ypos > MENU_H_YS && ypos < MENU_H_YE ) { Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); disp_help(); /* ヘルプ */ main_menu_disp(); } else if ( xpos > MENU_E_XS && xpos < MENU_E_XE && ypos > MENU_E_YS && ypos < MENU_E_YE ) { break; /* 終了 */ } } } Lib_gs_close_data_file(); } else Lib_display_message( 100, 200, "エラー", "パタンエリアは使用できません" ); } /* * メインメニュー表示 */ static void main_menu_disp( void ) { int iLanguage; /* 日本語/英語表示文字列切替情報取得 */ iLanguage = Lib_get_disp_language(); /* 整列キー表示 -> ( m_menu.c ) */ SUB_menu_disp4he( (char *)str_main_menu[0][iLanguage], (char *)str_main_menu[1][iLanguage], (char *)str_main_menu[2][iLanguage], (char *)NULL ); } /* * ヘルプ表示 */ static void disp_help( void ) { Lib_chrdisp( 10, 8, "【機能\概要】 GSPCOR" ); Lib_chrdisp( 11, 10, "1点マッチング(相関値計測)によってサーチパタン" ); Lib_chrdisp( 11, 12, "とグレイメモリの指定位置の相関計数値を求めます。" ); } /************************************************************************/ /* パタン登録 */ /************************************************************************/ void ptn_reg( void ) { int out_inf[8]; int error; Lib_freeze( TRANSMIT ); if ( NORMAL_RETURN == ( error = Lib_gs_defpat( name ) ) ) /* パタン登録 */ { Lib_gs_infpat( name, out_inf ); /* 登録パタンの情報取得 */ ptn_xsize = out_inf[0]; /* xサイズ */ ptn_ysize = out_inf[1]; /* yサイズ */ } if ( -1 == error ) Lib_display_message( 150, 200, "エラー", "既に200個登録済みです" ); else if ( -2 == error ) Lib_display_message( 150, 200, "エラー", "パタン格納領域不足です" ); Lib_freerun(); } /************************************************************************/ /* パタン表示 */ /************************************************************************/ void ptn_disp( void ) { Lib_gs_dsppat(); /* パタン表示 */ Lib_freerun(); } /************************************************************************/ /* 1点マッチング(相関値計測) */ /************************************************************************/ void exe_pcorr( void ) { int xs, ys, xe, ye; int val; int status; Lib_freeze( TRANSMIT ); box_pos_set( &xs, &ys, &xe, &ye ); /*相関値計測する位置設定*/ Lib_strtclk_count(); /*タイマーカウントモードのスタート*/ if ( NORMAL_RETURN == ( status = Lib_gs_pcorr( BASIC_POS, name, xs, ys, &val ) ) ) { Lib_time_disp( 0, 452 ); Lib_sprintf( ss, "相関値 = %d", val ); Lib_chrdisp( 40, 30, ss ); Lib_display_keyinput( 0, 0, "確認" ); } else if ( -1 == status ) Lib_display_message( 100, 200, "エラー", "パタンが登録されていません" ); Lib_freerun(); Lib_cls( ( LINE_PLANE | CHAR_PLANE ), BLACK_COLOR ); } /************************************************************************/ /* BOX位置設定 */ /************************************************************************/ void box_pos_set( xs, ys, xe, ye ) int *xs, *ys, *xe, *ye; /* 出力:BOXのxs, ys, xe, ye */ { int xpos, ypos; int s_xpos, s_ypos; int sts; /* 始点設定 */ s_xpos = xpos = 0; s_ypos = ypos = 0; Lib_move_cursor( xpos, ypos ); Lib_box( xpos, ypos, xpos + ptn_xsize - 1, ypos + ptn_ysize - 1, SOLID_LINE ); for (;;) { sts = 0; sts = Lib_see_current_position( &xpos, &ypos ); /* マウス位置読みとり */ if ( s_xpos != xpos || s_ypos != ypos ) { Lib_move_cursor( xpos, ypos ); Lib_box( s_xpos, s_ypos, s_xpos + ptn_xsize - 1, s_ypos + ptn_ysize - 1, 0x00000000 ); Lib_box( xpos , ypos , xpos + ptn_xsize - 1, ypos + ptn_ysize - 1, SOLID_LINE ); s_xpos = xpos; s_ypos = ypos; } if ( CURSOR_EXECUTE == sts ) { *xs = xpos; *ys = ypos; *xe = xpos + ptn_xsize - 1; *ye = ypos + ptn_ysize - 1; break; } } }