pcb 4.1.1
An interactive printed circuit board layout editor.

search.h File Reference

Prototypes for search routines. More...

#include "global.h"
Include dependency graph for search.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define SLOP   5
#define POINT_IN_BOX(x, y, b)   ((x) >= (b)->X1 && (x) <= (b)->X2 && (y) >= (b)->Y1 && (y) <= (b)->Y2)
#define VIA_OR_PIN_IN_BOX(v, b)   POINT_IN_BOX((v)->X,(v)->Y,(b))
#define LINE_IN_BOX(l, b)
#define PAD_IN_BOX(p, b)   LINE_IN_BOX((LineType *)(p),(b))
#define BOX_IN_BOX(b1, b)
#define TEXT_IN_BOX(t, b)   (BOX_IN_BOX(&((t)->BoundingBox), (b)))
#define POLYGON_IN_BOX(p, b)   (BOX_IN_BOX(&((p)->BoundingBox), (b)))
#define ELEMENT_IN_BOX(e, b)   (BOX_IN_BOX(&((e)->BoundingBox), (b)))
#define ARC_IN_BOX(a, b)   (BOX_IN_BOX(&((a)->BoundingBox), (b)))

Functions

bool IsPointOnLine (Coord, Coord, Coord, LineType *)
 Checks if a line intersects with a PV.
bool IsPointOnPin (Coord, Coord, Coord, PinType *)
 Checks if a point is on a pin.
bool IsPointOnArc (Coord, Coord, Coord, ArcType *)
 
bool IsPointOnLineEnd (Coord, Coord, RatType *)
 Checks if a rat-line end is on a PV.
bool IsLineInRectangle (Coord, Coord, Coord, Coord, LineType *)
 Checks if a line crosses a rectangle.
bool IsLineInQuadrangle (PointType p[4], LineType *Line)
 Checks if a line crosses a quadrangle: almost copied from IsLineInRectangle().
bool IsArcInRectangle (Coord, Coord, Coord, Coord, ArcType *)
 Checks if an arc crosses a square.
bool IsPointInPad (Coord, Coord, Coord, PadType *)
 Check if a circle of Radius with center at (X, Y) intersects a Pad.
bool IsPointInBox (Coord, Coord, BoxType *, Coord)
 
int SearchObjectByLocation (unsigned, void **, void **, void **, Coord, Coord, Coord)
 Searches for any kind of object or for a set of object types the calling routine passes two pointers to allocated memory for storing the results.
int SearchScreen (Coord, Coord, int, void **, void **, void **)
 Searches the cursor position for the type.
int SearchObjectByID (DataType *, void **, void **, void **, int, int)
 Searches for a object by it's unique ID.
ElementTypeSearchElementByName (DataType *, char *)
 Searches for an element by its board name.
int SearchLayerByName (DataType *Base, char *Name)
 Searches for an layer by its board name.

Detailed Description

Prototypes for search routines.


Copyright.


PCB, interactive printed circuit board design

Copyright (C) 1994,1995,1996 Thomas Nau

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Contact addresses for paper mail and Email:

Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany

Thomas.Nau@rz.uni-ulm.de

Definition in file search.h.


Define Documentation

#define ARC_IN_BOX (   a,
 
)    (BOX_IN_BOX(&((a)->BoundingBox), (b)))

Definition at line 72 of file search.h.

Referenced by SelectBlock().

#define BOX_IN_BOX (   b1,
 
)
Value:
((b1)->X1 >= (b)->X1 && (b1)->X2 <= (b)->X2 &&  \
        ((b1)->Y1 >= (b)->Y1 && (b1)->Y2 <= (b)->Y2))

Definition at line 59 of file search.h.

Referenced by SelectBlock().

#define ELEMENT_IN_BOX (   e,
 
)    (BOX_IN_BOX(&((e)->BoundingBox), (b)))

Definition at line 69 of file search.h.

Referenced by SelectBlock().

#define LINE_IN_BOX (   l,
 
)
Value:
(POINT_IN_BOX((l)->Point1.X,(l)->Point1.Y,(b)) &&       \
        POINT_IN_BOX((l)->Point2.X,(l)->Point2.Y,(b)))

Definition at line 53 of file search.h.

Referenced by SelectBlock().

#define PAD_IN_BOX (   p,
 
)    LINE_IN_BOX((LineType *)(p),(b))

Definition at line 57 of file search.h.

Referenced by SelectBlock().

#define POINT_IN_BOX (   x,
  y,
 
)    ((x) >= (b)->X1 && (x) <= (b)->X2 && (y) >= (b)->Y1 && (y) <= (b)->Y2)

