Update dangling flags in color settings' preview.
This commit is contained in:
parent
c7e6c273b4
commit
b9596a0a5d
|
@ -223,21 +223,12 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::onNewThemeSelected()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class SCH_BUS_WIRE_ENTRY_PREVIEW_ITEM : public SCH_BUS_WIRE_ENTRY
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SCH_BUS_WIRE_ENTRY_PREVIEW_ITEM() :
|
|
||||||
SCH_BUS_WIRE_ENTRY()
|
|
||||||
{
|
|
||||||
m_isDanglingStart = m_isDanglingEnd = false;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
|
void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
|
||||||
{
|
{
|
||||||
KIGFX::VIEW* view = m_preview->GetView();
|
KIGFX::VIEW* view = m_preview->GetView();
|
||||||
|
|
||||||
|
std::vector<DANGLING_END_ITEM> endPoints;
|
||||||
|
|
||||||
m_page = new PAGE_INFO( PAGE_INFO::Custom );
|
m_page = new PAGE_INFO( PAGE_INFO::Custom );
|
||||||
m_titleBlock = new TITLE_BLOCK;
|
m_titleBlock = new TITLE_BLOCK;
|
||||||
m_titleBlock->SetTitle( _( "Color Preview" ) );
|
m_titleBlock->SetTitle( _( "Color Preview" ) );
|
||||||
|
@ -246,11 +237,11 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
|
||||||
m_page->SetHeightMils( 5000 );
|
m_page->SetHeightMils( 5000 );
|
||||||
m_page->SetWidthMils( 6000 );
|
m_page->SetWidthMils( 6000 );
|
||||||
|
|
||||||
m_drawingSheet = new DS_PROXY_VIEW_ITEM((int) IU_PER_MILS, m_page, nullptr, m_titleBlock );
|
m_drawingSheet = new DS_PROXY_VIEW_ITEM( (int) IU_PER_MILS, m_page, nullptr, m_titleBlock );
|
||||||
m_drawingSheet->SetColorLayer( LAYER_SCHEMATIC_DRAWINGSHEET );
|
m_drawingSheet->SetColorLayer( LAYER_SCHEMATIC_DRAWINGSHEET );
|
||||||
view->Add( m_drawingSheet );
|
view->Add( m_drawingSheet );
|
||||||
|
|
||||||
// NOTE: It would be nice to parse a schematic file here.
|
// TODO: It would be nice to parse a schematic file here.
|
||||||
// This is created from the color_settings.sch file in demos folder
|
// This is created from the color_settings.sch file in demos folder
|
||||||
|
|
||||||
auto addItem = [&]( EDA_ITEM* aItem )
|
auto addItem = [&]( EDA_ITEM* aItem )
|
||||||
|
@ -276,7 +267,7 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
|
||||||
{ LAYER_NOTES, { { 2950, 2300 }, { 2350, 2300 } } }
|
{ LAYER_NOTES, { { 2950, 2300 }, { 2350, 2300 } } }
|
||||||
};
|
};
|
||||||
|
|
||||||
for( const auto& line : lines )
|
for( const std::pair<SCH_LAYER_ID, std::pair<wxPoint, wxPoint>>& line : lines )
|
||||||
{
|
{
|
||||||
SCH_LINE* wire = new SCH_LINE;
|
SCH_LINE* wire = new SCH_LINE;
|
||||||
wire->SetLayer( line.first );
|
wire->SetLayer( line.first );
|
||||||
|
@ -293,11 +284,11 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
|
||||||
nc->SetPosition( MILS_POINT( 2525, 1300 ) );
|
nc->SetPosition( MILS_POINT( 2525, 1300 ) );
|
||||||
addItem( nc );
|
addItem( nc );
|
||||||
|
|
||||||
SCH_BUS_WIRE_ENTRY* e1 = new SCH_BUS_WIRE_ENTRY_PREVIEW_ITEM;
|
SCH_BUS_WIRE_ENTRY* e1 = new SCH_BUS_WIRE_ENTRY;
|
||||||
e1->SetPosition( MILS_POINT( 1850, 1400 ) );
|
e1->SetPosition( MILS_POINT( 1850, 1400 ) );
|
||||||
addItem( e1 );
|
addItem( e1 );
|
||||||
|
|
||||||
SCH_BUS_WIRE_ENTRY* e2 = new SCH_BUS_WIRE_ENTRY_PREVIEW_ITEM;
|
SCH_BUS_WIRE_ENTRY* e2 = new SCH_BUS_WIRE_ENTRY;
|
||||||
e2->SetPosition( MILS_POINT( 1850, 2500 ) );
|
e2->SetPosition( MILS_POINT( 1850, 2500 ) );
|
||||||
addItem( e2 );
|
addItem( e2 );
|
||||||
|
|
||||||
|
@ -315,7 +306,7 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
|
||||||
t3->SetIsDangling( false );
|
t3->SetIsDangling( false );
|
||||||
addItem( t3 );
|
addItem( t3 );
|
||||||
|
|
||||||
SCH_GLOBALLABEL* t4 = new SCH_GLOBALLABEL( MILS_POINT( 1750, 1400 ), wxT( "GLOBAL[3..0]" ) );
|
SCH_GLOBALLABEL* t4 = new SCH_GLOBALLABEL( MILS_POINT( 1750, 1400 ), wxT( "GLOBAL[0..3]" ) );
|
||||||
t4->SetLabelSpinStyle( LABEL_SPIN_STYLE::SPIN::LEFT );
|
t4->SetLabelSpinStyle( LABEL_SPIN_STYLE::SPIN::LEFT );
|
||||||
t4->SetIsDangling( false );
|
t4->SetIsDangling( false );
|
||||||
addItem( t4 );
|
addItem( t4 );
|
||||||
|
@ -331,6 +322,12 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
|
||||||
t2->SetSelected();
|
t2->SetSelected();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
auto mapLibItemPosition =
|
||||||
|
[]( const wxPoint& aLibPosition ) -> wxPoint
|
||||||
|
{
|
||||||
|
return wxPoint( aLibPosition.x, -aLibPosition.y );
|
||||||
|
};
|
||||||
|
|
||||||
LIB_SYMBOL* symbol = new LIB_SYMBOL( wxEmptyString );
|
LIB_SYMBOL* symbol = new LIB_SYMBOL( wxEmptyString );
|
||||||
wxPoint p( 2625, -1600 );
|
wxPoint p( 2625, -1600 );
|
||||||
|
|
||||||
|
@ -365,35 +362,38 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
|
||||||
|
|
||||||
LIB_PIN* pin = new LIB_PIN( symbol );
|
LIB_PIN* pin = new LIB_PIN( symbol );
|
||||||
|
|
||||||
pin->SetPosition( MILS_POINT( p.x - 200, p.y + 100 ) );
|
pin->SetPosition( MILS_POINT( p.x - 300, p.y + 100 ) );
|
||||||
pin->SetLength( Mils2iu( 100 ) );
|
pin->SetLength( Mils2iu( 100 ) );
|
||||||
pin->SetOrientation( PIN_LEFT );
|
pin->SetOrientation( PIN_RIGHT );
|
||||||
pin->SetType( ELECTRICAL_PINTYPE::PT_INPUT );
|
pin->SetType( ELECTRICAL_PINTYPE::PT_INPUT );
|
||||||
pin->SetNumber( wxT( "1" ) );
|
pin->SetNumber( wxT( "1" ) );
|
||||||
pin->SetName( wxT( "-" ) );
|
pin->SetName( wxT( "-" ) );
|
||||||
|
|
||||||
|
endPoints.emplace_back( PIN_END, pin, mapLibItemPosition( pin->GetPosition() ) );
|
||||||
symbol->AddDrawItem( pin );
|
symbol->AddDrawItem( pin );
|
||||||
|
|
||||||
pin = new LIB_PIN( symbol );
|
pin = new LIB_PIN( symbol );
|
||||||
|
|
||||||
pin->SetPosition( MILS_POINT( p.x - 200, p.y - 100 ) );
|
pin->SetPosition( MILS_POINT( p.x - 300, p.y - 100 ) );
|
||||||
pin->SetLength( Mils2iu( 100 ) );
|
pin->SetLength( Mils2iu( 100 ) );
|
||||||
pin->SetOrientation( PIN_LEFT );
|
pin->SetOrientation( PIN_RIGHT );
|
||||||
pin->SetType( ELECTRICAL_PINTYPE::PT_INPUT );
|
pin->SetType( ELECTRICAL_PINTYPE::PT_INPUT );
|
||||||
pin->SetNumber( wxT( "2" ) );
|
pin->SetNumber( wxT( "2" ) );
|
||||||
pin->SetName( wxT( "+" ) );
|
pin->SetName( wxT( "+" ) );
|
||||||
|
|
||||||
|
endPoints.emplace_back( PIN_END, pin, mapLibItemPosition( pin->GetPosition() ) );
|
||||||
symbol->AddDrawItem( pin );
|
symbol->AddDrawItem( pin );
|
||||||
|
|
||||||
pin = new LIB_PIN( symbol );
|
pin = new LIB_PIN( symbol );
|
||||||
|
|
||||||
pin->SetPosition( MILS_POINT( p.x + 200, p.y ) );
|
pin->SetPosition( MILS_POINT( p.x + 300, p.y ) );
|
||||||
pin->SetLength( Mils2iu( 100 ) );
|
pin->SetLength( Mils2iu( 100 ) );
|
||||||
pin->SetOrientation( PIN_RIGHT );
|
pin->SetOrientation( PIN_LEFT );
|
||||||
pin->SetType( ELECTRICAL_PINTYPE::PT_OUTPUT );
|
pin->SetType( ELECTRICAL_PINTYPE::PT_OUTPUT );
|
||||||
pin->SetNumber( wxT( "3" ) );
|
pin->SetNumber( wxT( "3" ) );
|
||||||
pin->SetName( wxT( "OUT" ) );
|
pin->SetName( wxT( "OUT" ) );
|
||||||
|
|
||||||
|
endPoints.emplace_back( PIN_END, pin, mapLibItemPosition( pin->GetPosition() ) );
|
||||||
symbol->AddDrawItem( pin );
|
symbol->AddDrawItem( pin );
|
||||||
|
|
||||||
addItem( symbol );
|
addItem( symbol );
|
||||||
|
@ -409,6 +409,22 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
|
||||||
SCH_SHEET_PIN* sp = new SCH_SHEET_PIN( s, MILS_POINT( 4500, 1500 ), wxT( "SHEET PIN" ) );
|
SCH_SHEET_PIN* sp = new SCH_SHEET_PIN( s, MILS_POINT( 4500, 1500 ), wxT( "SHEET PIN" ) );
|
||||||
addItem( sp );
|
addItem( sp );
|
||||||
|
|
||||||
|
for( EDA_ITEM* item : m_previewItems )
|
||||||
|
{
|
||||||
|
SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item );
|
||||||
|
|
||||||
|
if( sch_item && sch_item->IsConnectable() )
|
||||||
|
sch_item->GetEndPoints( endPoints );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( EDA_ITEM* item : m_previewItems )
|
||||||
|
{
|
||||||
|
SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item );
|
||||||
|
|
||||||
|
if( sch_item && sch_item->IsConnectable() )
|
||||||
|
sch_item->UpdateDanglingState( endPoints, nullptr );
|
||||||
|
}
|
||||||
|
|
||||||
zoomFitPreview();
|
zoomFitPreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,7 @@ namespace KIGFX
|
||||||
{
|
{
|
||||||
|
|
||||||
SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() :
|
SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() :
|
||||||
|
m_IsSymbolEditor( false ),
|
||||||
m_ShowUnit( 0 ),
|
m_ShowUnit( 0 ),
|
||||||
m_ShowConvert( 0 ),
|
m_ShowConvert( 0 ),
|
||||||
m_ShowHiddenText( true ),
|
m_ShowHiddenText( true ),
|
||||||
|
@ -783,11 +784,7 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
||||||
#if 1
|
bool dangling = m_schSettings.m_IsSymbolEditor || aPin->HasFlag( IS_DANGLING );
|
||||||
bool dangling = !m_schematic || aPin->HasFlag(IS_DANGLING );
|
|
||||||
#else
|
|
||||||
bool dangling = aPin->HasFlag( IS_DANGLING );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( drawingShadows && !aPin->IsSelected() )
|
if( drawingShadows && !aPin->IsSelected() )
|
||||||
return;
|
return;
|
||||||
|
@ -988,7 +985,7 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
|
||||||
nameStrokeWidth = Clamp_Text_PenSize( nameStrokeWidth, aPin->GetNameTextSize(), false );
|
nameStrokeWidth = Clamp_Text_PenSize( nameStrokeWidth, aPin->GetNameTextSize(), false );
|
||||||
numStrokeWidth = Clamp_Text_PenSize( numStrokeWidth, aPin->GetNumberTextSize(), false );
|
numStrokeWidth = Clamp_Text_PenSize( numStrokeWidth, aPin->GetNumberTextSize(), false );
|
||||||
|
|
||||||
#define PIN_TEXT_MARGIN 4.0
|
int PIN_TEXT_MARGIN = KiROUND( 24 * m_schSettings.m_TextOffsetRatio );
|
||||||
|
|
||||||
// Four locations around a pin where text can be drawn
|
// Four locations around a pin where text can be drawn
|
||||||
enum { INSIDE = 0, OUTSIDE, ABOVE, BELOW };
|
enum { INSIDE = 0, OUTSIDE, ABOVE, BELOW };
|
||||||
|
@ -1810,14 +1807,13 @@ void SCH_PAINTER::draw( const SCH_NO_CONNECT *aNC, int aLayer )
|
||||||
|
|
||||||
void SCH_PAINTER::draw( const SCH_BUS_ENTRY_BASE *aEntry, int aLayer )
|
void SCH_PAINTER::draw( const SCH_BUS_ENTRY_BASE *aEntry, int aLayer )
|
||||||
{
|
{
|
||||||
SCH_LINE line;
|
SCH_LAYER_ID layer = aEntry->Type() == SCH_BUS_WIRE_ENTRY_T ? LAYER_WIRE : LAYER_BUS;
|
||||||
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
SCH_LINE line( wxPoint(), layer );
|
||||||
|
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
|
||||||
|
|
||||||
if( drawingShadows && !aEntry->IsSelected() )
|
if( drawingShadows && !aEntry->IsSelected() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
line.SetLayer( aEntry->Type() == SCH_BUS_WIRE_ENTRY_T ? LAYER_WIRE : LAYER_BUS );
|
|
||||||
|
|
||||||
if( aEntry->IsSelected() )
|
if( aEntry->IsSelected() )
|
||||||
line.SetSelected();
|
line.SetSelected();
|
||||||
else if( aEntry->IsBrightened() )
|
else if( aEntry->IsBrightened() )
|
||||||
|
|
|
@ -105,6 +105,8 @@ public:
|
||||||
|
|
||||||
const COLOR4D& GetCursorColor() override { return m_layerColors[ LAYER_SCHEMATIC_CURSOR ]; }
|
const COLOR4D& GetCursorColor() override { return m_layerColors[ LAYER_SCHEMATIC_CURSOR ]; }
|
||||||
|
|
||||||
|
bool m_IsSymbolEditor;
|
||||||
|
|
||||||
int m_ShowUnit; // Show all units if 0
|
int m_ShowUnit; // Show all units if 0
|
||||||
int m_ShowConvert; // Show all conversions if 0
|
int m_ShowConvert; // Show all conversions if 0
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,11 @@ SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL( wxWindow* aParentWindow, wxWindowID aWindo
|
||||||
m_gal->SetWorldUnitLength( SCH_WORLD_UNIT );
|
m_gal->SetWorldUnitLength( SCH_WORLD_UNIT );
|
||||||
|
|
||||||
m_painter.reset( new KIGFX::SCH_PAINTER( m_gal ) );
|
m_painter.reset( new KIGFX::SCH_PAINTER( m_gal ) );
|
||||||
m_painter->GetSettings()->LoadColors( Pgm().GetSettingsManager().GetColorSettings() );
|
|
||||||
|
auto* renderSettings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( m_painter->GetSettings() );
|
||||||
|
renderSettings->LoadColors( Pgm().GetSettingsManager().GetColorSettings() );
|
||||||
|
renderSettings->m_ShowPinsElectricalType = false;
|
||||||
|
renderSettings->m_TextOffsetRatio = 0.30;
|
||||||
|
|
||||||
m_view->SetPainter( m_painter.get() );
|
m_view->SetPainter( m_painter.get() );
|
||||||
// This fixes the zoom in and zoom out limits:
|
// This fixes the zoom in and zoom out limits:
|
||||||
|
|
|
@ -137,6 +137,7 @@ SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||||
GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
|
GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
|
||||||
|
|
||||||
GetRenderSettings()->LoadColors( GetColorSettings() );
|
GetRenderSettings()->LoadColors( GetColorSettings() );
|
||||||
|
GetRenderSettings()->m_IsSymbolEditor = true;
|
||||||
GetCanvas()->GetGAL()->SetAxesColor( m_colorSettings->GetColor( LAYER_SCHEMATIC_GRID_AXES ) );
|
GetCanvas()->GetGAL()->SetAxesColor( m_colorSettings->GetColor( LAYER_SCHEMATIC_GRID_AXES ) );
|
||||||
|
|
||||||
setupTools();
|
setupTools();
|
||||||
|
|
Loading…
Reference in New Issue