private void UpdateItem(int index) { VariableItem variable = Variables[index]; Bitmap bmp = null; string type = null; if (variable.Name != null && variable.Name != "") { var expression = m_debugger.GetExpression(variable.Name); if (expression.IsValidValue) { // create bitmap bmp = new Bitmap(100, 100); Graphics graphics = Graphics.FromImage(bmp); graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; graphics.Clear(m_colors.ClearColor); if (!ExpressionDrawer.Draw(graphics, m_debugger, variable.Name, m_colors)) { bmp = null; } type = expression.Type; } } // set new row ResetAt(new VariableItem(variable.Name, bmp, type), index); }
private void UpdateItems(bool load, int modified_index = -1) { m_currentBox = null; bool imageEmpty = true; if (ExpressionLoader.Debugger.CurrentMode == dbgDebugMode.dbgBreakMode) { if (load) { ExpressionLoader.ReloadUserTypes(Util.GetDialogPage <GeneralOptionPage>()); } ExpressionDrawer.Settings referenceSettings = new ExpressionDrawer.Settings(); GeometryWatchOptionPage optionPage = Util.GetDialogPage <GeometryWatchOptionPage>(); if (optionPage != null) { referenceSettings.densify = optionPage.Densify; referenceSettings.showDir = optionPage.EnableDirections; referenceSettings.showLabels = optionPage.EnableLabels; referenceSettings.showDots = true; } // TODO: Names are redundant string[] names = new string[Geometries.Count]; ExpressionDrawer.Settings[] settings = new ExpressionDrawer.Settings[Geometries.Count]; bool tryDrawing = false; // update the list, gather names and settings for (int index = 0; index < Geometries.Count; ++index) { GeometryItem geometry = Geometries[index]; System.Windows.Media.Color color = geometry.Color; int colorId = geometry.ColorId; string type = null; bool updateRequred = modified_index < 0 || modified_index == index; if (updateRequred && load) { geometry.Drawable = null; geometry.Traits = null; } if (geometry.Name != null && geometry.Name != "") { var expressions = updateRequred ? ExpressionLoader.GetExpressions(geometry.Name) : null; if (expressions == null || ExpressionLoader.AllValidValues(expressions)) { if (expressions != null) { type = ExpressionLoader.TypeFromExpressions(expressions); } names[index] = geometry.Name; if (updateRequred && geometry.ColorId < 0) { colorId = m_intsPool.Pull(); color = Util.ConvertColor(m_colors[colorId]); } settings[index] = referenceSettings.CopyColored(color); tryDrawing = true; } } // set new row if (updateRequred) { ResetAt(new GeometryItem(geometry.Drawable, geometry.Traits, geometry.Name, type, colorId, m_colors), index); } } // draw variables if (tryDrawing) { int width = (int)System.Math.Round(image.ActualWidth); int height = (int)System.Math.Round(image.ActualHeight); if (width > 0 && height > 0) { Bitmap bmp = new Bitmap(width, height); Graphics graphics = Graphics.FromImage(bmp); graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; graphics.Clear(m_colors.ClearColor); try { ExpressionDrawer.IDrawable[] drawables = new ExpressionDrawer.IDrawable[names.Length]; Geometry.Traits[] traits = new Geometry.Traits[names.Length]; for (int i = 0; i < names.Length; ++i) { if (Geometries[i].Drawable == null && names[i] != null && names[i] != "") { try { // TODO: Unify the loading of empty geometries. // For empty linestring the coordinate system name is drawn // however for empty multilinestring it is not. The reason // is that in the latter case null drawable and traits are // returned becasue traits are loaded from an element // (linestring) but there are no elements since the // multi-geometry is empty. ExpressionDrawer.IDrawable d = null; Geometry.Traits t = null; ExpressionLoader.Load(names[i], ExpressionLoader.OnlyGeometriesOrGeometryContainer, out t, out d); if (t == null) // Traits has to be defined for Geometry { d = null; } Geometries[i].Drawable = d; Geometries[i].Traits = t; Geometries[i].Error = null; } catch (Exception e) { Geometries[i].Error = e.Message; } } drawables[i] = Geometries[i].Drawable; traits[i] = Geometries[i].Traits; } m_currentBox = ExpressionDrawer.DrawGeometries(graphics, drawables, traits, settings, m_colors, m_zoomBox); } catch (Exception e) { ExpressionDrawer.DrawErrorMessage(graphics, e.Message); } image.Source = Util.BitmapToBitmapImage(bmp); imageEmpty = false; } } } if (imageEmpty) { image.Source = Util.BitmapToBitmapImage(m_emptyBitmap); } imageGrid.ContextMenu = new ContextMenu(); MenuItem mi = new MenuItem(); mi.Header = "Copy"; mi.Click += MenuItem_Copy; if (imageEmpty) { mi.IsEnabled = false; } imageGrid.ContextMenu.Items.Add(mi); imageGrid.ContextMenu.Items.Add(new Separator()); MenuItem mi2 = new MenuItem(); mi2.Header = "Reset View"; mi2.Click += MenuItem_ResetZoom; if (imageEmpty) { mi2.IsEnabled = false; } imageGrid.ContextMenu.Items.Add(mi2); }
private void UpdateItems(bool load, int modified_index = -1) { m_currentBox = null; bool imageEmpty = true; if (ExpressionLoader.Debugger.CurrentMode == dbgDebugMode.dbgBreakMode) { if (load) { ExpressionLoader.ReloadUserTypes(Util.GetDialogPage <GeneralOptionPage>()); } ExpressionDrawer.Settings referenceSettings = new ExpressionDrawer.Settings(); PlotWatchOptionPage optionPage = Util.GetDialogPage <PlotWatchOptionPage>(); if (optionPage != null) { if (optionPage.ValuePlot_EnableBars || optionPage.ValuePlot_EnableLines || optionPage.ValuePlot_EnablePoints) { referenceSettings.valuePlot_enableBars = optionPage.ValuePlot_EnableBars; referenceSettings.valuePlot_enableLines = optionPage.ValuePlot_EnableLines; referenceSettings.valuePlot_enablePoints = optionPage.ValuePlot_EnablePoints; } if (optionPage.PointPlot_EnableLines || optionPage.PointPlot_EnablePoints) { referenceSettings.pointPlot_enableLines = optionPage.PointPlot_EnableLines; referenceSettings.pointPlot_enablePoints = optionPage.PointPlot_EnablePoints; } } // TODO: Names are redundant string[] names = new string[Plots.Count]; ExpressionDrawer.Settings[] settings = new ExpressionDrawer.Settings[Plots.Count]; bool tryDrawing = false; // update the list, gather names and settings for (int index = 0; index < Plots.Count; ++index) { PlotItem geometry = Plots[index]; System.Windows.Media.Color color = geometry.Color; int colorId = geometry.ColorId; string type = null; bool updateRequred = modified_index < 0 || modified_index == index; if (updateRequred && load) { geometry.Drawable = null; geometry.Traits = null; } if (geometry.Name != null && geometry.Name != "") { var expressions = updateRequred ? ExpressionLoader.GetExpressions(geometry.Name) : null; if (expressions == null || ExpressionLoader.AllValidValues(expressions)) { if (expressions != null) { type = ExpressionLoader.TypeFromExpressions(expressions); } names[index] = geometry.Name; if (updateRequred && geometry.ColorId < 0) { colorId = m_intsPool.Pull(); color = Util.ConvertColor(m_colors[colorId]); } settings[index] = referenceSettings.CopyColored(color); tryDrawing = true; } } // set new row if (updateRequred) { ResetAt(new PlotItem(geometry.Drawable, geometry.Traits, geometry.Name, type, colorId, m_colors), index); } } // draw variables if (tryDrawing) { int width = (int)System.Math.Round(image.ActualWidth); int height = (int)System.Math.Round(image.ActualHeight); if (width > 0 && height > 0) { Bitmap bmp = new Bitmap(width, height); Graphics graphics = Graphics.FromImage(bmp); graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; graphics.Clear(m_colors.ClearColor); try { ExpressionDrawer.IDrawable[] drawables = new ExpressionDrawer.IDrawable[names.Length]; Geometry.Traits[] traits = new Geometry.Traits[names.Length]; for (int i = 0; i < names.Length; ++i) { if (Plots[i].Drawable == null && names[i] != null && names[i] != "") { ExpressionDrawer.IDrawable d = null; Geometry.Traits t = null; ExpressionLoader.Load(names[i], ExpressionLoader.OnlyMultiPoints, out t, out d); if (d != null) { if (t != null) { t = new Geometry.Traits(t.Dimension); // force cartesian } d = new ExpressionDrawer.PointsContainer(d as ExpressionDrawer.MultiPoint); } else { ExpressionLoader.Load(names[i], ExpressionLoader.OnlyContainers, out t, out d); } Plots[i].Drawable = d; Plots[i].Traits = t; } drawables[i] = Plots[i].Drawable; traits[i] = Plots[i].Traits; } m_currentBox = ExpressionDrawer.DrawPlots(graphics, drawables, traits, settings, m_colors, m_zoomBox); } catch (Exception e) { ExpressionDrawer.DrawErrorMessage(graphics, e.Message); } image.Source = Util.BitmapToBitmapImage(bmp); imageEmpty = false; } } } if (imageEmpty) { image.Source = Util.BitmapToBitmapImage(m_emptyBitmap); } imageGrid.ContextMenu = new ContextMenu(); MenuItem mi = new MenuItem(); mi.Header = "Copy"; mi.Click += MenuItem_Copy; if (imageEmpty) { mi.IsEnabled = false; } imageGrid.ContextMenu.Items.Add(mi); imageGrid.ContextMenu.Items.Add(new Separator()); MenuItem mi2 = new MenuItem(); mi2.Header = "Reset View"; mi2.Click += MenuItem_ResetZoom; if (imageEmpty) { mi2.IsEnabled = false; } imageGrid.ContextMenu.Items.Add(mi2); }
private void UpdateItem(bool load, int index) { GraphicalItem variable = Variables[index]; Bitmap bmp = null; string type = null; if (ExpressionLoader.Debugger.CurrentMode == dbgDebugMode.dbgBreakMode) { // Empty color - use default ExpressionDrawer.Settings settings = new ExpressionDrawer.Settings(); settings.densify = true; settings.showDir = false; settings.showLabels = false; settings.showDots = false; // Other settings int imageWidth = 100; int imageHeight = 100; bool displayMultiPointsAsPlots = false; // Load settings from option page GraphicalWatchOptionPage optionPage = Util.GetDialogPage <GraphicalWatchOptionPage>(); if (optionPage != null) { if (optionPage.ValuePlot_EnableBars || optionPage.ValuePlot_EnableLines || optionPage.ValuePlot_EnablePoints) { settings.valuePlot_enableBars = optionPage.ValuePlot_EnableBars; settings.valuePlot_enableLines = optionPage.ValuePlot_EnableLines; settings.valuePlot_enablePoints = optionPage.ValuePlot_EnablePoints; } if (optionPage.PointPlot_EnableLines || optionPage.PointPlot_EnablePoints) { settings.pointPlot_enableLines = optionPage.PointPlot_EnableLines; settings.pointPlot_enablePoints = optionPage.PointPlot_EnablePoints; } settings.densify = optionPage.Densify; settings.showDir = optionPage.EnableDirections; settings.showLabels = optionPage.EnableLabels; settings.showDots = false; imageHeight = Math.Max(optionPage.ImageHeight, 20); imageWidth = Math.Max(optionPage.ImageWidth, 20); displayMultiPointsAsPlots = optionPage.MultiPointDisplayMode == GraphicalWatchOptionPage.MultiPointDisplayModeValue.PointPlot; } (dataGrid.Columns[1] as DataGridTemplateColumn).Width = imageWidth + 1; dataGrid.RowHeight = imageHeight + 1; if (load) { variable.Drawable = null; variable.Traits = null; } if (variable.Name != null && variable.Name != "") { var expression = ExpressionLoader.Debugger.GetExpression(variable.Name); if (expression.IsValidValue) { // create bitmap bmp = new Bitmap(imageWidth, imageHeight); Graphics graphics = Graphics.FromImage(bmp); graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; graphics.Clear(m_colors.ClearColor); try { if (variable.Drawable == null) { Geometry.Traits traits = null; ExpressionDrawer.IDrawable drawable = null; ExpressionLoader.Load(variable.Name, out traits, out drawable); if (drawable != null && displayMultiPointsAsPlots && drawable is ExpressionDrawer.MultiPoint) { drawable = new ExpressionDrawer.PointsContainer(drawable as ExpressionDrawer.MultiPoint); } variable.Drawable = drawable; variable.Traits = traits; } else { if (displayMultiPointsAsPlots && variable.Drawable is ExpressionDrawer.MultiPoint) { variable.Drawable = new ExpressionDrawer.PointsContainer(variable.Drawable as ExpressionDrawer.MultiPoint); } else if (!displayMultiPointsAsPlots && variable.Drawable is ExpressionDrawer.PointsContainer) { variable.Drawable = (variable.Drawable as ExpressionDrawer.PointsContainer).MultiPoint; } } if (!ExpressionDrawer.Draw(graphics, variable.Drawable, variable.Traits, settings, m_colors)) { bmp = null; } } catch (Exception) { bmp = null; } type = expression.Type; } } } // set new row ResetAt(new GraphicalItem(variable.Drawable, variable.Traits, variable.Name, bmp, type), index); }
public void DrawPoint(Geometry.Box box, Graphics graphics, Settings settings, Geometry.Traits traits) { ExpressionDrawer.DrawPoint(point, box, graphics, settings, traits); }
private void UpdateItem(bool load, int index) { GraphicalItem variable = Variables[index]; if (ExpressionLoader.IsBreakMode) { if (load) { ExpressionLoader.ReloadUserTypes(Util.GetDialogPage <GeneralOptionPage>()); } // Load settings from option page ExpressionDrawer.Settings settings = GetOptions(); (dataGrid.Columns[1] as DataGridTemplateColumn).Width = settings.imageWidth + 1; dataGrid.RowHeight = settings.imageHeight + 1; if (load) { variable.Drawable = null; variable.Traits = null; variable.Bmp = null; variable.Type = null; variable.Error = null; } if (variable.Name != null && variable.Name != "") { var expressions = ExpressionLoader.GetExpressions(variable.Name); if (ExpressionLoader.AllValidValues(expressions)) { // create bitmap variable.Bmp = new Bitmap(settings.imageWidth, settings.imageHeight); Graphics graphics = Graphics.FromImage(variable.Bmp); graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; graphics.Clear(Util.Colors.ClearColor); try { if (variable.Drawable == null) { Geometry.Traits traits = null; ExpressionDrawer.IDrawable drawable = null; ExpressionLoader.Load(variable.Name, out traits, out drawable); if (drawable != null && settings.displayMultiPointsAsPlots && drawable is ExpressionDrawer.MultiPoint) { drawable = new ExpressionDrawer.PointsContainer(drawable as ExpressionDrawer.MultiPoint); } variable.Drawable = drawable; variable.Traits = traits; } else { if (settings.displayMultiPointsAsPlots && variable.Drawable is ExpressionDrawer.MultiPoint) { variable.Drawable = new ExpressionDrawer.PointsContainer(variable.Drawable as ExpressionDrawer.MultiPoint); } else if (!settings.displayMultiPointsAsPlots && variable.Drawable is ExpressionDrawer.PointsContainer) { variable.Drawable = (variable.Drawable as ExpressionDrawer.PointsContainer).MultiPoint; } } if (!ExpressionDrawer.Draw(graphics, variable.Drawable, variable.Traits, settings, Util.Colors)) { variable.Bmp = null; } variable.Error = null; } catch (Exception e) { variable.Bmp = null; variable.Error = e.Message; } variable.Type = ExpressionLoader.TypeFromExpressions(expressions); } } } // set new row ResetAt(variable.ShallowCopy(), index); }
private void UpdateItems(int modified_index = -1) { bool imageEmpty = true; if (m_debugger.CurrentMode == dbgDebugMode.dbgBreakMode) { string[] names = new string[Geometries.Count]; ExpressionDrawer.Settings[] settings = new ExpressionDrawer.Settings[Geometries.Count]; bool tryDrawing = false; // update the list, gather names and settings for (int index = 0; index < Geometries.Count; ++index) { GeometryItem geometry = Geometries[index]; System.Windows.Media.Color color = geometry.Color; int colorId = geometry.ColorId; string type = null; bool updateRequred = modified_index < 0 || modified_index == index; if (geometry.Name != null && geometry.Name != "") { var expression = updateRequred ? m_debugger.GetExpression(geometry.Name) : null; if (expression == null || expression.IsValidValue) { if (expression != null) { type = expression.Type; } names[index] = geometry.Name; if (updateRequred && geometry.ColorId < 0) { colorId = m_intsPool.Pull(); color = Util.ConvertColor(m_colors[colorId]); } settings[index] = new ExpressionDrawer.Settings(Util.ConvertColor(color), true, true); tryDrawing = true; } } // set new row if (updateRequred) { ResetAt(new GeometryItem(geometry.Name, type, colorId, m_colors), index); } } // draw variables if (tryDrawing) { int width = (int)System.Math.Round(image.ActualWidth); int height = (int)System.Math.Round(image.ActualHeight); if (width > 0 && height > 0) { Bitmap bmp = new Bitmap(width, height); Graphics graphics = Graphics.FromImage(bmp); graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; graphics.Clear(m_colors.ClearColor); ExpressionDrawer.DrawGeometries(graphics, m_debugger, names, settings, m_colors); image.Source = Util.BitmapToBitmapImage(bmp); imageEmpty = false; } } } if (imageEmpty) { image.Source = Util.BitmapToBitmapImage(m_emptyBitmap); } image.ContextMenu = new ContextMenu(); MenuItem mi = new MenuItem(); mi.Header = "Copy"; mi.Click += MenuItem_Copy; if (imageEmpty) { mi.IsEnabled = false; } image.ContextMenu.Items.Add(mi); }