diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index b939f8914b..2050d1dc3f 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -301,7 +301,6 @@ set( COMMON_SRCS array_axis.cpp array_options.cpp base64.cpp - base_struct.cpp bin_mod.cpp bitmap.cpp bitmap_base.cpp @@ -319,7 +318,9 @@ set( COMMON_SRCS eda_dde.cpp eda_doc.cpp eda_draw_frame.cpp + eda_item.cpp eda_pattern_match.cpp + eda_rect.cpp eda_size_ctrl.cpp env_paths.cpp env_vars.cpp diff --git a/common/base_screen.cpp b/common/base_screen.cpp index c7612766e9..cb025b79c3 100644 --- a/common/base_screen.cpp +++ b/common/base_screen.cpp @@ -25,7 +25,7 @@ */ #include -#include +#include #include diff --git a/common/base_struct.cpp b/common/base_struct.cpp deleted file mode 100644 index 147c7cc223..0000000000 --- a/common/base_struct.cpp +++ /dev/null @@ -1,845 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -/** - * @brief Implementation of EDA_ITEM base class for KiCad. - */ - -#include - -#include -#include -#include -#include -#include - -#include - - -static const unsigned char dummy_png[] = { - 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, - 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0xf3, 0xff, - 0x61, 0x00, 0x00, 0x00, 0x5f, 0x49, 0x44, 0x41, 0x54, 0x38, 0xcb, 0x63, 0xf8, 0xff, 0xff, 0x3f, - 0x03, 0x25, 0x98, 0x61, 0x68, 0x1a, 0x00, 0x04, 0x46, 0x40, 0xfc, 0x02, 0x88, 0x45, 0x41, 0x1c, - 0x76, 0x20, 0xfe, 0x01, 0xc4, 0xbe, 0x24, 0x18, 0x60, 0x01, 0xc4, 0x20, 0x86, 0x04, 0x88, 0xc3, - 0x01, 0xe5, 0x04, 0x0c, 0xb8, 0x01, 0x37, 0x81, 0xf8, 0x04, 0x91, 0xf8, 0x0a, 0x54, 0x8f, 0x06, - 0xb2, 0x01, 0x9b, 0x81, 0x78, 0x02, 0x91, 0x78, 0x05, 0x54, 0x8f, 0xca, 0xe0, 0x08, 0x03, 0x36, - 0xa8, 0xbf, 0xec, 0xc8, 0x32, 0x80, 0xcc, 0x84, 0x04, 0x0a, 0xbc, 0x1d, 0x40, 0x2c, 0xc8, 0x30, - 0xf4, 0x33, 0x13, 0x00, 0x6b, 0x1a, 0x46, 0x7b, 0x68, 0xe7, 0x0f, 0x0b, 0x00, 0x00, 0x00, 0x00, - 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, -}; - -static const BITMAP_OPAQUE dummy_xpm[1] = {{ dummy_png, sizeof( dummy_png ), "dummy_xpm" }}; - - -EDA_ITEM::EDA_ITEM( EDA_ITEM* parent, KICAD_T idType ) : - m_StructType( idType ), - m_Status( 0 ), - m_Parent( parent ), - m_forceVisible( false ), - m_Flags( 0 ) -{ } - - -EDA_ITEM::EDA_ITEM( KICAD_T idType ) : - m_StructType( idType ), - m_Status( 0 ), - m_Parent( nullptr ), - m_forceVisible( false ), - m_Flags( 0 ) -{ } - - -EDA_ITEM::EDA_ITEM( const EDA_ITEM& base ) : - m_Uuid( base.m_Uuid ), - m_StructType( base.m_StructType ), - m_Status( base.m_Status ), - m_Parent( base.m_Parent ), - m_forceVisible( base.m_forceVisible ), - m_Flags( base.m_Flags ) -{ } - - -void EDA_ITEM::SetModified() -{ - SetFlags( IS_CHANGED ); - - // If this a child object, then the parent modification state also needs to be set. - if( m_Parent ) - m_Parent->SetModified(); -} - - -const EDA_RECT EDA_ITEM::GetBoundingBox() const -{ - // return a zero-sized box per default. derived classes should override - // this - return EDA_RECT( wxPoint( 0, 0 ), wxSize( 0, 0 ) ); -} - - -EDA_ITEM* EDA_ITEM::Clone() const -{ - wxCHECK_MSG( false, NULL, wxT( "Clone not implemented in derived class " ) + GetClass() + - wxT( ". Bad programmer!" ) ); -} - - -// see base_struct.h -// many classes inherit this method, be careful: -//TODO (snh): Fix this to use std::set instead of C-style vector -SEARCH_RESULT EDA_ITEM::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) -{ -#if 0 && defined(DEBUG) - std::cout << GetClass().mb_str() << ' '; -#endif - - if( IsType( scanTypes ) ) - { - if( SEARCH_RESULT::QUIT == inspector( this, testData ) ) - return SEARCH_RESULT::QUIT; - } - - return SEARCH_RESULT::CONTINUE; -} - - -wxString EDA_ITEM::GetSelectMenuText( EDA_UNITS aUnits ) const -{ - wxFAIL_MSG( wxT( "GetSelectMenuText() was not overridden for schematic item type " ) + - GetClass() ); - - return wxString( wxT( "Undefined menu text for " ) + GetClass() ); -} - - -bool EDA_ITEM::Matches( const wxString& aText, wxFindReplaceData& aSearchData ) -{ - wxString text = aText; - wxString searchText = aSearchData.GetFindString(); - - // Don't match if searching for replaceable item and the item doesn't support text replace. - if( (aSearchData.GetFlags() & FR_SEARCH_REPLACE) && !IsReplaceable() ) - return false; - - if( aSearchData.GetFlags() & wxFR_WHOLEWORD ) - return aText.IsSameAs( searchText, aSearchData.GetFlags() & wxFR_MATCHCASE ); - - if( aSearchData.GetFlags() & FR_MATCH_WILDCARD ) - { - if( aSearchData.GetFlags() & wxFR_MATCHCASE ) - return text.Matches( searchText ); - - return text.MakeUpper().Matches( searchText.MakeUpper() ); - } - - if( aSearchData.GetFlags() & wxFR_MATCHCASE ) - return aText.Find( searchText ) != wxNOT_FOUND; - - return text.MakeUpper().Find( searchText.MakeUpper() ) != wxNOT_FOUND; -} - - -bool EDA_ITEM::Replace( wxFindReplaceData& aSearchData, wxString& aText ) -{ - wxString searchString = (aSearchData.GetFlags() & wxFR_MATCHCASE) ? aText : aText.Upper(); - - int result = searchString.Find( (aSearchData.GetFlags() & wxFR_MATCHCASE) ? - aSearchData.GetFindString() : - aSearchData.GetFindString().Upper() ); - - if( result == wxNOT_FOUND ) - return false; - - wxString prefix = aText.Left( result ); - wxString suffix; - - if( aSearchData.GetFindString().length() + result < aText.length() ) - suffix = aText.Right( aText.length() - ( aSearchData.GetFindString().length() + result ) ); - - wxLogTrace( traceFindReplace, wxT( "Replacing '%s', prefix '%s', replace '%s', suffix '%s'." ), - GetChars( aText ), GetChars( prefix ), GetChars( aSearchData.GetReplaceString() ), - GetChars( suffix ) ); - - aText = prefix + aSearchData.GetReplaceString() + suffix; - - return true; -} - - -bool EDA_ITEM::operator<( const EDA_ITEM& aItem ) const -{ - wxFAIL_MSG( wxString::Format( wxT( "Less than operator not defined for item type %s." ), - GetChars( GetClass() ) ) ); - - return false; -} - -EDA_ITEM& EDA_ITEM::operator=( const EDA_ITEM& aItem ) -{ - // do not call initVars() - - m_StructType = aItem.m_StructType; - m_Flags = aItem.m_Flags; - m_Status = aItem.m_Status; - m_Parent = aItem.m_Parent; - m_forceVisible = aItem.m_forceVisible; - - return *this; -} - -const BOX2I EDA_ITEM::ViewBBox() const -{ - // Basic fallback - return BOX2I( VECTOR2I( GetBoundingBox().GetOrigin() ), - VECTOR2I( GetBoundingBox().GetSize() ) ); -} - - -void EDA_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const -{ - // Basic fallback - aCount = 1; - aLayers[0] = 0; -} - -BITMAP_DEF EDA_ITEM::GetMenuImage() const -{ - return dummy_xpm; -} - -#if defined(DEBUG) - -void EDA_ITEM::ShowDummy( std::ostream& os ) const -{ - // XML output: - wxString s = GetClass(); - - os << '<' << s.Lower().mb_str() << ">" - << " Need ::Show() override for this class " - << "\n"; -} - - -std::ostream& EDA_ITEM::NestedSpace( int nestLevel, std::ostream& os ) -{ - for( int i = 0; i= 0) && (rel_pos.y >= 0) && ( rel_pos.y <= size.y) && ( rel_pos.x <= size.x); -} - - -bool EDA_RECT::Contains( const EDA_RECT& aRect ) const -{ - return Contains( aRect.GetOrigin() ) && Contains( aRect.GetEnd() ); -} - - -bool EDA_RECT::Intersects( const wxPoint& aPoint1, const wxPoint& aPoint2 ) const -{ - wxPoint point2, point4; - - if( Contains( aPoint1 ) || Contains( aPoint2 ) ) - return true; - - point2.x = GetEnd().x; - point2.y = GetOrigin().y; - point4.x = GetOrigin().x; - point4.y = GetEnd().y; - - //Only need to test 3 sides since a straight line cant enter and exit on same side - if( SegmentIntersectsSegment( aPoint1, aPoint2, GetOrigin() , point2 ) ) - return true; - - if( SegmentIntersectsSegment( aPoint1, aPoint2, point2 , GetEnd() ) ) - return true; - - if( SegmentIntersectsSegment( aPoint1, aPoint2, GetEnd() , point4 ) ) - return true; - - return false; -} - - -bool EDA_RECT::Intersects( const wxPoint& aPoint1, const wxPoint& aPoint2, - wxPoint* aIntersection1, wxPoint* aIntersection2 ) const -{ - wxPoint point2, point4; - - point2.x = GetEnd().x; - point2.y = GetOrigin().y; - point4.x = GetOrigin().x; - point4.y = GetEnd().y; - - bool intersects = false; - - wxPoint* aPointToFill = aIntersection1; - - if( SegmentIntersectsSegment( aPoint1, aPoint2, GetOrigin(), point2, aPointToFill ) ) - intersects = true; - - if( intersects ) - aPointToFill = aIntersection2; - - if( SegmentIntersectsSegment( aPoint1, aPoint2, point2, GetEnd(), aPointToFill ) ) - intersects = true; - - if( intersects ) - aPointToFill = aIntersection2; - - if( SegmentIntersectsSegment( aPoint1, aPoint2, GetEnd(), point4, aPointToFill ) ) - intersects = true; - - if( intersects ) - aPointToFill = aIntersection2; - - if( SegmentIntersectsSegment( aPoint1, aPoint2, point4, GetOrigin(), aPointToFill ) ) - intersects = true; - - return intersects; -} - - -bool EDA_RECT::Intersects( const EDA_RECT& aRect ) const -{ - if( !m_init ) - return false; - - // this logic taken from wxWidgets' geometry.cpp file: - bool rc; - EDA_RECT me(*this); - EDA_RECT rect(aRect); - me.Normalize(); // ensure size is >= 0 - rect.Normalize(); // ensure size is >= 0 - - // calculate the left common area coordinate: - int left = std::max( me.m_Pos.x, rect.m_Pos.x ); - // calculate the right common area coordinate: - int right = std::min( me.m_Pos.x + me.m_Size.x, rect.m_Pos.x + rect.m_Size.x ); - // calculate the upper common area coordinate: - int top = std::max( me.m_Pos.y, aRect.m_Pos.y ); - // calculate the lower common area coordinate: - int bottom = std::min( me.m_Pos.y + me.m_Size.y, rect.m_Pos.y + rect.m_Size.y ); - - // if a common area exists, it must have a positive (null accepted) size - if( left <= right && top <= bottom ) - rc = true; - else - rc = false; - - return rc; -} - - -bool EDA_RECT::Intersects( const EDA_RECT& aRect, double aRot ) const -{ - if( !m_init ) - return false; - - /* Most rectangles will be axis aligned. - * It is quicker to check for this case and pass the rect - * to the simpler intersection test - */ - - // Prevent floating point comparison errors - static const double ROT_EPS = 0.000000001; - - static const double ROT_PARALLEL[] = { -3600, -1800, 0, 1800, 3600 }; - static const double ROT_PERPENDICULAR[] = { -2700, -900, 0, 900, 2700 }; - - NORMALIZE_ANGLE_POS( aRot ); - - // Test for non-rotated rectangle - for( int ii = 0; ii < 5; ii++ ) - { - if( std::fabs( aRot - ROT_PARALLEL[ii] ) < ROT_EPS ) - { - return Intersects( aRect ); - } - } - - // Test for rectangle rotated by multiple of 90 degrees - for( int jj = 0; jj < 4; jj++ ) - { - if( std::fabs( aRot - ROT_PERPENDICULAR[jj] ) < ROT_EPS ) - { - EDA_RECT rotRect; - - // Rotate the supplied rect by 90 degrees - rotRect.SetOrigin( aRect.Centre() ); - rotRect.Inflate( aRect.GetHeight(), aRect.GetWidth() ); - return Intersects( rotRect ); - } - } - - /* There is some non-orthogonal rotation. - * There are three cases to test: - * A) One point of this rect is inside the rotated rect - * B) One point of the rotated rect is inside this rect - * C) One of the sides of the rotated rect intersect this - */ - - wxPoint corners[4]; - - /* Test A : Any corners exist in rotated rect? */ - - corners[0] = m_Pos; - corners[1] = m_Pos + wxPoint( m_Size.x, 0 ); - corners[2] = m_Pos + wxPoint( m_Size.x, m_Size.y ); - corners[3] = m_Pos + wxPoint( 0, m_Size.y ); - - wxPoint rCentre = aRect.Centre(); - - for( int i = 0; i < 4; i++ ) - { - wxPoint delta = corners[i] - rCentre; - RotatePoint( &delta, -aRot ); - delta += rCentre; - - if( aRect.Contains( delta ) ) - { - return true; - } - } - - /* Test B : Any corners of rotated rect exist in this one? */ - int w = aRect.GetWidth() / 2; - int h = aRect.GetHeight() / 2; - - // Construct corners around center of shape - corners[0] = wxPoint( -w, -h ); - corners[1] = wxPoint( w, -h ); - corners[2] = wxPoint( w, h ); - corners[3] = wxPoint( -w, h ); - - // Rotate and test each corner - for( int j=0; j<4; j++ ) - { - RotatePoint( &corners[j], aRot ); - corners[j] += rCentre; - - if( Contains( corners[j] ) ) - { - return true; - } - } - - /* Test C : Any sides of rotated rect intersect this */ - - if( Intersects( corners[0], corners[1] ) || - Intersects( corners[1], corners[2] ) || - Intersects( corners[2], corners[3] ) || - Intersects( corners[3], corners[0] ) ) - { - return true; - } - - - return false; -} - - -const wxPoint EDA_RECT::ClosestPointTo( const wxPoint& aPoint ) const -{ - EDA_RECT me( *this ); - - me.Normalize(); // ensure size is >= 0 - - // Determine closest point to the circle centre within this rect - int nx = std::max( me.GetLeft(), std::min( aPoint.x, me.GetRight() ) ); - int ny = std::max( me.GetTop(), std::min( aPoint.y, me.GetBottom() ) ); - - return wxPoint( nx, ny ); -} - - -const wxPoint EDA_RECT::FarthestPointTo( const wxPoint& aPoint ) const -{ - EDA_RECT me( *this ); - - me.Normalize(); // ensure size is >= 0 - - int fx = std::max( std::abs( aPoint.x - me.GetLeft() ), std::abs( aPoint.x - me.GetRight() ) ); - int fy = std::max( std::abs( aPoint.y - me.GetTop() ), std::abs( aPoint.y - me.GetBottom() ) ); - - return wxPoint( fx, fy ); -} - - -bool EDA_RECT::IntersectsCircle( const wxPoint& aCenter, const int aRadius ) const -{ - if( !m_init ) - return false; - - wxPoint closest = ClosestPointTo( aCenter ); - - double dx = static_cast( aCenter.x ) - closest.x; - double dy = static_cast( aCenter.y ) - closest.y; - - double r = static_cast( aRadius ); - - return ( dx * dx + dy * dy ) <= ( r * r ); -} - - -bool EDA_RECT::IntersectsCircleEdge( const wxPoint& aCenter, const int aRadius, const int aWidth ) const -{ - if( !m_init ) - return false; - - EDA_RECT me( *this ); - me.Normalize(); // ensure size is >= 0 - - // Test if the circle intersects at all - if( !IntersectsCircle( aCenter, aRadius + aWidth / 2 ) ) - { - return false; - } - - wxPoint farpt = FarthestPointTo( aCenter ); - // Farthest point must be further than the inside of the line - double fx = (double) farpt.x; - double fy = (double) farpt.y; - - double r = (double) aRadius - (double) aWidth / 2; - - return ( fx * fx + fy * fy ) > ( r * r ); -} - - -EDA_RECT& EDA_RECT::Inflate( int aDelta ) -{ - Inflate( aDelta, aDelta ); - return *this; -} - - -EDA_RECT& EDA_RECT::Inflate( wxCoord dx, wxCoord dy ) -{ - if( m_Size.x >= 0 ) - { - if( m_Size.x < -2 * dx ) - { - // Don't allow deflate to eat more width than we have, - m_Pos.x += m_Size.x / 2; - m_Size.x = 0; - } - else - { - // The inflate is valid. - m_Pos.x -= dx; - m_Size.x += 2 * dx; - } - } - else // size.x < 0: - { - if( m_Size.x > -2 * dx ) - { - // Don't allow deflate to eat more width than we have, - m_Pos.x -= m_Size.x / 2; - m_Size.x = 0; - } - else - { - // The inflate is valid. - m_Pos.x += dx; - m_Size.x -= 2 * dx; // m_Size.x <0: inflate when dx > 0 - } - } - - if( m_Size.y >= 0 ) - { - if( m_Size.y < -2 * dy ) - { - // Don't allow deflate to eat more height than we have, - m_Pos.y += m_Size.y / 2; - m_Size.y = 0; - } - else - { - // The inflate is valid. - m_Pos.y -= dy; - m_Size.y += 2 * dy; - } - } - else // size.y < 0: - { - if( m_Size.y > 2 * dy ) - { - // Don't allow deflate to eat more height than we have, - m_Pos.y -= m_Size.y / 2; - m_Size.y = 0; - } - else - { - // The inflate is valid. - m_Pos.y += dy; - m_Size.y -= 2 * dy; // m_Size.y <0: inflate when dy > 0 - } - } - - return *this; -} - - -void EDA_RECT::Merge( const EDA_RECT& aRect ) -{ - if( !m_init ) - { - if( aRect.IsValid() ) - { - m_Pos = aRect.GetPosition(); - m_Size = aRect.GetSize(); - m_init = true; - } - return; - } - - Normalize(); // ensure width and height >= 0 - EDA_RECT rect = aRect; - rect.Normalize(); // ensure width and height >= 0 - wxPoint end = GetEnd(); - wxPoint rect_end = rect.GetEnd(); - - // Change origin and size in order to contain the given rect - m_Pos.x = std::min( m_Pos.x, rect.m_Pos.x ); - m_Pos.y = std::min( m_Pos.y, rect.m_Pos.y ); - end.x = std::max( end.x, rect_end.x ); - end.y = std::max( end.y, rect_end.y ); - SetEnd( end ); -} - - -void EDA_RECT::Merge( const wxPoint& aPoint ) -{ - if( !m_init ) - { - m_Pos = aPoint; - m_Size = wxSize( 0, 0 ); - m_init = true; - return; - } - - Normalize(); // ensure width and height >= 0 - - wxPoint end = GetEnd(); - // Change origin and size in order to contain the given rect - m_Pos.x = std::min( m_Pos.x, aPoint.x ); - m_Pos.y = std::min( m_Pos.y, aPoint.y ); - end.x = std::max( end.x, aPoint.x ); - end.y = std::max( end.y, aPoint.y ); - SetEnd( end ); -} - - -double EDA_RECT::GetArea() const -{ - return (double) GetWidth() * (double) GetHeight(); -} - - -EDA_RECT EDA_RECT::Common( const EDA_RECT& aRect ) const -{ - EDA_RECT r; - - if( Intersects( aRect ) ) - { - wxPoint originA( std::min( GetOrigin().x, GetEnd().x ), - std::min( GetOrigin().y, GetEnd().y ) ); - wxPoint originB( std::min( aRect.GetOrigin().x, aRect.GetEnd().x ), - std::min( aRect.GetOrigin().y, aRect.GetEnd().y ) ); - wxPoint endA( std::max( GetOrigin().x, GetEnd().x ), - std::max( GetOrigin().y, GetEnd().y ) ); - wxPoint endB( std::max( aRect.GetOrigin().x, aRect.GetEnd().x ), - std::max( aRect.GetOrigin().y, aRect.GetEnd().y ) ); - - r.SetOrigin( wxPoint( std::max( originA.x, originB.x ), std::max( originA.y, originB.y ) ) ); - r.SetEnd ( wxPoint( std::min( endA.x, endB.x ), std::min( endA.y, endB.y ) ) ); - } - - return r; -} - - -const EDA_RECT EDA_RECT::GetBoundingBoxRotated( wxPoint aRotCenter, double aAngle ) const -{ - wxPoint corners[4]; - - // Build the corners list - corners[0] = GetOrigin(); - corners[2] = GetEnd(); - corners[1].x = corners[0].x; - corners[1].y = corners[2].y; - corners[3].x = corners[2].x; - corners[3].y = corners[0].y; - - // Rotate all corners, to find the bounding box - for( int ii = 0; ii < 4; ii ++ ) - RotatePoint( &corners[ii], aRotCenter, aAngle ); - - // Find the corners bounding box - wxPoint start = corners[0]; - wxPoint end = corners[0]; - - for( int ii = 1; ii < 4; ii ++ ) - { - start.x = std::min( start.x, corners[ii].x); - start.y = std::min( start.y, corners[ii].y); - end.x = std::max( end.x, corners[ii].x); - end.y = std::max( end.y, corners[ii].y); - } - - EDA_RECT bbox; - bbox.SetOrigin( start ); - bbox.SetEnd( end ); - - return bbox; -} - - -static struct EDA_ITEM_DESC -{ - EDA_ITEM_DESC() - { - ENUM_MAP::Instance() - .Undefined( TYPE_NOT_INIT ) - .Map( NOT_USED, wxT( "" ) ) - .Map( SCREEN_T, _( "Screen" ) ) - - .Map( PCB_MODULE_T, _( "Footprint" ) ) - .Map( PCB_PAD_T, _( "Pad" ) ) - .Map( PCB_SHAPE_T, _( "Graphic Shape" ) ) - .Map( PCB_TEXT_T, _( "Board Text" ) ) - .Map( PCB_FP_TEXT_T, _( "Footprint Text" ) ) - .Map( PCB_FP_SHAPE_T, _( "Graphic Shape" ) ) - .Map( PCB_TRACE_T, _( "Track" ) ) - .Map( PCB_VIA_T, _( "Via" ) ) - .Map( PCB_MARKER_T, _( "Board Marker" ) ) - .Map( PCB_DIM_ALIGNED_T, _( "Aligned Dimension" ) ) - .Map( PCB_DIM_ORTHOGONAL_T, _( "Orthogonal Dimension" ) ) - .Map( PCB_DIM_CENTER_T, _( "Center Dimension" ) ) - .Map( PCB_DIM_LEADER_T, _( "Leader" ) ) - .Map( PCB_TARGET_T, _( "Target" ) ) - .Map( PCB_ZONE_AREA_T, _( "Zone" ) ) - .Map( PCB_ITEM_LIST_T, _( "Item List" ) ) - .Map( PCB_NETINFO_T, _( "Net Info" ) ) - .Map( PCB_GROUP_T, _( "Group" ) ) - - .Map( SCH_MARKER_T, _( "Schematic Marker" ) ) - .Map( SCH_JUNCTION_T, _( "Junction" ) ) - .Map( SCH_NO_CONNECT_T, _( "No-Connect Flag" ) ) - .Map( SCH_BUS_WIRE_ENTRY_T, _( "Wire Entry" ) ) - .Map( SCH_BUS_BUS_ENTRY_T, _( "Bus Entry" ) ) - .Map( SCH_LINE_T, _( "Graphic Line" ) ) - .Map( SCH_BITMAP_T, _( "Bitmap" ) ) - .Map( SCH_TEXT_T, _( "Schematic Text" ) ) - .Map( SCH_LABEL_T, _( "Net Label" ) ) - .Map( SCH_GLOBAL_LABEL_T, _( "Global Label" ) ) - .Map( SCH_HIER_LABEL_T, _( "Hierarchical Label" ) ) - .Map( SCH_FIELD_T, _( "Schematic Field" ) ) - .Map( SCH_COMPONENT_T, _( "Component" ) ) - .Map( SCH_SHEET_PIN_T, _( "Sheet Pin" ) ) - .Map( SCH_SHEET_T, _( "Sheet" ) ) - - .Map( SCH_FIELD_LOCATE_REFERENCE_T, _( "Field Locate Reference" ) ) - .Map( SCH_FIELD_LOCATE_VALUE_T, _( "Field Locate Value" ) ) - .Map( SCH_FIELD_LOCATE_FOOTPRINT_T, _( "Field Locate Footprint" ) ) - - .Map( SCH_SCREEN_T, _( "SCH Screen" ) ) - - .Map( LIB_PART_T, _( "Symbol" ) ) - .Map( LIB_ALIAS_T, _( "Alias" ) ) - .Map( LIB_ARC_T, _( "Arc" ) ) - .Map( LIB_CIRCLE_T, _( "Circle" ) ) - .Map( LIB_TEXT_T, _( "Symbol Text" ) ) - .Map( LIB_RECTANGLE_T, _( "Rectangle" ) ) - .Map( LIB_POLYLINE_T, _( "Polyline" ) ) - .Map( LIB_BEZIER_T, _( "Bezier" ) ) - .Map( LIB_PIN_T, _( "Pin" ) ) - .Map( LIB_FIELD_T, _( "Symbol Field" ) ) - - .Map( GERBER_LAYOUT_T, _( "Gerber Layout" ) ) - .Map( GERBER_DRAW_ITEM_T, _( "Draw Item" ) ) - .Map( GERBER_IMAGE_T, _( "Image" ) ); - - PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); - REGISTER_TYPE( EDA_ITEM ); - propMgr.AddProperty( new PROPERTY_ENUM( "Type", - NO_SETTER( EDA_ITEM, KICAD_T ), &EDA_ITEM::Type ) ); - } -} _EDA_ITEM_DESC; - -ENUM_TO_WXANY( KICAD_T ); diff --git a/common/commit.cpp b/common/commit.cpp index 1e24071a1f..8ba3e89de2 100644 --- a/common/commit.cpp +++ b/common/commit.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include COMMIT::COMMIT() { diff --git a/common/dialogs/dialog_page_settings.cpp b/common/dialogs/dialog_page_settings.cpp index a80ae93d1d..f9be3007b9 100644 --- a/common/dialogs/dialog_page_settings.cpp +++ b/common/dialogs/dialog_page_settings.cpp @@ -22,10 +22,10 @@ */ #include -#include #include #include #include +#include #include #include // for KiROUND, Clamp #include diff --git a/common/eda_item.cpp b/common/eda_item.cpp new file mode 100644 index 0000000000..f88716c6aa --- /dev/null +++ b/common/eda_item.cpp @@ -0,0 +1,330 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/** + * @brief Implementation of EDA_ITEM base class for KiCad. + */ + +#include + +#include +#include +#include +#include +#include + +#include + + +static const unsigned char dummy_png[] = { + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0xf3, 0xff, + 0x61, 0x00, 0x00, 0x00, 0x5f, 0x49, 0x44, 0x41, 0x54, 0x38, 0xcb, 0x63, 0xf8, 0xff, 0xff, 0x3f, + 0x03, 0x25, 0x98, 0x61, 0x68, 0x1a, 0x00, 0x04, 0x46, 0x40, 0xfc, 0x02, 0x88, 0x45, 0x41, 0x1c, + 0x76, 0x20, 0xfe, 0x01, 0xc4, 0xbe, 0x24, 0x18, 0x60, 0x01, 0xc4, 0x20, 0x86, 0x04, 0x88, 0xc3, + 0x01, 0xe5, 0x04, 0x0c, 0xb8, 0x01, 0x37, 0x81, 0xf8, 0x04, 0x91, 0xf8, 0x0a, 0x54, 0x8f, 0x06, + 0xb2, 0x01, 0x9b, 0x81, 0x78, 0x02, 0x91, 0x78, 0x05, 0x54, 0x8f, 0xca, 0xe0, 0x08, 0x03, 0x36, + 0xa8, 0xbf, 0xec, 0xc8, 0x32, 0x80, 0xcc, 0x84, 0x04, 0x0a, 0xbc, 0x1d, 0x40, 0x2c, 0xc8, 0x30, + 0xf4, 0x33, 0x13, 0x00, 0x6b, 0x1a, 0x46, 0x7b, 0x68, 0xe7, 0x0f, 0x0b, 0x00, 0x00, 0x00, 0x00, + 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, +}; + +static const BITMAP_OPAQUE dummy_xpm[1] = {{ dummy_png, sizeof( dummy_png ), "dummy_xpm" }}; + + +EDA_ITEM::EDA_ITEM( EDA_ITEM* parent, KICAD_T idType ) : + m_StructType( idType ), + m_Status( 0 ), + m_Parent( parent ), + m_forceVisible( false ), + m_Flags( 0 ) +{ } + + +EDA_ITEM::EDA_ITEM( KICAD_T idType ) : + m_StructType( idType ), + m_Status( 0 ), + m_Parent( nullptr ), + m_forceVisible( false ), + m_Flags( 0 ) +{ } + + +EDA_ITEM::EDA_ITEM( const EDA_ITEM& base ) : + m_Uuid( base.m_Uuid ), + m_StructType( base.m_StructType ), + m_Status( base.m_Status ), + m_Parent( base.m_Parent ), + m_forceVisible( base.m_forceVisible ), + m_Flags( base.m_Flags ) +{ } + + +void EDA_ITEM::SetModified() +{ + SetFlags( IS_CHANGED ); + + // If this a child object, then the parent modification state also needs to be set. + if( m_Parent ) + m_Parent->SetModified(); +} + + +const EDA_RECT EDA_ITEM::GetBoundingBox() const +{ + // return a zero-sized box per default. derived classes should override + // this + return EDA_RECT( wxPoint( 0, 0 ), wxSize( 0, 0 ) ); +} + + +EDA_ITEM* EDA_ITEM::Clone() const +{ + wxCHECK_MSG( false, NULL, wxT( "Clone not implemented in derived class " ) + GetClass() + + wxT( ". Bad programmer!" ) ); +} + + +// see base_struct.h +// many classes inherit this method, be careful: +//TODO (snh): Fix this to use std::set instead of C-style vector +SEARCH_RESULT EDA_ITEM::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) +{ +#if 0 && defined(DEBUG) + std::cout << GetClass().mb_str() << ' '; +#endif + + if( IsType( scanTypes ) ) + { + if( SEARCH_RESULT::QUIT == inspector( this, testData ) ) + return SEARCH_RESULT::QUIT; + } + + return SEARCH_RESULT::CONTINUE; +} + + +wxString EDA_ITEM::GetSelectMenuText( EDA_UNITS aUnits ) const +{ + wxFAIL_MSG( wxT( "GetSelectMenuText() was not overridden for schematic item type " ) + + GetClass() ); + + return wxString( wxT( "Undefined menu text for " ) + GetClass() ); +} + + +bool EDA_ITEM::Matches( const wxString& aText, wxFindReplaceData& aSearchData ) +{ + wxString text = aText; + wxString searchText = aSearchData.GetFindString(); + + // Don't match if searching for replaceable item and the item doesn't support text replace. + if( (aSearchData.GetFlags() & FR_SEARCH_REPLACE) && !IsReplaceable() ) + return false; + + if( aSearchData.GetFlags() & wxFR_WHOLEWORD ) + return aText.IsSameAs( searchText, aSearchData.GetFlags() & wxFR_MATCHCASE ); + + if( aSearchData.GetFlags() & FR_MATCH_WILDCARD ) + { + if( aSearchData.GetFlags() & wxFR_MATCHCASE ) + return text.Matches( searchText ); + + return text.MakeUpper().Matches( searchText.MakeUpper() ); + } + + if( aSearchData.GetFlags() & wxFR_MATCHCASE ) + return aText.Find( searchText ) != wxNOT_FOUND; + + return text.MakeUpper().Find( searchText.MakeUpper() ) != wxNOT_FOUND; +} + + +bool EDA_ITEM::Replace( wxFindReplaceData& aSearchData, wxString& aText ) +{ + wxString searchString = (aSearchData.GetFlags() & wxFR_MATCHCASE) ? aText : aText.Upper(); + + int result = searchString.Find( (aSearchData.GetFlags() & wxFR_MATCHCASE) ? + aSearchData.GetFindString() : + aSearchData.GetFindString().Upper() ); + + if( result == wxNOT_FOUND ) + return false; + + wxString prefix = aText.Left( result ); + wxString suffix; + + if( aSearchData.GetFindString().length() + result < aText.length() ) + suffix = aText.Right( aText.length() - ( aSearchData.GetFindString().length() + result ) ); + + wxLogTrace( traceFindReplace, wxT( "Replacing '%s', prefix '%s', replace '%s', suffix '%s'." ), + GetChars( aText ), GetChars( prefix ), GetChars( aSearchData.GetReplaceString() ), + GetChars( suffix ) ); + + aText = prefix + aSearchData.GetReplaceString() + suffix; + + return true; +} + + +bool EDA_ITEM::operator<( const EDA_ITEM& aItem ) const +{ + wxFAIL_MSG( wxString::Format( wxT( "Less than operator not defined for item type %s." ), + GetChars( GetClass() ) ) ); + + return false; +} + +EDA_ITEM& EDA_ITEM::operator=( const EDA_ITEM& aItem ) +{ + // do not call initVars() + + m_StructType = aItem.m_StructType; + m_Flags = aItem.m_Flags; + m_Status = aItem.m_Status; + m_Parent = aItem.m_Parent; + m_forceVisible = aItem.m_forceVisible; + + return *this; +} + +const BOX2I EDA_ITEM::ViewBBox() const +{ + // Basic fallback + return BOX2I( VECTOR2I( GetBoundingBox().GetOrigin() ), + VECTOR2I( GetBoundingBox().GetSize() ) ); +} + + +void EDA_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const +{ + // Basic fallback + aCount = 1; + aLayers[0] = 0; +} + +BITMAP_DEF EDA_ITEM::GetMenuImage() const +{ + return dummy_xpm; +} + +#if defined(DEBUG) + +void EDA_ITEM::ShowDummy( std::ostream& os ) const +{ + // XML output: + wxString s = GetClass(); + + os << '<' << s.Lower().mb_str() << ">" + << " Need ::Show() override for this class " + << "\n"; +} + + +std::ostream& EDA_ITEM::NestedSpace( int nestLevel, std::ostream& os ) +{ + for( int i = 0; i::Instance() + .Undefined( TYPE_NOT_INIT ) + .Map( NOT_USED, wxT( "" ) ) + .Map( SCREEN_T, _( "Screen" ) ) + + .Map( PCB_MODULE_T, _( "Footprint" ) ) + .Map( PCB_PAD_T, _( "Pad" ) ) + .Map( PCB_SHAPE_T, _( "Graphic Shape" ) ) + .Map( PCB_TEXT_T, _( "Board Text" ) ) + .Map( PCB_FP_TEXT_T, _( "Footprint Text" ) ) + .Map( PCB_FP_SHAPE_T, _( "Graphic Shape" ) ) + .Map( PCB_TRACE_T, _( "Track" ) ) + .Map( PCB_VIA_T, _( "Via" ) ) + .Map( PCB_MARKER_T, _( "Board Marker" ) ) + .Map( PCB_DIM_ALIGNED_T, _( "Aligned Dimension" ) ) + .Map( PCB_DIM_ORTHOGONAL_T, _( "Orthogonal Dimension" ) ) + .Map( PCB_DIM_CENTER_T, _( "Center Dimension" ) ) + .Map( PCB_DIM_LEADER_T, _( "Leader" ) ) + .Map( PCB_TARGET_T, _( "Target" ) ) + .Map( PCB_ZONE_AREA_T, _( "Zone" ) ) + .Map( PCB_ITEM_LIST_T, _( "Item List" ) ) + .Map( PCB_NETINFO_T, _( "Net Info" ) ) + .Map( PCB_GROUP_T, _( "Group" ) ) + + .Map( SCH_MARKER_T, _( "Schematic Marker" ) ) + .Map( SCH_JUNCTION_T, _( "Junction" ) ) + .Map( SCH_NO_CONNECT_T, _( "No-Connect Flag" ) ) + .Map( SCH_BUS_WIRE_ENTRY_T, _( "Wire Entry" ) ) + .Map( SCH_BUS_BUS_ENTRY_T, _( "Bus Entry" ) ) + .Map( SCH_LINE_T, _( "Graphic Line" ) ) + .Map( SCH_BITMAP_T, _( "Bitmap" ) ) + .Map( SCH_TEXT_T, _( "Schematic Text" ) ) + .Map( SCH_LABEL_T, _( "Net Label" ) ) + .Map( SCH_GLOBAL_LABEL_T, _( "Global Label" ) ) + .Map( SCH_HIER_LABEL_T, _( "Hierarchical Label" ) ) + .Map( SCH_FIELD_T, _( "Schematic Field" ) ) + .Map( SCH_COMPONENT_T, _( "Component" ) ) + .Map( SCH_SHEET_PIN_T, _( "Sheet Pin" ) ) + .Map( SCH_SHEET_T, _( "Sheet" ) ) + + .Map( SCH_FIELD_LOCATE_REFERENCE_T, _( "Field Locate Reference" ) ) + .Map( SCH_FIELD_LOCATE_VALUE_T, _( "Field Locate Value" ) ) + .Map( SCH_FIELD_LOCATE_FOOTPRINT_T, _( "Field Locate Footprint" ) ) + + .Map( SCH_SCREEN_T, _( "SCH Screen" ) ) + + .Map( LIB_PART_T, _( "Symbol" ) ) + .Map( LIB_ALIAS_T, _( "Alias" ) ) + .Map( LIB_ARC_T, _( "Arc" ) ) + .Map( LIB_CIRCLE_T, _( "Circle" ) ) + .Map( LIB_TEXT_T, _( "Symbol Text" ) ) + .Map( LIB_RECTANGLE_T, _( "Rectangle" ) ) + .Map( LIB_POLYLINE_T, _( "Polyline" ) ) + .Map( LIB_BEZIER_T, _( "Bezier" ) ) + .Map( LIB_PIN_T, _( "Pin" ) ) + .Map( LIB_FIELD_T, _( "Symbol Field" ) ) + + .Map( GERBER_LAYOUT_T, _( "Gerber Layout" ) ) + .Map( GERBER_DRAW_ITEM_T, _( "Draw Item" ) ) + .Map( GERBER_IMAGE_T, _( "Image" ) ); + + PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); + REGISTER_TYPE( EDA_ITEM ); + propMgr.AddProperty( new PROPERTY_ENUM( "Type", + NO_SETTER( EDA_ITEM, KICAD_T ), &EDA_ITEM::Type ) ); + } +} _EDA_ITEM_DESC; + +ENUM_TO_WXANY( KICAD_T ); \ No newline at end of file diff --git a/common/eda_rect.cpp b/common/eda_rect.cpp new file mode 100644 index 0000000000..e962072a95 --- /dev/null +++ b/common/eda_rect.cpp @@ -0,0 +1,544 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/** + * @brief Implementation of EDA_RECT base class for KiCad. + */ + +#include +#include + +#include +#include + +void EDA_RECT::Normalize() +{ + if( m_Size.y < 0 ) + { + m_Size.y = -m_Size.y; + m_Pos.y -= m_Size.y; + } + + if( m_Size.x < 0 ) + { + m_Size.x = -m_Size.x; + m_Pos.x -= m_Size.x; + } +} + + +void EDA_RECT::Move( const wxPoint& aMoveVector ) +{ + m_Pos += aMoveVector; +} + + +bool EDA_RECT::Contains( const wxPoint& aPoint ) const +{ + wxPoint rel_pos = aPoint - m_Pos; + wxSize size = m_Size; + + if( size.x < 0 ) + { + size.x = -size.x; + rel_pos.x += size.x; + } + + if( size.y < 0 ) + { + size.y = -size.y; + rel_pos.y += size.y; + } + + return ( rel_pos.x >= 0 ) && ( rel_pos.y >= 0 ) && ( rel_pos.y <= size.y ) + && ( rel_pos.x <= size.x ); +} + + +bool EDA_RECT::Contains( const EDA_RECT& aRect ) const +{ + return Contains( aRect.GetOrigin() ) && Contains( aRect.GetEnd() ); +} + + +bool EDA_RECT::Intersects( const wxPoint& aPoint1, const wxPoint& aPoint2 ) const +{ + wxPoint point2, point4; + + if( Contains( aPoint1 ) || Contains( aPoint2 ) ) + return true; + + point2.x = GetEnd().x; + point2.y = GetOrigin().y; + point4.x = GetOrigin().x; + point4.y = GetEnd().y; + + //Only need to test 3 sides since a straight line cant enter and exit on same side + if( SegmentIntersectsSegment( aPoint1, aPoint2, GetOrigin(), point2 ) ) + return true; + + if( SegmentIntersectsSegment( aPoint1, aPoint2, point2, GetEnd() ) ) + return true; + + if( SegmentIntersectsSegment( aPoint1, aPoint2, GetEnd(), point4 ) ) + return true; + + return false; +} + + +bool EDA_RECT::Intersects( const wxPoint& aPoint1, const wxPoint& aPoint2, wxPoint* aIntersection1, + wxPoint* aIntersection2 ) const +{ + wxPoint point2, point4; + + point2.x = GetEnd().x; + point2.y = GetOrigin().y; + point4.x = GetOrigin().x; + point4.y = GetEnd().y; + + bool intersects = false; + + wxPoint* aPointToFill = aIntersection1; + + if( SegmentIntersectsSegment( aPoint1, aPoint2, GetOrigin(), point2, aPointToFill ) ) + intersects = true; + + if( intersects ) + aPointToFill = aIntersection2; + + if( SegmentIntersectsSegment( aPoint1, aPoint2, point2, GetEnd(), aPointToFill ) ) + intersects = true; + + if( intersects ) + aPointToFill = aIntersection2; + + if( SegmentIntersectsSegment( aPoint1, aPoint2, GetEnd(), point4, aPointToFill ) ) + intersects = true; + + if( intersects ) + aPointToFill = aIntersection2; + + if( SegmentIntersectsSegment( aPoint1, aPoint2, point4, GetOrigin(), aPointToFill ) ) + intersects = true; + + return intersects; +} + + +bool EDA_RECT::Intersects( const EDA_RECT& aRect ) const +{ + if( !m_init ) + return false; + + // this logic taken from wxWidgets' geometry.cpp file: + bool rc; + EDA_RECT me( *this ); + EDA_RECT rect( aRect ); + me.Normalize(); // ensure size is >= 0 + rect.Normalize(); // ensure size is >= 0 + + // calculate the left common area coordinate: + int left = std::max( me.m_Pos.x, rect.m_Pos.x ); + // calculate the right common area coordinate: + int right = std::min( me.m_Pos.x + me.m_Size.x, rect.m_Pos.x + rect.m_Size.x ); + // calculate the upper common area coordinate: + int top = std::max( me.m_Pos.y, aRect.m_Pos.y ); + // calculate the lower common area coordinate: + int bottom = std::min( me.m_Pos.y + me.m_Size.y, rect.m_Pos.y + rect.m_Size.y ); + + // if a common area exists, it must have a positive (null accepted) size + if( left <= right && top <= bottom ) + rc = true; + else + rc = false; + + return rc; +} + + +bool EDA_RECT::Intersects( const EDA_RECT& aRect, double aRot ) const +{ + if( !m_init ) + return false; + + /* Most rectangles will be axis aligned. + * It is quicker to check for this case and pass the rect + * to the simpler intersection test + */ + + // Prevent floating point comparison errors + static const double ROT_EPS = 0.000000001; + + static const double ROT_PARALLEL[] = { -3600, -1800, 0, 1800, 3600 }; + static const double ROT_PERPENDICULAR[] = { -2700, -900, 0, 900, 2700 }; + + NORMALIZE_ANGLE_POS( aRot ); + + // Test for non-rotated rectangle + for( int ii = 0; ii < 5; ii++ ) + { + if( std::fabs( aRot - ROT_PARALLEL[ii] ) < ROT_EPS ) + { + return Intersects( aRect ); + } + } + + // Test for rectangle rotated by multiple of 90 degrees + for( int jj = 0; jj < 4; jj++ ) + { + if( std::fabs( aRot - ROT_PERPENDICULAR[jj] ) < ROT_EPS ) + { + EDA_RECT rotRect; + + // Rotate the supplied rect by 90 degrees + rotRect.SetOrigin( aRect.Centre() ); + rotRect.Inflate( aRect.GetHeight(), aRect.GetWidth() ); + return Intersects( rotRect ); + } + } + + /* There is some non-orthogonal rotation. + * There are three cases to test: + * A) One point of this rect is inside the rotated rect + * B) One point of the rotated rect is inside this rect + * C) One of the sides of the rotated rect intersect this + */ + + wxPoint corners[4]; + + /* Test A : Any corners exist in rotated rect? */ + + corners[0] = m_Pos; + corners[1] = m_Pos + wxPoint( m_Size.x, 0 ); + corners[2] = m_Pos + wxPoint( m_Size.x, m_Size.y ); + corners[3] = m_Pos + wxPoint( 0, m_Size.y ); + + wxPoint rCentre = aRect.Centre(); + + for( int i = 0; i < 4; i++ ) + { + wxPoint delta = corners[i] - rCentre; + RotatePoint( &delta, -aRot ); + delta += rCentre; + + if( aRect.Contains( delta ) ) + { + return true; + } + } + + /* Test B : Any corners of rotated rect exist in this one? */ + int w = aRect.GetWidth() / 2; + int h = aRect.GetHeight() / 2; + + // Construct corners around center of shape + corners[0] = wxPoint( -w, -h ); + corners[1] = wxPoint( w, -h ); + corners[2] = wxPoint( w, h ); + corners[3] = wxPoint( -w, h ); + + // Rotate and test each corner + for( int j = 0; j < 4; j++ ) + { + RotatePoint( &corners[j], aRot ); + corners[j] += rCentre; + + if( Contains( corners[j] ) ) + { + return true; + } + } + + /* Test C : Any sides of rotated rect intersect this */ + + if( Intersects( corners[0], corners[1] ) || Intersects( corners[1], corners[2] ) + || Intersects( corners[2], corners[3] ) || Intersects( corners[3], corners[0] ) ) + { + return true; + } + + + return false; +} + + +const wxPoint EDA_RECT::ClosestPointTo( const wxPoint& aPoint ) const +{ + EDA_RECT me( *this ); + + me.Normalize(); // ensure size is >= 0 + + // Determine closest point to the circle centre within this rect + int nx = std::max( me.GetLeft(), std::min( aPoint.x, me.GetRight() ) ); + int ny = std::max( me.GetTop(), std::min( aPoint.y, me.GetBottom() ) ); + + return wxPoint( nx, ny ); +} + + +const wxPoint EDA_RECT::FarthestPointTo( const wxPoint& aPoint ) const +{ + EDA_RECT me( *this ); + + me.Normalize(); // ensure size is >= 0 + + int fx = std::max( std::abs( aPoint.x - me.GetLeft() ), std::abs( aPoint.x - me.GetRight() ) ); + int fy = std::max( std::abs( aPoint.y - me.GetTop() ), std::abs( aPoint.y - me.GetBottom() ) ); + + return wxPoint( fx, fy ); +} + + +bool EDA_RECT::IntersectsCircle( const wxPoint& aCenter, const int aRadius ) const +{ + if( !m_init ) + return false; + + wxPoint closest = ClosestPointTo( aCenter ); + + double dx = static_cast( aCenter.x ) - closest.x; + double dy = static_cast( aCenter.y ) - closest.y; + + double r = static_cast( aRadius ); + + return ( dx * dx + dy * dy ) <= ( r * r ); +} + + +bool EDA_RECT::IntersectsCircleEdge( + const wxPoint& aCenter, const int aRadius, const int aWidth ) const +{ + if( !m_init ) + return false; + + EDA_RECT me( *this ); + me.Normalize(); // ensure size is >= 0 + + // Test if the circle intersects at all + if( !IntersectsCircle( aCenter, aRadius + aWidth / 2 ) ) + { + return false; + } + + wxPoint farpt = FarthestPointTo( aCenter ); + // Farthest point must be further than the inside of the line + double fx = (double) farpt.x; + double fy = (double) farpt.y; + + double r = (double) aRadius - (double) aWidth / 2; + + return ( fx * fx + fy * fy ) > ( r * r ); +} + + +EDA_RECT& EDA_RECT::Inflate( int aDelta ) +{ + Inflate( aDelta, aDelta ); + return *this; +} + + +EDA_RECT& EDA_RECT::Inflate( wxCoord dx, wxCoord dy ) +{ + if( m_Size.x >= 0 ) + { + if( m_Size.x < -2 * dx ) + { + // Don't allow deflate to eat more width than we have, + m_Pos.x += m_Size.x / 2; + m_Size.x = 0; + } + else + { + // The inflate is valid. + m_Pos.x -= dx; + m_Size.x += 2 * dx; + } + } + else // size.x < 0: + { + if( m_Size.x > -2 * dx ) + { + // Don't allow deflate to eat more width than we have, + m_Pos.x -= m_Size.x / 2; + m_Size.x = 0; + } + else + { + // The inflate is valid. + m_Pos.x += dx; + m_Size.x -= 2 * dx; // m_Size.x <0: inflate when dx > 0 + } + } + + if( m_Size.y >= 0 ) + { + if( m_Size.y < -2 * dy ) + { + // Don't allow deflate to eat more height than we have, + m_Pos.y += m_Size.y / 2; + m_Size.y = 0; + } + else + { + // The inflate is valid. + m_Pos.y -= dy; + m_Size.y += 2 * dy; + } + } + else // size.y < 0: + { + if( m_Size.y > 2 * dy ) + { + // Don't allow deflate to eat more height than we have, + m_Pos.y -= m_Size.y / 2; + m_Size.y = 0; + } + else + { + // The inflate is valid. + m_Pos.y += dy; + m_Size.y -= 2 * dy; // m_Size.y <0: inflate when dy > 0 + } + } + + return *this; +} + + +void EDA_RECT::Merge( const EDA_RECT& aRect ) +{ + if( !m_init ) + { + if( aRect.IsValid() ) + { + m_Pos = aRect.GetPosition(); + m_Size = aRect.GetSize(); + m_init = true; + } + return; + } + + Normalize(); // ensure width and height >= 0 + EDA_RECT rect = aRect; + rect.Normalize(); // ensure width and height >= 0 + wxPoint end = GetEnd(); + wxPoint rect_end = rect.GetEnd(); + + // Change origin and size in order to contain the given rect + m_Pos.x = std::min( m_Pos.x, rect.m_Pos.x ); + m_Pos.y = std::min( m_Pos.y, rect.m_Pos.y ); + end.x = std::max( end.x, rect_end.x ); + end.y = std::max( end.y, rect_end.y ); + SetEnd( end ); +} + + +void EDA_RECT::Merge( const wxPoint& aPoint ) +{ + if( !m_init ) + { + m_Pos = aPoint; + m_Size = wxSize( 0, 0 ); + m_init = true; + return; + } + + Normalize(); // ensure width and height >= 0 + + wxPoint end = GetEnd(); + // Change origin and size in order to contain the given rect + m_Pos.x = std::min( m_Pos.x, aPoint.x ); + m_Pos.y = std::min( m_Pos.y, aPoint.y ); + end.x = std::max( end.x, aPoint.x ); + end.y = std::max( end.y, aPoint.y ); + SetEnd( end ); +} + + +double EDA_RECT::GetArea() const +{ + return (double) GetWidth() * (double) GetHeight(); +} + + +EDA_RECT EDA_RECT::Common( const EDA_RECT& aRect ) const +{ + EDA_RECT r; + + if( Intersects( aRect ) ) + { + wxPoint originA( + std::min( GetOrigin().x, GetEnd().x ), std::min( GetOrigin().y, GetEnd().y ) ); + wxPoint originB( std::min( aRect.GetOrigin().x, aRect.GetEnd().x ), + std::min( aRect.GetOrigin().y, aRect.GetEnd().y ) ); + wxPoint endA( + std::max( GetOrigin().x, GetEnd().x ), std::max( GetOrigin().y, GetEnd().y ) ); + wxPoint endB( std::max( aRect.GetOrigin().x, aRect.GetEnd().x ), + std::max( aRect.GetOrigin().y, aRect.GetEnd().y ) ); + + r.SetOrigin( + wxPoint( std::max( originA.x, originB.x ), std::max( originA.y, originB.y ) ) ); + r.SetEnd( wxPoint( std::min( endA.x, endB.x ), std::min( endA.y, endB.y ) ) ); + } + + return r; +} + + +const EDA_RECT EDA_RECT::GetBoundingBoxRotated( wxPoint aRotCenter, double aAngle ) const +{ + wxPoint corners[4]; + + // Build the corners list + corners[0] = GetOrigin(); + corners[2] = GetEnd(); + corners[1].x = corners[0].x; + corners[1].y = corners[2].y; + corners[3].x = corners[2].x; + corners[3].y = corners[0].y; + + // Rotate all corners, to find the bounding box + for( int ii = 0; ii < 4; ii++ ) + RotatePoint( &corners[ii], aRotCenter, aAngle ); + + // Find the corners bounding box + wxPoint start = corners[0]; + wxPoint end = corners[0]; + + for( int ii = 1; ii < 4; ii++ ) + { + start.x = std::min( start.x, corners[ii].x ); + start.y = std::min( start.y, corners[ii].y ); + end.x = std::max( end.x, corners[ii].x ); + end.y = std::max( end.y, corners[ii].y ); + } + + EDA_RECT bbox; + bbox.SetOrigin( start ); + bbox.SetEnd( end ); + + return bbox; +} \ No newline at end of file diff --git a/common/eda_text.cpp b/common/eda_text.cpp index 532dc838a1..1cb9082b65 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -32,7 +32,7 @@ #include // for swap #include // for vector -#include // for EDA_ITEM +#include // for EDA_ITEM #include #include // for BASIC_GAL, basic_gal #include // for wxStringSplit diff --git a/common/gr_basic.cpp b/common/gr_basic.cpp index 5a06d8be75..996d402c99 100644 --- a/common/gr_basic.cpp +++ b/common/gr_basic.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include #include diff --git a/common/page_layout/page_layout_reader.cpp b/common/page_layout/page_layout_reader.cpp index 626ca14c96..c5aca1c911 100644 --- a/common/page_layout/page_layout_reader.cpp +++ b/common/page_layout/page_layout_reader.cpp @@ -29,7 +29,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include #include #include #include diff --git a/common/page_layout/ws_data_model_io.cpp b/common/page_layout/ws_data_model_io.cpp index 5d4d5e58f2..0d1eb6038f 100644 --- a/common/page_layout/ws_data_model_io.cpp +++ b/common/page_layout/ws_data_model_io.cpp @@ -30,7 +30,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include #include #include #include diff --git a/common/plotters/DXF_plotter.cpp b/common/plotters/DXF_plotter.cpp index 5f4f2a61b9..7d428eadd9 100644 --- a/common/plotters/DXF_plotter.cpp +++ b/common/plotters/DXF_plotter.cpp @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include diff --git a/common/plotters/GERBER_plotter.cpp b/common/plotters/GERBER_plotter.cpp index 53884d8c14..df00216b97 100644 --- a/common/plotters/GERBER_plotter.cpp +++ b/common/plotters/GERBER_plotter.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include // for KiROUND diff --git a/common/plotters/HPGL_plotter.cpp b/common/plotters/HPGL_plotter.cpp index 07f2ffecab..3be058a26d 100644 --- a/common/plotters/HPGL_plotter.cpp +++ b/common/plotters/HPGL_plotter.cpp @@ -196,7 +196,7 @@ #include #include -#include +#include #include #include #include // for KiROUND diff --git a/common/plotters/PDF_plotter.cpp b/common/plotters/PDF_plotter.cpp index 6bb8cd8f0f..c0451f8069 100644 --- a/common/plotters/PDF_plotter.cpp +++ b/common/plotters/PDF_plotter.cpp @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include #include // for KiROUND diff --git a/common/plotters/PS_plotter.cpp b/common/plotters/PS_plotter.cpp index bc9fcd450e..3d8f3c7bb3 100644 --- a/common/plotters/PS_plotter.cpp +++ b/common/plotters/PS_plotter.cpp @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include // for KiROUND diff --git a/common/plotters/SVG_plotter.cpp b/common/plotters/SVG_plotter.cpp index b42dccbf24..3f81c32572 100644 --- a/common/plotters/SVG_plotter.cpp +++ b/common/plotters/SVG_plotter.cpp @@ -95,7 +95,7 @@ #include #include #include -#include +#include #include #include diff --git a/common/plotters/common_plot_functions.cpp b/common/plotters/common_plot_functions.cpp index 167e53270f..8f28299584 100644 --- a/common/plotters/common_plot_functions.cpp +++ b/common/plotters/common_plot_functions.cpp @@ -22,7 +22,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include #include #include #include diff --git a/common/plotters/plotter.cpp b/common/plotters/plotter.cpp index 4bd5fd69de..0424eefd5c 100644 --- a/common/plotters/plotter.cpp +++ b/common/plotters/plotter.cpp @@ -39,7 +39,7 @@ #include #include -#include +#include #include #include #include diff --git a/common/plotters/plotter_dxf.h b/common/plotters/plotter_dxf.h index f983a3749c..4454e35e06 100644 --- a/common/plotters/plotter_dxf.h +++ b/common/plotters/plotter_dxf.h @@ -27,7 +27,7 @@ #include #include -#include // FILL_T +#include // FILL_T #include diff --git a/common/plotters/plotter_gerber.h b/common/plotters/plotter_gerber.h index 240e542667..a2083979da 100644 --- a/common/plotters/plotter_gerber.h +++ b/common/plotters/plotter_gerber.h @@ -28,7 +28,7 @@ #include #include -#include // FILL_T +#include // FILL_T #include #include "gbr_plotter_apertures.h" diff --git a/common/plotters/plotter_hpgl.h b/common/plotters/plotter_hpgl.h index 3807792c3a..980238ba0c 100644 --- a/common/plotters/plotter_hpgl.h +++ b/common/plotters/plotter_hpgl.h @@ -27,7 +27,7 @@ #include #include -#include // FILL_T +#include // FILL_T #include diff --git a/common/plotters/plotters_pslike.h b/common/plotters/plotters_pslike.h index 46568e8a4a..90e292e2d3 100644 --- a/common/plotters/plotters_pslike.h +++ b/common/plotters/plotters_pslike.h @@ -27,7 +27,7 @@ #include #include -#include // FILL_T +#include // FILL_T #include diff --git a/common/rc_item.h b/common/rc_item.h index c715c45268..3fc5e29cfd 100644 --- a/common/rc_item.h +++ b/common/rc_item.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include class MARKER_BASE; diff --git a/common/swig/kicad.i b/common/swig/kicad.i index 02e3567471..6ac3f00442 100644 --- a/common/swig/kicad.i +++ b/common/swig/kicad.i @@ -82,7 +82,7 @@ principle should be easily implemented by adapting the current STL containers. %{ #include #include - #include + #include #include #include #include @@ -109,7 +109,7 @@ principle should be easily implemented by adapting the current STL containers. // header files that must be wrapped %include macros.h %include core/typeinfo.h -%include base_struct.h +%include eda_item.h %include eda_rect.h %include common.h %include title_block.h diff --git a/common/undo_redo_container.cpp b/common/undo_redo_container.cpp index c053674527..09336ecded 100644 --- a/common/undo_redo_container.cpp +++ b/common/undo_redo_container.cpp @@ -23,7 +23,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include #include diff --git a/common/view/view.cpp b/common/view/view.cpp index 3bcc5fa1c7..adea399366 100644 --- a/common/view/view.cpp +++ b/common/view/view.cpp @@ -24,7 +24,7 @@ */ -#include +#include #include #include diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 1b522f7974..dfc3b98570 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -23,7 +23,7 @@ */ #include -#include +#include #include #include #include diff --git a/eeschema/lib_item.h b/eeschema/lib_item.h index 32c6f561c1..2cf716a378 100644 --- a/eeschema/lib_item.h +++ b/eeschema/lib_item.h @@ -26,7 +26,7 @@ #ifndef _LIB_ITEM_H_ #define _LIB_ITEM_H_ -#include +#include #include #include #include diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index 3c44ecc271..6b4f695147 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -27,7 +27,7 @@ #ifndef COMPONENT_CLASS_H #define COMPONENT_CLASS_H -#include +#include #include #include #include diff --git a/eeschema/sch_draw_panel.h b/eeschema/sch_draw_panel.h index 92050270a5..f108de1646 100644 --- a/eeschema/sch_draw_panel.h +++ b/eeschema/sch_draw_panel.h @@ -25,7 +25,7 @@ #define __SCH_DRAW_PANEL_H #include -#include +#include #include #include #include diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 999ca6d1ab..5a6f35d79d 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -30,7 +30,7 @@ * They can be renamed and can appear in reports */ -#include +#include #include #include #include diff --git a/eeschema/sch_item.cpp b/eeschema/sch_item.cpp index 5c182a4e20..f6bb8d8750 100644 --- a/eeschema/sch_item.cpp +++ b/eeschema/sch_item.cpp @@ -22,7 +22,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include #include #include #include diff --git a/eeschema/sch_item.h b/eeschema/sch_item.h index d5f9338e59..42d7243772 100644 --- a/eeschema/sch_item.h +++ b/eeschema/sch_item.h @@ -29,7 +29,7 @@ #include #include -#include +#include #include // for PLOT_DASH_TYPE definition #include diff --git a/eeschema/sch_preview_panel.h b/eeschema/sch_preview_panel.h index 78df79617e..d596de0fbe 100644 --- a/eeschema/sch_preview_panel.h +++ b/eeschema/sch_preview_panel.h @@ -26,7 +26,7 @@ #define SCH_PREVIEW_PANEL_H #include -#include +#include #include #include diff --git a/eeschema/sch_screen.h b/eeschema/sch_screen.h index 332413ff21..93d6acc895 100644 --- a/eeschema/sch_screen.h +++ b/eeschema/sch_screen.h @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include #include diff --git a/eeschema/sch_sheet_path.h b/eeschema/sch_sheet_path.h index b4575aed92..9e4932af26 100644 --- a/eeschema/sch_sheet_path.h +++ b/eeschema/sch_sheet_path.h @@ -31,7 +31,7 @@ #ifndef CLASS_DRAWSHEET_PATH_H #define CLASS_DRAWSHEET_PATH_H -#include +#include #include #include diff --git a/eeschema/sch_view.h b/eeschema/sch_view.h index 520f5c3672..3bde301355 100644 --- a/eeschema/sch_view.h +++ b/eeschema/sch_view.h @@ -24,7 +24,7 @@ #ifndef SCH_VIEW_H_ #define SCH_VIEW_H_ -#include +#include #include #include #include diff --git a/eeschema/schematic.h b/eeschema/schematic.h index 80dc581245..f02014150e 100644 --- a/eeschema/schematic.h +++ b/eeschema/schematic.h @@ -20,7 +20,7 @@ #ifndef KICAD_SCHEMATIC_H #define KICAD_SCHEMATIC_H -#include +#include #include #include diff --git a/eeschema/tools/lib_move_tool.cpp b/eeschema/tools/lib_move_tool.cpp index dc44be626c..3bc386181e 100644 --- a/eeschema/tools/lib_move_tool.cpp +++ b/eeschema/tools/lib_move_tool.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include "lib_move_tool.h" #include "lib_pin_tool.h" diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 17a3bb344f..bd1ff6be1f 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/eeschema/tools/sch_line_wire_bus_tool.cpp b/eeschema/tools/sch_line_wire_bus_tool.cpp index 9145770fa4..6cb214640e 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.cpp +++ b/eeschema/tools/sch_line_wire_bus_tool.cpp @@ -36,7 +36,7 @@ #include #include -#include +#include #include #include #include diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index 881323cb35..6177c62561 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/gerbview/am_primitive.h b/gerbview/am_primitive.h index 458319d8f1..b746dde40b 100644 --- a/gerbview/am_primitive.h +++ b/gerbview/am_primitive.h @@ -33,7 +33,7 @@ #include #include -#include +#include #include #include diff --git a/gerbview/dcode.h b/gerbview/dcode.h index 7e5682d020..d788fb0018 100644 --- a/gerbview/dcode.h +++ b/gerbview/dcode.h @@ -32,7 +32,7 @@ #include -#include +#include #include #include diff --git a/gerbview/gerber_draw_item.h b/gerbview/gerber_draw_item.h index 5546a97dc5..aaa320e9d0 100644 --- a/gerbview/gerber_draw_item.h +++ b/gerbview/gerber_draw_item.h @@ -29,7 +29,7 @@ #ifndef GERBER_DRAW_ITEM_H #define GERBER_DRAW_ITEM_H -#include +#include #include #include #include diff --git a/gerbview/tools/gerbview_inspection_tool.cpp b/gerbview/tools/gerbview_inspection_tool.cpp index 84331bd3ba..7d48154f40 100644 --- a/gerbview/tools/gerbview_inspection_tool.cpp +++ b/gerbview/tools/gerbview_inspection_tool.cpp @@ -19,7 +19,7 @@ */ -#include +#include #include #include #include diff --git a/gerbview/tools/gerbview_selection.cpp b/gerbview/tools/gerbview_selection.cpp index 3e6d1893e5..b4180fbbe7 100644 --- a/gerbview/tools/gerbview_selection.cpp +++ b/gerbview/tools/gerbview_selection.cpp @@ -18,7 +18,7 @@ * with this program. If not, see . */ -#include +#include #include #include #include diff --git a/gerbview/tools/gerbview_selection_tool.cpp b/gerbview/tools/gerbview_selection_tool.cpp index cdcd25f1e5..ab8359532d 100644 --- a/gerbview/tools/gerbview_selection_tool.cpp +++ b/gerbview/tools/gerbview_selection_tool.cpp @@ -22,7 +22,7 @@ #include using namespace std::placeholders; -#include +#include #include #include #include diff --git a/include/base_screen.h b/include/base_screen.h index 7cd071388c..67dd10df90 100644 --- a/include/base_screen.h +++ b/include/base_screen.h @@ -32,7 +32,7 @@ #define BASE_SCREEN_H #include -#include +#include #include diff --git a/include/class_board_item.h b/include/class_board_item.h index afbd40f15c..3a95bb4a07 100644 --- a/include/class_board_item.h +++ b/include/class_board_item.h @@ -31,7 +31,7 @@ #define BOARD_ITEM_STRUCT_H -#include +#include #include #include #include diff --git a/include/collector.h b/include/collector.h index d628d719ef..353ce6af41 100644 --- a/include/collector.h +++ b/include/collector.h @@ -32,7 +32,7 @@ #include -#include // SEARCH_RESULT +#include // SEARCH_RESULT #include // GetNewTimeStamp() #include diff --git a/include/base_struct.h b/include/eda_item.h similarity index 99% rename from include/base_struct.h rename to include/eda_item.h index 1b6118e368..916e1939f6 100644 --- a/include/base_struct.h +++ b/include/eda_item.h @@ -24,8 +24,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef BASE_STRUCT_H_ -#define BASE_STRUCT_H_ +#ifndef EDA_ITEM_H +#define EDA_ITEM_H #include @@ -587,5 +587,4 @@ inline EDA_ITEM* new_clone( const EDA_ITEM& aItem ) { return aItem.Clone(); } */ typedef std::vector< EDA_ITEM* > EDA_ITEMS; - -#endif // BASE_STRUCT_H_ +#endif // EDA_ITEM_H \ No newline at end of file diff --git a/include/eda_text.h b/include/eda_text.h index d3a2cb0663..2395e57c84 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -28,7 +28,7 @@ #include // NORMALIZE_ANGLE_POS( angle ); #include // wxStringSplit #include // EDA_DRAW_MODE_T -#include // EDA_RECT +#include // EDA_RECT #include "kicad_string.h" #include "painter.h" diff --git a/include/gr_text.h b/include/gr_text.h index ab0def72f3..9f27ac1cbe 100644 --- a/include/gr_text.h +++ b/include/gr_text.h @@ -31,7 +31,7 @@ #ifndef __INCLUDE__DRAWTXT_H__ #define __INCLUDE__DRAWTXT_H__ 1 -#include +#include #include // EDA_TEXT_HJUSTIFY_T and EDA_TEXT_VJUSTIFY_T /* Minimum dimension in pixel for drawing/no drawing a text diff --git a/include/hashtables.h b/include/hashtables.h index 99108c637c..6fe2549a0f 100644 --- a/include/hashtables.h +++ b/include/hashtables.h @@ -25,7 +25,7 @@ #ifndef HASHTABLES_H_ #define HASHTABLES_H_ -#include +#include #include // Two competing strategies for providing portable hashtables are given: diff --git a/include/lib_tree_item.h b/include/lib_tree_item.h index 3ceebbfcff..66715966e0 100644 --- a/include/lib_tree_item.h +++ b/include/lib_tree_item.h @@ -25,7 +25,7 @@ #ifndef LIB_TREE_ITEM_H #define LIB_TREE_ITEM_H -#include +#include #include #include diff --git a/include/page_layout/ws_proxy_undo_item.h b/include/page_layout/ws_proxy_undo_item.h index d7c36e977f..b1256be347 100644 --- a/include/page_layout/ws_proxy_undo_item.h +++ b/include/page_layout/ws_proxy_undo_item.h @@ -25,7 +25,7 @@ #ifndef WS_PROXY_UNDO_ITEM_H #define WS_PROXY_UNDO_ITEM_H -#include +#include #include #include diff --git a/include/page_layout/ws_proxy_view_item.h b/include/page_layout/ws_proxy_view_item.h index d7e1acce50..b6e65a6eff 100644 --- a/include/page_layout/ws_proxy_view_item.h +++ b/include/page_layout/ws_proxy_view_item.h @@ -25,7 +25,7 @@ #ifndef WS_PROXY_VIEW_ITEM_H #define WS_PROXY_VIEW_ITEM_H -#include +#include class BOARD; class PAGE_INFO; diff --git a/include/pcb_base_frame.h b/include/pcb_base_frame.h index 69ec7fcb69..99cf3a8755 100644 --- a/include/pcb_base_frame.h +++ b/include/pcb_base_frame.h @@ -32,7 +32,7 @@ #define PCB_BASE_FRAME_H -#include +#include #include #include #include // EDA_DRAW_MODE_T diff --git a/include/plotter.h b/include/plotter.h index b3f54115a1..282eec7b48 100644 --- a/include/plotter.h +++ b/include/plotter.h @@ -36,7 +36,7 @@ #include #include #include -#include // FILL_T +#include // FILL_T class COLOR_SETTINGS; class SHAPE_POLY_SET; diff --git a/include/preview_items/arc_assistant.h b/include/preview_items/arc_assistant.h index a9a54b6279..aa2bf4544b 100644 --- a/include/preview_items/arc_assistant.h +++ b/include/preview_items/arc_assistant.h @@ -24,7 +24,7 @@ #ifndef PREVIEW_ITEMS_ARC_ASSISTANT_H #define PREVIEW_ITEMS_ARC_ASSISTANT_H -#include +#include #include #include diff --git a/include/preview_items/bright_box.h b/include/preview_items/bright_box.h index 701fc8f889..1a523e91e1 100644 --- a/include/preview_items/bright_box.h +++ b/include/preview_items/bright_box.h @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include diff --git a/include/preview_items/ruler_item.h b/include/preview_items/ruler_item.h index 5e7f440fad..08c4c2ff8a 100644 --- a/include/preview_items/ruler_item.h +++ b/include/preview_items/ruler_item.h @@ -24,7 +24,7 @@ #ifndef PREVIEW_ITEMS_RULER_ITEM_H #define PREVIEW_ITEMS_RULER_ITEM_H -#include +#include #include namespace KIGFX diff --git a/include/preview_items/simple_overlay_item.h b/include/preview_items/simple_overlay_item.h index 54dc5c8d19..e95863c656 100644 --- a/include/preview_items/simple_overlay_item.h +++ b/include/preview_items/simple_overlay_item.h @@ -24,7 +24,7 @@ #ifndef PREVIEW_SIMPLE_OUTLINE_ITEM__H_ #define PREVIEW_SIMPLE_OUTLINE_ITEM__H_ -#include +#include #include #include diff --git a/include/preview_items/two_point_assistant.h b/include/preview_items/two_point_assistant.h index ebae53238e..72c69c4f03 100644 --- a/include/preview_items/two_point_assistant.h +++ b/include/preview_items/two_point_assistant.h @@ -24,7 +24,7 @@ #ifndef PREVIEW_ITEMS_TWO_POINT_ASSISTANT_H #define PREVIEW_ITEMS_TWO_POINT_ASSISTANT_H -#include +#include #include #include diff --git a/include/tool/edit_points.h b/include/tool/edit_points.h index 17da1b3d99..da4460b94e 100644 --- a/include/tool/edit_points.h +++ b/include/tool/edit_points.h @@ -25,7 +25,7 @@ #ifndef EDIT_POINTS_H_ #define EDIT_POINTS_H_ -#include +#include #include #include diff --git a/include/tool/selection.h b/include/tool/selection.h index 311e16ce62..126822886f 100644 --- a/include/tool/selection.h +++ b/include/tool/selection.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include diff --git a/include/tool/tool_base.h b/include/tool/tool_base.h index ef1a2e38df..4b8185baa3 100644 --- a/include/tool/tool_base.h +++ b/include/tool/tool_base.h @@ -27,7 +27,7 @@ #define __TOOL_BASE_H #include -#include // for KICAD_T +#include // for KICAD_T #include diff --git a/include/undo_redo_container.h b/include/undo_redo_container.h index 5cb038a77d..2807f10280 100644 --- a/include/undo_redo_container.h +++ b/include/undo_redo_container.h @@ -27,7 +27,7 @@ #define _CLASS_UNDOREDO_CONTAINER_H #include -#include +#include class PICKED_ITEMS_LIST; diff --git a/include/widgets/unit_binder.h b/include/widgets/unit_binder.h index f8ede349c3..412b4cf562 100644 --- a/include/widgets/unit_binder.h +++ b/include/widgets/unit_binder.h @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include diff --git a/pagelayout_editor/tools/pl_edit_tool.cpp b/pagelayout_editor/tools/pl_edit_tool.cpp index f13b5549ca..ae44db0886 100644 --- a/pagelayout_editor/tools/pl_edit_tool.cpp +++ b/pagelayout_editor/tools/pl_edit_tool.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include // for KiROUND diff --git a/pcb_calculator/datafile_read_write.h b/pcb_calculator/datafile_read_write.h index 219aa44cda..5c86e1ebd4 100644 --- a/pcb_calculator/datafile_read_write.h +++ b/pcb_calculator/datafile_read_write.h @@ -21,7 +21,7 @@ #include #include -#include +#include class PCB_CALCULATOR_DATAFILE_PARSER; diff --git a/pcbnew/exporters/gen_drill_report_files.cpp b/pcbnew/exporters/gen_drill_report_files.cpp index 5ae00e0aa0..eede821d6d 100644 --- a/pcbnew/exporters/gen_drill_report_files.cpp +++ b/pcbnew/exporters/gen_drill_report_files.cpp @@ -28,7 +28,7 @@ */ #include -#include +#include #include #include #include diff --git a/pcbnew/pcb_text.cpp b/pcbnew/pcb_text.cpp index f4abe45ee7..7d8689f030 100644 --- a/pcbnew/pcb_text.cpp +++ b/pcbnew/pcb_text.cpp @@ -23,7 +23,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include #include #include #include diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index 8ba7f788ad..d62065917b 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -29,7 +29,7 @@ */ -#include +#include #include #include #include diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index b372eaf182..e87c130ac3 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -27,7 +27,7 @@ #include // for NULL, size_t #include // for vector, __vector_base<>... -#include +#include #include #include #include // for SEG diff --git a/pcbnew/ratsnest/ratsnest_viewitem.h b/pcbnew/ratsnest/ratsnest_viewitem.h index ac920ff52c..2fb2259895 100644 --- a/pcbnew/ratsnest/ratsnest_viewitem.h +++ b/pcbnew/ratsnest/ratsnest_viewitem.h @@ -31,7 +31,7 @@ #define RATSNEST_VIEWITEM_H #include -#include +#include #include class GAL;