public XbimModelViewModel(IfcProject project, IXbimViewModel parent)
 {
     xbimModel = project.ModelOf as XbimModel;
     _project = project;
     this.CreatingParent = parent;
     IEnumerable subs = this.Children; //call this once to preload first level of hierarchy   
 }
Example #2
0
 public SpatialViewModel(IfcSpatialStructureElement spatialStructure, IXbimViewModel parent)
 {
     xbimModel = spatialStructure.ModelOf as XbimModel;
     this.spatialStructureLabel = Math.Abs(spatialStructure.EntityLabel);
     CreatingParent = parent;
     IEnumerable subs = this.Children; //call this once to preload first level of hierarchy   
 }
 private void LazyLoadAll(IXbimViewModel parent)
 {
     foreach (var child in parent.Children)
     {
         LazyLoadAll(child);
     }
 }
 public SpatialViewModel(IfcSpatialStructureElement spatialStructure, IXbimViewModel parent)
 {
     xbimModel = spatialStructure.ModelOf as XbimModel;
     this.spatialStructureLabel = spatialStructure.EntityLabel;
     CreatingParent             = parent;
     // IEnumerable subs = this.Children; //call this once to preload first level of hierarchy
 }
 public XbimModelViewModel(IfcProject project, IXbimViewModel parent)
 {
     xbimModel           = project.ModelOf as XbimModel;
     _project            = project;
     this.CreatingParent = parent;
     IEnumerable subs = this.Children; //call this once to preload first level of hierarchy
 }
        public IXbimViewModel FindItemBreadthFirst(IPersistEntity entity)
        {
            Queue <IXbimViewModel> queue = new Queue <IXbimViewModel>();

            foreach (var item in HierarchySource.OfType <IXbimViewModel>())
            {
                queue.Enqueue(item);
            }
            IXbimViewModel current = queue.Dequeue();

            while (current != null)
            {
                if (IsMatch(current, entity))
                {
                    return(current);
                }
                foreach (var item in current.Children)
                {
                    queue.Enqueue(item);
                }
                if (!queue.Any())
                {
                    return(null);
                }
                current = queue.Dequeue();
            }
            return(null);
        }
        //public ContainedElementsViewModel(IfcSpatialStructureElement container)
        //{
        //    xbimModel = container.ModelOf as XbimModel;
        //    IEnumerable subs = this.Children; //call this once to preload first level of hierarchy          
        //}

        public ContainedElementsViewModel(IfcSpatialStructureElement spatialElem, Type type, IXbimViewModel parent)
        {
            this.spatialContainerLabel = spatialElem.EntityLabel;
            this.type = type;
            this.xbimModel = (XbimModel) spatialElem.ModelOf;
            this.CreatingParent = parent;
        }
Example #8
0
 public ContainedElementsViewModel(IIfcSpatialStructureElement spatialElem, Type type, IXbimViewModel parent)
 {
     _spatialContainer = spatialElem;
     _type             = type;
     Model             = spatialElem.Model;
     CreatingParent    = parent;
 }
 protected void Expand(IXbimViewModel treeitem)
 {
     treeitem.IsExpanded = true;
     foreach (var child in treeitem.Children)
     {
         Expand(child);
     }
 }
        private static void LazyLoadAll(IXbimViewModel parent)
        {

            foreach (var child in parent.Children)
            {
                LazyLoadAll(child);
            }

        }
Example #11
0
 public SpatialViewModel(IIfcSpatialStructureElement spatialStructure, IXbimViewModel parent)
 {
     if (spatialStructure == null)
     {
         throw new ArgumentNullException("spatialStructure");
     }
     _model            = spatialStructure.Model;
     _spatialStructure = spatialStructure;
     CreatingParent    = parent;
 }
Example #12
0
 private void Highlight(IXbimViewModel toSelect)
 {
     UpdateLayout();
     ScrollIntoView(toSelect);
     toSelect.IsSelected = true;
     while (toSelect != null)
     {
         toSelect.IsExpanded = true;
         toSelect            = toSelect.CreatingParent;
     }
 }
Example #13
0
        public IXbimViewModel FindItemDepthFirst(IXbimViewModel node, IPersistEntity entity)
        {
            if (IsMatch(node, entity))
            {
                // node.IsExpanded = true; // commented because of new Highlighting mechanisms
                return(node);
            }

            foreach (var child in node.Children)
            {
                IXbimViewModel res = FindItemDepthFirst(child, entity);
                if (res != null)
                {
                    // node.IsExpanded = true; //commented because of new Highlighting mechanisms
                    return(res);
                }
            }
            return(null);
        }
Example #14
0
 // todo: bonghi: this function should be changed to match IXbimViewModel directly.
 // it should be possible in the redesign to build an IXbimViewModel from an IPersistIfcEntity.
 private static bool IsMatch(IXbimViewModel node, IPersistIfcEntity entity)
 {
     return(node.Model == entity.ModelOf && node.EntityLabel == entity.EntityLabel);
 }
Example #15
0
 private void Highlight(IXbimViewModel toSelect)
 {
     UpdateLayout();
     ScrollIntoView(toSelect);
     toSelect.IsSelected = true;
     while (toSelect != null)
     {
         toSelect.IsExpanded = true;
         toSelect = toSelect.CreatingParent;
     }
 }
