diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 7bc4b9ed88..ea5c2b3144 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -220,6 +220,7 @@ set( PCB_COMMON_SRCS ../pcbnew/class_zone_settings.cpp ../pcbnew/classpcb.cpp ../pcbnew/ratsnest_data.cpp + ../pcbnew/ratsnest_viewitem.cpp ../pcbnew/collectors.cpp ../pcbnew/netlist_reader.cpp ../pcbnew/legacy_netlist_reader.cpp diff --git a/common/worksheet_viewitem.cpp b/common/worksheet_viewitem.cpp index 7ecf6de8d7..ba4185f8af 100644 --- a/common/worksheet_viewitem.cpp +++ b/common/worksheet_viewitem.cpp @@ -36,10 +36,8 @@ using namespace KIGFX; -WORKSHEET_VIEWITEM::WORKSHEET_VIEWITEM( const std::string& aFileName, const std::string& aSheetName, - const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock ) : +WORKSHEET_VIEWITEM::WORKSHEET_VIEWITEM( const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock ) : EDA_ITEM( NOT_USED ), // this item is never added to a BOARD so it needs no type - m_fileName( aFileName ), m_sheetName( aSheetName ), m_titleBlock( aTitleBlock ), m_pageInfo( aPageInfo ), m_sheetNumber( 1 ), m_sheetCount( 1 ) {} diff --git a/include/math/vector2d.h b/include/math/vector2d.h index 09cae7b31f..feee5ff060 100644 --- a/include/math/vector2d.h +++ b/include/math/vector2d.h @@ -31,6 +31,7 @@ #include #include #include +#include #include diff --git a/include/worksheet_viewitem.h b/include/worksheet_viewitem.h index 6380af9fd8..ca506c8577 100644 --- a/include/worksheet_viewitem.h +++ b/include/worksheet_viewitem.h @@ -47,8 +47,7 @@ class GAL; class WORKSHEET_VIEWITEM : public EDA_ITEM { public: - WORKSHEET_VIEWITEM( const std::string& aFileName, const std::string& aSheetName, - const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock ); + WORKSHEET_VIEWITEM( const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock ); /** * Function SetFileName() diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index ab0272f8b4..ff2a89a0d5 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -43,6 +43,8 @@ #include #include #include +#include +#include #include #include @@ -104,7 +106,13 @@ BOARD::BOARD() : SetCurrentNetClass( m_NetClasses.GetDefault()->GetName() ); + // Initialize ratsnest m_ratsnest = new RN_DATA( this ); + m_ratsnestViewItem = new KIGFX::RATSNEST_VIEWITEM( m_ratsnest ); + + // Initialize view item for displaying worksheet frame + m_worksheetViewItem = new KIGFX::WORKSHEET_VIEWITEM( &m_paper, &m_titles ); + m_worksheetViewItem->SetFileName( std::string( m_fileName.mb_str() ) ); } @@ -116,10 +124,11 @@ BOARD::~BOARD() Delete( area_to_remove ); } + delete m_worksheetViewItem; + delete m_ratsnestViewItem; delete m_ratsnest; m_FullRatsnest.clear(); - m_LocalRatsnest.clear(); DeleteMARKERs(); diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index c32d1d90e7..cac0f66ffd 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -58,6 +58,12 @@ class NETLIST; class REPORTER; class RN_DATA; +namespace KIGFX +{ + class RATSNEST_VIEWITEM; + class WORKSHEET_VIEWITEM; +} + // non-owning container of item candidates when searching for items on the same track. typedef std::vector< TRACK* > TRACK_PTRS; @@ -227,6 +233,8 @@ private: EDA_RECT m_BoundingBox; NETINFO_LIST m_NetInfo; ///< net info list (name, design constraints .. RN_DATA* m_ratsnest; + KIGFX::RATSNEST_VIEWITEM* m_ratsnestViewItem; ///< VIEW_ITEM that draws ratsnest + KIGFX::WORKSHEET_VIEWITEM* m_worksheetViewItem; ///< VIEW_ITEM that draws worksheet frame BOARD_DESIGN_SETTINGS m_designSettings; ZONE_SETTINGS m_zoneSettings; @@ -367,6 +375,24 @@ public: return m_ratsnest; } + /** + * Function GetRatsnestViewItem() + * returns VIEW_ITEM responsible for drawing the ratsnest for the board. + */ + KIGFX::RATSNEST_VIEWITEM* GetRatsnestViewItem() const + { + return m_ratsnestViewItem; + } + + /** + * Function GetWorksheetViewItem() + * returns VIEW_ITEM responsible for drawing the worksheet frame. + */ + KIGFX::WORKSHEET_VIEWITEM* GetWorksheetViewItem() const + { + return m_worksheetViewItem; + } + /** * Function DeleteMARKERs * deletes ALL MARKERS from the board. diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index ac4debcc70..64abab4807 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -596,26 +596,22 @@ void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const view->Add( zone ); } - // Add an entry for the worksheet layout - KIGFX::WORKSHEET_VIEWITEM* worksheet = new KIGFX::WORKSHEET_VIEWITEM( - std::string( aBoard->GetFileName().mb_str() ), - std::string( GetScreenDesc().mb_str() ), - &GetPageSettings(), &GetTitleBlock() ); + KIGFX::WORKSHEET_VIEWITEM* worksheet = aBoard->GetWorksheetViewItem(); + worksheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) ); + BASE_SCREEN* screen = GetScreen(); + if( screen != NULL ) { - worksheet->SetSheetNumber( GetScreen()->m_ScreenNumber ); - worksheet->SetSheetCount( GetScreen()->m_NumberOfScreens ); + worksheet->SetSheetNumber( screen->m_ScreenNumber ); + worksheet->SetSheetCount( screen->m_NumberOfScreens ); } view->Add( worksheet ); + view->Add( aBoard->GetRatsnestViewItem() ); - // Add an entry for the ratsnest - RN_DATA* ratsnest = aBoard->GetRatsnest(); - ratsnest->Recalculate(); - view->Add( new KIGFX::RATSNEST_VIEWITEM( ratsnest ) ); - - view->SetPanBoundary( worksheet->ViewBBox() ); + // Limit panning to the size of worksheet frame + view->SetPanBoundary( aBoard->GetWorksheetViewItem()->ViewBBox() ); view->RecacheAllItems( true ); if( IsGalCanvasActive() ) diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index 0aef34f903..646d011404 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -338,9 +338,13 @@ void PNS_ROUTER::ClearWorld() if( m_placer ) delete m_placer; + if( m_previewItems ) + delete m_previewItems; + m_clearanceFunc = NULL; m_world = NULL; m_placer = NULL; + m_previewItems = NULL; } diff --git a/pcbnew/router/pns_solid.h b/pcbnew/router/pns_solid.h index db52c808c4..b6f38a2851 100644 --- a/pcbnew/router/pns_solid.h +++ b/pcbnew/router/pns_solid.h @@ -32,10 +32,14 @@ class PNS_SOLID : public PNS_ITEM { public: - PNS_SOLID() : PNS_ITEM( SOLID ) + PNS_SOLID() : PNS_ITEM( SOLID ), m_shape( NULL ) { m_movable = false; - m_shape = NULL; + } + + ~PNS_SOLID() + { + delete m_shape; } PNS_ITEM* Clone() const;