Definition at line 47 of file search.h.

Referenced by element_callback(), name_callback(), and text_callback().

#define POLYGON_IN_BOX (   p,
 
)    (BOX_IN_BOX(&((p)->BoundingBox), (b)))

Definition at line 66 of file search.h.

Referenced by SelectBlock().

#define SLOP   5

Definition at line 40 of file search.h.

Referenced by SearchScreen().

#define TEXT_IN_BOX (   t,
 
)    (BOX_IN_BOX(&((t)->BoundingBox), (b)))

Definition at line 63 of file search.h.

Referenced by SelectBlock().

#define VIA_OR_PIN_IN_BOX (   v,
 
)    POINT_IN_BOX((v)->X,(v)->Y,(b))

Definition at line 50 of file search.h.

Referenced by SelectBlock().


Function Documentation

bool IsArcInRectangle ( Coord  ,
Coord  ,
Coord  ,
Coord  ,
ArcType  
)

Checks if an arc crosses a square.

Definition at line 932 of file search.c.

References line, LineArcIntersect(), and NoFlags.

Here is the call graph for this function:

bool IsLineInQuadrangle ( PointType  p[4],
LineType Line 
)

Checks if a line crosses a quadrangle: almost copied from IsLineInRectangle().

Note:
Actually this quadrangle is a slanted rectangle.

Definition at line 891 of file search.c.

References IsPointInQuadrangle(), line, LineLineIntersect(), NoFlags, PointType::X, and PointType::Y.

Referenced by LineLineIntersect().

Here is the call graph for this function:

bool IsLineInRectangle ( Coord  ,
Coord  ,
Coord  ,
Coord  ,
LineType  
)

Checks if a line crosses a rectangle.

Definition at line 809 of file search.c.

References line, LineLineIntersect(), and NoFlags.

Referenced by PinLineIntersect().

Here is the call graph for this function:

bool IsPointInBox ( Coord  X,
Coord  Y,
BoxType box,
Coord  Radius 
)

Note:
Assumes box has point1 with numerically lower X and Y coordinates.

Definition at line 1058 of file search.c.

References Distance(), X, BoxType::X1, BoxType::X2, Y, BoxType::Y1, and BoxType::Y2.

Referenced by IsPointOnPin().

Here is the call graph for this function:

bool IsPointInPad ( Coord  X,
Coord  Y,
Coord  Radius,
PadType Pad 
)

Check if a circle of Radius with center at (X, Y) intersects a Pad.

Written to enable arbitrary pad directions; for rounded pads, too.

Definition at line 978 of file search.c.

References Distance(), TEST_FLAG, X, x, and Y.

Referenced by line_callback(), LineArcIntersect(), LineLineIntersect(), pad_callback(), and PinLineIntersect().

Here is the call graph for this function:

bool IsPointOnArc ( Coord  X,
Coord  Y,
Coord  Radius,
ArcType Arc 
)

Todo:
This code is BROKEN in the case of non-circular arcs, and in the case that the arc thickness is greater than the radius.

Definition at line 1107 of file search.c.

References ArcType::Delta, Distance(), NormalizeAngle(), RAD_TO_DEG, ArcType::StartAngle, ArcType::Thickness, ArcType::Width, ArcType::X, and ArcType::Y.

Referenced by arc_callback(), ArcArcIntersect(), and LineArcIntersect().

Here is the call graph for this function:

bool IsPointOnLine ( Coord  X,
Coord  Y,
Coord  Radius,
LineType Line 
)

Checks if a line intersects with a PV.

 let the point be (X,Y) and the line (X1,Y1)(X2,Y2)
 the length of the line is
   L = ((X2-X1)^2 + (Y2-Y1)^2)^0.5
 let Q be the point of perpendicular projection of (X,Y) onto the line
   QX = X1 + D1*(X2-X1) / L
   QY = Y1 + D1*(Y2-Y1) / L
 with (from vector geometry)
        (Y1-Y)(Y1-Y2)+(X1-X)(X1-X2)
   D1 = ---------------------------
                     L
   D1 < 0   Q is on backward extension of the line
   D1 > L   Q is on forward extension of the line
   else     Q is on the line
 the signed distance from (X,Y) to Q is
        (Y2-Y1)(X-X1)-(X2-X1)(Y-Y1)
   D2 = ----------------------------
                     L
 Finally, D1 and D2 are orthogonal, so we can sum them easily
 by pythagorean theorem.
 

Definition at line 782 of file search.c.

References Distance().

