-
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #472 from DomCR/Viewport-select-entities
Viewport select entities
- Loading branch information
Showing
8 changed files
with
128 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using ACadSharp.Entities; | ||
using ACadSharp.Tests.Common; | ||
using CSMath; | ||
using System.Collections.Generic; | ||
using Xunit; | ||
|
||
namespace ACadSharp.Tests.Entities | ||
{ | ||
public class ViewportTests | ||
{ | ||
[Fact] | ||
public void GetBoundingBoxTest() | ||
{ | ||
Viewport viewport = new Viewport(); | ||
viewport.Width = 100; | ||
viewport.Height = 50; | ||
viewport.Center = new XYZ(10, 10, 0); | ||
|
||
BoundingBox boundingBox = viewport.GetBoundingBox(); | ||
|
||
AssertUtils.AreEqual(viewport.Center, boundingBox.Center); | ||
AssertUtils.AreEqual(new XYZ(-40, -15, 0), boundingBox.Min); | ||
AssertUtils.AreEqual(new XYZ(60, 35, 0), boundingBox.Max); | ||
} | ||
|
||
[Fact] | ||
public void GetModelBoundingBoxTest() | ||
{ | ||
Viewport viewport = new Viewport(); | ||
viewport.Width = 100; | ||
viewport.Height = 50; | ||
viewport.ViewHeight = 50; | ||
viewport.ViewCenter = new XY(10, 10); | ||
|
||
BoundingBox boundingBox = viewport.GetModelBoundingBox(); | ||
|
||
Assert.Equal(100, viewport.ViewWidth); | ||
AssertUtils.AreEqual(viewport.ViewCenter, ((XY)boundingBox.Center)); | ||
AssertUtils.AreEqual(new XYZ(-40, -15, 0), boundingBox.Min); | ||
AssertUtils.AreEqual(new XYZ(60, 35, 0), boundingBox.Max); | ||
} | ||
|
||
[Fact] | ||
public void SelectEntitiesTest() | ||
{ | ||
CadDocument doc = new CadDocument(); | ||
|
||
Viewport viewport = new Viewport(); | ||
viewport.Width = 100; | ||
viewport.Height = 50; | ||
viewport.ViewHeight = 50; | ||
viewport.ViewCenter = new XY(10, 10); | ||
|
||
//Viewbox | ||
//min: -40, -15 | ||
//max: 60, 35 | ||
|
||
doc.PaperSpace.Entities.Add(viewport); | ||
|
||
//Entities in the view | ||
Point ptIn = new Point(new XYZ(0, 0, 0)); | ||
Line lineIn = new Line(new XYZ(), new XYZ(100, 100, 0)); | ||
|
||
List<Entity> inView = new List<Entity> | ||
{ | ||
ptIn, | ||
lineIn | ||
}; | ||
doc.Entities.AddRange(inView); | ||
|
||
//Entities out the view | ||
Point ptOut = new Point(new XYZ(100, 100, 0)); | ||
|
||
List<Entity> outView = new List<Entity> | ||
{ | ||
ptOut | ||
}; | ||
doc.Entities.AddRange(outView); | ||
|
||
var selected = viewport.SelectEntities(); | ||
|
||
Assert.NotEmpty(selected); | ||
|
||
foreach (Entity e in selected) | ||
{ | ||
Assert.Contains(e, inView); | ||
Assert.DoesNotContain(e, outView); | ||
} | ||
|
||
var selectedPartial = viewport.SelectEntities(false); | ||
Assert.DoesNotContain(lineIn, selectedPartial); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule CSUtilities
updated
7 files
+35 −0 | CSMath.Tests/BoundingBoxTests.cs | |
+1 −1 | CSMath.Tests/QuaternionTests.cs | |
+46 −0 | CSMath/BoundingBox.cs | |
+1 −1 | CSMath/CSMath.projitems | |
+1 −1 | CSMath/MathHelper.cs | |
+3 −3 | CSMath/Transform.cs | |
+1 −1 | CSMath/VectorExtensions.cs |