diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index 02c0601e10..748b47917f 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -117,6 +118,15 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule ) GetScreen()->ClrModify(); Zoom_Automatique( false ); + if( IsGalCanvasActive() ) + { + static_cast( GetGalCanvas() )->DisplayBoard( GetBoard() ); + + m_Pcb->ComputeBoundingBox( false ); + EDA_RECT boardBbox = m_Pcb->GetBoundingBox(); + GetGalCanvas()->GetView()->SetViewport( BOX2D( boardBbox.GetOrigin(), boardBbox.GetSize() ) ); + } + return true; } diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index ed81bc7989..c3bae138a9 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -914,3 +915,15 @@ EDA_COLOR_T FOOTPRINT_EDIT_FRAME::GetGridColor() const return g_ColorsSettings.GetItemColor( GRID_VISIBLE ); } + +void FOOTPRINT_EDIT_FRAME::UseGalCanvas( bool aEnable ) +{ + EDA_DRAW_FRAME::UseGalCanvas( aEnable ); + + if( aEnable ) + { + SetBoard( m_Pcb ); + + GetGalCanvas()->StartDrawing(); + } +} diff --git a/pcbnew/module_editor_frame.h b/pcbnew/module_editor_frame.h index 1e10a01b09..665349aad9 100644 --- a/pcbnew/module_editor_frame.h +++ b/pcbnew/module_editor_frame.h @@ -399,6 +399,9 @@ public: virtual EDA_COLOR_T GetGridColor() const; + ///> @copydoc EDA_DRAW_FRAME::UseGalCanvas() + virtual void UseGalCanvas( bool aEnable ); + DECLARE_EVENT_TABLE() protected: diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index d844321bdc..9cf223a256 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -52,6 +53,15 @@ #include #include +#include +#include +#include "tools/selection_tool.h" +#include "tools/edit_tool.h" +#include "tools/drawing_tool.h" +#include "tools/point_editor.h" +#include "tools/pcbnew_control.h" +#include "tools/common_actions.h" + BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) EVT_MENU_RANGE( ID_POPUP_PCB_ITEM_SELECTION_START, ID_POPUP_PCB_ITEM_SELECTION_END, @@ -167,6 +177,12 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : // Show a title (frame title + footprint name): updateTitle(); + // Create GAL canvas + EDA_DRAW_FRAME* drawFrame = static_cast( aParent ); + PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, + drawFrame->GetGalCanvas()->GetBackend() ); + SetGalCanvas( drawPanel ); + SetBoard( new BOARD() ); // restore the last footprint from the project, if any @@ -224,11 +240,37 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_auimgr.AddPane( m_canvas, wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() ); + m_auimgr.AddPane( (wxWindow*) GetGalCanvas(), + wxAuiPaneInfo().Name( wxT( "DrawFrameGal" ) ).CentrePane().Hide() ); m_auimgr.AddPane( m_messagePanel, wxAuiPaneInfo( mesg_pane ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) ); m_auimgr.Update(); + + if( drawFrame->IsGalCanvasActive() ) + { + drawPanel->DisplayBoard( GetBoard() ); + + // Create the manager and dispatcher & route draw panel events to the dispatcher + m_toolManager = new TOOL_MANAGER; + m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(), + drawPanel->GetViewControls(), this ); + m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager ); + drawPanel->SetEventDispatcher( m_toolDispatcher ); + + m_toolManager->RegisterTool( new SELECTION_TOOL ); + m_toolManager->RegisterTool( new EDIT_TOOL ); + m_toolManager->RegisterTool( new DRAWING_TOOL ); + m_toolManager->RegisterTool( new POINT_EDITOR ); + m_toolManager->RegisterTool( new PCBNEW_CONTROL ); + m_toolManager->ResetTools( TOOL_BASE::RUN ); + + // Run the selection tool, it is supposed to be always active + m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" ); + + UseGalCanvas( true ); + } } diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 675d95dc39..d2199f8a5d 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -545,6 +545,7 @@ void EDIT_TOOL::processChanges( const PICKED_ITEMS_LIST* aList ) switch( operation ) { case UR_CHANGED: + case UR_MODEDIT: updItem->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); break;