Exemplo n.º 1
0
        bool Kernel.IGH_ElementIdParam.NeedsToBeExpired
        (
            DB.Document doc,
            ICollection <DB.ElementId> added,
            ICollection <DB.ElementId> deleted,
            ICollection <DB.ElementId> modified
        )
        {
            if (DataType == GH_ParamData.remote)
            {
                return(false);
            }

            foreach (var data in VolatileData.AllData(true).OfType <Types.IGH_ElementId>())
            {
                if (!data.IsElementLoaded)
                {
                    continue;
                }

                if (modified.Contains(data.Id))
                {
                    return(true);
                }

                if (deleted.Contains(data.Id))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        bool IGH_ElementIdParam.NeedsToBeExpired(Document doc, ICollection <ElementId> added, ICollection <ElementId> deleted, ICollection <ElementId> modified)
        {
            // If anything of that type is added we need to update ListItems
            if (added.Where(id => PassesFilter(doc, id)).Any())
            {
                return(true);
            }

            // If selected items are modified we need to expire dependant components
            foreach (var data in VolatileData.AllData(true).OfType <Types.IGH_ElementId>())
            {
                if (!data.IsElementLoaded)
                {
                    continue;
                }

                if (modified.Contains(data.Id))
                {
                    return(true);
                }
            }

            // If an item in ListItems is deleted we need to update ListItems
            foreach (var item in ListItems.Select(x => x.Value).OfType <Grasshopper.Kernel.Types.GH_Integer>())
            {
                var id = new ElementId(item.Value);

                if (deleted.Contains(id))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 3
0
        public override void PostProcessData()
        {
            base.PostProcessData();

            if (SourceCount == 0)
            {
                RefreshList(NickName);
            }
            else
            {
                RefreshList(VolatileData.AllData(true));
            }

            // Show elements sorted
            ListItems.Sort((x, y) => string.CompareOrdinal(x.Name, y.Name));

            //base.CollectVolatileData_Custom();
            m_data.Clear();

            var path = new GH_Path(0);

            if (SelectedItems.Count == 0)
            {
                m_data.AppendRange(new IGH_Goo[0], path);
            }
            else
            {
                foreach (var item in SelectedItems)
                {
                    m_data.Append(item.Value, path);
                }
            }
        }
Exemplo n.º 4
0
 public void BakeGeometry(RhinoDoc doc, ObjectAttributes att, List <Guid> obj_ids)
 {
     foreach (IGH_BakeAwareData data in VolatileData.AllData(true))
     {
         data.BakeGeometry(doc, att, out Guid id);
         obj_ids.Add(id);
     }
 }
Exemplo n.º 5
0
        public override void ClearData()
        {
            Logger.Info("ClearData Called");

            VolatileData.AllData(true).Select(obj => obj as T).Where(obj => obj.IsValid && obj.NXObject.HasUserAttribute("GH_Baked_Object", NXObject.AttributeType.Boolean, -1) && !obj.NXObject.GetBooleanUserAttribute("GH_Baked_Object", -1)).ToList().ForEach(obj => (obj as T).Delete());

            base.ClearData();
        }
Exemplo n.º 6
0
        protected void SelectionPreparation()
        {
            if (VolatileData.DataCount != 0)
            {
                var validDatas = VolatileData.AllData(true).Where(obj => obj.IsValid).ToArray();

                foreach (INXDisplayableObject data in validDatas)
                {
                    if (data.Highlight)
                    {
                        data.Highlight = false;
                    }
                }
            }
        }
Exemplo n.º 7
0
        public override void ProcessData()
        {
            int dataCount          = VolatileDataCount;
            int nonComparableCount = 0;
            var goosSet            = new HashSet <IGH_Goo>(VolatileData.AllData(true).
                                                           Where(x =>
            {
                if (GooComparer.IsComparable(x))
                {
                    return(true);
                }

                nonComparableCount++;
                return(false);
            })
                                                           , new GooComparer());

            if (nonComparableCount > 0)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, $"{nonComparableCount} null or non comparable elements filtered.");
            }

            var duplicatedCount = dataCount - nonComparableCount - goosSet.Count;

            if (duplicatedCount > 0)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, $"{duplicatedCount} duplicated elements filtered.");
            }

            if (DataType == GH_ParamData.local)
            {
                ListItems = goosSet.Select(goo => new ListItem(goo, true)).
                            Where(x => string.IsNullOrEmpty(NickName) || x.Name.IsSymbolNameLike(NickName)).
                            ToList();
            }
            else if (DataType == GH_ParamData.remote)
            {
                var selectSet = new HashSet <IGH_Goo>(PersistentData.Where(x => GooComparer.IsComparable(x)), new GooComparer());
                ListItems = goosSet.Select(goo => new ListItem(goo, selectSet.Contains(goo))).
                            Where(x => string.IsNullOrEmpty(NickName) || x.Name.IsSymbolNameLike(NickName)).
                            ToList();
            }
            else
            {
                ListItems.Clear();
            }
        }
Exemplo n.º 8
0
 public bool NeedsToBeExpired(ICollection <Handle> modified,
                              ICollection <Handle> erased,
                              ICollection <Handle> added,
                              ICollection <string> finishedCmds)
 {
     foreach (var data in VolatileData.AllData(true).OfType <Types.IGH_BcGeometricGoo>())
     {
         if (modified.Contains(data.PersistentRef) || erased.Contains(data.PersistentRef))
         {
             return(true);
         }
     }
     if (added.Count != 0)
     {
         return(PersistentData.AllData(true).OfType <Types.IGH_BcGeometricGoo>().Any(data => added.Contains(data.PersistentRef)));
     }
     return(false);
 }
Exemplo n.º 9
0
        /// <summary>
        /// 连接的 Source 断开
        /// </summary>
        /// <param name="source"></param>
        public override void RemoveSource(IGH_Param source)
        {
            VolatileData.AllData(true).Where(obj => obj.IsValid).ToList().ForEach(obj => (obj as T).Delete());

            base.RemoveSource(source);
        }
Exemplo n.º 10
0
        private void Menu_ForceUpdate(object sender, EventArgs e)
        {
            VolatileData.AllData(true).Select(obj => obj as NX_Body).Where(obj => obj.IsValid).ToList().ForEach(obj => System.IO.File.Delete(obj.InterFile));

            ExpireSolution(true);
        }