/// <summary> /// After the <see cref="HatchStyle"/>, the <see cref="CompoundShape"/> or the <see cref="HatchStyle"/> has been modified /// this method must be called to calculate the new contents. /// </summary> public void Recalc() { needsRecalc = false; GeoObjectList l = null; if (OnRecalc != null) { l = OnRecalc(this); } if (compoundShape == null) { return; } if (l == null) { l = hatchStyle.GenerateContent(compoundShape, plane); } for (int i = 0; i < l.Count; ++i) { if (l[i].Layer == null) { l[i].Layer = this.Layer; } if (l[i] is IColorDef && (l[i] as IColorDef).ColorDef == null) { (l[i] as IColorDef).ColorDef = this.ColorDef; } } base.ReplaceContent(l); // es werden keine change-events gefeuert! }
/// <summary> /// Removes all objects from that block and returns those objects in a new list. The returned objects /// have no <see cref="IGeoObject.Owner"/>. /// </summary> /// <returns>a list with all the objects of this block</returns> public GeoObjectList Clear() { GeoObjectList res = new GeoObjectList(containedObjects); using (new Changing(this, "Add", containedObjects.Clone())) { lock (this) { foreach (IGeoObject go in containedObjects) { go.WillChangeEvent -= new ChangeDelegate(OnWillChange); go.DidChangeEvent -= new ChangeDelegate(OnDidChange); go.Owner = null; IColorDef cd = go as IColorDef; if ((cd != null) && (cd.ColorDef != null)) { if (cd.ColorDef.Source == ColorDef.ColorSource.fromParent) { cd.ColorDef = ColorDef.CDfromParent; } } } containedObjects.Clear(); } } return(res); }
public virtual void Set(GeoObjectList toSet) { using (new Changing(this, "Set", new object[] { containedObjects.Clone() })) { ReplaceContent(toSet); } }
/// <summary> /// Implements <see cref="CADability.UserInterface.ICommandHandler.OnCommand (string)"/> /// </summary> /// <param name="MenuId"></param> /// <returns></returns> virtual public bool OnCommand(string MenuId) { switch (MenuId) { case "MenuId.Explode": if (frame.ActiveAction is SelectObjectsAction) { using (frame.Project.Undo.UndoFrame) { IGeoObjectOwner addTo = blockRef.Owner; if (addTo == null) { addTo = frame.ActiveView.Model; } addTo.Remove(blockRef); //IGeoObject go = blockRef.ReferencedBlock.Clone(); //go.PropagateAttributes(blockRef.Layer, blockRef.ColorDef); GeoObjectList l = blockRef.Decompose(); addTo.Add(l[0]); SelectObjectsAction soa = frame.ActiveAction as SelectObjectsAction; soa.SetSelectedObjects(l); // alle Teilobjekte markieren } } return(true); } return(false); }
public override void SetObjectData(IJsonReadData data) { base.SetObjectData(data); refPoint = data.GetProperty <GeoPoint>("RefPoint"); containedObjects = data.GetProperty <GeoObjectList>("ContainedObjects"); colorDef = data.GetPropertyOrDefault <ColorDef>("ColorDef"); name = data.GetPropertyOrDefault <string>("Name"); data.RegisterForSerializationDoneCallback(this); }
/// <summary> /// Overrides <see cref="CADability.GeoObject.IGeoObjectImpl.Decompose ()"/> /// </summary> /// <returns></returns> public override GeoObjectList Decompose() { GeoObjectList res = this.Children.CloneObjects(); for (int i = 0; i < res.Count; i++) { res[i].PropagateAttributes(this.Layer, this.colorDef); } return(res); }
/// <summary> /// Overrides <see cref="CADability.GeoObject.IGeoObjectImpl.Decompose ()"/> /// </summary> /// <returns></returns> public override GeoObjectList Decompose() { if (needsRecalc) { Recalc(); } GeoObjectList tmp = new GeoObjectList(OwnedItems); return(tmp.CloneObjects()); }
public virtual void Remove(GeoObjectList ToRemove) { using (new Changing(this, "Add", new object[] { ToRemove })) { foreach (IGeoObject go in ToRemove) { (this as IGeoObjectOwner).Remove(go); } } }
/// <summary> /// Returns a deep clone of the list. /// </summary> /// <returns></returns> public GeoObjectList CloneObjects() { GeoObjectList res = new GeoObjectList(this); for (int i = 0; i < res.Count; ++i) { IGeoObject go = res[i]; res[i] = go.Clone(); res[i].CopyAttributes(go); } return(res); }
public void AddRangeUnique(GeoObjectList ObjectsToAdd) { // erst die überflüssigen entfernen, dann alle verbleibenden zufügen wg. ObjectAddedEvent for (int i = ObjectsToAdd.Count - 1; i >= 0; --i) { int index = list.IndexOf(ObjectsToAdd[i]); if (index >= 0) { ObjectsToAdd.Remove(i); } } AddRange(ObjectsToAdd); }
IPropertyEntry INamedAttribute.GetSelectionProperty(string key, Project project, GeoObjectList geoObjectList) { GeoObjectList pointList = new GeoObjectList(); foreach (IGeoObject go in geoObjectList) { if (go is Point) { pointList.Add(go); } } return(new PointSymbolSelectionProperty(pointList, "Point.PointSymbol")); }
/// <summary> /// Tests, weather this list and the list l have the same content /// (maybe in a different order) /// </summary> /// <param name="l">The GeoObjectList to compare with this list</param> /// <returns>true if the lists have the same content</returns> public bool HasSameContent(GeoObjectList l) { if (l.Count != list.Count) { return(false); } for (int i = 0; i < l.Count; ++i) { int index = list.IndexOf(l[i]); if (index < 0) { return(false); } } return(true); }
public void DecomposeBlockRefs() { bool decomposed; do { decomposed = false; for (int i = list.Count - 1; i >= 0; --i) { if (this[i] is BlockRef) { GeoObjectList l = (this[i] as BlockRef).Decompose(); Remove(i); AddRange(l); decomposed = true; } } } while (decomposed); }
/// <summary> /// Constructor required by deserialization /// </summary> /// <param name="info">SerializationInfo</param> /// <param name="context">StreamingContext</param> protected Block(SerializationInfo info, StreamingContext context) : base(info, context) { try { colorDef = (ColorDef)info.GetValue("ColorDef", typeof(ColorDef)); refPoint = (GeoPoint)info.GetValue("RefPoint", typeof(GeoPoint)); containedObjects = (GeoObjectList)info.GetValue("ContainedObjects", typeof(GeoObjectList)); name = (string)info.GetValue("Name", typeof(string)); // FinishDeserialization.AddToContext(context,this); } catch (SerializationException ex) { SerializationInfoEnumerator e = info.GetEnumerator(); while (e.MoveNext()) { System.Diagnostics.Trace.WriteLine("im Block fehlt: " + e.Name); } } }
/// <summary> /// Replace the list of child objects without fireing a chang event. This is used /// by derived classes (e.g. <see cref="Hatch"/> or <see cref="Dimension"/> or user derived classes /// to recalculate their contents. The derived classes already have fired the change /// event. /// </summary> /// <param name="NewContent">List of child objects to replace the existing list</param> protected void ReplaceContent(GeoObjectList NewContent) { foreach (IGeoObject go in containedObjects) { //go.WillChangeEvent -= new ChangeDelegate(OnWillChange); wg. Trumpf die Events entfernt, werden die bei Schraffur und Bemaßung gebraucht? //go.DidChangeEvent -= new ChangeDelegate(OnDidChange); go.Owner = null; IColorDef cd = go as IColorDef; if (cd != null && cd.ColorDef != null) { if (cd.ColorDef.Source == ColorDef.ColorSource.fromParent) { cd.ColorDef = ColorDef.CDfromParent; } } } lock (this) { containedObjects.Clear(); } foreach (IGeoObject go in NewContent) { lock (this) { containedObjects.Add(go); } //go.WillChangeEvent += new ChangeDelegate(OnWillChange); //go.DidChangeEvent += new ChangeDelegate(OnDidChange); go.Owner = this; IColorDef cd = go as IColorDef; if (cd != null && cd.ColorDef != null) { if (cd.ColorDef.Source == ColorDef.ColorSource.fromParent) { cd.ColorDef = CDfromParent; } } } }
public virtual void Add(GeoObjectList ToAdd) { using (new Changing(this, "Remove", ToAdd)) { foreach (IGeoObject go in ToAdd) { lock (this) { containedObjects.Add(go); } go.WillChangeEvent += new ChangeDelegate(OnWillChange); go.DidChangeEvent += new ChangeDelegate(OnDidChange); go.Owner = this; IColorDef cd = go as IColorDef; if (cd != null && cd.ColorDef != null) { if (cd.ColorDef.Source == ColorDef.ColorSource.fromParent) { cd.ColorDef = CDfromParent; } } } } }
public Shell GetInsidePart() { closedBorder.Flatten(); if (!closedBorder.IsClosed) { Line l = Line.Construct(); l.SetTwoPoints(closedBorder.EndPoint, closedBorder.StartPoint); closedBorder.Add(l); } vertexToFace = new Face[closedBorder.CurveCount]; for (int i = 0; i < closedBorder.CurveCount; i++) { Face fc = FindClosestFace(closedBorder.Curve(i).StartPoint); if (fc == null) { throw new SplitShellWithCurvesException(); } vertexToFace[i] = fc; } all2DCurves = new Dictionary <Face, List <ICurve2D> >(); splitedEdges = new Dictionary <Edge, List <double> >(); for (int i = 0; i < vertexToFace.Length; i++) { InsertCurve(i); } // jetzt die Faces beschneiden und eine neue Shell bauen Vertex[] vertices = shell.Vertices; outsideVertices = new Set <Vertex>(); for (int i = 0; i < vertices.Length; i++) { // wenn der Vertex eine Außenkante hat, dann gilt er als außenliegend Edge[] vedges = vertices[i].Edges; for (int j = 0; j < vedges.Length; j++) { if (vedges[j].SecondaryFace == null) { FollowVertex(vertices[j]); } } } #if DEBUG DebuggerContainer dc = new DebuggerContainer(); foreach (Vertex vtx in outsideVertices) { Point pnt = Point.Construct(); pnt.Location = vtx.Position; pnt.Symbol = PointSymbol.Circle; dc.Add(pnt, vtx.GetHashCode()); } #endif // alle Faces, die aufgesplitted werden müssen: Set <Face> splittedFaces = new Set <Face>(); foreach (Edge edge in splitedEdges.Keys) { splittedFaces.Add(edge.PrimaryFace); if (edge.SecondaryFace != null) { splittedFaces.Add(edge.SecondaryFace); } } resultingFaces = new List <Face>(); for (int i = 0; i < shell.Faces.Length; i++) { Face face = shell.Faces[i]; if (splittedFaces.Contains(face)) { AddSplittedFace(face); } else { if (!outsideVertices.Contains(face.Vertices[0])) { resultingFaces.Add(face.Clone() as Face); } } } GeoObjectList res = Make3D.SewFacesAndShells(new GeoObjectList(resultingFaces.ToArray())); if (res.Count == 1) { return(res[0] as Shell); } return(null); }
protected Block() // wird gebraucht wg. BlockRef Paint { containedObjects = new GeoObjectList(); CDfromParent = ColorDef.CDfromParent.Clone(); }