/
View.rb
1311 lines (1264 loc) · 40.8 KB
/
View.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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
122
123
124
125
126
127
128
129
130
131
132
133
134
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
176
177
178
179
180
181
182
183
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
245
246
247
248
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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
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
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright:: Copyright 2023 Trimble Inc.
# License:: The MIT License (MIT)
# This class contains methods to manipulate the current point of view of the
# model. The drawing methods here (draw_line, draw_polyline, etc) are meant to
# be invoked within a tool's Tool.draw method. Calling them outside Tool.draw
# will have no effect.
#
# You access the View by calling the Model.active_view method.
#
# @example
# view = Sketchup.active_model.active_view
#
# @version SketchUp 6.0
class Sketchup::View
# Instance Methods
# The add_observer method is used to add an observer to the current object.
#
# @example
# view = Sketchup.active_model.active_view
# status = view.add_observer observer
#
# @param [Object] observer
# An observer.
#
# @return [Boolean] true if successful, false if unsuccessful.
#
# @version SketchUp 6.0
def add_observer(observer)
end
# The {#animation=} method is used to set an animation that is displayed for a
# view. See {Sketchup::Animation} for details on how to create an animation object.
#
# @example
# animation = ViewSpinner.new
# model = Sketchup.active_model
# view = model.active_view
# anim = view.animation = animation
#
# @param [#nextFrame] animation
#
# @version SketchUp 6.0
def animation=(animation)
end
# The average_refresh_time is used to set the average time used to refresh the
# current model in the view. This can be used to estimate the frame rate for
# an animation.
#
# @example
# model = Sketchup.active_model
# view = model.active_view
# time = view.average_refresh_time
#
# @return [Float] the time in seconds
#
# @version SketchUp 6.0
def average_refresh_time
end
# The camera method is used to retrieve the camera for the view.
#
# @example
# camera = view.camera
#
# @return [Sketchup::Camera] a Camera object
#
# @version SketchUp 6.0
def camera
end
# The {#camera=} method is used to set the camera for the view. If a transition
# time is given, then it will animate the transition from the current camera
# to the new one.
#
# @example
# camera = Sketchup::Camera.new([5, 5, 9], [5, 10, 0], Z_AXIS)
# view = Sketchup.active_model.active_view
# view.camera = camera
#
# @overload camera=(camera)
#
# @param [Sketchup::Camera] camera The new camera object.
#
# @overload camera=(camera_and_transition)
#
# @param [Array(Sketchup::Camera, Float)] camera_and_transition
# The second item in the array represents the transition time from the
# existing camera to the new one.
#
# @version SketchUp 6.0
def camera=(arg)
end
# The center method is used to retrieve the coordinates of the center of the
# view in pixels. It is returned as an array of 2 values for x and y.
#
# @example
# model = Sketchup.active_model
# view = model.active_view
# c = view.center
#
# @return [Geom::Point3d] the center of the view
#
# @version SketchUp 6.0
def center
end
# The corner method is used to retrieve the coordinates of one of the corners
# of the view. The argument is an index between 0 and 3 that identifies which
# corner you want. This method returns an array with two integers which are
# the coordinates of the corner of the view in the view space. If the view
# uses a Camera with a fixed aspect ratio, then the corners are the corners of
# the viewing are of the camera which might be different than the actual
# corners of the view itself.
#
# The index numbers are as follows:
# - 0: top left,
# - 1: top right,
# - 2: bottom left,
# - 3: bottom right.
#
# @example
# point = view.corner index
#
# @param [Integer] index
# A value between (or including) 0 and 3 identifying the
# corner whose coordinate you want to retrieve.
#
# @return [Array(Integer, Integer)] a 2d array [w,h] representing the screen point
#
# @version SketchUp 6.0
def corner(index)
end
# The {#draw} method is used to do basic drawing. This method can only be
# called from within the {Tool#draw} method of a tool that you implement in
# Ruby.
#
# The following constants are all OpenGL terms and have been externalized to
# Ruby. Here is a summary of their meanings:
#
# [GL_POINTS]
# Treats each vertex as a single point. Vertex n defines point n. N
# points are drawn.
#
# [GL_LINES]
# Treats each pair of vertices as
# an independent line segment. Vertices 2n-1 and 2n define line n. N/2 lines
# are drawn.
#
# [GL_LINE_STRIP]
# Draws a connected group of line
# segments from the first vertex to the last. Vertices n and n+1 define
# line n. N-1 lines are drawn.
#
# [GL_LINE_LOOP]
# Draws a connected group of line segments from the first vertex to the last,
# then back to the first. Vertices n and n+1 define line n. The last line,
# however, is defined by vertices N and 1. N lines are drawn.
#
# [GL_TRIANGLES]
# Treats each triplet of vertices as an independent
# triangle. Vertices 3n-2, 3n-1, and 3n define triangle n. N/3 triangles are
# drawn.
#
# [GL_TRIANGLE_STRIP]
# Draws a connected group of triangles. One triangle is defined for each
# vertex presented after the first two vertices. For odd n, vertices n, n+1,
# and n+2 define triangle n. For even n, vertices n+1, n, and n+2 define
# triangle n. N-2 triangles are drawn.
#
# [GL_TRIANGLE_FAN]
# Draws a connected group of triangles.
# One triangle is defined for each vertex presented after the first two
# vertices. Vertices 1, n+1, and n+2 define triangle n. N-2 triangles are
# drawn.
#
# [GL_QUADS]
# Treats each group of four vertices as an
# independent quadrilateral. Vertices 4n-3, 4n-2, 4n-1, and 4n define
# quadrilateral n. N/4 quadrilaterals are drawn.
#
# [GL_QUAD_STRIP]
# Draws a connected group of quadrilaterals. One quadrilateral is
# defined for each pair of vertices presented after the first pair.
# Vertices 2n-1, 2n, 2n+2, and 2n+1 define quadrilateral n. N/2-1
# quadrilaterals are drawn. Note that the order in which vertices are used to
# construct a quadrilateral from strip data is different from that used with
# independent data.
#
# [GL_POLYGON]
# Draws a single, convex polygon. Vertices 1
# through N define this polygon.
#
# @example
# points = [
# Geom::Point3d.new(0, 0, 0),
# Geom::Point3d.new(9, 0, 0),
# Geom::Point3d.new(9, 9, 0),
# Geom::Point3d.new(0, 9, 0)
# ]
# view.draw(GL_LINE_LOOP, points)
#
# @note If you draw outside the model bounds you need to implement
# {Tool#getExtents} which returns a bounding box large enough to include the
# points you draw. Otherwise your drawing will be clipped.
#
# @overload draw(openglenum, points)
#
# @param [Integer] openglenum
# The item you are going to draw, one of the constants
# from the comments, such as +GL_LINES+.
# @param [Array<Geom::Point3d>] points
#
# @overload draw(openglenum, *points)
#
# @param [Integer] openglenum
# The item you are going to draw, one of the constants
# from the comments, such as +GL_LINES+.
# @param [Array<Geom::Point3d>] points
#
# @overload draw(openglenum, points, **options)
#
# @version SketchUp 2020.0
# @param [Integer] openglenum
# The item you are going to draw, one of the constants
# from the comments, such as +GL_LINES+.
# @param [Array<Geom::Point3d>] points
# @param [Hash] options
# @option options [Array<Geom::Vector3d>] :normals
# Without normals the polygons will be rendered with flat shading. No
# light will affect it. By providing an array of vertex normals lighting
# is turned on and will use the model's current light. Note that the number
# of normals must match the number of points provided.
# @option options [Integer] :texture
# A texture id provided by {#load_texture}.
# @option options [Array<Geom::Vector3d>] :uvs
# Set of UV (Not UVQ) coordinates matching the number of points provided.
# This must be used along with the +:texture+ option.
#
# @overload draw(openglenum, *points, **options)
#
# @version SketchUp 2020.0
# @param [Integer] openglenum
# The item you are going to draw, one of the constants
# from the comments, such as +GL_LINES+.
# @param [Array<Geom::Point3d>] points
# @param [Hash] options
# @option options [Array<Geom::Vector3d>] :normals ([])
# Without normals the polygons will be rendered with flat shading. No
# light will affect it. By providing an array of vertex normals lighting
# is turned on and will use the model's current light. Note that the number
# of normals must match the number of points provided.
# @option options [Integer] :texture
# A texture id provided by {#load_texture}.
# @option options [Array<Geom::Vector3d>] :uvs
# Set of UV (Not UVQ) coordinates matching the number of points provided.
# This must be used along with the +:texture+ option.
#
# @return [Sketchup::View]
#
# @see Tool#getExtents
#
# @version SketchUp 6.0
def draw(*args)
end
# The {#draw2d} method is used to draw in screen space (using 2D screen
# coordinates) instead of 3D space.
#
# The second parameter is an {Array} of {Geom::Point3d} objects (or several
# individual {Geom::Point3d} objects). These {Geom::Point3d} objects are in
# screen space, not 3D space.
# The X value corresponds to the number of pixels from the left edge of the
# drawing area. The Y value corresponds to the number of pixels down from
# the top of the drawing area. The Z value is not used.
#
# @example
# points = [
# Geom::Point3d.new(0, 0, 0),
# Geom::Point3d.new(8, 0, 0),
# Geom::Point3d.new(8, 4, 0),
# Geom::Point3d.new(0, 4, 0)
# ]
# view.draw2d(GL_LINE_STRIP, points)
#
# @overload draw2d(openglenum, points)
#
# @param [Integer] openglenum
# The item you are going to draw, one of the constants
# from the comments, such as +GL_LINES+.
# @param [Array<Geom::Point3d>] points
#
# @overload draw2d(openglenum, *points)
#
# @param [Integer] openglenum
# The item you are going to draw, one of the constants
# from the comments, such as +GL_LINES+.
# @param [Array<Geom::Point3d>] points
#
# @overload draw2d(openglenum, points, **options)
#
# @version SketchUp 2020.0
# @param [Integer] openglenum
# The item you are going to draw, one of the constants
# from the comments, such as +GL_LINES+.
# @param [Array<Geom::Point3d>] points
# @param [Hash] options
# @option options [Integer] :texture
# A texture id provided by {#load_texture}.
# @option options [Array<Geom::Vector3d>] :uvs
# Set of UV (Not UVQ) coordinates matching the number of points provided.
# This must be used along with the +:texture+ option.
#
# @overload draw2d(openglenum, *points, **options)
#
# @version SketchUp 2020.0
# @param [Integer] openglenum
# The item you are going to draw, one of the constants
# from the comments, such as +GL_LINES+.
# @param [Array<Geom::Point3d>] points
# @param [Hash] options
# @option options [Integer] :texture
# A texture id provided by {#load_texture}.
# @option options [Array<Geom::Vector3d>] :uvs
# Set of UV (Not UVQ) coordinates matching the number of points provided.
# This must be used along with the +:texture+ option.
#
# @return [Sketchup::View]
#
# @see #draw
#
# @see UI.scale_factor
#
# @version SketchUp 6.0
def draw2d(*args)
end
# The draw_lines method is used to draw disconnected lines.
#
# You must have an even number of points. This method is usually invoked
# within the draw method of a tool.
#
# @example
# point4 = Geom::Point3d.new 0,0,0
# point5 = Geom::Point3d.new 100,100,100
# # returns a view
# status = view.drawing_color="red"
# status = view.draw_lines point4, point5
#
# @overload draw_lines(points, ...)
#
# @param [Array<Geom::Point3d>] points
# An even number of Point3d objects.
# @return [Sketchup::View]
#
# @overload draw_lines(points)
#
# @param [Array<Geom::Point3d>] points An array of Point3d objects.
# @return [Sketchup::View]
#
# @version SketchUp 6.0
def draw_line(*args)
end
# The draw_lines method is used to draw disconnected lines.
#
# You must have an even number of points. This method is usually invoked
# within the draw method of a tool.
#
# @example
# point4 = Geom::Point3d.new 0,0,0
# point5 = Geom::Point3d.new 100,100,100
# # returns a view
# status = view.drawing_color="red"
# status = view.draw_lines point4, point5
#
# @overload draw_lines(points, ...)
#
# @param [Array<Geom::Point3d>] points
# An even number of Point3d objects.
# @return [Sketchup::View]
#
# @overload draw_lines(points)
#
# @param [Array<Geom::Point3d>] points An array of Point3d objects.
# @return [Sketchup::View]
#
# @version SketchUp 6.0
def draw_lines(*args)
end
# This method is used to draw points.
#
# This method is usually invoked within the draw method of a tool.
#
# @example
# point3 = Geom::Point3d.new 0,0,0
# # returns a view
# status = view.draw_points(point3, 10, 1, "red")
#
# @param [Array<Geom::Point3d>] points
#
# @param [Integer] size
# Size of the point in pixels.
#
# @param [Integer] style
# 1 = open square, 2 = filled square, 3 = "+", 4 = "X", 5 = "*",
# 6 = open triangle, 7 = filled triangle.
#
# @param [Sketchup::Color] color
#
# @return [Sketchup::View] a View object
#
# @version SketchUp 6.0
def draw_points(points, size = 6, style = 3, color = 'black')
end
# The draw_polyline method is used to draw a series of connected line segments
# from pt1 to pt2 to pt3, and so on.
#
# This method is usually invoked within the draw method of a tool.
#
# @example
# point12 = Geom::Point3d.new 0,0,0
# point13 = Geom::Point3d.new 10,10,10
# point14 = Geom::Point3d.new 20,20,20
# point15 = Geom::Point3d.new 30,30,30
# status = view.draw_polyline point12, point13, point14, point15
#
# @overload draw_polyline(points, ...)
#
# @param [Array<Geom::Point3d>] points An even number of Point3d objects.
# @return [Sketchup::View]
#
# @overload draw_polyline(points)
#
# @param [Array<Geom::Point3d>] points An array of Point3d objects.
# @return [Sketchup::View]
#
# @version SketchUp 6.0
def draw_polyline(*args)
end
# This method is used to draw text on the screen and is usually invoked within
# the draw method of a tool.
#
# The {TextVerticalAlignCenter} option will align the text to the center of the
# height of the first line, not the whole boundingbox of the text. To align
# around the full bounds of the text, use {#text_bounds} to compute the
# desired alignment.
#
# The vertical alignment can vary between fonts and platforms. It's recommended
# to test different fonts and find one that fits well across both platforms
# for your purposes.
#
# <b>Example of different vertical alignment and text bounds:</b>
#
# rdoc-image:../images/view-draw-text-with-bounds.png
#
# @bug Prior to SU2022.0, on macOS, the vertical text alignment for some fonts
# could appear to be offset from their expected positions. As of SU2022.0 the
# vertical alignment should be more accurate and consistent.
#
# @example
# class ExampleTool
# def draw(view)
# # This works in all SketchUp versions and draws the text using the
# # default font, size and color (i.e. the model edge color).
# point = Geom::Point3d.new(200, 100, 0)
# view.draw_text(point, "This is a test")
#
# # This works in SketchUp 2016 and up.
# options = {
# :font => "Arial",
# :size => 20,
# :bold => true,
# :align => TextAlignRight
# }
# point = Geom::Point3d.new(200, 200, 0)
# view.draw_text(point, "This is another\ntest", options)
#
# # You can also use Ruby 2.0's named arguments:
# point = Geom::Point3d.new(200, 200, 0)
# view.draw_text(point, "Hello world!", color: "Red")
# end
# end
#
# @example Cross Platform Font Size
# class ExampleTool
# IS_WIN = Sketchup.platform == :platform_win
#
# def draw(view)
# draw_text(view, [100, 200, 0], "Hello World", size: 20)
# end
#
# private
#
# # This will ensure text is drawn with consistent size across platforms,
# # using pixels as size units.
# def draw_text(view, position, text, **options)
# native_options = options.dup
# if IS_WIN && options.key?(:size)
# native_options[:size] = pixels_to_points(options[:size])
# end
# view.draw_text(position, text, **native_options)
# end
#
# def pixels_to_points(pixels)
# ((pixels.to_f / 96.0) * 72.0).round
# end
# end
#
# @note Under Windows the font name must be less than 32 characters - due to
# system limitations.
#
# @note As of SU2017 this will automatically scale the font-size by the same
# factor as {UI.scale_factor}.
#
# @note The font size is platform dependent. On Windows the method expects
# points, where on Mac it's pixels. See "Cross Platform Font Size" example
# for details.
#
# @overload draw_text(point, text)
#
# @param [Geom::Point3d] point A Point3d object representing a 2D coordinate
# in view space.
# @param [String] text The text string to draw.
#
# @overload draw_text(point, text, options = {})
#
# @version SketchUp 2016
# @param [Geom::Point3d] point A Point3d object representing a 2D coordinate
# in view space.
# @param [String] text The text string to draw.
# @param [Hash] options The text can be customized by providing a hash or
# named arguments of options.
# @option options [String] :font The name of the font to use. If it does not
# exist on the system, a default font will be used instead.
# @option options [Integer] :size The size of the font in points
# @option options [Boolean] :bold Controls the Bold property of the font.
# @option options [Boolean] :italic Controls the Italic property of the font.
# @option options [Sketchup::Color] :color The color to draw the text with.
# @option options [Integer] :align The text alignment, one of the following
# constants: {TextAlignLeft}, {TextAlignCenter} or {TextAlignRight}.
# @option options [Integer] :vertical_align <b>Added SketchUp 2020.0.</b>
# The vertical text alignment, one of the following constants:
# {TextVerticalAlignBoundsTop}, {TextVerticalAlignBaseline},
# {TextVerticalAlignCapHeight} or {TextVerticalAlignCenter}. Note that
# some fonts on Mac might not align as expected due to the system
# reporting incorrect font metrics.
#
# @return [Sketchup::View]
#
# @version SketchUp 6.0
def draw_text(*args)
end
# The drawing_color method is used to set the color that is used for drawing
# to the view.
#
# This method is usually invoked within the draw method of a tool.
#
# @example
# view = view.drawing_color = color
#
# @param [Sketchup::Color, String] color
# A Color object.
#
# @return [Sketchup::View]
#
# @version SketchUp 6.0
def drawing_color=(color)
end
# The dynamic= method allows you to degrade visual quality while improving
# performance when a model is large and view refresh time is slow. For
# example, if you were using a Ruby script to animate the camera through
# a large scene, you may want to set dynamic to true during that time.
#
# See also camera.rb which is part of the film and stage ruby
# scripts.
#
# @deprecated This method is no longer doing anything.
#
# @example
# view.dynamic = true
#
# @param [Boolean] value
#
# @return [Boolean]
#
# @version SketchUp 6.0
def dynamic=(value)
end
# The field_of_view method is used get the view's field of view setting, in
# degrees.
#
# @example
# fov = Sketchup.active_model.active_view.field_of_view
#
# @return [Float] the field of view
#
# @version SketchUp 6.0
def field_of_view
end
# The field_of_view= method is used set the view's field of view setting,
# in degrees.
#
# @example
# my_view = Sketchup.active_model.active_view
# my_view.field_of_view = 45
# my_view.invalidate
#
# @param [Numeric] fov
# the field of view
#
# @return [Numeric]
#
# @version SketchUp 6.0
def field_of_view=(fov)
end
# The guess_target method is used to guess at what the user is looking at when
# you have a perspective view.
#
# This method is useful when writing a viewing tool. See also camera.rb which
# is part of the film and stage ruby scripts.
#
# @example
# target = view.guess_target
#
# @return [Geom::Point3d] a Point3d object representing the point in the
# model that the user is likely interested in.
#
# @version SketchUp 6.0
def guess_target(*args)
end
# The inference_locked? method is used to determine if inference locking is on
# for the view.
#
# @example
# model = Sketchup.active_model
# view = model.active_view
# status = view.inference_locked
#
# @return [Boolean]
#
# @version SketchUp 6.0
def inference_locked?
end
# The inputpoint method is used to retrieve an input point.
#
# This will normally be used inside one of the mouse event handling methods in
# a tool. Usually, it is preferable to create the InputPoint first and then
# use the pick method on it.
#
# @example
# inputpoint = view.inputpoint x, y, inputpoint1
#
# @param [Numeric] x
# A x value.
#
# @param [Numeric] y
# A y value.
#
# @param [Sketchup::InputPoint] inputpoint1
# An InputPoint object.
#
# @return [Sketchup::InputPoint]
#
# @version SketchUp 6.0
def inputpoint(x, y, inputpoint1)
end
# The invalidate method is used mark the view as in need of a redraw.
#
# @example
# model = Sketchup.active_model
# view = model.active_view
# invalidated_view = view.invalidate
#
# @note This is the preferred method to update the viewport. Use this before
# trying to use {#refresh}.
#
# @return [Sketchup::View] the invalidated View object
#
# @version SketchUp 6.0
def invalidate
end
# The last_refresh_time method is used to retrieve the time for the last full
# view refresh.
#
# @example
# time = view.last_refresh_time
#
# @return [Float] time in milliseconds
#
# @version SketchUp 6.0
def last_refresh_time(*args)
end
# The line_stipple= method is used to set the line pattern to use for drawing.
# The stipple pattern is given as a string.
# Valid strings are:
# "." (Dotted Line),
# "-" (Short Dashes Line),
# "_" (Long Dashes Line),
# "-.-" (Dash Dot Dash Line),
# "" (Solid Line).
#
# This method is usually invoked within the draw method of a tool.
#
# @example
# point8 = Geom::Point3d.new 0,0,0
# point9 = Geom::Point3d.new 100,100,100
# view.line_stipple = "-.-"
# view = view.draw_lines point8, point9
#
# @param [String] pattern
# A string stipple pattern, such as "-.-"
#
# @return [Sketchup::View] the View object
#
# @version SketchUp 6.0
def line_stipple=(pattern)
end
# The line_width= method is used to set the line width to use for drawing. The
# value is a Double indicating the desired width in pixels.
#
# This method is usually invoked within the draw method of a tool.
#
# @example
# view.line_width = width
#
# @note As of SU2017 this will automatically scale the line width by the same
# factor as {UI.scale_factor}.
#
# @param [Integer] width
# The width in pixels.
#
# @return [Integer]
#
# @version SketchUp 6.0
def line_width=(width)
end
# Loads a texture to be drawn with {#draw} or {#draw2d}.
#
# @example
# module Example
# class MyTool
# def activate
# view = Sketchup.active_model.active_view
# image_rep = view.model.materials.current.texture.image_rep
# @texture_id = view.load_texture(image_rep)
# end
#
# def deactivate(view)
# view.release_texture(@texture_id)
# end
#
# def draw(view)
# points = [ [0, 0, 0], [9, 0, 0], [9, 9, 0], [0, 9, 0] ]
# uvs = [ [0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0] ]
# view.draw(GL_QUADS, points, texture: @texture_id, uvs: uvs)
# end
# end
# end
# Sketchup.active_model.select_tool(Example::MyTool.new)
#
# @note Avoid loading and releasing textures within the {Sketchup::Tool#draw}
# event as that is not efficient.
#
# @note SketchUp 2020.0-2022.0: To conserve resources on the user's machine,
# textures can be loaded only when there is a Ruby tool on the tool stack.
# Make sure to release the texture when it's no longer needed. Any textures
# not already released when the last Ruby tool on the tool stack is removed
# will be automatically released by SketchUp. As of SketchUp 2023.0 this
# automatic cleanup was removed to allow Overlays to draw textures.
#
# @param [Sketchup::ImageRep] image_rep
#
# @raise [ArgumentError] if the provided {Sketchup::ImageRep} is not valid.
#
# @raise [RuntimeError] if a Ruby tool was not on the tool stack.
# (Applies to SketchUp 2020.0-2022.0).
#
# @return [Integer] A resource ID referring to the image loaded.
#
# @see #release_texture
#
# @see #draw
#
# @version SketchUp 2020.0
def load_texture(image_rep)
end
# The {#lock_inference} method is used to lock or unlock an inference.
#
# This method will typically be called from inside a tool class when the user
# presses the shift key or arrow keys.
#
# With no arguments it unlocks all inferences. With one argument it locks
# inference based on that passed {Sketchup::InputPoint}'s entities, e.g. along
# a {Sketchup::Edge}'s line or a {Sketchup::Face}'s plane. With two arguments,
# it locks inference along an axis.
#
# @example
# view = view.lock_inference
# view = view.lock_inference(inputpoint)
# view = view.lock_inference(inputpoint1, inputpoint2)
#
# @overload lock_inference
#
#
# @overload lock_inference(inputpoint)
#
# @param [Sketchup::InputPoint] inputpoint
#
# @overload lock_inference(inputpoint, inputpoint2)
#
# @param [Sketchup::InputPoint] inputpoint
# @param [Sketchup::InputPoint] inputpoint2
# @example
# # Lock inference to X axis.
# # The points can be anywhere; only the vector between them affects
# # the result.
# view.lock_inference(
# Sketchup::InputPoint.new(ORIGIN),
# Sketchup::InputPoint.new(Geom::Point3d.new(1, 0, 0))
# )
#
# @return [Sketchup::View] a View object
#
# @version SketchUp 6.0
def lock_inference(*args)
end
# The model method is used to retrieve the model for the current view.
#
# @example
# model = view.model
#
# @return [Sketchup::Model] the model for this view
#
# @version SketchUp 6.0
def model
end
# The pick_helper method is used to retrieve a pick helper for the view. See
# the PickHelper class for information on pick helpers.
#
# This call returns an initialized PickHelper.
#
# @example
# model = Sketchup.active_model
# view = model.active_view
# ph = view.pick_helper
#
# @overload pick_helper
#
# @return [Sketchup::PickHelper] a PickHelper object
#
# @overload pick_helper(x, y, aperture = 0)
#
# @param [Integer] x
# @param [Integer] y
# @param [Integer] aperture
# @return [Sketchup::PickHelper] a PickHelper object
#
# @version SketchUp 6.0
def pick_helper(*args)
end
# The pickray method is used to retrieve a ray passing through a given screen
# position in the viewing direction.
#
# @example
# ray = view.pickray x, y
#
# @overload pickray(screen_point)
#
# @param [Array(Integer, Integer)] screen_point
# @return [Array(Geom::Point3d, Geom::Vector3d)] a ray
#
# @overload pickray(x, y)
#
# @param [Integer] x
# @param [Integer] y
# @return [Array(Geom::Point3d, Geom::Vector3d)] a ray
#
# @version SketchUp 6.0
def pickray(*args)
end
# The pixels_to_model method is used to compute a model size from a pixel size
# at a given point.
#
# This method is useful for deciding how big to draw something based on a
# desired size in pixels.
#
# @example
# size = view.pixels_to_model(pixels, point)
#
# @note As of SU2017 this will automatically scale the pixel-size by the same
# factor as {UI.scale_factor}.
#
# @param [Numeric] pixels
# The pixel size.
#
# @param [Geom::Point3d] point
# A Point3d object where the size will be calculated from.
#
# @return [Float] the model size
#
# @version SketchUp 6.0
def pixels_to_model(pixels, point)
end
# The refresh method is used to immediately force a redraw of the view.
#
# @example
# model = Sketchup.active_model
# view = model.active_view
# refreshed_view = view.refresh
#
# @note This method might impact performance and if used incorrectly cause
# instability or crashes. Don't use this unless you have verified that
# you cannot use {#invalidate} instead.
#
# @return [Sketchup::View] the refreshed View object
#
# @version SketchUp 7.1
def refresh
end
# Releases a texture loaded via {#load_texture}, freeing up it's memory.
# It's good practice to do so whenever there is no longer any need for the
# resource.
#
# For example, when your tool deactivates you probably want to release your
# resources as you don't know if your tool will be used again.
#
# @example
# module Example
# class MyTool
# def activate
# view = Sketchup.active_model.active_view
# image_rep = view.model.materials.current.texture.image_rep
# @texture_id = view.load_texture(image_rep)
# end
#
# def deactivate(view)
# view.release_texture(@texture_id)
# end
#
# def draw(view)
# points = [ [0, 0, 0], [9, 0, 0], [9, 9, 0], [0, 9, 0] ]
# uvs = [ [0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0] ]
# view.draw(GL_QUADS, points, texture: @texture_id, uvs: uvs)
# end
# end
# end
# Sketchup.active_model.select_tool(Example::MyTool.new)
#
# @param [Integer] texture_id
#
# @return [Boolean] +true+ if texture was released. +false+ otherwise.
#
# @see #load_texture
def release_texture(texture_id)
end
# The remove_observer method is used to remove an observer from the current
# object.
#
# @example
# view = Sketchup.active_model.active_view
# status = view.remove_observer observer
#
# @param [Object] observer
# An observer.
#
# @return [Boolean] true if successful, false if unsuccessful.
#
# @version SketchUp 6.0
def remove_observer(observer)
end