Skip to content

Commit 081381e

Browse files
committed
qtvcp -docs: update qt_vismach programming guide
1 parent 5e27875 commit 081381e

1 file changed

Lines changed: 70 additions & 8 deletions

File tree

docs/src/gui/qtvcp-vismach.adoc

Lines changed: 70 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*Vismach* is a set of *Python functions that can be used to create and animate models of machines*.
88

99
This chapter is about the Qt embedded version of <<cha:vismach,Vismach>>.
10+
Also see: https://sa-cnc.com/linuxcnc-vismach/
1011

1112
[[sec:qtvcp:vismach:intro]]
1213
== Introduction
@@ -53,7 +54,6 @@ Taking the mill shown in the 3D Viewport picture above for example:
5354

5455
So for this machine, the tree looks like this:
5556

56-
//FIXME Shouldn't yassembly be a branch of base and zassembly a branch of column ?
5757
----
5858
model
5959
|
@@ -149,8 +149,7 @@ It is probably easiest to:
149149
* _create geometry in a CAD package_
150150
* _import into the model script using the `AsciiSTL()` or `AsciiOBJ()` functions_.
151151

152-
//FIXME Ascii(STL|OBJ): what's the second arg ?
153-
Both functions can take one of two named arguments, either a _filename_ or _raw data_:
152+
Both functions can take one of two named arguments, either a _filename_ or _data_:
154153

155154
[source,python]
156155
----
@@ -160,8 +159,12 @@ part = AsciiOBJ(filename="path/to/file.obj")
160159
part = AsciiOBJ(data="v 0.123 0.234 0.345 1.0 ...")
161160
----
162161

163-
The parts will be created in the Vismach space in the _same locations as they occupy in the STL or OBJ space_,
164-
meaning it may be possible to assemble the model in the CAD package.
162+
- STL model parts are added to the Vismach space in the _same locations as they were created in the STL or OBJ space_,
163+
ie ideally with a rotational point at their origin.
164+
165+
[NOTE]
166+
It is much easier to move while building if the origin of the model is at
167+
a rotational pivot point.
165168

166169
[[sub:qtvcp:vismach:primitives]]
167170
=== Build from Geometric Primitives
@@ -204,6 +207,8 @@ part4 = Collection([part1, part2])
204207
== Moving Model Parts
205208

206209
Parts may need to be moved in the Vismach space to assemble the model.
210+
The origin does not move - Translate() and Rotate() move the Collection
211+
as you add parts, relative to a stationary origin.
207212

208213
//FIXME unclear
209214
They may also need to be moved to create the animation as the animation
@@ -217,16 +222,16 @@ rotation axis is created at the origin (but moves with the Part).
217222
[[sub:qtvcp:vismach:rotate]]
218223
=== Rotating Model Parts
219224

220-
//FIXME angle unit ?
221225
*`part1 = Rotate([part1], theta, x, y, z)`*::
222-
Rotate the part by angle theta about an axis between the origin and x, y, z.
226+
Rotate the part by angle theta degrees about an axis between the origin and
227+
x, y, z.
223228

224229
[[sec:qtvcp:vismach:animate]]
225230
== Animating Parts
226231

227232
//FIXME 2 or 3 functions ? HalToolCylinder not documented here ?
228233
To *animate the model controlled by the values of HAL pins* there are
229-
two functions `HalTranslate`, `HalRotate` and `HalToolCylinder`.
234+
four functions `HalTranslate`, `HalRotate`, `HalToolCylinder` and 'HalToolTriangle'.
230235

231236
_For parts to move inside an assembly they need to have their HAL motions
232237
defined before being assembled with the "Collection" command_.
@@ -274,6 +279,36 @@ Otherwise the component instance would be specified and the pin name of that com
274279
the axis of rotation can be considered to remain "embedded" in the part.
275280
`angle_scale`;; _Rotation angles_ are in degrees, so for a rotary joint with a 0-1 scaling you would need to use an angle scale of 360.
276281

282+
=== 'HalToolCylinder'
283+
284+
*`tool = HalToolCylinder()`*::
285+
Make a cylinder to represent a cylindrical mill tool, based on the tool table
286+
and current loaded tool.
287+
288+
[source,python]
289+
----
290+
tool = HalToolCylinder()
291+
toolshape = Color([1, .5, .5, .5],[tool])
292+
293+
# or more compact:
294+
toolshape = Color([1, .5, .5, .5], [HalToolCylinder()])
295+
----
296+
297+
=== 'HalToolTriangle'
298+
299+
*`tool = HalToolTriangle()`*::
300+
Make a triangle to represent a triangular lathe tool, based on the tool table
301+
and current loaded tool.
302+
303+
[source,python]
304+
----
305+
tool = HalToolTriangle()
306+
toolshape = Color([1, 1, 0, 1],[tool])
307+
308+
# or more compact:
309+
toolshape = Color([1, 1, 0, 1],[HalToolTriangle()])
310+
----
311+
277312
[[sec:qtvcp:vismach:assembly]]
278313
== Assembling the model
279314

@@ -370,6 +405,33 @@ model = Collection([base, saddle, head, carousel])
370405
`_rotation_vectors_` or `_lat, lon_`;; Can be used to set the original viewpoint. +
371406
It is advisable to do as the default initial viewpoint is rather unhelpful from immediately overhead.
372407

408+
409+
== Tips
410+
create an axes origin marker to be able to see parts relative to it, for
411+
construction purposes. You can remove it when you are done.
412+
413+
[source,python]
414+
----
415+
# build axis origin markers
416+
X = CylinderX(-500,1,500,1)
417+
X = Color([1, 0, 0, 1], [X])
418+
Y = CylinderY(-500,1,500,1)
419+
Y = Color([0, 1, 0, 1], [Y])
420+
Z = CylinderZ(-500,1,500,1)
421+
Z = Color([0, 0, 1, 1], [Z])
422+
origin = Collection([X,Y,Z])
423+
----
424+
425+
Add it to the Window class Collection so it is never moved from the origin.
426+
[source,python]
427+
----
428+
v.model = Collection([origin, model, world])
429+
----
430+
431+
Start from the cutting tip and work your way back.
432+
add each collection to the model at the origin and run the script to confirm
433+
the location, then rotate/translate and run the script to confirm again.
434+
373435
[[sec:qtvcp:vismach:structure]]
374436
== Basic structure of a `QtVismach` script
375437

0 commit comments

Comments
 (0)