Component library editor improvements and minor bug fixes.

* Component library objects renamed for improved readability.
* Fields now move when selected in library editor.
* Add copy constructor to all library draw and library component objects.
* Added copy constructor to EDA_BaseStruct.
* Delete base screen in WinEDA_DrawFrame destructor to prevent potential memory leak.
* Fixed memory access bug when replacing and adding a component to library.
* Moved library component block manipulation code into component object.
* Removed all of the global variables used by the library editor main window object.
* The usual code cleaning and refactoring.
This commit is contained in:
stambaughw 2009-09-25 18:49:04 +00:00
parent fb52997c85
commit 8570d3311a
108 changed files with 1974 additions and 1742 deletions

View File

@ -41,6 +41,18 @@ EDA_BaseStruct::EDA_BaseStruct( KICAD_T idType )
} }
EDA_BaseStruct::EDA_BaseStruct( const EDA_BaseStruct& base )
{
m_StructType = base.m_StructType;
m_Parent = base.m_Parent;
m_Son = base.m_Son;
m_Flags = base.m_Flags;
m_TimeStamp = base.m_TimeStamp;
m_Status = base.m_Status;
m_Selected = base.m_Selected;
}
/********************************************/ /********************************************/
void EDA_BaseStruct::InitVars() void EDA_BaseStruct::InitVars()
/********************************************/ /********************************************/

View File

@ -108,10 +108,10 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype,
} }
/****************************************/
WinEDA_DrawFrame::~WinEDA_DrawFrame() WinEDA_DrawFrame::~WinEDA_DrawFrame()
/****************************************/
{ {
if( m_CurrentScreen != NULL )
delete m_CurrentScreen;
} }

View File

