Class: Wx::SF::Diagram

Inherits:
Object
  • Object
show all
Includes:
FIRM::Serializable
Defined in:
lib/wx/shapes/diagram.rb

Constant Summary collapse

SEARCHMODE =

Search mode flags for get_shape_at_position method

ShapeCanvas::SEARCHMODE

Instance Method Summary collapse

Constructor Details

#initializeDiagram

Returns a new instance of Diagram.



22
23
24
25
26
27
28
# File 'lib/wx/shapes/diagram.rb', line 22

def initialize
  @shapes = ShapeList.new
  @shape_canvas = nil
  @is_modified = false
  @accepted_shapes = ::Set.new([ACCEPT_ALL])
  @accepted_top_shapes = ::Set.new([ACCEPT_ALL])
end

Instance Method Details

#accept_shape(type) ⇒ Object

Add given shape type to an acceptance list. The acceptance list contains class names of the shapes which can be inserted into this instance of shapes canvas. Note: Constant value ACCEPT_ALL behaves like any class.

Parameters:

  • type (Class)

    Class of accepted shape object

See Also:



376
377
378
379
# File 'lib/wx/shapes/diagram.rb', line 376

def accept_shape(type)
  ::Kernel.raise ArgumentError, 'Class or ACCEPT_ALL expected' unless type.is_a?(::Class)
  @accepted_shapes << type
end

#accept_top_shape(type) ⇒ Object

Note: Constant value ACCEPT_ALL behaves like any class.

Parameters:

  • type (Class)

    Class of accepted shape object

See Also:



412
413
414
415
# File 'lib/wx/shapes/diagram.rb', line 412

def accept_top_shape(type)
  ::Kernel.raise ArgumentError, 'Class or ACCEPT_ALL expected' unless type.is_a?(::Class)
  @accepted_top_shapes << type
end

#add_shape(shape, parent, pos, initialize, save_state = true) ⇒ Wx::SF::ERRCODE

Add an existing shape to the canvas.

Parameters:

  • shape (Wx::SF::Shape)

    new shape

  • parent (Wx::SF::Shape)

    the parent shape

  • pos (Wx::Point)

    shape position (device coordinates)

  • initialize (Boolean)

    true if the shape should be reinitialized, otherwise false

  • save_state (Boolean) (defaults to: true)

    true if the canvas state should be saved

Returns:



184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/wx/shapes/diagram.rb', line 184

def add_shape(shape, parent,  pos, initialize, save_state = true)
  if shape
    if shape.is_a?(Shape) && is_shape_accepted(shape.class)
      pos = pos.to_point
      if @shape_canvas
        new_pos = @shape_canvas.fit_position_to_grid(@shape_canvas.dp2lp(pos))
        shape.set_relative_position(new_pos.to_real)
      else
        shape.set_relative_position(pos.to_real)
      end

      # add shape
      if parent
        shape.set_parent_shape(parent)
      else
        if is_top_shape_accepted(shape.class)
          @shapes << shape
          shape.set_diagram(self)
        else
          return ERRCODE::NOT_ACCEPTED
        end
      end

      # initialize added shape
      if initialize
        shape.create_handles

        shape.set_hover_colour(@shape_canvas.get_hover_colour) if @shape_canvas

        if has_children(shape)
            # get shape's children (if exist)
            lst_children = shape.get_child_shapes(ANY, RECURSIVE)
            # initialize shape's children
            lst_children.each do |child|
              child.create_handles
              child.update(false)

              child.set_hover_colour(@shape_canvas.get_hover_colour) if @shape_canvas
            end
        end

        shape.update
      end

      # reset scale of assigned shape canvas (if exists and it is necessary...)
      if @shape_canvas && shape.is_a?(ControlShape)
        @shape_canvas.set_scale(1.0)
      end

      @shape_canvas.save_canvas_state if @shape_canvas && save_state

      @is_modified = true

      ERRCODE::OK
    else
      ERRCODE::NOT_ACCEPTED
    end
  else
    ERRCODE::INVALID_INPUT
  end
end

#clearObject

Remove all shapes from canvas



321
322
323
324
325
326
327
# File 'lib/wx/shapes/diagram.rb', line 321

def clear
  @shapes.clear
  if @shape_canvas
    @shape_canvas.get_multiselection_box.show(false)
    @shape_canvas.update_virtual_size
  end
