class Microstation::Element
Attributes
app[R]
ole_obj[R]
original[R]
Public Class Methods
convert_item(ole,app, cell=nil)
click to toggle source
# File lib/microstation/element.rb, line 107 def self.convert_item(ole,app, cell=nil) return Point3d.from_ole(ole) if ole.class == WIN32OLE_RECORD && ole.typename == 'Point3d' return ole unless ole.class == WIN32OLE case ole.Type when ::Microstation::MSD::MsdElementTypeText ::Microstation::Text.new(ole,app,cell) when ::Microstation::MSD::MsdElementTypeLine ::Microstation::Line.new(ole,app,cell) when ::Microstation::MSD::MsdElementTypeTextNode ::Microstation::TextNode.new(ole,app,cell) when ::Microstation::MSD::MsdElementTypeTag ::Microstation::Tag.new(ole,app,cell) when ::Microstation::MSD::MsdElementTypeCellHeader ::Microstation::Cell.new(ole,app,cell) when ::Microstation::MSD::MsdElementTypeSharedCell ::Microstation::Cell.new(ole,app,cell) when ::Microstation::MSD::MsdElementTypeArc ::Microstation::Arc.new(ole,app,cell) when ::Microstation::MSD::MsdElementTypeEllipse ::Microstation::Ellipse.new(ole,app,cell) when ::Microstation::MSD::MsdElementTypeBsplineSurface ::Microstation::BSplineSurface.new(ole,app,cell) when ::Microstation::MSD::MsdElementTypeBsplineCurve ::Microstation::BSplineCurve.new(ole,app,cell) else new(ole,app,cell) end end
new(ole,app, cell = nil)
click to toggle source
# File lib/microstation/element.rb, line 144 def initialize(ole,app, cell = nil) @ole_obj = ole @original = read_ole(ole) @app = app @cell = cell end
ole_object?()
click to toggle source
# File lib/microstation/element.rb, line 137 def self.ole_object? ole.class == WIN32OLE end
Public Instance Methods
[](name)
click to toggle source
# File lib/microstation/element.rb, line 182 def [](name) property_handler[name] end
app_ole_obj()
click to toggle source
# File lib/microstation/element.rb, line 226 def app_ole_obj app.ole_obj end
do_update(value)
click to toggle source
# File lib/microstation/element.rb, line 187 def do_update(value) return false if value == original saved_original = original begin write_ole(value) @original = read_ole(ole_obj) return true rescue => e @original = saved_original false end end
each(ole = ole_obj,&block)
click to toggle source
# File lib/microstation/element.rb, line 251 def each(ole = ole_obj,&block) return unless ole.IsComplexElement return to_enum(:each) unless block_given? if ole.IsCellElement each_cell(ole,&block) else each_complex(ole,&block) end end
each_cell(ole) { |wrap(component.AsTextNodeElement,app,cell)| ... }
click to toggle source
# File lib/microstation/element.rb, line 234 def each_cell(ole,&block) cell = ole if ole_cell(ole) ole.ResetElementEnumeration rescue binding.pry while ole.MoveToNextElement component = ole.CopyCurrentElement if component.IsTextNodeElement yield Microstation::Wrap.wrap(component.AsTextNodeElement,app,cell) elsif component.IsTextElement yield Microstation::Wrap.wrap(component.AsTextElement,app,cell) elsif component.IsComplexElement each(component) else yield Microstation::Wrap.wrap(component,app,cell) end end end
each_complex(ole) { |wrap(component.AsTextNodeElement,app,cell)| ... }
click to toggle source
# File lib/microstation/element.rb, line 261 def each_complex(ole,&block) cell = nil components = ole.GetSubElements while components.MoveNext component = components.Current if component.IsTextNodeElement yield Microstation::Wrap.wrap(component.AsTextNodeElement,app,cell) elsif component.IsTextElement yield Microstation::Wrap.wrap(component.AsTextElement,app,cell) elsif component.IsComplexElement each(component,&block) else yield Microstation::Wrap.wrap(component,app,cell) end end end
get_property_handler()
click to toggle source
# File lib/microstation/element.rb, line 173 def get_property_handler ph_ole = app_ole_obj.CreatePropertyHandler(ole_obj) PropertyHandler.new(ph_ole) end
in_cell?()
click to toggle source
# File lib/microstation/element.rb, line 151 def in_cell? !!@cell end
method_missing(meth,*args,&block)
click to toggle source
Calls superclass method
# File lib/microstation/element.rb, line 163 def method_missing(meth,*args,&block) if meth.to_s =~ /^[A-Z]/ result = ole_obj.send(meth,*args,&block) Element.convert_item(result,app) else super(meth,*args,&block) end end
ole_cell(ole)
click to toggle source
# File lib/microstation/element.rb, line 230 def ole_cell(ole) ole.IsCellElement || ole.IsSharedCellElement end
property_handler()
click to toggle source
# File lib/microstation/element.rb, line 178 def property_handler @property_handler ||= get_property_handler end
read_ole(ole)
click to toggle source
# File lib/microstation/element.rb, line 155 def read_ole(ole) end
redraw(el = ole_obj)
click to toggle source
# File lib/microstation/element.rb, line 221 def redraw(el = ole_obj) el.RedrawRedraw::Microstation::MSD::MsdDrawingModeNormal el.Rewrite end
update(value)
click to toggle source
# File lib/microstation/element.rb, line 201 def update(value) redraw_el = ole_obj if do_update(value) if in_cell? @cell.ReplaceCurrentElement @ole_obj redraw_el = @cell end redraw(redraw_el) @updated = true true else @updated = false false end end
updated?()
click to toggle source
# File lib/microstation/element.rb, line 217 def updated? @updated end
write_ole(value)
click to toggle source
# File lib/microstation/element.rb, line 159 def write_ole(value) end