Push most of PCB_SHAPE impl down in to EDA_SHAPE.
This commit is contained in:
parent
672b27f91a
commit
a41944020d
|
@ -734,7 +734,7 @@ void BOARD_ADAPTER::addShapeWithClearance( const PCB_SHAPE* aShape,
|
|||
|
||||
default:
|
||||
wxFAIL_MSG( "BOARD_ADAPTER::addShapeWithClearance no implementation for "
|
||||
+ SHAPE_T_asString( aShape->GetShape()) );
|
||||
+ aShape->SHAPE_T_asString() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -502,6 +502,7 @@ target_include_directories( common PUBLIC
|
|||
set( PCB_COMMON_SRCS
|
||||
base_screen.cpp
|
||||
eda_text.cpp
|
||||
eda_shape.cpp
|
||||
fp_lib_table.cpp
|
||||
hash_eda.cpp
|
||||
page_info.cpp
|
||||
|
@ -533,7 +534,7 @@ set( PCB_COMMON_SRCS
|
|||
${CMAKE_SOURCE_DIR}/pcbnew/connectivity/connectivity_items.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/connectivity/connectivity_data.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/connectivity/from_to_cache.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/convert_drawsegment_list_to_polygon.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/convert_shape_list_to_polygon.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/drc/drc_engine.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/drc/drc_item.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/drc/drc_rule.cpp
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -649,6 +649,25 @@ double EDA_TEXT::GetDrawRotation() const
|
|||
}
|
||||
|
||||
|
||||
int EDA_TEXT::Compare( const EDA_TEXT* aOther ) const
|
||||
{
|
||||
#define TEST( a, b ) { if( a != b ) return a < b; }
|
||||
#define TEST_PT( a, b ) { TEST( a.x, b.x ); TEST( a.y, b.y ); }
|
||||
|
||||
TEST_PT( m_e.pos, aOther->m_e.pos );
|
||||
|
||||
TEST_PT( m_e.size, aOther->m_e.size );
|
||||
TEST( m_e.penwidth, aOther->m_e.penwidth );
|
||||
TEST( m_e.angle, aOther->m_e.angle );
|
||||
|
||||
TEST( m_e.hjustify, aOther->m_e.hjustify );
|
||||
TEST( m_e.vjustify, aOther->m_e.vjustify );
|
||||
TEST( m_e.bits, aOther->m_e.bits );
|
||||
|
||||
return m_text.Cmp( aOther->m_text );
|
||||
}
|
||||
|
||||
|
||||
static struct EDA_TEXT_DESC
|
||||
{
|
||||
EDA_TEXT_DESC()
|
||||
|
|
|
@ -40,37 +40,6 @@ class PCB_BASE_FRAME;
|
|||
class SHAPE;
|
||||
class PCB_GROUP;
|
||||
|
||||
/**
|
||||
* The set of shapes for PCB graphics and tracks and footprint graphics in the .m_Shape member
|
||||
*/
|
||||
enum class SHAPE_T : int
|
||||
{
|
||||
SEGMENT = 0, ///< usual segment : line with rounded ends
|
||||
RECT, ///< segment with non rounded ends
|
||||
ARC, ///< Arcs (with rounded ends)
|
||||
CIRCLE, ///< ring
|
||||
POLY, ///< polygon (not yet used for tracks, but could be in microwave apps)
|
||||
BEZIER, ///< Bezier Curve
|
||||
LAST ///< last value for this list
|
||||
};
|
||||
|
||||
static inline wxString SHAPE_T_asString( SHAPE_T a )
|
||||
{
|
||||
switch( a )
|
||||
{
|
||||
case SHAPE_T::SEGMENT: return "S_SEGMENT";
|
||||
case SHAPE_T::RECT: return "S_RECT";
|
||||
case SHAPE_T::ARC: return "S_ARC";
|
||||
case SHAPE_T::CIRCLE: return "S_CIRCLE";
|
||||
case SHAPE_T::POLY: return "S_POLYGON";
|
||||
case SHAPE_T::BEZIER: return "S_CURVE";
|
||||
case SHAPE_T::LAST: return "S_LAST"; // Synthetic value, but if we come across it we're
|
||||
// going to want to know.
|
||||
}
|
||||
|
||||
return wxEmptyString; // Just to quiet GCC.
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A base class for any item which can be embedded within the #BOARD container class, and
|
||||
|
@ -259,11 +228,6 @@ public:
|
|||
*/
|
||||
void DeleteStructure();
|
||||
|
||||
/**
|
||||
* Convert the enum #PCB_SHAPE_TYPE_T integer value to a wxString.
|
||||
*/
|
||||
static wxString ShowShape( SHAPE_T aShape );
|
||||
|
||||
/**
|
||||
* Move this object.
|
||||
*
|
||||
|
@ -271,8 +235,7 @@ public:
|
|||
*/
|
||||
virtual void Move( const wxPoint& aMoveVector )
|
||||
{
|
||||
wxFAIL_MSG( wxString::Format( wxT( "virtual BOARD_ITEM::Move called for %s" ),
|
||||
GetClass() ) );
|
||||
wxFAIL_MSG( "virtual BOARD_ITEM::Move called for " + GetClass() );
|
||||
}
|
||||
|
||||
void Move( const VECTOR2I& aMoveVector )
|
||||
|
|
|
@ -0,0 +1,316 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2018 Jean-Pierre Charras jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef EDA_SHAPE_H
|
||||
#define EDA_SHAPE_H
|
||||
|
||||
#include <eda_units.h>
|
||||
#include <convert_to_biu.h>
|
||||
#include <math_for_graphics.h>
|
||||
#include <trigo.h>
|
||||
#include <geometry/shape_poly_set.h>
|
||||
#include <geometry/geometry_utils.h>
|
||||
|
||||
class LINE_READER;
|
||||
class EDA_DRAW_FRAME;
|
||||
class FOOTPRINT;
|
||||
class MSG_PANEL_ITEM;
|
||||
|
||||
|
||||
enum class SHAPE_T : int
|
||||
{
|
||||
SEGMENT = 0,
|
||||
RECT,
|
||||
ARC,
|
||||
CIRCLE,
|
||||
POLY,
|
||||
BEZIER,
|
||||
LAST ///< marker for list end
|
||||
};
|
||||
|
||||
|
||||
class EDA_SHAPE
|
||||
{
|
||||
public:
|
||||
EDA_SHAPE( SHAPE_T aType, int aDefaultLineWidth );
|
||||
|
||||
// Do not create a copy constructor & operator=.
|
||||
// The ones generated by the compiler are adequate.
|
||||
|
||||
~EDA_SHAPE();
|
||||
|
||||
void SwapShape( EDA_SHAPE* aImage );
|
||||
|
||||
wxString ShowShape() const;
|
||||
|
||||
wxString SHAPE_T_asString() const;
|
||||
|
||||
void SetFilled( bool aFlag ) { m_filled = aFlag; }
|
||||
|
||||
bool IsFilled() const
|
||||
{
|
||||
switch( m_shape )
|
||||
{
|
||||
case SHAPE_T::RECT:
|
||||
case SHAPE_T::CIRCLE:
|
||||
case SHAPE_T::POLY:
|
||||
return m_filled;
|
||||
|
||||
case SHAPE_T::SEGMENT:
|
||||
case SHAPE_T::ARC:
|
||||
case SHAPE_T::BEZIER:
|
||||
return false;
|
||||
|
||||
case SHAPE_T::LAST: // Make CLang compiler happy
|
||||
return false;
|
||||
}
|
||||
|
||||
return false; // Make GCC compiler happy
|
||||
}
|
||||
|
||||
void SetWidth( int aWidth ) { m_width = aWidth; }
|
||||
int GetWidth() const { return m_width; }
|
||||
|
||||
/**
|
||||
* Set the angle for arcs, and normalizes it within the range 0 - 360 degrees.
|
||||
*
|
||||
* @param aAngle is tenths of degrees, but will soon be degrees.
|
||||
* @param aUpdateEnd set to true to update also arc end coordinates m_thirdPoint, so must
|
||||
* be called after setting m_Start and m_End.
|
||||
*/
|
||||
virtual void SetAngle( double aAngle, bool aUpdateEnd = true );
|
||||
double GetAngle() const { return m_angle; }
|
||||
|
||||
void SetShape( SHAPE_T aShape ) { m_shape = aShape; }
|
||||
SHAPE_T GetShape() const { return m_shape; }
|
||||
|
||||
void SetBezierC1( const wxPoint& aPoint ) { m_bezierC1 = aPoint; }
|
||||
const wxPoint& GetBezierC1() const { return m_bezierC1; }
|
||||
|
||||
void SetBezierC2( const wxPoint& aPoint ) { m_bezierC2 = aPoint; }
|
||||
const wxPoint& GetBezierC2() const { return m_bezierC2; }
|
||||
|
||||
void SetShapePos( const wxPoint& aPos );
|
||||
wxPoint GetShapePos() const;
|
||||
|
||||
/**
|
||||
* Return the starting point of the graphic.
|
||||
*/
|
||||
const wxPoint& GetStart() const { return m_start; }
|
||||
int GetStartY() { return m_start.y; }
|
||||
int GetStartX() { return m_start.x; }
|
||||
void SetStart( const wxPoint& aStart ) { m_start = aStart; }
|
||||
void SetStartY( int y ) { m_start.y = y; }
|
||||
void SetStartX( int x ) { m_start.x = x; }
|
||||
|
||||
/**
|
||||
* Return the ending point of the graphic.
|
||||
*/
|
||||
const wxPoint& GetEnd() const { return m_end; }
|
||||
int GetEndY() { return m_end.y; }
|
||||
int GetEndX() { return m_end.x; }
|
||||
void SetEnd( const wxPoint& aEnd ) { m_end = aEnd; }
|
||||
void SetEndY( int y ) { m_end.y = y; }
|
||||
void SetEndX( int x ) { m_end.x = x; }
|
||||
|
||||
/**
|
||||
* Function GetThirdPoint
|
||||
* returns the third point point of the graphic
|
||||
*/
|
||||
const wxPoint& GetThirdPoint() const { return m_thirdPoint; }
|
||||
int GetThirdPointY() { return m_thirdPoint.y; }
|
||||
int GetThirdPointX() { return m_thirdPoint.x; }
|
||||
void SetThirdPoint( const wxPoint& aPoint ) { m_thirdPoint = aPoint; }
|
||||
void SetThirdPointY( int y ) { m_thirdPoint.y = y; }
|
||||
void SetThirdPointX( int x ) { m_thirdPoint.x = x; }
|
||||
|
||||
// Some attributes are read only, since they are derived from m_Start, m_End, and m_Angle.
|
||||
// No Set...() function for these attributes.
|
||||
|
||||
wxPoint getCenter() const;
|
||||
wxPoint GetArcStart() const { return m_end; }
|
||||
wxPoint GetArcEnd() const;
|
||||
wxPoint GetArcMid() const;
|
||||
std::vector<wxPoint> GetRectCorners() const;
|
||||
|
||||
/**
|
||||
* @return the angle of the starting point of this arc, between 0 and 3600 in 0.1 deg.
|
||||
*/
|
||||
double GetArcAngleStart() const;
|
||||
|
||||
/**
|
||||
* @return the angle of the ending point of this arc, between 0 and 3600 in 0.1 deg.
|
||||
*/
|
||||
double GetArcAngleEnd() const;
|
||||
|
||||
/**
|
||||
* Return the radius of this item.
|
||||
*
|
||||
* Has meaning only for arcs and circles.
|
||||
*/
|
||||
int GetRadius() const;
|
||||
|
||||
/**
|
||||
* Initialize the start arc point.
|
||||
*
|
||||
* Can be used for circles to initialize one point of the cicumference.
|
||||
*/
|
||||
void SetArcStart( const wxPoint& aArcStartPoint )
|
||||
{
|
||||
m_end = aArcStartPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the end arc point.
|
||||
*
|
||||
* Can be used for circles to initialize one point of the cicumference.
|
||||
*/
|
||||
void SetArcEnd( const wxPoint& aArcEndPoint )
|
||||
{
|
||||
m_thirdPoint = aArcEndPoint;
|
||||
}
|
||||
|
||||
void SetArcCenter( const wxPoint& aCenterPoint ) { m_start = aCenterPoint; }
|
||||
|
||||
/**
|
||||
* Set the three controlling points for an arc.
|
||||
*
|
||||
* NB: these are NOT what's currently stored, so we have to do some calculations behind
|
||||
* the scenes. However, they are what SHOULD be stored.
|
||||
*/
|
||||
void SetArcGeometry( const wxPoint& aStart, const wxPoint& aMid, const wxPoint& aEnd );
|
||||
|
||||
const std::vector<wxPoint>& GetBezierPoints() const { return m_bezierPoints; }
|
||||
|
||||
/**
|
||||
* Duplicate the list of corners in a std::vector<wxPoint>
|
||||
*
|
||||
* It must be used only to convert the SHAPE_POLY_SET internal corner buffer
|
||||
* to a list of wxPoints, and nothing else, because it duplicates the buffer,
|
||||
* that is inefficient to know for instance the corner count
|
||||
*/
|
||||
void DupPolyPointsList( std::vector<wxPoint>& aBuffer ) const;
|
||||
|
||||
/**
|
||||
* @return the number of corners of the polygonal shape
|
||||
*/
|
||||
int GetPointCount() const;
|
||||
|
||||
// Accessors to the polygonal shape
|
||||
SHAPE_POLY_SET& GetPolyShape() { return m_poly; }
|
||||
const SHAPE_POLY_SET& GetPolyShape() const { return m_poly; }
|
||||
|
||||
/**
|
||||
* @return true if the polygonal shape is valid (has more than 2 points)
|
||||
*/
|
||||
bool IsPolyShapeValid() const;
|
||||
|
||||
void SetPolyShape( const SHAPE_POLY_SET& aShape ) { m_poly = aShape; }
|
||||
|
||||
void SetBezierPoints( const std::vector<wxPoint>& aPoints ) { m_bezierPoints = aPoints; }
|
||||
|
||||
/**
|
||||
* Rebuild the m_BezierPoints vertex list that approximate the Bezier curve
|
||||
* by a list of segments.
|
||||
*
|
||||
* Has meaning only for BEZIER shape.
|
||||
*
|
||||
* @param aMinSegLen is the min length of segments approximating the bezier. The shape's last
|
||||
* segment can be shorter. This parameter avoids having too many very short
|
||||
* segment in list. Good values are between m_width/2 and m_width.
|
||||
*/
|
||||
void RebuildBezierToSegmentsPointsList( int aMinSegLen );
|
||||
|
||||
void SetPolyPoints( const std::vector<wxPoint>& aPoints );
|
||||
|
||||
/**
|
||||
* Make a set of SHAPE objects representing the EDA_SHAPE. Caller owns the objects.
|
||||
*/
|
||||
// fixme: move to shape_compound
|
||||
std::vector<SHAPE*> MakeEffectiveShapes() const;
|
||||
|
||||
void ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList );
|
||||
|
||||
/**
|
||||
* Return the length of the track using the hypotenuse calculation.
|
||||
*
|
||||
* @return the length of the track
|
||||
*/
|
||||
double GetLength() const;
|
||||
|
||||
/**
|
||||
* Convert the shape to a closed polygon.
|
||||
*
|
||||
* Used in filling zones calculations. Circles and arcs are approximated by segments.
|
||||
*
|
||||
* @param aCornerBuffer is a buffer to store the polygon.
|
||||
* @param aClearanceValue is the clearance around the pad.
|
||||
* @param aError is the maximum deviation from a true arc.
|
||||
* @param aErrorLoc whether any approximation error shoule be placed inside or outside
|
||||
* @param ignoreLineWidth is used for edge cut items where the line width is only
|
||||
* for visualization
|
||||
*/
|
||||
void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, int aClearanceValue,
|
||||
int aError, ERROR_LOC aErrorLoc,
|
||||
bool ignoreLineWidth ) const;
|
||||
|
||||
int Compare( const EDA_SHAPE* aOther ) const;
|
||||
|
||||
protected:
|
||||
void move( const wxPoint& aMoveVector );
|
||||
void rotate( const wxPoint& aRotCentre, double aAngle );
|
||||
void flip( const wxPoint& aCentre, bool aFlipLeftRight );
|
||||
void scale( double aScale );
|
||||
|
||||
// To be implemented by concrete classes
|
||||
virtual double getParentOrientation() const = 0;
|
||||
virtual wxPoint getParentPosition() const = 0;
|
||||
|
||||
const EDA_RECT getBoundingBox() const;
|
||||
|
||||
void computeArcBBox( EDA_RECT& aBBox ) const;
|
||||
|
||||
bool hitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const;
|
||||
bool hitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const;
|
||||
|
||||
const std::vector<wxPoint> buildBezierToSegmentsPointsList( int aMinSegLen ) const;
|
||||
|
||||
protected:
|
||||
SHAPE_T m_shape; // Shape: line, Circle, Arc
|
||||
int m_width; // thickness of lines ...
|
||||
bool m_filled; // Pretty much what it says on the tin...
|
||||
wxPoint m_start; // Line start point or Circle and Arc center
|
||||
wxPoint m_end; // Line end point or circle and arc start point
|
||||
|
||||
wxPoint m_thirdPoint; // Used only for Arcs: arc end point
|
||||
double m_angle; // Used only for Arcs: Arc angle in 1/10 deg
|
||||
|
||||
wxPoint m_bezierC1; // Bezier Control Point 1
|
||||
wxPoint m_bezierC2; // Bezier Control Point 2
|
||||
|
||||
std::vector<wxPoint> m_bezierPoints;
|
||||
SHAPE_POLY_SET m_poly; // Stores the S_POLYGON shape
|
||||
};
|
||||
|
||||
#endif // EDA_SHAPE_H
|
|
@ -366,6 +366,8 @@ public:
|
|||
|
||||
virtual double GetDrawRotation() const;
|
||||
|
||||
int Compare( const EDA_TEXT* aOther ) const;
|
||||
|
||||
private:
|
||||
void cacheShownText();
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace KIGFX
|
|||
namespace PREVIEW
|
||||
{
|
||||
|
||||
// TODO: required until PCB_SHAPE_TYPE_T is moved into commons or a better approach is found
|
||||
// TODO: required until EDA_SHAPE_TYPE_T is moved into commons or a better approach is found
|
||||
enum class GEOM_SHAPE
|
||||
{
|
||||
SEGMENT = 0,
|
||||
|
|
|
@ -272,7 +272,7 @@ set( PCBNEW_CLASS_SRCS
|
|||
array_pad_number_provider.cpp
|
||||
build_BOM_from_board.cpp
|
||||
cleanup_item.cpp
|
||||
convert_drawsegment_list_to_polygon.cpp
|
||||
convert_shape_list_to_polygon.cpp
|
||||
cross-probing.cpp
|
||||
edit.cpp
|
||||
edit_track_width.cpp
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
#include <pcb_marker.h>
|
||||
#include <pcb_group.h>
|
||||
#include <pcb_target.h>
|
||||
#include <pcb_shape.h>
|
||||
#include <pcb_text.h>
|
||||
#include <core/arraydim.h>
|
||||
#include <core/kicad_algo.h>
|
||||
#include <connectivity/connectivity_data.h>
|
||||
|
@ -50,7 +52,7 @@
|
|||
#include <project/project_local_settings.h>
|
||||
#include <ratsnest/ratsnest_data.h>
|
||||
#include <tool/selection_conditions.h>
|
||||
#include <convert_drawsegment_list_to_polygon.h>
|
||||
#include <convert_shape_list_to_polygon.h>
|
||||
#include <wx/log.h>
|
||||
|
||||
// This is an odd place for this, but CvPcb won't link if it's in board_item.cpp like I first
|
||||
|
@ -2120,3 +2122,52 @@ BOARD::GroupLegalOpsField BOARD::GroupLegalOps( const PCB_SELECTION& selection )
|
|||
|
||||
return legalOps;
|
||||
}
|
||||
|
||||
|
||||
bool BOARD::cmp_items::operator() ( const BOARD_ITEM* a, const BOARD_ITEM* b ) const
|
||||
{
|
||||
if( a->Type() != b->Type() )
|
||||
return a->Type() < b->Type();
|
||||
|
||||
if( a->GetLayer() != b->GetLayer() )
|
||||
return a->GetLayer() < b->GetLayer();
|
||||
|
||||
if( a->GetPosition().x != b->GetPosition().x )
|
||||
return a->GetPosition().x < b->GetPosition().x;
|
||||
|
||||
if( a->GetPosition().y != b->GetPosition().y )
|
||||
return a->GetPosition().y < b->GetPosition().y;
|
||||
|
||||
if( a->m_Uuid != b->m_Uuid ) // shopuld be always the case foer valid boards
|
||||
return a->m_Uuid < b->m_Uuid;
|
||||
|
||||
return a < b;
|
||||
}
|
||||
|
||||
|
||||
bool BOARD::cmp_drawings::operator()( const BOARD_ITEM* aFirst,
|
||||
const BOARD_ITEM* aSecond ) const
|
||||
{
|
||||
if( aFirst->Type() != aSecond->Type() )
|
||||
return aFirst->Type() < aSecond->Type();
|
||||
|
||||
if( aFirst->GetLayer() != aSecond->GetLayer() )
|
||||
return aFirst->GetLayer() < aSecond->GetLayer();
|
||||
|
||||
if( aFirst->Type() == PCB_SHAPE_T )
|
||||
{
|
||||
const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( aFirst );
|
||||
const PCB_SHAPE* other = static_cast<const PCB_SHAPE*>( aSecond );
|
||||
return shape->Compare( other );
|
||||
}
|
||||
else if( aFirst->Type() == PCB_TEXT_T )
|
||||
{
|
||||
const PCB_TEXT* text = static_cast<const PCB_TEXT*>( aFirst );
|
||||
const PCB_TEXT* other = static_cast<const PCB_TEXT*>( aSecond );
|
||||
return text->Compare( other );
|
||||
}
|
||||
|
||||
return aFirst->m_Uuid < aSecond->m_Uuid;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include <board_item_container.h>
|
||||
#include <common.h> // Needed for stl hash extensions
|
||||
#include <convert_drawsegment_list_to_polygon.h> // for OUTLINE_ERROR_HANDLER
|
||||
#include <convert_shape_list_to_polygon.h> // for OUTLINE_ERROR_HANDLER
|
||||
#include <layer_ids.h>
|
||||
#include <netinfo.h>
|
||||
#include <pcb_item_containers.h>
|
||||
|
@ -1073,6 +1073,18 @@ public:
|
|||
*/
|
||||
GroupLegalOpsField GroupLegalOps( const PCB_SELECTION& selection ) const;
|
||||
|
||||
// --------- Item order comparators ---------
|
||||
|
||||
struct cmp_items
|
||||
{
|
||||
bool operator() ( const BOARD_ITEM* aFirst, const BOARD_ITEM* aSecond ) const;
|
||||
};
|
||||
|
||||
struct cmp_drawings
|
||||
{
|
||||
bool operator()( const BOARD_ITEM* aFirst, const BOARD_ITEM* aSecond ) const;
|
||||
};
|
||||
|
||||
// ------------ Run-time caches -------------
|
||||
std::mutex m_CachesMutex;
|
||||
std::map< std::pair<BOARD_ITEM*, BOARD_ITEM*>, bool > m_InsideCourtyardCache;
|
||||
|
|
|
@ -32,21 +32,6 @@
|
|||
#include <pcb_group.h>
|
||||
|
||||
|
||||
wxString BOARD_ITEM::ShowShape( SHAPE_T aShape )
|
||||
{
|
||||
switch( aShape )
|
||||
{
|
||||
case SHAPE_T::SEGMENT: return _( "Line" );
|
||||
case SHAPE_T::RECT: return _( "Rect" );
|
||||
case SHAPE_T::ARC: return _( "Arc" );
|
||||
case SHAPE_T::CIRCLE: return _( "Circle" );
|
||||
case SHAPE_T::BEZIER: return _( "Bezier Curve" );
|
||||
case SHAPE_T::POLY: return _( "Polygon" );
|
||||
default: return wxT( "??" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const BOARD* BOARD_ITEM::GetBoard() const
|
||||
{
|
||||
if( Type() == PCB_T )
|
||||
|
|
|
@ -415,8 +415,8 @@ void PCB_TEXT::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuff
|
|||
}
|
||||
|
||||
|
||||
void PCB_SHAPE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
|
||||
PCB_LAYER_ID aLayer, int aClearanceValue,
|
||||
void EDA_SHAPE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
|
||||
int aClearanceValue,
|
||||
int aError, ERROR_LOC aErrorLoc,
|
||||
bool ignoreLineWidth ) const
|
||||
{
|
||||
|
@ -429,12 +429,12 @@ void PCB_SHAPE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuf
|
|||
case SHAPE_T::CIRCLE:
|
||||
if( IsFilled() )
|
||||
{
|
||||
TransformCircleToPolygon( aCornerBuffer, GetCenter(), GetRadius() + width / 2, aError,
|
||||
TransformCircleToPolygon( aCornerBuffer, getCenter(), GetRadius() + width / 2, aError,
|
||||
aErrorLoc );
|
||||
}
|
||||
else
|
||||
{
|
||||
TransformRingToPolygon( aCornerBuffer, GetCenter(), GetRadius(), width, aError,
|
||||
TransformRingToPolygon( aCornerBuffer, getCenter(), GetRadius(), width, aError,
|
||||
aErrorLoc );
|
||||
}
|
||||
|
||||
|
@ -479,12 +479,8 @@ void PCB_SHAPE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuf
|
|||
break;
|
||||
|
||||
// The polygon is expected to be a simple polygon; not self intersecting, no hole.
|
||||
FOOTPRINT* footprint = GetParentFootprint();
|
||||
double orientation = footprint ? footprint->GetOrientation() : 0.0;
|
||||
wxPoint offset;
|
||||
|
||||
if( footprint )
|
||||
offset = footprint->GetPosition();
|
||||
double orientation = getParentOrientation();
|
||||
wxPoint offset = getParentPosition();
|
||||
|
||||
// Build the polygon with the actual position and orientation:
|
||||
std::vector<wxPoint> poly;
|
||||
|
@ -538,12 +534,22 @@ void PCB_SHAPE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuf
|
|||
|
||||
default:
|
||||
wxFAIL_MSG( "PCB_SHAPE::TransformShapeWithClearanceToPolygon no implementation for "
|
||||
+ SHAPE_T_asString( m_shape ) );
|
||||
+ SHAPE_T_asString() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PCB_SHAPE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
|
||||
PCB_LAYER_ID aLayer, int aClearanceValue,
|
||||
int aError, ERROR_LOC aErrorLoc,
|
||||
bool ignoreLineWidth ) const
|
||||
{
|
||||
EDA_SHAPE::TransformShapeWithClearanceToPolygon( aCornerBuffer, aClearanceValue, aError,
|
||||
aErrorLoc, ignoreLineWidth );
|
||||
}
|
||||
|
||||
|
||||
void PCB_TRACK::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
|
||||
PCB_LAYER_ID aLayer, int aClearanceValue,
|
||||
int aError, ERROR_LOC aErrorLoc,
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include <convert_basic_shapes_to_polygon.h>
|
||||
#include <geometry/shape_poly_set.h>
|
||||
#include <geometry/geometry_utils.h>
|
||||
#include <convert_drawsegment_list_to_polygon.h>
|
||||
#include <convert_shape_list_to_polygon.h>
|
||||
|
||||
#include <wx/log.h>
|
||||
|
||||
|
@ -535,8 +535,8 @@ bool ConvertOutlineToPolygon( std::vector<PCB_SHAPE*>& aSegList, SHAPE_POLY_SET&
|
|||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( "Unsupported PCB_SHAPE type "
|
||||
+ BOARD_ITEM::ShowShape( graphic->GetShape() ) );
|
||||
wxFAIL_MSG( "ConvertOutlineToPolygon not implemented for "
|
||||
+ graphic->SHAPE_T_asString() );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -781,9 +781,8 @@ bool ConvertOutlineToPolygon( std::vector<PCB_SHAPE*>& aSegList, SHAPE_POLY_SET&
|
|||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( "Unsupported PCB_SHAPE type "
|
||||
+ BOARD_ITEM::ShowShape( graphic->GetShape() ) );
|
||||
|
||||
wxFAIL_MSG( "ConvertOutlineToPolygon not implemented for "
|
||||
+ graphic->SHAPE_T_asString() );
|
||||
return false;
|
||||
}
|
||||
|
|
@ -21,12 +21,6 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file convert_drawsegment_list_to_polygon.h
|
||||
* @brief functions to convert a shape built with DRAWSEGMENTS to a polygon.
|
||||
* expecting the shape describes shape similar to a polygon
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
class PCB_SHAPE;
|
|
@ -29,7 +29,7 @@
|
|||
#include <pcb_marker.h>
|
||||
#include <drc/drc_results_provider.h>
|
||||
#include <footprint_edit_frame.h>
|
||||
#include <convert_drawsegment_list_to_polygon.h>
|
||||
#include <convert_shape_list_to_polygon.h>
|
||||
#include <tools/footprint_editor_control.h>
|
||||
|
||||
|
||||
|
|
|
@ -335,7 +335,7 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow()
|
|||
|
||||
if( m_item->GetShape() == SHAPE_T::ARC )
|
||||
{
|
||||
m_item->SetCenter( GetArcCenter( m_item->GetArcStart(), m_item->GetArcEnd(), m_AngleValue ) );
|
||||
m_item->SetArcCenter( GetArcCenter( m_item->GetArcStart(), m_item->GetArcEnd(), m_AngleValue ));
|
||||
m_item->SetAngle( m_AngleValue * 10.0, false );
|
||||
}
|
||||
|
||||
|
@ -408,8 +408,8 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::Validate()
|
|||
break;
|
||||
|
||||
default:
|
||||
wxASSERT_MSG( false, "DIALOG_GRAPHIC_ITEM_PROPERTIES::Validate not implemented for shape"
|
||||
+ PCB_SHAPE::ShowShape( m_item->GetShape() ) );
|
||||
wxFAIL_MSG( "DIALOG_GRAPHIC_ITEM_PROPERTIES::Validate not implemented for shape "
|
||||
+ m_item->SHAPE_T_asString() );
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
#include <view/view.h>
|
||||
#include <geometry/shape_null.h>
|
||||
#include <i18n_utility.h>
|
||||
#include <convert_drawsegment_list_to_polygon.h>
|
||||
#include <convert_shape_list_to_polygon.h>
|
||||
#include <geometry/convex_hull.h>
|
||||
|
||||
FOOTPRINT::FOOTPRINT( BOARD* parent ) :
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include <list>
|
||||
|
||||
#include <zones.h>
|
||||
#include <convert_drawsegment_list_to_polygon.h>
|
||||
#include <convert_shape_list_to_polygon.h>
|
||||
#include <pcb_item_containers.h>
|
||||
#include <fp_text.h>
|
||||
#include <functional>
|
||||
|
|
|
@ -38,10 +38,8 @@
|
|||
|
||||
|
||||
FP_SHAPE::FP_SHAPE( FOOTPRINT* parent, SHAPE_T aShape ) :
|
||||
PCB_SHAPE( parent, PCB_FP_SHAPE_T )
|
||||
PCB_SHAPE( parent, PCB_FP_SHAPE_T, aShape )
|
||||
{
|
||||
m_shape = aShape;
|
||||
m_angle = 0;
|
||||
m_layer = F_SilkS;
|
||||
}
|
||||
|
||||
|
@ -122,7 +120,7 @@ void FP_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_IT
|
|||
wxString FP_SHAPE::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
{
|
||||
return wxString::Format( _( "%s on %s" ),
|
||||
ShowShape( m_shape ),
|
||||
ShowShape(),
|
||||
GetLayerName() );
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ bool GRAPHICS_CLEANER::isNullShape( PCB_SHAPE* aShape )
|
|||
|
||||
default:
|
||||
wxFAIL_MSG( "GRAPHICS_CLEANER::isNullSegment unsupported PCB_SHAPE shape: "
|
||||
+ SHAPE_T_asString( aShape->GetShape()) );
|
||||
+ aShape->SHAPE_T_asString() );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ bool GRAPHICS_CLEANER::areEquivalent( PCB_SHAPE* aShape1, PCB_SHAPE* aShape2 )
|
|||
|
||||
default:
|
||||
wxFAIL_MSG( "GRAPHICS_CLEANER::areEquivalent unsupported PCB_SHAPE shape: "
|
||||
+ SHAPE_T_asString( aShape1->GetShape()) );
|
||||
+ aShape1->SHAPE_T_asString() );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ void GRAPHICS_IMPORTER_PCBNEW::AddCircle( const VECTOR2D& aCenter, double aRadiu
|
|||
circle->SetFilled( aFilled );
|
||||
circle->SetLayer( GetLayer() );
|
||||
circle->SetWidth( MapLineWidth( aWidth ) );
|
||||
circle->SetCenter( MapCoordinate( aCenter ) );
|
||||
circle->SetArcCenter( MapCoordinate( aCenter ));
|
||||
circle->SetArcStart( MapCoordinate( VECTOR2D( aCenter.x + aRadius, aCenter.y ) ) );
|
||||
|
||||
if( circle->Type() == PCB_FP_SHAPE_T )
|
||||
|
@ -99,7 +99,7 @@ void GRAPHICS_IMPORTER_PCBNEW::AddArc( const VECTOR2D& aCenter, const VECTOR2D&
|
|||
arc->SetShape( SHAPE_T::ARC );
|
||||
arc->SetLayer( GetLayer() );
|
||||
arc->SetWidth( MapLineWidth( aWidth ) );
|
||||
arc->SetCenter( MapCoordinate( aCenter) );
|
||||
arc->SetArcCenter( MapCoordinate( aCenter ));
|
||||
arc->SetArcStart( MapCoordinate( aStart ) );
|
||||
arc->SetAngle( aAngle * 10.0 ); // Pcbnew uses the decidegree
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ void PAD::AddPrimitiveArc( const wxPoint& aCenter, const wxPoint& aStart, int aA
|
|||
PCB_SHAPE* item = new PCB_SHAPE();
|
||||
item->SetShape( SHAPE_T::ARC );
|
||||
item->SetFilled( false );
|
||||
item->SetCenter( aCenter );
|
||||
item->SetArcCenter( aCenter );
|
||||
item->SetArcStart( aStart );
|
||||
item->SetAngle( aArcAngle );
|
||||
item->SetWidth( aThickness );
|
||||
|
|
1228
pcbnew/pcb_shape.cpp
1228
pcbnew/pcb_shape.cpp
File diff suppressed because it is too large
Load Diff
|
@ -26,11 +26,7 @@
|
|||
#define PCB_SHAPE_H
|
||||
|
||||
#include <board_item.h>
|
||||
#include <eda_units.h>
|
||||
#include <convert_to_biu.h>
|
||||
#include <math_for_graphics.h>
|
||||
#include <trigo.h>
|
||||
#include <geometry/shape_poly_set.h>
|
||||
#include <eda_shape.h>
|
||||
|
||||
|
||||
class LINE_READER;
|
||||
|
@ -39,10 +35,11 @@ class FOOTPRINT;
|
|||
class MSG_PANEL_ITEM;
|
||||
|
||||
|
||||
class PCB_SHAPE : public BOARD_ITEM
|
||||
class PCB_SHAPE : public BOARD_ITEM, public EDA_SHAPE
|
||||
{
|
||||
public:
|
||||
PCB_SHAPE( BOARD_ITEM* aParent = nullptr, KICAD_T idtype = PCB_SHAPE_T );
|
||||
PCB_SHAPE( BOARD_ITEM* aParent = NULL, KICAD_T idtype = PCB_SHAPE_T,
|
||||
SHAPE_T shapetype = SHAPE_T::SEGMENT );
|
||||
|
||||
// Do not create a copy constructor & operator=.
|
||||
// The ones generated by the compiler are adequate.
|
||||
|
@ -54,6 +51,11 @@ public:
|
|||
return aItem && PCB_SHAPE_T == aItem->Type();
|
||||
}
|
||||
|
||||
wxString GetClass() const override
|
||||
{
|
||||
return wxT( "PCB_SHAPE" );
|
||||
}
|
||||
|
||||
bool IsType( const KICAD_T aScanTypes[] ) const override
|
||||
{
|
||||
if( BOARD_ITEM::IsType( aScanTypes ) )
|
||||
|
@ -70,145 +72,14 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
void SetFilled( bool aFlag ) { m_filled = aFlag; }
|
||||
void SetPosition( const wxPoint& aPos ) override { SetShapePos( aPos ); }
|
||||
wxPoint GetPosition() const override { return GetShapePos(); }
|
||||
|
||||
bool IsFilled() const
|
||||
{
|
||||
switch( m_shape )
|
||||
{
|
||||
case SHAPE_T::RECT:
|
||||
case SHAPE_T::CIRCLE:
|
||||
case SHAPE_T::POLY:
|
||||
return m_filled;
|
||||
|
||||
case SHAPE_T::SEGMENT:
|
||||
case SHAPE_T::ARC:
|
||||
case SHAPE_T::BEZIER:
|
||||
return false;
|
||||
|
||||
case SHAPE_T::LAST: // Make CLang compiler happy
|
||||
return false;
|
||||
}
|
||||
|
||||
return false; // Make GCC compiler happy
|
||||
}
|
||||
|
||||
void SetWidth( int aWidth ) { m_width = aWidth; }
|
||||
int GetWidth() const { return m_width; }
|
||||
wxPoint GetCenter() const override { return getCenter(); }
|
||||
|
||||
/**
|
||||
* Set the angle for arcs, and normalizes it within the range 0 - 360 degrees.
|
||||
*
|
||||
* @param aAngle is tenths of degrees, but will soon be degrees.
|
||||
* @param aUpdateEnd set to true to update also arc end coordinates m_thirdPoint,
|
||||
* so must be called after setting m_Start and m_End.
|
||||
*/
|
||||
virtual void SetAngle( double aAngle, bool aUpdateEnd = true );
|
||||
double GetAngle() const { return m_angle; }
|
||||
|
||||
void SetShape( SHAPE_T aShape ) { m_shape = aShape; }
|
||||
SHAPE_T GetShape() const { return m_shape; }
|
||||
|
||||
void SetBezierC1( const wxPoint& aPoint ) { m_bezierC1 = aPoint; }
|
||||
const wxPoint& GetBezierC1() const { return m_bezierC1; }
|
||||
|
||||
void SetBezierC2( const wxPoint& aPoint ) { m_bezierC2 = aPoint; }
|
||||
const wxPoint& GetBezierC2() const { return m_bezierC2; }
|
||||
|
||||
void SetPosition( const wxPoint& aPos ) override;
|
||||
wxPoint GetPosition() const override;
|
||||
|
||||
/**
|
||||
* Return the starting point of the graphic.
|
||||
*/
|
||||
const wxPoint& GetStart() const { return m_start; }
|
||||
int GetStartY() { return m_start.y; }
|
||||
int GetStartX() { return m_start.x; }
|
||||
void SetStart( const wxPoint& aStart ) { m_start = aStart; }
|
||||
void SetStartY( int y ) { m_start.y = y; }
|
||||
void SetStartX( int x ) { m_start.x = x; }
|
||||
|
||||
/**
|
||||
* Return the ending point of the graphic.
|
||||
*/
|
||||
const wxPoint& GetEnd() const { return m_end; }
|
||||
int GetEndY() { return m_end.y; }
|
||||
int GetEndX() { return m_end.x; }
|
||||
void SetEnd( const wxPoint& aEnd ) { m_end = aEnd; }
|
||||
void SetEndY( int y ) { m_end.y = y; }
|
||||
void SetEndX( int x ) { m_end.x = x; }
|
||||
|
||||
/**
|
||||
* Return the third point of the graphic.
|
||||
*/
|
||||
const wxPoint& GetThirdPoint() const { return m_thirdPoint; }
|
||||
int GetThirdPointY() { return m_thirdPoint.y; }
|
||||
int GetThirdPointX() { return m_thirdPoint.x; }
|
||||
void SetThirdPoint( const wxPoint& aPoint ) { m_thirdPoint = aPoint; }
|
||||
void SetThirdPointY( int y ) { m_thirdPoint.y = y; }
|
||||
void SetThirdPointX( int x ) { m_thirdPoint.x = x; }
|
||||
|
||||
// Some attributes are read only, since they are "calculated" from
|
||||
// m_Start, m_End, and m_Angle.
|
||||
// No Set...() function for these attributes.
|
||||
|
||||
wxPoint GetCenter() const override;
|
||||
wxPoint GetArcStart() const { return m_end; }
|
||||
wxPoint GetArcEnd() const;
|
||||
wxPoint GetArcMid() const;
|
||||
std::vector<wxPoint> GetRectCorners() const;
|
||||
|
||||
/**
|
||||
* @return the angle of the starting point of this arc, between 0 and 3600 in 0.1 deg.
|
||||
*/
|
||||
double GetArcAngleStart() const;
|
||||
|
||||
/**
|
||||
* @return the angle of the ending point of this arc, between 0 and 3600 in 0.1 deg.
|
||||
*/
|
||||
double GetArcAngleEnd() const;
|
||||
|
||||
/**
|
||||
* Return the radius of this item.
|
||||
*
|
||||
* Has meaning only for arcs and circles.
|
||||
*/
|
||||
int GetRadius() const;
|
||||
|
||||
/**
|
||||
* Initialize the start arc point.
|
||||
*
|
||||
* Can be used for circles to initialize one point of the cicumference.
|
||||
*/
|
||||
void SetArcStart( const wxPoint& aArcStartPoint )
|
||||
{
|
||||
m_end = aArcStartPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the end arc point.
|
||||
*
|
||||
* Can be used for circles to initialize one point of the cicumference.
|
||||
*/
|
||||
void SetArcEnd( const wxPoint& aArcEndPoint )
|
||||
{
|
||||
m_thirdPoint = aArcEndPoint;
|
||||
}
|
||||
|
||||
void SetCenter( const wxPoint& aCenterPoint ) { m_start = aCenterPoint; }
|
||||
|
||||
/**
|
||||
* Set the three controlling points for an arc.
|
||||
*
|
||||
* NB: these are NOT what's currently stored, so we have to do some calculations behind
|
||||
* the scenes. However, they are what SHOULD be stored.
|
||||
*/
|
||||
void SetArcGeometry( const wxPoint& aStart, const wxPoint& aMid, const wxPoint& aEnd );
|
||||
|
||||
/**
|
||||
* Allows items to return their visual center rather than their anchor.
|
||||
* For some shapes this is similar to GetPosition, but for polygonal shapes,
|
||||
* the anchor is not suitable (shows nothing): a point on the outline is better
|
||||
* Allows items to return their visual center rather than their anchor. For some shapes this
|
||||
* is similar to GetCenter(), but for unfilled shapes a point on the outline is better.
|
||||
*/
|
||||
const wxPoint GetFocusPosition() const override;
|
||||
|
||||
|
@ -219,77 +90,24 @@ public:
|
|||
*/
|
||||
FOOTPRINT* GetParentFootprint() const;
|
||||
|
||||
// Accessors:
|
||||
const std::vector<wxPoint>& GetBezierPoints() const { return m_bezierPoints; }
|
||||
|
||||
/**
|
||||
* Duplicate the list of corners in a std::vector<wxPoint>
|
||||
*
|
||||
* It must be used only to convert the SHAPE_POLY_SET internal corner buffer
|
||||
* to a list of wxPoints, and nothing else, because it duplicates the buffer,
|
||||
* that is inefficient to know for instance the corner count
|
||||
*/
|
||||
void DupPolyPointsList( std::vector<wxPoint>& aBuffer ) const;
|
||||
|
||||
/**
|
||||
* @return the number of corners of the polygonal shape
|
||||
*/
|
||||
int GetPointCount() const;
|
||||
|
||||
// Accessors to the polygonal shape
|
||||
SHAPE_POLY_SET& GetPolyShape() { return m_poly; }
|
||||
const SHAPE_POLY_SET& GetPolyShape() const { return m_poly; }
|
||||
|
||||
/**
|
||||
* @return true if the polygonal shape is valid (has more than 2 points)
|
||||
*/
|
||||
bool IsPolyShapeValid() const;
|
||||
|
||||
void SetPolyShape( const SHAPE_POLY_SET& aShape ) { m_poly = aShape; }
|
||||
|
||||
void SetBezierPoints( const std::vector<wxPoint>& aPoints )
|
||||
{
|
||||
m_bezierPoints = aPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild the m_BezierPoints vertex list that approximate the Bezier curve
|
||||
* by a list of segments.
|
||||
*
|
||||
* Has meaning only for S_CURVE DRAW_SEGMENT shape.
|
||||
*
|
||||
* @param aMinSegLen is the min length of segments approximating the he. shape last segment
|
||||
* can be shorter. This parameter avoids having too many very short segment in list.
|
||||
* A good value is m_Width/2 to m_Width.
|
||||
*/
|
||||
void RebuildBezierToSegmentsPointsList( int aMinSegLen );
|
||||
|
||||
void SetPolyPoints( const std::vector<wxPoint>& aPoints );
|
||||
|
||||
/**
|
||||
* Make a set of SHAPE objects representing the PCB_SHAPE. Caller owns the objects.
|
||||
*/
|
||||
std::vector<SHAPE*> MakeEffectiveShapes() const; // fixme: move to shape_compound
|
||||
std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER ) const override;
|
||||
|
||||
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
||||
|
||||
const EDA_RECT GetBoundingBox() const override;
|
||||
const EDA_RECT GetBoundingBox() const override { return getBoundingBox(); }
|
||||
|
||||
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
|
||||
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
||||
|
||||
wxString GetClass() const override
|
||||
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override
|
||||
{
|
||||
return wxT( "PCB_SHAPE" );
|
||||
return hitTest( aPosition, aAccuracy );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the length of the track using the hypotenuse calculation.
|
||||
*
|
||||
* @return the length of the track
|
||||
*/
|
||||
double GetLength() const;
|
||||
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override
|
||||
{
|
||||
return hitTest( aRect, aContained, aAccuracy );
|
||||
}
|
||||
|
||||
virtual void Move( const wxPoint& aMoveVector ) override;
|
||||
|
||||
|
@ -300,13 +118,14 @@ public:
|
|||
void Scale( double aScale );
|
||||
|
||||
/**
|
||||
* Convert the draw segment to a closed polygon.
|
||||
* Convert the shape to a closed polygon.
|
||||
*
|
||||
* Used in filling zones calculations. Circles and arcs are approximated by segments.
|
||||
*
|
||||
* @param aCornerBuffer is a buffer to store the polygon.
|
||||
* @param aClearanceValue is the clearance around the pad.
|
||||
* @param aError is the maximum deviation from a true arc.
|
||||
* @param aErrorLoc whether any approximation error shoule be placed inside or outside
|
||||
* @param ignoreLineWidth is used for edge cut items where the line width is only
|
||||
* for visualization
|
||||
*/
|
||||
|
@ -335,24 +154,8 @@ public:
|
|||
#endif
|
||||
|
||||
protected:
|
||||
// Compute the bounding box for an arc
|
||||
void computeArcBBox( EDA_RECT& aBBox ) const;
|
||||
|
||||
const std::vector<wxPoint> buildBezierToSegmentsPointsList( int aMinSegLen ) const;
|
||||
|
||||
int m_width; // thickness of lines ...
|
||||
bool m_filled; // Pretty much what it says on the tin...
|
||||
wxPoint m_start; // Line start point or Circle and Arc center
|
||||
wxPoint m_end; // Line end point or circle and arc start point
|
||||
wxPoint m_thirdPoint; // Used only for Arcs: arc end point
|
||||
|
||||
SHAPE_T m_shape; // Shape: line, Circle, Arc
|
||||
double m_angle; // Used only for Arcs: Arc angle in 1/10 deg
|
||||
wxPoint m_bezierC1; // Bezier Control Point 1
|
||||
wxPoint m_bezierC2; // Bezier Control Point 2
|
||||
|
||||
std::vector<wxPoint> m_bezierPoints;
|
||||
SHAPE_POLY_SET m_poly; // Stores the S_POLYGON shape
|
||||
double getParentOrientation() const override;
|
||||
wxPoint getParentPosition() const override;
|
||||
};
|
||||
|
||||
#endif // PCB_SHAPE_H
|
||||
|
|
|
@ -868,7 +868,7 @@ void ALTIUM_PCB::HelperCreateBoardOutline( const std::vector<ALTIUM_VERTICE>& aV
|
|||
wxPoint arcStartOffset = wxPoint( KiROUND( std::cos( startradiant ) * cur->radius ),
|
||||
-KiROUND( std::sin( startradiant ) * cur->radius ) );
|
||||
wxPoint arcStart = cur->center + arcStartOffset;
|
||||
shape->SetCenter( cur->center );
|
||||
shape->SetArcCenter( cur->center );
|
||||
shape->SetArcStart( arcStart );
|
||||
|
||||
if( !last->isRound )
|
||||
|
@ -1927,7 +1927,7 @@ void ALTIUM_PCB::ParseArcs6Data( const CFB::CompoundFileReader& aReader,
|
|||
{
|
||||
PCB_SHAPE shape( nullptr ); // just a helper to get the graphic
|
||||
shape.SetWidth( elem.width );
|
||||
shape.SetCenter( elem.center );
|
||||
shape.SetArcCenter( elem.center );
|
||||
|
||||
if( elem.startangle == 0. && elem.endangle == 360. )
|
||||
{ // TODO: other variants to define circle?
|
||||
|
@ -2027,7 +2027,7 @@ void ALTIUM_PCB::ParseArcs6Data( const CFB::CompoundFileReader& aReader,
|
|||
else
|
||||
{
|
||||
PCB_SHAPE* shape = HelperCreateAndAddDrawsegment( elem.component );
|
||||
shape->SetCenter( elem.center );
|
||||
shape->SetArcCenter( elem.center );
|
||||
shape->SetWidth( elem.width );
|
||||
shape->SetLayer( klayer );
|
||||
|
||||
|
@ -2367,7 +2367,7 @@ void ALTIUM_PCB::HelperParsePad6NonCopper( const APAD6& aElem )
|
|||
// circle
|
||||
shape->SetShape( SHAPE_T::CIRCLE );
|
||||
shape->SetFilled( true );
|
||||
shape->SetCenter( aElem.position );
|
||||
shape->SetArcCenter( aElem.position );
|
||||
shape->SetWidth( aElem.topsize.x / 2 );
|
||||
shape->SetArcStart( aElem.position - wxPoint( 0, aElem.topsize.x / 4 ) );
|
||||
}
|
||||
|
@ -2400,7 +2400,7 @@ void ALTIUM_PCB::HelperParsePad6NonCopper( const APAD6& aElem )
|
|||
shape->SetShape( SHAPE_T::CIRCLE );
|
||||
shape->SetFilled( true );
|
||||
shape->SetLayer( klayer );
|
||||
shape->SetCenter( aElem.position );
|
||||
shape->SetArcCenter( aElem.position );
|
||||
shape->SetWidth( aElem.topsize.x / 2 );
|
||||
shape->SetArcStart( aElem.position - wxPoint( 0, aElem.topsize.x / 4 ) );
|
||||
HelperDrawsegmentSetLocalCoord( shape, aElem.component );
|
||||
|
|
|
@ -2834,7 +2834,7 @@ PCB_SHAPE* CADSTAR_PCB_ARCHIVE_LOADER::getShapeFromVertex( const POINT& aCadstar
|
|||
}
|
||||
|
||||
shape->SetArcStart( startPoint );
|
||||
shape->SetCenter( centerPoint );
|
||||
shape->SetArcCenter( centerPoint );
|
||||
|
||||
arcStartAngle = getPolarAngle( startPoint - centerPoint );
|
||||
arcEndAngle = getPolarAngle( endPoint - centerPoint );
|
||||
|
|
|
@ -2120,14 +2120,14 @@ bool FABMASTER::loadFootprints( BOARD* aBoard )
|
|||
if( src->mirror )
|
||||
{
|
||||
arc->SetLayer( FlipLayer( layer ) );
|
||||
arc->SetCenter( wxPoint( lsrc->center_x, 2 * src->y - lsrc->center_y ) );
|
||||
arc->SetArcCenter( wxPoint( lsrc->center_x, 2 * src->y - lsrc->center_y ));
|
||||
arc->SetArcStart( wxPoint( lsrc->end_x, 2 * src->y - lsrc->end_y ) );
|
||||
arc->SetAngle( lsrc->result.GetCentralAngle() * 10.0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
arc->SetLayer( layer );
|
||||
arc->SetCenter( wxPoint( lsrc->center_x, lsrc->center_y ) );
|
||||
arc->SetArcCenter( wxPoint( lsrc->center_x, lsrc->center_y ));
|
||||
arc->SetArcStart( wxPoint( lsrc->end_x, lsrc->end_y ) );
|
||||
arc->SetAngle( -lsrc->result.GetCentralAngle() * 10.0 );
|
||||
}
|
||||
|
@ -2775,7 +2775,7 @@ bool FABMASTER::loadOutline( BOARD* aBoard, const std::unique_ptr<FABMASTER::TRA
|
|||
PCB_SHAPE* arc = new PCB_SHAPE( aBoard );
|
||||
arc->SetShape( SHAPE_T::ARC );
|
||||
arc->SetLayer( layer );
|
||||
arc->SetCenter( wxPoint( src->center_x, src->center_y ) );
|
||||
arc->SetArcCenter( wxPoint( src->center_x, src->center_y ));
|
||||
arc->SetArcStart( wxPoint( src->start_x, src->start_y ) );
|
||||
arc->SetAngle( src->result.GetCentralAngle() * 10.0 );
|
||||
arc->SetWidth( src->width );
|
||||
|
@ -2896,7 +2896,7 @@ bool FABMASTER::loadGraphics( BOARD* aBoard )
|
|||
PCB_SHAPE* arc = new PCB_SHAPE( aBoard );
|
||||
arc->SetShape( SHAPE_T::ARC );
|
||||
arc->SetLayer( layer );
|
||||
arc->SetCenter( wxPoint( src->center_x, src->center_y ) );
|
||||
arc->SetArcCenter( wxPoint( src->center_x, src->center_y ));
|
||||
arc->SetArcStart( wxPoint( src->start_x, src->start_y ) );
|
||||
arc->SetAngle( src->result.GetCentralAngle() * 10.0 );
|
||||
arc->SetWidth( src->width );
|
||||
|
|
|
@ -906,7 +906,7 @@ void PCB_IO::format( const PCB_SHAPE* aShape, int aNestLevel ) const
|
|||
|
||||
default:
|
||||
wxFAIL_MSG( "PCB_IO::format cannot format unknown PCB_SHAPE shape:"
|
||||
+ SHAPE_T_asString( aShape->GetShape()) );
|
||||
+ aShape->SHAPE_T_asString() );
|
||||
return;
|
||||
};
|
||||
|
||||
|
@ -1040,7 +1040,7 @@ void PCB_IO::format( const FP_SHAPE* aFPShape, int aNestLevel ) const
|
|||
|
||||
default:
|
||||
wxFAIL_MSG( "PCB_IO::format cannot format unknown FP_SHAPE shape:"
|
||||
+ SHAPE_T_asString( aFPShape->GetShape()) );
|
||||
+ aFPShape->SHAPE_T_asString() );
|
||||
return;
|
||||
};
|
||||
|
||||
|
|
|
@ -2392,7 +2392,7 @@ PCB_SHAPE* PCB_PARSER::parsePCB_SHAPE()
|
|||
|
||||
pt.x = parseBoardUnits( "X coordinate" );
|
||||
pt.y = parseBoardUnits( "Y coordinate" );
|
||||
shape->SetCenter( pt );
|
||||
shape->SetArcCenter( pt );
|
||||
NeedRIGHT();
|
||||
NeedLEFT();
|
||||
token = NextTok();
|
||||
|
@ -2426,7 +2426,7 @@ PCB_SHAPE* PCB_PARSER::parsePCB_SHAPE()
|
|||
|
||||
pt.x = parseBoardUnits( "X coordinate" );
|
||||
pt.y = parseBoardUnits( "Y coordinate" );
|
||||
shape->SetCenter( pt );
|
||||
shape->SetArcCenter( pt );
|
||||
NeedRIGHT();
|
||||
NeedLEFT();
|
||||
|
||||
|
|
|
@ -32,28 +32,8 @@
|
|||
%include board_item.h // generate code for this interface
|
||||
%include eda_item_flags.h // generate code for this interface
|
||||
|
||||
/* Only for compatibility with old python scripts: */
|
||||
const int S_SEGMENT = (const int)SHAPE_T::SEGMENT;
|
||||
const int S_RECT = (const int)SHAPE_T::RECT;
|
||||
const int S_ARC = (const int)SHAPE_T::ARC;
|
||||
const int S_CIRCLE = (const int)SHAPE_T::CIRCLE;
|
||||
const int S_POLYGON = (const int)SHAPE_T::POLY;
|
||||
const int S_CURVE = (const int)SHAPE_T::BEZIER;
|
||||
|
||||
%rename(Get) operator BOARD_ITEM*;
|
||||
|
||||
%{
|
||||
#include <board_item.h>
|
||||
/* for compatibility with old python scripts: */
|
||||
const int S_SEGMENT = (const int)SHAPE_T::SEGMENT;
|
||||
const int S_RECT = (const int)SHAPE_T::RECT;
|
||||
const int S_ARC = (const int)SHAPE_T::ARC;
|
||||
const int S_CIRCLE = (const int)SHAPE_T::CIRCLE;
|
||||
const int S_POLYGON = (const int)SHAPE_T::POLY;
|
||||
const int S_CURVE = (const int)SHAPE_T::BEZIER;
|
||||
%}
|
||||
|
||||
|
||||
%inline
|
||||
{
|
||||
/// Cast down from EDA_ITEM/BOARD_ITEM to child
|
||||
|
|
|
@ -814,7 +814,7 @@ int CONVERT_TOOL::SegmentToArc( const TOOL_EVENT& aEvent )
|
|||
arc->SetLayer( layer );
|
||||
arc->SetWidth( line->GetWidth() );
|
||||
|
||||
arc->SetCenter( wxPoint( center ) );
|
||||
arc->SetArcCenter( wxPoint( center ));
|
||||
arc->SetArcStart( wxPoint( start ) );
|
||||
arc->SetAngle( GetArcAngle( start, mid, end ) );
|
||||
|
||||
|
|
|
@ -1418,7 +1418,7 @@ bool DRAWING_TOOL::drawSegment( const std::string& aTool, PCB_SHAPE** aGraphic,
|
|||
KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPointManager;
|
||||
|
||||
// drawing assistant overlay
|
||||
// TODO: workaround because PCB_SHAPE_TYPE_T is not visible from commons.
|
||||
// TODO: workaround because EDA_SHAPE_TYPE_T is not visible from commons.
|
||||
KIGFX::PREVIEW::GEOM_SHAPE geomShape( static_cast<KIGFX::PREVIEW::GEOM_SHAPE>( shape ) );
|
||||
KIGFX::PREVIEW::TWO_POINT_ASSISTANT twoPointAsst( twoPointManager, userUnits, geomShape );
|
||||
|
||||
|
@ -1716,7 +1716,7 @@ static void updateArcFromConstructionMgr( const KIGFX::PREVIEW::ARC_GEOM_MANAGER
|
|||
{
|
||||
auto vec = aMgr.GetOrigin();
|
||||
|
||||
aArc.SetCenter( { vec.x, vec.y } );
|
||||
aArc.SetArcCenter( { vec.x, vec.y } );
|
||||
|
||||
vec = aMgr.GetStartRadiusEnd();
|
||||
aArc.SetArcStart( { vec.x, vec.y } );
|
||||
|
|
|
@ -760,7 +760,7 @@ void PCB_POINT_EDITOR::editArcEndpointKeepTangent( PCB_SHAPE* aArc, const VECTOR
|
|||
if( arcValid )
|
||||
{
|
||||
aArc->SetAngle( newAngle, false );
|
||||
aArc->SetCenter( ( wxPoint ) center );
|
||||
aArc->SetArcCenter( ( wxPoint ) center );
|
||||
|
||||
if( movingStart )
|
||||
aArc->SetArcStart( ( wxPoint ) start );
|
||||
|
@ -944,7 +944,7 @@ void PCB_POINT_EDITOR::editArcEndpointKeepCenter( PCB_SHAPE* aArc, const VECTOR2
|
|||
newAngle -= 3600.0;
|
||||
|
||||
aArc->SetAngle( newAngle, false );
|
||||
aArc->SetCenter( (wxPoint) aCenter );
|
||||
aArc->SetArcCenter((wxPoint) aCenter );
|
||||
|
||||
if( movingStart )
|
||||
aArc->SetArcStart( (wxPoint) aStart );
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <tool/selection.h>
|
||||
#include <tool/selection_conditions.h>
|
||||
#include <board_item.h>
|
||||
#include <eda_shape.h>
|
||||
|
||||
|
||||
class PCB_SELECTION_CONDITIONS : public SELECTION_CONDITIONS
|
||||
|
|
Loading…
Reference in New Issue