Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












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

index.php?t=getfile&id=4293&private=0

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 596 times)

[Updated on: Sat, 07 September 2013 12:17]

Report message to a moderator

Re: ScatterCtrl, 2 questions. [message #40615 is a reply to message #40596] Fri, 23 August 2013 16:29 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello rxantos

To be sure of your questions:

- You want to programatically zoom the data just to fit data in X and Y axis
- You want to avoid that the user would over zoom out the data.


Best regards
IƱaki
Re: ScatterCtrl, 2 questions. [message #40618 is a reply to message #40615] Fri, 23 August 2013 17:07 Go to previous messageGo to next message
rxantos is currently offline  rxantos
Messages: 72
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 #40620 is a reply to message #40618] Fri, 23 August 2013 18:02 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello rxantos

- Now there is SetMaxZoom(double x, double y = -1). It "Sets x and y as the maximum zoom factor. If y is -1, only x zoom is considered.". Is it enough for you?

- About the spikes, SetFastViewX() renders faster as it only takes a point per pixel column, so there is data that is discarded. However i am surprised that it does not work for you saving the control to a .png image. Could you confirm this? You can do it with a sv.SaveToFile(filename).


Best regards
IƱaki
Re: ScatterCtrl, 2 questions. [message #40627 is a reply to message #40620] Sat, 24 August 2013 07:21 Go to previous messageGo to next message
rxantos is currently offline  rxantos
Messages: 72
Registered: October 2011
Member
Here is a screen shot of the control.
index.php?t=getfile&id=4295&private=0

[Updated on: Sat, 24 August 2013 07:22]

Report message to a moderator

Re: ScatterCtrl, 2 questions. [message #40628 is a reply to message #40627] Sat, 24 August 2013 07:24 Go to previous messageGo to next message
rxantos is currently offline  rxantos
Messages: 72
Registered: October 2011
Member
And here is the resulting png. Look how in the result it has the spikes (what I need) and in the other it doesn't. I do not mind updating one second. But need to identify spikes.

index.php?t=getfile&id=4296&private=0


Now that I think of it, it might be that the result is bigger in the png, thus less bars skipped.

Anyway, to keep things simple.

What would be the calls to:
- Disable bar skipping. Maybe enabling it while zooming and do a full render after the image is at the size the user one.

- Limiting the zoom out. If for example the data in x is 0 to 100, do not let the borders to be <0 or greater than 100.

  • Attachment: test.png
    (Size: 125.37KB, Downloaded 480 times)

[Updated on: Sat, 24 August 2013 07:30]

Report message to a moderator

Re: ScatterCtrl, 2 questions. [message #40629 is a reply to message #40628] Sat, 24 August 2013 07:33 Go to previous messageGo to next message
rxantos is currently offline  rxantos
Messages: 72
Registered: October 2011
Member
Just in case the sample code.

BTW: Thanks for taking time to respond.
Re: ScatterCtrl, 2 questions. [message #40630 is a reply to message #40629] Sat, 24 August 2013 09:53 Go to previous messageGo to next message
jerson is currently offline  jerson
Messages: 202
Registered: June 2010
Location: Bombay, India
Experienced Member

I found this .SetFastViewX() to be causing the behavior you describe.

Hope that helps
Re: ScatterCtrl, 2 questions. [message #40631 is a reply to message #40630] Sat, 24 August 2013 11:04 Go to previous messageGo to next message
rxantos is currently offline  rxantos
Messages: 72
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

Embarassed 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:
index.php?t=getfile&id=4299&private=0
by using the mouse wheel.


Re: ScatterCtrl, 2 questions. [message #40634 is a reply to message #40631] Sat, 24 August 2013 19:12 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello rxantos

- About the spikes
You can see that when changing the window size. The bigger the window, the more spikes you can see. This is of course a limitation of SetFastViewX(): if data "jumps" too much, much information is lost.

- About the data range
Your use of SetMaxZoom(NPOINTS) is not right as it works with zoom factor instead of with data range.
To take care of this some new functions will be added tomorrow to set visible limits:
-- The minimum X and Y (X = 0 in your case)
-- The maximum X and Y (X = 1000 in your case)
-- The minimum X and Y ranges (X = 10 in your case)
-- The maximum X and Y ranges (X = 1000 in your case)


Best regards
IƱaki
Re: ScatterCtrl, 2 questions. [message #40636 is a reply to message #40634] Sun, 25 August 2013 04:27 Go to previous messageGo to next message
rxantos is currently offline  rxantos
Messages: 72
Registered: October 2011
Member
Thank you.
Re: ScatterCtrl, 2 questions. [message #40656 is a reply to message #40636] Mon, 26 August 2013 18:50 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello rxantos

Still working on it. I will try to upload it tomorrow.


Best regards
IƱaki
Re: ScatterCtrl, 2 questions. [message #40663 is a reply to message #40656] Thu, 29 August 2013 08:08 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello rxantos

It is done. Added and documented SetMinRange(), SetMaxRange(), SetMinXmin(), SetMinYmin(), SetMaxXmax(), SetMaxYmax().

To try to compensate the delay, the control now highlights when a limit in zoom or scroll is reached Smile

You could put this in your code:
.SetMaxRange(1000).SetMinRange(10).SetMinXmin(0).SetMaxXmax(1000);


In addition instead of rand() there is a Random(dword max) to get a random number smaller than max.

My next comment was wrong Rolling Eyes SetMaxZoom() == SetMaxRange(). It sets the visible data range.
Quote:

Your use of SetMaxZoom(NPOINTS) is not right as it works with zoom factor instead of with data range.



Best regards
IƱaki
icon14.gif  Re: ScatterCtrl, 2 questions. [message #40664 is a reply to message #40663] Thu, 29 August 2013 10:48 Go to previous messageGo to next message
rxantos is currently offline  rxantos
Messages: 72
Registered: October 2011
Member
Just tried and is now perfect. Thanks.

I have another question. When zooming the text in the X axis sometimes overlaps.

index.php?t=getfile&id=4310&private=0
Re: ScatterCtrl, 2 questions. [message #40670 is a reply to message #40664] Fri, 30 August 2013 08:18 Go to previous message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Rxantos

It is now solved.


Best regards
IƱaki
Previous Topic: Can't add asembly from bazzar
Next Topic: Painter 2.0 Path definition: mix of cubics and quadratics
Goto Forum:
  


Current Time: Fri Apr 19 09:34:42 CEST 2024

Total time taken to generate the page: 3.01165 seconds