pivy 0.6.2

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Post Reply
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

pivy 0.6.2

Post by looo »

I will soon release a new pivy version. So I am looking for people who can create packages for osx and linux. Pivy should be quite simple to be compiled, so if you know how to package FreeCAD, pivy should not be a big problem.

pivy 0.6.2 includes:
- python3 support
- PyQt4 is replaced with PySide
- callbacks and sensors are working with FreeCAD
- most examples work
- some extra utilities are added

Also if anyone has the time to try this pivy version:

Code: Select all

git clone https://github.com/looooo/pivy
cd pivy
python setup.py build
sudo python setup.py install
And please report any problems:
https://github.com/looooo/pivy/issues
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: pivy 0.6.2

Post by looo »

I need some help with some pivy stuff. This makes headache for some time allready. Maybe someone has an idea.

After moving soqt to pyside I get a problem with callbacks. The example 10.2 [1] doesn't work with soqt. The second argument of the callback-function should be a subclass of QEvent. But with pyside it always is a QEvent and not a subclass. I have no idea how the wrapping is done. Somehow it must happen automatically because subclasses of QEvent are never mentioned in the wrapper files.
There is also a minimal example available showing this problem [2] Printing the event in the callback-function gives this result:

Code: Select all

<0x7ffd587590c0  at 0x7fbf24eaef80>
This doesn't look like a proper PySide object.

[1] https://github.com/looooo/pivy/blob/mas ... CB.py#L104
[2] https://github.com/looooo/pivy/blob/246 ... back.py#L8

edit:
I think this should be the wrapper-function for the QEvent. But somehow this function is never called...
https://github.com/looooo/pivy/blob/246 ... i#L109L150
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: pivy 0.6.2

Post by looo »

The problem seems to be some differences between sip and shiboken. QEvents are not wrapped to python QEvents, and not to there subclasses. The wrapping happens in these 3 lines: https://github.com/looooo/pivy/blob/mas ... a.i#L28L32
I found some references about differences of "wrapInstance" between sip and shiboken. While sip returns the subclass directly, some further things have to be done to get the subclass with shiboken: https://github.com/mottosso/Qt.py/issue ... -224840437

But a QEvent is not a QObject and therefor has no metaObject() to get the subclass name. So the question is: How to get the sub-class name of a QEvent?
wmayer
Founder
Posts: 20300
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: pivy 0.6.2

Post by wmayer »

When looking through PySide2 code then it uses the C++ typeid keyword. So, in your case replace the hard-coded "QEvent" with this:

Code: Select all

typeid(*event).name()
So, I hope it also works for PySide.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: pivy 0.6.2

Post by looo »

thanks. Can you give some references where you have found the information. I tried it. but the typeinfo doesn't match the subclassname:

Code: Select all

11QMouseEvent
edit:
worked with some helpers:

Code: Select all

# include <typeinfo>
#if __unix
#include <cxxabi.h>
template <typename T> char* get_typename(T& object)
{
    return abi::__cxa_demangle(typeid(object).name(), 0, 0, 0);
}
#else
template <typename T> char* get_typename(T& object)
{
    return typeid(object).name();
}
#endif
wmayer
Founder
Posts: 20300
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: pivy 0.6.2

Post by wmayer »

thanks. Can you give some references where you have found the information. I tried it. but the typeinfo doesn't match the subclassname:
I implemented a little demo application:

Code: Select all

from PySide2 import QtWidgets

class MyWidget(QtWidgets.QWidget):
    def event(self, e):
        print type(e)
        return False
        

w=MyWidget()
w.show()
When opening qwidget_wrapper.cpp then there is the overridden event() method of the Python wrapper which invokes the methods of the Pythpn class MyWidget

Code: Select all


