void SCH_EDIT_FRAME::DisplayCurrentSheet() { SetRepeatItem( NULL ); ClearMsgPanel(); SCH_SCREEN* screen = m_CurrentSheet->LastScreen(); // Switch to current sheet, // and update the grid size, because it can be modified in latest screen SetScreen( screen ); GetScreen()->SetGrid( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ); // update the References m_CurrentSheet->UpdateAllScreenReferences(); SetSheetNumberAndCount(); m_canvas->SetCanStartBlock( -1 ); if( screen->m_FirstRedraw ) { Zoom_Automatique( false ); screen->m_FirstRedraw = false; SetCrossHairPosition( GetScrollCenterPosition() ); m_canvas->MoveCursorToCrossHair(); // Ensure the schematic is fully segmented on first display BreakSegmentsOnJunctions(); SchematicCleanUp( true ); screen->ClearUndoORRedoList( screen->m_UndoList, 1 ); screen->TestDanglingEnds(); } else { RedrawScreen( GetScrollCenterPosition(), true ); } // Some items (wires, labels) can be highlighted. So prepare the highlight flag: SetCurrentSheetHighlightFlags(); // Now refresh m_canvas. Should be not necessary, but because screen has changed // the previous refresh has set all new draw parameters (scroll position ..) // but most of time there were some inconsitencies about cursor parameters // ( previous position of cursor ...) and artefacts can happen // mainly when sheet size has changed // This second refresh clears artefacts because at this point, // all parameters are now updated m_canvas->Refresh(); }
void SCH_EDIT_FRAME::GetSchematicFromRedoList( wxCommandEvent& event ) { if( GetScreen()->GetRedoCommandCount() == 0 ) return; /* Get the old list */ PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromRedoList(); /* Redo the command: */ PutDataInPreviousState( List, true ); /* Put the old list in UndoList */ List->ReversePickersListOrder(); GetScreen()->PushCommandToUndoList( List ); OnModify(); SetSheetNumberAndCount(); GetScreen()->TestDanglingEnds(); m_canvas->Refresh(); }
bool SCH_EDIT_FRAME::AppendOneEEProject() { SCH_SCREEN* screen; wxString FullFileName; wxString msg; screen = GetScreen(); if( !screen ) { wxLogError( wxT("Document not ready, cannot import") ); return false; } // open file chooser dialog wxFileDialog dlg( this, _( "Import Schematic" ), wxGetCwd(), wxEmptyString, SchematicFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST ); if( dlg.ShowModal() == wxID_CANCEL ) return false; FullFileName = dlg.GetPath(); wxFileName fn = FullFileName; if( fn.IsRelative() ) { fn.MakeAbsolute(); FullFileName = fn.GetFullPath(); } LoadCacheLibrary( FullFileName ); wxLogDebug( wxT( "Importing schematic " ) + FullFileName ); // load the project bool success = LoadOneEEFile( screen, FullFileName, true ); if( success ) { // load sub-sheets EDA_ITEM* bs = screen->GetDrawItems(); while( bs ) { // do not append hierarchical sheets if( bs->Type() == SCH_SHEET_T ) { screen->Remove( (SCH_SHEET*) bs ); } // clear annotation and init new time stamp for the new components else if( bs->Type() == SCH_COMPONENT_T ) { ( (SCH_COMPONENT*) bs )->SetTimeStamp( GetNewTimeStamp() ); ( (SCH_COMPONENT*) bs )->ClearAnnotation( NULL ); // Clear flags, which are set by these previous modifications: bs->ClearFlags(); } bs = bs->Next(); } } // redraw base screen (ROOT) if necessary GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); Zoom_Automatique( false ); SetSheetNumberAndCount(); m_canvas->Refresh( true ); return success; }
bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& aFileName, bool aIsNew ) { SCH_SCREEN* screen; wxString FullFileName, msg; bool LibCacheExist = false; SCH_SCREENS ScreenList; for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) { if( screen->IsModify() ) break; } if( screen ) { int response = YesNoCancelDialog( this, _( "The current schematic has been modified. Do " "you wish to save the changes?" ), wxEmptyString, _( "Save and Load" ), _( "Load Without Saving" ) ); if( response == wxID_CANCEL ) { return false; } else if( response == wxID_YES ) { wxCommandEvent dummy; OnSaveProject( dummy ); } } FullFileName = aFileName; if( FullFileName.IsEmpty() && !aIsNew ) { wxFileDialog dlg( this, _( "Open Schematic" ), wxGetCwd(), wxEmptyString, SchematicFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST ); if( dlg.ShowModal() == wxID_CANCEL ) return false; FullFileName = dlg.GetPath(); } wxFileName fn = FullFileName; if( fn.IsRelative() ) { fn.MakeAbsolute(); FullFileName = fn.GetFullPath(); } if( !wxGetApp().LockFile( FullFileName ) ) { DisplayError( this, _( "This file is already open." ) ); return false; } // Clear the screen before open a new file if( g_RootSheet ) { delete g_RootSheet; g_RootSheet = NULL; } CreateScreens(); screen = GetScreen(); wxLogDebug( wxT( "Loading schematic " ) + FullFileName ); wxSetWorkingDirectory( fn.GetPath() ); screen->SetFileName( FullFileName ); g_RootSheet->SetFileName( FullFileName ); SetStatusText( wxEmptyString ); ClearMsgPanel(); screen->ClrModify(); if( aIsNew ) { /* SCH_SCREEN constructor does this now screen->SetPageSettings( PAGE_INFO( wxT( "A4" ) ) ); */ screen->SetZoom( 32 ); screen->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); TITLE_BLOCK tb; wxString title; title += NAMELESS_PROJECT; title += wxT( ".sch" ); tb.SetTitle( title ); screen->SetTitleBlock( tb ); GetScreen()->SetFileName( title ); LoadProjectFile( wxEmptyString, true ); Zoom_Automatique( false ); SetSheetNumberAndCount(); m_canvas->Refresh(); return true; } // Reloading configuration. msg.Printf( _( "Ready\nWorking dir: <%s>\n" ), GetChars( wxGetCwd() ) ); PrintMsg( msg ); LoadProjectFile( wxEmptyString, false ); // Clear (if needed) the current active library in libedit because it could be // removed from memory LIB_EDIT_FRAME::EnsureActiveLibExists(); // Delete old caches. CMP_LIBRARY::RemoveCacheLibrary(); LibCacheExist = LoadCacheLibrary( g_RootSheet->GetScreen()->GetFileName() ); if( !wxFileExists( g_RootSheet->GetScreen()->GetFileName() ) && !LibCacheExist ) { Zoom_Automatique( false ); msg.Printf( _( "File <%s> not found." ), GetChars( g_RootSheet->GetScreen()->GetFileName() ) ); DisplayInfoMessage( this, msg ); return false; } // load the project. g_RootSheet->SetScreen( NULL ); bool diag = g_RootSheet->Load( this ); SetScreen( m_CurrentSheet->LastScreen() ); UpdateFileHistory( g_RootSheet->GetScreen()->GetFileName() ); /* Redraw base screen (ROOT) if necessary. */ GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); Zoom_Automatique( false ); SetSheetNumberAndCount(); m_canvas->Refresh( true ); return diag; }
void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) { int id = event.GetId(); wxPoint pos; SCH_SCREEN* screen = GetScreen(); SCH_ITEM* item = screen->GetCurItem(); pos = wxGetMousePosition(); pos.y += 20; // If needed, stop the current command and deselect current tool switch( id ) { case wxID_CUT: case wxID_COPY: case ID_POPUP_CANCEL_CURRENT_COMMAND: case ID_POPUP_SCH_ENTRY_SELECT_SLASH: case ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH: case ID_POPUP_SCH_BEGIN_WIRE: case ID_POPUP_SCH_BEGIN_BUS: case ID_POPUP_END_LINE: case ID_POPUP_SCH_SET_SHAPE_TEXT: case ID_POPUP_SCH_CLEANUP_SHEET: case ID_POPUP_SCH_END_SHEET: case ID_POPUP_SCH_RESIZE_SHEET: case ID_POPUP_IMPORT_GLABEL: case ID_POPUP_SCH_INIT_CMP: case ID_POPUP_SCH_DISPLAYDOC_CMP: case ID_POPUP_SCH_EDIT_CONVERT_CMP: case ID_POPUP_DELETE_BLOCK: case ID_POPUP_PLACE_BLOCK: case ID_POPUP_ZOOM_BLOCK: case ID_POPUP_DRAG_BLOCK: case ID_POPUP_COPY_BLOCK: case ID_POPUP_SCH_DELETE_NODE: case ID_POPUP_SCH_DELETE_CONNECTION: case ID_POPUP_SCH_ENTER_SHEET: case ID_POPUP_SCH_LEAVE_SHEET: case ID_POPUP_SCH_ADD_JUNCTION: case ID_POPUP_SCH_ADD_LABEL: case ID_POPUP_SCH_GETINFO_MARKER: /* At this point: Do nothing. these commands do not need to stop the * current command (mainly a block command) or reset the current state * They will be executed later, in next switch structure. */ break; case ID_POPUP_SCH_DELETE_CMP: case ID_POPUP_SCH_DELETE: // Stop the current command (if any) but keep the current tool m_canvas->EndMouseCapture(); break; default: // Stop the current command and deselect the current tool m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() ); break; } INSTALL_UNBUFFERED_DC( dc, m_canvas ); item = screen->GetCurItem(); // Can be modified by previous calls. switch( id ) { case ID_HIERARCHY: InstallHierarchyFrame( &dc, pos ); SetRepeatItem( NULL ); break; case wxID_CUT: if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE ) break; screen->m_BlockLocate.SetCommand( BLOCK_DELETE ); screen->m_BlockLocate.SetMessageBlock( this ); HandleBlockEnd( &dc ); SetRepeatItem( NULL ); SetSheetNumberAndCount(); break; case wxID_PASTE: HandleBlockBegin( &dc, BLOCK_PASTE, GetCrossHairPosition() ); break; case ID_POPUP_SCH_ENTRY_SELECT_SLASH: m_canvas->MoveCursorToCrossHair(); SetBusEntryShape( &dc, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '/' ); break; case ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH: m_canvas->MoveCursorToCrossHair(); SetBusEntryShape( &dc, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '\\' ); break; case ID_POPUP_CANCEL_CURRENT_COMMAND: if( m_canvas->IsMouseCaptured() ) { m_canvas->EndMouseCapture(); SetToolID( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString ); } else { SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString ); } break; case ID_POPUP_END_LINE: m_canvas->MoveCursorToCrossHair(); EndSegment( &dc ); break; case ID_POPUP_SCH_BEGIN_WIRE: m_canvas->MoveCursorToCrossHair(); OnLeftClick( &dc, GetCrossHairPosition() ); break; case ID_POPUP_SCH_BEGIN_BUS: m_canvas->MoveCursorToCrossHair(); OnLeftClick( &dc, GetCrossHairPosition() ); break; case ID_POPUP_SCH_SET_SHAPE_TEXT: // Not used break; case ID_POPUP_SCH_DELETE_NODE: case ID_POPUP_SCH_DELETE_CONNECTION: m_canvas->MoveCursorToCrossHair(); DeleteConnection( id == ID_POPUP_SCH_DELETE_CONNECTION ); screen->SetCurItem( NULL ); SetRepeatItem( NULL ); screen->TestDanglingEnds( m_canvas, &dc ); m_canvas->Refresh(); break; case ID_POPUP_SCH_BREAK_WIRE: { DLIST< SCH_ITEM > oldWires; oldWires.SetOwnership( false ); // Prevent DLIST for deleting items in destructor. m_canvas->MoveCursorToCrossHair(); screen->ExtractWires( oldWires, true ); screen->BreakSegment( GetCrossHairPosition() ); if( oldWires.GetCount() != 0 ) { PICKED_ITEMS_LIST oldItems; oldItems.m_Status = UR_WIRE_IMAGE; while( oldWires.GetCount() != 0 ) { ITEM_PICKER picker = ITEM_PICKER( oldWires.PopFront(), UR_WIRE_IMAGE ); oldItems.PushItem( picker ); } SaveCopyInUndoList( oldItems, UR_WIRE_IMAGE ); } screen->TestDanglingEnds( m_canvas, &dc ); } break; case ID_POPUP_SCH_DELETE_CMP: case ID_POPUP_SCH_DELETE: if( item == NULL ) break; DeleteItem( item ); screen->SetCurItem( NULL ); SetRepeatItem( NULL ); screen->TestDanglingEnds( m_canvas, &dc ); SetSheetNumberAndCount(); OnModify(); break; case ID_POPUP_SCH_END_SHEET: m_canvas->MoveCursorToCrossHair(); addCurrentItemToList( &dc ); break; case ID_POPUP_SCH_RESIZE_SHEET: ReSizeSheet( (SCH_SHEET*) item, &dc ); screen->TestDanglingEnds( m_canvas, &dc ); break; case ID_POPUP_IMPORT_GLABEL: if( item != NULL && item->Type() == SCH_SHEET_T ) screen->SetCurItem( ImportSheetPin( (SCH_SHEET*) item, &dc ) ); break; case ID_POPUP_SCH_CLEANUP_SHEET: if( item != NULL && item->Type() == SCH_SHEET_T ) { SCH_SHEET* sheet = (SCH_SHEET*) item; if( !sheet->HasUndefinedPins() ) { DisplayInfoMessage( this, _( "There are no undefined labels in this sheet to clean up." ) ); return; } if( !IsOK( this, _( "Do you wish to cleanup this sheet?" ) ) ) return; /* Save sheet in undo list before cleaning up unreferenced hierarchical labels. */ SaveCopyInUndoList( sheet, UR_CHANGED ); sheet->CleanupSheet(); OnModify(); m_canvas->RefreshDrawingRect( sheet->GetBoundingBox() ); } break; case ID_POPUP_SCH_INIT_CMP: m_canvas->MoveCursorToCrossHair(); break; case ID_POPUP_SCH_EDIT_CONVERT_CMP: // Ensure the struct is a component (could be a struct of a component, like Field, text..) if( item && item->Type() == SCH_COMPONENT_T ) { m_canvas->MoveCursorToCrossHair(); ConvertPart( (SCH_COMPONENT*) item, &dc ); } break; case ID_POPUP_SCH_DISPLAYDOC_CMP: // Ensure the struct is a component (could be a piece of a component, like Field, text..) if( item && item->Type() == SCH_COMPONENT_T ) { LIB_ALIAS* LibEntry; LibEntry = CMP_LIBRARY::FindLibraryEntry( ( (SCH_COMPONENT*) item )->GetLibName() ); if( LibEntry && LibEntry->GetDocFileName() != wxEmptyString ) { GetAssociatedDocument( this, LibEntry->GetDocFileName(), &wxGetApp().GetLibraryPathList() ); } } break; case ID_POPUP_SCH_ENTER_SHEET: if( item && (item->Type() == SCH_SHEET_T) ) { m_CurrentSheet->Push( (SCH_SHEET*) item ); DisplayCurrentSheet(); } break; case ID_POPUP_SCH_LEAVE_SHEET: m_CurrentSheet->Pop(); DisplayCurrentSheet(); break; case wxID_COPY: // really this is a Save block for paste screen->m_BlockLocate.SetCommand( BLOCK_SAVE ); screen->m_BlockLocate.SetMessageBlock( this ); HandleBlockEnd( &dc ); break; case ID_POPUP_PLACE_BLOCK: m_canvas->SetAutoPanRequest( false ); m_canvas->MoveCursorToCrossHair(); HandleBlockPlace( &dc ); break; case ID_POPUP_ZOOM_BLOCK: screen->m_BlockLocate.SetCommand( BLOCK_ZOOM ); screen->m_BlockLocate.SetMessageBlock( this ); HandleBlockEnd( &dc ); break; case ID_POPUP_DELETE_BLOCK: m_canvas->MoveCursorToCrossHair(); screen->m_BlockLocate.SetCommand( BLOCK_DELETE ); screen->m_BlockLocate.SetMessageBlock( this ); HandleBlockEnd( &dc ); SetSheetNumberAndCount(); break; case ID_POPUP_COPY_BLOCK: m_canvas->MoveCursorToCrossHair(); screen->m_BlockLocate.SetCommand( BLOCK_COPY ); screen->m_BlockLocate.SetMessageBlock( this ); HandleBlockEnd( &dc ); break; case ID_POPUP_DRAG_BLOCK: m_canvas->MoveCursorToCrossHair(); screen->m_BlockLocate.SetCommand( BLOCK_DRAG ); screen->m_BlockLocate.SetMessageBlock( this ); HandleBlockEnd( &dc ); break; case ID_POPUP_SCH_ADD_JUNCTION: m_canvas->MoveCursorToCrossHair(); screen->SetCurItem( AddJunction( &dc, GetCrossHairPosition(), true ) ); screen->TestDanglingEnds( m_canvas, &dc ); screen->SetCurItem( NULL ); break; case ID_POPUP_SCH_ADD_LABEL: case ID_POPUP_SCH_ADD_GLABEL: screen->SetCurItem( CreateNewText( &dc, id == ID_POPUP_SCH_ADD_LABEL ? LAYER_LOCLABEL : LAYER_GLOBLABEL ) ); item = screen->GetCurItem(); if( item ) addCurrentItemToList( &dc ); break; case ID_POPUP_SCH_GETINFO_MARKER: if( item && item->Type() == SCH_MARKER_T ) ( (SCH_MARKER*) item )->DisplayMarkerInfo( this ); break; default: // Log error: wxFAIL_MSG( wxString::Format( wxT( "Cannot process command event ID %d" ), event.GetId() ) ); break; } // End switch ( id ) (Command execution) if( GetToolId() == ID_NO_TOOL_SELECTED ) SetRepeatItem( NULL ); }
void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic, ANNOTATE_ORDER_T aSortOption, ANNOTATE_OPTION_T aAlgoOption, bool aResetAnnotation, bool aRepairTimestamps, bool aLockUnits ) { SCH_REFERENCE_LIST references; SCH_SCREENS screens; // Build the sheet list. SCH_SHEET_LIST sheets; // Map of locked components SCH_MULTI_UNIT_REFERENCE_MAP lockedComponents; // Test for and replace duplicate time stamps in components and sheets. Duplicate // time stamps can happen with old schematics, schematic conversions, or manual // editing of files. if( aRepairTimestamps ) { int count = screens.ReplaceDuplicateTimeStamps(); if( count ) { wxString msg; msg.Printf( _( "%d duplicate time stamps were found and replaced." ), count ); DisplayInfoMessage( NULL, msg, 2 ); } } // If units must be locked, collect all the sets that must be annotated together. if( aLockUnits ) { if( aAnnotateSchematic ) { sheets.GetMultiUnitComponents( Prj().SchLibs(), lockedComponents ); } else { m_CurrentSheet->GetMultiUnitComponents( Prj().SchLibs(), lockedComponents ); } } // If it is an annotation for all the components, reset previous annotation. if( aResetAnnotation ) DeleteAnnotation( !aAnnotateSchematic ); // Set sheet number and number of sheets. SetSheetNumberAndCount(); // Build component list if( aAnnotateSchematic ) { sheets.GetComponents( Prj().SchLibs(), references ); } else { m_CurrentSheet->GetComponents( Prj().SchLibs(), references ); } // Break full components reference in name (prefix) and number: // example: IC1 become IC, and 1 references.SplitReferences(); switch( aSortOption ) { default: case SORT_BY_X_POSITION: references.SortByXCoordinate(); break; case SORT_BY_Y_POSITION: references.SortByYCoordinate(); break; } bool useSheetNum = false; int idStep = 100; switch( aAlgoOption ) { default: case INCREMENTAL_BY_REF: break; case SHEET_NUMBER_X_100: useSheetNum = true; break; case SHEET_NUMBER_X_1000: useSheetNum = true; idStep = 1000; break; } // Recalculate and update reference numbers in schematic references.Annotate( useSheetNum, idStep, lockedComponents ); references.UpdateAnnotation(); wxArrayString errors; // Final control (just in case ... ). if( CheckAnnotate( &errors, !aAnnotateSchematic ) ) { wxString msg; for( size_t i = 0; i < errors.GetCount(); i++ ) msg += errors[i]; // wxLogWarning is a cheap and dirty way to dump a potentially long list of // strings to a dialog that can be saved to a file. This should be replaced // by a more elegant solution. wxLogWarning( msg ); } OnModify(); // Update on screen references, that can be modified by previous calculations: m_CurrentSheet->UpdateAllScreenReferences(); SetSheetNumberAndCount(); m_canvas->Refresh( true ); }
void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic, ANNOTATE_ORDER_T aSortOption, ANNOTATE_OPTION_T aAlgoOption, int aStartNumber, bool aResetAnnotation, bool aRepairTimestamps, bool aLockUnits, REPORTER& aReporter ) { SCH_REFERENCE_LIST references; SCH_SCREENS screens; // Build the sheet list. SCH_SHEET_LIST sheets( g_RootSheet ); // Map of locked components SCH_MULTI_UNIT_REFERENCE_MAP lockedComponents; // Map of previous annotation for building info messages std::map<timestamp_t, wxString> previousAnnotation; // Test for and replace duplicate time stamps in components and sheets. Duplicate // time stamps can happen with old schematics, schematic conversions, or manual // editing of files. if( aRepairTimestamps ) { int count = screens.ReplaceDuplicateTimeStamps(); if( count ) { wxString msg; msg.Printf( _( "%d duplicate time stamps were found and replaced." ), count ); aReporter.ReportTail( msg, REPORTER::RPT_WARNING ); } } // If units must be locked, collect all the sets that must be annotated together. if( aLockUnits ) { if( aAnnotateSchematic ) { sheets.GetMultiUnitComponents( lockedComponents ); } else { m_CurrentSheet->GetMultiUnitComponents( lockedComponents ); } } // Store previous annotations for building info messages mapExistingAnnotation( previousAnnotation ); // If it is an annotation for all the components, reset previous annotation. if( aResetAnnotation ) DeleteAnnotation( !aAnnotateSchematic ); // Set sheet number and number of sheets. SetSheetNumberAndCount(); // Build component list if( aAnnotateSchematic ) { sheets.GetComponents( references ); } else { m_CurrentSheet->GetComponents( references ); } // Break full components reference in name (prefix) and number: // example: IC1 become IC, and 1 references.SplitReferences(); switch( aSortOption ) { default: case SORT_BY_X_POSITION: references.SortByXCoordinate(); break; case SORT_BY_Y_POSITION: references.SortByYCoordinate(); break; } bool useSheetNum = false; int idStep = 100; switch( aAlgoOption ) { default: case INCREMENTAL_BY_REF: break; case SHEET_NUMBER_X_100: useSheetNum = true; break; case SHEET_NUMBER_X_1000: useSheetNum = true; idStep = 1000; break; } // Recalculate and update reference numbers in schematic references.Annotate( useSheetNum, idStep, aStartNumber, lockedComponents ); references.UpdateAnnotation(); for( size_t i = 0; i < references.GetCount(); i++ ) { SCH_COMPONENT* comp = references[ i ].GetComp(); wxString prevRef = previousAnnotation[ comp->GetTimeStamp() ]; wxString newRef = comp->GetField( REFERENCE )->GetFullyQualifiedText(); wxString msg; if( prevRef.Length() ) { if( newRef == prevRef ) continue; if( comp->GetUnitCount() > 1 ) msg.Printf( _( "Updated %s (unit %s) from %s to %s" ), GetChars( comp->GetField( VALUE )->GetShownText() ), LIB_PART::SubReference( comp->GetUnit(), false ), GetChars( prevRef ), GetChars( newRef ) ); else msg.Printf( _( "Updated %s from %s to %s" ), GetChars( comp->GetField( VALUE )->GetShownText() ), GetChars( prevRef ), GetChars( newRef ) ); } else { if( comp->GetUnitCount() > 1 ) msg.Printf( _( "Annotated %s (unit %s) as %s" ), GetChars( comp->GetField( VALUE )->GetShownText() ), LIB_PART::SubReference( comp->GetUnit(), false ), GetChars( newRef ) ); else msg.Printf( _( "Annotated %s as %s" ), GetChars( comp->GetField( VALUE )->GetShownText() ), GetChars( newRef ) ); } aReporter.Report( msg, REPORTER::RPT_ACTION ); } // Final control (just in case ... ). if( !CheckAnnotate( aReporter, !aAnnotateSchematic ) ) aReporter.ReportTail( _( "Annotation complete." ), REPORTER::RPT_ACTION ); // Update on screen references, that can be modified by previous calculations: m_CurrentSheet->UpdateAllScreenReferences(); SetSheetNumberAndCount(); SyncView(); GetCanvas()->Refresh(); OnModify(); }
void SCH_EDIT_FRAME::addCurrentItemToList( wxDC* aDC ) { SCH_SCREEN* screen = GetScreen(); SCH_ITEM* item = screen->GetCurItem(); wxCHECK_RET( item != NULL, wxT( "Cannot add current item to list." ) ); m_canvas->SetAutoPanRequest( false ); SCH_ITEM* undoItem = item; if( item->Type() == SCH_SHEET_PIN_T ) { SCH_SHEET* sheet = (SCH_SHEET*) item->GetParent(); wxCHECK_RET( (sheet != NULL) && (sheet->Type() == SCH_SHEET_T), wxT( "Cannot place sheet pin in invalid schematic sheet object." ) ); undoItem = sheet; } else if( item->Type() == SCH_FIELD_T ) { SCH_COMPONENT* cmp = (SCH_COMPONENT*) item->GetParent(); wxCHECK_RET( (cmp != NULL) && (cmp->Type() == SCH_COMPONENT_T), wxT( "Cannot place field in invalid schematic component object." ) ); undoItem = cmp; } if( item->IsNew() ) { if( item->Type() == SCH_SHEET_T ) { // Fix the size and position of the new sheet using the last values set by // the m_mouseCaptureCallback function. m_canvas->SetMouseCapture( NULL, NULL ); if( !EditSheet( (SCH_SHEET*)item, aDC ) ) { screen->SetCurItem( NULL ); item->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode ); delete item; return; } SetSheetNumberAndCount(); } if( undoItem == item ) { if( !screen->CheckIfOnDrawList( item ) ) // don't want a loop! screen->Append( item ); SetRepeatItem( item ); SaveCopyInUndoList( undoItem, UR_NEW ); } else { // Here, item is not a basic schematic item, but an item inside // a parent basic schematic item, // currently: sheet pin or component field. // currently, only a sheet pin can be found as new item, // because new component fields have a specific handling, and do not appears here SaveCopyInUndoList( undoItem, UR_CHANGED ); if( item->Type() == SCH_SHEET_PIN_T ) ( (SCH_SHEET*)undoItem )->AddPin( (SCH_SHEET_PIN*) item ); else wxLogMessage(wxT( "addCurrentItemToList: expected type = SCH_SHEET_PIN_T, actual type = %d" ), item->Type() ); } } else { SaveUndoItemInUndoList( undoItem ); } // Erase the wire representation before the 'normal' view is drawn. if ( item->IsWireImage() ) item->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode ); item->ClearFlags(); screen->SetModify(); screen->SetCurItem( NULL ); m_canvas->SetMouseCapture( NULL, NULL ); m_canvas->EndMouseCapture(); if( item->IsConnectable() ) screen->TestDanglingEnds(); if( aDC ) { EDA_CROSS_HAIR_MANAGER( m_canvas, aDC ); // Erase schematic cursor undoItem->Draw( m_canvas, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); } }