pcb 4.1.1
An interactive printed circuit board layout editor.
|
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"
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_DRAW * | ghid_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 |
Functions for drawing on the GTK 2D graphics canvas.
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 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 |
Definition at line 55 of file gtkhid-gdk.c.
Referenced by ghid_draw_arc(), ghid_draw_line(), ghid_draw_rect(), ghid_fill_circle(), ghid_fill_polygon(), and ghid_fill_rect().
Definition at line 301 of file gtkhid-gdk.c.
Referenced by ghid_set_line_cap(), ghid_set_line_width(), and use_gc().
typedef struct hid_gc_struct hid_gc_struct |
typedef struct render_priv render_priv |
static void draw_crosshair | ( | render_priv * | priv | ) | [static] |
Definition at line 1058 of file gtkhid-gdk.c.
References GhidGui::creating, SettingType::CrossColor, Crosshair, GHidPort::crosshair_x, GHidPort::crosshair_y, Dozen_Crosshair_Shape, draw_dozen_cross(), draw_right_cross(), draw_slanted_cross(), DRAW_X, DRAW_Y, GHidPort::drawing_area, ghid_map_color_string(), ghidgui, gport, GHidPort::has_entered, set_clip(), Settings, CrosshairType::shape, style, Union_Jack_Crosshair_Shape, window, x, and y.
Referenced by ghid_drawing_area_expose_cb(), and ghid_screen_update().
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_lead_user | ( | render_priv * | priv | ) | [static] |
Definition at line 1342 of file gtkhid-gdk.c.
References GHidPort::colormap, GHidPort::drawable, GHidPort::drawing_area, FALSE, gport, render_priv::lead_user, LEAD_USER_ARC_COUNT, LEAD_USER_ARC_SEPARATION, LEAD_USER_COLOR_B, LEAD_USER_COLOR_G, LEAD_USER_COLOR_R, LEAD_USER_INITIAL_RADIUS, render_priv::lead_user_radius, LEAD_USER_WIDTH, render_priv::lead_user_x, render_priv::lead_user_y, MM_TO_COORD, set_clip(), style, Vx(), Vy(), Vz(), and window.
Referenced by redraw_region().
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 | ) |
Definition at line 1429 of file gtkhid-gdk.c.
Referenced by ghid_lead_user_to_location(), ghid_shutdown_renderer(), netlist_close_cb(), and node_selection_changed_cb().
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().
static void ghid_draw_bg_image | ( | void | ) | [static] |
Definition at line 262 of file gtkhid-gdk.c.
References render_priv::bg_gc, GhidGui::bg_pixbuf, view_data::coord_per_px, GHidPort::drawable, ghidgui, gport, PCBType::MaxHeight, PCBType::MaxWidth, PCB, GHidPort::render_priv, GHidPort::view, x, view_data::x0, y, and view_data::y0.
Referenced by redraw_region().
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().
Definition at line 559 of file gtkhid-gdk.c.
Referenced by REGISTER_FLAGS().
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().
Definition at line 1313 of file gtkhid-gdk.c.
Referenced by ghid_note_event_location(), and ghid_set_crosshair().
Definition at line 662 of file gtkhid-gdk.c.
Referenced by REGISTER_FLAGS().
Definition at line 682 of file gtkhid-gdk.c.
Referenced by REGISTER_FLAGS().
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_all | ( | ) |
Definition at line 891 of file gtkhid-gdk.c.
Referenced by Benchmark(), config_color_defaults_cb(), config_color_load_cb(), config_color_set_cb(), config_layers_apply(), ghid_cancel_lead_user(), ghid_flip_view(), ghid_invalidate_lr(), ghid_menu_cb(), ghid_notify_crosshair_change(), ghid_notify_mark_change(), ghid_port_button_press_cb(), ghid_port_button_release_cb(), ghid_port_drawing_area_configure_event_cb(), ghid_port_key_release_cb(), ghid_port_ranges_changed(), ghid_port_rotate(), ghid_view_2d(), layer_selector_select_callback(), layer_selector_toggle_callback(), lead_user_cb(), node_selection_changed_cb(), and REGISTER_FLAGS().
Definition at line 864 of file gtkhid-gdk.c.
Referenced by REGISTER_FLAGS().
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().
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 | ) |
Definition at line 1142 of file gtkhid-gdk.c.
Referenced by ghid_flush_debug_draw(), ghid_invalidate_all(), ghid_invalidate_lr(), ghid_port_window_enter_cb(), and ghid_port_window_leave_cb().
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().
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 | ) |
Definition at line 1391 of file gtkhid-gdk.c.
References ghid_invalidate_all(), LEAD_USER_INITIAL_RADIUS, render_priv::lead_user_radius, render_priv::lead_user_timer, LEAD_USER_VELOCITY, MM_TO_COORD, and TRUE.
Referenced by ghid_lead_user_to_location().
static void redraw_region | ( | GdkRectangle * | rect | ) | [static] |
Redraw a region of the pcb workspace.
Definition at line 748 of file gtkhid-gdk.c.
References render_priv::attached_invalidate_depth, render_priv::bg_gc, render_priv::clip, render_priv::clip_rect, render_priv::crosshair_gc, hid_draw_st::draw_grid, draw_lead_user(), GHidPort::drawable, DrawAttached(), DrawMark(), ghid_draw_bg_image(), gport, render_priv::grid_gc, GHidPort::height, hid_expose_callback(), render_priv::mark_invalidate_depth, render_priv::mask_gc, MAX, PCBType::MaxHeight, PCBType::MaxWidth, MIN, render_priv::offlimits_gc, PCB, GHidPort::pixmap, Px(), Py(), region, GHidPort::render_priv, set_clip(), Vx(), Vy(), GHidPort::width, BoxType::X1, BoxType::X2, BoxType::Y1, and BoxType::Y2.
Referenced by ghid_invalidate_all(), and ghid_invalidate_lr().
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] |
Definition at line 371 of file gtkhid-gdk.c.
References GHidPort::bg_color, GHidPort::colormap, gport, GHidPort::grid_color, render_priv::grid_gc, and GHidPort::render_priv.
Referenced by ghid_set_special_colors().
static int use_gc | ( | hidGC | gc | ) | [static] |
Definition at line 524 of file gtkhid-gdk.c.
References hid_gc_struct::cap, hid_gc_struct::colorname, hid_gc_struct::gc, ghid_set_color(), ghid_set_draw_xor(), ghid_set_line_cap(), ghid_set_line_width(), gport, GHidPort::mask, mask_seq, hid_gc_struct::mask_seq, hid_gc_struct::me_pointer, GHidPort::pixmap, GHidPort::render_priv, set_clip(), GHidPort::top_window, render_priv::u_gc, WHICH_GC, hid_gc_struct::width, window, and hid_gc_struct::xor_mask.
Definition at line 57 of file gtkhid-gdk.c.
Referenced by ghid_use_mask().
Referenced by REGISTER_FLAGS().
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().