【VTK-Rendering::Core】第二期 vtkTextActor

很高兴在雪易的CSDN遇见你 

VTK技术爱好者 QQ:870202403


前言

本文以vtkTextActor为起点,分享VTK中Text相关的内容,希望对各位小伙伴有所帮助!

感谢各位小伙伴的点赞+关注,小易会继续努力分享,一起进步!

你的点赞就是我的动力(^U^)ノ~YO


目录

前言

1. vtkTextActor

1.1 SetInput设置输入

1.2 设置最小、最大尺寸

1.3 设置缩放模式

1.4 设置文本对齐位置

1.5 设置文本方向

1.6 设置文字属性

1.7 获取文字包围盒

1.8 设置约束的字体大小

1.9 启用非线性缩放字体大小

1.10 坐标转化方法

1.11 计算缩放字体比例

结论:


1. vtkTextActor

        用于展示文字的Actor,可以缩放,也可以不缩放。

         vtkTextActor可用于将文本注释放入窗口中。当TextScaleMode为NONE时,文本是固定字体,操作与vtkPolyDataMapper2D/vtkActor2D对相同。当TextScaleMode为VIEWPORT时,字体会调整大小,使其相对于呈现它的VIEWPORT保持一致的大小。当TextScaleMode为PROP时,字体会调整大小,使文本适合位置1和2坐标所定义的框。该类取代了已弃用的vtkScaledTextActor,并作为vtkTextMapper/vtkActor2D对的方便包装器。通过与此actor关联的vtkTextProperty设置文本属性/属性。其重要参数如下:

1.1 SetInput设置输入

  //@{
  /**
   * Set the text string to be displayed. "\n" is recognized
   * as a carriage return/linefeed (line separator).
   * The characters must be in the UTF-8 encoding.
   * Convenience method to the underlying mapper
   */
  void SetInput(const char* inputString);
  char* GetInput();
  //@}

1.2 设置最小、最大尺寸

  //@{
  /** 设置该Actor所占用的最小像素
   * Set/Get the minimum size in pixels for this actor.
   * Defaults to 10,10.
   * Only valid when TextScaleMode is PROP.
   */
  vtkSetVector2Macro(MinimumSize, int);
  vtkGetVector2Macro(MinimumSize, int);
  //@}

  //@{
  /**设置/获取文本行的最大高度,作为分配给它的垂直区域的百分比
   * 缩放文本actor。默认为1.0。
   * Set/Get the maximum height of a line of text as a
   * percentage of the vertical area allocated to this
   * scaled text actor. Defaults to 1.0.
   * Only valid when TextScaleMode is PROP.
   */
  vtkSetMacro(MaximumLineHeight, float);
  vtkGetMacro(MaximumLineHeight, float);
  //@}

1.3 设置缩放模式

  //@{
  /**
   * 设置文本的缩放方式。
   * 如果设置为vtkTextActor::TEXT_SCALE_MODE_NONE,字体大小将由TextProperty中给定的大小固定。
   * 如果设置为vtkTextActor::TEXT_SCALE_MODE_PROP,文本将被缩放到完全适合由位置1和2坐标指定的道具。
   * 如果设置为vtkTextActor::TEXT_SCALE_MODE_VIEWPORT,文本将根据显示的viewport的大小进行缩放。
   * Set how text should be scaled.  If set to
   * vtkTextActor::TEXT_SCALE_MODE_NONE, the font size will be fixed by the
   * size given in TextProperty.  If set to vtkTextActor::TEXT_SCALE_MODE_PROP,
   * the text will be scaled to fit exactly in the prop as specified by the
   * position 1 & 2 coordinates.  If set to
   * vtkTextActor::TEXT_SCALE_MODE_VIEWPORT, the text will be scaled based on
   * the size of the viewport it is displayed in.
   */
  vtkSetClampMacro(TextScaleMode, int, TEXT_SCALE_MODE_NONE, TEXT_SCALE_MODE_VIEWPORT);
  vtkGetMacro(TextScaleMode, int);
  void SetTextScaleModeToNone() { this->SetTextScaleMode(TEXT_SCALE_MODE_NONE); }
  void SetTextScaleModeToProp() { this->SetTextScaleMode(TEXT_SCALE_MODE_PROP); }
  void SetTextScaleModeToViewport() { this->SetTextScaleMode(TEXT_SCALE_MODE_VIEWPORT); }
  //@}

  enum
  {
    TEXT_SCALE_MODE_NONE = 0,
    TEXT_SCALE_MODE_PROP,
    TEXT_SCALE_MODE_VIEWPORT
  };

