Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Drag and drop a plot in a waveform graph.

Hi Guys,

in my C# application I visualize an array of plots in a waveform graph, side by side. Each plot is placed in a "slot" of x-axis (see attached picture). What I want to do is drag a plot over the graph and drop it to change its position. I do this by the dodragdrop method called when the mouse down event is fired. And then, when the dragdrop event occurs, I redraw the graph, and all is ok. But, after the dodragdrop call is not possible to drag cursors and the horizontal arrow is not visible when the mouse is across the cursor. The only way to "reset" the graph functionallity is a mouse right click on the plot area.

Why this problem occur ? Any suggestion to solve it ?

Thanks in advance.

 

 

0 Kudos
Message 1 of 10
(5,377 Views)

Hi Garraty,

are you using Measurement Studio?

Can you post a piece of code that shows the problem you see?

 

Thank you

Serena

0 Kudos
Message 2 of 10
(5,334 Views)

Hi Serena,

thanks for your reply.

I'm using Measurement Studio 8.5.0.220.

The problem, I think, is in this piece of code:

 

 private void waveformGraph_PlotAreaMouseDown(object sender, MouseEventArgs e)
        {
            if (waveformGraph.Plots.Count != 0)
            {
                .....

                .....

                        waveformGraph.DoDragDrop(SeqWavArray[WaveformSelected], DragDropEffects.Move);
                   
            }
        }

If I comment waveformGraph.DoDragDrop(....) all is ok.

On the contrary, after the execution of this instruction when the mouse is across a cursor, the horizontal arrows are not displayed.

But by a right click of he mouse, all returns ok.

Thank you for any suggestion.

 

Filippo

 

0 Kudos
Message 3 of 10
(5,330 Views)

I must say its a tricky use of WaveformGraphs.

I am trying to imitate what you are trying to do. But I didn't quite understood the cursor part, how it is suppose to work.
Instead of the DragDrop i used mouse up to move plots from one section to the other. There is no animation but it works great for me.

Check the attached code (Form1.cs).

Let me know if this is not what you intended. Also, you could elaborate on the cursor issue that you are concerned with. That will help us in solving the issue that you are facing.

Vijet Patankar

National Instruments

0 Kudos
Message 4 of 10
(5,327 Views)

Thanks Vijet, for your code.

It works,  but I found the same problem with cursors, even if it's less visible than in my case. After selecting a plot, by moving the mouse over a cursor, the mouse cursor don't change to arrows. This occurs after a mouse click, so the problem is less visible that in my code, where I select a plot by clicking in the plot section and not only in the plot.

See the attached print screen obtained with your code, before a selection and after a selection (but without any mouse click after the selection).

Thanks in advance.

 

Filippo

Download All
0 Kudos
Message 5 of 10
(5,290 Views)

Hi there,

I still have couple of doubts and some suggestions. Let me know if I understood the problem correctly.

  1. While you are moving the plot to another section (by clicking and hence selecting a plot first, and then move the mouse over to another section without releasing the mouse button), if you now move the mouse over a XYCursor (either over horizontal or vertical cursor line or both) the mouse cursor wont change to horizontal arrow (or vertical arrow). If this is what you mean, then that is how it should work. With the mouse in clicked state, mouse move event is not fired for an item (control, form etc) if the mouse click event happened on some other item.
  2. Are you saying that when you move the over a XYCursor and when mouse button is released, the plot is not moved to the new section?
  3. Do you want the plot to be selected whenever you click on the section area, irrespective of the plot or a XYCursor? If so, then it defeats the use of the XYCursor. You could  reduce the lenght of the XYCursor lines or totaly make them invisible. See the XYCursor.HorizontalCrosshairMode and XYCursor.HorizontalCrosshairLength properties.
  4. If you need the XYCursor just for the sake of highlighting a specific data point, then you can do it by not using cursors at all. You can get the coordinates in pixels for your data by using Plot.MapDataPoint() and Plot.MapDataPoints() methods. Now you have a point within the grah where you can draw something to highlight the data that you are interested in.
  5. It is good and easy to select a plot when mouse click happens anywhere within the section area. But this will not allow you to have multiple plots at the same section. You will run into the problem of which plot is to be selected!

 

I hope this helps. If you still have concerns, feel free to reply. It would be great if you write down step-by-step actions to be performed to re-produce the issue. By step-by-step I mean, something like,

 

1) The graph has X sections with Y number of sections filled with plots.

1) Click on a section with plot (not on the XYCursor) to select a plot.

2) Without releasing the mouse button, move the mouse to XYCursor on another section...

3) ....


Vijet Patankar
National Instruments

0 Kudos
Message 6 of 10
(5,271 Views)

Hi,

sorry for my explanation not very clear and thanks for your patience.

The problem is that you are described in your first point, but by relaising the mouse button after selecting a plot.

Step by step:

1) The graph has X sections filled with X plots. Each section is separated from the next section by a XYCursor

2) Click on a section with plot (not on the XYCursor) to select a plot and realease the mouse button.

3) Move the mouse over whatever XYCursor (either over horizontal or vertical cursor line or both) and the mouse cursor wont change to horizontal arrow (or vertical arrow)

4) Click on the graph, but not on a section with plot, to return to a normal behaviour (in your code is sufficient  to click not on a plot) 

 

I hope that now is more clear. However, I will make a short version of my project to post it.

 

Filippo

0 Kudos
Message 7 of 10
(5,266 Views)

In attachement, there is a short version of my project with 10 plots.

 

I now realize that to return to a normal behaviour is sufficient to press Control or Shift key(that changes the default interaction mode)  or also to change the active window and then return to the apllication window. Also if I debug with a breakpoint in the DragDrop event code, the behaviour is correct.

 

What I think is that when the DoDragDrop instruction is executed the drag doesn't terminate, also after the execution of DragDrop event. It seems instead, it's terminate, for example, by pressing Control key. Is it possible to terminate programmatically the drag action ?

 

Filippo

0 Kudos
Message 8 of 10
(5,260 Views)

Hi Filippo,

The culprit is the DoDragDrop() method. It consumes MouseUp and MouseMove events, meaning MouseUP and MouseMove events are not fired if drag drop is being used. This is not a bug, but thats is how .NET controls work (you can check this behavior with button control).

 

Internally the XYCursor listens to mouseMove and mouseUp events, but they are not raised because of the DoDragDrop() method. Because of this, the XYCursor are behaving unexpectedly.

However, I modified your code and got this. I did not use XYCursor in the code.

Hope this helps.

Vijet Patankar
National Instruments

0 Kudos
Message 9 of 10
(5,211 Views)

Hi Vijet,

thank for your code: with few small modifications it's ok for me.

Thank a lot.

 

Filippo

0 Kudos
Message 10 of 10
(5,120 Views)