void Finish() { constraint.isSelectable = true; MoveTool.instance.EditConstraintValue(constraint, pushUndo: false); constraint = null; e0 = null; }
//Vector3 click; protected override void OnMouseDown(Vector3 pos, ICADObject sko) { /* * if(constraint != null) { * MoveTool.instance.EditConstraintValue(constraint); * constraint = null; * return; * }*/ var entity = sko as IEntity; if (entity == null) { return; } if (entity.Length() != null) { editor.PushUndo(); constraint = new Length(DetailEditor.instance.currentSketch.GetSketch(), entity); //constraint.pos = WorldPlanePos; //click = WorldPlanePos; MoveTool.instance.EditConstraintValue(constraint, pushUndo: false); constraint = null; } }
public EqualValue(Sketch sk, ValueConstraint c0, ValueConstraint c1) : base(sk) { AddConstraint(c0); AddConstraint(c1); value.value = 1.0; Satisfy(); }
public void EditConstraintValue(ValueConstraint constraint) { valueConstraint = constraint; input.gameObject.SetActive(true); input.text = Math.Abs(valueConstraint.GetValue()).ToStr(); input.Select(); UpdateInputPosition(); }
public void EditConstraintValue(ValueConstraint constraint, bool pushUndo = true) { valueConstraint = constraint; this.shouldPushUndo = pushUndo; input.gameObject.SetActive(true); input.text = Math.Abs(valueConstraint.GetValue()).ToStr(); input.Select(); UpdateInputPosition(); }
void DrawStroke(LineCanvas canvas, ValueConstraint c, int rpt) { ref_points[rpt] = c.pos; if (rpt == 0) { Vector3 up = c.GetBasis().GetColumn(1); pos = c.pos + up.normalized * getPixelSize() * 30f; } }
protected override void OnDeactivate() { e0 = null; if (constraint != null) { constraint.Destroy(); editor.PopUndo(); } constraint = null; }
protected override void OnMouseDown(Vector3 pos, ICADObject sko) { if (constraint != null) { MoveTool.instance.EditConstraintValue(constraint); constraint = null; return; } var entity = sko as IEntity; if (entity == null) { return; } if (p0 == null) { if (entity.type == IEntityType.Line) { constraint = new PointsDistance(DetailEditor.instance.currentSketch.GetSketch(), entity); constraint.pos = WorldPlanePos; click = WorldPlanePos; return; } else if (entity is CircleEntity) { var circle = entity as CircleEntity; constraint = new Diameter(circle.sketch, circle); constraint.pos = WorldPlanePos; click = WorldPlanePos; return; } } if (p0 != null) { if (entity.type == IEntityType.Point) { constraint = new PointsDistance(DetailEditor.instance.currentSketch.GetSketch(), p0, entity); constraint.pos = WorldPlanePos; p0 = null; } else if (entity.type == IEntityType.Line) { constraint = new PointLineDistance(DetailEditor.instance.currentSketch.GetSketch(), p0, entity); constraint.pos = WorldPlanePos; p0 = null; } } else if (entity.type == IEntityType.Point) { p0 = entity; } }
void OnEndEdit(string value) { if (valueConstraint == null) { return; } var sign = Math.Sign(valueConstraint.GetValue()); valueConstraint.SetValue(sign * value.ToDouble()); valueConstraint = null; input.gameObject.SetActive(false); }
T SpawnConstraint <T>(Func <T> create) where T : ValueConstraint { if (constraint != null) { constraint.Destroy(); editor.PopUndo(); } editor.PushUndo(); var c = create(); constraint = c; constraint.pos = WorldPlanePos; click = WorldPlanePos; constraint.isSelectable = false; return(c); }
protected override void OnMouseDown(Vector3 pos, ICADObject sko) { var vc = sko as AngleConstraint; if (vc != null) { if (c0 == null) { c0 = vc; } else { editor.PushUndo(); //c0.reference = true; vc.reference = true; new EqualValue(DetailEditor.instance.currentSketch.GetSketch(), c0, vc); c0 = null; } } if (c0 != null) { return; } var entity = sko as IEntity; if (entity == null) { return; } if (entity.Radius() == null && entity.Length() == null) { return; } if (l0 != null) { editor.PushUndo(); new Equal(DetailEditor.instance.currentSketch.GetSketch(), l0, entity); l0 = null; } else { l0 = entity; } }
/// <summary> /// ChangeRule: typeof(ValueConstraint), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.ResizeParentRulePriority; /// Rule to watch the ValueConstraint.TextChanged property so that we can /// update text as needed. TextChanged is triggered when the ValueConstraint is /// first added, so this is sufficient for updating. /// </summary> private static void ValueConstraintTextChangedRule(ElementPropertyChangedEventArgs e) { if (e.DomainProperty.Id == ValueConstraint.TextChangedDomainPropertyId) { ValueConstraint constraint = (ValueConstraint)e.ModelElement; if (!constraint.IsDeleted) { foreach (ShapeElement pel in PresentationViewsSubject.GetPresentation(constraint)) { ValueConstraintShape valueConstraintShape = pel as ValueConstraintShape; if (valueConstraintShape != null) { valueConstraintShape.InvalidateDisplayText(); } } } } }
void OnEndEdit(string value) { if (valueConstraint == null) { return; } var sign = Math.Sign(valueConstraint.GetValue()); if (sign == 0) { sign = 1; } if (shouldPushUndo) { editor.PushUndo(); } valueConstraint.SetValue(sign * value.ToDouble()); valueConstraint = null; input.gameObject.SetActive(false); }
/// <summary> /// Helper method to recursively walk value roles. A value role /// is any role that is allowed to have a value constraint. /// </summary> /// <param name="playedRoles">Roles from an ObjectType to walk. The assumption is made that the /// owning ObjectType is either a value type or has a preferred identifier with exactly one role</param> /// <param name="dataTypeLink">The data type information for the constraint</param> /// <param name="pathRoots">The <see cref="RolePathObjectTypeRoot"/> relationships from a role path associated /// with the root path.</param> /// <param name="previousValueConstraint">The value constraint nearest this value role. /// Any value constraint on the current set of roles must be a subset of the previousValueConstraint.</param> /// <param name="skipRole">A role to skip. If the playedRoles came from a preferred identifier, /// then the skipRole is the opposite role.</param> /// <param name="walkSubtypes">true to walk subtypes. Should be true if the playedRoles come from an /// EntityType and false if they come from a ValueType</param> /// <param name="visitor">The callback delegate</param> /// <returns>true to continue iteration</returns> private static bool WalkDescendedValueRoles(IList<Role> playedRoles, IList<RolePathObjectTypeRoot> pathRoots, ValueTypeHasDataType dataTypeLink, ValueConstraint previousValueConstraint, Role skipRole, bool walkSubtypes, ValueRoleVisitor visitor) { int count = pathRoots.Count; for (int i = 0; i < count; ++i) { RolePathObjectTypeRoot pathRoot = pathRoots[i]; if (!visitor(null, null, pathRoot, dataTypeLink, pathRoot.ValueConstraint, previousValueConstraint)) { return false; } } count = playedRoles.Count; for (int i = 0; i < count; ++i) { Role role = playedRoles[i]; SupertypeMetaRole supertypeRole; if (role == skipRole) { // Nothing to do } else if (null != (supertypeRole = role as SupertypeMetaRole)) { if (walkSubtypes) { SubtypeFact subtypeFact = (SubtypeFact)role.FactType; ObjectType subtype; if (subtypeFact.ProvidesPreferredIdentifier && null != (subtype = subtypeFact.Subtype) && subtype.PreferredIdentifier == null) { if (!WalkDescendedValueRoles(subtype.PlayedRoleCollection, RolePathObjectTypeRoot.GetLinksToRolePathCollection(subtype), dataTypeLink, previousValueConstraint, null, true, visitor)) { return false; } } } } else if (!(role is SubtypeMetaRole)) { RoleValueConstraint currentValueConstraint = role.ValueConstraint; if (!visitor(role, null, null, dataTypeLink, currentValueConstraint, previousValueConstraint)) { return false; } if (currentValueConstraint != null && !currentValueConstraint.IsDeleted) { previousValueConstraint = currentValueConstraint; } foreach (PathedRole pathedRole in PathedRole.GetLinksToRolePathCollection(role)) { // UNDONE: VALUEROLE This does not correctly report a value constraint from a previous // path node. Note that this, as well as allowing value restrictions on supertype roles // (and possibly other patterns), can result in multiple previous value constraints, so // the callback signature may possibly need to be modified here. As of changeset 1442, // none of the callbacks use the previousValueConstraint information, so we can ignore // this for now. // Note that we visit for the pathed role even if no value constraint is present // to allow processing for this pathed role. if (!visitor(role, pathedRole, null, dataTypeLink, pathedRole.ValueConstraint, previousValueConstraint)) { return false; } } // Walk sequences to find a single-role preferred identifier so // we can get to the next link. LinkedElementCollection<ConstraintRoleSequence> sequences = role.ConstraintRoleSequenceCollection; int sequencesCount = sequences.Count; for (int j = 0; j < sequencesCount; ++j) { UniquenessConstraint constraint = sequences[j] as UniquenessConstraint; ObjectType identifierFor; if (null != (constraint = sequences[j] as UniquenessConstraint) && null != (identifierFor = constraint.PreferredIdentifierFor) && constraint.RoleCollection.Count == 1) { RoleBase nextSkipRole = role.OppositeRoleAlwaysResolveProxy; if (nextSkipRole == null) { return false; } if (!WalkDescendedValueRoles(identifierFor.PlayedRoleCollection, RolePathObjectTypeRoot.GetLinksToRolePathCollection(identifierFor), dataTypeLink, previousValueConstraint, nextSkipRole.Role, true, visitor)) { return false; } } } } } return true; }
public bool IsConstraintEditing(ValueConstraint constraint) { return(valueConstraint == constraint); }
protected override void OnDeactivate() { l0 = null; c0 = null; }
protected override void OnDeactivate() { ClearDrag(); valueConstraint = null; input.gameObject.SetActive(false); }
protected override void OnDeactivate() { p0 = null; constraint = null; }