Component library editor improvements.

* Eliminate external direct manipulation of component draw item pointer.
* Add draw item remove, add, and locate methods to library component object.
* Remove redundant locate pin, field, and draw item code.
* Fix add new pin drawing bug that left initial pin draw in place.
* Improved best zoom calculations for small components.
* Library component bounding box calculation now includes fields.
* Removed unnecessary header file "libcmp.h".
* Fixed potential locate draw item bug in library editor hot key handler.
This commit is contained in:
stambaughw
2009-09-29 18:38:21 +00:00
parent d1e137d600
commit b762f6aab7
35 changed files with 775 additions and 907 deletions
+14 -95
View File
@@ -19,7 +19,6 @@
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
bool erase );
static void MirrorMarkedItems( LIB_COMPONENT* LibEntry, wxPoint offset );
/*
@@ -77,6 +76,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
{
int ItemCount = 0;
int MustDoPlace = 0;
wxPoint pt;
if( GetScreen()->m_BlockLocate.GetCount() )
{
@@ -147,7 +147,9 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
g_EditPinByPinIsOn );
if( ItemCount )
SaveCopyInUndoList( m_component );
MirrorMarkedItems( m_component, GetScreen()->m_BlockLocate.Centre() );
pt = GetScreen()->m_BlockLocate.Centre();
pt.y *= -1;
m_component->MirrorSelectedItemsH( pt );
break;
case BLOCK_ZOOM: /* Window Zoom */
@@ -191,7 +193,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
{
bool err = FALSE;
wxPoint offset;
wxPoint pt;
if( DrawPanel->ManageCurseur == NULL )
{
@@ -212,18 +214,18 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( m_component );
offset = GetScreen()->m_BlockLocate.m_MoveVector;
offset.y *= -1;
m_component->MoveSelectedItems( offset );
pt = GetScreen()->m_BlockLocate.m_MoveVector;
pt.y *= -1;
m_component->MoveSelectedItems( pt );
DrawPanel->Refresh( TRUE );
break;
case BLOCK_COPY: /* Copy */
GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( m_component );
offset = GetScreen()->m_BlockLocate.m_MoveVector;
offset.y *= -1;
m_component->CopySelectedItems( offset );
pt = GetScreen()->m_BlockLocate.m_MoveVector;
pt.y *= -1;
m_component->CopySelectedItems( pt );
break;
case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */
@@ -232,7 +234,9 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
case BLOCK_MIRROR_Y: /* Invert by popup menu, from block move */
SaveCopyInUndoList( m_component );
MirrorMarkedItems( m_component, GetScreen()->m_BlockLocate.Centre() );
pt = GetScreen()->m_BlockLocate.Centre();
pt.y *= -1;
m_component->MirrorSelectedItemsH( pt );
break;
case BLOCK_ZOOM: // Handled by HandleBlockEnd
@@ -305,88 +309,3 @@ void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
g_XorMode, -1, DefaultTransformMatrix,
true, true, true );
}
/*
* Mirror marked items, refer to a Vertical axis at position offset
*/
void MirrorMarkedItems( LIB_COMPONENT* LibEntry, wxPoint offset )
{
#define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x;
LIB_DRAW_ITEM* item;
if( LibEntry == NULL )
return;
offset.y = -offset.y; // Y axis for lib items is Down to Up: reverse y offset value
item = LibEntry->m_Drawings;
for( ; item != NULL; item = item->Next() )
{
if( item->m_Selected == 0 )
continue;
switch( item->Type() )
{
case COMPONENT_PIN_DRAW_TYPE:
SETMIRROR( ( (LibDrawPin*) item )->m_Pos.x );
switch( ( (LibDrawPin*) item )->m_Orient )
{
case PIN_RIGHT:
( (LibDrawPin*) item )->m_Orient = PIN_LEFT;
break;
case PIN_LEFT:
( (LibDrawPin*) item )->m_Orient = PIN_RIGHT;
break;
case PIN_UP:
case PIN_DOWN:
break;
}
break;
case COMPONENT_ARC_DRAW_TYPE:
{
SETMIRROR( ( (LibDrawArc*) item )->m_Pos.x );
SETMIRROR( ( (LibDrawArc*) item )->m_ArcStart.x );
SETMIRROR( ( (LibDrawArc*) item )->m_ArcEnd.x );
EXCHG( ( (LibDrawArc*) item )->m_ArcStart,
( (LibDrawArc*) item )->m_ArcEnd );
break;
}
case COMPONENT_CIRCLE_DRAW_TYPE:
SETMIRROR( ( (LibDrawCircle*) item )->m_Pos.x );
break;
case COMPONENT_RECT_DRAW_TYPE:
SETMIRROR( ( (LibDrawSquare*) item )->m_Pos.x );
SETMIRROR( ( (LibDrawSquare*) item )->m_End.x );
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
{
unsigned ii, imax = ( (LibDrawPolyline*) item )->GetCornerCount();
for( ii = 0; ii < imax; ii ++ )
{
SETMIRROR( ( (LibDrawPolyline*) item )->m_PolyPoints[ii].x );
}
}
break;
case COMPONENT_LINE_DRAW_TYPE:
break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
SETMIRROR( ( (LibDrawText*) item )->m_Pos.x );
break;
default:
break;
}
item->m_Flags = item->m_Selected = 0;
}
}