replicator-workshop 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. replicator/__init__.py +6 -0
  2. replicator/app.py +204 -0
  3. replicator/config.py +48 -0
  4. replicator/core/__init__.py +0 -0
  5. replicator/core/assembly.py +117 -0
  6. replicator/core/blender_link.py +161 -0
  7. replicator/core/critique.py +594 -0
  8. replicator/core/drawing.py +389 -0
  9. replicator/core/dxf.py +120 -0
  10. replicator/core/evaluate.py +439 -0
  11. replicator/core/explain.py +139 -0
  12. replicator/core/export.py +96 -0
  13. replicator/core/fit.py +170 -0
  14. replicator/core/importers.py +185 -0
  15. replicator/core/materials.py +104 -0
  16. replicator/core/ops_advanced.py +496 -0
  17. replicator/core/ops_engineering.py +223 -0
  18. replicator/core/physics.py +147 -0
  19. replicator/core/printers.py +100 -0
  20. replicator/core/program.py +298 -0
  21. replicator/core/render.py +145 -0
  22. replicator/core/reverse.py +350 -0
  23. replicator/core/robot.py +153 -0
  24. replicator/core/step.py +245 -0
  25. replicator/fixtures/gaming_pc_liquid.json +2259 -0
  26. replicator/fixtures/gas_generator_rocket.json +876 -0
  27. replicator/fixtures/gas_generator_rocket_aero.json +861 -0
  28. replicator/fixtures/house_two_bed.json +979 -0
  29. replicator/fixtures/quadcopter_drone.json +687 -0
  30. replicator/fixtures/raspberry_pi_5.json +884 -0
  31. replicator/fixtures/rocket_engine.json +652 -0
  32. replicator/fixtures/turbofan.json +931 -0
  33. replicator/fixtures/vector_engine.json +314 -0
  34. replicator/gpu.py +81 -0
  35. replicator/image3d/__init__.py +0 -0
  36. replicator/image3d/comfy.py +181 -0
  37. replicator/image3d/pipeline.py +208 -0
  38. replicator/image3d/sheet.py +154 -0
  39. replicator/knowledge/__init__.py +61 -0
  40. replicator/knowledge/car_wheel_corner.md +21 -0
  41. replicator/knowledge/desk_lamp.md +21 -0
  42. replicator/knowledge/desktop_pc.md +20 -0
  43. replicator/knowledge/electronics_board.md +21 -0
  44. replicator/knowledge/exoskeleton.md +21 -0
  45. replicator/knowledge/house.md +22 -0
  46. replicator/knowledge/light_aircraft.md +22 -0
  47. replicator/knowledge/multirotor_drone.md +25 -0
  48. replicator/knowledge/print_replica.md +13 -0
  49. replicator/knowledge/rocket_engine.md +27 -0
  50. replicator/knowledge/turbofan.md +23 -0
  51. replicator/llm/__init__.py +0 -0
  52. replicator/llm/client.py +424 -0
  53. replicator/llm/prompts/blueprint.md +28 -0
  54. replicator/llm/prompts/edit.md +15 -0
  55. replicator/llm/prompts/explain.md +37 -0
  56. replicator/llm/prompts/name_parts.md +13 -0
  57. replicator/llm/prompts/program.md +72 -0
  58. replicator/llm/prompts/research_queries.md +8 -0
  59. replicator/mcp_server.py +307 -0
  60. replicator/qml/Main.qml +874 -0
  61. replicator/qml/Replicator/UI/Chip.qml +17 -0
  62. replicator/qml/Replicator/UI/DockHeader.qml +27 -0
  63. replicator/qml/Replicator/UI/Icon.qml +118 -0
  64. replicator/qml/Replicator/UI/IconButton.qml +31 -0
  65. replicator/qml/Replicator/UI/Kbd.qml +18 -0
  66. replicator/qml/Replicator/UI/NumField.qml +69 -0
  67. replicator/qml/Replicator/UI/Pill.qml +28 -0
  68. replicator/qml/Replicator/UI/RCombo.qml +51 -0
  69. replicator/qml/Replicator/UI/RMenu.qml +42 -0
  70. replicator/qml/Replicator/UI/RSlider.qml +23 -0
  71. replicator/qml/Replicator/UI/Segmented.qml +63 -0
  72. replicator/qml/Replicator/UI/Swatch.qml +47 -0
  73. replicator/qml/Replicator/UI/Theme.qml +149 -0
  74. replicator/qml/Replicator/UI/qmldir +14 -0
  75. replicator/qml/panels/AgentPrompt.qml +53 -0
  76. replicator/qml/panels/AttributeManager.qml +171 -0
  77. replicator/qml/panels/Commander.qml +136 -0
  78. replicator/qml/panels/HolodeckPanel.qml +117 -0
  79. replicator/qml/panels/IssuesCard.qml +78 -0
  80. replicator/qml/panels/LedgerPanel.qml +110 -0
  81. replicator/qml/panels/MaterialShelf.qml +97 -0
  82. replicator/qml/panels/ObjectManager.qml +107 -0
  83. replicator/qml/panels/Preferences.qml +211 -0
  84. replicator/qml/panels/Presenter.qml +316 -0
  85. replicator/qml/panels/StatusBar.qml +77 -0
  86. replicator/qml/panels/Timeline.qml +149 -0
  87. replicator/qml/panels/Welcome.qml +126 -0
  88. replicator/qml/viewport/Callouts.qml +87 -0
  89. replicator/qml/viewport/EdgeMaterial.qml +16 -0
  90. replicator/qml/viewport/GridMaterial.qml +16 -0
  91. replicator/qml/viewport/HoloMaterial.qml +23 -0
  92. replicator/qml/viewport/NavGizmo.qml +72 -0
  93. replicator/qml/viewport/ReferenceMaterial.qml +17 -0
  94. replicator/qml/viewport/Viewport.qml +583 -0
  95. replicator/qt/__init__.py +0 -0
  96. replicator/qt/bridge.py +1427 -0
  97. replicator/qt/drawing_sheet.py +33 -0
  98. replicator/qt/envmap.py +40 -0
  99. replicator/qt/library.py +68 -0
  100. replicator/qt/mesh_geometry.py +167 -0
  101. replicator/qt/svg.py +41 -0
  102. replicator/research/__init__.py +0 -0
  103. replicator/research/lane.py +281 -0
  104. replicator/shaders/edge.frag +9 -0
  105. replicator/shaders/edge.vert +7 -0
  106. replicator/shaders/grid.frag +52 -0
  107. replicator/shaders/grid.vert +6 -0
  108. replicator/shaders/holo.frag +41 -0
  109. replicator/shaders/reference.frag +15 -0
  110. replicator/shaders/reference.vert +6 -0
  111. replicator/voice.py +120 -0
  112. replicator_workshop-0.1.0.dist-info/METADATA +410 -0
  113. replicator_workshop-0.1.0.dist-info/RECORD +118 -0
  114. replicator_workshop-0.1.0.dist-info/WHEEL +5 -0
  115. replicator_workshop-0.1.0.dist-info/entry_points.txt +3 -0
  116. replicator_workshop-0.1.0.dist-info/licenses/LICENSE +21 -0
  117. replicator_workshop-0.1.0.dist-info/licenses/vendor/mcp-for-blender/LICENSE +21 -0
  118. replicator_workshop-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,583 @@
