Commit c759be6f authored by CHARRAS's avatar CHARRAS
Browse files

eeschema: problems found. some (not all) solved (see changelog)

parent 36554e68
Loading
Loading
Loading
Loading
+15 −0
Original line number Original line Diff line number Diff line
@@ -5,6 +5,21 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
Please add newer entries at the top, list the date and your name with
email address.
email address.


2008-Feb-21 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+eeschema
	added : full text conversion between text, label, global label and hierarchical label
	some problems fixed:
	- annotation incorrectly cleared.
	- reference not copied in component copy.
	- incorrect redo when changing the chip name in component edition
	
	bugs not fixed
	- undo/redo problems when changing a text type between text, label, global label and hierarchical label
	- incorrect annotation in complex hierarchy with multi parts per package (duplicates created).
	


2008-Feb-20 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
2008-Feb-20 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
================================================================================
+eeschema
+eeschema
+166 −136
Original line number Original line Diff line number Diff line
@@ -89,67 +89,82 @@ const wxString& EDA_SchComponentStruct::ReturnFieldName( int aFieldNdx ) const
    return m_Field[aFieldNdx].m_Name;
    return m_Field[aFieldNdx].m_Name;
}
}


/************************************/

/****************************************************************/
wxString EDA_SchComponentStruct::GetPath( DrawSheetList* sheet )
wxString EDA_SchComponentStruct::GetPath( DrawSheetList* sheet )
/************************************/
/****************************************************************/
{
{
    wxString str;
    wxString str;
	str.Printf(_("%8.8lX"), m_TimeStamp );

    str.Printf( wxT( "%8.8lX" ), m_TimeStamp );
    return sheet->Path() + str;
    return sheet->Path() + str;
}
}


/************************************/

/********************************************************************/
const wxString EDA_SchComponentStruct::GetRef( DrawSheetList* sheet )
const wxString EDA_SchComponentStruct::GetRef( DrawSheetList* sheet )
/************************************/
/********************************************************************/
{
{
    wxString     path = GetPath( sheet );
    wxString     path = GetPath( sheet );
    unsigned int i;
    unsigned int i;
	for(i=0; i<m_Paths.GetCount(); i++){

		if( m_Paths[i].Cmp(path) == 0 ){
    for( i = 0; i<m_Paths.GetCount(); i++ )
    {
        if( m_Paths[i].Cmp( path ) == 0 )
        {
            /*printf("GetRef path: %s ref: %s\n",
            /*printf("GetRef path: %s ref: %s\n",
					CONV_TO_UTF8(m_Paths[i]), 
             *     CONV_TO_UTF8(m_Paths[i]),
					CONV_TO_UTF8(m_References[i])); */
             *     CONV_TO_UTF8(m_References[i])); */
            return m_References[i];
            return m_References[i];
        }
        }
    }
    }

    //if it was not found in m_Paths array, then see if it is in
    //if it was not found in m_Paths array, then see if it is in
    // m_Field[REFERENCE] -- if so, use this as a default for this path.
    // m_Field[REFERENCE] -- if so, use this as a default for this path.
    // this will happen if we load a version 1 schematic file.
    // this will happen if we load a version 1 schematic file.
    // it will also mean that multiple instances of the same sheet by default
    // it will also mean that multiple instances of the same sheet by default
    // all have the same component references, but perhaps this is best.
    // all have the same component references, but perhaps this is best.
	if( !m_Field[REFERENCE].m_Text.IsEmpty() ){
    if( !m_Field[REFERENCE].m_Text.IsEmpty() )
    {
        SetRef( sheet, m_Field[REFERENCE].m_Text );
        SetRef( sheet, m_Field[REFERENCE].m_Text );
        return m_Field[REFERENCE].m_Text;
        return m_Field[REFERENCE].m_Text;
    }
    }
    return m_PrefixString;
    return m_PrefixString;
}
}


/************************************/

