1 /*! 2 * \file src/misc.h 3 * 4 * \brief Prototypes for misc routines. 5 * 6 * <hr> 7 * 8 * <h1><b>Copyright.</b></h1>\n 9 * 10 * PCB, interactive printed circuit board design 11 * 12 * Copyright (C) 1994,1995,1996,2006 Thomas Nau 13 * 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. 18 * 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. 23 * 24 * You should have received a copy of the GNU General Public License along 25 * with this program; if not, write to the Free Software Foundation, Inc., 26 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 27 * 28 * Contact addresses for paper mail and Email: 29 * 30 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany 31 * 32 * Thomas.Nau@rz.uni-ulm.de 33 */ 34 35 #ifndef PCB_MISC_H 36 #define PCB_MISC_H 37 38 #include <stdlib.h> 39 #include "global.h" 40 #include "mymem.h" 41 42 enum unitflags { UNIT_PERCENT = 1 }; 43 44 typedef struct { 45 const char *suffix; 46 double scale; 47 enum unitflags flags; 48 } UnitList[]; 49 50 double Distance (double x1, double y1, double x2, double y2); 51 Angle NormalizeAngle (Angle a); 52 53 void r_delete_element (DataType *, ElementType *); 54 void SetLineBoundingBox (LineType *); 55 void SetArcBoundingBox (ArcType *); 56 void SetPointBoundingBox (PointType *); 57 void SetPinBoundingBox (PinType *); 58 void SetPadBoundingBox (PadType *); 59 void SetPolygonBoundingBox (PolygonType *); 60 void SetElementBoundingBox (DataType *, ElementType *, FontType *); 61 bool IsDataEmpty (DataType *); 62 bool IsLayerEmpty (LayerType *); 63 bool IsLayerNumEmpty (int); 64 bool IsLayerGroupEmpty (int); 65 bool IsPasteEmpty (int); 66 void CountHoles (int *, int *, const BoxType *); 67 void CountHolesEx (int *, int *, const BoxType *, Cardinal, Cardinal); 68 BoxType * GetDataBoundingBox (DataType *); 69 void CenterDisplay (Coord, Coord, bool warp_pointer); 70 void SetFontInfo (FontType *); 71 char *make_route_string (RouteStyleType rs[], int n_styles); 72 int ParseGroupString (char *, LayerGroupType *, int * /* LayerN */); 73 int ParseRouteString (char *, RouteStyleType *, const char *); 74 void QuitApplication (void); 75 char *EvaluateFilename (char *, char *, char *, char *); 76 char *ExpandFilename (char *, char *); 77 void SetTextBoundingBox (FontType *, TextType *); 78 79 void SaveOutputWindow (void); 80 int GetLayerNumber (DataType *, LayerType *); 81 int GetLayerGroupNumberByPointer (LayerType *); 82 int GetLayerGroupNumberByNumber (Cardinal); 83 int GetLayerGroupNumberBySide (int); 84 int ChangeGroupVisibility (int, bool, bool); 85 void LayerStringToLayerStack (char *); 86 87 88 BoxType * GetObjectBoundingBox (int, void *, void *, void *); 89 void ResetStackAndVisibility (void); 90 void SaveStackAndVisibility (void); 91 void RestoreStackAndVisibility (void); 92 char *GetWorkingDirectory (char *); 93 void CreateQuotedString (DynamicStringType *, char *); 94 BoxType * GetArcEnds (ArcType *); 95 void ChangeArcAngles (LayerType *, ArcType *, Angle, Angle); 96 char *UniqueElementName (DataType *, char *); 97 void AttachForCopy (Coord, Coord); 98 double GetValue (const char *, const char *, bool *); 99 double GetValueEx (const char *, const char *, bool *, UnitList, const char *); 100 double GetUnitlessValue (const char *, bool *); 101 int FileExists (const char *); 102 char *Concat (const char *, ...); /* end with NULL */ 103 104 char *pcb_author (); 105 char *AttributeGetFromList (AttributeListType *list, char *name); 106 int AttributePutToList (AttributeListType *list, const char *name, const char *value, int replace); 107 /* Simplistic version: Takes a pointer to an object, looks up attributes in it. */ 108 #define AttributeGet(OBJ,name) AttributeGetFromList (&(OBJ->Attributes), name) 109 /* Simplistic version: Takes a pointer to an object, sets attributes in it. */ 110 #define AttributePut(OBJ,name,value) AttributePutToList (&(OBJ->Attributes), name, value, 1) 111 void AttributeRemoveFromList(AttributeListType *list, char *name); 112 /* Simplistic version of Remove. */ 113 #define AttributeRemove(OBJ, name) AttributeRemoveFromList (&(OBJ->Attributes), name) 114 115 /* Layer Group Functions */ 116 117 int MoveLayerToGroup (int layer, int group); 118 char *LayerGroupsToString (LayerGroupType *); 119 /*! \todo is this an orphan prototype ? 120 * 121 * Make the current layer groups the default. 122 */ 123 void MakeLayerGroupsDefault (); 124 125 extern const char *c_dtostr(double d); 126 char * GetInfoString (void); 127 void AssignDefaultLayerTypes (); 128 int ElementOrientation (ElementType *e); 129 130 /* Buried vias Functions */ 131 bool IsLayerMoveSafe (int, int); 132 void ChangeBuriedViasAfterLayerMove (int, int); 133 void ChangeBuriedViasAfterLayerCreate (int); 134 void ChangeBuriedViasAfterLayerDelete (int); 135 bool ViaIsOnLayerGroup (PinType *, int); 136 bool ViaIsOnAnyVisibleLayer (PinType *); 137 void SanitizeBuriedVia (PinType *); 138 139 int GetMaxBottomLayer (); 140 141 142 143 /*! 144 * \todo These are in netlist.c 145 */ 146 void NetlistChanged (int force_unfreeze); 147 148 /* 149 * Check whether mkdir() is mkdir or _mkdir, and whether it takes one 150 * or two arguments. WIN32 mkdir takes one argument and POSIX takes 151 * two. 152 */ 153 #if HAVE_MKDIR 154 #if MKDIR_TAKES_ONE_ARG 155 /* MinGW32 */ 156 #include <io.h> /* mkdir under MinGW only takes one argument */ 157 #define MKDIR(a, b) mkdir(a) 158 #else 159 #define MKDIR(a, b) mkdir(a, b) 160 #endif 161 #else 162 #if HAVE__MKDIR 163 /* plain Windows 32 */ 164 #define MKDIR(a, b) _mkdir(a) 165 #else 166 #define MKDIR(a, b) pcb_mkdir(a, b) 167 #define MKDIR_IS_PCBMKDIR 1 168 int pcb_mkdir (const char *path, int mode); 169 #endif 170 #endif 171 172 173 #endif /* PCB_MISC_H */ 174 175