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
|
2022-01-13 12:29:46 +00:00
|
|
|
* Copyright (C) 2019-2022 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2019-05-10 19:57:24 +00:00
|
|
|
#include <sch_item.h>
|
2021-09-15 20:15:55 +00:00
|
|
|
#include <trigo.h>
|
2021-06-15 13:24:55 +00:00
|
|
|
#include <symbol_library.h>
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <connection_graph.h>
|
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2021-07-17 19:56:18 +00:00
|
|
|
#include <geometry/shape_segment.h>
|
|
|
|
#include <geometry/shape_simple.h>
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <gr_text.h>
|
2021-07-18 23:08:54 +00:00
|
|
|
#include <lib_shape.h>
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <lib_field.h>
|
2019-08-15 07:09:52 +00:00
|
|
|
#include <lib_item.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <lib_pin.h>
|
|
|
|
#include <lib_text.h>
|
2022-01-25 22:33:37 +00:00
|
|
|
#include <lib_textbox.h>
|
2020-01-04 23:05:57 +00:00
|
|
|
#include <math/util.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>
|
|
|
|
#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>
|
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>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.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"
|
2021-07-17 19:56:18 +00:00
|
|
|
#include "sch_shape.h"
|
|
|
|
|
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() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-02 20:19:22 +00:00
|
|
|
SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() :
|
2021-09-30 14:44:35 +00:00
|
|
|
m_IsSymbolEditor( false ),
|
2020-04-06 09:15:57 +00:00
|
|
|
m_ShowUnit( 0 ),
|
|
|
|
m_ShowConvert( 0 ),
|
|
|
|
m_ShowPinsElectricalType( true ),
|
|
|
|
m_ShowDisabled( false ),
|
2021-02-10 22:56:26 +00:00
|
|
|
m_ShowGraphicsDisabled( false ),
|
2020-04-09 16:15:57 +00:00
|
|
|
m_OverrideItemColors( false ),
|
2021-07-25 11:42:19 +00:00
|
|
|
m_LabelSizeRatio( DEFAULT_LABEL_SIZE_RATIO ),
|
|
|
|
m_TextOffsetRatio( DEFAULT_TEXT_OFFSET_RATIO ),
|
2020-05-20 03:34:55 +00:00
|
|
|
m_PinSymbolSize( DEFAULT_TEXT_SIZE * IU_PER_MILS / 2 ),
|
|
|
|
m_JunctionSize( DEFAULT_JUNCTION_DIAM * IU_PER_MILS )
|
2020-05-03 12:35:52 +00:00
|
|
|
{
|
2021-08-25 18:36:37 +00:00
|
|
|
SetDefaultPenWidth( DEFAULT_LINE_WIDTH_MILS * IU_PER_MILS );
|
2021-12-25 14:00:57 +00:00
|
|
|
SetDashLengthRatio( 12 ); // From ISO 128-2
|
|
|
|
SetGapLengthRatio( 3 ); // From ISO 128-2
|
2020-09-08 19:18:50 +00:00
|
|
|
|
|
|
|
m_minPenWidth = ADVANCED_CFG::GetCfg().m_MinPlotPenWidth * IU_PER_MM;
|
2020-05-03 12:35:52 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-09-09 20:14:00 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void SCH_RENDER_SETTINGS::LoadColors( const COLOR_SETTINGS* aSettings )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
|
|
|
for( int layer = SCH_LAYER_ID_START; layer < SCH_LAYER_ID_END; layer ++)
|
2020-01-13 01:44:19 +00:00
|
|
|
m_layerColors[ layer ] = aSettings->GetColor( layer );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-08-14 18:52:27 +00:00
|
|
|
for( int layer = GAL_LAYER_ID_START; layer < GAL_LAYER_ID_END; layer ++)
|
2020-01-13 01:44:19 +00:00
|
|
|
m_layerColors[ layer ] = aSettings->GetColor( layer );
|
2018-08-14 18:52:27 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
m_backgroundColor = aSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND );
|
2020-04-09 16:15:57 +00:00
|
|
|
|
2020-08-09 21:39:45 +00:00
|
|
|
m_layerColors[LAYER_AUX_ITEMS] = m_layerColors[LAYER_SCHEMATIC_AUX_ITEMS];
|
|
|
|
|
2020-04-09 16:15:57 +00:00
|
|
|
m_OverrideItemColors = aSettings->GetOverrideSchItemColors();
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-09-09 20:14:00 +00:00
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
COLOR4D SCH_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
return m_layerColors[ aLayer ];
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-09-05 22:17:22 +00:00
|
|
|
|
2021-09-07 20:34:10 +00:00
|
|
|
bool SCH_RENDER_SETTINGS::GetShowPageLimits() const
|
2020-04-12 23:09:17 +00:00
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
return eeconfig()->m_Appearance.show_page_limits;
|
2020-04-12 23:09:17 +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
|
|
|
|
2021-07-18 23:08:54 +00:00
|
|
|
LIB_SHAPE* square = new LIB_SHAPE( symbol, SHAPE_T::RECT );
|
2018-08-30 19:44:10 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
square->MoveTo( VECTOR2I( Mils2iu( -200 ), Mils2iu( 200 ) ) );
|
|
|
|
square->SetEnd( VECTOR2I( Mils2iu( 200 ), Mils2iu( -200 ) ) );
|
2018-08-30 19:44:10 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_TEXT* text = new LIB_TEXT( symbol );
|
2018-08-30 19:44:10 +00:00
|
|
|
|
2019-12-30 18:28:00 +00:00
|
|
|
text->SetTextSize( wxSize( Mils2iu( 150 ), Mils2iu( 150 ) ) );
|
2018-08-30 19:44:10 +00:00
|
|
|
text->SetText( wxString( wxT( "??" ) ) );
|
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
symbol->AddDrawItem( square );
|
|
|
|
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 ) :
|
2020-05-13 02:00:37 +00:00
|
|
|
KIGFX::PAINTER( aGal ),
|
|
|
|
m_schematic( nullptr )
|
2018-08-30 19:44:10 +00:00
|
|
|
{ }
|
2018-08-03 12:18:26 +00:00
|
|
|
|
|
|
|
|
2018-09-09 20:14:00 +00:00
|
|
|
#define HANDLE_ITEM( type_id, type_name ) \
|
2019-07-30 01:57:41 +00:00
|
|
|
case type_id: draw( (type_name *) item, aLayer ); break
|
2018-09-09 20:14:00 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
|
|
|
|
bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer )
|
|
|
|
{
|
2020-12-20 18:59:07 +00:00
|
|
|
const auto 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;
|
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
#ifdef CONNECTIVITY_DEBUG
|
|
|
|
|
2020-12-20 18:59:07 +00:00
|
|
|
auto sch_item = dynamic_cast<const SCH_ITEM*>( item );
|
2019-03-11 21:32:05 +00:00
|
|
|
auto conn = sch_item ? sch_item->Connection( *g_CurrentSheet ) : nullptr;
|
|
|
|
|
|
|
|
if( conn )
|
|
|
|
{
|
|
|
|
auto pos = item->GetBoundingBox().Centre();
|
|
|
|
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
|
|
|
|
|
2022-01-17 11:55:55 +00:00
|
|
|
if( m_schSettings.GetDrawBoundingBoxes() )
|
2021-02-24 22:14:39 +00:00
|
|
|
{
|
|
|
|
BOX2I box = item->GetBoundingBox();
|
|
|
|
|
2021-06-10 14:10:55 +00:00
|
|
|
if( item->Type() == SCH_SYMBOL_T )
|
|
|
|
box = static_cast<const SCH_SYMBOL*>( item )->GetBodyBoundingBox();
|
2021-02-24 22:14:39 +00:00
|
|
|
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
2021-09-15 20:15:55 +00:00
|
|
|
m_gal->SetStrokeColor( item->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 )
|
|
|
|
: COLOR4D( 0.2, 0.2, 0.2, 1 ) );
|
2021-02-24 22:14:39 +00:00
|
|
|
m_gal->SetLineWidth( Mils2iu( 3 ) );
|
|
|
|
m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() );
|
|
|
|
}
|
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
HANDLE_ITEM( LIB_SYMBOL_T, LIB_SYMBOL );
|
2021-07-18 23:08:54 +00:00
|
|
|
HANDLE_ITEM( LIB_SHAPE_T, LIB_SHAPE );
|
2019-11-06 19:15:42 +00:00
|
|
|
HANDLE_ITEM( LIB_PIN_T, LIB_PIN );
|
|
|
|
HANDLE_ITEM( LIB_FIELD_T, LIB_FIELD );
|
|
|
|
HANDLE_ITEM( LIB_TEXT_T, LIB_TEXT );
|
2022-01-25 22:33:37 +00:00
|
|
|
HANDLE_ITEM( LIB_TEXTBOX_T, LIB_TEXTBOX );
|
2021-06-10 14:10:55 +00:00
|
|
|
HANDLE_ITEM( SCH_SYMBOL_T, SCH_SYMBOL );
|
2019-11-06 19:15:42 +00:00
|
|
|
HANDLE_ITEM( SCH_JUNCTION_T, SCH_JUNCTION );
|
|
|
|
HANDLE_ITEM( SCH_LINE_T, SCH_LINE );
|
2021-07-17 19:56:18 +00:00
|
|
|
HANDLE_ITEM( SCH_SHAPE_T, SCH_SHAPE );
|
2019-11-06 19:15:42 +00:00
|
|
|
HANDLE_ITEM( SCH_TEXT_T, SCH_TEXT );
|
2022-01-25 22:33:37 +00:00
|
|
|
HANDLE_ITEM( SCH_TEXTBOX_T, SCH_TEXTBOX );
|
2021-10-12 20:05:37 +00:00
|
|
|
HANDLE_ITEM( SCH_LABEL_T, SCH_LABEL );
|
2022-01-24 13:40:39 +00:00
|
|
|
HANDLE_ITEM( SCH_DIRECTIVE_LABEL_T, SCH_DIRECTIVE_LABEL );
|
2019-11-06 19:15:42 +00:00
|
|
|
HANDLE_ITEM( SCH_FIELD_T, SCH_FIELD );
|
|
|
|
HANDLE_ITEM( SCH_HIER_LABEL_T, SCH_HIERLABEL );
|
|
|
|
HANDLE_ITEM( SCH_GLOBAL_LABEL_T, SCH_GLOBALLABEL );
|
|
|
|
HANDLE_ITEM( SCH_SHEET_T, SCH_SHEET );
|
|
|
|
HANDLE_ITEM( SCH_SHEET_PIN_T, SCH_HIERLABEL );
|
|
|
|
HANDLE_ITEM( SCH_NO_CONNECT_T, SCH_NO_CONNECT );
|
|
|
|
HANDLE_ITEM( SCH_BUS_WIRE_ENTRY_T, SCH_BUS_ENTRY_BASE );
|
|
|
|
HANDLE_ITEM( SCH_BUS_BUS_ENTRY_T, SCH_BUS_ENTRY_BASE );
|
|
|
|
HANDLE_ITEM( SCH_BITMAP_T, SCH_BITMAP );
|
|
|
|
HANDLE_ITEM( SCH_MARKER_T, SCH_MARKER );
|
2018-09-05 22:17:22 +00:00
|
|
|
|
2018-09-19 20:52:13 +00:00
|
|
|
default: return false;
|
2019-11-06 19:15:42 +00:00
|
|
|
}
|
2018-09-05 22:17:22 +00:00
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
return false;
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-08-28 13:27:56 +00:00
|
|
|
|
2022-02-23 12:07:33 +00:00
|
|
|
// Drawing outline fonts, and to a lesser extent stroke fonts and stroke font drop-shadows, is
|
|
|
|
// expensive. At small effective sizes (ie: zoomed out) the 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 material.
|
|
|
|
#define BITMAP_FONT_LOD_THRESHOLD 3.5
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-23 12:07:33 +00:00
|
|
|
bool SCH_PAINTER::underLODThreshold( int aFontSize )
|
|
|
|
{
|
|
|
|
return aFontSize * m_gal->GetWorldScale() < BITMAP_FONT_LOD_THRESHOLD;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-20 18:44:13 +00:00
|
|
|
bool SCH_PAINTER::isUnitAndConversionShown( const LIB_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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_schSettings.m_ShowConvert // showing a specific conversion
|
|
|
|
&& aItem->GetConvert() // item is conversion-specific
|
|
|
|
&& aItem->GetConvert() != m_schSettings.m_ShowConvert )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
|
2021-09-15 20:03:07 +00:00
|
|
|
return (float) std::fabs( matrix.GetScale().x * milsWidth ) + Mils2iu( milsWidth );
|
2019-07-30 01:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-20 18:44:13 +00:00
|
|
|
COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows ) const
|
2019-04-19 15:54:29 +00:00
|
|
|
{
|
2021-10-12 20:05:37 +00:00
|
|
|
// We don't (yet?) have a separate color for intersheet refs
|
|
|
|
if( aLayer == LAYER_INTERSHEET_REFS )
|
|
|
|
aLayer = LAYER_GLOBLABEL;
|
|
|
|
|
2019-05-19 21:04:04 +00:00
|
|
|
COLOR4D color = m_schSettings.GetLayerColor( aLayer );
|
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-01-31 23:53:34 +00:00
|
|
|
if( aLayer == LAYER_SHEET )
|
|
|
|
color = sheet->GetBorderColor();
|
|
|
|
else if( aLayer == LAYER_SHEET_BACKGROUND )
|
|
|
|
color = sheet->GetBackgroundColor();
|
|
|
|
}
|
|
|
|
else if( aItem->Type() == SCH_SHAPE_T )
|
|
|
|
{
|
|
|
|
const SCH_SHAPE* shape = static_cast<const SCH_SHAPE*>( aItem );
|
2022-01-11 18:17:41 +00:00
|
|
|
|
2022-01-31 23:53:34 +00:00
|
|
|
if( aLayer == LAYER_NOTES )
|
|
|
|
color = shape->GetStroke().GetColor();
|
|
|
|
else if( aLayer == LAYER_NOTES_BACKGROUND )
|
|
|
|
color = shape->GetFillColor();
|
2022-04-05 22:32:48 +00:00
|
|
|
|
|
|
|
if( color == COLOR4D::UNSPECIFIED )
|
|
|
|
color = m_schSettings.GetLayerColor( LAYER_NOTES );
|
2022-01-31 23:53:34 +00:00
|
|
|
}
|
|
|
|
else if( aItem->Type() == LIB_SHAPE_T )
|
|
|
|
{
|
|
|
|
const LIB_SHAPE* shape = static_cast<const LIB_SHAPE*>( aItem );
|
2022-01-11 18:17:41 +00:00
|
|
|
|
2022-01-31 23:53:34 +00:00
|
|
|
if( aLayer == LAYER_DEVICE || aLayer == LAYER_NOTES )
|
|
|
|
color = shape->GetStroke().GetColor();
|
|
|
|
else if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND )
|
|
|
|
color = shape->GetFillColor();
|
|
|
|
}
|
|
|
|
else if( aItem->Type() == SCH_TEXTBOX_T )
|
|
|
|
{
|
|
|
|
const SCH_TEXTBOX* textBox = static_cast<const SCH_TEXTBOX*>( aItem );
|
2022-01-25 22:33:37 +00:00
|
|
|
|
2022-01-31 23:53:34 +00:00
|
|
|
if( aLayer == LAYER_NOTES_BACKGROUND )
|
|
|
|
color = textBox->GetFillColor();
|
2022-03-31 18:43:08 +00:00
|
|
|
else
|
|
|
|
color = textBox->GetTextColor();
|
2022-01-31 23:53:34 +00:00
|
|
|
}
|
|
|
|
else if( aItem->Type() == LIB_TEXTBOX_T )
|
|
|
|
{
|
|
|
|
const LIB_TEXTBOX* textBox = static_cast<const LIB_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();
|
2022-03-31 18:43:08 +00:00
|
|
|
else
|
|
|
|
color = textBox->GetTextColor();
|
|
|
|
}
|
|
|
|
else if( const EDA_TEXT* otherTextItem = dynamic_cast<const EDA_TEXT*>( aItem ) )
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2021-02-10 22:56:26 +00:00
|
|
|
if( m_schSettings.m_ShowDisabled
|
|
|
|
|| ( m_schSettings.m_ShowGraphicsDisabled && aItem->Type() != LIB_FIELD_T ) )
|
|
|
|
{
|
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
|
|
|
|
2019-04-19 15:54:29 +00:00
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
float SCH_PAINTER::getLineWidth( const EDA_ITEM* aItem, bool aDrawingShadows ) const
|
2019-07-30 01:57:41 +00:00
|
|
|
{
|
2022-01-25 22:33:37 +00:00
|
|
|
wxCHECK( aItem, static_cast<float>( Mils2iu( DEFAULT_LINE_WIDTH_MILS ) ) );
|
2020-04-04 20:32:14 +00:00
|
|
|
|
2022-02-06 18:14:07 +00:00
|
|
|
int pen = 0;
|
2019-07-30 01:57:41 +00:00
|
|
|
|
2022-02-06 18:14:07 +00:00
|
|
|
if( dynamic_cast<const LIB_ITEM*>( aItem ) )
|
2022-01-25 22:33:37 +00:00
|
|
|
pen = static_cast<const LIB_ITEM*>( aItem )->GetEffectivePenWidth( &m_schSettings );
|
|
|
|
else if( dynamic_cast<const SCH_ITEM*>( aItem ) )
|
|
|
|
pen = static_cast<const SCH_ITEM*>( aItem )->GetPenWidth();
|
|
|
|
else
|
|
|
|
UNIMPLEMENTED_FOR( aItem->GetClass() );
|
2019-07-30 01:57:41 +00:00
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
float width = pen;
|
2019-07-30 01:57:41 +00:00
|
|
|
|
2021-09-15 20:03:07 +00:00
|
|
|
if( ( aItem->IsBrightened() || aItem->IsSelected() ) && aDrawingShadows )
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
float SCH_PAINTER::getTextThickness( const EDA_ITEM* aItem, bool aDrawingShadows ) 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:
|
|
|
|
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
|
|
|
case LIB_FIELD_T:
|
|
|
|
pen = std::max( pen, static_cast<const LIB_FIELD*>( aItem )->GetEffectiveTextPenWidth() );
|
|
|
|
break;
|
2020-04-14 09:08:42 +00:00
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
case LIB_TEXT_T:
|
|
|
|
pen = std::max( pen, static_cast<const LIB_TEXT*>( aItem )->GetEffectiveTextPenWidth() );
|
|
|
|
break;
|
2020-04-14 09:08:42 +00:00
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
case LIB_TEXTBOX_T:
|
|
|
|
pen = std::max( pen, static_cast<const LIB_TEXTBOX*>( aItem )->GetEffectiveTextPenWidth() );
|
|
|
|
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-01-25 22:33:37 +00:00
|
|
|
float width = (float) pen;
|
2020-04-14 09:08:42 +00:00
|
|
|
|
2021-09-15 20:03:07 +00:00
|
|
|
if( ( aItem->IsBrightened() || aItem->IsSelected() ) && aDrawingShadows )
|
|
|
|
width += getShadowWidth( aItem->IsBrightened() );
|
2020-04-14 09:08:42 +00:00
|
|
|
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-29 21:30:11 +00:00
|
|
|
static VECTOR2D mapCoords( const VECTOR2D& aCoord )
|
2021-09-15 20:15:55 +00:00
|
|
|
{
|
|
|
|
return VECTOR2D( aCoord.x, -aCoord.y );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
const TEXT_ATTRIBUTES& aAttrs )
|
2019-10-21 18:03:54 +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
|
|
|
|
|
|
|
m_gal->SetIsFill( font->IsOutline() );
|
|
|
|
m_gal->SetIsStroke( font->IsStroke() );
|
|
|
|
|
|
|
|
font->Draw( m_gal, aText, aPosition, aAttrs );
|
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-03-07 17:41:46 +00:00
|
|
|
// Bitmap font has different metrics than the stroke font so we compensate a bit before
|
|
|
|
// stroking
|
|
|
|
m_gal->SetGlyphSize( VECTOR2I( aAttrs.m_Size.x * 0.60, aAttrs.m_Size.y * 0.72 ) );
|
|
|
|
m_gal->SetLineWidth( aAttrs.m_StrokeWidth * 1.2 );
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-31 14:07:24 +00:00
|
|
|
void SCH_PAINTER::boxText( const wxString& aText, const VECTOR2D& aPosition,
|
|
|
|
const TEXT_ATTRIBUTES& aAttrs )
|
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,
|
2022-01-07 14:49:17 +00:00
|
|
|
aAttrs.m_Bold, aAttrs.m_Italic );
|
2021-12-31 14:07:24 +00:00
|
|
|
EDA_RECT box( (VECTOR2I) aPosition, wxSize( extents.x, aAttrs.m_Size.y ) );
|
|
|
|
|
|
|
|
switch( aAttrs.m_Halign )
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2021-09-15 20:15:55 +00:00
|
|
|
|
2021-12-31 14:07:24 +00:00
|
|
|
switch( aAttrs.m_Valign )
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2021-09-15 20:15:55 +00:00
|
|
|
|
2021-12-31 14:07:24 +00:00
|
|
|
// Many fonts draw diacriticals, descenders, etc. outside the X-height of the font. This
|
|
|
|
// will cacth most (but probably not all) of them.
|
2022-02-23 12:07:33 +00:00
|
|
|
box.Inflate( 0, aAttrs.m_StrokeWidth );
|
2021-09-15 20:15:55 +00:00
|
|
|
|
|
|
|
box.Normalize(); // Make h and v sizes always >= 0
|
2022-01-16 21:15:20 +00:00
|
|
|
box = box.GetBoundingBoxRotated( (VECTOR2I) aPosition, aAttrs.m_Angle );
|
2021-09-15 20:15:55 +00:00
|
|
|
box.RevertYAxis();
|
2021-12-31 14:07:24 +00:00
|
|
|
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetLineWidth( getShadowWidth( false ) );
|
2021-09-15 20:15:55 +00:00
|
|
|
m_gal->DrawRectangle( mapCoords( box.GetOrigin() ), mapCoords( box.GetEnd() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-22 22:26:48 +00:00
|
|
|
void SCH_PAINTER::draw( const LIB_SYMBOL *aSymbol, int aLayer, bool aDrawFields, int aUnit,
|
|
|
|
int aConvert )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2018-09-02 20:19:22 +00:00
|
|
|
if( !aUnit )
|
|
|
|
aUnit = m_schSettings.m_ShowUnit;
|
|
|
|
|
|
|
|
if( !aConvert )
|
|
|
|
aConvert = m_schSettings.m_ShowConvert;
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
for( const LIB_ITEM& item : drawnSymbol->GetDrawItems() )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2018-08-31 21:39:11 +00:00
|
|
|
if( !aDrawFields && item.Type() == LIB_FIELD_T )
|
2018-10-21 12:50:31 +00:00
|
|
|
continue;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
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
|
|
|
|
2018-08-28 13:27:56 +00:00
|
|
|
if( aConvert && item.GetConvert() && aConvert != item.GetConvert() )
|
2018-10-21 12:50:31 +00:00
|
|
|
continue;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2019-04-19 15:54:29 +00:00
|
|
|
Draw( &item, aLayer );
|
2018-10-21 12:50:31 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-08-28 13:27:56 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
bool SCH_PAINTER::setDeviceColors( const LIB_ITEM* aItem, int aLayer )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
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 ) );
|
|
|
|
m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, true ) );
|
2019-11-21 15:48:44 +00:00
|
|
|
m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, true ) );
|
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
|
|
|
{
|
2021-12-15 10:17:04 +00:00
|
|
|
COLOR4D fillColor;
|
2021-12-16 18:04:59 +00:00
|
|
|
|
|
|
|
if( shape->GetFillMode() == FILL_T::FILLED_SHAPE )
|
2022-02-28 21:10:28 +00:00
|
|
|
return false; // rendered on LAYER_NOTES or LAYER_DEVICE
|
2021-12-16 18:04:59 +00:00
|
|
|
else if( shape->GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR )
|
2021-12-15 10:17:04 +00:00
|
|
|
fillColor = getRenderColor( aItem, LAYER_DEVICE_BACKGROUND, false );
|
|
|
|
else if( shape->GetFillMode() == FILL_T::FILLED_WITH_COLOR )
|
|
|
|
fillColor = shape->GetFillColor();
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
|
|
|
|
m_gal->SetIsFill( true );
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetFillColor( fillColor );
|
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:
|
2019-07-30 01:57:41 +00:00
|
|
|
case LAYER_DEVICE:
|
2021-07-17 19:56:18 +00:00
|
|
|
m_gal->SetIsFill( shape && shape->GetFillMode() == FILL_T::FILLED_SHAPE );
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, false ) );
|
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 ) );
|
|
|
|
m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, false ) );
|
|
|
|
}
|
|
|
|
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
|
|
|
|
|
|
|
|
2021-07-18 23:08:54 +00:00
|
|
|
void SCH_PAINTER::draw( const LIB_SHAPE *aShape, int aLayer )
|
2018-10-15 18:35:10 +00:00
|
|
|
{
|
2021-07-18 23:08:54 +00:00
|
|
|
if( !isUnitAndConversionShown( aShape ) )
|
2018-10-15 18:35:10 +00:00
|
|
|
return;
|
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
if( aShape->IsPrivate() && !m_schSettings.m_IsSymbolEditor )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( !setDeviceColors( aShape, aLayer ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
|
|
|
PLOT_DASH_TYPE lineStyle = aShape->GetStroke().GetPlotStyle();
|
|
|
|
COLOR4D color = getRenderColor( aShape, aLayer, drawingShadows );
|
|
|
|
|
|
|
|
auto drawShape =
|
|
|
|
[&]( const LIB_SHAPE* shape )
|
|
|
|
{
|
|
|
|
switch( shape->GetShape() )
|
|
|
|
{
|
|
|
|
case SHAPE_T::ARC:
|
|
|
|
{
|
|
|
|
EDA_ANGLE startAngle;
|
|
|
|
EDA_ANGLE endAngle;
|
|
|
|
shape->CalcArcAngles( startAngle, endAngle );
|
|
|
|
|
|
|
|
TRANSFORM().MapAngles( &startAngle, &endAngle );
|
|
|
|
|
|
|
|
m_gal->DrawArc( mapCoords( shape->GetCenter() ), shape->GetRadius(),
|
|
|
|
startAngle, endAngle );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SHAPE_T::CIRCLE:
|
|
|
|
m_gal->DrawCircle( mapCoords( shape->GetPosition() ), shape->GetRadius() );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SHAPE_T::RECT:
|
|
|
|
m_gal->DrawRectangle( mapCoords( shape->GetPosition() ),
|
|
|
|
mapCoords( shape->GetEnd() ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SHAPE_T::POLY:
|
|
|
|
{
|
|
|
|
const SHAPE_LINE_CHAIN poly = shape->GetPolyShape().Outline( 0 );
|
|
|
|
std::deque<VECTOR2D> mappedPts;
|
|
|
|
|
|
|
|
for( const VECTOR2I& pt : poly.CPoints() )
|
|
|
|
mappedPts.push_back( mapCoords( pt ) );
|
|
|
|
|
|
|
|
m_gal->DrawPolygon( mappedPts );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SHAPE_T::BEZIER:
|
|
|
|
{
|
|
|
|
std::deque<VECTOR2D> mappedPts;
|
|
|
|
|
|
|
|
for( const VECTOR2I& p : shape->GetBezierPoints() )
|
|
|
|
mappedPts.push_back( mapCoords( p ) );
|
|
|
|
|
|
|
|
m_gal->DrawPolygon( mappedPts );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
UNIMPLEMENTED_FOR( shape->SHAPE_T_asString() );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if( aLayer == LAYER_SELECTION_SHADOWS )
|
2019-11-21 15:48:44 +00:00
|
|
|
{
|
2022-01-25 22:33:37 +00:00
|
|
|
if( eeconfig()->m_Selection.fill_shapes )
|
2021-11-16 22:55:53 +00:00
|
|
|
{
|
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.
|
2021-11-16 22:55:53 +00:00
|
|
|
if( aShape->GetShape() == SHAPE_T::ARC )
|
|
|
|
m_gal->SetIsFill( aShape->IsFilled() );
|
|
|
|
else
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
}
|
2022-01-25 22:33:37 +00:00
|
|
|
else
|
2021-07-18 23:08:54 +00:00
|
|
|
{
|
2022-01-25 22:33:37 +00:00
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetLineWidth( getLineWidth( aShape, true ) );
|
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
}
|
2018-09-05 16:21:51 +00:00
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
drawShape( aShape );
|
|
|
|
}
|
|
|
|
else if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND )
|
|
|
|
{
|
2022-02-28 21:10:28 +00:00
|
|
|
if( aShape->GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR
|
|
|
|
|| aShape->GetFillMode() == FILL_T::FILLED_WITH_COLOR )
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( false );
|
|
|
|
drawShape( aShape );
|
2021-07-18 23:08:54 +00:00
|
|
|
}
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
2022-02-28 21:10:28 +00:00
|
|
|
else if( aLayer == LAYER_DEVICE || ( m_schSettings.m_IsSymbolEditor && aLayer == LAYER_NOTES ) )
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
2022-02-28 21:10:28 +00:00
|
|
|
if( aShape->GetFillMode() == FILL_T::FILLED_SHAPE )
|
|
|
|
{
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( false );
|
|
|
|
drawShape( aShape );
|
|
|
|
}
|
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
int lineWidth = getLineWidth( aShape, drawingShadows );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2022-01-31 19:11:21 +00:00
|
|
|
if( lineWidth > 0 )
|
2021-07-18 23:08:54 +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-10-15 18:35:10 +00:00
|
|
|
|
2022-01-31 19:11:21 +00:00
|
|
|
if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE || drawingShadows )
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
2022-01-31 19:11:21 +00:00
|
|
|
drawShape( aShape );
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
2022-01-31 19:11:21 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( true );
|
2018-10-15 18:35:10 +00:00
|
|
|
|
2022-01-31 19:11:21 +00:00
|
|
|
for( SHAPE* shape : shapes )
|
|
|
|
{
|
|
|
|
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( mapCoords( a+1 ), mapCoords( b ) );
|
|
|
|
else
|
|
|
|
m_gal->DrawLine( mapCoords( a ), mapCoords( b ) );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( SHAPE* shape : shapes )
|
|
|
|
delete shape;
|
|
|
|
}
|
2021-07-18 23:08:54 +00:00
|
|
|
}
|
2019-07-30 01:57:41 +00:00
|
|
|
}
|
2018-10-15 18:35:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-20 18:44:13 +00:00
|
|
|
void SCH_PAINTER::draw( const LIB_FIELD *aField, int aLayer )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
|
|
|
|
2021-09-15 20:03:07 +00:00
|
|
|
if( drawingShadows && !( aField->IsBrightened() || aField->IsSelected() ) )
|
2019-07-30 01:57:41 +00:00
|
|
|
return;
|
|
|
|
|
2019-08-27 19:52:04 +00:00
|
|
|
if( !isUnitAndConversionShown( aField ) )
|
|
|
|
return;
|
|
|
|
|
2018-10-21 12:50:31 +00:00
|
|
|
// Must check layer as fields are sometimes drawn by their parent rather than
|
|
|
|
// directly from the view.
|
2019-08-27 19:52:04 +00:00
|
|
|
int layers[KIGFX::VIEW::VIEW_MAX_LAYERS];
|
|
|
|
int layers_count;
|
|
|
|
bool foundLayer = false;
|
|
|
|
|
2018-10-21 12:50:31 +00:00
|
|
|
aField->ViewGetLayers( layers, layers_count );
|
|
|
|
|
2019-08-27 19:52:04 +00:00
|
|
|
for( int i = 0; i < layers_count; ++i )
|
|
|
|
{
|
|
|
|
if( layers[i] == aLayer )
|
|
|
|
foundLayer = true;
|
|
|
|
}
|
2018-09-02 20:19:22 +00:00
|
|
|
|
2019-08-27 19:52:04 +00:00
|
|
|
if( !foundLayer )
|
2018-10-21 12:50:31 +00:00
|
|
|
return;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
|
2018-09-09 20:14:00 +00:00
|
|
|
|
2020-04-24 20:33:59 +00:00
|
|
|
if( !( aField->IsVisible() || aField->IsForceVisible() ) )
|
2018-08-31 17:19:09 +00:00
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
if( !m_schematic || eeconfig()->m_Appearance.show_hidden_fields )
|
2019-07-30 01:57:41 +00:00
|
|
|
color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
|
2018-08-31 17:19:09 +00:00
|
|
|
else
|
2018-09-09 20:14:00 +00:00
|
|
|
return;
|
2018-09-05 22:17:22 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +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
|
|
|
|
2021-09-07 11:32:25 +00:00
|
|
|
EDA_RECT bbox = aField->GetBoundingBox();
|
2022-01-25 22:33:37 +00:00
|
|
|
VECTOR2I textpos = bbox.Centre();
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
if( drawingShadows && ( eeconfig()->m_Selection.text_as_box
|
2022-02-23 12:07:33 +00:00
|
|
|
|| aField->GetDrawFont()->IsOutline()
|
|
|
|
|| underLODThreshold( aField->GetTextHeight() ) ) )
|
2019-11-21 15:48:44 +00:00
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetLineWidth( getTextThickness( aField, drawingShadows ) );
|
2022-01-07 17:42:43 +00:00
|
|
|
m_gal->DrawRectangle( bbox.GetPosition(), bbox.GetEnd() );
|
2019-11-21 15:48:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
TEXT_ATTRIBUTES attrs( aField->GetAttributes() );
|
|
|
|
attrs.m_Halign = GR_TEXT_H_ALIGN_CENTER;
|
|
|
|
attrs.m_Valign = GR_TEXT_V_ALIGN_CENTER;
|
|
|
|
attrs.m_StrokeWidth = getTextThickness( aField, drawingShadows );
|
2019-11-21 15:48:44 +00:00
|
|
|
|
2022-02-24 18:15:47 +00:00
|
|
|
if( nonCached( aField ) && underLODThreshold( aField->GetTextHeight() ) )
|
2022-02-23 12:07:33 +00:00
|
|
|
bitmapText( UnescapeString( aField->GetText() ), textpos, attrs );
|
|
|
|
else
|
|
|
|
strokeText( UnescapeString( aField->GetText() ), textpos, attrs );
|
2019-11-21 15:48:44 +00:00
|
|
|
}
|
2018-10-21 21:54:02 +00:00
|
|
|
|
2021-09-07 20:34:10 +00:00
|
|
|
// Draw the umbilical line when in the schematic editor
|
|
|
|
if( aField->IsMoving() && m_schematic )
|
2018-10-21 21:54:02 +00:00
|
|
|
{
|
|
|
|
m_gal->SetLineWidth( m_schSettings.m_outlineWidth );
|
2021-09-29 00:26:47 +00:00
|
|
|
m_gal->SetStrokeColor( getRenderColor( aField, LAYER_SCHEMATIC_ANCHOR, drawingShadows ) );
|
2022-01-01 06:04:08 +00:00
|
|
|
m_gal->DrawLine( textpos, VECTOR2I( 0, 0 ) );
|
2018-10-21 21:54:02 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
void SCH_PAINTER::draw( const LIB_TEXT* aText, int aLayer )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2018-09-02 20:19:22 +00:00
|
|
|
if( !isUnitAndConversionShown( aText ) )
|
|
|
|
return;
|
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
if( aText->IsPrivate() && !m_schSettings.m_IsSymbolEditor )
|
|
|
|
return;
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
|
|
|
|
2021-09-15 20:03:07 +00:00
|
|
|
if( drawingShadows && !( aText->IsBrightened() || aText->IsSelected() ) )
|
2019-07-30 01:57:41 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
COLOR4D color = getRenderColor( aText, LAYER_DEVICE, drawingShadows );
|
2018-09-09 20:14:00 +00:00
|
|
|
|
2018-09-05 22:17:22 +00:00
|
|
|
if( !aText->IsVisible() )
|
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
if( !m_schematic || 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-09-05 22:17:22 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-09-01 23:29:19 +00:00
|
|
|
EDA_RECT bBox = aText->GetBoundingBox();
|
2022-01-07 17:42:43 +00:00
|
|
|
VECTOR2D pos = bBox.Centre();
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2021-12-31 14:07:24 +00:00
|
|
|
m_gal->SetFillColor( color );
|
2018-08-31 17:19:09 +00:00
|
|
|
m_gal->SetStrokeColor( color );
|
2021-12-31 14:07:24 +00:00
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
if( drawingShadows && ( eeconfig()->m_Selection.text_as_box
|
2022-02-23 12:07:33 +00:00
|
|
|
|| aText->GetDrawFont()->IsOutline()
|
|
|
|
|| underLODThreshold( aText->GetTextHeight() ) ) )
|
2022-01-07 17:42:43 +00:00
|
|
|
{
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetLineWidth( getTextThickness( aText, drawingShadows ) );
|
|
|
|
m_gal->DrawRectangle( bBox.GetPosition(), bBox.GetEnd() );
|
2022-01-25 22:33:37 +00:00
|
|
|
return;
|
2022-01-07 17:42:43 +00:00
|
|
|
}
|
2022-01-25 22:33:37 +00:00
|
|
|
|
|
|
|
wxString shownText( aText->GetShownText() );
|
|
|
|
|
|
|
|
if( !shownText.IsEmpty() )
|
2022-01-07 17:42:43 +00:00
|
|
|
{
|
2022-01-25 22:33:37 +00:00
|
|
|
TEXT_ATTRIBUTES attrs = aText->GetAttributes();
|
2022-01-07 17:42:43 +00:00
|
|
|
attrs.m_StrokeWidth = getTextThickness( aText, drawingShadows );
|
2021-12-31 14:07:24 +00:00
|
|
|
|
2022-03-06 19:48:36 +00:00
|
|
|
if( attrs.m_Angle == ANGLE_VERTICAL )
|
|
|
|
{
|
|
|
|
switch( attrs.m_Halign )
|
|
|
|
{
|
|
|
|
case GR_TEXT_H_ALIGN_LEFT: pos.y = bBox.GetBottom(); break;
|
|
|
|
case GR_TEXT_H_ALIGN_CENTER: pos.y = ( bBox.GetTop() + bBox.GetBottom() ) / 2; break;
|
|
|
|
case GR_TEXT_H_ALIGN_RIGHT: pos.y = bBox.GetTop(); break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch( attrs.m_Halign )
|
|
|
|
{
|
|
|
|
case GR_TEXT_H_ALIGN_LEFT: pos.x = bBox.GetLeft(); break;
|
|
|
|
case GR_TEXT_H_ALIGN_CENTER: pos.x = ( bBox.GetLeft() + bBox.GetRight() ) / 2; break;
|
|
|
|
case GR_TEXT_H_ALIGN_RIGHT: pos.x = bBox.GetRight(); break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Because the text vertical position is the bounding box center, the text is drawn as
|
|
|
|
// vertically centered.
|
2022-01-30 08:11:16 +00:00
|
|
|
attrs.m_Valign = GR_TEXT_V_ALIGN_CENTER;
|
|
|
|
|
2022-03-06 19:48:36 +00:00
|
|
|
if( nonCached( aText )
|
|
|
|
&& underLODThreshold( aText->GetTextHeight() )
|
|
|
|
&& !shownText.Contains( wxT( "\n" ) ) )
|
|
|
|
{
|
|
|
|
bitmapText( shownText, pos, attrs );
|
|
|
|
}
|
2022-02-23 12:07:33 +00:00
|
|
|
else
|
2022-03-06 19:48:36 +00:00
|
|
|
{
|
|
|
|
strokeText( shownText, pos, attrs );
|
|
|
|
}
|
2022-01-07 17:42:43 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
void SCH_PAINTER::draw( const LIB_TEXTBOX* aTextBox, int aLayer )
|
|
|
|
{
|
|
|
|
if( !isUnitAndConversionShown( aTextBox ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( aTextBox->IsPrivate() && !m_schSettings.m_IsSymbolEditor )
|
|
|
|
return;
|
|
|
|
|
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
|
|
|
|
|
|
|
if( drawingShadows && !( aTextBox->IsBrightened() || aTextBox->IsSelected() ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
COLOR4D color = getRenderColor( aTextBox, aLayer, drawingShadows );
|
|
|
|
float borderWidth = getLineWidth( aTextBox, drawingShadows );
|
|
|
|
PLOT_DASH_TYPE borderStyle = aTextBox->GetStroke().GetPlotStyle();
|
|
|
|
wxString shownText = aTextBox->GetShownText();
|
|
|
|
|
|
|
|
auto drawText =
|
|
|
|
[&]()
|
|
|
|
{
|
|
|
|
if( !shownText.IsEmpty() )
|
|
|
|
{
|
|
|
|
TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes();
|
2022-01-31 19:11:21 +00:00
|
|
|
attrs.m_Angle = aTextBox->GetDrawRotation();
|
2022-01-25 22:33:37 +00:00
|
|
|
attrs.m_StrokeWidth = getTextThickness( aTextBox, drawingShadows );
|
|
|
|
|
2022-02-23 12:07:33 +00:00
|
|
|
// Note: don't check LODThreshold for textboxes: the bitmap font may mess
|
|
|
|
// up tab positioning.
|
|
|
|
|
2022-01-31 19:11:21 +00:00
|
|
|
strokeText( shownText, aTextBox->GetDrawPos(), attrs );
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
m_gal->SetFillColor( color );
|
|
|
|
|
|
|
|
if( aLayer == LAYER_SELECTION_SHADOWS )
|
|
|
|
{
|
|
|
|
if( eeconfig()->m_Selection.fill_shapes
|
|
|
|
|| eeconfig()->m_Selection.text_as_box
|
2022-02-23 12:07:33 +00:00
|
|
|
|| aTextBox->GetDrawFont()->IsOutline()
|
|
|
|
|| underLODThreshold( aTextBox->GetTextHeight() ) )
|
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
|
|
|
|
|
|
|
m_gal->DrawRectangle( mapCoords( aTextBox->GetPosition() ),
|
|
|
|
mapCoords( aTextBox->GetEnd() ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetIsFill( false );
|
2022-03-30 13:39:38 +00:00
|
|
|
m_gal->SetLineWidth( borderWidth );
|
2022-01-25 22:33:37 +00:00
|
|
|
|
|
|
|
m_gal->DrawRectangle( mapCoords( aTextBox->GetPosition() ),
|
|
|
|
mapCoords( aTextBox->GetEnd() ) );
|
|
|
|
drawText();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND )
|
|
|
|
{
|
|
|
|
if( aTextBox->IsFilled() )
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
m_gal->DrawRectangle( mapCoords( aTextBox->GetPosition() ),
|
|
|
|
mapCoords( aTextBox->GetEnd() ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( aLayer == LAYER_DEVICE || aLayer == LAYER_NOTES )
|
|
|
|
{
|
2022-01-31 23:53:34 +00:00
|
|
|
drawText();
|
|
|
|
|
2022-03-06 20:32:01 +00:00
|
|
|
if( borderWidth > 0 )
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
2022-04-29 13:10:22 +00:00
|
|
|
COLOR4D borderColor = aTextBox->GetStroke().GetColor();
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2022-01-31 19:11:21 +00:00
|
|
|
if( borderStyle <= PLOT_DASH_TYPE::FIRST_TYPE || drawingShadows )
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
2022-01-31 19:11:21 +00:00
|
|
|
m_gal->DrawRectangle( mapCoords( aTextBox->GetPosition() ),
|
|
|
|
mapCoords( 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 )
|
|
|
|
{
|
|
|
|
STROKE_PARAMS::Stroke( shape, borderStyle, borderWidth, &m_schSettings,
|
|
|
|
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
|
|
|
{
|
|
|
|
// DrawLine has problem with 0 length lines so enforce minimum
|
|
|
|
if( a == b )
|
|
|
|
m_gal->DrawLine( mapCoords( a+1 ), mapCoords( b ) );
|
|
|
|
else
|
|
|
|
m_gal->DrawLine( mapCoords( a ), mapCoords( b ) );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( SHAPE* shape : shapes )
|
|
|
|
delete shape;
|
|
|
|
}
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-03 23:55:31 +00:00
|
|
|
int SCH_PAINTER::internalPinDecoSize( const LIB_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
|
2020-05-03 23:55:31 +00:00
|
|
|
int SCH_PAINTER::externalPinDecoSize( const LIB_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.
|
2021-12-06 18:50:00 +00:00
|
|
|
void SCH_PAINTER::drawPinDanglingSymbol( const VECTOR2I& aPos, const COLOR4D& aColor,
|
2021-09-15 20:03:07 +00:00
|
|
|
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 )
|
2020-08-25 12:46:16 +00:00
|
|
|
: m_schSettings.GetDanglineSymbolThickness() );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-19 15:54:29 +00:00
|
|
|
void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
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;
|
2021-12-07 20:47:12 +00:00
|
|
|
bool drawingDangling = aLayer == LAYER_DANGLING;
|
|
|
|
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;
|
|
|
|
|
2018-09-09 20:14:00 +00:00
|
|
|
VECTOR2I pos = mapCoords( aPin->GetPosition() );
|
2019-07-30 01:57:41 +00:00
|
|
|
COLOR4D color = getRenderColor( aPin, LAYER_PIN, drawingShadows );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-08-30 19:44:10 +00:00
|
|
|
if( !aPin->IsVisible() )
|
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
if( !m_schematic || eeconfig()->m_Appearance.show_hidden_pins )
|
2018-09-09 20:14:00 +00:00
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
|
2018-09-09 20:14:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-07 20:47:12 +00:00
|
|
|
if( drawingDangling && isDangling && aPin->IsPowerConnection() )
|
2021-09-15 20:03:07 +00:00
|
|
|
drawPinDanglingSymbol( pos, color, drawingShadows, aPin->IsBrightened() );
|
2018-08-30 19:44:10 +00:00
|
|
|
|
|
|
|
return;
|
2018-09-09 20:14:00 +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 )
|
2021-09-15 20:03:07 +00:00
|
|
|
drawPinDanglingSymbol( pos, color, drawingShadows, aPin->IsBrightened() );
|
2021-12-06 18:50:00 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-09-24 19:08:29 +00:00
|
|
|
VECTOR2I p0;
|
2019-07-30 01:57:41 +00:00
|
|
|
VECTOR2I dir;
|
2021-09-24 19:08:29 +00:00
|
|
|
int len = aPin->GetLength();
|
|
|
|
int orient = aPin->GetOrientation();
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2021-09-24 19:08:29 +00:00
|
|
|
switch( orient )
|
2019-11-06 19:15:42 +00:00
|
|
|
{
|
2021-09-24 19:08:29 +00:00
|
|
|
case PIN_UP:
|
|
|
|
p0 = VECTOR2I( pos.x, pos.y - len );
|
|
|
|
dir = VECTOR2I( 0, 1 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_DOWN:
|
|
|
|
p0 = VECTOR2I( pos.x, pos.y + len );
|
|
|
|
dir = VECTOR2I( 0, -1 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_LEFT:
|
|
|
|
p0 = VECTOR2I( pos.x - len, pos.y );
|
|
|
|
dir = VECTOR2I( 1, 0 );
|
|
|
|
break;
|
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
default:
|
2021-09-24 19:08:29 +00:00
|
|
|
case PIN_RIGHT:
|
|
|
|
p0 = VECTOR2I( pos.x + len, pos.y );
|
|
|
|
dir = VECTOR2I( -1, 0 );
|
|
|
|
break;
|
2019-11-06 19:15:42 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
|
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() )
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_SYMBOL* libEntry = aPin->GetParent();
|
2019-11-21 15:48:44 +00:00
|
|
|
|
2018-09-19 20:52:13 +00:00
|
|
|
// Draw the labels
|
2021-07-17 19:56:18 +00:00
|
|
|
|
|
|
|
if( libEntry->Type() == LIB_SYMBOL_T )
|
2021-05-27 16:49:53 +00:00
|
|
|
{
|
2021-07-17 19:56:18 +00:00
|
|
|
if( drawingShadows && !eeconfig()->m_Selection.draw_selected_children )
|
|
|
|
return;
|
2021-05-27 16:49:53 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2021-09-17 11:08:16 +00:00
|
|
|
float penWidth = (float) m_schSettings.GetDefaultPenWidth();
|
|
|
|
int textOffset = libEntry->GetPinNameOffset();
|
|
|
|
float nameStrokeWidth = getLineWidth( aPin, drawingShadows );
|
|
|
|
float numStrokeWidth = getLineWidth( aPin, drawingShadows );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2021-09-17 11:08:16 +00:00
|
|
|
nameStrokeWidth = Clamp_Text_PenSize( nameStrokeWidth, aPin->GetNameTextSize(), false );
|
|
|
|
numStrokeWidth = Clamp_Text_PenSize( numStrokeWidth, aPin->GetNumberTextSize(), false );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2021-09-30 14:44:35 +00:00
|
|
|
int PIN_TEXT_MARGIN = 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 };
|
|
|
|
int size[4] = { 0, 0, 0, 0 };
|
2021-09-17 11:08:16 +00:00
|
|
|
float thickness[4] = { numStrokeWidth, numStrokeWidth, numStrokeWidth, numStrokeWidth };
|
2018-08-30 01:38:08 +00:00
|
|
|
COLOR4D colour[4];
|
|
|
|
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
|
|
|
{
|
2018-08-30 01:38:08 +00:00
|
|
|
size [INSIDE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
|
2021-09-17 11:08:16 +00:00
|
|
|
thickness[INSIDE] = nameStrokeWidth;
|
2019-07-30 01:57:41 +00:00
|
|
|
colour [INSIDE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
|
2021-06-12 18:54:34 +00:00
|
|
|
text [INSIDE] = aPin->GetShownName();
|
2018-08-30 01:38:08 +00:00
|
|
|
|
|
|
|
size [ABOVE] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
|
2021-09-17 11:08:16 +00:00
|
|
|
thickness[ABOVE] = numStrokeWidth;
|
2019-07-30 01:57:41 +00:00
|
|
|
colour [ABOVE] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
|
2021-06-12 18:54:34 +00:00
|
|
|
text [ABOVE] = aPin->GetShownNumber();
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
// Otherwise pin NAMES go above and pin NUMBERS go below
|
|
|
|
else
|
|
|
|
{
|
|
|
|
size [ABOVE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
|
2021-09-17 11:08:16 +00:00
|
|
|
thickness[ABOVE] = nameStrokeWidth;
|
2019-07-30 01:57:41 +00:00
|
|
|
colour [ABOVE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
|
2021-06-12 18:54:34 +00:00
|
|
|
text [ABOVE] = aPin->GetShownName();
|
2018-08-30 01:38:08 +00:00
|
|
|
|
|
|
|
size [BELOW] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
|
2021-09-17 11:08:16 +00:00
|
|
|
thickness[BELOW] = numStrokeWidth;
|
2019-07-30 01:57:41 +00:00
|
|
|
colour [BELOW] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
|
2021-06-12 18:54:34 +00:00
|
|
|
text [BELOW] = aPin->GetShownNumber();
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
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
|
|
|
{
|
|
|
|
size [OUTSIDE] = std::max( aPin->GetNameTextSize() * 3 / 4, Millimeter2iu( 0.7 ) );
|
2021-12-31 14:07:24 +00:00
|
|
|
thickness[OUTSIDE] = float( size[OUTSIDE] ) / 8.0F;
|
2019-07-30 01:57:41 +00:00
|
|
|
colour [OUTSIDE] = getRenderColor( aPin, LAYER_NOTES, drawingShadows );
|
2018-08-30 01:38:08 +00:00
|
|
|
text [OUTSIDE] = aPin->GetElectricalTypeName();
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-08-30 19:44:10 +00:00
|
|
|
if( !aPin->IsVisible() )
|
|
|
|
{
|
|
|
|
for( COLOR4D& c : colour )
|
2019-07-30 01:57:41 +00:00
|
|
|
c = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
|
2018-08-30 19:44:10 +00:00
|
|
|
}
|
|
|
|
|
2022-04-05 12:15:27 +00:00
|
|
|
float insideOffset = textOffset - thickness[INSIDE] / 2.0;
|
|
|
|
float outsideOffset = Mils2iu( PIN_TEXT_MARGIN ) + TARGET_PIN_RADIUS - thickness[OUTSIDE] / 2.0;
|
|
|
|
float aboveOffset = Mils2iu( PIN_TEXT_MARGIN ) + penWidth / 2.0 + thickness[ABOVE] / 2.0;
|
|
|
|
float belowOffset = Mils2iu( PIN_TEXT_MARGIN ) + penWidth / 2.0 + thickness[BELOW] / 2.0;
|
2021-09-17 11:08:16 +00:00
|
|
|
|
2021-12-07 20:47:12 +00:00
|
|
|
if( isDangling )
|
2021-09-17 11:08:16 +00:00
|
|
|
outsideOffset += TARGET_PIN_RADIUS / 2.0;
|
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;
|
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;
|
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;
|
|
|
|
attrs.m_StrokeWidth = thickness[i];
|
2021-09-15 20:15:55 +00:00
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
if( drawingShadows && ( eeconfig()->m_Selection.text_as_box
|
2022-02-23 12:07:33 +00:00
|
|
|
|| aPin->GetDrawFont()->IsOutline()
|
|
|
|
|| underLODThreshold( size[i] ) ) )
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
boxText( text[i], aPos, attrs );
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
2022-02-24 18:15:47 +00:00
|
|
|
else if( nonCached( aPin ) && underLODThreshold( size[i] ) )
|
2022-02-23 12:07:33 +00:00
|
|
|
{
|
|
|
|
bitmapText( text[i], aPos, attrs );
|
|
|
|
}
|
2021-09-15 20:15:55 +00:00
|
|
|
else
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
strokeText( text[i], aPos, attrs );
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
2021-09-15 20:15:55 +00:00
|
|
|
};
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2021-09-24 19:08:29 +00:00
|
|
|
switch( orient )
|
2018-08-29 18:31:43 +00:00
|
|
|
{
|
2018-08-30 01:38:08 +00:00
|
|
|
case PIN_LEFT:
|
|
|
|
if( size[INSIDE] )
|
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
drawText( INSIDE, pos + VECTOR2D( -insideOffset - 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
|
|
|
|
2018-08-30 01:38:08 +00:00
|
|
|
case PIN_RIGHT:
|
|
|
|
if( size[INSIDE] )
|
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
drawText( INSIDE, pos + VECTOR2D( insideOffset + 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
|
|
|
|
2018-08-30 01:38:08 +00:00
|
|
|
case PIN_DOWN:
|
|
|
|
if( size[INSIDE] )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
drawText( INSIDE, pos + VECTOR2D( 0, insideOffset + 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
|
|
|
|
2018-08-30 01:38:08 +00:00
|
|
|
case PIN_UP:
|
|
|
|
if( size[INSIDE] )
|
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
drawText( INSIDE, pos + VECTOR2D( 0, -insideOffset - 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.
|
2021-12-29 21:30:11 +00:00
|
|
|
void SCH_PAINTER::drawDanglingSymbol( const VECTOR2I& aPos, const COLOR4D& aColor, int aWidth,
|
2021-09-15 20:03:07 +00:00
|
|
|
bool aDrawingShadows, bool aBrightened )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I radius( aWidth + Mils2iu( DANGLING_SYMBOL_SIZE / 2 ),
|
|
|
|
aWidth + Mils2iu( DANGLING_SYMBOL_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 )
|
2020-08-25 12:46:16 +00:00
|
|
|
: m_schSettings.GetDanglineSymbolThickness() );
|
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
|
|
|
|
2020-12-20 18:44:13 +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;
|
|
|
|
|
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
|
|
|
|
2020-12-20 18:44:13 +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;
|
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 && !( aLine->IsBrightened() || aLine->IsSelected() ) )
|
2019-07-30 01:57:41 +00:00
|
|
|
return;
|
2018-09-05 22:17:22 +00:00
|
|
|
|
2022-03-03 14:35:57 +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
|
|
|
|
if( aLine->IsNew() && drawingDangling )
|
|
|
|
return;
|
|
|
|
|
2020-07-08 18:29:16 +00:00
|
|
|
COLOR4D color = getRenderColor( aLine, aLine->GetLayer(), drawingShadows );
|
|
|
|
float width = getLineWidth( aLine, drawingShadows );
|
|
|
|
PLOT_DASH_TYPE lineStyle = aLine->GetEffectiveLineStyle();
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2021-12-28 15:42:19 +00:00
|
|
|
if( drawingDangling || drawingShadows )
|
2021-12-06 18:50:00 +00:00
|
|
|
{
|
|
|
|
if( aLine->IsStartDangling() && aLine->IsWire() )
|
|
|
|
{
|
2022-02-10 18:38:40 +00:00
|
|
|
COLOR4D danglingColor =
|
|
|
|
( drawingShadows && !aLine->HasFlag( STARTPOINT ) ) ? color.Inverted() : color;
|
|
|
|
drawDanglingSymbol( aLine->GetStartPoint(), danglingColor,
|
|
|
|
getLineWidth( aLine, drawingShadows ), drawingShadows,
|
|
|
|
aLine->IsBrightened() );
|
2021-12-06 18:50:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( aLine->IsEndDangling() && aLine->IsWire() )
|
|
|
|
{
|
2022-02-10 18:38:40 +00:00
|
|
|
COLOR4D danglingColor =
|
|
|
|
( drawingShadows && !aLine->HasFlag( ENDPOINT ) ) ? color.Inverted() : color;
|
|
|
|
drawDanglingSymbol( aLine->GetEndPoint(), danglingColor,
|
|
|
|
getLineWidth( aLine, drawingShadows ), drawingShadows,
|
|
|
|
aLine->IsBrightened() );
|
2021-12-06 18:50:00 +00:00
|
|
|
}
|
|
|
|
|
2021-12-28 15:42:19 +00:00
|
|
|
if( drawingDangling )
|
|
|
|
return;
|
2021-12-06 18:50:00 +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
|
|
|
|
2020-07-08 18:29:16 +00:00
|
|
|
if( lineStyle <= PLOT_DASH_TYPE::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
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
STROKE_PARAMS::Stroke( &line, lineStyle, width, &m_schSettings,
|
2022-01-01 06:04:08 +00:00
|
|
|
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
2022-01-12 08:44:30 +00:00
|
|
|
// DrawLine has problem with 0 length lines
|
|
|
|
// so draw a line with a minimal length
|
|
|
|
if( a == b )
|
|
|
|
m_gal->DrawLine( a+1, b );
|
|
|
|
else
|
|
|
|
m_gal->DrawLine( a, b );
|
2021-07-17 19:56:18 +00:00
|
|
|
} );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer )
|
|
|
|
{
|
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
|
|
|
PLOT_DASH_TYPE lineStyle = aShape->GetEffectiveLineStyle();
|
2022-01-22 22:26:48 +00:00
|
|
|
COLOR4D color = getRenderColor( aShape, aLayer, drawingShadows );
|
|
|
|
|
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:
|
|
|
|
{
|
2022-01-16 01:06:25 +00:00
|
|
|
EDA_ANGLE startAngle;
|
|
|
|
EDA_ANGLE endAngle;
|
2021-07-17 19:56:18 +00:00
|
|
|
aShape->CalcArcAngles( startAngle, endAngle );
|
|
|
|
|
2022-01-16 16:15:07 +00:00
|
|
|
m_gal->DrawArc( aShape->GetCenter(), aShape->GetRadius(), startAngle,
|
|
|
|
endAngle );
|
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:
|
|
|
|
m_gal->DrawCircle( shape->GetPosition(), shape->GetRadius() );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SHAPE_T::RECT:
|
|
|
|
m_gal->DrawRectangle( shape->GetPosition(), shape->GetEnd() );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SHAPE_T::POLY:
|
|
|
|
{
|
|
|
|
std::deque<VECTOR2D> pts;
|
|
|
|
|
|
|
|
for( const VECTOR2I& pt : shape->GetPolyShape().Outline( 0 ).CPoints() )
|
|
|
|
pts.push_back( pt );
|
|
|
|
|
|
|
|
m_gal->DrawPolygon( pts );
|
|
|
|
break;
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
2021-07-17 19:56:18 +00:00
|
|
|
|
|
|
|
case SHAPE_T::BEZIER:
|
|
|
|
{
|
|
|
|
std::deque<VECTOR2D> pts;
|
|
|
|
|
|
|
|
for( const VECTOR2I &p : shape->GetPolyShape().Outline( 0 ).CPoints() )
|
|
|
|
pts.push_back( p );
|
|
|
|
|
|
|
|
m_gal->DrawPolygon( pts );
|
|
|
|
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 );
|
|
|
|
}
|
2022-01-31 19:11:21 +00:00
|
|
|
else if( aLayer == LAYER_NOTES_BACKGROUND )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
2022-01-31 19:11:21 +00:00
|
|
|
if( aShape->IsFilled() )
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
else if( aLayer == LAYER_NOTES )
|
|
|
|
{
|
2022-01-11 18:17:41 +00:00
|
|
|
int 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
|
|
|
|
2022-01-31 19:11:21 +00:00
|
|
|
if( lineStyle <= PLOT_DASH_TYPE::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 )
|
|
|
|
{
|
|
|
|
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 );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( SHAPE* shape : shapes )
|
|
|
|
delete shape;
|
|
|
|
}
|
2018-09-07 21:33:01 +00:00
|
|
|
}
|
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-20 18:44:13 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_TEXT *aText, int aLayer )
|
2018-08-30 22:43:42 +00:00
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
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 && !( 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
|
|
|
{
|
2022-01-24 13:40:39 +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;
|
|
|
|
case SCH_LABEL_T: aLayer = LAYER_LOCLABEL; break;
|
|
|
|
default: aLayer = LAYER_NOTES; break;
|
2018-08-31 17:19:09 +00:00
|
|
|
}
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
COLOR4D color = getRenderColor( aText, aLayer, drawingShadows );
|
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
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
if( !m_schematic || 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
|
|
|
}
|
|
|
|
|
2021-12-07 20:47:12 +00:00
|
|
|
if( drawingDangling )
|
2021-12-06 18:50:00 +00:00
|
|
|
{
|
|
|
|
if( aText->IsDangling() )
|
|
|
|
{
|
|
|
|
drawDanglingSymbol( aText->GetTextPos(), color, Mils2iu( DANGLING_SYMBOL_SIZE / 2 ),
|
2021-09-15 20:03:07 +00:00
|
|
|
drawingShadows, aText->IsBrightened() );
|
2021-12-06 18:50:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2022-01-07 14:49:17 +00:00
|
|
|
VECTOR2I text_offset = aText->GetSchematicTextOffset( &m_schSettings );
|
2018-08-30 22:43:42 +00:00
|
|
|
wxString shownText( aText->GetShownText() );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
if( drawingShadows && ( eeconfig()->m_Selection.text_as_box
|
2022-02-23 12:07:33 +00:00
|
|
|
|| aText->GetDrawFont()->IsOutline()
|
|
|
|
|| underLODThreshold( aText->GetTextHeight() ) ) )
|
2019-08-03 23:03:35 +00:00
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
EDA_RECT bBox = aText->GetBoundingBox();
|
|
|
|
bBox.RevertYAxis();
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetLineWidth( getTextThickness( aText, drawingShadows ) );
|
|
|
|
m_gal->DrawRectangle( mapCoords( bBox.GetPosition() ), mapCoords( bBox.GetEnd() ) );
|
|
|
|
return;
|
2019-08-03 23:03:35 +00:00
|
|
|
}
|
|
|
|
|
2018-08-30 22:43:42 +00:00
|
|
|
if( !shownText.IsEmpty() )
|
2020-04-14 12:25:00 +00:00
|
|
|
{
|
2021-12-31 14:07:24 +00:00
|
|
|
TEXT_ATTRIBUTES attrs = aText->GetAttributes();
|
2022-01-31 19:11:21 +00:00
|
|
|
attrs.m_Angle = aText->GetDrawRotation();
|
2021-12-31 14:07:24 +00:00
|
|
|
attrs.m_StrokeWidth = getTextThickness( aText, drawingShadows );
|
2019-07-30 01:57:41 +00:00
|
|
|
|
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.
|
|
|
|
if( aText->GetDrawFont()->IsOutline() )
|
|
|
|
{
|
|
|
|
EDA_RECT firstLineBBox = aText->GetTextBox( 0 );
|
|
|
|
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 )
|
|
|
|
&& underLODThreshold( aText->GetTextHeight() )
|
|
|
|
&& !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-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-04-25 22:22:45 +00:00
|
|
|
cache = aText->GetRenderCache( shownText, text_offset );
|
2022-02-23 12:07:33 +00:00
|
|
|
|
|
|
|
if( cache )
|
|
|
|
{
|
|
|
|
for( const std::unique_ptr<KIFONT::GLYPH>& glyph : *cache )
|
|
|
|
m_gal->DrawGlyph( *glyph.get() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strokeText( shownText, aText->GetDrawPos() + text_offset, attrs );
|
|
|
|
}
|
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
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer )
|
|
|
|
{
|
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
|
|
|
COLOR4D color = getRenderColor( aTextBox, aLayer, drawingShadows );
|
|
|
|
float borderWidth = getLineWidth( aTextBox, drawingShadows );
|
|
|
|
PLOT_DASH_TYPE borderStyle = aTextBox->GetEffectiveLineStyle();
|
|
|
|
wxString shownText = aTextBox->GetShownText();
|
|
|
|
|
|
|
|
auto drawText =
|
|
|
|
[&]()
|
|
|
|
{
|
|
|
|
if( !shownText.IsEmpty() )
|
|
|
|
{
|
|
|
|
TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes();
|
2022-01-31 19:11:21 +00:00
|
|
|
attrs.m_Angle = aTextBox->GetDrawRotation();
|
2022-01-25 22:33:37 +00:00
|
|
|
attrs.m_StrokeWidth = getTextThickness( aTextBox, drawingShadows );
|
|
|
|
|
2022-02-23 12:07:33 +00:00
|
|
|
// Note: don't check LODThreshold for textboxes: the bitmap font may mess
|
|
|
|
// up tab positioning.
|
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
|
|
|
|
|
|
|
|
cache = aTextBox->GetRenderCache( shownText );
|
|
|
|
|
|
|
|
if( cache )
|
|
|
|
{
|
|
|
|
for( const std::unique_ptr<KIFONT::GLYPH>& glyph : *cache )
|
|
|
|
m_gal->DrawGlyph( *glyph.get() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-31 19:11:21 +00:00
|
|
|
strokeText( shownText, aTextBox->GetDrawPos(), attrs );
|
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 )
|
|
|
|
{
|
|
|
|
if( eeconfig()->m_Selection.fill_shapes
|
|
|
|
|| eeconfig()->m_Selection.text_as_box
|
2022-02-23 12:07:33 +00:00
|
|
|
|| aTextBox->GetDrawFont()->IsOutline()
|
|
|
|
|| underLODThreshold( aTextBox->GetTextHeight() ) )
|
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
|
|
|
|
|
|
|
m_gal->DrawRectangle( aTextBox->GetPosition(), aTextBox->GetEnd() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetIsFill( false );
|
2022-03-30 13:39:38 +00:00
|
|
|
m_gal->SetLineWidth( borderWidth );
|
2022-01-25 22:33:37 +00:00
|
|
|
|
|
|
|
m_gal->DrawRectangle( aTextBox->GetPosition(), aTextBox->GetEnd() );
|
|
|
|
drawText();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( aLayer == LAYER_NOTES_BACKGROUND )
|
|
|
|
{
|
|
|
|
if( aTextBox->IsFilled() )
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
m_gal->DrawRectangle( aTextBox->GetPosition(), aTextBox->GetEnd() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( aLayer == LAYER_NOTES )
|
|
|
|
{
|
2022-01-31 23:53:34 +00:00
|
|
|
drawText();
|
|
|
|
|
2022-03-30 13:39:38 +00:00
|
|
|
if( borderWidth > 0 )
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
2022-04-29 13:10:22 +00:00
|
|
|
COLOR4D borderColor = aTextBox->GetStroke().GetColor();
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2022-01-31 19:11:21 +00:00
|
|
|
if( borderStyle <= PLOT_DASH_TYPE::FIRST_TYPE || drawingShadows )
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
2022-01-31 19:11:21 +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 )
|
|
|
|
{
|
|
|
|
STROKE_PARAMS::Stroke( shape, borderStyle, borderWidth, &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 );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( SHAPE* shape : shapes )
|
|
|
|
delete shape;
|
|
|
|
}
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2018-09-01 23:29:19 +00:00
|
|
|
for( auto& 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
|
|
|
}
|
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
for( auto& 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++ )
|
2022-01-01 06:04:08 +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 )
|
2022-01-01 06:04:08 +00:00
|
|
|
item.MirrorVertical( VECTOR2I( 0, 0 ) );
|
2018-09-01 23:29:19 +00:00
|
|
|
|
|
|
|
if( o.mirror_y )
|
2022-01-01 06:04:08 +00:00
|
|
|
item.MirrorHorizontal( VECTOR2I( 0, 0 ) );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-30 22:43:42 +00:00
|
|
|
|
2021-06-10 14:10:55 +00:00
|
|
|
void SCH_PAINTER::draw( 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;
|
|
|
|
|
|
|
|
if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
|
|
|
|
{
|
|
|
|
for( const SCH_FIELD& field : aSymbol->GetFields() )
|
|
|
|
draw( &field, aLayer );
|
|
|
|
}
|
|
|
|
|
|
|
|
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() );
|
|
|
|
int convert = aSymbol->GetConvert();
|
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).
|
2021-06-15 12:31:28 +00:00
|
|
|
LIB_SYMBOL* originalSymbol = aSymbol->GetLibSymbolRef() ?
|
|
|
|
aSymbol->GetLibSymbolRef().get() : dummy();
|
2020-08-21 15:54:24 +00:00
|
|
|
LIB_PINS originalPins;
|
2021-06-10 18:51:46 +00:00
|
|
|
originalSymbol->GetPins( originalPins, unit, convert );
|
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.
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_SYMBOL tempSymbol( *originalSymbol );
|
2020-08-21 15:54:24 +00:00
|
|
|
LIB_PINS tempPins;
|
2021-06-10 18:51:46 +00:00
|
|
|
tempSymbol.GetPins( tempPins, unit, convert );
|
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
|
|
|
|
2022-02-17 19:02:51 +00:00
|
|
|
for( LIB_ITEM& tempItem : tempSymbol.GetDrawItems() )
|
2019-04-23 17:40:29 +00:00
|
|
|
{
|
2020-11-15 17:03:27 +00:00
|
|
|
tempItem.SetFlags( aSymbol->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
|
2022-01-01 06:04:08 +00:00
|
|
|
tempItem.MoveTo( tempItem.GetPosition() + (VECTOR2I) mapCoords( aSymbol->GetPosition() ) );
|
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 ] );
|
2019-04-19 15:54:29 +00:00
|
|
|
LIB_PIN* tempPin = tempPins[ i ];
|
2018-09-05 16:21:51 +00:00
|
|
|
|
2019-04-22 10:14:47 +00:00
|
|
|
tempPin->ClearFlags();
|
2020-11-15 17:03:27 +00:00
|
|
|
tempPin->SetFlags( symbolPin->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2021-06-12 18:54:34 +00:00
|
|
|
tempPin->SetName( symbolPin->GetShownName() );
|
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 );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
draw( &tempSymbol, aLayer, false, aSymbol->GetUnit(), aSymbol->GetConvert() );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-09-01 23:29:19 +00:00
|
|
|
|
2020-12-20 18:44:13 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_FIELD *aField, int aLayer )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
|
|
|
|
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
|
|
|
|
2021-10-12 20:05:37 +00:00
|
|
|
if( !drawingShadows && aField->GetLayer() != aLayer )
|
|
|
|
return;
|
|
|
|
|
2020-03-06 12:05:21 +00:00
|
|
|
aLayer = aField->GetLayer();
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
|
|
|
|
|
2020-04-18 11:04:52 +00:00
|
|
|
if( !( aField->IsVisible() || aField->IsForceVisible() ) )
|
2018-08-31 17:19:09 +00:00
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
if( !m_schematic || eeconfig()->m_Appearance.show_hidden_fields )
|
2019-07-30 01:57:41 +00:00
|
|
|
color = getRenderColor( aField, 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-08-31 17:19:09 +00:00
|
|
|
if( aField->IsVoid() )
|
2018-08-03 12:18:26 +00:00
|
|
|
return;
|
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
if( drawingShadows && !eeconfig()->m_Selection.draw_selected_children )
|
2019-11-21 15:48:44 +00:00
|
|
|
return;
|
|
|
|
|
2021-04-02 09:54:03 +00:00
|
|
|
if( aField->IsHypertext() && ( aField->GetFlags() & IS_ROLLOVER ) > 0
|
|
|
|
&& !drawingShadows && !aField->IsMoving() )
|
2020-11-17 16:02:47 +00:00
|
|
|
{
|
|
|
|
color = PUREBLUE;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2020-11-15 17:03:27 +00:00
|
|
|
// Rotate symbol 90 degrees.
|
2021-12-28 22:13:54 +00:00
|
|
|
if( orient.IsHorizontal() )
|
2022-01-13 12:29:46 +00:00
|
|
|
orient = ANGLE_VERTICAL;
|
2018-08-03 12:18:26 +00:00
|
|
|
else
|
2022-01-13 12:29:46 +00:00
|
|
|
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
|
|
|
*/
|
2021-09-07 11:32:25 +00:00
|
|
|
EDA_RECT 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 ) );
|
|
|
|
}
|
|
|
|
|
2021-12-29 21:30:11 +00:00
|
|
|
VECTOR2I textpos = bbox.Centre();
|
2018-08-03 12:18:26 +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
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
if( drawingShadows && ( eeconfig()->m_Selection.text_as_box
|
2022-02-23 12:07:33 +00:00
|
|
|
|| aField->GetDrawFont()->IsOutline()
|
|
|
|
|| underLODThreshold( aField->GetTextHeight() ) ) )
|
2019-11-21 15:48:44 +00:00
|
|
|
{
|
2021-09-07 11:32:25 +00:00
|
|
|
bbox.RevertYAxis();
|
2021-12-31 14:07:24 +00:00
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetLineWidth( getTextThickness( aField, drawingShadows ) );
|
2021-09-07 11:32:25 +00:00
|
|
|
m_gal->DrawRectangle( mapCoords( bbox.GetPosition() ), mapCoords( bbox.GetEnd() ) );
|
2019-11-21 15:48:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-07 17:42:43 +00:00
|
|
|
wxString shownText = aField->GetShownText();
|
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;
|
|
|
|
attributes.m_StrokeWidth = getTextThickness( aField, drawingShadows );
|
|
|
|
attributes.m_Angle = orient;
|
2019-11-21 15:48:44 +00:00
|
|
|
|
2022-02-24 18:15:47 +00:00
|
|
|
if( nonCached( aField ) && underLODThreshold( aField->GetTextHeight() ) )
|
2022-01-07 17:42:43 +00:00
|
|
|
{
|
2022-02-23 12:07:33 +00:00
|
|
|
bitmapText( shownText, textpos, attributes );
|
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;
|
|
|
|
|
|
|
|
cache = aField->GetRenderCache( shownText, textpos, attributes );
|
|
|
|
|
|
|
|
if( cache )
|
|
|
|
{
|
|
|
|
for( const std::unique_ptr<KIFONT::GLYPH>& glyph : *cache )
|
|
|
|
m_gal->DrawGlyph( *glyph.get() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strokeText( shownText, textpos, attributes );
|
|
|
|
}
|
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
|
|
|
|
if( aField->IsMoving() )
|
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I parentPos = aField->GetParentPosition();
|
2020-03-06 12:05:21 +00:00
|
|
|
|
2018-10-21 21:54:02 +00:00
|
|
|
m_gal->SetLineWidth( m_schSettings.m_outlineWidth );
|
2021-09-29 00:26:47 +00:00
|
|
|
m_gal->SetStrokeColor( getRenderColor( aField, LAYER_SCHEMATIC_ANCHOR, drawingShadows ) );
|
2020-03-06 12:05:21 +00:00
|
|
|
m_gal->DrawLine( textpos, 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
|
|
|
|
2021-10-12 20:05:37 +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;
|
|
|
|
|
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() )
|
|
|
|
draw( &field, aLayer );
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
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
|
|
|
// The text is drawn inside the graphic shape.
|
|
|
|
// On Cairo the graphic shape is filled by the background before drawing the text.
|
|
|
|
// However if the text is selected, it is draw twice: first on LAYER_SELECTION_SHADOWS
|
|
|
|
// and second on the text layer. The second must not erase the first drawing.
|
|
|
|
bool fillBg = ( ( aLayer == LAYER_SELECTION_SHADOWS ) || !aLabel->IsSelected() )
|
|
|
|
&& aLayer != LAYER_DANGLING;
|
|
|
|
m_gal->SetIsFill( fillBg );
|
|
|
|
m_gal->SetFillColor( m_schSettings.GetLayerColor( LAYER_SCHEMATIC_BACKGROUND ) );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
|
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
m_gal->DrawPolyline( pts2 );
|
|
|
|
|
2021-10-12 20:05:37 +00:00
|
|
|
draw( static_cast<const SCH_TEXT*>( aLabel ), aLayer );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_PAINTER::draw( const SCH_LABEL *aLabel, int aLayer )
|
|
|
|
{
|
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
|
|
|
|
|
|
|
if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
|
|
|
|
{
|
|
|
|
for( const SCH_FIELD& field : aLabel->GetFields() )
|
|
|
|
draw( &field, aLayer );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( isFieldsLayer( aLayer ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( drawingShadows && !( aLabel->IsBrightened() || aLabel->IsSelected() ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
draw( static_cast<const SCH_TEXT*>( aLabel ), aLayer );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-12 20:05:37 +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;
|
|
|
|
|
2021-10-12 20:05:37 +00:00
|
|
|
if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
|
|
|
|
{
|
|
|
|
for( const SCH_FIELD& field : aLabel->GetFields() )
|
|
|
|
draw( &field, aLayer );
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
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 );
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetLineWidth( getTextThickness( 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 );
|
|
|
|
|
2020-12-20 18:44:13 +00:00
|
|
|
draw( static_cast<const SCH_TEXT*>( aLabel ), aLayer );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2020-12-20 18:44:13 +00:00
|
|
|
|
2022-01-24 13:40:39 +00:00
|
|
|
void SCH_PAINTER::draw( const SCH_DIRECTIVE_LABEL *aLabel, int aLayer )
|
2021-10-12 20:05:37 +00:00
|
|
|
{
|
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
|
|
|
|
|
|
|
if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
|
|
|
|
{
|
|
|
|
for( const SCH_FIELD& field : aLabel->GetFields() )
|
|
|
|
draw( &field, aLayer );
|
|
|
|
}
|
|
|
|
|
|
|
|
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() )
|
|
|
|
{
|
|
|
|
drawDanglingSymbol( aLabel->GetTextPos(), color, Mils2iu( DANGLING_SYMBOL_SIZE / 2 ),
|
|
|
|
drawingShadows, aLabel->IsBrightened() );
|
|
|
|
}
|
|
|
|
|
|
|
|
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 );
|
|
|
|
m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-20 18:44:13 +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;
|
|
|
|
|
2021-10-12 20:05:37 +00:00
|
|
|
if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
|
|
|
|
{
|
|
|
|
for( const SCH_FIELD& field : aSheet->GetFields() )
|
|
|
|
draw( &field, aLayer );
|
|
|
|
}
|
|
|
|
|
2020-03-06 20:02:58 +00:00
|
|
|
if( aLayer == LAYER_HIERLABEL || aLayer == LAYER_SELECTION_SHADOWS )
|
2019-07-30 01:57:41 +00:00
|
|
|
{
|
2020-01-12 18:40:50 +00:00
|
|
|
for( SCH_SHEET_PIN* sheetPin : aSheet->GetPins() )
|
2019-07-30 01:57:41 +00:00
|
|
|
{
|
2021-09-15 20:03:07 +00:00
|
|
|
if( drawingShadows )
|
2020-04-12 23:09:17 +00:00
|
|
|
{
|
2021-09-15 20:03:07 +00:00
|
|
|
if( ( aSheet->IsBrightened() || aSheet->IsSelected() )
|
|
|
|
&& eeconfig()->m_Selection.draw_selected_children )
|
|
|
|
{
|
|
|
|
// fall through to draw
|
|
|
|
}
|
|
|
|
else if( sheetPin->IsBrightened() || sheetPin->IsSelected() )
|
|
|
|
{
|
|
|
|
// fall through to draw
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2020-04-12 23:09:17 +00:00
|
|
|
}
|
2019-11-21 15:48:44 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
int width = std::max( aSheet->GetPenWidth(), m_schSettings.GetDefaultPenWidth() );
|
2021-12-29 21:30:11 +00:00
|
|
|
VECTOR2I initial_pos = sheetPin->GetTextPos();
|
|
|
|
VECTOR2I offset_pos = initial_pos;
|
2019-07-30 01:57:41 +00:00
|
|
|
|
|
|
|
// For aesthetic reasons, the SHEET_PIN is drawn with a small offset of width / 2
|
2021-11-28 19:06:08 +00:00
|
|
|
switch( sheetPin->GetSide() )
|
2019-07-30 01:57:41 +00:00
|
|
|
{
|
2021-05-31 01:20:43 +00:00
|
|
|
case SHEET_SIDE::TOP: offset_pos.y += KiROUND( width / 2.0 ); break;
|
|
|
|
case SHEET_SIDE::BOTTOM: offset_pos.y -= KiROUND( width / 2.0 ); break;
|
|
|
|
case SHEET_SIDE::RIGHT: offset_pos.x -= KiROUND( width / 2.0 ); break;
|
|
|
|
case SHEET_SIDE::LEFT: offset_pos.x += KiROUND( width / 2.0 ); break;
|
2019-07-30 01:57:41 +00:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
2020-01-12 18:40:50 +00:00
|
|
|
sheetPin->SetTextPos( offset_pos );
|
|
|
|
draw( static_cast<SCH_HIERLABEL*>( sheetPin ), aLayer );
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->DrawLine( offset_pos, initial_pos );
|
2020-01-12 18:40:50 +00:00
|
|
|
sheetPin->SetTextPos( initial_pos );
|
2019-07-30 01:57:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2020-03-08 02:18:45 +00:00
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
2020-12-20 18:44:13 +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
|
|
|
|
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;
|
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() )
|
|
|
|
line.SetSelected();
|
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() );
|
2021-06-13 19:44:13 +00:00
|
|
|
line.SetLineWidth( getLineWidth( aEntry, drawingShadows ) );
|
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 ) );
|
2021-09-15 20:03:07 +00:00
|
|
|
m_gal->SetLineWidth( drawingShadows ? getShadowWidth( aEntry->IsBrightened() )
|
|
|
|
: m_schSettings.GetDanglineSymbolThickness() );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2021-12-06 18:50:00 +00:00
|
|
|
if( aEntry->IsDanglingStart() )
|
|
|
|
{
|
|
|
|
m_gal->DrawCircle( aEntry->GetPosition(),
|
|
|
|
aEntry->GetPenWidth() + ( TARGET_BUSENTRY_RADIUS / 2 ) );
|
|
|
|
}
|
2018-09-05 22:17:22 +00:00
|
|
|
|
2021-12-06 18:50:00 +00:00
|
|
|
if( aEntry->IsDanglingEnd() )
|
|
|
|
{
|
|
|
|
m_gal->DrawCircle( aEntry->GetEnd(),
|
|
|
|
aEntry->GetPenWidth() + ( TARGET_BUSENTRY_RADIUS / 2 ) );
|
|
|
|
}
|
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
|
|
|
|
2020-12-20 18:44:13 +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
|
|
|
|
2020-12-20 18:44:13 +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
|
|
|
|
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
|