1
+ import QtQuick
2
+ import QtQuick3D
3
+ import QtQuick3D.Helpers
4
+ import Replicator.UI
5
+
6
+ // The workshop viewport. A custom orbit camera (pivot + yaw/pitch/distance, damped), C4D and Blender bindings,
7
+ // zoom to cursor, adaptive clip planes, ortho views, a move gizmo with grid snapping, display modes,
8
+ // exploded views (Dissect) and a Showcase look.
9
+ Item {
10
+ id: root
11
+ focus: true
12
+
13
+ // ---- state from the window
14
+ property real blueprint: 0.0
15
+ property real explode: 0.0 // 0 assembled .. 1 fully exploded
16
+ property real explodeGoal: 0.0 // where explode is heading (framing uses it)
17
+ property string displayMode: "shaded" // shaded | lines | wire | xray
18
+ property bool colorByComponent: false
19
+ property string isolate: "" // component id shown alone ("" = all)
20
+ property var hidden: ({}) // component id -> true
21
+ property string tool: "select" // select | move | measure
22
+ property var measurePts: [] // measure tool: up to two picked surface points (scene units)
23
+ onToolChanged: measurePts = []
24
+ property bool showcase: false
25
+ property bool present: false
26
+ property bool turntable: false
27
+ property bool gridOn: true
28
+ property bool referenceOn: true
29
+ property real revealMs: 1100
30
+ property alias view: view
31
+ signal picked(string shapeId)
32
+ signal contextRequested(string shapeId, real x, real y)
33
+ signal userInteracted()
34
+ signal explodeNudge(real delta)
35
+
36
+ // ---- camera state (current and target, eased every frame)
37
+ property real yaw: 35; property real tYaw: 35
38
+ property real pitch: 24; property real tPitch: 24
39
+ property real dist: 900; property real tDist: 900
40
+ property vector3d pivot: Qt.vector3d(0, 150, 0)
41
+ property vector3d tPivot: Qt.vector3d(0, 150, 0)
42
+ property bool ortho: false
43
+ property string viewName: "Perspective"
44
+ readonly property real fov: 35
45
+ readonly property real gridCell: Math.pow(10, Math.floor(Math.log(Math.max(dist, 1) / 14) / Math.LN10)) // as grid.frag
46
+ property rect avoid: Qt.rect(0, 0, 0, 0) // a bar floating over the view (the specify capsule) the read-out keeps clear of
47
+ property int tick: 0 // bumps every frame so 2D overlays re-project
48
+ property real idle: 0
49
+
50
+ readonly property real minDist: Math.max(studio.radius * 0.03, 2)
51
+ readonly property real maxDist: studio.radius * 60
52
+ // Present: the object stands on the white stage, or levitates with a slow bob when its footprint is
53
+ // too small to stand on (studio.restPose, measured from the geometry)
54
+ property real bobClock: 0
55
+ readonly property real lift: root.present && studio.restPose === "levitate"
56
+ ? studio.radius * 0.18 + Math.sin(bobClock * Math.PI / 2) * studio.radius * 0.012
57
+ : 0
58
+ readonly property vector3d camDir: Qt.vector3d(Math.cos(pitch * Math.PI / 180) * Math.sin(yaw * Math.PI / 180),
59
+ Math.sin(pitch * Math.PI / 180),
60
+ Math.cos(pitch * Math.PI / 180) * Math.cos(yaw * Math.PI / 180))
61
+ readonly property vector3d camRight: Qt.vector3d(Math.cos(yaw * Math.PI / 180), 0, -Math.sin(yaw * Math.PI / 180))
62
+ readonly property vector3d camUp: camDir.crossProduct(camRight).normalized()
63
+
64
+ readonly property alias parts: partsRep
65
+ function frameAll(animate) {
66
+ const c = studio.center
67
+ tPivot = Qt.vector3d(c[0], c[1], c[2])
68
+ // 1.18: room for the dream bar and the title over the view; with 1.0 a tall build touched both edges
69
+ tDist = studio.radius * 1.18 * (1.0 + Math.max(explode, explodeGoal) * 1.1) / Math.sin(fov / 2 * Math.PI / 180)
70
+ if (!animate) { pivot = tPivot; dist = tDist }
71
+ }
72
+ function heroAngle() { tYaw = nearestYaw(38); tPitch = 14; ortho = false; viewName = "Perspective" }
73
+ function frameSelected() {
74
+ const g = selectedGeo()
75
+ if (!g) return frameAll(true)
76
+ const o = g.explodeOffset
77
+ tPivot = Qt.vector3d(g.center.x + o.x * explode, g.center.y + studio.ground + o.y * explode,
78
+ g.center.z + o.z * explode)
79
+ tDist = Math.max(minDist * 2, studio.radius * 0.6 / Math.sin(fov / 2 * Math.PI / 180))
80
+ }
81
+ function frameComponent(cid) {
82
+ for (let i = 0; i < studio.components.length; i++)
83
+ if (studio.components[i].id === cid) {
84
+ const c = studio.components[i]
85
+ tPivot = Qt.vector3d(c.center[0], c.center[1], c.center[2])
86
+ tDist = Math.max(minDist * 2, Math.max(c.size[0], c.size[1], c.size[2]) * 0.6 / Math.sin(fov / 2 * Math.PI / 180))
87
+ return
88
+ }
89
+ frameAll(true)
90
+ }
91
+ function setView(name) {
92
+ viewName = name
93
+ const v = { "Perspective": [35, 24, false], "Top": [0, 89.9, true], "Front": [0, 0, true],
94
+ "Right": [90, 0, true], "Back": [180, 0, true], "Left": [-90, 0, true],
95
+ "Bottom": [0, -89.9, true] }[name]
96
+ if (!v) return
97
+ tYaw = nearestYaw(v[0]); tPitch = v[1]; ortho = v[2]
98
+ }
99
+ function nearestYaw(target) { // turn the short way round
100
+ const d = ((target - tYaw) % 360 + 540) % 360 - 180
101
+ return tYaw + d
102
+ }
103
+ function selectedGeo() {
104
+ for (let i = 0; i < studio.shapes.length; i++)
105
+ if (studio.shapes[i].shapeId === studio.selected) return studio.shapes[i]
106
+ return null
107
+ }
108
+ function project(v) { return view.mapFrom3DScene(v) }
109
+ function cameraJson() {
110
+ const p = cam.position
111
+ return JSON.stringify({ position: [p.x, p.y, p.z], target: [pivot.x, pivot.y, pivot.z], fov: fov,
112
+ width: Math.round(view.width), height: Math.round(view.height),
113
+ radius: studio.radius, dof: showcase })
114
+ }
115
+
116
+ FrameAnimation {
117
+ running: true
118
+ onTriggered: {
119
+ const k = 1 - Math.exp(-frameTime * 16)
120
+ if (root.present) root.bobClock += frameTime
121
+ if (root.turntable && root.idle > 1.5) root.tYaw -= frameTime * 9
122
+ root.idle += frameTime
123
+ root.yaw += (root.tYaw - root.yaw) * k
124
+ root.pitch += (root.tPitch - root.pitch) * k
125
+ root.dist += (root.tDist - root.dist) * k
126
+ root.pivot = root.pivot.plus(root.tPivot.minus(root.pivot).times(k))
127
+ cam.position = root.pivot.plus(root.camDir.times(root.dist))
128
+ cam.lookAt(root.pivot)
129
+ ocam.position = root.pivot.plus(root.camDir.times(Math.max(root.dist, studio.radius * 4)))
130
+ ocam.lookAt(root.pivot)
131
+ root.tick++
132
+ }
133
+ }
134
+
135
+ View3D {
136
+ id: view
137
+ anchors.fill: parent
138
+ camera: root.ortho ? ocam : cam
139
+
140
+ environment: ExtendedSceneEnvironment {
141
+ backgroundMode: SceneEnvironment.Transparent
142
+ antialiasingMode: SceneEnvironment.MSAA
143
+ antialiasingQuality: SceneEnvironment.High
144
+ specularAAEnabled: true
145
+ tonemapMode: SceneEnvironment.TonemapModeFilmic
146
+ exposure: root.showcase ? 0.95 : 1.0
147
+ lightProbe: Texture { textureData: studio.envMap; mappingMode: Texture.LightProbe }
148
+ probeExposure: root.showcase ? 1.3 : 0.9
149
+ probeOrientation: Qt.vector3d(0, 30, 0)
150
+ glowEnabled: true
151
+ glowStrength: 1.0
152
+ glowIntensity: 0.7
153
+ glowBloom: root.showcase ? 0.12 : 0.2 // 0.35 haloed every silhouette
154
+ glowHDRMinimumValue: 1.0
155
+ aoEnabled: root.showcase || root.present
156
+ aoStrength: 50
157
+ aoDistance: studio.radius * 0.06
158
+ aoSoftness: 40
159
+ depthOfFieldEnabled: root.showcase && !root.ortho
160
+ depthOfFieldFocusDistance: root.dist
161
+ depthOfFieldFocusRange: studio.radius * 1.6
162
+ depthOfFieldBlurAmount: 1.6
163
+ vignetteEnabled: root.showcase
164
+ vignetteStrength: 12 // 0..15, LOWER is darker (Qt docs); 0.55 blacked out the stage
165
+ vignetteRadius: 0.38
166
+ vignetteColor: "#000000"
167
+ ditheringEnabled: true
168
+ fog: Fog { // melts the Showcase stage into the backdrop (no hard horizon)
169
+ enabled: root.showcase
170
+ color: Theme.stageTop
171
+ depthEnabled: true
172
+ depthNear: root.dist + studio.radius * 1.4 // starts behind the object, never on it
173
+ depthFar: root.dist + studio.radius * 1.4 + root.dist * 2.2
174
+ depthCurve: 1.0
175
+ density: 1.0
176
+ }
177
+ }
178
+
179
+ PerspectiveCamera {
180
+ id: cam
181
+ fieldOfView: root.fov
182
+ clipNear: Math.max(root.dist * 0.004, 0.05)
183
+ clipFar: Math.max(root.dist * 60, studio.radius * 80)
184
+ }
185
+ OrthographicCamera {
186
+ id: ocam
187
+ readonly property real mag: Math.max(view.height, 1) / (2 * Math.max(root.dist, 1e-3) * Math.tan(root.fov / 2 * Math.PI / 180))
188
+ horizontalMagnification: mag
189
+ verticalMagnification: mag
190
+ clipNear: 1
191
+ clipFar: studio.radius * 400
192
+ }
193
+
194
+ DirectionalLight {
195
+ eulerRotation: Qt.vector3d(-52, -35, 0)
196
+ brightness: root.showcase ? 2.3 : root.present ? 2.8 : 1.05
197
+ castsShadow: true
198
+ shadowMapQuality: Light.ShadowMapQualityVeryHigh
199
+ shadowFactor: root.showcase ? 75 : root.present ? 100 : 50
200
+ csmNumSplits: 2
201
+ shadowBias: 2
202
+ pcfFactor: root.present ? 6 : 3
203
+ }
204
+ DirectionalLight { eulerRotation: Qt.vector3d(-18, 140, 0); brightness: 0.45; color: "#dfe8ff" }
205
+ DirectionalLight { eulerRotation: Qt.vector3d(12, 205, 0); brightness: root.showcase ? 1.6 : 0.7 }
206
+ DirectionalLight { // Showcase rim: a cool edge from behind lifts dark parts off the dark stage
207
+ visible: root.showcase
208
+ eulerRotation: Qt.vector3d(-28, root.yaw + 150, 0)
209
+ brightness: 2.4; color: "#bcd8ff"
210
+ }
211
+ SpotLight { // Showcase top light: a soft pool on the stage
212
+ visible: root.showcase
213
+ position: Qt.vector3d(studio.center[0], studio.radius * 4, studio.center[2])
214
+ eulerRotation.x: -90
215
+ brightness: 4.5
216
+ coneAngle: 50; innerConeAngle: 20
217
+ constantFade: 1; linearFade: 0; quadraticFade: 0
218
+ }
219
+
220
+ Model { // workshop floor grid
221
+ visible: !root.showcase && !root.present && root.gridOn
222
+ source: "#Rectangle"
223
+ eulerRotation.x: -90
224
+ scale: Qt.vector3d(1200, 1200, 1)
225
+ materials: GridMaterial {
226
+ blueprint: root.blueprint
227
+ fade: Math.max(root.dist * 6, studio.radius * 8)
228
+ span: root.dist
229
+ lineColor: Qt.tint(Theme.gridMinor, Qt.rgba(0.2, 0.55, 0.85, root.blueprint))
230
+ majorColor: Qt.tint(Theme.gridMajor, Qt.rgba(0.3, 0.8, 1.0, root.blueprint))
231
+ }
232
+ }
233
+ Model { // shadow catcher in the workshop; a glossy stage in Showcase; a white matte stage in Present
234
+ source: "#Rectangle"
235
+ eulerRotation.x: -90
236
+ y: -0.3
237
+ scale: Qt.vector3d(root.present ? 50000 : 1200, root.present ? 50000 : 1200, 1)
238
+ receivesShadows: true
239
+ castsShadows: false
240
+ opacity: root.showcase ? 1.0 : root.present ? 1.0 : (Theme.dark ? 0.5 : 0.4) * (1 - root.blueprint)
241
+ materials: PrincipledMaterial {
242
+ baseColor: root.showcase ? "#0d0e11" : root.present ? "#ffffff" : Theme.dark ? Theme.raised : "#8a929c"
243
+ roughness: root.showcase ? 0.5 : 1
244
+ metalness: 0
245
+ specularAmount: root.showcase ? 0.12 : 0 // a glossy floor mirrored the probe into grey haze
246
+ }
247
+ }
248
+
249
+ // ---- reference images (image to 3D keeps the views it was built from): one plane per view, standing on
250
+ // the floor behind the model on its own axis, the way a DCC places blueprints. Front looks down -Z.
251
+ Node {
252
+ id: refs
253
+ visible: root.referenceOn && !root.showcase && !root.present && studio.reference.length > 0
254
+ readonly property real h: studio.dimensions.length === 3 ? studio.dimensions[1] : 100
255
+ readonly property real away: studio.radius * 1.15
256
+ readonly property var place: ({ front: [Qt.vector3d(0, 0, -1), 0], back: [Qt.vector3d(0, 0, 1), 180],
257
+ left: [Qt.vector3d(-1, 0, 0), 90], right: [Qt.vector3d(1, 0, 0), -90] })
258
+ Repeater3D {
259
+ model: studio.reference
260
+ delegate: Model {
261
+ required property var modelData
262
+ readonly property var pl: refs.place[modelData.key] || refs.place.front
263
+ readonly property real side: refs.h / modelData.fill // the figure in the picture is as tall as the model
264
+ source: "#Rectangle"
265
+ position: Qt.vector3d(studio.center[0] + pl[0].x * refs.away, refs.h / 2 + (modelData.cy - 0.5) * side,
266
+ studio.center[2] + pl[0].z * refs.away)
267
+ eulerRotation.y: pl[1]
268
+ scale: Qt.vector3d(side / 100, side / 100, 1)
269
+ castsShadows: false; receivesShadows: false
270
+ pickable: false
271
+ materials: ReferenceMaterial {
272
+ tex: TextureInput { texture: Texture { source: "file://" + modelData.path } }
273
+ }
274
+ }
275
+ }
276
+ }
277
+
278
+ Node {
279
+ id: build
280
+ y: studio.ground + root.lift
281
+ Repeater3D {
282
+ id: partsRep
283
+ model: studio.shapes
284
+ delegate: Node {
285
+ id: part
286
+ required property var modelData
287
+ readonly property string shapeId: modelData.shapeId
288
+ readonly property bool isSel: studio.selected === shapeId || studio.selected === modelData.component
289
+ readonly property bool hiddenComp: root.hidden[modelData.component] === true
290
+ readonly property bool dimmed: root.isolate !== "" && root.isolate !== modelData.component
291
+ readonly property vector3d boom: modelData.explodeOffset.times(root.explode)
292
+ property real reveal: modelData.phase === 1 ? 0.0 : 1.0
293
+ position: boom.plus(studio.selected === shapeId && gizmo.dragging ? gizmo.offset : Qt.vector3d(0, 0, 0))
294
+ visible: !hiddenComp && reveal > 0.001
295
+ opacity: dimmed ? 0.07 : 1.0
296
+ Behavior on opacity { NumberAnimation { duration: 280 } }
297
+
298
+ Model {
299
+ property string shapeId: part.shapeId
300
+ geometry: part.modelData
301
+ pickable: !part.dimmed
302
+ castsShadows: true
303
+ receivesShadows: true
304
+ visible: root.displayMode !== "wire"
305
+ opacity: root.displayMode === "xray" ? 0.18 : 1.0
306
+ materials: HoloMaterial {
307
+ alpha: part.modelData.opacity
308
+ baseColor: part.modelData.baseColor
309
+ emissiveColor: part.modelData.emissive
310
+ tint: part.modelData.componentColor
311
+ tintAmount: root.colorByComponent ? 0.75 : 0.0
312
+ metal: part.modelData.metalness
313
+ rough: part.modelData.roughness
314
+ minY: part.modelData.minY + studio.ground + part.boom.y
315
+ maxY: part.modelData.maxY + studio.ground + part.boom.y
316
+ reveal: part.reveal
317
+ blueprint: root.blueprint
318
+ selected: part.isSel ? 1.0 : 0.0
319
+ xray: root.displayMode === "xray" ? 1.0 : 0.0
320
+ }
321
+ }
322
+ Model {
323
+ geometry: part.modelData.edges
324
+ visible: root.displayMode !== "shaded" || root.blueprint > 0.3 || part.isSel
325
+ materials: EdgeMaterial {
326
+ lineColor: part.isSel ? Theme.amber
327
+ : root.blueprint > 0.3 ? Qt.rgba(0.55, 0.9, 1.0, 1)
328
+ : (root.displayMode === "wire" || root.displayMode === "xray") ? part.modelData.componentColor
329
+ : "#0c0d10"
330
+ strength: root.displayMode === "lines" ? 0.85 : 1.0
331
+ minY: part.modelData.minY + studio.ground + part.boom.y
332
+ maxY: part.modelData.maxY + studio.ground + part.boom.y
333
+ reveal: part.reveal
334
+ }
335
+ }
336
+ NumberAnimation on reveal {
337
+ running: part.modelData.phase === 1
338
+ from: 0; to: 1; duration: root.revealMs; easing.type: Easing.InOutCubic
339
+ }
340
+ NumberAnimation on reveal {
341
+ running: part.modelData.phase === 2
342
+ from: 1; to: 0; duration: root.revealMs * 0.8; easing.type: Easing.InOutCubic
343
+ }
344
+ }
345
+ }
346
+ }
347
+
348
+ // ---- move gizmo (X red, Y green, Z blue), always drawn on top
349
+ Node {
350
+ id: gizmo
351
+ property bool dragging: false
352
+ property int axis: -1
353
+ property vector3d offset: Qt.vector3d(0, 0, 0)
354
+ property var geo: root.tool === "move" && !root.showcase ? root.selectedGeo() : null
355
+ visible: geo !== null
356
+ readonly property real s: root.dist * 0.0011
357
+ position: geo ? Qt.vector3d(geo.center.x, geo.center.y + studio.ground, geo.center.z)
358
+ .plus(geo.explodeOffset.times(root.explode)).plus(offset) : Qt.vector3d(0, 0, 0)
359
+ Repeater3D {
360
+ model: [ { a: 0, c: "#e5484d", r: Qt.vector3d(0, 0, -90) },
361
+ { a: 1, c: "#7bd88f", r: Qt.vector3d(0, 0, 0) },
362
+ { a: 2, c: "#3d8ee6", r: Qt.vector3d(90, 0, 0) } ]
363
+ delegate: Node {
364
+ id: arrow
365
+ required property var modelData
366
+ eulerRotation: modelData.r
367
+ scale: Qt.vector3d(gizmo.s, gizmo.s, gizmo.s)
368
+ Model {
369
+ property int gizmoAxis: arrow.modelData.a
370
+ source: "#Cylinder"; pickable: true
371
+ y: 50; scale: Qt.vector3d(0.045, 1.0, 0.045)
372
+ depthBias: -100000
373
+ materials: DefaultMaterial {
374
+ lighting: DefaultMaterial.NoLighting
375
+ diffuseColor: gizmo.axis === arrow.modelData.a ? "#ffffff" : arrow.modelData.c
376
+ }
377
+ }
378
+ Model {
379
+ property int gizmoAxis: arrow.modelData.a
380
+ source: "#Cone"; pickable: true
381
+ y: 100; scale: Qt.vector3d(0.16, 0.3, 0.16)
382
+ depthBias: -100000
383
+ materials: DefaultMaterial {
384
+ lighting: DefaultMaterial.NoLighting
385
+ diffuseColor: gizmo.axis === arrow.modelData.a ? "#ffffff" : arrow.modelData.c
386
+ }
387
+ }
388
+ }
389
+ }
390
+ }
391
+ }
392
+
393
+ // ---- input: C4D (Alt+L orbit, Alt+M pan, Alt+R dolly) and plain (L orbit, M or Shift+L pan, R dolly)
394
+ MouseArea {
395
+ id: mouse
396
+ anchors.fill: parent
397
+ acceptedButtons: Qt.AllButtons
398
+ hoverEnabled: true
399
+ property real lx: 0
400
+ property real ly: 0
401
+ property real px: 0
402
+ property real py: 0
403
+ property string act: ""
404
+ property bool moved: false
405
+ property vector2d gDir: Qt.vector2d(1, 0)
406
+ property real gUnits: 1
407
+
408
+ function pickGizmo(x, y) {
409
+ if (!gizmo.visible) return -1
410
+ const hits = view.pickAll(x, y)
411
+ for (let i = 0; i < hits.length; i++) {
412
+ const o = hits[i].objectHit
413
+ if (o && o.gizmoAxis !== undefined) return o.gizmoAxis
414
+ }
415
+ return -1
416
+ }
417
+ onPressed: (m) => {
418
+ root.forceActiveFocus()
419
+ root.idle = 0
420
+ root.userInteracted()
421
+ lx = px = m.x; ly = py = m.y; moved = false
422
+ const alt = m.modifiers & Qt.AltModifier
423
+ const shift = m.modifiers & Qt.ShiftModifier
424
+ if (m.button === Qt.LeftButton && !alt) {
425
+ const ax = pickGizmo(m.x, m.y)
426
+ if (ax >= 0) {
427
+ act = "gizmo"; gizmo.axis = ax; gizmo.offset = Qt.vector3d(0, 0, 0); gizmo.dragging = true
428
+ const c = gizmo.position
429
+ const L = studio.radius * 0.2
430
+ const a = ax === 0 ? Qt.vector3d(L, 0, 0) : ax === 1 ? Qt.vector3d(0, L, 0) : Qt.vector3d(0, 0, L)
431
+ const p0 = view.mapFrom3DScene(c), p1 = view.mapFrom3DScene(c.plus(a))
432
+ const d = Qt.vector2d(p1.x - p0.x, p1.y - p0.y)
433
+ gDir = d.normalized(); gUnits = L / Math.max(d.length(), 0.001)
434
+ return
435
+ }
436
+ }
437
+ if (m.button === Qt.MiddleButton) act = "pan"
438
+ else if (m.button === Qt.RightButton) act = "dolly"
439
+ else if (shift) act = "pan"
440
+ else if (m.modifiers & Qt.ControlModifier) act = "dolly" // one-button mice and trackpads
441
+ else act = "orbit"
442
+ }
443
+ onPositionChanged: (m) => {
444
+ if (!pressed) return
445
+ const dx = m.x - lx, dy = m.y - ly
446
+ lx = m.x; ly = m.y
447
+ if (Math.abs(m.x - px) + Math.abs(m.y - py) > 4) moved = true
448
+ if (!moved) return
449
+ root.idle = 0
450
+ if (act === "orbit") {
451
+ if (root.ortho) { root.ortho = false; root.viewName = "Perspective" }
452
+ root.tYaw -= dx * 0.32
453
+ root.tPitch = Math.max(-89, Math.min(89, root.tPitch + dy * 0.32))
454
+ } else if (act === "pan") {
455
+ const s = 2 * root.dist * Math.tan(root.fov / 2 * Math.PI / 180) / view.height
456
+ root.tPivot = root.tPivot.minus(root.camRight.times(dx * s)).plus(root.camUp.times(dy * s))
457
+ } else if (act === "dolly") {
458
+ root.tDist = Math.max(root.minDist, Math.min(root.maxDist, root.tDist * Math.exp(dy * 0.006)))
459
+ } else if (act === "gizmo") {
460
+ const t = (m.x - px) * gDir.x + (m.y - py) * gDir.y
461
+ let v = t * gUnits
462
+ if (m.modifiers & Qt.ControlModifier) v = Math.round(v / 10) * 10 // 10 mm snap
463
+ else if (!(m.modifiers & Qt.ShiftModifier)) v = Math.round(v) // Shift = free
464
+ gizmo.offset = gizmo.axis === 0 ? Qt.vector3d(v, 0, 0)
465
+ : gizmo.axis === 1 ? Qt.vector3d(0, v, 0) : Qt.vector3d(0, 0, v)
466
+ }
467
+ }
468
+ onReleased: (m) => {
469
+ if (act === "gizmo") {
470
+ const o = gizmo.offset
471
+ gizmo.dragging = false; gizmo.axis = -1
472
+ gizmo.offset = Qt.vector3d(0, 0, 0)
473
+ if (o.length() > 0.001) studio.nudge(studio.selected, o.x, o.y, o.z)
474
+ } else if (!moved && m.button === Qt.LeftButton && root.tool === "measure") {
475
+ const r = view.pick(m.x, m.y)
476
+ if (r.objectHit) {
477
+ const pts = root.measurePts.length >= 2 ? [] : root.measurePts.slice()
478
+ pts.push(r.scenePosition)
479
+ root.measurePts = pts
480
+ }
481
+ } else if (!moved && (m.button === Qt.LeftButton || m.button === Qt.RightButton)) {
482
+ const r = view.pick(m.x, m.y)
483
+ const id = r.objectHit && r.objectHit.shapeId !== undefined ? r.objectHit.shapeId : ""
484
+ if (m.button === Qt.LeftButton) root.picked(id)
485
+ else { const p = mouse.mapToItem(null, m.x, m.y); root.contextRequested(id, p.x, p.y) }
486
+ }
487
+ act = ""
488
+ }
489
+ onDoubleClicked: (m) => { // re-centre the orbit on the point under the cursor
490
+ const r = view.pick(m.x, m.y)
491
+ if (r.objectHit) root.tPivot = r.scenePosition
492
+ }
493
+ onWheel: (w) => {
494
+ root.idle = 0
495
+ root.userInteracted()
496
+ if (w.modifiers & Qt.AltModifier) { root.explodeNudge(w.angleDelta.y / 1200); return }
497
+ const f = Math.exp(-w.angleDelta.y / 120 * 0.14)
498
+ const nd = Math.max(root.minDist, Math.min(root.maxDist, root.tDist * f))
499
+ const r = view.pick(w.x, w.y) // zoom toward what is under the cursor
500
+ if (r.objectHit && nd < root.tDist)
501
+ root.tPivot = root.tPivot.plus(r.scenePosition.minus(root.tPivot).times(1 - nd / root.tDist))
502
+ root.tDist = nd
503
+ }
504
+ }
505
+
506
+ PinchHandler { // touchpad pinch: explode in Dissect, zoom elsewhere
507
+ target: null
508
+ onScaleChanged: (delta) => {
509
+ if (studio.mode === "dissect") root.explodeNudge((delta - 1) * 1.5)
510
+ else root.tDist = Math.max(root.minDist, Math.min(root.maxDist, root.tDist / delta))
511
+ }
512
+ }
513
+
514
+ // ---- measure overlay: picked points, the line between them and the distance with its X, Y, Z parts
515
+ Item {
516
+ id: measure
517
+ anchors.fill: parent
518
+ visible: root.tool === "measure" && root.measurePts.length > 0
519
+ readonly property var pts: {
520
+ root.tick
521
+ return root.measurePts.map(p => root.project(p))
522
+ }
523
+ readonly property var d: root.measurePts.length === 2 ? root.measurePts[1].minus(root.measurePts[0]) : null
524
+ function fmt(v) { return Math.abs(v) >= 100 ? v.toFixed(1) : Math.abs(v) >= 1 ? v.toFixed(2) : v.toFixed(3) }
525
+ Rectangle {
526
+ visible: measure.pts.length === 2
527
+ readonly property var a: measure.pts.length > 0 ? measure.pts[0] : Qt.point(0, 0)
528
+ readonly property var b: measure.pts.length === 2 ? measure.pts[1] : a
529
+ x: a.x; y: a.y - 1; height: 2; color: Theme.accent; antialiasing: true
530
+ width: Math.hypot(b.x - a.x, b.y - a.y)
531
+ transformOrigin: Item.Left
532
+ rotation: Math.atan2(b.y - a.y, b.x - a.x) * 180 / Math.PI
533
+ }
534
+ Repeater {
535
+ model: measure.pts
536
+ delegate: Rectangle {
537
+ required property var modelData
538
+ x: modelData.x - 5; y: modelData.y - 5; width: 10; height: 10; radius: 5
539
+ color: Theme.bg; border.color: Theme.accent; border.width: 2
540
+ }
541
+ }
542
+ Rectangle {
543
+ visible: measure.d !== null
544
+ x: measure.pts.length === 2 ? (measure.pts[0].x + measure.pts[1].x) / 2 + 12 : 0
545
+ y: measure.pts.length === 2 ? (measure.pts[0].y + measure.pts[1].y) / 2 - height - 8 : 0
546
+ width: mLabel.implicitWidth + 16; height: mLabel.implicitHeight + 10; radius: 6
547
+ color: Theme.panel; border.color: Theme.line
548
+ Text {
549
+ id: mLabel
550
+ anchors.centerIn: parent
551
+ color: Theme.text; font.family: Theme.mono; font.pixelSize: Theme.fsSmall
552
+ text: !measure.d ? "" : measure.fmt(measure.d.length()) + " " + studio.units
553
+ + "\nΔX " + measure.fmt(measure.d.x) + " ΔY " + measure.fmt(measure.d.y) + " ΔZ " + measure.fmt(measure.d.z)
554
+ }
555
+ }
556
+ }
557
+ Text {
558
+ anchors.horizontalCenter: parent.horizontalCenter; anchors.top: parent.top; anchors.topMargin: 14
559
+ visible: root.tool === "measure"
560
+ text: root.measurePts.length === 1 ? "Click a second point" : "Measure: click two points on the model · Esc leaves"
561
+ color: Theme.viewDim; font.pixelSize: Theme.fsTiny; font.family: Theme.sans
562
+ }
563
+
564
+ // ---- HUD: view name, axis triad (click an axis to look down it)
565
+ Text { // camera read-out, bottom right; rises above the capsule when they would overlap
566
+ readonly property bool blocked: root.avoid.width > 0 && parent.width - 14 - implicitWidth < root.avoid.x + root.avoid.width + 32
567
+ && parent.height - 14 - implicitHeight < root.avoid.y + root.avoid.height
568
+ anchors.right: parent.right; anchors.bottom: parent.bottom; anchors.margins: 14
569
+ anchors.bottomMargin: blocked ? parent.height - root.avoid.y + 8 : 14
570
+ visible: !root.showcase && !root.present && studio.stepCount > 0
571
+ text: "GRID " + (root.gridCell >= 1000 ? root.gridCell / 1000 + " m" : root.gridCell + " mm") + " "
572
+ + (root.ortho ? "ORTHO" : "PERSP " + root.fov + "°") + " " + Math.round(root.dist) + " mm"
573
+ + (root.tool === "move" ? " MOVE" : root.tool === "measure" ? " MEASURE" : "")
574
+ color: Theme.viewDim
575
+ font.pixelSize: Theme.fsTiny; font.family: Theme.mono
576
+ }
577
+ NavGizmo {
578
+ anchors.right: parent.right; anchors.top: parent.top; anchors.margins: 10
579
+ visible: !root.showcase && !root.present && studio.stepCount > 0
580
+ yaw: root.yaw; pitch: root.pitch
581
+ onSnap: (name) => root.setView(name)
582
+ }
583
+ }
File without changes