当前位置: 首页 > news >正文

基于cornerstone3D的dicom影像浏览器 第二十八章 LabelTool文字标记,L标记,R标记及标记样式设置

文章目录

  • 前言
  • 一、L标记、R标记
  • 二、修改工具样式
    • 1. 样式的四种级别
    • 2. 导入annotation
    • 3. 示例1 - 修改toolGroup中的样式
    • 4. 示例2 - 修改viewport中的样式
  • 三、可配置样式


前言

cornerstone3D 中的文字标记工具LabelTool,在添加文字标记时会弹出对话框让用户输入文字,所以可以添加任意文字。
本章通过设置LabelTool的getTextCallback函数,使用户可以直接添加指定的文字,不再弹出输入文字的对话框,从而实现L标记,R标记。
另外介绍标记工具的样式设置方法,以改变工具的颜色、文字等。
效果如下:
在这里插入图片描述


一、L标记、R标记

toolGroup调用setToolConfiguration函数,设置LabelTool工具的getTextCallback为自定义函数。

activeLabelTool(type) {toolGroup.setToolActive(type, {[{ mouseButton: MouseBindings.Primary }]});if (type==="Label-L" || type==="Label-R") {const text = type.split("-")[1];toolGroup.setToolConfiguration(LabelTool.toolName,{getTextCallback: fn => {return fn(text);},});} else if (type==="Label") {// 恢复LabelTool默认回调函数toolGroup.setToolConfiguration(LabelTool.toolName,{getTextCallback: fn => {return fn(prompt("Enter your annotation:"));}});}
}

二、修改工具样式

1. 样式的四种级别

cornerstone3D 中提供四种级别的标注样式修改方法:

  1. 单个标注样式(需提供annotationUID),优先级最高:set/getAnnotationToolStyle
  2. viewport中所有标注样式,优先级次之:set/getViewportToolStyle
  3. toolGroup中所有标注样式,优先级又次之:set/getToolGroupToolStyle
  4. 默认所有标注样式,优先级最低:set/getDefaultToolStyle

每种级别中又可指定设置单个Tool的样式或所有Tool的样式,如:

annotation.config.style.setToolGroupToolStyles(toolGroupId, { // 修改LabelTool字体[LabelTool.toolName]: { textBoxFontSize: "28px" } // 修改LengthTool字体[Length.toolName]: { textBoxFontSize: "20px" }// 修改toolGroup中所有Tool字体global: { textBoxFontSize: "12px" }}
);

2. 导入annotation

import * as cornerstoneTools from "@cornerstonejs/tools";const {annotation
} = cornerstoneTools;

3. 示例1 - 修改toolGroup中的样式

function initTools() {...// 操作cornerstoneTools.addTool(WindowLevelTool);cornerstoneTools.addTool(PanTool);cornerstoneTools.addTool(ZoomTool);cornerstoneTools.addTool(StackScrollTool);...// 修改toolGroup中的样式annotation.config.style.setToolGroupToolStyles(toolGroupId, { // 修改LabelTool字体[LabelTool.toolName]: { textBoxFontSize: "28px" },// 修改LengthTool字体[LengthTool.toolName]: { textBoxFontSize: "20px" },// 修改toolGroup中所有Tool字体global: { textBoxFontSize: "12px" }});
}

效果:
在这里插入图片描述

4. 示例2 - 修改viewport中的样式


function setVieportToolStyles(viewportId) {annotation.config.style.setViewportToolStyles(viewportId, {// 修改LabelTool字体[LabelTool.toolName]: { textBoxFontSize: "60px" },// 修改viewport中所有Tool字体global: { textBoxFontSize: "8px" }});
}

效果:
在这里插入图片描述

三、可配置样式

color;  
colorActive;  
colorHighlighted;  
colorHighlightedActive;  
colorHighlightedPassive;  
colorLocked;  
colorLockedActive;  
colorLockedPassive;  
colorPassive;  
colorSelected;  
colorSelectedActive;  
colorSelectedPassive;  
lineDash;  
lineDashActive;  
lineDashHighlighted;  
lineDashHighlightedActive;  
lineDashHighlightedPassive;  
lineDashLocked;  
lineDashLockedActive;  
lineDashLockedPassive;  
lineDashPassive;  
lineDashSelected;  
lineDashSelectedActive;  
lineDashSelectedPassive;  
lineWidth;  
lineWidthActive;  
lineWidthHighlighted;  
lineWidthHighlightedActive;  
lineWidthHighlightedPassive;  
lineWidthLocked;  
lineWidthLockedActive;  
lineWidthLockedPassive;  
lineWidthPassive;  
lineWidthSelected;  
lineWidthSelectedActive;  
lineWidthSelectedPassive;  
textBoxBackground;  
textBoxBackgroundActive;  
textBoxBackgroundHighlighted;  
textBoxBackgroundHighlightedActive;  
textBoxBackgroundHighlightedPassive;  
textBoxBackgroundLocked;  
textBoxBackgroundLockedActive;  
textBoxBackgroundLockedPassive;  
textBoxBackgroundPassive;  
textBoxBackgroundSelected;  
textBoxBackgroundSelectedActive;  
textBoxBackgroundSelectedPassive;  
textBoxColor;  
textBoxColorActive;  
textBoxColorHighlighted;  
textBoxColorHighlightedActive;  
textBoxColorHighlightedPassive;  
textBoxColorLocked;  
textBoxColorLockedActive;  
textBoxColorLockedPassive;  
textBoxColorPassive;  
textBoxColorSelected;  
textBoxColorSelectedActive;  
textBoxColorSelectedPassive;  
textBoxFontFamily;  
textBoxFontFamilyActive;  
textBoxFontFamilyHighlighted;  
textBoxFontFamilyHighlightedActive;  
textBoxFontFamilyHighlightedPassive;  
textBoxFontFamilyLocked;  
textBoxFontFamilyLockedActive;  
textBoxFontFamilyLockedPassive;  
textBoxFontFamilyPassive;  
textBoxFontFamilySelected;  
textBoxFontFamilySelectedActive;  
textBoxFontFamilySelectedPassive;  
textBoxFontSize;  
textBoxFontSizeActive;  
textBoxFontSizeHighlighted;  
textBoxFontSizeHighlightedActive;  
textBoxFontSizeHighlightedPassive;  
textBoxFontSizeLocked;  
textBoxFontSizeLockedActive;  
textBoxFontSizeLockedPassive;  
textBoxFontSizePassive;  
textBoxFontSizeSelected;  
textBoxFontSizeSelectedActive;  
textBoxFontSizeSelectedPassive;  
textBoxLinkLineDash;  
textBoxLinkLineDashActive;  
textBoxLinkLineDashHighlighted;  
textBoxLinkLineDashHighlightedActive;  
textBoxLinkLineDashHighlightedPassive;  
textBoxLinkLineDashLocked;  
textBoxLinkLineDashLockedActive;  
textBoxLinkLineDashLockedPassive;  
textBoxLinkLineDashPassive;  
textBoxLinkLineDashSelected;  
textBoxLinkLineDashSelectedActive;  
textBoxLinkLineDashSelectedPassive;  
textBoxLinkLineWidth;  
textBoxLinkLineWidthActive;  
textBoxLinkLineWidthHighlighted;  
textBoxLinkLineWidthHighlightedActive;  
textBoxLinkLineWidthHighlightedPassive;  
textBoxLinkLineWidthLocked;  
textBoxLinkLineWidthLockedActive;  
textBoxLinkLineWidthLockedPassive;  
textBoxLinkLineWidthPassive;  
textBoxLinkLineWidthSelected;  
textBoxLinkLineWidthSelectedActive;  
textBoxLinkLineWidthSelectedPassive;  
http://www.lqws.cn/news/144775.html

相关文章:

  • AMFCNN-RKD:齿轮故障诊断的轻量级多传感器融合模型详解(python代码复现)
  • STM32 NVIC中断控制器
  • 鸿蒙APP测试实战:从HDC命令到专项测试
  • XHR / Fetch / Axios 请求的取消请求与请求重试
  • 【Linux】网络--数据链路层--以太网
  • 4.2 HarmonyOS NEXT分布式AI应用实践:联邦学习、跨设备协作与个性化推荐实战
  • Elasticsearch:spring2.x集成elasticsearch8.x
  • CB/T 3361-2019 甲板敷料检测
  • HarmonyOS:Counter计数器组件
  • 免费工具-微软Bing Video Creator
  • 塑料回收新突破!Nature 重磅:2 小时解聚碳纤维废料
  • 【推荐算法】WideDeep推荐模型:融合记忆与泛化的智能推荐引擎
  • 【Linux】POSIX信号量
  • 第20讲、Odoo 18 翻译机制与 PO 文件详解
  • YOLOv8 × VisDrone 全流程实战:训练你的无人机识别模型 AI(第一部分:数据集准备)
  • 鸿蒙缺少WMIC missing WMIC
  • 《C++ 模板》
  • 仓库自动化搬运:自动叉车与AGV选型要点及核心技术解析
  • MyBatis之测试添加功能
  • 18650锂电池组点焊机:高效组装锂电池的关键工具|比斯特自动化
  • XDMA pcie环路测试
  • Oracle 的 SEC_CASE_SENSITIVE_LOGON 参数
  • 代码中文抽取工具并替换工具(以ts为例)
  • 在 CentOS 上将 Ansible 项目推送到 GitHub 的完整指南
  • 高效线程安全的单例模式:Python 中的懒加载与自定义初始化参数
  • [论文阅读] 人工智能+软件工程 | MemFL:给大模型装上“项目记忆”,让软件故障定位又快又准
  • [pdf、epub]300道《软件方法》强化自测题业务建模需求分析共257页(202505更新)
  • 机器学习监督学习实战四:九种回归算法对波士顿房价数据进行回归预测和评估方法可视化
  • 【从0-1的CSS】第1篇:CSS简介,选择器已经常用样式
  • centos部署k8s v1.33版本