/* --------------------------------------------------------------------------- * moves a text object between layers; lowlevel routines */ static void * MoveTextToLayerLowLevel (LayerType *Source, TextType *text, LayerType *Destination) { 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 ++; if (GetLayerGroupNumberByNumber (solder_silk_layer) == GetLayerGroupNumberByPointer (Destination)) SET_FLAG (ONSOLDERFLAG, text); else CLEAR_FLAG (ONSOLDERFLAG, text); /* re-calculate the bounding box (it could be mirrored now) */ SetTextBoundingBox (&PCB->Font, text); if (!Destination->text_tree) Destination->text_tree = r_create_tree (NULL, 0, 0); r_insert_entry (Destination->text_tree, (BoxType *)text, 0); ClearFromPolygon (PCB->Data, TEXT_TYPE, Destination, text); return text; }
/* --------------------------------------------------------------------------- * creates a new text on a layer */ TextTypePtr CreateNewText (LayerTypePtr Layer, FontTypePtr PCBFont, LocationType X, LocationType Y, BYTE Direction, int Scale, char *TextString, FlagType Flags) { TextType *text; if (TextString == NULL) return NULL; text = GetTextMemory (Layer); if (text == NULL) return NULL; /* copy values, width and height are set by drawing routine * because at this point we don't know which symbols are available */ text->X = X; text->Y = Y; text->Direction = Direction; text->Flags = Flags; text->Scale = Scale; text->TextString = strdup (TextString); /* calculate size of the bounding box */ SetTextBoundingBox (PCBFont, text); text->ID = ID++; if (!Layer->text_tree) Layer->text_tree = r_create_tree (NULL, 0, 0); r_insert_entry (Layer->text_tree, (BoxTypePtr) text, 0); return (text); }
/* --------------------------------------------------------------------------- * creates a new textobject as part of an element * copies the values to the appropriate text object */ static void AddTextToElement (TextTypePtr Text, FontTypePtr PCBFont, LocationType X, LocationType Y, BYTE Direction, char *TextString, int Scale, FlagType Flags) { free (Text->TextString); Text->TextString = (TextString && *TextString) ? strdup (TextString) : NULL; Text->X = X; Text->Y = Y; Text->Direction = Direction; Text->Flags = Flags; Text->Scale = Scale; /* calculate size of the bounding box */ SetTextBoundingBox (PCBFont, Text); Text->ID = ID++; }
/* --------------------------------------------------------------------------- * flip components/tracks from one side to the other */ static void SwapBuffer (BufferType *Buffer) { int j, k; Cardinal sgroup, cgroup; LayerType swap; ELEMENT_LOOP (Buffer->Data); { r_delete_element (Buffer->Data, element); MirrorElementCoordinates (Buffer->Data, element, 0); } END_LOOP; /* set buffer offset to 'mark' position */ Buffer->X = SWAP_X (Buffer->X); Buffer->Y = SWAP_Y (Buffer->Y); VIA_LOOP (Buffer->Data); { r_delete_entry (Buffer->Data->via_tree, (BoxType *)via); via->X = SWAP_X (via->X); via->Y = SWAP_Y (via->Y); SetPinBoundingBox (via); r_insert_entry (Buffer->Data->via_tree, (BoxType *)via, 0); } END_LOOP; ALLLINE_LOOP (Buffer->Data); { r_delete_entry (layer->line_tree, (BoxType *)line); line->Point1.X = SWAP_X (line->Point1.X); line->Point1.Y = SWAP_Y (line->Point1.Y); line->Point2.X = SWAP_X (line->Point2.X); line->Point2.Y = SWAP_Y (line->Point2.Y); SetLineBoundingBox (line); r_insert_entry (layer->line_tree, (BoxType *)line, 0); } ENDALL_LOOP; ALLARC_LOOP (Buffer->Data); { r_delete_entry (layer->arc_tree, (BoxType *)arc); arc->X = SWAP_X (arc->X); arc->Y = SWAP_Y (arc->Y); arc->StartAngle = SWAP_ANGLE (arc->StartAngle); arc->Delta = SWAP_DELTA (arc->Delta); SetArcBoundingBox (arc); r_insert_entry (layer->arc_tree, (BoxType *)arc, 0); } ENDALL_LOOP; ALLPOLYGON_LOOP (Buffer->Data); { r_delete_entry (layer->polygon_tree, (BoxType *)polygon); POLYGONPOINT_LOOP (polygon); { point->X = SWAP_X (point->X); point->Y = SWAP_Y (point->Y); } END_LOOP; SetPolygonBoundingBox (polygon); r_insert_entry (layer->polygon_tree, (BoxType *)polygon, 0); /* hmmm, how to handle clip */ } ENDALL_LOOP; ALLTEXT_LOOP (Buffer->Data); { r_delete_entry (layer->text_tree, (BoxType *)text); text->X = SWAP_X (text->X); text->Y = SWAP_Y (text->Y); TOGGLE_FLAG (ONSOLDERFLAG, text); SetTextBoundingBox (&PCB->Font, text); r_insert_entry (layer->text_tree, (BoxType *)text, 0); } ENDALL_LOOP; /* swap silkscreen layers */ swap = Buffer->Data->Layer[solder_silk_layer]; Buffer->Data->Layer[solder_silk_layer] = Buffer->Data->Layer[component_silk_layer]; Buffer->Data->Layer[component_silk_layer] = swap; /* swap layer groups when balanced */ sgroup = GetLayerGroupNumberByNumber (solder_silk_layer); cgroup = GetLayerGroupNumberByNumber (component_silk_layer); if (PCB->LayerGroups.Number[cgroup] == PCB->LayerGroups.Number[sgroup]) { for (j = k = 0; j < PCB->LayerGroups.Number[sgroup]; j++) { int t1, t2; Cardinal cnumber = PCB->LayerGroups.Entries[cgroup][k]; Cardinal snumber = PCB->LayerGroups.Entries[sgroup][j]; if (snumber >= max_copper_layer) continue; swap = Buffer->Data->Layer[snumber]; while (cnumber >= max_copper_layer) { k++; cnumber = PCB->LayerGroups.Entries[cgroup][k]; } Buffer->Data->Layer[snumber] = Buffer->Data->Layer[cnumber]; Buffer->Data->Layer[cnumber] = swap; k++; /* move the thermal flags with the layers */ ALLPIN_LOOP (Buffer->Data); { t1 = TEST_THERM (snumber, pin); t2 = TEST_THERM (cnumber, pin); ASSIGN_THERM (snumber, t2, pin); ASSIGN_THERM (cnumber, t1, pin); } ENDALL_LOOP; VIA_LOOP (Buffer->Data); { t1 = TEST_THERM (snumber, via); t2 = TEST_THERM (cnumber, via); ASSIGN_THERM (snumber, t2, via); ASSIGN_THERM (cnumber, t1, via); } END_LOOP; } } SetBufferBoundingBox (Buffer); SetCrosshairRangeToBuffer (); }