end

#clear_accepted_shapesObject

Clear shape object acceptance list

See Also:



395
396
397
# File 'lib/wx/shapes/diagram.rb', line 395

def clear_accepted_shapes
  @accepted_shapes.clear
end

#clear_accepted_top_shapesObject

Clear top shapes acceptance list

See Also:



431
432
433
# File 'lib/wx/shapes/diagram.rb', line 431

def clear_accepted_top_shapes
  @accepted_top_shapes.clear
end

#contains_shape(shape) ⇒ Boolean Also known as: contains_shape?, contains?

Returns true if the given shape is part of the diagram, false otherwise

Parameters:

Returns:

  • (Boolean)


314
315
316
# File 'lib/wx/shapes/diagram.rb', line 314

def contains_shape(shape)
  @shapes.include?(shape,true)
end

#create_connection(src_id, trg_id, save_state = true) ⇒ Array(Wx::SF::ERRCODE, Wx::SF::Shape) #create_connection(src_id, trg_id, line_info, save_state = true) ⇒ Array(Wx::SF::ERRCODE, Wx::SF::Shape) #create_connection(src_id, trg_id, line, save_state = true) ⇒ Array(Wx::SF::ERRCODE, Wx::SF::Shape)

Create new direct connection between two shapes.

This function creates new simple connection line (without arrows) between given shapes.

Overloads:

  • #create_connection(src_id, trg_id, save_state = true) ⇒ Array(Wx::SF::ERRCODE, Wx::SF::Shape)

    Returns operation result and new connection object. the object is added to the shape canvas automatically.

    Parameters:

    • src (Shape)

      source shape

    • trg (Shape)

      target shape

    • save_state (Boolean) (defaults to: true)

      set the parameter true if you wish to save canvas state after the operation

    Returns:

  • #create_connection(src_id, trg_id, line_info, save_state = true) ⇒ Array(Wx::SF::ERRCODE, Wx::SF::Shape)

    Returns operation result and new connection object. the object is added to the shape canvas automatically.

    Parameters:

    • src (Shape)

      source shape

    • trg (Shape)

      target shape

    • line_info (Class)

      Connection type (any class inherited from Wx::SF::LineShape)

    • save_state (Boolean) (defaults to: true)

      set the parameter true if you wish to save canvas state after the operation

    Returns:

  • #create_connection(src_id, trg_id, line, save_state = true) ⇒ Array(Wx::SF::ERRCODE, Wx::SF::Shape)

    Returns operation result and new connection object. the object is added to the shape canvas automatically.

    Parameters:

    • src (Shape)

      source shape

    • trg (Shape)

      target shape

    • line (Wx::SF::LineShape)

      the line shape

    • save_state (Boolean) (defaults to: true)

      set the parameter true if you wish to save canvas state after the operation

    Returns:

See Also:

  • start_interactive_connection


83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/wx/shapes/diagram.rb', line 83

def create_connection(src, trg, *rest)
  shape = nil
  if rest.first.is_a?(LineShape)
    line = rest.shift
    save_state = rest.empty? ? true : rest.shift
    err = add_shape(line, nil, Wx::DEFAULT_POSITION, INITIALIZE, DONT_SAVE_STATE)
    shape = line if err == ERRCODE::OK
  else
    line_type = (rest.empty? || !rest.first.is_a?(::Class)) ? LineShape : rest.shift
    save_state = rest.empty? ? true : rest.shift
    err, shape = create_shape(line_type, DONT_SAVE_STATE)
  end
  if shape
    shape.set_src_shape(src)
    shape.set_trg_shape(trg)

    if @shape_canvas
      @shape_canvas.save_canvas_state if save_state
      shape.refresh
    end
  end
  [err, shape]
end

#create_shape(shape_info, save_state = true) ⇒ Array(Wx::SF::ERRCODE, Wx::SF::Shape) #create_shape(shape_info, pos, save_state = true) ⇒ Array(Wx::SF::ERRCODE, Wx::SF::Shape)

Create new shape and add it to the shape canvas.

