[Drawkit] DXF Import Progress / Example
Graham Cox
graham.cox at bigpond.com
Thu Jan 22 19:36:39 PST 2009
On 22 Jan 2009, at 7:47 pm, Allan wrote:
> The floorplan file is another example that is more like the actual
> types of files I will be using. This has thousands of DXF objects in
> it and works OK. Once imported things are a bit slow to drag and I'm
> starting to get a number of crashes that I'll need to dig into at
> some point, but for now at least it works and I've learned quite a
> bit about the DXF format and the DrawKit logic/implementation.
> Graham -- if you happen to try this out I would appreciate it if you
> have any thoughts on the crashes that happen one you try to "select
> all" and "move" the large number of DK objects that I created based
> on the DXF file.
>
Hi Allan,
I'm wondering if this could be due to the (still experimental) BSP
object storage? Unless you deliberately set it to use this however it
should be using the simpler linear storage. Even so, I changed a
number of fundamental areas of the code to accommodate the variable
storage model, so there could have been a bug introduced there. If you
manage to get a stack trace from your crash that would be very helpful.
Dragging within a drawing consisting of thousands of objects is likely
to be slow (even if you are only dragging a few objects) when using
the linear storage model, which is one reason that I've been
experimenting with alternatives. The reason for this is that when the
drawing is updated, every object is tested to see if it intersects the
update region, and of course when dragging you are posting updates at
a (capped) rate of 40 frames per second. The BSP storage model avoids
these lengthy iterations of the entire drawing list, but being new,
I'm not 100% certain it's entirely reliable yet.
I've also been working on some optimisations that will improve things
regardless of the storage model; I hope to be able to release these
soon.
> Another question I have for you, Graham, is what is the correct
> logic in the "simple" DK demo program to do a zoom to fit the entire
> extents of the imported DXF into the area of the drawing that you
> can see on the screen? In other words, how would I implement a "zoom
> extents" command now that I have the DXF imported and it extends
> outside the viewable area? I did play with the GCZoom methods some,
> but couldn't make anything work yet -- but I haven't spent much time
> on that so far.
Brad suggests using -zoomFitInWindow: which will work if the drawing
size is set to the extents of the objects. But if your question is
about how to zoom to the objects that exist ignoring the drawing size
(for example if your objects are all clustered in one corner) then
you'll probably find that -zoomViewToRect: would be more useful.
You'll have to supply a suitable rect, either by calculating it as you
work through importing your objects or afterwards by iterating over
them and forming the union of their bounds - a helpful method for
doing this is [DKObjectOwnerLayer unionOfAllObjectBounds];
--Graham
More information about the Drawkit
mailing list