[Bf-blender-cvs] [c2e46946a7f] greasepencil-object: Gpencil: svg exporter initial.
YimingWu
noreply at git.blender.org
Tue Jul 9 05:23:55 CEST 2019
Commit: c2e46946a7f984b4a27e077c3ecf60424d5be0bd
Author: YimingWu
Date: Tue Jul 9 11:23:29 2019 +0800
Branches: greasepencil-object
https://developer.blender.org/rBc2e46946a7f984b4a27e077c3ecf60424d5be0bd
Gpencil: svg exporter initial.
===================================================================
M intern/ghost/intern/GHOST_ContextCGL.mm
M intern/ghost/intern/GHOST_SystemCocoa.mm
M release/datafiles/locale
M release/scripts/addons
M release/scripts/addons_contrib
A source/blender/blenkernel/BKE_writesvg.h
M source/blender/blenkernel/CMakeLists.txt
A source/blender/blenkernel/intern/writesvg.c
M source/blender/editors/gpencil/gpencil_intern.h
M source/blender/editors/gpencil/gpencil_ops.c
A source/blender/editors/gpencil/gpencil_svg.c
M source/blender/editors/object/object_add.c
M source/blender/makesrna/intern/rna_mesh.c
M source/tools
===================================================================
diff --git a/intern/ghost/intern/GHOST_ContextCGL.mm b/intern/ghost/intern/GHOST_ContextCGL.mm
index 12c340ffe97..0fca41306a6 100644
--- a/intern/ghost/intern/GHOST_ContextCGL.mm
+++ b/intern/ghost/intern/GHOST_ContextCGL.mm
@@ -34,7 +34,8 @@
static void ghost_fatal_error_dialog(const char *msg)
{
- @autoreleasepool {
+ @autoreleasepool
+ {
NSString *message = [NSString stringWithFormat:@"Error opening window:\n%s", msg];
NSAlert *alert = [[NSAlert alloc] init];
@@ -337,7 +338,8 @@ static const OSType METAL_CORE_VIDEO_PIXEL_FORMAT = kCVPixelFormatType_32BGRA;
void GHOST_ContextCGL::metalInit()
{
- @autoreleasepool {
+ @autoreleasepool
+ {
id<MTLDevice> device = m_metalLayer.device;
// Create a command queue for blit/present operation
@@ -532,7 +534,8 @@ void GHOST_ContextCGL::metalUpdateFramebuffer()
void GHOST_ContextCGL::metalSwapBuffers()
{
- @autoreleasepool {
+ @autoreleasepool
+ {
updateDrawingContext();
glFlush();
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 376ebfa2a21..80a521a7ca5 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -1358,7 +1358,8 @@ bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr)
// Check open windows if some changes are not saved
if (m_windowManager->getAnyModifiedState()) {
- @autoreleasepool {
+ @autoreleasepool
+ {
NSAlert *alert = [[NSAlert alloc] init];
NSString *title = [NSString stringWithFormat:@"Opening %@", [filepath lastPathComponent]];
NSString *text = @"Current document has not been saved.\nDo you really want to proceed?";
diff --git a/release/datafiles/locale b/release/datafiles/locale
index 6a6b84fd505..ad82c4ce43e 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 6a6b84fd50538a65276c729b5d396be615bc79f2
+Subproject commit ad82c4ce43ef2801ef51e75af1f9702992478b02
diff --git a/release/scripts/addons b/release/scripts/addons
index 5819abebf40..8e6f485cf5b 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 5819abebf40d5f09543bfe2af3aa4dfa698b3114
+Subproject commit 8e6f485cf5b160c425d7da7c743879b20f3d6a96
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index f00d4fbe848..7077ff07384 160000
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit f00d4fbe84852e40af281267c06dc21bafb5df49
+Subproject commit 7077ff07384491d1f7630484995557f1c7302dae
diff --git a/source/blender/blenkernel/BKE_writesvg.h b/source/blender/blenkernel/BKE_writesvg.h
new file mode 100644
index 00000000000..f088648c70c
--- /dev/null
+++ b/source/blender/blenkernel/BKE_writesvg.h
@@ -0,0 +1,30 @@
+/*
+ * 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) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ */
+
+#ifndef __BKE_WRITESVG_H__
+#define __BKE_WRITESVG_H__
+
+/** \file
+ * \ingroup bke
+ */
+
+bool BKE_svg_data_from_gpencil(struct bGPdata* gpd, struct Text* ta);
+
+
+#endif
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index e564e91749c..f0373016e95 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -221,6 +221,7 @@ set(SRC
intern/workspace.c
intern/world.c
intern/writeavi.c
+ intern/writesvg.c
BKE_DerivedMesh.h
BKE_action.h
@@ -343,6 +344,7 @@ set(SRC
BKE_workspace.h
BKE_world.h
BKE_writeavi.h
+ BKE_writesvg.h
nla_private.h
particle_private.h
diff --git a/source/blender/blenkernel/intern/writesvg.c b/source/blender/blenkernel/intern/writesvg.c
new file mode 100644
index 00000000000..75ad64c5263
--- /dev/null
+++ b/source/blender/blenkernel/intern/writesvg.c
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "BLI_utildefines.h"
+#include "BLI_string.h"
+#include "BLI_string_utils.h"
+#include "BLI_listbase.h"
+
+#include "BKE_writesvg.h"
+#include "BKE_text.h"
+
+#include "DNA_object_types.h"
+#include "DNA_gpencil_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_text_types.h"
+
+#include "DEG_depsgraph.h"
+
+#include "MEM_guardedalloc.h"
+
+static void write_svg_head(Text* ta){
+ BKE_text_write(ta, NULL, "<?xml version=\"1.0\" standalone=\"no\"?>\n");
+ BKE_text_write(ta, NULL, "<svg width=\"10cm\" height=\"10cm\" viewbox=\"0 0 10 10\""
+ "xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n");
+}
+
+static void write_svg_end(Text* ta){
+ BKE_text_write(ta, NULL, "</svg>");
+}
+
+typedef int (svg_get_node_callback)(void* container, float *x, float *y, float *z);
+
+static void write_path_from_callback(Text* ta, svg_get_node_callback get_node){
+
+}
+
+bool BKE_svg_data_from_gpencil(bGPdata* gpd, Text* ta){
+ if(!gpd || !ta){
+ return false;
+ }
+
+ BKE_text_free_lines(ta);
+
+ {
+
+ // export paths.
+
+ }
+
+}
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index a9acd8057c1..a4b86362eb9 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -454,6 +454,8 @@ void GPENCIL_OT_frame_clean_loose(struct wmOperatorType *ot);
void GPENCIL_OT_convert(struct wmOperatorType *ot);
+void GPENCIL_OT_export_svg(struct wmOperatorType *ot);
+
enum {
GP_STROKE_JOIN = -1,
GP_STROKE_JOINCOPY = 1,
diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c
index db4c601709c..43b7dbe32d6 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -264,6 +264,8 @@ void ED_operatortypes_gpencil(void)
WM_operatortype_append(GPENCIL_OT_sculpt_paint);
+ WM_operatortype_append(GPENCIL_OT_export_svg);
+
/* Editing (Buttons) ------------ */
WM_operatortype_append(GPENCIL_OT_data_add);
diff --git a/source/blender/editors/gpencil/gpencil_svg.c b/source/blender/editors/gpencil/gpencil_svg.c
new file mode 100644
index 00000000000..3381273c45c
--- /dev/null
+++ b/source/blender/editors/gpencil/gpencil_svg.c
@@ -0,0 +1,87 @@
+/*
+ * 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) 2011 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup edgpencil
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_gpencil_types.h"
+#include "DNA_object_types.h"
+#include "DNA_listBase.h"
+
+#include "BKE_context.h"
+#include "BKE_gpencil.h"
+
+#include "DEG_depsgraph.h"
+
+#include "BKE_context.h"
+#include "BKE_gpencil.h"
+#include "BKE_report.h"
+
+#include "UI_interface.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "gpencil_intern.h"
+
+#include "ED_gpencil.h"
+#include "ED_select_utils.h"
+
+
+static int gpencil_export_svg_exec(bContext *C, wmOperator *op)
+{
+ return OPERATOR_FINISHED;
+}
+
+static bool gpencil_found(bContext *C)
+{
+ Object* o = CTX_data_active_object(C);
+
+ if(o && o->type == OB_GPENCIL){
+ return true;
+ }
+ return false;
+}
+
+void GPENCIL_OT_export_svg(wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+
+ /* identifiers */
+ ot->name = "Export to SVG";
+ ot->description = "Export this GPencil object to a SVG file";
+ ot->idname = "GPENCIL_OT_export_svg";
+
+ /* callbacks */
+ ot->exec = gpencil_export_svg_exec;
+ ot->poll = gpencil_found;
+
+ /* flag */
+ ot->flag = OPTYPE_USE_EVAL_DATA;
+
+ /* properties */
+ /* Should have: facing, layer, visibility, file split... */
+}
+
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 22550e18dba..2fbc52266a0 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -2530,11 +2530,8 @@ void OBJECT_OT_convert(wmOperatorType *ot)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list