import bpy
import random
import math
import pickle
# from .general import DirectionalPoint2d, Rect2d, DirectionalPoints2dCollection
# from ..utils import définirPixel
from bpy.types import Node
from .. import CityNodeTreeNode


class HtmlOutputNodeExportOperator(bpy.types.Operator):
	bl_idname = 'node.html_output_node_export'
	bl_label = 'Export'
	bl_description = ''
	source_node_path = bpy.props.StringProperty()

	def execute(self, context):
		source_node = eval(self.source_node_path)
		return {'FINISHED'}


class HtmlOutputNode(Node, CityNodeTreeNode):
	bl_label = 'HTML output'

	export_path = bpy.props.StringProperty(
		name='Export path',
		description='', )

	def init(self, context):
		self.width = 300
		self.inputs.new('AssetInstancesSocket', 'Asset instances')
		self.inputs.new('CityDefSocket', 'City def')

	def draw_buttons(self, context, layout):
		row = layout.row()
		row.prop(self, 'export_path')
		row = layout.row()
		op = row.operator('node.html_output_node_export')
		op.source_node_path = 'bpy.data.node_groups["' + self.id_data.name + '"].' + self.path_from_id()

	def update(self):
		pass
