Back

OglLabel

sofa::gl::component::rendering2d::OglLabel
VisualModel
Doc (from source)

Display 2D text in the viewport.

Abstract (AI generated)

The `OglLabel` component displays 2D text within the viewport, providing customization options for position, font size, color, and contrast settings.

Metadata
module
Sofa.GL.Component.Rendering2D
namespace
sofa::gl::component::rendering2d
include
sofa/gl/component/rendering2d/OglLabel.h
inherits
  • VisualModel
description

The OglLabel component in the SOFA framework is designed to display 2D text within the viewport. It does not directly involve any mathematical or physical equations related to finite element analysis, continuum mechanics, or variational principles. Instead, it serves a purely visual and interactive role, providing means to annotate or label elements within the simulation environment.

The primary function of OglLabel is to render text at specified positions on the screen with customizable attributes such as font size, color, and contrast settings. The component does not contribute to any governing equations (e.g., mass matrix $M$, stiffness matrix $K$, internal force $f_{int}$, residual $R$) or numerical methods typically associated with FEM.

The OglLabel implements several methods, including:
- init: Initializes the component.
- reinit: Reinitializes the component.
- doUpdateVisual: Updates the visual representation of the label.
- doDrawVisual: Draws the label on the screen.
- handleEvent: Handles events such as user interactions.
- parse: Parses configuration information to set up the label.

While these methods are crucial for its functionality, they do not involve any mathematical formulations related to FEM or continuum mechanics. The component's role is purely in visual rendering and does not influence the numerical simulation process.

In summary, OglLabel is a pure visualization component without direct relevance to the mathematical and physical aspects of FEM simulations within SOFA.

