Order of Setting Transformer & Constraint Matters
I just found out that it matters in which order you set transformer and constraint. From the outside (i.e. the API) there's no direct connection between the two, but looking at the code it's very simple to see.
function set constraint overwrites viewport.transformer.constraint
function set transformer overwrites viewport.transformer
So in case you first add the constraint and later on the transformer, you'll no longer have any constraints in place.
I have a patch (made from 0.4.2 SDK) for MultiScaleImageBase, which fixes this behaviour:
Of course, it is debatable, if one should copy attributes from an old transformation to a new one, but i found it pretty confusing that the order, in which i set the attributes. matters.
function set constraint overwrites viewport.transformer.constraint
function set transformer overwrites viewport.transformer
So in case you first add the constraint and later on the transformer, you'll no longer have any constraints in place.
I have a patch (made from 0.4.2 SDK) for MultiScaleImageBase, which fixes this behaviour:
Index: MultiScaleImageBase.as
===================================================================
--- MultiScaleImageBase.as (revision 8310)
+++ MultiScaleImageBase.as (working copy)
@@ -186,8 +186,11 @@
public function set transformer(value:IViewportTransformer):void
{
- if (transformer !== value)
- viewport.transformer = value
+ if (transformer === value)
+ return;
+ var oldConstraint:IViewportConstraint = viewport.transformer.constraint;
+ viewport.transformer = value
+ viewport.transformer.constraint = oldConstraint;
}
//----------------------------------
Of course, it is debatable, if one should copy attributes from an old transformation to a new one, but i found it pretty confusing that the order, in which i set the attributes. matters.
1
person likes this idea
I like this idea!
Tell me when this idea gets some attention.
The more people who like this idea, the more it gets noticed.
The more people who like this idea, the more it gets noticed.
-
Inappropriate?Claudius,
Wow, it seems you're really diving deep into the SDK. Actually, I've come across the same problem and I was actually thinking I'll move the constraint directly into the IViewport type. This way they it would be independent of the transformer.
What do you think?
Cheers,
Daniel
I’m thinking
The company thinks
this is one of the best points
-
Inappropriate?I can't really evaluate what's the better solution in this case. From a API-Standpoint it seems clearer, but on the other hand, i am still in the process of learning about openzoom and its internal workings.
If there is no dependency between transformer and constraint, this change might spare new users one or two moments of confusion.
I guess I'll be working with it for one or two days next week, maybe i'll dive deeper into the code.
I’m excited
Loading Profile...




EMPLOYEE