Overloads:

  • #create_shape(shape_info, save_state = true) ⇒ Array(Wx::SF::ERRCODE, Wx::SF::Shape)

    Returns operation result and new shape. the object is added to the shape canvas automatically.

    Parameters:

    • shape_info (Class)

      Shape type

    • save_state (Boolean) (defaults to: true)

      Set the parameter true if you wish to save canvas state after the operation

    Returns:

  • #create_shape(shape_info, pos, save_state = true) ⇒ Array(Wx::SF::ERRCODE, Wx::SF::Shape)

    Returns operation result and new shape. the object is added to the shape canvas automatically.

    Parameters:

    • shape_info (Class)

      Shape type

    • pos (Wx::Point)

      shape position

    • save_state (Boolean) (defaults to: true)

      Set the parameter true if you wish to save canvas state after the operation

    Returns:



117
118
119
120
121
122
123
# File 'lib/wx/shapes/diagram.rb', line 117

def create_shape(shape_info, *rest)
  if shape_info && is_shape_accepted(shape_info)
    insert_shape(shape_info.new, *rest)
  else
    [ERRCODE::NOT_ACCEPTED, nil]
  end
end

#get_accepted_shapesSet<String> Also known as: accepted_shapes

Returns:

  • (Set<String>)


401
402
403
# File 'lib/wx/shapes/diagram.rb', line 401

def get_accepted_shapes
  @accepted_shapes
end

#get_accepted_top_shapesSet<String> Also known as: accepted_top_shapes

Returns:

  • (Set<String>)


437
438
439
# File 'lib/wx/shapes/diagram.rb', line 437

def get_accepted_top_shapes
  @accepted_top_shapes
end

#get_all_shapesObject

Get all shapes recursively. This is an optimized convenience method which returns all shapes the same as if #get_shapes() was called with default arguments.



476
477
478
# File 'lib/wx/shapes/diagram.rb', line 476

def get_all_shapes
  @shapes.all
end

#get_assigned_connections(parent, shape_info, mode, lines = []) ⇒ Object

See Also:



449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
# File 'lib/wx/shapes/diagram.rb', line 449

def get_assigned_connections(parent, shape_info, mode, lines = [])
  return lines unless parent

  # lines are all toplevel so we do not have to search recursively...
  lst_lines = @shapes.select { |shape| shape.is_a?(shape_info) && !shape.stand_alone? }

  lst_lines.each do |line|
    case mode
    when Shape::CONNECTMODE::STARTING
      lines << line if line.get_src_shape == parent
    when Shape::CONNECTMODE::ENDING
      lines << line if line.get_trg_shape == parent
    when Shape::CONNECTMODE::BOTH
      lines << line if line.get_src_shape == parent || line.get_trg_shape == parent
    end
  end
  lines
end

#get_neighbours(parent, shape_info, condir, direct = true, neighbours = []) ⇒ Array<Wx::SF::Shape>

otherwise also shapes connected by forked lines will be found (also constants DIRECT and INDIRECT can be used)

Parameters:

Returns:

See Also:



591
592
593
594
595
596
597
598
599
600
# File 'lib/wx/shapes/diagram.rb', line 591

def get_neighbours(parent, shape_info, condir, direct = true, neighbours = [])
  if parent
    parent.get_neighbours(shape_info, condir, direct, neighbours)
  else
    @shapes.each do |shape|
      shape.get_neighbours(shape_info, condir, direct, neighbours)
    end
  end
  neighbours
end

#get_shape_at_position(pos, zorder = 1, mode = SEARCHMODE::BOTH) ⇒ Object

See Also:



505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
# File 'lib/wx/shapes/diagram.rb', line 505

def get_shape_at_position(pos, zorder = 1, mode = SEARCHMODE::BOTH)
  # sort shapes list in the way that the line shapes will be at the top of the list
  # and all non-line shapes get listed in reversed order as returned from get_shapes (for z order)
  ins_pos = 0
  pos = pos.to_point
  shapes = get_all_shapes.inject([]) do |list, shape|
    if shape.is_a?(LineShape)
      list.prepend(shape)
      ins_pos += 1
    else
      list.insert(ins_pos, shape)
    end
    list
  end
  # find the topmost shape according to the given rules
  counter = 1
  shapes.each do |shape|
    if shape.visible? && shape.active? && shape.contains?(pos)
      case mode
      when SEARCHMODE::SELECTED
        if shape.selected?
          return shape if counter == zorder
          counter += 1
        end
      when SEARCHMODE::UNSELECTED
        unless shape.selected?
          return shape if counter == zorder
          counter += 1
        end
      when SEARCHMODE::BOTH
        return shape if counter == zorder
        counter += 1
      end
    end
  end

  nil
