2011-10-11 13:38:13 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-02-20 08:17:54 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
2017-11-16 11:45:53 +00:00
|
|
|
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-11 13:38:13 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file sch_no_connect.cpp
|
|
|
|
* @brief Class SCH_NO_CONNECT implementation.
|
|
|
|
*/
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <macros.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <common.h>
|
2017-11-16 11:45:53 +00:00
|
|
|
#include <class_plotter.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
|
|
|
#include <sch_no_connect.h>
|
|
|
|
#include <class_netlist_object.h>
|
2011-02-28 18:36:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) :
|
|
|
|
SCH_ITEM( NULL, SCH_NO_CONNECT_T )
|
|
|
|
{
|
|
|
|
#define DRAWNOCONNECT_SIZE 48 /* No symbol connection range. */
|
2011-12-07 20:19:29 +00:00
|
|
|
m_pos = pos;
|
|
|
|
m_size.x = m_size.y = DRAWNOCONNECT_SIZE;
|
2011-02-28 18:36:19 +00:00
|
|
|
#undef DRAWNOCONNECT_SIZE
|
2011-06-17 13:24:22 +00:00
|
|
|
|
|
|
|
SetLayer( LAYER_NOCONNECT );
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-17 14:39:27 +00:00
|
|
|
EDA_ITEM* SCH_NO_CONNECT::Clone() const
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
|
|
|
return new SCH_NO_CONNECT( *this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-19 20:32:21 +00:00
|
|
|
void SCH_NO_CONNECT::SwapData( SCH_ITEM* aItem )
|
|
|
|
{
|
|
|
|
wxCHECK_RET( (aItem != NULL) && (aItem->Type() == SCH_NO_CONNECT_T),
|
|
|
|
wxT( "Cannot swap no connect data with invalid item." ) );
|
|
|
|
|
|
|
|
SCH_NO_CONNECT* item = (SCH_NO_CONNECT*)aItem;
|
2015-06-26 13:41:56 +00:00
|
|
|
std::swap( m_pos, item->m_pos );
|
|
|
|
std::swap( m_size, item->m_size );
|
2011-10-19 20:32:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-24 17:48:14 +00:00
|
|
|
const EDA_RECT SCH_NO_CONNECT::GetBoundingBox() const
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2011-12-07 20:19:29 +00:00
|
|
|
int delta = ( GetPenSize() + m_size.x ) / 2;
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT box;
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2011-12-07 20:19:29 +00:00
|
|
|
box.SetOrigin( m_pos );
|
2011-02-28 18:36:19 +00:00
|
|
|
box.Inflate( delta );
|
|
|
|
|
|
|
|
return box;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-08 00:07:42 +00:00
|
|
|
void SCH_NO_CONNECT::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
|
|
|
|
{
|
|
|
|
DANGLING_END_ITEM item( NO_CONNECT_END, this, m_pos );
|
|
|
|
aItemList.push_back( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
int SCH_NO_CONNECT::GetPenSize() const
|
|
|
|
{
|
2012-09-28 17:47:41 +00:00
|
|
|
return GetDefaultLineThickness();
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_NO_CONNECT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
|
2017-02-20 16:57:41 +00:00
|
|
|
GR_DRAWMODE aDrawMode, COLOR4D aColor )
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2012-09-02 12:06:47 +00:00
|
|
|
int pX, pY;
|
2011-12-07 20:19:29 +00:00
|
|
|
int delta = m_size.x / 2;
|
2012-09-28 17:47:41 +00:00
|
|
|
int width = GetDefaultLineThickness();
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2011-12-07 20:19:29 +00:00
|
|
|
pX = m_pos.x + aOffset.x;
|
|
|
|
pY = m_pos.y + aOffset.y;
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D color;
|
|
|
|
|
2017-02-20 17:48:27 +00:00
|
|
|
if( aColor != COLOR4D::UNSPECIFIED )
|
2011-02-28 18:36:19 +00:00
|
|
|
color = aColor;
|
|
|
|
else
|
2013-04-04 21:35:01 +00:00
|
|
|
color = GetLayerColor( LAYER_NOCONNECT );
|
2011-02-28 18:36:19 +00:00
|
|
|
|
|
|
|
GRSetDrawMode( aDC, aDrawMode );
|
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
GRLine( aPanel->GetClipBox(), aDC, pX - delta, pY - delta, pX + delta, pY + delta,
|
|
|
|
width, color );
|
|
|
|
GRLine( aPanel->GetClipBox(), aDC, pX + delta, pY - delta, pX - delta, pY + delta,
|
|
|
|
width, color );
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_NO_CONNECT::MirrorX( int aXaxis_position )
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2015-06-26 13:41:56 +00:00
|
|
|
MIRROR( m_pos.y, aXaxis_position );
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_NO_CONNECT::MirrorY( int aYaxis_position )
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2015-06-26 13:41:56 +00:00
|
|
|
MIRROR( m_pos.x, aYaxis_position );
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_NO_CONNECT::Rotate( wxPoint aPosition )
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2012-03-15 14:31:16 +00:00
|
|
|
RotatePoint( &m_pos, aPosition, 900 );
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_NO_CONNECT::IsSelectStateChanged( const wxRect& aRect )
|
|
|
|
{
|
|
|
|
bool previousState = IsSelected();
|
|
|
|
|
2011-12-07 20:19:29 +00:00
|
|
|
if( aRect.Contains( m_pos ) )
|
2013-03-30 19:55:26 +00:00
|
|
|
SetFlags( SELECTED );
|
2011-02-28 18:36:19 +00:00
|
|
|
else
|
2013-03-30 19:55:26 +00:00
|
|
|
ClearFlags( SELECTED );
|
2011-02-28 18:36:19 +00:00
|
|
|
|
|
|
|
return previousState != IsSelected();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-13 16:27:30 +00:00
|
|
|
void SCH_NO_CONNECT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2011-12-07 20:19:29 +00:00
|
|
|
aPoints.push_back( m_pos );
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
2011-10-11 13:38:13 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
void SCH_NO_CONNECT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
|
|
|
|
SCH_SHEET_PATH* aSheetPath )
|
2011-10-11 13:38:13 +00:00
|
|
|
{
|
|
|
|
NETLIST_OBJECT* item = new NETLIST_OBJECT();
|
|
|
|
|
2013-09-29 18:24:38 +00:00
|
|
|
item->m_SheetPath = *aSheetPath;
|
|
|
|
item->m_SheetPathInclude = *aSheetPath;
|
2011-10-11 13:38:13 +00:00
|
|
|
item->m_Comp = this;
|
|
|
|
item->m_Type = NET_NOCONNECT;
|
2011-12-07 20:19:29 +00:00
|
|
|
item->m_Start = item->m_End = m_pos;
|
2011-10-11 13:38:13 +00:00
|
|
|
|
|
|
|
aNetListItems.push_back( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
bool SCH_NO_CONNECT::doIsConnected( const wxPoint& aPosition ) const
|
|
|
|
{
|
2011-12-07 20:19:29 +00:00
|
|
|
return m_pos == aPosition;
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
bool SCH_NO_CONNECT::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2012-09-28 17:47:41 +00:00
|
|
|
int delta = ( ( m_size.x + GetDefaultLineThickness() ) / 2 ) + aAccuracy;
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
wxPoint dist = aPosition - m_pos;
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2012-09-22 11:19:37 +00:00
|
|
|
if( ( std::abs( dist.x ) <= delta ) && ( std::abs( dist.y ) <= delta ) )
|
2011-02-28 18:36:19 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
bool SCH_NO_CONNECT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT rect = aRect;
|
2011-02-28 18:36:19 +00:00
|
|
|
|
|
|
|
rect.Inflate( aAccuracy );
|
|
|
|
|
|
|
|
if( aContained )
|
|
|
|
return rect.Contains( GetBoundingBox() );
|
|
|
|
|
|
|
|
return rect.Intersects( GetBoundingBox() );
|
|
|
|
}
|
2011-06-17 13:24:22 +00:00
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_NO_CONNECT::Plot( PLOTTER* aPlotter )
|
2011-06-17 13:24:22 +00:00
|
|
|
{
|
2011-12-07 20:19:29 +00:00
|
|
|
int delta = m_size.x / 2;
|
2011-06-17 13:24:22 +00:00
|
|
|
int pX, pY;
|
|
|
|
|
2011-12-07 20:19:29 +00:00
|
|
|
pX = m_pos.x;
|
|
|
|
pY = m_pos.y;
|
2011-06-17 13:24:22 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
aPlotter->SetCurrentLineWidth( GetPenSize() );
|
2013-04-04 21:35:01 +00:00
|
|
|
aPlotter->SetColor( GetLayerColor( GetLayer() ) );
|
2012-05-03 18:37:56 +00:00
|
|
|
aPlotter->MoveTo( wxPoint( pX - delta, pY - delta ) );
|
|
|
|
aPlotter->FinishTo( wxPoint( pX + delta, pY + delta ) );
|
|
|
|
aPlotter->MoveTo( wxPoint( pX + delta, pY - delta ) );
|
|
|
|
aPlotter->FinishTo( wxPoint( pX - delta, pY + delta ) );
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
2012-05-03 18:37:56 +00:00
|
|
|
|
2017-02-20 12:20:39 +00:00
|
|
|
|
|
|
|
BITMAP_DEF SCH_NO_CONNECT::GetMenuImage() const
|
|
|
|
{
|
|
|
|
return noconn_xpm;
|
|
|
|
}
|
|
|
|
|