Memory allocation improvements and other minor fixes.
* Replace C malloc() and free() functions with C++ new and delete operators or the appropriate STL container. * Add option to end mouse capture function to skip executing the end mouse capture callback. * Lots of coding policy and Doxygen comment goodness.
This commit is contained in:
parent
7bd8284661
commit
cc7e7fc5ca
|
@ -1,6 +1,31 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: 3d_aux.cpp
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file 3d_aux.cpp
|
||||
*/
|
||||
|
||||
#include "fctsys.h"
|
||||
|
||||
|
@ -23,54 +48,53 @@
|
|||
#include "trackball.h"
|
||||
|
||||
|
||||
void S3D_MASTER::Set_Object_Coords( S3D_Vertex* coord, int nbcoord )
|
||||
void S3D_MASTER::Set_Object_Coords( std::vector< S3D_Vertex >& aVertices )
|
||||
{
|
||||
int ii;
|
||||
|
||||
unsigned ii;
|
||||
|
||||
/* adjust object scale, rotation and offset position */
|
||||
for( ii = 0; ii < nbcoord; ii++ )
|
||||
for( ii = 0; ii < aVertices.size(); ii++ )
|
||||
{
|
||||
coord[ii].x *= m_MatScale.x;
|
||||
coord[ii].y *= m_MatScale.y;
|
||||
coord[ii].z *= m_MatScale.z;
|
||||
aVertices[ii].x *= m_MatScale.x;
|
||||
aVertices[ii].y *= m_MatScale.y;
|
||||
aVertices[ii].z *= m_MatScale.z;
|
||||
|
||||
/* adjust rotation */
|
||||
if( m_MatRotation.x )
|
||||
RotatePoint( &coord[ii].y, &coord[ii].z, (int) (m_MatRotation.x * 10) );
|
||||
RotatePoint( &aVertices[ii].y, &aVertices[ii].z, (int) (m_MatRotation.x * 10) );
|
||||
|
||||
if( m_MatRotation.y )
|
||||
RotatePoint( &coord[ii].z, &coord[ii].x, (int) (m_MatRotation.y * 10) );
|
||||
RotatePoint( &aVertices[ii].z, &aVertices[ii].x, (int) (m_MatRotation.y * 10) );
|
||||
|
||||
if( m_MatRotation.z )
|
||||
RotatePoint( &coord[ii].x, &coord[ii].y, (int) (m_MatRotation.z * 10) );
|
||||
RotatePoint( &aVertices[ii].x, &aVertices[ii].y, (int) (m_MatRotation.z * 10) );
|
||||
|
||||
/* adjust offset position (offset is given in UNIT 3D (0.1 inch) */
|
||||
#define SCALE_3D_CONV (PCB_INTERNAL_UNIT / UNITS3D_TO_UNITSPCB)
|
||||
coord[ii].x += m_MatPosition.x * SCALE_3D_CONV;
|
||||
coord[ii].y += m_MatPosition.y * SCALE_3D_CONV;
|
||||
coord[ii].z += m_MatPosition.z * SCALE_3D_CONV;
|
||||
aVertices[ii].x += m_MatPosition.x * SCALE_3D_CONV;
|
||||
aVertices[ii].y += m_MatPosition.y * SCALE_3D_CONV;
|
||||
aVertices[ii].z += m_MatPosition.z * SCALE_3D_CONV;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Set_Object_Data( const S3D_Vertex* coord, int nbcoord )
|
||||
void Set_Object_Data( std::vector< S3D_Vertex >& aVertices )
|
||||
{
|
||||
int ii;
|
||||
unsigned ii;
|
||||
GLfloat ax, ay, az, bx, by, bz, nx, ny, nz, r;
|
||||
|
||||
/* ignore faces with less than 3 points */
|
||||
if( nbcoord < 3 )
|
||||
if( aVertices.size() < 3 )
|
||||
return;
|
||||
|
||||
/* calculate normal direction */
|
||||
ax = coord[1].x - coord[0].x;
|
||||
ay = coord[1].y - coord[0].y;
|
||||
az = coord[1].z - coord[0].z;
|
||||
ax = aVertices[1].x - aVertices[0].x;
|
||||
ay = aVertices[1].y - aVertices[0].y;
|
||||
az = aVertices[1].z - aVertices[0].z;
|
||||
|
||||
bx = coord[nbcoord - 1].x - coord[0].x;
|
||||
by = coord[nbcoord - 1].y - coord[0].y;
|
||||
bz = coord[nbcoord - 1].z - coord[0].z;
|
||||
bx = aVertices[aVertices.size() - 1].x - aVertices[0].x;
|
||||
by = aVertices[aVertices.size() - 1].y - aVertices[0].y;
|
||||
bz = aVertices[aVertices.size() - 1].z - aVertices[0].z;
|
||||
|
||||
nx = ay * bz - az * by;
|
||||
ny = az * bx - ax * bz;
|
||||
|
@ -80,12 +104,14 @@ void Set_Object_Data( const S3D_Vertex* coord, int nbcoord )
|
|||
|
||||
if( r >= 0.000001 ) /* avoid division by zero */
|
||||
{
|
||||
nx /= r; ny /= r; nz /= r;
|
||||
nx /= r;
|
||||
ny /= r;
|
||||
nz /= r;
|
||||
glNormal3f( nx, ny, nz );
|
||||
}
|
||||
|
||||
/* glBegin/glEnd */
|
||||
switch( nbcoord )
|
||||
switch( aVertices.size() )
|
||||
{
|
||||
case 3:
|
||||
glBegin( GL_TRIANGLES );
|
||||
|
@ -101,11 +127,11 @@ void Set_Object_Data( const S3D_Vertex* coord, int nbcoord )
|
|||
}
|
||||
|
||||
/* draw polygon/triangle/quad */
|
||||
for( ii = 0; ii < nbcoord; ii++ )
|
||||
for( ii = 0; ii < aVertices.size(); ii++ )
|
||||
{
|
||||
glVertex3f( coord[ii].x * DataScale3D,
|
||||
coord[ii].y * DataScale3D,
|
||||
coord[ii].z * DataScale3D );
|
||||
glVertex3f( aVertices[ii].x * DataScale3D,
|
||||
aVertices[ii].y * DataScale3D,
|
||||
aVertices[ii].z * DataScale3D );
|
||||
}
|
||||
|
||||
glEnd();
|
||||
|
@ -150,10 +176,6 @@ GLuint EDA_3D_CANVAS::DisplayCubeforTest()
|
|||
}
|
||||
|
||||
|
||||
/**********************/
|
||||
/* class Info_3D_Visu */
|
||||
/**********************/
|
||||
|
||||
Info_3D_Visu::Info_3D_Visu()
|
||||
{
|
||||
int ii;
|
||||
|
@ -182,8 +204,6 @@ Info_3D_Visu::~Info_3D_Visu()
|
|||
}
|
||||
|
||||
|
||||
/* Display and edit a Vertex (triplet of values) in INCHES or MM or without
|
||||
* units */
|
||||
WinEDA_VertexCtrl::WinEDA_VertexCtrl( wxWindow* parent, const wxString& title,
|
||||
wxBoxSizer* BoxSizer,
|
||||
EDA_UNITS_T units, int internal_unit )
|
||||
|
@ -262,7 +282,6 @@ WinEDA_VertexCtrl::~WinEDA_VertexCtrl()
|
|||
}
|
||||
|
||||
|
||||
/* Returns (in internal units) to coordinate between (in user units) */
|
||||
S3D_Vertex WinEDA_VertexCtrl::GetValue()
|
||||
{
|
||||
S3D_Vertex value;
|
||||
|
|
|
@ -1,3 +1,28 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file 3d_draw.cpp
|
||||
*/
|
||||
|
@ -62,6 +87,7 @@ static void CALLBACK tessErrorCB( GLenum errorCode );
|
|||
static void CALLBACK tessCPolyPt2Vertex( const GLvoid* data );
|
||||
static void CALLBACK tesswxPoint2Vertex( const GLvoid* data );
|
||||
|
||||
|
||||
void EDA_3D_CANVAS::Redraw( bool finish )
|
||||
{
|
||||
/* SwapBuffer requires the window to be shown before calling */
|
||||
|
@ -118,8 +144,6 @@ void EDA_3D_CANVAS::Redraw( bool finish )
|
|||
}
|
||||
|
||||
|
||||
/* Create the draw list items
|
||||
*/
|
||||
GLuint EDA_3D_CANVAS::CreateDrawGL_List()
|
||||
{
|
||||
PCB_BASE_FRAME* pcbframe = m_Parent->m_Parent;
|
||||
|
@ -410,11 +434,6 @@ void EDA_3D_CANVAS::Draw3D_Track( TRACK* track )
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function Draw3D_SolidPolygonsInZones
|
||||
* draw all solid polygons used as filles areas in a zone
|
||||
* @param aZone = the zone to draw
|
||||
*/
|
||||
void EDA_3D_CANVAS::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone )
|
||||
{
|
||||
double zpos;
|
||||
|
@ -474,8 +493,6 @@ void EDA_3D_CANVAS::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone )
|
|||
}
|
||||
|
||||
|
||||
/* 3D drawing for a VIA (cylinder + filled circles)
|
||||
*/
|
||||
void EDA_3D_CANVAS::Draw3D_Via( SEGVIA* via )
|
||||
{
|
||||
double x, y, r, hole;
|
||||
|
@ -603,15 +620,6 @@ void EDA_3D_CANVAS::Draw3D_DrawSegment( DRAWSEGMENT* segment )
|
|||
}
|
||||
|
||||
|
||||
/* function to draw 3D segments, called by DrawGraphicText
|
||||
* When DrawGraphicText is called to draw a text to an OpenGL DC
|
||||
* it calls Draw3dTextSegm to each segment to draw.
|
||||
* 2 parameters used by Draw3D_FilledSegment are not handled by DrawGraphicText
|
||||
* but are used in Draw3D_FilledSegment().
|
||||
* they are 2 local variables. This is an ugly, but trivial code.
|
||||
* Using DrawGraphicText to draw all texts ensure texts have the same shape
|
||||
* in all contexts
|
||||
*/
|
||||
static double s_Text3DWidth, s_Text3DZPos;
|
||||
static void Draw3dTextSegm( int x0, int y0, int xf, int yf )
|
||||
{
|
||||
|
@ -1152,7 +1160,9 @@ static void Draw3D_FilledCylinder( double posx, double posy, double rayon,
|
|||
double x, y;
|
||||
|
||||
#define NB_SEGM 12
|
||||
S3D_Vertex coords[4];
|
||||
std::vector< S3D_Vertex > coords;
|
||||
coords.resize( 4 );
|
||||
|
||||
double tmp = DataScale3D;
|
||||
|
||||
DataScale3D = 1.0; // Coordinate is already in range for Set_Object_Data();
|
||||
|
@ -1168,7 +1178,7 @@ static void Draw3D_FilledCylinder( double posx, double posy, double rayon,
|
|||
RotatePoint( &x, &y, ii * (3600 / NB_SEGM) );
|
||||
coords[2].x = coords[3].x = posx + x;
|
||||
coords[2].y = coords[3].y = posy + y;
|
||||
Set_Object_Data( coords, 4 );
|
||||
Set_Object_Data( coords );
|
||||
coords[0].x = coords[2].x;
|
||||
coords[0].y = coords[2].y;
|
||||
coords[1].x = coords[3].x;
|
||||
|
@ -1377,12 +1387,6 @@ static void Draw3D_CircleSegment( double startx, double starty, double endx,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function Draw3D_Polygon
|
||||
* draw one solid polygon
|
||||
* @param aCornersList = a std::vector<wxPoint> list of corners, in physical coordinates
|
||||
* @param aZpos = the z position in 3D units
|
||||
*/
|
||||
void EDA_3D_CANVAS::Draw3D_Polygon( std::vector<wxPoint>& aCornersList, double aZpos )
|
||||
{
|
||||
g_Parm_3D_Visu.m_ActZpos = aZpos;
|
||||
|
|
|
@ -1,6 +1,31 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file 3d_read_mesh.cpp
|
||||
*/
|
||||
*/
|
||||
|
||||
#include "fctsys.h"
|
||||
#include "common.h"
|
||||
|
@ -36,7 +61,7 @@ int S3D_MASTER::ReadData()
|
|||
if( FullFilename.IsEmpty() )
|
||||
{
|
||||
wxLogDebug( wxT( "3D part library <%s> could not be found." ),
|
||||
GetChars( fn.GetFullPath() ) );
|
||||
GetChars( fn.GetFullPath() ) );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -48,8 +73,7 @@ int S3D_MASTER::ReadData()
|
|||
return -1;
|
||||
}
|
||||
|
||||
// Switch the locale to standard C (needed to print floating point
|
||||
// numbers like 1.3)
|
||||
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
|
||||
SetLocaleTo_C_standard();
|
||||
|
||||
while( GetLine( file, line, &LineNum, 512 ) )
|
||||
|
@ -82,20 +106,7 @@ int S3D_MASTER::ReadData()
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Analyzes the description of the type:
|
||||
* DEF yellow material Material (
|
||||
* DiffuseColor 1.00000 1.00000 0.00000e 0
|
||||
* EmissiveColor 0.00000e 0 0.00000e 0 0.00000e 0
|
||||
* SpecularColor 1.00000 1.00000 1.00000
|
||||
* AmbientIntensity 1.00000
|
||||
* Transparency 0.00000e 0
|
||||
* Shininess 1.00000
|
||||
*)
|
||||
* Or type:
|
||||
* USE yellow material
|
||||
*/
|
||||
int S3D_MASTER:: ReadMaterial( FILE* file, int* LineNum )
|
||||
int S3D_MASTER::ReadMaterial( FILE* file, int* LineNum )
|
||||
{
|
||||
char line[512], * text, * command;
|
||||
wxString mat_name;
|
||||
|
@ -282,7 +293,9 @@ int S3D_MASTER::ReadAppearance( FILE* file, int* LineNum )
|
|||
|
||||
#define BUFSIZE 2000
|
||||
|
||||
/* Read a coordinate list like:
|
||||
/**
|
||||
* Function ReadCoordList
|
||||
* reads 3D coordinate lists like:
|
||||
* coord Coordinate { point [
|
||||
* -5.24489 6.57640e-3 -9.42129e-2,
|
||||
* -5.11821 6.57421e-3 0.542654,
|
||||
|
@ -294,14 +307,12 @@ int S3D_MASTER::ReadAppearance( FILE* file, int* LineNum )
|
|||
* 0.707107 -9.38186e-7 0.707107]
|
||||
* }
|
||||
*
|
||||
* Return the coordinate list
|
||||
* text_buffer contains the first line of this node :
|
||||
* "coord Coordinate { point ["
|
||||
*/
|
||||
double* ReadCoordsList( FILE* file, char* text_buffer, int* bufsize, int* LineNum )
|
||||
void ReadCoordsList( FILE* file, char* text_buffer, std::vector< double >& aList, int* LineNum )
|
||||
{
|
||||
double* data_list = NULL;
|
||||
unsigned int ii = 0, jj = 0, nn = BUFSIZE;
|
||||
unsigned int ii = 0, jj = 0;
|
||||
char* text;
|
||||
bool HasData = false;
|
||||
bool StartData = false;
|
||||
|
@ -324,8 +335,8 @@ double* ReadCoordsList( FILE* file, char* text_buffer, int* bufsize, int* LineNu
|
|||
{
|
||||
case '[':
|
||||
StartData = true;
|
||||
jj = 0; string_num[jj] = 0;
|
||||
data_list = (double*) MyZMalloc( nn * sizeof(double) );
|
||||
jj = 0;
|
||||
string_num[jj] = 0;
|
||||
break;
|
||||
|
||||
case '}':
|
||||
|
@ -341,33 +352,29 @@ double* ReadCoordsList( FILE* file, char* text_buffer, int* bufsize, int* LineNu
|
|||
if( !StartData || !HasData )
|
||||
break;
|
||||
|
||||
data_list[ii] = atof( string_num );
|
||||
aList.push_back( atof( string_num ) );
|
||||
string_num[jj] = 0;
|
||||
ii++;
|
||||
|
||||
if( ii >= nn )
|
||||
{
|
||||
nn *= 2;
|
||||
data_list = (double*) realloc( data_list, ( nn * sizeof(double) ) );
|
||||
}
|
||||
|
||||
HasData = false;
|
||||
|
||||
if( *text == ']' )
|
||||
{
|
||||
StartData = false;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
if( !StartData )
|
||||
break;
|
||||
|
||||
if( jj >= sizeof(string_num) )
|
||||
if( jj >= sizeof( string_num ) )
|
||||
break;
|
||||
|
||||
string_num[jj] = *text;
|
||||
jj++; string_num[jj] = 0;
|
||||
jj++;
|
||||
string_num[jj] = 0;
|
||||
HasData = true;
|
||||
break;
|
||||
}
|
||||
|
@ -375,14 +382,6 @@ double* ReadCoordsList( FILE* file, char* text_buffer, int* bufsize, int* LineNu
|
|||
text++;
|
||||
}
|
||||
}
|
||||
|
||||
if( data_list )
|
||||
data_list = (double*) realloc( data_list, ( ii * sizeof(double) ) );
|
||||
|
||||
if( bufsize )
|
||||
*bufsize = ii;
|
||||
|
||||
return data_list;
|
||||
}
|
||||
|
||||
|
||||
|
@ -390,9 +389,8 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum )
|
|||
{
|
||||
char line[1024], buffer[1024], * text;
|
||||
int err = 1;
|
||||
int nn = BUFSIZE;
|
||||
double* points = NULL;
|
||||
int* index = NULL;
|
||||
std::vector< double > points;
|
||||
std::vector< double > list;
|
||||
|
||||
while( GetLine( file, line, LineNum, 512 ) )
|
||||
{
|
||||
|
@ -401,7 +399,8 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum )
|
|||
|
||||
if( *text == '}' )
|
||||
{
|
||||
err = 0; break;
|
||||
err = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if( stricmp( text, "normalPerVertex" ) == 0 )
|
||||
|
@ -432,13 +431,11 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum )
|
|||
|
||||
if( stricmp( text, "normal" ) == 0 )
|
||||
{
|
||||
int coord_number;
|
||||
double* buf_points = ReadCoordsList( file, line, &coord_number, LineNum );
|
||||
|
||||
// Do something if needed
|
||||
free( buf_points );
|
||||
ReadCoordsList( file, line, list, LineNum );
|
||||
list.clear();
|
||||
continue;
|
||||
}
|
||||
|
||||
if( stricmp( text, "normalIndex" ) == 0 )
|
||||
{
|
||||
while( GetLine( file, line, LineNum, 512 ) )
|
||||
|
@ -462,11 +459,8 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum )
|
|||
|
||||
if( stricmp( text, "color" ) == 0 )
|
||||
{
|
||||
int coord_number;
|
||||
double* buf_points = ReadCoordsList( file, line, &coord_number, LineNum );
|
||||
|
||||
// Do something if needed
|
||||
free( buf_points );
|
||||
ReadCoordsList( file, line, list, LineNum );
|
||||
list.clear();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -493,17 +487,24 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum )
|
|||
|
||||
if( stricmp( text, "coord" ) == 0 )
|
||||
{
|
||||
int coord_number;
|
||||
points = ReadCoordsList( file, line, &coord_number, LineNum );
|
||||
ReadCoordsList( file, line, points, LineNum );
|
||||
}
|
||||
else if( stricmp( text, "coordIndex" ) == 0 )
|
||||
{
|
||||
index = (int*) MyMalloc( nn * sizeof(int) );
|
||||
S3D_Vertex* coords = (S3D_Vertex*) MyMalloc( nn * sizeof(S3D_Vertex) );
|
||||
if( points.size() < 3 || points.size() % 3 != 0 )
|
||||
{
|
||||
wxLogError( wxT( "3D geometry read error <%s> at line %d." ),
|
||||
GetChars( FROM_UTF8( text ) ), *LineNum );
|
||||
err = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
std::vector< int > coordIndex;
|
||||
std::vector< S3D_Vertex > vertices;
|
||||
|
||||
while( GetLine( file, line, LineNum, 512 ) )
|
||||
{
|
||||
int coord_count = 0, jj;
|
||||
int jj;
|
||||
text = strtok( line, " ,\t\n\r" );
|
||||
|
||||
while( text )
|
||||
|
@ -515,24 +516,33 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum )
|
|||
|
||||
if( jj < 0 )
|
||||
{
|
||||
S3D_Vertex* curr_coord = coords;
|
||||
|
||||
for( jj = 0; jj < coord_count; jj++ )
|
||||
for( jj = 0; jj < (int) coordIndex.size(); jj++ )
|
||||
{
|
||||
int kk = index[jj] * 3;
|
||||
curr_coord->x = points[kk];
|
||||
curr_coord->y = points[kk + 1];
|
||||
curr_coord->z = points[kk + 2];
|
||||
curr_coord++;
|
||||
int kk = coordIndex[jj] * 3;
|
||||
|
||||
if( (kk < 0) || ((kk + 3) > points.size()) )
|
||||
{
|
||||
wxLogError( wxT( "3D geometry index read error <%s> at line %d." ),
|
||||
GetChars( FROM_UTF8( text ) ), *LineNum );
|
||||
err = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
S3D_Vertex vertex;
|
||||
vertex.x = points[kk];
|
||||
vertex.y = points[kk + 1];
|
||||
vertex.z = points[kk + 2];
|
||||
vertices.push_back( vertex );
|
||||
}
|
||||
|
||||
Set_Object_Coords( coords, coord_count );
|
||||
Set_Object_Data( coords, coord_count );
|
||||
coord_count = 0;
|
||||
Set_Object_Coords( vertices );
|
||||
Set_Object_Data( vertices );
|
||||
vertices.clear();
|
||||
coordIndex.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
index[coord_count++] = jj;
|
||||
coordIndex.push_back( jj );
|
||||
}
|
||||
|
||||
text = strtok( NULL, " ,\t\n\r" );
|
||||
|
@ -541,20 +551,16 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum )
|
|||
if( text && (*text == ']') )
|
||||
break;
|
||||
}
|
||||
|
||||
free( index );
|
||||
free( coords );
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "ReadGeometry error line %d <%s> \n", *LineNum, text );
|
||||
wxLogError( wxT( "3D geometry read error <%s> at line %d." ),
|
||||
GetChars( FROM_UTF8( text ) ), *LineNum );
|
||||
err = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( points )
|
||||
free( points );
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,28 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file 3d_struct.h
|
||||
*/
|
||||
|
@ -32,7 +57,9 @@ class S3D_Vertex /* 3D coordinate (3 float numbers: x,y,z coordinates)*/
|
|||
{
|
||||
public:
|
||||
double x, y, z;
|
||||
public: S3D_Vertex();
|
||||
|
||||
public:
|
||||
S3D_Vertex();
|
||||
};
|
||||
|
||||
class S3D_MATERIAL : public EDA_ITEM /* openGL "material" data*/
|
||||
|
@ -46,7 +73,8 @@ public:
|
|||
float m_Transparency;
|
||||
float m_Shininess;
|
||||
|
||||
public: S3D_MATERIAL( S3D_MASTER* father, const wxString& name );
|
||||
public:
|
||||
S3D_MATERIAL( S3D_MASTER* father, const wxString& name );
|
||||
|
||||
S3D_MATERIAL* Next() const { return (S3D_MATERIAL*) Pnext; }
|
||||
S3D_MATERIAL* Back() const { return (S3D_MATERIAL*) Pback; }
|
||||
|
@ -66,7 +94,8 @@ public:
|
|||
Struct3D_Shape* m_3D_Drawings;
|
||||
S3D_MATERIAL* m_Materials;
|
||||
|
||||
public: S3D_MASTER( EDA_ITEM* aParent );
|
||||
public:
|
||||
S3D_MASTER( EDA_ITEM* aParent );
|
||||
~S3D_MASTER();
|
||||
|
||||
S3D_MASTER* Next() const { return (S3D_MASTER*) Pnext; }
|
||||
|
@ -81,12 +110,27 @@ public: S3D_MASTER( EDA_ITEM* aParent );
|
|||
|
||||
void Copy( S3D_MASTER* pattern );
|
||||
int ReadData();
|
||||
|
||||
/**
|
||||
* Function ReadMaterial
|
||||
* read the description of a 3D material definition in the form:
|
||||
* DEF yellow material Material (
|
||||
* DiffuseColor 1.00000 1.00000 0.00000e 0
|
||||
* EmissiveColor 0.00000e 0 0.00000e 0 0.00000e 0
|
||||
* SpecularColor 1.00000 1.00000 1.00000
|
||||
* AmbientIntensity 1.00000
|
||||
* Transparency 0.00000e 0
|
||||
* Shininess 1.00000
|
||||
*)
|
||||
* Or type:
|
||||
* USE yellow material
|
||||
*/
|
||||
int ReadMaterial( FILE* file, int* LineNum );
|
||||
int ReadChildren( FILE* file, int* LineNum );
|
||||
int ReadShape( FILE* file, int* LineNum );
|
||||
int ReadAppearance( FILE* file, int* LineNum );
|
||||
int ReadGeometry( FILE* file, int* LineNum );
|
||||
void Set_Object_Coords( S3D_Vertex* coord, int nbcoord );
|
||||
void Set_Object_Coords( std::vector< S3D_Vertex >& aVertices );
|
||||
};
|
||||
|
||||
|
||||
|
@ -98,7 +142,8 @@ public:
|
|||
int* m_3D_CoordIndex;
|
||||
int m_3D_Points;
|
||||
|
||||
public: Struct3D_Shape( EDA_ITEM* aParent );
|
||||
public:
|
||||
Struct3D_Shape( EDA_ITEM* aParent );
|
||||
~Struct3D_Shape();
|
||||
|
||||
Struct3D_Shape* Next() const { return (Struct3D_Shape*) Pnext; }
|
||||
|
@ -108,11 +153,13 @@ public: Struct3D_Shape( EDA_ITEM* aParent );
|
|||
};
|
||||
|
||||
|
||||
/* Display and edit a Vertex (triplet of values) in INCHES or MM or without
|
||||
* units.
|
||||
* internal_unit is the internal unit number by inch:
|
||||
* - 1000 for EESchema
|
||||
* - 10000 for PcbNew
|
||||
/**
|
||||
* Class WinEDA_VertexCtrl
|
||||
* displays a vertex for editing. A vertex is a triplet of values in INCHES, MM,
|
||||
* or without units.
|
||||
*
|
||||
* Internal_units are the internal units by inch which is 1000 for Eeschema and
|
||||
* 10000 for Pcbnew
|
||||
*/
|
||||
class WinEDA_VertexCtrl
|
||||
{
|
||||
|
@ -128,6 +175,10 @@ public:
|
|||
|
||||
~WinEDA_VertexCtrl();
|
||||
|
||||
/**
|
||||
* Function GetValue
|
||||
* @return the vertex in internal units.
|
||||
*/
|
||||
S3D_Vertex GetValue();
|
||||
void SetValue( S3D_Vertex vertex );
|
||||
void Enable( bool enbl );
|
||||
|
|
|
@ -1,6 +1,32 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file 3d_viewer.h
|
||||
*/
|
||||
|
||||
#ifndef __3D_VIEWER_H__
|
||||
#define __3D_VIEWER_H__
|
||||
|
||||
|
@ -130,7 +156,7 @@ public:
|
|||
double m_BoardScale; /* Normalization scale for coordinates:
|
||||
* when scaled between -1.0 and +1.0 */
|
||||
double m_LayerZcoord[32];
|
||||
double m_ActZpos;
|
||||
double m_ActZpos;
|
||||
|
||||
public: Info_3D_Visu();
|
||||
~Info_3D_Visu();
|
||||
|
@ -175,6 +201,11 @@ public:
|
|||
void OnEnterWindow( wxMouseEvent& event );
|
||||
|
||||
void Render();
|
||||
|
||||
/**
|
||||
* Function CreateDrawGL_List
|
||||
* creates the OpenGL draw list items.
|
||||
*/
|
||||
GLuint CreateDrawGL_List();
|
||||
void InitGL();
|
||||
void SetLights();
|
||||
|
@ -194,11 +225,28 @@ public:
|
|||
* @param aZpos = the z position in 3D units
|
||||
*/
|
||||
void Draw3D_Polygon( std::vector<wxPoint>& aCornersList, double aZpos );
|
||||
|
||||
/**
|
||||
* Function Draw3D_Via
|
||||
* draws 3D via as a cylinder and filled circles.
|
||||
*/
|
||||
void Draw3D_Via( SEGVIA* via );
|
||||
void Draw3D_DrawSegment( DRAWSEGMENT* segment );
|
||||
|
||||
/**
|
||||
* Function Draw3D_DrawText
|
||||
* draws 3D segments to create text objects.
|
||||
* When DrawGraphicText is called to draw a text to an OpenGL DC
|
||||
* it calls Draw3dTextSegm to each segment to draw.
|
||||
* 2 parameters used by Draw3D_FilledSegment are not handled by DrawGraphicText
|
||||
* but are used in Draw3D_FilledSegment().
|
||||
* they are 2 local variables. This is an ugly, but trivial code.
|
||||
* Using DrawGraphicText to draw all texts ensure texts have the same shape
|
||||
* in all contexts
|
||||
*/
|
||||
void Draw3D_DrawText( TEXTE_PCB* text );
|
||||
|
||||
/// Toggles ortographic projection on and off
|
||||
/// Toggles orthographic projection on and off
|
||||
void ToggleOrtho(){ m_ortho = !m_ortho ; Refresh(true);};
|
||||
|
||||
/// Returns the orthographic projection flag
|
||||
|
@ -277,8 +325,8 @@ public:
|
|||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
void SetGLColor( int color );
|
||||
void Set_Object_Data( const S3D_Vertex* coord, int nbcoord );
|
||||
void SetGLColor( int color );
|
||||
void Set_Object_Data( std::vector< S3D_Vertex >& aVertices );
|
||||
|
||||
extern Info_3D_Visu g_Parm_3D_Visu;
|
||||
extern double g_Draw3d_dx, g_Draw3d_dy;
|
||||
|
|
|
@ -1,6 +1,31 @@
|
|||
/**************/
|
||||
/* common.cpp */
|
||||
/**************/
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file common.cpp
|
||||
*/
|
||||
|
||||
#include "fctsys.h"
|
||||
#include "gr_basic.h"
|
||||
|
@ -36,10 +61,8 @@ Ki_PageDescr g_Sheet_B( wxSize( 17000, 11000 ), wxPoint( 0, 0 ), wxT( "B" ) );
|
|||
Ki_PageDescr g_Sheet_C( wxSize( 22000, 17000 ), wxPoint( 0, 0 ), wxT( "C" ) );
|
||||
Ki_PageDescr g_Sheet_D( wxSize( 34000, 22000 ), wxPoint( 0, 0 ), wxT( "D" ) );
|
||||
Ki_PageDescr g_Sheet_E( wxSize( 44000, 34000 ), wxPoint( 0, 0 ), wxT( "E" ) );
|
||||
Ki_PageDescr g_Sheet_GERBER( wxSize( 32000, 32000 ), wxPoint( 0, 0 ),
|
||||
wxT( "GERBER" ) );
|
||||
Ki_PageDescr g_Sheet_user( wxSize( 17000, 11000 ), wxPoint( 0, 0 ),
|
||||
wxT( "User" ) );
|
||||
Ki_PageDescr g_Sheet_GERBER( wxSize( 32000, 32000 ), wxPoint( 0, 0 ), wxT( "GERBER" ) );
|
||||
Ki_PageDescr g_Sheet_user( wxSize( 17000, 11000 ), wxPoint( 0, 0 ), wxT( "User" ) );
|
||||
|
||||
Ki_PageDescr* g_SheetSizeList[NB_ITEMS + 1] =
|
||||
{
|
||||
|
@ -49,10 +72,6 @@ Ki_PageDescr* g_SheetSizeList[NB_ITEMS + 1] =
|
|||
};
|
||||
|
||||
|
||||
/* File extension definitions. Please do not changes these. If a different
|
||||
* file extension is needed, create a new definition in the application.
|
||||
* Please note, just because they are defined as const doesn't guarantee
|
||||
* that they cannot be changed. */
|
||||
const wxString ProjectFileExtension( wxT( "pro" ) );
|
||||
const wxString SchematicFileExtension( wxT( "sch" ) );
|
||||
const wxString NetlistFileExtension( wxT( "net" ) );
|
||||
|
@ -61,7 +80,6 @@ const wxString PcbFileExtension( wxT( "brd" ) );
|
|||
const wxString PdfFileExtension( wxT( "pdf" ) );
|
||||
const wxString MacrosFileExtension( wxT( "mcr" ) );
|
||||
|
||||
/* Proper wxFileDialog wild card definitions. */
|
||||
const wxString ProjectFileWildcard( _( "KiCad project files (*.pro)|*.pro" ) );
|
||||
const wxString SchematicFileWildcard( _( "KiCad schematic files (*.sch)|*.sch" ) );
|
||||
const wxString NetlistFileWildcard( _( "KiCad netlist files (*.net)|*.net" ) );
|
||||
|
@ -79,13 +97,12 @@ wxString g_UserLibDirBuffer;
|
|||
wxString g_Prj_Default_Config_FullFilename;
|
||||
wxString g_Prj_Config_LocalFilename;
|
||||
|
||||
/* Current user unit of measure */
|
||||
EDA_UNITS_T g_UserUnit;
|
||||
|
||||
/* Draw color for moving objects: */
|
||||
int g_GhostColor;
|
||||
|
||||
/* predefined colors used in kicad.
|
||||
/**
|
||||
* The predefined colors used in KiCad.
|
||||
* Please: if you change a value, remember these values are carefully chosen
|
||||
* to have good results in Pcbnew, that uses the ORed value of basic colors
|
||||
* when displaying superimposed objects
|
||||
|
@ -119,6 +136,7 @@ StructColors ColorRefs[NBCOLOR] =
|
|||
{ 128, 255, 255, LIGHTYELLOW, wxT( "LIGHTYELLOW" ), LIGHTYELLOW }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Function to use local notation or C standard notation for floating point numbers
|
||||
* some countries use 1,5 and others (and C) 1.5
|
||||
|
@ -131,34 +149,12 @@ StructColors ColorRefs[NBCOLOR] =
|
|||
bool g_DisableFloatingPointLocalNotation = false;
|
||||
|
||||
|
||||
/**
|
||||
* Function SetLocaleTo_C_standard
|
||||
* because KiCad is internationalized, switch internalization to "C" standard
|
||||
* i.e. uses the . (dot) as separator in print/read float numbers
|
||||
* (some countries (France, Germany ..) use , (comma) as separator)
|
||||
* This function must be called before read or write ascii files using float
|
||||
* numbers in data the SetLocaleTo_C_standard function must be called after
|
||||
* reading or writing the file
|
||||
*
|
||||
* This is wrapper to the C setlocale( LC_NUMERIC, "C" ) function,
|
||||
* but could make more easier an optional use of locale in KiCad
|
||||
*/
|
||||
void SetLocaleTo_C_standard( void )
|
||||
{
|
||||
setlocale( LC_NUMERIC, "C" ); // Switch the locale to standard C
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function SetLocaleTo_Default
|
||||
* because KiCad is internationalized, switch internalization to default
|
||||
* to use the default separator in print/read float numbers
|
||||
* (. (dot) but some countries (France, Germany ..) use , (comma) as separator)
|
||||
* This function must be called after a call to SetLocaleTo_C_standard
|
||||
*
|
||||
* This is wrapper to the C setlocale( LC_NUMERIC, "" ) function,
|
||||
* but could make more easier an optional use of locale in KiCad
|
||||
*/
|
||||
void SetLocaleTo_Default( void )
|
||||
{
|
||||
if( ! g_DisableFloatingPointLocalNotation )
|
||||
|
@ -166,8 +162,7 @@ void SetLocaleTo_Default( void )
|
|||
}
|
||||
|
||||
|
||||
bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl,
|
||||
const wxString* aString )
|
||||
bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString )
|
||||
{
|
||||
wxWindow* window = aCtrl->GetParent();
|
||||
|
||||
|
@ -192,19 +187,19 @@ bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl,
|
|||
}
|
||||
|
||||
wxSize size = aCtrl->GetSize();
|
||||
|
||||
if( size.GetWidth() < width + 10 )
|
||||
{
|
||||
size.SetWidth( width + 10 );
|
||||
aCtrl->SetSizeHints( size );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Ki_PageDescr::Ki_PageDescr( const wxSize& size,
|
||||
const wxPoint& offset,
|
||||
const wxString& name )
|
||||
Ki_PageDescr::Ki_PageDescr( const wxSize& size, const wxPoint& offset, const wxString& name )
|
||||
{
|
||||
// All sizes are in 1/1000 inch
|
||||
m_Size = size;
|
||||
|
@ -296,10 +291,6 @@ wxString GetAbbreviatedUnitsLabel( EDA_UNITS_T aUnit )
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Add string " (mm):" or " ("):" to the static text Stext.
|
||||
* Used in dialog boxes for entering values depending on selected units
|
||||
*/
|
||||
void AddUnitSymbol( wxStaticText& Stext, EDA_UNITS_T aUnit )
|
||||
{
|
||||
wxString msg = Stext.GetLabel();
|
||||
|
@ -310,10 +301,6 @@ void AddUnitSymbol( wxStaticText& Stext, EDA_UNITS_T aUnit )
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Convert the number Value in a string according to the internal units
|
||||
* and the selected unit (g_UserUnit) and put it in the wxTextCtrl TextCtrl
|
||||
*/
|
||||
void PutValueInLocalUnits( wxTextCtrl& TextCtr, int Value, int Internal_Unit )
|
||||
{
|
||||
wxString msg = ReturnStringFromValue( g_UserUnit, Value, Internal_Unit );
|
||||
|
@ -322,10 +309,6 @@ void PutValueInLocalUnits( wxTextCtrl& TextCtr, int Value, int Internal_Unit )
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Convert the Value in the wxTextCtrl TextCtrl in an integer,
|
||||
* according to the internal units and the selected unit (g_UserUnit)
|
||||
*/
|
||||
int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit )
|
||||
{
|
||||
int value;
|
||||
|
@ -337,17 +320,6 @@ int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit )
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function ReturnStringFromValue
|
||||
* Return the string from Value, according to units (inch, mm ...) for display,
|
||||
* and the initial unit for value
|
||||
* @param aUnit = display units (INCHES, MILLIMETRE ..)
|
||||
* @param aValue = value in Internal_Unit
|
||||
* @param aInternal_Unit = units per inch for Value
|
||||
* @param aAdd_unit_symbol = true to add symbol unit to the string value
|
||||
* @return a wxString what contains value and optionally the symbol unit
|
||||
* (like 2.000 mm)
|
||||
*/
|
||||
wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, int aInternal_Unit,
|
||||
bool aAdd_unit_symbol )
|
||||
{
|
||||
|
@ -355,9 +327,9 @@ wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, int aInternal_Uni
|
|||
double value_to_print;
|
||||
|
||||
value_to_print = To_User_Unit( aUnit, aValue, aInternal_Unit );
|
||||
|
||||
/* Yet another 'if Pcbnew' :( */
|
||||
StringValue.Printf( ( aInternal_Unit > 1000 ) ? wxT( "%.4f" ) :
|
||||
wxT( "%.3f" ),
|
||||
StringValue.Printf( ( aInternal_Unit > 1000 ) ? wxT( "%.4f" ) : wxT( "%.3f" ),
|
||||
value_to_print );
|
||||
|
||||
if( aAdd_unit_symbol )
|
||||
|
@ -379,15 +351,7 @@ wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, int aInternal_Uni
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Return the string from Value, according to units (inch, mm ...) for display,
|
||||
* and the initial unit for value
|
||||
* Unit = display units (INCH, MM ..)
|
||||
* Value = text
|
||||
* Internal_Unit = units per inch for computed value
|
||||
*/
|
||||
int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue,
|
||||
int Internal_Unit )
|
||||
int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue, int Internal_Unit )
|
||||
{
|
||||
int Value;
|
||||
double dtmp = 0;
|
||||
|
@ -399,6 +363,7 @@ int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue,
|
|||
|
||||
/* Convert the period in decimal point */
|
||||
buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) );
|
||||
|
||||
// An ugly fix needed by WxWidgets 2.9.1 that sometimes
|
||||
// back to a point as separator, although the separator is the comma
|
||||
// TODO: remove this line if WxWidgets 2.9.2 fixes this issue
|
||||
|
@ -406,14 +371,16 @@ int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue,
|
|||
|
||||
/* Find the end of the numeric part */
|
||||
unsigned brk_point = 0;
|
||||
|
||||
while( brk_point < buf.Len() )
|
||||
{
|
||||
wxChar ch = buf[brk_point];
|
||||
if( !( (ch >= '0' && ch <='9') || (ch == decimal_point)
|
||||
|| (ch == '-') || (ch == '+') ) )
|
||||
|
||||
if( !( (ch >= '0' && ch <='9') || (ch == decimal_point) || (ch == '-') || (ch == '+') ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
++brk_point;
|
||||
}
|
||||
|
||||
|
@ -422,6 +389,7 @@ int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue,
|
|||
|
||||
/* Check the optional unit designator (2 ch significant) */
|
||||
wxString unit( buf.Mid( brk_point ).Strip( wxString::leading ).Left( 2 ).Lower() );
|
||||
|
||||
if( unit == wxT( "in" ) || unit == wxT( "\"" ) )
|
||||
{
|
||||
aUnit = INCHES;
|
||||
|
@ -435,6 +403,7 @@ int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue,
|
|||
aUnit = INCHES;
|
||||
dtmp /= 1000;
|
||||
}
|
||||
|
||||
Value = From_User_Unit( aUnit, dtmp, Internal_Unit );
|
||||
|
||||
return Value;
|
||||
|
@ -453,18 +422,24 @@ const LENGTH_UNIT_DESC g_MillimetreDesc =
|
|||
wxT( "mm" ),
|
||||
6
|
||||
};
|
||||
|
||||
|
||||
const LENGTH_UNIT_DESC g_InchDesc =
|
||||
{
|
||||
LENGTH_UNITS<LENGTH_DEF>::inch(),
|
||||
wxT( "\"" ),
|
||||
7
|
||||
};
|
||||
|
||||
|
||||
const LENGTH_UNIT_DESC g_MilDesc =
|
||||
{
|
||||
LENGTH_UNITS<LENGTH_DEF>::mil(),
|
||||
wxT( "mil" ),
|
||||
5
|
||||
};
|
||||
|
||||
|
||||
const LENGTH_UNIT_DESC g_UnscaledDesc = /* stub */
|
||||
{
|
||||
LENGTH_DEF::quantum(),
|
||||
|
@ -472,6 +447,7 @@ const LENGTH_UNIT_DESC g_UnscaledDesc = /* stub */
|
|||
4
|
||||
};
|
||||
|
||||
|
||||
const LENGTH_UNIT_DESC *UnitDescription( EDA_UNITS_T aUnit ) {
|
||||
switch(aUnit) {
|
||||
case INCHES:
|
||||
|
@ -483,6 +459,7 @@ const LENGTH_UNIT_DESC *UnitDescription( EDA_UNITS_T aUnit ) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* TODO: localisation */
|
||||
wxString LengthToString( const LENGTH_UNIT_DESC *aUnit, LENGTH_DEF aValue,
|
||||
bool aAdd_unit_symbol ) {
|
||||
|
@ -491,18 +468,28 @@ wxString LengthToString( const LENGTH_UNIT_DESC *aUnit, LENGTH_DEF aValue,
|
|||
value_to_print = LENGTH<double>(aValue) / LENGTH<double>(aUnit->m_Value);
|
||||
StringValue.Printf( wxT( "%.*f" ), aUnit->m_Precision, value_to_print);
|
||||
size_t zero_tail = StringValue.find_last_not_of( wxT( "0" ) );
|
||||
if( zero_tail != std::string::npos ) {
|
||||
|
||||
if( zero_tail != std::string::npos )
|
||||
{
|
||||
//fprintf( stderr, "pos : %d", (int) zero_tail );
|
||||
size_t delim_pos = StringValue.Length() - aUnit->m_Precision;
|
||||
if( zero_tail < delim_pos) zero_tail = delim_pos;
|
||||
|
||||
if( zero_tail < delim_pos)
|
||||
zero_tail = delim_pos;
|
||||
|
||||
StringValue.Truncate( zero_tail + 1 );
|
||||
}
|
||||
if( aAdd_unit_symbol && aUnit->m_Symbol != wxT( "" ) ) {
|
||||
|
||||
if( aAdd_unit_symbol && aUnit->m_Symbol != wxT( "" ) )
|
||||
{
|
||||
StringValue += wxT( " " );
|
||||
StringValue += wxGetTranslation( aUnit->m_Symbol );
|
||||
|
||||
StringValue += wxGetTranslation( aUnit->m_Symbol );
|
||||
}
|
||||
|
||||
return StringValue;
|
||||
}
|
||||
|
||||
LENGTH_DEF StringToLength( const LENGTH_UNIT_DESC *aUnit, const wxString& TextValue )
|
||||
{
|
||||
|
||||
|
@ -516,6 +503,7 @@ LENGTH_DEF StringToLength( const LENGTH_UNIT_DESC *aUnit, const wxString& TextVa
|
|||
|
||||
/* Convert the period in decimal point */
|
||||
buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) );
|
||||
|
||||
// An ugly fix needed by WxWidgets 2.9.1 that sometimes
|
||||
// back to a point as separator, although the separator is the comma
|
||||
// TODO: remove this line if WxWidgets 2.9.2 fixes this issue
|
||||
|
@ -523,14 +511,17 @@ LENGTH_DEF StringToLength( const LENGTH_UNIT_DESC *aUnit, const wxString& TextVa
|
|||
|
||||
/* Find the end of the numeric part */
|
||||
unsigned brk_point = 0;
|
||||
|
||||
while( brk_point < buf.Len() )
|
||||
{
|
||||
wxChar ch = buf[brk_point];
|
||||
|
||||
if( !( (ch >= '0' && ch <='9') || (ch == decimal_point)
|
||||
|| (ch == '-') || (ch == '+') ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
++brk_point;
|
||||
}
|
||||
|
||||
|
@ -539,6 +530,7 @@ LENGTH_DEF StringToLength( const LENGTH_UNIT_DESC *aUnit, const wxString& TextVa
|
|||
|
||||
/* Check the optional unit designator (2 ch significant) */
|
||||
wxString unit( buf.Mid( brk_point ).Strip( wxString::leading ).Left( 2 ).Lower() );
|
||||
|
||||
if( unit == wxT( "in" ) || unit == wxT( "\"" ) )
|
||||
{
|
||||
aUnit = &g_InchDesc;
|
||||
|
@ -551,16 +543,19 @@ LENGTH_DEF StringToLength( const LENGTH_UNIT_DESC *aUnit, const wxString& TextVa
|
|||
{
|
||||
aUnit = &g_MilDesc;
|
||||
}
|
||||
|
||||
Value = LENGTH_DEF( dtmp * LENGTH< double, 1 >( aUnit->m_Value ) );
|
||||
|
||||
return Value;
|
||||
}
|
||||
|
||||
void LengthToTextCtrl( wxTextCtrl& TextCtr, LENGTH_DEF Value ) {
|
||||
void LengthToTextCtrl( wxTextCtrl& TextCtr, LENGTH_DEF Value )
|
||||
{
|
||||
wxString msg = LengthToString( UnitDescription( g_UserUnit ), Value );
|
||||
|
||||
TextCtr.SetValue( msg );
|
||||
}
|
||||
|
||||
LENGTH_DEF LengthFromTextCtrl( const wxTextCtrl& TextCtr )
|
||||
{
|
||||
LENGTH_DEF value;
|
||||
|
@ -573,46 +568,33 @@ LENGTH_DEF LengthFromTextCtrl( const wxTextCtrl& TextCtr )
|
|||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Function wxStringSplit
|
||||
* Split a String to a String List when founding 'splitter'
|
||||
* @return the list
|
||||
* @param txt : wxString : a String text
|
||||
* @param splitter : wxChar : the 'split' character
|
||||
*/
|
||||
wxArrayString* wxStringSplit( wxString txt, wxChar splitter )
|
||||
|
||||
wxArrayString* wxStringSplit( wxString aString, wxChar aSplitter )
|
||||
{
|
||||
wxArrayString* list = new wxArrayString();
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
int index = txt.Find( splitter );
|
||||
int index = aString.Find( aSplitter );
|
||||
|
||||
if( index == wxNOT_FOUND )
|
||||
break;
|
||||
|
||||
wxString tmp;
|
||||
tmp = txt.Mid( 0, index );
|
||||
txt = txt.Mid( index + 1, txt.size() - index );
|
||||
tmp = aString.Mid( 0, index );
|
||||
aString = aString.Mid( index + 1, aString.size() - index );
|
||||
list->Add( tmp );
|
||||
}
|
||||
|
||||
if( !txt.IsEmpty() )
|
||||
if( !aString.IsEmpty() )
|
||||
{
|
||||
list->Add( txt );
|
||||
list->Add( aString );
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function To_User_Unit
|
||||
* Convert in inch or mm the variable "val" (double)given in internal units
|
||||
* @return the converted value, in double
|
||||
* @param aUnit : user measure unit
|
||||
* @param val : double : the given value
|
||||
* @param internal_unit_value = internal units per inch
|
||||
*/
|
||||
double To_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value )
|
||||
{
|
||||
switch( aUnit )
|
||||
|
@ -629,9 +611,6 @@ double To_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value )
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Return in internal units the value "val" given in inch or mm
|
||||
*/
|
||||
int From_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value )
|
||||
{
|
||||
double value;
|
||||
|
@ -655,9 +634,6 @@ int From_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value )
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Return the string date "day month year" like "23 jun 2005"
|
||||
*/
|
||||
wxString GenDate()
|
||||
{
|
||||
static const wxString mois[12] =
|
||||
|
@ -679,36 +655,6 @@ wxString GenDate()
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* My memory allocation
|
||||
*/
|
||||
void* MyMalloc( size_t nb_octets )
|
||||
{
|
||||
void* pt_mem;
|
||||
|
||||
if( nb_octets == 0 )
|
||||
{
|
||||
DisplayError( NULL, wxT( "Allocate 0 bytes !!" ) );
|
||||
return NULL;
|
||||
}
|
||||
pt_mem = malloc( nb_octets );
|
||||
if( pt_mem == NULL )
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf( wxT( "Out of memory: allocation %d bytes" ), nb_octets );
|
||||
DisplayError( NULL, msg );
|
||||
}
|
||||
return pt_mem;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function ProcessExecute
|
||||
* runs a child process.
|
||||
* @param aCommandLine The process and any arguments to it all in a single string.
|
||||
* @param aFlags The same args as allowed for wxExecute()
|
||||
* @return bool - true if success, else false
|
||||
*/
|
||||
bool ProcessExecute( const wxString& aCommandLine, int aFlags )
|
||||
{
|
||||
#ifdef __WINDOWS__
|
||||
|
@ -721,26 +667,6 @@ bool ProcessExecute( const wxString& aCommandLine, int aFlags )
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* My memory allocation, memory space is cleared
|
||||
*/
|
||||
void* MyZMalloc( size_t nb_octets )
|
||||
{
|
||||
void* pt_mem = MyMalloc( nb_octets );
|
||||
|
||||
if( pt_mem )
|
||||
memset( pt_mem, 0, nb_octets );
|
||||
return pt_mem;
|
||||
}
|
||||
|
||||
|
||||
void MyFree( void* pt_mem )
|
||||
{
|
||||
if( pt_mem )
|
||||
free( pt_mem );
|
||||
}
|
||||
|
||||
|
||||
int GetTimeStamp()
|
||||
{
|
||||
static int OldTimeStamp, NewTimeStamp;
|
||||
|
@ -756,11 +682,6 @@ int GetTimeStamp()
|
|||
}
|
||||
|
||||
|
||||
/* Returns to display the value of a parameter, by type of units selected
|
||||
* Input: value in mils, buffer text
|
||||
* Returns to buffer: text: value expressed in inches or millimeters
|
||||
* Followed by " or mm
|
||||
*/
|
||||
const wxString& valeur_param( int valeur, wxString& buf_texte )
|
||||
{
|
||||
switch( g_UserUnit )
|
||||
|
@ -782,8 +703,6 @@ const wxString& valeur_param( int valeur, wxString& buf_texte )
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
wxString CoordinateToString( int aValue, int aInternalUnits, bool aConvertToMils )
|
||||
{
|
||||
wxCHECK_MSG( (aInternalUnits == EESCHEMA_INTERNAL_UNIT)
|
||||
|
@ -823,9 +742,6 @@ wxString CoordinateToString( int aValue, int aInternalUnits, bool aConvertToMils
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
wxString& operator <<( wxString& aString, const wxPoint& aPos )
|
||||
{
|
||||
wxString temp;
|
||||
|
|
|
@ -1127,7 +1127,7 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
|
|||
m_AbortRequest = true;
|
||||
|
||||
if( IsMouseCaptured() )
|
||||
EndMouseCapture( );
|
||||
EndMouseCapture();
|
||||
else
|
||||
EndMouseCapture( ID_NO_TOOL_SELECTED, m_defaultCursor, wxEmptyString );
|
||||
|
||||
|
@ -1237,9 +1237,10 @@ void EDA_DRAW_PANEL::OnPan( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
void EDA_DRAW_PANEL::EndMouseCapture( int id, int cursor, const wxString& title )
|
||||
void EDA_DRAW_PANEL::EndMouseCapture( int id, int cursor, const wxString& title,
|
||||
bool aCallEndFunc )
|
||||
{
|
||||
if( m_mouseCaptureCallback && m_endMouseCaptureCallback )
|
||||
if( m_mouseCaptureCallback && m_endMouseCaptureCallback && aCallEndFunc )
|
||||
{
|
||||
INSTALL_UNBUFFERED_DC( dc, this );
|
||||
m_endMouseCaptureCallback( this, &dc );
|
||||
|
|
|
@ -1,3 +1,28 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2009-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file eeschema/block.cpp
|
||||
*/
|
||||
|
@ -39,9 +64,6 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
|||
const wxPoint& aPosition, bool aErase );
|
||||
|
||||
|
||||
/* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
|
||||
* the key (ALT, SHIFT ALT ..)
|
||||
*/
|
||||
int SCH_EDIT_FRAME::ReturnBlockCommand( int key )
|
||||
{
|
||||
int cmd;
|
||||
|
@ -78,8 +100,6 @@ int SCH_EDIT_FRAME::ReturnBlockCommand( int key )
|
|||
}
|
||||
|
||||
|
||||
/* Init the parameters used by the block paste command
|
||||
*/
|
||||
void SCH_EDIT_FRAME::InitBlockPasteInfos()
|
||||
{
|
||||
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
|
||||
|
@ -89,11 +109,6 @@ void SCH_EDIT_FRAME::InitBlockPasteInfos()
|
|||
}
|
||||
|
||||
|
||||
/* Routine to handle the BLOCK PLACE command
|
||||
* Last routine for block operation for:
|
||||
* - block move & drag
|
||||
* - block copy & paste
|
||||
*/
|
||||
void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
||||
{
|
||||
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
|
||||
|
@ -175,22 +190,11 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
|||
block->ClearItemsList();
|
||||
}
|
||||
|
||||
DrawPanel->SetMouseCapture( NULL, NULL );
|
||||
SetToolID( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString );
|
||||
DrawPanel->EndMouseCapture( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString, false );
|
||||
DrawPanel->Refresh();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function HandleBlockEnd( )
|
||||
* Handle the "end" of a block command,
|
||||
* i.e. is called at the end of the definition of the area of a block.
|
||||
* depending on the current block command, this command is executed
|
||||
* or parameters are initialized to prepare a call to HandleBlockPlace
|
||||
* in GetScreen()->m_BlockLocate
|
||||
* @return false if no item selected, or command finished,
|
||||
* true if some items found and HandleBlockPlace must be called later
|
||||
*/
|
||||
bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
||||
{
|
||||
bool nextcmd = false;
|
||||
|
@ -309,8 +313,8 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
|||
block->m_State = STATE_NO_BLOCK;
|
||||
block->m_Command = BLOCK_IDLE;
|
||||
GetScreen()->SetCurItem( NULL );
|
||||
DrawPanel->SetMouseCapture( NULL, NULL );
|
||||
SetToolID( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString );
|
||||
DrawPanel->EndMouseCapture( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString,
|
||||
false );
|
||||
}
|
||||
|
||||
if( zoom_command )
|
||||
|
@ -320,15 +324,6 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
|||
}
|
||||
|
||||
|
||||
/* Manage end block command from context menu.
|
||||
* Can be called only :
|
||||
* after HandleBlockEnd
|
||||
* and if the current command is block move.
|
||||
* Execute a command other than block move from the current block move selected items list.
|
||||
* Due to (minor) problems in undo/redo or/and display block,
|
||||
* a mirror/rotate command is immediately executed and multiple block commands
|
||||
* are not allowed (multiple commands are tricky to undo/redo in one time)
|
||||
*/
|
||||
void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC )
|
||||
{
|
||||
bool blockCmdFinished = true; /* set to false for block command which
|
||||
|
@ -474,8 +469,8 @@ void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC )
|
|||
{
|
||||
block->Clear();
|
||||
GetScreen()->SetCurItem( NULL );
|
||||
DrawPanel->SetMouseCapture( NULL, NULL );
|
||||
SetToolID( GetToolId(), DrawPanel->GetDefaultCursor(), wxEmptyString );
|
||||
DrawPanel->EndMouseCapture( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString,
|
||||
false );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -536,10 +531,6 @@ void SCH_EDIT_FRAME::copyBlockItems( PICKED_ITEMS_LIST& aItemsList )
|
|||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Routine to paste a structure from the m_blockItems stack.
|
||||
* This routine is the same as undelete but original list is NOT removed.
|
||||
*****************************************************************************/
|
||||
void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC )
|
||||
{
|
||||
SCH_ITEM* Struct;
|
||||
|
|
|
@ -42,10 +42,6 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
|
|||
bool aErase );
|
||||
|
||||
|
||||
/*
|
||||
* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
|
||||
* the key (ALT, SHIFT ALT ..)
|
||||
*/
|
||||
int LIB_EDIT_FRAME::ReturnBlockCommand( int key )
|
||||
{
|
||||
int cmd;
|
||||
|
@ -86,13 +82,6 @@ int LIB_EDIT_FRAME::ReturnBlockCommand( int key )
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Command BLOCK END (end of block sizing)
|
||||
* return :
|
||||
* 0 if command finished (zoom, delete ...)
|
||||
* 1 if HandleBlockPlace must follow (items found, and a block place
|
||||
* command must follow)
|
||||
*/
|
||||
bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
||||
{
|
||||
int ItemCount = 0;
|
||||
|
@ -216,8 +205,8 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
|||
GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
|
||||
GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
|
||||
GetScreen()->SetCurItem( NULL );
|
||||
DrawPanel->SetMouseCapture( NULL, NULL );
|
||||
SetToolID( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString );
|
||||
DrawPanel->EndMouseCapture( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString,
|
||||
false );
|
||||
DrawPanel->Refresh( true );
|
||||
}
|
||||
|
||||
|
@ -225,12 +214,6 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Routine to handle the BLOCK PLACE command
|
||||
* Last routine for block operation for:
|
||||
* - block move & drag
|
||||
* - block copy & paste
|
||||
*/
|
||||
void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
||||
{
|
||||
wxPoint pt;
|
||||
|
@ -319,9 +302,8 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
|||
GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
|
||||
GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
|
||||
GetScreen()->SetCurItem( NULL );
|
||||
DrawPanel->SetMouseCapture( NULL, NULL );
|
||||
DrawPanel->EndMouseCapture( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString, false );
|
||||
DrawPanel->Refresh( true );
|
||||
SetToolID( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -102,13 +102,6 @@ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
|
|||
}
|
||||
|
||||
|
||||
/* Creates a new segment ( WIRE, BUS ),
|
||||
* or terminates the current segment
|
||||
* If the end of the current segment is on an other segment, place a junction
|
||||
* if needed and terminates the command
|
||||
* If the end of the current segment is on a pin, terminates the command
|
||||
* In others cases starts a new segment
|
||||
*/
|
||||
void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
|
||||
{
|
||||
SCH_LINE* oldsegment, * newsegment, * nextsegment;
|
||||
|
@ -240,8 +233,6 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
|
|||
}
|
||||
|
||||
|
||||
/* Called to terminate a bus, wire, or line creation
|
||||
*/
|
||||
void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
|
||||
{
|
||||
SCH_LINE* firstsegment = (SCH_LINE*) GetScreen()->GetCurItem();
|
||||
|
@ -291,7 +282,7 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
|
|||
GetScreen()->SetDrawItems( lastsegment );
|
||||
}
|
||||
|
||||
DrawPanel->SetMouseCapture( NULL, NULL );
|
||||
DrawPanel->EndMouseCapture( -1, -1, wxEmptyString, false );
|
||||
GetScreen()->SetCurItem( NULL );
|
||||
|
||||
wxPoint end_point, alt_end_point;
|
||||
|
@ -369,55 +360,53 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
|
|||
}
|
||||
|
||||
|
||||
/* compute the middle coordinate for 2 segments, from the start point to
|
||||
* new_pos
|
||||
* with the 2 segments kept H or V only
|
||||
/**
|
||||
* Function ComputeBreakPoint
|
||||
* computes the middle coordinate for 2 segments from the start point to \a aPosition
|
||||
* with the segments kept in the horizontal or vertical axis only.
|
||||
*/
|
||||
static void ComputeBreakPoint( SCH_LINE* segment, const wxPoint& new_pos )
|
||||
static void ComputeBreakPoint( SCH_LINE* aSegment, const wxPoint& aPosition )
|
||||
{
|
||||
SCH_LINE* nextsegment = segment->Next();
|
||||
wxPoint middle_position = new_pos;
|
||||
SCH_LINE* nextsegment = aSegment->Next();
|
||||
wxPoint middle_position = aPosition;
|
||||
|
||||
if( nextsegment == NULL )
|
||||
return;
|
||||
#if 0
|
||||
if( ABS( middle_position.x - segment->m_Start.x ) <
|
||||
ABS( middle_position.y - segment->m_Start.y ) )
|
||||
middle_position.x = segment->m_Start.x;
|
||||
if( ABS( middle_position.x - aSegment->m_Start.x ) <
|
||||
ABS( middle_position.y - aSegment->m_Start.y ) )
|
||||
middle_position.x = aSegment->m_Start.x;
|
||||
else
|
||||
middle_position.y = segment->m_Start.y;
|
||||
middle_position.y = aSegment->m_Start.y;
|
||||
#else
|
||||
int iDx = segment->m_End.x - segment->m_Start.x;
|
||||
int iDy = segment->m_End.y - segment->m_Start.y;
|
||||
int iDx = aSegment->m_End.x - aSegment->m_Start.x;
|
||||
int iDy = aSegment->m_End.y - aSegment->m_Start.y;
|
||||
|
||||
if( iDy != 0 ) // keep the first segment orientation (currently horizontal)
|
||||
{
|
||||
middle_position.x = segment->m_Start.x;
|
||||
middle_position.x = aSegment->m_Start.x;
|
||||
}
|
||||
else if( iDx != 0 ) // keep the first segment orientation (currently vertical)
|
||||
{
|
||||
middle_position.y = segment->m_Start.y;
|
||||
middle_position.y = aSegment->m_Start.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ABS( middle_position.x - segment->m_Start.x ) <
|
||||
ABS( middle_position.y - segment->m_Start.y ) )
|
||||
middle_position.x = segment->m_Start.x;
|
||||
if( ABS( middle_position.x - aSegment->m_Start.x ) <
|
||||
ABS( middle_position.y - aSegment->m_Start.y ) )
|
||||
middle_position.x = aSegment->m_Start.x;
|
||||
else
|
||||
middle_position.y = segment->m_Start.y;
|
||||
middle_position.y = aSegment->m_Start.y;
|
||||
}
|
||||
#endif
|
||||
|
||||
segment->m_End = middle_position;
|
||||
aSegment->m_End = middle_position;
|
||||
|
||||
nextsegment->m_Start = middle_position;
|
||||
nextsegment->m_End = new_pos;
|
||||
nextsegment->m_End = aPosition;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Erase the last trace or the element at the current mouse position.
|
||||
*/
|
||||
void SCH_EDIT_FRAME::DeleteCurrentSegment( wxDC* DC )
|
||||
{
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
|
@ -461,8 +450,6 @@ void SCH_EDIT_FRAME::DeleteCurrentSegment( wxDC* DC )
|
|||
}
|
||||
|
||||
|
||||
/* Routine to create new connection struct.
|
||||
*/
|
||||
SCH_JUNCTION* SCH_EDIT_FRAME::AddJunction( wxDC* aDC, const wxPoint& aPosition,
|
||||
bool aPutInUndoList )
|
||||
{
|
||||
|
@ -528,10 +515,6 @@ static void AbortCreateNewLine( EDA_DRAW_PANEL* Panel, wxDC* DC )
|
|||
}
|
||||
|
||||
|
||||
/* Repeat the last item placement.
|
||||
* Bus lines, text, labels
|
||||
* Labels that end with a number will be incremented.
|
||||
*/
|
||||
void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
|
||||
{
|
||||
if( m_itemToRepeat == NULL )
|
||||
|
|
|
@ -276,12 +276,9 @@ void LIB_POLYLINE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint
|
|||
int aColor, int aDrawMode, void* aData,
|
||||
const TRANSFORM& aTransform )
|
||||
{
|
||||
wxPoint pos1;
|
||||
int color = ReturnLayerColor( LAYER_DEVICE );
|
||||
|
||||
// Buffer used to store current corners coordinates for drawings
|
||||
static wxPoint* Buf_Poly_Drawings = NULL;
|
||||
static unsigned Buf_Poly_Size = 0;
|
||||
wxPoint pos1;
|
||||
int color = ReturnLayerColor( LAYER_DEVICE );
|
||||
wxPoint* buffer = NULL;
|
||||
|
||||
if( aColor < 0 ) // Used normal color or selected color
|
||||
{
|
||||
|
@ -293,29 +290,11 @@ void LIB_POLYLINE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint
|
|||
color = aColor;
|
||||
}
|
||||
|
||||
// Set the size of the buffer of coordinates
|
||||
if( Buf_Poly_Drawings == NULL )
|
||||
{
|
||||
Buf_Poly_Size = m_PolyPoints.size();
|
||||
Buf_Poly_Drawings = (wxPoint*) MyMalloc( sizeof(wxPoint) * Buf_Poly_Size );
|
||||
}
|
||||
else if( Buf_Poly_Size < m_PolyPoints.size() )
|
||||
{
|
||||
Buf_Poly_Size = m_PolyPoints.size();
|
||||
Buf_Poly_Drawings = (wxPoint*) realloc( Buf_Poly_Drawings,
|
||||
sizeof(wxPoint) * Buf_Poly_Size );
|
||||
}
|
||||
|
||||
// This should probably throw an exception instead of displaying a warning message.
|
||||
if( Buf_Poly_Drawings == NULL )
|
||||
{
|
||||
wxLogWarning( wxT( "Cannot allocate memory to draw polylines." ) );
|
||||
return;
|
||||
}
|
||||
buffer = new wxPoint[ m_PolyPoints.size() ];
|
||||
|
||||
for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ )
|
||||
{
|
||||
Buf_Poly_Drawings[ii] = aTransform.TransformCoordinate( m_PolyPoints[ii] ) + aOffset;
|
||||
buffer[ii] = aTransform.TransformCoordinate( m_PolyPoints[ii] ) + aOffset;
|
||||
}
|
||||
|
||||
FILL_T fill = aData ? NO_FILL : m_Fill;
|
||||
|
@ -326,16 +305,17 @@ void LIB_POLYLINE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint
|
|||
GRSetDrawMode( aDC, aDrawMode );
|
||||
|
||||
if( fill == FILLED_WITH_BG_BODYCOLOR )
|
||||
GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(),
|
||||
Buf_Poly_Drawings, 1, GetPenSize(),
|
||||
GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(), buffer, 1, GetPenSize(),
|
||||
(m_Flags & IS_MOVED) ? color : ReturnLayerColor( LAYER_DEVICE_BACKGROUND ),
|
||||
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
|
||||
else if( fill == FILLED_SHAPE )
|
||||
GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(),
|
||||
Buf_Poly_Drawings, 1, GetPenSize(), color, color );
|
||||
GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(), buffer, 1, GetPenSize(),
|
||||
color, color );
|
||||
else
|
||||
GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(),
|
||||
Buf_Poly_Drawings, 0, GetPenSize(), color, color );
|
||||
GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(), buffer, 0, GetPenSize(),
|
||||
color, color );
|
||||
|
||||
delete[] buffer;
|
||||
|
||||
/* Set to one (1) to draw bounding box around polyline to validate
|
||||
* bounding box calculation. */
|
||||
|
|
|
@ -470,8 +470,26 @@ public:
|
|||
bool LoadComponentAndSelectLib( LIB_ALIAS* aLibEntry, CMP_LIBRARY* aLibrary );
|
||||
|
||||
/* Block commands: */
|
||||
|
||||
/**
|
||||
* Function ReturnBlockCommand
|
||||
* returns the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
|
||||
* the \a aKey (ALT, SHIFT ALT ..)
|
||||
*/
|
||||
virtual int ReturnBlockCommand( int aKey );
|
||||
|
||||
/**
|
||||
* Function HandleBlockPlace
|
||||
* handles the block place command.
|
||||
*/
|
||||
virtual void HandleBlockPlace( wxDC* DC );
|
||||
|
||||
/**
|
||||
* Function HandleBlockEnd
|
||||
* performs a block end command.
|
||||
* @return If command finished (zoom, delete ...) false is returned otherwise true
|
||||
* is returned indicating more processing is required.
|
||||
*/
|
||||
virtual bool HandleBlockEnd( wxDC* DC );
|
||||
|
||||
void PlacePin( wxDC* DC );
|
||||
|
|
|
@ -537,13 +537,7 @@ void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet )
|
|||
int count = aSheet->CountSheets();
|
||||
m_count = count;
|
||||
m_index = 0;
|
||||
count *= sizeof(SCH_SHEET_PATH);
|
||||
|
||||
/* @bug - MyZMalloc() can return a NULL pointer if there is not enough
|
||||
* memory. This code continues on it's merry way with out
|
||||
* checking to see if the memory was actually allocated.
|
||||
*/
|
||||
m_List = (SCH_SHEET_PATH*) MyZMalloc( count );
|
||||
m_List = new SCH_SHEET_PATH[ count ];
|
||||
m_currList.Clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -317,7 +317,7 @@ public:
|
|||
~SCH_SHEET_LIST()
|
||||
{
|
||||
if( m_List )
|
||||
free( m_List );
|
||||
delete[] m_List;
|
||||
|
||||
m_List = NULL;
|
||||
}
|
||||
|
@ -460,10 +460,11 @@ private:
|
|||
/**
|
||||
* Function BuildSheetList
|
||||
* builds the list of sheets and their sheet path from \a aSheet.
|
||||
* If aSheet = g_RootSheet, the full sheet path and sheet list is built
|
||||
* If \a aSheet is the root sheet, the full sheet path and sheet list are built.
|
||||
*
|
||||
* @param aSheet is the starting sheet from which the list is built,
|
||||
* or NULL indicating that g_RootSheet should be used.
|
||||
* @param aSheet is the starting sheet from which the list is built, or NULL
|
||||
* indicating that g_RootSheet should be used.
|
||||
* @throw std::bad_alloc if the memory for the sheet path list could not be allocated.
|
||||
*/
|
||||
void BuildSheetList( SCH_SHEET* aSheet );
|
||||
};
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
/**
|
||||
* @file gerbview/block.cpp
|
||||
* @brief Block operations: displacement.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
|
@ -27,6 +22,11 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file gerbview/block.cpp
|
||||
* @brief Block operations: displacement.
|
||||
*/
|
||||
|
||||
|
||||
#include "fctsys.h"
|
||||
#include "common.h"
|
||||
|
@ -45,10 +45,7 @@
|
|||
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
||||
bool erase );
|
||||
|
||||
/* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
|
||||
* the key (ALT, SHIFT ALT ..)
|
||||
* Currently, only block move and block zoom is supported
|
||||
*/
|
||||
|
||||
int GERBVIEW_FRAME::ReturnBlockCommand( int key )
|
||||
{
|
||||
int cmd = 0;
|
||||
|
@ -78,7 +75,6 @@ int GERBVIEW_FRAME::ReturnBlockCommand( int key )
|
|||
}
|
||||
|
||||
|
||||
/* Routine to handle the BLOCK PLACE command */
|
||||
void GERBVIEW_FRAME::HandleBlockPlace( wxDC* DC )
|
||||
{
|
||||
wxASSERT( DrawPanel->IsMouseCaptured() );
|
||||
|
@ -120,9 +116,7 @@ void GERBVIEW_FRAME::HandleBlockPlace( wxDC* DC )
|
|||
break;
|
||||
}
|
||||
|
||||
DrawPanel->SetMouseCapture( NULL, NULL );
|
||||
DrawPanel->EndMouseCapture( );
|
||||
SetToolID( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString );
|
||||
DrawPanel->EndMouseCapture( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString, false );
|
||||
GetScreen()->SetModify();
|
||||
GetScreen()->ClearBlockCommand();
|
||||
|
||||
|
@ -132,16 +126,6 @@ void GERBVIEW_FRAME::HandleBlockPlace( wxDC* DC )
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function HandleBlockEnd( )
|
||||
* Handle the "end" of a block command,
|
||||
* i.e. is called at the end of the definition of the area of a block.
|
||||
* depending on the current block command, this command is executed
|
||||
* or parameters are initialized to prepare a call to HandleBlockPlace
|
||||
* in GetScreen()->m_BlockLocate
|
||||
* @return false if no item selected, or command finished,
|
||||
* true if some items found and HandleBlockPlace must be called later
|
||||
*/
|
||||
bool GERBVIEW_FRAME::HandleBlockEnd( wxDC* DC )
|
||||
{
|
||||
bool nextcmd = false;
|
||||
|
@ -188,10 +172,8 @@ bool GERBVIEW_FRAME::HandleBlockEnd( wxDC* DC )
|
|||
if( ! nextcmd )
|
||||
{
|
||||
GetScreen()->ClearBlockCommand();
|
||||
DrawPanel->SetMouseCapture( NULL, NULL );
|
||||
DrawPanel->EndMouseCapture( );
|
||||
SetToolID( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString );
|
||||
DisplayToolMsg( wxEmptyString );
|
||||
DrawPanel->EndMouseCapture( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString,
|
||||
false );
|
||||
}
|
||||
|
||||
if( zoom_command )
|
||||
|
@ -246,9 +228,6 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Erase the selected block.
|
||||
*/
|
||||
void GERBVIEW_FRAME::Block_Delete( wxDC* DC )
|
||||
{
|
||||
if( !IsOK( this, _( "Ok to delete block ?" ) ) )
|
||||
|
@ -272,9 +251,6 @@ void GERBVIEW_FRAME::Block_Delete( wxDC* DC )
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function to move items in the current selected block
|
||||
*/
|
||||
void GERBVIEW_FRAME::Block_Move( wxDC* DC )
|
||||
{
|
||||
wxPoint delta;
|
||||
|
@ -304,9 +280,6 @@ void GERBVIEW_FRAME::Block_Move( wxDC* DC )
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function to duplicate items in the current selected block
|
||||
*/
|
||||
void GERBVIEW_FRAME::Block_Duplicate( wxDC* DC )
|
||||
{
|
||||
wxPoint delta;
|
||||
|
@ -338,4 +311,3 @@ void GERBVIEW_FRAME::Block_Duplicate( wxDC* DC )
|
|||
|
||||
DrawPanel->Refresh();
|
||||
}
|
||||
|
||||
|
|
|
@ -383,12 +383,31 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title,
|
|||
void OnUpdateSelectDCode( wxUpdateUIEvent& aEvent );
|
||||
void OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent );
|
||||
|
||||
/* handlers for block commands */
|
||||
/**
|
||||
* Function ReturnBlockCommand
|
||||
* returns the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
|
||||
* the \a aKey (ALT, SHIFT ALT ..)
|
||||
*/
|
||||
virtual int ReturnBlockCommand( int key );
|
||||
virtual void HandleBlockPlace( wxDC* DC );
|
||||
virtual bool HandleBlockEnd( wxDC* DC );
|
||||
|
||||
/* Block operations: */
|
||||
/**
|
||||
* Function HandleBlockPlace
|
||||
* handles the block place command.
|
||||
*/
|
||||
virtual void HandleBlockPlace( wxDC* DC );
|
||||
|
||||
/**
|
||||
* Function HandleBlockEnd( )
|
||||
* handles the end of a block command,
|
||||
* It is called at the end of the definition of the area of a block.
|
||||
* Depending on the current block command, this command is executed
|
||||
* or parameters are initialized to prepare a call to HandleBlockPlace
|
||||
* in GetScreen()->m_BlockLocate
|
||||
*
|
||||
* @return false if no item selected, or command finished,
|
||||
* true if some items found and HandleBlockPlace must be called later.
|
||||
*/
|
||||
virtual bool HandleBlockEnd( wxDC* DC );
|
||||
|
||||
/**
|
||||
* Function Block_Delete
|
||||
|
|
|
@ -295,9 +295,11 @@ public:
|
|||
* current cursor.
|
||||
* @param aTitle The tool message to display in the status bar or wxEmptyString to clear
|
||||
* the message.
|
||||
* @param aCallEndFunc Call the abort mouse capture callback if true.
|
||||
*/
|
||||
void EndMouseCapture( int aId = -1, int aCursorId = -1,
|
||||
const wxString& aTitle = wxEmptyString );
|
||||
const wxString& aTitle = wxEmptyString,
|
||||
bool aCallEndFunc = true );
|
||||
|
||||
inline bool IsMouseCaptured() const { return m_mouseCaptureCallback != NULL; }
|
||||
|
||||
|
|
121
include/common.h
121
include/common.h
|
@ -1,3 +1,28 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* The common library
|
||||
* @file common.h
|
||||
|
@ -144,7 +169,12 @@ extern wxString g_UserLibDirBuffer;
|
|||
|
||||
extern bool g_ShowPageLimits; // true to display the page limits
|
||||
|
||||
/* File name extension definitions. */
|
||||
/**
|
||||
* File extension definitions. Please do not changes these. If a different
|
||||
* file extension is needed, create a new definition in the application.
|
||||
* Please note, just because they are defined as const doesn't guarantee
|
||||
* that they cannot be changed.
|
||||
*/
|
||||
extern const wxString ProjectFileExtension;
|
||||
extern const wxString SchematicFileExtension;
|
||||
extern const wxString NetlistFileExtension;
|
||||
|
@ -153,6 +183,7 @@ extern const wxString PcbFileExtension;
|
|||
extern const wxString PdfFileExtension;
|
||||
extern const wxString MacrosFileExtension;
|
||||
|
||||
/// Proper wxFileDialog wild card definitions.
|
||||
extern const wxString ProjectFileWildcard;
|
||||
extern const wxString SchematicFileWildcard;
|
||||
extern const wxString BoardFileWildcard;
|
||||
|
@ -172,7 +203,7 @@ extern wxString g_Prj_Config_LocalFilename;
|
|||
|
||||
extern EDA_UNITS_T g_UserUnit; ///< display units
|
||||
|
||||
/* Draw color for moving objects: */
|
||||
/// Draw color for moving objects.
|
||||
extern int g_GhostColor;
|
||||
|
||||
|
||||
|
@ -190,7 +221,7 @@ extern int g_GhostColor;
|
|||
* This is wrapper to the C setlocale( LC_NUMERIC, "C" ) function,
|
||||
* but could make more easier an optional use of locale in KiCad
|
||||
*/
|
||||
void SetLocaleTo_C_standard( void );
|
||||
void SetLocaleTo_C_standard( void );
|
||||
|
||||
/**
|
||||
* Function SetLocaleTo_Default
|
||||
|
@ -203,7 +234,7 @@ void SetLocaleTo_C_standard( void );
|
|||
* This is wrapper to the C setlocale( LC_NUMERIC, "" ) function,
|
||||
* but could make more easier an optional use of locale in KiCad
|
||||
*/
|
||||
void SetLocaleTo_Default( void );
|
||||
void SetLocaleTo_Default( void );
|
||||
|
||||
|
||||
/**
|
||||
|
@ -219,8 +250,7 @@ void SetLocaleTo_Default( void );
|
|||
* the text already within the control is used.
|
||||
* @return bool - true if the \a aCtrl had its size changed, else false.
|
||||
*/
|
||||
bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl,
|
||||
const wxString* aString = NULL );
|
||||
bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString = NULL );
|
||||
|
||||
|
||||
/**
|
||||
|
@ -292,8 +322,8 @@ wxString CoordinateToString( int aValue, int aInternalUnits, bool aConvertToMils
|
|||
* the format string must contain the %s format specifier.
|
||||
* @return The formatted units symbol.
|
||||
*/
|
||||
wxString ReturnUnitSymbol( EDA_UNITS_T aUnits = g_UserUnit,
|
||||
const wxString& aFormatString = _( " (%s):" ) );
|
||||
wxString ReturnUnitSymbol( EDA_UNITS_T aUnits = g_UserUnit,
|
||||
const wxString& aFormatString = _( " (%s):" ) );
|
||||
|
||||
/**
|
||||
* Get a human readable units string.
|
||||
|
@ -304,11 +334,18 @@ wxString ReturnUnitSymbol( EDA_UNITS_T aUnits = g_UserUnit,
|
|||
* @param aUnits - The units text to return.
|
||||
* @return The human readable units string.
|
||||
*/
|
||||
wxString GetUnitsLabel( EDA_UNITS_T aUnits );
|
||||
wxString GetAbbreviatedUnitsLabel( EDA_UNITS_T aUnit = g_UserUnit );
|
||||
wxString GetUnitsLabel( EDA_UNITS_T aUnits );
|
||||
wxString GetAbbreviatedUnitsLabel( EDA_UNITS_T aUnit = g_UserUnit );
|
||||
|
||||
int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue,
|
||||
int Internal_Unit );
|
||||
/**
|
||||
* Function ReturnValueFromeString
|
||||
* @return The string from Value, according to units (inch, mm ...) for display,
|
||||
* and the initial unit for value
|
||||
* Unit = display units (INCH, MM ..)
|
||||
* Value = text
|
||||
* Internal_Unit = units per inch for computed value
|
||||
*/
|
||||
int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue, int Internal_Unit );
|
||||
|
||||
/**
|
||||
* Function ReturnStringFromValue
|
||||
|
@ -321,24 +358,28 @@ int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextVa
|
|||
* @return a wxString what contains value and optionally the symbol unit (like
|
||||
* 2.000 mm)
|
||||
*/
|
||||
wxString ReturnStringFromValue( EDA_UNITS_T aUnit,
|
||||
int aValue,
|
||||
int aInternal_Unit,
|
||||
bool aAdd_unit_symbol = false );
|
||||
wxString ReturnStringFromValue( EDA_UNITS_T aUnit,
|
||||
int aValue,
|
||||
int aInternal_Unit,
|
||||
bool aAdd_unit_symbol = false );
|
||||
|
||||
|
||||
void AddUnitSymbol( wxStaticText& Stext, EDA_UNITS_T aUnit = g_UserUnit );
|
||||
/**
|
||||
* Function AddUnitSymbol
|
||||
* adds string " (mm):" or " ("):" to the static text Stext.
|
||||
* Used in dialog boxes for entering values depending on selected units
|
||||
*/
|
||||
void AddUnitSymbol( wxStaticText& Stext, EDA_UNITS_T aUnit = g_UserUnit );
|
||||
|
||||
/* Add string " (mm):" or " ("):" to the static text Stext.
|
||||
* Used in dialog boxes for entering values depending on selected units */
|
||||
void PutValueInLocalUnits( wxTextCtrl& TextCtr, int Value,
|
||||
int Internal_Unit );
|
||||
void PutValueInLocalUnits( wxTextCtrl& TextCtr, int Value, int Internal_Unit );
|
||||
|
||||
/* Convert the number Value in a string according to the internal units
|
||||
/**
|
||||
* Convert the number Value in a string according to the internal units
|
||||
* and the selected unit (g_UserUnit) and put it in the wxTextCtrl TextCtrl
|
||||
**/
|
||||
int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr,
|
||||
int Internal_Unit );
|
||||
*/
|
||||
int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit );
|
||||
|
||||
#ifdef KICAD_NANOMETRE
|
||||
|
||||
|
@ -348,6 +389,7 @@ struct LENGTH_UNIT_DESC
|
|||
const wxString m_Symbol;
|
||||
int m_Precision;
|
||||
};
|
||||
|
||||
extern const LENGTH_UNIT_DESC g_MillimetreDesc, g_InchDesc, g_MilDesc;
|
||||
|
||||
const LENGTH_UNIT_DESC *UnitDescription( EDA_UNITS_T aUnit );
|
||||
|
@ -358,10 +400,17 @@ wxString LengthToString( const LENGTH_UNIT_DESC *aUnit, LENGTH_DEF aValu
|
|||
|
||||
void LengthToTextCtrl( wxTextCtrl& TextCtr, LENGTH_DEF Value );
|
||||
LENGTH_DEF LengthFromTextCtrl( const wxTextCtrl& TextCtr );
|
||||
|
||||
#endif
|
||||
|
||||
/* return a String List from a string, with a specific splitter*/
|
||||
wxArrayString* wxStringSplit( wxString txt, wxChar splitter );
|
||||
/**
|
||||
* Function wxStringSplit
|
||||
* splita \a aString to a string list when split by \a aSplitter.
|
||||
* @return the list
|
||||
* @param aString : wxString : a String text
|
||||
* @param aSplitter : wxChar : the 'split' character
|
||||
*/
|
||||
wxArrayString* wxStringSplit( wxString aString, wxChar aSplitter );
|
||||
|
||||
/**
|
||||
* Function To_User_Unit
|
||||
|
@ -371,16 +420,18 @@ wxArrayString* wxStringSplit( wxString txt, wxChar splitter );
|
|||
* @param val : double : the given value
|
||||
* @param internal_unit_value = internal units per inch
|
||||
*/
|
||||
double To_User_Unit( EDA_UNITS_T aUnit,
|
||||
double val,
|
||||
int internal_unit_value );
|
||||
double To_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value );
|
||||
|
||||
int From_User_Unit( EDA_UNITS_T aUnit,
|
||||
double val,
|
||||
int internal_unit_value );
|
||||
wxString GenDate();
|
||||
void MyFree( void* pt_mem );
|
||||
void* MyZMalloc( size_t nb_octets );
|
||||
void* MyMalloc( size_t nb_octets );
|
||||
/*
|
||||
* Return in internal units the value "val" given in inch or mm
|
||||
*/
|
||||
int From_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value );
|
||||
|
||||
/**
|
||||
* Function GenDate
|
||||
* @return A wsString object containg the date in the format "day month year" like
|
||||
* "23 jun 2005".
|
||||
*/
|
||||
wxString GenDate();
|
||||
|
||||
#endif // __INCLUDE__COMMON_H__
|
||||
|
|
|
@ -404,7 +404,7 @@ public:
|
|||
* Uses data prepared by BuildAirWiresTargetsList()
|
||||
* @param aDC = the current device context
|
||||
*/
|
||||
void TraceAirWiresToTargets( wxDC* DC );
|
||||
void TraceAirWiresToTargets( wxDC* aDC );
|
||||
|
||||
/**
|
||||
* Function BuildAirWiresTargetsList
|
||||
|
|
|
@ -713,7 +713,10 @@ private:
|
|||
*/
|
||||
SCH_NO_CONNECT* AddNoConnect( wxDC* aDC, const wxPoint& aPosition );
|
||||
|
||||
// Junction
|
||||
/**
|
||||
* Function AddJunction
|
||||
* adds a new junction at \a aPosition.
|
||||
*/
|
||||
SCH_JUNCTION* AddJunction( wxDC* aDC, const wxPoint& aPosition, bool aPutInUndoList = false );
|
||||
|
||||
/**
|
||||
|
@ -738,9 +741,26 @@ private:
|
|||
*/
|
||||
void OnConvertTextType( wxCommandEvent& aEvent );
|
||||
|
||||
// Wire, Bus
|
||||
/**
|
||||
* Function BeginSegment
|
||||
* creates a new segment ( WIRE, BUS ) or terminates the current segment in progress.
|
||||
*
|
||||
* If the end of the current segment is on an other segment, place a junction if needed
|
||||
* and terminates the command. If the end of the current segment is on a pin, terminate
|
||||
* the command. In all other cases starts a new segment.
|
||||
*/
|
||||
void BeginSegment( wxDC* DC, int type );
|
||||
|
||||
/**
|
||||
* Function EndSegment
|
||||
* called to terminate a bus, wire, or line creation
|
||||
*/
|
||||
void EndSegment( wxDC* DC );
|
||||
|
||||
/**
|
||||
* Function DeleteCurrentSegment
|
||||
* erases the last segment at the current mouse position.
|
||||
*/
|
||||
void DeleteCurrentSegment( wxDC* DC );
|
||||
void DeleteConnection( bool DeleteFullConnection );
|
||||
|
||||
|
@ -870,6 +890,10 @@ private:
|
|||
void EditComponentFieldText( SCH_FIELD* aField, wxDC* aDC );
|
||||
void RotateField( SCH_FIELD* aField, wxDC* aDC );
|
||||
|
||||
/**
|
||||
* Function PastListOfItems
|
||||
* pastes a list of items from the block stack.
|
||||
*/
|
||||
void PasteListOfItems( wxDC* DC );
|
||||
|
||||
/* Undo - redo */
|
||||
|
@ -967,8 +991,21 @@ private:
|
|||
public:
|
||||
void Key( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct );
|
||||
|
||||
/* Block operations. */
|
||||
/**
|
||||
* Function InitBlockPasteInfos
|
||||
* initializes the parameters used by the block paste command.
|
||||
*/
|
||||
void InitBlockPasteInfos();
|
||||
|
||||
/* Function HandleBlockEndByPopUp
|
||||
* performs an end block command from context menu.
|
||||
*
|
||||
* This can be called only after HandleBlockEnd and the current command is block
|
||||
* move. Execute a command other than block move from the current block move
|
||||
* selected items list. Due to (minor) problems in undo/redo or/and display block,
|
||||
* a mirror/rotate command is immediately executed and multiple block commands are
|
||||
* not allowed (multiple commands are tricky to undo/redo in one time)
|
||||
*/
|
||||
void HandleBlockEndByPopUp( int Command, wxDC* DC );
|
||||
|
||||
/**
|
||||
|
@ -979,7 +1016,7 @@ public:
|
|||
* @param aKey = the key modifiers (Alt, Shift ...)
|
||||
* @return the block command id (BLOCK_MOVE, BLOCK_COPY...)
|
||||
*/
|
||||
virtual int ReturnBlockCommand( int aKey );
|
||||
virtual int ReturnBlockCommand( int aKey );
|
||||
|
||||
/**
|
||||
* Function HandleBlockPlace
|
||||
|
@ -1002,6 +1039,13 @@ public:
|
|||
*/
|
||||
virtual bool HandleBlockEnd( wxDC* DC );
|
||||
|
||||
/**
|
||||
* Function RepeatDrawItem
|
||||
* repeats the last item placement if the last item was a bus, bus entry,
|
||||
* label, or component.
|
||||
*
|
||||
* Labels that end with a number will be incremented.
|
||||
*/
|
||||
void RepeatDrawItem( wxDC* DC );
|
||||
|
||||
void SetRepeatItem( SCH_ITEM* aItem ) { m_itemToRepeat = aItem; }
|
||||
|
|
|
@ -755,6 +755,10 @@ public:
|
|||
*/
|
||||
void RecreateBOMFileFromBoard( wxCommandEvent& aEvent );
|
||||
|
||||
/**
|
||||
* Function ExportToGenCAD
|
||||
* creates a file in GenCAD 1.4 format from the current board.
|
||||
*/
|
||||
void ExportToGenCAD( wxCommandEvent& event );
|
||||
|
||||
/**
|
||||
|
@ -1311,6 +1315,13 @@ public:
|
|||
bool include_fixe );
|
||||
void LockModule( MODULE* aModule, bool aLocked );
|
||||
void AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb );
|
||||
|
||||
/**
|
||||
* Function AutoPlaceModule
|
||||
* automatically places footprints within the confines of the PCB edges.
|
||||
* The components with the FIXED status are not moved. If the menu is
|
||||
* calling the placement of 1 module, it will be replaced.
|
||||
*/
|
||||
void AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC );
|
||||
|
||||
/**
|
||||
|
@ -1324,6 +1335,15 @@ public:
|
|||
int GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC );
|
||||
|
||||
void GenModuleOnBoard( MODULE* Module );
|
||||
|
||||
/**
|
||||
* Function Compute_Ratsnest_PlaceModule
|
||||
* displays the module's ratsnest during displacement, and assess the "cost"
|
||||
* of the position.
|
||||
*
|
||||
* The cost is the longest ratsnest distance with penalty for connections
|
||||
* approaching 45 degrees.
|
||||
*/
|
||||
float Compute_Ratsnest_PlaceModule( wxDC* DC );
|
||||
|
||||
/**
|
||||
|
@ -1378,12 +1398,70 @@ public:
|
|||
*/
|
||||
void SendMessageToEESCHEMA( BOARD_ITEM* objectToSync );
|
||||
|
||||
/* Micro waves functions */
|
||||
/**
|
||||
* Function Edit_Gap
|
||||
* edits the GAP module if it has changed the position and/or size of the pads that
|
||||
* form the gap get a new value.
|
||||
*/
|
||||
void Edit_Gap( wxDC* DC, MODULE* Module );
|
||||
|
||||
/**
|
||||
* Function Create_MuWaveBasicShape
|
||||
* create a footprint with pad_count pads for micro wave applications.
|
||||
* This footprint has pad_count pads:
|
||||
* PAD_SMD, rectangular, H size = V size = current track width.
|
||||
*/
|
||||
MODULE* Create_MuWaveBasicShape( const wxString& name, int pad_count );
|
||||
|
||||
/**
|
||||
* Create_MuWaveComponent
|
||||
* creates a module "GAP" or "STUB" used in micro wave designs.
|
||||
* This module has 2 pads:
|
||||
* PAD_SMD, rectangular, H size = V size = current track width.
|
||||
* the "gap" is isolation created between this 2 pads
|
||||
*/
|
||||
MODULE* Create_MuWaveComponent( int shape_type );
|
||||
|
||||
MODULE* Create_MuWavePolygonShape();
|
||||
|
||||
void Begin_Self( wxDC* DC );
|
||||
|
||||
/**
|
||||
* Function Genre_Self
|
||||
* creates a self-shaped coil for microwave applications.
|
||||
* - Length Mself.lng
|
||||
* - Extremities Mself.m_Start and Mself.m_End
|
||||
*
|
||||
* 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.radius = radius of rounded parts of the coil
|
||||
* Mself.delta = segments extremities connection between him and the coil even
|
||||
*
|
||||
* The equations are
|
||||
* Mself.m_Size.x = 2 * Mself.radius + Mself.lbrin
|
||||
* Mself.m_Size.y * Mself.delta = 2 + 2 * Mself.nbrin * Mself.radius
|
||||
* 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.radius) / / length of rounded
|
||||
* Mself.lbrin + / 2 - Melf.radius * 2) / / length of 1st and last bit
|
||||
*
|
||||
* The constraints are:
|
||||
* Nbrin >= 2
|
||||
* Mself.radius < Mself.m_Size.x
|
||||
* Mself.m_Size.y = Mself.radius * 4 + 2 * Mself.raccord
|
||||
* Mself.lbrin> Mself.radius * 2
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
*/
|
||||
MODULE* Genere_Self( wxDC* DC );
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,3 +1,28 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file autoplac.cpp
|
||||
* @brief Routiness to automatically place MODULES on a board.
|
||||
|
@ -69,10 +94,6 @@ static void CreateKeepOutRectangle( BOARD* Pcb,
|
|||
static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC );
|
||||
|
||||
|
||||
/* Routine to automatically place components in the contour of the PCB
|
||||
* The components with the FIXED status are not moved. If the menu is
|
||||
* calling the placement of 1 module, it will be replaced.
|
||||
*/
|
||||
void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
|
||||
{
|
||||
int ii, activ;
|
||||
|
@ -867,12 +888,6 @@ int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide )
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Display the module's ratsnest during displacement, and
|
||||
* assess the "cost" of the position.
|
||||
* The cost is the longest ratsnest distance with penalty for connections
|
||||
* approaching 45 degrees.
|
||||
*/
|
||||
float PCB_EDIT_FRAME::Compute_Ratsnest_PlaceModule( wxDC* DC )
|
||||
{
|
||||
double cout, icout;
|
||||
|
@ -930,11 +945,9 @@ float PCB_EDIT_FRAME::Compute_Ratsnest_PlaceModule( wxDC* DC )
|
|||
}
|
||||
|
||||
|
||||
/***********************************/
|
||||
/* Draw keep out area of a module. */
|
||||
/***********************************/
|
||||
|
||||
/* Build the cost map.
|
||||
/**
|
||||
* Function CreateKeepOutRectangle
|
||||
* builds the cost map.
|
||||
* Cells ( in Dist mao ) inside the rect x0,y0 a x1,y1 are
|
||||
* incremented by value aKeepOut
|
||||
* Cell outside this rectangle, but inside the rectangle
|
||||
|
@ -1066,8 +1079,10 @@ static bool Tri_RatsModules( MODULE* ref, MODULE* compare )
|
|||
}
|
||||
|
||||
|
||||
/* Find the "best" module place
|
||||
* The criteria of choice are:
|
||||
/**
|
||||
* Function PickModule
|
||||
* find the "best" module place
|
||||
* The criteria are:
|
||||
* - Maximum ratsnest with modules already placed
|
||||
* - Max size, and number of pads max
|
||||
*/
|
||||
|
@ -1165,9 +1180,9 @@ static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
|
|||
*/
|
||||
int Propagation( PCB_EDIT_FRAME* frame )
|
||||
{
|
||||
int row, col, nn;
|
||||
int row, col;
|
||||
long current_cell, old_cell_H;
|
||||
int long* pt_cell_V;
|
||||
std::vector< long > pt_cell_V;
|
||||
int nbpoints = 0;
|
||||
|
||||
#define NO_CELL_ZONE (HOLE | CELL_is_EDGE | CELL_is_ZONE)
|
||||
|
@ -1176,13 +1191,10 @@ int Propagation( PCB_EDIT_FRAME* frame )
|
|||
frame->MsgPanel->SetMessage( 57, wxT( "Detect" ), msg, CYAN );
|
||||
frame->MsgPanel->SetMessage( -1, wxEmptyString, wxT( "1" ), CYAN );
|
||||
|
||||
// Alloc memory to handle 1 line or 1 column on the routing matrix
|
||||
nn = MAX( Nrows, Ncols ) * sizeof(*pt_cell_V);
|
||||
pt_cell_V = (long*) MyMalloc( nn );
|
||||
|
||||
/* search 1 : from left to right and top to bottom */
|
||||
memset( pt_cell_V, 0, nn );
|
||||
pt_cell_V.reserve( MAX( Nrows, Ncols ) );
|
||||
fill( pt_cell_V.begin(), pt_cell_V.end(), 0 );
|
||||
|
||||
// Search from left to right and top to bottom.
|
||||
for( row = 0; row < Nrows; row++ )
|
||||
{
|
||||
old_cell_H = 0;
|
||||
|
@ -1205,13 +1217,14 @@ int Propagation( PCB_EDIT_FRAME* frame )
|
|||
}
|
||||
}
|
||||
|
||||
/* search 2 : from right to left and top to bottom */
|
||||
// Search from right to left and top to bottom/
|
||||
frame->MsgPanel->SetMessage( -1, wxEmptyString, wxT( "2" ), CYAN );
|
||||
memset( pt_cell_V, 0, nn );
|
||||
fill( pt_cell_V.begin(), pt_cell_V.end(), 0 );
|
||||
|
||||
for( row = 0; row < Nrows; row++ )
|
||||
{
|
||||
old_cell_H = 0;
|
||||
|
||||
for( col = Ncols - 1; col >= 0; col-- )
|
||||
{
|
||||
current_cell = GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;
|
||||
|
@ -1230,9 +1243,9 @@ int Propagation( PCB_EDIT_FRAME* frame )
|
|||
}
|
||||
}
|
||||
|
||||
/* search 3 : from bottom to top and right to left balayage */
|
||||
// Search from bottom to top and right to left.
|
||||
frame->MsgPanel->SetMessage( -1, wxEmptyString, wxT( "3" ), CYAN );
|
||||
memset( pt_cell_V, 0, nn );
|
||||
fill( pt_cell_V.begin(), pt_cell_V.end(), 0 );
|
||||
|
||||
for( col = Ncols - 1; col >= 0; col-- )
|
||||
{
|
||||
|
@ -1256,9 +1269,9 @@ int Propagation( PCB_EDIT_FRAME* frame )
|
|||
}
|
||||
}
|
||||
|
||||
/* search 4 : from bottom to top and left to right */
|
||||
// Search from bottom to top and left to right.
|
||||
frame->MsgPanel->SetMessage( -1, wxEmptyString, wxT( "4" ), CYAN );
|
||||
memset( pt_cell_V, 0, nn );
|
||||
fill( pt_cell_V.begin(), pt_cell_V.end(), 0 );
|
||||
|
||||
for( col = 0; col < Ncols; col++ )
|
||||
{
|
||||
|
@ -1282,7 +1295,5 @@ int Propagation( PCB_EDIT_FRAME* frame )
|
|||
}
|
||||
}
|
||||
|
||||
MyFree( pt_cell_V );
|
||||
|
||||
return nbpoints;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,28 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file autorout.h
|
||||
*/
|
||||
|
@ -60,6 +85,10 @@ typedef char MATRIX_CELL;
|
|||
typedef int DIST_CELL;
|
||||
typedef char DIR_CELL;
|
||||
|
||||
|
||||
/**
|
||||
* class MATRIX_ROUTING_HEAD
|
||||
*/
|
||||
class MATRIX_ROUTING_HEAD /* header of blocks of MATRIX_CELL */
|
||||
{
|
||||
public:
|
||||
|
@ -79,9 +108,22 @@ public:
|
|||
MATRIX_ROUTING_HEAD();
|
||||
~MATRIX_ROUTING_HEAD();
|
||||
|
||||
bool ComputeMatrixSize( BOARD* aPcb );
|
||||
int InitBoard();
|
||||
void UnInitBoard();
|
||||
/**
|
||||
* Function ComputeMatrixSize
|
||||
* calculates the number of rows and columns of dimensions of \a aPcb for routing and
|
||||
* automatic calculation of area.
|
||||
*/
|
||||
bool ComputeMatrixSize( BOARD* aPcb );
|
||||
|
||||
/**
|
||||
* Function InitBoard
|
||||
* initializes the data structures.
|
||||
*
|
||||
* @return the amount of memory used or -1 if default.
|
||||
*/
|
||||
int InitBoard();
|
||||
|
||||
void UnInitBoard();
|
||||
};
|
||||
|
||||
extern MATRIX_ROUTING_HEAD Board; /* 2-sided board */
|
||||
|
|
103
pcbnew/block.cpp
103
pcbnew/block.cpp
|
@ -1,3 +1,28 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file pcbnew/block.cpp
|
||||
*/
|
||||
|
@ -58,6 +83,7 @@ static bool blockIncludePcbTexts = true;
|
|||
static bool blockDrawItems = true;
|
||||
static bool blockIncludeItemsOnInvisibleLayers = false;
|
||||
|
||||
|
||||
/************************************/
|
||||
/* class DIALOG_BLOCK_OPTIONS */
|
||||
/************************************/
|
||||
|
@ -149,14 +175,6 @@ void DIALOG_BLOCK_OPTIONS::ExecuteCommand( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function ReturnBlockCommand
|
||||
* Returns the block command internat code (BLOCK_MOVE, BLOCK_COPY...)
|
||||
* corresponding to the keys pressed (ALT, SHIFT, SHIFT ALT ..) when
|
||||
* block command is started by dragging the mouse.
|
||||
* @param aKey = the key modifiers (Alt, Shift ...)
|
||||
* @return the block command id (BLOCK_MOVE, BLOCK_COPY...)
|
||||
*/
|
||||
int PCB_EDIT_FRAME::ReturnBlockCommand( int aKey )
|
||||
{
|
||||
int cmd = 0;
|
||||
|
@ -196,13 +214,6 @@ int PCB_EDIT_FRAME::ReturnBlockCommand( int aKey )
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function HandleBlockPlace( )
|
||||
* Called after HandleBlockEnd, when a block command needs to be
|
||||
* executed after the block is moved to its new place
|
||||
* (bloc move, drag, copy .. )
|
||||
* Parameters must be initialized in GetScreen()->m_BlockLocate
|
||||
*/
|
||||
void PCB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
||||
{
|
||||
if( !DrawPanel->IsMouseCaptured() )
|
||||
|
@ -245,7 +256,7 @@ void PCB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
|||
|
||||
OnModify();
|
||||
|
||||
DrawPanel->SetMouseCapture( NULL, NULL );
|
||||
DrawPanel->EndMouseCapture( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString, false );
|
||||
GetScreen()->ClearBlockCommand();
|
||||
|
||||
if( GetScreen()->m_BlockLocate.GetCount() )
|
||||
|
@ -253,22 +264,9 @@ void PCB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
|||
DisplayError( this, wxT( "Error in HandleBlockPLace some items left in list" ) );
|
||||
GetScreen()->m_BlockLocate.ClearItemsList();
|
||||
}
|
||||
|
||||
DisplayToolMsg( wxEmptyString );
|
||||
DrawPanel->SetCursor( DrawPanel->GetCurrentCursor() );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function HandleBlockEnd( )
|
||||
* Handle the "end" of a block command,
|
||||
* i.e. is called at the end of the definition of the area of a block.
|
||||
* depending on the current block command, this command is executed
|
||||
* or parameters are initialized to prepare a call to HandleBlockPlace
|
||||
* in GetScreen()->m_BlockLocate
|
||||
* @return false if no item selected, or command finished,
|
||||
* true if some items found and HandleBlockPlace must be called later
|
||||
*/
|
||||
bool PCB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
||||
{
|
||||
bool nextcmd = false; // Will be set to true if a block place is needed
|
||||
|
@ -277,9 +275,9 @@ bool PCB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
|||
// If coming here after cancel block, clean up and exit
|
||||
if( GetScreen()->m_BlockLocate.m_State == STATE_NO_BLOCK )
|
||||
{
|
||||
DrawPanel->SetMouseCapture( NULL, NULL );
|
||||
DrawPanel->EndMouseCapture( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString,
|
||||
false );
|
||||
GetScreen()->ClearBlockCommand();
|
||||
DisplayToolMsg( wxEmptyString );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -368,22 +366,14 @@ bool PCB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
|||
if( ! nextcmd )
|
||||
{
|
||||
GetScreen()->ClearBlockCommand();
|
||||
DrawPanel->SetMouseCapture( NULL, NULL );
|
||||
DisplayToolMsg( wxEmptyString );
|
||||
DrawPanel->EndMouseCapture( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString,
|
||||
false );
|
||||
}
|
||||
|
||||
return nextcmd;
|
||||
}
|
||||
|
||||
|
||||
/* Block operations: */
|
||||
|
||||
/*
|
||||
* Function Block_SelectItems
|
||||
* Uses GetScreen()->m_BlockLocate
|
||||
* select items within the selected block.
|
||||
* selected items are put in the pick list
|
||||
*/
|
||||
void PCB_EDIT_FRAME::Block_SelectItems()
|
||||
{
|
||||
int layerMask;
|
||||
|
@ -598,9 +588,6 @@ static void drawMovingBlock( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Erase selected block.
|
||||
*/
|
||||
void PCB_EDIT_FRAME::Block_Delete()
|
||||
{
|
||||
OnModify();
|
||||
|
@ -633,7 +620,7 @@ void PCB_EDIT_FRAME::Block_Delete()
|
|||
case PCB_LINE_T: // a segment not on copper layers
|
||||
case PCB_TEXT_T: // a text on a layer
|
||||
case PCB_TRACE_T: // a track segment (segment on a copper layer)
|
||||
case PCB_VIA_T: // a via (like atrack segment on a copper layer)
|
||||
case PCB_VIA_T: // a via (like track segment on a copper layer)
|
||||
case PCB_DIMENSION_T: // a dimension (graphic item)
|
||||
case PCB_TARGET_T: // a target (graphic item)
|
||||
item->UnLink();
|
||||
|
@ -661,11 +648,6 @@ void PCB_EDIT_FRAME::Block_Delete()
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function Block_Rotate
|
||||
* Rotate all items within the selected block.
|
||||
* The rotation center is the center of the block
|
||||
*/
|
||||
void PCB_EDIT_FRAME::Block_Rotate()
|
||||
{
|
||||
wxPoint oldpos;
|
||||
|
@ -696,7 +678,7 @@ void PCB_EDIT_FRAME::Block_Rotate()
|
|||
|
||||
/* Move and rotate the track segments */
|
||||
case PCB_TRACE_T: // a track segment (segment on a copper layer)
|
||||
case PCB_VIA_T: // a via (like atrack segment on a copper layer)
|
||||
case PCB_VIA_T: // a via (like track segment on a copper layer)
|
||||
m_Pcb->m_Status_Pcb = 0;
|
||||
break;
|
||||
|
||||
|
@ -726,11 +708,6 @@ void PCB_EDIT_FRAME::Block_Rotate()
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function Block_Flip
|
||||
* flips items within the selected block.
|
||||
* The flip center is the center of the block
|
||||
*/
|
||||
void PCB_EDIT_FRAME::Block_Flip()
|
||||
{
|
||||
#define INVERT( pos ) (pos) = center.y - ( (pos) - center.y )
|
||||
|
@ -762,7 +739,7 @@ void PCB_EDIT_FRAME::Block_Flip()
|
|||
|
||||
/* Move and rotate the track segments */
|
||||
case PCB_TRACE_T: // a track segment (segment on a copper layer)
|
||||
case PCB_VIA_T: // a via (like atrack segment on a copper layer)
|
||||
case PCB_VIA_T: // a via (like track segment on a copper layer)
|
||||
m_Pcb->m_Status_Pcb = 0;
|
||||
break;
|
||||
|
||||
|
@ -792,12 +769,6 @@ void PCB_EDIT_FRAME::Block_Flip()
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function Block_Move
|
||||
* moves all tracks and segments within the selected block.
|
||||
* New location is determined by the current offset from the selected block's
|
||||
* original location.
|
||||
*/
|
||||
void PCB_EDIT_FRAME::Block_Move()
|
||||
{
|
||||
OnModify();
|
||||
|
@ -852,12 +823,6 @@ void PCB_EDIT_FRAME::Block_Move()
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function Block_Duplicate
|
||||
* duplicates all items within the selected block.
|
||||
* New location is determined by the current offset from the selected block's
|
||||
* original location.
|
||||
*/
|
||||
void PCB_EDIT_FRAME::Block_Duplicate()
|
||||
{
|
||||
wxPoint MoveVector = GetScreen()->m_BlockLocate.m_MoveVector;
|
||||
|
|
|
@ -1,7 +1,32 @@
|
|||
/****************************************************/
|
||||
/* block_module_editor.cpp */
|
||||
/* Handle block commands for the footprint editor */
|
||||
/****************************************************/
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file block_module_editor.cpp
|
||||
* @brief Footprint editor block handling implementation.
|
||||
*/
|
||||
|
||||
#include "fctsys.h"
|
||||
#include "appl_wxstruct.h"
|
||||
|
@ -194,8 +219,8 @@ bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
|||
|
||||
GetScreen()->ClearBlockCommand();
|
||||
SetCurItem( NULL );
|
||||
DrawPanel->SetMouseCapture( NULL, NULL );
|
||||
SetToolID( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString );
|
||||
DrawPanel->EndMouseCapture( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString,
|
||||
false );
|
||||
DrawPanel->Refresh( true );
|
||||
}
|
||||
|
||||
|
@ -264,9 +289,8 @@ void FOOTPRINT_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
|||
GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
|
||||
GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
|
||||
SetCurItem( NULL );
|
||||
DrawPanel->SetMouseCapture( NULL, NULL );
|
||||
DrawPanel->EndMouseCapture( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString, false );
|
||||
DrawPanel->Refresh( true );
|
||||
SetToolID( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,28 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file board.cpp
|
||||
* @brief Functions for autorouting
|
||||
|
@ -19,10 +44,6 @@
|
|||
#include "class_pcb_text.h"
|
||||
|
||||
|
||||
/*
|
||||
* Calculates nrows and ncols, dimensions of the matrix representation of BOARD
|
||||
* for routing and automatic calculation of area.
|
||||
*/
|
||||
bool MATRIX_ROUTING_HEAD::ComputeMatrixSize( BOARD* aPcb )
|
||||
{
|
||||
aPcb->ComputeBoundingBox();
|
||||
|
@ -51,8 +72,6 @@ bool MATRIX_ROUTING_HEAD::ComputeMatrixSize( BOARD* aPcb )
|
|||
}
|
||||
|
||||
|
||||
/* class MATRIX_ROUTING_HEAD
|
||||
*/
|
||||
MATRIX_ROUTING_HEAD::MATRIX_ROUTING_HEAD()
|
||||
{
|
||||
m_BoardSide[0] = m_BoardSide[1] = NULL;
|
||||
|
@ -70,9 +89,6 @@ MATRIX_ROUTING_HEAD::~MATRIX_ROUTING_HEAD()
|
|||
}
|
||||
|
||||
|
||||
/* initialize the data structures
|
||||
* returns the RAM size used, or -1 if default
|
||||
*/
|
||||
int MATRIX_ROUTING_HEAD::InitBoard()
|
||||
{
|
||||
int ii, kk;
|
||||
|
@ -93,19 +109,19 @@ int MATRIX_ROUTING_HEAD::InitBoard()
|
|||
m_DirSide[kk] = NULL;
|
||||
|
||||
/* allocate Board & initialize everything to empty */
|
||||
m_BoardSide[kk] = (MATRIX_CELL*) MyZMalloc( ii * sizeof(MATRIX_CELL) );
|
||||
m_BoardSide[kk] = (MATRIX_CELL*) operator new( ii * sizeof(MATRIX_CELL) );
|
||||
|
||||
if( m_BoardSide[kk] == NULL )
|
||||
return -1;
|
||||
|
||||
/***** allocate Distances *****/
|
||||
m_DistSide[kk] = (DIST_CELL*) MyZMalloc( ii * sizeof(DIST_CELL) );
|
||||
m_DistSide[kk] = (DIST_CELL*) operator new( ii * sizeof(DIST_CELL) );
|
||||
|
||||
if( m_DistSide[kk] == NULL )
|
||||
return -1;
|
||||
|
||||
/***** allocate Dir (chars) *****/
|
||||
m_DirSide[kk] = (char*) MyZMalloc( ii );
|
||||
m_DirSide[kk] = (char*) operator new( ii );
|
||||
|
||||
if( m_DirSide[kk] == NULL )
|
||||
return -1;
|
||||
|
@ -128,21 +144,21 @@ void MATRIX_ROUTING_HEAD::UnInitBoard()
|
|||
/***** de-allocate Dir matrix *****/
|
||||
if( m_DirSide[ii] )
|
||||
{
|
||||
MyFree( m_DirSide[ii] );
|
||||
delete m_DirSide[ii];
|
||||
m_DirSide[ii] = NULL;
|
||||
}
|
||||
|
||||
/***** de-allocate Distances matrix *****/
|
||||
if( m_DistSide[ii] )
|
||||
{
|
||||
MyFree( m_DistSide[ii] );
|
||||
delete m_DistSide[ii];
|
||||
m_DistSide[ii] = NULL;
|
||||
}
|
||||
|
||||
/**** de-allocate cells matrix *****/
|
||||
if( m_BoardSide[ii] )
|
||||
{
|
||||
MyFree( m_BoardSide[ii] );
|
||||
delete m_BoardSide[ii];
|
||||
m_BoardSide[ii] = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -151,10 +167,11 @@ void MATRIX_ROUTING_HEAD::UnInitBoard()
|
|||
}
|
||||
|
||||
|
||||
/* Initialize the cell board is set and VIA_IMPOSSIBLE HOLE according to
|
||||
* the setbacks
|
||||
* The elements of net_code = net_code will not be occupied as places
|
||||
* but only VIA_IMPOSSIBLE
|
||||
/**
|
||||
* Function PlaceCells
|
||||
* initializes the cell board is set and VIA_IMPOSSIBLE HOLE according to the setbacks.
|
||||
* The elements of net_code = net_code will not be occupied as places but only
|
||||
* VIA_IMPOSSIBLE
|
||||
* For single-sided Routing 1:
|
||||
* BOTTOM side is used and Route_Layer_BOTTOM = Route_Layer_TOP
|
||||
*
|
||||
|
|
|
@ -1,3 +1,28 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file export_gencad.cpp
|
||||
* @brief Export GenCAD 1.4 format.
|
||||
|
@ -53,6 +78,7 @@ static const wxString GenCAD_Layer_Name[32] =
|
|||
int offsetX, offsetY;
|
||||
D_PAD* PadList;
|
||||
|
||||
|
||||
/* 2 helper functions to calculate coordinates of modules in gencad values (
|
||||
* GenCAD Y axis from bottom to top)
|
||||
*/
|
||||
|
@ -68,9 +94,6 @@ static int mapYto( int y )
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Creates an Export file (format GenCAD 1.4) from the current board.
|
||||
*/
|
||||
void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& event )
|
||||
{
|
||||
wxFileName fn = GetScreen()->GetFileName();
|
||||
|
@ -612,6 +635,7 @@ void CreateRoutesSection( FILE* file, BOARD* pcb )
|
|||
|
||||
// Count items
|
||||
nbitems = 0;
|
||||
|
||||
for( track = pcb->m_Track; track != NULL; track = track->Next() )
|
||||
nbitems++;
|
||||
|
||||
|
@ -621,7 +645,7 @@ void CreateRoutesSection( FILE* file, BOARD* pcb )
|
|||
nbitems++;
|
||||
}
|
||||
|
||||
tracklist = (TRACK**) MyMalloc( (nbitems + 1) * sizeof(TRACK*) );
|
||||
tracklist = (TRACK**) operator new( (nbitems + 1) * sizeof( TRACK* ) );
|
||||
|
||||
nbitems = 0;
|
||||
|
||||
|
@ -690,7 +714,7 @@ void CreateRoutesSection( FILE* file, BOARD* pcb )
|
|||
|
||||
fputs( "$ENDROUTES\n\n", file );
|
||||
|
||||
free( tracklist );
|
||||
delete tracklist;
|
||||
}
|
||||
|
||||
|
||||
|
@ -926,6 +950,5 @@ void FootprintWriteShape( FILE* file, MODULE* module )
|
|||
default:
|
||||
break;
|
||||
} /* End switch Items type */
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,13 +71,11 @@ static bool HasNonSMDPins( MODULE* aModule )
|
|||
#endif
|
||||
|
||||
|
||||
/* Generate the module positions, used component placement.
|
||||
*/
|
||||
void PCB_EDIT_FRAME::GenModulesPosition( wxCommandEvent& event )
|
||||
{
|
||||
bool doBoardBack = false;
|
||||
MODULE* module;
|
||||
LIST_MOD* Liste = 0;
|
||||
LIST_MOD* list = NULL;
|
||||
char line[1024];
|
||||
wxFileName fnFront;
|
||||
wxFileName fnBack;
|
||||
|
@ -192,7 +190,7 @@ void PCB_EDIT_FRAME::GenModulesPosition( wxCommandEvent& event )
|
|||
AppendMsgPanel( _( "Module count" ), msg, RED );
|
||||
|
||||
// Sort the list of modules alphabetically
|
||||
Liste = (LIST_MOD*) MyZMalloc( moduleCount * sizeof(LIST_MOD) );
|
||||
list = new LIST_MOD[moduleCount];
|
||||
|
||||
module = GetBoard()->m_Modules;
|
||||
|
||||
|
@ -204,13 +202,13 @@ void PCB_EDIT_FRAME::GenModulesPosition( wxCommandEvent& event )
|
|||
if( (module->m_Attributs & MOD_CMS) == 0 )
|
||||
continue;
|
||||
|
||||
Liste[ii].m_Module = module;
|
||||
Liste[ii].m_Reference = module->m_Reference->m_Text;
|
||||
Liste[ii].m_Value = module->m_Value->m_Text;
|
||||
list[ii].m_Module = module;
|
||||
list[ii].m_Reference = module->m_Reference->m_Text;
|
||||
list[ii].m_Value = module->m_Value->m_Text;
|
||||
ii++;
|
||||
}
|
||||
|
||||
qsort( Liste, moduleCount, sizeof(LIST_MOD), ListeModCmp );
|
||||
qsort( list, moduleCount, sizeof(LIST_MOD), ListeModCmp );
|
||||
|
||||
// Write file header
|
||||
sprintf( line, "### Module positions - created on %s ###\n", TO_UTF8( DateAndTime() ) );
|
||||
|
@ -251,11 +249,11 @@ void PCB_EDIT_FRAME::GenModulesPosition( wxCommandEvent& event )
|
|||
for( int ii = 0; ii < moduleCount; ii++ )
|
||||
{
|
||||
wxPoint module_pos;
|
||||
wxString ref = Liste[ii].m_Reference;
|
||||
wxString val = Liste[ii].m_Value;
|
||||
wxString ref = list[ii].m_Reference;
|
||||
wxString val = list[ii].m_Value;
|
||||
sprintf( line, "%-8.8s %-16.16s ", TO_UTF8( ref ), TO_UTF8( val ) );
|
||||
|
||||
module_pos = Liste[ii].m_Module->m_Pos;
|
||||
module_pos = list[ii].m_Module->m_Pos;
|
||||
module_pos.x -= File_Place_Offset.x;
|
||||
module_pos.y -= File_Place_Offset.y;
|
||||
|
||||
|
@ -263,9 +261,9 @@ void PCB_EDIT_FRAME::GenModulesPosition( wxCommandEvent& event )
|
|||
sprintf( text, " %9.4f %9.4f %8.1f ",
|
||||
module_pos.x * conv_unit,
|
||||
module_pos.y * conv_unit,
|
||||
double(Liste[ii].m_Module->m_Orient) / 10 );
|
||||
double(list[ii].m_Module->m_Orient) / 10 );
|
||||
|
||||
int layer = Liste[ii].m_Module->GetLayer();
|
||||
int layer = list[ii].m_Module->GetLayer();
|
||||
|
||||
wxASSERT( layer==LAYER_N_FRONT || layer==LAYER_N_BACK );
|
||||
|
||||
|
@ -303,8 +301,8 @@ void PCB_EDIT_FRAME::GenModulesPosition( wxCommandEvent& event )
|
|||
|
||||
exit: // the only safe way out of here, no returns please.
|
||||
|
||||
if( Liste )
|
||||
MyFree( Liste );
|
||||
if( list )
|
||||
delete[] list;
|
||||
|
||||
if( switchedLocale )
|
||||
SetLocaleTo_Default( ); // revert to the current locale
|
||||
|
|
|
@ -1,3 +1,28 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file muonde.cpp
|
||||
* @brief Microwave pcb layout code.
|
||||
|
@ -26,8 +51,8 @@
|
|||
|
||||
|
||||
#define COEFF_COUNT 6
|
||||
static double* PolyEdges;
|
||||
static int PolyEdgesCount;
|
||||
|
||||
static std::vector< double > PolyEdges;
|
||||
static double ShapeScaleX, ShapeScaleY;
|
||||
static wxSize ShapeSize;
|
||||
static int PolyShapeType;
|
||||
|
@ -148,40 +173,6 @@ void PCB_EDIT_FRAME::Begin_Self( wxDC* DC )
|
|||
}
|
||||
|
||||
|
||||
/* Create a self-shaped coil
|
||||
* - Length Mself.lng
|
||||
* - Extremities Mself.m_Start and Mself.m_End
|
||||
*
|
||||
* 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.radius = radius of rounded parts of the coil
|
||||
* Mself.delta = segments extremities connection between him and the coil even
|
||||
*
|
||||
* The equations are
|
||||
* Mself.m_Size.x = 2 * Mself.radius + Mself.lbrin
|
||||
* Mself.m_Size.y * Mself.delta = 2 + 2 * Mself.nbrin * Mself.radius
|
||||
* 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.radius) / / length of rounded
|
||||
* Mself.lbrin + / 2 - Melf.radius * 2) / / length of 1st and last bit
|
||||
*
|
||||
* The constraints are:
|
||||
* Nbrin >= 2
|
||||
* Mself.radius < Mself.m_Size.x
|
||||
* Mself.m_Size.y = Mself.radius * 4 + 2 * Mself.raccord
|
||||
* Mself.lbrin> Mself.radius * 2
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
*/
|
||||
MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC )
|
||||
{
|
||||
D_PAD* PtPad;
|
||||
|
@ -210,7 +201,7 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC )
|
|||
wxTextEntryDialog dlg( this, _( "Length:" ), _( "Length" ), msg );
|
||||
|
||||
if( dlg.ShowModal() != wxID_OK )
|
||||
return NULL; // cancelled by user
|
||||
return NULL; // canceled by user
|
||||
|
||||
msg = dlg.GetValue();
|
||||
Mself.lng = ReturnValueFromString( g_UserUnit, msg, GetScreen()->GetInternalUnits() );
|
||||
|
@ -306,8 +297,9 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC )
|
|||
}
|
||||
|
||||
|
||||
/** gen_arc
|
||||
* Generate an arc using arc approximation by lines:
|
||||
/**
|
||||
* Function gen_arc
|
||||
* generates an arc using arc approximation by lines:
|
||||
* Center aCenter
|
||||
* Angle "angle" (in 0.1 deg)
|
||||
* @param aBuffer = a buffer to store points.
|
||||
|
@ -395,7 +387,7 @@ int BuildCornersList_S_Shape( std::vector <wxPoint>& aBuffer,
|
|||
// the arc to segment approximation.
|
||||
// because we use SEGM_COUNT_PER_360DEG segment to approximate a circle,
|
||||
// the trace len must be corrected when calculated using arcs
|
||||
// this factor adjust calculations and must be canged if SEGM_COUNT_PER_360DEG is modified
|
||||
// this factor adjust calculations and must be changed if SEGM_COUNT_PER_360DEG is modified
|
||||
// because trace using segment is shorter the corresponding arc
|
||||
// ADJUST_SIZE is the ratio between tline len and the arc len for an arc
|
||||
// of 360/ADJUST_SIZE angle
|
||||
|
@ -528,10 +520,6 @@ int BuildCornersList_S_Shape( std::vector <wxPoint>& aBuffer,
|
|||
}
|
||||
|
||||
|
||||
/* Create a footprint with pad_count pads for micro wave applications
|
||||
* This footprint has pad_count pads:
|
||||
* PAD_SMD, rectangular, H size = V size = current track width.
|
||||
*/
|
||||
MODULE* PCB_EDIT_FRAME::Create_MuWaveBasicShape( const wxString& name, int pad_count )
|
||||
{
|
||||
MODULE* Module;
|
||||
|
@ -578,12 +566,6 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveBasicShape( const wxString& name, int pad_c
|
|||
}
|
||||
|
||||
|
||||
/* Create a module "GAP" or "STUB"
|
||||
* This a "gap" or "stub" used in micro wave designs
|
||||
* This module has 2 pads:
|
||||
* PAD_SMD, rectangular, H size = V size = current track width.
|
||||
* the "gap" is isolation created between this 2 pads
|
||||
*/
|
||||
MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type )
|
||||
{
|
||||
int oX;
|
||||
|
@ -759,6 +741,23 @@ public: WinEDA_SetParamShapeFrame( PCB_EDIT_FRAME* parent, const wxPoint& pos );
|
|||
private:
|
||||
void OnOkClick( wxCommandEvent& event );
|
||||
void OnCancelClick( wxCommandEvent& event );
|
||||
|
||||
/**
|
||||
* Function ReadDataShapeDescr
|
||||
* read a description shape file
|
||||
* File format is
|
||||
* Unit=MM
|
||||
* XScale=271.501
|
||||
* YScale=1.00133
|
||||
*
|
||||
* $COORD
|
||||
* 0 0.6112600148417837
|
||||
* 0.001851851851851852 0.6104800531118608
|
||||
* ....
|
||||
* $ENDCOORD
|
||||
*
|
||||
* Each line is the X Y coord (normalized units from 0 to 1)
|
||||
*/
|
||||
void ReadDataShapeDescr( wxCommandEvent& event );
|
||||
void AcceptOptions( wxCommandEvent& event );
|
||||
|
||||
|
@ -779,11 +778,7 @@ WinEDA_SetParamShapeFrame::WinEDA_SetParamShapeFrame( PCB_EDIT_FRAME* parent,
|
|||
{
|
||||
m_Parent = parent;
|
||||
|
||||
if( PolyEdges )
|
||||
free( PolyEdges );
|
||||
|
||||
PolyEdges = NULL;
|
||||
PolyEdgesCount = 0;
|
||||
PolyEdges.clear();
|
||||
|
||||
wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
SetSizer( MainBoxSizer );
|
||||
|
@ -825,11 +820,7 @@ WinEDA_SetParamShapeFrame::WinEDA_SetParamShapeFrame( PCB_EDIT_FRAME* parent,
|
|||
|
||||
void WinEDA_SetParamShapeFrame::OnCancelClick( wxCommandEvent& event )
|
||||
{
|
||||
if( PolyEdges )
|
||||
free( PolyEdges );
|
||||
|
||||
PolyEdges = NULL;
|
||||
PolyEdgesCount = 0;
|
||||
PolyEdges.clear();
|
||||
EndModal( -1 );
|
||||
}
|
||||
|
||||
|
@ -842,20 +833,6 @@ void WinEDA_SetParamShapeFrame::OnOkClick( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
/* Read a description shape file
|
||||
* File format is
|
||||
* Unit=MM
|
||||
* XScale=271.501
|
||||
* YScale=1.00133
|
||||
*
|
||||
* $COORD
|
||||
* 0 0.6112600148417837
|
||||
* 0.001851851851851852 0.6104800531118608
|
||||
* ....
|
||||
* $ENDCOORD
|
||||
*
|
||||
* Each line is the X Y coord (normalized units from 0 to 1)
|
||||
*/
|
||||
void WinEDA_SetParamShapeFrame::ReadDataShapeDescr( wxCommandEvent& event )
|
||||
{
|
||||
wxString FullFileName;
|
||||
|
@ -864,8 +841,6 @@ void WinEDA_SetParamShapeFrame::ReadDataShapeDescr( wxCommandEvent& event )
|
|||
char* Line;
|
||||
double unitconv = 10000;
|
||||
char* param1, * param2;
|
||||
int bufsize;
|
||||
double* ptbuf;
|
||||
|
||||
ext = wxT( ".txt" );
|
||||
mask = wxT( "*" ) + ext;
|
||||
|
@ -892,9 +867,6 @@ void WinEDA_SetParamShapeFrame::ReadDataShapeDescr( wxCommandEvent& event )
|
|||
|
||||
FILTER_READER reader( fileReader );
|
||||
|
||||
bufsize = 100;
|
||||
ptbuf = PolyEdges = (double*) MyZMalloc( bufsize * 2 * sizeof(double) );
|
||||
|
||||
SetLocaleTo_C_standard();
|
||||
|
||||
while( reader.ReadLine() )
|
||||
|
@ -926,20 +898,8 @@ void WinEDA_SetParamShapeFrame::ReadDataShapeDescr( wxCommandEvent& event )
|
|||
if( strnicmp( param1, "$ENDCOORD", 8 ) == 0 )
|
||||
break;
|
||||
|
||||
if( bufsize <= PolyEdgesCount )
|
||||
{
|
||||
int index = ptbuf - PolyEdges;
|
||||
bufsize *= 2;
|
||||
ptbuf = PolyEdges = (double*) realloc( PolyEdges, bufsize * 2 *
|
||||
sizeof(double) );
|
||||
ptbuf += index;
|
||||
}
|
||||
|
||||
*ptbuf = atof( param1 );
|
||||
ptbuf++;
|
||||
*ptbuf = atof( param2 );
|
||||
ptbuf++;
|
||||
PolyEdgesCount++;
|
||||
PolyEdges.push_back( atof( param1 ) );
|
||||
PolyEdges.push_back( atof( param2 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -954,12 +914,6 @@ void WinEDA_SetParamShapeFrame::ReadDataShapeDescr( wxCommandEvent& event )
|
|||
}
|
||||
}
|
||||
|
||||
if( PolyEdgesCount == 0 )
|
||||
{
|
||||
free( PolyEdges );
|
||||
PolyEdges = NULL;
|
||||
}
|
||||
|
||||
SetLocaleTo_Default(); // revert to the current locale
|
||||
|
||||
ShapeScaleX *= unitconv;
|
||||
|
@ -988,12 +942,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
|
|||
|
||||
if( ok != 1 )
|
||||
{
|
||||
if( PolyEdges )
|
||||
free( PolyEdges );
|
||||
|
||||
PolyEdges = NULL;
|
||||
PolyEdgesCount = 0;
|
||||
return NULL;
|
||||
PolyEdges.clear();
|
||||
}
|
||||
|
||||
if( PolyShapeType == 2 ) // mirrored
|
||||
|
@ -1008,7 +957,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if( PolyEdgesCount == 0 )
|
||||
if( PolyEdges.size() == 0 )
|
||||
{
|
||||
DisplayError( this, _( "Shape has no points!" ) );
|
||||
return NULL;
|
||||
|
@ -1032,21 +981,20 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
|
|||
|
||||
edge->m_Shape = S_POLYGON;
|
||||
edge->SetLayer( LAYER_N_FRONT );
|
||||
npoints = PolyEdgesCount;
|
||||
npoints = PolyEdges.size();
|
||||
|
||||
std::vector<wxPoint> polyPoints = edge->GetPolyPoints();
|
||||
polyPoints.reserve( 2 * PolyEdgesCount + 2 );
|
||||
polyPoints.reserve( 2 * PolyEdges.size() + 2 );
|
||||
|
||||
// Init start point coord:
|
||||
polyPoints.push_back( wxPoint( pad1->m_Pos0.x, 0 ) );
|
||||
|
||||
double* dptr = PolyEdges;
|
||||
wxPoint first_coordinate, last_coordinate;
|
||||
|
||||
for( ii = 0; ii < npoints; ii++ ) // Copy points
|
||||
for( ii = 0; ii < PolyEdges.size(); ii++ ) // Copy points
|
||||
{
|
||||
last_coordinate.x = wxRound( *dptr++ *ShapeScaleX ) + pad1->m_Pos0.x;
|
||||
last_coordinate.y = -wxRound( *dptr++ *ShapeScaleY );
|
||||
last_coordinate.x = wxRound( PolyEdges[ii] * ShapeScaleX ) + pad1->m_Pos0.x;
|
||||
last_coordinate.y = -wxRound( PolyEdges[ii] * ShapeScaleY );
|
||||
polyPoints.push_back( last_coordinate );
|
||||
}
|
||||
|
||||
|
@ -1083,10 +1031,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
|
|||
break;
|
||||
}
|
||||
|
||||
free( PolyEdges );
|
||||
PolyEdgesCount = 0;
|
||||
PolyEdges = NULL;
|
||||
|
||||
PolyEdges.clear();
|
||||
Module->CalculateBoundingBox();
|
||||
GetBoard()->m_Status_Pcb = 0;
|
||||
OnModify();
|
||||
|
@ -1094,10 +1039,6 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* Module )
|
||||
{
|
||||
int gap_size, oX;
|
||||
|
|
|
@ -1,3 +1,28 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file queue.cpp
|
||||
*/
|
||||
|
@ -41,7 +66,8 @@ void FreeQueue()
|
|||
|
||||
while( (p = Save) != NULL )
|
||||
{
|
||||
Save = p->Next; MyFree( p );
|
||||
Save = p->Next;
|
||||
delete p;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,7 +129,7 @@ int SetQueue( int r, int c, int side, int d, int a, int r2, int c2 )
|
|||
{
|
||||
Save = p->Next;
|
||||
}
|
||||
else if( ( p = (struct PcbQueue*) MyMalloc( sizeof(PcbQueue) ) ) == NULL )
|
||||
else if( ( p = (PcbQueue*) operator new( sizeof( PcbQueue ), std::nothrow ) ) == NULL )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -871,25 +871,21 @@ void PCB_BASE_FRAME::BuildAirWiresTargetsList( BOARD_CONNECTED_ITEM* aItemRef,
|
|||
}
|
||||
|
||||
|
||||
/* Function TraceAirWiresToTargets
|
||||
* This functions shows airwires to nearest connecting points (pads)
|
||||
* from the current new track end during track creation
|
||||
*/
|
||||
void PCB_BASE_FRAME::TraceAirWiresToTargets( wxDC* DC )
|
||||
void PCB_BASE_FRAME::TraceAirWiresToTargets( wxDC* aDC )
|
||||
{
|
||||
if( DC == NULL )
|
||||
if( aDC == NULL )
|
||||
return;
|
||||
|
||||
if( s_TargetsLocations.size() == 0 )
|
||||
return;
|
||||
|
||||
GRSetDrawMode( DC, GR_XOR );
|
||||
GRSetDrawMode( aDC, GR_XOR );
|
||||
|
||||
for( int ii = 0; ii < (int) s_TargetsLocations.size(); ii++ )
|
||||
{
|
||||
if( ii >= g_MaxLinksShowed )
|
||||
break;
|
||||
|
||||
GRLine( &DrawPanel->m_ClipBox, DC, s_CursorPos, s_TargetsLocations[ii], 0, YELLOW );
|
||||
GRLine( &DrawPanel->m_ClipBox, aDC, s_CursorPos, s_TargetsLocations[ii], 0, YELLOW );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,28 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file work.cpp
|
||||
* @brief Automatic routing routines
|
||||
|
@ -47,7 +72,7 @@ void InitWork()
|
|||
while( ( ptr = Head ) != NULL )
|
||||
{
|
||||
Head = ptr->Next;
|
||||
MyFree( ptr );
|
||||
delete ptr;
|
||||
}
|
||||
|
||||
Tail = Current = NULL;
|
||||
|
@ -78,7 +103,7 @@ int SetWork( int r1,
|
|||
{
|
||||
CWORK* p;
|
||||
|
||||
if( ( p = (CWORK*) MyMalloc( sizeof(CWORK) ) ) != NULL )
|
||||
if( ( p = (CWORK*) operator new( sizeof(CWORK), std::nothrow ) ) != NULL )
|
||||
{
|
||||
p->FromRow = r1;
|
||||
p->FromCol = c1;
|
||||
|
@ -153,7 +178,9 @@ void SortWork()
|
|||
p->Next = NULL;
|
||||
|
||||
if( (r = q0) == NULL ) /* empty list? */
|
||||
{
|
||||
q0 = p;
|
||||
}
|
||||
else /* attach at end */
|
||||
{
|
||||
while( r->Next ) /* search for end */
|
||||
|
|
Loading…
Reference in New Issue