pcb 4.1.1
An interactive printed circuit board layout editor.

gtkhid-gdk.c File Reference

Functions for drawing on the GTK 2D graphics canvas. More...

#include <stdio.h>
#include "crosshair.h"
#include "clip.h"
#include "../hidint.h"
#include "gui.h"
#include "hid/common/draw_helpers.h"
Include dependency graph for gtkhid-gdk.c:

Go to the source code of this file.

Data Structures

struct  render_priv
struct  hid_gc_struct
struct  ColorCache

Defines

#define USE_GC(gc)   if (!use_gc(gc)) return
#define WHICH_GC(gc)   (cur_mask == HID_MASK_CLEAR ? priv->mask_gc : (gc)->gc)
#define LEAD_USER_WIDTH   0.2
#define LEAD_USER_PERIOD   (1000 / 5)
#define LEAD_USER_VELOCITY   3.
#define LEAD_USER_ARC_COUNT   3
#define LEAD_USER_ARC_SEPARATION   3.
#define LEAD_USER_INITIAL_RADIUS   10.
#define LEAD_USER_COLOR_R   1.
#define LEAD_USER_COLOR_G   1.
#define LEAD_USER_COLOR_B   0.

Typedefs

typedef struct render_priv render_priv
typedef struct hid_gc_struct hid_gc_struct

Functions

static void draw_lead_user (render_priv *priv)
int ghid_set_layer (const char *name, int group, int empty)
void ghid_destroy_gc (hidGC gc)
hidGC ghid_make_gc (void)
static void set_clip (render_priv *priv, GdkGC *gc)
 Set the drawing clip region.
void ghid_draw_grid (BoxType *region)
 Draw the grid on the 2D canvas.
static void ghid_draw_bg_image (void)
void ghid_use_mask (enum mask_mode mode)
static void set_special_grid_color (void)
void ghid_set_special_colors (HID_Attribute *ha)
void ghid_set_color (hidGC gc, const char *name)
void ghid_set_line_cap (hidGC gc, EndCapStyle style)
void ghid_set_line_width (hidGC gc, Coord width)
void ghid_set_draw_xor (hidGC gc, int xor_mask)
static int use_gc (hidGC gc)
void ghid_draw_line (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2)
void ghid_draw_arc (hidGC gc, Coord cx, Coord cy, Coord xradius, Coord yradius, Angle start_angle, Angle delta_angle)
void ghid_draw_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2)
void ghid_fill_circle (hidGC gc, Coord cx, Coord cy, Coord radius)
void ghid_fill_polygon (hidGC gc, int n_coords, Coord *x, Coord *y)
void ghid_fill_rect (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2)
static void redraw_region (GdkRectangle *rect)
 Redraw a region of the pcb workspace.
void ghid_invalidate_lr (Coord left, Coord right, Coord top, Coord bottom)
void ghid_invalidate_all ()
void ghid_notify_crosshair_change (bool changes_complete)
void ghid_notify_mark_change (bool changes_complete)
static void draw_right_cross (GdkGC *xor_gc, gint x, gint y)
static void draw_slanted_cross (GdkGC *xor_gc, gint x, gint y)
static void draw_dozen_cross (GdkGC *xor_gc, gint x, gint y)
static void draw_crosshair (render_priv *priv)
void ghid_init_renderer (int *argc, char ***argv, GHidPort *port)
void ghid_shutdown_renderer (GHidPort *port)
void ghid_init_drawing_widget (GtkWidget *widget, GHidPort *port)
void ghid_drawing_area_configure_hook (GHidPort *port)
void ghid_screen_update (void)
gboolean ghid_drawing_area_expose_cb (GtkWidget *widget, GdkEventExpose *ev, GHidPort *port)
void ghid_port_drawing_realize_cb (GtkWidget *widget, gpointer data)
gboolean ghid_pinout_preview_expose (GtkWidget *widget, GdkEventExpose *ev)
GdkPixmap * ghid_render_pixmap (int cx, int cy, double zoom, int width, int height, int depth)
HID_DRAWghid_request_debug_draw (void)
void ghid_flush_debug_draw (void)
void ghid_finish_debug_draw (void)
bool ghid_event_to_pcb_coords (int event_x, int event_y, Coord *pcb_x, Coord *pcb_y)
bool ghid_pcb_to_event_coords (Coord pcb_x, Coord pcb_y, int *event_x, int *event_y)
gboolean lead_user_cb (gpointer data)
void ghid_lead_user_to_location (Coord x, Coord y)
void ghid_cancel_lead_user (void)

