Results 1 to 3 of 3

Thread: how to fill Qlist in minimum time

  1. #1
    Join Date
    Dec 2012
    Posts
    45
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default how to fill Qlist in minimum time

    hello every one, i am new to Qt,
    I am trying to draw sound wave plot in sea water, for that i need a large no of points. So i used QList as i dont know how many points will be generated by the mathematical equation that i am using.
    here is my code

    Qt Code:
    1. for(int j = 1 ; j < number_of_rays ; j++)
    2. {
    3. // int a = Incident_angles.at(j-1) + Angle_Difference;
    4. Incident_angles.insert(j, Incident_angles.at(j-1) + Angle_Difference);
    5. //qDebug() << "InCIDENT ANGLE = " << Incident_angles.at(j);
    6. }
    7.  
    8. for (int j = 0; j < number_of_rays; j++)
    9. {
    10. SRP_X_Cordinate.clear();
    11. SRP_Y_Cordinate.clear();
    12.  
    13. int factor = -1;
    14. counter = 0;
    15. SRP_X_Cordinate.insert(0,0);
    16. SRP_Y_Cordinate.insert(0,source_depth);
    17.  
    18. Actual_Incident_Angle = Incident_angles.at(j);
    19. //qDebug() << "InCIDENT ANGLE = " << Incident_angles.at(j);
    20. if (Incident_angles.at(j) > 90)
    21. {
    22. factor = -factor;
    23. Actual_Incident_Angle = 180 - Incident_angles.at(j);
    24. //qDebug() << "Actual_Incident_Angle" << Actual_Incident_Angle;
    25. }
    26.  
    27. if (SRP_Y_Cordinate.at(0) > 0)
    28. {
    29. if (Incident_angles.at(j)!= 90)
    30. {
    31. Theta_1 = Actual_Incident_Angle*pi/180;
    32.  
    33. SRP_X_Cordinate.append(( SRP_X_Cordinate.at(counter) + difference_depth*tan(Theta_1)));
    34. SRP_Y_Cordinate.append((SRP_Y_Cordinate.at(counter) + factor*difference_depth));
    35. //qDebug() << "Inside not equal to 90";
    36. double C1 = Calculate_velocity(SRP_Y_Cordinate.at(counter));// + factor*0.001);
    37. double C2 = Calculate_velocity(SRP_Y_Cordinate.at(counter+1));// + factor*0.001);
    38.  
    39. double t = Temp_Time + (sqrt(pow((SRP_X_Cordinate.at(counter) - SRP_X_Cordinate.at(counter+1)),2) + pow((SRP_Y_Cordinate.at(counter) - SRP_Y_Cordinate.at(counter+1)),2)))/C1;
    40.  
    41. Ray_Time.insert(counter, t);
    42. Temp_Time = Ray_Time.at(counter);
    43.  
    44. Theta_2 = Calculate_Angle(C1, C2, Theta_1);
    45.  
    46. counter = counter + 1;
    47.  
    48. while( SRP_X_Cordinate.at(counter) < max_range)
    49. {
    50. qDebug()<<"Theta_1 = "<< Theta_1;
    51. qDebug()<<"Theta_2 = "<< Theta_2;
    52. qDebug()<<"C1 = "<< C1;
    53. qDebug()<<"C2 = "<< C2;
    54. if(Theta_2 < (pi/2 - 0.001))
    55. {
    56. Theta_1 = Theta_2;
    57. SRP_Y_Cordinate.append((SRP_Y_Cordinate.at(counter) + factor*difference_depth));
    58. SRP_X_Cordinate.append((counter+1, SRP_X_Cordinate.at(counter) + difference_depth*tan(Theta_1)));
    59.  
    60. if( SRP_Y_Cordinate.at(counter+1) > 0.001 && SRP_Y_Cordinate.at(counter+1) < max_depth)
    61. {
    62. //qDebug()<<"SRP_X_Cordinate.at(counter) theta<90- - .01 = "<< SRP_Y_Cordinate.at(counter);
    63. C1 = C2;
    64. C2 = Calculate_velocity(SRP_Y_Cordinate.at(counter+1));// + factor*0.001);
    65. Ray_Time.insert(counter, Temp_Time + (sqrt(pow((SRP_X_Cordinate.at(counter) - SRP_X_Cordinate.at(counter+1)),2) + pow((SRP_Y_Cordinate.at(counter) - SRP_Y_Cordinate.at(counter+1)),2)))/C1);
    66. Temp_Time = Ray_Time.at(counter);
    67. Theta_2 = Calculate_Angle(C1, C2, Theta_1);
    68. }
    69.  
    70. else
    71. {
    72. //qDebug()<<"SRP_X_Cordinate.at(counter) theta<90- - .01 else cond = "<< SRP_Y_Cordinate.at(counter);
    73. Theta_2 = Theta_1;
    74. C2 = Calculate_velocity(SRP_Y_Cordinate.at(counter + 1));// + factor*0.001);
    75. factor = - factor;
    76. Ray_Time.insert(counter, Temp_Time + (sqrt(pow((SRP_X_Cordinate.at(counter) - SRP_X_Cordinate.at(counter+1)),2) + pow((SRP_Y_Cordinate.at(counter) - SRP_Y_Cordinate.at(counter+1)),2)))/C2);
    77. }
    78. }
    79. else if(Theta_2 > (pi/2 + 0.0001))
    80. {
    81. qDebug()<<"SRP_X_Cordinate.at(counter) theta>90- - .01 = ";
    82. factor = - factor;
    83. Theta_1 = pi - Theta_2;
    84.  
    85. SRP_Y_Cordinate.append((SRP_Y_Cordinate.at(counter) + factor*difference_depth));
    86. SRP_X_Cordinate.append((SRP_X_Cordinate.at(counter) + difference_depth*tan(Theta_1)));
    87.  
    88. C1 = C2;
    89. C2 = Calculate_velocity(SRP_Y_Cordinate.at(counter+1));// + factor*0.001);
    90. Ray_Time.insert(counter, Temp_Time + (sqrt(pow((SRP_X_Cordinate.at(counter) - SRP_X_Cordinate.at(counter+1)),2) + pow((SRP_Y_Cordinate.at(counter) - SRP_Y_Cordinate.at(counter+1)),2)))/C1);
    91. Temp_Time = Ray_Time.at(counter);
    92.  
    93. Theta_2 = Calculate_Angle(C1, C2, Theta_1);
    94. }
    95.  
    96. else
    97. {
    98. factor = - factor;
    99. Theta_1 = 89*pi/180;
    100. //qDebug()<<"SRP_X_Cordinate.at(counter) theta<90- - .01 = else condition "<< SRP_Y_Cordinate.at(counter);
    101.  
    102. SRP_Y_Cordinate.append((SRP_Y_Cordinate.at(counter) + factor*difference_depth));
    103. SRP_X_Cordinate.append((SRP_X_Cordinate.at(counter) + difference_depth*tan(Theta_1)));
    104.  
    105. C1 = C2;
    106. C2 = Calculate_velocity(SRP_Y_Cordinate.at(counter+1));// + factor*0.001);
    107. Ray_Time.insert(counter, Temp_Time + (sqrt(pow((SRP_X_Cordinate.at(counter) - SRP_X_Cordinate.at(counter+1)),2) + pow((SRP_Y_Cordinate.at(counter) - SRP_Y_Cordinate.at(counter+1)),2)))/C1);
    108. Temp_Time = Ray_Time.at(counter);
    109.  
    110. Theta_2 = Calculate_Angle(C1, C2, Theta_1);
    111.  
    112. }
    113. // qDebug()<<"SRP_X_Cordinate.at(counter) theta<90- - .01 else cond = "<< SRP_Y_Cordinate.at(counter);
    114. counter = counter + 1;
    115. }
    116.  
    117. /* for( int r = 0; r< counter-1;r++)
    118.   {
    119.   Ray_Distance.insert(j, Ray_Distance.at(j) + sqrt(pow((SRP_X_Cordinate.at(r) - SRP_X_Cordinate.at(r+1)),2) + pow((SRP_Y_Cordinate.at(r) - SRP_Y_Cordinate.at(r+1)),2)));
    120.   }*/
    121. }
    122.  
    123. else
    124. {
    125. counter = 1;
    126. SRP_X_Cordinate.insert(1,max_range);
    127. SRP_Y_Cordinate.insert(1,source_depth);
    128. }
    129. }
    130.  
    131. SRP_2D_X_Cordinate.insert(j,SRP_X_Cordinate);
    132. SRP_2D_Y_Cordinate.insert(j,SRP_Y_Cordinate);
    133.  
    134. //qDebug()<<" counter "<< counter;
    135. Data_points.insert(j,counter);
    136. } /////////////////// END FOR /////////////////////////////////
    To copy to clipboard, switch view to plain text mode 
    this all i am doing on a button click and this is taking very long time
    Last edited by wysota; 26th August 2013 at 13:40.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: how to fill Qlist in minimum time

    Please edit your post and put your code between [code] [/code] tags.
    Then tell us what you expect us to do about it? There are a bunch of completely unknown functions, unknown numbers of loops, no idea what "a very long time", where you have measured the slow points to be, why you do this in a button click event is etc...

  3. #3
    Join Date
    Dec 2012
    Posts
    45
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: how to fill Qlist in minimum time

    M really sorry that i didnt gave the post in proper format. And thanks that you paid a heed to my problem but i sorted ot the problem , actually i am calculating large no of X and Y coordinates and storing them in list and then retriving these point to draw line in paint event . Its still complicated i have to disclose all my code thanks any way

Similar Threads

  1. Run time error related to QList
    By Channareddy in forum Newbie
    Replies: 2
    Last Post: 20th June 2011, 08:24
  2. Replies: 1
    Last Post: 9th May 2011, 16:19
  3. How to fill a QList<struct> ?
    By falconium in forum Newbie
    Replies: 1
    Last Post: 1st March 2011, 22:59
  4. Replies: 4
    Last Post: 20th August 2010, 14:54
  5. Minimum requirements for application
    By b1 in forum Qt Programming
    Replies: 8
    Last Post: 18th September 2006, 00:29

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.