pcbnew: implement SHAPE_COMPOUND-based GetEffectiveShape()

This commit is contained in:
Tomasz Wlostowski 2020-07-15 18:23:36 +02:00
parent 7dbd8ef802
commit 832a8c5bf7
6 changed files with 39 additions and 4 deletions

View File

@ -41,7 +41,7 @@ class BOARD;
class BOARD_ITEM_CONTAINER;
class SHAPE_POLY_SET;
class PCB_BASE_FRAME;
class SHAPE;
/**
* Enum STROKE_T
@ -156,6 +156,8 @@ public:
*/
static wxPoint ZeroOffset;
virtual std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER );
BOARD_ITEM_CONTAINER* GetParent() const { return (BOARD_ITEM_CONTAINER*) m_Parent; }
/**

View File

@ -150,6 +150,15 @@ bool BOARD_ITEM::ptr_cmp::operator() ( const BOARD_ITEM* a, const BOARD_ITEM* b
return a->m_Uuid < b->m_Uuid;
}
std::shared_ptr<SHAPE> BOARD_ITEM::GetEffectiveShape( PCB_LAYER_ID aLayer )
{
std::shared_ptr<SHAPE> shape;
return shape;
}
static struct BOARD_ITEM_DESC
{
BOARD_ITEM_DESC()

View File

@ -37,6 +37,7 @@
#include <geometry/shape_simple.h>
#include <geometry/shape_segment.h>
#include <geometry/shape_circle.h>
#include <geometry/shape_compound.h>
#include <settings/color_settings.h>
#include <settings/settings_manager.h>
@ -1120,6 +1121,12 @@ std::vector<SHAPE*> DRAWSEGMENT::MakeEffectiveShapes()
}
std::shared_ptr<SHAPE> DRAWSEGMENT::GetEffectiveShape( PCB_LAYER_ID aLayer )
{
return std::shared_ptr<SHAPE>( new SHAPE_COMPOUND( MakeEffectiveShapes() ) );
}
const std::vector<wxPoint> DRAWSEGMENT::BuildPolyPointsList() const
{
std::vector<wxPoint> rv;

View File

@ -244,7 +244,8 @@ public:
/**
* Makes a set of SHAPE objects representing the DRAWSEGMENT. Caller owns the objects.
*/
std::vector<SHAPE*> MakeEffectiveShapes();
std::vector<SHAPE*> MakeEffectiveShapes(); // fixme: move to shape_compound
virtual std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER ) override;
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;

View File

@ -40,6 +40,7 @@
#include <geometry/shape_segment.h>
#include <geometry/shape_simple.h>
#include <geometry/shape_rect.h>
#include <geometry/shape_compound.h>
#include <pcbnew.h>
#include <view/view.h>
#include <class_board.h>
@ -221,6 +222,20 @@ const std::shared_ptr<SHAPE_POLY_SET>& D_PAD::GetEffectivePolygon() const
}
std::shared_ptr<SHAPE> D_PAD::GetEffectiveShape( PCB_LAYER_ID aLayer )
{
std::shared_ptr<SHAPE_COMPOUND> shape( new SHAPE_COMPOUND );
if( m_shapesDirty )
BuildEffectiveShapes();
for( auto s : m_effectiveShapes )
shape->AddShape( s->Clone() ); // fixme: use COMPOUND everywhere
return shape;
}
const SHAPE_SEGMENT* D_PAD::GetEffectiveHoleShape() const
{
if( m_shapesDirty )

View File

@ -392,6 +392,7 @@ public:
* multiple outlines and/or holes).
*/
const std::vector<std::shared_ptr<SHAPE>>& GetEffectiveShapes() const;
virtual std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER ) override;
const std::shared_ptr<SHAPE_POLY_SET>& GetEffectivePolygon() const;