Home » Community » Newbie corner » (SOLVED) ScatterCtrl, 2 questions.
(SOLVED) ScatterCtrl, 2 questions. [message #40596] |
Tue, 20 August 2013 12:26  |
rxantos
Messages: 73 Registered: October 2011
|
Member |
|
|
Sorry for the big image. But is easier for me to explain.

The code I use for the example
#include <ScatterCtrl/ScatterCtrl.h>
using namespace Upp;
#define LAYOUTFILE <TestScatter/TestScatter.lay>
#include <CtrlCore/lay.h>
class TestScatter : public WithTestScatterLayout<TopWindow> {
public:
enum {
NPOINTS = 1000,
};
typedef TestScatter CLASSNAME;
Vector<Pointf> points;
TestScatter();
};
TestScatter::TestScatter()
{
int x,y,yMax = 0;
points.SetCount(NPOINTS);
Pointf * pv = points.Begin();
for(x = 0; x < NPOINTS; x++, pv++) {
pv->x = (double)x;
y = rand();
if(yMax < y) {
yMax = y;
}
pv->y = (double)(y);
}
sv.AddSeries(points).Legend("Y").Opacity(0.3).NoMark().Stroke(1);
sv.SetFastViewX().SetSequentialX().SetDrawXReticle().SetDrawYReticle().SetSequentialXAll();
sv.ShowInfo().ShowContextMenu().SetMouseHandling().SetMaxZoom(1000).SetMinZoom(10);
sv.ShowHGrid(false).ShowVGrid(false).SetLabels("X","Y");
sv.SetXYMin(0,0,0).SetRange(NPOINTS, yMax);
sv.Refresh();
Zoomable().Sizeable();
CtrlLayout(*this, "Window title");
}
GUI_APP_MAIN
{
TestScatter().Run();
}
The Layout is just
LAYOUT(TestScatterLayout, 368, 248)
ITEM(ScatterCtrl, sv, HSizePosZ(28, 40).VSizePosZ(24, 24))
END_LAYOUT
The first problem (the one in which the points are not in the correct position) does not happen when the image is exported, only when its shown.
As for the 2nd problem. How I get a zoom out limited to the size of the data?
-
Attachment: scatter.png
(Size: 95.00KB, Downloaded 699 times)
[Updated on: Sat, 07 September 2013 12:17] Report message to a moderator
|
|
|
|
Re: ScatterCtrl, 2 questions. [message #40618 is a reply to message #40615] |
Fri, 23 August 2013 17:07   |
rxantos
Messages: 73 Registered: October 2011
|
Member |
|
|
Thanks for responding.
When the mouse wheel is used, the user can zoom in and out. I want to know how to I limit the zoom out so that the x range is never greater than the data range. In the x I just use 0,1,2,3, etc. Lets say its from 0 to 1,000. Right now if the user zooms out with the wheel, the range goes in the negative in one side and over 1,000 in the other. I want it so that it always stays at a maximum zoom out of 0 to 1000. while allowing a zoom in lets say 0 to 10,
The 2nd problem:
The Y data is not the random I show in the example, but it has the same problem. Sometimes the spikes in the data are skipped and the data seem clean when in reality there is a spike on an area. The problem does not happen when exporting a png from the control only when using the control. My guess is that for speed reason some of the data is skipped when rendering the control. Lets say the same data 0 to 1000 and there are 100 pixels. And point 7 is an 8, point 9 a 100 and point 10 a 10. Sometimes the spike (The 100) is not shown. And sometimes it is. I wonder if there is a setting to avoid this and make it always show the spike (a flag maybe).
|
|
|
|
|
|
|
|
Re: ScatterCtrl, 2 questions. [message #40631 is a reply to message #40630] |
Sat, 24 August 2013 11:04   |
rxantos
Messages: 73 Registered: October 2011
|
Member |
|
|
jerson wrote on Sat, 24 August 2013 03:53 | I found this .SetFastViewX() to be causing the behavior you describe.
Hope that helps
|
A self inflicted problem. Sorry about that.
Thank you, that solved the missing spikes problem.
However the over zoom out one still present.
I tried
// NPOINTS = 1000 the number of points, where x = 0,1,2,...,999
sv.SetMaxZoom(NPOINTS, -1);
and still managed to get something like:

by using the mouse wheel.
|
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Tue May 06 23:31:42 CEST 2025
Total time taken to generate the page: 0.04002 seconds
|