1.4 设置文本对齐位置

  //@{
  /**
   * Turn on or off the UseBorderAlign option.
   * When UseBorderAlign is on, the bounding rectangle is used to align the text,
   * which is the proper behavior when using vtkTextRepresentation
   */
  vtkSetMacro(UseBorderAlign, vtkTypeBool);
  vtkGetMacro(UseBorderAlign, vtkTypeBool);
  vtkBooleanMacro(UseBorderAlign, vtkTypeBool);
  //@}

  //@{
  /**
   * This method is being deprecated.  Use SetJustification and
   * SetVerticalJustification in text property instead.
   * Set/Get the Alignment point
   * if zero (default), the text aligns itself to the bottom left corner
   * (which is defined by the PositionCoordinate)
   * otherwise the text aligns itself to corner/midpoint or centre
   * @verbatim
   * 6   7   8
   * 3   4   5
   * 0   1   2
   * @endverbatim
   * This is the same as setting the TextProperty's justification.
   * Currently TextActor is not oriented around its AlignmentPoint.
   */
  void SetAlignmentPoint(int point);
  int GetAlignmentPoint();
  //@}

1.5 设置文本方向

  //@{
  /**
   * 围绕对齐点逆时针旋转。单位以度为单位,默认为0。
   * text属性中的方向旋转纹理图中的文本。它可能不会给你想要的效果。
   * Counterclockwise rotation around the Alignment point.
   * Units are in degrees and defaults to 0.
   * The orientation in the text property rotates the text in the
   * texture map.  It will proba ly not give you the effect you
   * desire.
   */
  void SetOrientation(float orientation);
  vtkGetMacro(Orientation, float);
  //@}

1.6 设置文字属性

  //@{
  /**
   * Set/Get the text property.
   */
  virtual void SetTextProperty(vtkTextProperty* p);
  vtkGetObjectMacro(TextProperty, vtkTextProperty);
  //@}

1.7 获取文字包围盒

  /**
   * Return the bounding box coordinates of the text in pixels.
   * The bbox array is populated with [ xmin, xmax, ymin, ymax ]
   * values in that order.
   */
  virtual void GetBoundingBox(vtkViewport* vport, double bbox[4]);

  /**
   * Syntactic sugar to get the size of text instead of the entire bounding box.
   */
  virtual void GetSize(vtkViewport* vport, double size[2]);

1.8 设置约束的字体大小

  //@{
  /**
   * 根据设置的目标矩形,计算并设置合适的字体大小。
   * 该方法的静态版本也可用于方便其他类(例如,小部件)。
   * Set and return the font size required to make this mapper fit in a given
   * target rectangle (width x height, in pixels). A static version of the
   * method is also available for convenience to other classes (e.g., widgets).
   */
  virtual int SetConstrainedFontSize(vtkViewport*, int targetWidth, int targetHeight);
  static int SetConstrainedFontSize(vtkTextActor*, vtkViewport*, int targetWidth, int targetHeight);
  //@}

  /**
   * 设置并返回使映射器数组的每个元素适合给定矩形(宽度x高度,以像素为单位)所需的字体大小。
   * 此字体大小是适合此约束中最大映射器所需的最小大小。
   * Set and return the font size required to make each element of an array
   * of mappers fit in a given rectangle (width x height, in pixels).  This
   * font size is the smallest size that was required to fit the largest
   * mapper in this constraint.
   */
  static int SetMultipleConstrainedFontSize(vtkViewport*, int targetWidth, int targetHeight,
    vtkTextActor** actors, int nbOfActors, int* maxResultingSize);

1.9 启用非线性缩放字体大小

  /**
   * 启用非线性缩放字体大小。这在与缩放文本结合使用时非常有用。
   * 对于小窗口,您希望使用整个缩放文本区域。
   * 对于较大的窗口,您需要将字体大小减小一些,以便不使用整个区域。
   * 这些值修改计算的字体大小如下:newFontSize = pow(FontSize,指数)*pow(目标,1.0 -指数)
   * 通常指 数应该在0.7左右,目标应该在10左右
   * Enable non-linear scaling of font sizes. This is useful in combination
   * with scaled text. With small windows you want to use the entire scaled
   * text area. With larger windows you want to reduce the font size some so
   * that the entire area is not used. These values modify the computed font
   * size as follows:
   * newFontSize = pow(FontSize,exponent)*pow(target,1.0 - exponent)
   * typically exponent should be around 0.7 and target should be around 10
   */
  virtual void SetNonLinearFontScale(double exponent, int target);