bool QWidgetWrapper::event(QEvent * arg__1)
{
    Shiboken::GilState gil;
    if (PyErr_Occurred())
        return ((bool)0);
    Shiboken::AutoDecRef pyOverride(Shiboken::BindingManager::instance().getOverride(this, "event"));
    if (pyOverride.isNull()) {
        gil.release();
        return this->::QWidget::event(arg__1);
    }

    Shiboken::AutoDecRef pyArgs(Py_BuildValue("(N)",
        Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkPySide2_QtCoreTypes[SBK_QEVENT_IDX], arg__1)
    ));

    ...
}
When stepping through the code then the SbkConverter's pointerToPython function is this:

Code: Select all

// C++ to Python pointer conversion - tries to find the Python wrapper for the C++ object (keeps object identity).
static PyObject* QEvent_PTR_CppToPython_QEvent(const void* cppIn) {
    PyObject* pyOut = (PyObject*)Shiboken::BindingManager::instance().retrieveWrapper(cppIn);
    if (pyOut) {
        Py_INCREF(pyOut);
        return pyOut;
    }
    const char* typeName = typeid(*((::QEvent*)cppIn)).name();
    return Shiboken::Object::newObject(&Sbk_QEvent_Type, const_cast<void*>(cppIn), false, false, typeName);
}
If e.g. a mouse move is performed then for VS compilers the value of typeid().name() is class QMoveEvent. In the further handling there is no code that tries to get an unmangled name, i.e. removing the prefix class.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: pivy 0.6.2

Post by looo »

for VS-compiler this might be true. But I don't think there is a direct way to get the pure subclass-name with gcc. So I will stay with the demangeling hack with gcc. Actually this is only related to the SoQt bindings, which are not used by freecad...
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: pivy 0.6.2

Post by looo »

another soqt problem:
SoQt has some subrepos. Somehow this subrepos are actualized in the cmake step. Windows reports that hg (mercurial) is needed to run cmake... Using a compressed version of the soqt repo doesn't work because of some compile-errors. So somehow the compressed version of the repo differs from the cloned repo. This is very strange, and until now I couldn't find a way to solve this issue...
If anyone knows how to get a compressed copy of a repo with subrepos on mercurial, please give me a hint how to solve this problem.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: pivy 0.6.2

Post by looo »

my last reported problem was quite easy to solve. Creating a dir build and running cmake from this build-directory did the trick.
On Linux nearly all visual tests are now working. My win7 system also works quite good. Win8 is not that good (SoQt problems) and win 10 is worst... (SoQt and quarter fail) Win8 and Win10 currently have some problems with SoQt.

If anyone has time and is good with windows debugging... please help @peterl94 , @sgrogan

To setup an pivy environment:
conda create -n pivy_35 pivy pyside python=3.5

To test pivy, run the Mentor examples or other examples... especially 10.2 is interesting. We have already a quite long discussion about this example:
https://github.com/looooo/pivy/issues/18

I will also upload packages for python3.6...
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: pivy 0.6.2

Post by looo »

My first try to create a debian-package wasn't that successfully.
My problem was the signing of the dsc file. Somehow the key I have produced didn't work. The reported error was:

Code: Select all

dpkg-source -x pivy_0.6.2-0.dsc 
gpgv: Signatur vom Sam 10 Jun 2017 09:41:54 CEST
gpgv:                mittels DSA-Schlüssel 
gpgv: Signatur kann nicht geprüft werden: Kein öffentlicher Schlüssel
dpkg-source: Warnung: Fehler beim Überprüfen der Signatur von ./pivy_0.6.2-0.dsc
dpkg-source: Information: pivy wird nach pivy-0.6.2 extrahiert
dpkg-source: Fehler: unerkannte Datei für ein v2.0-Quellpaket: pivy.tar.gz
the files can be found here.
https://github.com/looooo/pivy/blob/mas ... ng/debian/

The 2. problem is most-likely because no tar.gz can be used. But I have no idea how to do the signing. Maybe someone can help with this step.
NormandC wrote:
wmayer wrote:
Post Reply