Results 1 to 7 of 7

Thread: Scales alignment

  1. #1
    Join Date
    Dec 2007
    Posts
    119
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Scales alignment

    Hi,
    I have to dynamically align plot x-axis scale (so on, all plot) according to a slider scale, so that min/max scale values are vertically aligned (with respect to x display coordinates) such as in the following picture.
    (i.e. plot min/max scale values have to change when I resize the slider by code).

    align.PNG

    Do you have some idea how to reach this task? How can I get slider min/max scale values x position? Than, how can I set plot min/max scale values x position?

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

    Default Re: Scales alignment

    Because of the layout concept implemented in QwtPlot It would be easier to align the scale of the slider.

    Uwe

  3. #3
    Join Date
    Dec 2007
    Posts
    119
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Scales alignment

    Quote Originally Posted by Uwe View Post
    Because of the layout concept implemented in QwtPlot It would be easier to align the scale of the slider.

    Uwe
    Unfortunately I have other homemade chronograms in the same layout which its scales have to be aligned to the slider scale (.i.e. a time line slider) so this one is the master over other scales...Afterword, how I can change the plot scale in order to change its x-axis min/max?

  4. #4
    Join Date
    Dec 2007
    Posts
    119
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Smile Re: Scales alignment

    Changing the point of view...trying to align the scale of the slider, first of all I want to set a fixed size about the plot y-axis (i.e. y-scale-widget width) regardless of y-data inserted, how can I do this? scale widget extent is the number of pixel needed to represent the digits (documentation isn't so clear)?

    sorry but I'm a newbie of qwt

  5. #5
    Join Date
    Dec 2007
    Posts
    119
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Scales alignment

    Ok...I've implemented my new plot widget containing a standard qwtplot and a custom YScaleWidget with a fixed size connected through like suggest in another post.
    This is my result:
    plot.jpg

    All works fine is I don't show e.g. x-bottom axis and plot title...my YScaleWidget height is the height of all qwtplot even if I use the plot->canvas()->geometry(), in order to find the right height of the canvas, inside the resizeEvent function of the container widget. I try to send a signal juast after the updateLayout is called with same result...why?

  6. #6
    Join Date
    Dec 2007
    Posts
    119
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Scales alignment

    Solved...I created a custom layout inherited from QLayout, something like a QHBoxLayout where the Y scalewidget height is perfectly alligned to the Plot Y-Axis.

  7. #7
    Join Date
    Dec 2007
    Posts
    119
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Scales alignment

    last questions:

    1. Why are little different Plot1 vs Plot2 (with Y-Axis sclae widget disabled) regarding Y-Axis behaviour of plot canvas data painting?

    Attachment 6916Attachment 6917

    2. If Y left Scale Widget is enabled setting canvas margin (e.g. plot->plotLayout()->setCanvasMargin(20, QwtPlot::xTop)) has effect on plot canvas data painting, besides if Y left Scale Widget is disabled setting canvas margin hasn't effect, why?

    Below the code used to implement setGeometry of my custom layout (PlotLayout):

    void MyPlotWidget::PlotLayout::setGeometry(const QRect &rect)
    {
    QLayout::setGeometry(rect);
    if (myItemList.size() == 0)
    return;

    int w = rect.width() - (myItemList.count() - 1) * spacing();
    int h = rect.height() - (myItemList.count() - 1) * spacing();

    int scaleWidgetWidth = 0;
    QLayoutItem * itemScaleWidget = NULL;
    QLayoutItem * itemPlot = NULL;
    for (int i=0; i<myItemList.size(); i++)
    {
    if (!itemScaleWidget && dynamic_cast<QwtScaleWidget *>(myItemList.at(i)->widget()))
    {
    itemScaleWidget = myItemList.at(i);
    scaleWidgetWidth = myItemList.at(i)->geometry().width();
    }
    else if (dynamic_cast<QwtPlot *>(myItemList.at(i)->widget()))
    {
    itemPlot = myItemList.at(i);
    itemPlot->setGeometry(QRect(rect.x() + scaleWidgetWidth + i * spacing(), rect.y() + i * spacing(), w - scaleWidgetWidth, h));
    }
    }

    if (itemScaleWidget && itemPlot && dynamic_cast<QwtPlot *>(itemPlot->widget()))
    {
    QwtPlot * plot = dynamic_cast<QwtPlot *>(itemPlot->widget());
    QRect scaleRect = itemScaleWidget->geometry();
    QRect canvasRect = plot->plotLayout()->canvasRect();
    QRect canvasRect2 = plot->canvas()->rect();
    QRect canvasContRect2 = plot->canvas()->contentsRect();
    int fw = plot->canvas()->frameWidth();
    int marginTop = 0;
    int marginBottom = 0;

    if(!plot->plotLayout()->alignCanvasToScales ())
    {
    marginTop = plot->plotLayout()->canvasMargin(QwtPlot::xTop);
    marginBottom = plot->plotLayout()->canvasMargin(QwtPlot::xBottom);
    }
    scaleRect.setTop(canvasRect.top() + fw + marginTop - plot->axisWidget(QwtPlot::yLeft)->startBorderDist());
    scaleRect.setBottom(canvasRect.bottom() - fw - marginBottom - 1 + plot->axisWidget(QwtPlot::yLeft)->startBorderDist());

    itemScaleWidget->setGeometry(scaleRect);
    }
    }

Similar Threads

  1. logarithmic scales
    By sergio486 in forum Qwt
    Replies: 2
    Last Post: 22nd December 2010, 17:05
  2. Replies: 0
    Last Post: 1st January 2009, 18:47
  3. fixed axis scales
    By oskarmellow in forum Qwt
    Replies: 1
    Last Post: 17th December 2008, 06:20
  4. Equal scales
    By sukram in forum Qwt
    Replies: 1
    Last Post: 22nd July 2008, 07:44
  5. Problem with scales
    By fear in forum Qwt
    Replies: 2
    Last Post: 5th May 2008, 22:18

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.