Commit 629c9329 authored by jean-pierre charras's avatar jean-pierre charras

Add undo command to dxf file import. Change improper use of __WXDEBUG__ to...

Add undo command to dxf file import. Change improper use of __WXDEBUG__ to DEBUG in class_board_connected_item.cpp.
parent 416c4461
......@@ -123,7 +123,7 @@ int BOARD_CONNECTED_ITEM::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
}
else
{
#ifdef __WXDEBUG__
#ifdef DEBUG
wxLogWarning(wxT("BOARD_CONNECTED_ITEM::GetClearance():NULL netclass,type %d"), Type() );
#endif
}
......@@ -148,7 +148,7 @@ NETCLASS* BOARD_CONNECTED_ITEM::GetNetClass() const
if( board == NULL ) // Should not occur
{
#ifdef __WXDEBUG__
#ifdef DEBUG
wxLogWarning( wxT("BOARD_CONNECTED_ITEM::GetNetClass():NULL board,type %d"), Type() );
#endif
return NULL;
......@@ -162,7 +162,7 @@ NETCLASS* BOARD_CONNECTED_ITEM::GetNetClass() const
{
netclass = net->GetNetClass();
#ifdef __WXDEBUG__
#ifdef DEBUG
if( netclass == NULL )
{
wxLogWarning( wxT("BOARD_CONNECTED_ITEM::GetNetClass():NULL netclass,type %d"), Type() );
......
......@@ -179,8 +179,23 @@ void DIALOG_DXF_IMPORT::OnOKClick( wxCommandEvent& event )
dxf_importer.SetOffset( offsetX, offsetY );
m_layer = m_SelLayerBox->GetLayerSelection();
dxf_importer.SetBrdLayer( m_layer );
// Read dxf file:
dxf_importer.ImportDxfFile( m_dxfFilename, brd );
// Prepare the undo list
std::vector<BOARD_ITEM*>& list = dxf_importer.GetItemsList();
PICKED_ITEMS_LIST picklist;
// Build the undo list
for( unsigned ii = 0; ii < list.size(); ii++ )
{
ITEM_PICKER itemWrapper( list[ii], UR_NEW );
picklist.PushItem( itemWrapper );
}
m_parent->SaveCopyInUndoList( picklist, UR_NEW, wxPoint(0,0) );
EndModal( wxID_OK );
}
......
......@@ -106,8 +106,16 @@ bool DXF2BRD_CONVERTER::ImportDxfFile( const wxString& aFile, BOARD* aBoard )
return true;
}
// Add aItem the the board
// this item is also added to the list of new items
// (for undo command for instance)
void DXF2BRD_CONVERTER::appendToBoard( BOARD_ITEM * aItem )
{
m_brd->Add( aItem );
m_newItemsList.push_back( aItem );
}
/**
/*
* Implementation of the method which handles layers.
*/
void DXF2BRD_CONVERTER::addLayer( const DRW_Layer& data )
......@@ -134,7 +142,7 @@ void DXF2BRD_CONVERTER::addLine( const DRW_Line& data )
segm->SetEnd( end );
segm->SetWidth( mapDim( data.thickness == 0 ? m_defaultThickness
: data.thickness ) );
m_brd->Add( segm );
appendToBoard( segm );
}
......@@ -154,7 +162,7 @@ void DXF2BRD_CONVERTER::addCircle( const DRW_Circle& data )
segm->SetEnd( circle_start );
segm->SetWidth( mapDim( data.thickness == 0 ? m_defaultThickness
: data.thickness ) );
m_brd->Add( segm );
appendToBoard( segm );
}
......@@ -190,7 +198,7 @@ void DXF2BRD_CONVERTER::addArc( const DRW_Arc& data )
segm->SetWidth( mapDim( data.thickness == 0 ? m_defaultThickness
: data.thickness ) );
m_brd->Add( segm );
appendToBoard( segm );
}
/**
......@@ -289,7 +297,7 @@ void DXF2BRD_CONVERTER::addText(const DRW_Text& data)
: data.thickness ) );
pcb_text->SetText( text );
m_brd->Add( pcb_text );
appendToBoard( pcb_text );
}
......@@ -389,7 +397,7 @@ void DXF2BRD_CONVERTER::addMText( const DRW_MText& data )
}
#endif
m_brd->Add( pcb_text );
appendToBoard( pcb_text );
}
......
......@@ -31,6 +31,7 @@
class dxfRW;
class BOARD;
class BOARD_ITEM;
/**
* This format filter class can import and export DXF files.
......@@ -41,17 +42,19 @@ class BOARD;
class DXF2BRD_CONVERTER : public DRW_Interface
{
private:
std::vector<BOARD_ITEM*> m_newItemsList; // The list of new items added
// to the board
BOARD * m_brd;
double m_xOffset; // X coord offset for conversion (in mm)
double m_yOffset; // Y coord offset for conversion (in mm)
double m_defaultThickness; // default line thickness for conversion (in dxf units)
double m_defaultThickness; // default line thickness for conversion (in mm)
double m_Dfx2mm; // The scale factor to convert DXF units to mm
// Seems DRW_Interface always converts DXF coordinates in mm
// (to be confirmed)
int m_brdLayer; // The board layer to place imported dfx items
int m_version;
std::string m_codePage;
dxfRW* m_dxf;
int m_version; // the dxf version, not used here
std::string m_codePage; // The code page, not used here
dxfRW* m_dxf; // the dxf reader
public:
DXF2BRD_CONVERTER();
......@@ -67,8 +70,8 @@ public:
*/
void SetOffset( double aOffsetX, double aOffsetY )
{
m_xOffset =aOffsetX;
m_yOffset =aOffsetY;
m_xOffset = aOffsetX;
m_yOffset = aOffsetY;
}
/**
......@@ -79,12 +82,25 @@ public:
bool ImportDxfFile( const wxString& aFile, BOARD * aBoard );
/**
* @return the list of new BOARD_ITEM
*/
std::vector<BOARD_ITEM*>& GetItemsList()
{
return m_newItemsList;
}
private:
// coordinate conversions from dxf to internal units
int mapX( double aDxfCoordX );
int mapY( double aDxfCoordY );
int mapDim( double aDxfValue );
// Add aItem the the board
// this item is also added to the list of new items
// (for undo command for instance)
void appendToBoard( BOARD_ITEM * aItem );
// Methods from DRW_CreationInterface:
// They are "call back" fonctions, called when the corresponding object
// is read in dxf file
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment