/// <summary> /// Drawing method used to draw factory content /// </summary> /// <param name="graphics">Graphic environment parameters</param> public void Draw(PicGraphics graphics, PicFilter filter) { graphics.Initialize(); // bounding box if (!graphics.DrawingBox.IsValid) { // compute bounding box using (PicVisitorBoundingBox visitor = new PicVisitorBoundingBox()) { ProcessVisitor(visitor); Box2D box = visitor.Box; box.AddMarginRatio(0.01); // set as drawing box graphics.DrawingBox = box; } } // first, draw cotation foreach (PicEntity entity in _entities) { try { // cotation PicCotation cotation = entity as PicCotation; if (cotation != null && !cotation.Deleted && filter.Accept(entity)) { cotation.Draw(graphics); } } catch (Exception ex) { _log.Error(ex.Message); } } // then other entities foreach (Object o in _entities) { try { // drawable entities PicDrawable drawable = o as PicDrawable; if (drawable != null && !drawable.Deleted && !(drawable is PicCotation) && filter.Accept(drawable)) { drawable.Draw(graphics); } } catch (Exception ex) { _log.Error(ex.Message); } } // cardboard format if (null != _cardboardFormat) { _cardboardFormat.Draw(graphics); } graphics.Finish(); }
/// <summary> /// Removes entities that match a specific criterion (filter) /// </summary> /// <param name="filter">Filter upon which entities are tested</param> public void Remove(PicFilter filter) { // build list of entities to remove List <PicEntity> entitiesToRemove = new List <PicEntity>(); foreach (PicEntity entity in _entities) { if (filter.Accept(entity)) { entitiesToRemove.Add(entity); } } // removes entities foreach (PicEntity entity in entitiesToRemove) { _entities.Remove(entity); } }
public void ProcessVisitor(PicFactoryVisitor visitor, PicFilter filter) { visitor.Initialize(this); foreach (PicEntity entity in _entities) { try { if (entity != null && !entity.Deleted && filter.Accept(entity)) { visitor.ProcessEntity(entity); } } catch (Exception ex) { _log.Error(ex.Message); } } visitor.Finish(); }
/// <summary> /// Drawing method used to draw factory content /// </summary> /// <param name="graphics">Graphic environment parameters</param> public void Draw(PicGraphics graphics, PicFilter filter) { graphics.Initialize(); // bounding box if (!graphics.DrawingBox.IsValid) { try { // compute bounding box graphics.DrawingBox = Tools.BoundingBox(this, filter, 0.025); } catch (Exception /*ex*/) { return; } } // first, draw cotation foreach (PicEntity entity in _entities) { try { // cotation if (entity is PicCotation cotation && !cotation.Deleted && filter.Accept(entity)) { cotation.Draw(graphics); } } catch (Exception ex) { _log.Error(ex.Message); } } // then other entities foreach (object o in _entities) { try { // drawable entities if (o is PicDrawable drawable && !drawable.Deleted && !(drawable is PicCotation) && filter.Accept(drawable)) { drawable.Draw(graphics); } } catch (Exception ex) { _log.Error(ex.Message); } } // cardboard format if (null != _cardboardFormat) { _cardboardFormat.Draw(graphics); } graphics.Finish(); }