/* --------------------------------------------------------------------------- * moves a polygon between layers */ static void * MovePolygonToLayer (LayerType *Layer, PolygonType *Polygon) { PolygonTypePtr newone; struct mptlc d; if (TEST_FLAG (LOCKFLAG, Polygon)) { Message (_("Sorry, the object is locked\n")); return NULL; } if (((long int) Dest == -1) || (Layer == Dest)) return (Polygon); AddObjectToMoveToLayerUndoList (POLYGON_TYPE, Layer, Polygon, Polygon); if (Layer->On) ErasePolygon (Polygon); /* Move all of the thermals with the polygon */ d.snum = GetLayerNumber (PCB->Data, Layer); d.dnum = GetLayerNumber (PCB->Data, Dest); d.polygon = Polygon; d.type = PIN_TYPE; r_search (PCB->Data->pin_tree, &Polygon->BoundingBox, NULL, mptl_pin_callback, &d); d.type = VIA_TYPE; r_search (PCB->Data->via_tree, &Polygon->BoundingBox, NULL, mptl_pin_callback, &d); newone = (struct polygon_st *)MovePolygonToLayerLowLevel (Layer, Polygon, Dest); InitClip (PCB->Data, Dest, newone); if (Dest->On) { DrawPolygon (Dest, newone); Draw (); } return (newone); }
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(); }
/* --------------------------------------------------------------------------- * copies a text to buffer */ static void * AddTextToBuffer (LayerType *Layer, TextType *Text) { LayerType *layer = &Dest->Layer[GetLayerNumber (Source, Layer)]; return (CreateNewText (layer, &PCB->Font, Text->X, Text->Y, Text->Direction, Text->Scale, Text->TextString, MaskFlags (Text->Flags, ExtraFlag))); }
void switch_layer(int *NumOfLayers, NAL *Nal,decoder_context* pdecoder_context) { int LayerChanged = GetLayerChanged(); int TemporalId = *NumOfLayers >> 16; int WantedDqId = *NumOfLayers & 0xff; if(LayerChanged ){ //IDR frame and a valid command to change of layer int i ; int test = 0; int SaveDqId = GetSaveDqId(); for ( i = 0; i < 8; i++){ if (SaveDqId == Nal -> layer_id_table[i]){ //we find it break; } else if(i < 7 && SaveDqId > Nal -> layer_id_table[i] && Nal -> layer_id_table[i + 1] == -1){ //we did not find it, but we should wait test = 1; break; }else if (i < 7 && SaveDqId > Nal -> layer_id_table[i] && SaveDqId < Nal -> layer_id_table[i + 1]){ //we did not find it, but the value must be wrong, so we choose another one test = 2; break; } } if ( test != 1){ if (test == 2){ //The DQId has not been found. //we know that the DQId wanted, is between the layer_id_table [i] and layer_id_table [i + 1] WantedDqId = Nal -> layer_id_table [i + 1]; SetSaveDqId(SaveDqId); } else { int WantedLayer = GetLayerNumber(Nal, SaveDqId); //we have to update the WantedDqId parameter to decode correctly the base layer if it's the one wanted if (WantedLayer < pdecoder_context -> MaxNumLayer){ WantedDqId = Nal -> layer_id_table[WantedLayer]; }else { WantedDqId = Nal -> layer_id_table[pdecoder_context -> MaxNumLayer - 1]; } } SaveDqId = Nal -> DqIdToDisplay = Nal -> DqIdWanted = WantedDqId; SetArgLayer(SaveDqId); SetLastDqId(SaveDqId); ResetLayerChanged(); }else { Nal -> DqIdToDisplay = WantedDqId = SaveDqId; } } *NumOfLayers = (TemporalId << 16) + WantedDqId; }
void DecRefBasePicMarking(unsigned char *data, int *position, MMO *Mmo, SPS *sps, NAL *Nal) { if (getNbits(data, position, 1) ) { int BaseDependency = (Nal -> DqId >> 4) - 1; int LayerId = GetLayerNumber(Nal, BaseDependency << 4); LAYER_MMO *LayerMmo = &Mmo -> LayerMMO [LayerId]; GetMMCOOperationCode(sps, LayerMmo, data, position); SetDecRefLayer(Nal, Mmo, LayerMmo, BaseDependency); }
/* --------------------------------------------------------------------------- * copies an arc to buffer */ static void * AddArcToBuffer (LayerType *Layer, ArcType *Arc) { LayerType *layer = &Dest->Layer[GetLayerNumber (Source, Layer)]; return (CreateNewArcOnLayer (layer, Arc->X, Arc->Y, Arc->Width, Arc->Height, Arc->StartAngle, Arc->Delta, Arc->Thickness, Arc->Clearance, MaskFlags (Arc->Flags, NOCOPY_FLAGS | ExtraFlag))); }
/** Copy the MMCO operation into all layers with the same dependency_id. */ void SetDecRefLayer(NAL *Nal, MMO *Mmo, LAYER_MMO *LayerMmo, int BaseDependency ) { int i; int LayerId = GetLayerNumber(Nal, BaseDependency << 4); //Set the same MMCO control for all layer with the same dependency_id for(i = LayerId; (Nal -> layer_id_table [i] >> 4) == BaseDependency; i++){ Mmo -> LayerMMO [i] . index = LayerMmo -> index; if(LayerMmo -> index){ memcpy(Mmo -> LayerMMO [i] . Mmco, LayerMmo -> Mmco, LayerMmo -> index * sizeof(MMCO)); } } }
/* --------------------------------------------------------------------------- * copies a line to buffer */ static void * AddLineToBuffer (LayerType *Layer, LineType *Line) { LineType *line; LayerType *layer = &Dest->Layer[GetLayerNumber (Source, Layer)]; line = CreateNewLineOnLayer (layer, Line->Point1.X, Line->Point1.Y, Line->Point2.X, Line->Point2.Y, Line->Thickness, Line->Clearance, MaskFlags (Line->Flags, NOCOPY_FLAGS | ExtraFlag)); if (line && Line->Number) line->Number = strdup (Line->Number); return (line); }
void svc_calculate_dpb(const int total_memory, const int mv_memory, short nb_of_layers, MMO *mmo_struct, SPS *sps, NAL *Nal){ short i; short changed = 0; short sps_id = 0; short NumLayers = GetLayerNumber(Nal, Nal -> DqIdMax) + 1; short SeqNumLayers = 0; short max_width = mmo_struct -> MaxWidth; short max_height = mmo_struct -> MaxHeight; unsigned char max_depth_wait = 0; for ( i = 0; i < 32; i ++){ if ( max_width < (sps[i] . pic_width_in_mbs << 4)){ //Get the higher horizontal resolution max_width = mmo_struct -> MaxWidth = (sps[i] . pic_width_in_mbs << 4); sps[i] . b_stride = (max_width) >> 1; sps[i] . b8_stride = (max_width) >> 2; changed = 1; sps_id = i; } if ( max_height < (sps[i] . pic_height_in_map_units << 4)){ //Get the higher vertical resolution max_height = mmo_struct -> MaxHeight = (sps[i] . pic_height_in_map_units << 4); } if ( sps[i] . nb_img_disp > max_depth_wait){ //Get the higher delay max_depth_wait = sps[i] . nb_img_disp; sps_id = i; } if (sps[i] . pic_width_in_mbs > 0){ //Get the num of layer of the sequence SeqNumLayers ++; if(sps[i]. num_ref_frames > sps[sps_id] . num_ref_frames){ sps_id = i; } if(changed){ sps[i]. MemoryAllocated = 1; } } }
/* --------------------------------------------------------------------------- * moves a polygon to buffer. Doesn't allocate memory for the points */ static void * MovePolygonToBuffer (LayerType *layer, PolygonType *polygon) { LayerType *lay = &Dest->Layer[GetLayerNumber (Source, layer)]; r_delete_entry (layer->polygon_tree, (BoxType *)polygon); layer->Polygon = g_list_remove (layer->Polygon, polygon); layer->PolygonN --; lay->Polygon = g_list_append (lay->Polygon, polygon); lay->PolygonN ++; CLEAR_FLAG (NOCOPY_FLAGS, polygon); if (!lay->polygon_tree) lay->polygon_tree = r_create_tree (NULL, 0, 0); r_insert_entry (lay->polygon_tree, (BoxType *)polygon, 0); return (polygon); }
/* --------------------------------------------------------------------------- * moves a text to buffer without allocating memory for the name */ static void * MoveTextToBuffer (LayerType *layer, TextType *text) { LayerType *lay = &Dest->Layer[GetLayerNumber (Source, layer)]; 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 ++; if (!lay->text_tree) lay->text_tree = r_create_tree (NULL, 0, 0); r_insert_entry (lay->text_tree, (BoxType *)text, 0); ClearFromPolygon (Dest, TEXT_TYPE, lay, text); return (text); }
/* --------------------------------------------------------------------------- * copies a polygon to buffer */ static void * AddPolygonToBuffer (LayerType *Layer, PolygonType *Polygon) { LayerType *layer = &Dest->Layer[GetLayerNumber (Source, Layer)]; PolygonType *polygon; polygon = CreateNewPolygon (layer, Polygon->Flags); CopyPolygonLowLevel (polygon, Polygon); /* Update the polygon r-tree. Unlike similarly named functions for * other objects, CreateNewPolygon does not do this as it creates a * skeleton polygon object, which won't have correct bounds. */ if (!layer->polygon_tree) layer->polygon_tree = r_create_tree (NULL, 0, 0); r_insert_entry (layer->polygon_tree, (BoxType *)polygon, 0); CLEAR_FLAG (NOCOPY_FLAGS | ExtraFlag, polygon); return (polygon); }
/* --------------------------------------------------------------------------- * moves a line to buffer */ static void * MoveLineToBuffer (LayerType *layer, LineType *line) { LayerType *lay = &Dest->Layer[GetLayerNumber (Source, layer)]; RestoreToPolygon (Source, LINE_TYPE, layer, line); r_delete_entry (layer->line_tree, (BoxType *)line); layer->Line = g_list_remove (layer->Line, line); layer->LineN --; lay->Line = g_list_append (lay->Line, line); lay->LineN ++; CLEAR_FLAG (NOCOPY_FLAGS, line); if (!lay->line_tree) lay->line_tree = r_create_tree (NULL, 0, 0); r_insert_entry (lay->line_tree, (BoxType *)line, 0); ClearFromPolygon (Dest, LINE_TYPE, lay, line); return (line); }
/* --------------------------------------------------------------------------- * moves an arc to buffer */ static void * MoveArcToBuffer (LayerType *layer, ArcType *arc) { LayerType *lay = &Dest->Layer[GetLayerNumber (Source, layer)]; RestoreToPolygon (Source, ARC_TYPE, layer, arc); r_delete_entry (layer->arc_tree, (BoxType *)arc); layer->Arc = g_list_remove (layer->Arc, arc); layer->ArcN --; lay->Arc = g_list_append (lay->Arc, arc); lay->ArcN ++; CLEAR_FLAG (NOCOPY_FLAGS, arc); if (!lay->arc_tree) lay->arc_tree = r_create_tree (NULL, 0, 0); r_insert_entry (lay->arc_tree, (BoxType *)arc, 0); ClearFromPolygon (Dest, ARC_TYPE, lay, arc); return (arc); }
/** Used when error has been detected into a slice, to execute the MMO operation and the display management */ void FinishFrameSVCError(int Execute, NAL *Nal, SPS *StructSPS, PPS *Pps, LIST_MMO *Current_pic, int *Crop, int *ImgToDisplay, DISPLAY_M * display_memory, MMO *Mmo, int *xsize, int *ysize) { SPS *sps_id; int pic_parameter_set_id; pic_parameter_set_id = Nal -> pic_parameter_id [Nal -> LayerId]; sps_id = &StructSPS[Pps[pic_parameter_set_id] . seq_parameter_set_id + (Nal -> LayerId ? 16: 0)]; //Sps must be defined if(Execute){ //Short and long term management int baseLayerId = GetLayerNumber(Nal,Nal->DqId>>4<<4); int highDQId = Nal->DqId < Nal->DqIdToDisplay ? Nal->DqId:Nal->DqIdToDisplay; int highLayerId = GetLayerNumber(Nal,highDQId); execute_ref_pic_marking(StructSPS,Mmo,baseLayerId,highLayerId); } //Display managment. DisplayOrderSvc(NULL, display_memory, xsize, ysize, Crop, ImgToDisplay, Mmo); }
static int ReportDialog (int argc, char **argv, Coord x, Coord y) { void *ptr1, *ptr2, *ptr3; int type; char report[2048]; type = SearchScreen (x, y, REPORT_TYPES, &ptr1, &ptr2, &ptr3); if (type == NO_TYPE) type = SearchScreen (x, y, REPORT_TYPES | LOCKED_TYPE, &ptr1, &ptr2, &ptr3); switch (type) { case VIA_TYPE: { PinType *via; #ifndef NDEBUG if (gui->shift_is_pressed ()) { __r_dump_tree (PCB->Data->via_tree->root, 0); return 0; } #endif via = (PinType *) ptr2; if (TEST_FLAG (HOLEFLAG, via)) pcb_snprintf (report, sizeof (report), _("%m+VIA ID# %ld; Flags:%s\n" "(X,Y) = %$mD.\n" "It is a pure hole of diameter %$mS.\n" "Name = \"%s\"." "%s"), USER_UNITMASK, via->ID, flags_to_string (via->Flags, VIA_TYPE), via->X, via->Y, via->DrillingHole, EMPTY (via->Name), TEST_FLAG (LOCKFLAG, via) ? _("It is LOCKED.\n") : ""); else pcb_snprintf (report, sizeof (report), _("%m+VIA ID# %ld; Flags:%s\n" "(X,Y) = %$mD.\n" "Copper width = %$mS. Drill width = %$mS.\n" "Clearance width in polygons = %$mS.\n" "Annulus = %$mS.\n" "Solder mask hole = %$mS (gap = %$mS).\n" "Name = \"%s\"." "%s"), USER_UNITMASK, via->ID, flags_to_string (via->Flags, VIA_TYPE), via->X, via->Y, via->Thickness, via->DrillingHole, via->Clearance / 2, (via->Thickness - via->DrillingHole) / 2, via->Mask, (via->Mask - via->Thickness) / 2, EMPTY (via->Name), TEST_FLAG (LOCKFLAG, via) ? _("It is LOCKED.\n") : ""); break; } case PIN_TYPE: { PinType *Pin; ElementType *element; #ifndef NDEBUG if (gui->shift_is_pressed ()) { __r_dump_tree (PCB->Data->pin_tree->root, 0); return 0; } #endif Pin = (PinType *) ptr2; element = (ElementType *) ptr1; PIN_LOOP (element); { if (pin == Pin) break; } END_LOOP; if (TEST_FLAG (HOLEFLAG, Pin)) pcb_snprintf (report, sizeof (report), _("%m+PIN ID# %ld; Flags:%s\n" "(X,Y) = %$mD.\n" "It is a mounting hole. Drill width = %$mS.\n" "It is owned by element %$mS.\n" "%s"), USER_UNITMASK, Pin->ID, flags_to_string (Pin->Flags, PIN_TYPE), Pin->X, Pin->Y, Pin->DrillingHole, EMPTY (element->Name[1].TextString), TEST_FLAG (LOCKFLAG, Pin) ? _("It is LOCKED.\n") : ""); else pcb_snprintf (report, sizeof (report), _("%m+PIN ID# %ld; Flags:%s\n" "(X,Y) = %$mD.\n" "Copper width = %$mS. Drill width = %$mS.\n" "Clearance width to Polygon = %$mS.\n" "Annulus = %$mS.\n" "Solder mask hole = %$mS (gap = %$mS).\n" "Name = \"%s\".\n" "It is owned by element %s\n as pin number %s.\n" "%s"), USER_UNITMASK, Pin->ID, flags_to_string (Pin->Flags, PIN_TYPE), Pin->X, Pin->Y, Pin->Thickness, Pin->DrillingHole, Pin->Clearance / 2, (Pin->Thickness - Pin->DrillingHole) / 2, Pin->Mask, (Pin->Mask - Pin->Thickness) / 2, EMPTY (Pin->Name), EMPTY (element->Name[1].TextString), EMPTY (Pin->Number), TEST_FLAG (LOCKFLAG, Pin) ? _("It is LOCKED.\n") : ""); break; } case LINE_TYPE: { LineType *line; #ifndef NDEBUG if (gui->shift_is_pressed ()) { LayerType *layer = (LayerType *) ptr1; __r_dump_tree (layer->line_tree->root, 0); return 0; } #endif line = (LineType *) ptr2; pcb_snprintf (report, sizeof (report), _("%m+LINE ID# %ld; Flags:%s\n" "FirstPoint(X,Y) = %$mD, ID = %ld.\n" "SecondPoint(X,Y) = %$mD, ID = %ld.\n" "Width = %$mS.\nClearance width in polygons = %$mS.\n" "It is on layer %d\n" "and has name \"%s\".\n" "%s"), USER_UNITMASK, line->ID, flags_to_string (line->Flags, LINE_TYPE), line->Point1.X, line->Point1.Y, line->Point1.ID, line->Point2.X, line->Point2.Y, line->Point2.ID, line->Thickness, line->Clearance / 2, GetLayerNumber (PCB->Data, (LayerType *) ptr1), UNKNOWN (line->Number), TEST_FLAG (LOCKFLAG, line) ? _("It is LOCKED.\n") : ""); break; } case RATLINE_TYPE: { RatType *line; #ifndef NDEBUG if (gui->shift_is_pressed ()) { __r_dump_tree (PCB->Data->rat_tree->root, 0); return 0; } #endif line = (RatType *) ptr2; pcb_snprintf (report, sizeof (report), _("%m+RAT-LINE ID# %ld; Flags:%s\n" "FirstPoint(X,Y) = %$mD; ID = %ld; " "connects to layer group %d.\n" "SecondPoint(X,Y) = %$mD; ID = %ld; " "connects to layer group %d.\n"), USER_UNITMASK, line->ID, flags_to_string (line->Flags, LINE_TYPE), line->Point1.X, line->Point1.Y, line->Point1.ID, line->group1, line->Point2.X, line->Point2.Y, line->Point2.ID, line->group2); break; } case ARC_TYPE: { ArcType *Arc; BoxType *box; #ifndef NDEBUG if (gui->shift_is_pressed ()) { LayerType *layer = (LayerType *) ptr1; __r_dump_tree (layer->arc_tree->root, 0); return 0; } #endif Arc = (ArcType *) ptr2; box = GetArcEnds (Arc); pcb_snprintf (report, sizeof (report), _("%m+ARC ID# %ld; Flags:%s\n" "CenterPoint(X,Y) = %$mD.\n" "Radius = %$mS, Thickness = %$mS.\n" "Clearance width in polygons = %$mS.\n" "StartAngle = %ma degrees, DeltaAngle = %ma degrees.\n" "Bounding Box is %$mD, %$mD.\n" "That makes the end points at %$mD and %$mD.\n" "It is on layer %d.\n" "%s"), USER_UNITMASK, Arc->ID, flags_to_string (Arc->Flags, ARC_TYPE), Arc->X, Arc->Y, Arc->Width, Arc->Thickness, Arc->Clearance / 2, Arc->StartAngle, Arc->Delta, Arc->BoundingBox.X1, Arc->BoundingBox.Y1, Arc->BoundingBox.X2, Arc->BoundingBox.Y2, box->X1, box->Y1, box->X2, box->Y2, GetLayerNumber (PCB->Data, (LayerType *) ptr1), TEST_FLAG (LOCKFLAG, Arc) ? _("It is LOCKED.\n") : ""); break; } case POLYGON_TYPE: { PolygonType *Polygon; #ifndef NDEBUG if (gui->shift_is_pressed ()) { LayerType *layer = (LayerType *) ptr1; __r_dump_tree (layer->polygon_tree->root, 0); return 0; } #endif Polygon = (PolygonType *) ptr2; pcb_snprintf (report, sizeof (report), _("%m+POLYGON ID# %ld; Flags:%s\n" "Its bounding box is %$mD %$mD.\n" "It has %d points and could store %d more\n" " without using more memory.\n" "It has %d holes and resides on layer %d.\n" "%s"), USER_UNITMASK, Polygon->ID, flags_to_string (Polygon->Flags, POLYGON_TYPE), Polygon->BoundingBox.X1, Polygon->BoundingBox.Y1, Polygon->BoundingBox.X2, Polygon->BoundingBox.Y2, Polygon->PointN, Polygon->PointMax - Polygon->PointN, Polygon->HoleIndexN, GetLayerNumber (PCB->Data, (LayerType *) ptr1), TEST_FLAG (LOCKFLAG, Polygon) ? _("It is LOCKED.\n") : ""); break; } case PAD_TYPE: { Coord len; PadType *Pad; ElementType *element; #ifndef NDEBUG if (gui->shift_is_pressed ()) { __r_dump_tree (PCB->Data->pad_tree->root, 0); return 0; } #endif Pad = (PadType *) ptr2; element = (ElementType *) ptr1; PAD_LOOP (element); { { if (pad == Pad) break; } } END_LOOP; len = Distance (Pad->Point1.X, Pad->Point1.Y, Pad->Point2.X, Pad->Point2.Y); pcb_snprintf (report, sizeof (report), _("%m+PAD ID# %ld; Flags:%s\n" "FirstPoint(X,Y) = %$mD; ID = %ld.\n" "SecondPoint(X,Y) = %$mD; ID = %ld.\n" "Width = %$mS. Length = %$mS.\n" "Clearance width in polygons = %$mS.\n" "Solder mask = %$mS x %$mS (gap = %$mS).\n" "Name = \"%s\".\n" "It is owned by SMD element %s\n" " as pin number %s and is on the %s\n" "side of the board.\n" "%s"), USER_UNITMASK, Pad->ID, flags_to_string (Pad->Flags, PAD_TYPE), Pad->Point1.X, Pad->Point1.Y, Pad->Point1.ID, Pad->Point2.X, Pad->Point2.Y, Pad->Point2.ID, Pad->Thickness, len + Pad->Thickness, Pad->Clearance / 2, Pad->Mask, len + Pad->Mask, (Pad->Mask - Pad->Thickness) / 2, EMPTY (Pad->Name), EMPTY (element->Name[1].TextString), EMPTY (Pad->Number), TEST_FLAG (ONSOLDERFLAG, Pad) ? _("solder (bottom)") : _("component"), TEST_FLAG (LOCKFLAG, Pad) ? _("It is LOCKED.\n") : ""); break; } case ELEMENT_TYPE: { ElementType *element; #ifndef NDEBUG if (gui->shift_is_pressed ()) { __r_dump_tree (PCB->Data->element_tree->root, 0); return 0; } #endif element = (ElementType *) ptr2; pcb_snprintf (report, sizeof (report), _("%m+ELEMENT ID# %ld; Flags:%s\n" "BoundingBox %$mD %$mD.\n" "Descriptive Name \"%s\".\n" "Name on board \"%s\".\n" "Part number name \"%s\".\n" "It is %$mS tall and is located at (X,Y) = %$mD %s.\n" "Mark located at point (X,Y) = %$mD.\n" "It is on the %s side of the board.\n" "%s"), USER_UNITMASK, element->ID, flags_to_string (element->Flags, ELEMENT_TYPE), element->BoundingBox.X1, element->BoundingBox.Y1, element->BoundingBox.X2, element->BoundingBox.Y2, EMPTY (element->Name[0].TextString), EMPTY (element->Name[1].TextString), EMPTY (element->Name[2].TextString), SCALE_TEXT (FONT_CAPHEIGHT, element->Name[1].Scale), element->Name[1].X, element->Name[1].Y, TEST_FLAG (HIDENAMEFLAG, element) ? _(",\n but it's hidden") : "", element->MarkX, element->MarkY, TEST_FLAG (ONSOLDERFLAG, element) ? _("solder (bottom)") : _("component"), TEST_FLAG (LOCKFLAG, element) ? _("It is LOCKED.\n") : ""); break; } case TEXT_TYPE: #ifndef NDEBUG if (gui->shift_is_pressed ()) { LayerType *layer = (LayerType *) ptr1; __r_dump_tree (layer->text_tree->root, 0); return 0; } #endif case ELEMENTNAME_TYPE: { char laynum[32]; TextType *text; #ifndef NDEBUG if (gui->shift_is_pressed ()) { __r_dump_tree (PCB->Data->name_tree[NAME_INDEX (PCB)]->root, 0); return 0; } #endif text = (TextType *) ptr2; if (type == TEXT_TYPE) sprintf (laynum, _("It is on layer %d."), GetLayerNumber (PCB->Data, (LayerType *) ptr1)); pcb_snprintf (report, sizeof (report), _("%m+TEXT ID# %ld; Flags:%s\n" "Located at (X,Y) = %$mD.\n" "Characters are %$mS tall.\n" "Value is \"%s\".\n" "Direction is %d.\n" "The bounding box is %$mD %$mD.\n" "%s\n" "%s"), USER_UNITMASK, text->ID, flags_to_string (text->Flags, TEXT_TYPE), text->X, text->Y, SCALE_TEXT (FONT_CAPHEIGHT, text->Scale), text->TextString, text->Direction, text->BoundingBox.X1, text->BoundingBox.Y1, text->BoundingBox.X2, text->BoundingBox.Y2, (type == TEXT_TYPE) ? laynum : _("It is an element name."), TEST_FLAG (LOCKFLAG, text) ? _("It is LOCKED.\n") : ""); break; } case LINEPOINT_TYPE: case POLYGONPOINT_TYPE: { PointType *point = (PointType *) ptr2; pcb_snprintf (report, sizeof (report), _("%m+POINT ID# %ld.\n" "Located at (X,Y) = %$mD.\n" "It belongs to a %s on layer %d.\n"), USER_UNITMASK, point->ID, point->X, point->Y, (type == LINEPOINT_TYPE) ? C_("report", "line") : C_("report", "polygon"), GetLayerNumber (PCB->Data, (LayerType *) ptr1)); break; } case NO_TYPE: report[0] = '\0'; break; default: sprintf (report, _("Unknown\n")); break; } if (report[0] == '\0') { Message (_("Nothing found to report on\n")); return 1; } /* create dialog box */ gui->report_dialog (_("Report"), report); return 0; }
static int ReportDialog (int argc, char **argv, int x, int y) { void *ptr1, *ptr2, *ptr3; int type, prec = Settings.grid_units_mm? 4: 2; char report[2048]; type = SearchScreen (x, y, REPORT_TYPES, &ptr1, &ptr2, &ptr3); if (type == NO_TYPE) type = SearchScreen (x, y, REPORT_TYPES | LOCKED_TYPE, &ptr1, &ptr2, &ptr3); switch (type) { case VIA_TYPE: { PinTypePtr via; #ifndef NDEBUG if (gui->shift_is_pressed ()) { __r_dump_tree (PCB->Data->via_tree->root, 0); return 0; } #endif via = (PinTypePtr) ptr2; if (TEST_FLAG (HOLEFLAG, via)) sprintf (&report[0], "VIA ID# %ld; Flags:%s\n" "(X,Y) = (%.*f, %.*f) %s.\n" "It is a pure hole of diameter %.*f %s.\n" "Name = \"%s\"." "%s", via->ID, flags_to_string (via->Flags, VIA_TYPE), prec, units (via->X), prec, UNIT (via->Y), prec, UNIT (via->DrillingHole), EMPTY (via->Name), TEST_FLAG (LOCKFLAG, via) ? "It is LOCKED.\n" : ""); else sprintf (&report[0], "VIA ID# %ld; Flags:%s\n" "(X,Y) = (%.*f, %.*f) %s.\n" "Copper width = %0.*f %s. Drill width = %0.*f %s.\n" "Clearance width in polygons = %0.*f %s.\n" "Annulus = %0.*f %s.\n" "Solder mask hole = %0.*f %s (gap = %0.*f %s).\n" "Name = \"%s\"." "%s", via->ID, flags_to_string (via->Flags, VIA_TYPE), prec, units (via->X), prec, UNIT (via->Y), prec, UNIT (via->Thickness), prec, UNIT (via->DrillingHole), prec, UNIT (via->Clearance / 2.), prec, UNIT ((via->Thickness - via->DrillingHole)/2), prec, UNIT (via->Mask), prec, UNIT ((via->Mask - via->Thickness)/2), EMPTY (via->Name), TEST_FLAG (LOCKFLAG, via) ? "It is LOCKED.\n" : ""); break; } case PIN_TYPE: { PinTypePtr Pin; ElementTypePtr element; #ifndef NDEBUG if (gui->shift_is_pressed ()) { __r_dump_tree (PCB->Data->pin_tree->root, 0); return 0; } #endif Pin = (PinTypePtr) ptr2; element = (ElementTypePtr) ptr1; PIN_LOOP (element); { if (pin == Pin) break; } END_LOOP; if (TEST_FLAG (HOLEFLAG, Pin)) sprintf (&report[0], "PIN ID# %ld; Flags:%s\n" "(X,Y) = (%.*f, %.*f) %s.\n" "It is a mounting hole. Drill width = %0.*f %s.\n" "It is owned by element %s.\n" "%s", Pin->ID, flags_to_string (Pin->Flags, PIN_TYPE), prec, units (Pin->X), prec, UNIT (Pin->Y), prec, UNIT (Pin->DrillingHole), EMPTY (element->Name[1].TextString), TEST_FLAG (LOCKFLAG, Pin) ? "It is LOCKED.\n" : ""); else sprintf (&report[0], "PIN ID# %ld; Flags:%s\n" "(X,Y) = (%.*f, %.*f) %s.\n" "Copper width = %0.*f %s. Drill width = %0.*f %s.\n" "Clearance width to Polygon = %0.*f %s.\n" "Annulus = %0.*f %s.\n" "Solder mask hole = %0.*f %s (gap = %0.*f %s).\n" "Name = \"%s\".\n" "It is owned by element %s\n as pin number %s.\n" "%s", Pin->ID, flags_to_string (Pin->Flags, PIN_TYPE), prec, units(Pin->X), prec, UNIT(Pin->Y), prec, UNIT (Pin->Thickness), prec, UNIT (Pin->DrillingHole), prec, UNIT (Pin->Clearance / 2.), prec, UNIT ((Pin->Thickness - Pin->DrillingHole)/2), prec, UNIT (Pin->Mask), prec, UNIT ((Pin->Mask - Pin->Thickness)/2), EMPTY (Pin->Name), EMPTY (element->Name[1].TextString), EMPTY (Pin->Number), TEST_FLAG (LOCKFLAG, Pin) ? "It is LOCKED.\n" : ""); break; } case LINE_TYPE: { LineTypePtr line; #ifndef NDEBUG if (gui->shift_is_pressed ()) { LayerTypePtr layer = (LayerTypePtr) ptr1; __r_dump_tree (layer->line_tree->root, 0); return 0; } #endif line = (LineTypePtr) ptr2; sprintf (&report[0], "LINE ID# %ld; Flags:%s\n" "FirstPoint(X,Y) = (%.*f, %.*f) %s, ID = %ld.\n" "SecondPoint(X,Y) = (%.*f, %.*f) %s, ID = %ld.\n" "Width = %0.*f %s.\nClearance width in polygons = %0.*f %s.\n" "It is on layer %d\n" "and has name \"%s\".\n" "%s", line->ID, flags_to_string (line->Flags, LINE_TYPE), prec, units (line->Point1.X), prec, UNIT (line->Point1.Y), line->Point1.ID, prec, units (line->Point2.X), prec, UNIT (line->Point2.Y), line->Point2.ID, prec, UNIT (line->Thickness), prec, UNIT (line->Clearance / 2.), GetLayerNumber (PCB->Data, (LayerTypePtr) ptr1), UNKNOWN (line->Number), TEST_FLAG (LOCKFLAG, line) ? "It is LOCKED.\n" : ""); break; } case RATLINE_TYPE: { RatTypePtr line; #ifndef NDEBUG if (gui->shift_is_pressed ()) { __r_dump_tree (PCB->Data->rat_tree->root, 0); return 0; } #endif line = (RatTypePtr) ptr2; sprintf (&report[0], "RAT-LINE ID# %ld; Flags:%s\n" "FirstPoint(X,Y) = (%.*f, %.*f) %s; ID = %ld; " "connects to layer group %d.\n" "SecondPoint(X,Y) = (%.*f, %.*f) %s; ID = %ld; " "connects to layer group %d.\n", line->ID, flags_to_string (line->Flags, LINE_TYPE), prec, units (line->Point1.X), prec, UNIT (line->Point1.Y), line->Point1.ID, line->group1, prec, units (line->Point2.X), prec, UNIT (line->Point2.Y), line->Point2.ID, line->group2); break; } case ARC_TYPE: { ArcTypePtr Arc; BoxTypePtr box; #ifndef NDEBUG if (gui->shift_is_pressed ()) { LayerTypePtr layer = (LayerTypePtr) ptr1; __r_dump_tree (layer->arc_tree->root, 0); return 0; } #endif Arc = (ArcTypePtr) ptr2; box = GetArcEnds (Arc); sprintf (&report[0], "ARC ID# %ld; Flags:%s\n" "CenterPoint(X,Y) = (%.*f, %.*f) %s.\n" "Radius = %0.*f %s, Thickness = %0.*f %s.\n" "Clearance width in polygons = %0.*f %s.\n" "StartAngle = %ld degrees, DeltaAngle = %ld degrees.\n" "Bounding Box is (%.*f,%.*f), (%.*f,%.*f) %s.\n" "That makes the end points at (%.*f,%.*f) %s and (%.*f,%.*f) %s.\n" "It is on layer %d.\n" "%s", Arc->ID, flags_to_string (Arc->Flags, ARC_TYPE), prec, units(Arc->X), prec, UNIT(Arc->Y), prec, UNIT (Arc->Width), prec, UNIT (Arc->Thickness), prec, UNIT (Arc->Clearance / 2.), Arc->StartAngle, Arc->Delta, prec, units (Arc->BoundingBox.X1), prec, units (Arc->BoundingBox.Y1), prec, units (Arc->BoundingBox.X2), prec, UNIT (Arc->BoundingBox.Y2), prec, units (box->X1), prec, UNIT (box->Y1), prec, units (box->X2), prec, UNIT (box->Y2), GetLayerNumber (PCB->Data, (LayerTypePtr) ptr1), TEST_FLAG (LOCKFLAG, Arc) ? "It is LOCKED.\n" : ""); break; } case POLYGON_TYPE: { PolygonTypePtr Polygon; #ifndef NDEBUG if (gui->shift_is_pressed ()) { LayerTypePtr layer = (LayerTypePtr) ptr1; __r_dump_tree (layer->polygon_tree->root, 0); return 0; } #endif Polygon = (PolygonTypePtr) ptr2; sprintf (&report[0], "POLYGON ID# %ld; Flags:%s\n" "Its bounding box is (%.*f,%.*f) (%.*f,%.*f) %s.\n" "It has %d points and could store %d more\n" " without using more memory.\n" "It has %d holes and resides on layer %d.\n" "%s", Polygon->ID, flags_to_string (Polygon->Flags, POLYGON_TYPE), prec, units(Polygon->BoundingBox.X1), prec, units(Polygon->BoundingBox.Y1), prec, units(Polygon->BoundingBox.X2), prec, UNIT(Polygon->BoundingBox.Y2), Polygon->PointN, Polygon->PointMax - Polygon->PointN, Polygon->HoleIndexN, GetLayerNumber (PCB->Data, (LayerTypePtr) ptr1), TEST_FLAG (LOCKFLAG, Polygon) ? "It is LOCKED.\n" : ""); break; } case PAD_TYPE: { int len, dx, dy, mgap; PadTypePtr Pad; ElementTypePtr element; #ifndef NDEBUG if (gui->shift_is_pressed ()) { __r_dump_tree (PCB->Data->pad_tree->root, 0); return 0; } #endif Pad = (PadTypePtr) ptr2; element = (ElementTypePtr) ptr1; PAD_LOOP (element); { { if (pad == Pad) break; } } END_LOOP; dx = Pad->Point1.X - Pad->Point2.X; dy = Pad->Point1.Y - Pad->Point2.Y; len = sqrt (dx*dx+dy*dy); mgap = (Pad->Mask - Pad->Thickness)/2; sprintf (&report[0], "PAD ID# %ld; Flags:%s\n" "FirstPoint(X,Y) = (%.*f, %.*f) %s; ID = %ld.\n" "SecondPoint(X,Y) = (%.*f, %.*f) %s; ID = %ld.\n" "Width = %0.*f %s. Length = %0.*f %s.\n" "Clearance width in polygons = %0.*f %s.\n" "Solder mask = %0.*f x %0.*f %s (gap = %0.*f %s).\n" "Name = \"%s\".\n" "It is owned by SMD element %s\n" " as pin number %s and is on the %s\n" "side of the board.\n" "%s", Pad->ID, flags_to_string (Pad->Flags, PAD_TYPE), prec, units (Pad->Point1.X), prec, UNIT (Pad->Point1.Y), Pad->Point1.ID, prec, units (Pad->Point2.X), prec, UNIT (Pad->Point2.Y), Pad->Point2.ID, prec, UNIT (Pad->Thickness), prec, UNIT (len + Pad->Thickness), prec, UNIT (Pad->Clearance / 2.), prec, units (Pad->Mask), prec, UNIT (Pad->Mask + len), prec, UNIT (mgap), EMPTY (Pad->Name), EMPTY (element->Name[1].TextString), EMPTY (Pad->Number), TEST_FLAG (ONSOLDERFLAG, Pad) ? "solder (bottom)" : "component", TEST_FLAG (LOCKFLAG, Pad) ? "It is LOCKED.\n" : ""); break; } case ELEMENT_TYPE: { ElementTypePtr element; #ifndef NDEBUG if (gui->shift_is_pressed ()) { __r_dump_tree (PCB->Data->element_tree->root, 0); return 0; } #endif element = (ElementTypePtr) ptr2; sprintf (&report[0], "ELEMENT ID# %ld; Flags:%s\n" "BoundingBox (%.*f,%.*f) (%.*f,%.*f) %s.\n" "Descriptive Name \"%s\".\n" "Name on board \"%s\".\n" "Part number name \"%s\".\n" "It is %.*f %s tall and is located at (X,Y) = (%.*f,%.*f)%s.\n" "Mark located at point (X,Y) = (%.*f,%.*f).\n" "It is on the %s side of the board.\n" "%s", element->ID, flags_to_string (element->Flags, ELEMENT_TYPE), prec, units(element->BoundingBox.X1), prec, units (element->BoundingBox.Y1), prec, units(element->BoundingBox.X2), prec, UNIT (element->BoundingBox.Y2), EMPTY (element->Name[0].TextString), EMPTY (element->Name[1].TextString), EMPTY (element->Name[2].TextString), prec, UNIT (0.45 * element->Name[1].Scale * 100.), prec, units(element->Name[1].X), prec, units(element->Name[1].Y), TEST_FLAG (HIDENAMEFLAG, element) ? ",\n but it's hidden" : "", prec, units(element->MarkX), prec, units(element->MarkY), TEST_FLAG (ONSOLDERFLAG, element) ? "solder (bottom)" : "component", TEST_FLAG (LOCKFLAG, element) ? "It is LOCKED.\n" : ""); break; } case TEXT_TYPE: #ifndef NDEBUG if (gui->shift_is_pressed ()) { LayerTypePtr layer = (LayerTypePtr) ptr1; __r_dump_tree (layer->text_tree->root, 0); return 0; } #endif case ELEMENTNAME_TYPE: { char laynum[32]; TextTypePtr text; #ifndef NDEBUG if (gui->shift_is_pressed ()) { __r_dump_tree (PCB->Data->name_tree[NAME_INDEX (PCB)]->root, 0); return 0; } #endif text = (TextTypePtr) ptr2; if (type == TEXT_TYPE) sprintf (laynum, "It is on layer %d.", GetLayerNumber (PCB->Data, (LayerTypePtr) ptr1)); sprintf (&report[0], "TEXT ID# %ld; Flags:%s\n" "Located at (X,Y) = (%.*f,%.*f) %s.\n" "Characters are %0.*f %s tall.\n" "Value is \"%s\".\n" "Direction is %d.\n" "The bounding box is (%.*f,%.*f) (%.*f, %.*f) %s.\n" "%s\n" "%s", text->ID, flags_to_string (text->Flags, TEXT_TYPE), prec, units(text->X), prec, UNIT (text->Y), prec, UNIT (0.45 * text->Scale * 100.), text->TextString, text->Direction, prec, units(text->BoundingBox.X1), prec, units(text->BoundingBox.Y1), prec, units(text->BoundingBox.X2), prec, UNIT (text->BoundingBox.Y2), (type == TEXT_TYPE) ? laynum : "It is an element name.", TEST_FLAG (LOCKFLAG, text) ? "It is LOCKED.\n" : ""); break; } case LINEPOINT_TYPE: case POLYGONPOINT_TYPE: { PointTypePtr point = (PointTypePtr) ptr2; sprintf (&report[0], "POINT ID# %ld.\n" "Located at (X,Y) = (%.*f,%.*f) %s.\n" "It belongs to a %s on layer %d.\n", point->ID, prec, units (point->X), prec, UNIT (point->Y), (type == LINEPOINT_TYPE) ? "line" : "polygon", GetLayerNumber (PCB->Data, (LayerTypePtr) ptr1)); break; } case NO_TYPE: report[0] = '\0'; break; default: sprintf (&report[0], "Unknown\n"); break; } if (report[0] == '\0') { Message (_("Nothing found to report on\n")); return 1; } HideCrosshair (false); /* create dialog box */ gui->report_dialog ("Report", &report[0]); RestoreCrosshair (false); return 0; }
static char * describe_location (Coord X, Coord Y) { void *ptr1, *ptr2, *ptr3; int type; int Range = 0; char *elename = ""; char *pinname; char *netname = NULL; char *description; /* check if there are any pins or pads at that position */ type = SearchObjectByLocation (PIN_TYPE | PAD_TYPE, &ptr1, &ptr2, &ptr3, X, Y, Range); if (type == NO_TYPE) return NULL; /* don't mess with silk objects! */ if (type & SILK_TYPE && GetLayerNumber (PCB->Data, (LayerType *) ptr1) >= max_copper_layer) return NULL; if (type == PIN_TYPE || type == PAD_TYPE) elename = (char *)UNKNOWN (NAMEONPCB_NAME ((ElementType *) ptr1)); pinname = ConnectionName (type, ptr1, ptr2); if (pinname == NULL) return NULL; /* Find netlist entry */ MENU_LOOP (&PCB->NetlistLib); { if (!menu->Name) continue; ENTRY_LOOP (menu); { if (!entry->ListEntry) continue; if (strcmp (entry->ListEntry, pinname) == 0) { netname = g_strdup (menu->Name); /* For some reason, the netname has spaces in front of it, strip them */ g_strstrip (netname); break; } } END_LOOP; if (netname != NULL) break; } END_LOOP; description = g_strdup_printf ("Element name: %s\n" "Pinname : %s\n" "Netname : %s", elename, (pinname != NULL) ? pinname : "--", (netname != NULL) ? netname : "--"); g_free (netname); return description; }
/*! * \brief Lookup all lines that are connected to an object and save the * data to 'Crosshair.AttachedObject.Rubberband'. * * Lookup is only done for visible layers. */ void LookupRubberbandLines (int Type, void *Ptr1, void *Ptr2, void *Ptr3) { /* the function is only supported for some types * check all visible lines; * it is only necessary to check if one of the endpoints * is connected */ switch (Type) { case ELEMENT_TYPE: { ElementType *element = (ElementType *) Ptr1; /* square pins are handled as if they are round. Speed * and readability is more important then the few % * of failures that are immediately recognized */ PIN_LOOP (element); { CheckPinForRubberbandConnection (pin); } END_LOOP; PAD_LOOP (element); { CheckPadForRubberbandConnection (pad); } END_LOOP; break; } case LINE_TYPE: { LayerType *layer = (LayerType *) Ptr1; LineType *line = (LineType *) Ptr2; if (GetLayerNumber (PCB->Data, layer) < max_copper_layer) { CheckLinePointForRubberbandConnection (layer, line, &line->Point1, false); CheckLinePointForRubberbandConnection (layer, line, &line->Point2, false); } break; } case LINEPOINT_TYPE: if (GetLayerNumber (PCB->Data, (LayerType *) Ptr1) < max_copper_layer) CheckLinePointForRubberbandConnection ((LayerType *) Ptr1, (LineType *) Ptr2, (PointType *) Ptr3, true); break; case ARC_TYPE: { LayerType *layer = (LayerType *) Ptr1; ArcType *arc = (ArcType *) Ptr2; if (GetLayerNumber (PCB->Data, layer) < max_copper_layer) { CheckArcPointForRubberbandConnection (layer, arc, &arc->Point1, false); CheckArcPointForRubberbandConnection (layer, arc, &arc->Point2, false); } break; } case VIA_TYPE: CheckPinForRubberbandConnection ((PinType *) Ptr1); break; case POLYGON_TYPE: if (GetLayerNumber (PCB->Data, (LayerType *) Ptr1) < max_copper_layer) CheckPolygonForRubberbandConnection ((LayerType *) Ptr1, (PolygonType *) Ptr2); break; } }