Variables

HID ghid_hid
HID_DRAW ghid_graphics
static enum mask_mode cur_mask = HID_MASK_OFF
static int mask_seq = 0

Detailed Description

Functions for drawing on the GTK 2D graphics canvas.


Copyright.


PCB, interactive printed circuit board design

Copyright (C) 1994,1995,1996,1997,1998,2005,2006 Thomas Nau

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: Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany Thomas.Nau@rz.uni-ulm.de

Definition in file gtkhid-gdk.c.


Define Documentation

#define LEAD_USER_ARC_COUNT   3

Definition at line 1334 of file gtkhid-gdk.c.

Referenced by draw_lead_user().

#define LEAD_USER_ARC_SEPARATION   3.

Definition at line 1335 of file gtkhid-gdk.c.

Referenced by draw_lead_user().

#define LEAD_USER_COLOR_B   0.

Definition at line 1339 of file gtkhid-gdk.c.

Referenced by draw_lead_user().

#define LEAD_USER_COLOR_G   1.

Definition at line 1338 of file gtkhid-gdk.c.

Referenced by draw_lead_user().

#define LEAD_USER_COLOR_R   1.

Definition at line 1337 of file gtkhid-gdk.c.

Referenced by draw_lead_user().

#define LEAD_USER_INITIAL_RADIUS   10.

Definition at line 1336 of file gtkhid-gdk.c.

Referenced by draw_lead_user(), ghid_lead_user_to_location(), and lead_user_cb().

#define LEAD_USER_PERIOD   (1000 / 5)

Definition at line 1332 of file gtkhid-gdk.c.

Referenced by ghid_lead_user_to_location().

#define LEAD_USER_VELOCITY   3.

Definition at line 1333 of file gtkhid-gdk.c.

Referenced by lead_user_cb().

#define LEAD_USER_WIDTH   0.2

Definition at line 1331 of file gtkhid-gdk.c.

Referenced by draw_lead_user().

#define USE_GC (   gc)    if (!use_gc(gc)) return
#define WHICH_GC (   gc)    (cur_mask == HID_MASK_CLEAR ? priv->mask_gc : (gc)->gc)

Definition at line 301 of file gtkhid-gdk.c.

Referenced by ghid_set_line_cap(), ghid_set_line_width(), and use_gc().


Typedef Documentation

typedef struct hid_gc_struct hid_gc_struct
typedef struct render_priv render_priv

Function Documentation

static void draw_dozen_cross ( GdkGC *  xor_gc,
gint  x,
gint  y 
) [static]

Definition at line 1010 of file gtkhid-gdk.c.

References GHidPort::drawing_area, gport, GHidPort::height, MAX, MIN, GHidPort::width, window, x, and y.

Referenced by draw_crosshair().

static void draw_right_cross ( GdkGC *  xor_gc,
gint  x,
gint  y 
) [static]

Definition at line 974 of file gtkhid-gdk.c.

References GHidPort::drawing_area, gport, GHidPort::height, GHidPort::width, and window.

Referenced by draw_crosshair().

static void draw_slanted_cross ( GdkGC *  xor_gc,
gint  x,
gint  y 
) [static]

Definition at line 983 of file gtkhid-gdk.c.

References GHidPort::drawing_area, gport, GHidPort::height, MAX, MIN, GHidPort::width, window, x, and y.

Referenced by draw_crosshair().

