GauiStori / PyQt-Qwt

Python PyQt wrapper for Qwt6
Other
53 stars 18 forks source link

Fixes QwtPlotZoomer.setZoomStack() issue #18 #19

Closed razman786 closed 3 years ago

razman786 commented 3 years ago

Quick hack to get QwtPlotZoomer.setZoomStack() working. Tested and setZoomStack() is doing what it is meant to :)

Initial error that was found and is now fixed:

QwtPlotZoomer.setZoomStack(self, stack, index) - TypeError: QRectF cannot be converted to PyQt5.QtCore.QPoint in this context

QwtPlotZoomer.zoomStack() however still results in the following error:

0x00007fffe5f909ac in convertFrom_QStack_0100QRectF () from /usr/lib/python3.8/site-packages/PyQt5/Qwt.so

After a quick hack the error for zoomStack() was still:

0x00007fffe5f909ac in ?? () from /usr/lib/python3.8/site-packages/PyQt5/Qwt.so

Please note that for some reason I need to keep adding -I/usr/include/qt5/QtOpenGL to INCPATH in Qwt/Makefile for a successful compilation.

Test environment (Gentoo):

QT_SELECT=qt5 python3 configure.py --qwt-incdir=/usr/include/qwt6 --qwt-libdir=/usr/lib64 --no-qwt-api --qwt-lib=qwt6-qt5
Configuring Qwt 1.02.02...
Qwt 6.1.5 is being used.
The Qwt .sip files will be installed in
/usr/lib/python-exec/python3.8/../../../share/sip/PyQt5.
Qwt will be installed in /usr/lib/python3.8/site-packages/PyQt5.
PyQt 5.15.2 is being used.
Qt 5.15.2 is being used.
sip 4.19.24 is being used.
The sip executable is /usr/bin/sip.
Qwt is being built with 'protected' redefined as 'public'.
The PEP 484 stubs will be installed in /usr/lib/python3.8/site-packages/PyQt5.
Generating the C++ source for the Qwt module...
Generating the .pro file for the Qwt module...
Generating the top-level .pro file...
Generating the Makefiles...
GauiStori commented 3 years ago

Hi Raz

opengl and svg has been added to the configure.py. I see that you are using sip 4.19 but I am using sip 5.5.

I also added zoomstack to the simpleplot example and it works nicely for me with the template implementation of QStack.

Can you please test again.

Regards Gudjon

razman786 commented 3 years ago

Hi Gudjon

The reason i'm using that SIP version is because the final deployment for the software update to PyQt5, is for users that are currently running on Ubuntu 20.04 LTS (and some are still on 18.04 LTS).

apt is providing SIP 4.19 and I'm not sure if it's possible to workaround it?

Any help or ideas would be much appreciated.

Cheers, Raz

GauiStori commented 3 years ago

Hi Raz

The reason i'm using that SIP version is because the final deployment for the software update to PyQt5, is for users that are currently running on Ubuntu 20.04 LTS (and some are still on 18.04 LTS). Then it will be around for some time. apt is providing SIP 4.19 and I'm not sure if it's possible to workaround it? Any help or ideas would be much appreciated.

I did remove sip5 from the configure.py script (only needed if sip5 is installed) and it seems to work nicely for me.

QT_SELECT=qt5 python3 configure.py --qwt-incdir=/usr/include/qwt --qwt-libdir=/usr/lib --qwt-lib=qwt-qt5 Configuring Qwt 1.02.02... Qwt 6.1.5 is being used. The Qwt .sip files will be installed in /usr/lib/python3/dist-packages/PyQt5/bindings. Qwt will be installed in /usr/lib/python3/dist-packages/PyQt5. PyQt 5.15.2 is being used. Qt 5.15.2 is being used. sip 4.19.25 is being used. The sip executable is /usr/bin/sip. Qwt is being built with 'protected' redefined as 'public'. The PEP 484 stubs will be installed in /usr/lib/python3/dist-packages/PyQt5. The Qwt API file will be installed in /usr/share/qt5/qwt/api/python. Generating the C++ source for the Qwt module... Generating the .pro file for the Qwt module... Generating the top-level .pro file... Generating the Makefiles...

