Import svg import code from experimental trunk: convert dxf importer

This commit is contained in:
jean-pierre charras 2018-11-01 10:47:41 +01:00
parent 74a9d5401a
commit 430c61822d
22 changed files with 755 additions and 684 deletions

View File

@ -1242,12 +1242,12 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
ArchiveModulesOnBoard( true );
break;
case ID_GEN_IMPORT_DXF_FILE:
case ID_GEN_IMPORT_GRAPHICS_FILE:
InvokeDXFDialogBoardImport( this );
m_canvas->Refresh();
break;
default:
wxString msg;
msg.Printf( wxT( "PCB_EDIT_FRAME::Process_Special_Functions() unknown event id %d" ), id );

View File

@ -112,7 +112,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
EVT_TOOL( ID_MODEDIT_CREATE_NEW_LIB, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_ADD_LIBRARY, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_SHEET_SET, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_GEN_IMPORT_DXF_FILE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_GEN_IMPORT_GRAPHICS_FILE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_PRINT, FOOTPRINT_EDIT_FRAME::ToPrinter )
EVT_TOOL( ID_MODEDIT_EDIT_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_CHECK, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
@ -205,7 +205,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
EVT_UPDATE_UI( ID_MODEDIT_SHOW_HIDE_SEARCH_TREE,
FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar )
EVT_UPDATE_UI( ID_GEN_IMPORT_DXF_FILE, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
EVT_UPDATE_UI( ID_GEN_IMPORT_GRAPHICS_FILE, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
END_EVENT_TABLE()

View File

@ -796,7 +796,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
HandleBlockEnd( &dc );
break;
case ID_GEN_IMPORT_DXF_FILE:
case ID_GEN_IMPORT_GRAPHICS_FILE:
if( GetBoard()->m_Modules )
{
InvokeDXFDialogModuleImport( this, GetBoard()->m_Modules );

View File

@ -105,7 +105,7 @@ DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX( PCB_BASE_FRAME* aParent, bool aUseModuleIt
m_SelLayerBox->SetLayerSelection( m_layer );
}
m_sdbSizer1OK->SetDefault();
m_sdbSizerOK->SetDefault();
GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this );
Centre();
@ -222,8 +222,8 @@ void DIALOG_IMPORT_GFX::OnOKClick( wxCommandEvent& event )
if( plugin )
{
m_importer->SetScale( 1e6 ); // @todo: add a setting in the dialog and apply it here
m_importer->SetLineWidth( 0.1 ); // @todo add a setting in the dialog and apply it here
m_importer->SetScale( 1.0 /*1e6*/ ); // mm -> IU @todo: add a setting in the dialog and apply it here
m_importer->SetLineWidth( 0.1 * 1e6 ); // @todo add a setting in the dialog and apply it here
m_importer->SetPlugin( std::move( plugin ) );
if( m_importer->Load( m_filename ) )
@ -239,17 +239,19 @@ void DIALOG_IMPORT_GFX::OnOKClick( wxCommandEvent& event )
void DIALOG_IMPORT_GFX::onChangeHeight( wxUpdateUIEvent &event)
{
double heightInput;
heightInput = DoubleValueFromString(UNSCALED_UNITS,m_tcHeight->GetValue());
// @todo: implement scaling of Y
#if 0
double heightInput = DoubleValueFromString(UNSCALED_UNITS,m_tcHeight->GetValue());
if(m_cbKeepAspectRatio->GetValue())
{
// @todo: implement scaling of Y
}
#endif
}
#if 0
// Must be reworked (perhaps removed) because this is not used in GAL canvases
// only in legacy canvas.
bool InvokeDialogImportGfxBoard( PCB_BASE_FRAME* aCaller )
{
DIALOG_IMPORT_GFX dlg( aCaller );
@ -299,7 +301,7 @@ bool InvokeDialogImportGfxModule( PCB_BASE_FRAME* aCaller, MODULE* aModule )
return success;
}
#endif
void DIALOG_IMPORT_GFX::OriginOptionOnUpdateUI( wxUpdateUIEvent& event )
{

View File

@ -115,50 +115,25 @@ DIALOG_IMPORT_GFX_BASE::DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id,
bSizer4->Add( bSizer7, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer11;
bSizer11 = new wxBoxSizer( wxHORIZONTAL );
m_staticTextScale = new wxStaticText( this, wxID_ANY, _("Scale:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextScale->Wrap( -1 );
bSizer11->Add( m_staticTextScale, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_tcScale = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer11->Add( m_tcScale, 0, wxALIGN_CENTER_VERTICAL, 5 );
bSizer4->Add( bSizer11, 0, wxALL|wxEXPAND, 5 );
bSizer3->Add( bSizer4, 1, wxALIGN_CENTER_VERTICAL, 5 );
bSizer10->Add( bSizer3, 0, wxALL|wxEXPAND, 5 );
wxBoxSizer* bSizer101;
bSizer101 = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizer11;
bSizer11 = new wxBoxSizer( wxHORIZONTAL );
m_staticText6 = new wxStaticText( this, wxID_ANY, _("Height:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText6->Wrap( -1 );
bSizer11->Add( m_staticText6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_tcHeight = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer11->Add( m_tcHeight, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_staticText7 = new wxStaticText( this, wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText7->Wrap( -1 );
bSizer11->Add( m_staticText7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_tcWidth = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_tcWidth->Enable( false );
bSizer11->Add( m_tcWidth, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
bSizer101->Add( bSizer11, 0, wxALL|wxEXPAND, 5 );
wxBoxSizer* bSizer15;
bSizer15 = new wxBoxSizer( wxVERTICAL );
m_cbKeepAspectRatio = new wxCheckBox( this, wxID_ANY, _("Keep aspect ratio"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbKeepAspectRatio->SetValue(true);
bSizer15->Add( m_cbKeepAspectRatio, 0, wxALL, 5 );
bSizer101->Add( bSizer15, 0, wxALL|wxEXPAND, 5 );
bSizer10->Add( bSizer101, 0, wxALL|wxEXPAND, 5 );
bSizerMain->Add( bSizer10, 1, wxALL|wxEXPAND, 5 );
@ -178,14 +153,14 @@ DIALOG_IMPORT_GFX_BASE::DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id,
m_staticline8 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline8, 0, wxALL|wxEXPAND, 5 );
m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( this, wxID_OK );
m_sdbSizer1->AddButton( m_sdbSizer1OK );
m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer1->AddButton( m_sdbSizer1Cancel );
m_sdbSizer1->Realize();
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK );
m_sdbSizerCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer->AddButton( m_sdbSizerCancel );
m_sdbSizer->Realize();
bSizerMain->Add( m_sdbSizer1, 0, wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT, 5 );
bSizerMain->Add( m_sdbSizer, 0, wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT, 5 );
this->SetSizer( bSizerMain );
@ -197,10 +172,9 @@ DIALOG_IMPORT_GFX_BASE::DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id,
// Connect Events
m_buttonBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::OnBrowseFiles ), NULL, this );
m_rbOffsetOption->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_IMPORT_GFX_BASE::OriginOptionOnUpdateUI ), NULL, this );
m_tcHeight->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_IMPORT_GFX_BASE::onChangeHeight ), NULL, this );
m_cbKeepAspectRatio->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_IMPORT_GFX_BASE::onKeepAspectRatioUpdate ), NULL, this );
m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::OnCancelClick ), NULL, this );
m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::OnOKClick ), NULL, this );
m_tcScale->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_IMPORT_GFX_BASE::onChangeHeight ), NULL, this );
m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::OnCancelClick ), NULL, this );
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::OnOKClick ), NULL, this );
}
DIALOG_IMPORT_GFX_BASE::~DIALOG_IMPORT_GFX_BASE()
@ -208,9 +182,8 @@ DIALOG_IMPORT_GFX_BASE::~DIALOG_IMPORT_GFX_BASE()
// Disconnect Events
m_buttonBrowse->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::OnBrowseFiles ), NULL, this );
m_rbOffsetOption->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_IMPORT_GFX_BASE::OriginOptionOnUpdateUI ), NULL, this );
m_tcHeight->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_IMPORT_GFX_BASE::onChangeHeight ), NULL, this );
m_cbKeepAspectRatio->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_IMPORT_GFX_BASE::onKeepAspectRatioUpdate ), NULL, this );
m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::OnCancelClick ), NULL, this );
m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::OnOKClick ), NULL, this );
m_tcScale->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_IMPORT_GFX_BASE::onChangeHeight ), NULL, this );
m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::OnCancelClick ), NULL, this );
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::OnOKClick ), NULL, this );
}

