Commit 1393eb0f authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

finish up SCH_SHEET::{Set,Get}PageSettings() switch over

parent d3afe95c
Loading
Loading
Loading
Loading
+60 −78
Original line number Original line Diff line number Diff line
@@ -176,26 +176,31 @@ bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString )


//-----<PAGE_INFO>-------------------------------------------------------------
//-----<PAGE_INFO>-------------------------------------------------------------


// Standard page sizes in 1/1000 inch
// Standard page sizes in mils
#if defined(KICAD_GOST)
#if defined(KICAD_GOST)
static const PAGE_INFO  pageA4(    wxSize(  8283, 11700 ),  wxT( "A4" ) );
const PAGE_INFO  PAGE_INFO::pageA4(    wxSize(  8283, 11700 ),  wxT( "A4" ) );
#else
#else
static const PAGE_INFO  pageA4(    wxSize( 11700,  8267 ),  wxT( "A4" ) );
const PAGE_INFO  PAGE_INFO::pageA4(    wxSize( 11700,  8267 ),  wxT( "A4" ) );
#endif
#endif
static const PAGE_INFO  pageA3(    wxSize( 16535, 11700 ),  wxT( "A3" ) );
const PAGE_INFO  PAGE_INFO::pageA3(    wxSize( 16535, 11700 ),  wxT( "A3" ) );
static const PAGE_INFO  pageA2(    wxSize( 23400, 16535 ),  wxT( "A2" ) );
const PAGE_INFO  PAGE_INFO::pageA2(    wxSize( 23400, 16535 ),  wxT( "A2" ) );
static const PAGE_INFO  pageA1(    wxSize( 33070, 23400 ),  wxT( "A1" ) );
const PAGE_INFO  PAGE_INFO::pageA1(    wxSize( 33070, 23400 ),  wxT( "A1" ) );
static const PAGE_INFO  pageA0(    wxSize( 46800, 33070 ),  wxT( "A0" ) );
const PAGE_INFO  PAGE_INFO::pageA0(    wxSize( 46800, 33070 ),  wxT( "A0" ) );
static const PAGE_INFO  pageA(     wxSize( 11000,  8500 ),  wxT( "A" ) );
const PAGE_INFO  PAGE_INFO::pageA(     wxSize( 11000,  8500 ),  wxT( "A" ) );
static const PAGE_INFO  pageB(     wxSize( 17000, 11000 ),  wxT( "B" ) );
const PAGE_INFO  PAGE_INFO::pageB(     wxSize( 17000, 11000 ),  wxT( "B" ) );
static const PAGE_INFO  pageC(     wxSize( 22000, 17000 ),  wxT( "C" ) );
const PAGE_INFO  PAGE_INFO::pageC(     wxSize( 22000, 17000 ),  wxT( "C" ) );
static const PAGE_INFO  pageD(     wxSize( 34000, 22000 ),  wxT( "D" ) );
const PAGE_INFO  PAGE_INFO::pageD(     wxSize( 34000, 22000 ),  wxT( "D" ) );
static const PAGE_INFO  pageE(     wxSize( 44000, 34000 ),  wxT( "E" ) );
const PAGE_INFO  PAGE_INFO::pageE(     wxSize( 44000, 34000 ),  wxT( "E" ) );
static const PAGE_INFO  pageGERBER(wxSize( 32000, 32000 ),  wxT( "GERBER" ) );
const PAGE_INFO  PAGE_INFO::pageGERBER(wxSize( 32000, 32000 ),  wxT( "GERBER" ) );

const PAGE_INFO  PAGE_INFO::pageUser(  wxSize( 17000, 11000 ),  wxT( "User" ) );
double PAGE_INFO::s_user_width  = 17.0;

double PAGE_INFO::s_user_height = 11.0;
int PAGE_INFO::s_user_width  = 17000;
static const PAGE_INFO  pageUser(  wxSize( 17000, 11000 ),  wxT( "User" ) );
int PAGE_INFO::s_user_height = 11000;

