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

基于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.xdnf.cn/news/12038.html

相关文章:

  • 企业培训学习考试系统源码 ThinkPHP框架+Uniapp支持多终端适配部署
  • python训练营打卡第45天
  • python学习day39
  • Linux环境-通过命令查看zookeeper注册的服务
  • 网页前端开发(基础进阶4--axios)
  • 用 NGINX 构建高效 SMTP 代理`ngx_mail_smtp_module`
  • 软件上线前为什么要做性能测试?
  • 深度解析ArrayList
  • 05.字母异位词分组
  • AI赋能国风艺术:穿越时空的诗词画卷如何诞生?
  • Numpy——通用函数、向量化、基础的统计计算
  • Comparable和Comparator
  • React-native实战系列
  • 每日算法-250604
  • Sui Prover:将形式化验证引入 Sui
  • yFiles:专业级图可视化终极解决方案
  • 2025年6月4日第一轮
  • Unity大型项目资源框架
  • 运行labelme
  • 【C/C++】析构函数好玩的用法:~Derived() override
  • day44python打卡
  • AI 基础应用与提示词工程
  • 深入理解计算机进制:从原理到 C++ 实现
  • WireShark相关技巧
  • 根据重叠点云生成匹配图像之间的对应点对
  • 【二分图 图论】P9384 [THUPC 2023 决赛] 着色|普及+
  • AI数字人软件开发:赋能企业数字化转型,打造智能服务新标杆
  • c#压缩与解压缩-SharpCompress
  • MySQL EXPLAIN 命令详解
  • 为什么选择电商平台API接口服务商?