Results 1 to 3 of 3

Thread: Bug in QwtLinearColorMap (as I think)

  1. #1
    Join Date
    Nov 2019
    Posts
    31
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Bug in QwtLinearColorMap (as I think)

    Hi,

    I'm working with QwtLinearColorMap and I'm making interactive colorbar editor where I can interactively addColorStop.
    Let suppose the simplest case where I have only two points in colormap: 0 and 1 (min and max values).
    Then I change the color at position 1 (to RED).
    I do:
    Qt Code:
    1. QwtLinearColorMap* colorMap0 = (QwtLinearColorMap*)colorBarWidget->colorMap();
    2. QColor color1 = colorMap0->color1();
    3. QColor color2 = colorMap0->color2();
    4. QwtLinearColorMap* colorMap1 = new QwtLinearColorMap( color1, color2, QwtColorMap::RGB );
    5. colorMap1->addColorStop(1, RED_color);
    6. colorBarWidget->setColorMap(QwtInterval(-100, 100), colorMap1);
    7. colorBarWidget->setColorBarEnabled(true);
    To copy to clipboard, switch view to plain text mode 
    After that the color of colorbar at position = 1 doesn't change but at the same time I can colorMap1->colorStops() returns me a vector of three components (I can see it in Qt debugger):
    1. first component at a position 0;
    2. second component at a position 1 with oldcolor;
    3. third component at a position 1 with new color.

    Also when I type QColor color = colorMap1->color(QwtInterval(0, 1), 1); I get the new color as I want.

    Interesting thing is this happens only with point at pos = 1. At position = 0 it works fine.

    I work with addColorStop but as can see there is unfortunately no something like removeColorStop method. So when I iteractively change color I create new colormap and there is no way to remove points from this colormap (as I can see).

    Now I can solve my problem if I perform the color change code twice: first time colorMap1 has three colorstops (0, 1, 1) and one of them with old color, then I repeat it and colorMap1 has also three points (0, 1, 1) two of them with new color.

    Best regards

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

    Default Re: Bug in QwtLinearColorMap (as I think)

    Quote Originally Posted by Vasya View Post
    So when I iteractively change color I create new colormap and there is no way to remove points from this colormap (as I can see).
    It makes sense to have 2 stops at the same position. F.e if you want to have blue for [0.2-0.3] and green for ]0.3-0.4] you need to set 2 stops at 0.3.
    Having 2 stops at 0.0 or 1.0 does of course not make much sense, but this is not handled by the implementation.

    And you are right there is no obvious way to remove or replace color stop ( please add a ticket at https://sourceforge.net/projects/qwt ).

    But for the moment: can you edit the vector you get from QwtLinearColorMap::colorStops() and create/assign a new QwtLinearColorMap from the edited vector ?

    Uwe

  3. The following user says thank you to Uwe for this useful post:

    Vasya (15th March 2020)

  4. #3
    Join Date
    Nov 2019
    Posts
    31
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Bug in QwtLinearColorMap (as I think)

    Thank you for the hint. Now after I prepared a vector for colors and for colorstops I could optimize the code.
    And yes, I agree that to have multiple colors at the same colorstop it is a good idea. Ceating possibility to remove colorstops and colors would ease the coding and debugging process.
    I added a ticket at sourceforge.

    Best regards

Similar Threads

  1. Replies: 2
    Last Post: 15th January 2011, 07:07

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.