2012-06-09 09:38:58 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-07-19 17:35:25 +00:00
|
|
|
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
2018-01-14 13:24:58 +00:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2015-02-02 16:43:34 +00:00
|
|
|
* Copyright (C) 2015 Dick Hollenbeck, dick@softplc.com
|
2018-01-14 13:24:58 +00:00
|
|
|
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-06-09 09:38:58 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
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 <kiface_i.h>
|
2018-03-28 17:14:04 +00:00
|
|
|
#include <view/view.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <pcbnew.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>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2016-06-20 13:46:58 +00:00
|
|
|
#include <board_commit.h>
|
2018-03-28 17:14:04 +00:00
|
|
|
#include <board_design_settings.h>
|
2018-03-12 22:45:17 +00:00
|
|
|
#include <dialog_text_entry.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_module.h>
|
2015-02-02 16:43:34 +00:00
|
|
|
#include <validators.h>
|
2018-05-30 10:52:19 +00:00
|
|
|
#include <widgets/wx_grid.h>
|
2017-11-23 13:05:26 +00:00
|
|
|
#include <widgets/text_ctrl_eval.h>
|
2018-03-07 13:05:12 +00:00
|
|
|
#include <filename_resolver.h>
|
2016-01-16 06:49:28 +00:00
|
|
|
#include "3d_cache/dialogs/panel_prev_model.h"
|
|
|
|
#include "3d_cache/dialogs/3d_cache_dialogs.h"
|
2018-03-28 17:14:04 +00:00
|
|
|
#include <bitmaps.h>
|
|
|
|
#include <3d_viewer.h>
|
2018-01-14 13:24:58 +00:00
|
|
|
|
2018-05-30 10:52:19 +00:00
|
|
|
#include <dialog_edit_footprint_for_BoardEditor.h>
|
|
|
|
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
#define FootprintTextShownColumnsKey wxT( "FootprintTextShownColumns" )
|
2015-02-02 16:43:34 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
int DIALOG_FOOTPRINT_BOARD_EDITOR::m_page = 0; // remember the last open page during session
|
2017-04-04 14:05:01 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
DIALOG_FOOTPRINT_BOARD_EDITOR::DIALOG_FOOTPRINT_BOARD_EDITOR( PCB_EDIT_FRAME* aParent,
|
|
|
|
MODULE* aModule, wxDC* aDC ) :
|
2018-02-16 19:26:55 +00:00
|
|
|
DIALOG_FOOTPRINT_BOARD_EDITOR_BASE( aParent ),
|
2018-03-28 17:14:04 +00:00
|
|
|
m_posX( aParent, m_XPosLabel, m_ModPositionX, m_XPosUnit ),
|
|
|
|
m_posY( aParent, m_YPosLabel, m_ModPositionY, m_YPosUnit ),
|
|
|
|
m_OrientValidator( 1, &m_OrientValue ),
|
|
|
|
m_netClearance( aParent, m_NetClearanceLabel, m_NetClearanceCtrl, m_NetClearanceUnits, false, 0 ),
|
|
|
|
m_solderMask( aParent, m_SolderMaskMarginLabel, m_SolderMaskMarginCtrl, m_SolderMaskMarginUnits ),
|
2018-07-22 23:26:09 +00:00
|
|
|
m_solderPaste( aParent, m_SolderPasteMarginLabel, m_SolderPasteMarginCtrl, m_SolderPasteMarginUnits ),
|
|
|
|
m_inSelect( false )
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
m_config = Kiface().KifaceSettings();
|
|
|
|
|
|
|
|
m_frame = aParent;
|
|
|
|
m_DC = aDC;
|
|
|
|
m_footprint = aModule;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_texts = new TEXT_MOD_GRID_TABLE( m_units, m_frame );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_delayedErrorMessage = wxEmptyString;
|
|
|
|
m_delayedFocusGrid = nullptr;
|
|
|
|
m_delayedFocusRow = -1;
|
|
|
|
m_delayedFocusColumn = -1;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2011-09-11 11:38:01 +00:00
|
|
|
// Give an icon
|
|
|
|
wxIcon icon;
|
|
|
|
icon.CopyFromBitmap( KiBitmap( icon_modedit_xpm ) );
|
|
|
|
SetIcon( icon );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
// Give a bit more room for combobox editors
|
|
|
|
m_itemsGrid->SetDefaultRowSize( m_itemsGrid->GetDefaultRowSize() + 4 );
|
|
|
|
m_modelsGrid->SetDefaultRowSize( m_modelsGrid->GetDefaultRowSize() + 4 );
|
|
|
|
|
2018-05-30 10:52:19 +00:00
|
|
|
m_itemsGrid->SetTable( m_texts );
|
2018-03-28 17:14:04 +00:00
|
|
|
m_itemsGrid->PushEventHandler( new GRID_TRICKS( m_itemsGrid ) );
|
|
|
|
m_modelsGrid->PushEventHandler( new GRID_TRICKS( m_modelsGrid ) );
|
|
|
|
|
|
|
|
// Show/hide text item columns according to the user's preference
|
|
|
|
wxString shownColumns;
|
|
|
|
m_config->Read( FootprintTextShownColumnsKey, &shownColumns, wxT( "0 1 2 3 4 5 6" ) );
|
2018-05-30 10:52:19 +00:00
|
|
|
m_itemsGrid->ShowHideColumns( shownColumns );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
// Set up the 3D models grid
|
|
|
|
wxGridCellAttr* attr = new wxGridCellAttr;
|
|
|
|
attr->SetRenderer( new wxGridCellBoolRenderer() );
|
|
|
|
attr->SetReadOnly(); // not really; we delegate interactivity to GRID_TRICKS
|
|
|
|
attr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
|
|
|
|
m_modelsGrid->SetColAttr( 1, attr );
|
|
|
|
m_modelsGrid->SetWindowStyleFlag( m_modelsGrid->GetWindowStyle() & ~wxHSCROLL );
|
|
|
|
|
2016-04-10 12:59:23 +00:00
|
|
|
m_OrientValidator.SetRange( -360.0, 360.0 );
|
|
|
|
m_OrientValueCtrl->SetValidator( m_OrientValidator );
|
2016-04-10 22:28:06 +00:00
|
|
|
m_OrientValidator.SetWindow( m_OrientValueCtrl );
|
2016-04-10 12:59:23 +00:00
|
|
|
|
2016-04-17 22:35:32 +00:00
|
|
|
aParent->Prj().Get3DCacheManager()->GetResolver()->SetProgramBase( &Pgm() );
|
2016-08-05 19:30:23 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_PreviewPane = new PANEL_PREV_3D( m_Panel3D, m_frame, m_footprint, &m_shapes3D_list );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
bLowerSizer3D->Add( m_PreviewPane, 1, wxEXPAND, 5 );
|
|
|
|
|
2018-07-17 21:14:02 +00:00
|
|
|
// Set font sizes
|
2018-05-04 16:20:41 +00:00
|
|
|
wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
2018-03-28 17:14:04 +00:00
|
|
|
infoFont.SetSymbolicSize( wxFONTSIZE_SMALL );
|
2018-07-17 21:14:02 +00:00
|
|
|
m_allow90Label->SetFont( infoFont );
|
|
|
|
m_allow180Label->SetFont( infoFont );
|
|
|
|
m_libraryIDLabel->SetFont( infoFont );
|
|
|
|
m_staticLibraryID->SetFont( infoFont );
|
2018-05-04 16:20:41 +00:00
|
|
|
m_staticTextInfoValNeg->SetFont( infoFont );
|
|
|
|
m_staticTextInfoValPos->SetFont( infoFont );
|
2018-07-17 21:14:02 +00:00
|
|
|
m_staticTextInfoCopper->SetFont( infoFont );
|
2018-05-04 16:20:41 +00:00
|
|
|
|
2015-02-02 16:43:34 +00:00
|
|
|
m_NoteBook->SetSelection( m_page );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
if( m_page == 0 )
|
|
|
|
{
|
|
|
|
m_delayedFocusGrid = m_itemsGrid;
|
|
|
|
m_delayedFocusRow = 0;
|
|
|
|
m_delayedFocusColumn = 0;
|
|
|
|
}
|
|
|
|
else if ( m_page == 1 )
|
|
|
|
SetInitialFocus( m_NetClearanceCtrl );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_delayedFocusGrid = m_modelsGrid;
|
|
|
|
m_delayedFocusRow = 0;
|
|
|
|
m_delayedFocusColumn = 0;
|
|
|
|
}
|
|
|
|
|
2011-03-14 15:17:18 +00:00
|
|
|
m_sdbSizerStdButtonsOK->SetDefault();
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-05-11 02:36:23 +00:00
|
|
|
m_OrientValue = 0;
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
// Configure button logos
|
|
|
|
m_bpAdd->SetBitmap( KiBitmap( small_plus_xpm ) );
|
|
|
|
m_bpDelete->SetBitmap( KiBitmap( trash_xpm ) );
|
|
|
|
m_buttonAdd->SetBitmap( KiBitmap( small_plus_xpm ) );
|
2018-07-22 23:26:09 +00:00
|
|
|
m_buttonBrowse->SetBitmap( KiBitmap( folder_xpm ) );
|
2018-03-28 17:14:04 +00:00
|
|
|
m_buttonRemove->SetBitmap( KiBitmap( trash_xpm ) );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
FinishDialogSettings();
|
|
|
|
}
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2015-02-02 16:43:34 +00:00
|
|
|
|
2018-02-16 19:26:55 +00:00
|
|
|
DIALOG_FOOTPRINT_BOARD_EDITOR::~DIALOG_FOOTPRINT_BOARD_EDITOR()
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2018-05-30 10:52:19 +00:00
|
|
|
m_config->Write( FootprintTextShownColumnsKey, m_itemsGrid->GetShownColumns() );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
// Prevents crash bug in wxGrid's d'tor
|
2018-05-30 10:52:19 +00:00
|
|
|
m_itemsGrid->DestroyTable( m_texts );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
// Delete the GRID_TRICKS.
|
|
|
|
m_itemsGrid->PopEventHandler( true );
|
|
|
|
m_modelsGrid->PopEventHandler( true );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2016-02-21 00:54:34 +00:00
|
|
|
// free the memory used by all models, otherwise models which were
|
|
|
|
// browsed but not used would consume memory
|
|
|
|
Prj().Get3DCacheManager()->FlushCache( false );
|
|
|
|
|
2016-06-14 10:08:35 +00:00
|
|
|
// the GL canvas has to be visible before it is destroyed
|
|
|
|
m_page = m_NoteBook->GetSelection();
|
|
|
|
m_NoteBook->SetSelection( 1 );
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
delete m_PreviewPane;
|
2009-11-04 19:08:08 +00:00
|
|
|
}
|
2009-08-11 10:27:21 +00:00
|
|
|
|
|
|
|
|
2018-10-15 14:28:53 +00:00
|
|
|
void DIALOG_FOOTPRINT_BOARD_EDITOR::EditFootprint( wxCommandEvent& )
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
if( m_footprint->GetTimeStamp() == 0 ) // Module Editor needs a non null timestamp
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
m_footprint->SetTimeStamp( GetNewTimeStamp() );
|
|
|
|
m_frame->OnModify();
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
|
|
|
|
2018-10-15 14:28:53 +00:00
|
|
|
EndModal( PRM_EDITOR_EDIT_BOARD_FOOTPRINT );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_BOARD_EDITOR::EditLibraryFootprint( wxCommandEvent& )
|
|
|
|
{
|
|
|
|
EndModal( PRM_EDITOR_EDIT_LIBRARY_FOOTPRINT );
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
void DIALOG_FOOTPRINT_BOARD_EDITOR::UpdateModule( wxCommandEvent& )
|
2018-01-12 19:36:15 +00:00
|
|
|
{
|
|
|
|
EndModal( PRM_EDITOR_WANT_UPDATE_FP );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
void DIALOG_FOOTPRINT_BOARD_EDITOR::ExchangeModule( wxCommandEvent& )
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2015-08-20 18:13:18 +00:00
|
|
|
EndModal( PRM_EDITOR_WANT_EXCHANGE_FP );
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
void DIALOG_FOOTPRINT_BOARD_EDITOR::ModuleOrientEvent( wxCommandEvent& )
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
if( m_Orient0->GetValue() )
|
2016-04-10 12:59:23 +00:00
|
|
|
m_OrientValue = 0.0;
|
2018-03-28 17:14:04 +00:00
|
|
|
else if( m_Orient90->GetValue() )
|
2016-04-10 12:59:23 +00:00
|
|
|
m_OrientValue = 90.0;
|
2018-03-28 17:14:04 +00:00
|
|
|
else if( m_Orient270->GetValue() )
|
2016-04-10 12:59:23 +00:00
|
|
|
m_OrientValue = 270.0;
|
2018-03-28 17:14:04 +00:00
|
|
|
else if( m_Orient180->GetValue() )
|
2016-04-10 12:59:23 +00:00
|
|
|
m_OrientValue = 180.0;
|
|
|
|
|
|
|
|
m_OrientValidator.TransferToWindow();
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
void DIALOG_FOOTPRINT_BOARD_EDITOR::OnOtherOrientation( wxKeyEvent& aEvent )
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
m_OrientOther->SetValue( true );
|
2014-02-10 09:30:08 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
aEvent.Skip();
|
|
|
|
}
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
bool DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataToWindow()
|
|
|
|
{
|
|
|
|
if( !wxDialog::TransferDataToWindow() )
|
|
|
|
return false;
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
if( !m_PanelGeneral->TransferDataToWindow() )
|
|
|
|
return false;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
if( !m_Panel3D->TransferDataToWindow() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Module Texts
|
2016-01-16 06:49:28 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_texts->push_back( m_footprint->Reference() );
|
|
|
|
m_texts->push_back( m_footprint->Value() );
|
|
|
|
|
|
|
|
for( BOARD_ITEM* item = m_footprint->GraphicalItemsList().GetFirst(); item; item = item->Next() )
|
|
|
|
{
|
|
|
|
auto textModule = dyn_cast<TEXTE_MODULE*>( item );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
if( textModule )
|
|
|
|
m_texts->push_back( *textModule );
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
// notify the grid
|
|
|
|
wxGridTableMessage tmsg( m_texts, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_texts->GetNumberRows() );
|
|
|
|
m_itemsGrid->ProcessTableMessage( tmsg );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
// Module Properties
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_posX.SetValue( m_footprint->GetPosition().x );
|
|
|
|
m_posY.SetValue( m_footprint->GetPosition().y );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_OrientValue = m_footprint->GetOrientation() / 10.0;
|
|
|
|
m_Orient0->SetValue( m_OrientValue == 0.0 );
|
|
|
|
m_Orient90->SetValue( m_OrientValue == 90.0 || m_OrientValue == -270.0 );
|
|
|
|
m_Orient270->SetValue( m_OrientValue == 270.0 || m_OrientValue == -90.0 );
|
|
|
|
m_Orient180->SetValue( m_OrientValue == 180.0 || m_OrientValue == -180.0 );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_OrientOther->SetValue( !m_Orient0->GetValue() && !m_Orient90->GetValue()
|
|
|
|
&& !m_Orient270->GetValue() && !m_Orient180->GetValue() );
|
|
|
|
m_OrientValidator.TransferToWindow();
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-08-15 13:29:53 +00:00
|
|
|
m_BoardSideCtrl->SetSelection( (m_footprint->GetLayer() == B_Cu) ? 1 : 0 );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
if( m_footprint->IsLocked() )
|
2015-02-17 23:58:14 +00:00
|
|
|
m_AutoPlaceCtrl->SetSelection( 2 );
|
2018-03-28 17:14:04 +00:00
|
|
|
else if( m_footprint->PadsLocked() )
|
2015-02-17 23:58:14 +00:00
|
|
|
m_AutoPlaceCtrl->SetSelection( 1 );
|
|
|
|
else
|
|
|
|
m_AutoPlaceCtrl->SetSelection( 0 );
|
2012-08-21 10:45:54 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_AutoPlaceCtrl->SetItemToolTip( 0, _( "Component can be freely moved and auto placed. User "
|
|
|
|
"can arbitrarily select and edit component's pads." ) );
|
|
|
|
m_AutoPlaceCtrl->SetItemToolTip( 1, _( "Component can be freely moved and auto placed, but "
|
|
|
|
"its pads cannot be selected or edited." ) );
|
|
|
|
m_AutoPlaceCtrl->SetItemToolTip( 2, _( "Component is locked: it cannot be freely moved or "
|
|
|
|
"auto placed." ) );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_CostRot90Ctrl->SetValue( m_footprint->GetPlacementCost90() );
|
|
|
|
m_CostRot180Ctrl->SetValue( m_footprint->GetPlacementCost180() );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_AttributsCtrl->SetItemToolTip( 0, _( "Use this attribute for most non SMD footprints\n"
|
|
|
|
"Footprints with this option are not put in the footprint position list file" ) );
|
|
|
|
m_AttributsCtrl->SetItemToolTip( 1, _( "Use this attribute for SMD footprints.\n"
|
|
|
|
"Only footprints with this option are put in the footprint position list file" ) );
|
|
|
|
m_AttributsCtrl->SetItemToolTip( 2, _( "Use this attribute for \"virtual\" footprints drawn on board\n"
|
|
|
|
"such as an edge connector (old ISA PC bus for instance)" ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
switch( m_footprint->GetAttributes() & 255 )
|
2016-01-23 03:52:54 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
case MOD_CMS: m_AttributsCtrl->SetSelection( 1 ); break;
|
|
|
|
case MOD_VIRTUAL: m_AttributsCtrl->SetSelection( 2 ); break;
|
|
|
|
case 0:
|
|
|
|
default: m_AttributsCtrl->SetSelection( 0 ); break;
|
2016-01-23 03:52:54 +00:00
|
|
|
}
|
2013-03-04 12:08:35 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
// Local Clearances
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_netClearance.SetValue( m_footprint->GetLocalClearance() );
|
|
|
|
m_solderMask.SetValue( m_footprint->GetLocalSolderMaskMargin() );
|
|
|
|
m_solderPaste.SetValue( m_footprint->GetLocalSolderPasteMargin() );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
// Prefer "-0" to "0" for normally negative values
|
|
|
|
if( m_footprint->GetLocalSolderPasteMargin() == 0 )
|
|
|
|
m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) + m_SolderPasteMarginCtrl->GetValue() );
|
2009-08-17 19:04:51 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
// Add solder paste margin ratio in per cent
|
|
|
|
// for the usual default value 0.0, display -0.0 (or -0,0 in some countries)
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf( wxT( "%f" ), m_footprint->GetLocalSolderPasteMarginRatio() * 100.0 );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
if( m_footprint->GetLocalSolderPasteMarginRatio() == 0.0 &&
|
|
|
|
msg[0] == '0') // Sometimes Printf adds a sign if the value is very small (0.0)
|
|
|
|
m_SolderPasteMarginRatioCtrl->SetValue( wxT("-") + msg );
|
|
|
|
else
|
|
|
|
m_SolderPasteMarginRatioCtrl->SetValue( msg );
|
2009-08-17 19:04:51 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
switch( m_footprint->GetZoneConnection() )
|
2009-08-17 19:04:51 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
default:
|
|
|
|
case PAD_ZONE_CONN_INHERITED: m_ZoneConnectionChoice->SetSelection( 0 ); break;
|
|
|
|
case PAD_ZONE_CONN_FULL: m_ZoneConnectionChoice->SetSelection( 1 ); break;
|
|
|
|
case PAD_ZONE_CONN_THERMAL: m_ZoneConnectionChoice->SetSelection( 2 ); break;
|
|
|
|
case PAD_ZONE_CONN_NONE: m_ZoneConnectionChoice->SetSelection( 3 ); break;
|
2009-08-17 19:04:51 +00:00
|
|
|
}
|
2016-01-16 06:49:28 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
// 3D Settings
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
wxString default_path;
|
|
|
|
wxGetEnv( KISYS3DMOD, &default_path );
|
|
|
|
#ifdef __WINDOWS__
|
|
|
|
default_path.Replace( wxT( "/" ), wxT( "\\" ) );
|
|
|
|
#endif
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_shapes3D_list.clear();
|
|
|
|
m_modelsGrid->DeleteRows( 0, m_modelsGrid->GetNumberRows() );
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
wxString origPath, alias, shortPath;
|
|
|
|
FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
for( MODULE_3D_SETTINGS model : m_footprint->Models() )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
m_shapes3D_list.push_back( model );
|
|
|
|
origPath = model.m_Filename;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
if( res && res->SplitAlias( origPath, alias, shortPath ) )
|
|
|
|
origPath = alias + wxT( ":" ) + shortPath;
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_modelsGrid->AppendRows( 1 );
|
|
|
|
int row = m_modelsGrid->GetNumberRows() - 1;
|
|
|
|
m_modelsGrid->SetCellValue( row, 0, origPath );
|
|
|
|
m_modelsGrid->SetCellValue( row, 1, model.m_Preview ? wxT( "1" ) : wxT( "0" ) );
|
|
|
|
}
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
select3DModel( 0 ); // will clamp idx within bounds
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2018-08-15 13:29:19 +00:00
|
|
|
// Show the footprint's ID.
|
2018-03-28 17:14:04 +00:00
|
|
|
m_staticLibraryID->SetLabel( m_footprint->GetFPID().Format() );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
Layout();
|
|
|
|
adjustGridColumns( m_itemsGrid->GetRect().GetWidth());
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
return true;
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
void DIALOG_FOOTPRINT_BOARD_EDITOR::select3DModel( int aModelIdx )
|
2015-02-02 16:43:34 +00:00
|
|
|
{
|
2018-07-22 23:26:09 +00:00
|
|
|
m_inSelect = true;
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
aModelIdx = std::max( 0, aModelIdx );
|
|
|
|
aModelIdx = std::min( aModelIdx, m_modelsGrid->GetNumberRows() - 1 );
|
2015-02-02 16:43:34 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
if( m_modelsGrid->GetNumberRows() )
|
2018-07-22 23:26:09 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
m_modelsGrid->SelectRow( aModelIdx );
|
2018-07-22 23:26:09 +00:00
|
|
|
m_modelsGrid->SetGridCursor( aModelIdx, 0 );
|
|
|
|
}
|
2016-01-16 06:49:28 +00:00
|
|
|
|
2018-07-20 20:56:12 +00:00
|
|
|
m_PreviewPane->SetSelectedModel( aModelIdx );
|
2018-07-22 23:26:09 +00:00
|
|
|
|
|
|
|
m_inSelect = false;
|
2018-03-28 17:14:04 +00:00
|
|
|
}
|
2016-01-16 06:49:28 +00:00
|
|
|
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
void DIALOG_FOOTPRINT_BOARD_EDITOR::On3DModelSelected( wxGridEvent& aEvent )
|
|
|
|
{
|
2018-07-22 23:26:09 +00:00
|
|
|
if( !m_inSelect )
|
|
|
|
select3DModel( aEvent.GetRow() );
|
2018-03-28 17:14:04 +00:00
|
|
|
}
|
2016-01-16 06:49:28 +00:00
|
|
|
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
void DIALOG_FOOTPRINT_BOARD_EDITOR::On3DModelCellChanged( wxGridEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( aEvent.GetCol() == 0 )
|
2016-01-16 06:49:28 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
bool hasAlias = false;
|
|
|
|
FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver();
|
|
|
|
wxString filename = m_modelsGrid->GetCellValue( aEvent.GetRow(), 0 );
|
2016-01-23 03:52:54 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
if( filename.empty() || !res->ValidateFileName( filename, hasAlias ) )
|
|
|
|
{
|
|
|
|
m_delayedErrorMessage = wxString::Format( _( "Invalid filename: %s" ), filename );
|
|
|
|
m_delayedFocusGrid = m_modelsGrid;
|
|
|
|
m_delayedFocusRow = aEvent.GetRow();
|
|
|
|
m_delayedFocusColumn = aEvent.GetCol();
|
2018-08-15 13:29:19 +00:00
|
|
|
aEvent.Veto();
|
2018-03-28 17:14:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// if the user has specified an alias in the name then prepend ':'
|
|
|
|
if( hasAlias )
|
|
|
|
filename.insert( 0, wxT( ":" ) );
|
|
|
|
|
|
|
|
#ifdef __WINDOWS__
|
|
|
|
// In Kicad files, filenames and paths are stored using Unix notation
|
|
|
|
filename.Replace( wxT( "\\" ), wxT( "/" ) );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
m_shapes3D_list[ aEvent.GetRow() ].m_Filename = filename;
|
2016-01-16 06:49:28 +00:00
|
|
|
}
|
2018-03-28 17:14:04 +00:00
|
|
|
else if( aEvent.GetCol() == 1 )
|
|
|
|
{
|
|
|
|
wxString previewValue = m_modelsGrid->GetCellValue( aEvent.GetRow(), 1 );
|
2015-02-02 16:43:34 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_shapes3D_list[ aEvent.GetRow() ].m_Preview = previewValue == wxT( "1" );
|
|
|
|
}
|
2016-01-16 06:49:28 +00:00
|
|
|
|
2018-07-20 20:56:12 +00:00
|
|
|
m_PreviewPane->UpdateDummyModule();
|
2018-03-28 17:14:04 +00:00
|
|
|
}
|
2016-01-16 06:49:28 +00:00
|
|
|
|
2016-01-17 21:33:39 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
void DIALOG_FOOTPRINT_BOARD_EDITOR::OnRemove3DModel( wxCommandEvent& )
|
|
|
|
{
|
2018-08-15 13:29:19 +00:00
|
|
|
m_modelsGrid->CommitPendingChanges( true /* quiet mode */ );
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
int idx = m_modelsGrid->GetGridCursorRow();
|
2016-01-17 21:33:39 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
if( idx >= 0 )
|
|
|
|
{
|
|
|
|
m_shapes3D_list.erase( m_shapes3D_list.begin() + idx );
|
2018-07-22 23:26:09 +00:00
|
|
|
m_modelsGrid->DeleteRows( idx, 1 );
|
2015-12-09 05:43:30 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
select3DModel( idx ); // will clamp idx within bounds
|
2018-07-20 20:56:12 +00:00
|
|
|
m_PreviewPane->UpdateDummyModule();
|
2018-03-28 17:14:04 +00:00
|
|
|
}
|
2015-02-02 16:43:34 +00:00
|
|
|
}
|
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
void DIALOG_FOOTPRINT_BOARD_EDITOR::OnAdd3DModel( wxCommandEvent& )
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2018-08-15 13:29:19 +00:00
|
|
|
if( !m_modelsGrid->CommitPendingChanges() )
|
|
|
|
return;
|
|
|
|
|
2016-01-16 06:49:28 +00:00
|
|
|
PROJECT& prj = Prj();
|
2017-10-27 14:25:20 +00:00
|
|
|
MODULE_3D_SETTINGS model;
|
* 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
|
|
|
|
2014-08-24 07:05:07 +00:00
|
|
|
wxString initialpath = prj.GetRString( PROJECT::VIEWER_3D_PATH );
|
2015-12-08 07:31:57 +00:00
|
|
|
wxString sidx = prj.GetRString( PROJECT::VIEWER_3D_FILTER_INDEX );
|
|
|
|
int filter = 0;
|
* 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
|
|
|
|
2017-12-27 17:43:26 +00:00
|
|
|
// If the PROJECT::VIEWER_3D_PATH hasn't been set yet, use the KISYS3DMOD environment
|
|
|
|
// varaible and fall back to the project path if necessary.
|
|
|
|
if( initialpath.IsEmpty() )
|
|
|
|
{
|
|
|
|
if( !wxGetEnv( "KISYS3DMOD", &initialpath ) || initialpath.IsEmpty() )
|
|
|
|
initialpath = prj.GetProjectPath();
|
|
|
|
}
|
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
if( !sidx.empty() )
|
|
|
|
{
|
|
|
|
long tmp;
|
|
|
|
sidx.ToLong( &tmp );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2016-08-05 19:30:23 +00:00
|
|
|
if( tmp > 0 && tmp <= INT_MAX )
|
2015-12-08 07:31:57 +00:00
|
|
|
filter = (int) tmp;
|
|
|
|
}
|
2010-01-20 12:43:05 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
if( !S3D::Select3DModel( this, Prj().Get3DCacheManager(), initialpath, filter, &model )
|
|
|
|
|| model.m_Filename.empty() )
|
2014-06-10 15:56:43 +00:00
|
|
|
{
|
2015-12-08 07:31:57 +00:00
|
|
|
return;
|
2010-01-20 12:43:05 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
prj.SetRString( PROJECT::VIEWER_3D_PATH, initialpath );
|
|
|
|
sidx = wxString::Format( wxT( "%i" ), filter );
|
|
|
|
prj.SetRString( PROJECT::VIEWER_3D_FILTER_INDEX, sidx );
|
2018-03-07 13:05:12 +00:00
|
|
|
FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver();
|
2016-01-17 21:33:39 +00:00
|
|
|
wxString alias;
|
|
|
|
wxString shortPath;
|
2016-07-19 17:35:25 +00:00
|
|
|
wxString filename = model.m_Filename;
|
2014-08-24 07:05:07 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
if( res && res->SplitAlias( filename, alias, shortPath ) )
|
2018-03-28 17:14:04 +00:00
|
|
|
filename = alias + wxT( ":" ) + shortPath;
|
* 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
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
#ifdef __WINDOWS__
|
2014-08-24 07:05:07 +00:00
|
|
|
// In Kicad files, filenames and paths are stored using Unix notation
|
2017-04-04 14:05:01 +00:00
|
|
|
model.m_Filename.Replace( "\\", "/" );
|
2012-08-21 10:45:54 +00:00
|
|
|
#endif
|
* 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
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
model.m_Preview = true;
|
2016-07-19 17:35:25 +00:00
|
|
|
m_shapes3D_list.push_back( model );
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
int idx = m_modelsGrid->GetNumberRows();
|
|
|
|
m_modelsGrid->AppendRows( 1 );
|
|
|
|
m_modelsGrid->SetCellValue( idx, 0, filename );
|
|
|
|
m_modelsGrid->SetCellValue( idx, 1, wxT( "1" ) );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2018-07-20 20:56:12 +00:00
|
|
|
m_PreviewPane->UpdateDummyModule();
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-22 23:26:09 +00:00
|
|
|
void DIALOG_FOOTPRINT_BOARD_EDITOR::OnAdd3DRow( wxCommandEvent& )
|
|
|
|
{
|
2018-08-15 13:29:19 +00:00
|
|
|
if( !m_modelsGrid->CommitPendingChanges() )
|
|
|
|
return;
|
|
|
|
|
2018-07-22 23:26:09 +00:00
|
|
|
MODULE_3D_SETTINGS model;
|
|
|
|
|
|
|
|
model.m_Preview = true;
|
|
|
|
m_shapes3D_list.push_back( model );
|
|
|
|
|
|
|
|
int row = m_modelsGrid->GetNumberRows();
|
|
|
|
m_modelsGrid->AppendRows( 1 );
|
|
|
|
m_modelsGrid->SetCellValue( row, 1, wxT( "1" ) );
|
|
|
|
|
|
|
|
m_modelsGrid->SetFocus();
|
|
|
|
m_modelsGrid->MakeCellVisible( row, 0 );
|
|
|
|
m_modelsGrid->SetGridCursor( row, 0 );
|
|
|
|
|
|
|
|
m_modelsGrid->EnableCellEditControl( true );
|
|
|
|
m_modelsGrid->ShowCellEditControl();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
bool DIALOG_FOOTPRINT_BOARD_EDITOR::Validate()
|
2016-04-10 12:59:23 +00:00
|
|
|
{
|
2018-08-15 13:29:19 +00:00
|
|
|
if( !m_itemsGrid->CommitPendingChanges() )
|
|
|
|
return false;
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
if( !DIALOG_SHIM::Validate() )
|
2016-04-10 12:59:23 +00:00
|
|
|
return false;
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
// Check for empty texts.
|
|
|
|
for( size_t i = 2; i < m_texts->size(); ++i )
|
2016-08-24 15:18:51 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
TEXTE_MODULE& text = m_texts->at( i );
|
|
|
|
|
|
|
|
if( text.GetText().IsEmpty() )
|
|
|
|
{
|
|
|
|
if( m_NoteBook->GetSelection() != 0 )
|
|
|
|
m_NoteBook->SetSelection( 0 );
|
|
|
|
|
|
|
|
m_delayedErrorMessage = _( "Text items must have some content." );
|
|
|
|
m_delayedFocusColumn = TMC_TEXT;
|
|
|
|
m_delayedFocusRow = i;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2016-08-24 15:18:51 +00:00
|
|
|
}
|
2016-04-10 12:59:23 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
if( !m_netClearance.Validate( true ) )
|
|
|
|
return false;
|
2016-04-10 12:59:23 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-16 19:26:55 +00:00
|
|
|
bool DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataFromWindow()
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
if( !Validate() )
|
|
|
|
return false;
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
if( !DIALOG_SHIM::TransferDataFromWindow() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( !m_PanelGeneral->TransferDataFromWindow() )
|
2016-04-10 12:59:23 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if( !m_Panel3D->TransferDataFromWindow() )
|
|
|
|
return false;
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
if( m_DC )
|
|
|
|
{
|
|
|
|
m_frame->GetCanvas()->CrossHairOff( m_DC );
|
|
|
|
m_footprint->Draw( m_frame->GetCanvas(), m_DC, GR_XOR );
|
2016-08-24 15:18:51 +00:00
|
|
|
}
|
2016-04-10 12:59:23 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
auto view = m_frame->GetGalCanvas()->GetView();
|
|
|
|
BOARD_COMMIT commit( m_frame );
|
|
|
|
commit.Modify( m_footprint );
|
|
|
|
|
|
|
|
// copy reference and value
|
|
|
|
m_footprint->Reference() = m_texts->at( 0 );
|
|
|
|
m_footprint->Value() = m_texts->at( 1 );
|
2018-02-14 16:46:35 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
size_t i = 2;
|
|
|
|
for( BOARD_ITEM* item = m_footprint->GraphicalItemsList().GetFirst(); item; item = item->Next() )
|
2018-02-14 16:46:35 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
TEXTE_MODULE* textModule = dyn_cast<TEXTE_MODULE*>( item );
|
|
|
|
|
|
|
|
if( textModule )
|
|
|
|
{
|
|
|
|
// copy grid table entries till we run out, then delete any remaining texts
|
|
|
|
if( i < m_texts->size() )
|
|
|
|
*textModule = m_texts->at( i++ );
|
|
|
|
else
|
|
|
|
textModule->DeleteStructure();
|
|
|
|
}
|
2018-02-14 16:46:35 +00:00
|
|
|
}
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
// if there are still grid table entries, create new texts for them
|
|
|
|
while( i < m_texts->size() )
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
auto newText = new TEXTE_MODULE( m_texts->at( i++ ) );
|
|
|
|
m_footprint->Add( newText, ADD_APPEND );
|
|
|
|
view->Add( newText );
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 19:08:08 +00:00
|
|
|
// Initialize masks clearances
|
2018-03-28 17:14:04 +00:00
|
|
|
m_footprint->SetLocalClearance( m_netClearance.GetValue() );
|
|
|
|
m_footprint->SetLocalSolderMaskMargin( m_solderMask.GetValue() );
|
|
|
|
m_footprint->SetLocalSolderPasteMargin( m_solderPaste.GetValue() );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
double dtmp = 0.0;
|
2018-03-28 17:14:04 +00:00
|
|
|
wxString msg = m_SolderPasteMarginRatioCtrl->GetValue();
|
2009-11-04 19:08:08 +00:00
|
|
|
msg.ToDouble( &dtmp );
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2012-05-18 08:33:57 +00:00
|
|
|
// A -50% margin ratio means no paste on a pad, the ratio must be >= -50%
|
|
|
|
if( dtmp < -50.0 )
|
|
|
|
dtmp = -50.0;
|
|
|
|
// A margin ratio is always <= 0
|
|
|
|
// 0 means use full pad copper area
|
|
|
|
if( dtmp > 0.0 )
|
|
|
|
dtmp = 0.0;
|
2011-12-22 13:28:11 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_footprint->SetLocalSolderPasteMarginRatio( dtmp / 100 );
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2012-02-24 23:23:46 +00:00
|
|
|
switch( m_ZoneConnectionChoice->GetSelection() )
|
|
|
|
{
|
|
|
|
default:
|
2018-03-28 17:14:04 +00:00
|
|
|
case 0: m_footprint->SetZoneConnection( PAD_ZONE_CONN_INHERITED ); break;
|
|
|
|
case 1: m_footprint->SetZoneConnection( PAD_ZONE_CONN_FULL ); break;
|
|
|
|
case 2: m_footprint->SetZoneConnection( PAD_ZONE_CONN_THERMAL ); break;
|
|
|
|
case 3: m_footprint->SetZoneConnection( PAD_ZONE_CONN_NONE ); break;
|
2012-02-24 23:23:46 +00:00
|
|
|
}
|
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
// Set Module Position
|
2018-03-28 17:14:04 +00:00
|
|
|
wxPoint modpos( m_posX.GetValue(), m_posY.GetValue() );
|
|
|
|
m_footprint->SetPosition( modpos );
|
|
|
|
m_footprint->SetLocked( m_AutoPlaceCtrl->GetSelection() == 2 );
|
|
|
|
m_footprint->SetPadsLocked( m_AutoPlaceCtrl->GetSelection() == 1 );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
|
|
|
switch( m_AttributsCtrl->GetSelection() )
|
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
case 0: m_footprint->SetAttributes( 0 ); break;
|
|
|
|
case 1: m_footprint->SetAttributes( MOD_CMS ); break;
|
|
|
|
case 2: m_footprint->SetAttributes( MOD_VIRTUAL ); break;
|
|
|
|
default: wxFAIL;
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_footprint->SetPlacementCost90( m_CostRot90Ctrl->GetValue() );
|
|
|
|
m_footprint->SetPlacementCost180( m_CostRot180Ctrl->GetValue() );
|
|
|
|
|
|
|
|
// Now, set orientation. Must be done after other changes because rotation changes field
|
|
|
|
// positions on board (so that relative positions are held constant)
|
|
|
|
m_OrientValidator.TransferFromWindow();
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2016-04-10 12:59:23 +00:00
|
|
|
int orient = KiROUND( m_OrientValue * 10.0 );
|
2011-12-22 13:28:11 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
if( m_footprint->GetOrientation() != orient )
|
|
|
|
m_footprint->Rotate( m_footprint->GetPosition(), orient - m_footprint->GetOrientation() );
|
2010-05-03 15:24:54 +00:00
|
|
|
|
|
|
|
// Set component side, that also have effect on the fields positions on board
|
2012-01-22 17:20:22 +00:00
|
|
|
bool change_layer = false;
|
2018-08-15 13:29:53 +00:00
|
|
|
if( m_BoardSideCtrl->GetSelection() == 0 ) // layer req = COMPONENT
|
2010-05-03 15:24:54 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
if( m_footprint->GetLayer() == B_Cu )
|
2012-01-22 17:20:22 +00:00
|
|
|
change_layer = true;
|
2010-05-03 15:24:54 +00:00
|
|
|
}
|
2018-03-28 17:14:04 +00:00
|
|
|
else if( m_footprint->GetLayer() == F_Cu )
|
2012-01-22 17:20:22 +00:00
|
|
|
change_layer = true;
|
2010-05-03 15:24:54 +00:00
|
|
|
|
|
|
|
if( change_layer )
|
2018-03-28 17:14:04 +00:00
|
|
|
m_footprint->Flip( m_footprint->GetPosition() );
|
2016-08-05 19:30:23 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
std::list<MODULE_3D_SETTINGS>* draw3D = &m_footprint->Models();
|
2016-07-19 17:35:25 +00:00
|
|
|
draw3D->clear();
|
|
|
|
draw3D->insert( draw3D->end(), m_shapes3D_list.begin(), m_shapes3D_list.end() );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_footprint->CalculateBoundingBox();
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-06-22 13:05:11 +00:00
|
|
|
// This is a simple edit, we must create an undo entry
|
2018-09-27 20:09:00 +00:00
|
|
|
int mask = EDA_ITEM_ALL_FLAGS - ( SELECTED | HIGHLIGHTED | BRIGHTENED );
|
|
|
|
if( ( m_footprint->GetFlags() & mask ) == 0 ) // i.e. not edited, or moved
|
2016-06-20 13:46:58 +00:00
|
|
|
commit.Push( _( "Modify module properties" ) );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2016-04-10 12:59:23 +00:00
|
|
|
SetReturnCode( PRM_EDITOR_EDIT_OK );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
|
|
|
if( m_DC )
|
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
m_footprint->Draw( m_frame->GetCanvas(), m_DC, GR_OR );
|
|
|
|
m_frame->GetCanvas()->CrossHairOn( m_DC );
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
2016-04-10 12:59:23 +00:00
|
|
|
|
|
|
|
return true;
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
void DIALOG_FOOTPRINT_BOARD_EDITOR::OnAddField( wxCommandEvent& )
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2018-08-15 13:29:19 +00:00
|
|
|
if( !m_itemsGrid->CommitPendingChanges() )
|
|
|
|
return;
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
const BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
|
|
|
|
TEXTE_MODULE textMod( m_footprint );
|
|
|
|
|
|
|
|
// Set active layer if legal; otherwise copy layer from previous text item
|
|
|
|
if( LSET::AllTechMask().test( m_frame->GetActiveLayer() ) )
|
|
|
|
textMod.SetLayer( m_frame->GetActiveLayer() );
|
|
|
|
else
|
|
|
|
textMod.SetLayer( m_texts->at( m_texts->size() - 1 ).GetLayer() );
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
textMod.SetTextSize( dsnSettings.GetTextSize( textMod.GetLayer() ) );
|
|
|
|
textMod.SetThickness( dsnSettings.GetTextThickness( textMod.GetLayer() ) );
|
|
|
|
textMod.SetItalic( dsnSettings.GetTextItalic( textMod.GetLayer() ) );
|
|
|
|
textMod.SetKeepUpright( dsnSettings.GetTextUpright( textMod.GetLayer() ) );
|
2018-01-14 13:24:58 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_texts->push_back( textMod );
|
2018-01-14 13:24:58 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
// notify the grid
|
|
|
|
wxGridTableMessage msg( m_texts, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
|
|
|
|
m_itemsGrid->ProcessTableMessage( msg );
|
|
|
|
|
|
|
|
m_itemsGrid->SetFocus();
|
|
|
|
m_itemsGrid->MakeCellVisible( m_texts->size() - 1, 0 );
|
|
|
|
m_itemsGrid->SetGridCursor( m_texts->size() - 1, 0 );
|
|
|
|
|
|
|
|
m_itemsGrid->EnableCellEditControl( true );
|
|
|
|
m_itemsGrid->ShowCellEditControl();
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
void DIALOG_FOOTPRINT_BOARD_EDITOR::OnDeleteField( wxCommandEvent& )
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2018-08-15 13:29:19 +00:00
|
|
|
m_itemsGrid->CommitPendingChanges( true /* quiet mode */ );
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
int curRow = m_itemsGrid->GetGridCursorRow();
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2018-08-15 13:29:19 +00:00
|
|
|
if( curRow < 0 )
|
2018-03-28 17:14:04 +00:00
|
|
|
return;
|
2018-08-15 13:29:19 +00:00
|
|
|
else if( curRow < 2 )
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
|
|
|
DisplayError( nullptr, _( "Reference and value are mandatory." ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-15 13:29:19 +00:00
|
|
|
m_texts->erase( m_texts->begin() + curRow );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
// notify the grid
|
|
|
|
wxGridTableMessage msg( m_texts, wxGRIDTABLE_NOTIFY_ROWS_DELETED, curRow, 1 );
|
|
|
|
m_itemsGrid->ProcessTableMessage( msg );
|
2018-01-14 13:24:58 +00:00
|
|
|
|
2018-08-15 13:29:19 +00:00
|
|
|
if( m_itemsGrid->GetNumberRows() > 0 )
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
2018-08-15 13:29:19 +00:00
|
|
|
m_itemsGrid->MakeCellVisible( std::max( 0, curRow-1 ), m_itemsGrid->GetGridCursorCol() );
|
|
|
|
m_itemsGrid->SetGridCursor( std::max( 0, curRow-1 ), m_itemsGrid->GetGridCursorCol() );
|
2018-03-28 17:14:04 +00:00
|
|
|
}
|
2009-08-11 10:27:21 +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
|
|
|
|
2016-02-27 23:17:58 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
void DIALOG_FOOTPRINT_BOARD_EDITOR::Cfg3DPath( wxCommandEvent& )
|
2016-02-27 23:17:58 +00:00
|
|
|
{
|
2016-07-19 17:35:25 +00:00
|
|
|
if( S3D::Configure3DPaths( this, Prj().Get3DCacheManager()->GetResolver() ) )
|
2018-07-20 20:56:12 +00:00
|
|
|
m_PreviewPane->UpdateDummyModule();
|
2018-03-28 17:14:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_BOARD_EDITOR::adjustGridColumns( int aWidth )
|
|
|
|
{
|
|
|
|
// Account for scroll bars
|
|
|
|
int itemsWidth = aWidth - ( m_itemsGrid->GetSize().x - m_itemsGrid->GetClientSize().x );
|
|
|
|
int modelsWidth = aWidth - ( m_modelsGrid->GetSize().x - m_modelsGrid->GetClientSize().x );
|
|
|
|
|
|
|
|
itemsWidth -= m_itemsGrid->GetRowLabelSize();
|
|
|
|
|
|
|
|
for( int i = 1; i < m_itemsGrid->GetNumberCols(); i++ )
|
|
|
|
itemsWidth -= m_itemsGrid->GetColSize( i );
|
|
|
|
|
|
|
|
m_itemsGrid->SetColSize( 0, std::max( itemsWidth, 120 ) );
|
|
|
|
|
|
|
|
m_modelsGrid->SetColSize( 0, modelsWidth - m_modelsGrid->GetColSize( 1 ) - 5 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_BOARD_EDITOR::OnUpdateUI( wxUpdateUIEvent& )
|
|
|
|
{
|
|
|
|
if( !m_itemsGrid->IsCellEditControlShown() && !m_modelsGrid->IsCellEditControlShown() )
|
|
|
|
adjustGridColumns( m_itemsGrid->GetRect().GetWidth());
|
|
|
|
|
|
|
|
// Handle a grid error. This is delayed to OnUpdateUI so that we can change focus
|
|
|
|
// even when the original validation was triggered from a killFocus event, and so
|
|
|
|
// that the corresponding notebook page can be shown in the background when triggered
|
|
|
|
// from an OK.
|
|
|
|
if( m_delayedFocusRow >= 0 )
|
|
|
|
{
|
2018-10-13 23:06:41 +00:00
|
|
|
// We will re-enter this routine if an error dialog is displayed, so make sure we
|
|
|
|
// zero out our member variables first.
|
|
|
|
wxGrid* grid = m_delayedFocusGrid;
|
|
|
|
int row = m_delayedFocusRow;
|
|
|
|
int col = m_delayedFocusColumn;
|
|
|
|
wxString msg = m_delayedErrorMessage;
|
|
|
|
|
|
|
|
m_delayedFocusGrid = nullptr;
|
|
|
|
m_delayedFocusRow = -1;
|
|
|
|
m_delayedFocusColumn = -1;
|
|
|
|
m_delayedErrorMessage = wxEmptyString;
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
if( !m_delayedErrorMessage.IsEmpty() )
|
|
|
|
{
|
|
|
|
// Do not use DisplayErrorMessage(); it screws up window order on Mac
|
|
|
|
DisplayError( nullptr, msg );
|
|
|
|
}
|
|
|
|
|
2018-10-13 23:06:41 +00:00
|
|
|
grid->SetFocus();
|
|
|
|
grid->MakeCellVisible( row, col );
|
|
|
|
grid->SetGridCursor( row, col );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
2018-10-13 23:06:41 +00:00
|
|
|
grid->EnableCellEditControl( true );
|
|
|
|
grid->ShowCellEditControl();
|
2018-03-28 17:14:04 +00:00
|
|
|
|
2018-10-13 23:06:41 +00:00
|
|
|
if( grid == m_itemsGrid && row == 0 && col == 0 )
|
|
|
|
{
|
|
|
|
auto referenceEditor = grid->GetCellEditor( 0, 0 );
|
|
|
|
SelectReferenceNumber( dynamic_cast<wxTextEntry*>( referenceEditor->GetControl() ) );
|
|
|
|
referenceEditor->DecRef();
|
|
|
|
}
|
2018-03-28 17:14:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_BOARD_EDITOR::OnGridSize( wxSizeEvent& aEvent )
|
|
|
|
{
|
|
|
|
adjustGridColumns( aEvent.GetSize().GetX());
|
|
|
|
|
|
|
|
aEvent.Skip();
|
2016-02-27 23:17:58 +00:00
|
|
|
}
|