# Class: EnfEditor::EEAnnotation

Inherits:
  EEAnnoBase
  - Object
  - EEBase
  - EEElement
  - EEAttribute
  - EEAnnoBase
  - EnfEditor::EEAnnotation
  show all

Defined in:
  lib/enfeditor/core_ext/ee_annotation.rb,
  ext/enfhandler/EnfHandler_wrap2.cxx

## Overview

Proxy of C++ EnfEditor::EEAnnotation class

## Direct Known Subclasses

EEAnnoDatum, EEAnnoDatumTarget, EEAnnoDimension, EEAnnoFreeSymbolPmi, EEAnnoGdt, EEAnnoGraphicDataPmi, EEAnnoLineWeld, EEAnnoLocator, EEAnnoNotSupported, EEAnnoNote, EEAnnoRoughness, EEAnnoSpotWeld

## Instance Method Summary collapse

- #annotation_type ⇒ Symbol

  Returns annotation type.

- #cast ⇒ EEAnnoNote, ...

  Returns each annotation sub class such as EEAnnoNote from EEAnnotaion base class.

- #layer_number ⇒ Integer

  Returns annotation layer number.

- #layer_number=(layer_number) ⇒ Object

  Set layer number to the annotation.

- #name ⇒ String

  Returns annotation name.

- #name=(name) ⇒ Object

  Set name to the annotation.

- #rgba ⇒ Array<Float>

  Returns annotation color rgba array.

- #rgba=(rgba) ⇒ Object

  Set color to the annotation.

- #set_color_all(new_rgba) ⇒ Object

  Set color to all annotation elements in annotation including semantic and graphic elements.

- #visible ⇒ Boolean

  Returns annotation visibile flag.

- #visible=(visible_flag) ⇒ Object

  Set visible flag to the annotation.

### Methods inherited from EEElement

#delete!

### Methods inherited from EEBase

#null?

## Instance Method Details

### #annotation_type ⇒ `Symbol`

Returns annotation type. Valid types are :note, :datum, :datum_target, :roughness, :gdt, :dimension, :locator, :spot_weld, :line_weld, :free_symbol_pmi, :graphic_data_pmi, :not_supported, :unknown

Examples:

    if anno.annotation_type == :note
      note_text = note.label_text.string
    end

Returns:

- (`Symbol`) —

  Returns annotation type. Valid types are :note, :datum, :datum_target, :roughness, :gdt, :dimension, :locator, :spot_weld, :line_weld, :free_symbol_pmi, :graphic_data_pmi, :not_supported, :unknown

Since:

- 1.0.0.0

    # File 'lib/enfeditor/core_ext/ee_annotation.rb', line 13

### #cast ⇒ `EEAnnoNote`, ...

Returns each annotation sub class such as EEAnnoNote from EEAnnotaion base class

Examples:

    component.annotations.each do |anno|
      if anno.annotation_type == :note
        note = anno.cast
        note.name = "Text.1"
        note.label_text_string = "Note Label Text"
      end
    end

Returns:

- (`EEAnnoNote`, `EEAnnoDatum`, `EEAnnoDatumTarget`, `EEAnnoDimension`, `EEAnnoGdt`, `EEAnnoRoughness`, `EEAnnoLocator`, `EEAnnoSpotWeld`, `EEAnnoLineWeld`, `EEAnnoFreeSymbolPmi`, `EEAnnoGraphicDataPmi`, `EEAnnoNotSupported`, `nil`) —

  Returns each annotation sub class such as EEAnnoNote from EEAnnotaion base class

Since:

- 1.0.0.0

    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    # File 'lib/enfeditor/core_ext/ee_annotation.rb', line 210

    def cast
      return to_note              unless to_note.is_null?
      return to_datum             unless to_datum.is_null?
      return to_datum_target      unless to_datum_target.is_null?
      return to_roughness         unless to_roughness.is_null?
      return to_gdt               unless to_gdt.is_null?
      return to_dimension         unless to_dimension.is_null?
      return to_locator           unless to_locator.is_null?
      return to_spot_weld         unless to_spot_weld.is_null?
      return to_line_weld         unless to_line_weld.is_null?
      return to_balloon_stack     unless to_balloon_stack.is_null?
      return to_free_symbol_pmi   unless to_free_symbol_pmi.is_null?
      return to_mock_pmi          unless to_mock_pmi.is_null?
      return to_graphic_data_pmi  unless to_graphic_data_pmi.is_null?
      return to_not_supported     unless to_not_supported.is_null?
      return nil
    end