/***********************************************************************/
void EDA_SchComponentStruct::SetRef( DrawSheetList* sheet, wxString ref )
void EDA_SchComponentStruct::SetRef( DrawSheetList* sheet, wxString ref )
/************************************/
/***********************************************************************/
{
{
    //check to see if it is already there before inserting it
    //check to see if it is already there before inserting it
    wxString path = GetPath( sheet );
    wxString path = GetPath( sheet );

    printf( "SetRef path: %s ref: %s\n",
    printf( "SetRef path: %s ref: %s\n",
           CONV_TO_UTF8( path ),
           CONV_TO_UTF8( path ),
           CONV_TO_UTF8( ref ) );
           CONV_TO_UTF8( ref ) );
    unsigned int i;
    unsigned int i;
    bool         notInArray = true;
    bool         notInArray = true;
	for(i=0; i<m_Paths.GetCount(); i++){
    for( i = 0; i<m_Paths.GetCount(); i++ )
		if(m_Paths[i].Cmp(path) == 0){
    {
        if( m_Paths[i].Cmp( path ) == 0 )
        {
            //just update the reference text, not the timestamp.
            //just update the reference text, not the timestamp.
            m_References.RemoveAt( i );
            m_References.RemoveAt( i );
            m_References.Insert( ref, i );
            m_References.Insert( ref, i );
            notInArray = false;
            notInArray = false;
        }
        }
    }
    }
	if(notInArray){

    if( notInArray )
    {
        m_References.Add( ref );
        m_References.Add( ref );
        m_Paths.Add( path );
        m_Paths.Add( path );
    }
    }
	if(m_Field[REFERENCE].m_Text.IsEmpty() || 
    if( m_Field[REFERENCE].m_Text.IsEmpty()
		( abs(m_Field[REFERENCE].m_Pos.x - m_Pos.x) + 
       || ( abs( m_Field[REFERENCE].m_Pos.x - m_Pos.x ) +
			abs(m_Field[REFERENCE].m_Pos.y - m_Pos.y) > 1000)) {
            abs( m_Field[REFERENCE].m_Pos.y - m_Pos.y ) > 1000) )
    {
        //move it to a reasonable position..
        //move it to a reasonable position..
        m_Field[REFERENCE].m_Pos    = m_Pos;
        m_Field[REFERENCE].m_Pos    = m_Pos;
        m_Field[REFERENCE].m_Pos.x += 50; //a slight offset..
        m_Field[REFERENCE].m_Pos.x += 50; //a slight offset..
@@ -158,14 +173,16 @@ void EDA_SchComponentStruct::SetRef( DrawSheetList* sheet, wxString ref )
    m_Field[REFERENCE].m_Text = ref; //for drawing.
    m_Field[REFERENCE].m_Text = ref; //for drawing.
}
}


/************************************/

/**************************************/
void EDA_SchComponentStruct::ClearRefs()
void EDA_SchComponentStruct::ClearRefs()
/************************************/
/**************************************/
{
{
    m_Paths.Empty();
    m_Paths.Empty();
    m_References.Empty();
    m_References.Empty();
}
}



const wxString& EDA_SchComponentStruct::GetFieldValue( int aFieldNdx ) const
const wxString& EDA_SchComponentStruct::GetFieldValue( int aFieldNdx ) const
{
{
    // avoid unnecessarily copying wxStrings.
    // avoid unnecessarily copying wxStrings.
@@ -186,6 +203,7 @@ EDA_SchComponentStruct::EDA_SchComponentStruct( const wxPoint& pos ) :
    int ii;
    int ii;


    m_Multi = 0;    /* In multi unit chip - which unit to draw. */
    m_Multi = 0;    /* In multi unit chip - which unit to draw. */

    //m_FlagControlMulti = 0;
    //m_FlagControlMulti = 0;
    m_UsedOnSheets.Clear();
    m_UsedOnSheets.Clear();
    m_Convert = 0;  /* Gestion des mutiples representations (conversion De Morgan) */
    m_Convert = 0;  /* Gestion des mutiples representations (conversion De Morgan) */
@@ -214,9 +232,9 @@ EDA_SchComponentStruct::EDA_SchComponentStruct( const wxPoint& pos ) :
}
}




/**********************************************************************/
/************************************************/
EDA_Rect EDA_SchComponentStruct::GetBoundaryBox()
EDA_Rect EDA_SchComponentStruct::GetBoundaryBox()
/**********************************************************************/
/************************************************/
{
{
    EDA_LibComponentStruct* Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
    EDA_LibComponentStruct* Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
    EDA_Rect BoundaryBox;
    EDA_Rect BoundaryBox;
@@ -230,7 +248,7 @@ EDA_Rect EDA_SchComponentStruct::GetBoundaryBox()


        // We must reverse Y values, because matrix orientation
        // We must reverse Y values, because matrix orientation
        // suppose Y axis normal for the library items coordinates,
        // suppose Y axis normal for the library items coordinates,
        // m_Transform reverse Y values, but BoundaryBox ais already reversed!
        // m_Transform reverse Y values, but BoundaryBox is already reversed!
        y0 = -BoundaryBox.GetY();
        y0 = -BoundaryBox.GetY();
        ym = -BoundaryBox.GetBottom();
        ym = -BoundaryBox.GetBottom();
    }
    }
@@ -262,6 +280,8 @@ EDA_Rect EDA_SchComponentStruct::GetBoundaryBox()
    BoundaryBox.Offset( m_Pos );
    BoundaryBox.Offset( m_Pos );
    return BoundaryBox;
    return BoundaryBox;
}
}