1.10 坐标转化方法

  /**这只是在渲染过程中使用的一种简单的坐标转换方法。
   * This is just a simple coordinate conversion method used in the render
   * process.
   */
  void SpecifiedToDisplay(double* pos, vtkViewport* vport, int specified);

  /**
   * This is just a simple coordinate conversion method used in the render
   * process.
   */
  void DisplayToSpecified(double* pos, vtkViewport* vport, int specified);

1.11 计算缩放字体比例

  /**
   * Compute the scale the font should be given the viewport.  The result
   * is placed in the ScaledTextProperty ivar.
   */
  virtual void ComputeScaledFont(vtkViewport* viewport);

  //@{
  /**
   * Get the scaled font.  Use ComputeScaledFont to set the scale for a given
   * viewport.
   */
  vtkGetObjectMacro(ScaledTextProperty, vtkTextProperty);
  //@}

  /**
   * Provide a font scaling based on a viewport.  This is the scaling factor
   * used when the TextScaleMode is set to VIEWPORT and has been made public for
   * other components to use.  This scaling assumes that the long dimension of
   * the viewport is meant to be 6 inches (a typical width of text in a paper)
   * and then resizes based on if that long dimension was 72 DPI.
   */
  static float GetFontScale(vtkViewport* viewport);

结论:

感谢各位小伙伴的点赞+关注,小易会继续努力分享,一起进步!

你的赞赏是我的最最最最大的动力(^U^)ノ~YO

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/287149.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

提升三维模型数据的几何坐标纠正速度效率具体技术方法

提升三维模型数据的几何坐标纠正速度效率具体技术方法 根据搜索结果,以下是提升倾斜摄影三维模型数据的几何坐标纠正和三维重建速度的具体技术方法: 1、增加控制点:通过增加控制点数量可以提高几何坐标精度。控制点是已知地面坐标的点&#…

儿童可以戴骨传导耳机吗?骨传导耳机对儿童有危害吗?

儿童是可以佩戴骨传导耳机的,相比于传统的入耳式蓝牙耳机,佩戴骨传导耳机要更健康一些。 首先骨传导耳机通过人体骨骼来传递声音,不经过耳道和耳膜,所以对听力的损伤较小,而且由于儿童还处于发育期,耳道和耳…

【并发设计模式】聊聊等待唤醒机制的规范实现

在多线程编程中,其实就是分工、协作、互斥。在很多场景中,比如A执行的过程中需要同步等待另外一个线程处理的结果,这种方式下,就是一种等待唤醒的机制。本篇我们来讲述等待唤醒机制的三种实现,以及对应的应用场景。 G…

{“sn“:““,“error“:3,“desc“:“VAD is not available“,“sub_error“:3100}解决办法

