2012-01-14 19:50:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2012-06-08 09:56:42 +00:00
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2021-07-19 23:56:05 +00:00
|
|
|
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
|
2023-11-11 15:29:34 +00:00
|
|
|
* Copyright (C) 2023 CERN
|
2023-03-04 23:15:43 +00:00
|
|
|
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-01-14 19:50:32 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <base_units.h>
|
2021-10-25 19:50:33 +00:00
|
|
|
#include <convert_basic_shapes_to_polygon.h>
|
2023-09-18 23:52:27 +00:00
|
|
|
#include <font/font.h>
|
2024-04-27 19:57:24 +00:00
|
|
|
#include <board.h>
|
2021-06-11 16:59:28 +00:00
|
|
|
#include <pcb_dimension.h>
|
2020-10-04 23:34:59 +00:00
|
|
|
#include <pcb_text.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <geometry/shape_compound.h>
|
2020-09-12 20:09:40 +00:00
|
|
|
#include <geometry/shape_circle.h>
|
|
|
|
#include <geometry/shape_segment.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/color_settings.h>
|
|
|
|
#include <settings/settings_manager.h>
|
2020-10-14 03:37:48 +00:00
|
|
|
#include <trigo.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
|
2022-01-20 23:08:48 +00:00
|
|
|
static const EDA_ANGLE s_arrowAngle( 27.5, DEGREES_T );
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
PCB_DIMENSION_BASE::PCB_DIMENSION_BASE( BOARD_ITEM* aParent, KICAD_T aType ) :
|
2023-03-04 23:15:43 +00:00
|
|
|
PCB_TEXT( aParent, aType ),
|
2020-09-11 23:52:45 +00:00
|
|
|
m_overrideTextEnabled( false ),
|
|
|
|
m_units( EDA_UNITS::INCHES ),
|
|
|
|
m_autoUnits( false ),
|
|
|
|
m_unitsFormat( DIM_UNITS_FORMAT::BARE_SUFFIX ),
|
2023-03-05 13:27:22 +00:00
|
|
|
m_precision( DIM_PRECISION::X_XXXX ),
|
2020-09-11 23:52:45 +00:00
|
|
|
m_suppressZeroes( false ),
|
2022-09-16 11:33:56 +00:00
|
|
|
m_lineThickness( pcbIUScale.mmToIU( 0.2 ) ),
|
2022-09-16 23:42:20 +00:00
|
|
|
m_arrowLength( pcbIUScale.MilsToIU( 50 ) ),
|
2020-09-11 23:52:45 +00:00
|
|
|
m_extensionOffset( 0 ),
|
|
|
|
m_textPosition( DIM_TEXT_POSITION::OUTSIDE ),
|
|
|
|
m_keepTextAligned( true ),
|
2023-03-04 23:15:43 +00:00
|
|
|
m_measuredValue( 0 ),
|
|
|
|
m_inClearRenderCache( false )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2020-11-14 14:29:11 +00:00
|
|
|
m_layer = Dwgs_User;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2023-09-14 21:39:42 +00:00
|
|
|
bool PCB_DIMENSION_BASE::operator==( const BOARD_ITEM& aOther ) const
|
|
|
|
{
|
|
|
|
if( Type() != aOther.Type() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
const PCB_DIMENSION_BASE& other = static_cast<const PCB_DIMENSION_BASE&>( aOther );
|
|
|
|
|
|
|
|
if( m_textPosition != other.m_textPosition )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( m_keepTextAligned != other.m_keepTextAligned )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( m_units != other.m_units )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( m_autoUnits != other.m_autoUnits )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( m_unitsFormat != other.m_unitsFormat )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( m_precision != other.m_precision )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( m_suppressZeroes != other.m_suppressZeroes )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( m_lineThickness != other.m_lineThickness )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( m_arrowLength != other.m_arrowLength )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( m_extensionOffset != other.m_extensionOffset )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( m_measuredValue != other.m_measuredValue )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return EDA_TEXT::operator==( other );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double PCB_DIMENSION_BASE::Similarity( const BOARD_ITEM& aOther ) const
|
|
|
|
{
|
|
|
|
if( m_Uuid == aOther.m_Uuid )
|
|
|
|
return 1.0;
|
|
|
|
|
|
|
|
if( Type() != aOther.Type() )
|
|
|
|
return 0.0;
|
|
|
|
|
|
|
|
const PCB_DIMENSION_BASE& other = static_cast<const PCB_DIMENSION_BASE&>( aOther );
|
|
|
|
|
|
|
|
double similarity = 1.0;
|
|
|
|
|
|
|
|
if( m_textPosition != other.m_textPosition )
|
|
|
|
similarity *= 0.9;
|
|
|
|
|
|
|
|
if( m_keepTextAligned != other.m_keepTextAligned )
|
|
|
|
similarity *= 0.9;
|
|
|
|
|
|
|
|
if( m_units != other.m_units )
|
|
|
|
similarity *= 0.9;
|
|
|
|
|
|
|
|
if( m_autoUnits != other.m_autoUnits )
|
|
|
|
similarity *= 0.9;
|
|
|
|
|
|
|
|
if( m_unitsFormat != other.m_unitsFormat )
|
|
|
|
similarity *= 0.9;
|
|
|
|
|
|
|
|
if( m_precision != other.m_precision )
|
|
|
|
similarity *= 0.9;
|
|
|
|
|
|
|
|
if( m_suppressZeroes != other.m_suppressZeroes )
|
|
|
|
similarity *= 0.9;
|
|
|
|
|
|
|
|
if( m_lineThickness != other.m_lineThickness )
|
|
|
|
similarity *= 0.9;
|
|
|
|
|
|
|
|
if( m_arrowLength != other.m_arrowLength )
|
|
|
|
similarity *= 0.9;
|
|
|
|
|
|
|
|
if( m_extensionOffset != other.m_extensionOffset )
|
|
|
|
similarity *= 0.9;
|
|
|
|
|
|
|
|
if( m_measuredValue != other.m_measuredValue )
|
|
|
|
similarity *= 0.9;
|
|
|
|
|
|
|
|
similarity *= EDA_TEXT::Similarity( other );
|
|
|
|
|
|
|
|
return similarity;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
void PCB_DIMENSION_BASE::updateText()
|
2020-09-11 23:52:45 +00:00
|
|
|
{
|
|
|
|
wxString text = m_overrideTextEnabled ? m_valueString : GetValueText();
|
|
|
|
|
|
|
|
switch( m_unitsFormat )
|
|
|
|
{
|
|
|
|
case DIM_UNITS_FORMAT::NO_SUFFIX: // no units
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIM_UNITS_FORMAT::BARE_SUFFIX: // normal
|
2022-09-19 09:25:20 +00:00
|
|
|
text += EDA_UNIT_UTILS::GetText( m_units );
|
2020-09-11 23:52:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DIM_UNITS_FORMAT::PAREN_SUFFIX: // parenthetical
|
2022-09-19 09:25:20 +00:00
|
|
|
text += wxT( " (" ) + EDA_UNIT_UTILS::GetText( m_units ).Trim( false ) + wxT( ")" );
|
2020-09-11 23:52:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
text.Prepend( m_prefix );
|
|
|
|
text.Append( m_suffix );
|
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
SetText( text );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_DIMENSION_BASE::ClearRenderCache()
|
|
|
|
{
|
|
|
|
PCB_TEXT::ClearRenderCache();
|
|
|
|
|
|
|
|
// We use EDA_TEXT::ClearRenderCache() as a signal that the properties of the EDA_TEXT
|
|
|
|
// have changed and we may need to update the dimension text
|
|
|
|
|
|
|
|
if( !m_inClearRenderCache )
|
|
|
|
{
|
|
|
|
m_inClearRenderCache = true;
|
2024-05-22 05:56:37 +00:00
|
|
|
Update();
|
2023-03-04 23:15:43 +00:00
|
|
|
m_inClearRenderCache = false;
|
|
|
|
}
|
2020-09-11 23:52:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
template<typename ShapeType>
|
2021-06-11 16:59:28 +00:00
|
|
|
void PCB_DIMENSION_BASE::addShape( const ShapeType& aShape )
|
2020-09-12 20:09:40 +00:00
|
|
|
{
|
2020-10-01 19:11:35 +00:00
|
|
|
m_shapes.push_back( std::make_shared<ShapeType>( aShape ) );
|
2020-09-12 20:09:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
wxString PCB_DIMENSION_BASE::GetValueText() const
|
2020-09-11 23:52:45 +00:00
|
|
|
{
|
2020-09-30 22:26:37 +00:00
|
|
|
struct lconv* lc = localeconv();
|
|
|
|
wxChar sep = lc->decimal_point[0];
|
2020-09-11 23:52:45 +00:00
|
|
|
|
2020-09-30 22:26:37 +00:00
|
|
|
int val = GetMeasuredValue();
|
2023-03-05 13:27:22 +00:00
|
|
|
int precision = static_cast<int>( m_precision );
|
2020-09-11 23:52:45 +00:00
|
|
|
wxString text;
|
2022-04-17 13:02:19 +00:00
|
|
|
|
|
|
|
if( precision >= 6 )
|
|
|
|
{
|
|
|
|
switch( m_units )
|
|
|
|
{
|
|
|
|
case EDA_UNITS::INCHES: precision = precision - 4; break;
|
|
|
|
case EDA_UNITS::MILS: precision = std::max( 0, precision - 7 ); break;
|
|
|
|
case EDA_UNITS::MILLIMETRES: precision = precision - 5; break;
|
|
|
|
default: precision = precision - 4; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString format = wxT( "%." ) + wxString::Format( wxT( "%i" ), precision ) + wxT( "f" );
|
2020-09-11 23:52:45 +00:00
|
|
|
|
2022-09-16 04:38:10 +00:00
|
|
|
text.Printf( format, EDA_UNIT_UTILS::UI::ToUserUnit( pcbIUScale, m_units, val ) );
|
2020-09-11 23:52:45 +00:00
|
|
|
|
|
|
|
if( m_suppressZeroes )
|
|
|
|
{
|
|
|
|
while( text.Last() == '0' )
|
|
|
|
{
|
|
|
|
text.RemoveLast();
|
|
|
|
|
2020-09-30 22:26:37 +00:00
|
|
|
if( text.Last() == '.' || text.Last() == sep )
|
2020-09-11 23:52:45 +00:00
|
|
|
{
|
|
|
|
text.RemoveLast();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
void PCB_DIMENSION_BASE::SetPrefix( const wxString& aPrefix )
|
2020-09-11 23:52:45 +00:00
|
|
|
{
|
|
|
|
m_prefix = aPrefix;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
void PCB_DIMENSION_BASE::SetSuffix( const wxString& aSuffix )
|
2020-09-11 23:52:45 +00:00
|
|
|
{
|
|
|
|
m_suffix = aSuffix;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
void PCB_DIMENSION_BASE::SetUnits( EDA_UNITS aUnits )
|
2020-09-11 23:52:45 +00:00
|
|
|
{
|
|
|
|
m_units = aUnits;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
DIM_UNITS_MODE PCB_DIMENSION_BASE::GetUnitsMode() const
|
2012-12-19 19:31:36 +00:00
|
|
|
{
|
2020-09-09 03:17:08 +00:00
|
|
|
if( m_autoUnits )
|
2020-10-02 20:51:24 +00:00
|
|
|
{
|
2020-09-09 03:17:08 +00:00
|
|
|
return DIM_UNITS_MODE::AUTOMATIC;
|
2020-10-02 20:51:24 +00:00
|
|
|
}
|
2020-09-09 03:17:08 +00:00
|
|
|
else
|
2020-10-02 20:51:24 +00:00
|
|
|
{
|
|
|
|
switch( m_units )
|
|
|
|
{
|
|
|
|
default:
|
2021-12-04 23:52:00 +00:00
|
|
|
case EDA_UNITS::INCHES: return DIM_UNITS_MODE::INCHES;
|
|
|
|
case EDA_UNITS::MILLIMETRES: return DIM_UNITS_MODE::MILLIMETRES;
|
|
|
|
case EDA_UNITS::MILS: return DIM_UNITS_MODE::MILS;
|
2020-10-02 20:51:24 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-09 03:17:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
void PCB_DIMENSION_BASE::SetUnitsMode( DIM_UNITS_MODE aMode )
|
2020-09-09 03:17:08 +00:00
|
|
|
{
|
|
|
|
switch( aMode )
|
|
|
|
{
|
2023-03-05 13:27:22 +00:00
|
|
|
case DIM_UNITS_MODE::INCHES:
|
|
|
|
m_autoUnits = false;
|
|
|
|
m_units = EDA_UNITS::INCHES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIM_UNITS_MODE::MILS:
|
|
|
|
m_autoUnits = false;
|
|
|
|
m_units = EDA_UNITS::MILS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIM_UNITS_MODE::MILLIMETRES:
|
|
|
|
m_autoUnits = false;
|
|
|
|
m_units = EDA_UNITS::MILLIMETRES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIM_UNITS_MODE::AUTOMATIC:
|
|
|
|
m_autoUnits = true;
|
2023-03-07 09:09:34 +00:00
|
|
|
m_units = GetBoard() ? GetBoard()->GetUserUnits() : EDA_UNITS::MILLIMETRES;
|
2023-03-05 13:27:22 +00:00
|
|
|
break;
|
2020-09-09 03:17:08 +00:00
|
|
|
}
|
2012-12-19 19:31:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-05-22 05:56:37 +00:00
|
|
|
void PCB_DIMENSION_BASE::ChangeTextAngleDegrees( double aDegrees )
|
2024-05-20 09:28:29 +00:00
|
|
|
{
|
|
|
|
SetTextAngleDegrees( aDegrees );
|
|
|
|
// Create or repair any knockouts
|
|
|
|
Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-05-22 05:56:37 +00:00
|
|
|
void PCB_DIMENSION_BASE::ChangeKeepTextAligned( bool aKeepAligned )
|
2024-05-20 09:28:29 +00:00
|
|
|
{
|
|
|
|
SetKeepTextAligned( aKeepAligned );
|
|
|
|
// Re-align the text and repair any knockouts
|
|
|
|
Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void PCB_DIMENSION_BASE::Move( const VECTOR2I& offset )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2023-03-04 23:15:43 +00:00
|
|
|
PCB_TEXT::Offset( offset );
|
2020-09-09 03:17:08 +00:00
|
|
|
|
|
|
|
m_start += offset;
|
|
|
|
m_end += offset;
|
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
Update();
|
2008-01-06 12:43:57 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2022-01-13 19:32:00 +00:00
|
|
|
void PCB_DIMENSION_BASE::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
2023-03-04 23:15:43 +00:00
|
|
|
EDA_ANGLE newAngle = GetTextAngle() + aAngle;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2022-01-13 19:32:00 +00:00
|
|
|
newAngle.Normalize();
|
2011-11-29 17:25:30 +00:00
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
SetTextAngle( newAngle );
|
2020-09-09 03:17:08 +00:00
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
VECTOR2I pt = GetTextPos();
|
2021-12-29 21:30:11 +00:00
|
|
|
RotatePoint( pt, aRotCentre, aAngle );
|
2023-03-04 23:15:43 +00:00
|
|
|
SetTextPos( pt );
|
2020-11-21 23:52:36 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
RotatePoint( m_start, aRotCentre, aAngle );
|
|
|
|
RotatePoint( m_end, aRotCentre, aAngle );
|
2020-11-21 23:52:36 +00:00
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
Update();
|
2008-01-06 12:43:57 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void PCB_DIMENSION_BASE::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
|
|
|
Mirror( aCentre );
|
2015-12-27 15:51:13 +00:00
|
|
|
|
2021-02-20 12:16:45 +00:00
|
|
|
SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) );
|
2009-08-01 19:26:05 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void PCB_DIMENSION_BASE::Mirror( const VECTOR2I& axis_pos, bool aMirrorLeftRight )
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
2019-07-12 21:02:10 +00:00
|
|
|
int axis = aMirrorLeftRight ? axis_pos.x : axis_pos.y;
|
2023-03-04 23:15:43 +00:00
|
|
|
VECTOR2I newPos = GetTextPos();
|
2013-03-18 19:36:07 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
#define INVERT( pos ) ( ( pos ) = axis - ( ( pos ) - axis ) )
|
2019-07-12 21:02:10 +00:00
|
|
|
if( aMirrorLeftRight )
|
|
|
|
INVERT( newPos.x );
|
|
|
|
else
|
|
|
|
INVERT( newPos.y );
|
2013-03-18 19:36:07 +00:00
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
SetTextPos( newPos );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-11-29 17:25:30 +00:00
|
|
|
// invert angle
|
2023-03-04 23:15:43 +00:00
|
|
|
SetTextAngle( -GetTextAngle() );
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2019-07-12 21:02:10 +00:00
|
|
|
if( aMirrorLeftRight )
|
|
|
|
{
|
2020-09-09 03:17:08 +00:00
|
|
|
INVERT( m_start.x );
|
|
|
|
INVERT( m_end.x );
|
2019-07-12 21:02:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-09 03:17:08 +00:00
|
|
|
INVERT( m_start.y );
|
|
|
|
INVERT( m_end.y );
|
2019-07-12 21:02:10 +00:00
|
|
|
}
|
2014-02-11 12:22:30 +00:00
|
|
|
|
2022-10-25 11:08:32 +00:00
|
|
|
if( ( GetLayerSet() & LSET::SideSpecificMask() ).any() )
|
2023-03-04 23:15:43 +00:00
|
|
|
SetMirrored( !IsMirrored() );
|
2020-11-03 22:45:26 +00:00
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
Update();
|
2014-02-11 12:22:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void PCB_DIMENSION_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame,
|
|
|
|
std::vector<MSG_PANEL_ITEM>& aList )
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
// for now, display only the text within the DIMENSION using class PCB_TEXT.
|
2020-09-24 21:23:16 +00:00
|
|
|
wxString msg;
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
wxCHECK_RET( m_parent != nullptr, wxT( "PCB_TEXT::GetMsgPanelInfo() m_Parent is NULL." ) );
|
2020-09-24 21:23:16 +00:00
|
|
|
|
2023-05-05 13:21:56 +00:00
|
|
|
// Don't use GetShownText(); we want to see the variable references here
|
|
|
|
aList.emplace_back( _( "Dimension" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
|
2020-09-24 21:23:16 +00:00
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Prefix" ), GetPrefix() );
|
2020-09-24 21:23:16 +00:00
|
|
|
|
|
|
|
if( GetOverrideTextEnabled() )
|
|
|
|
{
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Override Text" ), GetOverrideText() );
|
2020-09-24 21:23:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Value" ), GetValueText() );
|
2020-09-24 21:23:16 +00:00
|
|
|
|
2022-04-17 13:02:19 +00:00
|
|
|
switch( GetPrecision() )
|
|
|
|
{
|
2023-03-05 13:27:22 +00:00
|
|
|
case DIM_PRECISION::V_VV: msg = wxT( "0.00 in / 0 mils / 0.0 mm" ); break;
|
|
|
|
case DIM_PRECISION::V_VVV: msg = wxT( "0.000 in / 0 mils / 0.00 mm" ); break;
|
|
|
|
case DIM_PRECISION::V_VVVV: msg = wxT( "0.0000 in / 0.0 mils / 0.000 mm" ); break;
|
|
|
|
case DIM_PRECISION::V_VVVVV: msg = wxT( "0.00000 in / 0.00 mils / 0.0000 mm" ); break;
|
|
|
|
default: msg = wxT( "%" ) + wxString::Format( wxT( "1.%df" ), GetPrecision() );
|
2022-04-17 13:02:19 +00:00
|
|
|
}
|
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Precision" ), wxString::Format( msg, 0.0 ) );
|
2020-09-24 21:23:16 +00:00
|
|
|
}
|
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Suffix" ), GetSuffix() );
|
2020-09-24 21:23:16 +00:00
|
|
|
|
2022-09-19 16:09:59 +00:00
|
|
|
// Use our own UNITS_PROVIDER to report dimension info in dimension's units rather than
|
|
|
|
// in frame's units.
|
|
|
|
UNITS_PROVIDER unitsProvider( pcbIUScale, EDA_UNITS::MILLIMETRES );
|
|
|
|
unitsProvider.SetUserUnits( GetUnits() );
|
2020-09-24 21:23:16 +00:00
|
|
|
|
2022-09-19 16:09:59 +00:00
|
|
|
aList.emplace_back( _( "Units" ), EDA_UNIT_UTILS::GetLabel( GetUnits() ) );
|
2020-09-24 23:40:35 +00:00
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
|
|
|
|
aList.emplace_back( _( "Text Thickness" ), unitsProvider.MessageTextFromValue( GetTextThickness() ) );
|
|
|
|
aList.emplace_back( _( "Text Width" ), unitsProvider.MessageTextFromValue( GetTextWidth() ) );
|
|
|
|
aList.emplace_back( _( "Text Height" ), unitsProvider.MessageTextFromValue( GetTextHeight() ) );
|
2022-04-26 17:52:53 +00:00
|
|
|
|
2023-11-09 18:40:47 +00:00
|
|
|
ORIGIN_TRANSFORMS& originTransforms = aFrame->GetOriginTransforms();
|
2020-09-24 23:40:35 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
if( Type() == PCB_DIM_CENTER_T )
|
2020-09-24 23:40:35 +00:00
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I startCoord = originTransforms.ToDisplayAbs( GetStart() );
|
2022-02-04 22:44:59 +00:00
|
|
|
wxString start = wxString::Format( wxT( "@(%s, %s)" ),
|
2022-09-19 16:09:59 +00:00
|
|
|
aFrame->MessageTextFromValue( startCoord.x ),
|
|
|
|
aFrame->MessageTextFromValue( startCoord.y ) );
|
2020-09-24 23:40:35 +00:00
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( start, wxEmptyString );
|
2020-09-24 23:40:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I startCoord = originTransforms.ToDisplayAbs( GetStart() );
|
2022-02-04 22:44:59 +00:00
|
|
|
wxString start = wxString::Format( wxT( "@(%s, %s)" ),
|
2022-09-19 16:09:59 +00:00
|
|
|
aFrame->MessageTextFromValue( startCoord.x ),
|
|
|
|
aFrame->MessageTextFromValue( startCoord.y ) );
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I endCoord = originTransforms.ToDisplayAbs( GetEnd() );
|
2022-02-04 22:44:59 +00:00
|
|
|
wxString end = wxString::Format( wxT( "@(%s, %s)" ),
|
2022-09-19 16:09:59 +00:00
|
|
|
aFrame->MessageTextFromValue( endCoord.x ),
|
|
|
|
aFrame->MessageTextFromValue( endCoord.y ) );
|
2020-09-24 23:40:35 +00:00
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( start, end );
|
2020-09-24 23:40:35 +00:00
|
|
|
}
|
|
|
|
|
2021-10-31 16:32:24 +00:00
|
|
|
if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
|
2021-04-21 14:40:16 +00:00
|
|
|
aList.emplace_back( _( "Status" ), _( "Locked" ) );
|
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Layer" ), GetLayerName() );
|
2007-08-20 19:33:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-03-16 23:48:24 +00:00
|
|
|
std::shared_ptr<SHAPE> PCB_DIMENSION_BASE::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
|
2020-09-19 11:47:43 +00:00
|
|
|
{
|
2020-10-31 21:00:40 +00:00
|
|
|
std::shared_ptr<SHAPE_COMPOUND> effectiveShape = std::make_shared<SHAPE_COMPOUND>();
|
2020-10-31 19:13:30 +00:00
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
effectiveShape->AddShape( GetEffectiveTextShape()->Clone() );
|
2020-09-19 11:47:43 +00:00
|
|
|
|
|
|
|
for( const std::shared_ptr<SHAPE>& shape : GetShapes() )
|
2020-10-31 21:00:40 +00:00
|
|
|
effectiveShape->AddShape( shape->Clone() );
|
2020-09-19 11:47:43 +00:00
|
|
|
|
2020-10-31 21:00:40 +00:00
|
|
|
return effectiveShape;
|
2020-09-19 11:47:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
bool PCB_DIMENSION_BASE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2023-03-04 23:15:43 +00:00
|
|
|
if( TextHitTest( aPosition ) )
|
2011-09-20 15:07:52 +00:00
|
|
|
return true;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
int dist_max = aAccuracy + ( m_lineThickness / 2 );
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2012-12-27 16:42:41 +00:00
|
|
|
// Locate SEGMENTS
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
for( const std::shared_ptr<SHAPE>& shape : GetShapes() )
|
2020-09-09 03:17:08 +00:00
|
|
|
{
|
2020-09-12 20:09:40 +00:00
|
|
|
if( shape->Collide( aPosition, dist_max ) )
|
2020-09-09 03:17:08 +00:00
|
|
|
return true;
|
|
|
|
}
|
2007-08-08 20:51:08 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
|
2022-08-31 09:33:46 +00:00
|
|
|
bool PCB_DIMENSION_BASE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
2022-08-31 09:33:46 +00:00
|
|
|
BOX2I arect = aRect;
|
2013-09-21 18:09:41 +00:00
|
|
|
arect.Inflate( aAccuracy );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2022-08-31 09:33:46 +00:00
|
|
|
BOX2I rect = GetBoundingBox();
|
2020-09-17 00:54:58 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
if( aAccuracy )
|
|
|
|
rect.Inflate( aAccuracy );
|
|
|
|
|
|
|
|
if( aContained )
|
|
|
|
return arect.Contains( rect );
|
|
|
|
|
|
|
|
return arect.Intersects( rect );
|
2008-01-06 12:43:57 +00:00
|
|
|
}
|
2011-02-25 16:23:24 +00:00
|
|
|
|
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I PCB_DIMENSION_BASE::GetBoundingBox() const
|
2011-02-25 16:23:24 +00:00
|
|
|
{
|
2022-08-31 09:15:42 +00:00
|
|
|
BOX2I bBox;
|
|
|
|
int xmin, xmax, ymin, ymax;
|
2012-12-19 19:31:36 +00:00
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
bBox = GetTextBox();
|
2012-12-19 19:31:36 +00:00
|
|
|
xmin = bBox.GetX();
|
|
|
|
xmax = bBox.GetRight();
|
|
|
|
ymin = bBox.GetY();
|
|
|
|
ymax = bBox.GetBottom();
|
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
for( const std::shared_ptr<SHAPE>& shape : GetShapes() )
|
2020-09-09 03:17:08 +00:00
|
|
|
{
|
2020-09-12 20:09:40 +00:00
|
|
|
BOX2I shapeBox = shape->BBox();
|
2020-09-17 00:54:58 +00:00
|
|
|
shapeBox.Inflate( m_lineThickness / 2 );
|
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
xmin = std::min( xmin, shapeBox.GetOrigin().x );
|
|
|
|
xmax = std::max( xmax, shapeBox.GetEnd().x );
|
|
|
|
ymin = std::min( ymin, shapeBox.GetOrigin().y );
|
|
|
|
ymax = std::max( ymax, shapeBox.GetEnd().y );
|
2020-09-09 03:17:08 +00:00
|
|
|
}
|
2013-09-16 12:44:03 +00:00
|
|
|
|
2011-02-25 16:23:24 +00:00
|
|
|
bBox.SetX( xmin );
|
|
|
|
bBox.SetY( ymin );
|
|
|
|
bBox.SetWidth( xmax - xmin + 1 );
|
|
|
|
bBox.SetHeight( ymax - ymin + 1 );
|
|
|
|
|
|
|
|
bBox.Normalize();
|
|
|
|
|
|
|
|
return bBox;
|
|
|
|
}
|
2011-07-14 15:42:44 +00:00
|
|
|
|
|
|
|
|
2023-01-12 03:27:44 +00:00
|
|
|
wxString PCB_DIMENSION_BASE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
|
2011-07-14 15:42:44 +00:00
|
|
|
{
|
2023-05-05 13:21:56 +00:00
|
|
|
return wxString::Format( _( "Dimension '%s' on %s" ),
|
|
|
|
KIUI::EllipsizeMenuText( GetText() ),
|
|
|
|
GetLayerName() );
|
2011-07-14 15:42:44 +00:00
|
|
|
}
|
2012-01-14 19:50:32 +00:00
|
|
|
|
|
|
|
|
2017-02-20 12:20:39 +00:00
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
const BOX2I PCB_DIMENSION_BASE::ViewBBox() const
|
2013-09-16 12:44:03 +00:00
|
|
|
{
|
|
|
|
BOX2I dimBBox = BOX2I( VECTOR2I( GetBoundingBox().GetPosition() ),
|
|
|
|
VECTOR2I( GetBoundingBox().GetSize() ) );
|
2023-03-04 23:15:43 +00:00
|
|
|
dimBBox.Merge( PCB_TEXT::ViewBBox() );
|
2013-09-16 12:44:03 +00:00
|
|
|
|
|
|
|
return dimBBox;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
OPT_VECTOR2I PCB_DIMENSION_BASE::segPolyIntersection( const SHAPE_POLY_SET& aPoly, const SEG& aSeg,
|
|
|
|
bool aStart )
|
2020-09-12 20:09:40 +00:00
|
|
|
{
|
|
|
|
VECTOR2I start( aStart ? aSeg.A : aSeg.B );
|
|
|
|
VECTOR2I endpoint( aStart ? aSeg.B : aSeg.A );
|
|
|
|
|
|
|
|
if( aPoly.Contains( start ) )
|
2022-08-25 22:50:47 +00:00
|
|
|
return std::nullopt;
|
2020-09-12 20:09:40 +00:00
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
for( SHAPE_POLY_SET::CONST_SEGMENT_ITERATOR seg = aPoly.CIterateSegments(); seg; ++seg )
|
2020-09-12 20:09:40 +00:00
|
|
|
{
|
|
|
|
if( OPT_VECTOR2I intersection = ( *seg ).Intersect( aSeg ) )
|
|
|
|
{
|
|
|
|
if( ( *intersection - start ).SquaredEuclideanNorm() <
|
|
|
|
( endpoint - start ).SquaredEuclideanNorm() )
|
|
|
|
endpoint = *intersection;
|
|
|
|
}
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
if( start == endpoint )
|
2022-08-25 22:50:47 +00:00
|
|
|
return std::nullopt;
|
2020-09-12 20:09:40 +00:00
|
|
|
|
|
|
|
return OPT_VECTOR2I( endpoint );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
OPT_VECTOR2I PCB_DIMENSION_BASE::segCircleIntersection( CIRCLE& aCircle, SEG& aSeg, bool aStart )
|
2021-03-05 23:10:18 +00:00
|
|
|
{
|
|
|
|
VECTOR2I start( aStart ? aSeg.A : aSeg.B );
|
|
|
|
VECTOR2I endpoint( aStart ? aSeg.B : aSeg.A );
|
|
|
|
|
|
|
|
if( aCircle.Contains( start ) )
|
2022-08-25 22:50:47 +00:00
|
|
|
return std::nullopt;
|
2021-03-05 23:10:18 +00:00
|
|
|
|
|
|
|
std::vector<VECTOR2I> intersections = aCircle.Intersect( aSeg );
|
|
|
|
|
|
|
|
for( VECTOR2I& intersection : aCircle.Intersect( aSeg ) )
|
|
|
|
{
|
|
|
|
if( ( intersection - start ).SquaredEuclideanNorm() <
|
|
|
|
( endpoint - start ).SquaredEuclideanNorm() )
|
|
|
|
endpoint = intersection;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( start == endpoint )
|
2022-08-25 22:50:47 +00:00
|
|
|
return std::nullopt;
|
2021-03-05 23:10:18 +00:00
|
|
|
|
|
|
|
return OPT_VECTOR2I( endpoint );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-21 12:48:45 +00:00
|
|
|
void PCB_DIMENSION_BASE::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer,
|
|
|
|
int aClearance, int aError, ERROR_LOC aErrorLoc,
|
|
|
|
bool aIgnoreLineWidth ) const
|
2021-10-25 19:50:33 +00:00
|
|
|
{
|
2022-02-04 22:44:59 +00:00
|
|
|
wxASSERT_MSG( !aIgnoreLineWidth, wxT( "IgnoreLineWidth has no meaning for dimensions." ) );
|
2021-10-25 19:50:33 +00:00
|
|
|
|
|
|
|
for( const std::shared_ptr<SHAPE>& shape : m_shapes )
|
|
|
|
{
|
|
|
|
const SHAPE_CIRCLE* circle = dynamic_cast<const SHAPE_CIRCLE*>( shape.get() );
|
|
|
|
const SHAPE_SEGMENT* seg = dynamic_cast<const SHAPE_SEGMENT*>( shape.get() );
|
|
|
|
|
|
|
|
if( circle )
|
|
|
|
{
|
2022-10-21 12:48:45 +00:00
|
|
|
TransformCircleToPolygon( aBuffer, circle->GetCenter(),
|
2021-10-25 19:50:33 +00:00
|
|
|
circle->GetRadius() + m_lineThickness / 2 + aClearance,
|
|
|
|
aError, aErrorLoc );
|
|
|
|
}
|
|
|
|
else if( seg )
|
|
|
|
{
|
2022-10-21 12:48:45 +00:00
|
|
|
TransformOvalToPolygon( aBuffer, seg->GetSeg().A, seg->GetSeg().B,
|
|
|
|
m_lineThickness + 2 * aClearance, aError, aErrorLoc );
|
2021-10-25 19:50:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-10-21 12:48:45 +00:00
|
|
|
wxFAIL_MSG( wxT( "PCB_DIMENSION_BASE::TransformShapeToPolygon unknown shape type." ) );
|
2021-10-25 19:50:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
PCB_DIM_ALIGNED::PCB_DIM_ALIGNED( BOARD_ITEM* aParent, KICAD_T aType ) :
|
|
|
|
PCB_DIMENSION_BASE( aParent, aType ),
|
2020-09-09 03:17:08 +00:00
|
|
|
m_height( 0 )
|
|
|
|
{
|
|
|
|
// To preserve look of old dimensions, initialize extension height based on default arrow length
|
2022-01-20 23:08:48 +00:00
|
|
|
m_extensionHeight = static_cast<int>( m_arrowLength * s_arrowAngle.Sin() );
|
2020-09-09 03:17:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
EDA_ITEM* PCB_DIM_ALIGNED::Clone() const
|
2012-01-14 19:50:32 +00:00
|
|
|
{
|
2021-06-11 16:59:28 +00:00
|
|
|
return new PCB_DIM_ALIGNED( *this );
|
2012-01-14 19:50:32 +00:00
|
|
|
}
|
2017-10-31 13:59:03 +00:00
|
|
|
|
2020-02-02 18:40:14 +00:00
|
|
|
|
2022-11-11 17:09:25 +00:00
|
|
|
void PCB_DIM_ALIGNED::swapData( BOARD_ITEM* aImage )
|
2017-10-31 13:59:03 +00:00
|
|
|
{
|
2021-12-04 23:52:00 +00:00
|
|
|
wxASSERT( aImage->Type() == Type() );
|
2020-09-12 20:09:40 +00:00
|
|
|
|
|
|
|
m_shapes.clear();
|
2021-06-11 16:59:28 +00:00
|
|
|
static_cast<PCB_DIM_ALIGNED*>( aImage )->m_shapes.clear();
|
2017-10-31 13:59:03 +00:00
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
std::swap( *static_cast<PCB_DIM_ALIGNED*>( this ), *static_cast<PCB_DIM_ALIGNED*>( aImage ) );
|
2020-09-12 20:09:40 +00:00
|
|
|
|
|
|
|
Update();
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2022-06-20 20:15:21 +00:00
|
|
|
void PCB_DIM_ALIGNED::Mirror( const VECTOR2I& axis_pos, bool aMirrorLeftRight )
|
|
|
|
{
|
|
|
|
PCB_DIMENSION_BASE::Mirror( axis_pos, aMirrorLeftRight );
|
|
|
|
|
|
|
|
m_height = -m_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
BITMAPS PCB_DIM_ALIGNED::GetMenuImage() const
|
2020-09-12 20:09:40 +00:00
|
|
|
{
|
2021-03-08 02:59:07 +00:00
|
|
|
return BITMAPS::add_aligned_dimension;
|
2017-10-31 13:59:03 +00:00
|
|
|
}
|
2020-02-02 18:40:14 +00:00
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void PCB_DIM_ALIGNED::UpdateHeight( const VECTOR2I& aCrossbarStart, const VECTOR2I& aCrossbarEnd )
|
2020-09-09 03:17:08 +00:00
|
|
|
{
|
|
|
|
VECTOR2D height( aCrossbarStart - GetStart() );
|
|
|
|
VECTOR2D crossBar( aCrossbarEnd - aCrossbarStart );
|
|
|
|
|
|
|
|
if( height.Cross( crossBar ) > 0 )
|
|
|
|
m_height = -height.EuclideanNorm();
|
|
|
|
else
|
|
|
|
m_height = height.EuclideanNorm();
|
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
Update();
|
2020-09-09 03:17:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
void PCB_DIM_ALIGNED::updateGeometry()
|
2020-09-09 03:17:08 +00:00
|
|
|
{
|
2020-09-12 20:09:40 +00:00
|
|
|
m_shapes.clear();
|
2020-09-09 03:17:08 +00:00
|
|
|
|
|
|
|
VECTOR2I dimension( m_end - m_start );
|
|
|
|
|
|
|
|
m_measuredValue = KiROUND( dimension.EuclideanNorm() );
|
|
|
|
|
|
|
|
VECTOR2I extension;
|
|
|
|
|
|
|
|
if( m_height > 0 )
|
|
|
|
extension = VECTOR2I( -dimension.y, dimension.x );
|
|
|
|
else
|
|
|
|
extension = VECTOR2I( dimension.y, -dimension.x );
|
|
|
|
|
|
|
|
// Add extension lines
|
|
|
|
int extensionHeight = std::abs( m_height ) - m_extensionOffset + m_extensionHeight;
|
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
VECTOR2I extStart( m_start );
|
|
|
|
extStart += extension.Resize( m_extensionOffset );
|
2020-09-09 03:17:08 +00:00
|
|
|
|
2020-10-01 19:11:35 +00:00
|
|
|
addShape( SHAPE_SEGMENT( extStart, extStart + extension.Resize( extensionHeight ) ) );
|
2020-09-09 03:17:08 +00:00
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
extStart = VECTOR2I( m_end );
|
|
|
|
extStart += extension.Resize( m_extensionOffset );
|
2020-09-09 03:17:08 +00:00
|
|
|
|
2020-10-01 19:11:35 +00:00
|
|
|
addShape( SHAPE_SEGMENT( extStart, extStart + extension.Resize( extensionHeight ) ) );
|
2020-09-09 03:17:08 +00:00
|
|
|
|
|
|
|
// Add crossbar
|
|
|
|
VECTOR2I crossBarDistance = sign( m_height ) * extension.Resize( m_height );
|
2022-01-01 18:08:03 +00:00
|
|
|
m_crossBarStart = m_start + crossBarDistance;
|
|
|
|
m_crossBarEnd = m_end + crossBarDistance;
|
2020-09-09 03:17:08 +00:00
|
|
|
|
|
|
|
// Update text after calculating crossbar position but before adding crossbar lines
|
|
|
|
updateText();
|
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
// Now that we have the text updated, we can determine how to draw the crossbar.
|
|
|
|
// First we need to create an appropriate bounding polygon to collide with
|
2023-03-04 23:15:43 +00:00
|
|
|
BOX2I textBox = GetTextBox().Inflate( GetTextWidth() / 2, - GetEffectiveTextPenWidth() );
|
2020-09-11 23:52:45 +00:00
|
|
|
|
|
|
|
SHAPE_POLY_SET polyBox;
|
|
|
|
polyBox.NewOutline();
|
|
|
|
polyBox.Append( textBox.GetOrigin() );
|
|
|
|
polyBox.Append( textBox.GetOrigin().x, textBox.GetEnd().y );
|
|
|
|
polyBox.Append( textBox.GetEnd() );
|
|
|
|
polyBox.Append( textBox.GetEnd().x, textBox.GetOrigin().y );
|
2023-03-04 23:15:43 +00:00
|
|
|
polyBox.Rotate( GetTextAngle(), textBox.GetCenter() );
|
2020-09-11 23:52:45 +00:00
|
|
|
|
|
|
|
// The ideal crossbar, if the text doesn't collide
|
|
|
|
SEG crossbar( m_crossBarStart, m_crossBarEnd );
|
|
|
|
|
|
|
|
// Now we can draw 0, 1, or 2 crossbar lines depending on how the polygon collides
|
|
|
|
bool containsA = polyBox.Contains( crossbar.A );
|
|
|
|
bool containsB = polyBox.Contains( crossbar.B );
|
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
OPT_VECTOR2I endpointA = segPolyIntersection( polyBox, crossbar );
|
|
|
|
OPT_VECTOR2I endpointB = segPolyIntersection( polyBox, crossbar, false );
|
2020-09-09 03:17:08 +00:00
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
if( endpointA )
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( crossbar.A, *endpointA ) );
|
2020-09-11 23:52:45 +00:00
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
if( endpointB )
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( *endpointB, crossbar.B ) );
|
|
|
|
|
|
|
|
if( !containsA && !containsB && !endpointA && !endpointB )
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( crossbar ) );
|
2020-09-09 03:17:08 +00:00
|
|
|
|
|
|
|
// Add arrows
|
2022-01-20 23:08:48 +00:00
|
|
|
VECTOR2I arrowEndPos( m_arrowLength, 0 );
|
|
|
|
VECTOR2I arrowEndNeg( m_arrowLength, 0 );
|
2022-01-21 14:27:50 +00:00
|
|
|
RotatePoint( arrowEndPos, -EDA_ANGLE( dimension ) + s_arrowAngle );
|
|
|
|
RotatePoint( arrowEndNeg, -EDA_ANGLE( dimension ) - s_arrowAngle );
|
2022-01-20 23:08:48 +00:00
|
|
|
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarStart, m_crossBarStart + arrowEndPos ) );
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarStart, m_crossBarStart + arrowEndNeg ) );
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarEnd, m_crossBarEnd - arrowEndPos ) );
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarEnd, m_crossBarEnd - arrowEndNeg ) );
|
2020-09-09 03:17:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
void PCB_DIM_ALIGNED::updateText()
|
2020-09-09 03:17:08 +00:00
|
|
|
{
|
|
|
|
VECTOR2I crossbarCenter( ( m_crossBarEnd - m_crossBarStart ) / 2 );
|
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
if( m_textPosition == DIM_TEXT_POSITION::OUTSIDE )
|
2020-09-09 03:17:08 +00:00
|
|
|
{
|
2023-03-04 23:15:43 +00:00
|
|
|
int textOffsetDistance = GetEffectiveTextPenWidth() + GetTextHeight();
|
2022-01-20 23:08:48 +00:00
|
|
|
EDA_ANGLE rotation;
|
|
|
|
|
2021-02-21 22:44:41 +00:00
|
|
|
if( crossbarCenter.x == 0 )
|
2022-01-20 23:08:48 +00:00
|
|
|
rotation = ANGLE_90 * sign( -crossbarCenter.y );
|
|
|
|
else if( crossbarCenter.x < 0 )
|
|
|
|
rotation = -ANGLE_90;
|
2021-02-21 22:44:41 +00:00
|
|
|
else
|
2022-01-20 23:08:48 +00:00
|
|
|
rotation = ANGLE_90;
|
2021-02-21 22:44:41 +00:00
|
|
|
|
2022-01-20 23:08:48 +00:00
|
|
|
VECTOR2I textOffset = crossbarCenter;
|
2022-02-19 09:24:44 +00:00
|
|
|
RotatePoint( textOffset, rotation );
|
|
|
|
textOffset = crossbarCenter + textOffset.Resize( textOffsetDistance );
|
2020-09-09 03:17:08 +00:00
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
SetTextPos( m_crossBarStart + textOffset );
|
2020-09-09 03:17:08 +00:00
|
|
|
}
|
2020-09-11 23:52:45 +00:00
|
|
|
else if( m_textPosition == DIM_TEXT_POSITION::INLINE )
|
|
|
|
{
|
2023-03-04 23:15:43 +00:00
|
|
|
SetTextPos( m_crossBarStart + crossbarCenter );
|
2020-09-11 23:52:45 +00:00
|
|
|
}
|
2020-09-09 03:17:08 +00:00
|
|
|
|
|
|
|
if( m_keepTextAligned )
|
2020-09-22 02:32:40 +00:00
|
|
|
{
|
2022-01-20 23:08:48 +00:00
|
|
|
EDA_ANGLE textAngle = FULL_CIRCLE - EDA_ANGLE( crossbarCenter );
|
2022-01-13 23:30:52 +00:00
|
|
|
textAngle.Normalize();
|
2020-09-22 02:32:40 +00:00
|
|
|
|
2022-01-13 23:30:52 +00:00
|
|
|
if( textAngle > ANGLE_90 && textAngle <= ANGLE_270 )
|
|
|
|
textAngle -= ANGLE_180;
|
2020-09-22 02:32:40 +00:00
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
SetTextAngle( textAngle );
|
2020-09-22 02:32:40 +00:00
|
|
|
}
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
PCB_DIMENSION_BASE::updateText();
|
2020-09-22 02:32:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
void PCB_DIM_ALIGNED::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
|
2021-01-19 16:08:37 +00:00
|
|
|
{
|
2021-06-11 16:59:28 +00:00
|
|
|
PCB_DIMENSION_BASE::GetMsgPanelInfo( aFrame, aList );
|
2021-01-19 16:08:37 +00:00
|
|
|
|
2022-09-19 16:09:59 +00:00
|
|
|
// Use our own UNITS_PROVIDER to report dimension info in dimension's units rather than
|
|
|
|
// in frame's units.
|
|
|
|
UNITS_PROVIDER unitsProvider( pcbIUScale, EDA_UNITS::MILLIMETRES );
|
|
|
|
unitsProvider.SetUserUnits( GetUnits() );
|
2022-09-19 09:25:20 +00:00
|
|
|
|
2022-09-19 16:09:59 +00:00
|
|
|
aList.emplace_back( _( "Height" ), unitsProvider.MessageTextFromValue( m_height ) );
|
2021-01-19 16:08:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
PCB_DIM_ORTHOGONAL::PCB_DIM_ORTHOGONAL( BOARD_ITEM* aParent ) :
|
|
|
|
PCB_DIM_ALIGNED( aParent, PCB_DIM_ORTHOGONAL_T )
|
2020-09-22 02:32:40 +00:00
|
|
|
{
|
|
|
|
// To preserve look of old dimensions, initialize extension height based on default arrow length
|
2022-01-20 23:08:48 +00:00
|
|
|
m_extensionHeight = static_cast<int>( m_arrowLength * s_arrowAngle.Sin() );
|
2020-10-03 10:47:41 +00:00
|
|
|
m_orientation = DIR::HORIZONTAL;
|
2020-09-22 02:32:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
EDA_ITEM* PCB_DIM_ORTHOGONAL::Clone() const
|
2020-09-22 02:32:40 +00:00
|
|
|
{
|
2021-06-11 16:59:28 +00:00
|
|
|
return new PCB_DIM_ORTHOGONAL( *this );
|
2020-09-22 02:32:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-11 17:09:25 +00:00
|
|
|
void PCB_DIM_ORTHOGONAL::swapData( BOARD_ITEM* aImage )
|
2020-09-22 02:32:40 +00:00
|
|
|
{
|
2021-12-04 23:52:00 +00:00
|
|
|
wxASSERT( aImage->Type() == Type() );
|
2020-09-22 02:32:40 +00:00
|
|
|
|
|
|
|
m_shapes.clear();
|
2021-06-11 16:59:28 +00:00
|
|
|
static_cast<PCB_DIM_ORTHOGONAL*>( aImage )->m_shapes.clear();
|
2020-09-22 02:32:40 +00:00
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
std::swap( *static_cast<PCB_DIM_ORTHOGONAL*>( this ),
|
|
|
|
*static_cast<PCB_DIM_ORTHOGONAL*>( aImage ) );
|
2020-09-22 02:32:40 +00:00
|
|
|
|
|
|
|
Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
BITMAPS PCB_DIM_ORTHOGONAL::GetMenuImage() const
|
2020-09-22 02:32:40 +00:00
|
|
|
{
|
2021-03-08 02:59:07 +00:00
|
|
|
return BITMAPS::add_orthogonal_dimension;
|
2020-09-22 02:32:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
void PCB_DIM_ORTHOGONAL::updateGeometry()
|
2020-09-22 02:32:40 +00:00
|
|
|
{
|
|
|
|
m_shapes.clear();
|
|
|
|
|
|
|
|
int measurement = ( m_orientation == DIR::HORIZONTAL ? m_end.x - m_start.x :
|
|
|
|
m_end.y - m_start.y );
|
|
|
|
m_measuredValue = KiROUND( std::abs( measurement ) );
|
|
|
|
|
|
|
|
VECTOR2I extension;
|
|
|
|
|
|
|
|
if( m_orientation == DIR::HORIZONTAL )
|
|
|
|
extension = VECTOR2I( 0, m_height );
|
|
|
|
else
|
|
|
|
extension = VECTOR2I( m_height, 0 );
|
|
|
|
|
|
|
|
// Add first extension line
|
|
|
|
int extensionHeight = std::abs( m_height ) - m_extensionOffset + m_extensionHeight;
|
|
|
|
|
|
|
|
VECTOR2I extStart( m_start );
|
|
|
|
extStart += extension.Resize( m_extensionOffset );
|
|
|
|
|
2020-10-01 19:11:35 +00:00
|
|
|
addShape( SHAPE_SEGMENT( extStart, extStart + extension.Resize( extensionHeight ) ) );
|
2020-09-22 02:32:40 +00:00
|
|
|
|
|
|
|
// Add crossbar
|
|
|
|
VECTOR2I crossBarDistance = sign( m_height ) * extension.Resize( m_height );
|
2022-01-01 18:08:03 +00:00
|
|
|
m_crossBarStart = m_start + crossBarDistance;
|
2020-09-22 02:32:40 +00:00
|
|
|
|
|
|
|
if( m_orientation == DIR::HORIZONTAL )
|
2022-01-01 18:08:03 +00:00
|
|
|
m_crossBarEnd = VECTOR2I( m_end.x, m_crossBarStart.y );
|
2020-09-22 02:32:40 +00:00
|
|
|
else
|
2022-01-01 18:08:03 +00:00
|
|
|
m_crossBarEnd = VECTOR2I( m_crossBarStart.x, m_end.y );
|
2020-09-22 02:32:40 +00:00
|
|
|
|
|
|
|
// Add second extension line (m_end to crossbar end)
|
|
|
|
if( m_orientation == DIR::HORIZONTAL )
|
|
|
|
extension = VECTOR2I( 0, m_end.y - m_crossBarEnd.y );
|
|
|
|
else
|
|
|
|
extension = VECTOR2I( m_end.x - m_crossBarEnd.x, 0 );
|
|
|
|
|
|
|
|
extensionHeight = extension.EuclideanNorm() - m_extensionOffset + m_extensionHeight;
|
|
|
|
|
|
|
|
extStart = VECTOR2I( m_crossBarEnd );
|
|
|
|
extStart -= extension.Resize( m_extensionHeight );
|
|
|
|
|
2020-10-01 19:11:35 +00:00
|
|
|
addShape( SHAPE_SEGMENT( extStart, extStart + extension.Resize( extensionHeight ) ) );
|
2020-09-22 02:32:40 +00:00
|
|
|
|
|
|
|
// Update text after calculating crossbar position but before adding crossbar lines
|
|
|
|
updateText();
|
|
|
|
|
|
|
|
// Now that we have the text updated, we can determine how to draw the crossbar.
|
|
|
|
// First we need to create an appropriate bounding polygon to collide with
|
2023-03-04 23:15:43 +00:00
|
|
|
BOX2I textBox = GetTextBox().Inflate( GetTextWidth() / 2, GetEffectiveTextPenWidth() );
|
2020-09-22 02:32:40 +00:00
|
|
|
|
|
|
|
SHAPE_POLY_SET polyBox;
|
|
|
|
polyBox.NewOutline();
|
|
|
|
polyBox.Append( textBox.GetOrigin() );
|
|
|
|
polyBox.Append( textBox.GetOrigin().x, textBox.GetEnd().y );
|
|
|
|
polyBox.Append( textBox.GetEnd() );
|
|
|
|
polyBox.Append( textBox.GetEnd().x, textBox.GetOrigin().y );
|
2023-03-04 23:15:43 +00:00
|
|
|
polyBox.Rotate( GetTextAngle(), textBox.GetCenter() );
|
2020-09-22 02:32:40 +00:00
|
|
|
|
|
|
|
// The ideal crossbar, if the text doesn't collide
|
|
|
|
SEG crossbar( m_crossBarStart, m_crossBarEnd );
|
|
|
|
|
|
|
|
// Now we can draw 0, 1, or 2 crossbar lines depending on how the polygon collides
|
|
|
|
bool containsA = polyBox.Contains( crossbar.A );
|
|
|
|
bool containsB = polyBox.Contains( crossbar.B );
|
|
|
|
|
|
|
|
OPT_VECTOR2I endpointA = segPolyIntersection( polyBox, crossbar );
|
|
|
|
OPT_VECTOR2I endpointB = segPolyIntersection( polyBox, crossbar, false );
|
|
|
|
|
|
|
|
if( endpointA )
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( crossbar.A, *endpointA ) );
|
|
|
|
|
|
|
|
if( endpointB )
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( *endpointB, crossbar.B ) );
|
|
|
|
|
|
|
|
if( !containsA && !containsB && !endpointA && !endpointB )
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( crossbar ) );
|
|
|
|
|
|
|
|
// Add arrows
|
2022-01-20 23:08:48 +00:00
|
|
|
EDA_ANGLE crossBarAngle( m_crossBarEnd - m_crossBarStart );
|
|
|
|
VECTOR2I arrowEndPos( m_arrowLength, 0 );
|
|
|
|
VECTOR2I arrowEndNeg( m_arrowLength, 0 );
|
2022-01-21 14:27:50 +00:00
|
|
|
RotatePoint( arrowEndPos, -crossBarAngle + s_arrowAngle );
|
|
|
|
RotatePoint( arrowEndNeg, -crossBarAngle - s_arrowAngle );
|
2022-01-20 23:08:48 +00:00
|
|
|
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarStart, m_crossBarStart + arrowEndPos ) );
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarStart, m_crossBarStart + arrowEndNeg ) );
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarEnd, m_crossBarEnd - arrowEndPos ) );
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarEnd, m_crossBarEnd - arrowEndNeg ) );
|
2020-09-22 02:32:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
void PCB_DIM_ORTHOGONAL::updateText()
|
2020-09-22 02:32:40 +00:00
|
|
|
{
|
|
|
|
VECTOR2I crossbarCenter( ( m_crossBarEnd - m_crossBarStart ) / 2 );
|
|
|
|
|
|
|
|
if( m_textPosition == DIM_TEXT_POSITION::OUTSIDE )
|
|
|
|
{
|
2023-03-04 23:15:43 +00:00
|
|
|
int textOffsetDistance = GetEffectiveTextPenWidth() + GetTextHeight();
|
2020-09-22 02:32:40 +00:00
|
|
|
|
2021-02-21 22:44:41 +00:00
|
|
|
VECTOR2I textOffset;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2021-02-21 22:44:41 +00:00
|
|
|
if( m_orientation == DIR::HORIZONTAL )
|
|
|
|
textOffset.y = -textOffsetDistance;
|
|
|
|
else
|
|
|
|
textOffset.x = -textOffsetDistance;
|
2020-10-13 15:47:57 +00:00
|
|
|
|
2020-09-22 02:32:40 +00:00
|
|
|
textOffset += crossbarCenter;
|
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
SetTextPos( m_crossBarStart + textOffset );
|
2020-09-22 02:32:40 +00:00
|
|
|
}
|
|
|
|
else if( m_textPosition == DIM_TEXT_POSITION::INLINE )
|
|
|
|
{
|
2023-03-04 23:15:43 +00:00
|
|
|
SetTextPos( m_crossBarStart + crossbarCenter );
|
2020-09-22 02:32:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( m_keepTextAligned )
|
2020-09-09 03:17:08 +00:00
|
|
|
{
|
2021-02-21 22:44:41 +00:00
|
|
|
if( abs( crossbarCenter.x ) > abs( crossbarCenter.y ) )
|
2023-03-04 23:15:43 +00:00
|
|
|
SetTextAngle( ANGLE_HORIZONTAL );
|
2021-02-21 22:44:41 +00:00
|
|
|
else
|
2023-03-04 23:15:43 +00:00
|
|
|
SetTextAngle( ANGLE_VERTICAL );
|
2020-09-09 03:17:08 +00:00
|
|
|
}
|
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
PCB_DIM_ALIGNED::updateText();
|
2020-09-09 03:17:08 +00:00
|
|
|
}
|
2020-09-12 20:09:40 +00:00
|
|
|
|
|
|
|
|
2022-01-13 19:32:00 +00:00
|
|
|
void PCB_DIM_ORTHOGONAL::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
2021-04-09 09:16:41 +00:00
|
|
|
{
|
2022-01-13 19:32:00 +00:00
|
|
|
EDA_ANGLE angle( aAngle );
|
|
|
|
|
2021-04-09 09:16:41 +00:00
|
|
|
// restrict angle to -179.9 to 180.0 degrees
|
2022-01-31 10:34:21 +00:00
|
|
|
angle.Normalize180();
|
2021-04-09 09:16:41 +00:00
|
|
|
|
|
|
|
// adjust orientation and height to new angle
|
|
|
|
// we can only handle the cases of -90, 0, 90, 180 degrees exactly;
|
|
|
|
// in the other cases we will use the nearest 90 degree angle to
|
|
|
|
// choose at least an approximate axis for the target orientation
|
|
|
|
// In case of exactly 45 or 135 degrees, we will round towards zero for consistency
|
2022-01-13 19:32:00 +00:00
|
|
|
if( angle > ANGLE_45 && angle <= ANGLE_135 )
|
2021-04-09 09:16:41 +00:00
|
|
|
{
|
|
|
|
// about 90 degree
|
|
|
|
if( m_orientation == DIR::HORIZONTAL )
|
|
|
|
{
|
|
|
|
m_orientation = DIR::VERTICAL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_orientation = DIR::HORIZONTAL;
|
|
|
|
m_height = -m_height;
|
|
|
|
}
|
|
|
|
}
|
2022-01-13 19:32:00 +00:00
|
|
|
else if( angle < -ANGLE_45 && angle >= -ANGLE_135 )
|
2021-04-09 09:16:41 +00:00
|
|
|
{
|
|
|
|
// about -90 degree
|
|
|
|
if( m_orientation == DIR::HORIZONTAL )
|
|
|
|
{
|
|
|
|
m_orientation = DIR::VERTICAL;
|
|
|
|
m_height = -m_height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_orientation = DIR::HORIZONTAL;
|
|
|
|
}
|
|
|
|
}
|
2022-01-13 19:32:00 +00:00
|
|
|
else if( angle > ANGLE_135 || angle < -ANGLE_135 )
|
2021-04-09 09:16:41 +00:00
|
|
|
{
|
|
|
|
// about 180 degree
|
|
|
|
m_height = -m_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
// this will update m_crossBarStart and m_crossbarEnd
|
2022-01-13 19:32:00 +00:00
|
|
|
PCB_DIMENSION_BASE::Rotate( aRotCentre, angle );
|
2021-04-09 09:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
PCB_DIM_LEADER::PCB_DIM_LEADER( BOARD_ITEM* aParent ) :
|
|
|
|
PCB_DIMENSION_BASE( aParent, PCB_DIM_LEADER_T ),
|
2021-07-13 18:46:33 +00:00
|
|
|
m_textBorder( DIM_TEXT_BORDER::NONE )
|
2020-09-12 20:09:40 +00:00
|
|
|
{
|
|
|
|
m_unitsFormat = DIM_UNITS_FORMAT::NO_SUFFIX;
|
|
|
|
m_overrideTextEnabled = true;
|
|
|
|
m_keepTextAligned = false;
|
2021-07-13 18:46:33 +00:00
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
SetOverrideText( _( "Leader" ) );
|
2020-09-12 20:09:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
EDA_ITEM* PCB_DIM_LEADER::Clone() const
|
2020-09-12 20:09:40 +00:00
|
|
|
{
|
2021-06-11 16:59:28 +00:00
|
|
|
return new PCB_DIM_LEADER( *this );
|
2020-09-12 20:09:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-11 17:09:25 +00:00
|
|
|
void PCB_DIM_LEADER::swapData( BOARD_ITEM* aImage )
|
2020-09-12 20:09:40 +00:00
|
|
|
{
|
2021-12-04 23:52:00 +00:00
|
|
|
wxASSERT( aImage->Type() == Type() );
|
2020-09-12 20:09:40 +00:00
|
|
|
|
2021-07-13 18:46:33 +00:00
|
|
|
m_shapes.clear();
|
|
|
|
static_cast<PCB_DIM_LEADER*>( aImage )->m_shapes.clear();
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
std::swap( *static_cast<PCB_DIM_LEADER*>( this ), *static_cast<PCB_DIM_LEADER*>( aImage ) );
|
2021-07-13 18:46:33 +00:00
|
|
|
|
|
|
|
Update();
|
2020-09-12 20:09:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
BITMAPS PCB_DIM_LEADER::GetMenuImage() const
|
2020-09-12 20:09:40 +00:00
|
|
|
{
|
2021-03-08 02:59:07 +00:00
|
|
|
return BITMAPS::add_leader;
|
2020-09-12 20:09:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-03-05 13:27:22 +00:00
|
|
|
void PCB_DIM_LEADER::updateText()
|
|
|
|
{
|
|
|
|
// Our geometry is dependent on the size of the text, so just update the whole shebang
|
|
|
|
updateGeometry();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
void PCB_DIM_LEADER::updateGeometry()
|
2020-09-12 20:09:40 +00:00
|
|
|
{
|
|
|
|
m_shapes.clear();
|
|
|
|
|
2023-03-05 13:27:22 +00:00
|
|
|
PCB_DIMENSION_BASE::updateText();
|
2021-01-13 08:02:02 +00:00
|
|
|
|
|
|
|
// Now that we have the text updated, we can determine how to draw the second line
|
|
|
|
// First we need to create an appropriate bounding polygon to collide with
|
2023-03-04 23:15:43 +00:00
|
|
|
BOX2I textBox = GetTextBox().Inflate( GetTextWidth() / 2, GetEffectiveTextPenWidth() * 2 );
|
2021-01-13 08:02:02 +00:00
|
|
|
|
|
|
|
SHAPE_POLY_SET polyBox;
|
|
|
|
polyBox.NewOutline();
|
|
|
|
polyBox.Append( textBox.GetOrigin() );
|
|
|
|
polyBox.Append( textBox.GetOrigin().x, textBox.GetEnd().y );
|
|
|
|
polyBox.Append( textBox.GetEnd() );
|
|
|
|
polyBox.Append( textBox.GetEnd().x, textBox.GetOrigin().y );
|
2023-03-04 23:15:43 +00:00
|
|
|
polyBox.Rotate( GetTextAngle(), textBox.GetCenter() );
|
2021-01-13 08:02:02 +00:00
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
VECTOR2I firstLine( m_end - m_start );
|
|
|
|
VECTOR2I start( m_start );
|
|
|
|
start += firstLine.Resize( m_extensionOffset );
|
|
|
|
|
2021-03-05 23:10:18 +00:00
|
|
|
SEG arrowSeg( m_start, m_end );
|
2023-03-04 23:15:43 +00:00
|
|
|
SEG textSeg( m_end, GetTextPos() );
|
2022-08-25 22:50:47 +00:00
|
|
|
OPT_VECTOR2I arrowSegEnd;
|
|
|
|
OPT_VECTOR2I textSegEnd;
|
2021-03-05 23:10:18 +00:00
|
|
|
|
2021-07-13 18:46:33 +00:00
|
|
|
if( m_textBorder == DIM_TEXT_BORDER::CIRCLE )
|
2021-03-05 23:10:18 +00:00
|
|
|
{
|
2023-03-04 23:15:43 +00:00
|
|
|
double penWidth = GetEffectiveTextPenWidth() / 2.0;
|
2021-03-05 23:10:18 +00:00
|
|
|
double radius = ( textBox.GetWidth() / 2.0 ) - penWidth;
|
|
|
|
CIRCLE circle( textBox.GetCenter(), radius );
|
|
|
|
|
|
|
|
arrowSegEnd = segCircleIntersection( circle, arrowSeg );
|
|
|
|
textSegEnd = segCircleIntersection( circle, textSeg );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
arrowSegEnd = segPolyIntersection( polyBox, arrowSeg );
|
|
|
|
textSegEnd = segPolyIntersection( polyBox, textSeg );
|
|
|
|
}
|
2021-01-13 08:02:02 +00:00
|
|
|
|
2021-03-05 23:10:18 +00:00
|
|
|
if( !arrowSegEnd )
|
|
|
|
arrowSegEnd = m_end;
|
2021-01-13 08:02:02 +00:00
|
|
|
|
2021-03-05 23:10:18 +00:00
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( start, *arrowSegEnd ) );
|
2020-09-12 20:09:40 +00:00
|
|
|
|
|
|
|
// Add arrows
|
2022-01-20 23:08:48 +00:00
|
|
|
VECTOR2I arrowEndPos( m_arrowLength, 0 );
|
|
|
|
VECTOR2I arrowEndNeg( m_arrowLength, 0 );
|
2022-01-21 14:27:50 +00:00
|
|
|
RotatePoint( arrowEndPos, -EDA_ANGLE( firstLine ) + s_arrowAngle );
|
|
|
|
RotatePoint( arrowEndNeg, -EDA_ANGLE( firstLine ) - s_arrowAngle );
|
2020-09-12 20:09:40 +00:00
|
|
|
|
2022-01-20 23:08:48 +00:00
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( start, start + arrowEndPos ) );
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( start, start + arrowEndNeg ) );
|
2020-09-12 20:09:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
if( !GetText().IsEmpty() )
|
|
|
|
{
|
2021-07-13 18:46:33 +00:00
|
|
|
switch( m_textBorder )
|
2020-09-12 20:09:40 +00:00
|
|
|
{
|
2021-07-13 18:46:33 +00:00
|
|
|
case DIM_TEXT_BORDER::RECTANGLE:
|
2020-09-12 20:09:40 +00:00
|
|
|
{
|
|
|
|
for( SHAPE_POLY_SET::SEGMENT_ITERATOR seg = polyBox.IterateSegments(); seg; seg++ )
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( *seg ) );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-07-13 18:46:33 +00:00
|
|
|
case DIM_TEXT_BORDER::CIRCLE:
|
2020-09-12 20:09:40 +00:00
|
|
|
{
|
2023-03-04 23:15:43 +00:00
|
|
|
double penWidth = GetEffectiveTextPenWidth() / 2.0;
|
2020-09-12 20:09:40 +00:00
|
|
|
double radius = ( textBox.GetWidth() / 2.0 ) - penWidth;
|
|
|
|
m_shapes.emplace_back( new SHAPE_CIRCLE( textBox.GetCenter(), radius ) );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-05 23:10:18 +00:00
|
|
|
if( textSegEnd && *arrowSegEnd == m_end )
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( m_end, *textSegEnd ) );
|
2020-09-12 20:09:40 +00:00
|
|
|
}
|
2020-09-17 00:54:58 +00:00
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
void PCB_DIM_LEADER::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
|
2020-09-24 21:23:16 +00:00
|
|
|
{
|
2023-05-05 13:21:56 +00:00
|
|
|
// Don't use GetShownText(); we want to see the variable references here
|
|
|
|
aList.emplace_back( _( "Leader" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
|
2020-09-24 21:23:16 +00:00
|
|
|
|
2023-11-09 18:40:47 +00:00
|
|
|
ORIGIN_TRANSFORMS& originTransforms = aFrame->GetOriginTransforms();
|
2020-09-24 23:40:35 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I startCoord = originTransforms.ToDisplayAbs( GetStart() );
|
2022-02-04 22:44:59 +00:00
|
|
|
wxString start = wxString::Format( wxT( "@(%s, %s)" ),
|
2022-09-19 16:09:59 +00:00
|
|
|
aFrame->MessageTextFromValue( startCoord.x ),
|
|
|
|
aFrame->MessageTextFromValue( startCoord.y ) );
|
2020-09-24 23:40:35 +00:00
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( start, wxEmptyString );
|
2020-09-24 23:40:35 +00:00
|
|
|
|
2020-11-30 14:35:48 +00:00
|
|
|
aList.emplace_back( _( "Layer" ), GetLayerName() );
|
2020-09-24 21:23:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
PCB_DIM_RADIAL::PCB_DIM_RADIAL( BOARD_ITEM* aParent ) :
|
|
|
|
PCB_DIMENSION_BASE( aParent, PCB_DIM_RADIAL_T )
|
2021-07-13 18:46:33 +00:00
|
|
|
{
|
|
|
|
m_unitsFormat = DIM_UNITS_FORMAT::NO_SUFFIX;
|
|
|
|
m_overrideTextEnabled = false;
|
|
|
|
m_keepTextAligned = true;
|
|
|
|
m_isDiameter = false;
|
|
|
|
m_prefix = "R ";
|
|
|
|
m_leaderLength = m_arrowLength * 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EDA_ITEM* PCB_DIM_RADIAL::Clone() const
|
|
|
|
{
|
|
|
|
return new PCB_DIM_RADIAL( *this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-11 17:09:25 +00:00
|
|
|
void PCB_DIM_RADIAL::swapData( BOARD_ITEM* aImage )
|
2021-07-13 18:46:33 +00:00
|
|
|
{
|
2021-12-04 23:52:00 +00:00
|
|
|
wxASSERT( aImage->Type() == Type() );
|
2021-07-13 18:46:33 +00:00
|
|
|
|
|
|
|
m_shapes.clear();
|
|
|
|
static_cast<PCB_DIM_RADIAL*>( aImage )->m_shapes.clear();
|
|
|
|
|
|
|
|
std::swap( *static_cast<PCB_DIM_RADIAL*>( this ), *static_cast<PCB_DIM_RADIAL*>( aImage ) );
|
|
|
|
|
|
|
|
Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BITMAPS PCB_DIM_RADIAL::GetMenuImage() const
|
|
|
|
{
|
|
|
|
return BITMAPS::add_radial_dimension;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I PCB_DIM_RADIAL::GetKnee() const
|
2021-07-13 18:46:33 +00:00
|
|
|
{
|
|
|
|
VECTOR2I radial( m_end - m_start );
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
return m_end + radial.Resize( m_leaderLength );
|
2021-07-13 18:46:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_DIM_RADIAL::updateText()
|
|
|
|
{
|
|
|
|
if( m_keepTextAligned )
|
|
|
|
{
|
2023-03-04 23:15:43 +00:00
|
|
|
VECTOR2I textLine( GetTextPos() - GetKnee() );
|
2022-01-20 23:08:48 +00:00
|
|
|
EDA_ANGLE textAngle = FULL_CIRCLE - EDA_ANGLE( textLine );
|
2021-07-13 18:46:33 +00:00
|
|
|
|
2022-01-13 23:30:52 +00:00
|
|
|
textAngle.Normalize();
|
2021-07-13 18:46:33 +00:00
|
|
|
|
2022-01-13 23:30:52 +00:00
|
|
|
if( textAngle > ANGLE_90 && textAngle <= ANGLE_270 )
|
|
|
|
textAngle -= ANGLE_180;
|
2021-07-13 18:46:33 +00:00
|
|
|
|
|
|
|
// Round to nearest degree
|
2022-01-13 23:30:52 +00:00
|
|
|
textAngle = EDA_ANGLE( KiROUND( textAngle.AsDegrees() ), DEGREES_T );
|
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
SetTextAngle( textAngle );
|
2021-07-13 18:46:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PCB_DIMENSION_BASE::updateText();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_DIM_RADIAL::updateGeometry()
|
|
|
|
{
|
|
|
|
m_shapes.clear();
|
|
|
|
|
|
|
|
VECTOR2I center( m_start );
|
|
|
|
VECTOR2I centerArm( 0, m_arrowLength );
|
|
|
|
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( center - centerArm, center + centerArm ) );
|
|
|
|
|
2022-01-20 23:08:48 +00:00
|
|
|
RotatePoint( centerArm, -ANGLE_90 );
|
2021-07-13 18:46:33 +00:00
|
|
|
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( center - centerArm, center + centerArm ) );
|
|
|
|
|
|
|
|
VECTOR2I radius( m_end - m_start );
|
|
|
|
|
|
|
|
if( m_isDiameter )
|
|
|
|
m_measuredValue = KiROUND( radius.EuclideanNorm() * 2 );
|
|
|
|
else
|
|
|
|
m_measuredValue = KiROUND( radius.EuclideanNorm() );
|
|
|
|
|
|
|
|
updateText();
|
|
|
|
|
|
|
|
// Now that we have the text updated, we can determine how to draw the second line
|
|
|
|
// First we need to create an appropriate bounding polygon to collide with
|
2023-03-04 23:15:43 +00:00
|
|
|
BOX2I textBox = GetTextBox().Inflate( GetTextWidth() / 2, GetEffectiveTextPenWidth() );
|
2021-07-13 18:46:33 +00:00
|
|
|
|
|
|
|
SHAPE_POLY_SET polyBox;
|
|
|
|
polyBox.NewOutline();
|
|
|
|
polyBox.Append( textBox.GetOrigin() );
|
|
|
|
polyBox.Append( textBox.GetOrigin().x, textBox.GetEnd().y );
|
|
|
|
polyBox.Append( textBox.GetEnd() );
|
|
|
|
polyBox.Append( textBox.GetEnd().x, textBox.GetOrigin().y );
|
2023-03-04 23:15:43 +00:00
|
|
|
polyBox.Rotate( GetTextAngle(), textBox.GetCenter() );
|
2021-07-13 18:46:33 +00:00
|
|
|
|
|
|
|
VECTOR2I radial( m_end - m_start );
|
|
|
|
radial = radial.Resize( m_leaderLength );
|
|
|
|
|
2022-01-01 18:08:03 +00:00
|
|
|
SEG arrowSeg( m_end, m_end + radial );
|
2023-03-04 23:15:43 +00:00
|
|
|
SEG textSeg( arrowSeg.B, GetTextPos() );
|
2021-07-13 18:46:33 +00:00
|
|
|
|
|
|
|
OPT_VECTOR2I arrowSegEnd = segPolyIntersection( polyBox, arrowSeg );
|
|
|
|
OPT_VECTOR2I textSegEnd = segPolyIntersection( polyBox, textSeg );
|
|
|
|
|
|
|
|
if( arrowSegEnd )
|
2022-08-30 20:58:43 +00:00
|
|
|
arrowSeg.B = *arrowSegEnd;
|
2021-07-13 18:46:33 +00:00
|
|
|
|
|
|
|
if( textSegEnd )
|
2022-08-30 20:58:43 +00:00
|
|
|
textSeg.B = *textSegEnd;
|
2021-07-13 18:46:33 +00:00
|
|
|
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( arrowSeg ) );
|
|
|
|
|
|
|
|
// Add arrows
|
2022-01-20 23:08:48 +00:00
|
|
|
VECTOR2I arrowEndPos( m_arrowLength, 0 );
|
|
|
|
VECTOR2I arrowEndNeg( m_arrowLength, 0 );
|
2022-01-21 14:27:50 +00:00
|
|
|
RotatePoint( arrowEndPos, -EDA_ANGLE( radial ) + s_arrowAngle );
|
|
|
|
RotatePoint( arrowEndNeg, -EDA_ANGLE( radial ) - s_arrowAngle );
|
2021-07-13 18:46:33 +00:00
|
|
|
|
2022-01-20 23:08:48 +00:00
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( m_end, m_end + arrowEndPos ) );
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( m_end, m_end + arrowEndNeg ) );
|
2021-07-13 18:46:33 +00:00
|
|
|
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( textSeg ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
PCB_DIM_CENTER::PCB_DIM_CENTER( BOARD_ITEM* aParent ) :
|
|
|
|
PCB_DIMENSION_BASE( aParent, PCB_DIM_CENTER_T )
|
2020-09-17 00:54:58 +00:00
|
|
|
{
|
|
|
|
m_unitsFormat = DIM_UNITS_FORMAT::NO_SUFFIX;
|
|
|
|
m_overrideTextEnabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
EDA_ITEM* PCB_DIM_CENTER::Clone() const
|
2020-09-17 00:54:58 +00:00
|
|
|
{
|
2021-06-11 16:59:28 +00:00
|
|
|
return new PCB_DIM_CENTER( *this );
|
2020-09-17 00:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-11 17:09:25 +00:00
|
|
|
void PCB_DIM_CENTER::swapData( BOARD_ITEM* aImage )
|
2020-09-17 00:54:58 +00:00
|
|
|
{
|
2021-12-04 23:52:00 +00:00
|
|
|
wxASSERT( aImage->Type() == Type() );
|
2020-09-17 00:54:58 +00:00
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
std::swap( *static_cast<PCB_DIM_CENTER*>( this ), *static_cast<PCB_DIM_CENTER*>( aImage ) );
|
2020-09-17 00:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
BITMAPS PCB_DIM_CENTER::GetMenuImage() const
|
2020-09-17 00:54:58 +00:00
|
|
|
{
|
2021-03-08 02:59:07 +00:00
|
|
|
return BITMAPS::add_center_dimension;
|
2020-09-17 00:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I PCB_DIM_CENTER::GetBoundingBox() const
|
2020-09-17 00:54:58 +00:00
|
|
|
{
|
|
|
|
int halfWidth = VECTOR2I( m_end - m_start ).x + ( m_lineThickness / 2.0 );
|
|
|
|
|
2022-08-31 16:17:14 +00:00
|
|
|
BOX2I bBox;
|
2020-09-17 00:54:58 +00:00
|
|
|
|
|
|
|
bBox.SetX( m_start.x - halfWidth );
|
|
|
|
bBox.SetY( m_start.y - halfWidth );
|
|
|
|
bBox.SetWidth( halfWidth * 2 );
|
|
|
|
bBox.SetHeight( halfWidth * 2 );
|
|
|
|
|
|
|
|
bBox.Normalize();
|
|
|
|
|
|
|
|
return bBox;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
const BOX2I PCB_DIM_CENTER::ViewBBox() const
|
2020-09-17 00:54:58 +00:00
|
|
|
{
|
|
|
|
return BOX2I( VECTOR2I( GetBoundingBox().GetPosition() ),
|
|
|
|
VECTOR2I( GetBoundingBox().GetSize() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
void PCB_DIM_CENTER::updateGeometry()
|
2020-09-17 00:54:58 +00:00
|
|
|
{
|
|
|
|
m_shapes.clear();
|
|
|
|
|
|
|
|
VECTOR2I center( m_start );
|
|
|
|
VECTOR2I arm( m_end - m_start );
|
|
|
|
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( center - arm, center + arm ) );
|
|
|
|
|
2022-01-20 23:08:48 +00:00
|
|
|
RotatePoint( arm, -ANGLE_90 );
|
2020-09-17 00:54:58 +00:00
|
|
|
|
|
|
|
m_shapes.emplace_back( new SHAPE_SEGMENT( center - arm, center + arm ) );
|
|
|
|
}
|
2020-10-16 15:51:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
static struct DIMENSION_DESC
|
|
|
|
{
|
|
|
|
DIMENSION_DESC()
|
|
|
|
{
|
2023-03-05 13:27:22 +00:00
|
|
|
ENUM_MAP<DIM_PRECISION>::Instance()
|
|
|
|
.Map( DIM_PRECISION::X, _HKI( "0" ) )
|
|
|
|
.Map( DIM_PRECISION::X_X, _HKI( "0.0" ) )
|
|
|
|
.Map( DIM_PRECISION::X_XX, _HKI( "0.00" ) )
|
|
|
|
.Map( DIM_PRECISION::X_XXX, _HKI( "0.000" ) )
|
|
|
|
.Map( DIM_PRECISION::X_XXXX, _HKI( "0.0000" ) )
|
|
|
|
.Map( DIM_PRECISION::X_XXXXX, _HKI( "0.00000" ) )
|
|
|
|
.Map( DIM_PRECISION::V_VV, _HKI( "0.00 in / 0 mils / 0.0 mm" ) )
|
|
|
|
.Map( DIM_PRECISION::V_VVV, _HKI( "0.000 / 0 / 0.00" ) )
|
|
|
|
.Map( DIM_PRECISION::V_VVVV, _HKI( "0.0000 / 0.0 / 0.000" ) )
|
|
|
|
.Map( DIM_PRECISION::V_VVVVV, _HKI( "0.00000 / 0.00 / 0.0000" ) );
|
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
ENUM_MAP<DIM_UNITS_FORMAT>::Instance()
|
|
|
|
.Map( DIM_UNITS_FORMAT::NO_SUFFIX, _HKI( "1234.0" ) )
|
|
|
|
.Map( DIM_UNITS_FORMAT::BARE_SUFFIX, _HKI( "1234.0 mm" ) )
|
|
|
|
.Map( DIM_UNITS_FORMAT::PAREN_SUFFIX, _HKI( "1234.0 (mm)" ) );
|
|
|
|
|
|
|
|
ENUM_MAP<DIM_UNITS_MODE>::Instance()
|
|
|
|
.Map( DIM_UNITS_MODE::INCHES, _HKI( "Inches" ) )
|
|
|
|
.Map( DIM_UNITS_MODE::MILS, _HKI( "Mils" ) )
|
|
|
|
.Map( DIM_UNITS_MODE::MILLIMETRES, _HKI( "Millimeters" ) )
|
|
|
|
.Map( DIM_UNITS_MODE::AUTOMATIC, _HKI( "Automatic" ) );
|
|
|
|
|
2020-10-16 15:51:24 +00:00
|
|
|
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
2021-06-11 16:59:28 +00:00
|
|
|
REGISTER_TYPE( PCB_DIMENSION_BASE );
|
2023-03-04 23:15:43 +00:00
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIMENSION_BASE, PCB_TEXT> );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIMENSION_BASE, BOARD_ITEM> );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIMENSION_BASE, EDA_TEXT> );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIMENSION_BASE ), TYPE_HASH( PCB_TEXT ) );
|
2021-06-11 16:59:28 +00:00
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIMENSION_BASE ), TYPE_HASH( BOARD_ITEM ) );
|
2023-03-04 23:15:43 +00:00
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIMENSION_BASE ), TYPE_HASH( EDA_TEXT ) );
|
2022-11-28 03:40:14 +00:00
|
|
|
|
2024-05-20 09:28:29 +00:00
|
|
|
propMgr.Mask( TYPE_HASH( PCB_DIMENSION_BASE ), TYPE_HASH( EDA_TEXT ), _HKI( "Orientation" ) );
|
|
|
|
|
2022-12-27 01:10:22 +00:00
|
|
|
const wxString groupDimension = _HKI( "Dimension Properties" );
|
2022-11-28 03:40:14 +00:00
|
|
|
|
2023-05-25 14:58:31 +00:00
|
|
|
auto isLeader =
|
|
|
|
[]( INSPECTABLE* aItem ) -> bool
|
|
|
|
{
|
|
|
|
return dynamic_cast<PCB_DIM_LEADER*>( aItem ) != nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
auto isNotLeader =
|
|
|
|
[]( INSPECTABLE* aItem ) -> bool
|
|
|
|
{
|
|
|
|
return dynamic_cast<PCB_DIM_LEADER*>( aItem ) == nullptr;
|
|
|
|
};
|
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<PCB_DIMENSION_BASE, wxString>( _HKI( "Prefix" ),
|
|
|
|
&PCB_DIMENSION_BASE::ChangePrefix, &PCB_DIMENSION_BASE::GetPrefix ),
|
2023-05-25 14:58:31 +00:00
|
|
|
groupDimension )
|
|
|
|
.SetAvailableFunc( isNotLeader );
|
2023-03-04 23:15:43 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<PCB_DIMENSION_BASE, wxString>( _HKI( "Suffix" ),
|
|
|
|
&PCB_DIMENSION_BASE::ChangeSuffix, &PCB_DIMENSION_BASE::GetSuffix ),
|
2023-05-25 14:58:31 +00:00
|
|
|
groupDimension )
|
|
|
|
.SetAvailableFunc( isNotLeader );
|
2022-11-28 03:40:14 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<PCB_DIMENSION_BASE, wxString>( _HKI( "Override Text" ),
|
2023-03-04 23:15:43 +00:00
|
|
|
&PCB_DIMENSION_BASE::ChangeOverrideText, &PCB_DIMENSION_BASE::GetOverrideText ),
|
2023-05-25 14:58:31 +00:00
|
|
|
groupDimension )
|
|
|
|
.SetAvailableFunc( isNotLeader );
|
|
|
|
|
|
|
|
propMgr.AddProperty( new PROPERTY<PCB_DIMENSION_BASE, wxString>( _HKI( "Text" ),
|
|
|
|
&PCB_DIMENSION_BASE::ChangeOverrideText, &PCB_DIMENSION_BASE::GetOverrideText ),
|
|
|
|
groupDimension )
|
|
|
|
.SetAvailableFunc( isLeader );
|
2023-03-04 23:15:43 +00:00
|
|
|
|
|
|
|
propMgr.AddProperty( new PROPERTY_ENUM<PCB_DIMENSION_BASE, DIM_UNITS_MODE>( _HKI( "Units" ),
|
|
|
|
&PCB_DIMENSION_BASE::ChangeUnitsMode, &PCB_DIMENSION_BASE::GetUnitsMode ),
|
2023-05-25 14:58:31 +00:00
|
|
|
groupDimension )
|
|
|
|
.SetAvailableFunc( isNotLeader );
|
2023-03-04 23:15:43 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY_ENUM<PCB_DIMENSION_BASE, DIM_UNITS_FORMAT>( _HKI( "Units Format" ),
|
|
|
|
&PCB_DIMENSION_BASE::ChangeUnitsFormat, &PCB_DIMENSION_BASE::GetUnitsFormat ),
|
2023-05-25 14:58:31 +00:00
|
|
|
groupDimension )
|
|
|
|
.SetAvailableFunc( isNotLeader );
|
2023-03-05 13:27:22 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY_ENUM<PCB_DIMENSION_BASE, DIM_PRECISION>( _HKI( "Precision" ),
|
2023-03-04 23:15:43 +00:00
|
|
|
&PCB_DIMENSION_BASE::ChangePrecision, &PCB_DIMENSION_BASE::GetPrecision ),
|
2023-05-25 14:58:31 +00:00
|
|
|
groupDimension )
|
|
|
|
.SetAvailableFunc( isNotLeader );
|
2023-03-04 23:15:43 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<PCB_DIMENSION_BASE, bool>( _HKI( "Suppress Trailing Zeroes" ),
|
|
|
|
&PCB_DIMENSION_BASE::ChangeSuppressZeroes, &PCB_DIMENSION_BASE::GetSuppressZeroes ),
|
2023-05-25 14:58:31 +00:00
|
|
|
groupDimension )
|
|
|
|
.SetAvailableFunc( isNotLeader );
|
2024-05-20 09:28:29 +00:00
|
|
|
|
|
|
|
const wxString groupText = _HKI( "Text Properties" );
|
|
|
|
|
|
|
|
const auto isTextOrientationWriteable =
|
|
|
|
[]( INSPECTABLE* aItem ) -> bool
|
|
|
|
{
|
|
|
|
return !static_cast<PCB_DIMENSION_BASE*>( aItem )->GetKeepTextAligned();
|
|
|
|
};
|
|
|
|
|
|
|
|
propMgr.AddProperty( new PROPERTY<PCB_DIMENSION_BASE, bool>( _HKI( "Keep Aligned with Dimension" ),
|
2024-05-22 05:56:37 +00:00
|
|
|
&PCB_DIMENSION_BASE::ChangeKeepTextAligned,
|
2024-05-21 14:11:28 +00:00
|
|
|
&PCB_DIMENSION_BASE::GetKeepTextAligned ),
|
2024-05-20 09:28:29 +00:00
|
|
|
groupText );
|
|
|
|
|
2024-05-21 16:14:40 +00:00
|
|
|
propMgr.AddProperty( new PROPERTY<PCB_DIMENSION_BASE, double>( _HKI( "Orientation" ),
|
2024-05-22 05:56:37 +00:00
|
|
|
&PCB_DIMENSION_BASE::ChangeTextAngleDegrees,
|
2024-05-21 16:14:40 +00:00
|
|
|
&PCB_DIMENSION_BASE::GetTextAngleDegreesProp,
|
|
|
|
PROPERTY_DISPLAY::PT_DEGREE ),
|
|
|
|
groupText )
|
|
|
|
.SetWriteableFunc( isTextOrientationWriteable );
|
2020-10-16 15:51:24 +00:00
|
|
|
}
|
|
|
|
} _DIMENSION_DESC;
|
2023-03-04 23:15:43 +00:00
|
|
|
|
2023-03-05 13:27:22 +00:00
|
|
|
ENUM_TO_WXANY( DIM_PRECISION )
|
2023-03-04 23:15:43 +00:00
|
|
|
ENUM_TO_WXANY( DIM_UNITS_FORMAT )
|
|
|
|
ENUM_TO_WXANY( DIM_UNITS_MODE )
|
|
|
|
|
|
|
|
|
|
|
|
static struct ALIGNED_DIMENSION_DESC
|
|
|
|
{
|
|
|
|
ALIGNED_DIMENSION_DESC()
|
|
|
|
{
|
|
|
|
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
|
|
|
REGISTER_TYPE( PCB_DIM_ALIGNED );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIM_ALIGNED, BOARD_ITEM> );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIM_ALIGNED, EDA_TEXT> );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIM_ALIGNED, PCB_TEXT> );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIM_ALIGNED, PCB_DIMENSION_BASE> );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIM_ALIGNED ), TYPE_HASH( BOARD_ITEM ) );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIM_ALIGNED ), TYPE_HASH( EDA_TEXT ) );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIM_ALIGNED ), TYPE_HASH( PCB_TEXT ) );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIM_ALIGNED ), TYPE_HASH( PCB_DIMENSION_BASE ) );
|
|
|
|
|
|
|
|
const wxString groupDimension = _HKI( "Dimension Properties" );
|
|
|
|
|
|
|
|
propMgr.AddProperty( new PROPERTY<PCB_DIM_ALIGNED, int>( _HKI( "Crossbar Height" ),
|
|
|
|
&PCB_DIM_ALIGNED::ChangeHeight, &PCB_DIM_ALIGNED::GetHeight,
|
|
|
|
PROPERTY_DISPLAY::PT_SIZE ),
|
|
|
|
groupDimension );
|
|
|
|
propMgr.AddProperty( new PROPERTY<PCB_DIM_ALIGNED, int>( _HKI( "Extension Line Overshoot" ),
|
|
|
|
&PCB_DIM_ALIGNED::ChangeExtensionHeight, &PCB_DIM_ALIGNED::GetExtensionHeight,
|
|
|
|
PROPERTY_DISPLAY::PT_SIZE ),
|
|
|
|
groupDimension );
|
|
|
|
|
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_ALIGNED ), TYPE_HASH( EDA_TEXT ),
|
|
|
|
_HKI( "Visible" ),
|
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_ALIGNED ), TYPE_HASH( EDA_TEXT ),
|
2023-05-25 14:58:31 +00:00
|
|
|
_HKI( "Text" ),
|
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_ALIGNED ), TYPE_HASH( EDA_TEXT ),
|
|
|
|
_HKI( "Vertical Justification" ),
|
2023-03-04 23:15:43 +00:00
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_ALIGNED ), TYPE_HASH( EDA_TEXT ),
|
|
|
|
_HKI( "Hyperlink" ),
|
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
2023-05-25 14:58:31 +00:00
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_ALIGNED ), TYPE_HASH( BOARD_ITEM ),
|
|
|
|
_HKI( "Knockout" ),
|
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
2023-03-04 23:15:43 +00:00
|
|
|
}
|
|
|
|
} ALIGNED_DIMENSION_DESC;
|
|
|
|
|
|
|
|
|
|
|
|
static struct ORTHOGONAL_DIMENSION_DESC
|
|
|
|
{
|
|
|
|
ORTHOGONAL_DIMENSION_DESC()
|
|
|
|
{
|
|
|
|
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
|
|
|
REGISTER_TYPE( PCB_DIM_ORTHOGONAL );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIM_ORTHOGONAL, BOARD_ITEM> );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIM_ORTHOGONAL, EDA_TEXT> );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIM_ORTHOGONAL, PCB_TEXT> );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIM_ORTHOGONAL, PCB_DIMENSION_BASE> );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIM_ORTHOGONAL, PCB_DIM_ALIGNED> );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIM_ORTHOGONAL ), TYPE_HASH( BOARD_ITEM ) );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIM_ORTHOGONAL ), TYPE_HASH( EDA_TEXT ) );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIM_ORTHOGONAL ), TYPE_HASH( PCB_TEXT ) );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIM_ORTHOGONAL ), TYPE_HASH( PCB_DIMENSION_BASE ) );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIM_ORTHOGONAL ), TYPE_HASH( PCB_DIM_ALIGNED ) );
|
|
|
|
|
2023-05-25 14:58:31 +00:00
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_ORTHOGONAL ), TYPE_HASH( EDA_TEXT ),
|
2023-03-04 23:15:43 +00:00
|
|
|
_HKI( "Visible" ),
|
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
2023-05-25 14:58:31 +00:00
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_ORTHOGONAL ), TYPE_HASH( EDA_TEXT ),
|
|
|
|
_HKI( "Text" ),
|
2023-03-04 23:15:43 +00:00
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
2023-05-25 14:58:31 +00:00
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_ORTHOGONAL ), TYPE_HASH( EDA_TEXT ),
|
|
|
|
_HKI( "Vertical Justification" ),
|
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_ORTHOGONAL ), TYPE_HASH( EDA_TEXT ),
|
2023-03-04 23:15:43 +00:00
|
|
|
_HKI( "Hyperlink" ),
|
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
2023-05-25 14:58:31 +00:00
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_ORTHOGONAL ), TYPE_HASH( BOARD_ITEM ),
|
|
|
|
_HKI( "Knockout" ),
|
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
2023-03-04 23:15:43 +00:00
|
|
|
}
|
|
|
|
} ORTHOGONAL_DIMENSION_DESC;
|
|
|
|
|
|
|
|
|
|
|
|
static struct RADIAL_DIMENSION_DESC
|
|
|
|
{
|
|
|
|
RADIAL_DIMENSION_DESC()
|
|
|
|
{
|
|
|
|
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
|
|
|
REGISTER_TYPE( PCB_DIM_RADIAL );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIM_RADIAL, BOARD_ITEM> );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIM_RADIAL, EDA_TEXT> );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIM_RADIAL, PCB_TEXT> );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIM_RADIAL, PCB_DIMENSION_BASE> );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIM_RADIAL ), TYPE_HASH( BOARD_ITEM ) );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIM_RADIAL ), TYPE_HASH( EDA_TEXT ) );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIM_RADIAL ), TYPE_HASH( PCB_TEXT ) );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIM_RADIAL ), TYPE_HASH( PCB_DIMENSION_BASE ) );
|
|
|
|
|
|
|
|
const wxString groupDimension = _HKI( "Dimension Properties" );
|
|
|
|
|
|
|
|
propMgr.AddProperty( new PROPERTY<PCB_DIM_RADIAL, int>( _HKI( "Leader Length" ),
|
|
|
|
&PCB_DIM_RADIAL::ChangeLeaderLength, &PCB_DIM_RADIAL::GetLeaderLength,
|
|
|
|
PROPERTY_DISPLAY::PT_SIZE ),
|
|
|
|
groupDimension );
|
|
|
|
|
2023-05-25 14:58:31 +00:00
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_RADIAL ), TYPE_HASH( EDA_TEXT ),
|
2023-03-04 23:15:43 +00:00
|
|
|
_HKI( "Visible" ),
|
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
2023-05-25 14:58:31 +00:00
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_RADIAL ), TYPE_HASH( EDA_TEXT ),
|
|
|
|
_HKI( "Text" ),
|
2023-03-04 23:15:43 +00:00
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
2023-05-25 14:58:31 +00:00
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_RADIAL ), TYPE_HASH( EDA_TEXT ),
|
|
|
|
_HKI( "Vertical Justification" ),
|
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_RADIAL ), TYPE_HASH( EDA_TEXT ),
|
2023-03-04 23:15:43 +00:00
|
|
|
_HKI( "Hyperlink" ),
|
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
2023-05-25 14:58:31 +00:00
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_RADIAL ), TYPE_HASH( BOARD_ITEM ),
|
|
|
|
_HKI( "Knockout" ),
|
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
2023-03-04 23:15:43 +00:00
|
|
|
}
|
|
|
|
} RADIAL_DIMENSION_DESC;
|
|
|
|
|
|
|
|
|
|
|
|
static struct LEADER_DIMENSION_DESC
|
|
|
|
{
|
|
|
|
LEADER_DIMENSION_DESC()
|
|
|
|
{
|
|
|
|
ENUM_MAP<DIM_TEXT_BORDER>::Instance()
|
|
|
|
.Map( DIM_TEXT_BORDER::NONE, _HKI( "None" ) )
|
|
|
|
.Map( DIM_TEXT_BORDER::RECTANGLE, _HKI( "Rectangle" ) )
|
|
|
|
.Map( DIM_TEXT_BORDER::CIRCLE, _HKI( "Circle" ) );
|
|
|
|
|
|
|
|
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
|
|
|
REGISTER_TYPE( PCB_DIM_LEADER );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIM_LEADER, BOARD_ITEM> );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIM_LEADER, EDA_TEXT> );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIM_LEADER, PCB_TEXT> );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIM_LEADER, PCB_DIMENSION_BASE> );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIM_LEADER ), TYPE_HASH( BOARD_ITEM ) );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIM_LEADER ), TYPE_HASH( EDA_TEXT ) );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIM_LEADER ), TYPE_HASH( PCB_TEXT ) );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIM_LEADER ), TYPE_HASH( PCB_DIMENSION_BASE ) );
|
|
|
|
|
|
|
|
const wxString groupDimension = _HKI( "Dimension Properties" );
|
|
|
|
|
|
|
|
propMgr.AddProperty( new PROPERTY_ENUM<PCB_DIM_LEADER, DIM_TEXT_BORDER>( _HKI( "Text Frame" ),
|
|
|
|
&PCB_DIM_LEADER::ChangeTextBorder, &PCB_DIM_LEADER::GetTextBorder ),
|
|
|
|
groupDimension );
|
|
|
|
|
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_LEADER ), TYPE_HASH( EDA_TEXT ),
|
|
|
|
_HKI( "Visible" ),
|
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_LEADER ), TYPE_HASH( EDA_TEXT ),
|
2023-05-25 14:58:31 +00:00
|
|
|
_HKI( "Text" ),
|
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_LEADER ), TYPE_HASH( EDA_TEXT ),
|
|
|
|
_HKI( "Vertical Justification" ),
|
2023-03-04 23:15:43 +00:00
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_LEADER ), TYPE_HASH( EDA_TEXT ),
|
|
|
|
_HKI( "Hyperlink" ),
|
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
2023-05-25 14:58:31 +00:00
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_LEADER ), TYPE_HASH( BOARD_ITEM ),
|
|
|
|
_HKI( "Knockout" ),
|
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
2023-03-04 23:15:43 +00:00
|
|
|
}
|
|
|
|
} LEADER_DIMENSION_DESC;
|
|
|
|
|
|
|
|
ENUM_TO_WXANY( DIM_TEXT_BORDER )
|
|
|
|
|
|
|
|
|
|
|
|
static struct CENTER_DIMENSION_DESC
|
|
|
|
{
|
|
|
|
CENTER_DIMENSION_DESC()
|
|
|
|
{
|
|
|
|
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
|
|
|
REGISTER_TYPE( PCB_DIM_CENTER );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIM_CENTER, BOARD_ITEM> );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIM_CENTER, EDA_TEXT> );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIM_CENTER, PCB_TEXT> );
|
|
|
|
propMgr.AddTypeCast( new TYPE_CAST<PCB_DIM_CENTER, PCB_DIMENSION_BASE> );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIM_CENTER ), TYPE_HASH( BOARD_ITEM ) );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIM_CENTER ), TYPE_HASH( EDA_TEXT ) );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIM_CENTER ), TYPE_HASH( PCB_TEXT ) );
|
|
|
|
propMgr.InheritsAfter( TYPE_HASH( PCB_DIM_CENTER ), TYPE_HASH( PCB_DIMENSION_BASE ) );
|
|
|
|
|
|
|
|
|
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_CENTER ), TYPE_HASH( EDA_TEXT ),
|
|
|
|
_HKI( "Visible" ),
|
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_CENTER ), TYPE_HASH( EDA_TEXT ),
|
2023-05-25 14:58:31 +00:00
|
|
|
_HKI( "Text" ),
|
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_CENTER ), TYPE_HASH( EDA_TEXT ),
|
|
|
|
_HKI( "Vertical Justification" ),
|
2023-03-04 23:15:43 +00:00
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_CENTER ), TYPE_HASH( EDA_TEXT ),
|
|
|
|
_HKI( "Hyperlink" ),
|
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
2023-05-25 14:58:31 +00:00
|
|
|
propMgr.OverrideAvailability( TYPE_HASH( PCB_DIM_CENTER ), TYPE_HASH( BOARD_ITEM ),
|
|
|
|
_HKI( "Knockout" ),
|
|
|
|
[]( INSPECTABLE* aItem ) { return false; } );
|
2023-03-04 23:15:43 +00:00
|
|
|
}
|
|
|
|
} CENTER_DIMENSION_DESC;
|