Changeset 5514


Ignore:
Timestamp:
08/21/09 20:20:37 (4 years ago)
Author:
werner
Message:
  • measurement offsets can now use variables. We evaluate the offset during instantiation and create a partially formed instance. During measurement instantiation, we complete that instance.
  • leak.supp: finally figured out how to write a valgrind suppression file
  • fped.c: we don't need the FPED_NO_GUI kludge anymore
  • fped.c: moved gui_cleanup_style to gui_main
  • dereference icons (seems that this doesn't deallocate everything, though)
Location:
trunk/eda/fped
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/eda/fped/TODO

    r5487 r5514  
    3535- can't edit measurement labels through the GUI 
    3636- r of rpads is misleading, particularly if we have a circle 
    37 - using variables in a measurement offset causes a crash because evaluation 
    38   takes place after all table entries have been visited 
    3937 
    4038Code cleanup: 
  • trunk/eda/fped/fped.c

    r5506 r5514  
    5757        int batch_write_kicad = 0, batch_write_ps = 0; 
    5858        int c; 
    59         int have_gui = !getenv("FPED_NO_GUI"); 
    6059 
    61         if (have_gui) { 
    62                 error = gui_init(&argc, &argv); 
    63                 if (error) 
    64                         return error; 
    65         } 
     60        error = gui_init(&argc, &argv); 
     61        if (error) 
     62                return error; 
    6663 
    6764        while ((c = getopt(argc, argv, "kp")) != EOF) 
     
    107104        if (batch_write_ps) 
    108105                write_ps(); 
    109         if (have_gui && !batch_write_kicad && !batch_write_ps) { 
     106        if (!batch_write_kicad && !batch_write_ps) { 
    110107                error = gui_main(); 
    111108                if (error) 
  • trunk/eda/fped/gui.c

    r5462 r5514  
    140140 
    141141 
     142static void cleanup_tool_bar(void) 
     143{ 
     144        g_object_unref(stuff_image[0]); 
     145        g_object_unref(stuff_image[1]); 
     146        g_object_unref(meas_image[0]); 
     147        g_object_unref(meas_image[1]); 
     148} 
     149 
     150 
    142151static void make_top_bar(GtkWidget *vbox) 
    143152{ 
     
    249258        gtk_main(); 
    250259 
     260        gui_cleanup_style(); 
     261        gui_cleanup_tools(); 
     262        cleanup_tool_bar(); 
     263 
    251264        return 0; 
    252265} 
  • trunk/eda/fped/gui_style.c

    r5487 r5514  
    7575        item_list_font = pango_font_description_from_string(ITEM_LIST_FONT); 
    7676} 
     77 
     78 
     79void gui_cleanup_style(void) 
     80{ 
     81        pango_font_description_free(item_list_font); 
     82} 
  • trunk/eda/fped/gui_style.h

    r5461 r5514  
    116116 
    117117void gui_setup_style(GdkDrawable *drawable); 
     118void gui_cleanup_style(void); 
    118119 
    119120#endif /* !GUI_STYLE_H */ 
  • trunk/eda/fped/gui_tool.c

    r5480 r5514  
    10451045        return bar; 
    10461046} 
     1047 
     1048 
     1049void gui_cleanup_tools(void) 
     1050{ 
     1051        g_object_unref(frame_image); 
     1052        g_object_unref(frame_image_locked); 
     1053        g_object_unref(frame_image_ready); 
     1054        g_object_unref(delete_image[0]); 
     1055        g_object_unref(delete_image[1]); 
     1056} 
  • trunk/eda/fped/gui_tool.h

    r5440 r5514  
    7878 
    7979GtkWidget *gui_setup_tools(GdkDrawable *drawable); 
     80void gui_cleanup_tools(void); 
    8081 
    8182#endif /* !GUI_TOOL_H */ 
  • trunk/eda/fped/inst.c

    r5506 r5514  
    804804 
    805805 
    806 int inst_meas(struct obj *obj, 
    807     struct coord from, struct coord to, unit_type offset) 
     806static struct inst *find_meas_hint(const struct obj *obj) 
     807{ 
     808        struct inst *inst; 
     809 
     810        for (inst = curr_pkg->insts[ip_meas]; inst; inst = inst->next) 
     811                if (inst->obj == obj) 
     812                        break; 
     813        return inst; 
     814} 
     815 
     816 
     817int inst_meas(struct obj *obj, struct coord from, struct coord to) 
    808818{ 
    809819        struct inst *inst; 
    810820        struct coord a1, b1; 
    811821 
    812         inst = add_inst(&meas_ops, ip_meas, from); 
    813         inst->obj = obj; 
     822        inst = find_meas_hint(obj); 
     823        assert(inst); 
     824        inst->base = from; 
    814825        inst->u.meas.end = to; 
    815         inst->u.meas.offset = offset; 
    816         inst->active = 1; /* measurements are always active */ 
    817826        /* @@@ we still need to consider the text size as well */ 
     827        update_bbox(&inst->bbox, from); 
    818828        update_bbox(&inst->bbox, to); 
    819829        project_meas(inst, &a1, &b1); 
     
    822832        propagate_bbox(inst); 
    823833        return 1; 
     834} 
     835 
     836 
     837void inst_meas_hint(struct obj *obj, unit_type offset) 
     838{ 
     839        static const struct coord zero = { 0, 0 }; 
     840        struct inst *inst; 
     841 
     842        inst = find_meas_hint(obj); 
     843        if (inst) 
     844                return; 
     845        inst = add_inst(&meas_ops, ip_meas, zero); 
     846        inst->obj = obj; 
     847        inst->u.meas.offset = offset; 
     848        inst->active = 1; /* measurements are always active */ 
    824849} 
    825850 
  • trunk/eda/fped/inst.h

    r5506 r5514  
    165165int inst_arc(struct obj *obj, struct coord center, struct coord start, 
    166166    struct coord stop, unit_type width); 
    167 int inst_meas(struct obj *obj, struct coord from, struct coord to, 
    168     unit_type offset); 
     167int inst_meas(struct obj *obj, struct coord from, struct coord to); 
     168void inst_meas_hint(struct obj *obj, unit_type offset); 
    169169 
    170170void inst_begin_active(int active); 
  • trunk/eda/fped/leakcheck

    r5506 r5514  
    11#!/bin/sh 
    2 #valgrind --leak-check=full --show-reachable=yes --suppressions=leak.supp \ 
    3 #  ./fped "$@" 
    4  
    5 # 
    6 # Seems that we can't suppress warnings from gtk_init, so we use FPED_NO_GUI 
    7 # to avoid bringing up Gtk+ at all. 
    8 # 
    9 FPED_NO_GUI=y valgrind --leak-check=full --show-reachable=yes \ 
     2valgrind --leak-check=full --show-reachable=yes --num-callers=50 \ 
     3  --suppressions=leak.supp \ 
    104  ./fped "$@" 
    11  
    12 #valgrind --leak-check=full --show-reachable=no \ 
    13 #  ./fped "$@" 
  • trunk/eda/fped/meas.c

    r5480 r5514  
    232232        struct coord a0, b0; 
    233233        lt_op_type lt; 
    234         struct num offset; 
    235234 
    236235        for (obj = root_frame->objs; obj; obj = obj->next) { 
     
    251250                            curr_pkg->samples[meas->high->n]); 
    252251 
    253                 if (!meas->offset) 
    254                         offset.n = 0; 
    255                 else { 
    256                         offset = eval_unit(meas->offset, root_frame); 
    257                         if (is_undef(offset)) { 
    258                                 instantiation_error = obj; 
    259                                 return 0; 
    260                         } 
    261                 } 
    262252                inst_meas(obj, 
    263                     meas->inverted ? b0 : a0, meas->inverted ? a0 : b0, 
    264                     offset.n); 
     253                    meas->inverted ? b0 : a0, meas->inverted ? a0 : b0); 
    265254        } 
    266255        return 1; 
  • trunk/eda/fped/obj.c

    r5506 r5514  
    9595static int generate_objs(struct frame *frame, struct coord base, int active) 
    9696{ 
     97        static const struct num zero_offset = { 
     98                .type = nt_mm, 
     99                .exponent = 0, 
     100                .n = 0, 
     101        }; 
    97102        struct obj *obj; 
    98103        char *name; 
    99104        int ok; 
    100         struct num width; 
     105        struct num width, offset; 
    101106 
    102107        for (obj = frame->objs; obj; obj = obj->next) 
     
    151156                        break; 
    152157                case ot_meas: 
     158                        assert(frame == root_frame); 
     159                        offset = eval_unit_default(obj->u.meas.offset, frame, 
     160                            zero_offset); 
     161                        if (is_undef(offset)) 
     162                                goto error; 
     163                        inst_meas_hint(obj, offset.n); 
    153164                        break; 
    154165                default: 
Note: See TracChangeset for help on using the changeset viewer.