pcb 4.1.1
An interactive printed circuit board layout editor.
|
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"
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. | |
BoxType * | GetDataBoundingBox (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). | |
BoxType * | GetObjectBoundingBox (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. | |
BoxType * | GetArcEnds (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 [] |
Misc functions used by several modules.
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
Definition in file src/misc.c.
#define TAB " " |
Referenced by GetInfoString().
Definition at line 2854 of file src/misc.c.
References PCBType::Data, ELEMENT_LOOP, ElementOrientation(), END_LOOP, NAMEONPCB_NAME, and PCB.
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().
Definition at line 2015 of file src/misc.c.
References CrosshairType::AttachedObject, COPY_MODE, Crosshair, crosshair_update_range(), GetGridLockCoordinates(), PCBType::Grid, GridFit(), PCBType::GridOffsetX, PCBType::GridOffsetY, LookupRatLines(), LookupRubberbandLines(), Marked, SettingType::Mode, PCB, AttachedObjectType::Ptr1, AttachedObjectType::Ptr2, AttachedObjectType::Ptr3, AttachedObjectType::RubberbandN, SetLocalRef(), Settings, AttachedObjectType::State, STATE_SECOND, MarkType::status, TEST_FLAG, AttachedObjectType::Type, AttachedObjectType::X, and AttachedObjectType::Y.
Referenced by click_cb(), and NotifyMode().
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.
Definition at line 2564 of file src/misc.c.
References AttributeListType::List, AttributeListType::Max, AttributeType::name, AttributeListType::Number, realloc(), STRDUP, and AttributeType::value.
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] |
const char* c_dtostr | ( | double | d | ) |
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().
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().
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().
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().
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().
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().
int ChangeGroupVisibility | ( | int | Layer, |
bool | On, | ||
bool | ChangeStackOrder | ||
) |
Changes the visibility of all layers in a group.
Definition at line 1457 of file src/misc.c.
References PCBType::Data, LayerGroupType::Entries, GetLayerGroupNumberByNumber(), hid_action(), Layer, DataType::Layer, layer, PCBType::LayerGroups, max_copper_layer, LayerGroupType::Number, LayerType::On, PCB, PushOnTopOfLayerStack(), Settings, and SettingType::verbose.
Referenced by ActionSetSame(), GotoError(), layer_selector_select_callback(), layer_selector_toggle_callback(), layerpick_button_callback(), LayerStringToLayerStack(), MoveLayerAction(), ResetStackAndVisibility(), selection_changed_cb(), and SwapSides().
char* Concat | ( | const char * | first, |
... | |||
) |
Definition at line 2075 of file src/misc.c.
References len, malloc(), realloc(), and s.
Referenced by ActionImport(), get_menu_filename(), hid_init(), hid_load_dir(), hid_load_settings(), hid_save_settings(), lesstif_menu(), libnode_select(), LoadFootprintByName(), REGISTER_ATTRIBUTES(), and ReportNetLength().
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().
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().
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().
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.
Definition at line 110 of file src/misc.c.
Referenced by AdjustInsertPoint(), arc_endpoint_is(), ArcArcIntersect(), arcpoint_callback(), check_point_in_pad(), check_point_in_pin(), CreateNewVia(), dist2_to_box(), dist_lp(), dist_lsp(), form_slanted_rectangle(), gcode_do_export(), ghid_set_cursor_position_labels(), gp_point_force(), IsPointInBox(), IsPointInPad(), IsPointOnArc(), IsPointOnLine(), IsPointOnPin(), line_callback(), linepoint_callback(), mark_delta_to_widget(), maybe_pull_1(), NotifyLine(), png_draw_line(), Puller(), rat_callback(), ReportDialog(), SearchPointByLocation(), and within().
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.
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().
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().
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.
Definition at line 1876 of file src/misc.c.
References box, ArcType::Delta, ArcType::Height, M180, ArcType::StartAngle, ArcType::Width, ArcType::X, BoxType::X1, BoxType::X2, ArcType::Y, BoxType::Y1, and BoxType::Y2.
Referenced by ActionUndo(), ArcPolyNoIntersect(), GetGridLockCoordinates(), LineArcIntersect(), NotifyMode(), ReportDialog(), and XORDrawAttachedArc().
Gets minimum and maximum coordinates.
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().
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().
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().
int GetLayerGroupNumberByNumber | ( | Cardinal | Layer | ) |
Returns the layergroup number for the passed layer number.
Definition at line 1610 of file src/misc.c.
References LayerGroupType::Entries, PCBType::LayerGroups, max_group, LayerGroupType::Number, and PCB.
Referenced by AddPolygon(), assign_eagle_file_suffix(), assign_hackvana_file_suffix(), assign_oshpark_file_suffix(), ChangeGroupVisibility(), CreateRouteData(), DrawEverything(), drc_lines(), eps_hid_export_to_file(), gcode_choose_groups(), gcode_do_export(), gerber_do_export(), GetLayerGroupNumberByPointer(), GetLayerGroupNumberBySide(), gsvit_choose_groups(), gsvit_do_export(), hole_callback(), hole_counting_callback(), info(), LastNormalLayerInSideGroup(), layer_button_callback(), layer_stack_sort(), layer_type_to_file_name(), lesstif_set_layer(), LOCtoPVarc_callback(), LOCtoPVline_callback(), LOCtoPVpoly_callback(), MoveLayerToGroup(), nelma_choose_groups(), NotifyMode(), PlowsPolygon(), png_hid_export_to_file(), ps_hid_export_to_file(), pv_arc_callback(), pv_line_callback(), pv_poly_callback(), pv_pv_callback(), read_lines(), SwapSides(), and ViaIsOnLayerGroup().
int GetLayerGroupNumberByPointer | ( | LayerType * | Layer | ) |
Returns the layergroup number for the passed pointer.
Definition at line 1601 of file src/misc.c.
References PCBType::Data, GetLayerGroupNumberByNumber(), GetLayerNumber(), and PCB.
Referenced by CheckArcPointForRubberbandConnection(), CheckLinePointForRat(), CheckLinePointForRubberbandConnection(), CheckPolygonForRubberbandConnection(), GatherSubnets(), GlobalPuller(), MoveLineToLayer(), MoveTextToLayerLowLevel(), and NotifyMode().
int GetLayerGroupNumberBySide | ( | int | side | ) |
Returns the layergroup number for the passed side (TOP_SIDE or BOTTOM_SIDE).
Definition at line 1630 of file src/misc.c.
References bottom_silk_layer, GetLayerGroupNumberByNumber(), TOP_SIDE, and top_silk_layer.
Referenced by AddNet(), assign_eagle_file_suffix(), assign_hackvana_file_suffix(), assign_oshpark_file_suffix(), CheckPadForRat(), CheckPadForRubberbandConnection(), ConvertBufferToElement(), CreateRouteData(), DrawEverything(), DrawPPV(), drc_lines(), eps_hid_export_to_file(), FitCrosshairIntoGrid(), gcode_do_export(), gerber_do_export(), GetMaxBottomLayer(), GlobalPuller(), gsvit_do_export(), info(), LastNormalLayerInSideGroup(), layer_type_to_file_name(), LOCtoPVpad_callback(), MoveTextToLayerLowLevel(), NotifyMode(), png_hid_export_to_file(), PrintAssembly(), ProcNetlist(), ps_hid_export_to_file(), ps_set_layer(), pv_pad_callback(), read_pads(), ResetStackAndVisibility(), SmashBufferElement(), SwapBuffer(), SwapSides(), and UpdateXY().
Returns the layer number for the passed pointer.
Definition at line 1417 of file src/misc.c.
References DataType::Layer, and MAX_ALL_LAYER.
Referenced by ActionSetSame(), add_plow(), AddArcToBuffer(), AddLineToBuffer(), AddObjectToMoveToLayerUndoList(), AddPolygonToBuffer(), AddTextToBuffer(), clearPoly(), CreateRouteData(), describe_location(), DrawRecoveredObject(), GetLayerGroupNumberByPointer(), GotoError(), ListStart(), LookupConnection(), LookupRubberbandLines(), MoveArcToBuffer(), MoveLineToBuffer(), MoveLineToLayer(), MovePolygonToBuffer(), MovePolygonToLayer(), MoveTextToBuffer(), NotifyMode(), pin_sub_callback(), PlowsPolygon(), ReportDialog(), selection_changed_cb(), subtract_plow(), SubtractPin(), and UndoMoveToLayer().
int GetMaxBottomLayer | ( | ) |
Definition at line 2236 of file src/misc.c.
References BOTTOM_SIDE, LayerGroupType::Entries, GetLayerGroupNumberBySide(), PCBType::LayerGroups, max, max_copper_layer, LayerGroupType::Number, and PCB.
Referenced by ChangeObjectViaLayers(), ChangeSelectedViaLayers(), and SanitizeBuriedVia().
static Coord GetNum | ( | char ** | s, |
const char * | default_unit | ||
) | [static] |
Definition at line 969 of file src/misc.c.
References GetValueEx().
Referenced by ParseRouteString().
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.
Referenced by crosshair_update_range().
double GetUnitlessValue | ( | const char * | val, |
bool * | absolute | ||
) |
Extract a unit-less value from a string.
val | String containing the value to be read. |
absolute | Returns whether the returned value is an absolute one. |
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 | ||
) |
GetValue() returns a numeric value passed from the string and sets the bool variable absolute to false if it leads with a +/- character.
Definition at line 134 of file src/misc.c.
References GetValueEx().
Referenced by ActionChange2ndSize(), ActionChangeClearSize(), ActionChangeSize(), ActionDisplay(), ActionImport(), ActionMinClearGap(), ActionMinMaskGap(), ActionMoveObject(), ActionPasteBuffer(), ActionSetValue(), coordentry_changed_cb(), hid_parse_command_line(), hid_set_attribute(), lesstif_attribute_dialog(), parse_layout_attribute_units(), parse_optionv(), pcb_cvt_string_to_coord(), real_load_pcb(), and set_config_attribute().
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().
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] |
Definition at line 732 of file src/misc.c.
References pin_st::BuriedFrom, pin_st::BuriedTo, GetLayerGroupNumberByNumber(), HoleCountStruct::group_from, HoleCountStruct::group_to, HoleCountStruct::nplated, HoleCountStruct::nunplated, pin, TEST_FLAG, and VIA_IS_BURIED.
Referenced by CountHoles(), and CountHolesEx().
bool IsDataEmpty | ( | DataType * | Data | ) |
Returns true if data area is empty.
Definition at line 656 of file src/misc.c.
References LayerType::ArcN, DataType::ElementN, DataType::Layer, LayerType::LineN, max_copper_layer, LayerType::PolygonN, SILK_LAYER, LayerType::TextN, and DataType::ViaN.
Referenced by Export(), FlagIsDataEmpty(), GetDataBoundingBox(), and Print().
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().
bool IsLayerNumEmpty | ( | int | num | ) |
Definition at line 691 of file src/misc.c.
References PCBType::Data, IsLayerEmpty(), DataType::Layer, and PCB.
Referenced by IsLayerGroupEmpty().
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().
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().
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().
Definition at line 2151 of file src/misc.c.
References FlagType::f.
Referenced by AddArcToBuffer(), AddLineToBuffer(), AddRatToBuffer(), AddTextToBuffer(), AddViaToBuffer(), ConvertBufferToElement(), CopyArc(), CopyElementLowLevel(), CopyLine(), CopyText(), CopyVia(), and UndoFlag().
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().
Bring an angle into [0, 360] range.
Definition at line 119 of file src/misc.c.
Referenced by CreateNewArcInElement(), CreateNewArcOnLayer(), FreeRotateBuffer(), FreeRotateElementLowLevel(), gcode_draw_arc(), ghid_draw_arc(), gsvit_draw_arc(), IsPointOnArc(), lesstif_draw_arc(), nelma_draw_arc(), normalize_angles(), png_draw_arc(), RotateArcLowLevel(), and SetArcBoundingBox().
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 | ||
) |
Definition at line 1087 of file src/misc.c.
References BOTTOM_SILK_LAYER, LayerGroupType::Entries, error, layer, MAX, MAX_ALL_LAYER, LayerGroupType::Number, s, and TOP_SILK_LAYER.
Referenced by config_layers_apply(), CreateNewPCBPost(), and main().
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().
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().
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.
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().
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().
void r_delete_element | ( | DataType * | data, |
ElementType * | element | ||
) |
Definition at line 2647 of file src/misc.c.
References DataType::element_tree, ELEMENTTEXT_LOOP, END_LOOP, n, DataType::name_tree, PAD_LOOP, DataType::pad_tree, pin, PIN_LOOP, DataType::pin_tree, and r_delete_entry().
Referenced by MirrorElementCoordinates(), MoveElementToBuffer(), and SwapBuffer().
void ResetStackAndVisibility | ( | void | ) |
Resets the layerstack setting.
Definition at line 1745 of file src/misc.c.
References ChangeGroupVisibility(), PCBType::Data, PCBType::ElementOn, LayerGroupType::Entries, GetLayerGroupNumberBySide(), PCBType::InvisibleObjectsOn, DataType::Layer, PCBType::LayerGroups, LayerStack, max_copper_layer, LayerType::On, PCB, PCBType::PinOn, PCBType::RatOn, SILK_LAYER, top_group, TOP_SIDE, and PCBType::ViaOn.
Referenced by ActionNew(), DRCAll(), main(), and real_load_pcb().
void RestoreStackAndVisibility | ( | void | ) |
Restores the layerstack setting.
Definition at line 1807 of file src/misc.c.
References PCBType::Data, PCBType::ElementOn, PCBType::InvisibleObjectsOn, DataType::Layer, LayerStack, max_copper_layer, LayerType::On, PCB, PCBType::PinOn, PCBType::RatOn, SavedStack, SILK_LAYER, and PCBType::ViaOn.
Referenced by DRCAll().
void SanitizeBuriedVia | ( | PinType * | via | ) |
Sanitize buried via.
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().
void SaveStackAndVisibility | ( | void | ) |
Saves the layerstack setting.
Definition at line 1771 of file src/misc.c.
References PCBType::Data, PCBType::ElementOn, PCBType::InvisibleObjectsOn, DataType::Layer, LayerStack, max_copper_layer, LayerType::On, PCB, PCBType::PinOn, PCBType::RatOn, SavedStack, SILK_LAYER, and PCBType::ViaOn.
Referenced by DRCAll().
void SetArcBoundingBox | ( | ArcType * | Arc | ) |
Computes the bounding box of an arc.
Definition at line 1673 of file src/misc.c.
References ArcType::Clearance, close_box(), ArcType::Delta, ArcType::Height, M180, MAX, maxx, maxy, MIN, minx, miny, NormalizeAngle(), ArcType::Point1, ArcType::Point2, POLY_ARC_MAX_DEVIATION, POLY_CIRC_RADIUS_ADJ, ArcType::StartAngle, ArcType::Thickness, ArcType::Width, PointType::X, ArcType::X, PointType::Y, and ArcType::Y.
Referenced by ChangeArcAngles(), ChangeArcClearSize(), ChangeArcSize(), CreateNewArcOnLayer(), MirrorBuffer(), SetElementBoundingBox(), SwapBuffer(), and UndoChangeAngles().
void SetElementBoundingBox | ( | DataType * | Data, |
ElementType * | Element, | ||
FontType * | Font | ||
) |
Sets the bounding box of an element.
Definition at line 385 of file src/misc.c.
References ARC_LOOP, box, CLEAR_FLAG, close_box(), DataType::element_tree, ELEMENTLINE_LOOP, ELEMENTTEXT_LOOP, END_LOOP, line, MAKEMAX, MAKEMIN, MAX, MIN, n, DataType::name_tree, PAD_LOOP, DataType::pad_tree, pin, PIN_LOOP, DataType::pin_tree, r_create_tree(), r_delete_entry(), r_insert_entry(), SET_FLAG, SetArcBoundingBox(), SetLineBoundingBox(), SetPadBoundingBox(), SetPinBoundingBox(), SetTextBoundingBox(), BoxType::X1, BoxType::X2, BoxType::Y1, and BoxType::Y2.
Referenced by ChangePadClearSize(), ChangePadMaskSize(), ChangePadSize(), ChangePinClearSize(), ChangePinMaskSize(), ChangePinSize(), ConvertBufferToElement(), CopyElementLowLevel(), FreeRotateElementLowLevel(), LoadElementToBuffer(), MirrorElementCoordinates(), MoveElementToBuffer(), and RotateElementLowLevel().
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 SetLineBoundingBox | ( | LineType * | Line | ) |
Sets the bounding box of a line.
Definition at line 345 of file src/misc.c.
References close_box(), MAX, MIN, POLY_CIRC_RADIUS_ADJ, and SetPointBoundingBox().
Referenced by ChangeLineClearSize(), ChangeLineSize(), CreateNewLineOnLayer(), CreateNewRat(), drc_lines(), FreeRotateBuffer(), FreeRotateElementLowLevel(), InsertPointIntoLine(), IsPolygonInPolygon(), MoveLinePoint(), RotateLineLowLevel(), RotateLinePoint(), RotateObject(), SetElementBoundingBox(), and SwapBuffer().
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().
void SetPinBoundingBox | ( | PinType * | Pin | ) |
Sets the bounding box of a pin or via.
Definition at line 269 of file src/misc.c.
References pin_st::Clearance, close_box(), pin_st::Mask, MAX, PIN_SIZE, POLY_CIRC_RADIUS_ADJ, pin_st::X, and pin_st::Y.
Referenced by ChangeHole(), ChangeViaClearSize(), ChangeViaMaskSize(), ChangeViaSize(), CreateNewVia(), FreeRotateBuffer(), FreeRotateElementLowLevel(), RotateBuffer(), SetElementBoundingBox(), and SwapBuffer().
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 | ) |
Sets the bounding box of a polygons.
Definition at line 365 of file src/misc.c.
References close_box(), END_LOOP, MAKEMAX, MAKEMIN, and POLYGONPOINT_LOOP.
Referenced by CopyAttachedPolygonToLayer(), CopyPolygonLowLevel(), CreateNewPolygonFromRectangle(), DestroyPolygonPoint(), FreeRotateBuffer(), InsertPointIntoPolygon(), MirrorBuffer(), MovePolygonPoint(), PolyToPolygonsOnLayer(), RemovePolygonPoint(), and SwapBuffer().
Creates the bounding box of a text object.
Definition at line 534 of file src/misc.c.
References PCBType::Bloat, close_box(), FontType::DefaultSymbol, SymbolType::Delta, TextType::Direction, SymbolType::Line, line, SymbolType::LineN, MAX, maxx, maxy, MIN, PCBType::minSlk, PCBType::minWid, minx, miny, PCB, RotateBoxLowLevel(), s, TextType::Scale, SCALE_TEXT, FontType::Symbol, TEST_FLAG, TextType::TextString, UNSCALE_TEXT, SymbolType::Width, TextType::X, BoxType::X1, BoxType::X2, TextType::Y, BoxType::Y1, and BoxType::Y2.
Referenced by AddTextToElement(), ChangeElementNameSize(), ChangeElementText(), ChangeTextName(), ChangeTextSize(), CreateNewText(), MoveTextToLayerLowLevel(), NotifyMode(), SetElementBoundingBox(), and SwapBuffer().
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().
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 | ||
) |
Check if via penetrates layer group.
Definition at line 2462 of file src/misc.c.
References pin_st::BuriedFrom, GetLayerGroupNumberByNumber(), layer, and VIA_IS_BURIED.
Referenced by LOCtoPVarc_callback(), LOCtoPVline_callback(), LOCtoPVpad_callback(), LOCtoPVpoly_callback(), pv_arc_callback(), pv_line_callback(), pv_pad_callback(), pv_poly_callback(), pv_pv_callback(), and via_visible_on_layer_group().
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.
bool InvisibleObjectsOn |
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.
{ {"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] |
Referenced by RestoreStackAndVisibility(), and SaveStackAndVisibility().
bool ViaOn |
Definition at line 99 of file src/misc.c.