本文整理汇总了Python中vtk.vtkObject函数的典型用法代码示例。如果您正苦于以下问题:Python vtkObject函数的具体用法?Python vtkObject怎么用?Python vtkObject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkObject函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
EventHandler.EventHandler.__init__(self)
# default name is the class name, minus the "Factory"
self._Name = self.__class__.__name__
if self._Name[-7:] == 'Factory':
self._Name = self._Name[0:-7]
# Store the modified time
self._MTime = vtk.vtkObject()
self._RenderTime = vtk.vtkObject()
# list of renderers the actors are displayed in
self._Renderers = []
# dictionary of actors for each renderer
self._ActorDict = {}
# ActorFactories which are children of this one
self._Children = []
# the transform for all of the actors
self._Transform = vtk.vtkTransform()
# this transform is used as a spare
self._DummyTransform = vtk.vtkTransform()
开发者ID:parallaxinnovations,项目名称:vtkAtamai,代码行数:25,代码来源:ActorFactory.py
示例2: testObjId
def testObjId(self):
map = vtk.vtkObjectIdMap()
# Just make sure if we call it twice with None, the results match
objId1 = map.GetGlobalId(None)
objId1b = map.GetGlobalId(None)
print('Object ids for None: objId1 => ',objId1,', objId1b => ',objId1b)
self.assertTrue(objId1 == objId1b)
object2 = vtk.vtkObject()
addr2 = object2.__this__
addr2 = addr2[1:addr2.find('_', 1)]
addr2 = int(addr2, 16)
object3 = vtk.vtkObject()
addr3 = object3.__this__
addr3 = addr3[1:addr3.find('_', 1)]
addr3 = int(addr3, 16)
# insert the bigger address first
if (addr2 < addr3):
object2, object3 = object3, object2
objId2 = map.GetGlobalId(object2)
objId2b = map.GetGlobalId(object2)
print('Object ids for object2: objId2 => ',objId2,', objId2b => ',objId2b)
self.assertTrue(objId2 == objId2b)
objId3 = map.GetGlobalId(object3)
objId3b = map.GetGlobalId(object3)
print('Object ids for object3: objId3 => ',objId3,', objId3b => ',objId3b)
self.assertTrue(objId3 == objId3b)
开发者ID:Kitware,项目名称:VTK,代码行数:31,代码来源:TestObjectIdMap.py
示例3: test_removeObserver
def test_removeObserver(self):
foo = Foo()
object = vtk.vtkObject()
object2 = vtk.vtkObject()
event = vtk.vtkCommand.ModifiedEvent
callback = foo.onObjectModified
callback2 = foo.onObjectModifiedAgain
self.assertEqual(len(foo.Observations), 0)
foo.addObserver(object, event, callback)
foo.addObserver(object2, event, callback)
foo.addObserver(object, event, callback2)
foo.addObserver(object2, event, callback2)
self.assertEqual(len(foo.Observations), 4)
foo.removeObserver(object2, event, callback)
self.assertEqual(len(foo.Observations), 3)
foo.removeObserver(object, event, callback)
self.assertEqual(len(foo.Observations), 2)
foo.removeObserver(object, event, callback2)
self.assertEqual(len(foo.Observations), 1)
foo.removeObserver(object2, event, callback2)
self.assertEqual(len(foo.Observations), 0)
开发者ID:BRAINSia,项目名称:Slicer,代码行数:26,代码来源:test_slicer_util_VTKObservationMixin.py
示例4: testGhostForDict
def testGhostForDict(self):
"""Ghost an object to save the dict"""
o = vtk.vtkObject()
o.customattr = 'hello'
a = vtk.vtkVariantArray()
a.InsertNextValue(o)
i = id(o)
del o
o = vtk.vtkObject()
o = a.GetValue(0).ToVTKObject()
# make sure the id has changed, but dict the same
self.assertEqual(o.customattr, 'hello')
self.assertNotEqual(i, id(o))
开发者ID:0004c,项目名称:VTK,代码行数:13,代码来源:TestGhost.py
示例5: test_hasObserver
def test_hasObserver(self):
foo = Foo()
object = vtk.vtkObject()
object2 = vtk.vtkObject()
event = vtk.vtkCommand.ModifiedEvent
callback = foo.onObjectModified
self.assertFalse(foo.hasObserver(object, event, callback))
self.assertFalse(foo.hasObserver(object2, event, callback))
foo.addObserver(object, event, callback)
self.assertTrue(foo.hasObserver(object, event, callback))
self.assertFalse(foo.hasObserver(object2, event, callback))
foo.addObserver(object2, event, callback)
self.assertTrue(foo.hasObserver(object, event, callback))
self.assertTrue(foo.hasObserver(object2, event, callback))
开发者ID:BRAINSia,项目名称:Slicer,代码行数:16,代码来源:test_slicer_util_VTKObservationMixin.py
示例6: __init__
def __init__(self):
ActorFactory.ActorFactory.__init__(self)
self.markList = []
self.positionList = [] # none transformed position list
self.captions = []
self.activeIndex = None
self._defaultCaptionVisibility = False
self.cursorMark = None
self.curpos = None
# sizes
self.markSize = 10.
self.cursorMarkSize = 12.
# colors
self.cursorMarkColor = (1, 0, 0) # red
self.markColor = (1, 1, 0) # yellow
self._markTransform = vtk.vtkTransform()
self._markTransform.AddObserver(
'ModifiedEvent', self._OnTransformModified)
self._transformedView = False
self.eventObject = vtk.vtkObject()
开发者ID:andyTsing,项目名称:MicroView,代码行数:26,代码来源:SphereMarkListFactory.py
示例7: testProxy
def testProxy(self):
o = vtk.vtkObject()
proxy = weakref.proxy(o)
self.assertEqual(proxy.GetClassName(), 'vtkObject')
del o
self.assertRaises(weakref.ReferenceError, getattr,
proxy, 'GetClassName')
开发者ID:0004c,项目名称:VTK,代码行数:7,代码来源:TestWeakref.py
示例8: setUp
def setUp(self):
self.vtkObjs = [vtk.vtkObject() for _ in range(30)]
self.collection = vtk.vtkCollection()
for obj in self.vtkObjs:
self.collection.AddItem(obj)
self.emptyCollection = vtk.vtkCollection()
开发者ID:ALouis38,项目名称:VTK,代码行数:7,代码来源:TestIterateCollection.py
示例9: test_observer
def test_observer(self):
foo = Foo()
object = vtk.vtkObject()
object2 = vtk.vtkObject()
event = vtk.vtkCommand.ModifiedEvent
callback = foo.onObjectModified
callback2 = foo.onObjectModifiedAgain
self.assertEqual(foo.observer(event, callback), None)
foo.addObserver(object, event, callback)
self.assertEqual(foo.observer(event, callback), object)
# observer function return the first observer
foo.addObserver(object2, event, callback)
self.assertEqual(foo.observer(event, callback), object)
foo.addObserver(object2, event, callback2)
self.assertEqual(foo.observer(event, callback2), object2)
开发者ID:BRAINSia,项目名称:Slicer,代码行数:18,代码来源:test_slicer_util_VTKObservationMixin.py
示例10: testPriorityArg
def testPriorityArg(self):
"""Test the optional priority argument
"""
cb = callback()
o = vtk.vtkObject()
o.AddObserver(vtk.vtkCommand.ModifiedEvent, cb, 0.5)
o.Modified()
self.assertEqual(cb.caller, o)
开发者ID:AndreasFetzer,项目名称:VTK,代码行数:9,代码来源:TestCommand.py
示例11: testCommandWithArgs
def testCommandWithArgs(self):
"""Test binding a command that has arguments.
"""
cb = callback()
o = vtk.vtkObject()
o.AddObserver(vtk.vtkCommand.ModifiedEvent, cb)
o.Modified()
self.assertEqual(cb.caller, o)
self.assertEqual(cb.event, "ModifiedEvent")
开发者ID:AndreasFetzer,项目名称:VTK,代码行数:10,代码来源:TestCommand.py
示例12: testUseEventNameString
def testUseEventNameString(self):
"""Test binding with a string event name.
"""
cb = callback()
o = vtk.vtkObject()
o.AddObserver("ModifiedEvent", cb)
o.Modified()
self.assertEqual(cb.caller, o)
self.assertEqual(cb.event, "ModifiedEvent")
开发者ID:AndreasFetzer,项目名称:VTK,代码行数:10,代码来源:TestCommand.py
示例13: testCommandCircularRef
def testCommandCircularRef(self):
"""Test correct reference loop reporting for commands
"""
cb = callback()
o = vtk.vtkObject()
o.AddObserver(vtk.vtkCommand.ModifiedEvent, cb)
cb.circular_ref = o
# referent to check if "o" is deleted
referent = vtk.vtkObject()
o.referent = referent
# make sure gc removes referer "o" from referent
s1 = repr(gc.get_referrers(referent))
del o
del cb
gc.collect()
s2 = repr(gc.get_referrers(referent))
self.assertNotEqual(s1, s2)
self.assertNotEqual(s1.count("vtkObject"), 0)
self.assertEqual(s2.count("vtkObject"), 0)
开发者ID:hepburnfans,项目名称:VTK,代码行数:20,代码来源:TestCommand.py
示例14: test_addObserver
def test_addObserver(self):
foo = Foo()
object = vtk.vtkObject()
object2 = vtk.vtkObject()
event = vtk.vtkCommand.ModifiedEvent
callback = foo.onObjectModified
self.assertEqual(len(foo.Observations), 0)
foo.ModifiedEventCount = {}
foo.addObserver(object, event, callback)
object.Modified()
self.assertEqual(len(foo.Observations), 1)
self.assertEqual(foo.modifiedEventCount(object), 1)
self.assertEqual(foo.modifiedEventCount(object2), 0)
foo.ModifiedEventCount = {}
foo.addObserver(object, event, callback)
object.Modified()
self.assertEqual(len(foo.Observations), 1)
self.assertEqual(foo.modifiedEventCount(object), 1)
self.assertEqual(foo.modifiedEventCount(object2), 0)
foo.ModifiedEventCount = {}
foo.addObserver(object, event, callback, group='a')
object.Modified()
self.assertEqual(len(foo.Observations), 1)
self.assertEqual(foo.modifiedEventCount(object), 1)
self.assertEqual(foo.modifiedEventCount(object2), 0)
foo.ModifiedEventCount = {}
foo.addObserver(object2, event, callback)
object.Modified()
self.assertEqual(len(foo.Observations), 2)
self.assertEqual(foo.modifiedEventCount(object), 1)
self.assertEqual(foo.modifiedEventCount(object2), 0)
foo.ModifiedEventCount = {}
object2.Modified()
self.assertEqual(len(foo.Observations), 2)
self.assertEqual(foo.modifiedEventCount(object), 0)
self.assertEqual(foo.modifiedEventCount(object2), 1)
开发者ID:BRAINSia,项目名称:Slicer,代码行数:41,代码来源:test_slicer_util_VTKObservationMixin.py
示例15: testObjectPointer
def testObjectPointer(self):
a = vtk.vtkInformation()
ptr = a.__this__
# check the format _0123456789abcdef_p_vtkInformation
self.assertEqual(ptr[0:1], "_")
self.assertEqual(ptr[-17:], "_p_vtkInformation")
address = int(ptr[1:-17], 16)
# create a VTK object from the swig pointer
b = vtk.vtkObject(ptr)
self.assertEqual(b.GetClassName(), a.GetClassName())
self.assertEqual(a.__this__, b.__this__)
self.assertEqual(a, b)
开发者ID:timkrentz,项目名称:SunTracker,代码行数:12,代码来源:TestSwigPointer.py
示例16: testGhostForClass
def testGhostForClass(self):
"""Ghost an object to save the class"""
o = vtkCustomObject()
a = vtk.vtkVariantArray()
a.InsertNextValue(o)
i = id(o)
del o
o = vtk.vtkObject()
o = a.GetValue(0).ToVTKObject()
# make sure the id has changed, but class the same
self.assertEqual(o.__class__, vtkCustomObject)
self.assertNotEqual(i, id(o))
开发者ID:0004c,项目名称:VTK,代码行数:12,代码来源:TestGhost.py
示例17: testSubclassGhost
def testSubclassGhost(self):
"""Make sure ghosting of the class works"""
o = vtkCustomObject()
c = vtk.vtkCollection()
c.AddItem(o)
i = id(o)
del o
o = vtk.vtkObject()
o = c.GetItemAsObject(0)
# make sure the id has changed, but class the same
self.assertEqual(o.__class__, vtkCustomObject)
self.assertNotEqual(i, id(o))
开发者ID:timkrentz,项目名称:SunTracker,代码行数:12,代码来源:TestSubClass.py
示例18: testArgumentConversion
def testArgumentConversion(self):
"""Test argument conversion via implicit constructors"""
# automatic conversion to vtkVariant
a = vtk.vtkVariantArray()
a.InsertNextValue(2.5)
a.InsertNextValue(vtk.vtkObject())
self.assertEqual(a.GetValue(0), vtk.vtkVariant(2.5))
self.assertEqual(a.GetValue(1).GetType(), vtk.VTK_OBJECT)
# same, but this one is via "const vtkVariant&" argument
a = vtk.vtkDenseArray[float]()
a.Resize(1)
a.SetVariantValue(0, 2.5)
self.assertEqual(a.GetVariantValue(0).ToDouble(), 2.5)
开发者ID:ALouis38,项目名称:VTK,代码行数:13,代码来源:TestOverloads.py
示例19: testRemoveCommand
def testRemoveCommand(self):
"""Test the removal of an observer.
"""
cb = callback()
o = vtk.vtkObject()
o.AddObserver(vtk.vtkCommand.ModifiedEvent, cb)
o.Modified()
self.assertEqual(cb.caller, o)
o.RemoveObservers(vtk.vtkCommand.ModifiedEvent)
cb.caller = None
cb.event = None
o.Modified()
self.assertEqual(cb.caller, None)
开发者ID:AndreasFetzer,项目名称:VTK,代码行数:13,代码来源:TestCommand.py
示例20: testConstructors
def testConstructors(self):
"""Test overloaded constructors"""
# resolve by number of arguments
v = vtk.vtkVector3d(3, 4, 5)
self.assertEqual((v[0], v[1], v[2]), (3, 4, 5))
v = vtk.vtkVector3d(6)
self.assertEqual((v[0], v[1], v[2]), (6, 6, 6))
# resolve by argument type
v = vtk.vtkVariant(3.0)
self.assertEqual(v.GetType(), vtk.VTK_DOUBLE)
v = vtk.vtkVariant(1)
self.assertEqual(v.GetType(), vtk.VTK_INT)
v = vtk.vtkVariant("hello")
self.assertEqual(v.GetType(), vtk.VTK_STRING)
v = vtk.vtkVariant(vtk.vtkObject())
self.assertEqual(v.GetType(), vtk.VTK_OBJECT)
开发者ID:ALouis38,项目名称:VTK,代码行数:16,代码来源:TestOverloads.py
注:本文中的vtk.vtkObject函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论