Commit 441efc9f authored by charras's avatar charras

Bugs and problems solved in fields edition (some are windows only)

parent 23748be6
...@@ -11,7 +11,9 @@ email address. ...@@ -11,7 +11,9 @@ email address.
++Eeschema: ++Eeschema:
Note: this is a work in progress! Note: this is a work in progress!
Files modification. Files modification.
More about italic andf bold in fileds in libraries More about italic and bold fields in libraries
Use DLIST to handle fields in lib entries
Bugs and problems solved in fields edition (some are windows only).
2008-Dec-30 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2008-Dec-30 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
/**********************************************************/ /**********************************************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h"
#include "common.h" #include "common.h"
#include "program.h" #include "program.h"
...@@ -87,8 +86,6 @@ EDA_LibComponentStruct:: EDA_LibComponentStruct( const wxChar* CmpName ) : ...@@ -87,8 +86,6 @@ EDA_LibComponentStruct:: EDA_LibComponentStruct( const wxChar* CmpName ) :
m_Options = ENTRY_NORMAL; m_Options = ENTRY_NORMAL;
m_UnitSelectionLocked = FALSE; m_UnitSelectionLocked = FALSE;
m_DrawPinNum = m_DrawPinName = 1; m_DrawPinNum = m_DrawPinName = 1;
Fields = NULL;
m_Prefix.m_FieldId = REFERENCE; m_Prefix.m_FieldId = REFERENCE;
} }
...@@ -98,15 +95,6 @@ EDA_LibComponentStruct::~EDA_LibComponentStruct() ...@@ -98,15 +95,6 @@ EDA_LibComponentStruct::~EDA_LibComponentStruct()
/******************************************************/ /******************************************************/
{ {
LibEDA_BaseStruct* DrawItem, * NextDrawItem; LibEDA_BaseStruct* DrawItem, * NextDrawItem;
LibDrawField* TempField, * field;
field = Fields; Fields = NULL;
while( field )
{
TempField = field;
field = field->Next();
SAFE_DELETE( TempField );
}
/* suppression des elements dependants */ /* suppression des elements dependants */
DrawItem = m_Drawings; m_Drawings = NULL; DrawItem = m_Drawings; m_Drawings = NULL;
...@@ -279,3 +267,50 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert ) ...@@ -279,3 +267,50 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert )
return BoundaryBox; return BoundaryBox;
} }
/** Function SetFields
* initialize fields from a vector of fields
* @param aFields a std::vector <LibDrawField> to import.
*/
void EDA_LibComponentStruct::SetFields( const std::vector <LibDrawField> aFields )
{
// Init basic fields (Value = name in lib, and reference):
aFields[VALUE].Copy( &m_Name );
aFields[REFERENCE].Copy( &m_Prefix );
// Remove others fields:
CurrentLibEntry->m_Fields.DeleteAll();
for( unsigned ii = FOOTPRINT; ii < aFields.size(); ii++ )
{
bool create = FALSE;
if( !aFields[ii].m_Text.IsEmpty() )
create = TRUE;
if( !aFields[ii].m_Name.IsEmpty()
&& ( aFields[ii].m_Name != ReturnDefaultFieldName( ii ) ) )
create = TRUE;
if( create )
{
LibDrawField*Field = new LibDrawField( ii );
aFields[ii].Copy( Field );
CurrentLibEntry->m_Fields.PushBack( Field );
}
}
/* for a user field (FieldId >= FIELD1), if a field value is void,
* fill it with "~" because for a library component a void field is not a very good idea
* (we do not see anything...) and in schematic this text is like a void text
* and for non editable names, remove the name (set to the default name)
*/
for( LibDrawField* Field = CurrentLibEntry->m_Fields; Field; Field = Field->Next() )
{
if( Field->m_FieldId >= FIELD1 )
{
if( Field->m_Text.IsEmpty() )
Field->m_Text = wxT( "~" );
}
else
Field->m_Name.Empty();
}
}
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef CLASS_LIBENTRY_H #ifndef CLASS_LIBENTRY_H
#define CLASS_LIBENTRY_H #define CLASS_LIBENTRY_H
#include "dlist.h"
#include "classes_body_items.h" #include "classes_body_items.h"
#include "class_libentry_fields.h" #include "class_libentry_fields.h"
...@@ -71,7 +73,7 @@ public: ...@@ -71,7 +73,7 @@ public:
* with a distance of m_TextInside in mils */ * with a distance of m_TextInside in mils */
bool m_DrawPinNum; bool m_DrawPinNum;
bool m_DrawPinName; bool m_DrawPinName;
LibDrawField* Fields; /* Auxiliairy Field list (id = 2 a 11) */ DLIST<LibDrawField> m_Fields; /* Auxiliairy Field list (id >= 2 ) */
LibEDA_BaseStruct* m_Drawings; /* How to draw this part */ LibEDA_BaseStruct* m_Drawings; /* How to draw this part */
long m_LastDate; // Last change Date long m_LastDate; // Last change Date
......
...@@ -27,12 +27,13 @@ ...@@ -27,12 +27,13 @@
*/ */
LibDrawField::LibDrawField( int idfield ) : LibEDA_BaseStruct( COMPONENT_FIELD_DRAW_TYPE ) LibDrawField::LibDrawField( int idfield ) : LibEDA_BaseStruct( COMPONENT_FIELD_DRAW_TYPE )
{ {
m_FieldId = idfield; /* 0 a 11, 0 = REFERENCE, 1 = VALUE*/ m_FieldId = idfield; /* 0 = REFERENCE
if( m_FieldId < 0 ) * 1 = VALUE
m_FieldId = 0; * 3 = FOOTPRINT (default Footprint)
if( m_FieldId >= NUMBER_OF_FIELDS ) * 4 = DOCUMENTATION (user doc link)
m_FieldId = NUMBER_OF_FIELDS - 1; * others = free fields
m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT; */
m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT;
} }
...@@ -97,8 +98,8 @@ bool LibDrawField::Save( FILE* ExportFile ) const ...@@ -97,8 +98,8 @@ bool LibDrawField::Save( FILE* ExportFile ) const
m_Orient == 0 ? 'H' : 'V', m_Orient == 0 ? 'H' : 'V',
(m_Attributs & TEXT_NO_VISIBLE ) ? 'I' : 'V', (m_Attributs & TEXT_NO_VISIBLE ) ? 'I' : 'V',
hjustify, vjustify, hjustify, vjustify,
m_Italic ? 'I' : 'N', m_Italic ? 'I' : 'N',
m_Width > 1 ? 'B' : 'N'); m_Width > 1 ? 'B' : 'N' );
// Save field name, if necessary // Save field name, if necessary
if( m_FieldId >= FIELD1 && !m_Name.IsEmpty() ) if( m_FieldId >= FIELD1 && !m_Name.IsEmpty() )
...@@ -108,3 +109,33 @@ bool LibDrawField::Save( FILE* ExportFile ) const ...@@ -108,3 +109,33 @@ bool LibDrawField::Save( FILE* ExportFile ) const
return true; return true;
} }
/****************************************************************/
wxString ReturnDefaultFieldName( int aFieldNdx )
/****************************************************************/
/** Function ReturnDefaultFieldName
* Return the default field name from its index (REFERENCE, VALUE ..)
* FieldDefaultNameList is not static, because we want the text translation for I18n
* @param aFieldNdx = Filed number (>= 0)
*/
{
// avoid unnecessarily copying wxStrings at runtime.
static const wxString defaults[] = {
_( "Reference" ), // Reference of part, i.e. "IC21"
_( "Value" ), // Value of part, i.e. "3.3K" and name in lib for lib entries
_( "Footprint" ), // Footprint, used by cvpcb or pcbnew, i.e. "16DIP300"
_( "Datasheet" ), // A link to an user document, if wanted
};
if( (unsigned) aFieldNdx <= DATASHEET )
return defaults[ aFieldNdx ];
else
{
wxString ret = _( "Field" );
ret << ( aFieldNdx - FIELD1 + 1);
return ret;
}
}
...@@ -13,15 +13,16 @@ ...@@ -13,15 +13,16 @@
* Name (74LS00..) used to find the component in libraries, and give the default value in schematic * Name (74LS00..) used to find the component in libraries, and give the default value in schematic
*/ */
class LibDrawField : public LibEDA_BaseStruct class LibDrawField : public LibEDA_BaseStruct,
, public EDA_TextStruct public EDA_TextStruct
{ {
public: public:
int m_FieldId; /* 0 a 11 int m_FieldId; /* 0 = REFERENCE
* 0 = Reference; 1 = Value * 1 = VALUE
* 2 = Default footprint, 3 = subsheet (not used, reserved) * 3 = FOOTPRINT (default Footprint)
* 4 .. 11 other fields * 4 = DOCUMENTATION (user doc link)
*/ * others = free fields
*/
wxString m_Name; /* Field Name (not the field text itself, that is .m_Text) */ wxString m_Name; /* Field Name (not the field text itself, that is .m_Text) */
public: public:
...@@ -44,18 +45,18 @@ public: ...@@ -44,18 +45,18 @@ public:
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
virtual bool Save( FILE* aFile ) const; virtual bool Save( FILE* aFile ) const;
LibDrawField* GenCopy(); LibDrawField* GenCopy();
/** Function Copy /** Function Copy
* copy parameters of this to Target. Pointers are not copied * copy parameters of this to Target. Pointers are not copied
* @param Target = the LibDrawField to set with "this" values * @param aTarget = the LibDrawField to set with "this" values
*/ */
void Copy( LibDrawField* Target ) const; void Copy( LibDrawField* aTarget ) const;
void SetFields( const std::vector <LibDrawField> aFields ); void SetFields( const std::vector <LibDrawField> aFields );
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor, void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor,
int aDrawMode, void* aData, int aTransformMatrix[2][2] ); int aDrawMode, void* aData, int aTransformMatrix[2][2] );
...@@ -66,7 +67,7 @@ public: ...@@ -66,7 +67,7 @@ public:
* @param refPos A wxPoint to test, in Field coordinate system * @param refPos A wxPoint to test, in Field coordinate system
* @return bool - true if a hit, else false * @return bool - true if a hit, else false
*/ */
bool HitTest( const wxPoint& refPos ); bool HitTest( const wxPoint& refPos );
}; };
#endif // CLASS_LIBENTRY_FIELDS_H #endif // CLASS_LIBENTRY_FIELDS_H
/***********************************************************************/ /**************************************************************/
/* component_class.cpp : handle the class SCH_COMPONENT */ /* class_sch_cmp_field.cpp : handle the class SCH_CMP_FIELD */
/***********************************************************************/ /**************************************************************/
/* Fields are texts attached to a component, having a specuial meaning
* Fields 0 and 1 are very important: reference and value
* Field 2 is used as default footprint name.
* Field 3 is reserved (not currently used
* Fields 4 and more are user fields.
* They can be renamed and can appear in reports
*/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -36,6 +44,23 @@ SCH_CMP_FIELD::~SCH_CMP_FIELD() ...@@ -36,6 +44,23 @@ SCH_CMP_FIELD::~SCH_CMP_FIELD()
{ {
} }
/** Function ImportValues
* copy parameters from a source.
* Pointers and specific values (position, texts) are not copied
* used to init a field from the model read from a lib entry
* @param aSource = the LibDrawField to read
*/
void SCH_CMP_FIELD::ImportValues( const LibDrawField& aSource )
{
m_Orient = aSource.m_Orient;
m_Size = aSource.m_Size;
m_HJustify = aSource.m_HJustify;
m_VJustify = aSource.m_VJustify;
m_Italic = aSource.m_Italic;
m_Width = aSource.m_Width;
m_Attributs = aSource.m_Attributs;
m_Mirror = aSource.m_Mirror;
}
/**************************************************************************/ /**************************************************************************/
void SCH_CMP_FIELD::SwapData( SCH_CMP_FIELD* copyitem ) void SCH_CMP_FIELD::SwapData( SCH_CMP_FIELD* copyitem )
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Fields 0 and 1 are very important: reference and value * Fields 0 and 1 are very important: reference and value
* Field 2 is used as default footprint name. * Field 2 is used as default footprint name.
* Field 3 is reserved (not currently used * Field 3 is reserved (not currently used
* Fields 4 to 11 are user fields. * Fields 4 and more are user fields.
* They can be renamed and can appear in reports * They can be renamed and can appear in reports
*/ */
...@@ -50,6 +50,13 @@ public: ...@@ -50,6 +50,13 @@ public:
bool IsVoid(); bool IsVoid();
void SwapData( SCH_CMP_FIELD* copyitem ); void SwapData( SCH_CMP_FIELD* copyitem );
/** Function ImportValues
* copy parameters from a source.
* Pointers and specific values (position) are not copied
* @param aSource = the LibDrawField to read
*/
void ImportValues( const LibDrawField& aSource );
/** /**
* Function Draw * Function Draw
*/ */
......
...@@ -114,35 +114,6 @@ void SCH_COMPONENT::AddHierarchicalReference( const wxString& aPath, ...@@ -114,35 +114,6 @@ void SCH_COMPONENT::AddHierarchicalReference( const wxString& aPath,
} }
/****************************************************************/
wxString ReturnDefaultFieldName( int aFieldNdx )
/****************************************************************/
/* Return the default field name from its index (REFERENCE, VALUE ..)
* FieldDefaultNameList is not static, because we want the text translation
* for I18n
*/
{
// avoid unnecessarily copying wxStrings at runtime.
static const wxString defaults[] = {
_( "Ref" ), // Reference of part, i.e. "IC21"
_( "Value" ), // Value of part, i.e. "3.3K"
_( "Footprint" ), // Footprint, used by cvpcb or pcbnew, i.e. "16DIP300"
_( "Datasheet" ),
};
if( (unsigned) aFieldNdx <= DATASHEET )
return defaults[ aFieldNdx ];
else
{
wxString ret = _( "Field" );
ret << ( aFieldNdx - FIELD1 + 1);
return ret;
}
}
/****************************************************************/ /****************************************************************/
wxString SCH_COMPONENT::ReturnFieldName( int aFieldNdx ) const wxString SCH_COMPONENT::ReturnFieldName( int aFieldNdx ) const
/****************************************************************/ /****************************************************************/
......
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: dialog_edit_component_in_lib.cpp // Name: dialog_edit_component_in_lib.cpp
// Purpose: // Purpose:
// Author: jean-pierre Charras // Author: jean-pierre Charras
// Modified by: // Modified by:
// Created: 02/03/2006 08:51:09 // Created: 02/03/2006 08:51:09
// RCS-ID: // RCS-ID:
// Copyright: License GNU // Copyright: License GNU
// Licence: // Licence:
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Generated by DialogBlocks (unregistered), 02/03/2006 08:51:09 // Generated by DialogBlocks (unregistered), 02/03/2006 08:51:09
...@@ -42,7 +42,6 @@ BEGIN_EVENT_TABLE( WinEDA_PartPropertiesFrame, wxDialog ) ...@@ -42,7 +42,6 @@ BEGIN_EVENT_TABLE( WinEDA_PartPropertiesFrame, wxDialog )
EVT_BUTTON( wxID_OK, WinEDA_PartPropertiesFrame::OnOkClick ) EVT_BUTTON( wxID_OK, WinEDA_PartPropertiesFrame::OnOkClick )
////@end WinEDA_PartPropertiesFrame event table entries ////@end WinEDA_PartPropertiesFrame event table entries
EVT_RADIOBOX(ID_ON_SELECT_FIELD, WinEDA_PartPropertiesFrame::SelectNewField)
EVT_BUTTON(ID_ADD_ALIAS, WinEDA_PartPropertiesFrame::AddAliasOfPart) EVT_BUTTON(ID_ADD_ALIAS, WinEDA_PartPropertiesFrame::AddAliasOfPart)
EVT_BUTTON(ID_DELETE_ONE_ALIAS, WinEDA_PartPropertiesFrame::DeleteAliasOfPart) EVT_BUTTON(ID_DELETE_ONE_ALIAS, WinEDA_PartPropertiesFrame::DeleteAliasOfPart)
EVT_BUTTON(ID_DELETE_ALL_ALIAS, WinEDA_PartPropertiesFrame::DeleteAllAliasOfPart) EVT_BUTTON(ID_DELETE_ALL_ALIAS, WinEDA_PartPropertiesFrame::DeleteAllAliasOfPart)
...@@ -64,12 +63,11 @@ WinEDA_PartPropertiesFrame::WinEDA_PartPropertiesFrame( WinEDA_LibeditFrame* par ...@@ -64,12 +63,11 @@ WinEDA_PartPropertiesFrame::WinEDA_PartPropertiesFrame( WinEDA_LibeditFrame* par
m_Parent = parent; m_Parent = parent;
m_RecreateToolbar = FALSE; m_RecreateToolbar = FALSE;
m_AliasLocation = -1; m_AliasLocation = -1;
m_CurrentFieldId = 0;
InitBuffers(); InitBuffers();
Create(parent, id, caption, pos, size, style); Create(parent, id, caption, pos, size, style);
SetTitle(m_Title); SetTitle(m_Title);
} }
...@@ -79,7 +77,6 @@ WinEDA_PartPropertiesFrame::WinEDA_PartPropertiesFrame( WinEDA_LibeditFrame* par ...@@ -79,7 +77,6 @@ WinEDA_PartPropertiesFrame::WinEDA_PartPropertiesFrame( WinEDA_LibeditFrame* par
bool WinEDA_PartPropertiesFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) bool WinEDA_PartPropertiesFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{ {
m_FieldNameCtrl = NULL;
////@begin WinEDA_PartPropertiesFrame member initialisation ////@begin WinEDA_PartPropertiesFrame member initialisation
m_GeneralBoxSizer = NULL; m_GeneralBoxSizer = NULL;
m_NoteBook = NULL; m_NoteBook = NULL;
...@@ -119,9 +116,9 @@ bool WinEDA_PartPropertiesFrame::Create( wxWindow* parent, wxWindowID id, const ...@@ -119,9 +116,9 @@ bool WinEDA_PartPropertiesFrame::Create( wxWindow* parent, wxWindowID id, const
*/ */
void WinEDA_PartPropertiesFrame::CreateControls() void WinEDA_PartPropertiesFrame::CreateControls()
{ {
SetFont(*g_DialogFont); SetFont(*g_DialogFont);
////@begin WinEDA_PartPropertiesFrame content construction ////@begin WinEDA_PartPropertiesFrame content construction
// Generated by DialogBlocks, 29/04/2008 21:32:37 (unregistered) // Generated by DialogBlocks, 29/04/2008 21:32:37 (unregistered)
...@@ -228,7 +225,6 @@ void WinEDA_PartPropertiesFrame::CreateControls() ...@@ -228,7 +225,6 @@ void WinEDA_PartPropertiesFrame::CreateControls()
BuildPanelBasic(); BuildPanelBasic();
BuildPanelDoc(); BuildPanelDoc();
BuildPanelAlias(); BuildPanelAlias();
BuildPanelEditField(); // Add panel Field edition
BuildPanelFootprintFilter(); BuildPanelFootprintFilter();
} }
......
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: dialog_edit_component_in_lib.h // Name: dialog_edit_component_in_lib.h
// Purpose: // Purpose:
// Author: jean-pierre Charras // Author: jean-pierre Charras
// Modified by: // Modified by:
// Created: 02/03/2006 08:51:09 // Created: 02/03/2006 08:51:09
// RCS-ID: // RCS-ID:
// Copyright: License GNU // Copyright: License GNU
// Licence: // Licence:
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Generated by DialogBlocks (unregistered), 02/03/2006 08:51:09 // Generated by DialogBlocks (unregistered), 02/03/2006 08:51:09
...@@ -75,7 +75,7 @@ class wxSpinCtrl; ...@@ -75,7 +75,7 @@ class wxSpinCtrl;
*/ */
class WinEDA_PartPropertiesFrame: public wxDialog class WinEDA_PartPropertiesFrame: public wxDialog
{ {
DECLARE_DYNAMIC_CLASS( WinEDA_PartPropertiesFrame ) DECLARE_DYNAMIC_CLASS( WinEDA_PartPropertiesFrame )
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
...@@ -122,7 +122,6 @@ public: ...@@ -122,7 +122,6 @@ public:
void BuildPanelBasic(); void BuildPanelBasic();
void BuildPanelDoc(); void BuildPanelDoc();
void BuildPanelAlias(); void BuildPanelAlias();
void BuildPanelEditField();
void PartPropertiesAccept(wxCommandEvent& event); void PartPropertiesAccept(wxCommandEvent& event);
void OnQuit(wxCommandEvent& event); void OnQuit(wxCommandEvent& event);
void DeleteAllAliasOfPart(wxCommandEvent& event); void DeleteAllAliasOfPart(wxCommandEvent& event);
...@@ -132,11 +131,6 @@ public: ...@@ -132,11 +131,6 @@ public:
bool SetUnsetConvert(); bool SetUnsetConvert();
void CopyDocToAlias(wxCommandEvent& event); void CopyDocToAlias(wxCommandEvent& event);
void BrowseAndSelectDocFile(wxCommandEvent& event); void BrowseAndSelectDocFile(wxCommandEvent& event);
void SelectNewField(wxCommandEvent& event);
void CopyFieldDataToBuffer(LibDrawField * Field);
void CopyBufferToFieldData(LibDrawField * Field);
void CopyDataToPanelField();
void CopyPanelFieldToData();
void BuildPanelFootprintFilter(); void BuildPanelFootprintFilter();
void DeleteAllFootprintFilter(wxCommandEvent& event); void DeleteAllFootprintFilter(wxCommandEvent& event);
...@@ -164,10 +158,8 @@ public: ...@@ -164,10 +158,8 @@ public:
////@end WinEDA_PartPropertiesFrame member variables ////@end WinEDA_PartPropertiesFrame member variables
WinEDA_LibeditFrame * m_Parent; WinEDA_LibeditFrame * m_Parent;
int m_CurrentFieldId;
wxString m_Title; wxString m_Title;
wxPanel * m_PanelField;
wxPanel * m_PanelFootprintFilter; wxPanel * m_PanelFootprintFilter;
wxButton * m_ButtonDeleteOneAlias; wxButton * m_ButtonDeleteOneAlias;
wxButton * m_ButtonDeleteAllAlias; wxButton * m_ButtonDeleteAllAlias;
...@@ -181,24 +173,6 @@ public: ...@@ -181,24 +173,6 @@ public:
wxListBox * m_PartAliasList; wxListBox * m_PartAliasList;
wxListBox * m_FootprintFilterListBox; wxListBox * m_FootprintFilterListBox;
wxRadioBox * m_FieldSelection;
wxCheckBox * m_ShowFieldTextCtrl;
wxCheckBox * m_VorientFieldTextCtrl;
wxRadioBox * m_FieldHJustifyCtrl;
wxRadioBox * m_FieldVJustifyCtrl;
WinEDA_GraphicTextCtrl * m_FieldTextCtrl;
WinEDA_EnterText * m_FieldNameCtrl;
WinEDA_PositionCtrl * m_FieldPositionCtrl;
int m_FieldFlags[NUMBER_OF_FIELDS];
int m_FieldOrient[NUMBER_OF_FIELDS];
int m_FieldHJustify[NUMBER_OF_FIELDS];
int m_FieldVJustify[NUMBER_OF_FIELDS];
int m_FieldSize[NUMBER_OF_FIELDS];
wxString m_FieldText[NUMBER_OF_FIELDS];
wxString m_FieldName[NUMBER_OF_FIELDS];
wxPoint m_FieldPosition[NUMBER_OF_FIELDS];
bool m_RecreateToolbar; bool m_RecreateToolbar;
int m_AliasLocation; int m_AliasLocation;
......
...@@ -85,6 +85,23 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow ...@@ -85,6 +85,23 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow
} }
/******************************************************************************/
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::reinitializeFieldsIdAndDefaultNames( )
/*****************************************************************************/
{
for( unsigned new_id = FIELD1; new_id < m_FieldsBuf.size(); new_id++ )
{
unsigned old_id = m_FieldsBuf[new_id].m_FieldId;
if ( old_id != new_id )
{
if ( m_FieldsBuf[new_id].m_Name == ReturnDefaultFieldName( old_id ) )
m_FieldsBuf[new_id].m_Name = ReturnDefaultFieldName( new_id );
m_FieldsBuf[new_id].m_FieldId = new_id;
}
}
}
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemDeselected( wxListEvent& event ) void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemDeselected( wxListEvent& event )
{ {
D( printf( "OnListItemDeselected()\n" ); ) D( printf( "OnListItemDeselected()\n" ); )
...@@ -251,10 +268,11 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::addFieldButtonHandler( wxCommandEvent& ...@@ -251,10 +268,11 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::addFieldButtonHandler( wxCommandEvent&
blank.m_Orient = m_FieldsBuf[REFERENCE].m_Orient; blank.m_Orient = m_FieldsBuf[REFERENCE].m_Orient;
m_FieldsBuf.push_back( blank ); m_FieldsBuf.push_back( blank );
m_FieldsBuf[fieldNdx].m_Name = ReturnDefaultFieldName(fieldNdx);
m_skipCopyFromPanel = true;
setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] ); setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] );
m_skipCopyFromPanel = true;
setSelectedFieldNdx( fieldNdx ); setSelectedFieldNdx( fieldNdx );
m_skipCopyFromPanel = false; m_skipCopyFromPanel = false;
} }
...@@ -273,13 +291,17 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::deleteFieldButtonHandler( wxCommandEven ...@@ -273,13 +291,17 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::deleteFieldButtonHandler( wxCommandEven
return; return;
} }
m_skipCopyFromPanel = true;
m_FieldsBuf.erase( m_FieldsBuf.begin() + fieldNdx ); m_FieldsBuf.erase( m_FieldsBuf.begin() + fieldNdx );
fieldListCtrl->DeleteItem( fieldNdx ); fieldListCtrl->DeleteItem( fieldNdx );
if( fieldNdx >= m_FieldsBuf.size() ) if( fieldNdx >= m_FieldsBuf.size() )
--fieldNdx; --fieldNdx;
m_skipCopyFromPanel = true; // Reinitialize fields IDs and default names:
reinitializeFieldsIdAndDefaultNames();
updateDisplay( );
setSelectedFieldNdx( fieldNdx ); setSelectedFieldNdx( fieldNdx );
m_skipCopyFromPanel = false; m_skipCopyFromPanel = false;
} }
...@@ -314,6 +336,10 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC:: moveUpButtonHandler( wxCommandEvent& e ...@@ -314,6 +336,10 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC:: moveUpButtonHandler( wxCommandEvent& e
m_FieldsBuf[fieldNdx] = tmp; m_FieldsBuf[fieldNdx] = tmp;
setRowItem( fieldNdx, tmp ); setRowItem( fieldNdx, tmp );
// Reinitialize fields IDs and default names:
reinitializeFieldsIdAndDefaultNames();
updateDisplay( );
m_skipCopyFromPanel = true; m_skipCopyFromPanel = true;
setSelectedFieldNdx( fieldNdx - 1 ); setSelectedFieldNdx( fieldNdx - 1 );
m_skipCopyFromPanel = false; m_skipCopyFromPanel = false;
...@@ -645,20 +671,10 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event ) ...@@ -645,20 +671,10 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
/* Initialise fields values to default values found in library: */ /* Initialise fields values to default values found in library: */
m_Cmp->GetField( REFERENCE )->m_Pos = entry->m_Prefix.m_Pos + m_Cmp->m_Pos; m_Cmp->GetField( REFERENCE )->m_Pos = entry->m_Prefix.m_Pos + m_Cmp->m_Pos;
m_Cmp->GetField( REFERENCE )->m_Orient = entry->m_Prefix.m_Orient; m_Cmp->GetField( REFERENCE )->ImportValues( entry->m_Prefix );
m_Cmp->GetField( REFERENCE )->m_Size = entry->m_Prefix.m_Size;
m_Cmp->GetField( REFERENCE )->m_HJustify = entry->m_Prefix.m_HJustify;
m_Cmp->GetField( REFERENCE )->m_VJustify = entry->m_Prefix.m_VJustify;
m_Cmp->GetField( REFERENCE )->m_Italic = entry->m_Prefix.m_Italic;
m_Cmp->GetField( REFERENCE )->m_Width = entry->m_Prefix.m_Width;
m_Cmp->GetField( VALUE )->m_Pos = entry->m_Name.m_Pos + m_Cmp->m_Pos; m_Cmp->GetField( VALUE )->m_Pos = entry->m_Name.m_Pos + m_Cmp->m_Pos;
m_Cmp->GetField( VALUE )->m_Orient = entry->m_Name.m_Orient; m_Cmp->GetField( VALUE )->ImportValues( entry->m_Name );
m_Cmp->GetField( VALUE )->m_Size = entry->m_Name.m_Size;
m_Cmp->GetField( VALUE )->m_HJustify = entry->m_Name.m_HJustify;
m_Cmp->GetField( VALUE )->m_VJustify = entry->m_Name.m_VJustify;
m_Cmp->GetField( VALUE )->m_Italic = entry->m_Name.m_Italic;
m_Cmp->GetField( VALUE )->m_Width = entry->m_Name.m_Width;
m_Cmp->SetRotationMiroir( CMP_NORMAL ); m_Cmp->SetRotationMiroir( CMP_NORMAL );
......
...@@ -73,6 +73,22 @@ public: ...@@ -73,6 +73,22 @@ public:
*/ */
void InitBuffers( SCH_COMPONENT* aComponent ); void InitBuffers( SCH_COMPONENT* aComponent );
private:
/** Function updateDisplay
* update the listbox showing fields, according to the fields texts
* must be called after a text change in fields, if this change is not an edition
*/
void updateDisplay( )
{
for( unsigned ii = FIELD1; ii<m_FieldsBuf.size(); ii++ )
setRowItem( ii, m_FieldsBuf[ii] );
}
/** Function reinitializeFieldsIdAndDefaultNames
* Calculates the field id and default name, after deleting a field
* or moving a field
*/
void reinitializeFieldsIdAndDefaultNames();
}; };
#endif // __dialog_edit_component_in_schematic__ #endif // __dialog_edit_component_in_schematic__
...@@ -18,86 +18,6 @@ ...@@ -18,86 +18,6 @@
// Local variables: // Local variables:
static int s_SelectedRow; static int s_SelectedRow;
/** @todo function to move in a file like class_libentry.cpp
*/
/** Function SetFields
* initialize fields from a vector of fields
* @param aFields a std::vector <LibDrawField> to import.
*/
void EDA_LibComponentStruct::SetFields( const std::vector <LibDrawField> aFields )
{
// Init basic fields (Value = name in lib, and reference):
aFields[VALUE].Copy( &m_Name );
aFields[REFERENCE].Copy( &m_Prefix );
// Init others fields:
for( unsigned ii = FOOTPRINT; ii < aFields.size(); ii++ )
{
LibDrawField* Field = CurrentLibEntry->Fields;
LibDrawField* NextField, * previousField = NULL;
while( Field )
{
NextField = Field->Next();
if( Field->m_FieldId == (int) ii )
{
aFields[ii].Copy( Field );
// An old field exists; delete it if void
if( Field->m_Text.IsEmpty() )
{
if( ii < FIELD1 || Field->m_Name.IsEmpty() )
{
SAFE_DELETE( Field );
if( previousField )
previousField->SetNext( NextField );
else
Fields = NextField;
}
}
break;
}
previousField = Field;
Field = NextField;
}
if( Field == NULL ) // Do not exists: must be created if not void
{
bool create = FALSE;
if( !aFields[ii].m_Text.IsEmpty() )
create = TRUE;
if( !aFields[ii].m_Name.IsEmpty()
&& ( aFields[ii].m_Name != ReturnDefaultFieldName( ii ) ) )
create = TRUE;
if( create )
{
Field = new LibDrawField( ii );
*Field = aFields[ii];
Field->SetNext( CurrentLibEntry->Fields );
Fields = Field;
}
}
}
/* for a user field (FieldId >= FIELD1), if a field value is void,
* fill it with "~" because for a library component a void field is not a very good idea
* (we do not see anything...) and in schematic this text is like a void text
* and for non editable names, remove the name (set to the default name)
*/
for( LibDrawField* Field = Fields; Field; Field = Field->Next() )
{
if( Field->m_FieldId >= FIELD1 )
{
if( Field->m_Text.IsEmpty() )
Field->m_Text = wxT( "~" );
}
else
Field->m_Name.Empty();
}
}
/*****************************************************************************************/ /*****************************************************************************************/
class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB : public DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB : public DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE
...@@ -156,6 +76,22 @@ private: ...@@ -156,6 +76,22 @@ private:
*/ */
bool copyPanelToSelectedField(); bool copyPanelToSelectedField();
void setRowItem( int aFieldNdx, const LibDrawField& aField ); void setRowItem( int aFieldNdx, const LibDrawField& aField );
/** Function updateDisplay
* update the listbox showing fields, according to the fields texts
* must be called after a text change in fields, if this change is not an edition
*/
void updateDisplay( )
{
for( unsigned ii = FIELD1; ii<m_FieldsBuf.size(); ii++ )
setRowItem( ii, m_FieldsBuf[ii] );
}
/** Function reinitializeFieldsIdAndDefaultNames
* Calculates the field id and default name, after deleting a field
* or moving a field
*/
void reinitializeFieldsIdAndDefaultNames();
}; };
/*****************************************************************/ /*****************************************************************/
...@@ -168,10 +104,15 @@ void WinEDA_LibeditFrame::InstallFieldsEditorDialog( void ) ...@@ -168,10 +104,15 @@ void WinEDA_LibeditFrame::InstallFieldsEditorDialog( void )
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB* frame = DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB* frame =
new DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB( this, CurrentLibEntry ); new DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB( this, CurrentLibEntry );
int IsModified = frame->ShowModal(); frame->Destroy(); int abort = frame->ShowModal(); frame->Destroy();
if( IsModified ) if( ! abort )
{
ReCreateHToolbar();
Refresh(); Refresh();
}
DisplayLibInfos();
} }
...@@ -180,10 +121,10 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB( ...@@ -180,10 +121,10 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB(
WinEDA_LibeditFrame* aParent, WinEDA_LibeditFrame* aParent,
EDA_LibComponentStruct* aLibEntry ) : EDA_LibComponentStruct* aLibEntry ) :
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( aParent ) DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( aParent )
/***********************************************************************/
{ {
m_Parent = aParent; m_Parent = aParent;
m_LibEntry = aLibEntry; m_LibEntry = aLibEntry;
/***********************************************************************/
} }
...@@ -309,12 +250,27 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnOKButtonClick( wxCommandEvent& event ...@@ -309,12 +250,27 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnOKButtonClick( wxCommandEvent& event
m_Parent->GetScreen()->SetModify(); m_Parent->GetScreen()->SetModify();
m_Parent->DrawPanel->Refresh( TRUE );
EndModal( 0 ); EndModal( 0 );
} }
/******************************************************************************/
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::reinitializeFieldsIdAndDefaultNames( )
/*****************************************************************************/
{
for( unsigned new_id = FIELD1; new_id < m_FieldsBuf.size(); new_id++ )
{
unsigned old_id = m_FieldsBuf[new_id].m_FieldId;
if ( old_id != new_id )
{
if ( m_FieldsBuf[new_id].m_Name == ReturnDefaultFieldName( old_id ) )
m_FieldsBuf[new_id].m_Name = ReturnDefaultFieldName( new_id );
m_FieldsBuf[new_id].m_FieldId = new_id;
}
}
}
/**************************************************************************************/ /**************************************************************************************/
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::addFieldButtonHandler( wxCommandEvent& event ) void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::addFieldButtonHandler( wxCommandEvent& event )
/**************************************************************************************/ /**************************************************************************************/
...@@ -328,9 +284,8 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::addFieldButtonHandler( wxCommandEvent& ...@@ -328,9 +284,8 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::addFieldButtonHandler( wxCommandEvent&
LibDrawField blank( fieldNdx ); LibDrawField blank( fieldNdx );
blank.m_Orient = m_FieldsBuf[REFERENCE].m_Orient;
m_FieldsBuf.push_back( blank ); m_FieldsBuf.push_back( blank );
m_FieldsBuf[fieldNdx].m_Name = ReturnDefaultFieldName(fieldNdx);
setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] ); setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] );
...@@ -355,13 +310,18 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::deleteFieldButtonHandler( wxCommandEven ...@@ -355,13 +310,18 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::deleteFieldButtonHandler( wxCommandEven
return; return;
} }
m_skipCopyFromPanel = true;
m_FieldsBuf.erase( m_FieldsBuf.begin() + fieldNdx ); m_FieldsBuf.erase( m_FieldsBuf.begin() + fieldNdx );
fieldListCtrl->DeleteItem( fieldNdx ); fieldListCtrl->DeleteItem( fieldNdx );
if( fieldNdx >= m_FieldsBuf.size() ) if( fieldNdx >= m_FieldsBuf.size() )
--fieldNdx; --fieldNdx;
m_skipCopyFromPanel = true; // Reinitialize fields IDs and default names:
reinitializeFieldsIdAndDefaultNames();
updateDisplay( );
setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] );
setSelectedFieldNdx( fieldNdx ); setSelectedFieldNdx( fieldNdx );
m_skipCopyFromPanel = false; m_skipCopyFromPanel = false;
} }
...@@ -395,6 +355,10 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB:: moveUpButtonHandler( wxCommandEvent& e ...@@ -395,6 +355,10 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB:: moveUpButtonHandler( wxCommandEvent& e
m_FieldsBuf[fieldNdx] = tmp; m_FieldsBuf[fieldNdx] = tmp;
setRowItem( fieldNdx, tmp ); setRowItem( fieldNdx, tmp );
// Reinitialize fields IDs and default names:
reinitializeFieldsIdAndDefaultNames();
updateDisplay( );
m_skipCopyFromPanel = true; m_skipCopyFromPanel = true;
setSelectedFieldNdx( fieldNdx - 1 ); setSelectedFieldNdx( fieldNdx - 1 );
m_skipCopyFromPanel = false; m_skipCopyFromPanel = false;
...@@ -443,7 +407,8 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::InitBuffers( void ) ...@@ -443,7 +407,8 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::InitBuffers( void )
m_FieldsBuf.push_back( m_LibEntry->m_Prefix ); m_FieldsBuf.push_back( m_LibEntry->m_Prefix );
m_FieldsBuf.push_back( m_LibEntry->m_Name ); m_FieldsBuf.push_back( m_LibEntry->m_Name );
for( LibDrawField* field = m_LibEntry->Fields; field != NULL; field = field->Next() ) // Creates a working copy of fields
for( LibDrawField* field = m_LibEntry->m_Fields; field != NULL; field = field->Next() )
m_FieldsBuf.push_back( *field ); m_FieldsBuf.push_back( *field );
// Display 12 fields (or more), and add missing fields // Display 12 fields (or more), and add missing fields
...@@ -483,6 +448,8 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::InitBuffers( void ) ...@@ -483,6 +448,8 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::InitBuffers( void )
fieldListCtrl->SetFocus(); fieldListCtrl->SetFocus();
// resume editing at the last row edited, last time dialog was up. // resume editing at the last row edited, last time dialog was up.
if ( s_SelectedRow < (int) m_FieldsBuf.size() )
s_SelectedRow = 0;
setSelectedFieldNdx( s_SelectedRow ); setSelectedFieldNdx( s_SelectedRow );
} }
...@@ -544,7 +511,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel() ...@@ -544,7 +511,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
fieldNameTextCtrl->SetValue( field.m_Name ); fieldNameTextCtrl->SetValue( field.m_Name );
// if fieldNdx == REFERENCE, VALUE, FOOTPRINT, or DATASHEET, then disable editing // if fieldNdx == REFERENCE, VALUE, FOOTPRINT, or DATASHEET, then disable filed name editing
fieldNameTextCtrl->Enable( fieldNdx >= FIELD1 ); fieldNameTextCtrl->Enable( fieldNdx >= FIELD1 );
fieldNameTextCtrl->SetEditable( fieldNdx >= FIELD1 ); fieldNameTextCtrl->SetEditable( fieldNdx >= FIELD1 );
...@@ -629,7 +596,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField() ...@@ -629,7 +596,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
rotateCheckBox->SetValue( field.m_Orient == TEXT_ORIENT_VERT ); rotateCheckBox->SetValue( field.m_Orient == TEXT_ORIENT_VERT );
/* Void fields for REFERENCE and VALUE are not allowed /* Void fields for REFERENCE and VALUE are not allowed
* chnage therm only for a new non void value * change therm only for a new non void value
*/ */
if( !fieldValueTextCtrl->GetValue().IsEmpty() ) if( !fieldValueTextCtrl->GetValue().IsEmpty() )
field.m_Text = fieldValueTextCtrl->GetValue(); field.m_Text = fieldValueTextCtrl->GetValue();
......
This diff is collapsed.
...@@ -153,7 +153,7 @@ void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -153,7 +153,7 @@ void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC,
if( (LibEntry->m_Name.m_Flags & IS_MOVED) == 0 ) if( (LibEntry->m_Name.m_Flags & IS_MOVED) == 0 )
LibEntry->m_Name.Draw( panel, DC, aOffset, color, DrawMode, NULL, TransMat ); LibEntry->m_Name.Draw( panel, DC, aOffset, color, DrawMode, NULL, TransMat );
for( Field = LibEntry->Fields; Field != NULL; Field = Field->Next() ) for( Field = LibEntry->m_Fields; Field != NULL; Field = Field->Next() )
{ {
if( Field->m_Text.IsEmpty() ) if( Field->m_Text.IsEmpty() )
return; return;
......
...@@ -957,9 +957,7 @@ static bool GetLibEntryField (EDA_LibComponentStruct* LibEntry, ...@@ -957,9 +957,7 @@ static bool GetLibEntryField (EDA_LibComponentStruct* LibEntry,
break; break;
Field = new LibDrawField( NumOfField ); Field = new LibDrawField( NumOfField );
LibEntry->m_Fields.PushBack( Field );
Field->SetNext( LibEntry->Fields );
LibEntry->Fields = Field;
break; break;
} }
......
...@@ -185,43 +185,30 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC, ...@@ -185,43 +185,30 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
/* Init champ Valeur */ /* Init champ Valeur */
DrawLibItem->GetField( VALUE )->m_Pos = Entry->m_Name.m_Pos + DrawLibItem->m_Pos; DrawLibItem->GetField( VALUE )->m_Pos = Entry->m_Name.m_Pos + DrawLibItem->m_Pos;
DrawLibItem->GetField( VALUE )->m_Orient = Entry->m_Name.m_Orient; DrawLibItem->GetField( VALUE )->ImportValues( Entry->m_Name );
DrawLibItem->GetField( VALUE )->m_Size = Entry->m_Name.m_Size;
DrawLibItem->GetField( VALUE )->m_Text = DrawLibItem->m_ChipName; DrawLibItem->GetField( VALUE )->m_Text = DrawLibItem->m_ChipName;
DrawLibItem->GetField( VALUE )->m_Attributs = Entry->m_Name.m_Attributs;
DrawLibItem->GetField( VALUE )->m_HJustify = Entry->m_Name.m_HJustify;
DrawLibItem->GetField( VALUE )->m_VJustify = Entry->m_Name.m_VJustify;
DrawLibItem->GetField( VALUE )->m_Italic = Entry->m_Name.m_Italic;
DrawLibItem->GetField( VALUE )->m_Width = Entry->m_Name.m_Width;
msg = Entry->m_Prefix.m_Text; msg = Entry->m_Prefix.m_Text;
if( msg.IsEmpty() ) if( msg.IsEmpty() )
msg = wxT( "U" ); msg = wxT( "U" );
msg += wxT( "?" ); msg += wxT( "?" );
//update the reference -- just the prefix for now. // update the reference -- just the prefix for now.
DrawLibItem->SetRef( GetSheet(), msg ); DrawLibItem->SetRef( GetSheet(), msg );
/* Init champ Reference */ /* Init champ Reference */
DrawLibItem->GetField( REFERENCE )->m_Pos = DrawLibItem->GetField( REFERENCE )->m_Pos = Entry->m_Prefix.m_Pos + DrawLibItem->m_Pos;
Entry->m_Prefix.m_Pos + DrawLibItem->m_Pos; DrawLibItem->GetField( REFERENCE )->ImportValues( Entry->m_Prefix );
DrawLibItem->GetField( REFERENCE )->m_Orient = Entry->m_Prefix.m_Orient;
DrawLibItem->GetField( REFERENCE )->m_Size = Entry->m_Prefix.m_Size;
DrawLibItem->m_PrefixString = Entry->m_Prefix.m_Text; DrawLibItem->m_PrefixString = Entry->m_Prefix.m_Text;
DrawLibItem->GetField( REFERENCE )->m_Attributs = Entry->m_Prefix.m_Attributs;
DrawLibItem->GetField( REFERENCE )->m_HJustify = Entry->m_Prefix.m_HJustify;
DrawLibItem->GetField( REFERENCE )->m_VJustify = Entry->m_Prefix.m_VJustify;
DrawLibItem->GetField( REFERENCE )->m_Italic = Entry->m_Prefix.m_Italic;
DrawLibItem->GetField( REFERENCE )->m_Width = Entry->m_Prefix.m_Width;
/* Init des autres champs si predefinis dans la librairie */ /* Init des autres champs si predefinis dans la librairie */
for( Field = Entry->Fields; Field != NULL; Field = Field->Next() ) for( Field = Entry->m_Fields; Field != NULL; Field = Field->Next() )
{ {
if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() ) if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() )
continue; continue;
ii = Field->m_FieldId; ii = Field->m_FieldId;
if( ii < 2 ) if( ii < 2 ) // Reference or value, already done
continue; continue;
if( ii >= DrawLibItem->GetFieldCount() ) if( ii >= DrawLibItem->GetFieldCount() )
...@@ -230,15 +217,9 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC, ...@@ -230,15 +217,9 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
SCH_CMP_FIELD* f = DrawLibItem->GetField( ii ); SCH_CMP_FIELD* f = DrawLibItem->GetField( ii );
f->m_Pos += Field->m_Pos; f->m_Pos += Field->m_Pos;
f->m_Size = Field->m_Size; f->ImportValues( *Field );
f->m_Attributs = Field->m_Attributs;
f->m_Orient = Field->m_Orient;
f->m_Text = Field->m_Text; f->m_Text = Field->m_Text;
f->m_Name = Field->m_Name; f->m_Name = Field->m_Name;
f->m_HJustify = Field->m_HJustify;
f->m_VJustify = Field->m_VJustify;
f->m_Italic = Field->m_Italic;
f->m_Width = Field->m_Width;
} }
DrawStructsInGhost( DrawPanel, DC, DrawLibItem, 0, 0 ); DrawStructsInGhost( DrawPanel, DC, DrawLibItem, 0, 0 );
......
...@@ -220,9 +220,7 @@ void WinEDA_LibeditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -220,9 +220,7 @@ void WinEDA_LibeditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
} }
if( DrawEntry == NULL ) if( DrawEntry == NULL )
{ {
wxPoint mpos; InstallLibeditFrame( );
wxGetMousePosition( &mpos.x, &mpos.y );
InstallLibeditFrame( mpos );
} }
} }
......
...@@ -327,7 +327,7 @@ LibDrawField* WinEDA_LibeditFrame::LocateField( EDA_LibComponentStruct* LibEntry ...@@ -327,7 +327,7 @@ LibDrawField* WinEDA_LibeditFrame::LocateField( EDA_LibComponentStruct* LibEntry
return &LibEntry->m_Prefix; return &LibEntry->m_Prefix;
/* Localisation des autres fields */ /* Localisation des autres fields */
for( LibDrawField* field = LibEntry->Fields; field; field = field->Next() ) for( LibDrawField* field = LibEntry->m_Fields; field; field = field->Next() )
{ {
if( field->m_Text.IsEmpty() ) if( field->m_Text.IsEmpty() )
continue; continue;
......
...@@ -378,7 +378,7 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -378,7 +378,7 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_LIBEDIT_GET_FRAME_EDIT_PART: case ID_LIBEDIT_GET_FRAME_EDIT_PART:
InstallLibeditFrame( pos ); InstallLibeditFrame( );
break; break;
case ID_LIBEDIT_GET_FRAME_EDIT_FIELDS: case ID_LIBEDIT_GET_FRAME_EDIT_FIELDS:
......
...@@ -278,12 +278,10 @@ EDA_LibComponentStruct* CopyLibEntryStruct( wxWindow* frame, EDA_LibComponentStr ...@@ -278,12 +278,10 @@ EDA_LibComponentStruct* CopyLibEntryStruct( wxWindow* frame, EDA_LibComponentStr
NewStruct->m_DocFile = OldEntry->m_DocFile; NewStruct->m_DocFile = OldEntry->m_DocFile;
/* Copie des champs */ /* Copie des champs */
for( OldField = OldEntry->Fields; OldField != NULL; for( OldField = OldEntry->m_Fields; OldField != NULL; OldField = OldField->Next() )
OldField = (LibDrawField*) OldField->Next() )
{ {
NewField = OldField->GenCopy(); NewField = OldField->GenCopy();
NewField->SetNext( NewStruct->Fields ); NewStruct->m_Fields.PushBack( NewField );
NewStruct->Fields = NewField;
} }
/* Copie des elements type Drawing */ /* Copie des elements type Drawing */
...@@ -363,8 +361,7 @@ bool EDA_LibComponentStruct::Save( FILE* aFile ) ...@@ -363,8 +361,7 @@ bool EDA_LibComponentStruct::Save( FILE* aFile )
m_Prefix.Save( aFile ); m_Prefix.Save( aFile );
m_Name.Save( aFile ); m_Name.Save( aFile );
for( Field = Fields; Field!= NULL; for( Field = m_Fields; Field != NULL; Field = Field->Next() )
Field = (LibDrawField*) Field->Next() )
{ {
if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() ) if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() )
continue; continue;
......
...@@ -394,7 +394,7 @@ void WinEDA_LibeditFrame::PlaceAncre() ...@@ -394,7 +394,7 @@ void WinEDA_LibeditFrame::PlaceAncre()
LibEntry->m_Name.m_Pos += offset; LibEntry->m_Name.m_Pos += offset;
LibEntry->m_Prefix.m_Pos += offset; LibEntry->m_Prefix.m_Pos += offset;
for( LibDrawField* field = LibEntry->Fields; field; field = field->Next() ) for( LibDrawField* field = LibEntry->m_Fields; field; field = field->Next() )
{ {
field->m_Pos += offset; field->m_Pos += offset;
} }
......
...@@ -160,7 +160,7 @@ void WinEDA_LibeditFrame::ReCreateHToolbar() ...@@ -160,7 +160,7 @@ void WinEDA_LibeditFrame::ReCreateHToolbar()
wxNullBitmap, wxNullBitmap,
FALSE, FALSE,
-1, -1, (wxObject*) NULL, -1, -1, (wxObject*) NULL,
_( "Add, remove, edit fields properties" ) ); _( "Add, remove fields and edit fields properties" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_LIBEDIT_CHECK_PART, BITMAP( erc_xpm ), m_HToolBar->AddTool( ID_LIBEDIT_CHECK_PART, BITMAP( erc_xpm ),
......
...@@ -403,7 +403,7 @@ private: ...@@ -403,7 +403,7 @@ private:
LibraryStruct* Library, int noMsg = 0 ); LibraryStruct* Library, int noMsg = 0 );
void DisplayCmpDoc( const wxString& Name ); void DisplayCmpDoc( const wxString& Name );
void InstallLibeditFrame( const wxPoint& pos ); void InstallLibeditFrame( );
// General editing // General editing
public: public:
......
...@@ -85,8 +85,8 @@ public: ...@@ -85,8 +85,8 @@ public:
int m_Status_Pcb; // Flags used in ratsnet calculation and update int m_Status_Pcb; // Flags used in ratsnet calculation and update
EDA_BoardDesignSettings* m_BoardSettings; // Link to current design settings EDA_BoardDesignSettings* m_BoardSettings; // Link to current design settings
int m_NbNodes; // Active pads (pads attached to a net ) count int m_NbNodes; // Active pads (pads attached to a net ) count
int m_NbLinks; // Ratsnet count int m_NbLinks; // Ratsnest count
int m_NbLoclinks; // Rastests to shew while creating a track int m_NbLoclinks; // Ratsests to show while creating a track
int m_NbNoconnect; // Active ratsnet count (rastnest not alraedy connected by tracks int m_NbNoconnect; // Active ratsnet count (rastnest not alraedy connected by tracks
DLIST<BOARD_ITEM> m_Drawings; // linked list of lines & texts DLIST<BOARD_ITEM> m_Drawings; // linked list of lines & texts
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment