public bool AddBehaviour(IGizmoBehaviour behaviour) { if (behaviour == null || behaviour.Gizmo != null) { return(false); } GizmoBehaviorInitParams initParams = new GizmoBehaviorInitParams(); initParams.Gizmo = this; behaviour.Init_SystemCall(initParams); if (!_behaviours.Add(behaviour)) { return(false); } Type behaviourType = behaviour.GetType(); if (behaviourType == typeof(MoveGizmo)) { _moveGizmo = behaviour as MoveGizmo; } else if (behaviourType == typeof(RotationGizmo)) { _rotationGizmo = behaviour as RotationGizmo; } else if (behaviourType == typeof(ScaleGizmo)) { _scaleGizmo = behaviour as ScaleGizmo; } else if (behaviourType == typeof(UniversalGizmo)) { _universalGizmo = behaviour as UniversalGizmo; } else if (behaviourType == typeof(SceneGizmo)) { _sceneGizmo = behaviour as SceneGizmo; } else if (behaviourType == typeof(BoxGizmo)) { _boxGizmo = behaviour as BoxGizmo; } else if (behaviourType == typeof(ObjectTransformGizmo)) { _objectTransformGizmo = behaviour as ObjectTransformGizmo; } else if (behaviourType == typeof(ObjectExtrudeGizmo)) { _objectExtrudeGizmo = behaviour as ObjectExtrudeGizmo; } behaviour.OnAttached(); behaviour.OnEnabled(); return(true); }
public ScaleGizmo CreateScaleGizmo() { Gizmo gizmo = CreateGizmo(); ScaleGizmo scaleGizmo = new ScaleGizmo(); gizmo.AddBehaviour(scaleGizmo); return(scaleGizmo); }
public ObjectTransformGizmo CreateObjectScaleGizmo() { ScaleGizmo scaleGizmo = CreateScaleGizmo(); var transformGizmo = scaleGizmo.Gizmo.AddBehaviour <ObjectTransformGizmo>(); transformGizmo.SetTransformChannelFlags(ObjectTransformGizmo.Channels.Scale); transformGizmo.SetTransformSpace(GizmoSpace.Local); transformGizmo.MakeTransformSpacePermanent(); return(transformGizmo); }
public bool RemoveBehaviour(IGizmoBehaviour behaviour) { if (behaviour == null) { return(false); } if (behaviour == _moveGizmo) { _moveGizmo = null; } else if (behaviour == _rotationGizmo) { _rotationGizmo = null; } else if (behaviour == _scaleGizmo) { _scaleGizmo = null; } else if (behaviour == _universalGizmo) { _universalGizmo = null; } else if (behaviour == _sceneGizmo) { _sceneGizmo = null; } else if (behaviour == _boxGizmo) { _boxGizmo = null; } else if (behaviour == _objectTransformGizmo) { _objectTransformGizmo = null; } else if (behaviour == _objectExtrudeGizmo) { _objectExtrudeGizmo = null; } return(_behaviours.Remove(behaviour)); }
private bool RegisterGizmo(int gizmoId, Gizmo gizmo) { if (IsGizmoRegistered(gizmoId) || IsGizmoRegistered(gizmo)) { return(false); } _allGizmos.Add(new ObjectSelectionGizmo(gizmoId, gizmo)); ObjectTransformGizmo transformGizmo = gizmo.GetFirstBehaviourOfType <ObjectTransformGizmo>(); if (transformGizmo != null) { _objectTransformGizmos.Add(transformGizmo); transformGizmo.SetTargetObjects(_targetObjectCollection); } MoveGizmo moveGizmo = gizmo.GetFirstBehaviourOfType <MoveGizmo>(); if (moveGizmo != null) { moveGizmo.SharedSettings2D = MoveGizmoSettings2D; moveGizmo.SharedSettings3D = MoveGizmoSettings3D; moveGizmo.SharedLookAndFeel2D = MoveGizmoLookAndFeel2D; moveGizmo.SharedLookAndFeel3D = MoveGizmoLookAndFeel3D; moveGizmo.SharedHotkeys = MoveGizmoHotkeys; moveGizmo.SetVertexSnapTargetObjects(_targetObjectCollection); if (transformGizmo != null) { transformGizmo.SharedSettings = ObjectMoveGizmoSettings; } } RotationGizmo rotationGizmo = gizmo.GetFirstBehaviourOfType <RotationGizmo>(); if (rotationGizmo != null) { rotationGizmo.SharedSettings3D = RotationGizmoSettings3D; rotationGizmo.SharedLookAndFeel3D = RotationGizmoLookAndFeel3D; rotationGizmo.SharedHotkeys = RotationGizmoHotkeys; if (transformGizmo != null) { transformGizmo.SharedSettings = ObjectRotationGizmoSettings; } } ScaleGizmo scaleGizmo = gizmo.GetFirstBehaviourOfType <ScaleGizmo>(); if (scaleGizmo != null) { scaleGizmo.SharedSettings3D = ScaleGizmoSettings3D; scaleGizmo.SharedLookAndFeel3D = ScaleGizmoLookAndFeel3D; scaleGizmo.SharedHotkeys = ScaleGizmoHotkeys; scaleGizmo.SetScaleGuideTargetObjects(_targetObjectCollection); if (transformGizmo != null) { transformGizmo.SharedSettings = ObjectScaleGizmoSettings; } } BoxGizmo boxScaleGizmo = gizmo.GetFirstBehaviourOfType <BoxGizmo>(); if (boxScaleGizmo != null) { boxScaleGizmo.SharedSettings3D = BoxScaleGizmoSettings3D; boxScaleGizmo.SharedLookAndFeel3D = BoxScaleGizmoLookAndFeel3D; boxScaleGizmo.SharedHotkeys = BoxScaleGizmoHotkeys; } UniversalGizmo universalGizmo = gizmo.GetFirstBehaviourOfType <UniversalGizmo>(); if (universalGizmo != null) { universalGizmo.SharedSettings2D = UniversalGizmoSettings2D; universalGizmo.SharedSettings3D = UniversalGizmoSettings3D; universalGizmo.SharedLookAndFeel2D = UniversalGizmoLookAndFeel2D; universalGizmo.SharedLookAndFeel3D = UniversalGizmoLookAndFeel3D; universalGizmo.SharedHotkeys = UniversalGizmoHotkeys; universalGizmo.SetMvVertexSnapTargetObjects(_targetObjectCollection); universalGizmo.SetScaleGuideTargetObjects(_targetObjectCollection); if (transformGizmo != null) { transformGizmo.SharedSettings = ObjectUniversalGizmoSettings; } } ObjectExtrudeGizmo extrudeGizmo = gizmo.GetFirstBehaviourOfType <ObjectExtrudeGizmo>(); if (extrudeGizmo != null) { extrudeGizmo.SharedLookAndFeel3D = ExtrudeGizmoLookAndFeel3D; extrudeGizmo.SharedHotkeys = ExtrudeGozmoHotkeys; extrudeGizmo.SetExtrudeTargets(_targetObjectCollection); } gizmo.PostEnabled += OnGizmoPostEnabled; return(true); }