kicad/pcbnew/dialogs/dialog_edit_module_for_Boar...

726 lines
23 KiB
C++
Raw Normal View History

/**
* Module editor: Dialog for editing module properties in the pcb editor.
*/
2009-08-11 10:27:21 +00:00
2012-06-09 09:38:58 +00:00
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2015 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2004-2015 KiCad Developers, see change_log.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
*/
#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>
#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>
#include <gestfich.h>
#include <3d_struct.h>
#include <3d_viewer.h>
#include <wxPcbStruct.h>
#include <base_units.h>
#include <class_module.h>
#include <class_text_mod.h>
#include <validators.h>
#include <dialog_edit_module_for_BoardEditor.h>
#include <wildcards_and_files_ext.h>
2009-08-11 10:27:21 +00:00
size_t DIALOG_MODULE_BOARD_EDITOR::m_page = 0; // remember the last open page during session
2009-08-11 10:27:21 +00:00
DIALOG_MODULE_BOARD_EDITOR::DIALOG_MODULE_BOARD_EDITOR( PCB_EDIT_FRAME* aParent,
MODULE* aModule,
wxDC* aDC ) :
2009-08-11 10:27:21 +00:00
DIALOG_MODULE_BOARD_EDITOR_BASE( aParent )
{
m_Parent = aParent;
m_DC = aDC;
m_CurrentModule = aModule;
2009-08-11 10:27:21 +00:00
// Give an icon
wxIcon icon;
icon.CopyFromBitmap( KiBitmap( icon_modedit_xpm ) );
SetIcon( icon );
2009-08-11 10:27:21 +00:00
InitModeditProperties();
InitBoardProperties();
m_NoteBook->SetSelection( m_page );
m_sdbSizerStdButtonsOK->SetDefault();
2009-08-11 10:27:21 +00:00
GetSizer()->SetSizeHints( this );
Centre();
}
2009-08-11 10:27:21 +00:00
DIALOG_MODULE_BOARD_EDITOR::~DIALOG_MODULE_BOARD_EDITOR()
{
m_page = m_NoteBook->GetSelection();
2009-08-11 10:27:21 +00:00
for( unsigned ii = 0; ii < m_Shapes3D_list.size(); ii++ )
delete m_Shapes3D_list[ii];
m_Shapes3D_list.clear();
delete m_ReferenceCopy;
delete m_ValueCopy;
delete m_3D_Scale;
delete m_3D_Offset;
delete m_3D_Rotation;
}
// Creation of the panel properties of the module editor.
void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties()
2009-08-11 10:27:21 +00:00
{
PutValueInLocalUnits( *m_ModPositionX, m_CurrentModule->GetPosition().x );
m_XPosUnit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
2009-08-11 10:27:21 +00:00
PutValueInLocalUnits( *m_ModPositionY, m_CurrentModule->GetPosition().y );
m_YPosUnit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
2009-08-11 10:27:21 +00:00
m_LayerCtrl->SetSelection(
(m_CurrentModule->GetLayer() == B_Cu) ? 1 : 0 );
2009-08-11 10:27:21 +00:00
bool select = false;
2013-05-04 11:57:09 +00:00
switch( int( m_CurrentModule->GetOrientation() ) )
{
case 0:
m_OrientCtrl->SetSelection( 0 );
break;
case 900:
case -2700:
m_OrientCtrl->SetSelection( 1 );
break;
case -900:
case 2700:
m_OrientCtrl->SetSelection( 2 );
break;
case -1800:
case 1800:
m_OrientCtrl->SetSelection( 3 );
break;
default:
m_OrientCtrl->SetSelection( 4 );
select = true;
break;
}
2009-08-11 10:27:21 +00:00
wxString msg;
msg << m_CurrentModule->GetOrientation();
m_OrientValue->SetValue( msg );
m_OrientValue->Enable( select );
// Initialize dialog relative to masks clearances
m_NetClearanceUnits->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_SolderMaskMarginUnits->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_SolderPasteMarginUnits->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_CurrentModule->GetLocalClearance() );
PutValueInLocalUnits( *m_SolderMaskMarginCtrl, m_CurrentModule->GetLocalSolderMaskMargin() );
// These 2 parameters are usually < 0, so prepare entering a negative
// value, if current is 0
PutValueInLocalUnits( *m_SolderPasteMarginCtrl, m_CurrentModule->GetLocalSolderPasteMargin() );
2012-02-19 04:02:19 +00:00
if( m_CurrentModule->GetLocalSolderPasteMargin() == 0 )
m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) +
m_SolderPasteMarginCtrl->GetValue() );
// Add solder paste margin ration in per cent
// for the usual default value 0.0, display -0.0 (or -0,0 in some countries)
msg.Printf( wxT( "%f" ),
2012-02-19 04:02:19 +00:00
m_CurrentModule->GetLocalSolderPasteMarginRatio() * 100.0 );
2012-02-19 04:02:19 +00:00
if( m_CurrentModule->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 );
switch( m_CurrentModule->GetZoneConnection() )
{
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-11 10:27:21 +00:00
void DIALOG_MODULE_BOARD_EDITOR::OnCancelClick( wxCommandEvent& event )
2009-08-11 10:27:21 +00:00
{
EndModal( PRM_EDITOR_ABORT );
2009-08-11 10:27:21 +00:00
}
void DIALOG_MODULE_BOARD_EDITOR::GotoModuleEditor( wxCommandEvent& event )
{
2011-12-12 08:37:05 +00:00
if( m_CurrentModule->GetTimeStamp() == 0 ) // Module Editor needs a non null timestamp
2009-08-11 10:27:21 +00:00
{
2011-12-12 08:37:05 +00:00
m_CurrentModule->SetTimeStamp( GetNewTimeStamp() );
m_Parent->OnModify();
2009-08-11 10:27:21 +00:00
}
EndModal( PRM_EDITOR_WANT_MODEDIT );
2009-08-11 10:27:21 +00:00
}
void DIALOG_MODULE_BOARD_EDITOR::ExchangeModule( wxCommandEvent& event )
{
EndModal( PRM_EDITOR_WANT_EXCHANGE_FP );
2009-08-11 10:27:21 +00:00
}
void DIALOG_MODULE_BOARD_EDITOR::ModuleOrientEvent( wxCommandEvent& event )
{
switch( m_OrientCtrl->GetSelection() )
{
case 0:
m_OrientValue->Enable( false );
2009-08-11 10:27:21 +00:00
m_OrientValue->SetValue( wxT( "0" ) );
break;
case 1:
m_OrientValue->Enable( false );
2009-08-11 10:27:21 +00:00
m_OrientValue->SetValue( wxT( "900" ) );
break;
case 2:
m_OrientValue->Enable( false );
2009-08-11 10:27:21 +00:00
m_OrientValue->SetValue( wxT( "2700" ) );
break;
case 3:
m_OrientValue->Enable( false );
2009-08-11 10:27:21 +00:00
m_OrientValue->SetValue( wxT( "1800" ) );
break;
default:
m_OrientValue->Enable( true );
2009-08-11 10:27:21 +00:00
break;
}
}
void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
{
wxString default_path;
wxGetEnv( KISYS3DMOD, &default_path );
#ifdef __WINDOWS__
default_path.Replace( wxT( "/" ), wxT( "\\" ) );
#endif
m_textCtrl3DDefaultPath->SetValue( default_path );
2009-08-11 10:27:21 +00:00
m_LastSelected3DShapeIndex = -1;
// Init 3D shape list
S3D_MASTER* draw3D = m_CurrentModule->Models();
2009-08-11 10:27:21 +00:00
while( draw3D )
{
if( !draw3D->GetShape3DName().IsEmpty() )
{
S3D_MASTER* draw3DCopy = new S3D_MASTER( NULL );
draw3DCopy->Copy( draw3D );
m_Shapes3D_list.push_back( draw3DCopy );
m_3D_ShapeNameListBox->Append( draw3DCopy->GetShape3DName() );
}
2009-08-11 10:27:21 +00:00
draw3D = (S3D_MASTER*) draw3D->Next();
}
m_ReferenceCopy = new TEXTE_MODULE( NULL );
m_ValueCopy = new TEXTE_MODULE( NULL );
m_ReferenceCopy->Copy( &m_CurrentModule->Reference() );
m_ValueCopy->Copy( &m_CurrentModule->Value() );
m_ReferenceCtrl->SetValue( m_ReferenceCopy->GetText() );
m_ValueCtrl->SetValue( m_ValueCopy->GetText() );
2009-08-11 10:27:21 +00:00
// Shows the footprint's schematic path.
m_textCtrlSheetPath->SetValue( m_CurrentModule->GetPath() );
m_AttributsCtrl->SetItemToolTip( 0,
_( "Use this attribute for most non SMD components\n"
"Components with this option are not put in the footprint position list file" ) );
2009-08-11 10:27:21 +00:00
m_AttributsCtrl->SetItemToolTip( 1,
_( "Use this attribute for SMD components.\n"
"Only components with this option are put in the footprint position list file" ) );
2009-08-11 10:27:21 +00:00
m_AttributsCtrl->SetItemToolTip( 2,
_( "Use this attribute for \"virtual\" components drawn on board\n"
"(like a old ISA PC bus connector)" ) );
2009-08-11 10:27:21 +00:00
// Controls on right side of the dialog
switch( m_CurrentModule->GetAttributes() & 255 )
2009-08-11 10:27:21 +00:00
{
case 0:
m_AttributsCtrl->SetSelection( 0 );
break;
case MOD_CMS:
m_AttributsCtrl->SetSelection( 1 );
break;
case MOD_VIRTUAL:
m_AttributsCtrl->SetSelection( 2 );
break;
default:
m_AttributsCtrl->SetSelection( 0 );
break;
}
2015-02-18 16:53:46 +00:00
if( m_CurrentModule->IsLocked() )
m_AutoPlaceCtrl->SetSelection( 2 );
2015-02-18 16:53:46 +00:00
else if( m_CurrentModule->PadsLocked() )
m_AutoPlaceCtrl->SetSelection( 1 );
else
m_AutoPlaceCtrl->SetSelection( 0 );
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." ) );
m_CostRot90Ctrl->SetValue( m_CurrentModule->GetPlacementCost90() );
2009-08-11 10:27:21 +00:00
m_CostRot180Ctrl->SetValue( m_CurrentModule->GetPlacementCost180() );
2009-08-11 10:27:21 +00:00
// Initialize 3D parameters
m_3D_Scale = new S3DPOINT_VALUE_CTRL( m_Panel3D, m_bSizerShapeScale );
m_3D_Offset = new S3DPOINT_VALUE_CTRL( m_Panel3D, m_bSizerShapeOffset );
m_3D_Rotation = new S3DPOINT_VALUE_CTRL( m_Panel3D, m_bSizerShapeRotation );
// if m_3D_ShapeNameListBox is not empty, preselect first 3D shape
if( m_3D_ShapeNameListBox->GetCount() > 0 )
{
m_LastSelected3DShapeIndex = 0;
m_3D_ShapeNameListBox->SetSelection( m_LastSelected3DShapeIndex );
Transfert3DValuesToDisplay( m_Shapes3D_list[m_LastSelected3DShapeIndex] );
}
// We have modified the UI, so call Fit() for m_Panel3D
// to be sure the m_Panel3D sizers are initiliazed before opening the dialog
m_Panel3D->GetSizer()->Fit( m_Panel3D );
2009-08-11 10:27:21 +00:00
}
/* Initialize 3D info displayed in dialog box from values in aStruct3DSource
*/
void DIALOG_MODULE_BOARD_EDITOR::Transfert3DValuesToDisplay(
S3D_MASTER* aStruct3DSource )
2009-08-11 10:27:21 +00:00
{
if( aStruct3DSource )
{
m_3D_Scale->SetValue( aStruct3DSource->m_MatScale );
m_3D_Offset->SetValue( aStruct3DSource->m_MatPosition );
m_3D_Rotation->SetValue( aStruct3DSource->m_MatRotation );
}
else
{
S3DPOINT dummy_vertex( 1.0, 1.0, 1.0 );
2009-08-11 10:27:21 +00:00
m_3D_Scale->SetValue( dummy_vertex );
}
}
2009-08-11 10:27:21 +00:00
/** Copy 3D info displayed in dialog box to values in a item in m_Shapes3D_list
* @param aIndexSelection = item index in m_Shapes3D_list
*/
void DIALOG_MODULE_BOARD_EDITOR::TransfertDisplayTo3DValues(
int aIndexSelection )
2009-08-11 10:27:21 +00:00
{
if( aIndexSelection >= (int) m_Shapes3D_list.size() )
2009-08-11 10:27:21 +00:00
return;
S3D_MASTER* struct3DDest = m_Shapes3D_list[aIndexSelection];
2009-08-11 10:27:21 +00:00
struct3DDest->m_MatScale = m_3D_Scale->GetValue();
struct3DDest->m_MatRotation = m_3D_Rotation->GetValue();
struct3DDest->m_MatPosition = m_3D_Offset->GetValue();
}
void DIALOG_MODULE_BOARD_EDITOR::On3DShapeNameSelected( wxCommandEvent& event )
2009-08-11 10:27:21 +00:00
{
if( m_LastSelected3DShapeIndex >= 0 )
TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex );
m_LastSelected3DShapeIndex = m_3D_ShapeNameListBox->GetSelection();
if( m_LastSelected3DShapeIndex < 0 ) // happens under wxGTK when
// deleting an item in
// m_3D_ShapeNameListBox wxListBox
return;
if( m_LastSelected3DShapeIndex >= (int) m_Shapes3D_list.size() )
{
wxMessageBox( wxT( "On3DShapeNameSelected() error" ) );
m_LastSelected3DShapeIndex = -1;
return;
}
2009-08-11 10:27:21 +00:00
Transfert3DValuesToDisplay( m_Shapes3D_list[m_LastSelected3DShapeIndex] );
}
void DIALOG_MODULE_BOARD_EDITOR::Remove3DShape( wxCommandEvent& event )
2009-08-11 10:27:21 +00:00
{
if( m_LastSelected3DShapeIndex >= 0 )
TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex );
int ii = m_3D_ShapeNameListBox->GetSelection();
if( ii < 0 )
return;
m_Shapes3D_list.erase( m_Shapes3D_list.begin() + ii );
m_3D_ShapeNameListBox->Delete( ii );
2009-08-11 10:27:21 +00:00
if( m_3D_ShapeNameListBox->GetCount() == 0 )
2009-08-11 10:27:21 +00:00
Transfert3DValuesToDisplay( NULL );
else
{
m_LastSelected3DShapeIndex = 0;
m_3D_ShapeNameListBox->SetSelection( m_LastSelected3DShapeIndex );
Transfert3DValuesToDisplay(
m_Shapes3D_list[m_LastSelected3DShapeIndex] );
2009-08-11 10:27:21 +00:00
}
}
void DIALOG_MODULE_BOARD_EDITOR::Edit3DShapeFileName()
{
int idx = m_3D_ShapeNameListBox->GetSelection();
if( idx < 0 )
return;
// Edit filename
wxString filename = m_3D_ShapeNameListBox->GetStringSelection();
wxTextEntryDialog dlg( this, wxEmptyString, wxEmptyString, filename );
dlg.SetTextValidator( FILE_NAME_WITH_PATH_CHAR_VALIDATOR( &filename ) );
if( dlg.ShowModal() != wxID_OK || filename.IsEmpty() )
return; //Aborted by user
#ifdef __WINDOWS__
// In Kicad files, filenames and paths are stored using Unix notation
// So be sure the unix notation is still used
filename.Replace( wxT( "\\" ), wxT( "/" ) );
#endif
m_3D_ShapeNameListBox->SetString( idx, filename );
S3D_MASTER* new3DShape = new S3D_MASTER( NULL );
new3DShape->SetShape3DName( filename );
delete m_Shapes3D_list[idx];
m_Shapes3D_list[idx] = new3DShape;
}
2009-08-11 10:27:21 +00:00
void DIALOG_MODULE_BOARD_EDITOR::BrowseAndAdd3DShapeFile()
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
PROJECT& prj = Prj();
// here, the KISYS3DMOD default path for 3D shape files is expected
// to be already defined (when starting Pcbnew, it is defined
// from the user defined env variable, or set to a default value)
wxFileName fn( wxGetenv( KISYS3DMOD ), wxEmptyString );
wxString default3DPath = fn.GetPathWithSep();
* 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 initialpath = prj.GetRString( PROJECT::VIEWER_3D_PATH );
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
if( !initialpath )
initialpath = default3DPath;
* 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 fileFilters = wxGetTranslation( Shapes3DFileWildcard );
fileFilters += wxChar( '|' );
fileFilters += wxGetTranslation( IDF3DFileWildcard );
wxString filename = EDA_FILE_SELECTOR( _( "3D Shape:" ), initialpath,
wxEmptyString, wxEmptyString,
fileFilters, this, wxFD_OPEN, true );
if( filename.IsEmpty() )
2009-08-11 10:27:21 +00:00
return;
fn = filename;
* 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
prj.SetRString( PROJECT::VIEWER_3D_PATH, fn.GetPath() );
2009-08-11 10:27:21 +00:00
/* If the file path is already in the 3D shape file default path
* just add the file name relative to this path to the list.
* Otherwise, add the file name with a full or relative path.
* The relative path, when possible, is preferable
* because it preserve use of default path, when the path is a sub path of this path
2009-08-11 10:27:21 +00:00
*/
wxString rootpath = filename.SubString( 0, default3DPath.Length()-1 );
bool useRelPath = rootpath.IsSameAs( default3DPath, wxFileName::IsCaseSensitive() );
if( useRelPath )
fn.MakeRelativeTo( default3DPath );
else // Absolute path given, not a subpath of the default path,
// therefore ask if the user wants a relative (to the default path) one
{
wxString msg;
msg.Printf( _( "Use a path relative to '%s'?" ), GetChars( default3DPath ) );
int diag = wxMessageBox( msg, _( "Path type" ),
wxYES_NO | wxICON_QUESTION, this );
if( diag == wxYES ) // Make it relative to the default 3D path
fn.MakeRelativeTo( default3DPath );
}
filename = fn.GetFullPath();
S3D_MASTER* new3DShape = new S3D_MASTER( NULL );
* 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
#ifdef __WINDOWS__
// In Kicad files, filenames and paths are stored using Unix notation
filename.Replace( wxT( "\\" ), wxT( "/" ) );
#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
new3DShape->SetShape3DName( filename );
2009-08-11 10:27:21 +00:00
m_Shapes3D_list.push_back( new3DShape );
m_3D_ShapeNameListBox->Append( filename );
2009-08-11 10:27:21 +00:00
if( m_LastSelected3DShapeIndex >= 0 )
TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex );
m_LastSelected3DShapeIndex = m_3D_ShapeNameListBox->GetCount() - 1;
m_3D_ShapeNameListBox->SetSelection( m_LastSelected3DShapeIndex );
2009-08-11 10:27:21 +00:00
Transfert3DValuesToDisplay( m_Shapes3D_list[m_LastSelected3DShapeIndex] );
}
void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event )
{
wxPoint modpos;
wxString msg;
2009-08-11 10:27:21 +00:00
if( m_CurrentModule->GetFlags() == 0 ) // this is a simple edition, we
// must create an undo entry
2009-08-11 10:27:21 +00:00
m_Parent->SaveCopyInUndoList( m_CurrentModule, UR_CHANGED );
if( m_DC )
{
m_Parent->GetCanvas()->CrossHairOff( m_DC );
m_CurrentModule->Draw( m_Parent->GetCanvas(), m_DC, GR_XOR );
2009-08-11 10:27:21 +00:00
}
2012-04-06 18:03:16 +00:00
// Init Fields (should be first, because they can be moved or/and flipped later):
m_CurrentModule->Reference().Copy( m_ReferenceCopy );
m_CurrentModule->Value().Copy( m_ValueCopy );
2012-04-06 18:03:16 +00:00
// Initialize masks clearances
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
m_CurrentModule->SetLocalClearance( ValueFromTextCtrl( *m_NetClearanceValueCtrl ) );
m_CurrentModule->SetLocalSolderMaskMargin( ValueFromTextCtrl( *m_SolderMaskMarginCtrl ) );
m_CurrentModule->SetLocalSolderPasteMargin( ValueFromTextCtrl( *m_SolderPasteMarginCtrl ) );
2012-02-19 04:02:19 +00:00
double dtmp = 0.0;
msg = m_SolderPasteMarginRatioCtrl->GetValue();
msg.ToDouble( &dtmp );
// 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;
2012-02-19 04:02:19 +00:00
m_CurrentModule->SetLocalSolderPasteMarginRatio( dtmp / 100 );
switch( m_ZoneConnectionChoice->GetSelection() )
{
default:
case 0:
m_CurrentModule->SetZoneConnection( PAD_ZONE_CONN_INHERITED );
break;
case 1:
m_CurrentModule->SetZoneConnection( PAD_ZONE_CONN_FULL );
break;
case 2:
m_CurrentModule->SetZoneConnection( PAD_ZONE_CONN_THERMAL );
break;
case 3:
m_CurrentModule->SetZoneConnection( PAD_ZONE_CONN_NONE );
break;
}
2009-08-11 10:27:21 +00:00
// Set Module Position
* 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
modpos.x = ValueFromTextCtrl( *m_ModPositionX );
modpos.y = ValueFromTextCtrl( *m_ModPositionY );
m_CurrentModule->SetPosition( modpos );
m_CurrentModule->SetLocked( m_AutoPlaceCtrl->GetSelection() == 2 );
m_CurrentModule->SetPadsLocked( m_AutoPlaceCtrl->GetSelection() == 1 );
2009-08-11 10:27:21 +00:00
switch( m_AttributsCtrl->GetSelection() )
{
case 0:
m_CurrentModule->SetAttributes( 0 );
2009-08-11 10:27:21 +00:00
break;
case 1:
m_CurrentModule->SetAttributes( MOD_CMS );
2009-08-11 10:27:21 +00:00
break;
case 2:
m_CurrentModule->SetAttributes( MOD_VIRTUAL );
2009-08-11 10:27:21 +00:00
break;
}
m_CurrentModule->SetPlacementCost90( m_CostRot90Ctrl->GetValue() );
m_CurrentModule->SetPlacementCost180( m_CostRot180Ctrl->GetValue() );
2009-08-11 10:27:21 +00:00
/* Now, set orientation. must be made after others changes,
* because rotation changes fields positions on board according to the new orientation
* (relative positions are not modified)
*/
long orient = 0;
msg = m_OrientValue->GetValue();
msg.ToLong( &orient );
if( m_CurrentModule->GetOrientation() != orient )
m_CurrentModule->Rotate( m_CurrentModule->GetPosition(),
orient - m_CurrentModule->GetOrientation() );
// Set component side, that also have effect on the fields positions on board
bool change_layer = false;
if( m_LayerCtrl->GetSelection() == 0 ) // layer req = COMPONENT
{
if( m_CurrentModule->GetLayer() == B_Cu )
change_layer = true;
}
else if( m_CurrentModule->GetLayer() == F_Cu )
change_layer = true;
if( change_layer )
m_CurrentModule->Flip( m_CurrentModule->GetPosition() );
// Update 3D shape list
* 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
int ii = m_3D_ShapeNameListBox->GetSelection();
if( ii >= 0 )
2009-08-11 10:27:21 +00:00
TransfertDisplayTo3DValues( ii );
S3D_MASTER* draw3D = m_CurrentModule->Models();
2009-08-11 10:27:21 +00:00
for( unsigned ii = 0; ii < m_Shapes3D_list.size(); ii++ )
{
S3D_MASTER* draw3DCopy = m_Shapes3D_list[ii];
if( draw3DCopy->GetShape3DName().IsEmpty() )
2009-08-11 10:27:21 +00:00
continue;
2009-08-11 10:27:21 +00:00
if( draw3D == NULL )
{
draw3D = new S3D_MASTER( draw3D );
m_CurrentModule->Models().Append( draw3D );
2009-08-11 10:27:21 +00:00
}
draw3D->SetShape3DName( draw3DCopy->GetShape3DName() );
2009-08-11 10:27:21 +00:00
draw3D->m_MatScale = draw3DCopy->m_MatScale;
draw3D->m_MatRotation = draw3DCopy->m_MatRotation;
draw3D->m_MatPosition = draw3DCopy->m_MatPosition;
draw3D = draw3D->Next();
}
// Remove old extra 3D shapes
S3D_MASTER* nextdraw3D;
2009-08-11 10:27:21 +00:00
for( ; draw3D != NULL; draw3D = nextdraw3D )
{
nextdraw3D = (S3D_MASTER*) draw3D->Next();
delete m_CurrentModule->Models().Remove( draw3D );
2009-08-11 10:27:21 +00:00
}
// Fill shape list with one void entry, if no entry
if( m_CurrentModule->Models() == NULL )
m_CurrentModule->Models().PushBack( new S3D_MASTER( m_CurrentModule ) );
2009-08-11 10:27:21 +00:00
m_CurrentModule->CalculateBoundingBox();
2009-08-11 10:27:21 +00:00
m_Parent->OnModify();
2009-08-11 10:27:21 +00:00
EndModal( PRM_EDITOR_EDIT_OK );
2009-08-11 10:27:21 +00:00
if( m_DC )
{
m_CurrentModule->Draw( m_Parent->GetCanvas(), m_DC, GR_OR );
m_Parent->GetCanvas()->CrossHairOn( m_DC );
2009-08-11 10:27:21 +00:00
}
}
void DIALOG_MODULE_BOARD_EDITOR::OnEditReference( wxCommandEvent& event )
2009-08-11 10:27:21 +00:00
{
wxPoint tmp = m_Parent->GetCrossHairPosition();
m_Parent->SetCrossHairPosition( m_ReferenceCopy->GetTextPosition() );
m_ReferenceCopy->SetParent( m_CurrentModule );
2009-08-11 10:27:21 +00:00
m_Parent->InstallTextModOptionsFrame( m_ReferenceCopy, NULL );
m_Parent->SetCrossHairPosition( tmp );
m_ReferenceCtrl->SetValue( m_ReferenceCopy->GetText() );
2009-08-11 10:27:21 +00:00
}
void DIALOG_MODULE_BOARD_EDITOR::OnEditValue( wxCommandEvent& event )
2009-08-11 10:27:21 +00:00
{
wxPoint tmp = m_Parent->GetCrossHairPosition();
m_Parent->SetCrossHairPosition( m_ValueCopy->GetTextPosition() );
m_ValueCopy->SetParent( m_CurrentModule );
2009-08-11 10:27:21 +00:00
m_Parent->InstallTextModOptionsFrame( m_ValueCopy, NULL );
m_Parent->SetCrossHairPosition( tmp );
m_ValueCtrl->SetValue( m_ValueCopy->GetText() );
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