/*
wxArrayString PAGE_INFO::GetStandardSizes()
{
    wxArrayString ret;


    static const PAGE_INFO* stdPageSizes[] = {
    static const PAGE_INFO* stdPageSizes[] = {
        &pageA4,
        &pageA4,
@@ -208,21 +213,16 @@ static const PAGE_INFO* stdPageSizes[] = {
        &pageC,
        &pageC,
        &pageD,
        &pageD,
        &pageE,
        &pageE,
    // &pageGERBER,  omitted, not standard
        // &pageGERBER,     // standard?
        &pageUser,
        &pageUser,
    };
    };



wxArrayString PAGE_INFO::GetStandardSizes()
{
    wxArrayString ret;

    for( unsigned i=0;  i < DIM( stdPageSizes );  ++i )
    for( unsigned i=0;  i < DIM( stdPageSizes );  ++i )
        ret.Add( stdPageSizes[i]->GetType() );
        ret.Add( stdPageSizes[i]->GetType() );


    return ret;
    return ret;
}
}

*/


bool PAGE_INFO::SetType( const wxString& aType )
bool PAGE_INFO::SetType( const wxString& aType )
{
{
@@ -252,9 +252,13 @@ bool PAGE_INFO::SetType( const wxString& aType )
        *this = pageGERBER;
        *this = pageGERBER;
    else if( aType == pageUser.GetType() )
    else if( aType == pageUser.GetType() )
    {
    {
        // pageUser is const, and may not and does not hold the custom size,
        // so customize *this later
        *this  = pageUser;
        *this  = pageUser;
        m_widthInches  = s_user_width;

        m_heightInches = s_user_height;
        // customize:
        m_size.x = s_user_width;
        m_size.y = s_user_height;
    }
    }
    else
    else
        rc = false;
        rc = false;
@@ -263,22 +267,18 @@ bool PAGE_INFO::SetType( const wxString& aType )
}
}




PAGE_INFO::PAGE_INFO( const wxSize& aSizeMils, const wxString& aType )
PAGE_INFO::PAGE_INFO( const wxSize& aSizeMils, const wxString& aType ) :
    m_size( aSizeMils )
{
{
    // aSizeMils is in 1/1000th of an inch
    m_type   = aType;
    SetWidthInches(  aSizeMils.x / 1000.0 );
    SetHeightInches( aSizeMils.y / 1000.0 );

    m_Type   = aType;


    // Adjust the default value for margins to 400 mils (0,4 inch or 10 mm)
#if defined(KICAD_GOST)
#if defined(KICAD_GOST)
    m_LeftMargin   = GOST_LEFTMARGIN;
    m_left_margin   = GOST_LEFTMARGIN;
    m_RightMargin  = GOST_RIGHTMARGIN;
    m_right_margin  = GOST_RIGHTMARGIN;
    m_TopMargin    = GOST_TOPMARGIN;
    m_top_margin    = GOST_TOPMARGIN;
    m_BottomMargin = GOST_BOTTOMMARGIN;
    m_bottom_margin = GOST_BOTTOMMARGIN;
#else
#else
    m_LeftMargin = m_RightMargin = m_TopMargin = m_BottomMargin = 400;
    m_left_margin = m_right_margin = m_top_margin = m_bottom_margin = 400;
#endif
#endif
}
}


@@ -289,42 +289,24 @@ PAGE_INFO::PAGE_INFO( const wxString& aType )
}
}




void PAGE_INFO::SetWidthInches( double aWidthInInches )
void PAGE_INFO::SetUserWidthMils( int aWidthInMils )
{
    // limit resolution to 1/1000th of an inch
    int mils = aWidthInInches * 1000 + 0.5;

    m_widthInches = mils / 1000.0;
}


void PAGE_INFO::SetHeightInches( double aHeightInInches )
{
    // limit resolution to 1/1000th of an inch
    int mils = aHeightInInches * 1000 + 0.5;

    m_heightInches = mils / 1000.0;
}


void PAGE_INFO::SetUserWidthInches( double aWidthInInches )
{
{
    if( aWidthInInches < 6.0 )
    if( aWidthInMils < 6000 )
        aWidthInInches = 6.0;
        aWidthInMils = 6000;
    else if( aWidthInInches > 44.0 )
    else if( aWidthInMils > 44000 )
        aWidthInInches = 44.0;
        aWidthInMils = 44000;


    s_user_width = aWidthInInches;
    s_user_width = aWidthInMils;
}
}


void PAGE_INFO::SetUserHeightInches( double aHeightInInches )
void PAGE_INFO::SetUserHeightMils( int aHeightInMils )
{
{
    if( aHeightInInches < 4.0 )
    if( aHeightInMils < 4000 )
        aHeightInInches = 4.0;
        aHeightInMils = 4000;
    else if( aHeightInInches > 44.0 )
    else if( aHeightInMils > 44000 )
        aHeightInInches = 44.0;
        aHeightInMils = 44000;


    s_user_height = aHeightInInches;
    s_user_height = aHeightInMils;
}
}




+13 −13
Original line number Original line Diff line number Diff line
@@ -79,8 +79,8 @@ void DIALOG_PAGES_SETTINGS::initDialog()
    switch( g_UserUnit )
    switch( g_UserUnit )
    {
    {
    case MILLIMETRES:
    case MILLIMETRES:
        userSizeX  = m_user_size.GetWidthInches()  * 25.4;
        userSizeX  = m_user_size.GetWidthMils()  * 25.4e-3;
        userSizeY  = m_user_size.GetHeightInches() * 25.4;
        userSizeY  = m_user_size.GetHeightMils() * 25.4e-3;


        msg.Printf( wxT( "%.2f" ), userSizeX );
        msg.Printf( wxT( "%.2f" ), userSizeX );
        m_TextUserSizeX->SetValue( msg );
        m_TextUserSizeX->SetValue( msg );
@@ -91,8 +91,8 @@ void DIALOG_PAGES_SETTINGS::initDialog()


    default:
    default:
    case INCHES:
    case INCHES:
        userSizeX  = m_user_size.GetWidthInches();
        userSizeX  = m_user_size.GetWidthMils() / 1000.0;
        userSizeY  = m_user_size.GetHeightInches();
        userSizeY  = m_user_size.GetHeightMils() / 1000.0;


        msg.Printf( wxT( "%.3f" ), userSizeX );
        msg.Printf( wxT( "%.3f" ), userSizeX );
        m_TextUserSizeX->SetValue( msg );
        m_TextUserSizeX->SetValue( msg );
@@ -101,10 +101,10 @@ void DIALOG_PAGES_SETTINGS::initDialog()
        m_TextUserSizeY->SetValue( msg );
        m_TextUserSizeY->SetValue( msg );
        break;
        break;


/*  // you want it in 1/1000ths of an inch, why?
/*  // you want it in mils, why?
    case UNSCALED_UNITS:
    case UNSCALED_UNITS:
        userSizeX  = m_user_size.GetWidthInches() * 1000;
        userSizeX  = m_user_size.GetWidthMils();
        userSizeY  = m_user_size.GetHeightInches() * 1000;
        userSizeY  = m_user_size.GetHeightMils();
        msg.Printf( wxT( "%f" ), m_userSizeX );
        msg.Printf( wxT( "%f" ), m_userSizeX );
        m_TextUserSizeX->SetValue( msg );
        m_TextUserSizeX->SetValue( msg );
        msg.Printf( wxT( "%f" ), m_userSizeY );
        msg.Printf( wxT( "%f" ), m_userSizeY );
@@ -204,20 +204,20 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event )
    switch( g_UserUnit )
    switch( g_UserUnit )
    {
    {
    case MILLIMETRES:
    case MILLIMETRES:
        PAGE_INFO::SetUserWidthInches( userSizeX / 25.4 );
        PAGE_INFO::SetUserWidthMils( int( userSizeX * 1000.0 / 25.4 ) );
        PAGE_INFO::SetUserHeightInches( userSizeY / 25.4 );
        PAGE_INFO::SetUserHeightMils( int( userSizeY * 1000.0 / 25.4 ) );
        break;
        break;


    default:
    default:
    case INCHES:
    case INCHES:
        PAGE_INFO::SetUserWidthInches( userSizeX );
        PAGE_INFO::SetUserWidthMils( int( 1000 * userSizeX ) );
        PAGE_INFO::SetUserHeightInches( userSizeY );
        PAGE_INFO::SetUserHeightMils( int( 1000 * userSizeY ) );
        break;
        break;


/*      // set in 1/1000ths of an inch, but why?
/*      // set in 1/1000ths of an inch, but why?
    case UNSCALED_UNITS:
    case UNSCALED_UNITS:
        PAGE_INFO::SetUserWidthInches( userSizeX /1000 );
        PAGE_INFO::SetUserWidthMils( (int) userSizeX );
        PAGE_INFO::SetUserHeightInches( userSizeY /1000 );
        PAGE_INFO::SetUserHeightMils( (int) userSizeY );
        break;
        break;
*/
*/
    }
    }
