From ee6acb983a62c37742513991749c22845c3ef3c7 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 1 Aug 2020 20:48:39 +0100 Subject: [PATCH] Build out the rest of the schematic preview for colors editor. Fixes https://gitlab.com/kicad/code/kicad/issues/5029 --- .../dialogs/panel_eeschema_color_settings.cpp | 58 +++++++++++++++++-- eeschema/sch_preview_panel.cpp | 2 +- 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/eeschema/dialogs/panel_eeschema_color_settings.cpp b/eeschema/dialogs/panel_eeschema_color_settings.cpp index 3050a64ef1..96fc0ae940 100644 --- a/eeschema/dialogs/panel_eeschema_color_settings.cpp +++ b/eeschema/dialogs/panel_eeschema_color_settings.cpp @@ -227,7 +227,7 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems() m_titleBlock = new TITLE_BLOCK; m_page->SetHeightMils( 5000 ); - m_page->SetWidthMils( 5500 ); + m_page->SetWidthMils( 6000 ); m_ws = new KIGFX::WS_PROXY_VIEW_ITEM( (int) IU_PER_MILS, m_page, nullptr, m_titleBlock ); m_ws->SetColorLayer( LAYER_SCHEMATIC_WORKSHEET ); @@ -286,12 +286,12 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems() t1->SetLabelSpinStyle( LABEL_SPIN_STYLE::SPIN::LEFT ); addItem( t1 ); - auto t2 = new SCH_LABEL( wxPoint( Mils2iu( 1975 ), Mils2iu( 1500 ) ), wxT( "GLOBAL0" ) ); + auto t2 = new SCH_LABEL( wxPoint( Mils2iu( 1975 ), Mils2iu( 1500 ) ), wxT( "LABEL_{0}" ) ); t2->SetLabelSpinStyle( LABEL_SPIN_STYLE::SPIN::RIGHT ); t2->SetIsDangling( false ); addItem( t2 ); - auto t3 = new SCH_LABEL( wxPoint( Mils2iu( 1975 ), Mils2iu( 2600 ) ), wxT( "GLOBAL1" ) ); + auto t3 = new SCH_LABEL( wxPoint( Mils2iu( 1975 ), Mils2iu( 2600 ) ), wxT( "LABEL_{1}" ) ); t3->SetLabelSpinStyle( LABEL_SPIN_STYLE::SPIN::RIGHT ); t3->SetIsDangling( false ); addItem( t3 ); @@ -313,15 +313,28 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems() t2->SetSelected(); { - auto part = new LIB_PART( wxEmptyString ); + LIB_PART* part = new LIB_PART( wxEmptyString ); wxPoint p( 2625, -1600 ); + LIB_FIELD& ref = part->GetReferenceField(); + + ref.SetText( wxT( "U1" ) ); + ref.SetPosition( wxPoint( Mils2iu( p.x + 30 ), Mils2iu( p.y + 260 ) ) ); + ref.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + + LIB_FIELD& value = part->GetValueField(); + + value.SetText( wxT( "OPA604" ) ); + value.SetPosition( wxPoint( Mils2iu( p.x + 30 ), Mils2iu( p.y + 180 ) ) ); + value.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + part->SetShowPinNames( true ); part->SetShowPinNumbers( true ); + part->SetPinNameOffset( 0 ); addItem( part ); - auto comp_body = new LIB_POLYLINE( part ); + LIB_POLYLINE* comp_body = new LIB_POLYLINE( part ); comp_body->SetUnit( 0 ); comp_body->SetConvert( 0 ); @@ -333,6 +346,39 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems() comp_body->AddPoint( wxPoint( Mils2iu( p.x - 200 ), Mils2iu( p.y + 200 ) ) ); addItem( comp_body ); + + LIB_PIN* pin = new LIB_PIN( part ); + + pin->SetPosition( wxPoint( Mils2iu( p.x - 200 ), Mils2iu( p.y + 100 ) ) ); + pin->SetLength( Mils2iu( 100 ) ); + pin->SetOrientation( PIN_LEFT ); + pin->SetType( ELECTRICAL_PINTYPE::PT_INPUT ); + pin->SetNumber( wxT( "1" ) ); + pin->SetName( wxT( "-" ) ); + + part->AddDrawItem( pin ); + + pin = new LIB_PIN( part ); + + pin->SetPosition( wxPoint( Mils2iu( p.x - 200 ), Mils2iu( p.y - 100 ) ) ); + pin->SetLength( Mils2iu( 100 ) ); + pin->SetOrientation( PIN_LEFT ); + pin->SetType( ELECTRICAL_PINTYPE::PT_INPUT ); + pin->SetNumber( wxT( "2" ) ); + pin->SetName( wxT( "+" ) ); + + part->AddDrawItem( pin ); + + pin = new LIB_PIN( part ); + + pin->SetPosition( wxPoint( Mils2iu( p.x + 200 ), Mils2iu( p.y ) ) ); + pin->SetLength( Mils2iu( 100 ) ); + pin->SetOrientation( PIN_RIGHT ); + pin->SetType( ELECTRICAL_PINTYPE::PT_OUTPUT ); + pin->SetNumber( wxT( "3" ) ); + pin->SetName( wxT( "OUT" ) ); + + part->AddDrawItem( pin ); } zoomFitPreview(); @@ -377,7 +423,7 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::zoomFitPreview() double scale = view->GetScale() / std::max( fabs( psize.x / screenSize.x ), fabs( psize.y / screenSize.y ) ); - view->SetScale( scale / 1.02 ); + view->SetScale( scale * 1.1 ); view->SetCenter( m_ws->ViewBBox().Centre() ); m_preview->ForceRefresh(); } diff --git a/eeschema/sch_preview_panel.cpp b/eeschema/sch_preview_panel.cpp index da6a3e240e..4a6c58212d 100644 --- a/eeschema/sch_preview_panel.cpp +++ b/eeschema/sch_preview_panel.cpp @@ -68,7 +68,7 @@ SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL( wxWindow* aParentWindow, wxWindowID aWindo m_gal->SetGridColor( m_painter->GetSettings()->GetLayerColor( LAYER_SCHEMATIC_GRID ) ); m_gal->SetCursorEnabled( false ); - m_gal->SetGridSize( VECTOR2D( Mils2iu( 50.0 ), Mils2iu( 50.0 ) ) ); + m_gal->SetGridSize( VECTOR2D( Mils2iu( 100.0 ), Mils2iu( 100.0 ) ) ); m_viewControls->SetSnapping( true );