pcb 4.1.1
An interactive printed circuit board layout editor.

hid.h File Reference

Human Interface Device. More...

#include <stdarg.h>
Include dependency graph for hid.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

union  hidval
 The HID may need something more than an "int" for colors, timers, etc. More...
struct  HID_Action
 This is used to register the action callbacks (for menus and whatnot). More...
struct  HID_Flag
struct  HID_Attr_Val
 Used for HID attributes (exporting and printing, mostly). More...
struct  HID_Attribute
struct  HID_DRC_GUI
 DRC GUI Hooks. More...
struct  hid_st
 This is the main HID structure. More...

Defines

#define HIDCONCAT(a, b)   a##b
#define REGISTER_ACTIONS(a)
#define REGISTER_FLAGS(a)
#define ATTR_UNDOCUMENTED   ((char *)(1))
#define REGISTER_ATTRIBUTES(a)
#define SL_0_SIDE   0x0000
#define SL_TOP_SIDE   0x0001
#define SL_BOTTOM_SIDE   0x0002
#define SL_INNER_SIDE   0x0004
#define SL_SILK   0x0010
#define SL_MASK   0x0020
#define SL_PDRILL   0x0030
#define SL_UDRILL   0x0040
#define SL_PASTE   0x0050
#define SL_INVISIBLE   0x0060
#define SL_FAB   0x0070
#define SL_ASSY   0x0080
#define SL_RATS   0x0090
#define SL(type, side)   (~0xfff | SL_##type | SL_##side##_SIDE)
#define HID_SC_DO_NOTHING   0
#define HID_SC_WARP_POINTER   1
#define HID_SC_PAN_VIEWPORT   2
#define HID_SC_CENTER_IN_VIEWPORT   3
#define HID_SC_CENTER_IN_VIEWPORT_AND_WARP_POINTER   4
#define HID_CLOSE_CONFIRM_CANCEL   0
#define HID_CLOSE_CONFIRM_OK   1
#define HID_FILESELECT_READ   0x01
#define HID_FILESELECT_MAY_NOT_EXIST   0x02
#define HID_FILESELECT_IS_TEMPLATE   0x04

Typedefs

typedef struct hid_gc_structhidGC
typedef struct hid_st HID
typedef struct hid_draw_st HID_DRAW

Enumerations

enum  EndCapStyle { Trace_Cap, Square_Cap, Round_Cap, Beveled_Cap }
 

Like end cap styles.

More...
enum  hids {
  HID_Label, HID_Integer, HID_Real, HID_String,
  HID_Boolean, HID_Enum, HID_Mixed, HID_Path,
  HID_Unit, HID_Coord
}
enum  LayertypeType {
  LT_COPPER = 0, LT_SILK, LT_MASK, LT_PASTE,
  LT_OUTLINE, LT_ROUTE, LT_KEEPOUT, LT_FAB,
  LT_ASSY, LT_NOTES, LT_NUM_LAYERTYPES
}
enum  PCBWatchFlags { PCB_WATCH_READABLE = 1 << 0, PCB_WATCH_WRITABLE = 1 << 1, PCB_WATCH_ERROR = 1 << 2, PCB_WATCH_HANGUP = 1 << 3 }
 

File Watch flags.

More...

Functions

void hid_register_action (HID_Action *)
void hid_register_actions (HID_Action *, int)
int hid_action (const char *action_)
int hid_actionl (const char *action_,...)
int hid_actionv (const char *action_, int argc_, char **argv_)
void hid_save_settings (int)
void hid_load_settings (void)
int hid_parse_command (const char *str_)
 Parse the given command string into action calls, and call hid_actionv for each action found.
int hid_parse_actions (const char *str_)
 Parse the given string into action calls, and call hid_actionv for each action found.
void hid_register_flags (HID_Flag *, int)
int hid_get_flag (const char *name_)
 Looks up one of the flags registered above.
void hid_register_attributes (HID_Attribute *, int)
void hid_init (void)
 Call this as soon as possible from main().
void hid_uninit (void)
 Call this at exit.
HIDhid_find_gui ()
 When PCB runs in interactive mode, this is called to instantiate one GUI HID which happens to be the GUI.
HIDhid_find_printer (void)
 Finds the one printer HID and instantiates it.
HIDhid_find_exporter (const char *)
 Finds the indicated exporter HID and instantiates it.
HID ** hid_enumerate (void)
 This returns a NULL-terminated array of available HIDs.
void hid_expose_callback (HID *hid_, struct BoxType *region_, void *item_)
 This function (in the common code) will be called whenever the GUI needs to redraw the screen, print the board, or export a layer.

Variables

const char pcbchanged_help []
const char pcbchanged_syntax []
const char routestyleschanged_help []
const char routestyleschanged_syntax []
const char netlistchanged_help []
const char netlistchanged_syntax []
const char layerschanged_help []
const char layerschanged_syntax []
const char librarychanged_help []
const char librarychanged_syntax []
char * program_name
char * program_directory
char * program_basename
HIDgui
HIDexporter
HID_Actioncurrent_action
int pixel_slop

Detailed Description

Human Interface Device.

Author:
This file, hid.h, was written and is Copyright (c) 2006 DJ Delorie <dj@delorie.com>

The way the HID layer works is that you instantiate a HID device structure, and invoke functions through its members.

Code in the common part of PCB may *not* rely on *anything* other than what's defined in this file.

Code in the HID layers *may* rely on data and functions in the common code (like, board size and such) but it's considered bad form to do so when not needed.

Coordinates are ALWAYS in pcb's default resolution.

Positive X is right, positive Y is down.

Angles are degrees, with 0 being right (positive X) and 90 being up (negative Y).

All zoom, scaling, panning, and conversions are hidden inside the HID layers.

The main structure is at the end of this file.

Data structures passed to the HIDs will be copied if the HID needs to save them.

Data structures retured from the HIDs must not be freed, and may be changed by the HID in response to new information.


Copyright.


PCB, interactive printed circuit board design

Copyright (C) 1994,1995,1996 Thomas Nau

Copyright (C) 1998,1999,2000,2001 harry eaton

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: harry eaton, 6697 Buttonhole Ct, Columbia, MD 21044 USA haceaton@aplcomm.jhuapl.edu

Definition in file hid.h.


Define Documentation

#define ATTR_UNDOCUMENTED   ((char *)(1))

Definition at line 242 of file hid.h.

Referenced by ghid_attribute_dialog(), lesstif_attribute_dialog(), and usage_attr().

#define HID_CLOSE_CONFIRM_CANCEL   0

Definition at line 609 of file hid.h.

#define HID_CLOSE_CONFIRM_OK   1

Definition at line 611 of file hid.h.

Referenced by ActionQuit().

#define HID_FILESELECT_IS_TEMPLATE   0x04

The call is supposed to return a file template (for gerber output for example) instead of an actual file.

Only used when writing.

Definition at line 643 of file hid.h.

#define HID_FILESELECT_MAY_NOT_EXIST   0x02

The function calling hid->fileselect will deal with the case where the selected file already exists.

If not given, then the gui will prompt with an "overwrite?" prompt.

Only used when writing.

Definition at line 633 of file hid.h.

#define HID_FILESELECT_READ   0x01

Prompts the user for a filename or directory name.

For GUI HID's this would mean a file select dialog box.

The 'flags' argument is the bitwise OR of the following values.

Definition at line 625 of file hid.h.

Referenced by ActionLoadVendorFrom(), and ghid_fileselect().

#define HID_SC_CENTER_IN_VIEWPORT   3

Definition at line 537 of file hid.h.

Referenced by CenterDisplay(), and ghid_set_crosshair().

#define HID_SC_CENTER_IN_VIEWPORT_AND_WARP_POINTER   4

Definition at line 539 of file hid.h.

Referenced by CenterDisplay(), ghid_set_crosshair(), and lesstif_set_crosshair().

#define HID_SC_DO_NOTHING   0

Definition at line 531 of file hid.h.

Referenced by CursorAction(), and FitCrosshairIntoGrid().

#define HID_SC_PAN_VIEWPORT   2

Definition at line 535 of file hid.h.

Referenced by CursorAction(), ghid_set_crosshair(), lesstif_set_crosshair(), and netnode_browse().

#define HID_SC_WARP_POINTER   1

Definition at line 533 of file hid.h.

Referenced by CursorAction(), ghid_set_crosshair(), and lesstif_set_crosshair().

#define HIDCONCAT (   a,
 
)    a##b

Definition at line 114 of file hid.h.

#define REGISTER_ACTIONS (   a)
Value:
HIDCONCAT(void register_,a) ()\
{ hid_register_actions(a, sizeof(a)/sizeof(a[0])); }

Definition at line 146 of file hid.h.

