2021-07-17 19:56:18 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2022-01-25 22:33:37 +00:00
|
|
|
* Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2021-07-17 19:56:18 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sch_draw_panel.h>
|
2021-07-18 23:08:54 +00:00
|
|
|
#include <plotters/plotter.h>
|
|
|
|
#include <macros.h>
|
2021-07-17 19:56:18 +00:00
|
|
|
#include <base_units.h>
|
|
|
|
#include <widgets/msgpanel.h>
|
|
|
|
#include <bitmaps.h>
|
|
|
|
#include <eda_draw_frame.h>
|
|
|
|
#include <general.h>
|
|
|
|
#include <lib_shape.h>
|
|
|
|
|
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
LIB_SHAPE::LIB_SHAPE( LIB_SYMBOL* aParent, SHAPE_T aShape, int aLineWidth, FILL_T aFillType,
|
|
|
|
KICAD_T aType ) :
|
|
|
|
LIB_ITEM( aType, aParent ),
|
2021-07-17 19:56:18 +00:00
|
|
|
EDA_SHAPE( aShape, aLineWidth, aFillType, true )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
2021-07-18 23:08:54 +00:00
|
|
|
m_editState = 0;
|
2021-07-17 19:56:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
bool LIB_SHAPE::HitTest( const VECTOR2I& aPosRef, int aAccuracy ) const
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
|
|
|
if( aAccuracy < Mils2iu( MINIMUM_SELECTION_DISTANCE ) )
|
|
|
|
aAccuracy = Mils2iu( MINIMUM_SELECTION_DISTANCE );
|
|
|
|
|
|
|
|
return hitTest( DefaultTransform.TransformCoordinate( aPosRef ), aAccuracy );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool LIB_SHAPE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
|
|
|
|
{
|
|
|
|
if( m_flags & (STRUCT_DELETED | SKIP_STRUCT ) )
|
|
|
|
return false;
|
|
|
|
|
2021-07-18 23:08:54 +00:00
|
|
|
return hitTest( DefaultTransform.TransformCoordinate( aRect ), aContained, aAccuracy );
|
2021-07-17 19:56:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EDA_ITEM* LIB_SHAPE::Clone() const
|
|
|
|
{
|
|
|
|
return new LIB_SHAPE( *this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int LIB_SHAPE::compare( const LIB_ITEM& aOther, LIB_ITEM::COMPARE_FLAGS aCompareFlags ) const
|
|
|
|
{
|
|
|
|
int retv = LIB_ITEM::compare( aOther, aCompareFlags );
|
|
|
|
|
|
|
|
if( retv )
|
|
|
|
return retv;
|
|
|
|
|
|
|
|
return EDA_SHAPE::Compare( &static_cast<const LIB_SHAPE&>( aOther ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void LIB_SHAPE::Offset( const VECTOR2I& aOffset )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
|
|
|
move( aOffset );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void LIB_SHAPE::MoveTo( const VECTOR2I& aPosition )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
|
|
|
setPosition( aPosition );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void LIB_SHAPE::MirrorHorizontal( const VECTOR2I& aCenter )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
|
|
|
flip( aCenter, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void LIB_SHAPE::MirrorVertical( const VECTOR2I& aCenter )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
|
|
|
flip( aCenter, false );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void LIB_SHAPE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
2022-01-16 21:15:20 +00:00
|
|
|
EDA_ANGLE rot_angle = aRotateCCW ? -ANGLE_90 : ANGLE_90;
|
2021-07-17 19:56:18 +00:00
|
|
|
|
|
|
|
rotate( aCenter, rot_angle );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void LIB_SHAPE::Plot( PLOTTER* aPlotter, const VECTOR2I& aOffset, bool aFill,
|
2021-07-17 19:56:18 +00:00
|
|
|
const TRANSFORM& aTransform ) const
|
|
|
|
{
|
2022-01-31 19:11:21 +00:00
|
|
|
if( IsPrivate() )
|
|
|
|
return;
|
|
|
|
|
2022-01-16 01:06:25 +00:00
|
|
|
VECTOR2I start = aTransform.TransformCoordinate( m_start ) + aOffset;
|
|
|
|
VECTOR2I end = aTransform.TransformCoordinate( m_end ) + aOffset;
|
2022-01-25 22:33:37 +00:00
|
|
|
VECTOR2I center = aTransform.TransformCoordinate( getCenter() ) + aOffset;
|
|
|
|
int penWidth = GetEffectivePenWidth( aPlotter->RenderSettings() );
|
2022-01-16 01:06:25 +00:00
|
|
|
FILL_T fill = aFill ? m_fill : FILL_T::NO_FILL;
|
2022-01-31 19:11:21 +00:00
|
|
|
COLOR4D color = aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE );
|
2021-07-17 19:56:18 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
static std::vector<VECTOR2I> cornerList;
|
2021-07-17 19:56:18 +00:00
|
|
|
|
2021-07-18 23:08:54 +00:00
|
|
|
if( GetShape() == SHAPE_T::POLY )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
2021-07-18 23:08:54 +00:00
|
|
|
const SHAPE_LINE_CHAIN& poly = m_poly.Outline( 0 );
|
2021-07-17 19:56:18 +00:00
|
|
|
cornerList.clear();
|
|
|
|
|
2021-07-18 23:08:54 +00:00
|
|
|
for( const VECTOR2I& pt : poly.CPoints() )
|
2022-01-01 06:04:08 +00:00
|
|
|
cornerList.push_back( aTransform.TransformCoordinate( pt ) + aOffset );
|
2021-07-17 19:56:18 +00:00
|
|
|
}
|
2021-07-18 23:08:54 +00:00
|
|
|
else if( GetShape() == SHAPE_T::BEZIER )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
|
|
|
cornerList.clear();
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
for( const VECTOR2I& pt : m_bezierPoints )
|
2021-07-17 19:56:18 +00:00
|
|
|
cornerList.push_back( aTransform.TransformCoordinate( pt ) + aOffset );
|
|
|
|
}
|
2022-01-25 22:33:37 +00:00
|
|
|
|
|
|
|
if( fill != FILL_T::NO_FILL )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
2022-01-25 22:33:37 +00:00
|
|
|
COLOR4D fillColor = color;
|
2021-07-18 23:08:54 +00:00
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
if( aPlotter->GetColorMode() )
|
|
|
|
{
|
|
|
|
if( fill == FILL_T::FILLED_WITH_BG_BODYCOLOR )
|
|
|
|
fillColor = aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE_BACKGROUND );
|
|
|
|
else if( fill == FILL_T::FILLED_WITH_COLOR )
|
|
|
|
fillColor = GetFillColor();
|
|
|
|
}
|
2021-07-17 19:56:18 +00:00
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
aPlotter->SetColor( fillColor );
|
2021-07-17 19:56:18 +00:00
|
|
|
|
|
|
|
switch( GetShape() )
|
|
|
|
{
|
|
|
|
case SHAPE_T::ARC:
|
2022-01-25 22:33:37 +00:00
|
|
|
aPlotter->Arc( center, start, end, fill, 0, ARC_HIGH_DEF );
|
2021-07-17 19:56:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SHAPE_T::CIRCLE:
|
2022-01-25 22:33:37 +00:00
|
|
|
aPlotter->Circle( center, GetRadius() * 2, fill, 0 );
|
2021-07-17 19:56:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SHAPE_T::RECT:
|
|
|
|
aPlotter->Rect( start, end, fill, 0 );
|
|
|
|
break;
|
|
|
|
|
2021-07-18 23:08:54 +00:00
|
|
|
case SHAPE_T::POLY:
|
|
|
|
case SHAPE_T::BEZIER:
|
2021-07-17 19:56:18 +00:00
|
|
|
aPlotter->PlotPoly( cornerList, fill, 0 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2021-07-18 23:08:54 +00:00
|
|
|
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
2021-07-17 19:56:18 +00:00
|
|
|
}
|
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
if( penWidth <= 0 )
|
2021-07-17 19:56:18 +00:00
|
|
|
return;
|
|
|
|
else
|
|
|
|
fill = FILL_T::NO_FILL;
|
|
|
|
}
|
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
aPlotter->SetColor( color );
|
2021-07-17 19:56:18 +00:00
|
|
|
|
|
|
|
switch( GetShape() )
|
|
|
|
{
|
|
|
|
case SHAPE_T::ARC:
|
2022-01-25 22:33:37 +00:00
|
|
|
aPlotter->Arc( center, start, end, fill, penWidth, ARC_HIGH_DEF );
|
2021-07-17 19:56:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SHAPE_T::CIRCLE:
|
2022-01-25 22:33:37 +00:00
|
|
|
aPlotter->Circle( center, GetRadius() * 2, fill, penWidth );
|
2021-07-17 19:56:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SHAPE_T::RECT:
|
2022-01-25 22:33:37 +00:00
|
|
|
aPlotter->Rect( start, end, fill, penWidth );
|
2021-07-17 19:56:18 +00:00
|
|
|
break;
|
|
|
|
|
2021-07-18 23:08:54 +00:00
|
|
|
case SHAPE_T::POLY:
|
|
|
|
case SHAPE_T::BEZIER:
|
2022-01-25 22:33:37 +00:00
|
|
|
aPlotter->PlotPoly( cornerList, fill, penWidth );
|
2021-07-17 19:56:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2021-07-18 23:08:54 +00:00
|
|
|
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
2021-07-17 19:56:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int LIB_SHAPE::GetPenWidth() const
|
|
|
|
{
|
2021-07-18 23:08:54 +00:00
|
|
|
return GetWidth();
|
2021-07-17 19:56:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void LIB_SHAPE::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
|
|
|
|
const TRANSFORM& aTransform )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
2022-01-31 19:11:21 +00:00
|
|
|
if( IsPrivate() )
|
|
|
|
return;
|
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
bool forceNoFill = static_cast<bool>( aData );
|
2021-11-01 14:48:18 +00:00
|
|
|
int penWidth = GetEffectivePenWidth( aSettings );
|
2021-07-17 19:56:18 +00:00
|
|
|
|
|
|
|
if( forceNoFill && IsFilled() && penWidth == 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxDC* DC = aSettings->GetPrintDC();
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I pt1 = aTransform.TransformCoordinate( m_start ) + aOffset;
|
|
|
|
VECTOR2I pt2 = aTransform.TransformCoordinate( m_end ) + aOffset;
|
|
|
|
VECTOR2I c;
|
2022-01-31 19:11:21 +00:00
|
|
|
COLOR4D color = aSettings->GetLayerColor( LAYER_DEVICE );
|
2021-07-17 19:56:18 +00:00
|
|
|
|
|
|
|
unsigned ptCount = 0;
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I* buffer = nullptr;
|
2021-07-17 19:56:18 +00:00
|
|
|
|
2021-07-18 23:08:54 +00:00
|
|
|
if( GetShape() == SHAPE_T::POLY )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
2021-07-18 23:08:54 +00:00
|
|
|
const SHAPE_LINE_CHAIN& poly = m_poly.Outline( 0 );
|
2021-07-17 19:56:18 +00:00
|
|
|
|
|
|
|
ptCount = poly.GetPointCount();
|
2022-01-01 06:04:08 +00:00
|
|
|
buffer = new VECTOR2I[ptCount];
|
2021-07-17 19:56:18 +00:00
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < ptCount; ++ii )
|
2022-01-01 06:04:08 +00:00
|
|
|
buffer[ii] = aTransform.TransformCoordinate( poly.CPoint( ii ) ) + aOffset;
|
2021-07-17 19:56:18 +00:00
|
|
|
}
|
2021-07-18 23:08:54 +00:00
|
|
|
else if( GetShape() == SHAPE_T::BEZIER )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
|
|
|
ptCount = m_bezierPoints.size();
|
2022-01-01 06:04:08 +00:00
|
|
|
buffer = new VECTOR2I[ptCount];
|
2021-07-17 19:56:18 +00:00
|
|
|
|
|
|
|
for( size_t ii = 0; ii < ptCount; ++ii )
|
|
|
|
buffer[ii] = aTransform.TransformCoordinate( m_bezierPoints[ii] ) + aOffset;
|
|
|
|
}
|
|
|
|
else if( GetShape() == SHAPE_T::ARC )
|
|
|
|
{
|
|
|
|
c = aTransform.TransformCoordinate( getCenter() ) + aOffset;
|
2021-07-18 23:08:54 +00:00
|
|
|
|
2022-01-16 01:06:25 +00:00
|
|
|
EDA_ANGLE t1, t2;
|
2021-11-17 10:59:49 +00:00
|
|
|
|
2021-07-18 23:08:54 +00:00
|
|
|
CalcArcAngles( t1, t2 );
|
2021-10-14 23:39:31 +00:00
|
|
|
|
2022-01-18 12:42:26 +00:00
|
|
|
if( aTransform.MapAngles( &t1, &t2 ) == ( ( t1 - t2 ).Normalize180() > ANGLE_0 ) )
|
2021-10-30 14:08:44 +00:00
|
|
|
std::swap( pt1, pt2 );
|
2021-07-17 19:56:18 +00:00
|
|
|
}
|
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
if( forceNoFill || GetFillMode() == FILL_T::NO_FILL )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
|
|
|
penWidth = std::max( penWidth, aSettings->GetDefaultPenWidth() );
|
|
|
|
|
|
|
|
switch( GetShape() )
|
|
|
|
{
|
|
|
|
case SHAPE_T::ARC:
|
2022-01-28 22:51:34 +00:00
|
|
|
GRArc( DC, pt1, pt2, c, penWidth, color );
|
2021-07-17 19:56:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SHAPE_T::CIRCLE:
|
2022-01-28 22:51:34 +00:00
|
|
|
GRCircle( DC, pt1, GetRadius(), penWidth, color );
|
2021-07-17 19:56:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SHAPE_T::RECT:
|
2022-01-28 22:51:34 +00:00
|
|
|
GRRect( DC, pt1, pt2, penWidth, color );
|
2021-07-17 19:56:18 +00:00
|
|
|
break;
|
|
|
|
|
2021-07-18 23:08:54 +00:00
|
|
|
case SHAPE_T::POLY:
|
2022-01-28 22:51:34 +00:00
|
|
|
GRPoly( DC, ptCount, buffer, false, penWidth, color, color );
|
2021-07-17 19:56:18 +00:00
|
|
|
break;
|
|
|
|
|
2021-07-18 23:08:54 +00:00
|
|
|
case SHAPE_T::BEZIER:
|
2022-01-28 22:51:34 +00:00
|
|
|
GRPoly( DC, ptCount, buffer, false, penWidth, color, color );
|
2021-07-17 19:56:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2021-07-18 23:08:54 +00:00
|
|
|
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
2021-07-17 19:56:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-25 22:33:37 +00:00
|
|
|
COLOR4D fillColor = color;
|
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
if( GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR )
|
2021-11-01 20:09:32 +00:00
|
|
|
fillColor = aSettings->GetLayerColor( LAYER_DEVICE_BACKGROUND );
|
2022-01-25 22:33:37 +00:00
|
|
|
else if( GetFillMode() == FILL_T::FILLED_WITH_COLOR )
|
|
|
|
fillColor = GetFillColor();
|
2021-07-17 19:56:18 +00:00
|
|
|
|
|
|
|
switch( GetShape() )
|
|
|
|
{
|
|
|
|
case SHAPE_T::ARC:
|
2021-11-16 22:55:53 +00:00
|
|
|
// If we stroke in GRFilledArc it will stroke the two radials too, so we have to
|
|
|
|
// fill and stroke separately
|
|
|
|
|
2022-01-28 22:51:34 +00:00
|
|
|
GRFilledArc( DC, pt1, pt2, c, 0, fillColor, fillColor );
|
2021-11-16 22:55:53 +00:00
|
|
|
|
2022-01-28 22:51:34 +00:00
|
|
|
GRArc( DC, pt1, pt2, c, penWidth, color );
|
2021-07-17 19:56:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SHAPE_T::CIRCLE:
|
2022-01-28 22:51:34 +00:00
|
|
|
GRFilledCircle( DC, pt1, GetRadius(), 0, color, fillColor );
|
2021-07-17 19:56:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SHAPE_T::RECT:
|
2022-01-28 22:51:34 +00:00
|
|
|
GRFilledRect( DC, pt1, pt2, penWidth, color, fillColor );
|
2021-07-17 19:56:18 +00:00
|
|
|
break;
|
|
|
|
|
2021-07-18 23:08:54 +00:00
|
|
|
case SHAPE_T::POLY:
|
2022-01-20 18:52:48 +00:00
|
|
|
|
2022-01-28 22:51:34 +00:00
|
|
|
GRPoly( DC, ptCount, buffer, true, 0, fillColor, fillColor );
|
2022-01-20 18:52:48 +00:00
|
|
|
|
2021-11-17 01:49:44 +00:00
|
|
|
if( penWidth > 0 )
|
2022-01-28 22:51:34 +00:00
|
|
|
GRPoly( DC, ptCount, buffer, false, penWidth, color, fillColor );
|
2022-01-20 18:52:48 +00:00
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
break;
|
|
|
|
|
2021-07-18 23:08:54 +00:00
|
|
|
case SHAPE_T::BEZIER:
|
2021-11-17 01:49:44 +00:00
|
|
|
if( penWidth > 0 )
|
2022-01-28 22:51:34 +00:00
|
|
|
GRPoly( DC, ptCount, buffer, true, penWidth, color, fillColor );
|
2021-11-17 01:49:44 +00:00
|
|
|
else
|
2022-01-28 22:51:34 +00:00
|
|
|
GRPoly( DC, ptCount, buffer, true, 0, fillColor, fillColor );
|
2021-07-17 19:56:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2021-07-18 23:08:54 +00:00
|
|
|
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
2021-07-17 19:56:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete[] buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const EDA_RECT LIB_SHAPE::GetBoundingBox() const
|
|
|
|
{
|
|
|
|
EDA_RECT rect = getBoundingBox();
|
|
|
|
|
|
|
|
rect.RevertYAxis();
|
|
|
|
|
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-14 23:39:31 +00:00
|
|
|
void LIB_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
|
|
|
LIB_ITEM::GetMsgPanelInfo( aFrame, aList );
|
|
|
|
|
|
|
|
ShapeGetMsgPanelInfo( aFrame, aList );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString LIB_SHAPE::GetSelectMenuText( EDA_UNITS aUnits ) const
|
|
|
|
{
|
|
|
|
switch( GetShape() )
|
|
|
|
{
|
|
|
|
case SHAPE_T::ARC:
|
|
|
|
return wxString::Format( _( "Arc, radius %s" ),
|
|
|
|
MessageTextFromValue( aUnits, GetRadius() ) );
|
|
|
|
|
|
|
|
case SHAPE_T::CIRCLE:
|
|
|
|
return wxString::Format( _( "Circle, radius %s" ),
|
|
|
|
MessageTextFromValue( aUnits, GetRadius() ) );
|
|
|
|
|
|
|
|
case SHAPE_T::RECT:
|
|
|
|
return wxString::Format( _( "Rectangle, width %s height %s" ),
|
|
|
|
MessageTextFromValue( aUnits, std::abs( m_start.x - m_end.x ) ),
|
|
|
|
MessageTextFromValue( aUnits, std::abs( m_start.y - m_end.y ) ) );
|
|
|
|
|
2021-07-18 23:08:54 +00:00
|
|
|
case SHAPE_T::POLY:
|
2021-07-17 19:56:18 +00:00
|
|
|
return wxString::Format( _( "Polyline, %d points" ),
|
|
|
|
int( m_poly.Outline( 0 ).GetPointCount() ) );
|
|
|
|
|
2021-07-18 23:08:54 +00:00
|
|
|
case SHAPE_T::BEZIER:
|
2021-07-17 19:56:18 +00:00
|
|
|
return wxString::Format( _( "Bezier Curve, %d points" ),
|
|
|
|
int( m_bezierPoints.size() ) );
|
|
|
|
|
|
|
|
default:
|
2021-07-18 23:08:54 +00:00
|
|
|
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
2021-07-17 19:56:18 +00:00
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BITMAPS LIB_SHAPE::GetMenuImage() const
|
|
|
|
{
|
|
|
|
switch( GetShape() )
|
|
|
|
{
|
2021-07-18 23:08:54 +00:00
|
|
|
case SHAPE_T::SEGMENT: return BITMAPS::add_line;
|
|
|
|
case SHAPE_T::ARC: return BITMAPS::add_arc;
|
|
|
|
case SHAPE_T::CIRCLE: return BITMAPS::add_circle;
|
|
|
|
case SHAPE_T::RECT: return BITMAPS::add_rectangle;
|
|
|
|
case SHAPE_T::POLY: return BITMAPS::add_graphical_segments;
|
2021-07-17 19:56:18 +00:00
|
|
|
|
|
|
|
default:
|
2021-07-18 23:08:54 +00:00
|
|
|
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
2021-07-17 19:56:18 +00:00
|
|
|
return BITMAPS::question_mark;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void LIB_SHAPE::AddPoint( const VECTOR2I& aPosition )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
2021-07-18 23:08:54 +00:00
|
|
|
if( GetShape() == SHAPE_T::POLY )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
|
|
|
if( m_poly.IsEmpty() )
|
|
|
|
m_poly.NewOutline();
|
|
|
|
|
|
|
|
m_poly.Outline( 0 ).Append( aPosition, true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-17 19:56:18 +00:00
|
|
|
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
2021-07-17 19:56:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
void LIB_SHAPE::ViewGetLayers( int aLayers[], int& aCount ) const
|
|
|
|
{
|
|
|
|
aCount = 3;
|
|
|
|
aLayers[0] = IsPrivate() ? LAYER_NOTES : LAYER_DEVICE;
|
|
|
|
aLayers[1] = IsPrivate() ? LAYER_NOTES_BACKGROUND : LAYER_DEVICE_BACKGROUND;
|
|
|
|
aLayers[2] = LAYER_SELECTION_SHADOWS;
|
|
|
|
}
|