Example #1
0
        public void SelectGeometry(GeometricEntity _e)
        {
            List <GeometricEntity> gList = GetFlatGeometryList();
            // DEBUG
            //long[] ids = gList.Select(x => x.ID).ToArray();
            long id = (_e == null) ? -1 : _e.ID;

            this.AdaptSelectionState(gList, id);
        }
Example #2
0
        public ZonedVolume GetVolumeByID(long _id)
        {
            List <GeometricEntity> gList = GetFlatGeometryList();
            GeometricEntity        found = gList.FirstOrDefault(x => x.ID == _id && x is ZonedVolume);

            if (found != null)
            {
                return(found as ZonedVolume);
            }
            else
            {
                return(null);
            }
        }
Example #3
0
        internal ZonedPolygonGroup ReconstructZonedLevel(long _id, string _name, SharpDX.Color _color, EntityVisibility _vis, bool _is_valid, bool _assoc_w_comp,
                                                         float _line_thickness_GUI, List <string> _mLtext, bool _is_top_closure, bool _is_bottom_closure,
                                                         List <long> _zoned_polygon_ids)
        {
            // find all polygons contained in the group (level)
            if (_zoned_polygon_ids == null)
            {
                return(null);
            }
            if (_zoned_polygon_ids.Count < 1)
            {
                return(null);
            }

            List <ZonedPolygon> level_polygons = new List <ZonedPolygon>();

            foreach (long id in _zoned_polygon_ids)
            {
                GeometricEntity ge_found = this.parsed_GE_before_adding_to_Layer.FirstOrDefault(x => x.ID == id);
                if (ge_found == null)
                {
                    continue;
                }

                ZonedPolygon zp_found = ge_found as ZonedPolygon;
                if (zp_found == null)
                {
                    continue;
                }

                level_polygons.Add(zp_found);
            }

            if (level_polygons.Count < 1)
            {
                return(null);
            }

            // reconstruct the grouop (level)
            ZonedPolygonGroup created = new ZonedPolygonGroup(_id, _name, _color, _vis, _is_valid, _assoc_w_comp, _line_thickness_GUI, _mLtext,
                                                              _is_top_closure, _is_bottom_closure, level_polygons);

            Entity.Nr_Entities = Math.Max(Entity.Nr_Entities, _id) + 1;
            return(created);
        }
Example #4
0
        public Entity ProcessSearch(string _partName)
        {
            if (_partName == null || _partName == String.Empty)
            {
                return(null);
            }

            if (this.entities_flat == null)
            {
                this.entities_flat = new List <Entity>();
                this.entities_flat.AddRange(this.GetFlatLayerList());
                this.entities_flat.AddRange(this.GetFlatGeometryList());
            }

            if (this.entities_flat.Count < 1)
            {
                return(null);
            }

            if (this.matchingEntityEnumerator == null || !this.matchingEntityEnumerator.MoveNext() || prev_search_text != _partName)
            {
                this.VerifyMatches(_partName);
            }

            Entity ent = this.matchingEntityEnumerator.Current;

            // update GUI parameters
            if (ent != null)
            {
                GeometricEntity gent = ent as GeometricEntity;
                if (gent != null)
                {
                    this.SelectGeometry(gent);
                }
                Layer lent = ent as Layer;
                if (lent != null)
                {
                    this.SelectLayer(lent);
                }
            }

            this.prev_search_text = _partName;
            return(ent);
        }
Example #5
0
        public bool RemoveEntity(Entity _e)
        {
            if (_e == null)
            {
                return(false);
            }

            GeometricEntity ge    = _e as GeometricEntity;
            Layer           layer = _e as Layer;

            if (ge != null)
            {
                // if the entity is a volume, release the connection to its defining levels and polygons
                // trigger its PropertyChanged event to alert a Space that may use it
                ZonedVolume zv = ge as ZonedVolume;
                if (zv != null)
                {
                    zv.ReleaseLevels();
                    zv.EditModeType = ZonedVolumeEditModeType.ISBEING_DELETED;
                }

                // if the entity is a polygon, trigger its PropertyChanged event to alert a Volume that may use it
                ZonedPolygon zp = ge as ZonedPolygon;
                if (zp != null)
                {
                    zp.EditModeType = ZonePolygonEditModeType.ISBEING_DELETED;
                }

                // remove from the layer
                Layer geL = ge.EntityLayer;
                return(geL.RemoveEntity(_e));
            }
            else if (layer != null)
            {
                return(this.RemoveLayer(layer));
            }

            return(false);
        }
        public List <GeometricEntity> GetFlatGeometryList()
        {
            if (this.ContainedEntities == null || this.ContainedEntities.Count < 1)
            {
                return(new List <GeometricEntity>());
            }

            List <GeometricEntity> list = new List <GeometricEntity>();

            foreach (Entity e in this.ContainedEntities)
            {
                GeometricEntity ge    = e as GeometricEntity;
                Layer           layer = e as Layer;
                if (ge != null)
                {
                    list.Add(ge);
                }
                else if (layer != null)
                {
                    list.AddRange(layer.GetFlatGeometryList());
                }
            }
            return(list);
        }
Example #7
0
        private void AdaptSelectionState(List <GeometricEntity> _gList, long _gID)
        {
            if (_gList == null)
            {
                return;
            }

            this.ResetSelectionVaraibles();

            int n = _gList.Count;

            for (int i = 0; i < n; i++)
            {
                GeometricEntity ge = _gList[i];
                if (_gID != ge.ID)
                {
                    ge.IsSelected = false;
                }
                else
                {
                    ge.IsSelected = true;

                    // process state in GUI
                    ge.EntityLayer.IsExpanded = true;
                    Layer topParent = GetParentLayer(ge.EntityLayer);
                    if (topParent != null)
                    {
                        topParent.IsExpanded = true;
                    }

                    // process further, if selected entity is a ZonedPolygon or a ZonedVolume
                    ZonedPolygon zp = ge as ZonedPolygon;
                    ZonedVolume  zv = ge as ZonedVolume;
                    if (zp != null)
                    {
                        this.SelectedPolygon           = zp;
                        this.SelectedEntityIsPolygon   = true;
                        this.VerticesOfSelectedPolygon = zp.ExtractVerticesForDisplay();
                        this.OpeningsOfSelectedPolygon = zp.ExtractOpeningsForDisplay();
                        this.SurfacesOfSelectedVolume  = new List <ZonedVolumeSurfaceVis>();

                        this.SelectedVolume         = null;
                        this.SelectedEntityIsVolume = false;
                    }
                    else if (zv != null)
                    {
                        this.SelectedVolume         = zv;
                        this.SelectedEntityIsVolume = true;

                        this.SelectedPolygon           = null;
                        this.SelectedEntityIsPolygon   = false;
                        this.VerticesOfSelectedPolygon = new List <ZonedPolygonVertexVis>();
                        this.OpeningsOfSelectedPolygon = new List <ZoneOpeningVis>();
                        this.SurfacesOfSelectedVolume  = zv.ExtractSurfacesAndOpeningsForDisplay(); // changed 30.08.2017
                    }
                    else
                    {
                        this.ResetSelectionVaraibles();
                    }
                    this.SelectedGeomIndex = i;
                    break;
                }
            }
        }