Code cleaning
This commit is contained in:
parent
02b670d8b3
commit
ada6b6b8ba
|
@ -5,6 +5,13 @@ Started 2007-June-11
|
||||||
Please add newer entries at the top, list the date and your name with
|
Please add newer entries at the top, list the date and your name with
|
||||||
email address.
|
email address.
|
||||||
|
|
||||||
|
2009-Jan-02 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
|
||||||
|
================================================================================
|
||||||
|
++Eeschema:
|
||||||
|
Code cleaning.
|
||||||
|
LibDrawPolyline uses now std::vector<wxPoint> to handle corners.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
2008-Dec-31 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
|
2008-Dec-31 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
|
@ -23,9 +23,9 @@ static SCH_ITEM* CopyStruct( WinEDA_DrawPanel* panel,
|
||||||
BASE_SCREEN* screen,
|
BASE_SCREEN* screen,
|
||||||
SCH_ITEM* DrawStruct );
|
SCH_ITEM* DrawStruct );
|
||||||
static void CollectStructsToDrag( SCH_SCREEN* screen );
|
static void CollectStructsToDrag( SCH_SCREEN* screen );
|
||||||
static void AddPickedItem( SCH_SCREEN* screen, wxPoint position );
|
static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition );
|
||||||
static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* DrawLibItem,
|
static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
|
||||||
wxPoint& position );
|
wxPoint& aPosition );
|
||||||
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel,
|
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel,
|
||||||
wxDC* DC,
|
wxDC* DC,
|
||||||
bool erase );
|
bool erase );
|
||||||
|
@ -182,9 +182,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
|
||||||
|
|
||||||
/* clear struct.m_Flags */
|
/* clear struct.m_Flags */
|
||||||
SCH_ITEM* Struct;
|
SCH_ITEM* Struct;
|
||||||
for( Struct = GetScreen()->EEDrawList;
|
for( Struct = GetScreen()->EEDrawList; Struct != NULL; Struct = Struct->Next() )
|
||||||
Struct != NULL;
|
|
||||||
Struct = Struct->Next() )
|
|
||||||
Struct->m_Flags = 0;
|
Struct->m_Flags = 0;
|
||||||
|
|
||||||
DrawPanel->ManageCurseur = NULL;
|
DrawPanel->ManageCurseur = NULL;
|
||||||
|
@ -203,9 +201,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
|
||||||
block->m_BlockDrawStruct = NULL;
|
block->m_BlockDrawStruct = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetToolID( m_ID_current_state,
|
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
|
||||||
DrawPanel->m_PanelDefaultCursor,
|
|
||||||
wxEmptyString );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1152,10 +1148,7 @@ bool PlaceStruct( BASE_SCREEN* screen, SCH_ITEM* DrawStruct )
|
||||||
if( !DrawStruct )
|
if( !DrawStruct )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
move_vector.x = screen->m_Curseur.x -
|
move_vector = screen->m_Curseur - screen->BlockLocate.m_BlockLastCursorPosition;
|
||||||
screen->BlockLocate.m_BlockLastCursorPosition.x;
|
|
||||||
move_vector.y = screen->m_Curseur.y -
|
|
||||||
screen->BlockLocate.m_BlockLastCursorPosition.y;
|
|
||||||
|
|
||||||
switch( DrawStruct->Type() )
|
switch( DrawStruct->Type() )
|
||||||
{
|
{
|
||||||
|
@ -1709,8 +1702,8 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* DrawLibItem,
|
static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
|
||||||
wxPoint& position )
|
wxPoint& aPosition )
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
{
|
{
|
||||||
EDA_LibComponentStruct* Entry;
|
EDA_LibComponentStruct* Entry;
|
||||||
|
@ -1720,19 +1713,19 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* DrawLibItem,
|
||||||
int orient;
|
int orient;
|
||||||
LibDrawPin* Pin;
|
LibDrawPin* Pin;
|
||||||
|
|
||||||
if( DrawLibItem )
|
if( aDrawLibItem )
|
||||||
{
|
{
|
||||||
NextItem = NULL;
|
NextItem = NULL;
|
||||||
if( ( Entry =
|
if( ( Entry =
|
||||||
FindLibPart( DrawLibItem->m_ChipName.GetData(), wxEmptyString,
|
FindLibPart( aDrawLibItem->m_ChipName.GetData(), wxEmptyString,
|
||||||
FIND_ROOT ) ) == NULL )
|
FIND_ROOT ) ) == NULL )
|
||||||
return NULL;
|
return NULL;
|
||||||
DEntry = Entry->m_Drawings;
|
DEntry = Entry->m_Drawings;
|
||||||
Multi = DrawLibItem->m_Multi;
|
Multi = aDrawLibItem->m_Multi;
|
||||||
convert = DrawLibItem->m_Convert;
|
convert = aDrawLibItem->m_Convert;
|
||||||
PartX = DrawLibItem->m_Pos.x;
|
PartX = aDrawLibItem->m_Pos.x;
|
||||||
PartY = DrawLibItem->m_Pos.y;
|
PartY = aDrawLibItem->m_Pos.y;
|
||||||
memcpy( TransMat, DrawLibItem->m_Transform, sizeof(TransMat) );
|
memcpy( TransMat, aDrawLibItem->m_Transform, sizeof(TransMat) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
DEntry = NextItem;
|
DEntry = NextItem;
|
||||||
|
@ -1753,10 +1746,7 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* DrawLibItem,
|
||||||
orient = Pin->ReturnPinDrawOrient( TransMat );
|
orient = Pin->ReturnPinDrawOrient( TransMat );
|
||||||
|
|
||||||
/* Calcul de la position du point de reference */
|
/* Calcul de la position du point de reference */
|
||||||
position.x = PartX + (TransMat[0][0] *Pin->m_Pos.x)
|
aPosition = TransformCoordinate( TransMat, Pin->m_Pos);
|
||||||
+ (TransMat[0][1] *Pin->m_Pos.y);
|
|
||||||
position.y = PartY + (TransMat[1][0] *Pin->m_Pos.x)
|
|
||||||
+ (TransMat[1][1] *Pin->m_Pos.y);
|
|
||||||
NextItem = DEntry->Next();
|
NextItem = DEntry->Next();
|
||||||
return DEntry;
|
return DEntry;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
/* BLOCK.CPP */
|
/* block_libedt.cpp */
|
||||||
/* Gestion des Operations sur Blocks et Effacements */
|
/* Gestion des Operations sur Blocks et Effacements */
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
|
|
||||||
|
@ -139,11 +139,11 @@ int MarkItemsInBloc( EDA_LibComponentStruct* LibComponent,
|
||||||
|
|
||||||
case COMPONENT_POLYLINE_DRAW_TYPE:
|
case COMPONENT_POLYLINE_DRAW_TYPE:
|
||||||
{
|
{
|
||||||
int ii, imax = ( (LibDrawPolyline*) item )->m_CornersCount * 2;
|
int ii, imax = ( (LibDrawPolyline*) item )->GetCornerCount();
|
||||||
int* ptpoly = ( (LibDrawPolyline*) item )->m_PolyList;
|
for( ii = 0; ii < imax; ii ++ )
|
||||||
for( ii = 0; ii < imax; ii += 2 )
|
|
||||||
{
|
{
|
||||||
pos.x = ptpoly[ii]; pos.y = -ptpoly[ii + 1];
|
pos = ( (LibDrawPolyline*) item )->m_PolyPoints[ii];
|
||||||
|
NEGATE( pos.y );
|
||||||
if( Rect.Inside( pos ) )
|
if( Rect.Inside( pos ) )
|
||||||
{
|
{
|
||||||
item->m_Selected = IS_SELECTED;
|
item->m_Selected = IS_SELECTED;
|
||||||
|
@ -537,7 +537,7 @@ void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset )
|
||||||
if( LibEntry == NULL )
|
if( LibEntry == NULL )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
offset.y = -offset.y; // Y axis for lib items is Down to Up: reverse y offset value
|
NEGATE( offset.y ); // Y axis for lib items is Down to Up: reverse y offset value
|
||||||
item = LibEntry->m_Drawings;
|
item = LibEntry->m_Drawings;
|
||||||
for( ; item != NULL; item = item->Next() )
|
for( ; item != NULL; item = item->Next() )
|
||||||
{
|
{
|
||||||
|
@ -547,42 +547,31 @@ void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset )
|
||||||
switch( item->Type() )
|
switch( item->Type() )
|
||||||
{
|
{
|
||||||
case COMPONENT_PIN_DRAW_TYPE:
|
case COMPONENT_PIN_DRAW_TYPE:
|
||||||
( (LibDrawPin*) item )->m_Pos.x += offset.x;
|
( (LibDrawPin*) item )->m_Pos += offset;
|
||||||
( (LibDrawPin*) item )->m_Pos.y += offset.y;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPONENT_ARC_DRAW_TYPE:
|
case COMPONENT_ARC_DRAW_TYPE:
|
||||||
{
|
{
|
||||||
( (LibDrawArc*) item )->m_Pos.x += offset.x;
|
( (LibDrawArc*) item )->m_Pos += offset;
|
||||||
( (LibDrawArc*) item )->m_Pos.y += offset.y;
|
( (LibDrawArc*) item )->m_ArcStart += offset;
|
||||||
( (LibDrawArc*) item )->m_ArcStart.x += offset.x;
|
( (LibDrawArc*) item )->m_ArcEnd += offset;
|
||||||
( (LibDrawArc*) item )->m_ArcStart.y += offset.y;
|
|
||||||
( (LibDrawArc*) item )->m_ArcEnd.x += offset.x;
|
|
||||||
( (LibDrawArc*) item )->m_ArcEnd.y += offset.y;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case COMPONENT_CIRCLE_DRAW_TYPE:
|
case COMPONENT_CIRCLE_DRAW_TYPE:
|
||||||
( (LibDrawCircle*) item )->m_Pos.x += offset.x;
|
( (LibDrawCircle*) item )->m_Pos += offset;
|
||||||
( (LibDrawCircle*) item )->m_Pos.y += offset.y;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPONENT_RECT_DRAW_TYPE:
|
case COMPONENT_RECT_DRAW_TYPE:
|
||||||
( (LibDrawSquare*) item )->m_Pos.x += offset.x;
|
( (LibDrawSquare*) item )->m_Pos += offset;
|
||||||
( (LibDrawSquare*) item )->m_Pos.y += offset.y;
|
( (LibDrawSquare*) item )->m_End += offset;
|
||||||
( (LibDrawSquare*) item )->m_End.x += offset.x;
|
|
||||||
( (LibDrawSquare*) item )->m_End.y += offset.y;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPONENT_POLYLINE_DRAW_TYPE:
|
case COMPONENT_POLYLINE_DRAW_TYPE:
|
||||||
{
|
{
|
||||||
int ii, imax = ( (LibDrawPolyline*) item )->m_CornersCount * 2;
|
unsigned ii, imax = ( (LibDrawPolyline*) item )->GetCornerCount();
|
||||||
int* ptpoly = ( (LibDrawPolyline*) item )->m_PolyList;
|
for( ii = 0; ii < imax; ii ++ )
|
||||||
for( ii = 0; ii < imax; ii += 2 )
|
( (LibDrawPolyline*) item )->m_PolyPoints[ii] += offset;
|
||||||
{
|
|
||||||
ptpoly[ii] += offset.x;
|
|
||||||
ptpoly[ii + 1] += offset.y;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -590,8 +579,7 @@ void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
|
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
|
||||||
( (LibDrawText*) item )->m_Pos.x += offset.x;
|
( (LibDrawText*) item )->m_Pos += offset;
|
||||||
( (LibDrawText*) item )->m_Pos.y += offset.y;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -688,11 +676,10 @@ void MirrorMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset )
|
||||||
|
|
||||||
case COMPONENT_POLYLINE_DRAW_TYPE:
|
case COMPONENT_POLYLINE_DRAW_TYPE:
|
||||||
{
|
{
|
||||||
int ii, imax = ( (LibDrawPolyline*) item )->m_CornersCount * 2;
|
unsigned ii, imax = ( (LibDrawPolyline*) item )->GetCornerCount();
|
||||||
int* ptpoly = ( (LibDrawPolyline*) item )->m_PolyList;
|
for( ii = 0; ii < imax; ii ++ )
|
||||||
for( ii = 0; ii < imax; ii += 2 )
|
|
||||||
{
|
{
|
||||||
SETMIRROR( ptpoly[ii] );
|
SETMIRROR( ( (LibDrawPolyline*) item )->m_PolyPoints[ii].x );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -118,7 +118,6 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert )
|
||||||
**/
|
**/
|
||||||
{
|
{
|
||||||
int xmin, xmax, ymin, ymax, x1, y1;
|
int xmin, xmax, ymin, ymax, x1, y1;
|
||||||
int* pt, ii;
|
|
||||||
LibEDA_BaseStruct* DrawEntry;
|
LibEDA_BaseStruct* DrawEntry;
|
||||||
EDA_Rect BoundaryBox;
|
EDA_Rect BoundaryBox;
|
||||||
|
|
||||||
|
@ -232,21 +231,15 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert )
|
||||||
|
|
||||||
case COMPONENT_POLYLINE_DRAW_TYPE:
|
case COMPONENT_POLYLINE_DRAW_TYPE:
|
||||||
{
|
{
|
||||||
LibDrawPolyline* polyline = (LibDrawPolyline*) DrawEntry;
|
EDA_Rect rect = ((LibDrawPolyline*) DrawEntry)->GetBoundaryBox( );
|
||||||
pt = polyline->m_PolyList;
|
xmin = MIN( xmin, rect.GetX() );
|
||||||
for( ii = 0; ii < polyline->m_CornersCount; ii++ )
|
xmax = MAX( xmax, rect.GetX() );
|
||||||
{
|
ymin = MIN( ymin, rect.GetY() );
|
||||||
if( xmin > *pt )
|
ymax = MAX( ymax, rect.GetY() );
|
||||||
xmin = *pt;
|
xmin = MIN( xmin, rect.GetEnd().x );
|
||||||
if( xmax < *pt )
|
xmax = MAX( xmax, rect.GetEnd().x );
|
||||||
xmax = *pt;
|
ymin = MIN( ymin, rect.GetEnd().y );
|
||||||
pt++;
|
ymax = MAX( ymax, rect.GetEnd().y );
|
||||||
if( ymin > *pt )
|
|
||||||
ymin = *pt;
|
|
||||||
if( ymax < *pt )
|
|
||||||
ymax = *pt;
|
|
||||||
pt++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -257,9 +250,7 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert )
|
||||||
|
|
||||||
// Update the BoundaryBox. Remember the fact the screen Y axis is the reverse */
|
// Update the BoundaryBox. Remember the fact the screen Y axis is the reverse */
|
||||||
NEGATE(ymax); NEGATE(ymin); // Y is not is screen axis sense
|
NEGATE(ymax); NEGATE(ymin); // Y is not is screen axis sense
|
||||||
// Ensure w and H > 0 (wxRect assume it)
|
// Ensure H > 0 (wxRect assume it)
|
||||||
if( xmax < xmin )
|
|
||||||
EXCHG( xmax, xmin );
|
|
||||||
if( ymax < ymin )
|
if( ymax < ymin )
|
||||||
EXCHG( ymax, ymin );
|
EXCHG( ymax, ymin );
|
||||||
BoundaryBox.SetX( xmin ); BoundaryBox.SetWidth( xmax - xmin );
|
BoundaryBox.SetX( xmin ); BoundaryBox.SetWidth( xmax - xmin );
|
||||||
|
|
|
@ -240,8 +240,8 @@ void LibDrawPolyline::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
|
||||||
|
|
||||||
int color = ReturnLayerColor( LAYER_DEVICE );
|
int color = ReturnLayerColor( LAYER_DEVICE );
|
||||||
int linewidth = MAX( m_Width, g_DrawMinimunLineWidth );
|
int linewidth = MAX( m_Width, g_DrawMinimunLineWidth );
|
||||||
static int* Buf_Poly_Drawings = NULL; // Buffer used to store current corners coordinates for drawings
|
static wxPoint* Buf_Poly_Drawings = NULL; // Buffer used to store current corners coordinates for drawings
|
||||||
static int Buf_Poly_Size = 0; // Buffer used to store current corners coordinates for drawings
|
static unsigned Buf_Poly_Size = 0; // Buffer used to store current corners coordinates for drawings
|
||||||
|
|
||||||
if( aColor < 0 ) // Used normal color or selected color
|
if( aColor < 0 ) // Used normal color or selected color
|
||||||
{
|
{
|
||||||
|
@ -254,25 +254,19 @@ void LibDrawPolyline::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
|
||||||
// Set the size of the buffer od coordinates
|
// Set the size of the buffer od coordinates
|
||||||
if( Buf_Poly_Drawings == NULL )
|
if( Buf_Poly_Drawings == NULL )
|
||||||
{
|
{
|
||||||
Buf_Poly_Size = m_CornersCount;
|
Buf_Poly_Size = m_PolyPoints.size();
|
||||||
Buf_Poly_Drawings = (int*) MyMalloc( sizeof(int) * 2 * Buf_Poly_Size );
|
Buf_Poly_Drawings = (wxPoint*) MyMalloc( sizeof(wxPoint) * Buf_Poly_Size );
|
||||||
}
|
}
|
||||||
else if( Buf_Poly_Size < m_CornersCount )
|
else if( Buf_Poly_Size < m_PolyPoints.size() )
|
||||||
{
|
{
|
||||||
Buf_Poly_Size = m_CornersCount;
|
Buf_Poly_Size = m_PolyPoints.size();
|
||||||
Buf_Poly_Drawings = (int*) realloc( Buf_Poly_Drawings,
|
Buf_Poly_Drawings = (wxPoint*) realloc( Buf_Poly_Drawings,
|
||||||
sizeof(int) * 2 * Buf_Poly_Size );
|
sizeof(wxPoint) * Buf_Poly_Size );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( int ii = 0, jj = 0; ii < m_CornersCount; ii++, jj += 2 )
|
for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ )
|
||||||
{
|
{
|
||||||
pos1.x = m_PolyList[jj];
|
Buf_Poly_Drawings[ii] = TransformCoordinate( aTransformMatrix, m_PolyPoints[ii] ) + aOffset;
|
||||||
pos1.y = m_PolyList[jj + 1];
|
|
||||||
|
|
||||||
pos1 = TransformCoordinate( aTransformMatrix, pos1 ) + aOffset;
|
|
||||||
|
|
||||||
Buf_Poly_Drawings[jj] = pos1.x;
|
|
||||||
Buf_Poly_Drawings[jj + 1] = pos1.y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FILL_T fill = aData ? NO_FILL : m_Fill;
|
FILL_T fill = aData ? NO_FILL : m_Fill;
|
||||||
|
@ -280,15 +274,15 @@ void LibDrawPolyline::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
|
||||||
fill = NO_FILL;
|
fill = NO_FILL;
|
||||||
|
|
||||||
if( fill == FILLED_WITH_BG_BODYCOLOR )
|
if( fill == FILLED_WITH_BG_BODYCOLOR )
|
||||||
GRPoly( &aPanel->m_ClipBox, aDC, m_CornersCount,
|
GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(),
|
||||||
(wxPoint*) Buf_Poly_Drawings, 1, linewidth, color,
|
Buf_Poly_Drawings, 1, linewidth, color,
|
||||||
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
|
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
|
||||||
else if( fill == FILLED_SHAPE )
|
else if( fill == FILLED_SHAPE )
|
||||||
GRPoly( &aPanel->m_ClipBox, aDC, m_CornersCount,
|
GRPoly( &aPanel->m_ClipBox, aDC,m_PolyPoints.size(),
|
||||||
(wxPoint*) Buf_Poly_Drawings, 1, linewidth, color, color );
|
Buf_Poly_Drawings, 1, linewidth, color, color );
|
||||||
else
|
else
|
||||||
GRPoly( &aPanel->m_ClipBox, aDC, m_CornersCount,
|
GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(),
|
||||||
(wxPoint*) Buf_Poly_Drawings, 0, linewidth, color, color );
|
Buf_Poly_Drawings, 0, linewidth, color, color );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -520,8 +514,6 @@ LibDrawSegment* LibDrawSegment::GenCopy()
|
||||||
|
|
||||||
LibDrawPolyline::LibDrawPolyline() : LibEDA_BaseStruct( COMPONENT_POLYLINE_DRAW_TYPE )
|
LibDrawPolyline::LibDrawPolyline() : LibEDA_BaseStruct( COMPONENT_POLYLINE_DRAW_TYPE )
|
||||||
{
|
{
|
||||||
m_CornersCount = 0;
|
|
||||||
m_PolyList = NULL;
|
|
||||||
m_Fill = NO_FILL;
|
m_Fill = NO_FILL;
|
||||||
m_Width = 0;
|
m_Width = 0;
|
||||||
}
|
}
|
||||||
|
@ -532,16 +524,7 @@ LibDrawPolyline* LibDrawPolyline::GenCopy()
|
||||||
/************************************************/
|
/************************************************/
|
||||||
{
|
{
|
||||||
LibDrawPolyline* newitem = new LibDrawPolyline();
|
LibDrawPolyline* newitem = new LibDrawPolyline();
|
||||||
|
newitem->m_PolyPoints = m_PolyPoints; // Vector copy
|
||||||
int size;
|
|
||||||
|
|
||||||
newitem->m_CornersCount = m_CornersCount;
|
|
||||||
size = sizeof(int) * 2 * m_CornersCount;
|
|
||||||
if( size )
|
|
||||||
{
|
|
||||||
newitem->m_PolyList = (int*) MyMalloc( size );
|
|
||||||
memcpy( newitem->m_PolyList, m_PolyList, size );
|
|
||||||
}
|
|
||||||
newitem->m_Width = m_Width;
|
newitem->m_Width = m_Width;
|
||||||
newitem->m_Unit = m_Unit;
|
newitem->m_Unit = m_Unit;
|
||||||
newitem->m_Convert = m_Convert;
|
newitem->m_Convert = m_Convert;
|
||||||
|
@ -555,18 +538,55 @@ LibDrawPolyline* LibDrawPolyline::GenCopy()
|
||||||
void LibDrawPolyline::AddPoint( const wxPoint& point )
|
void LibDrawPolyline::AddPoint( const wxPoint& point )
|
||||||
/***************************************************/
|
/***************************************************/
|
||||||
|
|
||||||
/* add a point to the polyline coordinate list, and realloc the memory
|
/* add a point to the polyline coordinate list
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int allocsize;
|
m_PolyPoints.push_back( point );
|
||||||
|
}
|
||||||
m_CornersCount++;
|
|
||||||
allocsize = 2 * sizeof(int) * m_CornersCount;
|
|
||||||
if( m_PolyList == NULL )
|
/** Function HitTest
|
||||||
m_PolyList = (int*) MyMalloc( allocsize );
|
* @return true if the point aPosRef is near a segment
|
||||||
else
|
* @param aPosRef = a wxPoint to test
|
||||||
m_PolyList = (int*) realloc( m_PolyList, allocsize );
|
* @param aThreshold = max distance to a segment
|
||||||
|
* @param aTransMat = the transform matrix
|
||||||
m_PolyList[(m_CornersCount * 2) - 2] = point.x;
|
*/
|
||||||
m_PolyList[(m_CornersCount * 2) - 1] = -point.y;
|
bool LibDrawPolyline::HitTest( wxPoint aPosRef, int aThreshold, int aTransMat[2][2] )
|
||||||
|
{
|
||||||
|
|
||||||
|
aPosRef = TransformCoordinate( aTransMat, aPosRef);
|
||||||
|
/* Move origin coordinate to segment start point */
|
||||||
|
wxPoint end;
|
||||||
|
for ( unsigned ii = 0; ii < m_PolyPoints.size() -1; ii++ )
|
||||||
|
{
|
||||||
|
aPosRef -= m_PolyPoints[0];
|
||||||
|
end = m_PolyPoints[1] - m_PolyPoints[0];
|
||||||
|
|
||||||
|
if( distance( end.x, end.y, aPosRef.x, aPosRef.y, aThreshold ) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Function GetBoundaryBox
|
||||||
|
* @return the boundary box for this, in library coordinates
|
||||||
|
*/
|
||||||
|
EDA_Rect LibDrawPolyline::GetBoundaryBox( )
|
||||||
|
{
|
||||||
|
EDA_Rect BoundaryBox;
|
||||||
|
int xmin, xmax, ymin, ymax;
|
||||||
|
xmin = xmax = m_PolyPoints[0].x;
|
||||||
|
ymin = ymax = m_PolyPoints[0].y;
|
||||||
|
for( unsigned ii = 1; ii < GetCornerCount(); ii++ )
|
||||||
|
{
|
||||||
|
xmin = MIN( xmin, m_PolyPoints[0].x );
|
||||||
|
xmax = MAX( xmax, m_PolyPoints[0].x );
|
||||||
|
ymin = MIN( ymin, m_PolyPoints[0].y );
|
||||||
|
ymax = MAX( ymax, m_PolyPoints[0].y );
|
||||||
|
}
|
||||||
|
BoundaryBox.SetX( xmin ); BoundaryBox.SetWidth( xmax - xmin );
|
||||||
|
BoundaryBox.SetY( ymin ); BoundaryBox.SetHeight( ymax - ymin );
|
||||||
|
|
||||||
|
return BoundaryBox;
|
||||||
}
|
}
|
||||||
|
|
|
@ -413,24 +413,18 @@ public:
|
||||||
int aDrawMode, void* aData, int aTransformMatrix[2][2] );
|
int aDrawMode, void* aData, int aTransformMatrix[2][2] );
|
||||||
};
|
};
|
||||||
|
|
||||||
/*********************************************/
|
/**********************************************************/
|
||||||
/* Graphic Body Item: Polygon (set of lines) */
|
/* Graphic Body Item: Polygon and polyline (set of lines) */
|
||||||
/*********************************************/
|
/**********************************************************/
|
||||||
class LibDrawPolyline : public LibEDA_BaseStruct
|
class LibDrawPolyline : public LibEDA_BaseStruct
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int m_CornersCount;
|
|
||||||
int* m_PolyList;
|
|
||||||
int m_Width; /* Tickness */
|
int m_Width; /* Tickness */
|
||||||
|
std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LibDrawPolyline();
|
LibDrawPolyline();
|
||||||
~LibDrawPolyline()
|
~LibDrawPolyline() { }
|
||||||
{
|
|
||||||
if( m_PolyList )
|
|
||||||
free( m_PolyList );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
virtual wxString GetClass() const
|
virtual wxString GetClass() const
|
||||||
{
|
{
|
||||||
|
@ -449,6 +443,24 @@ public:
|
||||||
LibDrawPolyline* GenCopy();
|
LibDrawPolyline* GenCopy();
|
||||||
void AddPoint( const wxPoint& point );
|
void AddPoint( const wxPoint& point );
|
||||||
|
|
||||||
|
/** Function GetCornerCount
|
||||||
|
* @return the number of corners
|
||||||
|
*/
|
||||||
|
unsigned GetCornerCount() const { return m_PolyPoints.size(); }
|
||||||
|
|
||||||
|
/** Function HitTest
|
||||||
|
* @return true if the point aPosRef is near a segment
|
||||||
|
* @param aPosRef = a wxPoint to test
|
||||||
|
* @param aThreshold = max distance to a segment
|
||||||
|
* @param aTransMat = the transform matrix
|
||||||
|
*/
|
||||||
|
bool HitTest( wxPoint aPosRef, int aThreshold, int aTransMat[2][2] );
|
||||||
|
|
||||||
|
/** Function GetBoundaryBox
|
||||||
|
* @return the boundary box for this, in library coordinates
|
||||||
|
*/
|
||||||
|
EDA_Rect GetBoundaryBox( );
|
||||||
|
|
||||||
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor,
|
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor,
|
||||||
int aDrawMode, void* aData, int aTransformMatrix[2][2] );
|
int aDrawMode, void* aData, int aTransformMatrix[2][2] );
|
||||||
};
|
};
|
||||||
|
|
|
@ -168,18 +168,12 @@ LibDrawPin* WinEDA_SchematicFrame::LocatePinEnd( SCH_ITEM* DrawList, const wxPo
|
||||||
pinpos = Pin->m_Pos;
|
pinpos = Pin->m_Pos;
|
||||||
|
|
||||||
if( DrawLibItem == NULL )
|
if( DrawLibItem == NULL )
|
||||||
pinpos.y = -pinpos.y;
|
NEGATE( pinpos.y );
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
pinpos = TransformCoordinate( DrawLibItem->m_Transform, pinpos);
|
||||||
int x1 = pinpos.x, y1 = pinpos.y;
|
|
||||||
pinpos.x = DrawLibItem->m_Pos.x + DrawLibItem->m_Transform[0][0] * x1
|
|
||||||
+ DrawLibItem->m_Transform[0][1] * y1;
|
|
||||||
pinpos.y = DrawLibItem->m_Pos.y + DrawLibItem->m_Transform[1][0] * x1
|
|
||||||
+ DrawLibItem->m_Transform[1][1] * y1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( (pos.x == pinpos.x) && (pos.y == pinpos.y) )
|
if( pos == pinpos )
|
||||||
return Pin;
|
return Pin;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -292,16 +286,10 @@ wxPoint ReturnPinPhysicalPosition( LibDrawPin* Pin,
|
||||||
wxPoint PinPos = Pin->m_Pos;
|
wxPoint PinPos = Pin->m_Pos;
|
||||||
|
|
||||||
if( DrawLibItem == NULL )
|
if( DrawLibItem == NULL )
|
||||||
PinPos.y = -PinPos.y;
|
NEGATE( PinPos.y );
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
PinPos = TransformCoordinate( DrawLibItem->m_Transform, Pin->m_Pos);
|
||||||
int x = Pin->m_Pos.x, y = Pin->m_Pos.y;
|
|
||||||
PinPos.x = DrawLibItem->m_Pos.x + DrawLibItem->m_Transform[0][0] * x
|
|
||||||
+ DrawLibItem->m_Transform[0][1] * y;
|
|
||||||
PinPos.y = DrawLibItem->m_Pos.y + DrawLibItem->m_Transform[1][0] * x
|
|
||||||
+ DrawLibItem->m_Transform[1][1] * y;
|
|
||||||
}
|
|
||||||
|
|
||||||
return PinPos;
|
return PinPos;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
// Local variables:
|
// Local variables:
|
||||||
static int s_SelectedRow;
|
static int s_SelectedRow;
|
||||||
|
|
||||||
|
#define COLUMN_FIELD_NAME 0
|
||||||
|
#define COLUMN_TEXT 1
|
||||||
|
|
||||||
/*****************************************************************************************/
|
/*****************************************************************************************/
|
||||||
class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB : public DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE
|
class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB : public DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE
|
||||||
|
@ -146,10 +148,10 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnInitDialog( wxInitDialogEvent& event
|
||||||
columnLabel.SetImage( -1 );
|
columnLabel.SetImage( -1 );
|
||||||
|
|
||||||
columnLabel.SetText( _( "Name" ) );
|
columnLabel.SetText( _( "Name" ) );
|
||||||
fieldListCtrl->InsertColumn( 0, columnLabel );
|
fieldListCtrl->InsertColumn( COLUMN_FIELD_NAME, columnLabel );
|
||||||
|
|
||||||
columnLabel.SetText( _( "Value" ) );
|
columnLabel.SetText( _( "Value" ) );
|
||||||
fieldListCtrl->InsertColumn( 1, columnLabel );
|
fieldListCtrl->InsertColumn( COLUMN_TEXT, columnLabel );
|
||||||
|
|
||||||
wxString label = _( "Size" ) + ReturnUnitSymbol( g_UnitMetric );
|
wxString label = _( "Size" ) + ReturnUnitSymbol( g_UnitMetric );
|
||||||
textSizeLabel->SetLabel( label );
|
textSizeLabel->SetLabel( label );
|
||||||
|
@ -298,19 +300,26 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::addFieldButtonHandler( wxCommandEvent&
|
||||||
/*****************************************************************************************/
|
/*****************************************************************************************/
|
||||||
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::deleteFieldButtonHandler( wxCommandEvent& event )
|
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::deleteFieldButtonHandler( wxCommandEvent& event )
|
||||||
/*****************************************************************************************/
|
/*****************************************************************************************/
|
||||||
|
/* Delete a field.
|
||||||
|
* Fields REFERENCE and VALUE are mandatory, and cannot be deleted.
|
||||||
|
* If a field is empty, it is removed.
|
||||||
|
* if not empty, the text is removed.
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
unsigned fieldNdx = getSelectedFieldNdx();
|
unsigned fieldNdx = getSelectedFieldNdx();
|
||||||
|
|
||||||
if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
|
if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( fieldNdx < FIELD1 )
|
if( fieldNdx <= VALUE )
|
||||||
{
|
{
|
||||||
wxBell();
|
wxBell();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_skipCopyFromPanel = true;
|
m_skipCopyFromPanel = true;
|
||||||
|
if( m_FieldsBuf[fieldNdx].m_Text.IsEmpty() )
|
||||||
|
{
|
||||||
m_FieldsBuf.erase( m_FieldsBuf.begin() + fieldNdx );
|
m_FieldsBuf.erase( m_FieldsBuf.begin() + fieldNdx );
|
||||||
fieldListCtrl->DeleteItem( fieldNdx );
|
fieldListCtrl->DeleteItem( fieldNdx );
|
||||||
|
|
||||||
|
@ -319,6 +328,13 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::deleteFieldButtonHandler( wxCommandEven
|
||||||
|
|
||||||
// Reinitialize fields IDs and default names:
|
// Reinitialize fields IDs and default names:
|
||||||
reinitializeFieldsIdAndDefaultNames();
|
reinitializeFieldsIdAndDefaultNames();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_FieldsBuf[fieldNdx].m_Text.Empty();
|
||||||
|
copySelectedFieldToPanel();
|
||||||
|
}
|
||||||
|
|
||||||
updateDisplay( );
|
updateDisplay( );
|
||||||
|
|
||||||
setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] );
|
setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] );
|
||||||
|
@ -467,15 +483,15 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::setRowItem( int aFieldNdx, const LibDra
|
||||||
|
|
||||||
wxASSERT( ndx >= 0 );
|
wxASSERT( ndx >= 0 );
|
||||||
|
|
||||||
fieldListCtrl->SetItem( ndx, 1, wxEmptyString );
|
fieldListCtrl->SetItem( ndx, COLUMN_TEXT, wxEmptyString );
|
||||||
}
|
}
|
||||||
|
|
||||||
fieldListCtrl->SetItem( aFieldNdx, 0, aField.m_Name );
|
fieldListCtrl->SetItem( aFieldNdx, COLUMN_FIELD_NAME, aField.m_Name );
|
||||||
fieldListCtrl->SetItem( aFieldNdx, 1, aField.m_Text );
|
fieldListCtrl->SetItem( aFieldNdx, COLUMN_TEXT, aField.m_Text );
|
||||||
|
|
||||||
// recompute the column widths here, after setting texts
|
// recompute the column widths here, after setting texts
|
||||||
fieldListCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE );
|
fieldListCtrl->SetColumnWidth( COLUMN_FIELD_NAME, wxLIST_AUTOSIZE );
|
||||||
fieldListCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE );
|
fieldListCtrl->SetColumnWidth( COLUMN_TEXT, wxLIST_AUTOSIZE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -514,6 +530,9 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
|
||||||
// if fieldNdx == REFERENCE, VALUE, FOOTPRINT, or DATASHEET, then disable filed name editing
|
// if fieldNdx == REFERENCE, VALUE, FOOTPRINT, or DATASHEET, then disable filed name editing
|
||||||
fieldNameTextCtrl->Enable( fieldNdx >= FIELD1 );
|
fieldNameTextCtrl->Enable( fieldNdx >= FIELD1 );
|
||||||
fieldNameTextCtrl->SetEditable( fieldNdx >= FIELD1 );
|
fieldNameTextCtrl->SetEditable( fieldNdx >= FIELD1 );
|
||||||
|
moveUpButton->Enable( fieldNdx >= FIELD1 ); // disable move up button for non moveable fields
|
||||||
|
// if fieldNdx == REFERENCE, VALUE, then disable delete button
|
||||||
|
deleteFieldButton->Enable( fieldNdx > VALUE );
|
||||||
|
|
||||||
fieldValueTextCtrl->SetValue( field.m_Text );
|
fieldValueTextCtrl->SetValue( field.m_Text );
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC )
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPoint pos, newpos;
|
wxPoint pos, newpos;
|
||||||
int x1, y1;
|
|
||||||
SCH_COMPONENT* comp = (SCH_COMPONENT*) aField->GetParent();
|
SCH_COMPONENT* comp = (SCH_COMPONENT*) aField->GetParent();
|
||||||
|
|
||||||
SAFE_DELETE( g_ItemToUndoCopy );
|
SAFE_DELETE( g_ItemToUndoCopy );
|
||||||
|
@ -50,19 +49,16 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC )
|
||||||
|
|
||||||
/* Les positions sont calculees par la matrice TRANSPOSEE de la matrice
|
/* Les positions sont calculees par la matrice TRANSPOSEE de la matrice
|
||||||
* de rotation-miroir */
|
* de rotation-miroir */
|
||||||
x1 = aField->m_Pos.x - pos.x;
|
newpos = aField->m_Pos - pos;
|
||||||
y1 = aField->m_Pos.y - pos.y;
|
|
||||||
|
|
||||||
// Empirically this is necessary. The Y coordinate appears to be inverted
|
// Empirically this is necessary. The Y coordinate appears to be inverted
|
||||||
// under some circumstances, but that inversion is not preserved by all
|
// under some circumstances, but that inversion is not preserved by all
|
||||||
// combinations of mirroring and rotation. The following clause is true
|
// combinations of mirroring and rotation. The following clause is true
|
||||||
// when the number of rotations and the number of mirrorings are both odd.
|
// when the number of rotations and the number of mirrorings are both odd.
|
||||||
if( comp->m_Transform[1][0] * comp->m_Transform[0][1] < 0 )
|
if( comp->m_Transform[1][0] * comp->m_Transform[0][1] < 0 )
|
||||||
{
|
NEGATE (newpos.y);
|
||||||
y1 = -y1;
|
|
||||||
}
|
newpos = TransformCoordinate( comp->m_Transform, newpos) + pos;
|
||||||
newpos.x = pos.x + comp->m_Transform[0][0] * x1 + comp->m_Transform[1][0] * y1;
|
|
||||||
newpos.y = pos.y + comp->m_Transform[0][1] * x1 + comp->m_Transform[1][1] * y1;
|
|
||||||
|
|
||||||
DrawPanel->CursorOff( DC );
|
DrawPanel->CursorOff( DC );
|
||||||
GetScreen()->m_Curseur = newpos;
|
GetScreen()->m_Curseur = newpos;
|
||||||
|
|
|
@ -748,28 +748,28 @@ LibEDA_BaseStruct* GetDrawEntry (WinEDA_DrawFrame* frame,
|
||||||
case 'P': /* Polyline */
|
case 'P': /* Polyline */
|
||||||
{
|
{
|
||||||
LibDrawPolyline* Polyl = new LibDrawPolyline();
|
LibDrawPolyline* Polyl = new LibDrawPolyline();
|
||||||
|
int ccount = 0;
|
||||||
New = Polyl;
|
New = Polyl;
|
||||||
|
|
||||||
if( sscanf( &Line[2], "%d %d %d %d",
|
if( sscanf( &Line[2], "%d %d %d %d",
|
||||||
&Polyl->m_CornersCount, &Unit, &Convert,
|
&ccount, &Unit, &Convert,
|
||||||
&Polyl->m_Width ) == 4
|
&Polyl->m_Width ) == 4
|
||||||
&& Polyl->m_CornersCount > 0 )
|
&& ccount > 0 )
|
||||||
{
|
{
|
||||||
Polyl->m_Unit = Unit; Polyl->m_Convert = Convert;
|
Polyl->m_Unit = Unit; Polyl->m_Convert = Convert;
|
||||||
|
|
||||||
Polyl->m_PolyList = (int*)
|
|
||||||
MyZMalloc( sizeof(int) * Polyl->m_CornersCount * 2 );
|
|
||||||
|
|
||||||
p = strtok( &Line[2], " \t\n" );
|
p = strtok( &Line[2], " \t\n" );
|
||||||
p = strtok( NULL, " \t\n" );
|
p = strtok( NULL, " \t\n" );
|
||||||
p = strtok( NULL, " \t\n" );
|
p = strtok( NULL, " \t\n" );
|
||||||
p = strtok( NULL, " \t\n" );
|
p = strtok( NULL, " \t\n" );
|
||||||
|
|
||||||
for( i = 0; i < Polyl->m_CornersCount * 2 && !Error; i++ )
|
for( i = 0; i < ccount && !Error; i++ )
|
||||||
{
|
{
|
||||||
|
wxPoint point;
|
||||||
p = strtok( NULL, " \t\n" );
|
p = strtok( NULL, " \t\n" );
|
||||||
Error = sscanf( p, "%d", &Polyl->m_PolyList[i] ) != 1;
|
Error = sscanf( p, "%d", &point.x ) != 1;
|
||||||
|
p = strtok( NULL, " \t\n" );
|
||||||
|
Error = Error || sscanf( p, "%d", &point.y ) != 1;
|
||||||
|
Polyl->AddPoint(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
Polyl->m_Fill = NO_FILL;
|
Polyl->m_Fill = NO_FILL;
|
||||||
|
@ -787,8 +787,8 @@ LibEDA_BaseStruct* GetDrawEntry (WinEDA_DrawFrame* frame,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
MsgLine.Printf( wxT( "Undefined DRAW command in line %d, aborted." ),
|
MsgLine.Printf( wxT( "Undefined DRAW command in line %d\n%s, aborted." ),
|
||||||
*LineNum );
|
*LineNum, Line );
|
||||||
DisplayError( frame, MsgLine );
|
DisplayError( frame, MsgLine );
|
||||||
return Head;
|
return Head;
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,10 +149,7 @@ SCH_ITEM * WinEDA_SchematicFrame::FindComponentAndItem(
|
||||||
}
|
}
|
||||||
wxPoint delta;
|
wxPoint delta;
|
||||||
pos -= Component->m_Pos;
|
pos -= Component->m_Pos;
|
||||||
|
delta = TransformCoordinate( Component->m_Transform, pos);
|
||||||
delta.x = Component->m_Transform[0][0] * pos.x + Component->m_Transform[0][1] * pos.y;
|
|
||||||
delta.y = Component->m_Transform[1][0] * pos.x + Component->m_Transform[1][1] * pos.y;
|
|
||||||
|
|
||||||
pos = delta + Component->m_Pos;
|
pos = delta + Component->m_Pos;
|
||||||
|
|
||||||
wxPoint old_cursor_position = sheet->LastScreen()->m_Curseur;
|
wxPoint old_cursor_position = sheet->LastScreen()->m_Curseur;
|
||||||
|
@ -165,8 +162,7 @@ SCH_ITEM * WinEDA_SchematicFrame::FindComponentAndItem(
|
||||||
&( GetScreen()->m_StartVisu.y ));
|
&( GetScreen()->m_StartVisu.y ));
|
||||||
|
|
||||||
// calcul des coord curseur avec origine = screen
|
// calcul des coord curseur avec origine = screen
|
||||||
curpos.x -= GetScreen()->m_StartVisu.x;
|
curpos -= GetScreen()->m_StartVisu;
|
||||||
curpos.y -= GetScreen()->m_StartVisu.y;
|
|
||||||
|
|
||||||
/* Il y a peut-etre necessite de recadrer le dessin: */
|
/* Il y a peut-etre necessite de recadrer le dessin: */
|
||||||
#define MARGIN 30
|
#define MARGIN 30
|
||||||
|
@ -420,7 +416,7 @@ SCH_ITEM* WinEDA_SchematicFrame::FindSchematicItem(
|
||||||
{
|
{
|
||||||
DrawSheetPath* Sheet, * FirstSheet = NULL;
|
DrawSheetPath* Sheet, * FirstSheet = NULL;
|
||||||
SCH_ITEM* DrawList = NULL, * FirstStruct = NULL, * Struct = NULL;
|
SCH_ITEM* DrawList = NULL, * FirstStruct = NULL, * Struct = NULL;
|
||||||
int StartCount, ii, jj;
|
int StartCount;
|
||||||
bool NotFound;
|
bool NotFound;
|
||||||
wxPoint firstpos, pos, old_cursor_position;
|
wxPoint firstpos, pos, old_cursor_position;
|
||||||
static int Find_in_hierarchy;
|
static int Find_in_hierarchy;
|
||||||
|
@ -556,14 +552,9 @@ SCH_ITEM* WinEDA_SchematicFrame::FindSchematicItem(
|
||||||
{
|
{
|
||||||
SCH_COMPONENT* pSch = (SCH_COMPONENT*) Struct;
|
SCH_COMPONENT* pSch = (SCH_COMPONENT*) Struct;
|
||||||
|
|
||||||
pos.x -= pSch->m_Pos.x;
|
pos -= pSch->m_Pos;
|
||||||
pos.y -= pSch->m_Pos.y;
|
pos = TransformCoordinate( pSch->m_Transform, pos );
|
||||||
|
pos += pSch->m_Pos;
|
||||||
ii = pSch->m_Transform[0][0] * pos.x + pSch->m_Transform[0][1] * pos.y;
|
|
||||||
jj = pSch->m_Transform[1][0] * pos.x + pSch->m_Transform[1][1] * pos.y;
|
|
||||||
|
|
||||||
pos.x = ii + pSch->m_Pos.x;
|
|
||||||
pos.y = jj + pSch->m_Pos.y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
old_cursor_position = Sheet->LastScreen()->m_Curseur;
|
old_cursor_position = Sheet->LastScreen()->m_Curseur;
|
||||||
|
@ -576,8 +567,7 @@ SCH_ITEM* WinEDA_SchematicFrame::FindSchematicItem(
|
||||||
&( GetScreen()->m_StartVisu.y ));
|
&( GetScreen()->m_StartVisu.y ));
|
||||||
|
|
||||||
// calcul des coord curseur avec origine = screen
|
// calcul des coord curseur avec origine = screen
|
||||||
curpos.x -= m_CurrentSheet->LastScreen()->m_StartVisu.x;
|
curpos -= m_CurrentSheet->LastScreen()->m_StartVisu;
|
||||||
curpos.y -= m_CurrentSheet->LastScreen()->m_StartVisu.y;
|
|
||||||
|
|
||||||
/* Il y a peut-etre necessite de recadrer le dessin: */
|
/* Il y a peut-etre necessite de recadrer le dessin: */
|
||||||
#define MARGIN 30
|
#define MARGIN 30
|
||||||
|
|
|
@ -153,7 +153,7 @@ bool BlockActive = (GetScreen()->BlockLocate.m_Command != BLOCK_IDLE);
|
||||||
}
|
}
|
||||||
else if( (DrawEntry->m_Flags & IS_NEW) )
|
else if( (DrawEntry->m_Flags & IS_NEW) )
|
||||||
{
|
{
|
||||||
if( ((LibDrawPolyline*)DrawEntry)->m_CornersCount > 2 )
|
if( ((LibDrawPolyline*)DrawEntry)->GetCornerCount() > 2 )
|
||||||
{
|
{
|
||||||
msg = AddHotkeyName( _( "Delete Segment " ), s_Libedit_Hokeys_Descr, HK_DELETE_PIN );
|
msg = AddHotkeyName( _( "Delete Segment " ), s_Libedit_Hokeys_Descr, HK_DELETE_PIN );
|
||||||
ADD_MENUITEM(PopMenu,
|
ADD_MENUITEM(PopMenu,
|
||||||
|
|
|
@ -22,11 +22,11 @@ static SCH_ITEM* LastSnappedStruct = NULL;
|
||||||
static int PickedBoxMinX, PickedBoxMinY, PickedBoxMaxX, PickedBoxMaxY;
|
static int PickedBoxMinX, PickedBoxMinY, PickedBoxMaxX, PickedBoxMaxY;
|
||||||
static bool IsBox1InBox2( int StartX1, int StartY1, int EndX1, int EndY1,
|
static bool IsBox1InBox2( int StartX1, int StartY1, int EndX1, int EndY1,
|
||||||
int StartX2, int StartY2, int EndX2, int EndY2 );
|
int StartX2, int StartY2, int EndX2, int EndY2 );
|
||||||
static bool IsPointInBox( int pX, int pY,
|
static bool IsPointInBox( wxPoint aPosRef,
|
||||||
int BoxX1, int BoxY1, int BoxX2, int BoxY2 );
|
int BoxX1, int BoxY1, int BoxX2, int BoxY2 );
|
||||||
static bool IsPointOnSegment( int pX, int pY,
|
static bool IsPointOnSegment( wxPoint aPosRef,
|
||||||
int SegmX1, int SegmY1, int SegmX2, int SegmY2, int seuil = 0 );
|
int SegmX1, int SegmY1, int SegmX2, int SegmY2, int seuil = 0 );
|
||||||
static bool SnapPoint2( const wxPoint& PosRef, int SearchMask,
|
static bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
|
||||||
SCH_ITEM* DrawList, DrawPickedStruct* DontSnapList, int zoom_value );
|
SCH_ITEM* DrawList, DrawPickedStruct* DontSnapList, int zoom_value );
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,13 +119,11 @@ SCH_ITEM* PickStruct( const wxPoint& refpos, BASE_SCREEN* screen, int SearchMask
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
bool Snapped;
|
bool Snapped;
|
||||||
SCH_ITEM* DrawList = screen->EEDrawList;
|
if( screen == NULL || screen->EEDrawList == NULL )
|
||||||
|
|
||||||
if( screen==NULL || DrawList == NULL )
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if( ( Snapped = SnapPoint2( refpos, SearchMask,
|
if( ( Snapped = SnapPoint2( refpos, SearchMask,
|
||||||
DrawList, NULL, screen->GetZoom() ) ) != FALSE )
|
screen->EEDrawList, NULL, screen->GetZoom() ) ) != FALSE )
|
||||||
{
|
{
|
||||||
return LastSnappedStruct;
|
return LastSnappedStruct;
|
||||||
}
|
}
|
||||||
|
@ -197,10 +195,10 @@ SCH_ITEM* PickStruct( EDA_Rect& block, BASE_SCREEN* screen, int SearchMask )
|
||||||
* If DontSnapList is not NULL, structes in this list are skipped. *
|
* If DontSnapList is not NULL, structes in this list are skipped. *
|
||||||
* The routine returns TRUE if point was snapped. *
|
* The routine returns TRUE if point was snapped. *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
bool SnapPoint2( const wxPoint& PosRef, int SearchMask,
|
bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
|
||||||
SCH_ITEM* DrawList, DrawPickedStruct* DontSnapList, int zoom_value )
|
SCH_ITEM* DrawList, DrawPickedStruct* DontSnapList, int zoom_value )
|
||||||
{
|
{
|
||||||
int i, * Points, x = PosRef.x, y = PosRef.y;
|
int i, * Points;
|
||||||
int x1, y1, x2, y2, NumOfPoints2;
|
int x1, y1, x2, y2, NumOfPoints2;
|
||||||
DrawPickedStruct* DontSnap;
|
DrawPickedStruct* DontSnap;
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
|
@ -231,7 +229,7 @@ bool SnapPoint2( const wxPoint& PosRef, int SearchMask,
|
||||||
{
|
{
|
||||||
x1 = Points[i]; y1 = Points[i + 1];
|
x1 = Points[i]; y1 = Points[i + 1];
|
||||||
x2 = Points[i + 2]; y2 = Points[i + 3];
|
x2 = Points[i + 2]; y2 = Points[i + 3];
|
||||||
if( IsPointOnSegment( x, y, x1, y1, x2, y2 ) )
|
if( IsPointOnSegment( aPosRef, x1, y1, x2, y2 ) )
|
||||||
{
|
{
|
||||||
LastSnappedStruct = DrawList;
|
LastSnappedStruct = DrawList;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -246,7 +244,7 @@ bool SnapPoint2( const wxPoint& PosRef, int SearchMask,
|
||||||
if( !( SearchMask & (DRAWITEM | WIREITEM | BUSITEM) ) )
|
if( !( SearchMask & (DRAWITEM | WIREITEM | BUSITEM) ) )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if( IsPointOnSegment( x, y, STRUCT->m_Start.x, STRUCT->m_Start.y,
|
if( IsPointOnSegment( aPosRef, STRUCT->m_Start.x, STRUCT->m_Start.y,
|
||||||
STRUCT->m_End.x, STRUCT->m_End.y ) )
|
STRUCT->m_End.x, STRUCT->m_End.y ) )
|
||||||
{
|
{
|
||||||
if( ( (SearchMask & DRAWITEM) && (STRUCT->GetLayer() == LAYER_NOTES) )
|
if( ( (SearchMask & DRAWITEM) && (STRUCT->GetLayer() == LAYER_NOTES) )
|
||||||
|
@ -256,15 +254,13 @@ bool SnapPoint2( const wxPoint& PosRef, int SearchMask,
|
||||||
{
|
{
|
||||||
if( SearchMask & EXCLUDE_WIRE_BUS_ENDPOINTS )
|
if( SearchMask & EXCLUDE_WIRE_BUS_ENDPOINTS )
|
||||||
{
|
{
|
||||||
if( x == STRUCT->m_Start.x && y == STRUCT->m_Start.y )
|
if( aPosRef == STRUCT->m_Start || aPosRef == STRUCT->m_End )
|
||||||
break;
|
|
||||||
if( x == STRUCT->m_End.x && y == STRUCT->m_End.y )
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( SearchMask & WIRE_BUS_ENDPOINTS_ONLY )
|
if( SearchMask & WIRE_BUS_ENDPOINTS_ONLY )
|
||||||
{
|
{
|
||||||
if( !STRUCT->IsOneEndPointAt( wxPoint( x, y ) ) )
|
if( !STRUCT->IsOneEndPointAt( aPosRef ) )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +277,7 @@ bool SnapPoint2( const wxPoint& PosRef, int SearchMask,
|
||||||
if( !( SearchMask & (RACCORDITEM) ) )
|
if( !( SearchMask & (RACCORDITEM) ) )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if( IsPointOnSegment( x, y, STRUCT->m_Pos.x, STRUCT->m_Pos.y,
|
if( IsPointOnSegment( aPosRef, STRUCT->m_Pos.x, STRUCT->m_Pos.y,
|
||||||
STRUCT->m_End().x, STRUCT->m_End().y ) )
|
STRUCT->m_End().x, STRUCT->m_End().y ) )
|
||||||
{
|
{
|
||||||
LastSnappedStruct = DrawList;
|
LastSnappedStruct = DrawList;
|
||||||
|
@ -299,7 +295,7 @@ bool SnapPoint2( const wxPoint& PosRef, int SearchMask,
|
||||||
y1 = STRUCT->m_Pos.y - dx;
|
y1 = STRUCT->m_Pos.y - dx;
|
||||||
x2 = STRUCT->m_Pos.x + dx;
|
x2 = STRUCT->m_Pos.x + dx;
|
||||||
y2 = STRUCT->m_Pos.y + dx;
|
y2 = STRUCT->m_Pos.y + dx;
|
||||||
if( IsPointInBox( x, y, x1, y1, x2, y2 ) )
|
if( IsPointInBox( aPosRef, x1, y1, x2, y2 ) )
|
||||||
{
|
{
|
||||||
LastSnappedStruct = DrawList;
|
LastSnappedStruct = DrawList;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -317,7 +313,7 @@ bool SnapPoint2( const wxPoint& PosRef, int SearchMask,
|
||||||
y1 = STRUCT->m_Pos.y - dx;
|
y1 = STRUCT->m_Pos.y - dx;
|
||||||
x2 = STRUCT->m_Pos.x + dx;
|
x2 = STRUCT->m_Pos.x + dx;
|
||||||
y2 = STRUCT->m_Pos.y + dx;
|
y2 = STRUCT->m_Pos.y + dx;
|
||||||
if( IsPointInBox( x, y, x1, y1, x2, y2 ) )
|
if( IsPointInBox( aPosRef, x1, y1, x2, y2 ) )
|
||||||
{
|
{
|
||||||
LastSnappedStruct = DrawList;
|
LastSnappedStruct = DrawList;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -334,7 +330,7 @@ bool SnapPoint2( const wxPoint& PosRef, int SearchMask,
|
||||||
y1 = STRUCT->m_Pos.y - dx;
|
y1 = STRUCT->m_Pos.y - dx;
|
||||||
x2 = STRUCT->m_Pos.x + dx;
|
x2 = STRUCT->m_Pos.x + dx;
|
||||||
y2 = STRUCT->m_Pos.y + dx;
|
y2 = STRUCT->m_Pos.y + dx;
|
||||||
if( IsPointInBox( x, y, x1, y1, x2, y2 ) )
|
if( IsPointInBox( aPosRef, x1, y1, x2, y2 ) )
|
||||||
{
|
{
|
||||||
LastSnappedStruct = DrawList;
|
LastSnappedStruct = DrawList;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -371,7 +367,7 @@ bool SnapPoint2( const wxPoint& PosRef, int SearchMask,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( IsPointInBox( x, y, x1, y1, x2, y2 ) )
|
if( IsPointInBox( aPosRef, x1, y1, x2, y2 ) )
|
||||||
{
|
{
|
||||||
LastSnappedStruct = DrawList;
|
LastSnappedStruct = DrawList;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -409,7 +405,7 @@ bool SnapPoint2( const wxPoint& PosRef, int SearchMask,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( IsPointInBox( x, y, x1, y1, x2, y2 ) )
|
if( IsPointInBox( aPosRef, x1, y1, x2, y2 ) )
|
||||||
{
|
{
|
||||||
LastSnappedStruct = DrawList;
|
LastSnappedStruct = DrawList;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -434,7 +430,7 @@ bool SnapPoint2( const wxPoint& PosRef, int SearchMask,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
EDA_Rect BoundaryBox = field->GetBoundaryBox();
|
EDA_Rect BoundaryBox = field->GetBoundaryBox();
|
||||||
if( BoundaryBox.Inside( x, y ) )
|
if( BoundaryBox.Inside( aPosRef ) )
|
||||||
{
|
{
|
||||||
LastSnappedStruct = field;
|
LastSnappedStruct = field;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -446,7 +442,7 @@ bool SnapPoint2( const wxPoint& PosRef, int SearchMask,
|
||||||
#undef STRUCT
|
#undef STRUCT
|
||||||
#define STRUCT ( (SCH_COMPONENT*) DrawList )
|
#define STRUCT ( (SCH_COMPONENT*) DrawList )
|
||||||
EDA_Rect BoundaryBox = STRUCT->GetBoundaryBox();
|
EDA_Rect BoundaryBox = STRUCT->GetBoundaryBox();
|
||||||
if( BoundaryBox.Inside( x, y ) )
|
if( BoundaryBox.Inside( aPosRef ) )
|
||||||
{
|
{
|
||||||
LastSnappedStruct = DrawList;
|
LastSnappedStruct = DrawList;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -465,7 +461,7 @@ bool SnapPoint2( const wxPoint& PosRef, int SearchMask,
|
||||||
x2 = STRUCT->m_Pos.x + STRUCT->m_Size.x;
|
x2 = STRUCT->m_Pos.x + STRUCT->m_Size.x;
|
||||||
y2 = STRUCT->m_Pos.y + STRUCT->m_Size.y;
|
y2 = STRUCT->m_Pos.y + STRUCT->m_Size.y;
|
||||||
|
|
||||||
if( IsPointInBox( x, y, x1, y1, x2, y2 ) )
|
if( IsPointInBox( aPosRef, x1, y1, x2, y2 ) )
|
||||||
{
|
{
|
||||||
LastSnappedStruct = DrawList;
|
LastSnappedStruct = DrawList;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -740,7 +736,7 @@ static bool IsBox1InBox2( int StartX1, int StartY1, int EndX1, int EndY1,
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
static bool IsPointInBox( int pX, int pY,
|
static bool IsPointInBox( wxPoint aPosRef,
|
||||||
int BoxX1, int BoxY1, int BoxX2, int BoxY2 )
|
int BoxX1, int BoxY1, int BoxX2, int BoxY2 )
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
||||||
|
@ -754,7 +750,7 @@ static bool IsPointInBox( int pX, int pY,
|
||||||
if( BoxY1 > BoxY2 )
|
if( BoxY1 > BoxY2 )
|
||||||
EXCHG( BoxY1, BoxY2 );
|
EXCHG( BoxY1, BoxY2 );
|
||||||
|
|
||||||
if( (pX >= BoxX1) && (pX <= BoxX2) && (pY >= BoxY1) && (pY <= BoxY2) )
|
if( (aPosRef.x >= BoxX1) && (aPosRef.x <= BoxX2) && (aPosRef.y >= BoxY1) && (aPosRef.y <= BoxY2) )
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -763,7 +759,7 @@ static bool IsPointInBox( int pX, int pY,
|
||||||
|
|
||||||
|
|
||||||
/********************************************************************************/
|
/********************************************************************************/
|
||||||
static bool IsPointOnSegment( int pX, int pY,
|
static bool IsPointOnSegment( wxPoint aPosRef,
|
||||||
int SegmX1, int SegmY1, int SegmX2, int SegmY2, int seuil )
|
int SegmX1, int SegmY1, int SegmX2, int SegmY2, int seuil )
|
||||||
/********************************************************************************/
|
/********************************************************************************/
|
||||||
|
|
||||||
|
@ -772,10 +768,10 @@ static bool IsPointOnSegment( int pX, int pY,
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
/* Recalcul des coord avec SegmX1, SegmX2 comme origine */
|
/* Recalcul des coord avec SegmX1, SegmX2 comme origine */
|
||||||
pX -= SegmX1; pY -= SegmY1;
|
aPosRef.x -= SegmX1; aPosRef.y -= SegmY1;
|
||||||
SegmX2 -= SegmX1; SegmY2 -= SegmY1;
|
SegmX2 -= SegmX1; SegmY2 -= SegmY1;
|
||||||
|
|
||||||
if( distance( SegmX2, SegmY2, pX, pY, seuil ) )
|
if( distance( SegmX2, SegmY2, aPosRef.x, aPosRef.y, seuil ) )
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -785,7 +781,7 @@ static bool IsPointOnSegment( int pX, int pY,
|
||||||
|
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
|
LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
|
||||||
const wxPoint& refpoint,
|
const wxPoint& aRefPoint,
|
||||||
EDA_LibComponentStruct* LibEntry,
|
EDA_LibComponentStruct* LibEntry,
|
||||||
int Unit,
|
int Unit,
|
||||||
int Convert,
|
int Convert,
|
||||||
|
@ -798,8 +794,7 @@ LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
|
||||||
* toutes variantes)
|
* toutes variantes)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int x, y, dx, dy, ii, * ptpoly;
|
int dx, dy;
|
||||||
int px, py;
|
|
||||||
LibEDA_BaseStruct* DrawItem;
|
LibEDA_BaseStruct* DrawItem;
|
||||||
int seuil;
|
int seuil;
|
||||||
|
|
||||||
|
@ -815,8 +810,6 @@ LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
|
||||||
DrawItem = LibEntry->m_Drawings;
|
DrawItem = LibEntry->m_Drawings;
|
||||||
|
|
||||||
seuil = 3; /* Tolerance: 1/2 pas de petite grille */
|
seuil = 3; /* Tolerance: 1/2 pas de petite grille */
|
||||||
px = refpoint.x;
|
|
||||||
py = refpoint.y;
|
|
||||||
|
|
||||||
for( ; DrawItem != NULL; DrawItem = DrawItem->Next() )
|
for( ; DrawItem != NULL; DrawItem = DrawItem->Next() )
|
||||||
{
|
{
|
||||||
|
@ -832,10 +825,10 @@ LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
|
||||||
LibDrawArc* Arc = (LibDrawArc*) DrawItem;
|
LibDrawArc* Arc = (LibDrawArc*) DrawItem;
|
||||||
if( (masque & LOCATE_COMPONENT_ARC_DRAW_TYPE) == 0 )
|
if( (masque & LOCATE_COMPONENT_ARC_DRAW_TYPE) == 0 )
|
||||||
break;
|
break;
|
||||||
dx = px - Arc->m_Pos.x;
|
dx = aRefPoint.x - Arc->m_Pos.x;
|
||||||
dy = py + Arc->m_Pos.y;
|
dy = aRefPoint.y + Arc->m_Pos.y;
|
||||||
ii = (int) sqrt( ((double)dx * dx) + ((double)dy * dy) );
|
int dist = (int) sqrt( ((double)dx * dx) + ((double)dy * dy) );
|
||||||
if( abs( ii - Arc->m_Rayon ) <= seuil )
|
if( abs( dist - Arc->m_Rayon ) <= seuil )
|
||||||
return DrawItem;
|
return DrawItem;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -845,10 +838,10 @@ LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
|
||||||
LibDrawCircle* Circle = (LibDrawCircle*) DrawItem;
|
LibDrawCircle* Circle = (LibDrawCircle*) DrawItem;
|
||||||
if( (masque & LOCATE_COMPONENT_CIRCLE_DRAW_TYPE) == 0 )
|
if( (masque & LOCATE_COMPONENT_CIRCLE_DRAW_TYPE) == 0 )
|
||||||
break;
|
break;
|
||||||
dx = px - Circle->m_Pos.x;
|
dx = aRefPoint.x - Circle->m_Pos.x;
|
||||||
dy = py + Circle->m_Pos.y;
|
dy = aRefPoint.y + Circle->m_Pos.y;
|
||||||
ii = (int) sqrt( dx * dx + dy * dy );
|
int dist = (int) sqrt( dx * dx + dy * dy );
|
||||||
if( abs( ii - Circle->m_Rayon ) <= seuil )
|
if( abs( dist - Circle->m_Rayon ) <= seuil )
|
||||||
return DrawItem;
|
return DrawItem;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -858,19 +851,19 @@ LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
|
||||||
LibDrawSquare* Square = (LibDrawSquare*) DrawItem;
|
LibDrawSquare* Square = (LibDrawSquare*) DrawItem;
|
||||||
if( (masque & LOCATE_COMPONENT_RECT_DRAW_TYPE) == 0 )
|
if( (masque & LOCATE_COMPONENT_RECT_DRAW_TYPE) == 0 )
|
||||||
break;
|
break;
|
||||||
if( IsPointOnSegment( px, py, // locate lower segment
|
if( IsPointOnSegment( aRefPoint, // locate lower segment
|
||||||
Square->m_Pos.x, -Square->m_Pos.y,
|
Square->m_Pos.x, -Square->m_Pos.y,
|
||||||
Square->m_End.x, -Square->m_Pos.y, seuil ) )
|
Square->m_End.x, -Square->m_Pos.y, seuil ) )
|
||||||
return DrawItem;
|
return DrawItem;
|
||||||
if( IsPointOnSegment( px, py, // locate right segment
|
if( IsPointOnSegment( aRefPoint, // locate right segment
|
||||||
Square->m_End.x, -Square->m_Pos.y,
|
Square->m_End.x, -Square->m_Pos.y,
|
||||||
Square->m_End.x, -Square->m_End.y, seuil ) )
|
Square->m_End.x, -Square->m_End.y, seuil ) )
|
||||||
return DrawItem;
|
return DrawItem;
|
||||||
if( IsPointOnSegment( px, py, // locate upper segment
|
if( IsPointOnSegment( aRefPoint, // locate upper segment
|
||||||
Square->m_End.x, -Square->m_End.y,
|
Square->m_End.x, -Square->m_End.y,
|
||||||
Square->m_Pos.x, -Square->m_End.y, seuil ) )
|
Square->m_Pos.x, -Square->m_End.y, seuil ) )
|
||||||
return DrawItem;
|
return DrawItem;
|
||||||
if( IsPointOnSegment( px, py, // locate left segment
|
if( IsPointOnSegment( aRefPoint, // locate left segment
|
||||||
Square->m_Pos.x, -Square->m_End.y,
|
Square->m_Pos.x, -Square->m_End.y,
|
||||||
Square->m_Pos.x, -Square->m_Pos.y, seuil ) )
|
Square->m_Pos.x, -Square->m_Pos.y, seuil ) )
|
||||||
return DrawItem;
|
return DrawItem;
|
||||||
|
@ -882,11 +875,12 @@ LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
|
||||||
LibDrawPolyline* polyline = (LibDrawPolyline*) DrawItem;
|
LibDrawPolyline* polyline = (LibDrawPolyline*) DrawItem;
|
||||||
if( (masque & LOCATE_COMPONENT_POLYLINE_DRAW_TYPE) == 0 )
|
if( (masque & LOCATE_COMPONENT_POLYLINE_DRAW_TYPE) == 0 )
|
||||||
break;
|
break;
|
||||||
ptpoly = polyline->m_PolyList;
|
|
||||||
for( ii = polyline->m_CornersCount - 1; ii > 0; ii--, ptpoly += 2 )
|
for( unsigned ii = 0; ii < polyline->m_PolyPoints.size()-1; ii++ )
|
||||||
{
|
{
|
||||||
if( IsPointOnSegment( px, py,
|
if( IsPointOnSegment( aRefPoint,
|
||||||
ptpoly[0], -ptpoly[1], ptpoly[2], -ptpoly[3], seuil ) )
|
polyline->m_PolyPoints[ii].x, -polyline->m_PolyPoints[ii].y,
|
||||||
|
polyline->m_PolyPoints[ii+1].x, -polyline->m_PolyPoints[ii+1].y, seuil ) )
|
||||||
return DrawItem;
|
return DrawItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -897,7 +891,7 @@ LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
|
||||||
LibDrawSegment* Segment = (LibDrawSegment*) DrawItem;
|
LibDrawSegment* Segment = (LibDrawSegment*) DrawItem;
|
||||||
if( (masque & LOCATE_COMPONENT_LINE_DRAW_TYPE) == 0 )
|
if( (masque & LOCATE_COMPONENT_LINE_DRAW_TYPE) == 0 )
|
||||||
break;
|
break;
|
||||||
if( IsPointOnSegment( px, py,
|
if( IsPointOnSegment( aRefPoint,
|
||||||
Segment->m_Pos.x, -Segment->m_Pos.y,
|
Segment->m_Pos.x, -Segment->m_Pos.y,
|
||||||
Segment->m_End.x, -Segment->m_End.y, seuil ) )
|
Segment->m_End.x, -Segment->m_End.y, seuil ) )
|
||||||
return DrawItem;
|
return DrawItem;
|
||||||
|
@ -909,16 +903,17 @@ LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
|
||||||
LibDrawText* Text = (LibDrawText*) DrawItem;
|
LibDrawText* Text = (LibDrawText*) DrawItem;
|
||||||
if( (masque & LOCATE_COMPONENT_GRAPHIC_TEXT_DRAW_TYPE) == 0 )
|
if( (masque & LOCATE_COMPONENT_GRAPHIC_TEXT_DRAW_TYPE) == 0 )
|
||||||
break;
|
break;
|
||||||
ii = Text->m_Text.Len(); if( ii < 2 )
|
int len = Text->m_Text.Len();
|
||||||
ii = 2;
|
if( len < 2 )
|
||||||
dx = (Text->m_Size.x * ii) / 2;
|
len = 2;
|
||||||
|
dx = (Text->m_Size.x * len) / 2;
|
||||||
dy = Text->m_Size.y / 2;
|
dy = Text->m_Size.y / 2;
|
||||||
if( Text->m_Orient == TEXT_ORIENT_VERT )
|
if( Text->m_Orient == TEXT_ORIENT_VERT )
|
||||||
{
|
{
|
||||||
EXCHG( dx, dy );
|
EXCHG( dx, dy );
|
||||||
}
|
}
|
||||||
x = px - Text->m_Pos.x;
|
int x = aRefPoint.x - Text->m_Pos.x;
|
||||||
y = py + Text->m_Pos.y;
|
int y = aRefPoint.y + Text->m_Pos.y;
|
||||||
if( (abs( x ) <= dx) && (abs( y ) <= dy) )
|
if( (abs( x ) <= dx) && (abs( y ) <= dy) )
|
||||||
return DrawItem; /* Texte trouve */
|
return DrawItem; /* Texte trouve */
|
||||||
}
|
}
|
||||||
|
|
|
@ -308,11 +308,10 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
|
||||||
case COMPONENT_POLYLINE_DRAW_TYPE:
|
case COMPONENT_POLYLINE_DRAW_TYPE:
|
||||||
{
|
{
|
||||||
LibDrawPolyline* polyline = (LibDrawPolyline*) DEntry;
|
LibDrawPolyline* polyline = (LibDrawPolyline*) DEntry;
|
||||||
Poly = (int*) MyMalloc( sizeof(int) * 2 * polyline->m_CornersCount );
|
Poly = (int*) MyMalloc( sizeof(int) * 2 * polyline->GetCornerCount() );
|
||||||
for( ii = 0; ii < polyline->m_CornersCount; ii++ )
|
for( ii = 0; ii < (int)polyline->GetCornerCount(); ii++ )
|
||||||
{
|
{
|
||||||
pos.x = polyline->m_PolyList[ii * 2];
|
pos = polyline->m_PolyPoints[ii];
|
||||||
pos.y = polyline->m_PolyList[ii * 2 + 1];
|
|
||||||
pos = TransformCoordinate( TransMat, pos ) + DrawLibItem->m_Pos;
|
pos = TransformCoordinate( TransMat, pos ) + DrawLibItem->m_Pos;
|
||||||
Poly[ii * 2] = pos.x;
|
Poly[ii * 2] = pos.x;
|
||||||
Poly[ii * 2 + 1] = pos.y;
|
Poly[ii * 2 + 1] = pos.y;
|
||||||
|
|
|
@ -157,17 +157,14 @@ bool LibDrawPin::Save( FILE* ExportFile ) const
|
||||||
bool LibDrawPolyline::Save( FILE* ExportFile ) const
|
bool LibDrawPolyline::Save( FILE* ExportFile ) const
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
{
|
{
|
||||||
int ii, * ptpoly;
|
int ccount = GetCornerCount();
|
||||||
|
|
||||||
fprintf( ExportFile, "P %d %d %d %d",
|
fprintf( ExportFile, "P %d %d %d %d",
|
||||||
m_CornersCount,
|
ccount,
|
||||||
m_Unit, m_Convert,
|
m_Unit, m_Convert,
|
||||||
m_Width );
|
m_Width );
|
||||||
ptpoly = m_PolyList;
|
for( unsigned ii = 0; ii < GetCornerCount(); ii++ )
|
||||||
for( ii = m_CornersCount; ii > 0; ii-- )
|
|
||||||
{
|
{
|
||||||
fprintf( ExportFile, " %d %d", *ptpoly, *(ptpoly + 1) );
|
fprintf( ExportFile, " %d %d", m_PolyPoints[ii].x, m_PolyPoints[ii].y );
|
||||||
ptpoly += 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf( ExportFile, " %c\n", fill_tab[m_Fill] );
|
fprintf( ExportFile, " %c\n", fill_tab[m_Fill] );
|
||||||
|
|
|
@ -196,7 +196,6 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( wxDC* DC )
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int DrawType;
|
int DrawType;
|
||||||
int* ptpoly;
|
|
||||||
|
|
||||||
DrawPanel->m_IgnoreMouseEvents = TRUE;
|
DrawPanel->m_IgnoreMouseEvents = TRUE;
|
||||||
|
|
||||||
|
@ -274,13 +273,11 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( wxDC* DC )
|
||||||
case COMPONENT_POLYLINE_DRAW_TYPE:
|
case COMPONENT_POLYLINE_DRAW_TYPE:
|
||||||
{
|
{
|
||||||
LibDrawPolyline* polyline = new LibDrawPolyline();
|
LibDrawPolyline* polyline = new LibDrawPolyline();
|
||||||
|
|
||||||
CurrentDrawItem = polyline;
|
CurrentDrawItem = polyline;
|
||||||
polyline->m_CornersCount = 2;
|
wxPoint point = GetScreen()->m_Curseur;
|
||||||
ptpoly = (int*) MyZMalloc( 4 * sizeof(int) );
|
NEGATE( point.y );
|
||||||
polyline->m_PolyList = ptpoly;
|
polyline->AddPoint( point ); // Start point of the current segment
|
||||||
ptpoly[0] = ptpoly[2] = GetScreen()->m_Curseur.x;
|
polyline->AddPoint( point ); // End point of the current segment
|
||||||
ptpoly[1] = ptpoly[3] = -( GetScreen()->m_Curseur.y );
|
|
||||||
polyline->m_Fill = FlSymbol_Fill;
|
polyline->m_Fill = FlSymbol_Fill;
|
||||||
polyline->m_Width = g_LibSymbolDefaultLineWidth;
|
polyline->m_Width = g_LibSymbolDefaultLineWidth;
|
||||||
}
|
}
|
||||||
|
@ -378,6 +375,7 @@ void WinEDA_LibeditFrame::GraphicItemBeginDraw( wxDC* DC )
|
||||||
case COMPONENT_POLYLINE_DRAW_TYPE:
|
case COMPONENT_POLYLINE_DRAW_TYPE:
|
||||||
{
|
{
|
||||||
wxPoint pos = GetScreen()->m_Curseur;
|
wxPoint pos = GetScreen()->m_Curseur;
|
||||||
|
NEGATE(pos.y);
|
||||||
( (LibDrawPolyline*) CurrentDrawItem )->AddPoint( pos );
|
( (LibDrawPolyline*) CurrentDrawItem )->AddPoint( pos );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -423,52 +421,36 @@ static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel,
|
||||||
void MoveLibDrawItemAt( LibEDA_BaseStruct* DrawItem, wxPoint newpos )
|
void MoveLibDrawItemAt( LibEDA_BaseStruct* DrawItem, wxPoint newpos )
|
||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
{
|
{
|
||||||
int mx = newpos.x, my = newpos.y;
|
NEGATE(newpos.y);
|
||||||
wxSize size;
|
wxPoint size;
|
||||||
|
|
||||||
switch( DrawItem->Type() )
|
switch( DrawItem->Type() )
|
||||||
{
|
{
|
||||||
case COMPONENT_ARC_DRAW_TYPE:
|
case COMPONENT_ARC_DRAW_TYPE:
|
||||||
{
|
{
|
||||||
int dx = mx - ( (LibDrawArc*) CurrentDrawItem )->m_Pos.x;
|
wxPoint offset = newpos - ( (LibDrawArc*) CurrentDrawItem )->m_Pos;
|
||||||
int dy = -my - ( (LibDrawArc*) CurrentDrawItem )->m_Pos.y;
|
( (LibDrawArc*) CurrentDrawItem )->m_Pos = newpos;
|
||||||
( (LibDrawArc*) CurrentDrawItem )->m_Pos.x = mx;
|
( (LibDrawArc*) CurrentDrawItem )->m_ArcStart += offset;
|
||||||
( (LibDrawArc*) CurrentDrawItem )->m_Pos.y = -my;
|
( (LibDrawArc*) CurrentDrawItem )->m_ArcEnd += offset;
|
||||||
( (LibDrawArc*) CurrentDrawItem )->m_ArcStart.x += dx;
|
|
||||||
( (LibDrawArc*) CurrentDrawItem )->m_ArcStart.y += dy;
|
|
||||||
( (LibDrawArc*) CurrentDrawItem )->m_ArcEnd.x += dx;
|
|
||||||
( (LibDrawArc*) CurrentDrawItem )->m_ArcEnd.y += dy;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case COMPONENT_CIRCLE_DRAW_TYPE:
|
case COMPONENT_CIRCLE_DRAW_TYPE:
|
||||||
( (LibDrawCircle*) CurrentDrawItem )->m_Pos.x = mx;
|
( (LibDrawCircle*) CurrentDrawItem )->m_Pos = newpos;
|
||||||
( (LibDrawCircle*) CurrentDrawItem )->m_Pos.y = -my;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPONENT_RECT_DRAW_TYPE:
|
case COMPONENT_RECT_DRAW_TYPE:
|
||||||
size.x = ( (LibDrawSquare*) CurrentDrawItem )->m_End.x -
|
size = ( (LibDrawSquare*) CurrentDrawItem )->m_End - ( (LibDrawSquare*) CurrentDrawItem )->m_Pos;
|
||||||
( (LibDrawSquare*) CurrentDrawItem )->m_Pos.x;
|
( (LibDrawSquare*) CurrentDrawItem )->m_Pos = newpos;
|
||||||
size.y = ( (LibDrawSquare*) CurrentDrawItem )->m_End.y -
|
( (LibDrawSquare*) CurrentDrawItem )->m_End = newpos + size;
|
||||||
( (LibDrawSquare*) CurrentDrawItem )->m_Pos.y;
|
|
||||||
( (LibDrawSquare*) CurrentDrawItem )->m_Pos.x = mx;
|
|
||||||
( (LibDrawSquare*) CurrentDrawItem )->m_Pos.y = -my;
|
|
||||||
( (LibDrawSquare*) CurrentDrawItem )->m_End.x = mx + size.x;
|
|
||||||
( (LibDrawSquare*) CurrentDrawItem )->m_End.y = -my + size.y;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPONENT_POLYLINE_DRAW_TYPE:
|
case COMPONENT_POLYLINE_DRAW_TYPE:
|
||||||
{
|
{
|
||||||
int ii, imax =
|
int ii, imax = ( (LibDrawPolyline*) CurrentDrawItem )->GetCornerCount();
|
||||||
( (LibDrawPolyline*) CurrentDrawItem )->m_CornersCount * 2;
|
wxPoint offset = newpos - ( (LibDrawPolyline*) CurrentDrawItem )->m_PolyPoints[0];
|
||||||
int* ptpoly = ( (LibDrawPolyline*) CurrentDrawItem )->m_PolyList;
|
|
||||||
int dx = mx - ptpoly[0];
|
|
||||||
int dy = -my - ptpoly[1];
|
|
||||||
for( ii = 0; ii < imax; ii += 2 )
|
for( ii = 0; ii < imax; ii += 2 )
|
||||||
{
|
( (LibDrawPolyline*) CurrentDrawItem )->m_PolyPoints[ii] += offset;
|
||||||
ptpoly[ii] += dx;
|
|
||||||
ptpoly[ii + 1] += dy;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -476,8 +458,7 @@ void MoveLibDrawItemAt( LibEDA_BaseStruct* DrawItem, wxPoint newpos )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
|
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
|
||||||
( (LibDrawText*) CurrentDrawItem )->m_Pos.x = mx;
|
( (LibDrawText*) CurrentDrawItem )->m_Pos = newpos;
|
||||||
( (LibDrawText*) CurrentDrawItem )->m_Pos.y = -my;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -513,9 +494,7 @@ void WinEDA_LibeditFrame::StartMoveDrawSymbol( wxDC* DC )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPONENT_POLYLINE_DRAW_TYPE:
|
case COMPONENT_POLYLINE_DRAW_TYPE:
|
||||||
InitPosition.x = *( (LibDrawPolyline*) CurrentDrawItem )->m_PolyList;
|
InitPosition = ( (LibDrawPolyline*) CurrentDrawItem )->m_PolyPoints[0];
|
||||||
InitPosition.y =
|
|
||||||
*( ( (LibDrawPolyline*) CurrentDrawItem )->m_PolyList + 1 );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPONENT_LINE_DRAW_TYPE:
|
case COMPONENT_LINE_DRAW_TYPE:
|
||||||
|
@ -543,11 +522,11 @@ void WinEDA_LibeditFrame::StartMoveDrawSymbol( wxDC* DC )
|
||||||
static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
||||||
{
|
{
|
||||||
int DrawMode = g_XorMode;
|
int DrawMode = g_XorMode;
|
||||||
int* ptpoly;
|
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
BASE_SCREEN* Screen = panel->GetScreen();
|
BASE_SCREEN* Screen = panel->GetScreen();
|
||||||
int mx = Screen->m_Curseur.x,
|
wxPoint curr_pos = Screen->m_Curseur;
|
||||||
my = Screen->m_Curseur.y;
|
|
||||||
|
NEGATE(curr_pos.y);
|
||||||
|
|
||||||
GRSetDrawMode( DC, DrawMode );
|
GRSetDrawMode( DC, DrawMode );
|
||||||
|
|
||||||
|
@ -589,7 +568,7 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
||||||
case COMPONENT_ARC_DRAW_TYPE:
|
case COMPONENT_ARC_DRAW_TYPE:
|
||||||
if( StateDrawArc == 1 )
|
if( StateDrawArc == 1 )
|
||||||
{
|
{
|
||||||
ArcEndX = mx; ArcEndY = -my;
|
ArcEndX = curr_pos.x; ArcEndY = curr_pos.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( StateDrawArc == 2 )
|
if( StateDrawArc == 2 )
|
||||||
|
@ -600,31 +579,28 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPONENT_CIRCLE_DRAW_TYPE:
|
case COMPONENT_CIRCLE_DRAW_TYPE:
|
||||||
dx = ( (LibDrawCircle*) CurrentDrawItem )->m_Pos.x - mx;
|
dx = ( (LibDrawCircle*) CurrentDrawItem )->m_Pos.x - curr_pos.x;
|
||||||
dy = ( (LibDrawCircle*) CurrentDrawItem )->m_Pos.y + my;
|
dy = ( (LibDrawCircle*) CurrentDrawItem )->m_Pos.y - curr_pos.y;
|
||||||
( (LibDrawCircle*) CurrentDrawItem )->m_Rayon =
|
( (LibDrawCircle*) CurrentDrawItem )->m_Rayon =
|
||||||
(int) sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) );
|
(int) sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) );
|
||||||
( (LibDrawCircle*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
|
( (LibDrawCircle*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPONENT_RECT_DRAW_TYPE:
|
case COMPONENT_RECT_DRAW_TYPE:
|
||||||
( (LibDrawSquare*) CurrentDrawItem )->m_End.x = mx;
|
( (LibDrawSquare*) CurrentDrawItem )->m_End = curr_pos;
|
||||||
( (LibDrawSquare*) CurrentDrawItem )->m_End.y = -my;
|
|
||||||
( (LibDrawSquare*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
|
( (LibDrawSquare*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPONENT_POLYLINE_DRAW_TYPE:
|
case COMPONENT_POLYLINE_DRAW_TYPE:
|
||||||
ptpoly = ( (LibDrawPolyline*) CurrentDrawItem )->m_PolyList;
|
{
|
||||||
ptpoly += 2 *
|
unsigned idx = ( (LibDrawPolyline*) CurrentDrawItem )->GetCornerCount() - 1;
|
||||||
( ( (LibDrawPolyline*) CurrentDrawItem )->m_CornersCount - 1 );
|
( (LibDrawPolyline*) CurrentDrawItem )->m_PolyPoints[idx] = curr_pos;
|
||||||
ptpoly[0] = mx;
|
|
||||||
ptpoly[1] = -my;
|
|
||||||
( (LibDrawPolyline*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
|
( (LibDrawPolyline*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPONENT_LINE_DRAW_TYPE:
|
case COMPONENT_LINE_DRAW_TYPE:
|
||||||
( (LibDrawSegment*) CurrentDrawItem )->m_End.x = mx;
|
( (LibDrawSegment*) CurrentDrawItem )->m_End = curr_pos;
|
||||||
( (LibDrawSegment*) CurrentDrawItem )->m_End.y = -my;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: /* Traite par des routines specifiques */
|
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: /* Traite par des routines specifiques */
|
||||||
|
@ -856,28 +832,24 @@ void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC )
|
||||||
if( CurrentDrawItem->Type() != COMPONENT_POLYLINE_DRAW_TYPE )
|
if( CurrentDrawItem->Type() != COMPONENT_POLYLINE_DRAW_TYPE )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int* ptpoly;
|
|
||||||
LibDrawPolyline* Poly = (LibDrawPolyline*) CurrentDrawItem;
|
LibDrawPolyline* Poly = (LibDrawPolyline*) CurrentDrawItem;
|
||||||
|
|
||||||
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
|
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
|
||||||
CurrentDrawItem, g_XorMode );
|
CurrentDrawItem, g_XorMode );
|
||||||
|
|
||||||
while( Poly->m_CornersCount > 2 ) // First segment is kept, only its end point is changed
|
while ( Poly->GetCornerCount() > 2 ) // First segment is kept, only its end point is changed
|
||||||
{
|
{
|
||||||
Poly->m_CornersCount--;
|
Poly->m_PolyPoints.pop_back();
|
||||||
ptpoly = Poly->m_PolyList + ( 2 * (Poly->m_CornersCount - 1) );
|
unsigned idx = Poly->GetCornerCount() - 1;
|
||||||
if( (ptpoly[0] != GetScreen()->m_Curseur.x)
|
wxPoint point = GetScreen()->m_Curseur;
|
||||||
|| (ptpoly[1] != -GetScreen()->m_Curseur.y) )
|
NEGATE( point.y );
|
||||||
|
if( Poly->m_PolyPoints[idx] != point )
|
||||||
{
|
{
|
||||||
ptpoly[0] = GetScreen()->m_Curseur.x;
|
Poly->m_PolyPoints[idx] = point;
|
||||||
ptpoly[1] = -( GetScreen()->m_Curseur.y);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int allocsize = 2 * sizeof(int) * Poly->m_CornersCount;
|
|
||||||
Poly->m_PolyList = (int*) realloc( Poly->m_PolyList, allocsize );
|
|
||||||
|
|
||||||
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
|
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
|
||||||
CurrentDrawItem, g_XorMode );
|
CurrentDrawItem, g_XorMode );
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,9 +270,6 @@ static bool CompareSymbols( LibEDA_BaseStruct* DEntryRef,
|
||||||
* TRUE si they are identical, and therefore redundant
|
* TRUE si they are identical, and therefore redundant
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int ii;
|
|
||||||
int* ptref, * ptcomp;
|
|
||||||
|
|
||||||
/* Comparaison des proprietes generales */
|
/* Comparaison des proprietes generales */
|
||||||
if( DEntryRef->Type() != DEntryCompare->Type() )
|
if( DEntryRef->Type() != DEntryCompare->Type() )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -349,15 +346,12 @@ static bool CompareSymbols( LibEDA_BaseStruct* DEntryRef,
|
||||||
#undef CMPSTRUCT
|
#undef CMPSTRUCT
|
||||||
#define REFSTRUCT ( (LibDrawPolyline*) DEntryRef )
|
#define REFSTRUCT ( (LibDrawPolyline*) DEntryRef )
|
||||||
#define CMPSTRUCT ( (LibDrawPolyline*) DEntryCompare )
|
#define CMPSTRUCT ( (LibDrawPolyline*) DEntryCompare )
|
||||||
if( REFSTRUCT->m_CornersCount != CMPSTRUCT->m_CornersCount )
|
if( REFSTRUCT->GetCornerCount() != CMPSTRUCT->GetCornerCount() )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
ptref = REFSTRUCT->m_PolyList;
|
for( unsigned ii = 0; ii < REFSTRUCT->GetCornerCount(); ii++ )
|
||||||
ptcomp = CMPSTRUCT->m_PolyList;
|
|
||||||
for( ii = 2 * REFSTRUCT->m_CornersCount; ii > 0; ii-- )
|
|
||||||
{
|
{
|
||||||
if( *ptref != *ptcomp )
|
if( REFSTRUCT->m_PolyPoints[ii] != CMPSTRUCT->m_PolyPoints[ii] )
|
||||||
return FALSE;
|
return false;
|
||||||
ptref++; ptcomp++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -440,14 +434,8 @@ void WinEDA_LibeditFrame::PlaceAncre()
|
||||||
case COMPONENT_POLYLINE_DRAW_TYPE:
|
case COMPONENT_POLYLINE_DRAW_TYPE:
|
||||||
#undef STRUCT
|
#undef STRUCT
|
||||||
#define STRUCT ( (LibDrawPolyline*) DrawEntry )
|
#define STRUCT ( (LibDrawPolyline*) DrawEntry )
|
||||||
int ii;
|
for( unsigned ii = 0; ii < STRUCT->GetCornerCount(); ii ++ )
|
||||||
int* ptsegm;
|
STRUCT->m_PolyPoints[ii] += offset;
|
||||||
for( ptsegm = STRUCT->m_PolyList,
|
|
||||||
ii = STRUCT->m_CornersCount; ii > 0; ii-- )
|
|
||||||
{
|
|
||||||
*ptsegm++ += offset.x;
|
|
||||||
*ptsegm++ += offset.y;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue