QControl Enthusiasts

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding functionalities to XY Graph - Waveform Chart - Waveform Graph

Hello there !

 

I have already done in the past a tool using LVOOP to apply a color gradient to plots in a graph and display the color scale corresponding to that graph (picture: ScaleAndGraph). 

 
 

I used two class:

. One to hold the three kinds of graphs

. The second to hold the color scale (picture: ScaleAndGraph)

 

The results was a unique vi which needed to have the references to the scale and to the graph and some parameters (picture: CodeScaleAndGraph - Comments writtten in french).

 

I'm thinking to re-do this stuff using QControls.

 

But I have a few questions about what can be the best way to do this :

 

. Do I need to create three QControl ?

     . One to hold the graphs

     . The second to hold the scale

     . A third to combine these two? Cluster ?

 

. The VI server doesn't define the waveform Chart/Graph and XY graph on the same level (picture ViServerGraphicHierarchy), that's why I created a "Graph.lvclass" (picture GraphHierarchy).

Doing this could to use on VI without thinking about which kind of graph I use.

Can I obtain this kinds of uses with QControl ?

If not, I think that I'll get my old tool.

 

Thank you for reading,

 

Loïc.W

0 Kudos
Message 1 of 5
(3,139 Views)

Loic,

 

I wanted to let you know, I have seen your post and I am trying to think through how to help.  I'll write another post when I get back to my computer.  However, before that, here is some ideas:

 

First, when selecting which class to inherit from for your QControl, you have to decide which Properties and Methods you want to have automatically exposed for you by the QControl Toolkit based off of the reference you will give to it as input. You can just inherit from "Control" and any reference that is a Control or a descendant of Control could be inputted and then only Properties and Methods of Control would show automatically.  In your case, you could create your main class by inheriting from a common ancestor of Waveform Chart/Graph and XY Graph.  Which would be "GraphChart".

 

Next, you would add a reference to the picture control for your Scale to the constructor VI.  So it would have two reference inputs: one for GraphChart and one for Picture.  The edit the constructor and the rest of your code to handle the more specific references internally.

 

Then, you could either handle specific types internally in the one class or further inherit from that class to make the specific instances for XY Graph, Waveform Graph, and Waveform Chart.  Each one of the constructors would need to be modified to add the picture control.

 

I will try to make an example and post it here later. 

Quentin "Q" Alldredge

Chief LabVIEW Architect, Testeract | Owner, Q Software Innovations, LLC (QSI)
Director, GCentral | Admin, LabVIEW Wiki | Creator, The QControl Toolkit
Certified LabVIEW Architect | LabVIEW Champion | NI Alliance Partner



0 Kudos
Message 2 of 5
(3,112 Views)

Hi,

 

Thx for the reply.

Instead of rework my old code I tried to add a "preview" option to a graph.
I understand better how to use QControl now.

I don't know if I used the best practice but the result looks well.

Let me know what you're thinking about it.

 

Note : I used OpenG fonction in the code.

Loïc.

0 Kudos
Message 3 of 5
(3,060 Views)

The concept works great. A bit of feedback:

 

-There appear to be 3 working examples in your code, only one of which uses Qcontrols, and it was kind of hard to find at first (for others: inside the project, it's in GraphPreview/GraphPreview.lvclass/Tester/Tester.vi)

-It didn't quite work right when I first loaded it. The smaller window didn't have anything in it at all, and the sliders didn't match up with the selected area. It turns out the slider's min an max were set to ~0.2 and 0.7. Changing that to 0 to 1 made it work. I'd recommend setting these properties in the Constructor.

-If the two cursors overlap, they will stop working. See this post for a way to fix that: https://forums.ni.com/t5/LabVIEW/Limit-range-of-one-slider-to-the-other-slider-s-value-on-a-two/m-p/...

-I'd recommend using a method instead of a property node to write new data to the graph. That way you get your type checking done properly instead of writing to a variant (useful if others are using the code- it will be obvious what type of data you should be writing to the plot) You can even make this polymorphic or malleable so it can accept data of different types and do the conversions internally. For example, it could accept either a single array (assume the array is Y data, use 0,1,2... for X), or two arrays (one is X array, one is Y array), single Wfm data, array of Wfm data, etc.

-If you're using this for very large data sets (it's not worth it if not), I'd recommend keeping your data in an internal variable and sending a decimated version to the plot itself. This will increase your plot draw speed. Say you have 1 million points and only 500 pixels to show it- you can reduce your data set by a lot before plotting it in the "full" graph. There are multiple ways to do this. Some of which include:

-Simply pick every n points (quickest and easiest)

-Average every n points (slower but better fidelity, use median or mean depending on data content)

-Take the min and max values of every 2*n points and plot those (useful if you're looking for very specific peaks and valleys, but shows lots of noise)

-Etc

In those examples, n = total points / pixel width. For a 1,000,000 point graph and a 500 pixel image, n = 2000)

 

The concept works great. Those thoughts are definitely minor as the code clearly works well now. Great work so far. You've given me some ideas on how to do something similar for some code that gets passed around the office a lot!

0 Kudos
Message 4 of 5
(3,046 Views)

Hi,

Thx BertMcahan for the reply, I made some changes as you suggested and add a click+drag option to move the window (Left/Right).

About your feedback :


"-There appear to be 3 working examples in your code, only one of which uses Qcontrols, and it was kind of hard to find at first (for others: inside the project, it's in GraphPreview/GraphPreview.lvclass/Tester/Tester.vi)"
As I still working on it, there is some parts where I was testing... My fault.
As you said the QControl can be found here : GraphPreview/GraphPreview.lvclass/Tester/Tester.vi

"-It didn't quite work right when I first loaded it. The smaller window didn't have anything in it at all, and the sliders didn't match up with the selected area. It turns out the slider's min an max were set to ~0.2 and 0.7. Changing that to 0 to 1 made it work. I'd recommend setting these properties in the Constructor."
I fixed it this morning !

-If the two cursors overlap, they will stop working. See this post for a way to fix that: https://forums.ni.com/t5/LabVIEW/Limit-range-of-one-slider-to-the-other-slider-s-value-on-a-two/m-p/...
I used the same solution than the shared post ! (And add a drag option as says earlier)

I don't know yet what to do about data setting and type checking...

I have another problem : The commun ancestor that I used is GraphChart and it doesn't have the "PlotImage" method...
I should implemented type checking for graph and cast it to use this method (actually hardcode...)

I let the latest version !

Thanks for reading.

Loic.W

0 Kudos
Message 5 of 5
(3,013 Views)