pcb 4.1.1
An interactive printed circuit board layout editor.

src/misc.c File Reference

Misc functions used by several modules. More...

#include <stdlib.h>
#include <stdarg.h>
#include <memory.h>
#include <ctype.h>
#include <signal.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <math.h>
#include "global.h"
#include "box.h"
#include "crosshair.h"
#include "create.h"
#include "data.h"
#include "draw.h"
#include "file.h"
#include "error.h"
#include "mymem.h"
#include "misc.h"
#include "move.h"
#include "pcb-printf.h"
#include "polygon.h"
#include "remove.h"
#include "rtree.h"
#include "rotate.h"
#include "rubberband.h"
#include "search.h"
#include "set.h"
#include "undo.h"
#include "action.h"
Include dependency graph for src/misc.c:

Go to the source code of this file.

Data Structures

struct  HoleCountStruct

Defines

#define TAB   " "

Functions

static char * BumpName (char *)
static void GetGridLockCoordinates (int, void *, void *, void *, Coord *, Coord *)
double Distance (double x1, double y1, double x2, double y2)
 Distance() should be used so that there is only one place to deal with overflow/precision errors.
Angle NormalizeAngle (Angle a)
 Bring an angle into [0, 360] range.
double GetValue (const char *val, const char *units, bool *absolute)
 GetValue() returns a numeric value passed from the string and sets the bool variable absolute to false if it leads with a +/- character.
double GetValueEx (const char *val, const char *units, bool *absolute, UnitList extra_units, const char *default_unit)
double GetUnitlessValue (const char *val, bool *absolute)
 Extract a unit-less value from a string.
void SetPointBoundingBox (PointType *Pnt)
 Sets the bounding box of a point (which is silly).
void SetPinBoundingBox (PinType *Pin)
 Sets the bounding box of a pin or via.
void SetPadBoundingBox (PadType *Pad)
 Sets the bounding box of a pad.
void SetLineBoundingBox (LineType *Line)
 Sets the bounding box of a line.
void SetPolygonBoundingBox (PolygonType *Polygon)
 Sets the bounding box of a polygons.
void SetElementBoundingBox (DataType *Data, ElementType *Element, FontType *Font)
 Sets the bounding box of an element.
void SetTextBoundingBox (FontType *FontPtr, TextType *Text)
 Creates the bounding box of a text object.
bool IsDataEmpty (DataType *Data)
 Returns true if data area is empty.
int FlagIsDataEmpty (int parm)
bool IsLayerEmpty (LayerType *layer)
bool IsLayerNumEmpty (int num)
bool IsLayerGroupEmpty (int num)
bool IsPasteEmpty (int side)
static int hole_counting_callback (const BoxType *b, void *cl)
void CountHoles (int *plated, int *unplated, const BoxType *within_area)
 Counts the number of plated and unplated holes in the design within a given area of the board.
void CountHolesEx (int *plated, int *unplated, const BoxType *within_area, Cardinal group_from, Cardinal group_to)
 Counts the number of plated and unplated holes in the design within a given area of the board.
BoxTypeGetDataBoundingBox (DataType *Data)
 Gets minimum and maximum coordinates.
void CenterDisplay (Coord X, Coord Y, bool warp_pointer)
 Centers the displayed PCB around the specified point (X,Y), and move the crosshair there.
void SetFontInfo (FontType *Ptr)
 Transforms symbol coordinates so that the left edge of each symbol is at the zero position.
static Coord GetNum (char **s, const char *default_unit)
char * make_route_string (RouteStyleType rs[], int n_styles)
 Serializes the route style list .
int ParseRouteString (char *s, RouteStyleType *routeStyle, const char *default_unit)
int ParseGroupString (char *group_string, LayerGroupType *LayerGroup, int *LayerN)
void AssignDefaultLayerTypes ()
 Sets up any remaining layer type guesses.
