PDA

View Full Version : Make a new QwtPlotCurve on a QwtPlot?



bigjoeystud
22nd October 2014, 23:07
I am interested in creating a new QwtPlotCurve on an existing set of overlaid QwtPlots. Something where the user can draw a line (or maybe a set of points and have it connect the dots?) on top of my plot. Looking at the Qwt docs/examples/playground, it seems like the closest thing is the spline editor to what I want as an interface, with the exception of the line drawing interface.

Ideally, after the user has drawn a line, they would be able to change the points of the line like the spline editor where they are moving points up and down.

What I am trying to do is allow a user to follow a certain feature in a plot and trace out where the peaks and valleys are.

Anyway, I know I need to override the event filter and capture the mouse movements, but are there other things in Qwt that could help with this? Is it reasonable to have 1000 symbols across my plot that they can manipulate? Maybe someone has done something similar and can share experience or code?

Thanks for any advice!
Joey

Uwe
23rd October 2014, 09:33
You should also have a look the itemeditor example - it is about shape items, but the general idea of how to implement such an editor ( using a QwtWidgetOverly ) is similar. You could also have a look at QwtPlotPicker ( also using a widget overlay for the rubberband ), where you can create polygons interactively. In opposite the implementation of the spline editor does replots while moving a point - what of course is much easier to implement , but might be too slow for plots with more content.

I have implemented several graphical editors using the widget overlay approach myself - unfortunately those are too specific to make an example that would help more than the itemeditor one. So if you have a good specification for an editor in combination with curves, that could qualify for a demo, let me know.

Uwe

bigjoeystud
23rd October 2014, 23:02
So if you have a good specification for an editor in combination with curves, that could qualify for a demo, let me know.

I can tell you my specification, and maybe it is good enough. I kind of know where to start, but I feel like there is more in the Qwt source that I could be using and that's where I'm stuck. For instance, the QwtPicker and QwtOverlay should be used together to pick the points and hide/show them. I need to save each of the points, but then am I making a QwtPlotCurve or something else (the state machine?)?

In my case, for every X value there should be a single unique Y value that the user has picked. Ideally, a user could click and drag a trace line and have it saved/exported. Alternatively, if he picks a few points across the plot, it would connect the points together and that would be a line. If the user picks in the middle of his trace, he could move the trace line up and down to position it perfectly in the right place. Using zooming/panning, the user could see very small details in the overall plot and make sure the line is picked perfectly!

As I'm writing this, this seems very similar to the "Lasso" tool in Photoshop. You could also have a smart lasso which tries to follow the contours of the image as best it can and then let the user modify it?

One other thing I've seen done is use a boxcar sliding window across a plot to average pixels together so features can be blended and highlighted while noise is removed. Once the noise is removed, tracing along the peaks is easier since there are fewer levels. For this, you might actually need real data which would be harder to do in a small demo.

Joey