Removed unnecessary *.orig files for dialogs
This commit is contained in:
parent
497b2a9442
commit
02c404ab10
|
@ -1,848 +0,0 @@
|
|||
/**
|
||||
* Module editor: Dialog for editing module properties in the pcb editor.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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-2016 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* 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>
|
||||
#include <kiface_i.h>
|
||||
#include <gr_basic.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <confirm.h>
|
||||
#include <pcbnew.h>
|
||||
#include <pgm_base.h>
|
||||
#include <gestfich.h>
|
||||
#include <3d_struct.h>
|
||||
#include <3d_viewer.h>
|
||||
#include <wxPcbStruct.h>
|
||||
#include <base_units.h>
|
||||
#include <project.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>
|
||||
#include "3d_cache/dialogs/panel_prev_model.h"
|
||||
#include "3d_cache/dialogs/3d_cache_dialogs.h"
|
||||
#include "3d_cache/3d_cache.h"
|
||||
#include "3d_cache/3d_filename_resolver.h"
|
||||
|
||||
size_t DIALOG_MODULE_BOARD_EDITOR::m_page = 0; // remember the last open page during session
|
||||
|
||||
|
||||
DIALOG_MODULE_BOARD_EDITOR::DIALOG_MODULE_BOARD_EDITOR( PCB_EDIT_FRAME* aParent,
|
||||
MODULE* aModule,
|
||||
wxDC* aDC ) :
|
||||
DIALOG_MODULE_BOARD_EDITOR_BASE( aParent ),
|
||||
m_OrientValidator( 1, &m_OrientValue )
|
||||
{
|
||||
m_Parent = aParent;
|
||||
m_DC = aDC;
|
||||
m_CurrentModule = aModule;
|
||||
|
||||
// Give an icon
|
||||
wxIcon icon;
|
||||
icon.CopyFromBitmap( KiBitmap( icon_modedit_xpm ) );
|
||||
SetIcon( icon );
|
||||
|
||||
m_OrientValidator.SetRange( -360.0, 360.0 );
|
||||
m_OrientValueCtrl->SetValidator( m_OrientValidator );
|
||||
m_OrientValidator.SetWindow( m_OrientValueCtrl );
|
||||
|
||||
aParent->Prj().Get3DCacheManager()->GetResolver()->SetProgramBase( &Pgm() );
|
||||
m_PreviewPane = new PANEL_PREV_3D( m_Panel3D, aParent->Prj().Get3DCacheManager() );
|
||||
bLowerSizer3D->Add( m_PreviewPane, 1, wxEXPAND, 5 );
|
||||
|
||||
m_NoteBook->SetSelection( m_page );
|
||||
m_sdbSizerStdButtonsOK->SetDefault();
|
||||
|
||||
m_ReferenceCopy = NULL;
|
||||
m_ValueCopy = NULL;
|
||||
m_LastSelected3DShapeIndex = 0;
|
||||
m_OrientValue = 0;
|
||||
|
||||
Layout();
|
||||
|
||||
FixOSXCancelButtonIssue();
|
||||
}
|
||||
|
||||
|
||||
|
||||
DIALOG_MODULE_BOARD_EDITOR::~DIALOG_MODULE_BOARD_EDITOR()
|
||||
{
|
||||
for( unsigned ii = 0; ii < m_Shapes3D_list.size(); ii++ )
|
||||
delete m_Shapes3D_list[ii];
|
||||
|
||||
m_Shapes3D_list.clear();
|
||||
|
||||
// free the memory used by all models, otherwise models which were
|
||||
// browsed but not used would consume memory
|
||||
Prj().Get3DCacheManager()->FlushCache( false );
|
||||
|
||||
// the GL canvas has to be visible before it is destroyed
|
||||
m_page = m_NoteBook->GetSelection();
|
||||
m_NoteBook->SetSelection( 1 );
|
||||
delete m_PreviewPane;
|
||||
m_PreviewPane = NULL; // just in case, to avoid double-free
|
||||
|
||||
delete m_ReferenceCopy;
|
||||
delete m_ValueCopy;
|
||||
}
|
||||
|
||||
|
||||
// Creation of the panel properties of the module editor.
|
||||
void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties()
|
||||
{
|
||||
PutValueInLocalUnits( *m_ModPositionX, m_CurrentModule->GetPosition().x );
|
||||
m_XPosUnit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
|
||||
|
||||
PutValueInLocalUnits( *m_ModPositionY, m_CurrentModule->GetPosition().y );
|
||||
m_YPosUnit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
|
||||
|
||||
m_LayerCtrl->SetSelection(
|
||||
(m_CurrentModule->GetLayer() == B_Cu) ? 1 : 0 );
|
||||
|
||||
bool custom_orientation = false;
|
||||
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 );
|
||||
custom_orientation = true;
|
||||
break;
|
||||
}
|
||||
|
||||
m_OrientValueCtrl->Enable( custom_orientation );
|
||||
m_OrientValue = m_CurrentModule->GetOrientation() / 10.0;
|
||||
m_OrientValidator.TransferToWindow();
|
||||
|
||||
// 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() );
|
||||
|
||||
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)
|
||||
wxString msg;
|
||||
msg.Printf( wxT( "%f" ),
|
||||
m_CurrentModule->GetLocalSolderPasteMarginRatio() * 100.0 );
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_BOARD_EDITOR::GotoModuleEditor( wxCommandEvent& event )
|
||||
{
|
||||
if( m_CurrentModule->GetTimeStamp() == 0 ) // Module Editor needs a non null timestamp
|
||||
{
|
||||
m_CurrentModule->SetTimeStamp( GetNewTimeStamp() );
|
||||
m_Parent->OnModify();
|
||||
}
|
||||
|
||||
EndModal( PRM_EDITOR_WANT_MODEDIT );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_BOARD_EDITOR::ExchangeModule( wxCommandEvent& event )
|
||||
{
|
||||
EndModal( PRM_EDITOR_WANT_EXCHANGE_FP );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_BOARD_EDITOR::ModuleOrientEvent( wxCommandEvent& event )
|
||||
{
|
||||
bool custom_orientation = false;
|
||||
|
||||
switch( m_OrientCtrl->GetSelection() )
|
||||
{
|
||||
case 0:
|
||||
m_OrientValue = 0.0;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
m_OrientValue = 90.0;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
m_OrientValue = 270.0;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
m_OrientValue = 180.0;
|
||||
break;
|
||||
|
||||
default:
|
||||
custom_orientation = true;
|
||||
break;
|
||||
}
|
||||
|
||||
m_OrientValidator.TransferToWindow();
|
||||
m_OrientValueCtrl->Enable( custom_orientation );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
|
||||
{
|
||||
wxString default_path;
|
||||
wxGetEnv( KISYS3DMOD, &default_path );
|
||||
#ifdef __WINDOWS__
|
||||
default_path.Replace( wxT( "/" ), wxT( "\\" ) );
|
||||
#endif
|
||||
|
||||
m_LastSelected3DShapeIndex = -1;
|
||||
|
||||
// Init 3D shape list
|
||||
m_3D_ShapeNameListBox->Clear();
|
||||
S3D_MASTER* draw3D = m_CurrentModule->Models();
|
||||
wxString origPath;
|
||||
wxString alias;
|
||||
wxString shortPath;
|
||||
S3D_FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver();
|
||||
|
||||
while( draw3D )
|
||||
{
|
||||
if( !draw3D->GetShape3DName().IsEmpty() )
|
||||
{
|
||||
S3D_MASTER* draw3DCopy = new S3D_MASTER( NULL );
|
||||
draw3DCopy->Copy( draw3D );
|
||||
m_Shapes3D_list.push_back( draw3DCopy );
|
||||
origPath = draw3DCopy->GetShape3DName();
|
||||
|
||||
if( res && res->SplitAlias( origPath, alias, shortPath ) )
|
||||
{
|
||||
origPath = alias;
|
||||
origPath.append( wxT( ":" ) );
|
||||
origPath.append( shortPath );
|
||||
}
|
||||
|
||||
m_3D_ShapeNameListBox->Append( origPath );
|
||||
}
|
||||
|
||||
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() );
|
||||
|
||||
// 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" ) );
|
||||
m_AttributsCtrl->SetItemToolTip( 1,
|
||||
_( "Use this attribute for SMD components.\n"
|
||||
"Only components with this option are put in the footprint position list file" ) );
|
||||
m_AttributsCtrl->SetItemToolTip( 2,
|
||||
_( "Use this attribute for \"virtual\" components drawn on board\n"
|
||||
"(like a old ISA PC bus connector)" ) );
|
||||
|
||||
// Controls on right side of the dialog
|
||||
switch( m_CurrentModule->GetAttributes() & 255 )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
if( m_CurrentModule->IsLocked() )
|
||||
m_AutoPlaceCtrl->SetSelection( 2 );
|
||||
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() );
|
||||
|
||||
m_CostRot180Ctrl->SetValue( m_CurrentModule->GetPlacementCost180() );
|
||||
|
||||
// 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] );
|
||||
}
|
||||
else
|
||||
{
|
||||
S3D_INFO params;
|
||||
params.scale.x = 1.0;
|
||||
params.scale.y = 1.0;
|
||||
params.scale.z = 1.0;
|
||||
m_PreviewPane->SetModelData( ¶ms );
|
||||
}
|
||||
|
||||
// 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 );
|
||||
}
|
||||
|
||||
|
||||
/* Initialize 3D info displayed in dialog box from values in aStruct3DSource
|
||||
*/
|
||||
void DIALOG_MODULE_BOARD_EDITOR::Transfert3DValuesToDisplay(
|
||||
S3D_MASTER* aStruct3DSource )
|
||||
{
|
||||
S3D_INFO params;
|
||||
|
||||
if( aStruct3DSource )
|
||||
{
|
||||
params.filename = aStruct3DSource->GetShape3DName();
|
||||
params.scale.x = aStruct3DSource->m_MatScale.x;
|
||||
params.scale.y = aStruct3DSource->m_MatScale.y;
|
||||
params.scale.z = aStruct3DSource->m_MatScale.z;
|
||||
|
||||
params.offset.x = aStruct3DSource->m_MatPosition.x;
|
||||
params.offset.y = aStruct3DSource->m_MatPosition.y;
|
||||
params.offset.z = aStruct3DSource->m_MatPosition.z;
|
||||
|
||||
params.rotation.x = aStruct3DSource->m_MatRotation.x;
|
||||
params.rotation.y = aStruct3DSource->m_MatRotation.y;
|
||||
params.rotation.z = aStruct3DSource->m_MatRotation.z;
|
||||
}
|
||||
else
|
||||
{
|
||||
params.scale.x = 1.0;
|
||||
params.scale.y = 1.0;
|
||||
params.scale.z = 1.0;
|
||||
|
||||
params.offset.x = 0.0;
|
||||
params.offset.y = 0.0;
|
||||
params.offset.z = 0.0;
|
||||
|
||||
params.rotation = params.offset;
|
||||
}
|
||||
|
||||
m_PreviewPane->SetModelData( ¶ms );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/** 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 )
|
||||
{
|
||||
if( aIndexSelection >= (int) m_Shapes3D_list.size() )
|
||||
return;
|
||||
|
||||
S3D_MASTER* struct3DDest = m_Shapes3D_list[aIndexSelection];
|
||||
S3D_INFO params;
|
||||
m_PreviewPane->GetModelData( ¶ms );
|
||||
|
||||
struct3DDest->m_MatScale.x = params.scale.x;
|
||||
struct3DDest->m_MatScale.y = params.scale.y;
|
||||
struct3DDest->m_MatScale.z = params.scale.z;
|
||||
|
||||
struct3DDest->m_MatRotation.x = params.rotation.x;
|
||||
struct3DDest->m_MatRotation.y = params.rotation.y;
|
||||
struct3DDest->m_MatRotation.z = params.rotation.z;
|
||||
|
||||
struct3DDest->m_MatPosition.x = params.offset.x;
|
||||
struct3DDest->m_MatPosition.y = params.offset.y;
|
||||
struct3DDest->m_MatPosition.z = params.offset.z;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_BOARD_EDITOR::On3DShapeNameSelected( wxCommandEvent& event )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
Transfert3DValuesToDisplay( m_Shapes3D_list[m_LastSelected3DShapeIndex] );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DIALOG_MODULE_BOARD_EDITOR::Remove3DShape( wxCommandEvent& event )
|
||||
{
|
||||
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 );
|
||||
|
||||
if( m_3D_ShapeNameListBox->GetCount() == 0 )
|
||||
Transfert3DValuesToDisplay( NULL );
|
||||
else
|
||||
{
|
||||
if( ii > 0 )
|
||||
m_LastSelected3DShapeIndex = ii - 1;
|
||||
else
|
||||
m_LastSelected3DShapeIndex = 0;
|
||||
|
||||
m_3D_ShapeNameListBox->SetSelection( m_LastSelected3DShapeIndex );
|
||||
Transfert3DValuesToDisplay(
|
||||
m_Shapes3D_list[m_LastSelected3DShapeIndex] );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_BOARD_EDITOR::Edit3DShapeFileName()
|
||||
{
|
||||
int idx = m_3D_ShapeNameListBox->GetSelection();
|
||||
|
||||
if( idx < 0 )
|
||||
return;
|
||||
|
||||
// ensure any updated parameters are not discarded
|
||||
TransfertDisplayTo3DValues( idx );
|
||||
|
||||
// Edit filename
|
||||
wxString filename = m_3D_ShapeNameListBox->GetStringSelection();
|
||||
wxTextEntryDialog dlg( this, wxEmptyString, wxEmptyString, filename );
|
||||
|
||||
bool hasAlias;
|
||||
S3D_FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver();
|
||||
|
||||
if( dlg.ShowModal() != wxID_OK )
|
||||
return;
|
||||
|
||||
filename = dlg.GetValue();
|
||||
|
||||
if( filename.empty() )
|
||||
return;
|
||||
|
||||
if( !res->ValidateFileName( filename, hasAlias ) )
|
||||
{
|
||||
wxString msg = _( "Invalid filename: " );
|
||||
msg.append( filename );
|
||||
wxMessageBox( msg, _T( "Edit 3D file name" ) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_3D_ShapeNameListBox->SetString( idx, filename );
|
||||
|
||||
// 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
|
||||
|
||||
S3D_MASTER* new3DShape = new S3D_MASTER( NULL );
|
||||
new3DShape->SetShape3DName( filename );
|
||||
new3DShape->m_MatPosition = m_Shapes3D_list[idx]->m_MatPosition;
|
||||
new3DShape->m_MatRotation = m_Shapes3D_list[idx]->m_MatRotation;
|
||||
new3DShape->m_MatScale = m_Shapes3D_list[idx]->m_MatScale;
|
||||
delete m_Shapes3D_list[idx];
|
||||
m_Shapes3D_list[idx] = new3DShape;
|
||||
|
||||
Transfert3DValuesToDisplay( m_Shapes3D_list[idx] );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_BOARD_EDITOR::BrowseAndAdd3DShapeFile()
|
||||
{
|
||||
PROJECT& prj = Prj();
|
||||
S3D_INFO model;
|
||||
|
||||
wxString initialpath = prj.GetRString( PROJECT::VIEWER_3D_PATH );
|
||||
wxString sidx = prj.GetRString( PROJECT::VIEWER_3D_FILTER_INDEX );
|
||||
int filter = 0;
|
||||
|
||||
if( !sidx.empty() )
|
||||
{
|
||||
long tmp;
|
||||
sidx.ToLong( &tmp );
|
||||
|
||||
if( tmp > 0 && tmp <= 0x7FFFFFFF )
|
||||
filter = (int) tmp;
|
||||
}
|
||||
|
||||
if( !S3D::Select3DModel( this, Prj().Get3DCacheManager(),
|
||||
initialpath, filter, &model ) || model.filename.empty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
prj.SetRString( PROJECT::VIEWER_3D_PATH, initialpath );
|
||||
sidx = wxString::Format( wxT( "%i" ), filter );
|
||||
prj.SetRString( PROJECT::VIEWER_3D_FILTER_INDEX, sidx );
|
||||
wxString origPath = model.filename;
|
||||
wxString alias;
|
||||
wxString shortPath;
|
||||
S3D_FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver();
|
||||
|
||||
if( res && res->SplitAlias( origPath, alias, shortPath ) )
|
||||
{
|
||||
origPath = alias;
|
||||
origPath.append( wxT( ":" ) );
|
||||
origPath.append( shortPath );
|
||||
}
|
||||
|
||||
m_3D_ShapeNameListBox->Append( origPath );
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
// In Kicad files, filenames and paths are stored using Unix notation
|
||||
model.filename.Replace( wxT( "\\" ), wxT( "/" ) );
|
||||
#endif
|
||||
|
||||
S3D_MASTER* new3DShape = new S3D_MASTER( NULL );
|
||||
new3DShape->SetShape3DName( model.filename );
|
||||
new3DShape->m_MatScale.x = model.scale.x;
|
||||
new3DShape->m_MatScale.y = model.scale.y;
|
||||
new3DShape->m_MatScale.z = model.scale.z;
|
||||
new3DShape->m_MatRotation.x = model.rotation.x;
|
||||
new3DShape->m_MatRotation.y = model.rotation.y;
|
||||
new3DShape->m_MatRotation.z = model.rotation.z;
|
||||
new3DShape->m_MatPosition.x = model.offset.x;
|
||||
new3DShape->m_MatPosition.y = model.offset.y;
|
||||
new3DShape->m_MatPosition.z = model.offset.z;
|
||||
|
||||
m_Shapes3D_list.push_back( new3DShape );
|
||||
m_LastSelected3DShapeIndex = m_3D_ShapeNameListBox->GetCount() - 1;
|
||||
m_3D_ShapeNameListBox->SetSelection( m_LastSelected3DShapeIndex );
|
||||
Transfert3DValuesToDisplay( m_Shapes3D_list[m_LastSelected3DShapeIndex] );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool DIALOG_MODULE_BOARD_EDITOR::TransferDataToWindow()
|
||||
{
|
||||
if( !wxDialog::TransferDataToWindow() )
|
||||
return false;
|
||||
|
||||
if( !m_PanelProperties->TransferDataToWindow() )
|
||||
return false;
|
||||
if( !m_Panel3D->TransferDataToWindow() )
|
||||
return false;
|
||||
|
||||
InitModeditProperties();
|
||||
InitBoardProperties();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool DIALOG_MODULE_BOARD_EDITOR::TransferDataFromWindow()
|
||||
{
|
||||
wxPoint modpos;
|
||||
wxString msg;
|
||||
|
||||
if( !Validate() || !DIALOG_MODULE_BOARD_EDITOR_BASE::TransferDataFromWindow() )
|
||||
return false;
|
||||
|
||||
if( !m_PanelProperties->TransferDataFromWindow() )
|
||||
return false;
|
||||
if( !m_Panel3D->TransferDataFromWindow() )
|
||||
return false;
|
||||
|
||||
if( m_CurrentModule->GetFlags() == 0 ) // this is a simple edition, we
|
||||
// must create an undo entry
|
||||
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 );
|
||||
}
|
||||
|
||||
// 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 );
|
||||
|
||||
// Initialize masks clearances
|
||||
m_CurrentModule->SetLocalClearance( ValueFromTextCtrl( *m_NetClearanceValueCtrl ) );
|
||||
m_CurrentModule->SetLocalSolderMaskMargin( ValueFromTextCtrl( *m_SolderMaskMarginCtrl ) );
|
||||
m_CurrentModule->SetLocalSolderPasteMargin( ValueFromTextCtrl( *m_SolderPasteMarginCtrl ) );
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// Set Module Position
|
||||
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 );
|
||||
|
||||
switch( m_AttributsCtrl->GetSelection() )
|
||||
{
|
||||
case 0:
|
||||
m_CurrentModule->SetAttributes( 0 );
|
||||
break;
|
||||
|
||||
case 1:
|
||||
m_CurrentModule->SetAttributes( MOD_CMS );
|
||||
break;
|
||||
|
||||
case 2:
|
||||
m_CurrentModule->SetAttributes( MOD_VIRTUAL );
|
||||
break;
|
||||
}
|
||||
|
||||
m_CurrentModule->SetPlacementCost90( m_CostRot90Ctrl->GetValue() );
|
||||
m_CurrentModule->SetPlacementCost180( m_CostRot180Ctrl->GetValue() );
|
||||
|
||||
/* 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)
|
||||
*/
|
||||
int orient = KiROUND( m_OrientValue * 10.0 );
|
||||
|
||||
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
|
||||
int idx = m_3D_ShapeNameListBox->GetSelection();
|
||||
|
||||
if( idx >= 0 )
|
||||
TransfertDisplayTo3DValues( idx );
|
||||
|
||||
S3D_MASTER* draw3D = m_CurrentModule->Models();
|
||||
|
||||
for( unsigned ii = 0; ii < m_Shapes3D_list.size(); ii++ )
|
||||
{
|
||||
S3D_MASTER* draw3DCopy = m_Shapes3D_list[ii];
|
||||
|
||||
if( draw3DCopy->GetShape3DName().IsEmpty() )
|
||||
continue;
|
||||
|
||||
if( draw3D == NULL )
|
||||
{
|
||||
draw3D = new S3D_MASTER( draw3D );
|
||||
m_CurrentModule->Models().Append( draw3D );
|
||||
}
|
||||
|
||||
draw3D->SetShape3DName( draw3DCopy->GetShape3DName() );
|
||||
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;
|
||||
|
||||
for( ; draw3D != NULL; draw3D = nextdraw3D )
|
||||
{
|
||||
nextdraw3D = (S3D_MASTER*) draw3D->Next();
|
||||
delete m_CurrentModule->Models().Remove( draw3D );
|
||||
}
|
||||
|
||||
// Fill shape list with one void entry, if no entry
|
||||
if( m_CurrentModule->Models() == NULL )
|
||||
m_CurrentModule->Models().PushBack( new S3D_MASTER( m_CurrentModule ) );
|
||||
|
||||
|
||||
m_CurrentModule->CalculateBoundingBox();
|
||||
|
||||
m_Parent->OnModify();
|
||||
|
||||
SetReturnCode( PRM_EDITOR_EDIT_OK );
|
||||
|
||||
if( m_DC )
|
||||
{
|
||||
m_CurrentModule->Draw( m_Parent->GetCanvas(), m_DC, GR_OR );
|
||||
m_Parent->GetCanvas()->CrossHairOn( m_DC );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_BOARD_EDITOR::OnEditReference( wxCommandEvent& event )
|
||||
{
|
||||
wxPoint tmp = m_Parent->GetCrossHairPosition();
|
||||
|
||||
m_Parent->SetCrossHairPosition( m_ReferenceCopy->GetTextPosition() );
|
||||
m_ReferenceCopy->SetParent( m_CurrentModule );
|
||||
m_Parent->InstallTextModOptionsFrame( m_ReferenceCopy, NULL );
|
||||
m_Parent->SetCrossHairPosition( tmp );
|
||||
m_ReferenceCtrl->SetValue( m_ReferenceCopy->GetText() );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_BOARD_EDITOR::OnEditValue( wxCommandEvent& event )
|
||||
{
|
||||
wxPoint tmp = m_Parent->GetCrossHairPosition();
|
||||
|
||||
m_Parent->SetCrossHairPosition( m_ValueCopy->GetTextPosition() );
|
||||
m_ValueCopy->SetParent( m_CurrentModule );
|
||||
m_Parent->InstallTextModOptionsFrame( m_ValueCopy, NULL );
|
||||
m_Parent->SetCrossHairPosition( tmp );
|
||||
m_ValueCtrl->SetValue( m_ValueCopy->GetText() );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_BOARD_EDITOR::Cfg3DPath( wxCommandEvent& event )
|
||||
{
|
||||
S3D::Configure3DPaths( this, Prj().Get3DCacheManager()->GetResolver() );
|
||||
}
|
|
@ -1,646 +0,0 @@
|
|||
/**
|
||||
* @file dialog_edit_module_for_Modedit.cpp
|
||||
*
|
||||
* @brief Dialog for editing a module properties in module editor (modedit)
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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) 2008-2015 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* 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>
|
||||
#include <class_drawpanel.h>
|
||||
#include <confirm.h>
|
||||
#include <pcbnew.h>
|
||||
#include <kiface_i.h>
|
||||
#include <gestfich.h>
|
||||
#include <3d_struct.h>
|
||||
#include <3d_viewer.h>
|
||||
#include <wxPcbStruct.h>
|
||||
#include <base_units.h>
|
||||
#include <macros.h>
|
||||
#include <validators.h>
|
||||
#include <kicad_string.h>
|
||||
|
||||
#include <class_module.h>
|
||||
#include <class_text_mod.h>
|
||||
#include <module_editor_frame.h>
|
||||
#include <dialog_edit_module_for_Modedit.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <pgm_base.h>
|
||||
#include "3d_cache/dialogs/panel_prev_model.h"
|
||||
#include "3d_cache/dialogs/3d_cache_dialogs.h"
|
||||
#include "3d_cache/3d_cache.h"
|
||||
#include "3d_cache/3d_filename_resolver.h"
|
||||
|
||||
size_t DIALOG_MODULE_MODULE_EDITOR::m_page = 0; // remember the last open page during session
|
||||
|
||||
|
||||
DIALOG_MODULE_MODULE_EDITOR::DIALOG_MODULE_MODULE_EDITOR( FOOTPRINT_EDIT_FRAME* aParent,
|
||||
MODULE* aModule ) :
|
||||
DIALOG_MODULE_MODULE_EDITOR_BASE( aParent )
|
||||
{
|
||||
m_parent = aParent;
|
||||
m_currentModule = aModule;
|
||||
|
||||
// Give an icon
|
||||
wxIcon icon;
|
||||
icon.CopyFromBitmap( KiBitmap( icon_modedit_xpm ) );
|
||||
SetIcon( icon );
|
||||
|
||||
aParent->Prj().Get3DCacheManager()->GetResolver()->SetProgramBase( &Pgm() );
|
||||
m_PreviewPane = new PANEL_PREV_3D( m_Panel3D, aParent->Prj().Get3DCacheManager() );
|
||||
bLowerSizer3D->Add( m_PreviewPane, 1, wxEXPAND, 5 );
|
||||
|
||||
m_FootprintNameCtrl->SetValidator( FILE_NAME_CHAR_VALIDATOR() );
|
||||
initModeditProperties();
|
||||
|
||||
m_NoteBook->SetSelection( m_page );
|
||||
|
||||
m_sdbSizerStdButtonsOK->SetDefault();
|
||||
|
||||
Layout();
|
||||
|
||||
FixOSXCancelButtonIssue();
|
||||
}
|
||||
|
||||
|
||||
DIALOG_MODULE_MODULE_EDITOR::~DIALOG_MODULE_MODULE_EDITOR()
|
||||
{
|
||||
for( unsigned ii = 0; ii < m_shapes3D_list.size(); ii++ )
|
||||
delete m_shapes3D_list[ii];
|
||||
|
||||
m_shapes3D_list.clear();
|
||||
|
||||
// free the memory used by all models, otherwise models which were
|
||||
// browsed but not used would consume memory
|
||||
Prj().Get3DCacheManager()->FlushCache( false );
|
||||
|
||||
// the GL canvas has to be visible before it is destroyed
|
||||
m_page = m_NoteBook->GetSelection();
|
||||
m_NoteBook->SetSelection( 1 );
|
||||
delete m_PreviewPane;
|
||||
m_PreviewPane = NULL; // just in case, to avoid double-free
|
||||
|
||||
delete m_referenceCopy;
|
||||
delete m_valueCopy;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_MODULE_EDITOR::initModeditProperties()
|
||||
{
|
||||
SetFocus();
|
||||
|
||||
// Display the default path, given by environment variable KISYS3DMOD
|
||||
wxString default_path;
|
||||
wxGetEnv( KISYS3DMOD, &default_path );
|
||||
#ifdef __WINDOWS__
|
||||
default_path.Replace( wxT( "/" ), wxT( "\\" ) );
|
||||
#endif
|
||||
|
||||
m_lastSelected3DShapeIndex = -1;
|
||||
|
||||
// Init 3D shape list
|
||||
m_3D_ShapeNameListBox->Clear();
|
||||
S3D_MASTER* draw3D = m_currentModule->Models();
|
||||
wxString origPath;
|
||||
wxString alias;
|
||||
wxString shortPath;
|
||||
S3D_FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver();
|
||||
|
||||
while( draw3D )
|
||||
{
|
||||
if( !draw3D->GetShape3DName().IsEmpty() )
|
||||
{
|
||||
S3D_MASTER* draw3DCopy = new S3D_MASTER(NULL);
|
||||
draw3DCopy->Copy( draw3D );
|
||||
m_shapes3D_list.push_back( draw3DCopy );
|
||||
|
||||
origPath = draw3DCopy->GetShape3DName();
|
||||
|
||||
if( res && res->SplitAlias( origPath, alias, shortPath ) )
|
||||
{
|
||||
origPath = alias;
|
||||
origPath.append( wxT( ":" ) );
|
||||
origPath.append( shortPath );
|
||||
}
|
||||
|
||||
m_3D_ShapeNameListBox->Append( origPath );
|
||||
}
|
||||
|
||||
draw3D = (S3D_MASTER*) draw3D->Next();
|
||||
}
|
||||
|
||||
m_DocCtrl->SetValue( m_currentModule->GetDescription() );
|
||||
m_KeywordCtrl->SetValue( m_currentModule->GetKeywords() );
|
||||
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() );
|
||||
m_FootprintNameCtrl->SetValue( m_currentModule->GetFPID().Format() );
|
||||
|
||||
m_AttributsCtrl->SetItemToolTip( 0, _( "Use this attribute for most non SMD components" ) );
|
||||
m_AttributsCtrl->SetItemToolTip( 1,
|
||||
_( "Use this attribute for SMD components.\nOnly components with this option are put in the footprint position list file" ) );
|
||||
m_AttributsCtrl->SetItemToolTip( 2,
|
||||
_( "Use this attribute for \"virtual\" components drawn on board (like a old ISA PC bus connector)" ) );
|
||||
|
||||
// Controls on right side of the dialog
|
||||
switch( m_currentModule->GetAttributes() & 255 )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
m_AutoPlaceCtrl->SetSelection( (m_currentModule->IsLocked()) ? 1 : 0 );
|
||||
m_AutoPlaceCtrl->SetItemToolTip( 0, _( "Enable hotkey move commands and Auto Placement" ) );
|
||||
m_AutoPlaceCtrl->SetItemToolTip( 1, _( "Disable hotkey move commands and Auto Placement" ) );
|
||||
|
||||
m_CostRot90Ctrl->SetValue( m_currentModule->GetPlacementCost90() );
|
||||
m_CostRot180Ctrl->SetValue( m_currentModule->GetPlacementCost180() );
|
||||
|
||||
// Initialize dialog relative to masks clearances
|
||||
m_NetClearanceUnits->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
|
||||
m_SolderMaskMarginUnits->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
|
||||
m_SolderPasteMarginUnits->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
|
||||
|
||||
wxString msg;
|
||||
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() );
|
||||
|
||||
if( m_currentModule->GetLocalSolderPasteMargin() == 0 )
|
||||
m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) + m_SolderPasteMarginCtrl->GetValue() );
|
||||
|
||||
if( m_currentModule->GetLocalSolderPasteMarginRatio() == 0.0 )
|
||||
msg.Printf( wxT( "-%f" ), m_currentModule->GetLocalSolderPasteMarginRatio() * 100.0 );
|
||||
else
|
||||
msg.Printf( wxT( "%f" ), m_currentModule->GetLocalSolderPasteMarginRatio() * 100.0 );
|
||||
|
||||
m_SolderPasteMarginRatioCtrl->SetValue( msg );
|
||||
|
||||
// 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" ), m_currentModule->GetLocalSolderPasteMarginRatio() * 100.0 );
|
||||
|
||||
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 );
|
||||
|
||||
// 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] );
|
||||
}
|
||||
else
|
||||
{
|
||||
S3D_INFO params;
|
||||
params.scale.x = 1.0;
|
||||
params.scale.y = 1.0;
|
||||
params.scale.z = 1.0;
|
||||
m_PreviewPane->SetModelData( ¶ms );
|
||||
}
|
||||
|
||||
// We have modified the UI, so call Fit() for m_Panel3D
|
||||
// to be sure the m_Panel3D sizers are initialized before opening the dialog
|
||||
m_Panel3D->GetSizer()->Fit( m_Panel3D );
|
||||
}
|
||||
|
||||
|
||||
// Initialize 3D info displayed in dialog box from values in aStruct3DSource
|
||||
void DIALOG_MODULE_MODULE_EDITOR::Transfert3DValuesToDisplay( S3D_MASTER * aStruct3DSource )
|
||||
{
|
||||
S3D_INFO params;
|
||||
|
||||
if( aStruct3DSource )
|
||||
{
|
||||
params.filename = aStruct3DSource->GetShape3DName();
|
||||
|
||||
params.scale.x = aStruct3DSource->m_MatScale.x;
|
||||
params.scale.y = aStruct3DSource->m_MatScale.y;
|
||||
params.scale.z = aStruct3DSource->m_MatScale.z;
|
||||
|
||||
params.offset.x = aStruct3DSource->m_MatPosition.x;
|
||||
params.offset.y = aStruct3DSource->m_MatPosition.y;
|
||||
params.offset.z = aStruct3DSource->m_MatPosition.z;
|
||||
|
||||
params.rotation.x = aStruct3DSource->m_MatRotation.x;
|
||||
params.rotation.y = aStruct3DSource->m_MatRotation.y;
|
||||
params.rotation.z = aStruct3DSource->m_MatRotation.z;
|
||||
}
|
||||
else
|
||||
{
|
||||
params.scale.x = 1.0;
|
||||
params.scale.y = 1.0;
|
||||
params.scale.z = 1.0;
|
||||
|
||||
params.offset.x = 0.0;
|
||||
params.offset.y = 0.0;
|
||||
params.offset.z = 0.0;
|
||||
|
||||
params.rotation = params.offset;
|
||||
}
|
||||
|
||||
m_PreviewPane->SetModelData( ¶ms );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/** 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_MODULE_EDITOR::TransfertDisplayTo3DValues( int aIndexSelection )
|
||||
{
|
||||
if( aIndexSelection >= (int) m_shapes3D_list.size() )
|
||||
return;
|
||||
|
||||
S3D_MASTER* struct3DDest = m_shapes3D_list[aIndexSelection];
|
||||
S3D_INFO params;
|
||||
m_PreviewPane->GetModelData( ¶ms );
|
||||
|
||||
struct3DDest->m_MatScale.x = params.scale.x;
|
||||
struct3DDest->m_MatScale.y = params.scale.y;
|
||||
struct3DDest->m_MatScale.z = params.scale.z;
|
||||
|
||||
struct3DDest->m_MatRotation.x = params.rotation.x;
|
||||
struct3DDest->m_MatRotation.y = params.rotation.y;
|
||||
struct3DDest->m_MatRotation.z = params.rotation.z;
|
||||
|
||||
struct3DDest->m_MatPosition.x = params.offset.x;
|
||||
struct3DDest->m_MatPosition.y = params.offset.y;
|
||||
struct3DDest->m_MatPosition.z = params.offset.z;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_MODULE_EDITOR::On3DShapeNameSelected(wxCommandEvent& event)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
Transfert3DValuesToDisplay( m_shapes3D_list[m_lastSelected3DShapeIndex] );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_MODULE_EDITOR::Remove3DShape(wxCommandEvent& event)
|
||||
{
|
||||
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 );
|
||||
|
||||
if( m_3D_ShapeNameListBox->GetCount() == 0 )
|
||||
Transfert3DValuesToDisplay( NULL );
|
||||
else
|
||||
{
|
||||
if( ii > 0 )
|
||||
m_lastSelected3DShapeIndex = ii - 1;
|
||||
else
|
||||
m_lastSelected3DShapeIndex = 0;
|
||||
|
||||
m_3D_ShapeNameListBox->SetSelection( m_lastSelected3DShapeIndex );
|
||||
Transfert3DValuesToDisplay(
|
||||
m_shapes3D_list[m_lastSelected3DShapeIndex] );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_MODULE_EDITOR::Edit3DShapeFileName()
|
||||
{
|
||||
int idx = m_3D_ShapeNameListBox->GetSelection();
|
||||
|
||||
if( idx < 0 )
|
||||
return;
|
||||
|
||||
// ensure any updated parameters are not discarded
|
||||
TransfertDisplayTo3DValues( idx );
|
||||
|
||||
// Edit filename
|
||||
wxString filename = m_3D_ShapeNameListBox->GetStringSelection();
|
||||
wxTextEntryDialog dlg( this, wxEmptyString, wxEmptyString, filename );
|
||||
|
||||
bool hasAlias;
|
||||
S3D_FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver();
|
||||
|
||||
if( dlg.ShowModal() != wxID_OK )
|
||||
return;
|
||||
|
||||
filename = dlg.GetValue();
|
||||
|
||||
if( filename.empty() )
|
||||
return;
|
||||
|
||||
if( !res->ValidateFileName( filename, hasAlias ) )
|
||||
{
|
||||
wxString msg = _( "Invalid filename: " );
|
||||
msg.append( filename );
|
||||
wxMessageBox( msg, _T( "Edit 3D file name" ) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_3D_ShapeNameListBox->SetString( idx, filename );
|
||||
|
||||
// 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
|
||||
|
||||
S3D_MASTER* new3DShape = new S3D_MASTER( NULL );
|
||||
new3DShape->SetShape3DName( filename );
|
||||
new3DShape->m_MatPosition = m_shapes3D_list[idx]->m_MatPosition;
|
||||
new3DShape->m_MatRotation = m_shapes3D_list[idx]->m_MatRotation;
|
||||
new3DShape->m_MatScale = m_shapes3D_list[idx]->m_MatScale;
|
||||
delete m_shapes3D_list[idx];
|
||||
m_shapes3D_list[idx] = new3DShape;
|
||||
|
||||
Transfert3DValuesToDisplay( m_shapes3D_list[idx] );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DShapeFile()
|
||||
{
|
||||
PROJECT& prj = Prj();
|
||||
S3D_INFO model;
|
||||
|
||||
wxString initialpath = prj.GetRString( PROJECT::VIEWER_3D_PATH );
|
||||
wxString sidx = prj.GetRString( PROJECT::VIEWER_3D_FILTER_INDEX );
|
||||
int filter = 0;
|
||||
|
||||
if( !sidx.empty() )
|
||||
{
|
||||
long tmp;
|
||||
sidx.ToLong( &tmp );
|
||||
|
||||
if( tmp > 0 && tmp <= 0x7FFFFFFF )
|
||||
filter = (int) tmp;
|
||||
}
|
||||
|
||||
if( !S3D::Select3DModel( m_PreviewPane, Prj().Get3DCacheManager(),
|
||||
initialpath, filter, &model ) || model.filename.empty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
prj.SetRString( PROJECT::VIEWER_3D_PATH, initialpath );
|
||||
sidx = wxString::Format( wxT( "%i" ), filter );
|
||||
prj.SetRString( PROJECT::VIEWER_3D_FILTER_INDEX, sidx );
|
||||
wxString origPath = model.filename;
|
||||
wxString alias;
|
||||
wxString shortPath;
|
||||
S3D_FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver();
|
||||
|
||||
if( res && res->SplitAlias( origPath, alias, shortPath ) )
|
||||
{
|
||||
origPath = alias;
|
||||
origPath.append( wxT( ":" ) );
|
||||
origPath.append( shortPath );
|
||||
}
|
||||
|
||||
m_3D_ShapeNameListBox->Append( origPath );
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
// In Kicad files, filenames and paths are stored using Unix notation
|
||||
model.filename.Replace( wxT( "\\" ), wxT( "/" ) );
|
||||
#endif
|
||||
|
||||
S3D_MASTER* new3DShape = new S3D_MASTER( NULL );
|
||||
new3DShape->SetShape3DName( model.filename );
|
||||
new3DShape->m_MatScale.x = model.scale.x;
|
||||
new3DShape->m_MatScale.y = model.scale.y;
|
||||
new3DShape->m_MatScale.z = model.scale.z;
|
||||
new3DShape->m_MatRotation.x = model.rotation.x;
|
||||
new3DShape->m_MatRotation.y = model.rotation.y;
|
||||
new3DShape->m_MatRotation.z = model.rotation.z;
|
||||
new3DShape->m_MatPosition.x = model.offset.x;
|
||||
new3DShape->m_MatPosition.y = model.offset.y;
|
||||
new3DShape->m_MatPosition.z = model.offset.z;
|
||||
|
||||
m_shapes3D_list.push_back( new3DShape );
|
||||
m_lastSelected3DShapeIndex = m_3D_ShapeNameListBox->GetCount() - 1;
|
||||
m_3D_ShapeNameListBox->SetSelection( m_lastSelected3DShapeIndex );
|
||||
Transfert3DValuesToDisplay( m_shapes3D_list[m_lastSelected3DShapeIndex] );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_MODULE_EDITOR::OnCancelClick( wxCommandEvent& event )
|
||||
{
|
||||
EndModal( -1 );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event )
|
||||
{
|
||||
// First, test for invalid chars in module name
|
||||
wxString footprintName = m_FootprintNameCtrl->GetValue();
|
||||
|
||||
if( ! footprintName.IsEmpty() )
|
||||
{
|
||||
if( ! MODULE::IsLibNameValid( footprintName ) )
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf( _( "Error:\none of invalid chars <%s> found\nin <%s>" ),
|
||||
MODULE::StringLibNameInvalidChars( true ),
|
||||
GetChars( footprintName ) );
|
||||
|
||||
DisplayError( NULL, msg );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_parent->SaveCopyInUndoList( m_currentModule, UR_MODEDIT );
|
||||
m_currentModule->SetLocked( m_AutoPlaceCtrl->GetSelection() == 1 );
|
||||
|
||||
switch( m_AttributsCtrl->GetSelection() )
|
||||
{
|
||||
case 0:
|
||||
m_currentModule->SetAttributes( 0 );
|
||||
break;
|
||||
|
||||
case 1:
|
||||
m_currentModule->SetAttributes( MOD_CMS );
|
||||
break;
|
||||
|
||||
case 2:
|
||||
m_currentModule->SetAttributes( MOD_VIRTUAL );
|
||||
break;
|
||||
}
|
||||
|
||||
m_currentModule->SetPlacementCost90( m_CostRot90Ctrl->GetValue() );
|
||||
m_currentModule->SetPlacementCost180( m_CostRot180Ctrl->GetValue() );
|
||||
m_currentModule->SetDescription( m_DocCtrl->GetValue() );
|
||||
m_currentModule->SetKeywords( m_KeywordCtrl->GetValue() );
|
||||
|
||||
// Init footprint name in library
|
||||
if( ! footprintName.IsEmpty() )
|
||||
m_currentModule->SetFPID( FPID( footprintName ) );
|
||||
|
||||
// Init Fields:
|
||||
m_currentModule->Reference().Copy( m_referenceCopy );
|
||||
m_currentModule->Value().Copy( m_valueCopy );
|
||||
|
||||
// Initialize masks clearances
|
||||
m_currentModule->SetLocalClearance( ValueFromTextCtrl( *m_NetClearanceValueCtrl ) );
|
||||
m_currentModule->SetLocalSolderMaskMargin( ValueFromTextCtrl( *m_SolderMaskMarginCtrl ) );
|
||||
m_currentModule->SetLocalSolderPasteMargin( ValueFromTextCtrl( *m_SolderPasteMarginCtrl ) );
|
||||
double dtmp;
|
||||
wxString 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
|
||||
if( dtmp > 0.0 )
|
||||
dtmp = 0.0;
|
||||
|
||||
m_currentModule->SetLocalSolderPasteMarginRatio( dtmp / 100 );
|
||||
|
||||
// Update 3D shape list
|
||||
int idx = m_3D_ShapeNameListBox->GetSelection();
|
||||
|
||||
if ( idx >= 0 )
|
||||
TransfertDisplayTo3DValues( idx );
|
||||
|
||||
S3D_MASTER* draw3D = m_currentModule->Models();
|
||||
|
||||
for( unsigned ii = 0; ii < m_shapes3D_list.size(); ii++ )
|
||||
{
|
||||
S3D_MASTER* draw3DCopy = m_shapes3D_list[ii];
|
||||
|
||||
if( draw3DCopy->GetShape3DName().IsEmpty() )
|
||||
continue;
|
||||
|
||||
if( draw3D == NULL )
|
||||
{
|
||||
draw3D = new S3D_MASTER( draw3D );
|
||||
m_currentModule->Models().Append( draw3D );
|
||||
}
|
||||
|
||||
draw3D->SetShape3DName( draw3DCopy->GetShape3DName() );
|
||||
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;
|
||||
|
||||
for( ; draw3D != NULL; draw3D = nextdraw3D )
|
||||
{
|
||||
nextdraw3D = (S3D_MASTER*) draw3D->Next();
|
||||
delete m_currentModule->Models().Remove( draw3D );
|
||||
}
|
||||
|
||||
// Fill shape list with one void entry, if no entry
|
||||
if( m_currentModule->Models() == NULL )
|
||||
m_currentModule->Models().PushBack( new S3D_MASTER( m_currentModule ) );
|
||||
|
||||
|
||||
m_currentModule->CalculateBoundingBox();
|
||||
|
||||
m_parent->OnModify();
|
||||
|
||||
EndModal( 1 );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_MODULE_EDITOR::OnEditReference(wxCommandEvent& event)
|
||||
{
|
||||
wxPoint tmp = m_parent->GetCrossHairPosition();
|
||||
m_parent->SetCrossHairPosition( m_referenceCopy->GetTextPosition() );
|
||||
m_parent->InstallTextModOptionsFrame( m_referenceCopy, NULL );
|
||||
m_parent->SetCrossHairPosition( tmp );
|
||||
m_ReferenceCtrl->SetValue( m_referenceCopy->GetText() );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_MODULE_EDITOR::OnEditValue(wxCommandEvent& event)
|
||||
{
|
||||
wxPoint tmp = m_parent->GetCrossHairPosition();
|
||||
m_parent->SetCrossHairPosition( m_valueCopy->GetTextPosition() );
|
||||
m_parent->InstallTextModOptionsFrame( m_valueCopy, NULL );
|
||||
m_parent->SetCrossHairPosition( tmp );
|
||||
m_ValueCtrl->SetValue( m_valueCopy->GetText() );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_MODULE_EDITOR::Cfg3DPath( wxCommandEvent& event )
|
||||
{
|
||||
S3D::Configure3DPaths( this, Prj().Get3DCacheManager()->GetResolver() );
|
||||
}
|
|
@ -1,231 +0,0 @@
|
|||
/**
|
||||
* @file dialog_export_idf.cpp
|
||||
*/
|
||||
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013-2015 Cirilo Bernardo
|
||||
*
|
||||
* 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 <wxPcbStruct.h>
|
||||
#include <kiface_i.h>
|
||||
#include <pcbnew.h>
|
||||
#include <class_board.h>
|
||||
#include <convert_to_biu.h>
|
||||
|
||||
// IDF export header generated by wxFormBuilder
|
||||
#include <dialog_export_idf_base.h>
|
||||
|
||||
#define OPTKEY_IDF_THOU wxT( "IDFExportThou" )
|
||||
#define OPTKEY_IDF_REF_AUTOADJ wxT( "IDFRefAutoAdj" )
|
||||
#define OPTKEY_IDF_REF_UNITS wxT( "IDFRefUnits" )
|
||||
#define OPTKEY_IDF_REF_X wxT( "IDFRefX" )
|
||||
#define OPTKEY_IDF_REF_Y wxT( "IDFRefY" )
|
||||
|
||||
|
||||
/**
|
||||
* Function Export_IDF3
|
||||
* Creates an IDF3 compliant BOARD (*.emn) and LIBRARY (*.emp) file.
|
||||
*
|
||||
* @param aPcb = a pointer to the board to be exported to IDF
|
||||
* @param aFullFileName = the full filename of the export file
|
||||
* @param aUseThou = set to true if the desired IDF unit is thou (mil)
|
||||
* @param aXRef = the board Reference Point in mm, X value
|
||||
* @param aYRef = the board Reference Point in mm, Y value
|
||||
* @return true if OK
|
||||
*/
|
||||
bool Export_IDF3( BOARD *aPcb, const wxString & aFullFileName, bool aUseThou,
|
||||
double aXRef, double aYRef );
|
||||
|
||||
|
||||
class DIALOG_EXPORT_IDF3: public DIALOG_EXPORT_IDF3_BASE
|
||||
{
|
||||
private:
|
||||
PCB_EDIT_FRAME* m_parent;
|
||||
wxConfigBase* m_config;
|
||||
bool m_idfThouOpt; // remember last preference for units in THOU
|
||||
bool m_AutoAdjust; // remember last Reference Point AutoAdjust setting
|
||||
int m_RefUnits; // remember last units for Reference Point
|
||||
double m_XRef; // remember last X Reference Point
|
||||
double m_YRef; // remember last Y Reference Point
|
||||
|
||||
public:
|
||||
DIALOG_EXPORT_IDF3( PCB_EDIT_FRAME* parent ) :
|
||||
DIALOG_EXPORT_IDF3_BASE( parent )
|
||||
{
|
||||
m_parent = parent;
|
||||
m_config = Kiface().KifaceSettings();
|
||||
SetFocus();
|
||||
m_idfThouOpt = false;
|
||||
m_config->Read( OPTKEY_IDF_THOU, &m_idfThouOpt );
|
||||
m_rbUnitSelection->SetSelection( m_idfThouOpt ? 1 : 0 );
|
||||
m_config->Read( OPTKEY_IDF_REF_AUTOADJ, &m_AutoAdjust, false );
|
||||
m_config->Read( OPTKEY_IDF_REF_UNITS, &m_RefUnits, 0 );
|
||||
m_config->Read( OPTKEY_IDF_REF_X, &m_XRef, 0.0 );
|
||||
m_config->Read( OPTKEY_IDF_REF_Y, &m_YRef, 0.0 );
|
||||
|
||||
m_cbAutoAdjustOffset->SetValue( m_AutoAdjust );
|
||||
m_cbAutoAdjustOffset->Bind( wxEVT_CHECKBOX, &DIALOG_EXPORT_IDF3::OnAutoAdjustOffset, this );
|
||||
|
||||
m_IDF_RefUnitChoice->SetSelection( m_RefUnits );
|
||||
wxString tmpStr;
|
||||
tmpStr << m_XRef;
|
||||
m_IDF_Xref->SetValue( tmpStr );
|
||||
tmpStr = wxT( "" );
|
||||
tmpStr << m_YRef;
|
||||
m_IDF_Yref->SetValue( tmpStr );
|
||||
|
||||
if( m_AutoAdjust )
|
||||
{
|
||||
m_IDF_RefUnitChoice->Enable( false );
|
||||
m_IDF_Xref->Enable( false );
|
||||
m_IDF_Yref->Enable( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_IDF_RefUnitChoice->Enable( true );
|
||||
m_IDF_Xref->Enable( true );
|
||||
m_IDF_Yref->Enable( true );
|
||||
}
|
||||
|
||||
m_sdbSizerOK->SetDefault();
|
||||
|
||||
FixOSXCancelButtonIssue();
|
||||
|
||||
// Now all widgets have the size fixed, call FinishDialogSettings
|
||||
FinishDialogSettings();
|
||||
}
|
||||
|
||||
~DIALOG_EXPORT_IDF3()
|
||||
{
|
||||
m_idfThouOpt = m_rbUnitSelection->GetSelection() == 1;
|
||||
m_config->Write( OPTKEY_IDF_THOU, m_idfThouOpt );
|
||||
m_config->Write( OPTKEY_IDF_REF_AUTOADJ, GetAutoAdjustOffset() );
|
||||
m_config->Write( OPTKEY_IDF_REF_UNITS, m_IDF_RefUnitChoice->GetSelection() );
|
||||
m_config->Write( OPTKEY_IDF_REF_X, m_IDF_Xref->GetValue() );
|
||||
m_config->Write( OPTKEY_IDF_REF_Y, m_IDF_Yref->GetValue() );
|
||||
}
|
||||
|
||||
bool GetThouOption()
|
||||
{
|
||||
return m_rbUnitSelection->GetSelection() == 1;
|
||||
}
|
||||
|
||||
wxFilePickerCtrl* FilePicker()
|
||||
{
|
||||
return m_filePickerIDF;
|
||||
}
|
||||
|
||||
int GetRefUnitsChoice()
|
||||
{
|
||||
return m_IDF_RefUnitChoice->GetSelection();
|
||||
}
|
||||
|
||||
double GetXRef()
|
||||
{
|
||||
return DoubleValueFromString( UNSCALED_UNITS, m_IDF_Xref->GetValue() );
|
||||
}
|
||||
|
||||
double GetYRef()
|
||||
{
|
||||
return DoubleValueFromString( UNSCALED_UNITS, m_IDF_Yref->GetValue() );
|
||||
}
|
||||
|
||||
bool GetAutoAdjustOffset()
|
||||
{
|
||||
return m_cbAutoAdjustOffset->GetValue();
|
||||
}
|
||||
|
||||
void OnAutoAdjustOffset( wxCommandEvent& event )
|
||||
{
|
||||
if( GetAutoAdjustOffset() )
|
||||
{
|
||||
m_IDF_RefUnitChoice->Enable( false );
|
||||
m_IDF_Xref->Enable( false );
|
||||
m_IDF_Yref->Enable( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_IDF_RefUnitChoice->Enable( true );
|
||||
m_IDF_Xref->Enable( true );
|
||||
m_IDF_Yref->Enable( true );
|
||||
}
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Function OnExportIDF3
|
||||
* will export the current BOARD to IDF board and lib files.
|
||||
*/
|
||||
void PCB_EDIT_FRAME::ExportToIDF3( wxCommandEvent& event )
|
||||
{
|
||||
wxFileName fn;
|
||||
|
||||
// Build default file name
|
||||
fn = GetBoard()->GetFileName();
|
||||
fn.SetExt( wxT( "emn" ) );
|
||||
|
||||
DIALOG_EXPORT_IDF3 dlg( this );
|
||||
dlg.FilePicker()->SetPath( fn.GetFullPath() );
|
||||
|
||||
if ( dlg.ShowModal() != wxID_OK )
|
||||
return;
|
||||
|
||||
bool thou = dlg.GetThouOption();
|
||||
double aXRef;
|
||||
double aYRef;
|
||||
|
||||
if( dlg.GetAutoAdjustOffset() )
|
||||
{
|
||||
EDA_RECT bbox = GetBoard()->ComputeBoundingBox( true );
|
||||
|
||||
aXRef = bbox.Centre().x * MM_PER_IU;
|
||||
aYRef = bbox.Centre().y * MM_PER_IU;
|
||||
}
|
||||
else
|
||||
{
|
||||
aXRef = dlg.GetXRef();
|
||||
aYRef = dlg.GetYRef();
|
||||
|
||||
if( dlg.GetRefUnitsChoice() == 1 )
|
||||
{
|
||||
// selected reference unit is in inches
|
||||
aXRef *= 25.4;
|
||||
aYRef *= 25.4;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
wxBusyCursor dummy;
|
||||
|
||||
wxString fullFilename = dlg.FilePicker()->GetPath();
|
||||
|
||||
if( !Export_IDF3( GetBoard(), fullFilename, thou, aXRef, aYRef ) )
|
||||
{
|
||||
wxString msg = _( "Unable to create " ) + fullFilename;
|
||||
wxMessageBox( msg );
|
||||
return;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue