2012-01-14 19:50:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-07-31 19:04:30 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
2012-06-08 09:56:42 +00:00
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
|
|
|
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
|
2015-07-31 19:04:30 +00:00
|
|
|
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-01-14 19:50:32 +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
|
|
|
|
*/
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file class_edge_mod.cpp
|
|
|
|
* @brief EDGE_MODULE class definition.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <trigo.h>
|
|
|
|
#include <class_drawpanel.h>
|
2018-01-29 10:37:29 +00:00
|
|
|
#include <pcb_screen.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <richio.h>
|
|
|
|
#include <macros.h>
|
2013-05-01 17:32:36 +00:00
|
|
|
#include <math_for_graphics.h>
|
2018-01-29 15:39:40 +00:00
|
|
|
#include <pcb_base_frame.h>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <msgpanel.h>
|
|
|
|
#include <base_units.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_edge_mod.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2018-02-17 18:03:22 +00:00
|
|
|
#include <view/view.h>
|
|
|
|
|
2012-02-28 20:14:17 +00:00
|
|
|
#include <stdio.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2011-12-01 22:50:41 +00:00
|
|
|
EDGE_MODULE::EDGE_MODULE( MODULE* parent, STROKE_T aShape ) :
|
2011-10-01 19:24:27 +00:00
|
|
|
DRAWSEGMENT( parent, PCB_MODULE_EDGE_T )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-12-01 22:50:41 +00:00
|
|
|
m_Shape = aShape;
|
2009-11-20 19:51:39 +00:00
|
|
|
m_Angle = 0;
|
2014-06-24 16:17:18 +00:00
|
|
|
m_Layer = F_SilkS;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
EDGE_MODULE::~EDGE_MODULE()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2014-07-09 09:59:24 +00:00
|
|
|
void EDGE_MODULE::SetLocalCoord()
|
|
|
|
{
|
|
|
|
MODULE* module = (MODULE*) m_Parent;
|
|
|
|
|
|
|
|
if( module == NULL )
|
|
|
|
{
|
|
|
|
m_Start0 = m_Start;
|
|
|
|
m_End0 = m_End;
|
2018-07-07 11:04:01 +00:00
|
|
|
m_Bezier0_C1 = m_BezierC1;
|
|
|
|
m_Bezier0_C2 = m_BezierC2;
|
2014-07-09 09:59:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Start0 = m_Start - module->GetPosition();
|
|
|
|
m_End0 = m_End - module->GetPosition();
|
2018-07-07 11:04:01 +00:00
|
|
|
m_Bezier0_C1 = m_BezierC1 - module->GetPosition();
|
|
|
|
m_Bezier0_C2 = m_BezierC2 - module->GetPosition();
|
2014-07-09 09:59:24 +00:00
|
|
|
double angle = module->GetOrientation();
|
|
|
|
RotatePoint( &m_Start0.x, &m_Start0.y, -angle );
|
|
|
|
RotatePoint( &m_End0.x, &m_End0.y, -angle );
|
2018-07-07 11:04:01 +00:00
|
|
|
RotatePoint( &m_Bezier0_C1.x, &m_Bezier0_C1.y, -angle );
|
2018-07-22 12:50:35 +00:00
|
|
|
RotatePoint( &m_Bezier0_C2.x, &m_Bezier0_C2.y, -angle );
|
2014-07-09 09:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
void EDGE_MODULE::SetDrawCoord()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-11-29 17:25:30 +00:00
|
|
|
MODULE* module = (MODULE*) m_Parent;
|
2007-08-06 20:26:59 +00:00
|
|
|
|
|
|
|
m_Start = m_Start0;
|
|
|
|
m_End = m_End0;
|
2018-07-07 11:04:01 +00:00
|
|
|
m_BezierC1 = m_Bezier0_C1;
|
|
|
|
m_BezierC2 = m_Bezier0_C2;
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2011-11-29 17:25:30 +00:00
|
|
|
if( module )
|
2007-08-06 20:26:59 +00:00
|
|
|
{
|
2011-11-29 17:25:30 +00:00
|
|
|
RotatePoint( &m_Start.x, &m_Start.y, module->GetOrientation() );
|
2018-07-07 11:04:01 +00:00
|
|
|
RotatePoint( &m_End.x, &m_End.y, module->GetOrientation() );
|
|
|
|
RotatePoint( &m_BezierC1.x, &m_BezierC1.y, module->GetOrientation() );
|
|
|
|
RotatePoint( &m_BezierC2.x, &m_BezierC2.y, module->GetOrientation() );
|
2011-11-29 17:25:30 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
m_Start += module->GetPosition();
|
|
|
|
m_End += module->GetPosition();
|
2018-07-07 11:04:01 +00:00
|
|
|
m_BezierC1 += module->GetPosition();
|
|
|
|
m_BezierC2 += module->GetPosition();
|
2007-08-06 20:26:59 +00:00
|
|
|
}
|
2018-07-07 11:04:01 +00:00
|
|
|
|
|
|
|
RebuildBezierToSegmentsPointsList( m_Width );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-01 13:38:27 +00:00
|
|
|
void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
|
|
|
const wxPoint& offset )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2014-06-29 13:05:51 +00:00
|
|
|
int ux0, uy0, dx, dy, radius, StAngle, EndAngle;
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
|
2014-06-29 13:05:51 +00:00
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
MODULE* module = (MODULE*) m_Parent;
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2014-06-29 13:05:51 +00:00
|
|
|
if( !module )
|
2010-01-31 20:01:46 +00:00
|
|
|
return;
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2014-06-29 13:05:51 +00:00
|
|
|
BOARD* brd = GetBoard( );
|
2011-08-08 23:50:55 +00:00
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
if( brd->IsLayerVisible( m_Layer ) == false )
|
2007-08-06 20:26:59 +00:00
|
|
|
return;
|
|
|
|
|
2017-08-04 12:43:02 +00:00
|
|
|
|
|
|
|
auto frame = static_cast<PCB_BASE_FRAME*> ( panel->GetParent() );
|
|
|
|
auto color = frame->Settings().Colors().GetLayerColor( m_Layer );
|
|
|
|
|
2017-10-30 17:21:07 +00:00
|
|
|
auto displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() );
|
2009-10-10 01:25:53 +00:00
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
if(( draw_mode & GR_ALLOW_HIGHCONTRAST ) && displ_opts && displ_opts->m_ContrastModeDisplay )
|
2012-02-28 20:14:17 +00:00
|
|
|
{
|
|
|
|
if( !IsOnLayer( curr_layer ) )
|
2017-02-20 16:57:41 +00:00
|
|
|
color = COLOR4D( DARKDARKGRAY );
|
2012-02-28 20:14:17 +00:00
|
|
|
}
|
|
|
|
|
2008-02-19 00:30:10 +00:00
|
|
|
ux0 = m_Start.x - offset.x;
|
2007-08-08 03:50:44 +00:00
|
|
|
uy0 = m_Start.y - offset.y;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
2009-11-20 19:51:39 +00:00
|
|
|
dx = m_End.x - offset.x;
|
|
|
|
dy = m_End.y - offset.y;
|
2007-08-06 20:26:59 +00:00
|
|
|
|
|
|
|
GRSetDrawMode( DC, draw_mode );
|
2015-02-02 08:06:39 +00:00
|
|
|
bool filled = displ_opts ? displ_opts->m_DisplayModEdgeFill : FILLED;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( IsCopperLayer( m_Layer ) )
|
2015-02-02 08:06:39 +00:00
|
|
|
filled = displ_opts ? displ_opts->m_DisplayPcbTrackFill : FILLED;
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2014-09-24 16:42:56 +00:00
|
|
|
switch( m_Shape )
|
2007-08-06 20:26:59 +00:00
|
|
|
{
|
|
|
|
case S_SEGMENT:
|
2015-02-02 08:06:39 +00:00
|
|
|
if( filled )
|
2011-12-29 20:11:42 +00:00
|
|
|
GRLine( panel->GetClipBox(), DC, ux0, uy0, dx, dy, m_Width, color );
|
2007-08-06 20:26:59 +00:00
|
|
|
else
|
|
|
|
// SKETCH Mode
|
2011-12-29 20:11:42 +00:00
|
|
|
GRCSegm( panel->GetClipBox(), DC, ux0, uy0, dx, dy, m_Width, color );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-08-06 20:26:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_CIRCLE:
|
2013-05-01 17:32:36 +00:00
|
|
|
radius = KiROUND( Distance( ux0, uy0, dx, dy ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
if( filled )
|
2007-08-06 20:26:59 +00:00
|
|
|
{
|
2015-02-02 08:06:39 +00:00
|
|
|
GRCircle( panel->GetClipBox(), DC, ux0, uy0, radius, m_Width, color );
|
2007-08-06 20:26:59 +00:00
|
|
|
}
|
2015-02-02 08:06:39 +00:00
|
|
|
else // SKETCH Mode
|
2007-08-06 20:26:59 +00:00
|
|
|
{
|
2015-02-02 08:06:39 +00:00
|
|
|
GRCircle( panel->GetClipBox(), DC, ux0, uy0, radius + (m_Width / 2), color );
|
|
|
|
GRCircle( panel->GetClipBox(), DC, ux0, uy0, radius - (m_Width / 2), color );
|
2007-08-06 20:26:59 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-08-06 20:26:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_ARC:
|
2013-05-01 17:32:36 +00:00
|
|
|
radius = KiROUND( Distance( ux0, uy0, dx, dy ) );
|
|
|
|
StAngle = ArcTangente( dy - uy0, dx - ux0 );
|
2007-08-06 20:26:59 +00:00
|
|
|
EndAngle = StAngle + m_Angle;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-02-12 10:03:34 +00:00
|
|
|
if( !panel->GetPrintMirrored() )
|
|
|
|
{
|
|
|
|
if( StAngle > EndAngle )
|
2015-06-26 13:41:56 +00:00
|
|
|
std::swap( StAngle, EndAngle );
|
2014-02-12 10:03:34 +00:00
|
|
|
}
|
|
|
|
else // Mirrored mode: arc orientation is reversed
|
|
|
|
{
|
|
|
|
if( StAngle < EndAngle )
|
2015-06-26 13:41:56 +00:00
|
|
|
std::swap( StAngle, EndAngle );
|
2014-02-12 10:03:34 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
if( filled )
|
2007-08-06 20:26:59 +00:00
|
|
|
{
|
2011-12-29 20:11:42 +00:00
|
|
|
GRArc( panel->GetClipBox(), DC, ux0, uy0, StAngle, EndAngle, radius, m_Width, color );
|
2007-08-06 20:26:59 +00:00
|
|
|
}
|
|
|
|
else // SKETCH Mode
|
|
|
|
{
|
2011-12-29 20:11:42 +00:00
|
|
|
GRArc( panel->GetClipBox(), DC, ux0, uy0, StAngle, EndAngle,
|
2011-09-07 19:41:04 +00:00
|
|
|
radius + (m_Width / 2), color );
|
2011-12-29 20:11:42 +00:00
|
|
|
GRArc( panel->GetClipBox(), DC, ux0, uy0, StAngle, EndAngle,
|
2011-09-07 19:41:04 +00:00
|
|
|
radius - (m_Width / 2), color );
|
2007-08-06 20:26:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case S_POLYGON:
|
2017-10-25 07:39:26 +00:00
|
|
|
if( m_Poly.IsEmpty() )
|
|
|
|
break;
|
|
|
|
|
2014-09-24 16:42:56 +00:00
|
|
|
{
|
2015-07-31 19:04:30 +00:00
|
|
|
// We must compute absolute coordinates from m_PolyPoints
|
2009-01-29 14:26:20 +00:00
|
|
|
// which are relative to module position, orientation 0
|
2017-10-19 21:16:06 +00:00
|
|
|
std::vector<wxPoint> points;
|
|
|
|
|
|
|
|
for( auto iter = m_Poly.CIterate(); iter; iter++ )
|
|
|
|
{
|
|
|
|
points.push_back( wxPoint( iter->x,iter->y ) );
|
|
|
|
}
|
2008-12-29 18:02:54 +00:00
|
|
|
|
2009-01-29 14:26:20 +00:00
|
|
|
for( unsigned ii = 0; ii < points.size(); ii++ )
|
|
|
|
{
|
|
|
|
wxPoint& pt = points[ii];
|
2008-12-29 18:02:54 +00:00
|
|
|
|
2011-11-29 17:25:30 +00:00
|
|
|
RotatePoint( &pt.x, &pt.y, module->GetOrientation() );
|
2013-03-13 18:53:58 +00:00
|
|
|
pt += module->GetPosition() - offset;
|
2008-12-29 18:02:54 +00:00
|
|
|
}
|
2009-01-29 14:26:20 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
GRPoly( panel->GetClipBox(), DC, points.size(), &points[0], true, m_Width, color, color );
|
2014-09-24 16:42:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2018-07-07 11:04:01 +00:00
|
|
|
case S_CURVE:
|
|
|
|
{
|
|
|
|
RebuildBezierToSegmentsPointsList( m_Width );
|
|
|
|
|
|
|
|
wxPoint& startp = m_BezierPoints[0];
|
|
|
|
|
|
|
|
for( unsigned int i = 1; i < m_BezierPoints.size(); i++ )
|
|
|
|
{
|
|
|
|
wxPoint& endp = m_BezierPoints[i];
|
|
|
|
|
|
|
|
if( filled )
|
|
|
|
GRFilledSegment( panel->GetClipBox(), DC,
|
|
|
|
startp-offset, endp-offset, m_Width, color );
|
|
|
|
else
|
|
|
|
GRCSegm( panel->GetClipBox(), DC,
|
|
|
|
startp-offset, endp-offset, m_Width, color );
|
|
|
|
|
|
|
|
startp = m_BezierPoints[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2014-09-24 16:42:56 +00:00
|
|
|
default:
|
2007-08-06 20:26:59 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2007-08-20 19:33:15 +00:00
|
|
|
|
|
|
|
|
2008-02-19 00:30:10 +00:00
|
|
|
// see class_edge_mod.h
|
2018-04-10 10:52:12 +00:00
|
|
|
void EDGE_MODULE::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList )
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
2009-10-11 15:13:39 +00:00
|
|
|
wxString msg;
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2009-11-20 19:51:39 +00:00
|
|
|
MODULE* module = (MODULE*) m_Parent;
|
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
if( !module )
|
|
|
|
return;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
BOARD* board = (BOARD*) module->GetParent();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-02-19 00:30:10 +00:00
|
|
|
if( !board )
|
|
|
|
return;
|
|
|
|
|
2014-11-15 19:06:05 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), module->GetReference(), DARKCYAN ) );
|
2014-11-15 13:09:59 +00:00
|
|
|
|
|
|
|
// append the features shared with the base class
|
2018-04-10 10:52:12 +00:00
|
|
|
DRAWSEGMENT::GetMsgPanelInfo( aUnits, aList );
|
2007-08-20 19:33:15 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-04-10 10:52:12 +00:00
|
|
|
wxString EDGE_MODULE::GetSelectMenuText( EDA_UNITS_T aUnits ) const
|
2011-07-14 15:42:44 +00:00
|
|
|
{
|
2018-04-10 10:52:12 +00:00
|
|
|
return wxString::Format( _( "Graphic %s of %s on %s" ),
|
|
|
|
ShowShape( m_Shape ),
|
|
|
|
((MODULE*) GetParent())->GetReference(),
|
|
|
|
GetLayerName() );
|
2011-07-14 15:42:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-20 12:20:39 +00:00
|
|
|
BITMAP_DEF EDGE_MODULE::GetMenuImage() const
|
|
|
|
{
|
|
|
|
return show_mod_edge_xpm;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-17 14:39:27 +00:00
|
|
|
EDA_ITEM* EDGE_MODULE::Clone() const
|
2012-01-14 19:50:32 +00:00
|
|
|
{
|
|
|
|
return new EDGE_MODULE( *this );
|
|
|
|
}
|
|
|
|
|
2014-09-24 16:42:56 +00:00
|
|
|
|
2014-11-15 19:06:05 +00:00
|
|
|
void EDGE_MODULE::Flip( const wxPoint& aCentre )
|
2014-09-24 16:42:56 +00:00
|
|
|
{
|
|
|
|
wxPoint pt;
|
|
|
|
|
|
|
|
switch( GetShape() )
|
|
|
|
{
|
|
|
|
case S_ARC:
|
|
|
|
SetAngle( -GetAngle() );
|
|
|
|
//Fall through
|
|
|
|
default:
|
|
|
|
case S_SEGMENT:
|
2018-07-07 11:04:01 +00:00
|
|
|
case S_CURVE:
|
2014-09-24 16:42:56 +00:00
|
|
|
pt = GetStart();
|
2015-07-31 19:04:30 +00:00
|
|
|
MIRROR( pt.y, aCentre.y );
|
2014-09-24 16:42:56 +00:00
|
|
|
SetStart( pt );
|
|
|
|
|
|
|
|
pt = GetEnd();
|
2015-07-31 19:04:30 +00:00
|
|
|
MIRROR( pt.y, aCentre.y );
|
2014-09-24 16:42:56 +00:00
|
|
|
SetEnd( pt );
|
|
|
|
|
2018-07-07 11:04:01 +00:00
|
|
|
MIRROR( m_BezierC1.y, aCentre.y );
|
|
|
|
MIRROR( m_BezierC2.y, aCentre.y );
|
|
|
|
|
2015-07-31 19:04:30 +00:00
|
|
|
MIRROR( m_Start0.y, 0 );
|
|
|
|
MIRROR( m_End0.y, 0 );
|
2018-07-07 11:04:01 +00:00
|
|
|
MIRROR( m_Bezier0_C1.y, 0 );
|
|
|
|
MIRROR( m_Bezier0_C2.y, 0 );
|
|
|
|
RebuildBezierToSegmentsPointsList( m_Width );
|
2014-09-24 16:42:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_POLYGON:
|
|
|
|
// polygon corners coordinates are always relative to the
|
|
|
|
// footprint position, orientation 0
|
2017-10-19 21:16:06 +00:00
|
|
|
for( auto iter = m_Poly.Iterate(); iter; iter++ )
|
|
|
|
{
|
|
|
|
MIRROR( iter->y, 0 );
|
|
|
|
}
|
|
|
|
break;
|
2014-09-24 16:42:56 +00:00
|
|
|
}
|
|
|
|
|
2015-12-27 15:51:13 +00:00
|
|
|
// DRAWSEGMENT items are not usually on copper layers, but
|
|
|
|
// it can happen in microwave apps.
|
|
|
|
// However, currently, only on Front or Back layers.
|
|
|
|
// So the copper layers count is not taken in account
|
2014-09-24 16:42:56 +00:00
|
|
|
SetLayer( FlipLayer( GetLayer() ) );
|
|
|
|
}
|
2015-02-28 17:39:05 +00:00
|
|
|
|
2018-02-17 18:03:22 +00:00
|
|
|
bool EDGE_MODULE::IsParentFlipped() const
|
|
|
|
{
|
|
|
|
if( GetParent() && GetParent()->GetLayer() == B_Cu )
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
2015-07-31 19:04:30 +00:00
|
|
|
|
|
|
|
void EDGE_MODULE::Mirror( wxPoint aCentre, bool aMirrorAroundXAxis )
|
|
|
|
{
|
|
|
|
// Mirror an edge of the footprint. the layer is not modified
|
|
|
|
// This is a footprint shape modification.
|
|
|
|
switch( GetShape() )
|
|
|
|
{
|
|
|
|
case S_ARC:
|
|
|
|
SetAngle( -GetAngle() );
|
|
|
|
//Fall through
|
|
|
|
default:
|
2018-07-07 11:04:01 +00:00
|
|
|
case S_CURVE:
|
2015-07-31 19:04:30 +00:00
|
|
|
case S_SEGMENT:
|
|
|
|
if( aMirrorAroundXAxis )
|
|
|
|
{
|
|
|
|
MIRROR( m_Start0.y, aCentre.y );
|
|
|
|
MIRROR( m_End0.y, aCentre.y );
|
2018-07-07 11:04:01 +00:00
|
|
|
MIRROR( m_Bezier0_C1.y, aCentre.y );
|
|
|
|
MIRROR( m_Bezier0_C2.y, aCentre.y );
|
2015-07-31 19:04:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MIRROR( m_Start0.x, aCentre.x );
|
|
|
|
MIRROR( m_End0.x, aCentre.x );
|
2018-07-07 11:04:01 +00:00
|
|
|
MIRROR( m_Bezier0_C1.x, aCentre.x );
|
|
|
|
MIRROR( m_Bezier0_C2.x, aCentre.x );
|
2015-07-31 19:04:30 +00:00
|
|
|
}
|
2018-07-07 11:04:01 +00:00
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < m_BezierPoints.size(); ii++ )
|
|
|
|
{
|
|
|
|
if( aMirrorAroundXAxis )
|
|
|
|
MIRROR( m_BezierPoints[ii].y, aCentre.y );
|
|
|
|
else
|
|
|
|
MIRROR( m_BezierPoints[ii].x, aCentre.x );
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2015-07-31 19:04:30 +00:00
|
|
|
|
|
|
|
case S_POLYGON:
|
|
|
|
// polygon corners coordinates are always relative to the
|
|
|
|
// footprint position, orientation 0
|
2017-10-19 21:16:06 +00:00
|
|
|
for( auto iter = m_Poly.Iterate(); iter; iter++ )
|
2015-07-31 19:04:30 +00:00
|
|
|
{
|
|
|
|
if( aMirrorAroundXAxis )
|
2017-10-19 21:16:06 +00:00
|
|
|
MIRROR( iter->y, aCentre.y );
|
2015-07-31 19:04:30 +00:00
|
|
|
else
|
2017-10-19 21:16:06 +00:00
|
|
|
MIRROR( iter->x, aCentre.x );
|
2015-07-31 19:04:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SetDrawCoord();
|
|
|
|
}
|
|
|
|
|
2015-02-28 17:39:05 +00:00
|
|
|
void EDGE_MODULE::Rotate( const wxPoint& aRotCentre, double aAngle )
|
|
|
|
{
|
2015-07-31 19:04:30 +00:00
|
|
|
// We should rotate the relative coordinates, but to avoid duplicate code,
|
|
|
|
// do the base class rotation of draw coordinates, which is acceptable
|
|
|
|
// because in module editor, m_Pos0 = m_Pos
|
2015-02-28 17:39:05 +00:00
|
|
|
DRAWSEGMENT::Rotate( aRotCentre, aAngle );
|
|
|
|
|
2015-07-31 19:04:30 +00:00
|
|
|
// and now update the relative coordinates, which are
|
|
|
|
// the reference in most transforms.
|
2015-02-28 17:39:05 +00:00
|
|
|
SetLocalCoord();
|
|
|
|
}
|
2015-07-31 19:04:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
void EDGE_MODULE::Move( const wxPoint& aMoveVector )
|
|
|
|
{
|
|
|
|
// Move an edge of the footprint.
|
|
|
|
// This is a footprint shape modification.
|
|
|
|
m_Start0 += aMoveVector;
|
|
|
|
m_End0 += aMoveVector;
|
2018-07-07 11:04:01 +00:00
|
|
|
m_Bezier0_C1 += aMoveVector;
|
|
|
|
m_Bezier0_C2 += aMoveVector;
|
2015-07-31 19:04:30 +00:00
|
|
|
|
|
|
|
switch( GetShape() )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case S_POLYGON:
|
|
|
|
// polygon corners coordinates are always relative to the
|
|
|
|
// footprint position, orientation 0
|
2017-10-19 21:16:06 +00:00
|
|
|
for( auto iter = m_Poly.Iterate(); iter; iter++ )
|
|
|
|
*iter += VECTOR2I( aMoveVector );
|
2018-07-22 12:50:35 +00:00
|
|
|
|
|
|
|
break;
|
2015-07-31 19:04:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SetDrawCoord();
|
|
|
|
}
|
2018-02-17 18:03:22 +00:00
|
|
|
|
|
|
|
unsigned int EDGE_MODULE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
|
|
|
|
{
|
|
|
|
const int HIDE = std::numeric_limits<unsigned int>::max();
|
|
|
|
|
|
|
|
if( !aView )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// Handle Render tab switches
|
|
|
|
if( !IsParentFlipped() && !aView->IsLayerVisible( LAYER_MOD_FR ) )
|
|
|
|
return HIDE;
|
|
|
|
|
|
|
|
if( IsParentFlipped() && !aView->IsLayerVisible( LAYER_MOD_BK ) )
|
|
|
|
return HIDE;
|
|
|
|
|
|
|
|
// Other layers are shown without any conditions
|
|
|
|
return 0;
|
|
|
|
}
|