GenerateCurve.qml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import QtQuick 2.11
  2. Item {
  3. id:root
  4. Loader{
  5. id:loader
  6. x:100
  7. y:100
  8. }
  9. function show(axisxMin,axisxMax,axisyMin,axisyMax,modelData,title,name){
  10. loader.sourceComponent = undefined
  11. loader.sourceComponent = componet
  12. loader.item.axisxMin = axisxMin
  13. if(axisxMax > 1)
  14. loader.item.axisxMax = axisxMax-1
  15. else
  16. loader.item.axisxMax = axisxMax
  17. loader.item.axisyMin = axisyMin
  18. loader.item.axisyMax = axisyMax
  19. loader.item.setData(modelData)
  20. loader.item.title = title
  21. loader.item.name = name
  22. }
  23. function exit(){
  24. loader.sourceComponent =undefined
  25. }
  26. Component{
  27. id:componet
  28. Item {
  29. id:item
  30. width: 800
  31. height: 500
  32. property alias axisxMin : curveDisplay.axisxMin
  33. property alias axisxMax : curveDisplay.axisxMax
  34. property alias axisyMin : curveDisplay.axisyMin
  35. property alias axisyMax : curveDisplay.axisyMax
  36. property alias title: titleText.text
  37. property alias name :curveDisplay.name
  38. property var modelData
  39. function setData(modelData){
  40. var pointList=[]
  41. for(var i=0; i<modelData.count;i++){
  42. var obj = modelData.get(i)
  43. var point = Qt.point(i, obj.pressure)
  44. pointList.push(point)
  45. }
  46. dataSource.update(curveDisplay.charView.series(0),pointList)
  47. // timer.start()
  48. }
  49. // Timer{
  50. // id:timer
  51. // repeat: false
  52. // interval: 100
  53. // onTriggered: {
  54. // curveDisplayItem.grabToImage(function(result) {
  55. // result.saveToFile(titleText.text+".jpg");
  56. // });
  57. // }
  58. // }
  59. Rectangle{
  60. id:body
  61. anchors.fill: parent
  62. border.color: "black"
  63. border.width: 1
  64. Rectangle{
  65. id:title
  66. x:1
  67. y:1
  68. width: parent.width-2
  69. height: 30
  70. color: "#DDDDDD"
  71. Text {
  72. id: titleText
  73. text: qsTr("压力记录表")
  74. anchors.centerIn: parent
  75. font.bold: true
  76. font.pixelSize: 13
  77. }
  78. Image {
  79. width: 30
  80. height: 30
  81. source: "qrc:/img/close.png"
  82. anchors.right: parent.right
  83. MouseArea{
  84. anchors.fill: parent
  85. onClicked: {
  86. root.exit()
  87. }
  88. }
  89. }
  90. MouseArea{
  91. anchors.fill: parent
  92. drag.target: item
  93. drag.axis: Drag.XAndYAxis
  94. propagateComposedEvents:true
  95. }
  96. }
  97. Rectangle {
  98. id:curveDisplayItem
  99. anchors.top: title.bottom
  100. x:1
  101. width: parent.width-2
  102. height: parent.height-title.height-2
  103. color: "white"
  104. CurveDisplay{
  105. id:curveDisplay
  106. anchors.verticalCenter: parent.verticalCenter
  107. width: parent.width//-20
  108. height: parent.height//-50
  109. }
  110. }
  111. }
  112. }
  113. }
  114. }