GithubHelp home page GithubHelp logo

thehubbit / pyinventor Goto Github PK

View Code? Open in Web Editor NEW
16.0 16.0 8.0 8.63 MB

3D Graphics in Python with Open Inventor

Home Page: http://thehubbit.github.io/PyInventor

License: BSD 3-Clause "New" or "Revised" License

Python 26.10% C++ 71.64% Awk 2.25%

pyinventor's People

Contributors

thehubbit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pyinventor's Issues

Support for SoSFImage

The SoSFImage field is not directly supported (only setting via generic string API possible).

May 27, 2013: Solved. Images return and can be initialized with tuple (width, heigth, num components, pixel array).

compile fails with invalid conversion

src/PySceneObject.cpp:775:48: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
  775 |                         type = PyUnicode_AsUTF8(className);
      |                                ~~~~~~~~~~~~~~~~^~~~~~~~~~~
      |                                                |
      |                                                const char*
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1

How to work with iv.Gate: no input, no output

Hi Thomas,

You may want to include the following "examiner_embed.py" example from Tamer Fahmy's Pivy to PyInventor's example suite. My port of this example to PyInventor "almost" works :-) but apparently the iv.Gate toggeling the rotation of the cone was created incompletely by myself (SoGate for an MFFloat in the original) and unfortunately does not provide both required fields "input" and "output". Could you please make a suggestion how I can work with iv.Gate? Many thanks in advance!

Best,
Peter

""" Demonstrates embedding of an ExaminerViewer
within a simple widget hierarchy. """

import sys
from random import random
from PySide.QtCore import *
from PySide.QtGui import *
from PySide import QtOpenGL
from PyInventor import QtInventor
import inventor as iv

class ExaminerViewer(QWidget):
    """ExaminerViewer style QtGui widget"""
    
    myCamera = None
    
    def __init__(self, parent=None, title="Examiner Viewer", scene=None,
                 headlight=True, camera=True, interaction=False,
                 backgroundColor = (0.0, 0.0, 0.0)):
        
        QWidget.__init__(self, parent)
        
        self.ivWidget = QtInventor.QIVWidget(format=QtOpenGL.QGLFormat(QtOpenGL.QGL.SampleBuffers))
        self.ivWidget.sceneManager.background = backgroundColor

        # create a superscene containing a headlight and
        # an examiner viewer style camera
        examinerStyleCamera = iv.Separator()
        if headlight:
            examinerStyleCamera += iv.DirectionalLight()
        if camera:
            self.myCamera = iv.PerspectiveCamera()
            examinerStyleCamera += self.myCamera
        self.superScene = examinerStyleCamera
        self.superScene += scene
         
        self.ivWidget.sceneManager.scene = self.superScene       
        self.ivWidget.sceneManager.view_all()
        if interaction:
            self.ivWidget.sceneManager.interaction(0)
        else:
            self.ivWidget.sceneManager.interaction(1)		

        mainLayout = QHBoxLayout()
        mainLayout.setContentsMargins(0, 0, 0, 0)
        mainLayout.addWidget(self.ivWidget)
        self.setLayout(mainLayout)
        self.setWindowTitle(title)

    def minimumSizeHint(self):
        return QSize(100, 100)


class EmbeddedWindow(QMainWindow):
    def __init__(self, *args):
        super(self.__class__, self).__init__()

        # construct a simple scenegraph
        root = iv.Separator()
        self.rotxyz = iv.RotationXYZ()
        self.gate = iv.Gate("MFFloat") # iv.Gate(SoMFFloat.getClassTypeId())
        self.elapsedTime = iv.ElapsedTime()
        self.gate.enableNotify(False)
        self.gate.connect("input", self.elapsedTime, "timeOut")
        self.rotxyz.connect("angle", self.gate, "output")
        self.material = iv.Material()
        self.material.diffuseColor = (0.0, 1.0, 1.0)
        self.cone = iv.Cone()
        root += self.rotxyz
        root += self.material
        root += self.cone

        # dummy widget needed for the PyQt stuff
        self.centralWidget = QWidget(self)
        self.mainLayout = QVBoxLayout(self.centralWidget)
        self.examiner = ExaminerViewer(parent=self.centralWidget, scene=root)
        self.mainLayout.addWidget(self.examiner) # add the examiner viewer
        self.hLayout = QHBoxLayout()
        self.groupBox = QGroupBox("Choose axis", self.centralWidget)
        self.hboxlayout1 = QHBoxLayout(self.groupBox)
        self.buttonGroup = QButtonGroup(self.groupBox)
        self.radio_x = QRadioButton("&X", self.groupBox)
        self.radio_y = QRadioButton("&Y", self.groupBox)
        self.radio_z = QRadioButton("&Z", self.groupBox)
        self.buttonGroup.addButton(self.radio_x, 0)
        self.buttonGroup.addButton(self.radio_y, 1)
        self.buttonGroup.addButton(self.radio_z, 2)
        self.hboxlayout1.addWidget(self.radio_x)
        self.hboxlayout1.addWidget(self.radio_y)
        self.hboxlayout1.addWidget(self.radio_z)
        self.hLayout.addWidget(self.groupBox)

        self.controlLayout = QVBoxLayout()
        self.checkbox = QCheckBox("Enable &rotation", self.centralWidget)
        self.checkbox.setDown(False)
        self.button = QPushButton("&Change cone color", self.centralWidget)
        self.controlLayout.addWidget(self.checkbox)
        self.controlLayout.addWidget(self.button)

        self.hLayout.addLayout(self.controlLayout)
        self.mainLayout.addLayout(self.hLayout)

        self.setCentralWidget(self.centralWidget)

        self.radio_x.setChecked(True)

        self.examiner.show()

        self.connect(self.buttonGroup, SIGNAL("buttonClicked(int)"), self.change_axis)
        self.connect(self.button, SIGNAL("clicked()"), self.change_color)
        self.connect(self.checkbox, SIGNAL("clicked()"), self.rotate)

    def change_axis(self, axis):
        self.rotxyz.axis = axis

    def change_color(self):
        self.material.diffuseColor = (random(), random(), random())

    def rotate(self):
        self.gate.enableNotify(not self.gate.enableNotify(False))

