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 » U++ Library support » Draw, Display, Images, Bitmaps, Icons » Problem in dasher.cpp and proposed solution
Problem in dasher.cpp and proposed solution [message #35981] Fri, 13 April 2012 16:02 Go to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Mirek

In dasher.cpp if the line drawn is very long, it enters in an almost endless loop.

void Dasher::Line(const Pointf& p)
{
	if(sum == 0) {
		PutLine(p);
		return;
	}
	Pointf v = p - p0;
	double len = Length(v);
	double pos = 0;
	while(pos + rem < len) {
		pos += rem;
		Put(pos / len * v + p0);
		flag = !flag;
		rem = (*pattern)[patterni];
		patterni = (patterni + 1) % pattern->GetCount();
	}
	rem -= len - pos;
	Put(p);
	p0 = p;
}


If "len" is very high, the program gets stuck in the while loop.

If you could limit this in any way, by limiting or len or the number of iterations of the while loop, the problem gets solved.

Thank you Smile.


Best regards
Iñaki
Re: Problem in dasher.cpp and proposed solution [message #35982 is a reply to message #35981] Sat, 14 April 2012 11:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Fri, 13 April 2012 10:02

Hello Mirek

In dasher.cpp if the line drawn is very long, it enters in an almost endless loop.

void Dasher::Line(const Pointf& p)
{
	if(sum == 0) {
		PutLine(p);
		return;
	}
	Pointf v = p - p0;
	double len = Length(v);
	double pos = 0;
	while(pos + rem < len) {
		pos += rem;
		Put(pos / len * v + p0);
		flag = !flag;
		rem = (*pattern)[patterni];
		patterni = (patterni + 1) % pattern->GetCount();
	}
	rem -= len - pos;
	Put(p);
	p0 = p;
}


If "len" is very high, the program gets stuck in the while loop.

If you could limit this in any way, by limiting or len or the number of iterations of the while loop, the problem gets solved.

Thank you Smile.


If I understand it well, this is the same problem as

http://www.ultimatepp.org/redmine/issues/214

correct?

There is no easy solution to this... Perhaps some rough clip estimate before doing stroke?
Re: Problem in dasher.cpp and proposed solution [message #35983 is a reply to message #35982] Sat, 14 April 2012 13:00 Go to previous message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Mirek

Yes. It seems the same problem.

I think in this case a rough solution could be valid.


Best regards
Iñaki
Previous Topic: Bug: Missing width in DrawArc on X11
Next Topic: how to dispaly moving text has any idea?
Goto Forum:
  


Current Time: Thu Mar 28 20:53:17 CET 2024

Total time taken to generate the page: 0.00910 seconds