[Bf-blender-cvs] [e2d9b9fd6a8] soc-2020-io-performance: Placeholder files, WIP
Ankit Meel
noreply at git.blender.org
Thu May 21 16:54:47 CEST 2020
Commit: e2d9b9fd6a815cd065d13ff1286afbe4e0f2695f
Author: Ankit Meel
Date: Wed May 20 18:14:54 2020 +0530
Branches: soc-2020-io-performance
https://developer.blender.org/rBe2d9b9fd6a815cd065d13ff1286afbe4e0f2695f
Placeholder files, WIP
===================================================================
M release/scripts/startup/bl_ui/space_topbar.py
A source/blender/editors/io/io_obj.c
A source/blender/editors/io/io_obj.h
M source/blender/editors/io/io_ops.c
M source/blender/io/CMakeLists.txt
A source/blender/io/obj/CMakeLists.txt
A source/blender/io/obj/obj.cpp
A source/blender/io/obj/obj.h
M source/blender/makesdna/DNA_space_types.h
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index 6fc29119cdc..fbc0da42f35 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -436,6 +436,7 @@ class TOPBAR_MT_file_import(Menu):
bl_owner_use_filter = False
def draw(self, _context):
+ self.layout.operator("wm.obj_import", text="OBJ New (.obj)")
if bpy.app.build_options.collada:
self.layout.operator("wm.collada_import",
text="Collada (Default) (.dae)")
@@ -449,6 +450,7 @@ class TOPBAR_MT_file_export(Menu):
bl_owner_use_filter = False
def draw(self, context):
+ self.layout.operator("wm.obj_export", text="OBJ New (.obj)")
if bpy.app.build_options.collada:
self.layout.operator("wm.collada_export",
text="Collada (Default) (.dae)")
diff --git a/source/blender/editors/io/io_obj.c b/source/blender/editors/io/io_obj.c
new file mode 100644
index 00000000000..066f3fde5b0
--- /dev/null
+++ b/source/blender/editors/io/io_obj.c
@@ -0,0 +1,168 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2019 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup editor/io
+ */
+
+# include "DNA_space_types.h"
+
+# include "BKE_context.h"
+# include "BKE_main.h"
+# include "BKE_report.h"
+
+# include "BLI_path_util.h"
+# include "BLI_string.h"
+# include "BLI_utildefines.h"
+
+# include "BLT_translation.h"
+
+# include "MEM_guardedalloc.h"
+
+# include "RNA_access.h"
+# include "RNA_define.h"
+
+# include "UI_interface.h"
+# include "UI_resources.h"
+
+# include "WM_api.h"
+# include "WM_types.h"
+
+# include "DEG_depsgraph.h"
+
+# include "io_obj.h"
+# include "obj.h"
+
+static int wm_obj_export_invoke(bContext *C, wmOperator *op, const wmEvent *event){
+ if (!RNA_struct_property_is_set(op->ptr, "print_name")) {
+ printf("\n Name not set \n");
+ }
+
+ if (!RNA_struct_property_is_set(op->ptr, "print_the_float")) {
+ printf("float not set");
+ }
+
+ if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
+ Main *bmain = CTX_data_main(C);
+ char filepath[FILE_MAX];
+
+ if (BKE_main_blendfile_path(bmain)[0] == '\0') {
+ BLI_strncpy(filepath, "untitled", sizeof(filepath));
+ }
+ else {
+ BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath));
+ }
+
+ BLI_path_extension_replace(filepath, sizeof(filepath), ".obj");
+ RNA_string_set(op->ptr, "filepath", filepath);
+ }
+
+ return OPERATOR_RUNNING_MODAL;
+
+ UNUSED_VARS(event);
+}
+static int wm_obj_export_exec(bContext *C, wmOperator *op){
+ if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
+ BKE_report(op->reports, RPT_ERROR, "No filename given");
+ return OPERATOR_CANCELLED;
+ }
+ struct OBJExportParams a;
+ char filename[FILE_MAX];
+ RNA_string_get(op->ptr, "filepath", filename);
+ a.print_name = RNA_boolean_get(op->ptr, "print_name");
+ a.number = RNA_float_get(op->ptr, "print_the_float");
+
+ bool ok = obj_export(C, &a);
+ return ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
+}
+
+static void ui_obj_export_settings(uiLayout *layout, PointerRNA *imfptr)
+{
+ uiLayout *box;
+ uiLayout *row;
+
+ box = uiLayoutBox(layout);
+ row = uiLayoutRow(layout, false);
+ uiItemL(layout, "Print Name?", ICON_NONE);
+
+ row = uiLayoutRow(layout, false);
+ uiItemL(layout, "Print a Float", ICON_NONE);
+}
+
+static void wm_obj_export_draw(bContext *UNUSED(C), wmOperator *op ){
+ PointerRNA ptr;
+ ui_obj_export_settings(op->layout, &ptr);
+}
+
+
+void WM_OT_obj_export(struct wmOperatorType *ot){
+ ot->name = "Export Wavefront OBJ";
+ ot->description = "Save the scene to a Wavefront OBJ file";
+ ot->idname = "WM_OT_obj_export";
+
+ ot->invoke = wm_obj_export_invoke;
+ ot->exec = wm_obj_export_exec;
+ ot->poll = WM_operator_winactive;
+ ot->ui = wm_obj_export_draw;
+
+ WM_operator_properties_filesel(ot,
+ FILE_TYPE_FOLDER | FILE_TYPE_OBJ,
+ FILE_BLENDER,
+ FILE_SAVE,
+ WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS,
+ FILE_DEFAULTDISPLAY,
+ FILE_SORT_ALPHA);
+
+ RNA_def_boolean(ot->srna, "print_name", 0, "Print Name?", "If enabled, prints name of OP");
+ RNA_def_float(ot->srna, "print_the_float", 4.56, 0.0f, 10.0f, "Print a Float", "Prints given Float", 1.0f, 9.0f);
+}
+
+
+static int wm_obj_import_invoke(bContext *C, wmOperator *op, const wmEvent *event){
+ return 1;
+}
+static int wm_obj_import_exec(bContext *C, wmOperator *op){
+ return 1;
+}
+static void wm_obj_import_draw(bContext *UNUSED(C), wmOperator *op){
+
+}
+
+
+void WM_OT_obj_import(struct wmOperatorType *ot)
+{
+ ot->name = "Import Wavefront OBJ";
+ ot->description = "Load an Wavefront OBJ scene";
+ ot->idname = "WM_OT_obj_import";
+
+ ot->invoke = wm_obj_import_invoke;
+ ot->exec = wm_obj_import_exec;
+ ot->poll = WM_operator_winactive;
+ ot->ui = wm_obj_import_draw;
+
+ WM_operator_properties_filesel(ot,
+ FILE_TYPE_FOLDER | FILE_TYPE_OBJ,
+ FILE_BLENDER,
+ FILE_SAVE,
+ WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS,
+ FILE_DEFAULTDISPLAY,
+ FILE_SORT_ALPHA);
+
+}
+
diff --git a/source/blender/editors/io/io_obj.h b/source/blender/editors/io/io_obj.h
new file mode 100644
index 00000000000..257c90e64c2
--- /dev/null
+++ b/source/blender/editors/io/io_obj.h
@@ -0,0 +1,27 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2016 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup editor/io
+ */
+
+struct wmOperatorType;
+
+void WM_OT_obj_export(struct wmOperatorType *ot);
+void WM_OT_obj_import(struct wmOperatorType *ot);
diff --git a/source/blender/editors/io/io_ops.c b/source/blender/editors/io/io_ops.c
index acb511a414d..53effe31eb2 100644
--- a/source/blender/editors/io/io_ops.c
+++ b/source/blender/editors/io/io_ops.c
@@ -38,6 +38,7 @@
#endif
#include "io_cache.h"
+#include "io_obj.h"
void ED_operatortypes_io(void)
{
@@ -56,4 +57,6 @@ void ED_operatortypes_io(void)
WM_operatortype_append(CACHEFILE_OT_open);
WM_operatortype_append(CACHEFILE_OT_reload);
+ WM_operatortype_append(WM_OT_obj_import);
+ WM_operatortype_append(WM_OT_obj_export);
}
diff --git a/source/blender/io/CMakeLists.txt b/source/blender/io/CMakeLists.txt
index bc2f8d628e2..05abfdf51c1 100644
--- a/source/blender/io/CMakeLists.txt
+++ b/source/blender/io/CMakeLists.txt
@@ -33,3 +33,5 @@ endif()
if(WITH_USD)
add_subdirectory(usd)
endif()
+
+add_subdirectory(obj)
\ No newline at end of file
diff --git a/source/blender/io/CMakeLists.txt b/source/blender/io/obj/CMakeLists.txt
similarity index 75%
copy from source/blender/io/CMakeLists.txt
copy to source/blender/io/obj/CMakeLists.txt
index bc2f8d628e2..b556747549c 100644
--- a/source/blender/io/CMakeLists.txt
+++ b/source/blender/io/obj/CMakeLists.txt
@@ -14,22 +14,29 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
-# The Original Code is Copyright (C) 2020, Blender Foundation
+# The Original Code is Copyright (C) 2006, Blender Foundation
# All rights reserved.
# ***** END GPL LICENSE BLOCK *****
-if(WITH_ALEMBIC)
- add_subdirectory(alembic)
-endif()
+set(INC
+ .
+../../blenlib
+../../makesrna
+ ../../../../intern/guardedalloc
+)
-if(WITH_CODEC_AVI)
- add_subdirectory(avi)
-endif()
+set(INC_SYS
-if(WITH_OPENCOLLADA)
- add_subdirectory(collada)
-endif()
+)
-if(WITH_USD)
- add_subdirectory(usd)
-endif()
+set(SRC
+ obj.cpp
+
+ obj.h
+)
+
+set(LIB
+
+)
+
+blender_add_lib(bf_obj "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
diff --git a/source/blender/io/obj/obj.cpp b/source/blender/io/obj/obj.cpp
new file mode 100644
index 00000000000..9bb55b5086b
--- /dev/null
+++ b/source/blender/io/obj/obj.cpp
@@ -0,0 +1,11 @@
+#include "obj.h"
+
+bool export_obj(bContext *C, OBJExportParams * a){
+ if (a->print_name) {
+ printf("\n Ankit");
+ }
+ if (a->number) {
+ printf("\n%f\n",a->number);
+ }
+ return true;
+}
diff --git a/source/blender/io/obj/obj.h b/source/blender/io/obj/obj.h
new file mode 100644
index 00000000000..069070585e4
--- /dev/null
+++ b/source/blender/io/obj/obj.h
@@ -0,0 +1,52 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Gene
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list