New selection highlighting model for eeschema.

This commit is contained in:
Jeff Young 2019-07-29 19:57:41 -06:00
parent b70df18939
commit 6bf1ac45e3
18 changed files with 447 additions and 305 deletions

View File

@ -54,11 +54,8 @@ int GetPenSizeForBold( int aTextSize )
/** /**
* Function Clamp_Text_PenSize * Function Clamp_Text_PenSize
* As a rule, pen width should not be >1/4em, otherwise the character * Don't allow text to become cluttered up in its own fatness. Bold fonts are generally around
* will be cluttered up in its own fatness * aSize/5 in width, so we limit them to aSize/4, and normal text to aSize/6.
* so pen width max is aSize/4 for bold text, and aSize/6 for normal text
* The "best" pen width is aSize/5 for bold texts,
* so the clamp is consistant with bold option.
* @param aPenSize = the pen size to clamp * @param aPenSize = the pen size to clamp
* @param aSize the char size (height or width) * @param aSize the char size (height or width)
* @param aBold = true if text accept bold pen size * @param aBold = true if text accept bold pen size
@ -66,14 +63,19 @@ int GetPenSizeForBold( int aTextSize )
*/ */
int Clamp_Text_PenSize( int aPenSize, int aSize, bool aBold ) int Clamp_Text_PenSize( int aPenSize, int aSize, bool aBold )
{ {
int penSize = aPenSize; double scale = aBold ? 4.0 : 6.0;
double scale = aBold ? 4.0 : 6.0; int maxWidth = KiROUND( (double) aSize / scale );
int maxWidth = KiROUND( std::abs( aSize ) / scale );
if( penSize > maxWidth ) return std::min( aPenSize, maxWidth );
penSize = maxWidth; }
return penSize;
float Clamp_Text_PenSize( float aPenSize, int aSize, bool aBold )
{
float scale = aBold ? 4.0 : 6.0;
float maxWidth = (float) aSize / scale;
return std::min( aPenSize, maxWidth );
} }

View File

