-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathSolidDefaultPickBehavior.cpp
More file actions
102 lines (86 loc) · 4.45 KB
/
Copy pathSolidDefaultPickBehavior.cpp
File metadata and controls
102 lines (86 loc) · 4.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include "SolidDefaultPickBehavior.h"
#include "AliceIRenderViewPortInput.h"
using namespace sdr;
using namespace alice;
SolidDefaultPickBehavior::SolidDefaultPickBehavior(SolidPickIntent intent, std::string viewKind)
: m_intent(intent)
, m_viewKind(std::move(viewKind))
{
}
SolidPickIntent SolidDefaultPickBehavior::GetIntent() const noexcept
{
return m_intent;
}
const std::string& SolidDefaultPickBehavior::GetViewKind() const noexcept
{
return m_viewKind;
}
bool SolidDefaultPickBehavior::ShouldAppendSelection(std::uint32_t modifiers) const noexcept
{
return (modifiers & static_cast<std::uint32_t>(RenderKeyModifier::Ctrl)) != 0u;
}
bool SolidDefaultPickBehavior::AcceptSelectionItem(const SelectionItem& item) const
{
return AcceptCommandSelectionInput(item.ToCommandSelectionInput());
}
bool SolidDefaultPickBehavior::AcceptCommandSelectionInput(const CommandSelectionInput& input) const
{
if (!input.Handle.TargetObjectId.IsValid())
return false;
const std::string primarySemanticRole = input.GetPrimarySemanticRole();
if (primarySemanticRole.empty())
return m_intent == SolidPickIntent::DefaultModeling;
switch (m_intent)
{
case SolidPickIntent::SketchPlaneInput:
return alice::MatchesAnySemanticRoleKind(primarySemanticRole, GetSketchSelectionSemanticRoleKinds()) || alice::MatchesAnySemanticRoleKind(primarySemanticRole, GetSketchPlaneSemanticRoleKinds());
case SolidPickIntent::OrientationReferenceInput:
return alice::MatchesAnySemanticRoleKind(primarySemanticRole, GetOrientationReferenceSemanticRoleKinds());
case SolidPickIntent::DefaultModeling:
default:
return alice::MatchesAnySemanticRoleKind(primarySemanticRole, DefaultModelingRoleKinds_());
}
}
const std::vector<SemanticRoleKind>& SolidDefaultPickBehavior::GetSketchSelectionSemanticRoleKinds() const
{
return SketchRoleKinds_();
}
const std::vector<SemanticRoleKind>& SolidDefaultPickBehavior::GetSketchPlaneSemanticRoleKinds() const
{
return SketchPlaneRoleKinds_();
}
const std::vector<SemanticRoleKind>& SolidDefaultPickBehavior::GetOrientationReferenceSemanticRoleKinds() const
{
return OrientationReferenceRoleKinds_();
}
const std::vector<SemanticRoleKind>& SolidDefaultPickBehavior::DefaultModelingRoleKinds_()
{
static const std::vector<SemanticRoleKind> v = { SemanticRoleKind::DatumPlane, SemanticRoleKind::DatumAxis, SemanticRoleKind::DatumPoint, SemanticRoleKind::DatumCsys,
SemanticRoleKind::ModelPlanarFace, SemanticRoleKind::ModelFace, SemanticRoleKind::ModelEdge, SemanticRoleKind::ModelVertex,
SemanticRoleKind::ModelBody, SemanticRoleKind::ModelCurve, SemanticRoleKind::ModelPoint, SemanticRoleKind::SketchRegion,
SemanticRoleKind::SketchCurve, SemanticRoleKind::SketchPoint, SemanticRoleKind::FeatureResult, SemanticRoleKind::FeatureBody,
SemanticRoleKind::FeatureFace, SemanticRoleKind::FeatureEdge, SemanticRoleKind::FeatureVertex, SemanticRoleKind::Component,
SemanticRoleKind::ComponentInstance, SemanticRoleKind::Occurrence };
return v;
}
const std::vector<SemanticRoleKind>& SolidDefaultPickBehavior::SketchRoleKinds_()
{
static const std::vector<SemanticRoleKind> v = { SemanticRoleKind::SketchRegion, SemanticRoleKind::SketchProfile,
SemanticRoleKind::SketchLoop, SemanticRoleKind::SketchChain, SemanticRoleKind::SketchCurve, SemanticRoleKind::SketchPoint,
SemanticRoleKind::Sketch, SemanticRoleKind::SketchFeature };
return v;
}
const std::vector<SemanticRoleKind>& SolidDefaultPickBehavior::SketchPlaneRoleKinds_()
{
static const std::vector<SemanticRoleKind> v = { SemanticRoleKind::DatumPlane, SemanticRoleKind::ModelPlanarFace,
SemanticRoleKind::ModelFace, SemanticRoleKind::FeatureFace, SemanticRoleKind::SketchRegion, SemanticRoleKind::SketchProfile };
return v;
}
const std::vector<SemanticRoleKind>& SolidDefaultPickBehavior::OrientationReferenceRoleKinds_()
{
static const std::vector<SemanticRoleKind> v = { SemanticRoleKind::DatumPlane, SemanticRoleKind::DatumAxis,
SemanticRoleKind::DatumPoint, SemanticRoleKind::DatumCsys, SemanticRoleKind::ModelPlanarFace, SemanticRoleKind::ModelFace,
SemanticRoleKind::ModelEdge, SemanticRoleKind::ModelVertex, SemanticRoleKind::FeatureFace, SemanticRoleKind::FeatureEdge,
SemanticRoleKind::FeatureVertex, SemanticRoleKind::SketchRegion, SemanticRoleKind::SketchCurve, SemanticRoleKind::SketchPoint };
return v;
}