You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
4.4 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
  5. * Copyright (C) 1992-2014 KiCad Developers, see change_log.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. /**
  25. * @file gbr_screen.cpp
  26. */
  27. #include <fctsys.h>
  28. #include <common.h>
  29. #include <macros.h>
  30. #include <gbr_screen.h>
  31. #include <gerbview_id.h>
  32. #define MIL_GRID( x ) wxRealPoint( x * IU_PER_MILS,\
  33. x * IU_PER_MILS)
  34. #define MM_GRID( x ) wxRealPoint( x * IU_PER_MM,\
  35. x * IU_PER_MM )
  36. /**
  37. Default GerbView zoom values.
  38. Roughly a 1.5 progression.
  39. */
  40. static const double gbrZoomList[] =
  41. {
  42. ZOOM_FACTOR( 0.05 ),
  43. ZOOM_FACTOR( 0.075 ),
  44. ZOOM_FACTOR( 0.1 ),
  45. ZOOM_FACTOR( 0.15 ),
  46. ZOOM_FACTOR( 0.2 ),
  47. ZOOM_FACTOR( 0.3 ),
  48. ZOOM_FACTOR( 0.45 ),
  49. ZOOM_FACTOR( 0.7 ),
  50. ZOOM_FACTOR( 1.0 ),
  51. ZOOM_FACTOR( 1.5 ),
  52. ZOOM_FACTOR( 2.2 ),
  53. ZOOM_FACTOR( 3.5 ),
  54. ZOOM_FACTOR( 5.0 ),
  55. ZOOM_FACTOR( 8.0 ),
  56. ZOOM_FACTOR( 11.0 ),
  57. ZOOM_FACTOR( 15.0 ),
  58. ZOOM_FACTOR( 20.0 ),
  59. ZOOM_FACTOR( 35.0 ),
  60. ZOOM_FACTOR( 50.0 ),
  61. ZOOM_FACTOR( 100.0 ),
  62. ZOOM_FACTOR( 200.0 )
  63. };
  64. // Default grid sizes for PCB editor screens.
  65. static GRID_TYPE gbrGridList[] =
  66. {
  67. // predefined grid list in mils
  68. { ID_POPUP_GRID_LEVEL_1000, MIL_GRID( 100 ) },
  69. { ID_POPUP_GRID_LEVEL_500, MIL_GRID( 50 ) },
  70. { ID_POPUP_GRID_LEVEL_250, MIL_GRID( 25 ) },
  71. { ID_POPUP_GRID_LEVEL_200, MIL_GRID( 20 ) },
  72. { ID_POPUP_GRID_LEVEL_100, MIL_GRID( 10 ) },
  73. { ID_POPUP_GRID_LEVEL_50, MIL_GRID( 5 ) },
  74. { ID_POPUP_GRID_LEVEL_25, MIL_GRID( 2.5 ) },
  75. { ID_POPUP_GRID_LEVEL_20, MIL_GRID( 2 ) },
  76. { ID_POPUP_GRID_LEVEL_10, MIL_GRID( 1 ) },
  77. { ID_POPUP_GRID_LEVEL_5, MIL_GRID( 0.5 ) },
  78. { ID_POPUP_GRID_LEVEL_2, MIL_GRID( 0.2 ) },
  79. { ID_POPUP_GRID_LEVEL_1, MIL_GRID( 0.1 ) },
  80. // predefined grid list in mm
  81. { ID_POPUP_GRID_LEVEL_5MM, MM_GRID( 5.0 ) },
  82. { ID_POPUP_GRID_LEVEL_2_5MM, MM_GRID( 2.5 ) },
  83. { ID_POPUP_GRID_LEVEL_1MM, MM_GRID( 1.0 ) },
  84. { ID_POPUP_GRID_LEVEL_0_5MM, MM_GRID( 0.5 ) },
  85. { ID_POPUP_GRID_LEVEL_0_25MM, MM_GRID( 0.25 ) },
  86. { ID_POPUP_GRID_LEVEL_0_2MM, MM_GRID( 0.2 ) },
  87. { ID_POPUP_GRID_LEVEL_0_1MM, MM_GRID( 0.1 ) },
  88. { ID_POPUP_GRID_LEVEL_0_0_5MM, MM_GRID( 0.05 ) },
  89. { ID_POPUP_GRID_LEVEL_0_0_25MM, MM_GRID( 0.025 ) },
  90. { ID_POPUP_GRID_LEVEL_0_0_1MM, MM_GRID( 0.01 ) }
  91. };
  92. GBR_SCREEN::GBR_SCREEN( const wxSize& aPageSizeIU ) :
  93. BASE_SCREEN( SCREEN_T )
  94. {
  95. for( unsigned i = 0; i < DIM( gbrZoomList ); ++i )
  96. m_ZoomList.push_back( gbrZoomList[i] );
  97. for( unsigned i = 0; i < DIM( gbrGridList ); ++i )
  98. AddGrid( gbrGridList[i] );
  99. // Set the working grid size to a reasonable value
  100. SetGrid( MIL_GRID( 50 ) );
  101. SetZoom( ZOOM_FACTOR( 350 ) ); // a default value for zoom
  102. m_Active_Layer = 0; // default active layer = first graphic layer
  103. InitDataPoints( aPageSizeIU );
  104. }
  105. GBR_SCREEN::~GBR_SCREEN()
  106. {
  107. ClearUndoRedoList();
  108. }
  109. // virtual function
  110. int GBR_SCREEN::MilsToIuScalar()
  111. {
  112. return (int)IU_PER_MILS;
  113. }
  114. /* Virtual function needed by classes derived from BASE_SCREEN
  115. * this is a virtual pure function in BASE_SCREEN
  116. * do nothing in GerbView
  117. * could be removed later
  118. */
  119. void GBR_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER&, int )
  120. {
  121. }