@ -23,10 +23,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
/**
* @file class_libentry.cpp
*/
#include <fctsys.h> #include <fctsys.h>
#include <macros.h> #include <macros.h>
#include <kicad_string.h> #include <kicad_string.h>
@ -35,9 +31,7 @@
#include <gr_basic.h> #include <gr_basic.h>
#include <sch_screen.h> #include <sch_screen.h>
#include <richio.h> #include <richio.h>
#include <kicad_string.h>
#include <trace_helpers.h> #include <trace_helpers.h>
#include <general.h> #include <general.h>
#include <template_fieldnames.h> #include <template_fieldnames.h>
#include <transform.h> #include <transform.h>
@ -45,11 +39,6 @@
#include <class_libentry.h> #include <class_libentry.h>
#include <lib_pin.h> #include <lib_pin.h>
#include <lib_arc.h> #include <lib_arc.h>
#include <lib_bezier.h>
#include <lib_circle.h>
#include <lib_polyline.h>
#include <lib_rectangle.h>
#include <lib_text.h>
// the separator char between the subpart id and the reference // the separator char between the subpart id and the reference
@ -205,12 +194,13 @@ void LIB_ALIAS::ViewGetLayers( int aLayers[], int& aCount ) const
// An alias's fields don't know how to fetch their parent's values so we don't let // An alias's fields don't know how to fetch their parent's values so we don't let
// them draw themselves. This means the alias always has to draw them, which means // them draw themselves. This means the alias always has to draw them, which means
// it has to "own" their layers as well. // it has to "own" their layers as well.
aCount = 5; aCount = 6;
aLayers[0] = LAYER_DEVICE; aLayers[0] = LAYER_DEVICE;
aLayers[1] = LAYER_DEVICE_BACKGROUND; aLayers[1] = LAYER_DEVICE_BACKGROUND;
aLayers[2] = LAYER_REFERENCEPART; aLayers[2] = LAYER_REFERENCEPART;
aLayers[3] = LAYER_VALUEPART; aLayers[3] = LAYER_VALUEPART;
aLayers[4] = LAYER_FIELDS; aLayers[4] = LAYER_FIELDS;
aLayers[5] = LAYER_SELECTION_SHADOWS;
} }
@ -717,9 +707,10 @@ const EDA_RECT LIB_PART::GetUnitBoundingBox( int aUnit, int aConvert ) const
void LIB_PART::ViewGetLayers( int aLayers[], int& aCount ) const void LIB_PART::ViewGetLayers( int aLayers[], int& aCount ) const
{ {
aCount = 2; aCount = 3;
aLayers[0] = LAYER_DEVICE; aLayers[0] = LAYER_DEVICE;
aLayers[1] = LAYER_DEVICE_BACKGROUND; aLayers[1] = LAYER_DEVICE_BACKGROUND;
aLayers[2] = LAYER_SELECTION_SHADOWS;
} }

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2019 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -23,10 +23,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
/**
* @file lib_draw_item.cpp
*/
#include <fctsys.h> #include <fctsys.h>
#include <gr_basic.h> #include <gr_basic.h>
#include <sch_draw_panel.h> #include <sch_draw_panel.h>
@ -133,9 +129,10 @@ void LIB_ITEM::Print( wxDC* aDC, const wxPoint& aOffset, void* aData, const TRAN
void LIB_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const void LIB_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
{ {
// Basic fallback // Basic fallback
aCount = 2; aCount = 3;
aLayers[0] = LAYER_DEVICE; aLayers[0] = LAYER_DEVICE;
aLayers[1] = LAYER_DEVICE_BACKGROUND; aLayers[1] = LAYER_DEVICE_BACKGROUND;
aLayers[2] = LAYER_SELECTION_SHADOWS;
} }

View File

@ -340,7 +340,7 @@ const EDA_RECT LIB_FIELD::GetBoundingBox() const
void LIB_FIELD::ViewGetLayers( int aLayers[], int& aCount ) const void LIB_FIELD::ViewGetLayers( int aLayers[], int& aCount ) const
{ {
aCount = 1; aCount = 2;
switch( m_id ) switch( m_id )
{ {
@ -348,6 +348,8 @@ void LIB_FIELD::ViewGetLayers( int aLayers[], int& aCount ) const
case VALUE: aLayers[0] = LAYER_VALUEPART; break; case VALUE: aLayers[0] = LAYER_VALUEPART; break;
default: aLayers[0] = LAYER_FIELDS; break; default: aLayers[0] = LAYER_FIELDS; break;
} }
aLayers[1] = LAYER_SELECTION_SHADOWS;
} }

View File

@ -52,8 +52,9 @@ LIB_TEXT::LIB_TEXT( LIB_PART * aParent ) :
void LIB_TEXT::ViewGetLayers( int aLayers[], int& aCount ) const void LIB_TEXT::ViewGetLayers( int aLayers[], int& aCount ) const
{ {
aCount = 1; aCount = 2;
aLayers[0] = LAYER_DEVICE; aLayers[0] = LAYER_DEVICE;
aLayers[1] = LAYER_SELECTION_SHADOWS;
} }

View File

@ -105,8 +105,9 @@ void SCH_BUS_ENTRY_BASE::SwapData( SCH_ITEM* aItem )
void SCH_BUS_ENTRY_BASE::ViewGetLayers( int aLayers[], int& aCount ) const void SCH_BUS_ENTRY_BASE::ViewGetLayers( int aLayers[], int& aCount ) const
{ {
aCount = 1; aCount = 2;
aLayers[0] = Type() == SCH_BUS_BUS_ENTRY_T ? LAYER_BUS : LAYER_WIRE; aLayers[0] = Type() == SCH_BUS_BUS_ENTRY_T ? LAYER_BUS : LAYER_WIRE;
aLayers[1] = LAYER_SELECTION_SHADOWS;
} }
@ -386,6 +387,16 @@ char SCH_BUS_ENTRY_BASE::GetBusEntryShape() const
void SCH_BUS_ENTRY_BASE::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) void SCH_BUS_ENTRY_BASE::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList )
{ {
wxString msg;
switch( GetLayer() )
{
default:
case LAYER_WIRE: msg = _( "Wire" ); break;
case LAYER_BUS: msg = _( "Bus" ); break;
}
aList.push_back( MSG_PANEL_ITEM( _( "Bus Entry Type" ), msg, DARKCYAN ) );
if( auto conn = Connection( *g_CurrentSheet ) ) if( auto conn = Connection( *g_CurrentSheet ) )
{ {
#if defined(DEBUG) #if defined(DEBUG)

View File

@ -236,9 +236,10 @@ EDA_ITEM* SCH_COMPONENT::Clone() const
void SCH_COMPONENT::ViewGetLayers( int aLayers[], int& aCount ) const void SCH_COMPONENT::ViewGetLayers( int aLayers[], int& aCount ) const
{ {
aCount = 2; aCount = 3;
aLayers[0] = LAYER_DEVICE; aLayers[0] = LAYER_DEVICE;
aLayers[1] = LAYER_DEVICE_BACKGROUND; aLayers[1] = LAYER_DEVICE_BACKGROUND;
aLayers[2] = LAYER_SELECTION_SHADOWS;
} }

View File

@ -144,17 +144,20 @@ void SCH_DRAW_PANEL::setDefaultLayerDeps()
m_view->SetLayerTarget( i, target ); m_view->SetLayerTarget( i, target );
// Bitmaps are draw on a non cached GAL layer: // Bitmaps are draw on a non cached GAL layer:
m_view->SetLayerTarget( LAYER_DRAW_BITMAPS , KIGFX::TARGET_NONCACHED ); m_view->SetLayerTarget( LAYER_DRAW_BITMAPS, KIGFX::TARGET_NONCACHED );
// Some draw layers need specific settings // Some draw layers need specific settings
m_view->SetLayerTarget( LAYER_GP_OVERLAY , KIGFX::TARGET_OVERLAY ); m_view->SetLayerTarget( LAYER_GP_OVERLAY, KIGFX::TARGET_OVERLAY );
m_view->SetLayerDisplayOnly( LAYER_GP_OVERLAY ) ; m_view->SetLayerDisplayOnly( LAYER_GP_OVERLAY ) ;
m_view->SetLayerTarget( LAYER_SELECT_OVERLAY , KIGFX::TARGET_OVERLAY ); m_view->SetLayerTarget( LAYER_SELECT_OVERLAY, KIGFX::TARGET_OVERLAY );
m_view->SetLayerDisplayOnly( LAYER_SELECT_OVERLAY ) ; m_view->SetLayerDisplayOnly( LAYER_SELECT_OVERLAY ) ;
m_view->SetLayerTarget( LAYER_WORKSHEET , KIGFX::TARGET_NONCACHED ); m_view->SetLayerTarget( LAYER_WORKSHEET, KIGFX::TARGET_NONCACHED );
m_view->SetLayerDisplayOnly( LAYER_WORKSHEET ) ; m_view->SetLayerDisplayOnly( LAYER_WORKSHEET ) ;
m_view->SetLayerTarget( LAYER_SELECTION_SHADOWS, KIGFX::TARGET_NONCACHED );
m_view->SetLayerDisplayOnly( LAYER_SELECTION_SHADOWS ) ;
} }

View File

@ -110,8 +110,9 @@ SCH_ITEM* SCH_ITEM::Duplicate( bool doClone )
void SCH_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const void SCH_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
{ {
// Basic fallback // Basic fallback
aCount = 1; aCount = 2;
aLayers[0] = LAYER_DEVICE; aLayers[0] = LAYER_DEVICE;
aLayers[1] = LAYER_SELECTION_SHADOWS;
} }

View File

@ -76,8 +76,9 @@ void SCH_JUNCTION::SwapData( SCH_ITEM* aItem )
void SCH_JUNCTION::ViewGetLayers( int aLayers[], int& aCount ) const void SCH_JUNCTION::ViewGetLayers( int aLayers[], int& aCount ) const
{ {
aCount = 1; aCount = 2;
aLayers[0] = LAYER_JUNCTION; aLayers[0] = LAYER_JUNCTION;
aLayers[1] = LAYER_SELECTION_SHADOWS;
} }

View File

@ -81,8 +81,9 @@ const EDA_RECT SCH_NO_CONNECT::GetBoundingBox() const
void SCH_NO_CONNECT::ViewGetLayers( int aLayers[], int& aCount ) const void SCH_NO_CONNECT::ViewGetLayers( int aLayers[], int& aCount ) const
{ {
aCount = 2;
aLayers[0] = LAYER_NOCONNECT; aLayers[0] = LAYER_NOCONNECT;
aCount = 1; aLayers[1] = LAYER_SELECTION_SHADOWS;
} }

File diff suppressed because it is too large Load Diff

View File

@ -137,7 +137,6 @@ private:
void draw( LIB_RECTANGLE* aRect, int aLayer ); void draw( LIB_RECTANGLE* aRect, int aLayer );
void draw( LIB_PIN* aPin, int aLayer ); void draw( LIB_PIN* aPin, int aLayer );
void draw( LIB_CIRCLE* aCircle, int aLayer ); void draw( LIB_CIRCLE* aCircle, int aLayer );
void draw( LIB_ITEM *, int aLayer );
void draw( LIB_PART* aPart, int, bool aDrawFields = true, int aUnit = 0, int aConvert = 0 ); void draw( LIB_PART* aPart, int, bool aDrawFields = true, int aUnit = 0, int aConvert = 0 );
void draw( LIB_ALIAS* aAlias, int aLayer ); void draw( LIB_ALIAS* aAlias, int aLayer );
void draw( LIB_ARC* aArc, int aLayer ); void draw( LIB_ARC* aArc, int aLayer );
@ -158,11 +157,18 @@ private:
void draw( SCH_LINE* aLine, int aLayer ); void draw( SCH_LINE* aLine, int aLayer );
void draw( SCH_BUS_ENTRY_BASE* aEntry, int aLayer ); void draw( SCH_BUS_ENTRY_BASE* aEntry, int aLayer );
void drawPinDanglingSymbol( const VECTOR2I& aPos, bool aDrawingShadows );
void drawDanglingSymbol( const wxPoint& aPos, bool aDrawingShadows );
bool isUnitAndConversionShown( const LIB_ITEM* aItem ); bool isUnitAndConversionShown( const LIB_ITEM* aItem );
COLOR4D getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aOnBackgroundLayer ); float getShadowWidth();
COLOR4D getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows );
float getLineWidth( const LIB_ITEM* aItem, bool aDrawingShadows );
float getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows );
float getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows );
bool setColors( const LIB_ITEM* aItem, int aLayer ); bool setDeviceColors( const LIB_ITEM* aItem, int aLayer );
void triLine ( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c ); void triLine ( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c );

