2006-12-05 David Lodge <dave@cirt.net>
[dia.git] / objects / AADL / aadl.h
blob454bcdcaddaaa67e6ad1c2da2c0165978188f817
1 /* AADL plugin for DIA
3 * Copyright (C) 2005 Laboratoire d'Informatique de Paris 6
4 * Author: Pierre Duquesne
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
26 #include <assert.h>
27 #include <math.h>
28 #include <string.h>
30 #include "intl.h"
31 #include "object.h"
32 #include "element.h"
33 #include "diarenderer.h"
34 #include "attributes.h"
35 #include "text.h"
36 #include "properties.h"
38 #undef min
39 #define min(a,b) (a<b?a:b)
40 #undef max
41 #define max(a,b) (a>b?a:b)
43 #define L1 printf("%d\n", __LINE__);
46 /***********************************************
47 ** CONSTANTS **
48 ***********************************************/
50 static const double AADLBOX_BORDERWIDTH = 0.1;
51 static const double AADLBOX_FONTHEIGHT = 0.8;
52 static const double AADLBOX_TEXT_MARGIN = 0.5;
54 #define AADL_PORT_MAX_OUT 1.0 /* Maximum size out of the box */
56 #define AADL_MEMORY_FACTOR 0.1
57 #define AADLBOX_INCLINE_FACTOR 0.2
58 #define AADLBOX_DASH_LENGTH 0.3
59 #define AADL_BUS_ARROW_SIZE_FACTOR 0.16
60 #define AADL_BUS_HEIGHT_FACTOR 0.3
61 #define AADL_ROUNDEDBOX_CORNER_SIZE_FACTOR 0.25
63 /***********************************************
64 ** TYPES **
65 ***********************************************/
67 typedef struct _Aadlport Aadlport;
68 typedef struct _Aadlbox Aadlbox;
70 typedef struct _Aadlbox_specific Aadlbox_specific;
73 struct _Aadlbox
75 Element element;
77 gchar *declaration;
79 Text *name;
80 TextAttributes attrs;
82 int num_ports;
83 Aadlport **ports;
85 int num_connections;
86 ConnectionPoint **connections;
88 Color line_color;
89 Color fill_color;
91 Aadlbox_specific *specific;
95 typedef enum {
96 BUS,
97 DEVICE,
98 MEMORY,
99 PROCESSOR,
100 PROCESS,
101 SUBPROGRAM,
102 SYSTEM,
103 THREAD,
104 THREAD_GROUP,
106 ACCESS_PROVIDER,
107 ACCESS_REQUIRER,
108 IN_DATA_PORT,
109 IN_EVENT_PORT,
110 IN_EVENT_DATA_PORT,
111 OUT_DATA_PORT,
112 OUT_EVENT_PORT,
113 OUT_EVENT_DATA_PORT,
114 IN_OUT_DATA_PORT,
115 IN_OUT_EVENT_PORT,
116 IN_OUT_EVENT_DATA_PORT,
118 PORT_GROUP
119 } Aadl_type;
122 struct _Aadlport {
123 Aadl_type type;
124 Handle *handle;
125 real angle;
127 ConnectionPoint in;
128 ConnectionPoint out;
130 gchar *declaration;
133 typedef void (*AadlProjectionFunc) (Aadlbox *aadlbox,Point *p,real *angle);
134 typedef void (*AadlDrawFunc) (Aadlbox* obj, DiaRenderer* ddisp);
135 typedef void (*AadlTextPosFunc) (Aadlbox* obj, Point *p);
136 typedef void (*AadlSizeFunc) (Aadlbox* obj, Point *size);
138 /* In the abstract class system (see aadlbox.c), these are the
139 functions an inherited class *must* define, because they are
140 used by aadlbox_ functions */
142 struct _Aadlbox_specific
144 AadlProjectionFunc project_point_on_nearest_border;
145 AadlTextPosFunc text_position;
146 AadlSizeFunc min_size;
150 /***********************************************
151 ** FUNCTIONS **
152 ***********************************************/
155 /* aadltext.c */
156 void aadldata_text_position(Aadlbox *aadlbox, Point *p);
157 void aadldata_minsize(Aadlbox *aadlbox, Point *size);
159 void aadlprocess_text_position(Aadlbox *aadlbox, Point *p);
160 void aadlprocess_minsize(Aadlbox *aadlbox, Point *size);
162 void aadlbus_text_position(Aadlbox *aadlbox, Point *p);
163 void aadlbus_minsize(Aadlbox *aadlbox, Point *size);
165 void aadlsystem_text_position(Aadlbox *aadlbox, Point *p);
166 void aadlsystem_minsize(Aadlbox *aadlbox, Point *size);
168 void aadlsubprogram_text_position(Aadlbox *aadlbox, Point *p);
169 void aadlsubprogram_minsize(Aadlbox *aadlbox, Point *size);
171 void aadlmemory_text_position(Aadlbox *aadlbox, Point *p);
172 void aadlmemory_minsize(Aadlbox *aadlbox, Point *size);
174 /* aadlport.c */
175 void rotate_around_origin (Point *p, real angle);
176 void aadlbox_draw_port(Aadlport *port, DiaRenderer *renderer);
177 void aadlbox_update_port(Aadlbox *aadlbox, Aadlport *port);
178 void aadlbox_update_ports(Aadlbox *aadlbox);
180 /* aadlbox.c */
181 real aadlbox_distance_from(Aadlbox *aadlbox, Point *point);
182 void aadlbox_select(Aadlbox *aadlbox, Point *clicked_point,
183 DiaRenderer *interactive_renderer);
184 ObjectChange* aadlbox_move_handle(Aadlbox *aadlbox, Handle *handle,
185 Point *to, ConnectionPoint *cp,
186 HandleMoveReason reason,
187 ModifierKeys modifiers);
188 ObjectChange* aadlbox_move(Aadlbox *aadlbox, Point *to);
189 void aadlbox_draw(Aadlbox *aadlbox, DiaRenderer *renderer);
190 DiaObject *aadlbox_create(Point *startpoint, void *user_data,
191 Handle **handle1, Handle **handle2);
192 void aadlbox_destroy(Aadlbox *aadlbox);
193 PropDescription *aadlbox_describe_props(Aadlbox *aadlbox);
194 void aadlbox_get_props(Aadlbox *aadlbox, GPtrArray *props);
195 void aadlbox_set_props(Aadlbox *aadlbox, GPtrArray *props);
196 DiaObject *aadlbox_copy(DiaObject *obj);
197 DiaMenu * aadlbox_get_object_menu(Aadlbox *aadlbox, Point *clickedpoint);
198 void aadlbox_save(Aadlbox *aadlbox, ObjectNode obj_node, const char *filename);
199 void aadlbox_load(ObjectNode obj_node, int version, const char *filename,
200 Aadlbox *aadlbox);
202 /* aadldata.c */
203 void aadlbox_project_point_on_rectangle(Rectangle *rectangle,
204 Point *p,real *angle);
205 void aadldata_project_point_on_nearest_border(Aadlbox *aadlbox,
206 Point *p,real *angle);
208 /* aadlprocess.c */
210 void
211 aadlbox_inclined_project_point_on_nearest_border(Aadlbox *aadlbox,Point *p,
212 real *angle);
213 void aadlprocess_text_position(Aadlbox *aadlbox, Point *p);
214 real aadlprocess_blank_space_height(Aadlbox *aadlbox);
215 real aadlprocess_blank_space_width(Aadlbox *aadlbox);
217 /* aadlthread.c */
218 void aadlbox_draw_inclined_box(Aadlbox *aadlbox, DiaRenderer *renderer,
219 LineStyle linestyle);
220 /* aadlsubprogram.c */
221 void
222 aadlsubprogram_project_point_on_nearest_border(Aadlbox *aadlbox,Point *p,
223 real *angle);
224 /* aadlsystem.c */
225 void aadlbox_draw_rounded_box (Aadlbox *aadlbox, DiaRenderer *renderer,
226 LineStyle linestyle);