qa: added simple GAL+Tool Framework test program
This commit is contained in:
parent
b945d2a708
commit
3292d622c1
|
@ -0,0 +1,327 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file pcbnew.cpp
|
||||
* @brief Pcbnew main program.
|
||||
*/
|
||||
|
||||
#ifdef KICAD_SCRIPTING
|
||||
#include <python_scripting.h>
|
||||
#include <pcbnew_scripting_helpers.h>
|
||||
#endif
|
||||
#include <fctsys.h>
|
||||
#include <pgm_base.h>
|
||||
#include <kiface_i.h>
|
||||
#include <confirm.h>
|
||||
#include <macros.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <wxPcbStruct.h>
|
||||
#include <eda_dde.h>
|
||||
#include <wx/stdpaths.h>
|
||||
|
||||
#include <wx/file.h>
|
||||
#include <wx/snglinst.h>
|
||||
#include <wx/dir.h>
|
||||
#include <gestfich.h>
|
||||
|
||||
#include <pcbnew.h>
|
||||
#include <hotkeys.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <class_board.h>
|
||||
#include <3d_viewer.h>
|
||||
#include <fp_lib_table.h>
|
||||
#include <module_editor_frame.h>
|
||||
#include <modview_frame.h>
|
||||
#include <footprint_wizard_frame.h>
|
||||
|
||||
#include <wxPcbStruct.h>
|
||||
|
||||
#include <class_board.h>
|
||||
#include <class_track.h>
|
||||
#include <class_drawsegment.h>
|
||||
#include <class_pcb_text.h>
|
||||
#include <class_pcb_target.h>
|
||||
#include <class_module.h>
|
||||
#include <class_dimension.h>
|
||||
#include <class_zone.h>
|
||||
#include <class_edge_mod.h>
|
||||
|
||||
#include <tools/pcb_actions.h>
|
||||
|
||||
#include "pcb_tool.h"
|
||||
#include <dialog_find.h>
|
||||
#include <dialog_block_options.h>
|
||||
|
||||
bool g_Drc_On = true;
|
||||
bool g_AutoDeleteOldTrack = true;
|
||||
bool g_Raccord_45_Auto = true;
|
||||
bool g_Alternate_Track_Posture = false;
|
||||
bool g_Track_45_Only_Allowed = true; // True to allow horiz, vert. and 45deg only tracks
|
||||
bool g_Segments_45_Only; // True to allow horiz, vert. and 45deg only graphic segments
|
||||
bool g_TwoSegmentTrackBuild = true;
|
||||
|
||||
PCB_LAYER_ID g_Route_Layer_TOP;
|
||||
PCB_LAYER_ID g_Route_Layer_BOTTOM;
|
||||
int g_MagneticPadOption;
|
||||
int g_MagneticTrackOption;
|
||||
|
||||
wxPoint g_Offset_Module; // module offset used when moving a footprint
|
||||
|
||||
/* Name of the document footprint list
|
||||
* usually located in share/modules/footprints_doc
|
||||
* this is of the responsibility to users to create this file
|
||||
* if they want to have a list of footprints
|
||||
*/
|
||||
wxString g_DocModulesFileName = wxT( "footprints_doc/footprints.pdf" );
|
||||
|
||||
/*
|
||||
* Used in track creation, a list of track segments currently being created,
|
||||
* with the newest track at the end of the list, sorted by new-ness. e.g. use
|
||||
* TRACK->Back() to get the next older track, TRACK->Next() to get the next
|
||||
* newer track.
|
||||
*/
|
||||
DLIST<TRACK> g_CurrentTrackList;
|
||||
|
||||
bool g_DumpZonesWhenFilling = false;
|
||||
|
||||
static struct IFACE : public KIFACE_I
|
||||
{
|
||||
// Of course all are overloads, implementations of the KIFACE.
|
||||
|
||||
IFACE( const char* aName, KIWAY::FACE_T aType ) :
|
||||
KIFACE_I( aName, aType )
|
||||
{}
|
||||
|
||||
bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnKifaceEnd() {}
|
||||
|
||||
wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 )
|
||||
{
|
||||
assert( false );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function IfaceOrAddress
|
||||
* return a pointer to the requested object. The safest way to use this
|
||||
* is to retrieve a pointer to a static instance of an interface, similar to
|
||||
* how the KIFACE interface is exported. But if you know what you are doing
|
||||
* use it to retrieve anything you want.
|
||||
*
|
||||
* @param aDataId identifies which object you want the address of.
|
||||
*
|
||||
* @return void* - and must be cast into the know type.
|
||||
*/
|
||||
void* IfaceOrAddress( int aDataId )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
kiface( "pcb_test_frame", KIWAY::FACE_PCB );
|
||||
|
||||
static struct PGM_TEST_FRAME : public PGM_BASE
|
||||
{
|
||||
bool OnPgmInit();
|
||||
|
||||
void OnPgmExit()
|
||||
{
|
||||
Kiway.OnKiwayEnd();
|
||||
|
||||
// Destroy everything in PGM_BASE, especially wxSingleInstanceCheckerImpl
|
||||
// earlier than wxApp and earlier than static destruction would.
|
||||
PGM_BASE::Destroy();
|
||||
}
|
||||
|
||||
void MacOpenFile( const wxString& aFileName ) override
|
||||
{
|
||||
wxFileName filename( aFileName );
|
||||
|
||||
if( filename.FileExists() )
|
||||
{
|
||||
#if 0
|
||||
// this pulls in EDA_DRAW_FRAME type info, which we don't want in
|
||||
// the single_top link image.
|
||||
KIWAY_PLAYER* frame = dynamic_cast<KIWAY_PLAYER*>( App().GetTopWindow() );
|
||||
#else
|
||||
KIWAY_PLAYER* frame = (KIWAY_PLAYER*) App().GetTopWindow();
|
||||
#endif
|
||||
|
||||
if( frame )
|
||||
frame->OpenProjectFiles( std::vector<wxString>( 1, aFileName ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
program;
|
||||
|
||||
PGM_BASE& Pgm()
|
||||
{
|
||||
return program;
|
||||
}
|
||||
|
||||
|
||||
KIFACE_I& Kiface()
|
||||
{
|
||||
return kiface;
|
||||
}
|
||||
|
||||
|
||||
FP_LIB_TABLE GFootprintTable;
|
||||
|
||||
void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const wxPoint& offset )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Initialize static member variables
|
||||
wxString DIALOG_FIND::prevSearchString;
|
||||
bool DIALOG_FIND::warpMouse = true;
|
||||
|
||||
|
||||
DIALOG_FIND::DIALOG_FIND( PCB_BASE_FRAME* aParent ) : DIALOG_FIND_BASE( aParent )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_FIND::OnInitDialog( wxInitDialogEvent& event )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_FIND::EnableWarp( bool aEnabled )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_FIND::onButtonCloseClick( wxCommandEvent& aEvent )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_FIND::onButtonFindItemClick( wxCommandEvent& aEvent )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_FIND::onButtonFindMarkerClick( wxCommandEvent& aEvent )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_FIND::onClose( wxCloseEvent& aEvent )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DIALOG_FIND_BASE::DIALOG_FIND_BASE( wxWindow* parent,
|
||||
wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DIALOG_FIND_BASE::~DIALOG_FIND_BASE()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
MODULE* PCB_BASE_FRAME::GetFootprintFromBoardByReference()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::selectionModified( "pcbnew.InteractiveEdit.ModifiedSelection",
|
||||
AS_GLOBAL, 0,
|
||||
"", "", nullptr, AF_NOTIFY );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::flip( "pcbnew.InteractiveEdit.flip",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_FLIP_ITEM ),
|
||||
_( "Flip" ), _( "Flips selected item(s)" ), nullptr );
|
||||
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::properties( "pcbnew.InteractiveEdit.properties",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT_ITEM ),
|
||||
_( "Properties" ), _( "Displays item properties dialog" ), nullptr );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::highlightNet( "pcbnew.EditorControl.highlightNet",
|
||||
AS_GLOBAL, 0,
|
||||
"", "" );
|
||||
|
||||
|
||||
DIALOG_BLOCK_OPTIONS_BASE::DIALOG_BLOCK_OPTIONS_BASE( wxWindow* parent,
|
||||
wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DIALOG_BLOCK_OPTIONS_BASE::~DIALOG_BLOCK_OPTIONS_BASE()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::rotateCw( "pcbnew.InteractiveEdit.rotateCw",
|
||||
AS_GLOBAL, MD_SHIFT + 'R',
|
||||
_( "Rotate Clockwise" ), _( "Rotates selected item(s) clockwise" ),
|
||||
nullptr, AF_NONE, (void*) -1 );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::rotateCcw( "pcbnew.InteractiveEdit.rotateCcw",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ROTATE_ITEM ),
|
||||
_( "Rotate Counterclockwise" ), _( "Rotates selected item(s) counterclockwise" ),
|
||||
nullptr, AF_NONE, (void*) 1 );
|
||||
|
||||
DIALOG_BLOCK_OPTIONS::DIALOG_BLOCK_OPTIONS( PCB_BASE_FRAME* aParent,
|
||||
OPTIONS& aOptions, bool aShowLegacyOptions,
|
||||
const wxString& aTitle ) :
|
||||
DIALOG_BLOCK_OPTIONS_BASE( aParent, -1, aTitle ),
|
||||
m_options( aOptions )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_BLOCK_OPTIONS::checkBoxClicked( wxCommandEvent& aEvent )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_BLOCK_OPTIONS::ExecuteCommand( wxCommandEvent& event )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount )
|
||||
{
|
||||
}
|
|
@ -0,0 +1,230 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013-2017 CERN
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <wx/timer.h>
|
||||
#include <wx/math.h>
|
||||
#include <wx/log.h>
|
||||
#include <wx/popupwin.h>
|
||||
#include <wx/cmdline.h>
|
||||
|
||||
#include <layers_id_colors_and_visibility.h>
|
||||
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
#include <view/view.h>
|
||||
#include <class_draw_panel_gal.h>
|
||||
#include <pcb_draw_panel_gal.h>
|
||||
#include <view/wx_view_controls.h>
|
||||
#include <pcb_painter.h>
|
||||
|
||||
#include <class_pad.h>
|
||||
#include <class_module.h>
|
||||
#include <class_board.h>
|
||||
#include <class_track.h>
|
||||
#include <class_zone.h>
|
||||
|
||||
#include <pcb_painter.h>
|
||||
#include <wxPcbStruct.h>
|
||||
|
||||
#include <connectivity.h>
|
||||
|
||||
#include <io_mgr.h>
|
||||
#include <set>
|
||||
|
||||
#include <tool/actions.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tool/tool_dispatcher.h>
|
||||
#include <tools/pcb_tool.h>
|
||||
#include <tools/pcb_actions.h>
|
||||
#include <tools/selection_tool.h>
|
||||
#include <kicad_plugin.h>
|
||||
|
||||
#include "pcb_test_frame.h"
|
||||
|
||||
IMPLEMENT_APP( GAL_TEST_APP )
|
||||
|
||||
using namespace KIGFX;
|
||||
|
||||
bool GAL_TEST_APP::OnInit()
|
||||
{
|
||||
if( !wxApp::OnInit() )
|
||||
return false;
|
||||
|
||||
// Create the main frame window
|
||||
auto frame = CreateMainFrame( (const char*) m_filename.c_str() );
|
||||
|
||||
return frame != nullptr;
|
||||
}
|
||||
|
||||
|
||||
void GAL_TEST_APP::OnInitCmdLine( wxCmdLineParser& parser )
|
||||
{
|
||||
parser.AddOption( "f", wxEmptyString, "Open board file" );
|
||||
wxApp::OnInitCmdLine( parser );
|
||||
}
|
||||
|
||||
|
||||
bool GAL_TEST_APP::OnCmdLineParsed( wxCmdLineParser& parser )
|
||||
{
|
||||
wxString filename;
|
||||
|
||||
if( parser.Found( "f", &filename ) )
|
||||
{
|
||||
m_filename = filename;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
class TEST_ACTIONS : public ACTIONS
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~TEST_ACTIONS() {};
|
||||
|
||||
virtual boost::optional<TOOL_EVENT> TranslateLegacyId( int aId )
|
||||
{
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
void RegisterAllTools( TOOL_MANAGER* aToolManager )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
void PCB_TEST_FRAME::OnMenuFileOpen( wxCommandEvent& WXUNUSED( event ) )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void PCB_TEST_FRAME::OnMotion( wxMouseEvent& aEvent )
|
||||
{
|
||||
aEvent.Skip();
|
||||
}
|
||||
|
||||
|
||||
void PCB_TEST_FRAME::SetBoard( BOARD* b )
|
||||
{
|
||||
m_board.reset( b );
|
||||
m_board->GetConnectivity()->Build( m_board.get() );
|
||||
m_galPanel->DisplayBoard( m_board.get() );
|
||||
m_toolManager->SetEnvironment( m_board.get(), m_galPanel->GetView(),
|
||||
m_galPanel->GetViewControls(), nullptr );
|
||||
|
||||
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
||||
}
|
||||
|
||||
|
||||
BOARD* PCB_TEST_FRAME::LoadAndDisplayBoard( const std::string& filename )
|
||||
{
|
||||
PLUGIN::RELEASER pi( new PCB_IO );
|
||||
BOARD* brd = nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
brd = pi->Load( wxString( filename.c_str() ), NULL, NULL );
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
wxString msg = wxString::Format( _( "Error loading board.\n%s" ),
|
||||
ioe.Problem() );
|
||||
|
||||
printf( "%s\n", (const char*) msg.mb_str() );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SetBoard( brd );
|
||||
|
||||
return brd;
|
||||
}
|
||||
|
||||
|
||||
PCB_TEST_FRAME::PCB_TEST_FRAME( wxFrame* frame, const wxString& title, const wxPoint& pos,
|
||||
const wxSize& size, long style ) :
|
||||
wxFrame( frame, wxID_ANY, title, pos, size, style )
|
||||
{
|
||||
// Make a menubar
|
||||
wxMenu* fileMenu = new wxMenu;
|
||||
|
||||
fileMenu->Append( wxID_OPEN, wxT( "&Open..." ) );
|
||||
fileMenu->AppendSeparator();
|
||||
fileMenu->Append( wxID_EXIT, wxT( "E&xit" ) );
|
||||
wxMenuBar* menuBar = new wxMenuBar;
|
||||
menuBar->Append( fileMenu, wxT( "&File" ) );
|
||||
SetMenuBar( menuBar );
|
||||
|
||||
Show( true );
|
||||
Maximize();
|
||||
Raise();
|
||||
|
||||
KIGFX::GAL_DISPLAY_OPTIONS options;
|
||||
|
||||
m_galPanel.reset( new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0,
|
||||
0 ), wxDefaultSize, options, EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) );
|
||||
|
||||
m_galPanel->SetEvtHandlerEnabled( true );
|
||||
m_galPanel->SetFocus();
|
||||
m_galPanel->Show( true );
|
||||
m_galPanel->Raise();
|
||||
m_galPanel->StartDrawing();
|
||||
|
||||
auto gal = m_galPanel->GetGAL();
|
||||
|
||||
gal->SetGridVisibility( true );
|
||||
gal->SetGridSize( VECTOR2D( 100000.0, 100000.0 ) );
|
||||
gal->SetGridOrigin( VECTOR2D( 0.0, 0.0 ) );
|
||||
|
||||
m_galPanel->Connect( wxEVT_MOTION,
|
||||
wxMouseEventHandler( PCB_TEST_FRAME::OnMotion ), NULL, this );
|
||||
|
||||
m_galPanel->GetViewControls()->ShowCursor( true );
|
||||
|
||||
m_toolManager.reset( new TOOL_MANAGER );
|
||||
m_toolManager->SetEnvironment( m_board.get(), m_galPanel->GetView(),
|
||||
m_galPanel->GetViewControls(), nullptr );
|
||||
|
||||
m_pcbActions.reset( new TEST_ACTIONS() );
|
||||
m_toolDispatcher.reset( new TOOL_DISPATCHER( m_toolManager.get(), m_pcbActions.get() ) );
|
||||
|
||||
m_toolManager->RegisterTool( new SELECTION_TOOL );
|
||||
|
||||
m_toolManager->InitTools();
|
||||
m_galPanel->SetEventDispatcher( m_toolDispatcher.get() );
|
||||
m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
|
||||
|
||||
SetBoard( new BOARD );
|
||||
}
|
||||
|
||||
|
||||
PCB_TEST_FRAME::~PCB_TEST_FRAME()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Intercept menu commands
|
||||
void PCB_TEST_FRAME::OnExit( wxCommandEvent& WXUNUSED( event ) )
|
||||
{
|
||||
// true is to force the frame to close
|
||||
Close( true );
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013-2017 CERN
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef __PCB_TEST_FRAME_H
|
||||
#define __PCB_TEST_FRAME_H
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/app.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
using std::unique_ptr;
|
||||
|
||||
class PCB_DRAW_PANEL_GAL;
|
||||
class BOARD;
|
||||
|
||||
class TOOL_MANAGER;
|
||||
class TOOL_DISPATCHER;
|
||||
class ACTIONS;
|
||||
|
||||
|
||||
namespace KIGFX {
|
||||
class VIEW;
|
||||
};
|
||||
|
||||
// Define a new application type
|
||||
class GAL_TEST_APP : public wxApp
|
||||
{
|
||||
public:
|
||||
virtual bool OnInit();
|
||||
|
||||
virtual void OnInitCmdLine(wxCmdLineParser& parser);
|
||||
virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
|
||||
|
||||
private:
|
||||
wxString m_filename;
|
||||
};
|
||||
|
||||
class PCB_TEST_FRAME : public wxFrame
|
||||
{
|
||||
public:
|
||||
PCB_TEST_FRAME(wxFrame *frame,
|
||||
const wxString& title,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxDEFAULT_FRAME_STYLE);
|
||||
|
||||
virtual ~PCB_TEST_FRAME();
|
||||
|
||||
void SetBoard( BOARD * b);
|
||||
BOARD* LoadAndDisplayBoard ( const std::string& filename );
|
||||
|
||||
protected:
|
||||
|
||||
virtual void OnExit(wxCommandEvent& event);
|
||||
virtual void OnMotion( wxMouseEvent& aEvent );
|
||||
virtual void OnMenuFileOpen( wxCommandEvent& WXUNUSED(event) );
|
||||
|
||||
void buildView();
|
||||
|
||||
unique_ptr < PCB_DRAW_PANEL_GAL > m_galPanel;
|
||||
unique_ptr < BOARD > m_board;
|
||||
unique_ptr < TOOL_MANAGER > m_toolManager;
|
||||
unique_ptr < TOOL_DISPATCHER > m_toolDispatcher;
|
||||
unique_ptr < ACTIONS > m_pcbActions;
|
||||
};
|
||||
|
||||
wxFrame* CreateMainFrame( const std::string& aFileName );
|
||||
|
||||
#endif
|
|
@ -0,0 +1,82 @@
|
|||
|
||||
#
|
||||
# This program source code file is part of KiCad, a free EDA CAD application.
|
||||
#
|
||||
# Copyright (C) 2017 CERN
|
||||
# @author Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, you may find one here:
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
# or you may search the http://www.gnu.org website for the version 2 license,
|
||||
# or you may write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
find_package(Boost COMPONENTS unit_test_framework REQUIRED)
|
||||
find_package( wxWidgets 3.0.0 COMPONENTS gl aui adv html core net base xml stc REQUIRED )
|
||||
|
||||
add_definitions(-DBOOST_TEST_DYN_LINK -DPCBNEW)
|
||||
|
||||
add_executable(test_window
|
||||
test.cpp
|
||||
../common/pcb_test_frame.cpp
|
||||
../common/mocks.cpp
|
||||
../../common/base_units.cpp
|
||||
../../pcbnew/tools/pcb_tool.cpp
|
||||
../../pcbnew/tools/selection.cpp
|
||||
../../pcbnew/tools/selection_tool.cpp
|
||||
../../pcbnew/tools/tool_event_utils.cpp
|
||||
#../../pcbnew/tools/outline_editor.cpp
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/3d-viewer
|
||||
${CMAKE_SOURCE_DIR}/common
|
||||
${CMAKE_SOURCE_DIR}/pcbnew
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/router
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/tools
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/dialogs
|
||||
${CMAKE_SOURCE_DIR}/polygon
|
||||
${CMAKE_SOURCE_DIR}/common/geometry
|
||||
${CMAKE_SOURCE_DIR}/qa/common
|
||||
${Boost_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries( test_window
|
||||
polygon
|
||||
pnsrouter
|
||||
common
|
||||
pcbcommon
|
||||
bitmaps
|
||||
polygon
|
||||
pnsrouter
|
||||
common
|
||||
pcbcommon
|
||||
bitmaps
|
||||
polygon
|
||||
pnsrouter
|
||||
common
|
||||
pcbcommon
|
||||
bitmaps
|
||||
polygon
|
||||
pnsrouter
|
||||
common
|
||||
pcbcommon
|
||||
bitmaps
|
||||
${Boost_FILESYSTEM_LIBRARY}
|
||||
${Boost_SYSTEM_LIBRARY}
|
||||
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
|
||||
${wxWidgets_LIBRARIES}
|
||||
)
|
|
@ -0,0 +1,40 @@
|
|||
#include <pcb_test_frame.h>
|
||||
// #include <tools/outline_editor.h>
|
||||
#include <tool/tool_manager.h>
|
||||
|
||||
class OED_TEST_FRAME : public PCB_TEST_FRAME
|
||||
{
|
||||
public:
|
||||
OED_TEST_FRAME( wxFrame* frame,
|
||||
const wxString& title,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxDEFAULT_FRAME_STYLE ) :
|
||||
PCB_TEST_FRAME( frame, title, pos, size, style )
|
||||
{
|
||||
registerTools();
|
||||
}
|
||||
|
||||
void registerTools();
|
||||
|
||||
virtual ~OED_TEST_FRAME() {}
|
||||
};
|
||||
|
||||
wxFrame* CreateMainFrame( const std::string& aFileName )
|
||||
{
|
||||
auto frame = new OED_TEST_FRAME( nullptr, wxT( "Outline Editor Test" ) );
|
||||
|
||||
if( aFileName != "" )
|
||||
{
|
||||
frame->LoadAndDisplayBoard( aFileName );
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
void OED_TEST_FRAME::registerTools()
|
||||
{
|
||||
// m_toolManager->RegisterTool( new OUTLINE_EDITOR );
|
||||
m_toolManager->InitTools();
|
||||
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
||||
}
|
Loading…
Reference in New Issue