private CWintabContext OpenSystemContext(bool ctrlSysCursor = true) { CWintabContext context = CWintabInfo.GetDefaultSystemContext(); if (context == null) { return(null); } // Set system cursor if caller wants it. if (ctrlSysCursor) { context.Options |= (uint)ECTXOptionValues.CXO_SYSTEM; } else { context.Options &= ~(uint)ECTXOptionValues.CXO_SYSTEM; } context.Name = "BgoonLibrary Tablet Context"; deviceID = CWintabInfo.GetDefaultDeviceIndex(); WintabAxis tabletX = CWintabInfo.GetDeviceAxis(deviceID, EAxisDimension.AXIS_X); WintabAxis tabletY = CWintabInfo.GetDeviceAxis(deviceID, EAxisDimension.AXIS_Y); NativeRect = new GRect(tabletX.axMin, tabletY.axMin, tabletX.axMax, tabletY.axMax); context.OutOrgX = context.OutOrgY = 0; context.OutExtX = (int)(context.OutExtX * OutputExtFactor); context.OutExtY = (int)(context.OutExtY * OutputExtFactor); //context.OutOrgX = context.OutOrgY = 0; //context.OutExtX = MaxPos.x; //context.OutExtY = MaxPos.y; //context.OutExtY *= -1; return(context.Open() ? context : null); }
public GPixmap GetPixelMap(GRect rect, int subsample, double gamma, PixelMap retval) { if (rect.Empty) { return((retval == null) ? (new PixelMap()) : retval.Init(0, 0, null)); } GPixmap bg = GetBgPixmap(rect, subsample, gamma, retval); if (ForegroundJB2Image != null) { if (bg == null) { bg = (retval == null) ? new PixelMap() : retval; bg.Init( rect.Height, rect.Width, GPixel.WhitePixel); } if (Stencil(bg, rect, subsample, gamma)) { retval = bg; } } else { retval = bg; } return(retval); }
public GBitmap GetBitmapList(GRect rect, int subsample, int align, List <int> components) { if (rect.Empty) { return(new Graphics.Bitmap()); } if (Info != null) { int width = Info.Width; int height = Info.Height; JB2Image fgJb2 = ForegroundJB2Image; if ( (width != 0) && (height != 0) && (fgJb2 != null) && (fgJb2.Width == width) && (fgJb2.Height == height)) { return(fgJb2.GetBitmap(rect, subsample, align, 0, components)); } } return(null); }
private CWintabContext OpenDigitalContext(bool ctrlSysCursor = true) { CWintabContext context = CWintabInfo.GetDefaultDigitizingContext(); if (context == null) { return(null); } context.Options |= (uint)ECTXOptionValues.CXO_MESSAGES; if (ctrlSysCursor) { context.Options |= (uint)ECTXOptionValues.CXO_SYSTEM; } context.Name = "BgoonLibrary Tablet Context"; deviceID = CWintabInfo.GetDefaultDeviceIndex(); WintabAxis tabletX = CWintabInfo.GetDeviceAxis(deviceID, EAxisDimension.AXIS_X); WintabAxis tabletY = CWintabInfo.GetDeviceAxis(deviceID, EAxisDimension.AXIS_Y); NativeRect = new GRect(tabletX.axMin, tabletX.axMax, tabletY.axMin, tabletY.axMax); context.OutOrgX = context.OutOrgY = 0; context.OutExtX = (int)(context.OutExtX * OutputExtFactor); context.OutExtY = (int)(context.OutExtY * OutputExtFactor); //context.OutExtY *= -1; return(context.Open() ? context : null); }
private void UpdateSometime() { if (!IsRunning) { return; } maxNormalPressure = CWintabInfo.GetMaxPressure(true); maxTangentPressure = CWintabInfo.GetMaxPressure(false); displaySize = new Vector2( SystemInformation.VirtualScreen.Width, SystemInformation.VirtualScreen.Height); if (context != null) { inputRect = new GRect(context.InOrgX, context.InOrgY, context.InExtX, context.InExtY); outputRect = new GRect(context.OutOrgX, context.OutOrgY, context.OutExtX, context.OutExtY); systemRect = new GRect(context.SysOrgX, context.SysOrgY, context.SysExtX, context.SysExtY); } }
public void Reduce(GRect source) { if (xMin < source.xMin) { xMin = source.xMin; } if (xMax > source.xMax) { xMax = source.xMax; } if (yMax > source.yMax) { yMax = source.yMax; } if (yMin < source.yMin) { yMin = source.yMin; } }
public void Extend(GRect source) { if (xMin > source.xMin) { xMin = source.xMin; } if (xMax < source.xMax) { xMax = source.xMax; } if (yMax < source.yMax) { yMax = source.yMax; } if (yMin > source.yMin) { yMin = source.yMin; } }
public Map GetMap(GRect segment, int subsample, GMap retval) { retval = IsColor ? (GMap)GetPixelMap( segment, subsample, 0.0D, (retval is GPixmap) ? (GPixmap)retval : null) : (GMap)GetBitmap( segment, subsample, 1, ((retval is GBitmap) ? (GBitmap)retval : null)); return(retval); }
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) { base.OnRenderSizeChanged(sizeInfo); { System.Windows.Size constraint = sizeInfo.NewSize; region = new GRect(-50, -50, (int)constraint.Width + 100, (int)constraint.Height + 100); TilesLayer.Width = sizeInfo.NewSize.Width; TilesLayer.Height = sizeInfo.NewSize.Height; QuadTree.Bounds = new Rect(sizeInfo.NewSize); } //var sizeInPx = Projection.GetTileMatrixSizePixel(ZoomStep); //TilesLayer.Width = sizeInPx.Width; //TilesLayer.Height = sizeInPx.Height; if (IsLoaded) { Refresh(); } }
public sealed override void Redraw() { if (!MatchUtils.IsEmpty(this.Target) && !MatchUtils.IsEmpty(this.Target.Netmap) && !MatchUtils.IsEmpty(this.Facade) && this.Target.Enable && this.Enable) { bool hide = this.Matte || !this.Viewble(this.Arise); { if (!MatchUtils.IsEmpty(this.Handle)) { if (!(this.Handle.Matte = hide)) { GRect v_rect = this.Handle as GRect; { v_rect.Mouse = this.Mouse; v_rect.Title = this.Title; v_rect.Alpha = this.Alpha; v_rect.Color = this.color; v_rect.Thick = this.thick; v_rect.Style = this.style; v_rect.Stuff = this.stuff; v_rect.Slope = this.slope; v_rect.Extra = this.Fit4e(this.extra); v_rect.Point = this.Fit4p(this.point); } } // 重绘图形 this.Facade.Dispatcher.BeginInvoke(new Action(() => { if (!MatchUtils.IsEmpty(this.Handle)) { this.Handle.Paint(); } })); } else { if (!((this.Handle = this.Target.Sketch.CreateRect()).Matte = hide)) { GRect v_rect = this.Handle as GRect; { v_rect.Mouse = this.Mouse; v_rect.Title = this.Title; v_rect.Alpha = this.Alpha; v_rect.Color = this.color; v_rect.Thick = this.thick; v_rect.Style = this.style; v_rect.Stuff = this.stuff; v_rect.Slope = this.slope; v_rect.Extra = this.Fit4e(this.extra); v_rect.Point = this.Fit4p(this.point); } // 绘制图形 this.Facade.Dispatcher.BeginInvoke(new Action(() => { if (!MatchUtils.IsEmpty(this.Handle)) { v_rect.Paint(); } })); } } } } }
/// <summary> /// Gets the background pixmap /// </summary> /// <param name="rect"></param> /// <param name="subSample"></param> /// <param name="gamma"></param> /// <param name="retval"></param> /// <returns></returns> public GPixmap GetBgPixmap(GRect rect, int subsample, double gamma, GPixmap retval) { GPixmap pm = null; int width = (Info == null) ? 0 : Info.Width; int height = (Info == null) ? 0 : Info.Height; if ((width <= 0) || (height <= 0) || (Info == null)) { return(null); } double gamma_correction = 1.0D; if ((gamma > 0.0D) && (Info != null)) { gamma_correction = gamma / Info.Gamma; } if (gamma_correction < 0.10000000000000001D) { gamma_correction = 0.10000000000000001D; } else if (gamma_correction > 10D) { gamma_correction = 10D; } IWPixelMap bgIWPixmap = BackgroundIWPixelMap; if (bgIWPixmap != null) { int w = bgIWPixmap.Width; int h = bgIWPixmap.Height; if ((w == 0) || (h == 0) || (width == 0) || (height == 0)) { return(null); } int red = ComputeRed(width, height, w, h); if ((red < 1) || (red > 12)) { return(null); } if (subsample == red) { pm = bgIWPixmap.GetPixmap(1, rect, retval); } else if (subsample == (2 * red)) { pm = bgIWPixmap.GetPixmap(2, rect, retval); } else if (subsample == (4 * red)) { pm = bgIWPixmap.GetPixmap(4, rect, retval); } else if (subsample == (8 * red)) { pm = bgIWPixmap.GetPixmap(8, rect, retval); } else if ((red * 4) == (subsample * 3)) { GRect xrect = new GRect(); xrect.Right = (int)Math.Floor(rect.Right * 4D / 3D); xrect.Bottom = (int)Math.Floor(rect.Bottom * 4D / 3D); xrect.Left = (int)Math.Ceiling((double)rect.Left * 4D / 3D); xrect.Top = (int)Math.Ceiling((double)rect.Top * 4D / 3D); GRect nrect = new GRect(0, 0, rect.Width, rect.Height); if (xrect.Left > w) { xrect.Left = w; } if (xrect.Top > h) { xrect.Top = h; } GPixmap ipm = bgIWPixmap.GetPixmap(1, xrect, null); pm = (retval != null) ? retval : new GPixmap(); pm.Downsample43(ipm, nrect); } else { int po2 = 16; while ((po2 > 1) && (subsample < (po2 * red))) { po2 >>= 1; } int inw = ((w + po2) - 1) / po2; int inh = ((h + po2) - 1) / po2; int outw = ((width + subsample) - 1) / subsample; int outh = ((height + subsample) - 1) / subsample; PixelMapScaler ps = new PixelMapScaler(inw, inh, outw, outh); ps.SetHorzRatio(red * po2, subsample); ps.SetVertRatio(red * po2, subsample); GRect xrect = ps.GetRequiredRect(rect); GPixmap ipm = bgIWPixmap.GetPixmap(po2, xrect, null); pm = (retval != null) ? retval : new GPixmap(); ps.Scale(xrect, ipm, rect, pm); } if ((pm != null) && (gamma_correction != 1.0D)) { pm.ApplyGammaCorrection(gamma_correction); for (int i = 0; i < 9; i++) { pm.ApplyGammaCorrection(gamma_correction); } } return(pm); } else { return(null); } }
private bool Stencil(PixelMap pm, Graphics.Rectangle rect, int subsample, double gamma) { if (Info == null) { return(false); } int width = Info.Width; int height = Info.Height; if ((width <= 0) || (height <= 0)) { return(false); } double gamma_correction = 1.0D; if (gamma > 0.0D) { gamma_correction = gamma / Info.Gamma; } if (gamma_correction < 0.10000000000000001D) { gamma_correction = 0.10000000000000001D; } else if (gamma_correction > 10D) { gamma_correction = 10D; } JB2Image fgJb2 = ForegroundJB2Image; if (fgJb2 != null) { ColorPalette fgPalette = ForegroundPalette; if (fgPalette != null) { List <int> components = new List <int>(); GBitmap bm = GetBitmapList(rect, subsample, 1, components); if (fgJb2.Blits.Count != fgPalette.BlitColors.Length) { pm.Attenuate(bm, 0, 0); return(false); } GPixmap colors = new GPixmap().Init( 1, fgPalette.PaletteColors.Length, null); GPixelReference color = colors.CreateGPixelReference(0); for (int i = 0; i < colors.ImageWidth; color.IncOffset()) { fgPalette.index_to_color(i++, color); } colors.ApplyGammaCorrection(gamma_correction); List <int> compset = new List <int>(); while (components.Count > 0) { int lastx = 0; int colorindex = fgPalette.BlitColors[((int)components[0])]; GRect comprect = new GRect(); compset = new List <int>(); for (int pos = 0; pos < components.Count;) { int blitno = ((int)components[pos]); JB2Blit pblit = fgJb2.Blits[blitno]; if (pblit.Left < lastx) { break; } lastx = pblit.Left; if (fgPalette.BlitColors[blitno] == colorindex) { JB2Shape pshape = fgJb2.GetShape(pblit.ShapeNumber); GRect xrect = new GRect( pblit.Left, pblit.Bottom, pshape.Bitmap.ImageWidth, pshape.Bitmap.ImageHeight); comprect.Recthull(comprect, xrect); compset.Add(components[pos]); components.Remove(pos); } else { pos++; } } comprect.XMin /= subsample; comprect.YMin /= subsample; comprect.XMax = ((comprect.XMax + subsample) - 1) / subsample; comprect.YMax = ((comprect.YMax + subsample) - 1) / subsample; comprect.Intersect(comprect, rect); if (comprect.Empty) { continue; } // bm = getBitmap(comprect, subsample, 1); bm = new GBitmap(); bm.Init( comprect.Height, comprect.Width, 0); bm.Grays = 1 + (subsample * subsample); int rxmin = comprect.XMin * subsample; int rymin = comprect.YMin * subsample; for (int pos = 0; pos < compset.Count; ++pos) { int blitno = ((int)compset[pos]); JB2Blit pblit = fgJb2.Blits[blitno]; JB2Shape pshape = fgJb2.GetShape(pblit.ShapeNumber); bm.Blit( pshape.Bitmap, pblit.Left - rxmin, pblit.Bottom - rymin, subsample); } color.SetOffset(colorindex); pm.Blit( bm, comprect.XMin - rect.XMin, comprect.YMin - rect.YMin, color); } return(true); } // Three layer model. IWPixelMap fgIWPixmap = ForegroundIWPixelMap; if (fgIWPixmap != null) { GBitmap bm = GetBitmap(rect, subsample, 1, null); if ((bm != null) && (pm != null)) { GPixmap fgPixmap = ForegroundPixelMap; int w = fgPixmap.ImageWidth; int h = fgPixmap.ImageHeight; int red = ComputeRed(width, height, w, h); // if((red < 1) || (red > 12)) if ((red < 1) || (red > 16)) { return(false); } // // int supersample = (red <= subsample) // ? 1 // : (red / subsample); // int wantedred = supersample * subsample; // // if(red == wantedred) // { // pm.stencil(bm, fgPixmap, supersample, rect, gamma_correction); // // return 1; // } pm.Stencil(bm, fgPixmap, red, subsample, rect, gamma_correction); return(true); } } } return(false); }
public GBitmap GetBitmap(GRect rect, int subsample, int align, GBitmap retval) { return(GetBitmapList(rect, 1, 1, null)); }
void GmapWidget_ButtonPressEvent(object o, ButtonPressEventArgs args) { if (args.Event.Button == 1) { bool markerIsSelect = false; if (args.Event.State.HasFlag(ModifierType.LockMask)) { foreach (var marker in addressesOverlay.Markers) { if (marker.IsMouseOver) { var markerUnderMouse = selectedMarkers .Where(m => m.Tag is Order) .FirstOrDefault(x => (x.Tag as Order).Id == (marker.Tag as Order)?.Id); if (markerUnderMouse == null) { selectedMarkers.Add(marker); logger.Debug("Маркер с заказом №{0} добавлен в список выделенных", (marker.Tag as Order)?.Id); } else { selectedMarkers.Remove(markerUnderMouse); logger.Debug("Маркер с заказом №{0} исключен из списка выделенных", (marker.Tag as Order)?.Id); } markerIsSelect = true; } } UpdateSelectedInfo(selectedMarkers); UpdateAddressesOnMap(); return; } if (!markerIsSelect) { selectedMarkers.Clear(); logger.Debug("Список выделенных маркеров очищен"); } UpdateAddressesOnMap(); if (poligonSelection) { GRect rect = new GRect((long)args.Event.X - 5, (long)args.Event.Y - 5, 10, 10); rect.OffsetNegative(gmapWidget.RenderOffset); dragSelectionPointId = brokenSelection.LocalPoints.FindIndex(rect.Contains); if (dragSelectionPointId != -1) { gmapWidget.DisableAltForSelection = false; return; } } if (args.Event.State.HasFlag(ModifierType.ControlMask)) { if (!poligonSelection) { poligonSelection = true; logger.Debug("Старт выделения через полигон."); var startPoint = gmapWidget.FromLocalToLatLng((int)args.Event.X, (int)args.Event.Y); brokenSelection = new GMapPolygon(new List <PointLatLng> { startPoint }, "Выделение"); gmapWidget.UpdatePolygonLocalPosition(brokenSelection); selectionOverlay.Polygons.Add(brokenSelection); } else { logger.Debug("Продолжили."); var newPoint = gmapWidget.FromLocalToLatLng((int)args.Event.X, (int)args.Event.Y); brokenSelection.Points.Add(newPoint); gmapWidget.UpdatePolygonLocalPosition(brokenSelection); } OnPoligonSelectionUpdated(); } else { logger.Debug("Закончили."); poligonSelection = false; UpdateSelectedInfo(new List <GMapMarker>()); selectionOverlay.Clear(); } } if (args.Event.Button == 3 && addressesOverlay.Markers.FirstOrDefault(m => m.IsMouseOver)?.Tag is Order order) { Menu popupMenu = new Menu(); var item = new MenuItem(string.Format("Открыть {0}", order)); item.Activated += (sender, e) => { var dlg = new OrderDlg(order) { HasChanges = false }; dlg.SetDlgToReadOnly(); Tab.TabParent.AddSlaveTab(Tab, dlg); }; popupMenu.Add(item); popupMenu.ShowAll(); popupMenu.Popup(); } }