# cee::vis::OverlayCategoryLegend

class `OverlayCategoryLegend` : public OverlayItem

  A color legend used to indicate the interpretation of the colors in the model.

  For instance, a part color legend.

  Any number of combinations of label and color can be specified.

  See also

  OverlayItem and View

  Public Types

  enum `TickMarksPosition`

    Position of the legend tick marks.

    Values:

    enumerator `LEFT`

      Draw tick marks on the left side of the color legend.

    enumerator `RIGHT`

      Draw tick marks on the right side of the color legend.

    enumerator `TOP`

      Draw tick marks above the color legend.

    enumerator `BOTTOM`

      Draw tick marks below the color legend.

    enumerator `FOLLOW_LAYOUT`

      Automatically position the tick marks left or right based on the color legend’s alignment in the view.

  enum `Direction`

    Direction of color legend bar.

    Values:

    enumerator `HORIZONTAL`

      Draw horizontal color legend bar.

    enumerator `VERTICAL`

      Draw vertical color legend bar.

  Public Functions

  `OverlayCategoryLegend`()

    Constructs an overlay category legend.

  `OverlayCategoryLegend`(Font *titleFont, Font *categoryFont)

    Constructs an overlay category legend with custom fonts.

  void `setWidthToFitText`()

    Sets the width of the legend to fit the current text.

  size_t `categoryCount`() const

    Returns the number of categories.

  Str `categoryText`(size_t index) const

    Returns the text/label for the category with the given index.

  Color3f `categoryColor`(size_t index) const

    Returns the color of the category with the given index.

  void `addCategory`(const Str &text, Color3f color)

    Adds a category (label & color) to the legend.

  void `removeAllCategories`()

    Removes all categories from the legend.

  Str `title`() const

    Returns the title of the legend.

  void `setTitle`(const Str &title)

    Sets the title of the legend.

    Multiple lines can be specified by using the ‘\n’ separator

  Color3f `textColor`() const

    Returns the text color.

  void `setTextColor`(const Color3f &color)

    Sets the text color for the category labels. Also sets the border color for the category bar.

  TickMarksPosition `tickMarksPosition`() const

    Returns if the labels are drawn on the left side, right side or automatically based on view layout.

  void `setTickMarksPosition`(TickMarksPosition position)

    If set to true, the category colors will be drawn on the right side and the text will be right aligned on the left side.

  Direction `direction`() const

    Returns the direction of the color legend bar.

  void `setDirection`(Direction direction)

    Sets the direction of the color legend bar.

  bool `drawBackground`() const

    Sets if a background should be drawn for the legend.

  void `setDrawBackground`(bool drawBackground)

    Returns true if a background is drawn for the legend.

  Color3f `backgroundColor`() const

    Returns the color of the legend background.

  void `setBackgroundColor`(const Color3f &color)

    Sets the color of the legend background.

    The legend does not draw the background by default. Set setDrawBackground(true) to draw a background behind the legend. This is useful when you need to improve the contrast between the tick value labels and the background. The background opacity is set using setBackgroundOpacity().

  float `backgroundOpacity`() const

    Returns the opacity of the legend background.

  void `setBackgroundOpacity`(float opacity)

    Sets the legend background opacity.

    The legend does not draw the background by default. Set setDrawLegendBackground(true) to draw a background behind the legend.

  Color3f `backgroundBorderColor`() const

    Returns the color of the legend background border.

  void `setBackgroundBorderColor`(const Color3f &color)

    Sets the color of the legend background border.

Conversation saved
HOOPSY BETA

### Hello! I'm HOOPSY

Your multilingual generative AI assistant for documentation. Ask me anything about HOOPS Envision for Desktop in your own language, or choose a sample question below to start a conversation:

What is HOOPS Envision for Desktop?
What are the latest release notes for HOOPS Envision for Desktop?
How do I start evaluating HOOPS Envision for Desktop?
How do I write my first sample application?
How can I get assistance?

HOOPSY may store conversations according to OpenAI's policy. Responses may not always be accurate.

HOOPSY is thinking...