Files
create/src/Mod/CAM/App
Billy Huddleston a970235484 CAM: Enhance Path.Command annotations with variant type, type-safe API, and robust persistence
- Refactored `Annotations` member to use `std::variant<std::string, double>` for type-safe storage of both string and numeric values.
- Implemented C++ methods:
	- `setAnnotation(key, value)`: overloaded for string and double types.
	- `getAnnotation(key)`: returns annotation value as string.
	- `getAnnotationString(key)`: returns string annotation.
	- `getAnnotationDouble(key, fallback)`: returns numeric annotation.
	- `getAnnotationValue(key)`: returns raw variant value.
	- `hasAnnotation(key)`: checks for annotation existence.
	- `setAnnotations(annotationString)`: parses and stores values as double if possible, otherwise as string.
- Improved XML serialization (`Save`) and deserialization (`Restore`) to persist annotation types and values, including annotation count for robust restoration.
- Updated Python bindings:
	- `Annotations` property now supports mixed-type values (str/float).
	- Values are returned as native Python types.
	- Type errors are raised for invalid assignments.
- Expanded tests in `TestPathCommandAnnotations.py`:
	- Added cases for mixed-type annotations, edge cases, and in-memory persistence using `dumpContent`/`restoreContent`.
	- Verified type preservation and correct restoration.
- Ensured backward compatibility for string-only annotations and improved error handling.

**How to use annotations in Python:**

```import Path

c = Path.Command('G1', {'X': 10.0, 'Y': 20.0, 'F': 1000.0})
c.Annotations = {
	'tool_name': '6mm_endmill',      # string
	'spindle_speed': 12000.0,        # float
	'feed_rate': 1500,               # int (stored as float)
	'operation': 'pocket',           # string
	'depth_of_cut': -2.5,            # negative float
}
print(c.Annotations)  # {'tool_name': '6mm_endmill', 'spindle_speed': 12000.0, ...}
print(type(c.Annotations['spindle_speed']))  # <class 'float'>
print(type(c.Annotations['tool_name']))      # <class 'str'>

xml = c.dumpContent()
c2 = Path.Command()
c2.restoreContent(xml)
print(c2.Annotations)  # Restored with correct types

c.addAnnotations('speed:1000 operation:drill')
print(c.Annotations['speed'])        # 1000.0 (float)
print(c.Annotations['operation'])    # 'drill' (str)
```
2025-10-15 14:26:13 -04:00
..
2025-10-08 19:11:11 -05:00
2025-10-08 19:11:11 -05:00
2025-10-08 19:11:11 -05:00
2025-10-08 19:11:11 -05:00
2025-10-08 19:11:11 -05:00
2025-10-08 19:11:11 -05:00
2025-10-08 19:11:11 -05:00
2025-10-08 19:11:11 -05:00
2025-10-08 19:11:11 -05:00
2025-10-08 19:11:11 -05:00
2025-10-08 19:11:11 -05:00
2025-10-08 19:11:11 -05:00
2025-10-08 19:11:11 -05:00
2025-10-08 19:11:11 -05:00
2025-10-08 19:11:11 -05:00
2025-10-08 19:11:11 -05:00
2025-10-08 19:11:11 -05:00
2025-10-08 19:11:11 -05:00
2025-10-08 19:11:11 -05:00