Module: TT::Cursor
- Defined in:
- TT_Lib2/cursor.rb
Overview
Constant Summary
Class Method Summary collapse
-
.get_id(id) ⇒ Integer?
Creates cursor ids for the requested cursor
id
. -
.get_vector2d_cursor(screen_vector, view) ⇒ Integer?
Returns a cursor ID to a scaling direction cursor based on a 2D vector in screen space.
-
.get_vector3d_cursor(vector, view) ⇒ Integer?
Returns a cursor ID to a scaling direction cursor based on a 3D vector in model space.
- .scale_handles ⇒ Hash
Class Method Details
.get_id(id) ⇒ Integer?
Creates cursor ids for the requested cursor id
. Cursors are
created on demand and reused to save resources.
Valid id
arguments
-
:default
-
:invalid
(2.7.0) -
:hand
(2.7.0) -
:hand_invalid
(2.7.0) -
:link
(2.7.0) -
:erase
(2.7.0) -
:pencil
(2.7.0) -
:freehand
(2.7.0) -
:arc_1
(2.7.0) -
:arc_2
(2.7.0) -
:arc_3
(2.7.0) -
:man
(2.7.0) -
:position_camera_3d
(2.7.0) -
:orbit
(2.7.0) -
:orbit_3d
(2.7.0) -
:pan_2d
(2.7.0) -
:pan
(2.7.0) -
:walk
(2.7.0) -
:walk_3d
(2.7.0) -
:look_around
(2.7.0) -
:look_around_903
(2.7.0) -
:zoom
(2.7.0) -
:zoom_region
(2.7.0) -
:zoom_3d
(2.7.0) -
:zoom_2d
(2.7.0) -
:zoom_2d_region
(2.7.0) -
:offset
-
:offset_invalid
-
:dropper
-
:dropper_texture
(2.7.0) -
:dropper_invalid
-
:paint
(2.7.0) -
:paint_same
(2.7.0) -
:paint_object
(2.7.0) -
:paint_connected
(2.7.0) -
:paint_invalid
(2.7.0) -
:text
(2.7.0) -
:follow
(2.7.0) -
:follow_me
(2.7.0) -
:pushpull
(2.7.0) -
:pushpull_add
(2.7.0) -
:pushpull_invalid
(2.7.0) -
:tape
(2.7.0) -
:tape_add
(2.7.0) -
:select
-
:select_add
-
:select_remove
-
:select_toggle
-
:select_step_1
(2.7.0) -
:select_step_2
(2.7.0) -
:select_invalid
(2.7.0) -
:vertex
(2.5.0) -
:vertex_add
(2.5.0) -
:vertex_remove
(2.5.0) -
:vertex_toggle
(2.5.0) -
:rectangle
(2.6.0) -
:move
(2.6.0) -
:move_copy
(2.7.0) -
:move_fold
(2.7.0) -
:move_invalid
(2.7.0) -
:position
(2.7.0) -
:position_invalid
(2.7.0) -
:rotate
(2.6.0) -
:rotate_copy
(2.6.0) -
:rotate_invalid
(2.7.0) -
:scale
(2.6.0) -
:scale_invalid
(2.7.0) -
:scale_n_s
(2.7.0) -
:scale_n_ne
(2.7.0) -
:scale_ne
(2.7.0) -
:scale_ne_e
(2.7.0) -
:scale_w_e
(2.7.0) -
:scale_n_nw
(2.7.0) -
:scale_nw
(2.7.0) -
:scale_nw_w
(2.7.0)
181 182 183 184 185 186 187 188 189 190 |
# File 'TT_Lib2/cursor.rb', line 181 def self.get_id(id) return nil unless @cursors.key?(id) # Load cursors on demand if @cursors[id].is_a?(Array) cursor_file, x, y = @cursors[id] filename = File.join( TT::Cursor::PATH, cursor_file ) @cursors[id] = UI.create_cursor( filename, x, y ) end return @cursors[id] end |
.get_vector2d_cursor(screen_vector, view) ⇒ Integer?
Returns a cursor ID to a scaling direction cursor based on a 2D vector in screen space.
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'TT_Lib2/cursor.rb', line 200 def self.get_vector2d_cursor( screen_vector, view ) cursors = self.scale_handles cursor_id = nil nearest_angle = nil for vector, cursor in cursors a1 = vector.angle_between( screen_vector ).abs a2 = vector.angle_between( screen_vector.reverse ).abs angle = [ a1, a2 ].min if nearest_angle.nil? || angle < nearest_angle nearest_angle = angle cursor_id = cursor end end cursor_id end |
.get_vector3d_cursor(vector, view) ⇒ Integer?
Returns a cursor ID to a scaling direction cursor based on a 3D vector in model space.
224 225 226 227 228 229 230 231 232 233 |
# File 'TT_Lib2/cursor.rb', line 224 def self.get_vector3d_cursor( vector, view ) pt1 = ORIGIN pt2 = ORIGIN.offset( vector ) spt1 = view.screen_coords( pt1 ) spt2 = view.screen_coords( pt2 ) spt1.z = 0 spt2.z = 0 screen_vector = spt1.vector_to( spt2 ) self.get_vector2d_cursor( screen_vector, view ) end |
.scale_handles ⇒ Hash
237 238 239 240 |
# File 'TT_Lib2/cursor.rb', line 237 def self.scale_handles @scale_handles ||= self.compute_scale_handles @scale_handles end |