|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Tnz6 includes
|
|
Toshihiro Shimizu |
890ddd |
#include "colormodelviewer.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "menubarcommandids.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "floatingpanelcommand.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tapp.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "pane.h"
|
|
shun-iwasawa |
dd780b |
#include "colormodelbehaviorpopup.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzTools includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/cursormanager.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/cursors.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/stylepicker.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/toolcommandids.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/tool.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/toolhandle.h"
|
|
shun_iwasawa |
06bcc2 |
#include "../tnztools/stylepickertool.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzQt includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/menubarcommand.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/viewcommandids.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/dvdialog.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/icongenerator.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/gutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/tselectionhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/styleselection.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzLib includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/palettecmd.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshlevelhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tpalettehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tframehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tscenehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheethandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcolumnhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzscene.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheet.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/palettecontroller.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshlevel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshsimplelevel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshcell.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tsystem.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ttoonzimage.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Qt includes
|
|
Toshihiro Shimizu |
890ddd |
#include <qmimedata></qmimedata>
|
|
Toshihiro Shimizu |
890ddd |
#include <qmouseevent></qmouseevent>
|
|
Toshihiro Shimizu |
890ddd |
#include <qurl></qurl>
|
|
Toshihiro Shimizu |
890ddd |
#include <qmenu></qmenu>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#define LINES "Lines"
|
|
Toshihiro Shimizu |
890ddd |
#define AREAS "Areas"
|
|
Toshihiro Shimizu |
890ddd |
#define ALL "Lines & Areas"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using namespace DVGui;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Shinya Kitaoka |
120a6e |
TPaletteHandle *getPaletteHandle() {
|
|
Shinya Kitaoka |
120a6e |
return TApp::instance()->getPaletteController()->getCurrentLevelPalette();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
/*! \class ColorModelViewer
|
|
Shinya Kitaoka |
120a6e |
\brief The ColorModelViewer class is a flip book used to manage
|
|
Shinya Kitaoka |
120a6e |
color model.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
Inherits \b FlipBook.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
This object show the reference image linked to current level
|
|
Shinya Kitaoka |
120a6e |
palette.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
/*! \fn void ColorModelViewer::resetImageViewer()
|
|
Shinya Kitaoka |
120a6e |
Set current level to TLevelP() and image to "0".
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
ColorModelViewer::ColorModelViewer(QWidget *parent)
|
|
Shinya Kitaoka |
120a6e |
: FlipBook(parent, QString(tr("Color Model")),
|
|
Shinya Kitaoka |
120a6e |
FlipConsole::cFullConsole &
|
|
Shinya Kitaoka |
120a6e |
(~(FlipConsole::eFilterRgbm | FlipConsole::cFilterGRgb |
|
|
Shinya Kitaoka |
120a6e |
FlipConsole::eRate | FlipConsole::eSound |
|
|
Shinya Kitaoka |
120a6e |
FlipConsole::eSaveImg | FlipConsole::eHisto |
|
|
Shinya Kitaoka |
120a6e |
FlipConsole::eCompare | FlipConsole::eCustomize |
|
|
Shinya Kitaoka |
120a6e |
FlipConsole::eSave | FlipConsole::eFilledRaster |
|
|
Shinya Kitaoka |
120a6e |
FlipConsole::eDefineLoadBox | FlipConsole::eUseLoadBox |
|
|
shun_iwasawa |
db5f54 |
FlipConsole::eDefineSubCamera | FlipConsole::eLocator)),
|
|
Shinya Kitaoka |
120a6e |
eDontKeepFilesOpened, true)
|
|
Shinya Kitaoka |
120a6e |
, m_mode(0)
|
|
Shinya Kitaoka |
120a6e |
, m_currentRefImgPath(TFilePath()) {
|
|
Shinya Kitaoka |
120a6e |
setObjectName("colormodel");
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
setToolCursor(m_imageViewer, ToolCursor::PickerCursor);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Do not call the special procedure for flipbook closures...
|
|
Shinya Kitaoka |
120a6e |
disconnect(parentWidget(), SIGNAL(closeButtonPressed()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onCloseButtonPressed()));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool ret = connect(this, SIGNAL(refImageNotFound()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onRefImageNotFound()), Qt::QueuedConnection);
|
|
Shinya Kitaoka |
120a6e |
assert(ret);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_imageViewer->setMouseTracking(true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ColorModelViewer::~ColorModelViewer() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Accept event if current palette is not empty, event data has urls and each
|
|
Shinya Kitaoka |
120a6e |
urls type are different from "src" and "tpl" .
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void ColorModelViewer::dragEnterEvent(QDragEnterEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = getPaletteHandle()->getPalette();
|
|
Shinya Kitaoka |
120a6e |
if (!palette) return;
|
|
Shinya Kitaoka |
120a6e |
const QMimeData *mimeData = event->mimeData();
|
|
Shinya Kitaoka |
120a6e |
if (!acceptResourceDrop(mimeData->urls())) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
dfe1cf |
for (const QUrl &url : mimeData->urls()) {
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp(url.toLocalFile().toStdWString());
|
|
Shinya Kitaoka |
120a6e |
std::string type = fp.getType();
|
|
Shinya Kitaoka |
120a6e |
if (type == "scr" || type == "tpl") return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
event->acceptProposedAction();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! If event data has urls, convert each urls in path and set view and current
|
|
Toshihiro Shimizu |
890ddd |
palette reference image (recall loadImage() and setLevel()).
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void ColorModelViewer::dropEvent(QDropEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
const QMimeData *mimeData = event->mimeData();
|
|
Shinya Kitaoka |
120a6e |
if (mimeData->hasUrls()) {
|
|
otakuto |
dfe1cf |
for (const QUrl &url : mimeData->urls()) {
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp(url.toLocalFile().toStdWString());
|
|
Shinya Kitaoka |
120a6e |
loadImage(fp);
|
|
Shinya Kitaoka |
120a6e |
setLevel(fp);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
event->acceptProposedAction();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Set current palette reference image to \b fp recall:
|
|
Shinya Kitaoka |
120a6e |
\b PaletteCmd::loadReferenceImage().
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
shun-iwasawa |
dd780b |
// This function will be called when drag & drop the file into the color model
|
|
shun-iwasawa |
dd780b |
// viewer
|
|
shun-iwasawa |
dd780b |
|
|
Shinya Kitaoka |
120a6e |
void ColorModelViewer::loadImage(const TFilePath &fp) {
|
|
Shinya Kitaoka |
120a6e |
if (fp.isEmpty()) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPaletteHandle *paletteHandle = getPaletteHandle();
|
|
shun-iwasawa |
dd780b |
TPalette *palette = paletteHandle->getPalette();
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
if (!palette || palette->isCleanupPalette()) {
|
|
shun-iwasawa |
dd780b |
DVGui::error(QObject::tr("Cannot load Color Model in current palette."));
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
shun-iwasawa |
dd780b |
}
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
PaletteCmd::ColorModelLoadingConfiguration config;
|
|
shun-iwasawa |
dd780b |
|
|
shun-iwasawa |
dd780b |
// if the palette is locked, replace the color model's palette with the
|
|
shun-iwasawa |
dd780b |
// destination
|
|
shun-iwasawa |
dd780b |
if (palette->isLocked()) {
|
|
shun-iwasawa |
dd780b |
// do nothing as config will use behavior = ReplaceColorModelPlt by default
|
|
shun-iwasawa |
dd780b |
// config.behavior = PaletteCmd::ReplaceColorModelPlt;
|
|
shun-iwasawa |
dd780b |
} else {
|
|
shun-iwasawa |
dd780b |
std::set<tfilepath> fpSet;</tfilepath>
|
|
shun-iwasawa |
dd780b |
fpSet.insert(fp);
|
|
shun-iwasawa |
dd780b |
ColorModelBehaviorPopup popup(fpSet, 0);
|
|
shun-iwasawa |
dd780b |
int ret = popup.exec();
|
|
shun-iwasawa |
dd780b |
if (ret == QDialog::Rejected) return;
|
|
shun-iwasawa |
dd780b |
popup.getLoadingConfiguration(config);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
dd780b |
int isLoaded =
|
|
shun-iwasawa |
dd780b |
PaletteCmd::loadReferenceImage(paletteHandle, config, fp, scene);
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
dd780b |
if (0 != isLoaded) {
|
|
shun-iwasawa |
dd780b |
std::cout << "loadReferenceImage Failed for some reason." << std::endl;
|
|
shun-iwasawa |
dd780b |
return;
|
|
shun-iwasawa |
dd780b |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
dd780b |
// no changes in the icon with replace (Keep the destination palette) option
|
|
shun-iwasawa |
dd780b |
if (config.behavior != PaletteCmd::ReplaceColorModelPlt) {
|
|
shun-iwasawa |
dd780b |
TXshLevel *level = TApp::instance()->getCurrentLevel()->getLevel();
|
|
shun-iwasawa |
dd780b |
if (!level) return;
|
|
shun-iwasawa |
dd780b |
std::vector<tframeid> fids;</tframeid>
|
|
shun-iwasawa |
dd780b |
level->getFids(fids);
|
|
shun-iwasawa |
dd780b |
invalidateIcons(level, fids);
|
|
shun-iwasawa |
dd780b |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Create and open the Right-click menu color model viewer.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void ColorModelViewer::contextMenuEvent(QContextMenuEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
/*-- Levelが取得できない場合はMenuを出さない --*/
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TXshLevel *xl = app->getCurrentLevel()->getLevel();
|
|
Shinya Kitaoka |
120a6e |
if (!xl) return;
|
|
Shinya Kitaoka |
120a6e |
TXshSimpleLevel *sl = xl->getSimpleLevel();
|
|
Shinya Kitaoka |
120a6e |
if (!sl) return;
|
|
Shinya Kitaoka |
120a6e |
TPalette *currentPalette =
|
|
Shinya Kitaoka |
120a6e |
app->getPaletteController()->getCurrentLevelPalette()->getPalette();
|
|
Shinya Kitaoka |
120a6e |
if (!currentPalette) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QMenu menu(this);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
menu.addAction(CommandManager::instance()->getAction(MI_LoadColorModel));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QAction *loadCurrentFrame =
|
|
Shinya Kitaoka |
120a6e |
new QAction(QString(tr("Use Current Frame")), this);
|
|
Shinya Kitaoka |
120a6e |
connect(loadCurrentFrame, SIGNAL(triggered()), SLOT(loadCurrentFrame()));
|
|
Shinya Kitaoka |
120a6e |
menu.addAction(loadCurrentFrame);
|
|
Shinya Kitaoka |
120a6e |
|
|
shun_iwasawa |
9cbd0e |
if (!m_imageViewer->getImage()) {
|
|
shun_iwasawa |
9cbd0e |
menu.exec(event->globalPos());
|
|
shun_iwasawa |
9cbd0e |
return;
|
|
shun_iwasawa |
9cbd0e |
}
|
|
shun_iwasawa |
9cbd0e |
|
|
Shinya Kitaoka |
120a6e |
QAction *removeColorModel =
|
|
Shinya Kitaoka |
120a6e |
new QAction(QString(tr("Remove Color Model")), this);
|
|
Shinya Kitaoka |
120a6e |
connect(removeColorModel, SIGNAL(triggered()), SLOT(removeColorModel()));
|
|
Shinya Kitaoka |
120a6e |
menu.addAction(removeColorModel);
|
|
Shinya Kitaoka |
120a6e |
|
|
shun_iwasawa |
9cbd0e |
/* If there is at least one style with "picked pos" parameter, then enable
|
|
shun_iwasawa |
9cbd0e |
* repick command */
|
|
shun_iwasawa |
9cbd0e |
TRasterImageP ri = m_imageViewer->getImage();
|
|
shun_iwasawa |
9cbd0e |
if (ri && currentPalette->hasPickedPosStyle()) {
|
|
shun_iwasawa |
9cbd0e |
menu.addSeparator();
|
|
shun_iwasawa |
9cbd0e |
QAction *repickFromColorModelAct = new QAction(
|
|
shun_iwasawa |
9cbd0e |
QString(tr("Update Colors by Using Picked Positions")), this);
|
|
shun_iwasawa |
9cbd0e |
connect(repickFromColorModelAct, SIGNAL(triggered()),
|
|
shun_iwasawa |
9cbd0e |
SLOT(repickFromColorModel()));
|
|
shun_iwasawa |
9cbd0e |
menu.addAction(repickFromColorModelAct);
|
|
shun_iwasawa |
9cbd0e |
}
|
|
shun_iwasawa |
9cbd0e |
|
|
Shinya Kitaoka |
120a6e |
menu.addSeparator();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QString shortcut = QString::fromStdString(
|
|
Shinya Kitaoka |
120a6e |
CommandManager::instance()->getShortcutFromId(V_ZoomReset));
|
|
Shinya Kitaoka |
120a6e |
QAction *reset = menu.addAction(tr("Reset View") + "\t " + shortcut);
|
|
Shinya Kitaoka |
120a6e |
connect(reset, SIGNAL(triggered()), m_imageViewer, SLOT(resetView()));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
shortcut = QString::fromStdString(
|
|
Shinya Kitaoka |
120a6e |
CommandManager::instance()->getShortcutFromId(V_ZoomFit));
|
|
Shinya Kitaoka |
120a6e |
QAction *fit = menu.addAction(tr("Fit to Window") + "\t" + shortcut);
|
|
Shinya Kitaoka |
120a6e |
connect(fit, SIGNAL(triggered()), m_imageViewer, SLOT(fitView()));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
menu.exec(event->globalPos());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! If left button is pressed recall \b pick() in event pos.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void ColorModelViewer::mousePressEvent(QMouseEvent *event) {
|
|
shun-iwasawa |
28ac2a |
if (event->button() == Qt::LeftButton) pick(event->pos() * getDevPixRatio());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! If left button is moved recall \b pick() in event pos.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void ColorModelViewer::mouseMoveEvent(QMouseEvent *event) {
|
|
shun-iwasawa |
28ac2a |
if (event->buttons() & Qt::LeftButton) pick(event->pos() * getDevPixRatio());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Pick color from image and set it as current style.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void ColorModelViewer::pick(const QPoint &p) {
|
|
Shinya Kitaoka |
120a6e |
TImageP img = m_imageViewer->getImage();
|
|
Shinya Kitaoka |
120a6e |
if (!img) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPaletteHandle *ph =
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getPaletteController()->getCurrentLevelPalette();
|
|
Shinya Kitaoka |
120a6e |
TPalette *currentPalette = ph->getPalette();
|
|
Shinya Kitaoka |
120a6e |
if (!currentPalette) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*- 画面外ではPickできない -*/
|
|
Shinya Kitaoka |
120a6e |
if (!m_imageViewer->rect().contains(p)) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
StylePicker picker(img, currentPalette);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QPoint viewP = m_imageViewer->mapFrom(this, p);
|
|
Shinya Kitaoka |
120a6e |
TPointD pos = m_imageViewer->getViewAff().inv() *
|
|
Shinya Kitaoka |
120a6e |
TPointD(viewP.x() - m_imageViewer->width() / 2,
|
|
Shinya Kitaoka |
120a6e |
-viewP.y() + m_imageViewer->height() / 2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*---
|
|
Shinya Kitaoka |
120a6e |
カレントToolに合わせてPickモードを変更
|
|
Shinya Kitaoka |
120a6e |
0=Area, 1=Line, 2=Line&Areas(default)
|
|
Shinya Kitaoka |
120a6e |
---*/
|
|
Shinya Kitaoka |
120a6e |
int styleIndex = picker.pickStyleId(pos, 1, m_mode);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (styleIndex < 0) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*-- pickLineモードのとき、取得Styleが0の場合 /
|
|
Shinya Kitaoka |
120a6e |
* PurePaintの部分をクリックした場合 はカレントStyleを変えない --*/
|
|
Shinya Kitaoka |
120a6e |
if (m_mode == 1) {
|
|
Shinya Kitaoka |
120a6e |
if (styleIndex == 0) return;
|
|
Shinya Kitaoka |
120a6e |
TToonzImageP ti = img;
|
|
Shinya Kitaoka |
120a6e |
if (ti && picker.pickTone(pos) == 255) return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
/*- Paletteに存在しない色が取れた場合はreturn -*/
|
|
Shinya Kitaoka |
120a6e |
TPalette::Page *page = currentPalette->getStylePage(styleIndex);
|
|
Shinya Kitaoka |
120a6e |
if (!page) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*-- Styleを選択している場合は選択を解除する --*/
|
|
Shinya Kitaoka |
120a6e |
TSelection *selection =
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentSelection()->getSelection();
|
|
Shinya Kitaoka |
120a6e |
if (selection) {
|
|
Shinya Kitaoka |
120a6e |
TStyleSelection *styleSelection =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<tstyleselection *="">(selection);</tstyleselection>
|
|
Shinya Kitaoka |
120a6e |
if (styleSelection) styleSelection->selectNone();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
shun_iwasawa |
e897af |
/*
|
|
shun_iwasawa |
48c671 |
if the Style Picker tool is current and "organize palette" is activated,
|
|
shun_iwasawa |
e897af |
then move the picked style to the first page of the palette.
|
|
shun_iwasawa |
06bcc2 |
*/
|
|
shun_iwasawa |
48c671 |
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
|
|
shun_iwasawa |
e897af |
if (tool->getName() == "T_StylePicker") {
|
|
shun_iwasawa |
e897af |
StylePickerTool *spTool = dynamic_cast<stylepickertool *="">(tool);</stylepickertool>
|
|
shun_iwasawa |
e897af |
if (spTool && spTool->isOrganizePaletteActive()) {
|
|
shun_iwasawa |
e897af |
TPoint point = picker.getRasterPoint(pos);
|
|
shun-iwasawa |
dd780b |
int frame = m_flipConsole->getCurrentFrame() - 1;
|
|
shun-iwasawa |
dd780b |
PaletteCmd::organizePaletteStyle(
|
|
shun-iwasawa |
dd780b |
ph, styleIndex, TColorStyle::PickedPosition(point, frame));
|
|
shun_iwasawa |
48c671 |
}
|
|
shun_iwasawa |
48c671 |
}
|
|
shun_iwasawa |
06bcc2 |
|
|
Shinya Kitaoka |
120a6e |
ph->setStyleIndex(styleIndex);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorModelViewer::hideEvent(QHideEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
TPaletteHandle *paletteHandle = getPaletteHandle();
|
|
Shinya Kitaoka |
120a6e |
TXshLevelHandle *levelHandle = TApp::instance()->getCurrentLevel();
|
|
Shinya Kitaoka |
120a6e |
ToolHandle *toolHandle = TApp::instance()->getCurrentTool();
|
|
Shinya Kitaoka |
120a6e |
disconnect(paletteHandle, SIGNAL(paletteSwitched()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(showCurrentImage()));
|
|
Shinya Kitaoka |
120a6e |
disconnect(paletteHandle, SIGNAL(paletteChanged()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(showCurrentImage()));
|
|
shun_iwasawa |
e553fc |
disconnect(paletteHandle, SIGNAL(colorStyleChanged(bool)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(showCurrentImage()));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
disconnect(toolHandle, SIGNAL(toolSwitched()), this, SLOT(changePickType()));
|
|
Shinya Kitaoka |
120a6e |
disconnect(toolHandle, SIGNAL(toolChanged()), this, SLOT(changePickType()));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
disconnect(levelHandle, SIGNAL(xshLevelViewChanged()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(updateViewer()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorModelViewer::showEvent(QShowEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
TPaletteHandle *paletteHandle = getPaletteHandle();
|
|
Shinya Kitaoka |
120a6e |
TXshLevelHandle *levelHandle = TApp::instance()->getCurrentLevel();
|
|
Shinya Kitaoka |
120a6e |
ToolHandle *toolHandle = TApp::instance()->getCurrentTool();
|
|
Shinya Kitaoka |
120a6e |
bool ret = connect(paletteHandle, SIGNAL(paletteSwitched()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(showCurrentImage()));
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(paletteHandle, SIGNAL(paletteChanged()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(showCurrentImage()));
|
|
shun_iwasawa |
e553fc |
ret = ret && connect(paletteHandle, SIGNAL(colorStyleChanged(bool)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(showCurrentImage()));
|
|
Shinya Kitaoka |
120a6e |
/*- ツールのTypeに合わせてPickのタイプも変え、カーソルも切り替える -*/
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(toolHandle, SIGNAL(toolSwitched()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(changePickType()));
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(toolHandle, SIGNAL(toolChanged()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(changePickType()));
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(levelHandle, SIGNAL(xshLevelViewChanged()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(updateViewer()));
|
|
Shinya Kitaoka |
120a6e |
assert(ret);
|
|
Shinya Kitaoka |
120a6e |
changePickType();
|
|
Shinya Kitaoka |
120a6e |
showCurrentImage();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*- ツールのTypeに合わせてPickのタイプも変え、カーソルも切り替える -*/
|
|
Shinya Kitaoka |
120a6e |
void ColorModelViewer::changePickType() {
|
|
shun_iwasawa |
06bcc2 |
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
|
|
shun_iwasawa |
06bcc2 |
if (tool->getName() == T_StylePicker) {
|
|
shun_iwasawa |
e897af |
StylePickerTool *stylePickerTool = dynamic_cast<stylepickertool *="">(tool);</stylepickertool>
|
|
shun_iwasawa |
06bcc2 |
if (stylePickerTool->isOrganizePaletteActive()) {
|
|
shun_iwasawa |
06bcc2 |
setToolCursor(m_imageViewer, ToolCursor::PickerCursorOrganize);
|
|
shun_iwasawa |
06bcc2 |
return;
|
|
shun_iwasawa |
06bcc2 |
}
|
|
shun_iwasawa |
06bcc2 |
}
|
|
shun_iwasawa |
06bcc2 |
|
|
shun_iwasawa |
06bcc2 |
TPropertyGroup *propGroup = tool->getProperties(0);
|
|
Shinya Kitaoka |
120a6e |
/*- Propertyの無いツールの場合 -*/
|
|
Shinya Kitaoka |
120a6e |
if (!propGroup) {
|
|
Shinya Kitaoka |
120a6e |
m_mode = 2;
|
|
Shinya Kitaoka |
120a6e |
setToolCursor(m_imageViewer, ToolCursor::PickerCursor);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*- Mode: の無いツールの場合は0が返る -*/
|
|
Shinya Kitaoka |
120a6e |
TProperty *modeProp = propGroup->getProperty("Mode:");
|
|
Shinya Kitaoka |
120a6e |
if (!modeProp) {
|
|
Shinya Kitaoka |
120a6e |
m_mode = 2;
|
|
Shinya Kitaoka |
120a6e |
setToolCursor(m_imageViewer, ToolCursor::PickerCursor);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
std::string var = modeProp->getValueAsString();
|
|
Shinya Kitaoka |
120a6e |
if (var == LINES) {
|
|
Shinya Kitaoka |
120a6e |
m_mode = 1;
|
|
Shinya Kitaoka |
120a6e |
setToolCursor(m_imageViewer, ToolCursor::PickerCursorLine);
|
|
Shinya Kitaoka |
120a6e |
} else if (var == AREAS) {
|
|
Shinya Kitaoka |
120a6e |
m_mode = 0;
|
|
Shinya Kitaoka |
120a6e |
setToolCursor(m_imageViewer, ToolCursor::PickerCursorArea);
|
|
Shinya Kitaoka |
120a6e |
} else // Line & Areas
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
m_mode = 2;
|
|
Shinya Kitaoka |
120a6e |
setToolCursor(m_imageViewer, ToolCursor::PickerCursor);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! If current palette level exists reset image viewer and set current viewer
|
|
Toshihiro Shimizu |
890ddd |
to refences image path level.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorModelViewer::updateViewer() { getImageViewer()->repaint(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorModelViewer::showCurrentImage() {
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = getPaletteHandle()->getPalette();
|
|
Shinya Kitaoka |
120a6e |
if (!palette) {
|
|
Shinya Kitaoka |
120a6e |
resetImageViewer();
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TXshLevel *xl = app->getCurrentLevel()->getLevel();
|
|
Shinya Kitaoka |
120a6e |
if (!xl) {
|
|
Shinya Kitaoka |
120a6e |
resetImageViewer();
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
/*-- UseCurrentFrameの場合、paletteを差し替える --*/
|
|
Shinya Kitaoka |
120a6e |
if (palette->getRefImgPath() == xl->getPath()) {
|
|
Shinya Kitaoka |
120a6e |
TXshSimpleLevel *sl = xl->getSimpleLevel();
|
|
Shinya Kitaoka |
120a6e |
if (!sl) {
|
|
Shinya Kitaoka |
120a6e |
resetImageViewer();
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
/*- 同じTFrameIdだった場合、パレットを差し替える -*/
|
|
Shinya Kitaoka |
120a6e |
if (m_currentRefImgPath == xl->getPath()) {
|
|
Shinya Kitaoka |
120a6e |
TImageP refImg = m_imageViewer->getImage();
|
|
Shinya Kitaoka |
120a6e |
if (!refImg) {
|
|
Shinya Kitaoka |
120a6e |
resetImageViewer();
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TImageP refImg_clone = refImg->cloneImage();
|
|
Shinya Kitaoka |
120a6e |
refImg_clone->setPalette(palette);
|
|
Shinya Kitaoka |
120a6e |
m_imageViewer->setImage(refImg_clone);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
/*- UseCurrentFrameのLevelに移動してきた場合、Levelを入れ直す -*/
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
reloadCurrentFrame();
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*- 以下、通常のColorModelが読み込まれている場合 -*/
|
|
Shinya Kitaoka |
120a6e |
resetImageViewer();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp = scene->decodeFilePath(palette->getRefImgPath());
|
|
Shinya Kitaoka |
120a6e |
if (TSystem::doesExistFileOrLevel(fp)) {
|
|
Shinya Kitaoka |
120a6e |
setLevel(fp, palette);
|
|
Shinya Kitaoka |
120a6e |
} else if (!fp.isEmpty())
|
|
Shinya Kitaoka |
120a6e |
emit refImageNotFound();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Clone current image and set it in viewer.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void ColorModelViewer::loadCurrentFrame() {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TXshLevel *xl = app->getCurrentLevel()->getLevel();
|
|
Shinya Kitaoka |
120a6e |
if (!xl) return;
|
|
Shinya Kitaoka |
120a6e |
TXshSimpleLevel *sl = xl->getSimpleLevel();
|
|
Shinya Kitaoka |
120a6e |
if (!sl) return;
|
|
Shinya Kitaoka |
120a6e |
/*- カレントフレームのFIdの取得 -*/
|
|
Shinya Kitaoka |
120a6e |
TFrameId fid;
|
|
Shinya Kitaoka |
120a6e |
if (app->getCurrentFrame()->isEditingLevel())
|
|
Shinya Kitaoka |
120a6e |
fid = app->getCurrentFrame()->getFid();
|
|
Shinya Kitaoka |
120a6e |
else if (app->getCurrentFrame()->isEditingScene()) {
|
|
Shinya Kitaoka |
120a6e |
int columnIndex = app->getCurrentColumn()->getColumnIndex();
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
if (!xsh) return;
|
|
Shinya Kitaoka |
120a6e |
TXshColumn *column = xsh->getColumn(columnIndex);
|
|
Shinya Kitaoka |
120a6e |
if (!column) return;
|
|
Shinya Kitaoka |
120a6e |
int frame = app->getCurrentFrame()->getFrame();
|
|
Shinya Kitaoka |
120a6e |
fid = column->getCellColumn()->getCell(frame).getFrameId();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
TImageP img = sl->getFrame(fid, true);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPalette *currentPalette =
|
|
Shinya Kitaoka |
120a6e |
app->getPaletteController()->getCurrentLevelPalette()->getPalette();
|
|
Shinya Kitaoka |
120a6e |
if (!img || !currentPalette) return;
|
|
Shinya Kitaoka |
120a6e |
TImageP refImg = img->cloneImage();
|
|
Shinya Kitaoka |
120a6e |
currentPalette->setRefImg(TImageP());
|
|
Shinya Kitaoka |
120a6e |
/*--onPaletteSwitchedでRefImagePathを見て、自分自身のパスを参照していたらUpdateのルーチンを切り替える--*/
|
|
Shinya Kitaoka |
120a6e |
currentPalette->setRefImgPath(xl->getPath());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
std::vector<tframeid> fids;</tframeid>
|
|
Shinya Kitaoka |
120a6e |
fids.push_back(fid);
|
|
Shinya Kitaoka |
120a6e |
currentPalette->setRefLevelFids(fids);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_currentRefImgPath = xl->getPath();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_levels.clear();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_levelNames.clear();
|
|
Shinya Kitaoka |
120a6e |
m_framesCount = 1;
|
|
Shinya Kitaoka |
120a6e |
m_palette = 0;
|
|
Shinya Kitaoka |
120a6e |
m_lr = TLevelReaderP();
|
|
Shinya Kitaoka |
120a6e |
m_dim = TDimension(0, 0);
|
|
Shinya Kitaoka |
120a6e |
m_loadbox = TRect();
|
|
Shinya Kitaoka |
120a6e |
m_loadboxes.clear();
|
|
Shinya Kitaoka |
120a6e |
m_flipConsole->enableProgressBar(false);
|
|
Shinya Kitaoka |
120a6e |
m_flipConsole->setProgressBarStatus(0);
|
|
Shinya Kitaoka |
120a6e |
m_flipConsole->setFrameRange(1, 1, 1);
|
|
Shinya Kitaoka |
120a6e |
m_title1 = m_viewerTitle + " :: " +
|
|
Shinya Kitaoka |
120a6e |
m_currentRefImgPath.withoutParentDir().withFrame(fid);
|
|
Shinya Kitaoka |
120a6e |
m_title = " :: <use current="" frame="">";</use>
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_imageViewer->setImage(refImg);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
/*--
|
|
Shinya Kitaoka |
120a6e |
* UseCurrentFrameのLevelに移動してきたときに、改めてCurrentFrameを格納しなおす
|
|
Shinya Kitaoka |
120a6e |
* --*/
|
|
Shinya Kitaoka |
120a6e |
void ColorModelViewer::reloadCurrentFrame() {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TXshLevel *xl = app->getCurrentLevel()->getLevel();
|
|
Shinya Kitaoka |
120a6e |
if (!xl) return;
|
|
Shinya Kitaoka |
120a6e |
TXshSimpleLevel *sl = xl->getSimpleLevel();
|
|
Shinya Kitaoka |
120a6e |
if (!sl) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPalette *currentPalette =
|
|
Shinya Kitaoka |
120a6e |
app->getPaletteController()->getCurrentLevelPalette()->getPalette();
|
|
Shinya Kitaoka |
120a6e |
if (!currentPalette) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
std::vector<tframeid> fids = currentPalette->getRefLevelFids();</tframeid>
|
|
Shinya Kitaoka |
120a6e |
/*- CurrentFrameなので、1Frameのみのはず -*/
|
|
Shinya Kitaoka |
120a6e |
if (fids.size() != 1) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TImageP img = sl->getFrame(fids[0], true);
|
|
Shinya Kitaoka |
120a6e |
if (!img) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TImageP refImg = img->cloneImage();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
currentPalette->setRefImg(TImageP());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
currentPalette->setRefImgPath(xl->getPath());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*- currentRefImgPathの更新 -*/
|
|
Shinya Kitaoka |
120a6e |
m_currentRefImgPath = xl->getPath();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_levels.clear();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_levelNames.clear();
|
|
Shinya Kitaoka |
120a6e |
m_framesCount = 1;
|
|
Shinya Kitaoka |
120a6e |
m_palette = 0;
|
|
Shinya Kitaoka |
120a6e |
m_lr = TLevelReaderP();
|
|
Shinya Kitaoka |
120a6e |
m_dim = TDimension(0, 0);
|
|
Shinya Kitaoka |
120a6e |
m_loadbox = TRect();
|
|
Shinya Kitaoka |
120a6e |
m_loadboxes.clear();
|
|
Shinya Kitaoka |
120a6e |
m_flipConsole->enableProgressBar(false);
|
|
Shinya Kitaoka |
120a6e |
m_flipConsole->setProgressBarStatus(0);
|
|
Shinya Kitaoka |
120a6e |
m_flipConsole->setFrameRange(1, 1, 1);
|
|
Shinya Kitaoka |
120a6e |
m_title1 = m_viewerTitle + " :: " +
|
|
Shinya Kitaoka |
120a6e |
m_currentRefImgPath.withoutParentDir().withFrame(fids[0]);
|
|
Shinya Kitaoka |
120a6e |
m_title = " :: <use current="" frame="">";</use>
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_imageViewer->setImage(refImg);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Remove reference image from current palette using
|
|
Shinya Kitaoka |
120a6e |
\b PaletteCmd::removeReferenceImage() and reset image viewer.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void ColorModelViewer::removeColorModel() {
|
|
Shinya Kitaoka |
120a6e |
PaletteCmd::removeReferenceImage(getPaletteHandle());
|
|
Shinya Kitaoka |
120a6e |
resetImageViewer();
|
|
Shinya Kitaoka |
120a6e |
m_currentRefImgPath = TFilePath();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorModelViewer::onRefImageNotFound() {
|
|
Shinya Kitaoka |
120a6e |
DVGui::info(
|
|
Shinya Kitaoka |
120a6e |
tr("It is not possible to retrieve the color model set for the current "
|
|
Shinya Kitaoka |
120a6e |
"level."));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun_iwasawa |
9cbd0e |
//-----------------------------------------------------------------------------
|
|
shun_iwasawa |
9cbd0e |
|
|
shun_iwasawa |
9cbd0e |
void ColorModelViewer::repickFromColorModel() {
|
|
shun_iwasawa |
9cbd0e |
TImageP img = m_imageViewer->getImage();
|
|
shun_iwasawa |
9cbd0e |
if (!img) return;
|
|
shun_iwasawa |
9cbd0e |
TPaletteHandle *ph =
|
|
shun_iwasawa |
9cbd0e |
TApp::instance()->getPaletteController()->getCurrentLevelPalette();
|
|
shun_iwasawa |
9cbd0e |
|
|
shun-iwasawa |
dd780b |
PaletteCmd::pickColorByUsingPickedPosition(
|
|
shun-iwasawa |
dd780b |
ph, img, m_flipConsole->getCurrentFrame() - 1);
|
|
shun_iwasawa |
9cbd0e |
}
|
|
shun_iwasawa |
9cbd0e |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
OpenFloatingPanel openColorModelCommand(MI_OpenColorModel, "ColorModel",
|
|
Shinya Kitaoka |
120a6e |
QObject::tr("Color Model"));
|