Gerbview: GAL mode: shows the page worksheet, similar to legacy mode.

This commit is contained in:
jean-pierre charras 2018-06-01 09:11:43 +02:00
parent fc71fc6474
commit 9a228d8ec9
7 changed files with 68 additions and 16 deletions

View File

@ -37,8 +37,10 @@
using namespace KIGFX; using namespace KIGFX;
WORKSHEET_VIEWITEM::WORKSHEET_VIEWITEM( const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock ) : WORKSHEET_VIEWITEM::WORKSHEET_VIEWITEM( int aMils2IUscalefactor,
const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock ) :
EDA_ITEM( NOT_USED ), // this item is never added to a BOARD so it needs no type EDA_ITEM( NOT_USED ), // this item is never added to a BOARD so it needs no type
m_mils2IUscalefactor( aMils2IUscalefactor ),
m_titleBlock( aTitleBlock ), m_pageInfo( aPageInfo ), m_sheetNumber( 1 ), m_sheetCount( 1 ) {} m_titleBlock( aTitleBlock ), m_pageInfo( aPageInfo ), m_sheetNumber( 1 ), m_sheetCount( 1 ) {}
@ -61,8 +63,8 @@ const BOX2I WORKSHEET_VIEWITEM::ViewBBox() const
if( m_pageInfo != NULL ) if( m_pageInfo != NULL )
{ {
bbox.SetOrigin( VECTOR2I( 0, 0 ) ); bbox.SetOrigin( VECTOR2I( 0, 0 ) );
bbox.SetEnd( VECTOR2I( m_pageInfo->GetWidthMils() * 25400, bbox.SetEnd( VECTOR2I( m_pageInfo->GetWidthMils() * m_mils2IUscalefactor,
m_pageInfo->GetHeightMils() * 25400 ) ); m_pageInfo->GetHeightMils() * m_mils2IUscalefactor ) );
} }
else else
{ {
@ -82,10 +84,10 @@ void WORKSHEET_VIEWITEM::ViewDraw( int aLayer, VIEW* aView ) const
WS_DRAW_ITEM_LIST drawList; WS_DRAW_ITEM_LIST drawList;
drawList.SetPenSize( settings->GetWorksheetLineWidth() ); drawList.SetPenSize( settings->GetWorksheetLineWidth() );
// Sorry, but I don't get this multi #ifdef from include/convert_to_biu.h, so here goes a magic // Adjust the scaling factor for worksheet items:
// number. IU_PER_MILS should be 25400 (as in a different compilation unit), but somehow // worksheet items coordinates and sizes are stored in mils,
// it equals 1 in this case.. // and must be scaled to the same units as the caller
drawList.SetMilsToIUfactor( 25400 /* IU_PER_MILS */ ); drawList.SetMilsToIUfactor( m_mils2IUscalefactor );
drawList.SetSheetNumber( m_sheetNumber ); drawList.SetSheetNumber( m_sheetNumber );
drawList.SetSheetCount( m_sheetCount ); drawList.SetSheetCount( m_sheetCount );
drawList.SetFileName( fileName ); drawList.SetFileName( fileName );

View File

@ -21,6 +21,7 @@
#include <view/view.h> #include <view/view.h>
#include <view/wx_view_controls.h> #include <view/wx_view_controls.h>
#include <gerbview_painter.h> #include <gerbview_painter.h>
#include <worksheet_viewitem.h>
#include <colors_design_settings.h> #include <colors_design_settings.h>
#include <gerbview_frame.h> #include <gerbview_frame.h>
@ -134,12 +135,20 @@ void GERBVIEW_DRAW_PANEL_GAL::setDefaultLayerDeps()
m_view->SetLayerDisplayOnly( LAYER_GERBVIEW_GRID ); m_view->SetLayerDisplayOnly( LAYER_GERBVIEW_GRID );
m_view->SetLayerDisplayOnly( LAYER_GERBVIEW_AXES ); m_view->SetLayerDisplayOnly( LAYER_GERBVIEW_AXES );
m_view->SetLayerDisplayOnly( LAYER_GERBVIEW_BACKGROUND ); m_view->SetLayerDisplayOnly( LAYER_GERBVIEW_BACKGROUND );
m_view->SetLayerDisplayOnly( LAYER_WORKSHEET );
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 );
} }
void GERBVIEW_DRAW_PANEL_GAL::SetWorksheet( KIGFX::WORKSHEET_VIEWITEM* aWorksheet )
{
m_worksheet.reset( aWorksheet );
m_view->Add( m_worksheet.get() );
}
void GERBVIEW_DRAW_PANEL_GAL::SetTopLayer( int aLayer ) void GERBVIEW_DRAW_PANEL_GAL::SetTopLayer( int aLayer )
{ {
m_view->ClearTopLayers(); m_view->ClearTopLayers();

View File

@ -21,6 +21,12 @@
#define GERBVIEW_DRAW_PANEL_GAL_H_ #define GERBVIEW_DRAW_PANEL_GAL_H_
#include <class_draw_panel_gal.h> #include <class_draw_panel_gal.h>
#include <worksheet_viewitem.h>
namespace KIGFX
{
class WORKSHEET_VIEWITEM;
}
class COLORS_DESIGN_SETTINGS; class COLORS_DESIGN_SETTINGS;
@ -55,9 +61,19 @@ public:
///> @copydoc EDA_DRAW_PANEL_GAL::SetTopLayer ///> @copydoc EDA_DRAW_PANEL_GAL::SetTopLayer
virtual void SetTopLayer( int aLayer ) override; virtual void SetTopLayer( int aLayer ) override;
/**
* Sets (or updates) worksheet used by the draw panel.
* @param aWorksheet is the worksheet to be used.
* The object is then owned by GERBVIEW_DRAW_PANEL_GAL.
*/
void SetWorksheet( KIGFX::WORKSHEET_VIEWITEM* aWorksheet );
protected: protected:
///> Sets rendering targets & dependencies for layers. ///> Sets rendering targets & dependencies for layers.
void setDefaultLayerDeps(); void setDefaultLayerDeps();
///> Currently used worksheet
std::unique_ptr<KIGFX::WORKSHEET_VIEWITEM> m_worksheet;
}; };

