KiCad PCB EDA Suite
muwave_command.cpp
Go to the documentation of this file.
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 
25 #include <fctsys.h>
26 #include <class_drawpanel.h>
27 #include <confirm.h>
28 #include <pcbnew.h>
29 #include <wxPcbStruct.h>
30 
31 #include <pcbnew_id.h>
32 #include <kicad_device_context.h>
33 
34 
35 /* Handle microwave commands.
36  */
37 void PCB_EDIT_FRAME::ProcessMuWaveFunctions( wxCommandEvent& event )
38 {
39  int id = event.GetId();
40  wxPoint pos;
42 
43  wxGetMousePosition( &pos.x, &pos.y );
44 
45  pos.y += 20;
46 
47  switch( id ) // End any command in progress.
48  {
50  break;
51 
52  default: // End block command in progress.
54  break;
55  }
56 
57  switch( id )
58  {
60  SetToolID( id, wxCURSOR_PENCIL, _( "Add Line" ) );
61  break;
62 
64  SetToolID( id, wxCURSOR_PENCIL, _( "Add Gap" ) );
65  break;
66 
68  SetToolID( id, wxCURSOR_PENCIL, _( "Add Stub" ) );
69  break;
70 
72  SetToolID( id, wxCURSOR_PENCIL, _( "Add Arc Stub" ) );
73  break;
74 
76  SetToolID( id, wxCURSOR_PENCIL, _( "Add Polynomial Shape" ) );
77  break;
78 
79  default:
80  DisplayError( this,
81  wxT( "PCB_EDIT_FRAME::ProcessMuWaveFunctions() id error" ) );
82  break;
83  }
84 }
85 
86 
87 void PCB_EDIT_FRAME::MuWaveCommand( wxDC* DC, const wxPoint& MousePos )
88 {
89  MODULE* module = NULL;
90 
91  switch( GetToolId() )
92  {
94  Begin_Self( DC );
95  break;
96 
98  module = Create_MuWaveComponent( 0 );
99  break;
100 
102  module = Create_MuWaveComponent( 1 );
103  break;
104 
106  module = Create_MuWaveComponent( 2 );
107  break;
108 
110  module = Create_MuWavePolygonShape();
111  break;
112 
113  default:
114  m_canvas->SetCursor( wxCURSOR_ARROW );
115  DisplayError( this, wxT( "PCB_EDIT_FRAME::MuWaveCommand() id error" ) );
117  break;
118  }
119 
120  if( module )
121  {
122  StartMoveModule( module, DC, false );
123  }
124 
126 }
void MuWaveCommand(wxDC *DC, const wxPoint &MousePos)
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
This file is part of the common library.
void EndMouseCapture(int aId=-1, int aCursorId=-1, const wxString &aTitle=wxEmptyString, bool aCallEndFunc=true)
Function EndMouseCapture ends mouse a capture.
void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
Definition: draw_panel.cpp:347
void Begin_Self(wxDC *DC)
Definition: microwave.cpp:139
MODULE * Create_MuWavePolygonShape()
Definition: microwave.cpp:574
a helper to handle the real device context used in KiCad
MODULE * Create_MuWaveComponent(int shape_type)
Create_MuWaveComponent creates a module "GAP" or "STUB" used in micro wave designs.
Definition: microwave.cpp:226
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Definition: draw_frame.cpp:571
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
void StartMoveModule(MODULE *aModule, wxDC *aDC, bool aDragConnectedTracks)
Function StartMoveModule Initialize a drag or move pad command.
Definition: modules.cpp:100
#define INSTALL_UNBUFFERED_DC(name, parent)
int GetToolId() const
Definition: draw_frame.h:471
void ProcessMuWaveFunctions(wxCommandEvent &event)
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:73