Hi Alan,

unfortunately I couldn't test the pyqt5_example as I do not use python and
in spite having it installed I couldn't understand exactly what else to
install but  trying to build plplot
i get
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.6.13",
minimum required is "3")
-- Could NOT find PythonLibs (missing: PYTHON_LIBRARIES
PYTHON_INCLUDE_DIRS)

however I build all the examples and the patch i send you now seems to work
very fine:

cheers

P.s. Latter on I will try to understand how to deploy  pyqt5_example. I'm
also going to try to see how i can force plplot to build with qt6 and then
one will know if this small patch is enough to deal with the next major
version of the qt,





On Sun, Jun 6, 2021 at 10:33 PM Alan W. Irwin <alan.w.irwin1...@gmail.com>
wrote:

> Hi António:
>
> On 2021-06-05 20:53+0100 António Rodrigues Tomé wrote:
>
> > Hi Alan,
> >
> > I hope you are well and managed to be free of the virus.
>
> So far so good.  And I hope that is true for everyone on this list
> and their close families!
>
> > new versions of QT5 produce some warnings about the use of  deprecated
> > functions in the driver.
> > The new qt6 will remove most of the obsolete functions,  unless one uses
> an
> > additional back compatibility module. Namely the  QLinkedList will no
> > longer be supported in qt6.
> >
> > So I send you a patch where I replace all the functions that (my qt5.15.2
> > versions) warns about.
> > I think that everything will work fine even with older qt versions,
> >
> > This was needed mainly because for qt6 it will be necessary.
>
> Thanks, António for making this effort to future-proof the PLplot qt
> component.
> You are very close to something I would be happy to push, but there is
> a regression in results that you need to fix in your patch.
>
> Here are the details concerning that regression.
>
> Your patch builds fine here on my Debian Buster = Stable with qt5.11.3
> platform and gives good run-time test results when I build the
> test_pyqt5_example (other than some deprecation warnings that eventually
> do need to be fixed), test_qt_example, and test_memqt_example targets
>
> However, it introduces a segfault regression when I attempt to build
> the test_c_qtwidget target.
>
> The previous (before your patch was applied) result for that target showed
> no warnings or errors for that target.  And there continue to be no
> warnings with this target when your patch is applied.  However,
> here is the error result for that case:
> Generate C results for qtwidget interactive device
> Testing subset of C examples for device qtwidget
> x01c
> x04c
> x08c
> x16c
> x24c
> x30c
> x14c
> /home/software/plplot/HEAD/build_dir/plplot_test/test_c_interactive.sh:
> line 47:  3746 Segmentation fault      $DEBUG_CMD "$cdir"/x${index}${lang}
> -dev $device $NP_OPTION 2> c_interactive_${device}_test.error >|
> "${OUTPUT_DIR}"/x${index}${lang}_${device}.txt
> make[3]: *** [examples/CMakeFiles/test_c_qtwidget.dir/build.make:58:
> examples/CMakeFiles/test_c_qtwidget] Error 1
> make[2]: *** [CMakeFiles/Makefile2:6635:
> examples/CMakeFiles/test_c_qtwidget.dir/all] Error 2
> make[1]: *** [CMakeFiles/Makefile2:6642:
> examples/CMakeFiles/test_c_qtwidget.dir/rule] Error 2
> make: *** [Makefile:2108: test_c_qtwidget] Error 2
>
> So it looks like all examples other than x14c work correctly with your
> patch, but
> x14c (which has quite special needs) apparently exposes an issue with your
> patch.
>
> In fact, after that test_c_qtwidget target was built (in order to build all
> necessary prerequisites) I could replicate the above segfault with
>
> software@merlin> examples/c/x14c -dev qtwidget
> Demo of multiple output streams via the qtwidget driver.
> Running with the second stream as slave to the first.
>
> Segmentation fault
>
> AND
>
> for a *fresh* configuration and build with
>
> software@merlin> printenv |grep FLAG
> FFLAGS=-g
> CXXFLAGS=-g
> CFLAGS=-g
>
> I confirmed the segfault (with these quite different compiler options)
> and also obtained the attached valgrind result determined
> from (after a build of the test_c_qtwidget target to build all
> prerequisites)
>
> valgrind --num-callers=400 examples/c/x14c -dev qtwidget 2>| valgrind.out
>
> Exactly the same test for the version of PLplot before your change
> produces the following results (if I keep hitting the enter key when
> the cursor was on the left-hand plot to proceed through the entire
> example successfully):
>
> software@merlin> valgrind --num-callers=400 examples/c/x14c -dev qtwidget
> ==9772== Memcheck, a memory error detector
> ==9772== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
> ==9772== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
> ==9772== Command: examples/c/x14c -dev qtwidget
> ==9772==
> Demo of multiple output streams via the qtwidget driver.
> Running with the second stream as slave to the first.
>
> ==9772==
> ==9772== HEAP SUMMARY:
> ==9772==     in use at exit: 526,787 bytes in 6,853 blocks
> ==9772==   total heap usage: 216,516 allocs, 209,663 frees, 39,317,429
> bytes allocated
> ==9772==
> ==9772== LEAK SUMMARY:
> ==9772==    definitely lost: 6,888 bytes in 40 blocks
> ==9772==    indirectly lost: 5,109 bytes in 125 blocks
> ==9772==      possibly lost: 2,112 bytes in 6 blocks
> ==9772==    still reachable: 512,678 bytes in 6,682 blocks
> ==9772==         suppressed: 0 bytes in 0 blocks
> ==9772== Rerun with --leak-check=full to see details of leaked memory
> ==9772==
> ==9772== For counts of detected and suppressed errors, rerun with: -v
> ==9772== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
>
> So aside from some memory leaks (likely due to a Qt5-5.11.3 issue
> rather than a PLplot issue) the 14th standard example runs perfectly
> under valgrind before your patch.
>
> I hope the attached detailed valgrind results for the segfault case
> with your patch will help you to figure out how your patch needs to be
> changed to fix this regression for the special needs of our 14th
> standard example.
>
> Also, for your next version of the patch will you please try all the
> relevant
> test targets and then report those testing results in a "Tested by":
> stanza similar to the following?
>
> Tested by: António R. Tomé <art...@gmail.com> on the <specify your
> platform details, e.g., Linux distribution name and version but also
> including your qt5.15.2 version> platform by configuring PLplot,
> building the test_pyqt5_example, test_qt_example, test_memqt_example,
> and test_c_qtwidget targets with no configuration, build, run-time, or
> GUI issues.
>
> Because our two Qt5 platforms are so different it is essential to test on
> both platforms.  So I plan to do these tests also and append my own
> "Tested by:" stanza to yours as
> follows (once those tests all succeed):
>
> Tested by: Alan W. Irwin <air...@users.sourceforge.net> on Linux
> (Debian Buster = Stable with qt5.11.3) by configuring PLplot, building
> the test_pyqt5_example, test_qt_example, test_memqt_example, and
> test_c_qtwidget targets with no configuration, build, run-time, or GUI
> issues.
>
> By the way, what I mean by no GUI issues above is that for the test targets
> that allow you to interact with a GUI (i.e., everything but
> test_c_qtwidget which because of the -np option for that test just
> runs through a critical subset of our standard examples automatically
> with no user intervention), you have exercised all possible actions
> (including exiting from the GUI which is always critical) to make sure
> all those GUI actions work).
>
> Also, if you have any trouble getting test_pyqt5_example to configure,
> remember you have to have the latest python3 and sip development
> packages installed for your platform.  Note I have included that
> possibility (if you have time to test it) because it already generates
> deprecated warnings here on my older platform, and it would be good to get
> our pyqt5 example future-proofed as well.
>
> For all those here wondering about the hiatus (for the last year now)
> in my PLplot development work, the reason for that is I am spending
> virtually 100 % of my current development time on FreeEOS with the
> goal of getting out a critical release for that software soon which
> will include all my work on modernizing that Fortran code (e.g., by
> using Fortran 2008 best practices) and by comprehensively testing that
> code's results.  So all that I have had time for from the PLplot
> perspective is to monitor other's PLplot development activities and
> help out where I can (as in the present segfault report to António).
>
> Of course, after that FreeEOS release is completed, I do hope to
> return to a more active PLplot development role starting with a fix to
> a pllegend issue (incorrect vertical line spacing when there are
> subscripts or superscripts in the legend text) that has been exposed
> by many of the FreeEOS research plots I have been producing using
> PLplot.  Of course, if you look back at the PLplot history, I first
> got active in PLplot development because of PLplot issues turned up by
> FreeEOS.  So it looks like my strong motivation for helping to develop
> PLplot will be continuing just like always!  :-)
>
> Alan
> __________________________
> Alan W. Irwin
>
> Research affiliation with the Department of Physics and Astronomy,
> University of Victoria, Victoria, BC, Canada.
>
> Programming affiliations with the FreeEOS equation-of-state
> implementation for stellar interiors (freeeos.sf.net); the Time
> Ephemerides project (timeephem.sf.net); PLplot scientific plotting
> software package (plplot.org); the libLASi project
> (unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
> and the Linux Brochure Project (lbproject.sf.net).
> __________________________
>
> Linux-powered Science
> __________________________



-- 

António Rodrigues Tomé
Universidade da Beira Interior
Instituto D. Luís (lab associado)
email address:
art...@gmail.com
art...@ubi.pt
http://www.researcherid.com/rid/A-5681-2013
From c6d3d7a83efeffe54799ab07fbf62a562fee59a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ant=C3=B3nio=20Rodrigues=20Tom=C3=A9?= <art...@gmail.com>
Date: Tue, 6 Jul 2021 23:04:54 +0100
Subject: [PATCH] Changes in the QT driver to replace deprecated functions.
 Tested with opensuse Using Qt version 5.15.2. This is a necessary move as qt6
 will remove most of the obsolete functions,  unless one uses an additional
 back compatibility module. QlinkedList is a container targeted to disapear in
 qt6, now deprecated in qt5. In this pacth we replaced it with the c++
 standard equivalent container. A few others changes were made replacing  some
  deprecated funtions for the new ones.

---
 bindings/qt_gui/plqt.cpp | 49 ++++++++++++++++++++++++++--------------
 include/qt.h             |  6 ++---
 2 files changed, 35 insertions(+), 20 deletions(-)

diff --git a/bindings/qt_gui/plqt.cpp b/bindings/qt_gui/plqt.cpp
index 498a65680..27f36975a 100644
--- a/bindings/qt_gui/plqt.cpp
+++ b/bindings/qt_gui/plqt.cpp
@@ -23,7 +23,7 @@
 //
 
 #include "qt.h"
-
+#include<list>
 // Global variables for Qt driver.
 PLDLLIMPEXP_QT_DATA( int ) vectorize = 0;
 PLDLLIMPEXP_QT_DATA( int ) lines_aa  = 1;
@@ -429,7 +429,7 @@ void QtPLDriver::drawText( EscText* txt )
     m_painterP->translate( txt->x * downscale, m_dHeight - txt->y * downscale );
     QMatrix rotShearMatrix( cos( rotation ) * stride, -sin( rotation ) * stride, cos( rotation ) * sin( shear ) + sin( rotation ) * cos( shear ), -sin( rotation ) * sin( shear ) + cos( rotation ) * cos( shear ), 0., 0. );
 
-    m_painterP->setWorldMatrix( rotShearMatrix, true );
+    m_painterP->setWorldTransform( QTransform (rotShearMatrix), true );
 
     m_painterP->translate( -txt->just * xOffset * m_painterP->device()->logicalDpiY() / picDpi, 0. );
 
@@ -618,19 +618,34 @@ QtEPSDevice::QtEPSDevice( int i_iWidth, int i_iHeight )
 {
 #if QT_VERSION < 0x040400
     setPageSize( QPrinter::A4 );
+    
 #else
+    #if QT_VERSION < 0x050300
     setFullPage( true );
     setPaperSize( QSizeF( i_iHeight, i_iWidth ), QPrinter::Point );
+    #else
+    setFullPage( true );
+    setPageSize( QPageSize(QSizeF( i_iHeight, i_iWidth ), QPageSize::Point,""));
+    #endif
 #endif
     setResolution( POINTS_PER_INCH );
     setColorMode( QPrinter::Color );
+    #if QT_VERSION < 0x050300
     setOrientation( QPrinter::Landscape );
+    #else
+    setPageOrientation( QPageLayout::Landscape );
+    #endif
     setPrintProgram( QString( "lpr" ) );
 
     if ( i_iWidth <= 0 || i_iHeight <= 0 )
     {
+        #if QT_VERSION < 0x050300
         m_dWidth  = pageRect().width();
         m_dHeight = pageRect().height();
+        #else
+         m_dWidth  =pageLayout().paintRectPixels(resolution()).width();
+         m_dHeight =pageLayout().paintRectPixels(resolution()).height();
+        #endif
     }
     else
     {
@@ -730,7 +745,7 @@ void QtPLWidget::flush()
 void QtPLWidget::clearBuffer()
 {
     lastColour.r = -1;
-    for ( QLinkedList<BufferElement>::iterator i = m_listBuffer.begin(); i != m_listBuffer.end(); ++i )
+    for ( std::list<BufferElement>::iterator i = m_listBuffer.begin(); i != m_listBuffer.end(); ++i )
     {
         switch ( i->Element )
         {
@@ -771,7 +786,7 @@ void QtPLWidget::clearBuffer()
     }
 
     m_listBuffer.clear();
-    start_iterator = m_listBuffer.constBegin();
+    start_iterator = m_listBuffer.cbegin();
     redrawAll      = true;
 }
 
@@ -792,7 +807,7 @@ void QtPLWidget::drawArc( short x, short y, short a, short b, PLFLT angle1, PLFL
     el.Data.ArcStruct->dx         = new QPointF( (PLFLT) x * downscale, m_dHeight - (PLFLT) y * downscale );
     el.Data.ArcStruct->fill       = fill;
 
-    m_listBuffer.append( el );
+    m_listBuffer.push_back( el );
     redrawFromLastFlush = true;
 }
 
@@ -803,7 +818,7 @@ void QtPLWidget::drawLine( short x1, short y1, short x2, short y2 )
     el.Element   = LINE;
     el.Data.Line = new QLineF( QPointF( (PLFLT) x1 * downscale, (PLFLT) ( m_dHeight - y1 * downscale ) ), QPointF( (PLFLT) x2 * downscale, (PLFLT) ( m_dHeight - y2 * downscale ) ) );
 
-    m_listBuffer.append( el );
+    m_listBuffer.push_back( el );
     redrawFromLastFlush = true;
 }
 
@@ -817,7 +832,7 @@ void QtPLWidget::drawPolyline( short * x, short * y, PLINT npts )
         ( *el.Data.Polyline ) << QPointF( (PLFLT) ( x[i] ) * downscale, (PLFLT) ( m_dHeight - ( y[i] ) * downscale ) );
     }
 
-    m_listBuffer.append( el );
+    m_listBuffer.push_back( el );
     redrawFromLastFlush = true;
 }
 
@@ -893,7 +908,7 @@ void QtPLWidget::drawPolygon( short * x, short * y, PLINT npts )
         }
     }
 