/**************************************************************************/
/**************************************************************************/
void PartTextStruct::SwapData( PartTextStruct* copyitem )
void PartTextStruct::SwapData( PartTextStruct* copyitem )
/**************************************************************************/
/**************************************************************************/
@@ -295,6 +315,7 @@ void EDA_SchComponentStruct::SwapData( EDA_SchComponentStruct* copyitem )
 *  swap data between this and copyitem
 *  swap data between this and copyitem
 */
 */
{
{
	EXCHG( m_ChipName, copyitem->m_ChipName );
    EXCHG( m_Pos, copyitem->m_Pos );
    EXCHG( m_Pos, copyitem->m_Pos );
    EXCHG( m_Multi, copyitem->m_Multi );
    EXCHG( m_Multi, copyitem->m_Multi );
    EXCHG( m_Convert, copyitem->m_Convert );
    EXCHG( m_Convert, copyitem->m_Convert );
@@ -342,13 +363,19 @@ void EDA_SchComponentStruct::ClearAnnotation()
 */
 */
{
{
    wxString defRef = m_PrefixString;
    wxString defRef = m_PrefixString;
	defRef.Append( _("?") ); 

    while( defRef.Last() == '?' )
        defRef.RemoveLast();

    defRef.Append( wxT( "?" ) );
    m_References.Empty();
    m_References.Empty();
    unsigned int            i;
    unsigned int            i;
	for(i=0; i< m_Paths.GetCount(); i++){
    for( i = 0; i< m_Paths.GetCount(); i++ )
    {
        m_References.Add( defRef );
        m_References.Add( defRef );
    }
    }


    m_Field[REFERENCE].m_Text = defRef; //for drawing.
    EDA_LibComponentStruct* Entry;
    EDA_LibComponentStruct* Entry;
    Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
    Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString, FIND_ROOT );


@@ -367,6 +394,8 @@ EDA_SchComponentStruct* EDA_SchComponentStruct::GenCopy()


    new_item->m_Multi    = m_Multi;
    new_item->m_Multi    = m_Multi;
    new_item->m_ChipName = m_ChipName;
    new_item->m_ChipName = m_ChipName;
	new_item->m_PrefixString = m_PrefixString;

    //new_item->m_FlagControlMulti = m_FlagControlMulti;
    //new_item->m_FlagControlMulti = m_FlagControlMulti;
    new_item->m_UsedOnSheets = m_UsedOnSheets;
    new_item->m_UsedOnSheets = m_UsedOnSheets;
    new_item->m_Convert = m_Convert;
    new_item->m_Convert = m_Convert;
@@ -612,8 +641,8 @@ wxPoint EDA_SchComponentStruct::GetScreenCoord( const wxPoint& coord )
}
}





#if defined (DEBUG)
#if defined (DEBUG)

/**
/**
 * Function Show
 * Function Show
 * is used to output the object tree, currently for debugging only.
 * is used to output the object tree, currently for debugging only.
@@ -646,14 +675,15 @@ void EDA_SchComponentStruct::Show( int nestLevel, std::ostream& os )


    NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
    NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
}
}
#endif




#endif




/***************************************************************************/
/***************************************************************************/
PartTextStruct::PartTextStruct( const wxPoint& pos, const wxString& text ) :
PartTextStruct::PartTextStruct( const wxPoint& pos, const wxString& text ) :
    EDA_BaseStruct( DRAW_PART_TEXT_STRUCT_TYPE ), EDA_TextStruct( text )
    EDA_BaseStruct( DRAW_PART_TEXT_STRUCT_TYPE )
    , EDA_TextStruct( text )
/***************************************************************************/
/***************************************************************************/
{
{
    m_Pos     = pos;
    m_Pos     = pos;
+4 −4
Original line number Original line Diff line number Diff line
@@ -117,7 +117,7 @@ void WinEDA_SchematicFrame::EditSchematicText( DrawTextStruct* TextStruct,
                                               wxDC*           DC )
                                               wxDC*           DC )
/*************************************************************************/
/*************************************************************************/


/* Edit the properties of the text (Label, Gloab label, graphic text).. )
/* Edit the properties of the text (Label, Global label, graphic text).. )
 *  pointed by "TextStruct"
 *  pointed by "TextStruct"
 */
 */
{
{
@@ -330,7 +330,7 @@ void WinEDA_SchematicFrame::ConvertTextType( DrawTextStruct* Text,
/*****************************************************************************/
/*****************************************************************************/


/* Routine to change a text type to an other one (GraphicText, label or Glabel).
/* Routine to change a text type to an other one (GraphicText, label or Glabel).
 * A new test, label or global label is created from the old text.
 * A new test, label or hierarchical or global label is created from the old text.
 * the old text is deleted
 * the old text is deleted
 */
 */
{
{
@@ -389,10 +389,10 @@ void WinEDA_SchematicFrame::ConvertTextType( DrawTextStruct* Text,
    {
    {
        DrawPanel->ForceCloseManageCurseur( DrawPanel, DC );
        DrawPanel->ForceCloseManageCurseur( DrawPanel, DC );
    }
    }
    if( (flags & IS_NEW) == 0 )    // Delete old text and save it in undo list
    if( (flags & IS_NEW) == 0 )    // Remove old text from current list and save it in undo list
    {
    {
        Text->m_Flags = 0;
        Text->m_Flags = 0;
        DeleteStruct( DrawPanel, DC, Text );
        DeleteStruct( DrawPanel, DC, Text );    // old text is really saved in undo list
		GetScreen()->SetCurItem( NULL );
		GetScreen()->SetCurItem( NULL );
        g_ItemToRepeat = NULL;
        g_ItemToRepeat = NULL;
    }
    }
+9 −1
Original line number Original line Diff line number Diff line
@@ -380,6 +380,8 @@ void AddMenusForGLabel( wxMenu* PopMenu, DrawGlobalLabelStruct* GLabel )
                  _( "Change to Label" ), glabel2label_xpm );
                  _( "Change to Label" ), glabel2label_xpm );
    ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT,
    ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT,
                  _( "Change to Text" ), glabel2text_xpm );
                  _( "Change to Text" ), glabel2text_xpm );
    ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL,
                  _( "Change to Hierarchical Label" ), label2glabel_xpm );
    ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type,
    ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type,
                               ID_POPUP_SCH_CHANGE_TYPE_TEXT, _( "Change Type" ), gl_change_xpm );
                               ID_POPUP_SCH_CHANGE_TYPE_TEXT, _( "Change Type" ), gl_change_xpm );
}
}
@@ -402,6 +404,8 @@ void AddMenusForHLabel( wxMenu* PopMenu, DrawHierLabelStruct* HLabel )
                  _( "Change to Label" ), glabel2label_xpm );
                  _( "Change to Label" ), glabel2label_xpm );
    ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT,
    ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT,
                  _( "Change to Text" ), glabel2text_xpm );
                  _( "Change to Text" ), glabel2text_xpm );
    ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL,
                  _( "Change to Global label" ), label2glabel_xpm );
    ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type,
    ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type,
                               ID_POPUP_SCH_CHANGE_TYPE_TEXT, _( "Change Type" ), gl_change_xpm );
                               ID_POPUP_SCH_CHANGE_TYPE_TEXT, _( "Change Type" ), gl_change_xpm );
}
}
@@ -424,9 +428,11 @@ void AddMenusForLabel( wxMenu* PopMenu, DrawLabelStruct* Label )


    // add menu change type text (to label, glabel, text):
    // add menu change type text (to label, glabel, text):
    ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL,
    ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL,
                  _( "Change to Glabel" ), label2glabel_xpm );
                  _( "Change to Global label" ), label2glabel_xpm );
    ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT,
    ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT,
                  _( "Change to Text" ), label2text_xpm );
                  _( "Change to Text" ), label2text_xpm );
    ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL,
                  _( "Change to Hierarchical Label" ), label2glabel_xpm );
    ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type,
    ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type,
                               ID_POPUP_SCH_CHANGE_TYPE_TEXT, _( "Change Type" ), gl_change_xpm );
                               ID_POPUP_SCH_CHANGE_TYPE_TEXT, _( "Change Type" ), gl_change_xpm );
}
}
@@ -450,6 +456,8 @@ void AddMenusForText( wxMenu* PopMenu, DrawTextStruct* Text )
    // add menu change type text (to label, glabel, text):
    // add menu change type text (to label, glabel, text):
    ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL,
    ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL,
                  _( "Change to Label" ), label2text_xpm );
                  _( "Change to Label" ), label2text_xpm );
    ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL,
                  _( "Change to Hierarchical Label" ), label2glabel_xpm );
    ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL,
    ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL,
                  _( "Change to Glabel" ), label2glabel_xpm );
                  _( "Change to Glabel" ), label2glabel_xpm );
    ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type,
    ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type,
+8 −1
Original line number Original line Diff line number Diff line
@@ -42,6 +42,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
    case ID_POPUP_SCH_EDIT_TEXT:
    case ID_POPUP_SCH_EDIT_TEXT:
    case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL:
    case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL:
    case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL:
    case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL:
    case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL:
    case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT:
    case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT:
    case ID_POPUP_SCH_SET_SHAPE_TEXT:
    case ID_POPUP_SCH_SET_SHAPE_TEXT:
    case ID_POPUP_SCH_ROTATE_TEXT:
    case ID_POPUP_SCH_ROTATE_TEXT:
@@ -395,6 +396,12 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
                        &dc, DRAW_GLOBAL_LABEL_STRUCT_TYPE );
                        &dc, DRAW_GLOBAL_LABEL_STRUCT_TYPE );
        break;
        break;


    case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL:
        DrawPanel->MouseToCursorSchema();
		ConvertTextType( (DrawTextStruct*) GetScreen()->GetCurItem(),
                        &dc, DRAW_HIER_LABEL_STRUCT_TYPE );
        break;

    case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT:
    case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT:
        DrawPanel->MouseToCursorSchema();
        DrawPanel->MouseToCursorSchema();
		ConvertTextType( (DrawTextStruct*) GetScreen()->GetCurItem(),
		ConvertTextType( (DrawTextStruct*) GetScreen()->GetCurItem(),
@@ -403,7 +410,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )


    case ID_POPUP_SCH_SET_SHAPE_TEXT:
    case ID_POPUP_SCH_SET_SHAPE_TEXT:


        // Non utilis�
        // Not used
        break;
        break;


    case ID_POPUP_SCH_ROTATE_FIELD:
    case ID_POPUP_SCH_ROTATE_FIELD:
Loading