class MARKER rework: fix a few minor issues, remove duplicate code and add comments.
This commit is contained in:
parent
64f1fb9e79
commit
15843ae01a
|
@ -8,40 +8,34 @@
|
||||||
#include "dialog_display_info_HTML_base.h"
|
#include "dialog_display_info_HTML_base.h"
|
||||||
|
|
||||||
|
|
||||||
static const wxPoint MarkerShapeCorners[] =
|
|
||||||
{
|
|
||||||
wxPoint( 0, 0 ),
|
|
||||||
wxPoint( 8, 1 ),
|
|
||||||
wxPoint( 4, 3 ),
|
|
||||||
wxPoint( 13, 8 ),
|
|
||||||
wxPoint( 9, 9 ),
|
|
||||||
wxPoint( 8, 13 ),
|
|
||||||
wxPoint( 3, 4 ),
|
|
||||||
wxPoint( 1, 8 )
|
|
||||||
};
|
|
||||||
const unsigned CORNERS_COUNT = DIM( MarkerShapeCorners );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MARKER_BASE::DrawMarker( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
|
void MARKER_BASE::DrawMarker( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
|
||||||
const wxPoint& aOffset )
|
const wxPoint& aOffset )
|
||||||
{
|
{
|
||||||
wxPoint corners[CORNERS_COUNT];
|
// Build the marker shape polygon in internal units:
|
||||||
|
const int ccount = GetShapePolygonCornerCount();
|
||||||
|
std::vector<wxPoint> shape;
|
||||||
|
shape.reserve( ccount );
|
||||||
|
|
||||||
|
for( int ii = 0; ii < ccount; ii++ )
|
||||||
|
shape.push_back( wxPoint( GetShapePolygonCorner( ii ).x * MarkerScale(),
|
||||||
|
GetShapePolygonCorner( ii ).y * MarkerScale() ) );
|
||||||
|
|
||||||
GRSetDrawMode( aDC, aDrawMode );
|
GRSetDrawMode( aDC, aDrawMode );
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < CORNERS_COUNT; ii++ )
|
for( int ii = 0; ii < ccount; ii++ )
|
||||||
{
|
{
|
||||||
corners[ii] = MarkerShapeCorners[ii];
|
shape[ii] += m_Pos + aOffset;
|
||||||
corners[ii].x *= m_ScalingFactor;
|
|
||||||
corners[ii].y *= m_ScalingFactor;
|
|
||||||
corners[ii] += m_Pos + aOffset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GRClosedPoly( aPanel->GetClipBox(), aDC, CORNERS_COUNT, corners,
|
GRClosedPoly( aPanel->GetClipBox(), aDC, ccount, &shape[0],
|
||||||
true, // = Filled
|
true, // = Filled
|
||||||
0, // outline width
|
0, // outline width
|
||||||
m_Color, // outline color
|
m_Color, // outline color
|
||||||
m_Color // fill collor
|
m_Color // fill collor
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#if 0 // For testing purpose only:
|
||||||
|
EDA_RECT bbox = GetBoundingBoxMarker();
|
||||||
|
GRRect( aPanel->GetClipBox(), aDC, bbox, 10, m_Color );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "fctsys.h"
|
#include "fctsys.h"
|
||||||
#include "gr_basic.h"
|
//#include "gr_basic.h"
|
||||||
#include "base_screen.h"
|
#include "base_screen.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
|
@ -39,22 +39,22 @@
|
||||||
#include "dialog_display_info_HTML_base.h"
|
#include "dialog_display_info_HTML_base.h"
|
||||||
|
|
||||||
|
|
||||||
// Default marquer shape:
|
|
||||||
const int M_SHAPE_SCALE = 6; // default scaling factor for MarkerShapeCorners coordinates
|
|
||||||
/* The graphic shape of markers is a polygon.
|
/* The graphic shape of markers is a polygon.
|
||||||
* MarkerShapeCorners contains the coordinates of corners of the polygonal default shape
|
* MarkerShapeCorners contains the coordinates of corners of the polygonal default shape
|
||||||
* actual coordinates are these values * .m_ScalingFactor
|
* they are arbitrary units to make coding shape easy.
|
||||||
|
* internal units coordinates are these values scaled by .m_ScalingFactor
|
||||||
*/
|
*/
|
||||||
static const wxPoint MarkerShapeCorners[] =
|
static const VECTOR2I MarkerShapeCorners[] =
|
||||||
{
|
{
|
||||||
wxPoint( 0, 0 ),
|
VECTOR2I( 0, 0 ),
|
||||||
wxPoint( 8, 1 ),
|
VECTOR2I( 8, 1 ),
|
||||||
wxPoint( 4, 3 ),
|
VECTOR2I( 4, 3 ),
|
||||||
wxPoint( 13, 8 ),
|
VECTOR2I( 13, 8 ),
|
||||||
wxPoint( 9, 9 ),
|
VECTOR2I( 9, 9 ),
|
||||||
wxPoint( 8, 13 ),
|
VECTOR2I( 8, 13 ),
|
||||||
wxPoint( 3, 4 ),
|
VECTOR2I( 3, 4 ),
|
||||||
wxPoint( 1, 8 )
|
VECTOR2I( 1, 8 ),
|
||||||
|
VECTOR2I( 0, 0 )
|
||||||
};
|
};
|
||||||
const unsigned CORNERS_COUNT = DIM( MarkerShapeCorners );
|
const unsigned CORNERS_COUNT = DIM( MarkerShapeCorners );
|
||||||
|
|
||||||
|
@ -67,16 +67,17 @@ void MARKER_BASE::init()
|
||||||
m_MarkerType = MARKER_UNSPEC;
|
m_MarkerType = MARKER_UNSPEC;
|
||||||
m_ErrorLevel = MARKER_SEVERITY_UNSPEC;
|
m_ErrorLevel = MARKER_SEVERITY_UNSPEC;
|
||||||
m_Color = RED;
|
m_Color = RED;
|
||||||
wxPoint start = MarkerShapeCorners[0];
|
const VECTOR2I* point_shape = GetShapePolygon();
|
||||||
wxPoint end = MarkerShapeCorners[0];
|
wxPoint start( point_shape->x, point_shape->y );
|
||||||
|
wxPoint end = start;
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < CORNERS_COUNT; ii++ )
|
for( int ii = 1; ii < GetShapePolygonCornerCount(); ii++ )
|
||||||
{
|
{
|
||||||
wxPoint corner = MarkerShapeCorners[ii];
|
++point_shape;
|
||||||
start.x = std::min( start.x, corner.x);
|
start.x = std::min( start.x, point_shape->x);
|
||||||
start.y = std::min( start.y, corner.y);
|
start.y = std::min( start.y, point_shape->y);
|
||||||
end.x = std::max( end.x, corner.x);
|
end.x = std::max( end.x, point_shape->x);
|
||||||
end.y = std::max( end.y, corner.y);
|
end.y = std::max( end.y, point_shape->y);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ShapeBoundingBox.SetOrigin(start);
|
m_ShapeBoundingBox.SetOrigin(start);
|
||||||
|
@ -97,7 +98,7 @@ MARKER_BASE::MARKER_BASE( const MARKER_BASE& aMarker )
|
||||||
|
|
||||||
MARKER_BASE::MARKER_BASE()
|
MARKER_BASE::MARKER_BASE()
|
||||||
{
|
{
|
||||||
m_ScalingFactor = M_SHAPE_SCALE;
|
m_ScalingFactor = 1;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +107,7 @@ MARKER_BASE::MARKER_BASE( EDA_UNITS_T aUnits, int aErrorCode, const wxPoint& aMa
|
||||||
EDA_ITEM* aItem, const wxPoint& aPos,
|
EDA_ITEM* aItem, const wxPoint& aPos,
|
||||||
EDA_ITEM* bItem, const wxPoint& bPos )
|
EDA_ITEM* bItem, const wxPoint& bPos )
|
||||||
{
|
{
|
||||||
m_ScalingFactor = M_SHAPE_SCALE;
|
m_ScalingFactor = 1;
|
||||||
init();
|
init();
|
||||||
|
|
||||||
SetData( aUnits, aErrorCode, aMarkerPos, aItem, aPos, bItem, bPos );
|
SetData( aUnits, aErrorCode, aMarkerPos, aItem, aPos, bItem, bPos );
|
||||||
|
@ -117,7 +118,7 @@ MARKER_BASE::MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos,
|
||||||
const wxString& aText, const wxPoint& aPos,
|
const wxString& aText, const wxPoint& aPos,
|
||||||
const wxString& bText, const wxPoint& bPos )
|
const wxString& bText, const wxPoint& bPos )
|
||||||
{
|
{
|
||||||
m_ScalingFactor = M_SHAPE_SCALE;
|
m_ScalingFactor = 1;
|
||||||
init();
|
init();
|
||||||
|
|
||||||
SetData( aErrorCode, aMarkerPos, aText, aPos, bText, bPos );
|
SetData( aErrorCode, aMarkerPos, aText, aPos, bText, bPos );
|
||||||
|
@ -127,7 +128,7 @@ MARKER_BASE::MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos,
|
||||||
MARKER_BASE::MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos,
|
MARKER_BASE::MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos,
|
||||||
const wxString& aText, const wxPoint& aPos )
|
const wxString& aText, const wxPoint& aPos )
|
||||||
{
|
{
|
||||||
m_ScalingFactor = M_SHAPE_SCALE;
|
m_ScalingFactor = 1;
|
||||||
init();
|
init();
|
||||||
|
|
||||||
SetData( aErrorCode, aMarkerPos, aText, aPos );
|
SetData( aErrorCode, aMarkerPos, aText, aPos );
|
||||||
|
@ -159,26 +160,43 @@ void MARKER_BASE::SetData( int aErrorCode, const wxPoint& aMarkerPos,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool MARKER_BASE::HitTestMarker( const wxPoint& refPos ) const
|
bool MARKER_BASE::HitTestMarker( const wxPoint& aHitPosition ) const
|
||||||
{
|
{
|
||||||
wxPoint rel_pos = refPos - m_Pos;
|
EDA_RECT bbox = GetBoundingBoxMarker();
|
||||||
rel_pos.x /= m_ScalingFactor;
|
|
||||||
rel_pos.y /= m_ScalingFactor;
|
|
||||||
|
|
||||||
return m_ShapeBoundingBox.Contains( rel_pos );
|
return bbox.Contains( aHitPosition );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const VECTOR2I* MARKER_BASE::GetShapePolygon() const
|
||||||
|
{
|
||||||
|
return MarkerShapeCorners;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const VECTOR2I& MARKER_BASE::GetShapePolygonCorner( int aIdx ) const
|
||||||
|
{
|
||||||
|
return MarkerShapeCorners[aIdx];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int MARKER_BASE::GetShapePolygonCornerCount() const
|
||||||
|
{
|
||||||
|
return CORNERS_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EDA_RECT MARKER_BASE::GetBoundingBoxMarker() const
|
EDA_RECT MARKER_BASE::GetBoundingBoxMarker() const
|
||||||
{
|
{
|
||||||
wxSize realsize = m_ShapeBoundingBox.GetSize();
|
wxSize size_iu = m_ShapeBoundingBox.GetSize();
|
||||||
wxPoint realposition = m_ShapeBoundingBox.GetPosition();
|
wxPoint position_iu = m_ShapeBoundingBox.GetPosition();
|
||||||
realsize.x *= m_ScalingFactor;
|
size_iu.x *= m_ScalingFactor;
|
||||||
realsize.y *= m_ScalingFactor;
|
size_iu.y *= m_ScalingFactor;
|
||||||
realposition.x *= m_ScalingFactor;
|
position_iu.x *= m_ScalingFactor;
|
||||||
realposition.y *= m_ScalingFactor;
|
position_iu.y *= m_ScalingFactor;
|
||||||
realposition += m_Pos;
|
position_iu += m_Pos;
|
||||||
return EDA_RECT( m_Pos, realsize );
|
|
||||||
|
return EDA_RECT( position_iu, size_iu );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,14 +32,18 @@
|
||||||
#include <trigo.h>
|
#include <trigo.h>
|
||||||
#include <msgpanel.h>
|
#include <msgpanel.h>
|
||||||
#include <bitmaps.h>
|
#include <bitmaps.h>
|
||||||
|
#include <base_units.h>
|
||||||
|
|
||||||
#include <sch_marker.h>
|
#include <sch_marker.h>
|
||||||
#include <erc.h>
|
#include <erc.h>
|
||||||
|
|
||||||
|
/// Factor to convert the maker unit shape to internal units:
|
||||||
|
#define SCALING_FACTOR Millimeter2iu( 0.1 )
|
||||||
|
|
||||||
|
|
||||||
SCH_MARKER::SCH_MARKER() : SCH_ITEM( NULL, SCH_MARKER_T ), MARKER_BASE()
|
SCH_MARKER::SCH_MARKER() : SCH_ITEM( NULL, SCH_MARKER_T ), MARKER_BASE()
|
||||||
{
|
{
|
||||||
m_ScalingFactor = 8;
|
m_ScalingFactor = SCALING_FACTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,7 +51,7 @@ SCH_MARKER::SCH_MARKER( const wxPoint& pos, const wxString& text ) :
|
||||||
SCH_ITEM( NULL, SCH_MARKER_T ),
|
SCH_ITEM( NULL, SCH_MARKER_T ),
|
||||||
MARKER_BASE( 0, pos, text, pos )
|
MARKER_BASE( 0, pos, text, pos )
|
||||||
{
|
{
|
||||||
m_ScalingFactor = 8;
|
m_ScalingFactor = SCALING_FACTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors.
|
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -1364,21 +1364,16 @@ void SCH_PAINTER::draw( SCH_BITMAP *aBitmap, int aLayer )
|
||||||
|
|
||||||
void SCH_PAINTER::draw( SCH_MARKER *aMarker, int aLayer )
|
void SCH_PAINTER::draw( SCH_MARKER *aMarker, int aLayer )
|
||||||
{
|
{
|
||||||
const int scale = aMarker->m_ScalingFactor;
|
const int scale = aMarker->MarkerScale();
|
||||||
|
|
||||||
// If you are changing this, update the bounding box as well
|
// Build the marker shape polygon in internal units:
|
||||||
const VECTOR2D arrow[] =
|
const int ccount = aMarker->GetShapePolygonCornerCount();
|
||||||
{
|
std::vector<VECTOR2D> arrow;
|
||||||
VECTOR2D( 0 * scale, 0 * scale ),
|
arrow.reserve( ccount );
|
||||||
VECTOR2D( 8 * scale, 1 * scale ),
|
|
||||||
VECTOR2D( 4 * scale, 3 * scale ),
|
for( int ii = 0; ii < ccount; ii++ )
|
||||||
VECTOR2D( 13 * scale, 8 * scale ),
|
arrow.push_back( VECTOR2D( aMarker->GetShapePolygonCorner( ii ).x * scale,
|
||||||
VECTOR2D( 9 * scale, 9 * scale ),
|
aMarker->GetShapePolygonCorner( ii ).y * scale ) );
|
||||||
VECTOR2D( 8 * scale, 13 * scale ),
|
|
||||||
VECTOR2D( 3 * scale, 4 * scale ),
|
|
||||||
VECTOR2D( 1 * scale, 8 * scale ),
|
|
||||||
VECTOR2D( 0 * scale, 0 * scale )
|
|
||||||
};
|
|
||||||
|
|
||||||
COLOR4D color = m_schSettings.GetLayerColor( LAYER_ERC_WARN );
|
COLOR4D color = m_schSettings.GetLayerColor( LAYER_ERC_WARN );
|
||||||
|
|
||||||
|
@ -1390,7 +1385,7 @@ void SCH_PAINTER::draw( SCH_MARKER *aMarker, int aLayer )
|
||||||
m_gal->SetFillColor( color );
|
m_gal->SetFillColor( color );
|
||||||
m_gal->SetIsFill( true );
|
m_gal->SetIsFill( true );
|
||||||
m_gal->SetIsStroke( false );
|
m_gal->SetIsStroke( false );
|
||||||
m_gal->DrawPolygon( arrow, sizeof( arrow ) / sizeof( VECTOR2D ) );
|
m_gal->DrawPolygon( &arrow[0], arrow.size() );
|
||||||
m_gal->Restore();
|
m_gal->Restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,16 +52,15 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
wxPoint m_Pos; ///< position of the marker
|
wxPoint m_Pos; ///< position of the marker
|
||||||
int m_ScalingFactor; ///< Scaling factor for m_Size and m_Corners (can
|
|
||||||
///< set the physical size)
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
int m_ScalingFactor; ///< Scaling factor to convert corners coordinates
|
||||||
|
///< to internat units coordinates
|
||||||
TYPEMARKER m_MarkerType; ///< The type of marker (useful to filter markers)
|
TYPEMARKER m_MarkerType; ///< The type of marker (useful to filter markers)
|
||||||
MARKER_SEVERITY m_ErrorLevel; ///< Specify the severity of the error
|
MARKER_SEVERITY m_ErrorLevel; ///< Specify the severity of the error
|
||||||
COLOR4D m_Color; ///< color
|
COLOR4D m_Color; ///< color
|
||||||
EDA_RECT m_ShapeBoundingBox; ///< Bounding box of the graphic symbol, relative
|
EDA_RECT m_ShapeBoundingBox; ///< Bounding box of the graphic symbol, relative
|
||||||
///< to the position of the shape, used for Hit
|
///< to the position of the shape, in marker shape units
|
||||||
///< Tests
|
|
||||||
DRC_ITEM m_drc;
|
DRC_ITEM m_drc;
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
@ -116,6 +115,22 @@ public:
|
||||||
|
|
||||||
~MARKER_BASE();
|
~MARKER_BASE();
|
||||||
|
|
||||||
|
/** The scaling factor to convert polygonal shape coordinates to internal units
|
||||||
|
*/
|
||||||
|
int MarkerScale() const { return m_ScalingFactor; }
|
||||||
|
|
||||||
|
/** @return the shape polygon corners list
|
||||||
|
*/
|
||||||
|
const VECTOR2I* GetShapePolygon() const;
|
||||||
|
|
||||||
|
/** @return the shape polygon corner aIdx
|
||||||
|
*/
|
||||||
|
const VECTOR2I& GetShapePolygonCorner( int aIdx ) const;
|
||||||
|
|
||||||
|
/** @return the default shape polygon corner count
|
||||||
|
*/
|
||||||
|
int GetShapePolygonCornerCount() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function DrawMarker
|
* Function DrawMarker
|
||||||
* draws the shape is the polygon defined in m_Corners (array of wxPoints).
|
* draws the shape is the polygon defined in m_Corners (array of wxPoints).
|
||||||
|
@ -125,7 +140,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetPos
|
* Function GetPos
|
||||||
* returns the position of this MARKER, const.
|
* @return the position of this MARKER in internal units.
|
||||||
*/
|
*/
|
||||||
const wxPoint& GetPos() const
|
const wxPoint& GetPos() const
|
||||||
{
|
{
|
||||||
|
@ -229,12 +244,11 @@ public:
|
||||||
void DisplayMarkerInfo( EDA_DRAW_FRAME* aFrame );
|
void DisplayMarkerInfo( EDA_DRAW_FRAME* aFrame );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function HitTestMarker
|
* Tests if the given wxPoint is within the bounds of this object.
|
||||||
* tests if the given wxPoint is within the bounds of this object.
|
* @param aHitPosition is the wxPoint to test (in internal units)
|
||||||
* @param ref_pos A wxPoint to test
|
|
||||||
* @return bool - true if a hit, else false
|
* @return bool - true if a hit, else false
|
||||||
*/
|
*/
|
||||||
bool HitTestMarker( const wxPoint& ref_pos ) const;
|
bool HitTestMarker( const wxPoint& aHitPosition ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetBoundingBoxMarker
|
* Function GetBoundingBoxMarker
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||||
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -41,9 +41,8 @@
|
||||||
#include <layers_id_colors_and_visibility.h>
|
#include <layers_id_colors_and_visibility.h>
|
||||||
|
|
||||||
|
|
||||||
/// Adjust the actual size of markers, when using default shape
|
/// Factor to convert the maker unit shape to internal units:
|
||||||
#define SCALING_FACTOR Mils2iu( 3 )
|
#define SCALING_FACTOR Millimeter2iu( 0.1 )
|
||||||
|
|
||||||
|
|
||||||
MARKER_PCB::MARKER_PCB( BOARD_ITEM* aParent ) :
|
MARKER_PCB::MARKER_PCB( BOARD_ITEM* aParent ) :
|
||||||
BOARD_ITEM( aParent, PCB_MARKER_T ),
|
BOARD_ITEM( aParent, PCB_MARKER_T ),
|
||||||
|
@ -146,5 +145,19 @@ void MARKER_PCB::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||||
|
|
||||||
const EDA_RECT MARKER_PCB::GetBoundingBox() const
|
const EDA_RECT MARKER_PCB::GetBoundingBox() const
|
||||||
{
|
{
|
||||||
return EDA_RECT( m_Pos, wxSize( 1300000, 1300000 ) );
|
EDA_RECT bbox = m_ShapeBoundingBox;
|
||||||
|
|
||||||
|
wxPoint pos = m_Pos;
|
||||||
|
pos.x += int( bbox.GetOrigin().x * MarkerScale() );
|
||||||
|
pos.y += int( bbox.GetOrigin().y * MarkerScale() );
|
||||||
|
|
||||||
|
return EDA_RECT( pos, wxSize( int( bbox.GetWidth() * MarkerScale() ),
|
||||||
|
int( bbox.GetHeight() * MarkerScale() ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const BOX2I MARKER_PCB::ViewBBox() const
|
||||||
|
{
|
||||||
|
EDA_RECT bbox = GetBoundingBox();
|
||||||
|
return BOX2I( bbox.GetOrigin(), VECTOR2I( bbox.GetWidth(), bbox.GetHeight() ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009-2014 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
* Copyright (C) 2009-2018 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
||||||
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -34,13 +34,14 @@
|
||||||
#include <class_board_item.h>
|
#include <class_board_item.h>
|
||||||
#include <marker_base.h>
|
#include <marker_base.h>
|
||||||
|
|
||||||
|
// Coordinates count for the basic shape marker
|
||||||
|
#define MARKER_SHAPE_POINT_COUNT 9
|
||||||
|
|
||||||
class MSG_PANEL_ITEM;
|
class MSG_PANEL_ITEM;
|
||||||
|
|
||||||
|
|
||||||
class MARKER_PCB : public BOARD_ITEM, public MARKER_BASE
|
class MARKER_PCB : public BOARD_ITEM, public MARKER_BASE
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MARKER_PCB( BOARD_ITEM* aParent );
|
MARKER_PCB( BOARD_ITEM* aParent );
|
||||||
|
@ -78,10 +79,6 @@ public:
|
||||||
return aItem && PCB_MARKER_T == aItem->Type();
|
return aItem && PCB_MARKER_T == aItem->Type();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A scaling factor to create the marker symbol
|
|
||||||
*/
|
|
||||||
static int MarkerScale() {return Millimeter2iu( 0.1 ); }
|
|
||||||
|
|
||||||
void Move(const wxPoint& aMoveVector) override
|
void Move(const wxPoint& aMoveVector) override
|
||||||
{
|
{
|
||||||
m_Pos += aMoveVector;
|
m_Pos += aMoveVector;
|
||||||
|
@ -113,12 +110,7 @@ public:
|
||||||
|
|
||||||
BITMAP_DEF GetMenuImage() const override;
|
BITMAP_DEF GetMenuImage() const override;
|
||||||
|
|
||||||
const BOX2I ViewBBox() const override
|
const BOX2I ViewBBox() const override;
|
||||||
{
|
|
||||||
// The following is based on the PCB_PAINTER::draw( const MARKER_PCB* )
|
|
||||||
// the value 13 comes from the max relative coordinate of the shape)
|
|
||||||
return BOX2I( m_Pos, VECTOR2I( 13*MarkerScale(), 13*MarkerScale() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
const EDA_RECT GetBoundingBox() const override;
|
const EDA_RECT GetBoundingBox() const override;
|
||||||
|
|
||||||
|
|
|
@ -1243,20 +1243,16 @@ void PCB_PAINTER::draw( const PCB_TARGET* aTarget )
|
||||||
|
|
||||||
void PCB_PAINTER::draw( const MARKER_PCB* aMarker )
|
void PCB_PAINTER::draw( const MARKER_PCB* aMarker )
|
||||||
{
|
{
|
||||||
const int scale = MARKER_PCB::MarkerScale();
|
const int scale = aMarker->MarkerScale();
|
||||||
|
|
||||||
// If you are changing this, update MARKER_PCB::ViewBBox()
|
// Build the marker shape polygon in internal units:
|
||||||
const VECTOR2D arrow[] = {
|
const int ccount = aMarker->GetShapePolygonCornerCount();
|
||||||
VECTOR2D( 0 * scale, 0 * scale ),
|
std::vector<VECTOR2D> arrow;
|
||||||
VECTOR2D( 8 * scale, 1 * scale ),
|
arrow.reserve( ccount );
|
||||||
VECTOR2D( 4 * scale, 3 * scale ),
|
|
||||||
VECTOR2D( 13 * scale, 8 * scale ),
|
for( int ii = 0; ii < ccount; ii++ )
|
||||||
VECTOR2D( 9 * scale, 9 * scale ),
|
arrow.push_back( VECTOR2D( aMarker->GetShapePolygonCorner( ii ).x * scale,
|
||||||
VECTOR2D( 8 * scale, 13 * scale ),
|
aMarker->GetShapePolygonCorner( ii ).y * scale ) );
|
||||||
VECTOR2D( 3 * scale, 4 * scale ),
|
|
||||||
VECTOR2D( 1 * scale, 8 * scale ),
|
|
||||||
VECTOR2D( 0 * scale, 0 * scale )
|
|
||||||
};
|
|
||||||
|
|
||||||
auto strokeColor = m_pcbSettings.GetColor( aMarker, LAYER_DRC );
|
auto strokeColor = m_pcbSettings.GetColor( aMarker, LAYER_DRC );
|
||||||
|
|
||||||
|
@ -1265,7 +1261,7 @@ void PCB_PAINTER::draw( const MARKER_PCB* aMarker )
|
||||||
m_gal->SetFillColor( strokeColor );
|
m_gal->SetFillColor( strokeColor );
|
||||||
m_gal->SetIsFill( true );
|
m_gal->SetIsFill( true );
|
||||||
m_gal->SetIsStroke( false );
|
m_gal->SetIsStroke( false );
|
||||||
m_gal->DrawPolygon( arrow, sizeof( arrow ) / sizeof( VECTOR2D ) );
|
m_gal->DrawPolygon( &arrow[0], arrow.size() );
|
||||||
m_gal->Restore();
|
m_gal->Restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue