Toshihiro Shimizu 890ddd
#ifndef RULERTOOL_H
Toshihiro Shimizu 890ddd
#define RULERTOOL_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tools/tool.h"
Toshihiro Shimizu 890ddd
#include "tproperty.h"
Toshihiro Shimizu 890ddd
#include "tools/tooloptions.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <qcoreapplication></qcoreapplication>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class RulerTool : public TTool
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	Q_DECLARE_TR_FUNCTIONS(RulerTool)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	enum DragMode {
Toshihiro Shimizu 890ddd
		MakeNewRuler = 0,
Toshihiro Shimizu 890ddd
		MoveFirstPos,
Toshihiro Shimizu 890ddd
		MoveSecondPos,
Toshihiro Shimizu 890ddd
		MoveRuler
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPointD m_firstPos, m_secondPos;
Toshihiro Shimizu 890ddd
	TPointD m_mousePos;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	DragMode m_dragMode;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool m_justClicked;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	vector<rulertooloptionsbox *=""> m_toolOptionsBox;</rulertooloptionsbox>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	RulerTool();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setToolOptionsBox(RulerToolOptionsBox *toolOptionsBox);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	ToolType getToolType() const { return TTool::GenericTool; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onImageChanged();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void draw();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void leftButtonDown(const TPointD &pos, const TMouseEvent &e);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void leftButtonDrag(const TPointD &pos, const TMouseEvent &e);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void leftButtonUp(const TPointD &pos, const TMouseEvent &);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void mouseMove(const TPointD &pos, const TMouseEvent &e);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onActivate();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int getCursorId() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void updateToolOption();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*--- 現在のマウス位置がRulerに十分近ければTrue ---*/
Toshihiro Shimizu 890ddd
	bool isNearRuler();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	/*--- 基準点に対し、マウス位置を0,45,90度にフィットさせた位置を返す ---*/
Toshihiro Shimizu 890ddd
	TPointD getHVCoordinatedPos(TPointD p, TPointD centerPos);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif