KiCad PCB EDA Suite
simulate.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) 2016 CERN
5  * @author Tomasz Wlostowski <tomasz.wlostowski@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 3
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  * https://www.gnu.org/licenses/gpl-3.0.html
20  * or you may search the http://www.gnu.org website for the version 3 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 <kiway.h>
26 #include <schframe.h>
27 #include "sim_plot_frame.h"
28 
29 void SCH_EDIT_FRAME::OnSimulate( wxCommandEvent& event )
30 {
31  SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, true );
32  simFrame->Show( true );
33 
34  // On Windows, Raise() does not bring the window on screen, when iconized
35  if( simFrame->IsIconized() )
36  simFrame->Iconize( false );
37 
38  simFrame->Raise();
39 }
40 
41 // I apologize for the following lines, but this is more or less what wxWidgets
42 // authors suggest (http://docs.wxwidgets.org/trunk/classwx_cursor.html)
43 
44 static const unsigned char cursor_probe[] = {
45  0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x70,
46  0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04,
47  0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x04,
48  0x00, 0x00, 0x10, 0x02, 0x00, 0x00, 0x08, 0x01, 0x00, 0x00, 0x84, 0x00,
49  0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x80, 0x10, 0x00,
50  0x00, 0x40, 0x08, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00, 0x10, 0x02, 0x00,
51  0x00, 0x08, 0x01, 0x00, 0x80, 0x85, 0x00, 0x00, 0x40, 0x42, 0x00, 0x00,
52  0x20, 0x21, 0x00, 0x00, 0x20, 0x11, 0x00, 0x00, 0x20, 0x09, 0x00, 0x00,
53  0x20, 0x16, 0x00, 0x00, 0x50, 0x10, 0x00, 0x00, 0x88, 0x08, 0x00, 0x00,
54  0x44, 0x07, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00,
55  0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 };
56 
57 static const unsigned char cursor_probe_mask[] {
58  0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x70,
59  0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04,
60  0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x07,
61  0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0xfc, 0x00,
62  0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x80, 0x1f, 0x00,
63  0x00, 0xc0, 0x0f, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xf0, 0x03, 0x00,
64  0x00, 0xf8, 0x01, 0x00, 0x80, 0xfd, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00,
65  0xe0, 0x3f, 0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00,
66  0xe0, 0x1f, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00,
67  0x7c, 0x07, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00,
68  0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 };
69 
70 static const unsigned char cursor_tune[] = {
71  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
72  0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0xc0, 0x0f,
73  0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x0f,
74  0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00, 0xff, 0x01,
75  0x00, 0x80, 0xff, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00,
76  0x00, 0xe0, 0x1f, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xfc, 0x07, 0x00,
77  0x00, 0xfc, 0x03, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0xf4, 0x00, 0x00,
78  0x00, 0xea, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00,
79  0x40, 0x01, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
80  0x2c, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00,
81  0x0a, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00 };
82 
83 static const unsigned char cursor_tune_mask[] = {
84  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
85  0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0xc0, 0x0f,
86  0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x0f,
87  0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00, 0xff, 0x01,
88  0x00, 0x80, 0xff, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00,
89  0x00, 0xe0, 0x1f, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xfc, 0x07, 0x00,
90  0x00, 0xfc, 0x03, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00,
91  0x00, 0xee, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00,
92  0xc0, 0x01, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
93  0x3c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00,
94  0x0e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00 };
95 
96 #if defined(__WXMSW__) or defined(__WXMAC__)
97 struct SIM_CURSORS_INIT
98 {
99 public:
100  static wxImage& GetProbeImage()
101  {
102  static wxImage* probe_image = NULL;
103 
104  if( probe_image == NULL )
105  {
106  wxBitmap probe_bitmap( (const char*) cursor_probe, 32, 32 );
107  wxBitmap probe_mask_bitmap( (const char*) cursor_probe_mask, 32, 32 );
108  probe_bitmap.SetMask( new wxMask( probe_mask_bitmap ) );
109  probe_image = new wxImage( probe_bitmap.ConvertToImage() );
110 #ifdef __WXMSW__
111  probe_image->SetMaskColour( 255, 255, 255 );
112 #endif
113  probe_image->SetOption( wxIMAGE_OPTION_CUR_HOTSPOT_X, 0 );
114  probe_image->SetOption( wxIMAGE_OPTION_CUR_HOTSPOT_Y, 31 );
115  }
116 
117  return *probe_image;
118  }
119 
120  static wxImage& GetTuneImage()
121  {
122  static wxImage* tune_image = NULL;
123 
124  if( tune_image == NULL )
125  {
126  wxBitmap tune_bitmap( (const char*) cursor_tune, 32, 32 );
127  wxBitmap tune_mask_bitmap( (const char*) cursor_tune_mask, 32, 32 );
128  tune_bitmap.SetMask( new wxMask( tune_mask_bitmap ) );
129  tune_image = new wxImage( tune_bitmap.ConvertToImage() );
130 #ifdef __WXMSW__
131  tune_image->SetMaskColour( 255, 255, 255 );
132 #endif
133  tune_image->SetOption( wxIMAGE_OPTION_CUR_HOTSPOT_X, 0 );
134  tune_image->SetOption( wxIMAGE_OPTION_CUR_HOTSPOT_Y, 31 );
135  }
136 
137  return *tune_image;
138  }
139 };
140 
141 const wxCursor SCH_EDIT_FRAME::CURSOR_PROBE( SIM_CURSORS_INIT::GetProbeImage() );
142 const wxCursor SCH_EDIT_FRAME::CURSOR_TUNE( SIM_CURSORS_INIT::GetTuneImage() );
143 #elif defined(__WXGTK__) or defined(__WXMOTIF__)
144 const wxCursor SCH_EDIT_FRAME::CURSOR_PROBE( (const char*) cursor_probe, 32, 32, 0, 31, (const char*) cursor_probe_mask );
145 const wxCursor SCH_EDIT_FRAME::CURSOR_TUNE( (const char*) cursor_tune, 32, 32, 1, 30, (const char*) cursor_tune_mask );
146 #endif
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
static const wxCursor CURSOR_TUNE
Tuner cursor, used by circuit simulator
Definition: schframe.h:1404
static const unsigned char cursor_tune_mask[]
Definition: simulate.cpp:83
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, KIWAY_PLAYER *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:302
static const unsigned char cursor_tune[]
Definition: simulate.cpp:70
static const wxCursor CURSOR_PROBE
Probe cursor, used by circuit simulator
Definition: schframe.h:1401
Subclass of SIM_PLOT_FRAME_BASE, which is generated by wxFormBuilder.
Implementing SIM_PLOT_FRAME_BASE.
static const unsigned char cursor_probe[]
Definition: simulate.cpp:44
void OnSimulate(wxCommandEvent &event)
Definition: simulate.cpp:29
static const unsigned char cursor_probe_mask[]
Definition: simulate.cpp:57