(no commit message)
[geda-pcb/pcjc2.git] / src / misc.h
blobd6f33e558b1f92f296464f7914816d054adcb6ef
1 /*
2 * COPYRIGHT
4 * PCB, interactive printed circuit board design
5 * Copyright (C) 1994,1995,1996,2006 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 misc routines
30 #ifndef PCB_MISC_H
31 #define PCB_MISC_H
33 #include <stdlib.h>
34 #include "global.h"
35 #include "mymem.h"
37 enum unitflags { UNIT_PERCENT = 1 };
39 typedef struct {
40 const char *suffix;
41 double scale;
42 enum unitflags flags;
43 } UnitList[];
45 double Distance (double x1, double y1, double x2, double y2);
46 Angle NormalizeAngle (Angle a);
48 void r_delete_element (DataType *, ElementType *);
49 void SetLineBoundingBox (LineType *);
50 void SetArcBoundingBox (ArcType *);
51 void SetPointBoundingBox (PointType *);
52 void SetPinBoundingBox (PinType *);
53 void SetPadBoundingBox (PadType *);
54 void SetPolygonBoundingBox (PolygonType *);
55 void SetElementBoundingBox (DataType *, ElementType *, FontType *);
56 bool IsDataEmpty (DataType *);
57 bool IsLayerEmpty (LayerType *);
58 bool IsLayerNumEmpty (int);
59 bool IsLayerGroupEmpty (int);
60 bool IsPasteEmpty (int);
61 void CountHoles (int *, int *, const BoxType *);
62 BoxType * GetDataBoundingBox (DataType *);
63 void CenterDisplay (Coord, Coord);
64 void SetFontInfo (FontType *);
65 char *make_route_string (RouteStyleType rs[], int n_styles);
66 int ParseGroupString (char *, LayerGroupType *, int * /* LayerN */);
67 int ParseRouteString (char *, RouteStyleType *, const char *);
68 void QuitApplication (void);
69 char *EvaluateFilename (char *, char *, char *, char *);
70 char *ExpandFilename (char *, char *);
71 void SetTextBoundingBox (FontType *, TextType *);
73 void SaveOutputWindow (void);
74 int GetLayerNumber (DataType *, LayerType *);
75 int GetLayerGroupNumberByPointer (LayerType *);
76 int GetLayerGroupNumberByNumber (Cardinal);
77 int GetLayerGroupNumberBySide (int);
78 int ChangeGroupVisibility (int, bool, bool);
79 void LayerStringToLayerStack (char *);
82 BoxType * GetObjectBoundingBox (int, void *, void *, void *);
83 void ResetStackAndVisibility (void);
84 void SaveStackAndVisibility (void);
85 void RestoreStackAndVisibility (void);
86 char *GetWorkingDirectory (char *);
87 void CreateQuotedString (DynamicStringType *, char *);
88 BoxType * GetArcEnds (ArcType *);
89 void ChangeArcAngles (LayerType *, ArcType *, Angle, Angle);
90 char *UniqueElementName (DataType *, char *);
91 void AttachForCopy (Coord, Coord);
92 double GetValue (const char *, const char *, bool *);
93 double GetValueEx (const char *, const char *, bool *, UnitList, const char *);
94 int FileExists (const char *);
95 char *Concat (const char *, ...); /* end with NULL */
97 char *pcb_author ();
99 /* Returns NULL if the name isn't found, else the value for that named
100 attribute. */
101 char *AttributeGetFromList (AttributeListType *list, char *name);
102 /* Adds an attribute to the list. If the attribute already exists,
103 whether it's replaced or a second copy added depends on
104 REPLACE. Returns non-zero if an existing attribute was replaced. */
105 int AttributePutToList (AttributeListType *list, const char *name, const char *value, int replace);
106 /* Simplistic version: Takes a pointer to an object, looks up attributes in it. */
107 #define AttributeGet(OBJ,name) AttributeGetFromList (&(OBJ->Attributes), name)
108 /* Simplistic version: Takes a pointer to an object, sets attributes in it. */
109 #define AttributePut(OBJ,name,value) AttributePutToList (&(OBJ->Attributes), name, value, 1)
110 /* Remove an attribute by name. */
111 void AttributeRemoveFromList(AttributeListType *list, char *name);
112 /* Simplistic version of Remove. */
113 #define AttributeRemove(OBJ, name) AttributeRemoveFromList (&(OBJ->Attributes), name)
115 /* For passing modified flags to other functions. */
116 FlagType MakeFlags (unsigned int);
117 FlagType OldFlags (unsigned int);
118 FlagType AddFlags (FlagType, unsigned int);
119 FlagType MaskFlags (FlagType, unsigned int);
120 #define NoFlags() MakeFlags(0)
122 /* Layer Group Functions */
124 /* Returns group actually moved to (i.e. either group or previous) */
125 int MoveLayerToGroup (int layer, int group);
126 /* returns pointer to private buffer */
127 char *LayerGroupsToString (LayerGroupType *);
128 /* Make the current layer groups the default. */
129 void MakeLayerGroupsDefault ();
131 /* These act like you'd expect, except always in the C locale. */
132 extern const char *c_dtostr(double d);
134 /* Returns a string with info about this copy of pcb. */
135 char * GetInfoString (void);
137 /* Return a relative rotation for an element, useful only for
138 comparing two similar footprints. */
139 int ElementOrientation (ElementType *e);
141 /* These are in netlist.c */
143 void NetlistChanged (int force_unfreeze);
146 * Check whether mkdir() is mkdir or _mkdir, and whether it takes one
147 * or two arguments. WIN32 mkdir takes one argument and POSIX takes
148 * two.
150 #if HAVE_MKDIR
151 #if MKDIR_TAKES_ONE_ARG
152 /* MinGW32 */
153 #include <io.h> /* mkdir under MinGW only takes one argument */
154 #define MKDIR(a, b) mkdir(a)
155 #else
156 #define MKDIR(a, b) mkdir(a, b)
157 #endif
158 #else
159 #if HAVE__MKDIR
160 /* plain Windows 32 */
161 #define MKDIR(a, b) _mkdir(a)
162 #else
163 #define MKDIR(a, b) pcb_mkdir(a, b)
164 #define MKDIR_IS_PCBMKDIR 1
165 int pcb_mkdir (const char *path, int mode);
166 #endif
167 #endif
170 #endif /* PCB_MISC_H */