Commit 535a4d1f authored by charras's avatar charras

Eeschema: code cleanup

parent b4bd181d
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -14,6 +14,7 @@ set(EESCHEMA_SRCS ...@@ -14,6 +14,7 @@ set(EESCHEMA_SRCS
build_BOM.cpp build_BOM.cpp
busentry.cpp busentry.cpp
bus-wire-junction.cpp bus-wire-junction.cpp
class_BodyItem_Text.cpp
class_drawsheet.cpp class_drawsheet.cpp
class_drawsheetpath.cpp class_drawsheetpath.cpp
class_hierarchical_PIN_sheet.cpp class_hierarchical_PIN_sheet.cpp
......
...@@ -254,27 +254,53 @@ void LibDrawField::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, ...@@ -254,27 +254,53 @@ void LibDrawField::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
*/ */
bool LibDrawField::HitTest( const wxPoint& refPos ) bool LibDrawField::HitTest( const wxPoint& refPos )
{ {
// Reference designator text has one additional character (displays U?) return HitTest( refPos, 0, DefaultTransformMatrix );
}
/** Function HitTest
* @return true if the point aPosRef is near this object
* @param aPosRef = a wxPoint to test
* @param aThreshold = unused here (TextHitTest calculates its threshold )
* @param aTransMat = the transform matrix
*/
bool LibDrawField::HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] )
{
int extraCharCount = 0;
// Reference designator text has one or 2 additional character (displays U? or U?A)
if( m_FieldId == REFERENCE ) if( m_FieldId == REFERENCE )
{
extraCharCount++;
m_Text.Append('?'); m_Text.Append('?');
// if using TextHitTest() remember this function uses top to bottom y axis convention EDA_LibComponentStruct* parent = (EDA_LibComponentStruct*)m_Parent;
// and for lib items we are using bottom to top convention if ( parent && ( parent->m_UnitCount > 1 ) )
// so for non center Y justification we use a trick. {
GRTextVertJustifyType vJustify = m_VJustify; m_Text.Append('A');
if ( m_VJustify == GR_TEXT_VJUSTIFY_TOP ) extraCharCount++;
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; }
else if ( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM ) }
m_VJustify = GR_TEXT_VJUSTIFY_TOP;
bool hit = TextHitTest(refPos);
m_VJustify = vJustify;
if( m_FieldId == REFERENCE ) wxPoint physicalpos = TransformCoordinate( aTransMat, m_Pos );
wxPoint tmp = m_Pos;
m_Pos = physicalpos;
/* The text orientation may need to be flipped if the
* transformation matrix causes xy axes to be flipped.
* this simple algo works only for schematic matrix (rot 90 or/and mirror)
*/
int t1 = ( aTransMat[0][0] != 0 ) ^ ( m_Orient != 0 );
int orient = t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT;
EXCHG( m_Orient, orient );
bool hit = TextHitTest(aPosRef);
EXCHG( m_Orient, orient );
m_Pos = tmp;
while( extraCharCount-- )
m_Text.RemoveLast( ); m_Text.RemoveLast( );
return hit; return hit;
} }
// Creation et Duplication d'un field // Creation et Duplication d'un field
LibDrawField* LibDrawField::GenCopy() LibDrawField* LibDrawField::GenCopy()
{ {
......
...@@ -74,6 +74,14 @@ public: ...@@ -74,6 +74,14 @@ public:
*/ */
bool HitTest( const wxPoint& refPos ); bool HitTest( const wxPoint& refPos );
/** Function HitTest
* @return true if the point aPosRef is near this object
* @param aPosRef = a wxPoint to test
* @param aThreshold = max distance to this object (usually the half thickness of a line)
* @param aTransMat = the transform matrix
*/
virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] );
void operator=( const LibDrawField& field ) void operator=( const LibDrawField& field )
{ {
m_FieldId = field.m_FieldId; m_FieldId = field.m_FieldId;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "trigo.h"
#include "common.h" #include "common.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "drawtxt.h" #include "drawtxt.h"
...@@ -14,6 +15,20 @@ ...@@ -14,6 +15,20 @@
#include "plot_common.h" #include "plot_common.h"
#include "protos.h" #include "protos.h"
const wxChar* MsgPinElectricType[] =
{
wxT( "input" ),
wxT( "output" ),
wxT( "BiDi" ),
wxT( "3state" ),
wxT( "passive" ),
wxT( "unspc" ),
wxT( "power_in" ),
wxT( "power_out" ),
wxT( "openCol" ),
wxT( "openEm" ),
wxT( "?????" )
};
LibDrawPin::LibDrawPin() : LibEDA_BaseStruct( COMPONENT_PIN_DRAW_TYPE ) LibDrawPin::LibDrawPin() : LibEDA_BaseStruct( COMPONENT_PIN_DRAW_TYPE )
{ {
...@@ -27,8 +42,42 @@ LibDrawPin::LibDrawPin() : LibEDA_BaseStruct( COMPONENT_PIN_DRAW_TYPE ) ...@@ -27,8 +42,42 @@ LibDrawPin::LibDrawPin() : LibEDA_BaseStruct( COMPONENT_PIN_DRAW_TYPE )
m_PinNameSize = 50; /* Default size for pin name and num */ m_PinNameSize = 50; /* Default size for pin name and num */
m_Width = 0; m_Width = 0;
m_typeName = _( "Pin" ); m_typeName = _( "Pin" );
m_PinNumShapeOpt = 0;
m_PinNameShapeOpt = 0;
m_PinNumPositionOpt = 0;
m_PinNamePositionOpt = 0;
}
// m_PinNumWidth = m_PinNameWidth = 0; // Unused /**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param aRefPos A wxPoint to test
* @return bool - true if a hit, else false
*/
bool LibDrawPin::HitTest( const wxPoint& aRefPos )
{
int mindist = m_Width ? m_Width / 2 : g_DrawDefaultLineThickness / 2;
// Have a minimal tolerance for hit test
if( mindist < 3 )
mindist = 3; // = 3 mils
return HitTest( aRefPos, mindist, DefaultTransformMatrix );
}
/** Function HitTest
* @return true if the point aPosRef is near a pin
* @param aRefPos = a wxPoint to test
* @param aThreshold = max distance to a segment
* @param aTransMat = the transform matrix
*/
bool LibDrawPin::HitTest( wxPoint aRefPos, int aThreshold, const int aTransMat[2][2] )
{
wxPoint pinPos = TransformCoordinate( aTransMat, m_Pos );
wxPoint pinEnd = TransformCoordinate( aTransMat, ReturnPinEndPoint() );
return TestSegmentHit( aRefPos, pinPos, pinEnd, aThreshold );
} }
...@@ -461,6 +510,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, ...@@ -461,6 +510,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
wxSize PinNumSize( m_PinNumSize, m_PinNumSize ); wxSize PinNumSize( m_PinNumSize, m_PinNumSize );
int nameLineWidth = g_DrawDefaultLineThickness; int nameLineWidth = g_DrawDefaultLineThickness;
nameLineWidth = Clamp_Text_PenSize( nameLineWidth, m_PinNameSize, false ); nameLineWidth = Clamp_Text_PenSize( nameLineWidth, m_PinNameSize, false );
int numLineWidth = g_DrawDefaultLineThickness; int numLineWidth = g_DrawDefaultLineThickness;
numLineWidth = Clamp_Text_PenSize( numLineWidth, m_PinNumSize, false ); numLineWidth = Clamp_Text_PenSize( numLineWidth, m_PinNumSize, false );
...@@ -561,7 +611,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, ...@@ -561,7 +611,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
TEXT_ORIENT_VERT, PinNumSize, TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth,
false, false); false, false );
} }
else /* PIN_UP */ else /* PIN_UP */
{ {
...@@ -582,7 +632,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, ...@@ -582,7 +632,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
TEXT_ORIENT_VERT, PinNumSize, TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth,
false, false); false, false );
} }
} }
} }
...@@ -611,7 +661,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, ...@@ -611,7 +661,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
TEXT_ORIENT_HORIZ, PinNumSize, TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP, numLineWidth, GR_TEXT_VJUSTIFY_TOP, numLineWidth,
false, false); false, false );
} }
} }
else /* Its a vertical line. */ else /* Its a vertical line. */
...@@ -643,6 +693,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, ...@@ -643,6 +693,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
} }
} }
/***************************************************************************** /*****************************************************************************
* Plot pin number and pin text info, given the pin line coordinates. * * Plot pin number and pin text info, given the pin line coordinates. *
* Same as DrawPinTexts((), but output is the plotter * Same as DrawPinTexts((), but output is the plotter
...@@ -653,11 +704,11 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, ...@@ -653,11 +704,11 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
* the opposite direction to x2,y2), otherwise all is drawn outside. * * the opposite direction to x2,y2), otherwise all is drawn outside. *
*****************************************************************************/ *****************************************************************************/
void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
int orient, int orient,
int TextInside, int TextInside,
bool DrawPinNum, bool DrawPinNum,
bool DrawPinName, bool DrawPinName,
int aWidth ) int aWidth )
{ {
int x, y, x1, y1; int x, y, x1, y1;
wxString StringPinNum; wxString StringPinNum;
...@@ -956,19 +1007,23 @@ LibDrawPin* LibDrawPin::GenCopy() ...@@ -956,19 +1007,23 @@ LibDrawPin* LibDrawPin::GenCopy()
{ {
LibDrawPin* newpin = new LibDrawPin(); LibDrawPin* newpin = new LibDrawPin();
newpin->m_Pos = m_Pos; newpin->m_Pos = m_Pos;
newpin->m_PinLen = m_PinLen; newpin->m_PinLen = m_PinLen;
newpin->m_Orient = m_Orient; newpin->m_Orient = m_Orient;
newpin->m_PinShape = m_PinShape; newpin->m_PinShape = m_PinShape;
newpin->m_PinType = m_PinType; newpin->m_PinType = m_PinType;
newpin->m_Attributs = m_Attributs; newpin->m_Attributs = m_Attributs;
newpin->m_PinNum = m_PinNum; newpin->m_PinNum = m_PinNum;
newpin->m_PinNumSize = m_PinNumSize; newpin->m_PinNumSize = m_PinNumSize;
newpin->m_PinNameSize = m_PinNameSize; newpin->m_PinNameSize = m_PinNameSize;
newpin->m_Unit = m_Unit; newpin->m_PinNumShapeOpt = m_PinNumShapeOpt;
newpin->m_Convert = m_Convert; newpin->m_PinNameShapeOpt = m_PinNameShapeOpt;
newpin->m_Flags = m_Flags; newpin->m_PinNumPositionOpt = m_PinNumPositionOpt;
newpin->m_Width = m_Width; newpin->m_PinNamePositionOpt = m_PinNamePositionOpt;
newpin->m_Unit = m_Unit;
newpin->m_Convert = m_Convert;
newpin->m_Flags = m_Flags;
newpin->m_Width = m_Width;
newpin->m_PinName = m_PinName; newpin->m_PinName = m_PinName;
......
This diff is collapsed.
...@@ -161,6 +161,29 @@ public: ...@@ -161,6 +161,29 @@ public:
virtual bool Save( FILE* aFile ) const = 0; virtual bool Save( FILE* aFile ) const = 0;
virtual bool Load( char* line, wxString& errorMsg ) = 0; virtual bool Load( char* line, wxString& errorMsg ) = 0;
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param refPos A wxPoint to test
* @return bool - true if a hit, else false
*/
virtual bool HitTest( const wxPoint& refPos )
{
return false; // derived classes should override this function
}
/** Function HitTest (overlayed)
* @return true if the point aPosRef is near this object
* @param aPosRef = a wxPoint to test
* @param aThreshold = max distance to this object (usually the half thickness of a line)
* @param aTransMat = the transform matrix
*/
virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] ) = 0;
/** Function GetBoundingBox
* @return the boundary box for this, in library coordinates
*/
virtual EDA_Rect GetBoundingBox() virtual EDA_Rect GetBoundingBox()
{ {
return EDA_BaseStruct::GetBoundingBox(); return EDA_BaseStruct::GetBoundingBox();
...@@ -188,8 +211,12 @@ public: ...@@ -188,8 +211,12 @@ public:
int m_PinNumSize; int m_PinNumSize;
int m_PinNameSize; /* Pin num and Pin name sizes */ int m_PinNameSize; /* Pin num and Pin name sizes */
// int m_PinNumWidth, m_PinNameWidth; /* (Currently Unused) Pin num and Pin name text width */ // (Currently Unused) Pin num and Pin name text opt: italic/normal/bold, 0 = default:
wxPoint m_Pos; /* Position or centre (Arc and Circle) or start char m_PinNumShapeOpt, m_PinNameShapeOpt;
// (Currently Unused) Pin num and Pin name text opt position, 0 = default:
char m_PinNumPositionOpt, m_PinNamePositionOpt;
wxPoint m_Pos; /* Position or centre (Arc and Circle) or start
* point (segments) */ * point (segments) */
int m_Width; /* Line width */ int m_Width; /* Line width */
...@@ -217,6 +244,22 @@ public: ...@@ -217,6 +244,22 @@ public:
virtual bool Load( char* line, wxString& errorMsg ); virtual bool Load( char* line, wxString& errorMsg );
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param aRefPos A wxPoint to test
* @return bool - true if a hit, else false
*/
virtual bool HitTest( const wxPoint& aRefPos );
/** Function HitTest
* @return true if the point aPosRef is near this object
* @param aPosRef = a wxPoint to test
* @param aThreshold = max distance to this object (usually the half thickness of a line)
* @param aTransMat = the transform matrix
*/
virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] );
LibDrawPin* GenCopy(); LibDrawPin* GenCopy();
virtual void DisplayInfo( WinEDA_DrawFrame* frame ); virtual void DisplayInfo( WinEDA_DrawFrame* frame );
virtual EDA_Rect GetBoundingBox(); virtual EDA_Rect GetBoundingBox();
...@@ -288,7 +331,14 @@ public: ...@@ -288,7 +331,14 @@ public:
* @return bool - true if a hit, else false * @return bool - true if a hit, else false
*/ */
virtual bool HitTest( const wxPoint& aRefPos ); virtual bool HitTest( const wxPoint& aRefPos );
/** Function HitTest
* @return true if the point aPosRef is near this object
* @param aPosRef = a wxPoint to test
* @param aThreshold = max distance to this object (usually the half thickness of a line)
* @param aTransMat = the transform matrix
*/
virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] );
LibDrawArc* GenCopy(); LibDrawArc* GenCopy();
...@@ -339,6 +389,14 @@ public: ...@@ -339,6 +389,14 @@ public:
*/ */
virtual bool HitTest( const wxPoint& aRefPos ); virtual bool HitTest( const wxPoint& aRefPos );
/** Function HitTest
* @return true if the point aPosRef is near this object
* @param aPosRef = a wxPoint to test
* @param aThreshold = max distance to this object (usually the half thickness of a line)
* @param aTransMat = the transform matrix
*/
virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] );
LibDrawCircle* GenCopy(); LibDrawCircle* GenCopy();
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset,
...@@ -385,6 +443,14 @@ public: ...@@ -385,6 +443,14 @@ public:
*/ */
virtual bool HitTest( const wxPoint& refPos ); virtual bool HitTest( const wxPoint& refPos );
/** Function HitTest
* @return true if the point aPosRef is near a segment
* @param aPosRef = a wxPoint to test, in eeschema coordinates
* @param aThreshold = max distance to a segment
* @param aTransMat = the transform matrix
*/
virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] );
/** /**
* Function HitTest (overlayed) * Function HitTest (overlayed)
* tests if the given EDA_Rect intersect this object. * tests if the given EDA_Rect intersect this object.
...@@ -436,6 +502,22 @@ public: ...@@ -436,6 +502,22 @@ public:
virtual bool Save( FILE* aFile ) const; virtual bool Save( FILE* aFile ) const;
virtual bool Load( char* line, wxString& errorMsg ); virtual bool Load( char* line, wxString& errorMsg );
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param aRefPos A wxPoint to test
* @return bool - true if a hit, else false
*/
virtual bool HitTest( const wxPoint& aRefPos );
/** Function HitTest
* @return true if the point aPosRef is near this object
* @param aPosRef = a wxPoint to test
* @param aThreshold = max distance to this object (usually the half thickness of a line)
* @param aTransMat = the transform matrix
*/
virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] );
LibDrawSquare* GenCopy(); LibDrawSquare* GenCopy();
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset,
...@@ -476,6 +558,22 @@ public: ...@@ -476,6 +558,22 @@ public:
virtual bool Save( FILE* aFile ) const; virtual bool Save( FILE* aFile ) const;
virtual bool Load( char* line, wxString& errorMsg ); virtual bool Load( char* line, wxString& errorMsg );
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param aRefPos A wxPoint to test
* @return bool - true if a hit, else false
*/
virtual bool HitTest( const wxPoint& aRefPos );
/** Function HitTest
* @return true if the point aPosRef is near this object
* @param aPosRef = a wxPoint to test
* @param aThreshold = max distance to this object (usually the half thickness of a line)
* @param aTransMat = the transform matrix
*/
virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] );
LibDrawSegment* GenCopy(); LibDrawSegment* GenCopy();
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset,
...@@ -523,13 +621,21 @@ public: ...@@ -523,13 +621,21 @@ public:
*/ */
unsigned GetCornerCount() const { return m_PolyPoints.size(); } unsigned GetCornerCount() const { return m_PolyPoints.size(); }
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param aRefPos A wxPoint to test
* @return bool - true if a hit, else false
*/
virtual bool HitTest( const wxPoint& aRefPos );
/** Function HitTest /** Function HitTest
* @return true if the point aPosRef is near a segment * @return true if the point aPosRef is near a segment
* @param aPosRef = a wxPoint to test * @param aPosRef = a wxPoint to test
* @param aThreshold = max distance to a segment * @param aThreshold = max distance to a segment
* @param aTransMat = the transform matrix * @param aTransMat = the transform matrix
*/ */
bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] ); virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] );
/** Function GetBoundingBox /** Function GetBoundingBox
* @return the boundary box for this, in library coordinates * @return the boundary box for this, in library coordinates
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "common.h" #include "common.h"
#include "trigo.h"
#include "confirm.h" #include "confirm.h"
#include "class_drawpickedstruct.h" #include "class_drawpickedstruct.h"
#include "program.h" #include "program.h"
...@@ -16,8 +17,7 @@ ...@@ -16,8 +17,7 @@
/* Routines locales */ /* Routines locales */
static int TstAlignSegment( EDA_DrawLineStruct* RefSegm, static int TstAlignSegment( EDA_DrawLineStruct* RefSegm, EDA_DrawLineStruct* TstSegm );
EDA_DrawLineStruct* TstSegm );
/* Variable locales */ /* Variable locales */
...@@ -37,7 +37,7 @@ bool SCH_SCREEN::SchematicCleanUp( wxDC* DC ) ...@@ -37,7 +37,7 @@ bool SCH_SCREEN::SchematicCleanUp( wxDC* DC )
WinEDA_SchematicFrame* frame; WinEDA_SchematicFrame* frame;
frame = (WinEDA_SchematicFrame*)wxGetApp().GetTopWindow(); frame = (WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
DrawList = EEDrawList; DrawList = EEDrawList;
for( ; DrawList != NULL; DrawList = DrawList->Next() ) for( ; DrawList != NULL; DrawList = DrawList->Next() )
...@@ -50,7 +50,7 @@ bool SCH_SCREEN::SchematicCleanUp( wxDC* DC ) ...@@ -50,7 +50,7 @@ bool SCH_SCREEN::SchematicCleanUp( wxDC* DC )
if( TstDrawList->Type() == DRAW_SEGMENT_STRUCT_TYPE ) if( TstDrawList->Type() == DRAW_SEGMENT_STRUCT_TYPE )
{ {
flag = TstAlignSegment( (EDA_DrawLineStruct*) DrawList, flag = TstAlignSegment( (EDA_DrawLineStruct*) DrawList,
(EDA_DrawLineStruct*) TstDrawList ); (EDA_DrawLineStruct*) TstDrawList );
if( flag ) /* Suppression de TstSegm */ if( flag ) /* Suppression de TstSegm */
{ {
/* keep the bits set in .m_Flags, because the deleted segment can be flagged */ /* keep the bits set in .m_Flags, because the deleted segment can be flagged */
...@@ -87,7 +87,7 @@ void BreakSegmentOnJunction( SCH_SCREEN* Screen ) ...@@ -87,7 +87,7 @@ void BreakSegmentOnJunction( SCH_SCREEN* Screen )
if( Screen == NULL ) if( Screen == NULL )
{ {
DisplayError( NULL, DisplayError( NULL,
wxT( "BreakSegmentOnJunction() error: NULL screen" ) ); wxT( "BreakSegmentOnJunction() error: NULL screen" ) );
return; return;
} }
...@@ -144,7 +144,6 @@ DrawPickedStruct* BreakSegment( SCH_SCREEN* screen, ...@@ -144,7 +144,6 @@ DrawPickedStruct* BreakSegment( SCH_SCREEN* screen,
{ {
EDA_BaseStruct* DrawList; EDA_BaseStruct* DrawList;
EDA_DrawLineStruct* segment, * NewSegment; EDA_DrawLineStruct* segment, * NewSegment;
int ox, oy, fx, fy;
DrawPickedStruct* List = NULL; DrawPickedStruct* List = NULL;
DrawList = screen->EEDrawList; DrawList = screen->EEDrawList;
...@@ -154,17 +153,13 @@ DrawPickedStruct* BreakSegment( SCH_SCREEN* screen, ...@@ -154,17 +153,13 @@ DrawPickedStruct* BreakSegment( SCH_SCREEN* screen,
{ {
case DRAW_SEGMENT_STRUCT_TYPE: case DRAW_SEGMENT_STRUCT_TYPE:
segment = (EDA_DrawLineStruct*) DrawList; segment = (EDA_DrawLineStruct*) DrawList;
ox = segment->m_Start.x; oy = segment->m_Start.y;
fx = segment->m_End.x; fy = segment->m_End.y; if( !TestSegmentHit( breakpoint, segment->m_Start, segment->m_End, 0 ) )
if( distance( fx - ox, fy - oy, breakpoint.x - ox, breakpoint.y -
oy, 0 ) == 0 )
break; break;
/* Segment connecte: doit etre coupe en 2 si px,py n'est /* Segment connecte: doit etre coupe en 2 si px,py n'est
* pas une extremite */ * pas une extremite */
if( (ox == breakpoint.x) && (oy == breakpoint.y ) ) if( (segment->m_Start == breakpoint) || (segment->m_End == breakpoint ) )
break;
if( (fx == breakpoint.x) && (fy == breakpoint.y ) )
break; break;
/* Ici il faut couper le segment en 2 */ /* Ici il faut couper le segment en 2 */
if( PutInUndoList ) // First: put copy of the old segment in undo list if( PutInUndoList ) // First: put copy of the old segment in undo list
......
This diff is collapsed.
...@@ -139,12 +139,12 @@ SCH_ITEM * PickStruct(const wxPoint & refpos, BASE_SCREEN* screen, int SearchMas ...@@ -139,12 +139,12 @@ SCH_ITEM * PickStruct(const wxPoint & refpos, BASE_SCREEN* screen, int SearchMas
Return: Return:
-Bloc searc: -Bloc search:
pointeur sur liste de pointeurs de structures si Plusieurs pointeur sur liste de pointeurs de structures si Plusieurs
structures selectionnees. structures selectionnees.
pointeur sur la structure si 1 seule pointeur sur la structure si 1 seule
Positon serach: Positon search:
pointeur sur la structure. pointeur sur la structure.
Si pas de structures selectionnees: retourne NULL */ Si pas de structures selectionnees: retourne NULL */
...@@ -160,20 +160,6 @@ LibDrawPin * LocateAnyPin(SCH_ITEM *DrawList, const wxPoint & RefPos, ...@@ -160,20 +160,6 @@ LibDrawPin * LocateAnyPin(SCH_ITEM *DrawList, const wxPoint & RefPos,
Hierarchical_PIN_Sheet_Struct * LocateAnyPinSheet(const wxPoint & RefPos, Hierarchical_PIN_Sheet_Struct * LocateAnyPinSheet(const wxPoint & RefPos,
SCH_ITEM *DrawList); SCH_ITEM *DrawList);
int distance(int dx, int dy, int spot_cX, int spot_cY, int seuil);
/* Calcul de la distance du point spot_cx,spot_cy a un segment de droite,
d'origine 0,0 et d'extremite dx, dy;
retourne:
0 si distance > seuil
1 si distance <= seuil
Variables utilisees ( sont ramenees au repere centre sur l'origine du segment)
dx, dy = coord de l'extremite segment.
spot_cX,spot_cY = coord du curseur souris
la recherche se fait selon 4 cas:
segment horizontal
segment vertical
segment quelconque */
/***************/ /***************/
/* EEREDRAW.CPP */ /* EEREDRAW.CPP */
......
...@@ -271,13 +271,8 @@ void InitKiCadAbout( wxAboutDialogInfo& info); ...@@ -271,13 +271,8 @@ void InitKiCadAbout( wxAboutDialogInfo& info);
wxString GetBuildVersion(); /* Return the build date */ wxString GetBuildVersion(); /* Return the build date */
wxString GetAboutBuildVersion(); /* Return custom build date for about dialog */ wxString GetAboutBuildVersion(); /* Return custom build date for about dialog */
void Affiche_1_Parametre( WinEDA_DrawFrame* frame, /**
int pos_X, * function Affiche_1_Parametre
const wxString& texte_H,
const wxString& texte_L,
int color );
/*
* Routine d'affichage d'un parametre. * Routine d'affichage d'un parametre.
* pos_X = cadrage horizontal * pos_X = cadrage horizontal
* si pos_X < 0 : la position horizontale est la derniere * si pos_X < 0 : la position horizontale est la derniere
...@@ -288,6 +283,11 @@ void Affiche_1_Parametre( WinEDA_DrawFrame* frame, ...@@ -288,6 +283,11 @@ void Affiche_1_Parametre( WinEDA_DrawFrame* frame,
* si "", par d'affichage sur cette ligne * si "", par d'affichage sur cette ligne
* color = couleur d'affichage * color = couleur d'affichage
*/ */
void Affiche_1_Parametre( WinEDA_DrawFrame* frame,
int pos_X,
const wxString& texte_H,
const wxString& texte_L,
int color );
void AfficheDoc( WinEDA_DrawFrame* frame, const wxString& Doc, void AfficheDoc( WinEDA_DrawFrame* frame, const wxString& Doc,
const wxString& KeyW ); const wxString& KeyW );
......
...@@ -14,15 +14,27 @@ void RotatePoint( wxPoint* point, int angle ); ...@@ -14,15 +14,27 @@ void RotatePoint( wxPoint* point, int angle );
void RotatePoint( wxPoint *point, const wxPoint & centre, int angle ); void RotatePoint( wxPoint *point, const wxPoint & centre, int angle );
void RotatePoint( double *pX, double *pY, int angle ); void RotatePoint( double *pX, double *pY, int angle );
void RotatePoint( double *pX, double *pY, double cx, double cy, int angle ); void RotatePoint( double *pX, double *pY, double cx, double cy, int angle );
int ArcTangente( int dy, int dx );
/* Retourne l'arc tangente en 0.1 degres du vecteur de coord dx, dy /** function ArcTangente
Retourne l'arc tangente en 0.1 degres du vecteur de coord dx, dy
entre -1800 et 1800 entre -1800 et 1800
Analogue a atan2 ( mais plus rapide pour les caculs si Analogue a atan2 ( mais plus rapide pour les caculs si
l'angle est souvent 0, -1800, ou +- 900 */ l'angle est souvent 0, -1800, ou +- 900 */
int ArcTangente( int dy, int dx );
bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY ); bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY );
/** Function TestSegmentHit
* test for hit on line segment
* i.e. cursor within a given distance from segment
* @param aRefPoint = cursor (point to test) coords
* @param aStart is the first end-point of the line segment
* @param aEnd is the second end-point of the line segment
* @param aDist = maximum distance for hit
*/
bool TestSegmentHit( wxPoint aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist );
/*******************/ /*******************/
/* Macro NEW_COORD */ /* Macro NEW_COORD */
/*******************/ /*******************/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment