//
//	Copyright © 2006 Nemetschek North America 
//	All Rights Reserved.
//
// Created by Vladislav Stanev

#include "StdAfx.h"

//#include "VWPluginToolApp.h"

#include "VWFC/PluginSupport/VWPluginToolProviders.h"

using namespace VWFC::Math;
using namespace VWFC::PluginSupport;

VWPluginToolApp::VWPluginToolApp()
{
	fpModeBarProvider		= NULL;
	fResult					= 0;
}

VWPluginToolApp::~VWPluginToolApp()
{
}

void VWPluginToolApp::SetToolModeBarProvider(IToolModeBarProvider* pModeBarProvider)
{
	fpModeBarProvider	= pModeBarProvider;
}

bool VWPluginToolApp::InitializeApp()
{
	return true;
}

void VWPluginToolApp::DeinitializeApp()
{
}

long VWPluginToolApp::GetResult() const
{
	return fResult;
}

void VWPluginToolApp::SetResult(long result)
{
	fResult	= result;
}

long VWPluginToolApp::GetUserData() const
{
	return 0;
}

void VWPluginToolApp::SetUserData(long userData)
{
}

TXString VWPluginToolApp::GetContextualHelpID() const
{
	return TXString();
}

void VWPluginToolApp::OnInitXProperties(const IToolPropertiesProvider* pPropsProvider)
{
}

void VWPluginToolApp::OnSelectionChange()
{
}

void VWPluginToolApp::OnCustomBar_Setup()
{
}

void VWPluginToolApp::OnCustomBar_Setdown()
{
}

void VWPluginToolApp::OnCustomBar_UpdateValues()
{
}

void VWPluginToolApp::OnCustomBar_LockValue(size_t fieldIndex, const TXString& userString)
{
}

void VWPluginToolApp::OnCustomBar_UnlockValue(size_t fieldIndex)
{
}

bool VWPluginToolApp::DoSetUp(bool bRestore, const IToolModeBarInitProvider* pModeBarInitProvider)
{
	return true;
}

void VWPluginToolApp::DoSetDown(bool bRestore, const IToolModeBarInitProvider* pModeBarInitProvider)
{
}

void VWPluginToolApp::DoDrawScrMod()
{
}

void VWPluginToolApp::DoUndrawScrMod()
{
}

void VWPluginToolApp::OnToolInitByObject(MCObjectHandle hObject, const IToolModeBarProvider* pModeBarInitProvider)
{
}

long VWPluginToolApp::GetCursor()
{
	return 0;
}

TToolStatus VWPluginToolApp::GetStatus(const IToolStatusProvider* pStatusProvider)
{
	return pStatusProvider->GetOnePointToolStatus();
}

void VWPluginToolApp::PointAdded()
{
}

void VWPluginToolApp::PointRemoved(bool bClearAllPts)
{
}

void VWPluginToolApp::MouseMove()
{
}

void VWPluginToolApp::DoModeEvent(size_t modeGroupID, size_t newButtonID, size_t oldButtonID)
{
}

void VWPluginToolApp::DoDoubleClick()
{
}

bool VWPluginToolApp::DrawingDoubleClick()
{
	return true;
}

void VWPluginToolApp::GenericStateChange()
{
}

size_t VWPluginToolApp::GetToolPointsCount() const
{
	return ::GS_GetNumToolPts( gCBP );
}

void VWPluginToolApp::ClearAllToolPoints()
{
	VWFC_VERIFY( ::GS_ClearAllToolPts( gCBP ) );
}

VWPoint2D VWPluginToolApp::GetToolPt2D(size_t ptIndex) const
{
	VWFC_ASSERT( ptIndex < this->GetToolPointsCount() );

	WorldPt		pt;
	VWFC_VERIFY( ::GS_GetToolPt2D( gCBP, DemoteTo<long>( kVStanev, ptIndex ), pt ) );
	return pt;
}

VWPoint3D VWPluginToolApp::GetToolPt3D(size_t ptIndex) const
{
	VWFC_ASSERT( ptIndex < this->GetToolPointsCount() );

	WorldPt3	pt;
	VWFC_VERIFY( ::GS_GetToolPt3D( gCBP, DemoteTo<long>( kVStanev, ptIndex ), pt ) );
	return pt;
}

bool VWPluginToolApp::GetToolPtCurren2D(VWPoint2D& outPt) const
{
	WorldPt		pt;
	bool		ok	= ::GS_GetToolPtCurrent2D( gCBP, pt );
	outPt			= pt;
	return ok;
}

bool VWPluginToolApp::GetToolPtCurren3D(VWPoint3D& outPt) const
{
	WorldPt3	pt;
	bool		ok	= ::GS_GetToolPtCurrent3D( gCBP, pt ) ? true : false;
	outPt			= pt;
	return ok;
}

bool VWPluginToolApp::PopLastToolPt()
{
	return GS_PopLastToolPt( gCBP ) ? true : false;
}