end

#get_shape_canvasWx::SF::ShapeCanvas? Also known as: shape_canvas

Returns the shape canvas.

Returns:



32
33
34
# File 'lib/wx/shapes/diagram.rb', line 32

def get_shape_canvas
  @shape_canvas
end

#get_shapes(shape_info = Wx::SF::Shape, mode = Shape::SEARCHMODE::BFS, shapes = []) ⇒ Object

See Also:



486
487
488
489
490
491
492
493
494
495
# File 'lib/wx/shapes/diagram.rb', line 486

def get_shapes(shape_info = Wx::SF::Shape, mode = Shape::SEARCHMODE::BFS, shapes = [])
  @shapes.each do |shape|
    shapes << shape if shape.is_a?(shape_info)
    shape.get_children_recursively(shape_info, mode, shapes) if mode == Shape::SEARCHMODE::DFS
  end
  if mode == Shape::SEARCHMODE::BFS
    @shapes.each { |shape| shape.get_children_recursively(shape_info, mode, shapes) }
  end
  shapes
end

#get_shapes_at_position(pos, shapes = []) ⇒ Array<Wx::SF::Shape>

Returns shape list.

Parameters:

  • pos (Wx::Point)

    Logical position

  • shapes (Array<Wx::SF::Shape>) (defaults to: [])

    shape list where all found shapes will be stored

Returns:

See Also:

  • ShapeCanvas::dp2lp


549
550
551
552
553
554
# File 'lib/wx/shapes/diagram.rb', line 549

def get_shapes_at_position(pos, shapes = [])
  pos = pos.to_point
  get_all_shapes.each do |shape|
    shapes << shape if shape.visible? && shape.active? && shape.contains?(pos)
  end
end

#get_shapes_inside(rct, shapes = []) ⇒ Array<Wx::SF::Shape>

Returns shape list.

Parameters:

  • shapes (Array<Wx::SF::Shape>) (defaults to: [])

    shape list where all found shapes will be stored

Returns:



560
561
562
563
564
# File 'lib/wx/shapes/diagram.rb', line 560

def get_shapes_inside(rct, shapes = [])
  get_all_shapes.each do |shape|
    shapes << shape if shape.visible? && shape.active? && shape.intersects?(rct)
  end
end

#get_top_shapesObject

Returns the list of top level shapes



469
470
471
# File 'lib/wx/shapes/diagram.rb', line 469

def get_top_shapes
  @shapes
end

#has_children(parent) ⇒ Boolean Also known as: has_children?

Function finds out whether given shape has some children.

Parameters:

Returns:

  • (Boolean)

    true if the parent shape has children, otherwise false



576
577
578
# File 'lib/wx/shapes/diagram.rb', line 576

def has_children(parent)
  parent.has_children?
end

#insert_shape(shape, save_state = true) ⇒ Array(Wx::SF::ERRCODE, Wx::SF::Shape) #insert_shape(shape, pos, save_state = true) ⇒ Array(Wx::SF::ERRCODE, Wx::SF::Shape)

Insert new shape to the shape canvas.

Overloads:

  • #insert_shape(shape, save_state = true) ⇒ Array(Wx::SF::ERRCODE, Wx::SF::Shape)

    Returns operation result and new shape. the object is added to the shape canvas automatically.

    Parameters:

    • shape (Wx::SF::Shape)

      new shape

    • save_state (Boolean) (defaults to: true)

      Set the parameter true if you wish to save canvas state after the operation

    Returns:

  • #insert_shape(shape, pos, save_state = true) ⇒ Array(Wx::SF::ERRCODE, Wx::SF::Shape)

    Returns operation result and new shape. the object is added to the shape canvas automatically.

    Parameters:

    • shape (Wx::SF::Shape)

      new shape

    • pos (Wx::Point)

      shape position (device coordinates)

    • save_state (Boolean) (defaults to: true)

      Set the parameter true if you wish to save canvas state after the operation

    Returns:



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/wx/shapes/diagram.rb', line 135

