int SCH_SHEET::ComponentCount() { int n = 0; if( m_screen ) { EDA_ITEM* bs; for( bs = m_screen->GetDrawItems(); bs != NULL; bs = bs->Next() ) { if( bs->Type() == SCH_COMPONENT_T ) { SCH_COMPONENT* Cmp = (SCH_COMPONENT*) bs; if( Cmp->GetField( VALUE )->GetText().GetChar( 0 ) != '#' ) n++; } if( bs->Type() == SCH_SHEET_T ) { SCH_SHEET* sheet = (SCH_SHEET*) bs; n += sheet->ComponentCount(); } } } return n; }
static void export_vrml_drawings( MODEL_VRML& aModel, BOARD* pcb ) { // draw graphic items for( EDA_ITEM* drawing = pcb->m_Drawings; drawing != 0; drawing = drawing->Next() ) { LAYER_ID layer = ( (DRAWSEGMENT*) drawing )->GetLayer(); if( layer != F_Cu && layer != B_Cu && layer != B_SilkS && layer != F_SilkS ) continue; switch( drawing->Type() ) { case PCB_LINE_T: export_vrml_drawsegment( aModel, (DRAWSEGMENT*) drawing ); break; case PCB_TEXT_T: export_vrml_pcbtext( aModel, (TEXTE_PCB*) drawing ); break; default: break; } } }
void SCH_SHEET_PATH::AnnotatePowerSymbols( PART_LIBS* aLibs, int* aReference ) { int ref = 1; if( aReference ) ref = *aReference; for( EDA_ITEM* item = LastDrawList(); item; item = item->Next() ) { if( item->Type() != SCH_COMPONENT_T ) continue; SCH_COMPONENT* component = (SCH_COMPONENT*) item; LIB_PART* part = aLibs->FindLibPart( component->GetPartName() ); if( !part || !part->IsPower() ) continue; wxString refstr = component->GetPrefix(); //str will be "C?" or so after the ClearAnnotation call. while( refstr.Last() == '?' ) refstr.RemoveLast(); if( !refstr.StartsWith( wxT( "#" ) ) ) refstr = wxT( "#" ) + refstr; refstr << wxT( "0" ) << ref; component->SetRef( this, refstr ); ref++; } if( aReference ) *aReference = ref; }
bool SCH_SHEET::SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen ) { if( m_screen ) { EDA_ITEM* item = m_screen->GetDrawItems(); while( item ) { if( item->Type() == SCH_SHEET_T ) { SCH_SHEET* sheet = (SCH_SHEET*) item; if( sheet->m_screen && sheet->m_screen->GetFileName().CmpNoCase( aFilename ) == 0 ) { *aScreen = sheet->m_screen; return true; } if( sheet->SearchHierarchy( aFilename, aScreen ) ) return true; } item = item->Next(); } } return false; }
void FOOTPRINT_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem, UNDO_REDO_T aTypeCommand, const wxPoint& aTransformPoint ) { EDA_ITEM* item; MODULE* CopyItem; PICKED_ITEMS_LIST* lastcmd; CopyItem = new MODULE( *( (MODULE*) aItem ) ); CopyItem->SetParent( GetBoard() ); lastcmd = new PICKED_ITEMS_LIST(); ITEM_PICKER wrapper( CopyItem, UR_MODEDIT ); lastcmd->PushItem( wrapper ); GetScreen()->PushCommandToUndoList( lastcmd ); /* Clear current flags (which can be temporary set by a current edit command) */ for( item = CopyItem->GraphicalItems(); item != NULL; item = item->Next() ) item->ClearFlags(); for( D_PAD* pad = CopyItem->Pads(); pad; pad = pad->Next() ) pad->ClearFlags(); CopyItem->Reference().ClearFlags(); CopyItem->Value().ClearFlags(); /* Clear redo list, because after new save there is no redo to do */ GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList ); }
void SCH_SCREENS::BuildScreenList( EDA_ITEM* aItem ) { if( aItem && aItem->Type() == SCH_SHEET_T ) { SCH_SHEET* ds = (SCH_SHEET*) aItem; aItem = ds->GetScreen(); } if( aItem && aItem->Type() == SCH_SCREEN_T ) { SCH_SCREEN* screen = (SCH_SCREEN*) aItem; AddScreenToList( screen ); EDA_ITEM* strct = screen->GetDrawItems(); while( strct ) { if( strct->Type() == SCH_SHEET_T ) { BuildScreenList( strct ); } strct = strct->Next(); } } }
void POINT_EDITOR::removeCorner( EDIT_POINT* aPoint ) { EDA_ITEM* item = m_editPoints->GetParent(); if( item->Type() == PCB_ZONE_AREA_T ) { const SELECTION& selection = m_selectionTool->GetSelection(); PCB_BASE_FRAME* frame = getEditFrame<PCB_BASE_FRAME>(); ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item ); CPolyLine* outline = zone->Outline(); for( int i = 0; i < outline->GetCornersCount(); ++i ) { if( VECTOR2I( outline->GetPos( i ) ) == aPoint->GetPosition() ) { frame->OnModify(); frame->SaveCopyInUndoList( selection.items, UR_CHANGED ); outline->DeleteCorner( i ); setEditedPoint( NULL ); break; } } } }
void SCH_SHEET::CleanupSheet() { SCH_SHEET_PINS::iterator i = m_pins.begin(); while( i != m_pins.end() ) { /* Search the schematic for a hierarchical label corresponding to this sheet label. */ EDA_ITEM* DrawStruct = m_screen->GetDrawItems(); const SCH_HIERLABEL* HLabel = NULL; for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() ) { if( DrawStruct->Type() != SCH_HIERARCHICAL_LABEL_T ) continue; HLabel = static_cast<SCH_HIERLABEL*>( DrawStruct ); if( i->GetText().CmpNoCase( HLabel->GetText() ) == 0 ) break; // Found! HLabel = NULL; } if( HLabel == NULL ) // Hlabel not found: delete sheet label. i = m_pins.erase( i ); else ++i; } }
void SCH_SCREENS::BuildScreenList( EDA_ITEM* aItem ) { if( aItem && aItem->Type() == SCH_SHEET_T ) { SCH_SHEET* ds = (SCH_SHEET*) aItem; aItem = ds->GetScreen(); } if( aItem && aItem->Type() == SCH_SCREEN_T ) { SCH_SCREEN* screen = (SCH_SCREEN*) aItem; // Ensure each component has its pointer to its part lib LIB_PART // up to date (the cost is low if this is the case) // We do this update here, because most of time this function is called // to create a netlist, or an ERC, which need this update screen->BuildSchCmpLinksToLibCmp(); AddScreenToList( screen ); EDA_ITEM* strct = screen->GetDrawItems(); while( strct ) { if( strct->Type() == SCH_SHEET_T ) { BuildScreenList( strct ); } strct = strct->Next(); } } }
void PCB_EDIT_FRAME::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC ) { EDA_ITEM* PtStruct; int track_fill_copy = DisplayOpt.DisplayDrawItems; if( Segment == NULL ) return; if( Segment->IsNew() ) // Trace in progress. { // Delete current segment. DisplayOpt.DisplayDrawItems = SKETCH; Segment->Draw( m_canvas, DC, GR_XOR ); PtStruct = Segment->Back(); Segment ->DeleteStructure(); if( PtStruct && (PtStruct->Type() == PCB_LINE_T ) ) Segment = (DRAWSEGMENT*) PtStruct; DisplayOpt.DisplayDrawItems = track_fill_copy; SetCurItem( NULL ); } else if( Segment->GetFlags() == 0 ) { Segment->Draw( m_canvas, DC, GR_XOR ); Segment->ClearFlags(); SaveCopyInUndoList(Segment, UR_DELETED); Segment->UnLink(); SetCurItem( NULL ); OnModify(); } }
wxString SCH_FIND_COLLECTOR::GetText() { wxCHECK_MSG( (GetCount() != 0) && IsValidIndex( m_foundIndex ), wxEmptyString, wxT( "Cannot get found item at invalid index." ) ); SCH_FIND_COLLECTOR_DATA data = m_data[ m_foundIndex ]; EDA_ITEM* foundItem = m_List[ m_foundIndex ]; wxCHECK_MSG( foundItem != NULL, wxEmptyString, wxT( "Invalid found item pointer." ) ); wxString msg; if( data.GetParent() ) { msg.Printf( _( "Child item %s of parent item %s found in sheet %s" ), GetChars( foundItem->GetSelectMenuText() ), GetChars( data.GetParent()->GetSelectMenuText() ), GetChars( data.GetSheetPath() ) ); } else { msg.Printf( _( "Item %s found in sheet %s" ), GetChars( foundItem->GetSelectMenuText() ), GetChars( data.GetSheetPath() ) ); } return msg; }
bool SCH_SHEET::HasUndefinedPins() { for( const SCH_SHEET_PIN& pin : m_pins ) { /* Search the schematic for a hierarchical label corresponding to this sheet label. */ EDA_ITEM* DrawStruct = m_screen->GetDrawItems(); const SCH_HIERLABEL* HLabel = NULL; for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() ) { if( DrawStruct->Type() != SCH_HIERARCHICAL_LABEL_T ) continue; HLabel = static_cast<SCH_HIERLABEL*>( DrawStruct ); if( pin.GetText().CmpNoCase( HLabel->GetText() ) == 0 ) break; // Found! HLabel = NULL; } if( HLabel == NULL ) // Corresponding hierarchical label not found. return true; } return false; }
bool SCH_SHEET::LocatePathOfScreen( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aList ) { if( m_screen ) { aList->push_back( this ); if( m_screen == aScreen ) return true; EDA_ITEM* strct = m_screen->GetDrawItems(); while( strct ) { if( strct->Type() == SCH_SHEET_T ) { SCH_SHEET* ss = (SCH_SHEET*) strct; if( ss->LocatePathOfScreen( aScreen, aList ) ) return true; } strct = strct->Next(); } aList->pop_back(); } return false; }
void MODULE::MoveAnchorPosition( const wxPoint& aMoveVector ) { /* Move the reference point of the footprint * the footprints elements (pads, outlines, edges .. ) are moved * but: * - the footprint position is not modified. * - the relative (local) coordinates of these items are modified */ wxPoint footprintPos = GetPosition(); /* Update the relative coordinates: * The coordinates are relative to the anchor point. * Calculate deltaX and deltaY from the anchor. */ wxPoint moveVector = aMoveVector; RotatePoint( &moveVector, -GetOrientation() ); // Update of the reference and value. m_Reference->SetPos0( m_Reference->GetPos0() + moveVector ); m_Reference->SetDrawCoord(); m_Value->SetPos0( m_Value->GetPos0() + moveVector ); m_Value->SetDrawCoord(); // Update the pad local coordinates. for( D_PAD* pad = Pads(); pad; pad = pad->Next() ) { pad->SetPos0( pad->GetPos0() + moveVector ); pad->SetPosition( pad->GetPos0() + footprintPos ); } // Update the draw element coordinates. for( EDA_ITEM* item = GraphicalItems(); item; item = item->Next() ) { switch( item->Type() ) { case PCB_MODULE_EDGE_T: { EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( item ); edge->m_Start0 += moveVector; edge->m_End0 += moveVector; edge->SetDrawCoord(); break; } case PCB_MODULE_TEXT_T: { TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item ); text->SetPos0( text->GetPos0() + moveVector ); text->SetDrawCoord(); break; } default: break; } } CalculateBoundingBox(); }
// Same as function TransformGraphicShapesWithClearanceToPolygonSet but // this only render text void MODULE::TransformGraphicTextWithClearanceToPolygonSet( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aCornerBuffer, int aInflateValue, int aError ) const { std::vector<TEXTE_MODULE *> texts; // List of TEXTE_MODULE to convert for( EDA_ITEM* item = GraphicalItemsList(); item != NULL; item = item->Next() ) { switch( item->Type() ) { case PCB_MODULE_TEXT_T: { TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item ); if( text->GetLayer() == aLayer && text->IsVisible() ) texts.push_back( text ); break; } case PCB_MODULE_EDGE_T: // This function does not render this break; default: break; } } // Convert texts sur modules if( Reference().GetLayer() == aLayer && Reference().IsVisible() ) texts.push_back( &Reference() ); if( Value().GetLayer() == aLayer && Value().IsVisible() ) texts.push_back( &Value() ); prms.m_cornerBuffer = &aCornerBuffer; for( unsigned ii = 0; ii < texts.size(); ii++ ) { TEXTE_MODULE *textmod = texts[ii]; prms.m_textWidth = textmod->GetThickness() + ( 2 * aInflateValue ); prms.m_error = aError; wxSize size = textmod->GetTextSize(); if( textmod->IsMirrored() ) size.x = -size.x; DrawGraphicText( NULL, NULL, textmod->GetTextPos(), BLACK, textmod->GetShownText(), textmod->GetDrawRotation(), size, textmod->GetHorizJustify(), textmod->GetVertJustify(), textmod->GetThickness(), textmod->IsItalic(), true, addTextSegmToPoly, &prms ); } }
/* Move marked items, at new position = old position + offset */ void MoveMarkedItems( MODULE* module, wxPoint offset ) { EDA_ITEM* item; if( module == NULL ) return; if( module->Reference().IsSelected() ) module->Reference().Move( offset ); if( module->Value().IsSelected() ) module->Value().Move( offset ); D_PAD* pad = module->Pads(); for( ; pad != NULL; pad = pad->Next() ) { if( !pad->IsSelected() ) continue; pad->SetPosition( pad->GetPosition() + offset ); pad->SetPos0( pad->GetPos0() + offset ); } item = module->GraphicalItems(); for( ; item != NULL; item = item->Next() ) { if( !item->IsSelected() ) continue; switch( item->Type() ) { case PCB_MODULE_TEXT_T: static_cast<TEXTE_MODULE*>( item )->Move( offset ); break; case PCB_MODULE_EDGE_T: { EDGE_MODULE* em = (EDGE_MODULE*) item; em->SetStart( em->GetStart() + offset ); em->SetEnd( em->GetEnd() + offset ); em->SetStart0( em->GetStart0() + offset ); em->SetEnd0( em->GetEnd0() + offset ); } break; default: ; } } ClearMarkItems( module ); }
void SCH_SCREEN::Show( int nestLevel, std::ostream& os ) const { // for now, make it look like XML, expand on this later. NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n"; for( EDA_ITEM* item = m_drawList.begin(); item; item = item->Next() ) { item->Show( nestLevel+1, os ); } NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n"; }
void POINT_EDITOR::finishItem() const { EDA_ITEM* item = m_editPoints->GetParent(); if( item->Type() == PCB_ZONE_AREA_T ) { ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item ); if( zone->IsFilled() ) getEditFrame<PCB_EDIT_FRAME>()->Fill_Zone( zone ); } }
/* Move marked items, at new position = old position + offset */ void MoveMarkedItems( MODULE* module, wxPoint offset ) { EDA_ITEM* item; if( module == NULL ) return; D_PAD* pad = module->Pads(); for( ; pad != NULL; pad = pad->Next() ) { if( !pad->IsSelected() ) continue; pad->SetPosition( pad->GetPosition() + offset ); pad->SetPos0( pad->GetPos0() + offset ); } item = module->GraphicalItems(); for( ; item != NULL; item = item->Next() ) { if( !item->IsSelected() ) continue; switch( item->Type() ) { case PCB_MODULE_TEXT_T: { TEXTE_MODULE* tm = (TEXTE_MODULE*) item; tm->Offset( offset ); tm->SetPos0( tm->GetPos0() + offset ); } break; case PCB_MODULE_EDGE_T: { EDGE_MODULE* em = (EDGE_MODULE*) item; em->SetStart( em->GetStart() + offset ); em->SetEnd( em->GetEnd() + offset ); em->SetStart0( em->GetStart0() + offset ); em->SetEnd0( em->GetEnd0() + offset ); } break; default: ; } item->ClearFlags(); } }
void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& aEvent ) { SCH_FIND_REPLACE_DATA searchCriteria; SCH_FIND_COLLECTOR_DATA data; searchCriteria.SetFlags( aEvent.GetFlags() ); searchCriteria.SetFindString( aEvent.GetFindString() ); searchCriteria.SetReplaceString( aEvent.GetReplaceString() ); if( aEvent.GetEventType() == wxEVT_COMMAND_FIND_CLOSE ) { if( m_foundItems.GetCount() == 0 ) return; // Refresh the search cache in case something has changed. This prevents any stale // pointers from crashing Eeschema when the wxEVT_FIND_CLOSE event is handled. if( IsSearchCacheObsolete( searchCriteria ) ) { if( aEvent.GetFlags() & FR_CURRENT_SHEET_ONLY && g_RootSheet->CountSheets() > 1 ) { m_foundItems.Collect( searchCriteria, m_CurrentSheet ); } else { m_foundItems.Collect( searchCriteria ); } } } else if( IsSearchCacheObsolete( searchCriteria ) ) { if( aEvent.GetFlags() & FR_CURRENT_SHEET_ONLY && g_RootSheet->CountSheets() > 1 ) { m_foundItems.Collect( searchCriteria, m_CurrentSheet ); } else { m_foundItems.Collect( searchCriteria ); } } else { EDA_ITEM* currentItem = m_foundItems.GetItem( data ); if( currentItem != NULL ) currentItem->SetForceVisible( false ); m_foundItems.UpdateIndex(); } updateFindReplaceView( aEvent ); }
void PL_SELECTION_TOOL::guessSelectionCandidates( COLLECTOR& collector, const VECTOR2I& aPos ) { // There are certain conditions that can be handled automatically. // Prefer an exact hit to a sloppy one for( int i = 0; collector.GetCount() == 2 && i < 2; ++i ) { EDA_ITEM* item = collector[ i ]; EDA_ITEM* other = collector[ ( i + 1 ) % 2 ]; if( item->HitTest( (wxPoint) aPos, 0 ) && !other->HitTest( (wxPoint) aPos, 0 ) ) collector.Remove( other ); } }
EDIT_POINT POINT_EDITOR::get45DegConstrainer() const { EDA_ITEM* item = m_editPoints->GetParent(); switch( item->Type() ) { case PCB_LINE_T: case PCB_MODULE_EDGE_T: { const DRAWSEGMENT* segment = static_cast<const DRAWSEGMENT*>( item ); { switch( segment->GetShape() ) { case S_SEGMENT: return *( m_editPoints->Next( *m_editedPoint ) ); // select the other end of line case S_ARC: case S_CIRCLE: return m_editPoints->Point( CIRC_CENTER ); default: // suppress warnings break; } } break; } case PCB_DIMENSION_T: { // Constraint for crossbar if( isModified( m_editPoints->Point( DIM_FEATUREGO ) ) ) return m_editPoints->Point( DIM_FEATUREDO ); else if( isModified( m_editPoints->Point( DIM_FEATUREDO ) ) ) return m_editPoints->Point( DIM_FEATUREGO ); else return EDIT_POINT( m_editedPoint->GetPosition() ); // no constraint break; } default: break; } // In any other case we may align item to its original position return m_original; }
SEARCH_RESULT EDA_ITEM::IterateForward( EDA_ITEM* listStart, INSPECTOR* inspector, const void* testData, const KICAD_T scanTypes[] ) { EDA_ITEM* p = listStart; for( ; p; p = p->Pnext ) { if( SEARCH_QUIT == p->Visit( inspector, testData, scanTypes ) ) return SEARCH_QUIT; } return SEARCH_CONTINUE; }
/** Rotate marked items, refer to a rotation point at position offset * Note: because this function is used in global transform, * if force_all is true, all items will be rotated */ void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all ) { #define ROTATE( z ) RotatePoint( (&z), offset, 900 ) if( module == NULL ) return; if( module->Reference().IsSelected() || force_all ) module->Reference().Rotate( offset, 900 ); if( module->Value().IsSelected() || force_all ) module->Value().Rotate( offset, 900 ); for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() ) { if( !pad->IsSelected() && !force_all ) continue; wxPoint pos = pad->GetPos0(); ROTATE( pos ); pad->SetPos0( pos ); pad->SetOrientation( pad->GetOrientation() + 900 ); pad->SetDrawCoord(); } for( EDA_ITEM* item = module->GraphicalItems(); item; item = item->Next() ) { if( !item->IsSelected() && !force_all ) continue; switch( item->Type() ) { case PCB_MODULE_EDGE_T: ((EDGE_MODULE*) item)->Rotate( offset, 900 ); break; case PCB_MODULE_TEXT_T: static_cast<TEXTE_MODULE*>( item )->Rotate( offset, 900 ); break; default: break; } } ClearMarkItems( module ); }
void SCH_SHEET_PATH::UpdateAllScreenReferences() { EDA_ITEM* t = LastDrawList(); while( t ) { if( t->Type() == SCH_COMPONENT_T ) { SCH_COMPONENT* component = (SCH_COMPONENT*) t; component->GetField( REFERENCE )->SetText( component->GetRef( this ) ); component->UpdateUnit( component->GetUnitSelection( this ) ); } t = t->Next(); } }
/* * Move the footprint anchor position to the current cursor position. */ void FOOTPRINT_EDIT_FRAME::Place_Ancre( MODULE* aModule ) { wxPoint moveVector; if( aModule == NULL ) return; moveVector = aModule->m_Pos - GetScreen()->GetCrossHairPosition(); aModule->m_Pos = GetScreen()->GetCrossHairPosition(); /* Update the relative coordinates: * The coordinates are relative to the anchor point. * Calculate deltaX and deltaY from the anchor. */ RotatePoint( &moveVector, -aModule->m_Orient ); // Update the pad coordinates. for( D_PAD* pad = (D_PAD*) aModule->m_Pads; pad; pad = pad->Next() ) { pad->SetPos0( pad->GetPos0() + moveVector ); } // Update the draw element coordinates. for( EDA_ITEM* item = aModule->m_Drawings; item; item = item->Next() ) { switch( item->Type() ) { case PCB_MODULE_EDGE_T: #undef STRUCT #define STRUCT ( (EDGE_MODULE*) item ) STRUCT->m_Start0 += moveVector; STRUCT->m_End0 += moveVector; break; case PCB_MODULE_TEXT_T: #undef STRUCT #define STRUCT ( (TEXTE_MODULE*) item ) STRUCT->SetPos0( STRUCT->GetPos0() + moveVector ); break; default: break; } } aModule->CalculateBoundingBox(); }
void MODULE::Flip( const wxPoint& aCentre ) { // Move module to its final position: wxPoint finalPos = m_Pos; finalPos.y = aCentre.y - ( finalPos.y - aCentre.y ); /// Mirror the Y position SetPosition( finalPos ); // Flip layer SetLayer( FlipLayer( GetLayer() ) ); // Reverse mirror orientation. NEGATE( m_Orient ); NORMALIZE_ANGLE_POS( m_Orient ); // Mirror pads to other side of board about the x axis, i.e. vertically. for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) pad->Flip( m_Pos ); // Mirror reference. m_Reference->FlipWithModule( m_Pos.y ); // Mirror value. m_Value->FlipWithModule( m_Pos.y ); // Reverse mirror module graphics and texts. for( EDA_ITEM* item = m_Drawings; item; item = item->Next() ) { switch( item->Type() ) { case PCB_MODULE_EDGE_T: ( (EDGE_MODULE*) item )->Flip( m_Pos ); break; case PCB_MODULE_TEXT_T: static_cast<TEXTE_MODULE*>( item )->FlipWithModule( m_Pos.y ); break; default: wxMessageBox( wxT( "MODULE::Flip() error: Unknown Draw Type" ) ); break; } } CalculateBoundingBox(); }
bool SCH_FIND_COLLECTOR::ReplaceItem( SCH_SHEET_PATH* aSheetPath ) { if( PassedEnd() ) return false; wxCHECK_MSG( IsValidIndex( m_foundIndex ), false, wxT( "Invalid replace list index in SCH_FIND_COLLECTOR." ) ); EDA_ITEM* item = m_List[ m_foundIndex ]; bool replaced = item->Replace( m_findReplaceData, aSheetPath ); if( replaced ) SetForceSearch(); return replaced; }
int SCH_SHEET::CountSheets() { int count = 1; //1 = this!! if( m_screen ) { EDA_ITEM* strct = m_screen->GetDrawItems(); for( ; strct; strct = strct->Next() ) { if( strct->Type() == SCH_SHEET_T ) { SCH_SHEET* subsheet = (SCH_SHEET*) strct; count += subsheet->CountSheets(); } } } return count; }
SCH_SHEET_PIN* SCH_EDIT_FRAME::ImportSheetPin( SCH_SHEET* aSheet, wxDC* aDC ) { EDA_ITEM* item; SCH_SHEET_PIN* sheetPin; SCH_HIERLABEL* label = NULL; if( !aSheet->GetScreen() ) return NULL; item = aSheet->GetScreen()->GetDrawItems(); for( ; item != NULL; item = item->Next() ) { if( item->Type() != SCH_HIERARCHICAL_LABEL_T ) continue; label = (SCH_HIERLABEL*) item; /* A global label has been found: check if there a corresponding sheet label. */ if( !aSheet->HasPin( label->GetText() ) ) break; label = NULL; } if( label == NULL ) { DisplayInfoMessage( this, _( "No new hierarchical labels found." ) ); return NULL; } sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), label->GetText() ); sheetPin->SetFlags( IS_NEW ); sheetPin->SetSize( m_lastSheetPinTextSize ); m_lastSheetPinType = label->GetShape(); sheetPin->SetShape( label->GetShape() ); sheetPin->SetPosition( GetCrossHairPosition() ); sheetPin->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode ); MoveItem( (SCH_ITEM*) sheetPin, aDC ); return sheetPin; }