View File

@ -722,11 +722,11 @@
<event name="OnUpdateUI">OriginOptionOnUpdateUI</event>
</object>
</object>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="0">
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer4</property>
<property name="orient">wxVERTICAL</property>
@ -931,11 +931,11 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="0">
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer7</property>
<property name="orient">wxHORIZONTAL</property>
@ -1131,510 +1131,204 @@
</object>
</object>
</object>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer101</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer11</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Height:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText6</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption">Set imported image height in PCB</property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_tcHeight</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NUMERIC</property>
<property name="validator_type">wxTextValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnText"></event>
<event name="OnTextEnter"></event>
<event name="OnTextMaxLen"></event>
<event name="OnTextURL"></event>
<event name="OnUpdateUI">onChangeHeight</event>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Width:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText7</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption">Set imported image width in PCB</property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">0</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_tcWidth</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NUMERIC</property>
<property name="validator_type">wxTextValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnText"></event>
<event name="OnTextEnter"></event>
<event name="OnTextMaxLen"></event>
<event name="OnTextURL"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer15</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption">Keep aspect ratio of original image</property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">1</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Keep aspect ratio</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_cbKeepAspectRatio</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnCheckBox"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI">onKeepAspectRatioUpdate</event>
<property name="name">bSizer11</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Scale:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticTextScale</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption">Set imported image height in PCB</property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_tcScale</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NUMERIC</property>
<property name="validator_type">wxTextValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnText"></event>
<event name="OnTextEnter"></event>
<event name="OnTextMaxLen"></event>
<event name="OnTextURL"></event>
<event name="OnUpdateUI">onChangeHeight</event>
</object>
</object>
</object>
</object>
</object>
@ -1945,7 +1639,7 @@
<property name="Save">0</property>
<property name="Yes">0</property>
<property name="minimum_size"></property>
<property name="name">m_sdbSizer1</property>
<property name="name">m_sdbSizer</property>
<property name="permission">protected</property>
<event name="OnApplyButtonClick"></event>
<event name="OnCancelButtonClick">OnCancelClick</event>

View File

