Skip to content

Commit 5f464fb

Browse files
committed
Change user-defined UserBoxCoords definition and TransformingConverter's delegate.
1 parent 021f6d6 commit 5f464fb

File tree

4 files changed

+79
-62
lines changed

4 files changed

+79
-62
lines changed

Visual_Studio_2017/GraphicalDebugging/ExpressionLoader_UserDefined.cs

Lines changed: 69 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ public LoaderCreator(ITypeMatcher typeMatcher,
463463
}
464464

465465
public bool IsUserDefined() { return true; }
466-
public Kind Kind() { return ExpressionLoader.Kind.Point; }
466+
public Kind Kind() { return ExpressionLoader.Kind.Box; }
467467
public Loader Create(Loaders loaders, Debugger debugger, string name, string type, string id)
468468
{
469469
if (!typeMatcher.MatchType(type, id))
@@ -600,7 +600,7 @@ public LoaderCreator(ITypeMatcher typeMatcher,
600600
}
601601

602602
public bool IsUserDefined() { return true; }
603-
public Kind Kind() { return ExpressionLoader.Kind.Point; }
603+
public Kind Kind() { return ExpressionLoader.Kind.Box; }
604604
public Loader Create(Loaders loaders, Debugger debugger, string name, string type, string id)
605605
{
606606
if (!typeMatcher.MatchType(type, id))
@@ -730,19 +730,21 @@ public override MemoryReader.Converter<double> GetMemoryConverter(MemoryReader m
730730
new MemoryReader.Member<double>(converterY1, (int)infoY1.Offset),
731731
new MemoryReader.Member<double>(converterX2, (int)infoX2.Offset),
732732
new MemoryReader.Member<double>(converterY2, (int)infoY2.Offset)),
733-
delegate(double[] values)
733+
delegate(double[] values, int offset)
734734
{
735-
if (values.Length != 4)
736-
return;
737735
// convert to LBRT
738736
if (coordsX == CoordsX.LW) // LXWX
739-
values[2] = values[0] + values[2]; // r = l + w
737+
values[offset + 2] = values[offset + 0]
738+
+ values[offset + 2]; // r = l + w
740739
else if (coordsX == CoordsX.WR) // WXRX
741-
values[0] = values[2] - values[0]; // l = r - w
740+
values[offset + 0] = values[offset + 2]
741+
- values[offset + 0]; // l = r - w
742742
if (coordsY == CoordsY.BH) // XBXH
743-
values[3] = values[1] + values[3]; // t = b + h
743+
values[offset + 3] = values[offset + 1]
744+
+ values[offset + 3]; // t = b + h
744745
else if (coordsY == CoordsY.HT) // XHXT
745-
values[1] = values[3] - values[1]; // b = t - h
746+
values[offset + 1] = values[offset + 3]
747+
- values[offset + 1]; // b = t - h
746748
});
747749
}
748750

@@ -1517,6 +1519,7 @@ private static bool ReloadUserTypes(Loaders loaders,
15171519
{
15181520
var elPoints = Util.GetXmlElementByTagName(elEntry, "Points");
15191521
var elCoordinates = Util.GetXmlElementByTagName(elEntry, "Coordinates");
1522+
var elCoordinatesDimensions = Util.GetXmlElementByTagName(elEntry, "CoordinatesDimensions");
15201523
if (elPoints != null)
15211524
{
15221525
var elMin = Util.GetXmlElementByTagName(elPoints, "Min");
@@ -1529,68 +1532,82 @@ private static bool ReloadUserTypes(Loaders loaders,
15291532
typeMatcher, exprMin, exprMax));
15301533
}
15311534
}
1532-
else if (elCoordinates != null)
1535+
else if (elCoordinates != null || elCoordinatesDimensions != null)
15331536
{
15341537
Geometry.CoordinateSystem cs = Geometry.CoordinateSystem.Cartesian;
15351538
Geometry.Unit unit = Geometry.Unit.None;
15361539
GetCSAndUnit(elEntry, out cs, out unit);
15371540

1538-
var elLeft = Util.GetXmlElementByTagName(elCoordinates, "MinX");
1539-
var elBottom = Util.GetXmlElementByTagName(elCoordinates, "MinY");
1540-
var elRight = Util.GetXmlElementByTagName(elCoordinates, "MaxX");
1541-
var elTop = Util.GetXmlElementByTagName(elCoordinates, "MaxY");
1541+
var elParent = elCoordinates != null
1542+
? elCoordinates
1543+
: elCoordinatesDimensions;
1544+
1545+
var elLeft = Util.GetXmlElementByTagName(elParent, "MinX");
1546+
var elBottom = Util.GetXmlElementByTagName(elParent, "MinY");
1547+
var elRight = Util.GetXmlElementByTagName(elParent, "MaxX");
1548+
var elTop = Util.GetXmlElementByTagName(elParent, "MaxY");
15421549
if (elLeft == null)
1543-
elLeft = Util.GetXmlElementByTagName(elCoordinates, "Left");
1550+
elLeft = Util.GetXmlElementByTagName(elParent, "Left");
15441551
if (elBottom == null)
1545-
elBottom = Util.GetXmlElementByTagName(elCoordinates, "Bottom");
1552+
elBottom = Util.GetXmlElementByTagName(elParent, "Bottom");
15461553
if (elRight == null)
1547-
elRight = Util.GetXmlElementByTagName(elCoordinates, "Right");
1554+
elRight = Util.GetXmlElementByTagName(elParent, "Right");
15481555
if (elTop == null)
1549-
elTop = Util.GetXmlElementByTagName(elCoordinates, "Top");
1550-
var elWidth = Util.GetXmlElementByTagName(elCoordinates, "Width");
1551-
var elHeight = Util.GetXmlElementByTagName(elCoordinates, "Height");
1556+
elTop = Util.GetXmlElementByTagName(elParent, "Top");
1557+
var elWidth = Util.GetXmlElementByTagName(elParent, "Width");
1558+
var elHeight = Util.GetXmlElementByTagName(elParent, "Height");
1559+
15521560
string exprX1 = null;
15531561
string exprX2 = null;
15541562
string exprY1 = null;
15551563
string exprY2 = null;
15561564
UserBoxCoords.CoordsX coordsX = UserBoxCoords.CoordsX.LR;
15571565
UserBoxCoords.CoordsY coordsY = UserBoxCoords.CoordsY.BT;
1558-
if (elLeft != null && elRight != null)
1566+
if (elCoordinates != null)
15591567
{
1560-
exprX1 = elLeft.InnerText;
1561-
exprX2 = elRight.InnerText;
1562-
coordsX = UserBoxCoords.CoordsX.LR;
1568+
if (elLeft != null && elRight != null)
1569+
{
1570+
exprX1 = elLeft.InnerText;
1571+
exprX2 = elRight.InnerText;
1572+
coordsX = UserBoxCoords.CoordsX.LR;
1573+
}
1574+
1575+
if (elBottom != null && elTop != null)
1576+
{
1577+
exprY1 = elBottom.InnerText;
1578+
exprY2 = elTop.InnerText;
1579+
coordsY = UserBoxCoords.CoordsY.BT;
1580+
}
15631581
}
1564-
else if (elLeft != null && elWidth != null)
1582+
else // elCoordinatesDimensions != null
15651583
{
1566-
exprX1 = elLeft.InnerText;
1567-
exprX2 = elWidth.InnerText;
1568-
coordsX = UserBoxCoords.CoordsX.LW;
1569-
}
1570-
else if (elRight != null && elWidth != null)
1571-
{
1572-
exprX1 = elWidth.InnerText;
1573-
exprX2 = elRight.InnerText;
1574-
coordsX = UserBoxCoords.CoordsX.WR;
1575-
}
1576-
if (elBottom != null && elTop != null)
1577-
{
1578-
exprY1 = elBottom.InnerText;
1579-
exprY2 = elTop.InnerText;
1580-
coordsY = UserBoxCoords.CoordsY.BT;
1581-
}
1582-
else if (elBottom != null && elHeight != null)
1583-
{
1584-
exprY1 = elBottom.InnerText;
1585-
exprY2 = elHeight.InnerText;
1586-
coordsY = UserBoxCoords.CoordsY.BH;
1587-
}
1588-
else if (elTop != null && elHeight != null)
1589-
{
1590-
exprY1 = elHeight.InnerText;
1591-
exprY2 = elTop.InnerText;
1592-
coordsY = UserBoxCoords.CoordsY.HT;
1584+
if (elLeft != null && elWidth != null)
1585+
{
1586+
exprX1 = elLeft.InnerText;
1587+
exprX2 = elWidth.InnerText;
1588+
coordsX = UserBoxCoords.CoordsX.LW;
1589+
}
1590+
else if (elRight != null && elWidth != null)
1591+
{
1592+
exprX1 = elWidth.InnerText;
1593+
exprX2 = elRight.InnerText;
1594+
coordsX = UserBoxCoords.CoordsX.WR;
1595+
}
1596+
1597+
if (elBottom != null && elHeight != null)
1598+
{
1599+
exprY1 = elBottom.InnerText;
1600+
exprY2 = elHeight.InnerText;
1601+
coordsY = UserBoxCoords.CoordsY.BH;
1602+
}
1603+
else if (elTop != null && elHeight != null)
1604+
{
1605+
exprY1 = elHeight.InnerText;
1606+
exprY2 = elTop.InnerText;
1607+
coordsY = UserBoxCoords.CoordsY.HT;
1608+
}
15931609
}
1610+
15941611
if (exprX1 != null && exprX2 != null && exprY1 != null && exprY2 != null)
15951612
{
15961613
loaders.Add(new UserBoxCoords.LoaderCreator(

Visual_Studio_2017/GraphicalDebugging/MemoryReader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ private void initialize(int byteSize)
215215
public class TransformingConverter<ValueType> : Converter<ValueType>
216216
where ValueType : struct
217217
{
218-
public delegate void Transformer(ValueType[] values);
218+
public delegate void Transformer(ValueType[] values, int offset);
219219

220220
public TransformingConverter(Converter<ValueType> baseConverter,
221221
Transformer transformer)
@@ -237,7 +237,7 @@ public override int ByteSize()
237237
public override void Copy(byte[] bytes, int bytesOffset, ValueType[] result, int resultOffset)
238238
{
239239
baseConverter.Copy(bytes, bytesOffset, result, resultOffset);
240-
transformer(result);
240+
transformer(result, resultOffset);
241241
}
242242

243243
Converter<ValueType> baseConverter;

examples/cpp.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@
120120
};
121121
-->
122122
<Box Type="MyBox2" Id="MyBox2" CoordinateSystem="Cartesian" Unit="None">
123-
<Coordinates>
124-
<MinX>left</MinX> <!-- or <Left> -->
125-
<MinY>bottom</MinY> <!-- or <Bottom> -->
123+
<CoordinatesDimensions>
124+
<MinX>left</MinX> <!-- or <Left> or <MaxX> or <Right> -->
125+
<MinY>bottom</MinY> <!-- or <Bottom> or <MaxY> or <Top> -->
126126
<Width>width</Width>
127127
<Height>height</Height>
128-
</Coordinates>
128+
</CoordinatesDimensions>
129129
</Box>
130130

131131
<!--

examples/cs.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@
8282
}
8383
-->
8484
<Box Id="WpfApp1.MyBox2" CoordinateSystem="Cartesian" Unit="None">
85-
<Coordinates>
86-
<MinX>left</MinX> <!-- or <Left> -->
87-
<MinY>bottom</MinY> <!-- or <Bottom> -->
85+
<CoordinatesDimensions>
86+
<MinX>left</MinX> <!-- or <Left> or <MaxX> or <Right> -->
87+
<MinY>bottom</MinY> <!-- or <Bottom> or <MaxY> or <Top> -->
8888
<Width>width</Width>
8989
<Height>height</Height>
90-
</Coordinates>
90+
</CoordinatesDimensions>
9191
</Box>
9292

9393
<!--

0 commit comments

Comments
 (0)