measure.py revision e7bafc69cc367122b93ff2659a151d2792e387a7
'''
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) 2010 Alvin Penner
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
area = 0.0
n0 = 0.0
x0 = 0.0
y0 = 0.0
n0 += 1.0
bezarea = ( 0.0*sp[i-1][1][1] + 2.0*sp[i-1][2][1] + 1.0*sp[i][0][1] - 3.0*sp[i][1][1])*sp[i-1][1][0]
bezarea += (-2.0*sp[i-1][1][1] + 0.0*sp[i-1][2][1] + 1.0*sp[i][0][1] + 1.0*sp[i][1][1])*sp[i-1][2][0]
help="Type of measurement")
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
# Removed to fix LP #308183
# (Measure Path text shifted when used with a copied object)
#if t:
# self.group.set('transform', t)
a =[]
num = 1
else:
# Format the length as string
lenstr = locale.format("%(len)25."+str(prec)+"f",{'len':round(stotal*factor*self.options.scale,prec)}).strip()
else:
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)+')')
new = inkex.etree.SubElement(node,inkex.addNS('tspan','svg'), {inkex.addNS('role','sodipodi'): 'line'})
s = {'text-align': 'center', 'vertical-align': 'bottom',
'fill-opacity': '1.0', 'stroke': 'none',
'font-weight': 'normal', 'font-style': 'normal', 'fill': '#000000'}
if __name__ == '__main__':
e = Length()
e.affect()
# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99