pcb 4.1.1
An interactive printed circuit board layout editor.

nelma.c File Reference

#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <time.h>
#include "global.h"
#include "error.h"
#include "data.h"
#include "misc.h"
#include "rats.h"
#include "hid.h"
#include "hid_draw.h"
#include "../hidint.h"
#include "hid/common/hidnogui.h"
#include "hid/common/draw_helpers.h"
#include <gd.h>
#include "hid/common/hidinit.h"
Include dependency graph for nelma.c:

Go to the source code of this file.

Data Structures

struct  color_struct
struct  hid_gc_struct

Defines

#define CRASH   fprintf(stderr, "HID error: pcb called unimplemented PNG function %s.\n", __FUNCTION__); abort()

Functions

 REGISTER_ATTRIBUTES (nelma_attribute_list)
static char * nelma_get_png_name (const char *basename, const char *suffix)
static int pin_name_to_xy (LibraryEntryType *pin, Coord *x, Coord *y)
static void nelma_write_space (FILE *out)
static void nelma_write_material (FILE *out, char *name, char *type, double e)
static void nelma_write_materials (FILE *out)
static void nelma_write_nets (FILE *out)
static void nelma_write_layer (FILE *out, int z, int h, const char *name, int full, char *mat)
static void nelma_write_layers (FILE *out)
static void nelma_write_object (FILE *out, LibraryEntryType *pin)
static void nelma_write_objects (FILE *out)
static void nelma_parse_arguments (int *argc, char ***argv)
static HID_Attributenelma_get_export_options (int *n)
void nelma_choose_groups ()
static void nelma_alloc_colors ()
static void nelma_start_png (const char *basename, const char *suffix)
static void nelma_finish_png ()
void nelma_start_png_export ()
static void nelma_do_export (HID_Attr_Val *options)
static int nelma_set_layer (const char *name, int group, int empty)
static hidGC nelma_make_gc (void)
static void nelma_destroy_gc (hidGC gc)
static void nelma_use_mask (enum mask_mode mode)
static void nelma_set_color (hidGC gc, const char *name)
static void nelma_set_line_cap (hidGC gc, EndCapStyle style)
static void nelma_set_line_width (hidGC gc, Coord width)
static void nelma_set_draw_xor (hidGC gc, int xor_)
static void nelma_set_draw_faded (hidGC gc, int faded)
static void use_gc (hidGC gc)
static void nelma_draw_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2)
static void nelma_fill_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2)
static void nelma_draw_line (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2)
static void nelma_draw_arc (hidGC gc, Coord cx, Coord cy, Coord width, Coord height, Angle start_angle, Angle delta_angle)
static void nelma_fill_circle (hidGC gc, Coord cx, Coord cy, Coord radius)
static void nelma_fill_polygon (hidGC gc, int n_coords, Coord *x, Coord *y)
static void nelma_calibrate (double xval, double yval)
static void nelma_set_crosshair (int x, int y, int a)
void hid_nelma_init ()

Variables

static HID nelma_hid
static HID_DRAW nelma_graphics
static struct color_structblack = NULL
static struct color_structwhite = NULL
static Coord linewidth = -1
static gdImagePtr lastbrush = (gdImagePtr)((void *) -1)
static gdImagePtr nelma_im = NULL
static FILE * nelma_f = NULL
static int is_mask
static int is_drill
static int nelma_export_group [MAX_GROUP]
static int nelma_cur_group
static const char * nelma_basename = NULL
static int nelma_dpi = -1
static int nelma_copperh = -1
static int nelma_substrateh = -1
static double nelma_substratee = -1
static const double nelma_air_epsilon = 8.85e-12
HID_Attribute nelma_attribute_list []

Define Documentation

#define CRASH   fprintf(stderr, "HID error: pcb called unimplemented PNG function %s.\n", __FUNCTION__); abort()

Definition at line 86 of file nelma.c.

Referenced by nelma_calibrate().


Function Documentation

static void nelma_alloc_colors ( ) [static]

Definition at line 581 of file nelma.c.

References color_struct::b, color_struct::c, color_struct::g, malloc(), color_struct::r, and white.

Referenced by nelma_start_png().

Here is the call graph for this function:

static void nelma_calibrate ( double  xval,
double  yval 
) [static]

Definition at line 1023 of file nelma.c.

References CRASH.

Referenced by hid_nelma_init().

void nelma_choose_groups ( )

Definition at line 549 of file nelma.c.

References LayerType::ArcN, PCBType::Data, GetLayerGroupNumberByNumber(), DataType::Layer, layer, LayerType::LineN, m, max_copper_layer, n, PCB, LayerType::PolygonN, SL_TYPE, and LayerType::TextN.

Referenced by nelma_do_export().

Here is the call graph for this function:

static void nelma_destroy_gc ( hidGC  gc) [static]

Definition at line 775 of file nelma.c.

Referenced by hid_nelma_init().

static void nelma_draw_arc ( hidGC  gc,
Coord  cx,
Coord  cy,
Coord  width,
Coord  height,
Angle  start_angle,
Angle  delta_angle 
) [static]

