2018-08-03 12:18:26 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 CERN
|
2024-01-16 15:29:13 +00:00
|
|
|
* Copyright (C) 2019-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
2018-08-03 12:18:26 +00:00
|
|
|
*
|
2019-11-06 19:15:42 +00:00
|
|
|
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
|
|
|
*
|
2018-08-03 12:18:26 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2021-09-15 20:15:55 +00:00
|
|
|
#include <trigo.h>
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <connection_graph.h>
|
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2023-02-09 17:18:56 +00:00
|
|
|
#include <callback_gal.h>
|
2021-07-17 19:56:18 +00:00
|
|
|
#include <geometry/shape_segment.h>
|
2023-11-25 12:38:24 +00:00
|
|
|
#include <geometry/shape_rect.h>
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <gr_text.h>
|
2024-04-20 09:44:34 +00:00
|
|
|
#include <sch_pin.h>
|
2020-01-04 23:05:57 +00:00
|
|
|
#include <math/util.h>
|
2023-01-11 19:29:06 +00:00
|
|
|
#include <pgm_base.h>
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <sch_bitmap.h>
|
|
|
|
#include <sch_bus_entry.h>
|
2021-02-24 13:48:02 +00:00
|
|
|
#include <sch_symbol.h>
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <sch_field.h>
|
|
|
|
#include <sch_junction.h>
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <sch_line.h>
|
2024-04-15 20:18:54 +00:00
|
|
|
#include <sch_shape.h>
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <sch_marker.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <sch_no_connect.h>
|
2019-03-11 21:32:05 +00:00
|
|
|
#include <sch_sheet.h>
|
2021-04-06 21:15:49 +00:00
|
|
|
#include <sch_sheet_pin.h>
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <sch_text.h>
|
2022-01-25 22:33:37 +00:00
|
|
|
#include <sch_textbox.h>
|
2023-11-25 12:38:24 +00:00
|
|
|
#include <sch_table.h>
|
2020-05-13 02:00:37 +00:00
|
|
|
#include <schematic.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/color_settings.h>
|
2018-10-21 12:50:31 +00:00
|
|
|
#include <view/view.h>
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2020-04-14 18:11:50 +00:00
|
|
|
#include <default_values.h>
|
2020-09-08 19:18:50 +00:00
|
|
|
#include <advanced_config.h>
|
2023-01-11 19:29:06 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2021-07-17 19:56:18 +00:00
|
|
|
#include <stroke_params.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include "sch_painter.h"
|
2023-01-16 15:59:31 +00:00
|
|
|
#include "common.h"
|
2021-07-17 19:56:18 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-09-05 22:17:22 +00:00
|
|
|
namespace KIGFX
|
|
|
|
{
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2021-09-07 20:34:10 +00:00
|
|
|
EESCHEMA_SETTINGS* eeconfig()
|
|
|
|
{
|
|
|
|
return dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-21 19:54:07 +00:00
|
|
|
std::vector<KICAD_T> SCH_PAINTER::g_ScaledSelectionTypes = {
|
2022-08-20 09:27:35 +00:00
|
|
|
SCH_MARKER_T,
|
|
|
|
SCH_JUNCTION_T,
|
|
|
|
SCH_NO_CONNECT_T,
|
|
|
|
SCH_BUS_WIRE_ENTRY_T,
|
|
|
|
SCH_BUS_BUS_ENTRY_T,
|
|
|
|
SCH_LINE_T,
|
2024-04-15 20:18:54 +00:00
|
|
|
SCH_SHAPE_T,
|
2024-04-25 14:24:46 +00:00
|
|
|
SCH_RULE_AREA_T,
|
2022-08-20 09:27:35 +00:00
|
|
|
SCH_BITMAP_T,
|
2023-08-24 16:54:01 +00:00
|
|
|
SCH_TEXT_T,
|
2023-06-23 11:00:03 +00:00
|
|
|
SCH_GLOBAL_LABEL_T,
|
2022-08-20 09:27:35 +00:00
|
|
|
SCH_DIRECTIVE_LABEL_T,
|
2023-08-24 16:54:01 +00:00
|
|
|
SCH_FIELD_T,
|
2023-07-08 17:50:04 +00:00
|
|
|
SCH_HIER_LABEL_T,
|
|
|
|
SCH_SHEET_PIN_T,
|
2022-08-20 09:27:35 +00:00
|
|
|
LIB_SYMBOL_T, SCH_SYMBOL_T,
|
|
|
|
SCH_SHEET_T,
|
2024-04-20 09:44:34 +00:00
|
|
|
SCH_PIN_T
|
2022-08-20 09:27:35 +00:00
|
|
|
};
|
2022-05-13 21:36:20 +00:00
|
|
|
|
|
|
|
|
2018-08-30 19:44:10 +00:00
|
|
|
/**
|
2021-06-10 18:51:46 +00:00
|
|
|
* Used when a LIB_SYMBOL is not found in library to draw a dummy shape.
|
2020-11-15 17:03:27 +00:00
|
|
|
* This symbol is a 400 mils square with the text "??"
|
2019-07-30 01:57:41 +00:00
|
|
|
*
|
|
|
|
* DEF DUMMY U 0 40 Y Y 1 0 N
|
|
|
|
* F0 "U" 0 -350 60 H V
|
|
|
|
* F1 "DUMMY" 0 350 60 H V
|
|
|
|
* DRAW
|
|
|
|
* T 0 0 0 150 0 0 0 ??
|
|
|
|
* S -200 200 200 -200 0 1 0
|
|
|
|
* ENDDRAW
|
|
|
|
* ENDDEF
|
2018-08-30 19:44:10 +00:00
|
|
|
*/
|
2021-06-10 18:51:46 +00:00
|
|
|
static LIB_SYMBOL* dummy()
|
2018-08-30 19:44:10 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
static LIB_SYMBOL* symbol;
|
2018-08-30 19:44:10 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
if( !symbol )
|
2018-08-30 19:44:10 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
symbol = new LIB_SYMBOL( wxEmptyString );
|
2018-08-30 19:44:10 +00:00
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
SCH_SHAPE* square = new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE );
|
2018-08-30 19:44:10 +00:00
|
|
|
|
2024-04-06 13:14:44 +00:00
|
|
|
square->SetPosition( VECTOR2I( schIUScale.MilsToIU( -200 ), schIUScale.MilsToIU( 200 ) ) );
|
2022-09-16 23:42:20 +00:00
|
|
|
square->SetEnd( VECTOR2I( schIUScale.MilsToIU( 200 ), schIUScale.MilsToIU( -200 ) ) );
|
2024-04-15 20:18:54 +00:00
|
|
|
symbol->AddDrawItem( square );
|
2018-08-30 19:44:10 +00:00
|
|
|
|
2024-04-14 18:04:53 +00:00
|
|
|
SCH_TEXT* text = new SCH_TEXT( { 0, 0 }, wxT( "??" ), LAYER_DEVICE );
|
2018-08-30 19:44:10 +00:00
|
|
|
|
2023-02-19 03:40:07 +00:00
|
|
|
text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 150 ), schIUScale.MilsToIU( 150 ) ) );
|
2021-06-10 18:51:46 +00:00
|
|
|
symbol->AddDrawItem( text );
|
2018-08-30 19:44:10 +00:00
|
|
|
}
|
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
return symbol;
|
2018-08-30 19:44:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
SCH_PAINTER::SCH_PAINTER( GAL* aGal ) :
|
2024-04-15 20:18:54 +00:00
|
|
|
KIGFX::PAINTER( aGal ),
|
|
|
|
m_schematic( nullptr )
|
2018-08-30 19:44:10 +00:00
|
|
|
{ }
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
|
2023-06-12 09:45:29 +00:00
|
|
|
bool SCH_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2022-09-16 16:20:36 +00:00
|
|
|
const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2020-12-20 18:59:07 +00:00
|
|
|
if( !item )
|
2020-08-15 21:06:10 +00:00
|
|
|
return false;
|
|
|
|
|
2022-09-16 16:20:36 +00:00
|
|
|
draw( item, aLayer, false );
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-06-12 09:45:29 +00:00
|
|
|
void SCH_PAINTER::draw( const EDA_ITEM* aItem, int aLayer, bool aDimmed )
|
2022-09-16 16:20:36 +00:00
|
|
|
{
|
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
#ifdef CONNECTIVITY_DEBUG
|
|
|
|
|
2022-09-16 16:20:36 +00:00
|
|
|
auto sch_item = dynamic_cast<const SCH_ITEM*>( aItem );
|
2019-03-11 21:32:05 +00:00
|
|
|
auto conn = sch_item ? sch_item->Connection( *g_CurrentSheet ) : nullptr;
|
|
|
|
|
|
|
|
if( conn )
|
|
|
|
{
|
2022-09-16 16:20:36 +00:00
|
|
|
auto pos = aItem->GetBoundingBox().Centre();
|
2019-03-11 21:32:05 +00:00
|
|
|
auto label = conn->Name( true );
|
|
|
|
|
2021-12-28 22:13:54 +00:00
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
|
2019-03-11 21:32:05 +00:00
|
|
|
m_gal->SetStrokeColor( COLOR4D( LIGHTRED ) );
|
2019-12-30 18:28:00 +00:00
|
|
|
m_gal->SetLineWidth( Mils2ui( 2 ) );
|
|
|
|
m_gal->SetGlyphSize( VECTOR2D( Mils2ui( 20 ), Mils2ui( 20 ) ) );
|
2020-04-14 12:25:00 +00:00
|
|
|
m_gal->StrokeText( conn->Name( true ), pos, 0.0, 0 );
|
2019-03-11 21:32:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2024-03-13 16:42:05 +00:00
|
|
|
// Enable draw bounding box on request. Some bboxes are handled locally.
|
|
|
|
bool drawBoundingBox = m_schSettings.GetDrawBoundingBoxes();
|
2021-02-24 22:14:39 +00:00
|
|
|
|
2022-09-16 16:20:36 +00:00
|
|
|
switch( aItem->Type() )
|
|
|
|
{
|
|
|
|
case LIB_SYMBOL_T:
|
|
|
|
draw( static_cast<const LIB_SYMBOL*>( aItem ), aLayer );
|
|
|
|
break;
|
2024-04-20 09:44:34 +00:00
|
|
|
case SCH_PIN_T:
|
2024-03-13 16:42:05 +00:00
|
|
|
drawBoundingBox = false;
|
2024-04-20 09:44:34 +00:00
|
|
|
draw( static_cast<const SCH_PIN*>( aItem ), aLayer, aDimmed );
|
2022-09-16 16:20:36 +00:00
|
|
|
break;
|
|
|
|
case SCH_SYMBOL_T:
|
|
|
|
draw( static_cast<const SCH_SYMBOL*>( aItem ), aLayer );
|
|
|
|
break;
|
|
|
|
case SCH_JUNCTION_T:
|
|
|
|
draw( static_cast<const SCH_JUNCTION*>( aItem ), aLayer );
|
|
|
|
break;
|
|
|
|
case SCH_LINE_T:
|
|
|
|
draw( static_cast<const SCH_LINE*>( aItem ), aLayer );
|
|
|
|
break;
|
|
|
|
case SCH_SHAPE_T:
|
2024-04-15 20:18:54 +00:00
|
|
|
draw( static_cast<const SCH_SHAPE*>( aItem ), aLayer, aDimmed );
|
2022-09-16 16:20:36 +00:00
|
|
|
break;
|
2024-04-25 14:24:46 +00:00
|
|
|
case SCH_RULE_AREA_T:
|
|
|
|
draw( static_cast<const SCH_SHAPE*>( aItem ), aLayer, aDimmed );
|
|
|
|
break;
|
2022-09-16 16:20:36 +00:00
|
|
|
case SCH_TEXT_T:
|
2024-04-14 18:04:53 +00:00
|
|
|
draw( static_cast<const SCH_TEXT*>( aItem ), aLayer, aDimmed );
|
2022-09-16 16:20:36 +00:00
|
|
|
break;
|
|
|
|
case SCH_TEXTBOX_T:
|
2024-04-15 20:18:54 +00:00
|
|
|
draw( static_cast<const SCH_TEXTBOX*>( aItem ), aLayer, aDimmed );
|
2022-09-16 16:20:36 +00:00
|
|
|
break;
|
2023-11-25 12:38:24 +00:00
|
|
|
case SCH_TABLE_T:
|
2024-04-15 20:18:54 +00:00
|
|
|
draw( static_cast<const SCH_TABLE*>( aItem ), aLayer, aDimmed );
|
2023-11-25 12:38:24 +00:00
|
|
|
break;
|
2022-09-16 16:20:36 +00:00
|
|
|
case SCH_LABEL_T:
|
|
|
|
draw( static_cast<const SCH_LABEL*>( aItem ), aLayer );
|
|
|
|
break;
|
|
|
|
case SCH_DIRECTIVE_LABEL_T:
|
|
|
|
draw( static_cast<const SCH_DIRECTIVE_LABEL*>( aItem ), aLayer );
|
|
|
|
break;
|
|
|
|
case SCH_FIELD_T:
|
|
|
|
draw( static_cast<const SCH_FIELD*>( aItem ), aLayer, aDimmed );
|
|
|
|
break;
|
|
|
|
case SCH_HIER_LABEL_T:
|
|
|
|
draw( static_cast<const SCH_HIERLABEL*>( aItem ), aLayer );
|
|
|
|
break;
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
draw( static_cast<const SCH_GLOBALLABEL*>( aItem ), aLayer );
|
|
|
|
break;
|
|
|
|
case SCH_SHEET_T:
|
|
|
|
draw( static_cast<const SCH_SHEET*>( aItem ), aLayer );
|
|
|
|
break;
|
|
|
|
case SCH_SHEET_PIN_T:
|
|
|
|
draw( static_cast<const SCH_HIERLABEL*>( aItem ), aLayer );
|
|
|
|
break;
|
|
|
|
case SCH_NO_CONNECT_T:
|
|
|
|
draw( static_cast<const SCH_NO_CONNECT*>( aItem ), aLayer );
|
|
|
|
break;
|
|
|
|
case SCH_BUS_WIRE_ENTRY_T:
|
|
|
|
draw( static_cast<const SCH_BUS_ENTRY_BASE*>( aItem ), aLayer );
|
|
|
|
break;
|
|
|
|
case SCH_BUS_BUS_ENTRY_T:
|
|
|
|
draw( static_cast<const SCH_BUS_ENTRY_BASE*>( aItem ), aLayer );
|
|
|
|
break;
|
|
|
|
case SCH_BITMAP_T:
|
|
|
|
draw( static_cast<const SCH_BITMAP*>( aItem ), aLayer );
|
|
|
|
break;
|
|
|
|
case SCH_MARKER_T:
|
|
|
|
draw( static_cast<const SCH_MARKER*>( aItem ), aLayer );
|
|
|
|
break;
|
2018-09-05 22:17:22 +00:00
|
|
|
|
2022-09-16 16:20:36 +00:00
|
|
|
default: return;
|
|
|
|
}
|
2024-03-13 16:42:05 +00:00
|
|
|
|
|
|
|
if( drawBoundingBox )
|
|
|
|
drawItemBoundingBox( aItem );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_PAINTER::drawItemBoundingBox( const EDA_ITEM* aItem )
|
|
|
|
{
|
2024-04-22 09:54:58 +00:00
|
|
|
if( const SCH_ITEM* item = dynamic_cast<const SCH_ITEM*>( aItem ) )
|
|
|
|
{
|
|
|
|
if( item->IsPrivate() && !m_schSettings.m_IsSymbolEditor )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-03-13 16:42:05 +00:00
|
|
|
BOX2I box = aItem->GetBoundingBox();
|
|
|
|
|
|
|
|
if( aItem->Type() == SCH_SYMBOL_T )
|
|
|
|
box = static_cast<const SCH_SYMBOL*>( aItem )->GetBodyBoundingBox();
|
|
|
|
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetStrokeColor( aItem->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 )
|
|
|
|
: COLOR4D( 0.2, 0.2, 0.2, 1 ) );
|
|
|
|
m_gal->SetLineWidth( schIUScale.MilsToIU( 3 ) );
|
|
|
|
m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-08-28 13:27:56 +00:00
|
|
|
|
2022-02-24 18:15:47 +00:00
|
|
|
bool SCH_PAINTER::nonCached( const EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
// TODO: it would be nice to have a more definitive test for this, but we've currently got
|
|
|
|
// no access to the VIEW_GROUP to see if it's cached or not.
|
|
|
|
return aItem->IsSelected();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-06 13:14:44 +00:00
|
|
|
bool SCH_PAINTER::isUnitAndConversionShown( const SCH_ITEM* aItem ) const
|
2018-09-02 20:19:22 +00:00
|
|
|
{
|
|
|
|
if( m_schSettings.m_ShowUnit // showing a specific unit
|
|
|
|
&& aItem->GetUnit() // item is unit-specific
|
|
|
|
&& aItem->GetUnit() != m_schSettings.m_ShowUnit )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-01-26 16:16:13 +00:00
|
|
|
if( m_schSettings.m_ShowBodyStyle // showing a specific body style
|
|
|
|
&& aItem->GetBodyStyle() // item is body-style-specific
|
|
|
|
&& aItem->GetBodyStyle() != m_schSettings.m_ShowBodyStyle )
|
2018-09-02 20:19:22 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-01-28 20:01:58 +00:00
|
|
|
KIFONT::FONT* SCH_PAINTER::getFont( const EDA_TEXT* aItem ) const
|
|
|
|
{
|
2023-05-26 12:45:25 +00:00
|
|
|
if( KIFONT::FONT* font = aItem->GetFont() )
|
|
|
|
return font;
|
2023-01-28 20:01:58 +00:00
|
|
|
|
2023-05-26 12:45:25 +00:00
|
|
|
return KIFONT::FONT::GetFont( m_schSettings.GetDefaultFont(), aItem->IsBold(),
|
|
|
|
aItem->IsItalic() );
|
2023-01-28 20:01:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-15 20:03:07 +00:00
|
|
|
float SCH_PAINTER::getShadowWidth( bool aForHighlight ) const
|
2019-07-30 01:57:41 +00:00
|
|
|
{
|
|
|
|
const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
|
|
|
|
|
2021-09-15 20:03:07 +00:00
|
|
|
int milsWidth = aForHighlight ? eeconfig()->m_Selection.highlight_thickness
|
|
|
|
: eeconfig()->m_Selection.selection_thickness;
|
|
|
|
|
2019-08-08 09:06:53 +00:00
|
|
|
// For best visuals the selection width must be a cross between the zoom level and the
|
|
|
|
// default line width.
|
2022-09-16 23:42:20 +00:00
|
|
|
return (float) std::fabs( matrix.GetScale().x * milsWidth ) + schIUScale.MilsToIU( milsWidth );
|
2019-07-30 01:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-20 09:44:34 +00:00
|
|
|
COLOR4D SCH_PAINTER::getRenderColor( const SCH_ITEM* aItem, int aLayer, bool aDrawingShadows,
|
2022-09-24 22:50:52 +00:00
|
|
|
bool aDimmed ) const
|
2019-04-19 15:54:29 +00:00
|
|
|
{
|
2019-05-19 21:04:04 +00:00
|
|
|
COLOR4D color = m_schSettings.GetLayerColor( aLayer );
|
2024-04-19 13:26:15 +00:00
|
|
|
// Graphic items of a SYMBOL frequently use the LAYER_DEVICE layer color
|
|
|
|
// (i.e. when no specific color is set)
|
2024-04-20 09:44:34 +00:00
|
|
|
bool isSymbolChild = aItem->GetParentSymbol() != nullptr;
|
2019-04-19 15:54:29 +00:00
|
|
|
|
2019-06-29 18:45:32 +00:00
|
|
|
if( aItem->Type() == SCH_LINE_T )
|
2020-02-03 16:46:58 +00:00
|
|
|
{
|
2022-01-31 23:53:34 +00:00
|
|
|
color = static_cast<const SCH_LINE*>( aItem )->GetLineColor();
|
2020-02-03 16:46:58 +00:00
|
|
|
}
|
2020-06-24 17:35:33 +00:00
|
|
|
else if( aItem->Type() == SCH_BUS_WIRE_ENTRY_T )
|
|
|
|
{
|
2022-01-31 23:53:34 +00:00
|
|
|
color = static_cast<const SCH_BUS_WIRE_ENTRY*>( aItem )->GetBusEntryColor();
|
2020-06-24 17:35:33 +00:00
|
|
|
}
|
|
|
|
else if( aItem->Type() == SCH_JUNCTION_T )
|
|
|
|
{
|
2022-01-31 23:53:34 +00:00
|
|
|
color = static_cast<const SCH_JUNCTION*>( aItem )->GetJunctionColor();
|
2020-06-24 17:35:33 +00:00
|
|
|
}
|
2022-01-31 23:53:34 +00:00
|
|
|
else if( !m_schSettings.m_OverrideItemColors )
|
2020-03-08 02:18:45 +00:00
|
|
|
{
|
2022-01-31 23:53:34 +00:00
|
|
|
if( aItem->Type() == SCH_SHEET_T )
|
|
|
|
{
|
|
|
|
const SCH_SHEET* sheet = static_cast<const SCH_SHEET*>( aItem );
|
2020-07-30 01:16:07 +00:00
|
|
|
|
2022-07-07 04:51:23 +00:00
|
|
|
if( aLayer == LAYER_SHEET_BACKGROUND )
|
2022-01-31 23:53:34 +00:00
|
|
|
color = sheet->GetBackgroundColor();
|
2022-07-07 04:51:23 +00:00
|
|
|
else
|
|
|
|
color = sheet->GetBorderColor();
|
2022-01-31 23:53:34 +00:00
|
|
|
}
|
2024-04-25 14:24:46 +00:00
|
|
|
else if( aItem->Type() == SCH_SHAPE_T || aItem->Type() == SCH_RULE_AREA_T )
|
2022-01-31 23:53:34 +00:00
|
|
|
{
|
|
|
|
const SCH_SHAPE* shape = static_cast<const SCH_SHAPE*>( aItem );
|
2022-01-11 18:17:41 +00:00
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND )
|
2024-04-19 13:26:15 +00:00
|
|
|
{
|
2024-04-20 09:44:34 +00:00
|
|
|
if( !isSymbolChild || shape->GetFillColor() != COLOR4D::UNSPECIFIED )
|
2024-04-19 13:26:15 +00:00
|
|
|
color = shape->GetFillColor();
|
2024-04-20 09:44:34 +00:00
|
|
|
|
|
|
|
if( isSymbolChild && shape->GetFillMode() == FILL_T::FILLED_SHAPE )
|
2024-04-19 13:26:15 +00:00
|
|
|
color = shape->GetStroke().GetColor();
|
|
|
|
}
|
2022-07-07 04:51:23 +00:00
|
|
|
else
|
2024-04-19 13:26:15 +00:00
|
|
|
{
|
2024-04-20 09:44:34 +00:00
|
|
|
if( !isSymbolChild || shape->GetStroke().GetColor() != COLOR4D::UNSPECIFIED )
|
2024-04-19 13:26:15 +00:00
|
|
|
color = shape->GetStroke().GetColor();
|
|
|
|
}
|
2022-04-05 22:32:48 +00:00
|
|
|
|
2022-06-19 11:53:36 +00:00
|
|
|
// A filled shape means filled; if they didn't specify a fill colour then use the
|
|
|
|
// border colour.
|
2022-04-05 22:32:48 +00:00
|
|
|
if( color == COLOR4D::UNSPECIFIED )
|
2024-04-25 14:24:46 +00:00
|
|
|
{
|
|
|
|
if( aItem->Type() == SCH_RULE_AREA_T )
|
|
|
|
{
|
|
|
|
color = m_schSettings.GetLayerColor( LAYER_RULE_AREAS );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
color = m_schSettings.GetLayerColor( isSymbolChild ? LAYER_DEVICE
|
|
|
|
: LAYER_NOTES );
|
|
|
|
}
|
|
|
|
}
|
2022-01-31 23:53:34 +00:00
|
|
|
}
|
2022-09-24 22:50:52 +00:00
|
|
|
else if( aItem->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
|
|
|
|
{
|
|
|
|
color = static_cast<const SCH_LABEL_BASE*>( aItem )->GetLabelColor();
|
|
|
|
}
|
|
|
|
else if( aItem->Type() == SCH_FIELD_T )
|
|
|
|
{
|
|
|
|
color = static_cast<const SCH_FIELD*>( aItem )->GetFieldColor();
|
|
|
|
}
|
2023-11-25 12:38:24 +00:00
|
|
|
else if( aItem->Type() == SCH_TEXTBOX_T || aItem->Type() == SCH_TABLECELL_T )
|
2022-01-31 23:53:34 +00:00
|
|
|
{
|
2023-11-25 12:38:24 +00:00
|
|
|
const SCH_TEXTBOX* textBox = dynamic_cast<const SCH_TEXTBOX*>( aItem );
|
2022-01-25 22:33:37 +00:00
|
|
|
|
2022-01-31 23:53:34 +00:00
|
|
|
if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND )
|
|
|
|
color = textBox->GetFillColor();
|
2024-04-20 09:44:34 +00:00
|
|
|
else if( !isSymbolChild || textBox->GetTextColor() != COLOR4D::UNSPECIFIED )
|
2022-03-31 18:43:08 +00:00
|
|
|
color = textBox->GetTextColor();
|
|
|
|
}
|
|
|
|
else if( const EDA_TEXT* otherTextItem = dynamic_cast<const EDA_TEXT*>( aItem ) )
|
|
|
|
{
|
2024-04-20 09:44:34 +00:00
|
|
|
if( !isSymbolChild || otherTextItem->GetTextColor() != COLOR4D::UNSPECIFIED )
|
2024-04-19 13:26:15 +00:00
|
|
|
color = otherTextItem->GetTextColor();
|
2022-01-31 23:53:34 +00:00
|
|
|
}
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
2019-04-19 15:54:29 +00:00
|
|
|
|
2022-01-31 23:53:34 +00:00
|
|
|
if( color == COLOR4D::UNSPECIFIED )
|
|
|
|
color = m_schSettings.GetLayerColor( aLayer );
|
|
|
|
|
2021-09-15 20:03:07 +00:00
|
|
|
if( aItem->IsBrightened() ) // Selection disambiguation, net highlighting, etc.
|
2019-06-29 18:45:32 +00:00
|
|
|
{
|
|
|
|
color = m_schSettings.GetLayerColor( LAYER_BRIGHTENED );
|
2019-08-05 06:47:38 +00:00
|
|
|
|
2021-09-15 20:03:07 +00:00
|
|
|
if( aDrawingShadows )
|
2022-03-27 12:59:34 +00:00
|
|
|
{
|
|
|
|
if( aItem->IsSelected() )
|
|
|
|
color = m_schSettings.GetLayerColor( LAYER_SELECTION_SHADOWS );
|
|
|
|
else
|
|
|
|
color = color.WithAlpha( 0.15 );
|
|
|
|
}
|
2021-09-15 20:03:07 +00:00
|
|
|
else if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_SHEET_BACKGROUND )
|
2022-03-27 12:59:34 +00:00
|
|
|
{
|
2019-08-05 06:47:38 +00:00
|
|
|
color = color.WithAlpha( 0.2 );
|
2022-03-27 12:59:34 +00:00
|
|
|
}
|
2019-06-29 18:45:32 +00:00
|
|
|
}
|
2022-03-27 12:59:34 +00:00
|
|
|
else if( aItem->IsSelected() && aDrawingShadows )
|
2019-04-19 15:54:29 +00:00
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
if( aDrawingShadows )
|
2021-03-15 16:38:20 +00:00
|
|
|
color = m_schSettings.GetLayerColor( LAYER_SELECTION_SHADOWS );
|
2019-04-19 15:54:29 +00:00
|
|
|
}
|
2024-04-20 09:44:34 +00:00
|
|
|
else if( aItem->IsSelected() && ( aLayer == LAYER_DEVICE_BACKGROUND
|
|
|
|
|| aLayer == LAYER_SHEET_BACKGROUND ) )
|
2023-02-16 22:52:04 +00:00
|
|
|
{
|
|
|
|
// Selected items will be painted over all other items, so make backgrounds translucent so
|
|
|
|
// that non-selected overlapping objects are visible
|
|
|
|
color = color.WithAlpha( 0.5 );
|
|
|
|
}
|
2019-04-19 15:54:29 +00:00
|
|
|
|
2021-02-10 22:56:26 +00:00
|
|
|
if( m_schSettings.m_ShowDisabled
|
2024-04-12 21:00:41 +00:00
|
|
|
|| ( m_schSettings.m_ShowGraphicsDisabled && aItem->Type() != SCH_FIELD_T ) )
|
2021-02-10 22:56:26 +00:00
|
|
|
{
|
2019-11-06 19:15:42 +00:00
|
|
|
color = color.Darken( 0.5f );
|
2021-02-10 22:56:26 +00:00
|
|
|
}
|
2019-11-06 19:15:42 +00:00
|
|
|
|
2023-02-14 18:21:09 +00:00
|
|
|
if( aDimmed && !( aItem->IsSelected() && aDrawingShadows ) )
|
2022-09-16 16:20:36 +00:00
|
|
|
{
|
|
|
|
COLOR4D sheetColour = m_schSettings.GetLayerColor( LAYER_SCHEMATIC_BACKGROUND );
|
2023-01-11 20:53:09 +00:00
|
|
|
color.Desaturate();
|
2022-09-16 16:20:36 +00:00
|
|
|
color = color.Mix( sheetColour, 0.5f );
|
|
|
|
}
|
|
|
|
|
2023-03-11 12:42:58 +00:00
|
|
|
if( aItem->GetForcedTransparency() > 0.0 )
|
|
|
|
color = color.WithAlpha( color.a * ( 1.0 - aItem->GetForcedTransparency() ) );
|
2023-03-09 17:41:18 +00:00
|
|
|
|
2019-04-19 15:54:29 +00:00
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-20 09:44:34 +00:00
|
|
|
float SCH_PAINTER::getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows ) const
|
2019-07-30 01:57:41 +00:00
|
|
|
{
|
2022-09-16 23:42:20 +00:00
|
|
|
wxCHECK( aItem, static_cast<float>( schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ) ) );
|
2020-04-04 20:32:14 +00:00
|
|
|
|
2024-04-20 09:44:34 +00:00
|
|
|
int pen = aItem->GetEffectivePenWidth( &m_schSettings );
|
2022-01-25 22:33:37 +00:00
|
|
|
float width = pen;
|
2019-07-30 01:57:41 +00:00
|
|
|
|
2022-05-13 21:36:20 +00:00
|
|
|
if( aItem->IsBrightened() || aItem->IsSelected() )
|
|
|
|
{
|
|
|
|
if( aDrawingShadows && aItem->IsType( g_ScaledSelectionTypes ) )
|
|
|
|
width += getShadowWidth( aItem->IsBrightened() );
|
|
|
|
}
|
2019-07-30 01:57:41 +00:00
|
|
|
|
2022-02-06 18:14:07 +00:00
|
|
|
return width;
|
2019-07-30 01:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-20 09:44:34 +00:00
|
|
|
float SCH_PAINTER::getTextThickness( const SCH_ITEM* aItem ) const
|
2020-04-14 09:08:42 +00:00
|
|
|
{
|
2022-01-25 22:33:37 +00:00
|
|
|
int pen = m_schSettings.GetDefaultPenWidth();
|
2020-04-14 09:08:42 +00:00
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
switch( aItem->Type() )
|
|
|
|
{
|
|
|
|
case SCH_FIELD_T:
|
|
|
|
pen = static_cast<const SCH_FIELD*>( aItem )->GetEffectiveTextPenWidth( pen );
|
|
|
|
break;
|
2020-04-14 09:08:42 +00:00
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
case SCH_TEXT_T:
|
|
|
|
pen = static_cast<const SCH_TEXT*>( aItem )->GetEffectiveTextPenWidth( pen );
|
|
|
|
break;
|
2020-04-14 09:08:42 +00:00
|
|
|
|
2022-02-01 10:53:01 +00:00
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_DIRECTIVE_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIER_LABEL_T:
|
|
|
|
case SCH_SHEET_PIN_T:
|
|
|
|
pen = static_cast<const SCH_LABEL_BASE*>( aItem )->GetEffectiveTextPenWidth( pen );
|
|
|
|
break;
|
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
case SCH_TEXTBOX_T:
|
2023-11-25 12:38:24 +00:00
|
|
|
case SCH_TABLECELL_T:
|
2022-01-25 22:33:37 +00:00
|
|
|
pen = static_cast<const SCH_TEXTBOX*>( aItem )->GetEffectiveTextPenWidth( pen );
|
|
|
|
break;
|
2020-04-14 09:08:42 +00:00
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
default:
|
|
|
|
UNIMPLEMENTED_FOR( aItem->GetClass() );
|
|
|
|
}
|
2020-04-14 09:08:42 +00:00
|
|
|
|
2022-05-13 21:36:20 +00:00
|
|
|
return (float) pen;
|
2020-04-14 09:08:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-02-09 17:18:56 +00:00
|
|
|
int SCH_PAINTER::getOperatingPointTextSize() const
|
|
|
|
{
|
|
|
|
int docTextSize = schIUScale.MilsToIU( 50 );
|
|
|
|
int screenTextSize = std::abs( (int) m_gal->GetScreenWorldMatrix().GetScale().y * 7 );
|
|
|
|
|
|
|
|
// 66% zoom-relative
|
|
|
|
return KiROUND( ( docTextSize + screenTextSize * 2 ) / 3 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-12 20:05:37 +00:00
|
|
|
static bool isFieldsLayer( int aLayer )
|
|
|
|
{
|
|
|
|
return aLayer == LAYER_REFERENCEPART
|
|
|
|
|| aLayer == LAYER_VALUEPART
|
|
|
|
|| aLayer == LAYER_INTERSHEET_REFS
|
|
|
|
|| aLayer == LAYER_NETCLASS_REFS
|
|
|
|
|| aLayer == LAYER_FIELDS
|
|
|
|
|| aLayer == LAYER_SHEETNAME
|
|
|
|
|| aLayer == LAYER_SHEETFILENAME
|
|
|
|
|| aLayer == LAYER_SHEETFIELDS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-31 14:07:24 +00:00
|
|
|
void SCH_PAINTER::strokeText( const wxString& aText, const VECTOR2D& aPosition,
|
2024-04-20 20:50:40 +00:00
|
|
|
const TEXT_ATTRIBUTES& aAttrs,
|
2024-04-20 09:44:34 +00:00
|
|
|
const KIFONT::METRICS& aFontMetrics )
|
2019-10-21 18:03:54 +00:00
|
|
|
{
|
2024-04-20 20:50:40 +00:00
|
|
|
KIFONT::FONT* font = aAttrs.m_Font;
|
2021-12-31 14:07:24 +00:00
|
|
|
|
|
|
|
if( !font )
|
2022-01-07 00:47:23 +00:00
|
|
|
{
|
2024-04-20 20:50:40 +00:00
|
|
|
font = KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font, aAttrs.m_Bold,
|
|
|
|
aAttrs.m_Italic );
|
2022-01-07 00:47:23 +00:00
|
|
|
}
|
2021-12-31 14:07:24 +00:00
|
|
|
|
|
|
|
m_gal->SetIsFill( font->IsOutline() );
|
|
|
|
m_gal->SetIsStroke( font->IsStroke() );
|
|
|
|
|
2024-04-20 20:50:40 +00:00
|
|
|
font->Draw( m_gal, aText, aPosition, aAttrs, aFontMetrics );
|
2021-09-15 20:15:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-23 12:07:33 +00:00
|
|
|
void SCH_PAINTER::bitmapText( const wxString& aText, const VECTOR2D& aPosition,
|
|
|
|
const TEXT_ATTRIBUTES& aAttrs )
|
|
|
|
{
|
2022-05-13 21:36:20 +00:00
|
|
|
// Bitmap font has different metrics from the stroke font so we compensate a bit before
|
2022-03-07 17:41:46 +00:00
|
|
|
// stroking
|
2022-12-22 14:43:43 +00:00
|
|
|
m_gal->SetGlyphSize( VECTOR2I( aAttrs.m_Size.x, KiROUND( aAttrs.m_Size.y * 1.05 ) ) );
|
|
|
|
m_gal->SetLineWidth( (float) aAttrs.m_StrokeWidth * 1.35f );
|
2022-02-23 12:07:33 +00:00
|
|
|
|
|
|
|
m_gal->SetHorizontalJustify( aAttrs.m_Halign );
|
|
|
|
m_gal->SetVerticalJustify( aAttrs.m_Valign );
|
|
|
|
|
|
|
|
m_gal->BitmapText( aText, aPosition, aAttrs.m_Angle );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-02-09 17:18:56 +00:00
|
|
|
void SCH_PAINTER::knockoutText( const wxString& aText, const VECTOR2D& aPosition,
|
2023-08-06 19:20:53 +00:00
|
|
|
const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics )
|
2023-02-09 17:18:56 +00:00
|
|
|
{
|
|
|
|
TEXT_ATTRIBUTES attrs( aAttrs );
|
|
|
|
KIFONT::FONT* font = aAttrs.m_Font;
|
|
|
|
|
|
|
|
if( !font )
|
|
|
|
{
|
|
|
|
font = KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font, attrs.m_Bold,
|
|
|
|
attrs.m_Italic );
|
|
|
|
}
|
|
|
|
|
|
|
|
KIGFX::GAL_DISPLAY_OPTIONS empty_opts;
|
|
|
|
SHAPE_POLY_SET knockouts;
|
|
|
|
|
|
|
|
CALLBACK_GAL callback_gal( empty_opts,
|
|
|
|
// Polygon callback
|
|
|
|
[&]( const SHAPE_LINE_CHAIN& aPoly )
|
|
|
|
{
|
|
|
|
knockouts.AddOutline( aPoly );
|
|
|
|
} );
|
|
|
|
|
|
|
|
callback_gal.SetIsFill( false );
|
|
|
|
callback_gal.SetIsStroke( true );
|
|
|
|
callback_gal.SetLineWidth( (float) attrs.m_StrokeWidth );
|
2023-08-06 19:20:53 +00:00
|
|
|
font->Draw( &callback_gal, aText, aPosition, attrs, aFontMetrics );
|
2023-02-09 17:18:56 +00:00
|
|
|
|
|
|
|
BOX2I bbox = knockouts.BBox( attrs.m_StrokeWidth * 2 );
|
|
|
|
SHAPE_POLY_SET finalPoly;
|
|
|
|
|
|
|
|
finalPoly.NewOutline();
|
|
|
|
finalPoly.Append( bbox.GetLeft(), bbox.GetTop() );
|
|
|
|
finalPoly.Append( bbox.GetRight(), bbox.GetTop() );
|
|
|
|
finalPoly.Append( bbox.GetRight(), bbox.GetBottom() );
|
|
|
|
finalPoly.Append( bbox.GetLeft(), bbox.GetBottom() );
|
|
|
|
|
|
|
|
finalPoly.BooleanSubtract( knockouts, SHAPE_POLY_SET::PM_FAST );
|
|
|
|
finalPoly.Fracture( SHAPE_POLY_SET::PM_FAST );
|
|
|
|
|
|
|
|
m_gal->SetIsStroke( false );
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetFillColor( attrs.m_Color );
|
|
|
|
m_gal->DrawPolygon( finalPoly );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-31 14:07:24 +00:00
|
|
|
void SCH_PAINTER::boxText( const wxString& aText, const VECTOR2D& aPosition,
|
2024-04-27 12:47:56 +00:00
|
|
|
const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics )
|
2021-09-15 20:15:55 +00:00
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
KIFONT::FONT* font = aAttrs.m_Font;
|
|
|
|
|
|
|
|
if( !font )
|
2022-01-07 00:47:23 +00:00
|
|
|
{
|
|
|
|
font = KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font, aAttrs.m_Bold,
|
|
|
|
aAttrs.m_Italic );
|
|
|
|
}
|
2021-12-31 14:07:24 +00:00
|
|
|
|
2022-01-07 17:42:43 +00:00
|
|
|
VECTOR2I extents = font->StringBoundaryLimits( aText, aAttrs.m_Size, aAttrs.m_StrokeWidth,
|
2023-08-06 19:20:53 +00:00
|
|
|
aAttrs.m_Bold, aAttrs.m_Italic, aFontMetrics );
|
2022-08-31 09:15:42 +00:00
|
|
|
BOX2I box( aPosition, VECTOR2I( extents.x, aAttrs.m_Size.y ) );
|
2021-12-31 14:07:24 +00:00
|
|
|
|
|
|
|
switch( aAttrs.m_Halign )
|
|
|
|
{
|
2024-02-16 12:54:28 +00:00
|
|
|
case GR_TEXT_H_ALIGN_LEFT: break;
|
|
|
|
case GR_TEXT_H_ALIGN_CENTER: box.SetX( box.GetX() - box.GetWidth() / 2 ); break;
|
|
|
|
case GR_TEXT_H_ALIGN_RIGHT: box.SetX( box.GetX() - box.GetWidth() ); break;
|
|
|
|
case GR_TEXT_H_ALIGN_INDETERMINATE: wxFAIL_MSG( wxT( "Legal only in dialogs" ) ); break;
|
2021-12-31 14:07:24 +00:00
|
|
|
}
|
2021-09-15 20:15:55 +00:00
|
|
|
|
2021-12-31 14:07:24 +00:00
|
|
|
switch( aAttrs.m_Valign )
|
|
|
|
{
|
2024-02-16 12:54:28 +00:00
|
|
|
case GR_TEXT_V_ALIGN_TOP: break;
|
|
|
|
case GR_TEXT_V_ALIGN_CENTER: box.SetY( box.GetY() - box.GetHeight() / 2 ); break;
|
|
|
|
case GR_TEXT_V_ALIGN_BOTTOM: box.SetY( box.GetY() - box.GetHeight() ); break;
|
|
|
|
case GR_TEXT_V_ALIGN_INDETERMINATE: wxFAIL_MSG( wxT( "Legal only in dialogs" ) ); break;
|
2021-12-31 14:07:24 +00:00
|
|
|
}
|
2021-09-15 20:15:55 +00:00
|
|
|
|
2022-05-13 21:36:20 +00:00
|
|
|
// Give the highlight a bit of margin.
|
|
|
|
box.Inflate( 0, aAttrs.m_StrokeWidth * 2 );
|
2021-09-15 20:15:55 +00:00
|
|
|
|
|
|
|
box.Normalize(); // Make h and v sizes always >= 0
|
2024-04-15 20:18:54 +00:00
|
|
|
box = box.GetBoundingBoxRotated( aPosition, aAttrs.m_Angle );
|
2021-12-31 14:07:24 +00:00
|
|
|
|
|
|
|
m_gal->SetIsFill( true );
|
2022-05-13 21:36:20 +00:00
|
|
|
m_gal->SetIsStroke( false );
|
2024-04-27 12:47:56 +00:00
|
|
|
m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() );
|
2021-09-15 20:15:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_PAINTER::triLine( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c )
|
|
|
|
{
|
|
|
|
m_gal->DrawLine( a, b );
|
|
|
|
m_gal->DrawLine( b, c );
|
2019-10-21 18:03:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-12 09:45:29 +00:00
|
|
|
void SCH_PAINTER::draw( const LIB_SYMBOL* aSymbol, int aLayer, bool aDrawFields, int aUnit,
|
2024-01-26 16:16:13 +00:00
|
|
|
int aBodyStyle, bool aDimmed )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2018-09-02 20:19:22 +00:00
|
|
|
if( !aUnit )
|
|
|
|
aUnit = m_schSettings.m_ShowUnit;
|
|
|
|
|
2024-01-26 16:16:13 +00:00
|
|
|
if( !aBodyStyle )
|
|
|
|
aBodyStyle = m_schSettings.m_ShowBodyStyle;
|
2018-09-02 20:19:22 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
std::unique_ptr< LIB_SYMBOL > tmpSymbol;
|
|
|
|
const LIB_SYMBOL* drawnSymbol = aSymbol;
|
2019-11-06 19:15:42 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
if( aSymbol->IsAlias() )
|
2019-11-06 19:15:42 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
tmpSymbol = aSymbol->Flatten();
|
|
|
|
drawnSymbol = tmpSymbol.get();
|
2019-11-06 19:15:42 +00:00
|
|
|
}
|
|
|
|
|
2023-06-12 14:38:36 +00:00
|
|
|
// The parent must exist on the union of all its children's draw layers. But that doesn't
|
|
|
|
// mean we want to draw each child on the union.
|
|
|
|
auto childOnLayer =
|
2024-04-06 13:14:44 +00:00
|
|
|
[]( const SCH_ITEM& item, int layer )
|
2023-06-12 14:38:36 +00:00
|
|
|
{
|
|
|
|
int layers[512], layers_count;
|
|
|
|
item.ViewGetLayers( layers, layers_count );
|
|
|
|
|
|
|
|
for( int ii = 0; ii < layers_count; ++ii )
|
|
|
|
{
|
|
|
|
if( layers[ii] == layer )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2024-04-06 13:14:44 +00:00
|
|
|
for( const SCH_ITEM& item : drawnSymbol->GetDrawItems() )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2024-04-12 21:00:41 +00:00
|
|
|
if( !aDrawFields && item.Type() == SCH_FIELD_T )
|
2018-10-21 12:50:31 +00:00
|
|
|
continue;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2023-06-12 14:38:36 +00:00
|
|
|
if( !childOnLayer( item, aLayer ) )
|
|
|
|
continue;
|
|
|
|
|
2018-08-28 13:27:56 +00:00
|
|
|
if( aUnit && item.GetUnit() && aUnit != item.GetUnit() )
|
2018-10-21 12:50:31 +00:00
|
|
|
continue;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2024-01-26 16:16:13 +00:00
|
|
|
if( aBodyStyle && item.GetBodyStyle() && aBodyStyle != item.GetBodyStyle() )
|
2018-10-21 12:50:31 +00:00
|
|
|
continue;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2022-09-16 16:20:36 +00:00
|
|
|
draw( &item, aLayer, aDimmed );
|
2018-10-21 12:50:31 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-08-28 13:27:56 +00:00
|
|
|
|
2024-04-06 13:14:44 +00:00
|
|
|
bool SCH_PAINTER::setDeviceColors( const SCH_ITEM* aItem, int aLayer, bool aDimmed )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2024-01-07 17:40:34 +00:00
|
|
|
COLOR4D bg = m_schSettings.GetLayerColor( LAYER_SCHEMATIC_BACKGROUND );
|
2021-07-18 23:08:54 +00:00
|
|
|
const EDA_SHAPE* shape = dynamic_cast<const EDA_SHAPE*>( aItem );
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
switch( aLayer )
|
2018-10-15 18:35:10 +00:00
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
case LAYER_SELECTION_SHADOWS:
|
2021-09-15 20:03:07 +00:00
|
|
|
if( aItem->IsBrightened() || aItem->IsSelected() )
|
2019-07-30 01:57:41 +00:00
|
|
|
{
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetLineWidth( getLineWidth( aItem, true ) );
|
2022-09-16 16:20:36 +00:00
|
|
|
m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, true, aDimmed ) );
|
|
|
|
m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, true, aDimmed ) );
|
2019-07-30 01:57:41 +00:00
|
|
|
return true;
|
|
|
|
}
|
2019-02-23 16:17:50 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
return false;
|
2018-09-05 16:21:51 +00:00
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
case LAYER_NOTES_BACKGROUND:
|
2019-07-30 01:57:41 +00:00
|
|
|
case LAYER_DEVICE_BACKGROUND:
|
2021-12-15 10:17:04 +00:00
|
|
|
if( shape )
|
2019-07-30 01:57:41 +00:00
|
|
|
{
|
2022-09-10 09:26:51 +00:00
|
|
|
if( shape->GetFillMode() != FILL_T::FILLED_WITH_BG_BODYCOLOR )
|
|
|
|
{
|
|
|
|
return false; // FILLED_SHAPE and FILLED_WITH_COLOR rendered below on
|
|
|
|
// LAYER_NOTES or LAYER_DEVICE
|
|
|
|
}
|
2021-12-15 10:17:04 +00:00
|
|
|
|
|
|
|
m_gal->SetIsFill( true );
|
2022-09-16 16:20:36 +00:00
|
|
|
m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE_BACKGROUND, false, aDimmed ) );
|
2019-03-11 13:08:05 +00:00
|
|
|
m_gal->SetIsStroke( false );
|
2019-07-30 01:57:41 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
case LAYER_NOTES:
|
2022-07-07 04:51:23 +00:00
|
|
|
case LAYER_PRIVATE_NOTES:
|
2019-07-30 01:57:41 +00:00
|
|
|
case LAYER_DEVICE:
|
2022-09-10 09:26:51 +00:00
|
|
|
m_gal->SetIsFill( shape && ( shape->GetFillMode() == FILL_T::FILLED_SHAPE
|
|
|
|
|| shape->GetFillMode() == FILL_T::FILLED_WITH_COLOR ) );
|
|
|
|
|
|
|
|
if( shape && shape->GetFillMode() == FILL_T::FILLED_SHAPE )
|
2022-09-16 16:20:36 +00:00
|
|
|
{
|
|
|
|
m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, false, aDimmed ) );
|
|
|
|
}
|
2022-09-10 09:26:51 +00:00
|
|
|
else if( shape && shape->GetFillMode() == FILL_T::FILLED_WITH_COLOR )
|
2022-09-16 16:20:36 +00:00
|
|
|
{
|
|
|
|
COLOR4D fillColour = shape->GetFillColor();
|
2024-01-07 17:40:34 +00:00
|
|
|
double transparency = aItem->GetForcedTransparency();
|
|
|
|
|
|
|
|
if( transparency > 0.0 )
|
|
|
|
fillColour = fillColour.WithAlpha( fillColour.a * ( 1.0 - transparency ) );
|
2022-09-16 16:20:36 +00:00
|
|
|
|
2023-09-04 13:16:32 +00:00
|
|
|
if( m_schSettings.m_OverrideItemColors )
|
|
|
|
{
|
|
|
|
fillColour = getRenderColor( aItem, LAYER_DEVICE_BACKGROUND, false, aDimmed );
|
|
|
|
}
|
|
|
|
else if( aDimmed )
|
2022-09-16 16:20:36 +00:00
|
|
|
{
|
2024-01-07 17:40:34 +00:00
|
|
|
fillColour = fillColour.Mix( bg, 0.5f );
|
|
|
|
fillColour.Desaturate();
|
2022-09-16 16:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_gal->SetFillColor( fillColour );
|
|
|
|
}
|
2020-04-21 17:12:36 +00:00
|
|
|
|
2021-07-18 23:08:54 +00:00
|
|
|
if( aItem->GetPenWidth() >= 0 || !shape || !shape->IsFilled() )
|
2020-04-21 17:12:36 +00:00
|
|
|
{
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetLineWidth( getLineWidth( aItem, false ) );
|
2022-10-21 21:03:04 +00:00
|
|
|
m_gal->SetStrokeColor( getRenderColor( aItem, aLayer, false, aDimmed ) );
|
2020-04-21 17:12:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_gal->SetIsStroke( false );
|
|
|
|
}
|
2019-03-11 13:08:05 +00:00
|
|
|
|
2018-10-21 12:50:31 +00:00
|
|
|
return true;
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2018-10-15 18:35:10 +00:00
|
|
|
}
|
2018-09-05 16:21:51 +00:00
|
|
|
|
|
|
|
|
2024-04-20 09:44:34 +00:00
|
|
|
int SCH_PAINTER::internalPinDecoSize( const SCH_PIN &aPin )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2020-05-03 23:55:31 +00:00
|
|
|
if( m_schSettings.m_PinSymbolSize > 0 )
|
|
|
|
return m_schSettings.m_PinSymbolSize;
|
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
return aPin.GetNameTextSize() != 0 ? aPin.GetNameTextSize() / 2 : aPin.GetNumberTextSize() / 2;
|
|
|
|
}
|
|
|
|
|
2018-09-09 20:14:00 +00:00
|
|
|
|
|
|
|
// Utility for getting the size of the 'external' pin decorators (as a radius)
|
|
|
|
// i.e. the negation circle, the polarity 'slopes' and the nonlogic marker
|
2024-04-20 09:44:34 +00:00
|
|
|
int SCH_PAINTER::externalPinDecoSize( const SCH_PIN &aPin )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2020-05-03 23:55:31 +00:00
|
|
|
if( m_schSettings.m_PinSymbolSize > 0 )
|
|
|
|
return m_schSettings.m_PinSymbolSize;
|
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
return aPin.GetNumberTextSize() / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
// Draw the target (an open circle) for a pin which has no connection or is being moved.
|
2023-12-18 19:16:33 +00:00
|
|
|
void SCH_PAINTER::drawPinDanglingIndicator( const VECTOR2I& aPos, const COLOR4D& aColor,
|
|
|
|
bool aDrawingShadows, bool aBrightened )
|
2018-09-09 20:14:00 +00:00
|
|
|
{
|
2021-12-06 18:50:00 +00:00
|
|
|
// Dangling symbols must be drawn in a slightly different colour so they can be seen when
|
|
|
|
// they overlap with a junction dot.
|
|
|
|
m_gal->SetStrokeColor( aColor.Brightened( 0.3 ) );
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
2021-09-15 20:03:07 +00:00
|
|
|
m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth( aBrightened )
|
2023-12-18 19:16:33 +00:00
|
|
|
: m_schSettings.GetDanglingIndicatorThickness() );
|
2018-09-09 20:14:00 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->DrawCircle( aPos, TARGET_PIN_RADIUS );
|
2018-09-09 20:14:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-20 09:44:34 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_PIN* aPin, int aLayer, bool aDimmed )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2024-04-28 14:24:19 +00:00
|
|
|
// Don't draw pins from a selection view-group. Pins in a schematic must always be drawn
|
|
|
|
// from their parent symbol's m_part.
|
|
|
|
if( dynamic_cast<const SCH_SYMBOL*>( aPin->GetParentSymbol() ) )
|
|
|
|
return;
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
if( !isUnitAndConversionShown( aPin ) )
|
2018-10-21 12:50:31 +00:00
|
|
|
return;
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
2024-01-16 15:29:13 +00:00
|
|
|
|
|
|
|
if( m_schSettings.IsPrinting() && drawingShadows )
|
|
|
|
return;
|
|
|
|
|
2021-12-07 20:47:12 +00:00
|
|
|
bool drawingDangling = aLayer == LAYER_DANGLING;
|
2023-02-09 17:18:56 +00:00
|
|
|
bool drawingOP = aLayer == LAYER_OP_CURRENTS;
|
2021-12-07 20:47:12 +00:00
|
|
|
bool isDangling = m_schSettings.m_IsSymbolEditor || aPin->HasFlag( IS_DANGLING );
|
2019-07-30 01:57:41 +00:00
|
|
|
|
2021-09-15 20:03:07 +00:00
|
|
|
if( drawingShadows && !( aPin->IsBrightened() || aPin->IsSelected() ) )
|
2018-09-02 20:19:22 +00:00
|
|
|
return;
|
|
|
|
|
2024-04-27 12:47:56 +00:00
|
|
|
VECTOR2I pos = aPin->GetPosition();
|
2022-09-16 16:20:36 +00:00
|
|
|
COLOR4D color = getRenderColor( aPin, LAYER_PIN, drawingShadows, aDimmed );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-08-30 19:44:10 +00:00
|
|
|
if( !aPin->IsVisible() )
|
|
|
|
{
|
2023-11-23 16:24:16 +00:00
|
|
|
if( m_schSettings.IsPrinting() )
|
|
|
|
return;
|
|
|
|
|
2024-01-21 10:22:27 +00:00
|
|
|
bool force_show = m_schematic ? eeconfig()->m_Appearance.show_hidden_pins
|
2024-04-08 11:26:56 +00:00
|
|
|
: m_schSettings.m_ShowHiddenPins;
|
|
|
|
|
2024-01-21 10:22:27 +00:00
|
|
|
if( force_show )
|
2018-09-09 20:14:00 +00:00
|
|
|
{
|
2022-09-16 16:20:36 +00:00
|
|
|
color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows, aDimmed );
|
2018-09-09 20:14:00 +00:00
|
|
|
}
|
|
|
|
else
|
2024-01-16 15:29:13 +00:00
|
|
|
{
|
|
|
|
if( drawingDangling && isDangling && aPin->IsGlobalPower() )
|
|
|
|
drawPinDanglingIndicator( pos, color, drawingShadows, aPin->IsBrightened() );
|
|
|
|
|
2018-08-30 19:44:10 +00:00
|
|
|
return;
|
2024-01-16 15:29:13 +00:00
|
|
|
}
|
2018-09-05 22:17:22 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2021-12-07 20:47:12 +00:00
|
|
|
if( drawingDangling )
|
2021-12-06 18:50:00 +00:00
|
|
|
{
|
2021-12-07 20:47:12 +00:00
|
|
|
if( isDangling )
|
2023-12-18 19:16:33 +00:00
|
|
|
drawPinDanglingIndicator( pos, color, drawingShadows, aPin->IsBrightened() );
|
2021-12-06 18:50:00 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-03-13 16:42:05 +00:00
|
|
|
if( m_schSettings.GetDrawBoundingBoxes() )
|
|
|
|
drawItemBoundingBox( aPin );
|
|
|
|
|
2024-04-27 12:47:56 +00:00
|
|
|
VECTOR2I p0 = aPin->GetPinRoot();
|
|
|
|
VECTOR2I dir( sign( pos.x - p0.x ), sign( pos.y - p0.y ) );
|
2022-12-22 14:43:43 +00:00
|
|
|
int len = aPin->GetLength();
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2023-02-09 17:18:56 +00:00
|
|
|
if( drawingOP && !aPin->GetOperatingPoint().IsEmpty() )
|
|
|
|
{
|
|
|
|
int textSize = getOperatingPointTextSize();
|
|
|
|
VECTOR2I mid = ( p0 + pos ) / 2;
|
|
|
|
int textOffset = KiROUND( textSize * 0.22 );
|
|
|
|
TEXT_ATTRIBUTES attrs;
|
|
|
|
|
2023-02-13 18:38:43 +00:00
|
|
|
if( len > textSize )
|
2023-02-09 17:18:56 +00:00
|
|
|
{
|
|
|
|
if( dir.x == 0 )
|
|
|
|
{
|
|
|
|
mid.x += KiROUND( textOffset * 1.2 );
|
|
|
|
attrs.m_Angle = ANGLE_HORIZONTAL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mid.y -= KiROUND( textOffset * 1.2 );
|
|
|
|
attrs.m_Angle = ANGLE_VERTICAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
attrs.m_Halign = GR_TEXT_H_ALIGN_LEFT;
|
|
|
|
attrs.m_Valign = GR_TEXT_V_ALIGN_CENTER;
|
|
|
|
|
|
|
|
attrs.m_Font = KIFONT::FONT::GetFont(); // always use stroke font for performance
|
|
|
|
attrs.m_Size = VECTOR2I( textSize, textSize );
|
|
|
|
attrs.m_StrokeWidth = GetPenSizeForDemiBold( textSize );
|
|
|
|
attrs.m_Color = m_schSettings.GetLayerColor( LAYER_OP_CURRENTS );
|
|
|
|
|
2023-08-06 19:20:53 +00:00
|
|
|
knockoutText( aPin->GetOperatingPoint(), mid, attrs, aPin->GetFontMetrics() );
|
2023-02-09 17:18:56 +00:00
|
|
|
}
|
2023-06-24 13:01:31 +00:00
|
|
|
}
|
2023-02-09 17:18:56 +00:00
|
|
|
|
2023-06-24 13:01:31 +00:00
|
|
|
if( drawingOP )
|
2023-02-09 17:18:56 +00:00
|
|
|
return;
|
|
|
|
|
2018-08-29 18:31:43 +00:00
|
|
|
VECTOR2D pc;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-08-29 18:31:43 +00:00
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetIsFill( false );
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetLineWidth( getLineWidth( aPin, drawingShadows ) );
|
2018-08-29 18:31:43 +00:00
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
m_gal->SetFontBold( false );
|
2020-10-02 20:18:07 +00:00
|
|
|
m_gal->SetFontUnderlined( false );
|
2018-08-29 18:31:43 +00:00
|
|
|
m_gal->SetFontItalic( false );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2020-05-03 23:55:31 +00:00
|
|
|
const int radius = externalPinDecoSize( *aPin );
|
2018-10-14 10:36:02 +00:00
|
|
|
const int diam = radius*2;
|
2020-05-03 23:55:31 +00:00
|
|
|
const int clock_size = internalPinDecoSize( *aPin );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
if( aPin->GetType() == ELECTRICAL_PINTYPE::PT_NC ) // Draw a N.C. symbol
|
2018-08-29 18:31:43 +00:00
|
|
|
{
|
2018-08-30 19:44:10 +00:00
|
|
|
m_gal->DrawLine( p0, pos );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-08-30 19:44:10 +00:00
|
|
|
m_gal->DrawLine( pos + VECTOR2D( -1, -1 ) * TARGET_PIN_RADIUS,
|
|
|
|
pos + VECTOR2D( 1, 1 ) * TARGET_PIN_RADIUS );
|
|
|
|
m_gal->DrawLine( pos + VECTOR2D( 1, -1 ) * TARGET_PIN_RADIUS ,
|
|
|
|
pos + VECTOR2D( -1, 1 ) * TARGET_PIN_RADIUS );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
2019-10-06 10:59:18 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
switch( aPin->GetShape() )
|
|
|
|
{
|
2024-04-20 09:44:34 +00:00
|
|
|
default:
|
2020-01-18 20:51:28 +00:00
|
|
|
case GRAPHIC_PINSHAPE::LINE:
|
2019-10-06 10:59:18 +00:00
|
|
|
m_gal->DrawLine( p0, pos );
|
|
|
|
break;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
case GRAPHIC_PINSHAPE::INVERTED:
|
2019-10-06 10:59:18 +00:00
|
|
|
m_gal->DrawCircle( p0 + dir * radius, radius );
|
|
|
|
m_gal->DrawLine( p0 + dir * ( diam ), pos );
|
|
|
|
break;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
case GRAPHIC_PINSHAPE::INVERTED_CLOCK:
|
2019-10-06 10:59:18 +00:00
|
|
|
pc = p0 - dir * clock_size ;
|
|
|
|
|
|
|
|
triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
|
|
|
|
pc,
|
|
|
|
p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
|
|
|
|
|
|
|
|
m_gal->DrawCircle( p0 + dir * radius, radius );
|
|
|
|
m_gal->DrawLine( p0 + dir * ( diam ), pos );
|
2020-01-18 20:51:28 +00:00
|
|
|
break;
|
2019-10-06 10:59:18 +00:00
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
case GRAPHIC_PINSHAPE::CLOCK_LOW:
|
|
|
|
case GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK:
|
2019-10-06 10:59:18 +00:00
|
|
|
pc = p0 - dir * clock_size ;
|
|
|
|
|
|
|
|
triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
|
|
|
|
pc,
|
|
|
|
p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
|
|
|
|
|
2019-12-12 19:55:21 +00:00
|
|
|
if( !dir.y )
|
2019-10-06 10:59:18 +00:00
|
|
|
{
|
|
|
|
triLine( p0 + VECTOR2D(dir.x, 0) * diam,
|
|
|
|
p0 + VECTOR2D(dir.x, -1) * diam,
|
|
|
|
p0 );
|
|
|
|
}
|
|
|
|
else /* MapX1 = 0 */
|
|
|
|
{
|
|
|
|
triLine( p0 + VECTOR2D( 0, dir.y) * diam,
|
|
|
|
p0 + VECTOR2D(-1, dir.y) * diam,
|
|
|
|
p0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_gal->DrawLine( p0, pos );
|
|
|
|
break;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
case GRAPHIC_PINSHAPE::CLOCK:
|
2019-10-06 10:59:18 +00:00
|
|
|
m_gal->DrawLine( p0, pos );
|
|
|
|
|
2019-12-12 19:55:21 +00:00
|
|
|
if( !dir.y )
|
2019-10-06 10:59:18 +00:00
|
|
|
{
|
|
|
|
triLine( p0 + VECTOR2D( 0, clock_size ),
|
|
|
|
p0 + VECTOR2D( -dir.x * clock_size, 0 ),
|
|
|
|
p0 + VECTOR2D( 0, -clock_size ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
triLine( p0 + VECTOR2D( clock_size, 0 ),
|
|
|
|
p0 + VECTOR2D( 0, -dir.y * clock_size ),
|
|
|
|
p0 + VECTOR2D( -clock_size, 0 ) );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
case GRAPHIC_PINSHAPE::INPUT_LOW:
|
2019-10-06 10:59:18 +00:00
|
|
|
m_gal->DrawLine( p0, pos );
|
|
|
|
|
2019-12-12 19:55:21 +00:00
|
|
|
if( !dir.y )
|
2019-10-06 10:59:18 +00:00
|
|
|
{
|
|
|
|
triLine( p0 + VECTOR2D(dir.x, 0) * diam,
|
|
|
|
p0 + VECTOR2D(dir.x, -1) * diam,
|
|
|
|
p0 );
|
|
|
|
}
|
|
|
|
else /* MapX1 = 0 */
|
|
|
|
{
|
|
|
|
triLine( p0 + VECTOR2D( 0, dir.y) * diam,
|
|
|
|
p0 + VECTOR2D(-1, dir.y) * diam,
|
|
|
|
p0 );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
case GRAPHIC_PINSHAPE::OUTPUT_LOW: // IEEE symbol "Active Low Output"
|
2019-10-06 10:59:18 +00:00
|
|
|
m_gal->DrawLine( p0, pos );
|
|
|
|
|
|
|
|
if( !dir.y ) // Horizontal pin
|
|
|
|
m_gal->DrawLine( p0 - VECTOR2D( 0, diam ), p0 + VECTOR2D( dir.x, 0 ) * diam );
|
|
|
|
else // Vertical pin
|
|
|
|
m_gal->DrawLine( p0 - VECTOR2D( diam, 0 ), p0 + VECTOR2D( 0, dir.y ) * diam );
|
|
|
|
break;
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
case GRAPHIC_PINSHAPE::NONLOGIC: // NonLogic pin symbol
|
2019-10-06 10:59:18 +00:00
|
|
|
m_gal->DrawLine( p0, pos );
|
|
|
|
|
|
|
|
m_gal->DrawLine( p0 - VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius,
|
|
|
|
p0 + VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius );
|
|
|
|
m_gal->DrawLine( p0 - VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius,
|
|
|
|
p0 + VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-20 09:44:34 +00:00
|
|
|
if( drawingShadows && !eeconfig()->m_Selection.draw_selected_children )
|
|
|
|
return;
|
2019-11-21 15:48:44 +00:00
|
|
|
|
2018-09-19 20:52:13 +00:00
|
|
|
// Draw the labels
|
2024-04-20 09:44:34 +00:00
|
|
|
const SYMBOL* symbol = aPin->GetParentSymbol();
|
|
|
|
float penWidth = (float) m_schSettings.GetDefaultPenWidth();
|
|
|
|
int textOffset = symbol->GetPinNameOffset();
|
|
|
|
float nameStrokeWidth = getLineWidth( aPin, false );
|
|
|
|
float numStrokeWidth = getLineWidth( aPin, false );
|
|
|
|
bool showPinNames = symbol->GetShowPinNames();
|
|
|
|
bool showPinNumbers = m_schSettings.m_ShowPinNumbers || symbol->GetShowPinNumbers();
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2022-09-07 10:05:23 +00:00
|
|
|
nameStrokeWidth = Clamp_Text_PenSize( nameStrokeWidth, aPin->GetNameTextSize(), true );
|
|
|
|
numStrokeWidth = Clamp_Text_PenSize( numStrokeWidth, aPin->GetNumberTextSize(), true );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2022-12-22 14:43:43 +00:00
|
|
|
float PIN_TEXT_MARGIN = schIUScale.MilsToIU( KiROUND( 24 * m_schSettings.m_TextOffsetRatio ) );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-08-30 01:38:08 +00:00
|
|
|
// Four locations around a pin where text can be drawn
|
|
|
|
enum { INSIDE = 0, OUTSIDE, ABOVE, BELOW };
|
2022-12-22 14:43:43 +00:00
|
|
|
int size[4] = { 0, 0, 0, 0 };
|
|
|
|
float thickness[4] = { numStrokeWidth, numStrokeWidth, numStrokeWidth, numStrokeWidth };
|
|
|
|
COLOR4D colour[4];
|
2018-08-30 01:38:08 +00:00
|
|
|
wxString text[4];
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-08-30 01:38:08 +00:00
|
|
|
// TextOffset > 0 means pin NAMES on inside, pin NUMBERS above and nothing below
|
|
|
|
if( textOffset )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2022-09-06 16:28:44 +00:00
|
|
|
size [INSIDE] = showPinNames ? aPin->GetNameTextSize() : 0;
|
2021-09-17 11:08:16 +00:00
|
|
|
thickness[INSIDE] = nameStrokeWidth;
|
2022-10-21 21:42:09 +00:00
|
|
|
colour [INSIDE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows, aDimmed );
|
2021-06-12 18:54:34 +00:00
|
|
|
text [INSIDE] = aPin->GetShownName();
|
2018-08-30 01:38:08 +00:00
|
|
|
|
2022-09-06 16:28:44 +00:00
|
|
|
size [ABOVE] = showPinNumbers ? aPin->GetNumberTextSize() : 0;
|
2021-09-17 11:08:16 +00:00
|
|
|
thickness[ABOVE] = numStrokeWidth;
|
2022-10-21 21:42:09 +00:00
|
|
|
colour [ABOVE] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows, aDimmed );
|
2021-06-12 18:54:34 +00:00
|
|
|
text [ABOVE] = aPin->GetShownNumber();
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
2023-06-25 15:01:06 +00:00
|
|
|
// Otherwise if both are shown pin NAMES go above and pin NUMBERS go below
|
|
|
|
else if( showPinNames && showPinNumbers )
|
2018-08-30 01:38:08 +00:00
|
|
|
{
|
2023-06-26 19:51:58 +00:00
|
|
|
size [ABOVE] = aPin->GetNameTextSize();
|
2021-09-17 11:08:16 +00:00
|
|
|
thickness[ABOVE] = nameStrokeWidth;
|
2022-10-21 21:42:09 +00:00
|
|
|
colour [ABOVE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows, aDimmed );
|
2021-06-12 18:54:34 +00:00
|
|
|
text [ABOVE] = aPin->GetShownName();
|
2018-08-30 01:38:08 +00:00
|
|
|
|
2023-06-26 19:51:58 +00:00
|
|
|
size [BELOW] = aPin->GetNumberTextSize();
|
2021-09-17 11:08:16 +00:00
|
|
|
thickness[BELOW] = numStrokeWidth;
|
2022-10-21 21:42:09 +00:00
|
|
|
colour [BELOW] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows, aDimmed );
|
2021-06-12 18:54:34 +00:00
|
|
|
text [BELOW] = aPin->GetShownNumber();
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
2023-06-25 15:01:06 +00:00
|
|
|
else if( showPinNames )
|
|
|
|
{
|
|
|
|
size [ABOVE] = aPin->GetNameTextSize();
|
|
|
|
thickness[ABOVE] = nameStrokeWidth;
|
|
|
|
colour [ABOVE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows, aDimmed );
|
|
|
|
text [ABOVE] = aPin->GetShownName();
|
|
|
|
}
|
|
|
|
else if( showPinNumbers )
|
|
|
|
{
|
|
|
|
size [ABOVE] = aPin->GetNumberTextSize();
|
|
|
|
thickness[ABOVE] = numStrokeWidth;
|
|
|
|
colour [ABOVE] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows, aDimmed );
|
|
|
|
text [ABOVE] = aPin->GetShownNumber();
|
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-09-02 20:19:22 +00:00
|
|
|
if( m_schSettings.m_ShowPinsElectricalType )
|
2018-08-30 01:38:08 +00:00
|
|
|
{
|
2022-12-22 14:43:43 +00:00
|
|
|
size [OUTSIDE] = std::max( aPin->GetNameTextSize() * 3 / 4, schIUScale.mmToIU( 0.7 ) );
|
|
|
|
thickness[OUTSIDE] = float( size[OUTSIDE] ) / 8.0f;
|
2022-10-21 21:42:09 +00:00
|
|
|
colour [OUTSIDE] = getRenderColor( aPin, LAYER_PRIVATE_NOTES, drawingShadows, aDimmed );
|
2018-08-30 01:38:08 +00:00
|
|
|
text [OUTSIDE] = aPin->GetElectricalTypeName();
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2022-05-13 21:36:20 +00:00
|
|
|
// Rendering text is expensive (particularly when using outline fonts). At small effective
|
|
|
|
// sizes (ie: zoomed out) the visual differences between outline and/or stroke fonts and the
|
|
|
|
// bitmap font becomes immaterial, and there's often more to draw when zoomed out so the
|
|
|
|
// performance gain becomes more significant.
|
|
|
|
#define BITMAP_FONT_SIZE_THRESHOLD 3.5
|
|
|
|
|
|
|
|
bool renderTextAsBitmap = size[0] * m_gal->GetWorldScale() < BITMAP_FONT_SIZE_THRESHOLD
|
|
|
|
&& size[1] * m_gal->GetWorldScale() < BITMAP_FONT_SIZE_THRESHOLD
|
|
|
|
&& size[2] * m_gal->GetWorldScale() < BITMAP_FONT_SIZE_THRESHOLD
|
|
|
|
&& size[3] * m_gal->GetWorldScale() < BITMAP_FONT_SIZE_THRESHOLD;
|
|
|
|
|
2018-08-30 19:44:10 +00:00
|
|
|
if( !aPin->IsVisible() )
|
|
|
|
{
|
|
|
|
for( COLOR4D& c : colour )
|
2022-10-21 21:42:09 +00:00
|
|
|
c = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows, aDimmed );
|
2018-08-30 19:44:10 +00:00
|
|
|
}
|
|
|
|
|
2022-12-22 14:43:43 +00:00
|
|
|
float insideOffset = (float) textOffset - thickness[INSIDE] / 2.0f;
|
|
|
|
float outsideOffset = PIN_TEXT_MARGIN + TARGET_PIN_RADIUS - thickness[OUTSIDE] / 2.0f;
|
|
|
|
float aboveOffset = PIN_TEXT_MARGIN + penWidth / 2.0f + thickness[ABOVE] / 2.0f;
|
|
|
|
float belowOffset = PIN_TEXT_MARGIN + penWidth / 2.0f + thickness[BELOW] / 2.0f;
|
2021-09-17 11:08:16 +00:00
|
|
|
|
2021-12-07 20:47:12 +00:00
|
|
|
if( isDangling )
|
2022-12-22 14:43:43 +00:00
|
|
|
outsideOffset += TARGET_PIN_RADIUS / 2.0f;
|
2019-07-30 01:57:41 +00:00
|
|
|
|
|
|
|
if( drawingShadows )
|
|
|
|
{
|
2021-09-15 20:03:07 +00:00
|
|
|
float shadowWidth = getShadowWidth( aPin->IsBrightened() );
|
2021-09-15 20:15:55 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
for( float& t : thickness )
|
2021-09-15 20:15:55 +00:00
|
|
|
t += shadowWidth;
|
2023-06-22 11:20:47 +00:00
|
|
|
|
2023-06-23 08:32:23 +00:00
|
|
|
// Due to the fact a shadow text in position INSIDE or OUTSIDE is drawn left or right aligned,
|
|
|
|
// it needs an offset = shadowWidth/2 to be drawn at the same place as normal text
|
2023-06-22 11:20:47 +00:00
|
|
|
// texts drawn as GR_TEXT_H_ALIGN_CENTER do not need a specific offset.
|
2023-06-23 08:32:23 +00:00
|
|
|
// this offset is shadowWidth/2 but for some reason we need to slightly modify this offset
|
|
|
|
// for a better look (better alignment of shadow shape), for KiCad font only
|
|
|
|
if( !KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font )->IsOutline() )
|
|
|
|
{
|
|
|
|
const float adjust = 1.2f; // Value chosen after tests
|
|
|
|
float shadowOffset = shadowWidth/2.0f * adjust;
|
|
|
|
insideOffset -= shadowOffset;
|
|
|
|
outsideOffset -= shadowOffset;
|
|
|
|
}
|
2019-07-30 01:57:41 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2021-12-31 14:07:24 +00:00
|
|
|
auto drawText =
|
|
|
|
[&]( int i, const VECTOR2D& aPos, GR_TEXT_H_ALIGN_T hAlign, GR_TEXT_V_ALIGN_T vAlign,
|
|
|
|
const EDA_ANGLE& aAngle )
|
2021-09-15 20:15:55 +00:00
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
if( text[i].IsEmpty() )
|
|
|
|
return;
|
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
// Which of these gets used depends on the font technology, so set both
|
2021-09-15 20:15:55 +00:00
|
|
|
m_gal->SetStrokeColor( colour[i] );
|
|
|
|
m_gal->SetFillColor( colour[i] );
|
|
|
|
|
2021-12-31 14:07:24 +00:00
|
|
|
TEXT_ATTRIBUTES attrs;
|
2023-05-27 15:30:12 +00:00
|
|
|
attrs.m_Font = KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font );
|
2022-01-11 13:47:21 +00:00
|
|
|
attrs.m_Size = VECTOR2I( size[i], size[i] );
|
2021-12-31 14:07:24 +00:00
|
|
|
attrs.m_Halign = hAlign;
|
|
|
|
attrs.m_Valign = vAlign;
|
|
|
|
attrs.m_Angle = aAngle;
|
2022-12-22 14:43:43 +00:00
|
|
|
attrs.m_StrokeWidth = KiROUND( thickness[i] );
|
2021-09-15 20:15:55 +00:00
|
|
|
|
2023-05-27 15:30:12 +00:00
|
|
|
if( drawingShadows && !attrs.m_Font->IsOutline() )
|
2023-01-28 20:01:58 +00:00
|
|
|
{
|
2023-08-06 19:20:53 +00:00
|
|
|
strokeText( text[i], aPos, attrs, aPin->GetFontMetrics() );
|
2023-01-28 20:01:58 +00:00
|
|
|
}
|
|
|
|
else if( drawingShadows )
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
2024-04-27 12:47:56 +00:00
|
|
|
boxText( text[i], aPos, attrs, aPin->GetFontMetrics() );
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
2022-05-13 21:36:20 +00:00
|
|
|
else if( nonCached( aPin ) && renderTextAsBitmap )
|
2022-02-23 12:07:33 +00:00
|
|
|
{
|
|
|
|
bitmapText( text[i], aPos, attrs );
|
2024-04-20 09:44:34 +00:00
|
|
|
const_cast<SCH_PIN*>( aPin )->SetFlags( IS_SHOWN_AS_BITMAP );
|
2022-02-23 12:07:33 +00:00
|
|
|
}
|
2021-09-15 20:15:55 +00:00
|
|
|
else
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
2023-08-06 19:20:53 +00:00
|
|
|
strokeText( text[i], aPos, attrs, aPin->GetFontMetrics() );
|
2024-04-20 09:44:34 +00:00
|
|
|
const_cast<SCH_PIN*>( aPin )->SetFlags( IS_SHOWN_AS_BITMAP );
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
2021-09-15 20:15:55 +00:00
|
|
|
};
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2024-04-27 12:47:56 +00:00
|
|
|
switch( aPin->GetOrientation() )
|
2018-08-29 18:31:43 +00:00
|
|
|
{
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_LEFT:
|
2018-08-30 01:38:08 +00:00
|
|
|
if( size[INSIDE] )
|
|
|
|
{
|
2022-12-22 14:43:43 +00:00
|
|
|
drawText( INSIDE, pos + VECTOR2D( -insideOffset - (float) len, 0 ),
|
2022-01-13 12:29:46 +00:00
|
|
|
GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, ANGLE_HORIZONTAL );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[OUTSIDE] )
|
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
drawText( OUTSIDE, pos + VECTOR2D( outsideOffset, 0 ),
|
2022-01-13 12:29:46 +00:00
|
|
|
GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, ANGLE_HORIZONTAL );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[ABOVE] )
|
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
drawText( ABOVE, pos + VECTOR2D( -len / 2.0, -aboveOffset ),
|
2022-01-13 12:29:46 +00:00
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, ANGLE_HORIZONTAL );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[BELOW] )
|
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
drawText( BELOW, pos + VECTOR2D( -len / 2.0, belowOffset ),
|
2022-01-13 12:29:46 +00:00
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, ANGLE_HORIZONTAL );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
break;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_RIGHT:
|
2018-08-30 01:38:08 +00:00
|
|
|
if( size[INSIDE] )
|
|
|
|
{
|
2022-12-22 14:43:43 +00:00
|
|
|
drawText( INSIDE, pos + VECTOR2D( insideOffset + (float) len, 0 ),
|
2022-01-13 12:29:46 +00:00
|
|
|
GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, ANGLE_HORIZONTAL );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[OUTSIDE] )
|
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
drawText( OUTSIDE, pos + VECTOR2D( -outsideOffset, 0 ),
|
2022-01-13 12:29:46 +00:00
|
|
|
GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, ANGLE_HORIZONTAL );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[ABOVE] )
|
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
drawText( ABOVE, pos + VECTOR2D( len / 2.0, -aboveOffset ),
|
2022-01-13 12:29:46 +00:00
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, ANGLE_HORIZONTAL );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[BELOW] )
|
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
drawText( BELOW, pos + VECTOR2D( len / 2.0, belowOffset ),
|
2022-01-13 12:29:46 +00:00
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, ANGLE_HORIZONTAL );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
break;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_DOWN:
|
2018-08-30 01:38:08 +00:00
|
|
|
if( size[INSIDE] )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2022-12-22 14:43:43 +00:00
|
|
|
drawText( INSIDE, pos + VECTOR2D( 0, insideOffset + (float) len ),
|
2022-01-13 12:29:46 +00:00
|
|
|
GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, ANGLE_VERTICAL );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
2018-08-30 01:38:08 +00:00
|
|
|
if( size[OUTSIDE] )
|
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
drawText( OUTSIDE, pos + VECTOR2D( 0, -outsideOffset ),
|
2022-01-13 12:29:46 +00:00
|
|
|
GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, ANGLE_VERTICAL );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[ABOVE] )
|
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
drawText( ABOVE, pos + VECTOR2D( -aboveOffset, len / 2.0 ),
|
2022-01-13 12:29:46 +00:00
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, ANGLE_VERTICAL );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[BELOW] )
|
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
drawText( BELOW, pos + VECTOR2D( belowOffset, len / 2.0 ),
|
2022-01-13 12:29:46 +00:00
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, ANGLE_VERTICAL );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
break;
|
2018-08-29 18:31:43 +00:00
|
|
|
|
2023-07-27 03:46:15 +00:00
|
|
|
case PIN_ORIENTATION::PIN_UP:
|
2018-08-30 01:38:08 +00:00
|
|
|
if( size[INSIDE] )
|
|
|
|
{
|
2022-12-22 14:43:43 +00:00
|
|
|
drawText( INSIDE, pos + VECTOR2D( 0, -insideOffset - (float) len ),
|
2022-01-13 12:29:46 +00:00
|
|
|
GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, ANGLE_VERTICAL );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[OUTSIDE] )
|
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
drawText( OUTSIDE, pos + VECTOR2D( 0, outsideOffset ),
|
2022-01-13 12:29:46 +00:00
|
|
|
GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, ANGLE_VERTICAL );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[ABOVE] )
|
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
drawText( ABOVE, pos + VECTOR2D( -aboveOffset, -len / 2.0 ),
|
2022-01-13 12:29:46 +00:00
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, ANGLE_VERTICAL );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[BELOW] )
|
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
drawText( BELOW, pos + VECTOR2D( belowOffset, -len / 2.0 ),
|
2022-01-13 12:29:46 +00:00
|
|
|
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, ANGLE_VERTICAL );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
break;
|
2018-09-19 20:52:13 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
wxFAIL_MSG( "Unknown pin orientation" );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-30 22:43:42 +00:00
|
|
|
|
2018-09-09 20:14:00 +00:00
|
|
|
// Draw the target (an open square) for a wire or label which has no connection or is
|
|
|
|
// being moved.
|
2023-12-18 19:16:33 +00:00
|
|
|
void SCH_PAINTER::drawDanglingIndicator( const VECTOR2I& aPos, const COLOR4D& aColor, int aWidth,
|
|
|
|
bool aDangling, bool aDrawingShadows, bool aBrightened )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2024-01-16 15:29:13 +00:00
|
|
|
if( m_schSettings.IsPrinting() )
|
|
|
|
return;
|
|
|
|
|
2022-12-12 14:03:26 +00:00
|
|
|
int size = aDangling ? DANGLING_SYMBOL_SIZE : UNSELECTED_END_SIZE;
|
|
|
|
|
|
|
|
if( !aDangling )
|
|
|
|
aWidth /= 2;
|
|
|
|
|
|
|
|
VECTOR2I radius( aWidth + schIUScale.MilsToIU( size / 2 ),
|
|
|
|
aWidth + schIUScale.MilsToIU( size / 2 ) );
|
2018-09-09 20:14:00 +00:00
|
|
|
|
2021-12-06 18:50:00 +00:00
|
|
|
// Dangling symbols must be drawn in a slightly different colour so they can be seen when
|
|
|
|
// they overlap with a junction dot.
|
|
|
|
m_gal->SetStrokeColor( aColor.Brightened( 0.3 ) );
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetIsFill( false );
|
2021-09-15 20:03:07 +00:00
|
|
|
m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth( aBrightened )
|
2023-12-18 19:16:33 +00:00
|
|
|
: m_schSettings.GetDanglingIndicatorThickness() );
|
2018-09-09 20:14:00 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->DrawRectangle( aPos - radius, aPos + radius );
|
2018-08-30 22:43:42 +00:00
|
|
|
}
|
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2023-06-12 09:45:29 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_JUNCTION* aJct, int aLayer )
|
2018-08-30 22:43:42 +00:00
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
|
|
|
|
2024-01-16 15:29:13 +00:00
|
|
|
if( m_schSettings.IsPrinting() && drawingShadows )
|
|
|
|
return;
|
|
|
|
|
2021-09-15 20:03:07 +00:00
|
|
|
if( drawingShadows && !( aJct->IsBrightened() || aJct->IsSelected() ) )
|
2019-07-30 01:57:41 +00:00
|
|
|
return;
|
|
|
|
|
2020-04-23 01:33:57 +00:00
|
|
|
COLOR4D color = getRenderColor( aJct, aJct->GetLayer(), drawingShadows );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2021-08-31 10:48:45 +00:00
|
|
|
int junctionSize = aJct->GetEffectiveDiameter() / 2;
|
2020-06-24 17:35:33 +00:00
|
|
|
|
2020-10-08 17:04:53 +00:00
|
|
|
if( junctionSize > 1 )
|
|
|
|
{
|
|
|
|
m_gal->SetIsStroke( drawingShadows );
|
|
|
|
m_gal->SetLineWidth( getLineWidth( aJct, drawingShadows ) );
|
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
m_gal->SetIsFill( !drawingShadows );
|
|
|
|
m_gal->SetFillColor( color );
|
|
|
|
m_gal->DrawCircle( aJct->GetPosition(), junctionSize );
|
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-08-30 22:43:42 +00:00
|
|
|
|
2023-06-12 09:45:29 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_LINE* aLine, int aLayer )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
2024-01-16 15:29:13 +00:00
|
|
|
|
|
|
|
if( m_schSettings.IsPrinting() && drawingShadows )
|
|
|
|
return;
|
|
|
|
|
2021-12-07 20:47:12 +00:00
|
|
|
bool drawingDangling = aLayer == LAYER_DANGLING;
|
2023-02-09 17:18:56 +00:00
|
|
|
bool drawingOP = aLayer == LAYER_OP_VOLTAGES;
|
2019-07-30 01:57:41 +00:00
|
|
|
|
2021-09-15 20:03:07 +00:00
|
|
|
if( drawingShadows && !( aLine->IsBrightened() || aLine->IsSelected() ) )
|
2019-07-30 01:57:41 +00:00
|
|
|
return;
|
2018-09-05 22:17:22 +00:00
|
|
|
|
2024-04-10 09:26:43 +00:00
|
|
|
// Line end dangling status isn't updated until the line is finished drawing, so don't warn
|
|
|
|
// them about ends that are probably connected
|
2022-03-03 14:35:57 +00:00
|
|
|
if( aLine->IsNew() && drawingDangling )
|
|
|
|
return;
|
|
|
|
|
2023-11-25 13:05:45 +00:00
|
|
|
COLOR4D color = getRenderColor( aLine, aLine->GetLayer(), drawingShadows );
|
|
|
|
float width = getLineWidth( aLine, drawingShadows );
|
|
|
|
LINE_STYLE lineStyle = aLine->GetEffectiveLineStyle();
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2023-01-04 16:02:00 +00:00
|
|
|
if( ( drawingDangling || drawingShadows ) && !aLine->IsNew() )
|
2021-12-06 18:50:00 +00:00
|
|
|
{
|
2022-12-08 17:42:52 +00:00
|
|
|
if( ( aLine->IsWire() && aLine->IsStartDangling() )
|
2023-01-04 16:02:00 +00:00
|
|
|
|| ( drawingShadows && aLine->IsSelected() && !aLine->HasFlag( STARTPOINT ) ) )
|
2021-12-06 18:50:00 +00:00
|
|
|
{
|
2024-04-10 09:26:43 +00:00
|
|
|
COLOR4D indicatorColor( color );
|
|
|
|
|
|
|
|
if( drawingShadows && !aLine->HasFlag( STARTPOINT ) )
|
|
|
|
indicatorColor.Invert();
|
|
|
|
|
|
|
|
drawDanglingIndicator( aLine->GetStartPoint(), indicatorColor, KiROUND( width ),
|
2023-12-18 19:16:33 +00:00
|
|
|
aLine->IsWire() && aLine->IsStartDangling(), drawingShadows,
|
|
|
|
aLine->IsBrightened() );
|
2021-12-06 18:50:00 +00:00
|
|
|
}
|
|
|
|
|
2022-12-08 17:42:52 +00:00
|
|
|
if( ( aLine->IsWire() && aLine->IsEndDangling() )
|
2023-01-04 16:02:00 +00:00
|
|
|
|| ( drawingShadows && aLine->IsSelected() && !aLine->HasFlag( ENDPOINT ) ) )
|
2021-12-06 18:50:00 +00:00
|
|
|
{
|
2024-04-10 09:26:43 +00:00
|
|
|
COLOR4D indicatorColor( color );
|
|
|
|
|
|
|
|
if( drawingShadows && !aLine->HasFlag( ENDPOINT ) )
|
|
|
|
indicatorColor.Invert();
|
|
|
|
|
|
|
|
drawDanglingIndicator( aLine->GetEndPoint(), indicatorColor, KiROUND( width ),
|
2023-12-18 19:16:33 +00:00
|
|
|
aLine->IsWire() && aLine->IsEndDangling(), drawingShadows,
|
|
|
|
aLine->IsBrightened() );
|
2021-12-06 18:50:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-04 16:02:00 +00:00
|
|
|
if( drawingDangling )
|
|
|
|
return;
|
|
|
|
|
2023-02-09 17:18:56 +00:00
|
|
|
if( drawingOP && !aLine->GetOperatingPoint().IsEmpty() )
|
|
|
|
{
|
|
|
|
int textSize = getOperatingPointTextSize();
|
|
|
|
VECTOR2I pos = aLine->GetMidPoint();
|
|
|
|
int textOffset = KiROUND( textSize * 0.22 );
|
|
|
|
TEXT_ATTRIBUTES attrs;
|
|
|
|
|
|
|
|
if( aLine->GetStartPoint().y == aLine->GetEndPoint().y )
|
|
|
|
{
|
|
|
|
pos.y -= textOffset;
|
|
|
|
attrs.m_Halign = GR_TEXT_H_ALIGN_CENTER;
|
|
|
|
attrs.m_Valign = GR_TEXT_V_ALIGN_BOTTOM;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pos.x += KiROUND( textOffset * 1.2 );
|
|
|
|
attrs.m_Halign = GR_TEXT_H_ALIGN_LEFT;
|
|
|
|
attrs.m_Valign = GR_TEXT_V_ALIGN_CENTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
attrs.m_Font = KIFONT::FONT::GetFont(); // always use stroke font for performance
|
|
|
|
attrs.m_Size = VECTOR2I( textSize, textSize );
|
|
|
|
attrs.m_StrokeWidth = GetPenSizeForDemiBold( textSize );
|
|
|
|
attrs.m_Color = m_schSettings.GetLayerColor( LAYER_OP_VOLTAGES );
|
|
|
|
|
2023-08-06 19:20:53 +00:00
|
|
|
knockoutText( aLine->GetOperatingPoint(), pos, attrs, aLine->GetFontMetrics() );
|
2023-02-09 17:18:56 +00:00
|
|
|
}
|
|
|
|
|
2023-06-24 13:01:31 +00:00
|
|
|
if( drawingOP )
|
|
|
|
return;
|
2023-11-27 14:42:04 +00:00
|
|
|
|
2018-09-07 21:33:01 +00:00
|
|
|
m_gal->SetIsStroke( true );
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetStrokeColor( color );
|
2018-08-03 12:18:26 +00:00
|
|
|
m_gal->SetLineWidth( width );
|
2018-09-07 21:33:01 +00:00
|
|
|
|
2023-11-25 13:05:45 +00:00
|
|
|
if( lineStyle <= LINE_STYLE::FIRST_TYPE || drawingShadows )
|
2018-09-07 21:33:01 +00:00
|
|
|
{
|
|
|
|
m_gal->DrawLine( aLine->GetStartPoint(), aLine->GetEndPoint() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-17 19:56:18 +00:00
|
|
|
SHAPE_SEGMENT line( aLine->GetStartPoint(), aLine->GetEndPoint() );
|
2018-09-07 21:33:01 +00:00
|
|
|
|
2022-12-22 14:43:43 +00:00
|
|
|
STROKE_PARAMS::Stroke( &line, lineStyle, KiROUND( width ), &m_schSettings,
|
2024-04-10 09:26:43 +00:00
|
|
|
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
|
|
|
{
|
|
|
|
// DrawLine has problem with 0 length lines so enforce minimum
|
|
|
|
if( a == b )
|
|
|
|
m_gal->DrawLine( a+1, b );
|
|
|
|
else
|
|
|
|
m_gal->DrawLine( a, b );
|
|
|
|
} );
|
2021-07-17 19:56:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer, bool aDimmed )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
2024-04-15 20:18:54 +00:00
|
|
|
if( !isUnitAndConversionShown( aShape ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( aShape->IsPrivate() && !m_schSettings.m_IsSymbolEditor )
|
|
|
|
return;
|
|
|
|
|
2024-04-10 09:26:43 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
2024-01-16 15:29:13 +00:00
|
|
|
|
|
|
|
if( m_schSettings.IsPrinting() && drawingShadows )
|
|
|
|
return;
|
|
|
|
|
2023-11-25 13:05:45 +00:00
|
|
|
LINE_STYLE lineStyle = aShape->GetEffectiveLineStyle();
|
|
|
|
COLOR4D color = getRenderColor( aShape, aLayer, drawingShadows );
|
2022-01-22 22:26:48 +00:00
|
|
|
|
2021-09-15 20:03:07 +00:00
|
|
|
if( drawingShadows && !( aShape->IsBrightened() || aShape->IsSelected() ) )
|
2021-07-17 19:56:18 +00:00
|
|
|
return;
|
2018-09-07 21:33:01 +00:00
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
auto drawShape =
|
|
|
|
[&]( const SCH_SHAPE* shape )
|
|
|
|
{
|
|
|
|
switch( shape->GetShape() )
|
|
|
|
{
|
|
|
|
case SHAPE_T::ARC:
|
|
|
|
{
|
2024-04-27 12:47:56 +00:00
|
|
|
VECTOR2D start = shape->GetStart();
|
|
|
|
VECTOR2D mid = shape->GetArcMid();
|
|
|
|
VECTOR2D end = shape->GetEnd();
|
2024-04-15 20:18:54 +00:00
|
|
|
VECTOR2D center = CalcArcCenter( start, mid, end );
|
|
|
|
|
|
|
|
EDA_ANGLE startAngle( start - center );
|
|
|
|
EDA_ANGLE midAngle( mid - center );
|
|
|
|
EDA_ANGLE endAngle( end - center );
|
|
|
|
|
|
|
|
EDA_ANGLE angle1 = midAngle - startAngle;
|
|
|
|
EDA_ANGLE angle2 = endAngle - midAngle;
|
2021-07-17 19:56:18 +00:00
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
EDA_ANGLE angle = angle1.Normalize180() + angle2.Normalize180();
|
|
|
|
|
|
|
|
m_gal->DrawArc( center, ( start - center ).EuclideanNorm(), startAngle, angle );
|
2021-07-17 19:56:18 +00:00
|
|
|
break;
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
2021-07-17 19:56:18 +00:00
|
|
|
|
|
|
|
case SHAPE_T::CIRCLE:
|
2024-04-27 12:47:56 +00:00
|
|
|
m_gal->DrawCircle( shape->GetPosition(), shape->GetRadius() );
|
2021-07-17 19:56:18 +00:00
|
|
|
break;
|
|
|
|
|
2023-07-24 16:07:56 +00:00
|
|
|
case SHAPE_T::RECTANGLE:
|
2024-04-27 12:47:56 +00:00
|
|
|
m_gal->DrawRectangle( shape->GetPosition(), shape->GetEnd() );
|
2021-07-17 19:56:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SHAPE_T::POLY:
|
|
|
|
{
|
2024-04-25 14:24:46 +00:00
|
|
|
const std::vector<SHAPE*> polySegments = shape->MakeEffectiveShapes( true );
|
2024-04-27 12:47:56 +00:00
|
|
|
std::deque<VECTOR2D> pts;
|
2024-04-25 14:24:46 +00:00
|
|
|
|
|
|
|
for( SHAPE* polySegment : polySegments )
|
2024-04-27 12:47:56 +00:00
|
|
|
pts.push_back( static_cast<SHAPE_SEGMENT*>( polySegment )->GetSeg().A );
|
2024-04-25 14:24:46 +00:00
|
|
|
|
2024-04-27 12:47:56 +00:00
|
|
|
pts.push_back( static_cast<SHAPE_SEGMENT*>( polySegments.back() )->GetSeg().B );
|
2021-07-17 19:56:18 +00:00
|
|
|
|
2024-04-25 14:24:46 +00:00
|
|
|
for( SHAPE* polySegment : polySegments )
|
|
|
|
delete polySegment;
|
2021-07-17 19:56:18 +00:00
|
|
|
|
2024-04-27 12:47:56 +00:00
|
|
|
m_gal->DrawPolygon( pts );
|
2021-07-17 19:56:18 +00:00
|
|
|
break;
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
2021-07-17 19:56:18 +00:00
|
|
|
|
|
|
|
case SHAPE_T::BEZIER:
|
|
|
|
{
|
2024-04-27 12:47:56 +00:00
|
|
|
m_gal->DrawCurve( shape->GetStart(), shape->GetBezierC1(),
|
|
|
|
shape->GetBezierC2(), shape->GetEnd() );
|
2021-07-17 19:56:18 +00:00
|
|
|
break;
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
2021-07-17 19:56:18 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
UNIMPLEMENTED_FOR( shape->SHAPE_T_asString() );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-01-22 22:26:48 +00:00
|
|
|
if( aLayer == LAYER_SELECTION_SHADOWS )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
2022-01-22 22:26:48 +00:00
|
|
|
if( eeconfig()->m_Selection.fill_shapes )
|
|
|
|
{
|
2022-01-25 22:33:37 +00:00
|
|
|
// Consider a NAND gate. We have no idea which side of the arc is "inside"
|
|
|
|
// so we can't reliably fill.
|
|
|
|
if( aShape->GetShape() == SHAPE_T::ARC )
|
|
|
|
m_gal->SetIsFill( aShape->IsFilled() );
|
|
|
|
else
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
|
2022-01-22 22:26:48 +00:00
|
|
|
m_gal->SetIsStroke( false );
|
|
|
|
m_gal->SetFillColor( color );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetLineWidth( getLineWidth( aShape, true ) );
|
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
}
|
2021-07-17 19:56:18 +00:00
|
|
|
|
|
|
|
drawShape( aShape );
|
|
|
|
}
|
2024-04-15 20:18:54 +00:00
|
|
|
else if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
2024-04-10 09:26:43 +00:00
|
|
|
// Do not fill the shape in B&W print mode, to avoid to visible items inside the shape
|
2023-11-23 13:29:07 +00:00
|
|
|
if( aShape->IsFilled() && !m_schSettings.PrintBlackAndWhiteReq() )
|
2022-01-31 19:11:21 +00:00
|
|
|
{
|
2024-04-16 22:41:33 +00:00
|
|
|
if( aShape->GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR )
|
|
|
|
color = m_schSettings.GetLayerColor( LAYER_DEVICE_BACKGROUND );
|
|
|
|
|
2022-01-31 19:11:21 +00:00
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( false );
|
2022-04-05 22:32:48 +00:00
|
|
|
m_gal->SetFillColor( color );
|
2021-07-17 19:56:18 +00:00
|
|
|
|
2022-01-31 19:11:21 +00:00
|
|
|
drawShape( aShape );
|
|
|
|
}
|
2021-07-17 19:56:18 +00:00
|
|
|
}
|
2024-04-25 14:24:46 +00:00
|
|
|
else if( aLayer == LAYER_DEVICE || aLayer == LAYER_NOTES || aLayer == LAYER_PRIVATE_NOTES
|
|
|
|
|| aLayer == LAYER_RULE_AREAS )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
2022-12-22 14:43:43 +00:00
|
|
|
float lineWidth = getLineWidth( aShape, drawingShadows );
|
2021-07-17 19:56:18 +00:00
|
|
|
|
2022-01-31 19:11:21 +00:00
|
|
|
if( lineWidth > 0 )
|
2018-09-07 21:33:01 +00:00
|
|
|
{
|
2022-01-31 19:11:21 +00:00
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetLineWidth( lineWidth );
|
|
|
|
m_gal->SetStrokeColor( color );
|
2018-09-07 21:33:01 +00:00
|
|
|
|
2023-11-25 13:05:45 +00:00
|
|
|
if( lineStyle <= LINE_STYLE::FIRST_TYPE || drawingShadows )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
2022-01-31 19:11:21 +00:00
|
|
|
drawShape( aShape );
|
2021-07-17 19:56:18 +00:00
|
|
|
}
|
2022-01-31 19:11:21 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( true );
|
2018-09-07 21:33:01 +00:00
|
|
|
|
2022-01-31 19:11:21 +00:00
|
|
|
for( SHAPE* shape : shapes )
|
|
|
|
{
|
2022-12-22 14:43:43 +00:00
|
|
|
STROKE_PARAMS::Stroke( shape, lineStyle, KiROUND( lineWidth ), &m_schSettings,
|
2024-04-27 12:47:56 +00:00
|
|
|
[this]( const VECTOR2I& a, const VECTOR2I& b )
|
2022-01-31 19:11:21 +00:00
|
|
|
{
|
|
|
|
// DrawLine has problem with 0 length lines so enforce minimum
|
|
|
|
if( a == b )
|
2024-04-27 12:47:56 +00:00
|
|
|
m_gal->DrawLine( a+1, b );
|
2022-01-31 19:11:21 +00:00
|
|
|
else
|
2024-04-27 12:47:56 +00:00
|
|
|
m_gal->DrawLine( a, b );
|
2022-01-31 19:11:21 +00:00
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( SHAPE* shape : shapes )
|
|
|
|
delete shape;
|
|
|
|
}
|
2018-09-07 21:33:01 +00:00
|
|
|
}
|
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-14 18:04:53 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_TEXT* aText, int aLayer, bool aDimmed )
|
2018-08-30 22:43:42 +00:00
|
|
|
{
|
2024-04-14 18:04:53 +00:00
|
|
|
if( !isUnitAndConversionShown( aText ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( aText->IsPrivate() && !m_schSettings.m_IsSymbolEditor )
|
|
|
|
return;
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
|
|
|
|
2024-01-16 15:29:13 +00:00
|
|
|
if( m_schSettings.IsPrinting() && drawingShadows )
|
|
|
|
return;
|
|
|
|
|
2021-09-15 20:03:07 +00:00
|
|
|
if( drawingShadows && !( aText->IsBrightened() || aText->IsSelected() ) )
|
2019-07-30 01:57:41 +00:00
|
|
|
return;
|
2018-08-31 17:19:09 +00:00
|
|
|
|
2018-08-30 22:43:42 +00:00
|
|
|
switch( aText->Type() )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2024-04-20 09:44:34 +00:00
|
|
|
case SCH_SHEET_PIN_T: aLayer = LAYER_SHEETLABEL; break;
|
|
|
|
case SCH_HIER_LABEL_T: aLayer = LAYER_HIERLABEL; break;
|
|
|
|
case SCH_GLOBAL_LABEL_T: aLayer = LAYER_GLOBLABEL; break;
|
|
|
|
case SCH_DIRECTIVE_LABEL_T: aLayer = LAYER_NETCLASS_REFS; break;
|
2024-04-20 13:35:57 +00:00
|
|
|
case SCH_LABEL_T: aLayer = LAYER_LOCLABEL; break;
|
2024-04-20 09:44:34 +00:00
|
|
|
case SCH_TEXT_T: aLayer = aText->GetParentSymbol() ? LAYER_DEVICE
|
|
|
|
: LAYER_NOTES; break;
|
|
|
|
default: aLayer = LAYER_NOTES; break;
|
2018-08-31 17:19:09 +00:00
|
|
|
}
|
|
|
|
|
2024-04-14 18:04:53 +00:00
|
|
|
COLOR4D color = getRenderColor( aText, aLayer, drawingShadows, aDimmed );
|
2019-07-30 01:57:41 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
if( m_schematic )
|
|
|
|
{
|
2021-11-24 13:19:50 +00:00
|
|
|
SCH_CONNECTION* conn = nullptr;
|
|
|
|
|
|
|
|
if( !aText->IsConnectivityDirty() )
|
|
|
|
conn = aText->Connection();
|
2020-05-13 02:00:37 +00:00
|
|
|
|
|
|
|
if( conn && conn->IsBus() )
|
|
|
|
color = getRenderColor( aText, LAYER_BUS, drawingShadows );
|
|
|
|
}
|
2018-09-09 20:14:00 +00:00
|
|
|
|
2020-04-24 20:33:59 +00:00
|
|
|
if( !( aText->IsVisible() || aText->IsForceVisible() ) )
|
2018-08-31 17:19:09 +00:00
|
|
|
{
|
2024-04-11 10:27:22 +00:00
|
|
|
if( m_schSettings.m_IsSymbolEditor || eeconfig()->m_Appearance.show_hidden_fields )
|
2019-07-30 01:57:41 +00:00
|
|
|
color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
|
2018-09-09 20:14:00 +00:00
|
|
|
else
|
2018-08-31 17:19:09 +00:00
|
|
|
return;
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-11-19 20:29:28 +00:00
|
|
|
m_gal->SetStrokeColor( color );
|
2021-07-17 19:56:18 +00:00
|
|
|
m_gal->SetFillColor( color );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2023-05-05 13:21:56 +00:00
|
|
|
wxString shownText( aText->GetShownText( true ) );
|
2023-01-28 20:01:58 +00:00
|
|
|
VECTOR2I text_offset = aText->GetSchematicTextOffset( &m_schSettings );
|
|
|
|
TEXT_ATTRIBUTES attrs = aText->GetAttributes();
|
|
|
|
KIFONT::FONT* font = getFont( aText );
|
|
|
|
|
|
|
|
attrs.m_Angle = aText->GetDrawRotation();
|
|
|
|
attrs.m_StrokeWidth = KiROUND( getTextThickness( aText ) );
|
|
|
|
|
2024-04-14 18:04:53 +00:00
|
|
|
if( drawingShadows && font->IsOutline() )
|
|
|
|
{
|
|
|
|
BOX2I bBox = aText->GetBoundingBox();
|
|
|
|
bBox.Inflate( KiROUND( getTextThickness( aText ) * 2 ) );
|
|
|
|
|
|
|
|
m_gal->SetIsStroke( false );
|
|
|
|
m_gal->SetIsFill( true );
|
2024-04-27 12:47:56 +00:00
|
|
|
m_gal->DrawRectangle( bBox.GetPosition(), bBox.GetEnd() );
|
2024-04-14 18:04:53 +00:00
|
|
|
}
|
|
|
|
else if( aText->GetLayer() == LAYER_DEVICE )
|
|
|
|
{
|
|
|
|
BOX2I bBox = aText->GetBoundingBox();
|
|
|
|
VECTOR2D pos = bBox.Centre();
|
|
|
|
|
|
|
|
// Due to the fact a shadow text can be drawn left or right aligned, it needs to be
|
|
|
|
// offset by shadowWidth/2 to be drawn at the same place as normal text.
|
|
|
|
// For some reason we need to slightly modify this offset for a better look (better
|
|
|
|
// alignment of shadow shape), for KiCad font only.
|
|
|
|
double shadowOffset = 0.0;
|
|
|
|
|
|
|
|
if( drawingShadows )
|
|
|
|
{
|
|
|
|
double shadowWidth = getShadowWidth( !aText->IsSelected() );
|
|
|
|
attrs.m_StrokeWidth += getShadowWidth( !aText->IsSelected() );
|
|
|
|
|
|
|
|
const double adjust = 1.2f; // Value chosen after tests
|
|
|
|
shadowOffset = shadowWidth/2.0f * adjust;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( attrs.m_Angle == ANGLE_VERTICAL )
|
|
|
|
{
|
|
|
|
switch( attrs.m_Halign )
|
|
|
|
{
|
|
|
|
case GR_TEXT_H_ALIGN_LEFT:
|
|
|
|
pos.y = bBox.GetBottom() + shadowOffset;
|
|
|
|
break;
|
|
|
|
case GR_TEXT_H_ALIGN_CENTER:
|
|
|
|
pos.y = ( bBox.GetTop() + bBox.GetBottom() ) / 2.0;
|
|
|
|
break;
|
|
|
|
case GR_TEXT_H_ALIGN_RIGHT:
|
|
|
|
pos.y = bBox.GetTop() - shadowOffset;
|
|
|
|
break;
|
|
|
|
case GR_TEXT_H_ALIGN_INDETERMINATE:
|
|
|
|
wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch( attrs.m_Halign )
|
|
|
|
{
|
|
|
|
case GR_TEXT_H_ALIGN_LEFT:
|
|
|
|
pos.x = bBox.GetLeft() - shadowOffset;
|
|
|
|
break;
|
|
|
|
case GR_TEXT_H_ALIGN_CENTER:
|
|
|
|
pos.x = ( bBox.GetLeft() + bBox.GetRight() ) / 2.0;
|
|
|
|
break;
|
|
|
|
case GR_TEXT_H_ALIGN_RIGHT:
|
|
|
|
pos.x = bBox.GetRight() + shadowOffset;
|
|
|
|
break;
|
|
|
|
case GR_TEXT_H_ALIGN_INDETERMINATE:
|
|
|
|
wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Because the text vertical position is the bounding box center, the text is drawn as
|
|
|
|
// vertically centered.
|
|
|
|
attrs.m_Valign = GR_TEXT_V_ALIGN_CENTER;
|
|
|
|
|
|
|
|
strokeText( shownText, pos, attrs, aText->GetFontMetrics() );
|
|
|
|
}
|
|
|
|
else if( drawingShadows )
|
2023-01-28 20:01:58 +00:00
|
|
|
{
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
2024-04-11 10:27:22 +00:00
|
|
|
attrs.m_StrokeWidth += KiROUND( getShadowWidth( !aText->IsSelected() ) );
|
2023-01-28 20:01:58 +00:00
|
|
|
attrs.m_Underlined = false;
|
2023-05-17 20:30:31 +00:00
|
|
|
|
|
|
|
// Fudge factors to match 6.0 positioning
|
2024-04-11 10:27:22 +00:00
|
|
|
// New text stroking has width dependent offset but we need to center the shadow on the
|
|
|
|
// stroke. NB this offset is in font.cpp also.
|
|
|
|
int fudge = KiROUND( getShadowWidth( !aText->IsSelected() ) / 1.52 );
|
2023-05-17 20:30:31 +00:00
|
|
|
|
|
|
|
if( attrs.m_Halign == GR_TEXT_H_ALIGN_LEFT && attrs.m_Angle == ANGLE_0 )
|
|
|
|
text_offset.x -= fudge;
|
|
|
|
else if( attrs.m_Halign == GR_TEXT_H_ALIGN_RIGHT && attrs.m_Angle == ANGLE_90 )
|
|
|
|
text_offset.y -= fudge;
|
|
|
|
else if( attrs.m_Halign == GR_TEXT_H_ALIGN_RIGHT && attrs.m_Angle == ANGLE_0 )
|
|
|
|
text_offset.x += fudge;
|
|
|
|
else if( attrs.m_Halign == GR_TEXT_H_ALIGN_LEFT && attrs.m_Angle == ANGLE_90 )
|
|
|
|
text_offset.y += fudge;
|
|
|
|
|
2023-08-06 19:20:53 +00:00
|
|
|
strokeText( shownText, aText->GetDrawPos() + text_offset, attrs, aText->GetFontMetrics() );
|
2019-08-03 23:03:35 +00:00
|
|
|
}
|
2022-05-13 21:36:20 +00:00
|
|
|
else
|
2020-04-14 12:25:00 +00:00
|
|
|
{
|
2022-08-27 18:14:57 +00:00
|
|
|
if( aText->IsHypertext() && aText->IsRollover() )
|
|
|
|
{
|
|
|
|
m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_HOVERED ) );
|
|
|
|
m_gal->SetFillColor( m_schSettings.GetLayerColor( LAYER_HOVERED ) );
|
|
|
|
attrs.m_Underlined = true;
|
|
|
|
}
|
|
|
|
|
2022-04-25 22:22:45 +00:00
|
|
|
// Adjust text drawn in an outline font to more closely mimic the positioning of
|
|
|
|
// SCH_FIELD text.
|
2022-10-25 15:50:53 +00:00
|
|
|
if( font->IsOutline() && aText->Type() == SCH_TEXT_T )
|
2022-04-25 22:22:45 +00:00
|
|
|
{
|
2022-08-30 23:28:18 +00:00
|
|
|
BOX2I firstLineBBox = aText->GetTextBox( 0 );
|
2022-04-25 22:22:45 +00:00
|
|
|
int sizeDiff = firstLineBBox.GetHeight() - aText->GetTextSize().y;
|
|
|
|
int adjust = KiROUND( sizeDiff * 0.4 );
|
|
|
|
VECTOR2I adjust_offset( 0, - adjust );
|
|
|
|
|
|
|
|
RotatePoint( adjust_offset, aText->GetDrawRotation() );
|
|
|
|
text_offset += adjust_offset;
|
|
|
|
}
|
|
|
|
|
2022-03-06 20:17:33 +00:00
|
|
|
if( nonCached( aText )
|
2022-05-13 21:36:20 +00:00
|
|
|
&& aText->RenderAsBitmap( m_gal->GetWorldScale() )
|
2022-03-06 20:17:33 +00:00
|
|
|
&& !shownText.Contains( wxT( "\n" ) ) )
|
2022-01-07 14:49:17 +00:00
|
|
|
{
|
2022-02-23 12:07:33 +00:00
|
|
|
bitmapText( shownText, aText->GetDrawPos() + text_offset, attrs );
|
2022-05-13 21:36:20 +00:00
|
|
|
const_cast<SCH_TEXT*>( aText )->SetFlags( IS_SHOWN_AS_BITMAP );
|
2022-01-07 14:49:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-23 12:07:33 +00:00
|
|
|
std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
|
|
|
|
|
2022-10-22 20:32:10 +00:00
|
|
|
if( !aText->IsHypertext() && font->IsOutline() )
|
|
|
|
cache = aText->GetRenderCache( font, shownText, text_offset );
|
2022-02-23 12:07:33 +00:00
|
|
|
|
|
|
|
if( cache )
|
|
|
|
{
|
2023-04-17 14:15:29 +00:00
|
|
|
m_gal->SetLineWidth( attrs.m_StrokeWidth );
|
|
|
|
m_gal->DrawGlyphs( *cache );
|
2022-02-23 12:07:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-06 19:20:53 +00:00
|
|
|
strokeText( shownText, aText->GetDrawPos() + text_offset, attrs,
|
|
|
|
aText->GetFontMetrics() );
|
2022-02-23 12:07:33 +00:00
|
|
|
}
|
2022-05-13 21:36:20 +00:00
|
|
|
|
|
|
|
const_cast<SCH_TEXT*>( aText )->ClearFlags( IS_SHOWN_AS_BITMAP );
|
2022-01-07 14:49:17 +00:00
|
|
|
}
|
2020-09-06 12:04:52 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-08-30 22:43:42 +00:00
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer, bool aDimmed )
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
2023-11-25 12:38:24 +00:00
|
|
|
if( aTextBox->Type() == SCH_TABLECELL_T )
|
|
|
|
{
|
|
|
|
const SCH_TABLECELL* cell = static_cast<const SCH_TABLECELL*>( aTextBox );
|
|
|
|
|
|
|
|
if( cell->GetColSpan() == 0 || cell->GetRowSpan() == 0 )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
if( !isUnitAndConversionShown( aTextBox ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( aTextBox->IsPrivate() && !m_schSettings.m_IsSymbolEditor )
|
|
|
|
return;
|
|
|
|
|
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
2024-01-16 15:29:13 +00:00
|
|
|
|
|
|
|
if( m_schSettings.IsPrinting() && drawingShadows )
|
|
|
|
return;
|
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
COLOR4D color = getRenderColor( aTextBox, aLayer, drawingShadows, aDimmed );
|
|
|
|
COLOR4D bg = m_schSettings.GetLayerColor( LAYER_SCHEMATIC_BACKGROUND );
|
2023-05-27 15:30:12 +00:00
|
|
|
float borderWidth = getLineWidth( aTextBox, drawingShadows );
|
|
|
|
KIFONT::FONT* font = getFont( aTextBox );
|
2022-10-22 20:32:10 +00:00
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
auto drawText =
|
|
|
|
[&]()
|
|
|
|
{
|
2023-05-05 13:21:56 +00:00
|
|
|
wxString shownText = aTextBox->GetShownText( true );
|
2022-05-13 21:36:20 +00:00
|
|
|
TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes();
|
|
|
|
|
|
|
|
attrs.m_Angle = aTextBox->GetDrawRotation();
|
2022-12-22 14:43:43 +00:00
|
|
|
attrs.m_StrokeWidth = KiROUND( getTextThickness( aTextBox ) );
|
2022-05-13 21:36:20 +00:00
|
|
|
|
2022-08-27 18:14:57 +00:00
|
|
|
if( aTextBox->IsHypertext() && aTextBox->IsRollover() )
|
|
|
|
{
|
|
|
|
m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_HOVERED ) );
|
|
|
|
m_gal->SetFillColor( m_schSettings.GetLayerColor( LAYER_HOVERED ) );
|
|
|
|
attrs.m_Underlined = true;
|
|
|
|
}
|
|
|
|
|
2022-05-13 21:36:20 +00:00
|
|
|
std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
|
|
|
|
|
2022-10-22 20:32:10 +00:00
|
|
|
if( !aTextBox->IsHypertext() && font->IsOutline() )
|
|
|
|
cache = aTextBox->GetRenderCache( font, shownText );
|
2022-05-13 21:36:20 +00:00
|
|
|
|
|
|
|
if( cache )
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
2023-04-17 14:15:29 +00:00
|
|
|
m_gal->SetLineWidth( attrs.m_StrokeWidth );
|
|
|
|
m_gal->DrawGlyphs( *cache );
|
2022-05-13 21:36:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-06 19:20:53 +00:00
|
|
|
strokeText( shownText, aTextBox->GetDrawPos(), attrs, aTextBox->GetFontMetrics() );
|
2022-05-13 21:36:20 +00:00
|
|
|
}
|
2022-01-25 22:33:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if( drawingShadows && !( aTextBox->IsBrightened() || aTextBox->IsSelected() ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_gal->SetFillColor( color );
|
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
|
|
|
|
if( aLayer == LAYER_SELECTION_SHADOWS )
|
|
|
|
{
|
2022-05-13 21:36:20 +00:00
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( false );
|
|
|
|
m_gal->SetLineWidth( borderWidth );
|
2022-01-25 22:33:37 +00:00
|
|
|
|
2024-04-27 12:47:56 +00:00
|
|
|
m_gal->DrawRectangle( aTextBox->GetPosition(), aTextBox->GetEnd() );
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
2024-04-15 20:18:54 +00:00
|
|
|
else if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND )
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
2023-11-23 13:29:07 +00:00
|
|
|
// Do not fill the shape in B&W print mode, to avoid to visible items
|
|
|
|
// inside the shape
|
|
|
|
if( aTextBox->IsFilled() && !m_schSettings.PrintBlackAndWhiteReq() )
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( false );
|
2022-03-30 13:39:38 +00:00
|
|
|
m_gal->SetLineWidth( borderWidth );
|
2022-01-25 22:33:37 +00:00
|
|
|
|
2024-04-27 12:47:56 +00:00
|
|
|
m_gal->DrawRectangle( aTextBox->GetPosition(), aTextBox->GetEnd() );
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
|
|
|
}
|
2024-04-15 20:18:54 +00:00
|
|
|
else if( aLayer == LAYER_DEVICE || aLayer == LAYER_NOTES || aLayer == LAYER_PRIVATE_NOTES )
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
2022-01-31 23:53:34 +00:00
|
|
|
drawText();
|
|
|
|
|
2024-02-03 13:43:41 +00:00
|
|
|
if( aTextBox->Type() != SCH_TABLECELL_T && borderWidth > 0 )
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
2023-11-25 13:05:45 +00:00
|
|
|
COLOR4D borderColor = aTextBox->GetStroke().GetColor();
|
|
|
|
LINE_STYLE borderStyle = aTextBox->GetEffectiveLineStyle();
|
2024-04-15 20:18:54 +00:00
|
|
|
double transparency = aTextBox->GetForcedTransparency();
|
2022-04-29 13:10:22 +00:00
|
|
|
|
|
|
|
if( m_schSettings.m_OverrideItemColors || aTextBox->IsBrightened()
|
|
|
|
|| borderColor == COLOR4D::UNSPECIFIED )
|
2022-01-31 23:53:34 +00:00
|
|
|
{
|
2022-04-29 13:10:22 +00:00
|
|
|
borderColor = m_schSettings.GetLayerColor( aLayer );
|
2022-01-31 23:53:34 +00:00
|
|
|
}
|
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
if( transparency > 0.0 )
|
|
|
|
borderColor = borderColor.WithAlpha( borderColor.a * ( 1.0 - transparency ) );
|
|
|
|
|
|
|
|
if( aDimmed )
|
|
|
|
{
|
|
|
|
borderColor = borderColor.Mix( bg, 0.5f );
|
|
|
|
borderColor.Desaturate( );
|
|
|
|
}
|
|
|
|
|
2022-01-31 19:11:21 +00:00
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
2022-04-29 13:10:22 +00:00
|
|
|
m_gal->SetStrokeColor( borderColor );
|
2022-03-30 13:39:38 +00:00
|
|
|
m_gal->SetLineWidth( borderWidth );
|
2022-01-25 22:33:37 +00:00
|
|
|
|
2023-11-25 13:05:45 +00:00
|
|
|
if( borderStyle <= LINE_STYLE::FIRST_TYPE || drawingShadows )
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
2024-04-27 12:47:56 +00:00
|
|
|
m_gal->DrawRectangle( aTextBox->GetPosition(), aTextBox->GetEnd() );
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
2022-01-31 19:11:21 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
std::vector<SHAPE*> shapes = aTextBox->MakeEffectiveShapes( true );
|
2022-01-25 22:33:37 +00:00
|
|
|
|
2022-01-31 19:11:21 +00:00
|
|
|
for( SHAPE* shape : shapes )
|
|
|
|
{
|
2022-12-22 14:43:43 +00:00
|
|
|
STROKE_PARAMS::Stroke( shape, borderStyle, KiROUND( borderWidth ),
|
|
|
|
&m_schSettings,
|
2024-04-27 12:47:56 +00:00
|
|
|
[this]( const VECTOR2I& a, const VECTOR2I& b )
|
2022-01-31 19:11:21 +00:00
|
|
|
{
|
|
|
|
// DrawLine has problem with 0 length lines so enforce minimum
|
|
|
|
if( a == b )
|
2024-04-27 12:47:56 +00:00
|
|
|
m_gal->DrawLine( a+1, b );
|
2022-01-31 19:11:21 +00:00
|
|
|
else
|
2024-04-27 12:47:56 +00:00
|
|
|
m_gal->DrawLine( a, b );
|
2022-01-31 19:11:21 +00:00
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( SHAPE* shape : shapes )
|
|
|
|
delete shape;
|
|
|
|
}
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_TABLE* aTable, int aLayer, bool aDimmed )
|
2023-11-25 12:38:24 +00:00
|
|
|
{
|
2024-01-15 17:29:55 +00:00
|
|
|
for( SCH_TABLECELL* cell : aTable->GetCells() )
|
2024-04-15 20:18:54 +00:00
|
|
|
draw( cell, aLayer, aDimmed );
|
2023-11-25 12:38:24 +00:00
|
|
|
|
|
|
|
if( aLayer == LAYER_SELECTION_SHADOWS )
|
|
|
|
return;
|
|
|
|
|
|
|
|
VECTOR2I pos = aTable->GetPosition();
|
|
|
|
VECTOR2I end = aTable->GetEnd();
|
|
|
|
|
|
|
|
int lineWidth;
|
|
|
|
COLOR4D color;
|
|
|
|
LINE_STYLE lineStyle;
|
|
|
|
|
|
|
|
auto setupStroke =
|
|
|
|
[&]( const STROKE_PARAMS& stroke )
|
|
|
|
{
|
|
|
|
lineWidth = stroke.GetWidth();
|
|
|
|
color = stroke.GetColor();
|
|
|
|
lineStyle = stroke.GetLineStyle();
|
|
|
|
|
|
|
|
if( lineWidth == 0 )
|
2024-04-02 17:28:17 +00:00
|
|
|
lineWidth = m_schSettings.GetDefaultPenWidth();
|
2023-11-25 12:38:24 +00:00
|
|
|
|
|
|
|
if( color == COLOR4D::UNSPECIFIED )
|
|
|
|
color = m_schSettings.GetLayerColor( LAYER_NOTES );
|
|
|
|
|
|
|
|
if( lineStyle == LINE_STYLE::DEFAULT )
|
|
|
|
lineStyle = LINE_STYLE::SOLID;
|
|
|
|
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetStrokeColor( color );
|
2024-04-15 20:18:54 +00:00
|
|
|
m_gal->SetLineWidth( (float) lineWidth );
|
2023-11-25 12:38:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
auto strokeShape =
|
|
|
|
[&]( const SHAPE& shape )
|
|
|
|
{
|
|
|
|
STROKE_PARAMS::Stroke( &shape, lineStyle, lineWidth, &m_schSettings,
|
|
|
|
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
|
|
|
{
|
|
|
|
// DrawLine has problem with 0 length lines so enforce minimum
|
|
|
|
if( a == b )
|
|
|
|
m_gal->DrawLine( a+1, b );
|
|
|
|
else
|
|
|
|
m_gal->DrawLine( a, b );
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
|
|
|
auto strokeLine =
|
|
|
|
[&]( const VECTOR2I& ptA, const VECTOR2I& ptB )
|
|
|
|
{
|
|
|
|
if( lineStyle <= LINE_STYLE::FIRST_TYPE )
|
|
|
|
{
|
|
|
|
m_gal->DrawLine( ptA, ptB );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SHAPE_SEGMENT seg( ptA, ptB );
|
|
|
|
strokeShape( seg );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
auto strokeRect =
|
|
|
|
[&]( const VECTOR2I& ptA, const VECTOR2I& ptB )
|
|
|
|
{
|
|
|
|
if( lineStyle <= LINE_STYLE::FIRST_TYPE )
|
|
|
|
{
|
|
|
|
m_gal->DrawRectangle( ptA, ptB );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SHAPE_RECT rect( BOX2I( ptA, ptB - ptA ) );
|
|
|
|
strokeShape( rect );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if( aTable->GetSeparatorsStroke().GetWidth() >= 0 )
|
|
|
|
{
|
|
|
|
setupStroke( aTable->GetSeparatorsStroke() );
|
|
|
|
|
|
|
|
if( aTable->StrokeColumns() )
|
|
|
|
{
|
|
|
|
for( int col = 0; col < aTable->GetColCount() - 1; ++col )
|
|
|
|
{
|
|
|
|
for( int row = 0; row < aTable->GetRowCount(); ++row )
|
|
|
|
{
|
|
|
|
SCH_TABLECELL* cell = aTable->GetCell( row, col );
|
2024-03-11 22:57:02 +00:00
|
|
|
VECTOR2I topRight( cell->GetEndX(), cell->GetStartY() );
|
2023-11-25 12:38:24 +00:00
|
|
|
|
|
|
|
if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
|
2024-03-11 22:57:02 +00:00
|
|
|
strokeLine( topRight, cell->GetEnd() );
|
2023-11-25 12:38:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aTable->StrokeRows() )
|
|
|
|
{
|
|
|
|
for( int row = 0; row < aTable->GetRowCount() - 1; ++row )
|
|
|
|
{
|
|
|
|
for( int col = 0; col < aTable->GetColCount(); ++col )
|
|
|
|
{
|
2024-02-03 13:43:41 +00:00
|
|
|
SCH_TABLECELL* cell = aTable->GetCell( row, col );
|
2024-03-11 22:57:02 +00:00
|
|
|
VECTOR2I botLeft( cell->GetStartX(), cell->GetEndY() );
|
2023-11-25 12:38:24 +00:00
|
|
|
|
|
|
|
if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
|
2024-03-11 22:57:02 +00:00
|
|
|
strokeLine( botLeft, cell->GetEnd() );
|
2023-11-25 12:38:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aTable->GetBorderStroke().GetWidth() >= 0 )
|
|
|
|
{
|
|
|
|
setupStroke( aTable->GetBorderStroke() );
|
|
|
|
|
|
|
|
if( aTable->StrokeHeader() )
|
|
|
|
{
|
|
|
|
SCH_TABLECELL* cell = aTable->GetCell( 0, 0 );
|
|
|
|
strokeLine( VECTOR2I( pos.x, cell->GetEndY() ), VECTOR2I( end.x, cell->GetEndY() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aTable->StrokeExternal() )
|
|
|
|
strokeRect( pos, end );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
static void orientSymbol( LIB_SYMBOL* symbol, int orientation )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2018-08-30 22:43:42 +00:00
|
|
|
struct ORIENT
|
|
|
|
{
|
2018-08-03 12:18:26 +00:00
|
|
|
int flag;
|
|
|
|
int n_rots;
|
2018-09-01 23:29:19 +00:00
|
|
|
int mirror_x;
|
|
|
|
int mirror_y;
|
2018-08-30 22:43:42 +00:00
|
|
|
}
|
2018-09-01 23:29:19 +00:00
|
|
|
orientations[] =
|
2018-08-30 22:43:42 +00:00
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
{ SYM_ORIENT_0, 0, 0, 0 },
|
|
|
|
{ SYM_ORIENT_90, 1, 0, 0 },
|
|
|
|
{ SYM_ORIENT_180, 2, 0, 0 },
|
|
|
|
{ SYM_ORIENT_270, 3, 0, 0 },
|
|
|
|
{ SYM_MIRROR_X + SYM_ORIENT_0, 0, 1, 0 },
|
|
|
|
{ SYM_MIRROR_X + SYM_ORIENT_90, 1, 1, 0 },
|
|
|
|
{ SYM_MIRROR_Y, 0, 0, 1 },
|
|
|
|
{ SYM_MIRROR_X + SYM_ORIENT_270, 3, 1, 0 },
|
|
|
|
{ SYM_MIRROR_Y + SYM_ORIENT_0, 0, 0, 1 },
|
|
|
|
{ SYM_MIRROR_Y + SYM_ORIENT_90, 1, 0, 1 },
|
|
|
|
{ SYM_MIRROR_Y + SYM_ORIENT_180, 2, 0, 1 },
|
|
|
|
{ SYM_MIRROR_Y + SYM_ORIENT_270, 3, 0, 1 }
|
2018-08-03 12:18:26 +00:00
|
|
|
};
|
|
|
|
|
2018-09-01 23:29:19 +00:00
|
|
|
ORIENT o = orientations[ 0 ];
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2022-05-13 21:36:20 +00:00
|
|
|
for( ORIENT& i : orientations )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2018-09-01 23:29:19 +00:00
|
|
|
if( i.flag == orientation )
|
2018-08-30 22:43:42 +00:00
|
|
|
{
|
2018-09-01 23:29:19 +00:00
|
|
|
o = i;
|
2018-08-30 22:43:42 +00:00
|
|
|
break;
|
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2024-04-06 13:14:44 +00:00
|
|
|
for( SCH_ITEM& item : symbol->GetDrawItems() )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2018-09-01 23:29:19 +00:00
|
|
|
for( int i = 0; i < o.n_rots; i++ )
|
2024-04-22 09:54:58 +00:00
|
|
|
item.Rotate( VECTOR2I( 0, 0 ), true );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-09-01 23:29:19 +00:00
|
|
|
if( o.mirror_x )
|
2024-04-04 23:03:32 +00:00
|
|
|
item.MirrorVertically( 0 );
|
2018-09-01 23:29:19 +00:00
|
|
|
|
|
|
|
if( o.mirror_y )
|
2024-04-04 23:03:32 +00:00
|
|
|
item.MirrorHorizontally( 0 );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-30 22:43:42 +00:00
|
|
|
|
2023-09-13 17:29:59 +00:00
|
|
|
wxString SCH_PAINTER::expandLibItemTextVars( const wxString& aSourceText,
|
|
|
|
const SCH_SYMBOL* aSymbolContext )
|
2023-01-16 15:59:31 +00:00
|
|
|
{
|
|
|
|
std::function<bool( wxString* )> symbolResolver =
|
|
|
|
[&]( wxString* token ) -> bool
|
|
|
|
{
|
2023-05-06 18:22:14 +00:00
|
|
|
return aSymbolContext->ResolveTextVar( &m_schematic->CurrentSheet(), token );
|
2023-01-16 15:59:31 +00:00
|
|
|
};
|
|
|
|
|
2023-01-17 16:54:08 +00:00
|
|
|
return ExpandTextVars( aSourceText, &symbolResolver );
|
2023-01-16 15:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-16 16:20:36 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_SYMBOL* aSymbol, int aLayer )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2021-10-12 20:05:37 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
|
|
|
|
2024-01-16 15:29:13 +00:00
|
|
|
if( m_schSettings.IsPrinting() && drawingShadows )
|
|
|
|
return;
|
|
|
|
|
2021-10-12 20:05:37 +00:00
|
|
|
if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
|
|
|
|
{
|
|
|
|
for( const SCH_FIELD& field : aSymbol->GetFields() )
|
2022-09-16 16:20:36 +00:00
|
|
|
draw( &field, aLayer, aSymbol->GetDNP() );
|
2021-10-12 20:05:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( isFieldsLayer( aLayer ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( drawingShadows && !( aSymbol->IsBrightened() || aSymbol->IsSelected() ) )
|
2022-02-17 19:02:51 +00:00
|
|
|
{
|
|
|
|
// Don't exit here; symbol may still have selected pins
|
|
|
|
// return;
|
|
|
|
}
|
2021-10-12 20:05:37 +00:00
|
|
|
|
2020-11-15 17:03:27 +00:00
|
|
|
int unit = aSymbol->GetUnitSelection( &m_schematic->CurrentSheet() );
|
2024-01-26 16:16:13 +00:00
|
|
|
int bodyStyle = aSymbol->GetBodyStyle();
|
2020-08-21 15:54:24 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
// Use dummy symbol if the actual couldn't be found (or couldn't be locked).
|
2024-04-06 13:14:44 +00:00
|
|
|
LIB_SYMBOL* originalSymbol = aSymbol->GetLibSymbolRef() ? aSymbol->GetLibSymbolRef().get()
|
|
|
|
: dummy();
|
2024-04-20 09:44:34 +00:00
|
|
|
std::vector<SCH_PIN*> originalPins = originalSymbol->GetPins( unit, bodyStyle );
|
2019-04-03 09:14:36 +00:00
|
|
|
|
2019-04-19 15:54:29 +00:00
|
|
|
// Copy the source so we can re-orient and translate it.
|
2024-04-20 09:44:34 +00:00
|
|
|
LIB_SYMBOL tempSymbol( *originalSymbol );
|
|
|
|
std::vector<SCH_PIN*> tempPins = tempSymbol.GetPins( unit, bodyStyle );
|
2019-04-03 09:14:36 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
tempSymbol.SetFlags( aSymbol->GetFlags() );
|
2019-04-03 09:14:36 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
orientSymbol( &tempSymbol, aSymbol->GetOrientation() );
|
2019-04-03 09:14:36 +00:00
|
|
|
|
2024-04-06 13:14:44 +00:00
|
|
|
for( SCH_ITEM& tempItem : tempSymbol.GetDrawItems() )
|
2019-04-23 17:40:29 +00:00
|
|
|
{
|
2022-05-13 21:36:20 +00:00
|
|
|
tempItem.SetFlags( aSymbol->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED,
|
2024-04-27 12:47:56 +00:00
|
|
|
tempItem.Move( aSymbol->GetPosition() );
|
2023-01-16 15:59:31 +00:00
|
|
|
|
2024-04-14 18:04:53 +00:00
|
|
|
if( tempItem.Type() == SCH_TEXT_T )
|
2023-01-16 15:59:31 +00:00
|
|
|
{
|
2024-04-14 18:04:53 +00:00
|
|
|
SCH_TEXT* textItem = static_cast<SCH_TEXT*>( &tempItem );
|
2023-01-16 15:59:31 +00:00
|
|
|
|
|
|
|
if( textItem->HasTextVars() )
|
2023-01-17 16:54:08 +00:00
|
|
|
textItem->SetText( expandLibItemTextVars( textItem->GetText(), aSymbol ) );
|
2023-01-16 15:59:31 +00:00
|
|
|
}
|
2024-04-15 20:18:54 +00:00
|
|
|
else if( tempItem.Type() == SCH_TEXTBOX_T )
|
2023-01-16 15:59:31 +00:00
|
|
|
{
|
2024-04-15 20:18:54 +00:00
|
|
|
SCH_TEXTBOX* textboxItem = static_cast<SCH_TEXTBOX*>( &tempItem );
|
2023-01-16 15:59:31 +00:00
|
|
|
|
|
|
|
if( textboxItem->HasTextVars() )
|
2023-01-17 16:54:08 +00:00
|
|
|
textboxItem->SetText( expandLibItemTextVars( textboxItem->GetText(), aSymbol ) );
|
2023-01-16 15:59:31 +00:00
|
|
|
}
|
2019-04-23 17:40:29 +00:00
|
|
|
}
|
2019-04-19 15:54:29 +00:00
|
|
|
|
2020-11-15 17:03:27 +00:00
|
|
|
// Copy the pin info from the symbol to the temp pins
|
2020-08-21 15:54:24 +00:00
|
|
|
for( unsigned i = 0; i < tempPins.size(); ++ i )
|
2019-04-19 15:54:29 +00:00
|
|
|
{
|
2020-11-15 17:03:27 +00:00
|
|
|
SCH_PIN* symbolPin = aSymbol->GetPin( originalPins[ i ] );
|
2024-04-20 09:44:34 +00:00
|
|
|
SCH_PIN* tempPin = tempPins[ i ];
|
2018-09-05 16:21:51 +00:00
|
|
|
|
2019-04-22 10:14:47 +00:00
|
|
|
tempPin->ClearFlags();
|
2022-05-13 21:36:20 +00:00
|
|
|
tempPin->SetFlags( symbolPin->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED,
|
|
|
|
// IS_SHOWN_AS_BITMAP
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2023-09-13 17:29:59 +00:00
|
|
|
tempPin->SetName( expandLibItemTextVars( symbolPin->GetShownName(), aSymbol ) );
|
2020-11-15 17:03:27 +00:00
|
|
|
tempPin->SetType( symbolPin->GetType() );
|
|
|
|
tempPin->SetShape( symbolPin->GetShape() );
|
2020-08-21 15:54:24 +00:00
|
|
|
|
2020-11-15 17:03:27 +00:00
|
|
|
if( symbolPin->IsDangling() )
|
2019-04-22 10:14:47 +00:00
|
|
|
tempPin->SetFlags( IS_DANGLING );
|
2022-06-30 21:57:23 +00:00
|
|
|
else
|
|
|
|
tempPin->ClearFlags( IS_DANGLING );
|
2023-02-09 17:18:56 +00:00
|
|
|
|
|
|
|
tempPin->SetOperatingPoint( symbolPin->GetOperatingPoint() );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2024-01-26 16:16:13 +00:00
|
|
|
draw( &tempSymbol, aLayer, false, aSymbol->GetUnit(), aSymbol->GetBodyStyle(), aSymbol->GetDNP() );
|
2022-05-13 21:36:20 +00:00
|
|
|
|
|
|
|
for( unsigned i = 0; i < tempPins.size(); ++i )
|
|
|
|
{
|
|
|
|
SCH_PIN* symbolPin = aSymbol->GetPin( originalPins[ i ] );
|
2024-04-20 09:44:34 +00:00
|
|
|
SCH_PIN* tempPin = tempPins[ i ];
|
2022-05-13 21:36:20 +00:00
|
|
|
|
|
|
|
symbolPin->ClearFlags();
|
2022-05-15 16:31:23 +00:00
|
|
|
tempPin->ClearFlags( IS_DANGLING ); // Clear this temporary flag
|
2022-05-13 21:36:20 +00:00
|
|
|
symbolPin->SetFlags( tempPin->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED,
|
|
|
|
// IS_SHOWN_AS_BITMAP
|
|
|
|
}
|
2023-01-09 23:30:58 +00:00
|
|
|
|
|
|
|
if( aSymbol->GetDNP() )
|
|
|
|
{
|
2023-07-16 18:18:24 +00:00
|
|
|
BOX2I bbox = aSymbol->GetBodyBoundingBox();
|
|
|
|
BOX2I pins = aSymbol->GetBodyAndPinsBoundingBox();
|
|
|
|
VECTOR2D margins( std::max( bbox.GetX() - pins.GetX(), pins.GetEnd().x - bbox.GetEnd().x ),
|
|
|
|
std::max( bbox.GetY() - pins.GetY(), pins.GetEnd().y - bbox.GetEnd().y ) );
|
|
|
|
|
|
|
|
margins.x = std::max( margins.x * 0.6, margins.y * 0.3 );
|
|
|
|
margins.y = std::max( margins.y * 0.6, margins.x * 0.3 );
|
|
|
|
bbox.Inflate( KiROUND( margins.x ), KiROUND( margins.y ) );
|
|
|
|
|
2023-07-16 17:12:05 +00:00
|
|
|
VECTOR2I pt1 = bbox.GetOrigin();
|
|
|
|
VECTOR2I pt2 = bbox.GetEnd();
|
2023-01-09 23:30:58 +00:00
|
|
|
|
2023-02-15 19:14:41 +00:00
|
|
|
m_gal->PushDepth();
|
|
|
|
m_gal->AdvanceDepth();
|
2023-01-09 23:30:58 +00:00
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetIsFill( true );
|
2023-07-16 17:04:21 +00:00
|
|
|
m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_DNP_MARKER ) );
|
|
|
|
m_gal->SetFillColor( m_schSettings.GetLayerColor( LAYER_DNP_MARKER ) );
|
2023-01-09 23:30:58 +00:00
|
|
|
|
2023-02-07 12:05:41 +00:00
|
|
|
m_gal->DrawSegment( pt1, pt2, 3.0 * schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ) );
|
|
|
|
std::swap( pt1.x, pt2.x );
|
|
|
|
m_gal->DrawSegment( pt1, pt2, 3.0 * schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ) );
|
2023-02-15 19:14:41 +00:00
|
|
|
m_gal->PopDepth();
|
2023-01-09 23:30:58 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-09-01 23:29:19 +00:00
|
|
|
|
2022-09-16 16:20:36 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_FIELD* aField, int aLayer, bool aDimmed )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
|
|
|
|
2024-01-16 15:29:13 +00:00
|
|
|
if( m_schSettings.IsPrinting() && drawingShadows )
|
|
|
|
return;
|
|
|
|
|
2021-09-15 20:03:07 +00:00
|
|
|
if( drawingShadows && !( aField->IsBrightened() || aField->IsSelected() ) )
|
2019-07-30 01:57:41 +00:00
|
|
|
return;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2024-04-12 21:00:41 +00:00
|
|
|
if( !isUnitAndConversionShown( aField ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Must check layer as fields are sometimes drawn by their parent rather than directly
|
|
|
|
// from the view.
|
|
|
|
int layers[KIGFX::VIEW::VIEW_MAX_LAYERS];
|
|
|
|
int layers_count;
|
|
|
|
bool foundLayer = false;
|
|
|
|
|
|
|
|
aField->ViewGetLayers( layers, layers_count );
|
|
|
|
|
|
|
|
for( int i = 0; i < layers_count; ++i )
|
|
|
|
{
|
|
|
|
if( layers[i] == aLayer )
|
|
|
|
foundLayer = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !foundLayer )
|
2021-10-12 20:05:37 +00:00
|
|
|
return;
|
|
|
|
|
2020-03-06 12:05:21 +00:00
|
|
|
aLayer = aField->GetLayer();
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2022-09-16 16:20:36 +00:00
|
|
|
COLOR4D color = getRenderColor( aField, aLayer, drawingShadows, aDimmed );
|
2019-07-30 01:57:41 +00:00
|
|
|
|
2020-04-18 11:04:52 +00:00
|
|
|
if( !( aField->IsVisible() || aField->IsForceVisible() ) )
|
2018-08-31 17:19:09 +00:00
|
|
|
{
|
2024-04-12 21:00:41 +00:00
|
|
|
bool force_show = m_schematic ? eeconfig()->m_Appearance.show_hidden_fields
|
|
|
|
: m_schSettings.m_ShowHiddenFields;
|
|
|
|
|
|
|
|
if( force_show )
|
2022-09-16 16:20:36 +00:00
|
|
|
color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows, aDimmed );
|
2018-09-09 20:14:00 +00:00
|
|
|
else
|
2018-08-31 17:19:09 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2023-05-05 13:21:56 +00:00
|
|
|
wxString shownText = aField->GetShownText( true );
|
2022-11-03 11:20:29 +00:00
|
|
|
|
|
|
|
if( shownText.IsEmpty() )
|
2018-08-03 12:18:26 +00:00
|
|
|
return;
|
|
|
|
|
2020-03-06 12:05:21 +00:00
|
|
|
// Calculate the text orientation according to the parent orientation.
|
2021-12-28 22:13:54 +00:00
|
|
|
EDA_ANGLE orient = aField->GetTextAngle();
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2021-06-10 14:10:55 +00:00
|
|
|
if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
if( static_cast<SCH_SYMBOL*>( aField->GetParent() )->GetTransform().y1 )
|
2020-03-06 12:05:21 +00:00
|
|
|
{
|
2024-04-04 23:03:32 +00:00
|
|
|
// Rotate symbol 90 degrees.
|
|
|
|
if( orient.IsHorizontal() )
|
|
|
|
orient = ANGLE_VERTICAL;
|
|
|
|
else
|
|
|
|
orient = ANGLE_HORIZONTAL;
|
2020-03-06 12:05:21 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2020-11-15 17:03:27 +00:00
|
|
|
/*
|
|
|
|
* Calculate the text justification, according to the symbol orientation/mirror.
|
2020-03-06 20:02:58 +00:00
|
|
|
* This is a bit complicated due to cumulative calculations:
|
2018-08-03 12:18:26 +00:00
|
|
|
* - numerous cases (mirrored or not, rotation)
|
2019-07-30 01:57:41 +00:00
|
|
|
* - the DrawGraphicText function recalculate also H and H justifications according to the
|
|
|
|
* text orientation.
|
2020-11-15 17:03:27 +00:00
|
|
|
* - when symbol is mirrored, the text is not mirrored and justifications are complicated
|
|
|
|
* to calculate so the easier way is to use no justifications (centered text) and use
|
|
|
|
* GetBoundingBox to know the text coordinate considered as centered
|
2018-08-03 12:18:26 +00:00
|
|
|
*/
|
2022-08-31 09:15:42 +00:00
|
|
|
BOX2I bbox = aField->GetBoundingBox();
|
2021-10-12 20:05:37 +00:00
|
|
|
|
|
|
|
if( aField->GetParent() && aField->GetParent()->Type() == SCH_GLOBAL_LABEL_T )
|
|
|
|
{
|
|
|
|
SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( aField->GetParent() );
|
|
|
|
bbox.Offset( label->GetSchematicTextOffset( &m_schSettings ) );
|
|
|
|
}
|
|
|
|
|
2023-02-07 12:05:41 +00:00
|
|
|
if( m_schSettings.GetDrawBoundingBoxes() )
|
2024-03-13 16:42:05 +00:00
|
|
|
drawItemBoundingBox( aField );
|
2023-02-07 12:05:41 +00:00
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
m_gal->SetFillColor( color );
|
2019-11-21 15:48:44 +00:00
|
|
|
|
2023-01-28 20:01:58 +00:00
|
|
|
if( drawingShadows && getFont( aField )->IsOutline() )
|
2019-11-21 15:48:44 +00:00
|
|
|
{
|
2022-08-31 09:15:42 +00:00
|
|
|
BOX2I shadow_box = bbox;
|
2022-12-22 14:43:43 +00:00
|
|
|
shadow_box.Inflate( KiROUND( getTextThickness( aField ) * 2 ) );
|
2022-05-13 21:36:20 +00:00
|
|
|
|
|
|
|
m_gal->SetIsStroke( false );
|
2021-12-31 14:07:24 +00:00
|
|
|
m_gal->SetIsFill( true );
|
2024-04-27 12:47:56 +00:00
|
|
|
m_gal->DrawRectangle( shadow_box.GetPosition(), shadow_box.GetEnd() );
|
2019-11-21 15:48:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-05-13 21:36:20 +00:00
|
|
|
VECTOR2I textpos = bbox.Centre();
|
2021-12-31 14:07:24 +00:00
|
|
|
TEXT_ATTRIBUTES attributes = aField->GetAttributes();
|
2022-01-07 17:42:43 +00:00
|
|
|
|
2021-12-31 14:07:24 +00:00
|
|
|
attributes.m_Halign = GR_TEXT_H_ALIGN_CENTER;
|
|
|
|
attributes.m_Valign = GR_TEXT_V_ALIGN_CENTER;
|
2022-12-22 14:43:43 +00:00
|
|
|
attributes.m_StrokeWidth = KiROUND( getTextThickness( aField ) );
|
2021-12-31 14:07:24 +00:00
|
|
|
attributes.m_Angle = orient;
|
2019-11-21 15:48:44 +00:00
|
|
|
|
2023-01-28 20:01:58 +00:00
|
|
|
if( drawingShadows )
|
|
|
|
attributes.m_StrokeWidth += getShadowWidth( !aField->IsSelected() );
|
|
|
|
|
2022-08-27 18:14:57 +00:00
|
|
|
if( aField->IsHypertext() && aField->IsRollover() )
|
|
|
|
{
|
|
|
|
m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_HOVERED ) );
|
|
|
|
m_gal->SetFillColor( m_schSettings.GetLayerColor( LAYER_HOVERED ) );
|
|
|
|
attributes.m_Underlined = true;
|
|
|
|
}
|
|
|
|
|
2022-05-13 21:36:20 +00:00
|
|
|
if( nonCached( aField ) && aField->RenderAsBitmap( m_gal->GetWorldScale() ) )
|
2022-01-07 17:42:43 +00:00
|
|
|
{
|
2022-02-23 12:07:33 +00:00
|
|
|
bitmapText( shownText, textpos, attributes );
|
2022-05-13 21:36:20 +00:00
|
|
|
const_cast<SCH_FIELD*>( aField )->SetFlags( IS_SHOWN_AS_BITMAP );
|
2022-01-07 17:42:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-23 12:07:33 +00:00
|
|
|
std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
|
|
|
|
|
2022-08-27 18:14:57 +00:00
|
|
|
if( !aField->IsHypertext() )
|
|
|
|
cache = aField->GetRenderCache( shownText, textpos, attributes );
|
2022-02-23 12:07:33 +00:00
|
|
|
|
|
|
|
if( cache )
|
|
|
|
{
|
2023-04-17 14:15:29 +00:00
|
|
|
m_gal->SetLineWidth( attributes.m_StrokeWidth );
|
|
|
|
m_gal->DrawGlyphs( *cache );
|
2022-02-23 12:07:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-06 19:20:53 +00:00
|
|
|
strokeText( shownText, textpos, attributes, aField->GetFontMetrics() );
|
2022-02-23 12:07:33 +00:00
|
|
|
}
|
2022-05-13 21:36:20 +00:00
|
|
|
|
|
|
|
const_cast<SCH_FIELD*>( aField )->ClearFlags( IS_SHOWN_AS_BITMAP );
|
2022-01-07 17:42:43 +00:00
|
|
|
}
|
2019-11-21 15:48:44 +00:00
|
|
|
}
|
2018-10-21 21:54:02 +00:00
|
|
|
|
|
|
|
// Draw the umbilical line
|
2024-04-12 21:00:41 +00:00
|
|
|
if( aField->IsMoving() && m_schematic )
|
2018-10-21 21:54:02 +00:00
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I parentPos = aField->GetParentPosition();
|
2020-03-06 12:05:21 +00:00
|
|
|
|
2024-04-02 17:28:17 +00:00
|
|
|
m_gal->SetLineWidth( m_schSettings.GetOutlineWidth() );
|
2021-09-29 00:26:47 +00:00
|
|
|
m_gal->SetStrokeColor( getRenderColor( aField, LAYER_SCHEMATIC_ANCHOR, drawingShadows ) );
|
2022-05-13 21:36:20 +00:00
|
|
|
m_gal->DrawLine( bbox.Centre(), parentPos );
|
2018-10-21 21:54:02 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-08-27 13:25:48 +00:00
|
|
|
|
2023-06-12 09:45:29 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_GLOBALLABEL* aLabel, int aLayer )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
2024-01-16 15:29:13 +00:00
|
|
|
|
|
|
|
if( m_schSettings.IsPrinting() && drawingShadows )
|
|
|
|
return;
|
|
|
|
|
2023-06-23 11:00:03 +00:00
|
|
|
bool drawingDangling = aLayer == LAYER_DANGLING;
|
2019-07-30 01:57:41 +00:00
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
|
2021-10-12 20:05:37 +00:00
|
|
|
{
|
|
|
|
for( const SCH_FIELD& field : aLabel->GetFields() )
|
2022-09-16 16:20:36 +00:00
|
|
|
draw( &field, aLayer, false );
|
2021-10-12 20:05:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( isFieldsLayer( aLayer ) )
|
|
|
|
return;
|
2018-08-27 13:25:48 +00:00
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
if( drawingShadows && !( aLabel->IsBrightened() || aLabel->IsSelected() ) )
|
|
|
|
return;
|
2020-11-18 12:02:52 +00:00
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
COLOR4D color = getRenderColor( aLabel, LAYER_GLOBLABEL, drawingShadows );
|
2020-11-18 12:02:52 +00:00
|
|
|
|
2023-08-07 17:35:51 +00:00
|
|
|
if( drawingDangling )
|
|
|
|
{
|
|
|
|
if( aLabel->IsDangling() )
|
|
|
|
{
|
2023-12-18 19:16:33 +00:00
|
|
|
drawDanglingIndicator( aLabel->GetTextPos(), color,
|
|
|
|
schIUScale.MilsToIU( DANGLING_SYMBOL_SIZE / 2 ), true,
|
|
|
|
drawingShadows, aLabel->IsBrightened() );
|
2023-08-07 17:35:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
std::vector<VECTOR2I> pts;
|
2021-07-17 19:56:18 +00:00
|
|
|
std::deque<VECTOR2D> pts2;
|
2020-11-18 12:02:52 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
aLabel->CreateGraphicShape( &m_schSettings, pts, aLabel->GetTextPos() );
|
2018-08-27 13:25:48 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
for( const VECTOR2I& p : pts )
|
2021-07-17 19:56:18 +00:00
|
|
|
pts2.emplace_back( VECTOR2D( p.x, p.y ) );
|
2020-11-17 16:02:47 +00:00
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
m_gal->SetIsStroke( true );
|
2023-06-23 11:00:03 +00:00
|
|
|
m_gal->SetLineWidth( getLineWidth( aLabel, drawingShadows ) );
|
2021-07-17 19:56:18 +00:00
|
|
|
m_gal->SetStrokeColor( color );
|
2023-06-23 11:00:03 +00:00
|
|
|
|
|
|
|
if( drawingShadows )
|
|
|
|
{
|
|
|
|
m_gal->SetIsFill( eeconfig()->m_Selection.fill_shapes );
|
|
|
|
m_gal->SetFillColor( color );
|
|
|
|
m_gal->DrawPolygon( pts2 );
|
|
|
|
}
|
2023-08-07 17:35:51 +00:00
|
|
|
else
|
2023-06-23 11:00:03 +00:00
|
|
|
{
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->DrawPolyline( pts2 );
|
|
|
|
}
|
2021-07-17 19:56:18 +00:00
|
|
|
|
2024-04-14 18:04:53 +00:00
|
|
|
draw( static_cast<const SCH_TEXT*>( aLabel ), aLayer, false );
|
2021-10-12 20:05:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-12 09:45:29 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_LABEL* aLabel, int aLayer )
|
2021-10-12 20:05:37 +00:00
|
|
|
{
|
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
2024-01-16 15:29:13 +00:00
|
|
|
|
|
|
|
if( m_schSettings.IsPrinting() && drawingShadows )
|
|
|
|
return;
|
|
|
|
|
2023-07-08 17:50:04 +00:00
|
|
|
bool drawingDangling = aLayer == LAYER_DANGLING;
|
2021-10-12 20:05:37 +00:00
|
|
|
|
|
|
|
if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
|
|
|
|
{
|
|
|
|
for( const SCH_FIELD& field : aLabel->GetFields() )
|
2022-09-16 16:20:36 +00:00
|
|
|
draw( &field, aLayer, false );
|
2021-10-12 20:05:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( isFieldsLayer( aLayer ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( drawingShadows && !( aLabel->IsBrightened() || aLabel->IsSelected() ) )
|
|
|
|
return;
|
|
|
|
|
2023-07-08 17:50:04 +00:00
|
|
|
COLOR4D color = getRenderColor( aLabel, LAYER_HIERLABEL, drawingShadows );
|
|
|
|
|
|
|
|
if( drawingDangling )
|
|
|
|
{
|
|
|
|
if( aLabel->IsDangling() )
|
|
|
|
{
|
2023-12-18 19:16:33 +00:00
|
|
|
drawDanglingIndicator( aLabel->GetTextPos(), color,
|
|
|
|
schIUScale.MilsToIU( DANGLING_SYMBOL_SIZE / 2 ), true,
|
|
|
|
drawingShadows, aLabel->IsBrightened() );
|
2023-07-08 17:50:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-04-14 18:04:53 +00:00
|
|
|
draw( static_cast<const SCH_TEXT*>( aLabel ), aLayer, false );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-12 09:45:29 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_HIERLABEL* aLabel, int aLayer )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
2024-01-16 15:29:13 +00:00
|
|
|
|
|
|
|
if( m_schSettings.IsPrinting() && drawingShadows )
|
|
|
|
return;
|
|
|
|
|
2023-07-08 11:54:42 +00:00
|
|
|
bool drawingDangling = aLayer == LAYER_DANGLING;
|
2019-07-30 01:57:41 +00:00
|
|
|
|
2023-07-08 11:54:42 +00:00
|
|
|
if( !( drawingShadows || drawingDangling ) || eeconfig()->m_Selection.draw_selected_children )
|
2021-10-12 20:05:37 +00:00
|
|
|
{
|
|
|
|
for( const SCH_FIELD& field : aLabel->GetFields() )
|
2022-09-16 16:20:36 +00:00
|
|
|
draw( &field, aLayer, false );
|
2021-10-12 20:05:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( isFieldsLayer( aLayer ) )
|
|
|
|
return;
|
|
|
|
|
2021-09-15 20:03:07 +00:00
|
|
|
if( drawingShadows && !( aLabel->IsBrightened() || aLabel->IsSelected() ) )
|
2019-07-30 01:57:41 +00:00
|
|
|
return;
|
|
|
|
|
2021-10-17 23:14:49 +00:00
|
|
|
COLOR4D color = getRenderColor( aLabel, LAYER_HIERLABEL, drawingShadows );
|
2018-09-05 22:17:22 +00:00
|
|
|
|
2023-07-08 11:54:42 +00:00
|
|
|
if( drawingDangling )
|
|
|
|
{
|
|
|
|
if( aLabel->IsDangling() )
|
|
|
|
{
|
2023-12-18 19:16:33 +00:00
|
|
|
drawDanglingIndicator( aLabel->GetTextPos(), color,
|
|
|
|
schIUScale.MilsToIU( DANGLING_SYMBOL_SIZE / 2 ), true,
|
|
|
|
drawingShadows, aLabel->IsBrightened() );
|
2023-07-08 11:54:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
if( m_schematic )
|
|
|
|
{
|
2021-11-24 13:19:50 +00:00
|
|
|
SCH_CONNECTION* conn = nullptr;
|
|
|
|
|
|
|
|
if( !aLabel->IsConnectivityDirty() )
|
|
|
|
conn = aLabel->Connection();
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
if( conn && conn->IsBus() )
|
|
|
|
color = getRenderColor( aLabel, LAYER_BUS, drawingShadows );
|
|
|
|
}
|
2018-09-05 22:17:22 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
std::vector<VECTOR2I> pts;
|
2018-08-03 12:18:26 +00:00
|
|
|
std::deque<VECTOR2D> pts2;
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
aLabel->CreateGraphicShape( &m_schSettings, pts, (VECTOR2I)aLabel->GetTextPos() );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
for( const VECTOR2I& p : pts )
|
2018-09-19 20:52:13 +00:00
|
|
|
pts2.emplace_back( VECTOR2D( p.x, p.y ) );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2019-01-28 04:58:10 +00:00
|
|
|
m_gal->SetIsFill( true );
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetFillColor( m_schSettings.GetLayerColor( LAYER_SCHEMATIC_BACKGROUND ) );
|
2018-08-03 12:18:26 +00:00
|
|
|
m_gal->SetIsStroke( true );
|
2023-07-08 17:37:47 +00:00
|
|
|
m_gal->SetLineWidth( getLineWidth( aLabel, drawingShadows ) );
|
2018-09-05 22:17:22 +00:00
|
|
|
m_gal->SetStrokeColor( color );
|
2018-08-03 12:18:26 +00:00
|
|
|
m_gal->DrawPolyline( pts2 );
|
|
|
|
|
2024-04-14 18:04:53 +00:00
|
|
|
draw( static_cast<const SCH_TEXT*>( aLabel ), aLayer, false );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2020-12-20 18:44:13 +00:00
|
|
|
|
2023-06-12 09:45:29 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_DIRECTIVE_LABEL* aLabel, int aLayer )
|
2021-10-12 20:05:37 +00:00
|
|
|
{
|
2023-04-27 16:59:53 +00:00
|
|
|
if( !eeconfig()->m_Appearance.show_directive_labels && !aLabel->IsSelected() )
|
|
|
|
return;
|
|
|
|
|
2021-10-12 20:05:37 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
|
|
|
|
2024-01-16 15:29:13 +00:00
|
|
|
if( m_schSettings.IsPrinting() && drawingShadows )
|
|
|
|
return;
|
|
|
|
|
2021-10-12 20:05:37 +00:00
|
|
|
if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
|
|
|
|
{
|
|
|
|
for( const SCH_FIELD& field : aLabel->GetFields() )
|
2022-09-16 16:20:36 +00:00
|
|
|
draw( &field, aLayer, false );
|
2021-10-12 20:05:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( isFieldsLayer( aLayer ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( drawingShadows && !( aLabel->IsBrightened() || aLabel->IsSelected() ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
COLOR4D color = getRenderColor( aLabel, LAYER_NETCLASS_REFS, drawingShadows );
|
|
|
|
|
|
|
|
if( aLayer == LAYER_DANGLING )
|
|
|
|
{
|
|
|
|
if( aLabel->IsDangling() )
|
|
|
|
{
|
2023-12-18 19:16:33 +00:00
|
|
|
drawDanglingIndicator( aLabel->GetTextPos(), color,
|
|
|
|
schIUScale.MilsToIU( DANGLING_SYMBOL_SIZE / 2 ), true,
|
|
|
|
drawingShadows, aLabel->IsBrightened() );
|
2021-10-12 20:05:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
std::vector<VECTOR2I> pts;
|
2021-10-12 20:05:37 +00:00
|
|
|
std::deque<VECTOR2D> pts2;
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
aLabel->CreateGraphicShape( &m_schSettings, pts, aLabel->GetTextPos() );
|
2021-10-12 20:05:37 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
for( const VECTOR2I& p : pts )
|
2021-10-12 20:05:37 +00:00
|
|
|
pts2.emplace_back( VECTOR2D( p.x, p.y ) );
|
|
|
|
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetFillColor( color );
|
|
|
|
m_gal->SetIsStroke( true );
|
2022-05-13 21:36:20 +00:00
|
|
|
m_gal->SetLineWidth( getLineWidth( aLabel, drawingShadows ) );
|
2021-10-12 20:05:37 +00:00
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
|
|
|
|
if( aLabel->GetShape() == LABEL_FLAG_SHAPE::F_DOT )
|
|
|
|
{
|
|
|
|
m_gal->DrawLine( pts2[0], pts2[1] );
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->DrawCircle( pts2[2], ( pts2[2] - pts2[1] ).EuclideanNorm() );
|
|
|
|
}
|
|
|
|
else if( aLabel->GetShape() == LABEL_FLAG_SHAPE::F_ROUND )
|
|
|
|
{
|
|
|
|
m_gal->DrawLine( pts2[0], pts2[1] );
|
|
|
|
m_gal->DrawCircle( pts2[2], ( pts2[2] - pts2[1] ).EuclideanNorm() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_gal->DrawPolyline( pts2 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-12 09:45:29 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_SHEET* aSheet, int aLayer )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
|
|
|
|
2024-01-16 15:29:13 +00:00
|
|
|
if( m_schSettings.IsPrinting() && drawingShadows )
|
|
|
|
return;
|
|
|
|
|
2021-10-12 20:05:37 +00:00
|
|
|
if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
|
|
|
|
{
|
|
|
|
for( const SCH_FIELD& field : aSheet->GetFields() )
|
2022-09-16 16:20:36 +00:00
|
|
|
draw( &field, aLayer, false );
|
2021-10-12 20:05:37 +00:00
|
|
|
|
2020-01-12 18:40:50 +00:00
|
|
|
for( SCH_SHEET_PIN* sheetPin : aSheet->GetPins() )
|
|
|
|
draw( static_cast<SCH_HIERLABEL*>( sheetPin ), aLayer );
|
2019-07-30 01:57:41 +00:00
|
|
|
}
|
|
|
|
|
2023-07-08 11:54:42 +00:00
|
|
|
if( isFieldsLayer( aLayer ) )
|
|
|
|
return;
|
|
|
|
|
2020-12-20 18:50:45 +00:00
|
|
|
VECTOR2D pos = aSheet->GetPosition();
|
2018-08-03 12:18:26 +00:00
|
|
|
VECTOR2D size = aSheet->GetSize();
|
|
|
|
|
2018-10-21 12:50:31 +00:00
|
|
|
if( aLayer == LAYER_SHEET_BACKGROUND )
|
2018-09-16 11:30:18 +00:00
|
|
|
{
|
2024-04-14 18:04:53 +00:00
|
|
|
// Do not fill the shape in B&W print mode, to avoid to visible items
|
2023-11-23 13:29:07 +00:00
|
|
|
// inside the shape
|
|
|
|
if( !m_schSettings.PrintBlackAndWhiteReq() )
|
|
|
|
{
|
|
|
|
m_gal->SetFillColor( getRenderColor( aSheet, LAYER_SHEET_BACKGROUND, true ) );
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( false );
|
2018-10-21 12:50:31 +00:00
|
|
|
|
2023-11-23 13:29:07 +00:00
|
|
|
m_gal->DrawRectangle( pos, pos + size );
|
|
|
|
}
|
2018-09-16 11:30:18 +00:00
|
|
|
}
|
2019-07-30 01:57:41 +00:00
|
|
|
|
2020-03-06 20:02:58 +00:00
|
|
|
if( aLayer == LAYER_SHEET || aLayer == LAYER_SELECTION_SHADOWS )
|
2018-09-16 11:30:18 +00:00
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEET, drawingShadows ) );
|
2018-10-21 12:50:31 +00:00
|
|
|
m_gal->SetIsStroke( true );
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetLineWidth( getLineWidth( aSheet, drawingShadows ) );
|
2018-10-21 12:50:31 +00:00
|
|
|
m_gal->SetIsFill( false );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-10-21 12:50:31 +00:00
|
|
|
m_gal->DrawRectangle( pos, pos + size );
|
2018-12-13 23:04:49 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-09-04 20:53:04 +00:00
|
|
|
|
2023-06-12 09:45:29 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_NO_CONNECT* aNC, int aLayer )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2024-01-16 15:29:13 +00:00
|
|
|
if( m_schSettings.IsPrinting() && drawingShadows )
|
|
|
|
return;
|
|
|
|
|
2021-09-15 20:03:07 +00:00
|
|
|
if( drawingShadows && !( aNC->IsBrightened() || aNC->IsSelected() ) )
|
2019-07-30 01:57:41 +00:00
|
|
|
return;
|
2019-04-19 15:54:29 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
m_gal->SetIsStroke( true );
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetLineWidth( getLineWidth( aNC, drawingShadows ) );
|
|
|
|
m_gal->SetStrokeColor( getRenderColor( aNC, LAYER_NOCONNECT, drawingShadows ) );
|
2018-08-03 12:18:26 +00:00
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
|
|
|
|
VECTOR2D p = aNC->GetPosition();
|
2020-04-14 12:25:00 +00:00
|
|
|
int delta = std::max( aNC->GetSize(), m_schSettings.GetDefaultPenWidth() * 3 ) / 2;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-09-19 20:52:13 +00:00
|
|
|
m_gal->DrawLine( p + VECTOR2D( -delta, -delta ), p + VECTOR2D( delta, delta ) );
|
|
|
|
m_gal->DrawLine( p + VECTOR2D( -delta, delta ), p + VECTOR2D( delta, -delta ) );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-09-04 20:53:04 +00:00
|
|
|
|
2020-12-20 18:44:13 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_BUS_ENTRY_BASE *aEntry, int aLayer )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2021-09-30 14:44:35 +00:00
|
|
|
SCH_LAYER_ID layer = aEntry->Type() == SCH_BUS_WIRE_ENTRY_T ? LAYER_WIRE : LAYER_BUS;
|
2022-01-01 06:04:08 +00:00
|
|
|
SCH_LINE line( VECTOR2I(), layer );
|
2021-09-30 14:44:35 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
2024-01-16 15:29:13 +00:00
|
|
|
|
|
|
|
if( m_schSettings.IsPrinting() && drawingShadows )
|
|
|
|
return;
|
|
|
|
|
2021-12-07 20:47:12 +00:00
|
|
|
bool drawingDangling = aLayer == LAYER_DANGLING;
|
2019-07-30 01:57:41 +00:00
|
|
|
|
2021-09-15 20:03:07 +00:00
|
|
|
if( drawingShadows && !( aEntry->IsBrightened() || aEntry->IsSelected() ) )
|
2020-08-10 11:40:58 +00:00
|
|
|
return;
|
|
|
|
|
2020-06-19 11:48:00 +00:00
|
|
|
if( aEntry->IsSelected() )
|
2022-12-27 15:06:36 +00:00
|
|
|
{
|
2020-06-19 11:48:00 +00:00
|
|
|
line.SetSelected();
|
2022-12-27 15:06:36 +00:00
|
|
|
// Never show unselected endpoints on bus entries
|
|
|
|
line.SetFlags( STARTPOINT | ENDPOINT );
|
|
|
|
}
|
2020-07-08 18:29:16 +00:00
|
|
|
else if( aEntry->IsBrightened() )
|
|
|
|
line.SetBrightened();
|
2019-07-30 01:57:41 +00:00
|
|
|
|
2020-06-19 11:48:00 +00:00
|
|
|
line.SetStartPoint( aEntry->GetPosition() );
|
2020-09-08 13:27:13 +00:00
|
|
|
line.SetEndPoint( aEntry->GetEnd() );
|
2020-06-19 11:48:00 +00:00
|
|
|
line.SetStroke( aEntry->GetStroke() );
|
2022-12-27 15:06:36 +00:00
|
|
|
line.SetLineWidth( KiROUND( getLineWidth( aEntry, false ) ) );
|
2018-09-05 22:17:22 +00:00
|
|
|
|
2020-07-08 18:29:16 +00:00
|
|
|
COLOR4D color = getRenderColor( aEntry, LAYER_WIRE, drawingShadows );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2020-07-08 18:29:16 +00:00
|
|
|
if( aEntry->Type() == SCH_BUS_BUS_ENTRY_T )
|
|
|
|
color = getRenderColor( aEntry, LAYER_BUS, drawingShadows );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2021-12-07 20:47:12 +00:00
|
|
|
if( drawingDangling )
|
2021-12-06 18:50:00 +00:00
|
|
|
{
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetStrokeColor( color.Brightened( 0.3 ) );
|
2023-12-18 19:16:33 +00:00
|
|
|
m_gal->SetLineWidth( m_schSettings.GetDanglingIndicatorThickness() );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2021-12-06 18:50:00 +00:00
|
|
|
if( aEntry->IsDanglingStart() )
|
|
|
|
{
|
|
|
|
m_gal->DrawCircle( aEntry->GetPosition(),
|
2024-04-20 20:50:40 +00:00
|
|
|
aEntry->GetPenWidth() + KiROUND( TARGET_BUSENTRY_RADIUS / 2.0 ) );
|
2021-12-06 18:50:00 +00:00
|
|
|
}
|
2018-09-05 22:17:22 +00:00
|
|
|
|
2021-12-06 18:50:00 +00:00
|
|
|
if( aEntry->IsDanglingEnd() )
|
|
|
|
{
|
|
|
|
m_gal->DrawCircle( aEntry->GetEnd(),
|
2024-04-20 20:50:40 +00:00
|
|
|
aEntry->GetPenWidth() + KiROUND( TARGET_BUSENTRY_RADIUS / 2.0 ) );
|
2021-12-06 18:50:00 +00:00
|
|
|
}
|
2021-09-15 20:15:55 +00:00
|
|
|
}
|
2021-12-06 18:50:00 +00:00
|
|
|
else
|
2021-09-15 20:15:55 +00:00
|
|
|
{
|
2021-12-06 18:50:00 +00:00
|
|
|
line.SetLineColor( color );
|
2021-07-17 19:56:18 +00:00
|
|
|
line.SetLineStyle( aEntry->GetLineStyle() );
|
2021-12-06 18:50:00 +00:00
|
|
|
|
|
|
|
draw( &line, aLayer );
|
2021-09-15 20:15:55 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-09-04 20:53:04 +00:00
|
|
|
|
2023-06-12 09:45:29 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_BITMAP* aBitmap, int aLayer )
|
2018-08-27 13:25:48 +00:00
|
|
|
{
|
|
|
|
m_gal->Save();
|
|
|
|
m_gal->Translate( aBitmap->GetPosition() );
|
2018-09-08 11:12:41 +00:00
|
|
|
|
2019-08-01 04:52:22 +00:00
|
|
|
// When the image scale factor is not 1.0, we need to modify the actual as the image scale
|
|
|
|
// factor is similar to a local zoom
|
2018-10-20 16:24:22 +00:00
|
|
|
double img_scale = aBitmap->GetImageScale();
|
|
|
|
|
|
|
|
if( img_scale != 1.0 )
|
|
|
|
m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
|
2018-09-08 11:12:41 +00:00
|
|
|
|
2019-08-01 04:52:22 +00:00
|
|
|
if( aLayer == LAYER_DRAW_BITMAPS )
|
|
|
|
{
|
|
|
|
m_gal->DrawBitmap( *aBitmap->GetImage() );
|
|
|
|
}
|
2018-09-08 11:12:41 +00:00
|
|
|
|
2019-08-01 04:52:22 +00:00
|
|
|
if( aLayer == LAYER_SELECTION_SHADOWS )
|
2019-07-10 00:14:28 +00:00
|
|
|
{
|
2020-06-27 16:06:01 +00:00
|
|
|
if( aBitmap->IsSelected() || aBitmap->IsBrightened() )
|
2019-08-01 04:52:22 +00:00
|
|
|
{
|
|
|
|
COLOR4D color = getRenderColor( aBitmap, LAYER_DRAW_BITMAPS, true );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetStrokeColor( color );
|
2021-09-15 20:03:07 +00:00
|
|
|
m_gal->SetLineWidth ( getShadowWidth( aBitmap->IsBrightened() ) );
|
2019-08-01 04:52:22 +00:00
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
|
2019-08-01 06:48:01 +00:00
|
|
|
// Draws a bounding box.
|
|
|
|
VECTOR2D bm_size( aBitmap->GetSize() );
|
|
|
|
// bm_size is the actual image size in UI.
|
|
|
|
// but m_gal scale was previously set to img_scale
|
|
|
|
// so recalculate size relative to this image size.
|
|
|
|
bm_size.x /= img_scale;
|
|
|
|
bm_size.y /= img_scale;
|
|
|
|
VECTOR2D origin( -bm_size.x / 2.0, -bm_size.y / 2.0 );
|
|
|
|
VECTOR2D end = origin + bm_size;
|
|
|
|
|
2019-08-01 04:52:22 +00:00
|
|
|
m_gal->DrawRectangle( origin, end );
|
|
|
|
}
|
2019-07-10 00:14:28 +00:00
|
|
|
}
|
|
|
|
|
2018-08-27 13:25:48 +00:00
|
|
|
m_gal->Restore();
|
|
|
|
}
|
|
|
|
|
2018-09-04 20:53:04 +00:00
|
|
|
|
2023-06-12 09:45:29 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_MARKER* aMarker, int aLayer )
|
2018-08-27 13:25:48 +00:00
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
2018-09-04 20:53:04 +00:00
|
|
|
|
2024-01-16 15:29:13 +00:00
|
|
|
if( m_schSettings.IsPrinting() && drawingShadows )
|
|
|
|
return;
|
|
|
|
|
2021-09-15 20:03:07 +00:00
|
|
|
if( drawingShadows && !( aMarker->IsBrightened() || aMarker->IsSelected() ) )
|
2019-07-30 01:57:41 +00:00
|
|
|
return;
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
COLOR4D color = getRenderColor( aMarker, aMarker->GetColorLayer(), drawingShadows );
|
2018-08-27 13:25:48 +00:00
|
|
|
|
2019-08-07 18:23:59 +00:00
|
|
|
m_gal->Save();
|
2018-09-04 20:53:04 +00:00
|
|
|
m_gal->Translate( aMarker->GetPosition() );
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetIsFill( !drawingShadows );
|
2018-09-04 20:53:04 +00:00
|
|
|
m_gal->SetFillColor( color );
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetIsStroke( drawingShadows );
|
|
|
|
m_gal->SetLineWidth( getLineWidth( aMarker, drawingShadows ) );
|
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
|
|
|
|
SHAPE_LINE_CHAIN polygon;
|
|
|
|
aMarker->ShapeToPolygon( polygon );
|
|
|
|
|
2018-12-19 18:53:27 +00:00
|
|
|
m_gal->DrawPolygon( polygon );
|
2019-08-07 18:23:59 +00:00
|
|
|
m_gal->Restore();
|
2018-08-27 13:25:48 +00:00
|
|
|
}
|
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
|
|
|
|
}; // namespace KIGFX
|