📄 hwrawdatac.hh
字号:
/**************************************************************** Description:This module allows HWHeaderC and HWRawDataC objects to be read andwritten to/from the C++ stream objects. Return characters areautomatically appended to the output line. Examples: ifstream F("hello.hw", ios::in || ios::nocreate); HWHeaderC Header; F >> Header; HWRawDataC Rec1, Rec2; F >> Rec1 >> Rec2; ofstream F("hello.hw", ios::out); HWHeaderC Header; strcpy(Header.String, "hello"); F << Header; while (<not done reading user input>) { HWRawDataC Rec; <get input point from user into Rec> F << Rec; }****************************************************************/#include <fstream.h>#include <string.h>// The "type" of the HWRawDataC records.// Raw tablet events.#define DATA_RECORD 0#define PEN_DOWN 1#define PEN_UP 2#define CHAR_BOUND 3#define WORD_BOUND 4#define END_OF_FILE 5// Freeman vectors.#define FREEMAN_0 10#define FREEMAN_1 11#define FREEMAN_2 12#define FREEMAN_3 13#define FREEMAN_4 14#define FREEMAN_5 15#define FREEMAN_6 16#define FREEMAN_7 17// Possible segment breaks.#define POSS_SEG_BREAK 18// The velocity detector.#define MAX_VELOCITY 19#define MIN_VELOCITY 20// The loop detector.#define LOOP 21// The zone detector.#define ZONE_UP_CROSSING 22#define ZONE_DOWN_CROSSING 23// Word segmenter.#define END_WORDBODY 30 //navy blue#define END_WORDFRAG 24 //??#define END_TCROSS 40 //dark green#define END_IDOT 70 //light blue#define END_PUNCT 60 //grey#define END_STROKEOUT 50 //cream#define END_UNKNOWN 80 //?//Ascenders, Descenders, Median Axis Crossings#define ASC_UP_CROSSING 90#define ASC_DOWN_CROSSING 91#define DES_UP_CROSSING 92#define DES_DOWN_CROSSING 93#define MED_UP_CROSSING 94#define MED_DOWN_CROSSING 95struct HWHeaderC { HWHeaderC() { strcpy(Magic, "HW_file"); strcpy(String, ""); } IsValid() {return strcmp(Magic, "HW_file") == 0;} // A magic string. char Magic[20]; // The letter, word, or string written in the file. An // empty string if it is unknown. char String[1000];};// If unknown, XTilt, YTilt, and Pressure can be filled with// the value of -1. XPos and YPos must be non-negative.struct HWDataPointC { HWDataPointC() { XPos = YPos = 0; XTilt = YTilt = Pressure = -1; } HWDataPointC(long InitX, long InitY) { XPos = InitX; YPos = InitY; XTilt = YTilt = Pressure = -1; } // The co-ordinates of the point in any units. Must // be positive. long XPos, YPos; // Stylus tilt in degrees along the X and Y axis. // This record would be unused by // the digitizing tablet we have, but could be faked or // used by other digitizing tablets. long XTilt, YTilt; // Pressure or width of the pen stroke in some units. long Pressure;};struct HWRawDataC { HWRawDataC() { Type = Time = 0; } // The "type" of the record. See top of file for a list. int Type; // The time, in ms, between the first record in the file // and this record. long Time; // If type == 0, then this is the data point of the data record. HWDataPointC DataPoint;};ostream& operator << (ostream& outfile, HWHeaderC Header);ostream& operator << (ostream& outfile, HWRawDataC Record);ostream& operator << (ostream& outfile, HWDataPointC Point);istream& operator >> (istream& infile, HWHeaderC& Header);istream& operator >> (istream& infile, HWRawDataC& Record);int operator ==(const HWDataPointC& P1, const HWDataPointC& P2);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -