1 /* Dia -- an diagram creation/manipulation program 2 * Copyright (C) 1999 Alexander Larsson 3 * 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. 8 * 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. 13 * 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. 17 */ 18 #ifndef POLY_CONN_H 19 #define POLY_CONN_H 20 21 #include "diatypes.h" 22 #include "object.h" 23 #include "boundingbox.h" 24 25 #define HANDLE_CORNER (HANDLE_CUSTOM1) 26 27 /* This is a subclass of DiaObject used to help implementing objects 28 * that connect points with polygonal line-segments. 29 */ 30 struct _PolyConn { 31 /* DiaObject must be first because this is a 'subclass' of it. */ 32 DiaObject object; 33 34 int numpoints; /* >= 2 */ 35 Point *points; 36 37 PolyBBExtras extra_spacing; 38 }; 39 40 41 void polyconn_update_data(PolyConn *poly); 42 void polyconn_update_boundingbox(PolyConn *poly); 43 void polyconn_simple_draw(PolyConn *poly, DiaRenderer *renderer, real width); 44 void polyconn_init(PolyConn *poly, int num_points); 45 void polyconn_set_points(PolyConn *poly, int num_points, Point *points); 46 void polyconn_destroy(PolyConn *poly); 47 void polyconn_copy(PolyConn *from, PolyConn *to); 48 void polyconn_save(PolyConn *poly, ObjectNode obj_node); 49 void polyconn_load(PolyConn *poly, ObjectNode obj_node); /* NOTE: Does object_init() */ 50 ObjectChange *polyconn_add_point(PolyConn *poly, int segment, Point *point); 51 ObjectChange *polyconn_remove_point(PolyConn *poly, int point); 52 ObjectChange *polyconn_move_handle(PolyConn *poly, Handle *id, 53 Point *to, ConnectionPoint *cp, 54 HandleMoveReason reason, 55 ModifierKeys modifiers); 56 ObjectChange *polyconn_move(PolyConn *poly, Point *to); 57 real polyconn_distance_from(PolyConn *poly, Point *point, 58 real line_width); 59 Handle *polyconn_closest_handle(PolyConn *poly, Point *point); 60 int polyconn_closest_segment(PolyConn *poly, Point *point, 61 real line_width); 62 /* base property stuff... */ 63 #define POLYCONN_COMMON_PROPERTIES \ 64 OBJECT_COMMON_PROPERTIES, \ 65 { "poly_points", PROP_TYPE_POINTARRAY, 0, "polconn points", NULL} \ 66 67 #define POLYCONN_COMMON_PROPERTIES_OFFSETS \ 68 OBJECT_COMMON_PROPERTIES_OFFSETS, \ 69 { "poly_points", PROP_TYPE_POINTARRAY, \ 70 offsetof(PolyConn,points), offsetof(PolyConn,numpoints)} \ 71 72 #endif /* POLY_CONN_H */ 73