[x3d-public] Sample X3D Python API; examples publishedforcontinuing improvement

John Carlson yottzumm at gmail.com
Mon Apr 22 22:25:26 PDT 2019


Don,

I don’t feel like reimplementing autoclass from pyjnius.  I suggest we try to use it, or make small changes to reflect.py instead and import that instead of jnius (but I am not sure of this.  I don’t think I ever got the reflect import working).

We’ll have to offer 2 options, Standard or Pipelining.

I will look at other python/java solutions.

John

Sent from Mail for Windows 10

From: Brutzman, Donald (Don) (CIV)
Sent: Monday, April 22, 2019 10:49 PM
To: John Carlson
Cc: X3D Graphics public mailing list
Subject: Re: [x3d-public] Sample X3D Python API; examples publishedforcontinuing improvement

Added some files and special build tasks for HelloWorld in pyjnius build.xml file.


OK, I don't see the fix yet, but I think I see the problem.  Let's look very closely at the error message (uhh, cough cough, always a good idea):

- - - - - -
Loading HelloWorld.future.py with python, if successful then saving and validating as HelloWorld_RoundTrip2.x3d version:
Traceback (most recent call last):
   File "HelloWorld.future.py", line 107, in <module>
     .setDEF("ViewUpClose") \
AttributeError: 'org.web3d.x3d.sai.Navigation.X3DViewpointNode' object has no attribute 'setCenterOfRotation'
- - - - - -

The correct type for this method is not org.web3d.x3d.sai.Navigation.X3DViewpointNode but rather

	org.web3d.x3d.jsail.Navigation.ViewpointObject

(note differences: package .jsail and class ViewpointObject)

I checked the method invocation in the underlying Java.  It is correct, returning a "this" pointer to self of type org.web3d.x3d.jsais.Navigation.ViewpointObject

So there is a twist in the knickers somewhere when configuring pyjnius to choose the correct X3DJSAIL class.

Closely looking at source in ViewpointObject.java has this "override" method invocation:

============================
	@Override
	public final ViewpointObject setDEF(String newValue)
	{
============================

Notice that this specifically typed method in X3DJSAIL overrides the abstract superclass.  So that override should take precedence.

However the python error is referring to the abstract superclass.

So either we are pointing pynius to the wrong class, or else it is mistakenly looking for a superclass (not sure why).

Presumably the configuration file for pyjnius is X3Dautoclass.py which has:

	Viewpoint = autoclass('org.web3d.x3d.jsail.Navigation.ViewpointObject')

which is correct.  Is there something else you set, perhaps via your other scripts, which maybe takes precedence?

I tried removing all abstract superclasses from the python configuration, but that didn't seem to work.

Recommended next step: please confirm that you have no references to abstract classes anywhere in any of your mappings - scene graph programmers do not need them.

Thanks for checking further.  Another step closer I hope.


On 4/22/2019 7:25 PM, Brutzman, Donald (Don) (CIV) wrote:
> Everything I've seen so far indicates that no major redesign is needed, rather more likely is that
> 
> a. we are not invoking pyjnius correctly, or
> b. pyjnius is not behaving as expected.
> 
> Could we focus on HelloWorld.x3d and .java working for the two python versions?  Let's consider this simple example in depth, rather than everything + everything.
> 
> http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloWorldIndex.html
> http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloWorld
> 
> build outputs excerpt:
> 
> http://www.web3d.org/x3d/content/examples/build.python.all.log.txt
> ==================================================================
> 
> =====================
> create python:
> node xml2all.js C:\x3d-code\www.web3d.org\x3d\content\examples\X3dForWebAuthors/Chapter01TechnicalOverview//HelloWorld.x3d
> HelloWorld.x3d converted to HelloWorld.py
> - - - - - - - - - - -
> validate python:
> Loading HelloWorld.py with X3DJSAIL, if successful then saving as round-trip HelloWorld_RoundTrip1.x3d version:
> Moving 1 file to C:\x3d-code\www.web3d.org\x3d\content\examples\X3dForWebAuthors\Chapter01TechnicalOverview
> HelloWorld.py round-trip load test #1 complete
> - - - - - -
> Loading HelloWorld.future.py with X3DJSAIL, if successful then saving as round-trip HelloWorld_RoundTrip2.x3d version:
> Traceback (most recent call last):
>     File "C:\x3d-code\www.web3d.org\x3d\content\examples\X3dForWebAuthors/Chapter01TechnicalOverview//HelloWorld.future.py", line 104, in <module>
>       .setDEF("ViewUpClose") \
> AttributeError: 'org.web3d.x3d.sai.Navigation.X3DViewpointNode' object has no attribute 'setCenterOfRotation'
> Result: 1
> HelloWorld.future.py round-trip load test #2 complete
> ==================================================================
> 
> I think if we get that one to work for v2, we can get them all to work.
> 
> 
> On 4/17/2019 12:29 PM, John Carlson wrote:
>> Removing the getSuperclass and adding reflect package failed to fix anything.
>>
>> Hmm.
>>
>> Back to drawing board.   I am starting to work on XML output from the other API, looking at possible packages.  Will probably gen up my own, and then validate it.
>>
>> What are the XML aspects of SAI? Is there a standard API for exporting scenegraph?
>>
>> Thanks,
>>
>> John
>>
>> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
>>
>> *From: *John Carlson <mailto:yottzumm at gmail.com>
>> *Sent: *Tuesday, April 16, 2019 10:20 AM
>> *To: *Brutzman, Donald (Don) (CIV) <mailto:brutzman at nps.edu>
>> *Cc: *X3D Graphics public mailing list <mailto:x3d-public at web3d.org>
>> *Subject: *Re: [x3d-public] Sample X3D Python API; examples published forcontinuing improvement
>>
>> One idea is to edit reflect.py and remove getSuperclass call.
>>
>> On Tue, Apr 16, 2019 at 10:08 AM John Carlson <yottzumm at gmail.com <mailto:yottzumm at gmail.com>> wrote:
>>
>>      I think what we must try to do is duplicate autoclass functionality without abstract classes.   I suggest a separate version of X3DJSAIL????   Any other suggestions?   Please review/modify my generated code for any other suggestion?
>>
>>      A prior suggestion was to add casting?   Should we create a third serializer for this?
>>
>>      John
>>
>>      John
>>
>>      On Mon, Apr 15, 2019 at 8:32 PM Brutzman, Donald (Don) (CIV) <brutzman at nps.edu <mailto:brutzman at nps.edu>> wrote:
>>
>> OK thanks for feedback John.
>>
>> Sorry but no tossing in the towel yet, please!  Not ready for a reset on this end yet.  Am optimistic that close scrutiny of your pyjnius code - which has gotten so far - will continue to inform progress.  We're not far from an initial implementation.  More study of python will help (at least for me).
>>
>> ... and in any case, we now have a nice build harness to test and improve language-binding progress against all available example scenes.
>>
>>
>> On 4/15/2019 12:19 PM, John Carlson wrote:
>>   > You are welcome to produce an X3dToPy.xslt or otherwise manipulate the python files to eliminate any abstract classes.   I am not aware of using abstract classes in the *.future.py files, and would have to be shown an example, thanks.  You may also move the org/Web3d/X3D/sai pyjnius folder out of the way for a test.
>>   >
>>   > I do know ignoring the return value from the setters seems to work for pyjnius, so perhaps we should explore why that works in the context of abstract classes.
>>   >
>>   > Also, please explore what I am doing with declaring abstract classes under the pyjnius folder and how that might be improved.
>>   >
>>   > I need an example before I can move forward.
>>   >
>>   > Thanks,
>>   >
>>   > John
>>   >
>>   > On Mon, Apr 15, 2019 at 11:23 AM Brutzman, Donald (Don) (CIV) <brutzman at nps.edu <mailto:brutzman at nps.edu> <mailto:brutzman at nps.edu <mailto:brutzman at nps.edu>>> wrote:
>>   >
>>   >     Am happy to report that both versions of your .py programs are now being produced and published for all models in X3D Examples Archives.
>>   >
>>   >     BLUF: these should greatly help us in continued improvement of X3D Python language-binding syntax.
>>   >
>>   >     Build log (now 10MB) includes X3D validation of RoundTrip scenes and remains updated at
>>   > https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/
>>   > https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/build.python.all.log.txt
>>   >
>>   >     A zip of all autogenerated python models is at
>>   >
>>   > http://www.web3d.org/x3d/content/examples/X3dExampleArchivesPythonScenes.zip
>>   > http://www.web3d.org/x3d/content/examples/X3dExampleArchivesPythonScenes.zip.MD5
>>   >
>>   >     Example links to python source _.pyv1_ and _.pyv2_ are provided for each scene, for example
>>   >
>>   > http://x3dgraphics.com/examples/X3dForAdvancedModeling/HelloWorldScenes/
>>   > http://x3dgraphics.com/examples/X3dForAdvancedModeling/HelloWorldScenes/HelloWorldIndex.html
>>   >
>>   >     As before the .future.py versions fail pyjnius because of use of abstract classes.
>>   >
>>   >     On 4/11/2019 6:35 PM, John Carlson wrote:
>>   >      > This versions is much cleaner than the previous version. Attached zip.
>>   >      >
>>   >      > Please review.  We will get comments soon I hope.
>>   >      >
>>   >      > John
>>   >
>>   >     John, do you think we should pursue changes to pyJNIus to support abstract classes?
>>   >
>>   >     Or... we could instead eliminate them and fully elaborate each node.  Not convinced that Python programmers might want or need abstract classes in the first place.  Certainly we don't need to implement them in this initial-design phase.
>>   >
>>   >     This is kind of configuration preparation is automatable using X3DUOM, of course.  Excerpts from your zip follows.  You appear to be there already, fully elaborating methods for all fields in all nodes?  Perhaps we should simply test with abstract classes omitted, or defined second?
>>   >
>>   >     [...]
>>   >     class X3DAppearanceChildNode(X3DNode):
>>   >           def __init__(self, **kwargs):
>>   >           def metadata(self):
>>   >           def metadata(self, value = None):
>>   >           def setMetadata(self, metadata = None):
>>   >           def addMetadata(self, metadata = None):
>>   >           def removeMetadata(self, metadata):
>>   >           def getMetadata(self, metadata = None):
>>   >           def metadata_changed(self, metadata = None):
>>   >           def DEF(self):
>>   >           def DEF(self, value = None):
>>   >           def setDEF(self, DEF = None):
>>   >           def addDEF(self, DEF = None):
>>   >           def removeDEF(self, DEF):
>>   >           def getDEF(self, DEF = None):
>>   >           def DEF_changed(self, DEF = None):
>>   >           def USE(self):
>>   >           def USE(self, value = None):
>>   >           def setUSE(self, USE = None):
>>   >           def addUSE(self, USE = None):
>>   >           def removeUSE(self, USE):
>>   >           def getUSE(self, USE = None):
>>   >           def USE_changed(self, USE = None):
>>   >           def class_(self):
>>   >           def class_(self, value = None):
>>   >           def setClass(self, class_ = None):
>>   >           def addClass(self, class_ = None):
>>   >           def removeClass(self, class_):
>>   >           def getClass(self, class_ = None):
>>   >           def class_changed(self, class_ = None):
>>   >           def comments(self):
>>   >           def comments(self, value = None):
>>   >           def setComments(self, comments = None):
>>   >           def addComments(self, comments = None):
>>   >
>>   >     [...]
>>   >     class StringSensor(X3DKeyDeviceSensorNode):
>>   >           def __init__(self, **kwargs):
>>   >           def deletionAllowed(self):
>>   >           def deletionAllowed(self, value = True):
>>   >           def setDeletionAllowed(self, deletionAllowed = True):
>>   >           def addDeletionAllowed(self, deletionAllowed = True):
>>   >           def removeDeletionAllowed(self, deletionAllowed):
>>   >           def isDeletionAllowed(self, deletionAllowed = True):
>>   >           def enabled(self):
>>   >           def enabled(self, value = True):
>>   >           def setEnabled(self, enabled = True):
>>   >           def addEnabled(self, enabled = True):
>>   >           def removeEnabled(self, enabled):
>>   >           def isEnabled(self, enabled = True):
>>   >           def removeEnteredText(self, enteredText):
>>   >           def getEnteredText(self, enteredText = None):
>>   >           def enteredText_changed(self, enteredText = None):
>>   >           def removeFinalText(self, finalText):
>>   >           def getFinalText(self, finalText = None):
>>   >           def finalText_changed(self, finalText = None):
>>   >           def isActive(self, Active = None):
>>   >           def metadata(self):
>>   >           def metadata(self, value = None):
>>   >           def setMetadata(self, metadata = None):
>>   >           def addMetadata(self, metadata = None):
>>   >           def removeMetadata(self, metadata):
>>   >           def getMetadata(self, metadata = None):
>>   >           def metadata_changed(self, metadata = None):
>>   >           def DEF(self):
>>   >           def DEF(self, value = None):
>>   >           def setDEF(self, DEF = None):
>>   >           def addDEF(self, DEF = None):
>>   >           def removeDEF(self, DEF):
>>   >           def getDEF(self, DEF = None):
>>   >           def DEF_changed(self, DEF = None):
>>   >           def USE(self):
>>   >           def USE(self, value = None):
>>   >           def setUSE(self, USE = None):
>>   >           def addUSE(self, USE = None):
>>   >           def removeUSE(self, USE):
>>   >           def getUSE(self, USE = None):
>>   >           def USE_changed(self, USE = None):
>>   >           def class_(self):
>>   >           def class_(self, value = None):
>>   >           def setClass(self, class_ = None):
>>   >           def addClass(self, class_ = None):
>>   >           def removeClass(self, class_):
>>   >           def getClass(self, class_ = None):
>>   >           def class_changed(self, class_ = None):
>>   >           def comments(self):
>>   >           def comments(self, value = None):
>>   >           def setComments(self, comments = None):
>>   >           def addComments(self, comments = None):
>>   >
>>   >     all the best, Don
>>   >     --
>>   >     Don Brutzman  Naval Postgraduate School, Code USW/Br brutzman at nps.edu <mailto:brutzman at nps.edu> <mailto:brutzman at nps.edu <mailto:brutzman at nps.edu>>
>>   >     Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
>>   >     X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman
>>   >
>>
>>
>> all the best, Don
>> -- 
>> Don Brutzman  Naval Postgraduate School, Code USW/Br brutzman at nps.edu <mailto:brutzman at nps.edu>
>> Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
>> X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman
>>
> 
> 
> all the best, Don
> 


all the best, Don
-- 
Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20190423/dda4a54f/attachment-0001.html>


More information about the x3d-public mailing list