View File

@ -426,10 +426,11 @@ wxPoint SCH_SHEET::GetFileNamePosition()
void SCH_SHEET::ViewGetLayers( int aLayers[], int& aCount ) const void SCH_SHEET::ViewGetLayers( int aLayers[], int& aCount ) const
{ {
aCount = 3; aCount = 4;
aLayers[0] = LAYER_HIERLABEL; aLayers[0] = LAYER_HIERLABEL;
aLayers[1] = LAYER_SHEET; aLayers[1] = LAYER_SHEET;
aLayers[2] = LAYER_SHEET_BACKGROUND; aLayers[2] = LAYER_SHEET_BACKGROUND;
aLayers[3] = LAYER_SELECTION_SHADOWS;
} }

View File

@ -50,9 +50,10 @@ static const LAYER_NUM SCH_LAYER_ORDER[] =
LAYER_HIERLABEL, LAYER_HIERLABEL,
LAYER_WIRE, LAYER_BUS, LAYER_WIRE, LAYER_BUS,
LAYER_DEVICE, LAYER_DEVICE,
LAYER_DEVICE_BACKGROUND,
LAYER_NOTES, LAYER_NOTES,
LAYER_SHEET, LAYER_SHEET,
LAYER_SELECTION_SHADOWS,
LAYER_DEVICE_BACKGROUND,
LAYER_SHEET_BACKGROUND, LAYER_SHEET_BACKGROUND,
LAYER_WORKSHEET LAYER_WORKSHEET
}; };

