JMRI icon indicating copy to clipboard operation
JMRI copied to clipboard

WIP SignalMast Icon Click Sensors

Open icklesteve opened this issue 2 years ago • 19 comments

Enables Sensors to go active on clicks to the Icon. Adds Control ( right ) clicked options with default behaviour as existing. Sensor selection ComboBox added to edit icon popup when selecting Sensor action. Sensors stored as NamedBeanHandles. Larger methods to smaller blocks.

There's a getUsageReport( NamedBean ) method for the WhereUsed tool however not linked up.

Marked WIP to check general code structure is ok before tweaking the LoadAndStore xml files.

icklesteve avatar Feb 12 '24 18:02 icklesteve

Thanks for the PR. It includes changes to properties files, so the 'Needs L10N' label has been added"

mergeable[bot] avatar Feb 12 '24 19:02 mergeable[bot]

What is the purpose of clicking on a signal mast icon to activate a sensor.

I am not able to find any key combinations to trigger the action on macOS using a track pad. Control-click brings up the context menu.

dsand47 avatar Feb 12 '24 20:02 dsand47

Hi @dsand47

It would be possible to set ( NX style ) routes by ( left ) clicking from mast to mast. Route cancellation could be performed on the right ( control ) click. I believe this may be fairly common IECC behaviour used in many VSCS's ( VDU Signalling Control System ). Also the method used in SimSig, a popular IECC emulator ( https://www.simsig.co.uk/ ) .

The ( Windows right click ), ( Mac Control ? ) Sensor action only comes into play when the Panel is not in edit mode, the preference to use the ( right / control ) click action has been set, and a Sensor has been set.

Steve.

icklesteve avatar Feb 13 '24 12:02 icklesteve

Hi @dsand47

It would be possible to set ( NX style ) routes by ( left ) clicking from mast to mast. Route cancellation could be performed on the right ( control ) click. I believe this may be fairly common IECC behaviour used in many VSCS's ( VDU Signalling Control System ). Also the method used in SimSig, a popular IECC emulator ( https://www.simsig.co.uk/ ) .

The ( Windows right click ), ( Mac Control ? ) Sensor action only comes into play when the Panel is not in edit mode, the preference to use the ( right / control ) click action has been set, and a Sensor has been set.

Steve.

I am able to get it to work with Panel Editor, but Layout Editor still does not work.

What is interesting is that the JMRI Entry/Exit system was designed to use sensors or signals. However, the signal support was never implemented. In Entry/Exit, route cancellation is done by re-selecting the same sensor pair.

dsand47 avatar Feb 13 '24 15:02 dsand47

Hi again @dsand47

I am able to get it to work with Panel Editor, but Layout Editor still does not work.

Interesting. With current HOM, when not in Panel Edit mode and a SignalMast is ( Win 11 Right ) clicked on, there's a SignalMast aspect selection, do you see that with the Control Click?

It should be triggered via the mouseReleased method in LayoutEditor. I've added some temporary logging to the PR to assist trace this, here's what I get . . .

     [java] 15:23:14,512 rit.display.layoutEditor.LayoutEditor INFO  - mouseReleased jmri.util.swing.JmriMouseEvent@4c4ac92e [AWT-EventQueue-0]
     [java] 15:23:14,512 rit.display.layoutEditor.LayoutEditor INFO  - requesting marker popup out of edit mode [AWT-EventQueue-0]
     [java] 15:23:14,512 rit.display.layoutEditor.LayoutEditor INFO  - SignalMast found from checkSignalMastIconPopUps [AWT-EventQueue-0]
     [java] 15:23:14,513 rit.display.layoutEditor.LayoutEditor INFO  - showPopUp for IF$tsm:BR-2003:2-h($0001) [AWT-EventQueue-0]
     [java] 15:23:14,513 jmri.jmrit.display.SignalMastIcon     INFO  - showPopup [AWT-EventQueue-0]
     [java] 15:23:14,513 jmri.jmrit.display.SignalMastIcon     INFO  - performing right click action  [AWT-EventQueue-0]
     [java] java.lang.Exception: Trace
     [java]     at jmri.jmrit.display.SignalMastIcon.performControlClickNonEditAction(SignalMastIcon.java:406) [classes/:?]
     [java]     at jmri.jmrit.display.SignalMastIcon.showPopUp(SignalMastIcon.java:212) [classes/:?]
     [java]     at jmri.jmrit.display.layoutEditor.LayoutEditor.showPopUp(LayoutEditor.java:3985) [classes/:?]
     [java]     at jmri.jmrit.display.layoutEditor.LayoutEditor.mouseReleased(LayoutEditor.java:3715) [classes/:?]
     [java]     at jmri.util.swing.JmriMouseListener$1.mouseReleased(JmriMouseListener.java:33) [classes/:?]
     [java]     at java.awt.Component.processMouseEvent(Component.java:6635) [?:?]

