Store relative library path if possible
This commit is contained in:
parent
39caddd22b
commit
53d772989a
|
@ -27,6 +27,7 @@
|
||||||
#include <netlist_exporters/netlist_exporter_pspice.h>
|
#include <netlist_exporters/netlist_exporter_pspice.h>
|
||||||
#include <sim/spice_value.h>
|
#include <sim/spice_value.h>
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
|
#include <project.h>
|
||||||
|
|
||||||
#include <wx/tokenzr.h>
|
#include <wx/tokenzr.h>
|
||||||
|
|
||||||
|
@ -263,7 +264,7 @@ bool DIALOG_SPICE_MODEL::TransferDataToWindow()
|
||||||
{
|
{
|
||||||
const wxString& libFile = m_semiLib->GetValue();
|
const wxString& libFile = m_semiLib->GetValue();
|
||||||
m_fieldsTmp[SF_LIB_FILE] = libFile;
|
m_fieldsTmp[SF_LIB_FILE] = libFile;
|
||||||
updateFromFile( m_semiModel, libFile, "model" );
|
updateFromFile( m_semiModel, libFile, ".model" );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -276,7 +277,7 @@ bool DIALOG_SPICE_MODEL::TransferDataToWindow()
|
||||||
{
|
{
|
||||||
const wxString& libFile = m_icLib->GetValue();
|
const wxString& libFile = m_icLib->GetValue();
|
||||||
m_fieldsTmp[SF_LIB_FILE] = libFile;
|
m_fieldsTmp[SF_LIB_FILE] = libFile;
|
||||||
updateFromFile( m_icModel, libFile, "subckt" );
|
updateFromFile( m_icModel, libFile, ".subckt" );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -577,24 +578,25 @@ void DIALOG_SPICE_MODEL::updateFromFile( wxComboBox* aComboBox,
|
||||||
aComboBox->Clear();
|
aComboBox->Clear();
|
||||||
|
|
||||||
// Process the file, looking for components
|
// Process the file, looking for components
|
||||||
for( wxString line = file.GetFirstLine().Lower(); !file.Eof(); line = file.GetNextLine().Lower() )
|
for( wxString line = file.GetFirstLine().Lower(); !file.Eof(); line = file.GetNextLine() )
|
||||||
{
|
{
|
||||||
int idx = line.Find( keyword );
|
wxStringTokenizer tokenizer( line, " " );
|
||||||
|
|
||||||
if( idx != wxNOT_FOUND )
|
while( tokenizer.HasMoreTokens() )
|
||||||
{
|
{
|
||||||
wxString data = line.Mid( idx );
|
wxString token = tokenizer.GetNextToken().Lower();
|
||||||
data = data.AfterFirst( ' ' );
|
|
||||||
data.Trim( false );
|
|
||||||
data = data.BeforeFirst( ' ' );
|
|
||||||
data.Trim();
|
|
||||||
|
|
||||||
if( !data.IsEmpty() )
|
if( token == keyword )
|
||||||
aComboBox->Append( data );
|
{
|
||||||
|
token = tokenizer.GetNextToken();
|
||||||
|
|
||||||
|
if( !token.IsEmpty() )
|
||||||
|
aComboBox->Append( token );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore the previous value
|
// Restore the previous value or if there is none - pick the first one from the loaded library
|
||||||
if( !curValue.IsEmpty() )
|
if( !curValue.IsEmpty() )
|
||||||
aComboBox->SetValue( curValue );
|
aComboBox->SetValue( curValue );
|
||||||
else if( aComboBox->GetCount() > 0 )
|
else if( aComboBox->GetCount() > 0 )
|
||||||
|
@ -655,8 +657,15 @@ void DIALOG_SPICE_MODEL::onSemiSelectLib( wxCommandEvent& event )
|
||||||
if( openDlg.ShowModal() == wxID_CANCEL )
|
if( openDlg.ShowModal() == wxID_CANCEL )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
wxFileName libPath( openDlg.GetPath() );
|
||||||
|
|
||||||
|
// Try to convert the path to relative to project
|
||||||
|
if( libPath.MakeRelativeTo( Prj().GetProjectPath() ) && !libPath.GetFullPath().StartsWith( ".." ) )
|
||||||
|
m_semiLib->SetValue( libPath.GetFullPath() );
|
||||||
|
else
|
||||||
m_semiLib->SetValue( openDlg.GetPath() );
|
m_semiLib->SetValue( openDlg.GetPath() );
|
||||||
updateFromFile( m_semiModel, openDlg.GetPath(), "model" );
|
|
||||||
|
updateFromFile( m_semiModel, openDlg.GetPath(), ".model" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -670,8 +679,15 @@ void DIALOG_SPICE_MODEL::onSelectIcLib( wxCommandEvent& event )
|
||||||
if( openDlg.ShowModal() == wxID_CANCEL )
|
if( openDlg.ShowModal() == wxID_CANCEL )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
wxFileName libPath( openDlg.GetPath() );
|
||||||
|
|
||||||
|
// Try to convert the path to relative to project
|
||||||
|
if( libPath.MakeRelativeTo( Prj().GetProjectPath() ) && !libPath.GetFullPath().StartsWith( ".." ) )
|
||||||
|
m_icLib->SetValue( libPath.GetFullPath() );
|
||||||
|
else
|
||||||
m_icLib->SetValue( openDlg.GetPath() );
|
m_icLib->SetValue( openDlg.GetPath() );
|
||||||
updateFromFile( m_icModel, openDlg.GetPath(), "subckt" );
|
|
||||||
|
updateFromFile( m_icModel, openDlg.GetPath(), ".subckt" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DIALOG_SPICE_MODEL_BASE::DIALOG_SPICE_MODEL_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
|
DIALOG_SPICE_MODEL_BASE::DIALOG_SPICE_MODEL_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
|
||||||
{
|
{
|
||||||
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
<property name="pos"></property>
|
<property name="pos"></property>
|
||||||
<property name="size">425,630</property>
|
<property name="size">425,630</property>
|
||||||
<property name="style">wxDEFAULT_DIALOG_STYLE</property>
|
<property name="style">wxDEFAULT_DIALOG_STYLE</property>
|
||||||
<property name="subclass"></property>
|
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
|
||||||
<property name="title"></property>
|
<property name="title"></property>
|
||||||
<property name="tooltip"></property>
|
<property name="tooltip"></property>
|
||||||
<property name="window_extra_style"></property>
|
<property name="window_extra_style"></property>
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
#include <wx/artprov.h>
|
#include <wx/artprov.h>
|
||||||
#include <wx/xrc/xmlres.h>
|
#include <wx/xrc/xmlres.h>
|
||||||
#include <wx/intl.h>
|
#include <wx/intl.h>
|
||||||
|
class DIALOG_SHIM;
|
||||||
|
|
||||||
|
#include "dialog_shim.h"
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
#include <wx/stattext.h>
|
#include <wx/stattext.h>
|
||||||
#include <wx/gdicmn.h>
|
#include <wx/gdicmn.h>
|
||||||
|
@ -37,7 +40,7 @@
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
/// Class DIALOG_SPICE_MODEL_BASE
|
/// Class DIALOG_SPICE_MODEL_BASE
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
class DIALOG_SPICE_MODEL_BASE : public wxDialog
|
class DIALOG_SPICE_MODEL_BASE : public DIALOG_SHIM
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue