openconfiguration 1.5.0

OpenConfiguration (OC) is a modular, efficient and flexible approach for the uni-directional exchange of visual e-commerce configurations.
Documentation
use serde::{Deserialize, Serialize};

use crate::{impl_visitable_noop, Quaternion, Vector3};

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
/// The type of the point
/// "Origin" - the origin of a product, matches to "Child"
/// "Child" - a (virtual) child can be placed, matches to "Origin"
/// "Left" - L-R neighborship, matches to "Right"
/// "Right" - L-R neighborship, matches to "Left"
/// "Top" - vertical neighborship, matches to "Bottom"
/// "Bottom" - vertical neighborship, matches to "Top"
/// "Front" - front/back neighborship, matches to "Back"
/// "Back" - front/back neighborship, matches to "Front"
/// "Alignment" - auxiliary point to support alignments
/// "Maximum" - marks the maximum of the bbox
/// "Minimum" - marks the minimum of the bbox
pub enum AttachPointType {
    Origin,
    Child,
    Left,
    Right,
    Top,
    Bottom,
    Front,
    Back,
    Alignment,
    Maximum,
    Minimum,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub enum AttachPointRepresentation {
    Standard,
    Ghost,
    Ghost2,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "schema", schemars(deny_unknown_fields))]
#[serde(rename_all = "camelCase")]
/// An attachment point for planning support and placement of children.
/// All attributes are mandatory, except for Tags.
///
/// Two attachment points match:
/// - if Key and Foreign match, if needed with wildcards in the Foreign key,
/// - there's at least one matching Tag on both sides, in case at least one has tags,
/// - the Types match to each other, such as L - R
/// - both of them are enabled
/// - the position offset in global space is less than 0.2 [m]
/// - the rotation offset in global space is less than 45 deg
///
/// IGXC Compatibility: the Rotation is changed to Quaternion, in IGXC it
/// was Euler-based.
pub struct AttachPoint {
    #[serde(rename = "type")]

    /// The type of the point
    pub kind: AttachPointType,

    /// Own key of the point. Should match the counterpart's foreign key.
    pub key: String,

    /// Allowed keys of counterpart's points. May contain /// and ? characters.
    pub foreign: String,

    /// An optional list of ids or tags to be used for attach-point matching.
    /// If one point defines tags, the other point matches--if it already
    /// matches--and additionally provides at least one compatible tag.
    /// Two tags are compatible if there case-normalized versions are equal.
    pub tags: Option<Vec<String>>,

    /// The position of the point, relative to the Product.
    pub point: Vector3,

    /// The orientation of the point, relative to the Product.
    pub rotation: Quaternion,

    /// Attribute controls if the point is enabled.
    /// If disabled, it should be invisible too.
    pub enabled: bool,

    /// The visual representation of the attachment point.
    pub representation: AttachPointRepresentation,
}

impl_visitable_noop!(AttachPoint);