9#ifdef WITH_IO_GREASE_PENCIL
42# if defined(WITH_PUGIXML) || defined(WITH_HARU)
49 using SelectMode = ExportParams::SelectMode;
52 {
int(SelectMode::Active),
"ACTIVE", 0,
"Active",
"Include only the active object"},
53 {
int(SelectMode::Selected),
"SELECTED", 0,
"Selected",
"Include selected objects"},
54 {
int(SelectMode::Visible),
"VISIBLE", 0,
"Visible",
"Include all visible objects"},
55 {0,
nullptr, 0,
nullptr,
nullptr},
60 "selected_object_type",
62 int(SelectMode::Active),
64 "Which objects to include in the export");
71 "Precision of stroke sampling. Low values mean a more precise result, and zero "
76 ot->
srna,
"use_uniform_width",
false,
"Uniform Width",
"Export strokes with uniform width");
84static bool get_invoke_region(
bContext *C,
90 if (screen ==
nullptr) {
94 if (area ==
nullptr) {
100 *r_view3d =
static_cast<View3D *
>(area->spacedata.first);
101 *r_rv3d =
static_cast<RegionView3D *
>(region->regiondata);
144 if (!get_invoke_region(C, ®ion, &v3d, &rv3d)) {
152 const bool recenter_bounds =
true;
154 const IOContext io_context(*C, region, v3d, rv3d, op->
reports);
155 const ImportParams
params = {scale, scene->r.cfra, resolution, use_scene_unit, recenter_bounds};
160 for (
const auto &path : paths) {
185static bool grease_pencil_import_svg_poll(
bContext *C)
198 ot->
name =
"Import SVG as Grease Pencil";
200 ot->
idname =
"WM_OT_grease_pencil_import_svg";
203 ot->
exec = blender::ed::io::grease_pencil_import_svg_exec;
204 ot->
poll = blender::ed::io::grease_pencil_import_svg_poll;
205 ot->
ui = blender::ed::io::grease_pencil_import_svg_draw;
206 ot->
check = blender::ed::io::grease_pencil_import_svg_check;
223 "Resolution of the generated strokes",
233 "Scale of the final strokes",
241 "Apply current scene's unit (as defined by unit scale) to imported data");
293 if (!get_invoke_region(C, ®ion, &v3d, &rv3d)) {
301 const bool export_stroke_materials =
true;
304 const ExportParams::SelectMode select_mode = ExportParams::SelectMode(
306 const ExportParams::FrameMode frame_mode = ExportParams::FrameMode::Active;
310 const IOContext io_context(*C, region, v3d, rv3d, op->
reports);
311 const ExportParams
params = {ob,
314 export_stroke_materials,
315 export_fill_materials,
358static bool grease_pencil_export_svg_poll(
bContext *C)
371 ot->
name =
"Export to SVG";
373 ot->
idname =
"WM_OT_grease_pencil_export_svg";
375 ot->
invoke = blender::ed::io::grease_pencil_export_svg_invoke;
376 ot->
exec = blender::ed::io::grease_pencil_export_svg_exec;
377 ot->
poll = blender::ed::io::grease_pencil_export_svg_poll;
378 ot->
ui = blender::ed::io::grease_pencil_export_svg_draw;
379 ot->
check = blender::ed::io::grease_pencil_export_svg_check;
389 blender::ed::io::grease_pencil_export_common_props_definition(
ot);
395 "Clip drawings to camera size when exporting in camera view");
450 if (!get_invoke_region(C, ®ion, &v3d, &rv3d)) {
458 const bool export_stroke_materials =
true;
461 const ExportParams::SelectMode select_mode = ExportParams::SelectMode(
463 const ExportParams::FrameMode frame_mode = ExportParams::FrameMode(
465 const bool use_clip_camera =
false;
468 const IOContext io_context(*C, region, v3d, rv3d, op->
reports);
469 const ExportParams
params = {ob,
472 export_stroke_materials,
473 export_fill_materials,
522 ui_gpencil_export_pdf_settings(op->
layout, op->
ptr);
525static bool grease_pencil_export_pdf_poll(
bContext *C)
538 ot->
name =
"Export to PDF";
540 ot->
idname =
"WM_OT_grease_pencil_export_pdf";
542 ot->
invoke = blender::ed::io::grease_pencil_export_pdf_invoke;
543 ot->
exec = blender::ed::io::grease_pencil_export_pdf_exec;
544 ot->
poll = blender::ed::io::grease_pencil_export_pdf_poll;
545 ot->
ui = blender::ed::io::grease_pencil_export_pdf_draw;
546 ot->
check = blender::ed::io::grease_pencil_export_pdf_check;
559 {
int(ExportParams::FrameMode::Active),
"ACTIVE", 0,
"Active",
"Include only active frame"},
560 {
int(ExportParams::FrameMode::Selected),
564 "Include selected frames"},
565 {
int(ExportParams::FrameMode::Scene),
"SCENE", 0,
"Scene",
"Include all scene frames"},
566 {0,
nullptr, 0,
nullptr,
nullptr},
569 blender::ed::io::grease_pencil_export_common_props_definition(
ot);
573 int(ExportParams::FrameMode::Active),
575 "Which frames to include in the export");
586 auto fh = std::make_unique<blender::bke::FileHandlerType>();
587 STRNCPY(fh->idname,
"IO_FH_grease_pencil_svg");
588 STRNCPY(fh->import_operator,
"WM_OT_grease_pencil_import_svg");
589 STRNCPY(fh->label,
"SVG as Grease Pencil");
590 STRNCPY(fh->file_extensions_str,
".svg");
bScreen * CTX_wm_screen(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Object * CTX_data_active_object(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
enum eContextObjectMode CTX_data_mode_enum(const bContext *C)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
ScrArea * BKE_screen_find_big_area(const bScreen *screen, int spacetype, short min)
ARegion * BKE_area_find_region_type(const ScrArea *area, int region_type)
bool BLI_path_extension_check(const char *path, const char *ext) ATTR_NONNULL(1
bool BLI_path_extension_ensure(char *path, size_t path_maxncpy, const char *ext) ATTR_NONNULL(1
#define STRNCPY(dst, src)
void ED_fileselect_ensure_default_filepath(bContext *C, wmOperator *op, const char *extension)
uiLayout * uiLayoutBox(uiLayout *layout)
void uiItemL(uiLayout *layout, const char *name, int icon)
uiLayout * uiLayoutRow(uiLayout *layout, bool align)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep)
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void WM_OT_grease_pencil_import_svg(wmOperatorType *ot)
void file_handler_add(std::unique_ptr< FileHandlerType > file_handler)
bool poll_file_object_drop(const bContext *C, blender::bke::FileHandlerType *)
void grease_pencil_file_handler_add()
Vector< std::string > paths_from_operator_properties(PointerRNA *ptr)
int filesel_drop_import_invoke(bContext *C, wmOperator *op, const wmEvent *)
bool export_svg(const IOContext &context, const ExportParams ¶ms, Scene &scene, StringRefNull filepath)
bool import_svg(const IOContext &context, const ImportParams ¶ms, StringRefNull filepath)
bool export_pdf(const IOContext &context, const ExportParams ¶ms, Scene &scene, StringRefNull filepath)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_struct_property_is_set_ex(PointerRNA *ptr, const char *identifier, bool use_ghost)
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
int RNA_int_get(PointerRNA *ptr, const char *name)
float RNA_float_get(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
bool(* check)(bContext *C, wmOperator *op)
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
void(* ui)(bContext *C, wmOperator *op)
struct ReportList * reports
void WM_cursor_wait(bool val)
void WM_event_add_fileselect(bContext *C, wmOperator *op)
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)