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

VTK 标签中文

vtkCaptionActor2D可以创建带引线的标签,下载中文开源字库,通过设置字体文件实现中文显示。

字库链接:https://github.com/adobe-fonts/source-han-serif/tree/release#downloading-source-han-serif

int dumNote::CreateOrUpdateNote(vtkSmartPointer<vtkCaptionActor2D>  NoteActor,const char* Text, Standard_Real Location[3], int H,Standard_Real Notecolor[3], Standard_Real Backgroundcolor[3])
{
    
    NoteActor->SetCaption(dmuTools::CharToUtf8(Text));//文字
    //NoteActor->DragableOn();      //不能拖动
    NoteActor->SetAttachmentPoint(Location[0], Location[1], Location[2]);
    NoteActor->BorderOff();//无边框
    NoteActor->GetProperty()->SetColor(1,1, 1);
    NoteActor->GetProperty()->SetLineWidth(1.0);
    NoteActor->SetPosition(50*H, -50 );  // 左上角偏移
    //NoteActor->LeaderOff(); //有链接线
    std::string path = TZTEK::dmuTools::GetProgramDir();
    path = path + "\\dmu\\SourceHanSerifSC-VF.ttf";
    NoteActor->GetCaptionTextProperty()->SetVerticalJustificationToBottom();
    NoteActor->GetCaptionTextProperty()->SetFontSize(30);
    NoteActor->GetCaptionTextProperty()->SetFontFamily(VTK_FONT_FILE);
    NoteActor->GetCaptionTextProperty()->SetFontFile(path.c_str());//字库考虑动态位置
    NoteActor->GetCaptionTextProperty()->SetColor(Notecolor[0], Notecolor[1], Notecolor[2]);//文字颜色
    NoteActor->GetCaptionTextProperty()->SetBackgroundColor(Backgroundcolor[0], Backgroundcolor[1], Backgroundcolor[2]);
    NoteActor->GetCaptionTextProperty()->SetBackgroundOpacity(1);  // 设置背景透明度
    NoteActor->GetCaptionTextProperty()->BoldOn();
    NoteActor->GetCaptionTextProperty()->ShadowOff();//文字无阴影
    //NoteActor->GetCaptionTextProperty()->SetFrame(1);
    //NoteActor->GetCaptionTextProperty()->SetFrameWidth(30);
    NoteActor->SetPickable(0);
    NoteActor->SetVisibility(1);

    char* cCharUtf = dmuTools::CharToUtf8(Text);

    //NoteActor->SetCaption(cCharUtf);
    int size = strlen(cCharUtf);
    int num = 1;
    int max = 0;

    while (cCharUtf != NULL)
    {
        char* a = strstr((char*)cCharUtf, "\n");
        if (a != NULL)
        {
            size = strlen(cCharUtf);
            if (max < size - strlen(a))
                max = size - strlen(a);
            num++;
            cCharUtf = a + 1;
        }
        else
        {
            if (max < strlen(cCharUtf))
                max = strlen(cCharUtf);
            break;
        }
    }

    NoteActor->SetWidth(2*0.009 * max);
    NoteActor->SetHeight(2*0.025 * num);
    //double w = NoteActor->GetPosition2()[0];
    //double h = NoteActor->GetPosition2()[1];
    NoteActor->LeaderOn(); //有链接线
    return 0;

http://www.dtcms.com/a/325681.html

相关文章:

  • MFC C++ 使用ODBC方式调用Oracle数据库的详细步骤
  • Go 多进程编程-socket(套接字)
  • 今日项目之线程同步操作项目
  • 生成模型实战 | MuseGAN详解与实现
  • encoder-only / decoder-only / encoder-decoder架构分析
  • 云原生应用的DevOps2(Jenkins渗透场景)
  • Spring Boot 单元测试:@SpyBean 使用教程
  • Linux生成自签名 SSL 证书(适用于测试或内部使用)
  • CI/CD渗透测试靶场
  • cesium/resium 修改子模型材质
  • [Oracle] UNPIVOT 列转行
  • MySQL 数据操作全流程:创建、读取、更新与删除实战
  • openEuler、 CentOS、Ubuntu等 Linux 系统中,Docker 常用命令总结
  • FPGA+护理:跨学科发展的探索(一)
  • SAE J2716多协议网关的硬件架构与实时协议转换机制解析
  • 三种常见的菜单路由封装方式详解
  • rust编译过程的中间表现形式如何查看,ast,hir,mir
  • Rust学习笔记(一)|Rust初体验 猜数游戏
  • Excel 实战:基因表达矩阵前处理中测序符号的快速剥离方法
  • K210人脸识别系统
  • 在Linux中部署tomcat
  • 【Redis的安装与配置】
  • 如何理解Tomcat、Servlet、Catanalina的关系
  • 从零开始的云计算生活——第四十一天,勇攀高峰,Kubernetes模块之单Master集群部署
  • 微美全息(NASDAQ:WIMI)Raft携手节点动态评估:引领联盟链高性能共识新潮流
  • 为 Promethus 配置https访问
  • 机器学习 - Kaggle项目实践(1)Titanic
  • 揭开内容分发网络(CDN)的神秘面纱:互联网的隐形加速器
  • 飞翔的小鸟
  • 【数据结构入门】二叉树(1)