pcb 4.1.1
An interactive printed circuit board layout editor.

hidgl.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include "action.h"
#include "crosshair.h"
#include "data.h"
#include "error.h"
#include "global.h"
#include "mymem.h"
#include "clip.h"
#include "hid.h"
#include "hidgl.h"
#include "rtree.h"
Include dependency graph for hidgl.c:

Go to the source code of this file.

Data Structures

struct  do_hole_info

Defines

#define GL_GLEXT_PROTOTYPES   1
#define MAX_PIXELS_ARC_TO_CHORD   0.5
#define MIN_SLICES   6
#define MIN_TRIANGLES_PER_CAP   3
#define MAX_TRIANGLES_PER_CAP   90
#define MIN_SLICES_PER_ARC   6
#define MAX_SLICES_PER_ARC   360
#define MIN_TRIANGLES_PER_CIRCLE   6
#define MAX_TRIANGLES_PER_CIRCLE   360
#define MAX_COMBINED_MALLOCS   2500
#define CALLBACK
#define MAX_COMBINED_VERTICES   2500

Functions

static void hidgl_init_triangle_array (triangle_buffer *buffer)
void hidgl_flush_triangles (triangle_buffer *buffer)
void hidgl_ensure_triangle_space (triangle_buffer *buffer, int count)
void hidgl_set_depth (float depth)
void hidgl_draw_grid (BoxType *drawn_area)
 Draw the grid on the 3D canvas.
int calc_slices (float pix_radius, float sweep_angle)
static void draw_cap (Coord width, Coord x, Coord y, Angle angle, double scale)
void hidgl_draw_line (int cap, Coord width, Coord x1, Coord y1, Coord x2, Coord y2, double scale)
void hidgl_draw_arc (Coord width, Coord x, Coord y, Coord rx, Coord ry, Angle start_angle, Angle delta_angle, double scale)
void hidgl_draw_rect (Coord x1, Coord y1, Coord x2, Coord y2)
void hidgl_fill_circle (Coord vx, Coord vy, Coord vr, double scale)
static void CALLBACK myError (GLenum errno)
static void CALLBACK myCombine (GLdouble coords[3], void *vertex_data[4], GLfloat weight[4], void **dataOut)
static void CALLBACK myBegin (GLenum type)
static void CALLBACK myVertex (GLdouble *vertex_data)
static void myFreeCombined ()
void hidgl_fill_polygon (int n_coords, Coord *x, Coord *y)
void tesselate_contour (GLUtesselator *tobj, PLINE *contour, GLdouble *vertices, double scale)
static int do_hole (const BoxType *b, void *cl)
static void fill_polyarea (POLYAREA *pa, const BoxType *clip_box, double scale)
void hidgl_fill_pcb_polygon (PolygonType *poly, const BoxType *clip_box, double scale)
void hidgl_fill_rect (Coord x1, Coord y1, Coord x2, Coord y2)
void hidgl_init (void)
void hidgl_start_render (void)
void hidgl_finish_render (void)
int hidgl_stencil_bits (void)
static void hidgl_clean_unassigned_stencil (void)
int hidgl_assign_clear_stencil_bit (void)
void hidgl_return_stencil_bit (int bit)
void hidgl_reset_stencil_usage (void)

Variables

triangle_buffer buffer
float global_depth = 0
static void * combined_to_free [MAX_COMBINED_MALLOCS]
static int combined_num_to_free = 0
static GLenum tessVertexType
static int stashed_vertices
static int triangle_comp_idx
static double global_scale
static GLint stencil_bits
static int dirty_bits = 0
static int assigned_bits = 0

Define Documentation

#define CALLBACK

Definition at line 430 of file hidgl.c.

#define GL_GLEXT_PROTOTYPES   1

Definition at line 40 of file hidgl.c.

#define MAX_COMBINED_MALLOCS   2500

Definition at line 421 of file hidgl.c.

Referenced by myCombine().

#define MAX_COMBINED_VERTICES   2500

Referenced by myCombine().

#define MAX_PIXELS_ARC_TO_CHORD   0.5

Definition at line 189 of file hidgl.c.

Referenced by calc_slices().

#define MAX_SLICES_PER_ARC   360

Definition at line 297 of file hidgl.c.

Referenced by hidgl_draw_arc().

#define MAX_TRIANGLES_PER_CAP   90

Definition at line 203 of file hidgl.c.

Referenced by draw_cap().

#define MAX_TRIANGLES_PER_CIRCLE   360

Referenced by hidgl_fill_circle().

#define MIN_SLICES   6

Definition at line 190 of file hidgl.c.

Referenced by calc_slices().

#define MIN_SLICES_PER_ARC   6

Definition at line 296 of file hidgl.c.

Referenced by hidgl_draw_arc().

#define MIN_TRIANGLES_PER_CAP   3

Definition at line 202 of file hidgl.c.

Referenced by draw_cap().

#define MIN_TRIANGLES_PER_CIRCLE   6

Referenced by hidgl_fill_circle().


Function Documentation

int calc_slices ( float  pix_radius,
float  sweep_angle 
)

