pcb 4.1.1
An interactive printed circuit board layout editor.
|
Prototypes for misc routines. More...
Go to the source code of this file.
Data Structures | |
struct | UnitList |
Defines | |
#define | AttributeGet(OBJ, name) AttributeGetFromList (&(OBJ->Attributes), name) |
#define | AttributePut(OBJ, name, value) AttributePutToList (&(OBJ->Attributes), name, value, 1) |
#define | AttributeRemove(OBJ, name) AttributeRemoveFromList (&(OBJ->Attributes), name) |
#define | NoFlags() MakeFlags(0) |
#define | MKDIR(a, b) pcb_mkdir(a, b) |
#define | MKDIR_IS_PCBMKDIR 1 |
Enumerations | |
enum | unitflags { UNIT_PERCENT = 1 } |
Functions | |
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. | |
void | r_delete_element (DataType *, ElementType *) |
void | SetLineBoundingBox (LineType *) |
Sets the bounding box of a line. | |
void | SetArcBoundingBox (ArcType *) |
Computes the bounding box of an arc. | |
void | SetPointBoundingBox (PointType *) |
Sets the bounding box of a point (which is silly). | |
void | SetPinBoundingBox (PinType *) |
Sets the bounding box of a pin or via. | |
void | SetPadBoundingBox (PadType *) |
Sets the bounding box of a pad. | |
void | SetPolygonBoundingBox (PolygonType *) |
Sets the bounding box of a polygons. | |
void | SetElementBoundingBox (DataType *, ElementType *, FontType *) |
Sets the bounding box of an element. | |
bool | IsDataEmpty (DataType *) |
Returns true if data area is empty. | |
bool | IsLayerEmpty (LayerType *) |
bool | IsLayerNumEmpty (int) |
bool | IsLayerGroupEmpty (int) |
bool | IsPasteEmpty (int) |
void | CountHoles (int *, int *, const BoxType *) |
Counts the number of plated and unplated holes in the design within a given area of the board. | |
void | CountHolesEx (int *, int *, const BoxType *, Cardinal, Cardinal) |
Counts the number of plated and unplated holes in the design within a given area of the board. | |
BoxType * | GetDataBoundingBox (DataType *) |
Gets minimum and maximum coordinates. | |
void | CenterDisplay (Coord, Coord, bool warp_pointer) |
Centers the displayed PCB around the specified point (X,Y), and move the crosshair there. | |
void | SetFontInfo (FontType *) |
Transforms symbol coordinates so that the left edge of each symbol is at the zero position. | |
char * | make_route_string (RouteStyleType rs[], int n_styles) |
Serializes the route style list . | |
int | ParseGroupString (char *, LayerGroupType *, int *) |
int | ParseRouteString (char *, RouteStyleType *, const char *) |
void | QuitApplication (void) |
Quits application. | |
char * | EvaluateFilename (char *, char *, char *, char *) |
Creates a filename from a template. | |
char * | ExpandFilename (char *, char *) |
Concatenates directory and filename. | |
void | SetTextBoundingBox (FontType *, TextType *) |
Creates the bounding box of a text object. | |
void | SaveOutputWindow (void) |
int | GetLayerNumber (DataType *, LayerType *) |
Returns the layer number for the passed pointer. | |
int | GetLayerGroupNumberByPointer (LayerType *) |
Returns the layergroup number for the passed pointer. | |
int | GetLayerGroupNumberByNumber (Cardinal) |
Returns the layergroup number for the passed layer number. | |
int | GetLayerGroupNumberBySide (int) |
Returns the layergroup number for the passed side (TOP_SIDE or BOTTOM_SIDE). | |
int | ChangeGroupVisibility (int, bool, bool) |
Changes the visibility of all layers in a group. | |
void | LayerStringToLayerStack (char *) |
Given a string description of a layer stack, adjust the layer stack to correspond. | |
BoxType * | GetObjectBoundingBox (int, void *, void *, void *) |
Returns a pointer to an objects bounding box. | |
void | ResetStackAndVisibility (void) |
Resets the layerstack setting. | |
void | SaveStackAndVisibility (void) |
Saves the layerstack setting. | |
void | RestoreStackAndVisibility (void) |
Restores the layerstack setting. | |
char * | GetWorkingDirectory (char *) |
Returns pointer to current working directory. | |
void | CreateQuotedString (DynamicStringType *, char *) |
Write a string to the passed file pointer. | |
BoxType * | GetArcEnds (ArcType *) |
void | ChangeArcAngles (LayerType *, ArcType *, Angle, Angle) |
char * | UniqueElementName (DataType *, char *) |
Make a unique name for the name on board. | |
void | AttachForCopy (Coord, Coord) |
double | GetValue (const char *, const char *, bool *) |
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 *, const char *, bool *, UnitList, const char *) |
double | GetUnitlessValue (const char *, bool *) |
Extract a unit-less value from a string. | |
int | FileExists (const char *) |
Return nonzero if the given file exists and is readable. | |
char * | Concat (const char *,...) |
char * | pcb_author () |
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. | |
FlagType | MakeFlags (unsigned int) |
This just fills in a FlagType with current flags. | |
FlagType | OldFlags (unsigned int) |
This converts old flag bits (from saved PCB files) to new format. | |
FlagType | AddFlags (FlagType, unsigned int) |
FlagType | MaskFlags (FlagType, unsigned int) |
int | MoveLayerToGroup (int layer, int group) |
Returns group actually moved to (i.e. either group or previous). | |
char * | LayerGroupsToString (LayerGroupType *) |
Returns pointer to private buffer. | |
void | MakeLayerGroupsDefault () |
const char * | c_dtostr (double d) |
char * | GetInfoString (void) |
Returns a string that has a bunch of information about the program. | |
void | AssignDefaultLayerTypes () |
Sets up any remaining layer type guesses. | |
int | ElementOrientation (ElementType *e) |
Returns a best guess about the orientation of an element. | |
bool | IsLayerMoveSafe (int, int) |
void | ChangeBuriedViasAfterLayerMove (int, int) |
Update buried vias after layer move. | |
void | ChangeBuriedViasAfterLayerCreate (int) |
Update buried vias after new layer create. | |
void | ChangeBuriedViasAfterLayerDelete (int) |
Update buried vias after layer delete. | |
bool | ViaIsOnLayerGroup (PinType *, int) |
Check if via penetrates layer group. | |
bool | ViaIsOnAnyVisibleLayer (PinType *) |
Check if via penetrates any visible layer. | |
void | SanitizeBuriedVia (PinType *) |
Sanitize buried via. | |
int | GetMaxBottomLayer () |
void | NetlistChanged (int force_unfreeze) |
int | pcb_mkdir (const char *path, int mode) |
mkdir() implentation, mostly for plugins, which don't have our config.h. |
Prototypes for misc routines.
PCB, interactive printed circuit board design
Copyright (C) 1994,1995,1996,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 misc.h.
#define AttributeGet | ( | OBJ, | |
name | |||
) | AttributeGetFromList (&(OBJ->Attributes), name) |
Definition at line 108 of file misc.h.
Referenced by ActionImport(), parse_layout_attribute_units(), real_load_pcb(), and reassign_no_drc_flags().
#define AttributePut | ( | OBJ, | |
name, | |||
value | |||
) | AttributePutToList (&(OBJ->Attributes), name, value, 1) |
Definition at line 110 of file misc.h.
Referenced by ActionImport(), ImportGUI(), real_load_pcb(), SetGrid(), and SetUnits().
#define AttributeRemove | ( | OBJ, | |
name | |||
) | AttributeRemoveFromList (&(OBJ->Attributes), name) |
Definition at line 113 of file misc.h.
Referenced by ActionImport().
#define MKDIR | ( | a, | |
b | |||
) | pcb_mkdir(a, b) |
Definition at line 173 of file misc.h.
Referenced by config_file_open(), hid_save_settings(), and pcb_mkdir().
#define NoFlags | ( | ) | MakeFlags(0) |
Definition at line 120 of file misc.h.
Referenced by _draw_pv_name(), AddNet(), ConvertBufferToElement(), CopyAttachedPolygonToLayer(), CopyPolygon(), CreateDrawnLineOnLayer(), CreateNewLineInElement(), draw_pad_name(), DrawAttached(), DrawShortestRats(), drc_lines(), escape(), FontEdit(), IsArcInRectangle(), IsLineInQuadrangle(), IsLineInRectangle(), IsPolygonInPolygon(), moveline_callback(), NotifyMode(), SmashBufferElement(), square_therm(), text_at(), and ThermPoly().
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.
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 | ) |
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 | ) |
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 | , |
int | |||
) |
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 * | , |
... | |||
) |
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 * | ) |
Return nonzero if the given file exists and is readable.
Definition at line 2062 of file src/misc.c.
References f.
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().
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 | ) |
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 * | ) |
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 | ) |
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().
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 * | , |
const char * | , | ||
bool * | |||
) |
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 * | , |
const char * | , | ||
bool * | , | ||
UnitList | , | ||
const char * | |||
) |
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().
bool IsDataEmpty | ( | DataType * | ) |
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 * | ) |
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 | ) |
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 IsLayerMoveSafe | ( | int | , |
int | |||
) |
bool IsLayerNumEmpty | ( | int | ) |
Definition at line 691 of file src/misc.c.
References PCBType::Data, IsLayerEmpty(), DataType::Layer, and PCB.
Referenced by IsLayerGroupEmpty().
bool IsPasteEmpty | ( | int | ) |
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 * | ) |
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 * | ) |
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 | ) |
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().
void MakeLayerGroupsDefault | ( | ) |
Make the current layer groups the default.
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 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().
void NetlistChanged | ( | int | force_unfreeze | ) |
Definition at line 93 of file netlist.c.
References hid_action(), netlist_frozen, and netlist_needs_update.
Referenced by ActionLoadFrom(), ActionRenumber(), AddNet(), FreePCBMemory(), Netlist(), netlist_add(), netlist_clear(), netlist_norats(), netlist_rats(), and UndoNetlistChange().
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 | ) |
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 * | , |
LayerGroupType * | , | ||
int * | |||
) |
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 * | , |
RouteStyleType * | , | ||
const char * | |||
) |
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 | ( | ) |
Definition at line 2501 of file src/misc.c.
References SettingType::FabAuthor, len, malloc(), and Settings.
Referenced by PrintBOM(), and PrintFab().
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.
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 * | , |
ElementType * | |||
) |
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 SaveOutputWindow | ( | void | ) |
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 * | ) |
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 * | , |
ElementType * | , | ||
FontType * | |||
) |
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 * | ) |
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 * | ) |
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 * | ) |
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 * | ) |
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 * | ) |
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 * | ) |
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 * | , |
int | |||
) |
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().