Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#633 Add keyboard shortcut for hiding all lines in wxt

None
closed-accepted
nobody
wxt (1)
4
2014-02-17
2013-08-07
Jon Gjengset
No

When plotting many aspects of a dataset in a single graph, it is often convenient to be able to hide all lines and then only selectively enable those that are of interest. The attached patch makes 'c' a keyboard shortcut for doing this in wxterminal.

The patch currently adds a case to wxtPanel::OnKeyDownChar for handling this. In the long term, a better solution might be to dispatch a command like "hide line 1" to the main gnuplot process, which then triggers a replot, but then there first has to be a way of targeting a command to a specific line.

Patch has been tested against the latest CVS version on Arch Linux x64.

1 Attachments

Discussion

<< < 1 2 3 4 5 > >> (Page 3 of 5)
  • Jon Gjengset
    Jon Gjengset
    2013-08-11

    Yeah, that was my thinking in a comment further up somewhere too. It would probably increase the size and complexity of the change quite a bit though.

    • Fair enough.
    • Ah, hadn't thought of multiplots. Yes, an addtional graph id parameter could be a good addition. The ideal would be if gnuplot kept an incrementing id for each graph the user plots and also stores which window shows each graph. That would also make it substantially easier to implement a command like "toggle 3". It would also mean we would only need one additional parameter giving the graph id, rather than one for the window and one for the graph number within that window.
    • I made it more generic in case additional features that modify all plots in a graph might be added in the future; those features would then also not have to modify term_api.h, which would certainly be a win. I didn't have any particular ones in mind, but something like "cycle colors" or "set/unset bold" maybe?. The user might want to limit these to only some of the plots though, so perhaps modify_plots should take graph-id and plot-id, where plot-id is interpreted as "all" if it is set to 0?

    I'll have a look at adding this to 2 more terminals. qt and x11 are the two other I can think of that are interactive?

     
    • Ethan Merritt
      Ethan Merritt
      2013-08-11

      The other ones currently are canvas, svg, and win

       
      • Jon Gjengset
        Jon Gjengset
        2013-08-11

        canvas and svg aren't interactive though?
        They don't react to keypresses ('g' does not work for example), nor can I see how you could in an svg?

         
        • Ethan Merritt
          Ethan Merritt
          2013-08-11

          Both svg and canvas are interactive in that they respond to mouse clicks, and both support toggling the plots on/off. Canvas also responds to hot-keys, although the necessary HTML wrapper to enable them is unfortunately browser-dependent. Actually, the svg standard says it can do hotkeys, but gnuplot doesn't currently include code to support them.

          Because the hotkey support for canvas is somewhat problematic, I usually provide a separate icon for, e.g., toggling the grid. You can see how this works in any of the demos with a grid, including the one on the top page of the demo site.
          Somewhere near the top of my project list is a near total re-write of the .js code supporting the canvas terminal. Among other things it can be made to use the key entries as a toggle, just like the other terminals, in addition to using a separate icon. The point is that it's trivial to write a small .js routine to toggle the state of all plots. It can then be hooked to an icon or mouse event or hot key or whatever.

          But yeah, neither svg nor canvas can do anything in response to commands on the gnuplot command line once they are being displayed.

           
          • Jon Gjengset
            Jon Gjengset
            2013-08-11

            Hmm, but in order to keep the bindings in sync (that is, respect the bindings set in gnuplot), the canvas code would then have to parse the table of bindings to figure out which key is bound to the various modplot actions, which seems brittle at best, no? With wxt and qt, this is handled through communication with the gnuplot core.

            I could easily write up some js to show/hide plots in response to the same keys that are set by default, but dynamically discovering the bindings might not be quite so trivial.

             
  • Jon Gjengset
    Jon Gjengset
    2013-08-12

    I've added an implementation for qtterminal now (patch attached).

    It seems to work correctly, although there seems to be occasional delay between pressing the key and the visibilities changing. I don't know enough about the event dispatching here to figure out what might be causing it. Any thoughts?

     
    Attachments
    • Jon Gjengset
      Jon Gjengset
      2013-08-12

      Managed to remove the delay by adding qt_flushOutBuffer() to qt_modify_plots().

      The hotkeys do not seem to work if gnuplot is invoked with -p however. This is not because of my code though I think, as other hotkeys like "g" also stop working when run through gnuplot -p. The hotkeys work fine in wxt with -p.

       
      Attachments
  • Jon Gjengset
    Jon Gjengset
    2013-08-12

    I've been trying to write an integration with the x11 terminal, but am having some issues. Whenever any of the hotkeys are pressed, the x11 window will completely freeze, and I just can't figure out what is causing it.

    The attached patch contains only the changes to enable support in x11 (+mouse.c, term_api.h, etc). Any chance you could take a look and see if you immediately spot where the error is?

     
  • Ethan Merritt
    Ethan Merritt
    2013-08-13

    I don't know exactly why it hangs, but I can tell you that there is a fundamental problem with the code. The code you added to gplt_x11.c is inserting the toggle into the display list, where it will be executed every time the plot window is refreshed. It is not being executed just once, asynchronously, which is what you wanted it to do.

    I'm kind of busy these next few days. I'll have another look next weekend.

     
    • Jon Gjengset
      Jon Gjengset
      2013-08-13

      Ah, yes, that'd do it. Found the problem.

       
<< < 1 2 3 4 5 > >> (Page 3 of 5)