def insert_shape(shape, *rest)
  pos = if rest.first.respond_to?(:to_point)
          rest.shift.to_point
        elsif @shape_canvas
          clt_rect = @shape_canvas.get_client_rect
          Wx::Point.new((clt_rect.right - clt_rect.left)/2,
                        (clt_rect.bottom - clt_rect.top)/2)
        else
          Wx::Point.new
        end
  save_state = rest.empty? ? true : rest.shift
  if shape && is_shape_accepted(shape.class)
    parent_shape = nil
    # update given position
    lpos = @shape_canvas ? @shape_canvas.dp2lp(pos) : pos
    # line shapes can be assigned to root only
    parent_shape = get_shape_at_position(lpos) unless shape.is_a?(LineShape)
    # In case the matching shape does not accept ANY children see if this shape has a
    # parent that does also match the position and DOES accept children.
    # This allows dropping shapes onto child shapes inside a (container) shapes like
    # grids and/or boxes.
    while parent_shape&.does_not_accept_children? && parent_shape.parent_shape
      parent_shape = parent_shape.parent_shape
      parent_shape = nil unless parent_shape.get_bounding_box.contains?(lpos)
    end
    # see if the located parent (if any) accepts this particular type of child
    if parent_shape && parent_shape.is_child_accepted(shape.class)
      # add shape as child of located parent
      err = add_shape(shape, parent_shape, pos - parent_shape.get_absolute_position.to_point, INITIALIZE, save_state)
    else
      # add shape as new toplevel shape (if acceptable)
      err = add_shape(shape, nil, pos, INITIALIZE, save_state)
    end

    parent_shape.update if parent_shape

    [err, shape]
  else
    [ERRCODE::NOT_ACCEPTED, nil]
  end
end

#inspectObject



673
674
675
# File 'lib/wx/shapes/diagram.rb', line 673

public def inspect
  "#<Wx::SF::Diagram:#{object_id}>"
end

#is_emptyObject Also known as: empty?

Determines whether the diagram contains some shapes.

Returns:

  • true if there are no shapes in the diagram, otherwise false



568
569
570
# File 'lib/wx/shapes/diagram.rb', line 568

def is_empty
  @shapes.empty?
end

#is_modifiedBoolean Also known as: modified?

Get information about managed diagram’s modification.

The function returns TRUE if the diagram has been modified and its content should be saved. The modification flag is cleared when the content is saved.

Returns:

  • (Boolean)

    true if managed diagram is modified, otherwise false.



49
50
51
# File 'lib/wx/shapes/diagram.rb', line 49

def is_modified
  @is_modified
end

#is_shape_accepted(type) ⇒ Boolean Also known as: shape_accepted?

Tells whether the given shape type is accepted by this canvas instance (it means whether this shape can be inserted into it).

The function is typically used by the framework for determination whether class type supplied by add_shape or create_shape function can be inserted into shape canvas.

Parameters:

  • type (Class)

    Class of examined shape object

Returns:

  • (Boolean)

    true if the shape type is accepted, otherwise false.



388
389
390
# File 'lib/wx/shapes/diagram.rb', line 388

def is_shape_accepted(type)
  @accepted_shapes.include?(type) || @accepted_shapes.include?(ACCEPT_ALL)
end

#is_top_shape_accepted(type) ⇒ Boolean Also known as: top_shape_accepted?

The function is typically used by the framework for determination whether class type supplied by add_shape or create_shape function can be inserted directly onto shape canvas.

Parameters:

  • type (Class)

    Class of examined shape object

Returns:

  • (Boolean)

    true if the shape type is accepted, otherwise false.



424
425
426
# File 'lib/wx/shapes/diagram.rb', line 424

def is_top_shape_accepted(type)
  @accepted_top_shapes.include?(type) || @accepted_top_shapes.include?(ACCEPT_ALL)
end

#move_shapes_from_negativesObject

Move all shapes so none of it will be located in negative position



338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# File 'lib/wx/shapes/diagram.rb', line 338

