Worksheet display in GAL mode: fix missing filename and (in Eeschema) sheet full name.

This commit is contained in:
jean-pierre charras 2018-11-19 10:21:28 +01:00
parent eb689a5221
commit 240051fb26
5 changed files with 20 additions and 4 deletions

View File

@ -68,7 +68,7 @@ SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId,
{
m_defaultCursor = m_currentCursor = wxCURSOR_ARROW;
m_showCrossHair = true;
m_view = new KIGFX::SCH_VIEW( true );
m_view = new KIGFX::SCH_VIEW( true, dynamic_cast<SCH_BASE_FRAME*>( aParentWindow ) );
m_view->SetGAL( m_gal );
m_gal->SetWorldUnitLength( SCH_WORLD_UNIT );

View File

@ -46,7 +46,7 @@ SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL( wxWindow* aParentWindow, wxWindowID aWindo
EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalType ),
m_parent( aParentWindow )
{
m_view = new KIGFX::SCH_VIEW( true );
m_view = new KIGFX::SCH_VIEW( true, nullptr );
m_view->SetGAL( m_gal );
m_gal->SetWorldUnitLength( SCH_WORLD_UNIT );

View File

@ -34,6 +34,7 @@
#include <sch_sheet.h>
#include <sch_screen.h>
#include <preview_items/selection_area.h>
#include <sch_edit_frame.h>
#include "sch_view.h"
@ -41,9 +42,10 @@
namespace KIGFX {
SCH_VIEW::SCH_VIEW( bool aIsDynamic ) :
SCH_VIEW::SCH_VIEW( bool aIsDynamic, SCH_BASE_FRAME* aFrame ) :
VIEW( aIsDynamic )
{
m_frame = aFrame;
// Set m_boundary to define the max working area size. The default value
// is acceptable for Pcbnew and Gerbview, but too large for Eeschema.
// So we have to use a smaller value.
@ -68,6 +70,12 @@ void SCH_VIEW::DisplaySheet( SCH_SCREEN *aScreen )
&aScreen->GetTitleBlock() ) );
m_worksheet->SetSheetNumber( aScreen->m_ScreenNumber );
m_worksheet->SetSheetCount( aScreen->m_NumberOfScreens );
m_worksheet->SetFileName( TO_UTF8( aScreen->GetFileName() ) );
if( m_frame && m_frame->IsType( FRAME_SCH ) )
m_worksheet->SetSheetName( TO_UTF8( m_frame->GetScreenDesc() ) );
else
m_worksheet->SetSheetName( "" );
m_selectionArea.reset( new KIGFX::PREVIEW::SELECTION_AREA( ) );
m_preview.reset( new KIGFX::VIEW_GROUP () );

View File

@ -35,6 +35,7 @@
class SCH_SHEET;
class SCH_SCREEN;
class LIB_PART;
class SCH_BASE_FRAME;
// Eeschema uses mils as the internal units
constexpr double SCH_WORLD_UNIT = 0.001;
@ -68,7 +69,9 @@ namespace KIGFX
class SCH_VIEW : public KIGFX::VIEW
{
public:
SCH_VIEW( bool aIsDynamic );
// Note: aFrame is used to know the sheet path name when drawing the page layout.
// It can be null.
SCH_VIEW( bool aIsDynamic, SCH_BASE_FRAME* aFrame );
~SCH_VIEW();
void DisplaySheet( SCH_SHEET *aSheet );
@ -89,6 +92,8 @@ public:
void HideWorksheet();
private:
SCH_BASE_FRAME* m_frame; // The frame using this view. Can be null. Used mainly
// to know the sheet path name when drawing the page layout
std::unique_ptr<WORKSHEET_VIEWITEM> m_worksheet;
std::unique_ptr<KIGFX::PREVIEW::SELECTION_AREA> m_selectionArea;
std::unique_ptr<KIGFX::VIEW_GROUP> m_preview;

View File

@ -161,6 +161,9 @@ void PCB_DRAW_PANEL_GAL::DisplayBoard( BOARD* aBoard )
t.detach();
}
if( m_worksheet )
m_worksheet->SetFileName( TO_UTF8( aBoard->GetFileName() ) );
// Load drawings
for( auto drawing : const_cast<BOARD*>(aBoard)->Drawings() )
m_view->Add( drawing );