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 with offset
Problem with offset [message #14674] Thu, 06 March 2008 22:41 Go to next message
kodos is currently offline  kodos
Messages: 111
Registered: March 2008
Experienced Member
Hi,

I'm writing a SvgDraw package, and the basics work already. But now I have a problem with offsets.
When I'm drawing my image directly through my new SvgDraw class everything works fine, but if I draw the image first with a DrawingDraw and then draw this onto my SvgDraw with DrawDrawing the OffsetOp function is still called, but e.g. the coordinates of the DrawEllipseOp are already transformed, so the offset is applied twice. Am I doing something wrong or is this a bug in U++.
Re: Problem with offset [message #14683 is a reply to message #14674] Sat, 08 March 2008 15:13 Go to previous messageGo to next message
kodos is currently offline  kodos
Messages: 111
Registered: March 2008
Experienced Member
OK,

I solved it.
I had to update the actual_offset variable even if I don't use it. After all I still haven't found the reason why I have to update it but it works now Wink .
Re: Problem with offset [message #14687 is a reply to message #14674] Sat, 08 March 2008 17:24 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
kodos wrote on Thu, 06 March 2008 16:41

Hi,

I'm writing a SvgDraw package, and the basics work already. But now I have a problem with offsets.
When I'm drawing my image directly through my new SvgDraw class everything works fine, but if I draw the image first with a DrawingDraw and then draw this onto my SvgDraw with DrawDrawing the OffsetOp function is still called, but e.g. the coordinates of the DrawEllipseOp are already transformed, so the offset is applied twice. Am I doing something wrong or is this a bug in U++.


Well, I would like to investigate this a bit more to be sure it is not U++ problem.

Can you create a simple testcase to demonstrate the issue please?

Mirek
Re: Problem with offset [message #14688 is a reply to message #14687] Sat, 08 March 2008 19:28 Go to previous messageGo to next message
kodos is currently offline  kodos
Messages: 111
Registered: March 2008
Experienced Member
luzr wrote on Sat, 08 March 2008 17:24


Well, I would like to investigate this a bit more to be sure it is not U++ problem.

Can you create a simple test case to demonstrate the issue please?


Sure.

The program should create 4 files. 2 pdf files and 2 svg files. You can see the error in the "svg_DrawingDraw.svg" file. When you remove the "////" comments from the file "SvgDraw.cpp" that file should be the same ass the other svg file and also look identical to the pdf output.

I traced it back to the wsDrawEllipse function in Draw/Drawing.cpp:452 to the DrawingPos parameter which is different, but I don't know why Smile .
Re: Problem with offset [message #14748 is a reply to message #14688] Wed, 12 March 2008 17:13 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
OK, looks like you are right, actual_offset adjustment is required. Not very nice interface definition, but alternative is virtual GetOffset method...

Mirek
Re: Problem with offset [message #14749 is a reply to message #14748] Wed, 12 March 2008 17:59 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
P.S.: Svg-Draw - a good idea. But IMO it would be better to use lower-lever Xml construction instead of XmlNode, if possible.
Re: Problem with offset [message #14750 is a reply to message #14749] Wed, 12 March 2008 18:17 Go to previous messageGo to next message
kodos is currently offline  kodos
Messages: 111
Registered: March 2008
Experienced Member
luzr wrote on Wed, 12 March 2008 17:59

P.S.: Svg-Draw - a good idea. But IMO it would be better to use lower-lever Xml construction instead of XmlNode, if possible.



Hm, do you mean I should directly use a String?
Re: Problem with offset [message #14751 is a reply to message #14750] Wed, 12 March 2008 19:06 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
kodos wrote on Wed, 12 March 2008 13:17

luzr wrote on Wed, 12 March 2008 17:59

P.S.: Svg-Draw - a good idea. But IMO it would be better to use lower-lever Xml construction instead of XmlNode, if possible.



Hm, do you mean I should directly use a String?


XmlTag

Mirek

Re: Problem with offset [message #14753 is a reply to message #14751] Wed, 12 March 2008 20:34 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
luzr wrote on Wed, 12 March 2008 20:06

kodos wrote on Wed, 12 March 2008 13:17

luzr wrote on Wed, 12 March 2008 17:59

P.S.: Svg-Draw - a good idea. But IMO it would be better to use lower-lever Xml construction instead of XmlNode, if possible.



Hm, do you mean I should directly use a String?


XmlTag

Mirek



Yes, XmlNode uses a lot of memory because of the VectorMap. I was thinking about rewriting it with a more memory efficient container. I don't think that the performance difference will mater a lot, because XMLs with a lot of nodes are common, but with a lot of attributes are quite rare.
Re: Problem with offset [message #14755 is a reply to message #14753] Wed, 12 March 2008 21:23 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Wed, 12 March 2008 15:34

luzr wrote on Wed, 12 March 2008 20:06

kodos wrote on Wed, 12 March 2008 13:17

luzr wrote on Wed, 12 March 2008 17:59

P.S.: Svg-Draw - a good idea. But IMO it would be better to use lower-lever Xml construction instead of XmlNode, if possible.



Hm, do you mean I should directly use a String?


XmlTag

Mirek



Yes, XmlNode uses a lot of memory because of the VectorMap. I was thinking about rewriting it with a more memory efficient container. I don't think that the performance difference will mater a lot, because XMLs with a lot of nodes are common, but with a lot of attributes are quite rare.


The question is whether you need a container at all... (I do not know, I have not investigated the code in deep yet).

Mirek

Re: Problem with offset [message #14757 is a reply to message #14755] Thu, 13 March 2008 07:37 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Quote:

The question is whether you need a container at all... (I do not know, I have not investigated the code in deep yet).

Mirek


Didn't you write it Smile?
Re: Problem with offset [message #14763 is a reply to message #14674] Thu, 13 March 2008 16:09 Go to previous messageGo to next message
kodos is currently offline  kodos
Messages: 111
Registered: March 2008
Experienced Member
I looked over the XmlTag class, but I can't see any easy way to use it for the SvgDraw class. The problem is that I can't add XmlTag to another and keep that variable for further manipulations. So I'd have to use a Vector to store the XmlTags, and even than I don't know how I could manage the different depths of the XML tree that occur when offsets are used(I create a group SVG tag for every offset).

But I think it won't be that complicated to use a StringBuffer directly, the only thing is that it won't be as nicely formatted as the output of the Xml classes.

What do you think about it?
Re: Problem with offset [message #14765 is a reply to message #14763] Thu, 13 March 2008 18:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
kodos wrote on Thu, 13 March 2008 11:09

I looked over the XmlTag class, but I can't see any easy way to use it for the SvgDraw class. The problem is that I can't add XmlTag to another and keep that variable for further manipulations. So I'd have to use a Vector to store the XmlTags, and even than I don't know how I could manage the different depths of the XML tree that occur when offsets are used(I create a group SVG tag for every offset).

But I think it won't be that complicated to use a StringBuffer directly, the only thing is that it won't be as nicely formatted as the output of the Xml classes.

What do you think about it?


Well, I think that if it really requires "later" access to already created nodes, XmlNode might be as effective as anything else...

Mirek
Re: Problem with offset [message #14766 is a reply to message #14763] Thu, 13 March 2008 18:37 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
I was bored and curious, so I thought I'd have a go at doing this with just a StringBuffer (well, two actually) and XmlTags. It's not too complicated, and the results are identical to your version (I'm not sure if I fixed the offset bug correctly or not though). I've attached the results in case they are of interest.

To finish it you would need to add a stack of Rects to allow retrieval of the clipping/offset area, but I have no idea how that works so I haven't bothered Smile. Ideally you don't really want to use XmlTag either, since this forces a DeXml call on every attribute but it makes the code simpler.

If you are worried about being able to change it on the fly, couldn't you just convert the final string into an Xml tree and then modify it? There is no interface in Draw to allow modification of previous elements anyway.

EDIT: I stupidly uploaded versions of the files that didn't compile. Fixed now.
  • Attachment: SvgDraw.h
    (Size: 2.35KB, Downloaded 385 times)
  • Attachment: SvgDraw.cpp
    (Size: 7.71KB, Downloaded 663 times)

[Updated on: Thu, 13 March 2008 19:42]

Report message to a moderator

Re: Problem with offset [message #14767 is a reply to message #14674] Thu, 13 March 2008 18:57 Go to previous messageGo to next message
kodos is currently offline  kodos
Messages: 111
Registered: March 2008
Experienced Member
This is more or less what I intended to do, but thanks for the work Smile
If I have time I will test it a bit and then post it in the Bazaar forum.
Re: Problem with offset [message #14802 is a reply to message #14767] Sat, 15 March 2008 14:34 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
kodos wrote on Thu, 13 March 2008 13:57

This is more or less what I intended to do, but thanks for the work Smile
If I have time I will test it a bit and then post it in the Bazaar forum.


Be quick, this seems to be a nice quick addition to U++ Smile

Just tell me when things are ready.

Mirek
Re: Problem with offset [message #14815 is a reply to message #14674] Sat, 15 March 2008 18:19 Go to previous message
kodos is currently offline  kodos
Messages: 111
Registered: March 2008
Experienced Member
I have rewritten the class with the help of mrjts code to use XmlTags.

I have opened a thread in the Bazaar:
http://www.ultimatepp.org/forum/index.php?t=msg&goto=148 14&#msg_14814
Previous Topic: Rescale and copy area of source image into an area of dest image
Next Topic: How can I use RectTracker in a rubber-band like operation?
Goto Forum:
  


Current Time: Fri Mar 29 14:19:38 CET 2024

Total time taken to generate the page: 0.01099 seconds