/* this file has been autogenerated by vtkNodeJsWrap */
/* editing this might proof futile */

#define VTK_WRAPPING_CXX
#define VTK_STREAMS_FWD_ONLY
#include <nan.h>

#include "vtkContextItemWrap.h"
#include "vtkPiecewisePointHandleItemWrap.h"
#include "vtkObjectBaseWrap.h"
#include "vtkAbstractContextItemWrap.h"
#include "vtkContext2DWrap.h"
#include "vtkPiecewiseFunctionWrap.h"
#include "../../plus/plus.h"

using namespace v8;

extern Nan::Persistent<v8::Object> vtkNodeJsNoWrap;
Nan::Persistent<v8::FunctionTemplate> VtkPiecewisePointHandleItemWrap::ptpl;

VtkPiecewisePointHandleItemWrap::VtkPiecewisePointHandleItemWrap()
{ }

VtkPiecewisePointHandleItemWrap::VtkPiecewisePointHandleItemWrap(vtkSmartPointer<vtkPiecewisePointHandleItem> _native)
{ native = _native; }

VtkPiecewisePointHandleItemWrap::~VtkPiecewisePointHandleItemWrap()
{ }

void VtkPiecewisePointHandleItemWrap::Init(v8::Local<v8::Object> exports)
{
	Nan::SetAccessor(exports, Nan::New("vtkPiecewisePointHandleItem").ToLocalChecked(), ConstructorGetter);
	Nan::SetAccessor(exports, Nan::New("PiecewisePointHandleItem").ToLocalChecked(), ConstructorGetter);
}

void VtkPiecewisePointHandleItemWrap::ConstructorGetter(
	v8::Local<v8::String> property,
	const Nan::PropertyCallbackInfo<v8::Value>& info)
{
	InitPtpl();
	info.GetReturnValue().Set(Nan::New(ptpl)->GetFunction());
}

void VtkPiecewisePointHandleItemWrap::InitPtpl()
{
	if (!ptpl.IsEmpty()) return;
	v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
	VtkContextItemWrap::InitPtpl( );
	tpl->Inherit(Nan::New<FunctionTemplate>(VtkContextItemWrap::ptpl));
	tpl->SetClassName(Nan::New("VtkPiecewisePointHandleItemWrap").ToLocalChecked());
	tpl->InstanceTemplate()->SetInternalFieldCount(1);

	Nan::SetPrototypeMethod(tpl, "NewInstance", NewInstance);
	Nan::SetPrototypeMethod(tpl, "newInstance", NewInstance);

	Nan::SetPrototypeMethod(tpl, "Paint", Paint);
	Nan::SetPrototypeMethod(tpl, "paint", Paint);

	Nan::SetPrototypeMethod(tpl, "SafeDownCast", SafeDownCast);
	Nan::SetPrototypeMethod(tpl, "safeDownCast", SafeDownCast);

	Nan::SetPrototypeMethod(tpl, "SetParent", SetParent);
	Nan::SetPrototypeMethod(tpl, "setParent", SetParent);

	Nan::SetPrototypeMethod(tpl, "SetPiecewiseFunction", SetPiecewiseFunction);
	Nan::SetPrototypeMethod(tpl, "setPiecewiseFunction", SetPiecewiseFunction);

#ifdef VTK_NODE_PLUS_VTKPIECEWISEPOINTHANDLEITEMWRAP_INITPTPL
	VTK_NODE_PLUS_VTKPIECEWISEPOINTHANDLEITEMWRAP_INITPTPL
#endif
	ptpl.Reset( tpl );
}

void VtkPiecewisePointHandleItemWrap::New(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	if(!info.IsConstructCall())
	{
		Nan::ThrowError("Constructor not called in a construct call.");
		return;
	}

	if(info.Length() == 0)
	{
		vtkSmartPointer<vtkPiecewisePointHandleItem> native = vtkSmartPointer<vtkPiecewisePointHandleItem>::New();
		VtkPiecewisePointHandleItemWrap* obj = new VtkPiecewisePointHandleItemWrap(native);
		obj->Wrap(info.This());
	}
	else
	{
		if(info[0]->ToObject() != vtkNodeJsNoWrap )
		{
			Nan::ThrowError("Parameter Error");
			return;
		}
	}

	info.GetReturnValue().Set(info.This());
}

