2012-01-14 19:50:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
2019-05-17 00:13:21 +00:00
|
|
|
* Copyright (C) 1992-2020 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-14 20:04:58 +00:00
|
|
|
/**
|
|
|
|
* @file class_track.h
|
|
|
|
* @brief Definitions for tracks, vias and zones.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#ifndef CLASS_TRACK_H
|
|
|
|
#define CLASS_TRACK_H
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2018-02-02 20:57:12 +00:00
|
|
|
#include <board_connected_item.h>
|
2019-05-14 12:39:34 +00:00
|
|
|
#include <class_board_item.h>
|
|
|
|
#include <convert_to_biu.h>
|
2017-10-30 17:21:07 +00:00
|
|
|
#include <pcb_display_options.h>
|
2019-05-14 12:39:34 +00:00
|
|
|
#include <pcbnew.h>
|
2017-10-30 17:21:07 +00:00
|
|
|
|
2019-05-31 02:30:28 +00:00
|
|
|
#include <geometry/seg.h>
|
2019-05-17 00:13:21 +00:00
|
|
|
#include <geometry/shape_arc.h>
|
2019-05-31 02:30:28 +00:00
|
|
|
|
2013-05-01 17:32:36 +00:00
|
|
|
#include <trigo.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
class TRACK;
|
2014-04-25 06:00:04 +00:00
|
|
|
class VIA;
|
2011-11-30 11:45:49 +00:00
|
|
|
class D_PAD;
|
2013-01-12 17:32:24 +00:00
|
|
|
class MSG_PANEL_ITEM;
|
2017-10-30 17:21:07 +00:00
|
|
|
class SHAPE_POLY_SET;
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2019-03-31 09:37:57 +00:00
|
|
|
|
|
|
|
// Flag used in locate routines (from which endpoint work)
|
2019-05-17 00:13:21 +00:00
|
|
|
enum ENDPOINT_T : int
|
|
|
|
{
|
2019-03-31 09:37:57 +00:00
|
|
|
ENDPOINT_START = 0,
|
|
|
|
ENDPOINT_END = 1
|
|
|
|
};
|
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
// Via types
|
2017-03-13 03:19:33 +00:00
|
|
|
// Note that this enum must be synchronized to GAL_LAYER_ID
|
2019-05-17 00:13:21 +00:00
|
|
|
enum class VIATYPE : int
|
2014-04-25 06:00:04 +00:00
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
THROUGH = 3, /* Always a through hole via */
|
|
|
|
BLIND_BURIED = 2, /* this via can be on internal layers */
|
|
|
|
MICROVIA = 1, /* this via which connect from an external layer
|
2014-04-25 06:00:04 +00:00
|
|
|
* to the near neighbor internal layer */
|
2019-12-28 00:55:11 +00:00
|
|
|
NOT_DEFINED = 0 /* not yet used */
|
2014-04-25 06:00:04 +00:00
|
|
|
};
|
2012-04-01 20:51:56 +00:00
|
|
|
|
|
|
|
#define UNDEFINED_DRILL_DIAMETER -1 //< Undefined via drill diameter.
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2013-04-09 17:16:53 +00:00
|
|
|
#define MIN_VIA_DRAW_SIZE 4 /// Minimum size in pixel for full drawing
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2018-11-29 18:59:38 +00:00
|
|
|
// Used for tracks and vias for algorithmic safety, not to enforce constraints
|
|
|
|
#define GEOMETRY_MIN_SIZE ( int )( 0.001 * IU_PER_MM )
|
|
|
|
|
|
|
|
|
2008-11-18 18:13:55 +00:00
|
|
|
class TRACK : public BOARD_CONNECTED_ITEM
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-01-12 20:31:56 +00:00
|
|
|
public:
|
2014-06-06 09:44:21 +00:00
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
|
|
|
{
|
2014-06-12 20:03:57 +00:00
|
|
|
return aItem && PCB_TRACE_T == aItem->Type();
|
2014-06-06 09:44:21 +00:00
|
|
|
}
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
TRACK( BOARD_ITEM* aParent, KICAD_T idtype = PCB_TRACE_T );
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2012-01-14 19:50:32 +00:00
|
|
|
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2019-07-12 21:02:10 +00:00
|
|
|
void Move( const wxPoint& aMoveVector ) override
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
|
|
|
m_Start += aMoveVector;
|
2011-12-01 22:50:41 +00:00
|
|
|
m_End += aMoveVector;
|
2009-08-01 19:26:05 +00:00
|
|
|
}
|
|
|
|
|
2019-07-12 21:02:10 +00:00
|
|
|
void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
|
2009-08-01 19:26:05 +00:00
|
|
|
|
2019-07-12 21:02:10 +00:00
|
|
|
void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
|
2009-08-01 19:26:05 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void SetPosition( const wxPoint& aPos ) override { m_Start = aPos; }
|
2017-12-18 17:24:25 +00:00
|
|
|
const wxPoint GetPosition() const override { return m_Start; }
|
2011-11-29 17:25:30 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
void SetWidth( int aWidth ) { m_Width = aWidth; }
|
|
|
|
int GetWidth() const { return m_Width; }
|
2011-11-30 07:43:46 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
void SetEnd( const wxPoint& aEnd ) { m_End = aEnd; }
|
|
|
|
const wxPoint& GetEnd() const { return m_End; }
|
2011-11-29 17:25:30 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
void SetStart( const wxPoint& aStart ) { m_Start = aStart; }
|
|
|
|
const wxPoint& GetStart() const { return m_Start; }
|
2011-11-30 07:43:46 +00:00
|
|
|
|
2014-04-25 17:13:33 +00:00
|
|
|
|
|
|
|
/// Return the selected endpoint (start or end)
|
|
|
|
const wxPoint& GetEndPoint( ENDPOINT_T aEndPoint ) const
|
|
|
|
{
|
|
|
|
if( aEndPoint == ENDPOINT_START )
|
|
|
|
return m_Start;
|
|
|
|
else
|
|
|
|
return m_End;
|
|
|
|
}
|
|
|
|
|
2013-11-24 17:48:14 +00:00
|
|
|
// Virtual function
|
2016-09-24 18:53:15 +00:00
|
|
|
const EDA_RECT GetBoundingBox() const override;
|
2008-03-05 22:39:33 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
bool IsLocked() const override
|
2016-05-10 12:35:36 +00:00
|
|
|
{
|
|
|
|
return GetState( TRACK_LOCKED );
|
|
|
|
}
|
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void SetLocked( bool aLocked ) override
|
2016-05-10 12:35:36 +00:00
|
|
|
{
|
|
|
|
return SetState( TRACK_LOCKED, aLocked );
|
|
|
|
}
|
2016-05-09 08:29:06 +00:00
|
|
|
|
2007-10-13 06:18:44 +00:00
|
|
|
/**
|
|
|
|
* Function GetLength
|
|
|
|
* returns the length of the track using the hypotenuse calculation.
|
|
|
|
* @return double - the length of the track
|
|
|
|
*/
|
2019-03-27 12:38:29 +00:00
|
|
|
virtual double GetLength() const
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2013-05-01 17:32:36 +00:00
|
|
|
return GetLineLength( m_Start, m_End );
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
2007-10-16 19:05:33 +00:00
|
|
|
|
2019-05-31 12:15:25 +00:00
|
|
|
void Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& aOffset = ZeroOffset ) override;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function TransformShapeWithClearanceToPolygon
|
2009-11-14 19:47:52 +00:00
|
|
|
* Convert the track shape to a closed polygon
|
|
|
|
* Used in filling zones calculations
|
|
|
|
* Circles (vias) and arcs (ends of tracks) are approximated by segments
|
|
|
|
* @param aCornerBuffer = a buffer to store the polygon
|
|
|
|
* @param aClearanceValue = the clearance around the pad
|
2019-05-14 12:39:34 +00:00
|
|
|
* @param aError = the maximum deviation from true circle
|
2018-11-14 23:34:32 +00:00
|
|
|
* @param ignoreLineWidth = used for edge cut items where the line width is only
|
|
|
|
* for visualization
|
2009-11-14 19:47:52 +00:00
|
|
|
*/
|
2019-05-14 12:39:34 +00:00
|
|
|
void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, int aClearanceValue,
|
|
|
|
int aError = ARC_HIGH_DEF, bool ignoreLineWidth = false ) const override;
|
2011-09-14 20:04:58 +00:00
|
|
|
/**
|
|
|
|
* Function IsPointOnEnds
|
|
|
|
* returns STARTPOINT if point if near (dist = min_dist) start point, ENDPOINT if
|
|
|
|
* point if near (dist = min_dist) end point,STARTPOINT|ENDPOINT if point if near
|
|
|
|
* (dist = min_dist) both ends, or 0 if none of the above.
|
|
|
|
* if min_dist < 0: min_dist = track_width/2
|
|
|
|
*/
|
2019-05-31 02:30:28 +00:00
|
|
|
STATUS_FLAGS IsPointOnEnds( const wxPoint& point, int min_dist = 0 ) const;
|
2007-10-16 19:05:33 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
/**
|
|
|
|
* Function IsNull
|
|
|
|
* returns true if segment length is zero.
|
|
|
|
*/
|
2019-05-31 02:30:28 +00:00
|
|
|
bool IsNull() const
|
|
|
|
{
|
|
|
|
return ( Type() == PCB_VIA_T ) || ( m_Start == m_End );
|
|
|
|
}
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
void GetMsgPanelInfo( EDA_UNITS aUnits, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
2007-10-16 19:05:33 +00:00
|
|
|
|
2016-07-12 19:05:54 +00:00
|
|
|
SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
2007-10-16 19:05:33 +00:00
|
|
|
|
2019-05-05 10:33:34 +00:00
|
|
|
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
|
|
|
|
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
2011-09-14 20:04:58 +00:00
|
|
|
|
2019-05-31 02:30:28 +00:00
|
|
|
bool ApproxCollinear( const TRACK& aTrack )
|
|
|
|
{
|
|
|
|
SEG a( m_Start, m_End );
|
|
|
|
SEG b( aTrack.GetStart(), aTrack.GetEnd() );
|
|
|
|
return a.ApproxCollinear( b );
|
|
|
|
}
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
wxString GetClass() const override
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2007-10-16 19:05:33 +00:00
|
|
|
return wxT( "TRACK" );
|
2007-08-08 20:51:08 +00:00
|
|
|
}
|
2007-10-16 19:05:33 +00:00
|
|
|
|
2014-06-25 17:01:50 +00:00
|
|
|
/**
|
2010-04-08 11:33:43 +00:00
|
|
|
* Function GetClearance
|
|
|
|
* returns the clearance in internal units. If \a aItem is not NULL then the
|
|
|
|
* returned clearance is the greater of this object's clearance and
|
|
|
|
* aItem's clearance. If \a aItem is NULL, then this objects clearance
|
|
|
|
* is returned.
|
|
|
|
* @param aItem is another BOARD_CONNECTED_ITEM or NULL
|
|
|
|
* @return int - the clearance in internal units.
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual int GetClearance( BOARD_CONNECTED_ITEM* aItem = NULL ) const override;
|
2010-04-08 11:33:43 +00:00
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
virtual wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
2007-10-16 19:05:33 +00:00
|
|
|
|
2017-02-20 12:20:39 +00:00
|
|
|
BITMAP_DEF GetMenuImage() const override;
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual EDA_ITEM* Clone() const override;
|
2012-03-17 14:39:27 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
2013-07-08 07:57:23 +00:00
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
|
2013-07-08 07:57:23 +00:00
|
|
|
|
2018-06-12 08:36:41 +00:00
|
|
|
const BOX2I ViewBBox() const override;
|
|
|
|
|
2017-10-31 13:59:03 +00:00
|
|
|
virtual void SwapData( BOARD_ITEM* aImage ) override;
|
|
|
|
|
2019-07-25 11:08:41 +00:00
|
|
|
/**
|
|
|
|
* @return true because a track or a via is always on a copper layer.
|
|
|
|
*/
|
|
|
|
bool IsOnCopperLayer() const override
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-10-16 19:05:33 +00:00
|
|
|
#if defined (DEBUG)
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
2008-12-04 04:28:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function ShowState
|
|
|
|
* converts a set of state bits to a wxString
|
|
|
|
* @param stateBits Is an OR-ed together set of bits like BUSY, EDIT, etc.
|
|
|
|
*/
|
|
|
|
static wxString ShowState( int stateBits );
|
|
|
|
|
2007-10-16 19:05:33 +00:00
|
|
|
#endif
|
2014-04-25 06:00:04 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Function GetMsgPanelInfoBase
|
|
|
|
* Display info about the track segment only, and does not calculate the full track length
|
|
|
|
* @param aList A list of #MSG_PANEL_ITEM objects to add status information.
|
|
|
|
*/
|
2019-12-20 14:11:39 +00:00
|
|
|
virtual void GetMsgPanelInfoBase( EDA_UNITS aUnits, std::vector<MSG_PANEL_ITEM>& aList );
|
2014-04-25 06:00:04 +00:00
|
|
|
|
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
void GetMsgPanelInfoBase_Common( EDA_UNITS aUnits, std::vector<MSG_PANEL_ITEM>& aList );
|
2014-04-25 06:00:04 +00:00
|
|
|
|
2014-06-06 09:44:21 +00:00
|
|
|
|
|
|
|
int m_Width; ///< Thickness of track, or via diameter
|
|
|
|
wxPoint m_Start; ///< Line start point
|
|
|
|
wxPoint m_End; ///< Line end point
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2019-03-27 12:38:29 +00:00
|
|
|
class ARC : public TRACK
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ARC( BOARD_ITEM* aParent ) : TRACK( aParent, PCB_ARC_T ){};
|
|
|
|
|
2019-05-17 00:13:21 +00:00
|
|
|
ARC( BOARD_ITEM* aParent, const SHAPE_ARC* aArc ) :
|
|
|
|
TRACK( aParent, PCB_ARC_T )
|
|
|
|
{
|
|
|
|
m_Start = wxPoint( aArc->GetP0() );
|
|
|
|
m_End = wxPoint( aArc->GetP1() );
|
|
|
|
m_Mid = wxPoint( aArc->GetArcMid() );
|
|
|
|
}
|
|
|
|
|
2019-03-27 12:38:29 +00:00
|
|
|
static inline bool ClassOf( const EDA_ITEM *aItem )
|
|
|
|
{
|
|
|
|
return aItem && PCB_ARC_T == aItem->Type();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Move( const wxPoint& aMoveVector ) override
|
|
|
|
{
|
|
|
|
m_Start += aMoveVector;
|
|
|
|
m_Mid += aMoveVector;
|
|
|
|
m_End += aMoveVector;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
|
|
|
|
|
|
|
|
virtual void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
|
|
|
|
|
|
|
|
void SetMid( const wxPoint& aMid ) { m_Mid = aMid; }
|
|
|
|
const wxPoint& GetMid() const { return m_Mid; }
|
|
|
|
|
2019-05-17 00:13:21 +00:00
|
|
|
void SetPosition( const wxPoint& aPos ) override
|
|
|
|
{
|
|
|
|
printf("Setting the arc position\n");
|
|
|
|
m_Start = aPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual const wxPoint GetPosition() const override;
|
|
|
|
|
|
|
|
double GetRadius() const;
|
|
|
|
double GetAngle() const;
|
|
|
|
double GetArcAngleStart() const;
|
|
|
|
double GetArcAngleEnd() const;
|
|
|
|
|
2019-03-27 12:38:29 +00:00
|
|
|
virtual bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
|
|
|
|
|
|
|
|
virtual bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const override;
|
|
|
|
|
|
|
|
wxString GetClass() const override
|
|
|
|
{
|
|
|
|
return wxT( "ARC" );
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO(snh): Add GetSelectMenuText() and GetMsgPanelInfoBase()
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetLength
|
2019-05-17 00:13:21 +00:00
|
|
|
* returns the length of the arc track using a series of segment approximations.
|
2019-03-27 12:38:29 +00:00
|
|
|
* @return double - the length of the track
|
|
|
|
*/
|
|
|
|
virtual double GetLength() const override
|
|
|
|
{
|
|
|
|
//TODO(snh): Add proper arc length calc
|
|
|
|
return GetLineLength( m_Start, m_Mid ) + GetLineLength( m_Mid, m_End );
|
|
|
|
}
|
|
|
|
|
|
|
|
EDA_ITEM* Clone() const override;
|
|
|
|
|
|
|
|
virtual void SwapData( BOARD_ITEM* aImage ) override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
private:
|
|
|
|
wxPoint m_Mid; ///< Arc mid point, halfway between start and end
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
class VIA : public TRACK
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-04-25 06:00:04 +00:00
|
|
|
VIA( BOARD_ITEM* aParent );
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2014-06-06 09:44:21 +00:00
|
|
|
static inline bool ClassOf( const EDA_ITEM *aItem )
|
|
|
|
{
|
2014-06-12 20:03:57 +00:00
|
|
|
return aItem && PCB_VIA_T == aItem->Type();
|
2014-06-06 09:44:21 +00:00
|
|
|
}
|
|
|
|
|
2012-01-14 19:50:32 +00:00
|
|
|
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
2007-10-16 19:05:33 +00:00
|
|
|
|
2019-05-31 12:15:25 +00:00
|
|
|
void Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& aOffset = ZeroOffset ) override;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
bool IsOnLayer( PCB_LAYER_ID aLayer ) const override;
|
2007-10-16 19:05:33 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual LSET GetLayerSet() const override;
|
2014-04-25 06:00:04 +00:00
|
|
|
|
2011-09-14 20:04:58 +00:00
|
|
|
/**
|
|
|
|
* Function SetLayerPair
|
2014-04-25 08:03:50 +00:00
|
|
|
* For a via m_Layer contains the top layer, the other layer is in
|
|
|
|
* m_BottomLayer
|
2014-11-02 16:25:04 +00:00
|
|
|
* @param aTopLayer = first layer connected by the via
|
|
|
|
* @param aBottomLayer = last layer connected by the via
|
2011-09-14 20:04:58 +00:00
|
|
|
*/
|
2017-03-13 03:19:33 +00:00
|
|
|
void SetLayerPair( PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer );
|
2011-09-14 20:04:58 +00:00
|
|
|
|
2018-01-06 22:32:22 +00:00
|
|
|
void SetBottomLayer( PCB_LAYER_ID aLayer );
|
|
|
|
void SetTopLayer( PCB_LAYER_ID aLayer );
|
|
|
|
|
2011-09-14 20:04:58 +00:00
|
|
|
/**
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
* Function LayerPair
|
2011-09-14 20:04:58 +00:00
|
|
|
* Return the 2 layers used by the via (the via actually uses
|
|
|
|
* all layers between these 2 layers)
|
|
|
|
* @param top_layer = pointer to the first layer (can be null)
|
|
|
|
* @param bottom_layer = pointer to the last layer (can be null)
|
|
|
|
*/
|
2017-03-13 03:19:33 +00:00
|
|
|
void LayerPair( PCB_LAYER_ID* top_layer, PCB_LAYER_ID* bottom_layer ) const;
|
2007-10-16 19:05:33 +00:00
|
|
|
|
2018-01-06 22:32:22 +00:00
|
|
|
PCB_LAYER_ID TopLayer() const;
|
|
|
|
PCB_LAYER_ID BottomLayer() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SanitizeLayers
|
|
|
|
* Check so that the layers are correct dependin on the type of via, and
|
|
|
|
* so that the top actually is on top.
|
|
|
|
*/
|
|
|
|
void SanitizeLayers();
|
|
|
|
|
2017-12-18 17:24:25 +00:00
|
|
|
const wxPoint GetPosition() const override { return m_Start; }
|
2016-09-24 18:53:15 +00:00
|
|
|
void SetPosition( const wxPoint& aPoint ) override { m_Start = aPoint; m_End = aPoint; }
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2019-05-05 10:33:34 +00:00
|
|
|
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
|
|
|
|
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
2014-05-01 06:50:11 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
wxString GetClass() const override
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2007-10-16 19:05:33 +00:00
|
|
|
return wxT( "VIA" );
|
2007-08-08 20:51:08 +00:00
|
|
|
}
|
2007-10-01 04:14:29 +00:00
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
2011-07-14 15:42:44 +00:00
|
|
|
|
2017-02-20 12:20:39 +00:00
|
|
|
BITMAP_DEF GetMenuImage() const override;
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
EDA_ITEM* Clone() const override;
|
2012-03-17 14:39:27 +00:00
|
|
|
|
2019-07-12 21:02:10 +00:00
|
|
|
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2019-07-12 21:02:10 +00:00
|
|
|
unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
|
2017-04-20 16:19:41 +00:00
|
|
|
|
2019-07-12 21:02:10 +00:00
|
|
|
void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
|
2014-04-30 19:16:22 +00:00
|
|
|
|
2007-10-16 19:05:33 +00:00
|
|
|
#if defined (DEBUG)
|
2019-07-12 21:02:10 +00:00
|
|
|
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
2007-10-16 19:05:33 +00:00
|
|
|
#endif
|
2014-04-25 06:00:04 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
VIATYPE GetViaType() const
|
|
|
|
{
|
|
|
|
return m_ViaType;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetViaType( VIATYPE aViaType )
|
|
|
|
{
|
|
|
|
m_ViaType = aViaType;
|
|
|
|
}
|
2014-04-25 06:00:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetDrill
|
|
|
|
* sets the drill value for vias.
|
|
|
|
* @param aDrill is the new drill diameter
|
|
|
|
*/
|
|
|
|
void SetDrill( int aDrill ) { m_Drill = aDrill; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetDrill
|
|
|
|
* returns the local drill setting for this VIA. If you want the calculated value,
|
|
|
|
* use GetDrillValue() instead.
|
|
|
|
*/
|
|
|
|
int GetDrill() const { return m_Drill; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetDrillValue
|
|
|
|
* "calculates" the drill value for vias (m-Drill if > 0, or default
|
|
|
|
* drill value for the board.
|
|
|
|
* @return real drill_value
|
|
|
|
*/
|
|
|
|
int GetDrillValue() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetDrillDefault
|
|
|
|
* sets the drill value for vias to the default value #UNDEFINED_DRILL_DIAMETER.
|
|
|
|
*/
|
|
|
|
void SetDrillDefault() { m_Drill = UNDEFINED_DRILL_DIAMETER; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function IsDrillDefault
|
|
|
|
* @return true if the drill value is default value (-1)
|
|
|
|
*/
|
|
|
|
bool IsDrillDefault() const { return m_Drill <= 0; }
|
|
|
|
|
2017-10-31 13:59:03 +00:00
|
|
|
virtual void SwapData( BOARD_ITEM* aImage ) override;
|
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
protected:
|
2019-12-20 14:11:39 +00:00
|
|
|
void GetMsgPanelInfoBase( EDA_UNITS aUnits, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
2014-04-25 06:00:04 +00:00
|
|
|
|
|
|
|
private:
|
2014-04-25 08:03:50 +00:00
|
|
|
/// The bottom layer of the via (the top layer is in m_Layer)
|
2019-12-28 00:55:11 +00:00
|
|
|
PCB_LAYER_ID m_BottomLayer;
|
2014-04-25 08:03:50 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
VIATYPE m_ViaType; // Type of via
|
2014-04-25 06:00:04 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
int m_Drill; // for vias: via drill (- 1 for default value)
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
#endif // CLASS_TRACK_H
|