How to use StringVector in pyogre

mrkissinger

09-06-2006 09:11:34


vector=config[j].possibleValues
iterator=vector.iterator()
print iterator
iterator.next()


The result is:

<pyogre.ogre.PySwigIterator; proxy of C++ swig::PySwigIterator instance at 0x82749f8>
Segment fault.

StringVector has not begin() method, so I am lost...

Waiting for help!

viblo2

09-06-2006 14:42:42


vector=config[j].possibleValues
iterator=vector.iterator()
print iterator
iterator.next()


The result is:

<pyogre.ogre.PySwigIterator; proxy of C++ swig::PySwigIterator instance at 0x82749f8>
Segment fault.

StringVector has not begin() method, so I am lost...

Waiting for help!


I made a small test:

rs = self.root.renderSystem
co = rs.getConfigOptions()
i = co.iterator()
print i
i.next()
print i

No segfaults for me.. I also tried to create a StringVector and adding/removing some values, and that also worked.
But then Im not sure if this is the same thing as the one you tried to do, Im no pyOgre-master :)

mrkissinger

09-06-2006 17:34:45

Here is my codes.


def _configure(self):
"""This shows the config dialog and creates the renderWindow."""
root=Root.getSingleton()
root.restoreConfig()
render=root.renderSystem
renders=root.getAvailableRenderers()
renderCount=len(renders)
for i in renders:
print i.name
config=i.getConfigOptions()
keys=config.keys()
for j in keys:
print "Name: ",j
print "Current value: ", config[j].currentValue.pyString
vector=config[j].possibleValues
size=vector.size()
print "size: ",size
iterator=vector.iterator()
print iterator
iterator.next()



getConfigOptions() return a ConfigOptionMap, not a StringVector.
possibleValues is a StringVector.

In C++, Vector could be simply used as an array. But seems it doesn't work in this way in Python.

The running result is:

OpenGL Rendering Subsystem
Name: FSAA
Current value: 0
size: 4
<pyogre.ogre.PySwigIterator; proxy of C++ swig::PySwigIterator instance at 0x82749f8>
Segment fault.


According to the result,
- the StringVector is NOT empty.
- Iterator is got.
- next() caused a segment fault.

Any idea?

dermont

09-06-2006 17:46:07

Anyone of these should do what you want:

for k,v in self.root.renderSystem.getConfigOptions().iteritems():
print "Config Item", k
print v.name.pyString , v.currentValue.pyString
print "********Possible Values *********"
for p in v.possibleValues:
print p

for v in self.root.renderSystem.getConfigOptions().values():
print v.name.pyString,v.currentValue.pyString
print "********Possible Values *********"
for p in v.possibleValues:
print p

for v in self.root.renderSystem.getConfigOptions().itervalues():
print "Config Item", v.name.pyString
print v.name.pyString , v.currentValue.pyString
print "********Possible Values *********"
for p in v.possibleValues:
print p

mrkissinger

09-06-2006 20:39:39

It works!
Thanks, dermont, your codes are quite helpful!

nathan75

03-12-2006 06:59:33

Why not does the code work in my program?

File "test01.py", line 88, in _configure
keys=config.keys()
AttributeError: 'PySwigObject' object has no attribute 'keys'


root=self.root.getSingleton()
root.restoreConfig()
render=root.renderSystem
renders=root.getAvailableRenderers()
renderCount=len(renders)
for i in renders:
print i.name
config=i.getConfigOptions()
keys=config.keys()


print i.name works well.
the only problem is the result of getConfigOptions()

I use 1.0.6, is it a problem of 1.0.6 ?
Thanks

dermont

03-12-2006 07:07:11

Yes I think it was:
http://developer.berlios.de/bugs/?func= ... up_id=3464

I'll double check that on pyOgre1.0.6.