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.

82 lines
2.8 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2014 CERN
  5. * @author Maciej Suminski <maciej.suminski@cern.ch>
  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. #include <pcb_base_edit_frame.h>
  25. #include <tool/tool_manager.h>
  26. #include <pcb_draw_panel_gal.h>
  27. #include <gal/graphics_abstraction_layer.h>
  28. #include <class_board.h>
  29. #include <view/view.h>
  30. void PCB_BASE_EDIT_FRAME::SetRotationAngle( int aRotationAngle )
  31. {
  32. wxCHECK2_MSG( aRotationAngle > 0 && aRotationAngle <= 900, aRotationAngle = 900,
  33. wxT( "Invalid rotation angle, defaulting to 90." ) );
  34. m_rotationAngle = aRotationAngle;
  35. }
  36. void PCB_BASE_EDIT_FRAME::UseGalCanvas( bool aEnable )
  37. {
  38. PCB_BASE_FRAME::UseGalCanvas( aEnable );
  39. // No matter what, reenable undo/redo on switching to the legacy canvas
  40. if( !aEnable )
  41. UndoRedoBlock( false );
  42. else
  43. static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( m_Pcb );
  44. }
  45. void PCB_BASE_EDIT_FRAME::SetBoard( BOARD* aBoard )
  46. {
  47. bool new_board = ( aBoard != m_Pcb );
  48. // The active tool might store a reference to the BOARD that is about to be deleted.
  49. if( m_toolManager )
  50. m_toolManager->DeactivateTool();
  51. // It has to be done before the previous board is destroyed by SetBoard()
  52. if( new_board )
  53. GetGalCanvas()->GetView()->Clear();
  54. PCB_BASE_FRAME::SetBoard( aBoard );
  55. GetGalCanvas()->GetGAL()->SetGridOrigin( VECTOR2D( aBoard->GetGridOrigin() ) );
  56. // update the tool manager with the new board and its view.
  57. if( m_toolManager )
  58. {
  59. PCB_DRAW_PANEL_GAL* drawPanel = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
  60. drawPanel->DisplayBoard( aBoard );
  61. m_toolManager->SetEnvironment( aBoard, drawPanel->GetView(),
  62. drawPanel->GetViewControls(), this );
  63. if( new_board )
  64. m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
  65. }
  66. }