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

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
/******************************************/ /**
/* 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 ) ...@@ -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() ...@@ -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& ...@@ -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() ...@@ -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 ) ...@@ -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 ...@@ -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 ...@@ -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, ...@@ -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, ...@@ -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,7 +443,9 @@ void GERBER_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient, ...@@ -437,7 +443,9 @@ 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 );
}
} }
} }
...@@ -516,7 +524,7 @@ void GERBER_PLOTTER::flash_pad_rect( wxPoint pos, wxSize size, ...@@ -516,7 +524,7 @@ void GERBER_PLOTTER::flash_pad_rect( wxPoint pos, wxSize size,
* Plot mode = FILLED or SKETCH * Plot mode = FILLED or SKETCH
*/ */
void GERBER_PLOTTER::flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4], void GERBER_PLOTTER::flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
int aPadOrient, GRTraceMode aTrace_Mode ) int aPadOrient, GRTraceMode aTrace_Mode )
{ {
// polygon corners list // polygon corners list
...@@ -533,6 +541,7 @@ void GERBER_PLOTTER::flash_pad_rect( wxPoint pos, wxSize size, ...@@ -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, ...@@ -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 )
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -112,7 +112,6 @@ enum SEARCH_RESULT { ...@@ -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: ...@@ -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;
*/ */
......
...@@ -131,11 +131,12 @@ public: ...@@ -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; }
/** /**
......
/**********************************************************************************************/ /**
/* 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 */
......
/****************/ /**
/* pcbstruct.h */ * @file class_pcb_screen.h
/****************/ */
#ifndef __CLASSPCB_SCREEN_H__ #ifndef __CLASSPCB_SCREEN_H__
#define __CLASSPCB_SCREEN_H__ #define __CLASSPCB_SCREEN_H__
#include "class_base_screen.h"
#include "class_board_item.h"
class UNDO_REDO_CONTAINER;
/* Handle info to display a board */ /* Handle info to display a board */
class PCB_SCREEN : public BASE_SCREEN class PCB_SCREEN : public BASE_SCREEN
{ {
...@@ -41,7 +49,7 @@ public: ...@@ -41,7 +49,7 @@ public:
* sets the currently selected object, m_CurrentItem. * sets the currently selected object, m_CurrentItem.
* @param aItem Any object derived from BOARD_ITEM * @param aItem Any object derived from BOARD_ITEM
*/ */
void SetCurItem( BOARD_ITEM* aItem ) { BASE_SCREEN::SetCurItem( aItem ); } void SetCurItem( BOARD_ITEM* aItem ) { BASE_SCREEN::SetCurItem( (EDA_ITEM*)aItem ); }
/* full undo redo management : */ /* full undo redo management : */
......
/*************/ /**
/* trigo.h */ * @file trigo.h
/*************/ */
#ifndef TRIGO_H #ifndef TRIGO_H
#define TRIGO_H #define TRIGO_H
/*
* Calculate the new point of coord coord pX, pY,
* for a rotation center 0, 0, and angle in (1 / 10 degree)
*/
void RotatePoint( int *pX, int *pY, int angle ); void RotatePoint( int *pX, int *pY, int angle );
/*
* Calculate the new point of coord coord pX, pY,
* for a rotation center cx, cy, and angle in (1 / 10 degree)
*/
void RotatePoint( int *pX, int *pY, int cx, int cy, int angle ); void RotatePoint( int *pX, int *pY, int cx, int cy, int angle );
/*
* Calculates the new coord point point
* for a rotation angle in (1 / 10 degree)
*/
void RotatePoint( wxPoint* point, int angle ); void RotatePoint( wxPoint* point, int angle );
/*
* Calculates the new coord point point
* for a center rotation center and angle in (1 / 10 degree)
*/
void RotatePoint( wxPoint *point, const wxPoint & centre, int angle ); void RotatePoint( wxPoint *point, const wxPoint & centre, int angle );
void RotatePoint( double *pX, double *pY, int angle ); void RotatePoint( double *pX, double *pY, int angle );
void RotatePoint( double *pX, double *pY, double cx, double cy, int angle ); void RotatePoint( double *pX, double *pY, double cx, double cy, int angle );
/* Return the arc tangent of 0.1 degrees coord vector dx, dy /* Return the arc tangent of 0.1 degrees coord vector dx, dy
...@@ -20,6 +41,11 @@ void RotatePoint( double *pX, double *pY, double cx, double cy, int angle ); ...@@ -20,6 +41,11 @@ void RotatePoint( double *pX, double *pY, double cx, double cy, int angle );
*/ */
int ArcTangente( int dy, int dx ); int ArcTangente( int dy, int dx );
/**
* Function DistanceTest
* Calculate the distance from mouse cursor to a line segment.
* @return False if distance > threshold or true if distance <= threshold.
*/
bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY ); bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY );
//! @brief Compute the distance between a line and a reference point //! @brief Compute the distance between a line and a reference point
...@@ -82,7 +108,7 @@ double GetLineLength( const wxPoint& aPointA, const wxPoint& aPointB ); ...@@ -82,7 +108,7 @@ double GetLineLength( const wxPoint& aPointA, const wxPoint& aPointB );
* either: xrot = (y + x * tg) * cos * either: xrot = (y + x * tg) * cos
* yrot = (y - x * tg) * cos * yrot = (y - x * tg) * cos
* *
* Cosine coefficients are loaded from a trigometric table by 16 bit values. * Cosine coefficients are loaded from a trigonometric table by 16 bit values.
*/ */
#define NEW_COORD( x0, y0 ) \ #define NEW_COORD( x0, y0 ) \
do { \ do { \
...@@ -95,7 +121,4 @@ double GetLineLength( const wxPoint& aPointA, const wxPoint& aPointB ); ...@@ -95,7 +121,4 @@ double GetLineLength( const wxPoint& aPointA, const wxPoint& aPointB );
} while( 0 ); } while( 0 );
extern double fsinus[];
extern double fcosinus[];
#endif #endif
...@@ -21,23 +21,13 @@ ...@@ -21,23 +21,13 @@
/* Forward declarations of classes. */ /* Forward declarations of classes. */
class WinEDA_CvpcbFrame; class WinEDA_CvpcbFrame;
class PCB_EDIT_FRAME;
class FOOTPRINT_EDIT_FRAME; class FOOTPRINT_EDIT_FRAME;
class BOARD; class BOARD;
class TEXTE_PCB;
class MODULE; class MODULE;
class TRACK; class TRACK;
class SEGZONE;
class SEGVIA;
class D_PAD; class D_PAD;
class TEXTE_MODULE; class TEXTE_MODULE;
class MIREPCB;
class DIMENSION;
class EDGE_MODULE;
class EDA_3D_FRAME; class EDA_3D_FRAME;
class DRC;
class ZONE_CONTAINER;
class DRAWSEGMENT;
class GENERAL_COLLECTOR; class GENERAL_COLLECTOR;
class GENERAL_COLLECTORS_GUIDE; class GENERAL_COLLECTORS_GUIDE;
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
#define WXPCB_STRUCT_H #define WXPCB_STRUCT_H
#include "wxstruct.h" #include "wxBasePcbFrame.h"
#include "base_struct.h"
#include "param_config.h" #include "param_config.h"
#include "class_layer_box_selector.h" #include "class_layer_box_selector.h"
#include "class_macros_record.h" #include "class_macros_record.h"
#include "richio.h" #include "class_undoredo_container.h"
#ifndef PCB_INTERNAL_UNIT #ifndef PCB_INTERNAL_UNIT
#define PCB_INTERNAL_UNIT 10000 #define PCB_INTERNAL_UNIT 10000
...@@ -37,6 +37,8 @@ class DRAWSEGMENT; ...@@ -37,6 +37,8 @@ class DRAWSEGMENT;
class GENERAL_COLLECTOR; class GENERAL_COLLECTOR;
class GENERAL_COLLECTORS_GUIDE; class GENERAL_COLLECTORS_GUIDE;
class PCB_LAYER_WIDGET; class PCB_LAYER_WIDGET;
class MARKER_PCB;
class BOARD_ITEM;
/** /**
...@@ -389,23 +391,20 @@ public: ...@@ -389,23 +391,20 @@ public:
* Function IsElementVisible * Function IsElementVisible
* tests whether a given element category is visible. Keep this as an * tests whether a given element category is visible. Keep this as an
* inline function. * inline function.
* @param aPCB_VISIBLE is from the enum by the same name * @param aElement is from the enum by the same name
* @return bool - true if the element is visible. * @return bool - true if the element is visible.
* @see enum PCB_VISIBLE * @see enum PCB_VISIBLE
*/ */
bool IsElementVisible( int aPCB_VISIBLE ) bool IsElementVisible( int aElement );
{
return GetBoard()->IsElementVisible( aPCB_VISIBLE );
}
/** /**
* Function SetElementVisibility * Function SetElementVisibility
* changes the visibility of an element category * changes the visibility of an element category
* @param aPCB_VISIBLE is from the enum by the same name * @param aElement is from the enum by the same name
* @param aNewState = The new visibility state of the element category * @param aNewState = The new visibility state of the element category
* @see enum PCB_VISIBLE * @see enum PCB_VISIBLE
*/ */
void SetElementVisibility( int aPCB_VISIBLE, bool aNewState ); void SetElementVisibility( int aElement, bool aNewState );
/** /**
* Function SetVisibleAlls * Function SetVisibleAlls
...@@ -1212,10 +1211,42 @@ public: ...@@ -1212,10 +1211,42 @@ public:
void LockModule( MODULE* aModule, bool aLocked ); void LockModule( MODULE* aModule, bool aLocked );
void AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ); void AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb );
void AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ); void AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC );
int RecherchePlacementModule( MODULE* Module, wxDC* DC );
/**
* Function GetOptimalModulePlacement
* searches for the optimal position of the \a aModule.
*
* @param aModule A pointer to the MODULE object to get the optimal placement.
* @param aDC The device context to draw on.
* @return 1 if placement impossible or 0 if OK.
*/
int GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC );
void GenModuleOnBoard( MODULE* Module ); void GenModuleOnBoard( MODULE* Module );
float Compute_Ratsnest_PlaceModule( wxDC* DC ); float Compute_Ratsnest_PlaceModule( wxDC* DC );
/**
* Function GenPlaceBoard
* generates board board (component side copper + rating):
* Allocate the memory needed to represent in "bitmap" on the grid
* Current:
* - The size of clearance area of component (the board)
* - The bitmap PENALTIES
* And initialize the cells of the board has
* - Hole in the cells occupied by a segment EDGE
* - CELL_is_ZONE for cell internal contour EDGE (if closed)
*
* Placement surface (board) gives the cells internal to the contour
* PCB, and among the latter the free cells and cells already occupied
*
* The bitmap PENALTIES give cells occupied by the modules,
* Plus a surface penalty related to the number of pads of the module
*
* Bitmap of the penalty is set to 0
* Occupation cell is a 0 leaves
*/
int GenPlaceBoard(); int GenPlaceBoard();
void DrawInfoPlace( wxDC* DC ); void DrawInfoPlace( wxDC* DC );
// Autorouting: // Autorouting:
......
/**************/ /**
/* ar-proto.h */ * @file ar_protos.h
/**************/ */
#ifndef _AR_PROTOS_H_
#define _AR_PROTOS_H_
#include "autorout.h"
class PCB_EDIT_FRAME;
class BOARD;
class D_PAD;
class RATSNEST_ITEM;
int Propagation( PCB_EDIT_FRAME* frame ); int Propagation( PCB_EDIT_FRAME* frame );
/* Initialize a value type, the cells included in the board surface of the /* Initialize a color value, the cells included in the board edge of the
* pad edge by pt_pad, with the margin reserved for isolation. */ * pad surface by pt_pad, with the margin reserved for isolation and the
void Place_1_Pad_Board( BOARD * Pcb, D_PAD * pt_pad, int type, int marge, * half width of the runway
int op_logique ); * Parameters:
* Pt_pad: pointer to the description of the pad
* color: mask write in cells
* margin: add a value to the radius or half the score pad
* op_logic: type of writing in the cell (WRITE, OR)
*/
void PlacePad( BOARD* Pcb, D_PAD* pt_pad, int type, int marge, int op_logic );
/* Draws a segment of track on the board. */ /* Draws a segment of track on the board. */
void TraceSegmentPcb( BOARD * Pcb, TRACK * pt_segm, int type, int marge, void TraceSegmentPcb( BOARD* Pcb, TRACK* pt_segm, int type, int marge, int op_logic );
int op_logique );
void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int type,
int op_logique );
/* Uses the color value of all cells included in the board /* Uses the color value of all cells included in the board
* coord of the rectangle ux0, uy0 (top right corner) * coord of the rectangle ux0, uy0 (top right corner)
* a ux1, uy1 (lower left corner) (coord PCB) * a ux1, uy1 (lower left corner) (coord PCB)
* the rectangle is horizontal (or vertical) * the rectangle is horizontal (or vertical)
* masque_layer = mask layers; * masque_layer = mask layers;
* op_logique = WRITE_CELL, WRITE_OR_CELL, WRITE_XOR_CELL, WRITE_AND_CELL * op_logic = WRITE_CELL, WRITE_OR_CELL, WRITE_XOR_CELL, WRITE_AND_CELL
*/ */
void TraceFilledRectangle( BOARD * Pcb, int ux0, int uy0, int ux1, int uy1, void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
int side, int color, int op_logique); int side, int color, int op_logic);
/* Same as above, but the rectangle is inclined angle angle. */ /* Same as above, but the rectangle is inclined angle angle. */
void TraceFilledRectangle( BOARD * Pcb, int ux0, int uy0, int ux1, int uy1, void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
int angle, int masque_layer, int color, int angle, int masque_layer, int color, int op_logic );
int op_logique );
/* Fills all BOARD cells contained in the arc of "L" angle half-width lg
* ux center, starting in ux y0, y1 is set to color. Coordinates are in
* PCB units (0.1 mil) relating to the origin pt_pcb-> Pcb_oX, Y's board.
*/
void TraceArc( int ux0,int uy0, int ux1, int uy1, int ArcAngle, int lg,
int layer, int color, int op_logique);
/* QUEUE.CPP */ /* QUEUE.CPP */
void FreeQueue(); void FreeQueue();
...@@ -72,3 +79,6 @@ DIST_CELL GetDist( int aRow, int aCol, int aSide ); ...@@ -72,3 +79,6 @@ DIST_CELL GetDist( int aRow, int aCol, int aSide );
void SetDist( int aRow, int aCol, int aSide, DIST_CELL ); void SetDist( int aRow, int aCol, int aSide, DIST_CELL );
int GetDir( int aRow, int aCol, int aSide ); int GetDir( int aRow, int aCol, int aSide );
void SetDir( int aRow, int aCol, int aSide, int aDir); void SetDir( int aRow, int aCol, int aSide, int aDir);
#endif // _AR_PROTOS_H_
This diff is collapsed.
/***************************************/ /**
/* PCBNEW: Autorouting command control */ * @file autorout.cpp
/***************************************/ * @brief Autorouting command and control.
*/
#include "fctsys.h" #include "fctsys.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "pcbnew.h"
#include "wxPcbStruct.h" #include "wxPcbStruct.h"
#include "pcbnew.h"
#include "autorout.h" #include "autorout.h"
#include "cell.h" #include "cell.h"
#include "zones.h" #include "zones.h"
#include "class_board_design_settings.h" #include "class_board_design_settings.h"
#include "ar_protos.h"
int E_scale; /* Scaling factor of distance tables. */ int E_scale; /* Scaling factor of distance tables. */
...@@ -41,8 +44,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode ) ...@@ -41,8 +44,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
} }
else else
{ {
Route_Layer_TOP = Route_Layer_TOP = Route_Layer_BOTTOM = LAYER_N_BACK;
Route_Layer_BOTTOM = LAYER_N_BACK;
} }
switch( mode ) switch( mode )
...@@ -78,11 +80,13 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode ) ...@@ -78,11 +80,13 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
case ROUTE_PAD: case ROUTE_PAD:
Pad = (D_PAD*) GetScreen()->GetCurItem(); Pad = (D_PAD*) GetScreen()->GetCurItem();
if( (Pad == NULL) || (Pad->Type() != TYPE_PAD) ) if( (Pad == NULL) || (Pad->Type() != TYPE_PAD) )
{ {
wxMessageBox( _( "Pad not selected" ) ); wxMessageBox( _( "Pad not selected" ) );
return; return;
} }
break; break;
} }
...@@ -113,6 +117,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode ) ...@@ -113,6 +117,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
{ {
if( ptmp->m_PadStart == pt_pad ) if( ptmp->m_PadStart == pt_pad )
ptmp->m_Status |= CH_ROUTE_REQ; ptmp->m_Status |= CH_ROUTE_REQ;
if( ptmp->m_PadEnd == pt_pad ) if( ptmp->m_PadEnd == pt_pad )
ptmp->m_Status |= CH_ROUTE_REQ; ptmp->m_Status |= CH_ROUTE_REQ;
} }
...@@ -123,6 +128,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode ) ...@@ -123,6 +128,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
case ROUTE_PAD: case ROUTE_PAD:
if( ( ptmp->m_PadStart == Pad ) || ( ptmp->m_PadEnd == Pad ) ) if( ( ptmp->m_PadStart == Pad ) || ( ptmp->m_PadEnd == Pad ) )
ptmp->m_Status |= CH_ROUTE_REQ; ptmp->m_Status |= CH_ROUTE_REQ;
break; break;
} }
} }
...@@ -131,9 +137,13 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode ) ...@@ -131,9 +137,13 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
/* Calculation of no fixed routing to 5 mils and more. */ /* Calculation of no fixed routing to 5 mils and more. */
Board.m_GridRouting = (int)GetScreen()->GetGridSize().x; Board.m_GridRouting = (int)GetScreen()->GetGridSize().x;
if( Board.m_GridRouting < 50 ) if( Board.m_GridRouting < 50 )
Board.m_GridRouting = 50; Board.m_GridRouting = 50;
E_scale = Board.m_GridRouting / 50; if( E_scale < 1 )
E_scale = Board.m_GridRouting / 50;
if( E_scale < 1 )
E_scale = 1; E_scale = 1;
/* Calculated ncol and nrow, matrix size for routing. */ /* Calculated ncol and nrow, matrix size for routing. */
...@@ -143,6 +153,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode ) ...@@ -143,6 +153,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
/* Map the board */ /* Map the board */
Nb_Sides = ONE_SIDE; Nb_Sides = ONE_SIDE;
if( Route_Layer_TOP != Route_Layer_BOTTOM ) if( Route_Layer_TOP != Route_Layer_BOTTOM )
Nb_Sides = TWO_SIDES; Nb_Sides = TWO_SIDES;
...@@ -201,25 +212,33 @@ void DisplayBoard( EDA_DRAW_PANEL* panel, wxDC* DC ) ...@@ -201,25 +212,33 @@ void DisplayBoard( EDA_DRAW_PANEL* panel, wxDC* DC )
maxi = 600 / Ncols; maxi = 600 / Ncols;
maxi = ( maxi * 3 ) / 4; maxi = ( maxi * 3 ) / 4;
if( !maxi ) if( !maxi )
maxi = 1; maxi = 1;
GRSetDrawMode( DC, GR_COPY ); GRSetDrawMode( DC, GR_COPY );
for( col = 0; col < Ncols; col++ ) for( col = 0; col < Ncols; col++ )
{ {
for( row = 0; row < Nrows; row++ ) for( row = 0; row < Nrows; row++ )
{ {
color = 0; color = 0;
dcell0 = GetCell( row, col, BOTTOM ); dcell0 = GetCell( row, col, BOTTOM );
if( dcell0 & HOLE ) if( dcell0 & HOLE )
color = GREEN; color = GREEN;
// if( Nb_Sides ) // if( Nb_Sides )
// dcell1 = GetCell( row, col, TOP ); // dcell1 = GetCell( row, col, TOP );
if( dcell1 & HOLE ) if( dcell1 & HOLE )
color |= RED; color |= RED;
// dcell0 |= dcell1; // dcell0 |= dcell1;
if( !color && ( dcell0 & VIA_IMPOSSIBLE ) ) if( !color && ( dcell0 & VIA_IMPOSSIBLE ) )
color = BLUE; color = BLUE;
if( dcell0 & CELL_is_EDGE ) if( dcell0 & CELL_is_EDGE )
color = YELLOW; color = YELLOW;
else if( dcell0 & CELL_is_ZONE ) else if( dcell0 & CELL_is_ZONE )
......
/****************************************************/ /**
/* AUTOROUT.H */ * @file autorout.h
/****************************************************/ */
#ifndef AUTOROUT_H #ifndef AUTOROUT_H
#define AUTOROUT_H #define AUTOROUT_H
class BOARD;
#define TOP 0 #define TOP 0
#define BOTTOM 1 #define BOTTOM 1
#define EMPTY 0 #define EMPTY 0
...@@ -52,26 +55,27 @@ extern int MaxNodes; /* maximum number of nodes opened at one time */ ...@@ -52,26 +55,27 @@ extern int MaxNodes; /* maximum number of nodes opened at one time */
/* Structures useful to the generation of board as bitmap. */ /* Structures useful to the generation of board as bitmap. */
typedef char MATRIX_CELL; typedef char MATRIX_CELL;
typedef int DIST_CELL; typedef int DIST_CELL;
typedef char DIR_CELL; typedef char DIR_CELL;
class MATRIX_ROUTING_HEAD /* header of blocks of MATRIX_CELL */ class MATRIX_ROUTING_HEAD /* header of blocks of MATRIX_CELL */
{ {
public: public:
MATRIX_CELL* m_BoardSide[MAX_SIDES_COUNT]; /* ptr to block of memory: 2-sided board */ MATRIX_CELL* m_BoardSide[MAX_SIDES_COUNT]; /* ptr to block of memory: 2-sided board */
DIST_CELL* m_DistSide[MAX_SIDES_COUNT]; /* ptr to block of memory: path distance to DIST_CELL* m_DistSide[MAX_SIDES_COUNT]; /* ptr to block of memory: path distance to
* cells */ * cells */
DIR_CELL* m_DirSide[MAX_SIDES_COUNT]; /* header of blocks of chars:pointers back to DIR_CELL* m_DirSide[MAX_SIDES_COUNT]; /* header of blocks of chars:pointers back to
* source */ * source */
bool m_InitBoardDone; bool m_InitBoardDone;
int m_Layers; int m_Layers;
int m_GridRouting; // Size of grid for autoplace/autoroute int m_GridRouting; // Size of grid for autoplace/autoroute
EDA_RECT m_BrdBox; // Actual board bouding box EDA_RECT m_BrdBox; // Actual board bounding box
int m_Nrows, m_Ncols; int m_Nrows, m_Ncols;
int m_MemSize; int m_MemSize;
public: public:
MATRIX_ROUTING_HEAD(); MATRIX_ROUTING_HEAD();
~MATRIX_ROUTING_HEAD(); ~MATRIX_ROUTING_HEAD();
bool ComputeMatrixSize( BOARD* aPcb ); bool ComputeMatrixSize( BOARD* aPcb );
int InitBoard(); int InitBoard();
void UnInitBoard(); void UnInitBoard();
...@@ -88,8 +92,4 @@ extern MATRIX_ROUTING_HEAD Board; /* 2-sided board */ ...@@ -88,8 +92,4 @@ extern MATRIX_ROUTING_HEAD Board; /* 2-sided board */
#define WRITE_ADD_CELL 4 #define WRITE_ADD_CELL 4
#include "ar_protos.h"
#endif // AUTOROUT_H #endif // AUTOROUT_H
/* BOARD.CPP : functions for autorouting */ /**
* @file board.cpp
* @brief Functions for autorouting
*/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
#include "pcbnew.h" #include "pcbnew.h"
#include "autorout.h"
#include "cell.h" #include "cell.h"
#include "ar_protos.h"
/* /*
...@@ -19,6 +23,7 @@ bool MATRIX_ROUTING_HEAD::ComputeMatrixSize( BOARD* aPcb ) ...@@ -19,6 +23,7 @@ bool MATRIX_ROUTING_HEAD::ComputeMatrixSize( BOARD* aPcb )
aPcb->m_BoundaryBox.m_Pos.x -= aPcb->m_BoundaryBox.m_Pos.x % m_GridRouting; aPcb->m_BoundaryBox.m_Pos.x -= aPcb->m_BoundaryBox.m_Pos.x % m_GridRouting;
aPcb->m_BoundaryBox.m_Pos.y -= aPcb->m_BoundaryBox.m_Pos.y % m_GridRouting; aPcb->m_BoundaryBox.m_Pos.y -= aPcb->m_BoundaryBox.m_Pos.y % m_GridRouting;
m_BrdBox = aPcb->m_BoundaryBox; m_BrdBox = aPcb->m_BoundaryBox;
/* The boundary box must have its end point on routing grid: */ /* The boundary box must have its end point on routing grid: */
wxPoint end = m_BrdBox.GetEnd(); wxPoint end = m_BrdBox.GetEnd();
end.x -= end.x % m_GridRouting; end.x -= end.x % m_GridRouting;
...@@ -115,19 +120,22 @@ void MATRIX_ROUTING_HEAD::UnInitBoard() ...@@ -115,19 +120,22 @@ void MATRIX_ROUTING_HEAD::UnInitBoard()
/***** de-allocate Dir matrix *****/ /***** de-allocate Dir matrix *****/
if( m_DirSide[ii] ) if( m_DirSide[ii] )
{ {
MyFree( m_DirSide[ii] ); m_DirSide[ii] = NULL; MyFree( m_DirSide[ii] );
m_DirSide[ii] = NULL;
} }
/***** de-allocate Distances matrix *****/ /***** de-allocate Distances matrix *****/
if( m_DistSide[ii] ) if( m_DistSide[ii] )
{ {
MyFree( m_DistSide[ii] ); m_DistSide[ii] = NULL; MyFree( m_DistSide[ii] );
m_DistSide[ii] = NULL;
} }
/**** de-allocate cells matrix *****/ /**** de-allocate cells matrix *****/
if( m_BoardSide[ii] ) if( m_BoardSide[ii] )
{ {
MyFree( m_BoardSide[ii] ); m_BoardSide[ii] = NULL; MyFree( m_BoardSide[ii] );
m_BoardSide[ii] = NULL;
} }
} }
...@@ -168,10 +176,10 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag ) ...@@ -168,10 +176,10 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
if( net_code != pad->GetNet() || (flag & FORCE_PADS) ) if( net_code != pad->GetNet() || (flag & FORCE_PADS) )
{ {
Place_1_Pad_Board( aPcb, pad, HOLE, marge, WRITE_CELL ); ::PlacePad( aPcb, pad, HOLE, marge, WRITE_CELL );
} }
Place_1_Pad_Board( aPcb, pad, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL ); ::PlacePad( aPcb, pad, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL );
} }
// Place outlines of modules on matrix routing, if they are on a copper layer // Place outlines of modules on matrix routing, if they are on a copper layer
...@@ -250,7 +258,8 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag ) ...@@ -250,7 +258,8 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
break; break;
EDA_RECT textbox = PtText->GetTextBox( -1 ); EDA_RECT textbox = PtText->GetTextBox( -1 );
ux0 = textbox.GetX(); uy0 = textbox.GetY(); ux0 = textbox.GetX();
uy0 = textbox.GetY();
dx = textbox.GetWidth(); dx = textbox.GetWidth();
dy = textbox.GetHeight(); dy = textbox.GetHeight();
...@@ -310,7 +319,7 @@ int Build_Work( BOARD* Pcb ) ...@@ -310,7 +319,7 @@ int Build_Work( BOARD* Pcb )
{ {
pt_rats = &Pcb->m_FullRatsnest[ii]; pt_rats = &Pcb->m_FullRatsnest[ii];
/* We consider her only ratsnets that are active ( obviously not yet routed) /* We consider her only ratsnest that are active ( obviously not yet routed)
* and routables (that are not yet attempt to be routed and fail * and routables (that are not yet attempt to be routed and fail
*/ */
if( (pt_rats->m_Status & CH_ACTIF) == 0 ) if( (pt_rats->m_Status & CH_ACTIF) == 0 )
......
/**
* @file cell.h
*/
#ifndef _CELL_H_
#define _CELL_H_
/* Bits characterizing cell */ /* Bits characterizing cell */
#define HOLE 0x01 /* a conducting hole or obstacle */ #define HOLE 0x01 /* a conducting hole or obstacle */
#define CELL_is_MODULE 0x02 /* auto placement occupied by a module */ #define CELL_is_MODULE 0x02 /* auto placement occupied by a module */
#define CELL_is_EDGE 0x20 /* Area and auto-placement: limiting cell #define CELL_is_EDGE 0x20 /* Area and auto-placement: limiting cell contour (Board, Zone) */
* contour (Board, Zone) */ #define CELL_is_FRIEND 0x40 /* Area and auto-placement: cell part of the net */
#define CELL_is_FRIEND 0x40 /* Area and auto-placement: cell part of the
* net */
#define CELL_is_ZONE 0x80 /* Area and auto-placement: cell available */ #define CELL_is_ZONE 0x80 /* Area and auto-placement: cell available */
/* Bit masks for presence of obstacles to autorouting */ /* Bit masks for presence of obstacles to autorouting */
...@@ -74,3 +80,7 @@ ...@@ -74,3 +80,7 @@
#define FROM_WEST 7 #define FROM_WEST 7
#define FROM_NORTHWEST 8 #define FROM_NORTHWEST 8
#define FROM_OTHERSIDE 9 #define FROM_OTHERSIDE 9
#endif // _CELL_H_
...@@ -12,7 +12,11 @@ ...@@ -12,7 +12,11 @@
#include "class_board_design_settings.h" #include "class_board_design_settings.h"
class BOARD;
class ZONE_CONTAINER; class ZONE_CONTAINER;
class SEGZONE;
class TRACK;
class PCB_EDIT_FRAME;
// buffer of item candidates when search for items on the same track. // buffer of item candidates when search for items on the same track.
...@@ -1183,7 +1187,7 @@ public: ...@@ -1183,7 +1187,7 @@ public:
/** /**
* Function MarkTrace * Function MarkTrace
* marks a chain of trace segments, connected to \aaTrace. * marks a chain of trace segments, connected to \a aTrace.
* <p> * <p>
* Each segment is marked by setting the BUSY bit into m_Flags. Electrical * Each segment is marked by setting the BUSY bit into m_Flags. Electrical
* continuity is detected by walking each segment, and finally the segments * continuity is detected by walking each segment, and finally the segments
......
/** /**
* @file class_edge_module.h * @file class_edge_mod.h
* @brief EDGE_MODULE class definition. * @brief EDGE_MODULE class definition.
*/ */
......
/**********************************/ /**
/* classes to handle copper zones */ * @file class_zone.h
/**********************************/ * @brief Classes to handle copper zones
*/
#ifndef CLASS_ZONE_H #ifndef CLASS_ZONE_H
#define CLASS_ZONE_H #define CLASS_ZONE_H
#include <vector> #include <vector>
#include "gr_basic.h" #include "gr_basic.h"
#include "PolyLine.h" #include "PolyLine.h"
...@@ -12,15 +14,25 @@ ...@@ -12,15 +14,25 @@
#include "class_zone_setting.h" #include "class_zone_setting.h"
class EDA_RECT;
class EDA_DRAW_FRAME;
class EDA_DRAW_PANEL;
class PCB_EDIT_FRAME;
class BOARD;
class BOARD_CONNECTED_ITEM;
class ZONE_CONTAINER;
/* a small class used when filling areas with segments */ /* a small class used when filling areas with segments */
class SEGMENT class SEGMENT
{ {
public: public:
wxPoint m_Start; // starting point of a segment wxPoint m_Start; // starting point of a segment
wxPoint m_End; // ending point of a segment wxPoint m_End; // ending point of a segment
public: public:
SEGMENT() {} SEGMENT() {}
SEGMENT( const wxPoint & aStart, const wxPoint & aEnd) SEGMENT( const wxPoint& aStart, const wxPoint& aEnd)
{ {
m_Start = aStart; m_Start = aStart;
m_End = aEnd; m_End = aEnd;
......
/** /**
* @file edit_track_width.cpp * @file edit_track_width.cpp
* @breif Functions to modify sizes of segment, track, net , all vias and/or all tracks * @brief Functions to modify sizes of segment, track, net, all vias and/or all tracks.
*/ */
#include "fctsys.h" #include "fctsys.h"
......
This diff is collapsed.
...@@ -623,10 +623,16 @@ void PCB_EDIT_FRAME::unitsChangeRefresh() ...@@ -623,10 +623,16 @@ void PCB_EDIT_FRAME::unitsChangeRefresh()
} }
void PCB_EDIT_FRAME::SetElementVisibility( int aPCB_VISIBLE, bool aNewState ) bool PCB_EDIT_FRAME::IsElementVisible( int aElement )
{ {
GetBoard()->SetElementVisibility( aPCB_VISIBLE, aNewState ); return GetBoard()->IsElementVisible( aElement );
m_Layers->SetRenderState( aPCB_VISIBLE, aNewState ); }
void PCB_EDIT_FRAME::SetElementVisibility( int aElement, bool aNewState )
{
GetBoard()->SetElementVisibility( aElement, aNewState );
m_Layers->SetRenderState( aElement, aNewState );
} }
......
/*************/ /**
/* solve.cpp */ * @file solve.cpp
/*************/ */
#include "fctsys.h" #include "fctsys.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "autorout.h"
#include "wxPcbStruct.h"
#include "pcbnew.h" #include "pcbnew.h"
#include "wxPcbStruct.h"
#include "class_board_design_settings.h" #include "class_board_design_settings.h"
#include "autorout.h"
#include "protos.h" #include "protos.h"
#include "ar_protos.h"
#include "cell.h" #include "cell.h"
...@@ -22,7 +22,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, ...@@ -22,7 +22,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
int col_source, int col_source,
int row_target, int row_target,
int col_target, int col_target,
RATSNEST_ITEM* pt_chevelu ); RATSNEST_ITEM* pt_rat );
static int Retrace( PCB_EDIT_FRAME* pcbframe, static int Retrace( PCB_EDIT_FRAME* pcbframe,
wxDC* DC, wxDC* DC,
...@@ -372,7 +372,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, ...@@ -372,7 +372,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
int col_source, int col_source,
int row_target, int row_target,
int col_target, int col_target,
RATSNEST_ITEM* pt_chevelu ) RATSNEST_ITEM* pt_rat )
{ {
int r, c, side, d, apx_dist, nr, nc; int r, c, side, d, apx_dist, nr, nc;
int result, skip; int result, skip;
...@@ -412,8 +412,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, ...@@ -412,8 +412,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
/* Set active layers mask. */ /* Set active layers mask. */
routeLayerMask = topLayerMask | bottomLayerMask; routeLayerMask = topLayerMask | bottomLayerMask;
pt_cur_ch = pt_chevelu; pt_cur_ch = pt_rat;
current_net_code = pt_chevelu->GetNet(); current_net_code = pt_rat->GetNet();
padLayerMaskStart = pt_cur_ch->m_PadStart->m_layerMask; padLayerMaskStart = pt_cur_ch->m_PadStart->m_layerMask;
padLayerMaskEnd = pt_cur_ch->m_PadEnd->m_layerMask; padLayerMaskEnd = pt_cur_ch->m_PadEnd->m_layerMask;
...@@ -474,13 +474,10 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, ...@@ -474,13 +474,10 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
/* Placing the bit to remove obstacles on 2 pads to a link. */ /* Placing the bit to remove obstacles on 2 pads to a link. */
pcbframe->SetStatusText( wxT( "Gen Cells" ) ); pcbframe->SetStatusText( wxT( "Gen Cells" ) );
Place_1_Pad_Board( pcbframe->GetBoard(), pt_cur_ch->m_PadStart, PlacePad( pcbframe->GetBoard(), pt_cur_ch->m_PadStart, CURRENT_PAD, marge, WRITE_OR_CELL );
CURRENT_PAD, marge, WRITE_OR_CELL ); PlacePad( pcbframe->GetBoard(), pt_cur_ch->m_PadEnd, CURRENT_PAD, marge, WRITE_OR_CELL );
Place_1_Pad_Board( pcbframe->GetBoard(), pt_cur_ch->m_PadEnd,
CURRENT_PAD, marge, WRITE_OR_CELL );
/* Regenerates the remaining barriers (which may encroach on the placement /* Regenerates the remaining barriers (which may encroach on the placement bits precedent)
* bits precedent)
*/ */
i = pcbframe->GetBoard()->GetPadsCount(); i = pcbframe->GetBoard()->GetPadsCount();
...@@ -491,7 +488,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, ...@@ -491,7 +488,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
if( ( pt_cur_ch->m_PadStart != ptr ) && ( pt_cur_ch->m_PadEnd != ptr ) ) if( ( pt_cur_ch->m_PadStart != ptr ) && ( pt_cur_ch->m_PadEnd != ptr ) )
{ {
Place_1_Pad_Board( pcbframe->GetBoard(), ptr, ~CURRENT_PAD, marge, WRITE_AND_CELL ); PlacePad( pcbframe->GetBoard(), ptr, ~CURRENT_PAD, marge, WRITE_AND_CELL );
} }
} }
...@@ -624,6 +621,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, ...@@ -624,6 +621,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
for( i = 0; i < 8; i++ ) for( i = 0; i < 8; i++ )
{ {
selfok2[i].present = 0; selfok2[i].present = 0;
if( curcell & selfok2[i].trace ) if( curcell & selfok2[i].trace )
selfok2[i].present = 1; selfok2[i].present = 1;
} }
...@@ -631,7 +629,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, ...@@ -631,7 +629,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
for( i = 0; i < 8; i++ ) /* consider neighbors */ for( i = 0; i < 8; i++ ) /* consider neighbors */
{ {
nr = r + delta[i][0]; nc = c + delta[i][1]; nr = r + delta[i][0];
nc = c + delta[i][1];
/* off the edge? */ /* off the edge? */
if( nr < 0 || nr >= Nrows || nc < 0 || nc >= Ncols ) if( nr < 0 || nr >= Nrows || nc < 0 || nc >= Ncols )
...@@ -781,10 +780,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, ...@@ -781,10 +780,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
} }
end_of_route: end_of_route:
Place_1_Pad_Board( pcbframe->GetBoard(), pt_cur_ch->m_PadStart, PlacePad( pcbframe->GetBoard(), pt_cur_ch->m_PadStart, ~CURRENT_PAD, marge, WRITE_AND_CELL );
~CURRENT_PAD, marge, WRITE_AND_CELL ); PlacePad( pcbframe->GetBoard(), pt_cur_ch->m_PadEnd, ~CURRENT_PAD, marge, WRITE_AND_CELL );
Place_1_Pad_Board( pcbframe->GetBoard(), pt_cur_ch->m_PadEnd,
~CURRENT_PAD, marge, WRITE_AND_CELL );
msg.Printf( wxT( "Activity: Open %d Closed %d Moved %d"), msg.Printf( wxT( "Activity: Open %d Closed %d Moved %d"),
OpenNodes, ClosNodes, MoveNodes ); OpenNodes, ClosNodes, MoveNodes );
...@@ -986,8 +983,7 @@ static int Retrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC, ...@@ -986,8 +983,7 @@ static int Retrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC,
y = GetDir( r0, c0, s0 ); y = GetDir( r0, c0, s0 );
/* see if target or hole */ /* see if target or hole */
if( ( ( r1 == row_target ) && ( c1 == col_target ) ) if( ( ( r1 == row_target ) && ( c1 == col_target ) ) || ( s1 != s0 ) )
|| ( s1 != s0 ) )
{ {
int p_dir; int p_dir;
......
/************************/ /**
/* Autorouting routines */ * @file work.cpp
/************************/ * @brief Automatic routing routines
*/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
#include "pcbnew.h" #include "pcbnew.h"
#include "autorout.h"
#include "cell.h" #include "cell.h"
#include "ar_protos.h"
struct CWORK /* a unit of work is a hole-pair to connect */ struct CWORK /* a unit of work is a hole-pair to connect */
{ {
struct CWORK* Next; struct CWORK* Next;
int FromRow; /* source row */ int FromRow; /* source row */
int FromCol; /* source column */ int FromCol; /* source column */
int net_code; /* net_code */ int net_code; /* net_code */
int ToRow; /* target row */ int ToRow; /* target row */
int ToCol; /* target column */ int ToCol; /* target column */
RATSNEST_ITEM* pt_rats; /* Corresponding ratsnest */ RATSNEST_ITEM* pt_rats; /* Corresponding ratsnest */
int ApxDist; /* approximate distance */ int ApxDist; /* approximate distance */
int Cost; /* cost for sort by length */ int Cost; /* cost for sort by length */
int Priority; /* route priority */ int Priority; /* route priority */
}; };
...@@ -90,14 +91,18 @@ int SetWork( int r1, ...@@ -90,14 +91,18 @@ int SetWork( int r1,
p->Priority = pri; p->Priority = pri;
p->Next = NULL; p->Next = NULL;
if( Head ) /* attach at end */ if( Head ) /* attach at end */
Tail->Next = p; Tail->Next = p;
else /* first in list */ else /* first in list */
Head = Current = p; Head = Current = p;
Tail = p; Tail = p;
return 1; return 1;
} }
else /* can't get any more memory */ else /* can't get any more memory */
{
return 0; return 0;
}
} }
...@@ -137,12 +142,15 @@ void SortWork() ...@@ -137,12 +142,15 @@ void SortWork()
CWORK* r; CWORK* r;
q0 = q1 = NULL; q0 = q1 = NULL;
while( (p = Head) != NULL ) /* prioritize each work item */ while( (p = Head) != NULL ) /* prioritize each work item */
{ {
Head = Head->Next; Head = Head->Next;
if( p->Priority ) /* put at end of priority list */ if( p->Priority ) /* put at end of priority list */
{ {
p->Next = NULL; p->Next = NULL;
if( (r = q0) == NULL ) /* empty list? */ if( (r = q0) == NULL ) /* empty list? */
q0 = p; q0 = p;
else /* attach at end */ else /* attach at end */
...@@ -203,6 +211,7 @@ static int GetCost( int r1, int c1, int r2, int c2 ) ...@@ -203,6 +211,7 @@ static int GetCost( int r1, int c1, int r2, int c2 )
{ {
mx = dy; my = dx; mx = dy; my = dx;
} }
if( mx ) if( mx )
incl += (2 * (float) my / mx); incl += (2 * (float) my / mx);
......
...@@ -6,10 +6,11 @@ ...@@ -6,10 +6,11 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "kicad_string.h" #include "kicad_string.h"
#include "pcbnew.h"
#include "wxPcbStruct.h" #include "wxPcbStruct.h"
#include "pcbnew.h"
#include "dialog_exchange_modules_base.h" #include "dialog_exchange_modules_base.h"
#include "ar_protos.h"
int s_SelectionMode = 0; // Remember the last exchange option, when exit dialog. int s_SelectionMode = 0; // Remember the last exchange option, when exit dialog.
...@@ -145,7 +146,6 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference, ...@@ -145,7 +146,6 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
FILE* FichCmp, * NewFile; FILE* FichCmp, * NewFile;
char Line[1024]; char Line[1024];
wxString msg; wxString msg;
char* result; // quiet compiler
if( old_name == new_name ) if( old_name == new_name )
return 0; return 0;
...@@ -155,6 +155,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference, ...@@ -155,6 +155,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
fn.SetExt( NetCmpExtBuffer ); fn.SetExt( NetCmpExtBuffer );
FichCmp = wxFopen( fn.GetFullPath(), wxT( "rt" ) ); FichCmp = wxFopen( fn.GetFullPath(), wxT( "rt" ) );
if( FichCmp == NULL ) if( FichCmp == NULL )
{ {
if( ShowError ) if( ShowError )
...@@ -162,12 +163,14 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference, ...@@ -162,12 +163,14 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
msg.Printf( _( "file %s not found" ), GetChars( fn.GetFullPath() ) ); msg.Printf( _( "file %s not found" ), GetChars( fn.GetFullPath() ) );
m_WinMessages->AppendText( msg ); m_WinMessages->AppendText( msg );
} }
return 1; return 1;
} }
tmpFileName = fn; tmpFileName = fn;
tmpFileName.SetExt( wxT( "$$$" ) ); tmpFileName.SetExt( wxT( "$$$" ) );
NewFile = wxFopen( tmpFileName.GetFullPath(), wxT( "wt" ) ); NewFile = wxFopen( tmpFileName.GetFullPath(), wxT( "wt" ) );
if( NewFile == NULL ) if( NewFile == NULL )
{ {
if( ShowError ) if( ShowError )
...@@ -176,14 +179,15 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference, ...@@ -176,14 +179,15 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
GetChars( tmpFileName.GetFullPath() ) ); GetChars( tmpFileName.GetFullPath() ) );
m_WinMessages->AppendText( msg ); m_WinMessages->AppendText( msg );
} }
return 1; return 1;
} }
result = fgets( Line, sizeof(Line), FichCmp ); fgets( Line, sizeof(Line), FichCmp );
fprintf( NewFile, "Cmp-Mod V01 Genere par PcbNew le %s\n", fprintf( NewFile, "Cmp-Mod V01 Genere par PcbNew le %s\n", DateAndTime( Line ) );
DateAndTime( Line ) );
bool start_descr = false; bool start_descr = false;
while( fgets( Line, sizeof(Line), FichCmp ) != NULL ) while( fgets( Line, sizeof(Line), FichCmp ) != NULL )
{ {
if( strnicmp( Line, "Reference = ", 9 ) == 0 ) if( strnicmp( Line, "Reference = ", 9 ) == 0 )
...@@ -191,14 +195,14 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference, ...@@ -191,14 +195,14 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
char buf[1024]; char buf[1024];
strcpy( buf, Line + 12 ); strcpy( buf, Line + 12 );
strtok( buf, ";\n\r" ); strtok( buf, ";\n\r" );
if( stricmp( buf, TO_UTF8( reference ) ) == 0 ) if( stricmp( buf, TO_UTF8( reference ) ) == 0 )
{ {
start_descr = true; start_descr = true;
} }
} }
if( (strnicmp( Line, "Begin", 5 ) == 0) if( (strnicmp( Line, "Begin", 5 ) == 0) || (strnicmp( Line, "End", 3 ) == 0) )
|| (strnicmp( Line, "End", 3 ) == 0) )
{ {
start_descr = false; start_descr = false;
} }
...@@ -212,6 +216,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference, ...@@ -212,6 +216,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
start_descr = false; start_descr = false;
} }
fputs( Line, NewFile ); fputs( Line, NewFile );
} }
...@@ -243,6 +248,7 @@ void DIALOG_EXCHANGE_MODULE::Change_Current_Module() ...@@ -243,6 +248,7 @@ void DIALOG_EXCHANGE_MODULE::Change_Current_Module()
{ {
if( m_Parent->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) ) if( m_Parent->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
m_Parent->Compile_Ratsnest( NULL, true ); m_Parent->Compile_Ratsnest( NULL, true );
m_Parent->DrawPanel->Refresh(); m_Parent->DrawPanel->Refresh();
} }
...@@ -274,10 +280,12 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue ) ...@@ -274,10 +280,12 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
if( m_Parent->GetBoard()->m_Modules == NULL ) if( m_Parent->GetBoard()->m_Modules == NULL )
return; return;
if( newmodulename == wxEmptyString ) if( newmodulename == wxEmptyString )
return; return;
lib_reference = m_CurrentModule->m_LibRef; lib_reference = m_CurrentModule->m_LibRef;
if( aUseValue ) if( aUseValue )
{ {
check_module_value = true; check_module_value = true;
...@@ -305,16 +313,20 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue ) ...@@ -305,16 +313,20 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
* points the board or is NULL * points the board or is NULL
*/ */
Module = m_Parent->GetBoard()->m_Modules.GetLast(); Module = m_Parent->GetBoard()->m_Modules.GetLast();
for( ; Module && ( Module->Type() == TYPE_MODULE ); Module = PtBack ) for( ; Module && ( Module->Type() == TYPE_MODULE ); Module = PtBack )
{ {
PtBack = Module->Back(); PtBack = Module->Back();
if( lib_reference.CmpNoCase( Module->m_LibRef ) != 0 ) if( lib_reference.CmpNoCase( Module->m_LibRef ) != 0 )
continue; continue;
if( check_module_value ) if( check_module_value )
{ {
if( value.CmpNoCase( Module->m_Value->m_Text ) != 0 ) if( value.CmpNoCase( Module->m_Value->m_Text ) != 0 )
continue; continue;
} }
if( Change_1_Module( Module, newmodulename, &pickList, ShowErr ) ) if( Change_1_Module( Module, newmodulename, &pickList, ShowErr ) )
change = true; change = true;
else if( ShowErr ) else if( ShowErr )
...@@ -325,6 +337,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue ) ...@@ -325,6 +337,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
{ {
if( m_Parent->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) ) if( m_Parent->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
m_Parent->Compile_Ratsnest( NULL, true ); m_Parent->Compile_Ratsnest( NULL, true );
m_Parent->DrawPanel->Refresh(); m_Parent->DrawPanel->Refresh();
} }
...@@ -362,9 +375,11 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleAll() ...@@ -362,9 +375,11 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleAll()
* points the board or is NULL * points the board or is NULL
*/ */
Module = m_Parent->GetBoard()->m_Modules.GetLast(); Module = m_Parent->GetBoard()->m_Modules.GetLast();
for( ; Module && ( Module->Type() == TYPE_MODULE ); Module = PtBack ) for( ; Module && ( Module->Type() == TYPE_MODULE ); Module = PtBack )
{ {
PtBack = Module->Back(); PtBack = Module->Back();
if( Change_1_Module( Module, Module->m_LibRef, &pickList, ShowErr ) ) if( Change_1_Module( Module, Module->m_LibRef, &pickList, ShowErr ) )
change = true; change = true;
else if( ShowErr ) else if( ShowErr )
...@@ -375,8 +390,10 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleAll() ...@@ -375,8 +390,10 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleAll()
{ {
if( m_Parent->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) ) if( m_Parent->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
m_Parent->Compile_Ratsnest( NULL, true ); m_Parent->Compile_Ratsnest( NULL, true );
m_Parent->DrawPanel->Refresh(); m_Parent->DrawPanel->Refresh();
} }
if( pickList.GetCount() ) if( pickList.GetCount() )
m_Parent->SaveCopyInUndoList( pickList, UR_UNSPECIFIED ); m_Parent->SaveCopyInUndoList( pickList, UR_UNSPECIFIED );
} }
...@@ -434,10 +451,7 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module, ...@@ -434,10 +451,7 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module,
m_Parent->Exchange_Module( Module, NewModule, aUndoPickList ); m_Parent->Exchange_Module( Module, NewModule, aUndoPickList );
Maj_ListeCmp( NewModule->m_Reference->m_Text, Maj_ListeCmp( NewModule->m_Reference->m_Text, oldnamecmp, namecmp, ShowError );
oldnamecmp,
namecmp,
ShowError );
return true; return true;
} }
...@@ -460,8 +474,7 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule, ...@@ -460,8 +474,7 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule,
wxPoint oldpos; wxPoint oldpos;
D_PAD* pad, * old_pad; D_PAD* pad, * old_pad;
if( ( aOldModule->Type() != TYPE_MODULE ) if( ( aOldModule->Type() != TYPE_MODULE ) || ( aNewModule->Type() != TYPE_MODULE ) )
|| ( aNewModule->Type() != TYPE_MODULE ) )
{ {
wxMessageBox( wxT( "PCB_EDIT_FRAME::Exchange_Module() StuctType error" ) ); wxMessageBox( wxT( "PCB_EDIT_FRAME::Exchange_Module() StuctType error" ) );
return; return;
...@@ -501,15 +514,16 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule, ...@@ -501,15 +514,16 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule,
/* Update pad netnames ( when possible) */ /* Update pad netnames ( when possible) */
pad = aNewModule->m_Pads; pad = aNewModule->m_Pads;
for( ; pad != NULL; pad = pad->Next() ) for( ; pad != NULL; pad = pad->Next() )
{ {
pad->SetNetname( wxEmptyString ); pad->SetNetname( wxEmptyString );
pad->SetNet( 0 ); pad->SetNet( 0 );
old_pad = aOldModule->m_Pads; old_pad = aOldModule->m_Pads;
for( ; old_pad != NULL; old_pad = old_pad->Next() ) for( ; old_pad != NULL; old_pad = old_pad->Next() )
{ {
if( strnicmp( pad->m_Padname, old_pad->m_Padname, if( strnicmp( pad->m_Padname, old_pad->m_Padname, sizeof(pad->m_Padname) ) == 0 )
sizeof(pad->m_Padname) ) == 0 )
{ {
pad->SetNetname( old_pad->GetNetname() ); pad->SetNetname( old_pad->GetNetname() );
pad->SetNet( old_pad->GetNet() ); pad->SetNet( old_pad->GetNet() );
...@@ -526,7 +540,9 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule, ...@@ -526,7 +540,9 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule,
aUndoPickList->PushItem( picker_new ); aUndoPickList->PushItem( picker_new );
} }
else else
{
aOldModule->DeleteStructure(); aOldModule->DeleteStructure();
}
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
aNewModule->m_Flags = 0; aNewModule->m_Flags = 0;
...@@ -564,7 +580,6 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent ) ...@@ -564,7 +580,6 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
MODULE* Module = GetBoard()->m_Modules; MODULE* Module = GetBoard()->m_Modules;
wxString msg; wxString msg;
wxString wildcard; wxString wildcard;
char* result; // quiet compiler
if( Module == NULL ) if( Module == NULL )
{ {
...@@ -575,8 +590,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent ) ...@@ -575,8 +590,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
/* Calculation file name by changing the extension name to NetList */ /* Calculation file name by changing the extension name to NetList */
fn = GetScreen()->GetFileName(); fn = GetScreen()->GetFileName();
fn.SetExt( NetCmpExtBuffer ); fn.SetExt( NetCmpExtBuffer );
wildcard = _( "Component files (." ) + NetCmpExtBuffer + wxT( ")|*." ) + wildcard = _( "Component files (." ) + NetCmpExtBuffer + wxT( ")|*." ) + NetCmpExtBuffer;
NetCmpExtBuffer;
wxFileDialog dlg( this, _( "Save Component Files" ), wxGetCwd(), wxFileDialog dlg( this, _( "Save Component Files" ), wxGetCwd(),
fn.GetFullName(), wildcard, fn.GetFullName(), wildcard,
...@@ -588,6 +602,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent ) ...@@ -588,6 +602,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
fn = dlg.GetPath(); fn = dlg.GetPath();
FichCmp = wxFopen( fn.GetFullPath(), wxT( "wt" ) ); FichCmp = wxFopen( fn.GetFullPath(), wxT( "wt" ) );
if( FichCmp == NULL ) if( FichCmp == NULL )
{ {
msg = _( "Unable to create file " ) + fn.GetFullPath(); msg = _( "Unable to create file " ) + fn.GetFullPath();
...@@ -595,9 +610,8 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent ) ...@@ -595,9 +610,8 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
return; return;
} }
result = fgets( Line, sizeof(Line), FichCmp ); fgets( Line, sizeof(Line), FichCmp );
fprintf( FichCmp, "Cmp-Mod V01 Genere par PcbNew le %s\n", fprintf( FichCmp, "Cmp-Mod V01 Genere par PcbNew le %s\n", DateAndTime( Line ) );
DateAndTime( Line ) );
for( ; Module != NULL; Module = Module->Next() ) for( ; Module != NULL; Module = Module->Next() )
{ {
...@@ -610,8 +624,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent ) ...@@ -610,8 +624,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
fprintf( FichCmp, "ValeurCmp = %s;\n", fprintf( FichCmp, "ValeurCmp = %s;\n",
!Module->m_Value->m_Text.IsEmpty() ? !Module->m_Value->m_Text.IsEmpty() ?
TO_UTF8( Module->m_Value->m_Text ) : "[NoVal]" ); TO_UTF8( Module->m_Value->m_Text ) : "[NoVal]" );
fprintf( FichCmp, "IdModule = %s;\n", fprintf( FichCmp, "IdModule = %s;\n", TO_UTF8( Module->m_LibRef ) );
TO_UTF8( Module->m_LibRef ) );
fprintf( FichCmp, "EndCmp\n" ); fprintf( FichCmp, "EndCmp\n" );
} }
......
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