pcb 4.1.1
An interactive printed circuit board layout editor.
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "global.h"
#include "hid.h"
#include "hidnogui.h"
#include "../hidint.h"
#include "compat.h"
#include "error.h"
#include "misc.h"
#include "pcb-printf.h"
#include "hid/common/hidlist.h"
Go to the source code of this file.
Data Structures | |
struct | ecache |
struct | ccache |
Defines | |
#define | HID_DEF(x) extern void hid_ ## x ## _init(void); |
#define | HID_DEF(x) hid_ ## x ## _init(); |
#define | HASH_SIZE 31 |
Typedefs | |
typedef struct ecache | ecache |
typedef struct ccache | ccache |
Functions | |
static void | hid_load_dir (char *dirname) |
Search a directory for plugins and load them if found. | |
void | hid_init () |
Initialize the available hids and load plugins. | |
void | hid_uninit (void) |
Call this at exit. | |
void | hid_register_hid (HID *hid) |
Add an HID to the list of HIDs. | |
HID * | hid_find_gui () |
When PCB runs in interactive mode, this is called to instantiate one GUI HID which happens to be the GUI. | |
HID * | hid_find_printer () |
Finds the one printer HID and instantiates it. | |
HID * | hid_find_exporter (const char *which) |
Finds the indicated exporter HID and instantiates it. | |
HID ** | hid_enumerate () |
This returns a NULL-terminated array of available HIDs. | |
void | hid_register_attributes (HID_Attribute *a, int n) |
void | hid_parse_command_line (int *argc, char ***argv) |
A HID may use this if it does not need command line arguments in any special format. | |
static int | attr_hash (HID_Attribute *a) |
void | hid_save_settings (int locally) |
static void | hid_set_attribute (char *name, char *value) |
static void | hid_load_settings_1 (char *fname) |
void | hid_load_settings () |
static void | copy_color (int set, hidval *cval, hidval *aval) |
int | hid_cache_color (int set, const char *name, hidval *val, void **vcache) |
Used to cache color lookups. | |
void | derive_default_filename (const char *pcbfile, HID_Attribute *filename_attrib, const char *suffix, char **memory) |
Variables | |
HID ** | hid_list = 0 |
NULL terminated list of all static HID structures. | |
int | hid_num_hids = 0 |
Count of entries in the above. | |
HID * | gui = NULL |
HID * | exporter = NULL |
int | pixel_slop = 1 |
HID_AttrNode * | hid_attr_nodes = 0 |
#define HASH_SIZE 31 |
Definition at line 726 of file hidinit.c.
Referenced by hid_cache_color().
static int attr_hash | ( | HID_Attribute * | a | ) | [static] |
Definition at line 486 of file hidinit.c.
References HID_Attribute::hash.
Referenced by hid_load_settings(), and hid_save_settings().
Definition at line 742 of file hidinit.c.
Referenced by hid_cache_color().
void derive_default_filename | ( | const char * | pcbfile, |
HID_Attribute * | filename_attrib, | ||
const char * | suffix, | ||
char ** | memory | ||
) |
Definition at line 802 of file hidinit.c.
References HID_Attribute::default_val, malloc(), and HID_Attr_Val::str_value.
Referenced by bom_get_export_options(), gcode_get_export_options(), gerber_get_export_options(), gsvit_get_export_options(), IPCD356_get_export_options(), nelma_get_export_options(), png_get_export_options(), ps_get_export_options(), and REGISTER_ATTRIBUTES().
int hid_cache_color | ( | int | set, |
const char * | name, | ||
hidval * | val, | ||
void ** | cache | ||
) |
Used to cache color lookups.
If set is zero, it looks up the name and if found sets val and returns nonzero. If not found, it returns zero. If set is nonzero, name/val is added to the cache.
Definition at line 751 of file hidinit.c.
References ccache::colors, copy_color(), hash(), HASH_SIZE, ccache::lru, malloc(), ecache::name, ecache::next, and ecache::val.
Referenced by eps_set_color(), ghid_set_color(), lesstif_set_color(), png_set_color(), set_gl_color_for_gc(), and use_gc().
HID** hid_enumerate | ( | void | ) |
This returns a NULL-terminated array of available HIDs.
The only real reason to use this is to locate all the export-style HIDs.
Definition at line 287 of file hidinit.c.
References hid_list.
Referenced by Export(), GetInfoString(), ghid_dialog_export(), Print(), print_defaults(), and usage().
HID* hid_find_exporter | ( | const char * | which | ) |
Finds the indicated exporter HID and instantiates it.
Definition at line 269 of file hidinit.c.
References hid_num_hids.
Referenced by ActionPSCalib(), and main().
HID* hid_find_gui | ( | ) |
When PCB runs in interactive mode, this is called to instantiate one GUI HID which happens to be the GUI.
This HID is the one that interacts with the mouse and keyboard.
Definition at line 244 of file hidinit.c.
References hid_num_hids.
Referenced by main().
HID* hid_find_printer | ( | void | ) |
Finds the one printer HID and instantiates it.
Definition at line 257 of file hidinit.c.
References hid_num_hids.
Referenced by main(), Print(), and PrintCalibrate().
void hid_init | ( | void | ) |
Initialize the available hids and load plugins.
Call this as soon as possible from main().
The file hid/common/hidlist.h contains a list of HID_DEF statements, compiled by the build system. The HID_DEF macro is redefined here to call the init function for each of those hids.
Definition at line 173 of file hidinit.c.
References Concat(), exec_prefix, hid_load_dir(), hid_nogui_get_hid(), and homedir.
Referenced by main().
static void hid_load_dir | ( | char * | dirname | ) | [static] |
Search a directory for plugins and load them if found.
The specified path is searched for shared library objects and dynamic link libraries. If any are found, check their symbols for a "hid_x_init" (where x is the basename of the library file) or a pcb_plugin_init, and call it as a function if found.
Definition at line 98 of file hidinit.c.
References Concat().
Referenced by hid_init().
void hid_load_settings | ( | void | ) |
Definition at line 710 of file hidinit.c.
References attr_hash(), HID_AttrNode::attributes, Concat(), HID_Attribute::hash, hid_load_settings_1(), homedir, HID_AttrNode::n, HID_AttrNode::next, and pcblibdir.
Referenced by main().
static void hid_load_settings_1 | ( | char * | fname | ) | [static] |
Definition at line 672 of file hidinit.c.
References f, hid_set_attribute(), and line.
Referenced by hid_load_settings().
void hid_parse_command_line | ( | int * | argc, |
char *** | argv | ||
) |
A HID may use this if it does not need command line arguments in any special format.
For example, the Lesstif HID needs to use the Xt parser, but the Postscript HID can use this function.
Definition at line 308 of file hidinit.c.
References HID_AttrNode::attributes, HID_Attr_Val::coord_value, HID_Attribute::default_val, HID_Attribute::enumerations, get_unit_struct(), GetValue(), HID_Boolean, HID_Coord, HID_Enum, HID_Integer, HID_Label, HID_Mixed, HID_Path, HID_Real, HID_String, HID_Unit, unit::index, HID_Attr_Val::int_value, HID_AttrNode::n, HID_Attribute::name, HID_AttrNode::next, ok, HID_Attr_Val::real_value, HID_Attr_Val::str_value, unit::suffix, HID_Attribute::type, unit, and HID_Attribute::value.
Referenced by batch_parse_arguments(), bom_parse_arguments(), eps_parse_arguments(), gcode_parse_arguments(), gerber_parse_arguments(), gsvit_parse_arguments(), IPCD356_parse_arguments(), lpr_parse_arguments(), nelma_parse_arguments(), png_parse_arguments(), and ps_parse_arguments().
void hid_register_attributes | ( | HID_Attribute * | a, |
int | n | ||
) |
Definition at line 295 of file hidinit.c.
References HID_AttrNode::attributes, hid_attr_nodes, malloc(), n, HID_AttrNode::n, and HID_AttrNode::next.
Referenced by bom_parse_arguments(), eps_parse_arguments(), gcode_parse_arguments(), gerber_parse_arguments(), gsvit_parse_arguments(), IPCD356_parse_arguments(), lpr_parse_arguments(), nelma_parse_arguments(), png_parse_arguments(), and ps_parse_arguments().
void hid_register_hid | ( | HID * | hid | ) |
Add an HID to the list of HIDs.
Called by the init funcs, used to set up hid_list.
Definition at line 216 of file hidinit.c.
References hid_num_hids, malloc(), hid_st::name, realloc(), and hid_st::struct_size.
Referenced by hid_batch_init(), hid_bom_init(), hid_eps_init(), hid_gcode_init(), hid_gerber_init(), hid_gsvit_init(), hid_ipcd356_init(), hid_lesstif_init(), hid_lpr_init(), hid_nelma_init(), hid_png_init(), hid_ps_init(), and REGISTER_FLAGS().
void hid_save_settings | ( | int | locally | ) |
Definition at line 496 of file hidinit.c.
References attr_hash(), HID_AttrNode::attributes, Concat(), HID_Attr_Val::coord_value, HID_Attribute::default_val, HID_Attribute::enumerations, f, get_unit_list(), HID_Attribute::hash, HID_Boolean, HID_Coord, HID_Enum, HID_Integer, HID_Label, HID_Mixed, HID_Path, HID_Real, HID_String, HID_Unit, homedir, HID_Attr_Val::int_value, Message(), MKDIR, HID_AttrNode::n, HID_Attribute::name, HID_AttrNode::next, pcb_fprintf(), HID_Attr_Val::real_value, HID_Attr_Val::str_value, unit::suffix, HID_Attribute::type, and HID_Attribute::value.
Referenced by ActionSaveSettings().
static void hid_set_attribute | ( | char * | name, |
char * | value | ||
) | [static] |
Definition at line 601 of file hidinit.c.
References HID_AttrNode::attributes, HID_Attr_Val::coord_value, HID_Attribute::default_val, HID_Attribute::enumerations, get_unit_struct(), GetValue(), HID_Boolean, HID_Coord, HID_Enum, HID_Integer, HID_Label, HID_Mixed, HID_Path, HID_Real, HID_String, HID_Unit, unit::index, HID_Attr_Val::int_value, HID_AttrNode::n, HID_Attribute::name, HID_AttrNode::next, ok, HID_Attr_Val::real_value, HID_Attr_Val::str_value, unit::suffix, HID_Attribute::type, and unit.
Referenced by hid_load_settings_1().
void hid_uninit | ( | void | ) |
This is either NULL or points to the current HID that is being called to do the exporting.
The gui HIDs set and unset this var.
Definition at line 82 of file hidinit.c.
Referenced by Export(), GetInfoString(), ghid_dialog_export(), ghid_dialog_print(), main(), print_defaults(), usage(), and usage_hid().
This is initially set to a "no-gui" gui, and later reset by main.
hid_expose_callback also temporarily set it for drawing.
Definition at line 81 of file hidinit.c.
Referenced by _draw_pad(), _draw_pv(), _draw_pv_name(), ActionAttributes(), ActionAutoPlaceSelected(), ActionBell(), ActionChange2ndSize(), ActionChangeClearSize(), ActionChangeHole(), ActionChangeJoin(), ActionChangeName(), ActionChangeOctagon(), ActionChangePaste(), ActionChangePinName(), ActionChangeSquare(), ActionClearOctagon(), ActionClearSquare(), ActionConnection(), ActionDisplay(), ActionDRCheck(), ActionElementList(), ActionExecuteFile(), ActionFreeRotateBuffer(), ActionImport(), ActionLoadFrom(), ActionLoadVendorFrom(), ActionMorphPolygon(), ActionMoveToCurrentLayer(), ActionNew(), ActionPasteBuffer(), ActionQuit(), ActionRenumber(), ActionSaveTo(), ActionSelect(), ActionSetOctagon(), ActionSetSquare(), ActionToggleHideName(), ActionUnselect(), AdjustAttachedBox(), AdjustAttachedLine(), AdjustInsertPoint(), AdjustTwoLine(), append_drc_violation(), arc_callback(), AutoRoute(), backup_cb(), CenterDisplay(), ChangePolygonClearSize(), check_snap_object(), CheckAndOpenFile(), clearPin_callback(), ClearUndoList(), click_cb(), common_draw_pcb_arc(), common_draw_pcb_line(), common_draw_pcb_text(), common_fill_pcb_pad(), common_fill_pcb_pv(), common_gui_draw_pcb_polygon(), common_thindraw_pcb_pad(), common_thindraw_pcb_pv(), CursorAction(), Draw(), draw_dashed_line(), draw_element_name(), draw_element_package(), draw_octagon_poly(), draw_pad(), draw_pad_name(), draw_pin(), draw_via(), DrawAttached(), DrawEMark(), DrawEverything(), DrawLayer(), DrawLayerGroup(), DrawMark(), DrawMask(), DrawMaskBoardArea(), DrawPaste(), DrawPPV(), DrawRats(), DrawSilk(), DRCAll(), EnableAutosave(), EnforceLineDRC(), Export(), fab_circle(), fab_line(), fill_contour(), FinishStroke(), FitCrosshairIntoGrid(), gerber_set_layer(), GetInfoString(), GetXY(), ghid_dialog_export(), ghid_init_renderer(), ghid_listener_cb(), ghid_shutdown_renderer(), ghid_thindraw_pcb_polygon(), GlobalPuller(), hid_actionv(), hid_expose_callback(), hole_callback(), io_watch_handler_dbus_freed(), lgbutton_input(), line_callback(), LookupConnection(), LookupConnectionsToAllElements(), LookupElementConnections(), LookupUnusedPins(), main(), maybe_pull_1(), Message(), move_corner(), MoveLayer(), Netlist(), netnode_browse(), node_selection_changed_cb(), notify_crosshair_change(), notify_mark_change(), NotifyLine(), NotifyMode(), OpenConnectionDataFile(), pcb_dbus_connection_setup_with_mainloop(), pcb_main_uninit(), poly_callback(), Print(), PrintAssembly(), PrintBOM(), PrintCalibrate(), PrintFab(), ps_calibrate_1(), Puller(), QueryInputAndChangeObjectName(), QuitApplication(), rat_callback(), real_load_pcb(), Redraw(), ReleaseMode(), Report(), ReportAllNetLengths(), ReportDialog(), ReportDrills(), ReportFoundPins(), ReportNetLength(), ReportNetLengthByName(), reset_drc_dialog_message(), RouteAll(), SavePCB(), set_object_color(), teardrops(), text_at(), text_callback(), thindraw_contour(), thindraw_moved_pv(), throw_drc_dialog(), timeout_add(), timeout_handler_cb(), timeout_handler_dbus_freed(), TracePath(), usage(), watch_add(), XORDrawAttachedArc(), XORDrawAttachedLine(), XORDrawBuffer(), XORDrawElement(), XORDrawInsertPointObject(), XORDrawMoveOrCopyObject(), and XORPolygon().
Definition at line 292 of file hidinit.c.
Referenced by ghid_config_init(), hid_register_attributes(), lesstif_parse_arguments(), parse_optionv(), print_defaults(), and usage().
NULL terminated list of all static HID structures.
Built by hid_register_hid, used by hid_find_*() and hid_enumerate(). The order in this list is the same as the order of hid_register_hid calls.
Definition at line 78 of file hidinit.c.
Referenced by hid_enumerate().
int hid_num_hids = 0 |
Count of entries in the above.
Definition at line 79 of file hidinit.c.
Referenced by hid_find_exporter(), hid_find_gui(), hid_find_printer(), and hid_register_hid().
int pixel_slop = 1 |
The GUI may set this to be approximately the PCB size of a pixel, to allow for near-misses in selection and changes in drawing items smaller than a screen pixel.
Definition at line 84 of file hidinit.c.
Referenced by common_thindraw_pcb_pad(), DrawRat(), ghid_parse_arguments(), ghid_zoom_view_abs(), rat_callback(), SearchScreen(), XORDrawAttachedArc(), XORDrawAttachedLine(), zoom_max(), and zoom_to().