@ -29,7 +29,6 @@ class PCB_LAYER_BOX_SELECTOR;
#include <wx/choice.h>
#include <wx/radiobox.h>
#include <wx/valtext.h>
#include <wx/checkbox.h>
#include <wx/bmpcbox.h>
#include <wx/statline.h>
#include <wx/dialog.h>
@ -56,23 +55,19 @@ class DIALOG_IMPORT_GFX_BASE : public DIALOG_SHIM
wxTextCtrl* m_PCBXCoord;
wxStaticText* m_staticText5;
wxTextCtrl* m_PCBYCoord;
wxStaticText* m_staticText6;
wxTextCtrl* m_tcHeight;
wxStaticText* m_staticText7;
wxTextCtrl* m_tcWidth;
wxCheckBox* m_cbKeepAspectRatio;
wxStaticText* m_staticTextScale;
wxTextCtrl* m_tcScale;
wxStaticText* m_staticTextBrdlayer;
PCB_LAYER_BOX_SELECTOR* m_SelLayerBox;
wxStaticLine* m_staticline8;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Cancel;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnBrowseFiles( wxCommandEvent& event ) { event.Skip(); }
virtual void OriginOptionOnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void onChangeHeight( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void onKeepAspectRatioUpdate( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOKClick( wxCommandEvent& event ) { event.Skip(); }

View File

@ -22,16 +22,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
// The DXF reader lib (libdxfrw) comes from LibreCAD project, a 2D CAD program
// libdxfrw can be found on http://sourceforge.net/projects/libdxfrw/
// or (latest sources) on
// https://github.com/LibreCAD/LibreCAD/tree/master/libraries/libdxfrw/src
//
// There is no doc to use it, but have a look to
// https://github.com/LibreCAD/LibreCAD/blob/master/librecad/src/lib/filters/rs_filterdxf.cpp
// and https://github.com/LibreCAD/LibreCAD/blob/master/librecad/src/lib/filters/rs_filterdxf.h
// The DXF reader lib (libdxfrw) comes from dxflib project used in QCAD
// See http://www.ribbonsoft.com
// Each time a dxf entity is read, a "call back" fuction is called
// like void DXF_IMPORT_PLUGIN::addLine( const DRW_Line& data ) when a line is read.
// like void DXF_IMPORT_PLUGIN::addLine( const DL_LineData& data ) when a line is read.
// this function just add the BOARD entity from dxf parameters (start and end point ...)
@ -75,16 +69,14 @@ DXF_IMPORT_PLUGIN::~DXF_IMPORT_PLUGIN()
bool DXF_IMPORT_PLUGIN::Load( const wxString& aFileName )
{
//dxfRW dxf( aFileName.ToUTF8() );
//return dxf.read( this, true );
return true;
return ImportDxfFile( aFileName );
}
bool DXF_IMPORT_PLUGIN::Import( float aXScale, float aYScale )
{
//wxCHECK( m_importer, false );
//m_internalImporter.ImportTo( *m_importer );
wxCHECK( m_importer, false );
m_internalImporter.ImportTo( *m_importer );
return true;
}
@ -203,7 +195,7 @@ void DXF_IMPORT_PLUGIN::addLayer( const DL_LayerData& aData )
void DXF_IMPORT_PLUGIN::addLine( const DL_LineData& aData )
{
DRAWSEGMENT* segm = ( m_importAsfootprintGraphicItems ) ?
/* DRAWSEGMENT* segm = ( m_importAsfootprintGraphicItems ) ?
static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : new DRAWSEGMENT;
segm->SetLayer( ToLAYER_ID( m_brdLayer ) );
@ -212,7 +204,14 @@ void DXF_IMPORT_PLUGIN::addLine( const DL_LineData& aData )
wxPoint end( mapX( aData.x2 ), mapY( aData.y2 ) );
segm->SetEnd( end );
segm->SetWidth( mapWidth( attributes.getWidth() ) );
m_newItemsList.push_back( segm );
m_newItemsList.push_back( segm );*/
VECTOR2D start( mapX( aData.x1 ), mapY( aData.y1 ) );
VECTOR2D end( mapX( aData.x2 ), mapY( aData.y2 ) );
m_internalImporter.AddLine( start, end );
updateImageLimits( start );
updateImageLimits( end );
}
@ -295,7 +294,7 @@ void DXF_IMPORT_PLUGIN::endEntity()
void DXF_IMPORT_PLUGIN::addCircle( const DL_CircleData& aData )
{
DRAWSEGMENT* segm = ( m_importAsfootprintGraphicItems ) ?
/* DRAWSEGMENT* segm = ( m_importAsfootprintGraphicItems ) ?
static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : new DRAWSEGMENT;
segm->SetLayer( ToLAYER_ID( m_brdLayer ) );
@ -306,6 +305,14 @@ void DXF_IMPORT_PLUGIN::addCircle( const DL_CircleData& aData )
segm->SetArcStart( circle_start );
segm->SetWidth( mapWidth( attributes.getWidth() ) );
m_newItemsList.push_back( segm );
*/
VECTOR2D center( mapX( aData.cx ), mapY( aData.cy ) );
m_internalImporter.AddCircle( center, mapDim( aData.radius ) );
VECTOR2D radiusDelta( mapDim( aData.radius ), mapDim( aData.radius ) );
updateImageLimits( center + radiusDelta );
updateImageLimits( center - radiusDelta );
}
@ -314,6 +321,7 @@ void DXF_IMPORT_PLUGIN::addCircle( const DL_CircleData& aData )
*/
void DXF_IMPORT_PLUGIN::addArc( const DL_ArcData& aData )
{
/*
DRAWSEGMENT* segm = ( m_importAsfootprintGraphicItems ) ?
static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : new DRAWSEGMENT;
@ -349,11 +357,41 @@ void DXF_IMPORT_PLUGIN::addArc( const DL_ArcData& aData )
segm->SetWidth( mapWidth( attributes.getWidth() ) );
m_newItemsList.push_back( segm );
*/
// Init arc centre:
VECTOR2D center( mapX( aData.cx ), mapY( aData.cy ) );
// Init arc start point
double arcStartx = aData.radius;
double arcStarty = 0;
// aData.anglex is in degrees. Our internal units are 0.1 degree
// so convert DXF angles to our units
#define DXF2ANGLEUI 10
double startangle = aData.angle1 * DXF2ANGLEUI;
double endangle = aData.angle2 * DXF2ANGLEUI;
RotatePoint( &arcStartx, &arcStarty, -RAD2DECIDEG( startangle ) );
wxPoint arcStart( mapX( arcStartx + aData.cx ), mapY( arcStarty + aData.cy ) );
// calculate arc angle (arcs are CCW, and should be < 0 in Pcbnew)
double angle = -( endangle - startangle );
if( angle > 0.0 )
angle -= 3600.0;
m_internalImporter.AddArc( center, arcStart, angle );
VECTOR2D radiusDelta( mapDim( aData.radius ), mapDim( aData.radius ) );
updateImageLimits( center + radiusDelta );
updateImageLimits( center - radiusDelta );
}
void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData )
{
#if 0
BOARD_ITEM* brdItem;
EDA_TEXT* textItem;
@ -454,18 +492,150 @@ void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData )
textItem->SetTextPos( refPoint );
textItem->SetTextAngle( aData.angle * 10 );
// The 0.8 factor gives a better height/width ratio with our font
textItem->SetTextWidth( mapDim( aData.height * 0.8 ) );
// The 0.9 factor gives a better height/width ratio with our font
textItem->SetTextWidth( mapDim( aData.height * 0.9 ) );
textItem->SetTextHeight( mapDim( aData.height ) );
textItem->SetThickness( mapWidth( aData.height * DEFAULT_TEXT_WIDTH ) ); // Gives a reasonable text thickness
textItem->SetText( text );
m_newItemsList.push_back( static_cast< BOARD_ITEM* >( brdItem ) );
#endif
wxPoint refPoint( mapX( aData.ipx ), mapY( aData.ipy ) );
wxPoint secPoint( mapX( aData.apx ), mapY( aData.apy ) );
if( aData.vJustification != 0 || aData.hJustification != 0 || aData.hJustification == 4 )
{
if( aData.hJustification != 3 && aData.hJustification != 5 )
{
wxPoint tmp = secPoint;
secPoint = refPoint;
refPoint = tmp;
}
}
wxString text = toNativeString( wxString::FromUTF8( aData.text.c_str() ) );
double textHeight = mapDim( aData.height );
// The 0.9 factor gives a better height/width ratio with our font
double charWidth = textHeight * 0.9;
double textWidth = charWidth * text.length(); // Rough approximation
VECTOR2D bottomLeft(0.0, 0.0);
VECTOR2D bottomRight(0.0, 0.0);
VECTOR2D topLeft(0.0, 0.0);
VECTOR2D topRight(0.0, 0.0);
EDA_TEXT_HJUSTIFY_T hJustify = GR_TEXT_HJUSTIFY_LEFT;
EDA_TEXT_VJUSTIFY_T vJustify = GR_TEXT_VJUSTIFY_BOTTOM;
switch( aData.vJustification )
{
case 0: //DRW_Text::VBaseLine:
case 1: //DRW_Text::VBottom:
vJustify = GR_TEXT_VJUSTIFY_BOTTOM;
topLeft.y = textHeight;
topRight.y = textHeight;
break;
case 2: //DRW_Text::VMiddle:
vJustify = GR_TEXT_VJUSTIFY_CENTER;
bottomRight.y = -textHeight / 2.0;
bottomLeft.y = -textHeight / 2.0;
topLeft.y = textHeight / 2.0;
topRight.y = textHeight / 2.0;
break;
case 3: //DRW_Text::VTop:
vJustify = GR_TEXT_VJUSTIFY_TOP;
bottomLeft.y = -textHeight;
bottomRight.y = -textHeight;
break;
}
switch( aData.hJustification )
{
case 0: //DRW_Text::HLeft:
case 3: //DRW_Text::HAligned: // no equivalent options in text pcb.
case 5: //DRW_Text::HFit: // no equivalent options in text pcb.
hJustify = GR_TEXT_HJUSTIFY_LEFT;
bottomRight.x = textWidth;
topRight.x = textWidth;
break;
case 1: //DRW_Text::HCenter:
case 4: //DRW_Text::HMiddle: // no equivalent options in text pcb.
hJustify = GR_TEXT_HJUSTIFY_CENTER;
bottomLeft.x = -textWidth / 2.0;
topLeft.x = -textWidth / 2.0;
bottomRight.x = textWidth / 2.0;
topRight.x = textWidth / 2.0;
break;
case 2: //DRW_Text::HRight:
hJustify = GR_TEXT_HJUSTIFY_RIGHT;
bottomLeft.x = -textWidth;
topLeft.x = -textWidth;
break;
}
#if 0
wxString sty = wxString::FromUTF8( aData.style.c_str() );
sty = sty.ToLower();
if( aData.textgen == 2 )
{
// Text dir = left to right;
} else if( aData.textgen == 4 )
{
// Text dir = top to bottom;
} else
{
}
#endif
double angle = aData.angle * 10;
double angleInRads = angle / 10.0 * M_PI / 180.0;
double cosine = cos(angleInRads);
double sine = sin(angleInRads);
m_internalImporter.AddText( refPoint, text, textHeight, charWidth, angle,
hJustify, vJustify );
// Calculate the boundary box and update the image limits:
bottomLeft.x = bottomLeft.x * cosine - bottomLeft.y * sine;
bottomLeft.y = bottomLeft.x * sine + bottomLeft.y * cosine;
bottomRight.x = bottomRight.x * cosine - bottomRight.y * sine;
bottomRight.y = bottomRight.x * sine + bottomRight.y * cosine;
topLeft.x = topLeft.x * cosine - topLeft.y * sine;
topLeft.y = topLeft.x * sine + topLeft.y * cosine;
topRight.x = topRight.x * cosine - topRight.y * sine;
topRight.y = topRight.x * sine + topRight.y * cosine;
bottomLeft += refPoint;
bottomRight += refPoint;
topLeft += refPoint;
topRight += refPoint;
updateImageLimits( bottomLeft );
updateImageLimits( bottomRight );
updateImageLimits( topLeft );
updateImageLimits( topRight );
}
void DXF_IMPORT_PLUGIN::addMText( const DL_MTextData& aData )
{
#if 0
wxString text = toNativeString( wxString::FromUTF8( aData.text.c_str() ) );
wxString attrib, tmp;
@ -516,8 +686,8 @@ void DXF_IMPORT_PLUGIN::addMText( const DL_MTextData& aData )
textItem->SetTextPos( textpos );
textItem->SetTextAngle( aData.angle * 10 );
// The 0.8 factor gives a better height/width ratio with our font
textItem->SetTextWidth( mapDim( aData.height * 0.8 ) );
// The 0.9 factor gives a better height/width ratio with our font
textItem->SetTextWidth( mapDim( aData.height * 0.9 ) );
textItem->SetTextHeight( mapDim( aData.height ) );
textItem->SetThickness( mapWidth( aData.height * DEFAULT_TEXT_WIDTH ) ); // Gives a reasonable text thickness
textItem->SetText( text );
@ -574,6 +744,152 @@ void DXF_IMPORT_PLUGIN::addMText( const DL_MTextData& aData )
#endif
m_newItemsList.push_back( static_cast< BOARD_ITEM* >( brdItem ) );
#endif
wxString text = toNativeString( wxString::FromUTF8( aData.text.c_str() ) );
wxString attrib, tmp;
double textHeight = mapDim( aData.height );
// The 0.9 factor gives a better height/width ratio with our font
double charWidth = textHeight * 0.9;
double textWidth = charWidth * text.length(); // Rough approximation
wxRealPoint bottomLeft(0.0, 0.0);
wxRealPoint bottomRight(0.0, 0.0);
wxRealPoint topLeft(0.0, 0.0);
wxRealPoint topRight(0.0, 0.0);
/* Some texts start by '\' and have formating chars (font name, font option...)
* ending with ';'
* Here are some mtext formatting codes:
* Format code Purpose
* \0...\o Turns overline on and off
* \L...\l Turns underline on and off
* \~ Inserts a nonbreaking space
\\ Inserts a backslash
\\\{...\} Inserts an opening and closing brace
\\ \File name; Changes to the specified font file
\\ \Hvalue; Changes to the text height specified in drawing units
\\ \Hvaluex; Changes the text height to a multiple of the current text height
\\ \S...^...; Stacks the subsequent text at the \, #, or ^ symbol
\\ \Tvalue; Adjusts the space between characters, from.75 to 4 times
\\ \Qangle; Changes obliquing angle
\\ \Wvalue; Changes width factor to produce wide text
\\ \A Sets the alignment value; valid values: 0, 1, 2 (bottom, center, top) while( text.StartsWith( wxT("\\") ) )
*/
while( text.StartsWith( wxT( "\\" ) ) )
{
attrib << text.BeforeFirst( ';' );
tmp = text.AfterFirst( ';' );
text = tmp;
}
wxPoint textpos( mapX( aData.ipx ), mapY( aData.ipy ) );
// Initialize text justifications:
EDA_TEXT_HJUSTIFY_T hJustify = GR_TEXT_HJUSTIFY_LEFT;
EDA_TEXT_VJUSTIFY_T vJustify = GR_TEXT_VJUSTIFY_BOTTOM;
if( aData.attachmentPoint <= 3 )
{
vJustify = GR_TEXT_VJUSTIFY_TOP;
bottomLeft.y = -textHeight;
bottomRight.y = -textHeight;
}
else if( aData.attachmentPoint <= 6 )
{
vJustify = GR_TEXT_VJUSTIFY_CENTER;
bottomRight.y = -textHeight / 2.0;
bottomLeft.y = -textHeight / 2.0;
topLeft.y = textHeight / 2.0;
topRight.y = textHeight / 2.0;
}
else
{
vJustify = GR_TEXT_VJUSTIFY_BOTTOM;
topLeft.y = textHeight;
topRight.y = textHeight;
}
if( aData.attachmentPoint % 3 == 1 )
{
hJustify = GR_TEXT_HJUSTIFY_LEFT;
bottomRight.x = textWidth;
topRight.x = textWidth;
}
else if( aData.attachmentPoint % 3 == 2 )
{
hJustify = GR_TEXT_HJUSTIFY_CENTER;
bottomLeft.x = -textWidth / 2.0;
topLeft.x = -textWidth / 2.0;
bottomRight.x = textWidth / 2.0;
topRight.x = textWidth / 2.0;
}
else
{
hJustify = GR_TEXT_HJUSTIFY_RIGHT;
bottomLeft.x = -textWidth;
topLeft.x = -textWidth;
}
#if 0 // These setting have no mening in Pcbnew
if( data.alignH == 1 )
{
// Text is left to right;
}
else if( data.alignH == 3 )
{
// Text is top to bottom;
}
else
{
// use ByStyle;
}
if( aData.alignV == 1 )
{
// use AtLeast;
}
else
{
// useExact;
}
#endif
double angle = aData.angle * 10;
double angleInRads = angle / 10.0 * M_PI / 180.0;
double cosine = cos(angleInRads);
double sine = sin(angleInRads);
m_internalImporter.AddText( textpos, text, textHeight, charWidth, angle, hJustify, vJustify );
bottomLeft.x = bottomLeft.x * cosine - bottomLeft.y * sine;
bottomLeft.y = bottomLeft.x * sine + bottomLeft.y * cosine;
bottomRight.x = bottomRight.x * cosine - bottomRight.y * sine;
bottomRight.y = bottomRight.x * sine + bottomRight.y * cosine;
topLeft.x = topLeft.x * cosine - topLeft.y * sine;
topLeft.y = topLeft.x * sine + topLeft.y * cosine;
topRight.x = topRight.x * cosine - topRight.y * sine;
topRight.y = topRight.x * sine + topRight.y * cosine;
bottomLeft += textpos;
bottomRight += textpos;
topLeft += textpos;
topRight += textpos;
updateImageLimits( bottomLeft );
updateImageLimits( bottomRight );
updateImageLimits( topLeft );
updateImageLimits( topRight );
}
@ -803,6 +1119,7 @@ void DXF_IMPORT_PLUGIN::addTextStyle( const DL_StyleData& aData )
void DXF_IMPORT_PLUGIN::insertLine( const wxRealPoint& aSegStart,
const wxRealPoint& aSegEnd, int aWidth )
{
#if 0
DRAWSEGMENT* segm = ( m_importAsfootprintGraphicItems ) ?
static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : new DRAWSEGMENT;
wxPoint segment_startpoint( Millimeter2iu( aSegStart.x ), Millimeter2iu( aSegStart.y ) );
@ -814,17 +1131,24 @@ void DXF_IMPORT_PLUGIN::insertLine( const wxRealPoint& aSegStart,
segm->SetWidth( aWidth );
m_newItemsList.push_back( segm );
#endif
VECTOR2D origin( Millimeter2iu( aSegStart.x ), Millimeter2iu( aSegStart.y ) );
VECTOR2D end( Millimeter2iu( aSegEnd.x ), Millimeter2iu( aSegEnd.y ) );
m_internalImporter.AddLine( origin, end );
updateImageLimits( origin );
updateImageLimits( end );
}
void DXF_IMPORT_PLUGIN::insertArc( const wxRealPoint& aSegStart, const wxRealPoint& aSegEnd,
double aBulge, int aWidth )
{
DRAWSEGMENT* segm = ( m_importAsfootprintGraphicItems ) ?
/* DRAWSEGMENT* segm = ( m_importAsfootprintGraphicItems ) ?
static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : new DRAWSEGMENT;
wxPoint segment_startpoint( Millimeter2iu( aSegStart.x ), Millimeter2iu( aSegStart.y ) );
wxPoint segment_endpoint( Millimeter2iu( aSegEnd.x ), Millimeter2iu( aSegEnd.y ) );
*/
VECTOR2D segment_startpoint( Millimeter2iu( aSegStart.x ), Millimeter2iu( aSegStart.y ) );
VECTOR2D segment_endpoint( Millimeter2iu( aSegEnd.x ), Millimeter2iu( aSegEnd.y ) );
// ensure aBulge represents an angle from +/- ( 0 .. approx 359.8 deg )
if( aBulge < -2000.0 )
@ -835,8 +1159,8 @@ void DXF_IMPORT_PLUGIN::insertArc( const wxRealPoint& aSegStart, const wxRealPoi
double ang = 4.0 * atan( aBulge );
// reflect the Y values to put everything in a RHCS
wxRealPoint sp( aSegStart.x, -aSegStart.y );
wxRealPoint ep( aSegEnd.x, -aSegEnd.y );
VECTOR2D sp( aSegStart.x, -aSegStart.y );
VECTOR2D ep( aSegEnd.x, -aSegEnd.y );
// angle from end->start
double offAng = atan2( ep.y - sp.y, ep.x - sp.x );
// length of subtended segment = 1/2 distance between the 2 points
@ -874,25 +1198,37 @@ void DXF_IMPORT_PLUGIN::insertArc( const wxRealPoint& aSegStart, const wxRealPoi
// center point
double cx = h * cos( offAng ) + xm;
double cy = h * sin( offAng ) + ym;
VECTOR2D center( Millimeter2iu( cx ), Millimeter2iu( -cy ) );
VECTOR2D arc_start;
double angle = RAD2DECIDEG( ang );
segm->SetLayer( ToLAYER_ID( m_brdLayer ) );
segm->SetShape( S_ARC );
segm->SetCenter( wxPoint( Millimeter2iu( cx ), Millimeter2iu( -cy ) ) );
//segm->SetLayer( ToLAYER_ID( m_brdLayer ) );
//segm->SetShape( S_ARC );
//segm->SetCenter( wxPoint( Millimeter2iu( cx ), Millimeter2iu( -cy ) ) );
if( ang < 0.0 )
{
segm->SetArcStart( wxPoint( Millimeter2iu( ep.x ), Millimeter2iu( -ep.y ) ) );
segm->SetAngle( RAD2DECIDEG( ang ) );
arc_start = VECTOR2D( Millimeter2iu( ep.x ), Millimeter2iu( -ep.y ) );
//segm->SetArcStart( wxPoint( Millimeter2iu( ep.x ), Millimeter2iu( -ep.y ) ) );
//segm->SetAngle( RAD2DECIDEG( ang ) );
}
else
{
segm->SetArcStart( wxPoint( Millimeter2iu( sp.x ), Millimeter2iu( -sp.y ) ) );
segm->SetAngle( RAD2DECIDEG( -ang ) );
arc_start = VECTOR2D( Millimeter2iu( sp.x ), Millimeter2iu( -sp.y ) );
angle = -angle;
//segm->SetArcStart( wxPoint( Millimeter2iu( sp.x ), Millimeter2iu( -sp.y ) ) );
//segm->SetAngle( RAD2DECIDEG( -ang ) );
}
segm->SetWidth( aWidth );
//segm->SetWidth( aWidth );
//m_newItemsList.push_back( segm );
m_newItemsList.push_back( segm );
m_internalImporter.AddArc( center, arc_start, angle );
wxPoint radiusDelta( Millimeter2iu( radius ), Millimeter2iu( radius ) );
updateImageLimits( center + radiusDelta );
updateImageLimits( center - radiusDelta );
return;
}
@ -958,6 +1294,7 @@ void DXF_IMPORT_PLUGIN::insertSpline( int aWidth )
// So we can have more than one Bezier curve ( there are one curve each four vertices)
for( unsigned ii = 0; ii < coords.size(); ii += 8 )
{
#if 0
DRAWSEGMENT* segm = ( m_importAsfootprintGraphicItems ) ?
static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) :
new DRAWSEGMENT;
@ -970,7 +1307,36 @@ void DXF_IMPORT_PLUGIN::insertSpline( int aWidth )
segm->SetWidth( aWidth );
segm->RebuildBezierToSegmentsPointsList( aWidth );
m_newItemsList.push_back( segm );
#endif
VECTOR2D start( mapX( coords[ii] ), mapY( coords[ii+1] ) );
VECTOR2D bezierControl1( mapX( coords[ii+2] ), mapY( coords[ii+3] ) );
VECTOR2D bezierControl2( mapX( coords[ii+4] ), mapY( coords[ii+5] ) );
VECTOR2D end( mapX( coords[ii+6] ), mapY( coords[ii+7] ) );
m_internalImporter.AddSpline( start, bezierControl1, bezierControl2, end , aWidth );
}
#endif
}
void DXF_IMPORT_PLUGIN::updateImageLimits( const VECTOR2D& aPoint )
{
wxPoint truncatedPoint( (int)aPoint.x, (int)aPoint.y );
updateImageLimits( truncatedPoint );
}
void DXF_IMPORT_PLUGIN::updateImageLimits( const wxRealPoint& aPoint )
{
updateImageLimits( VECTOR2D( aPoint.x, aPoint.y ) );
}
void DXF_IMPORT_PLUGIN::updateImageLimits( const wxPoint& aPoint )
{
m_minX = std::min( aPoint.x, m_minX );
m_maxX = std::max( aPoint.x, m_maxX );
m_minY = std::min( aPoint.y, m_minY );
m_maxY = std::max( aPoint.y, m_maxY );
}

View File

@ -129,8 +129,8 @@ private:
// Each message ends by '\n'
DXF2BRD_ENTITY_DATA m_curr_entity; // the current entity parameters when parsing a DXF entity
int m_minX, m_maxX;
int m_minY, m_maxY;
int m_minX, m_maxX; // handles image size
int m_minY, m_maxY; // handles image size
GRAPHICS_IMPORTER_BUFFER m_internalImporter;
@ -155,6 +155,10 @@ public:
unsigned int GetImageWidth() const override;
unsigned int GetImageHeight() const override;
void updateImageLimits( const wxPoint& aPoint );
void updateImageLimits( const wxRealPoint& aPoint );
void updateImageLimits( const VECTOR2D& aPoint );
/**
* Allows the import DXF items converted to board graphic items or footprint
* graphic items.

View File

@ -110,23 +110,6 @@ public:
}
/**
* @brief Sets scale affecting the imported shapes, for the X direction.
*/
void SetXScale( double aScale )
{
m_xScale = aScale;
}
/**
* @brief Sets scale affecting the imported shapes, for the Y direction.
*/
void SetYScale( double aScale )
{
m_yScale = aScale;
}
/**
* @brief Returns the scale factor affecting the imported shapes.
*/
@ -169,14 +152,14 @@ public:
* @param aCenter is the circle center point expressed in internal units.
* @param aRadius is the circle radius expressed in internal units.
*/
virtual void AddCircle( const VECTOR2D& aCenter, unsigned int aRadius ) = 0;
virtual void AddCircle( const VECTOR2D& aCenter, double aRadius ) = 0;
/**
* @brief Creates an object representing an arc.
* @param aCenter is the arc center point expressed in internal units.
* @param aStart is the arc arm end point expressed in internal units.
* Its length is the arc radius.
* @param aAgnle is the arc angle expressed in decidegrees.
* @param aAngle is the arc angle expressed in decidegrees.
*/
virtual void AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart, double aAngle ) = 0;
@ -195,9 +178,12 @@ public:
* @param aVJustify is the text vertical justification.
*/
virtual void AddText( const VECTOR2D& aOrigin, const wxString& aText,
unsigned int aHeight, unsigned aWidth, double aOrientation,
double aHeight, double, double aOrientation,
EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify ) = 0;
virtual void AddSpline( const VECTOR2D& aStart, const VECTOR2D& aBezierControl1,
const VECTOR2D& aBezierControl2, const VECTOR2D& aEnd, double aWidth ) = 0;
protected:
///> Adds an item to the imported shapes list.
void addItem( std::unique_ptr<EDA_ITEM> aItem )
@ -221,12 +207,6 @@ private:
///> Default line thickness for the imported graphics
unsigned int m_lineWidth;
///> Scale factor applied to the imported graphics, X direction
double m_xScale;
///> Scale factor applied to the imported graphics, Y direction
double m_yScale;
///> Scale factor applied to the imported graphics
double m_scale;

