2009-11-18 12:52:19 +00:00
|
|
|
/*******************************************/
|
|
|
|
/* mounde.cpp - Microwave pcb layout code. */
|
|
|
|
/*******************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "trigo.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "kicad_string.h"
|
|
|
|
#include "gestfich.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "pcbnew.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2009-10-28 11:48:47 +00:00
|
|
|
#include "class_board_design_settings.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "protos.h"
|
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#define COEFF_COUNT 6
|
2008-12-06 12:49:33 +00:00
|
|
|
static double* PolyEdges;
|
|
|
|
static int PolyEdgesCount;
|
|
|
|
static double ShapeScaleX, ShapeScaleY;
|
|
|
|
static wxSize ShapeSize;
|
|
|
|
static int PolyShapeType;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-02-26 00:37:04 +00:00
|
|
|
|
|
|
|
static void Exit_Self( WinEDA_DrawPanel* Panel, wxDC* DC );
|
2009-11-18 12:52:19 +00:00
|
|
|
static EDGE_MODULE* gen_arc( MODULE* aModule,
|
|
|
|
EDGE_MODULE* PtSegm,
|
|
|
|
int cX,
|
|
|
|
int cY,
|
|
|
|
int angle );
|
2009-11-23 21:03:26 +00:00
|
|
|
static void ShowBoundingBoxMicroWaveInductor( WinEDA_DrawPanel* panel,
|
2009-11-18 12:52:19 +00:00
|
|
|
wxDC* DC,
|
|
|
|
bool erase );
|
2009-02-26 00:37:04 +00:00
|
|
|
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
class SELFPCB
|
2009-02-26 00:37:04 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-11-18 12:52:19 +00:00
|
|
|
int forme; // Shape: coil, spiral, etc ..
|
2009-02-26 00:37:04 +00:00
|
|
|
int orient; // 0..3600
|
2009-11-18 12:52:19 +00:00
|
|
|
int valeur; // Value.
|
2009-02-26 00:37:04 +00:00
|
|
|
wxPoint m_Start;
|
2009-11-18 12:52:19 +00:00
|
|
|
wxPoint m_End;
|
2009-02-26 00:37:04 +00:00
|
|
|
wxSize m_Size;
|
2009-11-18 12:52:19 +00:00
|
|
|
D_PAD* pt_pad_start, * pt_pad_end;
|
|
|
|
int lng; // Trace length.
|
|
|
|
int m_Width;
|
|
|
|
int nbrin; // Number of segments.
|
|
|
|
int lbrin; // Length of segments.
|
|
|
|
int rayon; // Radius between segments.
|
|
|
|
int delta; // distance between pads
|
2009-02-26 00:37:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static SELFPCB Mself;
|
|
|
|
static int Self_On;
|
2009-11-18 12:52:19 +00:00
|
|
|
static int Bl_X0, Bl_Y0, Bl_Xf, Bl_Yf;
|
2009-02-26 00:37:04 +00:00
|
|
|
|
|
|
|
|
2009-11-23 21:03:26 +00:00
|
|
|
/* This function shows on screen the bounding box of the inductor that will be
|
|
|
|
* created at the end of the build inductor process
|
|
|
|
*/
|
|
|
|
static void ShowBoundingBoxMicroWaveInductor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
2009-02-26 00:37:04 +00:00
|
|
|
{
|
|
|
|
int deltaX, deltaY;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Calculate the orientation and size of the window:
|
|
|
|
* - Orient = vertical or horizontal (maximum dimensions)
|
|
|
|
* - Size.x = Size.y / 2
|
2009-02-26 00:37:04 +00:00
|
|
|
*/
|
|
|
|
GRSetDrawMode( DC, GR_XOR );
|
2009-11-18 12:52:19 +00:00
|
|
|
|
|
|
|
if( erase )
|
2009-02-26 00:37:04 +00:00
|
|
|
{
|
|
|
|
GRRect( &panel->m_ClipBox, DC, Bl_X0, Bl_Y0, Bl_Xf, Bl_Yf, YELLOW );
|
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
deltaX = ( panel->GetScreen()->m_Curseur.x - Mself.m_Start.x ) / 4;
|
|
|
|
deltaY = ( panel->GetScreen()->m_Curseur.y - Mself.m_Start.y ) / 4;
|
2009-02-26 00:37:04 +00:00
|
|
|
|
|
|
|
Mself.orient = 900;
|
|
|
|
if( abs( deltaX ) > abs( deltaY ) )
|
|
|
|
Mself.orient = 0;
|
|
|
|
|
|
|
|
if( Mself.orient == 0 )
|
|
|
|
{
|
|
|
|
Bl_X0 = Mself.m_Start.x;
|
|
|
|
Bl_Y0 = Mself.m_Start.y - deltaX;
|
|
|
|
Bl_Xf = panel->GetScreen()->m_Curseur.x;
|
|
|
|
Bl_Yf = Mself.m_Start.y + deltaX;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Bl_X0 = Mself.m_Start.x - deltaY;
|
|
|
|
Bl_Y0 = Mself.m_Start.y;
|
|
|
|
Bl_Xf = Mself.m_Start.x + deltaY;
|
|
|
|
Bl_Yf = panel->GetScreen()->m_Curseur.y;
|
|
|
|
}
|
|
|
|
GRRect( &panel->m_ClipBox, DC, Bl_X0, Bl_Y0, Bl_Xf, Bl_Yf, YELLOW );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Exit_Self( WinEDA_DrawPanel* Panel, wxDC* DC )
|
|
|
|
{
|
|
|
|
if( Self_On )
|
|
|
|
{
|
|
|
|
Self_On = 0;
|
2009-11-18 12:52:19 +00:00
|
|
|
Panel->ManageCurseur( Panel, DC, 0 );
|
2009-02-26 00:37:04 +00:00
|
|
|
Panel->ManageCurseur = NULL;
|
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WinEDA_PcbFrame::Begin_Self( wxDC* DC )
|
|
|
|
{
|
|
|
|
if( Self_On )
|
|
|
|
{
|
|
|
|
Genere_Self( DC );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Mself.m_Start = GetScreen()->m_Curseur;
|
|
|
|
|
|
|
|
Self_On = 1;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Update the initial coordinates. */
|
2009-02-26 00:37:04 +00:00
|
|
|
GetScreen()->m_O_Curseur = GetScreen()->m_Curseur;
|
2009-04-05 20:49:15 +00:00
|
|
|
UpdateStatusBar();
|
2009-02-26 00:37:04 +00:00
|
|
|
|
|
|
|
Bl_X0 = Mself.m_Start.x;
|
|
|
|
Bl_Y0 = Mself.m_Start.y;
|
|
|
|
|
|
|
|
Bl_Xf = Bl_X0;
|
|
|
|
Bl_Yf = Bl_Y0;
|
|
|
|
|
2009-11-23 21:03:26 +00:00
|
|
|
DrawPanel->ManageCurseur = ShowBoundingBoxMicroWaveInductor;
|
2009-02-26 00:37:04 +00:00
|
|
|
DrawPanel->ForceCloseManageCurseur = Exit_Self;
|
2009-11-18 12:52:19 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, 0 );
|
2009-02-26 00:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Create a self-shaped coil
|
|
|
|
* - Length Mself.lng
|
|
|
|
* - Extremities Mself.m_Start and Mself.m_End
|
|
|
|
* - Constraint: m_Start.x = m_End.x (self Vertical)
|
|
|
|
* Or m_Start.y = m_End.y (self Horizontal)
|
2009-02-26 00:37:04 +00:00
|
|
|
*
|
2009-11-18 12:52:19 +00:00
|
|
|
* We must determine:
|
|
|
|
* Mself.nbrin = number of segments perpendicular to the direction
|
|
|
|
* (The coil nbrin will demicercles + 1 + 2 1 / 4 circle)
|
|
|
|
* Mself.lbrin = length of a strand
|
|
|
|
* Mself.rayon = radius of rounded parts of the coil
|
|
|
|
* Mself.delta = segments extremities connection between him and the coil even
|
2009-02-26 00:37:04 +00:00
|
|
|
*
|
2009-11-18 12:52:19 +00:00
|
|
|
* The equations are
|
|
|
|
* Mself.m_Size.x = 2 * Mself.rayon + Mself.lbrin
|
|
|
|
* Mself.m_Size.y * Mself.delta = 2 + 2 * Mself.nbrin * Mself.rayon
|
|
|
|
* Mself.lng = 2 * Mself.delta / / connections to the coil
|
|
|
|
+ (Mself.nbrin-2) * Mself.lbrin / / length of the strands except 1st and last
|
|
|
|
+ (Mself.nbrin 1) * (PI * Mself.rayon) / / length of rounded
|
|
|
|
* Mself.lbrin + / 2 - Melf.rayon * 2) / / length of 1st and last bit
|
2009-02-26 00:37:04 +00:00
|
|
|
*
|
2009-11-18 12:52:19 +00:00
|
|
|
* The constraints are:
|
|
|
|
* Nbrin >= 2
|
|
|
|
* Mself.rayon < Mself.m_Size.x
|
|
|
|
* Mself.m_Size.y = Mself.rayon * 4 + 2 * Mself.raccord
|
|
|
|
* Mself.lbrin> Mself.rayon * 2
|
2009-02-26 00:37:04 +00:00
|
|
|
*
|
2009-11-18 12:52:19 +00:00
|
|
|
* The calculation is conducted in the following way:
|
|
|
|
* Initially:
|
|
|
|
* Nbrin = 2
|
|
|
|
* Radius = 4 * m_Size.x (arbitrarily fixed value)
|
|
|
|
* Then:
|
|
|
|
* Increasing the number of segments to the desired length
|
|
|
|
* (Radius decreases if necessary)
|
2009-02-26 00:37:04 +00:00
|
|
|
*
|
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
|
2009-02-26 00:37:04 +00:00
|
|
|
{
|
|
|
|
EDGE_MODULE* PtSegm, * LastSegm, * FirstSegm, * newedge;
|
|
|
|
MODULE* Module;
|
|
|
|
D_PAD* PtPad;
|
|
|
|
int ii, ll, lextbrin;
|
|
|
|
double fcoeff;
|
|
|
|
bool abort = FALSE;
|
|
|
|
wxString msg;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
2009-02-26 00:37:04 +00:00
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
|
|
|
|
if( Self_On == 0 )
|
|
|
|
{
|
|
|
|
DisplayError( this, wxT( "Starting point not init.." ) );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Self_On = 0;
|
|
|
|
|
|
|
|
Mself.m_End = GetScreen()->m_Curseur;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Fitting of parameters to simplify the calculation:
|
|
|
|
* The starting point must be coord departure from the end point */
|
|
|
|
if( Mself.orient == 0 ) // Horizontal
|
2009-02-26 00:37:04 +00:00
|
|
|
{
|
|
|
|
Mself.m_End.y = Mself.m_Start.y;
|
|
|
|
if( Mself.m_Start.x > Mself.m_End.x )
|
|
|
|
EXCHG( Mself.m_Start.x, Mself.m_End.x );
|
|
|
|
Mself.m_Size.y = Mself.m_End.x - Mself.m_Start.x;
|
|
|
|
Mself.lng = Mself.m_Size.y;
|
|
|
|
}
|
2009-11-18 12:52:19 +00:00
|
|
|
else // Vertical
|
2009-02-26 00:37:04 +00:00
|
|
|
{
|
|
|
|
Mself.m_End.x = Mself.m_Start.x;
|
|
|
|
if( Mself.m_Start.y > Mself.m_End.y )
|
|
|
|
EXCHG( Mself.m_Start.y, Mself.m_End.y );
|
|
|
|
Mself.m_Size.y = Mself.m_End.y - Mself.m_Start.y;
|
|
|
|
Mself.lng = Mself.m_Size.y;
|
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Enter the desired length. */
|
2009-02-26 00:37:04 +00:00
|
|
|
if( !g_UnitMetric )
|
|
|
|
{
|
|
|
|
fcoeff = 10000.0;
|
|
|
|
msg.Printf( wxT( "%1.4f" ), Mself.lng / fcoeff );
|
2009-11-18 12:52:19 +00:00
|
|
|
abort = Get_Message( _( "Length(inch):" ), _( "Length" ), msg, this );
|
2009-02-26 00:37:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fcoeff = 10000.0 / 25.4;
|
|
|
|
msg.Printf( wxT( "%2.3f" ), Mself.lng / fcoeff );
|
2009-11-18 12:52:19 +00:00
|
|
|
abort = Get_Message( _( "Length(mm):" ), _( "Length" ), msg, this );
|
2009-02-26 00:37:04 +00:00
|
|
|
}
|
|
|
|
if( abort )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
double fval;
|
|
|
|
if( !msg.ToDouble( &fval ) )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "Incorrect number, abort" ) );
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-05-21 17:42:42 +00:00
|
|
|
Mself.lng = wxRound( fval * fcoeff );
|
2009-02-26 00:37:04 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Control values (ii = minimum length) */
|
2009-02-26 00:37:04 +00:00
|
|
|
if( Mself.lng < Mself.m_Size.y )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "Requested length < minimum length" ) );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Calculate the elements. */
|
2009-10-30 17:58:15 +00:00
|
|
|
Mself.m_Width = GetBoard()->GetCurrentTrackWidth();
|
2009-02-26 00:37:04 +00:00
|
|
|
Mself.m_Size.x = Mself.m_Size.y / 2;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
// Choose a reasonable starting value for the radius of the arcs.
|
2009-02-26 00:37:04 +00:00
|
|
|
Mself.rayon = MIN( Mself.m_Width * 5, Mself.m_Size.x / 4 );
|
|
|
|
|
|
|
|
for( Mself.nbrin = 2; ; Mself.nbrin++ )
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
Mself.delta =
|
|
|
|
( Mself.m_Size.y - ( Mself.rayon * 2 * Mself.nbrin ) ) / 2;
|
|
|
|
if( Mself.delta < Mself.m_Size.y / 10 ) // Reduce radius.
|
|
|
|
{
|
2009-02-26 00:37:04 +00:00
|
|
|
Mself.delta = Mself.m_Size.y / 10;
|
2009-11-18 12:52:19 +00:00
|
|
|
Mself.rayon =
|
|
|
|
( Mself.m_Size.y - 2 * Mself.delta ) / ( 2 * Mself.nbrin );
|
|
|
|
if( Mself.rayon < Mself.m_Width ) // Radius too small.
|
|
|
|
{
|
2009-02-26 00:37:04 +00:00
|
|
|
Affiche_Message( _( "Unable to create line: Requested length is too big" ) );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2009-11-18 12:52:19 +00:00
|
|
|
Mself.lbrin = Mself.m_Size.x - ( Mself.rayon * 2 );
|
|
|
|
lextbrin = ( Mself.lbrin / 2 ) - Mself.rayon;
|
|
|
|
ll = 2 * lextbrin; // Length of first and last
|
|
|
|
// segment.
|
|
|
|
ll += 2 * Mself.delta; // Length of coil connections.
|
|
|
|
ll += Mself.nbrin * ( Mself.lbrin - 2 ); // Length of other segments.
|
|
|
|
ll += ( ( Mself.nbrin + 1 ) * 314 * Mself.rayon ) / 100;
|
|
|
|
|
|
|
|
msg.Printf( _( "Segment count = %d, length = " ), Mself.nbrin );
|
2009-02-26 00:37:04 +00:00
|
|
|
wxString stlen;
|
|
|
|
valeur_param( ll, stlen );
|
|
|
|
msg += stlen;
|
|
|
|
Affiche_Message( msg );
|
|
|
|
if( ll >= Mself.lng )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Generate module. */
|
2009-02-26 00:37:04 +00:00
|
|
|
Module = Create_1_Module( DC, wxEmptyString );
|
|
|
|
if( Module == NULL )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
// here the Module is already in the BOARD, Create_1_Module() does that.
|
|
|
|
Module->m_LibRef = wxT( "MuSelf" );
|
|
|
|
Module->m_Attributs = MOD_VIRTUAL | MOD_CMS;
|
2009-11-18 12:52:19 +00:00
|
|
|
Module->m_Flags = 0;
|
2009-02-26 00:37:04 +00:00
|
|
|
|
|
|
|
Module->Draw( DrawPanel, DC, GR_XOR );
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Generate special features. */
|
2009-02-26 00:37:04 +00:00
|
|
|
FirstSegm = PtSegm = new EDGE_MODULE( Module );
|
|
|
|
Module->m_Drawings.PushBack( PtSegm );
|
|
|
|
|
|
|
|
PtSegm->m_Start = Mself.m_Start;
|
|
|
|
PtSegm->m_End.x = Mself.m_Start.x;
|
|
|
|
PtSegm->m_End.y = PtSegm->m_Start.y + Mself.delta;
|
|
|
|
PtSegm->m_Width = Mself.m_Width;
|
|
|
|
PtSegm->SetLayer( Module->GetLayer() );
|
|
|
|
PtSegm->m_Shape = S_SEGMENT;
|
|
|
|
|
|
|
|
newedge = new EDGE_MODULE( Module );
|
|
|
|
newedge->Copy( PtSegm );
|
|
|
|
|
|
|
|
Module->m_Drawings.PushBack( newedge );
|
|
|
|
|
|
|
|
PtSegm = newedge;
|
|
|
|
PtSegm->m_Start = PtSegm->m_End;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
PtSegm = gen_arc( Module,
|
|
|
|
PtSegm,
|
|
|
|
PtSegm->m_End.x - Mself.rayon,
|
|
|
|
PtSegm->m_End.y,
|
|
|
|
-900 );
|
2009-02-26 00:37:04 +00:00
|
|
|
|
|
|
|
if( lextbrin )
|
|
|
|
{
|
|
|
|
newedge = new EDGE_MODULE( Module );
|
|
|
|
newedge->Copy( PtSegm );
|
|
|
|
|
|
|
|
Module->m_Drawings.PushBack( newedge );
|
|
|
|
|
|
|
|
PtSegm = newedge;
|
|
|
|
PtSegm->m_Start = PtSegm->m_End;
|
|
|
|
PtSegm->m_End.x -= lextbrin;
|
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Create coil. */
|
2009-02-26 00:37:04 +00:00
|
|
|
for( ii = 1; ii < Mself.nbrin; ii++ )
|
|
|
|
{
|
|
|
|
int arc_angle;
|
|
|
|
newedge = new EDGE_MODULE( Module );
|
|
|
|
newedge->Copy( PtSegm );
|
|
|
|
|
|
|
|
Module->m_Drawings.PushBack( newedge );
|
|
|
|
|
|
|
|
PtSegm = newedge;
|
|
|
|
PtSegm->m_Start = PtSegm->m_End;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
if( ii & 1 ) /* odd order arcs are greater than 0 */
|
2009-02-26 00:37:04 +00:00
|
|
|
arc_angle = 1800;
|
|
|
|
else
|
|
|
|
arc_angle = -1800;
|
|
|
|
|
|
|
|
PtSegm = gen_arc( Module, PtSegm, PtSegm->m_End.x,
|
|
|
|
PtSegm->m_End.y + Mself.rayon, arc_angle );
|
|
|
|
|
|
|
|
if( ii < Mself.nbrin - 1 )
|
|
|
|
{
|
|
|
|
newedge = new EDGE_MODULE( Module );
|
|
|
|
newedge->Copy( PtSegm );
|
|
|
|
|
|
|
|
Module->m_Drawings.Insert( newedge, PtSegm->Next() );
|
|
|
|
|
|
|
|
PtSegm = newedge;
|
|
|
|
PtSegm->m_Start = PtSegm->m_End;
|
|
|
|
if( ii & 1 )
|
|
|
|
PtSegm->m_End.x += Mself.lbrin;
|
|
|
|
else
|
|
|
|
PtSegm->m_End.x -= Mself.lbrin;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Create last segment. */
|
|
|
|
if( ii & 1 )
|
2009-02-26 00:37:04 +00:00
|
|
|
{
|
|
|
|
if( lextbrin )
|
|
|
|
{
|
|
|
|
newedge = new EDGE_MODULE( Module );
|
|
|
|
newedge->Copy( PtSegm );
|
|
|
|
|
|
|
|
Module->m_Drawings.Insert( newedge, PtSegm->Next() );
|
|
|
|
|
|
|
|
PtSegm = newedge;
|
|
|
|
PtSegm->m_Start = PtSegm->m_End;
|
|
|
|
PtSegm->m_End.x -= lextbrin;
|
|
|
|
}
|
|
|
|
|
|
|
|
newedge = new EDGE_MODULE( Module );
|
|
|
|
newedge->Copy( PtSegm );
|
|
|
|
Module->m_Drawings.PushBack( newedge );
|
|
|
|
|
|
|
|
PtSegm = newedge;
|
2009-11-18 12:52:19 +00:00
|
|
|
PtSegm->m_Start.x = PtSegm->m_End.x; PtSegm->m_Start.y =
|
|
|
|
PtSegm->m_End.y;
|
|
|
|
PtSegm = gen_arc( Module,
|
|
|
|
PtSegm,
|
|
|
|
PtSegm->m_End.x,
|
|
|
|
PtSegm->m_End.y + Mself.rayon,
|
|
|
|
900 );
|
2009-02-26 00:37:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( lextbrin )
|
|
|
|
{
|
|
|
|
newedge = new EDGE_MODULE( Module );
|
|
|
|
newedge->Copy( PtSegm );
|
|
|
|
|
|
|
|
Module->m_Drawings.Insert( newedge, PtSegm->Next() );
|
|
|
|
|
|
|
|
PtSegm = newedge;
|
|
|
|
PtSegm->m_Start = PtSegm->m_End;
|
|
|
|
PtSegm->m_End.x += lextbrin;
|
|
|
|
}
|
|
|
|
newedge = new EDGE_MODULE( Module );
|
|
|
|
newedge->Copy( PtSegm );
|
|
|
|
|
|
|
|
Module->m_Drawings.PushBack( newedge );
|
|
|
|
PtSegm = newedge;
|
|
|
|
PtSegm->m_Start = PtSegm->m_End;
|
2009-11-18 12:52:19 +00:00
|
|
|
PtSegm = gen_arc( Module,
|
|
|
|
PtSegm,
|
|
|
|
PtSegm->m_End.x,
|
|
|
|
PtSegm->m_End.y + Mself.rayon,
|
|
|
|
-900 );
|
2009-02-26 00:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
newedge = new EDGE_MODULE( Module );
|
|
|
|
newedge->Copy( PtSegm );
|
|
|
|
Module->m_Drawings.Insert( newedge, PtSegm->Next() );
|
|
|
|
PtSegm = newedge;
|
|
|
|
|
|
|
|
PtSegm->m_Start = PtSegm->m_End;
|
|
|
|
PtSegm->m_End = Mself.m_End;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Rotate the coil if it has a horizontal orientation. */
|
2009-02-26 00:37:04 +00:00
|
|
|
LastSegm = PtSegm;
|
|
|
|
if( Mself.orient == 0 )
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
for( PtSegm = FirstSegm;
|
|
|
|
PtSegm != NULL;
|
|
|
|
PtSegm = (EDGE_MODULE*) PtSegm->Next() )
|
2009-02-26 00:37:04 +00:00
|
|
|
{
|
|
|
|
RotatePoint( &PtSegm->m_Start.x, &PtSegm->m_Start.y,
|
|
|
|
FirstSegm->m_Start.x, FirstSegm->m_Start.y, 900 );
|
|
|
|
if( PtSegm != LastSegm )
|
|
|
|
RotatePoint( &PtSegm->m_End.x, &PtSegm->m_End.y,
|
|
|
|
FirstSegm->m_Start.x, FirstSegm->m_Start.y, 900 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Module->m_Pos = LastSegm->m_End;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Place pad on each end of coil. */
|
2009-02-26 00:37:04 +00:00
|
|
|
PtPad = new D_PAD( Module );
|
|
|
|
|
|
|
|
Module->m_Pads.PushFront( PtPad );
|
|
|
|
|
|
|
|
PtPad->SetPadName( wxT( "1" ) );
|
2009-11-18 12:52:19 +00:00
|
|
|
PtPad->m_Pos = LastSegm->m_End;
|
2009-02-26 00:37:04 +00:00
|
|
|
PtPad->m_Pos0 = PtPad->m_Pos - Module->m_Pos;
|
|
|
|
PtPad->m_Size.x = PtPad->m_Size.y = LastSegm->m_Width;
|
|
|
|
PtPad->m_Masque_Layer = g_TabOneLayerMask[LastSegm->GetLayer()];
|
2009-11-18 12:52:19 +00:00
|
|
|
PtPad->m_Attribut = PAD_SMD;
|
|
|
|
PtPad->m_PadShape = PAD_CIRCLE;
|
|
|
|
PtPad->m_Rayon = PtPad->m_Size.x / 2;
|
2009-02-26 00:37:04 +00:00
|
|
|
|
|
|
|
D_PAD* newpad = new D_PAD( Module );
|
|
|
|
newpad->Copy( PtPad );
|
|
|
|
|
|
|
|
Module->m_Pads.Insert( newpad, PtPad->Next() );
|
|
|
|
|
|
|
|
PtPad = newpad;
|
|
|
|
PtPad->SetPadName( wxT( "2" ) );
|
|
|
|
PtPad->m_Pos = FirstSegm->m_Start;
|
|
|
|
PtPad->m_Pos0 = PtPad->m_Pos - Module->m_Pos;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Modify text positions. */
|
2009-04-17 08:51:02 +00:00
|
|
|
Module->DisplayInfo( this );
|
2009-11-18 12:52:19 +00:00
|
|
|
Module->m_Value->m_Pos.x = Module->m_Reference->m_Pos.x =
|
|
|
|
( FirstSegm->m_Start.x + LastSegm->m_End.x ) / 2;
|
|
|
|
Module->m_Value->m_Pos.y = Module->m_Reference->m_Pos.y =
|
|
|
|
( FirstSegm->m_Start.y + LastSegm->m_End.y ) / 2;
|
2009-02-26 00:37:04 +00:00
|
|
|
|
|
|
|
Module->m_Reference->m_Pos.y -= Module->m_Reference->m_Size.y;
|
|
|
|
Module->m_Value->m_Pos.y += Module->m_Value->m_Size.y;
|
|
|
|
Module->m_Reference->m_Pos0 = Module->m_Reference->m_Pos - Module->m_Pos;
|
|
|
|
Module->m_Value->m_Pos0 = Module->m_Value->m_Pos - Module->m_Pos;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Initial segment coordinates. */
|
|
|
|
for( PtSegm = FirstSegm; PtSegm; PtSegm = PtSegm->Next() )
|
2009-02-26 00:37:04 +00:00
|
|
|
{
|
|
|
|
PtSegm->m_Start0 = PtSegm->m_Start - Module->m_Pos;
|
|
|
|
PtSegm->m_End0 = PtSegm->m_End - Module->m_Pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
Module->Set_Rectangle_Encadrement();
|
|
|
|
Module->Draw( DrawPanel, DC, GR_OR );
|
|
|
|
|
|
|
|
return Module;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Generate an arc EDGE_MODULE:
|
|
|
|
* Center cX, cY
|
|
|
|
* Angle "angle"
|
|
|
|
* Starting point gives the structure pointed to by PtSegm, which must
|
|
|
|
* Returns a pointer to the structure EDGE_MODULE generated.
|
2009-02-26 00:37:04 +00:00
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
static EDGE_MODULE* gen_arc( MODULE* aModule,
|
|
|
|
EDGE_MODULE* PtSegm,
|
|
|
|
int cX,
|
|
|
|
int cY,
|
|
|
|
int angle )
|
2009-02-26 00:37:04 +00:00
|
|
|
{
|
|
|
|
int ii, nb_seg;
|
|
|
|
double alpha, beta, fsin, fcos;
|
|
|
|
int x0, xr0, y0, yr0;
|
|
|
|
EDGE_MODULE* newedge;
|
|
|
|
|
|
|
|
angle = -angle;
|
2009-11-18 12:52:19 +00:00
|
|
|
y0 = PtSegm->m_Start.x - cX;
|
|
|
|
x0 = PtSegm->m_Start.y - cY;
|
2009-02-26 00:37:04 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
nb_seg = ( abs( angle ) ) / 225;
|
|
|
|
|
|
|
|
if( nb_seg == 0 )
|
2009-02-26 00:37:04 +00:00
|
|
|
nb_seg = 1;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
alpha = ( (double) angle * 3.14159 / 1800 ) / nb_seg;
|
2009-02-26 00:37:04 +00:00
|
|
|
|
|
|
|
for( ii = 1; ii <= nb_seg; ii++ )
|
|
|
|
{
|
|
|
|
if( ii > 1 )
|
|
|
|
{
|
|
|
|
newedge = new EDGE_MODULE( aModule );
|
|
|
|
|
|
|
|
newedge->Copy( PtSegm );
|
|
|
|
|
|
|
|
aModule->m_Drawings.PushBack( newedge );
|
|
|
|
|
|
|
|
PtSegm = newedge;
|
|
|
|
|
|
|
|
PtSegm->m_Start = PtSegm->m_End;
|
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
beta = ( alpha * ii );
|
2009-02-26 00:37:04 +00:00
|
|
|
fcos = cos( beta ); fsin = sin( beta );
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
xr0 = (int) ( x0 * fcos + y0 * fsin );
|
|
|
|
yr0 = (int) ( y0 * fcos - x0 * fsin );
|
2009-02-26 00:37:04 +00:00
|
|
|
|
|
|
|
PtSegm->m_End.x = cX + yr0;
|
|
|
|
PtSegm->m_End.y = cY + xr0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return PtSegm;
|
|
|
|
}
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
/* Create a footprint with pad_count pads for micro wave applications
|
2007-08-08 03:50:44 +00:00
|
|
|
* This footprint has pad_count pads:
|
2008-01-05 17:30:56 +00:00
|
|
|
* PAD_SMD, rectangular, H size = V size = current track width.
|
2007-08-08 03:50:44 +00:00
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
MODULE* WinEDA_PcbFrame::Create_MuWaveBasicShape( const wxString& name,
|
|
|
|
int pad_count )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-08 03:50:44 +00:00
|
|
|
MODULE* Module;
|
|
|
|
int pad_num = 1;
|
|
|
|
wxString Line;
|
|
|
|
|
2008-12-06 12:49:33 +00:00
|
|
|
Module = Create_1_Module( NULL, name );
|
2007-08-08 03:50:44 +00:00
|
|
|
if( Module == NULL )
|
|
|
|
return NULL;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
Module->m_TimeStamp = GetTimeStamp();
|
|
|
|
Module->m_Value->m_Size = wxSize( 30, 30 );
|
2007-08-08 03:50:44 +00:00
|
|
|
Module->m_Value->m_Pos0.y = -30;
|
|
|
|
Module->m_Value->m_Pos.y += Module->m_Value->m_Pos0.y;
|
|
|
|
Module->m_Reference->m_Size = wxSize( 30, 30 );
|
|
|
|
Module->m_Reference->m_Pos0.y = 30;
|
|
|
|
Module->m_Reference->m_Pos.y += Module->m_Reference->m_Pos0.y;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Create dots forming the gap. */
|
2007-08-08 03:50:44 +00:00
|
|
|
while( pad_count-- )
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
D_PAD* pad = new D_PAD( Module );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
|
|
|
Module->m_Pads.PushFront( pad );
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
pad->m_Size.x = pad->m_Size.y = GetBoard()->GetCurrentTrackWidth();
|
|
|
|
pad->m_Pos = Module->m_Pos;
|
2008-01-05 17:30:56 +00:00
|
|
|
pad->m_PadShape = PAD_RECT;
|
|
|
|
pad->m_Attribut = PAD_SMD;
|
2009-12-21 13:05:11 +00:00
|
|
|
pad->m_Masque_Layer = LAYER_FRONT;
|
2007-08-08 03:50:44 +00:00
|
|
|
Line.Printf( wxT( "%d" ), pad_num );
|
|
|
|
pad->SetPadName( Line );
|
|
|
|
pad_num++;
|
|
|
|
}
|
2009-11-18 12:52:19 +00:00
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
return Module;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-02 02:04:45 +00:00
|
|
|
#if 0
|
2007-08-08 03:50:44 +00:00
|
|
|
static void Exit_Muonde( WinEDA_DrawFrame* frame, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
MODULE* Module = (MODULE*) frame->GetScreen()->GetCurItem();
|
2007-08-08 03:50:44 +00:00
|
|
|
|
|
|
|
if( Module )
|
|
|
|
{
|
|
|
|
if( Module->m_Flags & IS_NEW )
|
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
Module->Draw( frame->DrawPanel, DC, GR_XOR );
|
2009-11-18 12:52:19 +00:00
|
|
|
Module->DeleteStructure();
|
2007-08-08 03:50:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
Module->Draw( frame->DrawPanel, DC, GR_XOR );
|
2007-08-08 03:50:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
frame->DrawPanel->ManageCurseur = NULL;
|
|
|
|
frame->DrawPanel->ForceCloseManageCurseur = NULL;
|
2007-09-12 02:14:07 +00:00
|
|
|
frame->SetCurItem( NULL );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2007-08-08 03:50:44 +00:00
|
|
|
|
|
|
|
|
2007-08-02 02:04:45 +00:00
|
|
|
#endif
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Create a module "GAP" or "STUB"
|
2007-08-08 03:50:44 +00:00
|
|
|
* This a "gap" or "stub" used in micro wave designs
|
2009-11-18 12:52:19 +00:00
|
|
|
* This module has 2 pads:
|
2008-01-05 17:30:56 +00:00
|
|
|
* PAD_SMD, rectangular, H size = V size = current track width.
|
2007-08-08 03:50:44 +00:00
|
|
|
* the "gap" is isolation created between this 2 pads
|
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( int shape_type )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-12-29 18:02:54 +00:00
|
|
|
int oX;
|
2007-08-08 03:50:44 +00:00
|
|
|
float fcoeff;
|
2008-12-06 12:49:33 +00:00
|
|
|
D_PAD* pad;
|
2007-08-08 03:50:44 +00:00
|
|
|
MODULE* Module;
|
|
|
|
wxString msg, cmp_name;
|
|
|
|
int pad_count = 2;
|
2009-11-18 12:52:19 +00:00
|
|
|
int angle = 0;
|
2007-08-08 03:50:44 +00:00
|
|
|
bool abort;
|
|
|
|
|
2008-12-06 12:49:33 +00:00
|
|
|
/* Enter the size of the gap or stub*/
|
2009-11-18 12:52:19 +00:00
|
|
|
int gap_size = GetBoard()->GetCurrentTrackWidth();
|
2007-08-08 03:50:44 +00:00
|
|
|
|
|
|
|
switch( shape_type )
|
|
|
|
{
|
|
|
|
case 0:
|
2009-11-18 12:52:19 +00:00
|
|
|
msg = _( "Gap" );
|
2007-08-08 03:50:44 +00:00
|
|
|
cmp_name = wxT( "GAP" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2009-11-18 12:52:19 +00:00
|
|
|
msg = _( "Stub" );
|
2007-08-08 03:50:44 +00:00
|
|
|
cmp_name = wxT( "STUB" );
|
|
|
|
pad_count = 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2009-11-18 12:52:19 +00:00
|
|
|
msg = _( "Arc Stub" );
|
2007-08-08 03:50:44 +00:00
|
|
|
cmp_name = wxT( "ASTUB" );
|
|
|
|
pad_count = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
msg = wxT( "???" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString value;
|
|
|
|
if( g_UnitMetric )
|
|
|
|
{
|
2009-05-21 17:42:42 +00:00
|
|
|
fcoeff = 10000.0f / 25.4f;
|
2007-08-08 03:50:44 +00:00
|
|
|
value.Printf( wxT( "%2.4f" ), gap_size / fcoeff );
|
2009-11-18 12:52:19 +00:00
|
|
|
msg += _( " (mm):" );
|
2007-08-08 03:50:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fcoeff = 10000.0;
|
|
|
|
value.Printf( wxT( "%2.3f" ), gap_size / fcoeff );
|
2009-11-18 12:52:19 +00:00
|
|
|
msg += _( " (inch):" );
|
2007-08-08 03:50:44 +00:00
|
|
|
}
|
2009-11-18 12:52:19 +00:00
|
|
|
abort = Get_Message( msg, _( "Create microwave module" ), value, this );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
double fval;
|
2007-08-08 03:50:44 +00:00
|
|
|
if( !value.ToDouble( &fval ) )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "Incorrect number, abort" ) );
|
|
|
|
abort = TRUE;
|
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
gap_size = ABS( wxRound( fval * fcoeff ) );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
if( !abort && ( shape_type == 2 ) )
|
2007-08-08 03:50:44 +00:00
|
|
|
{
|
|
|
|
fcoeff = 10.0;
|
|
|
|
value.Printf( wxT( "%3.1f" ), angle / fcoeff );
|
|
|
|
msg = _( "Angle (0.1deg):" );
|
2009-11-18 12:52:19 +00:00
|
|
|
abort = Get_Message( msg, _( "Create microwave module" ), value, this );
|
2007-08-08 03:50:44 +00:00
|
|
|
if( !value.ToDouble( &fval ) )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "Incorrect number, abort" ) );
|
|
|
|
abort = TRUE;
|
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
angle = ABS( wxRound( fval * fcoeff ) );
|
2007-08-08 03:50:44 +00:00
|
|
|
if( angle > 1800 )
|
|
|
|
angle = 1800;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( abort )
|
|
|
|
{
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-12-06 12:49:33 +00:00
|
|
|
Module = Create_MuWaveBasicShape( cmp_name, pad_count );
|
2009-11-18 12:52:19 +00:00
|
|
|
pad = Module->m_Pads;
|
2007-08-08 03:50:44 +00:00
|
|
|
|
|
|
|
switch( shape_type )
|
|
|
|
{
|
|
|
|
case 0: //Gap :
|
2009-11-18 12:52:19 +00:00
|
|
|
oX = pad->m_Pos0.x = -( gap_size + pad->m_Size.x ) / 2;
|
2008-12-06 12:49:33 +00:00
|
|
|
pad->m_Pos.x += pad->m_Pos0.x;
|
|
|
|
pad = pad->Next();
|
|
|
|
pad->m_Pos0.x = oX + gap_size + pad->m_Size.x;
|
|
|
|
pad->m_Pos.x += pad->m_Pos0.x;
|
2007-08-08 03:50:44 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: //Stub :
|
2008-12-06 12:49:33 +00:00
|
|
|
pad->SetPadName( wxT( "1" ) );
|
|
|
|
pad = pad->Next();
|
2009-11-18 12:52:19 +00:00
|
|
|
pad->m_Pos0.y = -( gap_size + pad->m_Size.y ) / 2;
|
2008-12-06 12:49:33 +00:00
|
|
|
pad->m_Size.y = gap_size;
|
|
|
|
pad->m_Pos.y += pad->m_Pos0.y;
|
2007-08-08 03:50:44 +00:00
|
|
|
break;
|
|
|
|
|
2008-12-29 18:02:54 +00:00
|
|
|
case 2: // Arc Stub created by a polygonal approach:
|
2009-11-18 12:52:19 +00:00
|
|
|
{
|
|
|
|
EDGE_MODULE* edge = new EDGE_MODULE( Module );
|
|
|
|
Module->m_Drawings.PushFront( edge );
|
2008-12-29 18:02:54 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
edge->m_Shape = S_POLYGON;
|
2009-12-07 03:46:13 +00:00
|
|
|
edge->SetLayer( LAYER_N_FRONT );
|
2008-12-29 18:02:54 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
int numPoints = angle / 50 + 3; // Note: angles are in 0.1 degrees
|
|
|
|
edge->m_PolyPoints.reserve( numPoints );
|
2008-12-29 18:02:54 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
edge->m_Start0.y = -pad->m_Size.y / 2;
|
2008-12-29 18:02:54 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
edge->m_PolyPoints.push_back( wxPoint( 0, 0 ) );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
int theta = -angle / 2;
|
|
|
|
for( int ii = 1; ii<numPoints - 1; ii++ )
|
|
|
|
{
|
|
|
|
wxPoint pt( 0, -gap_size );
|
2008-12-29 18:02:54 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
RotatePoint( &pt.x, &pt.y, theta );
|
2008-12-29 18:02:54 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
edge->m_PolyPoints.push_back( pt );
|
2008-12-29 18:02:54 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
theta += 50;
|
|
|
|
if( theta > angle / 2 )
|
|
|
|
theta = angle / 2;
|
2008-12-29 18:02:54 +00:00
|
|
|
}
|
2009-11-18 12:52:19 +00:00
|
|
|
|
|
|
|
// Close the polygon:
|
|
|
|
edge->m_PolyPoints.push_back( edge->m_PolyPoints[0] );
|
|
|
|
}
|
|
|
|
break;
|
2007-08-08 03:50:44 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Module->Set_Rectangle_Encadrement();
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_Status_Pcb = 0;
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetModify();
|
2007-08-08 03:50:44 +00:00
|
|
|
return Module;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************** Polygon Shapes ***********************/
|
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
enum id_mw_cmd {
|
2007-10-07 03:08:24 +00:00
|
|
|
ID_READ_SHAPE_FILE = 1000
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Setting polynomial form parameters
|
2007-08-08 03:50:44 +00:00
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
class WinEDA_SetParamShapeFrame : public wxDialog
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
private:
|
2007-08-08 03:50:44 +00:00
|
|
|
WinEDA_PcbFrame* m_Parent;
|
|
|
|
wxRadioBox* m_ShapeOptionCtrl;
|
|
|
|
WinEDA_SizeCtrl* m_SizeCtrl;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
public: WinEDA_SetParamShapeFrame( WinEDA_PcbFrame* parent, const wxPoint& pos );
|
2007-09-01 12:00:30 +00:00
|
|
|
~WinEDA_SetParamShapeFrame() { };
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
private:
|
2009-11-18 12:52:19 +00:00
|
|
|
void OnOkClick( wxCommandEvent& event );
|
|
|
|
void OnCancelClick( wxCommandEvent& event );
|
|
|
|
void ReadDataShapeDescr( wxCommandEvent& event );
|
|
|
|
void AcceptOptions( wxCommandEvent& event );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
BEGIN_EVENT_TABLE( WinEDA_SetParamShapeFrame, wxDialog )
|
|
|
|
EVT_BUTTON( wxID_OK, WinEDA_SetParamShapeFrame::OnOkClick )
|
|
|
|
EVT_BUTTON( wxID_CANCEL, WinEDA_SetParamShapeFrame::OnCancelClick )
|
|
|
|
EVT_BUTTON( ID_READ_SHAPE_FILE,
|
|
|
|
WinEDA_SetParamShapeFrame::ReadDataShapeDescr )
|
|
|
|
END_EVENT_TABLE()
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
WinEDA_SetParamShapeFrame::WinEDA_SetParamShapeFrame( WinEDA_PcbFrame* parent,
|
|
|
|
const wxPoint& framepos ) :
|
|
|
|
wxDialog( parent, -1, _( "Complex shape" ), framepos, wxSize( 350, 280 ),
|
|
|
|
DIALOG_STYLE )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-08 03:50:44 +00:00
|
|
|
m_Parent = parent;
|
|
|
|
|
|
|
|
if( PolyEdges )
|
|
|
|
free( PolyEdges );
|
2009-11-18 12:52:19 +00:00
|
|
|
PolyEdges = NULL;
|
2007-08-08 03:50:44 +00:00
|
|
|
PolyEdgesCount = 0;
|
|
|
|
|
|
|
|
wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
SetSizer( MainBoxSizer );
|
|
|
|
wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 );
|
|
|
|
MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
|
|
|
|
2007-10-07 03:08:24 +00:00
|
|
|
wxButton* Button = new wxButton( this, wxID_OK, _( "OK" ) );
|
2007-08-08 03:50:44 +00:00
|
|
|
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
2007-10-07 03:08:24 +00:00
|
|
|
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
|
2007-08-08 03:50:44 +00:00
|
|
|
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
Button =
|
|
|
|
new wxButton( this, ID_READ_SHAPE_FILE,
|
|
|
|
_( "Read Shape Description File..." ) );
|
2007-08-08 03:50:44 +00:00
|
|
|
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
wxString shapelist[3] = { _( "Normal" ), _( "Symmetrical" ),
|
|
|
|
_( "Mirrored" ) };
|
|
|
|
m_ShapeOptionCtrl = new wxRadioBox( this, -1, _( "Shape Option" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, 3,
|
|
|
|
shapelist, 1,
|
2007-08-08 03:50:44 +00:00
|
|
|
wxRA_SPECIFY_COLS );
|
|
|
|
LeftBoxSizer->Add( m_ShapeOptionCtrl, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
m_SizeCtrl = new WinEDA_SizeCtrl( this, _( "Size" ), ShapeSize,
|
|
|
|
g_UnitMetric, LeftBoxSizer,
|
|
|
|
PCB_INTERNAL_UNIT );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
|
|
|
GetSizer()->Fit( this );
|
|
|
|
GetSizer()->SetSizeHints( this );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
void WinEDA_SetParamShapeFrame::OnCancelClick( wxCommandEvent& WXUNUSED( event ) )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-08 03:50:44 +00:00
|
|
|
if( PolyEdges )
|
|
|
|
free( PolyEdges );
|
2009-11-18 12:52:19 +00:00
|
|
|
PolyEdges = NULL;
|
2007-08-08 03:50:44 +00:00
|
|
|
PolyEdgesCount = 0;
|
2007-10-07 03:08:24 +00:00
|
|
|
EndModal( -1 );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 03:08:24 +00:00
|
|
|
void WinEDA_SetParamShapeFrame::OnOkClick( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-08 03:50:44 +00:00
|
|
|
ShapeSize = m_SizeCtrl->GetValue();
|
|
|
|
PolyShapeType = m_ShapeOptionCtrl->GetSelection();
|
|
|
|
EndModal( 1 );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Read a description shape file
|
2007-08-08 03:50:44 +00:00
|
|
|
* File format is
|
|
|
|
* Unit=MM
|
|
|
|
* XScale=271.501
|
|
|
|
* YScale=1.00133
|
2008-04-01 05:21:50 +00:00
|
|
|
*
|
2007-08-08 03:50:44 +00:00
|
|
|
* $COORD
|
|
|
|
* 0 0.6112600148417837
|
|
|
|
* 0.001851851851851852 0.6104800531118608
|
|
|
|
* ....
|
|
|
|
* $ENDCOORD
|
2008-04-01 05:21:50 +00:00
|
|
|
*
|
2009-11-18 12:52:19 +00:00
|
|
|
* Each line is the X Y coord (normalized units from 0 to 1)
|
2007-08-08 03:50:44 +00:00
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
void WinEDA_SetParamShapeFrame::ReadDataShapeDescr( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-08 03:50:44 +00:00
|
|
|
wxString FullFileName;
|
|
|
|
wxString ext, mask;
|
|
|
|
FILE* File;
|
|
|
|
char Line[1024];
|
|
|
|
double unitconv = 10000;
|
|
|
|
char* param1, * param2;
|
|
|
|
int bufsize;
|
|
|
|
double* ptbuf;
|
|
|
|
|
|
|
|
ext = wxT( ".txt" );
|
|
|
|
mask = wxT( "*" ) + ext;
|
|
|
|
FullFileName = EDA_FileSelector( _( "Read descr shape file" ),
|
2009-11-18 12:52:19 +00:00
|
|
|
wxEmptyString,
|
|
|
|
FullFileName,
|
|
|
|
ext,
|
|
|
|
mask,
|
2007-08-08 03:50:44 +00:00
|
|
|
this,
|
|
|
|
wxFD_OPEN,
|
2009-11-18 12:52:19 +00:00
|
|
|
TRUE );
|
2007-08-08 03:50:44 +00:00
|
|
|
if( FullFileName.IsEmpty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
File = wxFopen( FullFileName, wxT( "rt" ) );
|
|
|
|
|
|
|
|
if( File == NULL )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "File not found" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bufsize = 100;
|
|
|
|
ptbuf = PolyEdges = (double*) MyZMalloc( bufsize * 2 * sizeof(double) );
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
SetLocaleTo_C_standard();
|
2007-08-08 03:50:44 +00:00
|
|
|
int LineNum = 0;
|
|
|
|
while( GetLine( File, Line, &LineNum, sizeof(Line) - 1 ) != NULL )
|
|
|
|
{
|
|
|
|
param1 = strtok( Line, " =\n\r" );
|
|
|
|
param2 = strtok( NULL, " \t\n\r" );
|
|
|
|
|
|
|
|
if( strnicmp( param1, "Unit", 4 ) == 0 )
|
|
|
|
{
|
|
|
|
if( strnicmp( param2, "inch", 4 ) == 0 )
|
|
|
|
unitconv = 10000;
|
|
|
|
if( strnicmp( param2, "mm", 2 ) == 0 )
|
|
|
|
unitconv = 10000 / 25.4;
|
|
|
|
}
|
|
|
|
if( strnicmp( param1, "$ENDCOORD", 8 ) == 0 )
|
|
|
|
break;
|
|
|
|
if( strnicmp( param1, "$COORD", 6 ) == 0 )
|
|
|
|
{
|
|
|
|
while( GetLine( File, Line, &LineNum, sizeof(Line) - 1 ) != NULL )
|
|
|
|
{
|
|
|
|
param1 = strtok( Line, " \t\n\r" );
|
|
|
|
param2 = strtok( NULL, " \t\n\r" );
|
|
|
|
if( strnicmp( param1, "$ENDCOORD", 8 ) == 0 )
|
|
|
|
break;
|
|
|
|
if( bufsize <= PolyEdgesCount )
|
|
|
|
{
|
|
|
|
int index = ptbuf - PolyEdges;
|
|
|
|
bufsize *= 2;
|
2009-11-18 12:52:19 +00:00
|
|
|
ptbuf = PolyEdges = (double*) realloc(
|
|
|
|
PolyEdges, bufsize * 2 *
|
|
|
|
sizeof(double) );
|
|
|
|
ptbuf += index;
|
2007-08-08 03:50:44 +00:00
|
|
|
}
|
|
|
|
*ptbuf = atof( param1 );
|
|
|
|
ptbuf++;
|
|
|
|
*ptbuf = atof( param2 );
|
|
|
|
ptbuf++;
|
|
|
|
PolyEdgesCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( strnicmp( Line, "XScale", 6 ) == 0 )
|
|
|
|
{
|
|
|
|
ShapeScaleX = atof( param2 );
|
|
|
|
}
|
|
|
|
if( strnicmp( Line, "YScale", 6 ) == 0 )
|
|
|
|
{
|
|
|
|
ShapeScaleY = atof( param2 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( PolyEdgesCount == 0 )
|
|
|
|
{
|
|
|
|
free( PolyEdges );
|
|
|
|
PolyEdges = NULL;
|
|
|
|
}
|
|
|
|
fclose( File );
|
2009-11-18 12:52:19 +00:00
|
|
|
SetLocaleTo_Default(); // revert to the current locale
|
2007-08-08 03:50:44 +00:00
|
|
|
|
|
|
|
ShapeScaleX *= unitconv;
|
|
|
|
ShapeScaleY *= unitconv;
|
|
|
|
|
|
|
|
m_SizeCtrl->SetValue( (int) ShapeScaleX, (int) ShapeScaleY );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
MODULE* WinEDA_PcbFrame::Create_MuWavePolygonShape()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-08 03:50:44 +00:00
|
|
|
D_PAD* pad1, * pad2;
|
|
|
|
MODULE* Module;
|
|
|
|
wxString cmp_name;
|
|
|
|
int pad_count = 2;
|
2008-12-29 18:02:54 +00:00
|
|
|
EDGE_MODULE* edge;
|
2007-08-08 03:50:44 +00:00
|
|
|
int ii, npoints;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
WinEDA_SetParamShapeFrame* frame = new WinEDA_SetParamShapeFrame(
|
|
|
|
this, wxPoint( -1, -1 ) );
|
2008-12-29 18:02:54 +00:00
|
|
|
|
|
|
|
int ok = frame->ShowModal();
|
2009-11-18 12:52:19 +00:00
|
|
|
|
2008-12-29 18:02:54 +00:00
|
|
|
frame->Destroy();
|
2007-08-08 03:50:44 +00:00
|
|
|
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
|
|
|
if( ok != 1 )
|
|
|
|
{
|
|
|
|
if( PolyEdges )
|
|
|
|
free( PolyEdges );
|
2009-11-18 12:52:19 +00:00
|
|
|
PolyEdges = NULL;
|
2007-08-08 03:50:44 +00:00
|
|
|
PolyEdgesCount = 0;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( PolyShapeType == 2 ) // mirrored
|
|
|
|
ShapeScaleY = -ShapeScaleY;
|
2008-12-29 18:02:54 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
ShapeSize.x = wxRound( ShapeScaleX );
|
|
|
|
ShapeSize.y = wxRound( ShapeScaleY );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
if( ( ShapeSize.x ) == 0 || ( ShapeSize.y == 0 ) )
|
2007-08-08 03:50:44 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, _( "Shape has a null size!" ) );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if( PolyEdgesCount == 0 )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "Shape has no points!" ) );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmp_name = wxT( "POLY" );
|
|
|
|
|
2008-12-06 12:49:33 +00:00
|
|
|
Module = Create_MuWaveBasicShape( cmp_name, pad_count );
|
2007-08-08 03:50:44 +00:00
|
|
|
pad1 = Module->m_Pads;
|
|
|
|
|
|
|
|
pad1->m_Pos0.x = -ShapeSize.x / 2;
|
|
|
|
pad1->m_Pos.x += pad1->m_Pos0.x;
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
pad2 = (D_PAD*) pad1->Next();
|
2007-08-08 03:50:44 +00:00
|
|
|
pad2->m_Pos0.x = pad1->m_Pos0.x + ShapeSize.x;
|
|
|
|
pad2->m_Pos.x += pad2->m_Pos0.x;
|
|
|
|
|
|
|
|
edge = new EDGE_MODULE( Module );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
|
|
|
Module->m_Drawings.PushFront( edge );
|
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
edge->m_Shape = S_POLYGON;
|
2009-12-07 03:46:13 +00:00
|
|
|
edge->SetLayer( LAYER_N_FRONT );
|
2007-08-08 03:50:44 +00:00
|
|
|
npoints = PolyEdgesCount;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
edge->m_PolyPoints.reserve( 2 * PolyEdgesCount + 2 );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
|
|
|
// Init start point coord:
|
2009-11-18 12:52:19 +00:00
|
|
|
edge->m_PolyPoints.push_back( wxPoint( pad1->m_Pos0.x, 0 ) );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
|
|
|
double* dptr = PolyEdges;
|
2008-12-29 18:02:54 +00:00
|
|
|
wxPoint first_coordinate, last_coordinate;
|
2007-08-08 03:50:44 +00:00
|
|
|
for( ii = 0; ii < npoints; ii++ ) // Copy points
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
last_coordinate.x = wxRound( *dptr++ *ShapeScaleX ) + pad1->m_Pos0.x;
|
|
|
|
last_coordinate.y = -wxRound( *dptr++ *ShapeScaleY );
|
2008-12-29 18:02:54 +00:00
|
|
|
edge->m_PolyPoints.push_back( last_coordinate );
|
2007-08-08 03:50:44 +00:00
|
|
|
}
|
|
|
|
|
2008-12-29 18:02:54 +00:00
|
|
|
first_coordinate.y = edge->m_PolyPoints[1].y;
|
2007-08-08 03:50:44 +00:00
|
|
|
|
|
|
|
switch( PolyShapeType )
|
|
|
|
{
|
|
|
|
case 0: // Single
|
|
|
|
case 2: // Single mirrored
|
|
|
|
// Init end point coord:
|
2008-12-29 18:02:54 +00:00
|
|
|
pad2->m_Pos0.x = last_coordinate.x;
|
|
|
|
edge->m_PolyPoints.push_back( wxPoint( last_coordinate.x, 0 ) );
|
|
|
|
|
|
|
|
pad1->m_Size.x = pad1->m_Size.y = ABS( first_coordinate.y );
|
|
|
|
pad2->m_Size.x = pad2->m_Size.y = ABS( last_coordinate.y );
|
|
|
|
pad1->m_Pos0.y = first_coordinate.y / 2;
|
|
|
|
pad2->m_Pos0.y = last_coordinate.y / 2;
|
2007-08-08 03:50:44 +00:00
|
|
|
pad1->m_Pos.y = pad1->m_Pos0.y + Module->m_Pos.y;
|
|
|
|
pad2->m_Pos.y = pad2->m_Pos0.y + Module->m_Pos.y;
|
|
|
|
break;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
case 1: // Symmetric
|
|
|
|
for( int ndx = edge->m_PolyPoints.size() - 1; ndx>=0; --ndx )
|
2007-08-08 03:50:44 +00:00
|
|
|
{
|
2008-12-29 18:02:54 +00:00
|
|
|
wxPoint pt = edge->m_PolyPoints[ndx];
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2008-12-29 18:02:54 +00:00
|
|
|
pt.y = -pt.y; // mirror about X axis
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2008-12-29 18:02:54 +00:00
|
|
|
edge->m_PolyPoints.push_back( pt );
|
|
|
|
}
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2008-12-29 18:02:54 +00:00
|
|
|
pad1->m_Size.x = pad1->m_Size.y = 2 * ABS( first_coordinate.y );
|
|
|
|
pad2->m_Size.x = pad2->m_Size.y = 2 * ABS( last_coordinate.y );
|
2007-08-08 03:50:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
free( PolyEdges );
|
|
|
|
PolyEdgesCount = 0;
|
|
|
|
PolyEdges = NULL;
|
|
|
|
|
|
|
|
Module->Set_Rectangle_Encadrement();
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_Status_Pcb = 0;
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetModify();
|
2007-08-08 03:50:44 +00:00
|
|
|
return Module;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2009-11-18 12:52:19 +00:00
|
|
|
* Edit the GAP module, if it has changed the position and/or size
|
|
|
|
* Pads that form the gap to get a new value of the gap.
|
2007-05-06 16:03:28 +00:00
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
void WinEDA_PcbFrame::Edit_Gap( wxDC* DC, MODULE* Module )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-08 03:50:44 +00:00
|
|
|
int gap_size, oX;
|
|
|
|
float fcoeff;
|
|
|
|
D_PAD* pad, * next_pad;
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
if( Module == NULL )
|
2009-11-18 12:52:19 +00:00
|
|
|
return;
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Test if module is a gap type (name begins with GAP, and has 2 pads). */
|
2007-08-08 03:50:44 +00:00
|
|
|
msg = Module->m_Reference->m_Text.Left( 3 );
|
|
|
|
if( msg != wxT( "GAP" ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
pad = Module->m_Pads;
|
|
|
|
if( pad == NULL )
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
DisplayError( this, _( "No pad for this module" ) );
|
|
|
|
return;
|
2007-08-08 03:50:44 +00:00
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
next_pad = (D_PAD*) pad->Next();
|
2007-08-08 03:50:44 +00:00
|
|
|
if( next_pad == NULL )
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
DisplayError( this, _( "Only one pad for this module" ) );
|
|
|
|
return;
|
2007-08-08 03:50:44 +00:00
|
|
|
}
|
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
Module->Draw( DrawPanel, DC, GR_XOR );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Calculate the current dimension. */
|
2007-08-08 03:50:44 +00:00
|
|
|
gap_size = next_pad->m_Pos0.x - pad->m_Pos0.x - pad->m_Size.x;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Entrance to the desired length of the gap. */
|
2007-08-08 03:50:44 +00:00
|
|
|
if( g_UnitMetric )
|
|
|
|
{
|
2009-05-21 17:42:42 +00:00
|
|
|
fcoeff = 10000.0f / 25.4f;
|
2007-08-08 03:50:44 +00:00
|
|
|
msg.Printf( wxT( "%2.3f" ), gap_size / fcoeff );
|
2009-11-18 12:52:19 +00:00
|
|
|
Get_Message( _( "Gap (mm):" ), _( "Create Microwave Gap" ), msg, this );
|
2007-08-08 03:50:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fcoeff = 10000.0;
|
|
|
|
msg.Printf( wxT( "%2.4f" ), gap_size / fcoeff );
|
2009-11-18 12:52:19 +00:00
|
|
|
Get_Message( _( "Gap (inch):" ), _( "Create Microwave Gap" ), msg,
|
|
|
|
this );
|
2007-08-08 03:50:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( !msg.IsEmpty() )
|
|
|
|
{
|
|
|
|
double fval;
|
|
|
|
if( msg.ToDouble( &fval ) )
|
|
|
|
gap_size = (int) ( fval * fcoeff );
|
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Updating sizes of pads forming the gap. */
|
2009-10-30 17:58:15 +00:00
|
|
|
pad->m_Size.x = pad->m_Size.y = GetBoard()->GetCurrentTrackWidth();
|
2007-08-08 03:50:44 +00:00
|
|
|
pad->m_Pos0.y = 0;
|
|
|
|
oX = pad->m_Pos0.x = -( (gap_size + pad->m_Size.x) / 2 );
|
|
|
|
pad->m_Pos.x = pad->m_Pos0.x + Module->m_Pos.x;
|
|
|
|
pad->m_Pos.y = pad->m_Pos0.y + Module->m_Pos.y;
|
2009-11-18 12:52:19 +00:00
|
|
|
RotatePoint( &pad->m_Pos.x, &pad->m_Pos.y,
|
2007-08-08 03:50:44 +00:00
|
|
|
Module->m_Pos.x, Module->m_Pos.y, Module->m_Orient );
|
|
|
|
|
2009-10-30 17:58:15 +00:00
|
|
|
next_pad->m_Size.x = next_pad->m_Size.y = GetBoard()->GetCurrentTrackWidth();
|
2007-08-08 03:50:44 +00:00
|
|
|
next_pad->m_Pos0.y = 0;
|
|
|
|
next_pad->m_Pos0.x = oX + gap_size + next_pad->m_Size.x;
|
|
|
|
next_pad->m_Pos.x = next_pad->m_Pos0.x + Module->m_Pos.x;
|
|
|
|
next_pad->m_Pos.y = next_pad->m_Pos0.y + Module->m_Pos.y;
|
2009-11-18 12:52:19 +00:00
|
|
|
RotatePoint( &next_pad->m_Pos.x, &next_pad->m_Pos.y,
|
2007-08-08 03:50:44 +00:00
|
|
|
Module->m_Pos.x, Module->m_Pos.y, Module->m_Orient );
|
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
Module->Draw( DrawPanel, DC, GR_OR );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|