#define REGISTER_ATTRIBUTES (   a)
Value:
HIDCONCAT(void register_,a) ()\
{ hid_register_attributes(a, sizeof(a)/sizeof(a[0])); }

Definition at line 264 of file hid.h.

#define REGISTER_FLAGS (   a)
Value:
HIDCONCAT(void register_,a) ()\
{ hid_register_flags(a, sizeof(a)/sizeof(a[0])); }

Definition at line 205 of file hid.h.

#define SL (   type,
  side 
)    (~0xfff | SL_##type | SL_##side##_SIDE)
#define SL_0_SIDE   0x0000

Definition at line 273 of file hid.h.

#define SL_ASSY   0x0080
#define SL_BOTTOM_SIDE   0x0002

Definition at line 275 of file hid.h.

Referenced by ps_set_layer().

#define SL_FAB   0x0070

Definition at line 293 of file hid.h.

Referenced by eps_set_layer(), gerber_set_layer(), png_set_layer(), and ps_set_layer().

#define SL_INNER_SIDE   0x0004

Definition at line 276 of file hid.h.

#define SL_INVISIBLE   0x0060

Definition at line 292 of file hid.h.

Referenced by extents_set_layer(), ghid_set_layer(), and lesstif_set_layer().

#define SL_PASTE   0x0050

Definition at line 291 of file hid.h.

Referenced by eps_set_layer(), png_set_layer(), and ps_set_layer().

#define SL_RATS   0x0090

Definition at line 295 of file hid.h.

Referenced by ghid_set_layer(), and lesstif_set_layer().

#define SL_SILK   0x0010

Physical layer, deprecated, use LT_SILK.

Definition at line 287 of file hid.h.

Referenced by extents_set_layer(), gerber_set_layer(), ghid_set_layer(), and lesstif_set_layer().

#define SL_TOP_SIDE   0x0001

Definition at line 274 of file hid.h.


Typedef Documentation

typedef struct hid_st HID

Definition at line 348 of file hid.h.

typedef struct hid_draw_st HID_DRAW

Definition at line 349 of file hid.h.

typedef struct hid_gc_struct* hidGC

This graphics context is an opaque pointer defined by the HID.

GCs are HID-specific; attempts to use one HID's GC for a different HID will result in a fatal error.

Definition at line 112 of file hid.h.


Enumeration Type Documentation

Like end cap styles.

The cap *always* extends beyond the coordinates given, by half the width of the line.

Beveled ends can used to make octagonal pads by giving the same x,y coordinate twice.

Enumerator:
Trace_Cap 

This means we're drawing a trace, which has round caps.

Square_Cap 

Square pins or pads.

Round_Cap 

Round pins or round-ended pads, thermals.

Beveled_Cap 

Octagon pins or bevel-cornered pads.

Definition at line 85 of file hid.h.

enum hids
Enumerator:
HID_Label 
HID_Integer 
HID_Real 
HID_String 
HID_Boolean 
HID_Enum 
HID_Mixed 
HID_Path 
HID_Unit 
HID_Coord 

Definition at line 233 of file hid.h.

These are layers with direct physical representation, like copper, dye or to be milled paths. Their data can't be derived from other layers or element data.

To add more layer types, add them to the list here and in layerflags.c. Order of entries in both lists must be the same.

Enumerator:
LT_COPPER 
LT_SILK 
LT_MASK 

Complements SL_MASK above.

LT_PASTE 

Complements SL_PASTE above.

LT_OUTLINE 

Board outline; exists only once.

LT_ROUTE 
LT_KEEPOUT 
LT_FAB 

Complements SL_FAB above.

LT_ASSY 

Complements SL_ASSY above.

LT_NOTES 
LT_NUM_LAYERTYPES 

Must be the last one.

Definition at line 308 of file hid.h.

File Watch flags.

Based upon those in dbus/dbus-connection.h.

Enumerator:
PCB_WATCH_READABLE 

As in POLLIN

PCB_WATCH_WRITABLE 

As in POLLOUT

PCB_WATCH_ERROR 

As in POLLERR

PCB_WATCH_HANGUP 

As in POLLHUP

Definition at line 328 of file hid.h.


Function Documentation

int hid_actionl ( const char *  action_,
  ... 
)
int hid_actionv ( const char *  action_,
int  argc_,
char **  argv_ 
)
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().

void hid_expose_callback ( HID hid,
BoxType region,
void *  item 
)

This function (in the common code) will be called whenever the GUI needs to redraw the screen, print the board, or export a layer.

If item is not NULL, only draw the given item. Item is only non-NULL if the HID was created via show_item.

Each time func is called, it should do the following:

allocate any colors needed, via get_color.

cycle through the layers, calling set_layer for each layer to be drawn, and only drawing elements (all or specified) of desired layers.

Do *not* assume that the hid that is passed is the GUI hid.

This callback is also used for printing and exporting.

Definition at line 1670 of file draw.c.

References OutputType::bgGC, hid_draw_st::destroy_gc, doing_pinout, draw_element(), DrawEverything(), OutputType::fgGC, hid_st::graphics, gui, hid_draw_st::make_gc, Output, OutputType::pmGC, and hid_draw_st::set_color.

Referenced by Benchmark(), eps_hid_export_to_file(), gcode_start_png_export(), gerber_do_export(), ghid_drawing_area_expose_cb(), ghid_pinout_preview_expose(), ghid_render_pixmap(), gsvit_start_png_export(), hid_get_extents(), idle_proc(), nelma_start_png_export(), pinout_callback(), png_hid_export_to_file(), ps_hid_export_to_file(), and redraw_region().

Here is the call graph for this function:

HID* hid_find_exporter ( const char *  )

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().

int hid_get_flag ( const char *  name_)

Looks up one of the flags registered above.

Returns:
If the flag is unknown, returns zero.

Definition at line 94 of file hid/common/flags.c.

References f, HID_Flag::function, GetValueEx(), hid_find_flag(), HID_Flag::parm, and realloc().

Referenced by lesstif_update_widget_flags(), menu_toggle_update_cb(), set_some_route_style(), and update_style_buttons().

Here is the call graph for this function:

void hid_init ( void  )

Call this as soon as possible from main().

No other HID calls are valid until this is called.

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

int hid_parse_actions ( const char *  str_)

Parse the given string into action calls, and call hid_actionv for each action found.

Accepts only "action(arg1, arg2)".

Definition at line 413 of file actions.c.

References hid_parse_actionstring(), and TRUE.

Referenced by ActionExecuteFile(), callback(), do_mouse_action(), ghid_listener_cb(), ghid_menu_cb(), lesstif_key_event(), lesstif_listener_cb(), and main().

Here is the call graph for this function:

int hid_parse_command ( const char *  str_)

Parse the given command string into action calls, and call hid_actionv for each action found.

Accepts both "action(arg1, arg2)" and command-style "action arg1 arg2", allowing only one action in the later case.

Returns:
Returns nonzero if the action handler(s) return nonzero.

Definition at line 408 of file actions.c.

References FALSE, and hid_parse_actionstring().

Referenced by batch_do_export(), command_callback(), command_entry_activate_cb(), and ghid_handle_user_command().

Here is the call graph for this function:

void hid_register_action ( HID_Action )

Definition at line 58 of file actions.c.

References hid_register_actions().

Here is the call graph for this function:

void hid_register_actions ( HID_Action ,
int   
)

Definition at line 37 of file actions.c.

References _, all_actions_sorted, check_action_name(), Message(), n, n_actions, and realloc().

Referenced by hid_register_action().

Here is the call graph for this function:

void hid_register_flags ( HID_Flag ,
int   
)

Definition at line 32 of file hid/common/flags.c.

References HID_FlagNode::flags, hid_flag_nodes, malloc(), n, HID_FlagNode::n, n_flags, and HID_FlagNode::next.

Here is the call graph for this function:

void hid_uninit ( void  )

Call this at exit.

Definition at line 207 of file hidinit.c.

Referenced by pcb_main_uninit().


Variable Documentation

This is either NULL or points to the current HID_Action that is being called.

The action launcher sets and unsets this variable.

Definition at line 25 of file actions.c.

Referenced by hid_actionv().

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().

HID* gui

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().

const char layerschanged_help[]
const char layerschanged_syntax[]
const char librarychanged_help[]
const char librarychanged_syntax[]
const char netlistchanged_help[]
const char netlistchanged_syntax[]
const char pcbchanged_help[]
const char pcbchanged_syntax[]

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().

Definition at line 1897 of file main.c.

Referenced by main().

Definition at line 1898 of file main.c.

Referenced by main(), and pcb_main_uninit().

char* program_name

Definition at line 1896 of file main.c.

Referenced by main().