Index: trunk/doc-rnd/TODO =================================================================== --- trunk/doc-rnd/TODO (revision 1175) +++ trunk/doc-rnd/TODO (revision 1176) @@ -4,7 +4,8 @@ - test autorouter - test exporters - test gpmi search - - place 2 arcs, select first, can't move to left edge + - place 2 arcs, select first, can't move to left edge (bbox or rtree?) + - can't click into a text and get it selected (rtree?)?! - get rid of lists.h Index: trunk/src/Makefile.in =================================================================== --- trunk/src/Makefile.in (revision 1175) +++ trunk/src/Makefile.in (revision 1176) @@ -42,6 +42,7 @@ line.o list_arc.o list_line.o + list_text.o lrealpath.o main.o mirror.o Index: trunk/src/buffer.c =================================================================== --- trunk/src/buffer.c (revision 1175) +++ trunk/src/buffer.c (revision 1176) @@ -312,10 +312,8 @@ r_delete_entry(layer->text_tree, (BoxType *) text); RestoreToPolygon(Source, TEXT_TYPE, layer, text); - layer->Text = g_list_remove(layer->Text, text); - layer->TextN--; - lay->Text = g_list_append(lay->Text, text); - lay->TextN++; + textlist_remove(text); + textlist_append(&lay->Text, text); if (!lay->text_tree) lay->text_tree = r_create_tree(NULL, 0, 0); @@ -1060,7 +1058,7 @@ } for (i = 0; i < max_copper_layer + 2; i++) { LayerTypePtr layer = Buffer->Data->Layer + i; - if (layer->TextN) { + if (textlist_length(&layer->Text)) { Message(_("You can't mirror a buffer that has text!\n")); return; } Index: trunk/src/copy.c =================================================================== --- trunk/src/copy.c (revision 1175) +++ trunk/src/copy.c (revision 1176) @@ -303,8 +303,7 @@ LayerTypePtr sourcelayer = &PASTEBUFFER->Data->Layer[i], destlayer = LAYER_PTR(i); if (destlayer->On) { - changed = changed || - (linelist_length(&sourcelayer->Line) != 0) || (sourcelayer->ArcN != 0) || (sourcelayer->PolygonN != 0) || (sourcelayer->TextN != 0); + changed = changed || (!LAYER_IS_EMPTY(sourcelayer)); LINE_LOOP(sourcelayer); { CopyLine(destlayer, line); Index: trunk/src/file.c =================================================================== --- trunk/src/file.c (revision 1175) +++ trunk/src/file.c (revision 1176) @@ -760,9 +760,10 @@ gdl_iterator_t it; LineType *line; ArcType *arc; + TextType *text; /* write information about non empty layers */ - if (linelist_length(&layer->Line) || layer->ArcN || layer->TextN || layer->PolygonN || (layer->Name && *layer->Name)) { + if (!LAYER_IS_EMPTY(layer) || (layer->Name && *layer->Name)) { fprintf(FP, "Layer(%i ", (int) Number + 1); PrintQuotedString(FP, (char *) EMPTY(layer->Name)); fputs(")\n(\n", FP); @@ -773,13 +774,12 @@ line->Point1.X, line->Point1.Y, line->Point2.X, line->Point2.Y, line->Thickness, line->Clearance, F2S(line, LINE_TYPE)); } - linelist_foreach(&layer->Arc, &it, arc) { + arclist_foreach(&layer->Arc, &it, arc) { pcb_fprintf(FP, "\tArc[%mr %mr %mr %mr %mr %mr %ma %ma %s]\n", arc->X, arc->Y, arc->Width, arc->Height, arc->Thickness, arc->Clearance, arc->StartAngle, arc->Delta, F2S(arc, ARC_TYPE)); } - for (n = layer->Text; n != NULL; n = g_list_next(n)) { - TextType *text = n->data; + textlist_foreach(&layer->Text, &it, text) { pcb_fprintf(FP, "\tText[%mr %mr %d %d ", text->X, text->Y, text->Direction, text->Scale); PrintQuotedString(FP, (char *) EMPTY(text->TextString)); fprintf(FP, " %s]\n", F2S(text, TEXT_TYPE)); Index: trunk/src/find.c =================================================================== --- trunk/src/find.c (revision 1175) +++ trunk/src/find.c (revision 1176) @@ -623,9 +623,9 @@ LineList[i].Size = linelist_length(&layer->Line); LineList[i].Data = (void **) calloc(LineList[i].Size, sizeof(LineTypePtr)); } - if (layer->ArcN) { - ArcList[i].Data = (void **) calloc(layer->ArcN, sizeof(ArcTypePtr)); - ArcList[i].Size = layer->ArcN; + if (arclist_length(&layer->Arc)) { + ArcList[i].Size = arclist_length(&layer->Arc); + ArcList[i].Data = (void **) calloc(ArcList[i].Size, sizeof(ArcTypePtr)); } Index: trunk/src/global.h =================================================================== --- trunk/src/global.h (revision 1175) +++ trunk/src/global.h (revision 1176) @@ -63,6 +63,7 @@ #include "list_common.h" #include "list_line.h" #include "list_arc.h" +#include "list_text.h" #include "hid.h" #include "polyarea.h" @@ -196,11 +197,9 @@ typedef struct { /* holds information about one layer */ char *Name; /* layer name */ Cardinal /* number of... */ - TextN, /* labels */ - PolygonN, /* polygons */ - ArcN; /* and arcs */ + PolygonN; /* polygons */ linelist_t Line; - GList *Text; + textlist_t Text; GList *Polygon; arclist_t Arc; rtree_t *line_tree, *text_tree, *polygon_tree, *arc_tree; Index: trunk/src/global_objs.h =================================================================== --- trunk/src/global_objs.h (revision 1175) +++ trunk/src/global_objs.h (revision 1176) @@ -81,6 +81,7 @@ BYTE Direction; char *TextString; /* string */ void *Element; + gdl_elem_t link; /* a text is in a list of a layer or an element */ } TextType, *TextTypePtr; struct polygon_st { /* holds information about a polygon */ Index: trunk/src/hid/gcode/gcode.c =================================================================== --- trunk/src/hid/gcode/gcode.c (revision 1175) +++ trunk/src/hid/gcode/gcode.c (revision 1176) @@ -252,7 +252,7 @@ for (n = 0; n < max_copper_layer; n++) { layer = &PCB->Data->Layer[n]; - if (linelist_length(&layer->Line) || layer->TextN || layer->ArcN || layer->PolygonN) { + if (!LAYER_IS_EMPTY(layer)) { /* layer isn't empty */ /* Index: trunk/src/hid/gerber/gerber.c =================================================================== --- trunk/src/hid/gerber/gerber.c (revision 1175) +++ trunk/src/hid/gerber/gerber.c (revision 1176) @@ -557,7 +557,7 @@ hid_save_and_show_layer_ons(save_ons); for (i = 0; i < max_copper_layer; i++) { LayerType *layer = PCB->Data->Layer + i; - if (linelist_length(&layer->Line) || layer->TextN || layer->ArcN || layer->PolygonN) + if (!LAYER_IS_EMPTY(layer)) print_group[GetLayerGroupNumberByNumber(i)] = 1; } print_group[GetLayerGroupNumberByNumber(solder_silk_layer)] = 1; Index: trunk/src/hid/nelma/nelma.c =================================================================== --- trunk/src/hid/nelma/nelma.c (revision 1175) +++ trunk/src/hid/nelma/nelma.c (revision 1176) @@ -522,7 +522,7 @@ for (n = 0; n < max_copper_layer; n++) { layer = &PCB->Data->Layer[n]; - if (linelist_length(&layer->Line) || layer->TextN || layer->ArcN || layer->PolygonN) { + if (!LAYER_IS_EMPTY(layer)) { /* layer isn't empty */ /* Index: trunk/src/hid/png/png.c =================================================================== --- trunk/src/hid/png/png.c (revision 1175) +++ trunk/src/hid/png/png.c (revision 1176) @@ -440,7 +440,7 @@ for (i = 0; i < max_copper_layer; i++) { LayerType *layer = PCB->Data->Layer + i; - if (linelist_length(&layer->Line) || layer->TextN || layer->ArcN || layer->PolygonN) + if (!LAYER_IS_EMPTY(layer)) print_group[GetLayerGroupNumberByNumber(i)] = 1; } print_group[GetLayerGroupNumberByNumber(solder_silk_layer)] = 1; Index: trunk/src/hid/ps/eps.c =================================================================== --- trunk/src/hid/ps/eps.c (revision 1175) +++ trunk/src/hid/ps/eps.c (revision 1176) @@ -209,7 +209,7 @@ for (i = 0; i < max_copper_layer; i++) { LayerType *layer = PCB->Data->Layer + i; if (layer->On) - if (linelist_length(&layer->Line) || layer->TextN || layer->ArcN || layer->PolygonN) + if (!LAYER_IS_EMPTY(layer)) print_group[GetLayerGroupNumberByNumber(i)] = 1; } Index: trunk/src/hid/ps/ps.c =================================================================== --- trunk/src/hid/ps/ps.c (revision 1175) +++ trunk/src/hid/ps/ps.c (revision 1176) @@ -646,7 +646,7 @@ for (i = 0; i < max_copper_layer; i++) { LayerType *layer = PCB->Data->Layer + i; - if (linelist_length(&layer->Line) || layer->TextN || layer->ArcN || layer->PolygonN) + if (!LAYER_IS_EMPTY(layer)) global.print_group[GetLayerGroupNumberByNumber(i)] = 1; if (strcmp(layer->Name, "outline") == 0 || strcmp(layer->Name, "route") == 0) { Index: trunk/src/list_arc.h =================================================================== --- trunk/src/list_arc.h (revision 1175) +++ trunk/src/list_arc.h (revision 1176) @@ -23,7 +23,7 @@ #ifndef LIST_ARC_H #define LIST_ARC_H -/* List of Lines */ +/* List of Arcs */ #define TDL(x) arclist_ ## x #define TDL_LIST_T arclist_t #define TDL_ITEM_T ArcType Index: trunk/src/list_text.c =================================================================== --- trunk/src/list_text.c (nonexistent) +++ trunk/src/list_text.c (revision 1176) @@ -0,0 +1,26 @@ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 2016 Tibor 'Igor2' Palinkas + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#define TDL_DONT_UNDEF +#include "global_objs.h" +#include "list_text.h" +#include Index: trunk/src/list_text.h =================================================================== --- trunk/src/list_text.h (nonexistent) +++ trunk/src/list_text.h (revision 1176) @@ -0,0 +1,41 @@ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 2016 Tibor 'Igor2' Palinkas + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef LIST_TEXT_H +#define LIST_TEXT_H + +/* List of Text */ +#define TDL(x) textlist_ ## x +#define TDL_LIST_T textlist_t +#define TDL_ITEM_T TextType +#define TDL_FIELD link +#define TDL_SIZE_T size_t +#define TDL_FUNC + +#define textlist_foreach(list, iterator, loop_elem) \ + gdl_foreach_((&((list)->lst)), (iterator), (loop_elem)) + + +#include +#include + +#endif Index: trunk/src/macro.h =================================================================== --- trunk/src/macro.h (revision 1175) +++ trunk/src/macro.h (revision 1176) @@ -292,12 +292,9 @@ linelist_foreach(&(layer)->Line, &__it__, line) { #define TEXT_LOOP(layer) do { \ - GList *__iter, *__next; \ - Cardinal n = 0; \ - for (__iter = (layer)->Text, __next = g_list_next (__iter); \ - __iter != NULL; \ - __iter = __next, __next = g_list_next (__iter), n++) { \ - TextType *text = __iter->data; + TextType *text; \ + gdl_iterator_t __it__; \ + linelist_foreach(&(layer)->Text, &__it__, text) { #define POLYGON_LOOP(layer) do { \ GList *__iter, *__next; \ @@ -468,4 +465,7 @@ LayerTypePtr layer = (&data->Layer[(n)]); +#define LAYER_IS_EMPTY(layer) LAYER_IS_EMPTY_((layer)) +#define LAYER_IS_EMPTY_(layer) \ + ((linelist_length(&layer->Line) == 0) && (arclist_length(&layer->Arc) == 0) && (layer->PolygonN == 0) && (textlist_length(&layer->Text) == 0)) #endif Index: trunk/src/misc.c =================================================================== --- trunk/src/misc.c (revision 1175) +++ trunk/src/misc.c (revision 1176) @@ -584,8 +584,7 @@ hasNoObjects = (Data->ViaN == 0); hasNoObjects &= (Data->ElementN == 0); for (i = 0; i < max_copper_layer + 2; i++) - hasNoObjects = hasNoObjects && - linelist_length(&Data->Layer[i].Line) == 0 && Data->Layer[i].ArcN == 0 && Data->Layer[i].TextN == 0 && Data->Layer[i].PolygonN == 0; + hasNoObjects = hasNoObjects && LAYER_IS_EMPTY(&(Data->Layer[i])); return (hasNoObjects); } @@ -600,7 +599,7 @@ bool IsLayerEmpty(LayerTypePtr layer) { - return (linelist_length(&layer->Line) == 0 && layer->TextN == 0 && layer->PolygonN == 0 && layer->ArcN == 0); + return LAYER_IS_EMPTY(layer); } bool IsLayerNumEmpty(int num) Index: trunk/src/move.c =================================================================== --- trunk/src/move.c (revision 1175) +++ trunk/src/move.c (revision 1176) @@ -567,10 +567,8 @@ RestoreToPolygon(PCB->Data, TEXT_TYPE, Source, text); r_delete_entry(Source->text_tree, (BoxType *) text); - Source->Text = g_list_remove(Source->Text, text); - Source->TextN--; - Destination->Text = g_list_append(Destination->Text, text); - Destination->TextN++; + textlist_remove(text); + textlist_append(&Destination->Text, text); if (GetLayerGroupNumberByNumber(solder_silk_layer) == GetLayerGroupNumberByPointer(Destination)) SET_FLAG(ONSOLDERFLAG, text); Index: trunk/src/mymem.c =================================================================== --- trunk/src/mymem.c (revision 1175) +++ trunk/src/mymem.c (revision 1176) @@ -288,16 +288,16 @@ { TextType *new_obj; - new_obj = g_slice_new0(TextType); - layer->Text = g_list_append(layer->Text, new_obj); - layer->TextN++; + new_obj = calloc(sizeof(TextType), 1); + textlist_append(&layer->Text, new_obj); return new_obj; } -static void FreeText(TextType * data) +void RemoveFreeText(TextType * data) { - g_slice_free(TextType, data); + textlist_remove(data); + free(data); } /* --------------------------------------------------------------------------- @@ -664,7 +664,7 @@ list_map0(&layer->Line, LineType, RemoveFreeLine); list_map0(&layer->Arc, ArcType, RemoveFreeArc); - g_list_free_full(layer->Text, (GDestroyNotify) FreeText); + list_map0(&layer->Text, TextType, RemoveFreeText); POLYGON_LOOP(layer); { FreePolygonMemory(polygon); Index: trunk/src/mymem.h =================================================================== --- trunk/src/mymem.h (revision 1175) +++ trunk/src/mymem.h (revision 1176) @@ -95,8 +95,8 @@ void RemoveFreeArc(ArcType * data); void RemoveFreeLine(LineType * data); +void RemoveFreeText(TextType * data); - #ifdef NEED_STRDUP char *strdup(const char *); #endif Index: trunk/src/print.c =================================================================== --- trunk/src/print.c (revision 1175) +++ trunk/src/print.c (revision 1176) @@ -261,7 +261,7 @@ yoff = -TEXT_LINE; for (i = 0; i < max_copper_layer; i++) { LayerType *l = LAYER_PTR(i); - if (l->Name && (linelist_length(&l->Line) || l->ArcN)) { + if (l->Name && (linelist_length(&l->Line) || arclist_length(&l->Arc))) { if (strcmp("route", l->Name) == 0) break; if (strcmp("outline", l->Name) == 0) Index: trunk/src/remove.c =================================================================== --- trunk/src/remove.c (revision 1175) +++ trunk/src/remove.c (revision 1176) @@ -220,11 +220,8 @@ free(Text->TextString); r_delete_entry(Layer->text_tree, (BoxTypePtr) Text); - Layer->Text = g_list_remove(Layer->Text, Text); - Layer->TextN--; + RemoveFreeText(Text); - g_slice_free(TextType, Text); - return NULL; } Index: trunk/src_plugins/autoroute/autoroute.c =================================================================== --- trunk/src_plugins/autoroute/autoroute.c (revision 1175) +++ trunk/src_plugins/autoroute/autoroute.c (revision 1176) @@ -913,7 +913,7 @@ layergroupboxes[i].PtrMax = 0; GROUP_LOOP(PCB->Data, i); { - if (linelist_length(&layer->Line) || layer->ArcN) + if (linelist_length(&layer->Line) || arclist_length(&layer->Arc)) usedGroup[i] = true; else usedGroup[i] = false; Index: trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/layout/layers.c =================================================================== --- trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/layout/layers.c (revision 1175) +++ trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/layout/layers.c (revision 1176) @@ -65,9 +65,9 @@ layer_check(layer)(-1); switch(fld) { case LFLD_NUM_LINES: return linelist_length(&(PCB->Data->Layer[layer].Line)); - case LFLD_NUM_TEXTS: return PCB->Data->Layer[layer].TextN; + case LFLD_NUM_TEXTS: return textlist_length(&(PCB->Data->Layer[layer].Text)); case LFLD_NUM_POLYS: return PCB->Data->Layer[layer].PolygonN; - case LFLD_NUM_ARCS: return PCB->Data->Layer[layer].ArcN; + case LFLD_NUM_ARCS: return arclist_length(&(PCB->Data->Layer[layer].Arc)); case LFLD_VISIBLE: return PCB->Data->Layer[layer].On; case LFLD_NODRC: return PCB->Data->Layer[layer].no_drc; } Index: trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/layout/search.c =================================================================== --- trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/layout/search.c (revision 1175) +++ trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/layout/search.c (revision 1176) @@ -144,7 +144,7 @@ s->layer = l; select2(s, OM_ARC, flag, &layer->Arc); select2(s, OM_LINE, flag, &layer->Line); - select(s, OM_TEXT, flag, layer->Text); + select2(s, OM_TEXT, flag, &layer->Text); select(s, OM_POLYGON, flag, layer->Polygon); } select(s, OM_VIA, flag, PCB->Data->Via);