From 8ce1e752d8f1ecfa8978fc6b3a20fa232b0aa265 Mon Sep 17 00:00:00 2001 From: Caisking Date: Thu, 19 Jun 2025 14:37:31 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E6=A8=A1=E6=8B=9F=E6=95=B0?= =?utf8?q?=E6=8D=AE=E4=BB=A5=E5=8F=8A=E6=A8=A1=E6=8B=9F=E5=8A=A8=E6=80=81?= =?utf8?q?=E6=9B=B2=E7=BA=BF=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../include/detection/BPDetectBeginView.h | 6 +- .../nativeui/bloodpressure/src/BPModel.cpp | 2 +- .../src/detection/BPDetectBeginView.cpp | 77 +++++++++++++++++-- .../src/detection/BPDetectFirstView.cpp | 4 +- 4 files changed, 79 insertions(+), 10 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/detection/BPDetectBeginView.h b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/detection/BPDetectBeginView.h index 5c130bfdd..3952a6b54 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/detection/BPDetectBeginView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/detection/BPDetectBeginView.h @@ -23,7 +23,7 @@ namespace OHOS bool AddButton(); bool InitLable(); bool Initbackground(); - + void InitChartView(); void UpdateTimeText(int data); @@ -36,6 +36,10 @@ namespace OHOS UILabelExt *timeLabel = nullptr; UILabel*timenumLabel = nullptr; + Point testData[100]; + UIChartDataSerial *dataSerial{nullptr}; + UIChartPolyline *datachart = nullptr; + UIViewGroup *group{nullptr}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPModel.cpp index 6c37bc605..94d45d433 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPModel.cpp @@ -192,7 +192,7 @@ static uint16 CalibrationFlag = 0; // 倒计时 Time--; // 提前检查无效时间 - if (Time <= 0) + if (Time < 0) { BPModel::GetInstance()->BP_StopTimer(); BPModel::GetInstance()->BP_SetState(BPState::BP_NORMAL); diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectBeginView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectBeginView.cpp index f5368f2c0..4b8d4a0f6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectBeginView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectBeginView.cpp @@ -69,19 +69,81 @@ namespace OHOS delete timenumLabel; timenumLabel = nullptr; } + if(dataSerial != nullptr) + { + datachart->ClearDataSerial(); + delete dataSerial; + dataSerial = nullptr; + } + if(datachart != nullptr) + { + delete datachart; + datachart = nullptr; + } } delete group; group = nullptr; } /* -------------------------------------------------------------------------- */ - //倒计时更新时间文本 - void BPDetectBeginView::UpdateTimeText(int data) - { - if(timenumLabel != nullptr && data >= 0 && data <= BP_CHECK_TIME_MAX) - { + // 倒计时更新时间文本 + void BPDetectBeginView::UpdateTimeText(int data) { + if (timenumLabel != nullptr && data >= 0 && data <= BP_CHECK_TIME_MAX) { timenumLabel->SetText(std::to_string(data).c_str()); } + // 生成正常血压范围(60~200)的随机数更新数据 + for (int i = 0; i < 100; i++) { + testData[i].y = rand() % (210 - 60) + 60; + } + + // 更新图表数据 + if (datachart && dataSerial) { + dataSerial->ClearData(); + dataSerial->AddPoints(testData, 100); + datachart->AddDataSerial(dataSerial); + RootView::GetInstance()->Invalidate(); + } + } + + + void BPDetectBeginView::InitChartView() + { + /* + 测试数据 100条 + */ + for (int i = 0; i < 100; i++) { + testData[i].x = i; + testData[i].y = 100; + } + + //初始化图表控件 + if (datachart == nullptr) { + datachart = new UIChartPolyline(); + } + datachart->SetPosition(56, 105); + datachart->Resize(317, 136); + datachart->SetViewId("uiChart"); + datachart->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + //设置坐标轴为透明 + UIXAxis& uiChartXAxis = datachart->GetXAxis(); + UIYAxis& uiChartYAxis = datachart->GetYAxis(); + uiChartXAxis.SetMarkNum(100); + uiChartXAxis.SetDataRange(0, 100); + uiChartXAxis.SetLineColor(Color::GetColorFromRGBA(0x00, 0x00, 0x00, 0x00)); + uiChartYAxis.SetMarkNum(5); + uiChartYAxis.SetDataRange(60, 210); + uiChartYAxis.SetLineColor(Color::GetColorFromRGBA(0x00, 0x00, 0x00, 0x00)); + + //设置数据曲线 + dataSerial = new UIChartDataSerial(); + dataSerial->SetMaxDataCount(100); + dataSerial->AddPoints(testData, 100); + dataSerial->SetFillColor(Color::GetColorFromRGBA(0x0b, 0xe4, 0x43, 0xff)); + dataSerial->SetLineColor(Color::GetColorFromRGBA(0xf1, 0x0a, 0x0a, 0xff)); + dataSerial->EnableGradient(false); + datachart->AddDataSerial(dataSerial); + datachart->SetGradientOpacity(0, 0); } /* -------------------------------------------------------------------------- */ /*** @@ -99,10 +161,13 @@ namespace OHOS InitUILabel(timenumLabel, 133, 300, 200, 200, "timenumLabel", "30", DEFAULT_VECTOR_FONT_FILENAME, 100); + InitChartView(); + group->Add(calibrationLabel); group->Add(remindLabel); group->Add(timeLabel); group->Add(timenumLabel); + group->Add(datachart); return true; } @@ -117,7 +182,7 @@ namespace OHOS background->SetSrc(BPBACKPATH); lineground = new UIImageView(); - lineground->SetPosition(49, 95, 356, 161); + lineground->SetPosition(55, 95, 356, 161); lineground->SetSrc(BPLINEPATH); group->Add(background); diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectFirstView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectFirstView.cpp index 5b2d1aee9..ed95293af 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectFirstView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectFirstView.cpp @@ -134,8 +134,8 @@ namespace OHOS if (bpchart == nullptr) { bpchart = new UIChartPolyline(); } - bpchart->SetPosition(59, 203); - bpchart->Resize(315, 150); + bpchart->SetPosition(56, 205); + bpchart->Resize(317, 136); bpchart->SetViewId("uiChart"); bpchart->SetStyle(STYLE_BACKGROUND_OPA, 0x00); -- 2.17.1