What is interesting is that the JMRI Entry/Exit system was designed to use sensors or signals. However, the signal support was never implemented. In Entry/Exit, route cancellation is done by re-selecting the same sensor pair.

I'm assuming that it's OK to just set the Sensor active for this to work, there doesn't need to be a momentary action.

Steve.

icklesteve avatar Feb 15 '24 20:02 icklesteve

btw @dsand47 , here's the mini Panel I'm testing this with :

sigMastIconTest.zip

icklesteve avatar Feb 15 '24 20:02 icklesteve

I tested your latest updates. The mast icon does not respond to control-click or right click in Layout Editor. They both work for markers.

23:45:08,786 rit.display.layoutEditor.LayoutEditor INFO  - mouseReleased jmri.util.swing.JmriMouseEvent@25dc7161 [AWT-EventQueue-0]
23:45:08,787 rit.display.layoutEditor.LayoutEditor INFO  - requesting marker popup out of edit mode [AWT-EventQueue-0]
23:45:08,787 rit.display.layoutEditor.LayoutEditor INFO  - showPopUp for null [AWT-EventQueue-0]

The signal mast only shows the mouseReleased.

Note: Entry/Exit sensors are not momentary.

dsand47 avatar Feb 16 '24 05:02 dsand47

Much thanks for the feedback and log @dsand47

There are only a few else if statements difference so we're definitely getting closer! If you could please try the latest PR, the Right / Control clicks are initally going down the same path,

Win 11 latest PR right click on test case Panel Signal Mast Icon I'm getting

     [java] 02:06:08,956 rit.display.layoutEditor.LayoutEditor INFO  - mouseReleased, editable false [AWT-EventQueue-0]
     [java] 02:06:08,957 rit.display.layoutEditor.LayoutEditor INFO  - requesting popup out of edit mode [AWT-EventQueue-0]
     [java] 02:06:08,957 rit.display.layoutEditor.LayoutEditor INFO  - checking for SignalMast Icon at Point2D.Double[53.0, 28.0] [AWT-EventQueue-0]
     [java] 02:06:08,958 rit.display.layoutEditor.LayoutEditor INFO  - checking if click at Point2D.Double[53.0, 28.0] within bounds of SigMast Icon at java.awt.Rectangle[x=41,y=22,width=19,height=16] [AWT-EventQueue-0]
     [java] 02:06:08,962 rit.display.layoutEditor.LayoutEditor INFO  - SignalMast found from checkSignalMastIconPopUps [AWT-EventQueue-0]
     [java] 02:06:08,962 rit.display.layoutEditor.LayoutEditor INFO  - showPopUp for IF$tsm:BR-2003:2-h($0001) [AWT-EventQueue-0]
     [java] 02:06:08,962 jmri.jmrit.display.SignalMastIcon     INFO  - showPopup [AWT-EventQueue-0]
     [java] 02:06:08,962 jmri.jmrit.display.SignalMastIcon     INFO  - performing right click action  [AWT-EventQueue-0]
     [java] java.lang.Exception: Trace
     [java]     at jmri.jmrit.display.SignalMastIcon.performControlClickNonEditAction(SignalMastIcon.java:406) [classes/:?]
     [java]     at jmri.jmrit.display.SignalMastIcon.showPopUp(SignalMastIcon.java:212) [classes/:?]
     [java]     at jmri.jmrit.display.layoutEditor.LayoutEditor.showPopUp(LayoutEditor.java:3991) [classes/:?]
     [java]     at jmri.jmrit.display.layoutEditor.LayoutEditor.mouseReleased(LayoutEditor.java:3721) [classes/:?]
     [java]     at jmri.util.swing.JmriMouseListener$1.mouseReleased(JmriMouseListener.java:33) [classes/:?]
     [java]     at java.awt.Component.processMouseEvent(Component.java:6635) [?:?]

icklesteve avatar Feb 17 '24 02:02 icklesteve

Much thanks for the feedback and log @dsand47

There are only a few else if statements difference so we're definitely getting closer! If you could please try the latest PR, the Right / Control clicks are initally going down the same path,