Definition at line 191 of file hidgl.c.

References MAX_PIXELS_ARC_TO_CHORD, and MIN_SLICES.

Referenced by draw_cap(), hidgl_draw_arc(), hidgl_fill_circle(), and tesselate_contour().

static int do_hole ( const BoxType b,
void *  cl 
) [static]

Definition at line 616 of file hidgl.c.

References PLINE::Flags, PLINE::orient, PLF_DIR, do_hole_info::scale, tesselate_contour(), do_hole_info::tobj, and do_hole_info::vertices.

Referenced by fill_polyarea().

Here is the call graph for this function:

static void draw_cap ( Coord  width,
Coord  x,
Coord  y,
Angle  angle,
double  scale 
) [static]

Definition at line 204 of file hidgl.c.

References calc_slices(), hidgl_add_triangle(), hidgl_ensure_triangle_space(), M_PI, MAX_TRIANGLES_PER_CAP, MIN_TRIANGLES_PER_CAP, x, and y.

Referenced by hidgl_draw_arc(), and hidgl_draw_line().

Here is the call graph for this function:

int hidgl_assign_clear_stencil_bit ( void  )

Definition at line 782 of file hidgl.c.

References assigned_bits, dirty_bits, hidgl_clean_unassigned_stencil(), and stencil_bits.

Referenced by fill_polyarea(), ghid_use_mask(), and start_subcomposite().

Here is the call graph for this function:

static void hidgl_clean_unassigned_stencil ( void  ) [static]

Definition at line 772 of file hidgl.c.

References assigned_bits.

Referenced by hidgl_assign_clear_stencil_bit().

void hidgl_draw_arc ( Coord  width,
Coord  x,
Coord  y,
Coord  rx,
Coord  ry,
Angle  start_angle,
Angle  delta_angle,
double  scale 
)

Definition at line 299 of file hidgl.c.

References calc_slices(), draw_cap(), hidgl_add_triangle(), hidgl_ensure_triangle_space(), M_PI, MAX_SLICES_PER_ARC, MIN_SLICES_PER_ARC, scale, x, and y.

Referenced by draw_lead_user(), and ghid_draw_arc().

Here is the call graph for this function:

void hidgl_draw_grid ( BoxType drawn_area)

Draw the grid on the 3D canvas.

Definition at line 131 of file hidgl.c.

References SettingType::DrawGrid, global_depth, PCBType::Grid, GridFit(), PCBType::GridOffsetX, PCBType::GridOffsetY, MAX, PCBType::MaxHeight, PCBType::MaxWidth, MIN, n, PCB, realloc(), Settings, x, BoxType::X1, BoxType::X2, y, BoxType::Y1, and BoxType::Y2.

Referenced by ghid_draw_grid().

Here is the call graph for this function:

void hidgl_draw_line ( int  cap,
Coord  width,
Coord  x1,
Coord  y1,
Coord  x2,
Coord  y2,
double  scale 
)

Definition at line 232 of file hidgl.c.

References Beveled_Cap, draw_cap(), hidgl_add_triangle(), hidgl_ensure_triangle_space(), M_PI, Round_Cap, scale, Square_Cap, and Trace_Cap.

Referenced by ghid_draw_line().

Here is the call graph for this function:

void hidgl_draw_rect ( Coord  x1,
Coord  y1,
Coord  x2,
Coord  y2 
)

Definition at line 377 of file hidgl.c.

References global_depth.

Referenced by ghid_draw_rect().

void hidgl_ensure_triangle_space ( triangle_buffer buffer,
int  count 
)

Definition at line 108 of file hidgl.c.

References hidgl_flush_triangles(), TRIANGLE_ARRAY_SIZE, and triangle_buffer::triangle_count.

Referenced by draw_cap(), hidgl_draw_arc(), hidgl_draw_line(), hidgl_fill_circle(), hidgl_fill_rect(), and myVertex().

Here is the call graph for this function:

void hidgl_fill_circle ( Coord  vx,
Coord  vy,
Coord  vr,
double  scale 
)

Definition at line 389 of file hidgl.c.

References calc_slices(), hidgl_add_triangle(), hidgl_ensure_triangle_space(), M_PI, MAX_TRIANGLES_PER_CIRCLE, MIN_TRIANGLES_PER_CIRCLE, vx, vy, x, and y.

Referenced by ghid_fill_circle(), and tesselate_contour().

Here is the call graph for this function:

void hidgl_fill_pcb_polygon ( PolygonType poly,
const BoxType clip_box,
double  scale 
)

Definition at line 710 of file hidgl.c.

References polygon_st::Clipped, POLYAREA::f, fill_polyarea(), and TEST_FLAG.

Referenced by ghid_fill_pcb_polygon().

Here is the call graph for this function:

void hidgl_fill_polygon ( int  n_coords,
Coord x,
Coord y 
)

Definition at line 542 of file hidgl.c.

References malloc(), myBegin(), myCombine(), myError(), myFreeCombined(), and myVertex().

Referenced by ghid_fill_polygon().

Here is the call graph for this function:

