Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,49 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <GraphModel/Integration/BooleanDataInterface.h>
#include <GraphModel/Integration/IntegrationBus.h>
namespace GraphModelIntegration
{
BooleanDataInterface::BooleanDataInterface(GraphModel::SlotPtr slot)
: m_slot(slot)
{
}
bool BooleanDataInterface::GetBool() const
{
if (GraphModel::SlotPtr slot = m_slot.lock())
{
return slot->GetValue<bool>();
}
else
{
return false;
}
}
void BooleanDataInterface::SetBool(bool enabled)
{
if (GraphModel::SlotPtr slot = m_slot.lock())
{
if (enabled != slot->GetValue<bool>())
{
slot->SetValue(enabled);
GraphCanvas::GraphId graphCanvasSceneId;
IntegrationBus::BroadcastResult(graphCanvasSceneId, &IntegrationBusInterface::GetActiveGraphCanvasSceneId);
IntegrationBus::Broadcast(&IntegrationBusInterface::SignalSceneDirty, graphCanvasSceneId);
}
}
}
}
@@ -0,0 +1,105 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// AZ
#include <AzCore/std/smart_ptr/make_shared.h>
// GraphCanvas
#include <GraphCanvas/Widgets/GraphCanvasEditor/GraphCanvasEditorDockWidget.h>
// GraphModel
#include <GraphModel/Integration/EditorMainWindow.h>
#include <GraphModel/Model/Graph.h>
namespace GraphModelIntegration
{
EditorMainWindow::EditorMainWindow(GraphCanvas::AssetEditorWindowConfig* config, QWidget* parent)
: GraphCanvas::AssetEditorMainWindow(config, parent)
{
}
EditorMainWindow::~EditorMainWindow()
{
GraphControllerNotificationBus::MultiHandler::BusDisconnect();
}
GraphModel::GraphPtr EditorMainWindow::GetGraphById(GraphCanvas::GraphId graphId) const
{
auto it = m_graphs.find(graphId);
if (it != m_graphs.end())
{
return it->second;
}
return nullptr;
}
GraphCanvas::GraphId EditorMainWindow::GetGraphId(GraphModel::GraphPtr graph) const
{
auto it = AZStd::find_if(m_graphs.begin(), m_graphs.end(),
[graph](decltype(m_graphs)::const_reference pair)
{
return graph == pair.second;
});
if (it != m_graphs.end())
{
return it->first;
}
return GraphCanvas::GraphId();
}
void EditorMainWindow::OnEditorOpened(GraphCanvas::EditorDockWidget* dockWidget)
{
GraphCanvas::AssetEditorMainWindow::OnEditorOpened(dockWidget);
GraphCanvas::GraphId graphId = dockWidget->GetGraphId();
// Create the new graph.
GraphModel::GraphPtr graph = AZStd::make_shared<GraphModel::Graph>(GetGraphContext());
m_graphs[graphId] = graph;
// Create the controller for the new graph.
GraphModelIntegration::GraphManagerRequestBus::Broadcast(&GraphModelIntegration::GraphManagerRequests::CreateGraphController, graphId, graph);
// Listen for GraphController notifications on the new graph.
GraphModelIntegration::GraphControllerNotificationBus::MultiHandler::BusConnect(graphId);
}
void EditorMainWindow::OnEditorClosing(GraphCanvas::EditorDockWidget* dockWidget)
{
GraphCanvas::AssetEditorMainWindow::OnEditorClosing(dockWidget);
GraphCanvas::GraphId graphId = dockWidget->GetGraphId();
// Stop listening for GraphController notifications for this graph.
GraphModelIntegration::GraphControllerNotificationBus::MultiHandler::BusDisconnect(graphId);
// Remove the controller for this graph.
GraphModelIntegration::GraphManagerRequestBus::Broadcast(&GraphModelIntegration::GraphManagerRequests::DeleteGraphController, graphId);
// Delete the graph that was created.
m_graphs.erase(graphId);
}
void EditorMainWindow::OnWrapperNodeActionWidgetClicked(const AZ::EntityId& wrapperNode, const QRect& actionWidgetBoundingRect, const QPointF& scenePoint, const QPoint& screenPoint)
{
// Find the GraphModel::NodePtr whose action widget was clicked.
GraphCanvas::GraphId graphId = GetActiveGraphCanvasGraphId();
GraphModel::NodePtr node;
GraphControllerRequestBus::EventResult(node, graphId, &GraphControllerRequests::GetNodeById, wrapperNode);
AZ_Assert(node, "Unable to find NodePtr for the given NodeId");
// Invoke the handler so that the client can handle this event if necessary.
HandleWrapperNodeActionWidgetClicked(node, actionWidgetBoundingRect, scenePoint, screenPoint);
}
}
@@ -0,0 +1,66 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <GraphModel/Integration/FloatDataInterface.h>
#include <GraphModel/Integration/IntegrationBus.h>
namespace GraphModelIntegration
{
FloatDataInterface::FloatDataInterface(GraphModel::SlotPtr slot)
: m_slot(slot)
{
}
double FloatDataInterface::GetNumber() const
{
if (GraphModel::SlotPtr slot = m_slot.lock())
{
return slot->GetValue<float>();
}
else
{
return 0.0;
}
}
void FloatDataInterface::SetNumber(double value)
{
if (GraphModel::SlotPtr slot = m_slot.lock())
{
if (static_cast<float>(value) != slot->GetValue<float>())
{
slot->SetValue(static_cast<float>(value));
GraphCanvas::GraphId graphCanvasSceneId;
IntegrationBus::BroadcastResult(graphCanvasSceneId, &IntegrationBusInterface::GetActiveGraphCanvasSceneId);
IntegrationBus::Broadcast(&IntegrationBusInterface::SignalSceneDirty, graphCanvasSceneId);
}
}
}
int FloatDataInterface::GetDecimalPlaces() const
{
return 7;
}
int FloatDataInterface::GetDisplayDecimalPlaces() const
{
return 4;
}
double FloatDataInterface::GetMin() const
{
return std::numeric_limits<float>::lowest();
}
double FloatDataInterface::GetMax() const
{
return std::numeric_limits<float>::max();
}
}
@@ -0,0 +1,37 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// AZ
#include <AzCore/Serialization/SerializeContext.h>
// Graph Canvas
#include <GraphCanvas/Types/EntitySaveData.h>
// Graph Model
#include <GraphModel/Integration/GraphCanvasMetadata.h>
namespace GraphModelIntegration
{
void GraphCanvasMetadata::Reflect(AZ::ReflectContext* reflectContext)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(reflectContext);
if (serializeContext)
{
serializeContext->Class<GraphCanvasMetadata>()
->Version(0)
->Field("m_sceneMetadata", &GraphCanvasMetadata::m_sceneMetadata)
->Field("m_nodeMetadata", &GraphCanvasMetadata::m_nodeMetadata)
->Field("m_otherMetadata", &GraphCanvasMetadata::m_otherMetadata)
;
}
}
} // namespace ShaderCanvas
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,84 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// AZ
#include <AzCore/std/smart_ptr/make_shared.h>
// Graph Canvas
#include <GraphCanvas/GraphCanvasBus.h>
// Graph Model
#include <GraphModel/Integration/GraphControllerManager.h>
namespace GraphModelIntegration
{
AZ::Entity* GraphControllerManager::CreateScene(GraphModel::GraphPtr graph, const GraphCanvas::EditorId editorId)
{
AZ::Entity* scene = nullptr;
GraphCanvas::GraphCanvasRequestBus::BroadcastResult(scene, &GraphCanvas::GraphCanvasRequests::CreateSceneAndActivate);
// Set the EditorId for the new scene
const AZ::EntityId& sceneId = scene->GetId();
GraphCanvas::SceneRequestBus::Event(sceneId, &GraphCanvas::SceneRequests::SetEditorId, editorId);
// Create a graph controller for the new scene
CreateGraphController(sceneId, graph);
return scene;
}
void GraphControllerManager::RemoveScene(const GraphCanvas::GraphId& sceneId)
{
DeleteGraphController(sceneId);
}
void GraphControllerManager::CreateGraphController(const GraphCanvas::GraphId& sceneId, GraphModel::GraphPtr graph)
{
m_graphControllers[sceneId] = AZStd::make_shared<GraphController>(graph, sceneId);
}
void GraphControllerManager::DeleteGraphController(const GraphCanvas::GraphId& sceneId)
{
m_graphControllers.erase(sceneId);
}
GraphModel::GraphPtr GraphControllerManager::GetGraph(const GraphCanvas::GraphId& sceneId)
{
auto it = m_graphControllers.find(sceneId);
if (it != m_graphControllers.end())
{
return it->second->GetGraph();
}
return nullptr;
}
const GraphModelSerialization& GraphControllerManager::GetSerializedMappings()
{
return m_serialization;
}
void GraphControllerManager::SetSerializedMappings(const GraphModelSerialization& serialization)
{
m_serialization = serialization;
}
void GraphControllerManager::Activate()
{
GraphManagerRequestBus::Handler::BusConnect();
}
void GraphControllerManager::Deactivate()
{
GraphManagerRequestBus::Handler::BusDisconnect();
}
} // namespace GraphModelIntegration
@@ -0,0 +1,65 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <GraphModel/Integration/IntegerDataInterface.h>
#include <GraphModel/Integration/IntegrationBus.h>
namespace GraphModelIntegration
{
IntegerDataInterface::IntegerDataInterface(GraphModel::SlotPtr slot)
: m_slot(slot)
{
}
double IntegerDataInterface::GetNumber() const
{
if (GraphModel::SlotPtr slot = m_slot.lock())
{
return slot->GetValue<int>();
}
else
{
return 0.0;
}
}
void IntegerDataInterface::SetNumber(double value)
{
if (GraphModel::SlotPtr slot = m_slot.lock())
{
if (static_cast<int>(value) != slot->GetValue<int>())
{
slot->SetValue(static_cast<int>(value));
GraphCanvas::GraphId graphCanvasSceneId;
IntegrationBus::BroadcastResult(graphCanvasSceneId, &IntegrationBusInterface::GetActiveGraphCanvasSceneId);
IntegrationBus::Broadcast(&IntegrationBusInterface::SignalSceneDirty, graphCanvasSceneId);
}
}
}
int IntegerDataInterface::GetDecimalPlaces() const
{
return 0;
}
int IntegerDataInterface::GetDisplayDecimalPlaces() const
{
return 0;
}
double IntegerDataInterface::GetMin() const
{
return std::numeric_limits<int>::min();
}
double IntegerDataInterface::GetMax() const
{
return std::numeric_limits<int>::max();
}
}
@@ -0,0 +1,25 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <GraphModel/Integration/NodePalette/GraphCanvasNodePaletteItems.h>
namespace GraphModelIntegration
{
/// Add common utilities to a specific Node Palette tree.
void AddCommonNodePaletteUtilities(GraphCanvas::GraphCanvasTreeItem* rootItem, const GraphCanvas::EditorId& editorId)
{
GraphCanvas::IconDecoratedNodePaletteTreeItem* utilitiesCategory = rootItem->CreateChildNode<GraphCanvas::IconDecoratedNodePaletteTreeItem>("Utilities", editorId);
utilitiesCategory->SetTitlePalette("UtilityNodeTitlePalette");
utilitiesCategory->CreateChildNode<CommentNodePaletteTreeItem>("Comment", editorId);
utilitiesCategory->CreateChildNode<NodeGroupNodePaletteTreeItem>("Node Group", editorId);
}
}
@@ -0,0 +1,35 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Graph Model
#include <GraphModel/Integration/ReadOnlyDataInterface.h>
#include <GraphModel/Integration/IntegrationBus.h>
namespace GraphModelIntegration
{
ReadOnlyDataInterface::ReadOnlyDataInterface(GraphModel::SlotPtr slot)
: m_slot(slot)
{
}
AZStd::string ReadOnlyDataInterface::GetString() const
{
if (GraphModel::SlotPtr slot = m_slot.lock())
{
return slot->GetValue<AZStd::string>();
}
else
{
return "";
}
}
}
@@ -0,0 +1,55 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// AZ
#include <AzFramework/StringFunc/StringFunc.h>
// Graph Model
#include <GraphModel/Integration/StringDataInterface.h>
#include <GraphModel/Integration/IntegrationBus.h>
namespace GraphModelIntegration
{
StringDataInterface::StringDataInterface(GraphModel::SlotPtr slot)
: m_slot(slot)
{
}
AZStd::string StringDataInterface::GetString() const
{
if (GraphModel::SlotPtr slot = m_slot.lock())
{
return slot->GetValue<AZStd::string>();
}
else
{
return "";
}
}
void StringDataInterface::SetString(const AZStd::string& value)
{
if (GraphModel::SlotPtr slot = m_slot.lock())
{
AZStd::string trimValue = value;
AzFramework::StringFunc::TrimWhiteSpace(trimValue, true, true);
if (trimValue != slot->GetValue<AZStd::string>())
{
slot->SetValue(trimValue);
GraphCanvas::GraphId graphCanvasSceneId;
IntegrationBus::BroadcastResult(graphCanvasSceneId, &IntegrationBusInterface::GetActiveGraphCanvasSceneId);
IntegrationBus::Broadcast(&IntegrationBusInterface::SignalSceneDirty, graphCanvasSceneId);
}
}
}
}
@@ -0,0 +1,64 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Qt
#include <QPainter>
#include <QWidget>
// GraphModel
#include <GraphModel/Integration/ThumbnailImageItem.h>
namespace GraphModelIntegration
{
static const QSize IMAGE_MARGIN = QSize(10, 10);
ThumbnailImageItem::ThumbnailImageItem(const QPixmap& image, QGraphicsItem* parent)
: ThumbnailItem(parent)
, m_pixmap(image)
{
}
void ThumbnailImageItem::UpdateImage(const QPixmap& image)
{
m_pixmap = image;
// Schedule a new paint request since we changed the pixmap
update();
}
QSizeF ThumbnailImageItem::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
{
switch (which)
{
case Qt::MinimumSize:
case Qt::PreferredSize:
return m_pixmap.size() + IMAGE_MARGIN;
case Qt::MaximumSize:
return QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
default:
break;
}
return constraint;
}
void ThumbnailImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
(void)option;
(void)widget;
// Draw the pixmap centered in our given frame
QRectF frame(QPointF(0, 0), geometry().size());
QPointF topLeft = frame.center() - (QPointF(m_pixmap.width(), m_pixmap.height()) / 2);
painter->drawPixmap(topLeft, m_pixmap);
}
}
@@ -0,0 +1,35 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <GraphModel/Integration/ThumbnailItem.h>
namespace GraphModelIntegration
{
ThumbnailItem::ThumbnailItem(QGraphicsItem* parent)
: QGraphicsLayoutItem()
, QGraphicsItem(parent)
{
setGraphicsItem(this);
}
void ThumbnailItem::setGeometry(const QRectF &geom)
{
prepareGeometryChange();
QGraphicsLayoutItem::setGeometry(geom);
setPos(geom.topLeft());
}
QRectF ThumbnailItem::boundingRect() const
{
return QRectF(QPointF(0, 0), geometry().size());
}
}