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.
++Eeschema:
Note: this is a work in progress!
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>
......
......@@ -3,7 +3,6 @@
/**********************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
......@@ -87,8 +86,6 @@ EDA_LibComponentStruct:: EDA_LibComponentStruct( const wxChar* CmpName ) :
m_Options = ENTRY_NORMAL;
m_UnitSelectionLocked = FALSE;
m_DrawPinNum = m_DrawPinName = 1;
Fields = NULL;
m_Prefix.m_FieldId = REFERENCE;
}
......@@ -98,15 +95,6 @@ EDA_LibComponentStruct::~EDA_LibComponentStruct()
/******************************************************/
{
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 */
DrawItem = m_Drawings; m_Drawings = NULL;
......@@ -279,3 +267,50 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert )
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 @@
#ifndef CLASS_LIBENTRY_H
#define CLASS_LIBENTRY_H
#include "dlist.h"
#include "classes_body_items.h"
#include "class_libentry_fields.h"
......@@ -71,7 +73,7 @@ public:
* with a distance of m_TextInside in mils */
bool m_DrawPinNum;
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 */
long m_LastDate; // Last change Date
......
......@@ -27,11 +27,12 @@
*/
LibDrawField::LibDrawField( int idfield ) : LibEDA_BaseStruct( COMPONENT_FIELD_DRAW_TYPE )
{
m_FieldId = idfield; /* 0 a 11, 0 = REFERENCE, 1 = VALUE*/
if( m_FieldId < 0 )
m_FieldId = 0;
if( m_FieldId >= NUMBER_OF_FIELDS )
m_FieldId = NUMBER_OF_FIELDS - 1;
m_FieldId = idfield; /* 0 = REFERENCE
* 1 = VALUE
* 3 = FOOTPRINT (default Footprint)
* 4 = DOCUMENTATION (user doc link)
* others = free fields
*/
m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT;
}
......@@ -98,7 +99,7 @@ bool LibDrawField::Save( FILE* ExportFile ) const
(m_Attributs & TEXT_NO_VISIBLE ) ? 'I' : 'V',
hjustify, vjustify,
m_Italic ? 'I' : 'N',
m_Width > 1 ? 'B' : 'N');
m_Width > 1 ? 'B' : 'N' );
// Save field name, if necessary
if( m_FieldId >= FIELD1 && !m_Name.IsEmpty() )
......@@ -108,3 +109,33 @@ bool LibDrawField::Save( FILE* ExportFile ) const
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,14 +13,15 @@
* Name (74LS00..) used to find the component in libraries, and give the default value in schematic
*/
class LibDrawField : public LibEDA_BaseStruct
, public EDA_TextStruct
class LibDrawField : public LibEDA_BaseStruct,
public EDA_TextStruct
{
public:
int m_FieldId; /* 0 a 11
* 0 = Reference; 1 = Value
* 2 = Default footprint, 3 = subsheet (not used, reserved)
* 4 .. 11 other fields
int m_FieldId; /* 0 = REFERENCE
* 1 = VALUE
* 3 = FOOTPRINT (default Footprint)
* 4 = DOCUMENTATION (user doc link)
* others = free fields
*/
wxString m_Name; /* Field Name (not the field text itself, that is .m_Text) */
......@@ -51,9 +52,9 @@ public:
/** Function Copy
* 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 );
......
/***********************************************************************/
/* 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 "gr_basic.h"
......@@ -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 )
......
......@@ -9,7 +9,7 @@
* 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 to 11 are user fields.
* Fields 4 and more are user fields.
* They can be renamed and can appear in reports
*/
......@@ -50,6 +50,13 @@ public:
bool IsVoid();
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
*/
......
......@@ -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
/****************************************************************/
......
......@@ -42,7 +42,6 @@ BEGIN_EVENT_TABLE( WinEDA_PartPropertiesFrame, wxDialog )
EVT_BUTTON( wxID_OK, WinEDA_PartPropertiesFrame::OnOkClick )
////@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_DELETE_ONE_ALIAS, WinEDA_PartPropertiesFrame::DeleteAliasOfPart)
EVT_BUTTON(ID_DELETE_ALL_ALIAS, WinEDA_PartPropertiesFrame::DeleteAllAliasOfPart)
......@@ -64,7 +63,6 @@ WinEDA_PartPropertiesFrame::WinEDA_PartPropertiesFrame( WinEDA_LibeditFrame* par
m_Parent = parent;
m_RecreateToolbar = FALSE;
m_AliasLocation = -1;
m_CurrentFieldId = 0;
InitBuffers();
......@@ -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 )
{
m_FieldNameCtrl = NULL;
////@begin WinEDA_PartPropertiesFrame member initialisation
m_GeneralBoxSizer = NULL;
m_NoteBook = NULL;
......@@ -228,7 +225,6 @@ void WinEDA_PartPropertiesFrame::CreateControls()
BuildPanelBasic();
BuildPanelDoc();
BuildPanelAlias();
BuildPanelEditField(); // Add panel Field edition
BuildPanelFootprintFilter();
}
......
......@@ -122,7 +122,6 @@ public:
void BuildPanelBasic();
void BuildPanelDoc();
void BuildPanelAlias();
void BuildPanelEditField();
void PartPropertiesAccept(wxCommandEvent& event);
void OnQuit(wxCommandEvent& event);
void DeleteAllAliasOfPart(wxCommandEvent& event);
......@@ -132,11 +131,6 @@ public:
bool SetUnsetConvert();
void CopyDocToAlias(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 DeleteAllFootprintFilter(wxCommandEvent& event);
......@@ -164,10 +158,8 @@ public:
////@end WinEDA_PartPropertiesFrame member variables
WinEDA_LibeditFrame * m_Parent;
int m_CurrentFieldId;
wxString m_Title;
wxPanel * m_PanelField;
wxPanel * m_PanelFootprintFilter;
wxButton * m_ButtonDeleteOneAlias;
wxButton * m_ButtonDeleteAllAlias;
......@@ -181,24 +173,6 @@ public:
wxListBox * m_PartAliasList;
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;
int m_AliasLocation;
......
......@@ -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 )
{
D( printf( "OnListItemDeselected()\n" ); )
......@@ -251,10 +268,11 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::addFieldButtonHandler( wxCommandEvent&
blank.m_Orient = m_FieldsBuf[REFERENCE].m_Orient;
m_FieldsBuf.push_back( blank );
m_FieldsBuf[fieldNdx].m_Name = ReturnDefaultFieldName(fieldNdx);
m_skipCopyFromPanel = true;
setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] );
m_skipCopyFromPanel = true;
setSelectedFieldNdx( fieldNdx );
m_skipCopyFromPanel = false;
}
......@@ -273,13 +291,17 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::deleteFieldButtonHandler( wxCommandEven
return;
}
m_skipCopyFromPanel = true;
m_FieldsBuf.erase( m_FieldsBuf.begin() + fieldNdx );
fieldListCtrl->DeleteItem( fieldNdx );
if( fieldNdx >= m_FieldsBuf.size() )
--fieldNdx;
m_skipCopyFromPanel = true;
// Reinitialize fields IDs and default names:
reinitializeFieldsIdAndDefaultNames();
updateDisplay( );
setSelectedFieldNdx( fieldNdx );
m_skipCopyFromPanel = false;
}
......@@ -314,6 +336,10 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC:: moveUpButtonHandler( wxCommandEvent& e
m_FieldsBuf[fieldNdx] = tmp;
setRowItem( fieldNdx, tmp );
// Reinitialize fields IDs and default names:
reinitializeFieldsIdAndDefaultNames();
updateDisplay( );
m_skipCopyFromPanel = true;
setSelectedFieldNdx( fieldNdx - 1 );
m_skipCopyFromPanel = false;
......@@ -645,20 +671,10 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
/* 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_Orient = entry->m_Prefix.m_Orient;
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( REFERENCE )->ImportValues( entry->m_Prefix );
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 )->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->GetField( VALUE )->ImportValues( entry->m_Name );
m_Cmp->SetRotationMiroir( CMP_NORMAL );
......
......@@ -73,6 +73,22 @@ public:
*/
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__
......@@ -18,86 +18,6 @@
// Local variables:
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
......@@ -156,6 +76,22 @@ private:
*/
bool copyPanelToSelectedField();
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 )
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB* frame =
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();
}
DisplayLibInfos();
}
......@@ -180,10 +121,10 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB(
WinEDA_LibeditFrame* aParent,
EDA_LibComponentStruct* aLibEntry ) :
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( aParent )
/***********************************************************************/
{
m_Parent = aParent;
m_LibEntry = aLibEntry;
/***********************************************************************/
}
......@@ -309,12 +250,27 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnOKButtonClick( wxCommandEvent& event
m_Parent->GetScreen()->SetModify();
m_Parent->DrawPanel->Refresh( TRUE );
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 )
/**************************************************************************************/
......@@ -328,9 +284,8 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::addFieldButtonHandler( wxCommandEvent&
LibDrawField blank( fieldNdx );
blank.m_Orient = m_FieldsBuf[REFERENCE].m_Orient;
m_FieldsBuf.push_back( blank );
m_FieldsBuf[fieldNdx].m_Name = ReturnDefaultFieldName(fieldNdx);
setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] );
......@@ -355,13 +310,18 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::deleteFieldButtonHandler( wxCommandEven
return;
}
m_skipCopyFromPanel = true;
m_FieldsBuf.erase( m_FieldsBuf.begin() + fieldNdx );
fieldListCtrl->DeleteItem( fieldNdx );
if( fieldNdx >= m_FieldsBuf.size() )
--fieldNdx;
m_skipCopyFromPanel = true;
// Reinitialize fields IDs and default names:
reinitializeFieldsIdAndDefaultNames();
updateDisplay( );
setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] );
setSelectedFieldNdx( fieldNdx );
m_skipCopyFromPanel = false;
}
......@@ -395,6 +355,10 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB:: moveUpButtonHandler( wxCommandEvent& e
m_FieldsBuf[fieldNdx] = tmp;
setRowItem( fieldNdx, tmp );
// Reinitialize fields IDs and default names:
reinitializeFieldsIdAndDefaultNames();
updateDisplay( );
m_skipCopyFromPanel = true;
setSelectedFieldNdx( fieldNdx - 1 );
m_skipCopyFromPanel = false;
......@@ -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_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 );
// Display 12 fields (or more), and add missing fields
......@@ -483,6 +448,8 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::InitBuffers( void )
fieldListCtrl->SetFocus();
// 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 );
}
......@@ -544,7 +511,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
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->SetEditable( fieldNdx >= FIELD1 );
......@@ -629,7 +596,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
rotateCheckBox->SetValue( field.m_Orient == TEXT_ORIENT_VERT );
/* 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() )
field.m_Text = fieldValueTextCtrl->GetValue();
......
This diff is collapsed.
......@@ -153,7 +153,7 @@ void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC,
if( (LibEntry->m_Name.m_Flags & IS_MOVED) == 0 )
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() )
return;
......
......@@ -957,9 +957,7 @@ static bool GetLibEntryField (EDA_LibComponentStruct* LibEntry,
break;
Field = new LibDrawField( NumOfField );
Field->SetNext( LibEntry->Fields );
LibEntry->Fields = Field;
LibEntry->m_Fields.PushBack( Field );
break;
}
......
......@@ -185,43 +185,30 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
/* Init champ Valeur */
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 )->m_Size = Entry->m_Name.m_Size;
DrawLibItem->GetField( VALUE )->ImportValues( Entry->m_Name );
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;
if( msg.IsEmpty() )
msg = wxT( "U" );
msg += wxT( "?" );
//update the reference -- just the prefix for now.
// update the reference -- just the prefix for now.
DrawLibItem->SetRef( GetSheet(), msg );
/* Init champ Reference */
DrawLibItem->GetField( REFERENCE )->m_Pos =
Entry->m_Prefix.m_Pos + DrawLibItem->m_Pos;
DrawLibItem->GetField( REFERENCE )->m_Orient = Entry->m_Prefix.m_Orient;
DrawLibItem->GetField( REFERENCE )->m_Size = Entry->m_Prefix.m_Size;
DrawLibItem->GetField( REFERENCE )->m_Pos = Entry->m_Prefix.m_Pos + DrawLibItem->m_Pos;
DrawLibItem->GetField( REFERENCE )->ImportValues( Entry->m_Prefix );
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 */
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() )
continue;
ii = Field->m_FieldId;
if( ii < 2 )
if( ii < 2 ) // Reference or value, already done
continue;
if( ii >= DrawLibItem->GetFieldCount() )
......@@ -230,15 +217,9 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
SCH_CMP_FIELD* f = DrawLibItem->GetField( ii );
f->m_Pos += Field->m_Pos;
f->m_Size = Field->m_Size;
f->m_Attributs = Field->m_Attributs;
f->m_Orient = Field->m_Orient;
f->ImportValues( *Field );
f->m_Text = Field->m_Text;
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 );
......
......@@ -220,9 +220,7 @@ void WinEDA_LibeditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
}
if( DrawEntry == NULL )
{
wxPoint mpos;
wxGetMousePosition( &mpos.x, &mpos.y );
InstallLibeditFrame( mpos );
InstallLibeditFrame( );
}
}
......
......@@ -327,7 +327,7 @@ LibDrawField* WinEDA_LibeditFrame::LocateField( EDA_LibComponentStruct* LibEntry
return &LibEntry->m_Prefix;
/* 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() )
continue;
......
......@@ -378,7 +378,7 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_LIBEDIT_GET_FRAME_EDIT_PART:
InstallLibeditFrame( pos );
InstallLibeditFrame( );
break;
case ID_LIBEDIT_GET_FRAME_EDIT_FIELDS:
......
......@@ -278,12 +278,10 @@ EDA_LibComponentStruct* CopyLibEntryStruct( wxWindow* frame, EDA_LibComponentStr
NewStruct->m_DocFile = OldEntry->m_DocFile;
/* Copie des champs */
for( OldField = OldEntry->Fields; OldField != NULL;
OldField = (LibDrawField*) OldField->Next() )
for( OldField = OldEntry->m_Fields; OldField != NULL; OldField = OldField->Next() )
{
NewField = OldField->GenCopy();
NewField->SetNext( NewStruct->Fields );
NewStruct->Fields = NewField;
NewStruct->m_Fields.PushBack( NewField );
}
/* Copie des elements type Drawing */
......@@ -363,8 +361,7 @@ bool EDA_LibComponentStruct::Save( FILE* aFile )
m_Prefix.Save( aFile );
m_Name.Save( aFile );
for( Field = Fields; Field!= NULL;
Field = (LibDrawField*) Field->Next() )
for( Field = m_Fields; Field != NULL; Field = Field->Next() )
{
if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() )
continue;
......
......@@ -394,7 +394,7 @@ void WinEDA_LibeditFrame::PlaceAncre()
LibEntry->m_Name.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;
}
......
......@@ -160,7 +160,7 @@ void WinEDA_LibeditFrame::ReCreateHToolbar()
wxNullBitmap,
FALSE,
-1, -1, (wxObject*) NULL,
_( "Add, remove, edit fields properties" ) );
_( "Add, remove fields and edit fields properties" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_LIBEDIT_CHECK_PART, BITMAP( erc_xpm ),
......
......@@ -403,7 +403,7 @@ private:
LibraryStruct* Library, int noMsg = 0 );
void DisplayCmpDoc( const wxString& Name );
void InstallLibeditFrame( const wxPoint& pos );
void InstallLibeditFrame( );
// General editing
public:
......
......@@ -85,8 +85,8 @@ public:
int m_Status_Pcb; // Flags used in ratsnet calculation and update
EDA_BoardDesignSettings* m_BoardSettings; // Link to current design settings
int m_NbNodes; // Active pads (pads attached to a net ) count
int m_NbLinks; // Ratsnet count
int m_NbLoclinks; // Rastests to shew while creating a track
int m_NbLinks; // Ratsnest count
int m_NbLoclinks; // Ratsests to show while creating a track
int m_NbNoconnect; // Active ratsnet count (rastnest not alraedy connected by tracks
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