|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "rgbpickertool.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tvectorimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ttoonzimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/cursors.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tcolorstyles.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/cleanupcolorstyles.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trasterimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tgl.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tenv.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstroke.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/palettecontroller.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tpalettehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tscenehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshlevelhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/stage2.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshsimplelevel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/preferences.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/icongenerator.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/dvdialog.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/toolhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/stylepicker.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/toolutils.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/RGBpicker.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//iwsw commented out temporarily
|
|
Toshihiro Shimizu |
890ddd |
//#include "toonzqt/ghibli_3dlut_util.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#define NORMAL_PICK L"Normal"
|
|
Toshihiro Shimizu |
890ddd |
#define RECT_PICK L"Rectangular"
|
|
Toshihiro Shimizu |
890ddd |
#define FREEHAND_PICK L"Freehand"
|
|
Toshihiro Shimizu |
890ddd |
#define POLYLINE_PICK L"Polyline"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TEnv::StringVar PickVectorType("InknpaintPickVectorType", "Normal");
|
|
Toshihiro Shimizu |
890ddd |
TEnv::IntVar PickPassive("InknpaintPickPassive", 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace RGBPicker
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//============================================================
|
|
Toshihiro Shimizu |
890ddd |
// Pick RGB Tool
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class UndoPickRGBM : public TUndo
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPaletteP m_palette;
|
|
Toshihiro Shimizu |
890ddd |
int m_styleId;
|
|
Toshihiro Shimizu |
890ddd |
int m_styleParamIndex;
|
|
Toshihiro Shimizu |
890ddd |
TPixel32 m_oldValue, m_newValue;
|
|
Toshihiro Shimizu |
890ddd |
TXshSimpleLevelP m_level;
|
|
Toshihiro Shimizu |
890ddd |
bool m_colorAutoApplyEnabled;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
UndoPickRGBM(TPalette *palette, int styleId, const TPixel32 newValue, const TXshSimpleLevelP &level)
|
|
Toshihiro Shimizu |
890ddd |
: m_palette(palette), m_styleId(styleId), m_newValue(newValue), m_level(level), m_colorAutoApplyEnabled(true)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
PaletteController *controller = TTool::getApplication()->getPaletteController();
|
|
Toshihiro Shimizu |
890ddd |
m_colorAutoApplyEnabled = controller->isColorAutoApplyEnabled();
|
|
Toshihiro Shimizu |
890ddd |
m_styleParamIndex = controller->getCurrentPalette()->getStyleParamIndex();
|
|
Toshihiro Shimizu |
890ddd |
if (m_colorAutoApplyEnabled) {
|
|
Toshihiro Shimizu |
890ddd |
TColorStyle *cs = m_palette->getStyle(m_styleId);
|
|
Toshihiro Shimizu |
890ddd |
if (0 <= m_styleParamIndex && m_styleParamIndex < cs->getColorParamCount())
|
|
Toshihiro Shimizu |
890ddd |
m_oldValue = cs->getColorParamValue(m_styleParamIndex);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
m_oldValue = cs->getMainColor();
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
m_oldValue = controller->getColorSample();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void setColor(const TPixel32 &color) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
PaletteController *controller = TTool::getApplication()->getPaletteController();
|
|
Toshihiro Shimizu |
890ddd |
if (m_colorAutoApplyEnabled) {
|
|
Toshihiro Shimizu |
890ddd |
TColorStyle *cs = m_palette->getStyle(m_styleId);
|
|
Toshihiro Shimizu |
890ddd |
if (0 <= m_styleParamIndex && m_styleParamIndex < cs->getColorParamCount())
|
|
Toshihiro Shimizu |
890ddd |
cs->setColorParamValue(m_styleParamIndex, color);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
cs->setMainColor(color);
|
|
Toshihiro Shimizu |
890ddd |
cs->invalidateIcon();
|
|
Toshihiro Shimizu |
890ddd |
controller->getCurrentPalette()->notifyColorStyleChanged();
|
|
Toshihiro Shimizu |
890ddd |
updateLevel();
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
controller->setColorSample(color);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void undo() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setColor(m_oldValue);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void redo() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setColor(m_newValue);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int getSize() const { return sizeof(*this); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QString getHistoryString()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return QObject::tr("RGB Picker (R%1, G%2, B%3)")
|
|
Toshihiro Shimizu |
890ddd |
.arg(QString::number((int)m_newValue.r))
|
|
Toshihiro Shimizu |
890ddd |
.arg(QString::number((int)m_newValue.g))
|
|
Toshihiro Shimizu |
890ddd |
.arg(QString::number((int)m_newValue.b));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
void updateLevel() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tframeid> fids;</tframeid>
|
|
Toshihiro Shimizu |
890ddd |
if (!m_level)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
m_level->getFids(fids);
|
|
Toshihiro Shimizu |
890ddd |
unsigned int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < fids.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
IconGenerator::instance()->invalidate(m_level.getPointer(), fids[i]);
|
|
Toshihiro Shimizu |
890ddd |
IconGenerator::instance()->invalidateSceneIcon();
|
|
Toshihiro Shimizu |
890ddd |
TTool::getApplication()->getCurrentScene()->notifySceneChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void setCurrentColor(const TPixel32 &color)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
PaletteController *controller = TTool::getApplication()->getPaletteController();
|
|
Toshihiro Shimizu |
890ddd |
TPaletteHandle *ph = controller->getCurrentPalette();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TColorStyle *cs = ph->getStyle();
|
|
Toshihiro Shimizu |
890ddd |
if (!cs)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (controller->isColorAutoApplyEnabled()) {
|
|
Toshihiro Shimizu |
890ddd |
TCleanupStyle *ccs = dynamic_cast<tcleanupstyle *="">(cs);</tcleanupstyle>
|
|
Toshihiro Shimizu |
890ddd |
if (ccs)
|
|
Toshihiro Shimizu |
890ddd |
ccs->setCanUpdate(true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int index = ph->getStyleParamIndex();
|
|
Toshihiro Shimizu |
890ddd |
if (0 <= index && index < cs->getColorParamCount())
|
|
Toshihiro Shimizu |
890ddd |
cs->setColorParamValue(index, color);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
cs->setMainColor(color);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
cs->invalidateIcon();
|
|
Toshihiro Shimizu |
890ddd |
ph->notifyColorStyleChanged();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// per le palette animate
|
|
Toshihiro Shimizu |
890ddd |
int styleIndex = ph->getStyleIndex();
|
|
Toshihiro Shimizu |
890ddd |
TPalette *palette = ph->getPalette();
|
|
Toshihiro Shimizu |
890ddd |
if (palette && palette->isKeyframe(styleIndex, palette->getFrame()))
|
|
Toshihiro Shimizu |
890ddd |
palette->setKeyframe(styleIndex, palette->getFrame());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (ccs)
|
|
Toshihiro Shimizu |
890ddd |
ccs->setCanUpdate(false);
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
controller->setColorSample(color);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void setCurrentColorWithUndo(const TPixel32 &color)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TTool::Application *app = TTool::getApplication();
|
|
Toshihiro Shimizu |
890ddd |
TPaletteHandle *ph = app->getPaletteController()->getCurrentPalette();
|
|
Toshihiro Shimizu |
890ddd |
int styleId = ph->getStyleIndex();
|
|
Toshihiro Shimizu |
890ddd |
TPalette *palette = ph->getPalette();
|
|
Toshihiro Shimizu |
890ddd |
TXshSimpleLevel *level = app->getCurrentLevel()->getSimpleLevel();
|
|
Toshihiro Shimizu |
890ddd |
if (palette)
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->add(new UndoPickRGBM(palette, styleId, color, level));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
setCurrentColor(color);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (level) {
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tframeid> fids;</tframeid>
|
|
Toshihiro Shimizu |
890ddd |
level->getFids(fids);
|
|
Toshihiro Shimizu |
890ddd |
invalidateIcons(level, fids);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} // namespace RGBPicker
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using namespace RGBPicker;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
RGBPickerTool::RGBPickerTool()
|
|
Toshihiro Shimizu |
890ddd |
: TTool("T_RGBPicker"), m_currentStyleId(0), m_pickType("Type:"), m_drawingTrack(), m_workingTrack(), m_firstDrawingPos(), m_firstWorkingPos(), m_mousePosition(), m_thick(0.5), m_stroke(0), m_firstStroke(0), m_makePick(false), m_firstTime(true), m_passivePick("Passive Pick", false), m_toolOptionsBox(0)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
bind(TTool::CommonLevels);
|
|
Toshihiro Shimizu |
890ddd |
m_prop.bind(m_pickType);
|
|
Toshihiro Shimizu |
890ddd |
m_pickType.addValue(NORMAL_PICK);
|
|
Toshihiro Shimizu |
890ddd |
m_pickType.addValue(RECT_PICK);
|
|
Toshihiro Shimizu |
890ddd |
m_pickType.addValue(FREEHAND_PICK);
|
|
Toshihiro Shimizu |
890ddd |
m_pickType.addValue(POLYLINE_PICK);
|
|
Toshihiro Shimizu |
890ddd |
m_pickType.setId("Type");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_prop.bind(m_passivePick);
|
|
Toshihiro Shimizu |
890ddd |
m_passivePick.setId("PassivePick");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RGBPickerTool::setToolOptionsBox(RGBPickerToolOptionsBox *toolOptionsBox)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_toolOptionsBox.push_back(toolOptionsBox);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RGBPickerTool::updateTranslation()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_pickType.setQStringName(tr("Type:"));
|
|
Toshihiro Shimizu |
890ddd |
m_passivePick.setQStringName(tr("Passive Pick"));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
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 RGBPickerTool::onImageChanged()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_currentStyleId != 0 && m_makePick &&
|
|
Toshihiro Shimizu |
890ddd |
(m_pickType.getValue() == POLYLINE_PICK || m_pickType.getValue() == RECT_PICK)) {
|
|
Toshihiro Shimizu |
890ddd |
TTool::Application *app = TTool::getApplication();
|
|
Toshihiro Shimizu |
890ddd |
TPaletteHandle *ph = app->getPaletteController()->getCurrentPalette();
|
|
Toshihiro Shimizu |
890ddd |
int styleId = ph->getStyleIndex();
|
|
Toshihiro Shimizu |
890ddd |
TPalette *palette = ph->getPalette();
|
|
Toshihiro Shimizu |
890ddd |
TXshSimpleLevel *level = app->getCurrentLevel()->getSimpleLevel();
|
|
Toshihiro Shimizu |
890ddd |
if (palette)
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->add(new UndoPickRGBM(palette, styleId, m_currentValue, level));
|
|
Toshihiro Shimizu |
890ddd |
setCurrentColor(m_currentValue);
|
|
Toshihiro Shimizu |
890ddd |
if (level) {
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tframeid> fids;</tframeid>
|
|
Toshihiro Shimizu |
890ddd |
level->getFids(fids);
|
|
Toshihiro Shimizu |
890ddd |
invalidateIcons(level, fids);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
m_makePick = false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RGBPickerTool::draw()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
double pixelSize2 = getPixelSize() * getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
m_thick = sqrt(pixelSize2) / 2.0;
|
|
Toshihiro Shimizu |
890ddd |
if (m_makePick) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_currentStyleId != 0) {
|
|
Toshihiro Shimizu |
890ddd |
//Il pick in modalita' polyline e rectangular deve essere fatto soltanto dopo aver cancellato il
|
|
Toshihiro Shimizu |
890ddd |
//"disegno" della polyline altrimenti alcuni pixels neri delle spezzate che la
|
|
Toshihiro Shimizu |
890ddd |
//compongono vengono presi in considerazione nel calcolo del "colore medio"
|
|
Toshihiro Shimizu |
890ddd |
if (m_pickType.getValue() == POLYLINE_PICK && m_drawingPolyline.empty())
|
|
Toshihiro Shimizu |
890ddd |
doPolylinePick();
|
|
Toshihiro Shimizu |
890ddd |
else if (m_pickType.getValue() == RECT_PICK && m_drawingRect.isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
pickRect();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_pickType.getValue() == RECT_PICK && !m_makePick) {
|
|
Toshihiro Shimizu |
890ddd |
TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg ? TPixel32::White : TPixel32::Red;
|
|
Toshihiro Shimizu |
890ddd |
ToolUtils::drawRect(m_drawingRect, color, 0x3F33, true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_pickType.getValue() == POLYLINE_PICK && !m_drawingPolyline.empty()) {
|
|
Toshihiro Shimizu |
890ddd |
TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg ? TPixel32::White : TPixel32::Black;
|
|
Toshihiro Shimizu |
890ddd |
tglColor(color);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawCircle(m_drawingPolyline[0], 2);
|
|
Toshihiro Shimizu |
890ddd |
glBegin(GL_LINE_STRIP);
|
|
Toshihiro Shimizu |
890ddd |
for (UINT i = 0; i < m_drawingPolyline.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
tglVertex(m_drawingPolyline[i]);
|
|
Toshihiro Shimizu |
890ddd |
tglVertex(m_mousePosition);
|
|
Toshihiro Shimizu |
890ddd |
glEnd();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RGBPickerTool::leftButtonDown(const TPointD &pos, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TTool::Application *app = TTool::getApplication();
|
|
Toshihiro Shimizu |
890ddd |
TPaletteHandle *pltHandle = app->getPaletteController()->getCurrentPalette();
|
|
Toshihiro Shimizu |
890ddd |
m_currentStyleId = pltHandle->getStyleIndex();
|
|
Toshihiro Shimizu |
890ddd |
if (m_currentStyleId == 0)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TColorStyle *colorStyle = pltHandle->getStyle();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (colorStyle)
|
|
Toshihiro Shimizu |
890ddd |
m_oldValue = colorStyle->getMainColor();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_pickType.getValue() == RECT_PICK) {
|
|
Toshihiro Shimizu |
890ddd |
m_selectingRect.x0 = e.m_pos.x;
|
|
Toshihiro Shimizu |
890ddd |
m_selectingRect.y0 = e.m_pos.y;
|
|
Toshihiro Shimizu |
890ddd |
m_selectingRect.x1 = e.m_pos.x;
|
|
Toshihiro Shimizu |
890ddd |
m_selectingRect.y1 = e.m_pos.y;
|
|
Toshihiro Shimizu |
890ddd |
m_drawingRect.x0 = pos.x;
|
|
Toshihiro Shimizu |
890ddd |
m_drawingRect.y0 = pos.y;
|
|
Toshihiro Shimizu |
890ddd |
m_drawingRect.x1 = pos.x;
|
|
Toshihiro Shimizu |
890ddd |
m_drawingRect.y1 = pos.y;
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
} else if (m_pickType.getValue() == FREEHAND_PICK) {
|
|
Toshihiro Shimizu |
890ddd |
startFreehand(pos, convert(e.m_pos));
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
} else if (m_pickType.getValue() == POLYLINE_PICK) {
|
|
Toshihiro Shimizu |
890ddd |
addPointPolyline(pos, convert(e.m_pos));
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
pick(e.m_pos);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RGBPickerTool::leftButtonDrag(const TPointD &pos, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_currentStyleId == 0)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
if (m_pickType.getValue() == RECT_PICK) {
|
|
Toshihiro Shimizu |
890ddd |
m_selectingRect.x1 = e.m_pos.x;
|
|
Toshihiro Shimizu |
890ddd |
m_selectingRect.y1 = e.m_pos.y;
|
|
Toshihiro Shimizu |
890ddd |
m_drawingRect.x1 = pos.x;
|
|
Toshihiro Shimizu |
890ddd |
m_drawingRect.y1 = pos.y;
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
} else if (m_pickType.getValue() == FREEHAND_PICK)
|
|
Toshihiro Shimizu |
890ddd |
freehandDrag(pos, convert(e.m_pos));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RGBPickerTool::leftButtonUp(const TPointD &pos, const TMouseEvent &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_currentStyleId == 0)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
if (m_pickType.getValue() == RECT_PICK) {
|
|
Toshihiro Shimizu |
890ddd |
m_makePick = true;
|
|
Toshihiro Shimizu |
890ddd |
m_drawingRect.empty();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_pickType.getValue() == FREEHAND_PICK) {
|
|
Toshihiro Shimizu |
890ddd |
closeFreehand();
|
|
Toshihiro Shimizu |
890ddd |
if (m_currentStyleId != 0)
|
|
Toshihiro Shimizu |
890ddd |
pickStroke();
|
|
Toshihiro Shimizu |
890ddd |
delete m_stroke;
|
|
Toshihiro Shimizu |
890ddd |
m_stroke = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RGBPickerTool::leftButtonDoubleClick(const TPointD &pos, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_currentStyleId == 0)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
if (m_pickType.getValue() == POLYLINE_PICK) {
|
|
Toshihiro Shimizu |
890ddd |
closePolyline(pos, convert(e.m_pos));
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tthickpoint> strokePoints;</tthickpoint>
|
|
Toshihiro Shimizu |
890ddd |
for (UINT i = 0; i < m_workingPolyline.size() - 1; i++) {
|
|
Toshihiro Shimizu |
890ddd |
strokePoints.push_back(TThickPoint(m_workingPolyline[i], 1));
|
|
Toshihiro Shimizu |
890ddd |
strokePoints.push_back(TThickPoint(0.5 * (m_workingPolyline[i] + m_workingPolyline[i + 1]), 1));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
strokePoints.push_back(TThickPoint(m_workingPolyline.back(), 1));
|
|
Toshihiro Shimizu |
890ddd |
m_drawingPolyline.clear();
|
|
Toshihiro Shimizu |
890ddd |
m_workingPolyline.clear();
|
|
Toshihiro Shimizu |
890ddd |
m_stroke = new TStroke(strokePoints);
|
|
Toshihiro Shimizu |
890ddd |
m_makePick = true;
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RGBPickerTool::mouseMove(const TPointD &pos, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
/*--- Passiveに色を拾う機能 ---*/
|
|
Toshihiro Shimizu |
890ddd |
if (m_passivePick.getValue() == true) {
|
|
Toshihiro Shimizu |
890ddd |
TImageP image = TImageP(getImage(false));
|
|
Toshihiro Shimizu |
890ddd |
if (image) {
|
|
Toshihiro Shimizu |
890ddd |
TRectD area = TRectD(e.m_pos.x, e.m_pos.y, e.m_pos.x, e.m_pos.y);
|
|
Toshihiro Shimizu |
890ddd |
//TRectD area=TRectD(e.m_pos.x-1,e.m_pos.y-1,e.m_pos.x+1,e.m_pos.y+1);
|
|
Toshihiro Shimizu |
890ddd |
StylePicker picker(image);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//iwsw commented out temporarily
|
|
Toshihiro Shimizu |
890ddd |
//if (m_viewer->get3DLutUtil() && Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
|
|
Toshihiro Shimizu |
890ddd |
// m_viewer->get3DLutUtil()->bindFBO();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPixel32 pix = picker.pickColor(area);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//iwsw commented out temporarily
|
|
Toshihiro Shimizu |
890ddd |
//if (m_viewer->get3DLutUtil() && Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
|
|
Toshihiro Shimizu |
890ddd |
// m_viewer->get3DLutUtil()->releaseFBO();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QColor col((int)pix.r, (int)pix.g, (int)pix.b);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
PaletteController *controller = TTool::getApplication()->getPaletteController();
|
|
Toshihiro Shimizu |
890ddd |
controller->notifyColorPassivePicked(col);
|
|
Toshihiro Shimizu |
890ddd |
//for (int i = 0; i<(int)m_toolOptionsBox.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
//{
|
|
Toshihiro Shimizu |
890ddd |
// if (m_toolOptionsBox[i]->isVisible())
|
|
Toshihiro Shimizu |
890ddd |
// m_toolOptionsBox[i]->updateRealTimePickLabel(col);
|
|
Toshihiro Shimizu |
890ddd |
//}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_pickType.getValue() == POLYLINE_PICK && !m_drawingPolyline.empty()) {
|
|
Toshihiro Shimizu |
890ddd |
m_mousePosition = pos;
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RGBPickerTool::pick(TPoint pos)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TImageP image = TImageP(getImage(false));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TTool::Application *app = TTool::getApplication();
|
|
Toshihiro Shimizu |
890ddd |
TPaletteHandle *ph = app->getPaletteController()->getCurrentPalette();
|
|
Toshihiro Shimizu |
890ddd |
int styleId = ph->getStyleIndex();
|
|
Toshihiro Shimizu |
890ddd |
TPalette *palette = ph->getPalette();
|
|
Toshihiro Shimizu |
890ddd |
if (!palette)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRectD area = TRectD(pos.x - 1, pos.y - 1, pos.x + 1, pos.y + 1);
|
|
Toshihiro Shimizu |
890ddd |
StylePicker picker(image, palette);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//iwsw commented out temporarily
|
|
Toshihiro Shimizu |
890ddd |
//if (m_viewer->get3DLutUtil() && Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
|
|
Toshihiro Shimizu |
890ddd |
// m_viewer->get3DLutUtil()->bindFBO();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_currentValue = picker.pickColor(area);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//iwsw commented out temporarily
|
|
Toshihiro Shimizu |
890ddd |
//if (m_viewer->get3DLutUtil() && Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
|
|
Toshihiro Shimizu |
890ddd |
// m_viewer->get3DLutUtil()->releaseFBO();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TXshSimpleLevel *level = app->getCurrentLevel()->getSimpleLevel();
|
|
Toshihiro Shimizu |
890ddd |
UndoPickRGBM *cmd = new UndoPickRGBM(palette, styleId, m_currentValue, level);
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->add(cmd);
|
|
Toshihiro Shimizu |
890ddd |
cmd->redo();
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
setCurrentColor(m_currentValue);
|
|
Toshihiro Shimizu |
890ddd |
if(level)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
vector<tframeid> fids;</tframeid>
|
|
Toshihiro Shimizu |
890ddd |
level->getFids(fids);
|
|
Toshihiro Shimizu |
890ddd |
invalidateIcons(level,fids);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RGBPickerTool::pickRect()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TImageP image = TImageP(getImage(false));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TTool::Application *app = TTool::getApplication();
|
|
Toshihiro Shimizu |
890ddd |
TPaletteHandle *ph = app->getPaletteController()->getCurrentPalette();
|
|
Toshihiro Shimizu |
890ddd |
int styleId = ph->getStyleIndex();
|
|
Toshihiro Shimizu |
890ddd |
TPalette *palette = ph->getPalette();
|
|
Toshihiro Shimizu |
890ddd |
TRectD area = m_selectingRect;
|
|
Toshihiro Shimizu |
890ddd |
if (!palette)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
if (m_selectingRect.x0 > m_selectingRect.x1) {
|
|
Toshihiro Shimizu |
890ddd |
area.x1 = m_selectingRect.x0;
|
|
Toshihiro Shimizu |
890ddd |
area.x0 = m_selectingRect.x1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_selectingRect.y0 > m_selectingRect.y1) {
|
|
Toshihiro Shimizu |
890ddd |
area.y1 = m_selectingRect.y0;
|
|
Toshihiro Shimizu |
890ddd |
area.y0 = m_selectingRect.y1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
m_selectingRect.empty();
|
|
Toshihiro Shimizu |
890ddd |
if (area.getLx() <= 1 || area.getLy() <= 1)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
StylePicker picker(image, palette);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//iwsw commented out temporarily
|
|
Toshihiro Shimizu |
890ddd |
//if (m_viewer->get3DLutUtil() && Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
|
|
Toshihiro Shimizu |
890ddd |
// m_viewer->get3DLutUtil()->bindFBO();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_currentValue = picker.pickColor(area);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//iwsw commented out temporarily
|
|
Toshihiro Shimizu |
890ddd |
//if (m_viewer->get3DLutUtil() && Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
|
|
Toshihiro Shimizu |
890ddd |
// m_viewer->get3DLutUtil()->releaseFBO();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RGBPickerTool::pickStroke()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TImageP image = TImageP(getImage(false));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TTool::Application *app = TTool::getApplication();
|
|
Toshihiro Shimizu |
890ddd |
TPaletteHandle *ph = app->getPaletteController()->getCurrentPalette();
|
|
Toshihiro Shimizu |
890ddd |
int styleId = ph->getStyleIndex();
|
|
Toshihiro Shimizu |
890ddd |
TPalette *palette = ph->getPalette();
|
|
Toshihiro Shimizu |
890ddd |
if (!palette)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
StylePicker picker(image, palette);
|
|
Toshihiro Shimizu |
890ddd |
TStroke *stroke = new TStroke(*m_stroke);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//iwsw commented out temporarily
|
|
Toshihiro Shimizu |
890ddd |
//if (m_viewer->get3DLutUtil() && Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
|
|
Toshihiro Shimizu |
890ddd |
// m_viewer->get3DLutUtil()->bindFBO();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_currentValue = picker.pickColor(stroke);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//iwsw commented out temporarily
|
|
Toshihiro Shimizu |
890ddd |
//if (m_viewer->get3DLutUtil() && Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
|
|
Toshihiro Shimizu |
890ddd |
// m_viewer->get3DLutUtil()->releaseFBO();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!(m_pickType.getValue() == POLYLINE_PICK)) {
|
|
Toshihiro Shimizu |
890ddd |
TXshSimpleLevel *level = app->getCurrentLevel()->getSimpleLevel();
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->add(new UndoPickRGBM(palette, styleId, m_currentValue, level));
|
|
Toshihiro Shimizu |
890ddd |
setCurrentColor(m_currentValue);
|
|
Toshihiro Shimizu |
890ddd |
if (level) {
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tframeid> fids;</tframeid>
|
|
Toshihiro Shimizu |
890ddd |
level->getFids(fids);
|
|
Toshihiro Shimizu |
890ddd |
invalidateIcons(level, fids);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
bool RGBPickerTool::onPropertyChanged(std::string propertyName)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (propertyName == m_pickType.getName())
|
|
Toshihiro Shimizu |
890ddd |
PickVectorType = toString(m_pickType.getValue());
|
|
Toshihiro Shimizu |
890ddd |
else if (propertyName == m_passivePick.getName())
|
|
Toshihiro Shimizu |
890ddd |
PickPassive = m_passivePick.getValue();
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RGBPickerTool::onActivate()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_firstTime) {
|
|
Toshihiro Shimizu |
890ddd |
m_pickType.setValue(toWideString((PickVectorType.getValue())));
|
|
Toshihiro Shimizu |
890ddd |
m_passivePick.setValue(PickPassive ? 1 : 0);
|
|
Toshihiro Shimizu |
890ddd |
m_firstTime = false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPropertyGroup *RGBPickerTool::getProperties(int targetType) { return &m_prop; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int RGBPickerTool::getCursorId() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int currentStyleId = getApplication()->getPaletteController()->getCurrentPalette()->getStyleIndex();
|
|
Toshihiro Shimizu |
890ddd |
if (currentStyleId == 0)
|
|
Toshihiro Shimizu |
890ddd |
return ToolCursor::ForbiddenCursor;
|
|
Toshihiro Shimizu |
890ddd |
if (ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg)
|
|
Toshihiro Shimizu |
890ddd |
return ToolCursor::PickerRGBWhite;
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
return ToolCursor::PickerRGB;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RGBPickerTool::doPolylinePick()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_stroke && m_pickType.getValue() == POLYLINE_PICK) {
|
|
Toshihiro Shimizu |
890ddd |
pickStroke();
|
|
Toshihiro Shimizu |
890ddd |
delete m_stroke;
|
|
Toshihiro Shimizu |
890ddd |
m_stroke = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
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 RGBPickerTool::startFreehand(const TPointD &drawingPos, const TPointD &workingPos)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_drawingTrack.clear();
|
|
Toshihiro Shimizu |
890ddd |
m_workingTrack.clear();
|
|
Toshihiro Shimizu |
890ddd |
m_firstDrawingPos = drawingPos;
|
|
Toshihiro Shimizu |
890ddd |
m_firstWorkingPos = workingPos;
|
|
Toshihiro Shimizu |
890ddd |
double pixelSize2 = getPixelSize() * getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
m_drawingTrack.add(TThickPoint(drawingPos, m_thick), pixelSize2);
|
|
Toshihiro Shimizu |
890ddd |
m_workingTrack.add(TThickPoint(workingPos, m_thick), pixelSize2);
|
|
Toshihiro Shimizu |
890ddd |
#if defined(MACOSX)
|
|
Toshihiro Shimizu |
890ddd |
//m_viewer->prepareForegroundDrawing();
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg ? TPixel32::White : TPixel32::Black;
|
|
Toshihiro Shimizu |
890ddd |
tglColor(color);
|
|
Toshihiro Shimizu |
890ddd |
getViewer()->startForegroundDrawing();
|
|
Toshihiro Shimizu |
890ddd |
glPushMatrix();
|
|
Toshihiro Shimizu |
890ddd |
m_drawingTrack.drawLastFragments();
|
|
Toshihiro Shimizu |
890ddd |
glPopMatrix();
|
|
Toshihiro Shimizu |
890ddd |
getViewer()->endForegroundDrawing();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
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 RGBPickerTool::freehandDrag(const TPointD &drawingPos, const TPointD &workingPos)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
#if defined(MACOSX)
|
|
Toshihiro Shimizu |
890ddd |
//getViewer()->enableRedraw(false);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
getViewer()->startForegroundDrawing();
|
|
Toshihiro Shimizu |
890ddd |
TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg ? TPixel32::White : TPixel32::Black;
|
|
Toshihiro Shimizu |
890ddd |
tglColor(color);
|
|
Toshihiro Shimizu |
890ddd |
glPushMatrix();
|
|
Toshihiro Shimizu |
890ddd |
tglMultMatrix(getMatrix());
|
|
Toshihiro Shimizu |
890ddd |
double pixelSize2 = getPixelSize() * getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
m_workingTrack.add(TThickPoint(workingPos, m_thick), pixelSize2);
|
|
Toshihiro Shimizu |
890ddd |
m_drawingTrack.add(TThickPoint(drawingPos, m_thick), pixelSize2);
|
|
Toshihiro Shimizu |
890ddd |
m_drawingTrack.drawLastFragments();
|
|
Toshihiro Shimizu |
890ddd |
glPopMatrix();
|
|
Toshihiro Shimizu |
890ddd |
getViewer()->endForegroundDrawing();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
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 RGBPickerTool::closeFreehand()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
#if defined(MACOSX)
|
|
Toshihiro Shimizu |
890ddd |
//getViewer()->enableRedraw(true);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
if (m_drawingTrack.isEmpty() || m_workingTrack.isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
double pixelSize2 = getPixelSize() * getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
m_drawingTrack.add(TThickPoint(m_firstDrawingPos, m_thick), pixelSize2);
|
|
Toshihiro Shimizu |
890ddd |
m_workingTrack.add(TThickPoint(m_firstWorkingPos, m_thick), pixelSize2);
|
|
Toshihiro Shimizu |
890ddd |
m_workingTrack.filterPoints();
|
|
Toshihiro Shimizu |
890ddd |
double error = (30.0 / 11) * sqrt(pixelSize2);
|
|
Toshihiro Shimizu |
890ddd |
m_stroke = m_workingTrack.makeStroke(error);
|
|
Toshihiro Shimizu |
890ddd |
m_stroke->setStyle(1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!Viene aggiunto un punto al vettore m_polyline.
|
|
Toshihiro Shimizu |
890ddd |
void RGBPickerTool::addPointPolyline(const TPointD &drawingPos, const TPointD &workingPos)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_mousePosition = drawingPos;
|
|
Toshihiro Shimizu |
890ddd |
/*---drawingPosは中心からの座標 workingPosは画面左下からの座標---*/
|
|
Toshihiro Shimizu |
890ddd |
m_drawingPolyline.push_back(drawingPos);
|
|
Toshihiro Shimizu |
890ddd |
m_workingPolyline.push_back(workingPos);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
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 RGBPickerTool::closePolyline(const TPointD &drawingPos, const TPointD &workingPos)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_drawingPolyline.size() <= 1 || m_workingPolyline.size() <= 1)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
if (m_drawingPolyline.back() != drawingPos)
|
|
Toshihiro Shimizu |
890ddd |
m_drawingPolyline.push_back(drawingPos);
|
|
Toshihiro Shimizu |
890ddd |
if (m_workingPolyline.back() != workingPos)
|
|
Toshihiro Shimizu |
890ddd |
m_workingPolyline.push_back(workingPos);
|
|
Toshihiro Shimizu |
890ddd |
if (m_drawingPolyline.back() != m_drawingPolyline.front())
|
|
Toshihiro Shimizu |
890ddd |
m_drawingPolyline.push_back(m_drawingPolyline.front());
|
|
Toshihiro Shimizu |
890ddd |
if (m_workingPolyline.back() != m_workingPolyline.front())
|
|
Toshihiro Shimizu |
890ddd |
m_workingPolyline.push_back(m_workingPolyline.front());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Flipbook上でPassive Pickを有効にする
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void RGBPickerTool::showFlipPickedColor(const TPixel32 &pix)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_passivePick.getValue()) {
|
|
Toshihiro Shimizu |
890ddd |
QColor col((int)pix.r, (int)pix.g, (int)pix.b);
|
|
Toshihiro Shimizu |
890ddd |
PaletteController *controller = TTool::getApplication()->getPaletteController();
|
|
Toshihiro Shimizu |
890ddd |
controller->notifyColorPassivePicked(col);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
RGBPickerTool RGBpicktool;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//TTool *getPickRGBMTool() {return &pickRBGMTool;}
|