gerbview_dialog_display_options_frame.cpp 4.37 KB
Newer Older
1 2 3
/**
 * @file gerbview_dialog_display_options_frame.cpp
 * Set some display options for GerbView
4 5 6
 */


7 8 9 10 11 12 13 14
#include <fctsys.h>
#include <common.h>
#include <macros.h>
#include <class_drawpanel.h>

#include <pcbplot.h>
#include <gerbview.h>
#include <gerbview_dialog_display_options_frame_base.h>
15 16 17 18 19 20 21 22


/*******************************************/
/* Dialog frame to select display options */
/*******************************************/
class DIALOG_DISPLAY_OPTIONS : public DIALOG_DISPLAY_OPTIONS_BASE
{
private:
23
    GERBVIEW_FRAME* m_Parent;
24 25 26

public:

27
    DIALOG_DISPLAY_OPTIONS( GERBVIEW_FRAME* parent );
28 29 30 31 32
    ~DIALOG_DISPLAY_OPTIONS() {};

private:
    void OnOKBUttonClick( wxCommandEvent& event );
    void OnCancelButtonClick( wxCommandEvent& event );
33
    void initOptDialog( );
34 35 36 37
    void OnMiddleBtnPanEnbl( wxCommandEvent& event )
    {
        m_OptMiddleButtonPanLimited->Enable( m_OptMiddleButtonPan->GetValue() );
    }
38 39 40
};


41
void GERBVIEW_FRAME::InstallGerberOptionsDialog( wxCommandEvent& event )
42
{
43 44
    DIALOG_DISPLAY_OPTIONS dlg( this );
    int opt = dlg.ShowModal();
45

46 47
    if( opt > 0 )
        m_canvas->Refresh();
48 49
}

50
DIALOG_DISPLAY_OPTIONS::DIALOG_DISPLAY_OPTIONS( GERBVIEW_FRAME *parent) :
51 52 53 54
    DIALOG_DISPLAY_OPTIONS_BASE( parent, wxID_ANY )
{
    m_Parent = parent;
    SetFocus();
55
    initOptDialog( );
56

57 58 59
    GetSizer()->Fit( this );
    GetSizer()->SetSizeHints( this );
    Center();
60
    m_sdbSizer1OK->SetDefault();
61 62 63
}


64
void DIALOG_DISPLAY_OPTIONS::OnCancelButtonClick( wxCommandEvent& event )
65 66 67 68
{
    EndModal( 0 );
}

69

70 71
void DIALOG_DISPLAY_OPTIONS::initOptDialog( )
{
72
    m_PolarDisplay->SetSelection( m_Parent->m_DisplayOptions.m_DisplayPolarCood ? 1 : 0 );
73
    m_BoxUnits->SetSelection( g_UserUnit ? 1 : 0 );
74
    m_CursorShape->SetSelection( m_Parent->GetCursorShape() ? 1 : 0 );
75

76
    // Show Option Draw Lines. We use DisplayPcbTrackFill as Lines draw option
77 78
    m_OptDisplayLines->SetSelection( m_Parent->m_DisplayOptions.m_DisplayLinesFill ? 1 : 0 );
    m_OptDisplayFlashedItems->SetSelection( m_Parent->m_DisplayOptions.m_DisplayFlashedItemsFill ? 1 : 0);
79

80
    // Show Option Draw polygons
81
    m_OptDisplayPolygons->SetSelection( m_Parent->m_DisplayOptions.m_DisplayPolygonsFill ? 1 : 0 );
82 83

    m_ShowPageLimits->SetSelection(0);
84 85

    if( m_Parent->GetShowBorderAndTitleBlock() )
86
    {
87 88 89
        wxString    curPaperType = m_Parent->GetPageSettings().GetType();

        for( unsigned i = 1;  i < DIM( g_GerberPageSizeList );  ++i )
90
        {
91
            if( g_GerberPageSizeList[i] == curPaperType )
92
            {
93
                m_ShowPageLimits->SetSelection( i );
94 95 96 97 98
                break;
            }
        }
    }

charras's avatar
charras committed
99
    m_OptDisplayDCodes->SetValue( m_Parent->IsElementVisible( DCODES_VISIBLE ) );
100 101 102 103

    m_OptMiddleButtonPan->SetValue( m_Parent->GetCanvas()->GetEnableMiddleButtonPan() );
    m_OptMiddleButtonPanLimited->SetValue( m_Parent->GetCanvas()->GetMiddleButtonPanLimited() );
    m_OptMiddleButtonPanLimited->Enable( m_OptMiddleButtonPan->GetValue() );
104 105
}

106

107 108
void DIALOG_DISPLAY_OPTIONS::OnOKBUttonClick( wxCommandEvent& event )
{
109
    m_Parent->m_DisplayOptions.m_DisplayPolarCood =
110
        (m_PolarDisplay->GetSelection() == 0) ? false : true;
111
    g_UserUnit  = (m_BoxUnits->GetSelection() == 0) ? INCHES : MILLIMETRES;
112
    m_Parent->SetCursorShape( m_CursorShape->GetSelection() );
113

114
    if( m_OptDisplayLines->GetSelection() == 1 )
115
        m_Parent->m_DisplayOptions.m_DisplayLinesFill = true;
116
    else
117
        m_Parent->m_DisplayOptions.m_DisplayLinesFill = false;
118 119 120

    if( m_OptDisplayFlashedItems->GetSelection() == 1 )
    {
121
        m_Parent->m_DisplayOptions.m_DisplayFlashedItemsFill = true;
122 123 124
    }
    else
    {
125
        m_Parent->m_DisplayOptions.m_DisplayFlashedItemsFill = false;
126 127 128 129
    }


    if( m_OptDisplayPolygons->GetSelection() == 0 )
130
        m_Parent->m_DisplayOptions.m_DisplayPolygonsFill = false;
131
    else
132
        m_Parent->m_DisplayOptions.m_DisplayPolygonsFill = true;
133

charras's avatar
charras committed
134
    m_Parent->SetElementVisibility( DCODES_VISIBLE, m_OptDisplayDCodes->GetValue() );
135 136 137

    int idx = m_ShowPageLimits->GetSelection();

138 139 140 141 142
    m_Parent->SetShowBorderAndTitleBlock( idx > 0  ?  true : false );

    PAGE_INFO   pageInfo( g_GerberPageSizeList[idx] );

    m_Parent->SetPageSettings( pageInfo );
143

144 145 146 147 148
    m_Parent->GetCanvas()->SetEnableMiddleButtonPan( m_OptMiddleButtonPan->GetValue() );
    m_Parent->GetCanvas()->SetMiddleButtonPanLimited( m_OptMiddleButtonPanLimited->GetValue() );

    m_Parent->GetCanvas()->Refresh();

149 150 151
    EndModal( 1 );
}