def main():
    # Initialize Qt. This returns a main window to use.
    # If unsuccessful, exit.
    app = QApplication(sys.argv)

    if app is None:
        sys.exit(1)

    # set up scrollview window
    vp = EmbeddedWindow(app)
    vp.setWindowTitle("Embedded viewer")
    # map window
    vp.resize(640, 480)

    # set termination condition
    QObject.connect(qApp, SIGNAL("lastWindowClosed()"), qApp, SLOT("quit()"))

    # start event loop
    # show the widget
    vp.show()
    sys.exit(app.exec_())

if __name__ == '__main__':
    main()

VolumeRendering example changes for Ubuntu 18.04

Traceback (most recent call last):
File "VolumeRendering.py", line 69, in <module>
lib = ctypes.cdll.LoadLibrary("/Library/Frameworks/VolumeViz.framework/VolumeViz")
File "/usr/lib/python3.6/ctypes/__init__.py", line 426, in LoadLibrary
return self._dlltype(name)
File "/usr/lib/python3.6/ctypes/__init__.py", line 348, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /Library/Frameworks/VolumeViz.framework/VolumeViz: cannot open shared object file:No such file or directory

I have libSIMVoleon.so version 2.0.3a installed, what do I need to change or what am I missing?

changed line 70 to: lib = ctypes.cdll.LoadLibrary('/usr/local/lib/libSIMVoleon.so')

Issue with installation on Mac

I'm trying to install PyInventor on MacOSX, and I'm running into an issue during compiling:

src/PySceneManager.cpp:726:18: error: cannot initialize a parameter of type
'void *' with an rvalue of type 'const char *'
in.setBuffer(bgScene.getString(), bgScen...
^~~~~~~~~~~~~~~~~~~
/Library/Frameworks/Inventor.framework/Resources/include/Inventor/SoInput.h:78:33: note:
passing argument to parameter 'bufpointer' here
virtual void setBuffer(void * bufpointer, size_t bufsize);

It looks like it's related to the version of Coin, I have it working on Ubuntu 14.04 which has libcoin80, but it doesn't work on Ubuntu 12.04 (libcoin60). Installing from Coin3D's bitbucket repo gives libcoin60 on mac, it seems. I haven't tried using macports to install Coin, since I have qt5-mac installed through there and macports has qt4-mac as a dependency for coin, so they conflict. Taking a look at the portfile, it looks like it's pulling from the same bitbucket repo.

Do you have any ideas for other things I could try?

Won't compile on Ubuntu 14.04, Python 2.7

Using the current HEAD on master (git clone ...)

cd ./PyInventor
sudo python setup.py install

Results in:

src/PyInventor.cpp: In function ‘void PyInit_inventor()’:
src/PyInventor.cpp:622:28: error: variable ‘PyInit_inventor()::PyModuleDef iv_module’ has initializer but incomplete type
  static struct PyModuleDef iv_module = 
                            ^
src/PyInventor.cpp:624:3: error: ‘PyModuleDef_HEAD_INIT’ was not declared in this scope
   PyModuleDef_HEAD_INIT,
   ^
src/PyInventor.cpp:646:44: error: ‘PyModule_Create’ was not declared in this scope
  PyObject* mod = PyModule_Create(&iv_module);
                                            ^
src/PyInventor.cpp:671:9: error: return-statement with a value, in function returning 'void' [-fpermissive]
  return mod;
         ^

Would love to use this on my project. Hope it gets fixed :)

As a side note, I'm trying to use COIN (sudo apt-get install libcoin libcoin-dev) for the Open Inventor library. I hope it's compatible with PyInventor... didn't get that far yet.

scene graph editor PySide / python incompatibility

Scene Graph Editor would be very useful to me, but I can't get it to work.

I tried the windows installer, which said it needed python3.5, so I installed that using miniconda and edited my registry to get it in there so the installer would find it. But then when I run it it says it needs PySide, and PySide doesn't seem to exist for python 3.5 (only PySide2 or newer).

I also managed to install on linux using setup.py (with workaround for #11) and have pretty much the same experience over there -- it wants old pyside, but that's incompatible with the python version it wants.

Engines don't provide any outputs

Hi Thomas,

Thank you very much indeed for contributing and sharing PyInventor!
I really do enjoy experimenting with it and would appreciate it very much
if you could please make a design proposal how to extend PyInventor in
order to support Inventor engines for animated / interactive scenes.

As of PyInventor-1.0, engines don't seem to provide any outputs
(fields to connect to). For animation purposes, it would also be
helpful to have access and make field connections to the global
realtime field and set/get its temporal resolution. Would addding
the global realtime field to PyInventor be a "low hanging fruit"?

Otherwise, I would also be grateful if you could please make a
proposal how I can add the global realtime field to PyInventor.

Many thanks indeed in advance!

Best,
Peter.

Can't compile with Coin

Hello,
I am trying to compile with Coin which I have installed from your source. The Coin classes SbMatrix and SoForeignFileKit are not compatible. Thanks for any assistance.

System specs:

  • CentOS release 6.3
  • GNU/Linux 2.6.32-279.22.1.el6.x86_64
  • gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC)

From setup.py:

Coin3D paths

oivincpath = '/usr/local/include'
oivlibpath = '/usr/local/lib'
oivlibname = 'COIN'

gcc errors:

