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.
This commit is contained in:
parent
657a71a478
commit
4230ac4ca7
|
@ -1,6 +1,7 @@
|
|||
/******************************************/
|
||||
/* Kicad: Common plot GERBER Routines */
|
||||
/******************************************/
|
||||
/**
|
||||
* @file common_plotGERBER_functions.cpp
|
||||
* @brief Common GERBER plot routines.
|
||||
*/
|
||||
|
||||
#include "fctsys.h"
|
||||
#include "gr_basic.h"
|
||||
|
@ -49,18 +50,18 @@ bool GERBER_PLOTTER::start_plot( FILE* aFile )
|
|||
final_file = aFile;
|
||||
|
||||
// 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");
|
||||
work_file = wxFopen( m_workFilename, wxT( "wt" ));
|
||||
output_file = work_file;
|
||||
wxASSERT( output_file );
|
||||
|
||||
if( output_file == NULL )
|
||||
return false;
|
||||
|
||||
DateAndTime( Line );
|
||||
wxString Title = creator + wxT( " " ) + GetBuildVersion();
|
||||
fprintf( output_file, "G04 (created by %s) date %s*\n",
|
||||
TO_UTF8( Title ), Line );
|
||||
fprintf( output_file, "G04 (created by %s) date %s*\n", TO_UTF8( Title ), Line );
|
||||
|
||||
// Specify linear interpol (G01), unit = INCH (G70), abs format (G90):
|
||||
fputs( "G01*\nG70*\nG90*\n", output_file );
|
||||
|
@ -84,20 +85,22 @@ bool GERBER_PLOTTER::end_plot()
|
|||
wxString msg;
|
||||
|
||||
wxASSERT( output_file );
|
||||
|
||||
/* Outfile is actually a temporary file! */
|
||||
fputs( "M02*\n", output_file );
|
||||
fflush( output_file );
|
||||
|
||||
// rewind( work_file ); // work_file == output_file !!!
|
||||
fclose( work_file );
|
||||
work_file = wxFopen( m_workFilename, wxT( "rt" ));
|
||||
wxASSERT( work_file );
|
||||
output_file = final_file;
|
||||
|
||||
|
||||
// Placement of apertures in RS274X
|
||||
while( fgets( line, 1024, work_file ) )
|
||||
{
|
||||
fputs( line, output_file );
|
||||
|
||||
if( strcmp( strtok( line, "\n\r" ), "G04 APERTURE LIST*" ) == 0 )
|
||||
{
|
||||
write_aperture_list();
|
||||
|
@ -146,12 +149,14 @@ std::vector<APERTURE>::iterator GERBER_PLOTTER::get_aperture( const wxSize&
|
|||
|
||||
// Search an existing aperture
|
||||
std::vector<APERTURE>::iterator tool = apertures.begin();
|
||||
|
||||
while( tool != apertures.end() )
|
||||
{
|
||||
last_D_code = tool->D_code;
|
||||
if( (tool->type == type)
|
||||
&& (tool->size == size) )
|
||||
|
||||
if( (tool->type == type) && (tool->size == size) )
|
||||
return tool;
|
||||
|
||||
tool++;
|
||||
}
|
||||
|
||||
|
@ -214,8 +219,7 @@ void GERBER_PLOTTER::write_aperture_list()
|
|||
break;
|
||||
|
||||
case APERTURE::Oval:
|
||||
sprintf( text, "O,%fX%f*%%\n", tool->size.x * fscale,
|
||||
tool->size.y * fscale );
|
||||
sprintf( text, "O,%fX%f*%%\n", tool->size.x * fscale, tool->size.y * fscale );
|
||||
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
|
||||
* @param aWidth = line width
|
||||
*/
|
||||
void GERBER_PLOTTER::circle( wxPoint aCentre, int aDiameter, FILL_T aFill,
|
||||
int aWidth )
|
||||
void GERBER_PLOTTER::circle( wxPoint aCentre, int aDiameter, FILL_T aFill, int aWidth )
|
||||
{
|
||||
wxASSERT( output_file );
|
||||
wxPoint start, end;
|
||||
double radius = aDiameter / 2;
|
||||
const int delta = 3600 / 32; /* increment (in 0.1 degrees) to draw
|
||||
* circles */
|
||||
const int delta = 3600 / 32; /* increment (in 0.1 degrees) to draw circles */
|
||||
|
||||
start.x = aCentre.x + wxRound( radius );
|
||||
start.y = aCentre.y;
|
||||
set_current_line_width( aWidth );
|
||||
move_to( start );
|
||||
|
||||
for( int ii = delta; ii < 3600; ii += delta )
|
||||
{
|
||||
end.x = aCentre.x + (int) ( radius * fcosinus[ii] );
|
||||
end.y = aCentre.y + (int) ( radius * fsinus[ii] );
|
||||
end.x = aCentre.x + (int) ( radius * cos( DEG2RAD( (double)ii / 10.0 ) ) );
|
||||
end.y = aCentre.y + (int) ( radius * sin( DEG2RAD( (double)ii / 10.0 ) ) );
|
||||
line_to( end );
|
||||
}
|
||||
|
||||
|
@ -317,6 +320,7 @@ void GERBER_PLOTTER::PlotPoly( std::vector< wxPoint >& aCornerList, FILL_T aFill
|
|||
fputs( "G36*\n", output_file );
|
||||
|
||||
move_to( aCornerList[0] );
|
||||
|
||||
for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
|
||||
{
|
||||
line_to( aCornerList[ii] );
|
||||
|
@ -367,8 +371,7 @@ void GERBER_PLOTTER::PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFac
|
|||
/* Function flash_pad_circle
|
||||
* Plot a circular pad or via at the user position pos
|
||||
*/
|
||||
void GERBER_PLOTTER::flash_pad_circle( wxPoint pos, int diametre,
|
||||
GRTraceMode trace_mode )
|
||||
void GERBER_PLOTTER::flash_pad_circle( wxPoint pos, int diametre, GRTraceMode trace_mode )
|
||||
{
|
||||
wxASSERT( output_file );
|
||||
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. */
|
||||
EXCHG( size.x, size.y );
|
||||
|
||||
user_to_device_coordinates( pos );
|
||||
select_aperture( size, APERTURE::Oval );
|
||||
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 )
|
||||
{
|
||||
EXCHG( size.x, size.y );
|
||||
|
||||
if( orient < 2700 )
|
||||
orient += 900;
|
||||
else
|
||||
orient -= 2700;
|
||||
}
|
||||
|
||||
if( trace_mode == FILLED )
|
||||
{
|
||||
/* 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,
|
|||
size.x, trace_mode );
|
||||
}
|
||||
else
|
||||
{
|
||||
sketch_oval( pos, size, orient, -1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -516,7 +524,7 @@ void GERBER_PLOTTER::flash_pad_rect( wxPoint pos, wxSize size,
|
|||
* Plot mode = FILLED or SKETCH
|
||||
*/
|
||||
void GERBER_PLOTTER::flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
|
||||
int aPadOrient, GRTraceMode aTrace_Mode )
|
||||
int aPadOrient, GRTraceMode aTrace_Mode )
|
||||
|
||||
{
|
||||
// polygon corners list
|
||||
|
@ -533,6 +541,7 @@ void GERBER_PLOTTER::flash_pad_rect( wxPoint pos, wxSize size,
|
|||
RotatePoint( &cornerList[ii], aPadOrient );
|
||||
cornerList[ii] += aPadPos;
|
||||
}
|
||||
|
||||
// Close the polygon
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
void GERBER_PLOTTER::SetLayerPolarity( bool aPositive )
|
||||
{
|
||||
if( aPositive )
|
||||
|
|
1553
common/trigo.cpp
1553
common/trigo.cpp
File diff suppressed because it is too large
Load Diff
|
@ -112,7 +112,6 @@ enum SEARCH_RESULT {
|
|||
|
||||
class EDA_ITEM;
|
||||
class EDA_DRAW_FRAME;
|
||||
class BOARD;
|
||||
class EDA_RECT;
|
||||
class EDA_DRAW_PANEL;
|
||||
|
||||
|
@ -136,12 +135,11 @@ public:
|
|||
* Function Inspect
|
||||
* is the examining function within the INSPECTOR which is passed to the
|
||||
* Iterate function. It is used primarily for searching, but not limited
|
||||
*to
|
||||
* that. It can also collect or modify the scanned objects.
|
||||
* to that. It can also collect or modify the scanned objects.
|
||||
*
|
||||
* @param testItem An EDA_ITEM to examine.
|
||||
* @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,
|
||||
* else SCAN_CONTINUE;
|
||||
*/
|
||||
|
|
|
@ -131,11 +131,12 @@ public:
|
|||
~BASE_SCREEN();
|
||||
|
||||
/**
|
||||
* Function setCurItem
|
||||
* Function SetCurItem
|
||||
* sets the currently selected object, m_CurrentItem.
|
||||
* @param aItem Any object derived from EDA_ITEM
|
||||
*/
|
||||
void SetCurItem( EDA_ITEM* aItem ) { m_CurrentItem = aItem; }
|
||||
|
||||
EDA_ITEM* GetCurItem() const { return m_CurrentItem; }
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,14 +1,21 @@
|
|||
/**********************************************************************************************/
|
||||
/* 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
|
||||
#define BOARD_ITEM_STRUCT_H
|
||||
|
||||
|
||||
#include "base_struct.h"
|
||||
|
||||
#include <boost/ptr_container/ptr_vector.hpp>
|
||||
|
||||
|
||||
class BOARD;
|
||||
class EDA_DRAW_PANEL;
|
||||
|
||||
|
||||
/* Shapes for segments (graphic segments and tracks) ( .m_Shape member ) */
|
||||
enum Track_Shapes {
|
||||
S_SEGMENT = 0, /* usual segment : line with rounded ends */
|
||||
|
|
|
@ -1,10 +1,18 @@
|
|||
/****************/
|
||||
/* pcbstruct.h */
|
||||
/****************/
|
||||
/**
|
||||
* @file class_pcb_screen.h
|
||||
*/
|
||||
|
||||
#ifndef __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 */
|
||||
class PCB_SCREEN : public BASE_SCREEN
|
||||
{
|
||||
|
@ -41,7 +49,7 @@ public:
|
|||
* sets the currently selected object, m_CurrentItem.
|
||||
* @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 : */
|
||||
|
|
|
@ -1,16 +1,37 @@
|
|||
/*************/
|
||||
/* trigo.h */
|
||||
/*************/
|
||||
/**
|
||||
* @file trigo.h
|
||||
*/
|
||||
|
||||
#ifndef 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 );
|
||||
|
||||
/*
|
||||
* 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 );
|
||||
|
||||
/*
|
||||
* Calculates the new coord point point
|
||||
* for a rotation angle in (1 / 10 degree)
|
||||
*/
|
||||
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( double *pX, double *pY, 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
|
||||
|
@ -20,6 +41,11 @@ void RotatePoint( double *pX, double *pY, double cx, double cy, int angle );
|
|||
*/
|
||||
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 );
|
||||
|
||||
//! @brief Compute the distance between a line and a reference point
|
||||
|
@ -82,7 +108,7 @@ double GetLineLength( const wxPoint& aPointA, const wxPoint& aPointB );
|
|||
* either: xrot = (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 ) \
|
||||
do { \
|
||||
|
@ -95,7 +121,4 @@ double GetLineLength( const wxPoint& aPointA, const wxPoint& aPointB );
|
|||
} while( 0 );
|
||||
|
||||
|
||||
extern double fsinus[];
|
||||
extern double fcosinus[];
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,23 +21,13 @@
|
|||
|
||||
/* Forward declarations of classes. */
|
||||
class WinEDA_CvpcbFrame;
|
||||
class PCB_EDIT_FRAME;
|
||||
class FOOTPRINT_EDIT_FRAME;
|
||||
class BOARD;
|
||||
class TEXTE_PCB;
|
||||
class MODULE;
|
||||
class TRACK;
|
||||
class SEGZONE;
|
||||
class SEGVIA;
|
||||
class D_PAD;
|
||||
class TEXTE_MODULE;
|
||||
class MIREPCB;
|
||||
class DIMENSION;
|
||||
class EDGE_MODULE;
|
||||
class EDA_3D_FRAME;
|
||||
class DRC;
|
||||
class ZONE_CONTAINER;
|
||||
class DRAWSEGMENT;
|
||||
class GENERAL_COLLECTOR;
|
||||
class GENERAL_COLLECTORS_GUIDE;
|
||||
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
#define WXPCB_STRUCT_H
|
||||
|
||||
|
||||
#include "wxstruct.h"
|
||||
#include "base_struct.h"
|
||||
#include "wxBasePcbFrame.h"
|
||||
#include "param_config.h"
|
||||
#include "class_layer_box_selector.h"
|
||||
#include "class_macros_record.h"
|
||||
#include "richio.h"
|
||||
#include "class_undoredo_container.h"
|
||||
|
||||
|
||||
#ifndef PCB_INTERNAL_UNIT
|
||||
#define PCB_INTERNAL_UNIT 10000
|
||||
|
@ -37,6 +37,8 @@ class DRAWSEGMENT;
|
|||
class GENERAL_COLLECTOR;
|
||||
class GENERAL_COLLECTORS_GUIDE;
|
||||
class PCB_LAYER_WIDGET;
|
||||
class MARKER_PCB;
|
||||
class BOARD_ITEM;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -389,23 +391,20 @@ public:
|
|||
* Function IsElementVisible
|
||||
* tests whether a given element category is visible. Keep this as an
|
||||
* 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.
|
||||
* @see enum PCB_VISIBLE
|
||||
*/
|
||||
bool IsElementVisible( int aPCB_VISIBLE )
|
||||
{
|
||||
return GetBoard()->IsElementVisible( aPCB_VISIBLE );
|
||||
}
|
||||
bool IsElementVisible( int aElement );
|
||||
|
||||
/**
|
||||
* Function SetElementVisibility
|
||||
* 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
|
||||
* @see enum PCB_VISIBLE
|
||||
*/
|
||||
void SetElementVisibility( int aPCB_VISIBLE, bool aNewState );
|
||||
void SetElementVisibility( int aElement, bool aNewState );
|
||||
|
||||
/**
|
||||
* Function SetVisibleAlls
|
||||
|
@ -1212,10 +1211,42 @@ public:
|
|||
void LockModule( MODULE* aModule, bool aLocked );
|
||||
void AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb );
|
||||
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 );
|
||||
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();
|
||||
|
||||
void DrawInfoPlace( wxDC* DC );
|
||||
|
||||
// Autorouting:
|
||||
|
|
|
@ -1,44 +1,51 @@
|
|||
/**************/
|
||||
/* 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 );
|
||||
|
||||
/* Initialize a value type, the cells included in the board surface of the
|
||||
* pad edge by pt_pad, with the margin reserved for isolation. */
|
||||
void Place_1_Pad_Board( BOARD * Pcb, D_PAD * pt_pad, int type, int marge,
|
||||
int op_logique );
|
||||
/* Initialize a color value, the cells included in the board edge of the
|
||||
* pad surface by pt_pad, with the margin reserved for isolation and the
|
||||
* half width of the runway
|
||||
* 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. */
|
||||
void TraceSegmentPcb( BOARD * Pcb, TRACK * pt_segm, int type, int marge,
|
||||
int op_logique );
|
||||
|
||||
void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int type,
|
||||
int op_logique );
|
||||
void TraceSegmentPcb( BOARD* Pcb, TRACK* pt_segm, int type, int marge, int op_logic );
|
||||
|
||||
/* Uses the color value of all cells included in the board
|
||||
* coord of the rectangle ux0, uy0 (top right corner)
|
||||
* a ux1, uy1 (lower left corner) (coord PCB)
|
||||
* the rectangle is horizontal (or vertical)
|
||||
* 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,
|
||||
int side, int color, int op_logique);
|
||||
void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
|
||||
int side, int color, int op_logic);
|
||||
|
||||
|
||||
/* Same as above, but the rectangle is inclined angle angle. */
|
||||
void TraceFilledRectangle( BOARD * Pcb, int ux0, int uy0, int ux1, int uy1,
|
||||
int angle, int masque_layer, int color,
|
||||
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);
|
||||
void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
|
||||
int angle, int masque_layer, int color, int op_logic );
|
||||
|
||||
/* QUEUE.CPP */
|
||||
void FreeQueue();
|
||||
|
@ -72,3 +79,6 @@ DIST_CELL GetDist( int aRow, int aCol, int aSide );
|
|||
void SetDist( int aRow, int aCol, int aSide, DIST_CELL );
|
||||
int GetDir( int aRow, int aCol, int aSide );
|
||||
void SetDir( int aRow, int aCol, int aSide, int aDir);
|
||||
|
||||
|
||||
#endif // _AR_PROTOS_H_
|
||||
|
|
|
@ -1,22 +1,25 @@
|
|||
/*******************************************/
|
||||
/* Routines to automatically place MODULES */
|
||||
/*******************************************/
|
||||
/**
|
||||
* @file autoplac.cpp
|
||||
* @brief Routiness to automatically place MODULES on a board.
|
||||
*/
|
||||
|
||||
#include "fctsys.h"
|
||||
#include "class_drawpanel.h"
|
||||
#include "confirm.h"
|
||||
#include "pcbnew.h"
|
||||
#include "wxPcbStruct.h"
|
||||
|
||||
#include "protos.h"
|
||||
#include "ar_protos.h"
|
||||
#include "autorout.h"
|
||||
#include "cell.h"
|
||||
#include "class_board_design_settings.h"
|
||||
#include "colors_selection.h"
|
||||
|
||||
#include "protos.h"
|
||||
|
||||
#define GAIN 16
|
||||
#define KEEP_OUT_MARGIN 500
|
||||
|
||||
#define GAIN 16
|
||||
#define PENALITE 500
|
||||
|
||||
/* Penalty for guidance given by CntRot90 and CntRot180:
|
||||
* graduated from 0 (rotation allowed) to 10 (rotation count null)
|
||||
|
@ -41,8 +44,7 @@ static const float OrientPenality[11] =
|
|||
#define OUT_OF_BOARD -2
|
||||
#define OCCUPED_By_MODULE -1
|
||||
|
||||
static wxPoint CurrPosition; // Current position of the current module
|
||||
// placement
|
||||
static wxPoint CurrPosition; // Current position of the current module placement
|
||||
static bool AutoPlaceShowAll = true;
|
||||
|
||||
float MinCout;
|
||||
|
@ -55,8 +57,9 @@ static void CreateKeepOutRectangle( BOARD* Pcb,
|
|||
int ux1,
|
||||
int uy1,
|
||||
int marge,
|
||||
int Penalite,
|
||||
int aKeepOut,
|
||||
int aLayerMask );
|
||||
|
||||
static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC );
|
||||
|
||||
|
||||
|
@ -169,7 +172,8 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
|
|||
case PLACE_INCREMENTAL:
|
||||
if( Module->m_ModuleStatus & MODULE_is_LOCKED )
|
||||
{
|
||||
Module->m_ModuleStatus &= ~MODULE_is_PLACED; break;
|
||||
Module->m_ModuleStatus &= ~MODULE_is_PLACED;
|
||||
break;
|
||||
}
|
||||
|
||||
if( !(Module->m_ModuleStatus & MODULE_is_PLACED) )
|
||||
|
@ -204,7 +208,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
|
|||
/* Display fill area of interest, barriers, penalties. */
|
||||
DrawInfoPlace( DC );
|
||||
|
||||
error = RecherchePlacementModule( Module, DC );
|
||||
error = GetOptimalModulePlacement( Module, DC );
|
||||
BestScore = MinCout;
|
||||
PosOK = CurrPosition;
|
||||
|
||||
|
@ -219,7 +223,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
|
|||
int Angle_Rot_Module = 1800;
|
||||
Rotate_Module( DC, Module, Angle_Rot_Module, false );
|
||||
Module->CalculateBoundingBox();
|
||||
error = RecherchePlacementModule( Module, DC );
|
||||
error = GetOptimalModulePlacement( Module, DC );
|
||||
MinCout *= OrientPenality[ii];
|
||||
|
||||
if( BestScore > MinCout ) /* This orientation is best. */
|
||||
|
@ -244,7 +248,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
|
|||
{
|
||||
int Angle_Rot_Module = 900;
|
||||
Rotate_Module( DC, Module, Angle_Rot_Module, false );
|
||||
error = RecherchePlacementModule( Module, DC );
|
||||
error = GetOptimalModulePlacement( Module, DC );
|
||||
MinCout *= OrientPenality[ii];
|
||||
|
||||
if( BestScore > MinCout ) /* This orientation is best. */
|
||||
|
@ -269,7 +273,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
|
|||
{
|
||||
int Angle_Rot_Module = 2700;
|
||||
Rotate_Module( DC, Module, Angle_Rot_Module, false );
|
||||
error = RecherchePlacementModule( Module, DC );
|
||||
error = GetOptimalModulePlacement( Module, DC );
|
||||
MinCout *= OrientPenality[ii];
|
||||
|
||||
if( BestScore > MinCout ) /* This orientation is best. */
|
||||
|
@ -368,24 +372,6 @@ void PCB_EDIT_FRAME::DrawInfoPlace( wxDC* DC )
|
|||
}
|
||||
|
||||
|
||||
/* Generate 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 PCB_EDIT_FRAME::GenPlaceBoard()
|
||||
{
|
||||
int jj, ii;
|
||||
|
@ -406,6 +392,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
|
|||
Board.m_GridRouting;
|
||||
GetBoard()->m_BoundaryBox.m_Pos.y -= GetBoard()->m_BoundaryBox.m_Pos.y %
|
||||
Board.m_GridRouting;
|
||||
|
||||
/* The boundary box must have its end point on placing grid: */
|
||||
wxPoint end = GetBoard()->m_BoundaryBox.GetEnd();
|
||||
end.x -= end.x % Board.m_GridRouting;
|
||||
|
@ -509,7 +496,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
|
|||
*/
|
||||
void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module )
|
||||
{
|
||||
int ox, oy, fx, fy, Penalite;
|
||||
int ox, oy, fx, fy;
|
||||
int marge = Board.m_GridRouting / 2;
|
||||
int layerMask;
|
||||
D_PAD* Pad;
|
||||
|
@ -562,45 +549,36 @@ void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module )
|
|||
|
||||
for( Pad = Module->m_Pads; Pad != NULL; Pad = Pad->Next() )
|
||||
{
|
||||
Place_1_Pad_Board( GetBoard(), Pad, CELL_is_MODULE, marge, WRITE_OR_CELL );
|
||||
::PlacePad( GetBoard(), Pad, CELL_is_MODULE, marge, WRITE_OR_CELL );
|
||||
}
|
||||
|
||||
/* Trace clearance. */
|
||||
marge = ( Board.m_GridRouting * Module->m_PadNum ) / GAIN;
|
||||
Penalite = PENALITE;
|
||||
CreateKeepOutRectangle( GetBoard(), ox, oy, fx, fy, marge, Penalite, layerMask );
|
||||
marge = ( Board.m_GridRouting * Module->m_PadNum ) / GAIN;
|
||||
CreateKeepOutRectangle( GetBoard(), ox, oy, fx, fy, marge, KEEP_OUT_MARGIN, layerMask );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Search for the optimal position of the module.
|
||||
* Entree:
|
||||
* Module tip MODULE struct module's place.
|
||||
* Returns:
|
||||
* 1 if placement impossible, 0 if OK
|
||||
* = MinCout and external variable = cost of best placement
|
||||
*/
|
||||
int PCB_EDIT_FRAME::RecherchePlacementModule( MODULE* Module, wxDC* DC )
|
||||
int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
|
||||
{
|
||||
int cx, cy;
|
||||
int ox, oy, fx, fy; /* occupying part of the module focuses on the cursor */
|
||||
int error = 1;
|
||||
int DisplayChevelu = 0;
|
||||
int showRat = 0;
|
||||
wxPoint LastPosOK;
|
||||
float mincout, cout, Score;
|
||||
int Penalite;
|
||||
int keepOut;
|
||||
bool TstOtherSide;
|
||||
|
||||
Module->DisplayInfo( this );
|
||||
aModule->DisplayInfo( this );
|
||||
|
||||
LastPosOK.x = GetBoard()->m_BoundaryBox.m_Pos.x;
|
||||
LastPosOK.y = GetBoard()->m_BoundaryBox.m_Pos.y;
|
||||
|
||||
cx = Module->m_Pos.x; cy = Module->m_Pos.y;
|
||||
ox = Module->m_BoundaryBox.m_Pos.x - cx;
|
||||
fx = Module->m_BoundaryBox.m_Size.x + ox;
|
||||
oy = Module->m_BoundaryBox.m_Pos.y - cy;
|
||||
fy = Module->m_BoundaryBox.m_Size.y + oy;
|
||||
cx = aModule->m_Pos.x; cy = aModule->m_Pos.y;
|
||||
ox = aModule->m_BoundaryBox.m_Pos.x - cx;
|
||||
fx = aModule->m_BoundaryBox.m_Size.x + ox;
|
||||
oy = aModule->m_BoundaryBox.m_Pos.y - cy;
|
||||
fy = aModule->m_BoundaryBox.m_Size.y + oy;
|
||||
|
||||
CurrPosition.x = GetBoard()->m_BoundaryBox.m_Pos.x - ox;
|
||||
CurrPosition.y = GetBoard()->m_BoundaryBox.m_Pos.y - oy;
|
||||
|
@ -624,10 +602,10 @@ int PCB_EDIT_FRAME::RecherchePlacementModule( MODULE* Module, wxDC* DC )
|
|||
D_PAD* Pad;
|
||||
int otherLayerMask = LAYER_BACK;
|
||||
|
||||
if( Module->GetLayer() == LAYER_N_BACK )
|
||||
if( aModule->GetLayer() == LAYER_N_BACK )
|
||||
otherLayerMask = LAYER_FRONT;
|
||||
|
||||
for( Pad = Module->m_Pads; Pad != NULL; Pad = Pad->Next() )
|
||||
for( Pad = aModule->m_Pads; Pad != NULL; Pad = Pad->Next() )
|
||||
{
|
||||
if( ( Pad->m_layerMask & otherLayerMask ) == 0 )
|
||||
continue;
|
||||
|
@ -637,7 +615,7 @@ int PCB_EDIT_FRAME::RecherchePlacementModule( MODULE* Module, wxDC* DC )
|
|||
}
|
||||
}
|
||||
|
||||
DrawModuleOutlines( DrawPanel, DC, Module );
|
||||
DrawModuleOutlines( DrawPanel, aDC, aModule );
|
||||
|
||||
mincout = -1.0;
|
||||
SetStatusText( wxT( "Score ??, pos ??" ) );
|
||||
|
@ -655,43 +633,44 @@ int PCB_EDIT_FRAME::RecherchePlacementModule( MODULE* Module, wxDC* DC )
|
|||
DrawPanel->m_AbortRequest = false;
|
||||
}
|
||||
|
||||
cx = Module->m_Pos.x; cy = Module->m_Pos.y;
|
||||
Module->m_BoundaryBox.m_Pos.x = ox + CurrPosition.x;
|
||||
Module->m_BoundaryBox.m_Pos.y = oy + CurrPosition.y;
|
||||
cx = aModule->m_Pos.x; cy = aModule->m_Pos.y;
|
||||
aModule->m_BoundaryBox.m_Pos.x = ox + CurrPosition.x;
|
||||
aModule->m_BoundaryBox.m_Pos.y = oy + CurrPosition.y;
|
||||
|
||||
DrawModuleOutlines( DrawPanel, DC, Module );
|
||||
DrawModuleOutlines( DrawPanel, aDC, aModule );
|
||||
|
||||
g_Offset_Module.x = cx - CurrPosition.x;
|
||||
CurrPosition.y = GetBoard()->m_BoundaryBox.m_Pos.y - oy;
|
||||
|
||||
/* Placement on grid. */
|
||||
CurrPosition.y -= CurrPosition.y % Board.m_GridRouting;
|
||||
|
||||
DrawModuleOutlines( DrawPanel, DC, Module );
|
||||
DrawModuleOutlines( DrawPanel, aDC, aModule );
|
||||
|
||||
for( ; CurrPosition.y < GetBoard()->m_BoundaryBox.GetBottom() - fy;
|
||||
CurrPosition.y += Board.m_GridRouting )
|
||||
{
|
||||
/* Erase traces. */
|
||||
DrawModuleOutlines( DrawPanel, DC, Module );
|
||||
DrawModuleOutlines( DrawPanel, aDC, aModule );
|
||||
|
||||
if( DisplayChevelu )
|
||||
Compute_Ratsnest_PlaceModule( DC );
|
||||
if( showRat )
|
||||
Compute_Ratsnest_PlaceModule( aDC );
|
||||
|
||||
DisplayChevelu = 0;
|
||||
Module->m_BoundaryBox.m_Pos.x = ox + CurrPosition.x;
|
||||
Module->m_BoundaryBox.m_Pos.y = oy + CurrPosition.y;
|
||||
showRat = 0;
|
||||
aModule->m_BoundaryBox.m_Pos.x = ox + CurrPosition.x;
|
||||
aModule->m_BoundaryBox.m_Pos.y = oy + CurrPosition.y;
|
||||
|
||||
g_Offset_Module.y = cy - CurrPosition.y;
|
||||
DrawModuleOutlines( DrawPanel, DC, Module );
|
||||
Penalite = TstModuleOnBoard( GetBoard(), Module, TstOtherSide );
|
||||
DrawModuleOutlines( DrawPanel, aDC, aModule );
|
||||
keepOut = TstModuleOnBoard( GetBoard(), aModule, TstOtherSide );
|
||||
|
||||
if( Penalite >= 0 ) /* c a d if the module can be placed. */
|
||||
if( keepOut >= 0 ) /* c a d if the module can be placed. */
|
||||
{
|
||||
error = 0;
|
||||
build_ratsnest_module( Module );
|
||||
cout = Compute_Ratsnest_PlaceModule( DC );
|
||||
DisplayChevelu = 1;
|
||||
Score = cout + (float) Penalite;
|
||||
build_ratsnest_module( aModule );
|
||||
cout = Compute_Ratsnest_PlaceModule( aDC );
|
||||
showRat = 1;
|
||||
Score = cout + (float) keepOut;
|
||||
|
||||
if( (mincout >= Score ) || (mincout < 0 ) )
|
||||
{
|
||||
|
@ -706,21 +685,21 @@ int PCB_EDIT_FRAME::RecherchePlacementModule( MODULE* Module, wxDC* DC )
|
|||
}
|
||||
}
|
||||
|
||||
if( DisplayChevelu )
|
||||
Compute_Ratsnest_PlaceModule( DC );
|
||||
if( showRat )
|
||||
Compute_Ratsnest_PlaceModule( aDC );
|
||||
|
||||
DisplayChevelu = 0;
|
||||
showRat = 0;
|
||||
}
|
||||
}
|
||||
|
||||
DrawModuleOutlines( DrawPanel, DC, Module ); /* erasing the last traces */
|
||||
DrawModuleOutlines( DrawPanel, aDC, aModule ); /* erasing the last traces */
|
||||
|
||||
if( DisplayChevelu )
|
||||
Compute_Ratsnest_PlaceModule( DC );
|
||||
if( showRat )
|
||||
Compute_Ratsnest_PlaceModule( aDC );
|
||||
|
||||
/* Regeneration of the modified variable. */
|
||||
Module->m_BoundaryBox.m_Pos.x = ox + cx;
|
||||
Module->m_BoundaryBox.m_Pos.y = oy + cy;
|
||||
aModule->m_BoundaryBox.m_Pos.x = ox + cx;
|
||||
aModule->m_BoundaryBox.m_Pos.y = oy + cy;
|
||||
CurrPosition = LastPosOK;
|
||||
|
||||
GetBoard()->m_Status_Pcb &= ~( RATSNEST_ITEM_LOCAL_OK | LISTE_PAD_OK );
|
||||
|
@ -793,12 +772,11 @@ int TstRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int side )
|
|||
* (ux, ux .. y0, y1):
|
||||
* (Sum of cells in terms of distance)
|
||||
*/
|
||||
unsigned int CalculePenaliteRectangle( BOARD* Pcb, int ux0, int uy0,
|
||||
int ux1, int uy1, int side )
|
||||
unsigned int CalculateKeepOutArea( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int side )
|
||||
{
|
||||
int row, col;
|
||||
int row_min, row_max, col_min, col_max;
|
||||
unsigned int Penalite;
|
||||
unsigned int keepOut;
|
||||
|
||||
ux0 -= Pcb->m_BoundaryBox.m_Pos.x;
|
||||
uy0 -= Pcb->m_BoundaryBox.m_Pos.y;
|
||||
|
@ -829,17 +807,17 @@ unsigned int CalculePenaliteRectangle( BOARD* Pcb, int ux0, int uy0,
|
|||
if( col_max >= ( Ncols - 1 ) )
|
||||
col_max = Ncols - 1;
|
||||
|
||||
Penalite = 0;
|
||||
keepOut = 0;
|
||||
|
||||
for( row = row_min; row <= row_max; row++ )
|
||||
{
|
||||
for( col = col_min; col <= col_max; col++ )
|
||||
{
|
||||
Penalite += (int) GetDist( row, col, side );
|
||||
keepOut += (int) GetDist( row, col, side );
|
||||
}
|
||||
}
|
||||
|
||||
return Penalite;
|
||||
return keepOut;
|
||||
}
|
||||
|
||||
|
||||
|
@ -850,7 +828,7 @@ unsigned int CalculePenaliteRectangle( BOARD* Pcb, int ux0, int uy0,
|
|||
int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide )
|
||||
{
|
||||
int ox, oy, fx, fy;
|
||||
int error, Penalite, marge, side, otherside;
|
||||
int error, marge, side, otherside;
|
||||
|
||||
side = TOP; otherside = BOTTOM;
|
||||
|
||||
|
@ -879,9 +857,7 @@ int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide )
|
|||
|
||||
marge = ( Board.m_GridRouting * Module->m_PadNum ) / GAIN;
|
||||
|
||||
Penalite = CalculePenaliteRectangle( Pcb, ox - marge, oy - marge,
|
||||
fx + marge, fy + marge, side );
|
||||
return Penalite;
|
||||
return CalculateKeepOutArea( Pcb, ox - marge, oy - marge, fx + marge, fy + marge, side );
|
||||
}
|
||||
|
||||
|
||||
|
@ -954,10 +930,10 @@ float PCB_EDIT_FRAME::Compute_Ratsnest_PlaceModule( wxDC* DC )
|
|||
|
||||
/* Build the cost map.
|
||||
* Cells ( in Dist mao ) inside the rect x0,y0 a x1,y1 are
|
||||
* incremented by value Penalite
|
||||
* incremented by value aKeepOut
|
||||
* Cell outside this rectangle, but inside the rectangle
|
||||
* x0,y0 -marge to x1,y1 + marge sont incrementede by a decreasing value
|
||||
* (Penalite ... 0). The decreasing value de pends on the distance to the first rectangle
|
||||
* (aKeepOut ... 0). The decreasing value de pends on the distance to the first rectangle
|
||||
* Therefore the cost is high in rect x0,y0 a x1,y1, and decrease outside this rectangle
|
||||
*/
|
||||
static void CreateKeepOutRectangle( BOARD* Pcb,
|
||||
|
@ -966,7 +942,7 @@ static void CreateKeepOutRectangle( BOARD* Pcb,
|
|||
int ux1,
|
||||
int uy1,
|
||||
int marge,
|
||||
int Penalite,
|
||||
int aKeepOut,
|
||||
int aLayerMask )
|
||||
{
|
||||
int row, col;
|
||||
|
@ -1034,7 +1010,7 @@ static void CreateKeepOutRectangle( BOARD* Pcb,
|
|||
for( col = col_min; col <= col_max; col++ )
|
||||
{
|
||||
cgain = 256;
|
||||
LocalKeepOut = Penalite;
|
||||
LocalKeepOut = aKeepOut;
|
||||
|
||||
if( col < pmarge )
|
||||
cgain = ( 256 * col ) / pmarge;
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
/***************************************/
|
||||
/* PCBNEW: Autorouting command control */
|
||||
/***************************************/
|
||||
/**
|
||||
* @file autorout.cpp
|
||||
* @brief Autorouting command and control.
|
||||
*/
|
||||
|
||||
#include "fctsys.h"
|
||||
#include "class_drawpanel.h"
|
||||
#include "pcbnew.h"
|
||||
#include "wxPcbStruct.h"
|
||||
|
||||
#include "pcbnew.h"
|
||||
#include "autorout.h"
|
||||
#include "cell.h"
|
||||
#include "zones.h"
|
||||
#include "class_board_design_settings.h"
|
||||
#include "ar_protos.h"
|
||||
|
||||
|
||||
int E_scale; /* Scaling factor of distance tables. */
|
||||
|
@ -41,8 +44,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
|
|||
}
|
||||
else
|
||||
{
|
||||
Route_Layer_TOP =
|
||||
Route_Layer_BOTTOM = LAYER_N_BACK;
|
||||
Route_Layer_TOP = Route_Layer_BOTTOM = LAYER_N_BACK;
|
||||
}
|
||||
|
||||
switch( mode )
|
||||
|
@ -78,11 +80,13 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
|
|||
|
||||
case ROUTE_PAD:
|
||||
Pad = (D_PAD*) GetScreen()->GetCurItem();
|
||||
|
||||
if( (Pad == NULL) || (Pad->Type() != TYPE_PAD) )
|
||||
{
|
||||
wxMessageBox( _( "Pad not selected" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -113,6 +117,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
|
|||
{
|
||||
if( ptmp->m_PadStart == pt_pad )
|
||||
ptmp->m_Status |= CH_ROUTE_REQ;
|
||||
|
||||
if( ptmp->m_PadEnd == pt_pad )
|
||||
ptmp->m_Status |= CH_ROUTE_REQ;
|
||||
}
|
||||
|
@ -123,6 +128,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
|
|||
case ROUTE_PAD:
|
||||
if( ( ptmp->m_PadStart == Pad ) || ( ptmp->m_PadEnd == Pad ) )
|
||||
ptmp->m_Status |= CH_ROUTE_REQ;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -131,9 +137,13 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
|
|||
|
||||
/* Calculation of no fixed routing to 5 mils and more. */
|
||||
Board.m_GridRouting = (int)GetScreen()->GetGridSize().x;
|
||||
|
||||
if( 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;
|
||||
|
||||
/* Calculated ncol and nrow, matrix size for routing. */
|
||||
|
@ -143,6 +153,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
|
|||
|
||||
/* Map the board */
|
||||
Nb_Sides = ONE_SIDE;
|
||||
|
||||
if( Route_Layer_TOP != Route_Layer_BOTTOM )
|
||||
Nb_Sides = TWO_SIDES;
|
||||
|
||||
|
@ -201,25 +212,33 @@ void DisplayBoard( EDA_DRAW_PANEL* panel, wxDC* DC )
|
|||
|
||||
maxi = 600 / Ncols;
|
||||
maxi = ( maxi * 3 ) / 4;
|
||||
|
||||
if( !maxi )
|
||||
maxi = 1;
|
||||
|
||||
GRSetDrawMode( DC, GR_COPY );
|
||||
|
||||
for( col = 0; col < Ncols; col++ )
|
||||
{
|
||||
for( row = 0; row < Nrows; row++ )
|
||||
{
|
||||
color = 0;
|
||||
dcell0 = GetCell( row, col, BOTTOM );
|
||||
|
||||
if( dcell0 & HOLE )
|
||||
color = GREEN;
|
||||
|
||||
// if( Nb_Sides )
|
||||
// dcell1 = GetCell( row, col, TOP );
|
||||
|
||||
if( dcell1 & HOLE )
|
||||
color |= RED;
|
||||
|
||||
// dcell0 |= dcell1;
|
||||
|
||||
if( !color && ( dcell0 & VIA_IMPOSSIBLE ) )
|
||||
color = BLUE;
|
||||
|
||||
if( dcell0 & CELL_is_EDGE )
|
||||
color = YELLOW;
|
||||
else if( dcell0 & CELL_is_ZONE )
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
/****************************************************/
|
||||
/* AUTOROUT.H */
|
||||
/****************************************************/
|
||||
/**
|
||||
* @file autorout.h
|
||||
*/
|
||||
|
||||
#ifndef AUTOROUT_H
|
||||
#define AUTOROUT_H
|
||||
|
||||
|
||||
class BOARD;
|
||||
|
||||
|
||||
#define TOP 0
|
||||
#define BOTTOM 1
|
||||
#define EMPTY 0
|
||||
|
@ -52,26 +55,27 @@ extern int MaxNodes; /* maximum number of nodes opened at one time */
|
|||
/* Structures useful to the generation of board as bitmap. */
|
||||
typedef char MATRIX_CELL;
|
||||
typedef int DIST_CELL;
|
||||
typedef char DIR_CELL;
|
||||
typedef char DIR_CELL;
|
||||
|
||||
class MATRIX_ROUTING_HEAD /* header of blocks of MATRIX_CELL */
|
||||
{
|
||||
public:
|
||||
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
|
||||
* cells */
|
||||
DIR_CELL* m_DirSide[MAX_SIDES_COUNT]; /* header of blocks of chars:pointers back to
|
||||
* source */
|
||||
bool m_InitBoardDone;
|
||||
int m_Layers;
|
||||
int m_GridRouting; // Size of grid for autoplace/autoroute
|
||||
EDA_RECT m_BrdBox; // Actual board bouding box
|
||||
int m_Nrows, m_Ncols;
|
||||
int m_MemSize;
|
||||
* cells */
|
||||
DIR_CELL* m_DirSide[MAX_SIDES_COUNT]; /* header of blocks of chars:pointers back to
|
||||
* source */
|
||||
bool m_InitBoardDone;
|
||||
int m_Layers;
|
||||
int m_GridRouting; // Size of grid for autoplace/autoroute
|
||||
EDA_RECT m_BrdBox; // Actual board bounding box
|
||||
int m_Nrows, m_Ncols;
|
||||
int m_MemSize;
|
||||
|
||||
public:
|
||||
MATRIX_ROUTING_HEAD();
|
||||
~MATRIX_ROUTING_HEAD();
|
||||
|
||||
bool ComputeMatrixSize( BOARD* aPcb );
|
||||
int InitBoard();
|
||||
void UnInitBoard();
|
||||
|
@ -88,8 +92,4 @@ extern MATRIX_ROUTING_HEAD Board; /* 2-sided board */
|
|||
#define WRITE_ADD_CELL 4
|
||||
|
||||
|
||||
#include "ar_protos.h"
|
||||
|
||||
|
||||
#endif // AUTOROUT_H
|
||||
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
/* BOARD.CPP : functions for autorouting */
|
||||
/**
|
||||
* @file board.cpp
|
||||
* @brief Functions for autorouting
|
||||
*/
|
||||
|
||||
#include "fctsys.h"
|
||||
#include "common.h"
|
||||
|
||||
#include "pcbnew.h"
|
||||
#include "autorout.h"
|
||||
#include "cell.h"
|
||||
#include "ar_protos.h"
|
||||
|
||||
|
||||
/*
|
||||
|
@ -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.y -= aPcb->m_BoundaryBox.m_Pos.y % m_GridRouting;
|
||||
m_BrdBox = aPcb->m_BoundaryBox;
|
||||
|
||||
/* The boundary box must have its end point on routing grid: */
|
||||
wxPoint end = m_BrdBox.GetEnd();
|
||||
end.x -= end.x % m_GridRouting;
|
||||
|
@ -115,19 +120,22 @@ void MATRIX_ROUTING_HEAD::UnInitBoard()
|
|||
/***** de-allocate Dir matrix *****/
|
||||
if( m_DirSide[ii] )
|
||||
{
|
||||
MyFree( m_DirSide[ii] ); m_DirSide[ii] = NULL;
|
||||
MyFree( m_DirSide[ii] );
|
||||
m_DirSide[ii] = NULL;
|
||||
}
|
||||
|
||||
/***** de-allocate Distances matrix *****/
|
||||
if( m_DistSide[ii] )
|
||||
{
|
||||
MyFree( m_DistSide[ii] ); m_DistSide[ii] = NULL;
|
||||
MyFree( m_DistSide[ii] );
|
||||
m_DistSide[ii] = NULL;
|
||||
}
|
||||
|
||||
/**** de-allocate cells matrix *****/
|
||||
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 )
|
|||
|
||||
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
|
||||
|
@ -250,7 +258,8 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
|
|||
break;
|
||||
|
||||
EDA_RECT textbox = PtText->GetTextBox( -1 );
|
||||
ux0 = textbox.GetX(); uy0 = textbox.GetY();
|
||||
ux0 = textbox.GetX();
|
||||
uy0 = textbox.GetY();
|
||||
dx = textbox.GetWidth();
|
||||
dy = textbox.GetHeight();
|
||||
|
||||
|
@ -310,7 +319,7 @@ int Build_Work( BOARD* Pcb )
|
|||
{
|
||||
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
|
||||
*/
|
||||
if( (pt_rats->m_Status & CH_ACTIF) == 0 )
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
/**
|
||||
* @file cell.h
|
||||
*/
|
||||
|
||||
#ifndef _CELL_H_
|
||||
#define _CELL_H_
|
||||
|
||||
|
||||
/* Bits characterizing cell */
|
||||
#define HOLE 0x01 /* a conducting hole or obstacle */
|
||||
#define CELL_is_MODULE 0x02 /* auto placement occupied by a module */
|
||||
#define CELL_is_EDGE 0x20 /* Area and auto-placement: limiting cell
|
||||
* contour (Board, Zone) */
|
||||
#define CELL_is_FRIEND 0x40 /* Area and auto-placement: cell part of the
|
||||
* net */
|
||||
#define CELL_is_EDGE 0x20 /* Area and auto-placement: limiting cell contour (Board, Zone) */
|
||||
#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 */
|
||||
|
||||
/* Bit masks for presence of obstacles to autorouting */
|
||||
|
@ -74,3 +80,7 @@
|
|||
#define FROM_WEST 7
|
||||
#define FROM_NORTHWEST 8
|
||||
#define FROM_OTHERSIDE 9
|
||||
|
||||
|
||||
#endif // _CELL_H_
|
||||
|
||||
|
|
|
@ -12,7 +12,11 @@
|
|||
#include "class_board_design_settings.h"
|
||||
|
||||
|
||||
class BOARD;
|
||||
class ZONE_CONTAINER;
|
||||
class SEGZONE;
|
||||
class TRACK;
|
||||
class PCB_EDIT_FRAME;
|
||||
|
||||
|
||||
// buffer of item candidates when search for items on the same track.
|
||||
|
@ -1183,7 +1187,7 @@ public:
|
|||
|
||||
/**
|
||||
* Function MarkTrace
|
||||
* marks a chain of trace segments, connected to \aaTrace.
|
||||
* marks a chain of trace segments, connected to \a aTrace.
|
||||
* <p>
|
||||
* Each segment is marked by setting the BUSY bit into m_Flags. Electrical
|
||||
* continuity is detected by walking each segment, and finally the segments
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @file class_edge_module.h
|
||||
* @file class_edge_mod.h
|
||||
* @brief EDGE_MODULE class definition.
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
/**********************************/
|
||||
/* classes to handle copper zones */
|
||||
/**********************************/
|
||||
/**
|
||||
* @file class_zone.h
|
||||
* @brief Classes to handle copper zones
|
||||
*/
|
||||
|
||||
#ifndef CLASS_ZONE_H
|
||||
#define CLASS_ZONE_H
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include "gr_basic.h"
|
||||
#include "PolyLine.h"
|
||||
|
@ -12,15 +14,25 @@
|
|||
#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 */
|
||||
class SEGMENT
|
||||
{
|
||||
public:
|
||||
wxPoint m_Start; // starting point of a segment
|
||||
wxPoint m_End; // ending point of a segment
|
||||
|
||||
public:
|
||||
SEGMENT() {}
|
||||
SEGMENT( const wxPoint & aStart, const wxPoint & aEnd)
|
||||
SEGMENT( const wxPoint& aStart, const wxPoint& aEnd)
|
||||
{
|
||||
m_Start = aStart;
|
||||
m_End = aEnd;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
* @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"
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
/****************************************************/
|
||||
/* PCB EDITOR: autorouting and "graphics" routines. */
|
||||
/****************************************************/
|
||||
/**
|
||||
* @file graphpcb.cpp
|
||||
* @brief PCB editor autorouting and "graphics" routines.
|
||||
*/
|
||||
|
||||
#include "fctsys.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "pcbnew.h"
|
||||
#include "autorout.h"
|
||||
#include "trigo.h"
|
||||
#include "cell.h"
|
||||
#include "ar_protos.h"
|
||||
|
||||
int ToMatrixCoordinate( int aPhysicalCoordinate );
|
||||
void TraceLignePcb( int x0,
|
||||
int y0,
|
||||
int x1,
|
||||
int y1,
|
||||
int layer,
|
||||
int color );
|
||||
|
||||
void TracePcbLine( int x0, int y0, int x1, int y1, int layer, int color );
|
||||
|
||||
void TraceArc( int ux0,
|
||||
int uy0,
|
||||
int ux1,
|
||||
|
@ -25,7 +23,7 @@ void TraceArc( int ux0,
|
|||
int lg,
|
||||
int layer,
|
||||
int color,
|
||||
int op_logique );
|
||||
int op_logic );
|
||||
|
||||
|
||||
static void DrawSegmentQcq( int ux0,
|
||||
|
@ -35,17 +33,18 @@ static void DrawSegmentQcq( int ux0,
|
|||
int lg,
|
||||
int layer,
|
||||
int color,
|
||||
int op_logique );
|
||||
int op_logic );
|
||||
|
||||
static void TraceFilledCercle( BOARD* Pcb,
|
||||
static void TraceFilledCircle( BOARD* Pcb,
|
||||
int cx,
|
||||
int cy,
|
||||
int radius,
|
||||
int aLayerMask,
|
||||
int color,
|
||||
int op_logique );
|
||||
static void TraceCercle( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
|
||||
int color, int op_logique );
|
||||
int op_logic );
|
||||
|
||||
static void TraceCircle( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
|
||||
int color, int op_logic );
|
||||
|
||||
/* Macro call to update cell. */
|
||||
#define OP_CELL( layer, dy, dx ) \
|
||||
|
@ -79,35 +78,24 @@ int ToMatrixCoordinate( int aPhysicalCoordinate )
|
|||
}
|
||||
|
||||
|
||||
/* Initialize a color value, the cells included in the board edge of the
|
||||
* pad surface by pt_pad, with the margin reserved for isolation and the
|
||||
* half width of the runway
|
||||
* 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_logique: type of writing in the cell (WRITE, OR)
|
||||
*/
|
||||
void Place_1_Pad_Board( BOARD* Pcb,
|
||||
D_PAD* pt_pad,
|
||||
int color,
|
||||
int marge,
|
||||
int op_logique )
|
||||
void PlacePad( BOARD* Pcb, D_PAD* pt_pad, int color, int marge, int op_logic )
|
||||
{
|
||||
int dx, dy;
|
||||
wxPoint shape_pos = pt_pad->ReturnShapePos();
|
||||
|
||||
dx = pt_pad->m_Size.x / 2; dx += marge;
|
||||
dx = pt_pad->m_Size.x / 2;
|
||||
dx += marge;
|
||||
|
||||
if( pt_pad->m_PadShape == PAD_CIRCLE )
|
||||
{
|
||||
TraceFilledCercle( Pcb, shape_pos.x, shape_pos.y, dx,
|
||||
pt_pad->m_layerMask, color, op_logique );
|
||||
TraceFilledCircle( Pcb, shape_pos.x, shape_pos.y, dx,
|
||||
pt_pad->m_layerMask, color, op_logic );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
dy = pt_pad->m_Size.y / 2; dy += marge;
|
||||
dy = pt_pad->m_Size.y / 2;
|
||||
dy += marge;
|
||||
|
||||
if( pt_pad->m_PadShape == PAD_TRAPEZOID )
|
||||
{
|
||||
|
@ -126,33 +114,33 @@ void Place_1_Pad_Board( BOARD* Pcb,
|
|||
|
||||
TraceFilledRectangle( Pcb, shape_pos.x - dx, shape_pos.y - dy,
|
||||
shape_pos.x + dx, shape_pos.y + dy,
|
||||
pt_pad->m_layerMask, color, op_logique );
|
||||
pt_pad->m_layerMask, color, op_logic );
|
||||
}
|
||||
else
|
||||
{
|
||||
TraceFilledRectangle( Pcb, shape_pos.x - dx, shape_pos.y - dy,
|
||||
shape_pos.x + dx, shape_pos.y + dy,
|
||||
(int) pt_pad->m_Orient,
|
||||
pt_pad->m_layerMask, color, op_logique );
|
||||
pt_pad->m_layerMask, color, op_logic );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Initialize a color value, the cells included in the board rea of the
|
||||
/* Initialize a color value, the cells included in the board area of the
|
||||
* circle center cx, cy.
|
||||
* Parameters:
|
||||
* radius: a value add to the radius or half the score pad
|
||||
* aLayerMask: layer occupied
|
||||
* color: mask write in cells
|
||||
* op_logique: type of writing in the cell (WRITE, OR)
|
||||
* op_logic: type of writing in the cell (WRITE, OR)
|
||||
*/
|
||||
void TraceFilledCercle( BOARD* Pcb,
|
||||
void TraceFilledCircle( BOARD* Pcb,
|
||||
int cx,
|
||||
int cy,
|
||||
int radius,
|
||||
int aLayerMask,
|
||||
int color,
|
||||
int op_logique )
|
||||
int op_logic )
|
||||
{
|
||||
int row, col;
|
||||
int ux0, uy0, ux1, uy1;
|
||||
|
@ -179,7 +167,7 @@ void TraceFilledCercle( BOARD* Pcb,
|
|||
if( trace == 0 )
|
||||
return;
|
||||
|
||||
switch( op_logique )
|
||||
switch( op_logic )
|
||||
{
|
||||
default:
|
||||
case WRITE_CELL:
|
||||
|
@ -217,23 +205,25 @@ void TraceFilledCercle( BOARD* Pcb,
|
|||
/* Calculate limit coordinates of cells belonging to the rectangle. */
|
||||
row_max = uy1 / Board.m_GridRouting;
|
||||
col_max = ux1 / Board.m_GridRouting;
|
||||
row_min = uy0 / Board.m_GridRouting; // if (uy0 > row_min*Board.m_GridRouting
|
||||
// ) row_min++;
|
||||
col_min = ux0 / Board.m_GridRouting; // if (ux0 > col_min*Board.m_GridRouting
|
||||
// ) col_min++;
|
||||
row_min = uy0 / Board.m_GridRouting; // if (uy0 > row_min*Board.m_GridRouting) row_min++;
|
||||
col_min = ux0 / Board.m_GridRouting; // if (ux0 > col_min*Board.m_GridRouting) col_min++;
|
||||
|
||||
if( row_min < 0 )
|
||||
row_min = 0;
|
||||
|
||||
if( row_max >= (Nrows - 1) )
|
||||
row_max = Nrows - 1;
|
||||
|
||||
if( col_min < 0 )
|
||||
col_min = 0;
|
||||
|
||||
if( col_max >= (Ncols - 1) )
|
||||
col_max = Ncols - 1;
|
||||
|
||||
/* Calculate coordinate limits of cell belonging to the rectangle. */
|
||||
if( row_min > row_max )
|
||||
row_max = row_min;
|
||||
|
||||
if( col_min > col_max )
|
||||
col_max = col_min;
|
||||
|
||||
|
@ -243,6 +233,7 @@ void TraceFilledCercle( BOARD* Pcb,
|
|||
{
|
||||
fdisty = (float) ( cy - ( row * Board.m_GridRouting ) );
|
||||
fdisty *= fdisty;
|
||||
|
||||
for( col = col_min; col <= col_max; col++ )
|
||||
{
|
||||
fdistx = (float) ( cx - ( col * Board.m_GridRouting ) );
|
||||
|
@ -253,8 +244,10 @@ void TraceFilledCercle( BOARD* Pcb,
|
|||
|
||||
if( trace & 1 )
|
||||
WriteCell( row, col, BOTTOM, color );
|
||||
|
||||
if( trace & 2 )
|
||||
WriteCell( row, col, TOP, color );
|
||||
|
||||
tstwrite = 1;
|
||||
}
|
||||
}
|
||||
|
@ -266,13 +259,13 @@ void TraceFilledCercle( BOARD* Pcb,
|
|||
* (Adverse event: pad off grid in the center of the 4 neighboring
|
||||
* diagonal) */
|
||||
distmin = Board.m_GridRouting / 2 + 1;
|
||||
fdistmin = ( (float) distmin * distmin ) * 2; /* Distance to center point
|
||||
* diagonally */
|
||||
fdistmin = ( (float) distmin * distmin ) * 2; /* Distance to center point diagonally */
|
||||
|
||||
for( row = row_min; row <= row_max; row++ )
|
||||
{
|
||||
fdisty = (float) ( cy - ( row * Board.m_GridRouting ) );
|
||||
fdisty *= fdisty;
|
||||
|
||||
for( col = col_min; col <= col_max; col++ )
|
||||
{
|
||||
fdistx = (float) ( cx - ( col * Board.m_GridRouting ) );
|
||||
|
@ -283,6 +276,7 @@ void TraceFilledCercle( BOARD* Pcb,
|
|||
|
||||
if( trace & 1 )
|
||||
WriteCell( row, col, BOTTOM, color );
|
||||
|
||||
if( trace & 2 )
|
||||
WriteCell( row, col, TOP, color );
|
||||
}
|
||||
|
@ -290,18 +284,12 @@ void TraceFilledCercle( BOARD* Pcb,
|
|||
}
|
||||
|
||||
|
||||
/* Draws a segment of track on the BOARD.
|
||||
*/
|
||||
void TraceSegmentPcb( BOARD* Pcb,
|
||||
TRACK* pt_segm,
|
||||
int color,
|
||||
int marge,
|
||||
int op_logique )
|
||||
void TraceSegmentPcb( BOARD* Pcb, TRACK* pt_segm, int color, int marge, int op_logic )
|
||||
{
|
||||
int demi_largeur;
|
||||
int half_width;
|
||||
int ux0, uy0, ux1, uy1;
|
||||
|
||||
demi_largeur = ( pt_segm->m_Width / 2 ) + marge;
|
||||
half_width = ( pt_segm->m_Width / 2 ) + marge;
|
||||
|
||||
/* Calculate the bounding rectangle of the segment (if H, V or Via) */
|
||||
ux0 = pt_segm->m_Start.x - Pcb->m_BoundaryBox.m_Pos.x;
|
||||
|
@ -313,8 +301,10 @@ void TraceSegmentPcb( BOARD* Pcb,
|
|||
if( pt_segm->Type() == TYPE_VIA )
|
||||
{
|
||||
int mask_layer = 0;
|
||||
|
||||
if( pt_segm->IsOnLayer( Route_Layer_BOTTOM ) )
|
||||
mask_layer = 1 << Route_Layer_BOTTOM;
|
||||
|
||||
if( pt_segm->IsOnLayer( Route_Layer_TOP ) )
|
||||
{
|
||||
if( mask_layer == 0 )
|
||||
|
@ -327,63 +317,52 @@ void TraceSegmentPcb( BOARD* Pcb,
|
|||
mask_layer = -1;
|
||||
|
||||
if( mask_layer )
|
||||
TraceFilledCercle( Pcb, pt_segm->m_Start.x, pt_segm->m_Start.y,
|
||||
demi_largeur, mask_layer, color, op_logique );
|
||||
TraceFilledCircle( Pcb, pt_segm->m_Start.x, pt_segm->m_Start.y,
|
||||
half_width, mask_layer, color, op_logic );
|
||||
return;
|
||||
}
|
||||
|
||||
int layer = pt_segm->GetLayer();
|
||||
|
||||
if( color == VIA_IMPOSSIBLE )
|
||||
layer = -1;
|
||||
|
||||
/* The segment is here a straight line or a circle or an arc.: */
|
||||
if( pt_segm->m_Shape == S_CIRCLE )
|
||||
{
|
||||
TraceCercle( ux0, uy0, ux1, uy1, demi_largeur, layer, color,
|
||||
op_logique );
|
||||
TraceCircle( ux0, uy0, ux1, uy1, half_width, layer, color, op_logic );
|
||||
return;
|
||||
}
|
||||
|
||||
if( pt_segm->m_Shape == S_ARC )
|
||||
{
|
||||
TraceArc( ux0, uy0, ux1, uy1, pt_segm->m_Param, demi_largeur, layer,
|
||||
color, op_logique );
|
||||
TraceArc( ux0, uy0, ux1, uy1, pt_segm->m_Param, half_width, layer, color, op_logic );
|
||||
return;
|
||||
}
|
||||
|
||||
/* The segment is here a line segment. */
|
||||
if( ( ux0 != ux1 ) && ( uy0 != uy1 ) ) // Segment tilts.
|
||||
{
|
||||
DrawSegmentQcq( ux0, uy0, ux1, uy1, demi_largeur, layer, color,
|
||||
op_logique );
|
||||
DrawSegmentQcq( ux0, uy0, ux1, uy1, half_width, layer, color, op_logic );
|
||||
return;
|
||||
}
|
||||
|
||||
// The segment is horizontal or vertical.
|
||||
// DrawHVSegment(ux0,uy0,ux1,uy1,demi_largeur,layer,color,op_logique);
|
||||
// F4EXB 051018-01
|
||||
DrawSegmentQcq( ux0, uy0, ux1, uy1, demi_largeur, layer, color,
|
||||
op_logique ); // F4EXB 051018-01
|
||||
return; // F4EXB 051018-01
|
||||
DrawSegmentQcq( ux0, uy0, ux1, uy1, half_width, layer, color, op_logic );
|
||||
}
|
||||
|
||||
|
||||
/* Draws a line, if layer = -1 on all layers
|
||||
*/
|
||||
void TraceLignePcb( int x0,
|
||||
int y0,
|
||||
int x1,
|
||||
int y1,
|
||||
int layer,
|
||||
int color,
|
||||
int op_logique )
|
||||
void TracePcbLine( int x0, int y0, int x1, int y1, int layer, int color, int op_logic )
|
||||
{
|
||||
int dx, dy, lim;
|
||||
int cumul, inc, il, delta;
|
||||
|
||||
void (* WriteCell)( int, int, int, MATRIX_CELL );
|
||||
|
||||
switch( op_logique )
|
||||
switch( op_logic )
|
||||
{
|
||||
default:
|
||||
case WRITE_CELL:
|
||||
|
@ -406,16 +385,21 @@ void TraceLignePcb( int x0,
|
|||
{
|
||||
if( y1 < y0 )
|
||||
EXCHG( y0, y1 );
|
||||
|
||||
dy = y0 / Board.m_GridRouting;
|
||||
lim = y1 / Board.m_GridRouting;
|
||||
dx = x0 / Board.m_GridRouting;
|
||||
|
||||
/* Clipping limits of board. */
|
||||
if( ( dx < 0 ) || ( dx >= Ncols ) )
|
||||
return;
|
||||
|
||||
if( dy < 0 )
|
||||
dy = 0;
|
||||
|
||||
if( lim >= Nrows )
|
||||
lim = Nrows - 1;
|
||||
|
||||
for( ; dy <= lim; dy++ )
|
||||
{
|
||||
OP_CELL( layer, dy, dx );
|
||||
|
@ -428,16 +412,21 @@ void TraceLignePcb( int x0,
|
|||
{
|
||||
if( x1 < x0 )
|
||||
EXCHG( x0, x1 );
|
||||
|
||||
dx = x0 / Board.m_GridRouting;
|
||||
lim = x1 / Board.m_GridRouting;
|
||||
dy = y0 / Board.m_GridRouting;
|
||||
|
||||
/* Clipping limits of board. */
|
||||
if( ( dy < 0 ) || ( dy >= Nrows ) )
|
||||
return;
|
||||
|
||||
if( dx < 0 )
|
||||
dx = 0;
|
||||
|
||||
if( lim >= Ncols )
|
||||
lim = Ncols - 1;
|
||||
|
||||
for( ; dx <= lim; dx++ )
|
||||
{
|
||||
OP_CELL( layer, dy, dx );
|
||||
|
@ -457,15 +446,17 @@ void TraceLignePcb( int x0,
|
|||
dx = x0 / Board.m_GridRouting;
|
||||
lim = x1 / Board.m_GridRouting;
|
||||
dy = y0 / Board.m_GridRouting;
|
||||
inc = 1; if( y1 < y0 )
|
||||
inc = 1;
|
||||
|
||||
if( y1 < y0 )
|
||||
inc = -1;
|
||||
|
||||
il = lim - dx; cumul = il / 2;
|
||||
delta = abs( y1 - y0 ) / Board.m_GridRouting;
|
||||
|
||||
for( ; dx <= lim; )
|
||||
{
|
||||
if( ( dx >= 0 ) && ( dy >= 0 )
|
||||
&& ( dx < Ncols ) && ( dy < Nrows ) )
|
||||
if( ( dx >= 0 ) && ( dy >= 0 ) && ( dx < Ncols ) && ( dy < Nrows ) )
|
||||
{
|
||||
OP_CELL( layer, dy, dx );
|
||||
}
|
||||
|
@ -492,6 +483,7 @@ void TraceLignePcb( int x0,
|
|||
lim = y1 / Board.m_GridRouting;
|
||||
dx = x0 / Board.m_GridRouting;
|
||||
inc = 1;
|
||||
|
||||
if( x1 < x0 )
|
||||
inc = -1;
|
||||
|
||||
|
@ -500,8 +492,7 @@ void TraceLignePcb( int x0,
|
|||
|
||||
for( ; dy <= lim; )
|
||||
{
|
||||
if( ( dx >= 0 ) && ( dy >= 0 )
|
||||
&& ( dx < Ncols ) && ( dy < Nrows ) )
|
||||
if( ( dx >= 0 ) && ( dy >= 0 ) && ( dx < Ncols ) && ( dy < Nrows ) )
|
||||
{
|
||||
OP_CELL( layer, dy, dx );
|
||||
}
|
||||
|
@ -519,16 +510,8 @@ void TraceLignePcb( int x0,
|
|||
}
|
||||
|
||||
|
||||
/* Overloaded functions.
|
||||
*
|
||||
* Uses the color value of all cells included in the board coordinate of
|
||||
* the rectangle ux0, uy0 (top left corner)
|
||||
* A UX1, UY1 (bottom right corner)
|
||||
* The rectangle is horizontal (or vertical)
|
||||
* Contact PCBs.
|
||||
*/
|
||||
void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
|
||||
int aLayerMask, int color, int op_logique )
|
||||
int aLayerMask, int color, int op_logic )
|
||||
{
|
||||
int row, col;
|
||||
int row_min, row_max, col_min, col_max;
|
||||
|
@ -545,7 +528,7 @@ void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
|
|||
if( trace == 0 )
|
||||
return;
|
||||
|
||||
switch( op_logique )
|
||||
switch( op_logic )
|
||||
{
|
||||
default:
|
||||
case WRITE_CELL:
|
||||
|
@ -578,18 +561,24 @@ void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
|
|||
row_max = uy1 / Board.m_GridRouting;
|
||||
col_max = ux1 / Board.m_GridRouting;
|
||||
row_min = uy0 / Board.m_GridRouting;
|
||||
|
||||
if( uy0 > row_min * Board.m_GridRouting )
|
||||
row_min++;
|
||||
|
||||
col_min = ux0 / Board.m_GridRouting;
|
||||
|
||||
if( ux0 > col_min * Board.m_GridRouting )
|
||||
col_min++;
|
||||
|
||||
if( row_min < 0 )
|
||||
row_min = 0;
|
||||
|
||||
if( row_max >= ( Nrows - 1 ) )
|
||||
row_max = Nrows - 1;
|
||||
|
||||
if( col_min < 0 )
|
||||
col_min = 0;
|
||||
|
||||
if( col_max >= ( Ncols - 1 ) )
|
||||
col_max = Ncols - 1;
|
||||
|
||||
|
@ -599,6 +588,7 @@ void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
|
|||
{
|
||||
if( trace & 1 )
|
||||
WriteCell( row, col, BOTTOM, color );
|
||||
|
||||
if( trace & 2 )
|
||||
WriteCell( row, col, TOP, color );
|
||||
}
|
||||
|
@ -606,17 +596,8 @@ void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
|
|||
}
|
||||
|
||||
|
||||
/* Overloaded functions.
|
||||
*
|
||||
* Uses the color value of all cells included in the board coordinate of the
|
||||
* rectangle ux0, uy0 (top right corner)
|
||||
* a UX1, UY1 (lower left corner)
|
||||
* the rectangle is the value of turning angle (in degrees 0.1)
|
||||
* contact PCBs.
|
||||
*/
|
||||
void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
|
||||
int angle, int aLayerMask, int color,
|
||||
int op_logique )
|
||||
int angle, int aLayerMask, int color, int op_logic )
|
||||
{
|
||||
int row, col;
|
||||
int cx, cy; /* Center of rectangle */
|
||||
|
@ -631,13 +612,15 @@ void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
|
|||
trace = 1; /* Trace on BOTTOM */
|
||||
|
||||
if( aLayerMask & g_TabOneLayerMask[Route_Layer_TOP] )
|
||||
{
|
||||
if( Nb_Sides )
|
||||
trace |= 2; /* Trace on TOP */
|
||||
}
|
||||
|
||||
if( trace == 0 )
|
||||
return;
|
||||
|
||||
switch( op_logique )
|
||||
switch( op_logic )
|
||||
{
|
||||
default:
|
||||
case WRITE_CELL:
|
||||
|
@ -675,18 +658,24 @@ void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
|
|||
row_max = ( cy + radius ) / Board.m_GridRouting;
|
||||
col_max = ( cx + radius ) / Board.m_GridRouting;
|
||||
row_min = ( cy - radius ) / Board.m_GridRouting;
|
||||
|
||||
if( uy0 > row_min * Board.m_GridRouting )
|
||||
row_min++;
|
||||
|
||||
col_min = ( cx - radius ) / Board.m_GridRouting;
|
||||
|
||||
if( ux0 > col_min * Board.m_GridRouting )
|
||||
col_min++;
|
||||
|
||||
if( row_min < 0 )
|
||||
row_min = 0;
|
||||
|
||||
if( row_max >= ( Nrows - 1 ) )
|
||||
row_max = Nrows - 1;
|
||||
|
||||
if( col_min < 0 )
|
||||
col_min = 0;
|
||||
|
||||
if( col_max >= ( Ncols - 1 ) )
|
||||
col_max = Ncols - 1;
|
||||
|
||||
|
@ -697,16 +686,22 @@ void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
|
|||
rotrow = row * Board.m_GridRouting;
|
||||
rotcol = col * Board.m_GridRouting;
|
||||
RotatePoint( &rotcol, &rotrow, cx, cy, -angle );
|
||||
|
||||
if( rotrow <= uy0 )
|
||||
continue;
|
||||
|
||||
if( rotrow >= uy1 )
|
||||
continue;
|
||||
|
||||
if( rotcol <= ux0 )
|
||||
continue;
|
||||
|
||||
if( rotcol >= ux1 )
|
||||
continue;
|
||||
|
||||
if( trace & 1 )
|
||||
WriteCell( row, col, BOTTOM, color );
|
||||
|
||||
if( trace & 2 )
|
||||
WriteCell( row, col, TOP, color );
|
||||
}
|
||||
|
@ -720,7 +715,7 @@ void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
|
|||
* coordinates are in PCB units (0.1 mil) are relative to the Board
|
||||
*/
|
||||
void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
|
||||
int color, int op_logique )
|
||||
int color, int op_logic )
|
||||
{
|
||||
int row, col;
|
||||
int inc;
|
||||
|
@ -731,7 +726,7 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
|
|||
int angle;
|
||||
int cx, cy, dx, dy;
|
||||
|
||||
switch( op_logique )
|
||||
switch( op_logic )
|
||||
{
|
||||
default:
|
||||
case WRITE_CELL:
|
||||
|
@ -764,15 +759,19 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
|
|||
|
||||
/* Calculating the incrementing the Y axis */
|
||||
inc = 1;
|
||||
|
||||
if( uy1 < uy0 )
|
||||
inc = -1;
|
||||
|
||||
demi_pas = Board.m_GridRouting / 2;
|
||||
|
||||
col_min = ( ux0 - lg ) / Board.m_GridRouting;
|
||||
|
||||
if( col_min < 0 )
|
||||
col_min = 0;
|
||||
|
||||
col_max = ( ux1 + lg + demi_pas ) / Board.m_GridRouting;
|
||||
|
||||
if( col_max > ( Ncols - 1 ) )
|
||||
col_max = Ncols - 1;
|
||||
|
||||
|
@ -789,10 +788,13 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
|
|||
|
||||
if( row_min < 0 )
|
||||
row_min = 0;
|
||||
|
||||
if( row_min > ( Nrows - 1 ) )
|
||||
row_min = Nrows - 1;
|
||||
|
||||
if( row_max < 0 )
|
||||
row_max = 0;
|
||||
|
||||
if( row_max > ( Nrows - 1 ) )
|
||||
row_max = Nrows - 1;
|
||||
|
||||
|
@ -800,24 +802,30 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
|
|||
dy = uy1 - uy0;
|
||||
|
||||
if( dx )
|
||||
{
|
||||
angle = (int) ( atan2( (double) dy, (double) dx ) * 1800 / M_PI );
|
||||
}
|
||||
else
|
||||
{
|
||||
angle = 900;
|
||||
|
||||
if( dy < 0 )
|
||||
angle = -900;
|
||||
}
|
||||
|
||||
RotatePoint( &dx, &dy, angle ); /* dx = length, dy = 0 */
|
||||
|
||||
for( col = col_min; col <= col_max; col++ )
|
||||
{
|
||||
int cxr;
|
||||
cxr = ( col * Board.m_GridRouting ) - ux0;
|
||||
|
||||
for( row = row_min; row <= row_max; row++ )
|
||||
{
|
||||
cy = (row * Board.m_GridRouting) - uy0;
|
||||
cx = cxr;
|
||||
RotatePoint( &cx, &cy, angle );
|
||||
|
||||
if( abs( cy ) > lg )
|
||||
continue; /* The point is too far on the Y axis. */
|
||||
|
||||
|
@ -829,18 +837,21 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
|
|||
OP_CELL( layer, row, col );
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Examination of extremities are rounded. */
|
||||
if( ( cx < 0 ) && ( cx >= -lg ) )
|
||||
{
|
||||
if( ( ( cx * cx ) + ( cy * cy ) ) <= ( lg * lg ) )
|
||||
OP_CELL( layer, row, col );
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if( ( cx > dx ) && ( cx <= ( dx + lg ) ) )
|
||||
{
|
||||
if( ( ( ( cx - dx ) * ( cx - dx ) ) + ( cy * cy ) )
|
||||
<= ( lg * lg ) )
|
||||
if( ( ( ( cx - dx ) * ( cx - dx ) ) + ( cy * cy ) ) <= ( lg * lg ) )
|
||||
OP_CELL( layer, row, col );
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -853,8 +864,8 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
|
|||
* coord in PCB units (0.1 million) relating to the origin
|
||||
* pt_pcb-> m_PcbBox.m_Xmin, Y's board.
|
||||
*/
|
||||
void TraceCercle( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
|
||||
int color, int op_logique )
|
||||
void TraceCircle( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
|
||||
int color, int op_logic )
|
||||
{
|
||||
int radius, nb_segm;
|
||||
int x0, y0, // Starting point of the current segment trace.
|
||||
|
@ -866,36 +877,38 @@ void TraceCercle( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
|
|||
|
||||
x0 = x1 = radius;
|
||||
y0 = y1 = 0;
|
||||
|
||||
if( lg < 1 )
|
||||
lg = 1;
|
||||
|
||||
nb_segm = ( 2 * radius ) / lg;
|
||||
|
||||
if( nb_segm < 5 )
|
||||
nb_segm = 5;
|
||||
|
||||
if( nb_segm > 100 )
|
||||
nb_segm = 100;
|
||||
|
||||
for( ii = 1; ii < nb_segm; ii++ )
|
||||
{
|
||||
angle = (3600 * ii) / nb_segm;
|
||||
x1 = (int) ( radius * fcosinus[angle] );
|
||||
y1 = (int) ( radius * fsinus[angle] );
|
||||
DrawSegmentQcq( x0 + ux0, y0 + uy0, x1 + ux0, y1 + uy0, lg,
|
||||
layer, color, op_logique );
|
||||
x1 = (int) ( radius * cos( DEG2RAD( (double)angle / 10.0 ) ) );
|
||||
y1 = (int) ( radius * sin( DEG2RAD( (double)angle / 10.0 ) ) );
|
||||
DrawSegmentQcq( x0 + ux0, y0 + uy0, x1 + ux0, y1 + uy0, lg, layer, color, op_logic );
|
||||
x0 = x1;
|
||||
y0 = y1;
|
||||
}
|
||||
|
||||
DrawSegmentQcq( x1 + ux0, y1 + uy0, ux0 + radius, uy0, lg, layer,
|
||||
color, op_logique );
|
||||
DrawSegmentQcq( x1 + ux0, y1 + uy0, ux0 + radius, uy0, lg, layer, color, op_logic );
|
||||
}
|
||||
|
||||
|
||||
/* Fills all cells contained in arc with color , using op_logique.
|
||||
* half-width lg ux center, starting in ux y0, y1 is set to color.
|
||||
* coord in PCB units (0.1 mil) relating to the origin
|
||||
* of the board.
|
||||
/* 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 )
|
||||
int layer, int color, int op_logic )
|
||||
{
|
||||
int radius, nb_segm;
|
||||
int x0, y0, // Starting point of the current segment trace
|
||||
|
@ -909,12 +922,16 @@ void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg,
|
|||
x0 = ux1 - ux0;
|
||||
y0 = uy1 - uy0;
|
||||
StAngle = ArcTangente( uy1 - uy0, ux1 - ux0 );
|
||||
|
||||
if( lg < 1 )
|
||||
lg = 1;
|
||||
|
||||
nb_segm = ( 2 * radius ) / lg;
|
||||
nb_segm = ( nb_segm * abs( ArcAngle ) ) / 3600;
|
||||
|
||||
if( nb_segm < 5 )
|
||||
nb_segm = 5;
|
||||
|
||||
if( nb_segm > 100 )
|
||||
nb_segm = 100;
|
||||
|
||||
|
@ -929,14 +946,10 @@ void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg,
|
|||
while( angle < 0 )
|
||||
angle += 3600;
|
||||
|
||||
x1 = (int) ( radius * fcosinus[angle] );
|
||||
y1 = (int) ( radius * fsinus[angle] );
|
||||
DrawSegmentQcq( x0 + ux0, y0 + uy0, x1 + ux0, y1 + uy0, lg, layer,
|
||||
color, op_logique );
|
||||
x1 = (int) ( radius * cos( DEG2RAD( (double)angle / 10.0 ) ) );
|
||||
y1 = (int) ( radius * sin( DEG2RAD( (double)angle / 10.0 ) ) );
|
||||
DrawSegmentQcq( x0 + ux0, y0 + uy0, x1 + ux0, y1 + uy0, lg, layer, color, op_logic );
|
||||
x0 = x1;
|
||||
y0 = y1;
|
||||
}
|
||||
|
||||
// DrawSegmentQcq(x1+ux0,y1+uy0, ux0+radius, uy0,lg,layer, color,
|
||||
// op_logique);
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
m_Layers->SetRenderState( aPCB_VISIBLE, aNewState );
|
||||
return GetBoard()->IsElementVisible( aElement );
|
||||
}
|
||||
|
||||
|
||||
void PCB_EDIT_FRAME::SetElementVisibility( int aElement, bool aNewState )
|
||||
{
|
||||
GetBoard()->SetElementVisibility( aElement, aNewState );
|
||||
m_Layers->SetRenderState( aElement, aNewState );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
/*************/
|
||||
/* solve.cpp */
|
||||
/*************/
|
||||
/**
|
||||
* @file solve.cpp
|
||||
*/
|
||||
|
||||
#include "fctsys.h"
|
||||
#include "class_drawpanel.h"
|
||||
#include "confirm.h"
|
||||
#include "autorout.h"
|
||||
#include "wxPcbStruct.h"
|
||||
|
||||
#include "pcbnew.h"
|
||||
#include "wxPcbStruct.h"
|
||||
#include "class_board_design_settings.h"
|
||||
#include "autorout.h"
|
||||
#include "protos.h"
|
||||
|
||||
#include "ar_protos.h"
|
||||
#include "cell.h"
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
|
|||
int col_source,
|
||||
int row_target,
|
||||
int col_target,
|
||||
RATSNEST_ITEM* pt_chevelu );
|
||||
RATSNEST_ITEM* pt_rat );
|
||||
|
||||
static int Retrace( PCB_EDIT_FRAME* pcbframe,
|
||||
wxDC* DC,
|
||||
|
@ -372,7 +372,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
|
|||
int col_source,
|
||||
int row_target,
|
||||
int col_target,
|
||||
RATSNEST_ITEM* pt_chevelu )
|
||||
RATSNEST_ITEM* pt_rat )
|
||||
{
|
||||
int r, c, side, d, apx_dist, nr, nc;
|
||||
int result, skip;
|
||||
|
@ -412,8 +412,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
|
|||
/* Set active layers mask. */
|
||||
routeLayerMask = topLayerMask | bottomLayerMask;
|
||||
|
||||
pt_cur_ch = pt_chevelu;
|
||||
current_net_code = pt_chevelu->GetNet();
|
||||
pt_cur_ch = pt_rat;
|
||||
current_net_code = pt_rat->GetNet();
|
||||
padLayerMaskStart = pt_cur_ch->m_PadStart->m_layerMask;
|
||||
padLayerMaskEnd = pt_cur_ch->m_PadEnd->m_layerMask;
|
||||
|
||||
|
@ -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. */
|
||||
pcbframe->SetStatusText( wxT( "Gen Cells" ) );
|
||||
|
||||
Place_1_Pad_Board( pcbframe->GetBoard(), pt_cur_ch->m_PadStart,
|
||||
CURRENT_PAD, marge, WRITE_OR_CELL );
|
||||
Place_1_Pad_Board( pcbframe->GetBoard(), pt_cur_ch->m_PadEnd,
|
||||
CURRENT_PAD, marge, WRITE_OR_CELL );
|
||||
PlacePad( pcbframe->GetBoard(), pt_cur_ch->m_PadStart, CURRENT_PAD, marge, WRITE_OR_CELL );
|
||||
PlacePad( pcbframe->GetBoard(), pt_cur_ch->m_PadEnd, CURRENT_PAD, marge, WRITE_OR_CELL );
|
||||
|
||||
/* Regenerates the remaining barriers (which may encroach on the placement
|
||||
* bits precedent)
|
||||
/* Regenerates the remaining barriers (which may encroach on the placement bits precedent)
|
||||
*/
|
||||
i = pcbframe->GetBoard()->GetPadsCount();
|
||||
|
||||
|
@ -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 ) )
|
||||
{
|
||||
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,
|
|||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
selfok2[i].present = 0;
|
||||
|
||||
if( curcell & selfok2[i].trace )
|
||||
selfok2[i].present = 1;
|
||||
}
|
||||
|
@ -631,7 +629,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
|
|||
|
||||
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? */
|
||||
if( nr < 0 || nr >= Nrows || nc < 0 || nc >= Ncols )
|
||||
|
@ -781,10 +780,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
|
|||
}
|
||||
|
||||
end_of_route:
|
||||
Place_1_Pad_Board( pcbframe->GetBoard(), pt_cur_ch->m_PadStart,
|
||||
~CURRENT_PAD, marge, WRITE_AND_CELL );
|
||||
Place_1_Pad_Board( pcbframe->GetBoard(), pt_cur_ch->m_PadEnd,
|
||||
~CURRENT_PAD, marge, WRITE_AND_CELL );
|
||||
PlacePad( pcbframe->GetBoard(), pt_cur_ch->m_PadStart, ~CURRENT_PAD, marge, WRITE_AND_CELL );
|
||||
PlacePad( pcbframe->GetBoard(), pt_cur_ch->m_PadEnd, ~CURRENT_PAD, marge, WRITE_AND_CELL );
|
||||
|
||||
msg.Printf( wxT( "Activity: Open %d Closed %d Moved %d"),
|
||||
OpenNodes, ClosNodes, MoveNodes );
|
||||
|
@ -986,8 +983,7 @@ static int Retrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC,
|
|||
y = GetDir( r0, c0, s0 );
|
||||
|
||||
/* see if target or hole */
|
||||
if( ( ( r1 == row_target ) && ( c1 == col_target ) )
|
||||
|| ( s1 != s0 ) )
|
||||
if( ( ( r1 == row_target ) && ( c1 == col_target ) ) || ( s1 != s0 ) )
|
||||
{
|
||||
int p_dir;
|
||||
|
||||
|
|
|
@ -1,25 +1,26 @@
|
|||
/************************/
|
||||
/* Autorouting routines */
|
||||
/************************/
|
||||
/**
|
||||
* @file work.cpp
|
||||
* @brief Automatic routing routines
|
||||
*/
|
||||
|
||||
#include "fctsys.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "pcbnew.h"
|
||||
#include "autorout.h"
|
||||
#include "cell.h"
|
||||
#include "ar_protos.h"
|
||||
|
||||
|
||||
struct CWORK /* a unit of work is a hole-pair to connect */
|
||||
{
|
||||
struct CWORK* Next;
|
||||
int FromRow; /* source row */
|
||||
int FromCol; /* source column */
|
||||
int net_code; /* net_code */
|
||||
int ToRow; /* target row */
|
||||
int ToCol; /* target column */
|
||||
int FromRow; /* source row */
|
||||
int FromCol; /* source column */
|
||||
int net_code; /* net_code */
|
||||
int ToRow; /* target row */
|
||||
int ToCol; /* target column */
|
||||
RATSNEST_ITEM* pt_rats; /* Corresponding ratsnest */
|
||||
int ApxDist; /* approximate distance */
|
||||
int ApxDist; /* approximate distance */
|
||||
int Cost; /* cost for sort by length */
|
||||
int Priority; /* route priority */
|
||||
};
|
||||
|
@ -90,14 +91,18 @@ int SetWork( int r1,
|
|||
p->Priority = pri;
|
||||
p->Next = NULL;
|
||||
if( Head ) /* attach at end */
|
||||
|
||||
Tail->Next = p;
|
||||
else /* first in list */
|
||||
Head = Current = p;
|
||||
|
||||
Tail = p;
|
||||
return 1;
|
||||
}
|
||||
else /* can't get any more memory */
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,12 +142,15 @@ void SortWork()
|
|||
CWORK* r;
|
||||
|
||||
q0 = q1 = NULL;
|
||||
|
||||
while( (p = Head) != NULL ) /* prioritize each work item */
|
||||
{
|
||||
Head = Head->Next;
|
||||
|
||||
if( p->Priority ) /* put at end of priority list */
|
||||
{
|
||||
p->Next = NULL;
|
||||
|
||||
if( (r = q0) == NULL ) /* empty list? */
|
||||
q0 = p;
|
||||
else /* attach at end */
|
||||
|
@ -203,6 +211,7 @@ static int GetCost( int r1, int c1, int r2, int c2 )
|
|||
{
|
||||
mx = dy; my = dx;
|
||||
}
|
||||
|
||||
if( mx )
|
||||
incl += (2 * (float) my / mx);
|
||||
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
#include "class_drawpanel.h"
|
||||
#include "confirm.h"
|
||||
#include "kicad_string.h"
|
||||
#include "pcbnew.h"
|
||||
#include "wxPcbStruct.h"
|
||||
|
||||
#include "pcbnew.h"
|
||||
#include "dialog_exchange_modules_base.h"
|
||||
#include "ar_protos.h"
|
||||
|
||||
|
||||
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,
|
|||
FILE* FichCmp, * NewFile;
|
||||
char Line[1024];
|
||||
wxString msg;
|
||||
char* result; // quiet compiler
|
||||
|
||||
if( old_name == new_name )
|
||||
return 0;
|
||||
|
@ -155,6 +155,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
|
|||
fn.SetExt( NetCmpExtBuffer );
|
||||
|
||||
FichCmp = wxFopen( fn.GetFullPath(), wxT( "rt" ) );
|
||||
|
||||
if( FichCmp == NULL )
|
||||
{
|
||||
if( ShowError )
|
||||
|
@ -162,12 +163,14 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
|
|||
msg.Printf( _( "file %s not found" ), GetChars( fn.GetFullPath() ) );
|
||||
m_WinMessages->AppendText( msg );
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
tmpFileName = fn;
|
||||
tmpFileName.SetExt( wxT( "$$$" ) );
|
||||
NewFile = wxFopen( tmpFileName.GetFullPath(), wxT( "wt" ) );
|
||||
|
||||
if( NewFile == NULL )
|
||||
{
|
||||
if( ShowError )
|
||||
|
@ -176,14 +179,15 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
|
|||
GetChars( tmpFileName.GetFullPath() ) );
|
||||
m_WinMessages->AppendText( msg );
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
result = fgets( Line, sizeof(Line), FichCmp );
|
||||
fprintf( NewFile, "Cmp-Mod V01 Genere par PcbNew le %s\n",
|
||||
DateAndTime( Line ) );
|
||||
fgets( Line, sizeof(Line), FichCmp );
|
||||
fprintf( NewFile, "Cmp-Mod V01 Genere par PcbNew le %s\n", DateAndTime( Line ) );
|
||||
|
||||
bool start_descr = false;
|
||||
|
||||
while( fgets( Line, sizeof(Line), FichCmp ) != NULL )
|
||||
{
|
||||
if( strnicmp( Line, "Reference = ", 9 ) == 0 )
|
||||
|
@ -191,14 +195,14 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
|
|||
char buf[1024];
|
||||
strcpy( buf, Line + 12 );
|
||||
strtok( buf, ";\n\r" );
|
||||
|
||||
if( stricmp( buf, TO_UTF8( reference ) ) == 0 )
|
||||
{
|
||||
start_descr = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( (strnicmp( Line, "Begin", 5 ) == 0)
|
||||
|| (strnicmp( Line, "End", 3 ) == 0) )
|
||||
if( (strnicmp( Line, "Begin", 5 ) == 0) || (strnicmp( Line, "End", 3 ) == 0) )
|
||||
{
|
||||
start_descr = false;
|
||||
}
|
||||
|
@ -212,6 +216,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
|
|||
|
||||
start_descr = false;
|
||||
}
|
||||
|
||||
fputs( Line, NewFile );
|
||||
}
|
||||
|
||||
|
@ -243,6 +248,7 @@ void DIALOG_EXCHANGE_MODULE::Change_Current_Module()
|
|||
{
|
||||
if( m_Parent->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
|
||||
m_Parent->Compile_Ratsnest( NULL, true );
|
||||
|
||||
m_Parent->DrawPanel->Refresh();
|
||||
}
|
||||
|
||||
|
@ -274,10 +280,12 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
|
|||
|
||||
if( m_Parent->GetBoard()->m_Modules == NULL )
|
||||
return;
|
||||
|
||||
if( newmodulename == wxEmptyString )
|
||||
return;
|
||||
|
||||
lib_reference = m_CurrentModule->m_LibRef;
|
||||
|
||||
if( aUseValue )
|
||||
{
|
||||
check_module_value = true;
|
||||
|
@ -305,16 +313,20 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
|
|||
* points the board or is NULL
|
||||
*/
|
||||
Module = m_Parent->GetBoard()->m_Modules.GetLast();
|
||||
|
||||
for( ; Module && ( Module->Type() == TYPE_MODULE ); Module = PtBack )
|
||||
{
|
||||
PtBack = Module->Back();
|
||||
|
||||
if( lib_reference.CmpNoCase( Module->m_LibRef ) != 0 )
|
||||
continue;
|
||||
|
||||
if( check_module_value )
|
||||
{
|
||||
if( value.CmpNoCase( Module->m_Value->m_Text ) != 0 )
|
||||
continue;
|
||||
}
|
||||
|
||||
if( Change_1_Module( Module, newmodulename, &pickList, ShowErr ) )
|
||||
change = true;
|
||||
else if( ShowErr )
|
||||
|
@ -325,6 +337,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
|
|||
{
|
||||
if( m_Parent->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
|
||||
m_Parent->Compile_Ratsnest( NULL, true );
|
||||
|
||||
m_Parent->DrawPanel->Refresh();
|
||||
}
|
||||
|
||||
|
@ -362,9 +375,11 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleAll()
|
|||
* points the board or is NULL
|
||||
*/
|
||||
Module = m_Parent->GetBoard()->m_Modules.GetLast();
|
||||
|
||||
for( ; Module && ( Module->Type() == TYPE_MODULE ); Module = PtBack )
|
||||
{
|
||||
PtBack = Module->Back();
|
||||
|
||||
if( Change_1_Module( Module, Module->m_LibRef, &pickList, ShowErr ) )
|
||||
change = true;
|
||||
else if( ShowErr )
|
||||
|
@ -375,8 +390,10 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleAll()
|
|||
{
|
||||
if( m_Parent->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
|
||||
m_Parent->Compile_Ratsnest( NULL, true );
|
||||
|
||||
m_Parent->DrawPanel->Refresh();
|
||||
}
|
||||
|
||||
if( pickList.GetCount() )
|
||||
m_Parent->SaveCopyInUndoList( pickList, UR_UNSPECIFIED );
|
||||
}
|
||||
|
@ -434,10 +451,7 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module,
|
|||
|
||||
m_Parent->Exchange_Module( Module, NewModule, aUndoPickList );
|
||||
|
||||
Maj_ListeCmp( NewModule->m_Reference->m_Text,
|
||||
oldnamecmp,
|
||||
namecmp,
|
||||
ShowError );
|
||||
Maj_ListeCmp( NewModule->m_Reference->m_Text, oldnamecmp, namecmp, ShowError );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -460,8 +474,7 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule,
|
|||
wxPoint oldpos;
|
||||
D_PAD* pad, * old_pad;
|
||||
|
||||
if( ( aOldModule->Type() != TYPE_MODULE )
|
||||
|| ( aNewModule->Type() != TYPE_MODULE ) )
|
||||
if( ( aOldModule->Type() != TYPE_MODULE ) || ( aNewModule->Type() != TYPE_MODULE ) )
|
||||
{
|
||||
wxMessageBox( wxT( "PCB_EDIT_FRAME::Exchange_Module() StuctType error" ) );
|
||||
return;
|
||||
|
@ -501,15 +514,16 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule,
|
|||
|
||||
/* Update pad netnames ( when possible) */
|
||||
pad = aNewModule->m_Pads;
|
||||
|
||||
for( ; pad != NULL; pad = pad->Next() )
|
||||
{
|
||||
pad->SetNetname( wxEmptyString );
|
||||
pad->SetNet( 0 );
|
||||
old_pad = aOldModule->m_Pads;
|
||||
|
||||
for( ; old_pad != NULL; old_pad = old_pad->Next() )
|
||||
{
|
||||
if( strnicmp( pad->m_Padname, old_pad->m_Padname,
|
||||
sizeof(pad->m_Padname) ) == 0 )
|
||||
if( strnicmp( pad->m_Padname, old_pad->m_Padname, sizeof(pad->m_Padname) ) == 0 )
|
||||
{
|
||||
pad->SetNetname( old_pad->GetNetname() );
|
||||
pad->SetNet( old_pad->GetNet() );
|
||||
|
@ -526,7 +540,9 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule,
|
|||
aUndoPickList->PushItem( picker_new );
|
||||
}
|
||||
else
|
||||
{
|
||||
aOldModule->DeleteStructure();
|
||||
}
|
||||
|
||||
GetBoard()->m_Status_Pcb = 0;
|
||||
aNewModule->m_Flags = 0;
|
||||
|
@ -564,7 +580,6 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
|
|||
MODULE* Module = GetBoard()->m_Modules;
|
||||
wxString msg;
|
||||
wxString wildcard;
|
||||
char* result; // quiet compiler
|
||||
|
||||
if( Module == NULL )
|
||||
{
|
||||
|
@ -575,8 +590,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
|
|||
/* Calculation file name by changing the extension name to NetList */
|
||||
fn = GetScreen()->GetFileName();
|
||||
fn.SetExt( NetCmpExtBuffer );
|
||||
wildcard = _( "Component files (." ) + NetCmpExtBuffer + wxT( ")|*." ) +
|
||||
NetCmpExtBuffer;
|
||||
wildcard = _( "Component files (." ) + NetCmpExtBuffer + wxT( ")|*." ) + NetCmpExtBuffer;
|
||||
|
||||
wxFileDialog dlg( this, _( "Save Component Files" ), wxGetCwd(),
|
||||
fn.GetFullName(), wildcard,
|
||||
|
@ -588,6 +602,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
|
|||
fn = dlg.GetPath();
|
||||
|
||||
FichCmp = wxFopen( fn.GetFullPath(), wxT( "wt" ) );
|
||||
|
||||
if( FichCmp == NULL )
|
||||
{
|
||||
msg = _( "Unable to create file " ) + fn.GetFullPath();
|
||||
|
@ -595,9 +610,8 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
|
|||
return;
|
||||
}
|
||||
|
||||
result = fgets( Line, sizeof(Line), FichCmp );
|
||||
fprintf( FichCmp, "Cmp-Mod V01 Genere par PcbNew le %s\n",
|
||||
DateAndTime( Line ) );
|
||||
fgets( Line, sizeof(Line), FichCmp );
|
||||
fprintf( FichCmp, "Cmp-Mod V01 Genere par PcbNew le %s\n", DateAndTime( Line ) );
|
||||
|
||||
for( ; Module != NULL; Module = Module->Next() )
|
||||
{
|
||||
|
@ -610,8 +624,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
|
|||
fprintf( FichCmp, "ValeurCmp = %s;\n",
|
||||
!Module->m_Value->m_Text.IsEmpty() ?
|
||||
TO_UTF8( Module->m_Value->m_Text ) : "[NoVal]" );
|
||||
fprintf( FichCmp, "IdModule = %s;\n",
|
||||
TO_UTF8( Module->m_LibRef ) );
|
||||
fprintf( FichCmp, "IdModule = %s;\n", TO_UTF8( Module->m_LibRef ) );
|
||||
fprintf( FichCmp, "EndCmp\n" );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue