コード例 #1
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// An indexer for the overlay collection. NOTE: this will only use the
        /// lower 24 bits when looking for a key.
        /// </summary>
        /// <param name="overlayIDIn">the overlayID to find</param>
        public Overlay this[int overlayIDIn]
        {
            get
            {
                // make sure we are dealing with a clean ID
                int overlayID = OverlayCollection.CleanFlagsFromOverlayID(overlayIDIn);

                Overlay tmpObj = null;
                overlayObjects.TryGetValue(overlayID, out tmpObj);
                return(tmpObj);
            }
        }
コード例 #2
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Accepts a single tag and an overlay ID. Checks to see if we have an overlay
        /// matching the existing overlay without the tag.
        /// If we do, we return it. If not, we create one and return that.
        /// </summary>
        /// <param name="tagIn">the tag to look for</param>
        /// <param name="existingOverlayIDIn">the overlay ID </param>
        /// <returns>the overlay id of the existing or new overlay</returns>
        public int CreateNewOrReturnExistingRemovingSingleTagFromExistingOverlay(int tagIn, int existingOverlayIDIn)
        {
            Overlay outOverlay         = null;
            Overlay existingOverlayObj = null;
            string  identKey           = "";

            // make sure we are dealing with a clean ID
            int existingOverlayID = OverlayCollection.CleanFlagsFromOverlayID(existingOverlayIDIn);

            if (existingOverlayID == Overlay.DEFAULT_OVERLAY_ID)
            {
                throw new Exception("Bad overlay ID presented to collection");
            }
            // get the existing overlay object
            existingOverlayObj = this[existingOverlayID];
            if (existingOverlayObj == null)
            {
                // this should not happen, the caller should always have a valid overlay id
                throw new Exception("Unknown base overlay ID presented to collection");
            }

            // does this overlay already not contain the existing tag. In theory this should
            // never happen. But in reality sometimes the circle and arc algorythms write to the
            // same isopoint twice
            bool retBool = existingOverlayObj.DoesOverlayContainIsoPlotID(tagIn);

            if (retBool == false)
            {
                // no it does not, no need to create another one with a duplicate usage added, just use this one
                return(existingOverlayObj.OverlayID);
            }

            identKey = existingOverlayObj.CalcIndentKeyMinusTag(tagIn);
            // get the overlay
            outOverlay = GetOverlayByIdentKey(identKey);
            // do we have one? if so use that
            if (outOverlay != null)
            {
                return(outOverlay.OverlayID);
            }
            // we do not. We have to create one
            outOverlay = existingOverlayObj.BuildNewOverlayWithMissingTag(NextBuilderOverlayID, tagIn);
            // now add it
            this.Add(outOverlay);
            // return its ID
            return(outOverlay.OverlayID);
        }
コード例 #3
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Accepts a single tag and an overlay ID. Checks to see if we have an
        /// overlay matching that existing one plus the new tag.
        /// If we do, we return it. If not, we create one and return that.
        /// </summary>
        /// <param name="newUsage">the usage to add</param>
        /// <param name="existingOverlayIDIn">the overlay ID </param>
        /// <returns>the overlay id of the existing or new overlay</returns>
        public int CreateNewOrReturnExistingFromSingleUsageAndExistingOverlay(int newTag, int existingOverlayIDIn)
        {
            Overlay outOverlay         = null;
            Overlay existingOverlayObj = null;

            // make sure we are dealing with a clean ID
            int existingOverlayID = OverlayCollection.CleanFlagsFromOverlayID(existingOverlayIDIn);

            if (existingOverlayID == Overlay.DEFAULT_OVERLAY_ID)
            {
                throw new Exception("Bad overlay ID presented to collection");
            }
            // get the existing overlay object
            existingOverlayObj = this[existingOverlayID];
            if (existingOverlayObj == null)
            {
                // this should not happen, the caller should always have a valid overlay id
                throw new Exception("Unknown base overlay ID presented to collection");
            }
            // does this overlay already contain the existing usage. In theory this should
            // never happen. But in reality sometimes the circle and arc algorythms write to the
            // same isopoint twice
            bool retBool = existingOverlayObj.DoesOverlayContainTag(newTag);

            if (retBool == true)
            {
                // yes it does, no need to create another one with a duplicate usage added, just use this one
                return(existingOverlayObj.OverlayID);
            }

            // we need to see if we already have on based on the existing one with the new usage added
            string identKey = existingOverlayObj.CalcIndentKeyPlusUsage(newTag);

            // get the overlay the same as the existing one but with the new usage
            outOverlay = GetOverlayByIdentKey(identKey);
            // do we have one? if so use that
            if (outOverlay != null)
            {
                return(outOverlay.OverlayID);
            }
            // we do not. We have to create one
            outOverlay = existingOverlayObj.BuildNewOverlayWithAddedUsage(NextBuilderOverlayID, newTag);
            // now add it
            this.Add(outOverlay);
            // return its ID
            return(outOverlay.OverlayID);
        }
コード例 #4
0
 /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 /// <summary>
 /// Adds an overlay object to our collection
 /// </summary>
 /// <param name="item">the overlay object to add</param>
 public void Add(Overlay item)
 {
     if (item == null)
     {
         return;
     }
     if (item.OverlayID == Overlay.DEFAULT_OVERLAY_ID)
     {
         throw new Exception("Bad overlay ID presented to collection");
     }
     // does it already exist? - if so leave
     if (overlayObjects.Keys.Contains(item.OverlayID) == true)
     {
         return;
     }
     // add it now
     overlayObjects.Add(item.OverlayID, item);
     // also update this secondary index for speed
     idToIdentKeyMap.Add(item.IdentKey, OverlayCollection.CleanFlagsFromOverlayID(item.OverlayID));
 }
コード例 #5
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Detects if an overlay already contains a tag.
        /// </summary>
        /// <param name="overlayIDIn">the overlay to look for</param>
        /// <param name="tagIn">the tag to check</param>
        /// <returns>
        /// True - the overlay object represented by the id contains the usage, false - it does not
        /// </returns>
        public bool DoesOverlayContainTag(int overlayIDIn, int tagIn)
        {
            Overlay overlayObj = null;

            // make sure we are dealing with a clean ID
            int overlayID = OverlayCollection.CleanFlagsFromOverlayID(overlayIDIn);

            if (overlayID == Overlay.DEFAULT_OVERLAY_ID)
            {
                throw new Exception("Bad overlay ID presented to collection");
            }
            // get the existing overlay object
            overlayObj = this[overlayID];
            // does it even exist?
            if (overlayObj == null)
            {
                return(false);
            }
            // it exists, lets ask the overlay itself
            return(overlayObj.DoesOverlayContainTag(tagIn));
        }