This works without problem for me. Please show where the procedure stops for you.

Cheers Gudjon

razman786 commented 3 years ago

Hi Gudjon,

I went straight to the deployment platform (20.04 LTS) and ran QT_SELECT=qt5 python3 configure.py --qwt-incdir=/usr/include/qwt --qwt-libdir=/usr/lib --qwt-lib=qwt-qt5 from the zoomstack branch, output was:

Configuring Qwt 1.02.02...
Qwt 6.1.4 is being used.
The Qwt .sip files will be installed in /usr/share/sip/PyQt5.
Qwt will be installed in /usr/lib/python3/dist-packages/PyQt5.
PyQt 5.14.1 is being used.
Qt 5.12.8 is being used.
sip 4.19.21 is being used.
The sip executable is /usr/bin/sip.
Qwt is being built with 'protected' redefined as 'public'.
The PEP 484 stubs will be installed in /usr/lib/python3/dist-packages/PyQt5.
The Qwt API file will be installed in /usr/share/qt5/qwt/api/python.
Generating the C++ source for the Qwt module...
Generating the .pro file for the Qwt module...
Generating the top-level .pro file...
Generating the Makefiles...

The error encountered during make is:

PycharmProjects/new/PyQt-Qwt/Qwt/sipQwtQwtPlotSpectroCurve.cpp: In member function ‘virtual size_t sipQwtPlotSpectroCurve::dataSize() const’:
PycharmProjects/new/PyQt-Qwt/Qwt/sipQwtQwtPlotSpectroCurve.cpp:158:49: error: ‘size_t QwtSeriesStore<T>::dataSize() const [with T = QwtPoint3D; size_t = long unsigned int]’ is inaccessible within this context
  158 |         return  ::QwtPlotSpectroCurve::dataSize();
      |                                                 ^
In file included from /usr/include/qwt/qwt_plot_seriesitem.h:17,
                 from /usr/include/qwt/qwt_plot_spectrocurve.h:14,
                 from PycharmProjects/new/PyQt-Qwt/sip/qwt_plot_spectrocurve.sip:18:
/usr/include/qwt/qwt_series_store.h:174:8: note: declared here
  174 | size_t QwtSeriesStore<T>::dataSize() const
      |        ^~~~~~~~~~~~~~~~~
PycharmProjects/new/PyQt-Qwt/Qwt/sipQwtQwtPlotSpectroCurve.cpp:158:49: error: ‘QwtSeriesStore<QwtPoint3D>’ is not an accessible base of ‘const sipQwtPlotSpectroCurve’
  158 |         return  ::QwtPlotSpectroCurve::dataSize();
      |                                                 ^
PycharmProjects/new/PyQt-Qwt/Qwt/sipQwtQwtPlotSpectroCurve.cpp: In member function ‘virtual QRectF sipQwtPlotSpectroCurve::dataRect() const’:
PycharmProjects/new/PyQt-Qwt/Qwt/sipQwtQwtPlotSpectroCurve.cpp:173:49: error: ‘QRectF QwtSeriesStore<T>::dataRect() const [with T = QwtPoint3D]’ is inaccessible within this context
  173 |         return  ::QwtPlotSpectroCurve::dataRect();
      |                                                 ^
In file included from /usr/include/qwt/qwt_plot_seriesitem.h:17,
                 from /usr/include/qwt/qwt_plot_spectrocurve.h:14,
                 from PycharmProjects/new/PyQt-Qwt/sip/qwt_plot_spectrocurve.sip:18:
/usr/include/qwt/qwt_series_store.h:183:8: note: declared here
  183 | QRectF QwtSeriesStore<T>::dataRect() const
      |        ^~~~~~~~~~~~~~~~~
