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()
/********************************************/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,98 +11,15 @@
#include "block_commande.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "class_library.h"
#include "protos.h"
#include "libeditfrm.h"
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
bool erase );
static int MarkItemsInBloc( LIB_COMPONENT* LibComponent,
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;
}
static void MirrorMarkedItems( LIB_COMPONENT* LibEntry, wxPoint offset );
/*
@ -158,7 +75,7 @@ int WinEDA_LibeditFrame::ReturnBlockCommand( int key )
*/
int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
{
int ItemsCount = 0;
int ItemCount = 0;
int MustDoPlace = 0;
if( GetScreen()->m_BlockLocate.GetCount() )
@ -184,9 +101,10 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_DRAG: /* Drag */
case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */
ItemsCount = MarkItemsInBloc( m_currentComponent,
GetScreen()->m_BlockLocate );
if( ItemsCount )
ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate,
m_unit, m_convert,
g_EditPinByPinIsOn );
if( ItemCount )
{
MustDoPlace = 1;
if( DrawPanel->ManageCurseur != NULL )
@ -207,11 +125,12 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
break;
case BLOCK_DELETE: /* Delete */
ItemsCount = MarkItemsInBloc( m_currentComponent,
GetScreen()->m_BlockLocate );
if( ItemsCount )
SaveCopyInUndoList( m_currentComponent );
DeleteMarkedItems( m_currentComponent );
ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate,
m_unit, m_convert,
g_EditPinByPinIsOn );
if( ItemCount )
SaveCopyInUndoList( m_component );
m_component->DeleteSelectedItems();
break;
case BLOCK_SAVE: /* Save */
@ -223,12 +142,12 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_MIRROR_Y:
ItemsCount = MarkItemsInBloc( m_currentComponent,
GetScreen()->m_BlockLocate );
if( ItemsCount )
SaveCopyInUndoList( m_currentComponent );
MirrorMarkedItems( m_currentComponent,
GetScreen()->m_BlockLocate.Centre() );
ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate,
m_unit, m_convert,
g_EditPinByPinIsOn );
if( ItemCount )
SaveCopyInUndoList( m_component );
MirrorMarkedItems( m_component, GetScreen()->m_BlockLocate.Centre() );
break;
case BLOCK_ZOOM: /* Window Zoom */
@ -245,9 +164,8 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
if( MustDoPlace <= 0 )
{
if( GetScreen()->m_BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY )
{
ClearMarkItems( m_currentComponent );
}
m_component->ClearSelectedItems();
GetScreen()->m_BlockLocate.m_Flags = 0;
GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
@ -273,6 +191,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
{
bool err = FALSE;
wxPoint offset;
if( DrawPanel->ManageCurseur == NULL )
{
@ -292,17 +211,19 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
case BLOCK_MOVE: /* Move */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( m_currentComponent );
MoveMarkedItems( m_currentComponent,
GetScreen()->m_BlockLocate.m_MoveVector );
SaveCopyInUndoList( m_component );
offset = GetScreen()->m_BlockLocate.m_MoveVector;
offset.y *= -1;
m_component->MoveSelectedItems( offset );
DrawPanel->Refresh( TRUE );
break;
case BLOCK_COPY: /* Copy */
GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( m_currentComponent );
CopyMarkedItems( m_currentComponent,
GetScreen()->m_BlockLocate.m_MoveVector );
SaveCopyInUndoList( m_component );
offset = GetScreen()->m_BlockLocate.m_MoveVector;
offset.y *= -1;
m_component->CopySelectedItems( offset );
break;
case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */
@ -310,9 +231,8 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
break;
case BLOCK_MIRROR_Y: /* Invert by popup menu, from block move */
SaveCopyInUndoList( m_currentComponent );
MirrorMarkedItems( m_currentComponent,
GetScreen()->m_BlockLocate.Centre() );
SaveCopyInUndoList( m_component );
MirrorMarkedItems( m_component, GetScreen()->m_BlockLocate.Centre() );
break;
case BLOCK_ZOOM: // Handled by HandleBlockEnd
@ -348,25 +268,27 @@ void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
BLOCK_SELECTOR* PtBlock;
BASE_SCREEN* screen = panel->GetScreen();
wxPoint move_offset;
PtBlock = &screen->m_BlockLocate;
WinEDA_LibeditFrame* parent = ( WinEDA_LibeditFrame* ) panel->GetParent();
wxASSERT( parent != NULL );
LIB_COMPONENT* component = parent->GetCurrentComponent();
LIB_COMPONENT* component = parent->GetComponent();
if( component == NULL )
return;
int unit = parent->GetUnit();
int convert = parent->GetConvert();
if( erase )
{
PtBlock->Draw( panel, DC, PtBlock->m_MoveVector, g_XorMode,
PtBlock->m_Color );
component->Draw( panel, DC, PtBlock->m_MoveVector, CurrentUnit,
CurrentConvert, g_XorMode, -1, DefaultTransformMatrix,
true, false, true );
component->Draw( panel, DC, PtBlock->m_MoveVector, unit, convert,
g_XorMode, -1, DefaultTransformMatrix,
true, true, true );
}
/* 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->m_Color );
component->Draw( panel, DC, PtBlock->m_MoveVector, CurrentUnit,
CurrentConvert, g_XorMode, -1, DefaultTransformMatrix,
true, false, 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 );
}
component->Draw( panel, DC, PtBlock->m_MoveVector, unit, convert,
g_XorMode, -1, DefaultTransformMatrix,
true, true, true );
}
@ -460,7 +313,7 @@ void DeleteMarkedItems( LIB_COMPONENT* LibEntry )
void MirrorMarkedItems( LIB_COMPONENT* LibEntry, wxPoint offset )
{
#define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x;
LibEDA_BaseStruct* item;
LIB_DRAW_ITEM* item;
if( LibEntry == NULL )
return;

View File

@ -14,17 +14,16 @@
#include "kicad_string.h"
#include "gestfich.h"
#include "appl_wxstruct.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "class_library.h"
#include "netlist.h"
#include "protos.h"
#include "dialog_build_BOM.h"
#include "protos.h"
/* 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,
* 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 "program.h"
#include "libcmp.h"
#include "classes_body_items.h"
#include "general.h"
#include "protos.h"

View File

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

View File

@ -15,7 +15,7 @@
#include "trigo.h"
#include "program.h"
#include "libcmp.h"
#include "classes_body_items.h"
#include "general.h"
#include "protos.h"
@ -23,7 +23,7 @@
LibDrawText::LibDrawText(LIB_COMPONENT * aParent) :
LibEDA_BaseStruct( COMPONENT_GRAPHIC_TEXT_DRAW_TYPE, aParent ),
LIB_DRAW_ITEM( COMPONENT_GRAPHIC_TEXT_DRAW_TYPE, aParent ),
EDA_TextStruct()
{
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);
@ -189,11 +189,11 @@ LibEDA_BaseStruct* LibDrawText::DoGenCopy()
newitem->m_Bold = m_Bold;
newitem->m_HJustify = m_HJustify;
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 );
@ -220,6 +220,12 @@ bool LibDrawText::DoTestInside( EDA_Rect& rect )
}
void LibDrawText::DoMove( const wxPoint& newPosition )
{
m_Pos = newPosition;
}
/** Function GetPenSize
* @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;
LibEDA_BaseStruct::DisplayInfo( frame );
LIB_DRAW_ITEM::DisplayInfo( frame );
msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true );

View File

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

View File

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

View File

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

View File

@ -10,15 +10,16 @@
#include "gr_basic.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
#include "class_library.h"
#include "class_libentry.h"
int SortItemsFct(const void* ref, const void* item)
{
#define Ref ( *(LibEDA_BaseStruct**) (ref) )
#define Item ( *(LibEDA_BaseStruct**) (item) )
#define Ref ( *(LIB_DRAW_ITEM**) (ref) )
#define Item ( *(LIB_DRAW_ITEM**) (item) )
#define BEFORE -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()
{
}
@ -178,7 +193,43 @@ wxString CMP_LIB_ENTRY::GetLibraryName()
if( m_lib != NULL )
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()
{
}
@ -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()
{
LibEDA_BaseStruct* DrawItem;
LibEDA_BaseStruct* NextDrawItem;
LIB_DRAW_ITEM* DrawItem;
LIB_DRAW_ITEM* NextDrawItem;
/* suppression des elements dependants */
DrawItem = m_Drawings;
@ -285,7 +394,7 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* dc,
{
wxString fieldText;
LibDrawField* Field;
LibEDA_BaseStruct* drawItem;
LIB_DRAW_ITEM* drawItem;
BASE_SCREEN* screen = panel->GetScreen();
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 ) )
continue;
if( convert && drawItem->m_Convert && ( drawItem->m_Convert != convert ) )
if( convert && drawItem->m_Convert
&& ( drawItem->m_Convert != convert ) )
continue;
@ -346,12 +456,19 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* dc,
fieldText = m_Prefix.m_Text + wxT( "?" );
}
if( !( onlySelected && m_Prefix.m_Selected == 0 ) )
m_Prefix.Draw( panel, dc, offset, color, drawMode, &fieldText,
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() )
{
if( onlySelected && drawItem->m_Selected == 0 )
continue;
Field->Draw( panel, dc, offset, color, drawMode, NULL,
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,
wxDC* dc )
{
wxASSERT( item != NULL );
LibEDA_BaseStruct* prevItem = m_Drawings;
LIB_DRAW_ITEM* prevItem = m_Drawings;
if( dc != 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 )
{
LibEDA_BaseStruct* DrawEntry;
LIB_DRAW_ITEM* DrawEntry;
LibDrawField* Field;
if( Type != ROOT ) // should not happen, but just in case
return false;
/* Sort just in clase sorting was not done properly. */
SortDrawItems();
/* 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 )
@ -656,9 +773,9 @@ bool LIB_COMPONENT::Load( FILE* file, char* line, int* lineNum,
bool LIB_COMPONENT::LoadDrawEntries( FILE* f, char* line,
int* lineNum, wxString& errorMsg )
{
LibEDA_BaseStruct* newEntry = NULL;
LibEDA_BaseStruct* headEntry = NULL;
LibEDA_BaseStruct* tailEntry = NULL;
LIB_DRAW_ITEM* newEntry = NULL;
LIB_DRAW_ITEM* headEntry = NULL;
LIB_DRAW_ITEM* tailEntry = NULL;
while( true )
{
@ -676,31 +793,31 @@ bool LIB_COMPONENT::LoadDrawEntries( FILE* f, char* line,
switch( line[0] )
{
case 'A': /* Arc */
newEntry = ( LibEDA_BaseStruct* ) new LibDrawArc(this);
newEntry = ( LIB_DRAW_ITEM* ) new LibDrawArc(this);
break;
case 'C': /* Circle */
newEntry = ( LibEDA_BaseStruct* ) new LibDrawCircle(this);
newEntry = ( LIB_DRAW_ITEM* ) new LibDrawCircle(this);
break;
case 'T': /* Text */
newEntry = ( LibEDA_BaseStruct* ) new LibDrawText(this);
newEntry = ( LIB_DRAW_ITEM* ) new LibDrawText(this);
break;
case 'S': /* Square */
newEntry = ( LibEDA_BaseStruct* ) new LibDrawSquare(this);
newEntry = ( LIB_DRAW_ITEM* ) new LibDrawSquare(this);
break;
case 'X': /* Pin Description */
newEntry = ( LibEDA_BaseStruct* ) new LibDrawPin(this);
newEntry = ( LIB_DRAW_ITEM* ) new LibDrawPin(this);
break;
case 'P': /* Polyline */
newEntry = ( LibEDA_BaseStruct* ) new LibDrawPolyline(this);
newEntry = ( LIB_DRAW_ITEM* ) new LibDrawPolyline(this);
break;
case 'B': /* Bezier Curves */
newEntry = ( LibEDA_BaseStruct* ) new LibDrawBezier(this);
newEntry = ( LIB_DRAW_ITEM* ) new LibDrawBezier(this);
break;
default:
@ -818,7 +935,7 @@ bool LIB_COMPONENT::LoadFootprints( FILE* file, char* line,
*/
void LIB_COMPONENT::SortDrawItems()
{
LibEDA_BaseStruct** Bufentry, ** BufentryBase, * Entry = m_Drawings;
LIB_DRAW_ITEM** Bufentry, ** BufentryBase, * Entry = m_Drawings;
int ii, nbitems;
if( Entry == NULL )
@ -828,15 +945,15 @@ void LIB_COMPONENT::SortDrawItems()
nbitems++;
BufentryBase =
(LibEDA_BaseStruct**) MyZMalloc( (nbitems + 1) *
sizeof(LibEDA_BaseStruct*) );
(LIB_DRAW_ITEM**) MyZMalloc( (nbitems + 1) *
sizeof(LIB_DRAW_ITEM*) );
/* memorisation du chainage : */
for( Entry = m_Drawings, ii = 0; Entry != NULL; Entry = Entry->Next() )
BufentryBase[ii++] = Entry;
/* Tri du chainage */
qsort( BufentryBase, nbitems, sizeof(LibEDA_BaseStruct*), SortItemsFct );
qsort( BufentryBase, nbitems, sizeof(LIB_DRAW_ITEM*), SortItemsFct );
/* Mise a jour du chainage. Remarque:
* 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 )
{
LibEDA_BaseStruct* DrawEntry;
LIB_DRAW_ITEM* DrawEntry;
EDA_Rect bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) );
for( DrawEntry = m_Drawings; DrawEntry != NULL;
@ -982,7 +1099,7 @@ bool LIB_COMPONENT::LoadDateAndTime( char* Line )
void LIB_COMPONENT::SetOffset( const wxPoint& offset )
{
LibEDA_BaseStruct* DrawEntry;
LIB_DRAW_ITEM* DrawEntry;
m_Name.SetOffset( offset );
m_Prefix.SetOffset( offset );
@ -1004,8 +1121,8 @@ void LIB_COMPONENT::SetOffset( const wxPoint& offset )
void LIB_COMPONENT::RemoveDuplicateDrawItems()
{
LibEDA_BaseStruct* DEntryRef;
LibEDA_BaseStruct* DEntryCompare;
LIB_DRAW_ITEM* DEntryRef;
LIB_DRAW_ITEM* DEntryCompare;
bool deleted;
DEntryRef = m_Drawings;
@ -1043,7 +1160,7 @@ void LIB_COMPONENT::RemoveDuplicateDrawItems()
bool LIB_COMPONENT::HasConversion() const
{
LibEDA_BaseStruct* entry;
LIB_DRAW_ITEM* entry;
for( entry = m_Drawings; entry != NULL; entry = entry->Next() )
{
@ -1055,37 +1172,149 @@ bool LIB_COMPONENT::HasConversion() const
}
/**
* 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 )
int LIB_COMPONENT::SelectItems( EDA_Rect& rect, int unit, int convert,
bool editPinByPin )
{
if( m_Doc.IsEmpty() && m_KeyWord.IsEmpty() && m_DocFile.IsEmpty() )
return true;
LIB_DRAW_ITEM* item;
int ItemsCount = 0;
/* Generation des lignes utiles */
if( fprintf( aFile, "#\n$CMP %s\n", CONV_TO_UTF8( m_Name.m_Text ) ) < 0 )
return false;
for( item = m_Drawings; item != NULL; item = item->Next() )
{
item->m_Selected = 0;
if( ! m_Doc.IsEmpty()
&& fprintf( aFile, "D %s\n", CONV_TO_UTF8( m_Doc ) ) < 0 )
return false;
if( ( item->m_Unit && item->m_Unit != unit )
|| ( item->m_Convert && item->m_Convert != convert ) )
{
if( item->Type() != COMPONENT_PIN_DRAW_TYPE )
continue;
if( ! m_KeyWord.IsEmpty()
&& fprintf( aFile, "K %s\n", CONV_TO_UTF8( m_KeyWord ) ) < 0 )
return false;
// Specific rules for pins.
if( editPinByPin || m_UnitSelectionLocked
|| ( item->m_Convert && item->m_Convert != convert ) )
continue;
}
if( ! m_DocFile.IsEmpty()
&& fprintf( aFile, "F %s\n", CONV_TO_UTF8( m_DocFile ) ) < 0 )
return false;
if( item->Inside( rect ) )
{
item->m_Selected = IS_SELECTED;
ItemsCount++;
}
}
if( fprintf( aFile, "$ENDCMP\n" ) < 0 )
return false;
if( m_Name.Inside( rect ) )
{
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:
CMP_LIB_ENTRY( LibrEntryType CmpType, const wxString& name,
CMP_LIBRARY* lib = NULL );
CMP_LIB_ENTRY( const CMP_LIB_ENTRY& entry, CMP_LIBRARY* lib = NULL );
virtual ~CMP_LIB_ENTRY();
virtual wxString GetClass() const
@ -123,7 +125,7 @@ public:
bool m_DrawPinNum;
bool m_DrawPinName;
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
public:
@ -134,6 +136,8 @@ public:
LIB_COMPONENT( const wxString& name, CMP_LIBRARY* lib = NULL );
LIB_COMPONENT( const LIB_COMPONENT& component, CMP_LIBRARY* lib = NULL );
~LIB_COMPONENT();
EDA_Rect GetBoundaryBox( int Unit, int Convert );
@ -207,7 +211,7 @@ public:
* @param panel - Panel 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,
wxDC* dc = NULL );
@ -244,6 +248,52 @@ public:
wxASSERT( name != NULL );
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:
LIB_ALIAS( const wxString& name, LIB_COMPONENT* root,
CMP_LIBRARY* lib = NULL );
LIB_ALIAS( const LIB_ALIAS& alias, CMP_LIBRARY* lib = NULL );
~LIB_ALIAS();
virtual wxString GetClass() const

View File

@ -10,10 +10,9 @@
#include "kicad_string.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
#include "class_libentry.h"
#include <wx/tokenzr.h>
#include <wx/stream.h>
@ -39,19 +38,35 @@
* others = free fields
*/
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_Size.x = m_Size.y = DEFAULT_SIZE_TEXT;
}
LibDrawField::LibDrawField( int idfield ) :
LibEDA_BaseStruct( COMPONENT_FIELD_DRAW_TYPE, NULL )
LIB_DRAW_ITEM( COMPONENT_FIELD_DRAW_TYPE, NULL )
{
m_FieldId = idfield;
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()
{
@ -358,13 +373,13 @@ bool LibDrawField::HitTest( wxPoint aPosRef, int aThreshold,
}
// Creation et Duplication d'un field
LibEDA_BaseStruct* LibDrawField::DoGenCopy()
LIB_DRAW_ITEM* LibDrawField::DoGenCopy()
{
LibDrawField* newfield = new LibDrawField( m_FieldId );
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 );
@ -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,
* i.e U -> U? or U?A or the field text for others
*
* @fixme This should be handled by the field object.
*/
wxString LibDrawField::GetFullText( void )
wxString LibDrawField::GetFullText( int unit )
{
if( m_FieldId != REFERENCE )
return m_Text;
@ -433,11 +454,11 @@ wxString LibDrawField::GetFullText( void )
{
#if defined(KICAD_GOST)
text.Printf( wxT( "%s?.%c" ),
m_Text.GetData(), CurrentUnit + '1' - 1 );
m_Text.GetData(), unit + '1' - 1 );
#else
text.Printf( wxT( "%s?%c" ),
m_Text.GetData(), CurrentUnit + 'A' - 1 );
m_Text.GetData(), unit + 'A' - 1 );
#endif
}
else

View File

@ -6,6 +6,9 @@
#define CLASS_LIBENTRY_FIELDS_H
#include "classes_body_items.h"
/* Fields , same as component fields.
* can be defined in libraries (mandatory for ref and value, ca be useful for
* footprints)
@ -15,7 +18,7 @@
* default value in schematic
*/
class LibDrawField : public LibEDA_BaseStruct,
class LibDrawField : public LIB_DRAW_ITEM,
public EDA_TextStruct
{
public:
@ -36,6 +39,7 @@ public:
LibDrawField( int idfield = 2 );
LibDrawField( LIB_COMPONENT * aParent, int idfield = 2 );
LibDrawField( const LibDrawField& field );
~LibDrawField();
virtual wxString GetClass() const
{
@ -103,13 +107,26 @@ public:
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:
virtual LibEDA_BaseStruct* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const;
virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; }
};
#endif // CLASS_LIBENTRY_FIELDS_H

View File

@ -11,7 +11,6 @@
#include "eda_doc.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
#include "class_library.h"
@ -197,7 +196,7 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* cmp )
{
wxASSERT( cmp != NULL );
LIB_COMPONENT* newCmp = CopyLibEntryStruct( cmp );
LIB_COMPONENT* newCmp = new LIB_COMPONENT( *cmp, this );
if( newCmp == NULL )
return NULL;
@ -387,7 +386,7 @@ in library <%s>." ),
RemoveEntry( oldComponent->GetName() );
LIB_COMPONENT* newCmp = CopyLibEntryStruct( newComponent );
LIB_COMPONENT* newCmp = new LIB_COMPONENT( *newComponent, this );
if( newCmp == 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;
wxFileName libFileName = FullFileName;
wxFileName backupFileName = FullFileName;
wxFileName docFileName = FullFileName;
/* the old .lib file is renamed .bak */
if( libFileName.FileExists() )
@ -723,24 +721,8 @@ bool CMP_LIBRARY::Save( const wxString& FullFileName )
if( !wxRenameFile( libFileName.GetFullPath(),
backupFileName.GetFullPath() ) )
{
msg = wxT( "Failed to rename old lib file " ) +
backupFileName.GetFullPath();
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 " ) +
libFileName.MakeAbsolute();
msg = wxT( "Failed to rename old component library file " ) +
backupFileName.GetFullPath();
DisplayError( NULL, msg );
}
@ -750,31 +732,22 @@ bool CMP_LIBRARY::Save( const wxString& FullFileName )
if( libfile == NULL )
{
libFileName.MakeAbsolute();
msg = wxT( "Failed to create component library file " ) +
libFileName.GetFullPath();
DisplayError( NULL, msg );
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;
/* Creation de l'entete de la librairie */
m_TimeStamp = GetTimeStamp();
SaveHeader( libfile );
/* Sauvegarde des composant: */
char Line[256];
fprintf( docfile, "%s Date: %s\n", DOCFILE_IDENT,
DateAndTime( Line ) );
if( !SaveHeader( libfile ) )
{
fclose( libfile );
return false;
}
bool success = true;
@ -783,21 +756,80 @@ bool CMP_LIBRARY::Save( const wxString& FullFileName )
if ( entry.Type == ROOT )
{
LIB_COMPONENT* component = ( LIB_COMPONENT* ) &entry;
if ( ! component->Save( libfile ) )
success = false;
}
if ( docfile )
{
if ( ! entry.SaveDoc( docfile ) )
if ( !component->Save( libfile ) )
success = false;
}
}
fprintf( libfile, "#\n#End Library\n" );
if ( docfile )
fprintf( docfile, "#\n#End Doc Library\n" );
if( fprintf( libfile, "#\n#End Library\n" ) < 0 )
success = false;
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 );
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;
}
@ -805,7 +837,7 @@ bool CMP_LIBRARY::Save( const wxString& FullFileName )
bool CMP_LIBRARY::SaveHeader( FILE* file )
{
char BufLine[1024];
bool succes = false;
bool succes = true;
DateAndTime( BufLine );
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;
}
if( USE_OLD_DOC_FILE_FORMAT( lib->m_verMajor, lib->m_verMinor ) )
lib->LoadDocs( errMsg );
return lib;

View File

@ -1,6 +1,6 @@
/***********************************/
/* Headers for library definition */
/***********************************/
/*********************************************/
/* Headers for component library definition */
/*********************************************/
#ifndef CLASS_LIBRARY_H
#define CLASS_LIBRARY_H
@ -8,6 +8,37 @@
#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. */
class CMP_LIBRARY;
@ -43,17 +74,35 @@ public:
/**
* Save library to file.
*
* Two files are created. The component objects are save as component
* library (*.lib) files. The alias objects are save as document
* definition (*.dcm) files. If the component library already exists,
* it is backup up in file *.bak. If the document definition file
* already exists, it is backed up in file *.bck.
* Prior to component library version 3.0, two files were created. The
* component objects are wer as component library (*.lib) files. The
* library entry ojbect document strings were save in library document
* definition (*.dcm) files. After version component library version 3.0,
* 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.
*
* @return bool - true if success writing else false.
*/
bool Save( const wxString& aFullFileName );
bool SaveDocFile( const wxString& FullFileName );
/**
* Load library from file.

View File

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

View File

@ -12,10 +12,10 @@
#include "plot_common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
#include "libeditfrm.h"
#include "class_libentry.h"
const wxChar* MsgPinElectricType[] =
@ -34,7 +34,7 @@ const wxChar* MsgPinElectricType[] =
};
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_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
* 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() );
@ -1059,11 +1079,11 @@ LibEDA_BaseStruct* LibDrawPin::DoGenCopy()
newpin->m_Width = m_Width;
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 );
@ -1087,6 +1107,12 @@ bool LibDrawPin::DoTestInside( EDA_Rect& rect )
}
void LibDrawPin::DoMove( const wxPoint& newPosition )
{
m_Pos = newPosition;
}
/** Function LibDrawPin::DisplayInfo
* Displays info (pin num and name, orientation ...
* on the Info window
@ -1096,7 +1122,7 @@ void LibDrawPin::DisplayInfo( WinEDA_DrawFrame* frame )
wxString Text;
int ii;
LibEDA_BaseStruct::DisplayInfo( frame );
LIB_DRAW_ITEM::DisplayInfo( frame );
/* Affichage du nom */
frame->MsgPanel->Affiche_1_Parametre( 30, _( "PinName" ), m_PinName,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,9 +11,9 @@
#include "bezier_curves.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
#include "classes_body_items.h"
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 */
LibEDA_BaseStruct::LibEDA_BaseStruct( KICAD_T struct_type,
LIB_COMPONENT* aParent ) :
LIB_DRAW_ITEM::LIB_DRAW_ITEM( KICAD_T struct_type, LIB_COMPONENT* aParent ) :
EDA_BaseStruct( struct_type )
{
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
* shape) 0 if the item is common to all shapes */
m_Fill = NO_FILL;
m_Parent = aParent;
m_Parent = (EDA_BaseStruct*) aParent;
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.
*
@ -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
* 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;
@ -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() )
&& ( m_Unit == other.m_Unit )
@ -84,7 +94,7 @@ bool LibEDA_BaseStruct::operator==( const LibEDA_BaseStruct& other ) const
/**********************/
LibDrawArc::LibDrawArc( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_ARC_DRAW_TYPE, aParent )
LIB_DRAW_ITEM( COMPONENT_ARC_DRAW_TYPE, aParent )
{
m_Radius = 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:
* 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() );
@ -249,11 +272,11 @@ LibEDA_BaseStruct* LibDrawArc::DoGenCopy()
newitem->m_Flags = m_Flags;
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 );
@ -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
* @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;
EDA_Rect bBox = GetBoundingBox();
LibEDA_BaseStruct::DisplayInfo( frame );
LIB_DRAW_ITEM::DisplayInfo( frame );
msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true );
@ -438,7 +470,7 @@ void LibDrawArc::DisplayInfo( WinEDA_DrawFrame* frame )
/*************************/
LibDrawCircle::LibDrawCircle( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_CIRCLE_DRAW_TYPE, aParent )
LIB_DRAW_ITEM( COMPONENT_CIRCLE_DRAW_TYPE, aParent )
{
m_Radius = 0;
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
{
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() );
@ -531,11 +572,11 @@ LibEDA_BaseStruct* LibDrawCircle::DoGenCopy()
newitem->m_Flags = m_Flags;
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 );
@ -561,6 +602,12 @@ bool LibDrawCircle::DoTestInside( EDA_Rect& rect )
}
void LibDrawCircle::DoMove( const wxPoint& newPosition )
{
m_Pos = newPosition;
}
/** Function GetPenSize
* @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;
EDA_Rect bBox = GetBoundingBox();
LibEDA_BaseStruct::DisplayInfo( frame );
LIB_DRAW_ITEM::DisplayInfo( frame );
msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true );
@ -646,7 +693,7 @@ void LibDrawCircle::DisplayInfo( WinEDA_DrawFrame* frame )
/*************************/
LibDrawSquare::LibDrawSquare( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_RECT_DRAW_TYPE, aParent )
LIB_DRAW_ITEM( COMPONENT_RECT_DRAW_TYPE, aParent )
{
m_Width = 0;
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
{
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() );
@ -701,11 +758,11 @@ LibEDA_BaseStruct* LibDrawSquare::DoGenCopy()
newitem->m_Flags = m_Flags;
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 );
@ -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
* @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;
LibEDA_BaseStruct::DisplayInfo( frame );
LIB_DRAW_ITEM::DisplayInfo( frame );
msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true );
@ -864,13 +929,22 @@ bool LibDrawSquare::HitTest( wxPoint aRefPoint, int aThreshold,
/** class LibDrawSegment **/
/**************************/
LibDrawSegment::LibDrawSegment( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_LINE_DRAW_TYPE, aParent )
LIB_DRAW_ITEM( COMPONENT_LINE_DRAW_TYPE, aParent )
{
m_Width = 0;
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
{
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() );
@ -897,11 +971,11 @@ LibEDA_BaseStruct* LibDrawSegment::DoGenCopy()
newitem->m_Convert = m_Convert;
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 );
@ -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
* @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;
EDA_Rect bBox = GetBoundingBox();
LibEDA_BaseStruct::DisplayInfo( frame );
LIB_DRAW_ITEM::DisplayInfo( frame );
msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true );
@ -1016,7 +1098,7 @@ bool LibDrawSegment::HitTest( wxPoint aPosRef, int aThreshold,
/** class LibDrawPolyline **/
/***************************/
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_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
{
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() );
@ -1117,11 +1208,11 @@ LibEDA_BaseStruct* LibDrawPolyline::DoGenCopy()
newitem->m_Flags = m_Flags;
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 );
@ -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 )
{
m_PolyPoints.push_back( point );
@ -1304,7 +1401,7 @@ void LibDrawPolyline::DisplayInfo( WinEDA_DrawFrame* frame )
wxString msg;
EDA_Rect bBox = GetBoundingBox();
LibEDA_BaseStruct::DisplayInfo( frame );
LIB_DRAW_ITEM::DisplayInfo( frame );
msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true );
@ -1321,7 +1418,7 @@ void LibDrawPolyline::DisplayInfo( WinEDA_DrawFrame* frame )
/** class LibDrawBezier **/
/***************************/
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_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
{
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());
@ -1420,11 +1527,11 @@ LibEDA_BaseStruct* LibDrawBezier::DoGenCopy()
newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags;
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 );
@ -1467,6 +1574,12 @@ bool LibDrawBezier::DoTestInside( EDA_Rect& rect )
}
void LibDrawBezier::DoMove( const wxPoint& newPosition )
{
DoOffset( newPosition - m_PolyPoints[0] );
}
/** Function GetPenSize
* @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;
EDA_Rect bBox = GetBoundingBox();
LibEDA_BaseStruct::DisplayInfo( frame );
LIB_DRAW_ITEM::DisplayInfo( frame );
msg = ReturnStringFromValue( g_UnitMetric, m_Width,
EESCHEMA_INTERNAL_UNIT, true );

View File

@ -7,6 +7,11 @@
#ifndef 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
* 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)
*/
class LibEDA_BaseStruct : public EDA_BaseStruct
class LIB_DRAW_ITEM : public EDA_BaseStruct
{
public:
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. */
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 );
virtual ~LibEDA_BaseStruct() { }
LIB_DRAW_ITEM( KICAD_T struct_type, LIB_COMPONENT * aParent );
LIB_DRAW_ITEM( const LIB_DRAW_ITEM& item );
virtual ~LIB_DRAW_ITEM() { }
/** Function Draw (virtual pure)
* Draw A body item
@ -182,22 +188,22 @@ public:
/**
* 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.
*
* @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.
*
* @return bool - True if object is identical to this object.
*/
bool operator==( const LibEDA_BaseStruct& other ) const;
bool operator==( const LibEDA_BaseStruct* other ) const
bool operator==( const LIB_DRAW_ITEM& other ) const;
bool operator==( const LIB_DRAW_ITEM* other ) const
{
return *this == *other;
}
@ -207,7 +213,7 @@ public:
*
* @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.
@ -221,24 +227,40 @@ public:
*/
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:
virtual LibEDA_BaseStruct* DoGenCopy() = 0;
virtual LIB_DRAW_ITEM* DoGenCopy() = 0;
/**
* Provide the draw object specific comparison.
*
* 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 bool DoTestInside( EDA_Rect& rect ) = 0;
virtual void DoMove( const wxPoint& newPosition ) = 0;
virtual wxPoint DoGetPosition( void ) = 0;
};
/********/
/* Pins */
/********/
class LibDrawPin : public LibEDA_BaseStruct
class LibDrawPin : public LIB_DRAW_ITEM
{
public:
int m_PinLen; /* Pin length */
@ -267,6 +289,7 @@ public:
public:
LibDrawPin(LIB_COMPONENT * aParent);
LibDrawPin( const LibDrawPin& pin );
~LibDrawPin() { }
LibDrawPin* Next() const { return (LibDrawPin*) Pnext; }
@ -358,10 +381,12 @@ public:
int aWidth);
protected:
virtual LibEDA_BaseStruct* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const;
virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset );
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 */
/**************************/
class LibDrawArc : public LibEDA_BaseStruct
class LibDrawArc : public LIB_DRAW_ITEM
{
public:
int m_Radius;
@ -383,6 +408,7 @@ public:
public:
LibDrawArc(LIB_COMPONENT * aParent);
LibDrawArc( const LibDrawArc& arc );
~LibDrawArc() { }
virtual wxString GetClass() const
{
@ -430,17 +456,19 @@ public:
virtual int GetPenSize( );
protected:
virtual LibEDA_BaseStruct* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const;
virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; }
};
/*****************************/
/* Graphic Body Item: Circle */
/*****************************/
class LibDrawCircle : public LibEDA_BaseStruct
class LibDrawCircle : public LIB_DRAW_ITEM
{
public:
int m_Radius;
@ -450,6 +478,7 @@ public:
public:
LibDrawCircle(LIB_COMPONENT * aParent);
LibDrawCircle( const LibDrawCircle& circle );
~LibDrawCircle() { }
virtual wxString GetClass() const
{
@ -498,10 +527,12 @@ public:
virtual void DisplayInfo( WinEDA_DrawFrame* frame );
protected:
virtual LibEDA_BaseStruct* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const;
virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset );
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, */
/* they are a separate class */
/*********************************************/
class LibDrawText : public LibEDA_BaseStruct, public EDA_TextStruct
class LibDrawText : public LIB_DRAW_ITEM, public EDA_TextStruct
{
public:
LibDrawText(LIB_COMPONENT * aParent);
LibDrawText( const LibDrawText& text );
~LibDrawText() { }
virtual wxString GetClass() const
{
@ -573,17 +605,19 @@ public:
virtual void DisplayInfo( WinEDA_DrawFrame* frame );
protected:
virtual LibEDA_BaseStruct* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const;
virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; }
};
/********************************/
/* Graphic Body Item: Rectangle */
/********************************/
class LibDrawSquare : public LibEDA_BaseStruct
class LibDrawSquare : public LIB_DRAW_ITEM
{
public:
wxPoint m_End; /* Rectangle end point. */
@ -592,6 +626,7 @@ public:
public:
LibDrawSquare(LIB_COMPONENT * aParent);
LibDrawSquare( const LibDrawSquare& rect );
~LibDrawSquare() { }
virtual wxString GetClass() const
{
@ -640,16 +675,18 @@ public:
virtual void DisplayInfo( WinEDA_DrawFrame* frame );
protected:
virtual LibEDA_BaseStruct* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const;
virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; }
};
/**********************************/
/* Graphic Body Item: single line */
/**********************************/
class LibDrawSegment : public LibEDA_BaseStruct
class LibDrawSegment : public LIB_DRAW_ITEM
{
public:
wxPoint m_End;
@ -659,6 +696,7 @@ public:
public:
LibDrawSegment(LIB_COMPONENT * aParent);
LibDrawSegment( const LibDrawSegment& segment );
~LibDrawSegment() { }
virtual wxString GetClass() const
{
@ -706,17 +744,19 @@ public:
virtual void DisplayInfo( WinEDA_DrawFrame* frame );
protected:
virtual LibEDA_BaseStruct* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const;
virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset );
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) */
/**********************************************************/
class LibDrawPolyline : public LibEDA_BaseStruct
class LibDrawPolyline : public LIB_DRAW_ITEM
{
public:
int m_Width; /* Line width */
@ -724,6 +764,7 @@ public:
public:
LibDrawPolyline(LIB_COMPONENT * aParent);
LibDrawPolyline( const LibDrawPolyline& polyline );
~LibDrawPolyline() { }
virtual wxString GetClass() const
@ -783,16 +824,18 @@ public:
virtual void DisplayInfo( WinEDA_DrawFrame* frame );
protected:
virtual LibEDA_BaseStruct* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const;
virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset );
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) */
/**********************************************************/
class LibDrawBezier : public LibEDA_BaseStruct
class LibDrawBezier : public LIB_DRAW_ITEM
{
public:
int m_Width; /* Line width */
@ -800,7 +843,8 @@ public:
std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
public:
LibDrawBezier(LIB_COMPONENT * aParent);
LibDrawBezier( LIB_COMPONENT * aParent );
LibDrawBezier( const LibDrawBezier& bezier );
~LibDrawBezier() { }
virtual wxString GetClass() const
@ -860,10 +904,12 @@ public:
virtual void DisplayInfo( WinEDA_DrawFrame* frame );
protected:
virtual LibEDA_BaseStruct* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const;
virtual LIB_DRAW_ITEM* DoGenCopy();
virtual bool DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset );
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

