~cern-kicad/kicad/kicad-pns-tom

« back to all changes in this revision

Viewing changes to pagelayout_editor/class_pl_editor_screen.cpp

  • Committer: Maciej Suminski
  • Date: 2013-08-02 13:57:24 UTC
  • mfrom: (4024.1.238 kicad)
  • mto: This revision was merged to the branch mainline in revision 4221.
  • Revision ID: maciej.suminski@cern.ch-20130802135724-gix6orezshkukodv
Upstream merge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * @file class_pl_editor_screen.cpp
 
3
 */
 
4
 
 
5
#include <fctsys.h>
 
6
#include <common.h>
 
7
#include <macros.h>
 
8
#include <class_pl_editor_screen.h>
 
9
#include <base_units.h>
 
10
#include <pl_editor_id.h>
 
11
 
 
12
 
 
13
#define MM_GRID( x ) wxRealPoint( x * IU_PER_MM, x * IU_PER_MM )
 
14
#define ZOOM_FACTOR( x )  ( x * IU_PER_MM / 1000 )
 
15
 
 
16
 
 
17
/**
 
18
    Default zoom values.
 
19
    Roughly a 1.5 progression.
 
20
*/
 
21
static const double pl_editorZoomList[] =
 
22
{
 
23
    ZOOM_FACTOR( 5 ),
 
24
    ZOOM_FACTOR( 7.0 ),
 
25
    ZOOM_FACTOR( 10.0 ),
 
26
    ZOOM_FACTOR( 15.0 ),
 
27
    ZOOM_FACTOR( 22.0 ),
 
28
    ZOOM_FACTOR( 35.0 ),
 
29
    ZOOM_FACTOR( 50.0 ),
 
30
    ZOOM_FACTOR( 80.0 ),
 
31
    ZOOM_FACTOR( 120.0 ),
 
32
    ZOOM_FACTOR( 200.0 ),
 
33
    ZOOM_FACTOR( 350.0 ),
 
34
    ZOOM_FACTOR( 500.0 ),
 
35
    ZOOM_FACTOR( 750.0 ),
 
36
    ZOOM_FACTOR( 1000.0 ),
 
37
    ZOOM_FACTOR( 1500.0 ),
 
38
    ZOOM_FACTOR( 2000.0 ),
 
39
    ZOOM_FACTOR( 3000.0 ),
 
40
};
 
41
 
 
42
 
 
43
// Default grid sizes for PCB editor screens.
 
44
static GRID_TYPE pl_editorGridList[] =
 
45
{
 
46
    // predefined grid list in mm
 
47
    { ID_POPUP_GRID_LEVEL_1MM,      MM_GRID( 1.0 )     },
 
48
    { ID_POPUP_GRID_LEVEL_0_5MM,    MM_GRID( 0.5 )     },
 
49
    { ID_POPUP_GRID_LEVEL_0_25MM,   MM_GRID( 0.25 )    },
 
50
    { ID_POPUP_GRID_LEVEL_0_2MM,    MM_GRID( 0.2 )     },
 
51
    { ID_POPUP_GRID_LEVEL_0_1MM,    MM_GRID( 0.1 )     },
 
52
};
 
53
 
 
54
 
 
55
PL_EDITOR_SCREEN::PL_EDITOR_SCREEN( const wxSize& aPageSizeIU ) :
 
56
    BASE_SCREEN( SCREEN_T )
 
57
{
 
58
    for( unsigned i = 0; i < DIM( pl_editorZoomList );  ++i )
 
59
        m_ZoomList.push_back( pl_editorZoomList[i] );
 
60
 
 
61
    for( unsigned i = 0; i < DIM( pl_editorGridList );  ++i )
 
62
        AddGrid( pl_editorGridList[i] );
 
63
 
 
64
    // Set the working grid size to a reasonable value
 
65
    SetGrid( MM_GRID( 1.0 ) );
 
66
 
 
67
    SetZoom( ZOOM_FACTOR( 350 ) );            // a default value for zoom
 
68
 
 
69
    InitDataPoints( aPageSizeIU );
 
70
    m_NumberOfScreens = 2;
 
71
}
 
72
 
 
73
 
 
74
PL_EDITOR_SCREEN::~PL_EDITOR_SCREEN()
 
75
{
 
76
    ClearUndoRedoList();
 
77
}
 
78
 
 
79
 
 
80
// virtual function
 
81
int PL_EDITOR_SCREEN::MilsToIuScalar()
 
82
{
 
83
    return (int)IU_PER_MILS;
 
84
}
 
85
 
 
86
 
 
87
/* Virtual function needed by classes derived from BASE_SCREEN
 
88
 * this is a virtual pure function in BASE_SCREEN
 
89
 */
 
90
void PL_EDITOR_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList,
 
91
                                            int aItemCount )
 
92
{
 
93
    if( aItemCount == 0 )
 
94
        return;
 
95
 
 
96
    unsigned icnt = aList.m_CommandsList.size();
 
97
 
 
98
    if( aItemCount > 0 )
 
99
        icnt = aItemCount;
 
100
 
 
101
    for( unsigned ii = 0; ii < icnt; ii++ )
 
102
    {
 
103
        if( aList.m_CommandsList.size() == 0 )
 
104
            break;
 
105
 
 
106
        PICKED_ITEMS_LIST* curr_cmd = aList.m_CommandsList[0];
 
107
        aList.m_CommandsList.erase( aList.m_CommandsList.begin() );
 
108
 
 
109
        curr_cmd->ClearListAndDeleteItems();
 
110
        delete curr_cmd;    // Delete command
 
111
    }
 
112
}