def move_shapes_from_negatives
  min_x = min_y = 0.0

  # find the maximal negative position value
  shapes = get_all_shapes

  shapes.each_with_index do |shape, ix|
    shape_pos = shape.get_absolute_position
    if ix == 0
      min_x = shape_pos.x
      min_y = shape_pos.y
    else
      min_x = shape_pos.x if shape_pos.x < min_x
      min_y = shape_pos.y if shape_pos.y < min_y
    end
  end

  # move all parents shape so they (and their children) will be located in the positive values only
  if min_x < 0.0 || min_y < 0.0
    shapes.each do |shape|
      unless shape.get_parent_shape
        shape.move_by(min_x.to_i.abs, 0) if min_x < 0.0
        shape.move_by(0, min_y.to_i.abs) if min_y < 0.0
      end
    end
  end
end

#move_to_end(shape) ⇒ Object

Move given shape to the end of the shapes list

Parameters:



331
332
333
334
335
# File 'lib/wx/shapes/diagram.rb', line 331

def move_to_end(shape)
  if (a_shape = @shapes.delete(shape))
    @shapes << a_shape
  end
end

#remove_shape(shape, refresh = true) ⇒ Object

Remove given shape from the shape canvas.

Parameters:

  • shape (Wx::SF::Shape)

    shape object that should be deleted

  • refresh (Boolean) (defaults to: true)

    Set the parameter to true if you wish to repaint the canvas



249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/wx/shapes/diagram.rb', line 249

def remove_shape(shape, refresh = true)
  return unless shape

  parent = shape.get_parent_shape

  # get all shape's children
  lst_children = shape.get_child_shapes(ANY, RECURSIVE)
  lst_children << shape # and shape itself

  # retrieve all assigned lines
  lst_connections = []
  lst_children.each do |child|
    get_assigned_connections(child, LineShape, Shape::CONNECTMODE::BOTH, lst_connections)
  end

  # remove all assigned lines
  lst_removed_connections = []
  lst_connections.each do |line|
    # one connection may be used by the parent and also by his child
    unless lst_removed_connections.include?(line)
      lst_removed_connections << line
      remove_shape(line,false)
    end
  end

  # remove the shape and it's children from canvas cache and shape index list
  @shape_canvas.send(:remove_from_temporaries, shape) if @shape_canvas

  # remove the shape
  shape.set_parent_shape(nil) # also removes shape from parent if it had a parent
  shape.set_diagram(nil)
  @shapes.delete(shape)

  @is_modified = true

  parent.update if parent

  @shape_canvas.refresh(false) if refresh && @shape_canvas
end

#remove_shapes(selection) ⇒ Object

Remove shapes from the shape canvas

Parameters:

  • selection (Array<Wx::SF::Shape>)

    List of shapes which should be removed from the canvas



291
292
293
# File 'lib/wx/shapes/diagram.rb', line 291

def remove_shapes(selection)
  selection.each { |shape| remove_shape(shape, false) if contains?(shape) }
end

#reparent_shape(shape, parent) ⇒ Wx::SF::Shape

Change shape’s parent (possibly making it unparented i.e. toplevel)

Parameters:

Returns:



299
300
301
302
303
304
305
306
307
308
309
# File 'lib/wx/shapes/diagram.rb', line 299

def reparent_shape(shape, parent)
  prev_parent = shape.get_parent_shape
  if prev_parent.nil? && parent
    @shapes.delete(shape) # remove from top level list if the shape will become parented
  elsif prev_parent && parent.nil?
    @shapes << shape # add to toplevel shapes if the shape will become unparented
    shape.set_diagram(self) # make sure the right diagram is set
  end
  shape.set_parent_shape(parent)
  shape
end

#set_modified(state = true) ⇒ Object Also known as: modified=

Set diagram’s modification flag manually.

Parameters:

  • state (Boolean) (defaults to: true)

    State of diagram’s modification flag.



56
57
58
# File 'lib/wx/shapes/diagram.rb', line 56

def set_modified(state = true)
  @is_modified = state
end

#set_shape_canvas(canvas) ⇒ Object Also known as: shape_canvas=

Set the shape canvas.

Parameters:



39
40
41
# File 'lib/wx/shapes/diagram.rb', line 39

def set_shape_canvas(canvas)
  @shape_canvas = canvas
end

#update_allObject

Update all shapes in the diagram manager



367
368
369
# File 'lib/wx/shapes/diagram.rb', line 367

def update_all
  get_all_shapes.each { |shape| shape.update unless shape.has_children? }
end