Referenced by InsertPointIntoPolygon(), line_callback(), rat_callback(), and RemoveExcessPolygonPoints().

Here is the call graph for this function:

bool IsPointOnLineEnd ( Coord  ,
Coord  ,
RatType  
)

Checks if a rat-line end is on a PV.

Definition at line 739 of file search.c.

bool IsPointOnPin ( Coord  ,
Coord  ,
Coord  ,
PinType  
)

Checks if a point is on a pin.

Definition at line 716 of file search.c.

References Distance(), IsPointInBox(), PIN_SIZE, TEST_FLAG, pin_st::X, BoxType::X1, BoxType::X2, pin_st::Y, BoxType::Y1, and BoxType::Y2.

Referenced by pinorvia_callback(), and PV_TOUCH_PV().

Here is the call graph for this function:

ElementType* SearchElementByName ( DataType Base,
char *  Name 
)

Searches for an element by its board name.

Returns:
The function returns a pointer to the element, NULL if not found.

Definition at line 1629 of file search.c.

References ELEMENT_LOOP, END_LOOP, and NSTRCMP.

Referenced by FindPad().

int SearchLayerByName ( DataType Base,
char *  Name 
)

Searches for an layer by its board name.

Returns:
The function returns an index of the layer, -1 if not found.

Definition at line 1653 of file search.c.

References END_LOOP, layer, LAYER_LOOP, max_copper_layer, and NSTRCMP.

Referenced by identify_layer().

int SearchObjectByID ( DataType Base,
void **  Result1,
void **  Result2,
void **  Result3,
int  ID,
int  type 
)

Searches for a object by it's unique ID.

It doesn't matter if the object is visible or not.

The search is performed on a PCB, a buffer or on the remove list.

The calling routine passes two pointers to allocated memory for storing the results.

Returns:
A type value is returned too which is NO_TYPE if no objects has been found.

Definition at line 1425 of file search.c.

References ALLARC_LOOP, ALLLINE_LOOP, ALLPOLYGON_LOOP, ALLTEXT_LOOP, ARC_LOOP, ELEMENT_LOOP, ELEMENTLINE_LOOP, ELEMENTTEXT_LOOP, END_LOOP, ENDALL_LOOP, layer, line, Message(), PAD_LOOP, pin, PIN_LOOP, POLYGONPOINT_LOOP, RAT_LOOP, and VIA_LOOP.

Referenced by GetUndoSlot(), selection_changed_cb(), UndoChange2ndSize(), UndoChangeAngles(), UndoChangeClearSize(), UndoChangeMaskSize(), UndoChangeName(), UndoChangeSize(), UndoClearPoly(), UndoCopyOrCreate(), UndoFlag(), UndoInsertPoint(), UndoMirror(), UndoMove(), UndoMoveToLayer(), UndoRemove(), UndoRemovePoint(), UndoRotate(), UndoSetViaLayers(), and UndoSwapCopiedObject().

Here is the call graph for this function:

int SearchObjectByLocation ( unsigned  Type,
void **  Result1,
void **  Result2,
void **  Result3,
Coord  X,
Coord  Y,
Coord  Radius 
)

Searches for any kind of object or for a set of object types the calling routine passes two pointers to allocated memory for storing the results.

A type value is returned too which is NO_TYPE if no objects has been found.

A set of object types is passed in.

The object is located by it's position.

The layout is checked in the following order: polygon-point, pin, via, line, text, elementname, polygon, element

Note:
That if Type includes LOCKED_TYPE, then the search includes locked items. Otherwise, locked items are ignored.

Definition at line 1179 of file search.c.

References ans_info::area, box, PCBType::Data, PCBType::InvisibleObjectsOn, LAYER_ON_STACK, ans_info::locked, max_copper_layer, LayerType::On, PCB, point_box(), PosX, PosY, PCBType::RatOn, SearchArcByLocation(), SearchArcPointByLocation(), SearchElementByLocation(), SearchElementNameByLocation(), SearchLineByLocation(), SearchLinePointByLocation(), SearchPadByLocation(), SearchPinByLocation(), SearchPointByLocation(), SearchPolygonByLocation(), SearchRadius, SearchRatLineByLocation(), SearchTextByLocation(), SearchViaByLocation(), TEST_FLAG, X, BoxType::X1, BoxType::X2, Y, BoxType::Y1, and BoxType::Y2.

Referenced by ActionUndo(), AddNet(), check_snap_offgrid_line(), describe_location(), FitCrosshairIntoGrid(), LookupConnection(), MoveLineToLayer(), NotifyMode(), and SearchScreen().

Here is the call graph for this function: