GetLabelPosFromShape (was: update question)

Bernhard Reiter bernhard at intevation.de
Wed Oct 4 18:31:08 CEST 2006


On Friday 29 September 2006 15:56, Didrik Pinte wrote:
> > > [1] Concerning the modification of the Thuban/UI/viewport.py file, i've
> > > just extracted some code of the LabelShapeAt method in order to be used
> > > by a more general method that will allow the user to label a complete
> > > layer by selecting a field of the associated table. See
> > > http://wald.intevation.org/tracker/index.php?func=detail&aid=121&group_
> > >id=6 &atid=108 The new method GetLabelPosForShape is at the moment in
> > > the viewport.py file but IMHO, it could be moved to the
> > > Thuban/Model/map.py file. What do you think about this ? Is there an
> > > other place that could be more appropriate ?
> >
> > Extracting methods, if you need the functionality from different places
> > in the code is the right idea.
> > (I am currently commenting offline.)
> > Without having seen the method your are extracting I cannot comment
> > on the best place. From looking at LabelShapeAt I believe it works quite
> > closly to windows coordinates which I would consider UI dependent.
> > So what is your idea in moving thi sot Model/map.py?
>
> Here is the explanation (see code below or diff in attachement). The
> piece of code in the old LabelShapeAt method concerning the label
> positioning can be used pretty easily for any shape_index and layer. So,
> i've extracted all this code to a new method called
> GetLabelPosFromShape. This new method return a(x, y, halign, valign)
> tuple when called with a layer and a shape_index.
>
> Because the new GetLabelPosFromShape is not really UI related, I would
> propose to extract it to Model/map.py.

Looking at this a bit, I believe that it is fine to move GetLabelPosFromShape
from UI to Model. Why not using Model/layer.py as the funcation seems to 
deal with data on a layer level? Maybe Model/label.py could also be considered
as it has the related function AddLabel() already.
Given the layer data it works on, I think Model/layer.py would be fine.
What speaks for Model/map.py?

-- 
Managing Director - Owner, www.intevation.net       (Free Software Company)
Germany Coordinator, fsfeurope.org       (Non-Profit Org for Free Software)
www.kolab-konsortium.com   (Email/Groupware Solution, Professional Service)




More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)