Skip to content

Commit

Permalink
Update handling of section boxes
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgDangl committed Jul 16, 2024
1 parent 3779a40 commit 77cf838
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions src/IPA.Bcfier.Revit/Services/RevitViewpointDisplayService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ public RevitViewpointDisplayService(UIDocument uiDocument)
}

orthoView.SetOrientation(orient3D);

if (ShouldEnableSectionBox(bcfViewpoint))
{
orthoView.CropBoxActive = true;
orthoView.CropBoxVisible = true;
}
else
{
orthoView.CropBoxActive = false;
orthoView.CropBoxVisible = false;
}

trans.Commit();
}
}
Expand Down Expand Up @@ -123,8 +135,17 @@ public RevitViewpointDisplayService(UIDocument uiDocument)
Parameter m_farClip = perspView.get_Parameter(BuiltInParameter.VIEWER_BOUND_ACTIVE_FAR);
m_farClip.Set(0);
}
perspView.CropBoxActive = true;
perspView.CropBoxVisible = true;

if (ShouldEnableSectionBox(bcfViewpoint))
{
perspView.CropBoxActive = true;
perspView.CropBoxVisible = true;
}
else
{
perspView.CropBoxActive = false;
perspView.CropBoxVisible = false;
}

trans.Commit();
}
Expand Down Expand Up @@ -283,12 +304,30 @@ public string GetName()
// https://github.com/opf/openproject-revit-add-in/blob/93e117ad10176f4fffa741116733a3ee113e9335/src/OpenProject.Revit/Entry/OpenViewpointEventHandler.cs#L212
private const decimal _viewpointAngleThresholdRad = 0.087266462599716m;

private bool ShouldEnableSectionBox(BcfViewpoint bcfViewpoint)
{
if (bcfViewpoint.ClippingPlanes?.Count != 6)
{
return false;
}

AxisAlignedBoundingBox boundingBox = GetViewpointClippingBox(bcfViewpoint);
if (boundingBox.Equals(AxisAlignedBoundingBox.Infinite))
{
return false;
}

return true;
}

private void ApplyClippingPlanes(UIDocument uiDocument, View3D view, BcfViewpoint bcfViewpoint)
{
if (bcfViewpoint.ClippingPlanes?.Count != 6)
{
// Don't apply section box if it's not a full box
view.IsSectionBoxActive = false;
view.CropBoxActive = false;
view.CropBoxVisible = false;
return;
}

Expand All @@ -302,6 +341,8 @@ private void ApplyClippingPlanes(UIDocument uiDocument, View3D view, BcfViewpoin
else
{
view.IsSectionBoxActive = false;
view.CropBoxActive = false;
view.CropBoxVisible = false;
}
}

Expand Down

0 comments on commit 77cf838

Please sign in to comment.