+0 −1
Original line number Original line Diff line number Diff line
@@ -238,7 +238,6 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame,
    screen->m_IsPrinting   = false;
    screen->m_IsPrinting   = false;
    panel->m_ClipBox       = tmp;
    panel->m_ClipBox       = tmp;



    GRForceBlackPen( false );
    GRForceBlackPen( false );


    screen->m_StartVisu    = tmp_startvisu;
    screen->m_StartVisu    = tmp_startvisu;
+3 −3
Original line number Original line Diff line number Diff line
@@ -100,7 +100,7 @@ private:
    void OnPlotCurrent( wxCommandEvent& event );
    void OnPlotCurrent( wxCommandEvent& event );
    void OnPlotAll( wxCommandEvent& event );
    void OnPlotAll( wxCommandEvent& event );
    void OnCancelClick( wxCommandEvent& event );
    void OnCancelClick( wxCommandEvent& event );
    void AcceptplotOffset( wxCommandEvent& event );
    void AcceptPlotOffset( wxCommandEvent& event );


    void initDlg();
    void initDlg();
    void SetPenSpeed();
    void SetPenSpeed();
@@ -119,7 +119,7 @@ private:
// static members (static to remember last state):
// static members (static to remember last state):
HPGL_PAGEZ_T DIALOG_PLOT_SCHEMATIC_HPGL:: s_pageSizeSelect = PAGE_DEFAULT;
HPGL_PAGEZ_T DIALOG_PLOT_SCHEMATIC_HPGL:: s_pageSizeSelect = PAGE_DEFAULT;
bool DIALOG_PLOT_SCHEMATIC_HPGL::s_plot_Sheet_Ref = true;
bool DIALOG_PLOT_SCHEMATIC_HPGL::s_plot_Sheet_Ref = true;

wxSize DIALOG_PLOT_SCHEMATIC_HPGL::s_Offset;


void SCH_EDIT_FRAME::ToPlot_HPGL( wxCommandEvent& event )
void SCH_EDIT_FRAME::ToPlot_HPGL( wxCommandEvent& event )
{
{
@@ -202,7 +202,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::SetPageOffsetValue()
}
}




