More DXF import fixes.
This commit is contained in:
parent
0fbf31ef38
commit
2a93d083ee
|
@ -32,7 +32,6 @@
|
||||||
#include <kiface_i.h>
|
#include <kiface_i.h>
|
||||||
#include <convert_from_iu.h>
|
#include <convert_from_iu.h>
|
||||||
#include <class_pcb_layer_box_selector.h>
|
#include <class_pcb_layer_box_selector.h>
|
||||||
#include <class_draw_panel_gal.h>
|
|
||||||
|
|
||||||
#include <class_board.h>
|
#include <class_board.h>
|
||||||
#include <class_module.h>
|
#include <class_module.h>
|
||||||
|
@ -181,9 +180,7 @@ bool InvokeDXFDialogBoardImport( PCB_BASE_FRAME* aCaller )
|
||||||
{
|
{
|
||||||
const std::list<BOARD_ITEM*>& list = dlg.GetImportedItems();
|
const std::list<BOARD_ITEM*>& list = dlg.GetImportedItems();
|
||||||
PICKED_ITEMS_LIST picklist;
|
PICKED_ITEMS_LIST picklist;
|
||||||
|
|
||||||
BOARD* board = aCaller->GetBoard();
|
BOARD* board = aCaller->GetBoard();
|
||||||
KIGFX::VIEW* view = aCaller->GetGalCanvas()->GetView();
|
|
||||||
|
|
||||||
std::list<BOARD_ITEM*>::const_iterator it, itEnd;
|
std::list<BOARD_ITEM*>::const_iterator it, itEnd;
|
||||||
for( it = list.begin(), itEnd = list.end(); it != itEnd; ++it )
|
for( it = list.begin(), itEnd = list.end(); it != itEnd; ++it )
|
||||||
|
@ -193,9 +190,6 @@ bool InvokeDXFDialogBoardImport( PCB_BASE_FRAME* aCaller )
|
||||||
|
|
||||||
ITEM_PICKER itemWrapper( item, UR_NEW );
|
ITEM_PICKER itemWrapper( item, UR_NEW );
|
||||||
picklist.PushItem( itemWrapper );
|
picklist.PushItem( itemWrapper );
|
||||||
|
|
||||||
if( aCaller->IsGalCanvasActive() )
|
|
||||||
view->Add( item );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
aCaller->SaveCopyInUndoList( picklist, UR_NEW, wxPoint( 0, 0 ) );
|
aCaller->SaveCopyInUndoList( picklist, UR_NEW, wxPoint( 0, 0 ) );
|
||||||
|
@ -216,7 +210,6 @@ bool InvokeDXFDialogModuleImport( PCB_BASE_FRAME* aCaller, MODULE* aModule )
|
||||||
if( success )
|
if( success )
|
||||||
{
|
{
|
||||||
const std::list<BOARD_ITEM*>& list = dlg.GetImportedItems();
|
const std::list<BOARD_ITEM*>& list = dlg.GetImportedItems();
|
||||||
KIGFX::VIEW* view = aCaller->GetGalCanvas()->GetView();
|
|
||||||
|
|
||||||
aCaller->SaveCopyInUndoList( aModule, UR_MODEDIT );
|
aCaller->SaveCopyInUndoList( aModule, UR_MODEDIT );
|
||||||
aCaller->OnModify();
|
aCaller->OnModify();
|
||||||
|
@ -255,9 +248,6 @@ bool InvokeDXFDialogModuleImport( PCB_BASE_FRAME* aCaller, MODULE* aModule )
|
||||||
wxLogDebug( wxT( "type %d currently not handled" ), item->Type() );
|
wxLogDebug( wxT( "type %d currently not handled" ), item->Type() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( aCaller->IsGalCanvasActive() && converted )
|
|
||||||
view->Add( converted );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -448,52 +448,11 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
|
||||||
std::list<BOARD_ITEM*>::const_iterator it, itEnd;
|
std::list<BOARD_ITEM*>::const_iterator it, itEnd;
|
||||||
for( it = list.begin(), itEnd = list.end(); it != itEnd; ++it )
|
for( it = list.begin(), itEnd = list.end(); it != itEnd; ++it )
|
||||||
{
|
{
|
||||||
BOARD_ITEM* item = *it;
|
KICAD_T type = (*it)->Type();
|
||||||
BOARD_ITEM* converted = NULL;
|
assert( type == PCB_LINE_T || type == PCB_TEXT_T );
|
||||||
|
|
||||||
// Modules use different types for the same things,
|
if( type == PCB_LINE_T || type == PCB_TEXT_T )
|
||||||
// so we need to convert imported items to appropriate classes.
|
preview.Add( *it );
|
||||||
switch( item->Type() )
|
|
||||||
{
|
|
||||||
case PCB_LINE_T:
|
|
||||||
{
|
|
||||||
if( m_editModules )
|
|
||||||
{
|
|
||||||
converted = new EDGE_MODULE( m_board->m_Modules );
|
|
||||||
*static_cast<DRAWSEGMENT*>( converted ) = *static_cast<DRAWSEGMENT*>( item );
|
|
||||||
converted->Move( wxPoint( delta.x, delta.y ) );
|
|
||||||
preview.Add( converted );
|
|
||||||
delete item;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
preview.Add( item );
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case PCB_TEXT_T:
|
|
||||||
{
|
|
||||||
if( m_editModules )
|
|
||||||
{
|
|
||||||
converted = new TEXTE_MODULE( m_board->m_Modules );
|
|
||||||
*static_cast<TEXTE_PCB*>( converted ) = *static_cast<TEXTE_PCB*>( item );
|
|
||||||
converted->Move( wxPoint( delta.x, delta.y ) );
|
|
||||||
preview.Add( converted );
|
|
||||||
delete item;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
preview.Add( item );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
assert( false ); // there is a type that is currently not handled here
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOARD_ITEM* firstItem = static_cast<BOARD_ITEM*>( *preview.Begin() );
|
BOARD_ITEM* firstItem = static_cast<BOARD_ITEM*>( *preview.Begin() );
|
||||||
|
@ -549,22 +508,31 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
|
||||||
// Place the drawing
|
// Place the drawing
|
||||||
if( m_editModules )
|
if( m_editModules )
|
||||||
{
|
{
|
||||||
|
assert( m_board->m_Modules );
|
||||||
m_frame->SaveCopyInUndoList( m_board->m_Modules, UR_MODEDIT );
|
m_frame->SaveCopyInUndoList( m_board->m_Modules, UR_MODEDIT );
|
||||||
m_board->m_Modules->SetLastEditTime();
|
m_board->m_Modules->SetLastEditTime();
|
||||||
|
|
||||||
for( KIGFX::VIEW_GROUP::iter it = preview.Begin(), end = preview.End(); it != end; ++it )
|
for( KIGFX::VIEW_GROUP::iter it = preview.Begin(), end = preview.End(); it != end; ++it )
|
||||||
{
|
{
|
||||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( *it );
|
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( *it );
|
||||||
m_board->m_Modules->Add( item );
|
BOARD_ITEM* converted = NULL;
|
||||||
|
|
||||||
|
// Modules use different types for the same things,
|
||||||
|
// so we need to convert imported items to appropriate classes.
|
||||||
switch( item->Type() )
|
switch( item->Type() )
|
||||||
{
|
{
|
||||||
case PCB_MODULE_TEXT_T:
|
case PCB_TEXT_T:
|
||||||
static_cast<TEXTE_MODULE*>( item )->SetLocalCoord();
|
converted = new TEXTE_MODULE( m_board->m_Modules );
|
||||||
|
// Copy coordinates, layer, etc.
|
||||||
|
*static_cast<TEXTE_PCB*>( converted ) = *static_cast<TEXTE_PCB*>( item );
|
||||||
|
static_cast<TEXTE_MODULE*>( converted )->SetLocalCoord();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCB_MODULE_EDGE_T:
|
case PCB_LINE_T:
|
||||||
static_cast<EDGE_MODULE*>( item )->SetLocalCoord();
|
converted = new EDGE_MODULE( m_board->m_Modules );
|
||||||
|
// Copy coordinates, layer, etc.
|
||||||
|
*static_cast<DRAWSEGMENT*>( converted ) = *static_cast<DRAWSEGMENT*>( item );
|
||||||
|
static_cast<EDGE_MODULE*>( converted )->SetLocalCoord();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -572,7 +540,9 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_view->Add( item );
|
delete item;
|
||||||
|
m_board->m_Modules->Add( converted );
|
||||||
|
m_view->Add( converted );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -594,7 +564,6 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
m_frame->OnModify();
|
m_frame->OnModify();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue