Commit 3f38a6d8 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

worksheetcode cleaning and fix plot sheet filename bug under Linux.

parent 001723e0
Loading
Loading
Loading
Loading
+196 −295

File changed.

Preview size limit exceeded, changes collapsed.

+12 −15
Original line number Original line Diff line number Diff line
@@ -35,8 +35,7 @@
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 */
 */


#define SIZETEXT        100             // worksheet text size
#define TEXTSIZE        100             // worksheet text size
#define SIZETEXT_REF    50              // worksheet frame reference text size
#define PAS_REF         2000            // reference markings on worksheet frame
#define PAS_REF         2000            // reference markings on worksheet frame
                                        // used in worksheet.cpp
                                        // used in worksheet.cpp


@@ -974,10 +973,8 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
    wxPoint             pos;
    wxPoint             pos;
    wxPoint             end;
    wxPoint             end;
    int                 refx, refy;
    int                 refx, refy;
    wxString            Line;
    Ki_WorkSheetData*   WsItem;
    Ki_WorkSheetData*   WsItem;
    wxSize              size( SIZETEXT * m_milsToIu, SIZETEXT * m_milsToIu );
    wxSize              size( TEXTSIZE * m_milsToIu, TEXTSIZE * m_milsToIu );
    wxSize              size_ref( SIZETEXT_REF * m_milsToIu, SIZETEXT_REF * m_milsToIu );
    wxString            msg;
    wxString            msg;
    WS_DRAW_ITEM_TEXT*  gtext;
    WS_DRAW_ITEM_TEXT*  gtext;


@@ -994,10 +991,10 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
    int     lnWosn  = m_penSize * 2;
    int     lnWosn  = m_penSize * 2;
    int     lnWtonk = m_penSize;
    int     lnWtonk = m_penSize;
    wxSize  sz;
    wxSize  sz;
    wxSize  size0_8( SIZETEXT * m_milsToIu * 0.8, SIZETEXT * m_milsToIu * 1 );
    wxSize  size0_8( TEXTSIZE * m_milsToIu * 0.8, TEXTSIZE * m_milsToIu * 1 );
    wxSize  size1_5( SIZETEXT * m_milsToIu * 1.5, SIZETEXT * m_milsToIu * 1.5 );
    wxSize  size1_5( TEXTSIZE * m_milsToIu * 1.5, TEXTSIZE * m_milsToIu * 1.5 );
    wxSize  size2( SIZETEXT * m_milsToIu * 2, SIZETEXT * m_milsToIu * 2 );
    wxSize  size2( TEXTSIZE * m_milsToIu * 2, TEXTSIZE * m_milsToIu * 2 );
    wxSize  size3( SIZETEXT * m_milsToIu * 3, SIZETEXT * m_milsToIu * 3 );
    wxSize  size3( TEXTSIZE * m_milsToIu * 3, TEXTSIZE * m_milsToIu * 3 );


    // Draw the border.
    // Draw the border.
    Append( new WS_DRAW_ITEM_RECT(
    Append( new WS_DRAW_ITEM_RECT(
@@ -1112,9 +1109,9 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
            int             index   = 0;
            int             index   = 0;
            wxString        fullMsg = msg;
            wxString        fullMsg = msg;


            do      // Reduce the height of wrapped title until the fit
            while( 1 )      // Reduce the height of wrapped title until the fit
            {
            {
                do  // Wrap the title
                 while( 1 ) // Wrap the title
                {
                {
                    titleWidth = ReturnGraphicTextWidth( msg, sz.x, false, false ) / m_milsToIu;
                    titleWidth = ReturnGraphicTextWidth( msg, sz.x, false, false ) / m_milsToIu;


@@ -1122,7 +1119,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
                    {
                    {
                        index = 0;
                        index = 0;


                        do
                        while( 1 )
                        {
                        {
                            msg = msg.Left( msg.Length() - 1 );
                            msg = msg.Left( msg.Length() - 1 );


@@ -1163,7 +1160,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
                                    }
                                    }
                                }
                                }
                            }
                            }
                        } while( 1 );
                        }
                    }
                    }
                    else
                    else
                    {
                    {
@@ -1180,7 +1177,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(


                        break;
                        break;
                    }
                    }
                } while( 1 );
                }


                if( titleFieldHeight < (int) ( titleHeight * lines.Count() ) )
                if( titleFieldHeight < (int) ( titleHeight * lines.Count() ) )
                {
                {
@@ -1191,7 +1188,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
                }
                }
                else
                else
                    break;
                    break;
            } while( 1 );
            }


            pos.x   = ( refx - Mm2mils( 85 ) ) * m_milsToIu;
            pos.x   = ( refx - Mm2mils( 85 ) ) * m_milsToIu;
            pos.y   =
            pos.y   =
+2 −0
Original line number Original line Diff line number Diff line
@@ -133,6 +133,8 @@ public:
    WS_DRAW_ITEM_LIST()
    WS_DRAW_ITEM_LIST()
    {
    {
        m_idx = 0;
        m_idx = 0;
        m_milsToIu = 1.0;
        m_penSize = 1;
    }
    }


    ~WS_DRAW_ITEM_LIST()
    ~WS_DRAW_ITEM_LIST()
+15 −18
Original line number Original line Diff line number Diff line
@@ -530,27 +530,24 @@ wxString SCH_EDIT_FRAME::GetUniqueFilenameForCurrentSheet()
     * However if filename is too long name is <sheet filename>-<sheet number>
     * However if filename is too long name is <sheet filename>-<sheet number>
     */
     */


    #define FN_LEN_MAX 100   // A reasonnable value for the full file name len
    #define FN_LEN_MAX 80   // A reasonable value for the short filename len


    fn.ClearExt();
    wxString filename = fn.GetName();
    wxString filename = fn.GetFullPath();
    wxString sheetFullName =  m_CurrentSheet->PathHumanReadable();
    if( ( filename.Len() + m_CurrentSheet->PathHumanReadable().Len() ) < FN_LEN_MAX )
    sheetFullName.Trim( true );
    {
    sheetFullName.Trim( false );
        filename += m_CurrentSheet->PathHumanReadable();

        filename.Replace( wxT( "/" ), wxT( "-" ) );
    // Remove the last '/' of the path human readable
        filename.RemoveLast();
    // (and for the root sheet, make sheetFullName empty):
        // To avoid issues on unix, ensure the filename does not start
    sheetFullName.RemoveLast();
        // by '-', which has a special meaning in command lines

#ifndef __WINDOWS__
    // Convert path human readable separator to '-'
        wxString newfn;
    sheetFullName.Replace( wxT( "/" ), wxT( "-" ) );
        if( filename.StartsWith( wxT( "-" ), &newfn ) )

            filename = newfn;
    if( ( filename.Len() + sheetFullName.Len() ) < FN_LEN_MAX )
#endif
        filename += sheetFullName;
    }
    else
    else
    {
        filename << wxT( "-" ) << GetScreen()->m_ScreenNumber;
        filename << wxT( "-" ) << GetScreen()->m_ScreenNumber;
    }


    return filename;
    return filename;
}
}