2013-03-30 00:06:08 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-01-03 02:52:35 +00:00
|
|
|
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-03-30 00:06:08 +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
|
|
|
|
*/
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
#include <wx/tooltip.h>
|
2013-08-08 16:12:41 +00:00
|
|
|
#include <wx/hyperlink.h>
|
2017-05-31 21:34:31 +00:00
|
|
|
#include <wx/url.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#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>
|
2014-05-04 00:44:57 +00:00
|
|
|
#include <kiway.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2012-04-13 18:51:24 +00:00
|
|
|
#include <base_units.h>
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2018-01-06 12:36:08 +00:00
|
|
|
#include <sch_reference_list.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_library.h>
|
|
|
|
#include <sch_component.h>
|
|
|
|
#include <dialog_helpers.h>
|
2016-04-02 12:25:44 +00:00
|
|
|
#include <sch_validators.h>
|
2017-08-25 11:37:21 +00:00
|
|
|
#include <kicad_device_context.h>
|
2017-10-06 18:07:43 +00:00
|
|
|
#include <symbol_lib_table.h>
|
2016-04-02 12:25:44 +00:00
|
|
|
|
2017-09-12 07:43:51 +00:00
|
|
|
#include <bitmaps.h>
|
|
|
|
|
2018-03-18 21:37:27 +00:00
|
|
|
#include <dialog_edit_component_in_schematic_base.h>
|
2017-10-02 12:53:48 +00:00
|
|
|
#include <invoke_sch_dialog.h>
|
2017-10-06 18:07:43 +00:00
|
|
|
|
2016-08-11 12:42:13 +00:00
|
|
|
#ifdef KICAD_SPICE
|
2016-08-11 12:41:40 +00:00
|
|
|
#include <dialog_spice_model.h>
|
2016-08-11 12:41:10 +00:00
|
|
|
#include <netlist_exporter_pspice.h>
|
2016-08-11 12:42:13 +00:00
|
|
|
#endif /* KICAD_SPICE */
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2017-05-31 21:34:31 +00:00
|
|
|
#include "common.h"
|
2017-10-18 18:09:08 +00:00
|
|
|
#include "eda_doc.h"
|
2017-10-02 12:53:48 +00:00
|
|
|
#include <list>
|
2017-05-31 21:34:31 +00:00
|
|
|
|
2013-06-05 19:23:55 +00:00
|
|
|
|
|
|
|
/**
|
2017-10-06 18:07:43 +00:00
|
|
|
* Dialog used to edit #SCH_COMPONENT objects in a schematic.
|
|
|
|
*
|
2018-03-18 21:37:27 +00:00
|
|
|
* This is derived from DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE which is maintained by
|
2017-10-06 18:07:43 +00:00
|
|
|
* wxFormBuilder. Do not auto-generate this class or file, it is hand coded.
|
2013-06-05 19:23:55 +00:00
|
|
|
*/
|
2018-03-18 21:37:27 +00:00
|
|
|
class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC : public DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE
|
2013-06-05 19:23:55 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-01-01 12:17:06 +00:00
|
|
|
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT_FRAME* aParent );
|
2013-06-05 19:23:55 +00:00
|
|
|
|
|
|
|
/**
|
2017-10-06 18:07:43 +00:00
|
|
|
* Initialize controls with \a aComponent.
|
|
|
|
*.
|
2013-06-05 19:23:55 +00:00
|
|
|
* @param aComponent The component to edit.
|
|
|
|
*/
|
|
|
|
void InitBuffers( SCH_COMPONENT* aComponent );
|
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
SCH_EDIT_FRAME* GetParent() { return dynamic_cast< SCH_EDIT_FRAME* >( wxDialog::GetParent() ); }
|
|
|
|
|
2013-06-05 19:23:55 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
friend class SCH_EDIT_FRAME;
|
|
|
|
|
2015-02-17 18:47:21 +00:00
|
|
|
SCH_COMPONENT* m_cmp;
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
LIB_PART* m_part;
|
2013-06-05 19:23:55 +00:00
|
|
|
bool m_skipCopyFromPanel;
|
|
|
|
|
|
|
|
static int s_SelectedRow;
|
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
/// a copy of the edited symbol's SCH_FIELDs
|
2013-06-05 19:23:55 +00:00
|
|
|
SCH_FIELDS m_FieldsBuf;
|
|
|
|
|
|
|
|
void setSelectedFieldNdx( int aFieldNdx );
|
|
|
|
|
|
|
|
int getSelectedFieldNdx();
|
|
|
|
|
|
|
|
/**
|
2017-10-06 18:07:43 +00:00
|
|
|
* Sets the values displayed on the panel according to the currently selected field row.
|
2013-06-05 19:23:55 +00:00
|
|
|
*/
|
|
|
|
void copySelectedFieldToPanel();
|
|
|
|
|
|
|
|
/**
|
2017-10-06 18:07:43 +00:00
|
|
|
* Copy the values displayed on the panel fields to the currently selected field.
|
|
|
|
*
|
2013-06-05 19:23:55 +00:00
|
|
|
* @return bool - true if all fields are OK, else false if the user has put
|
|
|
|
* bad data into a field, and this value can be used to deny a row change.
|
|
|
|
*/
|
|
|
|
bool copyPanelToSelectedField();
|
|
|
|
|
|
|
|
void copyOptionsToPanel();
|
|
|
|
|
|
|
|
void copyPanelToOptions();
|
|
|
|
|
2016-05-17 18:02:49 +00:00
|
|
|
void setRowItem( int aFieldNdx, const wxString& aName, const wxString& aValue );
|
|
|
|
|
|
|
|
void setRowItem( int aFieldNdx, const SCH_FIELD& aField )
|
|
|
|
{
|
2018-01-26 17:21:29 +00:00
|
|
|
// Use default field name for mandatory fields, because they are transalted
|
|
|
|
// according to the current locale
|
|
|
|
wxString f_name;
|
|
|
|
|
|
|
|
if( aFieldNdx < MANDATORY_FIELDS )
|
|
|
|
f_name = TEMPLATE_FIELDNAME::GetDefaultFieldName( aFieldNdx );
|
|
|
|
else
|
|
|
|
f_name = aField.GetName( false );
|
|
|
|
|
|
|
|
setRowItem( aFieldNdx, f_name, aField.GetText() );
|
2016-05-17 18:02:49 +00:00
|
|
|
}
|
2013-06-05 19:23:55 +00:00
|
|
|
|
|
|
|
// event handlers
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnCloseDialog( wxCloseEvent& event ) override;
|
|
|
|
void OnListItemDeselected( wxListEvent& event ) override;
|
|
|
|
void OnListItemSelected( wxListEvent& event ) override;
|
|
|
|
void OnCancelButtonClick( wxCommandEvent& event ) override;
|
|
|
|
void OnOKButtonClick( wxCommandEvent& event ) override;
|
|
|
|
void SetInitCmp( wxCommandEvent& event ) override;
|
2017-08-25 11:37:21 +00:00
|
|
|
void UpdateFields( wxCommandEvent& event ) override;
|
2016-09-24 18:53:15 +00:00
|
|
|
void addFieldButtonHandler( wxCommandEvent& event ) override;
|
|
|
|
void deleteFieldButtonHandler( wxCommandEvent& event ) override;
|
|
|
|
void moveUpButtonHandler( wxCommandEvent& event ) override;
|
2017-09-12 07:43:51 +00:00
|
|
|
void moveDownButtonHandler( wxCommandEvent& event ) override;
|
2016-09-24 18:53:15 +00:00
|
|
|
void showButtonHandler( wxCommandEvent& event ) override;
|
|
|
|
void OnTestChipName( wxCommandEvent& event ) override;
|
|
|
|
void OnSelectChipName( wxCommandEvent& event ) override;
|
2018-03-05 00:06:12 +00:00
|
|
|
void OnSizeFieldsList( wxSizeEvent& event ) override;
|
2016-09-25 17:06:49 +00:00
|
|
|
void OnInitDlg( wxInitDialogEvent& event ) override
|
2016-07-16 11:25:07 +00:00
|
|
|
{
|
|
|
|
TransferDataToWindow();
|
|
|
|
|
|
|
|
// Now all widgets have the size fixed, call FinishDialogSettings
|
|
|
|
FinishDialogSettings();
|
|
|
|
}
|
2013-06-05 19:23:55 +00:00
|
|
|
|
2016-08-11 12:41:40 +00:00
|
|
|
void EditSpiceModel( wxCommandEvent& event ) override;
|
2016-08-11 12:41:10 +00:00
|
|
|
|
2013-06-05 19:23:55 +00:00
|
|
|
SCH_FIELD* findField( const wxString& aFieldName );
|
|
|
|
|
|
|
|
/**
|
2017-10-06 18:07:43 +00:00
|
|
|
* Update the listbox showing fields according to the field's text.
|
|
|
|
*
|
|
|
|
* This must be called after a text change in fields if this change is not an edition.
|
2013-06-05 19:23:55 +00:00
|
|
|
*/
|
2016-08-11 12:41:10 +00:00
|
|
|
void updateDisplay()
|
2013-06-05 19:23:55 +00:00
|
|
|
{
|
2017-10-02 12:53:48 +00:00
|
|
|
fieldListCtrl->DeleteAllItems();
|
|
|
|
|
2017-08-25 11:37:21 +00:00
|
|
|
for( unsigned ii = 0; ii < m_FieldsBuf.size(); ii++ )
|
2013-06-05 19:23:55 +00:00
|
|
|
setRowItem( ii, m_FieldsBuf[ii] );
|
|
|
|
}
|
|
|
|
};
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
int DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_SelectedRow;
|
2009-01-29 08:58:48 +00:00
|
|
|
|
|
|
|
|
2011-08-30 19:24:28 +00:00
|
|
|
void SCH_EDIT_FRAME::EditComponent( SCH_COMPONENT* aComponent )
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
2011-08-30 19:24:28 +00:00
|
|
|
wxCHECK_RET( aComponent != NULL && aComponent->Type() == SCH_COMPONENT_T,
|
2015-02-17 18:47:21 +00:00
|
|
|
wxT( "Invalid component object pointer. Bad Programmer!" ) );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( true );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2011-08-30 19:24:28 +00:00
|
|
|
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC* dlg = new DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( this );
|
2009-01-29 08:58:48 +00:00
|
|
|
|
2011-04-19 16:30:28 +00:00
|
|
|
dlg->InitBuffers( aComponent );
|
2009-01-29 17:30:38 +00:00
|
|
|
|
2011-08-30 19:24:28 +00:00
|
|
|
// make sure the chipnameTextCtrl is wide enough to hold any unusually long chip names:
|
2011-04-19 16:30:28 +00:00
|
|
|
EnsureTextCtrlWidth( dlg->chipnameTextCtrl );
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2014-08-17 23:00:49 +00:00
|
|
|
// This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
|
|
|
|
// frame. Therefore this dialog as a modal frame parent, MUST be run under
|
|
|
|
// quasimodal mode for the quasimodal frame support to work. So don't use
|
|
|
|
// the QUASIMODAL macros here.
|
2015-04-02 11:18:19 +00:00
|
|
|
int ret = dlg->ShowQuasiModal();
|
2009-01-29 08:58:48 +00:00
|
|
|
|
2015-12-13 16:56:47 +00:00
|
|
|
if( m_autoplaceFields )
|
|
|
|
aComponent->AutoAutoplaceFields( GetScreen() );
|
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( false );
|
2014-05-04 18:22:27 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2011-04-19 16:30:28 +00:00
|
|
|
dlg->Destroy();
|
2015-06-30 16:31:48 +00:00
|
|
|
|
|
|
|
if( ret == wxID_OK )
|
|
|
|
GetCanvas()->Refresh();
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2018-01-01 12:17:06 +00:00
|
|
|
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT_FRAME* aParent ) :
|
2018-03-18 21:37:27 +00:00
|
|
|
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE( aParent )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2016-08-11 12:42:13 +00:00
|
|
|
#ifndef KICAD_SPICE
|
|
|
|
spiceFieldsButton->Hide();
|
|
|
|
#endif /* not KICAD_SPICE */
|
|
|
|
|
2015-02-17 18:47:21 +00:00
|
|
|
m_cmp = NULL;
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
m_part = NULL;
|
2008-11-26 06:25:20 +00:00
|
|
|
m_skipCopyFromPanel = false;
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
wxListItem columnLabel;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
columnLabel.SetImage( -1 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
columnLabel.SetText( _( "Name" ) );
|
2008-11-24 21:06:50 +00:00
|
|
|
fieldListCtrl->InsertColumn( 0, columnLabel );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
columnLabel.SetText( _( "Value" ) );
|
2008-11-24 21:06:50 +00:00
|
|
|
fieldListCtrl->InsertColumn( 1, columnLabel );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2013-04-01 11:42:09 +00:00
|
|
|
m_staticTextUnitSize->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
|
|
|
|
m_staticTextUnitPosX->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
|
|
|
|
m_staticTextUnitPosY->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
wxToolTip::Enable( true );
|
2016-07-16 10:54:55 +00:00
|
|
|
stdDialogButtonSizerOK->SetDefault();
|
2009-07-26 17:16:42 +00:00
|
|
|
|
2017-09-12 07:43:51 +00:00
|
|
|
// Configure button logos
|
|
|
|
addFieldButton->SetBitmap( KiBitmap( plus_xpm ) );
|
|
|
|
deleteFieldButton->SetBitmap( KiBitmap( minus_xpm ) );
|
|
|
|
moveUpButton->SetBitmap( KiBitmap( go_up_xpm ) );
|
|
|
|
moveDownButton->SetBitmap( KiBitmap( go_down_xpm ) );
|
|
|
|
|
2016-07-18 07:04:13 +00:00
|
|
|
Fit();
|
2008-12-31 15:01:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-24 21:06:50 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemDeselected( wxListEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-11-26 06:25:20 +00:00
|
|
|
if( !m_skipCopyFromPanel )
|
|
|
|
{
|
|
|
|
if( !copyPanelToSelectedField() )
|
|
|
|
event.Skip(); // do not go to the next row
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2014-09-17 16:04:04 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnTestChipName( wxCommandEvent& event )
|
|
|
|
{
|
2017-10-06 18:07:43 +00:00
|
|
|
LIB_ID id;
|
2014-09-17 16:04:04 +00:00
|
|
|
wxString msg;
|
2017-10-06 18:07:43 +00:00
|
|
|
wxString partname = chipnameTextCtrl->GetValue();
|
2014-09-17 16:04:04 +00:00
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
if( id.Parse( partname ) != -1 || !id.IsValid() )
|
2014-09-17 16:04:04 +00:00
|
|
|
{
|
2018-03-08 03:48:38 +00:00
|
|
|
msg.Printf( _( "\"%s\" is not a valid library symbol identifier." ), partname );
|
2017-10-06 18:07:43 +00:00
|
|
|
DisplayError( this, msg );
|
2014-09-17 16:04:04 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
LIB_ALIAS* alias = NULL;
|
2014-09-17 16:04:04 +00:00
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
alias = Prj().SchSymbolLibTable()->LoadSymbol( id );
|
|
|
|
}
|
|
|
|
catch( ... )
|
2014-09-17 16:04:04 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
if( !alias )
|
2014-09-17 16:04:04 +00:00
|
|
|
{
|
2017-12-15 11:37:46 +00:00
|
|
|
msg.Printf( _( "Symbol \"%s\" not found in library \"%s\"" ),
|
2017-10-06 18:07:43 +00:00
|
|
|
id.GetLibItemName().wx_str(), id.GetLibNickname().wx_str() );
|
|
|
|
DisplayError( this, msg );
|
|
|
|
return;
|
2014-09-17 16:04:04 +00:00
|
|
|
}
|
2014-09-18 10:29:52 +00:00
|
|
|
|
2017-12-15 11:37:46 +00:00
|
|
|
msg.Printf( _( "Symbol \"%s\" found in library \"%s\"" ),
|
2017-10-06 18:07:43 +00:00
|
|
|
id.GetLibItemName().wx_str(), id.GetLibNickname().wx_str() );
|
|
|
|
|
|
|
|
DisplayInfoMessage( this, msg );
|
2014-09-17 16:04:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnSelectChipName( wxCommandEvent& event )
|
|
|
|
{
|
2017-03-23 00:59:25 +00:00
|
|
|
SCH_BASE_FRAME::HISTORY_LIST dummy;
|
|
|
|
|
2018-01-03 02:52:35 +00:00
|
|
|
auto sel = GetParent()->SelectComponentFromLibrary( NULL, dummy, true, 0, 0, false );
|
2017-03-23 00:59:25 +00:00
|
|
|
|
2017-11-06 01:59:51 +00:00
|
|
|
if( !sel.LibId.IsValid() )
|
2014-09-17 16:04:04 +00:00
|
|
|
return;
|
|
|
|
|
2017-11-06 01:59:51 +00:00
|
|
|
chipnameTextCtrl->SetValue( sel.LibId.Format() );
|
2018-04-24 23:35:37 +00:00
|
|
|
|
|
|
|
// Update the value field for Power symbols
|
|
|
|
LIB_PART* entry = GetParent()->GetLibPart( sel.LibId );
|
|
|
|
|
|
|
|
if( entry && entry->IsPower() )
|
|
|
|
{
|
|
|
|
m_FieldsBuf[VALUE].SetText( sel.LibId.GetLibItemName() );
|
|
|
|
setRowItem( VALUE, m_FieldsBuf[VALUE] );
|
|
|
|
|
|
|
|
if( s_SelectedRow == VALUE )
|
|
|
|
copySelectedFieldToPanel();
|
|
|
|
}
|
|
|
|
|
2014-09-17 16:04:04 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2016-08-11 12:41:40 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::EditSpiceModel( wxCommandEvent& event )
|
2016-08-11 12:41:10 +00:00
|
|
|
{
|
2016-08-11 12:42:13 +00:00
|
|
|
#ifdef KICAD_SPICE
|
2016-08-11 12:41:40 +00:00
|
|
|
setSelectedFieldNdx( 0 );
|
|
|
|
DIALOG_SPICE_MODEL dialog( this, *m_cmp, m_FieldsBuf );
|
2016-08-11 12:41:10 +00:00
|
|
|
|
2016-08-11 12:41:40 +00:00
|
|
|
if( dialog.ShowModal() == wxID_OK )
|
|
|
|
updateDisplay();
|
2016-08-11 12:42:13 +00:00
|
|
|
#endif /* KICAD_SPICE */
|
2016-08-11 12:41:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-24 21:06:50 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemSelected( wxListEvent& event )
|
|
|
|
{
|
2008-11-26 00:20:16 +00:00
|
|
|
// remember the selected row, statically
|
|
|
|
s_SelectedRow = event.GetIndex();
|
2008-11-24 21:06:50 +00:00
|
|
|
|
|
|
|
copySelectedFieldToPanel();
|
|
|
|
}
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2014-09-15 11:59:40 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCloseDialog( wxCloseEvent& event )
|
2014-09-15 12:06:00 +00:00
|
|
|
{
|
2014-09-15 11:59:40 +00:00
|
|
|
// On wxWidgets 2.8, and on Linux, calling EndQuasiModal here is mandatory
|
|
|
|
// Otherwise, the main event loop is never restored, and Eeschema does not
|
|
|
|
// respond to any event, because the DIALOG_SHIM destructor is never called.
|
2014-09-17 16:04:04 +00:00
|
|
|
// On wxWidgets 3.0, or on Windows, the DIALOG_SHIM destructor is called,
|
2014-09-15 11:59:40 +00:00
|
|
|
// and calls EndQuasiModal.
|
2014-09-17 16:04:04 +00:00
|
|
|
// therefore calling EndQuasiModal here is not always mandatory but it creates no issues
|
2014-09-15 11:59:40 +00:00
|
|
|
EndQuasiModal( wxID_CANCEL );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCancelButtonClick( wxCommandEvent& event )
|
2008-03-20 01:50:21 +00:00
|
|
|
{
|
2014-09-15 11:59:40 +00:00
|
|
|
EndQuasiModal( wxID_CANCEL );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2017-01-31 01:31:19 +00:00
|
|
|
LIB_ID id;
|
2017-10-06 18:07:43 +00:00
|
|
|
wxString msg;
|
2017-01-31 01:31:19 +00:00
|
|
|
wxString tmp = chipnameTextCtrl->GetValue();
|
|
|
|
|
|
|
|
tmp.Replace( wxT( " " ), wxT( "_" ) );
|
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
id.Parse( tmp );
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2014-12-16 18:58:26 +00:00
|
|
|
// Save current flags which could be modified by next change settings
|
2015-02-17 18:47:21 +00:00
|
|
|
STATUS_FLAGS flags = m_cmp->GetFlags();
|
2014-12-16 18:58:26 +00:00
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
if( !id.IsValid() )
|
2013-03-30 00:06:08 +00:00
|
|
|
{
|
2017-12-15 11:37:46 +00:00
|
|
|
msg.Printf( _( "Symbol library identifier \"%s\" is not valid!" ), tmp );
|
2017-10-06 18:07:43 +00:00
|
|
|
DisplayError( this, msg );
|
2013-03-30 00:06:08 +00:00
|
|
|
}
|
2017-01-31 01:31:19 +00:00
|
|
|
else if( id != m_cmp->GetLibId() )
|
2008-11-26 00:20:16 +00:00
|
|
|
{
|
2017-10-06 18:07:43 +00:00
|
|
|
LIB_ALIAS* alias = NULL;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
alias = Prj().SchSymbolLibTable()->LoadSymbol( id );
|
|
|
|
}
|
|
|
|
catch( ... )
|
|
|
|
{
|
|
|
|
}
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
if( !alias )
|
2008-11-26 00:20:16 +00:00
|
|
|
{
|
2017-12-15 11:37:46 +00:00
|
|
|
msg.Printf( _( "Symbol \"%s\" not found in library \"%s\"!" ),
|
2017-10-06 18:07:43 +00:00
|
|
|
id.GetLibItemName().wx_str(), id.GetLibNickname().wx_str() );
|
2014-09-17 16:04:04 +00:00
|
|
|
DisplayError( this, msg );
|
2008-11-26 00:20:16 +00:00
|
|
|
}
|
2017-10-06 18:07:43 +00:00
|
|
|
else // Change symbol from lib!
|
2008-11-26 00:20:16 +00:00
|
|
|
{
|
2017-10-06 18:07:43 +00:00
|
|
|
m_cmp->SetLibId( id, Prj().SchSymbolLibTable(), Prj().SchLibs()->GetCacheLibrary() );
|
2008-11-26 00:20:16 +00:00
|
|
|
}
|
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
// For symbols with multiple shapes (De Morgan representation) Set the selected shape:
|
2008-11-26 00:20:16 +00:00
|
|
|
if( convertCheckBox->IsEnabled() )
|
|
|
|
{
|
2015-02-17 18:47:21 +00:00
|
|
|
m_cmp->SetConvert( convertCheckBox->GetValue() ? 2 : 1 );
|
2008-11-26 00:20:16 +00:00
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2011-08-30 19:24:28 +00:00
|
|
|
//Set the part selection in multiple part per package
|
2018-04-13 10:56:01 +00:00
|
|
|
if( m_cmp->GetUnitCount() > 1 )
|
2008-11-26 00:20:16 +00:00
|
|
|
{
|
|
|
|
int unit_selection = unitChoice->GetCurrentSelection() + 1;
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
m_cmp->SetUnitSelection( &GetParent()->GetCurrentSheet(), unit_selection );
|
2015-02-17 18:47:21 +00:00
|
|
|
m_cmp->SetUnit( unit_selection );
|
2008-11-26 00:20:16 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
switch( orientationRadioBox->GetSelection() )
|
|
|
|
{
|
|
|
|
case 0:
|
2015-02-17 18:47:21 +00:00
|
|
|
m_cmp->SetOrientation( CMP_ORIENT_0 );
|
2008-11-26 00:20:16 +00:00
|
|
|
break;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
case 1:
|
2015-02-17 18:47:21 +00:00
|
|
|
m_cmp->SetOrientation( CMP_ORIENT_90 );
|
2008-11-26 00:20:16 +00:00
|
|
|
break;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
case 2:
|
2015-02-17 18:47:21 +00:00
|
|
|
m_cmp->SetOrientation( CMP_ORIENT_180 );
|
2008-11-26 00:20:16 +00:00
|
|
|
break;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
case 3:
|
2015-02-17 18:47:21 +00:00
|
|
|
m_cmp->SetOrientation( CMP_ORIENT_270 );
|
2008-11-26 00:20:16 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
int mirror = mirrorRadioBox->GetSelection();
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
switch( mirror )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
break;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
case 1:
|
2015-02-17 18:47:21 +00:00
|
|
|
m_cmp->SetOrientation( CMP_MIRROR_X );
|
2008-11-26 00:20:16 +00:00
|
|
|
break;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
case 2:
|
2015-02-17 18:47:21 +00:00
|
|
|
m_cmp->SetOrientation( CMP_MIRROR_Y );
|
2008-11-26 00:20:16 +00:00
|
|
|
break;
|
|
|
|
}
|
2014-12-16 18:58:26 +00:00
|
|
|
|
|
|
|
// Restore m_Flag modified by SetUnit() and other change settings
|
2015-02-17 18:47:21 +00:00
|
|
|
m_cmp->ClearFlags();
|
|
|
|
m_cmp->SetFlags( flags );
|
2008-11-26 00:20:16 +00:00
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event )
|
|
|
|
{
|
2011-08-30 19:24:28 +00:00
|
|
|
bool removeRemainingFields = false;
|
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
if( !copyPanelToSelectedField() )
|
|
|
|
return;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( ! SCH_COMPONENT::IsReferenceStringValid( m_FieldsBuf[REFERENCE].GetText() ) )
|
2011-05-31 16:29:14 +00:00
|
|
|
{
|
2018-03-08 05:39:08 +00:00
|
|
|
DisplayError( NULL, _( "Illegal reference. References must start with a letter" ) );
|
2011-05-31 16:29:14 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-08-30 19:24:28 +00:00
|
|
|
// save old cmp in undo list if not already in edit, or moving ...
|
2013-01-21 20:16:04 +00:00
|
|
|
// or the component to be edited is part of a block
|
2017-01-31 01:31:19 +00:00
|
|
|
if( m_cmp->GetFlags() == 0
|
2017-10-06 18:07:43 +00:00
|
|
|
|| GetParent()->GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK )
|
|
|
|
GetParent()->SaveCopyInUndoList( m_cmp, UR_CHANGED );
|
2008-11-26 00:20:16 +00:00
|
|
|
|
2011-01-18 10:42:49 +00:00
|
|
|
copyPanelToOptions();
|
|
|
|
|
2011-08-30 19:24:28 +00:00
|
|
|
// Delete any fields with no name before we copy all of m_FieldsBuf back into the component.
|
2010-06-17 16:30:10 +00:00
|
|
|
for( unsigned i = MANDATORY_FIELDS; i<m_FieldsBuf.size(); )
|
2008-11-26 00:20:16 +00:00
|
|
|
{
|
2011-12-07 18:47:59 +00:00
|
|
|
if( m_FieldsBuf[i].GetName( false ).IsEmpty() || m_FieldsBuf[i].GetText().IsEmpty() )
|
2008-11-26 00:20:16 +00:00
|
|
|
{
|
2011-08-30 19:24:28 +00:00
|
|
|
// If a field has no value and is not it the field template list, warn the user
|
|
|
|
// that it will be remove from the component. This gives the user a chance to
|
|
|
|
// correct the problem before removing the undefined fields. It should also
|
|
|
|
// resolve most of the bug reports and questions regarding missing fields.
|
2011-12-07 18:47:59 +00:00
|
|
|
if( !m_FieldsBuf[i].GetName( false ).IsEmpty() && m_FieldsBuf[i].GetText().IsEmpty()
|
2017-10-06 18:07:43 +00:00
|
|
|
&& !GetParent()->GetTemplates().HasFieldName( m_FieldsBuf[i].GetName( false ) )
|
|
|
|
&& !removeRemainingFields )
|
2011-08-30 19:24:28 +00:00
|
|
|
{
|
2013-08-08 16:12:41 +00:00
|
|
|
wxString msg = wxString::Format(
|
2017-12-15 11:37:46 +00:00
|
|
|
_( "The field name \"%s\" does not have a value and is not defined in "
|
2013-08-08 16:12:41 +00:00
|
|
|
"the field template list. Empty field values are invalid an will "
|
|
|
|
"be removed from the component. Do you wish to remove this and "
|
|
|
|
"all remaining undefined fields?" ),
|
|
|
|
GetChars( m_FieldsBuf[i].GetName( false ) )
|
|
|
|
);
|
2011-08-30 19:24:28 +00:00
|
|
|
|
|
|
|
wxMessageDialog dlg( this, msg, _( "Remove Fields" ), wxYES_NO | wxNO_DEFAULT );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_NO )
|
|
|
|
return;
|
|
|
|
|
|
|
|
removeRemainingFields = true;
|
|
|
|
}
|
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
m_FieldsBuf.erase( m_FieldsBuf.begin() + i );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
2013-03-30 00:06:08 +00:00
|
|
|
// change all field positions from relative to absolute
|
|
|
|
for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
|
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
m_FieldsBuf[i].Offset( m_cmp->m_Pos );
|
2013-03-30 00:06:08 +00:00
|
|
|
}
|
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
LIB_PART* entry = GetParent()->GetLibPart( m_cmp->GetLibId() );
|
2008-11-26 00:20:16 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
if( entry && entry->IsPower() )
|
2017-01-31 01:31:19 +00:00
|
|
|
m_FieldsBuf[VALUE].SetText( m_cmp->GetLibId().GetLibItemName() );
|
2008-11-26 00:20:16 +00:00
|
|
|
|
|
|
|
// copy all the fields back, and change the length of m_Fields.
|
2015-02-17 18:47:21 +00:00
|
|
|
m_cmp->SetFields( m_FieldsBuf );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2011-08-30 19:24:28 +00:00
|
|
|
// Reference has a specific initialization, depending on the current active sheet
|
|
|
|
// because for a given component, in a complex hierarchy, there are more than one
|
2010-01-13 13:43:36 +00:00
|
|
|
// reference.
|
2017-10-06 18:07:43 +00:00
|
|
|
m_cmp->SetRef( &GetParent()->GetCurrentSheet(), m_FieldsBuf[REFERENCE].GetText() );
|
2010-01-13 13:43:36 +00:00
|
|
|
|
2018-01-06 12:36:08 +00:00
|
|
|
// The value, footprint and datasheet fields should be kept in sync in multi-unit
|
|
|
|
// parts.
|
|
|
|
if( m_cmp->GetUnitCount() > 1 )
|
|
|
|
{
|
|
|
|
const LIB_ID thisLibId = m_cmp->GetLibId();
|
|
|
|
const wxString thisRef = m_cmp->GetRef( &( GetParent()->GetCurrentSheet() ) );
|
|
|
|
int thisUnit = m_cmp->GetUnit();
|
|
|
|
|
|
|
|
SCH_REFERENCE_LIST components;
|
|
|
|
GetParent()->GetCurrentSheet().GetComponents( components );
|
2018-01-24 13:22:43 +00:00
|
|
|
for( unsigned i = 0; i < components.GetCount(); i++ )
|
2018-01-06 12:36:08 +00:00
|
|
|
{
|
|
|
|
SCH_REFERENCE component = components[i];
|
|
|
|
if( component.GetLibPart()->GetLibId() == thisLibId
|
|
|
|
&& component.GetRef() == thisRef
|
|
|
|
&& component.GetUnit() != thisUnit )
|
|
|
|
{
|
|
|
|
SCH_COMPONENT* otherUnit = component.GetComp();
|
|
|
|
GetParent()->SaveCopyInUndoList( otherUnit, UR_CHANGED, true /* append */);
|
|
|
|
otherUnit->GetField( VALUE )->SetText( m_FieldsBuf[VALUE].GetText() );
|
|
|
|
otherUnit->GetField( FOOTPRINT )->SetText( m_FieldsBuf[FOOTPRINT].GetText() );
|
|
|
|
otherUnit->GetField( DATASHEET )->SetText( m_FieldsBuf[DATASHEET].GetText() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
GetParent()->OnModify();
|
|
|
|
GetParent()->GetScreen()->TestDanglingEnds();
|
2008-11-26 00:20:16 +00:00
|
|
|
|
2014-09-15 11:59:40 +00:00
|
|
|
EndQuasiModal( wxID_OK );
|
2008-11-26 00:20:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-26 06:25:20 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::addFieldButtonHandler( wxCommandEvent& event )
|
|
|
|
{
|
2008-12-31 09:27:19 +00:00
|
|
|
// in case m_FieldsBuf[REFERENCE].m_Orient has changed on screen only, grab
|
|
|
|
// screen contents.
|
2008-11-26 06:25:20 +00:00
|
|
|
if( !copyPanelToSelectedField() )
|
|
|
|
return;
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
unsigned fieldNdx = m_FieldsBuf.size();
|
2008-11-26 06:25:20 +00:00
|
|
|
|
2015-02-17 18:47:21 +00:00
|
|
|
SCH_FIELD blank( wxPoint(), fieldNdx, m_cmp );
|
2008-11-26 06:25:20 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
blank.SetTextAngle( m_FieldsBuf[REFERENCE].GetTextAngle() );
|
2008-11-26 06:25:20 +00:00
|
|
|
|
|
|
|
m_FieldsBuf.push_back( blank );
|
2011-12-07 18:47:59 +00:00
|
|
|
m_FieldsBuf[fieldNdx].SetName( TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldNdx ) );
|
2008-11-26 06:25:20 +00:00
|
|
|
|
2008-12-31 15:01:29 +00:00
|
|
|
m_skipCopyFromPanel = true;
|
2008-11-26 06:25:20 +00:00
|
|
|
setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] );
|
|
|
|
|
|
|
|
setSelectedFieldNdx( fieldNdx );
|
|
|
|
m_skipCopyFromPanel = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::deleteFieldButtonHandler( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
unsigned fieldNdx = getSelectedFieldNdx();
|
|
|
|
|
|
|
|
if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
|
|
|
|
return;
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
if( fieldNdx < MANDATORY_FIELDS )
|
2008-11-26 06:25:20 +00:00
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-12-31 15:01:29 +00:00
|
|
|
m_skipCopyFromPanel = true;
|
2008-11-26 06:25:20 +00:00
|
|
|
m_FieldsBuf.erase( m_FieldsBuf.begin() + fieldNdx );
|
|
|
|
fieldListCtrl->DeleteItem( fieldNdx );
|
|
|
|
|
|
|
|
if( fieldNdx >= m_FieldsBuf.size() )
|
|
|
|
--fieldNdx;
|
|
|
|
|
2011-08-30 19:24:28 +00:00
|
|
|
updateDisplay();
|
2008-12-31 15:01:29 +00:00
|
|
|
|
2008-11-26 06:25:20 +00:00
|
|
|
setSelectedFieldNdx( fieldNdx );
|
|
|
|
m_skipCopyFromPanel = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-08 16:12:41 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::showButtonHandler( wxCommandEvent& event )
|
|
|
|
{
|
2014-05-04 18:22:27 +00:00
|
|
|
unsigned fieldNdx = getSelectedFieldNdx();
|
2014-05-05 17:28:40 +00:00
|
|
|
|
2014-05-04 00:44:57 +00:00
|
|
|
if( fieldNdx == DATASHEET )
|
|
|
|
{
|
|
|
|
wxString datasheet_uri = fieldValueTextCtrl->GetValue();
|
2018-03-08 22:57:31 +00:00
|
|
|
datasheet_uri = ResolveUriByEnvVars( datasheet_uri );
|
2017-10-18 18:09:08 +00:00
|
|
|
GetAssociatedDocument( this, datasheet_uri );
|
2014-05-04 00:44:57 +00:00
|
|
|
}
|
|
|
|
else if( fieldNdx == FOOTPRINT )
|
|
|
|
{
|
2014-05-04 18:22:27 +00:00
|
|
|
// pick a footprint using the footprint picker.
|
2018-03-21 21:13:10 +00:00
|
|
|
wxString fpid = fieldValueTextCtrl->GetValue();
|
2014-05-04 00:44:57 +00:00
|
|
|
|
2018-01-01 16:18:28 +00:00
|
|
|
KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_MODULE_VIEWER_MODAL, true, this );
|
2014-05-04 00:44:57 +00:00
|
|
|
|
2018-03-22 11:25:04 +00:00
|
|
|
if( frame->ShowModal( &fpid, this ) )
|
2014-05-04 00:44:57 +00:00
|
|
|
{
|
2018-03-22 11:25:04 +00:00
|
|
|
// DBG( printf( "%s: %s\n", __func__, TO_UTF8( fpid ) ); )
|
|
|
|
fieldValueTextCtrl->SetValue( fpid );
|
2016-05-17 18:02:49 +00:00
|
|
|
|
2018-03-22 11:25:04 +00:00
|
|
|
setRowItem( fieldNdx, m_FieldsBuf[fieldNdx].GetName( false ), fpid );
|
2014-05-04 18:22:27 +00:00
|
|
|
}
|
2014-05-04 00:44:57 +00:00
|
|
|
|
2014-05-04 18:22:27 +00:00
|
|
|
frame->Destroy();
|
2014-05-04 00:44:57 +00:00
|
|
|
}
|
2013-08-08 16:12:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::moveUpButtonHandler( wxCommandEvent& event )
|
2008-11-26 06:25:20 +00:00
|
|
|
{
|
|
|
|
unsigned fieldNdx = getSelectedFieldNdx();
|
|
|
|
|
|
|
|
if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
|
|
|
|
return;
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
if( fieldNdx <= MANDATORY_FIELDS )
|
2008-11-26 06:25:20 +00:00
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !copyPanelToSelectedField() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// swap the fieldNdx field with the one before it, in both the vector
|
|
|
|
// and in the fieldListCtrl
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_FIELD tmp = m_FieldsBuf[fieldNdx - 1];
|
2008-11-26 06:25:20 +00:00
|
|
|
|
2013-09-10 15:07:46 +00:00
|
|
|
DBG( printf( "tmp.m_Text=\"%s\" tmp.m_Name=\"%s\"\n",
|
2015-02-17 18:47:21 +00:00
|
|
|
TO_UTF8( tmp.GetText() ), TO_UTF8( tmp.GetName( false ) ) ); )
|
2008-11-26 06:25:20 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
m_FieldsBuf[fieldNdx - 1] = m_FieldsBuf[fieldNdx];
|
|
|
|
setRowItem( fieldNdx - 1, m_FieldsBuf[fieldNdx] );
|
2008-11-26 06:25:20 +00:00
|
|
|
|
|
|
|
m_FieldsBuf[fieldNdx] = tmp;
|
|
|
|
setRowItem( fieldNdx, tmp );
|
|
|
|
|
2011-08-30 19:24:28 +00:00
|
|
|
updateDisplay();
|
2008-12-31 15:01:29 +00:00
|
|
|
|
2008-11-26 06:25:20 +00:00
|
|
|
m_skipCopyFromPanel = true;
|
|
|
|
setSelectedFieldNdx( fieldNdx - 1 );
|
|
|
|
m_skipCopyFromPanel = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-12 07:43:51 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::moveDownButtonHandler( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
unsigned fieldNdx = getSelectedFieldNdx();
|
|
|
|
|
|
|
|
// Ensure there is at least one field after this one
|
|
|
|
if( fieldNdx >= ( m_FieldsBuf.size() - 1 ) )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The first field which can be moved up is the second user field
|
|
|
|
// so any field which id < MANDATORY_FIELDS cannot be moved down
|
|
|
|
if( fieldNdx < MANDATORY_FIELDS )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( !copyPanelToSelectedField() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// swap the fieldNdx field with the one before it, in both the vector
|
|
|
|
// and in the fieldListCtrl
|
|
|
|
SCH_FIELD tmp = m_FieldsBuf[fieldNdx + 1];
|
|
|
|
|
|
|
|
m_FieldsBuf[fieldNdx + 1] = m_FieldsBuf[fieldNdx];
|
|
|
|
setRowItem( fieldNdx + 1, m_FieldsBuf[fieldNdx] );
|
|
|
|
m_FieldsBuf[fieldNdx + 1].SetId( fieldNdx + 1 );
|
|
|
|
|
|
|
|
m_FieldsBuf[fieldNdx] = tmp;
|
|
|
|
setRowItem( fieldNdx, tmp );
|
|
|
|
m_FieldsBuf[fieldNdx].SetId( fieldNdx );
|
|
|
|
|
|
|
|
updateDisplay( );
|
|
|
|
|
|
|
|
m_skipCopyFromPanel = true;
|
|
|
|
setSelectedFieldNdx( fieldNdx + 1 );
|
|
|
|
m_skipCopyFromPanel = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setSelectedFieldNdx( int aFieldNdx )
|
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
/* deselect old selection, but I think this is done by single selection
|
|
|
|
* flag within fieldListCtrl.
|
|
|
|
* fieldListCtrl->SetItemState( s_SelectedRow, 0,
|
|
|
|
* wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED);
|
2008-12-31 09:27:19 +00:00
|
|
|
*/
|
2008-11-26 00:20:16 +00:00
|
|
|
|
|
|
|
if( aFieldNdx >= (int) m_FieldsBuf.size() )
|
|
|
|
aFieldNdx = m_FieldsBuf.size() - 1;
|
|
|
|
|
|
|
|
if( aFieldNdx < 0 )
|
|
|
|
aFieldNdx = 0;
|
|
|
|
|
|
|
|
fieldListCtrl->SetItemState( aFieldNdx, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
|
|
|
|
fieldListCtrl->EnsureVisible( aFieldNdx );
|
|
|
|
|
|
|
|
s_SelectedRow = aFieldNdx;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::getSelectedFieldNdx()
|
|
|
|
{
|
|
|
|
return s_SelectedRow;
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
SCH_FIELD* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::findField( const wxString& aFieldName )
|
2008-12-31 16:49:45 +00:00
|
|
|
{
|
2010-06-17 16:30:10 +00:00
|
|
|
for( unsigned i=0; i<m_FieldsBuf.size(); ++i )
|
|
|
|
{
|
2011-12-07 18:47:59 +00:00
|
|
|
if( aFieldName == m_FieldsBuf[i].GetName( false ) )
|
2010-06-17 16:30:10 +00:00
|
|
|
return &m_FieldsBuf[i];
|
|
|
|
}
|
2011-08-30 19:24:28 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
return NULL;
|
2008-12-31 16:49:45 +00:00
|
|
|
}
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2015-02-17 18:47:21 +00:00
|
|
|
m_cmp = aComponent;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
/* We have 3 component related field lists to be aware of: 1) UI
|
|
|
|
presentation, 2) fields in component ram copy, and 3) fields recorded
|
|
|
|
with component on disk. m_FieldsBuf is the list of UI fields, and this
|
|
|
|
list is not the same as the list which is in the component, which is
|
|
|
|
also not the same as the list on disk. All 3 lists are potentially
|
|
|
|
different. In the UI we choose to preserve the order of the first
|
|
|
|
MANDATORY_FIELDS which are sometimes called fixed fields. Then we append
|
|
|
|
the template fieldnames in the exact same order as the template
|
|
|
|
fieldname editor shows them. Then we append any user defined fieldnames
|
|
|
|
which came from the component.
|
|
|
|
*/
|
|
|
|
|
2017-12-07 23:01:03 +00:00
|
|
|
m_part = GetParent()->GetLibPart( m_cmp->GetLibId(), true );
|
2008-11-26 00:20:16 +00:00
|
|
|
|
|
|
|
#if 0 && defined(DEBUG)
|
2008-12-31 09:27:19 +00:00
|
|
|
for( int i = 0; i<aComponent->GetFieldCount(); ++i )
|
2008-11-26 00:20:16 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
printf( "Orig[%d] (x=%d, y=%d)\n", i,
|
|
|
|
aComponent->m_Fields[i].GetTextPos().x,
|
|
|
|
aComponent->m_Fields[i].GetTextPos().y );
|
2008-11-26 00:20:16 +00:00
|
|
|
}
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
#endif
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// When this code was written, all field constructors ensure that the fixed fields
|
|
|
|
// are all present within a component. So we can knowingly copy them over
|
|
|
|
// in the normal order. Copy only the fixed fields at first.
|
|
|
|
// Please do not break the field constructors.
|
|
|
|
|
|
|
|
m_FieldsBuf.clear();
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
for( int i=0; i<MANDATORY_FIELDS; ++i )
|
|
|
|
{
|
|
|
|
m_FieldsBuf.push_back( aComponent->m_Fields[i] );
|
|
|
|
|
|
|
|
// make the editable field position relative to the component
|
2017-01-23 20:30:11 +00:00
|
|
|
m_FieldsBuf[i].Offset( -m_cmp->m_Pos );
|
2018-01-26 17:21:29 +00:00
|
|
|
|
|
|
|
// Ensure the Field name reflects the default name, even if the
|
|
|
|
// local has changed since schematic was read
|
|
|
|
m_FieldsBuf[i].SetName( TEMPLATE_FIELDNAME::GetDefaultFieldName( i ) );
|
2010-06-17 16:30:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add template fieldnames:
|
|
|
|
// Now copy in the template fields, in the order that they are present in the
|
|
|
|
// template field editor UI.
|
2017-10-06 18:07:43 +00:00
|
|
|
const TEMPLATE_FIELDNAMES& tfnames = GetParent()->GetTemplateFieldNames();
|
2011-08-30 19:24:28 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
for( TEMPLATE_FIELDNAMES::const_iterator it = tfnames.begin(); it!=tfnames.end(); ++it )
|
|
|
|
{
|
|
|
|
// add a new field unconditionally to the UI only
|
2015-02-17 18:47:21 +00:00
|
|
|
SCH_FIELD fld( wxPoint(0,0), -1 /* id is a relic */, m_cmp, it->m_Name );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
// See if field by same name already exists in component.
|
|
|
|
SCH_FIELD* schField = aComponent->FindField( it->m_Name );
|
|
|
|
|
|
|
|
// If the field does not already exist in the component, then we
|
|
|
|
// use defaults from the template fieldname, otherwise the original
|
|
|
|
// values from the component will be set.
|
|
|
|
if( !schField )
|
|
|
|
{
|
|
|
|
if( !it->m_Visible )
|
2013-03-18 19:36:07 +00:00
|
|
|
fld.SetVisible( false );
|
2010-06-17 16:30:10 +00:00
|
|
|
else
|
2013-03-18 19:36:07 +00:00
|
|
|
fld.SetVisible( true );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
fld.SetText( it->m_Value ); // empty? ok too.
|
2010-06-17 16:30:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fld = *schField;
|
|
|
|
|
|
|
|
// make the editable field position relative to the component
|
2017-01-23 20:30:11 +00:00
|
|
|
fld.Offset( -m_cmp->m_Pos );
|
2010-06-17 16:30:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_FieldsBuf.push_back( fld );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Lastly, append any original fields from the component which were not added
|
|
|
|
// from the set of fixed fields nor from the set of template fields.
|
|
|
|
for( unsigned i=MANDATORY_FIELDS; i<aComponent->m_Fields.size(); ++i )
|
|
|
|
{
|
|
|
|
SCH_FIELD* cmp = &aComponent->m_Fields[i];
|
2011-12-07 18:47:59 +00:00
|
|
|
SCH_FIELD* buf = findField( cmp->GetName( false ) );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
if( !buf )
|
|
|
|
{
|
|
|
|
int newNdx = m_FieldsBuf.size();
|
|
|
|
m_FieldsBuf.push_back( *cmp );
|
|
|
|
|
|
|
|
// make the editable field position relative to the component
|
2017-01-23 20:30:11 +00:00
|
|
|
m_FieldsBuf[newNdx].Offset( -m_cmp->m_Pos );
|
2010-06-17 16:30:10 +00:00
|
|
|
}
|
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-12-31 16:49:45 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
#if 0 && defined(DEBUG)
|
2008-12-31 09:27:19 +00:00
|
|
|
for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
|
2008-11-26 00:20:16 +00:00
|
|
|
{
|
2010-06-17 16:30:10 +00:00
|
|
|
printf( "m_FieldsBuf[%d] (x=%-3d, y=%-3d) name:%s\n", i, m_FieldsBuf[i].m_Pos.x,
|
2011-12-07 18:47:59 +00:00
|
|
|
m_FieldsBuf[i].m_Pos.y, TO_UTF8(m_FieldsBuf[i].GetName( false ) ) );
|
2008-11-26 00:20:16 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
m_FieldsBuf[REFERENCE].SetText( m_cmp->GetRef( &GetParent()->GetCurrentSheet() ) );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
2008-11-26 00:20:16 +00:00
|
|
|
setRowItem( i, m_FieldsBuf[i] );
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
#if 0 && defined(DEBUG)
|
2008-12-31 09:27:19 +00:00
|
|
|
for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
|
2008-11-26 00:20:16 +00:00
|
|
|
{
|
2008-12-31 09:27:19 +00:00
|
|
|
printf( "after[%d] (x=%d, y=%d)\n", i, m_FieldsBuf[i].m_Pos.x,
|
|
|
|
m_FieldsBuf[i].m_Pos.y );
|
2008-11-26 00:20:16 +00:00
|
|
|
}
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
copyOptionsToPanel();
|
|
|
|
|
2012-12-29 12:55:36 +00:00
|
|
|
// disable some options inside the edit dialog
|
|
|
|
// which can cause problems while dragging
|
2015-02-17 18:47:21 +00:00
|
|
|
if( m_cmp->IsDragging() )
|
2012-12-29 12:55:36 +00:00
|
|
|
{
|
|
|
|
orientationRadioBox->Disable();
|
|
|
|
mirrorRadioBox->Disable();
|
|
|
|
chipnameTextCtrl->Disable();
|
|
|
|
}
|
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
// put focus on the list ctrl
|
|
|
|
fieldListCtrl->SetFocus();
|
|
|
|
|
|
|
|
// resume editing at the last row edited, last time dialog was up.
|
|
|
|
setSelectedFieldNdx( s_SelectedRow );
|
2015-02-24 10:15:20 +00:00
|
|
|
|
|
|
|
copySelectedFieldToPanel();
|
2008-11-24 21:06:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-17 18:02:49 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setRowItem( int aFieldNdx, const wxString& aName, const wxString& aValue )
|
2008-11-24 21:06:50 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aFieldNdx >= 0 );
|
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
// insert blanks if aFieldNdx is referencing a "yet to be defined" row
|
2008-11-24 21:06:50 +00:00
|
|
|
while( aFieldNdx >= fieldListCtrl->GetItemCount() )
|
|
|
|
{
|
2008-12-31 09:27:19 +00:00
|
|
|
long ndx = fieldListCtrl->InsertItem( fieldListCtrl->GetItemCount(), wxEmptyString );
|
2008-11-24 21:06:50 +00:00
|
|
|
|
|
|
|
wxASSERT( ndx >= 0 );
|
|
|
|
|
|
|
|
fieldListCtrl->SetItem( ndx, 1, wxEmptyString );
|
|
|
|
}
|
|
|
|
|
2016-05-17 18:02:49 +00:00
|
|
|
fieldListCtrl->SetItem( aFieldNdx, 0, aName );
|
|
|
|
fieldListCtrl->SetItem( aFieldNdx, 1, aValue );
|
2008-11-24 21:06:50 +00:00
|
|
|
|
|
|
|
// recompute the column widths here, after setting texts
|
2018-03-05 00:06:12 +00:00
|
|
|
int totalWidth = fieldListCtrl->GetSize().GetWidth();
|
2008-11-24 21:06:50 +00:00
|
|
|
fieldListCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE );
|
2018-03-05 00:06:12 +00:00
|
|
|
fieldListCtrl->SetColumnWidth( 1, totalWidth - fieldListCtrl->GetColumnWidth( 0 ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-24 21:06:50 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2015-02-21 00:41:10 +00:00
|
|
|
wxCHECK_RET( m_cmp != NULL, wxT( "Component pointer not initialized." ) );
|
|
|
|
|
2008-11-24 21:06:50 +00:00
|
|
|
unsigned fieldNdx = getSelectedFieldNdx();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-24 21:06:50 +00:00
|
|
|
if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
|
2008-11-24 06:53:43 +00:00
|
|
|
return;
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_FIELD& field = m_FieldsBuf[fieldNdx];
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
showCheckBox->SetValue( field.IsVisible() );
|
2008-11-26 00:20:16 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
rotateCheckBox->SetValue( field.GetTextAngle() == TEXT_ANGLE_VERT );
|
2008-11-26 00:20:16 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
int style = 0;
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( field.IsItalic() )
|
2008-12-31 09:27:19 +00:00
|
|
|
style = 1;
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( field.IsBold() )
|
2008-12-31 09:27:19 +00:00
|
|
|
style |= 2;
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
m_StyleRadioBox->SetSelection( style );
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2010-12-21 12:41:17 +00:00
|
|
|
// Select the right text justification
|
2013-03-18 19:36:07 +00:00
|
|
|
if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
|
2013-03-30 00:06:08 +00:00
|
|
|
m_FieldHJustifyCtrl->SetSelection( 0 );
|
2013-03-18 19:36:07 +00:00
|
|
|
else if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
|
2013-03-30 00:06:08 +00:00
|
|
|
m_FieldHJustifyCtrl->SetSelection( 2 );
|
2010-12-21 12:41:17 +00:00
|
|
|
else
|
2013-03-30 00:06:08 +00:00
|
|
|
m_FieldHJustifyCtrl->SetSelection( 1 );
|
2010-12-21 12:41:17 +00:00
|
|
|
|
2017-11-10 16:26:48 +00:00
|
|
|
if( field.GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
|
2013-03-30 00:06:08 +00:00
|
|
|
m_FieldVJustifyCtrl->SetSelection( 0 );
|
2017-11-10 16:26:48 +00:00
|
|
|
else if( field.GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
|
2013-03-30 00:06:08 +00:00
|
|
|
m_FieldVJustifyCtrl->SetSelection( 2 );
|
2010-12-21 12:41:17 +00:00
|
|
|
else
|
2013-03-30 00:06:08 +00:00
|
|
|
m_FieldVJustifyCtrl->SetSelection( 1 );
|
2010-12-21 12:41:17 +00:00
|
|
|
|
|
|
|
|
2011-12-07 18:47:59 +00:00
|
|
|
fieldNameTextCtrl->SetValue( field.GetName( false ) );
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// the names of the fixed fields are not editable, others are.
|
|
|
|
fieldNameTextCtrl->Enable( fieldNdx >= MANDATORY_FIELDS );
|
|
|
|
fieldNameTextCtrl->SetEditable( fieldNdx >= MANDATORY_FIELDS );
|
|
|
|
|
|
|
|
// only user defined fields may be moved, and not the top most user defined
|
|
|
|
// field since it would be moving up into the fixed fields, > not >=
|
|
|
|
moveUpButton->Enable( fieldNdx > MANDATORY_FIELDS );
|
2018-01-30 08:56:43 +00:00
|
|
|
moveDownButton->Enable( ( fieldNdx >= MANDATORY_FIELDS ) && ( fieldNdx < ( m_FieldsBuf.size() - 1 ) ) );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
// may only delete user defined fields
|
|
|
|
deleteFieldButton->Enable( fieldNdx >= MANDATORY_FIELDS );
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2016-08-19 16:42:39 +00:00
|
|
|
fieldValueTextCtrl->SetValidator( SCH_FIELD_VALIDATOR( false, field.GetId() ) );
|
2013-03-18 19:36:07 +00:00
|
|
|
fieldValueTextCtrl->SetValue( field.GetText() );
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2014-05-04 18:22:27 +00:00
|
|
|
m_show_datasheet_button->Enable( fieldNdx == DATASHEET || fieldNdx == FOOTPRINT );
|
|
|
|
|
|
|
|
if( fieldNdx == DATASHEET )
|
2016-04-17 15:15:26 +00:00
|
|
|
{
|
|
|
|
m_show_datasheet_button->SetLabel( _( "Show Datasheet" ) );
|
|
|
|
m_show_datasheet_button->SetToolTip(
|
|
|
|
_("If your datasheet is given as an http:// link,"
|
|
|
|
" then pressing this button should bring it up in your webbrowser.") );
|
|
|
|
}
|
2014-05-04 18:22:27 +00:00
|
|
|
else if( fieldNdx == FOOTPRINT )
|
2016-04-17 15:15:26 +00:00
|
|
|
{
|
|
|
|
m_show_datasheet_button->SetLabel( _( "Browse Footprints" ) );
|
|
|
|
m_show_datasheet_button->SetToolTip(
|
|
|
|
_("Open the footprint browser to choose a footprint and assign it.") );
|
|
|
|
}
|
2014-05-04 18:22:27 +00:00
|
|
|
else
|
2016-04-17 15:15:26 +00:00
|
|
|
{
|
2014-05-04 18:22:27 +00:00
|
|
|
m_show_datasheet_button->SetLabel( wxEmptyString );
|
2016-04-17 15:15:26 +00:00
|
|
|
m_show_datasheet_button->SetToolTip(
|
|
|
|
_("Used only for fields Footprint and Datasheet.") );
|
|
|
|
}
|
2014-05-04 18:22:27 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
// For power symbols, the value is NOR editable, because value and pin
|
|
|
|
// name must be same and can be edited only in library editor
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
if( fieldNdx == VALUE && m_part && m_part->IsPower() )
|
2009-09-26 17:22:47 +00:00
|
|
|
fieldValueTextCtrl->Enable( false );
|
|
|
|
else
|
|
|
|
fieldValueTextCtrl->Enable( true );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetTextWidth() ) );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
wxPoint coord = field.GetTextPos();
|
2015-02-17 18:47:21 +00:00
|
|
|
wxPoint zero = -m_cmp->m_Pos; // relative zero
|
2008-11-26 00:20:16 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
// If the field value is empty and the position is at relative zero, we
|
|
|
|
// set the initial position as a small offset from the ref field, and
|
|
|
|
// orient it the same as the ref field. That is likely to put it at least
|
2008-11-24 06:53:43 +00:00
|
|
|
// close to the desired position.
|
2013-03-18 19:36:07 +00:00
|
|
|
if( coord == zero && field.GetText().IsEmpty() )
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetTextAngle() == TEXT_ANGLE_VERT );
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
coord.x = m_FieldsBuf[REFERENCE].GetTextPos().x
|
2010-06-17 16:30:10 +00:00
|
|
|
+ ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100;
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
coord.y = m_FieldsBuf[REFERENCE].GetTextPos().y
|
2010-06-17 16:30:10 +00:00
|
|
|
+ ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100;
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT.
|
2008-11-26 00:20:16 +00:00
|
|
|
// That is ok, we basically don't want all the new empty fields on
|
|
|
|
// top of each other.
|
2008-11-24 06:53:43 +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 coordText = StringFromValue( g_UserUnit, coord.x );
|
2008-11-26 00:20:16 +00:00
|
|
|
posXTextCtrl->SetValue( coordText );
|
2008-11-24 06:53:43 +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
|
|
|
coordText = StringFromValue( g_UserUnit, coord.y );
|
2008-11-26 00:20:16 +00:00
|
|
|
posYTextCtrl->SetValue( coordText );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
|
2008-11-24 21:06:50 +00:00
|
|
|
{
|
|
|
|
unsigned fieldNdx = getSelectedFieldNdx();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
|
|
|
|
return true;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2016-04-02 12:25:44 +00:00
|
|
|
// Check for illegal field text.
|
|
|
|
if( fieldValueTextCtrl->GetValidator()
|
|
|
|
&& !fieldValueTextCtrl->GetValidator()->Validate( this ) )
|
|
|
|
return false;
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_FIELD& field = m_FieldsBuf[fieldNdx];
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
field.SetVisible( showCheckBox->GetValue() );
|
2008-11-26 00:20:16 +00:00
|
|
|
|
|
|
|
if( rotateCheckBox->GetValue() )
|
2017-01-23 20:30:11 +00:00
|
|
|
field.SetTextAngle( TEXT_ANGLE_VERT );
|
2008-11-26 00:20:16 +00:00
|
|
|
else
|
2017-01-23 20:30:11 +00:00
|
|
|
field.SetTextAngle( TEXT_ANGLE_HORIZ );
|
2008-11-26 00:20:16 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
rotateCheckBox->SetValue( field.GetTextAngle() == TEXT_ANGLE_VERT );
|
2008-11-26 00:20:16 +00:00
|
|
|
|
2010-12-21 12:41:17 +00:00
|
|
|
// Copy the text justification
|
2013-11-18 22:03:34 +00:00
|
|
|
static const EDA_TEXT_HJUSTIFY_T hjustify[] = {
|
|
|
|
GR_TEXT_HJUSTIFY_LEFT,
|
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
2010-12-21 12:41:17 +00:00
|
|
|
GR_TEXT_HJUSTIFY_RIGHT
|
|
|
|
};
|
|
|
|
|
2013-11-18 22:03:34 +00:00
|
|
|
static const EDA_TEXT_VJUSTIFY_T vjustify[] = {
|
2017-11-10 16:26:48 +00:00
|
|
|
GR_TEXT_VJUSTIFY_TOP,
|
2013-11-18 22:03:34 +00:00
|
|
|
GR_TEXT_VJUSTIFY_CENTER,
|
2017-11-10 16:26:48 +00:00
|
|
|
GR_TEXT_VJUSTIFY_BOTTOM
|
2010-12-21 12:41:17 +00:00
|
|
|
};
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
field.SetHorizJustify( hjustify[m_FieldHJustifyCtrl->GetSelection()] );
|
|
|
|
field.SetVertJustify( vjustify[m_FieldVJustifyCtrl->GetSelection()] );
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2011-12-07 18:47:59 +00:00
|
|
|
field.SetName( fieldNameTextCtrl->GetValue() );
|
2011-08-30 19:24:28 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
/* Void fields texts for REFERENCE and VALUE (value is the name of the
|
2011-08-30 19:24:28 +00:00
|
|
|
* component in lib ! ) are not allowed
|
2009-01-02 17:31:32 +00:00
|
|
|
* change them only for a new non void value
|
2011-08-30 19:24:28 +00:00
|
|
|
* When void, usually netlists are broken
|
2009-01-02 17:31:32 +00:00
|
|
|
*/
|
|
|
|
if( !fieldValueTextCtrl->GetValue().IsEmpty() || fieldNdx > VALUE )
|
2013-03-18 19:36:07 +00:00
|
|
|
field.SetText( fieldValueTextCtrl->GetValue() );
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
setRowItem( fieldNdx, field ); // update fieldListCtrl
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
int tmp = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(), g_UserUnit );
|
2017-01-23 20:30:11 +00:00
|
|
|
field.SetTextSize( wxSize( tmp, tmp ) );
|
2008-12-31 09:27:19 +00:00
|
|
|
int style = m_StyleRadioBox->GetSelection();
|
2012-04-16 17:39:32 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
field.SetItalic( (style & 1 ) != 0 );
|
|
|
|
field.SetBold( (style & 2 ) != 0 );
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
wxPoint pos;
|
* 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
|
|
|
pos.x = ValueFromString( g_UserUnit, posXTextCtrl->GetValue() );
|
|
|
|
pos.y = ValueFromString( g_UserUnit, posYTextCtrl->GetValue() );
|
2017-01-23 20:30:11 +00:00
|
|
|
field.SetTextPos( pos );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
return true;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-11-27 18:42:19 +00:00
|
|
|
// Remove non existing choices (choiceCount must be <= number for parts)
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
int unitcount = m_part ? m_part->GetUnitCount() : 1;
|
2008-12-31 09:27:19 +00:00
|
|
|
|
|
|
|
if( unitcount < 1 )
|
2008-11-27 18:42:19 +00:00
|
|
|
unitcount = 1;
|
2009-01-29 08:58:48 +00:00
|
|
|
|
2014-12-20 17:26:37 +00:00
|
|
|
unitChoice->Clear();
|
|
|
|
|
2015-04-07 13:19:30 +00:00
|
|
|
for( int ii = 1; ii <= unitcount; ii++ )
|
2008-11-27 18:42:19 +00:00
|
|
|
{
|
2015-04-07 13:19:30 +00:00
|
|
|
unitChoice->Append( LIB_PART::SubReference( ii, false ) );
|
2008-11-27 18:42:19 +00:00
|
|
|
}
|
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
// For symbols with multiple parts per package, set the unit selection
|
2015-02-17 18:47:21 +00:00
|
|
|
if( m_cmp->GetUnit() <= (int)unitChoice->GetCount() )
|
|
|
|
unitChoice->SetSelection( m_cmp->GetUnit() - 1 );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-27 18:42:19 +00:00
|
|
|
// Disable unit selection if only one unit exists:
|
2015-04-07 11:52:29 +00:00
|
|
|
if( m_cmp->GetUnitCount() <= 1 )
|
2013-12-14 19:03:38 +00:00
|
|
|
{
|
2008-12-31 09:27:19 +00:00
|
|
|
unitChoice->Enable( false );
|
2013-12-14 19:03:38 +00:00
|
|
|
unitsInterchageableLabel->Show( false );
|
|
|
|
unitsInterchageableText->Show( false );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Show the "Units are not interchangeable" message option?
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
if( !m_part || !m_part->UnitsLocked() )
|
2014-12-20 17:26:37 +00:00
|
|
|
unitsInterchageableLabel->SetLabel( _( "Yes" ) );
|
2013-12-14 19:03:38 +00:00
|
|
|
else
|
2014-12-20 17:26:37 +00:00
|
|
|
unitsInterchageableLabel->SetLabel( _( "No" ) );
|
2013-12-14 19:03:38 +00:00
|
|
|
}
|
2008-11-27 18:42:19 +00:00
|
|
|
|
2015-02-17 18:47:21 +00:00
|
|
|
int orientation = m_cmp->GetOrientation() & ~( CMP_MIRROR_X | CMP_MIRROR_Y );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
if( orientation == CMP_ORIENT_90 )
|
|
|
|
orientationRadioBox->SetSelection( 1 );
|
|
|
|
else if( orientation == CMP_ORIENT_180 )
|
|
|
|
orientationRadioBox->SetSelection( 2 );
|
|
|
|
else if( orientation == CMP_ORIENT_270 )
|
|
|
|
orientationRadioBox->SetSelection( 3 );
|
2008-11-26 05:08:37 +00:00
|
|
|
else
|
|
|
|
orientationRadioBox->SetSelection( 0 );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2015-02-17 18:47:21 +00:00
|
|
|
int mirror = m_cmp->GetOrientation() & ( CMP_MIRROR_X | CMP_MIRROR_Y );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
if( mirror == CMP_MIRROR_X )
|
2008-11-26 00:20:16 +00:00
|
|
|
{
|
|
|
|
mirrorRadioBox->SetSelection( 1 );
|
2013-09-10 15:07:46 +00:00
|
|
|
DBG( printf( "mirror=X,1\n" ); )
|
2008-11-26 00:20:16 +00:00
|
|
|
}
|
2010-01-13 21:15:54 +00:00
|
|
|
else if( mirror == CMP_MIRROR_Y )
|
2008-11-26 00:20:16 +00:00
|
|
|
{
|
|
|
|
mirrorRadioBox->SetSelection( 2 );
|
2013-09-10 15:07:46 +00:00
|
|
|
DBG( printf( "mirror=Y,2\n" ); )
|
2008-11-26 00:20:16 +00:00
|
|
|
}
|
2008-11-26 05:08:37 +00:00
|
|
|
else
|
|
|
|
mirrorRadioBox->SetSelection( 0 );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
// Activate/Desactivate the normal/convert option ? (activated only if
|
|
|
|
// the component has more than one shape)
|
2015-02-17 18:47:21 +00:00
|
|
|
if( m_cmp->GetConvert() > 1 )
|
2008-11-26 00:20:16 +00:00
|
|
|
convertCheckBox->SetValue( true );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
if( m_part == NULL || !m_part->HasConversion() )
|
2008-11-26 00:20:16 +00:00
|
|
|
convertCheckBox->Enable( false );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2011-08-30 19:24:28 +00:00
|
|
|
// Set the component's library name.
|
2017-07-24 19:02:59 +00:00
|
|
|
chipnameTextCtrl->SetValue( m_cmp->GetLibId().Format() );
|
2013-12-14 19:03:38 +00:00
|
|
|
|
|
|
|
// Set the component's unique ID time stamp.
|
2014-12-20 17:26:37 +00:00
|
|
|
m_textCtrlTimeStamp->SetValue( wxString::Format( wxT( "%8.8lX" ),
|
2015-02-17 18:47:21 +00:00
|
|
|
(unsigned long) m_cmp->GetTimeStamp() ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2011-08-30 19:24:28 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
2015-02-17 18:47:21 +00:00
|
|
|
if( !m_cmp )
|
2008-11-26 00:20:16 +00:00
|
|
|
return;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2017-12-07 23:01:03 +00:00
|
|
|
if( LIB_PART* part = GetParent()->GetLibPart( m_cmp->GetLibId() ) )
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
{
|
|
|
|
// save old cmp in undo list if not already in edit, or moving ...
|
2017-01-31 01:31:19 +00:00
|
|
|
if( m_cmp->GetFlags() == 0 )
|
2017-10-06 18:07:43 +00:00
|
|
|
GetParent()->SaveCopyInUndoList( m_cmp, UR_CHANGED );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
INSTALL_UNBUFFERED_DC( dc, GetParent()->GetCanvas() );
|
|
|
|
m_cmp->Draw( GetParent()->GetCanvas(), &dc, wxPoint( 0, 0 ), g_XorMode );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
// Initialize fixed field values to default values found in library
|
|
|
|
// Note: the field texts are not modified because they are set in schematic,
|
|
|
|
// the text from libraries is most of time a dummy text
|
|
|
|
// Only VALUE, REFERENCE , FOOTPRINT and DATASHEET are re-initialized
|
|
|
|
LIB_FIELD& refField = part->GetReferenceField();
|
2010-07-11 17:26:03 +00:00
|
|
|
|
2015-02-17 18:47:21 +00:00
|
|
|
m_cmp->GetField( REFERENCE )->ImportValues( refField );
|
2017-05-24 19:19:26 +00:00
|
|
|
m_cmp->GetField( REFERENCE )->SetTextPos( refField.GetTextPos() + m_cmp->m_Pos );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
LIB_FIELD& valField = part->GetValueField();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2015-02-17 18:47:21 +00:00
|
|
|
m_cmp->GetField( VALUE )->ImportValues( valField );
|
2017-05-24 19:19:26 +00:00
|
|
|
m_cmp->GetField( VALUE )->SetTextPos( valField.GetTextPos() + m_cmp->m_Pos );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
LIB_FIELD* field = part->GetField(FOOTPRINT);
|
2013-10-14 16:03:38 +00:00
|
|
|
|
2015-02-17 18:47:21 +00:00
|
|
|
if( field && m_cmp->GetField( FOOTPRINT ) )
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
{
|
2015-02-17 18:47:21 +00:00
|
|
|
m_cmp->GetField( FOOTPRINT )->ImportValues( *field );
|
2017-05-24 19:19:26 +00:00
|
|
|
m_cmp->GetField( FOOTPRINT )->SetTextPos( field->GetTextPos() + m_cmp->m_Pos );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
}
|
2013-10-14 16:03:38 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
field = part->GetField(DATASHEET);
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2015-02-17 18:47:21 +00:00
|
|
|
if( field && m_cmp->GetField( DATASHEET ) )
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
{
|
2015-02-17 18:47:21 +00:00
|
|
|
m_cmp->GetField( DATASHEET )->ImportValues( *field );
|
2017-05-24 19:19:26 +00:00
|
|
|
m_cmp->GetField( DATASHEET )->SetTextPos( field->GetTextPos() + m_cmp->m_Pos );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2015-02-17 18:47:21 +00:00
|
|
|
m_cmp->SetOrientation( CMP_NORMAL );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
GetParent()->OnModify();
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
m_cmp->Draw( GetParent()->GetCanvas(), &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
2014-09-15 11:59:40 +00:00
|
|
|
EndQuasiModal( wxID_OK );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2017-08-25 11:37:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::UpdateFields( wxCommandEvent& event )
|
|
|
|
{
|
2017-10-02 12:53:48 +00:00
|
|
|
SCH_COMPONENT copy( *m_cmp );
|
|
|
|
std::list<SCH_COMPONENT*> components;
|
|
|
|
components.push_back( © );
|
2017-10-22 00:48:25 +00:00
|
|
|
InvokeDialogUpdateFields( GetParent(), components, false );
|
2017-08-25 11:37:21 +00:00
|
|
|
|
2017-10-02 12:53:48 +00:00
|
|
|
// Copy fields from the modified component copy to the dialog buffer
|
|
|
|
m_FieldsBuf.clear();
|
2017-08-25 11:37:21 +00:00
|
|
|
|
2017-10-02 12:53:48 +00:00
|
|
|
for( int i = 0; i < copy.GetFieldCount(); ++i )
|
2017-08-25 11:37:21 +00:00
|
|
|
{
|
2017-10-02 12:53:48 +00:00
|
|
|
copy.m_Fields[i].SetParent( m_cmp );
|
|
|
|
m_FieldsBuf.push_back( copy.m_Fields[i] );
|
|
|
|
m_FieldsBuf[i].Offset( -m_cmp->m_Pos );
|
2017-08-25 11:37:21 +00:00
|
|
|
}
|
|
|
|
|
2017-10-02 12:53:48 +00:00
|
|
|
// Update the selected field as well
|
|
|
|
copySelectedFieldToPanel();
|
2017-08-25 11:37:21 +00:00
|
|
|
updateDisplay();
|
|
|
|
}
|
2018-03-05 00:06:12 +00:00
|
|
|
|
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnSizeFieldsList( wxSizeEvent& event )
|
|
|
|
{
|
|
|
|
int newWidth = event.GetSize().GetX();
|
|
|
|
fieldListCtrl->SetColumnWidth( 1, newWidth - fieldListCtrl->GetColumnWidth( 0 ) );
|
|
|
|
event.Skip();
|
|
|
|
}
|