Definition at line 948 of file nelma.c.

References color_struct::c, hid_gc_struct::color, im, linewidth, NormalizeAngle(), SCALE, SCALE_X, SCALE_Y, start_angle, and use_gc().

Referenced by hid_nelma_init().

Here is the call graph for this function:

static void nelma_draw_line ( hidGC  gc,
Coord  x1,
Coord  y1,
Coord  x2,
Coord  y2 
) [static]

Definition at line 932 of file nelma.c.

References linewidth, nelma_fill_rect(), use_gc(), and hid_gc_struct::width.

Referenced by hid_nelma_init().

Here is the call graph for this function:

static void nelma_draw_rect ( hidGC  gc,
Coord  x1,
Coord  y1,
Coord  x2,
Coord  y2 
) [static]

Definition at line 913 of file nelma.c.

References color_struct::c, hid_gc_struct::color, and use_gc().

Referenced by hid_nelma_init().

Here is the call graph for this function:

static void nelma_fill_circle ( hidGC  gc,
Coord  cx,
Coord  cy,
Coord  radius 
) [static]

Definition at line 989 of file nelma.c.

References color_struct::c, hid_gc_struct::color, linewidth, and use_gc().

Referenced by hid_nelma_init().

Here is the call graph for this function:

static void nelma_fill_polygon ( hidGC  gc,
int  n_coords,
Coord x,
Coord y 
) [static]

Definition at line 1001 of file nelma.c.

References color_struct::c, hid_gc_struct::color, linewidth, malloc(), and use_gc().

Referenced by hid_nelma_init().

Here is the call graph for this function:

static void nelma_fill_rect ( hidGC  gc,
Coord  x1,
Coord  y1,
Coord  x2,
Coord  y2 
) [static]

Definition at line 922 of file nelma.c.

References color_struct::c, hid_gc_struct::color, linewidth, and use_gc().

Referenced by hid_nelma_init(), and nelma_draw_line().

Here is the call graph for this function:

static void nelma_finish_png ( ) [static]

Definition at line 620 of file nelma.c.

References Message(), and white.

Referenced by nelma_do_export().

Here is the call graph for this function:

static HID_Attribute* nelma_get_export_options ( int *  n) [static]

Definition at line 531 of file nelma.c.

References derive_default_filename(), PCBType::Filename, nelma_attribute_list, and PCB.

Referenced by hid_nelma_init(), and nelma_do_export().

Here is the call graph for this function:

static char* nelma_get_png_name ( const char *  basename,
const char *  suffix 
) [static]

Definition at line 225 of file nelma.c.

References len, and malloc().

Referenced by nelma_start_png(), and nelma_write_object().

Here is the call graph for this function:

static hidGC nelma_make_gc ( void  ) [static]
static void nelma_parse_arguments ( int *  argc,
char ***  argv 
) [static]

Definition at line 522 of file nelma.c.

References hid_parse_command_line(), and hid_register_attributes().

Referenced by hid_nelma_init().

Here is the call graph for this function:

static void nelma_set_color ( hidGC  gc,
const char *  name 
) [static]

Definition at line 787 of file nelma.c.

References black, hid_gc_struct::color, hid_gc_struct::erase, and white.

Referenced by hid_nelma_init().

static void nelma_set_crosshair ( int  x,
int  y,
int  a 
) [static]

Definition at line 1029 of file nelma.c.

Referenced by hid_nelma_init().

static void nelma_set_draw_faded ( hidGC  gc,
int  faded 
) [static]

Definition at line 830 of file nelma.c.

Referenced by hid_nelma_init().

static void nelma_set_draw_xor ( hidGC  gc,
int  xor_ 
) [static]

Definition at line 824 of file nelma.c.

Referenced by hid_nelma_init().

static int nelma_set_layer ( const char *  name,
int  group,
int  empty 
) [static]
static void nelma_set_line_cap ( hidGC  gc,
EndCapStyle  style 
) [static]

Definition at line 812 of file nelma.c.

References hid_gc_struct::cap, and style.

Referenced by hid_nelma_init().

static void nelma_set_line_width ( hidGC  gc,
Coord  width 
) [static]

Definition at line 818 of file nelma.c.

References hid_gc_struct::width.

Referenced by hid_nelma_init().

static void nelma_start_png ( const char *  basename,
const char *  suffix 
) [static]

Definition at line 598 of file nelma.c.

References PCBType::MaxHeight, PCBType::MaxWidth, nelma_alloc_colors(), nelma_get_png_name(), and PCB.

Referenced by nelma_do_export().

Here is the call graph for this function:

void nelma_start_png_export ( )

Definition at line 638 of file nelma.c.

References hid_expose_callback(), lastbrush, linewidth, PCBType::MaxHeight, PCBType::MaxWidth, PCB, region, BoxType::X1, BoxType::X2, BoxType::Y1, and BoxType::Y2.

Referenced by nelma_do_export().

Here is the call graph for this function:

static void nelma_use_mask ( enum mask_mode  mode) [static]

Definition at line 781 of file nelma.c.

Referenced by hid_nelma_init().

