From 3919b79777dd6403a16f213f391f7ca2cb708c59 Mon Sep 17 00:00:00 2001 From: Russell Oliver Date: Thu, 13 Jul 2017 22:28:35 +1000 Subject: [PATCH] Eeschema Eagle Import: Use bounding box for sheet position and size. --- eeschema/sch_eagle_plugin.cpp | 43 +++++++++++++---------------------- eeschema/sch_eagle_plugin.h | 4 ++-- 2 files changed, 18 insertions(+), 29 deletions(-) diff --git a/eeschema/sch_eagle_plugin.cpp b/eeschema/sch_eagle_plugin.cpp index 9d7e169489..ce57b3184b 100644 --- a/eeschema/sch_eagle_plugin.cpp +++ b/eeschema/sch_eagle_plugin.cpp @@ -512,16 +512,21 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode ) plainNode = plainNode->GetNext(); } - wxSize targetSheetSize( (sheetTopRight.x - sheetBottomLeft.x) * 1.5, - -( sheetTopRight.y - sheetBottomLeft.y) * 1.5 ); - - - wxPoint itemsCentre( (sheetTopRight.x - sheetBottomLeft.x) / 2, - (sheetTopRight.y - sheetBottomLeft.y) / 2 ); - SCH_ITEM* item = m_currentSheet->GetScreen()->GetDrawItems(); - wxSize pageSizeIU = m_currentSheet->GetScreen()->GetPageSettings().GetSizeIU(); + sheetBoundingBox = item->GetBoundingBox(); + item = item->Next(); + while( item ) + { + sheetBoundingBox.Merge( item->GetBoundingBox() ); + item = item->Next(); + } + wxSize targetSheetSize = sheetBoundingBox.GetSize(); + targetSheetSize.IncBy(1500,1500); + + wxPoint itemsCentre = sheetBoundingBox.Centre(); + + wxSize pageSizeIU = m_currentSheet->GetScreen()->GetPageSettings().GetSizeIU(); PAGE_INFO pageInfo = m_currentSheet->GetScreen()->GetPageSettings(); if( pageSizeIU.xGetScreen()->GetDrawItems(); while( item ) { - item->SetPosition( item->GetPosition() +translation); + item->SetPosition( item->GetPosition()+translation ); item = item->Next(); } } @@ -645,18 +652,6 @@ SCH_LINE* SCH_EAGLE_PLUGIN::loadSignalWire( wxXmlNode* aWireNode ) wire->SetStartPoint( begin ); wire->SetEndPoint( end ); - if( begin.x > sheetTopRight.x) sheetTopRight.x = begin.x; - if( begin.y < sheetTopRight.y) sheetTopRight.y = begin.y; - - if( end.x > sheetTopRight.x) sheetTopRight.x = end.x; - if( end.y < sheetTopRight.y) sheetTopRight.y = end.y; - - if( begin.x < sheetBottomLeft.x) sheetBottomLeft.x = begin.x; - if( begin.y > sheetBottomLeft.y) sheetBottomLeft.y = begin.y; - - if( end.x < sheetBottomLeft.x) sheetBottomLeft.x = end.x; - if( end.y > sheetBottomLeft.y) sheetBottomLeft.y = end.y; - return wire.release(); } @@ -670,12 +665,6 @@ SCH_JUNCTION* SCH_EAGLE_PLUGIN::loadJunction( wxXmlNode* aJunction ) junction->SetPosition( pos ); - if( pos.x > sheetTopRight.x) sheetTopRight.x = pos.x; - if( pos.y < sheetTopRight.y) sheetTopRight.y = pos.y; - - if( pos.x < sheetBottomLeft.x) sheetBottomLeft.x = pos.x; - if( pos.y > sheetBottomLeft.y) sheetBottomLeft.y = pos.y; - return junction.release(); } diff --git a/eeschema/sch_eagle_plugin.h b/eeschema/sch_eagle_plugin.h index 90029e67b5..a05d4b4d99 100644 --- a/eeschema/sch_eagle_plugin.h +++ b/eeschema/sch_eagle_plugin.h @@ -133,6 +133,7 @@ private: void loadInstance( wxXmlNode* aInstanceNode ); void loadModuleinst( wxXmlNode* aModuleinstNode ); EAGLE_LIBRARY* loadLibrary( wxXmlNode* aLibraryNode ); + void addBusEntries(); void loadSegments( wxXmlNode* aSegmentsNode, const wxString& aNetName, const wxString& aNetClass ); @@ -159,8 +160,7 @@ private: EPART_LIST m_partlist; std::map m_eaglelibraries; - wxPoint sheetTopRight; - wxPoint sheetBottomLeft; + EDA_RECT sheetBoundingBox; protected: