tahoma2d/toonz/sources/tnztools/rgbpickertool.h

114 lines
3.1 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef RGBPICKERTOOL_H
#define RGBPICKERTOOL_H
#include "tools/tool.h"
#include "tproperty.h"
#include "toonz/strokegenerator.h"
#include "tools/tooloptions.h"
#include <QCoreApplication>
class RGBPickerTool final : public TTool {
2016-06-15 18:43:10 +12:00
Q_DECLARE_TR_FUNCTIONS(RGBPickerTool)
bool m_firstTime;
int m_currentStyleId;
TPixel32 m_oldValue, m_currentValue;
TRectD m_selectingRect;
TRectD m_drawingRect;
TPropertyGroup m_prop;
TEnumProperty m_pickType;
TBoolProperty m_passivePick;
std::vector<RGBPickerToolOptionsBox *> m_toolOptionsBox;
// Aggiunte per disegnare il lazzo a la polyline
StrokeGenerator m_drawingTrack;
StrokeGenerator m_workingTrack;
TPointD m_firstDrawingPos, m_firstWorkingPos;
TPointD m_mousePosition;
double m_thick;
TStroke *m_stroke;
TStroke *m_firstStroke;
std::vector<TPointD> m_drawingPolyline;
std::vector<TPointD> m_workingPolyline;
bool m_makePick;
2016-03-19 06:57:51 +13:00
2018-01-19 22:29:42 +13:00
TPointD m_mousePixelPosition;
2016-06-20 23:17:05 +12:00
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
RGBPickerTool();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
/*-- ToolOptionBox上にPassiveに拾った色を表示するため --*/
void setToolOptionsBox(RGBPickerToolOptionsBox *toolOptionsBox);
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
ToolType getToolType() const override { return TTool::LevelReadTool; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void updateTranslation() override;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// Used to notify and set the currentColor outside the draw() methods:
// using special style there was a conflict between the draw() methods of the
// tool
// and the generation of the icon inside the style editor (makeIcon()) which
2016-06-15 18:43:10 +12:00
// use
// another glContext
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void onImageChanged() override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void draw() override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void leftButtonDown(const TPointD &pos, const TMouseEvent &e) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void leftButtonDrag(const TPointD &pos, const TMouseEvent &e) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void leftButtonUp(const TPointD &pos, const TMouseEvent &) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void leftButtonDoubleClick(const TPointD &pos, const TMouseEvent &e) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void mouseMove(const TPointD &pos, const TMouseEvent &e) override;
2016-03-19 06:57:51 +13:00
2016-06-20 23:17:05 +12:00
void pick();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void pickRect();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void pickStroke();
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
bool onPropertyChanged(std::string propertyName) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void onActivate() override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
TPropertyGroup *getProperties(int targetType) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
int getCursorId() const override;
2016-03-19 06:57:51 +13:00
2016-06-20 23:17:05 +12:00
void doPolylineFreehandPick();
void passivePick();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! Viene aggiunto \b pos a \b m_track e disegnato il primo pezzetto del
//! lazzo. Viene inizializzato \b m_firstPos
void startFreehand(const TPointD &drawingPos, const TPointD &workingPos);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! Viene aggiunto \b pos a \b m_track e disegnato un altro pezzetto del
//! lazzo.
void freehandDrag(const TPointD &drawingPos, const TPointD &workingPos);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! Viene chiuso il lazzo (si aggiunge l'ultimo punto ad m_track) e viene
//! creato lo stroke rappresentante il lazzo.
void closeFreehand();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! Viene aggiunto un punto al vettore m_polyline.
void addPointPolyline(const TPointD &drawingPos, const TPointD &workingPos);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! Agginge l'ultimo pos a \b m_polyline e chiude la spezzata (aggiunge \b
//! m_polyline.front() alla fine del vettore)
void closePolyline(const TPointD &drawingPos, const TPointD &workingPos);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
/*--- RGBPickerToolをFlipbookで有効にする ---*/
void showFlipPickedColor(const TPixel32 &pix);
2016-03-19 06:57:51 +13:00
};
#endif