Menu

Display scale

General
2010-11-08
2013-04-22
  • Aude Gueudry

    Aude Gueudry - 2010-11-08

    Hi,

    I plot a 3Dgrph and my scale is unreadable because numbers are at the end of long lines… I have take same code that in testnumpy.py  (http://pyqwt.sourceforge.net/pyqwt3d-examples.html) but I have a problem with the scale…

    Thank you very much if you can help me!

    Good week!
    Aude

     
  • sqqqrly

    sqqqrly - 2010-11-11

    I had this problem to.    i bet you are running Linux?

    One issue is that the courier font the lib uses does not exist but another close one is substituted instead.   For me this cause labels to not be redrawn properly.  Also the font ended up being longer than what the textbox would allow truncating the end.

    So, in Qwt3D::Label::Update(), I commented out the two lines "p.setFont( font_ );"    A default font that is available will be used instead so the text will fit.

    Also, in the part that erases the previous text, I changed it…simplified it really.  Instead of trying overwrite the old text with the background color, I just fill the whole QPixmap with the background color:

    I've pretty much forked svn trunk.    Am I wrong that this project's dev had died?    Also the trunk is missing the .pri file so qmake is broke.  I recreated one.

    void Label::update()
    {
      QPainter p;
      QFontMetrics fm(font_);
      QFontInfo info(font_);

      QRect r =   QRect(QPoint(0,0),fm.size(Qwt3D::SingleLine, text_));//fm.boundingRect(text_)  misbehaviour under linux;
      r.translate(0, -r.top());

      pm_ = QPixmap(r.width(), r.bottom());
      if (pm_.isNull()) // else crash under linux
      {
        r = QRect(QPoint(0,0),fm.size(Qwt3D::SingleLine, QString(" "))); // draw empty space else //todo
        r.translate(0, -r.top());
        pm_ = QPixmap(r.width(), r.bottom());  
      }
     
      QBitmap bm(pm_.width(),pm_.height());
      bm.fill(Qt::color0);
      p.begin( &bm );
        //p.setPen(Qt::color1);
        //p.setFont(font_);
        //p.drawText(0,r.height() - fm.descent() -1 , text_);
      p.end();

      clear();
     
      pm_.setMask(bm);
      p.begin( &pm_ );
        //p.setFont( font_ );
        p.setPen( Qt::SolidLine );
        p.setPen( GL2Qt(color.r, color.g, color.b) );
        p.drawText(0,r.height() - fm.descent() -1 , text_);
      p.end();
      buf_ = pm_.toImage();
      tex_ = QGLWidget::convertToGLFormat( buf_ );    // flipped 32bit RGBA ?  
    }

     
  • Boris Duran

    Boris Duran - 2010-11-12

    Hi sqqqrly,

    thanks for trying to solve this problem… I followed your instructions but with no success. First, I get an error because of the 'clear();', it tells me:

    src/qwt3d_label.cpp:131: error: ‘clear’ was not declared in this scope

    I commented that part just to see if commenting the other lines did something but I get the same weird labeling of before. I'll appreciate any other suggestion.

    Boris

    PS: I'm working on Ubuntu 10.4, Qt 4.7, qwt6.0.0-rc4

     
  • sqqqrly

    sqqqrly - 2010-11-15

    Hi Boris,

    Sorry, I omitted clear(). 

    void Label::clear()
    {
      pm_.fill();
      buf_ = pm_.toImage();
      tex_ = QGLWidget::convertToGLFormat( buf_ );    // flipped 32bit RGBA ?   
      GLboolean b;
      GLint func;
      GLdouble v;
      glGetBooleanv(GL_ALPHA_TEST, &b);
      glGetIntegerv(GL_ALPHA_TEST_FUNC, &func);
      glGetDoublev(GL_ALPHA_TEST_REF, &v);
      glEnable (GL_ALPHA_TEST);
      glAlphaFunc (GL_NOTEQUAL, 0.0);
      
      convert2screen();
      glRasterPos3d(beg_.x, beg_.y, beg_.z);
    
      int w = tex_.width();
      int h = tex_.height();
    
      if (1)//devicefonts_)
      {   
        drawDeviceText(QWT3DLOCAL8BIT(text_), "Courier", font_.pointSize(), pos_, color, anchor_, gap_);
      }
      else
      {
        drawDevicePixels(w, h, GL_RGBA, GL_UNSIGNED_BYTE, tex_.bits());
    //    glDrawPixels(w, h, GL_RGBA, GL_UNSIGNED_BYTE, tex_.bits()); 
      }
      glAlphaFunc(func,v);
      Enable(GL_ALPHA_TEST, b);
    }
    
     
  • sqqqrly

    sqqqrly - 2010-11-15

    I also had to tweak the Legend.  Same issue with fonts.  It does not line up the caption vertically, but its at least readable.

    These are all hacks.   

    To the developers:  TABS are evil.    They should never used!   :)

    ColorLegend::ColorLegend()
    {
        axis_.setNumbers(true);
        axis_.setScaling(true);
        axis_.setNumberColor(RGBA(0,0,0,1));
        axis_.setNumberAnchor(CenterRight);
        //axis_.setNumberFont(QFont("Courier",8));
        //caption_.setFont("Courier", 10, QFont::Bold);
        caption_.setColor(RGBA(0,0,0,1));
        axisposition_ = ColorLegend::Left;
        orientation_ = ColorLegend::BottomTop;
        showaxis_ = true;
        setRelPosition(Tuple(0.94, 1-0.36),Tuple(0.97, 1-0.04));
    }
    
     
  • sqqqrly

    sqqqrly - 2010-11-15

    Boris:   What is this qwt6.0.0-rc4 ?      I co'd trunk.

    -s

     
  • Boris Duran

    Boris Duran - 2010-11-16

    Hi sqqqrly,

    you are good my friend, it is working now… so thanks a lot for your help.
    I don't know if it is because of QwtPlot3D or because my implementation in Qt using QtBasicTimer but it is pretty slow. A student of mine is creating an opengl + Qt implementation of 3D plots for me and it is working a lot faster than QwtPlot3D… we'll see if I continue using these libraries.
    Qwt6.0.0-rc4 is the last release of Qwt, it is the original plotting libraries but for 2D. I was under the impression that QwtPlot3D build on Qwt but it seems I was wrong. Anyway, people in Qwt are still working on it in contrast to QwtPlot3D.
    Thanks again for your help,
    Boris

     
  • Michael Bieber

    Michael Bieber - 2010-11-16

    Maybe I should drop in here.

    > people in Qwt are still working on it in contrast to QwtPlot3D

    Not _quite_ true. I've provided months ago a rewrite of the last released version owr qwt3d (o.2.7) for some developers. It includes a multi-dataset plotting feature, making it possible to configure all the important attributes like colors etc. dataset-wise. It also should fix the once in a while mentioned font issue on Linux.

    Problem is, I never got an answer/opinion. Thats not to critisize people, life has changing priorities (true for me too). I got the impression, interest is quite low in general now, so this has affected me too. I have yet to mention, that I'm still using my library. So, if someone would show some more interest - not speaking about support yet - it is still welcome. I would check in the current version and maybe we could backport the font thing for the time being. Even some changes leading away from the old fixed-pipeline OpenGL would be something, I'm personally interested in.

    Michael

     
  • John Cummings

    John Cummings - 2010-11-17

    Problem is, I never got an answer/opinion. Thats not to critisize people, life has changing priorities (true for me too). I got the impression, interest is quite low in general now, so this has affected me too.

    It's funny you mention your code. Even before this message, I started late last  week looking over the current codebase.

    Since I instigated the multiple curve branch, I started there and I must say that I impressed with what Ion and Dave have done with the code. I especially like the elegance of Curve deriving from QObject.

    However, I haven't gotten to do more than compile your code, Micha. Well, I also ran the examples but I didn't look in depth at the code as yet.

    Finally, as I recall, Dave gave you some detailed feedback. I promised some but never delivered. My apologies. I will do better this time.

     
  • sqqqrly

    sqqqrly - 2010-11-17

    Hello Michael,

    This rewrite you speak of…    Is it checked in?  

    I hacked in some changes to get the fonts to work correctly (for me).   It seemed like this project had died and I was thinking of forking it.   I had sent you an email directly, but got no response. 

    So, in lieu of a fork, would you be open to someone working on this within the SF project? 

    1. I would first work on why the font issue appears.  I think it is just the specified font is not available on some Linux boxes and a substitution is made by Qt automatically.    It might be better to use a different font on Linux.  

    2. I would also love to remove all the TAB characters.  These are a major pain for me…and makes the code hard to read.

    3. One of the first things I would do is figure out how it works and add doxygen style commenting about what I learn. 

    4. My project needs a way of updating the plots from an external data source.   The data keeps being added to and I need to redraw the plot as this happens.   In my case, it is a vehicle's position in 3D space.     I haven't really looked at the current support for this yet.

    5. I started by modifying trunk.  Trunk is missing its pri file for qmake.  I created one.

    If this is not acceptable to you, I may have to fork, either using my own svn repo or something publicly available.  Id rather not squirrel away what I do.  And I hate writing code wo svn check ins.

    Ciao,
    -s

     
  • sqqqrly

    sqqqrly - 2010-11-17

    Boris,

    Glad I could help.   Care to share your other implementation?   I would love a look at it.    If you wish, please send me a copy at sqrlyguy @at@ yahoo .dot. com

    -s

     

Log in to post a comment.