public UndoRect(DRect r) { X = r.X; Y = r.Y; Width = r.Width; Height = r.Height; }
public static double DistYBetweenRects(DRect r1, DRect r2) { if (r1.Bottom < r2.Top) return r2.Top - r1.Bottom; else if (r1.Top > r2.Bottom) return r1.Top - r2.Bottom; else return 0; }
public static double DistXBetweenRects(DRect r1, DRect r2) { if (r1.Right < r2.Left) return r2.Left - r1.Right; else if (r1.Left > r2.Right) return r1.Left - r2.Right; else return 0; }
public EmfGraphics(DRect bounds, DPoint screenMM, DPoint deviceRes) { this.screenMM = screenMM; this.deviceRes = deviceRes; // create memory stream ms = new MemoryStream(); // write header Emf.MetafileHeaderExtension2 h = new Emf.MetafileHeaderExtension2(); h.EmfHeader.Type = 1; h.EmfHeader.Size = (uint)Marshal.SizeOf(typeof(Emf.MetafileHeaderExtension2)); h.EmfHeader.Bounds = new Emf.RectL((int)bounds.X, (int)bounds.Y, (int)bounds.Right, (int)bounds.Bottom); double pixelWidth = screenMM.X / deviceRes.X; double pixelHeight = screenMM.Y / deviceRes.Y; h.EmfHeader.Frame = new Emf.RectL((int)(bounds.X * 100 * pixelWidth), (int)(bounds.Y * 100 * pixelHeight), (int)(bounds.Right * 100 * pixelWidth), (int)(bounds.Bottom * 100 * pixelHeight)); h.EmfHeader.Signature = (uint)Emf.FormatSignature.ENHMETA_SIGNATURE; h.EmfHeader.Version = 0x00010000; h.EmfHeader.Bytes = 0; // size of metafile (set later on) h.EmfHeader.Records = 0; // num of records in metafile (set later on) h.EmfHeader.Handles = 0; // max number of gdi objects used at one time (set later on) h.EmfHeader.Reserved = 0; h.EmfHeader.nDescription = 0; h.EmfHeader.offDescription = 0; h.EmfHeader.nPalEntries = 0; // set later on h.EmfHeader.Device = new Wmf.SizeL((uint)deviceRes.X, (uint)deviceRes.Y); h.EmfHeader.Millimeters = new Wmf.SizeL((uint)screenMM.X, (uint)screenMM.Y); h.EmfHeaderExtension1.cbPixelFormat = 0; h.EmfHeaderExtension1.offPixelFormat = 0; h.EmfHeaderExtension1.bOpenGL = 0; h.EmfHeaderExtension2.MicrometersX = (uint)(screenMM.X * 1000); h.EmfHeaderExtension2.MicrometersY = (uint)(screenMM.Y * 1000); byte[] data = RawSerialize(h); ms.Write(data, 0, data.Length); WriteRecordHeader(Emf.RecordType.EMR_SETMAPMODE, 12); WriteUInt(0x08); // MM_ANISOTROPIC WriteRecordHeader(Emf.RecordType.EMR_SETWINDOWORGEX, 16); WritePointL(new Wmf.PointL(h.EmfHeader.Bounds.Left, h.EmfHeader.Bounds.Top)); WriteRecordHeader(Emf.RecordType.EMR_SETWINDOWEXTEX, 16); WriteSizeL(new Wmf.SizeL((uint)(h.EmfHeader.Bounds.Right - h.EmfHeader.Bounds.Left), (uint)(h.EmfHeader.Bounds.Bottom - h.EmfHeader.Bounds.Top))); WriteRecordHeader(Emf.RecordType.EMR_SETVIEWPORTORGEX, 16); WritePointL(new Wmf.PointL(h.EmfHeader.Bounds.Left, h.EmfHeader.Bounds.Top)); WriteRecordHeader(Emf.RecordType.EMR_SETVIEWPORTEXTEX, 16); WriteSizeL(new Wmf.SizeL((uint)(h.EmfHeader.Bounds.Right - h.EmfHeader.Bounds.Left), (uint)(h.EmfHeader.Bounds.Bottom - h.EmfHeader.Bounds.Top))); WriteRecordHeader(Emf.RecordType.EMR_SETBKMODE, 12); WriteUInt(0x01); // TRANSPARENT WriteRecordHeader(Emf.RecordType.EMR_SETTEXTALIGN, 12); WriteUInt(Wmf.TA_LEFT | Wmf.TA_TOP); }
public static DRect BoundingBoxOfRotatedRect(DRect rect, double angle, DPoint origin) { if (angle == 0) return rect; DPoint p1 = RotatePoint(rect.TopLeft, origin, angle); DPoint p2 = RotatePoint(rect.TopRight, origin, angle); DPoint p3 = RotatePoint(rect.BottomLeft, origin, angle); DPoint p4 = RotatePoint(rect.BottomRight, origin, angle); double x = Math.Min(Math.Min(p1.X, p2.X), Math.Min(p3.X, p4.X)); double y = Math.Min(Math.Min(p1.Y, p2.Y), Math.Min(p3.Y, p4.Y)); double right = Math.Max(Math.Max(p1.X, p2.X), Math.Max(p3.X, p4.X)); double bottom = Math.Max(Math.Max(p1.Y, p2.Y), Math.Max(p3.Y, p4.Y)); return new DRect(x, y, right - x, bottom - y); }
void Start () { audio = GetComponent<AudioSource>(); moves = moves.GetComponent<Text>(); BigSquare = BigSquare.GetComponent<BigSquare>(); DRect = DRect.GetComponent<DRect>(); Rect1 = Rect1.GetComponent<Rectangle>(); Rect2 = Rect2.GetComponent<Rectangle>(); Rect3 = Rect3.GetComponent<Rectangle>(); Rect4 = Rect4.GetComponent<Rectangle>(); Square1 = Square1.GetComponent<Square>(); Square2 = Square2.GetComponent<Square>(); Square3 = Square3.GetComponent<Square>(); Square4 = Square4.GetComponent<Square>(); setGameBoard (); }
// TODO: przerobiæ Part na LPoint public override void CalcMBR() { DRect oMBR = new DRect(); /* PolygonFeature oP = this; // draw polyline for (int iPart = 0; iPart < oP.m_oParts.Count; iPart++) { List<Point> Points_list = oP.m_oParts[iPart].Points; for (int iPnt = 0; iPnt < Points_list.Count; iPnt++) { Point oPnt = Points_list[iPnt]; oMBR.MergeRectWithPoint(new LPoint(oPnt.X, oPnt.Y)); } }*/ base.m_oMBR = oMBR; }
public DBitmap CaptureImage(DRect rect) { System.Diagnostics.Debug.Assert(rect.Width > 0, "ERROR: rect.Width <= 0"); System.Diagnostics.Debug.Assert(rect.Height > 0, "ERROR: rect.Height <= 0"); // create list of figures to format to bitmap List<Figure> figs = new List<Figure>(); figs.Add(de.BackgroundFigure); foreach (Figure f in de.Figures) figs.Add(f); // format the figures to bitmap DBitmap initialBmp = FigureSerialize.FormatToBmp(figs, dv.AntiAlias, DColor.White); // crop the bitmap to the rect DBitmap croppedBmp = WFHelper.MakeBitmap((int)rect.Width, (int)rect.Height); DGraphics dg = WFHelper.MakeGraphics(croppedBmp); dg.DrawBitmap(initialBmp, new DPoint(-rect.X, -rect.Y)); dg.Dispose(); initialBmp.Dispose(); return croppedBmp; }
/// <summary> /// Gets a list of items intersecting a specified rectangle /// </summary> /// <param name="Rect">The rectangle</param> /// <param name="ItemsFound">The list to add found items to (list will not be cleared first)</param> /// <remarks>ItemsFound is assumed to be initialized, and will not be cleared</remarks> public void GetItems(DRect Rect, ref List <QuadTreePositionItem <T> > ItemsFound) { // test the point against this node if (this.Rect.Intersects(Rect)) { // test the point in each item foreach (QuadTreePositionItem <T> Item in Items) { if (Item.Rect.Intersects(Rect)) { ItemsFound.Add(Item); } } // query all subtrees if (IsPartitioned) { TopLeftNode.GetItems(Rect, ref ItemsFound); TopRightNode.GetItems(Rect, ref ItemsFound); BottomLeftNode.GetItems(Rect, ref ItemsFound); BottomRightNode.GetItems(Rect, ref ItemsFound); } } }
public override void Update(DRect rect) { Rectangle r = new Rectangle((int)((rect.X * Scale) - HortScroll + OffsetX), (int)((rect.Y * Scale) - VertScroll + OffsetY), (int)(rect.Width * Scale), (int)(rect.Height * Scale)); r.Inflate(3, 3); // one for cast to int, one for antialiasing and one for GDI+ control.Invalidate(r); }
/// <summary> /// QuadTree constructor /// </summary> /// <param name="worldRect">The world rectangle for this QuadTree (a rectangle containing all items at all times)</param> /// <param name="maxItems">Maximum number of items in any cell of the QuadTree before partitioning</param> public QuadTree(DRect worldRect, int maxItems) { this.headNode = new QuadTreeNode <T>(worldRect, maxItems, Resize); this.maxItems = maxItems; }
public abstract void Update(DRect rect);
public override void Clip(DRect r) { cr.Rectangle(r.X, r.Y, r.Width, r.Height); cr.Clip(); }
public SelectionFigure(DRect rect) { x = rect.X; y = rect.Y; width = rect.Width; height = rect.Height; }
public override void DrawEllipse(DRect rect, DColor color, double alpha) { DrawEllipse(rect.X, rect.Y, rect.Width, rect.Height, color, alpha, 1, DStrokeStyle.Solid); }
/// <summary> /// Rednders contained features /// </summary> /// <param name="g"></param> /// <param name="Rect"></param> /// <param name="oCC"></param> public void draw(Graphics g, Rectangle Rect, CoordConverter oCC) { if (boundsOK == false) { calculateBounds(); } // calculate Bound in Layer Coordsys double xmin, xmax, ymin, ymax; // bounds of current viewport (in map coordsys) // TODO: respoct rotation of coordsys oCC.ConvertInverse(Rect.Left, Rect.Top); xmin = oCC.X; ymin = oCC.Y; oCC.ConvertInverse(Rect.Right, Rect.Bottom); xmax = oCC.X; ymax = oCC.Y; if (ymin > ymax) { double t = ymin; ymin = ymax; ymax = t; } DRect rectScreenInLayer = new DRect(xmin, ymin, xmax, ymax); // refresh value of Feature.MBR for (int i = 0; i < m_oFeatures.Count; i++) { Feature feature = m_oFeatures[i]; if (feature != null) { int pixelMargin = feature.pixelMargin(); if (feature.MBR.X2 >= xmin - pixelMargin && feature.MBR.X1 <= xmax + pixelMargin && feature.MBR.Y2 >= ymin - pixelMargin && feature.MBR.Y1 <= ymax + pixelMargin) { drawMapFeature(g, Rect, rectScreenInLayer, oCC, feature, false); } } } }
private void drawMapFeature(Graphics g, Rectangle Rect, DRect rectScreenInLayer, CoordConverter oCC, Feature feature, bool selectionStyle) { Debug.Assert(feature != null); if (feature is PolylineFeature) { PolylineFeature oP = (PolylineFeature)feature; // draw polyline points for (int iPart = 0; iPart < oP.m_oParts.Count; iPart++) { List<DPoint> Points_list = oP.m_oParts[iPart].Points; if (Points_list.Count > 0) { DPoint[] Points_src = oP.m_oParts[iPart].Points.ToArray(); int ipp_count = Points_src.GetLength(0); Point[] Points_array = new Point[ipp_count]; Rectangle rect = new Rectangle(0, 0, 6, 6); int? currPointX = null; int? currPointY = null; int? prevPointX = null; int? prevPointY = null; for (int ipp = 0; ipp < ipp_count; ipp++) { // only points withing screen area if (rectScreenInLayer.Contains((double)Points_src[ipp].X, (double)Points_src[ipp].Y)) { oCC.Convert(Points_src[ipp].X, Points_src[ipp].Y); currPointX = (int)oCC.X; currPointY = (int)oCC.Y; rect.X = (int)oCC.X - 3; rect.Y = (int)oCC.Y - 3; rect.Width = 6; rect.Height = 6; if (Points_src[ipp].Selected) { m_oRenderGDIplus.FillRectangle(g, rect, 0xffff0000); // red } else { m_oRenderGDIplus.DrawRectangle(g, rect, 0xff0000ff); // blue } } else { currPointX = null; currPointY = null; } // "add point marker" if (ipp > 0) { if (currPointX != null || prevPointX != null) { // draw if at least one point is visible if (prevPointX == null) { // failed to calculate earlier (not visible), do it now oCC.Convert(Points_src[ipp - 1].X, Points_src[ipp - 1].Y); prevPointX = (int)oCC.X; prevPointY = (int)oCC.Y; } if (currPointX == null) { // failed to calculate earlier (not visible), do it now oCC.Convert(Points_src[ipp].X, Points_src[ipp].Y); currPointX = (int)oCC.X; currPointY = (int)oCC.Y; } int dx = (int)(currPointX - prevPointX); int dy = (int)(currPointY - prevPointY); int len = (int)Math.Sqrt(dx * dx + dy * dy); // draw when line segment longer than 20 pixels if (len > 20) { int pointX = (int)(prevPointX + currPointX) / 2; int pointY = (int)(prevPointY + currPointY) / 2; //m_oRenderGDIplus.DrawLine(g, pointX - 3, pointY - 3, pointX + 3, pointY + 3, 2, Color.Blue, 1); //m_oRenderGDIplus.DrawLine(g, pointX - 3, pointY + 3, pointX + 3, pointY - 3, 2, Color.Blue, 1); } } } prevPointX = currPointX; prevPointY = currPointY; } } } // draw actual polyline for (int iPart = 0; iPart < oP.m_oParts.Count; iPart++) { List<DPoint> Points_list = oP.m_oParts[iPart].Points; if (Points_list.Count > 0) { DPoint[] Points_src = oP.m_oParts[iPart].Points.ToArray(); int ipp_count = Points_src.GetLength(0); Point[] Points_array = new Point[ipp_count]; for (int ipp = 0; ipp < ipp_count; ipp++) { oCC.Convert((double)Points_src[ipp].X, (double)Points_src[ipp].Y); Points_array[ipp] = new Point((int)oCC.X, (int)oCC.Y); } if (oP.Selected) { m_oRenderGDIplus.DrawPolylineFeature(g, Points_array, oP.Style.LinePattern, Color.Red, oP.Style.LineWidth); } else { m_oRenderGDIplus.DrawPolylineFeature(g, Points_array, oP.Style.LinePattern, oP.Style.LineColor, oP.Style.LineWidth); } } } } else if (feature is SymbolFeature) { SymbolFeature oP = (SymbolFeature)feature; oCC.Convert(oP.x, oP.y); Rectangle rect = new Rectangle((int)oCC.X - 2, (int)oCC.Y - 2, 4, 4); if ((oP.color & 0xff000000) != 0x00) { if (feature.Selected) { m_oRenderGDIplus.DrawRectangle(g, rect, (uint)Color.Red.ToArgb()); } else { m_oRenderGDIplus.DrawRectangle(g, rect, oP.color); } } } else if (feature is RectangleFeature) { RectangleFeature oP = (RectangleFeature)feature; oCC.Convert(oP.x, oP.y); Rectangle rect = new Rectangle((int)oCC.X - 2, (int)oCC.Y - 2, 4, 4); m_oRenderGDIplus.DrawRectangle(g, rect, (uint)0xff000000); } else if (feature is BitmapFeature) { BitmapFeature oB = feature as BitmapFeature; oCC.Convert(oB.X, oB.Y); int x = (int)oCC.X; int y = (int)oCC.Y; g.DrawImageUnscaled(oB.Bitmap, new Point(x - oB.Anchorx, y - oB.Anchory)); } else { throw new NotImplementedException(); } }
public override void FillEllipse(DRect rect, DColor color) { FillEllipse(rect.X, rect.Y, rect.Width, rect.Height, color, 1); }
internal static void CopyScaledAndTiledToAtlas(MaterialPropTexture source, MaterialPropTexturesSet sourceMaterial, ShaderTextureProperty shaderPropertyName, DRect srcSamplingRect, int targX, int targY, int targW, int targH, AtlasPadding padding, Color[][] atlasPixels, bool isNormalMap, TextureCombinePipelineData data, TextureCombineHandler combiner) { //HasFinished = false; Texture2D t = source.GetTexture2D(); Debug.Log(string.Format("CopyScaledAndTiledToAtlas: {0} inAtlasX={1} inAtlasY={2} inAtlasW={3} inAtlasH={4} paddX={5} paddY={6} srcSamplingRect={7}", t, targX, targY, targW, targH, padding.leftRight, padding.topBottom, srcSamplingRect)); float newWidth = targW; float newHeight = targH; float scx = (float)srcSamplingRect.width; float scy = (float)srcSamplingRect.height; float ox = (float)srcSamplingRect.x; float oy = (float)srcSamplingRect.y; int w = (int)newWidth; int h = (int)newHeight; if (data.considerNonTextureProperties) { t = combiner._createTextureCopy(shaderPropertyName.name, t); t = data.nonTexturePropertyBlender.TintTextureWithTextureCombiner(t, sourceMaterial, shaderPropertyName); } for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { float u = i / newWidth * scx + ox; float v = j / newHeight * scy + oy; atlasPixels[targY + j][targX + i] = t.GetPixelBilinear(u, v); } } //bleed the border colors into the padding for (int i = 0; i < w; i++) { for (int j = 1; j <= padding.topBottom; j++) { //top margin atlasPixels[(targY - j)][targX + i] = atlasPixels[(targY)][targX + i]; //bottom margin atlasPixels[(targY + h - 1 + j)][targX + i] = atlasPixels[(targY + h - 1)][targX + i]; } } for (int j = 0; j < h; j++) { for (int i = 1; i <= padding.leftRight; i++) { //left margin atlasPixels[(targY + j)][targX - i] = atlasPixels[(targY + j)][targX]; //right margin atlasPixels[(targY + j)][targX + w + i - 1] = atlasPixels[(targY + j)][targX + w - 1]; } } //corners for (int i = 1; i <= padding.leftRight; i++) { for (int j = 1; j <= padding.topBottom; j++) { atlasPixels[(targY - j)][targX - i] = atlasPixels[targY][targX]; atlasPixels[(targY + h - 1 + j)][targX - i] = atlasPixels[(targY + h - 1)][targX]; atlasPixels[(targY + h - 1 + j)][targX + w + i - 1] = atlasPixels[(targY + h - 1)][targX + w - 1]; atlasPixels[(targY - j)][targX + w + i - 1] = atlasPixels[targY][targX + w - 1]; } } }
public override void DrawRect(DRect rect, DColor color, double alpha, DStrokeStyle strokeStyle) { cr.SetSource(MakeColor(color, alpha)); cr.LineWidth = 1; CairoStrokeStyle(cr, strokeStyle, 1); cr.Rectangle(rect.X, rect.Y, rect.Width, rect.Height); cr.Stroke(); }
public override void DrawRect(DRect rect, DColor color, double alpha) { DrawRect(rect.X, rect.Y, rect.Width, rect.Height, color, alpha, 1); }
public override void DrawRect(DRect rect, DColor color) { DrawRect(rect.X, rect.Y, rect.Width, rect.Height, color, 1, 1); }
protected DRect GetRect(DGlyphPosition pos, DRect figureRect, double scale) { DPoint pt = GetXYPosition(pos, figureRect, scale); return new DRect(pt.X, pt.Y, Width * scale, Height * scale); }
public override void DrawBitmap(DBitmap bitmap, DRect rect) { DrawBitmap(bitmap, rect, 1); }
protected DPoint GetXYPosition(DGlyphPosition pos, DRect figureRect, double scale) { double x = 0, y = 0; switch (pos) { case DGlyphPosition.TopRight: x = figureRect.Right - Width * scale; y = figureRect.Top; break; case DGlyphPosition.BottomLeft: x = figureRect.Left; y = figureRect.Bottom - Height * scale; break; case DGlyphPosition.Center: x = figureRect.Center.X - Width / 2 * scale; y = figureRect.Center.Y - Height / 2 * scale; break; case DGlyphPosition.CenterStack: x = figureRect.Center.X - Width / 2 * scale; y = figureRect.Center.Y - Height / 2 * scale; double stackX = centerStackIndex * Width * scale; x += stackX; break; } return new DPoint(x, y); }
void hsm_MeasureRect(DEngine de, DRect rect) { if (MeasureRect != null) MeasureRect(this, rect); }
public override void FillEllipse(DRect rect, DColor color, double alpha) { FillEllipse(rect.X, rect.Y, rect.Width, rect.Height, color, alpha); }
public override void DrawBitmap(DBitmap bitmap, DRect rect, double alpha) { ImageSurface surf = (ImageSurface)bitmap.NativeBmp; cr.Save(); cr.Translate(rect.X, rect.Y); cr.Scale(rect.Width / surf.Width, rect.Height / surf.Height); cr.SetSource(surf, 0, 0); cr.PaintWithAlpha(alpha); cr.Restore(); }
public override void CreateAtlases( TextureCombinePipelineData data, TextureCombineHandler combiner, AtlasPackingResult packedAtlasRects, Texture2D[] atlases, EditorMethodsInterface textureEditorMethods) { Rect[] uvRects = packedAtlasRects.rects; int atlasSizeX = packedAtlasRects.atlasX; int atlasSizeY = packedAtlasRects.atlasY; Debug.Log("Generated atlas will be " + atlasSizeX + "x" + atlasSizeY); for (int propIdx = 0; propIdx < data.numAtlases; propIdx++) { Texture2D atlas = null; ShaderTextureProperty property = data.texPropertyNames[propIdx]; if (!TextureCombinePipeline.ShouldWeCreateAtlasForThisProperty(propIdx, data.considerNonTextureProperties, data.allTexturesAreNullAndSameColor)) { atlas = null; Debug.Log("=== Not creating atlas for " + property.name + " because textures are null and default value parameters are the same."); } else { Debug.Log("=== Creating atlas for " + property.name); GC.Collect(); CreateTemporaryTexturesForAtlas(data.distinctMaterialTextures, combiner, propIdx, data); //use a jagged array because it is much more efficient in memory Color[][] atlasPixels = new Color[atlasSizeY][]; for (int j = 0; j < atlasPixels.Length; j++) { atlasPixels[j] = new Color[atlasSizeX]; } bool isNormalMap = false; if (property.isNormalMap) { isNormalMap = true; } for (int texSetIdx = 0; texSetIdx < data.distinctMaterialTextures.Count; texSetIdx++) { MaterialPropTexturesSet texSet = data.distinctMaterialTextures[texSetIdx]; MaterialPropTexture matTex = texSet.ts[propIdx]; string s = "Creating Atlas '" + property.name + "' texture " + matTex.GetTexName(); Debug.Log(string.Format("Adding texture {0} to atlas {1} for texSet {2} srcMat {3}", matTex.GetTexName(), property.name, texSetIdx, texSet.matsAndGOs.mats[0].GetMaterialName())); Rect r = uvRects[texSetIdx]; Texture2D t = texSet.ts[propIdx].GetTexture2D(); int x = Mathf.RoundToInt(r.x * atlasSizeX); int y = Mathf.RoundToInt(r.y * atlasSizeY); int ww = Mathf.RoundToInt(r.width * atlasSizeX); int hh = Mathf.RoundToInt(r.height * atlasSizeY); if (ww == 0 || hh == 0) { Debug.LogError("Image in atlas has no height or width " + r); } if (textureEditorMethods != null) { textureEditorMethods.SetReadWriteFlag(t, true, true); } DRect samplingRect = texSet.ts[propIdx].GetEncapsulatingSamplingRect(); CopyScaledAndTiledToAtlas(texSet.ts[propIdx], texSet, property, samplingRect, x, y, ww, hh, packedAtlasRects.padding[texSetIdx], atlasPixels, isNormalMap, data, combiner); } atlas = new Texture2D(atlasSizeX, atlasSizeY, TextureFormat.ARGB32, true); for (int j = 0; j < atlasPixels.Length; j++) { atlas.SetPixels(0, j, atlasSizeX, 1, atlasPixels[j]); } atlas.Apply(); Debug.Log("Saving atlas " + property.name + " w=" + atlas.width + " h=" + atlas.height); } atlases[propIdx] = atlas; if (data.saveAtlasesAsAssets && textureEditorMethods != null) { textureEditorMethods.SaveAtlasToAssetDatabase(atlases[propIdx], data.texPropertyNames[propIdx], propIdx, data.ResultMaterial); } else { data.ResultMaterial.SetTexture(data.texPropertyNames[propIdx].name, atlases[propIdx]); } data.ResultMaterial.SetTextureOffset(data.texPropertyNames[propIdx].name, Vector2.zero); data.ResultMaterial.SetTextureScale(data.texPropertyNames[propIdx].name, Vector2.one); combiner._destroyTemporaryTextures(data.texPropertyNames[propIdx].name); } }
public override void MouseMove(object sender, MouseEventArgs e) { base.MouseMove(sender, e); // highlight polilines and points if (map.InsertionLayer == null) return; CoordSys layerCoordsys = map.InsertionLayer.LayerCoordSys; CoordConverter oCC = new CoordConverter(); oCC.Init(layerCoordsys, map.DisplayCoordSys); // this atPan converts DisplayCoordSys into Screen CoordSys[px] // DisplayCoordSys has Y axis up (unless its AT does not change it) // Screen Y axis is down AffineTransform atPan = new AffineTransform(); atPan.OffsetInPlace((double)map.MapOffsetX, (double)map.MapOffsetY); atPan.MultiplyInPlace(map.MapScale, -map.MapScale); // add screen scale and offset transformation oCC.atMaster = oCC.atMaster.Compose(atPan); int margin = 5; oCC.ConvertInverse(e.X, e.Y); DPoint pt_center = new DPoint(oCC.X, oCC.Y); oCC.ConvertInverse(e.X - margin, e.Y - margin); DPoint pt1 = new DPoint(oCC.X, oCC.Y); oCC.ConvertInverse(e.X + margin, e.Y + margin); DPoint pt2 = new DPoint(oCC.X, oCC.Y); // szukaj w tym miejscu feature //List<Feature> ftrs = map.InsertionLayer.Search(pt); // construct search rectangle (10px wide) DRect rect = new DRect(pt1.X, pt2.Y, pt2.X, pt1.Y); //map.InsertionLayer.SelectWithinRectangle(rect); }
/// <summary> /// Search for features that intersect or are contained in a given rectangle. /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> public List<Feature> searchAtPoint(DRect rect) { List<Feature> result = new List<Feature>(); for (int i = 0; i < m_oFeatures.Count; i++) { Feature feature = m_oFeatures[i]; if (feature.MBR.IntersectsWith(rect)) { // detailed collision test if (feature is SymbolFeature) result.Add(feature); if (feature is PolylineFeature) { //castToPolyline } } } return null; }
/// <summary> /// Checks if this rectangle intersects another rectangle /// </summary> /// <param name="Rect">The rectangle to check</param> /// <returns>Whether or not this rectangle intersects the other</returns> public bool Intersects(DRect Rect) { return (!( Bottom < Rect.Top || Top > Rect.Bottom || Right < Rect.Left || Left > Rect.Right )); }
void De_MeasureRect(DEngine de, DRect rect) { de.MeasureRect -= De_MeasureRect; if (ImportAnnotationsArea != null && rect.Width > 0 && rect.Height > 0) { // set haveImportedAnnotations HaveImportedAnnotations = true; // call the ImportAnnotationsArea event passing it the cropped bitmap ImportAnnotationsArea(annotationForm.CaptureImage(rect)); } // select the selection tool annotationForm.De.HsmState = DHsmState.Select; }
void De_MeasureRect(DEngine de, DRect rect) { de.MeasureRect -= De_MeasureRect; if (CaptureImage != null && rect.Width > 0 && rect.Height > 0) // call the CaptureImage event passing it the captured bitmap CaptureImage(annotationForm.CaptureImage(rect)); // close the annotation form CloseAnnotationForm(); }