ReportPicture.qml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import QtQuick 2.11
  2. Rectangle {
  3. id:root
  4. z:-1
  5. width:900
  6. height:460
  7. color: "white"
  8. visible: false
  9. property string fileName
  10. property int delayms:300
  11. property real m_maxY: 0.0
  12. property real m_minY: 0.0
  13. // property var pointList:[]
  14. function generatePicture(filename, dataArray){
  15. var current_step = 0
  16. for(var i=0; i<dataArray.length;i++){
  17. m_maxY = (m_maxY < dataArray[i].pressure)? dataArray[i].pressure:m_maxY
  18. m_minY = (m_minY > dataArray[i].pressure)? dataArray[i].pressure:m_minY
  19. //console.log("dataArray ",i,dataArray[i])
  20. }
  21. curveDisplay_pic.spline.clear()
  22. curveDisplay_pic.scatter_clear()
  23. //m_minY = (m_minY-2) < 0? 0:(m_minY-2)
  24. //m_maxY = m_maxY+2
  25. console.log("generatePicture dataArray.length:"+dataArray.length)
  26. curveDisplay_pic.setRange_Y(m_minY-1.0, m_maxY+1.0)
  27. curveDisplay_pic.setRange_X(0, dataArray.length-1)
  28. for(var j=0; j<dataArray.length; j++){
  29. curveDisplay_pic.spline.append(j,dataArray[j].pressure)
  30. if(current_step !== dataArray[j].step){
  31. if(2 == current_step ){
  32. curveDisplay_pic.scatter_add(j, dataArray[j].pressure)
  33. console.log("generatePicture keep end j:"+j)
  34. }
  35. current_step = dataArray[j].step
  36. if(2 == current_step ){
  37. curveDisplay_pic.scatter_add(j, dataArray[j].pressure)
  38. console.log("generatePicture keep begin j:"+j)
  39. }
  40. }
  41. }
  42. //dataSource.update(curveDisplay.charView.series(0),root.pointList)
  43. root.fileName = "D:/tmp/"+filename +".jpg"
  44. timer.start()
  45. }
  46. Timer{
  47. id:timer
  48. repeat: false
  49. interval: delayms
  50. onTriggered: {
  51. root.grabToImage(function(result) {
  52. result.saveToFile(root.fileName);
  53. });
  54. }
  55. }
  56. CurveDisplay{
  57. id:curveDisplay_pic
  58. anchors.fill: parent
  59. name: "横轴时间(秒) 纵轴压力(kPa)"
  60. }
  61. }