void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList, const wxPoint& aMoveVector ) { for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) { SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii ); item->Move( aMoveVector ); } }
bool WriteDiagnosticERC( const wxString& aFullFileName ) { wxString msg; wxFFile file( aFullFileName, wxT( "wt" ) ); if( !file.IsOpened() ) return false; msg = _( "ERC report" ); msg << wxT(" (") << DateAndTime() << wxT( ", " ) << _( "Encoding UTF8" ) << wxT( " )\n" ); int err_count = 0; int warn_count = 0; int total_count = 0; SCH_SHEET_LIST sheetList; SCH_SHEET_PATH* sheet; for( sheet = sheetList.GetFirst(); sheet != NULL; sheet = sheetList.GetNext() ) { msg << wxString::Format( _( "\n***** Sheet %s\n" ), GetChars( sheet->PathHumanReadable() ) ); for( SCH_ITEM* item = sheet->LastDrawList(); item != NULL; item = item->Next() ) { if( item->Type() != SCH_MARKER_T ) continue; SCH_MARKER* marker = (SCH_MARKER*) item; if( marker->GetMarkerType() != MARKER_BASE::MARKER_ERC ) continue; total_count++; if( marker->GetErrorLevel() == MARKER_BASE::MARKER_SEVERITY_ERROR ) err_count++; if( marker->GetErrorLevel() == MARKER_BASE::MARKER_SEVERITY_WARNING ) warn_count++; msg << marker->GetReporter().ShowReport(); } } msg << wxString::Format( _( "\n ** ERC messages: %d Errors %d Warnings %d\n" ), total_count, err_count, warn_count ); // Currently: write report unsing UTF8 (as usual in Kicad). // TODO: see if we can use the current encoding page (mainly for Windows users), // Or other format (HTML?) file.Write( msg ); // wxFFile dtor will close the file. return true; }
void DIALOG_ERC::OnLeftClickMarkersList( wxHtmlLinkEvent& event ) { wxString link = event.GetLinkInfo().GetHref(); m_lastMarkerFound = NULL; long index; if( !link.ToLong( &index ) ) return; const SCH_MARKER* marker = m_MarkersList->GetItem( index ); if( marker == NULL ) return; // Search for the selected marker SCH_SHEET_PATH* sheet; SCH_SHEET_LIST SheetList; bool notFound = true; for( sheet = SheetList.GetFirst(); sheet; sheet = SheetList.GetNext() ) { SCH_ITEM* item = (SCH_ITEM*) sheet->LastDrawList(); for( ; item; item = item->Next() ) { if( item == marker ) { notFound = false; break; } } if( notFound == false ) break; } if( notFound ) // Error { wxMessageBox( _( "Marker not found" ) ); // The marker was deleted, so rebuild marker list DisplayERC_MarkersList(); return; } if( *sheet != m_parent->GetCurrentSheet() ) { sheet->LastScreen()->SetZoom( m_parent->GetScreen()->GetZoom() ); m_parent->SetCurrentSheet( *sheet ); m_parent->GetCurrentSheet().UpdateAllScreenReferences(); } m_lastMarkerFound = marker; m_parent->SetCrossHairPosition( marker->m_Pos ); m_parent->RedrawScreen( marker->m_Pos, false); }
void SCH_EDIT_FRAME::OnSelectUnit( wxCommandEvent& aEvent ) { SCH_SCREEN* screen = GetScreen(); SCH_ITEM* item = screen->GetCurItem(); wxCHECK_RET( item != NULL && item->Type() == SCH_COMPONENT_T, wxT( "Cannot select unit of invalid schematic item." ) ); INSTALL_UNBUFFERED_DC( dc, m_canvas ); m_canvas->MoveCursorToCrossHair(); SCH_COMPONENT* component = (SCH_COMPONENT*) item; int unit = aEvent.GetId() + 1 - ID_POPUP_SCH_SELECT_UNIT1; LIB_PART* part = GetLibPart( component->GetLibId() ); if( !part ) return; int unitCount = part->GetUnitCount(); wxCHECK_RET( (unit >= 1) && (unit <= unitCount), wxString::Format( wxT( "Cannot select unit %d from component " ), unit ) + part->GetName() ); if( unitCount <= 1 || component->GetUnit() == unit ) return; if( unit > unitCount ) unit = unitCount; STATUS_FLAGS flags = component->GetFlags(); if( !flags ) // No command in progress: save in undo list SaveCopyInUndoList( component, UR_CHANGED ); if( flags ) component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode, g_GhostColor ); else component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode ); /* Update the unit number. */ component->SetUnitSelection( m_CurrentSheet, unit ); component->SetUnit( unit ); component->ClearFlags(); component->SetFlags( flags ); // Restore m_Flag modified by SetUnit() if( m_autoplaceFields ) component->AutoAutoplaceFields( GetScreen() ); if( screen->TestDanglingEnds() ) m_canvas->Refresh(); OnModify(); }
void MirrorX( PICKED_ITEMS_LIST& aItemsList, const wxPoint& aMirrorPoint ) { for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) { SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii ); item->MirrorX( aMirrorPoint.y ); // Place it in its new position. item->ClearFlags(); } }
void RotateListOfItems( PICKED_ITEMS_LIST& aItemsList, const wxPoint& rotationPoint ) { for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) { SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii ); item->Rotate( rotationPoint ); // Place it in its new position. item->ClearFlags(); } }
/* note: SCH_SCREEN::Plot is useful only for schematic. * library editor and library viewer do not use a draw list, and therefore * SCH_SCREEN::Plot plots nothing */ void SCH_SCREEN::Plot( PLOTTER* aPlotter ) { BuildSchCmpLinksToLibCmp(); for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() ) { aPlotter->SetCurrentLineWidth( item->GetPenSize() ); item->Plot( aPlotter ); } }
bool SCH_SCREEN::Save( FILE* aFile ) const { // Creates header if( fprintf( aFile, "%s %s %d\n", EESCHEMA_FILE_STAMP, SCHEMATIC_HEAD_STRING, EESCHEMA_VERSION ) < 0 ) return false; BOOST_FOREACH( const PART_LIB& lib, *Prj().SchLibs() ) { if( fprintf( aFile, "LIBS:%s\n", TO_UTF8( lib.GetName() ) ) < 0 ) return false; } // This section is not used, but written for file compatibility if( fprintf( aFile, "EELAYER %d %d\n", LAYERSCH_ID_COUNT, 0 ) < 0 || fprintf( aFile, "EELAYER END\n" ) < 0 ) return false; /* Write page info, ScreenNumber and NumberOfScreen; not very meaningful for * SheetNumber and Sheet Count in a complex hierarchy, but useful in * simple hierarchy and flat hierarchy. Used also to search the root * sheet ( ScreenNumber = 1 ) within the files */ const TITLE_BLOCK& tb = GetTitleBlock(); if( fprintf( aFile, "$Descr %s %d %d%s\n", TO_UTF8( m_paper.GetType() ), m_paper.GetWidthMils(), m_paper.GetHeightMils(), !m_paper.IsCustom() && m_paper.IsPortrait() ? " portrait" : "" ) < 0 || fprintf( aFile, "encoding utf-8\n") < 0 || fprintf( aFile, "Sheet %d %d\n", m_ScreenNumber, m_NumberOfScreens ) < 0 || fprintf( aFile, "Title %s\n", EscapedUTF8( tb.GetTitle() ).c_str() ) < 0 || fprintf( aFile, "Date %s\n", EscapedUTF8( tb.GetDate() ).c_str() ) < 0 || fprintf( aFile, "Rev %s\n", EscapedUTF8( tb.GetRevision() ).c_str() ) < 0 || fprintf( aFile, "Comp %s\n", EscapedUTF8( tb.GetCompany() ).c_str() ) < 0 || fprintf( aFile, "Comment1 %s\n", EscapedUTF8( tb.GetComment1() ).c_str() ) < 0 || fprintf( aFile, "Comment2 %s\n", EscapedUTF8( tb.GetComment2() ).c_str() ) < 0 || fprintf( aFile, "Comment3 %s\n", EscapedUTF8( tb.GetComment3() ).c_str() ) < 0 || fprintf( aFile, "Comment4 %s\n", EscapedUTF8( tb.GetComment4() ).c_str() ) < 0 || fprintf( aFile, "$EndDescr\n" ) < 0 ) return false; for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() ) { if( !item->Save( aFile ) ) return false; } if( fprintf( aFile, "$EndSCHEMATC\n" ) < 0 ) return false; return true; }
void SCH_SCREEN::Plot( PLOTTER* aPlotter ) { // Ensure links are up to date, even if a library was reloaded for some reason: UpdateSymbolLinks(); for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() ) { aPlotter->SetCurrentLineWidth( item->GetPenSize() ); item->Plot( aPlotter ); } }
LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponent, bool aEndPointOnly ) const { SCH_ITEM* item; SCH_COMPONENT* component = NULL; LIB_PIN* pin = NULL; for( item = m_drawList.begin(); item; item = item->Next() ) { if( item->Type() != SCH_COMPONENT_T ) continue; component = (SCH_COMPONENT*) item; if( aEndPointOnly ) { pin = NULL; LIB_PART* part = Prj().SchLibs()->FindLibPart( component->GetPartName() ); if( !part ) continue; for( pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) ) { // Skip items not used for this part. if( component->GetUnit() && pin->GetUnit() && ( pin->GetUnit() != component->GetUnit() ) ) continue; if( component->GetConvert() && pin->GetConvert() && ( pin->GetConvert() != component->GetConvert() ) ) continue; if(component->GetPinPhysicalPosition( pin ) == aPosition ) break; } if( pin ) break; } else { pin = (LIB_PIN*) component->GetDrawItem( aPosition, LIB_PIN_T ); if( pin ) break; } } if( pin && aComponent ) *aComponent = component; return pin; }
void SCH_EDIT_FRAME::CheckListConnections( PICKED_ITEMS_LIST& aItemsList, bool aAppend ) { std::vector< wxPoint > pts; std::vector< wxPoint > connections; GetSchematicConnections( connections ); for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) { SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii ); std::vector< wxPoint > new_pts; if( !item->IsConnectable() ) continue; item->GetConnectionPoints( new_pts ); pts.insert( pts.end(), new_pts.begin(), new_pts.end() ); // If the item is a line, we also add any connection points from the rest of the schematic // that terminate on the line after it is moved. if( item->Type() == SCH_LINE_T ) { SCH_LINE* line = (SCH_LINE*) item; for( auto i : connections ) if( IsPointOnSegment( line->GetStartPoint(), line->GetEndPoint(), i ) ) pts.push_back( i ); } else { // Clean up any wires that short non-wire connections in the list for( auto point = new_pts.begin(); point != new_pts.end(); point++ ) { for( auto second_point = point + 1; second_point != new_pts.end(); second_point++ ) { aAppend |= TrimWire( *point, *second_point, aAppend ); } } } } // We always have some overlapping connection points. Drop duplicates here std::sort( pts.begin(), pts.end(), []( const wxPoint& a, const wxPoint& b ) -> bool { return a.x < b.x || (a.x == b.x && a.y < b.y); } ); pts.erase( unique( pts.begin(), pts.end() ), pts.end() ); for( auto point : pts ) { if( GetScreen()->IsJunctionNeeded( point, true ) ) { AddJunction( point, aAppend ); aAppend = true; } } }
LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponent, bool aEndPointOnly ) const { SCH_ITEM* item; SCH_COMPONENT* component = NULL; LIB_PIN* pin = NULL; for( item = m_drawList.begin(); item != NULL; item = item->Next() ) { if( item->Type() != SCH_COMPONENT_T ) continue; component = (SCH_COMPONENT*) item; if( aEndPointOnly ) { pin = NULL; LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( component->GetLibName() ); if( entry == NULL ) continue; for( pin = entry->GetNextPin(); pin != NULL; pin = entry->GetNextPin( pin ) ) { // Skip items not used for this part. if( component->GetUnit() && pin->GetUnit() && ( pin->GetUnit() != component->GetUnit() ) ) continue; if( component->GetConvert() && pin->GetConvert() && ( pin->GetConvert() != component->GetConvert() ) ) continue; if(component->GetPinPhysicalPosition( pin ) == aPosition ) break; } if( pin ) break; } else { pin = (LIB_PIN*) component->GetDrawItem( aPosition, LIB_PIN_T ); if( pin ) break; } } if( pin && aComponent ) *aComponent = component; return pin; }
SCH_ITEM* DuplicateStruct( SCH_ITEM* aDrawStruct, bool aClone ) { wxCHECK_MSG( aDrawStruct != NULL, NULL, wxT( "Cannot duplicate NULL schematic item! Bad programmer." ) ); SCH_ITEM* NewDrawStruct = (SCH_ITEM*) aDrawStruct->Clone(); if( aClone ) NewDrawStruct->SetTimeStamp( aDrawStruct->GetTimeStamp() ); return NewDrawStruct; }
void SCH_SCREEN::GetHierarchicalItems( EDA_ITEMS& aItems ) { SCH_ITEM* item = m_drawList.begin(); while( item ) { if( ( item->Type() == SCH_SHEET_T ) || ( item->Type() == SCH_COMPONENT_T ) ) aItems.push_back( item ); item = item->Next(); } }
void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC ) { SCH_ITEM* repeater = GetRepeatItem(); if( !repeater ) return; //D( repeater>Show( 0, std::cout ); ) // clone the repeater, move it, insert into display list, then save a copy // via SetRepeatItem(); SCH_ITEM* my_clone = (SCH_ITEM*) repeater->Clone(); // If cloning a component then put into 'move' mode. if( my_clone->Type() == SCH_COMPONENT_T ) { wxPoint pos = GetCrossHairPosition() - ( (SCH_COMPONENT*) my_clone )->GetPosition(); my_clone->SetFlags( IS_NEW ); ( (SCH_COMPONENT*) my_clone )->SetTimeStamp( GetNewTimeStamp() ); my_clone->Move( pos ); my_clone->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode ); PrepareMoveItem( my_clone, DC ); } else { my_clone->Move( GetRepeatStep() ); if( my_clone->CanIncrementLabel() ) ( (SCH_TEXT*) my_clone )->IncrementLabel( GetRepeatDeltaLabel() ); GetScreen()->Append( my_clone ); if( my_clone->IsConnectable() ) { GetScreen()->TestDanglingEnds(); m_canvas->Refresh(); } else { my_clone->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); } SaveCopyInUndoList( my_clone, UR_NEW ); my_clone->ClearFlags(); } // clone my_clone, now that it has been moved, thus saving new position. SetRepeatItem( my_clone ); }
/** * Function get_components * Fills a vector with all of the project's components, to ease iterating over them. * * @param aComponents - a vector that will take the components */ static void get_components( std::vector<SCH_COMPONENT*>& aComponents ) { SCH_SCREENS screens; for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() ) { for( SCH_ITEM* item = screen->GetDrawItems(); item; item = item->Next() ) { if( item->Type() != SCH_COMPONENT_T ) continue; SCH_COMPONENT* component = dynamic_cast<SCH_COMPONENT*>( item ); aComponents.push_back( component ); } } }
bool SCH_SCREEN::CheckIfOnDrawList( SCH_ITEM* aItem ) { SCH_ITEM* itemList = m_drawList.begin(); while( itemList ) { if( itemList == aItem ) return true; itemList = itemList->Next(); } return false; }
void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList, const wxPoint& aMoveVector ) { SCH_ITEM* newitem; if( aItemsList.GetCount() == 0 ) return; for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) { newitem = DuplicateStruct( (SCH_ITEM*) aItemsList.GetPickedItem( ii ) ); aItemsList.SetPickedItem( newitem, ii ); aItemsList.SetPickedItemStatus( UR_NEW, ii ); { switch( newitem->Type() ) { case SCH_JUNCTION_T: case SCH_LINE_T: case SCH_BUS_BUS_ENTRY_T: case SCH_BUS_WIRE_ENTRY_T: case SCH_TEXT_T: case SCH_LABEL_T: case SCH_GLOBAL_LABEL_T: case SCH_HIERARCHICAL_LABEL_T: case SCH_SHEET_PIN_T: case SCH_MARKER_T: case SCH_NO_CONNECT_T: default: break; case SCH_SHEET_T: { SCH_SHEET* sheet = (SCH_SHEET*) newitem; sheet->SetTimeStamp( GetNewTimeStamp() ); break; } case SCH_COMPONENT_T: ( (SCH_COMPONENT*) newitem )->SetTimeStamp( GetNewTimeStamp() ); ( (SCH_COMPONENT*) newitem )->ClearAnnotation( NULL ); break; } SetSchItemParent( newitem, screen ); screen->Append( newitem ); } } MoveItemsInList( aItemsList, aMoveVector ); }
void SCH_EDIT_FRAME::DeleteItem( SCH_ITEM* aItem, bool aAppend ) { wxCHECK_RET( aItem != NULL, wxT( "Cannot delete invalid item." ) ); wxCHECK_RET( !( aItem->GetFlags() & STRUCT_DELETED ), wxT( "Cannot delete item that is already deleted." ) ); // Here, aItem is not null. SCH_SCREEN* screen = GetScreen(); if( aItem->Type() == SCH_SHEET_PIN_T ) { // This item is attached to a node, and is not accessible by the global list directly. SCH_SHEET* sheet = (SCH_SHEET*) aItem->GetParent(); wxCHECK_RET( (sheet != NULL) && (sheet->Type() == SCH_SHEET_T), wxT( "Sheet label has invalid parent item." ) ); SaveCopyInUndoList( (SCH_ITEM*) sheet, UR_CHANGED, aAppend ); sheet->RemovePin( (SCH_SHEET_PIN*) aItem ); m_canvas->RefreshDrawingRect( sheet->GetBoundingBox() ); } else { PICKED_ITEMS_LIST itemsList; ITEM_PICKER picker( aItem, UR_DELETED ); aItem->SetFlags( STRUCT_DELETED ); itemsList.PushItem( picker ); screen->Remove( aItem ); if( aItem->IsConnectable() && aItem->Type() != SCH_JUNCTION_T ) { std::vector< wxPoint > pts; aItem->GetConnectionPoints( pts ); for( auto point : pts ) { SCH_ITEM* junction; if( !screen->IsJunctionNeeded( point ) && ( junction = screen->GetItem( point, 0, SCH_JUNCTION_T ) ) ) { ITEM_PICKER picker_juction( junction, UR_DELETED ); junction->SetFlags( STRUCT_DELETED ); itemsList.PushItem( picker_juction ); screen->Remove( junction ); } } } SaveCopyInUndoList( itemsList, UR_DELETED, aAppend ); m_canvas->RefreshDrawingRect( aItem->GetBoundingBox() ); } }
/* note: SCH_SCREEN::Draw is useful only for schematic. * library editor and library viewer do not use a draw list, and therefore * SCH_SCREEN::Draw draws nothing */ void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor ) { for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() ) { if( item->IsMoving() || item->IsResized() ) continue; // uncomment line below when there is a virtual // EDA_ITEM::GetBoundingBox() // if( panel->GetClipBox().Intersects( Structs->GetBoundingBox() // ) ) item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), aDrawMode, aColor ); } }
int TestDuplicateSheetNames( bool aCreateMarker ) { SCH_SCREEN* screen; SCH_ITEM* item; SCH_ITEM* test_item; int err_count = 0; SCH_SCREENS screenList; // Created the list of screen for( screen = screenList.GetFirst(); screen != NULL; screen = screenList.GetNext() ) { for( item = screen->GetDrawItems(); item != NULL; item = item->Next() ) { // search for a sheet; if( item->Type() != SCH_SHEET_T ) continue; for( test_item = item->Next(); test_item != NULL; test_item = test_item->Next() ) { if( test_item->Type() != SCH_SHEET_T ) continue; // We have found a second sheet: compare names // we are using case insensitive comparison to avoid mistakes between // similar names like Mysheet and mysheet if( ( (SCH_SHEET*) item )->GetName().CmpNoCase( ( ( SCH_SHEET* ) test_item )->GetName() ) == 0 ) { if( aCreateMarker ) { /* Create a new marker type ERC error*/ SCH_MARKER* marker = new SCH_MARKER(); marker->SetTimeStamp( GetNewTimeStamp() ); marker->SetData( ERCE_DUPLICATE_SHEET_NAME, ( (SCH_SHEET*) test_item )->GetPosition(), _( "Duplicate sheet name" ), ( (SCH_SHEET*) test_item )->GetPosition() ); marker->SetMarkerType( MARKER_BASE::MARKER_ERC ); marker->SetErrorLevel( MARKER_BASE::MARKER_SEVERITY_ERROR ); screen->Append( marker ); } err_count++; } } } } return err_count; }
SCH_SHEET* SCH_SCREEN::GetSheet( const wxString& aName ) { for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() ) { if( item->Type() != SCH_SHEET_T ) continue; SCH_SHEET* sheet = (SCH_SHEET*) item; if( aName.CmpNoCase( sheet->GetName() ) == 0 ) return sheet; } return NULL; }
bool WriteDiagnosticERC( const wxString& aFullFileName ) { SCH_ITEM* item; SCH_MARKER* marker; static FILE* file; SCH_SHEET_PATH* sheet; wxString msg; int count = 0; if( ( file = wxFopen( aFullFileName, wxT( "wt" ) ) ) == NULL ) return false; msg = _( "ERC report" ); fprintf( file, "%s (%s)\n", TO_UTF8( msg ), TO_UTF8( DateAndTime() ) ); SCH_SHEET_LIST sheetList; for( sheet = sheetList.GetFirst(); sheet != NULL; sheet = sheetList.GetNext() ) { msg.Printf( _( "\n***** Sheet %s\n" ), GetChars( sheet->PathHumanReadable() ) ); fprintf( file, "%s", TO_UTF8( msg ) ); for( item = sheet->LastDrawList(); item != NULL; item = item->Next() ) { if( item->Type() != SCH_MARKER_T ) continue; marker = (SCH_MARKER*) item; if( marker->GetMarkerType() != MARK_ERC ) continue; if( marker->GetMarkerType() == ERR ) count++; msg = marker->GetReporter().ShowReport(); fprintf( file, "%s", TO_UTF8( msg ) ); } } msg.Printf( _( "\n >> Errors ERC: %d\n" ), count ); fprintf( file, "%s", TO_UTF8( msg ) ); fclose( file ); return true; }
int SCH_SCREEN::CountConnectedItems( const wxPoint& aPos, bool aTestJunctions ) const { SCH_ITEM* item; int count = 0; for( item = m_drawList.begin(); item; item = item->Next() ) { if( item->Type() == SCH_JUNCTION_T && !aTestJunctions ) continue; if( item->IsConnected( aPos ) ) count++; } return count; }
void SCH_SCREEN::ClearAnnotation( SCH_SHEET_PATH* aSheetPath ) { for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() ) { if( item->Type() == SCH_COMPONENT_T ) { SCH_COMPONENT* component = (SCH_COMPONENT*) item; component->ClearAnnotation( aSheetPath ); // Clear the modified component flag set by component->ClearAnnotation // because we do not use it here and we should not leave this flag set, // when an edition is finished: component->ClearFlags(); } } }
void SCH_EDIT_FRAME::DeleteItemsInList( PICKED_ITEMS_LIST& aItemsList, bool aAppend ) { PICKED_ITEMS_LIST itemsList; for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) { SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii ); ITEM_PICKER itemWrapper( item, UR_DELETED ); if( item->GetFlags() & STRUCT_DELETED ) continue; DeleteItem( item, aAppend ); aAppend = true; } GetScreen()->ClearDrawingState(); }
SCH_SHEET_PIN* SCH_SCREEN::GetSheetLabel( const wxPoint& aPosition ) { SCH_SHEET_PIN* sheetPin = NULL; for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() ) { if( item->Type() != SCH_SHEET_T ) continue; SCH_SHEET* sheet = (SCH_SHEET*) item; sheetPin = sheet->GetPin( aPosition ); if( sheetPin ) break; } return sheetPin; }
static void moveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) { SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen(); SCH_ITEM* item = screen->GetCurItem(); wxCHECK_RET( (item != NULL), wxT( "Cannot move invalid schematic item." ) ); #ifndef USE_WX_OVERLAY // Erase the current item at its current position. if( aErase ) item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); #endif item->SetPosition( aPanel->GetParent()->GetCrossHairPosition() ); // Draw the item item at it's new position. item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); }
bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxString& aReference, const wxString& aFootPrint, bool aSetVisible ) { SCH_COMPONENT* component; bool found = false; for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() ) { if( item->Type() != SCH_COMPONENT_T ) continue; component = (SCH_COMPONENT*) item; if( aReference.CmpNoCase( component->GetRef( aSheetPath ) ) == 0 ) { // Found: Init Footprint Field /* Give a reasonable value to the field position and * orientation, if the text is empty at position 0, because * it is probably not yet initialized */ SCH_FIELD * fpfield = component->GetField( FOOTPRINT ); if( fpfield->GetText().IsEmpty() && ( fpfield->GetTextPosition() == component->GetPosition() ) ) { fpfield->SetOrientation( component->GetField( VALUE )->GetOrientation() ); fpfield->SetTextPosition( component->GetField( VALUE )->GetTextPosition() ); fpfield->SetSize( component->GetField( VALUE )->GetSize() ); if( fpfield->GetOrientation() == 0 ) fpfield->Offset( wxPoint( 0, 100 ) ); else fpfield->Offset( wxPoint( 100, 0 ) ); } fpfield->SetText( aFootPrint ); fpfield->SetVisible( aSetVisible ); found = true; } } return found; }
SCH_ITEM* SCH_SHEET_LIST::FindNextItem( KICAD_T aType, SCH_SHEET_PATH** aSheetFoundIn, SCH_ITEM* aLastItem, bool aWrap ) { bool hasWrapped = false; bool firstItemFound = false; SCH_ITEM* drawItem = NULL; SCH_SHEET_PATH* sheet = GetFirst(); while( sheet ) { drawItem = sheet->LastDrawList(); while( drawItem ) { if( drawItem->Type() == aType ) { if( aLastItem == NULL || firstItemFound ) { if( aSheetFoundIn ) *aSheetFoundIn = sheet; return drawItem; } else if( !firstItemFound && drawItem == aLastItem ) { firstItemFound = true; } } drawItem = drawItem->Next(); } sheet = GetNext(); if( sheet == NULL && aLastItem && aWrap && !hasWrapped ) { hasWrapped = true; sheet = GetFirst(); } } return NULL; }