2011-09-20 15:07:52 +00:00
|
|
|
/**
|
|
|
|
* @file class_dimension.cpp
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
2011-09-23 13:57:12 +00:00
|
|
|
#include "macros.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "gr_basic.h"
|
2011-09-23 13:57:12 +00:00
|
|
|
#include "pcbcommon.h"
|
2007-08-08 20:51:08 +00:00
|
|
|
#include "trigo.h"
|
2007-08-20 19:33:15 +00:00
|
|
|
#include "wxstruct.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
2010-01-29 20:36:12 +00:00
|
|
|
#include "colors_selection.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "kicad_string.h"
|
2009-08-01 19:26:05 +00:00
|
|
|
#include "protos.h"
|
2011-01-14 17:43:30 +00:00
|
|
|
#include "richio.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
#include "class_board.h"
|
|
|
|
#include "class_pcb_text.h"
|
|
|
|
#include "class_dimension.h"
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
DIMENSION::DIMENSION( BOARD_ITEM* aParent ) :
|
2011-10-01 19:24:27 +00:00
|
|
|
BOARD_ITEM( aParent, PCB_DIMENSION_T )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-08 20:51:08 +00:00
|
|
|
m_Layer = DRAW_LAYER;
|
|
|
|
m_Width = 50;
|
|
|
|
m_Value = 0;
|
|
|
|
m_Shape = 0;
|
|
|
|
m_Unit = INCHES;
|
|
|
|
m_Text = new TEXTE_PCB( this );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
DIMENSION::~DIMENSION()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-08 20:51:08 +00:00
|
|
|
delete m_Text;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
void DIMENSION::SetText( const wxString& NewText )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-08 20:51:08 +00:00
|
|
|
m_Text->m_Text = NewText;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-14 15:42:44 +00:00
|
|
|
wxString DIMENSION::GetText( void ) const
|
2007-09-25 08:23:53 +00:00
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
return m_Text->m_Text;
|
2007-09-25 08:23:53 +00:00
|
|
|
}
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
void DIMENSION::SetLayer( int aLayer )
|
2009-08-03 07:55:08 +00:00
|
|
|
{
|
|
|
|
m_Layer = aLayer;
|
|
|
|
m_Text->SetLayer( aLayer);
|
|
|
|
}
|
2007-09-25 08:23:53 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
void DIMENSION::Copy( DIMENSION* source )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-08 20:51:08 +00:00
|
|
|
m_Value = source->m_Value;
|
2007-08-23 04:28:46 +00:00
|
|
|
SetLayer( source->GetLayer() );
|
2007-08-08 20:51:08 +00:00
|
|
|
m_Width = source->m_Width;
|
|
|
|
m_Pos = source->m_Pos;
|
|
|
|
m_Shape = source->m_Shape;
|
|
|
|
m_Unit = source->m_Unit;
|
|
|
|
m_TimeStamp = GetTimeStamp();
|
|
|
|
m_Text->Copy( source->m_Text );
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
m_crossBarOx = source->m_crossBarOx;
|
|
|
|
m_crossBarOy = source->m_crossBarOy;
|
|
|
|
m_crossBarFx = source->m_crossBarFx;
|
|
|
|
m_crossBarFy = source->m_crossBarFy;
|
|
|
|
m_featureLineGOx = source->m_featureLineGOx;
|
|
|
|
m_featureLineGOy = source->m_featureLineGOy;
|
|
|
|
m_featureLineGFx = source->m_featureLineGFx;
|
|
|
|
m_featureLineGFy = source->m_featureLineGFy;
|
|
|
|
m_featureLineDOx = source->m_featureLineDOx;
|
|
|
|
m_featureLineDOy = source->m_featureLineDOy;
|
|
|
|
m_featureLineDFx = source->m_featureLineDFx;
|
|
|
|
m_featureLineDFy = source->m_featureLineDFy;
|
|
|
|
m_arrowD1Ox = source->m_arrowD1Ox;
|
|
|
|
m_arrowD1Oy = source->m_arrowD1Oy;
|
|
|
|
m_arrowD1Fx = source->m_arrowD1Fx;
|
|
|
|
m_arrowD1Fy = source->m_arrowD1Fy;
|
|
|
|
m_arrowD2Ox = source->m_arrowD2Ox;
|
|
|
|
m_arrowD2Oy = source->m_arrowD2Oy;
|
|
|
|
m_arrowD2Fx = source->m_arrowD2Fx;
|
|
|
|
m_arrowD2Fy = source->m_arrowD2Fy;
|
|
|
|
m_arrowG1Ox = source->m_arrowG1Ox;
|
|
|
|
m_arrowG1Oy = source->m_arrowG1Oy;
|
|
|
|
m_arrowG1Fx = source->m_arrowG1Fx;
|
|
|
|
m_arrowG1Fy = source->m_arrowG1Fy;
|
|
|
|
m_arrowG2Ox = source->m_arrowG2Ox;
|
|
|
|
m_arrowG2Oy = source->m_arrowG2Oy;
|
|
|
|
m_arrowG2Fx = source->m_arrowG2Fx;
|
|
|
|
m_arrowG2Fy = source->m_arrowG2Fy;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-14 17:43:30 +00:00
|
|
|
bool DIMENSION::ReadDimensionDescr( LINE_READER* aReader )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-01-14 17:43:30 +00:00
|
|
|
char* Line;
|
|
|
|
char Text[2048];
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2011-01-14 17:43:30 +00:00
|
|
|
while( aReader->ReadLine() )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2011-01-14 17:43:30 +00:00
|
|
|
Line = aReader->Line();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
if( strnicmp( Line, "$EndDIMENSION", 4 ) == 0 )
|
2011-09-07 19:41:04 +00:00
|
|
|
return true;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
|
|
|
if( Line[0] == 'V' )
|
|
|
|
{
|
|
|
|
sscanf( Line + 2, " %d", &m_Value );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( Line[0] == 'G' )
|
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
int layer;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
sscanf( Line + 2, " %d %d %lX", &m_Shape, &layer, &m_TimeStamp );
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
if( layer < FIRST_NO_COPPER_LAYER )
|
|
|
|
layer = FIRST_NO_COPPER_LAYER;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
if( layer > LAST_NO_COPPER_LAYER )
|
|
|
|
layer = LAST_NO_COPPER_LAYER;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
SetLayer( layer );
|
|
|
|
m_Text->SetLayer( layer );
|
2007-08-08 20:51:08 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( Line[0] == 'T' )
|
|
|
|
{
|
|
|
|
ReadDelimitedText( Text, Line + 2, sizeof(Text) );
|
2011-02-28 18:36:19 +00:00
|
|
|
m_Text->m_Text = FROM_UTF8( Text );
|
2007-08-08 20:51:08 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( Line[0] == 'P' )
|
|
|
|
{
|
2009-11-12 15:43:38 +00:00
|
|
|
int normal_display = 1;
|
2007-08-08 20:51:08 +00:00
|
|
|
sscanf( Line + 2, " %d %d %d %d %d %d %d",
|
|
|
|
&m_Text->m_Pos.x, &m_Text->m_Pos.y,
|
|
|
|
&m_Text->m_Size.x, &m_Text->m_Size.y,
|
2010-11-27 13:09:18 +00:00
|
|
|
&m_Text->m_Thickness, &m_Text->m_Orient,
|
2008-12-20 20:38:39 +00:00
|
|
|
&normal_display );
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
m_Text->m_Mirror = normal_display ? false : true;
|
2007-08-08 20:51:08 +00:00
|
|
|
m_Pos = m_Text->m_Pos;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( Line[0] == 'S' )
|
|
|
|
{
|
|
|
|
switch( Line[1] )
|
|
|
|
{
|
|
|
|
int Dummy;
|
|
|
|
|
|
|
|
case 'b':
|
|
|
|
sscanf( Line + 2, " %d %d %d %d %d %d",
|
|
|
|
&Dummy,
|
2011-09-20 15:07:52 +00:00
|
|
|
&m_crossBarOx, &m_crossBarOy,
|
|
|
|
&m_crossBarFx, &m_crossBarFy,
|
2007-08-08 20:51:08 +00:00
|
|
|
&m_Width );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'd':
|
|
|
|
sscanf( Line + 2, " %d %d %d %d %d %d",
|
|
|
|
&Dummy,
|
2011-09-20 15:07:52 +00:00
|
|
|
&m_featureLineDOx, &m_featureLineDOy,
|
|
|
|
&m_featureLineDFx, &m_featureLineDFy,
|
2007-08-08 20:51:08 +00:00
|
|
|
&Dummy );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'g':
|
|
|
|
sscanf( Line + 2, " %d %d %d %d %d %d",
|
|
|
|
&Dummy,
|
2011-09-20 15:07:52 +00:00
|
|
|
&m_featureLineGOx, &m_featureLineGOy,
|
|
|
|
&m_featureLineGFx, &m_featureLineGFy,
|
2007-08-08 20:51:08 +00:00
|
|
|
&Dummy );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '1':
|
|
|
|
sscanf( Line + 2, " %d %d %d %d %d %d",
|
|
|
|
&Dummy,
|
2011-09-20 15:07:52 +00:00
|
|
|
&m_arrowD1Ox, &m_arrowD1Oy,
|
|
|
|
&m_arrowD1Fx, &m_arrowD1Fy,
|
2007-08-08 20:51:08 +00:00
|
|
|
&Dummy );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '2':
|
|
|
|
sscanf( Line + 2, " %d %d %d %d %d %d",
|
|
|
|
&Dummy,
|
2011-09-20 15:07:52 +00:00
|
|
|
&m_arrowD2Ox, &m_arrowD2Oy,
|
|
|
|
&m_arrowD2Fx, &m_arrowD2Fy,
|
2007-08-08 20:51:08 +00:00
|
|
|
&Dummy );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '3':
|
|
|
|
sscanf( Line + 2, " %d %d %d %d %d %d\n",
|
|
|
|
&Dummy,
|
2011-09-20 15:07:52 +00:00
|
|
|
&m_arrowG1Ox, &m_arrowG1Oy,
|
|
|
|
&m_arrowG1Fx, &m_arrowG1Fy,
|
2007-08-08 20:51:08 +00:00
|
|
|
&Dummy );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '4':
|
|
|
|
sscanf( Line + 2, " %d %d %d %d %d %d",
|
|
|
|
&Dummy,
|
2011-09-20 15:07:52 +00:00
|
|
|
&m_arrowG2Ox, &m_arrowG2Oy,
|
|
|
|
&m_arrowG2Fx, &m_arrowG2Fy,
|
2007-08-08 20:51:08 +00:00
|
|
|
&Dummy );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
return false;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
void DIMENSION::Move(const wxPoint& offset)
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
m_Pos += offset;
|
|
|
|
m_Text->m_Pos += offset;
|
2011-09-20 15:07:52 +00:00
|
|
|
m_crossBarOx += offset.x;
|
|
|
|
m_crossBarOy += offset.y;
|
|
|
|
m_crossBarFx += offset.x;
|
|
|
|
m_crossBarFy += offset.y;
|
|
|
|
m_featureLineGOx += offset.x;
|
|
|
|
m_featureLineGOy += offset.y;
|
|
|
|
m_featureLineGFx += offset.x;
|
|
|
|
m_featureLineGFy += offset.y;
|
|
|
|
m_featureLineDOx += offset.x;
|
|
|
|
m_featureLineDOy += offset.y;
|
|
|
|
m_featureLineDFx += offset.x;
|
|
|
|
m_featureLineDFy += offset.y;
|
|
|
|
m_arrowG1Ox += offset.x;
|
|
|
|
m_arrowG1Oy += offset.y;
|
|
|
|
m_arrowG1Fx += offset.x;
|
|
|
|
m_arrowG1Fy += offset.y;
|
|
|
|
m_arrowG2Ox += offset.x;
|
|
|
|
m_arrowG2Oy += offset.y;
|
|
|
|
m_arrowG2Fx += offset.x;
|
|
|
|
m_arrowG2Fy += offset.y;
|
|
|
|
m_arrowD1Ox += offset.x;
|
|
|
|
m_arrowD1Oy += offset.y;
|
|
|
|
m_arrowD1Fx += offset.x;
|
|
|
|
m_arrowD1Fy += offset.y;
|
|
|
|
m_arrowD2Ox += offset.x;
|
|
|
|
m_arrowD2Oy += offset.y;
|
|
|
|
m_arrowD2Fx += offset.x;
|
|
|
|
m_arrowD2Fy += offset.y;
|
2008-01-06 12:43:57 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2010-12-29 17:47:32 +00:00
|
|
|
void DIMENSION::Rotate(const wxPoint& aRotCentre, int aAngle)
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
2010-12-29 17:47:32 +00:00
|
|
|
RotatePoint( &m_Pos, aRotCentre, aAngle );
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2010-12-29 17:47:32 +00:00
|
|
|
RotatePoint( &m_Text->m_Pos, aRotCentre, aAngle );
|
|
|
|
m_Text->m_Orient += aAngle;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
if( m_Text->m_Orient >= 3600 )
|
|
|
|
m_Text->m_Orient -= 3600;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
if( ( m_Text->m_Orient > 900 ) && ( m_Text->m_Orient <2700 ) )
|
2008-04-01 05:21:50 +00:00
|
|
|
m_Text->m_Orient -= 1800;
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
RotatePoint( &m_crossBarOx, &m_crossBarOy, aRotCentre.x, aRotCentre.y, aAngle );
|
|
|
|
RotatePoint( &m_crossBarFx, &m_crossBarFy, aRotCentre.x, aRotCentre.y, aAngle );
|
|
|
|
RotatePoint( &m_featureLineGOx, &m_featureLineGOy, aRotCentre.x, aRotCentre.y, aAngle );
|
|
|
|
RotatePoint( &m_featureLineGFx, &m_featureLineGFy, aRotCentre.x, aRotCentre.y, aAngle );
|
|
|
|
RotatePoint( &m_featureLineDOx, &m_featureLineDOy, aRotCentre.x, aRotCentre.y, aAngle );
|
|
|
|
RotatePoint( &m_featureLineDFx, &m_featureLineDFy, aRotCentre.x, aRotCentre.y, aAngle );
|
|
|
|
RotatePoint( &m_arrowG1Ox, &m_arrowG1Oy, aRotCentre.x, aRotCentre.y, aAngle );
|
|
|
|
RotatePoint( &m_arrowG1Fx, &m_arrowG1Fy, aRotCentre.x, aRotCentre.y, aAngle );
|
|
|
|
RotatePoint( &m_arrowG2Ox, &m_arrowG2Oy, aRotCentre.x, aRotCentre.y, aAngle );
|
|
|
|
RotatePoint( &m_arrowG2Fx, &m_arrowG2Fy, aRotCentre.x, aRotCentre.y, aAngle );
|
|
|
|
RotatePoint( &m_arrowD1Ox, &m_arrowD1Oy, aRotCentre.x, aRotCentre.y, aAngle );
|
|
|
|
RotatePoint( &m_arrowD1Fx, &m_arrowD1Fy, aRotCentre.x, aRotCentre.y, aAngle );
|
|
|
|
RotatePoint( &m_arrowD2Ox, &m_arrowD2Oy, aRotCentre.x, aRotCentre.y, aAngle );
|
|
|
|
RotatePoint( &m_arrowD2Fx, &m_arrowD2Fy, aRotCentre.x, aRotCentre.y, aAngle );
|
2008-01-06 12:43:57 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
void DIMENSION::Flip(const wxPoint& aCentre )
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
|
|
|
Mirror( aCentre );
|
|
|
|
SetLayer( ChangeSideNumLayer( GetLayer() ) );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
void DIMENSION::Mirror(const wxPoint& axis_pos)
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
|
|
|
#define INVERT( pos ) (pos) = axis_pos.y - ( (pos) - axis_pos.y )
|
|
|
|
#define INVERT_ANGLE( phi ) (phi) = -(phi)
|
2008-04-01 05:21:50 +00:00
|
|
|
INVERT( m_Pos.y );
|
|
|
|
INVERT( m_Text->m_Pos.y );
|
|
|
|
INVERT_ANGLE( m_Text->m_Orient );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
if( m_Text->m_Orient >= 3600 )
|
|
|
|
m_Text->m_Orient -= 3600;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
if( ( m_Text->m_Orient > 900 ) && ( m_Text->m_Orient < 2700 ) )
|
2008-04-01 05:21:50 +00:00
|
|
|
m_Text->m_Orient -= 1800;
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
INVERT( m_crossBarOy );
|
|
|
|
INVERT( m_crossBarFy );
|
|
|
|
INVERT( m_featureLineGOy );
|
|
|
|
INVERT( m_featureLineGFy );
|
|
|
|
INVERT( m_featureLineDOy );
|
|
|
|
INVERT( m_featureLineDFy );
|
|
|
|
INVERT( m_arrowG1Oy );
|
|
|
|
INVERT( m_arrowG1Fy );
|
|
|
|
INVERT( m_arrowG2Oy );
|
|
|
|
INVERT( m_arrowG2Fy );
|
|
|
|
INVERT( m_arrowD1Oy );
|
|
|
|
INVERT( m_arrowD1Fy );
|
|
|
|
INVERT( m_arrowD2Oy );
|
|
|
|
INVERT( m_arrowD2Fy );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2007-10-30 21:30:58 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
bool DIMENSION::Save( FILE* aFile ) const
|
2007-10-30 21:30:58 +00:00
|
|
|
{
|
|
|
|
bool rc = false;
|
2011-09-20 15:07:52 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
// note: COTATION was the previous name of DIMENSION
|
|
|
|
// this old keyword is used here for compatibility
|
|
|
|
const char keyWordLine[] = "$COTATION\n";
|
|
|
|
const char keyWordLineEnd[] = "$endCOTATION\n";
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2010-05-02 19:35:46 +00:00
|
|
|
if( fputs( keyWordLine, aFile ) == EOF )
|
2007-10-30 21:30:58 +00:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
fprintf( aFile, "Ge %d %d %lX\n", m_Shape, m_Layer, m_TimeStamp );
|
|
|
|
|
|
|
|
fprintf( aFile, "Va %d\n", m_Value );
|
|
|
|
|
|
|
|
if( !m_Text->m_Text.IsEmpty() )
|
2011-03-25 20:07:27 +00:00
|
|
|
fprintf( aFile, "Te %s\n", EscapedUTF8( m_Text->m_Text ).c_str() );
|
2007-10-30 21:30:58 +00:00
|
|
|
else
|
|
|
|
fprintf( aFile, "Te \"?\"\n" );
|
|
|
|
|
|
|
|
fprintf( aFile, "Po %d %d %d %d %d %d %d\n",
|
|
|
|
m_Text->m_Pos.x, m_Text->m_Pos.y,
|
|
|
|
m_Text->m_Size.x, m_Text->m_Size.y,
|
2010-11-27 13:09:18 +00:00
|
|
|
m_Text->m_Thickness, m_Text->m_Orient,
|
2008-12-20 20:38:39 +00:00
|
|
|
m_Text->m_Mirror ? 0 : 1 );
|
2007-10-30 21:30:58 +00:00
|
|
|
|
|
|
|
fprintf( aFile, "Sb %d %d %d %d %d %d\n", S_SEGMENT,
|
2011-09-20 15:07:52 +00:00
|
|
|
m_crossBarOx, m_crossBarOy,
|
|
|
|
m_crossBarFx, m_crossBarFy, m_Width );
|
2007-10-30 21:30:58 +00:00
|
|
|
|
|
|
|
fprintf( aFile, "Sd %d %d %d %d %d %d\n", S_SEGMENT,
|
2011-09-20 15:07:52 +00:00
|
|
|
m_featureLineDOx, m_featureLineDOy,
|
|
|
|
m_featureLineDFx, m_featureLineDFy, m_Width );
|
2007-10-30 21:30:58 +00:00
|
|
|
|
|
|
|
fprintf( aFile, "Sg %d %d %d %d %d %d\n", S_SEGMENT,
|
2011-09-20 15:07:52 +00:00
|
|
|
m_featureLineGOx, m_featureLineGOy,
|
|
|
|
m_featureLineGFx, m_featureLineGFy, m_Width );
|
2007-10-30 21:30:58 +00:00
|
|
|
|
|
|
|
fprintf( aFile, "S1 %d %d %d %d %d %d\n", S_SEGMENT,
|
2011-09-20 15:07:52 +00:00
|
|
|
m_arrowD1Ox, m_arrowD1Oy,
|
|
|
|
m_arrowD1Fx, m_arrowD1Fy, m_Width );
|
2007-10-30 21:30:58 +00:00
|
|
|
|
|
|
|
fprintf( aFile, "S2 %d %d %d %d %d %d\n", S_SEGMENT,
|
2011-09-20 15:07:52 +00:00
|
|
|
m_arrowD2Ox, m_arrowD2Oy,
|
|
|
|
m_arrowD2Fx, m_arrowD2Fy, m_Width );
|
2007-10-30 21:30:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
fprintf( aFile, "S3 %d %d %d %d %d %d\n", S_SEGMENT,
|
2011-09-20 15:07:52 +00:00
|
|
|
m_arrowG1Ox, m_arrowG1Oy,
|
|
|
|
m_arrowG1Fx, m_arrowG1Fy, m_Width );
|
2007-10-30 21:30:58 +00:00
|
|
|
|
|
|
|
fprintf( aFile, "S4 %d %d %d %d %d %d\n", S_SEGMENT,
|
2011-09-20 15:07:52 +00:00
|
|
|
m_arrowG2Ox, m_arrowG2Oy,
|
|
|
|
m_arrowG2Fx, m_arrowG2Fy, m_Width );
|
2007-10-30 21:30:58 +00:00
|
|
|
|
2010-05-02 19:35:46 +00:00
|
|
|
if( fputs( keyWordLineEnd, aFile ) == EOF )
|
2007-10-30 21:30:58 +00:00
|
|
|
goto out;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
rc = true;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
out:
|
|
|
|
return rc;
|
|
|
|
}
|
2008-04-01 05:21:50 +00:00
|
|
|
|
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
|
|
|
|
{
|
|
|
|
#define ARROW_SIZE 500 //size of arrows
|
|
|
|
int ii;
|
2011-09-20 15:07:52 +00:00
|
|
|
int mesure, deltax, deltay; /* value of the measure on X and Y axes */
|
|
|
|
int arrow_up_X = 0, arrow_up_Y = 0; /* coordinates of arrow line / */
|
|
|
|
int arrow_dw_X = 0, arrow_dw_Y = 0; /* coordinates of arrow line \ */
|
|
|
|
int hx, hy; /* dimension line interval */
|
2010-04-23 09:54:40 +00:00
|
|
|
float angle, angle_f;
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
/* Init layer : */
|
|
|
|
m_Text->SetLayer( GetLayer() );
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
/* calculate the size of the dimension (text + line above the text) */
|
2010-04-23 09:54:40 +00:00
|
|
|
ii = m_Text->m_Size.y +
|
2010-11-27 13:09:18 +00:00
|
|
|
m_Text->m_Thickness + (m_Width * 3);
|
2010-04-23 09:54:40 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
deltax = m_featureLineDOx - m_featureLineGOx;
|
|
|
|
deltay = m_featureLineDOy - m_featureLineGOy;
|
2010-04-23 09:54:40 +00:00
|
|
|
|
|
|
|
/* Calculate dimension value */
|
|
|
|
mesure = wxRound(hypot( (double) deltax, (double) deltay ) );
|
|
|
|
|
|
|
|
if( deltax || deltay )
|
|
|
|
angle = atan2( (double) deltay, (double) deltax );
|
|
|
|
else
|
|
|
|
angle = 0.0;
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
/* Calculation of parameters X and Y dimensions of the arrows and lines. */
|
2010-04-23 09:54:40 +00:00
|
|
|
hx = hy = ii;
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
/* Taking into account the slope of the side lines. */
|
2010-04-23 09:54:40 +00:00
|
|
|
if( mesure )
|
|
|
|
{
|
|
|
|
hx = (abs) ( (int) ( ( (double) deltay * hx ) / mesure ) );
|
|
|
|
hy = (abs) ( (int) ( ( (double) deltax * hy ) / mesure ) );
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
if( m_featureLineGOx > m_crossBarOx )
|
2010-04-23 09:54:40 +00:00
|
|
|
hx = -hx;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
if( m_featureLineGOx == m_crossBarOx )
|
2010-04-23 09:54:40 +00:00
|
|
|
hx = 0;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
if( m_featureLineGOy > m_crossBarOy )
|
2010-04-23 09:54:40 +00:00
|
|
|
hy = -hy;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
if( m_featureLineGOy == m_crossBarOy )
|
2010-04-23 09:54:40 +00:00
|
|
|
hy = 0;
|
|
|
|
|
|
|
|
angle_f = angle + (M_PI * 27.5 / 180);
|
2011-09-20 15:07:52 +00:00
|
|
|
arrow_up_X = (int) ( ARROW_SIZE * cos( angle_f ) );
|
|
|
|
arrow_up_Y = (int) ( ARROW_SIZE * sin( angle_f ) );
|
2010-04-23 09:54:40 +00:00
|
|
|
angle_f = angle - (M_PI * 27.5 / 180);
|
2011-09-20 15:07:52 +00:00
|
|
|
arrow_dw_X = (int) ( ARROW_SIZE * cos( angle_f ) );
|
|
|
|
arrow_dw_Y = (int) ( ARROW_SIZE * sin( angle_f ) );
|
2010-04-23 09:54:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
m_arrowG1Ox = m_crossBarOx;
|
|
|
|
m_arrowG1Oy = m_crossBarOy;
|
|
|
|
m_arrowG1Fx = m_crossBarOx + arrow_up_X;
|
|
|
|
m_arrowG1Fy = m_crossBarOy + arrow_up_Y;
|
2010-04-23 09:54:40 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
m_arrowG2Ox = m_crossBarOx;
|
|
|
|
m_arrowG2Oy = m_crossBarOy;
|
|
|
|
m_arrowG2Fx = m_crossBarOx + arrow_dw_X;
|
|
|
|
m_arrowG2Fy = m_crossBarOy + arrow_dw_Y;
|
2010-04-23 09:54:40 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
/* The right arrow is symmetrical to the left.
|
|
|
|
* / = -\ and \ = -/
|
2010-04-23 09:54:40 +00:00
|
|
|
*/
|
2011-09-20 15:07:52 +00:00
|
|
|
m_arrowD1Ox = m_crossBarFx;
|
|
|
|
m_arrowD1Oy = m_crossBarFy;
|
|
|
|
m_arrowD1Fx = m_crossBarFx - arrow_dw_X;
|
|
|
|
m_arrowD1Fy = m_crossBarFy - arrow_dw_Y;
|
2010-04-23 09:54:40 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
m_arrowD2Ox = m_crossBarFx;
|
|
|
|
m_arrowD2Oy = m_crossBarFy;
|
|
|
|
m_arrowD2Fx = m_crossBarFx - arrow_up_X;
|
|
|
|
m_arrowD2Fy = m_crossBarFy - arrow_up_Y;
|
2010-04-23 09:54:40 +00:00
|
|
|
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
m_featureLineGFx = m_crossBarOx + hx;
|
|
|
|
m_featureLineGFy = m_crossBarOy + hy;
|
2010-04-23 09:54:40 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
m_featureLineDFx = m_crossBarFx + hx;
|
|
|
|
m_featureLineDFy = m_crossBarFy + hy;
|
2010-04-23 09:54:40 +00:00
|
|
|
|
|
|
|
/* Calculate the better text position and orientation: */
|
2011-09-20 15:07:52 +00:00
|
|
|
m_Pos.x = m_Text->m_Pos.x = (m_crossBarFx + m_featureLineGFx) / 2;
|
|
|
|
m_Pos.y = m_Text->m_Pos.y = (m_crossBarFy + m_featureLineGFy) / 2;
|
2010-04-23 09:54:40 +00:00
|
|
|
|
|
|
|
m_Text->m_Orient = -(int) (angle * 1800 / M_PI);
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
if( m_Text->m_Orient < 0 )
|
|
|
|
m_Text->m_Orient += 3600;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
if( m_Text->m_Orient >= 3600 )
|
|
|
|
m_Text->m_Orient -= 3600;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
if( (m_Text->m_Orient > 900) && (m_Text->m_Orient <2700) )
|
|
|
|
m_Text->m_Orient -= 1800;
|
|
|
|
|
|
|
|
if( !aDoNotChangeText )
|
|
|
|
{
|
|
|
|
m_Value = mesure;
|
|
|
|
valeur_param( m_Value, msg );
|
|
|
|
SetText( msg );
|
|
|
|
}
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void DIMENSION::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int mode_color, const wxPoint& offset )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-08 20:51:08 +00:00
|
|
|
int ox, oy, typeaff, width, gcolor;
|
|
|
|
|
2010-11-11 21:46:55 +00:00
|
|
|
ox = -offset.x;
|
|
|
|
oy = -offset.y;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
m_Text->Draw( panel, DC, mode_color, offset );
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
BOARD * brd = GetBoard( );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
if( brd->IsLayerVisible( m_Layer ) == false )
|
2007-08-08 20:51:08 +00:00
|
|
|
return;
|
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
gcolor = brd->GetLayerColor(m_Layer);
|
2009-10-10 01:25:53 +00:00
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
GRSetDrawMode( DC, mode_color );
|
|
|
|
typeaff = DisplayOpt.DisplayDrawItems;
|
|
|
|
width = m_Width;
|
2009-01-29 14:26:20 +00:00
|
|
|
|
2010-02-08 18:15:42 +00:00
|
|
|
if( DC->LogicalToDeviceXRel( width ) < 2 )
|
2007-08-08 20:51:08 +00:00
|
|
|
typeaff = FILAIRE;
|
|
|
|
|
|
|
|
switch( typeaff )
|
|
|
|
{
|
|
|
|
case FILAIRE:
|
|
|
|
width = 0;
|
|
|
|
|
|
|
|
case FILLED:
|
|
|
|
GRLine( &panel->m_ClipBox, DC,
|
2011-09-20 15:07:52 +00:00
|
|
|
m_crossBarOx - ox, m_crossBarOy - oy,
|
|
|
|
m_crossBarFx - ox, m_crossBarFy - oy, width, gcolor );
|
2007-08-08 20:51:08 +00:00
|
|
|
GRLine( &panel->m_ClipBox, DC,
|
2011-09-20 15:07:52 +00:00
|
|
|
m_featureLineGOx - ox, m_featureLineGOy - oy,
|
|
|
|
m_featureLineGFx - ox, m_featureLineGFy - oy, width, gcolor );
|
2007-08-08 20:51:08 +00:00
|
|
|
GRLine( &panel->m_ClipBox, DC,
|
2011-09-20 15:07:52 +00:00
|
|
|
m_featureLineDOx - ox, m_featureLineDOy - oy,
|
|
|
|
m_featureLineDFx - ox, m_featureLineDFy - oy, width, gcolor );
|
2007-08-08 20:51:08 +00:00
|
|
|
GRLine( &panel->m_ClipBox, DC,
|
2011-09-20 15:07:52 +00:00
|
|
|
m_arrowD1Ox - ox, m_arrowD1Oy - oy,
|
|
|
|
m_arrowD1Fx - ox, m_arrowD1Fy - oy, width, gcolor );
|
2007-08-08 20:51:08 +00:00
|
|
|
GRLine( &panel->m_ClipBox, DC,
|
2011-09-20 15:07:52 +00:00
|
|
|
m_arrowD2Ox - ox, m_arrowD2Oy - oy,
|
|
|
|
m_arrowD2Fx - ox, m_arrowD2Fy - oy, width, gcolor );
|
2007-08-08 20:51:08 +00:00
|
|
|
GRLine( &panel->m_ClipBox, DC,
|
2011-09-20 15:07:52 +00:00
|
|
|
m_arrowG1Ox - ox, m_arrowG1Oy - oy,
|
|
|
|
m_arrowG1Fx - ox, m_arrowG1Fy - oy, width, gcolor );
|
2007-08-08 20:51:08 +00:00
|
|
|
GRLine( &panel->m_ClipBox, DC,
|
2011-09-20 15:07:52 +00:00
|
|
|
m_arrowG2Ox - ox, m_arrowG2Oy - oy,
|
|
|
|
m_arrowG2Fx - ox, m_arrowG2Fy - oy, width, gcolor );
|
2007-08-08 20:51:08 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SKETCH:
|
|
|
|
GRCSegm( &panel->m_ClipBox, DC,
|
2011-09-20 15:07:52 +00:00
|
|
|
m_crossBarOx - ox, m_crossBarOy - oy,
|
|
|
|
m_crossBarFx - ox, m_crossBarFy - oy,
|
2007-08-08 20:51:08 +00:00
|
|
|
width, gcolor );
|
|
|
|
GRCSegm( &panel->m_ClipBox, DC,
|
2011-09-20 15:07:52 +00:00
|
|
|
m_featureLineGOx - ox, m_featureLineGOy - oy,
|
|
|
|
m_featureLineGFx - ox, m_featureLineGFy - oy,
|
2007-08-08 20:51:08 +00:00
|
|
|
width, gcolor );
|
|
|
|
GRCSegm( &panel->m_ClipBox, DC,
|
2011-09-20 15:07:52 +00:00
|
|
|
m_featureLineDOx - ox, m_featureLineDOy - oy,
|
|
|
|
m_featureLineDFx - ox, m_featureLineDFy - oy,
|
2007-08-08 20:51:08 +00:00
|
|
|
width, gcolor );
|
|
|
|
GRCSegm( &panel->m_ClipBox, DC,
|
2011-09-20 15:07:52 +00:00
|
|
|
m_arrowD1Ox - ox, m_arrowD1Oy - oy,
|
|
|
|
m_arrowD1Fx - ox, m_arrowD1Fy - oy,
|
2007-08-08 20:51:08 +00:00
|
|
|
width, gcolor );
|
|
|
|
GRCSegm( &panel->m_ClipBox, DC,
|
2011-09-20 15:07:52 +00:00
|
|
|
m_arrowD2Ox - ox, m_arrowD2Oy - oy,
|
|
|
|
m_arrowD2Fx - ox, m_arrowD2Fy - oy,
|
2007-08-08 20:51:08 +00:00
|
|
|
width, gcolor );
|
|
|
|
GRCSegm( &panel->m_ClipBox, DC,
|
2011-09-20 15:07:52 +00:00
|
|
|
m_arrowG1Ox - ox, m_arrowG1Oy - oy,
|
|
|
|
m_arrowG1Fx - ox, m_arrowG1Fy - oy,
|
2007-08-08 20:51:08 +00:00
|
|
|
width, gcolor );
|
|
|
|
GRCSegm( &panel->m_ClipBox, DC,
|
2011-09-20 15:07:52 +00:00
|
|
|
m_arrowG2Ox - ox, m_arrowG2Oy - oy,
|
|
|
|
m_arrowG2Fx - ox, m_arrowG2Fy - oy,
|
2007-08-08 20:51:08 +00:00
|
|
|
width, gcolor );
|
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
// see class_cotation.h
|
2011-01-21 19:30:59 +00:00
|
|
|
void DIMENSION::DisplayInfo( EDA_DRAW_FRAME* frame )
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
2010-04-23 09:54:40 +00:00
|
|
|
// for now, display only the text within the DIMENSION using class TEXTE_PCB.
|
2009-04-17 08:51:02 +00:00
|
|
|
m_Text->DisplayInfo( frame );
|
2007-08-20 19:33:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
bool DIMENSION::HitTest( const wxPoint& aPoint )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2011-09-20 15:07:52 +00:00
|
|
|
int ux0, uy0;
|
|
|
|
int dx, dy, spot_cX, spot_cY;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
if( m_Text && m_Text->TextHitTest( aPoint ) )
|
|
|
|
return true;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
/* Locate SEGMENTS? */
|
2011-09-20 15:07:52 +00:00
|
|
|
ux0 = m_crossBarOx;
|
|
|
|
uy0 = m_crossBarOy;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
/* Recalculate coordinates with ux0, uy0 = origin. */
|
2011-09-20 15:07:52 +00:00
|
|
|
dx = m_crossBarFx - ux0;
|
|
|
|
dy = m_crossBarFy - uy0;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
spot_cX = aPoint.x - ux0;
|
|
|
|
spot_cY = aPoint.y - uy0;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
|
|
|
if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) )
|
|
|
|
return true;
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
ux0 = m_featureLineGOx;
|
|
|
|
uy0 = m_featureLineGOy;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
dx = m_featureLineGFx - ux0;
|
|
|
|
dy = m_featureLineGFy - uy0;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
spot_cX = aPoint.x - ux0;
|
|
|
|
spot_cY = aPoint.y - uy0;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
|
|
|
if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) )
|
|
|
|
return true;
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
ux0 = m_featureLineDOx;
|
|
|
|
uy0 = m_featureLineDOy;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
dx = m_featureLineDFx - ux0;
|
|
|
|
dy = m_featureLineDFy - uy0;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
spot_cX = aPoint.x - ux0;
|
|
|
|
spot_cY = aPoint.y - uy0;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
|
|
|
if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) )
|
|
|
|
return true;
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
ux0 = m_arrowD1Ox;
|
|
|
|
uy0 = m_arrowD1Oy;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
dx = m_arrowD1Fx - ux0;
|
|
|
|
dy = m_arrowD1Fy - uy0;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
spot_cX = aPoint.x - ux0;
|
|
|
|
spot_cY = aPoint.y - uy0;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
|
|
|
if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) )
|
|
|
|
return true;
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
ux0 = m_arrowD2Ox;
|
|
|
|
uy0 = m_arrowD2Oy;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
dx = m_arrowD2Fx - ux0;
|
|
|
|
dy = m_arrowD2Fy - uy0;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
spot_cX = aPoint.x - ux0;
|
|
|
|
spot_cY = aPoint.y - uy0;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
|
|
|
if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) )
|
|
|
|
return true;
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
ux0 = m_arrowG1Ox;
|
|
|
|
uy0 = m_arrowG1Oy;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
dx = m_arrowG1Fx - ux0;
|
|
|
|
dy = m_arrowG1Fy - uy0;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
spot_cX = aPoint.x - ux0;
|
|
|
|
spot_cY = aPoint.y - uy0;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
|
|
|
if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) )
|
|
|
|
return true;
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
ux0 = m_arrowG2Ox;
|
|
|
|
uy0 = m_arrowG2Oy;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
dx = m_arrowG2Fx - ux0;
|
|
|
|
dy = m_arrowG2Fy - uy0;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
spot_cX = aPoint.x - ux0;
|
|
|
|
spot_cY = aPoint.y - uy0;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
|
|
|
if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
bool DIMENSION::HitTest( EDA_RECT& refArea )
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
2010-12-20 17:44:25 +00:00
|
|
|
if( refArea.Contains( m_Pos ) )
|
2008-04-01 05:21:50 +00:00
|
|
|
return true;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
return false;
|
2008-01-06 12:43:57 +00:00
|
|
|
}
|
2011-02-25 16:23:24 +00:00
|
|
|
|
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT DIMENSION::GetBoundingBox() const
|
2011-02-25 16:23:24 +00:00
|
|
|
{
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT bBox;
|
2011-02-25 16:23:24 +00:00
|
|
|
int xmin, xmax, ymin, ymax;
|
|
|
|
|
|
|
|
bBox = m_Text->GetTextBox( -1 );
|
|
|
|
xmin = bBox.GetX();
|
|
|
|
xmax = bBox.GetRight();
|
|
|
|
ymin = bBox.GetY();
|
|
|
|
ymax = bBox.GetBottom();
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
xmin = MIN( xmin, m_crossBarOx );
|
|
|
|
xmin = MIN( xmin, m_crossBarFx );
|
|
|
|
ymin = MIN( ymin, m_crossBarOy );
|
|
|
|
ymin = MIN( ymin, m_crossBarFy );
|
|
|
|
xmax = MAX( xmax, m_crossBarOx );
|
|
|
|
xmax = MAX( xmax, m_crossBarFx );
|
|
|
|
ymax = MAX( ymax, m_crossBarOy );
|
|
|
|
ymax = MAX( ymax, m_crossBarFy );
|
|
|
|
|
|
|
|
xmin = MIN( xmin, m_featureLineGOx );
|
|
|
|
xmin = MIN( xmin, m_featureLineGFx );
|
|
|
|
ymin = MIN( ymin, m_featureLineGOy );
|
|
|
|
ymin = MIN( ymin, m_featureLineGFy );
|
|
|
|
xmax = MAX( xmax, m_featureLineGOx );
|
|
|
|
xmax = MAX( xmax, m_featureLineGFx );
|
|
|
|
ymax = MAX( ymax, m_featureLineGOy );
|
|
|
|
ymax = MAX( ymax, m_featureLineGFy );
|
2011-02-25 16:23:24 +00:00
|
|
|
|
|
|
|
bBox.SetX( xmin );
|
|
|
|
bBox.SetY( ymin );
|
|
|
|
bBox.SetWidth( xmax - xmin + 1 );
|
|
|
|
bBox.SetHeight( ymax - ymin + 1 );
|
|
|
|
|
|
|
|
bBox.Normalize();
|
|
|
|
|
|
|
|
return bBox;
|
|
|
|
}
|
2011-07-14 15:42:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
wxString DIMENSION::GetSelectMenuText() const
|
|
|
|
{
|
|
|
|
wxString text;
|
|
|
|
|
|
|
|
text << _( "Dimension" ) << wxT( " \"" ) << GetText() << wxT( "\"" );
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|