### #layer_number ⇒ `Integer`

Returns annotation layer number

Examples:

    anno.layer_number # => 10

Returns:

- (`Integer`) —

  Returns annotation layer number

Since:

- 1.0.0.0

    # File 'lib/enfeditor/core_ext/ee_annotation.rb', line 38

### #layer_number=(layer_number) ⇒ `Object`

Set layer number to the annotation

Examples:

    anno.layer_number = 3

Parameters:

- layer_number (`Integer`) —

  Layer number to set

Since:

- 1.0.0.0

    # File 'lib/enfeditor/core_ext/ee_annotation.rb', line 45

### #name ⇒ `String`

Returns annotation name

Examples:

    anno.name # => "Dimension.1"

Returns:

- (`String`) —

  Returns annotation name

Since:

- 1.0.0.0

    # File 'lib/enfeditor/core_ext/ee_annotation.rb', line 23

### #name=(name) ⇒ `Object`

Set name to the annotation

Examples:

    anno.name = "Note.3"

Parameters:

- name (`String`) —

  Annotation name to set

Since:

- 1.0.0.0

    # File 'lib/enfeditor/core_ext/ee_annotation.rb', line 30

### #rgba ⇒ `Array<Float>`

Returns annotation color rgba array.

Examples:

    anno.rgba # => [1.0, 0.0, 0.0, 1.0]  Red

Returns:

- (`Array<Float>`) —

  Returns annotation color rgba array.

Since:

- 1.0.0.0

    # File 'lib/enfeditor/core_ext/ee_annotation.rb', line 68

### #rgba=(rgba) ⇒ `Object`

Set color to the annotation

Examples:

    anno.rgba = [1.0, 0.0, 0.0, 1.0]  # set red color

Parameters:

- rgba (`Array<Float>`) —

  Rgba color array

See Also:

- #set_color_all

Since:

- 1.0.0.0

    # File 'lib/enfeditor/core_ext/ee_annotation.rb', line 75

### #set_color_all(new_rgba) ⇒ `Object`

Set color to all annotation elements in annotation including semantic and graphic elements

Examples:

    # Set annotation element color (semantic and graphic) to red
    annotation.set_color_all([1.0, 0.0, 0.0, 1.0])

Parameters:

- new_rgba (`Array`) —

  New rgba color array

Since:

- 1.0.0.0

    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    # File 'lib/enfeditor/core_ext/ee_annotation.rb', line 159

    def set_color_all(new_rgba)
      unless new_rgba.is_a?(Array)
        raise "Input rgba should be an Array"
      end
      unless new_rgba.size == 4
        raise "Input rgba array size must be 4"
      end
      casted = self.cast
      rgba = new_rgba
      anno_color_elems = [
        :label_text,
        :text_property,
        :witness_l,
        :witness_r,
        :leaders,
        :graphic_data_elems
      ]
      casted.rgba = new_rgba
      anno_color_elems.each do |anno_color_elem|
        if casted.respond_to?(anno_color_elem)
          anno_elem = casted.send(anno_color_elem)
          if anno_elem.is_a?(Array)
            anno_elem.each do |each_elem|
              if each_elem.is_a?(EEAnnoBase)
                each_elem.rgba = new_rgba
              end
            end
          elsif anno_elem.is_a?(EEAnnoBase)
            anno_elem.rgba = new_rgba
          end
        end
      end
      if casted.respond_to?(:leaders)
        casted.leaders.each do |leader|
          leader.head.rgba = new_rgba unless leader.head.nil?
          leader.tail.rgba = new_rgba unless leader.tail.nil?
        end
      end
    end

### #visible ⇒ `Boolean`

Returns annotation visibile flag

Examples:

    anno.visible # => true

Returns:

- (`Boolean`) —

  Returns annotation visibile flag

Since:

- 1.0.0.0

    # File 'lib/enfeditor/core_ext/ee_annotation.rb', line 53

### #visible=(visible_flag) ⇒ `Object`

Set visible flag to the annotation

Examples:

    anno.visible = false # Make annotation invisible

Parameters:

- visible_flag (`Boolean`) —

  Set true(visible) or false(invisible)

Since:

- 1.0.0.0

    # File 'lib/enfeditor/core_ext/ee_annotation.rb', line 60