1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
|
/**********************************************************************
* VERSION *
**********************************************************************/
#define VERSION "0.6"
//#define DEBUG
/**********************************************************************
* ERROR HANDLING *
**********************************************************************/
#define fatal_in(S) { fprintf (stderr, _("Fatal error in function '%s'.\n"),\
S); \
exit (1); }
#define fatal(S) { fprintf (stderr, _("Fatal error: %s.\n"), S); \
exit (1); }
/* bug_in is used in places that should never be reached (especially
* default cases in switch instructions). */
#define bug_in(S) { fprintf (stderr, _("Strange fatal error in '%s'.\nThis shouldn't happen. You've just found a bug.\nPlease send a mail to <Francois-Xavier.Coudert@ens.fr>\n"), S); exit (1); }
/**********************************************************************
* INTERNATIONALISATION *
**********************************************************************/
#ifdef I18N
# include <libintl.h>
# include <locale.h>
# define _(S) gettext (S)
#else
# define _(S) (S)
#endif
/* This one is a trick related to handling of menu items */
#define __(S) (S)
/**********************************************************************
* MATHEMATICAL STUFF *
**********************************************************************/
#define SQR(x) ((x)*(x))
#define INT(x) ((int) ((x) + 0.5))
#define ATAN2(y, x) ((x) == 0 ? ((y) > 0 ? (G_PI / 2) : (- G_PI / 2)) : \
((x) > 0 ? atan2 ((double) (y), (double) (x)) : \
(G_PI + atan2 (- (double) (y), - (double) (x)))))
#define BIG 1000000
#define VERY_BIG 1E30
/**********************************************************************
* ENCODING MANAGEMENT *
**********************************************************************/
/*#define LATIN1(x) g_convert_with_fallback ((x), (signed) strlen (x), \
"latin1", "utf-8", "?", NULL, NULL, NULL)*/
#define LATIN1(x) (g_strdup(x))
#define IS_ALPHA(x) ((((x) >= 'a') && ((x) <= 'z')) \
|| (((x) >= 'A') && ((x) <= 'Z')))
typedef gint64 LLINT;
#define LLFORMAT G_GINT64_FORMAT
#define BOND_LENGTH 5000
#define ORN_DEF_DIST 1400
#define ORN_DEF_SIZE 1600
#define UNITS 100
#define GLOBAL_SIZE_H 100000
#define GLOBAL_SIZE_V 100000
#define FULL_COLOR 65535
struct Bond
{
unsigned int type;
unsigned int selected;
LLINT x1;
LLINT y1; /*
* For a bond or an arc, x1 and y1 are the coordinates of
* the first point.
*
* For an atom/group, it's the point where the
* PangoLayout should be displayed.
*/
LLINT x2;
LLINT y2; /*
* For a bond or an arc, the second point.
*
* For an atom/group, the width and height of the ink
* (used for the white masking rectangle).
*/
LLINT x3;
LLINT y3; /*
* For an atom/group, x3 and y3 are the coordinates of the
* atom (ie, the end of the bond).
*
* For an arc, x3 and y3 are the coordinates of its third
* point (the one in the middle).
*/
LLINT x4;
LLINT y4; /*
* For an atom, x4 and y4 are the upper-left corner of
* the ink (used for selection and for the masking white
* rectangle.
*
* For an arrow (or arc arrow), x4 represents the
* properties of the arrow-head on point 1, and y4 does
* the same for point 2.
*/
double width; /*
* For all bonds, this represents a "width"... For more
* details, use the source! :)
*/
GdkColor color;
char *text; /* Rich text in EasyChem format */
char *pango; /* Rich text in Pango markup */
char *pango_left; /* Left part, Pango markup */
char *pango_right; /* Right part, Pango markup */
struct Bond *group_members;
struct Ornament *ornaments[2]; /* ornaments[0] is for point 1,
ornaments[1] is for point 2,
ornaments[0] is for point 3
in case of text */
struct Bond *next;
};
struct Ornament
{
unsigned int type; /* The type of the ornaments... */
unsigned int number;
double size;
unsigned int angle; /* The angle the ornaments are centered on,
counted as in the trigonometric circle */
unsigned int spacing; /* Angle between two ornaments */
double dist; /* Distance from the point to the ornaments */
struct Ornament * next;
};
/* The global properties */
struct Properties
{
LLINT global_height;
LLINT global_width;
int latex_export;
gchar * path_gs;
gchar * path_pstoedit;
};
extern GdkColor black;
extern struct Properties prop;
extern GdkGC * gc_gray, * gc_sel;
/* The definition of all options so that we can read the code. */
#define SEL_NO 0
#define SEL_YES 1
#define SEL_CLOSE_1 2
#define SEL_CLOSE_2 4
#define SEL_TEMP 8
#define SEL_ALL 15
enum { BOND_SIMPLE, BOND_DOUBLE, BOND_TRIPLE, BOND_UP,
BOND_DOWN, BOND_DASHED, BOND_ARROW, BOND_ARC,
BOND_CIRCLE, BOND_ATOM, BOND_GROUP_L, BOND_GROUP_R, BOND_GROUP,
BOND_DELIMITER };
enum { ORN_LONE_PAIR, ORN_GAP, ORN_RADICAL, ORN_GAP2, ORN_LONE_PAIR_DOTS,
ORN_LONE_ELECTRON, ORN_DELIMITER };
#define BOND_HAS_TEXT(S) (((S)->type == BOND_ATOM) || \
((S)->type == BOND_GROUP_R) || \
((S)->type == BOND_GROUP_L))
#define BOND_HAS_WIDTH(S) ( \
(((S)->type >= BOND_DOUBLE) && ((S)->type <= BOND_DOWN)) \
|| (((S)->type >= BOND_ARROW) && ((S)->type <= BOND_ARC)))
enum { MODE_ADJUST, MODE_EDIT, MODE_ADD, MODE_ROTATE, MODE_ORNAMENT };
enum { DRAW_NO, DRAW_NORMAL, DRAW_POLY, DRAW_SEL, DRAW_SEL_ADD,
DRAW_MOVE, DRAW_MOVE_SEP, DRAW_COPY, DRAW_MOVE_POINT, DRAW_ROTATE,
DRAW_SECOND, DRAW_THIRD };
enum { EXPORT_EPS, EXPORT_EPS_SIZE, EXPORT_EPS_NOBBOX, EXPORT_PDF,
EXPORT_FIG, EXPORT_FIG_PRECISE, EXPORT_DELIMITER };
|