void ghid_cancel_lead_user ( void  )
void ghid_destroy_gc ( hidGC  gc)

Definition at line 146 of file gtkhid-gdk.c.

Referenced by REGISTER_FLAGS().

void ghid_draw_arc ( hidGC  gc,
Coord  cx,
Coord  cy,
Coord  xradius,
Coord  yradius,
Angle  start_angle,
Angle  delta_angle 
)

Definition at line 578 of file gtkhid-gdk.c.

Referenced by REGISTER_FLAGS().

void ghid_draw_grid ( BoxType region)

Draw the grid on the 2D canvas.

Definition at line 186 of file gtkhid-gdk.c.

Referenced by REGISTER_FLAGS().

void ghid_draw_line ( hidGC  gc,
Coord  x1,
Coord  y1,
Coord  x2,
Coord  y2 
)

Definition at line 559 of file gtkhid-gdk.c.

Referenced by REGISTER_FLAGS().

void ghid_draw_rect ( hidGC  gc,
Coord  x1,
Coord  y1,
Coord  x2,
Coord  y2 
)

Definition at line 618 of file gtkhid-gdk.c.

Referenced by REGISTER_FLAGS().

void ghid_drawing_area_configure_hook ( GHidPort port)

Definition at line 1117 of file gtkhid-gdk.c.

Referenced by ghid_port_drawing_area_configure_event_cb().

gboolean ghid_drawing_area_expose_cb ( GtkWidget *  widget,
GdkEventExpose *  ev,
GHidPort port 
)

Definition at line 1156 of file gtkhid-gdk.c.

Referenced by ghid_build_pcb_top_window().

bool ghid_event_to_pcb_coords ( int  event_x,
int  event_y,
Coord pcb_x,
Coord pcb_y 
)

Definition at line 1313 of file gtkhid-gdk.c.

Referenced by ghid_note_event_location(), and ghid_set_crosshair().

void ghid_fill_circle ( hidGC  gc,
Coord  cx,
Coord  cy,
Coord  radius 
)

Definition at line 662 of file gtkhid-gdk.c.

Referenced by REGISTER_FLAGS().

void ghid_fill_polygon ( hidGC  gc,
int  n_coords,
Coord x,
Coord y 
)

Definition at line 682 of file gtkhid-gdk.c.

Referenced by REGISTER_FLAGS().

void ghid_fill_rect ( hidGC  gc,
Coord  x1,
Coord  y1,
Coord  x2,
Coord  y2 
)

Definition at line 704 of file gtkhid-gdk.c.

Referenced by REGISTER_FLAGS().

void ghid_finish_debug_draw ( void  )

Definition at line 1305 of file gtkhid-gdk.c.

Referenced by REGISTER_FLAGS().

void ghid_flush_debug_draw ( void  )

Definition at line 1298 of file gtkhid-gdk.c.

Referenced by ghid_finish_debug_draw(), and REGISTER_FLAGS().

void ghid_init_drawing_widget ( GtkWidget *  widget,
GHidPort port 
)

Definition at line 1112 of file gtkhid-gdk.c.

Referenced by ghid_build_pcb_top_window(), and ghid_pinout_preview_constructed().

void ghid_init_renderer ( int *  argc,
char ***  argv,
GHidPort port 
)

Definition at line 1093 of file gtkhid-gdk.c.

Referenced by ghid_parse_arguments().

void ghid_invalidate_lr ( Coord  left,
Coord  right,
Coord  top,
Coord  bottom 
)

Definition at line 864 of file gtkhid-gdk.c.

Referenced by REGISTER_FLAGS().

void ghid_lead_user_to_location ( Coord  x,
Coord  y 
)

Definition at line 1414 of file gtkhid-gdk.c.

Referenced by node_selection_changed_cb().

hidGC ghid_make_gc ( void  )

Definition at line 154 of file gtkhid-gdk.c.

Referenced by REGISTER_FLAGS().

void ghid_notify_crosshair_change ( bool  changes_complete)

Definition at line 898 of file gtkhid-gdk.c.

Referenced by REGISTER_FLAGS().

void ghid_notify_mark_change ( bool  changes_complete)

Definition at line 936 of file gtkhid-gdk.c.

Referenced by REGISTER_FLAGS().

bool ghid_pcb_to_event_coords ( Coord  pcb_x,
Coord  pcb_y,
int *  event_x,
int *  event_y 
)

Definition at line 1322 of file gtkhid-gdk.c.

Referenced by Center(), ghid_flip_view(), and ghid_set_crosshair().

gboolean ghid_pinout_preview_expose ( GtkWidget *  widget,
GdkEventExpose *  ev 
)

Definition at line 1176 of file gtkhid-gdk.c.

Referenced by ghid_pinout_preview_class_init().

void ghid_port_drawing_realize_cb ( GtkWidget *  widget,
gpointer  data 
)

Definition at line 1171 of file gtkhid-gdk.c.

Referenced by ghid_build_pcb_top_window().

GdkPixmap* ghid_render_pixmap ( int  cx,
int  cy,
double  zoom,
int  width,
int  height,
int  depth 
)

Definition at line 1235 of file gtkhid-gdk.c.

Referenced by ghid_violation_renderer_render().

HID_DRAW* ghid_request_debug_draw ( void  )

Definition at line 1290 of file gtkhid-gdk.c.

Referenced by REGISTER_FLAGS().

void ghid_screen_update ( void  )
void ghid_set_color ( hidGC  gc,
const char *  name 
)

Definition at line 411 of file gtkhid-gdk.c.

Referenced by ghid_set_draw_xor(), REGISTER_FLAGS(), and use_gc().

void ghid_set_draw_xor ( hidGC  gc,
int  xor_mask 
)

Definition at line 514 of file gtkhid-gdk.c.

Referenced by REGISTER_FLAGS(), and use_gc().

int ghid_set_layer ( const char *  name,
int  group,
int  empty 
)

Definition at line 101 of file gtkhid-gdk.c.

Referenced by REGISTER_FLAGS().

void ghid_set_line_cap ( hidGC  gc,
EndCapStyle  style 
)

Definition at line 478 of file gtkhid-gdk.c.

Referenced by REGISTER_FLAGS(), and use_gc().

void ghid_set_line_width ( hidGC  gc,
Coord  width 
)

Definition at line 502 of file gtkhid-gdk.c.

Referenced by REGISTER_FLAGS(), and use_gc().

void ghid_set_special_colors ( HID_Attribute ha)

Definition at line 386 of file gtkhid-gdk.c.

Referenced by config_color_defaults_cb(), config_color_set_cb(), and config_colors_read().

void ghid_shutdown_renderer ( GHidPort port)

Definition at line 1101 of file gtkhid-gdk.c.

Referenced by destroy_chart_cb().

void ghid_use_mask ( enum mask_mode  mode)

Definition at line 304 of file gtkhid-gdk.c.

Referenced by REGISTER_FLAGS().

gboolean lead_user_cb ( gpointer  data)
static void set_clip ( render_priv priv,
GdkGC *  gc 
) [static]

Set the drawing clip region.

The clip region restricts drawing. Anything outside the clip region cannot be changed.

Definition at line 171 of file gtkhid-gdk.c.

References render_priv::clip, and render_priv::clip_rect.

Referenced by draw_crosshair(), draw_lead_user(), ghid_draw_grid(), ghid_use_mask(), redraw_region(), and use_gc().

static void set_special_grid_color ( void  ) [static]

Variable Documentation

enum mask_mode cur_mask = HID_MASK_OFF [static]

Definition at line 57 of file gtkhid-gdk.c.

Referenced by ghid_use_mask().

Referenced by REGISTER_FLAGS().

int mask_seq = 0 [static]

Definition at line 58 of file gtkhid-gdk.c.

Referenced by ghid_use_mask(), and use_gc().