static void selection_changed_cb (GtkTreeSelection *selection, gpointer user_data) { GtkTreeModel *model; GtkTreeIter iter; GhidDrcViolation *violation; int i; if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { if (ClearFlagOnAllObjects (true, FOUNDFLAG)) { IncrementUndoSerialNumber (); Draw (); } return; } /* Check the selected node has children, if so; return. */ if (gtk_tree_model_iter_has_child (model, &iter)) return; gtk_tree_model_get (model, &iter, DRC_VIOLATION_OBJ_COL, &violation, -1); ClearFlagOnAllObjects (true, FOUNDFLAG); if (violation == NULL) return; /* Flag the objects listed against this DRC violation */ for (i = 0; i < violation->object_count; i++) { int object_id = violation->object_id_list[i]; int object_type = violation->object_type_list[i]; int found_type; void *ptr1, *ptr2, *ptr3; found_type = SearchObjectByID (PCB->Data, &ptr1, &ptr2, &ptr3, object_id, object_type); if (found_type == NO_TYPE) { Message (_("Object ID %i identified during DRC was not found. Stale DRC window?\n"), object_id); continue; } AddObjectToFlagUndoList (object_type, ptr1, ptr2, ptr3); SET_FLAG (FOUNDFLAG, (AnyObjectType *)ptr2); switch (violation->object_type_list[i]) { case LINE_TYPE: case ARC_TYPE: case POLYGON_TYPE: ChangeGroupVisibility (GetLayerNumber (PCB->Data, (LayerType *) ptr1), true, true); } DrawObject (object_type, ptr1, ptr2); } SetChangedFlag (true); IncrementUndoSerialNumber (); Draw(); }
int mptl_pin_callback (const BoxType *b, void *cl) { struct mptlc *d = (struct mptlc *) cl; PinTypePtr pin = (PinTypePtr) b; if (!TEST_THERM (d->snum, pin) || ! IsPointInPolygon (pin->X, pin->Y, pin->Thickness + pin->Clearance + 2, d->polygon)) return 0; if (d->type == PIN_TYPE) AddObjectToFlagUndoList (PIN_TYPE, pin->Element, pin, pin); else AddObjectToFlagUndoList (VIA_TYPE, pin, pin, pin); ASSIGN_THERM (d->dnum, GET_THERM (d->snum, pin), pin); CLEAR_THERM (d->snum, pin); return 1; }
/* --------------------------------------------------------------------------- * toggle selection of pin * This SelectPin function was moved to here from the original netlist.c * as part of the gui code separation for the Gtk port. SelectPin() is * written by and is Copyright (C) 1998, 1999, 2000, 2001 harry eaton */ void SelectPin (LibraryEntryTypePtr entry, bool toggle) { ConnectionType conn; if (SeekPad (entry, &conn, false)) { switch (conn.type) { case PIN_TYPE: { PinTypePtr pin = (PinTypePtr) conn.ptr2; AddObjectToFlagUndoList (PIN_TYPE, conn.ptr1, conn.ptr2, conn.ptr2); if (toggle) { TOGGLE_FLAG (SELECTEDFLAG, pin); CenterDisplay (pin->X, pin->Y, false); } else SET_FLAG (SELECTEDFLAG, pin); DrawPin (pin, 0); break; } case PAD_TYPE: { PadTypePtr pad = (PadTypePtr) conn.ptr2; AddObjectToFlagUndoList (PAD_TYPE, conn.ptr1, conn.ptr2, conn.ptr2); if (toggle) { TOGGLE_FLAG (SELECTEDFLAG, pad); CenterDisplay (pad->Point1.X, pad->Point1.Y, false); } else SET_FLAG (SELECTEDFLAG, pad); DrawPad (pad, 0); break; } } } }
static void toggle_pin_selected (LibraryEntryType *entry) { ConnectionType conn; if (!SeekPad (entry, &conn, false)) return; AddObjectToFlagUndoList (conn.type, conn.ptr1, conn.ptr2, conn.ptr2); TOGGLE_FLAG (SELECTEDFLAG, (AnyObjectType *)conn.ptr2); DrawObject (conn.type, conn.ptr1, conn.ptr2); }
void *ChangeTextJoin( LayerTypePtr Layer, TextTypePtr Text ) { int esi; EraseText( Layer, Text ); AddObjectToClearPolyUndoList( 16, (void*)Layer, (void*)Text, (void*)Text, 0 ); RestoreToPolygon( &PCB->Data, 16, (void*)Layer, (void*)Text ); AddObjectToFlagUndoList( 4, (void*)Layer, (void*)Text, (void*)Text ); Text->Flags.f ^= 32; AddObjectToClearPolyUndoList( 16, (void*)Layer, (void*)Text, (void*)Text, 1 ); ClearFromPolygon( &PCB->Data, 16, (void*)Layer, (void*)Text ); DrawText( Layer, Text, 0 ); return (void*)Text; }
void *ChangeArcJoin( LayerTypePtr Layer, ArcTypePtr Arc ) { int esi; EraseArc( Arc ); RestoreToPolygon( &PCB->Data, 16384, (void*)Layer, (void*)Arc ); AddObjectToClearPolyUndoList( 16384, (void*)Layer, (void*)Arc, (void*)Arc, 0 ); AddObjectToFlagUndoList( 16384, (void*)Layer, (void*)Arc, (void*)Arc ); Arc->Flags.f ^= 32; ClearFromPolygon( &PCB->Data, 16384, (void*)Layer, (void*)Arc ); AddObjectToClearPolyUndoList( 16384, (void*)Layer, (void*)Arc, (void*)Arc, 1 ); DrawArc( Layer, Arc, 0 ); return (void*)Arc; }
void *ChangeLineJoin( LayerTypePtr Layer, LineTypePtr Line ) { int esi; EraseLine( Line ); AddObjectToClearPolyUndoList( 4, (void*)Layer, (void*)Line, (void*)Line, 0 ); RestoreToPolygon( &PCB->Data, 4, (void*)Layer, (void*)Line ); AddObjectToFlagUndoList( 4, (void*)Layer, (void*)Line, (void*)Line ); Line->Flags.f ^= 32; AddObjectToClearPolyUndoList( 4, (void*)Layer, (void*)Line, (void*)Line, 1 ); ClearFromPolygon( &PCB->Data, 4, (void*)Layer, (void*)Line ); DrawLine( Layer, Line, 0 ); return (void*)Line; }
void *ChangePinThermal( ElementTypePtr element, PinTypePtr Pin ) { int ecx; int edx; AddObjectToClearPolyUndoList( 256, (void*)element, (void*)Pin, (void*)Pin, 0 ); RestoreToPolygon( &PCB->ID, 1, PCB->SilkActive == 0 ? *(int*)(PCB + 8716) + ( LayerStack[0] * 92 ) + 76 : PCB->Data + ( ( PCB->Data->LayerN + ( Settings.ShowSolderSide == 0 ) ) * 92 ) + 76, (void*)Pin ); AddObjectToFlagUndoList( 256, (void*)element, (void*)Pin, (void*)Pin ); if ( Delta == 0 ) { } else { } AddObjectToClearPolyUndoList( 256, (void*)element, (void*)Pin, (void*)Pin, 1 ); ClearFromPolygon( &PCB->Data, 1, PCB->Data[5].name_tree[0] + ( LayerStack[0] * 92 ) + 76, (void*)Pin ); DrawPin( Pin, 0 ); return (void*)Pin; }
void *ChangeViaThermal( PinTypePtr Via ) { int ecx; int edx; AddObjectToClearPolyUndoList( 1, (void*)Via, (void*)Via, (void*)Via, 0 ); RestoreToPolygon( &PCB->ID, 1, PCB->SilkActive == 0 ? *(int*)(PCB + 8716) + ( LayerStack[0] * 92 ) + 76 : PCB->Data + ( ( PCB->Data->LayerN + ( Settings.ShowSolderSide == 0 ) ) * 92 ) + 76, (void*)Via ); AddObjectToFlagUndoList( 1, (void*)Via, (void*)Via, (void*)Via ); if ( Delta == 0 ) { } else { } AddObjectToClearPolyUndoList( 1, (void*)Via, (void*)Via, (void*)Via, 1 ); ClearFromPolygon( &PCB->Data, 1, PCB->Data[5].name_tree[0] + ( LayerStack[0] * 92 ) + 76, (void*)Via ); DrawVia( Via, 0 ); return (void*)Via; }
Boolean ChangeHole( PinTypePtr Via ) { EraseVia( Via ); AddObjectToFlagUndoList( 1, (void*)Via, (void*)Via, (void*)Via ); Via->Flags.f ^= 8; if ( ( (unsigned char)( Via->Flags.f ^ 8 ) & 8 ) & 255 ) { RestoreToPolygon( &PCB->Data, 1, (void*)Via, (void*)Via ); AddObjectToSizeUndoList( 1, (void*)Via, (void*)Via, (void*)Via ); Via->Mask = Via->DrillingHole; Via->Thickness = Via->DrillingHole; ClearFromPolygon( &PCB->Data, 1, (void*)Via, (void*)Via ); } else { AddObjectTo2ndSizeUndoList( 1, (void*)Via, (void*)Via, (void*)Via ); Via->DrillingHole = Via->Thickness + -400; } DrawVia( Via, 0 ); Draw( ); return 1; }
bool SelectObjectByName (int Type, char *Pattern, bool Flag) { bool changed = false; #if defined(HAVE_REGCOMP) #define REGEXEC(arg) (regexec_match_all(&compiled, (arg))) int result; regex_t compiled; /* compile the regular expression */ result = regcomp (&compiled, Pattern, REG_EXTENDED | REG_ICASE); if (result) { char errorstring[128]; regerror (result, &compiled, errorstring, 128); Message (_("regexp error: %s\n"), errorstring); regfree (&compiled); return (false); } #else #define REGEXEC(arg) (re_exec((arg)) == 1) char *compiled; /* compile the regular expression */ if ((compiled = re_comp (Pattern)) != NULL) { Message (_("re_comp error: %s\n"), compiled); return (false); } #endif /* loop over all visible objects with names */ if (Type & TEXT_TYPE) ALLTEXT_LOOP (PCB->Data); { if (!TEST_FLAG (LOCKFLAG, text) && TEXT_IS_VISIBLE (PCB, layer, text) && text->TextString && REGEXEC (text->TextString) && TEST_FLAG (SELECTEDFLAG, text) != Flag) { AddObjectToFlagUndoList (TEXT_TYPE, layer, text, text); ASSIGN_FLAG (SELECTEDFLAG, Flag, text); DrawText (layer, text, 0); changed = true; } } ENDALL_LOOP; if (PCB->ElementOn && (Type & ELEMENT_TYPE)) ELEMENT_LOOP (PCB->Data); { if (!TEST_FLAG (LOCKFLAG, element) && ((TEST_FLAG (ONSOLDERFLAG, element) != 0) == SWAP_IDENT || PCB->InvisibleObjectsOn) && TEST_FLAG (SELECTEDFLAG, element) != Flag) { String name = ELEMENT_NAME (PCB, element); if (name && REGEXEC (name)) { AddObjectToFlagUndoList (ELEMENT_TYPE, element, element, element); ASSIGN_FLAG (SELECTEDFLAG, Flag, element); PIN_LOOP (element); { AddObjectToFlagUndoList (PIN_TYPE, element, pin, pin); ASSIGN_FLAG (SELECTEDFLAG, Flag, pin); } END_LOOP; PAD_LOOP (element); { AddObjectToFlagUndoList (PAD_TYPE, element, pad, pad); ASSIGN_FLAG (SELECTEDFLAG, Flag, pad); } END_LOOP; ELEMENTTEXT_LOOP (element); { AddObjectToFlagUndoList (ELEMENTNAME_TYPE, element, text, text); ASSIGN_FLAG (SELECTEDFLAG, Flag, text); } END_LOOP; DrawElementName (element, 0); DrawElement (element, 0); changed = true; } } } END_LOOP; if (PCB->PinOn && (Type & PIN_TYPE)) ALLPIN_LOOP (PCB->Data); { if (!TEST_FLAG (LOCKFLAG, element) && pin->Name && REGEXEC (pin->Name) && TEST_FLAG (SELECTEDFLAG, pin) != Flag) { AddObjectToFlagUndoList (PIN_TYPE, element, pin, pin); ASSIGN_FLAG (SELECTEDFLAG, Flag, pin); DrawPin (pin, 0); changed = true; } } ENDALL_LOOP; if (PCB->PinOn && (Type & PAD_TYPE)) ALLPAD_LOOP (PCB->Data); { if (!TEST_FLAG (LOCKFLAG, element) && ((TEST_FLAG (ONSOLDERFLAG, pad) != 0) == SWAP_IDENT || PCB->InvisibleObjectsOn) && TEST_FLAG (SELECTEDFLAG, pad) != Flag) if (pad->Name && REGEXEC (pad->Name)) { AddObjectToFlagUndoList (PAD_TYPE, element, pad, pad); ASSIGN_FLAG (SELECTEDFLAG, Flag, pad); DrawPad (pad, 0); changed = true; } } ENDALL_LOOP; if (PCB->ViaOn && (Type & VIA_TYPE)) VIA_LOOP (PCB->Data); { if (!TEST_FLAG (LOCKFLAG, via) && via->Name && REGEXEC (via->Name) && TEST_FLAG (SELECTEDFLAG, via) != Flag) { AddObjectToFlagUndoList (VIA_TYPE, via, via, via); ASSIGN_FLAG (SELECTEDFLAG, Flag, via); DrawVia (via, 0); changed = true; } } END_LOOP; #if defined(HAVE_REGCOMP) #if !defined(sgi) regfree (&compiled); #endif #endif if (changed) { IncrementUndoSerialNumber (); Draw (); } return (changed); }
/* ---------------------------------------------------------------------- * selects/unselects all objects which were found during a connection scan * Flag determines if they are to be selected or unselected * returns true if the state of any object has changed * * text objects and elements cannot be selected by this routine */ bool SelectConnection (bool Flag) { bool changed = false; if (PCB->RatOn) RAT_LOOP (PCB->Data); { if (TEST_FLAG (FOUNDFLAG, line)) { AddObjectToFlagUndoList (RATLINE_TYPE, line, line, line); ASSIGN_FLAG (SELECTEDFLAG, Flag, line); DrawRat (line, 0); changed = true; } } END_LOOP; VISIBLELINE_LOOP (PCB->Data); { if (TEST_FLAG (FOUNDFLAG, line) && !TEST_FLAG (LOCKFLAG, line)) { AddObjectToFlagUndoList (LINE_TYPE, layer, line, line); ASSIGN_FLAG (SELECTEDFLAG, Flag, line); DrawLine (layer, line, 0); changed = true; } } ENDALL_LOOP; VISIBLEARC_LOOP (PCB->Data); { if (TEST_FLAG (FOUNDFLAG, arc) && !TEST_FLAG (LOCKFLAG, arc)) { AddObjectToFlagUndoList (ARC_TYPE, layer, arc, arc); ASSIGN_FLAG (SELECTEDFLAG, Flag, arc); DrawArc (layer, arc, 0); changed = true; } } ENDALL_LOOP; VISIBLEPOLYGON_LOOP (PCB->Data); { if (TEST_FLAG (FOUNDFLAG, polygon) && !TEST_FLAG (LOCKFLAG, polygon)) { AddObjectToFlagUndoList (POLYGON_TYPE, layer, polygon, polygon); ASSIGN_FLAG (SELECTEDFLAG, Flag, polygon); DrawPolygon (layer, polygon, 0); changed = true; } } ENDALL_LOOP; if (PCB->PinOn && PCB->ElementOn) { ALLPIN_LOOP (PCB->Data); { if (!TEST_FLAG (LOCKFLAG, element) && TEST_FLAG (FOUNDFLAG, pin)) { AddObjectToFlagUndoList (PIN_TYPE, element, pin, pin); ASSIGN_FLAG (SELECTEDFLAG, Flag, pin); DrawPin (pin, 0); changed = true; } } ENDALL_LOOP; ALLPAD_LOOP (PCB->Data); { if (!TEST_FLAG (LOCKFLAG, element) && TEST_FLAG (FOUNDFLAG, pad)) { AddObjectToFlagUndoList (PAD_TYPE, element, pad, pad); ASSIGN_FLAG (SELECTEDFLAG, Flag, pad); DrawPad (pad, 0); changed = true; } } ENDALL_LOOP; } if (PCB->ViaOn) VIA_LOOP (PCB->Data); { if (TEST_FLAG (FOUNDFLAG, via) && !TEST_FLAG (LOCKFLAG, via)) { AddObjectToFlagUndoList (VIA_TYPE, via, via, via); ASSIGN_FLAG (SELECTEDFLAG, Flag, via); DrawVia (via, 0); changed = true; } } END_LOOP; Draw (); return (changed); }
/* ---------------------------------------------------------------------- * performs several operations on selected objects which are also visible * The lowlevel procedures are passed together with additional information * resets the selected flag if requested * returns true if anything has changed */ bool SelectedOperation (ObjectFunctionTypePtr F, bool Reset, int type) { bool changed = false; /* check lines */ if (type & LINE_TYPE && F->Line) VISIBLELINE_LOOP (PCB->Data); { if (TEST_FLAG (SELECTEDFLAG, line)) { if (Reset) { AddObjectToFlagUndoList (LINE_TYPE, layer, line, line); CLEAR_FLAG (SELECTEDFLAG, line); } F->Line (layer, line); changed = true; } } ENDALL_LOOP; /* check arcs */ if (type & ARC_TYPE && F->Arc) VISIBLEARC_LOOP (PCB->Data); { if (TEST_FLAG (SELECTEDFLAG, arc)) { if (Reset) { AddObjectToFlagUndoList (ARC_TYPE, layer, arc, arc); CLEAR_FLAG (SELECTEDFLAG, arc); } F->Arc (layer, arc); changed = true; } } ENDALL_LOOP; /* check text */ if (type & TEXT_TYPE && F->Text) ALLTEXT_LOOP (PCB->Data); { if (TEST_FLAG (SELECTEDFLAG, text) && TEXT_IS_VISIBLE (PCB, layer, text)) { if (Reset) { AddObjectToFlagUndoList (TEXT_TYPE, layer, text, text); CLEAR_FLAG (SELECTEDFLAG, text); } F->Text (layer, text); changed = true; } } ENDALL_LOOP; /* check polygons */ if (type & POLYGON_TYPE && F->Polygon) VISIBLEPOLYGON_LOOP (PCB->Data); { if (TEST_FLAG (SELECTEDFLAG, polygon)) { if (Reset) { AddObjectToFlagUndoList (POLYGON_TYPE, layer, polygon, polygon); CLEAR_FLAG (SELECTEDFLAG, polygon); } F->Polygon (layer, polygon); changed = true; } } ENDALL_LOOP; /* elements silkscreen */ if (type & ELEMENT_TYPE && PCB->ElementOn && F->Element) ELEMENT_LOOP (PCB->Data); { if (TEST_FLAG (SELECTEDFLAG, element)) { if (Reset) { AddObjectToFlagUndoList (ELEMENT_TYPE, element, element, element); CLEAR_FLAG (SELECTEDFLAG, element); } F->Element (element); changed = true; } } END_LOOP; if (type & ELEMENTNAME_TYPE && PCB->ElementOn && F->ElementName) ELEMENT_LOOP (PCB->Data); { if (TEST_FLAG (SELECTEDFLAG, &ELEMENT_TEXT (PCB, element))) { if (Reset) { AddObjectToFlagUndoList (ELEMENTNAME_TYPE, element, &ELEMENT_TEXT (PCB, element), &ELEMENT_TEXT (PCB, element)); CLEAR_FLAG (SELECTEDFLAG, &ELEMENT_TEXT (PCB, element)); } F->ElementName (element); changed = true; } } END_LOOP; if (type & PIN_TYPE && PCB->PinOn && F->Pin) ELEMENT_LOOP (PCB->Data); { PIN_LOOP (element); { if (TEST_FLAG (SELECTEDFLAG, pin)) { if (Reset) { AddObjectToFlagUndoList (PIN_TYPE, element, pin, pin); CLEAR_FLAG (SELECTEDFLAG, pin); } F->Pin (element, pin); changed = true; } } END_LOOP; } END_LOOP; if (type & PAD_TYPE && PCB->PinOn && F->Pad) ELEMENT_LOOP (PCB->Data); { PAD_LOOP (element); { if (TEST_FLAG (SELECTEDFLAG, pad)) { if (Reset) { AddObjectToFlagUndoList (PAD_TYPE, element, pad, pad); CLEAR_FLAG (SELECTEDFLAG, pad); } F->Pad (element, pad); changed = true; } } END_LOOP; } END_LOOP; /* process vias */ if (type & VIA_TYPE && PCB->ViaOn && F->Via) VIA_LOOP (PCB->Data); { if (TEST_FLAG (SELECTEDFLAG, via)) { if (Reset) { AddObjectToFlagUndoList (VIA_TYPE, via, via, via); CLEAR_FLAG (SELECTEDFLAG, via); } F->Via (via); changed = true; } } END_LOOP; /* and rat-lines */ if (type & RATLINE_TYPE && PCB->RatOn && F->Rat) RAT_LOOP (PCB->Data); { if (TEST_FLAG (SELECTEDFLAG, line)) { if (Reset) { AddObjectToFlagUndoList (RATLINE_TYPE, line, line, line); CLEAR_FLAG (SELECTEDFLAG, line); } F->Rat (line); changed = true; } } END_LOOP; if (Reset && changed) IncrementUndoSerialNumber (); return (changed); }
/* ---------------------------------------------------------------------- * selects/unselects all visible objects within the passed box * Flag determines if the block is to be selected or unselected * returns true if the state of any object has changed */ bool SelectBlock (BoxTypePtr Box, bool Flag) { bool changed = false; if (PCB->RatOn || !Flag) RAT_LOOP (PCB->Data); { if (LINE_IN_BOX ((LineTypePtr) line, Box) && !TEST_FLAG (LOCKFLAG, line) && TEST_FLAG (SELECTEDFLAG, line) != Flag) { AddObjectToFlagUndoList (RATLINE_TYPE, line, line, line); ASSIGN_FLAG (SELECTEDFLAG, Flag, line); if (PCB->RatOn) DrawRat (line, 0); changed = true; } } END_LOOP; /* check layers */ LAYER_LOOP(PCB->Data, max_copper_layer + 2); { if (layer == & PCB->Data->SILKLAYER) { if (! (PCB->ElementOn || !Flag)) continue; } else if (layer == & PCB->Data->BACKSILKLAYER) { if (! (PCB->InvisibleObjectsOn || !Flag)) continue; } else if (! (layer->On || !Flag)) continue; LINE_LOOP (layer); { if (LINE_IN_BOX (line, Box) && !TEST_FLAG (LOCKFLAG, line) && TEST_FLAG (SELECTEDFLAG, line) != Flag) { AddObjectToFlagUndoList (LINE_TYPE, layer, line, line); ASSIGN_FLAG (SELECTEDFLAG, Flag, line); if (layer->On) DrawLine (layer, line, 0); changed = true; } } END_LOOP; ARC_LOOP (layer); { if (ARC_IN_BOX (arc, Box) && !TEST_FLAG (LOCKFLAG, arc) && TEST_FLAG (SELECTEDFLAG, arc) != Flag) { AddObjectToFlagUndoList (ARC_TYPE, layer, arc, arc); ASSIGN_FLAG (SELECTEDFLAG, Flag, arc); if (layer->On) DrawArc (layer, arc, 0); changed = true; } } END_LOOP; TEXT_LOOP (layer); { if (!Flag || TEXT_IS_VISIBLE(PCB, layer, text)) { if (TEXT_IN_BOX (text, Box) && !TEST_FLAG (LOCKFLAG, text) && TEST_FLAG (SELECTEDFLAG, text) != Flag) { AddObjectToFlagUndoList (TEXT_TYPE, layer, text, text); ASSIGN_FLAG (SELECTEDFLAG, Flag, text); if (TEXT_IS_VISIBLE(PCB, layer, text)) DrawText (layer, text, 0); changed = true; } } } END_LOOP; POLYGON_LOOP (layer); { if (POLYGON_IN_BOX (polygon, Box) && !TEST_FLAG (LOCKFLAG, polygon) && TEST_FLAG (SELECTEDFLAG, polygon) != Flag) { AddObjectToFlagUndoList (POLYGON_TYPE, layer, polygon, polygon); ASSIGN_FLAG (SELECTEDFLAG, Flag, polygon); if (layer->On) DrawPolygon (layer, polygon, 0); changed = true; } } END_LOOP; } END_LOOP; /* elements */ ELEMENT_LOOP (PCB->Data); { { bool gotElement = false; if ((PCB->ElementOn || !Flag) && !TEST_FLAG (LOCKFLAG, element) && ((TEST_FLAG (ONSOLDERFLAG, element) != 0) == SWAP_IDENT || PCB->InvisibleObjectsOn)) { if (BOX_IN_BOX (&ELEMENT_TEXT (PCB, element).BoundingBox, Box) && !TEST_FLAG (LOCKFLAG, &ELEMENT_TEXT (PCB, element)) && TEST_FLAG (SELECTEDFLAG, &ELEMENT_TEXT (PCB, element)) != Flag) { /* select all names of element */ ELEMENTTEXT_LOOP (element); { AddObjectToFlagUndoList (ELEMENTNAME_TYPE, element, text, text); ASSIGN_FLAG (SELECTEDFLAG, Flag, text); } END_LOOP; if (PCB->ElementOn) DrawElementName (element, 0); changed = true; } if ((PCB->PinOn || !Flag) && ELEMENT_IN_BOX (element, Box)) if (TEST_FLAG (SELECTEDFLAG, element) != Flag) { AddObjectToFlagUndoList (ELEMENT_TYPE, element, element, element); ASSIGN_FLAG (SELECTEDFLAG, Flag, element); PIN_LOOP (element); { if (TEST_FLAG (SELECTEDFLAG, pin) != Flag) { AddObjectToFlagUndoList (PIN_TYPE, element, pin, pin); ASSIGN_FLAG (SELECTEDFLAG, Flag, pin); if (PCB->PinOn) DrawPin (pin, 0); changed = true; } } END_LOOP; PAD_LOOP (element); { if (TEST_FLAG (SELECTEDFLAG, pad) != Flag) { AddObjectToFlagUndoList (PAD_TYPE, element, pad, pad); ASSIGN_FLAG (SELECTEDFLAG, Flag, pad); if (PCB->PinOn) DrawPad (pad, 0); changed = true; } } END_LOOP; if (PCB->PinOn) DrawElement (element, 0); changed = true; gotElement = true; } } if ((PCB->PinOn || !Flag) && !TEST_FLAG (LOCKFLAG, element) && !gotElement) { PIN_LOOP (element); { if ((VIA_OR_PIN_IN_BOX (pin, Box) && TEST_FLAG (SELECTEDFLAG, pin) != Flag)) { AddObjectToFlagUndoList (PIN_TYPE, element, pin, pin); ASSIGN_FLAG (SELECTEDFLAG, Flag, pin); if (PCB->PinOn) DrawPin (pin, 0); changed = true; } } END_LOOP; PAD_LOOP (element); { if (PAD_IN_BOX (pad, Box) && TEST_FLAG (SELECTEDFLAG, pad) != Flag) { AddObjectToFlagUndoList (PAD_TYPE, element, pad, pad); ASSIGN_FLAG (SELECTEDFLAG, Flag, pad); if (PCB->PinOn) DrawPad (pad, 0); changed = true; } } END_LOOP; } } } END_LOOP; /* end with vias */ if (PCB->ViaOn || !Flag) VIA_LOOP (PCB->Data); { if (VIA_OR_PIN_IN_BOX (via, Box) && !TEST_FLAG (LOCKFLAG, via) && TEST_FLAG (SELECTEDFLAG, via) != Flag) { AddObjectToFlagUndoList (VIA_TYPE, via, via, via); ASSIGN_FLAG (SELECTEDFLAG, Flag, via); if (PCB->ViaOn) DrawVia (via, 0); changed = true; } } END_LOOP; if (changed) { Draw (); IncrementUndoSerialNumber (); } return (changed); }
/* --------------------------------------------------------------------------- * toggles the selection of any kind of object * the different types are defined by search.h */ bool SelectObject (void) { void *ptr1, *ptr2, *ptr3; LayerTypePtr layer; int type; bool changed = true; type = SearchScreen (Crosshair.X, Crosshair.Y, SELECT_TYPES, &ptr1, &ptr2, &ptr3); if (type == NO_TYPE || TEST_FLAG (LOCKFLAG, (PinTypePtr) ptr2)) return (false); switch (type) { case VIA_TYPE: AddObjectToFlagUndoList (VIA_TYPE, ptr1, ptr1, ptr1); TOGGLE_FLAG (SELECTEDFLAG, (PinTypePtr) ptr1); DrawVia ((PinTypePtr) ptr1, 0); break; case LINE_TYPE: { LineType *line = (LineTypePtr) ptr2; layer = (LayerTypePtr) ptr1; AddObjectToFlagUndoList (LINE_TYPE, ptr1, ptr2, ptr2); TOGGLE_FLAG (SELECTEDFLAG, line); DrawLine (layer, line, 0); break; } case RATLINE_TYPE: { RatTypePtr rat = (RatTypePtr) ptr2; AddObjectToFlagUndoList (RATLINE_TYPE, ptr1, ptr1, ptr1); TOGGLE_FLAG (SELECTEDFLAG, rat); DrawRat (rat, 0); break; } case ARC_TYPE: { ArcType *arc = (ArcTypePtr) ptr2; layer = (LayerTypePtr) ptr1; AddObjectToFlagUndoList (ARC_TYPE, ptr1, ptr2, ptr2); TOGGLE_FLAG (SELECTEDFLAG, arc); DrawArc (layer, arc, 0); break; } case TEXT_TYPE: { TextType *text = (TextTypePtr) ptr2; layer = (LayerTypePtr) ptr1; AddObjectToFlagUndoList (TEXT_TYPE, ptr1, ptr2, ptr2); TOGGLE_FLAG (SELECTEDFLAG, text); DrawText (layer, text, 0); break; } case POLYGON_TYPE: { PolygonType *poly = (PolygonTypePtr) ptr2; layer = (LayerTypePtr) ptr1; AddObjectToFlagUndoList (POLYGON_TYPE, ptr1, ptr2, ptr2); TOGGLE_FLAG (SELECTEDFLAG, poly); DrawPolygon (layer, poly, 0); /* changing memory order no longer effects draw order */ break; } case PIN_TYPE: AddObjectToFlagUndoList (PIN_TYPE, ptr1, ptr2, ptr2); TOGGLE_FLAG (SELECTEDFLAG, (PinTypePtr) ptr2); DrawPin ((PinTypePtr) ptr2, 0); break; case PAD_TYPE: AddObjectToFlagUndoList (PAD_TYPE, ptr1, ptr2, ptr2); TOGGLE_FLAG (SELECTEDFLAG, (PadTypePtr) ptr2); DrawPad ((PadTypePtr) ptr2, 0); break; case ELEMENTNAME_TYPE: { ElementTypePtr element = (ElementTypePtr) ptr1; /* select all names of the element */ ELEMENTTEXT_LOOP (element); { AddObjectToFlagUndoList (ELEMENTNAME_TYPE, element, text, text); TOGGLE_FLAG (SELECTEDFLAG, text); } END_LOOP; DrawElementName (element, 0); break; } case ELEMENT_TYPE: { ElementTypePtr element = (ElementTypePtr) ptr1; /* select all pins and names of the element */ PIN_LOOP (element); { AddObjectToFlagUndoList (PIN_TYPE, element, pin, pin); TOGGLE_FLAG (SELECTEDFLAG, pin); } END_LOOP; PAD_LOOP (element); { AddObjectToFlagUndoList (PAD_TYPE, element, pad, pad); TOGGLE_FLAG (SELECTEDFLAG, pad); } END_LOOP; ELEMENTTEXT_LOOP (element); { AddObjectToFlagUndoList (ELEMENTNAME_TYPE, element, text, text); TOGGLE_FLAG (SELECTEDFLAG, text); } END_LOOP; AddObjectToFlagUndoList (ELEMENT_TYPE, element, element, element); TOGGLE_FLAG (SELECTEDFLAG, element); if (PCB->ElementOn && ((TEST_FLAG (ONSOLDERFLAG, element) != 0) == SWAP_IDENT || PCB->InvisibleObjectsOn)) if (PCB->ElementOn) { DrawElementName (element, 0); DrawElementPackage (element, 0); } if (PCB->PinOn) DrawElementPinsAndPads (element, 0); break; } } Draw (); IncrementUndoSerialNumber (); return (changed); }