View Issue Details

IDProjectCategoryView StatusLast Update
0002047ScribusScripterpublic2005-06-24 18:42
Reporterfcoiffie Assigned Toringerc 
Status closedResolutionfixed 
Platformi386OSLinuxOS VersionGentoo
Product Version1.3.0cvs 
Fixed in Version1.3.0cvs 
Summary0002047: Function to convert unit in another unit (mm -> pt)
DescriptionI'm looking for a way to convert a size in mm to a size in pt in a Python script.
I can't find any function like that.

I think it should be useful to add a function which can convert units (mm, picas...) in pt.
TagsNo tags attached.


related to 0001689 closedcbradney Move all measurement calculations to units.cpp/.h 
related to 0002053 closedringerc Make all measurement calculations in Scripter rely on units.h/.cpp 
child of 0003813 acknowledged Metabug: Scripter 



2005-06-02 14:27

reporter   ~0004877

That seems reasonable. I'd actually prefer to expose some constants that you can multiply/divide by to go to/from points, eg:

mm -> in : (value/mm)*in

since that helps reduce the growing bloat of functions in the API, is WAY faster (Python function calls are very slow) and those constants will be useful for other things later.


2005-06-03 05:12

reporter   ~0004878

In fact, yesterday, I did the same thing with my Python code : I looked inside the scribus source code to find these constants.
So, these constants could be available as Python constants. I thing it's very easy to do and very useful.


2005-06-03 21:19

administrator   ~0004886

units.cpp contains the functions for this.


2005-06-06 12:05

reporter   ~0004915

cbradney, while we can use util.cpp for the scripter, I'm not sure it's better than just exporting some constants. Function calls in Python are (alas) really slow, and I'd like to avoid adding yet more API functions if I can avoid it.

I figure the best way to do things is probably to use the util.cpp functions to initialize the constants we export to the user. That makes sure things are still all done in one place, but avoids the overhead of the function calls and yet more wrappers in the scripter.

Sound sensible?


2005-06-06 12:12

administrator   ~0004916

However it works best, as long as Scripter relies on units.cpp on startup to get the correct vales for conversion. You can reproduce similar functions in Scripter directly, but as you say initialise variables for those functions with those from units.cpp.


2005-06-12 05:46

reporter   ~0004997

Current 1.3cvs exports conversion constants `pt', `inch', `mm', `cm', etc into the `scribus' module so you can quickly and easily convert units, eg:

setPosition(10*cm, 10*cm)

Issue History

Date Modified Username Field Change
2005-06-02 13:05 fcoiffie New Issue
2005-06-02 14:27 ringerc Note Added: 0004877
2005-06-02 14:27 ringerc Status new => acknowledged
2005-06-02 14:27 ringerc Status acknowledged => assigned
2005-06-02 14:27 ringerc Assigned To => ringerc
2005-06-03 05:12 fcoiffie Note Added: 0004878
2005-06-03 21:19 cbradney Note Added: 0004886
2005-06-05 19:50 cbradney Relationship added related to 0001689
2005-06-05 19:53 cbradney Relationship added related to 0002053
2005-06-06 12:05 ringerc Note Added: 0004915
2005-06-06 12:12 cbradney Note Added: 0004916
2005-06-12 05:46 ringerc Status assigned => resolved
2005-06-12 05:46 ringerc Fixed in Version => 1.3.0cvs
2005-06-12 05:46 ringerc Resolution open => fixed
2005-06-12 05:46 ringerc Note Added: 0004997
2005-06-24 18:42 cbradney Status resolved => closed
2006-05-13 21:35 christoph_s Relationship added child of 0003813