Data Fields
NameTypeDefaultHelp
d_x unsigned int The x position of the text on the screen
d_y unsigned int The y position of the text on the screen
d_fontsize unsigned int The size of the font used to display the text on the screen
d_color sofa::type::RGBAColor The color of the text to display. (default='gray')
d_selectContrastingColor bool Override the color value but one that contrast with the background color
d_updateLabelEveryNbSteps unsigned int Update the display of the label every nb of time steps
Methods
void init () virtual
void reinit () virtual
void doUpdateVisual (const core::visual::VisualParams * ) virtual
void doDrawVisual (const core::visual::VisualParams * vparams) virtual
void handleEvent (core::objectmodel::Event * ) virtual
void parse (core::objectmodel::BaseObjectDescription * arg) virtual
void setColor (float r, float g, float b, float a)
{
  "name": "OglLabel",
  "namespace": "sofa::gl::component::rendering2d",
  "module": "Sofa.GL.Component.Rendering2D",
  "include": "sofa/gl/component/rendering2d/OglLabel.h",
  "doc": "Display 2D text in the viewport.",
  "inherits": [
    "VisualModel"
  ],
  "templates": [],
  "data_fields": [
    {
      "name": "d_x",
      "type": "unsigned int",
      "xmlname": "x",
      "help": "The x position of the text on the screen"
    },
    {
      "name": "d_y",
      "type": "unsigned int",
      "xmlname": "y",
      "help": "The y position of the text on the screen"
    },
    {
      "name": "d_fontsize",
      "type": "unsigned int",
      "xmlname": "fontsize",
      "help": "The size of the font used to display the text on the screen"
    },
    {
      "name": "d_color",
      "type": "sofa::type::RGBAColor",
      "xmlname": "color",
      "help": "The color of the text to display. (default='gray')"
    },
    {
      "name": "d_selectContrastingColor",
      "type": "bool",
      "xmlname": "selectContrastingColor",
      "help": "Override the color value but one that contrast with the background color"
    },
    {
      "name": "d_updateLabelEveryNbSteps",
      "type": "unsigned int",
      "xmlname": "updateLabelEveryNbSteps",
      "help": "Update the display of the label every nb of time steps"
    }
  ],
  "links": [],
  "methods": [
    {
      "name": "init",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "reinit",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "doUpdateVisual",
      "return_type": "void",
      "params": [
        {
          "name": "",
          "type": "const core::visual::VisualParams *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "doDrawVisual",
      "return_type": "void",
      "params": [
        {
          "name": "vparams",
          "type": "const core::visual::VisualParams *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "handleEvent",
      "return_type": "void",
      "params": [
        {
          "name": "",
          "type": "core::objectmodel::Event *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "parse",
      "return_type": "void",
      "params": [
        {
          "name": "arg",
          "type": "core::objectmodel::BaseObjectDescription *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setColor",
      "return_type": "void",
      "params": [
        {
          "name": "r",
          "type": "float"
        },
        {
          "name": "g",
          "type": "float"
        },
        {
          "name": "b",
          "type": "float"
        },
        {
          "name": "a",
          "type": "float"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    }
  ],
  "description": "The `OglLabel` component in the SOFA framework is designed to display 2D text within the viewport. It inherits from the `VisualModel` class, indicating its role in rendering visual elements. This component provides several data fields to customize the appearance and behavior of the displayed label, including position (`x`, `y`), font size, color, and options for contrasting with the background and updating frequency.\n\nIn terms of interactions within SOFA, `OglLabel` implements methods such as `init`, `reinit`, `doUpdateVisual`, `doDrawVisual`, `handleEvent`, and `parse`. These methods allow it to integrate seamlessly into the scene graph architecture for visual updates and event handling. The `setColor` method provides additional functionality to set the label's color.\n\nPractically, this component is useful for adding textual annotations or labels within a simulation environment. Users can specify position coordinates (`x`, `y`), font size, and colors to customize the text display. The option to select contrasting colors ensures that the text remains legible against various background settings.",
  "maths": "The `OglLabel` component in the SOFA framework is designed to display 2D text within the viewport. It does not directly involve any mathematical or physical equations related to finite element analysis, continuum mechanics, or variational principles. Instead, it serves a purely visual and interactive role, providing means to annotate or label elements within the simulation environment.\n\nThe primary function of `OglLabel` is to render text at specified positions on the screen with customizable attributes such as font size, color, and contrast settings. The component does not contribute to any governing equations (e.g., mass matrix \\(M\\), stiffness matrix \\(K\\), internal force \\(f_{int}\\), residual \\(R\\)) or numerical methods typically associated with FEM.\n\nThe `OglLabel` implements several methods, including:\n- **init**: Initializes the component.\n- **reinit**: Reinitializes the component.\n- **doUpdateVisual**: Updates the visual representation of the label.\n- **doDrawVisual**: Draws the label on the screen.\n- **handleEvent**: Handles events such as user interactions.\n- **parse**: Parses configuration information to set up the label.\n\nWhile these methods are crucial for its functionality, they do not involve any mathematical formulations related to FEM or continuum mechanics. The component's role is purely in visual rendering and does not influence the numerical simulation process.\n\nIn summary, `OglLabel` is a pure visualization component without direct relevance to the mathematical and physical aspects of FEM simulations within SOFA.",
  "abstract": "The `OglLabel` component displays 2D text within the viewport, providing customization options for position, font size, color, and contrast settings.",
  "sheet": "# OglLabel\n\n## Overview\n\nThe `OglLabel` is a visualization tool in SOFA that inherits from `VisualModel`. It is designed to display 2D text within the viewport. This component integrates seamlessly into the scene graph architecture for visual updates and event handling.\n\n## Parameters and Data\n\n- **x**: The x position of the text on the screen (`unsigned int`).\n- **y**: The y position of the text on the screen (`unsigned int`).\n- **fontsize**: The size of the font used to display the text on the screen (`unsigned int`).\n- **color**: The color of the text to display (`sofa::type::RGBAColor`, default='gray').\n- **selectContrastingColor**: Override the color value but one that contrasts with the background color (`bool`).\n- **updateLabelEveryNbSteps**: Update the display of the label every nb of time steps (`unsigned int`)."
}