LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType, const wxString& aLibraryName ) : SCH_BASE_FRAME( aKiway, aParent, aFrameType, _( "Symbol Library Browser" ), wxDefaultPosition, wxDefaultSize, aFrameType == FRAME_SCH_VIEWER_MODAL ? LIB_VIEW_STYLE_MODAL : LIB_VIEW_STYLE, aFrameType == FRAME_SCH_VIEWER_MODAL ? LIB_VIEW_NAME_MODAL : LIB_VIEW_NAME ), m_libList( nullptr ), m_cmpList( nullptr ), m_previewItem( nullptr ) { wxASSERT( aFrameType == FRAME_SCH_VIEWER || aFrameType == FRAME_SCH_VIEWER_MODAL ); if( aFrameType == FRAME_SCH_VIEWER_MODAL ) SetModal( true ); // Force the frame name used in config. the lib viewer frame has a name // depending on aFrameType (needed to identify the frame by wxWidgets), // but only one configuration is preferable. m_configFrameName = LIB_VIEW_NAME; // Give an icon wxIcon icon; icon.CopyFromBitmap( KiBitmap( library_browse_xpm ) ); SetIcon( icon ); m_hotkeysDescrList = g_Viewlib_Hotkeys_Descr; m_libListWidth = 200; m_cmpListWidth = 300; m_listPowerCmpOnly = false; SetShowElectricalType( true ); // Initialize grid id to the default value (50 mils): m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; SetScreen( new SCH_SCREEN( aKiway ) ); GetScreen()->m_Center = true; // Axis origin centered on screen. LoadSettings( config() ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); // Menu bar is not mandatory: uncomment/comment the next line // to add/remove the menubar ReCreateMenuBar(); ReCreateHToolbar(); ReCreateVToolbar(); m_libList = new wxListBox( this, ID_LIBVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL | wxNO_BORDER ); m_cmpList = new wxListBox( this, ID_LIBVIEW_CMP_LIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL | wxNO_BORDER ); if( aLibraryName.empty() ) { ReCreateListLib(); } else { m_libraryName = aLibraryName; m_entryName.Clear(); m_unit = 1; m_convert = 1; } m_selection_changed = false; DisplayLibInfos(); m_auimgr.SetManagedWindow( this ); m_auimgr.SetArtProvider( new EDA_DOCKART( this ) ); // Manage main toolbar m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) ); m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) ); m_auimgr.AddPane( m_libList, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(3) .CaptionVisible( false ).MinSize( 80, -1 ).BestSize( m_libListWidth, -1 ) ); m_auimgr.AddPane( m_cmpList, EDA_PANE().Palette().Name( "Symbols" ).Left().Layer(1) .CaptionVisible( false ).MinSize( 80, -1 ).BestSize( m_cmpListWidth, -1 ) ); m_auimgr.AddPane( m_canvas->GetWindow(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() ); m_auimgr.GetPane( m_libList ).Show( aLibraryName.empty() ); m_auimgr.Update(); setupTools(); GetToolManager()->RunAction( "common.Control.gridPreset", true, m_LastGridSizeId ); GetToolManager()->RunAction( "common.Control.zoomFitScreen", true ); if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame { Raise(); Show( true ); } SyncView(); GetGalCanvas()->GetViewControls()->SetSnapping( true ); GetGalCanvas()->GetGAL()->SetAxesEnabled( true ); GetGalCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() ); // Set the working/draw area size to display a symbol to a reasonable value: // A 450mm x 450mm with a origin at the area center looks like a large working area double max_size_x = Millimeter2iu( 450 ); double max_size_y = Millimeter2iu( 450 ); BOX2D bbox; bbox.SetOrigin( -max_size_x /2, -max_size_y/2 ); bbox.SetSize( max_size_x, max_size_y ); GetCanvas()->GetView()->SetBoundary( bbox ); }
void SCH_EDIT_FRAME::DeleteAnnotation( bool aCurrentSheetOnly ) { if( aCurrentSheetOnly ) { SCH_SCREEN* screen = GetScreen(); wxCHECK_RET( screen != NULL, wxT( "Attempt to clear annotation of a NULL screen." ) ); screen->ClearAnnotation( m_CurrentSheet ); } else { SCH_SCREENS ScreenList; ScreenList.ClearAnnotation(); } // Update the references for the sheet that is currently being displayed. m_CurrentSheet->UpdateAllScreenReferences(); SyncView(); GetCanvas()->Refresh(); OnModify(); }
LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_LIB_EDITOR, _( "Library Editor" ), wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, LIB_EDIT_FRAME_NAME ) { m_showAxis = true; // true to draw axis SetShowDeMorgan( false ); m_DrawSpecificConvert = true; m_DrawSpecificUnit = false; m_hotkeysDescrList = g_Libedit_Hotkeys_Descr; m_SyncPinEdit = false; m_repeatPinStep = DEFAULT_REPEAT_OFFSET_PIN; SetShowElectricalType( true ); m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs m_my_part = NULL; m_treePane = nullptr; m_libMgr = nullptr; m_unit = 1; m_convert = 1; m_AboutTitle = "LibEdit"; // Delayed initialization if( g_LastTextSize == -1 ) g_LastTextSize = GetDefaultTextSize(); // Initialize grid id to the default value 50 mils: m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; wxIcon icon; icon.CopyFromBitmap( KiBitmap( icon_libedit_xpm ) ); SetIcon( icon ); LoadSettings( config() ); // Ensure axis are always drawn KIGFX::GAL_DISPLAY_OPTIONS& gal_opts = GetGalDisplayOptions(); gal_opts.m_axesEnabled = true; m_dummyScreen = new SCH_SCREEN( aKiway ); SetScreen( m_dummyScreen ); GetScreen()->m_Center = true; GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax ); SetCrossHairPosition( wxPoint( 0, 0 ) ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); m_libMgr = new LIB_MANAGER( *this ); SyncLibraries( true ); m_treePane = new SYMBOL_TREE_PANE( this, m_libMgr ); setupTools(); ReCreateMenuBar(); ReCreateHToolbar(); ReCreateVToolbar(); ReCreateOptToolbar(); updateTitle(); DisplayCmpDoc(); RebuildSymbolUnitsList(); m_auimgr.SetManagedWindow( this ); m_auimgr.SetArtProvider( new EDA_DOCKART( this ) ); m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) ); m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) ); m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) ); m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "ComponentTree" ).Left().Layer(1) .Caption( _( "Libraries" ) ).MinSize( 250, -1 ) .BestSize( m_defaultLibWidth, -1 ).Resizable() ); m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) ); m_auimgr.AddPane( m_canvas->GetWindow(), wxAuiPaneInfo().Name( "DrawFrame" ).CentrePane() ); m_auimgr.Update(); GetToolManager()->RunAction( "common.Control.gridPreset", true, m_LastGridSizeId ); Raise(); Show( true ); Bind( wxEVT_COMMAND_MENU_SELECTED, &LIB_EDIT_FRAME::OnConfigurePaths, this, ID_PREFERENCES_CONFIGURE_PATHS ); Bind( wxEVT_COMMAND_MENU_SELECTED, &LIB_EDIT_FRAME::OnEditSymbolLibTable, this, ID_EDIT_SYM_LIB_TABLE ); m_toolManager->RunAction( ACTIONS::zoomFitScreen, true ); SyncView(); GetGalCanvas()->GetViewControls()->SetSnapping( true ); GetGalCanvas()->GetView()->UseDrawPriority( true ); GetGalCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() ); GetGalCanvas()->GetGAL()->SetAxesEnabled( true ); // Set the working/draw area size to display a symbol to a reasonable value: // A 600mm x 600mm with a origin at the area center looks like a large working area double max_size_x = Millimeter2iu( 600 ); double max_size_y = Millimeter2iu( 600 ); BOX2D bbox; bbox.SetOrigin( -max_size_x /2, -max_size_y/2 ); bbox.SetSize( max_size_x, max_size_y ); GetCanvas()->GetView()->SetBoundary( bbox ); }
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(); }