diff --git a/Alice b/Alice index 84c8f9a1..3733b50a 160000 --- a/Alice +++ b/Alice @@ -1 +1 @@ -Subproject commit 84c8f9a1025b40e2c9fca884cadec05b1a321b28 +Subproject commit 3733b50a6cc4de8ef5794f16528ab731ea4e11c2 diff --git a/Designer/Interaction/SolidDesignerInteraction/SolidDefaultPickBehavior.cpp b/Designer/Interaction/SolidDesignerInteraction/SolidDefaultPickBehavior.cpp deleted file mode 100644 index 9636fa4c..00000000 --- a/Designer/Interaction/SolidDesignerInteraction/SolidDefaultPickBehavior.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#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(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& SolidDefaultPickBehavior::GetSketchSelectionSemanticRoleKinds() const -{ - return SketchRoleKinds_(); -} - -const std::vector& SolidDefaultPickBehavior::GetSketchPlaneSemanticRoleKinds() const -{ - return SketchPlaneRoleKinds_(); -} - -const std::vector& SolidDefaultPickBehavior::GetOrientationReferenceSemanticRoleKinds() const -{ - return OrientationReferenceRoleKinds_(); -} - -const std::vector& SolidDefaultPickBehavior::DefaultModelingRoleKinds_() -{ - static const std::vector 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& SolidDefaultPickBehavior::SketchRoleKinds_() -{ - static const std::vector v = { SemanticRoleKind::SketchRegion, SemanticRoleKind::SketchProfile, - SemanticRoleKind::SketchLoop, SemanticRoleKind::SketchChain, SemanticRoleKind::SketchCurve, SemanticRoleKind::SketchPoint, - SemanticRoleKind::Sketch, SemanticRoleKind::SketchFeature }; - return v; -} - -const std::vector& SolidDefaultPickBehavior::SketchPlaneRoleKinds_() -{ - static const std::vector v = { SemanticRoleKind::DatumPlane, SemanticRoleKind::ModelPlanarFace, - SemanticRoleKind::ModelFace, SemanticRoleKind::FeatureFace, SemanticRoleKind::SketchRegion, SemanticRoleKind::SketchProfile }; - return v; -} - -const std::vector& SolidDefaultPickBehavior::OrientationReferenceRoleKinds_() -{ - static const std::vector 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; -} diff --git a/Designer/Interaction/SolidDesignerInteraction/SolidDefaultPickBehavior.h b/Designer/Interaction/SolidDesignerInteraction/SolidDefaultPickBehavior.h deleted file mode 100644 index d4094f0e..00000000 --- a/Designer/Interaction/SolidDesignerInteraction/SolidDefaultPickBehavior.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include "SolidDesignerInteraction.h" - -#include "AliceISelectionManager.h" -#include "AliceSemanticRoleKind.h" - -#include -#include -#include - -namespace sdr -{ - enum class SolidPickIntent { DefaultModeling, SketchPlaneInput, OrientationReferenceInput }; - - class SOLID_DESIGNER_INTERACTION_EXPORT SolidDefaultPickBehavior - { - public: - explicit SolidDefaultPickBehavior(SolidPickIntent intent = SolidPickIntent::DefaultModeling, std::string viewKind = {}); - SolidPickIntent GetIntent() const noexcept; - const std::string& GetViewKind() const noexcept; - bool ShouldAppendSelection(std::uint32_t modifiers) const noexcept; - bool AcceptSelectionItem(const alice::SelectionItem& item) const; - bool AcceptCommandSelectionInput(const alice::CommandSelectionInput& input) const; - const std::vector& GetSketchSelectionSemanticRoleKinds() const; - const std::vector& GetSketchPlaneSemanticRoleKinds() const; - const std::vector& GetOrientationReferenceSemanticRoleKinds() const; - private: - static const std::vector& DefaultModelingRoleKinds_(); - static const std::vector& SketchRoleKinds_(); - static const std::vector& SketchPlaneRoleKinds_(); - static const std::vector& OrientationReferenceRoleKinds_(); - private: - SolidPickIntent m_intent{ SolidPickIntent::DefaultModeling }; - std::string m_viewKind; - }; -} diff --git a/Designer/Interaction/SolidDesignerInteraction/SolidDefaultPickOperation.cpp b/Designer/Interaction/SolidDesignerInteraction/SolidDefaultPickOperation.cpp index 2bc4b138..1d9a5a03 100644 --- a/Designer/Interaction/SolidDesignerInteraction/SolidDefaultPickOperation.cpp +++ b/Designer/Interaction/SolidDesignerInteraction/SolidDefaultPickOperation.cpp @@ -1,88 +1,19 @@ #include "SolidDefaultPickOperation.h" #include "AliceOperationKeyBehavior.h" -#include "SolidOperationInputAdapter.h" -#include "AliceCoreAppUtil.h" -#include "AliceISession.h" #include "AliceISelectionManager.h" #include "AliceIPickingManager.h" -#include "AliceIHighlightManager.h" +#include "AliceIPickCandidate.h" #include "AliceOperationModifierQuery.h" #include #include -#include -#include "AliceVector3d.h" using namespace sdr; using namespace alice; -namespace -{ - static bool HasModifier_(std::uint32_t modifiers, RenderKeyModifier flag) noexcept - { - return (modifiers & static_cast(flag)) != 0u; - } - - static bool AllowsByFilter_(const PickHit& hit, const SolidSemanticPickFilter& pickFilter) - { - PickTargetOptions options{}; - pickFilter.ConfigurePickTargets(options); - if (!options.Allows(hit.Kind) || !pickFilter.AllowHit(hit)) - { - return false; - } - - RepresentationNodeReference node{}; - node.TargetObjectId = hit.TargetObjectId; - node.RepresentationNodeToken = hit.RepresentationNodeToken; - node.RepresentationNodeSemanticRole = hit.RepresentationNodeSemanticRole; - node.RepresentationNodePathToken = hit.RepresentationNodePathToken; - node.SubElementToken = hit.SubElementToken; - node.ModelElementStableIdentity = hit.ModelElementStableIdentity; - node.PersistentEntityId = hit.PersistentEntityId; - node.TopoSemanticRef = hit.TopoSemanticRef; - node.RuntimeInstanceId = hit.RuntimeInstanceId; - node.PrimitiveId = hit.PrimitiveId; - node.DisplayInstanceToken = hit.DisplayInstanceToken; - return pickFilter.AllowRepresentationNode(node); - } - - static bool TryResolveCyclingCandidate_(IPickingManager* pPickingManager, - const SolidSemanticPickFilter& pickFilter, - std::size_t candidateIndex, - PickHit& outHit) - { - if (pPickingManager == nullptr) - { - return false; - } - - std::vector candidates = pPickingManager->GetCandidateHits(); - std::vector filtered; - filtered.reserve(candidates.size()); - for (const PickHit& hit : candidates) - { - if (AllowsByFilter_(hit, pickFilter)) - { - filtered.push_back(hit); - } - } - if (filtered.empty()) - { - return false; - } - - const std::size_t safeIndex = candidateIndex % filtered.size(); - outHit = filtered[safeIndex]; - return true; - } -} - -SolidDefaultPickOperation::SolidDefaultPickOperation(std::string viewKind) - : m_viewKind(std::move(viewKind)) - , m_behavior(SolidPickIntent::DefaultModeling, m_viewKind) - , m_pickFilter(SolidPickIntent::DefaultModeling) +SolidDefaultPickOperation::SolidDefaultPickOperation() + : m_pickFilter(SolidPickIntent::DefaultModeling) { } @@ -93,46 +24,38 @@ void SolidDefaultPickOperation::InitOperation(IUiView* pCurrentView) PickOperationBase::InitOperation(pCurrentView); m_bFinished = false; m_dragAnchor = {}; - m_isLeftDragging = false; - m_cycleCandidateIndex = 0u; + m_bLeftButtonDown = false; + m_bLeftDragging = false; ClearCapturedPickCandidates(); - ClearLastPickHit(); - ClearPreselectionFeedback(); - ClearSnapFeedback(); + ClearPreselectionHighlight(); + ClearSnapPresentation(); } void SolidDefaultPickOperation::OnCancel() { ClearCapturedPickCandidates(); - ClearLastPickHit(); - ClearPreselectionFeedback(); - ClearSnapFeedback(); + ClearPreselectionHighlight(); + ClearSnapPresentation(); + m_bLeftButtonDown = false; + m_bLeftDragging = false; } bool SolidDefaultPickOperation::OnLButtonDown(IUiView* pCurrentView, const Vector3d& pos) { m_dragAnchor = pos; - m_isLeftDragging = false; - m_cycleCandidateIndex = 0u; + m_bLeftButtonDown = true; + m_bLeftDragging = false; return RefreshPickCandidates(pCurrentView, pos, m_pickFilter) && UpdatePreselection(m_pickFilter); } bool SolidDefaultPickOperation::OnMovePoint(IUiView* pCurrentView, const Vector3d& pos) { - std::int32_t screenX = 0; - std::int32_t screenY = 0; - std::uint32_t buttons = 0u; - std::uint32_t modifiers = 0u; - (void)sdr::detail::TryGetCurrentScreenPoint(screenX, screenY, &buttons, &modifiers); - - const bool isLeftPressed = (buttons & static_cast(RenderMouseButton::Left)) != 0u; - if (isLeftPressed) + if (m_bLeftButtonDown) { - m_isLeftDragging = IsDragGesture_(m_dragAnchor, pos); - if (m_isLeftDragging) + m_bLeftDragging = IsDragGesture_(m_dragAnchor, pos); + if (m_bLeftDragging) { - ClearPreselectionFeedback(); - m_cycleCandidateIndex = 0u; + ClearPreselectionHighlight(); return RefreshPickCandidates(pCurrentView, m_dragAnchor, pos, @@ -141,11 +64,10 @@ bool SolidDefaultPickOperation::OnMovePoint(IUiView* pCurrentView, const Vector3 } } - m_isLeftDragging = false; - m_cycleCandidateIndex = 0u; + m_bLeftDragging = false; if (!RefreshPickCandidates(pCurrentView, pos, m_pickFilter)) { - ClearPreselectionFeedback(); + ClearPreselectionHighlight(); return false; } return UpdateCurrentPreselectionFromCandidates_(); @@ -153,30 +75,27 @@ bool SolidDefaultPickOperation::OnMovePoint(IUiView* pCurrentView, const Vector3 bool SolidDefaultPickOperation::OnLButtonUp(IUiView* pCurrentView, const Vector3d& pos) { - std::int32_t screenX = 0; - std::int32_t screenY = 0; - std::uint32_t buttons = 0u; - std::uint32_t modifiers = 0u; - (void)sdr::detail::TryGetCurrentScreenPoint(screenX, screenY, &buttons, &modifiers); + const std::uint32_t nModifiers = alice::QueryCurrentKeyboardModifiers(); - const bool appendSelection = HasModifier_(modifiers, RenderKeyModifier::Shift); - const bool toggleSelection = HasModifier_(modifiers, RenderKeyModifier::Ctrl); + const bool bAppendSelection = HasModifier_(nModifiers, RenderKeyModifier::Shift); + const bool bToggleSelection = HasModifier_(nModifiers, RenderKeyModifier::Ctrl); - bool handled = false; - if (m_isLeftDragging && IsDragGesture_(m_dragAnchor, pos)) + bool bHandled = false; + if (m_bLeftDragging && IsDragGesture_(m_dragAnchor, pos)) { - handled = CommitBoxSelection_(pCurrentView, pos); + bHandled = CommitBoxSelection_(pCurrentView, pos); } else { if (RefreshPickCandidates(pCurrentView, pos, m_pickFilter)) { - handled = CommitSelection(m_pickFilter, appendSelection, toggleSelection); + bHandled = CommitSelection(m_pickFilter, bAppendSelection, bToggleSelection); } } - m_isLeftDragging = false; - return handled; + m_bLeftButtonDown = false; + m_bLeftDragging = false; + return bHandled; } bool SolidDefaultPickOperation::IsFinished() const noexcept @@ -184,39 +103,15 @@ bool SolidDefaultPickOperation::IsFinished() const noexcept return m_bFinished; } -bool SolidDefaultPickOperation::HandlePointerMove_(IUiView* pCurrentView, const Vector3d& pos) -{ - return OnMovePoint(pCurrentView, pos); -} - -bool SolidDefaultPickOperation::HandlePointerCommit_(IUiView* pCurrentView, const Vector3d& pos) -{ - return OnLButtonUp(pCurrentView, pos); -} - -bool SolidDefaultPickOperation::ShouldAppendSelection_() const noexcept -{ - std::int32_t x = 0; - std::int32_t y = 0; - std::uint32_t buttons = 0u; - std::uint32_t modifiers = 0u; - if (!sdr::detail::TryGetCurrentScreenPoint(x, y, &buttons, &modifiers)) - { - return false; - } - return HasModifier_(modifiers, RenderKeyModifier::Shift); -} - void SolidDefaultPickOperation::ClearInvalidPreselection_() const { if (ISelectionManager* const pSelectionManager = ResolveSelectionManager()) { - if (const auto preselection = pSelectionManager->GetPreselectionInput(); preselection.has_value()) + std::unique_ptr upPreselection = + pSelectionManager->GetPreselectionReference(); + if (upPreselection && !upPreselection->IsValid()) { - if (!m_behavior.AcceptCommandSelectionInput(preselection.value())) - { - pSelectionManager->ClearPreselection(); - } + pSelectionManager->ClearPreselection(); } } } @@ -224,14 +119,21 @@ void SolidDefaultPickOperation::ClearInvalidPreselection_() const bool SolidDefaultPickOperation::UpdateCurrentPreselectionFromCandidates_() const { IPickingManager* const pPickingManager = ResolvePickingManager(); - PickHit hit; - if (!TryResolveCyclingCandidate_(pPickingManager, m_pickFilter, 0u, hit)) + if (pPickingManager == nullptr) { - ClearPreselectionFeedback(); + ClearPreselectionHighlight(); return false; } - if (!ApplyPreselection(hit)) + std::unique_ptr upCandidate = + pPickingManager->MoveToDefaultRepresentationNodeCandidate(&m_pickFilter); + if (upCandidate == nullptr) + { + ClearPreselectionHighlight(); + return false; + } + + if (!ApplyPreselection(*upCandidate)) { return false; } @@ -241,59 +143,68 @@ bool SolidDefaultPickOperation::UpdateCurrentPreselectionFromCandidates_() const bool SolidDefaultPickOperation::CommitBoxSelection_(IUiView* pCurrentView, const Vector3d& endPos) { - std::int32_t x = 0; - std::int32_t y = 0; - std::uint32_t buttons = 0u; - std::uint32_t modifiers = 0u; - (void)sdr::detail::TryGetCurrentScreenPoint(x, y, &buttons, &modifiers); + const std::uint32_t nModifiers = alice::QueryCurrentKeyboardModifiers(); - const bool appendSelection = HasModifier_(modifiers, RenderKeyModifier::Shift); - const bool toggleSelection = HasModifier_(modifiers, RenderKeyModifier::Ctrl); + const bool bAppendSelection = HasModifier_(nModifiers, RenderKeyModifier::Shift); + const bool bToggleSelection = HasModifier_(nModifiers, RenderKeyModifier::Ctrl); if (!RefreshPickCandidates(pCurrentView, m_dragAnchor, endPos, PickBoxStyle::Directional, m_pickFilter)) { return false; } - return CommitSelectionFromCandidateHits(m_pickFilter, appendSelection, toggleSelection, false); + return CommitSelectionFromCandidates(m_pickFilter, bAppendSelection, bToggleSelection, false); +} + +bool SolidDefaultPickOperation::HasModifier_(std::uint32_t nModifiers, + RenderKeyModifier eModifier) noexcept +{ + return (nModifiers & static_cast(eModifier)) != 0u; } bool SolidDefaultPickOperation::IsDragGesture_(const Vector3d& beginPos, const Vector3d& endPos) noexcept { - const double dx = endPos.X() - beginPos.X(); - const double dy = endPos.Y() - beginPos.Y(); - return std::sqrt(dx * dx + dy * dy) >= 6.0; + const double dDeltaX = endPos.X() - beginPos.X(); + const double dDeltaY = endPos.Y() - beginPos.Y(); + return std::sqrt(dDeltaX * dDeltaX + dDeltaY * dDeltaY) >= 6.0; } bool SolidDefaultPickOperation::OnKeyDown(IUiView* pCurrentView, std::int32_t keyCode) { - const std::uint32_t modifiers = alice::QueryCurrentKeyboardModifiers(); + const std::uint32_t nModifiers = alice::QueryCurrentKeyboardModifiers(); if (SolidOperationKeyBehavior::IsEscape(keyCode)) { ClearCommittedSelection(); ClearCommittedSelectionHighlight(); - ClearPreselectionFeedback(); - ClearSnapFeedback(); + ClearPreselectionHighlight(); + ClearSnapPresentation(); ClearCapturedPickCandidates(); - ClearLastPickHit(); return true; } if (static_cast(keyCode) == InputKeyCode::Tab) { IPickingManager* const pPickingManager = ResolvePickingManager(); - PickHit cycledHit; - ++m_cycleCandidateIndex; - if (TryResolveCyclingCandidate_(pPickingManager, m_pickFilter, m_cycleCandidateIndex, cycledHit)) + if (pPickingManager == nullptr) + { + return false; + } + + const bool bUsePreviousCandidate = + (nModifiers & static_cast(RenderKeyModifier::Shift)) != 0u; + std::unique_ptr upCandidate = bUsePreviousCandidate + ? pPickingManager->MoveToPreviousRepresentationNodeCandidate(&m_pickFilter) + : pPickingManager->MoveToNextRepresentationNodeCandidate(&m_pickFilter); + if (upCandidate != nullptr) { - return ApplyPreselection(cycledHit); + return ApplyPreselection(*upCandidate); } return false; } - if (SolidOperationKeyBehavior::IsUndo(keyCode, modifiers)) + if (SolidOperationKeyBehavior::IsUndo(keyCode, nModifiers)) { return SolidOperationKeyBehavior::ExecuteUndo(); } - if (SolidOperationKeyBehavior::IsRedo(keyCode, modifiers)) + if (SolidOperationKeyBehavior::IsRedo(keyCode, nModifiers)) { return SolidOperationKeyBehavior::ExecuteRedo(); } diff --git a/Designer/Interaction/SolidDesignerInteraction/SolidDefaultPickOperation.h b/Designer/Interaction/SolidDesignerInteraction/SolidDefaultPickOperation.h index 0fe0ebd5..c8ac44ca 100644 --- a/Designer/Interaction/SolidDesignerInteraction/SolidDefaultPickOperation.h +++ b/Designer/Interaction/SolidDesignerInteraction/SolidDefaultPickOperation.h @@ -2,11 +2,9 @@ #include "SolidDesignerInteraction.h" #include "AlicePickOperationBase.h" -#include "SolidDefaultPickBehavior.h" +#include "AliceIRenderViewPortInput.h" #include "SolidPickFilters.h" -#include -#include #include "AliceVector3d.h" namespace sdr @@ -19,7 +17,7 @@ namespace sdr class SOLID_DESIGNER_INTERACTION_EXPORT SolidDefaultPickOperation final : public alice::PickOperationBase { public: - explicit SolidDefaultPickOperation(std::string viewKind = {}); + SolidDefaultPickOperation(); ~SolidDefaultPickOperation() override; void InitOperation(alice::IUiView* pCurrentView) override; @@ -32,23 +30,19 @@ namespace sdr bool IsFinished() const noexcept override; private: - bool HandlePointerMove_(alice::IUiView* pCurrentView, const alice::Vector3d& pos); - bool HandlePointerCommit_(alice::IUiView* pCurrentView, const alice::Vector3d& pos); - bool ShouldAppendSelection_() const noexcept; void ClearInvalidPreselection_() const; private: bool UpdateCurrentPreselectionFromCandidates_() const; bool CommitBoxSelection_(alice::IUiView* pCurrentView, const alice::Vector3d& endPos); + static bool HasModifier_(std::uint32_t nModifiers, alice::RenderKeyModifier eModifier) noexcept; static bool IsDragGesture_(const alice::Vector3d& beginPos, const alice::Vector3d& endPos) noexcept; private: - std::string m_viewKind; - SolidDefaultPickBehavior m_behavior; SolidSemanticPickFilter m_pickFilter; alice::Vector3d m_dragAnchor{}; - bool m_isLeftDragging = false; - std::size_t m_cycleCandidateIndex = 0u; + bool m_bLeftButtonDown = false; + bool m_bLeftDragging = false; bool m_bFinished = false; }; } diff --git a/Designer/Interaction/SolidDesignerInteraction/SolidExtrudeCreateOperation.cpp b/Designer/Interaction/SolidDesignerInteraction/SolidExtrudeCreateOperation.cpp index 9384b812..469bc871 100644 --- a/Designer/Interaction/SolidDesignerInteraction/SolidExtrudeCreateOperation.cpp +++ b/Designer/Interaction/SolidDesignerInteraction/SolidExtrudeCreateOperation.cpp @@ -262,12 +262,10 @@ void SolidExtrudeCreateOperation::InitOperation(IUiView* pCurrentView) (void)EnsureExtrudeDefinitionEditSession_(); (void)EnterDashboardUi_(); - ObjectId planeId; - std::string selectionKey; - std::string semanticRole; - if (TryResolveSketchPlaneFromSelection_(planeId, selectionKey, semanticRole)) + std::unique_ptr upPlaneReference; + if (TryResolveSketchPlaneFromSelection_(upPlaneReference)) { - (void)StartSectionPlacement_(planeId, selectionKey, semanticRole); + (void)StartSectionPlacement_(std::move(upPlaneReference)); return; } (void)BeginDefineInternalSketchPlacement(); @@ -378,10 +376,12 @@ void SolidExtrudeCreateOperation::OnChildOperationFinished(const OperationResult if (const auto* const pPick = dynamic_cast(childResult.Payload.get())) { - if (childResult.FinishStatus == OperationFinishStatus::Successful && pPick->ReferenceId.IsValid()) + if (childResult.FinishStatus == OperationFinishStatus::Successful && + pPick->ChosenReference && + pPick->ChosenReference->IsValid()) { m_bUseExistingSketchSection = true; - m_idSectionSourceSketchFeature = pPick->ReferenceId; + m_idSectionSourceSketchFeature = pPick->ChosenReference->GetTargetObjectId(); (void)BuildOrRefreshPreview_(); (void)EnterDashboardUi_(); m_stage = ExtrudeWorkflowStage::PreviewingDashboard; @@ -613,24 +613,25 @@ void SolidExtrudeCreateOperation::InitializeSketchPlacementContextFromActiveView } } -bool SolidExtrudeCreateOperation::TryResolveSketchPlaneFromSelection_(ObjectId& outPlaneId, std::string& outKey, std::string& outRole) const +bool SolidExtrudeCreateOperation::TryResolveSketchPlaneFromSelection_( + std::unique_ptr& outPlaneReference) const { ISelectionManager* const pSelectionManager = m_pSession ? m_pSession->GetSelectionManagerFw() : nullptr; if (!pSelectionManager) return false; - if (auto pre = pSelectionManager->GetPreselectionInput(); pre.has_value()) + + outPlaneReference = pSelectionManager->GetPreselectionReference(); + if (outPlaneReference && outPlaneReference->IsValid()) { - outPlaneId = pre->Handle.TargetObjectId; - outKey = pre->GetPrimarySelectionToken(); - outRole = pre->GetPrimarySemanticRole(); - return outPlaneId.IsValid(); + return true; } - const auto selections = pSelectionManager->GetSelectionInputs(); - if (!selections.empty()) + outPlaneReference.reset(); + + std::vector> vecReferences = + pSelectionManager->GetSelectedReferences(); + if (!vecReferences.empty() && vecReferences.front() && vecReferences.front()->IsValid()) { - outPlaneId = selections.front().Handle.TargetObjectId; - outKey = selections.front().GetPrimarySelectionToken(); - outRole = selections.front().GetPrimarySemanticRole(); - return outPlaneId.IsValid(); + outPlaneReference = std::move(vecReferences.front()); + return true; } return false; } @@ -860,10 +861,12 @@ bool SolidExtrudeCreateOperation::RestoreDefaultModelingInteraction_() return ExitCreationUiToHome_(); } -bool SolidExtrudeCreateOperation::StartSectionPlacement_(ObjectId preselectedPlaneId, std::string preselectedPlaneKey, std::string preselectedPlaneRole) +bool SolidExtrudeCreateOperation::StartSectionPlacement_( + std::unique_ptr upPreselectedPlane) { m_stage = ExtrudeWorkflowStage::DefiningSectionPlacement; - return StartChildOperation(std::make_unique(preselectedPlaneId, std::move(preselectedPlaneKey), std::move(preselectedPlaneRole))); + return StartChildOperation( + std::make_unique(std::move(upPreselectedPlane))); } bool SolidExtrudeCreateOperation::StartExistingSketchSelection_() diff --git a/Designer/Interaction/SolidDesignerInteraction/SolidExtrudeCreateOperation.h b/Designer/Interaction/SolidDesignerInteraction/SolidExtrudeCreateOperation.h index 873efe68..95c87758 100644 --- a/Designer/Interaction/SolidDesignerInteraction/SolidExtrudeCreateOperation.h +++ b/Designer/Interaction/SolidDesignerInteraction/SolidExtrudeCreateOperation.h @@ -6,6 +6,7 @@ #include "AliceObjectId.h" #include "AliceFeaturePrimitives.h" #include "AliceFeatureAuthoringInputs.h" +#include "AliceIRepresentationNodeReference.h" #include "AliceIRepresentationRecord.h" #include "SolidSketchEditState.h" #include "SolidExtrudeCommitDataBuilder.h" @@ -13,6 +14,8 @@ #include "SolidSketchPlacementContext.h" #include "SolidSketchSectionTypes.h" +#include + namespace alice { class ISession; @@ -105,7 +108,8 @@ namespace sdr bool RouteWorkflowCommand_(const std::string& commandId); void PrimeInputsFromParameters_(); void InitializeSketchPlacementContextFromActiveView_(); - bool TryResolveSketchPlaneFromSelection_(alice::ObjectId& outPlaneId, std::string& outKey, std::string& outRole) const; + bool TryResolveSketchPlaneFromSelection_( + std::unique_ptr& outPlaneReference) const; bool EnsureSketchEditSession_(); bool EnsureExtrudeDefinitionEditSession_(); void SyncSketchEditSessionFromState_(); @@ -116,7 +120,8 @@ namespace sdr bool EnterDashboardUi_(); bool ExitCreationUiToHome_(); bool RestoreDefaultModelingInteraction_(); - bool StartSectionPlacement_(alice::ObjectId preselectedPlaneId = {}, std::string preselectedPlaneKey = {}, std::string preselectedPlaneRole = {}); + bool StartSectionPlacement_( + std::unique_ptr upPreselectedPlane = nullptr); bool StartExistingSketchSelection_(); bool StartSectionEdit_(); bool BuildOrRefreshPreview_(); diff --git a/Designer/Interaction/SolidDesignerInteraction/SolidHostedSketchDisplayCoordinator.cpp b/Designer/Interaction/SolidDesignerInteraction/SolidHostedSketchDisplayCoordinator.cpp index 2cee25d5..31f2e45c 100644 --- a/Designer/Interaction/SolidDesignerInteraction/SolidHostedSketchDisplayCoordinator.cpp +++ b/Designer/Interaction/SolidDesignerInteraction/SolidHostedSketchDisplayCoordinator.cpp @@ -6,12 +6,14 @@ #include "AliceRepresentationRecord.h" #include "AliceRepresentationGroupNode.h" #include "AliceCurveRepresentationNode.h" +#include "AliceRepresentationNodeIdFactory.h" #include "AliceVector3d.h" #include "AliceSemanticRoleId.h" #include "AliceISketchInteractionController.h" #include #include +#include #include using namespace sdr; @@ -19,6 +21,11 @@ using namespace alice; namespace { + constexpr std::uint32_t kDraftLineNodeOrdinal = 1u; + constexpr std::uint32_t kDraftCircleNodeOrdinal = 2u; + constexpr std::uint32_t kDraftRectangleNodeOrdinal = 3u; + constexpr std::uint32_t kDraftEllipseNodeOrdinal = 4u; + static alice::Vector3d MakeVec3(double x, double y, double z) { return alice::Vector3d(x, y, z); @@ -93,13 +100,6 @@ namespace return values; } - static std::uint64_t HashSketchNodeId_(alice::ObjectId idObject, const std::string& token) - { - const std::uint64_t seed = static_cast(idObject.RawValue()); - const std::uint64_t hash = static_cast(std::hash{}(token)); - return seed ^ (hash + 0x9e3779b97f4a7c15ULL + (seed << 6u) + (seed >> 2u)); - } - static double ResolveGripHalfSize(const SolidSketchPlacementContext& context, bool highlighted) { const double pixels = highlighted ? 6.0 : 4.0; @@ -108,8 +108,10 @@ namespace } static std::shared_ptr BuildPolylineNode(alice::ObjectId idObject, + std::uint64_t nNodeId, const std::string& name, const std::string& role, + alice::SemanticRoleId eSemanticRole, const std::string& token, const std::vector& points) { @@ -119,10 +121,10 @@ namespace } auto pNode = std::make_shared(); - pNode->SetPersistentNodeId(HashSketchNodeId_(idObject, token)); + pNode->SetPersistentNodeId(nNodeId); pNode->SetOwnerObjectId(idObject); pNode->SetDebugName(name); - pNode->SetSemanticRole(role); + pNode->SetSemanticRoleId(eSemanticRole); pNode->SetCurveBindingToken(token); pNode->SetCurveStyleTokenStorage(role); pNode->SetSampledPolylineXs(ScaleCoords(points, 0)); @@ -150,25 +152,34 @@ std::shared_ptr SolidHostedSketchDisplayCoord pRecord->SetDebugLabel("extrude.hosted-sketch.preview"); auto pRoot = std::make_shared(); - pRoot->SetPersistentNodeId(HashSketchNodeId_(idObject, "extrude.hosted-sketch.root")); + pRoot->SetPersistentNodeId(alice::rep::RepresentationNodeIdFactory::ForRole( + idObject, alice::SemanticRoleId::Sketch)); pRoot->SetOwnerObjectId(idObject); pRoot->SetDebugName("extrude.hosted-sketch.root"); - pRoot->SetSemanticRole("sketch.root"); + pRoot->SetSemanticRoleId(alice::SemanticRoleId::Sketch); pRoot->SetGroupTag("sketch.preview"); pRoot->SetIsCadNode(true); SolidSketchRepresentationProjection::AppendProjectedSketchCurves(*pRoot, idObject, placementContext, sketchEditState.GetSketch()); - auto appendPolyline = [&](const std::string& token, const std::string& role, const std::vector& points) + auto appendPolyline = [&](std::uint64_t nNodeId, + const std::string& token, + const std::string& role, + alice::SemanticRoleId eSemanticRole, + const std::vector& points) { if (points.size() < 2u) return; - if (auto pNode = BuildPolylineNode(idObject, token, role, token, points)) + if (auto pNode = BuildPolylineNode(idObject, nNodeId, token, role, eSemanticRole, token, points)) { pRoot->AppendChild(pNode); } }; - auto appendSampledCurve = [&](const std::string& token, const std::string& role, auto evaluator) + auto appendSampledCurve = [&](std::uint64_t nNodeId, + const std::string& token, + const std::string& role, + alice::SemanticRoleId eSemanticRole, + auto evaluator) { std::vector points; constexpr int kSegments = 48; @@ -178,7 +189,7 @@ std::shared_ptr SolidHostedSketchDisplayCoord const double t = static_cast(i) / static_cast(kSegments); points.push_back(MapSketchPointToWorld_(placementContext, evaluator(t))); } - appendPolyline(token, role, points); + appendPolyline(nNodeId, token, role, eSemanticRole, points); }; const SolidSketchLineDraft& lineDraft = sketchEditState.GetLineDraft(); @@ -188,7 +199,9 @@ std::shared_ptr SolidHostedSketchDisplayCoord const double dy = lineDraft.Current.Y() - lineDraft.Start.Y(); if ((dx * dx + dy * dy) > 1.0e-18) { - appendPolyline("draft.line", "sketch.draft.curve", + appendPolyline(alice::rep::RepresentationNodeIdFactory::ForRole( + idObject, alice::SemanticRoleId::SketchCurve, kDraftLineNodeOrdinal), + "draft.line", "sketch.draft.curve", alice::SemanticRoleId::SketchCurve, { MapSketchPointToWorld_(placementContext, lineDraft.Start), MapSketchPointToWorld_(placementContext, lineDraft.Current) }); } @@ -202,7 +215,9 @@ std::shared_ptr SolidHostedSketchDisplayCoord const double radius = std::sqrt(dx * dx + dy * dy); if (radius > 1.0e-9) { - appendSampledCurve("draft.circle", "sketch.draft.curve", + appendSampledCurve(alice::rep::RepresentationNodeIdFactory::ForRole( + idObject, alice::SemanticRoleId::SketchCurve, kDraftCircleNodeOrdinal), + "draft.circle", "sketch.draft.curve", alice::SemanticRoleId::SketchCurve, [&](double t) { const double angle = t * 2.0 * alice::kPi; @@ -219,7 +234,9 @@ std::shared_ptr SolidHostedSketchDisplayCoord const alice::SketchPoint2d p1{ rectangleDraft.Corner1.X(), rectangleDraft.Corner0.Y() }; const alice::SketchPoint2d p2 = rectangleDraft.Corner1; const alice::SketchPoint2d p3{ rectangleDraft.Corner0.X(), rectangleDraft.Corner1.Y() }; - appendPolyline("draft.rectangle", "sketch.draft.curve", + appendPolyline(alice::rep::RepresentationNodeIdFactory::ForRole( + idObject, alice::SemanticRoleId::SketchCurve, kDraftRectangleNodeOrdinal), + "draft.rectangle", "sketch.draft.curve", alice::SemanticRoleId::SketchCurve, { MapSketchPointToWorld_(placementContext, p0), MapSketchPointToWorld_(placementContext, p1), MapSketchPointToWorld_(placementContext, p2), @@ -234,7 +251,9 @@ std::shared_ptr SolidHostedSketchDisplayCoord const double radiusY = std::abs(ellipseDraft.Current.Y() - ellipseDraft.Center.Y()); if (radiusX > 1.0e-9 && radiusY > 1.0e-9) { - appendSampledCurve("draft.ellipse", "sketch.draft.curve", + appendSampledCurve(alice::rep::RepresentationNodeIdFactory::ForRole( + idObject, alice::SemanticRoleId::SketchCurve, kDraftEllipseNodeOrdinal), + "draft.ellipse", "sketch.draft.curve", alice::SemanticRoleId::SketchCurve, [&](double t) { const double angle = t * 2.0 * alice::kPi; @@ -264,9 +283,13 @@ std::shared_ptr SolidHostedSketchDisplayCoord const alice::Vector3d dx = hasGripFrame ? (gripXAxis * halfSize) : alice::Vector3d(halfSize, 0.0, 0.0); const alice::Vector3d dy = hasGripFrame ? (gripYAxis * halfSize) : alice::Vector3d(0.0, halfSize, 0.0); const std::string token = grip.Token.empty() ? (std::string("grip.") + std::to_string(index)) : grip.Token; - const std::string role = std::string(alice::ToStableSemanticRoleText(grip.Highlighted ? alice::SemanticRoleId::SketchSnapPoint - : alice::SemanticRoleId::SketchControlPoint)); - appendPolyline(token + ".box", role, + const alice::SemanticRoleId eRole = grip.Highlighted + ? alice::SemanticRoleId::SketchSnapPoint + : alice::SemanticRoleId::SketchControlPoint; + const std::string role = std::string(alice::ToStableSemanticRoleText(eRole)); + appendPolyline(alice::rep::RepresentationNodeIdFactory::ForGuid( + idObject, eRole, grip.OwnerEntityId, static_cast(index)), + token + ".box", role, eRole, { center - dx - dy, center + dx - dy, center + dx + dy, diff --git a/Designer/Interaction/SolidDesignerInteraction/SolidOperationInputAdapter.h b/Designer/Interaction/SolidDesignerInteraction/SolidOperationInputAdapter.h deleted file mode 100644 index c1dd0803..00000000 --- a/Designer/Interaction/SolidDesignerInteraction/SolidOperationInputAdapter.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include "AliceOperationInputSnapshot.h" - -#include -#include - -namespace sdr::detail -{ - inline bool TryGetCurrentScreenPoint(std::int32_t& x, - std::int32_t& y, - std::uint32_t* pButtons = nullptr, - std::uint32_t* pModifiers = nullptr) noexcept - { - const std::optional snapshot = alice::OperationInputSnapshot::GetCurrentPointer(); - if (!snapshot.has_value()) - { - return false; - } - - x = static_cast(snapshot->X); - y = static_cast(snapshot->Y); - if (pButtons != nullptr) - { - *pButtons = snapshot->Buttons; - } - if (pModifiers != nullptr) - { - *pModifiers = snapshot->Modifiers; - } - return true; - } -} diff --git a/Designer/Interaction/SolidDesignerInteraction/SolidPickFilters.cpp b/Designer/Interaction/SolidDesignerInteraction/SolidPickFilters.cpp index b10cbaa2..d4127098 100644 --- a/Designer/Interaction/SolidDesignerInteraction/SolidPickFilters.cpp +++ b/Designer/Interaction/SolidDesignerInteraction/SolidPickFilters.cpp @@ -2,71 +2,82 @@ #include "AliceIPickingManager.h" #include "AliceSemanticRoleKind.h" #include +#include using namespace sdr; using namespace alice; -namespace -{ - static bool ContainsKind_(const std::vector& kinds, PickHitKind kind) - { - return std::find(kinds.begin(), kinds.end(), kind) != kinds.end(); - } -} - SolidSemanticPickFilter::SolidSemanticPickFilter(SolidPickIntent intent) { Reset(intent); } -SolidSemanticPickFilter::SolidSemanticPickFilter(std::vector allowedKinds, std::vector preferredSemanticRoleKinds, bool allowFallbackForUnnamedRoles) +SolidSemanticPickFilter::SolidSemanticPickFilter(PickTargetFlag allowedTargets, + std::vector preferredSemanticRoleKinds, + bool allowUnnamedRoleMatches) { - Reset(std::move(allowedKinds), std::move(preferredSemanticRoleKinds), allowFallbackForUnnamedRoles); + Reset(allowedTargets, std::move(preferredSemanticRoleKinds), allowUnnamedRoleMatches); } void SolidSemanticPickFilter::Reset(SolidPickIntent intent) { - Reset(AllowedKindsForIntent_(intent), RoleKindsForIntent_(intent), intent == SolidPickIntent::DefaultModeling); + Reset(TargetsForIntent_(intent), RoleKindsForIntent_(intent), intent == SolidPickIntent::DefaultModeling); } -void SolidSemanticPickFilter::Reset(std::vector allowedKinds, std::vector preferredSemanticRoleKinds, bool allowFallbackForUnnamedRoles) +void SolidSemanticPickFilter::Reset(PickTargetFlag allowedTargets, + std::vector preferredSemanticRoleKinds, + bool allowUnnamedRoleMatches) { - m_allowedKinds = std::move(allowedKinds); + m_allowedTargets = allowedTargets; m_preferredSemanticRoleKinds = std::move(preferredSemanticRoleKinds); - m_allowFallbackForUnnamedRoles = allowFallbackForUnnamedRoles; + m_allowUnnamedRoleMatches = allowUnnamedRoleMatches; +} + +void SolidSemanticPickFilter::ConfigurePickCollector(PickCollectorInput& ioCollector) const +{ + ConfigurePickTargets(ioCollector.TargetOptions); + ioCollector.PreferredSemanticRoleKinds = m_allowUnnamedRoleMatches + ? std::vector{} + : m_preferredSemanticRoleKinds; + ioCollector.MinimumReferenceCount = 0u; + ioCollector.MaximumReferenceCount = 1u; } void SolidSemanticPickFilter::ConfigurePickTargets(PickTargetOptions& ioOptions) const { - ioOptions.AllowedTargets = ToPickTargetFlags_(m_allowedKinds); + ioOptions.AllowedTargets = m_allowedTargets; ioOptions.AllowHighlightOnlyRepresentationNode = true; } -bool SolidSemanticPickFilter::AllowHit(const PickHit& hit) const -{ - if (!m_allowedKinds.empty() && !ContainsKind_(m_allowedKinds, hit.Kind)) - return false; - - const std::string_view role = !hit.RepresentationNodeSemanticRole.empty() ? std::string_view(hit.RepresentationNodeSemanticRole) : (!hit.TopoSemanticRef.empty() ? std::string_view(hit.TopoSemanticRef) : std::string_view(hit.EntityToken)); - if (role.empty()) - return m_allowFallbackForUnnamedRoles && hit.TargetObjectId.IsValid(); - - return MatchesPreferredRoleKinds_(role); - +bool SolidSemanticPickFilter::AllowRepresentationNode(const rep::IRepresentationNodeReference& node) const +{ + return node.IsValid(); } -bool SolidSemanticPickFilter::AllowRepresentationNode(const RepresentationNodeReference& node) const -{ - if (!node.TargetObjectId.IsValid() && node.PersistentEntityId == 0u && node.RepresentationNodeToken.empty()) - return false; - - const std::string_view role = !node.RepresentationNodeSemanticRole.empty() ? std::string_view(node.RepresentationNodeSemanticRole) : (!node.TopoSemanticRef.empty() ? std::string_view(node.TopoSemanticRef) : std::string_view(node.RepresentationNodeToken)); if (role.empty()) return m_allowFallbackForUnnamedRoles; - return MatchesPreferredRoleKinds_(role); +bool SolidSemanticPickFilter::PostProcessPickHits(const PickContext&, std::vector& ioHits) const +{ + if (!m_allowUnnamedRoleMatches) + { + return true; + } + + std::vector vecAcceptedHits; + vecAcceptedHits.reserve(ioHits.size()); + for (PickHit& hit : ioHits) + { + if (hit.ResolvedSemanticRoleKind == SemanticRoleKind::Unknown || + MatchesPreferredRoleKinds_(hit.ResolvedSemanticRoleKind)) + { + vecAcceptedHits.push_back(std::move(hit)); + } + } + ioHits = std::move(vecAcceptedHits); + return true; } -const std::vector& SolidSemanticPickFilter::GetAllowedKinds() const noexcept +PickTargetFlag SolidSemanticPickFilter::GetAllowedTargets() const noexcept { - return m_allowedKinds; + return m_allowedTargets; } const std::vector& SolidSemanticPickFilter::GetPreferredSemanticRoleKinds() const noexcept @@ -74,134 +85,56 @@ const std::vector& SolidSemanticPickFilter::GetPreferredSemant return m_preferredSemanticRoleKinds; } -bool SolidSemanticPickFilter::MatchesPreferredRoleKinds_(std::string_view roleOrToken) const +bool SolidSemanticPickFilter::MatchesPreferredRoleKinds_(SemanticRoleKind roleKind) const noexcept { - return alice::MatchesAnySemanticRoleKind(roleOrToken, m_preferredSemanticRoleKinds); -} - -PickTargetFlag SolidSemanticPickFilter::ToPickTargetFlags_(const std::vector& kinds) noexcept -{ - if (kinds.empty()) - return PickTargetFlag::Any; - - PickTargetFlag flags = PickTargetFlag::None; - for (const PickHitKind kind : kinds) - { - switch (kind) - { - case PickHitKind::Object: - flags = flags | PickTargetFlag::Object; - break; - case PickHitKind::Body: - flags = flags | PickTargetFlag::Body; - break; - case PickHitKind::Face: - flags = flags | PickTargetFlag::Face; - break; - case PickHitKind::Edge: - flags = flags | PickTargetFlag::Edge; - break; - case PickHitKind::Vertex: - flags = flags | PickTargetFlag::Vertex; - break; - case PickHitKind::Curve: - flags = flags | PickTargetFlag::Curve; - break; - case PickHitKind::Point: - flags = flags | PickTargetFlag::Point; - break; - case PickHitKind::SketchCurve: - flags = flags | PickTargetFlag::SketchCurve; - break; - case PickHitKind::SketchPoint: - flags = flags | PickTargetFlag::SketchPoint; - break; - case PickHitKind::SketchRegion: - flags = flags | PickTargetFlag::SketchRegion; - break; - case PickHitKind::DatumPlane: - flags = flags | PickTargetFlag::DatumPlane; - break; - case PickHitKind::DatumAxis: - flags = flags | PickTargetFlag::DatumAxis; - break; - case PickHitKind::DatumPoint: - flags = flags | PickTargetFlag::DatumPoint; - break; - case PickHitKind::DatumCsys: - flags = flags | PickTargetFlag::DatumCsys; - break; - case PickHitKind::FeatureResult: - flags = flags | PickTargetFlag::FeatureResult; - break; - case PickHitKind::Component: - flags = flags | PickTargetFlag::Component; - break; - case PickHitKind::Occurrence: - flags = flags | PickTargetFlag::Occurrence; - break; - case PickHitKind::Text: - flags = flags | PickTargetFlag::Text; - break; - case PickHitKind::MeshTriangle: - flags = flags | PickTargetFlag::MeshTriangle; - break; - case PickHitKind::SubElement: - flags = flags | PickTargetFlag::SubElement; - break; - default: - break; -} - } - return flags; + return std::find(m_preferredSemanticRoleKinds.begin(), + m_preferredSemanticRoleKinds.end(), + roleKind) != m_preferredSemanticRoleKinds.end(); } -std::vector SolidSemanticPickFilter::AllowedKindsForIntent_(SolidPickIntent intent) +PickTargetFlag SolidSemanticPickFilter::TargetsForIntent_(SolidPickIntent intent) noexcept { - //基准面是否应该填充?, 线框是否可行 switch (intent) { - case SolidPickIntent::SketchPlaneInput: - return { PickHitKind::DatumPlane, - PickHitKind::DatumAxis, - PickHitKind::DatumPoint, - PickHitKind::DatumCsys, - PickHitKind::Face, - PickHitKind::Edge, - PickHitKind::Vertex, - PickHitKind::Curve, - PickHitKind::SketchRegion, - PickHitKind::SketchCurve, - PickHitKind::SketchPoint, - PickHitKind::FeatureResult, - PickHitKind::SubElement, - PickHitKind::Object }; - case SolidPickIntent::OrientationReferenceInput: - return { PickHitKind::DatumPlane, PickHitKind::DatumAxis, PickHitKind::DatumPoint, PickHitKind::DatumCsys, - PickHitKind::Face, PickHitKind::Edge, PickHitKind::Vertex, PickHitKind::SketchRegion, PickHitKind::SketchCurve, - PickHitKind::SketchPoint, PickHitKind::FeatureResult, PickHitKind::SubElement, PickHitKind::Object }; - default: - return { PickHitKind::DatumPlane, PickHitKind::DatumAxis, PickHitKind::DatumPoint, PickHitKind::DatumCsys, - PickHitKind::Body, PickHitKind::Face, PickHitKind::Edge, PickHitKind::Vertex, PickHitKind::SketchRegion, - PickHitKind::SketchCurve, PickHitKind::SketchPoint, PickHitKind::FeatureResult, PickHitKind::Component, - PickHitKind::Occurrence, PickHitKind::SubElement, PickHitKind::Object }; } + case SolidPickIntent::SketchPlaneInput: + return PickTargetFlag::DatumPlane | PickTargetFlag::DatumAxis | PickTargetFlag::DatumPoint | + PickTargetFlag::DatumCsys | PickTargetFlag::Face | PickTargetFlag::Edge | + PickTargetFlag::Vertex | PickTargetFlag::Curve | PickTargetFlag::SketchRegion | + PickTargetFlag::SketchCurve | PickTargetFlag::SketchPoint | PickTargetFlag::FeatureResult | + PickTargetFlag::SubElement | PickTargetFlag::Object; + case SolidPickIntent::OrientationReferenceInput: + return PickTargetFlag::DatumPlane | PickTargetFlag::DatumAxis | PickTargetFlag::DatumPoint | + PickTargetFlag::DatumCsys | PickTargetFlag::Face | PickTargetFlag::Edge | + PickTargetFlag::Vertex | PickTargetFlag::SketchRegion | PickTargetFlag::SketchCurve | + PickTargetFlag::SketchPoint | PickTargetFlag::FeatureResult | PickTargetFlag::SubElement | + PickTargetFlag::Object; + default: + return PickTargetFlag::DatumPlane | PickTargetFlag::DatumAxis | PickTargetFlag::DatumPoint | + PickTargetFlag::DatumCsys | PickTargetFlag::Body | PickTargetFlag::Face | + PickTargetFlag::Edge | PickTargetFlag::Vertex | PickTargetFlag::SketchRegion | + PickTargetFlag::SketchCurve | PickTargetFlag::SketchPoint | PickTargetFlag::FeatureResult | + PickTargetFlag::Component | PickTargetFlag::Occurrence | PickTargetFlag::SubElement | + PickTargetFlag::Object; + } } std::vector SolidSemanticPickFilter::RoleKindsForIntent_(SolidPickIntent intent) -{ - SolidDefaultPickBehavior behavior(intent); +{ switch (intent) { case SolidPickIntent::SketchPlaneInput: - { - auto roles = behavior.GetSketchSelectionSemanticRoleKinds(); - const auto& plane = behavior.GetSketchPlaneSemanticRoleKinds(); - roles.insert(roles.end(), plane.begin(), plane.end()); - return roles; - } - case SolidPickIntent::OrientationReferenceInput: - return behavior.GetOrientationReferenceSemanticRoleKinds(); - default: + return { SemanticRoleKind::SketchRegion, SemanticRoleKind::SketchProfile, + SemanticRoleKind::SketchLoop, SemanticRoleKind::SketchChain, SemanticRoleKind::SketchCurve, + SemanticRoleKind::SketchPoint, SemanticRoleKind::Sketch, SemanticRoleKind::SketchFeature, + SemanticRoleKind::DatumPlane, SemanticRoleKind::ModelPlanarFace, SemanticRoleKind::ModelFace, + SemanticRoleKind::FeatureFace }; + case SolidPickIntent::OrientationReferenceInput: + return { 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 }; + default: return { SemanticRoleKind::DatumPlane, SemanticRoleKind::DatumAxis, SemanticRoleKind::DatumPoint, SemanticRoleKind::DatumCsys, SemanticRoleKind::ModelPlanarFace, SemanticRoleKind::ModelFace, SemanticRoleKind::ModelEdge, SemanticRoleKind::ModelVertex, SemanticRoleKind::ModelBody, diff --git a/Designer/Interaction/SolidDesignerInteraction/SolidPickFilters.h b/Designer/Interaction/SolidDesignerInteraction/SolidPickFilters.h index 84f60220..73103d84 100644 --- a/Designer/Interaction/SolidDesignerInteraction/SolidPickFilters.h +++ b/Designer/Interaction/SolidDesignerInteraction/SolidPickFilters.h @@ -1,31 +1,41 @@ #pragma once #include "SolidDesignerInteraction.h" #include "AliceIPickFilter.h" -#include "SolidDefaultPickBehavior.h" #include namespace sdr { + enum class SolidPickIntent + { + DefaultModeling, + SketchPlaneInput, + OrientationReferenceInput + }; + class SOLID_DESIGNER_INTERACTION_EXPORT SolidSemanticPickFilter final : public alice::IPickFilter { public: SolidSemanticPickFilter() = default; explicit SolidSemanticPickFilter(SolidPickIntent intent); - SolidSemanticPickFilter(std::vector allowedKinds, std::vector preferredSemanticRoleKinds, bool allowFallbackForUnnamedRoles = false); + SolidSemanticPickFilter(alice::PickTargetFlag allowedTargets, + std::vector preferredSemanticRoleKinds, + bool allowUnnamedRoleMatches = false); void Reset(SolidPickIntent intent); - void Reset(std::vector allowedKinds, std::vector preferredSemanticRoleKinds, bool allowFallbackForUnnamedRoles = false); + void Reset(alice::PickTargetFlag allowedTargets, + std::vector preferredSemanticRoleKinds, + bool allowUnnamedRoleMatches = false); + void ConfigurePickCollector(alice::PickCollectorInput& ioCollector) const override; void ConfigurePickTargets(alice::PickTargetOptions& ioOptions) const override; - bool AllowHit(const alice::PickHit& hit) const override; - bool AllowRepresentationNode(const alice::RepresentationNodeReference& node) const override; - const std::vector& GetAllowedKinds() const noexcept; + bool AllowRepresentationNode(const alice::rep::IRepresentationNodeReference& node) const override; + bool PostProcessPickHits(const alice::PickContext& context, std::vector& ioHits) const override; + alice::PickTargetFlag GetAllowedTargets() const noexcept; const std::vector& GetPreferredSemanticRoleKinds() const noexcept; private: - bool MatchesPreferredRoleKinds_(std::string_view roleOrToken) const; - static alice::PickTargetFlag ToPickTargetFlags_(const std::vector& kinds) noexcept; - static std::vector AllowedKindsForIntent_(SolidPickIntent intent); + bool MatchesPreferredRoleKinds_(alice::SemanticRoleKind roleKind) const noexcept; + static alice::PickTargetFlag TargetsForIntent_(SolidPickIntent intent) noexcept; static std::vector RoleKindsForIntent_(SolidPickIntent intent); private: - std::vector m_allowedKinds; + alice::PickTargetFlag m_allowedTargets = alice::PickTargetFlag::Any; std::vector m_preferredSemanticRoleKinds; - bool m_allowFallbackForUnnamedRoles = false; + bool m_allowUnnamedRoleMatches = false; }; } diff --git a/Designer/Interaction/SolidDesignerInteraction/SolidSectionEditOperation.cpp b/Designer/Interaction/SolidDesignerInteraction/SolidSectionEditOperation.cpp index 83d42931..7dd075e0 100644 --- a/Designer/Interaction/SolidDesignerInteraction/SolidSectionEditOperation.cpp +++ b/Designer/Interaction/SolidDesignerInteraction/SolidSectionEditOperation.cpp @@ -427,7 +427,7 @@ void SolidSectionEditOperation::ClearHighlightFeedback_() if (pSnappingManager) { pSnappingManager->ClearResolvedSnapPoint(); - pSnappingManager->SetResolvedEntityToken({}); + pSnappingManager->SetResolvedElementName({}); } alice::ISelectionManager* pSelectionManager = pSession ? pSession->GetSelectionManagerFw() : nullptr; if (pSelectionManager) @@ -450,12 +450,12 @@ void SolidSectionEditOperation::RefreshInteractionFeedback_() { const alice::SketchPoint2d point = m_pSketchInteractionController->GetResolvedFeedbackPoint(); pSnappingManager->SetResolvedSnapPoint(alice::Vector2d(point.X(), point.Y())); - pSnappingManager->SetResolvedEntityToken(m_pSketchInteractionController->GetResolvedFeedbackToken()); + pSnappingManager->SetResolvedElementName(m_pSketchInteractionController->GetResolvedFeedbackToken()); } else { pSnappingManager->ClearResolvedSnapPoint(); - pSnappingManager->SetResolvedEntityToken({}); + pSnappingManager->SetResolvedElementName({}); } } diff --git a/Designer/Interaction/SolidDesignerInteraction/SolidSectionPickFilters.cpp b/Designer/Interaction/SolidDesignerInteraction/SolidSectionPickFilters.cpp index 81e79a14..d538e939 100644 --- a/Designer/Interaction/SolidDesignerInteraction/SolidSectionPickFilters.cpp +++ b/Designer/Interaction/SolidDesignerInteraction/SolidSectionPickFilters.cpp @@ -3,14 +3,62 @@ using namespace sdr; using namespace alice; -void SolidSketchPlanePickFilter::ConfigurePickTargets(PickTargetOptions& ioOptions) const { m_filter.ConfigurePickTargets(ioOptions); } -bool SolidSketchPlanePickFilter::AllowHit(const PickHit& hit) const { return m_filter.AllowHit(hit); } -bool SolidSketchPlanePickFilter::AllowRepresentationNode(const RepresentationNodeReference& node) const { return m_filter.AllowRepresentationNode(node); } +void SolidSketchPlanePickFilter::ConfigurePickCollector(PickCollectorInput& ioCollector) const +{ + m_filter.ConfigurePickCollector(ioCollector); +} -void SolidOrientationReferencePickFilter::ConfigurePickTargets(PickTargetOptions& ioOptions) const { m_filter.ConfigurePickTargets(ioOptions); } -bool SolidOrientationReferencePickFilter::AllowHit(const PickHit& hit) const { return m_filter.AllowHit(hit); } -bool SolidOrientationReferencePickFilter::AllowRepresentationNode(const RepresentationNodeReference& node) const { return m_filter.AllowRepresentationNode(node); } +void SolidSketchPlanePickFilter::ConfigurePickTargets(PickTargetOptions& ioOptions) const +{ + m_filter.ConfigurePickTargets(ioOptions); +} -void SolidExistingSketchPickFilter::ConfigurePickTargets(PickTargetOptions& ioOptions) const { m_filter.ConfigurePickTargets(ioOptions); } -bool SolidExistingSketchPickFilter::AllowHit(const PickHit& hit) const { return m_filter.AllowHit(hit); } -bool SolidExistingSketchPickFilter::AllowRepresentationNode(const RepresentationNodeReference& node) const { return m_filter.AllowRepresentationNode(node); } +bool SolidSketchPlanePickFilter::AllowRepresentationNode(const rep::IRepresentationNodeReference& node) const +{ + return m_filter.AllowRepresentationNode(node); +} + +bool SolidSketchPlanePickFilter::PostProcessPickHits(const PickContext& context, std::vector& ioHits) const +{ + return m_filter.PostProcessPickHits(context, ioHits); +} + +void SolidOrientationReferencePickFilter::ConfigurePickCollector(PickCollectorInput& ioCollector) const +{ + m_filter.ConfigurePickCollector(ioCollector); +} + +void SolidOrientationReferencePickFilter::ConfigurePickTargets(PickTargetOptions& ioOptions) const +{ + m_filter.ConfigurePickTargets(ioOptions); +} + +bool SolidOrientationReferencePickFilter::AllowRepresentationNode(const rep::IRepresentationNodeReference& node) const +{ + return m_filter.AllowRepresentationNode(node); +} + +bool SolidOrientationReferencePickFilter::PostProcessPickHits(const PickContext& context, std::vector& ioHits) const +{ + return m_filter.PostProcessPickHits(context, ioHits); +} + +void SolidExistingSketchPickFilter::ConfigurePickCollector(PickCollectorInput& ioCollector) const +{ + m_filter.ConfigurePickCollector(ioCollector); +} + +void SolidExistingSketchPickFilter::ConfigurePickTargets(PickTargetOptions& ioOptions) const +{ + m_filter.ConfigurePickTargets(ioOptions); +} + +bool SolidExistingSketchPickFilter::AllowRepresentationNode(const rep::IRepresentationNodeReference& node) const +{ + return m_filter.AllowRepresentationNode(node); +} + +bool SolidExistingSketchPickFilter::PostProcessPickHits(const PickContext& context, std::vector& ioHits) const +{ + return m_filter.PostProcessPickHits(context, ioHits); +} diff --git a/Designer/Interaction/SolidDesignerInteraction/SolidSectionPickFilters.h b/Designer/Interaction/SolidDesignerInteraction/SolidSectionPickFilters.h index f8b4d0ad..20070e80 100644 --- a/Designer/Interaction/SolidDesignerInteraction/SolidSectionPickFilters.h +++ b/Designer/Interaction/SolidDesignerInteraction/SolidSectionPickFilters.h @@ -8,9 +8,10 @@ namespace sdr class SOLID_DESIGNER_INTERACTION_EXPORT SolidSketchPlanePickFilter final : public alice::IPickFilter { public: + void ConfigurePickCollector(alice::PickCollectorInput& ioCollector) const override; void ConfigurePickTargets(alice::PickTargetOptions& ioOptions) const override; - bool AllowHit(const alice::PickHit& hit) const override; - bool AllowRepresentationNode(const alice::RepresentationNodeReference& node) const override; + bool AllowRepresentationNode(const alice::rep::IRepresentationNodeReference& node) const override; + bool PostProcessPickHits(const alice::PickContext& context, std::vector& ioHits) const override; private: SolidSemanticPickFilter m_filter{ SolidPickIntent::SketchPlaneInput }; }; @@ -18,9 +19,10 @@ namespace sdr class SOLID_DESIGNER_INTERACTION_EXPORT SolidOrientationReferencePickFilter final : public alice::IPickFilter { public: + void ConfigurePickCollector(alice::PickCollectorInput& ioCollector) const override; void ConfigurePickTargets(alice::PickTargetOptions& ioOptions) const override; - bool AllowHit(const alice::PickHit& hit) const override; - bool AllowRepresentationNode(const alice::RepresentationNodeReference& node) const override; + bool AllowRepresentationNode(const alice::rep::IRepresentationNodeReference& node) const override; + bool PostProcessPickHits(const alice::PickContext& context, std::vector& ioHits) const override; private: SolidSemanticPickFilter m_filter{ SolidPickIntent::OrientationReferenceInput }; }; @@ -28,12 +30,24 @@ namespace sdr class SOLID_DESIGNER_INTERACTION_EXPORT SolidExistingSketchPickFilter final : public alice::IPickFilter { public: + void ConfigurePickCollector(alice::PickCollectorInput& ioCollector) const override; void ConfigurePickTargets(alice::PickTargetOptions& ioOptions) const override; - bool AllowHit(const alice::PickHit& hit) const override; - bool AllowRepresentationNode(const alice::RepresentationNodeReference& node) const override; + bool AllowRepresentationNode(const alice::rep::IRepresentationNodeReference& node) const override; + bool PostProcessPickHits(const alice::PickContext& context, std::vector& ioHits) const override; private: - SolidSemanticPickFilter m_filter{{ alice::PickHitKind::SketchRegion, alice::PickHitKind::SketchCurve, alice::PickHitKind::Object, alice::PickHitKind::FeatureResult }, - { alice::SemanticRoleKind::SketchRegion, alice::SemanticRoleKind::SketchCurve, alice::SemanticRoleKind::SketchPoint }, + SolidSemanticPickFilter m_filter{alice::PickTargetFlag::SketchRegion | + alice::PickTargetFlag::SketchCurve | + alice::PickTargetFlag::Object | + alice::PickTargetFlag::FeatureResult, + { alice::SemanticRoleKind::SketchRegion, + alice::SemanticRoleKind::SketchProfile, + alice::SemanticRoleKind::SketchLoop, + alice::SemanticRoleKind::SketchChain, + alice::SemanticRoleKind::SketchCurve, + alice::SemanticRoleKind::SketchPoint, + alice::SemanticRoleKind::Sketch, + alice::SemanticRoleKind::SketchFeature, + alice::SemanticRoleKind::FeatureProfile }, true}; }; } diff --git a/Designer/Interaction/SolidDesignerInteraction/SolidSectionPlacementOperation.cpp b/Designer/Interaction/SolidDesignerInteraction/SolidSectionPlacementOperation.cpp index 37d53b1a..928cc648 100644 --- a/Designer/Interaction/SolidDesignerInteraction/SolidSectionPlacementOperation.cpp +++ b/Designer/Interaction/SolidDesignerInteraction/SolidSectionPlacementOperation.cpp @@ -4,16 +4,16 @@ #include "SolidSectionPickFilters.h" #include "AliceIUiView.h" +#include + using namespace sdr; using namespace alice; -SolidSectionPlacementOperation::SolidSectionPlacementOperation(ObjectId preselectedPlaneId, - std::string preselectedPlaneKey, - std::string preselectedPlaneRole) - : m_idSketchPlane(preselectedPlaneId) - , m_strSketchPlaneKey(std::move(preselectedPlaneKey)) - , m_strSketchPlaneRole(std::move(preselectedPlaneRole)) - , m_bPickedPlane(preselectedPlaneId.IsValid()) +SolidSectionPlacementOperation::SolidSectionPlacementOperation( + std::unique_ptr upPreselectedPlane) + : m_idSketchPlane(upPreselectedPlane ? upPreselectedPlane->GetTargetObjectId() : ObjectId{}) + , m_upSketchPlaneReference(std::move(upPreselectedPlane)) + , m_bPickedPlane(m_idSketchPlane.IsValid()) { } @@ -27,7 +27,10 @@ void SolidSectionPlacementOperation::InitOperation(IUiView* pCurrentView) (void)BeginPickOrientationReference_(); return; } - (void)BeginPickSketchPlane_(); + if (!BeginPickSketchPlane_()) + { + CompleteFailed_("Unable to start sketch-plane selection operation."); + } } void SolidSectionPlacementOperation::OnCancel() @@ -42,7 +45,11 @@ void SolidSectionPlacementOperation::OnCancel() void SolidSectionPlacementOperation::OnChildOperationFinished(const OperationResult& result) { const auto* const pPick = dynamic_cast(result.Payload.get()); - if (result.FinishStatus != OperationFinishStatus::Successful || !pPick || pPick->Cancelled || !pPick->ReferenceId.IsValid()) + if (result.FinishStatus != OperationFinishStatus::Successful || + !pPick || + pPick->Cancelled || + !pPick->ChosenReference || + !pPick->ChosenReference->IsValid()) { SetOperationResult(result); return; @@ -50,17 +57,18 @@ void SolidSectionPlacementOperation::OnChildOperationFinished(const OperationRes if (!m_bPickedPlane) { - m_idSketchPlane = pPick->ReferenceId; - m_strSketchPlaneKey = pPick->SelectionKey; - m_strSketchPlaneRole = pPick->SemanticRole; + m_upSketchPlaneReference = pPick->ChosenReference->Clone(); + m_idSketchPlane = m_upSketchPlaneReference->GetTargetObjectId(); m_bPickedPlane = true; - (void)BeginPickOrientationReference_(); + if (!BeginPickOrientationReference_()) + { + CompleteFailed_("Unable to start sketch orientation-reference selection operation."); + } return; } - m_idOrientationReference = pPick->ReferenceId; - m_strOrientationKey = pPick->SelectionKey; - m_strOrientationRole = pPick->SemanticRole; + m_upOrientationReference = pPick->ChosenReference->Clone(); + m_idOrientationReference = m_upOrientationReference->GetTargetObjectId(); CompleteAccepted_(); } @@ -86,10 +94,6 @@ void SolidSectionPlacementOperation::CompleteAccepted_() data.Accepted = m_idSketchPlane.IsValid(); data.SectionInput.SketchPlaneReferenceId = m_idSketchPlane; data.SectionInput.PlacementReferenceId = m_idOrientationReference; - data.SectionInput.SketchPlaneGraphicToken = m_strSketchPlaneKey; - data.SectionInput.SketchPlaneGraphicRole = m_strSketchPlaneRole; - data.SectionInput.PlacementReferenceGraphicToken = m_strOrientationKey; - data.SectionInput.PlacementReferenceGraphicRole = m_strOrientationRole; data.PlacementContext.SketchPlaneId = m_idSketchPlane; data.PlacementContext.PlacementReferenceId = m_idOrientationReference; diff --git a/Designer/Interaction/SolidDesignerInteraction/SolidSectionPlacementOperation.h b/Designer/Interaction/SolidDesignerInteraction/SolidSectionPlacementOperation.h index 2577c729..2c619054 100644 --- a/Designer/Interaction/SolidDesignerInteraction/SolidSectionPlacementOperation.h +++ b/Designer/Interaction/SolidDesignerInteraction/SolidSectionPlacementOperation.h @@ -2,17 +2,20 @@ #include "SolidDesignerInteraction.h" #include "SolidAuthoringOperationBase.h" #include "AliceObjectId.h" +#include "AliceIRepresentationNodeReference.h" #include "AlicePickReferenceOperation.h" #include "SolidSectionOperationResults.h" +#include +#include + namespace sdr { class SOLID_DESIGNER_INTERACTION_EXPORT SolidSectionPlacementOperation final : public SolidAuthoringOperationBase { public: - SolidSectionPlacementOperation(alice::ObjectId preselectedPlaneId = {}, - std::string preselectedPlaneKey = {}, - std::string preselectedPlaneRole = {}); + explicit SolidSectionPlacementOperation( + std::unique_ptr upPreselectedPlane = nullptr); ~SolidSectionPlacementOperation() override; void InitOperation(alice::IUiView* pCurrentView) override; @@ -28,10 +31,8 @@ namespace sdr private: alice::ObjectId m_idSketchPlane; alice::ObjectId m_idOrientationReference; - std::string m_strSketchPlaneKey; - std::string m_strSketchPlaneRole; - std::string m_strOrientationKey; - std::string m_strOrientationRole; + std::unique_ptr m_upSketchPlaneReference; + std::unique_ptr m_upOrientationReference; bool m_bPickedPlane = false; }; } diff --git a/Designer/Interaction/SolidDesignerInteraction/SolidSketchInputProjector.cpp b/Designer/Interaction/SolidDesignerInteraction/SolidSketchInputProjector.cpp index 71a9f59f..93f74f14 100644 --- a/Designer/Interaction/SolidDesignerInteraction/SolidSketchInputProjector.cpp +++ b/Designer/Interaction/SolidDesignerInteraction/SolidSketchInputProjector.cpp @@ -37,14 +37,6 @@ SolidSketchPlacementContext SolidSketchInputProjector::GetPlacementContext() con return m_context; } -void SolidSketchInputProjector::SetPlaneAnchorFromRepresentationNodeHit(const alice::RepresentationNodeHitResult& hit) -{ - m_context.PlaneAnchorX = hit.ModelX; - m_context.PlaneAnchorY = hit.ModelY; - m_context.PlaneAnchorZ = hit.ModelZ; - m_context.HasPlaneAnchor = true; -} - bool SolidSketchInputProjector::TryProjectScreenPointToSketch(double screenX, double screenY, alice::SketchPoint2d& outPoint) const diff --git a/Designer/Interaction/SolidDesignerInteraction/SolidSketchInputProjector.h b/Designer/Interaction/SolidDesignerInteraction/SolidSketchInputProjector.h index c746eaa7..70bfb83a 100644 --- a/Designer/Interaction/SolidDesignerInteraction/SolidSketchInputProjector.h +++ b/Designer/Interaction/SolidDesignerInteraction/SolidSketchInputProjector.h @@ -1,7 +1,6 @@ #pragma once #include "SolidDesignerInteraction.h" #include "AliceSketchSemanticTypes.h" -#include "AliceIPickingManager.h" #include "SolidSketchPlacementContext.h" namespace sdr @@ -13,7 +12,6 @@ namespace sdr virtual void SetPlacementContext(const SolidSketchPlacementContext& context) = 0; virtual SolidSketchPlacementContext GetPlacementContext() const = 0; - virtual void SetPlaneAnchorFromRepresentationNodeHit(const alice::RepresentationNodeHitResult& hit) = 0; virtual bool TryProjectScreenPointToSketch(double screenX, double screenY, alice::SketchPoint2d& outPoint) const = 0; @@ -27,7 +25,6 @@ namespace sdr void SetPlacementContext(const SolidSketchPlacementContext& context) override; SolidSketchPlacementContext GetPlacementContext() const override; - void SetPlaneAnchorFromRepresentationNodeHit(const alice::RepresentationNodeHitResult& hit) override; bool TryProjectScreenPointToSketch(double screenX, double screenY, alice::SketchPoint2d& outPoint) const override; diff --git a/Designer/Interaction/SolidDesignerInteraction/SolidSketchRepresentationProjection.cpp b/Designer/Interaction/SolidDesignerInteraction/SolidSketchRepresentationProjection.cpp index 7e845e7d..86f7259e 100644 --- a/Designer/Interaction/SolidDesignerInteraction/SolidSketchRepresentationProjection.cpp +++ b/Designer/Interaction/SolidDesignerInteraction/SolidSketchRepresentationProjection.cpp @@ -7,6 +7,8 @@ #include "AliceArcRepresentationNode.h" #include "AliceEllipseRepresentationNode.h" #include "AliceRepresentationGeometryFactory.h" +#include "AliceRepresentationNodeIdFactory.h" +#include "AliceSemanticRoleId.h" #include "AliceSketchObjectModel.h" #include "AliceISketchLine.h" #include "AliceISketchCircle.h" @@ -72,13 +74,6 @@ namespace return origin + xAxis * x + yAxis * point.Y(); } - static std::uint64_t HashSketchNodeId(alice::ObjectId idObject, const std::string& token) - { - const std::uint64_t seed = static_cast(idObject.RawValue()); - const std::uint64_t hash = static_cast(std::hash{}(token)); - return seed ^ (hash + 0x9e3779b97f4a7c15ULL + (seed << 6u) + (seed >> 2u)); - } - static std::vector ScaleCoords(const std::vector& points, int axis) { std::vector values; @@ -129,6 +124,7 @@ namespace } static std::shared_ptr BuildPolylineNode(alice::ObjectId idObject, + const Guid& idSource, const std::string& name, const std::string& role, const std::string& token, @@ -139,10 +135,11 @@ namespace return {}; } auto pNode = std::make_shared(); - pNode->SetPersistentNodeId(HashSketchNodeId(idObject, token)); + pNode->SetPersistentNodeId(alice::rep::RepresentationNodeIdFactory::ForGuid( + idObject, alice::SemanticRoleId::SketchCurve, idSource)); pNode->SetOwnerObjectId(idObject); pNode->SetDebugName(name); - pNode->SetSemanticRole(role); + pNode->SetSemanticRoleId(alice::SemanticRoleId::SketchCurve); pNode->SetCurveBindingToken(token); pNode->SetCurveStyleTokenStorage(role); pNode->SetSampledPolylineXs(ScaleCoords(points, 0)); @@ -159,10 +156,11 @@ namespace const auto& header = line.GetHeader(); const std::string token = ResolveCurveToken(header); const std::string role = ResolveCurveRole(line); - pNode->SetPersistentNodeId(HashSketchNodeId(idObject, token)); + pNode->SetPersistentNodeId(alice::rep::RepresentationNodeIdFactory::ForGuid( + idObject, alice::SemanticRoleId::SketchCurve, header.Id)); pNode->SetOwnerObjectId(idObject); pNode->SetDebugName(token); - pNode->SetSemanticRole(role); + pNode->SetSemanticRoleId(alice::SemanticRoleId::SketchCurve); pNode->SetCurveBindingToken(token); pNode->SetCurveStyleToken(role); pNode->SetIsConstruction(line.IsConstruction()); @@ -183,10 +181,11 @@ namespace const auto& header = arc.GetHeader(); const std::string token = ResolveCurveToken(header); const std::string role = ResolveCurveRole(arc); - pNode->SetPersistentNodeId(HashSketchNodeId(idObject, token)); + pNode->SetPersistentNodeId(alice::rep::RepresentationNodeIdFactory::ForGuid( + idObject, alice::SemanticRoleId::SketchCurve, header.Id)); pNode->SetOwnerObjectId(idObject); pNode->SetDebugName(token); - pNode->SetSemanticRole(role); + pNode->SetSemanticRoleId(alice::SemanticRoleId::SketchCurve); pNode->SetCurveBindingToken(token); pNode->SetCurveStyleToken(role); pNode->SetIsConstruction(arc.IsConstruction()); @@ -214,10 +213,11 @@ namespace auto pNode = std::make_shared(); const std::string token = ResolveCurveToken(header); const std::string role = isConstruction ? "sketch.construction.curve" : "sketch.curve"; - pNode->SetPersistentNodeId(HashSketchNodeId(idObject, token)); + pNode->SetPersistentNodeId(alice::rep::RepresentationNodeIdFactory::ForGuid( + idObject, alice::SemanticRoleId::SketchCurve, header.Id)); pNode->SetOwnerObjectId(idObject); pNode->SetDebugName(token); - pNode->SetSemanticRole(role); + pNode->SetSemanticRoleId(alice::SemanticRoleId::SketchCurve); pNode->SetCurveBindingToken(token); pNode->SetCurveStyleToken(role); pNode->SetIsConstruction(isConstruction); @@ -289,6 +289,7 @@ void sdr::SolidSketchRepresentationProjection::AppendProjectedSketchCurves(alice points.push_back(MapSketchPointToWorld(placementContext, point)); } if (auto pNode = BuildPolylineNode(idObject, + bezier->GetHeader().Id, ResolveCurveToken(bezier->GetHeader()), ResolveCurveRole(*bezier), ResolveCurveToken(bezier->GetHeader()), @@ -306,6 +307,7 @@ void sdr::SolidSketchRepresentationProjection::AppendProjectedSketchCurves(alice points.push_back(MapSketchPointToWorld(placementContext, point)); } if (auto pNode = BuildPolylineNode(idObject, + bspline->GetHeader().Id, ResolveCurveToken(bspline->GetHeader()), ResolveCurveRole(*bspline), ResolveCurveToken(bspline->GetHeader()), diff --git a/Designer/UI/SolidDesignerCommand/EditCommands/SolidSelectSingleCommand.cpp b/Designer/UI/SolidDesignerCommand/EditCommands/SolidSelectSingleCommand.cpp index 73b6cfb5..827ccf64 100644 --- a/Designer/UI/SolidDesignerCommand/EditCommands/SolidSelectSingleCommand.cpp +++ b/Designer/UI/SolidDesignerCommand/EditCommands/SolidSelectSingleCommand.cpp @@ -96,11 +96,12 @@ std::string SolidSelectSingleCommand::DisabledReason() const std::unique_ptr SolidSelectSingleCommand::Execute(const CommandParameter& param) { + (void)param; if (!IsEnabled()) { return nullptr; } ConfigureDefaultViewShortcuts_(); - return std::make_unique(param.GetString("view_kind", {})); + return std::make_unique(); } diff --git a/Designer/UI/SolidDesignerCommand/ModelCommands/SolidFeatureEditWorkflowBridge.cpp b/Designer/UI/SolidDesignerCommand/ModelCommands/SolidFeatureEditWorkflowBridge.cpp index d99f7767..8fb07a1e 100644 --- a/Designer/UI/SolidDesignerCommand/ModelCommands/SolidFeatureEditWorkflowBridge.cpp +++ b/Designer/UI/SolidDesignerCommand/ModelCommands/SolidFeatureEditWorkflowBridge.cpp @@ -19,9 +19,11 @@ IFeature* SolidFeatureEditWorkflowBridge::ResolveEditDefinitionTarget(ISession* IDocumentFeatureManager* const pFeatureManager = pDocument->GetDocumentFeatureManagerFw(); ISelectionManager* const pSelectionManager = pSession->GetSelectionManagerFw(); if (!pFeatureManager || !pSelectionManager) return nullptr; - const auto selections = pSelectionManager->GetSelectionInputs(); - if (selections.empty()) return nullptr; - return pFeatureManager->FindFeatureById(FeatureId::FromPermanentValue(selections.front().Handle.TargetObjectId.Value())); + std::vector> vecReferences = + pSelectionManager->GetSelectedReferences(); + if (vecReferences.empty() || !vecReferences.front()) return nullptr; + return pFeatureManager->FindFeatureById( + FeatureId::FromPermanentValue(vecReferences.front()->GetTargetObjectId().Value())); } bool SolidFeatureEditWorkflowBridge::SupportsEditDefinition(const IFeature& feature) diff --git a/Designer/UI/SolidDesignerCommand/ModelCommands/SolidFeatureHistoryWorkflowBridge.cpp b/Designer/UI/SolidDesignerCommand/ModelCommands/SolidFeatureHistoryWorkflowBridge.cpp index 386387c4..917d52a8 100644 --- a/Designer/UI/SolidDesignerCommand/ModelCommands/SolidFeatureHistoryWorkflowBridge.cpp +++ b/Designer/UI/SolidDesignerCommand/ModelCommands/SolidFeatureHistoryWorkflowBridge.cpp @@ -100,11 +100,15 @@ IFeature* SolidFeatureHistoryWorkflowBridge::ResolveHistoryTarget(ISession* pSes return nullptr; } - const std::vector selection = pSelectionManager->GetSelection(); - for (const SelectionItem& item : selection) + std::vector> vecReferences = + pSelectionManager->GetSelectedReferences(); + for (const std::unique_ptr& upReference : vecReferences) { - const CommandSelectionInput input = item.ToCommandSelectionInput(false, pSelectionManager->GetSelectionOwnerContext()); - if (IFeature* const pFeature = ResolveFeatureByObjectId_(pDocument, input.Handle.TargetObjectId)) + if (!upReference) + { + continue; + } + if (IFeature* const pFeature = ResolveFeatureByObjectId_(pDocument, upReference->GetTargetObjectId())) { return pFeature; }