(no commit message)
[geda-pcb/pcjc2.git] / src / search.h
blobbdf460e4f42663acfb47fa1a5fc352aced8ff9a8
1 /*
2 * COPYRIGHT
4 * PCB, interactive printed circuit board design
5 * Copyright (C) 1994,1995,1996 Thomas Nau
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Contact addresses for paper mail and Email:
22 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
23 * Thomas.Nau@rz.uni-ulm.de
27 /* prototypes for search routines
30 #ifndef PCB_SEARCH_H
31 #define PCB_SEARCH_H
33 #include "global.h"
35 #define SLOP 5
36 /* ---------------------------------------------------------------------------
37 * some useful macros
39 /* ---------------------------------------------------------------------------
40 * some define to check for 'type' in box
42 #define POINT_IN_BOX(x,y,b) \
43 ((x) >= (b)->X1 && (x) <= (b)->X2 && (y) >= (b)->Y1 && (y) <= (b)->Y2)
45 #define VIA_OR_PIN_IN_BOX(v,b) \
46 POINT_IN_BOX((v)->X,(v)->Y,(b))
48 #define LINE_IN_BOX(l,b) \
49 (POINT_IN_BOX((l)->Point1.X,(l)->Point1.Y,(b)) && \
50 POINT_IN_BOX((l)->Point2.X,(l)->Point2.Y,(b)))
52 #define PAD_IN_BOX(p,b) LINE_IN_BOX((LineType *)(p),(b))
54 #define BOX_IN_BOX(b1,b) \
55 ((b1)->X1 >= (b)->X1 && (b1)->X2 <= (b)->X2 && \
56 ((b1)->Y1 >= (b)->Y1 && (b1)->Y2 <= (b)->Y2))
58 #define TEXT_IN_BOX(t,b) \
59 (BOX_IN_BOX(&((t)->BoundingBox), (b)))
61 #define POLYGON_IN_BOX(p,b) \
62 (BOX_IN_BOX(&((p)->BoundingBox), (b)))
64 #define ELEMENT_IN_BOX(e,b) \
65 (BOX_IN_BOX(&((e)->BoundingBox), (b)))
67 #define ARC_IN_BOX(a,b) \
68 (BOX_IN_BOX(&((a)->BoundingBox), (b)))
70 /* ---------------------------------------------------------------------------
71 * prototypes
73 bool IsPointOnLine (Coord, Coord, Coord, LineType *);
74 bool IsPointOnPin (Coord, Coord, Coord, PinType *);
75 bool IsPointOnArc (Coord, Coord, Coord, ArcType *);
76 bool IsPointOnLineEnd (Coord, Coord, RatType *);
77 bool IsLineInRectangle (Coord, Coord, Coord, Coord, LineType *);
78 bool IsLineInQuadrangle (PointType p[4], LineType * Line);
79 bool IsArcInRectangle (Coord, Coord, Coord, Coord, ArcType *);
80 bool IsPointInPad (Coord, Coord, Coord, PadType *);
81 bool IsPointInBox (Coord, Coord, BoxType *, Coord);
82 int SearchObjectByLocation (unsigned, void **, void **, void **, Coord, Coord, Coord);
83 int SearchScreen (Coord, Coord, int, void **, void **, void **);
84 int SearchScreenGridSlop (Coord, Coord, int, void **, void **, void **);
85 int SearchObjectByID (DataType *, void **, void **, void **, int, int);
86 ElementType * SearchElementByName (DataType *, char *);
88 #endif