The ScorpionEx.py extends the Scorpion module.
Example 1: TScorpionEx - Provide tests for
ScorpionEx.py
import ScorpionEx
reload (ScorpionEx)
from ScorpionEx import GetPointValue,SetPointValue, GetCircleValue, SetCircleValue,GetLineValue,SetLineValue
(x,y) = GetPointValue('ed.p1')
print x,y
SetPointValue('ed.p1',4,5)
SetCircleValue('ed.c',x,y,4)
print GetCircleValue('ed.c')
SetLineValue('ed.l1',x,y,x,y)
print GetLineValue('ed.l1')
from ScorpionEx import GetPointValue3D, SetPointValue3D,GetCircleValue3D, SetCircleValue3D,GetLineValue3D,SetLineValue3D
(x,y,z) = GetPointValue3D('ed.p3d')
print x,y,z
SetPointValue3D('ed.p3d',4,5,6)
SetCircleValue3D('ed.s3d',x,y,z,1)
print GetCircleValue3D('ed.s3d')
SetLineValue3D('ed.l3d',x,y,z,x,y,z)
print GetLineValue3D('ed.l3d')
from ScorpionEx import IsValid,IsPointValid, IsLine3DValid, IsLineValid,IsCircleValid,IsCircle3DValid
print IsPointValid('ed.p2')
print IsPointValid('ed.p1')
print IsLine3DValid('ed,l1')
print IsLine3DValid('ed.l3d')
print IsLineValid('ed.l1')
print IsCircle3DValid('ed.s3d')
print 'ed.c', IsCircleValid('ed.c')
print '-------------------'
from ScorpionEx import SetValid,SetPointValid,SetPoint3DValid,SetCircle3DValid,SetLineValid,SetLine3DValid,SetCircleValid
print SetPointValid('ed.p1',False)
print 'ed.p1', IsPointValid('ed.p1')
print SetLine3DValid('ed,l1',True)
print 'ed.l1', IsLine3DValid('ed,l1')
print SetLine3DValid('ed.l3d',True)
print 'ed.13d', IsLine3DValid('ed.l3d')
print SetLineValid('ed.l1',False)
print 'ed.l1',IsLineValid('ed.l1')
print SetCircle3DValid('ed.s3d',False)
print 'ed.s3d',IsCircle3DValid('ed.s3d')
print SetCircleValid('ed.c',False)
print 'ed.c',IsCircleValid('ed.c')
print '-------------------'
from ScorpionEx import IsBoolValid,SetBoolValid,IsStringValid,SetStringValid
print 'ed.b0',IsBoolValid('ed.b0')
print SetBoolValue('ed.b0',True)
print 'ed.b0',IsBoolValid('ed.b0'),GetBoolValue('ed.b0')
print SetBoolValid('ed.b0',False)
print 'ed.b0',IsBoolValid('ed.b0')
print ' - '
print 'ed.t1',IsStringValid('ed.t1')
print SetStringValue('ed.t1','Empty')
print 'ed.t1',IsStringValid('ed.t1'),GetStringValue('ed.t1')
print SetStringValid('ed.t1',False)
print 'ed.t1',IsStringValid('ed.t1')
ScorpionEx.py
from Scorpion import GetTool, GetValue, SetValue
def IsValid(name):
try:
(tool,parameter) = string.split(name,'.')
return GetTool(tool).getValid(parameter)
except:
return False
def SetValid(name,valid):
try:
(tool,parameter) = name.split('.')
return GetTool(tool).setValid(parameter,valid)
except:
return False
def IsStringValid(name):
return IsValid(name)
def SetStringValid(name,valid):
return SetValid(name,valid)
def IsBoolValid(name):
return IsValid(name)
def SetBoolValid(name,valid):
return SetValid(name,valid)
def IsPointValid(name):
bx = IsValid(name+'_x')
by = IsValid(name+'_y')
return bx and by
def SetPointValid(name,valid):
bx = SetValid(name+'_x',valid)
by = SetValid(name+'_y',valid)
return bx and by
def IsPoint3DValid(name):
bx = IsValid(name+'_x')
by = IsValid(name+'_y')
bz = IsValid(name+'_z')
return bx and by and bz
def SetPoint3DValid(name,valid):
bx = SetValid(name+'_x',valid)
by = SetValid(name+'_y',valid)
bz = SetValid(name+'_z',valid)
return bx and by and bz
def IsLineValid(name):
bp = IsPointValid(name+'_p')
bv = IsPointValid(name+'_v')
return bp and bv
def SetLineValid(name,valid):
bp = SetPointValid(name+'_p',valid)
bv = SetPointValid(name+'_v',valid)
return bp and bv
def IsLine3DValid(name):
bp = IsPoint3DValid(name+'_p')
bv = IsPoint3DValid(name+'_v')
return bp and bv
def SetLine3DValid(name,valid):
bp = SetPoint3DValid(name+'_p',valid)
bv = SetPoint3DValid(name+'_v',valid)
return bp and bv
def IsCircleValid(name):
bp = IsPointValid(name)
br = IsValid(name+'_r')
return bp and br
def SetCircleValid(name,valid):
bp = SetPointValid(name,valid)
br = SetValid(name+'_r',valid)
return bp and br
def IsCircle3DValid(name):
bp = IsPoint3DValid(name)
br = IsValid(name+'_r')
return bp and br
def SetCircle3DValid(name,valid):
bp = SetPoint3DValid(name,valid)
br = SetValid(name+'_r',valid)
return bp and br
def GetPointValue(name):
x = GetValue(name+'_x')
y = GetValue(name+'_y')
return (x,y)
def SetPointValue(name,x,y):
SetValue(name+'_x',x)
SetValue(name+'_y',y)
def GetPointValue3D(name):
x = GetValue(name+'_x')
y = GetValue(name+'_y')
z = GetValue(name+'_z')
return (x,y,z)
def SetPointValue3D(name,x,y,z):
SetValue(name+'_x',x)
SetValue(name+'_y',y)
SetValue(name+'_z',z)
def GetLineValue(name):
(x,y) = GetPointValue(name+'_p')
(u,v) = GetPointValue(name+'_v')
return (x,y,u,v)
def SetLineValue(name,x,y,u,v):
SetPointValue(name+'_p',x,y)
SetPointValue(name+'_v',u,v)
def GetLineValue3D(name):
(x,y,z) = GetPointValue3D(name+'_p')
(_x,_y,_z) = GetPointValue3D(name+'_v')
return (x,y,z,_x,_y,_z)
def SetLineValue3D(name,x,y,z,_x,_y,_z):
SetPointValue3D(name+'_p',x,y,z)
SetPointValue3D(name+'_v',_x,_y,_z)
def GetCircleValue(name):
(x,y) = GetPointValue(name)
r = GetValue(name+'_r')
return (x,y,r)
def SetCircleValue(name,x,y,r):
SetPointValue(name,x,y)
SetValue(name+'_r',r)
return (x,y,r)
def GetCircleValue3D(name):
(x,y,z) = GetPointValue3D(name)
r = GetValue(name+'_r')
return (x,y,z,r)
def SetCircleValue3D(name,x,y,z,r):
SetPointValue3D(name,x,y,z)
SetValue(name+'_r',r)
return (x,y,z,r)
|