2013-06-14 14:59:52 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-06-12 07:02:06 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras@wanadoo.fr
|
|
|
|
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-06-14 14:59:52 +00:00
|
|
|
*
|
|
|
|
* 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 eeschema/dialogs/dialog_bom.cpp
|
|
|
|
* @brief Dialog box for creating bom and other documents from generic netlist.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <fctsys.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <kiface_i.h>
|
2013-06-14 14:59:52 +00:00
|
|
|
#include <confirm.h>
|
|
|
|
#include <gestfich.h>
|
2015-02-21 09:46:44 +00:00
|
|
|
#include <schframe.h>
|
2013-06-14 14:59:52 +00:00
|
|
|
|
|
|
|
#include <netlist.h>
|
2015-06-12 07:02:06 +00:00
|
|
|
#include <netlist_exporter_generic.h>
|
2013-06-14 14:59:52 +00:00
|
|
|
#include <sch_sheet.h>
|
|
|
|
#include <invoke_sch_dialog.h>
|
|
|
|
#include <dialog_helpers.h>
|
|
|
|
#include <dialog_bom_base.h>
|
2013-06-19 16:11:12 +00:00
|
|
|
#include <html_messagebox.h>
|
2015-06-12 07:02:06 +00:00
|
|
|
#include <reporter.h>
|
2013-06-14 14:59:52 +00:00
|
|
|
|
|
|
|
#define BOM_PLUGINS_KEY wxT("bom_plugins")
|
|
|
|
#define BOM_PLUGIN_SELECTED_KEY wxT("bom_plugin_selected")
|
|
|
|
|
|
|
|
const char * s_bomHelpInfo =
|
|
|
|
#include <dialog_bom_help_html.h>
|
|
|
|
;
|
|
|
|
|
|
|
|
#include <dialog_bom_cfg_lexer.h>
|
|
|
|
|
|
|
|
using namespace T_BOMCFG_T;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class BOM_CFG_READER_PARSER
|
|
|
|
* holds data and functions pertinent to parsing a S-expression file
|
|
|
|
* for a WORKSHEET_LAYOUT.
|
|
|
|
*/
|
|
|
|
class BOM_CFG_READER_PARSER : public DIALOG_BOM_CFG_LEXER
|
|
|
|
{
|
|
|
|
wxArrayString* m_pluginsList;
|
|
|
|
|
|
|
|
public:
|
|
|
|
BOM_CFG_READER_PARSER( wxArrayString* aPlugins,
|
|
|
|
const char* aData, const wxString& aSource );
|
|
|
|
void Parse() throw( PARSE_ERROR, IO_ERROR );
|
|
|
|
|
|
|
|
private:
|
|
|
|
void parsePlugin() throw( IO_ERROR, PARSE_ERROR );
|
|
|
|
};
|
|
|
|
|
|
|
|
// PCB_PLOT_PARAMS_PARSER
|
|
|
|
|
|
|
|
BOM_CFG_READER_PARSER::BOM_CFG_READER_PARSER( wxArrayString* aPlugins,
|
|
|
|
const char* aLine,
|
|
|
|
const wxString& aSource ) :
|
|
|
|
DIALOG_BOM_CFG_LEXER( aLine, aSource )
|
|
|
|
{
|
|
|
|
m_pluginsList = aPlugins;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BOM_CFG_READER_PARSER::Parse() throw( PARSE_ERROR, IO_ERROR )
|
|
|
|
{
|
|
|
|
T token;
|
|
|
|
|
|
|
|
while( ( token = NextTok() ) != T_RIGHT )
|
|
|
|
{
|
|
|
|
if( token == T_EOF)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if( token == T_LEFT )
|
|
|
|
token = NextTok();
|
|
|
|
|
|
|
|
if( token == T_plugins )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
switch( token )
|
|
|
|
{
|
|
|
|
case T_plugin: // Defines a new plugin
|
|
|
|
parsePlugin();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// Unexpected( CurText() );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BOM_CFG_READER_PARSER::parsePlugin() throw( IO_ERROR, PARSE_ERROR )
|
|
|
|
{
|
|
|
|
wxString title, command;
|
|
|
|
|
|
|
|
NeedSYMBOLorNUMBER();
|
|
|
|
title = FromUTF8();
|
|
|
|
|
|
|
|
T token;
|
|
|
|
while( ( token = NextTok() ) != T_RIGHT )
|
|
|
|
{
|
|
|
|
if( token == T_EOF)
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch( token )
|
|
|
|
{
|
|
|
|
case T_LEFT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_cmd:
|
|
|
|
NeedSYMBOLorNUMBER();
|
|
|
|
command = FromUTF8();
|
|
|
|
NeedRIGHT();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_opts:
|
|
|
|
while( ( token = NextTok() ) != T_RIGHT && token != T_EOF );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
Unexpected( CurText() );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ! title.IsEmpty() )
|
|
|
|
{
|
|
|
|
m_pluginsList->Add( title );
|
|
|
|
m_pluginsList->Add( command );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The main dialog frame tu run scripts to build bom
|
|
|
|
class DIALOG_BOM : public DIALOG_BOM_BASE
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
SCH_EDIT_FRAME* m_parent;
|
|
|
|
// The list of scripts (or plugins):
|
|
|
|
// a script descr uses 2 lines:
|
|
|
|
// the first is the title
|
|
|
|
// the second is the command line
|
|
|
|
wxArrayString m_plugins;
|
2014-12-03 19:09:56 +00:00
|
|
|
wxConfigBase* m_config; // to store the "plugins"
|
2013-06-14 14:59:52 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
// Constructor and destructor
|
|
|
|
DIALOG_BOM( SCH_EDIT_FRAME* parent );
|
|
|
|
~DIALOG_BOM();
|
|
|
|
|
|
|
|
private:
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
void OnPluginSelected( wxCommandEvent& event );
|
2013-06-14 14:59:52 +00:00
|
|
|
void OnRunPlugin( wxCommandEvent& event );
|
|
|
|
void OnCancelClick( wxCommandEvent& event );
|
|
|
|
void OnHelp( wxCommandEvent& event );
|
|
|
|
void OnAddPlugin( wxCommandEvent& event );
|
|
|
|
void OnRemovePlugin( wxCommandEvent& event );
|
|
|
|
void OnEditPlugin( wxCommandEvent& event );
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
void OnCommandLineEdited( wxCommandEvent& event );
|
|
|
|
void OnNameEdited( wxCommandEvent& event );
|
2013-06-14 14:59:52 +00:00
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
void pluginInit();
|
2013-06-14 14:59:52 +00:00
|
|
|
void installPluginsList();
|
2014-12-03 19:09:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the Plugin filename from a command line
|
|
|
|
* @param aCommand = the command line
|
|
|
|
*/
|
|
|
|
wxString getPluginFileName( const wxString& aCommand );
|
2014-12-03 16:22:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* display (when exists) the text found between the keyword "@package"
|
2014-12-03 19:09:56 +00:00
|
|
|
* (compatible with doxygen comments)
|
2014-12-03 16:22:06 +00:00
|
|
|
* and the end of comment block (""" in python", --> in xml)
|
|
|
|
*/
|
|
|
|
void displayPluginInfo( FILE * aFile, const wxString& aFilename );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Browse plugin files, and set m_CommandStringCtrl field
|
2014-12-03 19:09:56 +00:00
|
|
|
* @return a command line ro run the plugin
|
2014-12-03 16:22:06 +00:00
|
|
|
*/
|
2014-12-03 19:09:56 +00:00
|
|
|
wxString choosePlugin();
|
2013-06-14 14:59:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Create and show DIALOG_BOM.
|
|
|
|
int InvokeDialogCreateBOM( SCH_EDIT_FRAME* aCaller )
|
|
|
|
{
|
|
|
|
DIALOG_BOM dlg( aCaller );
|
|
|
|
return dlg.ShowModal();
|
|
|
|
}
|
|
|
|
|
|
|
|
DIALOG_BOM::DIALOG_BOM( SCH_EDIT_FRAME* parent ) :
|
|
|
|
DIALOG_BOM_BASE( parent )
|
|
|
|
{
|
|
|
|
m_parent = parent;
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
m_config = Kiface().KifaceSettings();
|
2013-06-14 14:59:52 +00:00
|
|
|
installPluginsList();
|
|
|
|
|
2014-11-19 14:22:47 +00:00
|
|
|
GetSizer()->Fit( this );
|
2013-06-14 14:59:52 +00:00
|
|
|
Centre();
|
|
|
|
}
|
|
|
|
|
|
|
|
DIALOG_BOM::~DIALOG_BOM()
|
|
|
|
{
|
|
|
|
// Save the plugin descriptions in config.
|
|
|
|
// the config stores only one string.
|
|
|
|
// plugins are saved inside a S expr:
|
|
|
|
// ( plugins
|
|
|
|
// ( plugin "plugin name" (cmd "command line") )
|
|
|
|
// ....
|
|
|
|
// )
|
|
|
|
|
|
|
|
STRING_FORMATTER writer;
|
2013-06-17 19:01:47 +00:00
|
|
|
writer.Print( 0, "(plugins" );
|
2014-12-03 16:22:06 +00:00
|
|
|
|
2013-06-14 14:59:52 +00:00
|
|
|
for( unsigned ii = 0; ii < m_plugins.GetCount(); ii += 2 )
|
|
|
|
{
|
|
|
|
writer.Print( 1, "(plugin %s (cmd %s))",
|
|
|
|
writer.Quotew( m_plugins[ii] ).c_str(),
|
|
|
|
writer.Quotew( m_plugins[ii+1] ).c_str() );
|
|
|
|
}
|
2014-12-03 16:22:06 +00:00
|
|
|
|
2013-06-17 19:01:47 +00:00
|
|
|
writer.Print( 0, ")" );
|
2013-06-14 14:59:52 +00:00
|
|
|
|
2013-06-17 19:01:47 +00:00
|
|
|
wxString list( FROM_UTF8( writer.GetString().c_str() ) );
|
2013-06-14 14:59:52 +00:00
|
|
|
|
|
|
|
m_config->Write( BOM_PLUGINS_KEY, list );
|
|
|
|
|
|
|
|
wxString active_plugin_name = m_lbPlugins->GetStringSelection( );
|
|
|
|
m_config->Write( BOM_PLUGIN_SELECTED_KEY, active_plugin_name );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read the initialized plugins in config and fill the list
|
|
|
|
* of names
|
|
|
|
*/
|
|
|
|
void DIALOG_BOM::installPluginsList()
|
|
|
|
{
|
2013-06-17 19:01:47 +00:00
|
|
|
wxString list, active_plugin_name;
|
2013-06-14 14:59:52 +00:00
|
|
|
m_config->Read( BOM_PLUGINS_KEY, &list );
|
|
|
|
m_config->Read( BOM_PLUGIN_SELECTED_KEY, &active_plugin_name );
|
|
|
|
|
|
|
|
if( !list.IsEmpty() )
|
|
|
|
{
|
2013-06-17 19:01:47 +00:00
|
|
|
BOM_CFG_READER_PARSER cfg_parser( &m_plugins, TO_UTF8( list ),
|
|
|
|
wxT( "plugins" ) );
|
2013-06-14 14:59:52 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
cfg_parser.Parse();
|
|
|
|
}
|
2014-04-09 13:33:04 +00:00
|
|
|
catch( const IO_ERROR& ioe )
|
2013-06-14 14:59:52 +00:00
|
|
|
{
|
|
|
|
// wxLogMessage( ioe.errorText );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Populate list box
|
|
|
|
for( unsigned ii = 0; ii < m_plugins.GetCount(); ii+=2 )
|
|
|
|
{
|
|
|
|
m_lbPlugins->Append( m_plugins[ii] );
|
|
|
|
|
|
|
|
if( active_plugin_name == m_plugins[ii] )
|
|
|
|
m_lbPlugins->SetSelection( ii/2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
pluginInit();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DIALOG_BOM::OnPluginSelected( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
pluginInit();
|
|
|
|
}
|
|
|
|
|
2014-12-03 16:22:06 +00:00
|
|
|
#include <wx/ffile.h>
|
2013-06-14 14:59:52 +00:00
|
|
|
void DIALOG_BOM::pluginInit()
|
|
|
|
{
|
|
|
|
int ii = m_lbPlugins->GetSelection();
|
|
|
|
|
|
|
|
if( ii < 0 )
|
2013-06-15 18:02:52 +00:00
|
|
|
{
|
|
|
|
m_textCtrlName->SetValue( wxEmptyString );
|
|
|
|
m_textCtrlCommand->SetValue( wxEmptyString );
|
2013-06-14 14:59:52 +00:00
|
|
|
return;
|
2013-06-15 18:02:52 +00:00
|
|
|
}
|
2013-06-14 14:59:52 +00:00
|
|
|
|
|
|
|
m_textCtrlName->SetValue( m_plugins[2 * ii] );
|
|
|
|
m_textCtrlCommand->SetValue( m_plugins[(2 * ii)+1] );
|
2014-12-03 16:22:06 +00:00
|
|
|
|
2014-12-03 19:09:56 +00:00
|
|
|
wxString pluginName = getPluginFileName( m_textCtrlCommand->GetValue() );
|
2014-12-03 16:22:06 +00:00
|
|
|
|
|
|
|
if( pluginName.IsEmpty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
FILE* pluginFile = wxFopen( pluginName, "rt" );
|
|
|
|
|
|
|
|
if( pluginFile == NULL )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Failed to open file '%s'" ), GetChars( pluginName ) );
|
|
|
|
DisplayError( this, msg );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
displayPluginInfo( pluginFile, pluginName );
|
2013-06-14 14:59:52 +00:00
|
|
|
}
|
|
|
|
|
2014-12-03 19:09:56 +00:00
|
|
|
|
2014-12-03 16:22:06 +00:00
|
|
|
void DIALOG_BOM::displayPluginInfo( FILE * aFile, const wxString& aFilename )
|
|
|
|
{
|
|
|
|
m_Messages->Clear();
|
|
|
|
|
|
|
|
// display (when exists) the text found between the keyword "@package"
|
2014-12-03 19:09:56 +00:00
|
|
|
// (compatible with doxygen comments)
|
2014-12-03 16:22:06 +00:00
|
|
|
// and the end of comment block (""" in python", --> in xml)
|
|
|
|
|
|
|
|
wxString data;
|
|
|
|
wxFFile fdata( aFile ); // dtor will close the file
|
|
|
|
|
|
|
|
if( !fdata.ReadAll( &data ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxString header( wxT( "@package" ) );
|
|
|
|
wxString endsection( wxT( "-->" ) ); // For xml
|
|
|
|
|
|
|
|
wxFileName fn( aFilename );
|
|
|
|
|
|
|
|
if( fn.GetExt().IsSameAs( wxT("py"), false ) )
|
|
|
|
endsection = wxT( "\"\"\"" );
|
2014-12-03 19:09:56 +00:00
|
|
|
else if( !fn.GetExt().IsSameAs( wxT("xsl"), false ) )
|
|
|
|
// If this is not a python file, we know nothing about file
|
|
|
|
// and the info cannot be found
|
|
|
|
return;
|
2014-12-03 16:22:06 +00:00
|
|
|
|
|
|
|
// Extract substring between @package and """
|
|
|
|
int strstart = data.Find( header );
|
|
|
|
|
|
|
|
if( strstart == wxNOT_FOUND )
|
|
|
|
return;
|
|
|
|
|
|
|
|
strstart += header.Length();
|
|
|
|
int strend = data.find( endsection, strstart );
|
|
|
|
|
|
|
|
if( strend == wxNOT_FOUND)
|
|
|
|
return;
|
|
|
|
|
2015-06-12 07:02:06 +00:00
|
|
|
// Remove empty line if any
|
2014-12-03 16:22:06 +00:00
|
|
|
while( data[strstart] < ' ' )
|
|
|
|
strstart++;
|
|
|
|
|
|
|
|
m_Messages->SetValue( data.SubString( strstart, strend-1 ) );
|
|
|
|
}
|
2013-06-14 14:59:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function RunPlugin
|
|
|
|
* run the plugin command line
|
|
|
|
*/
|
|
|
|
void DIALOG_BOM::OnRunPlugin( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
wxFileName fn;
|
|
|
|
|
|
|
|
// Calculate the xml netlist filename
|
|
|
|
fn = g_RootSheet->GetScreen()->GetFileName();
|
|
|
|
|
2015-05-26 15:13:33 +00:00
|
|
|
fn.SetPath( wxPathOnly( Prj().GetProjectFullName() ) );
|
2013-06-14 14:59:52 +00:00
|
|
|
|
|
|
|
fn.ClearExt();
|
|
|
|
wxString fullfilename = fn.GetFullPath();
|
|
|
|
m_parent->ClearMsgPanel();
|
|
|
|
|
2015-06-12 07:02:06 +00:00
|
|
|
wxString reportmsg;
|
|
|
|
WX_STRING_REPORTER reporter( &reportmsg );
|
2013-06-14 14:59:52 +00:00
|
|
|
m_parent->SetNetListerCommand( m_textCtrlCommand->GetValue() );
|
2015-06-12 07:02:06 +00:00
|
|
|
m_parent->CreateNetlist( -1, fullfilename, 0, &reporter );
|
|
|
|
|
|
|
|
m_Messages->SetValue( reportmsg );
|
2013-06-14 14:59:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_BOM::OnCancelClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
EndModal( wxID_CANCEL );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function OnRemovePlugin
|
|
|
|
* Remove a plugin from the list
|
|
|
|
*/
|
|
|
|
void DIALOG_BOM::OnRemovePlugin( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
int ii = m_lbPlugins->GetSelection();
|
|
|
|
|
|
|
|
if( ii < 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_lbPlugins->Delete( ii );
|
|
|
|
|
|
|
|
m_plugins.RemoveAt( 2*ii, 2 ); // Remove title and command line
|
2013-06-15 18:02:52 +00:00
|
|
|
|
|
|
|
// Select the next item, if exists
|
|
|
|
if( (int)m_lbPlugins->GetCount() >= ii )
|
|
|
|
ii = m_lbPlugins->GetCount() - 1;
|
|
|
|
|
|
|
|
if( ii >= 0 )
|
|
|
|
m_lbPlugins->SetSelection( ii );
|
|
|
|
|
|
|
|
pluginInit();
|
2013-06-14 14:59:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function OnAddPlugin
|
|
|
|
* Add a new panel for a new netlist plugin
|
|
|
|
*/
|
|
|
|
void DIALOG_BOM::OnAddPlugin( wxCommandEvent& event )
|
|
|
|
{
|
2014-12-03 19:09:56 +00:00
|
|
|
wxString cmdLine = choosePlugin();
|
|
|
|
|
|
|
|
if( cmdLine.IsEmpty() )
|
|
|
|
return;
|
|
|
|
|
2013-06-14 14:59:52 +00:00
|
|
|
// Creates a new plugin entry
|
2014-12-03 19:09:56 +00:00
|
|
|
wxFileName fn( getPluginFileName( cmdLine ) );
|
|
|
|
|
|
|
|
wxString defaultName = fn.GetName();
|
|
|
|
wxString name = wxGetTextFromUser( _("Plugin name in plugin list") ,
|
|
|
|
_("Plugin name"), defaultName );
|
2013-06-14 14:59:52 +00:00
|
|
|
|
|
|
|
if( name.IsEmpty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Verify if it does not exists
|
|
|
|
for( unsigned ii = 0; ii < m_plugins.GetCount(); ii += 2 )
|
|
|
|
{
|
|
|
|
if( name == m_plugins[ii] )
|
|
|
|
{
|
2014-12-03 16:22:06 +00:00
|
|
|
wxMessageBox( _("This name already exists. Abort") );
|
2013-06-14 14:59:52 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-03 19:09:56 +00:00
|
|
|
// Eppend the new plugin
|
2013-06-14 14:59:52 +00:00
|
|
|
m_plugins.Add( name );
|
|
|
|
m_plugins.Add( wxEmptyString );
|
2014-12-03 19:09:56 +00:00
|
|
|
m_lbPlugins->SetSelection( m_lbPlugins->GetCount() - 1 );
|
2013-06-14 14:59:52 +00:00
|
|
|
m_lbPlugins->Append( name );
|
|
|
|
m_lbPlugins->SetSelection( m_lbPlugins->GetCount() - 1 );
|
2014-12-03 19:09:56 +00:00
|
|
|
m_textCtrlCommand->SetValue( cmdLine );
|
2014-12-03 16:22:06 +00:00
|
|
|
|
2013-06-15 18:02:52 +00:00
|
|
|
pluginInit();
|
2013-06-14 14:59:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Browse plugin files, and set m_CommandStringCtrl field
|
|
|
|
*/
|
2014-12-03 19:09:56 +00:00
|
|
|
wxString DIALOG_BOM::choosePlugin()
|
2013-06-14 14:59:52 +00:00
|
|
|
{
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxString mask = wxT( "*" );
|
2014-10-17 17:45:33 +00:00
|
|
|
#ifndef __WXMAC__
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxString path = Pgm().GetExecutablePath();
|
2014-10-17 17:45:33 +00:00
|
|
|
#else
|
|
|
|
wxString path = GetOSXKicadDataDir() + wxT( "/plugins" );
|
|
|
|
#endif
|
2013-06-14 14:59:52 +00:00
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxString fullFileName = EDA_FileSelector( _( "Plugin files:" ),
|
|
|
|
path,
|
2013-06-14 14:59:52 +00:00
|
|
|
wxEmptyString,
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxEmptyString,
|
|
|
|
mask,
|
2013-06-14 14:59:52 +00:00
|
|
|
this,
|
|
|
|
wxFD_OPEN,
|
|
|
|
true
|
|
|
|
);
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
if( fullFileName.IsEmpty() )
|
2014-12-03 19:09:56 +00:00
|
|
|
return wxEmptyString;
|
2013-06-14 14:59:52 +00:00
|
|
|
|
|
|
|
// Creates a default command line,
|
|
|
|
// suitable to run the external tool xslproc or python
|
|
|
|
// The default command line depending on plugin extension, currently
|
|
|
|
// "xsl" or "exe" or "py"
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxString cmdLine;
|
|
|
|
wxFileName fn( fullFileName );
|
|
|
|
wxString ext = fn.GetExt();
|
2013-06-14 14:59:52 +00:00
|
|
|
|
|
|
|
if( ext == wxT("xsl" ) )
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
cmdLine.Printf(wxT("xsltproc -o \"%%O\" \"%s\" \"%%I\""), GetChars( fullFileName ) );
|
2013-06-14 14:59:52 +00:00
|
|
|
else if( ext == wxT("exe" ) || ext.IsEmpty() )
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
cmdLine.Printf(wxT("\"%s\" < \"%%I\" > \"%%O\""), GetChars( fullFileName ) );
|
2013-06-14 14:59:52 +00:00
|
|
|
else if( ext == wxT("py" ) || ext.IsEmpty() )
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
cmdLine.Printf(wxT("python \"%s\" \"%%I\" \"%%O\""), GetChars( fullFileName ) );
|
2013-06-14 14:59:52 +00:00
|
|
|
else
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
cmdLine.Printf(wxT("\"%s\""), GetChars( fullFileName ) );
|
2013-06-14 14:59:52 +00:00
|
|
|
|
2014-12-03 19:09:56 +00:00
|
|
|
return cmdLine;
|
2013-06-14 14:59:52 +00:00
|
|
|
}
|
|
|
|
|
2014-12-03 16:22:06 +00:00
|
|
|
|
2014-12-03 19:09:56 +00:00
|
|
|
wxString DIALOG_BOM::getPluginFileName( const wxString& aCommand )
|
2013-06-14 14:59:52 +00:00
|
|
|
{
|
2014-12-03 16:22:06 +00:00
|
|
|
wxString pluginName;
|
2013-06-14 14:59:52 +00:00
|
|
|
|
|
|
|
// Try to find the plugin name.
|
|
|
|
// This is possible if the name ends by .py or .xsl
|
|
|
|
int pos = -1;
|
|
|
|
|
2014-12-03 19:09:56 +00:00
|
|
|
if( (pos = aCommand.Find( wxT(".py") )) != wxNOT_FOUND )
|
2013-06-14 14:59:52 +00:00
|
|
|
pos += 2;
|
2014-12-03 19:09:56 +00:00
|
|
|
else if( (pos = aCommand.Find( wxT(".xsl") )) != wxNOT_FOUND )
|
2013-06-14 14:59:52 +00:00
|
|
|
pos += 3;
|
|
|
|
|
|
|
|
// the end of plugin name is at position pos.
|
|
|
|
if( pos > 0 )
|
|
|
|
{
|
|
|
|
// Be sure this is the end of the name: the next char is " or space
|
2014-12-03 19:09:56 +00:00
|
|
|
int eos = aCommand[pos+1];
|
2013-06-14 14:59:52 +00:00
|
|
|
|
|
|
|
if( eos == ' '|| eos == '\"' )
|
|
|
|
{
|
|
|
|
// search for the starting point of the name
|
|
|
|
int jj = pos-1;
|
|
|
|
while( jj >= 0 )
|
2014-12-03 19:09:56 +00:00
|
|
|
if( aCommand[jj] != eos )
|
2013-06-14 14:59:52 +00:00
|
|
|
jj--;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
|
|
|
|
// extract the name
|
|
|
|
if( jj >= 0 )
|
2014-12-03 16:22:06 +00:00
|
|
|
{
|
2014-12-03 19:09:56 +00:00
|
|
|
eos = aCommand[jj];
|
2014-12-03 16:22:06 +00:00
|
|
|
|
|
|
|
if( eos == ' '|| eos == '\"' ) // do not include delimiters
|
|
|
|
jj++;
|
|
|
|
|
2014-12-03 19:09:56 +00:00
|
|
|
pluginName = aCommand.SubString( jj, pos );
|
2014-12-03 16:22:06 +00:00
|
|
|
}
|
2013-06-14 14:59:52 +00:00
|
|
|
}
|
|
|
|
}
|
2014-12-03 16:22:06 +00:00
|
|
|
|
2015-06-29 16:34:31 +00:00
|
|
|
// Using a format like %P is possible in plugin name, so expand it
|
|
|
|
wxString prj_dir = Prj().GetProjectPath();
|
|
|
|
|
|
|
|
if( prj_dir.EndsWith( '/' ) || prj_dir.EndsWith( '\\' ) )
|
|
|
|
prj_dir.RemoveLast();
|
|
|
|
|
|
|
|
pluginName.Replace( wxT( "%P" ), prj_dir.GetData(), true );
|
|
|
|
|
2014-12-03 16:22:06 +00:00
|
|
|
return pluginName;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DIALOG_BOM::OnEditPlugin( wxCommandEvent& event )
|
|
|
|
{
|
2014-12-03 19:09:56 +00:00
|
|
|
wxString pluginName = getPluginFileName( m_textCtrlCommand->GetValue() );
|
2014-12-03 16:22:06 +00:00
|
|
|
|
|
|
|
if( pluginName.Length() <= 2 ) // if name != ""
|
|
|
|
{
|
|
|
|
wxMessageBox( _("Plugin file name not found. Cannot edit plugin file") );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-14 14:59:52 +00:00
|
|
|
AddDelimiterString( pluginName );
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxString editorname = Pgm().GetEditorName();
|
2013-06-14 14:59:52 +00:00
|
|
|
|
|
|
|
if( !editorname.IsEmpty() )
|
|
|
|
ExecuteFile( this, editorname, pluginName );
|
|
|
|
else
|
|
|
|
wxMessageBox( _("No text editor selected in KiCad. Please choose it") );
|
|
|
|
}
|
|
|
|
|
|
|
|
void DIALOG_BOM::OnHelp( wxCommandEvent& event )
|
|
|
|
{
|
2013-06-19 16:11:12 +00:00
|
|
|
HTML_MESSAGE_BOX help_Dlg( this, _("Bom Generation Help"),
|
|
|
|
wxDefaultPosition, wxSize( 750,550 ) );
|
2013-06-14 14:59:52 +00:00
|
|
|
|
|
|
|
wxString msg = FROM_UTF8(s_bomHelpInfo);
|
|
|
|
help_Dlg.m_htmlWindow->AppendToPage( msg );
|
|
|
|
help_Dlg.ShowModal();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DIALOG_BOM::OnCommandLineEdited( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
int ii = m_lbPlugins->GetSelection();
|
|
|
|
|
|
|
|
if( ii < 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_plugins[(2 * ii)+1] = m_textCtrlCommand->GetValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DIALOG_BOM::OnNameEdited( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
int ii = m_lbPlugins->GetSelection();
|
|
|
|
|
|
|
|
if( ii < 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_plugins[2 * ii] = m_textCtrlName->GetValue();
|
|
|
|
m_lbPlugins->SetString( ii, m_plugins[2 * ii] );
|
|
|
|
}
|