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.

125 lines
3.3 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2007-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.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. #include <fctsys.h>
  25. #include <class_drawpanel.h>
  26. #include <confirm.h>
  27. #include <pcbnew.h>
  28. #include <pcb_edit_frame.h>
  29. #include <pcbnew_id.h>
  30. #include <kicad_device_context.h>
  31. /* Handle microwave commands.
  32. */
  33. void PCB_EDIT_FRAME::ProcessMuWaveFunctions( wxCommandEvent& event )
  34. {
  35. int id = event.GetId();
  36. wxPoint pos;
  37. INSTALL_UNBUFFERED_DC( dc, m_canvas );
  38. wxGetMousePosition( &pos.x, &pos.y );
  39. pos.y += 20;
  40. switch( id ) // End any command in progress.
  41. {
  42. case ID_POPUP_DUPLICATE_BLOCK:
  43. break;
  44. default: // End block command in progress.
  45. m_canvas->EndMouseCapture( );
  46. break;
  47. }
  48. switch( id )
  49. {
  50. case ID_PCB_MUWAVE_TOOL_SELF_CMD:
  51. SetToolID( id, wxCURSOR_PENCIL, _( "Add Line" ) );
  52. break;
  53. case ID_PCB_MUWAVE_TOOL_GAP_CMD:
  54. SetToolID( id, wxCURSOR_PENCIL, _( "Add Gap" ) );
  55. break;
  56. case ID_PCB_MUWAVE_TOOL_STUB_CMD:
  57. SetToolID( id, wxCURSOR_PENCIL, _( "Add Stub" ) );
  58. break;
  59. case ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD:
  60. SetToolID( id, wxCURSOR_PENCIL, _( "Add Arc Stub" ) );
  61. break;
  62. case ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD:
  63. SetToolID( id, wxCURSOR_PENCIL, _( "Add Polynomial Shape" ) );
  64. break;
  65. default:
  66. wxLogDebug( wxT( "id %d error" ), id );
  67. break;
  68. }
  69. }
  70. void PCB_EDIT_FRAME::MuWaveCommand( wxDC* DC, const wxPoint& MousePos )
  71. {
  72. MODULE* module = NULL;
  73. switch( GetToolId() )
  74. {
  75. case ID_PCB_MUWAVE_TOOL_SELF_CMD:
  76. Begin_Self( DC );
  77. break;
  78. case ID_PCB_MUWAVE_TOOL_GAP_CMD:
  79. module = Create_MuWaveComponent( 0 );
  80. break;
  81. case ID_PCB_MUWAVE_TOOL_STUB_CMD:
  82. module = Create_MuWaveComponent( 1 );
  83. break;
  84. case ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD:
  85. module = Create_MuWaveComponent( 2 );
  86. break;
  87. case ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD:
  88. module = Create_MuWavePolygonShape();
  89. break;
  90. default:
  91. m_canvas->SetCursor( wxCURSOR_ARROW );
  92. wxLogDebug( wxT( "id %d error" ), GetToolId() );
  93. SetNoToolSelected();
  94. break;
  95. }
  96. if( module )
  97. {
  98. StartMoveModule( module, DC, false );
  99. }
  100. m_canvas->MoveCursorToCrossHair();
  101. }