Example #16
0
 public GroupViewModel(IfcGroup gr, IXbimViewModel parent)
 {
     this.group = gr;
     CreatingParent = parent;
 }
 public XbimModelViewModel(IIfcProject project, IXbimViewModel parent)
 {
     Model          = project.Model;
     _project       = project;
     CreatingParent = parent;
 }
 public IfcProductModelView(IfcProduct prod, IXbimViewModel parent)
 {
     CreatingParent = parent;
     this.product = prod;
 }
Example #19
0
 // todo: bonghi: this function should be changed to match IXbimViewModel directly.
 // it should be possible in the redesign to build an IXbimViewModel from an IPersistIfcEntity.
 private static bool IsMatch(IXbimViewModel node, IPersistIfcEntity entity)
 {
     return node.Model == entity.ModelOf && node.EntityLabel == entity.EntityLabel;
 }
Example #20
0
        public IXbimViewModel FindItemDepthFirst(IXbimViewModel node, IPersistIfcEntity entity)
        {
            if (IsMatch(node, entity))
            {
                // node.IsExpanded = true; // commented because of new Highlighting mechanisms
                return node;
            }

            foreach (var child in node.Children)
            {
                IXbimViewModel res = FindItemDepthFirst(child, entity);
                if (res != null)
                {
                    // node.IsExpanded = true; //commented because of new Highlighting mechanisms
                    return res;
                }
            }
            return null;
        }
Example #21
0
 public IfcProductModelView(IIfcProduct prod, IXbimViewModel parent)
 {
     CreatingParent = parent;
     _product       = prod;
 }
 public XbimRefModelViewModel(IO.XbimReferencedModel refModel, IXbimViewModel parent)
 {
     this.CreatingParent = parent;
     this.refModel       = refModel;
 }
Example #23
0
 protected void Expand(IXbimViewModel treeitem)
 {
     treeitem.IsExpanded = true;
     foreach (var child in treeitem.Children)
     {
         Expand(child);
     }
 }
Example #24
0
 // todo: bonghi: this function should be changed to match IXbimViewModel directly.
 // it should be possible in the redesign to build an IXbimViewModel from an IPersistEntity.
 private static bool IsMatch(IXbimViewModel node, IPersistEntity entity)
 {
     return(Equals(node.Model, entity.Model) && node.EntityLabel == entity.EntityLabel);
 }
Example #25
0
        //public ContainedElementsViewModel(IfcSpatialStructureElement container)
        //{
        //    xbimModel = container.ModelOf as XbimModel;
        //    IEnumerable subs = this.Children; //call this once to preload first level of hierarchy
        //}

        public ContainedElementsViewModel(IfcSpatialStructureElement spatialElem, Type type, IXbimViewModel parent)
        {
            this.spatialContainerLabel = spatialElem.EntityLabel;
            this.type           = type;
            this.xbimModel      = (XbimModel)spatialElem.ModelOf;
            this.CreatingParent = parent;
        }
 public XbimRefModelViewModel(IO.XbimReferencedModel refModel, IXbimViewModel parent)
 {
     this.CreatingParent = parent;
     this.refModel = refModel;
 }
Example #27
0
 public GroupViewModel(IfcGroup gr, IXbimViewModel parent)
 {
     this.group     = gr;
     CreatingParent = parent;
 }
Example #28
0
        // todo: bonghi: this one is too slow on Architettonico_def.xBIM, so I'm patching it for a specific hierarchy, but it needs serious redesign for efficiency
        private void Select(IPersistEntity newVal, bool tryOptimise = true)
        {
            if (ViewDefinition == XbimViewType.SpatialStructure && tryOptimise)
            {
                /*
                 * We know that the structure in this case looks like:
                 *
                 * XbimModelViewModel
                 *  model.project.GetSpatialStructuralElements (into SpatialViewModel)
                 *  model.RefencedModels (into XbimRefModelViewModel)
                 *      model.project.GetSpatialStructuralElements (into SpatialViewModel)
                 *
                 * SpatialViewModel
                 *  SpatialViewModel
                 *  ContainedElementsViewModel
                 *      IfcProductModelView
                 *          IfcProductModelView
                 *
                 * If a model is a product then find its space with breadth first then expand to it with depth first.
                 * todo: bonghi: this is still not optimal, because it can only point to simple IPersistEntity and not intermediate IXbimViewModels.
                 *
                 */
                var p = newVal as IIfcProduct;
                if (p != null)
                {
                    var found = FindUnderContainingSpace(newVal, p);  // direct search
                    if (found == null)
                    {
                        // search for composed object
                        var decomp = p.Decomposes.FirstOrDefault();

                        if (decomp?.RelatingObject is IIfcProduct)                                          //
                        {
                            found = FindUnderContainingSpace(newVal, (IIfcProduct)(decomp.RelatingObject)); // direct search of parent through containing space
                            if (found != null)
                            {
                                found = FindItemDepthFirst(found, newVal); // then search for the child
                            }
                        }
                        else
                        {
                            // do basic search
                            Select(newVal, false);
                        }
                    }
                    if (found != null)
                    {
                        Highlight(found);
                        return;
                    }
                }
                // if optimised search fails revert to brute force expansion
                Select(newVal, false);
            }
            else
            {
                foreach (var item in HierarchySource.OfType <IXbimViewModel>())
                {
                    IXbimViewModel toSelect = FindItemDepthFirst(item, newVal);
                    if (toSelect != null)
                    {
                        Highlight(toSelect);
                        return;
                    }
                }
            }
        }
Example #29
0
 public XbimRefModelViewModel(IReferencedModel refModel, IXbimViewModel parent)
 {
     CreatingParent = parent;
     _refModel      = refModel;
 }