Results 1 to 14 of 14

Thread: How to make the x-Bottom scale fixed.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2008
    Posts
    52
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question How to make the x-Bottom scale fixed.

    Hi friends i have a problem with my Plotting program. I have a db in which i save the data i have acquired. Initially the db is empty with no values. I need to have a fixed time scale from 0 to 60 seconds. Now once i click the start acquisition button i have to start acquiring data from a external device and save it to the DB and plot it. Its real time plotting. so i have to plot as i acquire the data. But the x-bottom scale changes according to the amount of data present in the db.
    example - If i have only 4 values acquired to the DB the scale is changed to [0 to 3]. It looks like the image i have attached named (3).

    If have say 40 values are added to the db the scale is changed to 35. It looks like the image i have attached named (35)

    I actually wanted the scale to stay fixed to 60 and the graph to grow from the initial value as the data keeps adding in the graph has to grow gradually.Some thing like the snapshot (60) i have attached.

    what do i need to do so that the x-bottom scale is fixed and the data to be plotted with out changing the scale irrespective of the amount of data present in the DB like in the image named (60).


    Thank You
    Please looking forward for a reply.
    Attached Images Attached Images

  2. #2
    Join Date
    Mar 2008
    Posts
    52
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to make the x-Bottom scale fixed.

    Hi friends how do i fix the the x-bottom size of a qwt plot widget.
    Qt Code:
    1. myPlot->setTitle("Data Acquisition");
    2. myPlot->setAxisTitle(QwtPlot::xBottom, "System time");
    3. myPlot->setAxisScale(QwtPlot::xBottom, 0, 60);
    4. myPlot->setAxisTitle(QwtPlot::yLeft, "Bar");
    5. myPlot->setAxisScale(QwtPlot::yLeft, 0, 100);
    6. myPlot->setAutoReplot(true);
    To copy to clipboard, switch view to plain text mode 

    I am using the above code to set the x-bottom scale from 0 to 60. But when i click the start plotting button the bottom scale is changed according to the number of values present in the db. I wanted the scale to stay at 0 to 60 only and the graph to plot according to the number of values present in the db.I am able to retrive data from the db every second but my only problem is the scale which changes i want it to be fixed. How can i do that. ??


    Thank You

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

    Default Re: How to make the x-Bottom scale fixed.

    The code above is already what you need to do. Obviously someone else is also changing the scale or re-enables autoscaling.

    Uwe

  4. #4
    Join Date
    Mar 2008
    Posts
    52
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question Problem Solved.

    Hi uwe problem solved. Thank You for the reply.

    In my plot function i had this
    Qt Code:
    1. curve->setPen(QPen(Qt::red));
    2. //myPlot->setAxisScale(QwtPlot::xBottom, m_vx[0], m_vx[m_vx.count() - 1]);
    To copy to clipboard, switch view to plain text mode 

    Just commented the second line and Bingo. !! But once the graph reaches the x-bottom point 60. I wanted the graph to be cleared and the next graph which again starts with 0 to be started fresh again. I have the data in the db in this format ..
    Qt Code:
    1. TIME DATA
    2. 0 21
    3. 1 24
    4. 2 28
    5. 3 20
    6. . .
    7. . .
    8. . .
    9. 60 24
    10. 0 22
    11. 1 31
    12. 2 26
    13. 3 23
    14. 4 19
    15. . .
    16. . .
    17. . .
    18. 60 27
    To copy to clipboard, switch view to plain text mode 
    Time keeps repeating from 0 to 60 so once the graph is plotted from 0 to 60 it has to be cleared and the graph has to start again from next 0 to 60 and so on. I am not able to figure out how to clear the graph which is displayed on the screen once it reaches 60.Because of this once the graph reaches 60 weird things happen. How should i clear the graph from the screen uwe. ?

    Thank You

  5. #5
    Join Date
    Mar 2008
    Posts
    52
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation Clearing Plot. ??

    Hi uwe i used the clear slot to clear the plot on a button clicked.
    Qt Code:
    1. void graphplotting::on_pushButton_clicked()
    2. {
    3. myPlot->clear();
    4. }
    To copy to clipboard, switch view to plain text mode 

    But i get a exception error. I tried so much but i still get the same error.
    where am i going wrong uwe. !!!


    Thank You
    Attached Images Attached Images

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Clearing Plot. ??

    Such error appears when you try to access unallocated memory.

    When you invoke QwtPlot::clear() it deletes all attached curves, so this error might appear if you access "curve" after push button has been clicked.
    Last edited by jacek; 7th June 2008 at 00:57. Reason: typo

  7. #7
    Join Date
    Mar 2008
    Posts
    52
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to make the x-Bottom scale fixed.

    Hi jacek I have looked so much for an example which shows how to clear plots. But cud't find any. I have been tryin since yeste with this problem but cud't slove it. Pls tell me what i have to do to clear this error.



    Thank You

  8. #8
    Join Date
    Mar 2008
    Posts
    52
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to make the x-Bottom scale fixed.

    Hi some one pls give me an example to clear( ) a plot . I don't find any on the net. !!!


    Thank You

  9. #9
    Join Date
    Mar 2008
    Posts
    52
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question myPlot->Clear() not yet solved. !!!

    Hi every one,

    I tried so much , I tried the qwt example realtime_plot example in which there is a clear function . Into my program but still i get a exception. Some one pls help me i am really stuck at this place past 2 dazz. !! Tried all the things i cud.But no o/p . Give me a example or tell me how to use the qwtPlot->clear(); in the program.


    Thank You

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: myPlot->Clear() not yet solved. !!!

    Where do you use "curve" varaible?

  11. #11
    Join Date
    Mar 2008
    Posts
    52
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question Re:Referesh Graph . ?

    Hello jacek Thankx for the reply, I solved my problem .
    Qt Code:
    1. void RS232_Receive::retrive()
    2. {
    3. {
    4. m_curve = new QwtPlotCurve("myPlot");
    5. myPlot->clear();
    6. myPlot->replot();
    7. //draw();
    8. }
    9. draw();
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

    I did this but once i clear the curve i wanted to call the draw function so that the next values is plotted from start after the present graph is cleared from the screen. But i am not getting it, the new curve is not plotted. !! Where am i going wrong .

    Thank You jacek

Similar Threads

  1. Replies: 7
    Last Post: 15th November 2007, 17:19
  2. How to make headers fixed sized? (QTableWidget)
    By macias in forum Qt Programming
    Replies: 4
    Last Post: 13th August 2007, 15:57
  3. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 05:57

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
  •  
Qt is a trademark of The Qt Company.