Commit 517ca83f authored by Dick Hollenbeck's avatar Dick Hollenbeck

Hide m_galCanvas and m_galCanvasActive behind accessors. Fix DLIST concatonation API corner case.

parent 9be908ce
......@@ -62,7 +62,6 @@ PCBNew
Dick's Final TODO List:
======================
*) Apply Fabrizio and Alexander's linux desktop patches after unifying them.
*) Get licensing cleaned up.
*) Re-arrange the repo architecture.
*) DLL-ization of pcbnew & eeschema
......
......@@ -87,13 +87,13 @@ void DHEAD::append( EDA_ITEM* aNewElement )
void DHEAD::append( DHEAD& aList )
{
wxCHECK_RET( aList.GetCount() != 0, wxT( "Attempt to append empty list." ) );
if( aList.first )
{
// Change the item's list to me.
for( EDA_ITEM* item = aList.first; item != NULL; item = item->Next() )
for( EDA_ITEM* item = aList.first; item; item = item->Next() )
item->SetList( this );
if( first ) // list is not empty, set last item's next to the first item in aList
if( first ) // this list is not empty, set last item's next to the first item in aList
{
wxCHECK_RET( last != NULL, wxT( "Last list element not set." ) );
......@@ -101,7 +101,7 @@ void DHEAD::append( DHEAD& aList )
aList.first->SetBack( last );
last = aList.last;
}
else // list is empty, first and last are same as aList
else // this list is empty, first and last are same as aList
{
first = aList.first;
last = aList.last;
......@@ -112,6 +112,7 @@ void DHEAD::append( DHEAD& aList )
aList.count = 0;
aList.first = NULL;
aList.last = NULL;
}
}
......
......@@ -228,10 +228,10 @@ void EDA_DRAW_FRAME::SkipNextLeftButtonReleaseEvent()
void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent )
{
SetGridVisibility( !IsGridVisible() );
if( m_galCanvasActive )
if( IsGalCanvasActive() )
{
m_galCanvas->GetGAL()->SetGridVisibility( IsGridVisible() );
m_galCanvas->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
GetGalCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );
GetGalCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
}
m_canvas->Refresh();
......@@ -387,11 +387,11 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
screen->SetGrid( id );
SetCrossHairPosition( RefPos( true ) );
if( m_galCanvasActive )
if( IsGalCanvasActive() )
{
m_galCanvas->GetGAL()->SetGridSize( VECTOR2D( screen->GetGrid().m_Size.x,
GetGalCanvas()->GetGAL()->SetGridSize( VECTOR2D( screen->GetGrid().m_Size.x,
screen->GetGrid().m_Size.y ) );
m_galCanvas->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
GetGalCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
}
m_canvas->Refresh();
......@@ -422,17 +422,17 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
GetScreen()->SetZoom( selectedZoom );
if( m_galCanvasActive )
if( IsGalCanvasActive() )
{
// Apply computed view settings to GAL
KIGFX::VIEW* view = m_galCanvas->GetView();
KIGFX::GAL* gal = m_galCanvas->GetGAL();
KIGFX::VIEW* view = GetGalCanvas()->GetView();
KIGFX::GAL* gal = GetGalCanvas()->GetGAL();
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
double zoom = 1.0 / ( zoomFactor * GetZoom() );
view->SetScale( zoom );
m_galCanvas->Refresh();
GetGalCanvas()->Refresh();
}
else
RedrawScreen( GetScrollCenterPosition(), false );
......@@ -954,8 +954,8 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
{
KIGFX::VIEW* view = m_galCanvas->GetView();
KIGFX::GAL* gal = m_galCanvas->GetGAL();
KIGFX::VIEW* view = GetGalCanvas()->GetView();
KIGFX::GAL* gal = GetGalCanvas()->GetGAL();
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
......@@ -965,7 +965,7 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
BASE_SCREEN* screen = GetScreen();
// Switch to GAL rendering
if( !m_galCanvasActive )
if( !IsGalCanvasActive() )
{
// Set up viewport
double zoom = 1.0 / ( zoomFactor * m_canvas->GetZoom() );
......@@ -981,7 +981,7 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
else
{
// Switch to standard rendering
if( m_galCanvasActive )
if( IsGalCanvasActive() )
{
// Change view settings only if GAL was active previously
double zoom = 1.0 / ( zoomFactor * view->GetScale() );
......@@ -993,17 +993,17 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
}
m_canvas->SetEvtHandlerEnabled( !aEnable );
m_galCanvas->SetEvtHandlerEnabled( aEnable );
GetGalCanvas()->SetEvtHandlerEnabled( aEnable );
// Switch panes
m_auimgr.GetPane( wxT( "DrawFrame" ) ).Show( !aEnable );
m_auimgr.GetPane( wxT( "DrawFrameGal" ) ).Show( aEnable );
m_auimgr.Update();
m_galCanvasActive = aEnable;
SetGalCanvasActive( aEnable );
if( aEnable )
m_galCanvas->SetFocus();
GetGalCanvas()->SetFocus();
}
//-----< BASE_SCREEN API moved here >--------------------------------------------
......
......@@ -84,7 +84,7 @@ void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
if( screen->m_FirstRedraw )
SetCrossHairPosition( GetScrollCenterPosition() );
if( !m_galCanvasActive )
if( !IsGalCanvasActive() )
RedrawScreen( GetScrollCenterPosition(), aWarpPointer );
}
......@@ -194,18 +194,18 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
RedrawScreen( center, true );
}
if( m_galCanvasActive )
if( IsGalCanvasActive() )
{
// Apply computed view settings to GAL
KIGFX::VIEW* view = m_galCanvas->GetView();
KIGFX::GAL* gal = m_galCanvas->GetGAL();
KIGFX::VIEW* view = GetGalCanvas()->GetView();
KIGFX::GAL* gal = GetGalCanvas()->GetGAL();
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
double zoom = 1.0 / ( zoomFactor * GetZoom() );
view->SetScale( zoom );
view->SetCenter( VECTOR2D( center ) );
m_galCanvas->Refresh();
GetGalCanvas()->Refresh();
}
UpdateStatusBar();
......
......@@ -393,21 +393,21 @@ class EDA_DRAW_FRAME : public EDA_BASE_FRAME
int m_toolId;
BASE_SCREEN* m_currentScreen; ///< current used SCREEN
bool m_snapToGrid; ///< Indicates if cursor should be snapped to grid.
bool m_galCanvasActive; ///< whether to use new GAL engine
EDA_DRAW_PANEL_GAL* m_galCanvas;
protected:
EDA_HOTKEY_CONFIG* m_HotkeysZoomAndGridList;
int m_LastGridSizeId;
bool m_DrawGrid; // hide/Show grid
bool m_galCanvasActive; // whether to use new GAL engine
EDA_COLOR_T m_GridColor; // Grid color
/// The area to draw on.
EDA_DRAW_PANEL* m_canvas;
/// New type of area (GAL-based) to draw on.
EDA_DRAW_PANEL_GAL* m_galCanvas;
/// Tool ID of previously active draw tool bar button.
int m_lastDrawToolId;
......@@ -979,20 +979,22 @@ public:
virtual void UseGalCanvas( bool aEnable );
/**
* Function IsNewCanvasActive
* Function IsGalCanvasActive
* is used to check which canvas (GAL-based or standard) is currently in use.
*
* @return True for GAL-based canvas, false for standard canvas.
*/
bool IsGalCanvasActive() { return m_galCanvasActive; }
bool IsGalCanvasActive() const { return m_galCanvasActive; }
void SetGalCanvasActive( bool aState ) { m_galCanvasActive = aState; }
/**
* Function GetCalCanvas
* Function GetGalCanvas
* returns a pointer to GAL-based canvas of given EDA draw frame.
*
* @return Pointer to GAL-based canvas.
*/
EDA_DRAW_PANEL_GAL* GetGalCanvas() { return m_galCanvas; }
EDA_DRAW_PANEL_GAL* GetGalCanvas() const { return m_galCanvas; }
void SetGalCanvas( EDA_DRAW_PANEL_GAL* aPanel ) { m_galCanvas = aPanel; }
DECLARE_EVENT_TABLE()
};
......
......@@ -152,10 +152,12 @@ PCB_BASE_FRAME::PCB_BASE_FRAME( wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType,
m_FastGrid1 = 0;
m_FastGrid2 = 0;
m_galCanvas = new EDA_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
SetGalCanvas( new EDA_DRAW_PANEL_GAL(
this, -1, wxPoint( 0, 0 ), m_FrameSize,
EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) );
// Hide by default, it has to be explicitly shown
m_galCanvas->Hide();
GetGalCanvas()->Hide();
m_auxiliaryToolBar = NULL;
}
......@@ -166,7 +168,7 @@ PCB_BASE_FRAME::~PCB_BASE_FRAME()
delete m_Collector;
delete m_Pcb; // is already NULL for FOOTPRINT_EDIT_FRAME
delete m_galCanvas;
delete GetGalCanvas();
}
......@@ -437,11 +439,11 @@ void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent )
// Apply new display options to the GAL canvas
KIGFX::PCB_PAINTER* painter =
static_cast<KIGFX::PCB_PAINTER*> ( m_galCanvas->GetView()->GetPainter() );
static_cast<KIGFX::PCB_PAINTER*> ( GetGalCanvas()->GetView()->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
settings->LoadDisplayOptions( DisplayOpt );
m_galCanvas->GetView()->RecacheAllItems( true );
GetGalCanvas()->GetView()->RecacheAllItems( true );
m_canvas->Refresh();
}
......@@ -764,7 +766,7 @@ void PCB_BASE_FRAME::LoadSettings()
m_DisplayModText = FILLED;
// Apply display settings for GAL
KIGFX::VIEW* view = m_galCanvas->GetView();
KIGFX::VIEW* view = GetGalCanvas()->GetView();
// Set rendering order and properties of layers
for( LAYER_NUM i = 0; (unsigned) i < sizeof(GAL_LAYER_ORDER) / sizeof(LAYER_NUM); ++i )
......
......@@ -404,25 +404,27 @@ void PCB_LAYER_WIDGET::OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool is
myframe->GetCanvas()->Refresh();
}
void PCB_LAYER_WIDGET::OnRenderColorChange( int aId, EDA_COLOR_T aColor )
{
myframe->GetBoard()->SetVisibleElementColor( aId, aColor );
myframe->GetCanvas()->Refresh();
}
void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
{
BOARD* brd = myframe->GetBoard();
brd->SetElementVisibility( aId, isEnabled );
EDA_DRAW_PANEL_GAL *galCanvas = myframe->GetGalCanvas();
EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
if( galCanvas )
{
KIGFX::VIEW* view = galCanvas->GetView();
view->SetLayerVisible( ITEM_GAL_LAYER( aId ), isEnabled );
}
if( myframe->IsGalCanvasActive() )
if( galCanvas && myframe->IsGalCanvasActive() )
galCanvas->Refresh();
else
myframe->GetCanvas()->Refresh();
......
......@@ -153,7 +153,7 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
int id = event.GetId();
bool state = event.IsChecked();
KIGFX::PCB_PAINTER* painter =
static_cast<KIGFX::PCB_PAINTER*> ( m_galCanvas->GetView()->GetPainter() );
static_cast<KIGFX::PCB_PAINTER*> ( GetGalCanvas()->GetView()->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
bool recache = false;
......@@ -259,9 +259,9 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
{
// Apply new display options to the GAL canvas
settings->LoadDisplayOptions( DisplayOpt );
m_galCanvas->GetView()->RecacheAllItems( true );
GetGalCanvas()->GetView()->RecacheAllItems( true );
}
if( IsGalCanvasActive() )
m_galCanvas->Refresh();
GetGalCanvas()->Refresh();
}
......@@ -335,14 +335,14 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
SetBoard( new BOARD() );
if( m_galCanvas )
if( GetGalCanvas() )
{
ViewReloadBoard( m_Pcb );
// update the tool manager with the new board and its view.
if( m_toolManager )
m_toolManager->SetEnvironment( m_Pcb, m_galCanvas->GetView(),
m_galCanvas->GetViewControls(), this );
m_toolManager->SetEnvironment( m_Pcb, GetGalCanvas()->GetView(),
GetGalCanvas()->GetViewControls(), this );
}
// Create the PCB_LAYER_WIDGET *after* SetBoard():
......@@ -356,7 +356,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
if( screenHeight <= 900 )
pointSize = (pointSize * 8) / 10;
m_Layers = new PCB_LAYER_WIDGET( this, m_galCanvas, pointSize );
m_Layers = new PCB_LAYER_WIDGET( this, GetGalCanvas(), pointSize );
m_drc = new DRC( this ); // these 2 objects point to each other
......@@ -454,8 +454,8 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
m_auimgr.AddPane( m_canvas,
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
if( m_galCanvas )
m_auimgr.AddPane( (wxWindow*) m_galCanvas,
if( GetGalCanvas() )
m_auimgr.AddPane( (wxWindow*) GetGalCanvas(),
wxAuiPaneInfo().Name( wxT( "DrawFrameGal" ) ).CentrePane().Hide() );
if( m_messagePanel )
......@@ -538,21 +538,21 @@ void PCB_EDIT_FRAME::SetBoard( BOARD* aBoard )
{
PCB_BASE_FRAME::SetBoard( aBoard );
if( m_galCanvas )
if( GetGalCanvas() )
{
ViewReloadBoard( aBoard );
// update the tool manager with the new board and its view.
if( m_toolManager )
m_toolManager->SetEnvironment( aBoard, m_galCanvas->GetView(),
m_galCanvas->GetViewControls(), this );
m_toolManager->SetEnvironment( aBoard, GetGalCanvas()->GetView(),
GetGalCanvas()->GetViewControls(), this );
}
}
void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
{
KIGFX::VIEW* view = m_galCanvas->GetView();
KIGFX::VIEW* view = GetGalCanvas()->GetView();
view->Clear();
// All of PCB drawing elements should be added to the VIEW
......@@ -629,8 +629,8 @@ void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
view->SetPanBoundary( worksheet->ViewBBox() );
view->RecacheAllItems( true );
if( m_galCanvasActive )
m_galCanvas->Refresh();
if( IsGalCanvasActive() )
GetGalCanvas()->Refresh();
}
......@@ -668,7 +668,7 @@ void PCB_EDIT_FRAME::OnQuit( wxCommandEvent& event )
void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
m_canvas->SetAbortRequest( true );
m_galCanvas->StopDrawing();
GetGalCanvas()->StopDrawing();
if( GetScreen()->IsModify() )
{
......@@ -750,8 +750,8 @@ void PCB_EDIT_FRAME::UseGalCanvas( bool aEnable )
{
EDA_DRAW_FRAME::UseGalCanvas( aEnable );
m_toolManager->SetEnvironment( m_Pcb, m_galCanvas->GetView(),
m_galCanvas->GetViewControls(), this );
m_toolManager->SetEnvironment( m_Pcb, GetGalCanvas()->GetView(),
GetGalCanvas()->GetViewControls(), this );
ViewReloadBoard( m_Pcb );
}
......@@ -768,12 +768,12 @@ void PCB_EDIT_FRAME::SwitchCanvas( wxCommandEvent& aEvent )
break;
case ID_MENU_CANVAS_CAIRO:
m_galCanvas->SwitchBackend( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
GetGalCanvas()->SwitchBackend( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
UseGalCanvas( true );
break;
case ID_MENU_CANVAS_OPENGL:
m_galCanvas->SwitchBackend( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
GetGalCanvas()->SwitchBackend( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
UseGalCanvas( true );
break;
}
......@@ -902,7 +902,7 @@ bool PCB_EDIT_FRAME::IsMicroViaAcceptable( void )
void PCB_EDIT_FRAME::setHighContrastLayer( LAYER_NUM aLayer )
{
// Set display settings for high contrast mode
KIGFX::VIEW* view = m_galCanvas->GetView();
KIGFX::VIEW* view = GetGalCanvas()->GetView();
KIGFX::RENDER_SETTINGS* rSettings = view->GetPainter()->GetSettings();
setTopLayer( aLayer );
......@@ -945,7 +945,7 @@ void PCB_EDIT_FRAME::setHighContrastLayer( LAYER_NUM aLayer )
void PCB_EDIT_FRAME::setTopLayer( LAYER_NUM aLayer )
{
// Set display settings for high contrast mode
KIGFX::VIEW* view = m_galCanvas->GetView();
KIGFX::VIEW* view = GetGalCanvas()->GetView();
view->ClearTopLayers();
view->SetTopLayer( aLayer );
......@@ -993,8 +993,8 @@ void PCB_EDIT_FRAME::setActiveLayer( LAYER_NUM aLayer, bool doLayerWidgetUpdate
if( doLayerWidgetUpdate )
syncLayerWidgetLayer();
if( m_galCanvasActive )
m_galCanvas->Refresh();
if( IsGalCanvasActive() )
GetGalCanvas()->Refresh();
}
......@@ -1015,7 +1015,7 @@ void PCB_EDIT_FRAME::syncLayerVisibilities()
{
m_Layers->SyncLayerVisibilities();
KIGFX::VIEW* view = m_galCanvas->GetView();
KIGFX::VIEW* view = GetGalCanvas()->GetView();
// Load layer & elements visibility settings
for( LAYER_NUM i = 0; i < NB_LAYERS; ++i )
{
......
......@@ -44,7 +44,7 @@ void PCB_EDIT_FRAME::setupTools()
// Create the manager and dispatcher & route draw panel events to the dispatcher
m_toolManager = new TOOL_MANAGER;
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, this );
m_galCanvas->SetEventDispatcher( m_toolDispatcher );
GetGalCanvas()->SetEventDispatcher( m_toolDispatcher );
// Register tool actions
m_toolManager->RegisterAction( &COMMON_ACTIONS::moveActivate );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment