pcb 4.1.1
An interactive printed circuit board layout editor.

hid.h

Go to the documentation of this file.
00001 
00066 #ifndef PCB_HID_H
00067 #define PCB_HID_H
00068 
00069 #include <stdarg.h>
00070 
00071 #if defined(__cplusplus) && __cplusplus
00072 extern "C"
00073 {
00074 #endif
00075 
00085   typedef enum
00086   {
00087     Trace_Cap, 
00088     Square_Cap, 
00089     Round_Cap, 
00090     Beveled_Cap 
00091   } EndCapStyle;
00092 
00100   typedef union
00101   {
00102     long lval;
00103     void *ptr;
00104   } hidval;
00105 
00112   typedef struct hid_gc_struct *hidGC;
00113 
00114 #define HIDCONCAT(a,b) a##b
00115 
00124   typedef struct
00125   {
00126     char *name;
00128     const char *need_coord_msg;
00133     int (*trigger_cb) (int argc, char **argv, Coord x, Coord y);
00137     const char *description;
00139     const char *syntax;
00141   } HID_Action;
00142 
00143   extern void hid_register_action (HID_Action *);
00144 
00145   extern void hid_register_actions (HID_Action *, int);
00146 #define REGISTER_ACTIONS(a) HIDCONCAT(void register_,a) ()\
00147 { hid_register_actions(a, sizeof(a)/sizeof(a[0])); }
00148 
00149   /* Note that PCB expects the gui to provide the following actions:
00150 
00151      PCBChanged();
00152      RouteStylesChanged()
00153      NetlistChanged()  (but core should call "void NetlistChanged(int);" in netlist.c)
00154      LayersChanged()
00155      LibraryChanged()
00156      Busy()
00157    */
00158 
00159   extern const char pcbchanged_help[];
00160   extern const char pcbchanged_syntax[];
00161   extern const char routestyleschanged_help[];
00162   extern const char routestyleschanged_syntax[];
00163   extern const char netlistchanged_help[];
00164   extern const char netlistchanged_syntax[];
00165   extern const char layerschanged_help[];
00166   extern const char layerschanged_syntax[];
00167   extern const char librarychanged_help[];
00168   extern const char librarychanged_syntax[];
00169 
00170   int hid_action (const char *action_);
00171   int hid_actionl (const char *action_, ...);   /* NULL terminated */
00172   int hid_actionv (const char *action_, int argc_, char **argv_);
00173   void hid_save_settings (int);
00174   void hid_load_settings (void);
00175 
00185   int hid_parse_command (const char *str_);
00186 
00193   int hid_parse_actions (const char *str_);
00194 
00195   typedef struct
00196   {
00197     char *name; 
00198     int (*function) (void *);
00200     void *parm;
00202   } HID_Flag;
00203 
00204   extern void hid_register_flags (HID_Flag *, int);
00205 #define REGISTER_FLAGS(a) HIDCONCAT(void register_,a) ()\
00206 { hid_register_flags(a, sizeof(a)/sizeof(a[0])); }
00207 
00213   int hid_get_flag (const char *name_);
00214 
00225   typedef struct
00226   {
00227     int int_value;
00228     const char *str_value;
00229     double real_value;
00230     Coord coord_value;
00231   } HID_Attr_Val;
00232 
00233   enum hids
00234     { HID_Label, HID_Integer, HID_Real, HID_String,
00235       HID_Boolean, HID_Enum, HID_Mixed, HID_Path,
00236       HID_Unit, HID_Coord
00237     };
00238 
00239   typedef struct
00240   {
00241     char *name;
00242 #define ATTR_UNDOCUMENTED ((char *)(1))
00243     char *help_text;
00245     enum hids type;
00246     int min_val; 
00247     int max_val; 
00248     HID_Attr_Val default_val; 
00249     const char **enumerations;
00250     void *value;
00259     int hash; 
00260   } HID_Attribute;
00261 
00262   extern void hid_register_attributes (HID_Attribute *, int);
00263 
00264 #define REGISTER_ATTRIBUTES(a) HIDCONCAT(void register_,a) ()\
00265 { hid_register_attributes(a, sizeof(a)/sizeof(a[0])); }
00266 
00267 /* These three are set by hid_parse_command_line().  */
00268   extern char *program_name;
00269   extern char *program_directory;
00270   extern char *program_basename;
00271 
00272 /* These are used for set_layer(). */
00273 #define SL_0_SIDE       0x0000
00274 #define SL_TOP_SIDE     0x0001
00275 #define SL_BOTTOM_SIDE  0x0002
00276 #define SL_INNER_SIDE   0x0004
00277 
00278 /*
00279  * These are types of "layers" without direct physical representation.
00280  * Their content can be derived from other layers and element data.
00281  *
00282  * These values are used by DrawEverything() in draw.c to ask the active
00283  * GUI or exporter to act on these layers. Depending on the GUI/exporter
00284  * they result in a per-layer file, in some additional graphics or just
00285  * nothing.
00286  */
00287 #define SL_SILK         0x0010 
00288 #define SL_MASK         0x0020
00289 #define SL_PDRILL       0x0030
00290 #define SL_UDRILL       0x0040
00291 #define SL_PASTE        0x0050
00292 #define SL_INVISIBLE    0x0060
00293 #define SL_FAB          0x0070
00294 #define SL_ASSY         0x0080
00295 #define SL_RATS         0x0090
00296 
00297 /* Callers should use this.  */
00298 #define SL(type,side) (~0xfff | SL_##type | SL_##side##_SIDE)
00299 
00308 typedef enum
00309 {
00310   LT_COPPER = 0,
00311   LT_SILK,
00312   LT_MASK,           
00313   LT_PASTE,          
00314   LT_OUTLINE,        
00315   LT_ROUTE,
00316   LT_KEEPOUT,
00317   LT_FAB,            
00318   LT_ASSY,           
00319   LT_NOTES,
00320   LT_NUM_LAYERTYPES  
00321 } LayertypeType;
00322 
00328 typedef enum
00329 {
00330   PCB_WATCH_READABLE = 1 << 0, 
00331   PCB_WATCH_WRITABLE = 1 << 1, 
00332   PCB_WATCH_ERROR    = 1 << 2, 
00333   PCB_WATCH_HANGUP   = 1 << 3  
00334 } PCBWatchFlags;
00335 
00339   typedef struct
00340   {
00341     int log_drc_overview;
00342     int log_drc_violations;
00343     void (*reset_drc_dialog_message) (void);
00344     void (*append_drc_violation) (DrcViolationType *violation);
00345     int (*throw_drc_dialog) (void);
00346   } HID_DRC_GUI;
00347 
00348   typedef struct hid_st HID;
00349   typedef struct hid_draw_st HID_DRAW;
00350 
00354   struct hid_st
00355   {
00356     int struct_size;
00364     const char *name;
00371     const char *description;
00374     char gui:1;
00381     char printer:1;
00389     char exporter:1;
00396     char poly_before:1;
00401     char poly_after:1;
00409     HID_Attribute *(*get_export_options) (int *n_ret_);
00423     void (*do_export) (HID_Attr_Val * options_);
00433     void (*uninit) (HID *hid);
00436     void (*do_exit) (HID *hid);
00439     void (*parse_arguments) (int *argc_, char ***argv_);
00449     void (*invalidate_lr) (Coord left_, Coord right_,
00450                            Coord top_, Coord bottom_);
00455     void (*invalidate_all) (void);
00456 
00457     void (*notify_crosshair_change) (bool changes_complete);
00458 
00459     void (*notify_mark_change) (bool changes_complete);
00460 
00461     int (*set_layer) (const char *name_, int group_, int _empty);
00482     void (*end_layer) (void);
00485     HID_DRAW *graphics;
00486 
00487     void (*calibrate) (double xval_, double yval_);
00505     /* GUI layout functions.  Not used or defined for print/export
00506        HIDs.  */
00507 
00508     /* Temporary */
00509     int (*shift_is_pressed) (void);
00510 
00511     int (*control_is_pressed) (void);
00512     int (*mod1_is_pressed) (void);
00513 
00514     void (*get_coords) (const char *msg_, Coord *x_, Coord *y_);
00515 
00516     void (*set_crosshair) (int x_, int y_, int cursor_action_);
00531 #define HID_SC_DO_NOTHING                          0
00532 
00533 #define HID_SC_WARP_POINTER                            1
00534 
00535 #define HID_SC_PAN_VIEWPORT                        2
00536 
00537 #define HID_SC_CENTER_IN_VIEWPORT                  3
00538 
00539 #define HID_SC_CENTER_IN_VIEWPORT_AND_WARP_POINTER 4
00540 
00541       hidval (*add_timer) (void (*func) (hidval user_data_),
00542                            unsigned long milliseconds_, hidval user_data_);
00553     void (*stop_timer) (hidval timer_);
00556     hidval (*watch_file) (int fd_, unsigned int condition_, void (*func_) (hidval watch_, int fd_, unsigned int condition_, hidval user_data_),
00557             hidval user_data);
00567     void (*unwatch_file) (hidval watch_);
00570     hidval (*add_block_hook) (void (*func_) (hidval data_), hidval data_);
00575     void (*stop_block_hook) (hidval block_hook_);
00578     /* Various dialogs */
00579 
00580     void (*log) (const char *fmt_, ...);
00583     void (*logv) (const char *fmt_, va_list args_);
00586     int (*confirm_dialog) (char *msg_, ...);
00599     int (*close_confirm_dialog) ();
00609 #define HID_CLOSE_CONFIRM_CANCEL 0
00610 
00611 #define HID_CLOSE_CONFIRM_OK     1
00612 
00613     void (*report_dialog) (char *title_, char *msg_);
00616     char *(*prompt_for) (const char *msg_, const char *default_string_);
00625 #define HID_FILESELECT_READ  0x01
00626 
00633 #define HID_FILESELECT_MAY_NOT_EXIST 0x02
00634 
00643 #define HID_FILESELECT_IS_TEMPLATE 0x04
00644 
00650     char *(*fileselect) (const char *title_, const char *descr_,
00651                          char *default_file_, char *default_ext_,
00652                          const char *history_tag_, int flags_);
00670     int (*attribute_dialog) (HID_Attribute * attrs_,
00671                              int n_attrs_, HID_Attr_Val * results_,
00672                              const char * title_, const char * descr_);
00689     void (*show_item) (void *item_);
00700     void (*beep) (void);
00703     int (*progress) (int so_far_, int total_, const char *message_);
00712     HID_DRC_GUI *drc_gui;
00713 
00714     void (*edit_attributes) (char *owner, AttributeListType *attrlist_);
00715 
00716     /* Debug drawing support. These APIs must be implemented (non NULL),
00717      * but they do not have to be functional. request_debug_draw can
00718      * return NULL to indicate debug drawing is not permitted.
00719      *
00720      * Debug drawing is not guaranteed to be re-entrant.
00721      * The caller must not nest requests for debug drawing.
00722      */
00723 
00724     HID_DRAW *(*request_debug_draw) (void);
00737     void (*flush_debug_draw)   (void);
00744     void (*finish_debug_draw)  (void);
00751     void (*notify_save_pcb) (const char *filename, bool done);
00761     void (*notify_filename_changed) (void);
00763   };
00764 
00770   void hid_init (void);
00771 
00775   void hid_uninit (void);
00776 
00783   HID *hid_find_gui ();
00784 
00788   HID *hid_find_printer (void);
00789 
00793   HID *hid_find_exporter (const char *);
00794 
00801   HID **hid_enumerate (void);
00802 
00823   void hid_expose_callback (HID * hid_, struct BoxType *region_, void *item_);
00824 
00825   extern HID *gui;
00832   extern HID *exporter;
00839   extern HID_Action *current_action;
00846   extern int pixel_slop;
00852 #if defined(__cplusplus) && __cplusplus
00853 }
00854 #endif
00855 
00856 #endif