Re: A couple of problems with KoShapePaste
Thomas Zander <[email protected]>
| Newsgroups | gmane.comp.kde.devel.koffice |
|---|---|
| Message-ID | <[email protected]> |
On Thursday 4. November 2010 11.58.26 Dmitry Kazakov wrote: > > > It brings the first question, why KoShapePaste::process() first sets > > > the parent of the shape (uses way a) ) and then adds the same shape > > > into a controller (using way b) )? Why can't it just add this shape to > > > the controller in the end of the function? > > > > This way it ensures the parent is who it should be, instead of > > anticipating what the pure virtual controller would do. > > Ok then, but why does it set the parent in the beginning of the function > and add it to the controller in the beginning of the function? Isn't it > possible to write these two lines together one-under-the-other-one? I mean > not to split them with this big loop in the middle. I agree, this seems to have grown apart over time, it would make more sense to move that setParent down and make it into one modular part again. > > > 2) And one more question, if i add a shape using method a) to some > > > other > > > > > > shape that already is a part of some manager, will this shape be > > > painted > > > > on > > > > > the screen (in a KoShapeManager) ? > > > > In most cases, no it won't. > > The shape will also not be found in an update call or when clicking on > > top of > > the shape. > > The child shape has to be explicitly added to all shapeManagers that own > > its > > parent if you want to show it. Adding a shape means the shapeManager puts > > it > > into its rtree which is the managers entire view of the world. > > Why so? Why not just paint the children recursively? Is there any objective > reason against it? Yes, it would be slow as you need to iterate over all shapes for every paint. The most typical way stuff is painted is in a small square. For example if you have a text shape with a blinking cursor. The square thats repainted is 10x20 pixels or so. Using the rtree its easy and cheap to find out which shapes this square intersects with and thus which need to be called to repaint. Any other way takes too much time as you need to iterate over all shapes in a document. For a big document this can be thousands of shapes. -- Thomas Zander