From a96158e26bf975f6cd068239b42ca10e5bd0fcba Mon Sep 17 00:00:00 2001 From: Jeff Young <jeff@rokeby.ie> Date: Mon, 5 Aug 2019 16:34:47 -0600 Subject: [PATCH] Add current probe to SPICE simulation. Fixes: lp:1740321 * https://bugs.launchpad.net/kicad/+bug/1740321 --- bitmaps_png/cursors/current_probe.xbm | 14 +++ bitmaps_png/cursors/current_probe.xcf | Bin 0 -> 804 bytes bitmaps_png/cursors/voltage_probe.xbm | 14 +++ bitmaps_png/cursors/voltage_probe.xcf | Bin 0 -> 759 bytes eeschema/simulation_cursors.cpp | 117 ++++++++++++++------------ eeschema/simulation_cursors.h | 11 +-- eeschema/tools/sch_editor_control.cpp | 48 +++++++---- 7 files changed, 128 insertions(+), 76 deletions(-) create mode 100644 bitmaps_png/cursors/current_probe.xbm create mode 100644 bitmaps_png/cursors/current_probe.xcf create mode 100644 bitmaps_png/cursors/voltage_probe.xbm create mode 100644 bitmaps_png/cursors/voltage_probe.xcf diff --git a/bitmaps_png/cursors/current_probe.xbm b/bitmaps_png/cursors/current_probe.xbm new file mode 100644 index 0000000000..291e77f8ed --- /dev/null +++ b/bitmaps_png/cursors/current_probe.xbm @@ -0,0 +1,14 @@ +#define current_probe_width 32 +#define current_probe_height 32 +static unsigned char current_probe_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, + 0x00, 0x00, 0x60, 0x06, 0x00, 0x00, 0x30, 0x0c, 0x00, 0x00, 0x1c, 0x08, + 0x00, 0x00, 0x0f, 0x08, 0x00, 0x80, 0x0f, 0x18, 0x00, 0xc0, 0x0f, 0x30, + 0x80, 0xe1, 0x07, 0x60, 0x80, 0xf1, 0x03, 0x00, 0x80, 0xf9, 0x01, 0x00, + 0x80, 0xfd, 0x00, 0x00, 0x80, 0x7f, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, + 0x80, 0x1f, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xf8, 0x07, 0x00, 0x00, + 0xfe, 0x03, 0x00, 0x00, 0xc6, 0x01, 0x00, 0x00, 0x83, 0x01, 0x00, 0x00, + 0x83, 0x01, 0x00, 0x00, 0x83, 0x01, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, + 0xfc, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00 }; diff --git a/bitmaps_png/cursors/current_probe.xcf b/bitmaps_png/cursors/current_probe.xcf new file mode 100644 index 0000000000000000000000000000000000000000..edbbf9273b41700e61b837968a41708c606fbf9b GIT binary patch literal 804 zcmZ`%%Wi@|6dguTv~8+Zw3;qv(?k~-{Dpo)_l+WqBnSkk(Ut$uFY1?ddM*wPP3=ui z&bjA4hRh(NeI|~6C=Q;tVhEwZ!3NOL3>uIm?*Xu1KHJX(=n-H7U0|#=^*QK&0{10O zaijfO2CmGbEiBq?uz69Q;y@H>9Bmi9c_{rfPIED@$j#+uExe^y#TBvAr3FSeS4Qi) z_+QZIvB=hblt{6v&w_cnW@^uUPoh#piN6a9noq;92+E%ir0Kub#rZu-_n^c0s1;af zSm5CyjZ0kITb8GrV3{QnCZpG(XajWf3b3`No2Qo`pMqYX*1d+lY3SRAzH8`vXxdu` z{SEc5`qk@iL5aWWMgb<E#&=)}aREP4a>kakF=j0_V}>$-N1z2bj4O+MDK<p0O=7@I z2t)Omr8;1{>a<iBOgV=?0vlil{Kb^1#;l_ztc|r+1<D;}!>0jWu?bCilP7c{hdIUI I42@Iv4ZO{cAOHXW literal 0 HcmV?d00001 diff --git a/bitmaps_png/cursors/voltage_probe.xbm b/bitmaps_png/cursors/voltage_probe.xbm new file mode 100644 index 0000000000..f4451842ea --- /dev/null +++ b/bitmaps_png/cursors/voltage_probe.xbm @@ -0,0 +1,14 @@ +#define voltage_probe_width 32 +#define voltage_probe_height 32 +static unsigned char voltage_probe_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x30, 0x06, 0x00, 0x00, 0x18, 0x0c, + 0x00, 0x00, 0x0e, 0x08, 0x00, 0x80, 0x07, 0x08, 0x00, 0xc0, 0x07, 0x18, + 0x00, 0xe0, 0x07, 0x30, 0x00, 0xf0, 0x03, 0x60, 0x00, 0xf8, 0x01, 0x00, + 0x00, 0xfc, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, + 0x80, 0x1f, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, + 0xf0, 0x03, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, + 0x18, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/bitmaps_png/cursors/voltage_probe.xcf b/bitmaps_png/cursors/voltage_probe.xcf new file mode 100644 index 0000000000000000000000000000000000000000..88097cca0cd858e226677f8e7ba31ccb4e6f6e0a GIT binary patch literal 759 zcmaKq%}&BV6osc1D1ro3{DELH8xvTRl!ZH2K7)JHmUft=v`t$Htat~W$R~3=7iJ7b z^d?`<>HTXnQz4f*UxzVYdESg6xW<NBz|ji1Bulw#(0uu5JQDDIPy=;vt3CDIpnnAI z3B1LXOJ78;DC8U|+HJ9MS#6Stmsuj`lh!yEVU}bCAMeF2MBsC8>h0r%nd#C5qrr($ zQ|Esh8eNyUAIenlnRyqIn^Q@hbKg^0ahZmTsHFKUj?1X}{y>`kojPQGj?y{kuy)2l zxrWa3YLz7w4(=^4vLKq~sX&s^?NBrToxB1~?djytwTCde0qUV>0pr_8{^H1Yj(iuM z_L`u-!OWXmH{XJi{i+)|lt9g1Kq>eEdrc2pY}r~*tfmIcQZ~2)HPC0aYOqg*-|b8} jWP0dwQ0cO|YC=2E7PJk$|AztQhFCI0?@04N3!m8+y}5xw literal 0 HcmV?d00001 diff --git a/eeschema/simulation_cursors.cpp b/eeschema/simulation_cursors.cpp index 15ff476307..aebcd4b733 100644 --- a/eeschema/simulation_cursors.cpp +++ b/eeschema/simulation_cursors.cpp @@ -25,78 +25,85 @@ #include <cursor_store.h> -static const unsigned char cursor_probe[] = { - 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, - 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x04, - 0x00, 0x00, 0x10, 0x02, 0x00, 0x00, 0x08, 0x01, 0x00, 0x00, 0x84, 0x00, - 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x80, 0x10, 0x00, - 0x00, 0x40, 0x08, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00, 0x10, 0x02, 0x00, - 0x00, 0x08, 0x01, 0x00, 0x80, 0x85, 0x00, 0x00, 0x40, 0x42, 0x00, 0x00, - 0x20, 0x21, 0x00, 0x00, 0x20, 0x11, 0x00, 0x00, 0x20, 0x09, 0x00, 0x00, - 0x20, 0x16, 0x00, 0x00, 0x50, 0x10, 0x00, 0x00, 0x88, 0x08, 0x00, 0x00, - 0x44, 0x07, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 }; +static const unsigned char voltage_probe[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x30, 0x06, 0x00, 0x00, 0x18, 0x0c, + 0x00, 0x00, 0x0e, 0x08, 0x00, 0x80, 0x07, 0x08, 0x00, 0xc0, 0x07, 0x18, + 0x00, 0xe0, 0x07, 0x30, 0x00, 0xf0, 0x03, 0x60, 0x00, 0xf8, 0x01, 0x00, + 0x00, 0xfc, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, + 0x80, 0x1f, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, + 0xf0, 0x03, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, + 0x18, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const unsigned char cursor_probe_mask[] { - 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, - 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x07, - 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0xfc, 0x00, - 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x80, 0x1f, 0x00, - 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xf0, 0x03, 0x00, - 0x00, 0xf8, 0x01, 0x00, 0x80, 0xfd, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, - 0xe0, 0x3f, 0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, - 0xe0, 0x1f, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, - 0x7c, 0x07, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 }; +static const unsigned char current_probe[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, + 0x00, 0x00, 0x60, 0x06, 0x00, 0x00, 0x30, 0x0c, 0x00, 0x00, 0x1c, 0x08, + 0x00, 0x00, 0x0f, 0x08, 0x00, 0x80, 0x0f, 0x18, 0x00, 0xc0, 0x0f, 0x30, + 0x80, 0xe1, 0x07, 0x60, 0x80, 0xf1, 0x03, 0x00, 0x80, 0xf9, 0x01, 0x00, + 0x80, 0xfd, 0x00, 0x00, 0x80, 0x7f, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, + 0x80, 0x1f, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xf8, 0x07, 0x00, 0x00, + 0xfe, 0x03, 0x00, 0x00, 0xc6, 0x01, 0x00, 0x00, 0x83, 0x01, 0x00, 0x00, + 0x83, 0x01, 0x00, 0x00, 0x83, 0x01, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, + 0xfc, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00 }; static const unsigned char cursor_tune[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0xc0, 0x0f, - 0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x0f, - 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00, 0xff, 0x01, - 0x00, 0x80, 0xff, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, - 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xfc, 0x07, 0x00, - 0x00, 0xfc, 0x03, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0xf4, 0x00, 0x00, - 0x00, 0xea, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, - 0x40, 0x01, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, - 0x2c, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00 }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0xc0, 0x0f, + 0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x0f, + 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00, 0xff, 0x01, + 0x00, 0x80, 0xff, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, + 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xfc, 0x07, 0x00, + 0x00, 0xfc, 0x03, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0xf4, 0x00, 0x00, + 0x00, 0xea, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, + 0x40, 0x01, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, + 0x2c, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00 }; static const unsigned char cursor_tune_mask[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0xc0, 0x0f, - 0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x0f, - 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00, 0xff, 0x01, - 0x00, 0x80, 0xff, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, - 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xfc, 0x07, 0x00, - 0x00, 0xfc, 0x03, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, - 0x00, 0xee, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, - 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, - 0x3c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, - 0x0e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00 }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0xc0, 0x0f, + 0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x0f, + 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00, 0xff, 0x01, + 0x00, 0x80, 0xff, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, + 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xfc, 0x07, 0x00, + 0x00, 0xfc, 0x03, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, + 0x00, 0xee, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, + 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, + 0x3c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00 }; #include <vector> static const std::vector<CURSOR_STORE::CURSOR_DEF> simulation_cursors = { { - static_cast<int>( SIMULATION_CURSORS::CURSOR::TUNE ), + static_cast<int>( SIM_CURSORS::CURSOR::VOLTAGE_PROBE ), + voltage_probe, + voltage_probe, + { 32, 32 }, + { 1, 31 }, + }, + { + static_cast<int>( SIM_CURSORS::CURSOR::CURRENT_PROBE ), + current_probe, + current_probe, + { 32, 32 }, + { 4, 27 }, + }, + { + static_cast<int>( SIM_CURSORS::CURSOR::TUNE ), cursor_tune, cursor_tune_mask, { 32, 32 }, { 1, 30 }, }, - { - static_cast<int>( SIMULATION_CURSORS::CURSOR::PROBE ), - cursor_probe, - cursor_probe_mask, - { 32, 32 }, - { 0, 31 }, - }, }; -const wxCursor& SIMULATION_CURSORS::GetCursor( CURSOR aCursorType ) +const wxCursor& SIM_CURSORS::GetCursor( CURSOR aCursorType ) { static CURSOR_STORE store( simulation_cursors ); return store.Get( static_cast<int>( aCursorType ) ); diff --git a/eeschema/simulation_cursors.h b/eeschema/simulation_cursors.h index 7f8ca220a0..ac9505e402 100644 --- a/eeschema/simulation_cursors.h +++ b/eeschema/simulation_cursors.h @@ -29,16 +29,17 @@ /** * Simple class to provide cursors for simulation functions. * - * For now, it's using simple static-access, but could be made more advanced - * in future. + * For now, it's using simple static-access, but could be made more advanced in future. */ -class SIMULATION_CURSORS +class SIM_CURSORS { public: ///> Probe cursor, used by circuit simulator - enum class CURSOR + enum CURSOR { - PROBE, + VOLTAGE_PROBE, + CURRENT_PROBE, + WATTAGE_PROBE, TUNE, }; diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index eb3c59b00e..1a231da776 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -428,7 +428,8 @@ void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aF #ifdef KICAD_SPICE -static KICAD_T wiresAndPins[] = { SCH_LINE_T, SCH_PIN_T, SCH_SHEET_PIN_T, EOT }; +static KICAD_T wires[] = { SCH_LINE_LOCATE_WIRE_T, EOT }; +static KICAD_T wiresAndPins[] = { SCH_LINE_LOCATE_WIRE_T, SCH_PIN_T, SCH_SHEET_PIN_T, EOT }; static KICAD_T fieldsAndComponents[] = { SCH_COMPONENT_T, SCH_FIELD_T, EOT }; #define HITTEST_THRESHOLD_PIXELS 5 @@ -436,15 +437,19 @@ static KICAD_T fieldsAndComponents[] = { SCH_COMPONENT_T, SCH_FIELD_T, EOT }; int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent ) { - PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>(); + auto picker = m_toolMgr->GetTool<PICKER_TOOL>(); + auto simFrame = (SIM_PLOT_FRAME*) m_frame->Kiway().Player( FRAME_SIMULATOR, false ); + + if( !simFrame ) // Defensive coding; shouldn't happen. + return 0; // Deactivate other tools; particularly important if another PICKER is currently running Activate(); - picker->SetCursor( SIMULATION_CURSORS::GetCursor( SIMULATION_CURSORS::CURSOR::PROBE ) ); + picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::VOLTAGE_PROBE ) ); picker->SetClickHandler( - [this] ( const VECTOR2D& aPosition ) + [this, simFrame] ( const VECTOR2D& aPosition ) { EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>(); EDA_ITEM* item = selTool->SelectPoint( aPosition, wiresAndPins ); @@ -452,27 +457,33 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent ) if( !item ) return false; - std::unique_ptr<NETLIST_OBJECT_LIST> netlist( m_frame->BuildNetListBase() ); - - for( NETLIST_OBJECT* obj : *netlist ) + if( item->IsType( wires ) ) { - if( obj->m_Comp == item ) + std::unique_ptr<NETLIST_OBJECT_LIST> netlist( m_frame->BuildNetListBase() ); + + for( NETLIST_OBJECT* obj : *netlist ) { - SIM_PLOT_FRAME* simFrame = - (SIM_PLOT_FRAME*) m_frame->Kiway().Player( FRAME_SIMULATOR, false ); - - if( simFrame ) + if( obj->m_Comp == item ) + { simFrame->AddVoltagePlot( UnescapeString( obj->GetNetName() ) ); - - break; + break; + } } } + else if( item->Type() == SCH_PIN_T ) + { + SCH_PIN* pin = (SCH_PIN*) item; + SCH_COMPONENT* comp = (SCH_COMPONENT*) item->GetParent(); + wxString param = wxString::Format( _T( "I%s" ), pin->GetName().Lower() ); + + simFrame->AddCurrentPlot( comp->GetRef( g_CurrentSheet ), param ); + } return true; } ); picker->SetMotionHandler( - [this] ( const VECTOR2D& aPos ) + [this, picker] ( const VECTOR2D& aPos ) { EE_COLLECTOR collector; collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) ); @@ -485,6 +496,11 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent ) if( m_pickerItem != item ) { + if( item && item->Type() == SCH_PIN_T ) + picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::CURRENT_PROBE ) ); + else + picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::VOLTAGE_PROBE ) ); + if( m_pickerItem ) selectionTool->UnbrightenItem( m_pickerItem ); @@ -516,7 +532,7 @@ int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent ) // Deactivate other tools; particularly important if another PICKER is currently running Activate(); - picker->SetCursor( SIMULATION_CURSORS::GetCursor( SIMULATION_CURSORS::CURSOR::TUNE ) ); + picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::CURSOR::TUNE ) ); picker->SetClickHandler( [this] ( const VECTOR2D& aPosition )