View File

@ -63,6 +63,7 @@ class PLOTTER;
* @return the max pen size allowed * @return the max pen size allowed
*/ */
int Clamp_Text_PenSize( int aPenSize, int aSize, bool aBold = true ); int Clamp_Text_PenSize( int aPenSize, int aSize, bool aBold = true );
float Clamp_Text_PenSize( float aPenSize, int aSize, bool aBold = true );
int Clamp_Text_PenSize( int aPenSize, wxSize aSize, bool aBold = true ); int Clamp_Text_PenSize( int aPenSize, wxSize aSize, bool aBold = true );
/** /**

View File

@ -265,6 +265,7 @@ enum SCH_LAYER_ID: int
LAYER_SCHEMATIC_CURSOR, LAYER_SCHEMATIC_CURSOR,
LAYER_BRIGHTENED, LAYER_BRIGHTENED,
LAYER_HIDDEN, LAYER_HIDDEN,
LAYER_SELECTION_SHADOWS,
SCH_LAYER_ID_END SCH_LAYER_ID_END
}; };

View File

@ -247,7 +247,7 @@ public:
* (depending on correct GAL unit length & DPI settings). * (depending on correct GAL unit length & DPI settings).
* @param aScale: the scalefactor * @param aScale: the scalefactor
*/ */
inline void SetScale( double aScale ) virtual void SetScale( double aScale )
{ {
SetScale( aScale, m_center ); SetScale( aScale, m_center );
} }
@ -259,7 +259,7 @@ public:
* @param aAnchor: the zooming anchor point * @param aAnchor: the zooming anchor point
* @param aScale: the scale factor * @param aScale: the scale factor
*/ */
void SetScale( double aScale, const VECTOR2D& aAnchor ); virtual void SetScale( double aScale, const VECTOR2D& aAnchor );
/** /**
* Function GetScale() * Function GetScale()