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.
20 #include "connectionpoint.h"
22 /* Returns the available directions on a slope.
23 * The right-hand side of the line is assumed to be within the object,
24 * and thus not available. */
26 find_slope_directions(Point from
, Point to
)
31 if (fabs(from
.y
-to
.y
) < 0.0000001)
32 return (from
.x
> to
.x
?DIR_SOUTH
:DIR_NORTH
);
33 if (fabs(from
.x
-to
.x
) < 0.0000001)
34 return (from
.y
> to
.y
?DIR_WEST
:DIR_EAST
);
36 point_sub(&to
, &from
);
37 slope
= fabs(to
.y
/to
.x
);
40 if (slope
< 2) { /* Flat enough to allow north-south */
41 if (to
.x
> 0) { /* The outside is north, not south */
47 if (slope
> .5) { /* Steep enough to allow east-west */
48 if (to
.y
> 0) { /* The outside is east, not west */
58 /** Update the object-settable parts of a connectionpoints.
59 * p: A ConnectionPoint pointer (non-NULL).
60 * x: The x coordinate of the connectionpoint.
61 * y: The y coordinate of the connectionpoint.
62 * dirs: The directions that are open for connections on this point.
65 connpoint_update(ConnectionPoint
*p
, real x
, real y
, gint dirs
)
72 /** Returns TRUE if the given connection point is non-null and autogapped.
75 connpoint_is_autogap(ConnectionPoint
*cp
) {
76 return cp
!= NULL
&& (cp
->flags
& CP_FLAG_AUTOGAP
);