|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/tool.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzTools includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/toolcommandids.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/toolhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/cursors.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/tooloptions.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzQt includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/icongenerator.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzLib includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/menubarcommand.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshsimplelevel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshleveltypes.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/levelproperties.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzscene.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/sceneproperties.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/preferences.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tscenehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheethandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tframehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcolumnhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tobjecthandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tpalettehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshlevelhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshcell.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tstageobject.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tstageobjectspline.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tstageobjecttree.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/dpiscale.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/palettecontroller.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tvectorimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "timagecache.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstroke.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tcolorstyles.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ttoonzimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trasterimage.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Local namespace
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Global variables
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
typedef std::pair<std::string, ttool::tooltargettype=""> ToolKey;</std::string,>
|
|
Toshihiro Shimizu |
890ddd |
typedef std::map<toolkey, *="" ttool=""> ToolTable;</toolkey,>
|
|
Toshihiro Shimizu |
890ddd |
ToolTable *toolTable = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::set<std::string> *toolNames = 0;</std::string>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Local classes
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
struct DummyTool final : public TTool {
|
|
Shinya Kitaoka |
473e70 |
ToolType getToolType() const override {
|
|
Shinya Kitaoka |
120a6e |
return TTool::LevelReadTool;
|
|
Shinya Kitaoka |
120a6e |
} // Test level type
|
|
Shinya Kitaoka |
120a6e |
ToolTargetType getTargetType() const {
|
|
Shinya Kitaoka |
120a6e |
return TTool::NoTarget;
|
|
Shinya Kitaoka |
120a6e |
} // Works on nothing
|
|
Shinya Kitaoka |
473e70 |
int getCursorId() const override {
|
|
Shinya Kitaoka |
120a6e |
return ToolCursor::ForbiddenCursor;
|
|
Shinya Kitaoka |
120a6e |
} // Forbids everything
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
DummyTool() : TTool("T_Dummy") {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} theDummyTool;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class ToolSelector {
|
|
Shinya Kitaoka |
120a6e |
std::string m_toolName;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
ToolSelector(std::string toolName) : m_toolName(toolName) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void selectTool() {
|
|
Shinya Kitaoka |
120a6e |
TTool::Application *app = TTool::getApplication();
|
|
Shinya Kitaoka |
120a6e |
if (app) app->getCurrentTool()->setTool(QString::fromStdString(m_toolName));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Local functions
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFrameId getNewFrameId(TXshSimpleLevel *sl, int row) {
|
|
Shinya Kitaoka |
120a6e |
TFrameId fid(row + 1);
|
|
Shinya Kitaoka |
120a6e |
if (sl->isFid(fid)) {
|
|
Shinya Kitaoka |
120a6e |
fid = TFrameId(fid.getNumber(), 'a');
|
|
Shinya Kitaoka |
120a6e |
while (fid.getLetter() < 'z' && sl->isFid(fid))
|
|
Shinya Kitaoka |
120a6e |
fid = TFrameId(fid.getNumber(), fid.getLetter() + 1);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return fid;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TTool static members
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TTool::Application *TTool::m_application = 0;
|
|
Toshihiro Shimizu |
890ddd |
std::set<tframeid> TTool::m_selectedFrames = std::set<tframeid>();</tframeid></tframeid>
|
|
Shinya Kitaoka |
120a6e |
bool TTool::m_isLevelCreated = false;
|
|
Shinya Kitaoka |
120a6e |
bool TTool::m_isFrameCreated = false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// m_cellsData
|
|
Toshihiro Shimizu |
890ddd |
// brutto brutto. fix quick & dirty del baco #6213 (undo con animation sheet)
|
|
Toshihiro Shimizu |
890ddd |
// bisogna ripensare la logica degli undo e del touchImage
|
|
Toshihiro Shimizu |
890ddd |
// m_cellsData viene inizializzato nel touchImage() in modalita' animation sheet
|
|
Shinya Kitaoka |
120a6e |
// contiene una o due terne che rappresentano range di celle (dell'xsheet)
|
|
Shinya Kitaoka |
120a6e |
// modificate dall'inserimento
|
|
Toshihiro Shimizu |
890ddd |
// di un nuovo frame: [r0,r1,type].
|
|
Toshihiro Shimizu |
890ddd |
// type = 0 : vecchio (cella[r0-1]) => nuovo
|
|
Toshihiro Shimizu |
890ddd |
// type = 1 : vuoto => vecchio (cella[r0-1])
|
|
Toshihiro Shimizu |
890ddd |
// type = 2 : vuoto => nuovo
|
|
Shinya Kitaoka |
120a6e |
// cfr. il codice di TTool::touchImage()
|
|
Shinya Kitaoka |
120a6e |
// ToolUtils::TToolUndo::removeLevelAndFrameIfNeeded()
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::vector<int> TTool::m_cellsData;</int>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TTool implementation
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
TTool::TTool(std::string name)
|
|
Shinya Kitaoka |
120a6e |
: m_name(name)
|
|
Shinya Kitaoka |
120a6e |
, m_viewer(0)
|
|
Shinya Kitaoka |
120a6e |
, m_targetType(NoTarget)
|
|
Shinya Kitaoka |
120a6e |
, m_enabled(true)
|
|
Shinya Kitaoka |
120a6e |
, m_active(false)
|
|
Shinya Kitaoka |
120a6e |
, m_picking(false) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TTool *TTool::getTool(std::string toolName, ToolTargetType targetType) {
|
|
Shinya Kitaoka |
120a6e |
if (!toolTable) return 0;
|
|
Shinya Kitaoka |
120a6e |
ToolTable::iterator it =
|
|
Shinya Kitaoka |
120a6e |
toolTable->find(std::make_pair(toolName, targetType));
|
|
Shinya Kitaoka |
120a6e |
if (it == toolTable->end()) return 0;
|
|
Shinya Kitaoka |
120a6e |
return it->second;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TTool::bind(int targetType) {
|
|
Shinya Kitaoka |
120a6e |
m_targetType = targetType;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!toolTable) toolTable = new ToolTable();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!toolNames) toolNames = new std::set<std::string>();</std::string>
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
std::string name = getName();
|
|
Shinya Kitaoka |
120a6e |
if (toolNames->count(name) == 0) {
|
|
Shinya Kitaoka |
120a6e |
toolNames->insert(name);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Initialize with the dummy tool
|
|
Shinya Kitaoka |
120a6e |
toolTable->insert(
|
|
Shinya Kitaoka |
120a6e |
std::make_pair(std::make_pair(name, ToonzImage), &theDummyTool));
|
|
Shinya Kitaoka |
120a6e |
toolTable->insert(
|
|
Shinya Kitaoka |
120a6e |
std::make_pair(std::make_pair(name, VectorImage), &theDummyTool));
|
|
Shinya Kitaoka |
120a6e |
toolTable->insert(
|
|
Shinya Kitaoka |
120a6e |
std::make_pair(std::make_pair(name, RasterImage), &theDummyTool));
|
|
Shinya Kitaoka |
120a6e |
toolTable->insert(
|
|
Shinya Kitaoka |
120a6e |
std::make_pair(std::make_pair(name, MeshImage), &theDummyTool));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ToolSelector *toolSelector = new ToolSelector(name);
|
|
Shinya Kitaoka |
120a6e |
CommandManager::instance()->setHandler(
|
|
Shinya Kitaoka |
120a6e |
name.c_str(), new CommandHandlerHelper<toolselector>(</toolselector>
|
|
Shinya Kitaoka |
120a6e |
toolSelector, &ToolSelector::selectTool));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (targetType & ToonzImage)
|
|
Shinya Kitaoka |
120a6e |
(*toolTable)[std::make_pair(name, ToonzImage)] = this;
|
|
Shinya Kitaoka |
120a6e |
if (targetType & VectorImage)
|
|
Shinya Kitaoka |
120a6e |
(*toolTable)[std::make_pair(name, VectorImage)] = this;
|
|
Shinya Kitaoka |
120a6e |
if (targetType & RasterImage)
|
|
Shinya Kitaoka |
120a6e |
(*toolTable)[std::make_pair(name, RasterImage)] = this;
|
|
Shinya Kitaoka |
120a6e |
if (targetType & MeshImage)
|
|
Shinya Kitaoka |
120a6e |
(*toolTable)[std::make_pair(name, MeshImage)] = this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ToolOptionsBox *TTool::createOptionsBox() {
|
|
Shinya Kitaoka |
120a6e |
TPaletteHandle *currPalette =
|
|
Shinya Kitaoka |
120a6e |
m_application->getPaletteController()->getCurrentLevelPalette();
|
|
Shinya Kitaoka |
120a6e |
ToolHandle *currTool = m_application->getCurrentTool();
|
|
Shinya Kitaoka |
120a6e |
return new GenericToolOptionsBox(0, this, currPalette, 0, currTool);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double TTool::getPixelSize() const {
|
|
Shinya Kitaoka |
120a6e |
return m_viewer ? m_viewer->getPixelSize() : 1.0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TXshCell TTool::getImageCell() {
|
|
Shinya Kitaoka |
120a6e |
assert(m_application);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TXshCell result;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TFrameHandle *currentFrame = m_application->getCurrentFrame();
|
|
Shinya Kitaoka |
120a6e |
TXshLevelHandle *currentLevel = m_application->getCurrentLevel();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (currentFrame->isEditingLevel()) {
|
|
Shinya Kitaoka |
120a6e |
if (TXshLevel *xl = currentLevel->getLevel()) {
|
|
Shinya Kitaoka |
120a6e |
if (TXshSimpleLevel *sl = xl->getSimpleLevel()) {
|
|
Shinya Kitaoka |
120a6e |
result.m_level = xl;
|
|
Shinya Kitaoka |
120a6e |
result.m_frameId = currentFrame->getFid();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
if (TXsheet *xsh = m_application->getCurrentXsheet()->getXsheet()) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_application->getCurrentObject()->isSpline()) {
|
|
Shinya Kitaoka |
120a6e |
int row = currentFrame->getFrame();
|
|
Shinya Kitaoka |
120a6e |
int col = m_application->getCurrentColumn()->getColumnIndex();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
result = xsh->getCell(row, col);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return result;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TImage *TTool::getImage(bool toBeModified, int subsampling) {
|
|
Shinya Kitaoka |
120a6e |
assert(m_application);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_application->getCurrentFrame()->isPlaying())
|
|
Shinya Kitaoka |
120a6e |
toBeModified =
|
|
Shinya Kitaoka |
120a6e |
false; // In playback mode, you are not going to modify images
|
|
Shinya Kitaoka |
120a6e |
// Probably useless - tools are disabled when playing...
|
|
Shinya Kitaoka |
120a6e |
const TXshCell &cell = getImageCell();
|
|
Shinya Kitaoka |
120a6e |
if (cell.isEmpty()) {
|
|
Shinya Kitaoka |
120a6e |
TObjectHandle *currentObject = m_application->getCurrentObject();
|
|
Shinya Kitaoka |
120a6e |
return currentObject->isSpline() ? currentObject->getSplineImage()
|
|
Shinya Kitaoka |
120a6e |
: (TImage *)0;
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
return cell.getImage(toBeModified, subsampling).getPointer();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TImage *TTool::touchImage() {
|
|
Shinya Kitaoka |
120a6e |
if (!m_application) return 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_cellsData.clear();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_isLevelCreated = false;
|
|
Shinya Kitaoka |
120a6e |
m_isFrameCreated = false;
|
|
Shinya Kitaoka |
120a6e |
Preferences *pref = Preferences::instance();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool isAutoCreateEnabled = pref->isAutoCreateEnabled();
|
|
Shinya Kitaoka |
120a6e |
bool animationSheetEnabled = pref->isAnimationSheetEnabled();
|
|
manongjohn |
29ce0b |
bool isAutoStretchEnabled = pref->isAutoStretchEnabled();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TFrameHandle *currentFrame = m_application->getCurrentFrame();
|
|
Shinya Kitaoka |
120a6e |
TXshLevelHandle *currentLevel = m_application->getCurrentLevel();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (currentFrame->isEditingLevel()) {
|
|
Shinya Kitaoka |
120a6e |
// Editing level
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// no level => return 0
|
|
Shinya Kitaoka |
120a6e |
TXshLevel *xl = currentLevel->getLevel();
|
|
Shinya Kitaoka |
120a6e |
if (!xl) return 0;
|
|
Shinya Kitaoka |
120a6e |
TXshSimpleLevel *sl = xl->getSimpleLevel();
|
|
Shinya Kitaoka |
120a6e |
if (!sl || sl->isEmpty()) return 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TFrameId fid = currentFrame->getFid();
|
|
Shinya Kitaoka |
120a6e |
TImageP img = sl->getFrame(fid, true);
|
|
Shinya Kitaoka |
120a6e |
if (!img) {
|
|
Shinya Kitaoka |
120a6e |
// no drawing found
|
|
Shinya Kitaoka |
120a6e |
if (sl->isSubsequence() || sl->isReadOnly() || !isAutoCreateEnabled)
|
|
Shinya Kitaoka |
120a6e |
return 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// create a new drawing
|
|
Shinya Kitaoka |
120a6e |
img = sl->createEmptyFrame();
|
|
Shinya Kitaoka |
120a6e |
sl->setFrame(fid, img);
|
|
Shinya Kitaoka |
120a6e |
currentLevel->notifyLevelChange();
|
|
Shinya Kitaoka |
120a6e |
m_isFrameCreated = true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return img.getPointer();
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
// editing xsheet
|
|
Shinya Kitaoka |
120a6e |
if (m_application->getCurrentObject()->isSpline()) return 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TSceneHandle *currentScene = m_application->getCurrentScene();
|
|
Shinya Kitaoka |
120a6e |
ToonzScene *scene = currentScene->getScene();
|
|
Shinya Kitaoka |
120a6e |
int row = currentFrame->getFrame();
|
|
Shinya Kitaoka |
120a6e |
int col = m_application->getCurrentColumn()->getColumnIndex();
|
|
Shinya Kitaoka |
120a6e |
if (col < 0) return 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TXsheetHandle *currentXsheet = m_application->getCurrentXsheet();
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = currentXsheet->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
if (!xsh) return 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TXshCell cell = xsh->getCell(row, col);
|
|
Shinya Kitaoka |
120a6e |
TXshSimpleLevel *sl = cell.getSimpleLevel();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (sl != 0) {
|
|
Shinya Kitaoka |
120a6e |
// current cell is not empty
|
|
Shinya Kitaoka |
120a6e |
if (isAutoCreateEnabled && animationSheetEnabled && row > 0 &&
|
|
Shinya Kitaoka |
120a6e |
xsh->getCell(row - 1, col) == xsh->getCell(row, col)) {
|
|
Shinya Kitaoka |
120a6e |
// animationSheet is enabled and the current cell is a "hold". We must
|
|
Shinya Kitaoka |
120a6e |
// create a new drawing.
|
|
Shinya Kitaoka |
120a6e |
// measure the hold length (starting from the current row) : r0-r1
|
|
Shinya Kitaoka |
120a6e |
int r0 = row, r1 = row;
|
|
manongjohn |
29ce0b |
if (isAutoStretchEnabled)
|
|
manongjohn |
29ce0b |
while (xsh->getCell(r1 + 1, col) == cell) r1++;
|
|
Shinya Kitaoka |
120a6e |
// find the proper frameid (possibly addisng suffix, in order to avoid a
|
|
Shinya Kitaoka |
120a6e |
// fid already used)
|
|
Shinya Kitaoka |
120a6e |
TFrameId fid = getNewFrameId(sl, row);
|
|
Shinya Kitaoka |
120a6e |
// create the new drawing
|
|
Shinya Kitaoka |
120a6e |
TImageP img = sl->createEmptyFrame();
|
|
Shinya Kitaoka |
120a6e |
m_isFrameCreated = true;
|
|
Shinya Kitaoka |
120a6e |
// insert the drawing in the level
|
|
Shinya Kitaoka |
120a6e |
sl->setFrame(fid, img);
|
|
Shinya Kitaoka |
120a6e |
// update the cell
|
|
Shinya Kitaoka |
120a6e |
cell = TXshCell(sl, fid);
|
|
Shinya Kitaoka |
120a6e |
// update the xsheet (change the current cell and possibly all the
|
|
Shinya Kitaoka |
120a6e |
// following "hold")
|
|
Shinya Kitaoka |
120a6e |
for (int r = r0; r <= r1; r++) xsh->setCell(r, col, cell);
|
|
Shinya Kitaoka |
120a6e |
// notify
|
|
Shinya Kitaoka |
120a6e |
currentXsheet->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
currentScene->notifyCastChange();
|
|
Shinya Kitaoka |
120a6e |
currentLevel->notifyLevelChange();
|
|
Shinya Kitaoka |
120a6e |
m_cellsData.push_back(r0);
|
|
Shinya Kitaoka |
120a6e |
m_cellsData.push_back(r1);
|
|
Shinya Kitaoka |
120a6e |
m_cellsData.push_back(0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
// we've found the image. return it.
|
|
Shinya Kitaoka |
120a6e |
return cell.getImage(true).getPointer();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// current cell is empty.
|
|
Shinya Kitaoka |
120a6e |
if (!isAutoCreateEnabled) return 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// get the column range
|
|
Shinya Kitaoka |
120a6e |
int r0, r1;
|
|
Shinya Kitaoka |
120a6e |
xsh->getCellRange(col, r0, r1);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (animationSheetEnabled && r0 <= r1) {
|
|
Shinya Kitaoka |
120a6e |
// animation sheet enabled and not empty column. We must create a new
|
|
Shinya Kitaoka |
120a6e |
// drawing in the column level and possibly add "holds"
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// find the last not-empty cell before the current one (a) and the first
|
|
Shinya Kitaoka |
120a6e |
// after (b)
|
|
Shinya Kitaoka |
120a6e |
int a = row - 1, b = row + 1;
|
|
Shinya Kitaoka |
120a6e |
while (a >= r0 && xsh->getCell(a, col).isEmpty()) a--;
|
|
Shinya Kitaoka |
120a6e |
while (b <= r1 && xsh->getCell(b, col).isEmpty()) b++;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// find the level we must attach to
|
|
Shinya Kitaoka |
120a6e |
if (a >= r0) {
|
|
Shinya Kitaoka |
120a6e |
// there is a not-emtpy cell before the current one
|
|
Shinya Kitaoka |
120a6e |
sl = xsh->getCell(a, col).getSimpleLevel();
|
|
Shinya Kitaoka |
120a6e |
} else if (b <= r1) {
|
|
Shinya Kitaoka |
120a6e |
sl = xsh->getCell(b, col).getSimpleLevel();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (sl) {
|
|
Shinya Kitaoka |
120a6e |
// note: sl should be always !=0 (the column is not empty)
|
|
Shinya Kitaoka |
120a6e |
// if - for some reason - it is ==0 then we skip to the standard (i.e.
|
|
Shinya Kitaoka |
120a6e |
// !animationSheetEnabled) beahviour
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// create the drawing
|
|
Shinya Kitaoka |
120a6e |
// find the proper frameid (possibly addisng suffix, in order to avoid a
|
|
Shinya Kitaoka |
120a6e |
// fid already used)
|
|
Shinya Kitaoka |
120a6e |
TFrameId fid = getNewFrameId(sl, row);
|
|
Shinya Kitaoka |
120a6e |
// create the new drawing
|
|
Shinya Kitaoka |
120a6e |
TImageP img = sl->createEmptyFrame();
|
|
Shinya Kitaoka |
120a6e |
m_isFrameCreated = true;
|
|
Shinya Kitaoka |
120a6e |
// insert the drawing in the level
|
|
Shinya Kitaoka |
120a6e |
sl->setFrame(fid, img);
|
|
Shinya Kitaoka |
120a6e |
// update the cell
|
|
Shinya Kitaoka |
120a6e |
cell = TXshCell(sl, fid);
|
|
Shinya Kitaoka |
120a6e |
xsh->setCell(row, col, cell);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// create holds
|
|
manongjohn |
29ce0b |
if (!isAutoStretchEnabled) {
|
|
manongjohn |
29ce0b |
m_cellsData.push_back(row);
|
|
manongjohn |
29ce0b |
m_cellsData.push_back(row);
|
|
manongjohn |
29ce0b |
m_cellsData.push_back(2); // vuoto => nuovo
|
|
manongjohn |
29ce0b |
} else {
|
|
manongjohn |
29ce0b |
if (a >= r0) {
|
|
manongjohn |
29ce0b |
// create a hold before : [a+1, row-1]
|
|
manongjohn |
29ce0b |
TXshCell aCell = xsh->getCell(a, col);
|
|
manongjohn |
29ce0b |
for (int i = a + 1; i < row; i++) xsh->setCell(i, col, aCell);
|
|
manongjohn |
29ce0b |
m_cellsData.push_back(a + 1);
|
|
manongjohn |
29ce0b |
m_cellsData.push_back(row - 1);
|
|
manongjohn |
29ce0b |
m_cellsData.push_back(1); // vuoto => vecchio
|
|
manongjohn |
29ce0b |
|
|
manongjohn |
29ce0b |
if (b <= r1 && xsh->getCell(b, col).getSimpleLevel() == sl) {
|
|
manongjohn |
29ce0b |
// create also a hold after
|
|
manongjohn |
29ce0b |
for (int i = row + 1; i < b; i++) xsh->setCell(i, col, cell);
|
|
manongjohn |
29ce0b |
m_cellsData.push_back(row);
|
|
manongjohn |
29ce0b |
m_cellsData.push_back(b - 1);
|
|
manongjohn |
29ce0b |
m_cellsData.push_back(2); // vuoto => nuovo
|
|
manongjohn |
29ce0b |
} else {
|
|
manongjohn |
29ce0b |
m_cellsData.push_back(row);
|
|
manongjohn |
29ce0b |
m_cellsData.push_back(row);
|
|
manongjohn |
29ce0b |
m_cellsData.push_back(2); // vuoto => nuovo
|
|
manongjohn |
29ce0b |
}
|
|
manongjohn |
29ce0b |
} else if (b <= r1) {
|
|
manongjohn |
29ce0b |
// create a hold after
|
|
Shinya Kitaoka |
120a6e |
for (int i = row + 1; i < b; i++) xsh->setCell(i, col, cell);
|
|
Shinya Kitaoka |
120a6e |
m_cellsData.push_back(row);
|
|
Shinya Kitaoka |
120a6e |
m_cellsData.push_back(b - 1);
|
|
Shinya Kitaoka |
120a6e |
m_cellsData.push_back(2); // vuoto => nuovo
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
// notify & return
|
|
Shinya Kitaoka |
120a6e |
currentXsheet->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
currentScene->notifyCastChange();
|
|
Shinya Kitaoka |
120a6e |
currentLevel->notifyLevelChange();
|
|
Shinya Kitaoka |
120a6e |
return cell.getImage(true).getPointer();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (row > 0 && xsh->getCell(row - 1, col).getSimpleLevel() != 0 &&
|
|
Shinya Kitaoka |
120a6e |
!animationSheetEnabled) {
|
|
Shinya Kitaoka |
120a6e |
sl = xsh->getCell(row - 1, col).getSimpleLevel();
|
|
Shinya Kitaoka |
120a6e |
if (sl->getType() != OVL_XSHLEVEL ||
|
|
Shinya Kitaoka |
120a6e |
sl->getPath().getFrame() != TFrameId::NO_FRAME) {
|
|
Shinya Kitaoka |
120a6e |
// la cella precedente contiene un drawing di un livello. animationSheet
|
|
Shinya Kitaoka |
120a6e |
// e' disabilitato
|
|
Shinya Kitaoka |
120a6e |
// creo un nuovo frame
|
|
Shinya Kitaoka |
120a6e |
currentLevel->setLevel(sl);
|
|
Shinya Kitaoka |
120a6e |
if (sl->isSubsequence() || sl->isReadOnly()) return 0;
|
|
Shinya Kitaoka |
120a6e |
TFrameId fid = sl->index2fid(sl->getFrameCount());
|
|
Shinya Kitaoka |
120a6e |
TImageP img = sl->createEmptyFrame();
|
|
Shinya Kitaoka |
120a6e |
m_isFrameCreated = true;
|
|
Shinya Kitaoka |
120a6e |
sl->setFrame(fid, img);
|
|
Shinya Kitaoka |
120a6e |
cell = TXshCell(sl, fid);
|
|
Shinya Kitaoka |
120a6e |
xsh->setCell(row, col, cell);
|
|
Shinya Kitaoka |
120a6e |
currentXsheet->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
currentScene->notifyCastChange();
|
|
Shinya Kitaoka |
120a6e |
currentLevel->notifyLevelChange();
|
|
Shinya Kitaoka |
120a6e |
return img.getPointer();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// animation sheet disabled or empty column. autoCreate is enabled: we must
|
|
Shinya Kitaoka |
120a6e |
// create a new level
|
|
Shinya Kitaoka |
120a6e |
int levelType = pref->getDefLevelType();
|
|
Shinya Kitaoka |
120a6e |
TXshLevel *xl = scene->createNewLevel(levelType);
|
|
Shinya Kitaoka |
120a6e |
sl = xl->getSimpleLevel();
|
|
Shinya Kitaoka |
120a6e |
m_isLevelCreated = true;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// create the drawing
|
|
Shinya Kitaoka |
120a6e |
TFrameId fid = animationSheetEnabled ? getNewFrameId(sl, row) : TFrameId(1);
|
|
Shinya Kitaoka |
120a6e |
TImageP img = sl->createEmptyFrame();
|
|
Shinya Kitaoka |
120a6e |
m_isFrameCreated = true;
|
|
Shinya Kitaoka |
120a6e |
sl->setFrame(fid, img);
|
|
Shinya Kitaoka |
120a6e |
cell = TXshCell(sl, fid);
|
|
Shinya Kitaoka |
120a6e |
xsh->setCell(row, col, cell);
|
|
Shinya Kitaoka |
120a6e |
if (animationSheetEnabled) {
|
|
Shinya Kitaoka |
120a6e |
m_cellsData.push_back(row);
|
|
Shinya Kitaoka |
120a6e |
m_cellsData.push_back(row);
|
|
Shinya Kitaoka |
120a6e |
m_cellsData.push_back(2); // vuoto => nuovo
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
currentXsheet->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
currentScene->notifyCastChange();
|
|
Shinya Kitaoka |
120a6e |
currentLevel->notifyLevelChange();
|
|
Shinya Kitaoka |
120a6e |
return img.getPointer();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TTool::updateToolsPropertiesTranslation() {
|
|
Shinya Kitaoka |
120a6e |
ToolTable::iterator tt, tEnd(toolTable->end());
|
|
Shinya Kitaoka |
120a6e |
for (tt = toolTable->begin(); tt != tEnd; ++tt)
|
|
Shinya Kitaoka |
120a6e |
tt->second->updateTranslation();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TTool::invalidate(const TRectD &rect) {
|
|
Shinya Kitaoka |
120a6e |
if (m_viewer) {
|
|
Shinya Kitaoka |
120a6e |
if (rect.isEmpty())
|
|
Shinya Kitaoka |
120a6e |
m_viewer->GLInvalidateAll();
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
TPointD dpiScale(1, 1);
|
|
Shinya Kitaoka |
120a6e |
TXshSimpleLevel *sl =
|
|
Shinya Kitaoka |
120a6e |
getApplication()->getCurrentLevel()->getSimpleLevel();
|
|
Shinya Kitaoka |
120a6e |
if (sl) dpiScale = getCurrentDpiScale(sl, getCurrentFid());
|
|
Shinya Kitaoka |
120a6e |
m_viewer->GLInvalidateRect(getCurrentColumnMatrix() *
|
|
Shinya Kitaoka |
120a6e |
TScale(dpiScale.x, dpiScale.y) * rect);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun_iwasawa |
bc352c |
int TTool::pick(const TPointD &p) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_viewer) return 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_picking = true;
|
|
Shinya Kitaoka |
120a6e |
int ret = m_viewer->pick(p);
|
|
Shinya Kitaoka |
120a6e |
m_picking = false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return ret;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TXsheet *TTool::getXsheet() const {
|
|
Shinya Kitaoka |
120a6e |
if (!m_application) return 0;
|
|
Shinya Kitaoka |
120a6e |
return m_application->getCurrentXsheet()->getXsheet();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TTool::getFrame() {
|
|
Shinya Kitaoka |
120a6e |
if (!m_application) return 0;
|
|
Shinya Kitaoka |
120a6e |
return m_application->getCurrentFrame()->getFrame();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TTool::getColumnIndex() {
|
|
Shinya Kitaoka |
120a6e |
if (!m_application) return 0;
|
|
Shinya Kitaoka |
120a6e |
return m_application->getCurrentColumn()->getColumnIndex();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId TTool::getObjectId() {
|
|
Shinya Kitaoka |
120a6e |
if (!m_application) return TStageObjectId();
|
|
Shinya Kitaoka |
120a6e |
return m_application->getCurrentObject()->getObjectId();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TTool::Application *TTool::getApplication() {
|
|
Shinya Kitaoka |
120a6e |
if (m_application == 0)
|
|
Shinya Kitaoka |
120a6e |
assert(!"you MUST call the TTool::setApplication function in the main of the program!");
|
|
Shinya Kitaoka |
120a6e |
return m_application;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! Notify change of current image: update icon and notify level change.
|
|
Toshihiro Shimizu |
890ddd |
If current object is a spline commit spline chenged.
|
|
Toshihiro Shimizu |
890ddd |
If current mode is EditingLevel touch current frame.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void TTool::notifyImageChanged() {
|
|
Shinya Kitaoka |
120a6e |
onImageChanged();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!m_application) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_application->getCurrentScene()->setDirtyFlag(true);
|
|
Shinya Kitaoka |
120a6e |
if (m_application->getCurrentFrame()->isEditingLevel()) {
|
|
Shinya Kitaoka |
120a6e |
TXshLevel *xl = m_application->getCurrentLevel()->getLevel();
|
|
Shinya Kitaoka |
120a6e |
if (!xl) return;
|
|
Shinya Kitaoka |
120a6e |
TXshSimpleLevel *sl = xl->getSimpleLevel();
|
|
Shinya Kitaoka |
120a6e |
if (!sl) return;
|
|
Shinya Kitaoka |
120a6e |
TFrameId fid = m_application->getCurrentFrame()->getFid();
|
|
Shinya Kitaoka |
120a6e |
sl->touchFrame(fid);
|
|
Shinya Kitaoka |
120a6e |
// sl->setDirtyFlag(true);
|
|
Shinya Kitaoka |
120a6e |
IconGenerator::instance()->invalidate(sl, fid);
|
|
Shinya Kitaoka |
120a6e |
IconGenerator::instance()->invalidateSceneIcon();
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = m_application->getCurrentXsheet()->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
if (!xsh) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TObjectHandle *currentObject = m_application->getCurrentObject();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (currentObject->isSpline()) {
|
|
Shinya Kitaoka |
120a6e |
m_application->getCurrentObject()->commitSplineChanges();
|
|
Shinya Kitaoka |
120a6e |
TStageObject *pegbar = xsh->getStageObject(currentObject->getObjectId());
|
|
Shinya Kitaoka |
120a6e |
IconGenerator::instance()->invalidate(pegbar->getSpline());
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
int row = m_application->getCurrentFrame()->getFrame();
|
|
Shinya Kitaoka |
120a6e |
int col = m_application->getCurrentColumn()->getColumnIndex();
|
|
Shinya Kitaoka |
120a6e |
if (col < 0) return;
|
|
Shinya Kitaoka |
120a6e |
TXshCell cell = xsh->getCell(row, col);
|
|
Shinya Kitaoka |
120a6e |
TXshSimpleLevel *sl = cell.getSimpleLevel();
|
|
Shinya Kitaoka |
120a6e |
if (sl) {
|
|
Shinya Kitaoka |
120a6e |
IconGenerator::instance()->invalidate(sl, cell.m_frameId);
|
|
Shinya Kitaoka |
120a6e |
sl->touchFrame(cell.m_frameId);
|
|
Shinya Kitaoka |
120a6e |
IconGenerator::instance()->invalidateSceneIcon();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
m_application->getCurrentLevel()->notifyLevelChange();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! Notify change of image in \b fid: update icon and notify level change.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void TTool::notifyImageChanged(const TFrameId &fid) {
|
|
Shinya Kitaoka |
120a6e |
onImageChanged();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!m_application) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_application->getCurrentScene()->setDirtyFlag(true);
|
|
Shinya Kitaoka |
120a6e |
if (m_application->getCurrentFrame()->isEditingLevel()) {
|
|
Shinya Kitaoka |
120a6e |
TXshLevel *xl = m_application->getCurrentLevel()->getLevel();
|
|
Shinya Kitaoka |
120a6e |
if (!xl) return;
|
|
Shinya Kitaoka |
120a6e |
TXshSimpleLevel *sl = xl->getSimpleLevel();
|
|
Shinya Kitaoka |
120a6e |
if (!sl) return;
|
|
Shinya Kitaoka |
120a6e |
sl->setDirtyFlag(true);
|
|
Shinya Kitaoka |
120a6e |
IconGenerator::instance()->invalidate(sl, fid);
|
|
Shinya Kitaoka |
120a6e |
IconGenerator::instance()->invalidateSceneIcon();
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
int row = m_application->getCurrentFrame()->getFrame();
|
|
Shinya Kitaoka |
120a6e |
int col = m_application->getCurrentColumn()->getColumnIndex();
|
|
Shinya Kitaoka |
120a6e |
if (col < 0) return;
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = m_application->getCurrentXsheet()->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
if (!xsh) return;
|
|
Shinya Kitaoka |
120a6e |
TXshCell cell = xsh->getCell(row, col);
|
|
Shinya Kitaoka |
120a6e |
TXshSimpleLevel *sl = cell.getSimpleLevel();
|
|
Shinya Kitaoka |
120a6e |
if (sl) {
|
|
Shinya Kitaoka |
120a6e |
IconGenerator::instance()->invalidate(sl, fid);
|
|
Shinya Kitaoka |
120a6e |
IconGenerator::instance()->invalidateSceneIcon();
|
|
Shinya Kitaoka |
120a6e |
sl->setDirtyFlag(true);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
m_application->getCurrentLevel()->notifyLevelChange();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFrameId TTool::getCurrentFid() const {
|
|
Shinya Kitaoka |
120a6e |
if (!m_application) return TFrameId();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFrameHandle *fh = m_application->getCurrentFrame();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (fh->isEditingLevel()) return fh->getFid();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int row = m_application->getCurrentFrame()->getFrame();
|
|
Shinya Kitaoka |
120a6e |
int col = m_application->getCurrentColumn()->getColumnIndex();
|
|
Shinya Kitaoka |
120a6e |
TXshCell cell =
|
|
Shinya Kitaoka |
120a6e |
m_application->getCurrentXsheet()->getXsheet()->getCell(row, col);
|
|
Shinya Kitaoka |
120a6e |
if (cell.isEmpty()) return TFrameId::NO_FRAME;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return cell.getFrameId();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TAffine TTool::getCurrentColumnMatrix() const {
|
|
Shinya Kitaoka |
120a6e |
return getColumnMatrix(m_application->getCurrentColumn()->getColumnIndex());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TAffine TTool::getCurrentColumnParentMatrix() const {
|
|
Shinya Kitaoka |
120a6e |
if (!m_application) return TAffine();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TFrameHandle *fh = m_application->getCurrentFrame();
|
|
Shinya Kitaoka |
120a6e |
if (fh->isEditingLevel()) return TAffine();
|
|
Shinya Kitaoka |
120a6e |
int frame = fh->getFrame();
|
|
Shinya Kitaoka |
120a6e |
int columnIndex = m_application->getCurrentColumn()->getColumnIndex();
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = m_application->getCurrentXsheet()->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId parentId =
|
|
Shinya Kitaoka |
120a6e |
xsh->getStageObjectParent(TStageObjectId::ColumnId(columnIndex));
|
|
Shinya Kitaoka |
120a6e |
return xsh->getPlacement(parentId, frame);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TAffine TTool::getCurrentObjectParentMatrix() const {
|
|
Shinya Kitaoka |
120a6e |
if (!m_application) return TAffine();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = m_application->getCurrentXsheet()->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
int frame = m_application->getCurrentFrame()->getFrame();
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId currentObjectId =
|
|
Shinya Kitaoka |
120a6e |
m_application->getCurrentObject()->getObjectId();
|
|
Shinya Kitaoka |
120a6e |
if (currentObjectId == TStageObjectId::NoneId) return TAffine();
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId parentId = xsh->getStageObjectParent(currentObjectId);
|
|
Shinya Kitaoka |
120a6e |
if (parentId == TStageObjectId::NoneId)
|
|
Shinya Kitaoka |
120a6e |
return TAffine();
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
return xsh->getPlacement(parentId, frame);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TAffine TTool::getColumnMatrix(int columnIndex) const {
|
|
Shinya Kitaoka |
120a6e |
if (!m_application) return TAffine();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TFrameHandle *fh = m_application->getCurrentFrame();
|
|
Shinya Kitaoka |
120a6e |
if (fh->isEditingLevel()) return TAffine();
|
|
Shinya Kitaoka |
120a6e |
int frame = fh->getFrame();
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = m_application->getCurrentXsheet()->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId columnId = TStageObjectId::ColumnId(columnIndex);
|
|
Shinya Kitaoka |
120a6e |
TAffine columnPlacement = xsh->getPlacement(columnId, frame);
|
|
Shinya Kitaoka |
120a6e |
double columnZ = xsh->getZ(columnId, frame);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId cameraId = xsh->getStageObjectTree()->getCurrentCameraId();
|
|
Shinya Kitaoka |
120a6e |
TStageObject *camera = xsh->getStageObject(cameraId);
|
|
Shinya Kitaoka |
120a6e |
TAffine cameraPlacement = camera->getPlacement(frame);
|
|
Shinya Kitaoka |
120a6e |
double cameraZ = camera->getZ(frame);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TStageObject *object = xsh->getStageObject(columnId);
|
|
Shinya Kitaoka |
120a6e |
TAffine placement;
|
|
Shinya Kitaoka |
120a6e |
TStageObject::perspective(placement, cameraPlacement, cameraZ,
|
|
Shinya Kitaoka |
120a6e |
columnPlacement, columnZ,
|
|
Shinya Kitaoka |
120a6e |
object->getGlobalNoScaleZ());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return placement;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TAffine TTool::getCurrentObjectParentMatrix2() const {
|
|
Shinya Kitaoka |
120a6e |
TTool::Application *app = m_application;
|
|
Shinya Kitaoka |
120a6e |
TFrameHandle *fh = app->getCurrentFrame();
|
|
Shinya Kitaoka |
120a6e |
if (fh->isEditingLevel()) return TAffine();
|
|
Shinya Kitaoka |
120a6e |
int frame = fh->getFrame();
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId id = app->getCurrentObject()->getObjectId();
|
|
Shinya Kitaoka |
120a6e |
double objZ = xsh->getZ(id, frame);
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId parentId = xsh->getStageObjectParent(id);
|
|
Shinya Kitaoka |
120a6e |
if (parentId == TStageObjectId::NoneId) return TAffine();
|
|
Shinya Kitaoka |
120a6e |
id = parentId;
|
|
Shinya Kitaoka |
120a6e |
TAffine objPlacement = xsh->getPlacement(id, frame);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId cameraId = xsh->getStageObjectTree()->getCurrentCameraId();
|
|
Shinya Kitaoka |
120a6e |
TStageObject *camera = xsh->getStageObject(cameraId);
|
|
Shinya Kitaoka |
120a6e |
TAffine cameraPlacement = camera->getPlacement(frame);
|
|
Shinya Kitaoka |
120a6e |
double cameraZ = camera->getZ(frame);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TAffine placement;
|
|
Shinya Kitaoka |
120a6e |
TStageObject::perspective(placement, cameraPlacement, cameraZ, objPlacement,
|
|
Shinya Kitaoka |
120a6e |
objZ, 0);
|
|
Shinya Kitaoka |
120a6e |
return placement;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TTool::updateMatrix() {
|
|
Shinya Kitaoka |
120a6e |
assert(m_application);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (m_application->getCurrentObject()->isSpline())
|
|
Shinya Kitaoka |
120a6e |
setMatrix(getCurrentObjectParentMatrix2());
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
setMatrix(getCurrentColumnMatrix());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TTool::resetInputMethod() {
|
|
Shinya Kitaoka |
120a6e |
if (m_viewer) m_viewer->resetInputMethod();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool TTool::isColumnLocked(int columnIndex) const {
|
|
Shinya Kitaoka |
120a6e |
if (columnIndex < 0) return false;
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = getXsheet();
|
|
Shinya Kitaoka |
120a6e |
TXshColumn *column = xsh->getColumn(columnIndex);
|
|
Shinya Kitaoka |
120a6e |
return column->isLocked();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString TTool::updateEnabled() {
|
|
Shinya Kitaoka |
120a6e |
// Disable every tool during playback
|
|
Shinya Kitaoka |
120a6e |
if (m_application->getCurrentFrame()->isPlaying())
|
|
Shinya Kitaoka |
120a6e |
return (enable(false), QString());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Release Generic tools at once
|
|
Shinya Kitaoka |
120a6e |
int toolType = getToolType();
|
|
Shinya Kitaoka |
120a6e |
int targetType = getTargetType();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (toolType == TTool::GenericTool) return (enable(true), QString());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Retrieve vars and view modes
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = m_application->getCurrentXsheet()->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int rowIndex = m_application->getCurrentFrame()->getFrame();
|
|
Shinya Kitaoka |
120a6e |
int columnIndex = m_application->getCurrentColumn()->getColumnIndex();
|
|
Shinya Kitaoka |
120a6e |
TXshColumn *column = (columnIndex >= 0) ? xsh->getColumn(columnIndex) : 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TXshLevel *xl = m_application->getCurrentLevel()->getLevel();
|
|
Shinya Kitaoka |
120a6e |
TXshSimpleLevel *sl = xl ? xl->getSimpleLevel() : 0;
|
|
Shinya Kitaoka |
120a6e |
int levelType = sl ? sl->getType() : NO_XSHLEVEL;
|
|
Shinya Kitaoka |
120a6e |
|
|
manongjohn |
5f9599 |
if (Preferences::instance()->isAutoCreateEnabled() &&
|
|
manongjohn |
5f9599 |
Preferences::instance()->isAnimationSheetEnabled()) {
|
|
manongjohn |
5f9599 |
// If not in Level editor, let's use our current cell from the xsheet to
|
|
manongjohn |
5f9599 |
// find the nearest level before it
|
|
manongjohn |
5f9599 |
if (levelType == NO_XSHLEVEL &&
|
|
manongjohn |
5f9599 |
!m_application->getCurrentFrame()->isEditingLevel()) {
|
|
manongjohn |
5f9599 |
int r0, r1;
|
|
manongjohn |
5f9599 |
xsh->getCellRange(columnIndex, r0, r1);
|
|
manongjohn |
5f9599 |
for (int r = std::min(r1, rowIndex); r > r0; r--) {
|
|
manongjohn |
5f9599 |
TXshCell cell = xsh->getCell(r, columnIndex);
|
|
manongjohn |
5f9599 |
if (cell.isEmpty()) continue;
|
|
manongjohn |
5f9599 |
xl = (TXshLevel *)(&cell.m_level);
|
|
manongjohn |
5f9599 |
sl = cell.getSimpleLevel();
|
|
manongjohn |
5f9599 |
levelType = cell.m_level->getType();
|
|
manongjohn |
5f9599 |
break;
|
|
manongjohn |
5f9599 |
}
|
|
manongjohn |
5f9599 |
}
|
|
manongjohn |
5f9599 |
|
|
manongjohn |
5f9599 |
// If the current tool does not match the current type, check for
|
|
manongjohn |
5f9599 |
// a version of the same tool that does
|
|
manongjohn |
5f9599 |
{
|
|
manongjohn |
5f9599 |
TTool *tool = this;
|
|
manongjohn |
5f9599 |
|
|
manongjohn |
5f9599 |
if ((levelType == PLI_XSHLEVEL) && !(targetType & VectorImage))
|
|
manongjohn |
5f9599 |
tool = TTool::getTool(m_name, VectorImage);
|
|
manongjohn |
5f9599 |
else if ((levelType == TZP_XSHLEVEL) && !(targetType & ToonzImage))
|
|
manongjohn |
5f9599 |
tool = TTool::getTool(m_name, ToonzImage);
|
|
manongjohn |
5f9599 |
else if ((levelType == OVL_XSHLEVEL) && !(targetType & RasterImage))
|
|
manongjohn |
5f9599 |
tool = TTool::getTool(m_name, RasterImage);
|
|
manongjohn |
5f9599 |
else if ((levelType == MESH_XSHLEVEL) && !(targetType & MeshImage))
|
|
manongjohn |
5f9599 |
tool = TTool::getTool(m_name, MeshImage);
|
|
manongjohn |
5f9599 |
|
|
manongjohn |
5f9599 |
if (tool && tool != this && tool->getTargetType() != TTool::NoTarget)
|
|
manongjohn |
5f9599 |
return tool->updateEnabled();
|
|
manongjohn |
5f9599 |
}
|
|
manongjohn |
5f9599 |
}
|
|
manongjohn |
5f9599 |
|
|
Shinya Kitaoka |
120a6e |
TStageObject *obj =
|
|
Shinya Kitaoka |
120a6e |
xsh->getStageObject(TStageObjectId::ColumnId(columnIndex));
|
|
Shinya Kitaoka |
120a6e |
bool spline = m_application->getCurrentObject()->isSpline();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool filmstrip = m_application->getCurrentFrame()->isEditingLevel();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*-- MultiLayerStylePickerONのときは、現状に関わらず使用可能 --*/
|
|
Shinya Kitaoka |
120a6e |
if (m_name == T_StylePicker &&
|
|
Shinya Kitaoka |
120a6e |
Preferences::instance()->isMultiLayerStylePickerEnabled())
|
|
Shinya Kitaoka |
120a6e |
return (enable(true), QString());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Check against unplaced columns (not in filmstrip mode)
|
|
Shinya Kitaoka |
120a6e |
if (column && !filmstrip) {
|
|
Shinya Kitaoka |
120a6e |
if (column->isLocked())
|
|
Shinya Kitaoka |
120a6e |
return (enable(false), QObject::tr("The current column is locked."));
|
|
Shinya Kitaoka |
120a6e |
|
|
Jeremy Bullock |
3b3466 |
else if (!column->isCamstandVisible())
|
|
Jeremy Bullock |
3b3466 |
return (enable(false), QObject::tr("The current column is hidden."));
|
|
Jeremy Bullock |
3b3466 |
|
|
Shinya Kitaoka |
120a6e |
else if (column->getSoundColumn())
|
|
Shinya Kitaoka |
120a6e |
return (enable(false),
|
|
Shinya Kitaoka |
120a6e |
QObject::tr("It is not possible to edit the audio column."));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
else if (column->getSoundTextColumn())
|
|
Jeremy Bullock |
3b3466 |
return (
|
|
Jeremy Bullock |
3b3466 |
enable(false),
|
|
Jeremy Bullock |
3b3466 |
QObject::tr(
|
|
Jeremy Bullock |
3b3466 |
"Note columns can only be edited in the xsheet or timeline."));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (toolType == TTool::ColumnTool) {
|
|
Shinya Kitaoka |
120a6e |
// Check column target
|
|
Shinya Kitaoka |
120a6e |
if (column->getLevelColumn() && !(targetType & LevelColumns))
|
|
Shinya Kitaoka |
120a6e |
return (
|
|
Shinya Kitaoka |
120a6e |
enable(false),
|
|
Shinya Kitaoka |
120a6e |
QObject::tr("The current tool cannot be used on a Level column."));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (column->getMeshColumn() && !(targetType & MeshColumns))
|
|
Shinya Kitaoka |
120a6e |
return (
|
|
Shinya Kitaoka |
120a6e |
enable(false),
|
|
Shinya Kitaoka |
120a6e |
QObject::tr("The current tool cannot be used on a Mesh column."));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Check column tools
|
|
Shinya Kitaoka |
120a6e |
if (toolType == TTool::ColumnTool) {
|
|
Shinya Kitaoka |
120a6e |
if (filmstrip)
|
|
Shinya Kitaoka |
120a6e |
return (
|
|
Shinya Kitaoka |
120a6e |
enable(false),
|
|
Shinya Kitaoka |
120a6e |
QObject::tr("The current tool cannot be used in Level Strip mode."));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((!column || column->isEmpty()) && !(targetType & TTool::EmptyTarget))
|
|
Shinya Kitaoka |
120a6e |
return (enable(false), QString());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Check LevelRead & LevelWrite tools
|
|
Shinya Kitaoka |
120a6e |
if (toolType & TTool::LevelTool) {
|
|
Shinya Kitaoka |
120a6e |
// Check against splines
|
|
Shinya Kitaoka |
120a6e |
if (spline) {
|
|
Shinya Kitaoka |
120a6e |
return (targetType & Splines)
|
|
Shinya Kitaoka |
120a6e |
? (enable(true), QString())
|
|
Shinya Kitaoka |
120a6e |
: (enable(false), QObject::tr("The current tool cannot be "
|
|
Shinya Kitaoka |
120a6e |
"used to edit a motion path."));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Check against empty levels
|
|
Shinya Kitaoka |
120a6e |
if (!xl)
|
|
Shinya Kitaoka |
120a6e |
return (targetType & EmptyTarget) ? (enable(true), QString())
|
|
Shinya Kitaoka |
120a6e |
: (enable(false), QString());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Check against simple-level-edness
|
|
Shinya Kitaoka |
120a6e |
if (!sl)
|
|
Shinya Kitaoka |
120a6e |
return (enable(false),
|
|
Shinya Kitaoka |
120a6e |
QObject::tr("The current level is not editable.")); // Does it
|
|
Shinya Kitaoka |
120a6e |
// happen at
|
|
Shinya Kitaoka |
120a6e |
// all btw?
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Check against level types
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
if ((levelType == PLI_XSHLEVEL) && !(targetType & VectorImage))
|
|
Shinya Kitaoka |
120a6e |
return (
|
|
Shinya Kitaoka |
120a6e |
enable(false),
|
|
Shinya Kitaoka |
120a6e |
QObject::tr("The current tool cannot be used on a Vector Level."));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((levelType == TZP_XSHLEVEL) && !(targetType & ToonzImage))
|
|
Shinya Kitaoka |
120a6e |
return (
|
|
Shinya Kitaoka |
120a6e |
enable(false),
|
|
Shinya Kitaoka |
120a6e |
QObject::tr("The current tool cannot be used on a Toonz Level."));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((levelType == OVL_XSHLEVEL) && !(targetType & RasterImage))
|
|
Shinya Kitaoka |
120a6e |
return (
|
|
Shinya Kitaoka |
120a6e |
enable(false),
|
|
Shinya Kitaoka |
120a6e |
QObject::tr("The current tool cannot be used on a Raster Level."));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((levelType == MESH_XSHLEVEL) && !(targetType & MeshImage))
|
|
Shinya Kitaoka |
120a6e |
return (
|
|
Shinya Kitaoka |
120a6e |
enable(false),
|
|
Shinya Kitaoka |
120a6e |
QObject::tr("The current tool cannot be used on a Mesh Level."));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Check against impossibly traceable movements on the column
|
|
Shinya Kitaoka |
120a6e |
if ((levelType & LEVELCOLUMN_XSHLEVEL) && !filmstrip) {
|
|
Shinya Kitaoka |
120a6e |
// Test for Mesh-deformed levels
|
|
Shinya Kitaoka |
120a6e |
const TStageObjectId &parentId = obj->getParent();
|
|
Shinya Kitaoka |
120a6e |
if (parentId.isColumn() && obj->getParentHandle()[0] != 'H') {
|
|
Shinya Kitaoka |
120a6e |
TXshSimpleLevel *parentSl =
|
|
Shinya Kitaoka |
120a6e |
xsh->getCell(rowIndex, parentId.getIndex()).getSimpleLevel();
|
|
Shinya Kitaoka |
120a6e |
if (parentSl && parentSl->getType() == MESH_XSHLEVEL)
|
|
Shinya Kitaoka |
120a6e |
return (
|
|
Shinya Kitaoka |
120a6e |
enable(false),
|
|
Shinya Kitaoka |
120a6e |
QObject::tr(
|
|
Shinya Kitaoka |
120a6e |
"The current tool cannot be used on a mesh-deformed level"));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Check TTool::ImageType tools
|
|
Shinya Kitaoka |
120a6e |
if (toolType == TTool::LevelWriteTool) {
|
|
Shinya Kitaoka |
120a6e |
// Check level against read-only status
|
|
Shinya Kitaoka |
120a6e |
if (sl->isReadOnly()) {
|
|
Shinya Kitaoka |
120a6e |
const std::set<tframeid> &editableFrames = sl->getEditableRange();</tframeid>
|
|
Shinya Kitaoka |
120a6e |
TFrameId currentFid = getCurrentFid();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (editableFrames.find(currentFid) == editableFrames.end())
|
|
Shinya Kitaoka |
120a6e |
return (
|
|
Shinya Kitaoka |
120a6e |
enable(false),
|
|
Shinya Kitaoka |
120a6e |
QObject::tr(
|
|
Shinya Kitaoka |
120a6e |
"The current frame is locked: any editing is forbidden."));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Check level type write support
|
|
Shinya Kitaoka |
120a6e |
if (sl->getPath().getType() ==
|
|
Shinya Kitaoka |
120a6e |
"psd" || // We don't have the API to write psd files
|
|
Shinya Kitaoka |
120a6e |
sl->is16BitChannelLevel() || // Inherited by previous implementation.
|
|
Shinya Kitaoka |
120a6e |
// Could be fixed?
|
|
Shinya Kitaoka |
120a6e |
sl->getProperties()->getBpp() ==
|
|
Shinya Kitaoka |
120a6e |
1) // Black & White images. Again, could be fixed?
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return (enable(false),
|
|
Shinya Kitaoka |
120a6e |
QObject::tr("The current level is not editable."));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return (enable(true), QString());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TTool::setSelectedFrames(const std::set<tframeid> &selectedFrames) {</tframeid>
|
|
Shinya Kitaoka |
120a6e |
m_selectedFrames = selectedFrames;
|
|
Shinya Kitaoka |
120a6e |
onSelectedFramesChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|