protected override void OnMouseDown(Vector3 pos, ICADObject sko) { if (sko == null) { return; } var entity = sko as IEntity; if (entity == null) { return; } if (p == null) { if (entity.type == IEntityType.Point) { p = entity; } } else if (axis == null) { if (entity.type == IEntityType.Line) { axis = entity; StopTool(); editor.PushUndo(); var feature = new RevolveFeature(); DetailEditor.instance.AddFeature(feature); feature.axis = axis; feature.origin = p; feature.source = DetailEditor.instance.activeFeature; DetailEditor.instance.ActivateFeature(feature); } } }
public override void Read(XmlNode xml) { ids.Clear(); if (Enum.GetNames(optionInternal.GetType()).Length >= 2) { Enum output = optionInternal; xml.Attributes["chirality"].Value.ToEnum(ref output); optionInternal = output; } foreach (XmlNode node in xml.ChildNodes) { if (node.Name != "entity" && node.Name != "link") { continue; } var path = IdPath.From(node.Attributes["path"].Value); ICADObject o = null; if (sketch.idMapping != null) { o = sketch.GetChild(sketch.idMapping[path.path.Last()]); } else { o = sketch.feature.detail.GetObjectById(path); } AddObject(o); } base.Read(xml); }
protected override void OnMouseDown(Vector3 pos, ICADObject ico) { IEntity entity = ico as IEntity; if (entity == null) { return; } if (p0 != null) { if (entity.type == IEntityType.Point) { new PointsCoincident(DetailEditor.instance.currentSketch.GetSketch(), p0, entity); } else if (entity.type == IEntityType.Line) { new PointOnLine(DetailEditor.instance.currentSketch.GetSketch(), p0, entity); } p0 = null; } else if (entity.type == IEntityType.Point) { p0 = entity; } }
//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; } }
protected override void OnMouseMove(Vector3 pos, ICADObject entity) { if (current != null) { current.p[3].pos = pos; if (prev == null) { current.p[1].pos = (current.p[0].pos + current.p[3].pos) * 0.5f; current.p[2].pos = (current.p[0].pos + current.p[3].pos) * 0.5f; } else { var dir0 = current.p[3].pos - current.p[0].pos; var dir1 = prev.p[3].pos - prev.p[0].pos; var dir = (dir0.normalized + dir1.normalized).normalized; current.p[1].pos = current.p[0].pos + dir * dir0.magnitude / 3f; current.p[2].pos = current.p[3].pos - Vector3.Reflect(dir * dir0.magnitude / 3f, new Vector3(dir0.y, -dir0.x, 0f).normalized); prev.p[2].pos = prev.p[3].pos - dir * dir1.magnitude / 3f; } //var itr = new Vector3(); canCreate = true; //!current.sketch.IsCrossed(current, ref itr); current.isError = !canCreate; } else { canCreate = true; } }
protected override void OnMouseDown(Vector3 pos, ICADObject sko) { if (sko == null) { return; } if (!(sko is Entity)) { return; } if (!(sko is ISegmentaryEntity || sko is ILoopEntity)) { return; } editor.PushUndo(); var e = sko as Entity; var part = e.Split(pos); if (e is ISegmentaryEntity) { var s0 = e as ISegmentaryEntity; var s1 = part as ISegmentaryEntity; e.sketch.ReplaceEntityInConstraints(s0.end, s1.end); new PointsCoincident(e.sketch, s0.end, s1.begin); } }
protected override void OnMouseDown(Vector3 pos, ICADObject ico) { IEntity entity = ico as IEntity; if (entity == null) { return; } if (p0 != null) { if (entity.type == IEntityType.Point) { PointEntity pt0 = p0 as PointEntity; PointEntity pt1 = entity as PointEntity; if (!p0.IsSameAs(entity) && (pt0 == null || pt1 == null || !pt0.IsCoincidentWith(pt1))) { editor.PushUndo(); new PointsCoincident(DetailEditor.instance.currentSketch.GetSketch(), p0, entity); } } else { editor.PushUndo(); new PointOn(DetailEditor.instance.currentSketch.GetSketch(), p0, entity); } p0 = null; } else if (entity.type == IEntityType.Point) { p0 = entity; } }
protected override void OnMouseMove(Vector3 pos, ICADObject sko) { if (current == null) { return; } var delta = pos - click; var worldDelta = WorldPlanePos - worldClick; if (drag.Count > 0) { if (current is IEntity && (current as IEntity).IsCircular()) { var circle = current as IEntity; dragXP.value = (firstClickCenter - WorldPlanePos).magnitude + deltaR; } else { dragXP.value += delta.x; dragYP.value += delta.y; dragZP.value += delta.z; } } else if (current is Constraint) { (current as Constraint).Drag(worldDelta); } click = pos; worldClick = WorldPlanePos; }
protected override void OnMouseDown(Vector3 pos, ICADObject sko) { if (current != null) { if (!canCreate) { return; } current.c.isSelectable = true; current.isSelectable = true; current = null; return; } if (DetailEditor.instance.currentSketch == null) { return; } current = new CircleEntity(DetailEditor.instance.currentSketch.GetSketch()); current.center.pos = pos; AutoConstrainCoincident(current.center, sko as IEntity); current.isSelectable = false; current.c.isSelectable = false; }
protected override void OnMouseDoubleClick(Vector3 pos, ICADObject sko) { if (sko is ValueConstraint) { EditConstraintValue(sko as ValueConstraint); } }
public ICADObject HoverUntil(Vector3 mouse, Camera camera, Matrix4x4 tf, ref double objDist, Feature feature) { double min = -1.0; ICADObject result = null; foreach (var f in features) { if (!f.ShouldHoverWhenInactive() && !f.active) { continue; } double dist = -1.0; var hovered = f.Hover(mouse, camera, tf, ref dist); if (dist >= 0.0 && dist < Sketch.hoverRadius && (min < 0.0 || dist < min)) { result = hovered; min = dist; } if (f == feature) { break; } } objDist = min; return(result); }
protected override void OnMouseDown(Vector3 pos, ICADObject sko) { //click = pos; var entity = sko as IEntity; if (entity == null) { return; } if (p0 == null && entity.type == IEntityType.Line) { editor.PushUndo(); constraint = new HVConstraint(DetailEditor.instance.currentSketch.GetSketch(), entity); constraint.orientation = vertical ? HVOrientation.OX : HVOrientation.OY; return; } if (entity.type != IEntityType.Point) { return; } if (p0 != null) { editor.PushUndo(); constraint = new HVConstraint(DetailEditor.instance.currentSketch.GetSketch(), p0, entity); constraint.orientation = vertical ? HVOrientation.OX : HVOrientation.OY; p0 = null; constraint = null; } else { p0 = entity; } }
public bool IsSelected(ICADObject obj) { if (obj == null) { return(false); } return(selection.Contains(obj.id)); }
protected override void OnMouseMove(Vector3 pos, ICADObject entity) { if (constraint != null) { constraint.Drag(WorldPlanePos - click); } click = WorldPlanePos; }
protected override void OnMouseUp(Vector3 pos, ICADObject sko) { if (rectSelection) { rectSelection = false; editor.MarqueeSelect(marqueeRect, rectInvertedX); } ClearDrag(); }
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; } }
protected void AddObject(ICADObject o) { if (o is IEntity) { AddEntity(o as IEntity); } if (o is Constraint) { AddConstraint(o as Constraint); } }
void ClearDrag() { current = null; foreach (var d in drag) { DetailEditor.instance.RemoveDrag(d); DetailEditor.instance.suppressCombine = false; } drag.Clear(); //canMove = true; }
protected override void OnMouseDown(Vector3 pos, ICADObject entity) { editor.PushUndo(); var p = new PointEntity(DetailEditor.instance.currentSketch.GetSketch()); p.SetPosition(pos); if (entity is IEntity) { AutoConstrainCoincident(p, entity as IEntity); } }
void ClearDrag() { current = null; foreach (var d in drag) { editor.RemoveDrag(d); } editor.suppressCombine = false; editor.suppressHovering = false; drag.Clear(); //canMove = true; }
protected override void OnMouseDown(Vector3 pos, ICADObject sko) { if (sko == null) { return; } if (!(sko is SketchObject)) { return; } (sko as SketchObject).Destroy(); }
protected override void OnMouseDown(Vector3 pos, ICADObject sko) { if (current != null) { if (!canCreate) { return; } current.p[2].pos = pos; foreach (var p in current.p) { p.isSelectable = true; } current.isSelectable = true; if (prev != null) { new Tangent(current.sketch, current, prev); } if (AutoConstrainCoincident(current.p[3], sko as IEntity)) { current = null; StopTool(); return; } } if (DetailEditor.instance.currentSketch == null) { return; } editor.PushUndo(); var newEntity = new SplineEntity(DetailEditor.instance.currentSketch.GetSketch()); foreach (var p in newEntity.p) { p.pos = pos; } if (current == null) { AutoConstrainCoincident(newEntity.p[0], sko as IEntity); } else { new PointsCoincident(current.sketch, current.p[3], newEntity.p[0]); } prev = current; current = newEntity; foreach (var p in current.p) { p.isSelectable = false; } current.isSelectable = false; }
protected override void OnMouseMove(Vector3 pos, ICADObject entity) { if (current != null) { current.radius.value = (current.center.pos - pos).magnitude; //var itr = new Vector3(); canCreate = true; //!current.sketch.IsCrossed(current, ref itr); current.isError = !canCreate; } else { canCreate = true; } }
protected override void OnMouseMove(Vector3 pos, ICADObject entity) { if (current != null) { current.p1.pos = pos; //var itr = new Vector3(); canCreate = true; //!current.sketch.IsCrossed(current, ref itr); current.isError = !canCreate; } else { canCreate = true; } }
protected override void OnMouseDown(Vector3 pos, ICADObject sko) { if (sko == null) { return; } var entity = sko as IEntity; if (p == null) { if (entity.type == IEntityType.Point) { p = entity; } } else if (u == null) { if (entity.type == IEntityType.Line) { u = entity; } } else if (v == null) { if (entity.type == IEntityType.Line && entity != u) { v = entity; StopTool(); editor.PushUndo(); var feature = new SketchFeature(); DetailEditor.instance.AddFeature(feature); feature.u = u; feature.v = v; feature.p = p; feature.source = DetailEditor.instance.activeFeature; IPlane plane = feature as IPlane; if (Vector3.Dot(plane.n, Camera.main.transform.forward) < 0f) { feature.u = v; feature.v = u; } DetailEditor.instance.ActivateFeature(feature); CameraController.instance.AnimateToPlane(feature); } } }
void DrawCadObject(ICADObject obj, string style) { var he = obj as IEntity; canvas.SetStyle((he != null && he.type == IEntityType.Point) ? style + "Points" : style); if (he != null) { canvas.DrawSegments((obj as IEntity).SegmentsInPlane(null)); } else if (obj is SketchObject) { (obj as SketchObject).Draw(canvas); } }
protected override void OnMouseMove(Vector3 pos, ICADObject entity) { if (current != null) { var delta = current.center.pos - pos; current.r0.value = Mathf.Abs(delta.x); current.r1.value = Mathf.Abs(delta.y); canCreate = true; current.isError = !canCreate; } else { canCreate = true; } }
protected override void OnMouseDown(Vector3 pos, ICADObject sko) { ClearDrag(); if (valueConstraint != null) { return; } if (sko == null) { return; } var entity = sko as IEntity; current = sko; click = pos; worldClick = WorldPlanePos; int count = 0; if (entity != null) { count = entity.points.Count(); } if (count == 0) { return; } dragXP.value = 0; dragYP.value = 0; dragZP.value = 0; foreach (var ptExp in entity.points) { var dragX = ptExp.x.Drag(dragXP.exp + ptExp.x.Eval()); var dragY = ptExp.y.Drag(dragYP.exp + ptExp.y.Eval()); var dragZ = ptExp.z.Drag(dragZP.exp + ptExp.z.Eval()); drag.Add(dragX); drag.Add(dragY); drag.Add(dragZ); //Debug.Log("x: " + dragX); //Debug.Log("y: " + dragY); //Debug.Log("z: " + dragZ); DetailEditor.instance.AddDrag(dragX); DetailEditor.instance.AddDrag(dragY); DetailEditor.instance.AddDrag(dragZ); DetailEditor.instance.suppressCombine = true; } }
protected override void OnMouseDown(Vector3 pos, ICADObject sko) { click = WorldPlanePos; if (constraint != null) { MoveTool.instance.EditConstraintValue(constraint); constraint = null; return; } var entity = sko as IEntity; if (entity == null) { return; } if (l0 == null && entity.type == IEntityType.Arc) { constraint = new AngleConstraint(DetailEditor.instance.currentSketch.GetSketch(), entity); constraint.pos = WorldPlanePos; } if (entity.type != IEntityType.Line) { return; } if (l0 != null) { if (l0 is LineEntity && entity is LineEntity) { var pts = GetPoints(l0 as LineEntity, entity as LineEntity); constraint = new AngleConstraint(DetailEditor.instance.currentSketch.GetSketch(), pts); } else { constraint = new AngleConstraint(DetailEditor.instance.currentSketch.GetSketch(), l0, entity); } constraint.pos = WorldPlanePos; l0 = null; } else { l0 = entity; } }
protected override void OnMouseDown(Vector3 pos, ICADObject sko) { if (current != null) { if (!canCreate) { return; } current.p1.pos = pos; current.p1.isSelectable = true; current.p0.isSelectable = true; current.c.isSelectable = true; current.isSelectable = true; if (AutoConstrainCoincident(current.p1, sko as IEntity)) { current = null; StopTool(); return; } } if (DetailEditor.instance.currentSketch == null) { return; } editor.PushUndo(); var newEntity = new ArcEntity(DetailEditor.instance.currentSketch.GetSketch()); newEntity.p0.pos = pos; newEntity.p1.pos = pos; newEntity.c.pos = pos; if (current == null) { AutoConstrainCoincident(newEntity.p0, sko as IEntity); } else { new PointsCoincident(current.sketch, current.p1, newEntity.p0); } current = newEntity; current.isSelectable = false; current.p0.isSelectable = false; current.p1.isSelectable = false; current.c.isSelectable = false; }