[Bf-blender-cvs] [439fdfcda7b] functions: initial ability to show warning messages in nodes
Jacques Lucke
noreply at git.blender.org
Wed Mar 27 12:19:00 CET 2019
Commit: 439fdfcda7b2824d0dfd2570609222d906e42f9d
Author: Jacques Lucke
Date: Wed Mar 27 10:30:55 2019 +0100
Branches: functions
https://developer.blender.org/rB439fdfcda7b2824d0dfd2570609222d906e42f9d
initial ability to show warning messages in nodes
===================================================================
M release/scripts/startup/function_nodes/base.py
M source/blender/functions/CMakeLists.txt
M source/blender/functions/backends/tuple_call/execution_context.cpp
M source/blender/functions/backends/tuple_call/execution_context.hpp
A source/blender/functions/core/source_info.cpp
M source/blender/functions/core/source_info.hpp
M source/blender/functions/frontends/data_flow_nodes/builder.cpp
M source/blender/functions/functions/lists.cpp
===================================================================
diff --git a/release/scripts/startup/function_nodes/base.py b/release/scripts/startup/function_nodes/base.py
index 5b02bfa1cb6..d2f552f9dae 100644
--- a/release/scripts/startup/function_nodes/base.py
+++ b/release/scripts/startup/function_nodes/base.py
@@ -71,6 +71,8 @@ class BaseNode:
search_terms = tuple()
search_terms_only = False
+ warning_msg: StringProperty(default="")
+
def init(self, context):
from . update import managed_update
with managed_update():
@@ -143,6 +145,8 @@ class BaseNode:
return [], []
def draw_buttons(self, context, layout):
+ if self.warning_msg != "":
+ layout.label(text=self.warning_msg)
self.draw(layout)
for decl in self.storage.sockets_per_decl.keys():
decl.draw_node(layout, self)
diff --git a/source/blender/functions/CMakeLists.txt b/source/blender/functions/CMakeLists.txt
index 6a9a19f6e56..76c0b2d9a54 100644
--- a/source/blender/functions/CMakeLists.txt
+++ b/source/blender/functions/CMakeLists.txt
@@ -33,6 +33,7 @@ set(SRC
core/data_flow_graph.hpp
core/data_flow_graph.cpp
core/source_info.hpp
+ core/source_info.cpp
core/dot_export.cpp
backends/tuple_call/cpp_types.hpp
diff --git a/source/blender/functions/backends/tuple_call/execution_context.cpp b/source/blender/functions/backends/tuple_call/execution_context.cpp
index 2a5e8c8f86e..c596bfc68b8 100644
--- a/source/blender/functions/backends/tuple_call/execution_context.cpp
+++ b/source/blender/functions/backends/tuple_call/execution_context.cpp
@@ -19,6 +19,13 @@ namespace FN {
}
}
+ void SourceInfoStackFrame::handle_warning(std::string msg) const
+ {
+ if (m_source != nullptr) {
+ m_source->handle_warning(msg);
+ }
+ }
+
std::string TextStackFrame::to_string() const
{
return std::string(m_text);
@@ -30,4 +37,11 @@ namespace FN {
std::cout << "-> " << msg << std::endl;
}
+ void ExecutionContext::log_warning(std::string msg)
+ {
+ for (StackFrame *frame : m_stack) {
+ frame->handle_warning(msg);
+ }
+ }
+
} /* namespace FN */
\ No newline at end of file
diff --git a/source/blender/functions/backends/tuple_call/execution_context.hpp b/source/blender/functions/backends/tuple_call/execution_context.hpp
index 72b8509e197..a1934097ebe 100644
--- a/source/blender/functions/backends/tuple_call/execution_context.hpp
+++ b/source/blender/functions/backends/tuple_call/execution_context.hpp
@@ -7,6 +7,8 @@ namespace FN {
class StackFrame {
public:
virtual std::string to_string() const = 0;
+
+ virtual void handle_warning(std::string UNUSED(msg)) const {}
};
class SourceInfoStackFrame : public StackFrame {
@@ -23,6 +25,7 @@ namespace FN {
}
std::string to_string() const override;
+ void handle_warning(std::string msg) const override;
};
class TextStackFrame : public StackFrame {
@@ -60,6 +63,16 @@ namespace FN {
}
void print_traceback() const;
+
+ StackFrame **begin()
+ {
+ return m_stack.begin();
+ }
+
+ StackFrame **end()
+ {
+ return m_stack.end();
+ }
};
class ExecutionContext {
@@ -76,6 +89,7 @@ namespace FN {
}
void print_with_traceback(std::string msg);
+ void log_warning(std::string msg);
};
} /* namespace FN */
\ No newline at end of file
diff --git a/source/blender/functions/core/source_info.cpp b/source/blender/functions/core/source_info.cpp
new file mode 100644
index 00000000000..7f8aedd2dce
--- /dev/null
+++ b/source/blender/functions/core/source_info.cpp
@@ -0,0 +1,8 @@
+#include "FN_core.hpp"
+
+namespace FN {
+
+ void SourceInfo::handle_warning(std::string msg) const
+ { }
+
+} /* namespace FN */
\ No newline at end of file
diff --git a/source/blender/functions/core/source_info.hpp b/source/blender/functions/core/source_info.hpp
index 3c9090576b0..82db73b44fa 100644
--- a/source/blender/functions/core/source_info.hpp
+++ b/source/blender/functions/core/source_info.hpp
@@ -9,6 +9,7 @@ namespace FN {
virtual ~SourceInfo() {}
virtual std::string to_string() const = 0;
+ virtual void handle_warning(std::string msg) const;
};
} /* namespace FN */
\ No newline at end of file
diff --git a/source/blender/functions/frontends/data_flow_nodes/builder.cpp b/source/blender/functions/frontends/data_flow_nodes/builder.cpp
index a2e9e073756..1f2ce335251 100644
--- a/source/blender/functions/frontends/data_flow_nodes/builder.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/builder.cpp
@@ -26,6 +26,16 @@ namespace FN { namespace DataFlowNodes {
ss << " - Node \"" << m_bnode->name << "\"";
return ss.str();
}
+
+ void handle_warning(std::string msg) const override
+ {
+ PointerRNA ptr;
+ RNA_pointer_create(
+ &m_btree->id, &RNA_Node,
+ m_bnode, &ptr);
+
+ RNA_string_set(&ptr, "warning_msg", msg.c_str());
+ }
};
class LinkSource : public SourceInfo {
diff --git a/source/blender/functions/functions/lists.cpp b/source/blender/functions/functions/lists.cpp
index fb0ab34cfe7..1286f04f5ff 100644
--- a/source/blender/functions/functions/lists.cpp
+++ b/source/blender/functions/functions/lists.cpp
@@ -33,7 +33,7 @@ namespace FN { namespace Functions {
template<typename T>
class AppendToList : public TupleCallBody {
- void call(Tuple &fn_in, Tuple &fn_out, ExecutionContext &UNUSED(ctx)) const override
+ void call(Tuple &fn_in, Tuple &fn_out, ExecutionContext &ctx) const override
{
auto list = fn_in.relocate_out<SharedList<T>>(0);
T value = fn_in.relocate_out<T>(1);
More information about the Bf-blender-cvs
mailing list