public PivotManip(ShapeCircle circle, ISceneView sceneView) : base(sceneView) { if(circle == null) { throw new NullReferenceException(); } m_ShapeCircle = circle; this.EnableOffset = true; this.EnableRotate = true; }
public CircleTemplate(string name, string propertiesFilepath) : base(name, propertiesFilepath) { m_RootCircle = new ShapeCircle(this, new Transform(), (ISceneView)null); Transform radiusVectorTransform = new Transform(); radiusVectorTransform.Position = new Vector2f(-100.0f, 0.0f); new ShapeCircle(m_RootCircle, radiusVectorTransform); m_ShapeCircleSettingsList = new List<ShapeCircleSettings>(); m_ShapeCircleSettingsList.Resize(m_RootCircle.AllCircles.Count); }
public ShapeCircle(ShapeCircle parent, ITransform transform) { if(parent != null) { m_SceneView = parent.SceneView; parent.AddChild(this); } m_Owner = parent.Owner; m_Parent = parent; m_Transform = new TransformWrapper(transform, this.SceneView); m_Children = new List<ShapeCircle>(); }
public RectTemplate(string name, string propertiesFilepath) : base(name, propertiesFilepath) { m_RootCircle = new ShapeCircle(this, new Transform(), (ISceneView)null); Transform leftBottomTransform = new Transform(); leftBottomTransform.Position = new Vector2f(-100.0f, -100.0f); new ShapeCircle(m_RootCircle, leftBottomTransform); Transform rightTopTransform = new Transform(); rightTopTransform.Position = new Vector2f(100.0f, 100.0f); new ShapeCircle(m_RootCircle, rightTopTransform); m_ShapeCircleSettingsList = new List<ShapeCircleSettings>(); m_ShapeCircleSettingsList.Resize(m_RootCircle.AllCircles.Count); }
private static void SaveShapeCircle(DataElement node, ShapeCircle shapeCircle) { node.CreateAttribute("position", shapeCircle.Position.ToString()); node.CreateAttribute("radius", shapeCircle.Radius.ToString()); node.CreateAttribute("angle", shapeCircle.Angle.ToString()); }
private void HandleRootPositionChanged(ShapeCircle sender) { if(this.PositionChanged != null) { this.PositionChanged(this); } }
private void OnTemplateChanged() { Vector2f position = this.Position; float angle = this.Angle; if(m_RootCircle != null) { m_RootCircle.PositionChanged -= this.HandleRootPositionChanged; m_RootCircle.AngleChanged -= this.HandleRootAngleChanged; } if(this.Template != null) { ShapeCircle templateRootCircle = this.Template.RootCircle; CompositeTransform compositeTransform = new CompositeTransform(); if(this.EditTemplateMode) { compositeTransform.InducedTransforms.Add(templateRootCircle.Transform); } else { compositeTransform.InducedTransforms.Add(templateRootCircle.Transform); compositeTransform.InducedTransforms.Add(new Transform()); } m_RootCircle = new ShapeCircle(this, compositeTransform, this.SceneView); m_Color = this.Template.Color; foreach(ShapeCircle templateChildCircle in templateRootCircle.Children) { CreateCircleFromTemplate(templateChildCircle, m_RootCircle); } m_SelectionManip = this.Template.GetSelectionManip(this); m_Manips = this.Template.GetManips(this); if(m_Manips == null) { m_Manips = new List<SpatialManip>(); } this.UserPropertiesFilepath = this.Template.PropertiesFilepath; } else { m_RootCircle = new ShapeCircle(this, new Transform(), this.SceneView); m_Color = Color.Black; m_Manips = new List<SpatialManip>(); } if(!this.EditTemplateMode) { this.Position = position; this.Angle = angle; } m_RootCircle.PositionChanged += this.HandleRootPositionChanged; m_RootCircle.AngleChanged += this.HandleRootAngleChanged; InvalidateView(); }
public void TryResize(ShapeCircle circle, float radius) { if(this.Template != null) { this.Template.TryResize(circle, radius); } }
public Shape FindShape(ShapeCircle circle) { foreach(Shape shape in m_Shapes) { if(shape.Circles.Contains(circle)) { return shape; } } return null; }
private void EnableFreeform(ShapeCircle rootCircle, bool freeform) { foreach(ShapeCircle circle in rootCircle.AllCircles) { circle.Freeform = freeform; } }
public ShapeCircleSettings GetCircleSettings(ShapeCircle shapeCircle) { Dictionary<ShapeCircle, ShapeCircleSettings> settings = GetCirclesSettingsMap(shapeCircle); return settings[shapeCircle]; }
protected Circle GetAngleManipCircle(ShapeCircle shapeCircle) { return GetAngleManipCircle(shapeCircle.Position, shapeCircle.Angle); }
protected Circle GetPositionManipCircle(ShapeCircle shapeCircle) { return GetPositionManipCircle(shapeCircle.Position); }
private void AccumChildCircles(List<ShapeCircle> accum, ShapeCircle circle) { foreach(ShapeCircle childCircle in circle.Children) { accum.Add(childCircle); } foreach(ShapeCircle childCircle in circle.Children) { AccumChildCircles(accum, childCircle); } }
private void AddChild(ShapeCircle child) { m_Children.Add(child); }
protected virtual void ApplyRotation(ShapeCircle shapeCircle, float angle) { shapeCircle.Angle = angle; }
protected void RequestAddManip(List<SpatialManip> manips, Dictionary<ShapeCircle, ShapeCircleSettings> shapeSettings, Shape shape, ShapeCircle circle) { ShapeCircleSettings circleSettings = shapeSettings[circle]; if(shape.EditTemplateMode || circleSettings.EnableOffset || circleSettings.EnableRotate) { PivotManip manip = new PivotManip(circle, shape.SceneView); manips.Add(manip); if(!shape.EditTemplateMode) { manip.EnableOffset = circleSettings.EnableOffset; manip.EnableRotate = circleSettings.EnableRotate; } } }
public void TryTranslate(ShapeCircle shapeCircle, Vector2f position) { EnableFreeform(shapeCircle.Owner.RootCircle, true); ApplyPosition(shapeCircle, position); EnableFreeform(shapeCircle.Owner.RootCircle, false); History.Change(); }
public Dictionary<ShapeCircle, ShapeCircleSettings> GetCirclesSettingsMap(ShapeCircle circle) { Dictionary<ShapeCircle, ShapeCircleSettings> result = new Dictionary<ShapeCircle, ShapeCircleSettings>(); List<ShapeCircle> allCircles = circle.AllCircles; IList<ShapeCircleSettings> perCircleSettings = this.PerCircleSettings; for(int index = 0; index < perCircleSettings.Count; ++index) { result.Add(allCircles[index], perCircleSettings[index]); } return result; }
public void TryResize(ShapeCircle shapeCircle, float radius) { EnableFreeform(shapeCircle.Owner.RootCircle, true); ApplySize(shapeCircle, radius); EnableFreeform(shapeCircle.Owner.RootCircle, false); History.Change(); }
public void TryTranslate(ShapeCircle circle, Vector2f position) { if(this.Template != null) { this.Template.TryTranslate(circle, position); } }
public void TryRotate(ShapeCircle shapeCircle, float angle) { EnableFreeform(shapeCircle.Owner.RootCircle, true); ApplyRotation(shapeCircle, angle); EnableFreeform(shapeCircle.Owner.RootCircle, false); History.Change(); }
public void TryRotate(ShapeCircle circle, float angle) { if(this.Template != null) { this.Template.TryRotate(circle, angle); } }
protected ShapeCircle CloneRootCircle(ShapeTemplate owner, ISceneView sceneView) { ShapeCircle clone = new ShapeCircle(owner, this.RootCircle.Transform.Clone(), sceneView); foreach(ShapeCircle circle in this.RootCircle.Children) { CloneCircle(circle, clone); } return clone; }
private void CreateCircleFromTemplate(ShapeCircle templateCircle, ShapeCircle parent) { ITransform transform = templateCircle.Transform; if(!this.EditTemplateMode) { CompositeTransform compositeTransform = new CompositeTransform(); compositeTransform.InducedTransforms.Add(templateCircle.Transform); compositeTransform.InducedTransforms.Add(new Transform()); transform = compositeTransform; } ShapeCircle circle = null; if(parent != null) { circle = new ShapeCircle(parent, transform); } else { circle = new ShapeCircle(this, transform, this.SceneView); } foreach(ShapeCircle templateChildCircle in templateCircle.Children) { CreateCircleFromTemplate(templateChildCircle, circle); } }
private void CloneCircle(ShapeCircle circle, ShapeCircle parent) { new ShapeCircle(parent, circle.Transform.Clone()); }
private void HandleRootAngleChanged(ShapeCircle sender) { if(this.AngleChanged != null) { this.AngleChanged(this); } }
protected virtual void ApplyPosition(ShapeCircle shapeCircle, Vector2f position) { shapeCircle.Position = position; }
private static void LoadShapeCircle(DataElement node, ShapeCircle shapeCircle) { shapeCircle.Position = Vector2f.Parse(node.GetAttribValue("position")); shapeCircle.Radius = float.Parse(node.GetAttribValue("radius")); shapeCircle.Angle = float.Parse(node.GetAttribValue("angle")); }
protected virtual void ApplySize(ShapeCircle shapeCircle, float radius) { shapeCircle.Radius = radius; }