void DIALOG_PLOT_SCHEMATIC_HPGL::AcceptplotOffset( wxCommandEvent& event )
void DIALOG_PLOT_SCHEMATIC_HPGL::AcceptPlotOffset( wxCommandEvent& event )
{
{
    s_pageSizeSelect = (HPGL_PAGEZ_T) m_SizeOption->GetSelection();
    s_pageSizeSelect = (HPGL_PAGEZ_T) m_SizeOption->GetSelection();


+10 −9
Original line number Original line Diff line number Diff line
@@ -95,7 +95,7 @@ DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( SCH_EDIT_FRAME* aParent
    m_checkMonochrome->SetValue( aParent->GetPrintMonochrome() );
    m_checkMonochrome->SetValue( aParent->GetPrintMonochrome() );


#ifdef __WXMAC__
#ifdef __WXMAC__
    /* Problems with modal on wx-2.9 - Anyway preview is standard for OSX */
    // Problems with modal on wx-2.9 - Anyway preview is standard for OSX
   m_buttonPreview->Hide();
   m_buttonPreview->Hide();
#endif
#endif
}
}
@@ -310,7 +310,7 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
{
{
    int      oldZoom;
    int      oldZoom;
    wxPoint  tmp_startvisu;
    wxPoint  tmp_startvisu;
    wxSize   SheetSize;      // Page size in internal units
    wxSize   pageSizeIU;             // Page size in internal units
    wxPoint  old_org;
    wxPoint  old_org;
    EDA_RECT oldClipBox;
    EDA_RECT oldClipBox;
    wxRect   fitRect;
    wxRect   fitRect;
@@ -320,13 +320,13 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )


    wxBusyCursor dummy;
    wxBusyCursor dummy;


    /* Save current scale factor, offsets, and clip box. */
    // Save current scale factor, offsets, and clip box.
    tmp_startvisu = aScreen->m_StartVisu;
    tmp_startvisu = aScreen->m_StartVisu;
    oldZoom = aScreen->GetZoom();
    oldZoom = aScreen->GetZoom();
    old_org = aScreen->m_DrawOrg;
    old_org = aScreen->m_DrawOrg;
    oldClipBox = panel->m_ClipBox;
    oldClipBox = panel->m_ClipBox;


    /* Change scale factor, offsets, and clip box to print the whole page. */
    // Change scale factor, offsets, and clip box to print the whole page.
    panel->m_ClipBox.SetOrigin( wxPoint( 0, 0 ) );
    panel->m_ClipBox.SetOrigin( wxPoint( 0, 0 ) );
    panel->m_ClipBox.SetSize( wxSize( 0x7FFFFF0, 0x7FFFFF0 ) );
    panel->m_ClipBox.SetSize( wxSize( 0x7FFFFF0, 0x7FFFFF0 ) );


@@ -346,16 +346,17 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
        wxLogDebug( wxT( "MinX = %d, MaxX = %d, MinY = %d, MaxY = %d" ),
        wxLogDebug( wxT( "MinX = %d, MaxX = %d, MinY = %d, MaxY = %d" ),
                    memDC.MinX(), memDC.MaxX(), memDC.MinY(), memDC.MaxY() );
                    memDC.MinX(), memDC.MaxX(), memDC.MinY(), memDC.MaxY() );


        SheetSize.x = memDC.MaxX() - memDC.MinX();
        pageSizeIU.x = memDC.MaxX() - memDC.MinX();
        SheetSize.y = memDC.MaxY() - memDC.MinY();
        pageSizeIU.y = memDC.MaxY() - memDC.MinY();


        FitThisSizeToPageMargins( SheetSize, parent->GetPageSetupData() );
        FitThisSizeToPageMargins( pageSizeIU, parent->GetPageSetupData() );
        fitRect = GetLogicalPageMarginsRect( parent->GetPageSetupData() );
        fitRect = GetLogicalPageMarginsRect( parent->GetPageSetupData() );
    }
    }
    else
    else
    {
    {
        SheetSize = aScreen->m_CurrentSheetDesc->m_Size;
        pageSizeIU = aScreen->GetPageSettings().GetSizeIU();
        FitThisSizeToPaper( SheetSize );

        FitThisSizeToPaper( pageSizeIU );
        fitRect = GetLogicalPaperRect();
        fitRect = GetLogicalPaperRect();
    }
    }


Loading