Commit 50f6186e authored by jean-pierre charras's avatar jean-pierre charras

Dxf export: fix an issue in exported arcs. Update libdfx.

Pcbnew:, libedit, Save lib as...: the new .pretty lib format is the default, instead of legacy .mod format. The legacy format is still selectable in the file selection dialog.
parent de65a7a1
......@@ -386,7 +386,7 @@ void DXF_PLOTTER::ThickSegment( const wxPoint& aStart, const wxPoint& aEnd, int
}
}
/** Plot an arc in DXF format
/* Plot an arc in DXF format
* Filling is not supported
*/
void DXF_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, int radius,
......@@ -397,6 +397,14 @@ void DXF_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, i
if( radius <= 0 )
return;
// In DXF, arcs are drawn CCW.
// In Kicad, arcs are CW or CCW
// If StAngle > EndAngle, it is CW. So transform it to CCW
if( StAngle > EndAngle )
{
EXCHG( StAngle, EndAngle );
}
DPOINT centre_dev = userToDeviceCoordinates( centre );
double radius_dev = userToDeviceSize( radius );
......@@ -425,6 +433,7 @@ void DXF_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, double
EXCHG( size.x, size.y );
orient = AddAngles( orient, 900 );
}
sketchOval( pos, size, orient, -1 );
}
......
......@@ -1683,7 +1683,7 @@ DRW_ImageDef* dxfRW::writeImage( DRW_Image* ent, std::string name )
writer->writeInt16( 282, ent->contrast );
writer->writeInt16( 283, ent->fade );
writer->writeString( 360, idReactor );
id->reactors[idReactor] = ent->handle;
id->reactors[idReactor] = toHexStr( ent->handle );
return id;
}
......@@ -3817,9 +3817,9 @@ bool dxfRW::processImageDef()
std::string dxfRW::toHexStr( int n )
{
#if defined(__APPLE__)
std::string buffer( 9, '\0' );
snprintf( &buffer[0], 9, "%X", n );
return buffer;
char buffer[9] = { '\0' };
snprintf( buffer, 9, "%X", n );
return std::string( buffer );
#else
std::ostringstream Convert;
Convert << std::uppercase << std::hex << n;
......
......@@ -116,8 +116,9 @@ public:
void SetEndY( int y ) { m_End.y = y; }
void SetEndX( int x ) { m_End.x = x; }
// Arc attributes are read only, since they are "calculated" from
// m_Start, m_End, and m_Angle. No Set...() functions.
// Some attributes are read only, since they are "calculated" from
// m_Start, m_End, and m_Angle.
// No Set...() function for these attributes.
const wxPoint& GetCenter() const { return m_Start; }
const wxPoint& GetArcStart() const { return m_End; }
......@@ -140,6 +141,17 @@ public:
return KiROUND( radius );
}
/**
* Initialize the start arc point. can be used for circles
* to initialize one point of the cicumference
*/
void SetArcStart( const wxPoint& aArcStartPoint )
{ m_End = aArcStartPoint; }
/** For arcs and circles:
*/
void SetCenter( const wxPoint& aCenterPoint ) { m_Start = aCenterPoint; }
/**
* Function GetParentModule
* returns a pointer to the parent module, or NULL if DRAWSEGMENT does not
......
......@@ -41,9 +41,11 @@
#include <wx/regex.h>
#include <trigo.h>
#include <macros.h>
#include <class_board.h>
#include <class_drawsegment.h>
#include <class_pcb_text.h>
#include <convert_from_iu.h>
DXF2BRD_CONVERTER::DXF2BRD_CONVERTER() : DRW_Interface()
{
......@@ -156,10 +158,10 @@ void DXF2BRD_CONVERTER::addCircle( const DRW_Circle& data )
segm->SetLayer( m_brdLayer );
segm->SetShape( S_CIRCLE );
wxPoint center( mapX( data.basePoint.x ), mapY( data.basePoint.y ) );
segm->SetPosition( center );
segm->SetCenter( center );
wxPoint circle_start( mapX( data.basePoint.x + data.radious ),
mapY( data.basePoint.y ) );
segm->SetEnd( circle_start );
segm->SetArcStart( circle_start );
segm->SetWidth( mapDim( data.thickness == 0 ? m_defaultThickness
: data.thickness ) );
appendToBoard( segm );
......@@ -178,18 +180,21 @@ void DXF2BRD_CONVERTER::addArc( const DRW_Arc& data )
// Init arc centre:
wxPoint center( mapX( data.basePoint.x ), mapY( data.basePoint.y ) );
segm->SetPosition( center );
segm->SetCenter( center );
// Init arc start point
double arcStartx = data.radious;
double arcStarty = 0;
RotatePoint( &arcStartx, &arcStarty, -RAD2DECIDEG( data.staangle ) );
double startangle = data.staangle;
double endangle = data.endangle;
RotatePoint( &arcStartx, &arcStarty, -RAD2DECIDEG( startangle ) );
wxPoint arcStart( mapX( arcStartx + data.basePoint.x ),
mapY( arcStarty + data.basePoint.y ) );
segm->SetEnd( arcStart );
segm->SetArcStart( arcStart );
// calculate arc angle (arcs are CCW, and should be < 0 in Pcbnew)
double angle = -RAD2DECIDEG( data.endangle - data.staangle );
double angle = -RAD2DECIDEG( endangle - startangle );
if( angle > 0.0 )
angle -= 3600.0;
......
......@@ -378,13 +378,14 @@ wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary()
wxString wildcard;
wildcard << wxGetTranslation( LegacyFootprintLibPathWildcard ) << wxChar( '|' )
<< wxGetTranslation( KiCadFootprintLibPathWildcard );
// wildcard << wxGetTranslation( LegacyFootprintLibPathWildcard ) << wxChar( '|' )
// << wxGetTranslation( KiCadFootprintLibPathWildcard );
wildcard << wxGetTranslation( KiCadFootprintLibPathWildcard ) << wxChar( '|' )
<< wxGetTranslation( LegacyFootprintLibPathWildcard );
// prompt user for libPath and PLUGIN (library) type
wxFileDialog dlg( this, FMT_CREATE_LIB, fn.GetPath(), wxEmptyString,
wildcard,
wxFD_SAVE
wildcard, wxFD_SAVE
// | wxFD_OVERWRITE_PROMPT overwrite is tested below
// after file extension has been added.
);
......@@ -400,7 +401,7 @@ wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary()
}
// wildcard's filter index has legacy in position 0.
IO_MGR::PCB_FILE_T piType = ( dlg.GetFilterIndex() == 0 ) ? IO_MGR::LEGACY : IO_MGR::KICAD;
IO_MGR::PCB_FILE_T piType = ( dlg.GetFilterIndex() == 1 ) ? IO_MGR::LEGACY : IO_MGR::KICAD;
// wxFileDialog does not supply nor enforce the file extension, add it here.
if( piType == IO_MGR::LEGACY )
......
......@@ -1008,7 +1008,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) throw( IO_ER
// Set maximum proximity threshold for point to point nearness metric for
// board perimeter only, not interior keepouts yet.
prox = Mils2iu( 0 );
prox = Mils2iu( 1 );
// Output the Edge.Cuts perimeter as circle or polygon.
if( graphic->GetShape() == S_CIRCLE )
......
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