PycharmProjects/new/PyQt-Qwt/Qwt/sipQwtQwtPlotSpectroCurve.cpp:173:49: error: ‘QwtSeriesStore<QwtPoint3D>’ is not an accessible base of ‘const sipQwtPlotSpectroCurve’
  173 |         return  ::QwtPlotSpectroCurve::dataRect();
      |                                                 ^
PycharmProjects/new/PyQt-Qwt/Qwt/sipQwtQwtPlotSpectroCurve.cpp: In member function ‘virtual void sipQwtPlotSpectroCurve::setRectOfInterest(const QRectF&)’:
PycharmProjects/new/PyQt-Qwt/Qwt/sipQwtQwtPlotSpectroCurve.cpp:189:53: error: ‘void QwtSeriesStore<T>::setRectOfInterest(const QRectF&) [with T = QwtPoint3D]’ is inaccessible within this context
  189 |          ::QwtPlotSpectroCurve::setRectOfInterest(a0);
      |                                                     ^
In file included from /usr/include/qwt/qwt_plot_seriesitem.h:17,
                 from /usr/include/qwt/qwt_plot_spectrocurve.h:14,
                 from PycharmProjects/new/PyQt-Qwt/sip/qwt_plot_spectrocurve.sip:18:
/usr/include/qwt/qwt_series_store.h:192:6: note: declared here
  192 | void QwtSeriesStore<T>::setRectOfInterest( const QRectF &rect )
      |      ^~~~~~~~~~~~~~~~~
PycharmProjects/new/PyQt-Qwt/Qwt/sipQwtQwtPlotSpectroCurve.cpp:189:53: error: ‘QwtSeriesStore<QwtPoint3D>’ is not an accessible base of ‘sipQwtPlotSpectroCurve’
  189 |          ::QwtPlotSpectroCurve::setRectOfInterest(a0);
      |                                                     ^
PycharmProjects/new/PyQt-Qwt/Qwt/sipQwtQwtPlotSpectroCurve.cpp: In function ‘void* cast_QwtPlotSpectroCurve(void*, const sipTypeDef*)’:
PycharmProjects/new/PyQt-Qwt/Qwt/sipQwtQwtPlotSpectroCurve.cpp:794:65: error: ‘QwtSeriesStore<QwtPoint3D>’ is an inaccessible base of ‘QwtPlotSpectroCurve’
  794 |         return static_cast< ::QwtSeriesStoreQwtPoint3D *>(sipCpp);
      |                                                                 ^
make[1]: *** [Makefile:1289: sipQwtQwtPlotSpectroCurve.o] Error 1
make[1]: Leaving directory 'PycharmProjects/new/PyQt-Qwt/Qwt'
make: *** [Makefile:47: sub-Qwt-make_first-ordered] Error 2

Cheers, Raz

GauiStori commented 3 years ago

Hi again

On Sunday, 11 April 2021 21:28:47 CEST Raz wrote:

In file included from /usr/include/qwt/qwt_plot_seriesitem.h:17, from /usr/include/qwt/qwt_plot_spectrocurve.h:14, from PycharmProjects/new/PyQt-Qwt/sip/qwt_plot_spectrocurve.sip:18: /usr/include/qwt/qwt_series_store.h:192:6: note: declared here 192 | void QwtSeriesStore::setRectOfInterest( const QRectF &rect ) | ^~~~~ PycharmProjects/new/PyQt-Qwt/Qwt/sipQwtQwtPlotSpectroCurve.cpp:189:53: error: ‘QwtSeriesStore’ is not an accessible base of ‘sipQwtPlotSpectroCurve’ 189 | ::QwtPlotSpectroCurve::setRectOfInterest(a0); | ^ PycharmProjects/new/PyQt-Qwt/Qwt/sipQwtQwtPlotSpectroCurve.cpp: In function ‘void cast_QwtPlotSpectroCurve(void, const sipTypeDef)’: PycharmProjects/new/PyQt-Qwt/Qwt/sipQwtQwtPlotSpectroCurve.cpp:794:65: error: ‘QwtSeriesStore’ is an inaccessible base of ‘QwtPlotSpectroCurve’ 794 | return static_cast< ::QwtSeriesStoreQwtPoint3D >(sipCpp); | ^ make[1]: [Makefile:1289: sipQwtQwtPlotSpectroCurve.o] Error 1 make[1]: Leaving directory 'PycharmProjects/new/PyQt-Qwt/Qwt' make: [Makefile:47: sub-Qwt-make_first-ordered] Error 2