void VtkPiecewisePointHandleItemWrap::NewInstance(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkPiecewisePointHandleItemWrap *wrapper = ObjectWrap::Unwrap<VtkPiecewisePointHandleItemWrap>(info.Holder());
	vtkPiecewisePointHandleItem *native = (vtkPiecewisePointHandleItem *)wrapper->native.GetPointer();
	vtkPiecewisePointHandleItem * r;
	if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	r = native->NewInstance();
	VtkPiecewisePointHandleItemWrap::InitPtpl();
	v8::Local<v8::Value> argv[1] =
		{ Nan::New(vtkNodeJsNoWrap) };
	v8::Local<v8::Function> cons =
		Nan::New<v8::FunctionTemplate>(VtkPiecewisePointHandleItemWrap::ptpl)->GetFunction();
	v8::Local<v8::Object> wo = cons->NewInstance(1, argv);
	VtkPiecewisePointHandleItemWrap *w = new VtkPiecewisePointHandleItemWrap();
	w->native = r;
	w->Wrap(wo);
	info.GetReturnValue().Set(wo);
}

void VtkPiecewisePointHandleItemWrap::Paint(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkPiecewisePointHandleItemWrap *wrapper = ObjectWrap::Unwrap<VtkPiecewisePointHandleItemWrap>(info.Holder());
	vtkPiecewisePointHandleItem *native = (vtkPiecewisePointHandleItem *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkContext2DWrap::ptpl))->HasInstance(info[0]))
	{
		VtkContext2DWrap *a0 = ObjectWrap::Unwrap<VtkContext2DWrap>(info[0]->ToObject());
		bool r;
		if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		r = native->Paint(
			(vtkContext2D *) a0->native.GetPointer()
		);
		info.GetReturnValue().Set(Nan::New(r));
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkPiecewisePointHandleItemWrap::SafeDownCast(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkPiecewisePointHandleItemWrap *wrapper = ObjectWrap::Unwrap<VtkPiecewisePointHandleItemWrap>(info.Holder());
	vtkPiecewisePointHandleItem *native = (vtkPiecewisePointHandleItem *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkObjectBaseWrap::ptpl))->HasInstance(info[0]))
	{
		VtkObjectBaseWrap *a0 = ObjectWrap::Unwrap<VtkObjectBaseWrap>(info[0]->ToObject());
		vtkPiecewisePointHandleItem * r;
		if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		r = native->SafeDownCast(
			(vtkObjectBase *) a0->native.GetPointer()
		);
		VtkPiecewisePointHandleItemWrap::InitPtpl();
		v8::Local<v8::Value> argv[1] =
			{ Nan::New(vtkNodeJsNoWrap) };
		v8::Local<v8::Function> cons =
			Nan::New<v8::FunctionTemplate>(VtkPiecewisePointHandleItemWrap::ptpl)->GetFunction();
		v8::Local<v8::Object> wo = cons->NewInstance(1, argv);
		VtkPiecewisePointHandleItemWrap *w = new VtkPiecewisePointHandleItemWrap();
		w->native = r;
		w->Wrap(wo);
		info.GetReturnValue().Set(wo);
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkPiecewisePointHandleItemWrap::SetParent(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkPiecewisePointHandleItemWrap *wrapper = ObjectWrap::Unwrap<VtkPiecewisePointHandleItemWrap>(info.Holder());
	vtkPiecewisePointHandleItem *native = (vtkPiecewisePointHandleItem *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkAbstractContextItemWrap::ptpl))->HasInstance(info[0]))
	{
		VtkAbstractContextItemWrap *a0 = ObjectWrap::Unwrap<VtkAbstractContextItemWrap>(info[0]->ToObject());
				if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		native->SetParent(
			(vtkAbstractContextItem *) a0->native.GetPointer()
		);
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkPiecewisePointHandleItemWrap::SetPiecewiseFunction(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkPiecewisePointHandleItemWrap *wrapper = ObjectWrap::Unwrap<VtkPiecewisePointHandleItemWrap>(info.Holder());
	vtkPiecewisePointHandleItem *native = (vtkPiecewisePointHandleItem *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkPiecewiseFunctionWrap::ptpl))->HasInstance(info[0]))
	{
		VtkPiecewiseFunctionWrap *a0 = ObjectWrap::Unwrap<VtkPiecewiseFunctionWrap>(info[0]->ToObject());
				if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		native->SetPiecewiseFunction(
			(vtkPiecewiseFunction *) a0->native.GetPointer()
		);
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

