Commit 84a02963 authored by David Odin's avatar David Odin
Browse files

plug-ins/gfig/gfig-arc.c plug-ins/gfig/gfig-bezier.c

* plug-ins/gfig/gfig-arc.c
* plug-ins/gfig/gfig-bezier.c
* plug-ins/gfig/gfig-bezier.h
* plug-ins/gfig/gfig-dialog.c
* plug-ins/gfig/gfig-dialog.h
* plug-ins/gfig/gfig-dobject.c
* plug-ins/gfig/gfig-dobject.h
* plug-ins/gfig/gfig-ellipse.c
* plug-ins/gfig/gfig-grid.c
* plug-ins/gfig/gfig-grid.h
* plug-ins/gfig/gfig.c: small cleanups
parent 4877fdec
2004-10-28 DindinX <dindinx@gimp.org>
* plug-ins/gfig/gfig-arc.c
* plug-ins/gfig/gfig-bezier.c
* plug-ins/gfig/gfig-bezier.h
* plug-ins/gfig/gfig-dialog.c
* plug-ins/gfig/gfig-dialog.h
* plug-ins/gfig/gfig-dobject.c
* plug-ins/gfig/gfig-dobject.h
* plug-ins/gfig/gfig-ellipse.c
* plug-ins/gfig/gfig-grid.c
* plug-ins/gfig/gfig-grid.h
* plug-ins/gfig/gfig.c: small cleanups
2004-10-28 Sven Neumann <sven@gimp.org>
 