目录 问题描述: 解决顺序: 问题描述: 这个问题是在使用百度语音识别时出现的问题,当一切都配置好之后,启动程序,点击录音,发现程序并没有执行onEvent方法,直接闪退了,当断点调试时发现程序并没有进入onEvent方法,抛出异常{"sn":"","erro…

从0搭建github.io网页

点击跳转到🔗我的博客文章目录 从0搭建github.io网页 文章目录 从0搭建github.io网页1.成果展示1.1 网址和源码1.2 页面展示 2.new对象2.1 创建仓库 3.github.io仓库的初始化3.1 千里之行,始于足下3.2 _config.yml3.3 一点杂活 4.PerCheung.github.io.p…

2024/1/2 C++ work

全局变量,int monster 10000;定义英雄类hero,受保护的属性string name,int hp,int attck;公有的无参构造,有参构造,虚成员函数 void Atk(){blood-0;},法师类继承自英雄类,私有属性 …

k8s中实现pod自动扩缩容

一、k8s应用自动扩缩容概述 1)背景: 在实际的业务场景中,我们经常会遇到某个服务需要扩容的场景(例如:测试对服务压测、电商平台秒杀、大促活动、或由于资源紧张、工作负载降低等都需要对服务实例数进行扩缩容操作&…

gzip的了解

基本操作原理:通过消除文件中的冗余信息,使用哈夫曼编码等算法,将文件体积压缩到最小。这种数据压缩方式在网络传输中发扮了巨大作用,减小了传输数据的大小,从而提高了网页加载速度。 vue Vue CLI修改vue.config.js&a…

MySQL 临时表

MySQL 临时表 MySQL 临时表在我们需要保存一些临时数据时是非常有用的。 临时表只在当前连接可见,当关闭连接时,MySQL 会自动删除表并释放所有空间。 在 MySQL 中,临时表是一种在当前会话中存在的表,它在会话结束时会自动被销毁…

vue3按钮点击频率控制

现有一个按钮&#xff0c;如下图 点击时 再次点击 刷新窗口再次点击 刷新窗口依然可以实现点击频率控制。 代码实现&#xff1a; <template><!--<el-config-provider :locale"locale"><router-view/></el-config-provider>--><el…

Java学习苦旅(十六)——List

本篇博客将详细讲解Java中的List。 文章目录 预备知识——初识泛型泛型的引入泛型小结 预备知识——包装类基本数据类型和包装类直接对应关系装包与拆包 ArrayList简介ArrayList使用ArrayList的构造ArrayList常见操作ArrayList遍历 结尾 预备知识——初识泛型 泛型的引入 我…

机器人制作开源方案 | 多地形适应野外探索智能车

1. 作品基本介绍 如今&#xff0c;智能机器人在军事、制造业、交通运输、航天航空、医疗、服务等领域已有广泛的应用&#xff0c;智能车是机器人研究领域的一项重要基础内容&#xff0c;在各种移动机构中&#xff0c;最为常见的是轮式移动方式&#xff0c;当今社会正处于科技高…

[足式机器人]Part2 Dr. CAN学习笔记-自动控制原理Ch1-9PID控制器

本文仅供学习使用 本文参考&#xff1a; B站&#xff1a;DR_CAN Dr. CAN学习笔记-自动控制原理Ch1-9PID控制器&#xff09; P —— Proportional I —— Integral D —— Derivative 当前误差/过去误差/误差的变化趋势 K p ⋅ e K_{\mathrm{p}}\cdot e Kp​⋅e&#xff1a;比…

C++基本语言:1.5结构、pbulic、private权限修饰符、类简介

C基本语言包含10章节内容&#xff0c;存于C从入门到精通专栏 目录 一、结构回顾 ①结构变量作为参数 ②采用引用 ③用指向结构体的指针做函数参数 问&#xff1a;C/C的结构有何区别&#xff1f; 二、public和private权限修饰符 三、类简介&#xff1a;类也是一种用户自…

EBU7140 Security and Authentication(三)密钥管理;IP 层安全

B3 密钥管理 密钥分类&#xff1a; 按时长&#xff1a; short term&#xff1a;短期密钥&#xff0c;用于一次加密。long term&#xff1a;长期密钥&#xff0c;用于加密或者授权。 按服务类型&#xff1a; Authentication keys&#xff1a;公钥长期&#xff0c;私钥短期…

【InnoDB数据存储结构】第1章节:数据页存储结构

目录结构 之前整篇文章太长&#xff0c;阅读体验不好&#xff0c;将其拆分为几个子篇章。 本篇章讲解 InnoDB 数据页的存储结构。 数据的存储结构 索引是在存储引擎中实现的&#xff0c;MySQL 服务器上的 存储引擎负责对表数据的读取和写入。 但是不同存储引擎对 数据存放格…

Open3D 最小二乘拟合平面——拉格朗日乘子法

目录 一、算法原理二、代码实现三、结果展示本文由CSDN点云侠原创,原文链接Open3D 最小二乘拟合平面——拉格朗日乘子法。爬虫自重。 一、算法原理 设拟合出的平面方程为: a x + b y +

宣传照(私密)勿转发

精美的海报通常都是由UI进行精心设计的&#xff0c;现在有100 件商品需要进行宣传推广&#xff0c;如果每个商品都出一张图显然是不合理的&#xff0c;且商品信息各异。因此需要通过代码的形式生成海报。对此&#xff0c;我也对我宣传一波&#xff0c;企图实现我一夜暴富的伟大…

Nice Water Shader

非常好的水着色器! 标准RP上的新程序泡沫!!(URP即将推出) URP支持!! 有3个版本: -台式机 -移动设备 -桌面拼接 有灯光支持!! 使用 CUSTOM SHADER INSPECTOR(自定义着色器检查器) 个性化事物的能力,如: 镶嵌图案 3种不同颜色,形成渐变深度 色彩位置优势 菲涅耳颜色和…

[讲座] - 闲聊工业设计

1&#xff0c;工业设计相关的学科分类 2&#xff0c;工业设计的职业发展路线 3&#xff0c;工业设计师的成名人物 4&#xff0c;设计了可口可乐的Loewy 可口可乐的瓶子&#xff0c;无论白天晚上还是瓶子被打碎&#xff0c;都能认出这个是可口可乐的瓶子。 草图参照了可可豆&am…