Default STEP export to board only
[geda-pcb/pcjc2/v2.git] / src / misc.h
blobaa7e12f3e98dc6712e41ee705ad7b21e43becd4e
1 /*!
2 * \file src/misc.h
4 * \brief Prototypes for misc routines.
6 * <hr>
8 * <h1><b>Copyright.</b></h1>\n
10 * PCB, interactive printed circuit board design
12 * Copyright (C) 1994,1995,1996,2006 Thomas Nau
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 * Contact addresses for paper mail and Email:
30 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
32 * Thomas.Nau@rz.uni-ulm.de
35 #ifndef PCB_MISC_H
36 #define PCB_MISC_H
38 #include <stdlib.h>
39 #include "global.h"
40 #include "mymem.h"
42 enum unitflags { UNIT_PERCENT = 1 };
44 typedef struct {
45 const char *suffix;
46 double scale;
47 enum unitflags flags;
48 } UnitList[];
50 double Distance (double x1, double y1, double x2, double y2);
51 Angle NormalizeAngle (Angle a);
53 void r_delete_element (DataType *, ElementType *);
54 void SetLineBoundingBox (LineType *);
55 BoxType calc_thin_arc_bounds (Coord cx, Coord cy, Coord rx, Coord ry, Angle start_angle, Angle delta_angle);
56 void SetArcBoundingBox (ArcType *);
57 void SetArcEndpoints (ArcType *);
58 void SetPointBoundingBox (PointType *);
59 void SetPinBoundingBox (PinType *);
60 void SetPadBoundingBox (PadType *);
61 void calc_arc_from_points_and_included_angle (PointType *p1, PointType *p2, Angle included_angle, Coord *cx, Coord *cy, Coord *radius, Angle *start_angle, Angle *delta_angle);
62 void SetPolygonBoundingBox (PolygonType *);
63 void SetElementBoundingBox (DataType *, ElementType *, FontType *);
64 bool IsDataEmpty (DataType *);
65 bool IsLayerEmpty (LayerType *);
66 bool IsLayerNumEmpty (int);
67 bool IsLayerGroupEmpty (int);
68 bool IsPasteEmpty (int);
69 void CountHoles (int *, int *, const BoxType *);
70 void CountHolesEx (int *, int *, const BoxType *, Cardinal, Cardinal);
71 BoxType * GetDataBoundingBox (DataType *);
72 void CenterDisplay (Coord, Coord, bool warp_pointer);
73 void SetFontInfo (FontType *);
74 char *make_route_string (RouteStyleType rs[], int n_styles);
75 int ParseGroupString (char *, LayerGroupType *, int * /* LayerN */);
76 int ParseRouteString (char *, RouteStyleType *, const char *);
77 void QuitApplication (void);
78 char *EvaluateFilename (char *, char *, char *, char *);
79 char *ExpandFilename (char *, char *);
80 void SetTextBoundingBox (FontType *, TextType *);
82 void SaveOutputWindow (void);
83 int GetLayerNumber (DataType *, LayerType *);
84 int GetLayerGroupNumberByPointer (LayerType *);
85 int GetLayerGroupNumberByNumber (Cardinal);
86 int GetLayerGroupNumberBySide (int);
87 int ChangeGroupVisibility (int, bool, bool);
88 void LayerStringToLayerStack (char *);
91 BoxType * GetObjectBoundingBox (int, void *, void *, void *);
92 void ResetStackAndVisibility (void);
93 void SaveStackAndVisibility (void);
94 void RestoreStackAndVisibility (void);
95 char *GetWorkingDirectory (char *);
96 void CreateQuotedString (DynamicStringType *, char *);
97 BoxType * GetArcEnds (ArcType *);
98 void ChangeArcAngles (LayerType *, ArcType *, Angle, Angle);
99 char *UniqueElementName (DataType *, char *);
100 void AttachForCopy (Coord, Coord);
101 double GetValue (const char *, const char *, bool *);
102 double GetValueEx (const char *, const char *, bool *, UnitList, const char *);
103 double GetUnitlessValue (const char *, bool *);
104 int FileExists (const char *);
105 char *Concat (const char *, ...); /* end with NULL */
107 char *pcb_author ();
108 char *AttributeGetFromList (AttributeListType *list, char *name);
109 int AttributePutToList (AttributeListType *list, const char *name, const char *value, int replace);
110 /* Simplistic version: Takes a pointer to an object, looks up attributes in it. */
111 #define AttributeGet(OBJ,name) AttributeGetFromList (&(OBJ->Attributes), name)
112 /* Simplistic version: Takes a pointer to an object, sets attributes in it. */
113 #define AttributePut(OBJ,name,value) AttributePutToList (&(OBJ->Attributes), name, value, 1)
114 void AttributeRemoveFromList(AttributeListType *list, char *name);
115 /* Simplistic version of Remove. */
116 #define AttributeRemove(OBJ, name) AttributeRemoveFromList (&(OBJ->Attributes), name)
118 /* For passing modified flags to other functions. */
119 FlagType MakeFlags (unsigned int);
120 FlagType OldFlags (unsigned int);
121 FlagType AddFlags (FlagType, unsigned int);
122 FlagType MaskFlags (FlagType, unsigned int);
123 #define NoFlags() MakeFlags(0)
125 /* Layer Group Functions */
127 int MoveLayerToGroup (int layer, int group);
128 char *LayerGroupsToString (LayerGroupType *);
129 /*! \todo is this an orphan prototype ?
131 * Make the current layer groups the default.
133 void MakeLayerGroupsDefault ();
135 extern const char *c_dtostr(double d);
136 char * GetInfoString (void);
137 void AssignDefaultLayerTypes ();
138 int ElementOrientation (ElementType *e);
140 /* Buried vias Functions */
141 bool IsLayerMoveSafe (int, int);
142 void ChangeBuriedViasAfterLayerMove (int, int);
143 void ChangeBuriedViasAfterLayerCreate (int);
144 void ChangeBuriedViasAfterLayerDelete (int);
145 bool ViaIsOnLayerGroup (PinType *, int);
146 bool ViaIsOnAnyVisibleLayer (PinType *);
147 void SanitizeBuriedVia (PinType *);
149 int GetMaxBottomLayer ();
154 * \todo These are in netlist.c
156 void NetlistChanged (int force_unfreeze);
159 * Check whether mkdir() is mkdir or _mkdir, and whether it takes one
160 * or two arguments. WIN32 mkdir takes one argument and POSIX takes
161 * two.
163 #if HAVE_MKDIR
164 #if MKDIR_TAKES_ONE_ARG
165 /* MinGW32 */
166 #include <io.h> /* mkdir under MinGW only takes one argument */
167 #define MKDIR(a, b) mkdir(a)
168 #else
169 #define MKDIR(a, b) mkdir(a, b)
170 #endif
171 #else
172 #if HAVE__MKDIR
173 /* plain Windows 32 */
174 #define MKDIR(a, b) _mkdir(a)
175 #else
176 #define MKDIR(a, b) pcb_mkdir(a, b)
177 #define MKDIR_IS_PCBMKDIR 1
178 int pcb_mkdir (const char *path, int mode);
179 #endif
180 #endif
183 #endif /* PCB_MISC_H */