torqml 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +32 -0
  3. data/.yardopts +3 -0
  4. data/Gemfile +5 -0
  5. data/LICENSE +21 -0
  6. data/README.md +148 -0
  7. data/Rakefile +6 -0
  8. data/assets/images/capture.png +0 -0
  9. data/assets/images/configure.png +0 -0
  10. data/assets/images/edit.png +0 -0
  11. data/assets/images/play.png +0 -0
  12. data/assets/images/reload.png +0 -0
  13. data/assets/images/stop.png +0 -0
  14. data/assets/shapes/TQBox.obj +44 -0
  15. data/assets/shapes/TQCone.obj +169 -0
  16. data/assets/shapes/TQCylinder.obj +585 -0
  17. data/assets/shapes/TQSphere.obj +1497 -0
  18. data/assets/shapes/TQTorus.obj +3754 -0
  19. data/bin/torqml +12 -0
  20. data/examples/SerialLink/SerialLink.qml +35 -0
  21. data/examples/SerialLink/main.qml +29 -0
  22. data/examples/SerialLink/main_multi.qml +40 -0
  23. data/examples/Tutorial/MyModel.qml +34 -0
  24. data/examples/Tutorial/main_00_minimal.qml +10 -0
  25. data/examples/Tutorial/main_01_property.qml +15 -0
  26. data/examples/Tutorial/main_02_pose.qml +19 -0
  27. data/examples/Tutorial/main_03_link.qml +32 -0
  28. data/examples/Tutorial/main_04_importmodel.qml +7 -0
  29. data/examples/Tutorial/main_05_cameralight.qml +17 -0
  30. data/examples/Tutorial/main_06_animation.qml +18 -0
  31. data/examples/WheeledVehicle/WheeledVehicle.qml +62 -0
  32. data/examples/WheeledVehicle/data/maze2014student.dat +19 -0
  33. data/examples/WheeledVehicle/data/wheeledvehicle.csv +11712 -0
  34. data/examples/WheeledVehicle/main.qml +38 -0
  35. data/examples/WheeledVehicle/plugins/MazeWallGenerator/plugin.rb +68 -0
  36. data/examples/WheeledVehicle/plugins/MazeWallGenerator/qml/TorQML/Plugins/MazeWallGenerator/MazeHorizWall.qml +29 -0
  37. data/examples/WheeledVehicle/plugins/MazeWallGenerator/qml/TorQML/Plugins/MazeWallGenerator/MazeVertWall.qml +30 -0
  38. data/examples/WheeledVehicle/plugins/MazeWallGenerator/qml/TorQML/Plugins/MazeWallGenerator/MazeWallGenerator.qml +24 -0
  39. data/examples/WheeledVehicle/plugins/MazeWallGenerator/qml/TorQML/Plugins/MazeWallGenerator/qmldir +4 -0
  40. data/examples/WheeledVehicle/plugins/MazeWallGenerator/qml/TorQML/Plugins/MazeWallGenerator/wallAllocator.js +47 -0
  41. data/ext/TorQML/FrameGrabber/extconf.rb +45 -0
  42. data/ext/TorQML/FrameGrabber/framegrabber.cpp +36 -0
  43. data/ext/TorQML/FrameGrabber/framegrabber.pro +9 -0
  44. data/ext/TorQML/FrameGrabber/qmldir +2 -0
  45. data/lib/torqml.rb +47 -0
  46. data/lib/torqml/datasources.rb +12 -0
  47. data/lib/torqml/datasources/csvdatasource.rb +44 -0
  48. data/lib/torqml/datasources/datasource.rb +44 -0
  49. data/lib/torqml/datasources/lineardatasource.rb +47 -0
  50. data/lib/torqml/datasources/matrixdatasource.rb +37 -0
  51. data/lib/torqml/plugins.rb +44 -0
  52. data/lib/torqml/version.rb +6 -0
  53. data/plugins/DO_NOT_MODIFY_THIS_DIRECTORY +2 -0
  54. data/qml/TorQML/DataSources/TQCSVDataSource.qml +17 -0
  55. data/qml/TorQML/DataSources/TQLinearDataSource.qml +18 -0
  56. data/qml/TorQML/DataSources/qmldir +3 -0
  57. data/qml/TorQML/Shapes/TQAxis.qml +26 -0
  58. data/qml/TorQML/Shapes/TQBox.qml +11 -0
  59. data/qml/TorQML/Shapes/TQCone.qml +17 -0
  60. data/qml/TorQML/Shapes/TQCoordinate.qml +30 -0
  61. data/qml/TorQML/Shapes/TQCylinder.qml +17 -0
  62. data/qml/TorQML/Shapes/TQGrid.qml +36 -0
  63. data/qml/TorQML/Shapes/TQPrimitive.qml +33 -0
  64. data/qml/TorQML/Shapes/TQSphere.qml +18 -0
  65. data/qml/TorQML/Shapes/TQTorus.qml +18 -0
  66. data/qml/TorQML/Shapes/qmldir +10 -0
  67. data/qml/TorQML/TQModel.qml +9 -0
  68. data/qml/TorQML/Views/Dialogs/TQCaptureDialog.qml +197 -0
  69. data/qml/TorQML/Views/Dialogs/TQProgressDialog.qml +36 -0
  70. data/qml/TorQML/Views/Dialogs/qmldir +3 -0
  71. data/qml/TorQML/Views/TQBasicView.qml +148 -0
  72. data/qml/TorQML/Views/TQCamera.qml +11 -0
  73. data/qml/TorQML/Views/TQViewport.qml +41 -0
  74. data/qml/TorQML/Views/basicview.js +172 -0
  75. data/qml/TorQML/Views/mouseEventHandler.js +55 -0
  76. data/qml/TorQML/Views/qmldir +4 -0
  77. data/qml/TorQML/qmldir +2 -0
  78. data/torqml.gemspec +29 -0
  79. metadata +181 -0
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/ruby -Ku
2
+ # -*- coding: utf-8 -*-
3
+
4
+ require 'qml'
5
+
6
+ module TorQML
7
+ module DataSources
8
+ # Base class of data sources.
9
+ class DataSource_rb
10
+ include QML::Access
11
+ # do not call register_to_qml here because this class has no features
12
+
13
+ # @return [Integer] the current frame number
14
+ property(:currentFrame) { 1 }
15
+ # Event signal for QML component.
16
+ signal :dataTriggered, []
17
+
18
+ # Emitts onDataTriggered event to the QML component.
19
+ on_changed :currentFrame do
20
+ dataTriggered.emit # QML: onDataTriggered
21
+ end
22
+
23
+ # Returns the current frame value at column index.
24
+ # This is a dummy method.
25
+ #
26
+ # @param [Integer] index index
27
+ # @return [Float] always returns index
28
+ def value_at(index)
29
+ index # dummy
30
+ end
31
+
32
+ # Returns the number of rows.
33
+ # This is a dummy method.
34
+ #
35
+ # @return [Integer] always returns 0
36
+ def rows
37
+ 0 # dummy
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+
44
+ # vim:set ts=2 sw=2 et:
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/ruby -Ku
2
+ # -*- coding: utf-8 -*-
3
+
4
+ require 'qml'
5
+ require_relative './datasource'
6
+
7
+ module TorQML
8
+ module DataSources
9
+ # Data source class to provide simple linear data.
10
+ # This class is useful when testing some models without preparing time-series data files.
11
+ class LinearDataSource_rb < DataSource_rb
12
+ include QML::Access
13
+ register_to_qml # QML: LinearDataSource_rb
14
+
15
+ # @return [Integer] the size of data
16
+ property(:dataSize) { 0 }
17
+ # @return [Float] the value step against index
18
+ property(:dataStep) { 0 }
19
+
20
+ # Prepare data to provide.
21
+ def prepare_data
22
+ @data = Array.new(self.dataSize) do |i|
23
+ i * self.dataStep
24
+ end
25
+ end
26
+
27
+ # Returns the current frame value.
28
+ # Return value is not dependent on index argument.
29
+ #
30
+ # @param [Integer] index index
31
+ # @return [Float] the current frame value
32
+ def value_at(index)
33
+ @data[currentFrame.to_i - 1]
34
+ end
35
+
36
+ # Returns the number of rows.
37
+ #
38
+ # @return [Integer] the number of rows
39
+ def rows
40
+ @data.length
41
+ end
42
+
43
+ end
44
+ end
45
+ end
46
+
47
+ # vim:set ts=2 sw=2 et:
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/ruby -Ku
2
+ # -*- coding: utf-8 -*-
3
+
4
+ require 'qml'
5
+ require_relative './datasource'
6
+
7
+ module TorQML
8
+ module DataSources
9
+ # Base class of matrix type data sources.
10
+ class MatrixDataSource_rb < DataSource_rb
11
+ # do not call register_to_qml here
12
+
13
+ # Returns the current frame value at column index.
14
+ #
15
+ # @param [Integer] index index
16
+ # @return [Float] the current frame value at column index
17
+ def value_at(index)
18
+ if @data.nil?
19
+ raise "data not initialized"
20
+ 0
21
+ else
22
+ @data[currentFrame.to_i - 1][index.to_i]
23
+ end
24
+ end
25
+
26
+ # Returns the number of rows.
27
+ #
28
+ # @return [Integer] the number of rows
29
+ def rows
30
+ @data.length
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+
37
+ # vim:set ts=2 sw=2 et:
@@ -0,0 +1,44 @@
1
+ require 'qml'
2
+
3
+ module TorQML
4
+ # TorQML module of plugins
5
+ module Plugins
6
+ # Version of Plugins module.
7
+ VERSION="0.1"
8
+
9
+ # Returns default path of plugin directory.
10
+ #
11
+ # @return [String] the default directory
12
+ def default_path
13
+ ENV['HOME'] + '/.torqml/plugins'
14
+ end
15
+
16
+ # Preloads ruby modules of plugins.
17
+ #
18
+ # @param [Pathname] dir path to the directory that contains plugins
19
+ def preload(dir)
20
+ Pathname.glob(dir + '*/plugin.rb').each do |path|
21
+ # load ruby modules
22
+ require(path.realpath.dirname + path.basename)
23
+ end
24
+ end
25
+
26
+ # Loads QML/C++ plugins.
27
+ #
28
+ # @param [QML::Application] app QML application
29
+ # @param [Pathname] dir path to the directory that contains plugins
30
+ def load(app, dir)
31
+ Pathname.glob(dir + '*/plugin.rb').each do |path|
32
+ # add directories into import path of the application
33
+ app.engine.add_import_path("#{path.realpath.dirname}/qml") if (path.realpath.dirname + 'qml').exist?
34
+ app.engine.add_import_path("#{path.realpath.dirname}/ext") if (path.realpath.dirname + 'ext').exist?
35
+ end
36
+ end
37
+
38
+ module_function :default_path
39
+ module_function :preload
40
+ module_function :load
41
+ end
42
+ end
43
+
44
+ # vim:set ts=2 sw=2 et:
@@ -0,0 +1,6 @@
1
+ module TorQML
2
+ # Version of TorQML.
3
+ VERSION = "0.1.1"
4
+ end
5
+
6
+ # vim:set ts=2 sw=2 et:
@@ -0,0 +1,2 @@
1
+ This directory is for bundled plugins.
2
+ Do not place any other items under here.
@@ -0,0 +1,17 @@
1
+ import QtQuick 2.0
2
+ import TorQML.DataSources 0.1
3
+
4
+ // registered component by csvdatasource.rb
5
+ CSVDataSource_rb {
6
+ id: _dataSource
7
+ source: null
8
+ currentFrame: -1
9
+ onDataTriggered: {
10
+ }
11
+ Component.onCompleted: {
12
+ _dataSource.prepare_data()
13
+ _dataSource.currentFrame = 1
14
+ }
15
+ }
16
+
17
+ // vim:set ts=4 sw=4 et:
@@ -0,0 +1,18 @@
1
+ import QtQuick 2.0
2
+ import TorQML.DataSources 0.1
3
+
4
+ // registered component by lineardatasource.rb
5
+ LinearDataSource_rb {
6
+ id: _dataSource
7
+ dataSize: 100
8
+ dataStep: 0.1
9
+ currentFrame: -1
10
+ onDataTriggered: {
11
+ }
12
+ Component.onCompleted: {
13
+ _dataSource.prepare_data()
14
+ _dataSource.currentFrame = 1
15
+ }
16
+ }
17
+
18
+ // vim:set ts=4 sw=4 et:
@@ -0,0 +1,3 @@
1
+ module TorQML.Datasources
2
+ TQCSVDataSource 0.1 TQCSVDataSource.qml
3
+ TQLinearDataSource 0.1 TQLinearDataSource.qml
@@ -0,0 +1,26 @@
1
+ import QtQuick 2.0
2
+ import Qt3D 2.0
3
+ import Qt3D.Shapes 2.0
4
+ import TorQML.Shapes 0.1
5
+
6
+ Item3D {
7
+ id: _obj
8
+ property real cylinderRadius: 0.1
9
+ property real cylinderLength: 0.7
10
+ property real coneRadius: 0.2
11
+ property real coneLength: 0.3
12
+ property alias color: _cylinder.color
13
+
14
+ TQCylinder {
15
+ id: _cylinder
16
+ radius: cylinderRadius
17
+ length: cylinderLength
18
+ TQCone {
19
+ radius: coneRadius
20
+ length: coneLength
21
+ color: _cylinder.color
22
+ }
23
+ }
24
+ }
25
+
26
+ // vim:set ts=4 sw=4 et:
@@ -0,0 +1,11 @@
1
+ import QtQuick 2.0
2
+ import Qt3D 2.0
3
+ import Qt3D.Shapes 2.0
4
+ import TorQML.Shapes 0.1
5
+
6
+ TQPrimitive {
7
+ id: _obj
8
+ mesh: Mesh { source: "../../../assets/shapes/TQBox.obj" }
9
+ }
10
+
11
+ // vim:set ts=4 sw=4 et:
@@ -0,0 +1,17 @@
1
+ import QtQuick 2.0
2
+ import Qt3D 2.0
3
+ import Qt3D.Shapes 2.0
4
+ import TorQML.Shapes 0.1
5
+
6
+ TQPrimitive {
7
+ id: _obj
8
+ property real radius: 1
9
+ property alias length: _obj.xLength
10
+
11
+ yWidth: radius
12
+ zDepth: radius
13
+
14
+ mesh: Mesh { source: "../../../assets/shapes/TQCone.obj" }
15
+ }
16
+
17
+ // vim:set ts=4 sw=4 et:
@@ -0,0 +1,30 @@
1
+ import QtQuick 2.0
2
+ import Qt3D 2.0
3
+ import Qt3D.Shapes 2.0
4
+ import TorQML.Shapes 0.1
5
+
6
+ Item3D {
7
+ property alias xColor: xAxis.color
8
+ property alias yColor: yAxis.color
9
+ property alias zColor: zAxis.color
10
+ TQAxis {
11
+ id: xAxis
12
+ color: "red"
13
+ }
14
+ TQAxis {
15
+ id: yAxis
16
+ color: "green"
17
+ transform: [
18
+ Rotation3D { angle: 90; axis: "0,0,1" }
19
+ ]
20
+ }
21
+ TQAxis {
22
+ id: zAxis
23
+ color: "blue"
24
+ transform: [
25
+ Rotation3D { angle: -90; axis: "0,1,0" }
26
+ ]
27
+ }
28
+ }
29
+
30
+ // vim:set ts=4 sw=4 et:
@@ -0,0 +1,17 @@
1
+ import QtQuick 2.0
2
+ import Qt3D 2.0
3
+ import Qt3D.Shapes 2.0
4
+ import TorQML.Shapes 0.1
5
+
6
+ TQPrimitive {
7
+ id: _obj
8
+ property real radius: 1
9
+ property alias length: _obj.xLength
10
+
11
+ yWidth: radius
12
+ zDepth: radius
13
+
14
+ mesh: Mesh { source: "../../../assets/shapes/TQCylinder.obj" }
15
+ }
16
+
17
+ // vim:set ts=4 sw=4 et:
@@ -0,0 +1,36 @@
1
+ import QtQuick 2.0
2
+ import Qt3D 2.0
3
+ import Qt3D.Shapes 2.0
4
+ import TorQML.Shapes 0.1
5
+
6
+ Item3D {
7
+ id: _obj
8
+ property real step: 1.0
9
+ property real size: 10
10
+ property string color: "#33FFFFFF"
11
+ Repeater {
12
+ model: _obj.size / _obj.step * 2 + 1
13
+ delegate: TQCylinder {
14
+ radius: _obj.step / 20
15
+ length: _obj.size * 2
16
+ centered: true
17
+ position: Qt.vector3d(0, _obj.step * index - _obj.size, 0)
18
+ color: _obj.color
19
+ }
20
+ }
21
+ Repeater {
22
+ model: _obj.size / _obj.step * 2 + 1
23
+ delegate: TQCylinder {
24
+ radius: _obj.step / 20
25
+ length: _obj.size * 2
26
+ centered: true
27
+ position: Qt.vector3d(_obj.step * index - _obj.size, 0, 0)
28
+ transform: [
29
+ Rotation3D { angle: 90; axis: "0,0,1" }
30
+ ]
31
+ color: _obj.color
32
+ }
33
+ }
34
+ }
35
+
36
+ // vim:set ts=4 sw=4 et:
@@ -0,0 +1,33 @@
1
+ import QtQuick 2.0
2
+ import Qt3D 2.0
3
+
4
+ Item3D {
5
+ property real xLength: 1
6
+ property real yWidth: 1
7
+ property real zDepth: 1
8
+ property bool centered: false
9
+ property alias color: _effect.color
10
+ property alias texture: _effect.texture
11
+
12
+ property alias mesh: _obj.mesh
13
+
14
+ Item3D {
15
+ id: _obj
16
+ effect: Effect {
17
+ id: _effect
18
+ blending: true
19
+ color: "red"
20
+ }
21
+ transform: [
22
+ Scale3D { scale: Qt.vector3d(xLength, yWidth, zDepth) },
23
+ Translation3D { translate: Qt.vector3d( centered ? -xLength / 2 : 0, 0, 0) }
24
+ ]
25
+ }
26
+ Component.onCompleted: {
27
+ if("xLength" in parent){
28
+ position = Qt.vector3d( parent.xLength / ( parent.centered ? 2 : 1 ), 0, 0)
29
+ }
30
+ }
31
+ }
32
+
33
+ // vim:set ts=4 sw=4 et:
@@ -0,0 +1,18 @@
1
+ import QtQuick 2.0
2
+ import Qt3D 2.0
3
+ import Qt3D.Shapes 2.0
4
+ import TorQML.Shapes 0.1
5
+
6
+ TQPrimitive {
7
+ id: _obj
8
+ property real radius: 1
9
+
10
+ xLength: radius
11
+ yWidth: radius
12
+ zDepth: radius
13
+ centered: true
14
+
15
+ mesh: Mesh { source: "../../../assets/shapes/TQSphere.obj" }
16
+ }
17
+
18
+ // vim:set ts=4 sw=4 et:
@@ -0,0 +1,18 @@
1
+ import QtQuick 2.0
2
+ import Qt3D 2.0
3
+ import Qt3D.Shapes 2.0
4
+ import TorQML.Shapes 0.1
5
+
6
+ TQPrimitive {
7
+ id: _obj
8
+ property real radius: 1
9
+
10
+ xLength: radius
11
+ yWidth: radius
12
+ zDepth: radius
13
+
14
+ centered: false
15
+ mesh: Mesh { source: "../../../assets/shapes/TQTorus.obj" }
16
+ }
17
+
18
+ // vim:set ts=4 sw=4 et: