Commit 69a44d5f authored by tomasz.'s avatar tomasz.
Browse files

pcbnew: hooked Tool Framework into the edit panel. Added a sample selection...

pcbnew: hooked Tool Framework into the edit panel. Added a sample selection tool (not fully functional).
parent 4c777e92
Loading
Loading
Loading
Loading
+38 −2
Original line number Diff line number Diff line
@@ -38,6 +38,9 @@
#include <gal/opengl/opengl_gal.h>
#include <gal/cairo/cairo_gal.h>

#include <tool/tool_dispatcher.h>
#include <tool/tool_manager.h>

#ifdef __WXDEBUG__
#include <profile.h>
#endif /* __WXDEBUG__ */
@@ -54,6 +57,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
    m_currentGal = GAL_TYPE_NONE;
    m_view       = NULL;
    m_painter    = NULL;
    m_eventDispatcher = NULL;

    SwitchBackend( aGalType, true );
    SetBackgroundStyle( wxBG_STYLE_CUSTOM );
@@ -83,6 +87,19 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
    Connect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), NULL, this );
    Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this );

    /* Generic events for the Tool Dispatcher */

	Connect( wxEVT_MOTION, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
	Connect( wxEVT_LEFT_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
	Connect( wxEVT_LEFT_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
	Connect( wxEVT_RIGHT_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
	Connect( wxEVT_RIGHT_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
	Connect( wxEVT_MIDDLE_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
	Connect( wxEVT_MIDDLE_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
	Connect( wxEVT_MOUSEWHEEL, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
	Connect( wxEVT_KEY_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
	Connect( wxEVT_KEY_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
	
    m_timeStamp = 0;
}

@@ -121,8 +138,8 @@ void EDA_DRAW_PANEL_GAL::Refresh( bool eraseBackground, const wxRect* rect )

    // Framerate limiter
    wxLongLong currentTimeStamp = wxGetLocalTimeMillis();
    if( currentTimeStamp - m_timeStamp < ( 1000 / FPS_LIMIT ) )
        return;
   // if( currentTimeStamp - m_timeStamp < ( 1000 / FPS_LIMIT ) )
 //       return;
    m_timeStamp = currentTimeStamp;

#ifdef __WXDEBUG__
@@ -131,6 +148,8 @@ void EDA_DRAW_PANEL_GAL::Refresh( bool eraseBackground, const wxRect* rect )
    prof_start( &time, false );
#endif /* __WXDEBUG__ */

    printf("Refresh!\n");

    m_gal->BeginDrawing();
    m_gal->SetBackgroundColor( KiGfx::COLOR4D( 0.0, 0.0, 0.0, 1.0 ) );
    m_gal->ClearScreen();
@@ -193,3 +212,20 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType, bool aUseShaders )
    m_currentGal = aGalType;
    m_useShaders = aUseShaders;
}

void EDA_DRAW_PANEL_GAL::onEvent( wxEvent& aEvent )
{
	if(!m_eventDispatcher)
	{
		aEvent.Skip();
		return;
	} else {
        printf("evType %d\n", aEvent.GetEventType());
        m_eventDispatcher->DispatchWxEvent(aEvent);
    }
}

KiGfx::VIEW_CONTROLS* EDA_DRAW_PANEL_GAL::GetViewControls() const
{
    return m_viewControls;
}
 No newline at end of file
+11 −0
Original line number Diff line number Diff line
@@ -36,12 +36,14 @@
#include <math/vector2d.h>

class BOARD;
class TOOL_DISPATCHER;

namespace KiGfx
{
class GAL;
class VIEW;
class WX_VIEW_CONTROLS;
class VIEW_CONTROLS;
class PAINTER;
};

@@ -74,13 +76,21 @@ public:
    KiGfx::GAL* GetGAL() { return m_gal; }

    void SetView( KiGfx::VIEW* aView ) { m_view = aView; }
    
    KiGfx::VIEW* GetView() const { return m_view; }
    KiGfx::VIEW_CONTROLS* GetViewControls() const;

    virtual void Refresh( bool eraseBackground = true, const wxRect* rect = NULL );

    void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
    {
        m_eventDispatcher = aEventDispatcher;
    }

protected:
    void onPaint( wxPaintEvent& WXUNUSED( aEvent ) );
    void onSize( wxSizeEvent& aEvent );
	void onEvent( wxEvent& aEvent );

    KiGfx::GAL*              m_gal;              ///< Interface for drawing objects on a 2D-surface
    KiGfx::VIEW*             m_view;             ///< Stores view settings (scale, center, etc.)
@@ -91,6 +101,7 @@ protected:
    GalType                  m_currentGal;       ///< Currently used GAL
    bool                     m_useShaders;       ///< Are shaders used? (only for OpenGL GAL)
    wxLongLong               m_timeStamp;
	TOOL_DISPATCHER*		 m_eventDispatcher;  
};

#endif
+6 −1
Original line number Diff line number Diff line
@@ -56,7 +56,8 @@ class ZONE_SETTINGS;
class PCB_PLOT_PARAMS;
class FP_LIB_TABLE;
class FPID;

class TOOL_MANAGER;
class TOOL_DISPATCHER;

/**
 * class PCB_BASE_FRAME
@@ -94,6 +95,10 @@ protected:
    /// main window.
    wxAuiToolBar*       m_auxiliaryToolBar;

    TOOL_MANAGER *m_toolManager;
    TOOL_DISPATCHER *m_toolDispatcher;
    
    void setupTools();
    void updateGridSelectBox();
    void updateZoomSelectBox();
    virtual void unitsChangeRefresh();
+2 −1
Original line number Diff line number Diff line
@@ -65,7 +65,6 @@ class PARSE_ERROR;
class IO_ERROR;
class FP_LIB_TABLE;


/**
 * class PCB_EDIT_FRAME
 * the main frame for Pcbnew
@@ -118,6 +117,8 @@ protected:
    bool              m_useCmpFileForFpNames;   ///< is true, use the .cmp file from CvPcb, else use the netlist
                                                // to know the footprint name of components.

	void onGenericCommand( wxCommandEvent& aEvent );
		
    // we'll use lower case function names for private member functions.
    void createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu* aPopMenu );
    void createPopUpMenuForFootprints( MODULE* aModule, wxMenu* aPopMenu );
+4 −0
Original line number Diff line number Diff line
@@ -216,6 +216,10 @@ set(PCBNEW_CLASS_SRCS
    zones_polygons_test_connections.cpp
    zones_test_and_combine_areas.cpp
    class_footprint_wizard.cpp
    
    tools/selection_tool.cpp
    tools/selection_area.cpp
    tools/pcb_tools.cpp
    )

set(PCBNEW_SRCS ${PCBNEW_AUTOROUTER_SRCS} ${PCBNEW_CLASS_SRCS} ${PCBNEW_DIALOGS})
Loading