void SCH_TEXT::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems, SCH_SHEET_PATH* aSheetPath ) { if( GetLayer() == LAYER_NOTES || GetLayer() == LAYER_SHEETLABEL ) return; NETLIST_OBJECT* item = new NETLIST_OBJECT(); item->m_SheetList = *aSheetPath; item->m_SheetListInclude = *aSheetPath; item->m_Comp = (SCH_ITEM*) this; item->m_Type = NET_LABEL; if( GetLayer() == LAYER_GLOBLABEL ) item->m_Type = NET_GLOBLABEL; else if( GetLayer() == LAYER_HIERLABEL ) item->m_Type = NET_HIERLABEL; item->m_Label = m_Text; item->m_Start = item->m_End = m_Pos; aNetListItems.push_back( item ); /* If a bus connects to label */ if( IsBusLabel( m_Text ) ) item->ConvertBusToNetListItems( aNetListItems ); }
void SCH_SHEET::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) { SCH_SHEET_PATH sheetPath = *aSheetPath; sheetPath.push_back( this ); for( size_t i = 0; i < m_pins.size(); i++ ) { NETLIST_OBJECT* item = new NETLIST_OBJECT(); item->m_SheetPathInclude = sheetPath; item->m_SheetPath = *aSheetPath; item->m_Comp = &m_pins[i]; item->m_Link = this; item->m_Type = NET_SHEETLABEL; item->m_Label = m_pins[i].GetText(); item->m_Start = item->m_End = m_pins[i].GetPosition(); aNetListItems.push_back( item ); if( IsBusLabel( m_pins[i].GetText() ) ) item->ConvertBusToNetListItems( aNetListItems ); } }
void NETLIST_OBJECT::ConvertBusToNetListItems( NETLIST_OBJECT_LIST& aNetListItems ) { wxCHECK_RET( IsBusLabel( m_Label ), wxT( "<" ) + m_Label + wxT( "> is not a valid bus label." ) ); if( m_Type == NET_HIERLABEL ) m_Type = NET_HIERBUSLABELMEMBER; else if( m_Type == NET_GLOBLABEL ) m_Type = NET_GLOBBUSLABELMEMBER; else if( m_Type == NET_SHEETLABEL ) m_Type = NET_SHEETBUSLABELMEMBER; else if( m_Type == NET_LABEL ) m_Type = NET_BUSLABELMEMBER; else wxCHECK_RET( false, wxT( "Net list object type is not valid." ) ); unsigned i; wxString tmp, busName, busNumber; long begin, end, member; busName = busLabelRe.GetMatch( m_Label, 1 ); busNumber = busLabelRe.GetMatch( m_Label, 2 ); /* Search for '[' because a bus label is like "busname[nn..mm]" */ i = busNumber.Find( '[' ); i++; while( i < busNumber.Len() && busNumber[i] != '.' ) { tmp.Append( busNumber[i] ); i++; } tmp.ToLong( &begin ); while( i < busNumber.Len() && busNumber[i] == '.' ) i++; tmp.Empty(); while( i < busNumber.Len() && busNumber[i] != ']' ) { tmp.Append( busNumber[i] ); i++; } tmp.ToLong( &end ); if( begin < 0 ) begin = 0; if( end < 0 ) end = 0; if( begin > end ) std::swap( begin, end ); member = begin; tmp = busName; tmp << member; m_Label = tmp; m_Member = member; for( member++; member <= end; member++ ) { NETLIST_OBJECT* item = new NETLIST_OBJECT( *this ); // Conversion of bus label to the root name + the current member id. tmp = busName; tmp << member; item->m_Label = tmp; item->m_Member = member; aNetListItems.push_back( item ); } }
bool SCH_SCREEN::IsTerminalPoint( const wxPoint& aPosition, int aLayer ) { wxCHECK_MSG( aLayer == LAYER_NOTES || aLayer == LAYER_BUS || aLayer == LAYER_WIRE, false, wxT( "Invalid layer type passed to SCH_SCREEN::IsTerminalPoint()." ) ); SCH_SHEET_PIN* label; SCH_TEXT* text; switch( aLayer ) { case LAYER_BUS: if( GetBus( aPosition ) ) return true; label = GetSheetLabel( aPosition ); if( label && IsBusLabel( label->GetText() ) && label->IsConnected( aPosition ) ) return true; text = GetLabel( aPosition ); if( text && IsBusLabel( text->GetText() ) && text->IsConnected( aPosition ) && (text->Type() != SCH_LABEL_T) ) return true; break; case LAYER_NOTES: if( GetLine( aPosition ) ) return true; break; case LAYER_WIRE: if( GetItem( aPosition, std::max( GetDefaultLineThickness(), 3 ), SCH_BUS_WIRE_ENTRY_T) ) return true; if( GetItem( aPosition, std::max( GetDefaultLineThickness(), 3 ), SCH_BUS_BUS_ENTRY_T) ) return true; if( GetItem( aPosition, std::max( GetDefaultLineThickness(), 3 ), SCH_JUNCTION_T ) ) return true; if( GetPin( aPosition, NULL, true ) ) return true; if( GetWire( aPosition ) ) return true; text = GetLabel( aPosition ); if( text && text->IsConnected( aPosition ) && !IsBusLabel( text->GetText() ) ) return true; label = GetSheetLabel( aPosition ); if( label && label->IsConnected( aPosition ) && !IsBusLabel( label->GetText() ) ) return true; break; default: break; } return false; }
static bool IsTerminalPoint(SCH_SCREEN * screen, const wxPoint & pos, int layer) /***************************************************************************/ /* Returne TRUE si pos est un point possible pour terminer automatiquement un segment, c'est a dire pour - type WIRE, si il y a - une jonction - ou une pin - ou une extrémité unique de fil - type BUS, si il y a - ou une extrémité unique de BUS */ { EDA_BaseStruct * item; LibDrawPin * pin; DrawLibItemStruct * LibItem = NULL; DrawSheetLabelStruct * pinsheet; wxPoint itempos; switch ( layer ) { case LAYER_BUS: item = PickStruct(screen, BUSITEM); if ( item ) return TRUE; pinsheet = LocateAnyPinSheet(pos, screen->EEDrawList ); if ( pinsheet && IsBusLabel(pinsheet->GetText()) ) { itempos = pinsheet->m_Pos; if ( (itempos.x == pos.x) && (itempos.y == pos.y) ) return TRUE; } break; case LAYER_NOTES: item = PickStruct(screen, DRAWITEM); if ( item ) return TRUE; break; case LAYER_WIRE: item = PickStruct(screen, RACCORDITEM |JUNCTIONITEM); if ( item ) return TRUE; pin = LocateAnyPin( screen->EEDrawList, pos, &LibItem ); if ( pin && LibItem ) { // calcul de la position exacte du point de connexion de la pin, // selon orientation du composant: itempos = LibItem->GetScreenCoord(pin->m_Pos); itempos.x += LibItem->m_Pos.x; itempos.y += LibItem->m_Pos.y; if ( (itempos.x == pos.x) && (itempos.y == pos.y) ) return TRUE; } item = PickStruct(screen, WIREITEM); if ( item ) return TRUE; item = PickStruct(screen, LABELITEM); if ( item && (item->m_StructType != DRAW_TEXT_STRUCT_TYPE) && ( ((DrawGlobalLabelStruct*)item)->m_Pos.x == pos.x) && ( ((DrawGlobalLabelStruct*)item)->m_Pos.y == pos.y) ) return TRUE; pinsheet = LocateAnyPinSheet( pos, screen->EEDrawList ); if ( pinsheet && ! IsBusLabel(pinsheet->GetText()) ) { itempos = pinsheet->m_Pos; if ( (itempos.x == pos.x) && (itempos.y == pos.y) ) return TRUE; } break; default: break; } return FALSE; }
/* Routine generant la liste des objets relatifs aux connection entree: Window: pointeur sur l'ecran a traiter ObjNet: si NULL: la routine compte seulement le nombre des objets sinon: pointe le tableau a remplir */ static int ListeObjetConnection(wxWindow * frame, SCH_SCREEN *Window, ObjetNetListStruct *ObjNet) { int ii, NbrItem = 0, NumSheet; EDA_BaseStruct *DrawList; EDA_SchComponentStruct *DrawLibItem; int TransMat[2][2], PartX, PartY, x2, y2; EDA_LibComponentStruct *Entry; LibEDA_BaseStruct *DEntry; DrawSheetLabelStruct *SheetLabel; SCH_SCREEN * ScreenInclude; int NumInclude; NumSheet = Window->m_SheetNumber; DrawList = Window->EEDrawList; while ( DrawList ) { switch( DrawList->m_StructType ) { case DRAW_SEGMENT_STRUCT_TYPE : #undef STRUCT #define STRUCT ((EDA_DrawLineStruct *) DrawList) if( ObjNet) { if ( (STRUCT->m_Layer != LAYER_BUS) && (STRUCT->m_Layer != LAYER_WIRE) ) break; ObjNet[NbrItem].m_Comp = STRUCT; ObjNet[NbrItem].m_Window = Window; ObjNet[NbrItem].m_SheetNumber = NumSheet; ObjNet[NbrItem].m_Start = STRUCT->m_Start; ObjNet[NbrItem].m_End = STRUCT->m_End; if (STRUCT->m_Layer == LAYER_BUS) { ObjNet[NbrItem].m_Type = NET_BUS; } else /* Cas des WIRE */ { ObjNet[NbrItem].m_Type = NET_SEGMENT; } } NbrItem++; break; case DRAW_JUNCTION_STRUCT_TYPE : #undef STRUCT #define STRUCT ((DrawJunctionStruct *) DrawList) if( ObjNet) { ObjNet[NbrItem].m_Comp = STRUCT; ObjNet[NbrItem].m_Window = Window; ObjNet[NbrItem].m_Type = NET_JONCTION; ObjNet[NbrItem].m_SheetNumber = NumSheet; ObjNet[NbrItem].m_Start = STRUCT->m_Pos; ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start; } NbrItem++; break; case DRAW_NOCONNECT_STRUCT_TYPE : #undef STRUCT #define STRUCT ((DrawNoConnectStruct *) DrawList) if( ObjNet) { ObjNet[NbrItem].m_Comp = STRUCT; ObjNet[NbrItem].m_Window = Window; ObjNet[NbrItem].m_Type = NET_NOCONNECT; ObjNet[NbrItem].m_SheetNumber = NumSheet; ObjNet[NbrItem].m_Start = STRUCT->m_Pos; ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start; } NbrItem++; break; case DRAW_LABEL_STRUCT_TYPE : #undef STRUCT #define STRUCT ((DrawLabelStruct *) DrawList) ii = IsBusLabel( STRUCT->m_Text.GetData()); if( ObjNet) { ObjNet[NbrItem].m_Comp = STRUCT; ObjNet[NbrItem].m_Window = Window; ObjNet[NbrItem].m_Type = NET_LABEL; if (STRUCT->m_Layer == LAYER_GLOBLABEL) ObjNet[NbrItem].m_Type = NET_GLOBLABEL; ObjNet[NbrItem].m_Label = STRUCT->m_Text.GetData(); ObjNet[NbrItem].m_SheetNumber = NumSheet; ObjNet[NbrItem].m_Start = STRUCT->m_Pos; ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start; /* Si c'est un Bus, eclatement en Label */ if ( ii ) EclateBus(ObjNet + NbrItem); } NbrItem += ii+1; break; case DRAW_GLOBAL_LABEL_STRUCT_TYPE : #undef STRUCT #define STRUCT ((DrawGlobalLabelStruct *) DrawList) ii = IsBusLabel( STRUCT->m_Text.GetData()); if( ObjNet) { ObjNet[NbrItem].m_Comp = STRUCT; ObjNet[NbrItem].m_Window = Window; ObjNet[NbrItem].m_Type = NET_LABEL; if (STRUCT->m_Layer == LAYER_GLOBLABEL) ObjNet[NbrItem].m_Type = NET_GLOBLABEL; ObjNet[NbrItem].m_Label = STRUCT->m_Text.GetData(); ObjNet[NbrItem].m_SheetNumber = NumSheet; ObjNet[NbrItem].m_Start = STRUCT->m_Pos; ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start; /* Si c'est un Bus, eclatement en Label */ if ( ii ) EclateBus(ObjNet + NbrItem); } NbrItem += ii+1; break; case DRAW_LIB_ITEM_STRUCT_TYPE : DrawLibItem = (EDA_SchComponentStruct *) DrawList; memcpy(TransMat, DrawLibItem->m_Transform, sizeof(TransMat)); PartX = DrawLibItem->m_Pos.x; PartY = DrawLibItem->m_Pos.y; Entry = FindLibPart(DrawLibItem->m_ChipName, "", FIND_ROOT); if( Entry == NULL) break; if(Entry->m_Drawings == NULL) break ; DEntry = Entry->m_Drawings; for ( ;DEntry != NULL; DEntry = DEntry->Next()) { LibDrawPin * Pin = (LibDrawPin *) DEntry; if( DEntry->m_StructType != COMPONENT_PIN_DRAW_TYPE) continue; if( DEntry->m_Unit && (DEntry->m_Unit != DrawLibItem->m_Multi) ) continue; if( DEntry->m_Convert && (DEntry->m_Convert != DrawLibItem->m_Convert)) continue; x2 = PartX + TransMat[0][0] * Pin->m_Pos.x + TransMat[0][1] * Pin->m_Pos.y; y2 = PartY + TransMat[1][0] * Pin->m_Pos.x + TransMat[1][1] * Pin->m_Pos.y; if( ObjNet) { ObjNet[NbrItem].m_Comp = DEntry; ObjNet[NbrItem].m_Type = NET_PIN; ObjNet[NbrItem].m_Link = DrawLibItem; ObjNet[NbrItem].m_Window = Window; ObjNet[NbrItem].m_ElectricalType = Pin->m_PinType; ObjNet[NbrItem].m_PinNum = Pin->m_PinNum; ObjNet[NbrItem].m_Label = (char*)Pin->m_PinName.GetData(); ObjNet[NbrItem].m_SheetNumber = NumSheet; ObjNet[NbrItem].m_Start.x = x2; ObjNet[NbrItem].m_Start.y = y2; ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start; } NbrItem++; if( ( (int) Pin->m_PinType == (int) PIN_POWER_IN ) && ( Pin->m_Attributs & PINNOTDRAW ) ) { /* Il y a un PIN_LABEL Associe */ if( ObjNet) { ObjNet[NbrItem].m_Comp = NULL; ObjNet[NbrItem].m_Type = NET_PINLABEL; ObjNet[NbrItem].m_Window = Window; ObjNet[NbrItem].m_SheetNumber = NumSheet; ObjNet[NbrItem].m_Label = (char*)Pin->m_PinName.GetData(); ObjNet[NbrItem].m_Start.x = x2; ObjNet[NbrItem].m_Start.y = y2; ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start; } NbrItem++; } } break; case DRAW_PICK_ITEM_STRUCT_TYPE : case DRAW_POLYLINE_STRUCT_TYPE : case DRAW_BUSENTRY_STRUCT_TYPE : case DRAW_MARKER_STRUCT_TYPE : case DRAW_TEXT_STRUCT_TYPE : break; case DRAW_SHEET_STRUCT_TYPE : #undef STRUCT #define STRUCT ((DrawSheetStruct *) DrawList) ScreenInclude = (SCH_SCREEN*) STRUCT->m_Son; if( ScreenInclude ) NumInclude = ScreenInclude->m_SheetNumber; else NumInclude = 0; SheetLabel = STRUCT->m_Label; for ( ; SheetLabel != NULL; SheetLabel = (DrawSheetLabelStruct*) SheetLabel->Pnext) { ii = IsBusLabel(SheetLabel->m_Text.GetData()); if( ObjNet) { ObjNet[NbrItem].m_Comp = SheetLabel; ObjNet[NbrItem].m_Link = DrawList; ObjNet[NbrItem].m_Type = NET_SHEETLABEL; ObjNet[NbrItem].m_Window = Window; ObjNet[NbrItem].m_ElectricalType = SheetLabel->m_Shape; ObjNet[NbrItem].m_Label = SheetLabel->m_Text.GetData(); ObjNet[NbrItem].m_SheetNumber = NumSheet; ObjNet[NbrItem].m_NumInclude = NumInclude; ObjNet[NbrItem].m_Start = SheetLabel->m_Pos; ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start; /* Si c'est un Bus, eclatement en Label */ if ( ii ) EclateBus(ObjNet + NbrItem); } NbrItem += ii+1; } break; case DRAW_SHEETLABEL_STRUCT_TYPE : DisplayError(frame, " Netlist: Type DRAW_SHEETLABEL inattendu"); break; default: { char BufLine[1024]; sprintf(BufLine," Netlist: Type struct %d inattendu", DrawList->m_StructType); DisplayError(frame, BufLine); break; } } DrawList = DrawList->Pnext; } return(NbrItem); }