Remove AdvanceDepth() hacks in favour of proper layers.
Also removes the bounding-box cache since the last big merge should have sorted out the Update(GEOMETRY) calls. Fixes: lp:1797271 * https://bugs.launchpad.net/kicad/+bug/1797271 Fixes: lp:1797268 * https://bugs.launchpad.net/kicad/+bug/1797268 Fixes: lp:1797075 * https://bugs.launchpad.net/kicad/+bug/1797075
This commit is contained in:
parent
8ecdf58bad
commit
f17c18bcce
|
@ -180,6 +180,14 @@ bool operator<( const LIB_ALIAS& aItem1, const LIB_ALIAS& aItem2 )
|
|||
}
|
||||
|
||||
|
||||
void LIB_ALIAS::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
{
|
||||
aCount = 2;
|
||||
aLayers[0] = LAYER_DEVICE;
|
||||
aLayers[1] = LAYER_DEVICE_BACKGROUND;
|
||||
}
|
||||
|
||||
|
||||
/// http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared
|
||||
struct null_deleter
|
||||
{
|
||||
|
@ -761,6 +769,14 @@ const EDA_RECT LIB_PART::GetUnitBoundingBox( int aUnit, int aConvert ) const
|
|||
}
|
||||
|
||||
|
||||
void LIB_PART::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
{
|
||||
aCount = 2;
|
||||
aLayers[0] = LAYER_DEVICE;
|
||||
aLayers[1] = LAYER_DEVICE_BACKGROUND;
|
||||
}
|
||||
|
||||
|
||||
const EDA_RECT LIB_PART::GetBodyBoundingBox( int aUnit, int aConvert ) const
|
||||
{
|
||||
EDA_RECT bBox;
|
||||
|
|
|
@ -176,6 +176,8 @@ public:
|
|||
|
||||
bool operator==( const LIB_ALIAS* aAlias ) const { return this == aAlias; }
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
||||
#if defined(DEBUG)
|
||||
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
||||
#endif
|
||||
|
@ -329,6 +331,8 @@ public:
|
|||
|
||||
wxArrayString& GetFootprints() { return m_FootprintList; }
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
||||
/**
|
||||
* Get the bounding box for the symbol.
|
||||
*
|
||||
|
|
|
@ -153,6 +153,15 @@ void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
|||
}
|
||||
|
||||
|
||||
void LIB_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
{
|
||||
// Basic fallback
|
||||
aCount = 2;
|
||||
aLayers[0] = LAYER_DEVICE;
|
||||
aLayers[1] = LAYER_DEVICE_BACKGROUND;
|
||||
}
|
||||
|
||||
|
||||
COLOR4D LIB_ITEM::GetDefaultColor()
|
||||
{
|
||||
return GetLayerColor( LAYER_DEVICE );
|
||||
|
|
|
@ -219,6 +219,8 @@ public:
|
|||
return (LIB_PART *)m_Parent;
|
||||
}
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
||||
virtual bool HitTest( const wxPoint& aPosition ) const override
|
||||
{
|
||||
return EDA_ITEM::HitTest( aPosition );
|
||||
|
|
|
@ -393,26 +393,27 @@ const EDA_RECT LIB_FIELD::GetBoundingBox() const
|
|||
}
|
||||
|
||||
|
||||
COLOR4D LIB_FIELD::GetDefaultColor()
|
||||
void LIB_FIELD::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
{
|
||||
COLOR4D color;
|
||||
aCount = 1;
|
||||
|
||||
switch( m_id )
|
||||
{
|
||||
case REFERENCE:
|
||||
color = GetLayerColor( LAYER_REFERENCEPART );
|
||||
break;
|
||||
|
||||
case VALUE:
|
||||
color = GetLayerColor( LAYER_VALUEPART );
|
||||
break;
|
||||
|
||||
default:
|
||||
color = GetLayerColor( LAYER_FIELDS );
|
||||
break;
|
||||
case REFERENCE: aLayers[0] = LAYER_REFERENCEPART; break;
|
||||
case VALUE: aLayers[0] = LAYER_VALUEPART; break;
|
||||
default: aLayers[0] = LAYER_FIELDS; break;
|
||||
}
|
||||
}
|
||||
|
||||
return color;
|
||||
|
||||
COLOR4D LIB_FIELD::GetDefaultColor()
|
||||
{
|
||||
switch( m_id )
|
||||
{
|
||||
case REFERENCE: return GetLayerColor( LAYER_REFERENCEPART );
|
||||
case VALUE: return GetLayerColor( LAYER_VALUEPART );
|
||||
default: return GetLayerColor( LAYER_FIELDS );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -158,6 +158,8 @@ public:
|
|||
return m_Text.IsEmpty();
|
||||
}
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
||||
/**
|
||||
* @return true is this field is visible, false if flagged invisible
|
||||
*/
|
||||
|
|
|
@ -52,6 +52,13 @@ LIB_TEXT::LIB_TEXT( LIB_PART * aParent ) :
|
|||
}
|
||||
|
||||
|
||||
void LIB_TEXT::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
{
|
||||
aCount = 1;
|
||||
aLayers[0] = LAYER_NOTES;
|
||||
}
|
||||
|
||||
|
||||
bool LIB_TEXT::HitTest( const wxPoint& aPosition ) const
|
||||
{
|
||||
return HitTest( aPosition, 0, DefaultTransform );
|
||||
|
|
|
@ -70,6 +70,8 @@ public:
|
|||
return _( "Text" );
|
||||
}
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
||||
/**
|
||||
* Sets the text item string to \a aText.
|
||||
*
|
||||
|
|
|
@ -1742,17 +1742,12 @@ void LIB_EDIT_FRAME::SetScreen( BASE_SCREEN* aScreen )
|
|||
|
||||
void LIB_EDIT_FRAME::RebuildView()
|
||||
{
|
||||
KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
|
||||
|
||||
view->Clear();
|
||||
|
||||
GetRenderSettings()->m_ShowUnit = m_unit;
|
||||
GetRenderSettings()->m_ShowConvert = m_convert;
|
||||
GetCanvas()->DisplayComponent( m_my_part );
|
||||
|
||||
view->DisplayComponent( m_my_part );
|
||||
|
||||
view->HideWorksheet();
|
||||
view->ClearHiddenFlags();
|
||||
GetCanvas()->GetView()->HideWorksheet();
|
||||
GetCanvas()->GetView()->ClearHiddenFlags();
|
||||
|
||||
GetCanvas()->Refresh();
|
||||
}
|
||||
|
|
|
@ -100,6 +100,14 @@ void SCH_BUS_ENTRY_BASE::SwapData( SCH_ITEM* aItem )
|
|||
}
|
||||
|
||||
|
||||
void SCH_BUS_ENTRY_BASE::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
{
|
||||
aCount = 1;
|
||||
|
||||
aLayers[0] = Type() == SCH_BUS_BUS_ENTRY_T ? LAYER_BUS : LAYER_WIRE;
|
||||
}
|
||||
|
||||
|
||||
const EDA_RECT SCH_BUS_ENTRY_BASE::GetBoundingBox() const
|
||||
{
|
||||
EDA_RECT box;
|
||||
|
|
|
@ -83,6 +83,8 @@ public:
|
|||
|
||||
void SwapData( SCH_ITEM* aItem ) override;
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
||||
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
|
||||
GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override;
|
||||
|
||||
|
|
|
@ -233,6 +233,14 @@ EDA_ITEM* SCH_COMPONENT::Clone() const
|
|||
}
|
||||
|
||||
|
||||
void SCH_COMPONENT::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
{
|
||||
aCount = 2;
|
||||
aLayers[0] = LAYER_DEVICE;
|
||||
aLayers[1] = LAYER_DEVICE_BACKGROUND;
|
||||
}
|
||||
|
||||
|
||||
void SCH_COMPONENT::SetLibId( const LIB_ID& aLibId, PART_LIBS* aLibs )
|
||||
{
|
||||
if( m_lib_id != aLibId )
|
||||
|
|
|
@ -153,6 +153,8 @@ public:
|
|||
|
||||
const wxArrayString& GetPathsAndReferences() const { return m_PathsAndReferences; }
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
||||
/**
|
||||
* Return true for items which are moved with the anchor point at mouse cursor
|
||||
* and false for items moved with no reference to anchor.
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
|
||||
using namespace std::placeholders;
|
||||
|
||||
|
||||
// Events used by EDA_DRAW_PANEL
|
||||
// GAL TODO: some (most?) of these need to be implemented...
|
||||
BEGIN_EVENT_TABLE( SCH_DRAW_PANEL, wxScrolledCanvas )
|
||||
|
@ -69,13 +70,8 @@ SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId,
|
|||
EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalType ),
|
||||
m_parent( aParentWindow )
|
||||
{
|
||||
#ifdef __WXMAC__
|
||||
m_defaultCursor = m_currentCursor = wxCURSOR_CROSS;
|
||||
m_showCrossHair = false;
|
||||
#else
|
||||
m_defaultCursor = m_currentCursor = wxCURSOR_ARROW;
|
||||
m_showCrossHair = true;
|
||||
#endif
|
||||
m_view = new KIGFX::SCH_VIEW( true );
|
||||
m_view->SetGAL( m_gal );
|
||||
|
||||
|
@ -143,8 +139,6 @@ SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId,
|
|||
Show( true );
|
||||
Raise();
|
||||
StartDrawing();
|
||||
//printf("CreateGALPAnel\n");
|
||||
//m_selectionArea = new KIGFX::PREVIEW::SELECTION_AREA;
|
||||
}
|
||||
|
||||
|
||||
|
@ -182,13 +176,13 @@ void SCH_DRAW_PANEL::OnShow()
|
|||
|
||||
void SCH_DRAW_PANEL::setDefaultLayerOrder()
|
||||
{
|
||||
/* for( LAYER_NUM i = 0; (unsigned) i < sizeof( GAL_LAYER_ORDER ) / sizeof( LAYER_NUM ); ++i )
|
||||
for( LAYER_NUM i = 0; (unsigned) i < sizeof( SCH_LAYER_ORDER ) / sizeof( LAYER_NUM ); ++i )
|
||||
{
|
||||
LAYER_NUM layer = GAL_LAYER_ORDER[i];
|
||||
LAYER_NUM layer = SCH_LAYER_ORDER[i];
|
||||
wxASSERT( layer < KIGFX::VIEW::VIEW_MAX_LAYERS );
|
||||
|
||||
m_view->SetLayerOrder( layer, i );
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -259,8 +253,6 @@ void SCH_DRAW_PANEL::setDefaultLayerDeps()
|
|||
|
||||
m_view->SetLayerTarget( LAYER_WORKSHEET , KIGFX::TARGET_NONCACHED );
|
||||
m_view->SetLayerDisplayOnly( LAYER_WORKSHEET ) ;
|
||||
|
||||
m_view->SetLayerDisplayOnly( LAYER_DRC );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -68,6 +68,14 @@ SCH_ITEM::~SCH_ITEM()
|
|||
}
|
||||
|
||||
|
||||
void SCH_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
{
|
||||
// Basic fallback
|
||||
aCount = 1;
|
||||
aLayers[0] = LAYER_DEVICE;
|
||||
}
|
||||
|
||||
|
||||
bool SCH_ITEM::IsConnected( const wxPoint& aPosition ) const
|
||||
{
|
||||
if( m_Flags & STRUCT_DELETED || m_Flags & SKIP_STRUCT )
|
||||
|
|
|
@ -169,6 +169,12 @@ public:
|
|||
*/
|
||||
void SetLayer( SCH_LAYER_ID aLayer ) { m_Layer = aLayer; }
|
||||
|
||||
/**
|
||||
* Function ViewGetLayers
|
||||
* returns the layers the item is drawn on (which may be more than its "home" layer)
|
||||
*/
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
||||
/**
|
||||
* Function GetPenSize virtual pure
|
||||
* @return the size of the "pen" that be used to draw or plot this item
|
||||
|
|
|
@ -73,6 +73,13 @@ void SCH_JUNCTION::SwapData( SCH_ITEM* aItem )
|
|||
}
|
||||
|
||||
|
||||
void SCH_JUNCTION::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
{
|
||||
aCount = 1;
|
||||
aLayers[0] = LAYER_JUNCTION;
|
||||
}
|
||||
|
||||
|
||||
const EDA_RECT SCH_JUNCTION::GetBoundingBox() const
|
||||
{
|
||||
EDA_RECT rect;
|
||||
|
|
|
@ -59,6 +59,8 @@ public:
|
|||
|
||||
void SwapData( SCH_ITEM* aItem ) override;
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
||||
const EDA_RECT GetBoundingBox() const override;
|
||||
|
||||
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
|
||||
|
|
|
@ -108,6 +108,13 @@ bool SCH_MARKER::Matches( wxFindReplaceData& aSearchData, void* aAuxData,
|
|||
}
|
||||
|
||||
|
||||
void SCH_MARKER::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
{
|
||||
aCount = 1;
|
||||
aLayers[0] = this->m_ErrorLevel == MARKER_SEVERITY_ERROR ? LAYER_ERC_ERR : LAYER_ERC_WARN;
|
||||
}
|
||||
|
||||
|
||||
const EDA_RECT SCH_MARKER::GetBoundingBox() const
|
||||
{
|
||||
return GetBoundingBoxMarker();
|
||||
|
|
|
@ -52,6 +52,8 @@ public:
|
|||
return wxT( "SCH_MARKER" );
|
||||
}
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
||||
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
|
||||
GR_DRAWMODE aDraw_mode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override;
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
#include <class_libentry.h>
|
||||
#include <class_library.h>
|
||||
#include <sch_edit_frame.h>
|
||||
|
||||
#include <view/view.h>
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
#include <colors_design_settings.h>
|
||||
|
||||
|
@ -209,19 +209,16 @@ void SCH_PAINTER::draw( LIB_PART *aComp, int aLayer, bool aDrawFields, int aUnit
|
|||
|
||||
size_t pinIndex = 0;
|
||||
|
||||
auto visitItem = [&]( LIB_ITEM& item, bool aBackground )
|
||||
for( auto& item : aComp->GetDrawItems() )
|
||||
{
|
||||
if( aBackground != ( item.GetFillMode() == FILLED_WITH_BG_BODYCOLOR ) )
|
||||
return;
|
||||
|
||||
if( !aDrawFields && item.Type() == LIB_FIELD_T )
|
||||
return;
|
||||
continue;
|
||||
|
||||
if( aUnit && item.GetUnit() && aUnit != item.GetUnit() )
|
||||
return;
|
||||
continue;
|
||||
|
||||
if( aConvert && item.GetConvert() && aConvert != item.GetConvert() )
|
||||
return;
|
||||
continue;
|
||||
|
||||
if( item.Type() == LIB_PIN_T )
|
||||
{
|
||||
|
@ -236,18 +233,7 @@ void SCH_PAINTER::draw( LIB_PART *aComp, int aLayer, bool aDrawFields, int aUnit
|
|||
}
|
||||
else
|
||||
Draw( &item, aLayer );
|
||||
};
|
||||
|
||||
// Apply a z-order heuristic (because we don't yet let the user edit it):
|
||||
// draw body-filled objects first.
|
||||
|
||||
for( auto& item : aComp->GetDrawItems() )
|
||||
visitItem( item, true );
|
||||
|
||||
m_gal->AdvanceDepth();
|
||||
|
||||
for( auto& item : aComp->GetDrawItems() )
|
||||
visitItem( item, false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -284,9 +270,9 @@ void SCH_PAINTER::triLine( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D
|
|||
}
|
||||
|
||||
|
||||
void SCH_PAINTER::setColors( const LIB_ITEM* aItem, bool aBackground )
|
||||
bool SCH_PAINTER::setColors( const LIB_ITEM* aItem, int aLayer )
|
||||
{
|
||||
if( aBackground )
|
||||
if( aLayer == LAYER_DEVICE_BACKGROUND && aItem->GetFillMode() == FILLED_WITH_BG_BODYCOLOR )
|
||||
{
|
||||
COLOR4D color = m_schSettings.GetLayerColor( LAYER_DEVICE_BACKGROUND );
|
||||
|
||||
|
@ -297,8 +283,9 @@ void SCH_PAINTER::setColors( const LIB_ITEM* aItem, bool aBackground )
|
|||
m_gal->SetFillColor( color );
|
||||
|
||||
m_gal->SetIsStroke( false );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
else if( aLayer == LAYER_DEVICE )
|
||||
{
|
||||
COLOR4D color = m_schSettings.GetLayerColor( LAYER_DEVICE );
|
||||
|
||||
|
@ -311,7 +298,10 @@ void SCH_PAINTER::setColors( const LIB_ITEM* aItem, bool aBackground )
|
|||
|
||||
m_gal->SetIsFill( aItem->GetFillMode() == FILLED_SHAPE );
|
||||
m_gal->SetFillColor( color );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -320,15 +310,8 @@ void SCH_PAINTER::draw( LIB_RECTANGLE *aRect, int aLayer )
|
|||
if( !isUnitAndConversionShown( aRect ) )
|
||||
return;
|
||||
|
||||
if( aRect->GetFillMode() == FILLED_WITH_BG_BODYCOLOR )
|
||||
{
|
||||
setColors( aRect, true );
|
||||
if( setColors( aRect, aLayer ) )
|
||||
m_gal->DrawRectangle( mapCoords( aRect->GetPosition() ), mapCoords( aRect->GetEnd() ) );
|
||||
m_gal->AdvanceDepth();
|
||||
}
|
||||
|
||||
setColors( aRect, false );
|
||||
m_gal->DrawRectangle( mapCoords( aRect->GetPosition() ), mapCoords( aRect->GetEnd() ) );
|
||||
|
||||
}
|
||||
|
||||
|
@ -338,15 +321,8 @@ void SCH_PAINTER::draw( LIB_CIRCLE *aCircle, int aLayer )
|
|||
if( !isUnitAndConversionShown( aCircle ) )
|
||||
return;
|
||||
|
||||
if( aCircle->GetFillMode() == FILLED_WITH_BG_BODYCOLOR )
|
||||
{
|
||||
setColors( aCircle, true );
|
||||
if( setColors( aCircle, aLayer ) )
|
||||
m_gal->DrawCircle( mapCoords( aCircle->GetPosition() ), aCircle->GetRadius() );
|
||||
m_gal->AdvanceDepth();
|
||||
}
|
||||
|
||||
setColors( aCircle, false );
|
||||
m_gal->DrawCircle( mapCoords( aCircle->GetPosition() ), aCircle->GetRadius() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -366,14 +342,8 @@ void SCH_PAINTER::draw( LIB_ARC *aArc, int aLayer )
|
|||
|
||||
VECTOR2D pos = mapCoords( aArc->GetPosition() );
|
||||
|
||||
if( aArc->GetFillMode() == FILLED_WITH_BG_BODYCOLOR )
|
||||
{
|
||||
setColors( aArc, true );
|
||||
if( setColors( aArc, aLayer ) )
|
||||
m_gal->DrawArc( pos, aArc->GetRadius(), sa, ea );
|
||||
}
|
||||
|
||||
setColors( aArc, false );
|
||||
m_gal->DrawArc( pos, aArc->GetRadius(), sa, ea );
|
||||
}
|
||||
|
||||
|
||||
|
@ -382,38 +352,31 @@ void SCH_PAINTER::draw( LIB_POLYLINE *aLine, int aLayer )
|
|||
if( !isUnitAndConversionShown( aLine ) )
|
||||
return;
|
||||
|
||||
|
||||
const std::vector<wxPoint>& pts = aLine->GetPolyPoints();
|
||||
std::deque<VECTOR2D> vtx;
|
||||
|
||||
for( auto p : pts )
|
||||
vtx.push_back( mapCoords( p ) );
|
||||
|
||||
if( aLine->GetFillMode() == FILLED_WITH_BG_BODYCOLOR )
|
||||
{
|
||||
setColors( aLine, true );
|
||||
if( setColors( aLine, aLayer ) )
|
||||
m_gal->DrawPolygon( vtx );
|
||||
m_gal->AdvanceDepth();
|
||||
}
|
||||
|
||||
setColors( aLine, false );
|
||||
m_gal->DrawPolygon( vtx );
|
||||
}
|
||||
|
||||
|
||||
void SCH_PAINTER::draw( LIB_FIELD *aField, int aLayer )
|
||||
{
|
||||
// Must check layer as fields are sometimes drawn by their parent rather than
|
||||
// directly from the view.
|
||||
int layers[KIGFX::VIEW::VIEW_MAX_LAYERS], layers_count;
|
||||
aField->ViewGetLayers( layers, layers_count );
|
||||
|
||||
if( aLayer != layers[0] )
|
||||
return;
|
||||
|
||||
if( !isUnitAndConversionShown( aField ) )
|
||||
return;
|
||||
|
||||
COLOR4D color;
|
||||
|
||||
switch( aField->GetId() )
|
||||
{
|
||||
case REFERENCE: color = m_schSettings.GetLayerColor( LAYER_REFERENCEPART ); break;
|
||||
case VALUE: color = m_schSettings.GetLayerColor( LAYER_VALUEPART ); break;
|
||||
default: color = m_schSettings.GetLayerColor( LAYER_FIELDS ); break;
|
||||
}
|
||||
COLOR4D color = aField->GetDefaultColor();
|
||||
|
||||
if( aField->IsMoving() )
|
||||
color = selectedBrightening( color );
|
||||
|
@ -515,6 +478,9 @@ static void drawPinDanglingSymbol( GAL* aGal, const VECTOR2I& aPos, const COLOR4
|
|||
|
||||
void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer, bool isDangling, bool isMoving )
|
||||
{
|
||||
if( aLayer != LAYER_DEVICE )
|
||||
return;
|
||||
|
||||
if( !isUnitAndConversionShown( aPin ) )
|
||||
return;
|
||||
|
||||
|
@ -1241,58 +1207,70 @@ void SCH_PAINTER::draw( SCH_HIERLABEL *aLabel, int aLayer )
|
|||
|
||||
void SCH_PAINTER::draw( SCH_SHEET *aSheet, int aLayer )
|
||||
{
|
||||
VECTOR2D pos_sheetname = aSheet->GetSheetNamePosition();
|
||||
VECTOR2D pos_filename = aSheet->GetFileNamePosition();
|
||||
VECTOR2D pos = aSheet->GetPosition();
|
||||
VECTOR2D size = aSheet->GetSize();
|
||||
|
||||
m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_SHEET ) );
|
||||
|
||||
if( aSheet->IsMoving() ) // Gives a filled background when moving for a better look
|
||||
if( aLayer == LAYER_SHEET_BACKGROUND )
|
||||
{
|
||||
// Select a fill color working well with black and white background color,
|
||||
// both in Opengl and Cairo
|
||||
m_gal->SetFillColor( COLOR4D( 0.1, 0.5, 0.5, 0.3 ) );
|
||||
m_gal->SetIsFill( true );
|
||||
m_gal->SetIsStroke( false );
|
||||
|
||||
if( aSheet->IsMoving() ) // Gives a filled background when moving for a better look
|
||||
{
|
||||
// Select a fill color working well with black and white background color,
|
||||
// both in Opengl and Cairo
|
||||
m_gal->SetFillColor( COLOR4D( 0.1, 0.5, 0.5, 0.3 ) );
|
||||
m_gal->SetIsFill( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Could be modified later, when sheets can have their own fill color
|
||||
return;
|
||||
}
|
||||
|
||||
m_gal->DrawRectangle( pos, pos + size );
|
||||
}
|
||||
else
|
||||
else if( aLayer == LAYER_SHEET )
|
||||
{
|
||||
// Could be modified later, when sheets can have their own fill color
|
||||
m_gal->SetIsFill ( false );
|
||||
m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_SHEET ) );
|
||||
m_gal->SetIsStroke( true );
|
||||
|
||||
m_gal->SetIsFill( false );
|
||||
|
||||
m_gal->DrawRectangle( pos, pos + size );
|
||||
|
||||
VECTOR2D pos_sheetname = aSheet->GetSheetNamePosition();
|
||||
VECTOR2D pos_filename = aSheet->GetFileNamePosition();
|
||||
double nameAngle = 0.0;
|
||||
|
||||
if( aSheet->IsVerticalOrientation() )
|
||||
nameAngle = -M_PI/2;
|
||||
|
||||
m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_SHEETNAME ) );
|
||||
|
||||
auto text = wxT( "Sheet: " ) + aSheet->GetName();
|
||||
|
||||
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
|
||||
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
||||
|
||||
auto txtSize = aSheet->GetSheetNameSize();
|
||||
|
||||
m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
|
||||
m_gal->SetFontBold( false );
|
||||
m_gal->SetFontItalic( false );
|
||||
|
||||
m_gal->StrokeText( text, pos_sheetname, nameAngle );
|
||||
|
||||
txtSize = aSheet->GetFileNameSize();
|
||||
m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
|
||||
m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_SHEETFILENAME ) );
|
||||
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_TOP );
|
||||
|
||||
text = wxT( "File: " ) + aSheet->GetFileName();
|
||||
m_gal->StrokeText( text, pos_filename, nameAngle );
|
||||
|
||||
for( auto& sheetPin : aSheet->GetPins() )
|
||||
draw( static_cast<SCH_HIERLABEL*>( &sheetPin ), aLayer );
|
||||
}
|
||||
m_gal->SetIsStroke( true );
|
||||
m_gal->DrawRectangle( pos, pos + size );
|
||||
|
||||
auto nameAngle = 0.0;
|
||||
|
||||
if( aSheet->IsVerticalOrientation() )
|
||||
nameAngle = -M_PI/2;
|
||||
|
||||
m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_SHEETNAME ) );
|
||||
|
||||
auto text = wxT( "Sheet: " ) + aSheet->GetName();
|
||||
|
||||
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
|
||||
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
||||
|
||||
auto txtSize = aSheet->GetSheetNameSize();
|
||||
|
||||
m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
|
||||
m_gal->SetFontBold( false );
|
||||
m_gal->SetFontItalic( false );
|
||||
|
||||
m_gal->StrokeText( text, pos_sheetname, nameAngle );
|
||||
|
||||
txtSize = aSheet->GetFileNameSize();
|
||||
m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
|
||||
m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_SHEETFILENAME ) );
|
||||
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_TOP );
|
||||
|
||||
text = wxT( "File: " ) + aSheet->GetFileName();
|
||||
m_gal->StrokeText( text, pos_filename, nameAngle );
|
||||
|
||||
for( auto& sheetPin : aSheet->GetPins() )
|
||||
draw( static_cast<SCH_HIERLABEL*>( &sheetPin ), aLayer );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ private:
|
|||
|
||||
bool isUnitAndConversionShown( const LIB_ITEM* aItem );
|
||||
|
||||
void setColors( const LIB_ITEM* aItem, bool aBackground );
|
||||
bool setColors( const LIB_ITEM* aItem, int aLayer );
|
||||
|
||||
void triLine ( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c );
|
||||
|
||||
|
|
|
@ -96,29 +96,32 @@ void SCH_PREVIEW_PANEL::OnShow()
|
|||
|
||||
void SCH_PREVIEW_PANEL::setDefaultLayerOrder()
|
||||
{
|
||||
/* for( LAYER_NUM i = 0; (unsigned) i < sizeof( GAL_LAYER_ORDER ) / sizeof( LAYER_NUM ); ++i )
|
||||
for( LAYER_NUM i = 0; (unsigned) i < sizeof( SCH_LAYER_ORDER ) / sizeof( LAYER_NUM ); ++i )
|
||||
{
|
||||
LAYER_NUM layer = GAL_LAYER_ORDER[i];
|
||||
LAYER_NUM layer = SCH_LAYER_ORDER[i];
|
||||
wxASSERT( layer < KIGFX::VIEW::VIEW_MAX_LAYERS );
|
||||
|
||||
m_view->SetLayerOrder( layer, i );
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SCH_PREVIEW_PANEL::setDefaultLayerDeps()
|
||||
{
|
||||
// caching makes no sense for Cairo and other software renderers
|
||||
auto target = KIGFX::TARGET_NONCACHED;
|
||||
auto target = m_backend == GAL_TYPE_OPENGL ? KIGFX::TARGET_CACHED : KIGFX::TARGET_NONCACHED;
|
||||
|
||||
for( int i = 0; i < KIGFX::VIEW::VIEW_MAX_LAYERS; i++ )
|
||||
m_view->SetLayerTarget( i, target );
|
||||
|
||||
m_view->SetLayerTarget( LAYER_GP_OVERLAY , KIGFX::TARGET_OVERLAY );
|
||||
|
||||
m_view->SetLayerDisplayOnly( LAYER_GP_OVERLAY ) ;
|
||||
|
||||
m_view->SetLayerTarget( LAYER_SELECT_OVERLAY , KIGFX::TARGET_OVERLAY );
|
||||
m_view->SetLayerDisplayOnly( LAYER_SELECT_OVERLAY ) ;
|
||||
|
||||
m_view->SetLayerTarget( LAYER_WORKSHEET , KIGFX::TARGET_NONCACHED );
|
||||
m_view->SetLayerDisplayOnly( LAYER_WORKSHEET ) ;
|
||||
m_view->SetLayerDisplayOnly( LAYER_DRC );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -424,6 +424,14 @@ wxPoint SCH_SHEET::GetFileNamePosition()
|
|||
}
|
||||
|
||||
|
||||
void SCH_SHEET::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
{
|
||||
aCount = 2;
|
||||
aLayers[0] = LAYER_SHEET;
|
||||
aLayers[1] = LAYER_SHEET_BACKGROUND;
|
||||
}
|
||||
|
||||
|
||||
void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
||||
const wxPoint& aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor )
|
||||
{
|
||||
|
|
|
@ -544,6 +544,8 @@ public:
|
|||
|
||||
SCH_ITEM& operator=( const SCH_ITEM& aSheet );
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
|
||||
wxPoint GetPosition() const override { return m_pos; }
|
||||
|
||||
void SetPosition( const wxPoint& aPosition ) override;
|
||||
|
|
|
@ -52,31 +52,6 @@ SCH_VIEW::~SCH_VIEW()
|
|||
}
|
||||
|
||||
|
||||
static const LAYER_NUM SCH_LAYER_ORDER[] =
|
||||
{
|
||||
LAYER_GP_OVERLAY,
|
||||
LAYER_DRC,
|
||||
LAYER_WORKSHEET
|
||||
};
|
||||
|
||||
|
||||
void SCH_VIEW::Add( VIEW_ITEM* aItem, int aDrawPriority )
|
||||
{
|
||||
// store the bounding box as eeschema can change them at weird moments (i.e.)
|
||||
// while changing/resolving library references, resulting in incorrect bboxes
|
||||
// and invisible components
|
||||
m_cachedBBoxes[ aItem ] = aItem->ViewBBox();
|
||||
|
||||
VIEW::Add( aItem, aDrawPriority );
|
||||
}
|
||||
|
||||
void SCH_VIEW::Remove( VIEW_ITEM* aItem )
|
||||
{
|
||||
m_cachedBBoxes.erase( aItem );
|
||||
|
||||
VIEW::Remove( aItem );
|
||||
}
|
||||
|
||||
void SCH_VIEW::DisplaySheet( SCH_SCREEN *aSheet )
|
||||
{
|
||||
|
||||
|
@ -186,48 +161,5 @@ void SCH_VIEW::HideWorksheet()
|
|||
}
|
||||
|
||||
|
||||
void SCH_VIEW::Redraw()
|
||||
{
|
||||
std::set<EDA_ITEM*> toUpdate;
|
||||
BOX2I rect;
|
||||
rect.SetMaximum();
|
||||
|
||||
auto visitor = [&]( VIEW_ITEM* aItem ) -> bool {
|
||||
auto cached = m_cachedBBoxes.find( aItem );
|
||||
const auto bb = aItem->ViewBBox();
|
||||
|
||||
if( cached == m_cachedBBoxes.end() )
|
||||
{
|
||||
m_cachedBBoxes[aItem] = bb;
|
||||
return true;
|
||||
}
|
||||
|
||||
if( bb != cached->second )
|
||||
{
|
||||
Update( aItem, KIGFX::GEOMETRY );
|
||||
m_cachedBBoxes[aItem] = bb;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/* HACK: since eeschema doesn't have any notification mechanism for changing sch items' geometry,
|
||||
the bounding boxes may become inconsistend with the VIEW Rtree causing disappearing components
|
||||
(depending on the zoom level). This code keeps a cache of bboxes and checks (at every redraw) if
|
||||
they haven't changed wrs to the cached version. It eats up some extra CPU cycles, but for the
|
||||
complexity of schematics's graphics it has negligible effect on perforamance.
|
||||
*/
|
||||
|
||||
for( auto i = m_orderedLayers.rbegin(); i != m_orderedLayers.rend(); ++i )
|
||||
{
|
||||
( *i )->items->Query( rect, visitor );
|
||||
}
|
||||
|
||||
|
||||
m_gal->EnableDepthTest( false );
|
||||
|
||||
VIEW::Redraw();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -13,6 +13,23 @@ class SCH_SHEET;
|
|||
class SCH_SCREEN;
|
||||
class LIB_PART;
|
||||
|
||||
|
||||
static const LAYER_NUM SCH_LAYER_ORDER[] =
|
||||
{
|
||||
LAYER_GP_OVERLAY, LAYER_SELECT_OVERLAY,
|
||||
LAYER_ERC_ERR, LAYER_ERC_WARN,
|
||||
LAYER_REFERENCEPART, LAYER_VALUEPART, LAYER_FIELDS,
|
||||
LAYER_JUNCTION,
|
||||
LAYER_WIRE, LAYER_BUS,
|
||||
LAYER_DEVICE,
|
||||
LAYER_DEVICE_BACKGROUND,
|
||||
LAYER_NOTES,
|
||||
LAYER_SHEET,
|
||||
LAYER_SHEET_BACKGROUND,
|
||||
LAYER_WORKSHEET
|
||||
};
|
||||
|
||||
|
||||
namespace KIGFX
|
||||
{
|
||||
class VIEW_GROUP;
|
||||
|
@ -29,9 +46,6 @@ public:
|
|||
SCH_VIEW( bool aIsDynamic );
|
||||
~SCH_VIEW();
|
||||
|
||||
virtual void Add( VIEW_ITEM* aItem, int aDrawPriority = -1 ) override;
|
||||
virtual void Remove( VIEW_ITEM* aItem ) override;
|
||||
|
||||
void DisplaySheet( SCH_SHEET *aSheet );
|
||||
void DisplaySheet( SCH_SCREEN *aSheet );
|
||||
void DisplayComponent( LIB_PART *aPart );
|
||||
|
@ -49,14 +63,11 @@ public:
|
|||
void ClearHiddenFlags();
|
||||
void HideWorksheet();
|
||||
|
||||
virtual void Redraw() override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<WORKSHEET_VIEWITEM> m_worksheet;
|
||||
std::unique_ptr<KIGFX::PREVIEW::SELECTION_AREA> m_selectionArea;
|
||||
std::unique_ptr<KIGFX::VIEW_GROUP> m_preview;
|
||||
std::vector<EDA_ITEM *> m_ownedItems;
|
||||
std::unordered_map<VIEW_ITEM*, BOX2I> m_cachedBBoxes;
|
||||
};
|
||||
|
||||
}; // namespace
|
||||
|
|
|
@ -253,6 +253,7 @@ enum SCH_LAYER_ID: int
|
|||
LAYER_ERC_WARN,
|
||||
LAYER_ERC_ERR,
|
||||
LAYER_DEVICE_BACKGROUND,
|
||||
LAYER_SHEET_BACKGROUND,
|
||||
LAYER_SCHEMATIC_GRID,
|
||||
LAYER_SCHEMATIC_BACKGROUND,
|
||||
LAYER_SCHEMATIC_CURSOR,
|
||||
|
|
|
@ -107,6 +107,13 @@ int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
|
|||
pad->IncrementPadName( true, true );
|
||||
return std::unique_ptr<BOARD_ITEM>( pad );
|
||||
}
|
||||
|
||||
void PlaceItem( BOARD_ITEM *aItem, BOARD_COMMIT& aCommit ) override
|
||||
{
|
||||
auto pad = dynamic_cast<D_PAD*>( aItem );
|
||||
m_frame->Export_Pad_Settings( pad );
|
||||
aCommit.Add( aItem );
|
||||
}
|
||||
};
|
||||
|
||||
PAD_PLACER placer;
|
||||
|
|
|
@ -180,8 +180,7 @@ void PCB_TOOL::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer,
|
|||
|
||||
if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
|
||||
{
|
||||
const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
|
||||
*frame(), *evt );
|
||||
const int rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
|
||||
newItem->Rotate( newItem->GetPosition(), rotationAngle );
|
||||
view()->Update( &preview );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue