IO: Use panels for Alembic, OBJ, PLY, and STL

Instead of using "box" layouts for these import/export operators, use
panels instead.

Motivation for doing so is two fold.

Firstly the use of panels instead of boxes is more consistent with other
parts of Blender and with other IO addons implemented in Python (FBX,
glTF, 3ds, etc.)

Secondly, in the case of an Import invoked from drag-n-drop or Export
configured on a Collection, the large number of options often exposed
results in very long layouts. Panels allow us to close some sections by
default and allows the user to open/close panels based on their own
needs in general.

Along the way some effort went into standardizing the layout and wording
used as much as possible.

USD is a bigger change and requires some additional coordination. It
will be submitted and reviewed separately.

Pull Request: https://projects.blender.org/blender/blender/pulls/121557
This commit is contained in:
Jesse Yurkovich
2024-05-09 22:27:03 +02:00
committed by Jesse Yurkovich
parent d089b5e6ad
commit b773eca1b5
4 changed files with 260 additions and 261 deletions

View File

@@ -146,98 +146,92 @@ static int wm_alembic_export_exec(bContext *C, wmOperator *op)
return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
static void ui_alembic_export_settings(const bContext *C, uiLayout *layout, PointerRNA *imfptr)
static void ui_alembic_export_settings(const bContext *C, uiLayout *layout, PointerRNA *ptr)
{
uiLayout *box, *row, *col, *sub;
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
box = uiLayoutBox(layout);
uiItemL(box, IFACE_("Manual Transform"), ICON_NONE);
if (uiLayout *panel = uiLayoutPanel(C, layout, "ABC_export_general", false, IFACE_("General"))) {
uiLayout *col = uiLayoutColumn(panel, false);
uiItemR(col, ptr, "global_scale", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(box, imfptr, "global_scale", UI_ITEM_NONE, nullptr, ICON_NONE);
/* Scene Options */
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
uiItemL(row, IFACE_("Scene Options"), ICON_SCENE_DATA);
col = uiLayoutColumn(box, false);
sub = uiLayoutColumn(col, true);
uiItemR(sub, imfptr, "start", UI_ITEM_NONE, IFACE_("Frame Start"), ICON_NONE);
uiItemR(sub, imfptr, "end", UI_ITEM_NONE, IFACE_("End"), ICON_NONE);
uiItemR(col, imfptr, "xsamples", UI_ITEM_NONE, IFACE_("Samples Transform"), ICON_NONE);
uiItemR(col, imfptr, "gsamples", UI_ITEM_NONE, IFACE_("Geometry"), ICON_NONE);
sub = uiLayoutColumn(col, true);
uiItemR(sub, imfptr, "sh_open", UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
uiItemR(sub, imfptr, "sh_close", UI_ITEM_R_SLIDER, IFACE_("Close"), ICON_NONE);
uiItemS(col);
uiItemR(col, imfptr, "flatten", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(sub, imfptr, "use_instancing", UI_ITEM_NONE, IFACE_("Use Instancing"), ICON_NONE);
uiItemR(sub,
imfptr,
"export_custom_properties",
UI_ITEM_NONE,
IFACE_("Custom Properties"),
ICON_NONE);
if (CTX_wm_space_file(C)) {
sub = uiLayoutColumnWithHeading(col, true, IFACE_("Only"));
uiItemR(sub, imfptr, "selected", UI_ITEM_NONE, IFACE_("Selected Objects"), ICON_NONE);
uiItemR(
sub, imfptr, "visible_objects_only", UI_ITEM_NONE, IFACE_("Visible Objects"), ICON_NONE);
col = uiLayoutColumn(panel, false);
if (CTX_wm_space_file(C)) {
uiLayout *sub = uiLayoutColumnWithHeading(col, true, IFACE_("Include"));
uiItemR(sub, ptr, "selected", UI_ITEM_NONE, IFACE_("Selection Only"), ICON_NONE);
uiItemR(sub, ptr, "visible_objects_only", UI_ITEM_NONE, IFACE_("Visible Only"), ICON_NONE);
}
}
col = uiLayoutColumn(box, true);
uiItemR(col, imfptr, "evaluation_mode", UI_ITEM_NONE, nullptr, ICON_NONE);
/* Scene Options */
if (uiLayout *panel = uiLayoutPanel(C, layout, "ABC_export_scene", false, IFACE_("Scene"))) {
uiLayout *col = uiLayoutColumn(panel, false);
uiLayout *sub = uiLayoutColumn(col, true);
uiItemR(sub, ptr, "start", UI_ITEM_NONE, IFACE_("Frame Start"), ICON_NONE);
uiItemR(sub, ptr, "end", UI_ITEM_NONE, IFACE_("End"), ICON_NONE);
sub = uiLayoutColumn(col, true);
uiItemR(sub, ptr, "xsamples", UI_ITEM_NONE, IFACE_("Samples Transform"), ICON_NONE);
uiItemR(sub, ptr, "gsamples", UI_ITEM_NONE, IFACE_("Geometry"), ICON_NONE);
sub = uiLayoutColumn(col, true);
uiItemR(sub, ptr, "sh_open", UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
uiItemR(sub, ptr, "sh_close", UI_ITEM_R_SLIDER, IFACE_("Close"), ICON_NONE);
uiItemS(col);
uiItemR(col, ptr, "use_instancing", UI_ITEM_NONE, IFACE_("Use Instancing"), ICON_NONE);
uiItemR(col,
ptr,
"export_custom_properties",
UI_ITEM_NONE,
IFACE_("Custom Properties"),
ICON_NONE);
uiItemR(col, ptr, "flatten", UI_ITEM_NONE, nullptr, ICON_NONE);
col = uiLayoutColumn(panel, true);
uiItemR(col, ptr, "evaluation_mode", UI_ITEM_NONE, nullptr, ICON_NONE);
}
/* Object Data */
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
uiItemL(row, IFACE_("Object Options"), ICON_OBJECT_DATA);
if (uiLayout *panel = uiLayoutPanel(C, layout, "ABC_export_geometry", false, IFACE_("Geometry")))
{
uiLayout *col = uiLayoutColumn(panel, true);
uiItemR(col, ptr, "uvs", UI_ITEM_NONE, nullptr, ICON_NONE);
col = uiLayoutColumn(box, false);
uiLayout *row = uiLayoutRow(col, false);
uiLayoutSetActive(row, RNA_boolean_get(ptr, "uvs"));
uiItemR(row, ptr, "packuv", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, imfptr, "uvs", UI_ITEM_NONE, nullptr, ICON_NONE);
row = uiLayoutRow(col, false);
uiLayoutSetActive(row, RNA_boolean_get(imfptr, "uvs"));
uiItemR(row, imfptr, "packuv", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "normals", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "vcolors", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "orcos", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "face_sets", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "curves_as_mesh", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, imfptr, "normals", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, imfptr, "vcolors", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, imfptr, "orcos", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, imfptr, "face_sets", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, imfptr, "curves_as_mesh", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemS(col);
uiItemS(col);
uiLayout *sub = uiLayoutColumnWithHeading(col, true, IFACE_("Subdivision"));
uiItemR(sub, ptr, "apply_subdiv", UI_ITEM_NONE, IFACE_("Apply"), ICON_NONE);
uiItemR(sub, ptr, "subdiv_schema", UI_ITEM_NONE, IFACE_("Use Schema"), ICON_NONE);
sub = uiLayoutColumnWithHeading(col, true, IFACE_("Subdivisions"));
uiItemR(sub, imfptr, "apply_subdiv", UI_ITEM_NONE, IFACE_("Apply"), ICON_NONE);
uiItemR(sub, imfptr, "subdiv_schema", UI_ITEM_NONE, IFACE_("Use Schema"), ICON_NONE);
uiItemS(col);
col = uiLayoutColumn(box, false);
uiItemR(col, imfptr, "triangulate", UI_ITEM_NONE, nullptr, ICON_NONE);
sub = uiLayoutColumn(col, false);
uiLayoutSetActive(sub, RNA_boolean_get(imfptr, "triangulate"));
uiItemR(sub, imfptr, "quad_method", UI_ITEM_NONE, IFACE_("Method Quads"), ICON_NONE);
uiItemR(sub, imfptr, "ngon_method", UI_ITEM_NONE, IFACE_("Polygons"), ICON_NONE);
col = uiLayoutColumn(panel, false);
uiItemR(col, ptr, "triangulate", UI_ITEM_NONE, nullptr, ICON_NONE);
sub = uiLayoutColumn(col, false);
uiLayoutSetActive(sub, RNA_boolean_get(ptr, "triangulate"));
uiItemR(sub, ptr, "quad_method", UI_ITEM_NONE, IFACE_("Method Quads"), ICON_NONE);
uiItemR(sub, ptr, "ngon_method", UI_ITEM_NONE, IFACE_("Polygons"), ICON_NONE);
}
/* Particle Data */
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
uiItemL(row, IFACE_("Particle Systems"), ICON_PARTICLE_DATA);
col = uiLayoutColumn(box, true);
uiItemR(col, imfptr, "export_hair", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, imfptr, "export_particles", UI_ITEM_NONE, nullptr, ICON_NONE);
if (uiLayout *panel = uiLayoutPanel(
C, layout, "ABC_export_particles", false, IFACE_("Particle Systems")))
{
uiLayout *col = uiLayoutColumn(panel, true);
uiItemR(col, ptr, "export_hair", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "export_particles", UI_ITEM_NONE, nullptr, ICON_NONE);
}
}
static void wm_alembic_export_draw(bContext *C, wmOperator *op)
@@ -373,9 +367,9 @@ void WM_OT_alembic_export(wmOperatorType *ot)
prop = RNA_def_string(ot->srna, "collection", nullptr, MAX_IDPROP_NAME, "Collection", nullptr);
RNA_def_property_flag(prop, PROP_HIDDEN);
RNA_def_boolean(ot->srna, "uvs", true, "UVs", "Export UVs");
RNA_def_boolean(ot->srna, "uvs", true, "UV Coordinates", "Export UV coordinates");
RNA_def_boolean(ot->srna, "packuv", true, "Pack UV Islands", "Export UVs with packed island");
RNA_def_boolean(ot->srna, "packuv", true, "Merge UVs", "");
RNA_def_boolean(ot->srna, "normals", true, "Normals", "Export normals");
@@ -473,7 +467,7 @@ void WM_OT_alembic_export(wmOperatorType *ot)
"evaluation_mode",
rna_enum_abc_export_evaluation_mode_items,
DAG_EVAL_RENDER,
"Use Settings for",
"Settings",
"Determines visibility of objects, modifier settings, and other areas where there "
"are different settings for viewport and rendering");
@@ -570,33 +564,29 @@ static int get_sequence_len(const char *filepath, int *ofs)
/* ************************************************************************** */
static void ui_alembic_import_settings(uiLayout *layout, PointerRNA *imfptr)
static void ui_alembic_import_settings(const bContext *C, uiLayout *layout, PointerRNA *ptr)
{
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
uiLayout *box = uiLayoutBox(layout);
uiLayout *row = uiLayoutRow(box, false);
uiItemL(row, IFACE_("Manual Transform"), ICON_NONE);
if (uiLayout *panel = uiLayoutPanel(C, layout, "ABC_import_general", false, IFACE_("General"))) {
uiLayout *col = uiLayoutColumn(panel, false);
uiItemR(col, ptr, "scale", UI_ITEM_NONE, nullptr, ICON_NONE);
}
uiItemR(box, imfptr, "scale", UI_ITEM_NONE, nullptr, ICON_NONE);
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
uiItemL(row, IFACE_("Options"), ICON_NONE);
uiLayout *col = uiLayoutColumn(box, false);
uiItemR(col, imfptr, "relative_path", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, imfptr, "set_frame_range", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, imfptr, "is_sequence", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, imfptr, "validate_meshes", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, imfptr, "always_add_cache_reader", UI_ITEM_NONE, nullptr, ICON_NONE);
if (uiLayout *panel = uiLayoutPanel(C, layout, "ABC_import_options", false, IFACE_("Options"))) {
uiLayout *col = uiLayoutColumn(panel, false);
uiItemR(col, ptr, "relative_path", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "set_frame_range", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "is_sequence", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "validate_meshes", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "always_add_cache_reader", UI_ITEM_NONE, nullptr, ICON_NONE);
}
}
static void wm_alembic_import_draw(bContext * /*C*/, wmOperator *op)
static void wm_alembic_import_draw(bContext *C, wmOperator *op)
{
ui_alembic_import_settings(op->layout, op->ptr);
ui_alembic_import_settings(C, op->layout, op->ptr);
}
/* op->invoke, opens fileselect if path property not set, otherwise executes */

View File

@@ -115,93 +115,94 @@ static int wm_obj_export_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static void ui_obj_export_settings(const bContext *C, uiLayout *layout, PointerRNA *imfptr)
static void ui_obj_export_settings(const bContext *C, uiLayout *layout, PointerRNA *ptr)
{
const bool export_animation = RNA_boolean_get(imfptr, "export_animation");
const bool export_smooth_groups = RNA_boolean_get(imfptr, "export_smooth_groups");
const bool export_materials = RNA_boolean_get(imfptr, "export_materials");
const bool export_animation = RNA_boolean_get(ptr, "export_animation");
const bool export_smooth_groups = RNA_boolean_get(ptr, "export_smooth_groups");
const bool export_materials = RNA_boolean_get(ptr, "export_materials");
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
uiLayout *box, *col, *sub;
/* Object General options. */
if (uiLayout *panel = uiLayoutPanel(C, layout, "OBJ_export_general", false, IFACE_("General"))) {
uiLayout *col = uiLayoutColumn(panel, false);
/* Object Transform options. */
box = uiLayoutBox(layout);
col = uiLayoutColumn(box, false);
if (CTX_wm_space_file(C)) {
uiLayout *sub = uiLayoutColumnWithHeading(col, false, IFACE_("Include"));
uiItemR(
sub, ptr, "export_selected_objects", UI_ITEM_NONE, IFACE_("Selection Only"), ICON_NONE);
}
if (CTX_wm_space_file(C)) {
sub = uiLayoutColumnWithHeading(col, false, IFACE_("Limit to"));
uiItemR(
sub, imfptr, "export_selected_objects", UI_ITEM_NONE, IFACE_("Selected Only"), ICON_NONE);
uiItemR(col, ptr, "global_scale", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "forward_axis", UI_ITEM_NONE, IFACE_("Forward Axis"), ICON_NONE);
uiItemR(col, ptr, "up_axis", UI_ITEM_NONE, IFACE_("Up Axis"), ICON_NONE);
}
else {
sub = uiLayoutColumn(col, false);
}
uiItemR(sub, imfptr, "global_scale", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(sub, imfptr, "forward_axis", UI_ITEM_NONE, IFACE_("Forward Axis"), ICON_NONE);
uiItemR(sub, imfptr, "up_axis", UI_ITEM_NONE, IFACE_("Up Axis"), ICON_NONE);
col = uiLayoutColumn(box, false);
sub = uiLayoutColumn(col, false);
sub = uiLayoutColumnWithHeading(col, false, IFACE_("Objects"));
uiItemR(sub, imfptr, "apply_modifiers", UI_ITEM_NONE, IFACE_("Apply Modifiers"), ICON_NONE);
uiItemR(sub, imfptr, "export_eval_mode", UI_ITEM_NONE, IFACE_("Properties"), ICON_NONE);
/* Geometry options. */
box = uiLayoutBox(layout);
col = uiLayoutColumn(box, false);
sub = uiLayoutColumnWithHeading(col, false, IFACE_("Geometry"));
uiItemR(sub, imfptr, "export_uv", UI_ITEM_NONE, IFACE_("UV Coordinates"), ICON_NONE);
uiItemR(sub, imfptr, "export_normals", UI_ITEM_NONE, IFACE_("Normals"), ICON_NONE);
uiItemR(sub, imfptr, "export_colors", UI_ITEM_NONE, IFACE_("Colors"), ICON_NONE);
uiItemR(sub,
imfptr,
"export_triangulated_mesh",
UI_ITEM_NONE,
IFACE_("Triangulated Mesh"),
ICON_NONE);
uiItemR(
sub, imfptr, "export_curves_as_nurbs", UI_ITEM_NONE, IFACE_("Curves as NURBS"), ICON_NONE);
if (uiLayout *panel = uiLayoutPanel(C, layout, "OBJ_export_geometry", false, IFACE_("Geometry")))
{
uiLayout *col = uiLayoutColumn(panel, false);
uiItemR(col, ptr, "export_uv", UI_ITEM_NONE, IFACE_("UV Coordinates"), ICON_NONE);
uiItemR(col, ptr, "export_normals", UI_ITEM_NONE, IFACE_("Normals"), ICON_NONE);
uiItemR(col, ptr, "export_colors", UI_ITEM_NONE, IFACE_("Colors"), ICON_NONE);
uiItemR(
col, ptr, "export_curves_as_nurbs", UI_ITEM_NONE, IFACE_("Curves as NURBS"), ICON_NONE);
/* Material options. */
box = uiLayoutBox(layout);
col = uiLayoutColumn(box, false);
sub = uiLayoutColumnWithHeading(col, false, IFACE_("Materials"));
uiItemR(sub, imfptr, "export_materials", UI_ITEM_NONE, IFACE_("Export"), ICON_NONE);
sub = uiLayoutColumn(sub, false);
uiLayoutSetEnabled(sub, export_materials);
uiItemR(sub, imfptr, "export_pbr_extensions", UI_ITEM_NONE, IFACE_("PBR Extensions"), ICON_NONE);
uiItemR(sub, imfptr, "path_mode", UI_ITEM_NONE, IFACE_("Path Mode"), ICON_NONE);
uiItemR(col,
ptr,
"export_triangulated_mesh",
UI_ITEM_NONE,
IFACE_("Triangulated Mesh"),
ICON_NONE);
uiItemR(col, ptr, "apply_modifiers", UI_ITEM_NONE, IFACE_("Apply Modifiers"), ICON_NONE);
uiItemR(col, ptr, "export_eval_mode", UI_ITEM_NONE, IFACE_("Properties"), ICON_NONE);
}
/* Grouping options. */
box = uiLayoutBox(layout);
col = uiLayoutColumn(box, false);
sub = uiLayoutColumnWithHeading(col, false, IFACE_("Grouping"));
uiItemR(sub, imfptr, "export_object_groups", UI_ITEM_NONE, IFACE_("Object Groups"), ICON_NONE);
uiItemR(
sub, imfptr, "export_material_groups", UI_ITEM_NONE, IFACE_("Material Groups"), ICON_NONE);
uiItemR(sub, imfptr, "export_vertex_groups", UI_ITEM_NONE, IFACE_("Vertex Groups"), ICON_NONE);
uiItemR(sub, imfptr, "export_smooth_groups", UI_ITEM_NONE, IFACE_("Smooth Groups"), ICON_NONE);
sub = uiLayoutColumn(sub, false);
uiLayoutSetEnabled(sub, export_smooth_groups);
uiItemR(sub,
imfptr,
"smooth_group_bitflags",
UI_ITEM_NONE,
IFACE_("Smooth Group Bitflags"),
ICON_NONE);
if (uiLayout *panel = uiLayoutPanel(C, layout, "OBJ_export_grouping", false, IFACE_("Grouping")))
{
uiLayout *col = uiLayoutColumn(panel, false);
uiItemR(col, ptr, "export_object_groups", UI_ITEM_NONE, IFACE_("Object Groups"), ICON_NONE);
uiItemR(
col, ptr, "export_material_groups", UI_ITEM_NONE, IFACE_("Material Groups"), ICON_NONE);
uiItemR(col, ptr, "export_vertex_groups", UI_ITEM_NONE, IFACE_("Vertex Groups"), ICON_NONE);
uiItemR(col, ptr, "export_smooth_groups", UI_ITEM_NONE, IFACE_("Smooth Groups"), ICON_NONE);
col = uiLayoutColumn(col, false);
uiLayoutSetEnabled(col, export_smooth_groups);
uiItemR(col,
ptr,
"smooth_group_bitflags",
UI_ITEM_NONE,
IFACE_("Smooth Group Bitflags"),
ICON_NONE);
}
/* Material options. */
PanelLayout panel = uiLayoutPanel(C, layout, "OBJ_export_materials", false);
uiLayoutSetPropSep(panel.header, false);
uiItemR(panel.header, ptr, "export_materials", UI_ITEM_NONE, "", ICON_NONE);
uiItemL(panel.header, IFACE_("Materials"), ICON_NONE);
if (panel.body) {
uiLayout *col = uiLayoutColumn(panel.body, false);
uiLayoutSetEnabled(col, export_materials);
uiItemR(col, ptr, "export_pbr_extensions", UI_ITEM_NONE, IFACE_("PBR Extensions"), ICON_NONE);
uiItemR(col, ptr, "path_mode", UI_ITEM_NONE, IFACE_("Path Mode"), ICON_NONE);
}
/* Animation options. */
box = uiLayoutBox(layout);
col = uiLayoutColumn(box, false);
sub = uiLayoutColumnWithHeading(col, false, IFACE_("Animation"));
uiItemR(sub, imfptr, "export_animation", UI_ITEM_NONE, IFACE_("Export"), ICON_NONE);
sub = uiLayoutColumn(sub, true);
uiLayoutSetEnabled(sub, export_animation);
uiItemR(sub, imfptr, "start_frame", UI_ITEM_NONE, IFACE_("Frame Start"), ICON_NONE);
uiItemR(sub, imfptr, "end_frame", UI_ITEM_NONE, IFACE_("End"), ICON_NONE);
panel = uiLayoutPanel(C, layout, "OBJ_export_animation", true);
uiLayoutSetPropSep(panel.header, false);
uiItemR(panel.header, ptr, "export_animation", UI_ITEM_NONE, "", ICON_NONE);
uiItemL(panel.header, IFACE_("Animation"), ICON_NONE);
if (panel.body) {
uiLayout *col = uiLayoutColumn(panel.body, false);
uiLayoutSetEnabled(col, export_animation);
uiItemR(col, ptr, "start_frame", UI_ITEM_NONE, IFACE_("Frame Start"), ICON_NONE);
uiItemR(col, ptr, "end_frame", UI_ITEM_NONE, IFACE_("End"), ICON_NONE);
}
}
static void wm_obj_export_draw(bContext *C, wmOperator *op)
@@ -441,37 +442,32 @@ static int wm_obj_import_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static void ui_obj_import_settings(uiLayout *layout, PointerRNA *imfptr)
static void ui_obj_import_settings(const bContext *C, uiLayout *layout, PointerRNA *ptr)
{
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
uiLayout *box = uiLayoutBox(layout);
uiItemL(box, IFACE_("Transform"), ICON_OBJECT_DATA);
uiLayout *col = uiLayoutColumn(box, false);
uiLayout *sub = uiLayoutColumn(col, false);
uiItemR(sub, imfptr, "global_scale", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(sub, imfptr, "clamp_size", UI_ITEM_NONE, nullptr, ICON_NONE);
sub = uiLayoutColumn(col, false);
if (uiLayout *panel = uiLayoutPanel(C, layout, "OBJ_import_general", false, IFACE_("General"))) {
uiLayout *col = uiLayoutColumn(panel, false);
uiItemR(col, ptr, "global_scale", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "clamp_size", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "forward_axis", UI_ITEM_NONE, IFACE_("Forward Axis"), ICON_NONE);
uiItemR(col, ptr, "up_axis", UI_ITEM_NONE, IFACE_("Up Axis"), ICON_NONE);
}
uiItemR(sub, imfptr, "forward_axis", UI_ITEM_NONE, IFACE_("Forward Axis"), ICON_NONE);
uiItemR(sub, imfptr, "up_axis", UI_ITEM_NONE, IFACE_("Up Axis"), ICON_NONE);
box = uiLayoutBox(layout);
uiItemL(box, IFACE_("Options"), ICON_EXPORT);
col = uiLayoutColumn(box, false);
uiItemR(col, imfptr, "use_split_objects", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, imfptr, "use_split_groups", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, imfptr, "import_vertex_groups", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, imfptr, "validate_meshes", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, imfptr, "collection_separator", UI_ITEM_NONE, nullptr, ICON_NONE);
if (uiLayout *panel = uiLayoutPanel(C, layout, "OBJ_import_options", false, IFACE_("Options"))) {
uiLayout *col = uiLayoutColumn(panel, false);
uiItemR(col, ptr, "use_split_objects", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "use_split_groups", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "import_vertex_groups", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "validate_meshes", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "collection_separator", UI_ITEM_NONE, nullptr, ICON_NONE);
}
}
static void wm_obj_import_draw(bContext *C, wmOperator *op)
{
wmWindowManager *wm = CTX_wm_manager(C);
PointerRNA ptr = RNA_pointer_create(&wm->id, op->type->srna, op->properties);
ui_obj_import_settings(op->layout, &ptr);
ui_obj_import_settings(C, op->layout, op->ptr);
}
void WM_OT_obj_import(wmOperatorType *ot)

View File

@@ -100,39 +100,41 @@ static void wm_ply_export_draw(bContext *C, wmOperator *op)
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
uiLayout *box, *col, *sub;
if (uiLayout *panel = uiLayoutPanel(C, layout, "PLY_export_general", false, IFACE_("General"))) {
uiLayout *col = uiLayoutColumn(panel, false);
/* Object Transform options. */
box = uiLayoutBox(layout);
col = uiLayoutColumn(box, false);
sub = uiLayoutColumnWithHeading(col, false, IFACE_("Format"));
uiItemR(sub, ptr, "ascii_format", UI_ITEM_NONE, IFACE_("ASCII"), ICON_NONE);
uiLayout *sub = uiLayoutColumnWithHeading(col, false, IFACE_("Format"));
uiItemR(sub, ptr, "ascii_format", UI_ITEM_NONE, IFACE_("ASCII"), ICON_NONE);
/* The Selection only options only make sense when using regular export. */
if (CTX_wm_space_file(C)) {
sub = uiLayoutColumnWithHeading(col, false, IFACE_("Limit to"));
uiItemR(sub, ptr, "export_selected_objects", UI_ITEM_NONE, IFACE_("Selected Only"), ICON_NONE);
/* The Selection only options only make sense when using regular export. */
if (CTX_wm_space_file(C)) {
sub = uiLayoutColumnWithHeading(col, false, IFACE_("Include"));
uiItemR(
sub, ptr, "export_selected_objects", UI_ITEM_NONE, IFACE_("Selection Only"), ICON_NONE);
}
uiItemR(col, ptr, "global_scale", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "forward_axis", UI_ITEM_NONE, IFACE_("Forward Axis"), ICON_NONE);
uiItemR(col, ptr, "up_axis", UI_ITEM_NONE, IFACE_("Up Axis"), ICON_NONE);
}
uiItemR(sub, ptr, "global_scale", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(sub, ptr, "forward_axis", UI_ITEM_NONE, IFACE_("Forward Axis"), ICON_NONE);
uiItemR(sub, ptr, "up_axis", UI_ITEM_NONE, IFACE_("Up Axis"), ICON_NONE);
if (uiLayout *panel = uiLayoutPanel(C, layout, "PLY_export_geometry", false, IFACE_("Geometry")))
{
uiLayout *col = uiLayoutColumn(panel, false);
col = uiLayoutColumn(box, false);
sub = uiLayoutColumn(col, false);
sub = uiLayoutColumnWithHeading(col, false, IFACE_("Objects"));
uiItemR(sub, ptr, "apply_modifiers", UI_ITEM_NONE, IFACE_("Apply Modifiers"), ICON_NONE);
uiItemR(col, ptr, "export_uv", UI_ITEM_NONE, IFACE_("UV Coordinates"), ICON_NONE);
uiItemR(col, ptr, "export_normals", UI_ITEM_NONE, IFACE_("Vertex Normals"), ICON_NONE);
uiItemR(col, ptr, "export_attributes", UI_ITEM_NONE, IFACE_("Vertex Attributes"), ICON_NONE);
uiItemR(col, ptr, "export_colors", UI_ITEM_NONE, IFACE_("Vertex Colors"), ICON_NONE);
/* Geometry options. */
box = uiLayoutBox(layout);
col = uiLayoutColumn(box, false);
sub = uiLayoutColumnWithHeading(col, false, IFACE_("Geometry"));
uiItemR(sub, ptr, "export_uv", UI_ITEM_NONE, IFACE_("UV Coordinates"), ICON_NONE);
uiItemR(sub, ptr, "export_normals", UI_ITEM_NONE, IFACE_("Vertex Normals"), ICON_NONE);
uiItemR(sub, ptr, "export_colors", UI_ITEM_NONE, IFACE_("Vertex Colors"), ICON_NONE);
uiItemR(sub, ptr, "export_attributes", UI_ITEM_NONE, IFACE_("Vertex Attributes"), ICON_NONE);
uiItemR(
sub, ptr, "export_triangulated_mesh", UI_ITEM_NONE, IFACE_("Triangulated Mesh"), ICON_NONE);
uiItemR(col,
ptr,
"export_triangulated_mesh",
UI_ITEM_NONE,
IFACE_("Triangulated Mesh"),
ICON_NONE);
uiItemR(col, ptr, "apply_modifiers", UI_ITEM_NONE, IFACE_("Apply Modifiers"), ICON_NONE);
}
}
/**
@@ -276,24 +278,29 @@ static int wm_ply_import_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static void ui_ply_import_settings(uiLayout *layout, PointerRNA *ptr)
static void ui_ply_import_settings(const bContext *C, uiLayout *layout, PointerRNA *ptr)
{
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
uiLayout *box = uiLayoutBox(layout);
uiLayout *col = uiLayoutColumn(box, false);
uiItemR(col, ptr, "global_scale", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "use_scene_unit", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "forward_axis", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "up_axis", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "merge_verts", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "import_colors", UI_ITEM_NONE, nullptr, ICON_NONE);
if (uiLayout *panel = uiLayoutPanel(C, layout, "PLY_import_general", false, IFACE_("General"))) {
uiLayout *col = uiLayoutColumn(panel, false);
uiItemR(col, ptr, "global_scale", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "use_scene_unit", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "forward_axis", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "up_axis", UI_ITEM_NONE, nullptr, ICON_NONE);
}
if (uiLayout *panel = uiLayoutPanel(C, layout, "PLY_import_options", false, IFACE_("Options"))) {
uiLayout *col = uiLayoutColumn(panel, false);
uiItemR(col, ptr, "merge_verts", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "import_colors", UI_ITEM_NONE, nullptr, ICON_NONE);
}
}
static void wm_ply_import_draw(bContext * /*C*/, wmOperator *op)
static void wm_ply_import_draw(bContext *C, wmOperator *op)
{
ui_ply_import_settings(op->layout, op->ptr);
ui_ply_import_settings(C, op->layout, op->ptr);
}
void WM_OT_ply_import(wmOperatorType *ot)

View File

@@ -76,31 +76,32 @@ static void wm_stl_export_draw(bContext *C, wmOperator *op)
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
uiLayout *box, *col, *sub;
if (uiLayout *panel = uiLayoutPanel(C, layout, "STL_export_general", false, IFACE_("General"))) {
uiLayout *col = uiLayoutColumn(panel, false);
box = uiLayoutBox(layout);
col = uiLayoutColumn(box, false);
sub = uiLayoutColumnWithHeading(col, false, IFACE_("Format"));
uiItemR(sub, ptr, "ascii_format", UI_ITEM_NONE, IFACE_("ASCII"), ICON_NONE);
uiLayout *sub = uiLayoutColumnWithHeading(col, false, IFACE_("Format"));
uiItemR(sub, ptr, "ascii_format", UI_ITEM_NONE, IFACE_("ASCII"), ICON_NONE);
/* The Batch mode and Selection only options only make sense when using regular export. */
if (CTX_wm_space_file(C)) {
uiItemR(col, ptr, "use_batch", UI_ITEM_NONE, IFACE_("Batch"), ICON_NONE);
/* The Batch mode and Selection only options only make sense when using regular export. */
if (CTX_wm_space_file(C)) {
uiItemR(col, ptr, "use_batch", UI_ITEM_NONE, IFACE_("Batch"), ICON_NONE);
box = uiLayoutBox(layout);
sub = uiLayoutColumnWithHeading(box, false, IFACE_("Include"));
uiItemR(
sub, ptr, "export_selected_objects", UI_ITEM_NONE, IFACE_("Selection Only"), ICON_NONE);
sub = uiLayoutColumnWithHeading(col, false, IFACE_("Include"));
uiItemR(
sub, ptr, "export_selected_objects", UI_ITEM_NONE, IFACE_("Selection Only"), ICON_NONE);
}
uiItemR(sub, ptr, "global_scale", UI_ITEM_NONE, IFACE_("Scale"), ICON_NONE);
uiItemR(sub, ptr, "use_scene_unit", UI_ITEM_NONE, IFACE_("Scene Unit"), ICON_NONE);
uiItemR(sub, ptr, "forward_axis", UI_ITEM_NONE, IFACE_("Forward"), ICON_NONE);
uiItemR(sub, ptr, "up_axis", UI_ITEM_NONE, IFACE_("Up"), ICON_NONE);
}
uiItemR(sub, ptr, "global_scale", UI_ITEM_NONE, IFACE_("Scale"), ICON_NONE);
uiItemR(sub, ptr, "use_scene_unit", UI_ITEM_NONE, IFACE_("Scene Unit"), ICON_NONE);
uiItemR(sub, ptr, "forward_axis", UI_ITEM_NONE, IFACE_("Forward"), ICON_NONE);
uiItemR(sub, ptr, "up_axis", UI_ITEM_NONE, IFACE_("Up"), ICON_NONE);
box = uiLayoutBox(layout);
sub = uiLayoutColumnWithHeading(box, false, IFACE_("Geometry"));
uiItemR(sub, ptr, "apply_modifiers", UI_ITEM_NONE, IFACE_("Apply Modifiers"), ICON_NONE);
if (uiLayout *panel = uiLayoutPanel(C, layout, "STL_export_geometry", false, IFACE_("Geometry")))
{
uiLayout *col = uiLayoutColumn(panel, false);
uiItemR(col, ptr, "apply_modifiers", UI_ITEM_NONE, IFACE_("Apply Modifiers"), ICON_NONE);
}
}
/**
@@ -234,24 +235,29 @@ static bool wm_stl_import_check(bContext * /*C*/, wmOperator *op)
return false;
}
static void ui_stl_import_settings(uiLayout *layout, PointerRNA *ptr)
static void ui_stl_import_settings(const bContext *C, uiLayout *layout, PointerRNA *ptr)
{
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
uiLayout *box = uiLayoutBox(layout);
uiLayout *col = uiLayoutColumn(box, false);
uiItemR(col, ptr, "global_scale", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "use_scene_unit", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "use_facet_normal", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "forward_axis", UI_ITEM_NONE, IFACE_("Forward Axis"), ICON_NONE);
uiItemR(col, ptr, "up_axis", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "use_mesh_validate", UI_ITEM_NONE, nullptr, ICON_NONE);
if (uiLayout *panel = uiLayoutPanel(C, layout, "STL_import_general", false, IFACE_("General"))) {
uiLayout *col = uiLayoutColumn(panel, false);
uiItemR(col, ptr, "global_scale", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "use_scene_unit", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "forward_axis", UI_ITEM_NONE, IFACE_("Forward Axis"), ICON_NONE);
uiItemR(col, ptr, "up_axis", UI_ITEM_NONE, nullptr, ICON_NONE);
}
if (uiLayout *panel = uiLayoutPanel(C, layout, "STL_import_options", false, IFACE_("Options"))) {
uiLayout *col = uiLayoutColumn(panel, false);
uiItemR(col, ptr, "use_facet_normal", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "use_mesh_validate", UI_ITEM_NONE, nullptr, ICON_NONE);
}
}
static void wm_stl_import_draw(bContext * /*C*/, wmOperator *op)
static void wm_stl_import_draw(bContext *C, wmOperator *op)
{
ui_stl_import_settings(op->layout, op->ptr);
ui_stl_import_settings(C, op->layout, op->ptr);
}
void WM_OT_stl_import(wmOperatorType *ot)