Class: TECSCDE::TECSModel::TmJoinBar

Inherits:
TECSCDE::TmObject show all
Defined in:
lib/tecscde/tecs_model/tm_join_bar.rb

Direct Known Subclasses

HBar, VBar

Instance Attribute Summary

Attributes inherited from TECSCDE::TmObject

#owner

Instance Method Summary collapse

Methods inherited from TECSCDE::TmObject

#copy_from, #model, #modified

Constructor Details

#initialize(position, owner_join) ⇒ TmJoinBar

@position::Integer(mm) # horizontal(x) or vertical(y) position @owner::TmJoin (Reverse Reference)



57
58
59
60
61
# File 'lib/tecscde/tecs_model/tm_join_bar.rb', line 57

def initialize(position, owner_join)
  @position = position
  @owner = owner_join
  modified {}
end

Instance Method Details

#clone_for_undoObject

TmJoinBar#clone_for_undo



124
125
126
127
128
# File 'lib/tecscde/tecs_model/tm_join_bar.rb', line 124

def clone_for_undo
  bu = clone
  bu.copy_from(self)
  bu
end

#get_joinObject

TmJoinBar#get_join ***



83
84
85
# File 'lib/tecscde/tecs_model/tm_join_bar.rb', line 83

def get_join
  @owner
end

#get_positionObject

TmJoinBar#get_position ***



64
65
66
# File 'lib/tecscde/tecs_model/tm_join_bar.rb', line 64

def get_position
  @position
end

#horizontal?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


130
131
132
# File 'lib/tecscde/tecs_model/tm_join_bar.rb', line 130

def horizontal?
  raise NotImplementedError
end

#move(x_inc, y_inc) ⇒ Object

TmJoinBar#move ***

actually moving previous next bar 1st bar and last bar can not be moved (necessary cport, eport move)



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/tecscde/tecs_model/tm_join_bar.rb', line 90

def move(x_inc, y_inc)
  modified do
    bar_prev = nil
    bars = @owner.bars

    if bars.length >= 1 && bars[bars.length - 1] == self
      @owner.eport.move(x_inc, y_inc)
      return # last bar
    end

    bars.each do |bar|
      if bar.equal?(self)
        break
      end
      bar_prev = bar
    end

    if bar_prev # prev_bar is nil if self is 1st bar
      # p "bar_prev exist"
      if bar_prev.horizontal?
        xm = bar_prev.get_position + x_inc
        bar_prev.set_position(model.clip_x(xm))
      else
        ym = bar_prev.get_position + y_inc
        bar_prev.set_position(model.clip_y(ym))
      end
    else
      # 1st bar
      @owner.cport.move(x_inc, y_inc)
    end
  end
end

#moved(inc) ⇒ Object



74
75
76
# File 'lib/tecscde/tecs_model/tm_join_bar.rb', line 74

def moved(inc)
  set_position(@position + inc)
end

#set_position(position) ⇒ Object



68
69
70
71
72
# File 'lib/tecscde/tecs_model/tm_join_bar.rb', line 68

def set_position(position)
  modified do
    @position = TECSCDE::TECSModel.round_length_val(position)
  end
end

#typeObject

Raises:

  • (NotImplementedError)


138
139
140
# File 'lib/tecscde/tecs_model/tm_join_bar.rb', line 138

def type
  raise NotImplementedError
end

#vertical?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


134
135
136
# File 'lib/tecscde/tecs_model/tm_join_bar.rb', line 134

def vertical?
  raise NotImplementedError
end