| 1 | // =============================================================== // |
|---|
| 2 | // // |
|---|
| 3 | // File : aw_xfig.hxx // |
|---|
| 4 | // Purpose : // |
|---|
| 5 | // // |
|---|
| 6 | // Institute of Microbiology (Technical University Munich) // |
|---|
| 7 | // http://www.arb-home.de/ // |
|---|
| 8 | // // |
|---|
| 9 | // =============================================================== // |
|---|
| 10 | |
|---|
| 11 | #ifndef AW_XFIG_HXX |
|---|
| 12 | #define AW_XFIG_HXX |
|---|
| 13 | |
|---|
| 14 | #ifndef AW_BASE_HXX |
|---|
| 15 | #include "aw_base.hxx" |
|---|
| 16 | #endif |
|---|
| 17 | #ifndef ARBDB_BASE_H |
|---|
| 18 | #include <arbdb_base.h> |
|---|
| 19 | #endif |
|---|
| 20 | #ifndef ARBTOOLS_H |
|---|
| 21 | #include <arbtools.h> |
|---|
| 22 | #endif |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | const int XFIG_DEFAULT_FONT_WIDTH = 8; |
|---|
| 26 | const int XFIG_DEFAULT_FONT_HEIGHT = 13; |
|---|
| 27 | |
|---|
| 28 | const int MAX_LINE_WIDTH = 20; |
|---|
| 29 | const int MAX_XFIG_LENGTH = 100000; |
|---|
| 30 | |
|---|
| 31 | class AW_device; |
|---|
| 32 | |
|---|
| 33 | char *aw_get_font_from_xfig(int fontnr); |
|---|
| 34 | |
|---|
| 35 | struct AW_xfig_line { |
|---|
| 36 | struct AW_xfig_line *next; |
|---|
| 37 | |
|---|
| 38 | short x0, y0; |
|---|
| 39 | short x1, y1; |
|---|
| 40 | short color; |
|---|
| 41 | int gc; |
|---|
| 42 | }; |
|---|
| 43 | |
|---|
| 44 | struct AW_xfig_text { |
|---|
| 45 | struct AW_xfig_text *next; |
|---|
| 46 | |
|---|
| 47 | short x, y; |
|---|
| 48 | short pix_len; |
|---|
| 49 | char *text; |
|---|
| 50 | AW_font font; |
|---|
| 51 | short fontsize; |
|---|
| 52 | int center; |
|---|
| 53 | short color; |
|---|
| 54 | int gc; |
|---|
| 55 | }; |
|---|
| 56 | |
|---|
| 57 | struct AW_xfig_pos { |
|---|
| 58 | short x, y; |
|---|
| 59 | int center; |
|---|
| 60 | }; |
|---|
| 61 | |
|---|
| 62 | class AW_xfig : virtual Noncopyable { |
|---|
| 63 | void calc_scaling(int font_width, int font_height); |
|---|
| 64 | |
|---|
| 65 | void init(int font_width, int font_height) { |
|---|
| 66 | text = NULp; |
|---|
| 67 | at_pos_hash = NULp; |
|---|
| 68 | |
|---|
| 69 | memset(line, 0, sizeof(line)); |
|---|
| 70 | |
|---|
| 71 | minx = 0; maxx = 0; centerx = 0; |
|---|
| 72 | miny = 0; maxy = 0; centery = 0; |
|---|
| 73 | |
|---|
| 74 | size_x = size_y = 0; |
|---|
| 75 | |
|---|
| 76 | calc_scaling(font_width, font_height); |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | public: |
|---|
| 80 | struct AW_xfig_text *text; |
|---|
| 81 | struct AW_xfig_line *line[MAX_LINE_WIDTH]; |
|---|
| 82 | |
|---|
| 83 | GB_HASH *at_pos_hash; // hash table for named positions |
|---|
| 84 | |
|---|
| 85 | int minx, miny; |
|---|
| 86 | int maxx, maxy; |
|---|
| 87 | int size_x, size_y; |
|---|
| 88 | int centerx, centery; |
|---|
| 89 | |
|---|
| 90 | double font_scale; |
|---|
| 91 | double dpi_scale; |
|---|
| 92 | |
|---|
| 93 | AW_xfig(const char *filename, int font_width, int font_height); |
|---|
| 94 | AW_xfig(int font_width, int font_height); // creates an empty drawing area |
|---|
| 95 | |
|---|
| 96 | ~AW_xfig(); |
|---|
| 97 | void print(AW_device *device); // you can scale it |
|---|
| 98 | void create_gcs(AW_device *device, int screen_depth); // create the gcs |
|---|
| 99 | |
|---|
| 100 | void add_line(int x1, int y1, int x2, int y2, int width); // add a line to xfig |
|---|
| 101 | }; |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | /* xfig format :: |
|---|
| 105 | |
|---|
| 106 | text:: |
|---|
| 107 | |
|---|
| 108 | 4 0 font(-1== default) fontsize depth color ?? angle justified(4=left) flags width x y text^A |
|---|
| 109 | |
|---|
| 110 | lines:: |
|---|
| 111 | |
|---|
| 112 | 2 art depth width color .... |
|---|
| 113 | x y x y 9999 9999 |
|---|
| 114 | |
|---|
| 115 | */ |
|---|
| 116 | |
|---|
| 117 | #else |
|---|
| 118 | #error aw_xfig.hxx included twice |
|---|
| 119 | #endif // AW_XFIG_HXX |
|---|