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
|
2020-03-08 02:18:45 +00:00
|
|
|
* Copyright (C) 2019-2020 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>
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <bezier_curves.h>
|
|
|
|
#include <class_libentry.h>
|
|
|
|
#include <class_library.h>
|
|
|
|
#include <connection_graph.h>
|
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
|
|
|
#include <geometry/geometry_utils.h>
|
|
|
|
#include <geometry/shape_line_chain.h>
|
|
|
|
#include <gr_text.h>
|
|
|
|
#include <lib_arc.h>
|
|
|
|
#include <lib_bezier.h>
|
|
|
|
#include <lib_circle.h>
|
|
|
|
#include <lib_edit_frame.h>
|
|
|
|
#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_polyline.h>
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <lib_rectangle.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <lib_text.h>
|
2020-01-04 23:05:57 +00:00
|
|
|
#include <math/util.h>
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <plotter.h>
|
|
|
|
#include <sch_bitmap.h>
|
|
|
|
#include <sch_bus_entry.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <sch_component.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>
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <sch_text.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/color_settings.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <template_fieldnames.h>
|
2018-10-21 12:50:31 +00:00
|
|
|
#include <view/view.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
|
|
|
|
#include "sch_painter.h"
|
|
|
|
|
2018-09-05 22:17:22 +00:00
|
|
|
namespace KIGFX
|
|
|
|
{
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-09-02 20:19:22 +00:00
|
|
|
SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() :
|
2019-11-06 19:15:42 +00:00
|
|
|
m_ShowUnit( 0 ),
|
|
|
|
m_ShowConvert( 0 )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2019-01-03 16:49:25 +00:00
|
|
|
m_ShowHiddenText = true;
|
|
|
|
m_ShowHiddenPins = true;
|
|
|
|
m_ShowPinsElectricalType = true;
|
|
|
|
m_ShowUmbilicals = true;
|
2019-11-06 19:15:42 +00:00
|
|
|
m_ShowDisabled = false;
|
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 );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-09-09 20:14:00 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
const COLOR4D& SCH_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
|
|
|
|
{
|
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
|
|
|
|
2018-08-30 19:44:10 +00:00
|
|
|
/**
|
|
|
|
* Used when a LIB_PART is not found in library to draw a dummy shape.
|
|
|
|
* This component 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
|
|
|
*/
|
|
|
|
static LIB_PART* dummy()
|
|
|
|
{
|
|
|
|
static LIB_PART* part;
|
|
|
|
|
|
|
|
if( !part )
|
|
|
|
{
|
|
|
|
part = new LIB_PART( wxEmptyString );
|
|
|
|
|
|
|
|
LIB_RECTANGLE* square = new LIB_RECTANGLE( part );
|
|
|
|
|
2019-12-30 18:28:00 +00:00
|
|
|
square->MoveTo( wxPoint( Mils2iu( -200 ), Mils2iu( 200 ) ) );
|
|
|
|
square->SetEndPosition( wxPoint( Mils2iu( 200 ), Mils2iu( -200 ) ) );
|
2018-08-30 19:44:10 +00:00
|
|
|
|
|
|
|
LIB_TEXT* text = new LIB_TEXT( part );
|
|
|
|
|
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( "??" ) ) );
|
|
|
|
|
|
|
|
part->AddDrawItem( square );
|
|
|
|
part->AddDrawItem( text );
|
|
|
|
}
|
|
|
|
|
|
|
|
return part;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
SCH_PAINTER::SCH_PAINTER( GAL* aGal ) :
|
2019-11-06 19:15:42 +00:00
|
|
|
KIGFX::PAINTER( aGal )
|
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 )
|
|
|
|
{
|
2019-11-06 19:15:42 +00:00
|
|
|
auto item2 = static_cast<const EDA_ITEM*>( aItem );
|
2018-09-09 20:14:00 +00:00
|
|
|
auto item = const_cast<EDA_ITEM*>( item2 );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
#ifdef CONNECTIVITY_DEBUG
|
|
|
|
|
|
|
|
auto sch_item = dynamic_cast<SCH_ITEM*>( item );
|
|
|
|
auto conn = sch_item ? sch_item->Connection( *g_CurrentSheet ) : nullptr;
|
|
|
|
|
|
|
|
if( conn )
|
|
|
|
{
|
|
|
|
auto pos = item->GetBoundingBox().Centre();
|
|
|
|
auto label = conn->Name( true );
|
|
|
|
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
|
|
|
|
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 ) ) );
|
2019-03-11 21:32:05 +00:00
|
|
|
m_gal->StrokeText( conn->Name( true ), pos, 0.0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
HANDLE_ITEM( LIB_PART_T, LIB_PART );
|
|
|
|
HANDLE_ITEM( LIB_RECTANGLE_T, LIB_RECTANGLE );
|
|
|
|
HANDLE_ITEM( LIB_POLYLINE_T, LIB_POLYLINE );
|
|
|
|
HANDLE_ITEM( LIB_CIRCLE_T, LIB_CIRCLE );
|
|
|
|
HANDLE_ITEM( LIB_PIN_T, LIB_PIN );
|
|
|
|
HANDLE_ITEM( LIB_ARC_T, LIB_ARC );
|
|
|
|
HANDLE_ITEM( LIB_FIELD_T, LIB_FIELD );
|
|
|
|
HANDLE_ITEM( LIB_TEXT_T, LIB_TEXT );
|
|
|
|
HANDLE_ITEM( LIB_BEZIER_T, LIB_BEZIER );
|
|
|
|
HANDLE_ITEM( SCH_COMPONENT_T, SCH_COMPONENT );
|
|
|
|
HANDLE_ITEM( SCH_JUNCTION_T, SCH_JUNCTION );
|
|
|
|
HANDLE_ITEM( SCH_LINE_T, SCH_LINE );
|
|
|
|
HANDLE_ITEM( SCH_TEXT_T, SCH_TEXT );
|
|
|
|
HANDLE_ITEM( SCH_LABEL_T, SCH_TEXT );
|
|
|
|
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
|
|
|
|
2018-09-02 20:19:22 +00:00
|
|
|
bool SCH_PAINTER::isUnitAndConversionShown( const LIB_ITEM* aItem )
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
float SCH_PAINTER::getShadowWidth()
|
|
|
|
{
|
|
|
|
const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
|
|
|
|
|
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.
|
2020-03-08 02:18:45 +00:00
|
|
|
return static_cast<float>( fabs( matrix.GetScale().x * 2.75 ) + GetSelectionThickness() );
|
2019-07-30 01:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows )
|
2019-04-19 15:54:29 +00:00
|
|
|
{
|
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
|
|
|
{
|
|
|
|
COLOR4D lineColor = static_cast<const SCH_LINE*>( aItem )->GetLineColor();
|
|
|
|
|
|
|
|
if( lineColor != COLOR4D::UNSPECIFIED )
|
|
|
|
color = lineColor;
|
|
|
|
}
|
2020-03-08 02:18:45 +00:00
|
|
|
else if( aItem->Type() == SCH_SHEET_T )
|
|
|
|
{
|
|
|
|
SCH_SHEET* sheet = (SCH_SHEET*) aItem;
|
|
|
|
COLOR4D sheetColor = COLOR4D::UNSPECIFIED;
|
|
|
|
|
|
|
|
if( aLayer == LAYER_SHEET )
|
|
|
|
sheetColor = sheet->GetBorderColor();
|
|
|
|
else if( aLayer == LAYER_SHEET_BACKGROUND )
|
|
|
|
sheetColor = sheet->GetBackgroundColor();
|
|
|
|
|
|
|
|
if( sheetColor != COLOR4D::UNSPECIFIED )
|
|
|
|
color = sheetColor;
|
|
|
|
}
|
2019-04-19 15:54:29 +00:00
|
|
|
|
2019-08-05 06:47:38 +00:00
|
|
|
if( aItem->IsBrightened() && !aDrawingShadows ) // Selection disambiguation, etc.
|
2019-06-29 18:45:32 +00:00
|
|
|
{
|
|
|
|
color = m_schSettings.GetLayerColor( LAYER_BRIGHTENED );
|
2019-08-05 06:47:38 +00:00
|
|
|
|
|
|
|
if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_SHEET_BACKGROUND )
|
|
|
|
color = color.WithAlpha( 0.2 );
|
2019-06-29 18:45:32 +00:00
|
|
|
}
|
2019-07-30 01:57:41 +00:00
|
|
|
else if( aItem->IsSelected() )
|
2019-04-19 15:54:29 +00:00
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
if( aDrawingShadows )
|
2019-08-27 04:43:59 +00:00
|
|
|
color = m_schSettings.GetLayerColor( LAYER_SELECTION_SHADOWS ).WithAlpha( 0.8 );
|
2019-04-19 15:54:29 +00:00
|
|
|
}
|
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
if( m_schSettings.m_ShowDisabled )
|
|
|
|
color = color.Darken( 0.5f );
|
|
|
|
|
2019-04-19 15:54:29 +00:00
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
float SCH_PAINTER::getLineWidth( const LIB_ITEM* aItem, bool aDrawingShadows )
|
|
|
|
{
|
|
|
|
float width = (float) aItem->GetPenSize();
|
|
|
|
|
|
|
|
if( aItem->IsSelected() && aDrawingShadows )
|
|
|
|
width += getShadowWidth();
|
|
|
|
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float SCH_PAINTER::getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows )
|
|
|
|
{
|
|
|
|
float width = (float) aItem->GetPenSize();
|
|
|
|
|
|
|
|
if( aItem->IsSelected() && aDrawingShadows )
|
|
|
|
width += getShadowWidth();
|
|
|
|
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float SCH_PAINTER::getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows )
|
|
|
|
{
|
|
|
|
float width = (float) aItem->GetThickness();
|
|
|
|
|
|
|
|
if( width == 0 )
|
|
|
|
width = (float) GetDefaultLineThickness();
|
|
|
|
|
|
|
|
if( aItem->IsSelected() && aDrawingShadows )
|
|
|
|
width += getShadowWidth();
|
|
|
|
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-21 18:03:54 +00:00
|
|
|
void SCH_PAINTER::strokeText( const wxString& aText, const VECTOR2D& aPosition, double aAngle )
|
|
|
|
{
|
|
|
|
m_gal->StrokeText( aText, aPosition, aAngle, GetTextMarkupFlags() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-19 15:54:29 +00:00
|
|
|
void SCH_PAINTER::draw( LIB_PART *aPart, 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;
|
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
std::unique_ptr< LIB_PART > tmpPart;
|
|
|
|
LIB_PART* drawnPart = aPart;
|
|
|
|
|
|
|
|
if( aPart->IsAlias() )
|
|
|
|
{
|
|
|
|
tmpPart = aPart->Flatten();
|
|
|
|
drawnPart = tmpPart.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
for( auto& item : drawnPart->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
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
static VECTOR2D mapCoords( const wxPoint& aCoord )
|
|
|
|
{
|
|
|
|
return VECTOR2D( aCoord.x, -aCoord.y );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-09 20:14:00 +00:00
|
|
|
void SCH_PAINTER::triLine( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2018-09-09 20:14:00 +00:00
|
|
|
m_gal->DrawLine( a, b );
|
|
|
|
m_gal->DrawLine( b, c );
|
2018-08-03 12:18:26 +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
|
|
|
{
|
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:
|
|
|
|
if( aItem->IsSelected() )
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
case LAYER_DEVICE_BACKGROUND:
|
|
|
|
if( aItem->GetFillMode() == FILLED_WITH_BG_BODYCOLOR )
|
|
|
|
{
|
|
|
|
COLOR4D fillColor = getRenderColor( aItem, LAYER_DEVICE_BACKGROUND, false );
|
2018-10-15 18:35:10 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
// These actions place the item over others, so allow a modest transparency here
|
|
|
|
if( aItem->IsMoving() || aItem->IsDragging() || aItem->IsResized() )
|
|
|
|
fillColor = fillColor.WithAlpha( 0.75 );
|
2019-03-11 13:08:05 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetIsFill( aItem->GetFillMode() == FILLED_WITH_BG_BODYCOLOR );
|
|
|
|
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;
|
|
|
|
|
|
|
|
case LAYER_DEVICE:
|
|
|
|
m_gal->SetIsFill( aItem->GetFillMode() == FILLED_SHAPE );
|
|
|
|
m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, false ) );
|
|
|
|
m_gal->SetIsStroke( aItem->GetPenSize() > 0 );
|
|
|
|
m_gal->SetLineWidth( getLineWidth( aItem, false ) );
|
|
|
|
m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, 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
|
|
|
|
|
|
|
|
2019-11-21 15:48:44 +00:00
|
|
|
void SCH_PAINTER::fillIfSelection( int aLayer )
|
|
|
|
{
|
|
|
|
if( aLayer == LAYER_SELECTION_SHADOWS && GetSelectionFillShapes() )
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-15 18:35:10 +00:00
|
|
|
void SCH_PAINTER::draw( LIB_RECTANGLE *aRect, int aLayer )
|
|
|
|
{
|
|
|
|
if( !isUnitAndConversionShown( aRect ) )
|
|
|
|
return;
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
if( setDeviceColors( aRect, aLayer ) )
|
2019-11-21 15:48:44 +00:00
|
|
|
{
|
|
|
|
fillIfSelection( aLayer );
|
2018-10-15 18:35:10 +00:00
|
|
|
m_gal->DrawRectangle( mapCoords( aRect->GetPosition() ), mapCoords( aRect->GetEnd() ) );
|
2019-11-21 15:48:44 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-09-05 16:21:51 +00:00
|
|
|
|
2018-09-02 20:19:22 +00:00
|
|
|
void SCH_PAINTER::draw( LIB_CIRCLE *aCircle, int aLayer )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2018-09-02 20:19:22 +00:00
|
|
|
if( !isUnitAndConversionShown( aCircle ) )
|
|
|
|
return;
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
if( setDeviceColors( aCircle, aLayer ) )
|
2019-11-21 15:48:44 +00:00
|
|
|
{
|
|
|
|
fillIfSelection( aLayer );
|
2018-10-15 18:35:10 +00:00
|
|
|
m_gal->DrawCircle( mapCoords( aCircle->GetPosition() ), aCircle->GetRadius() );
|
2019-11-21 15:48:44 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-09-19 20:52:13 +00:00
|
|
|
|
2018-09-02 20:19:22 +00:00
|
|
|
void SCH_PAINTER::draw( LIB_ARC *aArc, int aLayer )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2018-09-02 20:19:22 +00:00
|
|
|
if( !isUnitAndConversionShown( aArc ) )
|
|
|
|
return;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
if( setDeviceColors( aArc, aLayer ) )
|
|
|
|
{
|
|
|
|
int sai = aArc->GetFirstRadiusAngle();
|
|
|
|
int eai = aArc->GetSecondRadiusAngle();
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2019-08-01 18:41:03 +00:00
|
|
|
/**
|
|
|
|
* This accounts for an oddity in the old library format, where the symbol
|
|
|
|
* is overdefined. The previous draw (based on wxwidgets) used start point and end
|
|
|
|
* point and always drew counter-clockwise. The new GAL draw takes center, radius and
|
|
|
|
* start/end angles. All of these points were stored in the file, so we need to mimic the
|
|
|
|
* swapping of start/end points rather than using the stored angles in order to properly map
|
|
|
|
* edge cases.
|
|
|
|
*
|
|
|
|
* todo(v6): Remove this hack when we update the file format and do translation on loading.
|
|
|
|
*/
|
|
|
|
if( !TRANSFORM().MapAngles( &sai, &eai ) )
|
|
|
|
{
|
|
|
|
LIB_ARC new_arc( *aArc );
|
|
|
|
|
|
|
|
new_arc.SetStart( aArc->GetEnd() );
|
|
|
|
new_arc.SetEnd( aArc->GetStart() );
|
|
|
|
new_arc.CalcRadiusAngles();
|
|
|
|
sai = new_arc.GetFirstRadiusAngle();
|
|
|
|
eai = new_arc.GetSecondRadiusAngle();
|
|
|
|
TRANSFORM().MapAngles( &sai, &eai );
|
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
double sa = (double) sai * M_PI / 1800.0;
|
|
|
|
double ea = (double) eai * M_PI / 1800.0 ;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
VECTOR2D pos = mapCoords( aArc->GetPosition() );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-10-15 18:35:10 +00:00
|
|
|
m_gal->DrawArc( pos, aArc->GetRadius(), sa, ea );
|
2019-07-30 01:57:41 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-15 18:35:10 +00:00
|
|
|
void SCH_PAINTER::draw( LIB_POLYLINE *aLine, int aLayer )
|
|
|
|
{
|
|
|
|
if( !isUnitAndConversionShown( aLine ) )
|
|
|
|
return;
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
if( setDeviceColors( aLine, aLayer ) )
|
|
|
|
{
|
|
|
|
const std::vector<wxPoint>& pts = aLine->GetPolyPoints();
|
|
|
|
std::deque<VECTOR2D> vtx;
|
2018-10-15 18:35:10 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
for( auto p : pts )
|
|
|
|
vtx.push_back( mapCoords( p ) );
|
2018-10-15 18:35:10 +00:00
|
|
|
|
2019-11-21 15:48:44 +00:00
|
|
|
fillIfSelection( aLayer );
|
2018-10-15 18:35:10 +00:00
|
|
|
m_gal->DrawPolygon( vtx );
|
2019-07-30 01:57:41 +00:00
|
|
|
}
|
2018-10-15 18:35:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-31 17:19:09 +00:00
|
|
|
void SCH_PAINTER::draw( 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;
|
|
|
|
|
|
|
|
if( drawingShadows && !aField->IsSelected() )
|
|
|
|
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
|
|
|
|
2018-08-31 17:19:09 +00:00
|
|
|
if( !aField->IsVisible() )
|
|
|
|
{
|
2019-10-31 16:24:23 +00:00
|
|
|
if( m_schSettings.m_ShowHiddenText || aField->IsBrightened() )
|
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
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetLineWidth( getLineWidth( aField, drawingShadows ) );
|
2018-08-03 12:18:26 +00:00
|
|
|
m_gal->SetIsFill( false );
|
2018-09-01 23:29:19 +00:00
|
|
|
m_gal->SetIsStroke( true );
|
2018-08-03 12:18:26 +00:00
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
|
|
|
|
auto pos = mapCoords( aField->GetPosition() );
|
|
|
|
|
2019-11-21 15:48:44 +00:00
|
|
|
if( drawingShadows && GetSelectionTextAsBox() )
|
|
|
|
{
|
|
|
|
EDA_RECT boundaryBox = aField->GetBoundingBox();
|
|
|
|
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetFillColor( color );
|
|
|
|
m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
|
|
|
|
boundaryBox.RevertYAxis();
|
|
|
|
|
|
|
|
m_gal->DrawRectangle(
|
|
|
|
mapCoords( boundaryBox.GetPosition() ), mapCoords( boundaryBox.GetEnd() ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
|
|
|
|
m_gal->SetFontItalic( aField->IsItalic() );
|
|
|
|
|
|
|
|
m_gal->SetHorizontalJustify( aField->GetHorizJustify() );
|
|
|
|
m_gal->SetVerticalJustify( aField->GetVertJustify() );
|
|
|
|
|
|
|
|
double orient = aField->GetTextAngleRadians();
|
|
|
|
|
|
|
|
strokeText( aField->GetText(), pos, orient );
|
|
|
|
}
|
2018-10-21 21:54:02 +00:00
|
|
|
|
|
|
|
// Draw the umbilical line
|
2018-11-14 23:34:32 +00:00
|
|
|
if( aField->IsMoving() && m_schSettings.m_ShowUmbilicals )
|
2018-10-21 21:54:02 +00:00
|
|
|
{
|
|
|
|
m_gal->SetLineWidth( m_schSettings.m_outlineWidth );
|
|
|
|
m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
|
|
|
|
m_gal->DrawLine( pos, wxPoint( 0, 0 ) );
|
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-31 17:19:09 +00:00
|
|
|
void SCH_PAINTER::draw( 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;
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
|
|
|
|
|
|
|
if( drawingShadows && !aText->IsSelected() )
|
|
|
|
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() )
|
|
|
|
{
|
2019-10-31 16:24:23 +00:00
|
|
|
if( m_schSettings.m_ShowHiddenText || aText->IsBrightened() )
|
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();
|
|
|
|
bBox.RevertYAxis();
|
|
|
|
VECTOR2D pos = mapCoords( bBox.Centre() );
|
|
|
|
double orient = aText->GetTextAngleRadians();
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-09-01 23:29:19 +00:00
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetLineWidth( getLineWidth( aText, drawingShadows ) );
|
2018-08-03 12:18:26 +00:00
|
|
|
m_gal->SetIsFill( false );
|
2018-08-31 17:19:09 +00:00
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetStrokeColor( color );
|
2018-09-01 23:29:19 +00:00
|
|
|
m_gal->SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
|
2018-08-31 17:19:09 +00:00
|
|
|
m_gal->SetFontBold( aText->IsBold() );
|
|
|
|
m_gal->SetFontItalic( aText->IsItalic() );
|
2019-10-21 18:03:54 +00:00
|
|
|
strokeText( aText->GetText(), pos, orient );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int InternalPinDecoSize( const LIB_PIN &aPin )
|
|
|
|
{
|
|
|
|
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
|
2018-08-03 12:18:26 +00:00
|
|
|
static int ExternalPinDecoSize( const LIB_PIN &aPin )
|
|
|
|
{
|
|
|
|
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.
|
|
|
|
void SCH_PAINTER::drawPinDanglingSymbol( const VECTOR2I& aPos, bool aDrawingShadows )
|
2018-09-09 20:14:00 +00:00
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth() : 1.0F );
|
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;
|
|
|
|
|
|
|
|
if( drawingShadows && !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() )
|
|
|
|
{
|
2018-09-09 20:14:00 +00:00
|
|
|
if( m_schSettings.m_ShowHiddenPins )
|
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
|
2018-09-09 20:14:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-08-27 12:12:34 +00:00
|
|
|
if( aPin->HasFlag( IS_DANGLING ) && aPin->IsPowerConnection() )
|
2019-07-30 01:57:41 +00:00
|
|
|
drawPinDanglingSymbol( pos, drawingShadows );
|
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
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
VECTOR2I p0;
|
|
|
|
VECTOR2I dir;
|
2019-11-06 19:15:42 +00:00
|
|
|
int len = aPin->GetLength();
|
2018-08-03 12:18:26 +00:00
|
|
|
int orient = aPin->GetOrientation();
|
|
|
|
|
2018-08-29 18:31:43 +00:00
|
|
|
switch( orient )
|
2019-11-06 19:15:42 +00:00
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
case PIN_UP:
|
|
|
|
p0 = VECTOR2I( pos.x, pos.y - len );
|
2019-12-12 19:55:21 +00:00
|
|
|
dir = VECTOR2I( 0, 1 );
|
2019-07-30 01:57:41 +00:00
|
|
|
break;
|
2019-10-06 10:59:18 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
case PIN_DOWN:
|
|
|
|
p0 = VECTOR2I( pos.x, pos.y + len );
|
2019-12-12 19:55:21 +00:00
|
|
|
dir = VECTOR2I( 0, -1 );
|
2019-07-30 01:57:41 +00:00
|
|
|
break;
|
2019-10-06 10:59:18 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
case PIN_LEFT:
|
|
|
|
p0 = VECTOR2I( pos.x - len, pos.y );
|
2019-12-12 19:55:21 +00:00
|
|
|
dir = VECTOR2I( 1, 0 );
|
2019-07-30 01:57:41 +00:00
|
|
|
break;
|
2019-10-06 10:59:18 +00:00
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
default:
|
2019-07-30 01:57:41 +00:00
|
|
|
case PIN_RIGHT:
|
|
|
|
p0 = VECTOR2I( pos.x + len, pos.y );
|
2019-12-12 19:55:21 +00:00
|
|
|
dir = VECTOR2I( -1, 0 );
|
2019-07-30 01:57:41 +00:00
|
|
|
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 );
|
|
|
|
m_gal->SetFontItalic( false );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-08-29 18:31:43 +00:00
|
|
|
const int radius = ExternalPinDecoSize( *aPin );
|
2018-10-14 10:36:02 +00:00
|
|
|
const int diam = radius*2;
|
2018-08-29 18:31:43 +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 );
|
2019-03-17 19:50:18 +00:00
|
|
|
|
2019-04-19 15:54:29 +00:00
|
|
|
aPin->ClearFlags( IS_DANGLING ); // PIN_NC pin type is always not connected and dangling.
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2019-08-27 12:12:34 +00:00
|
|
|
if( aPin->HasFlag( IS_DANGLING ) && ( aPin->IsVisible() || aPin->IsPowerConnection() ) )
|
2019-07-30 01:57:41 +00:00
|
|
|
drawPinDanglingSymbol( pos, drawingShadows );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2019-11-21 15:48:44 +00:00
|
|
|
LIB_PART* libEntry = aPin->GetParent();
|
|
|
|
|
2018-09-19 20:52:13 +00:00
|
|
|
// Draw the labels
|
2019-11-21 15:48:44 +00:00
|
|
|
if( drawingShadows && ( libEntry->Type() == LIB_PART_T || libEntry->IsSelected() )
|
|
|
|
&& !GetSelectionDrawChildItems() )
|
|
|
|
return;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
|
|
|
int textOffset = libEntry->GetPinNameOffset();
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
float nameLineWidth = getLineWidth( aPin, drawingShadows );
|
2018-08-03 12:18:26 +00:00
|
|
|
nameLineWidth = Clamp_Text_PenSize( nameLineWidth, aPin->GetNameTextSize(), false );
|
2019-07-30 01:57:41 +00:00
|
|
|
float numLineWidth = getLineWidth( aPin, drawingShadows );
|
2018-08-03 12:18:26 +00:00
|
|
|
numLineWidth = Clamp_Text_PenSize( numLineWidth, aPin->GetNumberTextSize(), false );
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
#define PIN_TEXT_MARGIN 4.0
|
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 };
|
2019-07-30 01:57:41 +00:00
|
|
|
float thickness[4] = { numLineWidth, numLineWidth, numLineWidth, numLineWidth };
|
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;
|
|
|
|
thickness[INSIDE] = nameLineWidth;
|
2019-07-30 01:57:41 +00:00
|
|
|
colour [INSIDE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
|
2018-08-30 01:38:08 +00:00
|
|
|
text [INSIDE] = aPin->GetName();
|
|
|
|
|
|
|
|
size [ABOVE] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
|
|
|
|
thickness[ABOVE] = numLineWidth;
|
2019-07-30 01:57:41 +00:00
|
|
|
colour [ABOVE] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
|
2018-08-30 01:38:08 +00:00
|
|
|
text [ABOVE] = aPin->GetNumber();
|
|
|
|
}
|
|
|
|
// Otherwise pin NAMES go above and pin NUMBERS go below
|
|
|
|
else
|
|
|
|
{
|
|
|
|
size [ABOVE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
|
|
|
|
thickness[ABOVE] = nameLineWidth;
|
2019-07-30 01:57:41 +00:00
|
|
|
colour [ABOVE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
|
2018-08-30 01:38:08 +00:00
|
|
|
text [ABOVE] = aPin->GetName();
|
|
|
|
|
|
|
|
size [BELOW] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
|
|
|
|
thickness[BELOW] = numLineWidth;
|
2019-07-30 01:57:41 +00:00
|
|
|
colour [BELOW] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
|
2018-08-30 01:38:08 +00:00
|
|
|
text [BELOW] = aPin->GetNumber();
|
|
|
|
}
|
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 ) );
|
2019-07-30 01:57:41 +00:00
|
|
|
thickness[OUTSIDE] = float( size[OUTSIDE] ) / 6.0F;
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
int insideOffset = textOffset;
|
|
|
|
int outsideOffset = 10;
|
|
|
|
float lineThickness = (float) GetDefaultLineThickness();
|
2019-12-30 18:28:00 +00:00
|
|
|
float aboveOffset = Mils2iu( PIN_TEXT_MARGIN ) + ( thickness[ABOVE] + lineThickness ) / 2.0;
|
|
|
|
float belowOffset = Mils2iu( PIN_TEXT_MARGIN ) + ( thickness[BELOW] + lineThickness ) / 2.0;
|
2019-07-30 01:57:41 +00:00
|
|
|
|
|
|
|
if( drawingShadows )
|
|
|
|
{
|
|
|
|
for( float& t : thickness )
|
|
|
|
t += getShadowWidth();
|
2019-08-03 23:03:35 +00:00
|
|
|
|
|
|
|
insideOffset -= KiROUND( getShadowWidth() / 2 );
|
|
|
|
outsideOffset -= KiROUND( getShadowWidth() / 2 );
|
2019-07-30 01:57:41 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-08-30 01:38:08 +00:00
|
|
|
#define SET_DC( i ) \
|
|
|
|
m_gal->SetGlyphSize( VECTOR2D( size[i], size[i] ) ); \
|
|
|
|
m_gal->SetLineWidth( thickness[i] ); \
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetStrokeColor( colour[i] )
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-08-30 01:38:08 +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] )
|
|
|
|
{
|
|
|
|
SET_DC( INSIDE );
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
|
2019-10-21 18:03:54 +00:00
|
|
|
strokeText( text[INSIDE], pos + VECTOR2D( -insideOffset - len, 0 ), 0 );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[OUTSIDE] )
|
|
|
|
{
|
|
|
|
SET_DC( OUTSIDE );
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
|
2019-10-21 18:03:54 +00:00
|
|
|
strokeText( text[OUTSIDE], pos + VECTOR2D( outsideOffset, 0 ), 0 );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[ABOVE] )
|
|
|
|
{
|
|
|
|
SET_DC( ABOVE );
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
2019-10-21 18:03:54 +00:00
|
|
|
strokeText( text[ABOVE], pos + VECTOR2D( -len / 2.0, -aboveOffset ), 0 );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[BELOW] )
|
|
|
|
{
|
|
|
|
SET_DC( BELOW );
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_TOP );
|
2019-10-21 18:03:54 +00:00
|
|
|
strokeText( text[BELOW], pos + VECTOR2D( -len / 2.0, belowOffset ), 0 );
|
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] )
|
|
|
|
{
|
|
|
|
SET_DC( INSIDE );
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
|
2019-10-21 18:03:54 +00:00
|
|
|
strokeText( text[INSIDE], pos + VECTOR2D( insideOffset + len, 0 ), 0 );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[OUTSIDE] )
|
|
|
|
{
|
|
|
|
SET_DC( OUTSIDE );
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
|
2019-10-21 18:03:54 +00:00
|
|
|
strokeText( text[OUTSIDE], pos + VECTOR2D( -outsideOffset, 0 ), 0 );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[ABOVE] )
|
|
|
|
{
|
|
|
|
SET_DC( ABOVE );
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
2019-10-21 18:03:54 +00:00
|
|
|
strokeText( text[ABOVE], pos + VECTOR2D( len / 2.0, -aboveOffset ), 0 );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[BELOW] )
|
|
|
|
{
|
|
|
|
SET_DC( BELOW );
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_TOP );
|
2019-10-21 18:03:54 +00:00
|
|
|
strokeText( text[BELOW], pos + VECTOR2D( len / 2.0, belowOffset ), 0 );
|
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
|
|
|
{
|
2018-08-30 01:38:08 +00:00
|
|
|
SET_DC( INSIDE );
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
|
2019-12-12 19:55:21 +00:00
|
|
|
strokeText( text[INSIDE], pos + VECTOR2D( 0, insideOffset + len ), M_PI / 2 );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
2018-08-30 01:38:08 +00:00
|
|
|
if( size[OUTSIDE] )
|
|
|
|
{
|
|
|
|
SET_DC( OUTSIDE );
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
|
2019-12-12 19:55:21 +00:00
|
|
|
strokeText( text[OUTSIDE], pos + VECTOR2D( 0, -outsideOffset ), M_PI / 2 );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[ABOVE] )
|
|
|
|
{
|
|
|
|
SET_DC( ABOVE );
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
2019-10-21 18:03:54 +00:00
|
|
|
strokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, len / 2.0 ), M_PI / 2 );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[BELOW] )
|
|
|
|
{
|
|
|
|
SET_DC( BELOW );
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_TOP );
|
2019-10-21 18:03:54 +00:00
|
|
|
strokeText( text[BELOW], pos + VECTOR2D( belowOffset, len / 2.0 ), M_PI / 2 );
|
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] )
|
|
|
|
{
|
|
|
|
SET_DC( INSIDE );
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
|
2019-12-12 19:55:21 +00:00
|
|
|
strokeText( text[INSIDE], pos + VECTOR2D( 0, -insideOffset - len ), M_PI / 2 );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[OUTSIDE] )
|
|
|
|
{
|
|
|
|
SET_DC( OUTSIDE );
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
|
2019-12-12 19:55:21 +00:00
|
|
|
strokeText( text[OUTSIDE], pos + VECTOR2D( 0, outsideOffset ), M_PI / 2 );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[ABOVE] )
|
|
|
|
{
|
|
|
|
SET_DC( ABOVE );
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
2019-10-21 18:03:54 +00:00
|
|
|
strokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, -len / 2.0 ), M_PI / 2 );
|
2018-08-30 01:38:08 +00:00
|
|
|
}
|
|
|
|
if( size[BELOW] )
|
|
|
|
{
|
|
|
|
SET_DC( BELOW );
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_TOP );
|
2019-10-21 18:03:54 +00:00
|
|
|
strokeText( text[BELOW], pos + VECTOR2D( belowOffset, -len / 2.0 ), M_PI / 2 );
|
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
|
|
|
|
2019-02-19 09:41:21 +00:00
|
|
|
void SCH_PAINTER::draw( LIB_BEZIER *aCurve, int aLayer )
|
|
|
|
{
|
|
|
|
if( !isUnitAndConversionShown( aCurve ) )
|
|
|
|
return;
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
if( setDeviceColors( aCurve, aLayer ) )
|
2019-02-19 09:41:21 +00:00
|
|
|
{
|
|
|
|
BEZIER_POLY poly ( aCurve->GetPoints() );
|
|
|
|
std::vector<wxPoint> pts;
|
|
|
|
std::deque<VECTOR2D> pts_xformed;
|
|
|
|
poly.GetPoly( pts );
|
|
|
|
|
|
|
|
for( const auto &p : pts )
|
|
|
|
pts_xformed.push_back( mapCoords( p ) );
|
|
|
|
|
|
|
|
m_gal->DrawPolygon( pts_xformed );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
|
2019-07-30 01:57:41 +00:00
|
|
|
void SCH_PAINTER::drawDanglingSymbol( const wxPoint& aPos, bool aDrawingShadows )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2019-12-30 18:28:00 +00:00
|
|
|
wxPoint radius( Mils2iu( DANGLING_SYMBOL_SIZE ), Mils2iu( DANGLING_SYMBOL_SIZE ) );
|
2018-09-09 20:14:00 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetIsFill( false );
|
2019-12-12 19:55:21 +00:00
|
|
|
m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth() : 1.0F );
|
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
|
|
|
|
2018-08-30 22:43:42 +00:00
|
|
|
void SCH_PAINTER::draw( SCH_JUNCTION *aJct, int aLayer )
|
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
|
|
|
|
|
|
|
if( drawingShadows && !aJct->IsSelected() )
|
|
|
|
return;
|
|
|
|
|
2019-04-19 15:54:29 +00:00
|
|
|
COLOR4D color;
|
2019-03-11 21:32:05 +00:00
|
|
|
auto conn = aJct->Connection( *g_CurrentSheet );
|
|
|
|
|
|
|
|
if( conn && conn->IsBus() )
|
2019-07-30 01:57:41 +00:00
|
|
|
color = getRenderColor( aJct, LAYER_BUS, drawingShadows );
|
2018-12-24 11:17:35 +00:00
|
|
|
else
|
2019-07-30 01:57:41 +00:00
|
|
|
color = getRenderColor( aJct, LAYER_JUNCTION, drawingShadows );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetIsStroke( drawingShadows );
|
|
|
|
m_gal->SetLineWidth( getLineWidth( aJct, drawingShadows ) );
|
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
m_gal->SetIsFill( !drawingShadows );
|
2018-08-03 12:18:26 +00:00
|
|
|
m_gal->SetFillColor( color );
|
2018-09-19 20:52:13 +00:00
|
|
|
m_gal->DrawCircle( aJct->GetPosition(), SCH_JUNCTION::GetEffectiveSymbolSize() / 2.0 );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-08-30 22:43:42 +00:00
|
|
|
|
|
|
|
void SCH_PAINTER::draw( 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;
|
|
|
|
|
|
|
|
if( drawingShadows && !aLine->IsSelected() )
|
|
|
|
return;
|
2018-09-05 22:17:22 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
COLOR4D color = getRenderColor( aLine, aLine->GetLayer(), drawingShadows );
|
|
|
|
float width = getLineWidth( aLine, drawingShadows );
|
2018-08-03 12:18:26 +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
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
if( aLine->GetLineStyle() <= PLOT_DASH_TYPE::FIRST_TYPE || drawingShadows )
|
2018-09-07 21:33:01 +00:00
|
|
|
{
|
|
|
|
m_gal->DrawLine( aLine->GetStartPoint(), aLine->GetEndPoint() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
VECTOR2D start = aLine->GetStartPoint();
|
|
|
|
VECTOR2D end = aLine->GetEndPoint();
|
|
|
|
|
2019-04-22 10:14:47 +00:00
|
|
|
EDA_RECT clip( (wxPoint)start, wxSize( end.x - start.x, end.y - start.y ) );
|
2018-09-07 21:33:01 +00:00
|
|
|
clip.Normalize();
|
|
|
|
|
|
|
|
double theta = atan2( end.y - start.y, end.x - start.x );
|
|
|
|
double strokes[] = { 1.0, DASH_GAP_LEN( width ), 1.0, DASH_GAP_LEN( width ) };
|
|
|
|
|
|
|
|
switch( aLine->GetLineStyle() )
|
|
|
|
{
|
2018-09-19 20:52:13 +00:00
|
|
|
default:
|
2019-12-28 00:55:11 +00:00
|
|
|
case PLOT_DASH_TYPE::DASH:
|
2018-09-07 21:33:01 +00:00
|
|
|
strokes[0] = strokes[2] = DASH_MARK_LEN( width );
|
|
|
|
break;
|
2019-12-28 00:55:11 +00:00
|
|
|
case PLOT_DASH_TYPE::DOT:
|
2018-09-07 21:33:01 +00:00
|
|
|
strokes[0] = strokes[2] = DOT_MARK_LEN( width );
|
|
|
|
break;
|
2019-12-28 00:55:11 +00:00
|
|
|
case PLOT_DASH_TYPE::DASHDOT:
|
2018-09-07 21:33:01 +00:00
|
|
|
strokes[0] = DASH_MARK_LEN( width );
|
|
|
|
strokes[2] = DOT_MARK_LEN( width );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-09-09 20:14:00 +00:00
|
|
|
for( size_t i = 0; i < 10000; ++i )
|
2018-09-07 21:33:01 +00:00
|
|
|
{
|
|
|
|
// Calculations MUST be done in doubles to keep from accumulating rounding
|
|
|
|
// errors as we go.
|
|
|
|
VECTOR2D next( start.x + strokes[ i % 4 ] * cos( theta ),
|
|
|
|
start.y + strokes[ i % 4 ] * sin( theta ) );
|
|
|
|
|
2018-09-09 20:14:00 +00:00
|
|
|
// Drawing each segment can be done rounded to ints.
|
2018-09-07 21:33:01 +00:00
|
|
|
wxPoint segStart( KiROUND( start.x ), KiROUND( start.y ) );
|
|
|
|
wxPoint segEnd( KiROUND( next.x ), KiROUND( next.y ) );
|
|
|
|
|
|
|
|
if( ClipLine( &clip, segStart.x, segStart.y, segEnd.x, segEnd.y ) )
|
|
|
|
break;
|
|
|
|
else if( i % 2 == 0 )
|
|
|
|
m_gal->DrawLine( segStart, segEnd );
|
|
|
|
|
|
|
|
start = next;
|
|
|
|
}
|
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-08-30 22:43:42 +00:00
|
|
|
if( aLine->IsStartDangling() )
|
2019-07-30 01:57:41 +00:00
|
|
|
drawDanglingSymbol( aLine->GetStartPoint(), drawingShadows );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-08-30 22:43:42 +00:00
|
|
|
if( aLine->IsEndDangling() )
|
2019-07-30 01:57:41 +00:00
|
|
|
drawDanglingSymbol( aLine->GetEndPoint(), drawingShadows );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-30 22:43:42 +00:00
|
|
|
void SCH_PAINTER::draw( SCH_TEXT *aText, int aLayer )
|
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
|
|
|
|
|
|
|
if( drawingShadows && !aText->IsSelected() )
|
|
|
|
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
|
|
|
{
|
2019-07-30 01:57:41 +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_LABEL_T: aLayer = LAYER_LOCLABEL; break;
|
|
|
|
default: aLayer = LAYER_NOTES; break;
|
2018-08-31 17:19:09 +00:00
|
|
|
}
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
COLOR4D color = getRenderColor( aText, aLayer, drawingShadows );
|
|
|
|
SCH_CONNECTION* conn = aText->Connection( *g_CurrentSheet );
|
|
|
|
|
2019-04-19 15:54:29 +00:00
|
|
|
if( conn && conn->IsBus() )
|
2019-07-30 01:57:41 +00:00
|
|
|
color = getRenderColor( aText, LAYER_BUS, drawingShadows );
|
2018-09-09 20:14:00 +00:00
|
|
|
|
2018-08-31 17:19:09 +00:00
|
|
|
if( !aText->IsVisible() )
|
|
|
|
{
|
2019-10-31 16:24:23 +00:00
|
|
|
if( m_schSettings.m_ShowHiddenText || aText->IsBrightened() )
|
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
|
|
|
}
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetLineWidth( getLineWidth( aText, drawingShadows ) );
|
2018-11-19 20:29:28 +00:00
|
|
|
m_gal->SetStrokeColor( color );
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetTextAttributes( aText );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2019-08-03 23:03:35 +00:00
|
|
|
VECTOR2D text_offset = aText->GetTextPos() + aText->GetSchematicTextOffset();
|
2018-08-30 22:43:42 +00:00
|
|
|
wxString shownText( aText->GetShownText() );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2019-08-03 23:03:35 +00:00
|
|
|
if( drawingShadows )
|
|
|
|
{
|
2019-11-21 15:48:44 +00:00
|
|
|
if( GetSelectionTextAsBox() )
|
|
|
|
{
|
|
|
|
EDA_RECT bBox = aText->GetBoundingBox();
|
|
|
|
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetFillColor( color );
|
|
|
|
m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
|
|
|
|
bBox.RevertYAxis();
|
|
|
|
|
|
|
|
m_gal->DrawRectangle( mapCoords( bBox.GetPosition() ), mapCoords( bBox.GetEnd() ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-08-03 23:03:35 +00:00
|
|
|
switch( aText->GetLabelSpinStyle() )
|
|
|
|
{
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::LEFT:
|
|
|
|
text_offset.x += getShadowWidth() / 2;
|
2019-08-03 23:03:35 +00:00
|
|
|
break;
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::UP:
|
2019-08-03 23:03:35 +00:00
|
|
|
text_offset.y += getShadowWidth() / 2;
|
|
|
|
break;
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::RIGHT:
|
|
|
|
text_offset.x -= getShadowWidth() / 2;
|
2019-08-03 23:03:35 +00:00
|
|
|
break;
|
2020-01-08 19:07:55 +00:00
|
|
|
case LABEL_SPIN_STYLE::BOTTOM:
|
2019-08-03 23:03:35 +00:00
|
|
|
text_offset.y -= getShadowWidth() / 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-30 22:43:42 +00:00
|
|
|
if( !shownText.IsEmpty() )
|
2019-10-21 18:03:54 +00:00
|
|
|
strokeText( shownText, text_offset, aText->GetTextAngleRadians() );
|
2019-07-30 01:57:41 +00:00
|
|
|
|
|
|
|
if( aText->IsDangling() )
|
|
|
|
drawDanglingSymbol( aText->GetTextPos(), drawingShadows );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-08-30 22:43:42 +00:00
|
|
|
|
2019-04-19 15:54:29 +00:00
|
|
|
static void orientPart( LIB_PART* part, 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
|
|
|
{
|
|
|
|
{ CMP_ORIENT_0, 0, 0, 0 },
|
|
|
|
{ CMP_ORIENT_90, 1, 0, 0 },
|
|
|
|
{ CMP_ORIENT_180, 2, 0, 0 },
|
|
|
|
{ CMP_ORIENT_270, 3, 0, 0 },
|
|
|
|
{ CMP_MIRROR_X + CMP_ORIENT_0, 0, 1, 0 },
|
|
|
|
{ CMP_MIRROR_X + CMP_ORIENT_90, 1, 1, 0 },
|
|
|
|
{ CMP_MIRROR_Y, 0, 0, 1 },
|
2018-09-01 23:29:19 +00:00
|
|
|
{ CMP_MIRROR_X + CMP_ORIENT_270, 3, 1, 0 },
|
|
|
|
{ CMP_MIRROR_Y + CMP_ORIENT_0, 0, 0, 1 },
|
|
|
|
{ CMP_MIRROR_Y + CMP_ORIENT_90, 1, 0, 1 },
|
|
|
|
{ CMP_MIRROR_Y + CMP_ORIENT_180, 2, 0, 1 },
|
|
|
|
{ CMP_MIRROR_Y + CMP_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
|
|
|
}
|
|
|
|
|
2018-09-01 23:29:19 +00:00
|
|
|
for( auto& item : part->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++ )
|
2018-08-03 12:18:26 +00:00
|
|
|
item.Rotate( wxPoint(0, 0 ), true );
|
|
|
|
|
2018-09-01 23:29:19 +00:00
|
|
|
if( o.mirror_x )
|
|
|
|
item.MirrorVertical( wxPoint( 0, 0 ) );
|
|
|
|
|
|
|
|
if( o.mirror_y )
|
|
|
|
item.MirrorHorizontal( wxPoint( 0, 0 ) );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-30 22:43:42 +00:00
|
|
|
|
2018-08-30 19:44:10 +00:00
|
|
|
void SCH_PAINTER::draw( SCH_COMPONENT *aComp, int aLayer )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2018-08-30 19:44:10 +00:00
|
|
|
// Use dummy part if the actual couldn't be found (or couldn't be locked).
|
2019-11-06 19:15:42 +00:00
|
|
|
LIB_PART* originalPart = aComp->GetPartRef() ? aComp->GetPartRef().get() : dummy();
|
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.
|
|
|
|
LIB_PART tempPart( *originalPart );
|
2019-04-03 09:14:36 +00:00
|
|
|
|
2019-04-19 15:54:29 +00:00
|
|
|
tempPart.SetFlags( aComp->GetFlags() );
|
2019-04-03 09:14:36 +00:00
|
|
|
|
2019-12-12 19:55:21 +00:00
|
|
|
orientPart( &tempPart, aComp->GetOrientation() );
|
2019-04-03 09:14:36 +00:00
|
|
|
|
2019-04-19 15:54:29 +00:00
|
|
|
for( auto& tempItem : tempPart.GetDrawItems() )
|
2019-04-23 17:40:29 +00:00
|
|
|
{
|
|
|
|
tempItem.SetFlags( aComp->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
|
2019-12-12 19:55:21 +00:00
|
|
|
tempItem.MoveTo( tempItem.GetPosition() + (wxPoint) mapCoords( aComp->GetPosition() ) );
|
2019-04-23 17:40:29 +00:00
|
|
|
}
|
2019-04-19 15:54:29 +00:00
|
|
|
|
2019-04-22 10:14:47 +00:00
|
|
|
// Copy the pin info from the component to the temp pins
|
|
|
|
LIB_PINS tempPins;
|
|
|
|
tempPart.GetPins( tempPins, aComp->GetUnit(), aComp->GetConvert() );
|
2020-01-17 02:33:16 +00:00
|
|
|
const SCH_PIN_PTRS compPins = aComp->GetSchPins();
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2019-04-23 01:18:47 +00:00
|
|
|
for( unsigned i = 0; i < tempPins.size() && i < compPins.size(); ++ i )
|
2019-04-19 15:54:29 +00:00
|
|
|
{
|
|
|
|
LIB_PIN* tempPin = tempPins[ i ];
|
2020-01-17 02:33:16 +00:00
|
|
|
const SCH_PIN* compPin = compPins[ i ];
|
2018-09-05 16:21:51 +00:00
|
|
|
|
2019-04-22 10:14:47 +00:00
|
|
|
tempPin->ClearFlags();
|
2020-01-17 02:33:16 +00:00
|
|
|
tempPin->SetFlags( compPin->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2020-01-17 02:33:16 +00:00
|
|
|
if( compPin->IsDangling() )
|
2019-04-22 10:14:47 +00:00
|
|
|
tempPin->SetFlags( IS_DANGLING );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2019-04-19 15:54:29 +00:00
|
|
|
draw( &tempPart, aLayer, false, aComp->GetUnit(), aComp->GetConvert() );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
// The fields are SCH_COMPONENT-specific so don't need to be copied/oriented/translated
|
2020-03-06 12:05:21 +00:00
|
|
|
for( SCH_FIELD* field : aComp->GetFields() )
|
2019-04-26 22:23:12 +00:00
|
|
|
draw( field, aLayer );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-09-01 23:29:19 +00:00
|
|
|
|
2018-08-31 17:19:09 +00:00
|
|
|
void SCH_PAINTER::draw( 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;
|
|
|
|
|
|
|
|
if( drawingShadows && !aField->IsSelected() )
|
|
|
|
return;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
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 );
|
|
|
|
|
2018-08-31 17:19:09 +00:00
|
|
|
if( !aField->IsVisible() )
|
|
|
|
{
|
2019-10-31 16:24:23 +00:00
|
|
|
if( m_schSettings.m_ShowHiddenText || aField->IsBrightened() )
|
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;
|
|
|
|
|
2020-03-06 12:05:21 +00:00
|
|
|
if( drawingShadows && aField->GetParent()->IsSelected() && !GetSelectionDrawChildItems() )
|
2019-11-21 15:48:44 +00:00
|
|
|
return;
|
|
|
|
|
2020-03-06 12:05:21 +00:00
|
|
|
// Calculate the text orientation according to the parent orientation.
|
|
|
|
int orient = (int) aField->GetTextAngle();
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2020-03-06 12:05:21 +00:00
|
|
|
if( aField->GetParent() && aField->GetParent()->Type() == SCH_COMPONENT_T )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2020-03-06 12:05:21 +00:00
|
|
|
if( static_cast<SCH_COMPONENT*>( aField->GetParent() )->GetTransform().y1 )
|
|
|
|
{
|
|
|
|
// Rotate component 90 degrees.
|
2018-08-03 12:18:26 +00:00
|
|
|
if( orient == TEXT_ANGLE_HORIZ )
|
|
|
|
orient = TEXT_ANGLE_VERT;
|
|
|
|
else
|
|
|
|
orient = TEXT_ANGLE_HORIZ;
|
2020-03-06 12:05:21 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
/* Calculate the text justification, according to the component 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.
|
|
|
|
* - When a component 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
|
|
|
*/
|
|
|
|
EDA_RECT boundaryBox = aField->GetBoundingBox();
|
2018-11-02 10:27:57 +00:00
|
|
|
wxPoint textpos = boundaryBox.Centre();
|
2018-08-03 12:18:26 +00:00
|
|
|
|
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
m_gal->SetIsStroke( true );
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetLineWidth( getLineWidth( aField, drawingShadows ) );
|
2019-11-21 15:48:44 +00:00
|
|
|
|
|
|
|
if( drawingShadows && GetSelectionTextAsBox() )
|
|
|
|
{
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetFillColor( color );
|
|
|
|
m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
|
|
|
|
boundaryBox.RevertYAxis();
|
|
|
|
|
2020-03-06 20:02:58 +00:00
|
|
|
m_gal->DrawRectangle( mapCoords( boundaryBox.GetPosition() ),
|
|
|
|
mapCoords( boundaryBox.GetEnd() ) );
|
2019-11-21 15:48:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
|
|
|
|
m_gal->SetFontBold( aField->IsBold() );
|
|
|
|
m_gal->SetFontItalic( aField->IsItalic() );
|
|
|
|
m_gal->SetTextMirrored( aField->IsMirrored() );
|
|
|
|
|
|
|
|
strokeText( aField->GetFullyQualifiedText(), textpos,
|
2020-03-06 20:02:58 +00:00
|
|
|
orient == TEXT_ANGLE_VERT ? M_PI / 2 : 0 );
|
2019-11-21 15:48:44 +00:00
|
|
|
}
|
2018-10-21 21:54:02 +00:00
|
|
|
|
|
|
|
// Draw the umbilical line
|
|
|
|
if( aField->IsMoving() )
|
|
|
|
{
|
2020-03-06 12:05:21 +00:00
|
|
|
wxPoint parentPos = aField->GetParentPosition();
|
|
|
|
|
2018-10-21 21:54:02 +00:00
|
|
|
m_gal->SetLineWidth( m_schSettings.m_outlineWidth );
|
|
|
|
m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
|
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
|
|
|
|
2018-09-01 23:29:19 +00:00
|
|
|
void SCH_PAINTER::draw( 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;
|
|
|
|
|
|
|
|
if( drawingShadows && !aLabel->IsSelected() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
COLOR4D color = getRenderColor( aLabel, LAYER_GLOBLABEL, drawingShadows );
|
2018-09-05 22:17:22 +00:00
|
|
|
|
2018-08-27 13:25:48 +00:00
|
|
|
std::vector<wxPoint> pts;
|
|
|
|
std::deque<VECTOR2D> pts2;
|
|
|
|
|
|
|
|
aLabel->CreateGraphicShape( pts, aLabel->GetTextPos() );
|
|
|
|
|
|
|
|
for( auto 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
|
|
|
|
2020-01-09 13:43:46 +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
|
|
|
|
// second, on the text layer.
|
|
|
|
// the second must not erase the first drawing.
|
|
|
|
bool fillBg = ( aLayer == LAYER_SELECTION_SHADOWS ) || !aLabel->IsSelected();
|
|
|
|
m_gal->SetIsFill( fillBg );
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetFillColor( m_schSettings.GetLayerColor( LAYER_SCHEMATIC_BACKGROUND ) );
|
2018-08-27 13:25:48 +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-27 13:25:48 +00:00
|
|
|
m_gal->DrawPolyline( pts2 );
|
|
|
|
|
|
|
|
draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-01 23:29:19 +00:00
|
|
|
void SCH_PAINTER::draw( 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;
|
|
|
|
|
|
|
|
if( drawingShadows && !aLabel->IsSelected() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
COLOR4D color = getRenderColor( aLabel, LAYER_SHEETLABEL, drawingShadows );
|
2018-09-05 22:17:22 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
SCH_CONNECTION* conn = aLabel->Connection( *g_CurrentSheet );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
|
|
|
if( conn && conn->IsBus() )
|
2019-07-30 01:57:41 +00:00
|
|
|
color = getRenderColor( aLabel, LAYER_BUS, drawingShadows );
|
2018-09-05 22:17:22 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
std::vector<wxPoint> pts;
|
|
|
|
std::deque<VECTOR2D> pts2;
|
|
|
|
|
|
|
|
aLabel->CreateGraphicShape( pts, aLabel->GetTextPos() );
|
|
|
|
|
|
|
|
for( auto 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 );
|
|
|
|
|
|
|
|
draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
|
|
|
|
}
|
|
|
|
|
2018-09-05 22:17:22 +00:00
|
|
|
void SCH_PAINTER::draw( 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;
|
|
|
|
|
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
|
|
|
{
|
2020-01-12 18:40:50 +00:00
|
|
|
if( drawingShadows && !aSheet->IsSelected() && !sheetPin->IsSelected() )
|
2019-07-30 01:57:41 +00:00
|
|
|
continue;
|
|
|
|
|
2019-11-21 15:48:44 +00:00
|
|
|
if( drawingShadows && !GetSelectionDrawChildItems() && aSheet->IsSelected() )
|
|
|
|
break;
|
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
int width = aSheet->GetPenSize();
|
2020-01-12 18:40:50 +00:00
|
|
|
wxPoint initial_pos = sheetPin->GetTextPos();
|
2019-07-30 01:57:41 +00:00
|
|
|
wxPoint offset_pos = initial_pos;
|
|
|
|
|
|
|
|
// For aesthetic reasons, the SHEET_PIN is drawn with a small offset of width / 2
|
2020-01-12 18:40:50 +00:00
|
|
|
switch( sheetPin->GetEdge() )
|
2019-07-30 01:57:41 +00:00
|
|
|
{
|
|
|
|
case SHEET_TOP_SIDE: offset_pos.y += KiROUND( width / 2.0 ); break;
|
|
|
|
case SHEET_BOTTOM_SIDE: offset_pos.y -= KiROUND( width / 2.0 ); break;
|
|
|
|
case SHEET_RIGHT_SIDE: offset_pos.x -= KiROUND( width / 2.0 ); break;
|
|
|
|
case SHEET_LEFT_SIDE: offset_pos.x += KiROUND( width / 2.0 ); break;
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
VECTOR2D pos = aSheet->GetPosition();
|
|
|
|
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-08-03 12:18:26 +00:00
|
|
|
|
2020-03-06 20:02:58 +00:00
|
|
|
if( drawingShadows && !GetSelectionDrawChildItems() && aSheet->IsSelected() )
|
2020-03-06 12:05:21 +00:00
|
|
|
return;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2020-03-06 12:05:21 +00:00
|
|
|
for( SCH_FIELD& field : aSheet->GetFields() )
|
|
|
|
draw( &field, aLayer );
|
2018-12-13 23:04:49 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-09-04 20:53:04 +00:00
|
|
|
|
|
|
|
void SCH_PAINTER::draw( 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
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
if( drawingShadows && !aNC->IsSelected() )
|
|
|
|
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();
|
2019-07-30 01:57:41 +00:00
|
|
|
int delta = aNC->GetSize() / 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
|
|
|
|
|
|
|
void SCH_PAINTER::draw( SCH_BUS_ENTRY_BASE *aEntry, int aLayer )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2019-07-30 01:57:41 +00:00
|
|
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
|
|
|
|
|
|
|
if( drawingShadows && !aEntry->IsSelected() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
COLOR4D color = getRenderColor( aEntry, LAYER_WIRE, drawingShadows );
|
|
|
|
|
|
|
|
if( aEntry->Type() == SCH_BUS_BUS_ENTRY_T )
|
|
|
|
color = getRenderColor( aEntry, LAYER_BUS, drawingShadows );
|
2018-09-05 22:17:22 +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( aEntry, drawingShadows ) );
|
|
|
|
m_gal->SetStrokeColor( color );
|
2018-08-03 12:18:26 +00:00
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
|
|
|
|
VECTOR2D pos = aEntry->GetPosition();
|
|
|
|
VECTOR2D endPos = aEntry->m_End();
|
|
|
|
|
|
|
|
m_gal->DrawLine( pos, endPos );
|
|
|
|
|
2018-09-07 07:15:22 +00:00
|
|
|
// Draw dangling symbols:
|
2019-07-30 01:57:41 +00:00
|
|
|
m_gal->SetLineWidth ( getLineWidth( aEntry, drawingShadows ) );
|
2018-09-05 22:17:22 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
if( aEntry->IsDanglingStart() )
|
|
|
|
m_gal->DrawCircle( pos, TARGET_BUSENTRY_RADIUS );
|
|
|
|
|
|
|
|
if( aEntry->IsDanglingEnd() )
|
|
|
|
m_gal->DrawCircle( endPos, TARGET_BUSENTRY_RADIUS );
|
|
|
|
}
|
|
|
|
|
2018-09-04 20:53:04 +00:00
|
|
|
|
|
|
|
void SCH_PAINTER::draw( 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
|
|
|
{
|
2019-08-01 04:52:22 +00:00
|
|
|
if( aBitmap->IsSelected() || aBitmap->IsBrightened() || aBitmap->IsHighlighted() )
|
|
|
|
{
|
|
|
|
COLOR4D color = getRenderColor( aBitmap, LAYER_DRAW_BITMAPS, true );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
m_gal->SetLineWidth ( getShadowWidth() );
|
|
|
|
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
|
|
|
|
|
|
|
void SCH_PAINTER::draw( 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
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
if( drawingShadows && !aMarker->IsSelected() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( aMarker->GetErrorLevel() == MARKER_BASE::MARKER_SEVERITY_ERROR )
|
2019-08-07 18:23:59 +00:00
|
|
|
aLayer = LAYER_ERC_ERR;
|
|
|
|
else
|
|
|
|
aLayer = LAYER_ERC_WARN;
|
2019-07-30 01:57:41 +00:00
|
|
|
|
2019-08-07 18:23:59 +00:00
|
|
|
COLOR4D color = getRenderColor( aMarker, aLayer, 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
|