/// <summary> /// constructor for loading a complete expansion krystal from a file /// </summary> /// <param name="filepath"></param> public ExpansionKrystal(string filepath) : base(filepath) { string expanderFilename = ""; using (XmlReader r = XmlReader.Create(filepath)) { K.ReadToXmlElementTag(r, "expansion"); // check that this is an expansion (the other checks have been done in base() for (int attr = 0; attr < r.AttributeCount; attr++) { r.MoveToAttribute(attr); switch (r.Name) { case "density": this._densityInputFilename = r.Value; break; case "inputPoints": this._pointsInputFilename = r.Value; break; case "expander": expanderFilename = r.Value; break; } } } string densityInputFilepath = K.KrystalsFolder + @"\" + _densityInputFilename; string pointsInputFilepath = K.KrystalsFolder + @"\" + _pointsInputFilename; string expanderFilepath = K.ExpansionOperatorsFolder + @"\" + expanderFilename; _densityInputKrystal = new DensityInputKrystal(densityInputFilepath); _pointsInputKrystal = new PointsInputKrystal(pointsInputFilepath); Expander = new Expander(expanderFilepath, _densityInputKrystal); }
/// <summary> /// constructor for loading a complete, shaped expansion krystal from a file /// </summary> /// <param name="filepath"></param> public ShapedExpansionKrystal(string filepath) : base(filepath) { string expanderFilename = ""; using (XmlReader r = XmlReader.Create(filepath)) { K.ReadToXmlElementTag(r, "expansion"); // check that this is an expansion (the other checks have been done in base() for (int attr = 0; attr < 5; attr++) { r.MoveToAttribute(attr); switch (r.Name) { case "density": this.DensityInputFilename = r.Value; break; case "inputPoints": this.PointsInputFilename = r.Value; break; case "axis": this._axisInputFilename = r.Value; break; case "contour": this._contourInputFilename = r.Value; break; case "expander": expanderFilename = r.Value; break; } } } string densityInputFilepath = K.KrystalsFolder + @"\" + DensityInputFilename; string pointsInputFilepath = K.KrystalsFolder + @"\" + PointsInputFilename; string axisInputFilepath = K.KrystalsFolder + @"\" + _axisInputFilename; string contourInputFilepath = K.KrystalsFolder + @"\" + _contourInputFilename; string expanderFilepath = K.ExpansionOperatorsFolder + @"\" + expanderFilename; DensityInputKrystal = new DensityInputKrystal(densityInputFilepath); PointsInputKrystal = new PointsInputKrystal(pointsInputFilepath); AxisInputKrystal = new AxisInputKrystal(axisInputFilepath); ContourInputKrystal = new ContourInputKrystal(contourInputFilepath); Expander = new Expander(expanderFilepath, DensityInputKrystal); }
public override List <StrandNode> StrandNodeList() { DensityInputKrystal dKrystal = this.DensityInputKrystal; PointsInputKrystal pKrystal = this.PointsInputKrystal; if (dKrystal.Level < pKrystal.Level) { string msg = "Error: The level of the density input krystal must be\n" + "greater than or equal to the level of any other input krystals."; throw new ApplicationException(msg); } int[] alignedInputPointValues = pKrystal.AlignedValues(dKrystal); if (dKrystal.NumValues != alignedInputPointValues.Length) { string msg = "Error: All the input krystals must belong to the same density family.\n"; throw new ApplicationException(msg); } List <LeveledValue> leveledValues = new List <LeveledValue>(); foreach (LeveledValue leveledValue in dKrystal.LeveledValues) { leveledValues.Add(leveledValue); } // construct the list of StrandNodes List <StrandNode> strandNodeList = new List <StrandNode>(); int momentIndex = 0; foreach (LeveledValue leveledValue in leveledValues) { int level = leveledValue.level; int mVal = leveledValue.value; if (mVal == 0 || alignedInputPointValues[momentIndex] == 0) { string msg = "Error: An input krystal contained a value of zero."; throw new ApplicationException(msg); } StrandNode sn = new StrandNode(momentIndex + 1, level, mVal, alignedInputPointValues[momentIndex]); strandNodeList.Add(sn); momentIndex++; } return(strandNodeList); }
/// <summary> /// Constructor used when the density and points input krystals, and the Expander are already available. /// Expand() is called in this constructor to create the strands. /// </summary> /// <param name="densityInputFilepath">The file path to the density input</param> /// <param name="inputValuesFilepath">The file path to the input values</param> /// <param name="expander">The expansion field consisting of input and output gametes</param> public ExpansionKrystalBase(DensityInputKrystal densityInputKrystal, PointsInputKrystal pointsInputKrystal, Expander expander) : base() { _name = K.UntitledKrystalName; _densityInputKrystal = densityInputKrystal; _pointsInputKrystal = pointsInputKrystal; _expander = expander; if (_densityInputKrystal != null && _pointsInputKrystal != null) { this._level = (_densityInputKrystal.Level > _pointsInputKrystal.Level) ? _densityInputKrystal.Level : _pointsInputKrystal.Level; this._level++; } Expand(); }
/// <summary> /// Constructor used when beginning to edit a new krystal (which has no strands yet). /// </summary> /// <param name="densityInputFilepath">The file path to the density input</param> /// <param name="inputValuesFilepath">The file path to the input values</param> /// <param name="expanderFilepath">The file path to the expander (may be null or empty)</param> public ExpansionKrystalBase(string densityInputFilepath, string pointsInputFilepath, string expanderFilepath) : base() { _name = K.UntitledKrystalName; if (String.IsNullOrEmpty(densityInputFilepath)) { _densityInputKrystal = null; } else { _densityInputFilename = Path.GetFileName(densityInputFilepath); _densityInputKrystal = new DensityInputKrystal(densityInputFilepath); } if (String.IsNullOrEmpty(pointsInputFilepath)) { _pointsInputKrystal = null; } else { _pointsInputFilename = Path.GetFileName(pointsInputFilepath); _pointsInputKrystal = new PointsInputKrystal(pointsInputFilepath); } if (String.IsNullOrEmpty(expanderFilepath)) { _expander = new Expander(); } else { _expander = new Expander(expanderFilepath, _densityInputKrystal); } if (_densityInputKrystal != null && _pointsInputKrystal != null) { this._level = _densityInputKrystal.Level > _pointsInputKrystal.Level ? _densityInputKrystal.Level : _pointsInputKrystal.Level; this._level++; } }
/// <summary> /// constructor for loading a complete, shaped expansion krystal from a file /// </summary> /// <param name="filepath"></param> public ShapedExpansionKrystal(string filepath) : base(filepath) { string expanderFilename = ""; using(XmlReader r = XmlReader.Create(filepath)) { K.ReadToXmlElementTag(r, "expansion"); // check that this is an expansion (the other checks have been done in base() for(int attr = 0 ; attr < 5 ; attr++) { r.MoveToAttribute(attr); switch(r.Name) { case "density": this.DensityInputFilename = r.Value; break; case "inputPoints": this.PointsInputFilename = r.Value; break; case "axis": this._axisInputFilename = r.Value; break; case "contour": this._contourInputFilename = r.Value; break; case "expander": expanderFilename = r.Value; break; } } } string densityInputFilepath = K.KrystalsFolder + @"\" + DensityInputFilename; string pointsInputFilepath = K.KrystalsFolder + @"\" + PointsInputFilename; string axisInputFilepath = K.KrystalsFolder + @"\" + _axisInputFilename; string contourInputFilepath = K.KrystalsFolder + @"\" + _contourInputFilename; string expanderFilepath = K.ExpansionOperatorsFolder + @"\" + expanderFilename; DensityInputKrystal = new DensityInputKrystal(densityInputFilepath); PointsInputKrystal = new PointsInputKrystal(pointsInputFilepath); AxisInputKrystal = new AxisInputKrystal(axisInputFilepath); ContourInputKrystal = new ContourInputKrystal(contourInputFilepath); Expander = new Expander(expanderFilepath, DensityInputKrystal); }
/// <summary> /// Constructor used when the density and points input krystals, and the Expander are already available. /// Expand() is called in this constructor to create the strands. /// </summary> /// <param name="densityInputFilepath">The file path to the density input</param> /// <param name="inputValuesFilepath">The file path to the input values</param> /// <param name="expander">The expansion field consisting of input and output gametes</param> public ExpansionKrystalBase(DensityInputKrystal densityInputKrystal, PointsInputKrystal pointsInputKrystal, Expander expander) : base() { _name = K.UntitledKrystalName; _densityInputKrystal = densityInputKrystal; _pointsInputKrystal = pointsInputKrystal; _expander = expander; if(_densityInputKrystal != null && _pointsInputKrystal != null) { this._level = (_densityInputKrystal.Level > _pointsInputKrystal.Level) ? _densityInputKrystal.Level : _pointsInputKrystal.Level; this._level++; } Expand(); }
/// <summary> /// Constructor used when beginning to edit a new krystal (which has no strands yet). /// </summary> /// <param name="densityInputFilepath">The file path to the density input</param> /// <param name="inputValuesFilepath">The file path to the input values</param> /// <param name="expanderFilepath">The file path to the expander (may be null or empty)</param> public ExpansionKrystalBase(string densityInputFilepath, string pointsInputFilepath, string expanderFilepath) : base() { _name = K.UntitledKrystalName; if(String.IsNullOrEmpty(densityInputFilepath)) _densityInputKrystal = null; else { _densityInputFilename = Path.GetFileName(densityInputFilepath); _densityInputKrystal = new DensityInputKrystal(densityInputFilepath); } if(String.IsNullOrEmpty(pointsInputFilepath)) _pointsInputKrystal = null; else { _pointsInputFilename = Path.GetFileName(pointsInputFilepath); _pointsInputKrystal = new PointsInputKrystal(pointsInputFilepath); } if(String.IsNullOrEmpty(expanderFilepath)) _expander = new Expander(); else _expander = new Expander(expanderFilepath, _densityInputKrystal); if(_densityInputKrystal != null && _pointsInputKrystal != null) { this._level = _densityInputKrystal.Level > _pointsInputKrystal.Level ? _densityInputKrystal.Level : _pointsInputKrystal.Level; this._level++; } }
/// <summary> /// Constructor used when the density and points input krystals, and the Expander are already available. /// Expand() is called in this constructor to create the strands. /// </summary> /// <param name="densityInputFilepath">The file path to the density input</param> /// <param name="inputValuesFilepath">The file path to the input values</param> /// <param name="expander">The expansion field consisting of input and output gametes</param> public ExpansionKrystal(DensityInputKrystal densityInputKrystal, PointsInputKrystal pointsInputKrystal, Expander expander) : base(densityInputKrystal, pointsInputKrystal, expander) { }
/// <summary> /// constructor for loading a complete expansion krystal from a file /// </summary> /// <param name="filepath"></param> public ExpansionKrystal(string filepath) : base(filepath) { string expanderFilename = ""; using(XmlReader r = XmlReader.Create(filepath)) { K.ReadToXmlElementTag(r, "expansion"); // check that this is an expansion (the other checks have been done in base() for(int attr = 0 ; attr < r.AttributeCount ; attr++) { r.MoveToAttribute(attr); switch(r.Name) { case "density": this._densityInputFilename = r.Value; break; case "inputPoints": this._pointsInputFilename = r.Value; break; case "expander": expanderFilename = r.Value; break; } } } string densityInputFilepath = K.KrystalsFolder + @"\" + _densityInputFilename; string pointsInputFilepath = K.KrystalsFolder + @"\" + _pointsInputFilename; string expanderFilepath = K.ExpansionOperatorsFolder + @"\" + expanderFilename; _densityInputKrystal = new DensityInputKrystal(densityInputFilepath); _pointsInputKrystal = new PointsInputKrystal(pointsInputFilepath); Expander = new Expander(expanderFilepath, _densityInputKrystal); }
public override List <StrandNode> StrandNodeList() { DensityInputKrystal dKrystal = this.DensityInputKrystal; PointsInputKrystal pKrystal = this.PointsInputKrystal; AxisInputKrystal aKrystal = this.AxisInputKrystal; ContourInputKrystal cKrystal = this.ContourInputKrystal; if (aKrystal == null || cKrystal == null) { string msg = "Error: Both the axis and contour inputs must be set."; throw new ApplicationException(msg); } if (dKrystal.Level < pKrystal.Level || (aKrystal != null && dKrystal.Level < aKrystal.Level) || (cKrystal != null && dKrystal.Level < cKrystal.Level)) { string msg = "Error: The level of the density input krystal must be\n" + "greater than or equal to the level of all the other input krystals."; throw new ApplicationException(msg); } int[] alignedInputPointValues = pKrystal.AlignedValues(dKrystal); int[] alignedInputAxisValues = { }; if (aKrystal != null) { alignedInputAxisValues = aKrystal.AlignedValues(dKrystal); } int[] alignedInputContourValues = { }; if (cKrystal != null) { alignedInputContourValues = cKrystal.AlignedValues(dKrystal); } if (dKrystal.NumValues != alignedInputPointValues.Length || (aKrystal != null && dKrystal.NumValues != alignedInputAxisValues.Length) || (cKrystal != null && dKrystal.NumValues != alignedInputContourValues.Length)) { string msg = "Error: All the input krystals must belong to the same density family.\n"; throw new ApplicationException(msg); } List <LeveledValue> leveledValues = new List <LeveledValue>(); foreach (LeveledValue leveledValue in dKrystal.LeveledValues) { leveledValues.Add(leveledValue); } // construct the list of StrandNodes List <StrandNode> strandNodeList = new List <StrandNode>(); int momentIndex = 0; foreach (LeveledValue leveledValue in leveledValues) { int level = leveledValue.level; int mVal = leveledValue.value; if (mVal == 0 || alignedInputPointValues[momentIndex] == 0 || alignedInputAxisValues[momentIndex] == 0 || alignedInputContourValues[momentIndex] == 0) { string msg = "Error: An input krystal contained a value of zero."; throw new ApplicationException(msg); } ContouredStrandNode csn = new ContouredStrandNode(momentIndex + 1, level, mVal, alignedInputPointValues[momentIndex], alignedInputAxisValues[momentIndex], alignedInputContourValues[momentIndex]); strandNodeList.Add(csn); momentIndex++; } return(strandNodeList); }
/// <summary> /// Constructor used when the density and points input krystals, and the Expander are already available. /// Expand() is called in this constructor to create the strands. /// </summary> /// <param name="densityInputFilepath">The file path to the density input</param> /// <param name="inputValuesFilepath">The file path to the input values</param> /// <param name="expander">The expansion field consisting of input and output gametes</param> public ExpansionKrystal(DensityInputKrystal densityInputKrystal, PointsInputKrystal pointsInputKrystal, Expander expander) : base(densityInputKrystal, pointsInputKrystal, expander) { }
/// <summary> /// Draws the current state of the output Krystal. /// If this._pointMarkers is not empty, this function draws in "time-slice" mode, /// otherwise it draws in normal editing mode, drawing a _singlePointMarker if ther /// is one. /// </summary> /// <param name="g">The field panel's current Graphics property</param> /// <param name="outputKrystal">The outputKrystal in the fieldEditor's database</param> /// <param name="scalePercent">The current value of the ZoomComboBox</param> public void Draw(Graphics g, ExpansionKrystal outputKrystal, float scalePercent) { _g = g; _g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; _g.PageUnit = GraphicsUnit.Pixel; _labelsHeight = (float)_g.MeasureString("1", _labelsFont).Height * 0.9f; // 0.9f centres the letters vertically _theDottedLinePen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; #region initialise graphics _scale = scalePercent * _basicScale; _fieldPanelCentreX = _g.VisibleClipBounds.Width / 2; _fieldPanelCentreY = _g.VisibleClipBounds.Height / 2; #endregion initialise graphics #region draw _g.Clear(Color.White); DrawBackground(_g); DrawPointMarkers(_scale, _fieldPanelCentreX, _fieldPanelCentreY); if (outputKrystal != null) { _densityInputKrystal = outputKrystal.DensityInputKrystal; _pointsInputKrystal = outputKrystal.PointsInputKrystal; Expander ef = outputKrystal.Expander; if (ef != null) { foreach (Planet planet in ef.OutputGamete.Planets) { planet.GetPlanetCoordinates(_densityInputKrystal, _fieldPanelCentreX, _fieldPanelCentreY, _scale); DrawPlanetBackground(planet, false); // draws unused input points and the line } foreach (Planet planet in ef.InputGamete.Planets) { planet.GetPlanetCoordinates(_densityInputKrystal, _fieldPanelCentreX, _fieldPanelCentreY, _scale); DrawPlanetBackground(planet, true); // draws unused input points and the line } foreach (Planet planet in ef.OutputGamete.Planets) DrawPlanet(planet, true); // true means draw output planet foreach (PointGroup p in ef.OutputGamete.FixedPointGroups) DrawFixedDots(p, false); foreach (PointGroup p in ef.InputGamete.FixedPointGroups) DrawFixedDots(p, true); foreach (Planet planet in ef.InputGamete.Planets) DrawPlanet(planet, false); // false means draw input planet } // if (ef != null) } #endregion draw }
private void MenuItemLoadPointsInputKrystal_Click(object sender, EventArgs e) { CheckSaved(); try { string pointsInputFilepath = K.GetFilepathFromOpenFileDialog(K.DialogFilterIndex.allKrystals); if (pointsInputFilepath.Length > 0) { PointsInputKrystal pik = new PointsInputKrystal(pointsInputFilepath); _outputKrystal.PointsInputKrystal = pik; _outputKrystal.PointsInputFilename = _outputKrystal.PointsInputKrystal.Name; LoadNewKrystalInputFileIntoEditor(); } } catch (ApplicationException ae) { MessageBox.Show(ae.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }