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

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
Loading
Loading
Loading
Loading
+10 −1
Original line number Original line Diff line number Diff line
@@ -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
 * Filling is not supported
 */
 */
void DXF_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, int radius,
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 )
    if( radius <= 0 )
        return;
        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 );
    DPOINT centre_dev = userToDeviceCoordinates( centre );
    double radius_dev = userToDeviceSize( radius );
    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 );
        EXCHG( size.x, size.y );
        orient = AddAngles( orient, 900 );
        orient = AddAngles( orient, 900 );
    }
    }

    sketchOval( pos, size, orient, -1 );
    sketchOval( pos, size, orient, -1 );
}
}


+4 −4
Original line number Original line Diff line number Diff line
@@ -1683,7 +1683,7 @@ DRW_ImageDef* dxfRW::writeImage( DRW_Image* ent, std::string name )
        writer->writeInt16( 282, ent->contrast );
        writer->writeInt16( 282, ent->contrast );
        writer->writeInt16( 283, ent->fade );
        writer->writeInt16( 283, ent->fade );
        writer->writeString( 360, idReactor );
        writer->writeString( 360, idReactor );
        id->reactors[idReactor] = ent->handle;
        id->reactors[idReactor] = toHexStr( ent->handle );
        return id;
        return id;
    }
    }


@@ -3817,9 +3817,9 @@ bool dxfRW::processImageDef()
std::string dxfRW::toHexStr( int n )
std::string dxfRW::toHexStr( int n )
{
{
#if defined(__APPLE__)
#if defined(__APPLE__)
    std::string buffer( 9, '\0' );
    char buffer[9] = { '\0' };
    snprintf( &buffer[0], 9, "%X", n );
    snprintf( buffer, 9, "%X", n );
    return buffer;
    return std::string( buffer );
#else
#else
    std::ostringstream Convert;
    std::ostringstream Convert;
    Convert << std::uppercase << std::hex << n;
    Convert << std::uppercase << std::hex << n;
+14 −2
Original line number Original line Diff line number Diff line
@@ -116,8 +116,9 @@ public:
    void SetEndY( int y )                   { m_End.y = y; }
    void SetEndY( int y )                   { m_End.y = y; }
    void SetEndX( int x )                   { m_End.x = x; }
    void SetEndX( int x )                   { m_End.x = x; }


    // Arc attributes are read only, since they are "calculated" from
    // Some attributes are read only, since they are "calculated" from
    // m_Start, m_End, and m_Angle.  No Set...() functions.
    // m_Start, m_End, and m_Angle.
    // No Set...() function for these attributes.


    const wxPoint& GetCenter() const        { return m_Start; }
    const wxPoint& GetCenter() const        { return m_Start; }
    const wxPoint& GetArcStart() const      { return m_End; }
    const wxPoint& GetArcStart() const      { return m_End; }
@@ -140,6 +141,17 @@ public:
        return KiROUND( radius );
        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
     * Function GetParentModule
     * returns a pointer to the parent module, or NULL if DRAWSEGMENT does not
     * returns a pointer to the parent module, or NULL if DRAWSEGMENT does not
+11 −6
Original line number Original line Diff line number Diff line
@@ -41,9 +41,11 @@
#include <wx/regex.h>
#include <wx/regex.h>


#include <trigo.h>
#include <trigo.h>
#include <macros.h>
#include <class_board.h>
#include <class_board.h>
#include <class_drawsegment.h>
#include <class_drawsegment.h>
#include <class_pcb_text.h>
#include <class_pcb_text.h>
#include <convert_from_iu.h>


DXF2BRD_CONVERTER::DXF2BRD_CONVERTER() : DRW_Interface()
DXF2BRD_CONVERTER::DXF2BRD_CONVERTER() : DRW_Interface()
{
{
@@ -156,10 +158,10 @@ void DXF2BRD_CONVERTER::addCircle( const DRW_Circle& data )
    segm->SetLayer( m_brdLayer );
    segm->SetLayer( m_brdLayer );
    segm->SetShape( S_CIRCLE );
    segm->SetShape( S_CIRCLE );
    wxPoint center( mapX( data.basePoint.x ), mapY( data.basePoint.y ) );
    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 ),
    wxPoint circle_start( mapX( data.basePoint.x + data.radious ),
                          mapY( data.basePoint.y ) );
                          mapY( data.basePoint.y ) );
    segm->SetEnd( circle_start );
    segm->SetArcStart( circle_start );
    segm->SetWidth( mapDim( data.thickness == 0 ? m_defaultThickness
    segm->SetWidth( mapDim( data.thickness == 0 ? m_defaultThickness
                            : data.thickness ) );
                            : data.thickness ) );
    appendToBoard( segm );
    appendToBoard( segm );
@@ -178,18 +180,21 @@ void DXF2BRD_CONVERTER::addArc( const DRW_Arc& data )


    // Init arc centre:
    // Init arc centre:
    wxPoint center( mapX( data.basePoint.x ), mapY( data.basePoint.y ) );
    wxPoint center( mapX( data.basePoint.x ), mapY( data.basePoint.y ) );
    segm->SetPosition( center );
    segm->SetCenter( center );


    // Init arc start point
    // Init arc start point
    double  arcStartx   = data.radious;
    double  arcStartx   = data.radious;
    double  arcStarty   = 0;
    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 ),
    wxPoint arcStart( mapX( arcStartx + data.basePoint.x ),
                      mapY( arcStarty + data.basePoint.y ) );
                      mapY( arcStarty + data.basePoint.y ) );
    segm->SetEnd( arcStart );
    segm->SetArcStart( arcStart );


    // calculate arc angle (arcs are CCW, and should be < 0 in Pcbnew)
    // 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 )
    if( angle > 0.0 )
        angle -= 3600.0;
        angle -= 3600.0;
+6 −5
Original line number Original line Diff line number Diff line
@@ -378,13 +378,14 @@ wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary()


    wxString    wildcard;
    wxString    wildcard;


    wildcard << wxGetTranslation( LegacyFootprintLibPathWildcard ) << wxChar( '|' )
//    wildcard << wxGetTranslation( LegacyFootprintLibPathWildcard ) << wxChar( '|' )
             << wxGetTranslation( KiCadFootprintLibPathWildcard );
//             << wxGetTranslation( KiCadFootprintLibPathWildcard );
    wildcard << wxGetTranslation( KiCadFootprintLibPathWildcard ) << wxChar( '|' )
             << wxGetTranslation( LegacyFootprintLibPathWildcard );


    // prompt user for libPath and PLUGIN (library) type
    // prompt user for libPath and PLUGIN (library) type
    wxFileDialog dlg( this, FMT_CREATE_LIB, fn.GetPath(), wxEmptyString,
    wxFileDialog dlg( this, FMT_CREATE_LIB, fn.GetPath(), wxEmptyString,
                      wildcard,
                      wildcard, wxFD_SAVE
                      wxFD_SAVE
                      // | wxFD_OVERWRITE_PROMPT overwrite is tested below
                      // | wxFD_OVERWRITE_PROMPT overwrite is tested below
                      // after file extension has been added.
                      // after file extension has been added.
                      );
                      );
@@ -400,7 +401,7 @@ wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary()
    }
    }


    // wildcard's filter index has legacy in position 0.
    // 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.
    // wxFileDialog does not supply nor enforce the file extension, add it here.
    if( piType == IO_MGR::LEGACY )
    if( piType == IO_MGR::LEGACY )
Loading