Shinya Kitaoka 810553
#pragma once
Shinya Kitaoka 810553
Toshihiro Shimizu 890ddd
#ifndef RGBPICKERTOOL_H
Toshihiro Shimizu 890ddd
#define RGBPICKERTOOL_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tools/tool.h"
Toshihiro Shimizu 890ddd
#include "tproperty.h"
Toshihiro Shimizu 890ddd
#include "toonz/strokegenerator.h"
Toshihiro Shimizu 890ddd
#include "tools/tooloptions.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <qcoreapplication></qcoreapplication>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class RGBPickerTool : public TTool
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	Q_DECLARE_TR_FUNCTIONS(RGBPickerTool)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool m_firstTime;
Toshihiro Shimizu 890ddd
	int m_currentStyleId;
Toshihiro Shimizu 890ddd
	TPixel32 m_oldValue, m_currentValue;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TRectD m_selectingRect;
Toshihiro Shimizu 890ddd
	TRectD m_drawingRect;
Toshihiro Shimizu 890ddd
	TPropertyGroup m_prop;
Toshihiro Shimizu 890ddd
	TEnumProperty m_pickType;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TBoolProperty m_passivePick;
Shinya Kitaoka 3bfa54
	std::vector<rgbpickertooloptionsbox *=""> m_toolOptionsBox;</rgbpickertooloptionsbox>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//Aggiunte per disegnare il lazzo a la polyline
Toshihiro Shimizu 890ddd
	StrokeGenerator m_drawingTrack;
Toshihiro Shimizu 890ddd
	StrokeGenerator m_workingTrack;
Toshihiro Shimizu 890ddd
	TPointD m_firstDrawingPos, m_firstWorkingPos;
Toshihiro Shimizu 890ddd
	TPointD m_mousePosition;
Toshihiro Shimizu 890ddd
	double m_thick;
Toshihiro Shimizu 890ddd
	TStroke *m_stroke;
Toshihiro Shimizu 890ddd
	TStroke *m_firstStroke;
Shinya Kitaoka 3bfa54
	std::vector<tpointd> m_drawingPolyline;</tpointd>
Shinya Kitaoka 3bfa54
	std::vector<tpointd> m_workingPolyline;</tpointd>
Toshihiro Shimizu 890ddd
	bool m_makePick;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	RGBPickerTool();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*-- ToolOptionBox上にPassiveに拾った色を表示するため --*/
Toshihiro Shimizu 890ddd
	void setToolOptionsBox(RGBPickerToolOptionsBox *toolOptionsBox);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	ToolType getToolType() const { return TTool::LevelReadTool; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void updateTranslation();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Used to notify and set the currentColor outside the draw() methods:
Toshihiro Shimizu 890ddd
	// using special style there was a conflict between the draw() methods of the tool
Toshihiro Shimizu 890ddd
	// and the genaration of the icon inside the style editor (makeIcon()) which use
Toshihiro Shimizu 890ddd
	// another glContext
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 leftButtonDoubleClick(const TPointD &pos, const TMouseEvent &e);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void mouseMove(const TPointD &pos, const TMouseEvent &e);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void pick(TPoint pos);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void pickRect();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void pickStroke();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 3bfa54
	bool onPropertyChanged(std::string propertyName);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onActivate();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPropertyGroup *getProperties(int targetType);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int getCursorId() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void doPolylinePick();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//!Viene aggiunto \b pos a \b m_track e disegnato il primo pezzetto del lazzo. Viene inizializzato \b m_firstPos
Toshihiro Shimizu 890ddd
	void startFreehand(const TPointD &drawingPos, const TPointD &workingPos);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//!Viene aggiunto \b pos a \b m_track e disegnato un altro pezzetto del lazzo.
Toshihiro Shimizu 890ddd
	void freehandDrag(const TPointD &drawingPos, const TPointD &workingPos);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//!Viene chiuso il lazzo (si aggiunge l'ultimo punto ad m_track) e viene creato lo stroke rappresentante il lazzo.
Toshihiro Shimizu 890ddd
	void closeFreehand();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//!Viene aggiunto un punto al vettore m_polyline.
Toshihiro Shimizu 890ddd
	void addPointPolyline(const TPointD &drawingPos, const TPointD &workingPos);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//!Agginge l'ultimo pos a \b m_polyline e chiude la spezzata (aggiunge \b m_polyline.front() alla fine del vettore)
Toshihiro Shimizu 890ddd
	void closePolyline(const TPointD &drawingPos, const TPointD &workingPos);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*--- RGBPickerToolをFlipbookで有効にする ---*/
Toshihiro Shimizu 890ddd
	void showFlipPickedColor(const TPixel32 &pix);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif