measure.py revision e9df3bcdd3387ec845d1fea626de245aa8d7e93b
'''
This extension module can measure arbitrary path and object length
It adds a text to the selected path containing the length in a
given unit.
Copyright (C) 2006 Georg Wiora
Copyright (C) 2006 Nathan Hurst
Copyright (C) 2005 Aaron Spike, aaron@ekips.org
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
TODO:
* should use the standard attributes for text
* Implement option to keep text orientation upright
1. Find text direction i.e. path tangent,
2. check direction >90 or <-90 Degrees
3. rotate by 180 degrees around text center
'''
# Set current system locale
return pointdistance(sp1[1], sp1[2]) + pointdistance(sp1[2], sp2[0]) + pointdistance(sp2[0], sp2[1])
total = 0
lengths = []
total += l
help="Size of length lable text in px")
help="The distance above the curve")
help="The unit of the measurement")
help="Number of significant digits after decimal point")
help="The distance above the curve")
help="Keep orientation of text upright")
help="The selected UI-tab when OK was pressed")
help="dummy")
# get number of digits
# loop over all selected paths
if t:
a =[]
num = 1
''' Wio: Umrechnung in unit '''
else :
''' Default unit is px'''
factor=1
# Format the length as string
lenstr = locale.format("%(len)25."+str(prec)+"f",{'len':round(stotal*factor*self.options.scale,prec)}).strip()
s = {'text-align': 'center', 'vertical-align': 'bottom',
'fill-opacity': '1.0', 'stroke': 'none',
'font-weight': 'normal', 'font-style': 'normal', 'fill': '#000000'}
#new.append(tp)
#node.set('transform','rotate(180,'+str(-x)+','+str(-y)+')')
e = Length()
e.affect()