@@ -585,6 +585,7 @@ def setup(self, args):
585
585
del args ['_objName' ]
586
586
587
587
# default values
588
+ self ._sizing = True # axis/size connection is the default; False for sphere, ring, text, compound
588
589
self ._pos = vector (0 ,0 ,0 )
589
590
self ._axis = vector (1 ,0 ,0 )
590
591
self ._up = vector (0 ,1 ,0 )
@@ -761,32 +762,52 @@ def up(self,value):
761
762
def axis (self ):
762
763
return self ._axis
763
764
@axis .setter
764
- def axis (self ,value ):
765
- self ._save_oldaxis = adjust_up (self ._axis , value , self ._up , self ._save_oldaxis ) # this sets self._axis and self._up
765
+ def axis (self ,value ): # sphere or ring or text or compound have no axis/size link
766
+ currentaxis = self ._axis
767
+ self ._axis = value
768
+ if value .mag2 == 0 :
769
+ if self ._save_oldaxis is None : self ._save_oldaxis = currentaxis
770
+ else :
771
+ if self ._save_oldaxis is not None :
772
+ self ._save_oldaxis = adjust_up (self ._axis , value , self ._up , self ._save_oldaxis ) # this sets self._axis and self._up
766
773
if not self ._constructing :
767
774
self .addattr ('axis' )
768
- self ._size ._x = value .mag # changing axis length changes size.x
775
+ if self ._sizing :
776
+ self ._size ._x = value .mag # changing axis length changes size.x
769
777
770
778
@property
771
779
def size (self ):
772
780
return self ._size
773
781
@size .setter
774
- def size (self ,value ):
775
- self ._size .value = value
782
+ def size (self ,value ): # sphere or ring or text or compound have no axis/size link
783
+ currentaxis = self ._axis
784
+ self ._size = value
785
+ if value .x == 0 :
786
+ if self ._save_oldaxis is not None :
787
+ currentaxis = self ._save_oldaxis
788
+ self ._save_oldaxis = None
789
+ else :
790
+ currentaxis = vector (1 ,0 ,0 )
776
791
if not self ._constructing :
777
792
self .addattr ('size' )
778
- a = self ._axis .norm () * value .x
779
- if mag (self ._axis ) == 0 :
780
- a = vector (value .x ,0 ,0 )
781
- self ._axis .value = a # changing size changes length of axis
793
+ if self ._sizing :
794
+ self ._axis = currentaxis .norm ()* value .x
782
795
783
796
@property
784
797
def length (self ):
785
798
return self ._size .x
786
799
@length .setter
787
800
def length (self ,value ):
788
- self ._axis = self ._axis .norm () * value
789
- self ._size ._x = value
801
+ if value == 0 :
802
+ if self ._save_oldaxis is None : self ._save_oldaxis = vector (self ._axis .x , self ._axis .y , self ._axis .z )
803
+ self ._axis = vector (0 ,0 ,0 )
804
+ self ._size ._x = 0
805
+ else :
806
+ if self ._save_oldaxis is not None :
807
+ self ._axis = self ._save_oldaxis
808
+ self ._save_oldaxis = None
809
+ if self ._size ._x == 0 : self .axis = vector (value , 0 , 0 )
810
+ else : self .axis = value * self ._axis .norm () # this will set length
790
811
if not self ._constructing :
791
812
self .addattr ('axis' )
792
813
self .addattr ('size' )
@@ -1122,6 +1143,7 @@ def __init__(self, **args):
1122
1143
args ['_default_size' ] = vector (2 ,2 ,2 )
1123
1144
args ['_objName' ] = "sphere"
1124
1145
super (sphere , self ).setup (args )
1146
+ self ._sizing = False # no axis/size connection
1125
1147
1126
1148
@property
1127
1149
def radius (self ):
@@ -1212,6 +1234,7 @@ def __init__(self, **args):
1212
1234
args ['_default_size' ] = vector (0.2 ,2.2 ,2.2 )
1213
1235
args ['_objName' ] = "ring"
1214
1236
super (ring , self ).setup (args )
1237
+ self ._sizing = False # no axis/size connection
1215
1238
1216
1239
@property
1217
1240
def thickness (self ):
@@ -1467,6 +1490,7 @@ def __init__(self, objList, **args):
1467
1490
self .compound_idx += 1
1468
1491
args ['_objName' ] = 'compound' + str (self .compound_idx )
1469
1492
super (compound , self ).setup (args )
1493
+ self ._sizing = False # no axis/size connection
1470
1494
1471
1495
for obj in objList :
1472
1496
# GlowScript will make the objects invisible, so need not set obj.visible
@@ -3859,6 +3883,7 @@ def end_face_color(self,value):
3859
3883
class text (standardAttributes ):
3860
3884
3861
3885
def __init__ (self , ** args ):
3886
+ self ._sizing = False # no axis/size connection
3862
3887
args ['_default_size' ] = vector (1 ,1 ,1 ) # to keep standardAttributes happy
3863
3888
args ['_objName' ] = "text"
3864
3889
self ._height = 1 ## not derived from size
@@ -3913,10 +3938,10 @@ def axis(self):
3913
3938
return self ._axis
3914
3939
@axis .setter
3915
3940
def axis (self ,value ): # changing axis does not affect size
3916
- oldaxis = vector (self .axis )
3941
+ old = vector (self .axis )
3917
3942
u = self .up
3918
3943
self ._axis .value = value
3919
- self ._save_oldaxis = adjust_up (norm (oldaxis ), self ._axis , self ._up , self ._save_oldaxis )
3944
+ self ._save_oldaxis = adjust_up (norm (old ), self ._axis , self ._up , self ._save_oldaxis )
3920
3945
self .addattr ('axis' )
3921
3946
self .addattr ('up' )
3922
3947
0 commit comments