Blender V5.3
io_spz_ops.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#ifdef WITH_IO_SPZ
10
11# include "io_spz_ops.hh"
12
13# include <memory>
14
15# include "BLI_string_utf8.hh"
16
17# include "BKE_context.hh"
18# include "BKE_file_handler.hh"
19
20# include "RNA_access.hh"
21# include "RNA_define.hh"
22
23# include "WM_api.hh"
24# include "WM_types.hh"
25
26# include "ED_outliner.hh"
27
28# include "IO_spz.hh"
29# include "io_utils.hh"
30
31namespace blender {
32
33static wmOperatorStatus wm_spz_import_exec(bContext *C, wmOperator *op)
34{
35 SPZImportParams params{
36 .reports = op->reports,
37 };
38
40
41 if (paths.is_empty()) {
42 BKE_report(op->reports, RPT_ERROR, "No filepath given");
43 return OPERATOR_CANCELLED;
44 }
45
46 for (const std::string &path : paths) {
47 params.filepath = path;
48 SPZ_import(C, &params);
49 }
50
51 Scene *scene = CTX_data_scene(C);
56
57 return OPERATOR_FINISHED;
58}
59
60static void wm_spz_import_draw(bContext * /*C*/, wmOperator * /*op*/) {}
61
63{
64 PropertyRNA *prop;
65
66 ot->name = "Import SPZ";
67 ot->description = "Import an SPZ file as a gaussian splat point cloud object";
68 ot->idname = "WM_OT_spz_import";
69
71 ot->exec = wm_spz_import_exec;
72 ot->ui = wm_spz_import_draw;
73 ot->poll = WM_operator_winactive;
74 ot->flag = OPTYPE_UNDO;
75
83
84 /* Only show `.spz` files by default. */
85 prop = RNA_def_string(ot->srna, "filter_glob", "*.spz", 0, "Extension Filter", "");
87}
88
89namespace ed::io {
90
92{
93 auto fh = std::make_unique<bke::FileHandlerType>();
94 STRNCPY_UTF8(fh->idname, "IO_FH_spz");
95 STRNCPY_UTF8(fh->import_operator, "WM_OT_spz_import");
96 STRNCPY_UTF8(fh->label, "SPZ");
97 STRNCPY_UTF8(fh->file_extensions_str, ".spz");
98 fh->poll_drop = poll_file_object_drop;
99 bke::file_handler_add(std::move(fh));
100}
101
102} // namespace ed::io
103} // namespace blender
104
105#endif /* WITH_IO_SPZ */
#define STRNCPY_UTF8(dst, src)
#define C
Definition RandGen.cpp:29
#define ND_OB_ACTIVE
Definition WM_types.hh:459
#define ND_OB_SELECT
Definition WM_types.hh:461
#define NC_SCENE
Definition WM_types.hh:391
#define ND_LAYER_CONTENT
Definition WM_types.hh:472
void file_handler_add(std::unique_ptr< FileHandlerType > file_handler)
bool poll_file_object_drop(const bContext *C, bke::FileHandlerType *)
Definition io_utils.cc:62
Vector< std::string > paths_from_operator_properties(PointerRNA *ptr)
Definition io_utils.cc:79
wmOperatorStatus filesel_drop_import_invoke(bContext *C, wmOperator *op, const wmEvent *)
Definition io_utils.cc:30
void spz_file_handler_add()
BMesh Iterators.
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void WM_operator_properties_filesel(wmOperatorType *ot, const int filter, const short type, const eFileSel_Action action, const eFileSel_Flag flag, const short display, const short sort)
void ED_outliner_select_sync_from_object_tag(bContext *C)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
@ WM_FILESEL_DIRECTORY
Definition WM_api.hh:1330
@ WM_FILESEL_FILES
Definition WM_api.hh:1333
@ WM_FILESEL_FILEPATH
Definition WM_api.hh:1332
void SPZ_import(bContext *C, const SPZImportParams *import_params)
Definition IO_spz.cc:15
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
@ FILE_OPENFILE
Definition WM_api.hh:1341
bool WM_operator_winactive(bContext *C)
@ PROP_HIDDEN
Definition RNA_types.hh:408
void WM_OT_spz_import(wmOperatorType *ot)
Scene * CTX_data_scene(const bContext *C)
@ OPTYPE_UNDO
Definition WM_types.hh:190