View File

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

View File

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

View File

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

View File

@ -5,12 +5,12 @@
#include "fctsys.h"
#include "gr_basic.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 "protos.h"
#include "class_library.h"
enum End_Type {
@ -392,7 +392,7 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
if( Entry == NULL )
break;
LibEDA_BaseStruct* DrawLibItem = Entry->m_Drawings;
LIB_DRAW_ITEM* DrawLibItem = Entry->m_Drawings;
for( ; DrawLibItem != NULL; DrawLibItem = DrawLibItem->Next() )
{
if( DrawLibItem->Type() != COMPONENT_PIN_DRAW_TYPE )

View File

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

View File

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

View File

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

View File

@ -9,10 +9,9 @@
#include "fctsys.h"
#include "appl_wxstruct.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.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 )
{
LibEDA_BaseStruct * CurrentItem = CurrentDrawItem;
LIB_DRAW_ITEM * CurrentItem = parent->GetDrawItem();
m_Parent = parent;
Create(parent, id, caption, pos, size, style);

View File

@ -16,12 +16,12 @@
#endif
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "confirm.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "class_libentry.h"
#include "libeditfrm.h"
////@begin includes
////@end includes
@ -104,7 +104,9 @@ bool WinEDA_CreateCmpDialog::Create( WinEDA_DrawFrame* parent, wxWindowID id, co
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_Prefix.m_Text = m_Reference->GetValue();
if ( m_PinNameInside->GetValue() == FALSE)

View File

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

View File

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

View File

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

View File

@ -10,10 +10,10 @@
#include "class_drawpanel.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
#include "libeditfrm.h"
#include "class_library.h"
#include "dialog_edit_libentry_fields_in_lib_base.h"
@ -101,12 +101,12 @@ private:
void WinEDA_LibeditFrame::InstallFieldsEditorDialog( wxCommandEvent& event )
{
if( m_currentComponent == NULL )
if( m_component == NULL )
return;
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();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -13,10 +13,10 @@
#include "class_drawpanel.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
#include "libeditfrm.h"
#include "class_libentry.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
*/
{
wxString Line;
wxString Line;
Line = m_TextValue->GetValue();
g_LastTextOrient = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ;
@ -165,12 +165,12 @@ wxString Line;
m_GraphicText->m_Orient = g_LastTextOrient;
if( g_FlDrawSpecificUnit )
m_GraphicText->m_Unit = CurrentUnit;
m_GraphicText->m_Unit = m_Parent->GetUnit();
else
m_GraphicText->m_Unit = 0;
if( g_FlDrawSpecificConvert )
m_GraphicText->m_Convert = CurrentConvert;
m_GraphicText->m_Convert = m_Parent->GetConvert();
else
m_GraphicText->m_Convert = 0;
@ -216,14 +216,14 @@ wxString Line;
}
Close();
if ( CurrentDrawItem )
CurrentDrawItem->DisplayInfo( m_Parent );
if ( m_Parent->GetDrawItem() )
m_Parent->GetDrawItem()->DisplayInfo( m_Parent );
Close();
}
void WinEDA_LibeditFrame::EditSymbolText(wxDC * DC, LibEDA_BaseStruct * DrawItem)
void WinEDA_LibeditFrame::EditSymbolText(wxDC* DC, LIB_DRAW_ITEM* DrawItem)
{
int DrawMode = g_XorMode;
@ -263,7 +263,7 @@ void WinEDA_LibeditFrame::RotateSymbolText(wxDC * DC)
90 deg Graphic text Rotation .
*/
{
LibDrawText * DrawItem = (LibDrawText *) CurrentDrawItem;
LibDrawText * DrawItem = (LibDrawText *) m_drawItem;
if( DrawItem == NULL )
return;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,12 +8,11 @@
#include "class_drawpanel.h"
#include "confirm.h"
#include "gestfich.h"
#include "program.h"
#include "general.h"
#include "bitmaps.h"
#include "eda_dde.h"
#include "libcmp.h"
#include "program.h"
#include "general.h"
#include "protos.h"
#include <wx/snglinst.h>
@ -65,7 +64,6 @@ HPGL_Pen_Descr_Struct g_HPGL_Pen_Descr;
//SCH_SCREEN * ScreenSch;
DrawSheetStruct* g_RootSheet = NULL;
SCH_SCREEN* g_ScreenLib = NULL;
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
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 } };

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,35 +6,6 @@
#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
{
LOCATE_COMPONENT_ARC_DRAW_TYPE = 1,
@ -49,19 +20,4 @@ enum LocateDrawStructType
#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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,6 +12,7 @@ class SCH_SCREEN;
class CMP_LIBRARY;
class LIB_COMPONENT;
class LIB_ALIAS;
class LIB_DRAW_ITEM;
/**
* The component library editor main window.
@ -39,6 +40,10 @@ public:
void CreateNewLibraryPart( wxCommandEvent& event );
void OnEditComponentProperties( 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 OnUpdateNotEditingPart( wxUpdateUIEvent& event );
@ -74,17 +79,51 @@ public:
void LoadSettings();
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:
// General:
void SaveOnePartInMemory();
void SelectActiveLibrary();
bool LoadOneLibraryPart();
void SaveActiveLibrary( wxCommandEvent& event );
bool LoadOneLibraryPartAux( CMP_LIB_ENTRY* LibEntry,
@ -109,26 +148,23 @@ private:
LibDrawPin* Pin );
void StartMovePin( wxDC* DC );
// Test des pins ( duplicates...)
bool TestPins( LIB_COMPONENT* LibEntry );
// Edition de l'ancre
void PlaceAncre();
// 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 StartMoveDrawSymbol( wxDC* DC );
void EndDrawGraphicItem( wxDC* DC );
void LoadOneSymbol();
void SaveOneSymbol();
void EditGraphicSymbol( wxDC* DC,
LibEDA_BaseStruct* DrawItem );
void EditSymbolText( wxDC* DC, LibEDA_BaseStruct* DrawItem );
LIB_DRAW_ITEM* DrawItem );
void EditSymbolText( wxDC* DC, LIB_DRAW_ITEM* DrawItem );
void RotateSymbolText( wxDC* DC );
void DeleteDrawPoly( wxDC* DC );
LibDrawField* LocateField( LIB_COMPONENT* LibEntry );
LibEDA_BaseStruct* LocateItemUsingCursor();
LIB_DRAW_ITEM* LocateItemUsingCursor();
void RotateField( wxDC* DC, LibDrawField* Field );
void PlaceField( wxDC* DC, LibDrawField* Field );
void EditField( wxDC* DC, LibDrawField* Field );
@ -152,7 +188,15 @@ protected:
wxString m_LastLibImportPath;
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()
};

View File

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

View File

@ -2,24 +2,20 @@
/* EESchema - libframe.cpp */
/****************************/
/* Gestion de la frame d'edition des composants en librairie
*/
#include "fctsys.h"
#include "appl_wxstruct.h"
#include "common.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "eda_doc.h"
#include "bitmaps.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "bitmaps.h"
#include "protos.h"
#include "eeschema_id.h"
#include "class_library.h"
#include "libeditfrm.h"
#include "class_library.h"
#include <boost/foreach.hpp>
@ -29,7 +25,7 @@ const wxString lastLibExportPathEntry( wxT( "LastLibraryExportPath" ) );
const wxString lastLibImportPathEntry( wxT( "LastLibraryImportPath" ) );
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
* source file in the project when adding IDs to include/id.h. */
int ExportPartId = ::wxNewId();
@ -37,7 +33,21 @@ int ImportPartId = ::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,
WinEDA_LibeditFrame::CreateNewLibraryPart )
EVT_TOOL( ID_LIBEDIT_SELECT_PART,
WinEDA_LibeditFrame::Process_Special_Functions )
WinEDA_LibeditFrame::LoadOneLibraryPart )
EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_PART,
WinEDA_LibeditFrame::Process_Special_Functions )
EVT_TOOL( ID_LIBEDIT_UNDO,
@ -70,13 +80,13 @@ BEGIN_EVENT_TABLE( WinEDA_LibeditFrame, WinEDA_DrawFrame )
EVT_TOOL( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS,
WinEDA_LibeditFrame::InstallFieldsEditorDialog )
EVT_TOOL( ID_LIBEDIT_CHECK_PART,
WinEDA_LibeditFrame::Process_Special_Functions )
WinEDA_LibeditFrame::OnCheckComponent )
EVT_TOOL( ID_DE_MORGAN_NORMAL_BUTT,
WinEDA_LibeditFrame::Process_Special_Functions )
WinEDA_LibeditFrame::OnSelectBodyStyle )
EVT_TOOL( ID_DE_MORGAN_CONVERT_BUTT,
WinEDA_LibeditFrame::Process_Special_Functions )
WinEDA_LibeditFrame::OnSelectBodyStyle )
EVT_TOOL( ID_LIBEDIT_VIEW_DOC,
WinEDA_LibeditFrame::Process_Special_Functions )
WinEDA_LibeditFrame::OnViewEntryDoc )
EVT_TOOL( ID_LIBEDIT_EDIT_PIN_BY_PIN,
WinEDA_LibeditFrame::Process_Special_Functions )
EVT_TOOL( ExportPartId, WinEDA_LibeditFrame::OnExportPart )
@ -147,7 +157,7 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father,
// Give an icon
SetIcon( wxIcon( libedit_xpm ) );
SetBaseScreen( g_ScreenLib );
SetBaseScreen( new SCH_SCREEN() );
GetScreen()->m_Center = true;
LoadSettings();
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
@ -159,7 +169,7 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father,
DisplayCmpDoc();
UpdateAliasSelectList();
UpdatePartSelectList();
BestZoom();
Zoom_Automatique( false );
Show( true );
}
@ -169,6 +179,7 @@ WinEDA_LibeditFrame::~WinEDA_LibeditFrame()
WinEDA_SchematicFrame* frame =
(WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
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
* settings will not get loaded.
*/
void WinEDA_LibeditFrame::LoadSettings( )
void WinEDA_LibeditFrame::LoadSettings()
{
wxConfig* cfg;
@ -248,41 +259,52 @@ void WinEDA_LibeditFrame::OnCloseWindow( wxCloseEvent& Event )
int WinEDA_LibeditFrame::BestZoom()
{
int dx, dy, ii, jj;
int bestzoom;
wxSize size;
EDA_Rect BoundaryBox;
if( m_currentComponent )
if( m_component )
{
BoundaryBox = m_currentComponent->GetBoundaryBox( CurrentUnit,
CurrentConvert );
BoundaryBox = m_component->GetBoundaryBox( m_unit, m_convert );
dx = BoundaryBox.GetWidth();
dy = BoundaryBox.GetHeight();
GetScreen()->m_Curseur = BoundaryBox.Centre();
}
else
{
dx = GetScreen()->m_CurrentSheetDesc->m_Size.x;
dy = GetScreen()->m_CurrentSheetDesc->m_Size.y;
GetScreen()->m_Curseur = wxPoint( 0, 0 );
}
size = DrawPanel->GetClientSize();
size -= wxSize( 100, 100 ); // reserve 100 mils margin
ii = abs( dx / size.x );
jj = abs( dy / size.y );
bestzoom = MAX( ii, jj ) + 1;
if( m_currentComponent )
/*
* This fixes a bug where the client size of the drawing area is not
* correctly reported until after the window is shown. This is most
* likely due to the unmanaged windows ( vertical tool bars and message
* panel ) that are drawn in the main window which wxWidgets knows
* nothing about. When the library editor is reopened with a component
* already loading, the zoom will be calculated correctly.
*/
if( !IsShownOnScreen() )
{
GetScreen()->m_Curseur = BoundaryBox.Centre();
if( m_clientSize != wxSize( -1, -1 ) )
size = m_clientSize;
else
size = DrawPanel->GetClientSize();
}
else
{
GetScreen()->m_Curseur.x = 0;
GetScreen()->m_Curseur.y = 0;
if( m_clientSize == wxSize( -1, -1 ) )
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();
if( m_currentComponent == NULL )
if( m_component == NULL )
return;
m_SelAliasBox->Append( m_currentComponent->GetName() );
m_SelAliasBox->Append( m_component->GetName() );
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 )
m_SelAliasBox->SetSelection( index );
@ -320,13 +342,13 @@ void WinEDA_LibeditFrame::UpdatePartSelectList()
if( m_SelpartBox->GetCount() != 0 )
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 );
}
else
{
for( int i = 0; i < m_currentComponent->m_UnitCount; i++ )
for( int i = 0; i < m_component->m_UnitCount; i++ )
{
wxString msg;
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 )
{
event.Enable( m_currentComponent != NULL );
event.Enable( m_component != NULL );
}
void WinEDA_LibeditFrame::OnUpdateNotEditingPart( wxUpdateUIEvent& event )
{
event.Enable( m_currentComponent == NULL );
event.Enable( m_component == NULL );
}
void WinEDA_LibeditFrame::OnUpdateUndo( wxUpdateUIEvent& event )
{
event.Enable( m_currentComponent != NULL && GetScreen() != NULL
event.Enable( m_component != NULL && GetScreen() != NULL
&& GetScreen()->GetUndoCommandCount() != 0 );
}
void WinEDA_LibeditFrame::OnUpdateRedo( wxUpdateUIEvent& event )
{
event.Enable( m_currentComponent != NULL && GetScreen() != NULL
event.Enable( m_component != NULL && GetScreen() != NULL
&& GetScreen()->GetRedoCommandCount() != 0 );
}
void WinEDA_LibeditFrame::OnUpdateSaveCurrentLib( wxUpdateUIEvent& event )
{
event.Enable( CurrentLib != NULL
&& ( CurrentLib->IsModified() || GetScreen()->IsModify() ) );
event.Enable( m_library != NULL
&& ( m_library->IsModified()|| GetScreen()->IsModify() ) );
}
@ -375,16 +397,16 @@ void WinEDA_LibeditFrame::OnUpdateViewDoc( wxUpdateUIEvent& event )
{
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 )
enable = !entry->m_DocFile.IsEmpty();
}
else if( !m_currentComponent->m_DocFile.IsEmpty() )
else if( !m_component->m_DocFile.IsEmpty() )
{
enable = true;
}
@ -396,9 +418,8 @@ void WinEDA_LibeditFrame::OnUpdateViewDoc( wxUpdateUIEvent& event )
void WinEDA_LibeditFrame::OnUpdatePinByPin( wxUpdateUIEvent& event )
{
event.Enable( ( m_currentComponent != NULL )
&& ( ( m_currentComponent->m_UnitCount > 1 )
|| g_AsDeMorgan ) );
event.Enable( ( m_component != NULL )
&& ( ( m_component->m_UnitCount > 1 ) || m_showDeMorgan ) );
if( m_HToolBar )
m_HToolBar->ToggleTool( event.GetId(), g_EditPinByPinIsOn );
@ -410,11 +431,11 @@ void WinEDA_LibeditFrame::OnUpdatePartNumber( wxUpdateUIEvent& event )
if( m_SelpartBox == NULL )
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.
*/
m_SelpartBox->Enable( m_currentComponent != NULL
&& m_currentComponent->m_UnitCount > 1 );
m_SelpartBox->Enable( m_component != NULL
&& m_component->m_UnitCount > 1 );
}
@ -423,9 +444,9 @@ void WinEDA_LibeditFrame::OnUpdateDeMorganNormal( wxUpdateUIEvent& event )
if( m_HToolBar == NULL )
return;
event.Enable( m_currentComponent != NULL
&& m_currentComponent->HasConversion() );
m_HToolBar->ToggleTool( event.GetId(), CurrentConvert <= 1 );
event.Enable( m_component != NULL
&& m_component->HasConversion() );
m_HToolBar->ToggleTool( event.GetId(), m_convert <= 1 );
}
@ -434,9 +455,9 @@ void WinEDA_LibeditFrame::OnUpdateDeMorganConvert( wxUpdateUIEvent& event )
if( m_HToolBar == NULL )
return;
event.Enable( m_currentComponent != NULL
&& m_currentComponent->HasConversion() );
m_HToolBar->ToggleTool( event.GetId(), CurrentConvert > 1 );
event.Enable( m_component != NULL
&& m_component->HasConversion() );
m_HToolBar->ToggleTool( event.GetId(), m_convert > 1 );
}
@ -445,26 +466,26 @@ void WinEDA_LibeditFrame::OnUpdateSelectAlias( wxUpdateUIEvent& event )
if( m_SelAliasBox == NULL )
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.
*/
m_SelAliasBox->Enable( m_currentComponent != NULL
&& !m_currentComponent->m_AliasList.IsEmpty() );
m_SelAliasBox->Enable( m_component != NULL
&& !m_component->m_AliasList.IsEmpty() );
}
void WinEDA_LibeditFrame::OnSelectAlias( wxCommandEvent& event )
{
if( m_SelAliasBox == NULL
|| m_SelAliasBox->GetStringSelection().CmpNoCase( CurrentAliasName ) == 0 )
|| m_SelAliasBox->GetStringSelection().CmpNoCase( m_aliasName ) == 0 )
return;
LibItemToRepeat = NULL;
m_lastDrawItem = NULL;
if( m_SelAliasBox->GetStringSelection().CmpNoCase(m_currentComponent->GetName() ) == 0 )
CurrentAliasName.Empty();
if( m_SelAliasBox->GetStringSelection().CmpNoCase(m_component->GetName() ) == 0 )
m_aliasName.Empty();
else
CurrentAliasName = m_SelAliasBox->GetStringSelection();
m_aliasName = m_SelAliasBox->GetStringSelection();
DisplayCmpDoc();
DrawPanel->Refresh();
@ -475,16 +496,56 @@ void WinEDA_LibeditFrame::OnSelectPart( wxCommandEvent& event )
{
int i = event.GetSelection();
if( ( i == wxNOT_FOUND ) || ( ( i + 1 ) == CurrentUnit ) )
if( ( i == wxNOT_FOUND ) || ( ( i + 1 ) == m_unit ) )
return;
LibItemToRepeat = NULL;
CurrentUnit = i + 1;
m_lastDrawItem = NULL;
m_unit = i + 1;
DrawPanel->Refresh();
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 )
{
int id = event.GetId();
@ -538,56 +599,10 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
SelectActiveLibrary();
break;
case ID_LIBEDIT_SELECT_PART:
LibItemToRepeat = NULL;
if( LoadOneLibraryPart() )
{
g_EditPinByPinIsOn = false;
GetScreen()->ClearUndoRedoList();
}
DrawPanel->Refresh();
break;
case ID_LIBEDIT_SAVE_CURRENT_PART:
SaveOnePartInMemory();
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:
g_EditPinByPinIsOn = g_EditPinByPinIsOn ? false : true;
break;
@ -597,13 +612,13 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_LIBEDIT_PIN_BUTT:
if( m_currentComponent )
if( m_component )
{
SetToolID( id, wxCURSOR_PENCIL, _( "Add Pin" ) );
SetToolID( id, wxCURSOR_PENCIL, _( "Add pin" ) );
}
else
{
SetToolID( id, wxCURSOR_ARROW, _( "Set Pin Options" ) );
SetToolID( id, wxCURSOR_ARROW, _( "Set pin options" ) );
InstallPineditFrame( this, &dc, pos );
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
}
@ -621,27 +636,27 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_LIBEDIT_BODY_TEXT_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add Text" ) );
SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
break;
case ID_LIBEDIT_BODY_RECT_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add Rectangle" ) );
SetToolID( id, wxCURSOR_PENCIL, _( "Add rectangle" ) );
break;
case ID_LIBEDIT_BODY_CIRCLE_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add Circle" ) );
SetToolID( id, wxCURSOR_PENCIL, _( "Add circle" ) );
break;
case ID_LIBEDIT_BODY_ARC_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add Arc" ) );
SetToolID( id, wxCURSOR_PENCIL, _( "Add arc" ) );
break;
case ID_LIBEDIT_BODY_LINE_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add Line" ) );
SetToolID( id, wxCURSOR_PENCIL, _( "Add line" ) );
break;
case ID_LIBEDIT_ANCHOR_ITEM_BUTT:
SetToolID( id, wxCURSOR_HAND, _( "Anchor" ) );
SetToolID( id, wxCURSOR_HAND, _( "Set anchor position" ) );
break;
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:
DrawPanel->MouseToCursorSchema();
if( CurrentDrawItem )
if( m_drawItem )
{
EndDrawGraphicItem( &dc );
}
break;
case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM:
if( CurrentDrawItem )
if( m_drawItem )
{
DrawPanel->CursorOff( &dc );
switch( CurrentDrawItem->Type() )
switch( m_drawItem->Type() )
{
case COMPONENT_ARC_DRAW_TYPE:
case COMPONENT_CIRCLE_DRAW_TYPE:
case COMPONENT_RECT_DRAW_TYPE:
case COMPONENT_POLYLINE_DRAW_TYPE:
case COMPONENT_LINE_DRAW_TYPE:
EditGraphicSymbol( &dc, CurrentDrawItem );
EditGraphicSymbol( &dc, m_drawItem );
break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
EditSymbolText( &dc, CurrentDrawItem );
EditSymbolText( &dc, m_drawItem );
break;
default:
@ -693,7 +708,7 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_LIBEDIT_DELETE_ITEM_BUTT:
if( m_currentComponent == NULL )
if( m_component == NULL )
{
wxBell();
break;
@ -704,79 +719,78 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT:
// Delete the last created segment, while creating a polyline draw item
if( CurrentDrawItem == NULL )
if( m_drawItem == NULL )
break;
DrawPanel->MouseToCursorSchema();
DeleteDrawPoly( &dc );
break;
case ID_POPUP_LIBEDIT_DELETE_ITEM:
if( CurrentDrawItem == NULL )
if( m_drawItem == NULL )
break;
DrawPanel->MouseToCursorSchema();
DrawPanel->CursorOff( &dc );
SaveCopyInUndoList( m_currentComponent );
if( CurrentDrawItem->Type() == COMPONENT_PIN_DRAW_TYPE )
SaveCopyInUndoList( m_component );
if( m_drawItem->Type() == COMPONENT_PIN_DRAW_TYPE )
{
DeletePin( &dc, m_currentComponent, (LibDrawPin*) CurrentDrawItem );
DeletePin( &dc, m_component, (LibDrawPin*) m_drawItem );
}
else
{
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
else
m_currentComponent->RemoveDrawItem( CurrentDrawItem, DrawPanel,
&dc );
m_component->RemoveDrawItem( m_drawItem, DrawPanel, &dc );
}
CurrentDrawItem = NULL;
m_drawItem = NULL;
GetScreen()->SetModify();
DrawPanel->CursorOn( &dc );
break;
case ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST:
if( CurrentDrawItem == NULL )
if( m_drawItem == NULL )
break;
DrawPanel->MouseToCursorSchema();
if( CurrentDrawItem->Type() == COMPONENT_PIN_DRAW_TYPE )
if( m_drawItem->Type() == COMPONENT_PIN_DRAW_TYPE )
StartMovePin( &dc );
else if( CurrentDrawItem->Type() == COMPONENT_FIELD_DRAW_TYPE )
StartMoveField( &dc, (LibDrawField*) CurrentDrawItem );
else if( m_drawItem->Type() == COMPONENT_FIELD_DRAW_TYPE )
StartMoveField( &dc, (LibDrawField*) m_drawItem );
else
StartMoveDrawSymbol( &dc );
break;
case ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT:
if( CurrentDrawItem == NULL )
if( m_drawItem == NULL )
break;
DrawPanel->CursorOff( &dc );
DrawPanel->MouseToCursorSchema();
if( (CurrentDrawItem->m_Flags & IS_NEW) == 0 )
SaveCopyInUndoList( m_currentComponent );
if( (m_drawItem->m_Flags & IS_NEW) == 0 )
SaveCopyInUndoList( m_component );
RotateSymbolText( &dc );
DrawPanel->CursorOn( &dc );
break;
case ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM:
if( CurrentDrawItem == NULL )
if( m_drawItem == NULL )
break;
DrawPanel->CursorOff( &dc );
DrawPanel->MouseToCursorSchema();
if( CurrentDrawItem->Type() == COMPONENT_FIELD_DRAW_TYPE )
if( m_drawItem->Type() == COMPONENT_FIELD_DRAW_TYPE )
{
SaveCopyInUndoList( m_currentComponent );
RotateField( &dc, (LibDrawField*) CurrentDrawItem );
SaveCopyInUndoList( m_component );
RotateField( &dc, (LibDrawField*) m_drawItem );
}
DrawPanel->CursorOn( &dc );
break;
case ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM:
if( CurrentDrawItem == NULL )
if( m_drawItem == NULL )
break;
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->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_PINNAMESIZE_ITEM:
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
if( (CurrentDrawItem == NULL )
|| (CurrentDrawItem->Type() != COMPONENT_PIN_DRAW_TYPE) )
if( (m_drawItem == NULL )
|| (m_drawItem->Type() != COMPONENT_PIN_DRAW_TYPE) )
break;
SaveCopyInUndoList( m_currentComponent );
GlobalSetPins( &dc, (LibDrawPin*) CurrentDrawItem, id );
SaveCopyInUndoList( m_component );
GlobalSetPins( &dc, (LibDrawPin*) m_drawItem, id );
DrawPanel->MouseToCursorSchema();
break;
@ -842,5 +856,5 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->m_IgnoreMouseEvents = false;
if( m_ID_current_state == 0 )
LibItemToRepeat = NULL;
m_lastDrawItem = NULL;
}

View File

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

View File

@ -5,16 +5,19 @@
#include "fctsys.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "trigo.h"
#include "macros.h"
#include "class_marker_sch.h"
#include "libcmp.h"
#include "general.h"
#include "class_marker_sch.h"
#include "protos.h"
#include "class_library.h"
/* 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 bool IsBox1InBox2( int StartX1, int StartY1, int EndX1, int EndY1,
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,
LIB_COMPONENT* LibEntry,
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.
*/
{
LibEDA_BaseStruct* DrawItem;
LIB_DRAW_ITEM* DrawItem;
if( LibEntry == NULL )
return NULL;
@ -717,7 +720,7 @@ LibDrawPin* LocatePinByNumber( const wxString& ePin_Number,
* @return a pointer on the pin, or NULL if not found
*/
{
LibEDA_BaseStruct* DrawItem;
LIB_DRAW_ITEM* DrawItem;
LIB_COMPONENT* Entry;
LibDrawPin* Pin;
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 )
/*******************************************************************/
@ -779,7 +782,7 @@ LibEDA_BaseStruct* LocatePin( const wxPoint& RefPos, LIB_COMPONENT* Entry,
return NULL;
}
LibEDA_BaseStruct* DrawItem = Entry->m_Drawings;
LIB_DRAW_ITEM* DrawItem = Entry->m_Drawings;
for( ; DrawItem != NULL; DrawItem = DrawItem->Next() )
{
if( DrawItem->Type() == COMPONENT_PIN_DRAW_TYPE ) /* Pin Trouvee */

View File

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

View File

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

View File

@ -4,15 +4,16 @@
#include "fctsys.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 "protos.h"
#include "class_library.h"
#include "algorithm"
// Buffer to build the list of items used in netlist and erc calculations
NETLIST_OBJECT_LIST g_NetObjectslist;
@ -354,7 +355,7 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist,
NETLIST_OBJECT* new_item;
SCH_COMPONENT* DrawLibItem;
LIB_COMPONENT* Entry;
LibEDA_BaseStruct* DEntry;
LIB_DRAW_ITEM* DEntry;
Hierarchical_PIN_Sheet_Struct* SheetLabel;
DrawSheetPath list;

View File

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

View File

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

View File

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

View File

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

View File

@ -8,18 +8,20 @@
#include "appl_wxstruct.h"
#include "common.h"
#include "class_drawpanel.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "class_marker_sch.h"
#include "protos.h"
/* Exported Functions */
void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveVector );
void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& aMirrorPoint );
void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList );
void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveVector );
void DeleteItemsInList( WinEDA_DrawPanel* panel,
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;
int accept = TRUE;
if ( ( CurrentDrawItem == NULL )
|| ( CurrentDrawItem->Type() == COMPONENT_PIN_DRAW_TYPE ) )
if ( ( parent->GetDrawItem() == NULL )
|| ( parent->GetDrawItem()->Type() == COMPONENT_PIN_DRAW_TYPE ) )
{
LibDrawPin * Pin = (LibDrawPin *) CurrentDrawItem;
LibDrawPin * Pin = (LibDrawPin *) parent->GetDrawItem();
WinEDA_PinPropertiesFrame dlg( parent );
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 )
{
LibDrawPin * CurrentPin = (LibDrawPin *) CurrentDrawItem;
LibDrawPin * CurrentPin = (LibDrawPin *) parent->GetDrawItem();
m_Parent = parent;
if ( CurrentPin )
@ -326,7 +326,7 @@ void WinEDA_PinPropertiesFrame::SetValuesInDialog(void)
/*******************************************************/
{
wxString number;
LibDrawPin * CurrentPin = (LibDrawPin *) CurrentDrawItem;
LibDrawPin * CurrentPin = (LibDrawPin *) m_Parent->GetDrawItem();
wxString msg;
int tmp, ii;

View File

@ -7,6 +7,7 @@
#include "program.h"
#include "libeditfrm.h"
#include "eeschema_id.h"
#include "class_libentry.h"
#include "pinedit-dialog.h"
@ -33,7 +34,8 @@ int CodeShape[NBSHAPES] =
/* 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 DrawMovePin( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
@ -82,50 +84,52 @@ void WinEDA_PinPropertiesFrame::PinPropertiesAccept( wxCommandEvent& event )
LastPinNumSize = ReturnValueFromString( g_UnitMetric, msg,
m_Parent->m_InternalUnits );
if( CurrentDrawItem ) // Set Pin Name & Num
{
if( !(CurrentDrawItem->m_Flags & IS_NEW) ) // if IS_NEW, copy for undo is done before place
m_Parent->SaveCopyInUndoList( CurrentDrawItem->GetParent() );
LIB_DRAW_ITEM* item = m_Parent->GetDrawItem();
if( item == NULL )
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 );
msg = m_PinNumCtrl->GetValue();
if( msg.IsEmpty() )
msg = wxT( "~" );
SetPinNum( msg, LastPinNumSize );
NewSizePin( LastPinSize );
SetPinShape( LastPinShape );
SetPinType( LastPinType );
SetPinOrient( LastPinOrient );
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();
}
/*********************************************/
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:
* 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
* 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* CurrentPin = (LibDrawPin*) CurrentDrawItem;
LibDrawPin* CurrentPin = (LibDrawPin*) m_drawItem;
if( m_currentComponent == NULL )
return;
if( CurrentPin == NULL )
if( m_component == NULL || CurrentPin == NULL )
return;
/* 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() )
{
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.
*/
{
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 ) )
CurrentPin->GetParent()->RemoveDrawItem( CurrentPin, Panel, DC );
/* clear edit flags */
LibEDA_BaseStruct* item = CurrentPin->GetParent()->m_Drawings;
LIB_DRAW_ITEM* item = CurrentPin->GetParent()->m_Drawings;
for( ; item != NULL; item = item->Next() )
item->m_Flags = 0;
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
CurrentDrawItem = NULL;
LibItemToRepeat = NULL;
parent->SetDrawItem( NULL );
parent->SetLastDrawItem( NULL );
Panel->Refresh( true );
}
@ -177,7 +186,7 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC )
/* Routine de fin de deplacement de la pin selectionnee */
{
LibDrawPin* Pin;
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem;
LibDrawPin* CurrentPin = (LibDrawPin*) m_drawItem;
bool ask_for_pin = true;
wxPoint newpos;
bool status;
@ -188,7 +197,7 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC )
newpos.x = GetScreen()->m_Curseur.x;
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:
for( ; Pin != NULL; Pin = Pin->Next() )
@ -224,12 +233,13 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC )
LastPinOrient = CurrentPin->m_Orient;
LastPinType = CurrentPin->m_PinType;
LastPinShape = CurrentPin->m_PinShape;
CreateImagePins( CurrentPin );
LibItemToRepeat = CurrentPin;
CreateImagePins( CurrentPin, m_unit, m_convert,
m_showDeMorgan );
m_lastDrawItem = CurrentPin;
}
/* 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() )
{
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
@ -246,7 +256,7 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC )
&showPinText, DefaultTransformMatrix );
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*/
{
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem;
LibDrawPin* CurrentPin = (LibDrawPin*) m_Parent->GetDrawItem();
LibDrawPin* Pin, * RefPin = CurrentPin;
if( CurrentPin == NULL || CurrentPin->GetParent() == NULL )
@ -289,11 +299,11 @@ void WinEDA_LibeditFrame::StartMovePin( wxDC* DC )
*/
{
LibDrawPin* Pin;
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem;
LibDrawPin* CurrentPin = (LibDrawPin*) m_drawItem;
wxPoint startPos;
/* Marquage des pins a traiter */
Pin = (LibDrawPin*) m_currentComponent->m_Drawings;
Pin = (LibDrawPin*) m_component->m_Drawings;
for( ; Pin != NULL; Pin = Pin->Next() )
{
Pin->m_Flags = 0;
@ -330,7 +340,12 @@ void WinEDA_LibeditFrame::StartMovePin( wxDC* DC )
/******************************************************************************/
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;
bool showPinText = true;
@ -367,7 +382,7 @@ void WinEDA_PinPropertiesFrame::SetPinShape( int newshape )
*/
{
LibDrawPin* Pin;
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem;
LibDrawPin* CurrentPin = (LibDrawPin*) m_Parent->GetDrawItem();
if( CurrentPin )
{
@ -400,7 +415,7 @@ void WinEDA_PinPropertiesFrame::SetPinType( int newtype )
*/
{
LibDrawPin* Pin;
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem;
LibDrawPin* CurrentPin = (LibDrawPin*) m_Parent->GetDrawItem();
if( CurrentPin == NULL || CurrentPin->GetParent() == NULL )
return;
@ -430,7 +445,7 @@ void WinEDA_PinPropertiesFrame::SetPinName( const wxString& newname, int newsize
*/
{
LibDrawPin* Pin;
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem;
LibDrawPin* CurrentPin = (LibDrawPin*) m_Parent->GetDrawItem();
wxString buf;
if( CurrentPin == NULL || CurrentPin->GetParent() == NULL )
@ -473,7 +488,7 @@ void WinEDA_PinPropertiesFrame::SetPinNum( const wxString& newnum, int newsize )
*/
{
LibDrawPin* Pin;
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem;
LibDrawPin* CurrentPin = (LibDrawPin*) m_Parent->GetDrawItem();
wxString buf;
buf = newnum;
@ -517,14 +532,14 @@ void WinEDA_LibeditFrame::DeletePin( wxDC* DC,
* Sinon seule la pin de l'unite en convert courante sera effacee
*/
{
LibEDA_BaseStruct* DrawItem;
LIB_DRAW_ITEM* DrawItem;
wxPoint PinPos;
if( LibEntry == NULL || Pin == NULL )
return;
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 */
if( g_EditPinByPinIsOn == false )
@ -541,7 +556,7 @@ void WinEDA_LibeditFrame::DeletePin( wxDC* DC,
DrawItem = DrawItem->Next();
if( Pin->m_Pos != PinPos )
continue;
LibEntry->RemoveDrawItem( (LibEDA_BaseStruct*) Pin );
LibEntry->RemoveDrawItem( (LIB_DRAW_ITEM*) Pin );
}
}
GetScreen()->SetModify();
@ -553,26 +568,26 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC )
/*********************************************/
/* Creation d'une nouvelle pin */
{
LibEDA_BaseStruct* DrawItem;
LIB_DRAW_ITEM* DrawItem;
LibDrawPin* CurrentPin;
bool showPinText = true;
if( m_currentComponent == NULL )
if( m_component == NULL )
return;
/* Effacement des flags */
DrawItem = m_currentComponent->m_Drawings;
DrawItem = m_component->m_Drawings;
for( ; DrawItem != NULL; DrawItem = DrawItem->Next() )
DrawItem->m_Flags = 0;
CurrentPin = new LibDrawPin(m_currentComponent);
CurrentPin = new LibDrawPin(m_component);
CurrentDrawItem = CurrentPin;
m_drawItem = CurrentPin;
if( CurrentPin == NULL )
return;
CurrentPin->m_Flags = IS_NEW;
CurrentPin->m_Unit = CurrentUnit;
CurrentPin->m_Convert = CurrentConvert;
CurrentPin->m_Unit = m_unit;
CurrentPin->m_Convert = m_convert;
/* Marquage des pins a traiter */
if( g_EditPinByPinIsOn == false )
@ -589,19 +604,19 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC )
if( LastPinCommonConvert )
CurrentPin->m_Convert = 0;
else
CurrentPin->m_Convert = CurrentConvert;
CurrentPin->m_Convert = m_convert;
if( LastPinCommonUnit )
CurrentPin->m_Unit = 0;
else
CurrentPin->m_Unit = CurrentUnit;
CurrentPin->m_Unit = m_unit;
if( LastPinNoDraw )
CurrentPin->m_Attributs |= PINNOTDRAW;
else
CurrentPin->m_Attributs &= ~PINNOTDRAW;
CurrentPin->SetNext( m_currentComponent->m_Drawings );
m_currentComponent->m_Drawings = CurrentPin;
m_currentComponent->SortDrawItems();
CurrentPin->SetNext( m_component->m_Drawings );
m_component->m_Drawings = CurrentPin;
m_component->SortDrawItems();
if( DC )
CurrentPin->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
@ -641,8 +656,8 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw,
*
*/
{
LibEDA_BaseStruct* DrawItem;
LibDrawPin* Pin, * CurrentPin = (LibDrawPin*) CurrentDrawItem;
LIB_DRAW_ITEM* DrawItem;
LibDrawPin* Pin, * CurrentPin = (LibDrawPin*) m_Parent->GetDrawItem();
if( CurrentPin == NULL )
return;
@ -654,7 +669,7 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw,
if( LastPinCommonUnit )
CurrentPin->m_Unit = 0;
else
CurrentPin->m_Unit = CurrentUnit;
CurrentPin->m_Unit = m_Parent->GetUnit();
Pin = (LibDrawPin*) CurrentPin->GetParent()->m_Drawings;
@ -679,7 +694,7 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw,
if( Pin->m_Orient != CurrentPin->m_Orient )
continue;
CurrentPin->GetParent()->RemoveDrawItem( (LibEDA_BaseStruct*) Pin );
CurrentPin->GetParent()->RemoveDrawItem( (LIB_DRAW_ITEM*) Pin );
}
}
} // end if unit
@ -689,7 +704,7 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw,
if( LastPinCommonConvert )
CurrentPin->m_Convert = 0;
else
CurrentPin->m_Convert = CurrentConvert;
CurrentPin->m_Convert = m_Parent->GetConvert();
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 )
continue;
CurrentPin->GetParent()->RemoveDrawItem( (LibEDA_BaseStruct*) Pin );
CurrentPin->GetParent()->RemoveDrawItem( (LIB_DRAW_ITEM*) Pin );
}
}
} // 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 )
return;
@ -778,13 +793,8 @@ void WinEDA_PinPropertiesFrame::NewSizePin( int newsize )
}
/********************************************/
static void CreateImagePins( LibDrawPin* Pin )
/********************************************/
/* Creation des autres pins pour les autres unites et pour convert, apres
* creation d'une pin
*/
static void CreateImagePins( LibDrawPin* Pin, int unit, int convert,
bool asDeMorgan )
{
int ii;
LibDrawPin* NewPin;
@ -794,7 +804,7 @@ static void CreateImagePins( LibDrawPin* Pin )
if( g_EditPinByPinIsOn )
return;
if( g_AsDeMorgan && ( Pin->m_Convert != 0 ) )
if( asDeMorgan && ( Pin->m_Convert != 0 ) )
CreateConv = true;
/* 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++ )
{
if( ii == CurrentUnit || Pin->m_Unit == 0 )
if( ii == unit || Pin->m_Unit == 0 )
continue; /* Pin commune a toutes les unites */
/* Creation pour la representation "normale" */
NewPin = (LibDrawPin*) Pin->GenCopy();
if( CurrentConvert != 0 )
if( convert != 0 )
NewPin->m_Convert = 1;
NewPin->m_Unit = ii;
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 showPinText = true;
if( ( m_currentComponent == NULL ) || ( MasterPin == NULL ) )
if( ( m_component == NULL ) || ( MasterPin == NULL ) )
return;
if( MasterPin->Type() != COMPONENT_PIN_DRAW_TYPE )
return;
GetScreen()->SetModify();
Pin = (LibDrawPin*) m_currentComponent->m_Drawings;
Pin = (LibDrawPin*) m_component->m_Drawings;
for( ; Pin != NULL; Pin = Pin->Next() )
{
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
continue;
if( ( Pin->m_Convert ) && ( Pin->m_Convert != CurrentConvert ) )
if( ( Pin->m_Convert ) && ( Pin->m_Convert != m_convert ) )
continue;
// Is it the "selected mode" ?
@ -904,13 +914,13 @@ void WinEDA_LibeditFrame::RepeatPinItem( wxDC* DC, LibDrawPin* SourcePin )
wxString msg;
int ox = 0, oy = 0;
if( m_currentComponent == NULL || SourcePin == NULL
if( m_component == NULL || SourcePin == NULL
|| SourcePin->Type() != COMPONENT_PIN_DRAW_TYPE )
return;
Pin = (LibDrawPin*)SourcePin->GenCopy();
Pin->SetNext( m_currentComponent->m_Drawings );
m_currentComponent->m_Drawings = Pin;
Pin->SetNext( m_component->m_Drawings );
m_component->m_Drawings = Pin;
Pin->m_Flags = IS_NEW;
Pin->m_Pos.x += g_RepeatStep.x;
@ -924,7 +934,7 @@ void WinEDA_LibeditFrame::RepeatPinItem( wxDC* DC, LibDrawPin* SourcePin )
IncrementLabelMember( msg );
Pin->SetPinNumFromString( msg );
CurrentDrawItem = Pin;
m_drawItem = Pin;
/* Marquage des pins a traiter */
if( g_EditPinByPinIsOn == false )
@ -954,22 +964,18 @@ int sort_by_pin_number( const void* ref, const void* tst )
}
/***************************************************************/
bool WinEDA_LibeditFrame::TestPins( LIB_COMPONENT* LibEntry )
/***************************************************************/
// Test des pins ( duplicates...)
void WinEDA_LibeditFrame::OnCheckComponent( wxCommandEvent& event )
{
int nb_pins, ii, error;
LibDrawPin* Pin;
LibDrawPin** PinList;
wxString msg;
if( m_currentComponent == NULL )
return false;
if( m_component == NULL )
return;
// 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() )
{
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*) );
Pin = (LibDrawPin*) m_currentComponent->m_Drawings;
Pin = (LibDrawPin*) m_component->m_Drawings;
for( ii = 0; Pin != NULL; Pin = Pin->Next() )
{
if( Pin->Type() == COMPONENT_PIN_DRAW_TYPE )
@ -995,39 +1001,42 @@ bool WinEDA_LibeditFrame::TestPins( LIB_COMPONENT* LibEntry )
LibDrawPin* curr_pin = PinList[ii];
Pin = PinList[ii - 1];
if( Pin->m_PinNum != curr_pin->m_PinNum )
continue;
if( Pin->m_Convert != curr_pin->m_Convert )
continue;
if( Pin->m_Unit != curr_pin->m_Unit )
if( Pin->m_PinNum != curr_pin->m_PinNum
|| Pin->m_Convert != curr_pin->m_Convert
|| Pin->m_Unit != curr_pin->m_Unit )
continue;
error++;
curr_pin->ReturnPinStringNum( StringPinNum );
msg.Printf( _( "Duplicate Pin %4.4s (Pin %s loc %d, %d, and Pin %s loc %d, %d)" ),
StringPinNum.GetData(), curr_pin->m_PinName.GetData(),
msg.Printf( _( "Duplicate pin %s at location (%d, %d) conflicts \
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,
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;
}
if( g_AsDeMorgan )
if( m_showDeMorgan )
{
if( curr_pin->m_Convert )
msg += _( " Convert" );
msg += _( " of converion" );
else
msg += _( " Normal" );
msg += _( " of normal" );
}
msg += wxT( "." );
DisplayError( this, msg );
}
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 "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
#include "class_library.h"
/* Local Variables : */
static void Plot_Hierarchical_PIN_Sheet( PLOTTER* plotter,
@ -64,7 +65,7 @@ static void PlotLibPart( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem )
Multi = DrawLibItem->m_Multi;
convert = DrawLibItem->m_Convert;
for( LibEDA_BaseStruct* DEntry = Entry->m_Drawings;
for( LIB_DRAW_ITEM* DEntry = Entry->m_Drawings;
DEntry != NULL; DEntry = DEntry->Next() )
{
/* Elimination des elements non relatifs a l'unite */

View File

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

View File

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

View File

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

View File

@ -2,7 +2,26 @@
/* 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,
int Unit,
int Convert,
@ -139,7 +158,7 @@ SCH_ITEM* PickStruct( const wxPoint& refpos,
int SearchMask );
LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
LIB_DRAW_ITEM* LocateDrawItem( SCH_SCREEN* Screen,
const wxPoint& refpoint,
LIB_COMPONENT* LibEntry,
int Unit,
@ -198,17 +217,6 @@ int CountCmpNumber();
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 */
/**************/
@ -352,3 +360,5 @@ void DisplayOptionFrame( WinEDA_SchematicFrame* parent,
/* CONTROLE.CPP */
/****************/
void RemoteCommand( const char* cmdline );
#endif /* __PROTOS_H__ */

View File

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

View File

@ -8,11 +8,10 @@
#include "confirm.h"
#include "kicad_string.h"
#include "gestfich.h"
#include "macros.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "macros.h"
#include "protos.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 "confirm.h"
#include "eda_doc.h"
#include "class_marker_sch.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "eeschema_id.h"
#include "protos.h"
#include "class_library.h"
/*****************************************************************************

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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