123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- import 'dart:convert';
- import 'package:fis_i18n/i18n.dart';
- import 'package:fis_measure/interfaces/process/workspace/application.dart';
- import 'package:fis_measure/view/paint/ai_patint_controller.dart';
- import 'package:fis_measure/view/paint/date_structure.dart';
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- /// AI诊断结果
- class ResultInfo extends StatefulWidget {
- final List<AIDetectedObject> aiDetectedObject;
- const ResultInfo(this.aiDetectedObject, {Key? key}) : super(key: key);
- @override
- State<ResultInfo> createState() => _ResultInfoState();
- }
- class _ResultInfoState extends State<ResultInfo> {
- late final aiPatintController = Get.find<AiPatintController>();
- late AIDetectedObject aiDetectedObjectItem;
- late double unitsPhysicalPixels;
- late final application = Get.find<IApplication>();
- @override
- void initState() {
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- final description = widget
- .aiDetectedObject[aiPatintController.state.aiResultIndex].descriptions;
- late final descriptions = (description?.length ?? 0) > 1
- ? jsonDecode(description?[description.length - 1].value ?? '')
- : '';
- unitsPhysicalPixels =
- (application.visuals[0].visualAreas[0].viewport?.region.width)! /
- (application.frameData!.width).toDouble();
- return Container(
- decoration: BoxDecoration(
- border: Border.all(
- color: Colors.grey,
- ),
- borderRadius: BorderRadius.circular(4),
- color: Colors.transparent,
- ),
- padding: const EdgeInsets.only(bottom: 10),
- child: Column(
- children: [
- Row(
- mainAxisSize: MainAxisSize.max,
- children: [
- Expanded(
- child: Container(
- decoration: const BoxDecoration(
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(4),
- topRight: Radius.circular(4),
- ),
- color: Color.fromRGBO(54, 169, 206, 1),
- ),
- padding: const EdgeInsets.only(
- top: 4,
- bottom: 10,
- left: 8,
- right: 8,
- ),
- child: const Text(
- 'AI诊断结果',
- style: TextStyle(
- color: Colors.white,
- ),
- ),
- ),
- )
- ],
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Container(
- padding: const EdgeInsets.only(
- left: 10,
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.start,
- children: [
- _buildTitle(
- i18nBook.measure.diseaseLabels.t,
- _buildAITitle(),
- ),
- if (descriptions != '' && descriptions != null)
- _buildTitle(
- i18nBook.measure.isLesionSize.t,
- _buildLesionSize(
- descriptions?['HorizontalLengthInPixel'] ?? 0,
- descriptions?['VerticalLengthInPixel'] ?? 0,
- unitsPhysicalPixels,
- ),
- )
- ],
- ),
- ),
- Container(
- margin: const EdgeInsets.symmetric(
- vertical: 15,
- ),
- child: SizedBox(
- width: 70,
- height: 70,
- child: Stack(
- children: [
- SizedBox(
- width: 70,
- height: 70,
- child: Obx(() {
- final aiDetected = widget.aiDetectedObject[
- aiPatintController.state.aiResultIndex];
- return CircularProgressIndicator(
- valueColor: AlwaysStoppedAnimation(
- _buildAITextColor(
- aiDetected.label,
- ),
- ),
- backgroundColor: Colors.grey,
- value: aiDetected.confidence,
- );
- }),
- ),
- Center(
- child: SizedBox(
- width: 45,
- height: 45,
- child: Obx(() {
- final confidence = widget
- .aiDetectedObject[
- aiPatintController.state.aiResultIndex]
- .confidence;
- return Text(
- i18nBook.measure.possibility.t +
- '${(confidence * 100).toStringAsFixed(1)}%',
- style: const TextStyle(
- color: Colors.white,
- ),
- );
- }),
- ),
- ),
- ],
- ),
- ),
- ),
- ],
- ),
- ],
- ),
- );
- }
- Widget _buildLesionSize(
- int horizontalLengthInPixel,
- int verticalLengthInPixel,
- double unitsPhysicalPixels,
- ) {
- return Text(
- (horizontalLengthInPixel * unitsPhysicalPixels)
- .toStringAsFixed(2)
- .toString() +
- 'cm x' +
- (verticalLengthInPixel * unitsPhysicalPixels)
- .toStringAsFixed(2)
- .toString() +
- 'cm',
- style: const TextStyle(color: Colors.white),
- );
- }
- Widget _buildTitle(String label, Widget value) {
- return Column(
- mainAxisSize: MainAxisSize.max,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- label,
- style: const TextStyle(
- color: Color.fromRGBO(54, 169, 206, 1),
- ),
- ),
- value,
- const SizedBox(
- height: 5,
- ),
- ],
- );
- }
- Color _buildAITextColor(int label) {
- switch (label) {
- case 0:
- return Colors.lightBlue;
- case 1:
- case 2:
- case 3:
- return Colors.greenAccent;
- default:
- return Colors.redAccent;
- }
- }
- Widget _buildAITitle() {
- switch (aiPatintController.diagnosisOrgan) {
- case DiagnosisOrganEnum.Breast:
- return Obx(() {
- aiDetectedObjectItem =
- widget.aiDetectedObject[aiPatintController.state.aiResultIndex];
- return _buildBreastDescription(aiDetectedObjectItem.label);
- });
- case DiagnosisOrganEnum.Liver:
- return Obx(() {
- aiDetectedObjectItem =
- widget.aiDetectedObject[aiPatintController.state.aiResultIndex];
- return _buildLiverDescription(aiDetectedObjectItem.label);
- });
- default:
- return const SizedBox();
- }
- }
- Widget _buildBreastDescription(int label) {
- switch (label) {
- case 0:
- return _buildDescription(
- i18nBook.measure.noSignificantAbnormalitiesWereSeen.t);
- case 1:
- return _buildDescription(i18nBook.measure.lipoma.t);
- case 2:
- return _buildDescription('BI-RADS 2');
- case 3:
- return _buildDescription('BI-RADS 3');
- case 4:
- return _buildDescription('BI-RADS 4a');
- case 5:
- return _buildDescription('BI-RADS 4b');
- case 6:
- return _buildDescription('BI-RADS 4c');
- case 7:
- return _buildDescription('BI-RADS 5');
- case 8:
- return _buildDescription(
- i18nBook.measure.noSignificantAbnormalitiesWereSeen.t);
- default:
- return _buildDescription(null);
- }
- }
- Widget _buildLiverDescription(int label) {
- switch (label) {
- case 0:
- return _buildDescription(
- i18nBook.measure.noSignificantAbnormalitiesWereSeen.t);
- case 1:
- return _buildDescription(i18nBook.measure.intrahepaticStrongEchoFoci.t);
- case 2:
- return _buildDescription(i18nBook.measure.hepaticHemangioma.t);
- case 3:
- return _buildDescription(i18nBook.measure.liverCysts.t);
- case 4:
- return _buildDescription(i18nBook.measure.liverCancerMayOccur.t);
- case 5:
- return _buildDescription(i18nBook.measure.fattyLiver.t);
- case 6:
- return _buildDescription(
- i18nBook.measure.panisodicChangesLiverDiffuseLesions.t);
- case 7:
- return _buildDescription(i18nBook.measure.cirrhosis.t);
- case 8:
- return _buildDescription(i18nBook.measure.polycysticLiver.t);
- default:
- return _buildDescription(null);
- }
- }
- Widget _buildDescription(
- String? title,
- ) {
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- if (title != null) ...[
- const SizedBox(
- height: 5,
- ),
- Text(
- title,
- style: const TextStyle(color: Colors.white),
- ),
- ],
- ],
- );
- }
- }
|