There is an error in my Timeline. As a workaround, can you please comment out the following lines 
in sip/Qwt_Qt5.sip

//%If(Qwt_6_1_5 -) //%Include qwt_plot_spectrocurve.sip
//%Include qwt_plot_tradingcurve.sip //%End // (Qwt_6_1_5 -)

I have tested this to work now. I was so sure I had made this work with configure.py.

Hope this works for you.

Cheers Gudjon

razman786 commented 3 years ago

Hi

Thank you! It now complies with the workaround on Ubuntu 20.04 LTS.

However, this error from my first post is back when running setZoomStack():

QwtPlotZoomer.setZoomStack(self, stack, index)
TypeError: QRectF cannot be converted to PyQt5.QtCore.QPoint in this context

If I change sip/QStack.sip like the following and replace QPoint with _TYPE_, it works fine:

diff --git a/sip/QtQStack.sip b/sip/QtQStack.sip
index f250705..30e00b8 100644
--- a/sip/QtQStack.sip
+++ b/sip/QtQStack.sip
@@ -52,11 +52,11 @@ template<_TYPE_>
         int state;
         t = reinterpret_cast<_TYPE_ *>(
                 sipForceConvertToType(PyList_GET_ITEM(sipPy, i),
-                        sipType_QPoint, 0, SIP_NOT_NONE, &state,
+                        sipType__TYPE, 0, SIP_NOT_NONE, &state,
                         sipIsErr));
         if (*sipIsErr)
         {
-            sipReleaseType(t, sipType_QPoint, state);
+            sipReleaseType(t, sipType__TYPE_, state);
             delete t;
             return 0;
         }

Calling zoomStack() still causes a segmentation fault though :(

Thank you again for all your help!

Cheers, Raz

GauiStori commented 3 years ago

Hi again

     {
  • sipReleaseType(t, sipType_QPoint, state);
  • sipReleaseType(t, sipType_QRectF, state); delete t; return 0; } Sorry. You are correct, my mistake but I changed QPoint to TYPE instead of QRect. It compiles and I will test later today.

The timeline works with sip-build. I will fix this in the configure.py script ASAP. The problem is that the spectrocurve and tradingcurve don't work with Qwt < 6.1.5.

I will update the Debian package to 6.1.6 soon but that may be too late for Ubuntu LTS.

Cheers Gudjon

razman786 commented 3 years ago

Hi

Thank you so much for all your help! It’s very much appreciated.

May be the zoomStack() call should be disabled or noted that it doesn’t work, well at least for me it seg faults. The priority is setZoomStack() that now works beautifully.

Would it be possible to have the Debian release installable as a Ubuntu LTS PPA, at least until LTS is updated?

Again my renewed thank you.

Cheers, Raz

GauiStori commented 3 years ago

Hi

On Monday, 12 April 2021 09:48:41 CEST Raz wrote:

May be the zoomStack() call should be disabled or noted that it doesn’t work, well at least for me it seg faults. You are correct. I will try to fix it. It works in C++, for Qwt-6.1.4 PyQt-Qwt segfaults but zoomStack() doesn't respond for Qwt-6.1.6

The priority is setZoomStack() that now works beautifully. Great

Would it be possible to have the Debian release installable as a Ubuntu LTS PPA, at least until LTS is updated? I will check that

Again my renewed thank you. You are welcome.

The timeline should work now. You don't need to comment the trading curve out.

Cheers Gudjon