2006-12-03 Dimitris Glezos <dimitris@glezos.com>
[dia.git] / lib / arrows.h
blobd2476eafa8bf08cc7ed917356138f74af7433ce8
1 /* Dia -- an diagram creation/manipulation program
2 * Copyright (C) 1998 Alexander Larsson
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 #ifndef ARROWS_H
19 #define ARROWS_H
21 #include "diavar.h"
22 #include "diatypes.h"
23 #include "geometry.h"
24 #include "color.h"
25 #include "dia_xml.h"
27 /* NOTE: Add new arrow types at the end, or the enums
28 will change order leading to file incompatibilities. */
30 /* Comments in curly braces mention ISO 10303-AP201 names */
32 typedef enum {
33 ARROW_NONE,
34 ARROW_LINES, /* {open arrow} */
35 ARROW_HOLLOW_TRIANGLE, /* {blanked arrow} */
36 ARROW_FILLED_TRIANGLE, /* {filled arrow} */
37 ARROW_HOLLOW_DIAMOND,
38 ARROW_FILLED_DIAMOND,
39 ARROW_HALF_HEAD,
40 ARROW_SLASHED_CROSS, /* Vertical + diagonal line */
41 ARROW_FILLED_ELLIPSE,
42 ARROW_HOLLOW_ELLIPSE,
43 ARROW_DOUBLE_HOLLOW_TRIANGLE,
44 ARROW_DOUBLE_FILLED_TRIANGLE,
45 ARROW_UNFILLED_TRIANGLE, /* {unfilled arrow} */
46 ARROW_FILLED_DOT, /* {filled dot} Ellipse + vertical line */
47 ARROW_DIMENSION_ORIGIN, /* {dimension origin} Ellipse + vert line */
48 ARROW_BLANKED_DOT, /* {blanked dot} Empty ellipse + vert line */
49 ARROW_FILLED_BOX, /* {filled box} Box + vertical line */
50 ARROW_BLANKED_BOX, /* {blanked box} Box + vertical line */
51 ARROW_SLASH_ARROW, /* {slash arrow} Vertical + diagonal line*/
52 ARROW_INTEGRAL_SYMBOL, /* {integral symbol} Vertical + integral */
53 ARROW_CROW_FOOT,
54 ARROW_CROSS, /* Vertical line */
55 ARROW_FILLED_CONCAVE,
56 ARROW_BLANKED_CONCAVE,
57 ARROW_ROUNDED,
58 ARROW_HALF_DIAMOND, /* ---< */
59 ARROW_OPEN_ROUNDED, /* ---c */
60 ARROW_FILLED_DOT_N_TRIANGLE, /* ---|>o */
61 ARROW_ONE_OR_MANY, /* ER-model: 1 or many*/
62 ARROW_NONE_OR_MANY, /* ER-model: 0 or many*/
63 ARROW_ONE_OR_NONE, /* ER-model: 1 or 0 */
64 ARROW_ONE_EXACTLY, /* ER-model: exactly one*/
65 ARROW_BACKSLASH, /* -\---- */
66 ARROW_THREE_DOTS,
68 MAX_ARROW_TYPE /* No arrow heads may be defined beyond here. */
69 } ArrowType;
71 struct menudesc {
72 char *name;
73 ArrowType enum_value;
76 /** The number of centimeters long and wide an arrow starts with by default.
77 * This can be changed without breaking old diagrams, as the arrow width
78 * is stored in there.
79 * Note: Currently, many places have this number hardcoded.
80 * find . -name \*.[ch] | xargs grep \\.8
82 #define DEFAULT_ARROW_SIZE 0.5
84 /** The minimum width or length of an arrowhead. This to avoid borderline
85 * cases that break trig functions, as seen in bug #144394
87 #define MIN_ARROW_DIMENSION 0.001
89 /* These are used to fill menus. See dia_arrow_fill_menu in widgets.c */
90 DIAVAR struct menudesc arrow_types[];
92 struct _Arrow {
93 ArrowType type;
94 real length;
95 real width;
99 void arrow_draw(DiaRenderer *renderer, ArrowType type,
100 Point *to, Point *from,
101 real length, real width, real linewidth,
102 Color *fg_color, Color *bg_color);
104 void
105 calculate_arrow_point(const Arrow *arrow, const Point *to, const Point *from,
106 Point *move_arrow, Point *move_line,
107 real linewidth);
109 /* Transforms 'start' to be at the back end of the arrow, and puts the
110 * tip of the arrow into 'arrowtip'.
112 void arrow_transform_points(Arrow *arrow, Point *start, Point *to,
113 int linewidth, Point *arrowtip);
115 void save_arrow(ObjectNode obj_node, Arrow *arrow, gchar *type_attribute,
116 gchar *length_attribute, gchar *width_attribute);
117 void load_arrow(ObjectNode obj_node, Arrow *arrow, gchar *type_attribute,
118 gchar *length_attribute, gchar *width_attribute);
120 /** Returns the ArrowType for a given name of an arrow, or 0 if not found. */
121 ArrowType arrow_type_from_name(gchar *name);
122 /** Returns the index in arrow_types of the given arrow type. */
123 gint arrow_index_from_type(ArrowType type);
124 gchar *arrow_get_name_from_type(ArrowType type);
125 GList *get_arrow_names(void);
127 #endif /* ARROWS_H */