/*
	extern "C" Boolean GS_CALLBACK GS_GetToolPtCurrentViewPt(CallBackPtr, ViewPt& outToolPt);
	//	Returns in outToolPt the current view space point. 
	extern "C" Boolean GS_CALLBACK GS_GetToolPtCurrentWorkingPlane(CallBackPtr, WorldPt3& outToolPt);
	//	Returns in outToolPt the current 3D working plane point. 
	extern "C" Boolean GS_CALLBACK GS_GetToolPtViewPoint(CallBackPtr, long inIndex, ViewPt& outToolPoint);
	//		Gets  the specified view space ToolPoint .  The index  is a zero based index .  False is returned if
	//		the index is out of range 0 <= index< GS_GetNumToolPoints.
	extern "C" Boolean GS_CALLBACK GS_GetToolPtWorkingPlane(CallBackPtr, long inIndex, WorldPt3& outToolPoint);
	//		Gets  the specified 3D working plane ToolPoint .  The index  is a zero based index .  False is
	//		returned if the index is out of range 0 <= index< GS_GetNumToolPoints.
*/

long VWPluginToolApp::HotSpotAdd(HotSpotType type, const VWPoint3D& pt, long cursorID)
{
	return gSDK->AddHotSpot( type, pt, cursorID, "" );
}

long VWPluginToolApp::HotSpotAdd(HotSpotType type, const VWPoint3D& pt, long cursorID, const TXString& strTip)
{
	return gSDK->AddHotSpot( type, pt, cursorID, strTip );
}

long VWPluginToolApp::HotSpotTrack(bool& bOutIs3D, VWPoint3D& outLocation)
{
	Boolean		is3d		= false;
	WorldPt3	location;
	long		hotSpotID	= gSDK->TrackHotSpot( is3d, location );

	bOutIs3D				= is3d ? true : false;
	outLocation				= location;
	return hotSpotID;
}

void VWPluginToolApp::HotSpotRemove(long hotSpotID)
{
	::GS_RemoveHotSpot( gCBP, hotSpotID );
}

long VWPluginToolApp::SnapGeometryAdd(MCObjectHandle hSnapGeometry)
{
	return ::GS_AddToolSnapGeometry( gCBP, hSnapGeometry );
}

void VWPluginToolApp::SnapGeometryRemove(long snapGeometryID)
{
	::GS_RemoveToolSnapGeometry( gCBP, snapGeometryID );
}


/*
	extern "C" void GS_CALLBACK GS_TrackTool(CallBackPtr, MCObjectHandle& overObject, short& overPart, long& code);
			Used during the kToolDoPick case of a tool definition.  Returns in overObject the object the cursor
			is currently over (or nil if the cursor is not over any object) and in overPart one of cursOnNothing
			(object is not over any snappable object), cursOnObject (cursor is over an object), or cursOnHandle
			(object is over a selected objectÕs handle).  TrackTool only responds to ÒsnappableÓ objects, i.e.
			objects that are on a currently editable or snappable layer. code returns a long that is specific to
			each overPart message.

	extern "C" Boolean GS_CALLBACK GS_RunTemporary2DTool(CallBackPtr cbp, long& ioUserData, ToolDefProcPtr inToolProc);
			RunTemporary2DTool runs a temporary tool as defined by the action handleing of inToolProc. 

	extern "C" Boolean GS_CALLBACK GS_RunTemporary3DTool(CallBackPtr cbp, long& ioUserData, ToolDefProcPtr inToolProc);
			RunTemporary3DTool runs a temporary tool as defined by the action handleing of inToolProc. 
*/
//////////////////////////////////////////////
/*
void VWPluginToolApp::SetToolPersistentDraw()
{
	// we here allow only one persistent draw callback
	VWFC_ASSERT( fPersistentDrawID == 0 );
	if ( fPersistentDrawID == 0 ) {
		fPersistentDrawID	= ::GS_AddToolPersistentDraw( gCBP, _PersistentDrawCallback, this );
	}
}

void VWPluginToolApp::RemoveToolPersistentDraw()
{
	::GS_RemoveToolPersistentDraw( gCBP, fPersistentDrawID );
}

void VWPluginToolApp::_PersistentDrawCallback(CallBackPtr cbp, void* pEnv)
{
	VWPluginToolApp*	pThis	= (VWPluginToolApp*) pEnv;
	VWFC_ASSERT( pThis );
	if ( pThis ) {
		CDrawProvider	 drawProvider;

		pThis->OnToolPersistentDraw( & drawProvider );
	}
}

void VWPluginToolApp::OnToolPersistentDraw(IToolDrawProvider* pDrawProvider)
{
}*/

long VWPluginToolApp::OnDefaultEvent(long action, long message1, long message2)
{
	return 0;
}

//////////////////////////////////////////////
/*
	extern "C" void GS_CALLBACK GS_Interactive2DDraw(CallBackPtr cbp, short options, short shiftConsMode, GS_I2DDrawProcPtr drawProc, void *env);
//			Interactive2DDraw is called when drawing interactively.  To use it, you must define all drawing to
//			be done as a function of the worldspace start and endpoints of a drag operation.
//			the prototype for Interactive2DDraw is :
//					
//			Interactive2DDraw(CallBackPtr cbp, short options, short shiftConsMode, I2DDrawProcPtr drawProc, void
//			*env);
//					
//			where drawProc is the function that does the drawing.  Interactive2DDraw takes care of 
//			the draw and undraw for you as well as respond to any constraints set with shiftConsMode 
//			or the constaint set in the TDef.


	extern "C" void GS_CALLBACK GS_GetCoords(CallBackPtr, WorldPt& p, Point& m);
//			Returns the final mouse position after an Interactive2DDraw call, both in world and view coordinates.
		*/


//////////////////////////////////////////////