View File

@ -38,7 +38,7 @@ void GRAPHICS_IMPORTER_BUFFER::AddLine( const VECTOR2D& aStart, const VECTOR2D&
}
void GRAPHICS_IMPORTER_BUFFER::AddCircle( const VECTOR2D& aCenter, unsigned int aRadius )
void GRAPHICS_IMPORTER_BUFFER::AddCircle( const VECTOR2D& aCenter, double aRadius )
{
m_shapes.push_back( make_shape< IMPORTED_CIRCLE >( aCenter, aRadius ) );
}
@ -58,13 +58,21 @@ void GRAPHICS_IMPORTER_BUFFER::AddPolygon( const std::vector< VECTOR2D >& aVerti
void GRAPHICS_IMPORTER_BUFFER::AddText( const VECTOR2D& aOrigin, const wxString& aText,
unsigned int aHeight, unsigned aWidth, double aOrientation,
double aHeight, double aWidth, double aOrientation,
EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify )
{
m_shapes.push_back( make_shape< IMPORTED_TEXT >( aOrigin, aText, aHeight, aWidth, aOrientation,
aHJustify, aVJustify ) );
}
void GRAPHICS_IMPORTER_BUFFER::AddSpline( const VECTOR2D& aStart, const VECTOR2D& aBezierControl1,
const VECTOR2D& aBezierControl2, const VECTOR2D& aEnd , double aWidth )
{
m_shapes.push_back( make_shape< IMPORTED_SPLINE >( aStart, aBezierControl1, aBezierControl2, aEnd, aWidth ) );
}
void GRAPHICS_IMPORTER_BUFFER::ImportTo( GRAPHICS_IMPORTER& aImporter )
{
for( auto& shape : m_shapes )

View File

@ -116,7 +116,7 @@ class IMPORTED_TEXT : public IMPORTED_SHAPE
{
public:
IMPORTED_TEXT( const VECTOR2D& aOrigin, const wxString& aText,
unsigned int aHeight, unsigned aWidth, double aOrientation,
double aHeight, double aWidth, double aOrientation,
EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify )
: m_origin( aOrigin ), m_text( aText ),
m_height( aHeight ), m_width( aWidth ),
@ -132,31 +132,58 @@ public:
}
private:
const VECTOR2D& m_origin;
const wxString& m_text;
unsigned int m_height;
unsigned int m_width;
const VECTOR2D m_origin;
const wxString m_text;
double m_height;
double m_width;
double m_orientation;
EDA_TEXT_HJUSTIFY_T m_hJustify;
EDA_TEXT_VJUSTIFY_T m_vJustify;
};
class IMPORTED_SPLINE : public IMPORTED_SHAPE
{
public:
IMPORTED_SPLINE( const VECTOR2D& aStart, const VECTOR2D& aBezierControl1,
const VECTOR2D& aBezierControl2, const VECTOR2D& aEnd, double aWidth )
: m_start( aStart ), m_bezierControl1( aBezierControl1 ),
m_bezierControl2( aBezierControl2 ), m_end( aEnd ), m_width( aWidth )
{
}
void ImportTo( GRAPHICS_IMPORTER& aImporter ) const override
{
aImporter.AddSpline( m_start, m_bezierControl1, m_bezierControl2, m_end, m_width );
}
private:
const VECTOR2D m_start;
const VECTOR2D m_bezierControl1;
const VECTOR2D m_bezierControl2;
const VECTOR2D m_end;
double m_width;
};
class GRAPHICS_IMPORTER_BUFFER : public GRAPHICS_IMPORTER
{
public:
void AddLine( const VECTOR2D& aStart, const VECTOR2D& aEnd ) override;
void AddCircle( const VECTOR2D& aCenter, unsigned int aRadius ) override;
void AddCircle( const VECTOR2D& aCenter, double aRadius ) override;
void AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart, double aAngle ) override;
void AddPolygon( const std::vector< VECTOR2D >& aVertices ) override;
void AddText( const VECTOR2D& aOrigin, const wxString& aText,
unsigned int aHeight, unsigned aWidth, double aOrientation,
double aHeight, double aWidth, double aOrientation,
EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify ) override;
void AddSpline( const VECTOR2D& aStart, const VECTOR2D& BezierControl1,
const VECTOR2D& BezierControl2, const VECTOR2D& aEnd , double aWidth ) override;
void ImportTo( GRAPHICS_IMPORTER& aImporter );
protected:

View File

@ -54,7 +54,7 @@ void GRAPHICS_IMPORTER_PCBNEW::AddLine( const VECTOR2D& aOrigin, const VECTOR2D&
}
void GRAPHICS_IMPORTER_PCBNEW::AddCircle( const VECTOR2D& aCenter, unsigned int aRadius )
void GRAPHICS_IMPORTER_PCBNEW::AddCircle( const VECTOR2D& aCenter, double aRadius )
{
unique_ptr<DRAWSEGMENT> circle( createDrawing() );
circle->SetShape( S_CIRCLE );
@ -91,7 +91,7 @@ void GRAPHICS_IMPORTER_PCBNEW::AddPolygon( const std::vector< VECTOR2D >& aVerti
void GRAPHICS_IMPORTER_PCBNEW::AddText( const VECTOR2D& aOrigin, const wxString& aText,
unsigned int aHeight, unsigned aWidth, double aOrientation,
double aHeight, double aWidth, double aOrientation,
EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify )
{
unique_ptr<BOARD_ITEM> boardItem;
@ -99,10 +99,10 @@ void GRAPHICS_IMPORTER_PCBNEW::AddText( const VECTOR2D& aOrigin, const wxString&
tie( boardItem, textItem ) = createText();
boardItem->SetLayer( GetLayer() );
textItem->SetThickness( GetLineWidth() );
textItem->SetTextPos( Round ( aOrigin * GetScale() ) );
textItem->SetTextPos( Round( aOrigin * GetScale() ) );
textItem->SetTextAngle( aOrientation );
textItem->SetTextWidth( (double)aWidth * GetScale() );
textItem->SetTextHeight( (double)aHeight * GetScale() );
textItem->SetTextWidth( aWidth * GetScale() );
textItem->SetTextHeight( aHeight * GetScale() );
textItem->SetVertJustify( aVJustify );
textItem->SetHorizJustify( aHJustify );
textItem->SetText( aText );
@ -110,6 +110,23 @@ void GRAPHICS_IMPORTER_PCBNEW::AddText( const VECTOR2D& aOrigin, const wxString&
}
void GRAPHICS_IMPORTER_PCBNEW::AddSpline( const VECTOR2D& aStart, const VECTOR2D& BezierControl1,
const VECTOR2D& BezierControl2, const VECTOR2D& aEnd, double aWidth )
{
unique_ptr<DRAWSEGMENT> spline( createDrawing() );
aWidth = GetLineWidth(); // To do: use dxf line thickness if defined
spline->SetShape( S_CURVE );
spline->SetLayer( GetLayer() );
spline->SetWidth( aWidth );
spline->SetStart( Round( aStart * GetScale() ) );
spline->SetBezControl1( Round( BezierControl1 * GetScale() ) );
spline->SetBezControl2( Round( BezierControl2 * GetScale() ) );
spline->SetEnd( Round( aEnd * GetScale() ) );
spline->RebuildBezierToSegmentsPointsList( aWidth );
addItem( std::move( spline ) );
}
unique_ptr<DRAWSEGMENT> GRAPHICS_IMPORTER_BOARD::createDrawing()
{
return unique_ptr<DRAWSEGMENT>( new DRAWSEGMENT( m_board ) );

View File

@ -62,16 +62,19 @@ public:
void AddLine( const VECTOR2D& aOrigin, const VECTOR2D& aEnd ) override;
void AddCircle( const VECTOR2D& aOrigin, unsigned int aRadius ) override;
void AddCircle( const VECTOR2D& aOrigin, double aRadius ) override;
void AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart, double aAngle ) override;
void AddPolygon( const std::vector< VECTOR2D >& aVertices ) override;
void AddText( const VECTOR2D& aOrigin, const wxString& aText,
unsigned int aHeight, unsigned aWidth, double aOrientation,
double aHeight, double aWidth, double aOrientation,
EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify ) override;
void AddSpline( const VECTOR2D& aStart, const VECTOR2D& aBezierControl1,
const VECTOR2D& aBezierControl2, const VECTOR2D& aEnd , double aWidth ) override;
protected:
///> Create an object representing a graphical shape.
virtual std::unique_ptr<DRAWSEGMENT> createDrawing() = 0;

View File

@ -101,9 +101,9 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
_( "Import a footprint from an existing footprint file" ),
KiBitmap( import_module_xpm ) );
AddMenuItem( fileMenu, ID_GEN_IMPORT_DXF_FILE,
_( "Import Outlines from &DXF File..." ),
_( "Import 2D Drawing DXF file to Footprint Editor on Drawings layer" ),
AddMenuItem( fileMenu, ID_GEN_IMPORT_GRAPHICS_FILE,
_( "Import Outlines from &DXF or SVG File..." ),
_( "Import 2D Drawing DXF or SVG file to Footprint Editor on Drawings layer" ),
KiBitmap( import_xpm ) );
AddMenuItem( fileMenu, ID_MODEDIT_EXPORT_PART,

View File

@ -830,9 +830,9 @@ void prepareFilesMenu( wxMenu* aParentMenu, bool aIsOutsideProject )
_( "Import routed \"Specctra Session\" (*.ses) file" ),
KiBitmap( import_xpm ) );
AddMenuItem( submenuImport, ID_GEN_IMPORT_DXF_FILE,
_( "&DXF File..." ),
_( "Import 2D Drawing DXF file to Pcbnew on Drawings layer" ),
AddMenuItem( submenuImport, ID_GEN_IMPORT_GRAPHICS_FILE,
_( "SVG or DXF &Graphics..." ),
_( "Import 2D Drawing DXF or SVG file to Pcbnew on Drawings layer" ),
KiBitmap( import_xpm ) );
AddMenuItem( aParentMenu, submenuImport,

View File

@ -131,7 +131,7 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU( ID_GEN_IMPORT_SPECCTRA_SESSION,PCB_EDIT_FRAME::ImportSpecctraSession )
EVT_MENU( ID_GEN_IMPORT_SPECCTRA_DESIGN, PCB_EDIT_FRAME::ImportSpecctraDesign )
EVT_MENU( ID_GEN_IMPORT_DXF_FILE, PCB_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_GEN_IMPORT_GRAPHICS_FILE, PCB_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_MENU_ARCHIVE_MODULES_IN_LIBRARY, PCB_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_MENU_CREATE_LIBRARY_AND_ARCHIVE_MODULES, PCB_EDIT_FRAME::Process_Special_Functions )

View File

@ -278,7 +278,7 @@ enum pcbnew_ids
ID_GEN_EXPORT_FILE_MODULE_REPORT,
ID_GEN_IMPORT_SPECCTRA_SESSION,
ID_GEN_IMPORT_SPECCTRA_DESIGN,
ID_GEN_IMPORT_DXF_FILE,
ID_GEN_IMPORT_GRAPHICS_FILE,
ID_TOOLBARH_PCB_MODE_MODULE,
ID_TOOLBARH_PCB_MODE_TRACKS,

View File

@ -113,9 +113,9 @@ TOOL_ACTION PCB_ACTIONS::drawSimilarZone( "pcbnew.InteractiveDrawing.similarZone
_( "Add a Similar Zone" ), _( "Add a zone with the same settings as an existing zone" ),
add_zone_xpm, AF_ACTIVATE );
TOOL_ACTION PCB_ACTIONS::placeDXF( "pcbnew.InteractiveDrawing.placeDXF",
TOOL_ACTION PCB_ACTIONS::placeImportedGraphics( "pcbnew.InteractiveDrawing.placeImportedGraphics",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_DXF ),
"Place DXF", "", NULL, AF_ACTIVATE );
"Place Imported Graphics", "", NULL, AF_ACTIVATE );
TOOL_ACTION PCB_ACTIONS::setAnchor( "pcbnew.InteractiveDrawing.setAnchor",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_ANCHOR ),
@ -734,13 +734,15 @@ int DRAWING_TOOL::DrawSimilarZone( const TOOL_EVENT& aEvent )
}
int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
{
if( !m_frame->GetModel() )
return 0;
//DIALOG_DXF_IMPORT dlg( m_frame );
DIALOG_IMPORT_GFX dlg( m_frame, m_editModules );
// Note: PlaceImportedGraphics() will convert PCB_LINE_T and PCB_TEXT_T to module graphic items
// if needed
DIALOG_IMPORT_GFX dlg( m_frame, false );// m_editModules );
int dlgResult = dlg.ShowModal();
/*const std::list<BOARD_ITEM*>*/auto& list = dlg.GetImportedItems();
@ -915,7 +917,7 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
commit.Add( item );
}
commit.Push( _( "Place a DXF drawing" ) );
commit.Push( _( "Place a DXF_SVG drawing" ) );
break;
}
}
@ -1793,7 +1795,7 @@ void DRAWING_TOOL::setTransitions()
Go( &DRAWING_TOOL::DrawSimilarZone, PCB_ACTIONS::drawSimilarZone.MakeEvent() );
Go( &DRAWING_TOOL::DrawVia, PCB_ACTIONS::drawVia.MakeEvent() );
Go( &DRAWING_TOOL::PlaceText, PCB_ACTIONS::placeText.MakeEvent() );
Go( &DRAWING_TOOL::PlaceDXF, PCB_ACTIONS::placeDXF.MakeEvent() );
Go( &DRAWING_TOOL::PlaceImportedGraphics, PCB_ACTIONS::placeImportedGraphics.MakeEvent() );
Go( &DRAWING_TOOL::SetAnchor, PCB_ACTIONS::setAnchor.MakeEvent() );
}

View File

@ -168,10 +168,10 @@ public:
int DrawSimilarZone( const TOOL_EVENT& aEvent );
/**
* Function PlaceDXF()
* Places a drawing imported from a DXF file in module editor.
* Function PlaceImportedGraphics()
* Places a drawing imported from a DXF or SVG file in module editor.
*/
int PlaceDXF( const TOOL_EVENT& aEvent );
int PlaceImportedGraphics( const TOOL_EVENT& aEvent );
/**
* Function SetAnchor()

View File

@ -93,8 +93,8 @@ OPT<TOOL_EVENT> PCB_ACTIONS::TranslateLegacyId( int aId )
case ID_MODEDIT_PAD_TOOL:
return PCB_ACTIONS::placePad.MakeEvent();
case ID_GEN_IMPORT_DXF_FILE:
return PCB_ACTIONS::placeDXF.MakeEvent();
case ID_GEN_IMPORT_GRAPHICS_FILE:
return PCB_ACTIONS::placeImportedGraphics.MakeEvent();
case ID_MODEDIT_ANCHOR_TOOL:
return PCB_ACTIONS::setAnchor.MakeEvent();

View File

@ -177,8 +177,8 @@ public:
/// Activation of the drawing tool (placing a MODULE)
static TOOL_ACTION placeModule;
/// Activation of the drawing tool (placing a drawing from DXF file)
static TOOL_ACTION placeDXF;
/// Activation of the drawing tool (placing a drawing imported from DXF or SVG file)
static TOOL_ACTION placeImportedGraphics;
/// Activation of the drawing tool (placing the footprint anchor)
static TOOL_ACTION setAnchor;