cosmos 3.6.2 → 3.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/data/crc.txt +19 -19
- data/lib/cosmos/core_ext/array.rb +4 -1
- data/lib/cosmos/core_ext/matrix.rb +3 -0
- data/lib/cosmos/gui/dialogs/find_replace_dialog.rb +42 -35
- data/lib/cosmos/gui/line_graph/line_graph.rb +3 -0
- data/lib/cosmos/gui/line_graph/line_graph_drawing.rb +3 -1
- data/lib/cosmos/gui/opengl/gl_viewer.rb +115 -127
- data/lib/cosmos/gui/utilities/script_module_gui.rb +2 -5
- data/lib/cosmos/interfaces/linc_interface.rb +207 -147
- data/lib/cosmos/io/win32_serial_driver.rb +1 -1
- data/lib/cosmos/script/scripting.rb +2 -2
- data/lib/cosmos/script/tools.rb +8 -1
- data/lib/cosmos/tools/data_viewer/data_viewer.rb +12 -17
- data/lib/cosmos/tools/launcher/launcher_config.rb +1 -1
- data/lib/cosmos/tools/script_runner/script_runner.rb +9 -4
- data/lib/cosmos/tools/table_manager/table_manager.rb +3 -1
- data/lib/cosmos/tools/tlm_grapher/plot_editors/linegraph_plot_editor.rb +11 -1
- data/lib/cosmos/tools/tlm_grapher/plot_gui_objects/linegraph_plot_gui_object.rb +1 -0
- data/lib/cosmos/tools/tlm_grapher/plots/linegraph_plot.rb +8 -0
- data/lib/cosmos/version.rb +4 -4
- data/spec/core_ext/array_spec.rb +62 -1
- data/spec/core_ext/matrix_spec.rb +61 -0
- data/spec/interfaces/linc_interface_spec.rb +0 -9
- data/spec/script/script_spec.rb +7 -3
- data/spec/script/scripting_spec.rb +2 -2
- data/spec/script/tools_spec.rb +2 -0
- data/spec/spec_helper.rb +10 -1
- data/spec/tools/launcher/launcher_config_spec.rb +21 -11
- data/spec/top_level/top_level_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c086907a0e1bda08352520d1a264be73867cde38
|
4
|
+
data.tar.gz: 6ae05f354e92bb9331bbea4a49689580a3e78e9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cac5dbce95e3e6893fb81f9bcb56738a7bd15c89e3e2f63aba7e04e5989cba2a5b3d3b9fb72230c1dc4f4a306fe71dd8d7b1e2948c1a2273bf613132cb9b3f42
|
7
|
+
data.tar.gz: 32ff6b4ff7946905dfc52dfe71d00978d76d3a333a2ec849cb441076bbca9f1e41c313ededa8931ff39fd3dd00fe17f0e344c1c8edb97e8e2286ed028722e69e
|
data/data/crc.txt
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
"lib/cosmos/utilities/low_fragmentation_array.rb" 0x7E797C76
|
35
35
|
"lib/cosmos/utilities/simulated_target.rb" 0x7EE7A3FF
|
36
36
|
"lib/cosmos/gui/qt.rb" 0x090A21D1
|
37
|
-
"lib/cosmos/gui/dialogs/find_replace_dialog.rb"
|
37
|
+
"lib/cosmos/gui/dialogs/find_replace_dialog.rb" 0xE5BA1A34
|
38
38
|
"lib/cosmos/gui/dialogs/set_tlm_dialog.rb" 0x02A207C9
|
39
39
|
"lib/cosmos/gui/dialogs/exception_dialog.rb" 0xEAC9F814
|
40
40
|
"lib/cosmos/gui/dialogs/tlm_edit_dialog.rb" 0xCD877DDA
|
@@ -53,14 +53,14 @@
|
|
53
53
|
"lib/cosmos/gui/dialogs/tlm_details_dialog.rb" 0x18B1DB71
|
54
54
|
"lib/cosmos/gui/dialogs/calendar_dialog.rb" 0x688D3D3B
|
55
55
|
"lib/cosmos/gui/qt_tool.rb" 0x5EC8FC5F
|
56
|
-
"lib/cosmos/gui/utilities/script_module_gui.rb"
|
56
|
+
"lib/cosmos/gui/utilities/script_module_gui.rb" 0x2AA7C2F8
|
57
57
|
"lib/cosmos/gui/utilities/screenshot.rb" 0x65F75371
|
58
58
|
"lib/cosmos/gui/widgets/full_text_search_line_edit.rb" 0x7AAF694C
|
59
59
|
"lib/cosmos/gui/widgets/realtime_button_bar.rb" 0xEB0CE858
|
60
60
|
"lib/cosmos/gui/widgets/packet_log_frame.rb" 0xF9312CBD
|
61
|
-
"lib/cosmos/gui/line_graph/line_graph.rb"
|
61
|
+
"lib/cosmos/gui/line_graph/line_graph.rb" 0x15D29433
|
62
62
|
"lib/cosmos/gui/line_graph/line_graph_popups.rb" 0x6B6BD351
|
63
|
-
"lib/cosmos/gui/line_graph/line_graph_drawing.rb"
|
63
|
+
"lib/cosmos/gui/line_graph/line_graph_drawing.rb" 0xEC9FEECC
|
64
64
|
"lib/cosmos/gui/line_graph/overview_graph.rb" 0x8FCDCE33
|
65
65
|
"lib/cosmos/gui/line_graph/line_graph_dialog.rb" 0xF73F68CB
|
66
66
|
"lib/cosmos/gui/line_graph/lines.rb" 0x871CA030
|
@@ -76,7 +76,7 @@
|
|
76
76
|
"lib/cosmos/gui/opengl/gl_material.rb" 0xA2356712
|
77
77
|
"lib/cosmos/gui/opengl/moon_model.rb" 0xC84B01EC
|
78
78
|
"lib/cosmos/gui/opengl/stl_reader.rb" 0x791FB9EB
|
79
|
-
"lib/cosmos/gui/opengl/gl_viewer.rb"
|
79
|
+
"lib/cosmos/gui/opengl/gl_viewer.rb" 0xCBFBC60C
|
80
80
|
"lib/cosmos/gui/opengl/gl_scene.rb" 0x0EABB1A2
|
81
81
|
"lib/cosmos/gui/opengl/gl_light.rb" 0xDF6C13EA
|
82
82
|
"lib/cosmos/gui/opengl/earth_model.rb" 0xF5CC4C1D
|
@@ -91,15 +91,15 @@
|
|
91
91
|
"lib/cosmos/gui/choosers/float_chooser.rb" 0x23B2FA77
|
92
92
|
"lib/cosmos/tools/script_runner/script_runner_config.rb" 0x1E46E8AA
|
93
93
|
"lib/cosmos/tools/script_runner/script_runner_frame.rb" 0x6FEE12DB
|
94
|
-
"lib/cosmos/tools/script_runner/script_runner.rb"
|
94
|
+
"lib/cosmos/tools/script_runner/script_runner.rb" 0x0CC0CBB4
|
95
95
|
"lib/cosmos/tools/script_runner/script_audit.rb" 0xB857FA4A
|
96
96
|
"lib/cosmos/tools/cmd_extractor/cmd_extractor.rb" 0x41CF52C2
|
97
97
|
"lib/cosmos/tools/data_viewer/data_viewer_component.rb" 0x3525E13F
|
98
98
|
"lib/cosmos/tools/data_viewer/dump_component.rb" 0x6942C5D6
|
99
|
-
"lib/cosmos/tools/data_viewer/data_viewer.rb"
|
99
|
+
"lib/cosmos/tools/data_viewer/data_viewer.rb" 0x53FF80A9
|
100
100
|
"lib/cosmos/tools/launcher/launcher_multitool.rb" 0x1020A3D0
|
101
101
|
"lib/cosmos/tools/launcher/launcher_tool.rb" 0xE2F186A7
|
102
|
-
"lib/cosmos/tools/launcher/launcher_config.rb"
|
102
|
+
"lib/cosmos/tools/launcher/launcher_config.rb" 0x569C343D
|
103
103
|
"lib/cosmos/tools/launcher/launcher.rb" 0xAF399283
|
104
104
|
"lib/cosmos/tools/replay/replay_server.rb" 0x307A7329
|
105
105
|
"lib/cosmos/tools/replay/replay.rb" 0x79D68481
|
@@ -127,7 +127,7 @@
|
|
127
127
|
"lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb" 0x50E37D3B
|
128
128
|
"lib/cosmos/tools/limits_monitor/limits_monitor.rb" 0x0321B411
|
129
129
|
"lib/cosmos/tools/packet_viewer/packet_viewer.rb" 0x859EC490
|
130
|
-
"lib/cosmos/tools/table_manager/table_manager.rb"
|
130
|
+
"lib/cosmos/tools/table_manager/table_manager.rb" 0x05E19031
|
131
131
|
"lib/cosmos/tools/table_manager/table.rb" 0x923A8589
|
132
132
|
"lib/cosmos/tools/table_manager/table_item.rb" 0x08A9A262
|
133
133
|
"lib/cosmos/tools/table_manager/table_manager_core.rb" 0xE5C42A6A
|
@@ -143,7 +143,7 @@
|
|
143
143
|
"lib/cosmos/tools/test_runner/test.rb" 0x264AB62E
|
144
144
|
"lib/cosmos/tools/tlm_grapher/plots/xy_plot.rb" 0x98F7712F
|
145
145
|
"lib/cosmos/tools/tlm_grapher/plots/singlexy_plot.rb" 0xA01649EC
|
146
|
-
"lib/cosmos/tools/tlm_grapher/plots/linegraph_plot.rb"
|
146
|
+
"lib/cosmos/tools/tlm_grapher/plots/linegraph_plot.rb" 0x487D5301
|
147
147
|
"lib/cosmos/tools/tlm_grapher/plots/plot.rb" 0xAD4F05B5
|
148
148
|
"lib/cosmos/tools/tlm_grapher/data_object_editors/linegraph_data_object_editor.rb" 0xC23AA3F6
|
149
149
|
"lib/cosmos/tools/tlm_grapher/data_object_editors/data_object_editor.rb" 0x6A92FD7C
|
@@ -162,12 +162,12 @@
|
|
162
162
|
"lib/cosmos/tools/tlm_grapher/plot_editors/plot_editor.rb" 0x0C92BBB8
|
163
163
|
"lib/cosmos/tools/tlm_grapher/plot_editors/xy_plot_editor.rb" 0x724D9469
|
164
164
|
"lib/cosmos/tools/tlm_grapher/plot_editors/singlexy_plot_editor.rb" 0xA9B7CD4C
|
165
|
-
"lib/cosmos/tools/tlm_grapher/plot_editors/linegraph_plot_editor.rb"
|
165
|
+
"lib/cosmos/tools/tlm_grapher/plot_editors/linegraph_plot_editor.rb" 0x38E79C34
|
166
166
|
"lib/cosmos/tools/tlm_grapher/data_object_adders/housekeeping_data_object_adder.rb" 0xDC2B0DD3
|
167
167
|
"lib/cosmos/tools/tlm_grapher/data_object_adders/singlexy_data_object_adder.rb" 0x74CEA56E
|
168
168
|
"lib/cosmos/tools/tlm_grapher/data_object_adders/xy_data_object_adder.rb" 0x552F8C1F
|
169
169
|
"lib/cosmos/tools/tlm_grapher/plot_gui_objects/singlexy_plot_gui_object.rb" 0x4FC1C15C
|
170
|
-
"lib/cosmos/tools/tlm_grapher/plot_gui_objects/linegraph_plot_gui_object.rb"
|
170
|
+
"lib/cosmos/tools/tlm_grapher/plot_gui_objects/linegraph_plot_gui_object.rb" 0xBD8282FB
|
171
171
|
"lib/cosmos/tools/tlm_grapher/plot_gui_objects/xy_plot_gui_object.rb" 0xA500650F
|
172
172
|
"lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb" 0xCD684000
|
173
173
|
"lib/cosmos/tools/tlm_grapher/data_objects/singlexy_data_object.rb" 0x1D037935
|
@@ -234,7 +234,7 @@
|
|
234
234
|
"lib/cosmos/tools/tlm_viewer/tlm_viewer.rb" 0x895983E9
|
235
235
|
"lib/cosmos/system.rb" 0x735DFB42
|
236
236
|
"lib/cosmos/conversions.rb" 0x43679D05
|
237
|
-
"lib/cosmos/version.rb"
|
237
|
+
"lib/cosmos/version.rb" 0x52D8F90A
|
238
238
|
"lib/cosmos/core_ext.rb" 0x1951B346
|
239
239
|
"lib/cosmos/interfaces.rb" 0x7E3EA326
|
240
240
|
"lib/cosmos/processors.rb" 0x5241327D
|
@@ -289,8 +289,8 @@
|
|
289
289
|
"lib/cosmos/io/json_drb.rb" 0x495EB58B
|
290
290
|
"lib/cosmos/io/stderr.rb" 0x401624AF
|
291
291
|
"lib/cosmos/io/io_multiplexer.rb" 0xD183938D
|
292
|
-
"lib/cosmos/io/win32_serial_driver.rb"
|
293
|
-
"lib/cosmos/interfaces/linc_interface.rb"
|
292
|
+
"lib/cosmos/io/win32_serial_driver.rb" 0xB5AF7D58
|
293
|
+
"lib/cosmos/interfaces/linc_interface.rb" 0x2E216D93
|
294
294
|
"lib/cosmos/interfaces/cmd_tlm_server_interface.rb" 0x36E0796A
|
295
295
|
"lib/cosmos/interfaces/interface.rb" 0x060825FA
|
296
296
|
"lib/cosmos/interfaces/stream_interface.rb" 0xDC602D7B
|
@@ -303,8 +303,8 @@
|
|
303
303
|
"lib/cosmos/script/commands.rb" 0x58ABA373
|
304
304
|
"lib/cosmos/script/telemetry.rb" 0x2AFB0DCB
|
305
305
|
"lib/cosmos/script/cmd_tlm_server.rb" 0x15F91C95
|
306
|
-
"lib/cosmos/script/scripting.rb"
|
307
|
-
"lib/cosmos/script/tools.rb"
|
306
|
+
"lib/cosmos/script/scripting.rb" 0x36D00CDC
|
307
|
+
"lib/cosmos/script/tools.rb" 0x18E9BE05
|
308
308
|
"lib/cosmos/script/script.rb" 0xF1B3E1F2
|
309
309
|
"lib/cosmos/script/extract.rb" 0xCF4666D3
|
310
310
|
"lib/cosmos/core_ext/range.rb" 0x0D55D9D1
|
@@ -312,7 +312,7 @@
|
|
312
312
|
"lib/cosmos/core_ext/file.rb" 0x1309270C
|
313
313
|
"lib/cosmos/core_ext/socket.rb" 0xB859FE77
|
314
314
|
"lib/cosmos/core_ext/cosmos_io.rb" 0xF098AAE0
|
315
|
-
"lib/cosmos/core_ext/array.rb"
|
315
|
+
"lib/cosmos/core_ext/array.rb" 0x660BC482
|
316
316
|
"lib/cosmos/core_ext/class.rb" 0x858C349B
|
317
317
|
"lib/cosmos/core_ext/objectspace.rb" 0x2CDC9CA2
|
318
318
|
"lib/cosmos/core_ext/math.rb" 0xEFD1636D
|
@@ -322,5 +322,5 @@
|
|
322
322
|
"lib/cosmos/core_ext/exception.rb" 0x695F7020
|
323
323
|
"lib/cosmos/core_ext/string.rb" 0xE82EACEE
|
324
324
|
"lib/cosmos/core_ext/hash.rb" 0x99038BE1
|
325
|
-
"lib/cosmos/core_ext/matrix.rb"
|
325
|
+
"lib/cosmos/core_ext/matrix.rb" 0x9DDBCA0B
|
326
326
|
"lib/cosmos.rb" 0x116E7B3E
|
@@ -205,7 +205,10 @@ class Array
|
|
205
205
|
# start_value and end_value
|
206
206
|
def range_within(start_value, end_value)
|
207
207
|
raise "end_value: #{end_value} must be greater than start_value: #{start_value}" if end_value < start_value
|
208
|
-
Range.new(index_gt_eq(start_value), index_lt_eq(end_value))
|
208
|
+
range = Range.new(index_gt_eq(start_value), index_lt_eq(end_value))
|
209
|
+
# Sometimes we get a backwards range so check for that and reverse it
|
210
|
+
range = Range.new(range.last, range.first) if range.last < range.first
|
211
|
+
range
|
209
212
|
end
|
210
213
|
|
211
214
|
if !(self.method_defined?(:sum))
|
@@ -19,54 +19,60 @@ module Cosmos
|
|
19
19
|
include Singleton
|
20
20
|
|
21
21
|
# Displays a Find dialog
|
22
|
-
# @param
|
23
|
-
|
24
|
-
|
22
|
+
# @param parent [Qt::Widget] Dialog parent which must implement a
|
23
|
+
# search_text method which returns a String to search on
|
24
|
+
def self.show_find(parent)
|
25
|
+
self.instance.show_find(parent)
|
25
26
|
end
|
26
|
-
def show_find(
|
27
|
+
def show_find(parent)
|
28
|
+
@parent = parent
|
27
29
|
disable_replace
|
28
|
-
show_dialog
|
30
|
+
show_dialog
|
29
31
|
end
|
30
32
|
|
31
33
|
# Displays a Find/Replace dialog
|
32
|
-
# @param
|
33
|
-
|
34
|
-
|
34
|
+
# @param parent [Qt::Widget] Dialog parent which must implement a
|
35
|
+
# search_text method which returns a String to search on
|
36
|
+
def self.show_replace(parent)
|
37
|
+
self.instance.show_replace(parent)
|
35
38
|
end
|
36
|
-
def show_replace(
|
39
|
+
def show_replace(parent)
|
40
|
+
@parent = parent
|
37
41
|
enable_replace
|
38
|
-
show_dialog
|
42
|
+
show_dialog
|
39
43
|
end
|
40
44
|
|
41
|
-
# @param
|
42
|
-
|
43
|
-
|
45
|
+
# @param parent [#search_text] Object which must implement a
|
46
|
+
# search_text method which returns a String to search on
|
47
|
+
def self.find_next(parent)
|
48
|
+
self.instance.find_next(parent)
|
44
49
|
end
|
45
|
-
def find_next(
|
50
|
+
def find_next(parent)
|
46
51
|
flags = find_flags()
|
47
52
|
flags &= ~Qt::TextDocument::FindBackward.to_i
|
48
|
-
found =
|
53
|
+
found = parent.search_text.find(find_text(), flags)
|
49
54
|
if not found and wrap_around?
|
50
|
-
cursor =
|
55
|
+
cursor = parent.search_text.textCursor
|
51
56
|
cursor.movePosition(Qt::TextCursor::Start)
|
52
|
-
|
53
|
-
|
57
|
+
parent.search_text.setTextCursor(cursor)
|
58
|
+
parent.search_text.find(find_text(), flags)
|
54
59
|
end
|
55
60
|
end
|
56
61
|
|
57
|
-
# @param
|
58
|
-
|
59
|
-
|
62
|
+
# @param parent [#search_text] Object which must implement a
|
63
|
+
# search_text method which returns a String to search on
|
64
|
+
def self.find_previous(parent)
|
65
|
+
self.instance.find_previous(parent)
|
60
66
|
end
|
61
|
-
def find_previous(
|
67
|
+
def find_previous(parent)
|
62
68
|
flags = find_flags()
|
63
69
|
flags |= Qt::TextDocument::FindBackward.to_i
|
64
|
-
found =
|
70
|
+
found = parent.search_text.find(find_text(), flags)
|
65
71
|
if not found and wrap_around?
|
66
|
-
cursor =
|
72
|
+
cursor = parent.search_text.textCursor
|
67
73
|
cursor.movePosition(Qt::TextCursor::End)
|
68
|
-
|
69
|
-
|
74
|
+
parent.search_text.setTextCursor(cursor)
|
75
|
+
parent.search_text.find(find_text(), flags)
|
70
76
|
end
|
71
77
|
end
|
72
78
|
|
@@ -156,10 +162,10 @@ module Cosmos
|
|
156
162
|
button_layout
|
157
163
|
end
|
158
164
|
|
159
|
-
def show_dialog
|
165
|
+
def show_dialog
|
160
166
|
@find_box.selectAll
|
161
167
|
@find_box.setFocus(Qt::PopupFocusReason)
|
162
|
-
setParent(
|
168
|
+
setParent(@parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | 3)
|
163
169
|
show()
|
164
170
|
end
|
165
171
|
|
@@ -198,7 +204,7 @@ module Cosmos
|
|
198
204
|
end
|
199
205
|
|
200
206
|
def handle_find_next
|
201
|
-
text =
|
207
|
+
text = @parent.search_text
|
202
208
|
found = text.find(find_text, find_flags)
|
203
209
|
if not found and wrap_around?
|
204
210
|
cursor = text.textCursor
|
@@ -213,7 +219,7 @@ module Cosmos
|
|
213
219
|
end
|
214
220
|
|
215
221
|
def handle_replace
|
216
|
-
text =
|
222
|
+
text = @parent.search_text
|
217
223
|
if text.textCursor.hasSelection &&
|
218
224
|
text.textCursor.selectedText == find_text
|
219
225
|
found = true
|
@@ -231,17 +237,18 @@ module Cosmos
|
|
231
237
|
end
|
232
238
|
end
|
233
239
|
if found
|
234
|
-
text.textCursor.removeSelectedText
|
235
|
-
text.textCursor.insertText(replace_text)
|
236
240
|
cursor = text.textCursor
|
237
|
-
cursor.
|
238
|
-
cursor.
|
241
|
+
cursor.removeSelectedText
|
242
|
+
position = cursor.position
|
243
|
+
cursor.insertText(replace_text)
|
244
|
+
# Move the cursor back over the inserted text to select it
|
245
|
+
cursor.movePosition(Qt::TextCursor::PreviousCharacter, Qt::TextCursor::KeepAnchor, replace_text.length)
|
239
246
|
text.setTextCursor(cursor)
|
240
247
|
end
|
241
248
|
end
|
242
249
|
|
243
250
|
def handle_replace_all
|
244
|
-
text =
|
251
|
+
text = @parent.search_text
|
245
252
|
cursor = text.textCursor
|
246
253
|
# Start the edit block so this can be all undone with a single undo step
|
247
254
|
cursor.beginEditBlock
|
@@ -79,6 +79,8 @@ module Cosmos
|
|
79
79
|
attr_accessor_with_redraw :show_popup_x_y
|
80
80
|
# Use x_value as floating point UTC timestamp with unix epoch
|
81
81
|
attr_accessor_with_redraw :unix_epoch_x_values
|
82
|
+
# Display x_value as UTC timestamp
|
83
|
+
attr_accessor_with_redraw :utc_time
|
82
84
|
|
83
85
|
#########################################################################
|
84
86
|
# Callback attributes
|
@@ -145,6 +147,7 @@ module Cosmos
|
|
145
147
|
@ordered_x_values = true
|
146
148
|
@show_popup_x_y = false
|
147
149
|
@unix_epoch_x_values = true
|
150
|
+
@utc_time = false
|
148
151
|
|
149
152
|
# Initialize the callbacks
|
150
153
|
@draw_cursor_line_callback = nil
|
@@ -247,7 +247,9 @@ module Cosmos
|
|
247
247
|
def convert_x_value_to_text(value, max_characters)
|
248
248
|
if !@show_popup_x_y and @unix_epoch_x_values
|
249
249
|
if (value > 1 and value < 2147483647)
|
250
|
-
|
250
|
+
time = Time.at(value.to_f)
|
251
|
+
time = time.utc if @utc_time
|
252
|
+
text = time.formatted(false) # no year
|
251
253
|
else
|
252
254
|
text = value.to_s
|
253
255
|
end
|
@@ -302,29 +302,11 @@ module Cosmos
|
|
302
302
|
# Preferred blend over background
|
303
303
|
GL.BlendFunc(GL::SRC_ALPHA, GL::ONE_MINUS_SRC_ALPHA)
|
304
304
|
|
305
|
-
|
306
|
-
GL.Enable(GL::LIGHT0)
|
307
|
-
GL.Light(GL::LIGHT0, GL::AMBIENT, @light.ambient)
|
308
|
-
GL.Light(GL::LIGHT0, GL::DIFFUSE, @light.diffuse)
|
309
|
-
GL.Light(GL::LIGHT0, GL::SPECULAR, @light.specular)
|
310
|
-
GL.Light(GL::LIGHT0, GL::POSITION, @light.position)
|
311
|
-
GL.Light(GL::LIGHT0, GL::SPOT_DIRECTION, @light.direction)
|
312
|
-
GL.Lightf(GL::LIGHT0, GL::SPOT_EXPONENT, @light.exponent)
|
313
|
-
GL.Lightf(GL::LIGHT0, GL::SPOT_CUTOFF, @light.cutoff)
|
314
|
-
GL.Lightf(GL::LIGHT0, GL::CONSTANT_ATTENUATION, @light.c_attn)
|
315
|
-
GL.Lightf(GL::LIGHT0, GL::LINEAR_ATTENUATION, @light.l_attn)
|
316
|
-
GL.Lightf(GL::LIGHT0, GL::QUADRATIC_ATTENUATION, @light.q_attn)
|
317
|
-
|
305
|
+
enable_light(@light)
|
318
306
|
# Viewer is close
|
319
307
|
GL.LightModeli(GL::LIGHT_MODEL_LOCAL_VIEWER, 1)
|
320
308
|
|
321
|
-
|
322
|
-
GL.Material(GL::FRONT_AND_BACK, GL::AMBIENT, @material.ambient)
|
323
|
-
GL.Material(GL::FRONT_AND_BACK, GL::DIFFUSE, @material.diffuse)
|
324
|
-
GL.Material(GL::FRONT_AND_BACK, GL::SPECULAR, @material.specular)
|
325
|
-
GL.Material(GL::FRONT_AND_BACK, GL::EMISSION, @material.emission)
|
326
|
-
GL.Materialf(GL::FRONT_AND_BACK, GL::SHININESS, @material.shininess)
|
327
|
-
|
309
|
+
enable_material(@material)
|
328
310
|
# Vertex colors change both diffuse and ambient
|
329
311
|
GL.ColorMaterial(GL::FRONT_AND_BACK, GL::AMBIENT_AND_DIFFUSE)
|
330
312
|
GL.Disable(GL::COLOR_MATERIAL)
|
@@ -349,8 +331,59 @@ module Cosmos
|
|
349
331
|
def paintGL
|
350
332
|
# Set viewport
|
351
333
|
GL.Viewport(0, 0, @wvt.w, @wvt.h)
|
334
|
+
reset_gl_state()
|
335
|
+
clear_solid_background()
|
336
|
+
|
337
|
+
# Depth test on by default
|
338
|
+
GL.DepthMask(GL::TRUE)
|
339
|
+
GL.Enable(GL::DEPTH_TEST)
|
352
340
|
|
353
|
-
#
|
341
|
+
# Switch to projection matrix
|
342
|
+
GL.MatrixMode(GL::PROJECTION)
|
343
|
+
GL.LoadIdentity
|
344
|
+
case @projection
|
345
|
+
when :PARALLEL
|
346
|
+
GL.Ortho(@wvt.left, @wvt.right, @wvt.bottom, @wvt.top, @wvt.hither, @wvt.yon)
|
347
|
+
when :PERSPECTIVE
|
348
|
+
GL.Frustum(@wvt.left, @wvt.right, @wvt.bottom, @wvt.top, @wvt.hither, @wvt.yon)
|
349
|
+
end
|
350
|
+
|
351
|
+
# Switch to model matrix
|
352
|
+
GL.MatrixMode(GL::MODELVIEW)
|
353
|
+
GL.LoadIdentity
|
354
|
+
|
355
|
+
enable_light(@light)
|
356
|
+
enable_material(@material)
|
357
|
+
|
358
|
+
# Color commands change both
|
359
|
+
GL.ColorMaterial(GL::FRONT_AND_BACK, GL::AMBIENT_AND_DIFFUSE)
|
360
|
+
# Global ambient light
|
361
|
+
GL.LightModel(GL::LIGHT_MODEL_AMBIENT, @ambient)
|
362
|
+
|
363
|
+
# Enable fog
|
364
|
+
if @options.include?(:VIEWER_FOG)
|
365
|
+
GL.Enable(GL::FOG)
|
366
|
+
GL.Fog(GL::FOG_COLOR, @top_background) # Disappear into the background
|
367
|
+
GL.Fogf(GL::FOG_START, (@distance - @diameter).to_f) # Range tight around model position
|
368
|
+
GL.Fogf(GL::FOG_END, (@distance + @diameter).to_f) # Far place same as clip plane:- clipped stuff is in the mist!
|
369
|
+
GL.Fogi(GL::FOG_MODE, GL::LINEAR) # Simple linear depth cueing
|
370
|
+
end
|
371
|
+
|
372
|
+
# Dithering
|
373
|
+
GL.Enable(GL::DITHER) if @options.include?(:VIEWER_DITHER)
|
374
|
+
# Enable lighting
|
375
|
+
GL.Enable(GL::LIGHTING) if @options.include?(:VIEWER_LIGHTING)
|
376
|
+
|
377
|
+
# Set model matrix
|
378
|
+
GL.LoadMatrixf(@transform)
|
379
|
+
|
380
|
+
draw_axis() if (@draw_axis and @draw_axis > 0)
|
381
|
+
|
382
|
+
# Draw what's visible
|
383
|
+
@scene.draw(self) if @scene
|
384
|
+
end
|
385
|
+
|
386
|
+
def reset_gl_state
|
354
387
|
GL.ShadeModel(GL::SMOOTH)
|
355
388
|
GL.PolygonMode(GL::FRONT_AND_BACK, GL::FILL)
|
356
389
|
GL.Disable(GL::LIGHTING)
|
@@ -370,8 +403,9 @@ module Cosmos
|
|
370
403
|
GL.LoadIdentity
|
371
404
|
GL.MatrixMode(GL::MODELVIEW)
|
372
405
|
GL.LoadIdentity
|
406
|
+
end
|
373
407
|
|
374
|
-
|
408
|
+
def clear_solid_background
|
375
409
|
GL.ClearDepth(1.0)
|
376
410
|
GL.ClearColor(@top_background[0], @top_background[1], @top_background[2], @top_background[3])
|
377
411
|
if @top_background == @bottom_background
|
@@ -397,105 +431,61 @@ module Cosmos
|
|
397
431
|
# Raises false error on Mac
|
398
432
|
end
|
399
433
|
end
|
434
|
+
end
|
400
435
|
|
401
|
-
|
402
|
-
GL.
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
436
|
+
def draw_axis
|
437
|
+
GL.PushMatrix
|
438
|
+
GL.LineWidth(2.5)
|
439
|
+
GL.Color3f(1.0, 0.0, 0.0)
|
440
|
+
GL.Begin(GL::LINES)
|
441
|
+
GL.Vertex3f(-@draw_axis.to_f, 0.0, 0.0)
|
442
|
+
GL.Vertex3f(@draw_axis.to_f, 0.0, 0.0)
|
443
|
+
begin
|
444
|
+
GL.End
|
445
|
+
rescue
|
446
|
+
# Raises false error on Mac
|
447
|
+
end
|
448
|
+
GL.Color3f(0.0, 1.0, 0.0)
|
449
|
+
GL.Begin(GL::LINES)
|
450
|
+
GL.Vertex3f(0, -@draw_axis, 0.0)
|
451
|
+
GL.Vertex3f(0, @draw_axis, 0)
|
452
|
+
begin
|
453
|
+
GL.End
|
454
|
+
rescue
|
455
|
+
# Raises false error on Mac
|
456
|
+
end
|
457
|
+
GL.Color3f(0.0, 0.0, 1.0)
|
458
|
+
GL.Begin(GL::LINES)
|
459
|
+
GL.Vertex3f(0, 0, -@draw_axis)
|
460
|
+
GL.Vertex3f(0, 0, @draw_axis)
|
461
|
+
begin
|
462
|
+
GL.End
|
463
|
+
rescue
|
464
|
+
# Raises false error on Mac
|
465
|
+
end
|
466
|
+
GL.PopMatrix
|
467
|
+
end
|
418
468
|
|
419
|
-
|
469
|
+
def enable_light(light)
|
420
470
|
GL.Enable(GL::LIGHT0)
|
421
|
-
GL.Light(GL::LIGHT0, GL::AMBIENT,
|
422
|
-
GL.Light(GL::LIGHT0, GL::DIFFUSE,
|
423
|
-
GL.Light(GL::LIGHT0, GL::SPECULAR,
|
424
|
-
GL.Light(GL::LIGHT0, GL::POSITION,
|
425
|
-
GL.Light(GL::LIGHT0, GL::SPOT_DIRECTION,
|
426
|
-
GL.Lightf(GL::LIGHT0, GL::SPOT_EXPONENT,
|
427
|
-
GL.Lightf(GL::LIGHT0, GL::SPOT_CUTOFF,
|
428
|
-
GL.Lightf(GL::LIGHT0, GL::CONSTANT_ATTENUATION,
|
429
|
-
GL.Lightf(GL::LIGHT0, GL::LINEAR_ATTENUATION,
|
430
|
-
GL.Lightf(GL::LIGHT0, GL::QUADRATIC_ATTENUATION,
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
GL.Material(GL::FRONT_AND_BACK, GL::
|
435
|
-
GL.Material(GL::FRONT_AND_BACK, GL::
|
436
|
-
GL.Material(GL::FRONT_AND_BACK, GL::
|
437
|
-
GL.
|
438
|
-
|
439
|
-
# Color commands change both
|
440
|
-
GL.ColorMaterial(GL::FRONT_AND_BACK, GL::AMBIENT_AND_DIFFUSE)
|
441
|
-
|
442
|
-
# Global ambient light
|
443
|
-
GL.LightModel(GL::LIGHT_MODEL_AMBIENT, @ambient)
|
444
|
-
|
445
|
-
# Enable fog
|
446
|
-
if @options.include?(:VIEWER_FOG)
|
447
|
-
GL.Enable(GL::FOG)
|
448
|
-
GL.Fog(GL::FOG_COLOR, @top_background) # Disappear into the background
|
449
|
-
GL.Fogf(GL::FOG_START, (@distance - @diameter).to_f) # Range tight around model position
|
450
|
-
GL.Fogf(GL::FOG_END, (@distance + @diameter).to_f) # Far place same as clip plane:- clipped stuff is in the mist!
|
451
|
-
GL.Fogi(GL::FOG_MODE, GL::LINEAR) # Simple linear depth cueing
|
452
|
-
end
|
453
|
-
|
454
|
-
# Dithering
|
455
|
-
GL.Enable(GL::DITHER) if @options.include?(:VIEWER_DITHER)
|
456
|
-
|
457
|
-
# Enable lighting
|
458
|
-
GL.Enable(GL::LIGHTING) if @options.include?(:VIEWER_LIGHTING)
|
459
|
-
|
460
|
-
# Set model matrix
|
461
|
-
GL.LoadMatrixf(@transform)
|
462
|
-
|
463
|
-
if (@draw_axis and @draw_axis > 0)
|
464
|
-
# Draw axis
|
465
|
-
GL.PushMatrix
|
466
|
-
GL.LineWidth(2.5)
|
467
|
-
GL.Color3f(1.0, 0.0, 0.0)
|
468
|
-
GL.Begin(GL::LINES)
|
469
|
-
GL.Vertex3f(-@draw_axis.to_f, 0.0, 0.0)
|
470
|
-
GL.Vertex3f(@draw_axis.to_f, 0.0, 0.0)
|
471
|
-
begin
|
472
|
-
GL.End
|
473
|
-
rescue
|
474
|
-
# Raises false error on Mac
|
475
|
-
end
|
476
|
-
GL.Color3f(0.0, 1.0, 0.0)
|
477
|
-
GL.Begin(GL::LINES)
|
478
|
-
GL.Vertex3f(0, -@draw_axis, 0.0)
|
479
|
-
GL.Vertex3f(0, @draw_axis, 0)
|
480
|
-
begin
|
481
|
-
GL.End
|
482
|
-
rescue
|
483
|
-
# Raises false error on Mac
|
484
|
-
end
|
485
|
-
GL.Color3f(0.0, 0.0, 1.0)
|
486
|
-
GL.Begin(GL::LINES)
|
487
|
-
GL.Vertex3f(0, 0, -@draw_axis)
|
488
|
-
GL.Vertex3f(0, 0, @draw_axis)
|
489
|
-
begin
|
490
|
-
GL.End
|
491
|
-
rescue
|
492
|
-
# Raises false error on Mac
|
493
|
-
end
|
494
|
-
GL.PopMatrix
|
495
|
-
end
|
496
|
-
|
497
|
-
# Draw what's visible
|
498
|
-
@scene.draw(self) if @scene
|
471
|
+
GL.Light(GL::LIGHT0, GL::AMBIENT, light.ambient)
|
472
|
+
GL.Light(GL::LIGHT0, GL::DIFFUSE, light.diffuse)
|
473
|
+
GL.Light(GL::LIGHT0, GL::SPECULAR, light.specular)
|
474
|
+
GL.Light(GL::LIGHT0, GL::POSITION, light.position)
|
475
|
+
GL.Light(GL::LIGHT0, GL::SPOT_DIRECTION, light.direction)
|
476
|
+
GL.Lightf(GL::LIGHT0, GL::SPOT_EXPONENT, light.exponent)
|
477
|
+
GL.Lightf(GL::LIGHT0, GL::SPOT_CUTOFF, light.cutoff)
|
478
|
+
GL.Lightf(GL::LIGHT0, GL::CONSTANT_ATTENUATION, light.c_attn)
|
479
|
+
GL.Lightf(GL::LIGHT0, GL::LINEAR_ATTENUATION, light.l_attn)
|
480
|
+
GL.Lightf(GL::LIGHT0, GL::QUADRATIC_ATTENUATION, light.q_attn)
|
481
|
+
end
|
482
|
+
|
483
|
+
def enable_material(material)
|
484
|
+
GL.Material(GL::FRONT_AND_BACK, GL::AMBIENT, material.ambient)
|
485
|
+
GL.Material(GL::FRONT_AND_BACK, GL::DIFFUSE, material.diffuse)
|
486
|
+
GL.Material(GL::FRONT_AND_BACK, GL::SPECULAR, material.specular)
|
487
|
+
GL.Material(GL::FRONT_AND_BACK, GL::EMISSION, material.emission)
|
488
|
+
GL.Materialf(GL::FRONT_AND_BACK, GL::SHININESS, material.shininess)
|
499
489
|
end
|
500
490
|
|
501
491
|
def resizeGL(width, height)
|
@@ -522,20 +512,18 @@ module Cosmos
|
|
522
512
|
[@worldpx*sx.to_f + @ax, @ay - @worldpx*sy.to_f, -@distance.to_f]
|
523
513
|
end
|
524
514
|
|
525
|
-
def eyeToWorld(e)
|
526
|
-
[e[0]*@itransform[0][0] + e[1]*@itransform[1][0] + e[2]*@itransform[2][0] + @itransform[3][0],
|
527
|
-
e[0]*@itransform[0][1] + e[1]*@itransform[1][1] + e[2]*@itransform[2][1] + @itransform[3][1],
|
528
|
-
e[0]*@itransform[0][2] + e[1]*@itransform[1][2] + e[2]*@itransform[2][2] + @itransform[3][2]]
|
529
|
-
end
|
530
|
-
|
531
515
|
def worldToEyeZ(w)
|
532
516
|
w[0]*@transform[0][2] + w[1]*@transform[1][2] + w[2]*@transform[2][2] + @transform[3][2]
|
533
517
|
end
|
534
518
|
|
519
|
+
def eyeToWorld(e)
|
520
|
+
calc_prime(e)
|
521
|
+
end
|
522
|
+
|
535
523
|
def calc_prime(v)
|
536
|
-
|
537
|
-
|
538
|
-
|
524
|
+
[v[0]*@itransform[0][0] + v[1]*@itransform[1][0] + v[2]*@itransform[2][0] + @itransform[3][0],
|
525
|
+
v[0]*@itransform[0][1] + v[1]*@itransform[1][1] + v[2]*@itransform[2][1] + @itransform[3][1],
|
526
|
+
v[0]*@itransform[0][2] + v[1]*@itransform[1][2] + v[2]*@itransform[2][2] + @itransform[3][2]]
|
539
527
|
end
|
540
528
|
|
541
529
|
def worldVector(fx, fy, tx, ty)
|