static void nelma_write_layer ( FILE *  out,
int  z,
int  h,
const char *  name,
int  full,
char *  mat 
) [static]
static void nelma_write_layers ( FILE *  out) [static]

Definition at line 411 of file nelma.c.

References LayerGroupType::Entries, FNS_fixed, layer_type_to_file_name(), PCBType::LayerGroups, max_group, nelma_copperh, nelma_write_layer(), and PCB.

Referenced by nelma_do_export().

Here is the call graph for this function:

static void nelma_write_material ( FILE *  out,
char *  name,
char *  type,
double  e 
) [static]

Definition at line 304 of file nelma.c.

Referenced by nelma_write_materials().

static void nelma_write_materials ( FILE *  out) [static]

Definition at line 315 of file nelma.c.

References nelma_write_material().

Referenced by nelma_do_export().

Here is the call graph for this function:

static void nelma_write_nets ( FILE *  out) [static]
static void nelma_write_object ( FILE *  out,
LibraryEntryType pin 
) [static]

Definition at line 458 of file nelma.c.

References LayerGroupType::Entries, f, FNS_fixed, layer_type_to_file_name(), PCBType::LayerGroups, LibraryEntryType::ListEntry, max_group, nelma_get_png_name(), PCB, pin_name_to_xy(), px, py, x, and y.

Referenced by nelma_write_objects().

Here is the call graph for this function:

static void nelma_write_objects ( FILE *  out) [static]

Definition at line 496 of file nelma.c.

References LibraryMenuType::Entry, LibraryMenuType::EntryN, m, LibraryType::Menu, LibraryType::MenuN, n, nelma_write_object(), PCBType::NetlistLib, PCB, and pin.

Referenced by nelma_do_export().

Here is the call graph for this function:

static void nelma_write_space ( FILE *  out) [static]

Definition at line 262 of file nelma.c.

References LayerGroupType::Entries, FNS_fixed, layer_type_to_file_name(), PCBType::LayerGroups, max_group, and PCB.

Referenced by nelma_do_export().

Here is the call graph for this function:

static int pin_name_to_xy ( LibraryEntryType pin,
Coord x,
Coord y 
) [static]

Definition at line 241 of file nelma.c.

References ConnectionType::ptr2, SeekPad(), ConnectionType::type, X, and Y.

Referenced by nelma_write_object().

Here is the call graph for this function:

REGISTER_ATTRIBUTES ( nelma_attribute_list  )

Definition at line 213 of file nelma.c.

References COORD_TO_INCH, and nelma_dpi.


Variable Documentation

struct color_struct* black = NULL [static]

Definition at line 111 of file nelma.c.

Referenced by nelma_set_color().

int is_drill [static]

Definition at line 120 of file nelma.c.

int is_mask [static]

Definition at line 119 of file nelma.c.

gdImagePtr lastbrush = (gdImagePtr)((void *) -1) [static]

Definition at line 113 of file nelma.c.

Referenced by nelma_start_png_export(), and use_gc().

const double nelma_air_epsilon = 8.85e-12 [static]

Definition at line 150 of file nelma.c.

Initial value:
 {
        


        {"basename", "File name prefix",
        HID_String, 0, 0, {0, 0, 0}, 0, 0},
#define HA_basename 0


        {"dpi", "Horizontal scale factor (grid points/inch)",
        HID_Integer, 0, 1000, {100, 0, 0}, 0, 0},
#define HA_dpi 1


        {"copper-height", "Copper layer height (um)",
        HID_Integer, 0, 200, {100, 0, 0}, 0, 0},
#define HA_copperh 2


        {"substrate-height", "Substrate layer height (um)",
        HID_Integer, 0, 10000, {2000, 0, 0}, 0, 0},
#define HA_substrateh 3


        {"substrate-epsilon", "Substrate relative epsilon",
        HID_Real, 0, 100, {0, 0, 4.0}, 0, 0},
#define HA_substratee 4
}

Definition at line 152 of file nelma.c.

Referenced by nelma_get_export_options().

const char* nelma_basename = NULL [static]

Definition at line 132 of file nelma.c.

int nelma_copperh = -1 [static]

Definition at line 143 of file nelma.c.

Referenced by nelma_write_layers().

int nelma_cur_group [static]

Definition at line 129 of file nelma.c.

int nelma_dpi = -1 [static]

Definition at line 135 of file nelma.c.

Referenced by REGISTER_ATTRIBUTES().

int nelma_export_group[MAX_GROUP] [static]

Definition at line 126 of file nelma.c.

FILE* nelma_f = NULL [static]

Definition at line 117 of file nelma.c.

Definition at line 109 of file nelma.c.

Referenced by hid_nelma_init().

HID nelma_hid [static]

Definition at line 108 of file nelma.c.

Referenced by nelma_make_gc().

gdImagePtr nelma_im = NULL [static]

Definition at line 116 of file nelma.c.

double nelma_substratee = -1 [static]

Definition at line 147 of file nelma.c.

int nelma_substrateh = -1 [static]

Definition at line 145 of file nelma.c.

struct color_struct * white = NULL

Definition at line 111 of file nelma.c.