Results 1 to 7 of 7

Thread: Twisted Letters in Vertical Axis Title

  1. #1
    Join Date
    Aug 2010
    Posts
    12
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Twisted Letters in Vertical Axis Title

    Qwt makes plots just fine on the monitor, but when asked to save to an image file using QwtPlot;;print(QPainter, ...) it fails to rotate the letters in the vertical scale's text.

    As a hack to investigate, I added code to write the labels for the tic marks at an angle. Note that for these too, the on-screen rendering is fine but the print( ) version shows the letters untransformed. The screen rendering doesn't use print(). How it does work, I'm not entirely sure, just that it has a completely different path of execution.

    The app I'm working on is very complex, with code in hundreds of classes, messy multiple inheritance, too few comments and poor naming non-conventions. Somehow QwtPlot;;print() has a different idea about font angles than whatever normally does the drawing. Even after several months working on this source code, I've never found anyplace where angles are mentioned regarding fonts for vertical (or horizontal) axes.

    Could this be a bug in QwtPlot;;print( )? Are there any properties of QwtPlot or some object connected to it that needs to be given some parameter? Advice for nailing this bug?

    (note: by ;; I eally mean two colons. This online editor wants to convert double colons to a smileyface. Don't know how to disable this.)

    I'm using Qt4.3.4, qwt 5.1.1 on a Red Hat 5 machine running KDE 3.5.4. Several users with different systems see the same bad vertical scale rendering.

    As drawn on screen, coming out fine:


    As drawn to a .png file using print() (and also, why is it gray? Our app does not say anywhere to change the color):

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Twisted Letters in Vertical Axis Title

    Post some ( compilable ) code and I will run it on my system, to check what is going on.

    Uwe

  3. #3
    Join Date
    Aug 2010
    Posts
    12
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Twisted Letters in Vertical Axis Title

    I'd have to write a small demo app from scratch, and somehow hope to find the same problem. Whittling down the real app would be impossible - hundreds of classes depending on each others' internals, macaroni code etc. A small demo may take a few days.

  4. #4
    Join Date
    Aug 2010
    Posts
    12
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Twisted Letters in Vertical Axis Title

    Here's a short demo using qwt that writes a .png image. On screen, the vertical axis is okay, but the .png image shows the letters failed to rotate 90 deg.

    Qt Code:
    1. /* ------ myplot.hpp ------ */
    2. #ifndef myplot_hpp
    3. #define myplot_hpp
    4.  
    5. #include <qwt/qwt.h>
    6. #include <qwt/qwt_plot.h>
    7.  
    8. class MyPlot : public QwtPlot
    9. {
    10. Q_OBJECT
    11.  
    12. public:
    13.  
    14. MyPlot();
    15.  
    16. void setup_details_1();
    17. };
    18.  
    19.  
    20. #endif
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. /* ------ myplot.cpp ------ */
    2.  
    3. #include "myplot.hpp"
    4.  
    5. MyPlot::MyPlot()
    6. {
    7. }
    8.  
    9.  
    10. void MyPlot::setup_details_1()
    11. {
    12. setTitle("Dizziness of Millisecond Pulsars");
    13. setAxisTitle(QwtPlot::xBottom, "whizzyness");
    14. setAxisTitle(QwtPlot::yLeft, "wooziness");
    15. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. /* ------ qwtdemo2.hpp ------ */
    2. #include <QtGui>
    3. #include <QWidget>
    4. #include "myplot.hpp"
    5.  
    6. class MyMainWindow : public QWidget
    7. {
    8. Q_OBJECT
    9.  
    10. public:
    11. MyMainWindow(QWidget *parent=0);
    12. ~MyMainWindow();
    13.  
    14. void createcontents();
    15.  
    16. public slots:
    17. void printmyplot();
    18.  
    19. private:
    20. QPushButton *print_button;
    21. QPushButton *quit_button;
    22. public:
    23. MyPlot* myplot;
    24. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. /* ------ qwtdemo2.cpp ------ */
    2. /*
    3. simple demo using qwt
    4. "print" button writes a .png file
    5. see if vert scale text has unturned letters
    6. */
    7.  
    8. #include <QtGui>
    9. #include <QWidget>
    10. #include <stdio.h>
    11. #include <unistd.h>
    12.  
    13. #include "myplot.hpp"
    14. #include "qwtdemo2.hpp"
    15.  
    16. MyMainWindow::~MyMainWindow() {}
    17.  
    18. MyMainWindow::MyMainWindow(QWidget *parent)
    19. : QWidget(parent), print_button(0), quit_button(0), myplot(0)
    20. {
    21. resize(500,500);
    22. setWindowTitle("QWT Simple Demo #1");
    23. }
    24.  
    25.  
    26. void MyMainWindow::createcontents()
    27. {
    28. print_button = new QPushButton("print", this);
    29. quit_button = new QPushButton("quit", this);
    30. myplot = new MyPlot;
    31.  
    32. QHBoxLayout *bottomrow = new QHBoxLayout;
    33. bottomrow->addWidget(print_button);
    34. bottomrow->addWidget(quit_button);
    35.  
    36. QVBoxLayout *mainlayout = new QVBoxLayout;
    37. mainlayout->addWidget(myplot);
    38. mainlayout->addLayout(bottomrow); // use setLayout()?
    39. setLayout(mainlayout);
    40.  
    41. connect(quit_button, SIGNAL(clicked()),
    42. this, SLOT(close()));
    43. connect(print_button, SIGNAL(clicked()),
    44. this, SLOT(printmyplot()));
    45. }
    46.  
    47.  
    48. void MyMainWindow::printmyplot()
    49. {
    50. QImage image(500,500, QImage::Format_ARGB32);
    51. QPainter painter(&image);
    52. QRect rect(0,0, 500,500);
    53. myplot->print(&painter, rect);
    54. printf("aobut to save ");
    55. image.save("000.png", "PNG", 1);
    56. printf("return from ::printmyplot \n");
    57. }
    58.  
    59.  
    60. int main(int nargs, char** args)
    61. {
    62. QApplication app(nargs, args);
    63.  
    64. MyMainWindow *mainwindow = new MyMainWindow;
    65. mainwindow->createcontents();
    66. mainwindow->myplot->setup_details_1();
    67. mainwindow->show();
    68. return app.exec();
    69. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. # .pro file to build qwtdemo2
    2. TEMPLATE = app
    3. TARGET =
    4. DEPENDPATH += .
    5. INCLUDEPATH += .
    6. INCLUDEPATH += $(QWT)/include
    7. LIBS += -lqwt
    8. HEADERS += myplot.hpp qwtdemo2.hpp
    9. SOURCES += myplot.cpp qwtdemo2.cpp
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Twisted Letters in Vertical Axis Title

    Quote Originally Posted by DrunkenUFOPilot View Post
    Here's a short demo using qwt that writes a .png image. On screen, the vertical axis is okay, but the .png image shows the letters failed to rotate 90 deg.
    Not here ( Qt 4.7.1, Qwt 5.2 Linux/X11 ).

    Your code does absolutely nothing special - so expect to find the source of the problem in your environment. The first candidate you should look for is your Qt version - Qt 4.3 is really too old. Another thing you should check is if it depends somehow on the font.

    Qwt rotates the transformation matrix and then paints the title with a single QPainter::drawText. An effect where each letter is rotated individually can only be caused by a layer below.

    Uwe

    PS: Consider to use a scalable vector graphics format like PDF, what is much better format than using raster graphics.

  6. #6
    Join Date
    Aug 2010
    Posts
    12
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Twisted Letters in Vertical Axis Title

    Quote Originally Posted by Uwe View Post
    PS: Consider to use a scalable vector graphics format like PDF,
    I didn't think to mention it in the original question, but PDF (and .ps) files do look fine. For now, we can tell users to just make a PDF and then print that however they like.

    Yeah, Qt 4.3.4 is old, and we have other issues unresolved that would go away with a newer Qt. Someday...

  7. #7
    Join Date
    Jan 2012
    Location
    San Diego, California
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Twisted Letters in Vertical Axis Title

    Follow-up for anyone who stumbles into this thread. Yes, the problem went away with an update of Qt4 version.

    (Note: I am DrunkeUFOPilot with new shorter user name darenw)

Similar Threads

  1. QregExp: matching accented letters
    By bred in forum Qt Programming
    Replies: 0
    Last Post: 4th January 2011, 11:48
  2. QwtPlot Change Axis Title Alignment
    By deepy in forum Qwt
    Replies: 5
    Last Post: 20th October 2010, 14:40
  3. A collection of letters and numbers
    By NewLegend in forum Qt Programming
    Replies: 8
    Last Post: 8th September 2010, 20:44
  4. Replies: 0
    Last Post: 9th August 2010, 11:46
  5. Set axis title on the right side
    By pospiech in forum Qwt
    Replies: 1
    Last Post: 14th March 2008, 08:26

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.