BooleanDataInterface.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <GraphModel/GraphModelBus.h>
  9. #include <GraphModel/Integration/BooleanDataInterface.h>
  10. #include <GraphModel/Integration/IntegrationBus.h>
  11. namespace GraphModelIntegration
  12. {
  13. BooleanDataInterface::BooleanDataInterface(GraphModel::SlotPtr slot)
  14. : m_slot(slot)
  15. {
  16. }
  17. bool BooleanDataInterface::GetBool() const
  18. {
  19. GraphModel::SlotPtr slot = m_slot.lock();
  20. return slot ? slot->GetValue<bool>() : false;
  21. }
  22. void BooleanDataInterface::SetBool(bool enabled)
  23. {
  24. GraphModel::SlotPtr slot = m_slot.lock();
  25. if (slot && slot->GetValue<bool>() != enabled)
  26. {
  27. const GraphCanvas::GraphId graphCanvasSceneId = GetDisplay()->GetSceneId();
  28. GraphCanvas::ScopedGraphUndoBatch undoBatch(graphCanvasSceneId);
  29. slot->SetValue(enabled);
  30. GraphControllerNotificationBus::Event(graphCanvasSceneId, &GraphControllerNotifications::OnGraphModelSlotModified, slot);
  31. GraphControllerNotificationBus::Event(
  32. graphCanvasSceneId, &GraphControllerNotifications::OnGraphModelGraphModified, slot->GetParentNode());
  33. }
  34. }
  35. } // namespace GraphModelIntegration