void hidgl_fill_rect ( Coord  x1,
Coord  y1,
Coord  x2,
Coord  y2 
)

Definition at line 727 of file hidgl.c.

References hidgl_add_triangle(), and hidgl_ensure_triangle_space().

Referenced by ghid_fill_rect().

Here is the call graph for this function:

void hidgl_finish_render ( void  )
void hidgl_init ( void  )

Definition at line 735 of file hidgl.c.

References stencil_bits.

Referenced by hidgl_start_render().

static void hidgl_init_triangle_array ( triangle_buffer buffer) [static]

Definition at line 86 of file hidgl.c.

References triangle_buffer::coord_comp_count, and triangle_buffer::triangle_count.

Referenced by hidgl_start_render().

void hidgl_reset_stencil_usage ( void  )

Definition at line 825 of file hidgl.c.

References assigned_bits, and dirty_bits.

Referenced by ghid_drawing_area_expose_cb(), ghid_pinout_preview_expose(), and ghid_render_pixmap().

void hidgl_return_stencil_bit ( int  bit)

Definition at line 819 of file hidgl.c.

References assigned_bits.

Referenced by end_subcomposite(), fill_polyarea(), and ghid_use_mask().

void hidgl_set_depth ( float  depth)

Definition at line 122 of file hidgl.c.

References global_depth.

void hidgl_start_render ( void  )

Definition at line 754 of file hidgl.c.

References hidgl_init(), and hidgl_init_triangle_array().

Referenced by ghid_drawing_area_expose_cb(), ghid_pinout_preview_expose(), ghid_render_pixmap(), and ghid_request_debug_draw().

Here is the call graph for this function:

int hidgl_stencil_bits ( void  )

Definition at line 766 of file hidgl.c.

References stencil_bits.

Referenced by ghid_drawing_area_expose_cb().

static void CALLBACK myBegin ( GLenum  type) [static]

Definition at line 472 of file hidgl.c.

References stashed_vertices, tessVertexType, and triangle_comp_idx.

Referenced by fill_polyarea(), and hidgl_fill_polygon().

static void CALLBACK myCombine ( GLdouble  coords[3],
void *  vertex_data[4],
GLfloat  weight[4],
void **  dataOut 
) [static]

Definition at line 440 of file hidgl.c.

References combined_num_to_free, combined_to_free, malloc(), MAX_COMBINED_MALLOCS, and MAX_COMBINED_VERTICES.

Referenced by fill_polyarea(), and hidgl_fill_polygon().

Here is the call graph for this function:

static void CALLBACK myError ( GLenum  errno) [static]

Definition at line 434 of file hidgl.c.

Referenced by fill_polyarea(), and hidgl_fill_polygon().

static void myFreeCombined ( ) [static]

Definition at line 535 of file hidgl.c.

References combined_num_to_free, and combined_to_free.

Referenced by fill_polyarea(), and hidgl_fill_polygon().

static void CALLBACK myVertex ( GLdouble *  vertex_data) [static]

Definition at line 482 of file hidgl.c.

References hidgl_add_triangle(), hidgl_ensure_triangle_space(), stashed_vertices, tessVertexType, and triangle_comp_idx.

Referenced by fill_polyarea(), and hidgl_fill_polygon().

Here is the call graph for this function:

void tesselate_contour ( GLUtesselator *  tobj,
PLINE contour,
GLdouble *  vertices,
double  scale 
)

Definition at line 578 of file hidgl.c.

References calc_slices(), PLINE::cx, PLINE::cy, PLINE::head, hidgl_fill_circle(), PLINE::is_round, M_PI, VNODE::next, VNODE::point, and PLINE::radius.

Referenced by do_hole(), and fill_polyarea().

Here is the call graph for this function:


Variable Documentation

int combined_num_to_free = 0 [static]

Definition at line 423 of file hidgl.c.

Referenced by myCombine(), and myFreeCombined().

void* combined_to_free[MAX_COMBINED_MALLOCS] [static]

Definition at line 422 of file hidgl.c.

Referenced by myCombine(), and myFreeCombined().

int dirty_bits = 0 [static]

Definition at line 631 of file hidgl.c.

Referenced by hidgl_assign_clear_stencil_bit(), and hidgl_reset_stencil_usage().

float global_depth = 0

Definition at line 83 of file hidgl.c.

Referenced by hidgl_add_triangle(), hidgl_draw_grid(), hidgl_draw_rect(), and hidgl_set_depth().

double global_scale [static]

Definition at line 479 of file hidgl.c.

Referenced by fill_polyarea().

int stashed_vertices [static]

Definition at line 426 of file hidgl.c.

Referenced by myBegin(), and myVertex().

GLint stencil_bits [static]

Definition at line 630 of file hidgl.c.

Referenced by hidgl_assign_clear_stencil_bit(), hidgl_init(), and hidgl_stencil_bits().

GLenum tessVertexType [static]

Definition at line 425 of file hidgl.c.

Referenced by myBegin(), and myVertex().

int triangle_comp_idx [static]

Definition at line 427 of file hidgl.c.

Referenced by myBegin(), and myVertex().