Commit 4230ac4c authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Remove sine and cosine look up tables and other minor fixes.

* Remove sine and cosine look up tables from trigo.cpp and replace them with
  sin() and cos() math functions.
* Large include file clean up to prevent header ordering dependency build
  failures.
* Translate French code names and comments.
* Lots of coding style policy and doxygen comment fixes.
parent 657a71a4
Loading
Loading
Loading
Loading
+30 −20
Original line number Original line Diff line number Diff line
/******************************************/
/**
/* Kicad: Common plot GERBER Routines */
 * @file common_plotGERBER_functions.cpp
/******************************************/
 * @brief Common GERBER plot routines.
 */


#include "fctsys.h"
#include "fctsys.h"
#include "gr_basic.h"
#include "gr_basic.h"
@@ -49,18 +50,18 @@ bool GERBER_PLOTTER::start_plot( FILE* aFile )
    final_file  = aFile;
    final_file  = aFile;


    // Create a temporary filename to store gerber file
    // Create a temporary filename to store gerber file
    // note tmpfile() does not work under Vista and W7 un user mode
    // note tmpfile() does not work under Vista and W7 in user mode
    m_workFilename = filename + wxT(".tmp");
    m_workFilename = filename + wxT(".tmp");
    work_file   = wxFopen( m_workFilename, wxT( "wt" ));
    work_file   = wxFopen( m_workFilename, wxT( "wt" ));
    output_file = work_file;
    output_file = work_file;
    wxASSERT( output_file );
    wxASSERT( output_file );

    if( output_file == NULL )
    if( output_file == NULL )
        return false;
        return false;


    DateAndTime( Line );
    DateAndTime( Line );
    wxString Title = creator + wxT( " " ) + GetBuildVersion();
    wxString Title = creator + wxT( " " ) + GetBuildVersion();
    fprintf( output_file, "G04 (created by %s) date %s*\n",
    fprintf( output_file, "G04 (created by %s) date %s*\n", TO_UTF8( Title ), Line );
             TO_UTF8( Title ), Line );


    // Specify linear interpol (G01), unit = INCH (G70), abs format (G90):
    // Specify linear interpol (G01), unit = INCH (G70), abs format (G90):
    fputs( "G01*\nG70*\nG90*\n", output_file );
    fputs( "G01*\nG70*\nG90*\n", output_file );
@@ -84,20 +85,22 @@ bool GERBER_PLOTTER::end_plot()
    wxString msg;
    wxString msg;


    wxASSERT( output_file );
    wxASSERT( output_file );

    /* Outfile is actually a temporary file! */
    /* Outfile is actually a temporary file! */
    fputs( "M02*\n", output_file );
    fputs( "M02*\n", output_file );
    fflush( output_file );
    fflush( output_file );

