/********************************************************************/
/* Copyright (c) 2019 System fugen G.K. and Yuzi Mizuno          */
/* All rights reserved.                                             */
/********************************************************************/
/**
 * @file GridCursor.h
 * @brief クラス MGGridCursor の宣言
 */
#pragma once

class MGPosition;
class mgGLSLProgram;
class mgTexture;
class MGLocateInfo;

#include "mgGL/VBO.h"

///defines rubberband line kind for the current input position.
enum  RUBBER_KIND{
	NO_RUBBER=0,///<no rubberband line
	LINE_RUBBER	///<straight line rubberband
};

///defines what kind of trace be drawn for the past input positions.
enum IPOINT_DRAWER_KIND{
	NO_IPDRAW=0,	///<no traces.
	POINT_IPDRAW,	///<only points.
	LINE_IPDRAW,	///<only a polyline.
	POINTLINE_IPDRAW///<both points and a polyline.
};

/// @class MGGridCursor GridCursor.h "Common/GridCursor.h"
/// OpenGL でカーソルイメージを描画するためのクラス。
class MGGridCursor:public mgVBO{
	friend class MGLocateState;

protected:
	const MGPosition* m_cursor;///Mouse cursor position of the interaction.

public:

	/// デフォルトコンストラクター
	MGGridCursor(){;};

	virtual ~MGGridCursor(){;};

	///m_gelの描画データ作成のみをおこなう。
	///すでに作成済みであっても強制的に再作成を行う。
	///m_gel=0のときはなにもしない。
	virtual void make_display_list(MGCL::VIEWMODE vmode=MGCL::DONTCARE);
	
	///描画関数draw()は、is_made()であれば、作成し、表示処理をする。
	///!is_made()(描画データ作成済み）であれば、すでに作成されたmgVBOElementの描画を行う。
	///MGGridCursor::draw() draws the grid cursor image.
	virtual void draw(MGCL::VIEWMODE viewMode=MGCL::DONTCARE);
	
	const MGPosition& cursor()const{return *m_cursor;};
	//const std::vector<MGPosition>* points()const{return m_points;};
	const LInfoVec* lpoints()const{return m_lpoints;};

	virtual void draw_contents();

	///Points drawer service program.
	virtual void draw_points();

	///Polyline drawer service program.
	virtual void draw_lines();

	//Singleton cursor get.
	mgVBO* getGridCursor();

private:
	mgTexture* m_gridCursorTexture;

	RUBBER_KIND m_rubberKind;//Rubberband line kind.
	IPOINT_DRAWER_KIND m_pointDrawKind;//Rubberband line kind.
	//const std::vector<MGPosition>* m_points;///Input positions so far for the command.
	const LInfoVec* m_lpoints;///Input positions so far for the command.

	float m_LWidthPLine;//Linewidth of m_pointDrawKind line.
	float m_LWidthRubber;//Linewidth of m_pointDrawKind line.
	MGColor m_pointColor;//color of the points ipos.
	MGColor m_lineColor;//color of the points ipos.
	MGColor m_lineToCursorColor;//color of the last point of ipos to the cursor.
};
