2011-10-11 13:38:13 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2017-11-16 11:45:53 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2020-03-16 13:04:50 +00:00
|
|
|
* Copyright (C) 1992-2020 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
|
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
2020-05-12 14:02:24 +00:00
|
|
|
#include <sch_painter.h>
|
2018-01-28 18:12:26 +00:00
|
|
|
#include <plotter.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <sch_line.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2020-03-06 03:00:30 +00:00
|
|
|
#include <settings/color_settings.h>
|
2020-05-20 03:39:15 +00:00
|
|
|
#include <schematic.h>
|
2020-07-07 10:17:30 +00:00
|
|
|
#include <project/project_file.h>
|
|
|
|
#include <project/net_settings.h>
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2017-12-06 02:42:37 +00:00
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
SCH_LINE::SCH_LINE( const wxPoint& pos, int layer ) :
|
|
|
|
SCH_ITEM( NULL, SCH_LINE_T )
|
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
m_start = pos;
|
|
|
|
m_end = pos;
|
2011-12-07 20:19:29 +00:00
|
|
|
m_startIsDangling = m_endIsDangling = false;
|
2020-06-17 19:59:27 +00:00
|
|
|
m_stroke.SetWidth( 0 );
|
|
|
|
m_stroke.SetType( PLOT_DASH_TYPE::DEFAULT );
|
|
|
|
m_stroke.SetColor( COLOR4D::UNSPECIFIED );
|
2011-02-28 18:36:19 +00:00
|
|
|
|
|
|
|
switch( layer )
|
|
|
|
{
|
2020-07-08 18:29:16 +00:00
|
|
|
default: m_Layer = LAYER_NOTES; break;
|
|
|
|
case LAYER_WIRE: m_Layer = LAYER_WIRE; break;
|
|
|
|
case LAYER_BUS: m_Layer = LAYER_BUS; break;
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCH_LINE::SCH_LINE( const SCH_LINE& aLine ) :
|
|
|
|
SCH_ITEM( aLine )
|
|
|
|
{
|
2011-12-07 20:19:29 +00:00
|
|
|
m_start = aLine.m_start;
|
|
|
|
m_end = aLine.m_end;
|
2020-06-17 19:59:27 +00:00
|
|
|
m_stroke = aLine.m_stroke;
|
2018-10-29 18:11:04 +00:00
|
|
|
m_startIsDangling = aLine.m_startIsDangling;
|
|
|
|
m_endIsDangling = aLine.m_endIsDangling;
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-17 14:39:27 +00:00
|
|
|
EDA_ITEM* SCH_LINE::Clone() const
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
|
|
|
return new SCH_LINE( *this );
|
|
|
|
}
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Conversion between PLOT_DASH_TYPE values and style names displayed
|
|
|
|
*/
|
|
|
|
const std::map<PLOT_DASH_TYPE, const char*> lineStyleNames{
|
|
|
|
{ PLOT_DASH_TYPE::SOLID, "solid" },
|
|
|
|
{ PLOT_DASH_TYPE::DASH, "dashed" },
|
|
|
|
{ PLOT_DASH_TYPE::DASHDOT, "dash_dot" },
|
|
|
|
{ PLOT_DASH_TYPE::DOT, "dotted" },
|
2017-11-15 13:08:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
const char* SCH_LINE::GetLineStyleName( PLOT_DASH_TYPE aStyle )
|
|
|
|
{
|
|
|
|
auto resultIt = lineStyleNames.find( aStyle );
|
2017-11-15 13:08:27 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
//legacy behavior is to default to dash if there is no name
|
|
|
|
return resultIt == lineStyleNames.end() ? lineStyleNames.find( PLOT_DASH_TYPE::DASH )->second :
|
|
|
|
resultIt->second;
|
2017-11-15 13:08:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
PLOT_DASH_TYPE SCH_LINE::GetLineStyleByName( const wxString& aStyleName )
|
2017-11-15 13:08:27 +00:00
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
PLOT_DASH_TYPE id = PLOT_DASH_TYPE::DEFAULT; // Default style id
|
2017-11-15 13:08:27 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
//find the name by value
|
|
|
|
auto resultIt = std::find_if( lineStyleNames.begin(), lineStyleNames.end(),
|
|
|
|
[aStyleName]( const auto& it ) { return it.second == aStyleName; } );
|
|
|
|
|
|
|
|
if( resultIt != lineStyleNames.end() )
|
|
|
|
id = resultIt->first;
|
2017-11-15 13:08:27 +00:00
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
|
|
|
|
void SCH_LINE::Move( const wxPoint& aOffset )
|
|
|
|
{
|
2019-04-27 12:09:04 +00:00
|
|
|
if( aOffset != wxPoint( 0, 0 ) )
|
|
|
|
{
|
|
|
|
m_start += aOffset;
|
|
|
|
m_end += aOffset;
|
|
|
|
SetModified();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_LINE::MoveStart( const wxPoint& aOffset )
|
|
|
|
{
|
|
|
|
if( aOffset != wxPoint( 0, 0 ) )
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2011-12-07 20:19:29 +00:00
|
|
|
m_start += aOffset;
|
2011-02-28 18:36:19 +00:00
|
|
|
SetModified();
|
|
|
|
}
|
2019-04-27 12:09:04 +00:00
|
|
|
}
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2019-04-27 12:09:04 +00:00
|
|
|
void SCH_LINE::MoveEnd( const wxPoint& aOffset )
|
|
|
|
{
|
|
|
|
if( aOffset != wxPoint( 0, 0 ) )
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2011-12-07 20:19:29 +00:00
|
|
|
m_end += aOffset;
|
2011-02-28 18:36:19 +00:00
|
|
|
SetModified();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
|
|
|
|
void SCH_LINE::Show( int nestLevel, std::ostream& os ) const
|
|
|
|
{
|
|
|
|
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
|
|
|
|
<< " layer=\"" << m_Layer << '"'
|
2011-12-07 20:19:29 +00:00
|
|
|
<< " startIsDangling=\"" << m_startIsDangling
|
2011-02-28 18:36:19 +00:00
|
|
|
<< '"' << " endIsDangling=\""
|
2011-12-07 20:19:29 +00:00
|
|
|
<< m_endIsDangling << '"' << ">"
|
|
|
|
<< " <start" << m_start << "/>"
|
|
|
|
<< " <end" << m_end << "/>" << "</"
|
2011-02-28 18:36:19 +00:00
|
|
|
<< GetClass().Lower().mb_str() << ">\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2019-08-03 19:44:20 +00:00
|
|
|
void SCH_LINE::ViewGetLayers( int aLayers[], int& aCount ) const
|
|
|
|
{
|
|
|
|
aCount = 2;
|
|
|
|
aLayers[0] = m_Layer;
|
|
|
|
aLayers[1] = LAYER_SELECTION_SHADOWS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-24 17:48:14 +00:00
|
|
|
const EDA_RECT SCH_LINE::GetBoundingBox() const
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2020-06-17 19:59:27 +00:00
|
|
|
int width = m_stroke.GetWidth() / 2;
|
|
|
|
int extra = m_stroke.GetWidth() & 0x1;
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2012-09-22 11:19:37 +00:00
|
|
|
int xmin = std::min( m_start.x, m_end.x ) - width;
|
|
|
|
int ymin = std::min( m_start.y, m_end.y ) - width;
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2020-01-07 14:49:50 +00:00
|
|
|
int xmax = std::max( m_start.x, m_end.x ) + width + extra;
|
|
|
|
int ymax = std::max( m_start.y, m_end.y ) + width + extra;
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2020-01-07 14:49:50 +00:00
|
|
|
EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin, ymax - ymin ) );
|
2011-02-28 18:36:19 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
double SCH_LINE::GetLength() const
|
|
|
|
{
|
2011-12-07 20:19:29 +00:00
|
|
|
return GetLineLength( m_start, m_end );
|
2011-03-25 19:16:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-17 19:59:27 +00:00
|
|
|
void SCH_LINE::SetLineColor( const COLOR4D& aColor )
|
2017-10-31 16:33:37 +00:00
|
|
|
{
|
2020-06-17 19:59:27 +00:00
|
|
|
m_stroke.SetColor( aColor );
|
2017-10-31 16:33:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_LINE::SetLineColor( const double r, const double g, const double b, const double a )
|
|
|
|
{
|
|
|
|
COLOR4D newColor(r, g, b, a);
|
|
|
|
|
2020-02-03 16:46:58 +00:00
|
|
|
if( newColor == COLOR4D::UNSPECIFIED )
|
2020-06-17 19:59:27 +00:00
|
|
|
m_stroke.SetColor( COLOR4D::UNSPECIFIED );
|
2017-10-31 16:33:37 +00:00
|
|
|
else
|
2017-11-14 23:19:03 +00:00
|
|
|
{
|
|
|
|
// Eeschema does not allow alpha channel in colors
|
|
|
|
newColor.a = 1.0;
|
2020-06-17 19:59:27 +00:00
|
|
|
m_stroke.SetColor( newColor );
|
2017-11-14 23:19:03 +00:00
|
|
|
}
|
2017-10-31 16:33:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
COLOR4D SCH_LINE::GetLineColor() const
|
|
|
|
{
|
2020-08-24 17:00:19 +00:00
|
|
|
if( m_stroke.GetColor() != COLOR4D::UNSPECIFIED )
|
|
|
|
return m_stroke.GetColor();
|
|
|
|
|
2020-07-08 18:29:16 +00:00
|
|
|
NETCLASSPTR netclass = NetClass();
|
|
|
|
|
2020-08-24 17:00:19 +00:00
|
|
|
if( netclass )
|
2020-07-08 18:29:16 +00:00
|
|
|
return netclass->GetSchematicColor();
|
|
|
|
|
2020-06-17 19:59:27 +00:00
|
|
|
return m_stroke.GetColor();
|
2017-10-31 16:33:37 +00:00
|
|
|
}
|
|
|
|
|
2020-02-03 16:46:58 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
PLOT_DASH_TYPE SCH_LINE::GetDefaultStyle() const
|
2017-10-31 16:33:37 +00:00
|
|
|
{
|
2019-12-26 15:15:34 +00:00
|
|
|
if( IsGraphicLine() )
|
2019-12-28 00:55:11 +00:00
|
|
|
return PLOT_DASH_TYPE::DASH;
|
2017-10-31 16:33:37 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
return PLOT_DASH_TYPE::SOLID;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_LINE::SetLineStyle( const int aStyleId )
|
|
|
|
{
|
|
|
|
SetLineStyle( static_cast<PLOT_DASH_TYPE>( aStyleId ) );
|
2017-10-31 16:33:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
void SCH_LINE::SetLineStyle( const PLOT_DASH_TYPE aStyle )
|
2017-10-31 16:33:37 +00:00
|
|
|
{
|
|
|
|
if( aStyle == GetDefaultStyle() )
|
2020-06-17 19:59:27 +00:00
|
|
|
m_stroke.SetType( PLOT_DASH_TYPE::DEFAULT );
|
2017-10-31 16:33:37 +00:00
|
|
|
else
|
2020-06-17 19:59:27 +00:00
|
|
|
m_stroke.SetType( aStyle );
|
2017-10-31 16:33:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
PLOT_DASH_TYPE SCH_LINE::GetLineStyle() const
|
2017-10-31 16:33:37 +00:00
|
|
|
{
|
2020-06-17 19:59:27 +00:00
|
|
|
if( m_stroke.GetType() != PLOT_DASH_TYPE::DEFAULT )
|
|
|
|
return m_stroke.GetType();
|
2017-10-31 16:33:37 +00:00
|
|
|
|
2017-11-13 03:53:27 +00:00
|
|
|
return GetDefaultStyle();
|
2017-10-31 16:33:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-08 18:29:16 +00:00
|
|
|
PLOT_DASH_TYPE SCH_LINE::GetEffectiveLineStyle() const
|
|
|
|
{
|
2020-08-24 17:00:19 +00:00
|
|
|
if( m_stroke.GetType() != PLOT_DASH_TYPE::DEFAULT )
|
|
|
|
return m_stroke.GetType();
|
|
|
|
|
2020-07-08 18:29:16 +00:00
|
|
|
NETCLASSPTR netclass = NetClass();
|
|
|
|
|
|
|
|
if( netclass )
|
|
|
|
return (PLOT_DASH_TYPE) netclass->GetLineStyle();
|
|
|
|
|
|
|
|
return GetLineStyle();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-31 16:33:37 +00:00
|
|
|
void SCH_LINE::SetLineWidth( const int aSize )
|
|
|
|
{
|
2020-06-17 19:59:27 +00:00
|
|
|
m_stroke.SetWidth( aSize );
|
2017-10-31 16:33:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
int SCH_LINE::GetPenWidth() const
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2020-07-08 18:29:16 +00:00
|
|
|
NETCLASSPTR netclass = NetClass();
|
|
|
|
|
2020-08-09 20:51:40 +00:00
|
|
|
switch ( m_Layer )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
if( m_stroke.GetWidth() > 0 )
|
|
|
|
return m_stroke.GetWidth();
|
|
|
|
|
|
|
|
if( Schematic() )
|
|
|
|
return Schematic()->Settings().m_DefaultLineWidth;
|
|
|
|
|
|
|
|
return DEFAULT_LINE_THICKNESS;
|
|
|
|
|
|
|
|
case LAYER_WIRE:
|
|
|
|
if( m_stroke.GetWidth() > 0 )
|
|
|
|
return m_stroke.GetWidth();
|
2020-07-08 18:29:16 +00:00
|
|
|
|
2020-08-18 15:51:45 +00:00
|
|
|
if( netclass )
|
|
|
|
return netclass->GetWireWidth();
|
|
|
|
|
2020-08-09 20:51:40 +00:00
|
|
|
if( Schematic() )
|
|
|
|
return Schematic()->Settings().m_DefaultWireThickness;
|
2020-05-20 03:39:15 +00:00
|
|
|
|
2020-08-09 20:51:40 +00:00
|
|
|
return DEFAULT_WIRE_THICKNESS;
|
|
|
|
|
|
|
|
case LAYER_BUS:
|
|
|
|
if( m_stroke.GetWidth() > 0 )
|
|
|
|
return m_stroke.GetWidth();
|
|
|
|
|
2020-08-18 15:51:45 +00:00
|
|
|
if( netclass )
|
|
|
|
return netclass->GetBusWidth();
|
|
|
|
|
2020-08-09 20:51:40 +00:00
|
|
|
if( Schematic() )
|
|
|
|
return Schematic()->Settings().m_DefaultBusThickness;
|
|
|
|
|
|
|
|
return DEFAULT_BUS_THICKNESS;
|
|
|
|
}
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
void SCH_LINE::Print( RENDER_SETTINGS* aSettings, const wxPoint& offset )
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2020-04-14 12:25:00 +00:00
|
|
|
wxDC* DC = aSettings->GetPrintDC();
|
2020-07-27 20:46:22 +00:00
|
|
|
COLOR4D color = GetLineColor();
|
|
|
|
|
|
|
|
if( color == COLOR4D::UNSPECIFIED )
|
|
|
|
color = aSettings->GetLayerColor( GetLayer() );
|
|
|
|
|
2011-12-07 20:19:29 +00:00
|
|
|
wxPoint start = m_start;
|
|
|
|
wxPoint end = m_end;
|
2020-04-14 12:25:00 +00:00
|
|
|
int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
|
|
|
|
|
|
|
|
GRLine( nullptr, DC, start.x, start.y, end.x, end.y, penWidth, color,
|
2020-07-08 18:29:16 +00:00
|
|
|
GetwxPenStyle( GetEffectiveLineStyle() ) );
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_LINE::MirrorX( int aXaxis_position )
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2015-06-26 13:41:56 +00:00
|
|
|
MIRROR( m_start.y, aXaxis_position );
|
|
|
|
MIRROR( m_end.y, aXaxis_position );
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_LINE::MirrorY( int aYaxis_position )
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2015-06-26 13:41:56 +00:00
|
|
|
MIRROR( m_start.x, aYaxis_position );
|
|
|
|
MIRROR( m_end.x, aYaxis_position );
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_LINE::Rotate( wxPoint aPosition )
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2012-03-15 14:31:16 +00:00
|
|
|
RotatePoint( &m_start, aPosition, 900 );
|
|
|
|
RotatePoint( &m_end, aPosition, 900 );
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-03 22:46:44 +00:00
|
|
|
void SCH_LINE::RotateStart( wxPoint aPosition )
|
|
|
|
{
|
|
|
|
RotatePoint( &m_start, aPosition, 900 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_LINE::RotateEnd( wxPoint aPosition )
|
|
|
|
{
|
|
|
|
RotatePoint( &m_end, aPosition, 900 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-16 21:38:57 +00:00
|
|
|
bool SCH_LINE::IsSameQuadrant( SCH_LINE* aLine, const wxPoint& aPosition )
|
|
|
|
{
|
|
|
|
wxPoint first;
|
|
|
|
wxPoint second;
|
|
|
|
|
|
|
|
if( m_start == aPosition )
|
|
|
|
first = m_end - aPosition;
|
|
|
|
else if( m_end == aPosition )
|
|
|
|
first = m_start - aPosition;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( aLine->m_start == aPosition )
|
|
|
|
second = aLine->m_end - aPosition;
|
|
|
|
else if( aLine->m_end == aPosition )
|
|
|
|
second = aLine->m_start - aPosition;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
|
2019-06-19 10:31:21 +00:00
|
|
|
return ( sign( first.x ) == sign( second.x ) && sign( first.y ) == sign( second.y ) );
|
2017-10-16 21:38:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_LINE::IsParallel( SCH_LINE* aLine )
|
|
|
|
{
|
|
|
|
wxCHECK_MSG( aLine != NULL && aLine->Type() == SCH_LINE_T, false,
|
|
|
|
wxT( "Cannot test line segment for overlap." ) );
|
|
|
|
|
|
|
|
wxPoint firstSeg = m_end - m_start;
|
|
|
|
wxPoint secondSeg = aLine->m_end - aLine->m_start;
|
|
|
|
|
|
|
|
// Use long long here to avoid overflow in calculations
|
|
|
|
return !( (long long) firstSeg.x * secondSeg.y - (long long) firstSeg.y * secondSeg.x );
|
|
|
|
}
|
|
|
|
|
2017-11-27 19:27:24 +00:00
|
|
|
|
2019-12-11 13:22:59 +00:00
|
|
|
SCH_LINE* SCH_LINE::MergeOverlap( SCH_LINE* aLine )
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2017-11-17 16:35:20 +00:00
|
|
|
auto less = []( const wxPoint& lhs, const wxPoint& rhs ) -> bool
|
|
|
|
{
|
|
|
|
if( lhs.x == rhs.x )
|
|
|
|
return lhs.y < rhs.y;
|
|
|
|
return lhs.x < rhs.x;
|
|
|
|
};
|
2019-04-03 02:46:22 +00:00
|
|
|
|
2017-11-27 19:27:24 +00:00
|
|
|
wxCHECK_MSG( aLine != NULL && aLine->Type() == SCH_LINE_T, NULL,
|
2011-02-28 18:36:19 +00:00
|
|
|
wxT( "Cannot test line segment for overlap." ) );
|
|
|
|
|
|
|
|
if( this == aLine || GetLayer() != aLine->GetLayer() )
|
2019-12-11 13:22:59 +00:00
|
|
|
return nullptr;
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2019-04-03 02:46:22 +00:00
|
|
|
auto leftmost_start = aLine->m_start;
|
|
|
|
auto leftmost_end = aLine->m_end;
|
|
|
|
|
|
|
|
auto rightmost_start = m_start;
|
|
|
|
auto rightmost_end = m_end;
|
2017-11-17 16:35:20 +00:00
|
|
|
|
|
|
|
// We place the start to the left and below the end of both lines
|
2019-04-03 02:46:22 +00:00
|
|
|
if( leftmost_start != std::min( { leftmost_start, leftmost_end }, less ) )
|
|
|
|
std::swap( leftmost_start, leftmost_end );
|
|
|
|
if( rightmost_start != std::min( { rightmost_start, rightmost_end }, less ) )
|
|
|
|
std::swap( rightmost_start, rightmost_end );
|
2017-11-17 16:35:20 +00:00
|
|
|
|
|
|
|
// -leftmost is the line that starts farthest to the left
|
|
|
|
// -other is the line that is _not_ leftmost
|
|
|
|
// -rightmost is the line that ends farthest to the right. This may or
|
|
|
|
// may not be 'other' as the second line may be completely covered by
|
|
|
|
// the first.
|
2019-04-03 02:46:22 +00:00
|
|
|
if( less( rightmost_start, leftmost_start ) )
|
|
|
|
{
|
|
|
|
std::swap( leftmost_start, rightmost_start );
|
|
|
|
std::swap( leftmost_end, rightmost_end );
|
|
|
|
}
|
2017-11-17 16:35:20 +00:00
|
|
|
|
2019-04-03 02:46:22 +00:00
|
|
|
auto other_start = rightmost_start;
|
|
|
|
auto other_end = rightmost_end;
|
2017-11-17 16:35:20 +00:00
|
|
|
|
2019-04-03 02:46:22 +00:00
|
|
|
if( less( rightmost_end, leftmost_end ) )
|
|
|
|
{
|
|
|
|
rightmost_start = leftmost_start;
|
|
|
|
rightmost_end = leftmost_end;
|
|
|
|
}
|
2017-11-17 16:35:20 +00:00
|
|
|
|
|
|
|
// If we end one before the beginning of the other, no overlap is possible
|
2019-04-03 02:46:22 +00:00
|
|
|
if( less( leftmost_end, other_start ) )
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2019-12-11 13:22:59 +00:00
|
|
|
return nullptr;
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
2017-11-17 16:35:20 +00:00
|
|
|
|
|
|
|
// Search for a common end:
|
2019-08-31 19:20:44 +00:00
|
|
|
if( ( leftmost_start == other_start ) && ( leftmost_end == other_end ) ) // Trivial case
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2019-04-03 20:26:43 +00:00
|
|
|
auto ret = new SCH_LINE( *aLine );
|
|
|
|
ret->SetStartPoint( leftmost_start );
|
2019-04-03 02:46:22 +00:00
|
|
|
ret->SetEndPoint( leftmost_end );
|
2019-08-31 19:20:44 +00:00
|
|
|
|
|
|
|
if( IsSelected() || aLine->IsSelected() )
|
|
|
|
ret->SetSelected();
|
|
|
|
|
2019-04-03 02:46:22 +00:00
|
|
|
return ret;
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
2012-03-19 07:48:29 +00:00
|
|
|
bool colinear = false;
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
/* Test alignment: */
|
2019-04-03 02:46:22 +00:00
|
|
|
if( ( leftmost_start.y == leftmost_end.y ) &&
|
|
|
|
( other_start.y == other_end.y ) ) // Horizontal segment
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2019-04-03 02:46:22 +00:00
|
|
|
colinear = ( leftmost_start.y == other_start.y );
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
2019-04-03 02:46:22 +00:00
|
|
|
else if( ( leftmost_start.x == leftmost_end.x ) &&
|
|
|
|
( other_start.x == other_end.x ) ) // Vertical segment
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2019-04-03 02:46:22 +00:00
|
|
|
colinear = ( leftmost_start.x == other_start.x );
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-11-17 16:35:20 +00:00
|
|
|
// We use long long here to avoid overflow -- it enforces promotion
|
|
|
|
// Don't use double as we need to make a direct comparison
|
|
|
|
// The slope of the left-most line is dy/dx. Then we check that the slope
|
|
|
|
// from the left most start to the right most start is the same as well as
|
|
|
|
// the slope from the left most start to right most end.
|
2019-04-03 02:46:22 +00:00
|
|
|
long long dx = leftmost_end.x - leftmost_start.x;
|
|
|
|
long long dy = leftmost_end.y - leftmost_start.y;
|
|
|
|
colinear = ( ( ( other_start.y - leftmost_start.y ) * dx ==
|
|
|
|
( other_start.x - leftmost_start.x ) * dy ) &&
|
|
|
|
( ( other_end.y - leftmost_start.y ) * dx ==
|
|
|
|
( other_end.x - leftmost_start.x ) * dy ) );
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
2017-11-17 16:35:20 +00:00
|
|
|
// Make a new segment that merges the 2 segments
|
2012-03-19 07:48:29 +00:00
|
|
|
if( colinear )
|
|
|
|
{
|
2019-04-03 02:46:22 +00:00
|
|
|
leftmost_end = rightmost_end;
|
|
|
|
|
2019-04-03 20:26:43 +00:00
|
|
|
auto ret = new SCH_LINE( *aLine );
|
|
|
|
ret->SetStartPoint( leftmost_start );
|
2019-04-03 02:46:22 +00:00
|
|
|
ret->SetEndPoint( leftmost_end );
|
2019-08-31 19:20:44 +00:00
|
|
|
|
|
|
|
if( IsSelected() || aLine->IsSelected() )
|
|
|
|
ret->SetSelected();
|
|
|
|
|
2019-04-03 02:46:22 +00:00
|
|
|
return ret;
|
2012-03-19 07:48:29 +00:00
|
|
|
}
|
2017-11-17 16:35:20 +00:00
|
|
|
|
2019-12-11 13:22:59 +00:00
|
|
|
return nullptr;
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_LINE::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
|
|
|
|
{
|
2019-12-26 15:15:34 +00:00
|
|
|
if( IsGraphicLine() )
|
2011-02-28 18:36:19 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if( ( GetLayer() == LAYER_BUS ) || ( GetLayer() == LAYER_WIRE ) )
|
|
|
|
{
|
2011-12-06 21:02:21 +00:00
|
|
|
DANGLING_END_ITEM item( (GetLayer() == LAYER_BUS) ? BUS_START_END : WIRE_START_END, this,
|
2011-12-07 20:19:29 +00:00
|
|
|
m_start );
|
2011-02-28 18:36:19 +00:00
|
|
|
aItemList.push_back( item );
|
2011-12-06 21:02:21 +00:00
|
|
|
|
|
|
|
DANGLING_END_ITEM item1( (GetLayer() == LAYER_BUS) ? BUS_END_END : WIRE_END_END, this,
|
2011-12-07 20:19:29 +00:00
|
|
|
m_end );
|
2011-02-28 18:36:19 +00:00
|
|
|
aItemList.push_back( item1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-17 02:33:16 +00:00
|
|
|
bool SCH_LINE::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
|
|
|
|
const SCH_SHEET_PATH* aPath )
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2011-12-07 20:19:29 +00:00
|
|
|
bool previousStartState = m_startIsDangling;
|
|
|
|
bool previousEndState = m_endIsDangling;
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2011-12-07 20:19:29 +00:00
|
|
|
m_startIsDangling = m_endIsDangling = true;
|
2011-02-28 18:36:19 +00:00
|
|
|
|
|
|
|
if( GetLayer() == LAYER_WIRE )
|
|
|
|
{
|
2016-06-29 20:07:55 +00:00
|
|
|
for( DANGLING_END_ITEM item : aItemList )
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2011-12-06 21:02:21 +00:00
|
|
|
if( item.GetItem() == this )
|
2011-02-28 18:36:19 +00:00
|
|
|
continue;
|
2015-06-08 00:07:42 +00:00
|
|
|
|
2018-11-27 14:43:04 +00:00
|
|
|
if( item.GetType() == BUS_START_END ||
|
2017-12-01 01:21:23 +00:00
|
|
|
item.GetType() == BUS_END_END ||
|
|
|
|
item.GetType() == BUS_ENTRY_END )
|
2015-06-08 00:07:42 +00:00
|
|
|
continue;
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2011-12-07 20:19:29 +00:00
|
|
|
if( m_start == item.GetPosition() )
|
|
|
|
m_startIsDangling = false;
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2011-12-07 20:19:29 +00:00
|
|
|
if( m_end == item.GetPosition() )
|
|
|
|
m_endIsDangling = false;
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2020-01-17 02:33:16 +00:00
|
|
|
if( !m_startIsDangling && !m_endIsDangling )
|
2011-02-28 18:36:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-12-26 15:15:34 +00:00
|
|
|
else if( GetLayer() == LAYER_BUS || IsGraphicLine() )
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
|
|
|
// Lines on the notes layer and the bus layer cannot be tested for dangling ends.
|
2011-12-07 20:19:29 +00:00
|
|
|
previousStartState = previousEndState = m_startIsDangling = m_endIsDangling = false;
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
2011-12-07 20:19:29 +00:00
|
|
|
return ( previousStartState != m_startIsDangling ) || ( previousEndState != m_endIsDangling );
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_LINE::IsConnectable() const
|
|
|
|
{
|
|
|
|
if( m_Layer == LAYER_WIRE || m_Layer == LAYER_BUS )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-19 17:45:56 +00:00
|
|
|
bool SCH_LINE::CanConnect( const SCH_ITEM* aItem ) const
|
|
|
|
{
|
|
|
|
switch( aItem->Type() )
|
|
|
|
{
|
|
|
|
case SCH_JUNCTION_T:
|
|
|
|
case SCH_NO_CONNECT_T:
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
2019-04-15 23:56:41 +00:00
|
|
|
case SCH_HIER_LABEL_T:
|
2017-12-19 17:45:56 +00:00
|
|
|
case SCH_BUS_WIRE_ENTRY_T:
|
|
|
|
case SCH_COMPONENT_T:
|
|
|
|
case SCH_SHEET_T:
|
|
|
|
case SCH_SHEET_PIN_T:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return aItem->GetLayer() == m_Layer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-08 13:27:13 +00:00
|
|
|
std::vector<wxPoint> SCH_LINE::GetConnectionPoints() const
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2020-09-08 13:27:13 +00:00
|
|
|
return { m_start, m_end };
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-11 20:17:05 +00:00
|
|
|
void SCH_LINE::GetSelectedPoints( std::vector< wxPoint >& aPoints ) const
|
|
|
|
{
|
|
|
|
if( m_Flags & STARTPOINT )
|
|
|
|
aPoints.push_back( m_start );
|
|
|
|
|
|
|
|
if( m_Flags & ENDPOINT )
|
|
|
|
aPoints.push_back( m_end );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString SCH_LINE::GetSelectMenuText( EDA_UNITS aUnits ) const
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2018-04-10 10:52:12 +00:00
|
|
|
wxString txtfmt, orient;
|
2011-10-11 13:38:13 +00:00
|
|
|
|
2011-12-07 20:19:29 +00:00
|
|
|
if( m_start.x == m_end.x )
|
2018-11-11 09:46:26 +00:00
|
|
|
orient = _( "Vertical" );
|
2011-12-07 20:19:29 +00:00
|
|
|
else if( m_start.y == m_end.y )
|
2018-11-11 09:46:26 +00:00
|
|
|
orient = _( "Horizontal" );
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
switch( m_Layer )
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2019-06-19 10:31:21 +00:00
|
|
|
case LAYER_NOTES: txtfmt = _( "%s Graphic Line from (%s, %s) to (%s, %s)" ); break;
|
|
|
|
case LAYER_WIRE: txtfmt = _( "%s Wire from (%s, %s) to (%s, %s)" ); break;
|
|
|
|
case LAYER_BUS: txtfmt = _( "%s Bus from (%s, %s) to (%s, %s)" ); break;
|
|
|
|
default: txtfmt = _( "%s Line on Unknown Layer from (%s, %s) to (%s, %s)" ); break;
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
2018-04-10 10:52:12 +00:00
|
|
|
return wxString::Format( txtfmt,
|
|
|
|
orient,
|
|
|
|
MessageTextFromValue( aUnits, m_start.x ),
|
|
|
|
MessageTextFromValue( aUnits, m_start.y ),
|
|
|
|
MessageTextFromValue( aUnits, m_end.x ),
|
|
|
|
MessageTextFromValue( aUnits, m_end.y ) );
|
2011-03-25 19:16:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-29 03:04:59 +00:00
|
|
|
BITMAP_DEF SCH_LINE::GetMenuImage() const
|
2011-03-25 19:16:05 +00:00
|
|
|
{
|
|
|
|
if( m_Layer == LAYER_NOTES )
|
2011-08-29 03:04:59 +00:00
|
|
|
return add_dashed_line_xpm;
|
2011-03-25 19:16:05 +00:00
|
|
|
else if( m_Layer == LAYER_WIRE )
|
2011-08-29 03:04:59 +00:00
|
|
|
return add_line_xpm;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2011-08-29 03:04:59 +00:00
|
|
|
return add_bus_xpm;
|
2011-03-25 19:16:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_LINE::operator <( const SCH_ITEM& aItem ) const
|
|
|
|
{
|
|
|
|
if( Type() != aItem.Type() )
|
|
|
|
return Type() < aItem.Type();
|
|
|
|
|
2020-01-28 15:42:42 +00:00
|
|
|
auto line = static_cast<const SCH_LINE*>( &aItem );
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2020-01-28 20:33:23 +00:00
|
|
|
if( GetLayer() != line->GetLayer() )
|
|
|
|
return GetLayer() < line->GetLayer();
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2020-01-28 20:33:23 +00:00
|
|
|
if( GetStartPoint().x != line->GetStartPoint().x )
|
|
|
|
return GetStartPoint().x < line->GetStartPoint().x;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2020-01-28 20:33:23 +00:00
|
|
|
if( GetStartPoint().y != line->GetStartPoint().y )
|
|
|
|
return GetStartPoint().y < line->GetStartPoint().y;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2020-01-28 20:33:23 +00:00
|
|
|
if( GetEndPoint().x != line->GetEndPoint().x )
|
|
|
|
return GetEndPoint().x < line->GetEndPoint().x;
|
|
|
|
|
|
|
|
return GetEndPoint().y < line->GetEndPoint().y;
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
bool SCH_LINE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
2011-03-25 19:16:05 +00:00
|
|
|
{
|
2019-09-09 22:21:59 +00:00
|
|
|
// Performance enhancement for connection-building
|
|
|
|
if( aPosition == m_start || aPosition == m_end )
|
|
|
|
return true;
|
|
|
|
|
2019-04-30 00:46:21 +00:00
|
|
|
// Insure minimum accuracy
|
|
|
|
if( aAccuracy == 0 )
|
2020-04-14 12:25:00 +00:00
|
|
|
aAccuracy = ( GetPenWidth() / 2 ) + 4;
|
2019-04-30 00:46:21 +00:00
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
return TestSegmentHit( aPosition, m_start, m_end, aAccuracy );
|
2011-03-25 19:16:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
bool SCH_LINE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
|
2011-02-28 18:36:19 +00:00
|
|
|
{
|
2014-10-28 12:03:50 +00:00
|
|
|
if( m_Flags & ( STRUCT_DELETED | SKIP_STRUCT ) )
|
2012-03-15 14:31:16 +00:00
|
|
|
return false;
|
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT rect = aRect;
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2014-10-28 12:03:50 +00:00
|
|
|
if ( aAccuracy )
|
2016-11-16 10:07:02 +00:00
|
|
|
rect.Inflate( aAccuracy );
|
2011-02-28 18:36:19 +00:00
|
|
|
|
|
|
|
if( aContained )
|
2014-10-28 12:03:50 +00:00
|
|
|
return rect.Contains( m_start ) && rect.Contains( m_end );
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2014-10-28 12:03:50 +00:00
|
|
|
return rect.Intersects( m_start, m_end );
|
2011-02-28 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
2017-11-27 19:27:24 +00:00
|
|
|
|
2017-10-31 16:33:37 +00:00
|
|
|
void SCH_LINE::SwapData( SCH_ITEM* aItem )
|
|
|
|
{
|
|
|
|
SCH_LINE* item = (SCH_LINE*) aItem;
|
|
|
|
|
|
|
|
std::swap( m_Layer, item->m_Layer );
|
|
|
|
|
|
|
|
std::swap( m_start, item->m_start );
|
|
|
|
std::swap( m_end, item->m_end );
|
|
|
|
std::swap( m_startIsDangling, item->m_startIsDangling );
|
|
|
|
std::swap( m_endIsDangling, item->m_endIsDangling );
|
2020-06-17 19:59:27 +00:00
|
|
|
std::swap( m_stroke, item->m_stroke );
|
2017-10-31 16:33:37 +00:00
|
|
|
}
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2017-11-27 19:27:24 +00:00
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
bool SCH_LINE::doIsConnected( const wxPoint& aPosition ) const
|
|
|
|
{
|
|
|
|
if( m_Layer != LAYER_WIRE && m_Layer != LAYER_BUS )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return IsEndPoint( aPosition );
|
|
|
|
}
|
2011-06-17 13:24:22 +00:00
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_LINE::Plot( PLOTTER* aPlotter )
|
2011-06-17 13:24:22 +00:00
|
|
|
{
|
2020-07-27 20:46:22 +00:00
|
|
|
auto* settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
|
|
|
|
int penWidth;
|
|
|
|
COLOR4D color = GetLineColor();
|
2020-05-12 14:02:24 +00:00
|
|
|
|
2020-07-27 20:46:22 +00:00
|
|
|
if( color == COLOR4D::UNSPECIFIED )
|
|
|
|
color = settings->GetLayerColor( GetLayer() );
|
|
|
|
|
|
|
|
aPlotter->SetColor( color );
|
2017-11-13 03:53:27 +00:00
|
|
|
|
2020-05-12 14:02:24 +00:00
|
|
|
switch( m_Layer )
|
|
|
|
{
|
|
|
|
case LAYER_WIRE: penWidth = settings->m_DefaultWireThickness; break;
|
|
|
|
case LAYER_BUS: penWidth = settings->m_DefaultBusThickness; break;
|
|
|
|
default: penWidth = GetPenWidth(); break;
|
|
|
|
}
|
|
|
|
|
2020-06-24 17:35:33 +00:00
|
|
|
if( m_stroke.GetWidth() != 0 )
|
|
|
|
penWidth = m_stroke.GetWidth();
|
|
|
|
|
2020-09-08 19:18:50 +00:00
|
|
|
penWidth = std::max( penWidth, settings->GetMinPenWidth() );
|
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
aPlotter->SetCurrentLineWidth( penWidth );
|
2020-07-08 18:29:16 +00:00
|
|
|
aPlotter->SetDash( GetEffectiveLineStyle() );
|
2011-06-17 13:24:22 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
aPlotter->MoveTo( m_start );
|
|
|
|
aPlotter->FinishTo( m_end );
|
2011-06-17 13:24:22 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
aPlotter->SetDash( PLOT_DASH_TYPE::SOLID );
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
2011-10-19 20:32:21 +00:00
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_LINE::SetPosition( const wxPoint& aPosition )
|
2011-10-19 20:32:21 +00:00
|
|
|
{
|
2011-12-07 20:19:29 +00:00
|
|
|
m_end = m_end - ( m_start - aPosition );
|
|
|
|
m_start = aPosition;
|
2011-10-19 20:32:21 +00:00
|
|
|
}
|
2017-07-13 12:42:06 +00:00
|
|
|
|
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
void SCH_LINE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList )
|
2019-03-11 21:32:05 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
switch( GetLayer() )
|
|
|
|
{
|
2020-06-24 17:35:33 +00:00
|
|
|
case LAYER_WIRE: msg = _( "Wire" ); break;
|
|
|
|
case LAYER_BUS: msg = _( "Bus" ); break;
|
|
|
|
default: msg = _( "Graphical" ); break;
|
2019-03-11 21:32:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Line Type" ), msg, DARKCYAN ) );
|
2020-07-08 18:29:16 +00:00
|
|
|
|
|
|
|
if( GetLineStyle() != GetEffectiveLineStyle() )
|
|
|
|
msg = _( "from netclass" );
|
|
|
|
else
|
|
|
|
msg = GetLineStyleName( GetLineStyle() );
|
|
|
|
|
2020-06-24 17:35:33 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Line Style" ), msg, DARKCYAN ) );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( aFrame );
|
|
|
|
|
2020-07-07 10:17:30 +00:00
|
|
|
if( frame )
|
2019-03-11 21:32:05 +00:00
|
|
|
{
|
2020-07-07 10:17:30 +00:00
|
|
|
if( SCH_CONNECTION* conn = Connection( frame->GetCurrentSheet() ) )
|
|
|
|
{
|
|
|
|
conn->AppendInfoToMsgPanel( aList );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2020-07-07 10:17:30 +00:00
|
|
|
NET_SETTINGS& netSettings = Schematic()->Prj().GetProjectFile().NetSettings();
|
2020-08-24 17:00:19 +00:00
|
|
|
wxString netname = conn->Name( true );
|
|
|
|
wxString netclassName = netSettings.m_NetClasses.GetDefaultPtr()->GetName();
|
2020-07-07 10:17:30 +00:00
|
|
|
|
|
|
|
if( netSettings.m_NetClassAssignments.count( netname ) )
|
2020-08-24 17:00:19 +00:00
|
|
|
netclassName = netSettings.m_NetClassAssignments[ netname ];
|
|
|
|
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Assigned Netclass" ), netclassName, DARKRED ) );
|
2020-07-07 10:17:30 +00:00
|
|
|
}
|
2019-03-11 21:32:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-26 15:15:34 +00:00
|
|
|
|
|
|
|
bool SCH_LINE::IsGraphicLine() const
|
|
|
|
{
|
|
|
|
return ( GetLayer() == LAYER_NOTES );
|
2020-01-07 14:49:50 +00:00
|
|
|
}
|
2020-03-16 13:04:50 +00:00
|
|
|
|
|
|
|
|
2020-05-09 21:19:34 +00:00
|
|
|
bool SCH_LINE::IsWire() const
|
|
|
|
{
|
|
|
|
return ( GetLayer() == LAYER_WIRE );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-16 13:04:50 +00:00
|
|
|
bool SCH_LINE::UsesDefaultStroke() const
|
|
|
|
{
|
2020-06-17 19:59:27 +00:00
|
|
|
return m_stroke.GetWidth() == 0 && m_stroke.GetColor() == COLOR4D::UNSPECIFIED
|
|
|
|
&& ( m_stroke.GetType() == GetDefaultStyle()
|
|
|
|
|| m_stroke.GetType() == PLOT_DASH_TYPE::DEFAULT );
|
2020-03-16 13:04:50 +00:00
|
|
|
}
|