1 /* Dia -- an diagram creation/manipulation program -*- c -*-
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.
23 #include "boundingbox.h"
30 #define FLIP_ORIENT(x) (((x)==HORIZONTAL)?VERTICAL:HORIZONTAL)
32 #define HANDLE_MIDPOINT (HANDLE_CUSTOM1)
34 /* This is a subclass of DiaObject used to help implementing objects
35 * that connect points with orthogonal line-segments.
38 /* DiaObject must be first because this is a 'subclass' of it. */
41 int numpoints
; /* >= 3 */
42 Point
*points
; /* [numpoints] */
44 int numorient
; /* always numpoints-1 */
45 Orientation
*orientation
; /*[numpoints - 1]*/
47 int numhandles
; /* should be == numorient */
48 Handle
**handles
; /*[numpoints - 1] */
49 /* Each line segment has one handle. The first and last handles
50 * are placed in the end of their segment, the other in the middle.
51 * The end handles are connectable, the others not. (That would be
52 * problematic, as they can only move freely in one direction.)
53 * The array of pointers is ordered in segment order.
55 PolyBBExtras extra_spacing
;
56 gboolean autorouting
; /* True if this line is autorouted. */
59 void orthconn_update_data(OrthConn
*orth
);
60 void orthconn_update_boundingbox(OrthConn
*orth
);
61 void orthconn_simple_draw(OrthConn
*orth
, DiaRenderer
*renderer
,
63 void orthconn_init(OrthConn
*orth
, Point
*startpoint
);
64 void orthconn_destroy(OrthConn
*orth
);
65 void orthconn_set_points(OrthConn
*orth
, int num_points
, Point
*points
);
66 void orthconn_copy(OrthConn
*from
, OrthConn
*to
);
67 void orthconn_save(OrthConn
*orth
, ObjectNode obj_node
);
68 void orthconn_load(OrthConn
*orth
, ObjectNode obj_node
); /* NOTE: Does object_init() */
69 ObjectChange
* orthconn_move_handle(OrthConn
*orth
, Handle
*id
,
70 Point
*to
, ConnectionPoint
*cp
,
71 HandleMoveReason reason
,
72 ModifierKeys modifiers
);
73 ObjectChange
* orthconn_move(OrthConn
*orth
, Point
*to
);
74 real
orthconn_distance_from(OrthConn
*orth
, Point
*point
,
76 Handle
* orthconn_get_middle_handle(OrthConn
*orth
);
78 int orthconn_can_delete_segment(OrthConn
*orth
, Point
*clickedpoint
);
79 int orthconn_can_add_segment(OrthConn
*orth
, Point
*clickedpoint
);
80 ObjectChange
*orthconn_delete_segment(OrthConn
*orth
, Point
*clickedpoint
);
81 ObjectChange
*orthconn_add_segment(OrthConn
*orth
, Point
*clickedpoint
);
82 ObjectChange
*orthconn_toggle_autorouting_callback(DiaObject
*orth
,
85 void orthconn_update_object_menu(OrthConn
*orth
, Point
*clicked
,
86 DiaMenuItem
*object_menu_items
);
87 /* base property stuff... */
88 #define ORTHCONN_COMMON_PROPERTIES \
89 OBJECT_COMMON_PROPERTIES, \
90 { "orth_points", PROP_TYPE_POINTARRAY, 0, "orthconn points", NULL}, \
91 { "orth_orient", PROP_TYPE_ENUMARRAY, 0, "orthconn orientations", NULL}, \
92 { "orth_autoroute", PROP_TYPE_BOOL, PROP_FLAG_VISIBLE|PROP_FLAG_OPTIONAL, N_("Autoroute"), NULL} \
94 #define ORTHCONN_COMMON_PROPERTIES_OFFSETS \
95 OBJECT_COMMON_PROPERTIES_OFFSETS, \
96 { "orth_points", PROP_TYPE_POINTARRAY, \
97 offsetof(OrthConn,points), offsetof(OrthConn,numpoints)}, \
98 { "orth_orient", PROP_TYPE_ENUMARRAY, \
99 offsetof(OrthConn,orientation), offsetof(OrthConn,numorient)}, \
100 { "orth_autoroute", PROP_TYPE_BOOL, offsetof(OrthConn,autorouting)} \
102 #define ORTHCONN_COMMON_MENUS \
103 { N_("Autorouting"), orthconn_toggle_autorouting_callback, NULL, \
104 DIAMENU_ACTIVE|DIAMENU_TOGGLE}
106 #endif /* ORTH_CONN_H */