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 » U++ Core » Rect_<T>::SetNull not correct for Rectf (Rect_<double>)
Rect_<T>::SetNull not correct for Rectf (Rect_<double>) [message #31959] Mon, 11 April 2011 22:25 Go to next message
hans is currently offline  hans
Messages: 44
Registered: March 2006
Location: Germany
Member
Hi,
latest addition of SetNull is implemented as
void   SetNull()                        { left = top = right = bottom = Null; }


but template specialisation for Rect_<double>(Null) is implemented as
template <>
inline Rect_<double>::Rect_(const Nuller&) {
	left = top = 0;
	right = bottom = -1;
}


I would suggest to implement SetNull as
void   SetNull()                        { *this= Rect_(Null); }

which works for Rect_<T> for generic T and specialisation.

Thanks,
Hans

[Updated on: Mon, 11 April 2011 22:27]

Report message to a moderator

Re: Rect_<T>::SetNull not correct for Rectf (Rect_<double>) [message #31965 is a reply to message #31959] Tue, 12 April 2011 09:44 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
the question is which of the 2 API calls is the right one. since currently there are the 2.

this recently added approach is one similar to Size..

so it probably should be sth like
template <>
inline Rect_<double>::Rect_(const Nuller&) {
	SetNull();
}


it seems as if there is some duplicated code

EDIT:
the problem seems to be that Rect_<double> seems to need a different Null handling

EDIT: mirek could clear up why Rect_<double> needs extra treatment (i imagine because of Ctrl drawing handling)

but maybe the above approach could be generalized for both

[Updated on: Tue, 12 April 2011 11:29]

Report message to a moderator

Re: Rect_<T>::SetNull not correct for Rectf (Rect_<double>) [message #32002 is a reply to message #31965] Sat, 16 April 2011 20:42 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Should be fixed now.

kohait00 wrote on Tue, 12 April 2011 03:44


EDIT:
the problem seems to be that Rect_<double> seems to need a different Null handling

EDIT: mirek could clear up why Rect_<double> needs extra treatment (i imagine because of Ctrl drawing handling)

but maybe the above approach could be generalized for both


Well, Rect<double> is a strange beast. The problem is that whereas for integer types, it is possible to define that points of rect are defined as

(x >= left && x < right && y >= yop && y < bottom)

for double this is not a good solution, you rather need

(x >= left && x <= right && y >= yop && y <= bottom)

which is the source of all differencies.
Re: Rect_<T>::SetNull not correct for Rectf (Rect_<double>) [message #32017 is a reply to message #32002] Sun, 17 April 2011 14:39 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
damn math Smile thanks for fixing..

Re: Rect_<T>::SetNull not correct for Rectf (Rect_<double>) [message #32087 is a reply to message #32017] Thu, 21 April 2011 08:28 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
Color should have an explicit SetNull like the others..
(need it for my Python export Smile looks good.. )

Color.h:41
+	void     SetNull()                 { color = 0xffffffff; }
	Color()                            { SetNull(); }
	Color(const Nuller&)               { SetNull(); }

[Updated on: Thu, 21 April 2011 10:14]

Report message to a moderator

Re: Rect_<T>::SetNull not correct for Rectf (Rect_<double>) [message #32110 is a reply to message #32087] Mon, 25 April 2011 10:46 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
kohait00 wrote on Thu, 21 April 2011 02:28

Color should have an explicit SetNull like the others..
(need it for my Python export Smile looks good.. )

Color.h:41
+	void     SetNull()                 { color = 0xffffffff; }
	Color()                            { SetNull(); }
	Color(const Nuller&)               { SetNull(); }



OK. Will commit in the evening...
Previous Topic: ADDs: ValueMap
Next Topic: FIX: UPP::Scan returns int64 for INT_V
Goto Forum:
  


Current Time: Sat Apr 27 15:08:09 CEST 2024

Total time taken to generate the page: 0.03095 seconds