28#include "RNA_prototypes.hh"
40 const std::string label = fmt::format(
"{:.5f}", value);
41 layout.label(label, ICON_NONE);
45 const std::string label = fmt::format(
"{}", value);
46 layout.
label(label, ICON_NONE);
55 col.label(fmt::format(
"{}: {:.5f}",
IFACE_(
"X"), value.x), ICON_NONE);
56 col.label(fmt::format(
"{}: {:.5f}",
IFACE_(
"Y"), value.y), ICON_NONE);
57 col.label(fmt::format(
"{}: {:.5f}",
IFACE_(
"Z"), value.z), ICON_NONE);
70 const int max_display_length = 200;
71 layout.
label(value.
substr(0, max_display_length), ICON_NONE);
78 params.node.identifier,
nullptr);
82 const int socket_index =
params.socket.index();
95 if (single_value.
is_type<
float>()) {
103 if (single_value.
is_type<
int>()) {
107 if (single_value.
is_type<
bool>()) {
111 if (single_value.
is_type<std::string>()) {
123 const CPPType &value_type = *
params.socket.typeinfo->base_cpp_type;
124 const CPPType &socket_base_cpp_type = *
params.socket.typeinfo->base_cpp_type;
126 if (value_type != socket_base_cpp_type) {
127 if (!conversions.
is_convertible(value_type, socket_base_cpp_type)) {
133 value_type, socket_base_cpp_type, value.
get(), socket_value);
135 switch (
params.socket.type) {
182 snode->
edittree->ensure_topology_cache();
184 if (!socket.is_directly_linked()) {
206 b.use_custom_socket_order();
207 b.allow_any_socket_order();
209 const bNode *node =
b.node_or_null();
212 if (!node || !
tree) {
216 b.add_default_layout();
224 auto &input_decl =
b.add_input(socket_type,
name, identifier)
228 input_decl.field_on_all();
230 input_decl.structure_type(StructureType::Dynamic);
234 b.add_input<
decl::Extend>(
"",
"__extend__").structure_type(StructureType::Dynamic);
241 data->domain = int8_t(AttrDomain::Auto);
250 bool has_geometry_input =
false;
251 bool has_potential_field_input =
false;
252 for (
const int i :
IndexRange(storage.items_num)) {
256 has_geometry_input =
true;
259 has_potential_field_input =
true;
263 if (has_geometry_input && has_potential_field_input) {
275 C, panel, ntree, node);
278 panel->use_property_split_set(
true);
279 panel->use_property_decorate_set(
false);
280 panel->prop(item_ptr,
"socket_type",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
281 panel->prop(item_ptr,
"auto_remove",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
291 bNode &node =
params.add_node(
"GeometryNodeViewer");
294 params.update_and_connect_available_socket(node, item->
name);
310 const StringRef viewer_attribute_name =
".viewer";
311 std::optional<int> last_geometry_identifier;
312 for (
const int i :
IndexRange(storage.items_num)) {
321 if (!last_geometry_identifier) {
329 r_log.
items.lookup_key_as(*last_geometry_identifier).value)
333 if (!(value.is_single() || value.is_context_dependent_field())) {
338 if (domain_or_auto == AttrDomain::Instance) {
343 component, viewer_attribute_name, AttrDomain::Instance, field);
359 if (domain_or_auto == AttrDomain::Auto) {
363 used_domain = *domain;
366 used_domain = AttrDomain::Point;
374 last_geometry_identifier.reset();
383 for (
const int i :
IndexRange(storage.items_num)) {
384 void *src_value = input_values[
i];
403 if (std::optional<ed::space_node::ObjectAndModifier> object_and_modifier =
410 row.
icon = ICON_ERROR;
411 row.
text =
TIP_(
"Modifier disabled");
412 row.
tooltip =
TIP_(
"The viewer does not work because the modifier is disabled");
413 params.rows.append(std::move(row));
415 else if (!nmd.
node_group->group_output_node()) {
417 row.
icon = ICON_ERROR;
420 "The viewer does not work because the node group used by the modifier has no output");
421 params.rows.append(std::move(row));
428 row.
icon = ICON_INFO;
429 row.
text =
TIP_(
"No color overlay");
431 "Rotation values can only be displayed with the text overlay in the 3D view");
432 params.rows.append(std::move(row));
451 *dst_storage = src_storage;
452 dst_node->
storage = dst_storage;
484 ntype.
ui_description =
"Display the input data in the Spreadsheet Editor";
SpaceNode * CTX_wm_space_node(const bContext *C)
Main * CTX_data_main(const bContext *C)
#define NODE_CLASS_OUTPUT
#define NODE_STORAGE_FUNCS(StorageT)
#define BUFFER_FOR_CPP_TYPE_VALUE(type, variable_name)
#define BLI_SCOPED_DEFER(function_to_defer)
void BLO_read_string(BlendDataReader *reader, char **ptr_p)
void BLO_write_string(BlendWriter *writer, const char *data_ptr)
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_COLOR
@ NODE_GEO_VIEWER_ITEM_FLAG_AUTO_REMOVE
#define NOD_REGISTER_NODE(REGISTER_FUNC)
BMesh const char void * data
void destruct(void *ptr) const
constexpr StringRef substr(int64_t start, int64_t size) const
void convert_to_uninitialized(const CPPType &from_type, const CPPType &to_type, const void *from_value, void *to_value) const
bool is_convertible(const CPPType &from_type, const CPPType &to_type) const
GPointer get_single_ptr() const
GeoTreeLog * get_main_tree_log(const bke::bNodeTreeZone *zone) const
static ContextualGeoTreeLogs get_contextual_tree_logs(const SpaceNode &snode)
void ensure_socket_values()
void ensure_viewer_node_logs()
Map< int32_t, ViewerNodeLog *, 0 > viewer_node_logs
ValueLog * find_socket_value_log(const bNodeSocket &query_socket)
CustomIDVectorSet< Item, ItemIdentifierGetter > items
void * MEM_mallocN(size_t len, const char *str)
void * MEM_callocN(size_t len, const char *str)
void MEM_freeN(void *vmemh)
std::optional< AttrDomain > try_detect_field_domain(const GeometryComponent &component, const fn::GField &field)
const DataTypeConversions & get_implicit_type_conversions()
void node_register_type(bNodeType &ntype)
bool try_capture_field_on_geometry(MutableAttributeAccessor attributes, const fn::FieldContext &field_context, const StringRef attribute_id, AttrDomain domain, const fn::Field< bool > &selection, const fn::GField &field)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
std::optional< ObjectAndModifier > get_modifier_for_node_editor(const SpaceNode &snode)
void activate_geometry_node(Main &bmain, SpaceNode &snode, bNode &node, std::optional< int > item_identifier=std::nullopt)
void foreach_real_geometry(bke::GeometrySet &geometry, FunctionRef< void(bke::GeometrySet &geometry_set)> fn)
static void node_copy_storage(bNodeTree *, bNode *dst_node, const bNode *src_node)
static void node_layout_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
static bool node_insert_link(bke::NodeInsertLinkParams ¶ms)
static void draw_input_socket(CustomSocketDrawParams ¶ms)
static void node_blend_write(const bNodeTree &, const bNode &node, BlendWriter &writer)
static void draw_vector(uiLayout &layout, const float3 &value)
static bool draw_from_viewer_log_value(CustomSocketDrawParams ¶ms, geo_eval_log::GeoTreeLog &tree_log)
static void draw_bool(uiLayout &layout, const bool value)
static bool draw_from_socket_log_value(CustomSocketDrawParams ¶ms, geo_eval_log::GeoTreeLog &tree_log)
static void draw_float(uiLayout &layout, const float value)
static void node_blend_read(bNodeTree &, bNode &node, BlendDataReader &reader)
static void draw_int(uiLayout &layout, const int value)
static void draw_color(uiLayout &layout, const ColorGeometry4f &value)
static bool draw_generic_value_log(CustomSocketDrawParams ¶ms, const GPointer &value)
static void node_free_storage(bNode *node)
static void geo_viewer_node_log_impl(const bNode &node, const Span< bke::SocketValueVariant * > input_values, geo_eval_log::ViewerNodeLog &r_log)
static void log_viewer_attribute(const bNode &node, geo_eval_log::ViewerNodeLog &r_log)
static void node_init(bNodeTree *, bNode *node)
static void node_register()
static void draw_string(uiLayout &layout, const StringRef value)
static void node_operators()
static void node_declare(NodeDeclarationBuilder &b)
static void node_extra_info(NodeExtraInfoParams ¶ms)
static void node_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms)
void make_common_operators()
static void draw_items_list_with_operators(const bContext *C, uiLayout *layout, const bNodeTree &tree, const bNode &node)
static void draw_active_item_props(const bNodeTree &tree, const bNode &node, const FunctionRef< void(PointerRNA *item_ptr)> draw_item)
void blend_write(BlendWriter *writer, const bNode &node)
void destruct_array(bNode &node)
void blend_read_data(BlendDataReader *reader, bNode &node)
void copy_array(const bNode &src_node, bNode &dst_node)
Accessor::ItemT * add_item_with_socket_type_and_name(bNodeTree &ntree, bNode &node, const eNodeSocketDatatype socket_type, const char *name, std::optional< int > dimensions=std::nullopt)
bool try_add_item_via_any_extend_socket(bNodeTree &ntree, bNode &extend_node, bNode &storage_node, bNodeLink &link, const std::optional< StringRef > socket_identifier=std::nullopt, typename Accessor::ItemT **r_new_item=nullptr)
void geo_viewer_node_log(const bNode &node, const Span< bke::SocketValueVariant * > input_values, geo_eval_log::ViewerNodeLog &r_log)
bool socket_type_supports_fields(const eNodeSocketDatatype socket_type)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
VecBase< float, 3 > float3
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
NodeGeometryViewerItem * items
struct bNodeTree * node_group
struct bNodeTree * edittree
bNodeSocketTypeHandle * typeinfo
NodeBlendWriteFunction blend_write_storage_content
std::string ui_description
NodeBlendDataReadFunction blend_data_read_storage_content
void(* initfunc)(bNodeTree *ntree, bNode *node)
void(* draw_buttons_ex)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeExtraInfoFunction get_extra_info
const char * enum_name_legacy
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
bool(* insert_link)(NodeInsertLinkParams ¶ms)
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
NodeDeclareFunction declare
void(* register_operators)()
static StructRNA * item_srna
static void blend_read_data_item(BlendDataReader *reader, ItemT &item)
static std::string socket_identifier_for_item(const NodeGeometryViewerItem &item)
static void blend_write_item(BlendWriter *writer, const ItemT &item)
bke::SocketValueVariant value
PanelLayout panel(const bContext *C, blender::StringRef idname, bool default_closed)
void label(blender::StringRef name, int icon)
uiLayout & column(bool align)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)