using Dirichlet.Numerics; /// /// Copyright (c) 2020 Sensus Slovensko a.s. /// using System; using System.Drawing; using System.Drawing.Drawing2D; namespace SchematicDrawing { public static class Const { public const int GridSize = 10; public const int SecondaryStart = 10000; public const int Vacuum = 1000000; } public enum Element { None = 0, Body = 1, /// Item body (component image) Label = 2, /// Item label MeasuredVal = 4, /// Item measured value Setpoint = 8, /// Item setpoint Node = 16, /// A node of an item Pipe = 32, /// Pipe between two nodes } public enum Shape { Ambient, Clamping, Cover, Cross, Div, EmergencyStop, FlowM, Junction, Knee, ParallelFlowM, PressM, Pump, PumpFM, RegV, Scale, Sink, Tank, Tee, TempM, UniCB, Vacuum, Valve, WaterM, ElectricM, Count, Custom, } public enum Sz { None, S, M, L, XL, Count, } public enum Orient { R, Dn, L, Up, Count, } public enum RouteCouple { None, OpenWhen1, ClosedWhen1, } public static class Utils { /// /// Return coordinates of the vector in direction Orient /// /// Orient /// Vector public static Point GetVect(Orient orient) { switch (orient) { default: case Orient.R: return new Point(1, 0); case Orient.Up: return new Point(0, -1); case Orient.L: return new Point(-1, 0); case Orient.Dn: return new Point(0, 1); } } /// /// Return coordinates of the vector perpendicular to Orient /// /// Orient /// Perpendicular vector public static Point GetNormalVect(Orient orient) { switch (orient) { default: case Orient.R: return new Point(0, 1); case Orient.Up: return new Point(1, 0); case Orient.L: return new Point(0, -1); case Orient.Dn: return new Point(-1, 0); } } /// /// Returns true when item is hidden (both X and Y coordinates are 0) /// /// Drawing item /// true when hidden public static bool IsHidden(IDrawingItem item) { return (item.X == 0) && (item.Y == 0); } /// /// Updates distances of graph edges of IRouteBasedDrewingItem (valve, pump, ...) after route chanage. /// /// Route /// Item public static void UpdateGraphEdges(UInt128 route, IRouteBasedDrawingItem item) { bool routeBit = (route & (((UInt128)1) << item.BitNr)) != 0; foreach (var gedge in item.EdgesToSet) gedge.UpdateFromRoute(item.Inverted ? (!routeBit) : routeBit); } } }