Changeset 18 in projects for visualisator/lochstreifen.h
- Timestamp:
- Sep 15, 2008, 4:23:39 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
visualisator/lochstreifen.h
r9 r18 1 /*2 ** Allgemeine Headerfile fuer das3 ** Lochstreifen-Visualisieren-Projekt4 */5 1 #ifndef __LOCHSTREIFEN_H__ 6 2 #define __LOCHSTREIFEN_H__ 7 3 8 #include <cairo-svg.h> // cairo_t unten 4 // if C++ compiling... 5 #ifdef __cplusplus 6 extern "C" { 7 #endif 9 8 10 #define byte_t unsigned char 11 #define LOCHSTREIFEN struct lochstreifen 9 #include <cairo-svg.h> /* because using cairo_t */ 12 10 13 // Die Lochstreifenstruktur, die alle relevanten Daten enthaelt 11 typedef unsigned char byte_t; 12 typedef struct lochstreifen LOCHSTREIFEN; 13 14 14 struct lochstreifen { 15 /* Daten, die der Lochstreifen enthaelt: */ 16 int data_length; // Länge des Datenarrays, rechnend ab 1 (wie argc) 17 byte_t *data; // Datenarray 15 /* DATA (not supposed to be set directly) */ 16 /// Length of data array (counting from 1, like argc) 17 int data_length; 18 /// data array (the data which LOCHSTREIFEN will print) 19 byte_t *data; 18 20 19 int empty_start; // wie viele 0bytes vorne 20 int empty_end; // wie viele 0bytes hinten 21 /* COLORS / SWITCHES WHETER PARTS ARE PAINTED */ 22 cairo_pattern_t *outer_background_color; 23 cairo_pattern_t *papertape_background_color; 24 cairo_pattern_t *one_code_hole_color; 25 cairo_pattern_t *zero_code_hole_color; 26 cairo_pattern_t *feed_hole_color; 21 27 22 /* Konstanten zum Aussehen des Lochstreifens 23 Referenzeinheit ist d, daraus wird alles berechnet, 24 siehe lochstreifen_set_d 25 */ 26 int d; // Durchmesser eines Loches 27 int bspace; // Abstand der Bytes voneinander (Reihen) 28 int hspace; // Abstand der Loecher in der Bytereihe 29 int padding; // Abstand Löcher <=> Lochstreifenrand 30 int df; // Durchmesser Lochfuehrungsloch 31 int fspace; // Breite der Lochfuehrungs"nut" 32 int margin; // Abstand um Lochstreifen herum (an allen Seiten) 33 int abriss; // Länge der Abrisse an Start/Ende (halbe Höhe vom Lochstreifen) 28 /// Highlighting a (row/byte) region 29 int highlight_region_start; ///< counting from 0, already in selection 30 int highlight_region_end; ///< counting from 0, no more in selection 31 cairo_pattern_t *highlight_region_color; ///< == NULL => no selection painted 34 32 35 /* Farben, in denen der Lochstreifen gehalten ist */ 36 cairo_pattern_t *hintergrund, *streifenbg, *punched, *notpunched, *fuehrung; 37 // Farben um Lochstreifen, Lochstreifen, Loecher, Nicht-Loecher, Fuehrung 38 // siehe zum Setzen: lochstreifen_set_color oder per Cairo-Funktion fuer 39 // komplexere Loesungen. Bei NULL wird die Komponente nicht gezeichnet! 33 /// Highlight one special row 34 int highlight_row_number; ///< counting from 0 35 cairo_pattern_t *highlight_row_color; 40 36 41 /* Drehungen und co, nicht direkt veraendern, sonst stimmt die vorberechnete 42 Hoehe/Breite nicht mehr mit den realen Werten ueberein. */ 43 //cairo_matrix_t transformation; 44 // Das folgende koennte man natuerlich effizienter Speichern, aber egal. 45 int drehung; // 0-3, jeweils 45°-Schritte im Uhrzeigersinn 46 int spiegelung_hor; // horizontale Spiegelung != 0 == ja 47 int spiegelung_ver; // vertikale Spiegelung != 0 == ja 37 /// Highlight one special bit (not complete track) 38 int highlight_bit_row; ///< counting from 0 39 int highlight_bit_track; ///< counting from 0 40 cairo_pattern_t *highlight_bit_color; 48 41 49 /* Nur bestimmte rechteckige Bereiche zeichnen -- dies wird massgeblich vom 50 GTK-Interface benutzt */ 51 int only_start_x; // Die angegebenen Punkte 52 int only_start_y; // spannen ein Rechteck auf. In grober 53 int only_width; // Naeherung wird nur in diesem Bereich 54 int only_height; // gezeichnet. 42 /// Perfomant Clipping 43 cairo_rectangle_t *clip; 44 45 /// Matrix to apply for every paint process 46 cairo_matrix_t *matrix; 47 48 /*<private>*/ 49 /* The following datas are private. */ 50 51 /// Make debug output if debug != 0. 52 byte_t debug; 53 }; 54 55 /// The default color values 56 #define LOCHSTREIFEN_DEFAULT_OUTER_BACKGROUND_COLOR NULL 57 #define LOCHSTREIFEN_DEFAULT_PAPERTAPE_BACKGROUND_COLOR cairo_pattern_create_rgb(0.7, 0.7, 0.7) 58 #define LOCHSTREIFEN_DEFAULT_ONE_CODE_HOLE_COLOR cairo_pattern_create_rgb(0, 0, 0) 59 #define LOCHSTREIFEN_DEFAULT_ZERO_CODE_HOLE_COLOR NULL 60 #define LOCHSTREIFEN_DEFAULT_FEED_HOLE_COLOR cairo_pattern_create_rgb(0.5, 0.7, 1) 61 #define LOCHSTREIFEN_DEFAULT_HIGHLIGHT_REGION_COLOR cairo_pattern_create_rgb(0.95, 1, 0) 62 #define LOCHSTREIFEN_DEFAULT_HIGHLIGHT_ROW_COLOR cairo_pattern_create_rgb(1, 0, 0) 63 #define LOCHSTREIFEN_DEFAULT_HIGHLIGHT_BIT_COLOR cairo_pattern_create_rgb(0.4, 0.55, 0.7) 64 65 /// dimensions of the paper tape after ECMA-10 standard 66 67 // width of paper tape, according to "PROPERTIES OF UNPUNCHED TAPE", section 1.1.2: 68 // 25.40mm = 1". This is the "base" unit in our vector drawing. 69 #define LOCHSTREIFEN_WIDTH 1.0 70 71 // length of tear-off: about the half of the width of a papertape 72 #define LOCHSTREIFEN_TEAR_OFF_LENGTH ( 0.5 * LOCHSTREIFEN_WIDTH ) 73 74 // Within a row the distance of the centres of the code holes from 75 // the centre of the feed hole shall be 2,54mm (=0.1"), where n is an integer. 76 #define LOCHSTREIFEN_TRACK_DISTANCE 0.1 77 78 // The distance between two adjacent rows shall be 2,54mm (=0.1") measured 79 // at the feed holes. 80 #define LOCHSTREIFEN_ROW_DISTANCE 0.1 81 82 // feed hole diameter: 1.170mm 83 #define LOCHSTREIFEN_RADIUS_FEED_HOLE ( (1.170 / 25.40) / 2) 84 85 // code hol diameter: 1.83mm 86 #define LOCHSTREIFEN_RADIUS_CODE_HOLE ( (1.830 / 25.40) / 2) 87 88 // length of paper tape: Tear off at start and end, data rows + 0.05" offset at start + end spacing 89 #define LOCHSTREIFEN_LENGTH ( 2 * LOCHSTREIFEN_TEAR_OFF_LENGTH + \ 90 LOCHSTREIFEN_ROW_DISTANCE * (l->data_length + 1) ) 91 92 enum lochstreifen_direction { 93 // special values for compatibility to old implementation 94 LOCHSTREIFEN_MOVEMENT_TO_LEFT = 0, 95 LOCHSTREIFEN_MOVEMENT_TO_TOP = 1, 96 LOCHSTREIFEN_MOVEMENT_TO_RIGHT = 2, 97 LOCHSTREIFEN_MOVEMENT_TO_BOTTOM = 3, 98 LOCHSTREIFEN_MOVEMENT_NONE = -1, 99 LOCHSTREIFEN_ROTATION_CLOCKWISE = 4, 100 LOCHSTREIFEN_ROTATION_ANTICLOCKWISE = 5 101 }; 55 102 56 103 57 /* Feature: Ein bestimmtes Byte hervorheben */ 58 int highlight_byte; // Nummer des Bytes (von 0) 59 cairo_pattern_t *highlight_color; // Farben => wenn NULL, kein Highlight 104 // functions 105 LOCHSTREIFEN *lochstreifen_new(); 106 void lochstreifen_print_debug(LOCHSTREIFEN* l); 107 void lochstreifen_set_data(LOCHSTREIFEN *l, int data_length, byte_t *data); 108 void lochstreifen_add_null_bytes(LOCHSTREIFEN *l, int start, int end); 109 double lochstreifen_get_length(LOCHSTREIFEN *l); 110 void lochstreifen_set_highlight_region(LOCHSTREIFEN *l, int start, int end); 111 int lochstreifen_get_highlight_region(LOCHSTREIFEN *l, int *start, int *end); 112 void lochstreifen_remove_highlight_region(LOCHSTREIFEN *l); 113 void lochstreifen_set_highlight_row(LOCHSTREIFEN *l, int number_of_row); 114 int lochstreifen_get_highlight_row(LOCHSTREIFEN *l); 115 void lochstreifen_remove_highlight_row(LOCHSTREIFEN *l); 116 void lochstreifen_set_highlight_bit(LOCHSTREIFEN *l, int number_of_row, int number_of_bit); 117 int lochstreifen_get_highlight_bit(LOCHSTREIFEN *l, int *number_of_row, int *number_of_bit); 118 void lochstreifen_remove_highlight_bit(LOCHSTREIFEN *l); 119 void lochstreifen_set_clip(LOCHSTREIFEN *l, double x, double y, double width, double height); 120 void lochstreifen_remove_clip(LOCHSTREIFEN *l); 121 void lochstreifen_set_scaling_by_length(LOCHSTREIFEN *l, int length); 122 void lochstreifen_set_scaling_by_width(LOCHSTREIFEN *l, int width); 123 void lochstreifen_set_scaling_by_code_hole(LOCHSTREIFEN *l, int diameter); 124 void lochstreifen_get_target_dimensions(LOCHSTREIFEN *l, int *width, int *height); 125 int lochstreifen_get_target_width(LOCHSTREIFEN *l); 126 int lochstreifen_get_target_height(LOCHSTREIFEN *l); 127 int lochstreifen_get_target_row_from_point(LOCHSTREIFEN* l, double x, double y); 128 void lochstreifen_set_rotation(LOCHSTREIFEN *l, enum lochstreifen_direction direction); 129 void lochstreifen_draw(LOCHSTREIFEN *l, cairo_t *cr); 60 130 61 /* Debugausgaben machen => wenn debug != 0 ist! */ 62 byte_t debug; 63 }; 131 #ifdef __cplusplus 132 } // extern "C" 133 #endif 64 134 65 /* lochstreifen.c */66 // allgemeine Zusatzfunktion, kein Bezug67 int file_get_contents(FILE *stream, byte_t **content);68 69 // Lochstreifenfunktionen, siehe Dokumentation in c-File70 LOCHSTREIFEN *lochstreifen_new();71 void lochstreifen_set_data(LOCHSTREIFEN *l, int data_length, byte_t *data, int empty_start, int empty_end);72 void lochstreifen_set_d(LOCHSTREIFEN *l, int d);73 void lochstreifen_set_d_by_width(LOCHSTREIFEN *l, int width);74 void lochstreifen_set_d_by_height(LOCHSTREIFEN *l, int height);75 int lochstreifen_get_width(LOCHSTREIFEN *l);76 int lochstreifen_get_height(LOCHSTREIFEN *l);77 int lochstreifen_set_draw_only_area(LOCHSTREIFEN *l, int x, int y, int width, int height);78 int lochstreifen_flush_draw_only_area(LOCHSTREIFEN *l);79 void lochstreifen_set_color(cairo_pattern_t *color, byte_t red, byte_t green, byte_t blue, byte_t alpha);80 //void lochstreifen_rotate(LOCHSTREIFEN *l);81 //void lochstreifen_spiegel(LOCHSTREIFEN *l, byte_t horizontal);82 void lochstreifen_set_direction(LOCHSTREIFEN *l, int drehung, int spiegelung_hor, int spiegelung_ver);83 void lochstreifen_draw(LOCHSTREIFEN *l, cairo_t *cr);84 int lochstreifen_get_orientation(LOCHSTREIFEN *l);85 int lochstreifen_byte_by_coordinate(LOCHSTREIFEN *l, int x, int y);86 int lochstreifen_flush_only_start_area(LOCHSTREIFEN *l);87 void lochstreifen_set_highlight(LOCHSTREIFEN* l, int byte_number);88 int lochstreifen_coordinate_by_byte(LOCHSTREIFEN *l, int byte);89 int lochstreifen_set_only_start_area(LOCHSTREIFEN *l, int x, int y, int width, int height);90 135 91 136 #endif /* __LOCHSTREIFEN_H__ */
Note: See TracChangeset
for help on using the changeset viewer.