//    rewind( work_file ); // work_file == output_file !!!
//    rewind( work_file ); // work_file == output_file !!!
    fclose( work_file );
    fclose( work_file );
    work_file   = wxFopen( m_workFilename, wxT( "rt" ));
    work_file   = wxFopen( m_workFilename, wxT( "rt" ));
    wxASSERT( work_file );
    wxASSERT( work_file );
    output_file = final_file;
    output_file = final_file;



    // Placement of apertures in RS274X
    // Placement of apertures in RS274X
    while( fgets( line, 1024, work_file ) )
    while( fgets( line, 1024, work_file ) )
    {
    {
        fputs( line, output_file );
        fputs( line, output_file );

        if( strcmp( strtok( line, "\n\r" ), "G04 APERTURE LIST*" ) == 0 )
        if( strcmp( strtok( line, "\n\r" ), "G04 APERTURE LIST*" ) == 0 )
        {
        {
            write_aperture_list();
            write_aperture_list();
@@ -146,12 +149,14 @@ std::vector<APERTURE>::iterator GERBER_PLOTTER::get_aperture( const wxSize&


    // Search an existing aperture
    // Search an existing aperture
    std::vector<APERTURE>::iterator tool = apertures.begin();
    std::vector<APERTURE>::iterator tool = apertures.begin();

    while( tool != apertures.end() )
    while( tool != apertures.end() )
    {
    {
        last_D_code = tool->D_code;
        last_D_code = tool->D_code;
        if( (tool->type == type)

           && (tool->size == size) )
        if( (tool->type == type) && (tool->size == size) )
            return tool;
            return tool;

        tool++;
        tool++;
    }
    }


@@ -214,8 +219,7 @@ void GERBER_PLOTTER::write_aperture_list()
            break;
            break;


        case APERTURE::Oval:
        case APERTURE::Oval:
            sprintf( text, "O,%fX%f*%%\n", tool->size.x * fscale,
            sprintf( text, "O,%fX%f*%%\n", tool->size.x * fscale, tool->size.y * fscale );
                     tool->size.y * fscale );
            break;
            break;
        }
        }


@@ -275,23 +279,22 @@ void GERBER_PLOTTER::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width )
 * not used here: circles are always not filled the gerber. Filled circles are flashed
 * not used here: circles are always not filled the gerber. Filled circles are flashed
 * @param aWidth = line width
 * @param aWidth = line width
 */
 */
void GERBER_PLOTTER::circle( wxPoint aCentre, int aDiameter, FILL_T aFill,
void GERBER_PLOTTER::circle( wxPoint aCentre, int aDiameter, FILL_T aFill, int aWidth )
                             int aWidth )
{
{
    wxASSERT( output_file );
    wxASSERT( output_file );
    wxPoint   start, end;
    wxPoint   start, end;
    double    radius = aDiameter / 2;
    double    radius = aDiameter / 2;
    const int delta  = 3600 / 32; /* increment (in 0.1 degrees) to draw
    const int delta  = 3600 / 32; /* increment (in 0.1 degrees) to draw circles */
                                   * circles */


    start.x = aCentre.x + wxRound( radius );
    start.x = aCentre.x + wxRound( radius );
    start.y = aCentre.y;
    start.y = aCentre.y;
    set_current_line_width( aWidth );
    set_current_line_width( aWidth );
    move_to( start );
    move_to( start );

    for( int ii = delta; ii < 3600; ii += delta )
    for( int ii = delta; ii < 3600; ii += delta )
    {
    {
        end.x = aCentre.x + (int) ( radius * fcosinus[ii] );
        end.x = aCentre.x + (int) ( radius * cos( DEG2RAD( (double)ii / 10.0 ) ) );
        end.y = aCentre.y + (int) ( radius * fsinus[ii] );
        end.y = aCentre.y + (int) ( radius * sin( DEG2RAD( (double)ii / 10.0 ) ) );
        line_to( end );
        line_to( end );
    }
    }


@@ -317,6 +320,7 @@ void GERBER_PLOTTER::PlotPoly( std::vector< wxPoint >& aCornerList, FILL_T aFill
        fputs( "G36*\n", output_file );
        fputs( "G36*\n", output_file );


    move_to( aCornerList[0] );
    move_to( aCornerList[0] );

    for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
    for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
    {
    {
        line_to( aCornerList[ii] );
        line_to( aCornerList[ii] );
@@ -367,8 +371,7 @@ void GERBER_PLOTTER::PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFac
/* Function flash_pad_circle
/* Function flash_pad_circle
 * Plot a circular pad or via at the user position pos
 * Plot a circular pad or via at the user position pos
 */
 */
void GERBER_PLOTTER::flash_pad_circle( wxPoint pos, int diametre,
void GERBER_PLOTTER::flash_pad_circle( wxPoint pos, int diametre, GRTraceMode trace_mode )
                                       GRTraceMode trace_mode )
{
{
    wxASSERT( output_file );
    wxASSERT( output_file );
    wxSize size( diametre, diametre );
    wxSize size( diametre, diametre );
@@ -408,6 +411,7 @@ void GERBER_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
    {
    {
        if( orient == 900 || orient == 2700 ) /* orientation turned 90 deg. */
        if( orient == 900 || orient == 2700 ) /* orientation turned 90 deg. */
            EXCHG( size.x, size.y );
            EXCHG( size.x, size.y );

        user_to_device_coordinates( pos );
        user_to_device_coordinates( pos );
        select_aperture( size, APERTURE::Oval );
        select_aperture( size, APERTURE::Oval );
        fprintf( output_file, "X%5.5dY%5.5dD03*\n", pos.x, pos.y );
        fprintf( output_file, "X%5.5dY%5.5dD03*\n", pos.x, pos.y );
@@ -417,11 +421,13 @@ void GERBER_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
        if( size.x > size.y )
        if( size.x > size.y )
        {
        {
            EXCHG( size.x, size.y );
            EXCHG( size.x, size.y );

            if( orient < 2700 )
            if( orient < 2700 )
                orient += 900;
                orient += 900;
            else
            else
                orient -= 2700;
                orient -= 2700;
        }
        }

        if( trace_mode == FILLED )
        if( trace_mode == FILLED )
        {
        {
            /* The pad  is reduced to an oval with dy > dx */
            /* The pad  is reduced to an oval with dy > dx */
@@ -437,9 +443,11 @@ void GERBER_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
                           size.x, trace_mode );
                           size.x, trace_mode );
        }
        }
        else
        else
        {
            sketch_oval( pos, size, orient, -1 );
            sketch_oval( pos, size, orient, -1 );
        }
        }
    }
    }
}




/* Plot rectangular pad.
/* Plot rectangular pad.
@@ -533,6 +541,7 @@ void GERBER_PLOTTER::flash_pad_rect( wxPoint pos, wxSize size,
        RotatePoint( &cornerList[ii], aPadOrient );
        RotatePoint( &cornerList[ii], aPadOrient );
        cornerList[ii] += aPadPos;
        cornerList[ii] += aPadPos;
    }
    }

    // Close the polygon
    // Close the polygon
    cornerList.push_back( cornerList[0] );
    cornerList.push_back( cornerList[0] );


@@ -540,6 +549,7 @@ void GERBER_PLOTTER::flash_pad_rect( wxPoint pos, wxSize size,
    PlotPoly( cornerList, aTrace_Mode==FILLED ? FILLED_SHAPE : NO_FILL );
    PlotPoly( cornerList, aTrace_Mode==FILLED ? FILLED_SHAPE : NO_FILL );
}
}



void GERBER_PLOTTER::SetLayerPolarity( bool aPositive )
void GERBER_PLOTTER::SetLayerPolarity( bool aPositive )
{
{
    if( aPositive )
    if( aPositive )
+32 −1521

File changed.

Preview size limit exceeded, changes collapsed.

+2 −4
Original line number Original line Diff line number Diff line
@@ -112,7 +112,6 @@ enum SEARCH_RESULT {


class EDA_ITEM;
class EDA_ITEM;
class EDA_DRAW_FRAME;
class EDA_DRAW_FRAME;
class BOARD;
class EDA_RECT;
class EDA_RECT;
class EDA_DRAW_PANEL;
class EDA_DRAW_PANEL;


@@ -136,12 +135,11 @@ public:
     * Function Inspect
     * Function Inspect
     * is the examining function within the INSPECTOR which is passed to the
     * is the examining function within the INSPECTOR which is passed to the
     * Iterate function.  It is used primarily for searching, but not limited
     * Iterate function.  It is used primarily for searching, but not limited
     *to
     * to that.  It can also collect or modify the scanned objects.
     * that.  It can also collect or modify the scanned objects.
     *
     *
     * @param testItem An EDA_ITEM to examine.
     * @param testItem An EDA_ITEM to examine.
     * @param testData is arbitrary data needed by the inspector to determine
     * @param testData is arbitrary data needed by the inspector to determine
     *   if the BOARD_ITEM under test meets its match criteria.
     *                 if the EDA_ITEM under test meets its match criteria.
     * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
     * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
     *   else SCAN_CONTINUE;
     *   else SCAN_CONTINUE;
     */
     */
+2 −1
Original line number Original line Diff line number Diff line
@@ -131,11 +131,12 @@ public:
    ~BASE_SCREEN();
    ~BASE_SCREEN();


    /**
    /**
     * Function setCurItem
     * Function SetCurItem
     * sets the currently selected object, m_CurrentItem.
     * sets the currently selected object, m_CurrentItem.
     * @param aItem Any object derived from EDA_ITEM
     * @param aItem Any object derived from EDA_ITEM
     */
     */
    void SetCurItem( EDA_ITEM* aItem ) { m_CurrentItem = aItem; }
    void SetCurItem( EDA_ITEM* aItem ) { m_CurrentItem = aItem; }

    EDA_ITEM* GetCurItem() const { return m_CurrentItem; }
    EDA_ITEM* GetCurItem() const { return m_CurrentItem; }


    /**
    /**
+10 −3
Original line number Original line Diff line number Diff line
/**********************************************************************************************/
/**
/*  board_item_struct.h :  Classes BOARD_ITEM and BOARD_CONNECTED_ITEM                        */
 * @file  class_board_item.h
/**********************************************************************************************/
 * @brief Classes BOARD_ITEM and BOARD_CONNECTED_ITEM.
 */


#ifndef BOARD_ITEM_STRUCT_H
#ifndef BOARD_ITEM_STRUCT_H
#define BOARD_ITEM_STRUCT_H
#define BOARD_ITEM_STRUCT_H




#include "base_struct.h"

#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/ptr_container/ptr_vector.hpp>




class BOARD;
class EDA_DRAW_PANEL;


/* Shapes for segments (graphic segments and tracks) ( .m_Shape member ) */
/* Shapes for segments (graphic segments and tracks) ( .m_Shape member ) */
enum Track_Shapes {
enum Track_Shapes {
    S_SEGMENT = 0,  /* usual segment : line with rounded ends */
    S_SEGMENT = 0,  /* usual segment : line with rounded ends */
Loading