@ -101,7 +101,6 @@ set(EESCHEMA_SRCS
plotps.cpp plotps.cpp
plotdxf.cpp plotdxf.cpp
read_from_file_schematic_items_descriptions.cpp read_from_file_schematic_items_descriptions.cpp
savelib.cpp
save_schemas.cpp save_schemas.cpp
schedit.cpp schedit.cpp
schematic_undo_redo.cpp schematic_undo_redo.cpp

View File

@ -10,8 +10,9 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "wxstruct.h" #include "wxstruct.h"
#include "program.h" #include "program.h"
#include "libcmp.h" #include "class_library.h"
#include "protos.h" #include "protos.h"
#include "netlist.h" #include "netlist.h"

View File

@ -9,10 +9,10 @@
#include "confirm.h" #include "confirm.h"
#include "kicad_string.h" #include "kicad_string.h"
#include "gestfich.h" #include "gestfich.h"
#include "libcmp.h"
#include "general.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "general.h"
/* Variables Locales */ /* Variables Locales */
/*******************************************************************************************/ /*******************************************************************************************/

View File

@ -12,26 +12,31 @@
#include "block_commande.h" #include "block_commande.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "class_marker_sch.h" #include "class_marker_sch.h"
#include "class_library.h"
#include "protos.h" #include "protos.h"
/* Variables Locales */ /* Variables Locales */
// Imported functions: // Imported functions:
void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveVector ); void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList,
void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& Center ); const wxPoint aMoveVector );
void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList ); void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList,
void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveVector ); wxPoint& Center );
void DeleteItemsInList( WinEDA_DrawPanel* panel,
PICKED_ITEMS_LIST& aItemsList );
void DuplicateItemsInList( SCH_SCREEN* screen,
PICKED_ITEMS_LIST& aItemsList,
const wxPoint aMoveVector );
/* Fonctions exportees */ /* Fonctions exportees */
/* Fonctions Locales */ /* Fonctions Locales */
static void CollectStructsToDrag( SCH_SCREEN* screen ); static void CollectStructsToDrag( SCH_SCREEN* screen );
static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition ); static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition );
static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, static LIB_DRAW_ITEM* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
wxPoint& aPosition ); wxPoint& aPosition );
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel,
wxDC* DC, wxDC* DC,
@ -645,7 +650,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
if( Struct->Type() == TYPE_SCH_COMPONENT ) if( Struct->Type() == TYPE_SCH_COMPONENT )
{ {
// Add all pins of the selected component to list // Add all pins of the selected component to list
LibEDA_BaseStruct* DrawItem; LIB_DRAW_ITEM* DrawItem;
wxPoint pos; wxPoint pos;
DrawItem = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos ); DrawItem = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos );
while( DrawItem ) while( DrawItem )
@ -840,7 +845,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
/*********************************************************************************/ /*********************************************************************************/
static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, static LIB_DRAW_ITEM* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
wxPoint& aPosition ) wxPoint& aPosition )
/*********************************************************************************/ /*********************************************************************************/
@ -856,9 +861,9 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
*/ */
{ {
LIB_COMPONENT* Entry; LIB_COMPONENT* Entry;
static LibEDA_BaseStruct* NextItem; static LIB_DRAW_ITEM* NextItem;
static int Multi, convert, TransMat[2][2]; static int Multi, convert, TransMat[2][2];
LibEDA_BaseStruct* DEntry; LIB_DRAW_ITEM* DEntry;
int orient; int orient;
LibDrawPin* Pin; LibDrawPin* Pin;
static wxPoint CmpPosition; static wxPoint CmpPosition;

View File

@ -11,98 +11,15 @@
#include "block_commande.h" #include "block_commande.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "class_library.h"
#include "protos.h" #include "protos.h"
#include "libeditfrm.h" #include "libeditfrm.h"
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
bool erase ); bool erase );
static int MarkItemsInBloc( LIB_COMPONENT* LibComponent, static void MirrorMarkedItems( LIB_COMPONENT* LibEntry, wxPoint offset );
EDA_Rect& Rect );
static void ClearMarkItems( LIB_COMPONENT* LibComponent );
static void CopyMarkedItems( LIB_COMPONENT* LibEntry, wxPoint offset );
static void MoveMarkedItems( LIB_COMPONENT* LibEntry, wxPoint offset );
static void MirrorMarkedItems( LIB_COMPONENT* LibEntry,
wxPoint offset );
static void DeleteMarkedItems( LIB_COMPONENT* LibEntry );
void ClearMarkItems( LIB_COMPONENT* LibComponent )
{
LibEDA_BaseStruct* item;
if( LibComponent == NULL )
return;
item = LibComponent->m_Drawings;
for( ; item != NULL; item = item->Next() )
item->m_Flags = item->m_Selected = 0;
}
/*
* Mark items inside rect.
* Items are inside rect when an end point is inside rect
*
* Rules for convert drawings and other parts ( for multi part per package):
* - Commons are always marked
* - Specific graphic shapes must agree with the current displayed part and
* convert
* - Because most of pins are specific to current part and current convert:
* - if g_EditPinByPinIsOn == TRUE, or flag .m_UnitSelectionLocked == TRUE,
* only the pins specific to current part and current convert are marked
* - all specific to current convert pins are marked;
*/
int MarkItemsInBloc( LIB_COMPONENT* LibComponent,
EDA_Rect& Rect )
{
LibEDA_BaseStruct* item;
int ItemsCount = 0;
wxPoint pos;
bool ItemIsInOtherPart;
bool ItemIsInOtherConvert;
if( LibComponent == NULL )
return 0;
item = LibComponent->m_Drawings;
for( ; item != NULL; item = item->Next() )
{
item->m_Selected = 0;
// Do not consider other units or other convert items:
ItemIsInOtherPart = ItemIsInOtherConvert = FALSE;
if( item->m_Unit && (item->m_Unit != CurrentUnit) )
ItemIsInOtherPart = TRUE;
if( item->m_Convert && (item->m_Convert != CurrentConvert) )
ItemIsInOtherConvert = TRUE;
if( ItemIsInOtherPart || ItemIsInOtherConvert )
{
if( item->Type() == COMPONENT_PIN_DRAW_TYPE )
{ // Specific rules for pins:
if( g_EditPinByPinIsOn )
continue;
if( LibComponent->m_UnitSelectionLocked )
continue;
if( ItemIsInOtherConvert )
continue;
}
else
continue;
}
if( item->Inside( Rect ) )
{
item->m_Selected = IS_SELECTED;
ItemsCount++;
}
}
return ItemsCount;
}
/* /*
@ -158,7 +75,7 @@ int WinEDA_LibeditFrame::ReturnBlockCommand( int key )
*/ */
int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC ) int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
{ {
int ItemsCount = 0; int ItemCount = 0;
int MustDoPlace = 0; int MustDoPlace = 0;
if( GetScreen()->m_BlockLocate.GetCount() ) if( GetScreen()->m_BlockLocate.GetCount() )
@ -184,9 +101,10 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_DRAG: /* Drag */ case BLOCK_DRAG: /* Drag */
case BLOCK_MOVE: /* Move */ case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
ItemsCount = MarkItemsInBloc( m_currentComponent, ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate,
GetScreen()->m_BlockLocate ); m_unit, m_convert,
if( ItemsCount ) g_EditPinByPinIsOn );
if( ItemCount )
{ {
MustDoPlace = 1; MustDoPlace = 1;
if( DrawPanel->ManageCurseur != NULL ) if( DrawPanel->ManageCurseur != NULL )
@ -207,11 +125,12 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
break; break;
case BLOCK_DELETE: /* Delete */ case BLOCK_DELETE: /* Delete */
ItemsCount = MarkItemsInBloc( m_currentComponent, ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate,
GetScreen()->m_BlockLocate ); m_unit, m_convert,
if( ItemsCount ) g_EditPinByPinIsOn );
SaveCopyInUndoList( m_currentComponent ); if( ItemCount )
DeleteMarkedItems( m_currentComponent ); SaveCopyInUndoList( m_component );
m_component->DeleteSelectedItems();
break; break;
case BLOCK_SAVE: /* Save */ case BLOCK_SAVE: /* Save */
@ -223,12 +142,12 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_MIRROR_Y: case BLOCK_MIRROR_Y:
ItemsCount = MarkItemsInBloc( m_currentComponent, ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate,
GetScreen()->m_BlockLocate ); m_unit, m_convert,
if( ItemsCount ) g_EditPinByPinIsOn );
SaveCopyInUndoList( m_currentComponent ); if( ItemCount )
MirrorMarkedItems( m_currentComponent, SaveCopyInUndoList( m_component );
GetScreen()->m_BlockLocate.Centre() ); MirrorMarkedItems( m_component, GetScreen()->m_BlockLocate.Centre() );
break; break;
case BLOCK_ZOOM: /* Window Zoom */ case BLOCK_ZOOM: /* Window Zoom */
@ -245,9 +164,8 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
if( MustDoPlace <= 0 ) if( MustDoPlace <= 0 )
{ {
if( GetScreen()->m_BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY ) if( GetScreen()->m_BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY )
{ m_component->ClearSelectedItems();
ClearMarkItems( m_currentComponent );
}
GetScreen()->m_BlockLocate.m_Flags = 0; GetScreen()->m_BlockLocate.m_Flags = 0;
GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE; GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
@ -273,6 +191,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC ) void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
{ {
bool err = FALSE; bool err = FALSE;
wxPoint offset;
if( DrawPanel->ManageCurseur == NULL ) if( DrawPanel->ManageCurseur == NULL )
{ {
@ -292,17 +211,19 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
case BLOCK_MOVE: /* Move */ case BLOCK_MOVE: /* Move */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
GetScreen()->m_BlockLocate.ClearItemsList(); GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( m_currentComponent ); SaveCopyInUndoList( m_component );
MoveMarkedItems( m_currentComponent, offset = GetScreen()->m_BlockLocate.m_MoveVector;
GetScreen()->m_BlockLocate.m_MoveVector ); offset.y *= -1;
m_component->MoveSelectedItems( offset );
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
break; break;
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
GetScreen()->m_BlockLocate.ClearItemsList(); GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( m_currentComponent ); SaveCopyInUndoList( m_component );
CopyMarkedItems( m_currentComponent, offset = GetScreen()->m_BlockLocate.m_MoveVector;
GetScreen()->m_BlockLocate.m_MoveVector ); offset.y *= -1;
m_component->CopySelectedItems( offset );
break; break;
case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */ case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */
@ -310,9 +231,8 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
break; break;
case BLOCK_MIRROR_Y: /* Invert by popup menu, from block move */ case BLOCK_MIRROR_Y: /* Invert by popup menu, from block move */
SaveCopyInUndoList( m_currentComponent ); SaveCopyInUndoList( m_component );
MirrorMarkedItems( m_currentComponent, MirrorMarkedItems( m_component, GetScreen()->m_BlockLocate.Centre() );
GetScreen()->m_BlockLocate.Centre() );
break; break;
case BLOCK_ZOOM: // Handled by HandleBlockEnd case BLOCK_ZOOM: // Handled by HandleBlockEnd
@ -348,25 +268,27 @@ void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
BLOCK_SELECTOR* PtBlock; BLOCK_SELECTOR* PtBlock;
BASE_SCREEN* screen = panel->GetScreen(); BASE_SCREEN* screen = panel->GetScreen();
wxPoint move_offset; wxPoint move_offset;
PtBlock = &screen->m_BlockLocate; PtBlock = &screen->m_BlockLocate;
WinEDA_LibeditFrame* parent = ( WinEDA_LibeditFrame* ) panel->GetParent(); WinEDA_LibeditFrame* parent = ( WinEDA_LibeditFrame* ) panel->GetParent();
wxASSERT( parent != NULL ); wxASSERT( parent != NULL );
LIB_COMPONENT* component = parent->GetCurrentComponent(); LIB_COMPONENT* component = parent->GetComponent();
if( component == NULL ) if( component == NULL )
return; return;
int unit = parent->GetUnit();
int convert = parent->GetConvert();
if( erase ) if( erase )
{ {
PtBlock->Draw( panel, DC, PtBlock->m_MoveVector, g_XorMode, PtBlock->Draw( panel, DC, PtBlock->m_MoveVector, g_XorMode,
PtBlock->m_Color ); PtBlock->m_Color );
component->Draw( panel, DC, PtBlock->m_MoveVector, CurrentUnit, component->Draw( panel, DC, PtBlock->m_MoveVector, unit, convert,
CurrentConvert, g_XorMode, -1, DefaultTransformMatrix, g_XorMode, -1, DefaultTransformMatrix,
true, false, true ); true, true, true );
} }
/* Redessin nouvel affichage */ /* Redessin nouvel affichage */
@ -379,78 +301,9 @@ void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
PtBlock->Draw( panel, DC, PtBlock->m_MoveVector, g_XorMode, PtBlock->Draw( panel, DC, PtBlock->m_MoveVector, g_XorMode,
PtBlock->m_Color ); PtBlock->m_Color );
component->Draw( panel, DC, PtBlock->m_MoveVector, CurrentUnit, component->Draw( panel, DC, PtBlock->m_MoveVector, unit, convert,
CurrentConvert, g_XorMode, -1, DefaultTransformMatrix, g_XorMode, -1, DefaultTransformMatrix,
true, false, true ); true, true, true );
}
/*
* Copy marked items, at new position = old position + offset
*/
void CopyMarkedItems( LIB_COMPONENT* LibEntry, wxPoint offset )
{
LibEDA_BaseStruct* item;
if( LibEntry == NULL )
return;
item = LibEntry->m_Drawings;
for( ; item != NULL; item = item->Next() )
{
if( item->m_Selected == 0 )
continue;
item->m_Selected = 0;
LibEDA_BaseStruct* newitem = item->GenCopy();
newitem->m_Selected = IS_SELECTED;
newitem->SetNext( LibEntry->m_Drawings );
LibEntry->m_Drawings = newitem;
}
MoveMarkedItems( LibEntry, offset );
}
/*
* Move marked items, at new position = old position + offset
*/
void MoveMarkedItems( LIB_COMPONENT* LibEntry, wxPoint offset )
{
LibEDA_BaseStruct* item;
if( LibEntry == NULL )
return;
NEGATE( offset.y ); // Y axis for lib items is Down to Up: reverse y offset value
for( item = LibEntry->m_Drawings; item != NULL; item = item->Next() )
{
if( item->m_Selected == 0 )
continue;
item->SetOffset( offset );
item->m_Flags = item->m_Selected = 0;
}
}
/*
* Delete marked items
*/
void DeleteMarkedItems( LIB_COMPONENT* LibEntry )
{
LibEDA_BaseStruct* item, * next_item;
if( LibEntry == NULL )
return;
item = LibEntry->m_Drawings;
for( ; item != NULL; item = next_item )
{
next_item = item->Next();
if( item->m_Selected == 0 )
continue;
LibEntry->RemoveDrawItem( item );
}
} }
@ -460,7 +313,7 @@ void DeleteMarkedItems( LIB_COMPONENT* LibEntry )
void MirrorMarkedItems( LIB_COMPONENT* LibEntry, wxPoint offset ) void MirrorMarkedItems( LIB_COMPONENT* LibEntry, wxPoint offset )
{ {
#define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x; #define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x;
LibEDA_BaseStruct* item; LIB_DRAW_ITEM* item;
if( LibEntry == NULL ) if( LibEntry == NULL )
return; return;

View File

@ -14,17 +14,16 @@
#include "kicad_string.h" #include "kicad_string.h"
#include "gestfich.h" #include "gestfich.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "class_library.h"
#include "netlist.h" #include "netlist.h"
#include "protos.h"
#include "dialog_build_BOM.h" #include "dialog_build_BOM.h"
#include "protos.h"
/* object used in build BOM to handle the list of labels in schematic /* object used in build BOM to handle the list of labels in schematic
* because in a complex hierarchy, a label is used more than once, * because in a complex hierarchy, a label is used more than once,
* and had more than one sheet path, so we must create a flat list of labels * and had more than one sheet path, so we must create a flat list of labels

View File

@ -9,7 +9,7 @@
#include "confirm.h" #include "confirm.h"
#include "program.h" #include "program.h"
#include "libcmp.h" #include "classes_body_items.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"

View File

@ -10,7 +10,6 @@
#include "confirm.h" #include "confirm.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"

View File

@ -15,7 +15,7 @@
#include "trigo.h" #include "trigo.h"
#include "program.h" #include "program.h"
#include "libcmp.h" #include "classes_body_items.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
@ -23,7 +23,7 @@
LibDrawText::LibDrawText(LIB_COMPONENT * aParent) : LibDrawText::LibDrawText(LIB_COMPONENT * aParent) :
LibEDA_BaseStruct( COMPONENT_GRAPHIC_TEXT_DRAW_TYPE, aParent ), LIB_DRAW_ITEM( COMPONENT_GRAPHIC_TEXT_DRAW_TYPE, aParent ),
EDA_TextStruct() EDA_TextStruct()
{ {
m_Size = wxSize( 50, 50 ); m_Size = wxSize( 50, 50 );
@ -172,7 +172,7 @@ bool LibDrawText::HitTest( wxPoint aPosRef, int aThreshold,
} }
LibEDA_BaseStruct* LibDrawText::DoGenCopy() LIB_DRAW_ITEM* LibDrawText::DoGenCopy()
{ {
LibDrawText* newitem = new LibDrawText(NULL); LibDrawText* newitem = new LibDrawText(NULL);
@ -189,11 +189,11 @@ LibEDA_BaseStruct* LibDrawText::DoGenCopy()
newitem->m_Bold = m_Bold; newitem->m_Bold = m_Bold;
newitem->m_HJustify = m_HJustify; newitem->m_HJustify = m_HJustify;
newitem->m_VJustify = m_VJustify; newitem->m_VJustify = m_VJustify;
return (LibEDA_BaseStruct*) newitem; return (LIB_DRAW_ITEM*) newitem;
} }
bool LibDrawText::DoCompare( const LibEDA_BaseStruct& other ) const bool LibDrawText::DoCompare( const LIB_DRAW_ITEM& other ) const
{ {
wxASSERT( other.Type() == COMPONENT_GRAPHIC_TEXT_DRAW_TYPE ); wxASSERT( other.Type() == COMPONENT_GRAPHIC_TEXT_DRAW_TYPE );
@ -220,6 +220,12 @@ bool LibDrawText::DoTestInside( EDA_Rect& rect )
} }
void LibDrawText::DoMove( const wxPoint& newPosition )
{
m_Pos = newPosition;
}
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
@ -273,7 +279,7 @@ void LibDrawText::DisplayInfo( WinEDA_DrawFrame* frame )
{ {
wxString msg; wxString msg;
LibEDA_BaseStruct::DisplayInfo( frame ); LIB_DRAW_ITEM::DisplayInfo( frame );
msg = ReturnStringFromValue( g_UnitMetric, m_Width, msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true ); EESCHEMA_INTERNAL_UNIT, true );

View File

@ -19,7 +19,6 @@
#include "confirm.h" #include "confirm.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"

View File

@ -11,7 +11,6 @@
#include "common.h" #include "common.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"

View File

@ -18,7 +18,6 @@
#include "drawtxt.h" #include "drawtxt.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"

View File

@ -10,15 +10,16 @@
#include "gr_basic.h" #include "gr_basic.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "class_library.h"
#include "class_libentry.h"
int SortItemsFct(const void* ref, const void* item) int SortItemsFct(const void* ref, const void* item)
{ {
#define Ref ( *(LibEDA_BaseStruct**) (ref) ) #define Ref ( *(LIB_DRAW_ITEM**) (ref) )
#define Item ( *(LibEDA_BaseStruct**) (item) ) #define Item ( *(LIB_DRAW_ITEM**) (item) )
#define BEFORE -1 #define BEFORE -1
#define AFTER 1 #define AFTER 1
@ -168,6 +169,20 @@ CMP_LIB_ENTRY::CMP_LIB_ENTRY( LibrEntryType type, const wxString& name,
} }
CMP_LIB_ENTRY::CMP_LIB_ENTRY( const CMP_LIB_ENTRY& entry, CMP_LIBRARY* lib ) :
EDA_BaseStruct( entry )
{
Type = entry.Type;
m_Name = entry.m_Name;
m_Doc = entry.m_Doc;
m_KeyWord = entry.m_KeyWord;
m_DocFile = entry.m_DocFile;
m_Options = entry.m_Options;
m_lib = lib;
m_Name.SetParent( this );
}
CMP_LIB_ENTRY::~CMP_LIB_ENTRY() CMP_LIB_ENTRY::~CMP_LIB_ENTRY()
{ {
} }
@ -178,7 +193,43 @@ wxString CMP_LIB_ENTRY::GetLibraryName()
if( m_lib != NULL ) if( m_lib != NULL )
return m_lib->GetName(); return m_lib->GetName();
return wxEmptyString; return wxString( _( "none" ) );
}
/**
* Function SaveDoc
* writes the doc info out to a FILE in "*.dcm" format.
* Only non empty fields are written.
* If all fields are empty, does not write anything
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool CMP_LIB_ENTRY::SaveDoc( FILE* aFile )
{
if( m_Doc.IsEmpty() && m_KeyWord.IsEmpty() && m_DocFile.IsEmpty() )
return true;
/* Generation des lignes utiles */
if( fprintf( aFile, "#\n$CMP %s\n", CONV_TO_UTF8( m_Name.m_Text ) ) < 0 )
return false;
if( ! m_Doc.IsEmpty()
&& fprintf( aFile, "D %s\n", CONV_TO_UTF8( m_Doc ) ) < 0 )
return false;
if( ! m_KeyWord.IsEmpty()
&& fprintf( aFile, "K %s\n", CONV_TO_UTF8( m_KeyWord ) ) < 0 )
return false;
if( ! m_DocFile.IsEmpty()
&& fprintf( aFile, "F %s\n", CONV_TO_UTF8( m_DocFile ) ) < 0 )
return false;
if( fprintf( aFile, "$ENDCMP\n" ) < 0 )
return false;
return true;
} }
@ -223,6 +274,13 @@ LIB_ALIAS::LIB_ALIAS( const wxString& name, LIB_COMPONENT* root,
} }
LIB_ALIAS::LIB_ALIAS( const LIB_ALIAS& alias, CMP_LIBRARY* lib ) :
CMP_LIB_ENTRY( alias )
{
m_root = alias.m_root;
}
LIB_ALIAS::~LIB_ALIAS() LIB_ALIAS::~LIB_ALIAS()
{ {
} }
@ -258,10 +316,61 @@ LIB_COMPONENT::LIB_COMPONENT( const wxString& name, CMP_LIBRARY* lib ) :
} }
LIB_COMPONENT::LIB_COMPONENT( const LIB_COMPONENT& component,
CMP_LIBRARY* lib ) :
CMP_LIB_ENTRY( component, lib )
{
LIB_DRAW_ITEM* oldItem;
LIB_DRAW_ITEM* newItem;
LIB_DRAW_ITEM* lastItem = NULL;
LibDrawField* oldField;
LibDrawField* newField;
m_Prefix = component.m_Prefix;
m_AliasList = component.m_AliasList;
m_FootprintList = component.m_FootprintList;
m_UnitCount = component.m_UnitCount;
m_UnitSelectionLocked = component.m_UnitSelectionLocked;
m_TextInside = component.m_TextInside;
m_DrawPinNum = component.m_DrawPinNum;
m_DrawPinName = component.m_DrawPinName;
m_LastDate = component.m_LastDate;
m_Prefix.SetParent( this );
for( oldItem = component.m_Drawings; oldItem != NULL;
oldItem = oldItem->Next() )
{
if( ( oldItem->m_Flags & IS_NEW ) != 0 )
continue;
newItem = oldItem->GenCopy();
if( lastItem == NULL )
m_Drawings = newItem;
else
lastItem->SetNext( newItem );
newItem->SetParent( this );
lastItem = newItem;
newItem->SetNext( NULL );
}
for( oldField = component.m_Fields; oldField != NULL;
oldField = oldField->Next() )
{
newField = (LibDrawField*) oldField->GenCopy();
newField->SetParent( this );
m_Fields.PushBack( newField );
}
}
LIB_COMPONENT::~LIB_COMPONENT() LIB_COMPONENT::~LIB_COMPONENT()
{ {
LibEDA_BaseStruct* DrawItem; LIB_DRAW_ITEM* DrawItem;
LibEDA_BaseStruct* NextDrawItem; LIB_DRAW_ITEM* NextDrawItem;
/* suppression des elements dependants */ /* suppression des elements dependants */
DrawItem = m_Drawings; DrawItem = m_Drawings;
@ -285,7 +394,7 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* dc,
{ {
wxString fieldText; wxString fieldText;
LibDrawField* Field; LibDrawField* Field;
LibEDA_BaseStruct* drawItem; LIB_DRAW_ITEM* drawItem;
BASE_SCREEN* screen = panel->GetScreen(); BASE_SCREEN* screen = panel->GetScreen();
GRSetDrawMode( dc, drawMode ); GRSetDrawMode( dc, drawMode );
@ -303,7 +412,8 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* dc,
if( multi && drawItem->m_Unit && ( drawItem->m_Unit != multi ) ) if( multi && drawItem->m_Unit && ( drawItem->m_Unit != multi ) )
continue; continue;
if( convert && drawItem->m_Convert && ( drawItem->m_Convert != convert ) ) if( convert && drawItem->m_Convert
&& ( drawItem->m_Convert != convert ) )
continue; continue;
@ -346,12 +456,19 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* dc,
fieldText = m_Prefix.m_Text + wxT( "?" ); fieldText = m_Prefix.m_Text + wxT( "?" );
} }
if( !( onlySelected && m_Prefix.m_Selected == 0 ) )
m_Prefix.Draw( panel, dc, offset, color, drawMode, &fieldText, m_Prefix.Draw( panel, dc, offset, color, drawMode, &fieldText,
transformMatrix ); transformMatrix );
m_Name.Draw( panel, dc, offset, color, drawMode, NULL, transformMatrix );
if( !( onlySelected && m_Name.m_Selected == 0 ) )
m_Name.Draw( panel, dc, offset, color, drawMode, NULL,
transformMatrix );
for( Field = m_Fields; Field != NULL; Field = Field->Next() ) for( Field = m_Fields; Field != NULL; Field = Field->Next() )
{ {
if( onlySelected && drawItem->m_Selected == 0 )
continue;
Field->Draw( panel, dc, offset, color, drawMode, NULL, Field->Draw( panel, dc, offset, color, drawMode, NULL,
transformMatrix ); transformMatrix );
} }
@ -376,13 +493,13 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* dc,
} }
void LIB_COMPONENT::RemoveDrawItem( LibEDA_BaseStruct* item, void LIB_COMPONENT::RemoveDrawItem( LIB_DRAW_ITEM* item,
WinEDA_DrawPanel* panel, WinEDA_DrawPanel* panel,
wxDC* dc ) wxDC* dc )
{ {
wxASSERT( item != NULL ); wxASSERT( item != NULL );
LibEDA_BaseStruct* prevItem = m_Drawings; LIB_DRAW_ITEM* prevItem = m_Drawings;
if( dc != NULL ) if( dc != NULL )
item->Draw( panel, dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL, item->Draw( panel, dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL,
@ -417,11 +534,11 @@ void LIB_COMPONENT::RemoveDrawItem( LibEDA_BaseStruct* item,
*/ */
bool LIB_COMPONENT::Save( FILE* aFile ) bool LIB_COMPONENT::Save( FILE* aFile )
{ {
LibEDA_BaseStruct* DrawEntry; LIB_DRAW_ITEM* DrawEntry;
LibDrawField* Field; LibDrawField* Field;
if( Type != ROOT ) // should not happen, but just in case /* Sort just in clase sorting was not done properly. */
return false; SortDrawItems();
/* First line: it s a comment (component name for readers) */ /* First line: it s a comment (component name for readers) */
if( fprintf( aFile, "#\n# %s\n#\n", CONV_TO_UTF8( m_Name.m_Text ) ) < 0 ) if( fprintf( aFile, "#\n# %s\n#\n", CONV_TO_UTF8( m_Name.m_Text ) ) < 0 )
@ -656,9 +773,9 @@ bool LIB_COMPONENT::Load( FILE* file, char* line, int* lineNum,
bool LIB_COMPONENT::LoadDrawEntries( FILE* f, char* line, bool LIB_COMPONENT::LoadDrawEntries( FILE* f, char* line,
int* lineNum, wxString& errorMsg ) int* lineNum, wxString& errorMsg )
{ {
LibEDA_BaseStruct* newEntry = NULL; LIB_DRAW_ITEM* newEntry = NULL;
LibEDA_BaseStruct* headEntry = NULL; LIB_DRAW_ITEM* headEntry = NULL;
LibEDA_BaseStruct* tailEntry = NULL; LIB_DRAW_ITEM* tailEntry = NULL;
while( true ) while( true )
{ {
@ -676,31 +793,31 @@ bool LIB_COMPONENT::LoadDrawEntries( FILE* f, char* line,
switch( line[0] ) switch( line[0] )
{ {
case 'A': /* Arc */ case 'A': /* Arc */
newEntry = ( LibEDA_BaseStruct* ) new LibDrawArc(this); newEntry = ( LIB_DRAW_ITEM* ) new LibDrawArc(this);
break; break;
case 'C': /* Circle */ case 'C': /* Circle */
newEntry = ( LibEDA_BaseStruct* ) new LibDrawCircle(this); newEntry = ( LIB_DRAW_ITEM* ) new LibDrawCircle(this);
break; break;
case 'T': /* Text */ case 'T': /* Text */
newEntry = ( LibEDA_BaseStruct* ) new LibDrawText(this); newEntry = ( LIB_DRAW_ITEM* ) new LibDrawText(this);
break; break;
case 'S': /* Square */ case 'S': /* Square */
newEntry = ( LibEDA_BaseStruct* ) new LibDrawSquare(this); newEntry = ( LIB_DRAW_ITEM* ) new LibDrawSquare(this);
break; break;
case 'X': /* Pin Description */ case 'X': /* Pin Description */
newEntry = ( LibEDA_BaseStruct* ) new LibDrawPin(this); newEntry = ( LIB_DRAW_ITEM* ) new LibDrawPin(this);
break; break;
case 'P': /* Polyline */ case 'P': /* Polyline */
newEntry = ( LibEDA_BaseStruct* ) new LibDrawPolyline(this); newEntry = ( LIB_DRAW_ITEM* ) new LibDrawPolyline(this);
break; break;
case 'B': /* Bezier Curves */ case 'B': /* Bezier Curves */
newEntry = ( LibEDA_BaseStruct* ) new LibDrawBezier(this); newEntry = ( LIB_DRAW_ITEM* ) new LibDrawBezier(this);
break; break;
default: default:
@ -818,7 +935,7 @@ bool LIB_COMPONENT::LoadFootprints( FILE* file, char* line,
*/ */
void LIB_COMPONENT::SortDrawItems() void LIB_COMPONENT::SortDrawItems()
{ {
LibEDA_BaseStruct** Bufentry, ** BufentryBase, * Entry = m_Drawings; LIB_DRAW_ITEM** Bufentry, ** BufentryBase, * Entry = m_Drawings;
int ii, nbitems; int ii, nbitems;
if( Entry == NULL ) if( Entry == NULL )
@ -828,15 +945,15 @@ void LIB_COMPONENT::SortDrawItems()
nbitems++; nbitems++;
BufentryBase = BufentryBase =
(LibEDA_BaseStruct**) MyZMalloc( (nbitems + 1) * (LIB_DRAW_ITEM**) MyZMalloc( (nbitems + 1) *
sizeof(LibEDA_BaseStruct*) ); sizeof(LIB_DRAW_ITEM*) );
/* memorisation du chainage : */ /* memorisation du chainage : */
for( Entry = m_Drawings, ii = 0; Entry != NULL; Entry = Entry->Next() ) for( Entry = m_Drawings, ii = 0; Entry != NULL; Entry = Entry->Next() )
BufentryBase[ii++] = Entry; BufentryBase[ii++] = Entry;
/* Tri du chainage */ /* Tri du chainage */
qsort( BufentryBase, nbitems, sizeof(LibEDA_BaseStruct*), SortItemsFct ); qsort( BufentryBase, nbitems, sizeof(LIB_DRAW_ITEM*), SortItemsFct );
/* Mise a jour du chainage. Remarque: /* Mise a jour du chainage. Remarque:
* le dernier element de BufEntryBase (BufEntryBase[nbitems]) est NULL*/ * le dernier element de BufEntryBase (BufEntryBase[nbitems]) est NULL*/
@ -861,7 +978,7 @@ void LIB_COMPONENT::SortDrawItems()
/**********************************************************************/ /**********************************************************************/
EDA_Rect LIB_COMPONENT::GetBoundaryBox( int Unit, int Convert ) EDA_Rect LIB_COMPONENT::GetBoundaryBox( int Unit, int Convert )
{ {
LibEDA_BaseStruct* DrawEntry; LIB_DRAW_ITEM* DrawEntry;
EDA_Rect bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) ); EDA_Rect bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) );
for( DrawEntry = m_Drawings; DrawEntry != NULL; for( DrawEntry = m_Drawings; DrawEntry != NULL;
@ -982,7 +1099,7 @@ bool LIB_COMPONENT::LoadDateAndTime( char* Line )
void LIB_COMPONENT::SetOffset( const wxPoint& offset ) void LIB_COMPONENT::SetOffset( const wxPoint& offset )
{ {
LibEDA_BaseStruct* DrawEntry; LIB_DRAW_ITEM* DrawEntry;
m_Name.SetOffset( offset ); m_Name.SetOffset( offset );
m_Prefix.SetOffset( offset ); m_Prefix.SetOffset( offset );
@ -1004,8 +1121,8 @@ void LIB_COMPONENT::SetOffset( const wxPoint& offset )
void LIB_COMPONENT::RemoveDuplicateDrawItems() void LIB_COMPONENT::RemoveDuplicateDrawItems()
{ {
LibEDA_BaseStruct* DEntryRef; LIB_DRAW_ITEM* DEntryRef;
LibEDA_BaseStruct* DEntryCompare; LIB_DRAW_ITEM* DEntryCompare;
bool deleted; bool deleted;
DEntryRef = m_Drawings; DEntryRef = m_Drawings;
@ -1043,7 +1160,7 @@ void LIB_COMPONENT::RemoveDuplicateDrawItems()
bool LIB_COMPONENT::HasConversion() const bool LIB_COMPONENT::HasConversion() const
{ {
LibEDA_BaseStruct* entry; LIB_DRAW_ITEM* entry;
for( entry = m_Drawings; entry != NULL; entry = entry->Next() ) for( entry = m_Drawings; entry != NULL; entry = entry->Next() )
{ {
@ -1055,37 +1172,149 @@ bool LIB_COMPONENT::HasConversion() const
} }
/** int LIB_COMPONENT::SelectItems( EDA_Rect& rect, int unit, int convert,
* Function SaveDoc bool editPinByPin )
* writes the doc info out to a FILE in "*.dcm" format.
* Only non empty fields are written.
* If all fields are empty, does not write anything
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool CMP_LIB_ENTRY::SaveDoc( FILE* aFile )
{ {
if( m_Doc.IsEmpty() && m_KeyWord.IsEmpty() && m_DocFile.IsEmpty() ) LIB_DRAW_ITEM* item;
return true; int ItemsCount = 0;
/* Generation des lignes utiles */ for( item = m_Drawings; item != NULL; item = item->Next() )
if( fprintf( aFile, "#\n$CMP %s\n", CONV_TO_UTF8( m_Name.m_Text ) ) < 0 ) {
return false; item->m_Selected = 0;
if( ! m_Doc.IsEmpty() if( ( item->m_Unit && item->m_Unit != unit )
&& fprintf( aFile, "D %s\n", CONV_TO_UTF8( m_Doc ) ) < 0 ) || ( item->m_Convert && item->m_Convert != convert ) )
return false; {
if( item->Type() != COMPONENT_PIN_DRAW_TYPE )
continue;
if( ! m_KeyWord.IsEmpty() // Specific rules for pins.
&& fprintf( aFile, "K %s\n", CONV_TO_UTF8( m_KeyWord ) ) < 0 ) if( editPinByPin || m_UnitSelectionLocked
return false; || ( item->m_Convert && item->m_Convert != convert ) )
continue;
}
if( ! m_DocFile.IsEmpty() if( item->Inside( rect ) )
&& fprintf( aFile, "F %s\n", CONV_TO_UTF8( m_DocFile ) ) < 0 ) {
return false; item->m_Selected = IS_SELECTED;
ItemsCount++;
}
}
if( fprintf( aFile, "$ENDCMP\n" ) < 0 ) if( m_Name.Inside( rect ) )
return false; {
m_Name.m_Selected = IS_SELECTED;
ItemsCount++;
}
return true; if( m_Prefix.Inside( rect ) )
{
m_Prefix.m_Selected = IS_SELECTED;
ItemsCount++;
}
for( LibDrawField* field = m_Fields.GetFirst(); field != NULL;
field = field->Next() )
{
if( field->Inside( rect ) )
{
field->m_Selected = IS_SELECTED;
ItemsCount++;
}
}
return ItemsCount;
}
void LIB_COMPONENT::MoveSelectedItems( const wxPoint& offset )
{
LIB_DRAW_ITEM* item;
LibDrawField* field;
for( item = m_Drawings; item != NULL; item = item->Next() )
{
if( item->m_Selected == 0 )
continue;
item->SetOffset( offset );
item->m_Flags = item->m_Selected = 0;
}
if( m_Name.m_Selected )
{
m_Name.SetOffset( offset );
m_Name.m_Flags = m_Name.m_Selected = 0;
}
if( m_Prefix.m_Selected )
{
m_Prefix.SetOffset( offset );
m_Prefix.m_Flags = m_Prefix.m_Selected = 0;
}
for( field = m_Fields.GetFirst(); field != NULL; field = field->Next() )
{
if( field->m_Selected )
{
field->SetOffset( offset );
field->m_Flags = field->m_Selected = 0;
}
}
SortDrawItems();
}
void LIB_COMPONENT::ClearSelectedItems( void )
{
LIB_DRAW_ITEM* item;
LibDrawField* field;
for( item = m_Drawings; item != NULL; item = item->Next() )
item->m_Flags = item->m_Selected = 0;
m_Name.m_Flags = m_Name.m_Selected = 0;
m_Prefix.m_Flags = m_Prefix.m_Selected = 0;
for( field = m_Fields.GetFirst(); field != NULL; field = field->Next() )
field->m_Flags = field->m_Selected = 0;
}
void LIB_COMPONENT::DeleteSelectedItems( void )
{
LIB_DRAW_ITEM* item;
LIB_DRAW_ITEM* nextItem;
for( item = m_Drawings; item != NULL; item = nextItem )
{
nextItem = item->Next();
if( item->m_Selected == 0 )
continue;
RemoveDrawItem( item );
}
}
void LIB_COMPONENT::CopySelectedItems( const wxPoint& offset )
{
LIB_DRAW_ITEM* item;
for( item = m_Drawings; item != NULL; item = item->Next() )
{
if( item->m_Selected == 0 )
continue;
item->m_Selected = 0;
LIB_DRAW_ITEM* newItem = item->GenCopy();
newItem->m_Selected = IS_SELECTED;
newItem->SetNext( m_Drawings );
m_Drawings = newItem;
}
MoveSelectedItems( offset );
SortDrawItems();
} }

View File

@ -53,6 +53,8 @@ public:
public: public:
CMP_LIB_ENTRY( LibrEntryType CmpType, const wxString& name, CMP_LIB_ENTRY( LibrEntryType CmpType, const wxString& name,
CMP_LIBRARY* lib = NULL ); CMP_LIBRARY* lib = NULL );
CMP_LIB_ENTRY( const CMP_LIB_ENTRY& entry, CMP_LIBRARY* lib = NULL );
virtual ~CMP_LIB_ENTRY(); virtual ~CMP_LIB_ENTRY();
virtual wxString GetClass() const virtual wxString GetClass() const
@ -123,7 +125,7 @@ public:
bool m_DrawPinNum; bool m_DrawPinNum;
bool m_DrawPinName; bool m_DrawPinName;
DLIST<LibDrawField> m_Fields; /* Auxiliary Field list (id >= 2 ) */ DLIST<LibDrawField> m_Fields; /* Auxiliary Field list (id >= 2 ) */
LibEDA_BaseStruct* m_Drawings; /* How to draw this part */ LIB_DRAW_ITEM * m_Drawings; /* How to draw this part */
long m_LastDate; // Last change Date long m_LastDate; // Last change Date
public: public:
@ -134,6 +136,8 @@ public:
LIB_COMPONENT( const wxString& name, CMP_LIBRARY* lib = NULL ); LIB_COMPONENT( const wxString& name, CMP_LIBRARY* lib = NULL );
LIB_COMPONENT( const LIB_COMPONENT& component, CMP_LIBRARY* lib = NULL );
~LIB_COMPONENT(); ~LIB_COMPONENT();
EDA_Rect GetBoundaryBox( int Unit, int Convert ); EDA_Rect GetBoundaryBox( int Unit, int Convert );
@ -207,7 +211,7 @@ public:
* @param panel - Panel to remove part from. * @param panel - Panel to remove part from.
* @param dc - Device context to remove part from. * @param dc - Device context to remove part from.
*/ */
void RemoveDrawItem( LibEDA_BaseStruct* item, void RemoveDrawItem( LIB_DRAW_ITEM* item,
WinEDA_DrawPanel* panel = NULL, WinEDA_DrawPanel* panel = NULL,
wxDC* dc = NULL ); wxDC* dc = NULL );
@ -244,6 +248,52 @@ public:
wxASSERT( name != NULL ); wxASSERT( name != NULL );
return m_AliasList.Index( name ) != wxNOT_FOUND; return m_AliasList.Index( name ) != wxNOT_FOUND;
} }
/**
* Checks all draw objects of component to see if they are with block.
*
* Use this method to mark draw objects as selected during block
* functions.
*
* @param rect - The bounding rectangle to test in draw items are inside.
* @param unit - The current unit number to test against.
* @param convert - Are the draw items being selected a conversion.
* @param editPinByPin - Used to ignore pin selections when in edit pin
* by pin mode is enabled.
*
* @return int - The number of draw object found inside the block select
* rectangle.
*/
int SelectItems( EDA_Rect& rect, int unit, int convert,
bool editPinByPin );
/**
* Clears all the draw items marked by a block select.
*/
void ClearSelectedItems( void );
/**
* Deletes the select draw items marked by a block select.
*
* The name and reference field will not be deleted. They are the
* minimum drawing items required for any component. Thier properties
* can be changed but the cannot be removed.
*/
void DeleteSelectedItems( void );
/**
* Move the selected draw items marked by a block select.
*/
void MoveSelectedItems( const wxPoint& offset );
/**
* Make a copy of the selected draw items marked by a block select.
*
* Fields are not copied. Only component body items are copied.
* Copying fields would result in duplicate fields which does not
* make sense in this context.
*/
void CopySelectedItems( const wxPoint& offset );
}; };
@ -265,6 +315,7 @@ protected:
public: public:
LIB_ALIAS( const wxString& name, LIB_COMPONENT* root, LIB_ALIAS( const wxString& name, LIB_COMPONENT* root,
CMP_LIBRARY* lib = NULL ); CMP_LIBRARY* lib = NULL );
LIB_ALIAS( const LIB_ALIAS& alias, CMP_LIBRARY* lib = NULL );
~LIB_ALIAS(); ~LIB_ALIAS();
virtual wxString GetClass() const virtual wxString GetClass() const

View File

@ -10,10 +10,9 @@
#include "kicad_string.h" #include "kicad_string.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "class_libentry.h"
#include <wx/tokenzr.h> #include <wx/tokenzr.h>
#include <wx/stream.h> #include <wx/stream.h>
@ -39,19 +38,35 @@
* others = free fields * others = free fields
*/ */
LibDrawField::LibDrawField(LIB_COMPONENT * aParent, int idfield ) : LibDrawField::LibDrawField(LIB_COMPONENT * aParent, int idfield ) :
LibEDA_BaseStruct( COMPONENT_FIELD_DRAW_TYPE, aParent ) LIB_DRAW_ITEM( COMPONENT_FIELD_DRAW_TYPE, aParent )
{ {
m_FieldId = idfield; m_FieldId = idfield;
m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT; m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT;
} }
LibDrawField::LibDrawField( int idfield ) : LibDrawField::LibDrawField( int idfield ) :
LibEDA_BaseStruct( COMPONENT_FIELD_DRAW_TYPE, NULL ) LIB_DRAW_ITEM( COMPONENT_FIELD_DRAW_TYPE, NULL )
{ {
m_FieldId = idfield; m_FieldId = idfield;
m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT; m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT;
} }
LibDrawField::LibDrawField( const LibDrawField& field ) :
LIB_DRAW_ITEM( field )
{
m_Pos = field.m_Pos;
m_Size = field.m_Size;
m_Width = field.m_Width;
m_Orient = field.m_Orient;
m_Attributs = field.m_Attributs;
m_Text = field.m_Text;
m_Name = field.m_Name;
m_HJustify = field.m_HJustify;
m_VJustify = field.m_VJustify;
m_Italic = field.m_Italic;
m_Bold = field.m_Bold;
}
LibDrawField::~LibDrawField() LibDrawField::~LibDrawField()
{ {
@ -358,13 +373,13 @@ bool LibDrawField::HitTest( wxPoint aPosRef, int aThreshold,
} }
// Creation et Duplication d'un field // Creation et Duplication d'un field
LibEDA_BaseStruct* LibDrawField::DoGenCopy() LIB_DRAW_ITEM* LibDrawField::DoGenCopy()
{ {
LibDrawField* newfield = new LibDrawField( m_FieldId ); LibDrawField* newfield = new LibDrawField( m_FieldId );
Copy( newfield ); Copy( newfield );
return (LibEDA_BaseStruct*) newfield; return (LIB_DRAW_ITEM*) newfield;
} }
@ -389,7 +404,7 @@ void LibDrawField::Copy( LibDrawField* Target ) const
} }
bool LibDrawField::DoCompare( const LibEDA_BaseStruct& other ) const bool LibDrawField::DoCompare( const LIB_DRAW_ITEM& other ) const
{ {
wxASSERT( other.Type() == COMPONENT_FIELD_DRAW_TYPE ); wxASSERT( other.Type() == COMPONENT_FIELD_DRAW_TYPE );
@ -416,13 +431,19 @@ bool LibDrawField::DoTestInside( EDA_Rect& rect )
} }
void LibDrawField::DoMove( const wxPoint& newPosition )
{
m_Pos = newPosition;
}
/* /*
* If the field is the reference, return reference like schematic, * If the field is the reference, return reference like schematic,
* i.e U -> U? or U?A or the field text for others * i.e U -> U? or U?A or the field text for others
* *
* @fixme This should be handled by the field object. * @fixme This should be handled by the field object.
*/ */
wxString LibDrawField::GetFullText( void ) wxString LibDrawField::GetFullText( int unit )
{ {
if( m_FieldId != REFERENCE ) if( m_FieldId != REFERENCE )
return m_Text; return m_Text;
@ -433,11 +454,11 @@ wxString LibDrawField::GetFullText( void )
{ {
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
text.Printf( wxT( "%s?.%c" ), text.Printf( wxT( "%s?.%c" ),
m_Text.GetData(), CurrentUnit + '1' - 1 ); m_Text.GetData(), unit + '1' - 1 );
#else #else
text.Printf( wxT( "%s?%c" ), text.Printf( wxT( "%s?%c" ),
m_Text.GetData(), CurrentUnit + 'A' - 1 ); m_Text.GetData(), unit + 'A' - 1 );
#endif #endif
} }
else else

View File

@ -6,6 +6,9 @@
#define CLASS_LIBENTRY_FIELDS_H #define CLASS_LIBENTRY_FIELDS_H
#include "classes_body_items.h"
/* Fields , same as component fields. /* Fields , same as component fields.
* can be defined in libraries (mandatory for ref and value, ca be useful for * can be defined in libraries (mandatory for ref and value, ca be useful for
* footprints) * footprints)
@ -15,7 +18,7 @@
* default value in schematic * default value in schematic
*/ */
class LibDrawField : public LibEDA_BaseStruct, class LibDrawField : public LIB_DRAW_ITEM,
public EDA_TextStruct public EDA_TextStruct
{ {
public: public:
@ -36,6 +39,7 @@ public:
LibDrawField( int idfield = 2 ); LibDrawField( int idfield = 2 );
LibDrawField( LIB_COMPONENT * aParent, int idfield = 2 ); LibDrawField( LIB_COMPONENT * aParent, int idfield = 2 );
LibDrawField( const LibDrawField& field );
~LibDrawField(); ~LibDrawField();
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
@ -103,13 +107,26 @@ public:
m_Parent = field.m_Parent; m_Parent = field.m_Parent;
} }
wxString GetFullText( void ); /**
* Return the text of a field.
*
* If the field is the reference field, the unit number is used to
* create a pseudo reference text. If the base reference field is U,
* the string U?A will be returned for unit = 1.
*
* @param unit - The package unit number. Only effects reference field.
*
* @return wxString - Field text.
*/
wxString GetFullText( int unit = 1 );
protected: protected:
virtual LibEDA_BaseStruct* DoGenCopy(); virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const; virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset ); virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect ); virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; }
}; };
#endif // CLASS_LIBENTRY_FIELDS_H #endif // CLASS_LIBENTRY_FIELDS_H

View File

@ -11,7 +11,6 @@
#include "eda_doc.h" #include "eda_doc.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "class_library.h" #include "class_library.h"
@ -197,7 +196,7 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* cmp )
{ {
wxASSERT( cmp != NULL ); wxASSERT( cmp != NULL );
LIB_COMPONENT* newCmp = CopyLibEntryStruct( cmp ); LIB_COMPONENT* newCmp = new LIB_COMPONENT( *cmp, this );
if( newCmp == NULL ) if( newCmp == NULL )
return NULL; return NULL;
@ -387,7 +386,7 @@ in library <%s>." ),
RemoveEntry( oldComponent->GetName() ); RemoveEntry( oldComponent->GetName() );
LIB_COMPONENT* newCmp = CopyLibEntryStruct( newComponent ); LIB_COMPONENT* newCmp = new LIB_COMPONENT( *newComponent, this );
if( newCmp == NULL ) if( newCmp == NULL )
return NULL; return NULL;
@ -706,13 +705,12 @@ document file." ),
} }
bool CMP_LIBRARY::Save( const wxString& FullFileName ) bool CMP_LIBRARY::Save( const wxString& FullFileName, bool oldDocFormat )
{ {
FILE* libfile, *docfile; FILE* libfile;
wxString msg; wxString msg;
wxFileName libFileName = FullFileName; wxFileName libFileName = FullFileName;
wxFileName backupFileName = FullFileName; wxFileName backupFileName = FullFileName;
wxFileName docFileName = FullFileName;
/* the old .lib file is renamed .bak */ /* the old .lib file is renamed .bak */
if( libFileName.FileExists() ) if( libFileName.FileExists() )
@ -723,24 +721,8 @@ bool CMP_LIBRARY::Save( const wxString& FullFileName )
if( !wxRenameFile( libFileName.GetFullPath(), if( !wxRenameFile( libFileName.GetFullPath(),
backupFileName.GetFullPath() ) ) backupFileName.GetFullPath() ) )
{ {
msg = wxT( "Failed to rename old lib file " ) + libFileName.MakeAbsolute();
backupFileName.GetFullPath(); msg = wxT( "Failed to rename old component library file " ) +
DisplayError( NULL, msg );
}
}
docFileName.SetExt( DOC_EXT );
/* L'ancien fichier doc lib est renomme en .bck */
if( wxFileExists( docFileName.GetFullPath() ) )
{
backupFileName = docFileName;
backupFileName.SetExt( wxT( "bck" ) );
wxRemoveFile( backupFileName.GetFullPath() );
if( !wxRenameFile( docFileName.GetFullPath(),
backupFileName.GetFullPath() ) )
{
msg = wxT( "Failed to save old doc lib file " ) +
backupFileName.GetFullPath(); backupFileName.GetFullPath();
DisplayError( NULL, msg ); DisplayError( NULL, msg );
} }
@ -750,31 +732,22 @@ bool CMP_LIBRARY::Save( const wxString& FullFileName )
if( libfile == NULL ) if( libfile == NULL )
{ {
libFileName.MakeAbsolute();
msg = wxT( "Failed to create component library file " ) + msg = wxT( "Failed to create component library file " ) +
libFileName.GetFullPath(); libFileName.GetFullPath();
DisplayError( NULL, msg ); DisplayError( NULL, msg );
return false; return false;
} }
docfile = wxFopen( docFileName.GetFullPath(), wxT( "wt" ) );
if( docfile == NULL )
{
msg = wxT( "Failed to create component document library file " ) +
docFileName.GetFullPath();
DisplayError( NULL, msg );
}
m_IsModified = false; m_IsModified = false;
/* Creation de l'entete de la librairie */ /* Creation de l'entete de la librairie */
m_TimeStamp = GetTimeStamp(); m_TimeStamp = GetTimeStamp();
SaveHeader( libfile ); if( !SaveHeader( libfile ) )
{
/* Sauvegarde des composant: */ fclose( libfile );
char Line[256]; return false;
fprintf( docfile, "%s Date: %s\n", DOCFILE_IDENT, }
DateAndTime( Line ) );
bool success = true; bool success = true;
@ -783,21 +756,80 @@ bool CMP_LIBRARY::Save( const wxString& FullFileName )
if ( entry.Type == ROOT ) if ( entry.Type == ROOT )
{ {
LIB_COMPONENT* component = ( LIB_COMPONENT* ) &entry; LIB_COMPONENT* component = ( LIB_COMPONENT* ) &entry;
if ( ! component->Save( libfile ) ) if ( !component->Save( libfile ) )
success = false;
}
if ( docfile )
{
if ( ! entry.SaveDoc( docfile ) )
success = false; success = false;
} }
} }
fprintf( libfile, "#\n#End Library\n" ); if( fprintf( libfile, "#\n#End Library\n" ) < 0 )
if ( docfile ) success = false;
fprintf( docfile, "#\n#End Doc Library\n" );
fclose( libfile ); fclose( libfile );
if( USE_OLD_DOC_FILE_FORMAT( m_verMajor, m_verMinor ) && oldDocFormat )
success = SaveDocFile( FullFileName );
return success;
}
bool CMP_LIBRARY::SaveDocFile( const wxString& FullFileName )
{
FILE* docfile;
wxString msg;
wxFileName backupFileName = FullFileName;
wxFileName docFileName = FullFileName;
docFileName.SetExt( DOC_EXT );
/* Save current doc file as .bck */
if( docFileName.FileExists() )
{
backupFileName = docFileName;
backupFileName.SetExt( wxT( "bck" ) );
wxRemoveFile( backupFileName.GetFullPath() );
if( !wxRenameFile( docFileName.GetFullPath(),
backupFileName.GetFullPath() ) )
{
msg = wxT( "Failed to save old library document file " ) +
backupFileName.GetFullPath();
DisplayError( NULL, msg );
}
}
docfile = wxFopen( docFileName.GetFullPath(), wxT( "wt" ) );
if( docfile == NULL )
{
docFileName.MakeAbsolute();
msg = wxT( "Failed to create component document library file " ) +
docFileName.GetFullPath();
DisplayError( NULL, msg );
return false;
}
char Line[256];
if( fprintf( docfile, "%s Date: %s\n", DOCFILE_IDENT,
DateAndTime( Line ) ) < 0 )
{
fclose( docfile ); fclose( docfile );
return false;
}
bool success = true;
BOOST_FOREACH( CMP_LIB_ENTRY& entry, m_Entries )
{
if ( !entry.SaveDoc( docfile ) )
success = false;
}
if ( fprintf( docfile, "#\n#End Doc Library\n" ) < 0 )
success = false;
fclose( docfile );
return success; return success;
} }
@ -805,7 +837,7 @@ bool CMP_LIBRARY::Save( const wxString& FullFileName )
bool CMP_LIBRARY::SaveHeader( FILE* file ) bool CMP_LIBRARY::SaveHeader( FILE* file )
{ {
char BufLine[1024]; char BufLine[1024];
bool succes = false; bool succes = true;
DateAndTime( BufLine ); DateAndTime( BufLine );
if( fprintf( file, "%s %d.%d Date: %s\n", LIBFILE_IDENT, if( fprintf( file, "%s %d.%d Date: %s\n", LIBFILE_IDENT,
@ -844,6 +876,7 @@ CMP_LIBRARY* CMP_LIBRARY::LoadLibrary( const wxFileName& fileName,
return NULL; return NULL;
} }
if( USE_OLD_DOC_FILE_FORMAT( lib->m_verMajor, lib->m_verMinor ) )
lib->LoadDocs( errMsg ); lib->LoadDocs( errMsg );
return lib; return lib;

View File

@ -1,6 +1,6 @@
/***********************************/ /*********************************************/
/* Headers for library definition */ /* Headers for component library definition */
/***********************************/ /*********************************************/
#ifndef CLASS_LIBRARY_H #ifndef CLASS_LIBRARY_H
#define CLASS_LIBRARY_H #define CLASS_LIBRARY_H
@ -8,6 +8,37 @@
#include "class_libentry.h" #include "class_libentry.h"
/*
* Component Library version and file header macros.
*/
#define LIB_VERSION_MAJOR 2
#define LIB_VERSION_MINOR 3
/* Must be the first line of component library (.lib) files. */
#define LIBFILE_IDENT "EESchema-LIBRARY Version"
#define LIB_VERSION( major, minor ) ( major * 100 + minor )
#define IS_LIB_CURRENT_VERSION( major, minor ) \
( \
LIB_VERSION( major1, minor1 ) == \
LIB_VERSION( LIB_VERSION_MAJOR, LIB_VERSION_MINOR) \
)
/*
* Library versions 2.3 and lower use the old separate library (.lib) and
* document (.dcm) files. Component libraries after 2.3 merged the library
* and document files into a single library file. This macro checks if the
* library version supports the old format
*/
#define USE_OLD_DOC_FILE_FORMAT( major, minor ) \
( LIB_VERSION( major, minor ) <= LIB_VERSION( 2, 3 ) )
/* Must be the first line of component library document (.dcm) files. */
#define DOCFILE_IDENT "EESchema-DOCLIB Version 2.0"
#define DOC_EXT wxT( "dcm" )
/* Helpers for creating a list of component libraries. */ /* Helpers for creating a list of component libraries. */
class CMP_LIBRARY; class CMP_LIBRARY;
@ -43,17 +74,35 @@ public:
/** /**
* Save library to file. * Save library to file.
* *
* Two files are created. The component objects are save as component * Prior to component library version 3.0, two files were created. The
* library (*.lib) files. The alias objects are save as document * component objects are wer as component library (*.lib) files. The
* definition (*.dcm) files. If the component library already exists, * library entry ojbect document strings were save in library document
* it is backup up in file *.bak. If the document definition file * definition (*.dcm) files. After version component library version 3.0,
* already exists, it is backed up in file *.bck. * the document string information is saved as part of the library file.
* Saving separate document is maintained for backwards compatability.
* Please note that this behavior may change in the future. If the
* component library already exists, it is backup up in file *.bak.
*
* @param aFullFileName - The library filename with path.
* @param oldDocFormat - Save the document information in a separate
* file if true. The default is to save as the
* current library file format.
*
* @return bool - true if success writing else false.
*/
bool Save( const wxString& aFullFileName, bool oldDocFormat = false );
/**
* Save library document information to file.
*
* If the document definition file* already exists, it is backed up in
* file *.bck.
* *
* @param aFullFileName - The library filename with path. * @param aFullFileName - The library filename with path.
* *
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
bool Save( const wxString& aFullFileName ); bool SaveDocFile( const wxString& FullFileName );
/** /**
* Load library from file. * Load library from file.

View File

@ -6,7 +6,6 @@
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "class_netlist_object.h" #include "class_netlist_object.h"

View File

@ -12,10 +12,10 @@
#include "plot_common.h" #include "plot_common.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "libeditfrm.h" #include "libeditfrm.h"
#include "class_libentry.h"
const wxChar* MsgPinElectricType[] = const wxChar* MsgPinElectricType[] =
@ -34,7 +34,7 @@ const wxChar* MsgPinElectricType[] =
}; };
LibDrawPin::LibDrawPin(LIB_COMPONENT * aParent) : LibDrawPin::LibDrawPin(LIB_COMPONENT * aParent) :
LibEDA_BaseStruct( COMPONENT_PIN_DRAW_TYPE, aParent ) LIB_DRAW_ITEM( COMPONENT_PIN_DRAW_TYPE, aParent )
{ {
m_PinLen = 300; /* default Pin len */ m_PinLen = 300; /* default Pin len */
m_Orient = PIN_RIGHT; /* Pin oprient: Up, Down, Left, Right */ m_Orient = PIN_RIGHT; /* Pin oprient: Up, Down, Left, Right */
@ -53,6 +53,26 @@ LibDrawPin::LibDrawPin(LIB_COMPONENT * aParent) :
} }
LibDrawPin::LibDrawPin( const LibDrawPin& pin ) : LIB_DRAW_ITEM( pin )
{
m_Pos = pin.m_Pos;
m_PinLen = pin.m_PinLen;
m_Orient = pin.m_Orient;
m_PinShape = pin.m_PinShape;
m_PinType = pin.m_PinType;
m_Attributs = pin.m_Attributs;
m_PinNum = pin.m_PinNum;
m_PinNumSize = pin.m_PinNumSize;
m_PinNameSize = pin.m_PinNameSize;
m_PinNumShapeOpt = pin.m_PinNumShapeOpt;
m_PinNameShapeOpt = pin.m_PinNameShapeOpt;
m_PinNumPositionOpt = pin.m_PinNumPositionOpt;
m_PinNamePositionOpt = pin.m_PinNamePositionOpt;
m_Width = pin.m_Width;
m_PinName = pin.m_PinName;
}
/** /**
* Function HitTest * Function HitTest
* tests if the given wxPoint is within the bounds of this object. * tests if the given wxPoint is within the bounds of this object.
@ -1035,7 +1055,7 @@ void LibDrawPin::SetPinNumFromString( wxString& buffer )
/*************************************/ /*************************************/
LibEDA_BaseStruct* LibDrawPin::DoGenCopy() LIB_DRAW_ITEM* LibDrawPin::DoGenCopy()
/*************************************/ /*************************************/
{ {
LibDrawPin* newpin = new LibDrawPin( GetParent() ); LibDrawPin* newpin = new LibDrawPin( GetParent() );
@ -1059,11 +1079,11 @@ LibEDA_BaseStruct* LibDrawPin::DoGenCopy()
newpin->m_Width = m_Width; newpin->m_Width = m_Width;
newpin->m_PinName = m_PinName; newpin->m_PinName = m_PinName;
return (LibEDA_BaseStruct*) newpin; return (LIB_DRAW_ITEM*) newpin;
} }
bool LibDrawPin::DoCompare( const LibEDA_BaseStruct& other ) const bool LibDrawPin::DoCompare( const LIB_DRAW_ITEM& other ) const
{ {
wxASSERT( other.Type() == COMPONENT_PIN_DRAW_TYPE ); wxASSERT( other.Type() == COMPONENT_PIN_DRAW_TYPE );
@ -1087,6 +1107,12 @@ bool LibDrawPin::DoTestInside( EDA_Rect& rect )
} }
void LibDrawPin::DoMove( const wxPoint& newPosition )
{
m_Pos = newPosition;
}
/** Function LibDrawPin::DisplayInfo /** Function LibDrawPin::DisplayInfo
* Displays info (pin num and name, orientation ... * Displays info (pin num and name, orientation ...
* on the Info window * on the Info window
@ -1096,7 +1122,7 @@ void LibDrawPin::DisplayInfo( WinEDA_DrawFrame* frame )
wxString Text; wxString Text;
int ii; int ii;
LibEDA_BaseStruct::DisplayInfo( frame ); LIB_DRAW_ITEM::DisplayInfo( frame );
/* Affichage du nom */ /* Affichage du nom */
frame->MsgPanel->Affiche_1_Parametre( 30, _( "PinName" ), m_PinName, frame->MsgPanel->Affiche_1_Parametre( 30, _( "PinName" ), m_PinName,

View File

@ -16,13 +16,12 @@
#include "base_struct.h" #include "base_struct.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "drawtxt.h" #include "drawtxt.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "macros.h" #include "macros.h"
#include "program.h"
#include "general.h"
#include "protos.h" #include "protos.h"
#include "class_library.h"
SCH_CMP_FIELD::SCH_CMP_FIELD( const wxPoint& aPos, int aFieldId, SCH_CMP_FIELD::SCH_CMP_FIELD( const wxPoint& aPos, int aFieldId,

View File

@ -6,12 +6,12 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "common.h" #include "common.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "macros.h" #include "macros.h"
#include "protos.h" #include "protos.h"
#include "class_library.h"
#include <wx/tokenzr.h> #include <wx/tokenzr.h>

View File

@ -4,8 +4,8 @@
#include "common.h" #include "common.h"
#include "eeschema_id.h" #include "eeschema_id.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"

View File

@ -8,9 +8,7 @@
#include "common.h" #include "common.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
/* used to calculate the pen size from default value /* used to calculate the pen size from default value

View File

@ -11,7 +11,6 @@
#include "drawtxt.h" #include "drawtxt.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"

View File

@ -11,9 +11,9 @@
#include "bezier_curves.h" #include "bezier_curves.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "classes_body_items.h"
static int fill_tab[3] = { 'N', 'F', 'f' }; static int fill_tab[3] = { 'N', 'F', 'f' };
@ -22,8 +22,7 @@ static int fill_tab[3] = { 'N', 'F', 'f' };
/* Base class (abstract) for components bodies items */ /* Base class (abstract) for components bodies items */
LibEDA_BaseStruct::LibEDA_BaseStruct( KICAD_T struct_type, LIB_DRAW_ITEM::LIB_DRAW_ITEM( KICAD_T struct_type, LIB_COMPONENT* aParent ) :
LIB_COMPONENT* aParent ) :
EDA_BaseStruct( struct_type ) EDA_BaseStruct( struct_type )
{ {
m_Unit = 0; /* Unit identification (for multi part per package) m_Unit = 0; /* Unit identification (for multi part per package)
@ -31,11 +30,22 @@ LibEDA_BaseStruct::LibEDA_BaseStruct( KICAD_T struct_type,
m_Convert = 0; /* Shape identification (for parts which have a convert m_Convert = 0; /* Shape identification (for parts which have a convert
* shape) 0 if the item is common to all shapes */ * shape) 0 if the item is common to all shapes */
m_Fill = NO_FILL; m_Fill = NO_FILL;
m_Parent = aParent; m_Parent = (EDA_BaseStruct*) aParent;
m_typeName = _( "Undefined" ); m_typeName = _( "Undefined" );
} }
LIB_DRAW_ITEM::LIB_DRAW_ITEM( const LIB_DRAW_ITEM& item ) :
EDA_BaseStruct( item )
{
m_Unit = item.m_Unit;
m_Convert = item.m_Convert;
m_Fill = item.m_Fill;
m_Parent = item.m_Parent;
m_typeName = item.m_typeName;
}
/** /**
* Update the message panel information with the drawing information. * Update the message panel information with the drawing information.
* *
@ -43,7 +53,7 @@ LibEDA_BaseStruct::LibEDA_BaseStruct( KICAD_T struct_type,
* all library items. Call the base class from the derived class or the * all library items. Call the base class from the derived class or the
* common information will not be updated in the message panel. * common information will not be updated in the message panel.
*/ */
void LibEDA_BaseStruct::DisplayInfo( WinEDA_DrawFrame* frame ) void LIB_DRAW_ITEM::DisplayInfo( WinEDA_DrawFrame* frame )
{ {
wxString msg; wxString msg;
@ -70,7 +80,7 @@ void LibEDA_BaseStruct::DisplayInfo( WinEDA_DrawFrame* frame )
} }
bool LibEDA_BaseStruct::operator==( const LibEDA_BaseStruct& other ) const bool LIB_DRAW_ITEM::operator==( const LIB_DRAW_ITEM& other ) const
{ {
return ( ( Type() == other.Type() ) return ( ( Type() == other.Type() )
&& ( m_Unit == other.m_Unit ) && ( m_Unit == other.m_Unit )
@ -84,7 +94,7 @@ bool LibEDA_BaseStruct::operator==( const LibEDA_BaseStruct& other ) const
/**********************/ /**********************/
LibDrawArc::LibDrawArc( LIB_COMPONENT* aParent ) : LibDrawArc::LibDrawArc( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_ARC_DRAW_TYPE, aParent ) LIB_DRAW_ITEM( COMPONENT_ARC_DRAW_TYPE, aParent )
{ {
m_Radius = 0; m_Radius = 0;
m_t1 = 0; m_t1 = 0;
@ -95,6 +105,19 @@ LibDrawArc::LibDrawArc( LIB_COMPONENT* aParent ) :
} }
LibDrawArc::LibDrawArc( const LibDrawArc& arc ) : LIB_DRAW_ITEM( arc )
{
m_Radius = arc.m_Radius;
m_t1 = arc.m_t1;
m_t2 = arc.m_t2;
m_Width = arc.m_Width;
m_Fill = arc.m_Fill;
m_Pos = arc.m_Pos;
m_ArcStart = arc.m_ArcStart;
m_ArcEnd = arc.m_ArcEnd;
}
/** /**
* format: * format:
* A centre_posx centre_posy rayon start_angle end_angle unit convert * A centre_posx centre_posy rayon start_angle end_angle unit convert
@ -233,7 +256,7 @@ bool LibDrawArc::HitTest( wxPoint aRefPoint, int aThreshold,
} }
LibEDA_BaseStruct* LibDrawArc::DoGenCopy() LIB_DRAW_ITEM* LibDrawArc::DoGenCopy()
{ {
LibDrawArc* newitem = new LibDrawArc( GetParent() ); LibDrawArc* newitem = new LibDrawArc( GetParent() );
@ -249,11 +272,11 @@ LibEDA_BaseStruct* LibDrawArc::DoGenCopy()
newitem->m_Flags = m_Flags; newitem->m_Flags = m_Flags;
newitem->m_Fill = m_Fill; newitem->m_Fill = m_Fill;
return (LibEDA_BaseStruct*) newitem; return (LIB_DRAW_ITEM*) newitem;
} }
bool LibDrawArc::DoCompare( const LibEDA_BaseStruct& other ) const bool LibDrawArc::DoCompare( const LIB_DRAW_ITEM& other ) const
{ {
wxASSERT( other.Type() == COMPONENT_ARC_DRAW_TYPE ); wxASSERT( other.Type() == COMPONENT_ARC_DRAW_TYPE );
@ -279,6 +302,15 @@ bool LibDrawArc::DoTestInside( EDA_Rect& rect )
} }
void LibDrawArc::DoMove( const wxPoint& newPosition )
{
wxPoint offset = newPosition - m_Pos;
m_Pos = newPosition;
m_ArcStart += offset;
m_ArcEnd += offset;
}
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
@ -419,7 +451,7 @@ void LibDrawArc::DisplayInfo( WinEDA_DrawFrame* frame )
wxString msg; wxString msg;
EDA_Rect bBox = GetBoundingBox(); EDA_Rect bBox = GetBoundingBox();
LibEDA_BaseStruct::DisplayInfo( frame ); LIB_DRAW_ITEM::DisplayInfo( frame );
msg = ReturnStringFromValue( g_UnitMetric, m_Width, msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true ); EESCHEMA_INTERNAL_UNIT, true );
@ -438,7 +470,7 @@ void LibDrawArc::DisplayInfo( WinEDA_DrawFrame* frame )
/*************************/ /*************************/
LibDrawCircle::LibDrawCircle( LIB_COMPONENT* aParent ) : LibDrawCircle::LibDrawCircle( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_CIRCLE_DRAW_TYPE, aParent ) LIB_DRAW_ITEM( COMPONENT_CIRCLE_DRAW_TYPE, aParent )
{ {
m_Radius = 0; m_Radius = 0;
m_Fill = NO_FILL; m_Fill = NO_FILL;
@ -446,6 +478,15 @@ LibDrawCircle::LibDrawCircle( LIB_COMPONENT* aParent ) :
} }
LibDrawCircle::LibDrawCircle( const LibDrawCircle& circle ) :
LIB_DRAW_ITEM( circle )
{
m_Pos = circle.m_Pos;
m_Radius = circle.m_Radius;
m_Fill = circle.m_Fill;
}
bool LibDrawCircle::Save( FILE* ExportFile ) const bool LibDrawCircle::Save( FILE* ExportFile ) const
{ {
if( fprintf( ExportFile, "C %d %d %d %d %d %d %c\n", m_Pos.x, m_Pos.y, if( fprintf( ExportFile, "C %d %d %d %d %d %d %c\n", m_Pos.x, m_Pos.y,
@ -519,7 +560,7 @@ bool LibDrawCircle::HitTest( wxPoint aPosRef, int aThreshold,
} }
LibEDA_BaseStruct* LibDrawCircle::DoGenCopy() LIB_DRAW_ITEM* LibDrawCircle::DoGenCopy()
{ {
LibDrawCircle* newitem = new LibDrawCircle( GetParent() ); LibDrawCircle* newitem = new LibDrawCircle( GetParent() );
@ -531,11 +572,11 @@ LibEDA_BaseStruct* LibDrawCircle::DoGenCopy()
newitem->m_Flags = m_Flags; newitem->m_Flags = m_Flags;
newitem->m_Fill = m_Fill; newitem->m_Fill = m_Fill;
return (LibEDA_BaseStruct*) newitem; return (LIB_DRAW_ITEM*) newitem;
} }
bool LibDrawCircle::DoCompare( const LibEDA_BaseStruct& other ) const bool LibDrawCircle::DoCompare( const LIB_DRAW_ITEM& other ) const
{ {
wxASSERT( other.Type() == COMPONENT_CIRCLE_DRAW_TYPE ); wxASSERT( other.Type() == COMPONENT_CIRCLE_DRAW_TYPE );
@ -561,6 +602,12 @@ bool LibDrawCircle::DoTestInside( EDA_Rect& rect )
} }
void LibDrawCircle::DoMove( const wxPoint& newPosition )
{
m_Pos = newPosition;
}
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
@ -623,7 +670,7 @@ void LibDrawCircle::DisplayInfo( WinEDA_DrawFrame* frame )
wxString msg; wxString msg;
EDA_Rect bBox = GetBoundingBox(); EDA_Rect bBox = GetBoundingBox();
LibEDA_BaseStruct::DisplayInfo( frame ); LIB_DRAW_ITEM::DisplayInfo( frame );
msg = ReturnStringFromValue( g_UnitMetric, m_Width, msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true ); EESCHEMA_INTERNAL_UNIT, true );
@ -646,7 +693,7 @@ void LibDrawCircle::DisplayInfo( WinEDA_DrawFrame* frame )
/*************************/ /*************************/
LibDrawSquare::LibDrawSquare( LIB_COMPONENT* aParent ) : LibDrawSquare::LibDrawSquare( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_RECT_DRAW_TYPE, aParent ) LIB_DRAW_ITEM( COMPONENT_RECT_DRAW_TYPE, aParent )
{ {
m_Width = 0; m_Width = 0;
m_Fill = NO_FILL; m_Fill = NO_FILL;
@ -654,6 +701,16 @@ LibDrawSquare::LibDrawSquare( LIB_COMPONENT* aParent ) :
} }
LibDrawSquare::LibDrawSquare( const LibDrawSquare& rect ) :
LIB_DRAW_ITEM( rect )
{
m_Pos = rect.m_Pos;
m_End = rect.m_End;
m_Width = rect.m_Width;
m_Fill = rect.m_Fill;
}
bool LibDrawSquare::Save( FILE* ExportFile ) const bool LibDrawSquare::Save( FILE* ExportFile ) const
{ {
if( fprintf( ExportFile, "S %d %d %d %d %d %d %d %c\n", m_Pos.x, m_Pos.y, if( fprintf( ExportFile, "S %d %d %d %d %d %d %d %c\n", m_Pos.x, m_Pos.y,
@ -689,7 +746,7 @@ bool LibDrawSquare::Load( char* line, wxString& errorMsg )
} }
LibEDA_BaseStruct* LibDrawSquare::DoGenCopy() LIB_DRAW_ITEM* LibDrawSquare::DoGenCopy()
{ {
LibDrawSquare* newitem = new LibDrawSquare( GetParent() ); LibDrawSquare* newitem = new LibDrawSquare( GetParent() );
@ -701,11 +758,11 @@ LibEDA_BaseStruct* LibDrawSquare::DoGenCopy()
newitem->m_Flags = m_Flags; newitem->m_Flags = m_Flags;
newitem->m_Fill = m_Fill; newitem->m_Fill = m_Fill;
return (LibEDA_BaseStruct*) newitem; return (LIB_DRAW_ITEM*) newitem;
} }
bool LibDrawSquare::DoCompare( const LibEDA_BaseStruct& other ) const bool LibDrawSquare::DoCompare( const LIB_DRAW_ITEM& other ) const
{ {
wxASSERT( other.Type() == COMPONENT_RECT_DRAW_TYPE ); wxASSERT( other.Type() == COMPONENT_RECT_DRAW_TYPE );
@ -728,6 +785,14 @@ bool LibDrawSquare::DoTestInside( EDA_Rect& rect )
} }
void LibDrawSquare::DoMove( const wxPoint& newPosition )
{
wxPoint size = m_End - m_Pos;
m_Pos = newPosition;
m_End = newPosition + size;
}
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
@ -778,7 +843,7 @@ void LibDrawSquare::DisplayInfo( WinEDA_DrawFrame* frame )
{ {
wxString msg; wxString msg;
LibEDA_BaseStruct::DisplayInfo( frame ); LIB_DRAW_ITEM::DisplayInfo( frame );
msg = ReturnStringFromValue( g_UnitMetric, m_Width, msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true ); EESCHEMA_INTERNAL_UNIT, true );
@ -864,13 +929,22 @@ bool LibDrawSquare::HitTest( wxPoint aRefPoint, int aThreshold,
/** class LibDrawSegment **/ /** class LibDrawSegment **/
/**************************/ /**************************/
LibDrawSegment::LibDrawSegment( LIB_COMPONENT* aParent ) : LibDrawSegment::LibDrawSegment( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_LINE_DRAW_TYPE, aParent ) LIB_DRAW_ITEM( COMPONENT_LINE_DRAW_TYPE, aParent )
{ {
m_Width = 0; m_Width = 0;
m_typeName = _( "Segment" ); m_typeName = _( "Segment" );
} }
LibDrawSegment::LibDrawSegment( const LibDrawSegment& segment ) :
LIB_DRAW_ITEM( segment )
{
m_Pos = segment.m_Pos;
m_End = segment.m_End;
m_Width = segment.m_Width;
}
bool LibDrawSegment::Save( FILE* ExportFile ) const bool LibDrawSegment::Save( FILE* ExportFile ) const
{ {
if( fprintf( ExportFile, "L %d %d %d", m_Unit, m_Convert, m_Width ) ) if( fprintf( ExportFile, "L %d %d %d", m_Unit, m_Convert, m_Width ) )
@ -886,7 +960,7 @@ bool LibDrawSegment::Load( char* line, wxString& errorMsg )
} }
LibEDA_BaseStruct* LibDrawSegment::DoGenCopy() LIB_DRAW_ITEM* LibDrawSegment::DoGenCopy()
{ {
LibDrawSegment* newitem = new LibDrawSegment( GetParent() ); LibDrawSegment* newitem = new LibDrawSegment( GetParent() );
@ -897,11 +971,11 @@ LibEDA_BaseStruct* LibDrawSegment::DoGenCopy()
newitem->m_Convert = m_Convert; newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags; newitem->m_Flags = m_Flags;
return (LibEDA_BaseStruct*) newitem; return (LIB_DRAW_ITEM*) newitem;
} }
bool LibDrawSegment::DoCompare( const LibEDA_BaseStruct& other ) const bool LibDrawSegment::DoCompare( const LIB_DRAW_ITEM& other ) const
{ {
wxASSERT( other.Type() == COMPONENT_LINE_DRAW_TYPE ); wxASSERT( other.Type() == COMPONENT_LINE_DRAW_TYPE );
@ -924,6 +998,14 @@ bool LibDrawSegment::DoTestInside( EDA_Rect& rect )
} }
void LibDrawSegment::DoMove( const wxPoint& newPosition )
{
wxPoint offset = newPosition - m_Pos;
m_Pos += offset;
m_End += offset;
}
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
@ -963,7 +1045,7 @@ void LibDrawSegment::DisplayInfo( WinEDA_DrawFrame* frame )
wxString msg; wxString msg;
EDA_Rect bBox = GetBoundingBox(); EDA_Rect bBox = GetBoundingBox();
LibEDA_BaseStruct::DisplayInfo( frame ); LIB_DRAW_ITEM::DisplayInfo( frame );
msg = ReturnStringFromValue( g_UnitMetric, m_Width, msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true ); EESCHEMA_INTERNAL_UNIT, true );
@ -1016,7 +1098,7 @@ bool LibDrawSegment::HitTest( wxPoint aPosRef, int aThreshold,
/** class LibDrawPolyline **/ /** class LibDrawPolyline **/
/***************************/ /***************************/
LibDrawPolyline::LibDrawPolyline( LIB_COMPONENT* aParent ) : LibDrawPolyline::LibDrawPolyline( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_POLYLINE_DRAW_TYPE, aParent ) LIB_DRAW_ITEM( COMPONENT_POLYLINE_DRAW_TYPE, aParent )
{ {
m_Fill = NO_FILL; m_Fill = NO_FILL;
m_Width = 0; m_Width = 0;
@ -1024,6 +1106,15 @@ LibDrawPolyline::LibDrawPolyline( LIB_COMPONENT* aParent ) :
} }
LibDrawPolyline::LibDrawPolyline( const LibDrawPolyline& polyline ) :
LIB_DRAW_ITEM( polyline )
{
m_PolyPoints = polyline.m_PolyPoints; // Vector copy
m_Width = polyline.m_Width;
m_Fill = polyline.m_Fill;
}
bool LibDrawPolyline::Save( FILE* ExportFile ) const bool LibDrawPolyline::Save( FILE* ExportFile ) const
{ {
int ccount = GetCornerCount(); int ccount = GetCornerCount();
@ -1106,7 +1197,7 @@ bool LibDrawPolyline::Load( char* line, wxString& errorMsg )
} }
LibEDA_BaseStruct* LibDrawPolyline::DoGenCopy() LIB_DRAW_ITEM* LibDrawPolyline::DoGenCopy()
{ {
LibDrawPolyline* newitem = new LibDrawPolyline( GetParent() ); LibDrawPolyline* newitem = new LibDrawPolyline( GetParent() );
@ -1117,11 +1208,11 @@ LibEDA_BaseStruct* LibDrawPolyline::DoGenCopy()
newitem->m_Flags = m_Flags; newitem->m_Flags = m_Flags;
newitem->m_Fill = m_Fill; newitem->m_Fill = m_Fill;
return (LibEDA_BaseStruct*) newitem; return (LIB_DRAW_ITEM*) newitem;
} }
bool LibDrawPolyline::DoCompare( const LibEDA_BaseStruct& other ) const bool LibDrawPolyline::DoCompare( const LIB_DRAW_ITEM& other ) const
{ {
wxASSERT( other.Type() == COMPONENT_POLYLINE_DRAW_TYPE ); wxASSERT( other.Type() == COMPONENT_POLYLINE_DRAW_TYPE );
@ -1158,6 +1249,12 @@ bool LibDrawPolyline::DoTestInside( EDA_Rect& rect )
} }
void LibDrawPolyline::DoMove( const wxPoint& newPosition )
{
DoOffset( newPosition - m_PolyPoints[0] );
}
void LibDrawPolyline::AddPoint( const wxPoint& point ) void LibDrawPolyline::AddPoint( const wxPoint& point )
{ {
m_PolyPoints.push_back( point ); m_PolyPoints.push_back( point );
@ -1304,7 +1401,7 @@ void LibDrawPolyline::DisplayInfo( WinEDA_DrawFrame* frame )
wxString msg; wxString msg;
EDA_Rect bBox = GetBoundingBox(); EDA_Rect bBox = GetBoundingBox();
LibEDA_BaseStruct::DisplayInfo( frame ); LIB_DRAW_ITEM::DisplayInfo( frame );
msg = ReturnStringFromValue( g_UnitMetric, m_Width, msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true ); EESCHEMA_INTERNAL_UNIT, true );
@ -1321,7 +1418,7 @@ void LibDrawPolyline::DisplayInfo( WinEDA_DrawFrame* frame )
/** class LibDrawBezier **/ /** class LibDrawBezier **/
/***************************/ /***************************/
LibDrawBezier::LibDrawBezier( LIB_COMPONENT* aParent ) : LibDrawBezier::LibDrawBezier( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_BEZIER_DRAW_TYPE, aParent ) LIB_DRAW_ITEM( COMPONENT_BEZIER_DRAW_TYPE, aParent )
{ {
m_Fill = NO_FILL; m_Fill = NO_FILL;
m_Width = 0; m_Width = 0;
@ -1329,6 +1426,16 @@ LibDrawBezier::LibDrawBezier( LIB_COMPONENT* aParent ) :
} }
LibDrawBezier::LibDrawBezier( const LibDrawBezier& bezier ) :
LIB_DRAW_ITEM( bezier )
{
m_PolyPoints = bezier.m_PolyPoints;
m_BezierPoints = bezier.m_BezierPoints; // Vector copy
m_Width = bezier.m_Width;
m_Fill = bezier.m_Fill;
}
bool LibDrawBezier::Save( FILE* ExportFile ) const bool LibDrawBezier::Save( FILE* ExportFile ) const
{ {
int ccount = GetCornerCount(); int ccount = GetCornerCount();
@ -1410,7 +1517,7 @@ bool LibDrawBezier::Load( char* line, wxString& errorMsg )
} }
LibEDA_BaseStruct* LibDrawBezier::DoGenCopy() LIB_DRAW_ITEM* LibDrawBezier::DoGenCopy()
{ {
LibDrawBezier* newitem = new LibDrawBezier(GetParent()); LibDrawBezier* newitem = new LibDrawBezier(GetParent());
@ -1420,11 +1527,11 @@ LibEDA_BaseStruct* LibDrawBezier::DoGenCopy()
newitem->m_Convert = m_Convert; newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags; newitem->m_Flags = m_Flags;
newitem->m_Fill = m_Fill; newitem->m_Fill = m_Fill;
return (LibEDA_BaseStruct*) newitem; return (LIB_DRAW_ITEM*) newitem;
} }
bool LibDrawBezier::DoCompare( const LibEDA_BaseStruct& other ) const bool LibDrawBezier::DoCompare( const LIB_DRAW_ITEM& other ) const
{ {
wxASSERT( other.Type() == COMPONENT_BEZIER_DRAW_TYPE ); wxASSERT( other.Type() == COMPONENT_BEZIER_DRAW_TYPE );
@ -1467,6 +1574,12 @@ bool LibDrawBezier::DoTestInside( EDA_Rect& rect )
} }
void LibDrawBezier::DoMove( const wxPoint& newPosition )
{
DoOffset( newPosition - m_PolyPoints[0] );
}
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
@ -1597,7 +1710,7 @@ void LibDrawBezier::DisplayInfo( WinEDA_DrawFrame* frame )
wxString msg; wxString msg;
EDA_Rect bBox = GetBoundingBox(); EDA_Rect bBox = GetBoundingBox();
LibEDA_BaseStruct::DisplayInfo( frame ); LIB_DRAW_ITEM::DisplayInfo( frame );
msg = ReturnStringFromValue( g_UnitMetric, m_Width, msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true ); EESCHEMA_INTERNAL_UNIT, true );

View File

@ -7,6 +7,11 @@
#ifndef CLASSES_BODY_ITEMS_H #ifndef CLASSES_BODY_ITEMS_H
#define CLASSES_BODY_ITEMS_H #define CLASSES_BODY_ITEMS_H
class LIB_COMPONENT;
class PLOTTER;
#define TARGET_PIN_DIAM 12 /* Circle diameter drawn at the active end of #define TARGET_PIN_DIAM 12 /* Circle diameter drawn at the active end of
* pins */ * pins */
@ -83,11 +88,11 @@ enum DrawPinOrient {
/****************************************************************************/ /****************************************************************************/
/* class LibEDA_BaseStruct : Basic class for items used in a library component /* class LIB_DRAW_ITEM : Basic class for items used in a library component
* (graphic shapes, texts, fields, pins) * (graphic shapes, texts, fields, pins)
*/ */
class LibEDA_BaseStruct : public EDA_BaseStruct class LIB_DRAW_ITEM : public EDA_BaseStruct
{ {
public: public:
int m_Unit; /* Unit identification (for multi part per package) int m_Unit; /* Unit identification (for multi part per package)
@ -99,14 +104,15 @@ public:
wxString m_typeName; /* Name of object displayed in the message panel. */ wxString m_typeName; /* Name of object displayed in the message panel. */
public: public:
LibEDA_BaseStruct* Next() LIB_DRAW_ITEM* Next()
{ {
return (LibEDA_BaseStruct*) Pnext; return (LIB_DRAW_ITEM*) Pnext;
} }
LibEDA_BaseStruct( KICAD_T struct_type, LIB_COMPONENT * aParent ); LIB_DRAW_ITEM( KICAD_T struct_type, LIB_COMPONENT * aParent );
virtual ~LibEDA_BaseStruct() { } LIB_DRAW_ITEM( const LIB_DRAW_ITEM& item );
virtual ~LIB_DRAW_ITEM() { }
/** Function Draw (virtual pure) /** Function Draw (virtual pure)
* Draw A body item * Draw A body item
@ -182,22 +188,22 @@ public:
/** /**
* Make a copy of this draw item. * Make a copy of this draw item.
* *
* Classes derived from LibEDA_BaseStruct must implement DoGenCopy(). * Classes derived from LIB_DRAW_ITEM must implement DoGenCopy().
* This is just a placeholder for the derived class. * This is just a placeholder for the derived class.
* *
* @return Copy of this draw item. * @return Copy of this draw item.
*/ */
LibEDA_BaseStruct* GenCopy() { return DoGenCopy(); } LIB_DRAW_ITEM* GenCopy() { return DoGenCopy(); }
/** /**
* Test LibEDA_BaseStruct objects for equivalence. * Test LIB_DRAW_ITEM objects for equivalence.
* *
* @param tst - Object to test against. * @param tst - Object to test against.
* *
* @return bool - True if object is identical to this object. * @return bool - True if object is identical to this object.
*/ */
bool operator==( const LibEDA_BaseStruct& other ) const; bool operator==( const LIB_DRAW_ITEM& other ) const;
bool operator==( const LibEDA_BaseStruct* other ) const bool operator==( const LIB_DRAW_ITEM* other ) const
{ {
return *this == *other; return *this == *other;
} }
@ -207,7 +213,7 @@ public:
* *
* @param offset - Cooridinates to offset position. * @param offset - Cooridinates to offset position.
*/ */
void SetOffset( const wxPoint offset ) { DoOffset( offset ); } void SetOffset( const wxPoint& offset ) { DoOffset( offset ); }
/** /**
* Test if any part of the draw object is inside rectangle bounds. * Test if any part of the draw object is inside rectangle bounds.
@ -221,24 +227,40 @@ public:
*/ */
bool Inside( EDA_Rect& rect ) { return DoTestInside( rect ); } bool Inside( EDA_Rect& rect ) { return DoTestInside( rect ); }
/**
* Move a draw object to a new position.
*
* The real work is done by the DoMove method for each derived object type.
*
* @param newPosition - Position to move draw item to.
*/
void Move( const wxPoint& newPosition ) { DoMove( newPosition ); }
/**
* Return the current draw object start position.
*/
wxPoint GetPosition( void ) { return DoGetPosition(); }
protected: protected:
virtual LibEDA_BaseStruct* DoGenCopy() = 0; virtual LIB_DRAW_ITEM* DoGenCopy() = 0;
/** /**
* Provide the draw object specific comparison. * Provide the draw object specific comparison.
* *
* This is called by the == operator. * This is called by the == operator.
*/ */
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const = 0; virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const = 0;
virtual void DoOffset( const wxPoint& offset ) = 0; virtual void DoOffset( const wxPoint& offset ) = 0;
virtual bool DoTestInside( EDA_Rect& rect ) = 0; virtual bool DoTestInside( EDA_Rect& rect ) = 0;
virtual void DoMove( const wxPoint& newPosition ) = 0;
virtual wxPoint DoGetPosition( void ) = 0;
}; };
/********/ /********/
/* Pins */ /* Pins */
/********/ /********/
class LibDrawPin : public LibEDA_BaseStruct class LibDrawPin : public LIB_DRAW_ITEM
{ {
public: public:
int m_PinLen; /* Pin length */ int m_PinLen; /* Pin length */
@ -267,6 +289,7 @@ public:
public: public:
LibDrawPin(LIB_COMPONENT * aParent); LibDrawPin(LIB_COMPONENT * aParent);
LibDrawPin( const LibDrawPin& pin );
~LibDrawPin() { } ~LibDrawPin() { }
LibDrawPin* Next() const { return (LibDrawPin*) Pnext; } LibDrawPin* Next() const { return (LibDrawPin*) Pnext; }
@ -358,10 +381,12 @@ public:
int aWidth); int aWidth);
protected: protected:
virtual LibEDA_BaseStruct* DoGenCopy(); virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const; virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset ); virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect ); virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; }
}; };
@ -369,7 +394,7 @@ protected:
/* Graphic Body Item: Arc */ /* Graphic Body Item: Arc */
/**************************/ /**************************/
class LibDrawArc : public LibEDA_BaseStruct class LibDrawArc : public LIB_DRAW_ITEM
{ {
public: public:
int m_Radius; int m_Radius;
@ -383,6 +408,7 @@ public:
public: public:
LibDrawArc(LIB_COMPONENT * aParent); LibDrawArc(LIB_COMPONENT * aParent);
LibDrawArc( const LibDrawArc& arc );
~LibDrawArc() { } ~LibDrawArc() { }
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
@ -430,17 +456,19 @@ public:
virtual int GetPenSize( ); virtual int GetPenSize( );
protected: protected:
virtual LibEDA_BaseStruct* DoGenCopy(); virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const; virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset ); virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect ); virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; }
}; };
/*****************************/ /*****************************/
/* Graphic Body Item: Circle */ /* Graphic Body Item: Circle */
/*****************************/ /*****************************/
class LibDrawCircle : public LibEDA_BaseStruct class LibDrawCircle : public LIB_DRAW_ITEM
{ {
public: public:
int m_Radius; int m_Radius;
@ -450,6 +478,7 @@ public:
public: public:
LibDrawCircle(LIB_COMPONENT * aParent); LibDrawCircle(LIB_COMPONENT * aParent);
LibDrawCircle( const LibDrawCircle& circle );
~LibDrawCircle() { } ~LibDrawCircle() { }
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
@ -498,10 +527,12 @@ public:
virtual void DisplayInfo( WinEDA_DrawFrame* frame ); virtual void DisplayInfo( WinEDA_DrawFrame* frame );
protected: protected:
virtual LibEDA_BaseStruct* DoGenCopy(); virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const; virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset ); virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect ); virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; }
}; };
@ -511,10 +542,11 @@ protected:
/* Fields like Ref , value... are not Text, */ /* Fields like Ref , value... are not Text, */
/* they are a separate class */ /* they are a separate class */
/*********************************************/ /*********************************************/
class LibDrawText : public LibEDA_BaseStruct, public EDA_TextStruct class LibDrawText : public LIB_DRAW_ITEM, public EDA_TextStruct
{ {
public: public:
LibDrawText(LIB_COMPONENT * aParent); LibDrawText(LIB_COMPONENT * aParent);
LibDrawText( const LibDrawText& text );
~LibDrawText() { } ~LibDrawText() { }
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
@ -573,17 +605,19 @@ public:
virtual void DisplayInfo( WinEDA_DrawFrame* frame ); virtual void DisplayInfo( WinEDA_DrawFrame* frame );
protected: protected:
virtual LibEDA_BaseStruct* DoGenCopy(); virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const; virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset ); virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect ); virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; }
}; };
/********************************/ /********************************/
/* Graphic Body Item: Rectangle */ /* Graphic Body Item: Rectangle */
/********************************/ /********************************/
class LibDrawSquare : public LibEDA_BaseStruct class LibDrawSquare : public LIB_DRAW_ITEM
{ {
public: public:
wxPoint m_End; /* Rectangle end point. */ wxPoint m_End; /* Rectangle end point. */
@ -592,6 +626,7 @@ public:
public: public:
LibDrawSquare(LIB_COMPONENT * aParent); LibDrawSquare(LIB_COMPONENT * aParent);
LibDrawSquare( const LibDrawSquare& rect );
~LibDrawSquare() { } ~LibDrawSquare() { }
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
@ -640,16 +675,18 @@ public:
virtual void DisplayInfo( WinEDA_DrawFrame* frame ); virtual void DisplayInfo( WinEDA_DrawFrame* frame );
protected: protected:
virtual LibEDA_BaseStruct* DoGenCopy(); virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const; virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset ); virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect ); virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; }
}; };
/**********************************/ /**********************************/
/* Graphic Body Item: single line */ /* Graphic Body Item: single line */
/**********************************/ /**********************************/
class LibDrawSegment : public LibEDA_BaseStruct class LibDrawSegment : public LIB_DRAW_ITEM
{ {
public: public:
wxPoint m_End; wxPoint m_End;
@ -659,6 +696,7 @@ public:
public: public:
LibDrawSegment(LIB_COMPONENT * aParent); LibDrawSegment(LIB_COMPONENT * aParent);
LibDrawSegment( const LibDrawSegment& segment );
~LibDrawSegment() { } ~LibDrawSegment() { }
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
@ -706,17 +744,19 @@ public:
virtual void DisplayInfo( WinEDA_DrawFrame* frame ); virtual void DisplayInfo( WinEDA_DrawFrame* frame );
protected: protected:
virtual LibEDA_BaseStruct* DoGenCopy(); virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const; virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset ); virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect ); virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; }
}; };
/**********************************************************/ /**********************************************************/
/* Graphic Body Item: Polygon and polyline (set of lines) */ /* Graphic Body Item: Polygon and polyline (set of lines) */
/**********************************************************/ /**********************************************************/
class LibDrawPolyline : public LibEDA_BaseStruct class LibDrawPolyline : public LIB_DRAW_ITEM
{ {
public: public:
int m_Width; /* Line width */ int m_Width; /* Line width */
@ -724,6 +764,7 @@ public:
public: public:
LibDrawPolyline(LIB_COMPONENT * aParent); LibDrawPolyline(LIB_COMPONENT * aParent);
LibDrawPolyline( const LibDrawPolyline& polyline );
~LibDrawPolyline() { } ~LibDrawPolyline() { }
virtual wxString GetClass() const virtual wxString GetClass() const
@ -783,16 +824,18 @@ public:
virtual void DisplayInfo( WinEDA_DrawFrame* frame ); virtual void DisplayInfo( WinEDA_DrawFrame* frame );
protected: protected:
virtual LibEDA_BaseStruct* DoGenCopy(); virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const; virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset ); virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect ); virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_PolyPoints[0]; }
}; };
/**********************************************************/ /**********************************************************/
/* Graphic Body Item: Bezier Curve (set of lines) */ /* Graphic Body Item: Bezier Curve (set of lines) */
/**********************************************************/ /**********************************************************/
class LibDrawBezier : public LibEDA_BaseStruct class LibDrawBezier : public LIB_DRAW_ITEM
{ {
public: public:
int m_Width; /* Line width */ int m_Width; /* Line width */
@ -800,7 +843,8 @@ public:
std::vector<wxPoint> m_PolyPoints; // list of points (>= 2) std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
public: public:
LibDrawBezier(LIB_COMPONENT * aParent); LibDrawBezier( LIB_COMPONENT * aParent );
LibDrawBezier( const LibDrawBezier& bezier );
~LibDrawBezier() { } ~LibDrawBezier() { }
virtual wxString GetClass() const virtual wxString GetClass() const
@ -860,10 +904,12 @@ public:
virtual void DisplayInfo( WinEDA_DrawFrame* frame ); virtual void DisplayInfo( WinEDA_DrawFrame* frame );
protected: protected:
virtual LibEDA_BaseStruct* DoGenCopy(); virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const; virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset ); virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect ); virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_PolyPoints[0]; }
}; };
#endif // CLASSES_BODY_ITEMS_H #endif // CLASSES_BODY_ITEMS_H

View File

@ -7,12 +7,12 @@
#include "common.h" #include "common.h"
#include "trigo.h" #include "trigo.h"
#include "confirm.h" #include "confirm.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "netlist.h"
#include "macros.h" #include "macros.h"
#include "program.h"
#include "general.h"
#include "protos.h" #include "protos.h"
#include "netlist.h"
/* Routines locales */ /* Routines locales */

View File

@ -10,14 +10,14 @@
#include "eeschema_id.h" #include "eeschema_id.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "libeditfrm.h" #include "libeditfrm.h"
#include "libviewfrm.h" #include "libviewfrm.h"
#include "classes_body_items.h"
#include "class_marker_sch.h" #include "class_marker_sch.h"
/**************************************************************************************/ /**************************************************************************************/
SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool IncludePin ) SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool IncludePin )
/**************************************************************************************/ /**************************************************************************************/

View File

@ -5,15 +5,13 @@
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "common.h" #include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "eda_dde.h" #include "eda_dde.h"
#include "program.h"
#include "general.h"
#include "eeschema_id.h" #include "eeschema_id.h"
#include "protos.h" #include "protos.h"
#include "classes_body_items.h"
/***************************************************************/ /***************************************************************/

View File

@ -5,12 +5,12 @@
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "common.h" #include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "program.h"
#include "general.h"
#include "netlist.h" /* Definitions generales liees au calcul de netliste */ #include "netlist.h" /* Definitions generales liees au calcul de netliste */
#include "protos.h" #include "protos.h"
#include "class_library.h"
enum End_Type { enum End_Type {
@ -392,7 +392,7 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
if( Entry == NULL ) if( Entry == NULL )
break; break;
LibEDA_BaseStruct* DrawLibItem = Entry->m_Drawings; LIB_DRAW_ITEM* DrawLibItem = Entry->m_Drawings;
for( ; DrawLibItem != NULL; DrawLibItem = DrawLibItem->Next() ) for( ; DrawLibItem != NULL; DrawLibItem = DrawLibItem->Next() )
{ {
if( DrawLibItem->Type() != COMPONENT_PIN_DRAW_TYPE ) if( DrawLibItem->Type() != COMPONENT_PIN_DRAW_TYPE )

View File

@ -13,9 +13,9 @@
#include "kicad_string.h" #include "kicad_string.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "class_library.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>

View File

@ -7,7 +7,6 @@
#include "common.h" #include "common.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "class_marker_sch.h" #include "class_marker_sch.h"

View File

@ -6,8 +6,8 @@
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "common.h" #include "common.h"
#include "confirm.h" #include "confirm.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"

View File

@ -9,10 +9,9 @@
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "common.h" #include "common.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "netlist.h" #include "netlist.h"

View File

@ -51,7 +51,7 @@ WinEDA_bodygraphics_PropertiesFrame::WinEDA_bodygraphics_PropertiesFrame( )
WinEDA_bodygraphics_PropertiesFrame::WinEDA_bodygraphics_PropertiesFrame( WinEDA_LibeditFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) WinEDA_bodygraphics_PropertiesFrame::WinEDA_bodygraphics_PropertiesFrame( WinEDA_LibeditFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{ {
LibEDA_BaseStruct * CurrentItem = CurrentDrawItem; LIB_DRAW_ITEM * CurrentItem = parent->GetDrawItem();
m_Parent = parent; m_Parent = parent;
Create(parent, id, caption, pos, size, style); Create(parent, id, caption, pos, size, style);

View File

@ -16,12 +16,12 @@
#endif #endif
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h"
#include "common.h" #include "common.h"
#include "confirm.h" #include "confirm.h"
#include "program.h" #include "program.h"
#include "libcmp.h" #include "class_libentry.h"
#include "general.h" #include "libeditfrm.h"
////@begin includes ////@begin includes
////@end includes ////@end includes
@ -104,7 +104,9 @@ bool WinEDA_CreateCmpDialog::Create( WinEDA_DrawFrame* parent, wxWindowID id, co
void WinEDA_CreateCmpDialog::SetComponentData( LIB_COMPONENT & component ) void WinEDA_CreateCmpDialog::SetComponentData( LIB_COMPONENT & component )
/**********************************************************************************/ /**********************************************************************************/
{ {
g_AsDeMorgan = m_AsConvert->GetValue(); WinEDA_LibeditFrame* parent = (WinEDA_LibeditFrame*) GetParent();
parent->SetShowDeMorgan( m_AsConvert->GetValue() );
component.m_UnitCount = m_PartsCount->GetSelection() + 1; component.m_UnitCount = m_PartsCount->GetSelection() + 1;
component.m_Prefix.m_Text = m_Reference->GetValue(); component.m_Prefix.m_Text = m_Reference->GetValue();
if ( m_PinNameInside->GetValue() == FALSE) if ( m_PinNameInside->GetValue() == FALSE)

View File

@ -10,10 +10,10 @@
#include "gestfich.h" #include "gestfich.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "libeditfrm.h" #include "libeditfrm.h"
#include "class_libentry.h"
#include "dialog_edit_component_in_lib.h" #include "dialog_edit_component_in_lib.h"
@ -45,7 +45,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::Init( )
SetFocus(); SetFocus();
m_AliasLocation = -1; m_AliasLocation = -1;
LIB_COMPONENT* component = m_Parent->GetCurrentComponent(); LIB_COMPONENT* component = m_Parent->GetComponent();
if( component == NULL ) if( component == NULL )
{ {
@ -55,22 +55,22 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::Init( )
wxString title = _( "Properties for " ); wxString title = _( "Properties for " );
if( !CurrentAliasName.IsEmpty() ) if( !m_Parent->GetAliasName().IsEmpty() )
{ {
title += CurrentAliasName + _( " (alias of " ) + title += m_Parent->GetAliasName() + _( " (alias of " ) +
component->GetName() + wxT( ")" ); component->GetName() + wxT( ")" );
} }
else else
{ {
title += component->GetName(); title += component->GetName();
CurrentAliasName.Empty(); m_Parent->GetAliasName().Empty();
} }
SetTitle( title ); SetTitle( title );
InitPanelDoc(); InitPanelDoc();
InitBasicPanel(); InitBasicPanel();
if( !CurrentAliasName.IsEmpty() ) if( !m_Parent->GetAliasName().IsEmpty() )
m_ButtonDeleteAllAlias->Enable( false ); m_ButtonDeleteAllAlias->Enable( false );
/* Place list of alias names in listbox */ /* Place list of alias names in listbox */

View File

@ -9,9 +9,9 @@
#include "confirm.h" #include "confirm.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "class_library.h"
#include "dialog_edit_component_in_schematic.h" #include "dialog_edit_component_in_schematic.h"

View File

@ -13,7 +13,6 @@
#include "common.h" #include "common.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "dialog_edit_label.h" #include "dialog_edit_label.h"

View File

@ -10,10 +10,10 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "libeditfrm.h" #include "libeditfrm.h"
#include "class_library.h"
#include "dialog_edit_libentry_fields_in_lib_base.h" #include "dialog_edit_libentry_fields_in_lib_base.h"
@ -101,12 +101,12 @@ private:
void WinEDA_LibeditFrame::InstallFieldsEditorDialog( wxCommandEvent& event ) void WinEDA_LibeditFrame::InstallFieldsEditorDialog( wxCommandEvent& event )
{ {
if( m_currentComponent == NULL ) if( m_component == NULL )
return; return;
DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW ); DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW );
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB dlg( this, m_currentComponent ); DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB dlg( this, m_component );
int abort = dlg.ShowModal(); int abort = dlg.ShowModal();

View File

@ -14,7 +14,6 @@
#include "gestfich.h" #include "gestfich.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "netlist.h" #include "netlist.h"

View File

@ -8,16 +8,14 @@
// Licence: GPL // Licence: GPL
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "bitmaps.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "netlist.h" #include "netlist.h"
#include "bitmaps.h"
#include "class_marker_sch.h" #include "class_marker_sch.h"
#include "protos.h" #include "protos.h"
#include "dialog_erc.h" #include "dialog_erc.h"

View File

@ -24,7 +24,6 @@
#include "confirm.h" #include "confirm.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"

View File

@ -9,14 +9,12 @@
#include "gestfich.h" #include "gestfich.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "libeditfrm.h" #include "libeditfrm.h"
#include "class_library.h"
extern int CurrentUnit;
/* Dialog box to edit a libentry (a component in library) properties */ /* Dialog box to edit a libentry (a component in library) properties */
/* Creates a NoteBook dialog /* Creates a NoteBook dialog
@ -38,7 +36,7 @@ void WinEDA_LibeditFrame::OnEditComponentProperties( wxCommandEvent& event )
void WinEDA_LibeditFrame::EditComponentProperties() void WinEDA_LibeditFrame::EditComponentProperties()
{ {
wxASSERT( m_currentComponent != NULL && CurrentLib != NULL ); wxASSERT( m_component != NULL && m_library != NULL );
DIALOG_EDIT_COMPONENT_IN_LIBRARY dlg( this ); DIALOG_EDIT_COMPONENT_IN_LIBRARY dlg( this );
@ -50,7 +48,7 @@ void WinEDA_LibeditFrame::EditComponentProperties()
DisplayLibInfos(); DisplayLibInfos();
DisplayCmpDoc(); DisplayCmpDoc();
GetScreen()->SetModify(); GetScreen()->SetModify();
SaveCopyInUndoList( m_currentComponent ); SaveCopyInUndoList( m_component );
} }
@ -58,18 +56,20 @@ void WinEDA_LibeditFrame::EditComponentProperties()
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc() void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc()
{ {
CMP_LIB_ENTRY* entry; CMP_LIB_ENTRY* entry;
LIB_COMPONENT* component = m_Parent->GetCurrentComponent(); LIB_COMPONENT* component = m_Parent->GetComponent();
CMP_LIBRARY* library = m_Parent->GetLibrary();
if( component == NULL ) if( component == NULL )
return; return;
if( CurrentAliasName.IsEmpty() ) if( m_Parent->GetAliasName().IsEmpty() )
{ {
entry = component; entry = component;
} }
else else
{ {
entry = ( CMP_LIB_ENTRY* ) CurrentLib->FindAlias( CurrentAliasName ); entry =
( CMP_LIB_ENTRY* ) library->FindAlias( m_Parent->GetAliasName() );
if( entry == NULL ) if( entry == NULL )
return; return;
@ -86,9 +86,9 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc()
*/ */
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel() void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel()
{ {
LIB_COMPONENT* component = m_Parent->GetCurrentComponent(); LIB_COMPONENT* component = m_Parent->GetComponent();
if( g_AsDeMorgan ) if( m_Parent->GetShowDeMorgan() )
m_AsConvertButt->SetValue( true ); m_AsConvertButt->SetValue( true );
/* Default values for a new component. */ /* Default values for a new component. */
@ -121,15 +121,16 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
size_t i; size_t i;
int index; int index;
CMP_LIB_ENTRY* entry; CMP_LIB_ENTRY* entry;
LIB_COMPONENT* component = m_Parent->GetCurrentComponent(); LIB_COMPONENT* component = m_Parent->GetComponent();
CMP_LIBRARY* library = m_Parent->GetLibrary();
if( CurrentAliasName.IsEmpty() ) if( m_Parent->GetAliasName().IsEmpty() )
{ {
entry = (CMP_LIB_ENTRY*) component; entry = (CMP_LIB_ENTRY*) component;
} }
else else
{ {
entry = CurrentLib->FindEntry( CurrentAliasName ); entry = library->FindEntry( m_Parent->GetAliasName() );
} }
if( entry == NULL ) if( entry == NULL )
@ -137,9 +138,9 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
wxString msg; wxString msg;
msg.Printf( _( "Alias <%s> not found for component <%s> in library \ msg.Printf( _( "Alias <%s> not found for component <%s> in library \
<%s>." ), <%s>." ),
(const wxChar*) CurrentAliasName, (const wxChar*) m_Parent->GetAliasName(),
(const wxChar*) component->GetName(), (const wxChar*) component->GetName(),
(const wxChar*) CurrentLib->GetName() ); (const wxChar*) library->GetName() );
wxMessageBox( msg, _( "Component Library Error" ), wxMessageBox( msg, _( "Component Library Error" ),
wxID_OK | wxICON_ERROR, this ); wxID_OK | wxICON_ERROR, this );
} }
@ -165,7 +166,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
alias = new LIB_ALIAS( aliases[ i ], component ); alias = new LIB_ALIAS( aliases[ i ], component );
if( !CurrentLib->AddAlias( alias ) ) if( !library->AddAlias( alias ) )
{ {
delete alias; delete alias;
alias = NULL; alias = NULL;
@ -181,9 +182,9 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
continue; continue;
CMP_LIB_ENTRY* alias = CMP_LIB_ENTRY* alias =
CurrentLib->FindAlias( component->m_AliasList[ i ] ); library->FindAlias( component->m_AliasList[ i ] );
if( alias != NULL ) if( alias != NULL )
CurrentLib->RemoveEntry( alias ); library->RemoveEntry( alias );
} }
component->m_AliasList = aliases; component->m_AliasList = aliases;
@ -194,17 +195,17 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
if( m_AsConvertButt->GetValue() ) if( m_AsConvertButt->GetValue() )
{ {
if( !g_AsDeMorgan ) if( !m_Parent->GetShowDeMorgan() )
{ {
g_AsDeMorgan = 1; m_Parent->SetShowDeMorgan( true );
SetUnsetConvert(); SetUnsetConvert();
} }
} }
else else
{ {
if( g_AsDeMorgan ) if( m_Parent->GetShowDeMorgan() )
{ {
g_AsDeMorgan = 0; m_Parent->SetShowDeMorgan( false );
SetUnsetConvert(); SetUnsetConvert();
} }
} }
@ -240,9 +241,9 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::CopyDocToAlias( wxCommandEvent& WXUNUSED (event) ) void DIALOG_EDIT_COMPONENT_IN_LIBRARY::CopyDocToAlias( wxCommandEvent& WXUNUSED (event) )
/******************************************************************************/ /******************************************************************************/
{ {
LIB_COMPONENT* component = m_Parent->GetCurrentComponent(); LIB_COMPONENT* component = m_Parent->GetComponent();
if( component == NULL || CurrentAliasName.IsEmpty() ) if( component == NULL || m_Parent->GetAliasName().IsEmpty() )
return; return;
m_Doc->SetValue( component->m_Doc ); m_Doc->SetValue( component->m_Doc );
@ -256,17 +257,18 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllAliasOfPart(
wxCommandEvent& WXUNUSED (event) ) wxCommandEvent& WXUNUSED (event) )
/**********************************************************/ /**********************************************************/
{ {
if( m_PartAliasList->FindString( CurrentAliasName ) != wxNOT_FOUND ) if( m_PartAliasList->FindString( m_Parent->GetAliasName() )
!= wxNOT_FOUND )
{ {
wxString msg; wxString msg;
msg.Printf( _( "Alias <%s> cannot be removed while it is being \ msg.Printf( _( "Alias <%s> cannot be removed while it is being \
edited!" ), edited!" ),
(const wxChar*) CurrentAliasName ); (const wxChar*) m_Parent->GetAliasName() );
DisplayError( this, msg ); DisplayError( this, msg );
return; return;
} }
CurrentAliasName.Empty(); m_Parent->GetAliasName().Empty();
if( IsOK( this, _( "Remove all aliases from list?" ) ) ) if( IsOK( this, _( "Remove all aliases from list?" ) ) )
{ {
@ -287,31 +289,33 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& WXUNUSED
{ {
wxString Line; wxString Line;
wxString aliasname; wxString aliasname;
LIB_COMPONENT* component = m_Parent->GetCurrentComponent(); LIB_COMPONENT* component = m_Parent->GetComponent();
CMP_LIBRARY* library = m_Parent->GetLibrary();
if( component == NULL ) if( component == NULL )
return; return;
if( Get_Message( _( "New alias:" ), _( "Component Alias" ), Line, this ) != 0 ) if( Get_Message( _( "New alias:" ),
_( "Component Alias" ), Line, this ) != 0 )
return; return;
Line.Replace( wxT( " " ), wxT( "_" ) ); Line.Replace( wxT( " " ), wxT( "_" ) );
aliasname = Line; aliasname = Line;
if( m_PartAliasList->FindString( aliasname ) != wxNOT_FOUND if( m_PartAliasList->FindString( aliasname ) != wxNOT_FOUND
|| CurrentLib->FindEntry( aliasname ) != NULL ) || library->FindEntry( aliasname ) != NULL )
{ {
wxString msg; wxString msg;
msg.Printf( _( "Alias or component name <%s> already exists in \ msg.Printf( _( "Alias or component name <%s> already exists in \
library <%s>." ), library <%s>." ),
(const wxChar*) aliasname, (const wxChar*) aliasname,
(const wxChar*) CurrentLib->GetName() ); (const wxChar*) library->GetName() );
DisplayError( this, msg ); DisplayError( this, msg );
return; return;
} }
m_PartAliasList->Append( aliasname ); m_PartAliasList->Append( aliasname );
if( CurrentAliasName.IsEmpty() ) if( m_Parent->GetAliasName().IsEmpty() )
m_ButtonDeleteAllAlias->Enable( TRUE ); m_ButtonDeleteAllAlias->Enable( TRUE );
m_ButtonDeleteOneAlias->Enable( TRUE ); m_ButtonDeleteOneAlias->Enable( TRUE );
} }
@ -324,7 +328,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAliasOfPart(
if( aliasname.IsEmpty() ) if( aliasname.IsEmpty() )
return; return;
if( aliasname.CmpNoCase( CurrentAliasName ) == 0 ) if( aliasname.CmpNoCase( m_Parent->GetAliasName() ) == 0 )
{ {
wxString msg; wxString msg;
msg.Printf( _( "Alias <%s> cannot be removed while it is being \ msg.Printf( _( "Alias <%s> cannot be removed while it is being \
@ -353,8 +357,8 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit )
*/ */
{ {
int OldNumUnits, ii, FlagDel = -1; int OldNumUnits, ii, FlagDel = -1;
LibEDA_BaseStruct* DrawItem, * NextDrawItem; LIB_DRAW_ITEM* DrawItem, * NextDrawItem;
LIB_COMPONENT* component = m_Parent->GetCurrentComponent(); LIB_COMPONENT* component = m_Parent->GetComponent();
if( component == NULL ) if( component == NULL )
return FALSE; return FALSE;
@ -384,8 +388,8 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit )
if( IsOK( this, _( "Delete units" ) ) ) if( IsOK( this, _( "Delete units" ) ) )
{ {
/* Si part selectee n'existe plus: selection 1ere unit */ /* Si part selectee n'existe plus: selection 1ere unit */
if( CurrentUnit > MaxUnit ) if( m_Parent->GetUnit() > MaxUnit )
CurrentUnit = 1; m_Parent->SetUnit( 1 );
FlagDel = 1; FlagDel = 1;
} }
else else
@ -435,10 +439,10 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
*/ */
{ {
int FlagDel = 0; int FlagDel = 0;
LibEDA_BaseStruct* DrawItem = NULL, * NextDrawItem; LIB_DRAW_ITEM* DrawItem = NULL, * NextDrawItem;
LIB_COMPONENT* component = m_Parent->GetCurrentComponent(); LIB_COMPONENT* component = m_Parent->GetComponent();
if( g_AsDeMorgan ) /* Representation convertie a creer */ if( m_Parent->GetShowDeMorgan() ) /* Representation convertie a creer */
{ {
/* Traitement des elements a ajouter ( pins seulement ) */ /* Traitement des elements a ajouter ( pins seulement ) */
if( component ) if( component )
@ -459,7 +463,8 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
if( IsOK( this, _( "Part as \"De Morgan\" anymore" ) ) ) if( IsOK( this, _( "Part as \"De Morgan\" anymore" ) ) )
return TRUE; return TRUE;
g_AsDeMorgan = 0; return FALSE; m_Parent->SetShowDeMorgan( false );
return FALSE;
} }
} }
NextDrawItem = DrawItem->GenCopy(); NextDrawItem = DrawItem->GenCopy();
@ -483,12 +488,12 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
{ {
if( IsOK( this, _( "Delete Convert items" ) ) ) if( IsOK( this, _( "Delete Convert items" ) ) )
{ {
CurrentConvert = 1; m_Parent->SetConvert( 1 );
FlagDel = 1; FlagDel = 1;
} }
else else
{ {
g_AsDeMorgan = 1; m_Parent->SetShowDeMorgan( true );
return FALSE; return FALSE;
} }
} }
@ -561,7 +566,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& WXUNU
*/ */
{ {
wxString Line; wxString Line;
LIB_COMPONENT* component = m_Parent->GetCurrentComponent(); LIB_COMPONENT* component = m_Parent->GetComponent();
if( component == NULL ) if( component == NULL )
return; return;
@ -596,7 +601,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteOneFootprintFilter(
wxCommandEvent& WXUNUSED (event) ) wxCommandEvent& WXUNUSED (event) )
/********************************************************/ /********************************************************/
{ {
LIB_COMPONENT* component = m_Parent->GetCurrentComponent(); LIB_COMPONENT* component = m_Parent->GetComponent();
int ii = m_FootprintFilterListBox->GetSelection(); int ii = m_FootprintFilterListBox->GetSelection();
m_FootprintFilterListBox->Delete( ii ); m_FootprintFilterListBox->Delete( ii );

View File

@ -9,10 +9,9 @@
#include "confirm.h" #include "confirm.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "class_library.h"
/* Fonctions locales */ /* Fonctions locales */

View File

@ -13,10 +13,10 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "libeditfrm.h" #include "libeditfrm.h"
#include "class_libentry.h"
#include "dialog_bodygraphictext_properties_base.h" #include "dialog_bodygraphictext_properties_base.h"
@ -144,7 +144,7 @@ void Dialog_BodyGraphicText_Properties::OnOkClick( wxCommandEvent& event )
/* Met a jour les differents parametres pour le composant en cours d'edition /* Met a jour les differents parametres pour le composant en cours d'edition
*/ */
{ {
wxString Line; wxString Line;
Line = m_TextValue->GetValue(); Line = m_TextValue->GetValue();
g_LastTextOrient = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ; g_LastTextOrient = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ;
@ -165,12 +165,12 @@ wxString Line;
m_GraphicText->m_Orient = g_LastTextOrient; m_GraphicText->m_Orient = g_LastTextOrient;
if( g_FlDrawSpecificUnit ) if( g_FlDrawSpecificUnit )
m_GraphicText->m_Unit = CurrentUnit; m_GraphicText->m_Unit = m_Parent->GetUnit();
else else
m_GraphicText->m_Unit = 0; m_GraphicText->m_Unit = 0;
if( g_FlDrawSpecificConvert ) if( g_FlDrawSpecificConvert )
m_GraphicText->m_Convert = CurrentConvert; m_GraphicText->m_Convert = m_Parent->GetConvert();
else else
m_GraphicText->m_Convert = 0; m_GraphicText->m_Convert = 0;
@ -216,14 +216,14 @@ wxString Line;
} }
Close(); Close();
if ( CurrentDrawItem ) if ( m_Parent->GetDrawItem() )
CurrentDrawItem->DisplayInfo( m_Parent ); m_Parent->GetDrawItem()->DisplayInfo( m_Parent );
Close(); Close();
} }
void WinEDA_LibeditFrame::EditSymbolText(wxDC * DC, LibEDA_BaseStruct * DrawItem) void WinEDA_LibeditFrame::EditSymbolText(wxDC* DC, LIB_DRAW_ITEM* DrawItem)
{ {
int DrawMode = g_XorMode; int DrawMode = g_XorMode;
@ -263,7 +263,7 @@ void WinEDA_LibeditFrame::RotateSymbolText(wxDC * DC)
90 deg Graphic text Rotation . 90 deg Graphic text Rotation .
*/ */
{ {
LibDrawText * DrawItem = (LibDrawText *) CurrentDrawItem; LibDrawText * DrawItem = (LibDrawText *) m_drawItem;
if( DrawItem == NULL ) if( DrawItem == NULL )
return; return;

View File

@ -12,12 +12,11 @@
#include "confirm.h" #include "confirm.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "dialog_edit_label.h"
#include "protos.h" #include "protos.h"
#include "dialog_edit_label.h"
/* Fonctions locales */ /* Fonctions locales */
static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void ExitMoveTexte( WinEDA_DrawPanel* panel, wxDC* DC ); static void ExitMoveTexte( WinEDA_DrawPanel* panel, wxDC* DC );

View File

@ -12,7 +12,6 @@
#include "gestfich.h" #include "gestfich.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "eeconfig.h" #include "eeconfig.h"

View File

@ -16,7 +16,6 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"

View File

@ -6,8 +6,8 @@
#include "gr_basic.h" #include "gr_basic.h"
#include "common.h" #include "common.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "class_library.h" #include "class_library.h"

View File

@ -7,8 +7,8 @@
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "class_library.h"
#include "dialog_load_error.h" #include "dialog_load_error.h"

View File

@ -10,9 +10,10 @@
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "class_library.h"
static EDA_BaseStruct* HighLightStruct = NULL; static EDA_BaseStruct* HighLightStruct = NULL;

View File

@ -8,12 +8,11 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "gestfich.h" #include "gestfich.h"
#include "program.h"
#include "general.h"
#include "bitmaps.h" #include "bitmaps.h"
#include "eda_dde.h" #include "eda_dde.h"
#include "libcmp.h" #include "program.h"
#include "general.h"
#include "protos.h" #include "protos.h"
#include <wx/snglinst.h> #include <wx/snglinst.h>
@ -65,7 +64,6 @@ HPGL_Pen_Descr_Struct g_HPGL_Pen_Descr;
//SCH_SCREEN * ScreenSch; //SCH_SCREEN * ScreenSch;
DrawSheetStruct* g_RootSheet = NULL; DrawSheetStruct* g_RootSheet = NULL;
SCH_SCREEN* g_ScreenLib = NULL;
wxString g_NetCmpExtBuffer( wxT( "cmp" ) ); wxString g_NetCmpExtBuffer( wxT( "cmp" ) );
@ -97,21 +95,6 @@ int g_ItemSelectetColor = BROWN;
// Color to draw items flagged invisible, in libedit (they are insisible in eeschema // Color to draw items flagged invisible, in libedit (they are insisible in eeschema
int g_InvisibleItemColor = DARKGRAY; int g_InvisibleItemColor = DARKGRAY;
/* Variables used by LibEdit */
LibEDA_BaseStruct* LibItemToRepeat = NULL; /* pointer on a graphic item than
* can be duplicated by the Ins key
* (usually the last created item */
CMP_LIBRARY* CurrentLib = NULL; /* Current opened library */
LibEDA_BaseStruct* CurrentDrawItem = NULL; /* current edited item */
// Current selected alias (for components which have aliases)
wxString CurrentAliasName;
// True if the current component has a "De Morgan" representation
bool g_AsDeMorgan;
int CurrentUnit = 1;
int CurrentConvert = 1;
int DefaultTransformMatrix[2][2] = { { 1, 0 }, { 0, -1 } }; int DefaultTransformMatrix[2][2] = { { 1, 0 }, { 0, -1 } };

View File

@ -8,18 +8,17 @@
#include "kicad_string.h" #include "kicad_string.h"
#include "gestfich.h" #include "gestfich.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "bitmaps.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "netlist.h" #include "netlist.h"
#include "bitmaps.h"
#include "class_marker_sch.h" #include "class_marker_sch.h"
#include "protos.h"
#include "dialog_erc.h"
#include "erc.h" #include "erc.h"
#include "protos.h" #include "dialog_erc.h"
/* ERC tests : /* ERC tests :
* 1 - conflicts between connected pins ( example: 2 connected outputs ) * 1 - conflicts between connected pins ( example: 2 connected outputs )

View File

@ -7,12 +7,12 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "gestfich.h" #include "gestfich.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "program.h"
#include "general.h"
#include "protos.h" #include "protos.h"
#include "eeschema_id.h" #include "eeschema_id.h"
#include "class_library.h"
/****************************************************************/ /****************************************************************/

View File

@ -16,10 +16,10 @@
#include "gestfich.h" #include "gestfich.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "class_marker_sch.h" #include "class_marker_sch.h"
#include "protos.h" #include "protos.h"
#include "class_library.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>

View File

@ -158,7 +158,7 @@ extern HPGL_Pen_Descr_Struct g_HPGL_Pen_Descr;
/* First and main (root) screen */ /* First and main (root) screen */
extern DrawSheetStruct* g_RootSheet; extern DrawSheetStruct* g_RootSheet;
extern SCH_SCREEN* g_ScreenLib;
/*************************************/ /*************************************/
/* Gestion de recherche des elements */ /* Gestion de recherche des elements */

View File

@ -9,14 +9,14 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "get_component_dialog.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "class_library.h" #include "class_library.h"
#include "libviewfrm.h" #include "libviewfrm.h"
#include "get_component_dialog.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
@ -441,7 +441,7 @@ void WinEDA_SchematicFrame::ConvertPart( SCH_COMPONENT* DrawComponent,
int LookForConvertPart( LIB_COMPONENT* LibEntry ) int LookForConvertPart( LIB_COMPONENT* LibEntry )
{ {
int ii; int ii;
LibEDA_BaseStruct* DrawLibEntry; LIB_DRAW_ITEM* DrawLibEntry;
DrawLibEntry = LibEntry->m_Drawings; DrawLibEntry = LibEntry->m_Drawings;
ii = 0; ii = 0;

View File

@ -7,18 +7,15 @@
#include "common.h" #include "common.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "bitmaps.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "wx/imaglist.h" #include "wx/imaglist.h"
#include "wx/treectrl.h" #include "wx/treectrl.h"
#include "bitmaps.h"
static bool UpdateScreenFromSheet( WinEDA_SchematicFrame* frame ); static bool UpdateScreenFromSheet( WinEDA_SchematicFrame* frame );
enum { enum {

View File

@ -8,10 +8,11 @@
#include "hotkeys.h" #include "hotkeys.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "libeditfrm.h" #include "libeditfrm.h"
#include "class_libentry.h"
/* How to add a new hotkey: /* How to add a new hotkey:
* add a new id in the enum hotkey_id_commnand like MY_NEW_ID_FUNCTION (see * add a new id in the enum hotkey_id_commnand like MY_NEW_ID_FUNCTION (see
@ -463,7 +464,7 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
wxPoint MousePos = GetScreen()->m_MousePosition; wxPoint MousePos = GetScreen()->m_MousePosition;
LibEDA_BaseStruct* DrawEntry = LocateItemUsingCursor(); LIB_DRAW_ITEM* DrawEntry = LocateItemUsingCursor();
// Remap the control key Ctrl A (0x01) to GR_KB_CTRL + 'A' (easier to // Remap the control key Ctrl A (0x01) to GR_KB_CTRL + 'A' (easier to
// handle...) // handle...)
@ -533,10 +534,10 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
break; break;
case HK_REPEAT_LAST: case HK_REPEAT_LAST:
if( LibItemToRepeat && (LibItemToRepeat->m_Flags == 0) if( m_lastDrawItem && (m_lastDrawItem->m_Flags == 0)
&& (LibItemToRepeat->Type() == COMPONENT_PIN_DRAW_TYPE) ) && (m_lastDrawItem->Type() == COMPONENT_PIN_DRAW_TYPE) )
{ {
RepeatPinItem( DC, (LibDrawPin*) LibItemToRepeat ); RepeatPinItem( DC, (LibDrawPin*) m_lastDrawItem );
} }
else else
wxBell(); wxBell();
@ -544,18 +545,18 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
case HK_EDIT_PIN: case HK_EDIT_PIN:
if( DrawEntry ) if( DrawEntry )
CurrentDrawItem = DrawEntry; m_drawItem = DrawEntry;
if( CurrentDrawItem ) if( m_drawItem )
{ {
if( CurrentDrawItem->Type() == COMPONENT_PIN_DRAW_TYPE ) if( m_drawItem->Type() == COMPONENT_PIN_DRAW_TYPE )
InstallPineditFrame( this, DC, MousePos ); InstallPineditFrame( this, DC, MousePos );
} }
break; break;
case HK_DELETE_PIN: case HK_DELETE_PIN:
if( DrawEntry ) if( DrawEntry )
CurrentDrawItem = DrawEntry; m_drawItem = DrawEntry;
if( CurrentDrawItem ) if( m_drawItem )
{ {
wxCommandEvent evt; wxCommandEvent evt;
evt.SetId( ID_POPUP_LIBEDIT_DELETE_ITEM ); evt.SetId( ID_POPUP_LIBEDIT_DELETE_ITEM );
@ -565,8 +566,8 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
case HK_MOVE_PIN: case HK_MOVE_PIN:
if( DrawEntry ) if( DrawEntry )
CurrentDrawItem = DrawEntry; m_drawItem = DrawEntry;
if( CurrentDrawItem ) if( m_drawItem )
{ {
wxCommandEvent evt; wxCommandEvent evt;
evt.SetId( ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST ); evt.SetId( ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST );

View File

@ -16,10 +16,10 @@
#include "eeschema_id.h" #include "eeschema_id.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "libeditfrm.h" #include "libeditfrm.h"
#include "class_library.h"
#include <wx/filename.h> #include <wx/filename.h>
@ -41,7 +41,7 @@ void WinEDA_LibeditFrame::OnImportPart( wxCommandEvent& event )
CMP_LIBRARY* LibTmp; CMP_LIBRARY* LibTmp;
CMP_LIB_ENTRY* LibEntry; CMP_LIB_ENTRY* LibEntry;
LibItemToRepeat = NULL; m_lastDrawItem = NULL;
wxFileDialog dlg( this, _( "Import Component" ), m_LastLibImportPath, wxFileDialog dlg( this, _( "Import Component" ), m_LastLibImportPath,
wxEmptyString, CompLibFileWildcard, wxEmptyString, CompLibFileWildcard,
@ -96,13 +96,13 @@ void WinEDA_LibeditFrame::OnExportPart( wxCommandEvent& event )
CMP_LIBRARY* CurLibTmp; CMP_LIBRARY* CurLibTmp;
bool createLib = ( event.GetId() != ExportPartId ) ? false : true; bool createLib = ( event.GetId() != ExportPartId ) ? false : true;
if( m_currentComponent == NULL ) if( m_component == NULL )
{ {
DisplayError( this, _( "There is no component selected to save." ) ); DisplayError( this, _( "There is no component selected to save." ) );
return; return;
} }
fn = m_currentComponent->GetName().Lower(); fn = m_component->GetName().Lower();
fn.SetExt( CompLibFileExtension ); fn.SetExt( CompLibFileExtension );
title = createLib ? _( "New Library" ) : _( "Export Component" ); title = createLib ? _( "New Library" ) : _( "Export Component" );
@ -115,19 +115,19 @@ void WinEDA_LibeditFrame::OnExportPart( wxCommandEvent& event )
fn = dlg.GetPath(); fn = dlg.GetPath();
CurLibTmp = CurrentLib; CurLibTmp = m_library;
CurrentLib = new CMP_LIBRARY( LIBRARY_TYPE_EESCHEMA, fn ); m_library = new CMP_LIBRARY( LIBRARY_TYPE_EESCHEMA, fn );
SaveOnePartInMemory(); SaveOnePartInMemory();
bool success = CurrentLib->Save( fn.GetFullPath() ); bool success = m_library->Save( fn.GetFullPath() );
if( success ) if( success )
m_LastLibExportPath = fn.GetPath(); m_LastLibExportPath = fn.GetPath();
delete CurrentLib; delete m_library;
CurrentLib = CurLibTmp; m_library = CurLibTmp;
if( createLib && success ) if( createLib && success )
{ {

View File

@ -7,10 +7,10 @@
#include "confirm.h" #include "confirm.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "netlist.h" #include "netlist.h"
#include "protos.h" #include "protos.h"
#include "class_library.h"
/* /*

View File

@ -6,35 +6,6 @@
#define LIBCMP_H #define LIBCMP_H
#define LIB_VERSION_MAJOR 2
#define LIB_VERSION_MINOR 3
/* Must be the first line of component library (.lib) files. */
#define LIBFILE_IDENT "EESchema-LIBRARY Version"
#define LIB_VERSION( major, minor ) ( major * 100 + minor )
#define IS_LIB_CURRENT_VERSION( major, minor ) \
( \
LIB_VERSION( major1, minor1 ) == \
LIB_VERSION( LIB_VERSION_MAJOR, LIB_VERSION_MINOR) \
)
/*
* Library versions 2.3 and lower use the old separate library (.lib) and
* document (.dcm) files. Component libraries after 2.3 merged the library
* and document files into a single library file. This macro checks if the
* library version supports the old format
*/
#define USE_OLD_DOC_FILE_FORMAT( major, minor ) \
( LIB_VERSION( major, minor ) < LIB_VERSION( 2, 3 )
/* Must be the first line of component library document (.dcm) files. */
#define DOCFILE_IDENT "EESchema-DOCLIB Version 2.0"
#define DOC_EXT wxT( "dcm" )
enum LocateDrawStructType enum LocateDrawStructType
{ {
LOCATE_COMPONENT_ARC_DRAW_TYPE = 1, LOCATE_COMPONENT_ARC_DRAW_TYPE = 1,
@ -49,19 +20,4 @@ enum LocateDrawStructType
#define LOCATE_ALL_DRAW_ITEM 0xFFFFFFFF #define LOCATE_ALL_DRAW_ITEM 0xFFFFFFFF
#include "class_library.h"
/* Variables used by LibEdit */
extern LibEDA_BaseStruct* LibItemToRepeat; /* pointer on a graphic item than
* can be duplicated by the Ins key
* (usually the last created item */
extern CMP_LIBRARY* CurrentLib; /* Current opened library */
extern LibEDA_BaseStruct* CurrentDrawItem; /* current edited item */
extern wxString CurrentAliasName;
extern bool g_AsDeMorgan;
extern int CurrentUnit;
extern int CurrentConvert;
#endif // LIBCMP_H #endif // LIBCMP_H

View File

@ -16,10 +16,10 @@
#include "eeschema_id.h" #include "eeschema_id.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "libeditfrm.h" #include "libeditfrm.h"
#include "class_library.h"
#include "dialog_create_component.h" #include "dialog_create_component.h"
@ -29,8 +29,8 @@ void WinEDA_LibeditFrame::DisplayLibInfos()
{ {
wxString msg = _( "Component Library Editor: " ); wxString msg = _( "Component Library Editor: " );
if( CurrentLib ) if( m_library )
msg += CurrentLib->GetFullFileName(); msg += m_library->GetFullFileName();
else else
msg += _( "no library selected" ); msg += _( "no library selected" );
@ -46,7 +46,7 @@ void WinEDA_LibeditFrame::SelectActiveLibrary()
Lib = SelectLibraryFromList( this ); Lib = SelectLibraryFromList( this );
if( Lib ) if( Lib )
{ {
CurrentLib = Lib; m_library = Lib;
} }
DisplayLibInfos(); DisplayLibInfos();
} }
@ -59,58 +59,60 @@ void WinEDA_LibeditFrame::SelectActiveLibrary()
* If there is no current selected library, * If there is no current selected library,
* prompt user for library name and make the selected library the current lib. * prompt user for library name and make the selected library the current lib.
*/ */
bool WinEDA_LibeditFrame::LoadOneLibraryPart() void WinEDA_LibeditFrame::LoadOneLibraryPart( wxCommandEvent& event )
{ {
int i; int i;
wxString msg; wxString msg;
wxString CmpName; wxString CmpName;
CMP_LIB_ENTRY* LibEntry = NULL; CMP_LIB_ENTRY* LibEntry = NULL;
if( g_ScreenLib->IsModify() && !IsOK( this, _( "Current part not \ DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW );
saved.\n\nDiscard current changes?" ) ) )
return false;
if( CurrentLib == NULL ) // No current lib, ask user for the library to use if( GetBaseScreen()->IsModify() && !IsOK( this, _( "Current part not \
saved.\n\nDiscard current changes?" ) ) )
return;
// No current lib, ask user for the library to use.
if( m_library == NULL )
{ {
SelectActiveLibrary(); SelectActiveLibrary();
if( CurrentLib == NULL ) if( m_library == NULL )
return false; return;
} }
i = GetNameOfPartToLoad( this, CurrentLib, CmpName ); i = GetNameOfPartToLoad( this, m_library, CmpName );
if( i == 0 ) if( i == 0 )
return false; return;
g_ScreenLib->ClrModify(); GetBaseScreen()->ClrModify();
CurrentDrawItem = NULL; m_lastDrawItem = m_drawItem = NULL;
// Delete previous library component, if any // Delete previous library component, if any
if( m_currentComponent ) if( m_component )
{ {
SAFE_DELETE( m_currentComponent ); SAFE_DELETE( m_component );
} }
/* Load the new library component */ /* Load the new library component */
LibEntry = CurrentLib->FindEntry( CmpName ); LibEntry = m_library->FindEntry( CmpName );
if( LibEntry == NULL ) if( LibEntry == NULL )
{ {
msg.Printf( _( "Component or alias name \"%s\" not found in \ msg.Printf( _( "Component or alias name \"%s\" not found in \
library \"%s\"." ), library \"%s\"." ),
(const wxChar*) CmpName, (const wxChar*) CmpName,
(const wxChar*) CurrentLib->GetName() ); (const wxChar*) m_library->GetName() );
DisplayError( this, msg ); DisplayError( this, msg );
return false; return;
} }
if( !LoadOneLibraryPartAux( LibEntry, m_library ) )
return;
g_EditPinByPinIsOn = false;
GetScreen()->ClearUndoRedoList(); GetScreen()->ClearUndoRedoList();
if( !LoadOneLibraryPartAux( LibEntry, CurrentLib ) )
return false;
Zoom_Automatique( false ); Zoom_Automatique( false );
DrawPanel->Refresh(); DrawPanel->Refresh();
return true;
} }
@ -119,7 +121,7 @@ library \"%s\"." ),
* retourne * retourne
* 0 si OK * 0 si OK
* 1 si err * 1 si err
* m_currentComponent pointe la copie ainsi creee * m_component pointe la copie ainsi creee
*/ */
bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( CMP_LIB_ENTRY* LibEntry, bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( CMP_LIB_ENTRY* LibEntry,
CMP_LIBRARY* Library ) CMP_LIBRARY* Library )
@ -138,7 +140,7 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( CMP_LIB_ENTRY* LibEntry,
} }
cmpName = LibEntry->GetName(); cmpName = LibEntry->GetName();
CurrentAliasName.Empty(); m_aliasName.Empty();
if( LibEntry->Type != ROOT ) if( LibEntry->Type != ROOT )
{ {
@ -151,19 +153,19 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( CMP_LIB_ENTRY* LibEntry,
(const wxChar*) cmpName, (const wxChar*) cmpName,
(const wxChar*) component->GetName() ); (const wxChar*) component->GetName() );
CurrentAliasName = cmpName; m_aliasName = cmpName;
} }
else else
{ {
component = (LIB_COMPONENT*) LibEntry; component = (LIB_COMPONENT*) LibEntry;
} }
if( m_currentComponent ) if( m_component )
SAFE_DELETE( m_currentComponent ); SAFE_DELETE( m_component );
m_currentComponent = CopyLibEntryStruct( component ); m_component = new LIB_COMPONENT( *component );
if( m_currentComponent == NULL ) if( m_component == NULL )
{ {
msg.Printf( _( "Could not create copy of part <%s> in library <%s>." ), msg.Printf( _( "Could not create copy of part <%s> in library <%s>." ),
(const wxChar*) LibEntry->GetName(), (const wxChar*) LibEntry->GetName(),
@ -172,15 +174,15 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( CMP_LIB_ENTRY* LibEntry,
return false; return false;
} }
CurrentUnit = 1; m_unit = 1;
CurrentConvert = 1; m_convert = 1;
g_AsDeMorgan = 0; m_showDeMorgan = false;
if( LookForConvertPart( m_currentComponent ) > 1 ) if( LookForConvertPart( m_component ) > 1 )
g_AsDeMorgan = 1; m_showDeMorgan = true;
g_ScreenLib->ClrModify(); GetBaseScreen()->ClrModify();
DisplayLibInfos(); DisplayLibInfos();
UpdateAliasSelectList(); UpdateAliasSelectList();
UpdatePartSelectList(); UpdatePartSelectList();
@ -216,9 +218,9 @@ void WinEDA_LibeditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
DrawPanel->DrawBackGround( DC ); DrawPanel->DrawBackGround( DC );
if( m_currentComponent ) if( m_component )
m_currentComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), CurrentUnit, m_component->Draw( DrawPanel, DC, wxPoint( 0, 0 ), m_unit,
CurrentConvert, GR_DEFAULT_DRAWMODE ); m_convert, GR_DEFAULT_DRAWMODE );
DrawPanel->CursorOn( DC ); // redraw cursor DrawPanel->CursorOn( DC ); // redraw cursor
@ -250,20 +252,20 @@ void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event )
SaveOnePartInMemory(); SaveOnePartInMemory();
} }
if( CurrentLib == NULL ) if( m_library == NULL )
{ {
DisplayError( this, wxT( "No library specified." ) ); DisplayError( this, wxT( "No library specified." ) );
return; return;
} }
fn = wxFileName( CurrentLib->GetFullFileName() ); fn = wxFileName( m_library->GetFullFileName() );
msg = _( "Modify library file \"" ) + fn.GetFullPath() + _( "\"?" ); msg = _( "Modify library file \"" ) + fn.GetFullPath() + _( "\"?" );
if( !IsOK( this, msg ) ) if( !IsOK( this, msg ) )
return; return;
bool success = CurrentLib->Save( fn.GetFullPath() ); bool success = m_library->Save( fn.GetFullPath() );
MsgPanel->EraseMsgBox(); MsgPanel->EraseMsgBox();
@ -296,38 +298,38 @@ void WinEDA_LibeditFrame::DisplayCmpDoc()
MsgPanel->EraseMsgBox(); MsgPanel->EraseMsgBox();
if( CurrentLib == NULL || m_currentComponent == NULL ) if( m_library == NULL || m_component == NULL )
return; return;
msg = m_currentComponent->GetName(); msg = m_component->GetName();
MsgPanel->AppendMessage( _( "Part" ), msg, BLUE, 8 ); MsgPanel->AppendMessage( _( "Part" ), msg, BLUE, 8 );
if( CurrentAliasName.IsEmpty() ) if( m_aliasName.IsEmpty() )
{ {
msg = _( "None" ); msg = _( "None" );
} }
else else
{ {
msg = CurrentAliasName; msg = m_aliasName;
alias = CurrentLib->FindAlias( CurrentAliasName ); alias = m_library->FindAlias( m_aliasName );
} }
MsgPanel->AppendMessage( _( "Alias" ), msg, RED, 8 ); MsgPanel->AppendMessage( _( "Alias" ), msg, RED, 8 );
static wxChar UnitLetter[] = wxT( "?ABCDEFGHIJKLMNOPQRSTUVWXYZ" ); static wxChar UnitLetter[] = wxT( "?ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
msg = UnitLetter[CurrentUnit]; msg = UnitLetter[m_unit];
MsgPanel->AppendMessage( _( "Unit" ), msg, BROWN, 8 ); MsgPanel->AppendMessage( _( "Unit" ), msg, BROWN, 8 );
if( CurrentConvert > 1 ) if( m_convert > 1 )
msg = _( "Convert" ); msg = _( "Convert" );
else else
msg = _( "Normal" ); msg = _( "Normal" );
MsgPanel->AppendMessage( _( "Body" ), msg, GREEN, 8 ); MsgPanel->AppendMessage( _( "Body" ), msg, GREEN, 8 );
if( m_currentComponent->m_Options == ENTRY_POWER ) if( m_component->m_Options == ENTRY_POWER )
msg = _( "Power Symbol" ); msg = _( "Power Symbol" );
else else
msg = _( "Component" ); msg = _( "Component" );
@ -337,14 +339,14 @@ void WinEDA_LibeditFrame::DisplayCmpDoc()
if( alias != NULL ) if( alias != NULL )
msg = alias->m_Doc; msg = alias->m_Doc;
else else
msg = m_currentComponent->m_Doc; msg = m_component->m_Doc;
MsgPanel->AppendMessage( _( "Description" ), msg, CYAN, 8 ); MsgPanel->AppendMessage( _( "Description" ), msg, CYAN, 8 );
if( alias != NULL ) if( alias != NULL )
msg = alias->m_KeyWord; msg = alias->m_KeyWord;
else else
msg = m_currentComponent->m_KeyWord; msg = m_component->m_KeyWord;
MsgPanel->AppendMessage( _( "Key words" ), msg, DARKDARKGRAY ); MsgPanel->AppendMessage( _( "Key words" ), msg, DARKDARKGRAY );
} }
@ -371,62 +373,63 @@ void WinEDA_LibeditFrame::DeleteOnePart( wxCommandEvent& event )
DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW ); DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW );
LibItemToRepeat = NULL; m_lastDrawItem = NULL;
CurrentDrawItem = NULL; m_drawItem = NULL;
if( CurrentLib == NULL ) if( m_library == NULL )
{ {
SelectActiveLibrary(); SelectActiveLibrary();
if( CurrentLib == NULL ) if( m_library == NULL )
{ {
DisplayError( this, _( "Please select a component library." ) ); DisplayError( this, _( "Please select a component library." ) );
return; return;
} }
} }
CurrentLib->GetEntryNames( ListNames ); m_library->GetEntryNames( ListNames );
if( ListNames.IsEmpty() ) if( ListNames.IsEmpty() )
{ {
msg.Printf( _( "Component library <%s> is empty." ), msg.Printf( _( "Component library <%s> is empty." ),
( const wxChar* ) CurrentLib->GetName() ); ( const wxChar* ) m_library->GetName() );
wxMessageBox( msg, _( "Delete Entry Error" ), wxMessageBox( msg, _( "Delete Entry Error" ),
wxID_OK | wxICON_EXCLAMATION, this ); wxID_OK | wxICON_EXCLAMATION, this );
return; return;
} }
msg.Printf( _( "Select 1 of %d components to delete\nfrom library <%s>." ), msg.Printf( _( "Select 1 of %d components to delete\nfrom library <%s>." ),
ListNames.GetCount(), ( const wxChar* ) CurrentLib->GetName() ); ListNames.GetCount(),
( const wxChar* ) m_library->GetName() );
wxSingleChoiceDialog dlg( this, msg, _( "Delete Component" ), ListNames ); wxSingleChoiceDialog dlg( this, msg, _( "Delete Component" ), ListNames );
if( dlg.ShowModal() == wxID_CANCEL || dlg.GetStringSelection().IsEmpty() ) if( dlg.ShowModal() == wxID_CANCEL || dlg.GetStringSelection().IsEmpty() )
return; return;
LibEntry = CurrentLib->FindEntry( dlg.GetStringSelection() ); LibEntry = m_library->FindEntry( dlg.GetStringSelection() );
if( LibEntry == NULL ) if( LibEntry == NULL )
{ {
msg.Printf( _( "Entry <%s> not found in library <%s>." ), msg.Printf( _( "Entry <%s> not found in library <%s>." ),
( const wxChar* ) dlg.GetStringSelection(), ( const wxChar* ) dlg.GetStringSelection(),
( const wxChar* ) CurrentLib->GetName() ); ( const wxChar* ) m_library->GetName() );
DisplayError( this, msg ); DisplayError( this, msg );
return; return;
} }
msg.Printf( _( "Delete component \"%s\" from library \"%s\"?" ), msg.Printf( _( "Delete component \"%s\" from library \"%s\"?" ),
(const wxChar*) LibEntry->GetName(), (const wxChar*) LibEntry->GetName(),
(const wxChar*) CurrentLib->GetName() ); (const wxChar*) m_library->GetName() );
if( !IsOK( this, msg ) ) if( !IsOK( this, msg ) )
return; return;
if( m_currentComponent == NULL if( m_component == NULL
|| ( m_currentComponent->GetName().CmpNoCase( LibEntry->GetName() ) != 0 || ( m_component->GetName().CmpNoCase( LibEntry->GetName() ) != 0
&& !m_currentComponent->HasAlias( LibEntry->GetName() ) ) ) && !m_component->HasAlias( LibEntry->GetName() ) ) )
{ {
CurrentLib->RemoveEntry( LibEntry ); m_library->RemoveEntry( LibEntry );
return; return;
} }
@ -447,33 +450,32 @@ All changes will be lost. Discard changes?" ) ) )
* in the library will be shown. If the current component has * in the library will be shown. If the current component has
* aliases, the updated component will be shown * aliases, the updated component will be shown
*/ */
if( m_currentComponent->GetName().CmpNoCase( LibEntry->GetName() ) == 0 ) if( m_component->GetName().CmpNoCase( LibEntry->GetName() ) == 0 )
{ {
if( m_currentComponent->m_AliasList.IsEmpty() ) if( m_component->m_AliasList.IsEmpty() )
{ {
nextEntry = nextEntry = m_library->GetNextEntry( m_component->GetName() );
CurrentLib->GetNextEntry( m_currentComponent->GetName() );
if( nextEntry != NULL ) if( nextEntry != NULL )
newCmpName = nextEntry->GetName(); newCmpName = nextEntry->GetName();
} }
else else
{ {
newCmpName = m_currentComponent->m_AliasList[ 0 ]; newCmpName = m_component->m_AliasList[ 0 ];
} }
} }
else else
{ {
newCmpName = m_currentComponent->GetName(); newCmpName = m_component->GetName();
} }
CurrentLib->RemoveEntry( LibEntry ); m_library->RemoveEntry( LibEntry );
if( !newCmpName.IsEmpty() ) if( !newCmpName.IsEmpty() )
{ {
nextEntry = CurrentLib->FindEntry( newCmpName ); nextEntry = m_library->FindEntry( newCmpName );
if( nextEntry != NULL && LoadOneLibraryPartAux( nextEntry, CurrentLib ) ) if( nextEntry != NULL && LoadOneLibraryPartAux( nextEntry, m_library ) )
Zoom_Automatique( false ); Zoom_Automatique( false );
DrawPanel->Refresh(); DrawPanel->Refresh();
@ -492,14 +494,14 @@ void WinEDA_LibeditFrame::CreateNewLibraryPart( wxCommandEvent& event )
wxString msg; wxString msg;
LIB_COMPONENT* NewStruct; LIB_COMPONENT* NewStruct;
if( m_currentComponent && GetScreen()->IsModify() if( m_component && GetScreen()->IsModify()
&& !IsOK( this, _( "All changes to the current component will be \ && !IsOK( this, _( "All changes to the current component will be \
lost!\n\nClear the current component from the screen?" ) ) ) lost!\n\nClear the current component from the screen?" ) ) )
return; return;
DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW ); DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW );
CurrentDrawItem = NULL; m_drawItem = NULL;
WinEDA_CreateCmpDialog Dialogbox( this ); WinEDA_CreateCmpDialog Dialogbox( this );
diag = Dialogbox.ShowModal(); diag = Dialogbox.ShowModal();
@ -512,15 +514,15 @@ lost!\n\nClear the current component from the screen?" ) ) )
msg.Replace( wxT( " " ), wxT( "_" ) ); msg.Replace( wxT( " " ), wxT( "_" ) );
/* Test: y a t-il un composant deja de ce nom */ /* Test: y a t-il un composant deja de ce nom */
if( CurrentLib ) if( m_library )
{ {
if( CurrentLib->FindEntry( msg ) ) if( m_library->FindEntry( msg ) )
{ {
wxString msg; wxString msg;
msg.Printf( _( "Component \"%s\" already exists in \ msg.Printf( _( "Component \"%s\" already exists in \
library \"%s\"." ), library \"%s\"." ),
(const wxChar*) Dialogbox.ReturnCmpName(), (const wxChar*) Dialogbox.ReturnCmpName(),
(const wxChar*) CurrentLib->GetName() ); (const wxChar*) m_library->GetName() );
DisplayError( this, msg ); DisplayError( this, msg );
return; return;
} }
@ -533,19 +535,19 @@ library \"%s\"." ),
NewStruct->m_Prefix.m_Text.MakeUpper(); NewStruct->m_Prefix.m_Text.MakeUpper();
// Effacement ancien composant affich<63> // Effacement ancien composant affich<63>
if( m_currentComponent ) if( m_component )
{ {
SAFE_DELETE( m_currentComponent ); SAFE_DELETE( m_component );
} }
m_currentComponent = NewStruct; m_component = NewStruct;
CurrentUnit = 1; m_unit = 1;
CurrentConvert = 1; m_convert = 1;
DisplayLibInfos(); DisplayLibInfos();
DisplayCmpDoc(); DisplayCmpDoc();
UpdateAliasSelectList(); UpdateAliasSelectList();
UpdatePartSelectList(); UpdatePartSelectList();
g_EditPinByPinIsOn = false; g_EditPinByPinIsOn = false;
LibItemToRepeat = NULL; m_lastDrawItem = NULL;
GetScreen()->ClearUndoRedoList(); GetScreen()->ClearUndoRedoList();
DrawPanel->Refresh(); DrawPanel->Refresh();
} }
@ -564,24 +566,24 @@ void WinEDA_LibeditFrame::SaveOnePartInMemory()
LIB_COMPONENT* Component; LIB_COMPONENT* Component;
wxString msg; wxString msg;
if( m_currentComponent == NULL ) if( m_component == NULL )
{ {
DisplayError( this, _( "No component to save." ) ); DisplayError( this, _( "No component to save." ) );
return; return;
} }
if( CurrentLib == NULL ) if( m_library == NULL )
SelectActiveLibrary(); SelectActiveLibrary();
if( CurrentLib == NULL ) if( m_library == NULL )
{ {
DisplayError( this, _( "No library specified." ) ); DisplayError( this, _( "No library specified." ) );
return; return;
} }
g_ScreenLib->ClrModify(); GetBaseScreen()->ClrModify();
oldComponent = CurrentLib->FindComponent( m_currentComponent->GetName() ); oldComponent = m_library->FindComponent( m_component->GetName() );
if( oldComponent != NULL ) if( oldComponent != NULL )
{ {
@ -591,19 +593,20 @@ void WinEDA_LibeditFrame::SaveOnePartInMemory()
return; return;
} }
wxASSERT( m_currentComponent->Type == ROOT ); m_drawItem = m_lastDrawItem = NULL;
wxASSERT( m_component->Type == ROOT );
if( oldComponent != NULL ) if( oldComponent != NULL )
Component = CurrentLib->ReplaceComponent( oldComponent, Component = m_library->ReplaceComponent( oldComponent, m_component );
m_currentComponent );
else else
Component = CurrentLib->AddComponent( m_currentComponent ); Component = m_library->AddComponent( m_component );
if( Component == NULL ) if( Component == NULL )
return; return;
msg.Printf( _( "Component %s saved in library %s" ), msg.Printf( _( "Component %s saved in library %s" ),
( const wxChar* ) Component->GetName(), ( const wxChar* ) Component->GetName(),
( const wxChar* ) CurrentLib->GetName() ); ( const wxChar* ) m_library->GetName() );
Affiche_Message( msg ); Affiche_Message( msg );
} }

View File

@ -13,24 +13,25 @@
#include "eeschema_id.h" #include "eeschema_id.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "libcmp.h"
#include "protos.h" #include "protos.h"
#include "libeditfrm.h" #include "libeditfrm.h"
#include "class_libentry.h"
void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{ {
LibEDA_BaseStruct* DrawEntry = CurrentDrawItem; LIB_DRAW_ITEM* DrawEntry = m_drawItem;
if( m_currentComponent == NULL ) // No component loaded ! if( m_component == NULL ) // No component loaded !
return; return;
if( m_ID_current_state == 0 ) if( m_ID_current_state == 0 )
{ {
if( DrawEntry && DrawEntry->m_Flags ) if( DrawEntry && DrawEntry->m_Flags )
{ {
SaveCopyInUndoList( m_currentComponent ); SaveCopyInUndoList( m_component );
switch( DrawEntry->Type() ) switch( DrawEntry->Type() )
{ {
@ -50,28 +51,24 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
} }
else else
{ {
DrawEntry = LocatePin( GetScreen()->m_MousePosition, DrawEntry = LocatePin( GetScreen()->m_MousePosition, m_component,
m_currentComponent, CurrentUnit, m_unit, m_convert );
CurrentConvert );
if( DrawEntry == NULL ) if( DrawEntry == NULL )
{ {
DrawEntry = LocateDrawItem( (SCH_SCREEN*)GetScreen(), DrawEntry = LocateDrawItem( (SCH_SCREEN*)GetScreen(),
GetScreen()->m_MousePosition, GetScreen()->m_MousePosition,
m_currentComponent, CurrentUnit, m_component, m_unit, m_convert,
CurrentConvert,
LOCATE_ALL_DRAW_ITEM ); LOCATE_ALL_DRAW_ITEM );
} }
if( DrawEntry == NULL ) if( DrawEntry == NULL )
DrawEntry = LocatePin( GetScreen()->m_Curseur, DrawEntry = LocatePin( GetScreen()->m_Curseur, m_component,
m_currentComponent, CurrentUnit, m_unit, m_convert );
CurrentConvert );
if( DrawEntry == NULL ) if( DrawEntry == NULL )
{ {
DrawEntry = LocateDrawItem( (SCH_SCREEN*)GetScreen(), DrawEntry = LocateDrawItem( (SCH_SCREEN*)GetScreen(),
GetScreen()->m_Curseur, GetScreen()->m_Curseur,
m_currentComponent, CurrentUnit, m_component, m_unit, m_convert,
CurrentConvert,
LOCATE_ALL_DRAW_ITEM ); LOCATE_ALL_DRAW_ITEM );
} }
@ -91,13 +88,13 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
break; break;
case ID_LIBEDIT_PIN_BUTT: case ID_LIBEDIT_PIN_BUTT:
if( CurrentDrawItem == NULL || CurrentDrawItem->m_Flags == 0 ) if( m_drawItem == NULL || m_drawItem->m_Flags == 0 )
{ {
CreatePin( DC ); CreatePin( DC );
} }
else else
{ {
SaveCopyInUndoList( m_currentComponent ); SaveCopyInUndoList( m_component );
PlacePin( DC ); PlacePin( DC );
} }
break; break;
@ -107,60 +104,57 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
case ID_LIBEDIT_BODY_CIRCLE_BUTT: case ID_LIBEDIT_BODY_CIRCLE_BUTT:
case ID_LIBEDIT_BODY_RECT_BUTT: case ID_LIBEDIT_BODY_RECT_BUTT:
case ID_LIBEDIT_BODY_TEXT_BUTT: case ID_LIBEDIT_BODY_TEXT_BUTT:
if( CurrentDrawItem == NULL || CurrentDrawItem->m_Flags == 0 ) if( m_drawItem == NULL || m_drawItem->m_Flags == 0 )
{ {
CurrentDrawItem = CreateGraphicItem( m_currentComponent, DC ); m_drawItem = CreateGraphicItem( m_component, DC );
} }
else if( CurrentDrawItem ) else if( m_drawItem )
{ {
if( CurrentDrawItem->m_Flags & IS_NEW ) if( m_drawItem->m_Flags & IS_NEW )
GraphicItemBeginDraw( DC ); GraphicItemBeginDraw( DC );
else else
{ {
SaveCopyInUndoList( m_currentComponent ); SaveCopyInUndoList( m_component );
EndDrawGraphicItem( DC ); EndDrawGraphicItem( DC );
} }
} }
break; break;
case ID_LIBEDIT_DELETE_ITEM_BUTT: case ID_LIBEDIT_DELETE_ITEM_BUTT:
DrawEntry = LocatePin( GetScreen()->m_MousePosition, DrawEntry = LocatePin( GetScreen()->m_MousePosition, m_component,
m_currentComponent, CurrentUnit, m_unit, m_convert );
CurrentConvert );
if( DrawEntry == NULL ) if( DrawEntry == NULL )
{ {
DrawEntry = LocateDrawItem( (SCH_SCREEN*)GetScreen(), DrawEntry = LocateDrawItem( (SCH_SCREEN*)GetScreen(),
GetScreen()->m_MousePosition, GetScreen()->m_MousePosition,
m_currentComponent, CurrentUnit, m_component, m_unit, m_convert,
CurrentConvert,
LOCATE_ALL_DRAW_ITEM ); LOCATE_ALL_DRAW_ITEM );
} }
if( DrawEntry == NULL ) if( DrawEntry == NULL )
DrawEntry = LocatePin( GetScreen()->m_Curseur, DrawEntry = LocatePin( GetScreen()->m_Curseur,
m_currentComponent, CurrentUnit, m_component, m_unit,
CurrentConvert ); m_convert );
if( DrawEntry == NULL ) if( DrawEntry == NULL )
{ {
DrawEntry = LocateDrawItem( (SCH_SCREEN*)GetScreen(), DrawEntry = LocateDrawItem( (SCH_SCREEN*)GetScreen(),
GetScreen()->m_Curseur, GetScreen()->m_Curseur,
m_currentComponent, CurrentUnit, m_component, m_unit, m_convert,
CurrentConvert,
LOCATE_ALL_DRAW_ITEM ); LOCATE_ALL_DRAW_ITEM );
} }
if( DrawEntry == NULL ) if( DrawEntry == NULL )
DisplayCmpDoc(); DisplayCmpDoc();
SaveCopyInUndoList( m_currentComponent ); SaveCopyInUndoList( m_component );
if( DrawEntry->Type() == COMPONENT_PIN_DRAW_TYPE ) if( DrawEntry->Type() == COMPONENT_PIN_DRAW_TYPE )
DeletePin( DC, m_currentComponent, (LibDrawPin*) DrawEntry ); DeletePin( DC, m_component, (LibDrawPin*) DrawEntry );
else else
m_currentComponent->RemoveDrawItem( DrawEntry, DrawPanel, DC ); m_component->RemoveDrawItem( DrawEntry, DrawPanel, DC );
DrawEntry = NULL; DrawEntry = NULL;
GetScreen()->SetModify(); GetScreen()->SetModify();
break; break;
case ID_LIBEDIT_ANCHOR_ITEM_BUTT: case ID_LIBEDIT_ANCHOR_ITEM_BUTT:
SaveCopyInUndoList( m_currentComponent ); SaveCopyInUndoList( m_component );
PlaceAncre(); PlaceAncre();
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
break; break;
@ -184,38 +178,36 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
void WinEDA_LibeditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) void WinEDA_LibeditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
{ {
wxPoint pos = GetPosition(); wxPoint pos = GetPosition();
LibEDA_BaseStruct* DrawEntry = CurrentDrawItem; LIB_DRAW_ITEM* DrawEntry = m_drawItem;
if( m_currentComponent == NULL ) if( m_component == NULL )
return; return;
if( ( DrawEntry == NULL ) || ( DrawEntry->m_Flags == 0 ) ) if( ( DrawEntry == NULL ) || ( DrawEntry->m_Flags == 0 ) )
{ // We can locate an item { // We can locate an item
DrawEntry = LocatePin( GetScreen()->m_MousePosition, m_currentComponent, DrawEntry = LocatePin( GetScreen()->m_MousePosition, m_component,
CurrentUnit, CurrentConvert ); m_unit, m_convert );
if( DrawEntry == NULL ) if( DrawEntry == NULL )
DrawEntry = LocatePin( GetScreen()->m_Curseur, m_currentComponent, DrawEntry = LocatePin( GetScreen()->m_Curseur, m_component,
CurrentUnit, CurrentConvert ); m_unit, m_convert );
if( DrawEntry == NULL ) if( DrawEntry == NULL )
{ {
DrawEntry = CurrentDrawItem = DrawEntry = m_drawItem =
LocateDrawItem( (SCH_SCREEN*) GetScreen(), LocateDrawItem( (SCH_SCREEN*) GetScreen(),
GetScreen()->m_MousePosition, GetScreen()->m_MousePosition, m_component,
m_currentComponent, CurrentUnit, m_unit, m_convert, LOCATE_ALL_DRAW_ITEM );
CurrentConvert, LOCATE_ALL_DRAW_ITEM );
} }
if( DrawEntry == NULL ) if( DrawEntry == NULL )
{ {
DrawEntry = CurrentDrawItem = DrawEntry = m_drawItem =
LocateDrawItem( (SCH_SCREEN*) GetScreen(), LocateDrawItem( (SCH_SCREEN*) GetScreen(),
GetScreen()->m_Curseur, GetScreen()->m_Curseur, m_component, m_unit,
m_currentComponent, CurrentUnit, m_convert, LOCATE_ALL_DRAW_ITEM );
CurrentConvert, LOCATE_ALL_DRAW_ITEM );
} }
if( DrawEntry == NULL ) if( DrawEntry == NULL )
{ {
DrawEntry = CurrentDrawItem = DrawEntry = m_drawItem =
(LibEDA_BaseStruct*) LocateField( m_currentComponent ); (LIB_DRAW_ITEM*) LocateField( m_component );
} }
if( DrawEntry == NULL ) if( DrawEntry == NULL )
{ {
@ -228,7 +220,7 @@ void WinEDA_LibeditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
else else
return; return;
CurrentDrawItem = DrawEntry; m_drawItem = DrawEntry;
DrawPanel->m_IgnoreMouseEvents = TRUE; DrawPanel->m_IgnoreMouseEvents = TRUE;

View File

@ -14,10 +14,10 @@
#include "hotkeys.h" #include "hotkeys.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "libeditfrm.h" #include "libeditfrm.h"
#include "class_libentry.h"
/* functions to add commands and submenus depending on the item */ /* functions to add commands and submenus depending on the item */
@ -29,10 +29,10 @@ static void AddMenusForPin( wxMenu* PopMenu, LibDrawPin* Pin,
bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos, bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos,
wxMenu* PopMenu ) wxMenu* PopMenu )
{ {
LibEDA_BaseStruct* DrawEntry = LocateItemUsingCursor(); LIB_DRAW_ITEM* DrawEntry = LocateItemUsingCursor();
bool BlockActive = (GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE); bool BlockActive = (GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE);
if( m_currentComponent == NULL ) if( m_component == NULL )
return true; return true;
// If Command in progresss: put the menu "cancel" and "end tool" // If Command in progresss: put the menu "cancel" and "end tool"
@ -68,7 +68,7 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos,
else else
return true; return true;
CurrentDrawItem = DrawEntry; m_drawItem = DrawEntry;
wxString msg; wxString msg;
switch( DrawEntry->Type() ) switch( DrawEntry->Type() )
@ -211,7 +211,7 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos,
StructType %d" ), StructType %d" ),
DrawEntry->Type() ); DrawEntry->Type() );
DisplayError( this, msg ); DisplayError( this, msg );
CurrentDrawItem = NULL; m_drawItem = NULL;
break; break;
} }

View File

@ -7,10 +7,10 @@
#include "common.h" #include "common.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "libeditfrm.h" #include "libeditfrm.h"
#include "class_libentry.h"
/*************************************************************************/ /*************************************************************************/
@ -22,7 +22,7 @@ void WinEDA_LibeditFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy,
LIB_COMPONENT* CopyItem; LIB_COMPONENT* CopyItem;
PICKED_ITEMS_LIST* lastcmd; PICKED_ITEMS_LIST* lastcmd;
CopyItem = CopyLibEntryStruct( (LIB_COMPONENT*) ItemToCopy ); CopyItem = new LIB_COMPONENT( *( (LIB_COMPONENT*) ItemToCopy ) );
if( CopyItem == NULL ) if( CopyItem == NULL )
return; return;
@ -54,17 +54,17 @@ void WinEDA_LibeditFrame::GetComponentFromRedoList(wxCommandEvent& event)
return; return;
PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST(); PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST();
ITEM_PICKER wrapper(m_currentComponent, UR_LIBEDIT); ITEM_PICKER wrapper(m_component, UR_LIBEDIT);
lastcmd->PushItem(wrapper); lastcmd->PushItem(wrapper);
GetScreen()->PushCommandToUndoList( lastcmd ); GetScreen()->PushCommandToUndoList( lastcmd );
lastcmd = GetScreen()->PopCommandFromRedoList( ); lastcmd = GetScreen()->PopCommandFromRedoList( );
wrapper = lastcmd->PopItem(); wrapper = lastcmd->PopItem();
m_currentComponent = (LIB_COMPONENT*) wrapper.m_PickedItem; m_component = (LIB_COMPONENT*) wrapper.m_PickedItem;
if( m_currentComponent ) if( m_component )
m_currentComponent->SetNext( NULL ); m_component->SetNext( NULL );
CurrentDrawItem = NULL; m_drawItem = NULL;
GetScreen()->SetModify(); GetScreen()->SetModify();
DrawPanel->Refresh(); DrawPanel->Refresh();
} }
@ -84,18 +84,18 @@ void WinEDA_LibeditFrame::GetComponentFromUndoList(wxCommandEvent& event)
return; return;
PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST(); PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST();
ITEM_PICKER wrapper(m_currentComponent, UR_LIBEDIT); ITEM_PICKER wrapper(m_component, UR_LIBEDIT);
lastcmd->PushItem(wrapper); lastcmd->PushItem(wrapper);
GetScreen()->PushCommandToRedoList( lastcmd ); GetScreen()->PushCommandToRedoList( lastcmd );
lastcmd = GetScreen()->PopCommandFromUndoList( ); lastcmd = GetScreen()->PopCommandFromUndoList( );
wrapper = lastcmd->PopItem(); wrapper = lastcmd->PopItem();
m_currentComponent = (LIB_COMPONENT*) wrapper.m_PickedItem; m_component = (LIB_COMPONENT*) wrapper.m_PickedItem;
if( m_currentComponent ) if( m_component )
m_currentComponent->SetNext( NULL ); m_component->SetNext( NULL );
CurrentDrawItem = NULL; m_drawItem = NULL;
GetScreen()->SetModify(); GetScreen()->SetModify();
DrawPanel->Refresh(); DrawPanel->Refresh();
} }

View File

@ -12,6 +12,7 @@ class SCH_SCREEN;
class CMP_LIBRARY; class CMP_LIBRARY;
class LIB_COMPONENT; class LIB_COMPONENT;
class LIB_ALIAS; class LIB_ALIAS;
class LIB_DRAW_ITEM;
/** /**
* The component library editor main window. * The component library editor main window.
@ -39,6 +40,10 @@ public:
void CreateNewLibraryPart( wxCommandEvent& event ); void CreateNewLibraryPart( wxCommandEvent& event );
void OnEditComponentProperties( wxCommandEvent& event ); void OnEditComponentProperties( wxCommandEvent& event );
void InstallFieldsEditorDialog( wxCommandEvent& event ); void InstallFieldsEditorDialog( wxCommandEvent& event );
void LoadOneLibraryPart( wxCommandEvent& event );
void OnViewEntryDoc( wxCommandEvent& event );
void OnCheckComponent( wxCommandEvent& event );
void OnSelectBodyStyle( wxCommandEvent& event );
void OnUpdateEditingPart( wxUpdateUIEvent& event ); void OnUpdateEditingPart( wxUpdateUIEvent& event );
void OnUpdateNotEditingPart( wxUpdateUIEvent& event ); void OnUpdateNotEditingPart( wxUpdateUIEvent& event );
@ -74,17 +79,51 @@ public:
void LoadSettings(); void LoadSettings();
void SaveSettings(); void SaveSettings();
LIB_COMPONENT* GetCurrentComponent( void ) LIB_COMPONENT* GetComponent( void ) { return m_component; }
CMP_LIBRARY* GetLibrary( void ) { return m_library; }
wxString& GetAliasName( void ) { return m_aliasName; }
int GetUnit( void ) { return m_unit; }
void SetUnit( int unit )
{ {
return m_currentComponent; wxASSERT( unit >= 1 );
m_unit = unit;
} }
int GetConvert( void ) { return m_convert; }
void SetConvert( int convert )
{
wxASSERT( convert >= 1 );
m_convert = convert;
}
LIB_DRAW_ITEM* GetLastDrawItem( void ) { return m_lastDrawItem; }
void SetLastDrawItem( LIB_DRAW_ITEM* drawItem )
{
m_lastDrawItem = drawItem;
}
LIB_DRAW_ITEM* GetDrawItem( void ) { return m_drawItem; }
void SetDrawItem( LIB_DRAW_ITEM* drawItem )
{
m_drawItem = drawItem;
}
bool GetShowDeMorgan( void ) { return m_showDeMorgan; }
void SetShowDeMorgan( bool show ) { m_showDeMorgan = show; }
private: private:
// General: // General:
void SaveOnePartInMemory(); void SaveOnePartInMemory();
void SelectActiveLibrary(); void SelectActiveLibrary();
bool LoadOneLibraryPart();
void SaveActiveLibrary( wxCommandEvent& event ); void SaveActiveLibrary( wxCommandEvent& event );
bool LoadOneLibraryPartAux( CMP_LIB_ENTRY* LibEntry, bool LoadOneLibraryPartAux( CMP_LIB_ENTRY* LibEntry,
@ -109,26 +148,23 @@ private:
LibDrawPin* Pin ); LibDrawPin* Pin );
void StartMovePin( wxDC* DC ); void StartMovePin( wxDC* DC );
// Test des pins ( duplicates...)
bool TestPins( LIB_COMPONENT* LibEntry );
// Edition de l'ancre // Edition de l'ancre
void PlaceAncre(); void PlaceAncre();
// Edition des graphismes: // Edition des graphismes:
LibEDA_BaseStruct* CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC* DC ); LIB_DRAW_ITEM* CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC* DC );
void GraphicItemBeginDraw( wxDC* DC ); void GraphicItemBeginDraw( wxDC* DC );
void StartMoveDrawSymbol( wxDC* DC ); void StartMoveDrawSymbol( wxDC* DC );
void EndDrawGraphicItem( wxDC* DC ); void EndDrawGraphicItem( wxDC* DC );
void LoadOneSymbol(); void LoadOneSymbol();
void SaveOneSymbol(); void SaveOneSymbol();
void EditGraphicSymbol( wxDC* DC, void EditGraphicSymbol( wxDC* DC,
LibEDA_BaseStruct* DrawItem ); LIB_DRAW_ITEM* DrawItem );
void EditSymbolText( wxDC* DC, LibEDA_BaseStruct* DrawItem ); void EditSymbolText( wxDC* DC, LIB_DRAW_ITEM* DrawItem );
void RotateSymbolText( wxDC* DC ); void RotateSymbolText( wxDC* DC );
void DeleteDrawPoly( wxDC* DC ); void DeleteDrawPoly( wxDC* DC );
LibDrawField* LocateField( LIB_COMPONENT* LibEntry ); LibDrawField* LocateField( LIB_COMPONENT* LibEntry );
LibEDA_BaseStruct* LocateItemUsingCursor(); LIB_DRAW_ITEM* LocateItemUsingCursor();
void RotateField( wxDC* DC, LibDrawField* Field ); void RotateField( wxDC* DC, LibDrawField* Field );
void PlaceField( wxDC* DC, LibDrawField* Field ); void PlaceField( wxDC* DC, LibDrawField* Field );
void EditField( wxDC* DC, LibDrawField* Field ); void EditField( wxDC* DC, LibDrawField* Field );
@ -152,7 +188,15 @@ protected:
wxString m_LastLibImportPath; wxString m_LastLibImportPath;
wxString m_LastLibExportPath; wxString m_LastLibExportPath;
static LIB_COMPONENT* m_currentComponent; static LIB_COMPONENT* m_component;
static CMP_LIBRARY* m_library;
static LIB_DRAW_ITEM* m_lastDrawItem;
static LIB_DRAW_ITEM* m_drawItem;
static wxString m_aliasName;
static int m_unit;
static int m_convert;
static bool m_showDeMorgan;
static wxSize m_clientSize;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@ -9,10 +9,11 @@
#include "confirm.h" #include "confirm.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "libcmp.h"
#include "protos.h" #include "protos.h"
#include "libeditfrm.h" #include "libeditfrm.h"
#include "class_library.h"
/* Routines locales */ /* Routines locales */
@ -20,7 +21,7 @@ static void ShowMoveField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
/* Variables locales */ /* Variables locales */
extern int CurrentUnit; extern int m_unit;
static wxPoint StartCursor, LastTextPosition; static wxPoint StartCursor, LastTextPosition;
@ -28,7 +29,15 @@ static void ExitMoveField( WinEDA_DrawPanel* Panel, wxDC* DC )
{ {
Panel->ManageCurseur = NULL; Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL;
if( CurrentDrawItem == NULL )
WinEDA_LibeditFrame* parent = ( WinEDA_LibeditFrame* ) Panel->GetParent();
if( parent == NULL )
return;
LIB_DRAW_ITEM* item = parent->GetDrawItem();
if( item == NULL )
return; return;
wxPoint curpos = Panel->GetScreen()->m_Curseur; wxPoint curpos = Panel->GetScreen()->m_Curseur;
@ -36,9 +45,8 @@ static void ExitMoveField( WinEDA_DrawPanel* Panel, wxDC* DC )
Panel->GetScreen()->m_Curseur = StartCursor; Panel->GetScreen()->m_Curseur = StartCursor;
ShowMoveField( Panel, DC, TRUE ); ShowMoveField( Panel, DC, TRUE );
Panel->GetScreen()->m_Curseur = curpos; Panel->GetScreen()->m_Curseur = curpos;
CurrentDrawItem->m_Flags = 0; item->m_Flags = 0;
parent->SetDrawItem( NULL );
CurrentDrawItem = NULL;
} }
@ -49,12 +57,12 @@ void WinEDA_LibeditFrame::StartMoveField( wxDC* DC, LibDrawField* field )
{ {
wxPoint startPos; wxPoint startPos;
if( ( m_currentComponent == NULL ) || ( field == NULL ) ) if( ( m_component == NULL ) || ( field == NULL ) )
return; return;
CurrentDrawItem = field; m_drawItem = field;
LastTextPosition = field->m_Pos; LastTextPosition = field->m_Pos;
CurrentDrawItem->m_Flags |= IS_MOVED; m_drawItem->m_Flags |= IS_MOVED;
startPos.x = LastTextPosition.x; startPos.x = LastTextPosition.x;
startPos.y = -LastTextPosition.y; startPos.y = -LastTextPosition.y;
@ -77,12 +85,17 @@ void WinEDA_LibeditFrame::StartMoveField( wxDC* DC, LibDrawField* field )
/*****************************************************************/ /*****************************************************************/
static void ShowMoveField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) static void ShowMoveField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{ {
LibDrawField* Field = (LibDrawField*) CurrentDrawItem; WinEDA_LibeditFrame* parent = (WinEDA_LibeditFrame*) panel->GetParent();
if( parent == NULL )
return;
LibDrawField* Field = (LibDrawField*) parent->GetDrawItem();
if( Field == NULL ) if( Field == NULL )
return; return;
wxString text = Field->GetFullText(); wxString text = Field->GetFullText( parent->GetUnit() );
if( erase ) if( erase )
Field->Draw( panel, DC, wxPoint( 0, 0 ), -1, g_XorMode, &text, Field->Draw( panel, DC, wxPoint( 0, 0 ), -1, g_XorMode, &text,
@ -107,7 +120,7 @@ void WinEDA_LibeditFrame::PlaceField( wxDC* DC, LibDrawField* Field )
Field->m_Pos.y = -GetScreen()->m_Curseur.y; Field->m_Pos.y = -GetScreen()->m_Curseur.y;
DrawPanel->CursorOff( DC ); DrawPanel->CursorOff( DC );
wxString fieldText = Field->GetFullText(); wxString fieldText = Field->GetFullText( m_unit );
Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, GR_DEFAULT_DRAWMODE, Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, GR_DEFAULT_DRAWMODE,
&fieldText, DefaultTransformMatrix ); &fieldText, DefaultTransformMatrix );
@ -116,7 +129,7 @@ void WinEDA_LibeditFrame::PlaceField( wxDC* DC, LibDrawField* Field )
GetScreen()->SetModify(); GetScreen()->SetModify();
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
CurrentDrawItem = NULL; m_drawItem = NULL;
} }
@ -148,13 +161,12 @@ void WinEDA_LibeditFrame::EditField( wxDC* DC, LibDrawField* Field )
Get_Message( title, _( "Edit field" ), Text, this ); Get_Message( title, _( "Edit field" ), Text, this );
Text.Replace( wxT( " " ), wxT( "_" ) ); Text.Replace( wxT( " " ), wxT( "_" ) );
/* If the value is changed, this is equivalent to create a new component /* If the value field is changed, this is equivalent to creating a new
* from the old one. * component from the old one. Check for an existing library entry of
* So we must check for an existing alias of this "new" component * this "new" component and change the value only if there is no existing
* and change the value only if there is no existing alias with the same * entry with the same name.
* name for this component
*/ */
if( Field->m_FieldId == VALUE ) if( Field->m_FieldId == VALUE && Text != Field->m_Text )
{ {
wxString msg; wxString msg;
@ -173,19 +185,19 @@ names in the alias list." ),
/* Test for an existing entry in the library to prevent duplicate /* Test for an existing entry in the library to prevent duplicate
* entry names. * entry names.
*/ */
if( CurrentLib && CurrentLib->FindEntry( Text ) != NULL ) if( m_library && m_library->FindEntry( Text ) != NULL )
{ {
msg.Printf( _( "The field name <%s> conflicts with an existing \ msg.Printf( _( "The field name <%s> conflicts with an existing \
entry in the component library <%s>.\nPlease choose another name that does \ entry in the component library <%s>.\nPlease choose another name that does \
not conflict with any library entries." ), not conflict with any library entries." ),
(const wxChar*) Text, (const wxChar*) Text,
(const wxChar*) CurrentLib->GetName() ); (const wxChar*) m_library->GetName() );
DisplayError( this, msg ); DisplayError( this, msg );
return; return;
} }
} }
wxString fieldText = Field->GetFullText(); wxString fieldText = Field->GetFullText( m_unit );
Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, &fieldText, Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, &fieldText,
DefaultTransformMatrix ); DefaultTransformMatrix );
@ -200,7 +212,7 @@ not conflict with any library entries." ),
DisplayError( this, _( "No new text: no change" ) ); DisplayError( this, _( "No new text: no change" ) );
} }
fieldText = Field->GetFullText(); fieldText = Field->GetFullText( m_unit );
int drawMode = g_XorMode; int drawMode = g_XorMode;
if( Field->m_Flags == 0 ) if( Field->m_Flags == 0 )
@ -229,7 +241,7 @@ void WinEDA_LibeditFrame::RotateField( wxDC* DC, LibDrawField* Field )
DrawPanel->CursorOff( DC ); DrawPanel->CursorOff( DC );
GRSetDrawMode( DC, g_XorMode ); GRSetDrawMode( DC, g_XorMode );
wxString fieldText = Field->GetFullText(); wxString fieldText = Field->GetFullText( m_unit );
Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, &fieldText, Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, &fieldText,
DefaultTransformMatrix ); DefaultTransformMatrix );
@ -283,37 +295,35 @@ LibDrawField* WinEDA_LibeditFrame::LocateField( LIB_COMPONENT* LibEntry )
} }
LibEDA_BaseStruct* WinEDA_LibeditFrame::LocateItemUsingCursor() LIB_DRAW_ITEM* WinEDA_LibeditFrame::LocateItemUsingCursor()
{ {
LibEDA_BaseStruct* DrawEntry = CurrentDrawItem; LIB_DRAW_ITEM* DrawEntry = m_drawItem;
if( m_currentComponent == NULL ) if( m_component == NULL )
return NULL; return NULL;
if( ( DrawEntry == NULL ) || ( DrawEntry->m_Flags == 0 ) ) if( ( DrawEntry == NULL ) || ( DrawEntry->m_Flags == 0 ) )
{ {
DrawEntry = LocatePin( GetScreen()->m_Curseur, m_currentComponent, DrawEntry = LocatePin( GetScreen()->m_Curseur, m_component,
CurrentUnit, CurrentConvert ); m_unit, m_convert );
if( DrawEntry == NULL ) if( DrawEntry == NULL )
{ {
DrawEntry = CurrentDrawItem = DrawEntry = m_drawItem =
LocateDrawItem( (SCH_SCREEN*) GetScreen(), LocateDrawItem( (SCH_SCREEN*) GetScreen(),
GetScreen()->m_MousePosition, GetScreen()->m_MousePosition, m_component,
m_currentComponent, CurrentUnit, m_unit, m_convert, LOCATE_ALL_DRAW_ITEM );
CurrentConvert, LOCATE_ALL_DRAW_ITEM );
} }
if( DrawEntry == NULL ) if( DrawEntry == NULL )
{ {
DrawEntry = CurrentDrawItem = DrawEntry = m_drawItem =
LocateDrawItem( (SCH_SCREEN*) GetScreen(), LocateDrawItem( (SCH_SCREEN*) GetScreen(),
GetScreen()->m_Curseur, m_currentComponent, GetScreen()->m_Curseur, m_component,
CurrentUnit, CurrentConvert, m_unit, m_convert, LOCATE_ALL_DRAW_ITEM );
LOCATE_ALL_DRAW_ITEM );
} }
if( DrawEntry == NULL ) if( DrawEntry == NULL )
{ {
DrawEntry = CurrentDrawItem = DrawEntry = m_drawItem =
(LibEDA_BaseStruct*) LocateField( m_currentComponent ); (LIB_DRAW_ITEM*) LocateField( m_component );
} }
} }

View File

@ -2,24 +2,20 @@
/* EESchema - libframe.cpp */ /* EESchema - libframe.cpp */
/****************************/ /****************************/
/* Gestion de la frame d'edition des composants en librairie
*/
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "common.h" #include "common.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "eda_doc.h" #include "eda_doc.h"
#include "bitmaps.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "bitmaps.h"
#include "protos.h" #include "protos.h"
#include "eeschema_id.h" #include "eeschema_id.h"
#include "class_library.h"
#include "libeditfrm.h" #include "libeditfrm.h"
#include "class_library.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
@ -29,7 +25,7 @@ const wxString lastLibExportPathEntry( wxT( "LastLibraryExportPath" ) );
const wxString lastLibImportPathEntry( wxT( "LastLibraryImportPath" ) ); const wxString lastLibImportPathEntry( wxT( "LastLibraryImportPath" ) );
const wxString showGridPathEntry( wxT( "ShowGrid" ) ); const wxString showGridPathEntry( wxT( "ShowGrid" ) );
/* This method guarentees unique IDs for the library this run of Eeschema /* This method guarantees unique IDs for the library this run of Eeschema
* which prevents ID conflicts and eliminates the need to recompile every * which prevents ID conflicts and eliminates the need to recompile every
* source file in the project when adding IDs to include/id.h. */ * source file in the project when adding IDs to include/id.h. */
int ExportPartId = ::wxNewId(); int ExportPartId = ::wxNewId();
@ -37,7 +33,21 @@ int ImportPartId = ::wxNewId();
int CreateNewLibAndSavePartId = ::wxNewId(); int CreateNewLibAndSavePartId = ::wxNewId();
LIB_COMPONENT* WinEDA_LibeditFrame::m_currentComponent = NULL; /*
* Static component library editor members. These are static so their
* state is saved between editing sessions. This way the last component
* that was being edited will be displayed. These members are protected
* making it necessary to use the class access methods.
*/
LIB_COMPONENT* WinEDA_LibeditFrame::m_component = NULL;
CMP_LIBRARY* WinEDA_LibeditFrame::m_library = NULL;
wxString WinEDA_LibeditFrame::m_aliasName;
int WinEDA_LibeditFrame::m_unit = 1;
int WinEDA_LibeditFrame::m_convert = 1;
LIB_DRAW_ITEM* WinEDA_LibeditFrame::m_lastDrawItem = NULL;
LIB_DRAW_ITEM* WinEDA_LibeditFrame::m_drawItem = NULL;
bool WinEDA_LibeditFrame::m_showDeMorgan = false;
wxSize WinEDA_LibeditFrame::m_clientSize = wxSize( -1, -1 );
/*****************************/ /*****************************/
@ -58,7 +68,7 @@ BEGIN_EVENT_TABLE( WinEDA_LibeditFrame, WinEDA_DrawFrame )
EVT_TOOL( ID_LIBEDIT_NEW_PART, EVT_TOOL( ID_LIBEDIT_NEW_PART,
WinEDA_LibeditFrame::CreateNewLibraryPart ) WinEDA_LibeditFrame::CreateNewLibraryPart )
EVT_TOOL( ID_LIBEDIT_SELECT_PART, EVT_TOOL( ID_LIBEDIT_SELECT_PART,
WinEDA_LibeditFrame::Process_Special_Functions ) WinEDA_LibeditFrame::LoadOneLibraryPart )
EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_PART, EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_PART,
WinEDA_LibeditFrame::Process_Special_Functions ) WinEDA_LibeditFrame::Process_Special_Functions )
EVT_TOOL( ID_LIBEDIT_UNDO, EVT_TOOL( ID_LIBEDIT_UNDO,
@ -70,13 +80,13 @@ BEGIN_EVENT_TABLE( WinEDA_LibeditFrame, WinEDA_DrawFrame )
EVT_TOOL( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, EVT_TOOL( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS,
WinEDA_LibeditFrame::InstallFieldsEditorDialog ) WinEDA_LibeditFrame::InstallFieldsEditorDialog )
EVT_TOOL( ID_LIBEDIT_CHECK_PART, EVT_TOOL( ID_LIBEDIT_CHECK_PART,
WinEDA_LibeditFrame::Process_Special_Functions ) WinEDA_LibeditFrame::OnCheckComponent )
EVT_TOOL( ID_DE_MORGAN_NORMAL_BUTT, EVT_TOOL( ID_DE_MORGAN_NORMAL_BUTT,
WinEDA_LibeditFrame::Process_Special_Functions ) WinEDA_LibeditFrame::OnSelectBodyStyle )
EVT_TOOL( ID_DE_MORGAN_CONVERT_BUTT, EVT_TOOL( ID_DE_MORGAN_CONVERT_BUTT,
WinEDA_LibeditFrame::Process_Special_Functions ) WinEDA_LibeditFrame::OnSelectBodyStyle )
EVT_TOOL( ID_LIBEDIT_VIEW_DOC, EVT_TOOL( ID_LIBEDIT_VIEW_DOC,
WinEDA_LibeditFrame::Process_Special_Functions ) WinEDA_LibeditFrame::OnViewEntryDoc )
EVT_TOOL( ID_LIBEDIT_EDIT_PIN_BY_PIN, EVT_TOOL( ID_LIBEDIT_EDIT_PIN_BY_PIN,
WinEDA_LibeditFrame::Process_Special_Functions ) WinEDA_LibeditFrame::Process_Special_Functions )
EVT_TOOL( ExportPartId, WinEDA_LibeditFrame::OnExportPart ) EVT_TOOL( ExportPartId, WinEDA_LibeditFrame::OnExportPart )
@ -147,7 +157,7 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father,
// Give an icon // Give an icon
SetIcon( wxIcon( libedit_xpm ) ); SetIcon( wxIcon( libedit_xpm ) );
SetBaseScreen( g_ScreenLib ); SetBaseScreen( new SCH_SCREEN() );
GetScreen()->m_Center = true; GetScreen()->m_Center = true;
LoadSettings(); LoadSettings();
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
@ -159,7 +169,7 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father,
DisplayCmpDoc(); DisplayCmpDoc();
UpdateAliasSelectList(); UpdateAliasSelectList();
UpdatePartSelectList(); UpdatePartSelectList();
BestZoom(); Zoom_Automatique( false );
Show( true ); Show( true );
} }
@ -169,6 +179,7 @@ WinEDA_LibeditFrame::~WinEDA_LibeditFrame()
WinEDA_SchematicFrame* frame = WinEDA_SchematicFrame* frame =
(WinEDA_SchematicFrame*) wxGetApp().GetTopWindow(); (WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
frame->m_LibeditFrame = NULL; frame->m_LibeditFrame = NULL;
m_drawItem = m_lastDrawItem = NULL;
} }
@ -178,7 +189,7 @@ WinEDA_LibeditFrame::~WinEDA_LibeditFrame()
* Don't forget to call this base method from any derived classes or the * Don't forget to call this base method from any derived classes or the
* settings will not get loaded. * settings will not get loaded.
*/ */
void WinEDA_LibeditFrame::LoadSettings( ) void WinEDA_LibeditFrame::LoadSettings()
{ {
wxConfig* cfg; wxConfig* cfg;
@ -248,41 +259,52 @@ void WinEDA_LibeditFrame::OnCloseWindow( wxCloseEvent& Event )
int WinEDA_LibeditFrame::BestZoom() int WinEDA_LibeditFrame::BestZoom()
{ {
int dx, dy, ii, jj; int dx, dy, ii, jj;
int bestzoom;
wxSize size; wxSize size;
EDA_Rect BoundaryBox; EDA_Rect BoundaryBox;
if( m_currentComponent ) if( m_component )
{ {
BoundaryBox = m_currentComponent->GetBoundaryBox( CurrentUnit, BoundaryBox = m_component->GetBoundaryBox( m_unit, m_convert );
CurrentConvert );
dx = BoundaryBox.GetWidth(); dx = BoundaryBox.GetWidth();
dy = BoundaryBox.GetHeight(); dy = BoundaryBox.GetHeight();
GetScreen()->m_Curseur = BoundaryBox.Centre();
} }
else else
{ {
dx = GetScreen()->m_CurrentSheetDesc->m_Size.x; dx = GetScreen()->m_CurrentSheetDesc->m_Size.x;
dy = GetScreen()->m_CurrentSheetDesc->m_Size.y; dy = GetScreen()->m_CurrentSheetDesc->m_Size.y;
GetScreen()->m_Curseur = wxPoint( 0, 0 );
} }
size = DrawPanel->GetClientSize(); /*
size -= wxSize( 100, 100 ); // reserve 100 mils margin * This fixes a bug where the client size of the drawing area is not
ii = abs( dx / size.x ); * correctly reported until after the window is shown. This is most
jj = abs( dy / size.y ); * likely due to the unmanaged windows ( vertical tool bars and message
* panel ) that are drawn in the main window which wxWidgets knows
bestzoom = MAX( ii, jj ) + 1; * nothing about. When the library editor is reopened with a component
* already loading, the zoom will be calculated correctly.
if( m_currentComponent ) */
if( !IsShownOnScreen() )
{ {
GetScreen()->m_Curseur = BoundaryBox.Centre(); if( m_clientSize != wxSize( -1, -1 ) )
size = m_clientSize;
else
size = DrawPanel->GetClientSize();
} }
else else
{ {
GetScreen()->m_Curseur.x = 0; if( m_clientSize == wxSize( -1, -1 ) )
GetScreen()->m_Curseur.y = 0; m_clientSize = DrawPanel->GetClientSize();
size = m_clientSize;
} }
return bestzoom * GetScreen()->m_ZoomScalar; size -= wxSize( 25, 25 ); // reserve 100 mils margin
ii = wxRound( ( (double) dx / (double) size.x ) *
(double) GetScreen()->m_ZoomScalar );
jj = wxRound( ( (double) dy / (double) size.y ) *
(double) GetScreen()->m_ZoomScalar );
return MAX( ii + 1, jj + 1 );
} }
@ -293,17 +315,17 @@ void WinEDA_LibeditFrame::UpdateAliasSelectList()
m_SelAliasBox->Clear(); m_SelAliasBox->Clear();
if( m_currentComponent == NULL ) if( m_component == NULL )
return; return;
m_SelAliasBox->Append( m_currentComponent->GetName() ); m_SelAliasBox->Append( m_component->GetName() );
m_SelAliasBox->SetSelection( 0 ); m_SelAliasBox->SetSelection( 0 );
if( !m_currentComponent->m_AliasList.IsEmpty() ) if( !m_component->m_AliasList.IsEmpty() )
{ {
m_SelAliasBox->Append( m_currentComponent->m_AliasList ); m_SelAliasBox->Append( m_component->m_AliasList );
int index = m_SelAliasBox->FindString( CurrentAliasName ); int index = m_SelAliasBox->FindString( m_aliasName );
if( index != wxNOT_FOUND ) if( index != wxNOT_FOUND )
m_SelAliasBox->SetSelection( index ); m_SelAliasBox->SetSelection( index );
@ -320,13 +342,13 @@ void WinEDA_LibeditFrame::UpdatePartSelectList()
if( m_SelpartBox->GetCount() != 0 ) if( m_SelpartBox->GetCount() != 0 )
m_SelpartBox->Clear(); m_SelpartBox->Clear();
if( m_currentComponent == NULL || m_currentComponent->m_UnitCount <= 1 ) if( m_component == NULL || m_component->m_UnitCount <= 1 )
{ {
m_SelpartBox->Append( wxEmptyString ); m_SelpartBox->Append( wxEmptyString );
} }
else else
{ {
for( int i = 0; i < m_currentComponent->m_UnitCount; i++ ) for( int i = 0; i < m_component->m_UnitCount; i++ )
{ {
wxString msg; wxString msg;
msg.Printf( _( "Part %c" ), 'A' + i ); msg.Printf( _( "Part %c" ), 'A' + i );
@ -334,40 +356,40 @@ void WinEDA_LibeditFrame::UpdatePartSelectList()
} }
} }
m_SelpartBox->SetSelection( ( CurrentUnit > 0 ) ? CurrentUnit - 1 : 0 ); m_SelpartBox->SetSelection( ( m_unit > 0 ) ? m_unit - 1 : 0 );
} }
void WinEDA_LibeditFrame::OnUpdateEditingPart( wxUpdateUIEvent& event ) void WinEDA_LibeditFrame::OnUpdateEditingPart( wxUpdateUIEvent& event )
{ {
event.Enable( m_currentComponent != NULL ); event.Enable( m_component != NULL );
} }
void WinEDA_LibeditFrame::OnUpdateNotEditingPart( wxUpdateUIEvent& event ) void WinEDA_LibeditFrame::OnUpdateNotEditingPart( wxUpdateUIEvent& event )
{ {
event.Enable( m_currentComponent == NULL ); event.Enable( m_component == NULL );
} }
void WinEDA_LibeditFrame::OnUpdateUndo( wxUpdateUIEvent& event ) void WinEDA_LibeditFrame::OnUpdateUndo( wxUpdateUIEvent& event )
{ {
event.Enable( m_currentComponent != NULL && GetScreen() != NULL event.Enable( m_component != NULL && GetScreen() != NULL
&& GetScreen()->GetUndoCommandCount() != 0 ); && GetScreen()->GetUndoCommandCount() != 0 );
} }
void WinEDA_LibeditFrame::OnUpdateRedo( wxUpdateUIEvent& event ) void WinEDA_LibeditFrame::OnUpdateRedo( wxUpdateUIEvent& event )
{ {
event.Enable( m_currentComponent != NULL && GetScreen() != NULL event.Enable( m_component != NULL && GetScreen() != NULL
&& GetScreen()->GetRedoCommandCount() != 0 ); && GetScreen()->GetRedoCommandCount() != 0 );
} }
void WinEDA_LibeditFrame::OnUpdateSaveCurrentLib( wxUpdateUIEvent& event ) void WinEDA_LibeditFrame::OnUpdateSaveCurrentLib( wxUpdateUIEvent& event )
{ {
event.Enable( CurrentLib != NULL event.Enable( m_library != NULL
&& ( CurrentLib->IsModified() || GetScreen()->IsModify() ) ); && ( m_library->IsModified()|| GetScreen()->IsModify() ) );
} }
@ -375,16 +397,16 @@ void WinEDA_LibeditFrame::OnUpdateViewDoc( wxUpdateUIEvent& event )
{ {
bool enable = false; bool enable = false;
if( m_currentComponent != NULL && CurrentLib != NULL ) if( m_component != NULL && m_library != NULL )
{ {
if( !CurrentAliasName.IsEmpty() ) if( !m_aliasName.IsEmpty() )
{ {
CMP_LIB_ENTRY* entry = CurrentLib->FindEntry( CurrentAliasName ); CMP_LIB_ENTRY* entry = m_library->FindEntry( m_aliasName );
if( entry != NULL ) if( entry != NULL )
enable = !entry->m_DocFile.IsEmpty(); enable = !entry->m_DocFile.IsEmpty();
} }
else if( !m_currentComponent->m_DocFile.IsEmpty() ) else if( !m_component->m_DocFile.IsEmpty() )
{ {
enable = true; enable = true;
} }
@ -396,9 +418,8 @@ void WinEDA_LibeditFrame::OnUpdateViewDoc( wxUpdateUIEvent& event )
void WinEDA_LibeditFrame::OnUpdatePinByPin( wxUpdateUIEvent& event ) void WinEDA_LibeditFrame::OnUpdatePinByPin( wxUpdateUIEvent& event )
{ {
event.Enable( ( m_currentComponent != NULL ) event.Enable( ( m_component != NULL )
&& ( ( m_currentComponent->m_UnitCount > 1 ) && ( ( m_component->m_UnitCount > 1 ) || m_showDeMorgan ) );
|| g_AsDeMorgan ) );
if( m_HToolBar ) if( m_HToolBar )
m_HToolBar->ToggleTool( event.GetId(), g_EditPinByPinIsOn ); m_HToolBar->ToggleTool( event.GetId(), g_EditPinByPinIsOn );
@ -410,11 +431,11 @@ void WinEDA_LibeditFrame::OnUpdatePartNumber( wxUpdateUIEvent& event )
if( m_SelpartBox == NULL ) if( m_SelpartBox == NULL )
return; return;
/* Using the typical event.Enable() call dosen't seem to work with wxGTK /* Using the typical event.Enable() call doesn't seem to work with wxGTK
* so use the pointer to alias combobox to directly enable or disable. * so use the pointer to alias combobox to directly enable or disable.
*/ */
m_SelpartBox->Enable( m_currentComponent != NULL m_SelpartBox->Enable( m_component != NULL
&& m_currentComponent->m_UnitCount > 1 ); && m_component->m_UnitCount > 1 );
} }
@ -423,9 +444,9 @@ void WinEDA_LibeditFrame::OnUpdateDeMorganNormal( wxUpdateUIEvent& event )
if( m_HToolBar == NULL ) if( m_HToolBar == NULL )
return; return;
event.Enable( m_currentComponent != NULL event.Enable( m_component != NULL
&& m_currentComponent->HasConversion() ); && m_component->HasConversion() );
m_HToolBar->ToggleTool( event.GetId(), CurrentConvert <= 1 ); m_HToolBar->ToggleTool( event.GetId(), m_convert <= 1 );
} }
@ -434,9 +455,9 @@ void WinEDA_LibeditFrame::OnUpdateDeMorganConvert( wxUpdateUIEvent& event )
if( m_HToolBar == NULL ) if( m_HToolBar == NULL )
return; return;
event.Enable( m_currentComponent != NULL event.Enable( m_component != NULL
&& m_currentComponent->HasConversion() ); && m_component->HasConversion() );
m_HToolBar->ToggleTool( event.GetId(), CurrentConvert > 1 ); m_HToolBar->ToggleTool( event.GetId(), m_convert > 1 );
} }
@ -445,26 +466,26 @@ void WinEDA_LibeditFrame::OnUpdateSelectAlias( wxUpdateUIEvent& event )
if( m_SelAliasBox == NULL ) if( m_SelAliasBox == NULL )
return; return;
/* Using the typical event.Enable() call dosen't seem to work with wxGTK /* Using the typical event.Enable() call doesn't seem to work with wxGTK
* so use the pointer to alias combobox to directly enable or disable. * so use the pointer to alias combobox to directly enable or disable.
*/ */
m_SelAliasBox->Enable( m_currentComponent != NULL m_SelAliasBox->Enable( m_component != NULL
&& !m_currentComponent->m_AliasList.IsEmpty() ); && !m_component->m_AliasList.IsEmpty() );
} }
void WinEDA_LibeditFrame::OnSelectAlias( wxCommandEvent& event ) void WinEDA_LibeditFrame::OnSelectAlias( wxCommandEvent& event )
{ {
if( m_SelAliasBox == NULL if( m_SelAliasBox == NULL
|| m_SelAliasBox->GetStringSelection().CmpNoCase( CurrentAliasName ) == 0 ) || m_SelAliasBox->GetStringSelection().CmpNoCase( m_aliasName ) == 0 )
return; return;
LibItemToRepeat = NULL; m_lastDrawItem = NULL;
if( m_SelAliasBox->GetStringSelection().CmpNoCase(m_currentComponent->GetName() ) == 0 ) if( m_SelAliasBox->GetStringSelection().CmpNoCase(m_component->GetName() ) == 0 )
CurrentAliasName.Empty(); m_aliasName.Empty();
else else
CurrentAliasName = m_SelAliasBox->GetStringSelection(); m_aliasName = m_SelAliasBox->GetStringSelection();
DisplayCmpDoc(); DisplayCmpDoc();
DrawPanel->Refresh(); DrawPanel->Refresh();
@ -475,16 +496,56 @@ void WinEDA_LibeditFrame::OnSelectPart( wxCommandEvent& event )
{ {
int i = event.GetSelection(); int i = event.GetSelection();
if( ( i == wxNOT_FOUND ) || ( ( i + 1 ) == CurrentUnit ) ) if( ( i == wxNOT_FOUND ) || ( ( i + 1 ) == m_unit ) )
return; return;
LibItemToRepeat = NULL; m_lastDrawItem = NULL;
CurrentUnit = i + 1; m_unit = i + 1;
DrawPanel->Refresh(); DrawPanel->Refresh();
DisplayCmpDoc(); DisplayCmpDoc();
} }
void WinEDA_LibeditFrame::OnViewEntryDoc( wxCommandEvent& event )
{
if( m_component == NULL )
return;
wxString fileName;
if( !m_aliasName.IsEmpty() )
{
CMP_LIB_ENTRY* entry =
m_library->FindEntry( m_aliasName );
if( entry != NULL )
fileName = entry->m_DocFile;
}
else
{
fileName = m_component->m_DocFile;
}
if( !fileName.IsEmpty() )
GetAssociatedDocument( this, fileName,
&wxGetApp().GetLibraryPathList() );
}
void WinEDA_LibeditFrame::OnSelectBodyStyle( wxCommandEvent& event )
{
DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW );
if( event.GetId() == ID_DE_MORGAN_NORMAL_BUTT )
m_convert = 1;
else
m_convert = 2;
m_lastDrawItem = NULL;
DrawPanel->Refresh();
}
void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event ) void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
{ {
int id = event.GetId(); int id = event.GetId();
@ -538,56 +599,10 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
SelectActiveLibrary(); SelectActiveLibrary();
break; break;
case ID_LIBEDIT_SELECT_PART:
LibItemToRepeat = NULL;
if( LoadOneLibraryPart() )
{
g_EditPinByPinIsOn = false;
GetScreen()->ClearUndoRedoList();
}
DrawPanel->Refresh();
break;
case ID_LIBEDIT_SAVE_CURRENT_PART: case ID_LIBEDIT_SAVE_CURRENT_PART:
SaveOnePartInMemory(); SaveOnePartInMemory();
break; break;
case ID_LIBEDIT_CHECK_PART:
if( m_currentComponent && TestPins( m_currentComponent ) == false )
DisplayInfoMessage( this, _( " Pins Test OK!" ) );
break;
case ID_DE_MORGAN_NORMAL_BUTT:
LibItemToRepeat = NULL;
CurrentConvert = 1;
DrawPanel->Refresh();
break;
case ID_DE_MORGAN_CONVERT_BUTT:
LibItemToRepeat = NULL;
CurrentConvert = 2;
DrawPanel->Refresh();
break;
case ID_LIBEDIT_VIEW_DOC:
if( m_currentComponent )
{
wxString docfilename;
if( !CurrentAliasName.IsEmpty() )
{
CMP_LIB_ENTRY* entry = CurrentLib->FindEntry( CurrentAliasName );
if( entry != NULL )
docfilename = entry->m_DocFile;
}
else
docfilename = m_currentComponent->m_DocFile;
if( !docfilename.IsEmpty() )
GetAssociatedDocument( this, docfilename,
&wxGetApp().GetLibraryPathList() );
}
break;
case ID_LIBEDIT_EDIT_PIN_BY_PIN: case ID_LIBEDIT_EDIT_PIN_BY_PIN:
g_EditPinByPinIsOn = g_EditPinByPinIsOn ? false : true; g_EditPinByPinIsOn = g_EditPinByPinIsOn ? false : true;
break; break;
@ -597,13 +612,13 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_LIBEDIT_PIN_BUTT: case ID_LIBEDIT_PIN_BUTT:
if( m_currentComponent ) if( m_component )
{ {
SetToolID( id, wxCURSOR_PENCIL, _( "Add Pin" ) ); SetToolID( id, wxCURSOR_PENCIL, _( "Add pin" ) );
} }
else else
{ {
SetToolID( id, wxCURSOR_ARROW, _( "Set Pin Options" ) ); SetToolID( id, wxCURSOR_ARROW, _( "Set pin options" ) );
InstallPineditFrame( this, &dc, pos ); InstallPineditFrame( this, &dc, pos );
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
} }
@ -621,27 +636,27 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_LIBEDIT_BODY_TEXT_BUTT: case ID_LIBEDIT_BODY_TEXT_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add Text" ) ); SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
break; break;
case ID_LIBEDIT_BODY_RECT_BUTT: case ID_LIBEDIT_BODY_RECT_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add Rectangle" ) ); SetToolID( id, wxCURSOR_PENCIL, _( "Add rectangle" ) );
break; break;
case ID_LIBEDIT_BODY_CIRCLE_BUTT: case ID_LIBEDIT_BODY_CIRCLE_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add Circle" ) ); SetToolID( id, wxCURSOR_PENCIL, _( "Add circle" ) );
break; break;
case ID_LIBEDIT_BODY_ARC_BUTT: case ID_LIBEDIT_BODY_ARC_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add Arc" ) ); SetToolID( id, wxCURSOR_PENCIL, _( "Add arc" ) );
break; break;
case ID_LIBEDIT_BODY_LINE_BUTT: case ID_LIBEDIT_BODY_LINE_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add Line" ) ); SetToolID( id, wxCURSOR_PENCIL, _( "Add line" ) );
break; break;
case ID_LIBEDIT_ANCHOR_ITEM_BUTT: case ID_LIBEDIT_ANCHOR_ITEM_BUTT:
SetToolID( id, wxCURSOR_HAND, _( "Anchor" ) ); SetToolID( id, wxCURSOR_HAND, _( "Set anchor position" ) );
break; break;
case ID_LIBEDIT_IMPORT_BODY_BUTT: case ID_LIBEDIT_IMPORT_BODY_BUTT:
@ -658,29 +673,29 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_LIBEDIT_END_CREATE_ITEM: case ID_POPUP_LIBEDIT_END_CREATE_ITEM:
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
if( CurrentDrawItem ) if( m_drawItem )
{ {
EndDrawGraphicItem( &dc ); EndDrawGraphicItem( &dc );
} }
break; break;
case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM: case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM:
if( CurrentDrawItem ) if( m_drawItem )
{ {
DrawPanel->CursorOff( &dc ); DrawPanel->CursorOff( &dc );
switch( CurrentDrawItem->Type() ) switch( m_drawItem->Type() )
{ {
case COMPONENT_ARC_DRAW_TYPE: case COMPONENT_ARC_DRAW_TYPE:
case COMPONENT_CIRCLE_DRAW_TYPE: case COMPONENT_CIRCLE_DRAW_TYPE:
case COMPONENT_RECT_DRAW_TYPE: case COMPONENT_RECT_DRAW_TYPE:
case COMPONENT_POLYLINE_DRAW_TYPE: case COMPONENT_POLYLINE_DRAW_TYPE:
case COMPONENT_LINE_DRAW_TYPE: case COMPONENT_LINE_DRAW_TYPE:
EditGraphicSymbol( &dc, CurrentDrawItem ); EditGraphicSymbol( &dc, m_drawItem );
break; break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
EditSymbolText( &dc, CurrentDrawItem ); EditSymbolText( &dc, m_drawItem );
break; break;
default: default:
@ -693,7 +708,7 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_LIBEDIT_DELETE_ITEM_BUTT: case ID_LIBEDIT_DELETE_ITEM_BUTT:
if( m_currentComponent == NULL ) if( m_component == NULL )
{ {
wxBell(); wxBell();
break; break;
@ -704,79 +719,78 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT: case ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT:
// Delete the last created segment, while creating a polyline draw item // Delete the last created segment, while creating a polyline draw item
if( CurrentDrawItem == NULL ) if( m_drawItem == NULL )
break; break;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
DeleteDrawPoly( &dc ); DeleteDrawPoly( &dc );
break; break;
case ID_POPUP_LIBEDIT_DELETE_ITEM: case ID_POPUP_LIBEDIT_DELETE_ITEM:
if( CurrentDrawItem == NULL ) if( m_drawItem == NULL )
break; break;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
DrawPanel->CursorOff( &dc ); DrawPanel->CursorOff( &dc );
SaveCopyInUndoList( m_currentComponent ); SaveCopyInUndoList( m_component );
if( CurrentDrawItem->Type() == COMPONENT_PIN_DRAW_TYPE ) if( m_drawItem->Type() == COMPONENT_PIN_DRAW_TYPE )
{ {
DeletePin( &dc, m_currentComponent, (LibDrawPin*) CurrentDrawItem ); DeletePin( &dc, m_component, (LibDrawPin*) m_drawItem );
} }
else else
{ {
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
else else
m_currentComponent->RemoveDrawItem( CurrentDrawItem, DrawPanel, m_component->RemoveDrawItem( m_drawItem, DrawPanel, &dc );
&dc );
} }
CurrentDrawItem = NULL; m_drawItem = NULL;
GetScreen()->SetModify(); GetScreen()->SetModify();
DrawPanel->CursorOn( &dc ); DrawPanel->CursorOn( &dc );
break; break;
case ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST: case ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST:
if( CurrentDrawItem == NULL ) if( m_drawItem == NULL )
break; break;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
if( CurrentDrawItem->Type() == COMPONENT_PIN_DRAW_TYPE ) if( m_drawItem->Type() == COMPONENT_PIN_DRAW_TYPE )
StartMovePin( &dc ); StartMovePin( &dc );
else if( CurrentDrawItem->Type() == COMPONENT_FIELD_DRAW_TYPE ) else if( m_drawItem->Type() == COMPONENT_FIELD_DRAW_TYPE )
StartMoveField( &dc, (LibDrawField*) CurrentDrawItem ); StartMoveField( &dc, (LibDrawField*) m_drawItem );
else else
StartMoveDrawSymbol( &dc ); StartMoveDrawSymbol( &dc );
break; break;
case ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT: case ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT:
if( CurrentDrawItem == NULL ) if( m_drawItem == NULL )
break; break;
DrawPanel->CursorOff( &dc ); DrawPanel->CursorOff( &dc );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
if( (CurrentDrawItem->m_Flags & IS_NEW) == 0 ) if( (m_drawItem->m_Flags & IS_NEW) == 0 )
SaveCopyInUndoList( m_currentComponent ); SaveCopyInUndoList( m_component );
RotateSymbolText( &dc ); RotateSymbolText( &dc );
DrawPanel->CursorOn( &dc ); DrawPanel->CursorOn( &dc );
break; break;
case ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM: case ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM:
if( CurrentDrawItem == NULL ) if( m_drawItem == NULL )
break; break;
DrawPanel->CursorOff( &dc ); DrawPanel->CursorOff( &dc );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
if( CurrentDrawItem->Type() == COMPONENT_FIELD_DRAW_TYPE ) if( m_drawItem->Type() == COMPONENT_FIELD_DRAW_TYPE )
{ {
SaveCopyInUndoList( m_currentComponent ); SaveCopyInUndoList( m_component );
RotateField( &dc, (LibDrawField*) CurrentDrawItem ); RotateField( &dc, (LibDrawField*) m_drawItem );
} }
DrawPanel->CursorOn( &dc ); DrawPanel->CursorOn( &dc );
break; break;
case ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM: case ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM:
if( CurrentDrawItem == NULL ) if( m_drawItem == NULL )
break; break;
DrawPanel->CursorOff( &dc ); DrawPanel->CursorOff( &dc );
if( CurrentDrawItem->Type() == COMPONENT_FIELD_DRAW_TYPE ) if( m_drawItem->Type() == COMPONENT_FIELD_DRAW_TYPE )
{ {
EditField( &dc, (LibDrawField*) CurrentDrawItem ); EditField( &dc, (LibDrawField*) m_drawItem );
} }
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
DrawPanel->CursorOn( &dc ); DrawPanel->CursorOn( &dc );
@ -785,11 +799,11 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM: case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM: case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM: case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
if( (CurrentDrawItem == NULL ) if( (m_drawItem == NULL )
|| (CurrentDrawItem->Type() != COMPONENT_PIN_DRAW_TYPE) ) || (m_drawItem->Type() != COMPONENT_PIN_DRAW_TYPE) )
break; break;
SaveCopyInUndoList( m_currentComponent ); SaveCopyInUndoList( m_component );
GlobalSetPins( &dc, (LibDrawPin*) CurrentDrawItem, id ); GlobalSetPins( &dc, (LibDrawPin*) m_drawItem, id );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
break; break;
@ -842,5 +856,5 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->m_IgnoreMouseEvents = false; DrawPanel->m_IgnoreMouseEvents = false;
if( m_ID_current_state == 0 ) if( m_ID_current_state == 0 )
LibItemToRepeat = NULL; m_lastDrawItem = NULL;
} }

View File

@ -5,12 +5,13 @@
#include "fctsys.h" #include "fctsys.h"
#include "confirm.h" #include "confirm.h"
#include "kicad_string.h" #include "kicad_string.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "class_marker_sch.h" #include "class_marker_sch.h"
/* in read_from_file_schematic_items_description.cpp */ /* in read_from_file_schematic_items_description.cpp */
SCH_ITEM* ReadTextDescr( FILE* aFile, wxString& aMsgDiag, char* aLine, SCH_ITEM* ReadTextDescr( FILE* aFile, wxString& aMsgDiag, char* aLine,
int aBufsize, int* aLineNum, int aBufsize, int* aLineNum,

View File

@ -5,16 +5,19 @@
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h"
#include "trigo.h" #include "trigo.h"
#include "macros.h" #include "macros.h"
#include "class_marker_sch.h"
#include "libcmp.h"
#include "general.h"
#include "class_marker_sch.h"
#include "protos.h" #include "protos.h"
#include "class_library.h"
/* Routines Locales */ /* Routines Locales */
static bool DrawStructInBox(int x1, int y1, int x2, int y2, SCH_ITEM *DrawStruct); static bool DrawStructInBox( int x1, int y1, int x2, int y2,
SCH_ITEM *DrawStruct );
static SCH_ITEM* LastSnappedStruct = NULL; static SCH_ITEM* LastSnappedStruct = NULL;
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 );
@ -612,7 +615,7 @@ static bool IsBox1InBox2( int StartX1, int StartY1, int EndX1, int EndY1,
/*********************************************************************************/ /*********************************************************************************/
LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen, LIB_DRAW_ITEM* LocateDrawItem( SCH_SCREEN* Screen,
const wxPoint& aRefPoint, const wxPoint& aRefPoint,
LIB_COMPONENT* LibEntry, LIB_COMPONENT* LibEntry,
int Unit, int Unit,
@ -626,7 +629,7 @@ LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
* remember the Y axis is from bottom to top in library entries for graphic items. * remember the Y axis is from bottom to top in library entries for graphic items.
*/ */
{ {
LibEDA_BaseStruct* DrawItem; LIB_DRAW_ITEM* DrawItem;
if( LibEntry == NULL ) if( LibEntry == NULL )
return NULL; return NULL;
@ -717,7 +720,7 @@ LibDrawPin* LocatePinByNumber( const wxString& ePin_Number,
* @return a pointer on the pin, or NULL if not found * @return a pointer on the pin, or NULL if not found
*/ */
{ {
LibEDA_BaseStruct* DrawItem; LIB_DRAW_ITEM* DrawItem;
LIB_COMPONENT* Entry; LIB_COMPONENT* Entry;
LibDrawPin* Pin; LibDrawPin* Pin;
int Unit, Convert; int Unit, Convert;
@ -760,7 +763,7 @@ LibDrawPin* LocatePinByNumber( const wxString& ePin_Number,
/*******************************************************************/ /*******************************************************************/
LibEDA_BaseStruct* LocatePin( const wxPoint& RefPos, LIB_COMPONENT* Entry, LIB_DRAW_ITEM* LocatePin( const wxPoint& RefPos, LIB_COMPONENT* Entry,
int Unit, int convert, SCH_COMPONENT* DrawLibItem ) int Unit, int convert, SCH_COMPONENT* DrawLibItem )
/*******************************************************************/ /*******************************************************************/
@ -779,7 +782,7 @@ LibEDA_BaseStruct* LocatePin( const wxPoint& RefPos, LIB_COMPONENT* Entry,
return NULL; return NULL;
} }
LibEDA_BaseStruct* DrawItem = Entry->m_Drawings; LIB_DRAW_ITEM* DrawItem = Entry->m_Drawings;
for( ; DrawItem != NULL; DrawItem = DrawItem->Next() ) for( ; DrawItem != NULL; DrawItem = DrawItem->Next() )
{ {
if( DrawItem->Type() == COMPONENT_PIN_DRAW_TYPE ) /* Pin Trouvee */ if( DrawItem->Type() == COMPONENT_PIN_DRAW_TYPE ) /* Pin Trouvee */

View File

@ -9,10 +9,10 @@
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "bitmaps.h" #include "bitmaps.h"
#include "program.h"
#include "general.h"
#include "protos.h" #include "protos.h"
#include "eeschema_id.h" #include "eeschema_id.h"
#include "hotkeys.h" #include "hotkeys.h"

View File

@ -8,13 +8,14 @@
#include "confirm.h" #include "confirm.h"
#include "kicad_string.h" #include "kicad_string.h"
#include "gestfich.h" #include "gestfich.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "netlist.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "program.h"
#include "general.h"
#include "netlist.h"
#include "protos.h" #include "protos.h"
#include "class_library.h"
/* Routines locales */ /* Routines locales */
static void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, const wxString& FullFileName ); static void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, const wxString& FullFileName );
@ -110,7 +111,7 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList(
{ {
SCH_COMPONENT* Component = NULL; SCH_COMPONENT* Component = NULL;
LIB_COMPONENT* Entry; LIB_COMPONENT* Entry;
LibEDA_BaseStruct* DEntry; LIB_DRAW_ITEM* DEntry;
s_SortedComponentPinList.clear(); s_SortedComponentPinList.clear();
for( ; DrawList != NULL; DrawList = DrawList->Next() ) for( ; DrawList != NULL; DrawList = DrawList->Next() )
@ -767,7 +768,7 @@ static void FindAllsInstancesOfComponent( SCH_COMPONENT* Component_in,
{ {
EDA_BaseStruct* SchItem; EDA_BaseStruct* SchItem;
SCH_COMPONENT* Component2; SCH_COMPONENT* Component2;
LibEDA_BaseStruct* DEntry; LIB_DRAW_ITEM* DEntry;
DrawSheetPath* sheet; DrawSheetPath* sheet;
wxString str, Reference = Component_in->GetRef( Sheet_in ); wxString str, Reference = Component_in->GetRef( Sheet_in );

View File

@ -4,15 +4,16 @@
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "program.h"
#include "general.h"
#include "netlist.h" /* Definitions generales liees au calcul de netliste */ #include "netlist.h" /* Definitions generales liees au calcul de netliste */
#include "protos.h" #include "protos.h"
#include "class_library.h"
#include "algorithm" #include "algorithm"
// Buffer to build the list of items used in netlist and erc calculations // Buffer to build the list of items used in netlist and erc calculations
NETLIST_OBJECT_LIST g_NetObjectslist; NETLIST_OBJECT_LIST g_NetObjectslist;
@ -354,7 +355,7 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist,
NETLIST_OBJECT* new_item; NETLIST_OBJECT* new_item;
SCH_COMPONENT* DrawLibItem; SCH_COMPONENT* DrawLibItem;
LIB_COMPONENT* Entry; LIB_COMPONENT* Entry;
LibEDA_BaseStruct* DEntry; LIB_DRAW_ITEM* DEntry;
Hierarchical_PIN_Sheet_Struct* SheetLabel; Hierarchical_PIN_Sheet_Struct* SheetLabel;
DrawSheetPath list; DrawSheetPath list;

View File

@ -5,6 +5,10 @@
#ifndef _NETLIST_H_ #ifndef _NETLIST_H_
#define _NETLIST_H_ #define _NETLIST_H_
#include "class_libentry.h"
#define NETLIST_HEAD_STRING "EESchema Netlist Version 1.1" #define NETLIST_HEAD_STRING "EESchema Netlist Version 1.1"
#define ISBUS 1 #define ISBUS 1

View File

@ -17,13 +17,14 @@
#include "common.h" #include "common.h"
#include "confirm.h" #include "confirm.h"
#include "gestfich.h" #include "gestfich.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "netlist.h" #include "netlist.h"
#include "protos.h" #include "protos.h"
#include "netlist_control.h" #include "netlist_control.h"
// ID for configuration: // ID for configuration:
#define CUSTOM_NETLIST_TITLE wxT( "CustomNetlistTitle" ) #define CUSTOM_NETLIST_TITLE wxT( "CustomNetlistTitle" )
#define CUSTOM_NETLIST_COMMAND wxT( "CustomNetlistCommand" ) #define CUSTOM_NETLIST_COMMAND wxT( "CustomNetlistCommand" )

View File

@ -9,12 +9,11 @@
#include "confirm.h" #include "confirm.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "class_marker_sch.h" #include "class_marker_sch.h"
#include "protos.h" #include "protos.h"
static wxArrayString s_CmpNameList; static wxArrayString s_CmpNameList;
static wxArrayString s_PowerNameList; static wxArrayString s_PowerNameList;

View File

@ -8,16 +8,15 @@
#include "eeschema_id.h" #include "eeschema_id.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "bitmaps.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "class_marker_sch.h" #include "class_marker_sch.h"
#include "protos.h" #include "protos.h"
#include "hotkeys.h" #include "hotkeys.h"
#include "class_library.h"
#include "bitmaps.h"
/* functions to add commands and submenus depending on the item */ /* functions to add commands and submenus depending on the item */
static void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame ); static void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame );

View File

@ -8,18 +8,20 @@
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "common.h" #include "common.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "class_marker_sch.h" #include "class_marker_sch.h"
#include "protos.h" #include "protos.h"
/* Exported Functions */ /* Exported Functions */
void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveVector ); void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveVector );
void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& aMirrorPoint ); void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& aMirrorPoint );
void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList ); void DeleteItemsInList( WinEDA_DrawPanel* panel,
void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveVector ); PICKED_ITEMS_LIST& aItemsList );
void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList,
const wxPoint aMoveVector );
/***************************************************************************** /*****************************************************************************

View File

@ -26,10 +26,10 @@ void InstallPineditFrame( WinEDA_LibeditFrame* parent, wxDC* DC,
wxPoint MousePos = parent->GetScreen()->m_Curseur; wxPoint MousePos = parent->GetScreen()->m_Curseur;
int accept = TRUE; int accept = TRUE;
if ( ( CurrentDrawItem == NULL ) if ( ( parent->GetDrawItem() == NULL )
|| ( CurrentDrawItem->Type() == COMPONENT_PIN_DRAW_TYPE ) ) || ( parent->GetDrawItem()->Type() == COMPONENT_PIN_DRAW_TYPE ) )
{ {
LibDrawPin * Pin = (LibDrawPin *) CurrentDrawItem; LibDrawPin * Pin = (LibDrawPin *) parent->GetDrawItem();
WinEDA_PinPropertiesFrame dlg( parent ); WinEDA_PinPropertiesFrame dlg( parent );
accept = dlg.ShowModal(); accept = dlg.ShowModal();
@ -81,7 +81,7 @@ WinEDA_PinPropertiesFrame::WinEDA_PinPropertiesFrame( )
WinEDA_PinPropertiesFrame::WinEDA_PinPropertiesFrame( WinEDA_LibeditFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) WinEDA_PinPropertiesFrame::WinEDA_PinPropertiesFrame( WinEDA_LibeditFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{ {
LibDrawPin * CurrentPin = (LibDrawPin *) CurrentDrawItem; LibDrawPin * CurrentPin = (LibDrawPin *) parent->GetDrawItem();
m_Parent = parent; m_Parent = parent;
if ( CurrentPin ) if ( CurrentPin )
@ -326,7 +326,7 @@ void WinEDA_PinPropertiesFrame::SetValuesInDialog(void)
/*******************************************************/ /*******************************************************/
{ {
wxString number; wxString number;
LibDrawPin * CurrentPin = (LibDrawPin *) CurrentDrawItem; LibDrawPin * CurrentPin = (LibDrawPin *) m_Parent->GetDrawItem();
wxString msg; wxString msg;
int tmp, ii; int tmp, ii;

View File

@ -7,6 +7,7 @@
#include "program.h" #include "program.h"
#include "libeditfrm.h" #include "libeditfrm.h"
#include "eeschema_id.h" #include "eeschema_id.h"
#include "class_libentry.h"
#include "pinedit-dialog.h" #include "pinedit-dialog.h"
@ -33,7 +34,8 @@ int CodeShape[NBSHAPES] =
/* Routines locales */ /* Routines locales */
static void CreateImagePins( LibDrawPin* Pin ); static void CreateImagePins( LibDrawPin* Pin, int unit, int convert,
bool asDeMorgan );
static void AbortPinMove( WinEDA_DrawPanel* Panel, wxDC* DC ); static void AbortPinMove( WinEDA_DrawPanel* Panel, wxDC* DC );
static void DrawMovePin( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void DrawMovePin( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
@ -82,50 +84,52 @@ void WinEDA_PinPropertiesFrame::PinPropertiesAccept( wxCommandEvent& event )
LastPinNumSize = ReturnValueFromString( g_UnitMetric, msg, LastPinNumSize = ReturnValueFromString( g_UnitMetric, msg,
m_Parent->m_InternalUnits ); m_Parent->m_InternalUnits );
if( CurrentDrawItem ) // Set Pin Name & Num LIB_DRAW_ITEM* item = m_Parent->GetDrawItem();
{
if( !(CurrentDrawItem->m_Flags & IS_NEW) ) // if IS_NEW, copy for undo is done before place if( item == NULL )
m_Parent->SaveCopyInUndoList( CurrentDrawItem->GetParent() ); return;
if( !( item->m_Flags & IS_NEW ) ) // if IS_NEW, copy for undo is done before place
m_Parent->SaveCopyInUndoList( item->GetParent() );
SetPinName( m_PinNameCtrl->GetValue(), LastPinNameSize ); SetPinName( m_PinNameCtrl->GetValue(), LastPinNameSize );
msg = m_PinNumCtrl->GetValue(); msg = m_PinNumCtrl->GetValue();
if( msg.IsEmpty() ) if( msg.IsEmpty() )
msg = wxT( "~" ); msg = wxT( "~" );
SetPinNum( msg, LastPinNumSize ); SetPinNum( msg, LastPinNumSize );
NewSizePin( LastPinSize ); NewSizePin( LastPinSize );
SetPinShape( LastPinShape ); SetPinShape( LastPinShape );
SetPinType( LastPinType ); SetPinType( LastPinType );
SetPinOrient( LastPinOrient ); SetPinOrient( LastPinOrient );
SetAttributsPin( true, true, true ); // Set all attributes (visibility, common to units and common to convert options) SetAttributsPin( true, true, true ); // Set all attributes (visibility, common to units and common to convert options)
CurrentDrawItem->DisplayInfo( m_Parent ); item->DisplayInfo( m_Parent );
}
m_Parent->DrawPanel->Refresh(); m_Parent->DrawPanel->Refresh();
} }
/*********************************************/ /*
void WinEDA_LibeditFrame::InitEditOnePin() * Called when installing the edit pin dialog frame
/*********************************************/
/* Called when installing the edit pin dialog frame
* Set pins flags (.m_Flags pins member) to ensure a correctins edition: * Set pins flags (.m_Flags pins member) to ensure a correctins edition:
* If 2 or more pins are on the same location (and the same orientation) they are all moved or resized. * If 2 or more pins are on the same location (and the same orientation) they
* are all moved or resized.
* This is usefull for components which have more than one part per package * This is usefull for components which have more than one part per package
* In this case all parts can be edited at once. * In this case all parts can be edited at once.
* Note: if the option "Edit Pin per Pin" (tool of the main toolbar) is activated, only the current part is edited * Note: if the option "Edit Pin per Pin" (tool of the main toolbar) is
* activated, only the current part is edited.
*/ */
void WinEDA_LibeditFrame::InitEditOnePin()
{ {
LibDrawPin* Pin; LibDrawPin* Pin;
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem; LibDrawPin* CurrentPin = (LibDrawPin*) m_drawItem;
if( m_currentComponent == NULL ) if( m_component == NULL || CurrentPin == NULL )
return;
if( CurrentPin == NULL )
return; return;
/* Marquage des pins a traiter,Si edition d'une pin non deja selectionnee */ /* Marquage des pins a traiter,Si edition d'une pin non deja selectionnee */
Pin = (LibDrawPin*) m_currentComponent->m_Drawings; Pin = (LibDrawPin*) m_component->m_Drawings;
for( ; Pin != NULL; Pin = Pin->Next() ) for( ; Pin != NULL; Pin = Pin->Next() )
{ {
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE ) if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
@ -153,20 +157,25 @@ static void AbortPinMove( WinEDA_DrawPanel* Panel, wxDC* DC )
/* Used to abort the move pin command. /* Used to abort the move pin command.
*/ */
{ {
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem; WinEDA_LibeditFrame* parent = (WinEDA_LibeditFrame*) Panel->GetParent();
if( parent == NULL )
return;
LibDrawPin* CurrentPin = (LibDrawPin*) parent->GetDrawItem();
if( CurrentPin && ( CurrentPin->m_Flags & IS_NEW ) ) if( CurrentPin && ( CurrentPin->m_Flags & IS_NEW ) )
CurrentPin->GetParent()->RemoveDrawItem( CurrentPin, Panel, DC ); CurrentPin->GetParent()->RemoveDrawItem( CurrentPin, Panel, DC );
/* clear edit flags */ /* clear edit flags */
LibEDA_BaseStruct* item = CurrentPin->GetParent()->m_Drawings; LIB_DRAW_ITEM* item = CurrentPin->GetParent()->m_Drawings;
for( ; item != NULL; item = item->Next() ) for( ; item != NULL; item = item->Next() )
item->m_Flags = 0; item->m_Flags = 0;
Panel->ManageCurseur = NULL; Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL;
CurrentDrawItem = NULL; parent->SetDrawItem( NULL );
LibItemToRepeat = NULL; parent->SetLastDrawItem( NULL );
Panel->Refresh( true ); Panel->Refresh( true );
} }
@ -177,7 +186,7 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC )
/* Routine de fin de deplacement de la pin selectionnee */ /* Routine de fin de deplacement de la pin selectionnee */
{ {
LibDrawPin* Pin; LibDrawPin* Pin;
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem; LibDrawPin* CurrentPin = (LibDrawPin*) m_drawItem;
bool ask_for_pin = true; bool ask_for_pin = true;
wxPoint newpos; wxPoint newpos;
bool status; bool status;
@ -188,7 +197,7 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC )
newpos.x = GetScreen()->m_Curseur.x; newpos.x = GetScreen()->m_Curseur.x;
newpos.y = -GetScreen()->m_Curseur.y; newpos.y = -GetScreen()->m_Curseur.y;
Pin = (LibDrawPin*) m_currentComponent->m_Drawings; Pin = (LibDrawPin*) m_component->m_Drawings;
// Tst for an other pin in same new position: // Tst for an other pin in same new position:
for( ; Pin != NULL; Pin = Pin->Next() ) for( ; Pin != NULL; Pin = Pin->Next() )
@ -224,12 +233,13 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC )
LastPinOrient = CurrentPin->m_Orient; LastPinOrient = CurrentPin->m_Orient;
LastPinType = CurrentPin->m_PinType; LastPinType = CurrentPin->m_PinType;
LastPinShape = CurrentPin->m_PinShape; LastPinShape = CurrentPin->m_PinShape;
CreateImagePins( CurrentPin ); CreateImagePins( CurrentPin, m_unit, m_convert,
LibItemToRepeat = CurrentPin; m_showDeMorgan );
m_lastDrawItem = CurrentPin;
} }
/* Put linked pins in new position, and clear flags */ /* Put linked pins in new position, and clear flags */
Pin = (LibDrawPin*) m_currentComponent->m_Drawings; Pin = (LibDrawPin*) m_component->m_Drawings;
for( ; Pin != NULL; Pin = Pin->Next() ) for( ; Pin != NULL; Pin = Pin->Next() )
{ {
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE ) if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
@ -246,7 +256,7 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC )
&showPinText, DefaultTransformMatrix ); &showPinText, DefaultTransformMatrix );
DrawPanel->CursorOn( DC ); DrawPanel->CursorOn( DC );
CurrentDrawItem = NULL; m_drawItem = NULL;
}; };
/***********************************************************/ /***********************************************************/
@ -254,7 +264,7 @@ void WinEDA_PinPropertiesFrame::SetPinOrient( int neworient )
/***********************************************************/ /***********************************************************/
/* Routine de Rotation de la pin courante*/ /* Routine de Rotation de la pin courante*/
{ {
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem; LibDrawPin* CurrentPin = (LibDrawPin*) m_Parent->GetDrawItem();
LibDrawPin* Pin, * RefPin = CurrentPin; LibDrawPin* Pin, * RefPin = CurrentPin;
if( CurrentPin == NULL || CurrentPin->GetParent() == NULL ) if( CurrentPin == NULL || CurrentPin->GetParent() == NULL )
@ -289,11 +299,11 @@ void WinEDA_LibeditFrame::StartMovePin( wxDC* DC )
*/ */
{ {
LibDrawPin* Pin; LibDrawPin* Pin;
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem; LibDrawPin* CurrentPin = (LibDrawPin*) m_drawItem;
wxPoint startPos; wxPoint startPos;
/* Marquage des pins a traiter */ /* Marquage des pins a traiter */
Pin = (LibDrawPin*) m_currentComponent->m_Drawings; Pin = (LibDrawPin*) m_component->m_Drawings;
for( ; Pin != NULL; Pin = Pin->Next() ) for( ; Pin != NULL; Pin = Pin->Next() )
{ {
Pin->m_Flags = 0; Pin->m_Flags = 0;
@ -330,7 +340,12 @@ void WinEDA_LibeditFrame::StartMovePin( wxDC* DC )
/******************************************************************************/ /******************************************************************************/
static void DrawMovePin( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) static void DrawMovePin( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{ {
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem; WinEDA_LibeditFrame* parent = (WinEDA_LibeditFrame*) panel->GetParent();
if( parent == NULL )
return;
LibDrawPin* CurrentPin = (LibDrawPin*) parent->GetDrawItem();
wxPoint pinpos = CurrentPin->m_Pos; wxPoint pinpos = CurrentPin->m_Pos;
bool showPinText = true; bool showPinText = true;
@ -367,7 +382,7 @@ void WinEDA_PinPropertiesFrame::SetPinShape( int newshape )
*/ */
{ {
LibDrawPin* Pin; LibDrawPin* Pin;
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem; LibDrawPin* CurrentPin = (LibDrawPin*) m_Parent->GetDrawItem();
if( CurrentPin ) if( CurrentPin )
{ {
@ -400,7 +415,7 @@ void WinEDA_PinPropertiesFrame::SetPinType( int newtype )
*/ */
{ {
LibDrawPin* Pin; LibDrawPin* Pin;
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem; LibDrawPin* CurrentPin = (LibDrawPin*) m_Parent->GetDrawItem();
if( CurrentPin == NULL || CurrentPin->GetParent() == NULL ) if( CurrentPin == NULL || CurrentPin->GetParent() == NULL )
return; return;
@ -430,7 +445,7 @@ void WinEDA_PinPropertiesFrame::SetPinName( const wxString& newname, int newsize
*/ */
{ {
LibDrawPin* Pin; LibDrawPin* Pin;
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem; LibDrawPin* CurrentPin = (LibDrawPin*) m_Parent->GetDrawItem();
wxString buf; wxString buf;
if( CurrentPin == NULL || CurrentPin->GetParent() == NULL ) if( CurrentPin == NULL || CurrentPin->GetParent() == NULL )
@ -473,7 +488,7 @@ void WinEDA_PinPropertiesFrame::SetPinNum( const wxString& newnum, int newsize )
*/ */
{ {
LibDrawPin* Pin; LibDrawPin* Pin;
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem; LibDrawPin* CurrentPin = (LibDrawPin*) m_Parent->GetDrawItem();
wxString buf; wxString buf;
buf = newnum; buf = newnum;
@ -517,14 +532,14 @@ void WinEDA_LibeditFrame::DeletePin( wxDC* DC,
* Sinon seule la pin de l'unite en convert courante sera effacee * Sinon seule la pin de l'unite en convert courante sera effacee
*/ */
{ {
LibEDA_BaseStruct* DrawItem; LIB_DRAW_ITEM* DrawItem;
wxPoint PinPos; wxPoint PinPos;
if( LibEntry == NULL || Pin == NULL ) if( LibEntry == NULL || Pin == NULL )
return; return;
PinPos = Pin->m_Pos; PinPos = Pin->m_Pos;
LibEntry->RemoveDrawItem( (LibEDA_BaseStruct*) Pin, DrawPanel, DC ); LibEntry->RemoveDrawItem( (LIB_DRAW_ITEM*) Pin, DrawPanel, DC );
/* Effacement des autres pins de meme coordonnees */ /* Effacement des autres pins de meme coordonnees */
if( g_EditPinByPinIsOn == false ) if( g_EditPinByPinIsOn == false )
@ -541,7 +556,7 @@ void WinEDA_LibeditFrame::DeletePin( wxDC* DC,
DrawItem = DrawItem->Next(); DrawItem = DrawItem->Next();
if( Pin->m_Pos != PinPos ) if( Pin->m_Pos != PinPos )
continue; continue;
LibEntry->RemoveDrawItem( (LibEDA_BaseStruct*) Pin ); LibEntry->RemoveDrawItem( (LIB_DRAW_ITEM*) Pin );
} }
} }
GetScreen()->SetModify(); GetScreen()->SetModify();
@ -553,26 +568,26 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC )
/*********************************************/ /*********************************************/
/* Creation d'une nouvelle pin */ /* Creation d'une nouvelle pin */
{ {
LibEDA_BaseStruct* DrawItem; LIB_DRAW_ITEM* DrawItem;
LibDrawPin* CurrentPin; LibDrawPin* CurrentPin;
bool showPinText = true; bool showPinText = true;
if( m_currentComponent == NULL ) if( m_component == NULL )
return; return;
/* Effacement des flags */ /* Effacement des flags */
DrawItem = m_currentComponent->m_Drawings; DrawItem = m_component->m_Drawings;
for( ; DrawItem != NULL; DrawItem = DrawItem->Next() ) for( ; DrawItem != NULL; DrawItem = DrawItem->Next() )
DrawItem->m_Flags = 0; DrawItem->m_Flags = 0;
CurrentPin = new LibDrawPin(m_currentComponent); CurrentPin = new LibDrawPin(m_component);
CurrentDrawItem = CurrentPin; m_drawItem = CurrentPin;
if( CurrentPin == NULL ) if( CurrentPin == NULL )
return; return;
CurrentPin->m_Flags = IS_NEW; CurrentPin->m_Flags = IS_NEW;
CurrentPin->m_Unit = CurrentUnit; CurrentPin->m_Unit = m_unit;
CurrentPin->m_Convert = CurrentConvert; CurrentPin->m_Convert = m_convert;
/* Marquage des pins a traiter */ /* Marquage des pins a traiter */
if( g_EditPinByPinIsOn == false ) if( g_EditPinByPinIsOn == false )
@ -589,19 +604,19 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC )
if( LastPinCommonConvert ) if( LastPinCommonConvert )
CurrentPin->m_Convert = 0; CurrentPin->m_Convert = 0;
else else
CurrentPin->m_Convert = CurrentConvert; CurrentPin->m_Convert = m_convert;
if( LastPinCommonUnit ) if( LastPinCommonUnit )
CurrentPin->m_Unit = 0; CurrentPin->m_Unit = 0;
else else
CurrentPin->m_Unit = CurrentUnit; CurrentPin->m_Unit = m_unit;
if( LastPinNoDraw ) if( LastPinNoDraw )
CurrentPin->m_Attributs |= PINNOTDRAW; CurrentPin->m_Attributs |= PINNOTDRAW;
else else
CurrentPin->m_Attributs &= ~PINNOTDRAW; CurrentPin->m_Attributs &= ~PINNOTDRAW;
CurrentPin->SetNext( m_currentComponent->m_Drawings ); CurrentPin->SetNext( m_component->m_Drawings );
m_currentComponent->m_Drawings = CurrentPin; m_component->m_Drawings = CurrentPin;
m_currentComponent->SortDrawItems(); m_component->SortDrawItems();
if( DC ) if( DC )
CurrentPin->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, CurrentPin->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
@ -641,8 +656,8 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw,
* *
*/ */
{ {
LibEDA_BaseStruct* DrawItem; LIB_DRAW_ITEM* DrawItem;
LibDrawPin* Pin, * CurrentPin = (LibDrawPin*) CurrentDrawItem; LibDrawPin* Pin, * CurrentPin = (LibDrawPin*) m_Parent->GetDrawItem();
if( CurrentPin == NULL ) if( CurrentPin == NULL )
return; return;
@ -654,7 +669,7 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw,
if( LastPinCommonUnit ) if( LastPinCommonUnit )
CurrentPin->m_Unit = 0; CurrentPin->m_Unit = 0;
else else
CurrentPin->m_Unit = CurrentUnit; CurrentPin->m_Unit = m_Parent->GetUnit();
Pin = (LibDrawPin*) CurrentPin->GetParent()->m_Drawings; Pin = (LibDrawPin*) CurrentPin->GetParent()->m_Drawings;
@ -679,7 +694,7 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw,
if( Pin->m_Orient != CurrentPin->m_Orient ) if( Pin->m_Orient != CurrentPin->m_Orient )
continue; continue;
CurrentPin->GetParent()->RemoveDrawItem( (LibEDA_BaseStruct*) Pin ); CurrentPin->GetParent()->RemoveDrawItem( (LIB_DRAW_ITEM*) Pin );
} }
} }
} // end if unit } // end if unit
@ -689,7 +704,7 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw,
if( LastPinCommonConvert ) if( LastPinCommonConvert )
CurrentPin->m_Convert = 0; CurrentPin->m_Convert = 0;
else else
CurrentPin->m_Convert = CurrentConvert; CurrentPin->m_Convert = m_Parent->GetConvert();
if( CurrentPin->m_Convert == 0 ) /* Effacement des pins redondantes */ if( CurrentPin->m_Convert == 0 ) /* Effacement des pins redondantes */
{ {
@ -711,7 +726,7 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw,
if( Pin->m_Orient != CurrentPin->m_Orient ) if( Pin->m_Orient != CurrentPin->m_Orient )
continue; continue;
CurrentPin->GetParent()->RemoveDrawItem( (LibEDA_BaseStruct*) Pin ); CurrentPin->GetParent()->RemoveDrawItem( (LIB_DRAW_ITEM*) Pin );
} }
} }
} // end if convert } // end if convert
@ -747,7 +762,7 @@ void WinEDA_PinPropertiesFrame::NewSizePin( int newsize )
* *
*/ */
{ {
LibDrawPin* RefPin, * Pin = (LibDrawPin*) CurrentDrawItem; LibDrawPin* RefPin, * Pin = (LibDrawPin*) m_Parent->GetDrawItem();
if( Pin == NULL || Pin->GetParent() == NULL ) if( Pin == NULL || Pin->GetParent() == NULL )
return; return;
@ -778,13 +793,8 @@ void WinEDA_PinPropertiesFrame::NewSizePin( int newsize )
} }
/********************************************/ static void CreateImagePins( LibDrawPin* Pin, int unit, int convert,
static void CreateImagePins( LibDrawPin* Pin ) bool asDeMorgan )
/********************************************/
/* Creation des autres pins pour les autres unites et pour convert, apres
* creation d'une pin
*/
{ {
int ii; int ii;
LibDrawPin* NewPin; LibDrawPin* NewPin;
@ -794,7 +804,7 @@ static void CreateImagePins( LibDrawPin* Pin )
if( g_EditPinByPinIsOn ) if( g_EditPinByPinIsOn )
return; return;
if( g_AsDeMorgan && ( Pin->m_Convert != 0 ) ) if( asDeMorgan && ( Pin->m_Convert != 0 ) )
CreateConv = true; CreateConv = true;
/* Creation de la pin " convert " pour la part courante */ /* Creation de la pin " convert " pour la part courante */
@ -811,12 +821,12 @@ static void CreateImagePins( LibDrawPin* Pin )
for( ii = 1; ii <= Pin->GetParent()->m_UnitCount; ii++ ) for( ii = 1; ii <= Pin->GetParent()->m_UnitCount; ii++ )
{ {
if( ii == CurrentUnit || Pin->m_Unit == 0 ) if( ii == unit || Pin->m_Unit == 0 )
continue; /* Pin commune a toutes les unites */ continue; /* Pin commune a toutes les unites */
/* Creation pour la representation "normale" */ /* Creation pour la representation "normale" */
NewPin = (LibDrawPin*) Pin->GenCopy(); NewPin = (LibDrawPin*) Pin->GenCopy();
if( CurrentConvert != 0 ) if( convert != 0 )
NewPin->m_Convert = 1; NewPin->m_Convert = 1;
NewPin->m_Unit = ii; NewPin->m_Unit = ii;
NewPin->SetNext( Pin->GetParent()->m_Drawings ); NewPin->SetNext( Pin->GetParent()->m_Drawings );
@ -852,19 +862,19 @@ void WinEDA_LibeditFrame::GlobalSetPins( wxDC* DC,
bool selected = ( MasterPin->m_Selected & IS_SELECTED ) != 0; bool selected = ( MasterPin->m_Selected & IS_SELECTED ) != 0;
bool showPinText = true; bool showPinText = true;
if( ( m_currentComponent == NULL ) || ( MasterPin == NULL ) ) if( ( m_component == NULL ) || ( MasterPin == NULL ) )
return; return;
if( MasterPin->Type() != COMPONENT_PIN_DRAW_TYPE ) if( MasterPin->Type() != COMPONENT_PIN_DRAW_TYPE )
return; return;
GetScreen()->SetModify(); GetScreen()->SetModify();
Pin = (LibDrawPin*) m_currentComponent->m_Drawings; Pin = (LibDrawPin*) m_component->m_Drawings;
for( ; Pin != NULL; Pin = Pin->Next() ) for( ; Pin != NULL; Pin = Pin->Next() )
{ {
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE ) if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
continue; continue;
if( ( Pin->m_Convert ) && ( Pin->m_Convert != CurrentConvert ) ) if( ( Pin->m_Convert ) && ( Pin->m_Convert != m_convert ) )
continue; continue;
// Is it the "selected mode" ? // Is it the "selected mode" ?
@ -904,13 +914,13 @@ void WinEDA_LibeditFrame::RepeatPinItem( wxDC* DC, LibDrawPin* SourcePin )
wxString msg; wxString msg;
int ox = 0, oy = 0; int ox = 0, oy = 0;
if( m_currentComponent == NULL || SourcePin == NULL if( m_component == NULL || SourcePin == NULL
|| SourcePin->Type() != COMPONENT_PIN_DRAW_TYPE ) || SourcePin->Type() != COMPONENT_PIN_DRAW_TYPE )
return; return;
Pin = (LibDrawPin*)SourcePin->GenCopy(); Pin = (LibDrawPin*)SourcePin->GenCopy();
Pin->SetNext( m_currentComponent->m_Drawings ); Pin->SetNext( m_component->m_Drawings );
m_currentComponent->m_Drawings = Pin; m_component->m_Drawings = Pin;
Pin->m_Flags = IS_NEW; Pin->m_Flags = IS_NEW;
Pin->m_Pos.x += g_RepeatStep.x; Pin->m_Pos.x += g_RepeatStep.x;
@ -924,7 +934,7 @@ void WinEDA_LibeditFrame::RepeatPinItem( wxDC* DC, LibDrawPin* SourcePin )
IncrementLabelMember( msg ); IncrementLabelMember( msg );
Pin->SetPinNumFromString( msg ); Pin->SetPinNumFromString( msg );
CurrentDrawItem = Pin; m_drawItem = Pin;
/* Marquage des pins a traiter */ /* Marquage des pins a traiter */
if( g_EditPinByPinIsOn == false ) if( g_EditPinByPinIsOn == false )
@ -954,22 +964,18 @@ int sort_by_pin_number( const void* ref, const void* tst )
} }
/***************************************************************/ void WinEDA_LibeditFrame::OnCheckComponent( wxCommandEvent& event )
bool WinEDA_LibeditFrame::TestPins( LIB_COMPONENT* LibEntry )
/***************************************************************/
// Test des pins ( duplicates...)
{ {
int nb_pins, ii, error; int nb_pins, ii, error;
LibDrawPin* Pin; LibDrawPin* Pin;
LibDrawPin** PinList; LibDrawPin** PinList;
wxString msg; wxString msg;
if( m_currentComponent == NULL ) if( m_component == NULL )
return false; return;
// Construction de la liste des pins: // Construction de la liste des pins:
Pin = (LibDrawPin*) m_currentComponent->m_Drawings; Pin = (LibDrawPin*) m_component->m_Drawings;
for( nb_pins = 0; Pin != NULL; Pin = Pin->Next() ) for( nb_pins = 0; Pin != NULL; Pin = Pin->Next() )
{ {
if( Pin->Type() == COMPONENT_PIN_DRAW_TYPE ) if( Pin->Type() == COMPONENT_PIN_DRAW_TYPE )
@ -977,7 +983,7 @@ bool WinEDA_LibeditFrame::TestPins( LIB_COMPONENT* LibEntry )
} }
PinList = (LibDrawPin**) MyZMalloc( (nb_pins + 1) * sizeof(LibDrawPin*) ); PinList = (LibDrawPin**) MyZMalloc( (nb_pins + 1) * sizeof(LibDrawPin*) );
Pin = (LibDrawPin*) m_currentComponent->m_Drawings; Pin = (LibDrawPin*) m_component->m_Drawings;
for( ii = 0; Pin != NULL; Pin = Pin->Next() ) for( ii = 0; Pin != NULL; Pin = Pin->Next() )
{ {
if( Pin->Type() == COMPONENT_PIN_DRAW_TYPE ) if( Pin->Type() == COMPONENT_PIN_DRAW_TYPE )
@ -995,39 +1001,42 @@ bool WinEDA_LibeditFrame::TestPins( LIB_COMPONENT* LibEntry )
LibDrawPin* curr_pin = PinList[ii]; LibDrawPin* curr_pin = PinList[ii];
Pin = PinList[ii - 1]; Pin = PinList[ii - 1];
if( Pin->m_PinNum != curr_pin->m_PinNum ) if( Pin->m_PinNum != curr_pin->m_PinNum
continue; || Pin->m_Convert != curr_pin->m_Convert
|| Pin->m_Unit != curr_pin->m_Unit )
if( Pin->m_Convert != curr_pin->m_Convert )
continue;
if( Pin->m_Unit != curr_pin->m_Unit )
continue; continue;
error++; error++;
curr_pin->ReturnPinStringNum( StringPinNum ); curr_pin->ReturnPinStringNum( StringPinNum );
msg.Printf( _( "Duplicate Pin %4.4s (Pin %s loc %d, %d, and Pin %s loc %d, %d)" ), msg.Printf( _( "Duplicate pin %s at location (%d, %d) conflicts \
StringPinNum.GetData(), curr_pin->m_PinName.GetData(), with pin %s at location (%d, %d)" ),
(const wxChar*)StringPinNum,
(const wxChar*)curr_pin->m_PinName,
curr_pin->m_Pos.x, -curr_pin->m_Pos.y, curr_pin->m_Pos.x, -curr_pin->m_Pos.y,
Pin->m_PinName.GetData(), Pin->m_Pos.x, -Pin->m_Pos.y ); (const wxChar*)Pin->m_PinName,
Pin->m_Pos.x, -Pin->m_Pos.y );
if( m_currentComponent->m_UnitCount > 1 ) if( m_component->m_UnitCount > 1 )
{ {
aux_msg.Printf( _( " Part %d" ), curr_pin->m_Unit ); aux_msg.Printf( _( " in part %c" ), 'A' + curr_pin->m_Unit );
msg += aux_msg; msg += aux_msg;
} }
if( g_AsDeMorgan ) if( m_showDeMorgan )
{ {
if( curr_pin->m_Convert ) if( curr_pin->m_Convert )
msg += _( " Convert" ); msg += _( " of converion" );
else else
msg += _( " Normal" ); msg += _( " of normal" );
} }
msg += wxT( "." );
DisplayError( this, msg ); DisplayError( this, msg );
} }
free( PinList ); free( PinList );
return error ? true : false;
if( error == 0 )
DisplayInfoMessage( this, _( "No duplicate pins were found." ) );
} }

View File

@ -11,9 +11,10 @@
#include "trigo.h" #include "trigo.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "class_library.h"
/* Local Variables : */ /* Local Variables : */
static void Plot_Hierarchical_PIN_Sheet( PLOTTER* plotter, static void Plot_Hierarchical_PIN_Sheet( PLOTTER* plotter,
@ -64,7 +65,7 @@ static void PlotLibPart( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem )
Multi = DrawLibItem->m_Multi; Multi = DrawLibItem->m_Multi;
convert = DrawLibItem->m_Convert; convert = DrawLibItem->m_Convert;
for( LibEDA_BaseStruct* DEntry = Entry->m_Drawings; for( LIB_DRAW_ITEM* DEntry = Entry->m_Drawings;
DEntry != NULL; DEntry = DEntry->Next() ) DEntry != NULL; DEntry = DEntry->Next() )
{ {
/* Elimination des elements non relatifs a l'unite */ /* Elimination des elements non relatifs a l'unite */

View File

@ -19,14 +19,15 @@
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "common.h" #include "common.h"
#include "confirm.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "worksheet.h"
#include "plot_common.h" #include "plot_common.h"
#include "confirm.h"
#include "worksheet.h"
#include "program.h"
#include "general.h"
#include "protos.h" #include "protos.h"
/* Variables locales : */ /* Variables locales : */
static bool Plot_Sheet_Ref = TRUE; static bool Plot_Sheet_Ref = TRUE;

View File

@ -23,14 +23,15 @@
#include "gr_basic.h" #include "gr_basic.h"
#include "common.h" #include "common.h"
#include "confirm.h" #include "confirm.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "worksheet.h"
#include "plot_common.h" #include "plot_common.h"
#include "worksheet.h"
#include "program.h"
#include "general.h"
#include "protos.h" #include "protos.h"
#include "plothpgl.h" #include "plothpgl.h"
////@begin XPM images ////@begin XPM images
////@end XPM images ////@end XPM images

View File

@ -20,11 +20,11 @@
#include "gr_basic.h" #include "gr_basic.h"
#include "common.h" #include "common.h"
#include "confirm.h" #include "confirm.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "worksheet.h" #include "worksheet.h"
#include "plot_common.h" #include "plot_common.h"
#include "program.h"
#include "general.h"
#include "protos.h" #include "protos.h"
enum PageFormatReq { enum PageFormatReq {

View File

@ -2,7 +2,26 @@
/* prototypage des fonctions de EESchema */ /* prototypage des fonctions de EESchema */
/*****************************************/ /*****************************************/
LibEDA_BaseStruct* LocatePin( const wxPoint& RefPos, #ifndef __PROTOS_H__
#define __PROTOS_H__
class EDA_BaseStruct;
class WinEDA_DrawPanel;
class WinEDA_SchematicFrame;
class LIB_COMPONENT;
class LIB_DRAW_ITEM;
class SCH_COMPONENT;
class BASE_SCREEN;
class SCH_SCREEN;
class SCH_ITEM;
class Hierarchical_PIN_Sheet_Struct;
class PLOTTER;
class DrawSheetStruct;
class LibDrawPin;
LIB_DRAW_ITEM* LocatePin( const wxPoint& RefPos,
LIB_COMPONENT* Entry, LIB_COMPONENT* Entry,
int Unit, int Unit,
int Convert, int Convert,
@ -139,7 +158,7 @@ SCH_ITEM* PickStruct( const wxPoint& refpos,
int SearchMask ); int SearchMask );
LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen, LIB_DRAW_ITEM* LocateDrawItem( SCH_SCREEN* Screen,
const wxPoint& refpoint, const wxPoint& refpoint,
LIB_COMPONENT* LibEntry, LIB_COMPONENT* LibEntry,
int Unit, int Unit,
@ -198,17 +217,6 @@ int CountCmpNumber();
bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose ); bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose );
/**************/
/* SAVELIB.CPP */
/**************/
LIB_COMPONENT* CopyLibEntryStruct( LIB_COMPONENT* OldEntry );
/* Routine de copie d'une partlib
* Parametres d'entree: pointeur sur la structure de depart
* Parametres de sortie: pointeur sur la structure creee */
/**************/ /**************/
/* NETLIST.CPP */ /* NETLIST.CPP */
/**************/ /**************/
@ -352,3 +360,5 @@ void DisplayOptionFrame( WinEDA_SchematicFrame* parent,
/* CONTROLE.CPP */ /* CONTROLE.CPP */
/****************/ /****************/
void RemoteCommand( const char* cmdline ); void RemoteCommand( const char* cmdline );
#endif /* __PROTOS_H__ */

View File

@ -6,11 +6,10 @@
#include "common.h" #include "common.h"
#include "confirm.h" #include "confirm.h"
#include "kicad_string.h" #include "kicad_string.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "drawtxt.h" #include "drawtxt.h"
#include "program.h"
#include "general.h"
#include "protos.h" #include "protos.h"

View File

@ -8,11 +8,10 @@
#include "confirm.h" #include "confirm.h"
#include "kicad_string.h" #include "kicad_string.h"
#include "gestfich.h" #include "gestfich.h"
#include "macros.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "macros.h"
#include "protos.h" #include "protos.h"
#include "class_library.h" #include "class_library.h"

View File

@ -1,108 +0,0 @@
/****************************/
/* EESchema - eesavlib.cpp */
/****************************/
/* Functions to save schematic libraries and library components (::Save()
* members)
*/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "confirm.h"
#include "kicad_string.h"
#include "gestfich.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
/*
* Routine de copie d'une partlib
* Parametres d'entree: pointeur sur la structure de depart
* Parametres de sortie: pointeur sur la structure creee
* Do not copy new items ( i.e. with m_Flag & IS_NEW)
*/
LIB_COMPONENT* CopyLibEntryStruct( LIB_COMPONENT* OldEntry )
{
wxString msg;
LIB_COMPONENT* NewStruct;
LibEDA_BaseStruct* NewDrawings, * OldDrawings;
LibEDA_BaseStruct* LastItem;
LibDrawField* OldField, * NewField;
if( OldEntry->Type != ROOT )
{
msg.Printf( wxT( "Component <%s> must be root type to make copy." ),
(const wxChar*) OldEntry->GetName() );
wxLogError( msg );
return NULL;
}
NewStruct = new LIB_COMPONENT( wxEmptyString );
OldEntry->m_Prefix.Copy( &NewStruct->m_Prefix );
OldEntry->m_Name.Copy( &NewStruct->m_Name );
NewStruct->m_UnitCount = OldEntry->m_UnitCount;
NewStruct->m_TextInside = OldEntry->m_TextInside;
NewStruct->m_DrawPinNum = OldEntry->m_DrawPinNum;
NewStruct->m_DrawPinName = OldEntry->m_DrawPinName;
NewStruct->m_Options = OldEntry->m_Options;
NewStruct->m_UnitSelectionLocked = OldEntry->m_UnitSelectionLocked;
/* Copie des sous structures: */
NewStruct->m_AliasList = OldEntry->m_AliasList;
NewStruct->m_Doc = OldEntry->m_Doc;
NewStruct->m_KeyWord = OldEntry->m_KeyWord;
NewStruct->m_DocFile = OldEntry->m_DocFile;
/* Copie des champs */
for( OldField = OldEntry->m_Fields; OldField != NULL;
OldField = OldField->Next() )
{
NewField = (LibDrawField*) OldField->GenCopy();
NewStruct->m_Fields.PushBack( NewField );
}
/* Copie des elements type Drawing */
LastItem = NULL;
for( OldDrawings = OldEntry->m_Drawings; OldDrawings != NULL;
OldDrawings = OldDrawings->Next() )
{
if( ( OldDrawings->m_Flags & IS_NEW ) != 0 )
continue;
NewDrawings = OldDrawings->GenCopy();
if( NewDrawings )
{
if( LastItem == NULL )
NewStruct->m_Drawings = NewDrawings;
else
LastItem->SetNext( NewDrawings );
LastItem = NewDrawings;
NewDrawings->SetNext( NULL );
}
else // Should never occur, just in case...
{ // CopyDrawEntryStruct() was not able to duplicate the type
// of OldDrawings
// occurs when an unexpected type is encountered
msg.Printf( wxT( "Error attempting to copy draw item <%s> from \
component <%s>." ),
(const wxChar*) OldDrawings->GetClass(),
(const wxChar*) OldEntry->GetName() );
wxLogError( msg );
break;
}
}
/* Copy the footprint filter list */
for( unsigned ii = 0; ii < OldEntry->m_FootprintList.GetCount(); ii++ )
NewStruct->m_FootprintList.Add( OldEntry->m_FootprintList[ii] );
return NewStruct;
}

View File

@ -9,15 +9,13 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "eda_doc.h" #include "eda_doc.h"
#include "class_marker_sch.h" #include "class_marker_sch.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "eeschema_id.h" #include "eeschema_id.h"
#include "protos.h" #include "protos.h"
#include "class_library.h"
/***************************************************************************** /*****************************************************************************

View File

@ -7,7 +7,6 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "class_marker_sch.h" #include "class_marker_sch.h"
@ -436,7 +435,7 @@ void WinEDA_SchematicFrame::GetSchematicFromUndoList(wxCommandEvent& event)
List->ReversePickersListOrder(); List->ReversePickersListOrder();
GetScreen()->PushCommandToRedoList( List ); GetScreen()->PushCommandToRedoList( List );
CurrentDrawItem = NULL; // m_drawItem = NULL;
GetScreen()->SetModify(); GetScreen()->SetModify();
SetSheetNumberAndCount(); SetSheetNumberAndCount();
ReCreateHToolbar(); ReCreateHToolbar();
@ -471,7 +470,7 @@ void WinEDA_SchematicFrame::GetSchematicFromRedoList(wxCommandEvent& event)
List->ReversePickersListOrder(); List->ReversePickersListOrder();
GetScreen()->PushCommandToUndoList( List ); GetScreen()->PushCommandToUndoList( List );
CurrentDrawItem = NULL; // m_drawItem = NULL;
GetScreen()->SetModify(); GetScreen()->SetModify();
SetSheetNumberAndCount(); SetSheetNumberAndCount();
ReCreateHToolbar(); ReCreateHToolbar();

View File

@ -11,11 +11,10 @@
#include "common.h" #include "common.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "gestfich.h" #include "gestfich.h"
#include "bitmaps.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "bitmaps.h"
#include "protos.h" #include "protos.h"
#include "eeschema_id.h" #include "eeschema_id.h"
#include "netlist.h" #include "netlist.h"
@ -286,10 +285,10 @@ void WinEDA_SchematicFrame::CreateScreens()
m_CurrentSheet->Clear(); m_CurrentSheet->Clear();
m_CurrentSheet->Push( g_RootSheet ); m_CurrentSheet->Push( g_RootSheet );
if( g_ScreenLib == NULL ) if( GetBaseScreen() == NULL )
g_ScreenLib = new SCH_SCREEN(); SetBaseScreen( new SCH_SCREEN() );
g_ScreenLib->SetZoom( 4 * g_ScreenLib->m_ZoomScalar ); GetBaseScreen()->SetZoom( 4 * GetBaseScreen()->m_ZoomScalar );
g_ScreenLib->m_UndoRedoCountMax = 10; GetBaseScreen()->m_UndoRedoCountMax = 10;
} }
@ -648,7 +647,7 @@ void WinEDA_SchematicFrame::OnOpenLibraryEditor( wxCommandEvent& event )
wxT( "Library Editor" ), wxT( "Library Editor" ),
wxPoint( -1, -1 ), wxPoint( -1, -1 ),
wxSize( 600, 400 ) ); wxSize( 600, 400 ) );
ActiveScreen = g_ScreenLib; ActiveScreen = GetBaseScreen();
m_LibeditFrame->AdjustScrollBars(); m_LibeditFrame->AdjustScrollBars();
} }
} }

View File

@ -8,9 +8,9 @@
#include "confirm.h" #include "confirm.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "class_library.h"
CMP_LIBRARY* SelectLibraryFromList( WinEDA_DrawFrame* frame ) CMP_LIBRARY* SelectLibraryFromList( WinEDA_DrawFrame* frame )

View File

@ -18,6 +18,7 @@
////@begin includes ////@begin includes
////@end includes ////@end includes
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "common.h" #include "common.h"
@ -26,11 +27,10 @@
#include "gestfich.h" #include "gestfich.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
/* Routines Locales */ /* Routines Locales */
static void ExitSheet( WinEDA_DrawPanel* Panel, wxDC* DC ); static void ExitSheet( WinEDA_DrawPanel* Panel, wxDC* DC );
static void DeplaceSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void DeplaceSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );

View File

@ -9,7 +9,6 @@
#include "confirm.h" #include "confirm.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"

View File

@ -13,11 +13,12 @@
#include "eeschema_id.h" #include "eeschema_id.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "trigo.h" #include "trigo.h"
#include "protos.h" #include "protos.h"
#include "libeditfrm.h" #include "libeditfrm.h"
#include "class_libentry.h"
/* Routines locales */ /* Routines locales */
static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
@ -25,7 +26,6 @@ static void ComputeArc( LibDrawArc* DrawItem, wxPoint ArcCentre );
static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel, static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel,
wxDC* DC, wxDC* DC,
bool erase ); bool erase );
static void MoveLibDrawItemAt( LibEDA_BaseStruct* DrawItem, wxPoint newpos );
/* Variables locales */ /* Variables locales */
static int StateDrawArc, ArcStartX, ArcStartY, ArcEndX, ArcEndY; static int StateDrawArc, ArcStartX, ArcStartY, ArcEndX, ArcEndY;
@ -46,6 +46,11 @@ void WinEDA_bodygraphics_PropertiesFrame::bodygraphics_PropertiesAccept( wxComma
/* Update the current draw item /* Update the current draw item
*/ */
{ {
LIB_DRAW_ITEM* item = m_Parent->GetDrawItem();
if( item == NULL )
return;
g_FlDrawSpecificConvert = m_CommonConvert->GetValue() ? FALSE : TRUE; g_FlDrawSpecificConvert = m_CommonConvert->GetValue() ? FALSE : TRUE;
g_FlDrawSpecificUnit = m_CommonUnit->GetValue() ? FALSE : TRUE; g_FlDrawSpecificUnit = m_CommonUnit->GetValue() ? FALSE : TRUE;
@ -54,91 +59,84 @@ void WinEDA_bodygraphics_PropertiesFrame::bodygraphics_PropertiesAccept( wxComma
g_LibSymbolDefaultLineWidth = m_GraphicShapeWidthCtrl->GetValue(); g_LibSymbolDefaultLineWidth = m_GraphicShapeWidthCtrl->GetValue();
if( CurrentDrawItem ) if( !(item->m_Flags & IS_NEW) ) // if IS_NEW, copy for undo is done before place
{ m_Parent->SaveCopyInUndoList( item->GetParent() );
if( !(CurrentDrawItem->m_Flags & IS_NEW) ) // if IS_NEW, copy for undo is done before place
m_Parent->SaveCopyInUndoList( CurrentDrawItem->GetParent() );
wxClientDC dc( m_Parent->DrawPanel ); wxClientDC dc( m_Parent->DrawPanel );
m_Parent->DrawPanel->PrepareGraphicContext( &dc ); m_Parent->DrawPanel->PrepareGraphicContext( &dc );
CurrentDrawItem->Draw( m_Parent->DrawPanel, &dc, wxPoint( 0, 0 ), -1, item->Draw( m_Parent->DrawPanel, &dc, wxPoint( 0, 0 ), -1, g_XorMode,
g_XorMode, NULL, DefaultTransformMatrix ); NULL, DefaultTransformMatrix );
if( g_FlDrawSpecificUnit ) if( g_FlDrawSpecificUnit )
CurrentDrawItem->m_Unit = CurrentUnit; item->m_Unit = m_Parent->GetUnit();
else else
CurrentDrawItem->m_Unit = 0; item->m_Unit = 0;
if( g_FlDrawSpecificConvert ) if( g_FlDrawSpecificConvert )
CurrentDrawItem->m_Convert = CurrentConvert; item->m_Convert = m_Parent->GetConvert();
else else
CurrentDrawItem->m_Convert = 0; item->m_Convert = 0;
if( m_Filled ) if( m_Filled )
{ {
switch( CurrentDrawItem->Type() ) switch( item->Type() )
{ {
case COMPONENT_ARC_DRAW_TYPE: case COMPONENT_ARC_DRAW_TYPE:
( (LibDrawArc*) CurrentDrawItem )->m_Fill = FlSymbol_Fill; ( (LibDrawArc*) item )->m_Fill = FlSymbol_Fill;
( (LibDrawArc*) CurrentDrawItem )->m_Width = ( (LibDrawArc*) item )->m_Width =
m_GraphicShapeWidthCtrl->GetValue(); m_GraphicShapeWidthCtrl->GetValue();
break; break;
case COMPONENT_CIRCLE_DRAW_TYPE: case COMPONENT_CIRCLE_DRAW_TYPE:
( (LibDrawCircle*) CurrentDrawItem )->m_Fill = FlSymbol_Fill; ( (LibDrawCircle*) item )->m_Fill = FlSymbol_Fill;
( (LibDrawCircle*) CurrentDrawItem )->m_Width = ( (LibDrawCircle*) item )->m_Width =
m_GraphicShapeWidthCtrl->GetValue(); m_GraphicShapeWidthCtrl->GetValue();
break; break;
case COMPONENT_RECT_DRAW_TYPE: case COMPONENT_RECT_DRAW_TYPE:
( (LibDrawSquare*) CurrentDrawItem )->m_Fill = FlSymbol_Fill; ( (LibDrawSquare*) item )->m_Fill = FlSymbol_Fill;
( (LibDrawSquare*) CurrentDrawItem )->m_Width = ( (LibDrawSquare*) item )->m_Width =
m_GraphicShapeWidthCtrl->GetValue(); m_GraphicShapeWidthCtrl->GetValue();
break; break;
case COMPONENT_POLYLINE_DRAW_TYPE: case COMPONENT_POLYLINE_DRAW_TYPE:
( (LibDrawPolyline*) CurrentDrawItem )->m_Fill = ( (LibDrawPolyline*) item )->m_Fill =
FlSymbol_Fill; FlSymbol_Fill;
( (LibDrawPolyline*) CurrentDrawItem )->m_Width = ( (LibDrawPolyline*) item )->m_Width =
m_GraphicShapeWidthCtrl-> m_GraphicShapeWidthCtrl->GetValue();
GetValue();
break; break;
default: default:
break; break;
} }
}
CurrentDrawItem->GetParent()->SortDrawItems(); item->GetParent()->SortDrawItems();
m_Parent->GetScreen()->SetModify(); m_Parent->GetScreen()->SetModify();
CurrentDrawItem->Draw( m_Parent->DrawPanel, &dc, wxPoint( 0, 0 ), item->Draw( m_Parent->DrawPanel, &dc, wxPoint( 0, 0 ), -1, g_XorMode,
-1, g_XorMode, NULL, DefaultTransformMatrix ); NULL, DefaultTransformMatrix );
} }
Close(); Close();
if( CurrentDrawItem ) item->DisplayInfo( m_Parent );
CurrentDrawItem->DisplayInfo( m_Parent );
m_Parent->DrawPanel->Refresh(); m_Parent->DrawPanel->Refresh();
} }
/**********************************************************/ /*
void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, * Show the dialog box for editing a graphical item properties
LibEDA_BaseStruct* DrawItem )
/**********************************************************/
/* Install the dialog box for editing a graphical item properties
*/ */
void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem )
{ {
if( DrawItem == NULL ) if( DrawItem == NULL )
return; return;
WinEDA_bodygraphics_PropertiesFrame* frame = WinEDA_bodygraphics_PropertiesFrame dlg( this );
new WinEDA_bodygraphics_PropertiesFrame( this );
frame->ShowModal(); frame->Destroy(); dlg.ShowModal();
} }
@ -146,91 +144,53 @@ void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC,
static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC ) static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC )
/****************************************************************/ /****************************************************************/
{ {
LIB_DRAW_ITEM* item;
item = ( ( WinEDA_LibeditFrame* ) Panel->GetParent() )->GetDrawItem();
if( item == NULL )
return;
StateDrawArc = 0; StateDrawArc = 0;
Panel->ManageCurseur = NULL; Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL;
if( CurrentDrawItem == NULL )
return;
if( CurrentDrawItem->m_Flags & IS_NEW ) if( item->m_Flags & IS_NEW )
{
if( CurrentDrawItem->Type() == COMPONENT_ARC_DRAW_TYPE )
{ {
if( item->Type() == COMPONENT_ARC_DRAW_TYPE )
Panel->m_Parent->RedrawActiveWindow( DC, TRUE ); Panel->m_Parent->RedrawActiveWindow( DC, TRUE );
}
else else
{ item->Draw( Panel, DC, wxPoint( 0, 0 ), -1, g_XorMode, NULL,
CurrentDrawItem->Draw( Panel, DC, wxPoint( 0, 0 ), -1, g_XorMode, DefaultTransformMatrix );
NULL, DefaultTransformMatrix );
}
SAFE_DELETE( CurrentDrawItem ); SAFE_DELETE( item );
} }
else else
{ {
wxPoint curpos; wxPoint curpos = Panel->GetScreen()->m_Curseur;
curpos = Panel->GetScreen()->m_Curseur;
Panel->GetScreen()->m_Curseur = StartCursor; Panel->GetScreen()->m_Curseur = StartCursor;
RedrawWhileMovingCursor( Panel, DC, TRUE ); RedrawWhileMovingCursor( Panel, DC, TRUE );
Panel->GetScreen()->m_Curseur = curpos; Panel->GetScreen()->m_Curseur = curpos;
CurrentDrawItem->Draw( Panel, DC, wxPoint( 0, 0 ), -1, item->Draw( Panel, DC, wxPoint( 0, 0 ), -1, GR_DEFAULT_DRAWMODE, NULL,
GR_DEFAULT_DRAWMODE, NULL,
DefaultTransformMatrix ); DefaultTransformMatrix );
CurrentDrawItem->m_Flags = 0; item->m_Flags = 0;
} }
} }
/*******************************************************************************************/ LIB_DRAW_ITEM* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEntry,
LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEntry,
wxDC* DC ) wxDC* DC )
/*******************************************************************************************/
/* Routine de creation d'un nouvel element type LibraryDrawStruct
*/
{ {
int DrawType;
DrawPanel->m_IgnoreMouseEvents = TRUE;
// Creation du nouvel element
switch( m_ID_current_state )
{
case ID_LIBEDIT_BODY_LINE_BUTT:
DrawType = COMPONENT_POLYLINE_DRAW_TYPE;
break;
case ID_LIBEDIT_BODY_ARC_BUTT:
DrawType = COMPONENT_ARC_DRAW_TYPE;
break;
case ID_LIBEDIT_BODY_CIRCLE_BUTT:
DrawType = COMPONENT_CIRCLE_DRAW_TYPE;
break;
case ID_LIBEDIT_BODY_RECT_BUTT:
DrawType = COMPONENT_RECT_DRAW_TYPE;
break;
case ID_LIBEDIT_BODY_TEXT_BUTT:
DrawType = COMPONENT_GRAPHIC_TEXT_DRAW_TYPE;
break;
default:
DisplayError( this, wxT( "WinEDA_LibeditFrame::CreateGraphicItem() error" ) );
return NULL;
}
DrawPanel->ManageCurseur = SymbolDisplayDraw; DrawPanel->ManageCurseur = SymbolDisplayDraw;
DrawPanel->ForceCloseManageCurseur = AbortSymbolTraceOn; DrawPanel->ForceCloseManageCurseur = AbortSymbolTraceOn;
switch( DrawType ) switch( m_ID_current_state )
{ {
case COMPONENT_ARC_DRAW_TYPE: case ID_LIBEDIT_BODY_ARC_BUTT:
{ {
LibDrawArc* Arc = new LibDrawArc( LibEntry ); LibDrawArc* Arc = new LibDrawArc( LibEntry );
CurrentDrawItem = Arc; m_drawItem = Arc;
ArcStartX = ArcEndX = GetScreen()->m_Curseur.x; ArcStartX = ArcEndX = GetScreen()->m_Curseur.x;
ArcStartY = ArcEndY = -( GetScreen()->m_Curseur.y ); ArcStartY = ArcEndY = -( GetScreen()->m_Curseur.y );
StateDrawArc = 1; StateDrawArc = 1;
@ -239,11 +199,11 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEnt
} }
break; break;
case COMPONENT_CIRCLE_DRAW_TYPE: case ID_LIBEDIT_BODY_CIRCLE_BUTT:
{ {
LibDrawCircle* Circle = new LibDrawCircle( LibEntry ); LibDrawCircle* Circle = new LibDrawCircle( LibEntry );
CurrentDrawItem = Circle; m_drawItem = Circle;
Circle->m_Pos = GetScreen()->m_Curseur; Circle->m_Pos = GetScreen()->m_Curseur;
NEGATE( Circle->m_Pos.y ); NEGATE( Circle->m_Pos.y );
Circle->m_Fill = FlSymbol_Fill; Circle->m_Fill = FlSymbol_Fill;
@ -251,11 +211,11 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEnt
} }
break; break;
case COMPONENT_RECT_DRAW_TYPE: case ID_LIBEDIT_BODY_RECT_BUTT:
{ {
LibDrawSquare* Square = new LibDrawSquare( LibEntry ); LibDrawSquare* Square = new LibDrawSquare( LibEntry );
CurrentDrawItem = Square; m_drawItem = Square;
Square->m_Pos = GetScreen()->m_Curseur; Square->m_Pos = GetScreen()->m_Curseur;
NEGATE( Square->m_Pos.y ); NEGATE( Square->m_Pos.y );
Square->m_End = Square->m_Pos; Square->m_End = Square->m_Pos;
@ -264,10 +224,10 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEnt
} }
break; break;
case COMPONENT_POLYLINE_DRAW_TYPE: case ID_LIBEDIT_BODY_LINE_BUTT:
{ {
LibDrawPolyline* polyline = new LibDrawPolyline( LibEntry ); LibDrawPolyline* polyline = new LibDrawPolyline( LibEntry );
CurrentDrawItem = polyline; m_drawItem = polyline;
wxPoint point = GetScreen()->m_Curseur; wxPoint point = GetScreen()->m_Curseur;
NEGATE( point.y ); NEGATE( point.y );
polyline->AddPoint( point ); // Start point of the current segment polyline->AddPoint( point ); // Start point of the current segment
@ -281,7 +241,7 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEnt
{ {
LibDrawSegment* Segment = new LibDrawSegment( LibEntry ); LibDrawSegment* Segment = new LibDrawSegment( LibEntry );
CurrentDrawItem = Segment; m_drawItem = Segment;
Segment->m_Pos = GetScreen()->m_Curseur; Segment->m_Pos = GetScreen()->m_Curseur;
NEGATE( Segment->m_Pos.y ); NEGATE( Segment->m_Pos.y );
Segment->m_End = Segment->m_Pos; Segment->m_End = Segment->m_Pos;
@ -289,11 +249,11 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEnt
} }
break; break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: case ID_LIBEDIT_BODY_TEXT_BUTT:
{ {
LibDrawText* Text = new LibDrawText( LibEntry ); LibDrawText* Text = new LibDrawText( LibEntry );
CurrentDrawItem = Text; m_drawItem = Text;
Text->m_Size.x = Text->m_Size.y = g_LastTextSize; Text->m_Size.x = Text->m_Size.y = g_LastTextSize;
Text->m_Orient = g_LastTextOrient; Text->m_Orient = g_LastTextOrient;
Text->m_Pos = GetScreen()->m_Curseur; Text->m_Pos = GetScreen()->m_Curseur;
@ -302,7 +262,7 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEnt
if( Text->m_Text.IsEmpty() ) if( Text->m_Text.IsEmpty() )
{ {
SAFE_DELETE( Text ); SAFE_DELETE( Text );
CurrentDrawItem = NULL; m_drawItem = NULL;
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
} }
@ -314,21 +274,26 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEnt
} }
} }
break; break;
default:
DisplayError( this, wxT( "WinEDA_LibeditFrame::CreateGraphicItem() \
error" ) );
return NULL;
} }
if( CurrentDrawItem ) if( m_drawItem )
{ {
CurrentDrawItem->m_Flags |= IS_NEW; m_drawItem->m_Flags |= IS_NEW;
if( g_FlDrawSpecificUnit ) if( g_FlDrawSpecificUnit )
CurrentDrawItem->m_Unit = CurrentUnit; m_drawItem->m_Unit = m_unit;
if( g_FlDrawSpecificConvert ) if( g_FlDrawSpecificConvert )
CurrentDrawItem->m_Convert = CurrentConvert; m_drawItem->m_Convert = m_convert;
} }
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = FALSE; DrawPanel->m_IgnoreMouseEvents = FALSE;
return CurrentDrawItem; return m_drawItem;
} }
@ -339,10 +304,10 @@ void WinEDA_LibeditFrame::GraphicItemBeginDraw( wxDC* DC )
/* Routine de creation d'un nouvel element type LibraryDrawStruct /* Routine de creation d'un nouvel element type LibraryDrawStruct
*/ */
{ {
if( CurrentDrawItem == NULL ) if( m_drawItem == NULL )
return; return;
switch( CurrentDrawItem->Type() ) switch( m_drawItem->Type() )
{ {
case COMPONENT_ARC_DRAW_TYPE: case COMPONENT_ARC_DRAW_TYPE:
if( StateDrawArc == 1 ) if( StateDrawArc == 1 )
@ -369,7 +334,7 @@ void WinEDA_LibeditFrame::GraphicItemBeginDraw( wxDC* DC )
{ {
wxPoint pos = GetScreen()->m_Curseur; wxPoint pos = GetScreen()->m_Curseur;
NEGATE( pos.y ); NEGATE( pos.y );
( (LibDrawPolyline*) CurrentDrawItem )->AddPoint( pos ); ( (LibDrawPolyline*) m_drawItem )->AddPoint( pos );
} }
break; break;
@ -382,15 +347,20 @@ void WinEDA_LibeditFrame::GraphicItemBeginDraw( wxDC* DC )
} }
/**************************************************************************/ /*
* Redraw the graphoc shape while moving
*/
static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel, static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel,
wxDC* DC, wxDC* DC,
bool erase ) bool erase )
/**************************************************************************/
/* Redraw the graphoc shape while moving
*/
{ {
LIB_DRAW_ITEM* item;
item = ( ( WinEDA_LibeditFrame* ) panel->GetParent() )->GetDrawItem();
if( item == NULL )
return;
BASE_SCREEN* Screen = panel->GetScreen(); BASE_SCREEN* Screen = panel->GetScreen();
wxPoint pos; wxPoint pos;
@ -398,110 +368,27 @@ static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel,
if( erase ) if( erase )
{ {
pos = ItemPreviousPos - StartCursor; pos = ItemPreviousPos - StartCursor;
CurrentDrawItem->Draw( panel, DC, pos, -1, g_XorMode, NULL, item->Draw( panel, DC, pos, -1, g_XorMode, NULL,
DefaultTransformMatrix ); DefaultTransformMatrix );
} }
/* Redraw moved shape */ /* Redraw moved shape */
pos = Screen->m_Curseur - StartCursor; pos = Screen->m_Curseur - StartCursor;
CurrentDrawItem->Draw( panel, DC, pos, -1, g_XorMode, NULL, item->Draw( panel, DC, pos, -1, g_XorMode, NULL, DefaultTransformMatrix );
DefaultTransformMatrix );
ItemPreviousPos = Screen->m_Curseur; ItemPreviousPos = Screen->m_Curseur;
} }
/*****************************************************************/
void MoveLibDrawItemAt( LibEDA_BaseStruct* DrawItem, wxPoint newpos )
/*****************************************************************/
{
NEGATE( newpos.y );
wxPoint size;
switch( DrawItem->Type() )
{
case COMPONENT_ARC_DRAW_TYPE:
{
wxPoint offset = newpos - ( (LibDrawArc*) CurrentDrawItem )->m_Pos;
( (LibDrawArc*) CurrentDrawItem )->m_Pos = newpos;
( (LibDrawArc*) CurrentDrawItem )->m_ArcStart += offset;
( (LibDrawArc*) CurrentDrawItem )->m_ArcEnd += offset;
break;
}
case COMPONENT_CIRCLE_DRAW_TYPE:
( (LibDrawCircle*) CurrentDrawItem )->m_Pos = newpos;
break;
case COMPONENT_RECT_DRAW_TYPE:
size = ( (LibDrawSquare*) CurrentDrawItem )->m_End -
( (LibDrawSquare*) CurrentDrawItem )->m_Pos;
( (LibDrawSquare*) CurrentDrawItem )->m_Pos = newpos;
( (LibDrawSquare*) CurrentDrawItem )->m_End = newpos + size;
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
{
int ii, imax = ( (LibDrawPolyline*) CurrentDrawItem )->GetCornerCount();
wxPoint offset = newpos - ( (LibDrawPolyline*) CurrentDrawItem )->m_PolyPoints[0];
for( ii = 0; ii < imax; ii++ )
( (LibDrawPolyline*) CurrentDrawItem )->m_PolyPoints[ii] += offset;
}
break;
case COMPONENT_LINE_DRAW_TYPE:
break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
( (LibDrawText*) CurrentDrawItem )->m_Pos = newpos;
break;
default:
;
}
}
/************************************************************/
void WinEDA_LibeditFrame::StartMoveDrawSymbol( wxDC* DC ) void WinEDA_LibeditFrame::StartMoveDrawSymbol( wxDC* DC )
/************************************************************/
{ {
if( CurrentDrawItem == NULL ) if( m_drawItem == NULL )
return; return;
SetCursor( wxCURSOR_HAND ); SetCursor( wxCURSOR_HAND );
CurrentDrawItem->m_Flags |= IS_MOVED; m_drawItem->m_Flags |= IS_MOVED;
StartCursor = GetScreen()->m_Curseur; StartCursor = GetScreen()->m_Curseur;
InitPosition = m_drawItem->GetPosition();
switch( CurrentDrawItem->Type() )
{
case COMPONENT_ARC_DRAW_TYPE:
InitPosition = ( (LibDrawArc*) CurrentDrawItem )->m_Pos;
break;
case COMPONENT_CIRCLE_DRAW_TYPE:
InitPosition = ( (LibDrawCircle*) CurrentDrawItem )->m_Pos;
break;
case COMPONENT_RECT_DRAW_TYPE:
InitPosition = ( (LibDrawSquare*) CurrentDrawItem )->m_Pos;
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
InitPosition = ( (LibDrawPolyline*) CurrentDrawItem )->m_PolyPoints[0];
break;
case COMPONENT_LINE_DRAW_TYPE:
break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
InitPosition = ( (LibDrawText*) CurrentDrawItem )->m_Pos;
break;
default:
;
}
ItemPreviousPos = GetScreen()->m_Curseur; ItemPreviousPos = GetScreen()->m_Curseur;
DrawPanel->ManageCurseur = RedrawWhileMovingCursor; DrawPanel->ManageCurseur = RedrawWhileMovingCursor;
DrawPanel->ForceCloseManageCurseur = AbortSymbolTraceOn; DrawPanel->ForceCloseManageCurseur = AbortSymbolTraceOn;
@ -520,6 +407,13 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
BASE_SCREEN* Screen = panel->GetScreen(); BASE_SCREEN* Screen = panel->GetScreen();
wxPoint curr_pos = Screen->m_Curseur; wxPoint curr_pos = Screen->m_Curseur;
LIB_DRAW_ITEM* item;
item = ( ( WinEDA_LibeditFrame* ) panel->GetParent() )->GetDrawItem();
if( item == NULL )
return;
NEGATE( curr_pos.y ); NEGATE( curr_pos.y );
GRSetDrawMode( DC, DrawMode ); GRSetDrawMode( DC, DrawMode );
@ -529,72 +423,67 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
if( StateDrawArc == 1 ) if( StateDrawArc == 1 )
{ {
int Color = ReturnLayerColor( LAYER_DEVICE ); int Color = ReturnLayerColor( LAYER_DEVICE );
GRLine( &panel->m_ClipBox, GRLine( &panel->m_ClipBox, DC, ArcStartX, -ArcStartY,
DC, ArcEndX, -ArcEndY, 0, Color );
ArcStartX,
-ArcStartY,
ArcEndX,
-ArcEndY,
0,
Color );
} }
else else
{ {
CurrentDrawItem->Draw( panel, DC, wxPoint( 0, 0 ), -1, DrawMode, item->Draw( panel, DC, wxPoint( 0, 0 ), -1, DrawMode, NULL,
NULL, DefaultTransformMatrix ); DefaultTransformMatrix );
if( CurrentDrawItem->Type() == COMPONENT_ARC_DRAW_TYPE ) if( item->Type() == COMPONENT_ARC_DRAW_TYPE )
{ {
int Color = ReturnLayerColor( LAYER_DEVICE ); int Color = ReturnLayerColor( LAYER_DEVICE );
GRDashedLine( &panel->m_ClipBox, DC, ArcStartX, -ArcStartY, GRDashedLine( &panel->m_ClipBox, DC, ArcStartX, -ArcStartY,
( (LibDrawArc*) CurrentDrawItem )->m_Pos.x, ( (LibDrawArc*) item )->m_Pos.x,
-( (LibDrawArc*) CurrentDrawItem )->m_Pos.y, -( (LibDrawArc*) item )->m_Pos.y,
0, Color ); 0, Color );
GRDashedLine( &panel->m_ClipBox, DC, ArcEndX, -ArcEndY, GRDashedLine( &panel->m_ClipBox, DC, ArcEndX, -ArcEndY,
( (LibDrawArc*) CurrentDrawItem )->m_Pos.x, ( (LibDrawArc*) item )->m_Pos.x,
-( (LibDrawArc*) CurrentDrawItem )->m_Pos.y, -( (LibDrawArc*) item )->m_Pos.y,
0, Color ); 0, Color );
} }
} }
} }
switch( CurrentDrawItem->Type() ) switch( item->Type() )
{ {
case COMPONENT_ARC_DRAW_TYPE: case COMPONENT_ARC_DRAW_TYPE:
if( StateDrawArc == 1 ) if( StateDrawArc == 1 )
{ {
ArcEndX = curr_pos.x; ArcEndY = curr_pos.y; ArcEndX = curr_pos.x;
ArcEndY = curr_pos.y;
} }
if( StateDrawArc == 2 ) if( StateDrawArc == 2 )
{ {
ComputeArc( (LibDrawArc*) CurrentDrawItem, Screen->m_Curseur ); ComputeArc( (LibDrawArc*) item, Screen->m_Curseur );
} }
( (LibDrawArc*) CurrentDrawItem )->m_Fill = FlSymbol_Fill; ( (LibDrawArc*) item )->m_Fill = FlSymbol_Fill;
break; break;
case COMPONENT_CIRCLE_DRAW_TYPE: case COMPONENT_CIRCLE_DRAW_TYPE:
dx = ( (LibDrawCircle*) CurrentDrawItem )->m_Pos.x - curr_pos.x; dx = ( (LibDrawCircle*) item )->m_Pos.x - curr_pos.x;
dy = ( (LibDrawCircle*) CurrentDrawItem )->m_Pos.y - curr_pos.y; dy = ( (LibDrawCircle*) item )->m_Pos.y - curr_pos.y;
( (LibDrawCircle*) CurrentDrawItem )->m_Radius = ( (LibDrawCircle*) item )->m_Radius =
(int) sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) ); (int) sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) );
( (LibDrawCircle*) CurrentDrawItem )->m_Fill = FlSymbol_Fill; ( (LibDrawCircle*) item )->m_Fill = FlSymbol_Fill;
break; break;
case COMPONENT_RECT_DRAW_TYPE: case COMPONENT_RECT_DRAW_TYPE:
( (LibDrawSquare*) CurrentDrawItem )->m_End = curr_pos; ( (LibDrawSquare*) item )->m_End = curr_pos;
( (LibDrawSquare*) CurrentDrawItem )->m_Fill = FlSymbol_Fill; ( (LibDrawSquare*) item )->m_Fill = FlSymbol_Fill;
break; break;
case COMPONENT_POLYLINE_DRAW_TYPE: case COMPONENT_POLYLINE_DRAW_TYPE:
{ {
unsigned idx = ( (LibDrawPolyline*) CurrentDrawItem )->GetCornerCount() - 1; unsigned idx = ( (LibDrawPolyline*) item )->GetCornerCount() - 1;
( (LibDrawPolyline*) CurrentDrawItem )->m_PolyPoints[idx] = curr_pos; ( (LibDrawPolyline*) item )->m_PolyPoints[idx] = curr_pos;
( (LibDrawPolyline*) CurrentDrawItem )->m_Fill = FlSymbol_Fill; ( (LibDrawPolyline*) item )->m_Fill = FlSymbol_Fill;
} }
break; break;
case COMPONENT_LINE_DRAW_TYPE: case COMPONENT_LINE_DRAW_TYPE:
( (LibDrawSegment*) CurrentDrawItem )->m_End = curr_pos; ( (LibDrawSegment*) item )->m_End = curr_pos;
break; break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: /* Traite par des routines specifiques */ case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: /* Traite par des routines specifiques */
@ -607,29 +496,24 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
if( StateDrawArc == 1 ) if( StateDrawArc == 1 )
{ {
int Color = ReturnLayerColor( LAYER_DEVICE ); int Color = ReturnLayerColor( LAYER_DEVICE );
GRLine( &panel->m_ClipBox, GRLine( &panel->m_ClipBox, DC, ArcStartX, -ArcStartY, ArcEndX,
DC, -ArcEndY, 0, Color );
ArcStartX,
-ArcStartY,
ArcEndX,
-ArcEndY,
0,
Color );
} }
else else
{ {
CurrentDrawItem->Draw( panel, DC, wxPoint( 0, 0 ), -1, DrawMode, item->Draw( panel, DC, wxPoint( 0, 0 ), -1, DrawMode, NULL,
NULL, DefaultTransformMatrix ); DefaultTransformMatrix );
if( CurrentDrawItem->Type() == COMPONENT_ARC_DRAW_TYPE )
if( item->Type() == COMPONENT_ARC_DRAW_TYPE )
{ {
int Color = ReturnLayerColor( LAYER_DEVICE ); int Color = ReturnLayerColor( LAYER_DEVICE );
GRDashedLine( &panel->m_ClipBox, DC, ArcStartX, -ArcStartY, GRDashedLine( &panel->m_ClipBox, DC, ArcStartX, -ArcStartY,
( (LibDrawArc*) CurrentDrawItem )->m_Pos.x, ( (LibDrawArc*) item )->m_Pos.x,
-( (LibDrawArc*) CurrentDrawItem )->m_Pos.y, -( (LibDrawArc*) item )->m_Pos.y,
0, Color ); 0, Color );
GRDashedLine( &panel->m_ClipBox, DC, ArcEndX, -ArcEndY, GRDashedLine( &panel->m_ClipBox, DC, ArcEndX, -ArcEndY,
( (LibDrawArc*) CurrentDrawItem )->m_Pos.x, ( (LibDrawArc*) item )->m_Pos.x,
-( (LibDrawArc*) CurrentDrawItem )->m_Pos.y, -( (LibDrawArc*) item )->m_Pos.y,
0, Color ); 0, Color );
} }
} }
@ -643,16 +527,14 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC )
/* Place la structure courante en liste des structures du composant /* Place la structure courante en liste des structures du composant
* courant, si elle existe et redessine toujours celle ci * courant, si elle existe et redessine toujours celle ci
* Parametres: (tous globaux) * Parametres: (tous globaux)
* CurrentDrawItem * m_drawItem
* m_currentComponent * m_component
*/ */
{ {
if( m_currentComponent == NULL ) if( m_component == NULL || m_drawItem == NULL )
return;
if( CurrentDrawItem == NULL )
return; return;
if( CurrentDrawItem->Type() == COMPONENT_ARC_DRAW_TYPE ) if( m_drawItem->Type() == COMPONENT_ARC_DRAW_TYPE )
{ {
if( StateDrawArc == 1 ) /* Trace d'arc en cours: doit etre termine */ if( StateDrawArc == 1 ) /* Trace d'arc en cours: doit etre termine */
{ {
@ -660,35 +542,35 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC )
} }
else else
{ {
if( (CurrentDrawItem->m_Flags & IS_MOVED) == 0 ) if( (m_drawItem->m_Flags & IS_MOVED) == 0 )
SymbolDisplayDraw( DrawPanel, DC, FALSE ); SymbolDisplayDraw( DrawPanel, DC, FALSE );
} }
} }
StateDrawArc = 0; StateDrawArc = 0;
if( CurrentDrawItem->m_Flags & IS_NEW ) if( m_drawItem->m_Flags & IS_NEW )
{ {
SaveCopyInUndoList( m_currentComponent ); SaveCopyInUndoList( m_component );
CurrentDrawItem->SetNext( m_currentComponent->m_Drawings ); m_drawItem->SetNext( m_component->m_Drawings );
m_currentComponent->m_Drawings = CurrentDrawItem; m_component->m_Drawings = m_drawItem;
switch( CurrentDrawItem->Type() ) switch( m_drawItem->Type() )
{ {
case COMPONENT_ARC_DRAW_TYPE: case COMPONENT_ARC_DRAW_TYPE:
( (LibDrawArc*) CurrentDrawItem )->m_Fill = FlSymbol_Fill; ( (LibDrawArc*) m_drawItem )->m_Fill = FlSymbol_Fill;
break; break;
case COMPONENT_CIRCLE_DRAW_TYPE: case COMPONENT_CIRCLE_DRAW_TYPE:
( (LibDrawCircle*) CurrentDrawItem )->m_Fill = FlSymbol_Fill; ( (LibDrawCircle*) m_drawItem )->m_Fill = FlSymbol_Fill;
break; break;
case COMPONENT_RECT_DRAW_TYPE: case COMPONENT_RECT_DRAW_TYPE:
( (LibDrawSquare*) CurrentDrawItem )->m_Fill = FlSymbol_Fill; ( (LibDrawSquare*) m_drawItem )->m_Fill = FlSymbol_Fill;
break; break;
case COMPONENT_POLYLINE_DRAW_TYPE: case COMPONENT_POLYLINE_DRAW_TYPE:
( (LibDrawPolyline*) CurrentDrawItem )->m_Fill = FlSymbol_Fill; ( (LibDrawPolyline*) m_drawItem )->m_Fill = FlSymbol_Fill;
break; break;
case COMPONENT_PIN_DRAW_TYPE: case COMPONENT_PIN_DRAW_TYPE:
@ -700,7 +582,7 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC )
; ;
} }
m_currentComponent->SortDrawItems(); m_component->SortDrawItems();
} }
if( m_ID_current_state ) if( m_ID_current_state )
@ -708,19 +590,20 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC )
else else
SetCursor( wxCURSOR_ARROW ); SetCursor( wxCURSOR_ARROW );
if( (CurrentDrawItem->m_Flags & IS_MOVED) ) if( (m_drawItem->m_Flags & IS_MOVED) )
{ {
wxPoint pos; wxPoint pos;
pos.x = GetScreen()->m_Curseur.x + InitPosition.x - StartCursor.x, pos.x = GetScreen()->m_Curseur.x + InitPosition.x - StartCursor.x,
pos.y = GetScreen()->m_Curseur.y - InitPosition.y - StartCursor.y; pos.y = GetScreen()->m_Curseur.y - InitPosition.y - StartCursor.y;
MoveLibDrawItemAt( CurrentDrawItem, pos ); NEGATE( pos.y );
m_drawItem->Move( pos );
} }
m_currentComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), CurrentUnit, m_component->Draw( DrawPanel, DC, wxPoint( 0, 0 ), m_unit, m_convert,
CurrentConvert, GR_DEFAULT_DRAWMODE ); GR_DEFAULT_DRAWMODE );
CurrentDrawItem->m_Flags = 0; m_drawItem->m_Flags = 0;
CurrentDrawItem = NULL; m_drawItem = NULL;
GetScreen()->SetModify(); GetScreen()->SetModify();
@ -826,14 +709,14 @@ void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC )
/* Used for deleting last entered segment while creating a Polyline /* Used for deleting last entered segment while creating a Polyline
*/ */
{ {
if( CurrentDrawItem == NULL if( m_drawItem == NULL
|| CurrentDrawItem->Type() != COMPONENT_POLYLINE_DRAW_TYPE ) || m_drawItem->Type() != COMPONENT_POLYLINE_DRAW_TYPE )
return; return;
LibDrawPolyline* Poly = (LibDrawPolyline*) CurrentDrawItem; LibDrawPolyline* Poly = (LibDrawPolyline*) m_drawItem;
CurrentDrawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, m_drawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, NULL,
NULL, DefaultTransformMatrix ); DefaultTransformMatrix );
while( Poly->GetCornerCount() > 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
{ {
@ -848,6 +731,6 @@ void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC )
} }
} }
CurrentDrawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, m_drawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, NULL,
NULL, DefaultTransformMatrix ); DefaultTransformMatrix );
} }

Some files were not shown because too many files have changed in this diff Show More