* libgimp/gimpdrawablecombobox.c
......
......@@ -40,7 +40,7 @@
#include "libgimp/stdplugins-intl.h"
/* Distance between two lines */
/* Distance between two points. */
static gdouble
dist (gdouble x1,
gdouble y1,
......@@ -117,7 +117,7 @@ line_definition (gdouble x1,
/* Invert grad for perpen gradient */
*lgrad = -1.0/grad1;
*lgrad = -1.0 / grad1;
*lconst = line_cons (midx, midy,*lgrad);
}
......@@ -145,8 +145,8 @@ arc_details (GdkPoint *vert_a,
double circumcircle_R;
double line1_grad, line1_const;
double line2_grad, line2_const;
double inter_x=0.0, inter_y=0.0;
int got_x=0, got_y=0;
double inter_x = 0.0, inter_y = 0.0;
int got_x = 0, got_y = 0;
ax = (double) (vert_a->x);
ay = (double) (vert_a->y);
......@@ -297,16 +297,16 @@ arc_angle (GdkPoint *pnt,
GdkPoint *center)
{
/* Get angle (in degress) of point given origin of center */
gint16 shift_x;
gint16 shift_y;
gint16 shift_x;
gint16 shift_y;
gdouble offset_angle;
shift_x = pnt->x - center->x;
shift_x = pnt->x - center->x;
shift_y = -pnt->y + center->y;
offset_angle = atan2 (shift_y, shift_x);
if (offset_angle < 0)
offset_angle += 2*G_PI;
offset_angle += 2.0 * G_PI;
return offset_angle * 360 / (2*G_PI);
}
......@@ -320,12 +320,12 @@ arc_drawing_details (Dobject *obj,
gint draw_cnts,
gint do_scale)
{
DobjPoints * pnt1 = NULL;
DobjPoints * pnt2 = NULL;
DobjPoints * pnt3 = NULL;
DobjPoints dpnts[3];
gdouble ang1, ang2, ang3;
gdouble maxang;
DobjPoints *pnt1 = NULL;
DobjPoints *pnt2 = NULL;
DobjPoints *pnt3 = NULL;
DobjPoints dpnts[3];
gdouble ang1, ang2, ang3;
gdouble maxang;
pnt1 = obj->points;
......@@ -406,15 +406,15 @@ static void
d_draw_arc (Dobject * obj)
{
GdkPoint center_pnt;
gdouble radius, minang, arcang;
gdouble radius, minang, arcang;
g_assert (obj != NULL);
if (!obj)
return;
arc_drawing_details (obj, &minang, &center_pnt, &arcang, &radius, TRUE,
FALSE);
arc_drawing_details (obj, &minang, &center_pnt, &arcang, &radius,
TRUE, FALSE);
gfig_draw_arc (center_pnt.x, center_pnt.y, radius, radius, minang, arcang);
}
......@@ -424,16 +424,16 @@ d_paint_arc (Dobject *obj)
/* first point center */
/* Next point is radius */
gdouble *line_pnts;
gint seg_count = 0;
gint i = 0;
gdouble ang_grid;
gdouble ang_loop;
gdouble radius;
gint loop;
gint seg_count = 0;
gint i = 0;
gdouble ang_grid;
gdouble ang_loop;
gdouble radius;
gint loop;
GdkPoint first_pnt, last_pnt;
gboolean first = TRUE;
GdkPoint center_pnt;
gdouble minang, arcang;
gdouble minang, arcang;
g_assert (obj != NULL);
......@@ -449,7 +449,7 @@ d_paint_arc (Dobject *obj)
line_pnts = g_new0 (gdouble, 2 * seg_count + 3);
/* Lines */
ang_grid = 2*G_PI/(gdouble)360;
ang_grid = 2.0 * G_PI / 360.0;
if (arcang < 0.0)
{
......@@ -458,16 +458,16 @@ d_paint_arc (Dobject *obj)
arcang = -arcang;
}
minang = minang * (2*G_PI/360); /* min ang is in degrees - need in rads*/
minang = minang * (2.0 * G_PI / 360.0); /* min ang is in degrees - need in rads*/
for (loop = 0 ; loop < abs ((gint)arcang) ; loop++)
{
gdouble lx, ly;
gdouble lx, ly;
GdkPoint calc_pnt;
ang_loop = (gdouble)loop * ang_grid + minang;
lx = radius * cos (ang_loop);
lx = radius * cos (ang_loop);
ly = -radius * sin (ang_loop); /* y grows down screen and angs measured from x clockwise */
calc_pnt.x = RINT (lx + center_pnt.x);
......@@ -525,7 +525,7 @@ d_paint_arc (Dobject *obj)
}
static Dobject *
d_copy_arc (Dobject * obj)
d_copy_arc (Dobject *obj)
{
Dobject *nc;
......@@ -552,9 +552,9 @@ d_arc_object_class_init ()
void
d_update_arc (GdkPoint *pnt)
{
DobjPoints * pnt1 = NULL;
DobjPoints * pnt2 = NULL;
DobjPoints * pnt3 = NULL;
DobjPoints *pnt1 = NULL;
DobjPoints *pnt2 = NULL;
DobjPoints *pnt3 = NULL;
/* First two points as line only become arch when third
* point is placed on canvas.
......@@ -562,9 +562,9 @@ d_update_arc (GdkPoint *pnt)
pnt1 = obj_creating->points;
if (!pnt1 ||
!(pnt2 = pnt1->next) ||
!(pnt3 = pnt2->next))
if (!pnt1 ||
!(pnt2 = pnt1->next) ||
!(pnt3 = pnt2->next))
{
d_update_line (pnt);
return; /* Not fully drawn */
......@@ -588,13 +588,12 @@ void
d_arc_end (GdkPoint *pnt,
gint shift_down)
{
/* Under contrl point */
if (!tmp_line ||
!tmp_line->points ||
!tmp_line->points->next)
/* Under control point */
if (!tmp_line ||
!tmp_line->points ||
!tmp_line->points->next)
{
/* No arc created - yet. Must have three points */
d_line_end (pnt, TRUE);
}
else
......
......@@ -50,8 +50,8 @@ static Dobject * d_copy_bezier (Dobject * obj);
#define FP_PNT_MAX 10
static int fp_pnt_cnt = 0;
static int fp_pnt_chunk = 0;
static int fp_pnt_cnt = 0;
static int fp_pnt_chunk = 0;
static gdouble *fp_pnt_pnts = NULL;
static void
......@@ -177,10 +177,10 @@ DrawBezier (gdouble (*points)[2],
void
d_draw_bezier (Dobject *obj)
{
DobjPoints * spnt;
gint seg_count = 0;
gint i = 0;
gdouble (*line_pnts)[2];
DobjPoints *spnt;
gint seg_count = 0;
gint i = 0;
gdouble (*line_pnts)[2];
spnt = obj->points;
......@@ -198,7 +198,8 @@ d_draw_bezier (Dobject *obj)
{
draw_sqr (&spnt->pnt);
line_pnts[i][0] = spnt->pnt.x;
line_pnts[i++][1] = spnt->pnt.y;
line_pnts[i][1] = spnt->pnt.y;
i++;
}
/* Generate an array of doubles which are the control points */
......@@ -221,11 +222,11 @@ d_draw_bezier (Dobject *obj)
static void
d_paint_bezier (Dobject *obj)
{
gdouble *line_pnts;
gdouble (*bz_line_pnts)[2];
gdouble *line_pnts;
gdouble (*bz_line_pnts)[2];
DobjPoints *spnt;
gint seg_count = 0;
gint i = 0;
gint seg_count = 0;
gint i = 0;
/* First count the number of points */
for (spnt = obj->points; spnt; spnt = spnt->next)
......@@ -240,7 +241,8 @@ d_paint_bezier (Dobject *obj)
for (spnt = obj->points; spnt; spnt = spnt->next)
{
bz_line_pnts[i][0] = spnt->pnt.x;
bz_line_pnts[i++][1] = spnt->pnt.y;
bz_line_pnts[i][1] = spnt->pnt.y;
i++;
}
fp_pnt_start ();
......@@ -308,7 +310,7 @@ void
d_update_bezier (GdkPoint *pnt)
{
DobjPoints *s_pnt, *l_pnt;
gint saved_cnt_pnt = selvals.opts.showcontrol;
gint saved_cnt_pnt = selvals.opts.showcontrol;
g_assert (tmp_bezier != NULL);
......@@ -464,8 +466,8 @@ tool_options_bezier (GtkWidget *notebook,
G_CALLBACK (gimp_toggle_button_update),
&bezier_line_frame);
gimp_help_set_help_data (toggle,
_("Draws lines between the control points. "
"Only during curve creation"), NULL);
_("Draws lines between the control points. "
"Only during curve creation"), NULL);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), bezier_line_frame);
gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
gtk_widget_show (toggle);
......
......@@ -28,7 +28,7 @@
extern Dobject *tmp_bezier;
void d_draw_bezier (Dobject *obj);
void d_draw_bezier (Dobject *obj);
void d_update_bezier (GdkPoint *pnt);
void d_bezier_start (GdkPoint *pnt,
......
......@@ -860,6 +860,7 @@ static GtkWidget *
draw_buttons (GtkWidget *ww)
{
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *button;
GtkWidget *frame;
GtkWidget *image;
......@@ -872,9 +873,13 @@ draw_buttons (GtkWidget *ww)
vbox = gtk_vbox_new (FALSE, 12);
gtk_widget_show (vbox);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
/* Create group */
frame = gimp_frame_new ("Toolbox");
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
table = gtk_table_new (9, 4, FALSE);
......@@ -1632,7 +1637,7 @@ but_with_pix (const gchar *stock_id,
G_CALLBACK (toggle_obj_type),
GINT_TO_POINTER (baction));
gtk_widget_show (button);
*group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
return button;
......@@ -1760,9 +1765,11 @@ gridtype_combo_callback (GtkWidget *widget,
case GRID_TYPE_MENU:
selvals.opts.gridtype = value;
break;
case GRID_RENDER_MENU:
grid_gc_type = value;
break;
default:
g_return_if_reached ();
break;
......@@ -1771,8 +1778,6 @@ gridtype_combo_callback (GtkWidget *widget,
draw_grid_clear ();
}
/*
* The edit gfig name attributes dialog
* Modified from Gimp source - layer edit.
......@@ -1837,15 +1842,19 @@ paint_layer_fill (void)
{
case FILL_NONE:
return;
case FILL_FOREGROUND:
fill_mode = GIMP_FG_BUCKET_FILL;
break;
case FILL_BACKGROUND:
fill_mode = GIMP_BG_BUCKET_FILL;
break;
case FILL_PATTERN:
fill_mode = GIMP_PATTERN_BUCKET_FILL;
break;
default:
return;
}
......@@ -1868,7 +1877,7 @@ gfig_paint_callback (void)
gchar buf[128];
gint count;
gint ccount = 0;
Style *style0;
Style *style0;
if (!gfig_context->enable_repaint || !gfig_context->current_obj)
return;
......@@ -1925,8 +1934,8 @@ draw_sqr (GdkPoint *p)
gdk_draw_rectangle (gfig_context->preview->window,
gfig_gc,
0,
gfig_scale_x (p->x) - SQ_SIZE/2,
gfig_scale_y (p->y) - SQ_SIZE/2,
gfig_scale_x (p->x) - SQ_SIZE / 2,
gfig_scale_y (p->y) - SQ_SIZE / 2,
SQ_SIZE,
SQ_SIZE);
}
......
......@@ -31,13 +31,13 @@
#define RESPONSE_SAVE 3
#define RESPONSE_PAINT 4
gint gfig_dialog (void);
void update_options (GFigObj *old_obj);
gint undo_water_mark; /* Last slot filled in -1 = no undo */
DAllObjs *undo_table[MAX_UNDO];
gint undo_water_mark; /* Last slot filled in -1 = no undo */
DAllObjs *undo_table[MAX_UNDO];
gint gfig_dialog (void);
void update_options (GFigObj *old_obj);
void tool_option_page_update (GtkWidget *button,
GtkWidget *notebook);
void tool_option_page_update (GtkWidget *button,
GtkWidget *notebook);
#endif /* __GFIG_DIALOG_H__ */
......@@ -54,16 +54,16 @@
static Dobject *operation_obj;
static GdkPoint *move_all_pnt; /* Point moving all from */
static void draw_one_obj (Dobject *obj);
static void do_move_obj (Dobject *obj,
GdkPoint *to_pnt);
static void do_move_all_obj (GdkPoint *to_pnt);
static void do_move_obj_pnt (Dobject *obj,
GdkPoint *to_pnt);
static void remove_obj_from_list (GFigObj *obj,
Dobject *del_obj);
static gint scan_obj_points (DobjPoints *opnt,
GdkPoint *pnt);
static void draw_one_obj (Dobject *obj);
static void do_move_obj (Dobject *obj,
GdkPoint *to_pnt);
static void do_move_all_obj (GdkPoint *to_pnt);
static void do_move_obj_pnt (Dobject *obj,
GdkPoint *to_pnt);
static void remove_obj_from_list (GFigObj *obj,
Dobject *del_obj);
static gint scan_obj_points (DobjPoints *opnt,
GdkPoint *pnt);
void
d_save_object (Dobject *obj,
......@@ -90,7 +90,8 @@ gfig_read_object_type (gchar *desc)
{
gchar *ptr = desc;
DobjType type;
if (* ptr != '<')
if (*ptr != '<')
return OBJ_TYPE_NONE;
ptr++;
......@@ -108,11 +109,11 @@ Dobject *
d_load_object (gchar *desc,
FILE *fp)
{
Dobject *new_obj = NULL;
gint xpnt;
gint ypnt;
gchar buf[MAX_LOAD_LINE];
DobjType type;
Dobject *new_obj = NULL;
gint xpnt;
gint ypnt;
gchar buf[MAX_LOAD_LINE];
DobjType type;
type = gfig_read_object_type (desc);
if (type == OBJ_TYPE_NONE)
......@@ -289,8 +290,8 @@ inside_sqr (GdkPoint *cpnt,
GdkPoint *testpnt)
{
/* Return TRUE if testpnt is near cpnt */
gint x = cpnt->x;
gint y = cpnt->y;
gint x = cpnt->x;
gint y = cpnt->y;
gint tx = testpnt->x;
gint ty = testpnt->y;
......
......@@ -25,25 +25,25 @@
#ifndef __GFIG_DOBJECT_H__
#define __GFIG_DOBJECT_H__
Dobject *d_load_object (gchar *desc,
FILE *fp);
Dobject *d_load_object (gchar *desc,
FILE *fp);
Dobject *d_new_object (DobjType type,
gint x,
gint y);
Dobject *d_new_object (DobjType type,
gint x,
gint y);
void d_save_object (Dobject *obj,
GString *string);
void d_save_object (Dobject *obj,
GString *string);
void free_all_objs (DAllObjs *objs);
void free_all_objs (DAllObjs *objs);
void clear_undo (void);
void clear_undo (void);
void new_obj_2edit (GFigObj *obj);
void new_obj_2edit (GFigObj *obj);
gint gfig_obj_counts (DAllObjs *objs);
gint gfig_obj_counts (DAllObjs *objs);
void gfig_init_object_classes (void);
void gfig_init_object_classes (void);
#endif /* __GFIG_DOBJECT_H__ */
......
......@@ -46,10 +46,10 @@ d_draw_ellipse (Dobject * obj)
{
DobjPoints *center_pnt;
DobjPoints *edge_pnt;
gint bound_wx;
gint bound_wy;
gint top_x;
gint top_y;
gint bound_wx;
gint bound_wy;
gint top_x;
gint top_y;
center_pnt = obj->points;
......@@ -87,19 +87,19 @@ d_paint_approx_ellipse (Dobject *obj)
{
/* first point center */
/* Next point is radius */
gdouble *line_pnts;
gint seg_count = 0;
gint i = 0;
DobjPoints * center_pnt;
DobjPoints * radius_pnt;
gdouble a_axis;
gdouble b_axis;
gdouble ang_grid;
gdouble ang_loop;
gdouble radius;
gint loop;
GdkPoint first_pnt, last_pnt;
gboolean first = TRUE;
gdouble *line_pnts;
gint seg_count = 0;
gint i = 0;
DobjPoints *center_pnt;
DobjPoints *radius_pnt;
gdouble a_axis;
gdouble b_axis;
gdouble ang_grid;
gdouble ang_loop;
gdouble radius;
gint loop;
GdkPoint first_pnt, last_pnt;
gboolean first = TRUE;
g_assert (obj != NULL);
......@@ -199,13 +199,13 @@ d_paint_approx_ellipse (Dobject *obj)
static void
d_paint_ellipse (Dobject *obj)
{
DobjPoints * center_pnt;
DobjPoints * edge_pnt;
gint bound_wx;
gint bound_wy;
gint top_x;
gint top_y;
gdouble dpnts[4];
DobjPoints *center_pnt;
DobjPoints *edge_pnt;
gint bound_wx;
gint bound_wy;
gint top_x;
gint top_y;
gdouble dpnts[4];
/* Drawing ellipse is hard .
* 1) select circle
......@@ -298,10 +298,10 @@ void
d_update_ellipse (GdkPoint *pnt)
{
DobjPoints *center_pnt, *edge_pnt;
gint bound_wx;
gint bound_wy;
gint top_x;
gint top_y;
gint bound_wx;
gint bound_wy;
gint top_x;
gint top_y;
/* Undraw last one then draw new one */
center_pnt = obj_creating->points;
......@@ -312,16 +312,16 @@ d_update_ellipse (GdkPoint *pnt)
if ((edge_pnt = center_pnt->next))
{
/* Undraw current */
bound_wx = abs (center_pnt->pnt.x - edge_pnt->pnt.x)*2;
bound_wy = abs (center_pnt->pnt.y - edge_pnt->pnt.y)*2;
bound_wx = abs (center_pnt->pnt.x - edge_pnt->pnt.x) * 2;
bound_wy = abs (center_pnt->pnt.y - edge_pnt->pnt.y) * 2;
if (edge_pnt->pnt.x > center_pnt->pnt.x)
top_x = 2*center_pnt->pnt.x - edge_pnt->pnt.x;
top_x = 2 * center_pnt->pnt.x - edge_pnt->pnt.x;
else
top_x = edge_pnt->pnt.x;
if (edge_pnt->pnt.y > center_pnt->pnt.y)
top_y = 2*center_pnt->pnt.y - edge_pnt->pnt.y;
top_y = 2 * center_pnt->pnt.y - edge_pnt->pnt.y;
else
top_y = edge_pnt->pnt.y;
......@@ -335,23 +335,23 @@ d_update_ellipse (GdkPoint *pnt)