Hi,
I'm bending OGL's purpose a little and trying to use it as a very simple 2D mapping
component (if anyone knows a better solution I'd love to hear it!).
So, I've got many small bitmaps arranged on a background. When I delete them I
eventually exhaust the GDI heap.
my delete involves
dc = wxClientDC(self)
shape.Erase(dc)
self.theDiagram.RemoveShape(shape)
shape.SetCanvas(None)
shape.Destroy()
self.Refresh()
shape has a getrefcount() of 4, which is odd. 1 for getrefcount, 1 in the delete
function but the others I can't account for.
My first thought was the shapes are being kept alive, but it appears that
deleting exhausts the heap much quicker than adding alot of bitmap shapes.
So perhaps its the refresh thats causing some sort of duplication??
Has anyone got any ideas or experience with this?
Cheers
···
--
wxPython
python@lee-morgan.net wrote:
Sorry I can't help you with theGDI heap problem...
I'm bending OGL's purpose a little and trying to use it as a very simple 2D mapping
component (if anyone knows a better solution I'd love to hear it!).
I ttok another route, deciding that I would be bending OGL's purpose too
mush to tbe worth it.
I now have a class that creates a window that will display objects
(polygons, text, rectangles, circles, etc) in Lat-long space (or any
floating point coordinates). It is zoomable and scollable, does a simple
flat-earth projection. I hav't had the chance to work on it for a while,
but I'm hoping to re-visit it soon.
I'd be glad to send it to you if you like, and be even happier if you
want to contribute to it! What are your requirements for a "2d mapping
component"?
Let me know if you want to take a look.
-Chris
···
--
Christopher Barker,
Ph.D.
ChrisHBarker@home.net --- --- ---
http://members.home.net/barkerlohmann ---@@ -----@@ -----@@
------@@@ ------@@@ ------@@@
Oil Spill Modeling ------ @ ------ @ ------ @
Water Resources Engineering ------- --------- --------
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------
Uh, what an interesting notice. Do you think you can share the code? I
have already wrapped the project library and have made also some
simple classes for distance, angle calculations. It would be really
nice to create an app which integrates these two.
TIA,
__Janko
···
--
Institut fuer Meereskunde phone: 49-431-597 3989
Dept. Theoretical Oceanography fax : 49-431-565876
Duesternbrooker Weg 20 email: jhauser@ifm.uni-kiel.de
24105 Kiel, Germany
Right now I use OGL to connect unit operations (shapes) and when ever I
load a new case, I delete all the shapes from it, and then add the new
ones, and I still haven't had those problems (maybe I haven't tested
enough though).
I just ran my application and opened and closed cases a lot of times, to
see if I get that problem and I didn't (but I don't really know what
"many" menas for you).
#This is how I delete shapes (code for deleting lines not included).
canvas = self.pfd
dc = wxClientDC(canvas)
canvas.PrepareDC(dc)
redraw = false
#imgsUO is a member dict with an instance of all the shapes
for i in canvas.imgsUO.keys():
shape = canvas.imgsUO[i]
canvas.RemoveShape(shape)
del canvas.imgsUO[i]
shape.Destroy()
canvas.Refresh()
The only difference I see is that I don't use Erase (sorry, I haven't
done reference count yet)
Raul
I use Win NT, wxPython 3.2.1
python@lee-morgan.net wrote:
···
Hi,
I'm bending OGL's purpose a little and trying to use it as a very simple 2D mapping
component (if anyone knows a better solution I'd love to hear it!).
So, I've got many small bitmaps arranged on a background. When I delete them I
eventually exhaust the GDI heap.
my delete involves
dc = wxClientDC(self)
shape.Erase(dc)
self.theDiagram.RemoveShape(shape)
shape.SetCanvas(None)
shape.Destroy()
self.Refresh()
shape has a getrefcount() of 4, which is odd. 1 for getrefcount, 1 in the delete
function but the others I can't account for.
My first thought was the shapes are being kept alive, but it appears that
deleting exhausts the heap much quicker than adding alot of bitmap shapes.
So perhaps its the refresh thats causing some sort of duplication??
Has anyone got any ideas or experience with this?
Cheers
--
wxPython
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users
writes:
Sorry I can't help you with theGDI heap problem...
> I'm bending OGL's purpose a little and trying to use it as a very simple 2D mapping
> component (if anyone knows a better solution I'd love to hear it!).
I ttok another route, deciding that I would be bending OGL's purpose too
mush to tbe worth it.
I now have a class that creates a window that will display objects
(polygons, text, rectangles, circles, etc) in Lat-long space (or any
floating point coordinates). It is zoomable and scollable, does a simple
flat-earth projection. I hav't had the chance to work on it for a while,
but I'm hoping to re-visit it soon.
I'd be glad to send it to you if you like, and be even happier if you
want to contribute to it! What are your requirements for a "2d mapping
component"?
Let me know if you want to take a look.
Yes please. I'd also be happy to contribute, to some wxpython component to do
this.
At the moment my requirements are very simple - scrollable, object positioning,
fp co-ords, no projection corrections, drop down menus on the objects. Currently
I'm using small bitmaps to represent objects - likely to be the main cause of my
GDI probs - but could use shapes instead. Ideally i'd like to be able to switch
between the two.
In the future I'd like to add object rotations, waypoint/keyposition nodes,
group selection, a way of layering maps - selectable terrain/road network/grid
etc, map in map location box etc etc. There's bound to be other stuff I may need
but at this point I should remind myself I'm much more efficient at dreaming up
new functionality than at implementing it!
···
python@lee-morgan.net wrote:
-Chris
--
Christopher Barker,
Ph.D.
ChrisHBarker@home.net --- --- ---
http://members.home.net/barkerlohmann ---@@ -----@@ -----@@
------@@@ ------@@@ ------@@@
Oil Spill Modeling ------ @ ------ @ ------ @
Water Resources Engineering ------- --------- --------
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------
--
wxPython
Raul Cota <cota@ucalgary.ca> writes:
Right now I use OGL to connect unit operations (shapes) and when ever I
load a new case, I delete all the shapes from it, and then add the new
ones, and I still haven't had those problems (maybe I haven't tested
enough though).
I just ran my application and opened and closed cases a lot of times, to
see if I get that problem and I didn't (but I don't really know what
"many" menas for you).
#This is how I delete shapes (code for deleting lines not included).
canvas = self.pfd
dc = wxClientDC(canvas)
canvas.PrepareDC(dc)
redraw = false
#imgsUO is a member dict with an instance of all the shapes
for i in canvas.imgsUO.keys():
shape = canvas.imgsUO[i]
canvas.RemoveShape(shape)
del canvas.imgsUO[i]
shape.Destroy()
canvas.Refresh()
The only difference I see is that I don't use Erase (sorry, I haven't
done reference count yet)
You're right, Erase is superflous - left over from when I wanted to delete a
shape without causing a whole diagram refresh.
Yes, I dont get the problem if I delete all, which I do (similarly to your code)
for shape in self.theDiagram.GetShapeList():
if shape.GetId() != self.backgroundShapeID:
self.theDiagram.RemoveShape(shape)
shape.SetCanvas(None)
shape.Destroy()
# print 'bitmap refcount',sys.getrefcount(self.featureTemplates[0].wxbitmap)
self.featureTemplates =
but I do when deleting one, which perhaps suggests an internal issue when
removing one shape and calling refresh. Or perhaps <canvas>.RemoveShape()
actually does more than call <canvas>.<diagram>.RemoveShape(). Hmm, more testing
needed to find out what I'm doing wrong.
Given I have to refresh the whole diagram on a delete its probably only a
marginal cost to deleteAll and recreate them.
Thanks for the help.
···
Raul
I use Win NT, wxPython 3.2.1
python@lee-morgan.net wrote:
>
> Hi,
>
> I'm bending OGL's purpose a little and trying to use it as a very simple 2D mapping
> component (if anyone knows a better solution I'd love to hear it!).
>
> So, I've got many small bitmaps arranged on a background. When I delete them I
> eventually exhaust the GDI heap.
>
> my delete involves
>
> dc = wxClientDC(self)
> shape.Erase(dc)
> self.theDiagram.RemoveShape(shape)
> shape.SetCanvas(None)
> shape.Destroy()
> self.Refresh()
>
> shape has a getrefcount() of 4, which is odd. 1 for getrefcount, 1 in the delete
> function but the others I can't account for.
>
> My first thought was the shapes are being kept alive, but it appears that
> deleting exhausts the heap much quicker than adding alot of bitmap shapes.
>
> So perhaps its the refresh thats causing some sort of duplication??
>
> Has anyone got any ideas or experience with this?
>
> Cheers
>
> --
> wxPython
>
> _______________________________________________
> wxpython-users mailing list
> wxpython-users@lists.wxwindows.org
> http://lists.wxwindows.org/mailman/listinfo/wxpython-users
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users
--
wxPython