: python3 ./setup.py install
running install
running build
running build_py
running build_ext
building 'inventor' extension
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/lib/python3.3/site-packages/numpy/numarray/include -I/usr/local/lib/python3.3/site-packages/numpy/core/include -I/usr/local/include -I/usr/local/include/python3.3m -c src/PyInventor.cpp -o build/temp.linux-x86_64-3.3/src/PyInventor.o -DCOIN_DLL
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
src/PyInventor.cpp: In function 'PyObject* iv_write(PyObject*, PyObject*, PyObject*)':
src/PyInventor.cpp:181: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp:181: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp: In function 'PyObject* iv_search(PyObject*, PyObject*, PyObject*)':
src/PyInventor.cpp:231: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp:231: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp:231: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp:231: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp:231: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp:231: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp: In function 'PyObject* iv_pick(PyObject*, PyObject*, PyObject*)':
src/PyInventor.cpp:313: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp:313: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp:313: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp:313: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp:313: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp:313: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp:313: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp:313: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp:313: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp:313: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp: In function 'PyObject* iv_image(PyObject*, PyObject*, PyObject*)':
src/PyInventor.cpp:411: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp:411: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp:411: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp:411: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp:411: warning: deprecated conversion from string constant to 'char*'
src/PyInventor.cpp:411: warning: deprecated conversion from string constant to 'char*'
/usr/local/lib/python3.3/site-packages/numpy/core/include/numpy/__multiarray_api.h: At global scope:
/usr/local/lib/python3.3/site-packages/numpy/core/include/numpy/__multiarray_api.h:1448: warning: 'int _import_array()' defined but not used
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/lib/python3.3/site-packages/numpy/numarray/include -I/usr/local/lib/python3.3/site-packages/numpy/core/include -I/usr/local/include -I/usr/local/include/python3.3m -c src/PySceneManager.cpp -o build/temp.linux-x86_64-3.3/src/PySceneManager.o -DCOIN_DLL
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
src/PySceneManager.cpp:52: warning: ignoring #pragma warning
src/PySceneManager.cpp:53: warning: ignoring #pragma warning
src/PySceneManager.cpp: In static member function 'static PyTypeObject* PySceneManager::getType()':
src/PySceneManager.cpp:76: warning: deprecated conversion from string constant to 'char*'
src/PySceneManager.cpp:76: warning: deprecated conversion from string constant to 'char*'
src/PySceneManager.cpp:76: warning: deprecated conversion from string constant to 'char*'
src/PySceneManager.cpp:76: warning: deprecated conversion from string constant to 'char*'
src/PySceneManager.cpp:76: warning: deprecated conversion from string constant to 'char*'
src/PySceneManager.cpp:76: warning: deprecated conversion from string constant to 'char*'
src/PySceneManager.cpp: In static member function 'static int PySceneManager::tp_init(PySceneManager::Object*, PyObject*, PyObject*)':
src/PySceneManager.cpp:246: warning: deprecated conversion from string constant to 'char*'
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/lib/python3.3/site-packages/numpy/numarray/include -I/usr/local/lib/python3.3/site-packages/numpy/core/include -I/usr/local/include -I/usr/local/include/python3.3m -c src/PySceneObject.cpp -o build/temp.linux-x86_64-3.3/src/PySceneObject.o -DCOIN_DLL
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
src/PySceneObject.cpp:34: warning: ignoring #pragma warning
src/PySceneObject.cpp:35: warning: ignoring #pragma warning
src/PySceneObject.cpp:36: warning: ignoring #pragma warning
src/PySceneObject.cpp: In function 'void inventorErrorCallback(const SoError*, void*)':
src/PySceneObject.cpp:145: warning: enumeration value 'ERROR' not handled in switch
src/PySceneObject.cpp: In static member function 'static PyTypeObject* PySceneObject::getNodeType()':
src/PySceneObject.cpp:366: warning: missing braces around initializer for 'PySequenceMethods'
src/PySceneObject.cpp:373: warning: missing braces around initializer for 'PyMappingMethods'
src/PySceneObject.cpp: In static member function 'static int PySceneObject::tp_init(PySceneObject::Object*, PyObject*, PyObject*)':
src/PySceneObject.cpp:624: warning: deprecated conversion from string constant to 'char*'
src/PySceneObject.cpp:624: warning: deprecated conversion from string constant to 'char*'
src/PySceneObject.cpp:624: warning: deprecated conversion from string constant to 'char*'
src/PySceneObject.cpp:624: warning: deprecated conversion from string constant to 'char*'
src/PySceneObject.cpp: In static member function 'static int PySceneObject::tp_init2(PySceneObject::Object*, PyObject*, PyObject*)':
src/PySceneObject.cpp:747: warning: deprecated conversion from string constant to 'char*'
src/PySceneObject.cpp:747: warning: deprecated conversion from string constant to 'char*'
src/PySceneObject.cpp:747: warning: deprecated conversion from string constant to 'char*'
src/PySceneObject.cpp: In static member function 'static int PySceneObject::setField(SoField*, PyObject*)':
src/PySceneObject.cpp:1171: warning: comparison between signed and unsigned integer expressions
src/PySceneObject.cpp:1180: warning: comparison between signed and unsigned integer expressions
src/PySceneObject.cpp:1192: warning: comparison between signed and unsigned integer expressions
src/PySceneObject.cpp:1228: warning: comparison between signed and unsigned integer expressions
src/PySceneObject.cpp:1272: error: no matching function for call to 'SbMatrix::setValue(float [16])'
/usr/local/include/Inventor/SbMatrix.h:52: note: candidates are: void SbMatrix::setValue(const float (&)[4][4])
/usr/local/include/Inventor/SbMatrix.h:53: note: void SbMatrix::setValue(const SbDPMatrix&)
src/PySceneObject.cpp:1294: error: no matching function for call to 'SbMatrix::setValue(float*)'
/usr/local/include/Inventor/SbMatrix.h:52: note: candidates are: void SbMatrix::setValue(const float (&)[4][4])
/usr/local/include/Inventor/SbMatrix.h:53: note: void SbMatrix::setValue(const SbDPMatrix&)
src/PySceneObject.cpp:1294: error: no matching function for call to 'SbMatrix::setValue(float*)'
/usr/local/include/Inventor/SbMatrix.h:52: note: candidates are: void SbMatrix::setValue(const float (&)[4][4])
/usr/local/include/Inventor/SbMatrix.h:53: note: void SbMatrix::setValue(const SbDPMatrix&)
src/PySceneObject.cpp: In static member function 'static PyObject* PySceneObject::tp_getattro(PySceneObject::Object*, PyObject*)':
src/PySceneObject.cpp:1349: error: 'class SoForeignFileKit' has no member named 'convert'
error: command 'gcc' failed with exit status 1

How to access constants (enums)

Hi

I'm trying to do more complex openInventor scenegraph programatically to display my data. For this i'm utilizing MaterialBinding and the MaterialBinding has constants like SO_PER_VERTEX_INDEXED or SO_PER_FACE_INDEXED, SO_PER_FACE etc

how can i accesse these constants throun inventor python package?

Similar for IndexedFaceSet how to specifiy SO_END_FACE_INDEX

I know that inventor and PyInventor skip the SO_ prefix but event without it constants are not found.

no match for ‘operator<’ Ubuntu 18.04

src/PyInventor.cpp:78:76: required from here /usr/include/c++/7/bits/stl_function.h:386:20: error: no match for ‘operator<’ (operand types are ‘const SbName’ and ‘const SbName’)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.