View File

@ -75,9 +75,6 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
// obviously depends on the monitor, // obviously depends on the monitor,
// but this is an acceptable value // but this is an acceptable value
PAGE_INFO pageInfo( wxT( "GERBER" ) );
SetPageSettings( pageInfo );
m_show_layer_manager_tools = true; m_show_layer_manager_tools = true;
m_showAxis = true; // true to show X and Y axis on screen m_showAxis = true; // true to show X and Y axis on screen
@ -400,8 +397,6 @@ void GERBVIEW_FRAME::LoadSettings( wxConfigBase* aCfg )
SetPageSettings( pageInfo ); SetPageSettings( pageInfo );
GetScreen()->InitDataPoints( pageInfo.GetSizeIU() );
bool tmp; bool tmp;
aCfg->Read( cfgShowDCodes, &tmp, true ); aCfg->Read( cfgShowDCodes, &tmp, true );
SetElementVisibility( LAYER_DCODES, tmp ); SetElementVisibility( LAYER_DCODES, tmp );
@ -990,9 +985,29 @@ void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings ) void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
{ {
m_paper = aPageSettings; m_paper = aPageSettings;
GBR_SCREEN* screen = static_cast<GBR_SCREEN*>( GetScreen() );
if( GetScreen() ) if( screen )
GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() ); screen->InitDataPoints( aPageSettings.GetSizeIU() );
if( IsGalCanvasActive() )
{
GERBVIEW_DRAW_PANEL_GAL* drawPanel =
static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetGalCanvas() );
// Prepare worksheet template
KIGFX::WORKSHEET_VIEWITEM* worksheet;
worksheet = new KIGFX::WORKSHEET_VIEWITEM( IU_PER_MILS, &GetPageSettings(), &GetTitleBlock() );
if( screen != NULL )
{
worksheet->SetSheetNumber( 1 );
worksheet->SetSheetCount( 1 );
}
// PCB_DRAW_PANEL_GAL takes ownership of the worksheet
drawPanel->SetWorksheet( worksheet );
}
} }
@ -1219,6 +1234,8 @@ void GERBVIEW_FRAME::UseGalCanvas( bool aEnable )
galCanvas->GetGAL()->SetGridColor( GetLayerColor( LAYER_GERBVIEW_GRID ) ); galCanvas->GetGAL()->SetGridColor( GetLayerColor( LAYER_GERBVIEW_GRID ) );
SetPageSettings( GetPageSettings() );
galCanvas->GetView()->RecacheAllItems(); galCanvas->GetView()->RecacheAllItems();
galCanvas->SetEventDispatcher( m_toolDispatcher ); galCanvas->SetEventDispatcher( m_toolDispatcher );
galCanvas->StartDrawing(); galCanvas->StartDrawing();

View File

@ -102,6 +102,9 @@ const COLOR4D& GERBVIEW_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int a
if( IsDCodeLayer( aLayer ) ) if( IsDCodeLayer( aLayer ) )
return m_layerColors[ LAYER_DCODES ]; return m_layerColors[ LAYER_DCODES ];
if( aLayer == LAYER_WORKSHEET )
return m_layerColors[ LAYER_WORKSHEET ];
if( item ) if( item )
{ {
if( item->IsSelected() ) if( item->IsSelected() )

View File

@ -48,7 +48,8 @@ class GAL;
class WORKSHEET_VIEWITEM : public EDA_ITEM class WORKSHEET_VIEWITEM : public EDA_ITEM
{ {
public: public:
WORKSHEET_VIEWITEM( const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock ); WORKSHEET_VIEWITEM( int aMils2IUscalefactor,
const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock );
/** /**
* Function SetFileName() * Function SetFileName()
@ -135,6 +136,10 @@ public:
} }
protected: protected:
/// the factor between mils (units used in worksheet and internal units)
/// it is the value IU_PER_MILS used in the caller
int m_mils2IUscalefactor;
/// File name displayed in the title block /// File name displayed in the title block
std::string m_fileName; std::string m_fileName;

View File

@ -567,7 +567,7 @@ void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
// Prepare worksheet template // Prepare worksheet template
KIGFX::WORKSHEET_VIEWITEM* worksheet; KIGFX::WORKSHEET_VIEWITEM* worksheet;
worksheet = new KIGFX::WORKSHEET_VIEWITEM( &m_Pcb->GetPageSettings(), worksheet = new KIGFX::WORKSHEET_VIEWITEM( IU_PER_MILS ,&m_Pcb->GetPageSettings(),
&m_Pcb->GetTitleBlock() ); &m_Pcb->GetTitleBlock() );
worksheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) ); worksheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) );