void pcb_main_uninit (void)
 Free up memory allocated to the PCB.
void QuitApplication (void)
 Quits application.
char * EvaluateFilename (char *Template, char *Path, char *Filename, char *Parameter)
 Creates a filename from a template.
char * ExpandFilename (char *Dirname, char *Filename)
 Concatenates directory and filename.
int GetLayerNumber (DataType *Data, LayerType *Layer)
 Returns the layer number for the passed pointer.
static void PushOnTopOfLayerStack (int NewTop)
 Move layer (number is passed in) to top of layerstack.
int ChangeGroupVisibility (int Layer, bool On, bool ChangeStackOrder)
 Changes the visibility of all layers in a group.
void LayerStringToLayerStack (char *s)
 Given a string description of a layer stack, adjust the layer stack to correspond.
int GetLayerGroupNumberByPointer (LayerType *Layer)
 Returns the layergroup number for the passed pointer.
int GetLayerGroupNumberByNumber (Cardinal Layer)
 Returns the layergroup number for the passed layer number.
int GetLayerGroupNumberBySide (int side)
 Returns the layergroup number for the passed side (TOP_SIDE or BOTTOM_SIDE).
BoxTypeGetObjectBoundingBox (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
 Returns a pointer to an objects bounding box.
void SetArcBoundingBox (ArcType *Arc)
 Computes the bounding box of an arc.
void ResetStackAndVisibility (void)
 Resets the layerstack setting.
void SaveStackAndVisibility (void)
 Saves the layerstack setting.
void RestoreStackAndVisibility (void)
 Restores the layerstack setting.
char * GetWorkingDirectory (char *path)
 Returns pointer to current working directory.
void CreateQuotedString (DynamicStringType *DS, char *S)
 Write a string to the passed file pointer.
BoxTypeGetArcEnds (ArcType *Arc)
void ChangeArcAngles (LayerType *Layer, ArcType *a, Angle new_sa, Angle new_da)
char * UniqueElementName (DataType *Data, char *Name)
 Make a unique name for the name on board.
void AttachForCopy (Coord PlaceX, Coord PlaceY)
int FileExists (const char *name)
 Return nonzero if the given file exists and is readable.
char * Concat (const char *first,...)
int mem_any_set (unsigned char *ptr, int bytes)
FlagType MakeFlags (unsigned int flags)
 This just fills in a FlagType with current flags.
FlagType OldFlags (unsigned int flags)
 This converts old flag bits (from saved PCB files) to new format.
FlagType AddFlags (FlagType flag, unsigned int flags)
FlagType MaskFlags (FlagType flag, unsigned int flags)
int MoveLayerToGroup (int layer, int group)
 Returns group actually moved to (i.e. either group or previous).
char * LayerGroupsToString (LayerGroupType *lg)
 Returns pointer to private buffer.
int GetMaxBottomLayer ()
void SanitizeBuriedVia (PinType *via)
 Sanitize buried via.
void ChangeBuriedViasAfterLayerMove (int old_index, int new_index)
 Update buried vias after layer move.
void ChangeBuriedViasAfterLayerCreate (int index)
 Update buried vias after new layer create.
void ChangeBuriedViasAfterLayerDelete (int index)
 Update buried vias after layer delete.
bool ViaIsOnLayerGroup (PinType *via, int group)
 Check if via penetrates layer group.
bool ViaIsOnAnyVisibleLayer (PinType *via)
 Check if via penetrates any visible layer.
char * pcb_author (void)
char * AttributeGetFromList (AttributeListType *list, char *name)
 Returns NULL if the name isn't found, else the value for that named attribute.
int AttributePutToList (AttributeListType *list, const char *name, const char *value, int replace)
 Adds an attribute to the list.
void AttributeRemoveFromList (AttributeListType *list, char *name)
 Remove an attribute by name.
const char * c_dtostr (double d)
void r_delete_element (DataType *data, ElementType *element)
char * GetInfoString (void)
 Returns a string that has a bunch of information about the program.
int pcb_mkdir (const char *path, int mode)
 mkdir() implentation, mostly for plugins, which don't have our config.h.
int ElementOrientation (ElementType *e)
 Returns a best guess about the orientation of an element.
int ActionListRotations (int argc, char **argv, Coord x, Coord y)

Variables

struct {
   bool   ElementOn
   bool   InvisibleObjectsOn
   bool   PinOn
   bool   ViaOn
   bool   RatOn
   int   LayerStack [MAX_ALL_LAYER]
   bool   LayerOn [MAX_ALL_LAYER]
   int   cnt
SavedStack
HID_Action misc_action_list []

Detailed Description

Misc functions used by several modules.


Copyright.


PCB, interactive printed circuit board design

Copyright (C) 1994,1995,1996,2004,2006 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 src/misc.c.


Define Documentation

#define TAB   " "

Referenced by GetInfoString().


Function Documentation

int ActionListRotations ( int  argc,
char **  argv,
Coord  x,
Coord  y 
)

Definition at line 2854 of file src/misc.c.

References PCBType::Data, ELEMENT_LOOP, ElementOrientation(), END_LOOP, NAMEONPCB_NAME, and PCB.

Here is the call graph for this function:

FlagType AddFlags ( FlagType  flag,
unsigned int  flags 
)

Definition at line 2144 of file src/misc.c.

References FlagType::f.

Referenced by SmashBufferElement().

void AssignDefaultLayerTypes ( )

Sets up any remaining layer type guesses.

Definition at line 1227 of file src/misc.c.

References PCBType::Data, END_LOOP, layer, LAYER_TYPE_LOOP, LT_OUTLINE, LT_ROUTE, max_copper_layer, n, outline_layer, and PCB.

Referenced by real_load_pcb().

char* AttributeGetFromList ( AttributeListType list,
char *  name 
)

Returns NULL if the name isn't found, else the value for that named attribute.

Definition at line 2546 of file src/misc.c.

References AttributeListType::List, AttributeType::name, AttributeListType::Number, and AttributeType::value.

Referenced by gsvit_write_xcentroids(), and PrintBOM().

int AttributePutToList ( AttributeListType list,
const char *  name,
const char *  value,
int  replace 
)

Adds an attribute to the list.

If the attribute already exists, whether it's replaced or a second copy added depends on REPLACE.

Returns:
Non-zero if an existing attribute was replaced.

Definition at line 2564 of file src/misc.c.

References AttributeListType::List, AttributeListType::Max, AttributeType::name, AttributeListType::Number, realloc(), STRDUP, and AttributeType::value.

Here is the call graph for this function:

void AttributeRemoveFromList ( AttributeListType list,
char *  name 
)

Remove an attribute by name.

Definition at line 2602 of file src/misc.c.

References AttributeListType::List, AttributeType::name, AttributeListType::Number, and AttributeType::value.

static char * BumpName ( char *  Name) [static]

Definition at line 1910 of file src/misc.c.

References c.

Referenced by UniqueElementName().

const char* c_dtostr ( double  d)
Todo:
In future all use of this should be supplanted by pcb-printf and mr/m# spec.

These act like you'd expect, except always in the C locale.

Definition at line 2623 of file src/misc.c.

References f.

Referenced by WritePCBDataHeader().

void CenterDisplay ( Coord  X,
Coord  Y,
bool  warp_pointer 
)

Centers the displayed PCB around the specified point (X,Y), and move the crosshair there.

If warp_pointer is true warp the pointer to the crosshair.

Definition at line 878 of file src/misc.c.

References Crosshair, PCBType::Grid, gui, HID_SC_CENTER_IN_VIEWPORT, HID_SC_CENTER_IN_VIEWPORT_AND_WARP_POINTER, MoveCrosshairAbsolute(), notify_crosshair_change(), PCB, hid_st::set_crosshair, CrosshairType::X, and CrosshairType::Y.

Referenced by ActionAddRats(), ActionNew(), GotoError(), row_activated_cb(), and selection_changed_cb().

Here is the call graph for this function:

void ChangeArcAngles ( LayerType Layer,
ArcType a,
Angle  new_sa,
Angle  new_da 
)
Todo:
Doesn't this belong in change.c ??

Definition at line 1891 of file src/misc.c.

References AddObjectToChangeAnglesUndoList(), LayerType::arc_tree, ClearFromPolygon(), PCBType::Data, PCB, r_delete_entry(), r_insert_entry(), RestoreToPolygon(), and SetArcBoundingBox().

Referenced by maybe_pull_1(), Puller(), and reverse_arc().

Here is the call graph for this function:

void ChangeBuriedViasAfterLayerCreate ( int  index)

Update buried vias after new layer create.

Definition at line 2411 of file src/misc.c.

References AddObjectToSetViaLayersUndoList(), PCBType::Data, END_LOOP, PCB, VIA_IS_BURIED, and VIA_LOOP.

Referenced by MoveLayer().

Here is the call graph for this function:

void ChangeBuriedViasAfterLayerDelete ( int  index)

Update buried vias after layer delete.

Definition at line 2435 of file src/misc.c.

References AddObjectToSetViaLayersUndoList(), PCBType::Data, END_LOOP, PCB, RemoveDegradedVias(), SanitizeBuriedVia(), VIA_IS_BURIED, and VIA_LOOP.

Referenced by MoveLayer().

Here is the call graph for this function:

void ChangeBuriedViasAfterLayerMove ( int  old_index,
int  new_index 
)

Update buried vias after layer move.

Definition at line 2309 of file src/misc.c.

References _, AddObjectToSetViaLayersUndoList(), PCBType::Data, END_LOOP, Message(), PCB, RemoveDegradedVias(), SanitizeBuriedVia(), VIA_IS_BURIED, VIA_LOOP, and VIA_ON_LAYER.

Referenced by MoveLayer().

Here is the call graph for this function:

int ChangeGroupVisibility ( int  Layer,
bool  On,
bool  ChangeStackOrder 
)
char* Concat ( const char *  first,
  ... 
)
void CountHoles ( int *  plated,
int *  unplated,
const BoxType within_area 
)

Counts the number of plated and unplated holes in the design within a given area of the board.

To count for the whole board, pass NULL to the within_area.

Definition at line 764 of file src/misc.c.

References PCBType::Data, hole_counting_callback(), HoleCountStruct::nplated, HoleCountStruct::nunplated, PCB, DataType::pin_tree, r_search(), and DataType::via_tree.

Referenced by DrawEverything().

Here is the call graph for this function:

void CountHolesEx ( int *  plated,
int *  unplated,
const BoxType within_area,
Cardinal  group_from,
Cardinal  group_to 
)

Counts the number of plated and unplated holes in the design within a given area of the board.

To count for the whole board, pass NULL to the within_area.

Definition at line 782 of file src/misc.c.

References PCBType::Data, hole_counting_callback(), HoleCountStruct::nplated, HoleCountStruct::nunplated, PCB, DataType::pin_tree, r_search(), and DataType::via_tree.

Referenced by DrawEverything().

Here is the call graph for this function:

void CreateQuotedString ( DynamicStringType DS,
char *  S 
)

Write a string to the passed file pointer.

Some special characters are quoted.

Definition at line 1862 of file src/misc.c.

References DSAddCharacter(), and DSClearString().

Referenced by PrintAndSelectUnusedPinsAndPadsOfElement(), PrintConnectionListEntry(), PrintElementNameList(), and PrintQuotedString().

Here is the call graph for this function:

int ElementOrientation ( ElementType e)

Returns a best guess about the orientation of an element.

The value corresponds to the rotation; a difference is the right value to pass to RotateElementLowLevel. However, the actual value is no indication of absolute rotation; only relative rotation is meaningful.

Returns:
a relative rotation for an element, useful only for comparing two similar footprints.

Definition at line 2784 of file src/misc.c.

References abs, END_LOOP, NSTRCMP, pin_st::Number, PAD_LOOP, pin, PIN_LOOP, pin_st::X, and pin_st::Y.

Referenced by ActionElementList(), and ActionListRotations().

char* EvaluateFilename ( char *  Template,
char *  Path,
char *  Filename,
char *  Parameter 
)

Creates a filename from a template.

"%f" is replaced by the filename.

"%p" is replaced by the searchpath.

Definition at line 1319 of file src/misc.c.

References command, DynamicStringType::Data, DSAddCharacter(), DSAddString(), DSClearString(), Settings, and SettingType::verbose.

Referenced by Parse(), ReadLibraryContents(), and ReadNetlist().

Here is the call graph for this function:

char* ExpandFilename ( char *  Dirname,
char *  Filename 
)

Concatenates directory and filename.

If directory != NULL expands them with a shell and returns the found name(s) or NULL.

Definition at line 1369 of file src/misc.c.

References c, command, DynamicStringType::Data, DSAddCharacter(), DSClearString(), and PopenErrorMessage().

Here is the call graph for this function:

int FileExists ( const char *  name)

Return nonzero if the given file exists and is readable.

Definition at line 2062 of file src/misc.c.

References f.

int FlagIsDataEmpty ( int  parm)

Definition at line 672 of file src/misc.c.

References PCBType::Data, IsDataEmpty(), and PCB.

Here is the call graph for this function:

BoxType* GetDataBoundingBox ( DataType Data)

Gets minimum and maximum coordinates.

Returns:
NULL if layout is empty.

Definition at line 799 of file src/misc.c.

References ALLARC_LOOP, ALLLINE_LOOP, ALLPOLYGON_LOOP, ALLTEXT_LOOP, box, ELEMENT_LOOP, END_LOOP, ENDALL_LOOP, IsDataEmpty(), line, MAX, MIN, NAMEONPCB_TEXT, VIA_LOOP, BoxType::X1, BoxType::X2, BoxType::Y1, and BoxType::Y2.

Referenced by eps_hid_export_to_file(), png_do_export(), png_hid_export_to_file(), and SetBufferBoundingBox().

Here is the call graph for this function:

static void GetGridLockCoordinates ( int  type,
void *  ptr1,
void *  ptr2,
void *  ptr3,
Coord x,
Coord y 
) [static]

Definition at line 1969 of file src/misc.c.

References box, GetArcEnds(), BoxType::X1, and BoxType::Y1.

Referenced by AttachForCopy().

Here is the call graph for this function:

char* GetInfoString ( void  )

Returns a string that has a bunch of information about the program.

Can be used for things like "about" dialog boxes.

Definition at line 2675 of file src/misc.c.

References _, DynamicStringType::Data, DSAddString(), exporter, gui, hid_enumerate(), and TAB.

Referenced by About(), and ghid_dialog_about().

Here is the call graph for this function:

int GetLayerGroupNumberByPointer ( LayerType Layer)
int GetMaxBottomLayer ( )
static Coord GetNum ( char **  s,
const char *  default_unit 
) [static]

Definition at line 969 of file src/misc.c.

References GetValueEx().

Referenced by ParseRouteString().

Here is the call graph for this function:

BoxType* GetObjectBoundingBox ( int  Type,
void *  Ptr1,
void *  Ptr2,
void *  Ptr3 
)

Returns a pointer to an objects bounding box.

Data is valid until the routine is called again.

Definition at line 1645 of file src/misc.c.

References _, and Message().

Referenced by crosshair_update_range().

Here is the call graph for this function:

double GetUnitlessValue ( const char *  val,
bool *  absolute 
)

Extract a unit-less value from a string.

Parameters:
valString containing the value to be read.
absoluteReturns whether the returned value is an absolute one.
Returns:
The value read, with sign.

This is the same as GetValue() and GetValueEx(), but totally ignoring units. Typical application is a list selector, like the type of thermal to apply to a pin.

Definition at line 233 of file src/misc.c.

Referenced by ActionSetThermal().

double GetValue ( const char *  val,
const char *  units,
bool *  absolute 
)
double GetValueEx ( const char *  val,
const char *  units,
bool *  absolute,
UnitList  extra_units,
const char *  default_unit 
)

Definition at line 140 of file src/misc.c.

References get_unit_struct(), n, UnitList::scale, UnitList::suffix, UNIT_PERCENT, and unit_to_coord().

Referenced by CursorAction(), GetNum(), GetValue(), hid_get_flag(), parse_bloat(), style_value_cb(), and sz_str2val().

Here is the call graph for this function:

char* GetWorkingDirectory ( char *  path)

Returns pointer to current working directory.

If 'path' is not NULL, then the current working directory is copied to the array pointed to by 'path'.

Definition at line 1845 of file src/misc.c.

Referenced by LoadNewlibFootprintsFromDir(), and ParseLibraryTree().

static int hole_counting_callback ( const BoxType b,
void *  cl 
) [static]
bool IsDataEmpty ( DataType Data)
bool IsLayerEmpty ( LayerType layer)

Definition at line 682 of file src/misc.c.

References LayerType::ArcN, LayerType::LineN, LayerType::PolygonN, and LayerType::TextN.

Referenced by DrawLayer(), and IsLayerNumEmpty().

bool IsLayerGroupEmpty ( int  num)

Definition at line 697 of file src/misc.c.

References LayerGroupType::Entries, IsLayerNumEmpty(), PCBType::LayerGroups, LayerGroupType::Number, and PCB.

Referenced by png_hid_export_to_file().

Here is the call graph for this function:

bool IsLayerNumEmpty ( int  num)

Definition at line 691 of file src/misc.c.

References PCBType::Data, IsLayerEmpty(), DataType::Layer, and PCB.

Referenced by IsLayerGroupEmpty().

Here is the call graph for this function:

bool IsPasteEmpty ( int  side)

Definition at line 707 of file src/misc.c.

References ALLPAD_LOOP, PCBType::Data, ENDALL_LOOP, ON_SIDE, PCB, and TEST_FLAG.

Referenced by DrawEverything().

char* LayerGroupsToString ( LayerGroupType lg)

Returns pointer to private buffer.

Definition at line 2195 of file src/misc.c.

References bottom_silk_layer, LayerGroupType::Entries, layer, PCBType::LayerGroups, MAX_ALL_LAYER, max_group, LayerGroupType::Number, PCB, and top_silk_layer.

Referenced by WritePCBDataHeader().

void LayerStringToLayerStack ( char *  s)

Given a string description of a layer stack, adjust the layer stack to correspond.

Definition at line 1502 of file src/misc.c.

References _, args, ChangeGroupVisibility(), CLEAR_FLAG, PCBType::Data, PCBType::ElementOn, PCBType::InvisibleObjectsOn, DataType::Layer, LayerStack, malloc(), max_copper_layer, LayerType::Name, LayerType::On, PCB, PCBType::PinOn, PCBType::RatOn, SET_FLAG, Settings, SettingType::ShowBottomSide, SILK_LAYER, and PCBType::ViaOn.

Referenced by main().

Here is the call graph for this function:

char* make_route_string ( RouteStyleType  rs[],
int  n_styles 
)

Serializes the route style list .

Right now n_styles should always be set to NUM_STYLES, since that is the number of route styles ParseRouteString() expects to parse.

Definition at line 987 of file src/misc.c.

References FALSE, and pcb_g_strdup_printf().

Referenced by route_styles_edited_cb().

Here is the call graph for this function:

FlagType MakeFlags ( unsigned int  flags)

This just fills in a FlagType with current flags.

Definition at line 2112 of file src/misc.c.

References FlagType::f.

Referenced by ConvertBufferToElement(), export_pcb_drawarc(), export_pcb_drawline(), IronDownAllUnfixedPaths(), NotifyMode(), RD_DrawLine(), and RD_DrawVia().

int mem_any_set ( unsigned char *  ptr,
int  bytes 
)

Definition at line 2100 of file src/misc.c.

int MoveLayerToGroup ( int  layer,
int  group 
)

Returns group actually moved to (i.e. either group or previous).

Definition at line 2164 of file src/misc.c.

References bottom_silk_layer, LayerGroupType::Entries, GetLayerGroupNumberByNumber(), layer, PCBType::LayerGroups, max_copper_layer, max_group, LayerGroupType::Number, PCB, and top_silk_layer.

Referenced by FontEdit(), lgbutton_cb(), and lgbutton_input().

Here is the call graph for this function:

FlagType OldFlags ( unsigned int  flags)

This converts old flag bits (from saved PCB files) to new format.

Definition at line 2125 of file src/misc.c.

References FlagType::f, f, and FlagType::t.

int ParseGroupString ( char *  group_string,
LayerGroupType LayerGroup,
int *  LayerN 
)
int ParseRouteString ( char *  s,
RouteStyleType routeStyle,
const char *  default_unit 
)

Definition at line 1014 of file src/misc.c.

References RouteStyleType::Diameter, error, GetNum(), RouteStyleType::Hole, RouteStyleType::Keepaway, MIL_TO_COORD, RouteStyleType::Name, style, and RouteStyleType::Thick.

Referenced by REGISTER_ATTRIBUTES().

Here is the call graph for this function:

char* pcb_author ( void  )

Definition at line 2501 of file src/misc.c.

References SettingType::FabAuthor, len, malloc(), and Settings.

Referenced by PrintBOM(), and PrintFab().

Here is the call graph for this function:

void pcb_main_uninit ( void  )

Free up memory allocated to the PCB.

Why bother when we're about to exit ?
Because it removes some false positives from heap bug detectors such as lib dmalloc.

Warning:
Please do not free the below variables like:
  for (i = 0; i < MAX_LAYER; i++)
    free (Settings.DefaultLayerName[i]);

  if (Settings.FontFile != NULL)
    {
      free (Settings.FontFile);
      Settings.FontFile = NULL;
    }
as these are initialized to static strings and freeing them causes segfaults when terminating the program.

Definition at line 1910 of file main.c.

References bindir, exec_prefix, free0, FreePCBMemory(), SettingType::GnetlistProgram, gui, hid_uninit(), homedir, SettingType::MakeProgram, PCB, pcblibdir, program_directory, Settings, hid_st::uninit, uninit_strflags_buf(), uninit_strflags_layerlist(), and UninitBuffers().

Referenced by main(), and QuitApplication().

Here is the call graph for this function:

int pcb_mkdir ( const char *  path,
int  mode 
)

mkdir() implentation, mostly for plugins, which don't have our config.h.

Definition at line 2767 of file src/misc.c.

References MKDIR.

static void PushOnTopOfLayerStack ( int  NewTop) [static]

Move layer (number is passed in) to top of layerstack.

Definition at line 1431 of file src/misc.c.

References LayerStack, and max_copper_layer.

Referenced by ChangeGroupVisibility().

void QuitApplication ( void  )

Quits application.

Definition at line 1290 of file src/misc.c.

References PCBType::Changed, DisableEmergencySave(), hid_st::do_exit, EmergencySave(), gui, PCB, pcb_main_uninit(), SettingType::SaveInTMP, and Settings.

Referenced by ActionQuit().

Here is the call graph for this function:

void r_delete_element ( DataType data,
ElementType element 
)
void ResetStackAndVisibility ( void  )
void RestoreStackAndVisibility ( void  )
void SanitizeBuriedVia ( PinType via)

Sanitize buried via.

  • remove degraded vias
  • ensure correct order of layers
  • change full size vias to TH vias

Definition at line 2259 of file src/misc.c.

References pin_st::BuriedFrom, pin_st::BuriedTo, and GetMaxBottomLayer().

Referenced by ChangeBuriedViasAfterLayerDelete(), ChangeBuriedViasAfterLayerMove(), ChangeObjectViaLayers(), and ChangeSelectedViaLayers().

Here is the call graph for this function:

void SaveStackAndVisibility ( void  )
void SetFontInfo ( FontType Ptr)

Transforms symbol coordinates so that the left edge of each symbol is at the zero position.

The y coordinates are moved so that min(y) = 0.

Definition at line 904 of file src/misc.c.

References FontType::DefaultSymbol, SymbolType::Height, SymbolType::Line, line, SymbolType::LineN, MAX, FontType::MaxHeight, FontType::MaxWidth, maxx, maxy, MIN, minx, miny, MOVE_LINE_LOWLEVEL, FontType::Symbol, SymbolType::Valid, SymbolType::Width, BoxType::X1, BoxType::X2, BoxType::Y1, and BoxType::Y2.

Referenced by FontSave().

void SetPadBoundingBox ( PadType Pad)

Sets the bounding box of a pad.

Definition at line 292 of file src/misc.c.

References close_box(), M_PI, pad_st::Mask, MAX, MIN, POLY_CIRC_RADIUS_ADJ, and TEST_FLAG.

Referenced by SetElementBoundingBox().

Here is the call graph for this function:

void SetPinBoundingBox ( PinType Pin)
void SetPointBoundingBox ( PointType Pnt)

Sets the bounding box of a point (which is silly).

Definition at line 259 of file src/misc.c.

References PointType::X, PointType::X2, PointType::Y, and PointType::Y2.

Referenced by SetLineBoundingBox().

void SetPolygonBoundingBox ( PolygonType Polygon)
char* UniqueElementName ( DataType Data,
char *  Name 
)

Make a unique name for the name on board.

This can alter the contents of the input string.

Definition at line 1942 of file src/misc.c.

References BumpName(), ELEMENT_LOOP, END_LOOP, NAMEONPCB_NAME, and NSTRCMP.

Referenced by ChangeElementName(), and CreateNewElement().

Here is the call graph for this function:

bool ViaIsOnAnyVisibleLayer ( PinType via)

Check if via penetrates any visible layer.

Definition at line 2483 of file src/misc.c.

References pin_st::BuriedFrom, PCBType::Data, DataType::Layer, layer, LayerType::On, PCB, and VIA_IS_BURIED.

Referenced by _draw_pv(), and hole_callback().

bool ViaIsOnLayerGroup ( PinType via,
int  group 
)

Variable Documentation

int cnt

Definition at line 102 of file src/misc.c.

Referenced by ActionRenumber(), process_skips(), and seg_in_seg().

bool ElementOn

Definition at line 99 of file src/misc.c.

Definition at line 99 of file src/misc.c.

bool LayerOn[MAX_ALL_LAYER]

Definition at line 101 of file src/misc.c.

int LayerStack[MAX_ALL_LAYER]

determines the layer draw order.

Definition at line 100 of file src/misc.c.

Initial value:
 {
  {"ListRotations", 0, ActionListRotations,
   0,0},
}

Definition at line 2865 of file src/misc.c.

bool PinOn

Definition at line 99 of file src/misc.c.

bool RatOn

Definition at line 99 of file src/misc.c.

struct { ... } SavedStack [static]
bool ViaOn

Definition at line 99 of file src/misc.c.