-    m_listBuffer.append( el );
+    m_listBuffer.push_back( el );
     redrawFromLastFlush = true;
 }
 
@@ -909,7 +924,7 @@ void QtPLWidget::setColor( int r, int g, int b, double alpha )
         el.Data.ColourStruct->B = b;
         el.Data.ColourStruct->A = (PLINT) ( alpha * 255. );
 
-        m_listBuffer.append( el );
+        m_listBuffer.push_back( el );
 
         lastColour.r     = r;
         lastColour.g     = g;
@@ -942,7 +957,7 @@ void QtPLWidget::setGradient( int x1, int x2, int y1, int y2,
             b[i], (int) ( alpha[i] * 255 ) ) );
     }
     ( *el.Data.LinearGradient ).setStops( stops );
-    m_listBuffer.append( el );
+    m_listBuffer.push_back( el );
 
     // No need to ask for a redraw at this point. The gradient only
     // affects subsequent items.
@@ -967,7 +982,7 @@ void QtPLWidget::setBackgroundColor( int r, int g, int b, double alpha )
     {
         clearBuffer();
     }
-    m_listBuffer.append( el );
+    m_listBuffer.push_back( el );
     redrawFromLastFlush = true;
 }
 
@@ -976,7 +991,7 @@ void QtPLWidget::setWidthF( PLFLT w )
     BufferElement el;
     el.Element       = SET_WIDTH;
     el.Data.fltParam = w;
-    m_listBuffer.append( el );
+    m_listBuffer.push_back( el );
 //     redrawFromLastFlush=true;
 }
 
@@ -1034,7 +1049,7 @@ void QtPLWidget::drawText( EscText* txt )
     el.Data.TextStruct->len   = txt->unicode_array_len;
     el.Data.TextStruct->chrht = pls->chrht;
 
-    m_listBuffer.append( el );
+    m_listBuffer.push_back( el );
     redrawFromLastFlush = true;
 }
 
@@ -1050,7 +1065,7 @@ void QtPLWidget::renderText( QPainter* p, struct TextStruct_* s, double x_fact,
     p->setClipRect( QRectF( s->clipxmin * x_fact + x_offset, s->clipymax * y_fact + y_offset, ( s->clipxmax - s->clipxmin ) * x_fact, ( -s->clipymax + s->clipymin ) * y_fact ), Qt::ReplaceClip );
     p->translate( s->x * x_fact + x_offset, s->y * y_fact + y_offset );
     QMatrix rotShearMatrix( cos( s->rotation ) * s->stride, -sin( s->rotation ) * s->stride, cos( s->rotation ) * sin( s->shear ) + sin( s->rotation ) * cos( s->shear ), -sin( s->rotation ) * sin( s->shear ) + cos( s->rotation ) * cos( s->shear ), 0., 0. );
-    p->setWorldMatrix( rotShearMatrix, true );
+    p->setWorldTransform( QTransform  (rotShearMatrix), true );
 
     p->translate( -s->just * xOffset * p->device()->logicalDpiY() / picDpi, 0. );
 
@@ -1315,7 +1330,7 @@ void QtPLWidget::paintEvent( QPaintEvent * )
         // Re-initialise pens etc.
         resetPensAndBrushes( painter );
 
-        start_iterator = m_listBuffer.constBegin();
+        start_iterator = m_listBuffer.cbegin();
 
         // Draw the plot
         doPlot( painter, x_fact, y_fact, x_offset, y_offset );
@@ -1379,7 +1394,7 @@ void QtPLWidget::doPlot( QPainter* p, double x_fact, double y_fact, double x_off
     }
 
     // unrolls the buffer and draws each element accordingly
-    for ( QLinkedList<BufferElement>::const_iterator i = start_iterator; i != m_listBuffer.constEnd(); ++i )
+    for ( std::list<BufferElement>::const_iterator i = start_iterator; i != m_listBuffer.cend(); ++i )
     {
         switch ( i->Element )
         {
@@ -1497,7 +1512,7 @@ void QtPLWidget::doPlot( QPainter* p, double x_fact, double y_fact, double x_off
         }
     }
 
-    start_iterator = m_listBuffer.constEnd();
+    start_iterator = m_listBuffer.cend();
     --start_iterator;
     redrawFromLastFlush = false;
     redrawAll           = false;
diff --git a/include/qt.h b/include/qt.h
index cde88af09..5ee858cc6 100644
--- a/include/qt.h
+++ b/include/qt.h
@@ -58,7 +58,7 @@
 #include <iostream>
 #include <QImage>
 #include <QPainter>
-#include <QLinkedList>
+#include <list>
 #include <QPrinter>
 #include <QApplication>
 #include <QWidget>
@@ -356,7 +356,7 @@ protected:
     double m_dAspectRatio;                       // Is kept constant during resizes
     QPixmap * m_pixPixmap;                       // stores the drawn image as long as it does not have to be regenerated
 
-    QLinkedList<BufferElement> m_listBuffer;     // Buffer holding the draw instructions
+    std::list<BufferElement> m_listBuffer;     // Buffer holding the draw instructions
 //         bool m_bAwaitingRedraw;
 //         int m_iOldSize; // Holds the size of the buffer. Modified => image has to be redrawn
     bool redrawFromLastFlush;
@@ -369,7 +369,7 @@ protected:
     QBrush SolidBrush;
     // end parameters
 
-    QLinkedList<BufferElement>::const_iterator start_iterator;
+    std::list<BufferElement>::const_iterator start_iterator;
 
     struct
     {
-- 
2.26.2

_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to