private void UpdateCatesianGrid(IUpdateColorPalette grid, GridBlockProperty property) { double axisMin, axisMax, step; ColorIndicatorAxisAutomator.Automate(property.MinValue, property.MaxValue, out axisMin, out axisMax, out step); grid.MinColorCode = (float)axisMin; grid.MaxColorCode = (float)axisMax; grid.UpdateColor(property); this.UIColorPalette.SetCodedColor(axisMin, axisMax, step); }
private void UpdateCatesianGrid(CatesianGrid grid, GridBlockProperty property) { double axisMin, axisMax, step; ColorIndicatorAxisAutomator.Automate(property.MinValue, property.MaxValue, out axisMin, out axisMax, out step); grid.MinColorCode = (float)axisMin; grid.MaxColorCode = (float)axisMax; grid.UpdateColor(property); this.scientificCanvas.ColorPalette.SetCodedColor(axisMin, axisMax, step); }
private float[] GetTextureCoords(GridBlockProperty property) { int[] gridIndexes = property.Positions; float[] values = property.Values; int[] resultsVisibles = this.DataSource.ExpandVisibles(gridIndexes); int[] bindVisibles = this.DataSource.BindCellActive(this.DataSource.BindVisibles, resultsVisibles); int dimenSize = this.DataSource.DimenSize; float[] textures = this.DataSource.GetInvisibleTextureCoords(); float distance = Math.Abs(this.MaxColorCode - this.MinColorCode); for (int i = 0; i < gridIndexes.Length; i++) { int gridIndex = gridIndexes[i]; float value = values[i]; if (value < this.MinColorCode) { value = this.MinColorCode; bindVisibles[gridIndex] = 0; } if (value > this.MaxColorCode) { value = this.MaxColorCode; bindVisibles[gridIndex] = 0; } if (bindVisibles[gridIndex] > 0) { if (!(distance <= 0.0f)) { textures[gridIndex] = (value - this.MinColorCode) / distance; if (textures[gridIndex] < 0.5f) { textures[gridIndex] = 0.5f - (0.5f - textures[gridIndex]) * 0.99f; } else { textures[gridIndex] = (textures[gridIndex] - 0.5f) * 0.99f + 0.5f; } } else { //最小值最大值相等时,显示最小值的颜色 //textures[gridIndex] = 0.01f; textures[gridIndex] = 0.01f; } } } return(textures); }
private void InitAutoRange(GridBlockProperty gbp) { if (!this.UseAutoRange) { return; } double axisMin; double axisMax; double step; ColorMapAxisAutomation.Automate(gbp.MinValue, gbp.MaxValue, out axisMin, out axisMax, out step); this.Minimum = axisMin; this.Maximum = axisMax; this.Step = step; }
public GridBlockProperty Load(string fileName,GridDimens dimens) { StreamReader reader = new StreamReader(fileName); try{ String data = reader.ReadToEnd(); String[] strValues = data.Split(delemeters,StringSplitOptions.RemoveEmptyEntries); float[] values = new float[strValues.Length]; int[] gridIndexes = new int[strValues.Length]; for(int i=0; i<values.Length; i++){ gridIndexes[i]=i; values[i]= Convert.ToSingle(strValues[i],CultureInfo.InvariantCulture); } String name = System.IO.Path.GetFileName(fileName); GridBlockProperty gbp = new GridBlockProperty(name,dimens,gridIndexes,values); return gbp; }finally{ reader.Close(); } }
private List <RangeCounter> StatRangeCounters(GridBlockProperty gbp, double minValue, double maxValue, double step, bool useLog, double logBase) { List <RangeCounter> rangeCounters = CreateRangeCounters(minValue, maxValue, step, useLog, logBase); float[] values = gbp.Values; for (int i = 0; i < values.Length; i++) { double value = values[i]; foreach (RangeCounter r in rangeCounters) { if (r.IsInRange(value)) { r.Counter += 1; break; } } } return(rangeCounters); }
public GridBlockProperty Load(string fileName, GridDimens dimens) { StreamReader reader = new StreamReader(fileName); try{ String data = reader.ReadToEnd(); String[] strValues = data.Split(delemeters, StringSplitOptions.RemoveEmptyEntries); float[] values = new float[strValues.Length]; int[] gridIndexes = new int[strValues.Length]; for (int i = 0; i < values.Length; i++) { gridIndexes[i] = i; values[i] = Convert.ToSingle(strValues[i], CultureInfo.InvariantCulture); } String name = System.IO.Path.GetFileName(fileName); GridBlockProperty gbp = new GridBlockProperty(name, dimens, gridIndexes, values); return(gbp); }finally{ reader.Close(); } }
private void mniLoadECLGrid_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() != DialogResult.OK) { return; } //ModelContainer modelContainer = this.ModelContainer; string fileName = openFileDialog1.FileName; SimulationInputData inputData; try { inputData = this.LoadEclInputData(fileName); } catch (Exception err) { MessageBox.Show(String.Format("Load Error,{0}", err.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { List <GridBlockProperty> gridProperties = inputData.RootDataFile.GetGridProperties(); GridBlockProperty firstProperty = gridProperties[0]; double axisMin, axisMax, step; ColorIndicatorAxisAutomator.Automate(firstProperty.MinValue, firstProperty.MaxValue, out axisMin, out axisMax, out step); CatesianGrid grid = inputData.DumpCatesianGrid((float)axisMin, (float)axisMax); SceneObject gridObj = GetCatesianGridObj(grid, gridProperties, fileName); SceneObject[] wellObjects = GetWellObjects(inputData, grid, fileName); var list = new List <IModelSpace>(); list.Add(gridObj.Renderer); list.AddRange(from item in wellObjects select item.Renderer); BoundingBoxRenderer boxRenderer = list.GetBoundingBoxRenderer(); SceneObject mainObj = boxRenderer.WrapToSceneObject( string.Format("CatesianGrid: {0}", fileName), new ModelScaleScript()); mainObj.Children.Add(gridObj); mainObj.Children.AddRange(wellObjects); this.scientificCanvas.Scene.RootObject.Children.Add(mainObj); this.scientificCanvas.Scene.FirstCamera.ZoomCamera(boxRenderer.GetBoundingBox()); vec3 back = this.scientificCanvas.Scene.FirstCamera.GetBack(); this.scientificCanvas.Scene.FirstCamera.Target = -grid.DataSource.Position; this.scientificCanvas.Scene.FirstCamera.Position = this.scientificCanvas.Scene.FirstCamera.Target + back; this.scientificCanvas.ColorPalette.SetCodedColor(axisMin, axisMax, step); // update tree node. TreeNode rootNode = DumpTreeNode(this.scientificCanvas.Scene.RootObject); this.objectsTreeView.Nodes.Clear(); this.objectsTreeView.Nodes.Add(rootNode); this.objectsTreeView.ExpandAll(); // refresh objects state in scene. this.scientificCanvas.Scene.UpdateOnce(); // render scene to this canvas. this.scientificCanvas.Invalidate(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// Used in <see cref="DumpCatesianGridTreeNodeScript"/>. /// </summary> /// <param name="sceneObject"></param> /// <param name="property"></param> /// <param name="uiCodedColorBar"></param> public ScientificModelScript(SceneObject sceneObject, GridBlockProperty property, UIColorPaletteRenderer uiCodedColorBar) : base(sceneObject) { this.GridBlockProperty = property; this.UIColorPalette = uiCodedColorBar; }
public abstract void UpdateColor(GridBlockProperty property);
private float[] GetTextureCoords(GridBlockProperty property) { int[] gridIndexes = property.Positions; float[] values = property.Values; int[] resultsVisibles = this.DataSource.ExpandVisibles(gridIndexes); int[] bindVisibles = this.DataSource.BindCellActive(this.DataSource.BindVisibles, resultsVisibles); int dimenSize = this.DataSource.DimenSize; float[] textures = this.DataSource.GetInvisibleTextureCoords(); float distance = Math.Abs(this.MaxColorCode - this.MinColorCode); for (int i = 0; i < gridIndexes.Length; i++) { int gridIndex = gridIndexes[i]; float value = values[i]; if (value < this.MinColorCode) { value = this.MinColorCode; bindVisibles[gridIndex] = 0; } if (value > this.MaxColorCode) { value = this.MaxColorCode; bindVisibles[gridIndex] = 0; } if (bindVisibles[gridIndex] > 0) { if (!(distance <= 0.0f)) { textures[gridIndex] = (value - this.MinColorCode) / distance; if (textures[gridIndex] < 0.5f) { textures[gridIndex] = 0.5f - (0.5f - textures[gridIndex]) * 0.99f; } else { textures[gridIndex] = (textures[gridIndex] - 0.5f) * 0.99f + 0.5f; } } else { //最小值最大值相等时,显示最小值的颜色 //textures[gridIndex] = 0.01f; textures[gridIndex] = 0.01f; } } } return textures; }