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.
23 #include "pixmaps/aadlprocess.xpm"
25 /***********************************************
27 ***********************************************/
30 void aadlbox_draw_inclined_box(Aadlbox
*aadlbox
, DiaRenderer
*renderer
,
33 DiaRendererClass
*renderer_ops
= DIA_RENDERER_GET_CLASS (renderer
);
38 assert(aadlbox
!= NULL
);
39 assert(renderer
!= NULL
);
41 elem
= &aadlbox
->element
;
48 points
[0].x
= x
+ w
* AADLBOX_INCLINE_FACTOR
;
50 points
[0].y
= points
[1].y
= y
;
53 points
[2].x
= x
+ w
- w
* AADLBOX_INCLINE_FACTOR
;
54 points
[3].y
= points
[2].y
= y
+ h
;
56 renderer_ops
->set_fillstyle(renderer
, FILLSTYLE_SOLID
);
57 renderer_ops
->set_linewidth(renderer
, AADLBOX_BORDERWIDTH
);
58 renderer_ops
->set_linestyle(renderer
, linestyle
);
59 renderer_ops
->set_dashlength(renderer
, AADLBOX_DASH_LENGTH
);
61 renderer_ops
->fill_polygon(renderer
, points
, 4, &aadlbox
->fill_color
);
62 renderer_ops
->draw_polygon(renderer
, points
, 4, &aadlbox
->line_color
);
66 static void aadlprocess_draw_borders(Aadlbox
*aadlbox
, DiaRenderer
*renderer
)
68 aadlbox_draw_inclined_box(aadlbox
, renderer
, LINESTYLE_SOLID
);
73 aadlbox_inclined_project_point_on_nearest_border(Aadlbox
*aadlbox
,Point
*p
,
77 ++++++B------------+ +----------++++++++
78 + /000000000000/+ |0000000000| +
79 + /000000000000/ + |0000000000| +
80 + /000000000000/ + ----------> |0000000000| +
81 + /000000000000/ + |0000000000| +
82 +/000000000000/ + |0000000000| +
83 A------------ ++++++ +----------++++++++
87 real w
, h
, delta_y
, delta_x
;
89 w
= aadlbox
->element
.width
;
90 h
= aadlbox
->element
.height
;
92 rectangle
.top
= aadlbox
->element
.corner
.y
;
93 rectangle
.left
= aadlbox
->element
.corner
.x
;
94 rectangle
.bottom
= aadlbox
->element
.corner
.y
+ h
;
95 rectangle
.right
= aadlbox
->element
.corner
.x
+ w
- w
* AADLBOX_INCLINE_FACTOR
;
97 delta_y
= h
- (p
->y
- aadlbox
->element
.corner
.y
);
98 delta_x
= delta_y
* (w
* AADLBOX_INCLINE_FACTOR
) / h
;
102 aadlbox_project_point_on_rectangle(&rectangle
, p
, angle
);
104 delta_y
= h
- (p
->y
- aadlbox
->element
.corner
.y
);
105 delta_x
= delta_y
* (w
* AADLBOX_INCLINE_FACTOR
) / h
;
110 static void aadlprocess_draw(Aadlbox
*aadlbox
, DiaRenderer
*renderer
)
112 aadlprocess_draw_borders(aadlbox
, renderer
);
113 aadlbox_draw(aadlbox
, renderer
);
117 static Aadlbox_specific aadlprocess_specific
=
119 (AadlProjectionFunc
) aadlbox_inclined_project_point_on_nearest_border
,
120 (AadlTextPosFunc
) aadlprocess_text_position
,
121 (AadlSizeFunc
) aadlprocess_minsize
125 ObjectTypeOps aadlprocess_type_ops
;
127 DiaObjectType aadlprocess_type
=
129 "AADL - Process", /* name */
131 (char **) aadlprocess_xpm
, /* pixmap */
133 &aadlprocess_type_ops
, /* ops */
135 &aadlprocess_specific
/* user data */
139 static ObjectOps aadlprocess_ops
=
141 (DestroyFunc
) aadlbox_destroy
,
142 (DrawFunc
) aadlprocess_draw
, /* redefined */
143 (DistanceFunc
) aadlbox_distance_from
,
144 (SelectFunc
) aadlbox_select
,
145 (CopyFunc
) aadlbox_copy
,
146 (MoveFunc
) aadlbox_move
,
147 (MoveHandleFunc
) aadlbox_move_handle
,
148 (GetPropertiesFunc
) object_create_props_dialog
,
149 (ApplyPropertiesFunc
) object_apply_props_from_dialog
,
150 (ObjectMenuFunc
) aadlbox_get_object_menu
,
151 (DescribePropsFunc
) aadlbox_describe_props
,
152 (GetPropsFunc
) aadlbox_get_props
,
153 (SetPropsFunc
) aadlbox_set_props
158 static DiaObject
*aadlprocess_create(Point
*startpoint
, void *user_data
, Handle
**handle1
, Handle
**handle2
)
160 DiaObject
*obj
= aadlbox_create(startpoint
, user_data
, handle1
, handle2
);
162 obj
->type
= &aadlprocess_type
;
163 obj
->ops
= &aadlprocess_ops
;
168 static DiaObject
*aadlprocess_load(ObjectNode obj_node
, int version
, const char *filename
)
171 Point startpoint
= {0.0,0.0};
172 Handle
*handle1
,*handle2
;
174 obj
= aadlprocess_create(&startpoint
,&aadlprocess_specific
, &handle1
,&handle2
);
175 aadlbox_load(obj_node
, version
, filename
, (Aadlbox
*) obj
);
180 ObjectTypeOps aadlprocess_type_ops
=
182 (CreateFunc
) aadlprocess_create
,
183 (LoadFunc
) aadlprocess_load
,/*using_properties*/ /* load */
184 (SaveFunc
) aadlbox_save
, /* save */
185 (GetDefaultsFunc
) NULL
,
186 (ApplyDefaultsFunc
) NULL