public DimArray(DimType dimtype, string filePath, int length) { this.m_DimShort = null; this.m_DimByte = null; this.m_DimUShort = null; this.m_DimOffset = 0; this.m_IsDataNeedTransform = true; this.m_IsForClutter = false; this.m_DimType = dimtype; switch (this.m_DimType) { case DimType.Binary8: this.m_DimByte = new DimArrayTemplate<byte>(filePath, length); this.m_DimBase = this.m_DimByte; break; case DimType.Binary16: this.m_DimShort = new DimArrayTemplate<short>(filePath, length); this.m_DimBase = this.m_DimShort; break; case DimType.Ubinary16: this.m_DimUShort = new DimArrayTemplate<ushort>(filePath, length); this.m_DimBase = this.m_DimUShort; break; } }
private void AddUomStringPart(DimType dimType, double dimPartVal, ref string sTop, ref string sBottom) { if (dimPartVal == 0) { return; } KnownUOM baseUom; baseUom = this.FindFromDimensions(new Dimensions(dimType, 1)); if (dimPartVal > 0) { sTop += baseUom.Symbol; if (dimPartVal != 1) { sTop += string.Format("^{0}", dimPartVal); } } else if (dimPartVal < 0) { sBottom += baseUom.Symbol; if (dimPartVal != -1) { sBottom += string.Format("^{0}", Math.Abs(dimPartVal)); } } }
/// <summary> /// Get the Dimensions for v1 / v2 by subtracting the component parts of the 2 sets of Dimensions. /// </summary> /// <returns>A newly created Dimensions instance</returns> public static Dimensions SubtractDimensions(Dimensions dims1, Dimensions dims2) { if ((dims1 == null) && (dims2 == null)) { return(null); } if (dims1 == null) { return(null); } if (dims2 == null) { return(null); } Dimensions resDims = new Dimensions(); foreach (var dimType in Enum.GetValues(typeof(DimType))) { DimType dt = (DimType)dimType; resDims.Dims[dt] = dims1.Dims[dt] - dims2.Dims[dt]; } return(resDims); }
public GeoDemFile(string filePath, IGeoLayerBoundProperty iLayerBound, int dimOffset, DimType type, GridType gridType) { this.m_RowsCount = 0; this.m_ColumnsCount = 0; this.m_Resolution = 10.0; this.m_DimOffset = 0; this.m_IsExceptional = false; this.m_DimOffset = dimOffset; this.m_DimType = type; this.m_GridType = gridType; this.m_FilePath = filePath; this.m_Resolution = iLayerBound.Resolution; this.m_BottomOfBound = iLayerBound.BottomBound; this.m_LeftOfBound = iLayerBound.LeftBound; this.m_TopOfBound = iLayerBound.TopBound; this.m_RightOfBound = iLayerBound.RightBound; this.m_BenchmarkHeight = iLayerBound.BenchmarkHeight; this.m_HeightStep = iLayerBound.HeightStep; try { this.CalcRowsColums(); } catch { this.m_IsExceptional = true; } }
public GeoDemFile() { this.m_RowsCount = 0; this.m_ColumnsCount = 0; this.m_Resolution = 10.0; this.m_DimOffset = 0; this.m_IsExceptional = false; this.m_DimType = DimType.Binary16; this.m_DimOffset = 0; }
public static string GetExplanationLine() { string explanationLine = ""; foreach (var dimType in Enum.GetValues(typeof(DimType))) { DimType dt = (DimType)dimType; explanationLine += $"{_prefixes[dt]}={dt.ToString()}, "; } return(explanationLine); }
float GenerateSize(DimType t, float srcS, float val) { switch (t) { case DimType.Relative: return(srcS - val); case DimType.RelativeScale: return(srcS * val); default: return(val); } }
/// <summary> /// Does it look like we can work with the token stream? If so, return some data /// regarding what statement type it is, and how many tokens were required to /// define that type /// </summary> private bool canBeHandled(List <IToken> tokens, out int tokensConsumed, out DimType dimType) { if (base.checkAtomTokenPattern(tokens, new string[] { "DIM" }, false)) { tokensConsumed = 1; dimType = DimType.Dim; return(true); } if (base.checkAtomTokenPattern(tokens, new string[] { "REDIM" }, false)) { if (base.checkAtomTokenPattern(tokens, new string[] { "REDIM", "PRESERVE" }, false)) { tokensConsumed = 2; dimType = DimType.ReDimPreserve; } else { tokensConsumed = 1; dimType = DimType.ReDim; } return(true); } if (base.checkAtomTokenPattern(tokens, new string[] { "PUBLIC" }, false)) { if (!base.checkAtomTokenPattern(tokens, new string[] { "PUBLIC", "FUNCTION" }, false) && !base.checkAtomTokenPattern(tokens, new string[] { "PUBLIC", "PROPERTY" }, false) && !base.checkAtomTokenPattern(tokens, new string[] { "PUBLIC", "DEFAULT", "PROPERTY" }, false) && !base.checkAtomTokenPattern(tokens, new string[] { "PUBLIC", "SUB" }, false)) { tokensConsumed = 1; dimType = DimType.Public; return(true); } } if (base.checkAtomTokenPattern(tokens, new string[] { "PRIVATE" }, false)) { if (!base.checkAtomTokenPattern(tokens, new string[] { "PRIVATE", "FUNCTION" }, false) && !base.checkAtomTokenPattern(tokens, new string[] { "PRIVATE", "PROPERTY" }, false) && !base.checkAtomTokenPattern(tokens, new string[] { "PRIVATE", "SUB" }, false)) { tokensConsumed = 1; dimType = DimType.Private; return(true); } } tokensConsumed = 0; dimType = DimType.Unknown; return(false); }
public override string ToString() { string s = ""; foreach (var dimType in Enum.GetValues(typeof(DimType))) { DimType dt = (DimType)dimType; if (Dims[dt] != 0.0) // TODO: Equations: Tolerance { s += string.Format("{0}^{1} ", _prefixes[dt], Dims[dt]); } s = s.Trim(); } return(s); }
public GeoDemFile(string filePath, GeoXYRect geoBound, double resolution) { this.m_RowsCount = 0; this.m_ColumnsCount = 0; this.m_Resolution = 10.0; this.m_DimOffset = 0; this.m_IsExceptional = false; this.m_DimType = DimType.Binary16; this.m_DimOffset = 0; this.m_FilePath = filePath; this.m_Resolution = resolution; this.m_BottomOfBound = geoBound.Bottom; this.m_LeftOfBound = geoBound.Left; this.m_TopOfBound = geoBound.Top; this.m_RightOfBound = geoBound.Right; this.CalcRowsColums(); }
/// <summary> /// Get the Dimensions for v1 ^ exponent by multiplying the component parts of the 1st set of Dimensions by the exponent. /// </summary> /// <returns>A newly created Dimensions instance</returns> public static Dimensions MultiplyDimensions(Dimensions dims1, double exponent) { if (dims1 == null) { return(null); } Dimensions resDims = new Dimensions(); foreach (var dimType in Enum.GetValues(typeof(DimType))) { DimType dt = (DimType)dimType; resDims.Dims[dt] = dims1.Dims[dt] * exponent; } return(resDims); }
// -------------------- public override bool Equals(Object obj) { Dimensions dims1 = obj as Dimensions; if (dims1 == null) { return(false); } foreach (var dimType in Enum.GetValues(typeof(DimType))) { DimType dt = (DimType)dimType; if (dims1.Dims[dt] != this.Dims[dt]) // TODO: Equations: Tolerance { return(false); } } return(true); }
/// <summary> /// See if dims1 is dimensionless /// </summary> /// <returns>A newly created Dimensions instance</returns> public static bool IsDimenionless(Dimensions dims1) { if (dims1 == null) { return(false); } bool bRet = true; foreach (var dimType in Enum.GetValues(typeof(DimType))) { DimType dt = (DimType)dimType; if (dims1.Dims[dt] != 0.0) // TODO: Equations: Tolerance { bRet = false; break; } } return(bRet); }
public ControlDimmer(LoxoneUuid loxoneUuid, DimType dimType, int value) { this.LoxoneUuid = loxoneUuid; this.Type = dimType; this.Value = value; }
public Dimensions(DimType dimType, double dimPartVal) { Initialise(); _dims[dimType] = dimPartVal; }
public DimArray(DimType dimType, Huawei.UNet.GIS.GeoInterface.GridType gridType, short benchmarkHeight, short heightStep) { this.m_DimShort = null; this.m_DimByte = null; this.m_DimUShort = null; this.m_DimOffset = 0; this.m_IsDataNeedTransform = true; this.m_IsForClutter = false; this.m_DimOffset = 0; this.m_DimType = dimType; this.m_GridType = gridType; this.m_BenchmarkHeight = benchmarkHeight; this.m_HeightStep = heightStep; switch (this.m_DimType) { case DimType.Binary8: this.m_DimByte = new DimArrayTemplate<byte>(); this.m_DimBase = this.m_DimByte; break; case DimType.Binary16: this.m_DimShort = new DimArrayTemplate<short>(); this.m_DimBase = this.m_DimShort; break; case DimType.Ubinary16: this.m_DimUShort = new DimArrayTemplate<ushort>(); this.m_DimBase = this.m_DimUShort; break; } }
static public void NZ_qvdim() { Document acDoc = Application.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; Editor ed = acDoc.Editor; var opt = new PromptNestedEntityThroughViewportOptions("开始拉线选择标注边界线."); Viewport vports; DimType dimtype = DimType.row; var res = SelectThroughViewport.GetDimedEntityThroughViewport(ed, opt, dimtype, out vports); if (res.Status != PromptStatus.OK) { Log4NetHelper.WriteInfoLog("没有选择到实体.\n"); ed.WriteMessage("没有选择到实体.\n\t"); return; } if (vports == null) { ed.WriteMessage("视口放大太小,请放大到全视口选择实体。\n"); return; } using (Transaction tr = acCurDb.TransactionManager.StartTransaction()) { LayerTable ltb = (LayerTable)tr.GetObject(acCurDb.LayerTableId, OpenMode.ForRead); //create a new layout. if (!ltb.Has("NewLayer")) { ltb.UpgradeOpen(); LayerTableRecord newLayer = new LayerTableRecord(); newLayer.Name = "NewLayer"; newLayer.LineWeight = LineWeight.LineWeight005; newLayer.Description = "This is new layer"; //red color newLayer.Color = Autodesk.AutoCAD.Colors.Color.FromRgb(255, 0, 0); ltb.Add(newLayer); tr.AddNewlyCreatedDBObject(newLayer, true); } tr.Commit(); //make it as current acCurDb.Clayer = ltb["NewLayer"]; } Entity ent, vent; ViewportInfo vpinfo = null; ObjectId[] vpEnts = null; using (Transaction trx = acCurDb.TransactionManager.StartTransaction()) { ObjectId lid = res.ObjectId; ent = (Entity)trx.GetObject(lid, OpenMode.ForWrite); Log4NetHelper.WriteInfoLog("实体的类型是:" + ent.Visible + "\n"); ed.WriteMessage("实体的类型是:" + ent.Visible + "\n"); //ent.ColorIndex = 1; // ent.Visible = false; vpinfo = CadHelper.GetViewInfo(vports, trx); if (vpinfo != null) { Log4NetHelper.WriteInfoLog("找到视口."); ed.SwitchToModelSpace(); vpEnts = SelectEntitisInModelSpaceByViewport( acDoc, vpinfo.BoundaryInModelSpace, trx); ed.WriteMessage("\n{0} entit{1} found via Viewport \"{2}\"", vpEnts.Length, vpEnts.Length > 1 ? "ies" : "y", vpinfo.ViewportId.ToString()); SqliteHelper.AddOrUpdateOneViewPortEntityIds((long)(vpinfo.ViewportId.OldIdPtr), vpEnts); } ed.SwitchToPaperSpace(); if (vpEnts != null && vpEnts.Length > 0) { foreach (ObjectId vpentid in vpEnts) { vent = (Entity)trx.GetObject(vpentid, OpenMode.ForWrite); if (vent.ColorIndex == ent.ColorIndex) { vent.Visible = true; } else { vent.Visible = false; } } } trx.Commit(); } }
public static PromptNestedEntityThroughViewportResult GetDimedEntityThroughViewport(this Editor acadEditor, PromptNestedEntityThroughViewportOptions options, DimType dimtype, out Viewport viewport) { Document acadDocument = acadEditor.Document; Database acadDatabase = acadDocument.Database; LayoutManager layoutManager = LayoutManager.Current; Point3d basepnt; PromptPointResult res = acadEditor.GetPoint("开始拉线请先选择线开始点。"); if (res.Status != PromptStatus.OK) { viewport = null; return(null);; } basepnt = res.Value; if (basepnt == null) { viewport = null; return(null);; } SelectDimViewportJig stvpJig = new SelectDimViewportJig(acadEditor, basepnt, options); PromptResult pointResult = acadEditor.Drag(stvpJig); if (pointResult.Status == PromptStatus.OK) { Point3d pickedPoint = stvpJig.Result.Value; PromptNestedEntityOptions pneOpions = options.Options; pneOpions.NonInteractivePickPoint = pickedPoint; pneOpions.UseNonInteractivePickPoint = true; PromptNestedEntityResult pickResult = acadEditor.GetNestedEntity(pneOpions); if ((pickResult.Status == PromptStatus.OK) || (acadDatabase.TileMode) || (acadDatabase.PaperSpaceVportId != acadEditor.CurrentViewportObjectId)) { viewport = null; return(new PromptNestedEntityThroughViewportResult(pickResult)); } else { SelectionFilter vportFilter = new SelectionFilter(new TypedValue[] { new TypedValue(0, "VIEWPORT"), new TypedValue(-4, "!="), new TypedValue(69, 1), new TypedValue(410, layoutManager.CurrentLayout) }); PromptSelectionResult vportResult = acadEditor.SelectAll(vportFilter); if (vportResult.Status == PromptStatus.OK) { using (Transaction trans = acadDocument.TransactionManager.StartTransaction()) { foreach (ObjectId objectId in vportResult.Value.GetObjectIds()) { viewport = (Viewport)trans.GetObject(objectId, OpenMode.ForRead, false, false); if (viewport.ContainsPoint(pickedPoint)) { pneOpions.NonInteractivePickPoint = TranslatePointPsToMs(viewport, pickedPoint); pneOpions.UseNonInteractivePickPoint = true; acadEditor.SwitchToModelSpace(); Application.SetSystemVariable("CVPORT", viewport.Number); PromptNestedEntityResult pneResult = acadEditor.GetNestedEntity(pneOpions); acadEditor.SwitchToPaperSpace(); if (pneResult.Status == PromptStatus.OK) { return(new PromptNestedEntityThroughViewportResult(pneResult, objectId)); } } } } } viewport = null; return(new PromptNestedEntityThroughViewportResult(pickResult)); } } else { viewport = null; return(new PromptNestedEntityThroughViewportResult(pointResult)); } }