protected virtual CSLineID SDeserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { CSLineID s = (o == null ? new CSLineID() : (CSLineID)o); s._parallelAxisNumber = info.GetInt32("Axis"); s._logicalValueFirstOther = info.GetDouble("Logical1"); s._usePhysicalValueFirstOther = info.GetBoolean("UsePhysical1"); if (s._usePhysicalValueFirstOther) { s._physicalValueFirstOther = (AltaxoVariant)info.GetValue("Physical1", s); } bool is3D = info.GetBoolean("Is3D"); if (is3D) { s._logicalValueSecondOther = info.GetDouble("Logical1"); s._usePhysicalValueSecondOther = info.GetBoolean("UsePhysical2"); if (s._usePhysicalValueSecondOther) { s._physicalValueSecondOther = (AltaxoVariant)info.GetValue("Physical2", s); } } return(s); }
/// <summary> /// Creates an instance from a given template instance and an offset to the first logical value. /// </summary> /// <param name="from">Instance to copy from.</param> /// <param name="offset1">Offset to the first logical value. The value given here is added to the first logical value of the template instance.</param> /// <returns>A new instance.</returns> /// <remarks>If template is using physical values instead of logical values, the offset will have no effect.</remarks> public static CSLineID FromIDandFirstLogicalOffset(CSLineID from, double offset1) { CSLineID retval = new CSLineID(from); retval._logicalValueFirstOther += offset1; return(retval); }
/// <summary> /// This is a private constructor that sets not only the identifier, but also default values. The second argument is ignored, but is essential /// to distinguish this contructor from the constructor that sets no default values. /// </summary> /// <param name="identifier">The identifier.</param> /// <param name="idIgnored">Ignored argument</param> private CSAxisInformation(CSLineID identifier, CSLineID idIgnored) { _identifier = identifier; switch (_identifier.ParallelAxisNumber) { case 0: _nameOfAxisStyle = "X-Axis"; break; case 1: _nameOfAxisStyle = "Y-Axis"; break; case 2: _nameOfAxisStyle = "Z-Axis"; break; default: _nameOfAxisStyle = "Axis" + _identifier.ParallelAxisNumber.ToString(); break; } // Axis name if (_identifier.Is3DIdentifier) { _nameOfAxisStyle += string.Format(" (at {0}={1}; {2}={3})", _identifier.UsePhysicalValueOtherFirst ? "P1" : "L1", _identifier.UsePhysicalValueOtherFirst ? _identifier.PhysicalValueOtherFirst.ToString() : _identifier.LogicalValueOtherFirst.ToString(), _identifier.UsePhysicalValueOtherSecond ? "P2" : "L2", _identifier.UsePhysicalValueOtherSecond ? _identifier.PhysicalValueOtherSecond.ToString() : _identifier.LogicalValueOtherSecond.ToString()); } else { if (_identifier.UsePhysicalValueOtherFirst) { _nameOfAxisStyle = string.Format("{0}={1}", _identifier.ParallelAxisNumber == 0 ? "Y" : "X", _identifier.PhysicalValueOtherFirst); } else { _nameOfAxisStyle += string.Format(" (at L={0})", _identifier.LogicalValueOtherFirst.ToString()); } } // Axis sides _nameOfFirstDownSide = "FirstDown"; _nameOfFirstUpSide = "FirstUp"; if (_identifier.Is3DIdentifier) { _nameOfSecondDownSide = "SecondDown"; _nameOfSecondUpSide = "SecondUp"; } else { _nameOfSecondDownSide = null; _nameOfSecondUpSide = null; } // preferred label side _preferedLabelSide = CSAxisSide.FirstDown; }
public virtual void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info) { CSLineID s = (CSLineID)obj; info.AddValue("Axis", s._parallelAxisNumber); info.AddValue("Logical1", s._logicalValueFirstOther); info.AddValue("UsePhysical1", s._usePhysicalValueFirstOther); if (s._usePhysicalValueFirstOther) { info.AddValue("Physical1", (object)(s._physicalValueFirstOther)); } bool is3D = s.Is3DIdentifier; info.AddValue("Is3DIdentifier", is3D); if (is3D) { info.AddValue("Logical2", s._logicalValueSecondOther); info.AddValue("UsePhysical2", s._usePhysicalValueSecondOther); if (s._usePhysicalValueSecondOther) { info.AddValue("Physical2", (object)(s._physicalValueSecondOther)); } } }
/// <summary> /// Gets the two planes parallel to the provided axis that are oriented to the main coordinate system axes. /// </summary> /// <param name="id">The line identifier.</param> /// <returns></returns> public static IEnumerable <CSPlaneID> GetPlanesParallelToAxis3D(CSLineID id) { switch (id.ParallelAxisNumber) { case 0: yield return(id.UsePhysicalValueOtherFirst ? CSPlaneID.FromPhysicalVariant(1, id.PhysicalValueOtherFirst) : new CSPlaneID(1, id.LogicalValueOtherFirst)); yield return(id.UsePhysicalValueOtherSecond ? CSPlaneID.FromPhysicalVariant(2, id.PhysicalValueOtherSecond) : new CSPlaneID(2, id.LogicalValueOtherSecond)); break; case 1: yield return(id.UsePhysicalValueOtherFirst ? CSPlaneID.FromPhysicalVariant(0, id.PhysicalValueOtherFirst) : new CSPlaneID(0, id.LogicalValueOtherFirst)); yield return(id.UsePhysicalValueOtherSecond ? CSPlaneID.FromPhysicalVariant(2, id.PhysicalValueOtherSecond) : new CSPlaneID(2, id.LogicalValueOtherSecond)); break; case 2: yield return(id.UsePhysicalValueOtherFirst ? CSPlaneID.FromPhysicalVariant(0, id.PhysicalValueOtherFirst) : new CSPlaneID(0, id.LogicalValueOtherFirst)); yield return(id.UsePhysicalValueOtherSecond ? CSPlaneID.FromPhysicalVariant(1, id.PhysicalValueOtherSecond) : new CSPlaneID(1, id.LogicalValueOtherSecond)); break; default: throw new ArgumentOutOfRangeException(nameof(id.ParallelAxisNumber)); } }
public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { var s = new CSLineID { _parallelAxisNumber = info.GetInt32("Axis"), _logicalValueFirstOther = info.GetDouble("Logical1"), _usePhysicalValueFirstOther = info.GetBoolean("UsePhysical1") }; if (s._usePhysicalValueFirstOther) { s._physicalValueFirstOther = (AltaxoVariant)info.GetValue("Physical1", s); } bool is3D = info.GetBoolean("Is3D"); if (is3D) { s._logicalValueSecondOther = info.GetDouble("Logical1"); s._usePhysicalValueSecondOther = info.GetBoolean("UsePhysical2"); if (s._usePhysicalValueSecondOther) { s._physicalValueSecondOther = (AltaxoVariant)info.GetValue("Physical2", s); } } return(s); }
public CSAxisInformation( CSLineID Identifier, string NameOfAxisStyle, string NameOfFirstDownSide, string NameOfFirstUpSide, string NameOfSecondDownSide, string NameOfSecondUpSide, CSAxisSide PreferredLabelSide, CSAxisSide PreferredTickSide, bool IsShownByDefault, bool HasTicksByDefault, bool HasLabelsByDefault, bool HasTitleByDefault ) { _identifier = Identifier; _nameOfAxisStyle = NameOfAxisStyle; _nameOfFirstDownSide = NameOfFirstDownSide; _nameOfFirstUpSide = NameOfFirstUpSide; _nameOfSecondDownSide = NameOfSecondDownSide; _nameOfSecondUpSide = NameOfSecondUpSide; _preferedLabelSide = PreferredLabelSide; _preferedTickSide = PreferredTickSide; _isShownByDefault = IsShownByDefault; _hasTicksByDefault = HasTicksByDefault; _hasLabelsByDefault = HasLabelsByDefault; _hasTitleByDefault = HasTitleByDefault; }
public static CSAxisInformation NewWithDefaultValues(CSLineID identifier) { if (null == identifier) { throw new ArgumentNullException(nameof(identifier)); } return(new CSAxisInformation(identifier, identifier)); }
public CSLineID(CSLineID from) { this._parallelAxisNumber = from._parallelAxisNumber; this._logicalValueFirstOther = from._logicalValueFirstOther; this._usePhysicalValueFirstOther = from._usePhysicalValueFirstOther; this._physicalValueFirstOther = from._physicalValueFirstOther; this._logicalValueSecondOther = from._logicalValueSecondOther; this._usePhysicalValueSecondOther = from._usePhysicalValueSecondOther; this._physicalValueSecondOther = from._physicalValueSecondOther; }
public override bool Equals(object obj) { if (!(obj is CSLineID)) { return(false); } CSLineID from = (CSLineID)obj; if (this.Is3DIdentifier != from.Is3DIdentifier) { return(false); } bool result = true; result &= this._parallelAxisNumber == from._parallelAxisNumber; result &= this._usePhysicalValueFirstOther == from._usePhysicalValueFirstOther; if (result == false) { return(false); } if (_usePhysicalValueFirstOther) { result &= (this._physicalValueFirstOther == from._physicalValueFirstOther); } else { result &= (this._logicalValueFirstOther == from._logicalValueFirstOther); } if (result == false) { return(false); } if (this.Is3DIdentifier) { if (this._usePhysicalValueSecondOther != from._usePhysicalValueSecondOther) { return(false); } if (_usePhysicalValueSecondOther) { result &= (this._physicalValueSecondOther == from._physicalValueSecondOther); } else { result &= (this._logicalValueSecondOther == from._logicalValueSecondOther); } } return(result); }
public CSAxisInformation( CSLineID Identifier, string NameOfAxisStyle, string NameOfFirstDownSide, string NameOfFirstUpSide, CSAxisSide PreferredLabelSide ) { _identifier = Identifier; _nameOfAxisStyle = NameOfAxisStyle; _nameOfFirstDownSide = NameOfFirstDownSide; _nameOfFirstUpSide = NameOfFirstUpSide; _preferedLabelSide = PreferredLabelSide; }
public static CSPlaneID GetPlaneParallelToAxis2D(CSLineID id) { switch (id.ParallelAxisNumber) { case 0: return(id.UsePhysicalValueOtherFirst ? CSPlaneID.FromPhysicalVariant(1, id.PhysicalValueOtherFirst) : new CSPlaneID(1, id.LogicalValueOtherFirst)); case 1: return(id.UsePhysicalValueOtherFirst ? CSPlaneID.FromPhysicalVariant(0, id.PhysicalValueOtherFirst) : new CSPlaneID(0, id.LogicalValueOtherFirst)); default: throw new ArgumentOutOfRangeException(nameof(id.ParallelAxisNumber)); } }
public CSAxisInformation( CSLineID Identifier, string NameOfAxisStyle, string NameOfFirstDownSide, string NameOfFirstUpSide, CSAxisSide PreferredLabelSide, bool IsShownByDefault, bool HasTitleByDefault ) { _identifier = Identifier; _nameOfAxisStyle = NameOfAxisStyle; _nameOfFirstDownSide = NameOfFirstDownSide; _nameOfFirstUpSide = NameOfFirstUpSide; _preferedLabelSide = PreferredLabelSide; _isShownByDefault = IsShownByDefault; _hasTitleByDefault = HasTitleByDefault; }
public CSAxisInformation WithIdentifier(CSLineID identifier) { if (_identifier == identifier) { return(this); } else { if (null == identifier) { throw new ArgumentNullException(nameof(identifier)); } var result = (CSAxisInformation)MemberwiseClone(); result._identifier = identifier; return(result); } }
/// <summary> /// Initialized a 2D identifier from the parallel axis and the physical value of the perpendicular axis. /// </summary> /// <param name="parallelAxisNumber">Number of parallel axis (0->X, 1->Y, 2->Z).</param> /// <param name="physicalValueOther">Physical value of the axis perendicular to the parallel axis.</param> /// <returns>A freshly created 2D line identifier.</returns> public static CSLineID FromPhysicalValue(int parallelAxisNumber, double physicalValueOther) { if (parallelAxisNumber < 0 || parallelAxisNumber > 2) { throw new ArgumentOutOfRangeException("AxisNumber must be either 0, 1, or 2, but you provide: " + parallelAxisNumber.ToString()); } if (double.IsNaN(physicalValueOther)) { throw new ArgumentException("Physical value is NaN, but it must be a valid number."); } CSLineID id = new CSLineID(); id._parallelAxisNumber = parallelAxisNumber; id._physicalValueFirstOther = physicalValueOther; id._logicalValueFirstOther = double.NaN; id._usePhysicalValueFirstOther = true; id._logicalValueSecondOther = double.NaN; return(id); }
/// <summary> /// Initialized a 2D identifier from the parallel axis and the physical value of the perpendicular axis. /// </summary> /// <param name="parallelAxisNumber">Number of parallel axis (0->X, 1->Y, 2->Z).</param> /// <param name="physicalValueOther">Physical value of the axis perendicular to the parallel axis.</param> /// <returns>A freshly created 2D line identifier.</returns> public static CSLineID FromPhysicalVariant(int parallelAxisNumber, AltaxoVariant physicalValueOther) { if (parallelAxisNumber < 0 || parallelAxisNumber > 2) { throw new ArgumentOutOfRangeException("AxisNumber must be either 0, 1, or 2, but you provide: " + parallelAxisNumber.ToString()); } if (!physicalValueOther.Equals(physicalValueOther)) { throw new ArgumentException("You can not set physical values that return false when compared to itself, value is: " + physicalValueOther.ToString()); } CSLineID id = new CSLineID(); id._parallelAxisNumber = parallelAxisNumber; id._physicalValueFirstOther = physicalValueOther; id._logicalValueFirstOther = double.NaN; id._usePhysicalValueFirstOther = true; id._logicalValueSecondOther = double.NaN; return(id); }
private void SetDefaultAxisTitlePositionAndOrientation(TextGraphic axisTitle, CSLineID id, CSAxisInformation info) { // find out the position and orientation of the item double rx0 = 0, rx1 = 1, ry0 = 0, ry1 = 1, rz0 = 0, rz1 = 1; double relOnAxis = 0.5; // where on the axis is the label positioned if (id.ParallelAxisNumber == 0) { ry0 = ry1 = id.LogicalValueOtherFirst; rz0 = rz1 = id.LogicalValueOtherSecond; } else if (id.ParallelAxisNumber == 1) { rx0 = rx1 = id.LogicalValueOtherFirst; rz0 = rz1 = id.LogicalValueOtherSecond; relOnAxis = 0.4; } else if (id.ParallelAxisNumber == 2) { rx0 = rx1 = id.LogicalValueOtherFirst; ry0 = ry1 = id.LogicalValueOtherSecond; relOnAxis = 0.4; } else { throw new NotImplementedException(); } VectorD3D normDirection; Logical3D tdirection = CoordinateSystem.GetLogicalDirection(info.Identifier.ParallelAxisNumber, info.PreferredLabelSide); var location = CoordinateSystem.GetPositionAndNormalizedDirection(new Logical3D(rx0, ry0, rz0), new Logical3D(rx1, ry1, rz1), relOnAxis, tdirection, out normDirection); axisTitle.Location.ParentAnchorX = RADouble.NewRel(location.X / this.Size.X); // set the x anchor of the parent axisTitle.Location.ParentAnchorY = RADouble.NewRel(location.Y / this.Size.Y); // set the y anchor of the parent axisTitle.Location.ParentAnchorZ = RADouble.NewRel(location.Z / this.Size.Z); // set the z anchor of the parent double distance = 0; AxisStyle axisStyle = _axisStyles[id]; if (null != axisStyle.AxisLineStyle) distance += axisStyle.AxisLineStyle.GetOuterDistance(info.PreferredLabelSide); double labelFontSize = 0; if (axisStyle.AreMajorLabelsEnabled) labelFontSize = Math.Max(labelFontSize, axisStyle.MajorLabelStyle.FontSize); if (axisStyle.AreMinorLabelsEnabled) labelFontSize = Math.Max(labelFontSize, axisStyle.MinorLabelStyle.FontSize); axisTitle.RotationX = 90; // Font height now is z, Font depth is y and x remains x axisTitle.Location.LocalAnchorX = normDirection.X == 0 ? RADouble.NewRel(0.5) : normDirection.X < 0 ? RADouble.NewRel(1) : RADouble.NewRel(0); axisTitle.Location.LocalAnchorY = normDirection.Z == 0 ? RADouble.NewRel(0.5) : normDirection.Z < 0 ? RADouble.NewRel(1) : RADouble.NewRel(0); axisTitle.Location.LocalAnchorZ = normDirection.Y == 0 ? RADouble.NewRel(0.5) : normDirection.Y < 0 ? RADouble.NewRel(1) : RADouble.NewRel(0); VectorD3D scaleFont = new VectorD3D(1, 1, 1.4); distance += Math.Abs(scaleFont.X * normDirection.X) * labelFontSize; distance += Math.Abs(scaleFont.Y * normDirection.Y) * labelFontSize; distance += Math.Abs(scaleFont.Z * normDirection.Z) * labelFontSize; axisTitle.Location.PositionX = RADouble.NewAbs(distance * normDirection.X); // because this is relative to the reference point, we don't need to take the location into account here, it is set above axisTitle.Location.PositionY = RADouble.NewAbs(distance * normDirection.Y); axisTitle.Location.PositionZ = RADouble.NewAbs(distance * normDirection.Z); }
public static CSAxisInformation NewWithDefaultValues(CSLineID identifier) { if (null == identifier) throw new ArgumentNullException(nameof(identifier)); return new CSAxisInformation(identifier, identifier); }
void SetCoordinateSystemDependentObjects(CSLineID id) { // collect the AxisStyleIdentifier from the actual layer and also all possible AxisStyleIdentifier _axisStyleIds = new Dictionary<CSLineID, CSAxisInformation>(); _axisStyleInfoSortedByName = new List<CSAxisInformation>(); foreach (CSLineID ids in _doc.CoordinateSystem.GetJoinedAxisStyleIdentifier(_doc.AxisStyles.AxisStyleIDs, new CSLineID[] { id })) { CSAxisInformation info = _doc.CoordinateSystem.GetAxisStyleInformation(ids); _axisStyleIds.Add(info.Identifier, info); _axisStyleInfoSortedByName.Add(info); } _planeIdentifier = new List<CSPlaneID>(); _planeIdentifier.Add(CSPlaneID.Front); _axisScaleController = new AxisScaleController[2]; _GridStyleController = new Dictionary<CSPlaneID, IMVCANController>(); _TitleFormatController = new Dictionary<CSLineID, IMVCANController>(); _MajorLabelController = new Dictionary<CSLineID, IMVCANController>(); _MinorLabelController = new Dictionary<CSLineID, IMVCANController>(); _enableAxisStyle = new Dictionary<CSLineID, bool>(); _enableMajorLabels = new Dictionary<CSLineID, bool>(); _enableMinorLabels = new Dictionary<CSLineID, bool>(); foreach (CSLineID ident in _axisStyleIds.Keys) { AxisStyle prop = _doc.AxisStyles[ident]; if (prop == null) { _enableAxisStyle.Add(ident, false); _enableMajorLabels.Add(ident, false); _enableMinorLabels.Add(ident, false); } else { _enableAxisStyle.Add(ident, true); _enableMajorLabels.Add(ident, prop.ShowMajorLabels); _enableMinorLabels.Add(ident, prop.ShowMinorLabels); } } }
public LayerController(XYPlotLayer layer, string currentPage, CSLineID id) : this(layer, currentPage, id.ParallelAxisNumber, id) { }
/// <summary> /// Initialized a 2D identifier from the parallel axis and the physical value of the perpendicular axis. /// </summary> /// <param name="parallelAxisNumber">Number of parallel axis (0->X, 1->Y, 2->Z).</param> /// <param name="physicalValueOther">Physical value of the axis perendicular to the parallel axis.</param> /// <returns>A freshly created 2D line identifier.</returns> public static CSLineID FromPhysicalValue(int parallelAxisNumber, double physicalValueOther) { if (parallelAxisNumber < 0 || parallelAxisNumber > 2) throw new ArgumentOutOfRangeException("AxisNumber must be either 0, 1, or 2, but you provide: " + parallelAxisNumber.ToString()); if (double.IsNaN(physicalValueOther)) throw new ArgumentException("Physical value is NaN, but it must be a valid number."); CSLineID id = new CSLineID(); id._parallelAxisNumber = parallelAxisNumber; id._physicalValueFirstOther = physicalValueOther; id._logicalValueFirstOther = double.NaN; id._usePhysicalValueFirstOther = true; id._logicalValueSecondOther = double.NaN; return id; }
public static CSPlaneID GetPlaneParallelToAxis2D(CSLineID id) { switch (id.ParallelAxisNumber) { case 0: return id.UsePhysicalValueOtherFirst ? CSPlaneID.FromPhysicalVariant(1, id.PhysicalValueOtherFirst) : new CSPlaneID(1, id.LogicalValueOtherFirst); case 1: return id.UsePhysicalValueOtherFirst ? CSPlaneID.FromPhysicalVariant(0, id.PhysicalValueOtherFirst) : new CSPlaneID(0, id.LogicalValueOtherFirst); default: throw new ArgumentOutOfRangeException(nameof(id.ParallelAxisNumber)); } }
/// <summary> /// Creates an instance from a given template instance and an offset to the first logical value. /// </summary> /// <param name="from">Instance to copy from.</param> /// <param name="offset1">Offset to the first logical value. The value given here is added to the first logical value of the template instance.</param> /// <returns>A new instance.</returns> /// <remarks>If template is using physical values instead of logical values, the offset will have no effect.</remarks> public static CSLineID FromIDandFirstLogicalOffset(CSLineID from, double offset1) { return from.WithLogicalValueOtherFirst(from.LogicalValueOtherFirst + offset1); }
/// <summary> /// Gets the two planes parallel to the provided axis that are oriented to the main coordinate system axes. /// </summary> /// <param name="id">The line identifier.</param> /// <returns></returns> public static IEnumerable<CSPlaneID> GetPlanesParallelToAxis3D(CSLineID id) { switch (id.ParallelAxisNumber) { case 0: yield return id.UsePhysicalValueOtherFirst ? CSPlaneID.FromPhysicalVariant(1, id.PhysicalValueOtherFirst) : new CSPlaneID(1, id.LogicalValueOtherFirst); yield return id.UsePhysicalValueOtherSecond ? CSPlaneID.FromPhysicalVariant(2, id.PhysicalValueOtherSecond) : new CSPlaneID(2, id.LogicalValueOtherSecond); break; case 1: yield return id.UsePhysicalValueOtherFirst ? CSPlaneID.FromPhysicalVariant(0, id.PhysicalValueOtherFirst) : new CSPlaneID(0, id.LogicalValueOtherFirst); yield return id.UsePhysicalValueOtherSecond ? CSPlaneID.FromPhysicalVariant(2, id.PhysicalValueOtherSecond) : new CSPlaneID(2, id.LogicalValueOtherSecond); break; case 2: yield return id.UsePhysicalValueOtherFirst ? CSPlaneID.FromPhysicalVariant(0, id.PhysicalValueOtherFirst) : new CSPlaneID(0, id.LogicalValueOtherFirst); yield return id.UsePhysicalValueOtherSecond ? CSPlaneID.FromPhysicalVariant(1, id.PhysicalValueOtherSecond) : new CSPlaneID(1, id.LogicalValueOtherSecond); break; default: throw new ArgumentOutOfRangeException(nameof(id.ParallelAxisNumber)); } }
private void SetAxisTitleString(CSLineID id, string value) { AxisStyle style = _axisStyles[id]; string oldtitle = (style == null || style.Title == null) ? null : style.Title.Text; string newtitle = (value == null || value == String.Empty) ? null : value; if (newtitle != oldtitle) { if (newtitle == null) { if (style != null) style.Title = null; } else if (_axisStyles.AxisStyleEnsured(id).Title != null) { _axisStyles[id].Title.Text = newtitle; } else { TextGraphic tg = new TextGraphic(this.GetPropertyContext()); CSAxisInformation info = CoordinateSystem.GetAxisStyleInformation(id); tg.SetParentSize(this.Size, false); SetDefaultAxisTitlePositionAndOrientation(tg, id, info); tg.Text = newtitle; _axisStyles.AxisStyleEnsured(id).Title = tg; } } }
public CSAxisInformation WithIdentifier(CSLineID identifier) { if (_identifier == identifier) { return this; } else { if (null == identifier) throw new ArgumentNullException(nameof(identifier)); var result = (CSAxisInformation)this.MemberwiseClone(); result._identifier = identifier; return result; } }
/// <summary> /// This is a private constructor that sets not only the identifier, but also default values. The second argument is ignored, but is essential /// to distinguish this contructor from the constructor that sets no default values. /// </summary> /// <param name="identifier">The identifier.</param> /// <param name="idIgnored">Ignored argument</param> private CSAxisInformation(CSLineID identifier, CSLineID idIgnored) { _identifier = identifier; switch (_identifier.ParallelAxisNumber) { case 0: _nameOfAxisStyle = "X-Axis"; break; case 1: _nameOfAxisStyle = "Y-Axis"; break; case 2: _nameOfAxisStyle = "Z-Axis"; break; default: _nameOfAxisStyle = "Axis" + _identifier.ParallelAxisNumber.ToString(); break; } // Axis name if (_identifier.Is3DIdentifier) { _nameOfAxisStyle += string.Format(" (at {0}={1}; {2}={3})", _identifier.UsePhysicalValueOtherFirst ? "P1" : "L1", _identifier.UsePhysicalValueOtherFirst ? _identifier.PhysicalValueOtherFirst.ToString() : _identifier.LogicalValueOtherFirst.ToString(), _identifier.UsePhysicalValueOtherSecond ? "P2" : "L2", _identifier.UsePhysicalValueOtherSecond ? _identifier.PhysicalValueOtherSecond.ToString() : _identifier.LogicalValueOtherSecond.ToString()); } else { if (_identifier.UsePhysicalValueOtherFirst) _nameOfAxisStyle = string.Format("{0}={1}", _identifier.ParallelAxisNumber == 0 ? "Y" : "X", _identifier.PhysicalValueOtherFirst); else _nameOfAxisStyle += string.Format(" (at L={0})", _identifier.LogicalValueOtherFirst.ToString()); } // Axis sides _nameOfFirstDownSide = "FirstDown"; _nameOfFirstUpSide = "FirstUp"; if (_identifier.Is3DIdentifier) { _nameOfSecondDownSide = "SecondDown"; _nameOfSecondUpSide = "SecondUp"; } else { _nameOfSecondDownSide = null; _nameOfSecondUpSide = null; } // preferred label side _preferedLabelSide = CSAxisSide.FirstDown; }
public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { CSLineID s = SDeserialize(o, info, parent); return(s); }
public CSAxisInformation GetAxisStyleInformation(CSLineID styleID) { // search for the same axis first, then for the style with the nearest logical value double minDistance = double.MaxValue; CSAxisInformation nearestInfo = null; if (!styleID.UsePhysicalValueOtherFirst) { foreach (CSAxisInformation info in AxisStyles) { if (styleID.ParallelAxisNumber == info.Identifier.ParallelAxisNumber) { if (styleID == info.Identifier) { minDistance = 0; nearestInfo = info; break; } double dist = Math.Abs(styleID.LogicalValueOtherFirst - info.Identifier.LogicalValueOtherFirst); if (styleID.Is3DIdentifier && info.Identifier.Is3DIdentifier) dist += Math.Abs(styleID.LogicalValueOtherSecond - info.Identifier.LogicalValueOtherSecond); if (dist < minDistance) { minDistance = dist; nearestInfo = info; if (0 == minDistance) break; // it can not be smaller than 0 } } } } CSAxisInformation result; if (nearestInfo == null) { result = CSAxisInformation.NewWithDefaultValues(styleID); } else { result = nearestInfo.WithIdentifier(styleID); if (minDistance != 0) { result = result.WithNameOfAxisStyle(result.NameOfAxisStyle + string.Format(" ({0}% offs.)", minDistance * 100)); } } result = result.WithNamesForFirstUpAndDownSides( GetAxisSideName(result.Identifier, CSAxisSide.FirstUp), GetAxisSideName(result.Identifier, CSAxisSide.FirstDown)); if (Is3D) { result = result.WithNamesForSecondUpAndDownSides( GetAxisSideName(result.Identifier, CSAxisSide.SecondUp), GetAxisSideName(result.Identifier, CSAxisSide.SecondDown)); } return result; }
public static bool ShowDialog(XYPlotLayer layer, string currentPage, CSLineID currentEdge) { LayerController ctrl = new LayerController(layer, currentPage, currentEdge); LayerControl view = new LayerControl(); ctrl.View = view; return Current.Gui.ShowDialog(ctrl, layer.Name, true); }
public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { var s = new CSLineID(); s._parallelAxisNumber = info.GetInt32("Axis"); s._logicalValueFirstOther = info.GetDouble("Logical1"); s._usePhysicalValueFirstOther = info.GetBoolean("UsePhysical1"); if (s._usePhysicalValueFirstOther) s._physicalValueFirstOther = (AltaxoVariant)info.GetValue("Physical1", s); bool is3D = info.GetBoolean("Is3D"); if (is3D) { s._logicalValueSecondOther = info.GetDouble("Logical1"); s._usePhysicalValueSecondOther = info.GetBoolean("UsePhysical2"); if (s._usePhysicalValueSecondOther) s._physicalValueSecondOther = (AltaxoVariant)info.GetValue("Physical2", s); } return s; }
bool ApplyCurrentController(bool force) { if (_currentController == null) return true; if (!force && object.ReferenceEquals(_currentController, _lastControllerApplied)) return true; if (!_currentController.Apply()) return false; _lastControllerApplied = _currentController; if(object.ReferenceEquals(_currentController,_coordinateController)) { _doc.CoordinateSystem = (G2DCoordinateSystem)_coordinateController.ModelObject; SetCoordinateSystemDependentObjects(); } else if (_currentPageName == "TitleAndFormat") { // if we have enabled/disabled some items, we must update the enable states of the minor/major controllers AxisStyle axstyle = (AxisStyle)_currentController.ModelObject; if (_currentAxisID == axstyle.StyleID) { _enableMajorLabels[axstyle.StyleID] = axstyle.ShowMajorLabels; _enableMinorLabels[axstyle.StyleID] = axstyle.ShowMinorLabels; } else // than we have applied a position offset, and the old StyleID is no longer valid { _doc.AxisStyles.Remove(_currentAxisID); _doc.AxisStyles.Add(axstyle); _currentAxisID = axstyle.StyleID; // take this for axstyle SetCoordinateSystemDependentObjects(); SetEdgeSecondaryChoice(); // update left side list of choices SetCurrentTabController(true); // we must simulate a page change in order to update the title-format tab page } } else if (_currentPageName == "MajorLabels") { if (!_enableMajorLabels[_currentAxisID] && _doc.AxisStyles.Contains(_currentAxisID)) { _doc.AxisStyles[_currentAxisID].ShowMajorLabels = false; } if (_TitleFormatController.ContainsKey(_currentAxisID)) _TitleFormatController.Remove(_currentAxisID); } else if (_currentPageName == "MinorLabels") { if (!_enableMinorLabels[_currentAxisID] && _doc.AxisStyles.Contains(_currentAxisID)) _doc.AxisStyles[_currentAxisID].ShowMinorLabels = false; if (_TitleFormatController.ContainsKey(_currentAxisID)) _TitleFormatController.Remove(_currentAxisID); } else if (_currentPageName == "GridStyle") { GridPlane gp = (GridPlane)_currentController.ModelObject; this._doc.GridPlanes[_currentPlaneID] = gp.IsUsed ? gp : null; } return true; }
public void CopyFrom(CSAxisInformation from) { this._identifier = from._identifier.Clone(); CopyWithoutIdentifierFrom(from); }
public void EhView_SecondChoiceChanged(int index, string item) { if (!ApplyCurrentController(false)) return; if (_primaryChoice == TabType.Scales) { _currentScale = index; } else if (_primaryChoice == TabType.Styles) { _currentAxisID = _axisStyleInfoSortedByName[index].Identifier; } else if (_primaryChoice == TabType.Planes) { _currentPlaneID = _planeIdentifier[index]; } SetCurrentTabController(false); }
/// <summary> /// Creates an instance from a given template instance and an offset to the first logical value. /// </summary> /// <param name="from">Instance to copy from.</param> /// <param name="offset1">Offset to the first logical value. The value given here is added to the first logical value of the template instance.</param> /// <returns>A new instance.</returns> /// <remarks>If template is using physical values instead of logical values, the offset will have no effect.</remarks> public static CSLineID FromIDandFirstLogicalOffset(CSLineID from, double offset1) { CSLineID retval = new CSLineID(from); retval._logicalValueFirstOther += offset1; return retval; }
public CSAxisInformation(CSLineID identifier) { _identifier = identifier.Clone(); }
/// <summary> /// Initialized a 2D identifier from the parallel axis and the physical value of the perpendicular axis. /// </summary> /// <param name="parallelAxisNumber">Number of parallel axis (0->X, 1->Y, 2->Z).</param> /// <param name="physicalValueOther">Physical value of the axis perendicular to the parallel axis.</param> /// <returns>A freshly created 2D line identifier.</returns> public static CSLineID FromPhysicalVariant(int parallelAxisNumber, AltaxoVariant physicalValueOther) { if (parallelAxisNumber < 0 || parallelAxisNumber > 2) throw new ArgumentOutOfRangeException("AxisNumber must be either 0, 1, or 2, but you provide: " + parallelAxisNumber.ToString()); if (!physicalValueOther.Equals(physicalValueOther)) throw new ArgumentException("You can not set physical values that return false when compared to itself, value is: " + physicalValueOther.ToString()); CSLineID id = new CSLineID(); id._parallelAxisNumber = parallelAxisNumber; id._physicalValueFirstOther = physicalValueOther; id._logicalValueFirstOther = double.NaN; id._usePhysicalValueFirstOther = true; id._logicalValueSecondOther = double.NaN; return id; }
LayerController(XYPlotLayer layer, string currentPage, int axisScaleIdx, CSLineID id) { _originalDoc = layer; _doc = (XYPlotLayer)layer.Clone(); _docSuspendLock = _doc.BeginUpdate(); SetCoordinateSystemDependentObjects(id); _currentScale = axisScaleIdx; _currentAxisID = id; _currentPlaneID = CSPlaneID.Front; _currentPageName = currentPage; if (null != View) SetViewElements(); }
/// <summary>Gets the name of the axis side.</summary> /// <param name="id">The axis identifier.</param> /// <param name="side">The axis side.</param> /// <returns>The name of the axis side for the axis line given by the identifier.</returns> public abstract string GetAxisSideName(CSLineID id, CSAxisSide side);
/// <summary> /// Initializes a new instance of the <see cref="CSAxisInformation"/> class, with only the identifier, but no other information. /// </summary> /// <param name="identifier">The identifier.</param> public CSAxisInformation(CSLineID identifier) { _identifier = identifier; }
/// <summary> /// Get a line along the axis designated by the argument id from the logical values r0 to r1. /// </summary> /// <param name="path">Graphics path.</param> /// <param name="id">Axis to draw the isoline along.</param> /// <param name="r0">Start point of the isoline. The logical value of the other coordinate.</param> /// <param name="r1">End point of the isoline. The logical value of the other coordinate.</param> public virtual void GetIsolineFromTo(CSLineID id, double r0, double r1, out IPolylineD3D path) { if (id.ParallelAxisNumber == 0) { path = GetIsoline(new Logical3D(r0, id.LogicalValueOtherFirst, id.LogicalValueOtherSecond), new Logical3D(r1, id.LogicalValueOtherFirst, id.LogicalValueOtherSecond)); } else if (id.ParallelAxisNumber == 1) { path = GetIsoline(new Logical3D(id.LogicalValueOtherFirst, r0, id.LogicalValueOtherSecond), new Logical3D(id.LogicalValueOtherFirst, r1, id.LogicalValueOtherSecond)); } else { path = GetIsoline(new Logical3D(id.LogicalValueOtherFirst, id.LogicalValueOtherSecond, r0), new Logical3D(id.LogicalValueOtherFirst, id.LogicalValueOtherSecond, r1)); } }
private string GetAxisTitleString(CSLineID id) { return _axisStyles[id] != null && _axisStyles[id].Title != null ? _axisStyles[id].Title.Text : null; }
/// <summary> /// Creates an instance from a given template instance and an offset to the first logical value. /// </summary> /// <param name="from">Instance to copy from.</param> /// <param name="offset1">Offset to the first logical value. The value given here is added to the first logical value of the template instance.</param> /// <returns>A new instance.</returns> /// <remarks>If template is using physical values instead of logical values, the offset will have no effect.</remarks> public static CSLineID FromIDandFirstLogicalOffset(CSLineID from, double offset1) { return(from.WithLogicalValueOtherFirst(from.LogicalValueOtherFirst + offset1)); }