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.

124 lines
3.5 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2013 CERN
  5. * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
  6. * @author Jean-Pierre Charras, jp.charras at wanadoo.fr
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. #include <fctsys.h>
  26. #include <common.h>
  27. #include <macros.h>
  28. #include <pl_editor_screen.h>
  29. #include <base_units.h>
  30. #include <pl_editor_id.h>
  31. #define MM_GRID( x ) wxRealPoint( x * IU_PER_MM, x * IU_PER_MM )
  32. #define ZOOM_FACTOR( x ) ( x * IU_PER_MM / 1000 )
  33. /**
  34. Default zoom values.
  35. Roughly a 1.5 progression.
  36. */
  37. static const double pl_editorZoomList[] =
  38. {
  39. ZOOM_FACTOR( 10.0 ), // Zoom in
  40. ZOOM_FACTOR( 15.0 ),
  41. ZOOM_FACTOR( 22.0 ),
  42. ZOOM_FACTOR( 35.0 ),
  43. ZOOM_FACTOR( 50.0 ),
  44. ZOOM_FACTOR( 80.0 ),
  45. ZOOM_FACTOR( 120.0 ),
  46. ZOOM_FACTOR( 160.0 ),
  47. ZOOM_FACTOR( 230.0 ),
  48. ZOOM_FACTOR( 290.0 ),
  49. ZOOM_FACTOR( 380.0 ),
  50. ZOOM_FACTOR( 500.0 ),
  51. ZOOM_FACTOR( 750.0 ),
  52. ZOOM_FACTOR( 1000.0 ),
  53. ZOOM_FACTOR( 1500.0 ),
  54. ZOOM_FACTOR( 2000.0 ),
  55. ZOOM_FACTOR( 3000.0 ),
  56. ZOOM_FACTOR( 4500.0 ), // Zoom out
  57. };
  58. // Default grid sizes for page layout editor screens.
  59. static GRID_TYPE pl_editorGridList[] =
  60. {
  61. // predefined grid list in mm
  62. { ID_POPUP_GRID_LEVEL_1MM, MM_GRID( 1.0 ) },
  63. { ID_POPUP_GRID_LEVEL_0_5MM, MM_GRID( 0.5 ) },
  64. { ID_POPUP_GRID_LEVEL_0_25MM, MM_GRID( 0.25 ) },
  65. { ID_POPUP_GRID_LEVEL_0_2MM, MM_GRID( 0.2 ) },
  66. { ID_POPUP_GRID_LEVEL_0_1MM, MM_GRID( 0.1 ) },
  67. };
  68. PL_EDITOR_SCREEN::PL_EDITOR_SCREEN( const wxSize& aPageSizeIU ) :
  69. BASE_SCREEN( SCREEN_T )
  70. {
  71. for( double zoom : pl_editorZoomList )
  72. m_ZoomList.push_back( zoom );
  73. for( GRID_TYPE grid : pl_editorGridList )
  74. AddGrid( grid );
  75. // pl_editor uses the same frame position as schematic and board editors
  76. m_Center = false;
  77. // Set the working grid size to a reasonable value
  78. SetGrid( MM_GRID( 1.0 ) );
  79. InitDataPoints( aPageSizeIU );
  80. m_NumberOfScreens = 2;
  81. }
  82. PL_EDITOR_SCREEN::~PL_EDITOR_SCREEN()
  83. {
  84. ClearUndoRedoList();
  85. }
  86. void PL_EDITOR_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount )
  87. {
  88. if( aItemCount == 0 )
  89. return;
  90. unsigned icnt = aList.m_CommandsList.size();
  91. if( aItemCount > 0 )
  92. icnt = aItemCount;
  93. for( unsigned ii = 0; ii < icnt; ii++ )
  94. {
  95. if( aList.m_CommandsList.size() == 0 )
  96. break;
  97. PICKED_ITEMS_LIST* curr_cmd = aList.m_CommandsList[0];
  98. aList.m_CommandsList.erase( aList.m_CommandsList.begin() );
  99. curr_cmd->ClearListAndDeleteItems();
  100. delete curr_cmd; // Delete command
  101. }
  102. }