Win 11 latest PR right click on test case Panel Signal Mast Icon I'm getting

     [java] 02:06:08,956 rit.display.layoutEditor.LayoutEditor INFO  - mouseReleased, editable false [AWT-EventQueue-0]
     [java] 02:06:08,957 rit.display.layoutEditor.LayoutEditor INFO  - requesting popup out of edit mode [AWT-EventQueue-0]
     [java] 02:06:08,957 rit.display.layoutEditor.LayoutEditor INFO  - checking for SignalMast Icon at Point2D.Double[53.0, 28.0] [AWT-EventQueue-0]
     [java] 02:06:08,958 rit.display.layoutEditor.LayoutEditor INFO  - checking if click at Point2D.Double[53.0, 28.0] within bounds of SigMast Icon at java.awt.Rectangle[x=41,y=22,width=19,height=16] [AWT-EventQueue-0]
     [java] 02:06:08,962 rit.display.layoutEditor.LayoutEditor INFO  - SignalMast found from checkSignalMastIconPopUps [AWT-EventQueue-0]
     [java] 02:06:08,962 rit.display.layoutEditor.LayoutEditor INFO  - showPopUp for IF$tsm:BR-2003:2-h($0001) [AWT-EventQueue-0]
     [java] 02:06:08,962 jmri.jmrit.display.SignalMastIcon     INFO  - showPopup [AWT-EventQueue-0]
     [java] 02:06:08,962 jmri.jmrit.display.SignalMastIcon     INFO  - performing right click action  [AWT-EventQueue-0]
     [java] java.lang.Exception: Trace
     [java]     at jmri.jmrit.display.SignalMastIcon.performControlClickNonEditAction(SignalMastIcon.java:406) [classes/:?]
     [java]     at jmri.jmrit.display.SignalMastIcon.showPopUp(SignalMastIcon.java:212) [classes/:?]
     [java]     at jmri.jmrit.display.layoutEditor.LayoutEditor.showPopUp(LayoutEditor.java:3991) [classes/:?]
     [java]     at jmri.jmrit.display.layoutEditor.LayoutEditor.mouseReleased(LayoutEditor.java:3721) [classes/:?]
     [java]     at jmri.util.swing.JmriMouseListener$1.mouseReleased(JmriMouseListener.java:33) [classes/:?]
     [java]     at java.awt.Component.processMouseEvent(Component.java:6635) [?:?]

The LE signal popup issue also applies to Linux.

For Linux (right click) and macOS (ctl-click), isPopupTrigger() might be true on mousePressed, never on mouseReleased.

At line 3148 is the code to handle Markers for Mac and Linux.

            // not in edit mode - check if a marker popup menu is being requested
              LocoIcon lo = checkMarkerPopUps(dLoc);
            if (lo != null) {
                delayedPopupTrigger = true;
            }

If you have not done so, you will need code similar to checkMarkerPopUps to see whether the mast, if any, should get the pup-up menu. delayedPopupTrigger is used to defer the trigger processing until mouseReleased which will include Windows.

dsand47 avatar Feb 17 '24 23:02 dsand47

Thanks for the line pointer @dsand47 , I've added the SignalMastIcon check.

icklesteve avatar Feb 19 '24 14:02 icklesteve

I think I know which does what. I have some extra log.info messages.

Win11 running in Parallels.

  • Button 3
    • pressed: popup true, delayed not set
    • released: popup true
    • sensor set on popup true
  • CTRL Button 3
    • pressed: popup true, delayed set true
    • released: popup false
    • sensor set based on delayed true

Ubuntu running in Parallels.

  • Button 3
    • pressed: popup true, delayed not set
    • released: popup false
    • sensor not set
  • CTRL Button 3
    • pressed: popup true, delayed set true
    • released: popup false
    • sensor set based on delayed true

Raspberry Pi

  • Button 3
    • pressed: popup true, delayed not set
    • released: popup false
    • sensor not set
  • CTRL Button 3
    • pressed: popup true, delayed set true
    • released: popup false
    • sensor set based on delayed true

macOS

  • Button 3 (two finger click on track pad)
    • pressed: popup true, delayed set true due to meta
    • released: popup false
    • sensor set based on delayed true
  • CTRL Button 1
    • pressed: popup true, delayed set true
    • released: popup false
    • sensor set based on delayed true

Summary

  • WIn 11: Button 3 with or without CTRL
  • Linux: Button 3 with CTRL
  • macOS: Button 1 with CTRL or Button 3 with META. Real mouse unknown.

dsand47 avatar Feb 19 '24 21:02 dsand47

They both work for markers.

Hi @dsand47 I've found another location that the Marker popups are being activated from :-) Thanks for all your testing on this, much appreciated, Steve.

icklesteve avatar Feb 23 '24 13:02 icklesteve

This PR is stale because it has been open for 45 days with no activity.

github-actions[bot] avatar Apr 15 '24 03:04 github-actions[bot]