|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tundo.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trandom.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tvectorimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ttoonzimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trasterimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpalette.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tsystem.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstream.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tconvert.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfilepath_io.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzBase includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tunit.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzLib includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheethandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tscenehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcolumnhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tobjecthandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tframehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshlevelhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheet.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshcell.h"
|
|
Jeremy Bullock |
52a220 |
#include "toonz/txshcolumn.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzscene.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/levelset.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshsimplelevel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshleveltypes.h"
|
|
Jeremy Bullock |
52a220 |
#include "toonz/txshsoundtextcolumn.h"
|
|
Jeremy Bullock |
c13d88 |
#include "toonz/txshsoundtextlevel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tstageobjecttree.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tstageobjectkeyframe.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/stageobjectutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzfolders.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshchildlevel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/childstack.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tproject.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/fxcommand.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tfxhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/scenefx.h"
|
|
manongjohn |
1be264 |
#include "toonz/preferences.h"
|
|
manongjohn |
8404a6 |
#include "toonz/navigationtags.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzQt includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/tselectionhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/gutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/menubarcommand.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/stageobjectsdata.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "historytypes.h"
|
|
manongjohn |
8404a6 |
#include "xsheetviewer.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Tnz6 includes
|
|
Toshihiro Shimizu |
890ddd |
#include "cellselection.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "columnselection.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "keyframeselection.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "celldata.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tapp.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "duplicatepopup.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "menubarcommandids.h"
|
|
manongjohn |
2e094e |
#include "columncommand.h"
|
|
shun-iwasawa |
f84c65 |
#include "xshcellviewer.h" // SetCellMarkUndo
|
|
manongjohn |
8404a6 |
#include "navtageditorpopup.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Qt includes
|
|
Toshihiro Shimizu |
890ddd |
#include <qclipboard></qclipboard>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// tcg includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tcg/boost/range_utility.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// boost includes
|
|
Toshihiro Shimizu |
890ddd |
#include <boost bind.hpp=""></boost>
|
|
Toshihiro Shimizu |
890ddd |
#include <boost bind="" make_adaptable.hpp=""></boost>
|
|
Toshihiro Shimizu |
890ddd |
#include <boost adaptor="" filtered.hpp="" range=""></boost>
|
|
Toshihiro Shimizu |
890ddd |
#include <boost adaptor="" range="" transformed.hpp=""></boost>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace ba = boost::adaptors;
|
|
Shinya Kitaoka |
120a6e |
using namespace std; // Please, remove
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Local Namespace stuff
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void getColumns(std::vector<int> &columns) {</int>
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColumnSelection *selection = dynamic_cast<tcolumnselection *="">(</tcolumnselection>
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentSelection()->getSelection());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (selection && selection->isEmpty()) selection = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!selection) // Se non c'e' selezione inserisco la colonna di camera
|
|
Shinya Kitaoka |
120a6e |
columns.push_back(-1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (int c = 0; c < xsh->getColumnCount(); ++c)
|
|
Shinya Kitaoka |
120a6e |
if (!selection || selection->isColumnSelected(c)) columns.push_back(c);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool isKeyframe(int r, int c) {
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objectId =
|
|
John Dancel |
c323ac |
(c == -1) ? TStageObjectId::CameraId(xsh->getCameraColumnIndex())
|
|
John Dancel |
c323ac |
: TStageObjectId::ColumnId(c);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TStageObject *object = xsh->getStageObject(objectId);
|
|
Shinya Kitaoka |
120a6e |
assert(object);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return object->isKeyframe(r);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// InsertSceneFrame command
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace XshCmd {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class InsertSceneFrameUndo : public TUndo {
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
120a6e |
int m_frame;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
InsertSceneFrameUndo(int frame) : m_frame(frame) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void undo() const override {
|
|
Shinya Kitaoka |
120a6e |
doRemoveSceneFrame(m_frame);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void redo() const override {
|
|
Shinya Kitaoka |
120a6e |
doInsertSceneFrame(m_frame);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
int getSize() const override { return sizeof(*this); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
QString getHistoryString() override {
|
|
Shinya Kitaoka |
120a6e |
return QObject::tr("Insert Frame at Frame %1")
|
|
Shinya Kitaoka |
120a6e |
.arg(QString::number(m_frame + 1));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
473e70 |
int getHistoryType() override { return HistoryType::Xsheet; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
120a6e |
static void doInsertSceneFrame(int frame);
|
|
Shinya Kitaoka |
120a6e |
static void doRemoveSceneFrame(int frame);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void InsertSceneFrameUndo::doInsertSceneFrame(int frame) {
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int c, colsCount = xsh->getColumnCount();
|
|
Shinya Kitaoka |
120a6e |
for (c = -1; c < colsCount; ++c) {
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objectId;
|
|
Toshihiro Shimizu |
890ddd |
|
|
manongjohn |
53a5c4 |
if (c == -1)
|
|
John Dancel |
c323ac |
objectId = TStageObjectId::CameraId(xsh->getCameraColumnIndex());
|
|
manongjohn |
53a5c4 |
else {
|
|
Shinya Kitaoka |
120a6e |
objectId = TStageObjectId::ColumnId(c);
|
|
Toshihiro Shimizu |
890ddd |
|
|
manongjohn |
53a5c4 |
xsh->insertCells(frame, c);
|
|
manongjohn |
53a5c4 |
xsh->setCell(frame, c, xsh->getCell(frame + 1, c));
|
|
manongjohn |
53a5c4 |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
manongjohn |
4334db |
if (!xsh->getColumn(c) || xsh->getColumn(c)->isLocked()) continue;
|
|
manongjohn |
4334db |
|
|
Shinya Kitaoka |
120a6e |
if (TStageObject *obj = xsh->getStageObject(objectId))
|
|
Shinya Kitaoka |
120a6e |
insertFrame(obj, frame);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
manongjohn |
8404a6 |
|
|
manongjohn |
8404a6 |
xsh->getNavigationTags()->shiftTags(frame, 1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void InsertSceneFrameUndo::doRemoveSceneFrame(int frame) {
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (int c = -1; c != xsh->getColumnCount(); ++c) {
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objectId;
|
|
Toshihiro Shimizu |
890ddd |
|
|
manongjohn |
53a5c4 |
if (c == -1)
|
|
John Dancel |
c323ac |
objectId = TStageObjectId::CameraId(xsh->getCameraColumnIndex());
|
|
manongjohn |
53a5c4 |
else {
|
|
Shinya Kitaoka |
120a6e |
objectId = TStageObjectId::ColumnId(c);
|
|
Toshihiro Shimizu |
890ddd |
|
|
manongjohn |
53a5c4 |
xsh->removeCells(frame, c);
|
|
manongjohn |
53a5c4 |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
manongjohn |
4334db |
if (!xsh->getColumn(c) || xsh->getColumn(c)->isLocked()) continue;
|
|
manongjohn |
4334db |
|
|
Shinya Kitaoka |
120a6e |
if (TStageObject *pegbar = xsh->getStageObject(objectId))
|
|
Shinya Kitaoka |
120a6e |
removeFrame(pegbar, frame);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
manongjohn |
8404a6 |
|
|
manongjohn |
8404a6 |
if (xsh->isFrameTagged(frame)) xsh->getNavigationTags()->removeTag(frame);
|
|
manongjohn |
8404a6 |
xsh->getNavigationTags()->shiftTags(frame, -1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
ccd505 |
static void insertSceneFrame(int frame) {
|
|
Shinya Kitaoka |
120a6e |
InsertSceneFrameUndo *undo = new InsertSceneFrameUndo(frame);
|
|
Shinya Kitaoka |
120a6e |
TUndoManager::manager()->add(undo);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
undo->redo();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
manongjohn |
1be264 |
class ToggleCurrentTimeIndicatorCommand final : public MenuItemHandler {
|
|
manongjohn |
1be264 |
public:
|
|
manongjohn |
1be264 |
ToggleCurrentTimeIndicatorCommand()
|
|
manongjohn |
1be264 |
: MenuItemHandler(MI_ToggleCurrentTimeIndicator) {}
|
|
manongjohn |
1be264 |
void execute() override {
|
|
manongjohn |
1be264 |
bool currentTimeIndEnabled =
|
|
manongjohn |
1be264 |
Preferences::instance()->isCurrentTimelineIndicatorEnabled();
|
|
shun-iwasawa |
8fb291 |
Preferences::instance()->setValue(currentTimelineEnabled,
|
|
shun-iwasawa |
8fb291 |
!currentTimeIndEnabled);
|
|
manongjohn |
1be264 |
}
|
|
manongjohn |
1be264 |
} toggleCurrentTimeIndicatorComman;
|
|
manongjohn |
1be264 |
|
|
manongjohn |
1be264 |
//=============================================================================
|
|
manongjohn |
1be264 |
|
|
Shinya Kitaoka |
d1f6c4 |
class InsertSceneFrameCommand final : public MenuItemHandler {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
InsertSceneFrameCommand() : MenuItemHandler(MI_InsertSceneFrame) {}
|
|
Shinya Kitaoka |
473e70 |
void execute() override {
|
|
Shinya Kitaoka |
120a6e |
int frame = TApp::instance()->getCurrentFrame()->getFrame();
|
|
Shinya Kitaoka |
120a6e |
XshCmd::insertSceneFrame(frame);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
} insertSceneFrameCommand;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// RemoveSceneFrame command
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class RemoveSceneFrameUndo final : public InsertSceneFrameUndo {
|
|
Shinya Kitaoka |
120a6e |
std::vector<txshcell> m_cells;</txshcell>
|
|
Shinya Kitaoka |
120a6e |
std::vector<tstageobject::keyframe> m_keyframes;</tstageobject::keyframe>
|
|
manongjohn |
8404a6 |
NavigationTags::Tag m_tag;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
RemoveSceneFrameUndo(int frame) : InsertSceneFrameUndo(frame) {
|
|
Shinya Kitaoka |
120a6e |
// Store cells and TStageObject::Keyframe that will be canceled
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
int colsCount = xsh->getColumnCount();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_cells.resize(colsCount);
|
|
Shinya Kitaoka |
120a6e |
m_keyframes.resize(colsCount + 1);
|
|
manongjohn |
8404a6 |
m_tag = xsh->getNavigationTags()->getTag(frame);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Inserting the eventual camera keyframe at the end
|
|
John Dancel |
c323ac |
TStageObject *cameraObj = xsh->getStageObject(
|
|
John Dancel |
c323ac |
TStageObjectId::CameraId(xsh->getCameraColumnIndex()));
|
|
Shinya Kitaoka |
120a6e |
if (cameraObj->isKeyframe(m_frame))
|
|
Shinya Kitaoka |
120a6e |
m_keyframes[colsCount] = cameraObj->getKeyframe(m_frame);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (int c = 0; c != colsCount; ++c) {
|
|
Shinya Kitaoka |
120a6e |
// Store cell
|
|
Shinya Kitaoka |
120a6e |
m_cells[c] = xsh->getCell(m_frame, c);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Store stage object keyframes
|
|
Shinya Kitaoka |
120a6e |
TStageObject *obj = xsh->getStageObject(TStageObjectId::ColumnId(c));
|
|
Shinya Kitaoka |
120a6e |
if (obj->isKeyframe(m_frame)) m_keyframes[c] = obj->getKeyframe(m_frame);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void redo() const override { InsertSceneFrameUndo::undo(); }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void undo() const override {
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Insert an empty frame, need space for our stored stuff
|
|
Shinya Kitaoka |
120a6e |
doInsertSceneFrame(m_frame);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Insert cells
|
|
Shinya Kitaoka |
120a6e |
int cellsCount = m_cells.size();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Deal with the eventual camera keyframe
|
|
Shinya Kitaoka |
120a6e |
if (m_keyframes[cellsCount].m_isKeyframe) {
|
|
John Dancel |
c323ac |
TStageObject *cameraObj = xsh->getStageObject(
|
|
John Dancel |
c323ac |
TStageObjectId::CameraId(xsh->getCameraColumnIndex()));
|
|
Shinya Kitaoka |
120a6e |
cameraObj->setKeyframeWithoutUndo(m_frame, m_keyframes[cellsCount]);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (int c = 0; c != cellsCount; ++c) {
|
|
Shinya Kitaoka |
120a6e |
xsh->setCell(m_frame, c, m_cells[c]);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_keyframes[c].m_isKeyframe) {
|
|
Shinya Kitaoka |
120a6e |
TStageObject *obj = xsh->getStageObject(TStageObjectId::ColumnId(c));
|
|
Shinya Kitaoka |
120a6e |
obj->setKeyframeWithoutUndo(m_frame, m_keyframes[c]);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
manongjohn |
8404a6 |
// Restore tag if there was one
|
|
manongjohn |
8404a6 |
if (m_tag.m_frame != -1)
|
|
manongjohn |
8404a6 |
xsh->getNavigationTags()->addTag(m_tag.m_frame, m_tag.m_label);
|
|
manongjohn |
8404a6 |
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
int getSize() const override {
|
|
Shinya Kitaoka |
120a6e |
return 10 << 10;
|
|
Shinya Kitaoka |
120a6e |
} // Gave up exact calculation. Say ~ 10 kB?
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
QString getHistoryString() override {
|
|
Shinya Kitaoka |
120a6e |
return QObject::tr("Remove Frame at Frame %1")
|
|
Shinya Kitaoka |
120a6e |
.arg(QString::number(m_frame + 1));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
473e70 |
int getHistoryType() override { return HistoryType::Xsheet; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
ccd505 |
static void removeSceneFrame(int frame) {
|
|
Shinya Kitaoka |
120a6e |
RemoveSceneFrameUndo *undo = new RemoveSceneFrameUndo(frame);
|
|
Shinya Kitaoka |
120a6e |
TUndoManager::manager()->add(undo);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
undo->redo();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class RemoveSceneFrameCommand final : public MenuItemHandler {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
RemoveSceneFrameCommand() : MenuItemHandler(MI_RemoveSceneFrame) {}
|
|
Shinya Kitaoka |
473e70 |
void execute() override {
|
|
Shinya Kitaoka |
120a6e |
int frame = TApp::instance()->getCurrentFrame()->getFrame();
|
|
Shinya Kitaoka |
120a6e |
XshCmd::removeSceneFrame(frame);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
} removeSceneFrameCommand;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// GlobalKeyframeUndo definition
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class GlobalKeyframeUndo : public TUndo {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
GlobalKeyframeUndo(int frame) : m_frame(frame) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
38fd86 |
int getSize() const override {
|
|
Shinya Kitaoka |
38fd86 |
return sizeof(*this) + m_columns.size() * sizeof(int);
|
|
Shinya Kitaoka |
38fd86 |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
int getHistoryType() override { return HistoryType::Xsheet; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
120a6e |
std::vector<int> m_columns;</int>
|
|
Shinya Kitaoka |
120a6e |
int m_frame;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
120a6e |
static void doInsertGlobalKeyframes(int frame,
|
|
Shinya Kitaoka |
120a6e |
const std::vector<int> &columns);</int>
|
|
Shinya Kitaoka |
120a6e |
static void doRemoveGlobalKeyframes(int frame,
|
|
Shinya Kitaoka |
120a6e |
const std::vector<int> &columns);</int>
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void GlobalKeyframeUndo::doInsertGlobalKeyframes(
|
|
Shinya Kitaoka |
120a6e |
int frame, const std::vector<int> &columns) {</int>
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
6b5568 |
for (const int c : columns) {
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objectId;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TXshColumn *column = xsh->getColumn(c);
|
|
Shinya Kitaoka |
120a6e |
if (column && column->getSoundColumn()) continue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
manongjohn |
4334db |
if (c == -1)
|
|
John Dancel |
c323ac |
objectId = TStageObjectId::CameraId(xsh->getCameraColumnIndex());
|
|
manongjohn |
4334db |
else
|
|
Shinya Kitaoka |
120a6e |
objectId = TStageObjectId::ColumnId(c);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TXshColumn *xshColumn = xsh->getColumn(c);
|
|
manongjohn |
4334db |
if (!xshColumn || xshColumn->isLocked() ||
|
|
manongjohn |
4334db |
(xshColumn->isCellEmpty(frame) && !objectId.isCamera()))
|
|
Shinya Kitaoka |
120a6e |
continue;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TStageObject *obj = xsh->getStageObject(objectId);
|
|
Shinya Kitaoka |
120a6e |
obj->setKeyframeWithoutUndo(frame);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void GlobalKeyframeUndo::doRemoveGlobalKeyframes(
|
|
Shinya Kitaoka |
120a6e |
int frame, const std::vector<int> &columns) {</int>
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
6b5568 |
for (const int c : columns) {
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objectId;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TXshColumn *column = xsh->getColumn(c);
|
|
Shinya Kitaoka |
120a6e |
if (column && column->getSoundColumn()) continue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
manongjohn |
4334db |
if (c == -1)
|
|
John Dancel |
c323ac |
objectId = TStageObjectId::CameraId(xsh->getCameraColumnIndex());
|
|
manongjohn |
4334db |
else
|
|
Shinya Kitaoka |
120a6e |
objectId = TStageObjectId::ColumnId(c);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (xsh->getColumn(c) && xsh->getColumn(c)->isLocked()) continue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TStageObject *obj = xsh->getStageObject(objectId);
|
|
Shinya Kitaoka |
120a6e |
obj->removeKeyframeWithoutUndo(frame);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// InsertGlobalKeyframe command
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class InsertGlobalKeyframeUndo final : public GlobalKeyframeUndo {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
InsertGlobalKeyframeUndo(int frame, const std::vector<int> &columns)</int>
|
|
Shinya Kitaoka |
120a6e |
: GlobalKeyframeUndo(frame) {
|
|
Shinya Kitaoka |
120a6e |
tcg::substitute(
|
|
Shinya Kitaoka |
120a6e |
m_columns,
|
|
Shinya Kitaoka |
120a6e |
columns | ba::filtered(std::not1(boost::make_adaptable<bool, int="">(</bool,>
|
|
Shinya Kitaoka |
120a6e |
boost::bind(isKeyframe, frame, _1)))));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void redo() const override {
|
|
Shinya Kitaoka |
120a6e |
doInsertGlobalKeyframes(m_frame, m_columns);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void undo() const override {
|
|
Shinya Kitaoka |
120a6e |
doRemoveGlobalKeyframes(m_frame, m_columns);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
QString getHistoryString() override {
|
|
Shinya Kitaoka |
120a6e |
return QObject::tr("Insert Multiple Keys at Frame %1")
|
|
Shinya Kitaoka |
120a6e |
.arg(QString::number(m_frame + 1));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
ccd505 |
static void insertGlobalKeyframe(int frame) {
|
|
Shinya Kitaoka |
120a6e |
std::vector<int> columns;</int>
|
|
Shinya Kitaoka |
120a6e |
::getColumns(columns);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (columns.empty()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TUndo *undo = new InsertGlobalKeyframeUndo(frame, columns);
|
|
Shinya Kitaoka |
120a6e |
TUndoManager::manager()->add(undo);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
undo->redo();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class InsertGlobalKeyframeCommand final : public MenuItemHandler {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
InsertGlobalKeyframeCommand() : MenuItemHandler(MI_InsertGlobalKeyframe) {}
|
|
Shinya Kitaoka |
473e70 |
void execute() override {
|
|
Shinya Kitaoka |
120a6e |
int frame = TApp::instance()->getCurrentFrame()->getFrame();
|
|
Shinya Kitaoka |
120a6e |
XshCmd::insertGlobalKeyframe(frame);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
} insertGlobalKeyframeCommand;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// RemoveGlobalKeyframe command
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class RemoveGlobalKeyframeUndo final : public GlobalKeyframeUndo {
|
|
Shinya Kitaoka |
120a6e |
std::vector<tstageobject::keyframe> m_keyframes;</tstageobject::keyframe>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
RemoveGlobalKeyframeUndo(int frame, const std::vector<int> &columns)</int>
|
|
Shinya Kitaoka |
120a6e |
: GlobalKeyframeUndo(frame) {
|
|
Shinya Kitaoka |
120a6e |
struct locals {
|
|
Shinya Kitaoka |
120a6e |
static TStageObject::Keyframe getKeyframe(int r, int c) {
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
|
|
John Dancel |
c323ac |
TStageObjectId objectId =
|
|
John Dancel |
c323ac |
(c == -1) ? TStageObjectId::CameraId(xsh->getCameraColumnIndex())
|
|
John Dancel |
c323ac |
: TStageObjectId::ColumnId(c);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TStageObject *object = xsh->getStageObject(objectId);
|
|
Shinya Kitaoka |
120a6e |
assert(object);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return object->getKeyframe(r);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}; // locals
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tcg::substitute(m_columns,
|
|
Shinya Kitaoka |
120a6e |
columns | ba::filtered(boost::bind(isKeyframe, frame, _1)));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tcg::substitute(m_keyframes,
|
|
Shinya Kitaoka |
120a6e |
m_columns | ba::transformed(boost::bind(locals::getKeyframe,
|
|
Shinya Kitaoka |
120a6e |
frame, _1)));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void redo() const override {
|
|
Shinya Kitaoka |
120a6e |
doRemoveGlobalKeyframes(m_frame, m_columns);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void undo() const override {
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int c, cCount = int(m_columns.size());
|
|
Shinya Kitaoka |
120a6e |
for (c = 0; c != cCount; ++c) {
|
|
Shinya Kitaoka |
120a6e |
int col = m_columns[c];
|
|
Shinya Kitaoka |
120a6e |
|
|
John Dancel |
c323ac |
TStageObjectId objectId =
|
|
John Dancel |
c323ac |
(col == -1) ? TStageObjectId::CameraId(xsh->getCameraColumnIndex())
|
|
John Dancel |
c323ac |
: TStageObjectId::ColumnId(col);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TStageObject *object = xsh->getStageObject(objectId);
|
|
Shinya Kitaoka |
120a6e |
object->setKeyframeWithoutUndo(m_frame, m_keyframes[c]);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
int getSize() const override {
|
|
Shinya Kitaoka |
120a6e |
return GlobalKeyframeUndo::getSize() +
|
|
Shinya Kitaoka |
120a6e |
m_keyframes.size() * sizeof(TStageObject::Keyframe);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
QString getHistoryString() override {
|
|
Shinya Kitaoka |
120a6e |
return QObject::tr("Remove Multiple Keys at Frame %1")
|
|
Shinya Kitaoka |
120a6e |
.arg(QString::number(m_frame + 1));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
ccd505 |
static void removeGlobalKeyframe(int frame) {
|
|
Shinya Kitaoka |
120a6e |
std::vector<int> columns;</int>
|
|
Shinya Kitaoka |
120a6e |
::getColumns(columns);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (columns.empty()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TUndo *undo = new RemoveGlobalKeyframeUndo(frame, columns);
|
|
Shinya Kitaoka |
120a6e |
TUndoManager::manager()->add(undo);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
undo->redo();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class RemoveGlobalKeyframeCommand final : public MenuItemHandler {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
RemoveGlobalKeyframeCommand() : MenuItemHandler(MI_RemoveGlobalKeyframe) {}
|
|
Shinya Kitaoka |
473e70 |
void execute() override {
|
|
Shinya Kitaoka |
120a6e |
int frame = TApp::instance()->getCurrentFrame()->getFrame();
|
|
Shinya Kitaoka |
120a6e |
XshCmd::removeGlobalKeyframe(frame);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
} removeGlobalKeyframeCommand;
|
|
Toshihiro Shimizu |
890ddd |
|
|
turtletooth |
48def2 |
//============================================================
|
|
turtletooth |
48def2 |
// Drawing Substitution
|
|
turtletooth |
48def2 |
//============================================================
|
|
Shinya Kitaoka |
d1f6c4 |
class DrawingSubtitutionUndo final : public TUndo {
|
|
turtletooth |
48def2 |
private:
|
|
Shinya Kitaoka |
473e70 |
int m_direction, m_row, m_col;
|
|
Shinya Kitaoka |
473e70 |
TCellSelection::Range m_range;
|
|
Shinya Kitaoka |
473e70 |
bool m_selected;
|
|
Jeremy Bullock |
c13d88 |
std::vector<std::pair<int, int="">> emptyCells;</std::pair<int,>
|
|
turtletooth |
48def2 |
|
|
turtletooth |
48def2 |
public:
|
|
Shinya Kitaoka |
38fd86 |
DrawingSubtitutionUndo(int dir, TCellSelection::Range range, int row, int col,
|
|
Shinya Kitaoka |
38fd86 |
bool selected)
|
|
Shinya Kitaoka |
38fd86 |
: m_direction(dir)
|
|
Shinya Kitaoka |
38fd86 |
, m_range(range)
|
|
Shinya Kitaoka |
38fd86 |
, m_row(row)
|
|
Shinya Kitaoka |
38fd86 |
, m_col(col)
|
|
Jeremy Bullock |
c13d88 |
, m_selected(selected) {
|
|
Jeremy Bullock |
c13d88 |
TXsheet *xsh = TApp::instance()->getCurrentScene()->getScene()->getXsheet();
|
|
Jeremy Bullock |
c13d88 |
int tempCol, tempRow;
|
|
Jeremy Bullock |
c13d88 |
int c = m_range.m_c0;
|
|
Jeremy Bullock |
c13d88 |
int r = m_range.m_r0;
|
|
Jeremy Bullock |
c13d88 |
while (c <= m_range.m_c1) {
|
|
Jeremy Bullock |
c13d88 |
tempCol = c;
|
|
Jeremy Bullock |
c13d88 |
while (r <= m_range.m_r1) {
|
|
Jeremy Bullock |
c13d88 |
tempRow = r;
|
|
Jeremy Bullock |
c13d88 |
if (xsh->getCell(tempRow, tempCol).isEmpty()) {
|
|
Jeremy Bullock |
c13d88 |
emptyCells.push_back(std::make_pair(tempRow, tempCol));
|
|
Jeremy Bullock |
c13d88 |
}
|
|
Jeremy Bullock |
c13d88 |
r++;
|
|
Jeremy Bullock |
c13d88 |
}
|
|
Jeremy Bullock |
c13d88 |
r = m_range.m_r0;
|
|
Jeremy Bullock |
c13d88 |
c++;
|
|
Jeremy Bullock |
c13d88 |
}
|
|
Jeremy Bullock |
c13d88 |
}
|
|
Shinya Kitaoka |
38fd86 |
|
|
Shinya Kitaoka |
473e70 |
void undo() const override {
|
|
Jeremy Bullock |
c13d88 |
TXsheet *xsh = TApp::instance()->getCurrentScene()->getScene()->getXsheet();
|
|
Jeremy Bullock |
c13d88 |
|
|
Shinya Kitaoka |
473e70 |
if (!m_selected) {
|
|
Shinya Kitaoka |
473e70 |
changeDrawing(-m_direction, m_row, m_col);
|
|
snapai |
254fd1 |
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
|
|
snapai |
254fd1 |
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
|
|
Shinya Kitaoka |
473e70 |
return;
|
|
Shinya Kitaoka |
473e70 |
}
|
|
Shinya Kitaoka |
473e70 |
int col, row;
|
|
Shinya Kitaoka |
473e70 |
int c = m_range.m_c0;
|
|
Shinya Kitaoka |
473e70 |
int r = m_range.m_r0;
|
|
Shinya Kitaoka |
38fd86 |
while (c <= m_range.m_c1) {
|
|
Shinya Kitaoka |
473e70 |
col = c;
|
|
Shinya Kitaoka |
38fd86 |
while (r <= m_range.m_r1) {
|
|
Jeremy Bullock |
c13d88 |
row = r;
|
|
Jeremy Bullock |
c13d88 |
bool found = false;
|
|
Jeremy Bullock |
c13d88 |
for (int i = 0; i < emptyCells.size(); i++) {
|
|
Jeremy Bullock |
c13d88 |
if (emptyCells[i].first == row && emptyCells[i].second == col) {
|
|
Jeremy Bullock |
c13d88 |
xsh->clearCells(row, col);
|
|
Jeremy Bullock |
c13d88 |
found = true;
|
|
Jeremy Bullock |
c13d88 |
}
|
|
Jeremy Bullock |
c13d88 |
}
|
|
Jeremy Bullock |
c13d88 |
if (found) {
|
|
Jeremy Bullock |
c13d88 |
r++;
|
|
Jeremy Bullock |
c13d88 |
continue;
|
|
Jeremy Bullock |
c13d88 |
}
|
|
Shinya Kitaoka |
473e70 |
changeDrawing(-m_direction, row, col);
|
|
Shinya Kitaoka |
473e70 |
r++;
|
|
Shinya Kitaoka |
473e70 |
}
|
|
Shinya Kitaoka |
473e70 |
r = m_range.m_r0;
|
|
Shinya Kitaoka |
473e70 |
c++;
|
|
Shinya Kitaoka |
473e70 |
}
|
|
snapai |
254fd1 |
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
|
|
snapai |
254fd1 |
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
|
|
Shinya Kitaoka |
473e70 |
}
|
|
Shinya Kitaoka |
473e70 |
|
|
Shinya Kitaoka |
473e70 |
void redo() const override {
|
|
Shinya Kitaoka |
473e70 |
if (!m_selected) {
|
|
Shinya Kitaoka |
473e70 |
changeDrawing(m_direction, m_row, m_col);
|
|
snapai |
254fd1 |
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
|
|
snapai |
254fd1 |
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
|
|
Shinya Kitaoka |
473e70 |
return;
|
|
Shinya Kitaoka |
473e70 |
}
|
|
Shinya Kitaoka |
38fd86 |
|
|
Shinya Kitaoka |
473e70 |
int col, row;
|
|
Shinya Kitaoka |
473e70 |
int c = m_range.m_c0;
|
|
Shinya Kitaoka |
473e70 |
int r = m_range.m_r0;
|
|
Shinya Kitaoka |
38fd86 |
while (c <= m_range.m_c1) {
|
|
Shinya Kitaoka |
473e70 |
col = c;
|
|
Shinya Kitaoka |
38fd86 |
while (r <= m_range.m_r1) {
|
|
Shinya Kitaoka |
473e70 |
row = r;
|
|
Shinya Kitaoka |
473e70 |
changeDrawing(m_direction, row, col);
|
|
Shinya Kitaoka |
473e70 |
r++;
|
|
Shinya Kitaoka |
473e70 |
}
|
|
Shinya Kitaoka |
473e70 |
r = m_range.m_r0;
|
|
Shinya Kitaoka |
473e70 |
c++;
|
|
Shinya Kitaoka |
473e70 |
}
|
|
snapai |
254fd1 |
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
|
|
snapai |
254fd1 |
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
|
|
Shinya Kitaoka |
473e70 |
}
|
|
Shinya Kitaoka |
473e70 |
|
|
Shinya Kitaoka |
38fd86 |
int getSize() const override { return sizeof(*this); }
|
|
Shinya Kitaoka |
473e70 |
|
|
Shinya Kitaoka |
473e70 |
QString getHistoryString() override {
|
|
Shinya Kitaoka |
38fd86 |
return QObject::tr("Change current drawing %1")
|
|
Shinya Kitaoka |
38fd86 |
.arg(QString::number(m_direction));
|
|
Shinya Kitaoka |
473e70 |
}
|
|
Shinya Kitaoka |
473e70 |
|
|
Shinya Kitaoka |
38fd86 |
int getHistoryType() override { return HistoryType::Xsheet; }
|
|
turtletooth |
48def2 |
|
|
Shinya Kitaoka |
38fd86 |
protected:
|
|
Shinya Kitaoka |
473e70 |
static bool changeDrawing(int delta, int row, int col);
|
|
Jeremy Bullock |
c13d88 |
static void setDrawing(const TFrameId &fid, int row, int col, TXshCell cell,
|
|
Jeremy Bullock |
c13d88 |
TXshLevel *level);
|
|
Shinya Kitaoka |
473e70 |
friend class DrawingSubtitutionGroupUndo;
|
|
turtletooth |
48def2 |
};
|
|
turtletooth |
48def2 |
|
|
turtletooth |
48def2 |
//============================================================
|
|
turtletooth |
48def2 |
|
|
Shinya Kitaoka |
d1f6c4 |
class DrawingSubtitutionGroupUndo final : public TUndo {
|
|
turtletooth |
48def2 |
private:
|
|
Shinya Kitaoka |
473e70 |
int m_direction;
|
|
Shinya Kitaoka |
473e70 |
int m_row;
|
|
Shinya Kitaoka |
473e70 |
int m_col;
|
|
Shinya Kitaoka |
473e70 |
int m_count;
|
|
manongjohn |
01e8e7 |
bool m_selected;
|
|
manongjohn |
01e8e7 |
TCellSelection::Range m_range;
|
|
manongjohn |
01e8e7 |
std::vector<std::pair<int, int="">> emptyCells;</std::pair<int,>
|
|
manongjohn |
01e8e7 |
typedef std::map<std::pair<int, int="">, int> FramesMap;</std::pair<int,>
|
|
manongjohn |
01e8e7 |
FramesMap m_frameRanges;
|
|
turtletooth |
48def2 |
|
|
turtletooth |
48def2 |
public:
|
|
manongjohn |
01e8e7 |
DrawingSubtitutionGroupUndo(int dir, int row, int col, bool selected,
|
|
manongjohn |
01e8e7 |
TCellSelection::Range range)
|
|
manongjohn |
01e8e7 |
: m_direction(dir)
|
|
manongjohn |
01e8e7 |
, m_col(col)
|
|
manongjohn |
01e8e7 |
, m_row(row)
|
|
manongjohn |
01e8e7 |
, m_selected(selected)
|
|
manongjohn |
01e8e7 |
, m_range(range) {
|
|
manongjohn |
01e8e7 |
TXsheet *xsh =
|
|
manongjohn |
01e8e7 |
TTool::getApplication()->getCurrentScene()->getScene()->getXsheet();
|
|
manongjohn |
01e8e7 |
|
|
manongjohn |
01e8e7 |
if (!selected) {
|
|
manongjohn |
01e8e7 |
m_range.m_c0 = col;
|
|
manongjohn |
01e8e7 |
m_range.m_r0 = row;
|
|
manongjohn |
01e8e7 |
m_range.m_c1 = col;
|
|
manongjohn |
01e8e7 |
m_range.m_r1 = row;
|
|
manongjohn |
01e8e7 |
}
|
|
Shinya Kitaoka |
473e70 |
|
|
manongjohn |
01e8e7 |
for (int c = m_range.m_c0; c <= m_range.m_c1; c++) {
|
|
manongjohn |
01e8e7 |
for (int r = m_range.m_r0; r <= m_range.m_r1; r++) {
|
|
manongjohn |
01e8e7 |
TXshCell baseCell = xsh->getCell(r, c);
|
|
manongjohn |
01e8e7 |
|
|
manongjohn |
01e8e7 |
// Find the 1st populated cell in the column
|
|
manongjohn |
01e8e7 |
if (baseCell.isEmpty()) continue;
|
|
Shinya Kitaoka |
473e70 |
|
|
manongjohn |
01e8e7 |
FramesMap::key_type frameBaseKey(r, c);
|
|
manongjohn |
01e8e7 |
int frameCount = 1;
|
|
manongjohn |
01e8e7 |
TXshCell nextCell = xsh->getCell((r + frameCount), c);
|
|
manongjohn |
01e8e7 |
while (nextCell == baseCell ||
|
|
manongjohn |
01e8e7 |
(nextCell.isEmpty() && (r + frameCount) <= m_range.m_r1)) {
|
|
manongjohn |
01e8e7 |
if (nextCell.isEmpty())
|
|
manongjohn |
01e8e7 |
emptyCells.push_back(std::make_pair((r + frameCount), c));
|
|
Shinya Kitaoka |
473e70 |
|
|
manongjohn |
01e8e7 |
frameCount++;
|
|
manongjohn |
01e8e7 |
nextCell = xsh->getCell((r + frameCount), c);
|
|
manongjohn |
01e8e7 |
}
|
|
manongjohn |
01e8e7 |
m_frameRanges.insert(std::make_pair(frameBaseKey, 0));
|
|
manongjohn |
01e8e7 |
m_frameRanges[frameBaseKey] = frameCount;
|
|
manongjohn |
01e8e7 |
r = r + (frameCount - 1); // Skip frames in range we've processed
|
|
manongjohn |
01e8e7 |
}
|
|
Shinya Kitaoka |
473e70 |
}
|
|
Shinya Kitaoka |
473e70 |
}
|
|
Shinya Kitaoka |
473e70 |
|
|
Shinya Kitaoka |
473e70 |
void undo() const override {
|
|
manongjohn |
01e8e7 |
TXsheet *xsh =
|
|
manongjohn |
01e8e7 |
TTool::getApplication()->getCurrentScene()->getScene()->getXsheet();
|
|
manongjohn |
01e8e7 |
FramesMap::const_iterator ct;
|
|
manongjohn |
01e8e7 |
for (ct = m_frameRanges.begin(); ct != m_frameRanges.end(); ++ct) {
|
|
manongjohn |
01e8e7 |
int n = 0;
|
|
manongjohn |
01e8e7 |
while (n < ct->second) {
|
|
manongjohn |
01e8e7 |
int row = ct->first.first + n;
|
|
manongjohn |
01e8e7 |
int col = ct->first.second;
|
|
manongjohn |
01e8e7 |
std::vector<std::pair<int, int="">>::const_iterator it;</std::pair<int,>
|
|
manongjohn |
01e8e7 |
bool found = false;
|
|
manongjohn |
01e8e7 |
for (it = emptyCells.begin(); it != emptyCells.end(); ++it) {
|
|
manongjohn |
01e8e7 |
if (it->first == row && it->second == col) {
|
|
manongjohn |
01e8e7 |
xsh->clearCells(row, col);
|
|
manongjohn |
01e8e7 |
found = true;
|
|
manongjohn |
01e8e7 |
}
|
|
manongjohn |
01e8e7 |
}
|
|
manongjohn |
01e8e7 |
|
|
manongjohn |
01e8e7 |
if (!found)
|
|
manongjohn |
01e8e7 |
DrawingSubtitutionUndo::changeDrawing(-m_direction, row, col);
|
|
manongjohn |
01e8e7 |
n++;
|
|
manongjohn |
01e8e7 |
}
|
|
Shinya Kitaoka |
473e70 |
}
|
|
manongjohn |
01e8e7 |
|
|
snapai |
254fd1 |
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
|
|
snapai |
254fd1 |
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
|
|
Shinya Kitaoka |
473e70 |
}
|
|
Shinya Kitaoka |
473e70 |
|
|
Shinya Kitaoka |
473e70 |
void redo() const override {
|
|
manongjohn |
01e8e7 |
FramesMap::const_iterator ct;
|
|
manongjohn |
01e8e7 |
for (ct = m_frameRanges.begin(); ct != m_frameRanges.end(); ++ct) {
|
|
manongjohn |
01e8e7 |
int n = 0;
|
|
manongjohn |
01e8e7 |
while (n < ct->second) {
|
|
manongjohn |
01e8e7 |
int row = ct->first.first + n;
|
|
manongjohn |
01e8e7 |
int col = ct->first.second;
|
|
manongjohn |
01e8e7 |
DrawingSubtitutionUndo::changeDrawing(m_direction, row, col);
|
|
manongjohn |
01e8e7 |
n++;
|
|
manongjohn |
01e8e7 |
}
|
|
Shinya Kitaoka |
473e70 |
}
|
|
snapai |
254fd1 |
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
|
|
snapai |
254fd1 |
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
|
|
Shinya Kitaoka |
473e70 |
}
|
|
Shinya Kitaoka |
473e70 |
|
|
Shinya Kitaoka |
38fd86 |
int getSize() const override { return sizeof(*this); }
|
|
Shinya Kitaoka |
473e70 |
|
|
Shinya Kitaoka |
473e70 |
QString getHistoryString() override {
|
|
Shinya Kitaoka |
38fd86 |
return QObject::tr("Change current drawing %1")
|
|
Shinya Kitaoka |
38fd86 |
.arg(QString::number(m_direction));
|
|
Shinya Kitaoka |
473e70 |
}
|
|
turtletooth |
48def2 |
|
|
Shinya Kitaoka |
38fd86 |
int getHistoryType() override { return HistoryType::Xsheet; }
|
|
turtletooth |
48def2 |
};
|
|
turtletooth |
48def2 |
|
|
turtletooth |
48def2 |
//============================================================
|
|
turtletooth |
48def2 |
|
|
turtletooth |
48def2 |
bool DrawingSubtitutionUndo::changeDrawing(int delta, int row, int col) {
|
|
Shinya Kitaoka |
38fd86 |
TTool::Application *app = TTool::getApplication();
|
|
Shinya Kitaoka |
38fd86 |
TXsheet *xsh = app->getCurrentScene()->getScene()->getXsheet();
|
|
Shinya Kitaoka |
38fd86 |
TXshCell cell = xsh->getCell(row, col);
|
|
Jeremy Bullock |
c13d88 |
bool usePrevCell = false;
|
|
Jeremy Bullock |
c13d88 |
if (cell.isEmpty()) {
|
|
Jeremy Bullock |
c13d88 |
TXshCell prevCell = xsh->getCell(row - 1, col);
|
|
shun-iwasawa |
8fb291 |
if (prevCell.isEmpty() || !(prevCell.m_level->getSimpleLevel() ||
|
|
shun-iwasawa |
8fb291 |
prevCell.m_level->getChildLevel() ||
|
|
shun-iwasawa |
8fb291 |
prevCell.m_level->getSoundTextLevel()))
|
|
Jeremy Bullock |
c13d88 |
return false;
|
|
Jeremy Bullock |
c13d88 |
cell = prevCell;
|
|
Jeremy Bullock |
c13d88 |
usePrevCell = true;
|
|
shun-iwasawa |
8fb291 |
} else if (!cell.m_level || !(cell.m_level->getSimpleLevel() ||
|
|
shun-iwasawa |
8fb291 |
cell.m_level->getChildLevel() ||
|
|
shun-iwasawa |
8fb291 |
cell.m_level->getSoundTextLevel()))
|
|
Jeremy Bullock |
c13d88 |
return false;
|
|
shun-iwasawa |
8fb291 |
TXshLevel *level = cell.m_level->getSimpleLevel();
|
|
Jeremy Bullock |
c13d88 |
if (!level) level = cell.m_level->getChildLevel();
|
|
Jeremy Bullock |
c13d88 |
if (!level) level = cell.m_level->getSoundTextLevel();
|
|
turtletooth |
48def2 |
|
|
Shinya Kitaoka |
38fd86 |
std::vector<tframeid> fids;</tframeid>
|
|
Jeremy Bullock |
c13d88 |
int framesTextSize = 0;
|
|
Jeremy Bullock |
c13d88 |
int n, index;
|
|
Jeremy Bullock |
c13d88 |
bool usingSoundText = false;
|
|
Jeremy Bullock |
c13d88 |
TFrameId cellFrameId;
|
|
Jeremy Bullock |
c13d88 |
if (cell.m_level->getSimpleLevel())
|
|
Jeremy Bullock |
c13d88 |
cell.m_level->getSimpleLevel()->getFids(fids);
|
|
Jeremy Bullock |
c13d88 |
if (cell.m_level->getChildLevel())
|
|
Jeremy Bullock |
c13d88 |
cell.m_level->getChildLevel()->getFids(fids);
|
|
Jeremy Bullock |
c13d88 |
if (cell.m_level->getSoundTextLevel()) {
|
|
Jeremy Bullock |
c13d88 |
n = cell.m_level->getSoundTextLevel()->m_framesText.size();
|
|
Jeremy Bullock |
c13d88 |
usingSoundText = true;
|
|
Jeremy Bullock |
c13d88 |
} else
|
|
Jeremy Bullock |
c13d88 |
n = fids.size();
|
|
Shinya Kitaoka |
473e70 |
|
|
Shinya Kitaoka |
38fd86 |
if (n < 2) return false;
|
|
Shinya Kitaoka |
38fd86 |
|
|
Jeremy Bullock |
c13d88 |
if (!usingSoundText) {
|
|
Jeremy Bullock |
c13d88 |
std::vector<tframeid>::iterator it;</tframeid>
|
|
Jeremy Bullock |
c13d88 |
it = std::find(fids.begin(), fids.end(), cell.m_frameId);
|
|
Shinya Kitaoka |
38fd86 |
|
|
Jeremy Bullock |
c13d88 |
if (it == fids.end()) return false;
|
|
Shinya Kitaoka |
38fd86 |
|
|
Jeremy Bullock |
c13d88 |
index = std::distance(fids.begin(), it);
|
|
Jeremy Bullock |
c13d88 |
} else
|
|
Jeremy Bullock |
c13d88 |
index = cell.getFrameId().getNumber();
|
|
Jeremy Bullock |
c13d88 |
|
|
Jeremy Bullock |
c13d88 |
if (usePrevCell) {
|
|
Jeremy Bullock |
c13d88 |
index -= delta;
|
|
Jeremy Bullock |
c13d88 |
cell = xsh->getCell(row, col);
|
|
Jeremy Bullock |
c13d88 |
}
|
|
Jeremy Bullock |
c13d88 |
|
|
Jeremy Bullock |
c13d88 |
// if negative direction, add the size to the direction to avoid a negative
|
|
Jeremy Bullock |
c13d88 |
// modulo
|
|
Shinya Kitaoka |
38fd86 |
while (delta < 0) delta += n;
|
|
Jeremy Bullock |
c13d88 |
// the index is the remainder
|
|
Shinya Kitaoka |
38fd86 |
index = (index + delta) % n;
|
|
Jeremy Bullock |
c13d88 |
assert(index < n);
|
|
Jeremy Bullock |
c13d88 |
|
|
Jeremy Bullock |
c13d88 |
// sound text levels can't have a 0 index frame id
|
|
Jeremy Bullock |
c13d88 |
// the index points to a qlist<qstring></qstring>
|
|
Jeremy Bullock |
c13d88 |
// reading 1 below the frameid number
|
|
Jeremy Bullock |
c13d88 |
// and you can't have a -1 index on a qlist
|
|
Jeremy Bullock |
c13d88 |
if (usingSoundText && index == 0) index = n;
|
|
Jeremy Bullock |
c13d88 |
|
|
Jeremy Bullock |
c13d88 |
if (!usingSoundText)
|
|
Jeremy Bullock |
c13d88 |
cellFrameId = fids[index];
|
|
Jeremy Bullock |
c13d88 |
else
|
|
Jeremy Bullock |
c13d88 |
cellFrameId = TFrameId(index);
|
|
Shinya Kitaoka |
38fd86 |
|
|
Jeremy Bullock |
c13d88 |
setDrawing(cellFrameId, row, col, cell, level);
|
|
Shinya Kitaoka |
d1f6c4 |
|
|
Shinya Kitaoka |
d1f6c4 |
return true;
|
|
Shinya Kitaoka |
38fd86 |
}
|
|
Shinya Kitaoka |
38fd86 |
|
|
Shinya Kitaoka |
38fd86 |
void DrawingSubtitutionUndo::setDrawing(const TFrameId &fid, int row, int col,
|
|
Jeremy Bullock |
c13d88 |
TXshCell cell, TXshLevel *level) {
|
|
Shinya Kitaoka |
38fd86 |
TTool::Application *app = TTool::getApplication();
|
|
Shinya Kitaoka |
38fd86 |
TXsheet *xsh = app->getCurrentScene()->getScene()->getXsheet();
|
|
Shinya Kitaoka |
38fd86 |
cell.m_frameId = fid;
|
|
Jeremy Bullock |
c13d88 |
cell.m_level = level;
|
|
Shinya Kitaoka |
38fd86 |
xsh->setCell(row, col, cell);
|
|
Shinya Kitaoka |
38fd86 |
TStageObject *pegbar = xsh->getStageObject(TStageObjectId::ColumnId(col));
|
|
Shinya Kitaoka |
38fd86 |
pegbar->setOffset(pegbar->getOffset());
|
|
turtletooth |
48def2 |
}
|
|
turtletooth |
48def2 |
|
|
turtletooth |
48def2 |
//-----------------------------------------------------------------------------
|
|
turtletooth |
48def2 |
|
|
Campbell Barton |
ccd505 |
static void drawingSubstituion(int dir) {
|
|
Shinya Kitaoka |
38fd86 |
TCellSelection *selection = dynamic_cast<tcellselection *="">(</tcellselection>
|
|
Shinya Kitaoka |
38fd86 |
TTool::getApplication()->getCurrentSelection()->getSelection());
|
|
Shinya Kitaoka |
473e70 |
TCellSelection::Range range;
|
|
Shinya Kitaoka |
473e70 |
bool selected = false;
|
|
Shinya Kitaoka |
473e70 |
if (selection) {
|
|
shun-iwasawa |
8fb291 |
range = selection->getSelectedCells();
|
|
Shinya Kitaoka |
38fd86 |
if (!(range.isEmpty())) selected = true;
|
|
Shinya Kitaoka |
473e70 |
}
|
|
Shinya Kitaoka |
473e70 |
int row = TTool::getApplication()->getCurrentFrame()->getFrame();
|
|
Shinya Kitaoka |
473e70 |
int col = TTool::getApplication()->getCurrentColumn()->getColumnIndex();
|
|
Shinya Kitaoka |
38fd86 |
|
|
Shinya Kitaoka |
38fd86 |
DrawingSubtitutionUndo *undo =
|
|
Shinya Kitaoka |
38fd86 |
new DrawingSubtitutionUndo(dir, range, row, col, selected);
|
|
Shinya Kitaoka |
473e70 |
TUndoManager::manager()->add(undo);
|
|
Shinya Kitaoka |
473e70 |
|
|
Shinya Kitaoka |
473e70 |
undo->redo();
|
|
turtletooth |
48def2 |
}
|
|
turtletooth |
48def2 |
|
|
Campbell Barton |
ccd505 |
static void drawingSubstituionGroup(int dir) {
|
|
manongjohn |
01e8e7 |
TCellSelection *selection = dynamic_cast<tcellselection *="">(</tcellselection>
|
|
manongjohn |
01e8e7 |
TTool::getApplication()->getCurrentSelection()->getSelection());
|
|
manongjohn |
01e8e7 |
TCellSelection::Range range;
|
|
manongjohn |
01e8e7 |
bool selected = false;
|
|
manongjohn |
01e8e7 |
if (selection) {
|
|
shun-iwasawa |
8fb291 |
range = selection->getSelectedCells();
|
|
manongjohn |
01e8e7 |
if (!(range.isEmpty())) selected = true;
|
|
manongjohn |
01e8e7 |
}
|
|
Shinya Kitaoka |
473e70 |
int row = TTool::getApplication()->getCurrentFrame()->getFrame();
|
|
Shinya Kitaoka |
473e70 |
int col = TTool::getApplication()->getCurrentColumn()->getColumnIndex();
|
|
manongjohn |
01e8e7 |
|
|
Shinya Kitaoka |
38fd86 |
DrawingSubtitutionGroupUndo *undo =
|
|
manongjohn |
01e8e7 |
new DrawingSubtitutionGroupUndo(dir, row, col, selected, range);
|
|
Shinya Kitaoka |
473e70 |
TUndoManager::manager()->add(undo);
|
|
Shinya Kitaoka |
473e70 |
undo->redo();
|
|
turtletooth |
48def2 |
}
|
|
turtletooth |
48def2 |
|
|
turtletooth |
48def2 |
//=============================================================================
|
|
turtletooth |
48def2 |
|
|
Shinya Kitaoka |
d1f6c4 |
class DrawingSubstitutionForwardCommand final : public MenuItemHandler {
|
|
turtletooth |
48def2 |
public:
|
|
Shinya Kitaoka |
473e70 |
DrawingSubstitutionForwardCommand() : MenuItemHandler(MI_DrawingSubForward) {}
|
|
Shinya Kitaoka |
38fd86 |
void execute() override { XshCmd::drawingSubstituion(1); }
|
|
turtletooth |
48def2 |
} DrawingSubstitutionForwardCommand;
|
|
turtletooth |
48def2 |
|
|
turtletooth |
48def2 |
//============================================================
|
|
turtletooth |
48def2 |
|
|
Shinya Kitaoka |
d1f6c4 |
class DrawingSubstitutionBackwardCommand final : public MenuItemHandler {
|
|
turtletooth |
48def2 |
public:
|
|
Shinya Kitaoka |
38fd86 |
DrawingSubstitutionBackwardCommand()
|
|
Shinya Kitaoka |
38fd86 |
: MenuItemHandler(MI_DrawingSubBackward) {}
|
|
Shinya Kitaoka |
38fd86 |
void execute() override { XshCmd::drawingSubstituion(-1); }
|
|
turtletooth |
48def2 |
} DrawingSubstitutionBackwardCommand;
|
|
turtletooth |
48def2 |
|
|
turtletooth |
48def2 |
//=============================================================================
|
|
turtletooth |
48def2 |
|
|
Shinya Kitaoka |
d1f6c4 |
class DrawingSubstitutionGroupForwardCommand final : public MenuItemHandler {
|
|
turtletooth |
48def2 |
public:
|
|
Shinya Kitaoka |
38fd86 |
DrawingSubstitutionGroupForwardCommand()
|
|
Shinya Kitaoka |
38fd86 |
: MenuItemHandler(MI_DrawingSubGroupForward) {}
|
|
Shinya Kitaoka |
38fd86 |
void execute() override { XshCmd::drawingSubstituionGroup(1); }
|
|
turtletooth |
48def2 |
} DrawingSubstitutionGroupForwardCommand;
|
|
turtletooth |
48def2 |
|
|
turtletooth |
48def2 |
//============================================================
|
|
turtletooth |
48def2 |
|
|
Shinya Kitaoka |
d1f6c4 |
class DrawingSubstitutionGroupBackwardCommand final : public MenuItemHandler {
|
|
turtletooth |
48def2 |
public:
|
|
Shinya Kitaoka |
38fd86 |
DrawingSubstitutionGroupBackwardCommand()
|
|
Shinya Kitaoka |
38fd86 |
: MenuItemHandler(MI_DrawingSubGroupBackward) {}
|
|
Shinya Kitaoka |
38fd86 |
void execute() override { XshCmd::drawingSubstituionGroup(-1); }
|
|
turtletooth |
48def2 |
} DrawingSubstitutionGroupBackwardCommand;
|
|
turtletooth |
48def2 |
|
|
turtletooth |
48def2 |
//============================================================
|
|
turtletooth |
48def2 |
|
|
Jeremy Bullock |
52a220 |
class NewNoteLevelUndo final : public TUndo {
|
|
Jeremy Bullock |
52a220 |
TXshSoundTextColumnP m_soundtextColumn;
|
|
Jeremy Bullock |
52a220 |
int m_col;
|
|
Jeremy Bullock |
52a220 |
QString m_columnName;
|
|
Jeremy Bullock |
52a220 |
|
|
Jeremy Bullock |
52a220 |
public:
|
|
Jeremy Bullock |
52a220 |
NewNoteLevelUndo(TXshSoundTextColumn *soundtextColumn, int col,
|
|
Jeremy Bullock |
52a220 |
QString columnName)
|
|
Jeremy Bullock |
52a220 |
: m_soundtextColumn(soundtextColumn)
|
|
Jeremy Bullock |
52a220 |
, m_col(col)
|
|
Jeremy Bullock |
52a220 |
, m_columnName(columnName) {}
|
|
Jeremy Bullock |
52a220 |
|
|
Jeremy Bullock |
52a220 |
void undo() const override {
|
|
Jeremy Bullock |
52a220 |
TApp *app = TApp::instance();
|
|
Jeremy Bullock |
52a220 |
TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
|
|
Jeremy Bullock |
52a220 |
xsh->removeColumn(m_col);
|
|
Jeremy Bullock |
52a220 |
app->getCurrentXsheet()->notifyXsheetChanged();
|
|
Jeremy Bullock |
52a220 |
}
|
|
Jeremy Bullock |
52a220 |
|
|
Jeremy Bullock |
52a220 |
void redo() const override {
|
|
Jeremy Bullock |
52a220 |
TApp *app = TApp::instance();
|
|
Jeremy Bullock |
52a220 |
TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
|
|
Jeremy Bullock |
52a220 |
xsh->insertColumn(m_col, m_soundtextColumn.getPointer());
|
|
Jeremy Bullock |
52a220 |
|
|
Jeremy Bullock |
52a220 |
TStageObject *obj = xsh->getStageObject(TStageObjectId::ColumnId(m_col));
|
|
Jeremy Bullock |
52a220 |
std::string str = m_columnName.toStdString();
|
|
Jeremy Bullock |
52a220 |
obj->setName(str);
|
|
Jeremy Bullock |
52a220 |
|
|
Jeremy Bullock |
52a220 |
app->getCurrentXsheet()->notifyXsheetChanged();
|
|
Jeremy Bullock |
52a220 |
}
|
|
Jeremy Bullock |
52a220 |
|
|
Jeremy Bullock |
52a220 |
int getSize() const override { return sizeof(*this); }
|
|
Jeremy Bullock |
52a220 |
|
|
Jeremy Bullock |
52a220 |
QString getHistoryString() override { return QObject::tr("New Note Level"); }
|
|
Jeremy Bullock |
52a220 |
|
|
Jeremy Bullock |
52a220 |
int getHistoryType() override { return HistoryType::Xsheet; }
|
|
Jeremy Bullock |
52a220 |
};
|
|
Jeremy Bullock |
52a220 |
|
|
Jeremy Bullock |
52a220 |
//============================================================
|
|
Jeremy Bullock |
52a220 |
|
|
Jeremy Bullock |
52a220 |
static void newNoteLevel() {
|
|
Jeremy Bullock |
52a220 |
TTool::Application *app = TTool::getApplication();
|
|
Jeremy Bullock |
52a220 |
TXsheet *xsh = app->getCurrentScene()->getScene()->getXsheet();
|
|
Jeremy Bullock |
52a220 |
int col = TTool::getApplication()->getCurrentColumn()->getColumnIndex();
|
|
John Dancel |
421acd |
if (col < 0)
|
|
John Dancel |
421acd |
col = 0; // Normally insert before. In case of camera, insert after
|
|
Jeremy Bullock |
52a220 |
TXshSoundTextColumn *textSoundCol = new TXshSoundTextColumn();
|
|
Jeremy Bullock |
52a220 |
|
|
Jeremy Bullock |
52a220 |
textSoundCol->setXsheet(xsh);
|
|
Jeremy Bullock |
52a220 |
QList<qstring> textList;</qstring>
|
|
Jeremy Bullock |
52a220 |
textList << " ";
|
|
Jeremy Bullock |
52a220 |
textSoundCol->createSoundTextLevel(0, textList);
|
|
Jeremy Bullock |
52a220 |
xsh->insertColumn(col, textSoundCol);
|
|
Jeremy Bullock |
52a220 |
|
|
Jeremy Bullock |
52a220 |
// name the level a unique NoteLevel number
|
|
Jeremy Bullock |
52a220 |
TStageObjectTree *objects = xsh->getStageObjectTree();
|
|
Jeremy Bullock |
52a220 |
int objectCount = objects->getStageObjectCount();
|
|
Jeremy Bullock |
52a220 |
int maxTextColumns = 1;
|
|
Jeremy Bullock |
52a220 |
for (int i = 0; i < objectCount; i++) {
|
|
Jeremy Bullock |
52a220 |
TStageObject *object = objects->getStageObject(i);
|
|
Jeremy Bullock |
52a220 |
std::string objName = object->getName();
|
|
Jeremy Bullock |
52a220 |
int pos = objName.find("NoteLevel");
|
|
Jeremy Bullock |
52a220 |
if (pos != std::string::npos && pos == 0) {
|
|
Jeremy Bullock |
52a220 |
std::string currStrCount = objName.substr(9);
|
|
Jeremy Bullock |
52a220 |
bool ok;
|
|
Jeremy Bullock |
52a220 |
int currCount = QString::fromStdString(currStrCount).toInt(&ok);
|
|
Jeremy Bullock |
52a220 |
if (ok && currCount >= maxTextColumns) {
|
|
Jeremy Bullock |
52a220 |
maxTextColumns = currCount + 1;
|
|
Jeremy Bullock |
52a220 |
}
|
|
Jeremy Bullock |
52a220 |
}
|
|
Jeremy Bullock |
52a220 |
}
|
|
Jeremy Bullock |
52a220 |
TStageObject *obj = xsh->getStageObject(TStageObjectId::ColumnId(col));
|
|
Jeremy Bullock |
52a220 |
QString str = "NoteLevel" + QString::number(maxTextColumns);
|
|
Jeremy Bullock |
52a220 |
obj->setName(str.toStdString());
|
|
Jeremy Bullock |
52a220 |
|
|
Jeremy Bullock |
52a220 |
TUndoManager::manager()->add(new NewNoteLevelUndo(textSoundCol, col, str));
|
|
manongjohn |
2e094e |
|
|
manongjohn |
2e094e |
TXsheetHandle *xshHandle = app->getCurrentXsheet();
|
|
manongjohn |
2e094e |
xshHandle->notifyXsheetChanged();
|
|
Jeremy Bullock |
52a220 |
}
|
|
Jeremy Bullock |
52a220 |
|
|
Jeremy Bullock |
52a220 |
//============================================================
|
|
Jeremy Bullock |
52a220 |
|
|
Jeremy Bullock |
52a220 |
class NewNoteLevelCommand final : public MenuItemHandler {
|
|
Jeremy Bullock |
52a220 |
public:
|
|
Jeremy Bullock |
52a220 |
NewNoteLevelCommand() : MenuItemHandler(MI_NewNoteLevel) {}
|
|
Jeremy Bullock |
52a220 |
void execute() override { XshCmd::newNoteLevel(); }
|
|
Jeremy Bullock |
52a220 |
} NewNoteLevelCommand;
|
|
Jeremy Bullock |
52a220 |
|
|
Jeremy Bullock |
52a220 |
//============================================================
|
|
Jeremy Bullock |
52a220 |
|
|
manongjohn |
2e094e |
static void removeEmptyColumns() {
|
|
manongjohn |
2e094e |
TTool::Application *app = TTool::getApplication();
|
|
manongjohn |
2e094e |
TXsheet *xsh = app->getCurrentScene()->getScene()->getXsheet();
|
|
manongjohn |
2e094e |
std::set<int> indices;</int>
|
|
manongjohn |
2e094e |
|
|
manongjohn |
2e094e |
for (int i = 0; i < xsh->getColumnCount(); i++) {
|
|
manongjohn |
2e094e |
TXshColumn *column = xsh->getColumn(i);
|
|
manongjohn |
2e094e |
if (!column || column->isEmpty()) indices.insert(i);
|
|
manongjohn |
2e094e |
}
|
|
manongjohn |
2e094e |
|
|
shun-iwasawa |
4a3868 |
if (indices.empty()) return;
|
|
shun-iwasawa |
4a3868 |
if (!ColumnCmd::checkExpressionReferences(indices)) return;
|
|
shun-iwasawa |
4a3868 |
|
|
shun-iwasawa |
4a3868 |
ColumnCmd::deleteColumns(indices, false, false);
|
|
manongjohn |
2e094e |
|
|
manongjohn |
2e094e |
app->getCurrentXsheet()->notifyXsheetChanged();
|
|
manongjohn |
2e094e |
}
|
|
manongjohn |
2e094e |
|
|
manongjohn |
2e094e |
class RemoveEmptyColumnsCommand final : public MenuItemHandler {
|
|
manongjohn |
2e094e |
public:
|
|
manongjohn |
2e094e |
RemoveEmptyColumnsCommand() : MenuItemHandler(MI_RemoveEmptyColumns) {}
|
|
manongjohn |
2e094e |
void execute() override { XshCmd::removeEmptyColumns(); }
|
|
manongjohn |
2e094e |
} RemoveEmptyColumnsCommand;
|
|
manongjohn |
2e094e |
|
|
manongjohn |
2e094e |
//============================================================
|
|
manongjohn |
2e094e |
|
|
Shinya Kitaoka |
38fd86 |
} // namespace XshCmd
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Selection commands
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class SelectRowKeyframesCommand final : public MenuItemHandler {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
SelectRowKeyframesCommand() : MenuItemHandler(MI_SelectRowKeyframes) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void execute() override {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TKeyframeSelection *selection = dynamic_cast<tkeyframeselection *="">(</tkeyframeselection>
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentSelection()->getSelection());
|
|
manongjohn |
7d6ab3 |
if (!selection) return;
|
|
Shinya Kitaoka |
120a6e |
int row = app->getCurrentFrame()->getFrame();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
selection->selectNone();
|
|
Shinya Kitaoka |
120a6e |
ToonzScene *scene = app->getCurrentScene()->getScene();
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = scene->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
int col;
|
|
Shinya Kitaoka |
120a6e |
for (col = -1; col < xsh->getColumnCount(); col++) {
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objectId;
|
|
manongjohn |
3fe913 |
if (col == -1 && Preferences::instance()->isXsheetCameraColumnVisible())
|
|
John Dancel |
c323ac |
objectId = TStageObjectId::CameraId(xsh->getCameraColumnIndex());
|
|
Shinya Kitaoka |
120a6e |
else
|
|
shun-iwasawa |
8fb291 |
objectId = TStageObjectId::ColumnId(col);
|
|
Shinya Kitaoka |
120a6e |
TStageObject *pegbar = xsh->getStageObject(objectId);
|
|
Shinya Kitaoka |
120a6e |
if (pegbar->isKeyframe(row)) selection->select(row, col);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentXsheet()->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} SelectRowKeyframesCommand;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class SelectColumnKeyframesCommand final : public MenuItemHandler {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
SelectColumnKeyframesCommand() : MenuItemHandler(MI_SelectColumnKeyframes) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void execute() override {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
John Dancel |
c323ac |
ToonzScene *scene = app->getCurrentScene()->getScene();
|
|
John Dancel |
c323ac |
TXsheet *xsh = scene->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
TKeyframeSelection *selection = dynamic_cast<tkeyframeselection *="">(</tkeyframeselection>
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentSelection()->getSelection());
|
|
manongjohn |
7d6ab3 |
if (!selection) return;
|
|
Shinya Kitaoka |
120a6e |
int col = app->getCurrentColumn()->getColumnIndex();
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objectId = app->getCurrentObject()->getObjectId();
|
|
John Dancel |
c323ac |
if (app->getCurrentObject()->getObjectId() ==
|
|
John Dancel |
c323ac |
TStageObjectId::CameraId(xsh->getCameraColumnIndex())) {
|
|
John Dancel |
c323ac |
objectId = TStageObjectId::CameraId(xsh->getCameraColumnIndex());
|
|
Shinya Kitaoka |
120a6e |
col = -1;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
selection->selectNone();
|
|
Shinya Kitaoka |
120a6e |
TStageObject *pegbar = xsh->getStageObject(objectId);
|
|
Shinya Kitaoka |
120a6e |
TStageObject::KeyframeMap keyframes;
|
|
Shinya Kitaoka |
120a6e |
pegbar->getKeyframes(keyframes);
|
|
Shinya Kitaoka |
120a6e |
for (TStageObject::KeyframeMap::iterator it = keyframes.begin();
|
|
Shinya Kitaoka |
120a6e |
it != keyframes.end(); ++it)
|
|
Shinya Kitaoka |
120a6e |
selection->select(it->first, col);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentXsheet()->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
} SelectColumnKeyframesCommand;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class SelectAllKeyframesCommand final : public MenuItemHandler {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
SelectAllKeyframesCommand() : MenuItemHandler(MI_SelectAllKeyframes) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void execute() override {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TKeyframeSelection *selection = dynamic_cast<tkeyframeselection *="">(</tkeyframeselection>
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentSelection()->getSelection());
|
|
Shinya Kitaoka |
120a6e |
if (!selection) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
selection->selectNone();
|
|
Shinya Kitaoka |
120a6e |
ToonzScene *scene = app->getCurrentScene()->getScene();
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = scene->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
int col;
|
|
Shinya Kitaoka |
120a6e |
for (col = -1; col < xsh->getColumnCount(); col++) {
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objectId;
|
|
manongjohn |
3fe913 |
if (col == -1 && Preferences::instance()->isXsheetCameraColumnVisible())
|
|
John Dancel |
c323ac |
objectId = TStageObjectId::CameraId(xsh->getCameraColumnIndex());
|
|
Shinya Kitaoka |
120a6e |
else
|
|
shun-iwasawa |
8fb291 |
objectId = TStageObjectId::ColumnId(col);
|
|
Shinya Kitaoka |
120a6e |
TStageObject *pegbar = xsh->getStageObject(objectId);
|
|
Shinya Kitaoka |
120a6e |
TStageObject::KeyframeMap keyframes;
|
|
Shinya Kitaoka |
120a6e |
pegbar->getKeyframes(keyframes);
|
|
Shinya Kitaoka |
120a6e |
for (TStageObject::KeyframeMap::iterator it = keyframes.begin();
|
|
Shinya Kitaoka |
120a6e |
it != keyframes.end(); ++it) {
|
|
Shinya Kitaoka |
120a6e |
int row = it->first;
|
|
Shinya Kitaoka |
120a6e |
assert(pegbar->isKeyframe(row));
|
|
Shinya Kitaoka |
120a6e |
selection->select(row, col);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentXsheet()->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
} SelectAllKeyframesCommand;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class SelectAllKeyframesBeforeCommand final : public MenuItemHandler {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
SelectAllKeyframesBeforeCommand()
|
|
Shinya Kitaoka |
120a6e |
: MenuItemHandler(MI_SelectAllKeyframesNotBefore) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void execute() override {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TKeyframeSelection *selection = dynamic_cast<tkeyframeselection *="">(</tkeyframeselection>
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentSelection()->getSelection());
|
|
Shinya Kitaoka |
120a6e |
if (!selection) return;
|
|
Shinya Kitaoka |
120a6e |
int currentRow = app->getCurrentFrame()->getFrame();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
selection->selectNone();
|
|
Shinya Kitaoka |
120a6e |
ToonzScene *scene = app->getCurrentScene()->getScene();
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = scene->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
for (int col = -1; col < xsh->getColumnCount(); col++) {
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objectId;
|
|
manongjohn |
3fe913 |
if (col == -1 && Preferences::instance()->isXsheetCameraColumnVisible())
|
|
John Dancel |
c323ac |
objectId = TStageObjectId::CameraId(xsh->getCameraColumnIndex());
|
|
Shinya Kitaoka |
120a6e |
else
|
|
shun-iwasawa |
8fb291 |
objectId = TStageObjectId::ColumnId(col);
|
|
Shinya Kitaoka |
120a6e |
TStageObject *pegbar = xsh->getStageObject(objectId);
|
|
Shinya Kitaoka |
120a6e |
TStageObject::KeyframeMap keyframes;
|
|
Shinya Kitaoka |
120a6e |
pegbar->getKeyframes(keyframes);
|
|
Shinya Kitaoka |
120a6e |
for (TStageObject::KeyframeMap::iterator it = keyframes.begin();
|
|
Shinya Kitaoka |
120a6e |
it != keyframes.end(); ++it) {
|
|
Shinya Kitaoka |
120a6e |
int row = it->first;
|
|
Shinya Kitaoka |
120a6e |
if (row < currentRow) continue;
|
|
Shinya Kitaoka |
120a6e |
assert(pegbar->isKeyframe(row));
|
|
Shinya Kitaoka |
120a6e |
selection->select(row, col);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentXsheet()->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
} SelectAllKeyframesBeforeCommand;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class SelectAllKeyframesAfterCommand final : public MenuItemHandler {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
SelectAllKeyframesAfterCommand()
|
|
Shinya Kitaoka |
120a6e |
: MenuItemHandler(MI_SelectAllKeyframesNotAfter) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void execute() override {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TKeyframeSelection *selection = dynamic_cast<tkeyframeselection *="">(</tkeyframeselection>
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentSelection()->getSelection());
|
|
Shinya Kitaoka |
120a6e |
if (!selection) return;
|
|
Shinya Kitaoka |
120a6e |
int currentRow = app->getCurrentFrame()->getFrame();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
selection->selectNone();
|
|
Shinya Kitaoka |
120a6e |
ToonzScene *scene = app->getCurrentScene()->getScene();
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = scene->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
int col;
|
|
Shinya Kitaoka |
120a6e |
for (col = -1; col < xsh->getColumnCount(); col++) {
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objectId;
|
|
manongjohn |
3fe913 |
if (col == -1 && Preferences::instance()->isXsheetCameraColumnVisible())
|
|
John Dancel |
c323ac |
objectId = TStageObjectId::CameraId(xsh->getCameraColumnIndex());
|
|
Shinya Kitaoka |
120a6e |
else
|
|
shun-iwasawa |
8fb291 |
objectId = TStageObjectId::ColumnId(col);
|
|
Shinya Kitaoka |
120a6e |
TStageObject *pegbar = xsh->getStageObject(objectId);
|
|
Shinya Kitaoka |
120a6e |
TStageObject::KeyframeMap keyframes;
|
|
Shinya Kitaoka |
120a6e |
pegbar->getKeyframes(keyframes);
|
|
Shinya Kitaoka |
120a6e |
for (TStageObject::KeyframeMap::iterator it = keyframes.begin();
|
|
Shinya Kitaoka |
120a6e |
it != keyframes.end(); ++it) {
|
|
Shinya Kitaoka |
120a6e |
int row = it->first;
|
|
Shinya Kitaoka |
120a6e |
if (row > currentRow) continue;
|
|
Shinya Kitaoka |
120a6e |
assert(pegbar->isKeyframe(row));
|
|
Shinya Kitaoka |
120a6e |
selection->select(row, col);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentXsheet()->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
} SelectAllKeyframesAfterCommand;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class SelectPreviousKeysInColumnCommand final : public MenuItemHandler {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
SelectPreviousKeysInColumnCommand()
|
|
Shinya Kitaoka |
120a6e |
: MenuItemHandler(MI_SelectPreviousKeysInColumn) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void execute() override {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TKeyframeSelection *selection = dynamic_cast<tkeyframeselection *="">(</tkeyframeselection>
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentSelection()->getSelection());
|
|
Shinya Kitaoka |
120a6e |
if (!selection) return;
|
|
Shinya Kitaoka |
120a6e |
int currentRow = app->getCurrentFrame()->getFrame();
|
|
Shinya Kitaoka |
120a6e |
int currentColumn = app->getCurrentColumn()->getColumnIndex();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
selection->selectNone();
|
|
Shinya Kitaoka |
120a6e |
ToonzScene *scene = app->getCurrentScene()->getScene();
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = scene->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objectId =
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentObject()->getObjectId();
|
|
John Dancel |
c323ac |
if (objectId == TStageObjectId::CameraId(xsh->getCameraColumnIndex()) &&
|
|
manongjohn |
3fe913 |
Preferences::instance()->isXsheetCameraColumnVisible())
|
|
shun-iwasawa |
8fb291 |
currentColumn = -1;
|
|
Shinya Kitaoka |
120a6e |
TStageObject *pegbar = xsh->getStageObject(objectId);
|
|
Shinya Kitaoka |
120a6e |
TStageObject::KeyframeMap keyframes;
|
|
Shinya Kitaoka |
120a6e |
pegbar->getKeyframes(keyframes);
|
|
Shinya Kitaoka |
120a6e |
for (TStageObject::KeyframeMap::iterator it = keyframes.begin();
|
|
Shinya Kitaoka |
120a6e |
it != keyframes.end(); ++it) {
|
|
Shinya Kitaoka |
120a6e |
int row = it->first;
|
|
Shinya Kitaoka |
120a6e |
if (row > currentRow) continue;
|
|
Shinya Kitaoka |
120a6e |
assert(pegbar->isKeyframe(row));
|
|
Shinya Kitaoka |
120a6e |
selection->select(row, currentColumn);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentXsheet()->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
} SelectPreviousKeysInColumnCommand;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class SelectFollowingKeysInColumnCommand final : public MenuItemHandler {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
SelectFollowingKeysInColumnCommand()
|
|
Shinya Kitaoka |
120a6e |
: MenuItemHandler(MI_SelectFollowingKeysInColumn) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void execute() override {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TKeyframeSelection *selection = dynamic_cast<tkeyframeselection *="">(</tkeyframeselection>
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentSelection()->getSelection());
|
|
Shinya Kitaoka |
120a6e |
if (!selection) return;
|
|
Shinya Kitaoka |
120a6e |
int currentRow = app->getCurrentFrame()->getFrame();
|
|
Shinya Kitaoka |
120a6e |
int currentColumn = app->getCurrentColumn()->getColumnIndex();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
selection->selectNone();
|
|
Shinya Kitaoka |
120a6e |
ToonzScene *scene = app->getCurrentScene()->getScene();
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = scene->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objectId =
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentObject()->getObjectId();
|
|
John Dancel |
c323ac |
if (objectId == TStageObjectId::CameraId(xsh->getCameraColumnIndex()) &&
|
|
manongjohn |
3fe913 |
Preferences::instance()->isXsheetCameraColumnVisible())
|
|
shun-iwasawa |
8fb291 |
currentColumn = -1;
|
|
Shinya Kitaoka |
120a6e |
TStageObject *pegbar = xsh->getStageObject(objectId);
|
|
Shinya Kitaoka |
120a6e |
TStageObject::KeyframeMap keyframes;
|
|
Shinya Kitaoka |
120a6e |
pegbar->getKeyframes(keyframes);
|
|
Shinya Kitaoka |
120a6e |
for (TStageObject::KeyframeMap::iterator it = keyframes.begin();
|
|
Shinya Kitaoka |
120a6e |
it != keyframes.end(); ++it) {
|
|
Shinya Kitaoka |
120a6e |
int row = it->first;
|
|
Shinya Kitaoka |
120a6e |
if (row < currentRow) continue;
|
|
Shinya Kitaoka |
120a6e |
assert(pegbar->isKeyframe(row));
|
|
Shinya Kitaoka |
120a6e |
selection->select(row, currentColumn);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentXsheet()->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
} SelectFollowingKeysInColumnCommand;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class SelectPreviousKeysInRowCommand final : public MenuItemHandler {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
SelectPreviousKeysInRowCommand()
|
|
Shinya Kitaoka |
120a6e |
: MenuItemHandler(MI_SelectPreviousKeysInRow) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void execute() override {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TKeyframeSelection *selection = dynamic_cast<tkeyframeselection *="">(</tkeyframeselection>
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentSelection()->getSelection());
|
|
Shinya Kitaoka |
120a6e |
if (!selection) return;
|
|
Shinya Kitaoka |
120a6e |
int currentRow = app->getCurrentFrame()->getFrame();
|
|
Shinya Kitaoka |
120a6e |
int currentColumn = app->getCurrentColumn()->getColumnIndex();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
selection->selectNone();
|
|
Shinya Kitaoka |
120a6e |
ToonzScene *scene = app->getCurrentScene()->getScene();
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = scene->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
int col;
|
|
Shinya Kitaoka |
120a6e |
for (col = -1; col <= currentColumn; col++) {
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objectId;
|
|
manongjohn |
3fe913 |
if (col == -1 && Preferences::instance()->isXsheetCameraColumnVisible())
|
|
John Dancel |
c323ac |
objectId = TStageObjectId::CameraId(xsh->getCameraColumnIndex());
|
|
Shinya Kitaoka |
120a6e |
else
|
|
shun-iwasawa |
8fb291 |
objectId = TStageObjectId::ColumnId(col);
|
|
Shinya Kitaoka |
120a6e |
TStageObject *pegbar = xsh->getStageObject(objectId);
|
|
Shinya Kitaoka |
120a6e |
TStageObject::KeyframeMap keyframes;
|
|
Shinya Kitaoka |
120a6e |
pegbar->getKeyframes(keyframes);
|
|
Shinya Kitaoka |
120a6e |
for (TStageObject::KeyframeMap::iterator it = keyframes.begin();
|
|
Shinya Kitaoka |
120a6e |
it != keyframes.end(); ++it) {
|
|
Shinya Kitaoka |
120a6e |
int row = it->first;
|
|
Shinya Kitaoka |
120a6e |
if (row != currentRow) continue;
|
|
Shinya Kitaoka |
120a6e |
assert(pegbar->isKeyframe(row));
|
|
Shinya Kitaoka |
120a6e |
selection->select(row, col);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentXsheet()->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentXsheet()->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
} SelectPreviousKeysInRowCommand;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class SelectFollowingKeysInRowCommand final : public MenuItemHandler {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
SelectFollowingKeysInRowCommand()
|
|
Shinya Kitaoka |
120a6e |
: MenuItemHandler(MI_SelectFollowingKeysInRow) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void execute() override {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TKeyframeSelection *selection = dynamic_cast<tkeyframeselection *="">(</tkeyframeselection>
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentSelection()->getSelection());
|
|
Shinya Kitaoka |
120a6e |
if (!selection) return;
|
|
Shinya Kitaoka |
120a6e |
int currentRow = app->getCurrentFrame()->getFrame();
|
|
Shinya Kitaoka |
120a6e |
int currentColumn = app->getCurrentColumn()->getColumnIndex();
|
|
Shinya Kitaoka |
120a6e |
|
|
John Dancel |
c323ac |
ToonzScene *scene = app->getCurrentScene()->getScene();
|
|
John Dancel |
c323ac |
TXsheet *xsh = scene->getXsheet();
|
|
John Dancel |
c323ac |
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objectId =
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentObject()->getObjectId();
|
|
John Dancel |
c323ac |
if (objectId == TStageObjectId::CameraId(xsh->getCameraColumnIndex()) &&
|
|
manongjohn |
3fe913 |
Preferences::instance()->isXsheetCameraColumnVisible())
|
|
John Dancel |
c323ac |
currentColumn = -1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
selection->selectNone();
|
|
Shinya Kitaoka |
120a6e |
int col;
|
|
Shinya Kitaoka |
120a6e |
for (col = currentColumn; col < xsh->getColumnCount(); col++) {
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objectId;
|
|
Shinya Kitaoka |
120a6e |
if (col == -1)
|
|
John Dancel |
c323ac |
objectId = TStageObjectId::CameraId(xsh->getCameraColumnIndex());
|
|
Shinya Kitaoka |
120a6e |
else
|
|
shun-iwasawa |
8fb291 |
objectId = TStageObjectId::ColumnId(col);
|
|
Shinya Kitaoka |
120a6e |
TStageObject *pegbar = xsh->getStageObject(objectId);
|
|
Shinya Kitaoka |
120a6e |
TStageObject::KeyframeMap keyframes;
|
|
Shinya Kitaoka |
120a6e |
pegbar->getKeyframes(keyframes);
|
|
Shinya Kitaoka |
120a6e |
for (TStageObject::KeyframeMap::iterator it = keyframes.begin();
|
|
Shinya Kitaoka |
120a6e |
it != keyframes.end(); ++it) {
|
|
Shinya Kitaoka |
120a6e |
int row = it->first;
|
|
Shinya Kitaoka |
120a6e |
if (row != currentRow) continue;
|
|
Shinya Kitaoka |
120a6e |
assert(pegbar->isKeyframe(row));
|
|
Shinya Kitaoka |
120a6e |
selection->select(row, col);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentXsheet()->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
} SelectFollowingKeysInRowCommand;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class InvertKeyframeSelectionCommand final : public MenuItemHandler {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
InvertKeyframeSelectionCommand()
|
|
Shinya Kitaoka |
120a6e |
: MenuItemHandler(MI_InvertKeyframeSelection) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void execute() override {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TKeyframeSelection *selection = dynamic_cast<tkeyframeselection *="">(</tkeyframeselection>
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentSelection()->getSelection());
|
|
Shinya Kitaoka |
120a6e |
if (!selection) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ToonzScene *scene = app->getCurrentScene()->getScene();
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = scene->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
int col;
|
|
Shinya Kitaoka |
120a6e |
for (col = -1; col < xsh->getColumnCount(); col++) {
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objectId;
|
|
manongjohn |
3fe913 |
if (col == -1 && Preferences::instance()->isXsheetCameraColumnVisible())
|
|
John Dancel |
c323ac |
objectId = TStageObjectId::CameraId(xsh->getCameraColumnIndex());
|
|
Shinya Kitaoka |
120a6e |
else
|
|
shun-iwasawa |
8fb291 |
objectId = TStageObjectId::ColumnId(col);
|
|
Shinya Kitaoka |
120a6e |
TStageObject *pegbar = xsh->getStageObject(objectId);
|
|
Shinya Kitaoka |
120a6e |
TStageObject::KeyframeMap keyframes;
|
|
Shinya Kitaoka |
120a6e |
pegbar->getKeyframes(keyframes);
|
|
Shinya Kitaoka |
120a6e |
for (TStageObject::KeyframeMap::iterator it = keyframes.begin();
|
|
Shinya Kitaoka |
120a6e |
it != keyframes.end(); ++it) {
|
|
Shinya Kitaoka |
120a6e |
assert(pegbar->isKeyframe(it->first));
|
|
Shinya Kitaoka |
120a6e |
if (selection->isSelected(it->first, col))
|
|
Shinya Kitaoka |
120a6e |
selection->unselect(it->first, col);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
selection->select(it->first, col);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentXsheet()->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
} InvertKeyframeSelectionCommand;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Kayframe Handles commands
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class KeyFrameHandleCommandUndo final : public TUndo {
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId m_objId;
|
|
Shinya Kitaoka |
120a6e |
int m_rowFirst, m_rowSecond;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TStageObject::Keyframe m_oldKeyframeFirst, m_oldKeyframeSecond,
|
|
Shinya Kitaoka |
120a6e |
m_newKeyframeFirst, m_newKeyframeSecond;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
KeyFrameHandleCommandUndo(TStageObjectId id, int rowFirst, int rowSecond)
|
|
Shinya Kitaoka |
120a6e |
: m_objId(id), m_rowFirst(rowFirst), m_rowSecond(rowSecond) {
|
|
Shinya Kitaoka |
120a6e |
TStageObject *pegbar =
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentXsheet()->getXsheet()->getStageObject(
|
|
Shinya Kitaoka |
120a6e |
m_objId);
|
|
Shinya Kitaoka |
120a6e |
assert(pegbar);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_oldKeyframeFirst = pegbar->getKeyframe(m_rowFirst);
|
|
Shinya Kitaoka |
120a6e |
m_oldKeyframeSecond = pegbar->getKeyframe(m_rowSecond);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void onAdd() override {
|
|
Shinya Kitaoka |
120a6e |
TStageObject *pegbar =
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentXsheet()->getXsheet()->getStageObject(
|
|
Shinya Kitaoka |
120a6e |
m_objId);
|
|
Shinya Kitaoka |
120a6e |
assert(pegbar);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_newKeyframeFirst = pegbar->getKeyframe(m_rowFirst);
|
|
Shinya Kitaoka |
120a6e |
m_newKeyframeSecond = pegbar->getKeyframe(m_rowSecond);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void setKeyframes(const TStageObject::Keyframe &k0,
|
|
Shinya Kitaoka |
120a6e |
const TStageObject::Keyframe &k1) const {
|
|
Shinya Kitaoka |
120a6e |
TStageObject *pegbar =
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentXsheet()->getXsheet()->getStageObject(
|
|
Shinya Kitaoka |
120a6e |
m_objId);
|
|
Shinya Kitaoka |
120a6e |
assert(pegbar);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
pegbar->setKeyframeWithoutUndo(m_rowFirst, k0);
|
|
Shinya Kitaoka |
120a6e |
pegbar->setKeyframeWithoutUndo(m_rowSecond, k1);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentObject()->notifyObjectIdChanged(false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
38fd86 |
void redo() const override {
|
|
Shinya Kitaoka |
38fd86 |
setKeyframes(m_newKeyframeFirst, m_newKeyframeSecond);
|
|
Shinya Kitaoka |
38fd86 |
}
|
|
Shinya Kitaoka |
38fd86 |
void undo() const override {
|
|
Shinya Kitaoka |
38fd86 |
setKeyframes(m_oldKeyframeFirst, m_oldKeyframeSecond);
|
|
Shinya Kitaoka |
38fd86 |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
int getSize() const override { return sizeof *this; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
QString getHistoryString() override {
|
|
Shinya Kitaoka |
120a6e |
return QObject::tr("Set Keyframe : %1")
|
|
Shinya Kitaoka |
120a6e |
.arg(QString::fromStdString(m_objId.toString()));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
473e70 |
int getHistoryType() override { return HistoryType::Xsheet; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class SetAccelerationCommand final : public MenuItemHandler {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
SetAccelerationCommand() : MenuItemHandler(MI_SetAcceleration) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void execute() override {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
int row = app->getCurrentFrame()->getFrame();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objectId = app->getCurrentObject()->getObjectId();
|
|
Shinya Kitaoka |
120a6e |
TStageObject *pegbar = xsh->getStageObject(objectId);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!pegbar) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int r0, r1;
|
|
Shinya Kitaoka |
120a6e |
double ease0, ease1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
pegbar->getKeyframeSpan(row, r0, ease0, r1, ease1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
2a7129 |
std::unique_ptr<tundo> undo(</tundo>
|
|
Shinya Kitaoka |
2a7129 |
new KeyFrameHandleCommandUndo(objectId, r0, r1));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TStageObject::Keyframe keyframe0 = pegbar->getKeyframe(r0);
|
|
Shinya Kitaoka |
120a6e |
TStageObject::Keyframe keyframe1 = pegbar->getKeyframe(r1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int dr = std::max(r1 - r0, 0);
|
|
Shinya Kitaoka |
120a6e |
if (keyframe0.m_easeOut == dr) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
keyframe0.m_easeOut = dr;
|
|
Shinya Kitaoka |
120a6e |
keyframe1.m_easeIn = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// The following TStageObject::setKeyframeWithoutUndo()s could probably
|
|
Shinya Kitaoka |
120a6e |
// be left to the undo->redo(). I would have to inquire further. No big deal
|
|
Shinya Kitaoka |
120a6e |
// anyway.
|
|
Shinya Kitaoka |
120a6e |
pegbar->setKeyframeWithoutUndo(r0, keyframe0);
|
|
Shinya Kitaoka |
120a6e |
pegbar->setKeyframeWithoutUndo(r1, keyframe1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TUndoManager::manager()->add(
|
|
Shinya Kitaoka |
120a6e |
undo.release()); // Stores set keyframes in the undo
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentObject()->notifyObjectIdChanged(false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} SetAccelerationCommand;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class SetDecelerationCommand final : public MenuItemHandler {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
SetDecelerationCommand() : MenuItemHandler(MI_SetDeceleration) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void execute() override {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
int row = app->getCurrentFrame()->getFrame();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objectId = app->getCurrentObject()->getObjectId();
|
|
Shinya Kitaoka |
120a6e |
TStageObject *pegbar = xsh->getStageObject(objectId);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!pegbar) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int r0, r1;
|
|
Shinya Kitaoka |
120a6e |
double ease0, ease1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
pegbar->getKeyframeSpan(row, r0, ease0, r1, ease1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
2a7129 |
std::unique_ptr<tundo> undo(</tundo>
|
|
Shinya Kitaoka |
2a7129 |
new KeyFrameHandleCommandUndo(objectId, r0, r1));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TStageObject::Keyframe keyframe0 = pegbar->getKeyframe(r0);
|
|
Shinya Kitaoka |
120a6e |
TStageObject::Keyframe keyframe1 = pegbar->getKeyframe(r1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int dr = std::max(r1 - r0, 0);
|
|
Shinya Kitaoka |
120a6e |
if (keyframe1.m_easeIn == dr) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
keyframe0.m_easeOut = 0;
|
|
Shinya Kitaoka |
120a6e |
keyframe1.m_easeIn = dr;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
pegbar->setKeyframeWithoutUndo(r0, keyframe0);
|
|
Shinya Kitaoka |
120a6e |
pegbar->setKeyframeWithoutUndo(r1, keyframe1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TUndoManager::manager()->add(undo.release());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentObject()->notifyObjectIdChanged(false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} SetDecelerationCommand;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class SetConstantSpeedCommand final : public MenuItemHandler {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
SetConstantSpeedCommand() : MenuItemHandler(MI_SetConstantSpeed) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void execute() override {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
int row = app->getCurrentFrame()->getFrame();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objectId = app->getCurrentObject()->getObjectId();
|
|
Shinya Kitaoka |
120a6e |
TStageObject *pegbar = xsh->getStageObject(objectId);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!pegbar) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int r0, r1;
|
|
Shinya Kitaoka |
120a6e |
double ease0, ease1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
pegbar->getKeyframeSpan(row, r0, ease0, r1, ease1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
KeyFrameHandleCommandUndo *undo =
|
|
Shinya Kitaoka |
120a6e |
new KeyFrameHandleCommandUndo(objectId, r0, r1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TStageObject::Keyframe keyframe0 = pegbar->getKeyframe(r0);
|
|
Shinya Kitaoka |
120a6e |
TStageObject::Keyframe keyframe1 = pegbar->getKeyframe(r1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
keyframe0.m_easeOut = 0;
|
|
Shinya Kitaoka |
120a6e |
keyframe1.m_easeIn = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
pegbar->setKeyframeWithoutUndo(r0, keyframe0);
|
|
Shinya Kitaoka |
120a6e |
pegbar->setKeyframeWithoutUndo(r1, keyframe1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TUndoManager::manager()->add(undo);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentObject()->notifyObjectIdChanged(false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} SetConstantSpeedCommand;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class ResetArrowCommand final : public MenuItemHandler {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
ResetArrowCommand() : MenuItemHandler(MI_ResetInterpolation) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void execute() override {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
int row = app->getCurrentFrame()->getFrame();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objectId = app->getCurrentObject()->getObjectId();
|
|
Shinya Kitaoka |
120a6e |
TStageObject *pegbar = xsh->getStageObject(objectId);
|
|
Shinya Kitaoka |
120a6e |
if (!pegbar) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int r0, r1;
|
|
Shinya Kitaoka |
120a6e |
double ease0, ease1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
pegbar->getKeyframeSpan(row, r0, ease0, r1, ease1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
KeyFrameHandleCommandUndo *undo =
|
|
Shinya Kitaoka |
120a6e |
new KeyFrameHandleCommandUndo(objectId, r0, r1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TStageObject::Keyframe k0 = pegbar->getKeyframe(r0);
|
|
Shinya Kitaoka |
120a6e |
TStageObject::Keyframe k1 = pegbar->getKeyframe(r1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
k0.m_easeOut = (k0.m_easeOut != 0) ? 1 : k0.m_easeOut;
|
|
Shinya Kitaoka |
120a6e |
k0.m_easeIn = (k0.m_easeIn != 0) ? 1 : k0.m_easeIn;
|
|
Shinya Kitaoka |
120a6e |
k1.m_easeOut = (k1.m_easeOut != 0) ? 1 : k1.m_easeOut;
|
|
Shinya Kitaoka |
120a6e |
k1.m_easeIn = (k1.m_easeIn != 0) ? 1 : k1.m_easeIn;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
pegbar->setKeyframeWithoutUndo(r0, k0);
|
|
Shinya Kitaoka |
120a6e |
pegbar->setKeyframeWithoutUndo(r1, k1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TUndoManager::manager()->add(undo);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentObject()->notifyObjectIdChanged(false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} ResetArrowCommand;
|
|
Toshihiro Shimizu |
890ddd |
|
|
manongjohn |
63e288 |
//-----------------------------------------------------------------------------
|
|
manongjohn |
63e288 |
// Unify commands for all types of interpolation
|
|
manongjohn |
63e288 |
class SetInterpolation final : public MenuItemHandler {
|
|
manongjohn |
63e288 |
TDoubleKeyframe::Type m_type;
|
|
manongjohn |
63e288 |
|
|
manongjohn |
63e288 |
public:
|
|
manongjohn |
63e288 |
SetInterpolation(CommandId cmdId, TDoubleKeyframe::Type type)
|
|
manongjohn |
63e288 |
: MenuItemHandler(cmdId), m_type(type) {}
|
|
manongjohn |
63e288 |
|
|
manongjohn |
63e288 |
void execute() override {
|
|
manongjohn |
63e288 |
TApp *app = TApp::instance();
|
|
manongjohn |
63e288 |
TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
|
|
manongjohn |
63e288 |
int row = app->getCurrentFrame()->getFrame();
|
|
manongjohn |
63e288 |
|
|
manongjohn |
63e288 |
TStageObjectId objectId = app->getCurrentObject()->getObjectId();
|
|
manongjohn |
63e288 |
TStageObject *pegbar = xsh->getStageObject(objectId);
|
|
manongjohn |
63e288 |
if (!pegbar) return;
|
|
manongjohn |
63e288 |
|
|
manongjohn |
63e288 |
int r0, r1;
|
|
manongjohn |
63e288 |
double ease0, ease1;
|
|
manongjohn |
63e288 |
|
|
manongjohn |
63e288 |
pegbar->getKeyframeSpan(row, r0, ease0, r1, ease1);
|
|
manongjohn |
63e288 |
|
|
manongjohn |
63e288 |
KeyFrameHandleCommandUndo *undo =
|
|
manongjohn |
63e288 |
new KeyFrameHandleCommandUndo(objectId, r0, r1);
|
|
manongjohn |
63e288 |
|
|
manongjohn |
63e288 |
TStageObject::Keyframe k0 = pegbar->getKeyframe(r0);
|
|
manongjohn |
63e288 |
TStageObject::Keyframe k1 = pegbar->getKeyframe(r1);
|
|
manongjohn |
63e288 |
|
|
manongjohn |
63e288 |
for (int i = 0; i < TStageObject::T_ChannelCount; i++) {
|
|
manongjohn |
63e288 |
k0.m_channels[i].m_type = m_type;
|
|
manongjohn |
63e288 |
k1.m_channels[i].m_prevType = m_type;
|
|
manongjohn |
63e288 |
}
|
|
manongjohn |
63e288 |
pegbar->setKeyframeWithoutUndo(r0, k0);
|
|
manongjohn |
63e288 |
pegbar->setKeyframeWithoutUndo(r1, k1);
|
|
manongjohn |
63e288 |
|
|
manongjohn |
63e288 |
TUndoManager::manager()->add(undo);
|
|
manongjohn |
63e288 |
|
|
manongjohn |
63e288 |
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
|
|
manongjohn |
63e288 |
TApp::instance()->getCurrentObject()->notifyObjectIdChanged(false);
|
|
manongjohn |
63e288 |
}
|
|
manongjohn |
63e288 |
|
|
manongjohn |
63e288 |
} UseLinearInterpolation(MI_UseLinearInterpolation, TDoubleKeyframe::Linear),
|
|
manongjohn |
63e288 |
UseSpeedInOutInterpolation(MI_UseSpeedInOutInterpolation,
|
|
manongjohn |
63e288 |
TDoubleKeyframe::SpeedInOut),
|
|
manongjohn |
63e288 |
UseEaseInOutInterpolation(MI_UseEaseInOutInterpolation,
|
|
manongjohn |
63e288 |
TDoubleKeyframe::EaseInOut),
|
|
manongjohn |
63e288 |
UseEaseInOutPctInterpolation(MI_UseEaseInOutPctInterpolation,
|
|
manongjohn |
63e288 |
TDoubleKeyframe::EaseInOutPercentage),
|
|
manongjohn |
63e288 |
UseExponentialInterpolation(MI_UseExponentialInterpolation,
|
|
manongjohn |
63e288 |
TDoubleKeyframe::Exponential),
|
|
manongjohn |
63e288 |
UseExpressionInterpolation(MI_UseExpressionInterpolation,
|
|
manongjohn |
63e288 |
TDoubleKeyframe::Expression),
|
|
manongjohn |
63e288 |
UseFileInterpolation(MI_UseFileInterpolation, TDoubleKeyframe::File),
|
|
manongjohn |
63e288 |
UseConstantInterpolation(MI_UseConstantInterpolation,
|
|
manongjohn |
63e288 |
TDoubleKeyframe::Constant);
|
|
manongjohn |
63e288 |
|
|
Toshihiro Shimizu |
890ddd |
//===========================================================
|
|
Toshihiro Shimizu |
890ddd |
// To Be Reworked
|
|
Toshihiro Shimizu |
890ddd |
//===========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class NewOutputFx final : public MenuItemHandler {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
NewOutputFx() : MenuItemHandler(MI_NewOutputFx) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void execute() override {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TFxCommand::createOutputFx(app->getCurrentXsheet(),
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentFx()->getFx());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} newOutputFx;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
int columnsPerPage = 10000;
|
|
Shinya Kitaoka |
120a6e |
int rowsPerPage = 10000;
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<std::pair<std::string, string="">> infos;</std::pair<std::string,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void readParameters() {
|
|
Shinya Kitaoka |
120a6e |
infos.clear();
|
|
Shinya Kitaoka |
120a6e |
const std::string name("xsheet_html.xml");
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp = ToonzFolder::getModuleFile(name);
|
|
Shinya Kitaoka |
120a6e |
if (!TFileStatus(fp).doesExist()) return;
|
|
Shinya Kitaoka |
120a6e |
try {
|
|
Shinya Kitaoka |
120a6e |
TIStream is(fp);
|
|
Shinya Kitaoka |
120a6e |
std::string tagName;
|
|
Shinya Kitaoka |
120a6e |
if (!is.matchTag(tagName) || tagName != "xsheet_html") return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
while (is.matchTag(tagName)) {
|
|
Shinya Kitaoka |
120a6e |
if (tagName == "page") {
|
|
Shinya Kitaoka |
120a6e |
std::string s;
|
|
shun-iwasawa |
8fb291 |
s = is.getTagAttribute("rows");
|
|
shun-iwasawa |
8fb291 |
if (s != "" && isInt(s)) rowsPerPage = std::stoi(s);
|
|
shun-iwasawa |
8fb291 |
s = is.getTagAttribute("columns");
|
|
Shinya Kitaoka |
120a6e |
if (s != "" && isInt(s)) columnsPerPage = std::stoi(s);
|
|
Shinya Kitaoka |
120a6e |
} else if (tagName == "info") {
|
|
Shinya Kitaoka |
120a6e |
std::string name = is.getTagAttribute("name");
|
|
Shinya Kitaoka |
120a6e |
std::string value = is.getTagAttribute("value");
|
|
Shinya Kitaoka |
120a6e |
infos.push_back(std::make_pair(name, value));
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} catch (...) {
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void copyCss(TFilePath fp) {
|
|
Shinya Kitaoka |
120a6e |
const std::string name("xsheet.css");
|
|
Shinya Kitaoka |
120a6e |
TFilePath cssFp = fp.getParentDir() + name;
|
|
Shinya Kitaoka |
120a6e |
if (TFileStatus(cssFp).doesExist()) return;
|
|
Shinya Kitaoka |
120a6e |
TFilePath src = ToonzFolder::getModuleFile(name);
|
|
Shinya Kitaoka |
120a6e |
if (TFileStatus(src).doesExist()) {
|
|
Shinya Kitaoka |
120a6e |
try {
|
|
Shinya Kitaoka |
120a6e |
TSystem::copyFile(cssFp, src);
|
|
Shinya Kitaoka |
120a6e |
} catch (...) {
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void getAllChildLevels(std::vector<txshchildlevel *=""> &levels,</txshchildlevel>
|
|
Shinya Kitaoka |
120a6e |
ToonzScene *scene) {
|
|
Shinya Kitaoka |
120a6e |
std::set<txsheet *=""> visited, toVisit;</txsheet>
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = scene->getChildStack()->getTopXsheet();
|
|
Shinya Kitaoka |
120a6e |
visited.insert(xsh);
|
|
Shinya Kitaoka |
120a6e |
toVisit.insert(xsh);
|
|
Shinya Kitaoka |
120a6e |
while (!toVisit.empty()) {
|
|
Shinya Kitaoka |
120a6e |
xsh = *toVisit.begin();
|
|
Shinya Kitaoka |
120a6e |
toVisit.erase(xsh);
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < xsh->getColumnCount(); i++) {
|
|
Shinya Kitaoka |
120a6e |
TXshColumn *column = xsh->getColumn(i);
|
|
Shinya Kitaoka |
120a6e |
if (!column) continue;
|
|
Shinya Kitaoka |
120a6e |
if (TXshCellColumn *cc = column->getCellColumn()) {
|
|
Shinya Kitaoka |
120a6e |
int r0 = 0, r1 = -1;
|
|
Shinya Kitaoka |
120a6e |
cc->getRange(r0, r1);
|
|
Shinya Kitaoka |
120a6e |
if (!cc->isEmpty() && r0 <= r1) {
|
|
Shinya Kitaoka |
120a6e |
for (int r = r0; r <= r1; r++) {
|
|
Shinya Kitaoka |
120a6e |
TXshCell cell = cc->getCell(r);
|
|
Shinya Kitaoka |
120a6e |
if (cell.m_level && cell.m_level->getChildLevel()) {
|
|
Shinya Kitaoka |
120a6e |
TXsheet *subxsh = cell.m_level->getChildLevel()->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
if (visited.find(subxsh) == visited.end()) {
|
|
Shinya Kitaoka |
120a6e |
levels.push_back(cell.m_level->getChildLevel());
|
|
Shinya Kitaoka |
120a6e |
visited.insert(subxsh);
|
|
Shinya Kitaoka |
120a6e |
toVisit.insert(subxsh);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
struct NumericColumn {
|
|
Shinya Kitaoka |
120a6e |
TStageObject *m_pegbar;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_curve;
|
|
Shinya Kitaoka |
120a6e |
NumericColumn(TStageObject *pegbar, const TDoubleParamP &curve)
|
|
Shinya Kitaoka |
120a6e |
: m_pegbar(pegbar), m_curve(curve){};
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class XsheetWriter {
|
|
Shinya Kitaoka |
120a6e |
TXsheet *m_xsh;
|
|
Shinya Kitaoka |
120a6e |
std::map<txshchildlevel *,="" int=""> m_childTable;</txshchildlevel>
|
|
Shinya Kitaoka |
120a6e |
std::vector<numericcolumn> m_numericColumns;</numericcolumn>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
XsheetWriter(ToonzScene *scene);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setXsheet(TXsheet *xsh);
|
|
Shinya Kitaoka |
120a6e |
void getSubXsheets(std::vector<txsheet *=""> &xsheets);</txsheet>
|
|
Shinya Kitaoka |
120a6e |
int getChildLevelIndex(TXshChildLevel *);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void buildNumericColumns();
|
|
Shinya Kitaoka |
120a6e |
void buildChildTable(ToonzScene *scene);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void tableCaption(ostream &os);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void columnHeader(ostream &os, int c);
|
|
Shinya Kitaoka |
120a6e |
void numericColumnHeader(ostream &os, int c);
|
|
Shinya Kitaoka |
120a6e |
void cell(ostream &os, int r, int c);
|
|
Shinya Kitaoka |
120a6e |
void numericCell(ostream &os, int r, int c);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void write(ostream &os);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
XsheetWriter::XsheetWriter(ToonzScene *scene) : m_xsh(0) {
|
|
Shinya Kitaoka |
120a6e |
buildChildTable(scene);
|
|
Shinya Kitaoka |
120a6e |
setXsheet(scene->getXsheet());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void XsheetWriter::setXsheet(TXsheet *xsh) {
|
|
Shinya Kitaoka |
120a6e |
m_xsh = xsh;
|
|
Shinya Kitaoka |
120a6e |
buildNumericColumns();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void XsheetWriter::getSubXsheets(std::vector<txsheet *=""> &xsheets) {</txsheet>
|
|
Shinya Kitaoka |
120a6e |
std::map<txshchildlevel *,="" int="">::iterator it;</txshchildlevel>
|
|
Shinya Kitaoka |
120a6e |
for (it = m_childTable.begin(); it != m_childTable.end(); ++it)
|
|
Shinya Kitaoka |
120a6e |
xsheets.push_back(it->first->getXsheet());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int XsheetWriter::getChildLevelIndex(TXshChildLevel *cl) {
|
|
Shinya Kitaoka |
120a6e |
std::map<txshchildlevel *,="" int="">::iterator it;</txshchildlevel>
|
|
Shinya Kitaoka |
120a6e |
it = m_childTable.find(cl);
|
|
Shinya Kitaoka |
120a6e |
return it == m_childTable.end() ? -1 : it->second;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void XsheetWriter::buildNumericColumns() {
|
|
Shinya Kitaoka |
120a6e |
m_numericColumns.clear();
|
|
Shinya Kitaoka |
120a6e |
TStageObjectTree *pegbarTree = m_xsh->getStageObjectTree();
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < pegbarTree->getStageObjectCount(); i++) {
|
|
Shinya Kitaoka |
120a6e |
TStageObject *pegbar = pegbarTree->getStageObject(i);
|
|
Shinya Kitaoka |
120a6e |
for (int j = 0; j < TStageObject::T_ChannelCount; j++) {
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP curve = pegbar->getParam((TStageObject::Channel)j);
|
|
Shinya Kitaoka |
120a6e |
if (curve->hasKeyframes()) {
|
|
Shinya Kitaoka |
120a6e |
m_numericColumns.push_back(NumericColumn(pegbar, curve));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void XsheetWriter::buildChildTable(ToonzScene *scene) {
|
|
Shinya Kitaoka |
120a6e |
std::vector<txshchildlevel *=""> levels;</txshchildlevel>
|
|
Shinya Kitaoka |
120a6e |
getAllChildLevels(levels, scene);
|
|
Shinya Kitaoka |
120a6e |
int i, k = 0;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < (int)levels.size(); i++) m_childTable[levels[i]] = k++;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void XsheetWriter::tableCaption(ostream &os) { os << "Â \n"; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void XsheetWriter::columnHeader(ostream &os, int c) {
|
|
Shinya Kitaoka |
120a6e |
os << " " << (c + 1) << "" << endl;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void XsheetWriter::numericColumnHeader(ostream &os, int c) {
|
|
Shinya Kitaoka |
120a6e |
std::string pegbarName = m_numericColumns[c].m_pegbar->getName();
|
|
Shinya Kitaoka |
120a6e |
std::string curveName =
|
|
Shinya Kitaoka |
120a6e |
m_numericColumns[c]
|
|
Shinya Kitaoka |
120a6e |
.m_curve
|
|
Shinya Kitaoka |
120a6e |
->getName(); // toString(TStringTable::translate(m_numericColumns[c].m_curve->getName()));
|
|
Shinya Kitaoka |
120a6e |
os << " ";
|
|
Shinya Kitaoka |
120a6e |
os << pegbarName << " " << curveName;
|
|
Shinya Kitaoka |
120a6e |
os << "" << endl;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void XsheetWriter::cell(ostream &os, int r, int c) {
|
|
Shinya Kitaoka |
120a6e |
TXshCell prevCell;
|
|
Shinya Kitaoka |
120a6e |
if (r > 0) prevCell = m_xsh->getCell(r - 1, c);
|
|
shun-iwasawa |
8fb291 |
TXshCell cell = m_xsh->getCell(r, c);
|
|
Shinya Kitaoka |
120a6e |
if (cell.isEmpty())
|
|
Shinya Kitaoka |
120a6e |
os << "Â ";
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
TXshLevel *level = cell.m_level.getPointer();
|
|
Shinya Kitaoka |
120a6e |
std::string type = "levelcell";
|
|
Shinya Kitaoka |
120a6e |
if (level->getChildLevel())
|
|
Shinya Kitaoka |
120a6e |
type = "subxsheetcell";
|
|
Shinya Kitaoka |
120a6e |
else if (level->getZeraryFxLevel())
|
|
Shinya Kitaoka |
120a6e |
type = "fxcell";
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
os << "";
|
|
Shinya Kitaoka |
120a6e |
bool newPage = r % rowsPerPage == 0;
|
|
Shinya Kitaoka |
120a6e |
if (cell.m_level.getPointer() == prevCell.m_level.getPointer() &&
|
|
Shinya Kitaoka |
120a6e |
!newPage) {
|
|
Shinya Kitaoka |
120a6e |
// stesso livello
|
|
Shinya Kitaoka |
120a6e |
if (cell.m_frameId == prevCell.m_frameId) {
|
|
Shinya Kitaoka |
120a6e |
// stesso frame
|
|
Shinya Kitaoka |
120a6e |
os << "|";
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
// frame diverso
|
|
Shinya Kitaoka |
120a6e |
os << cell.m_frameId.getNumber();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
// livello diverso
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
std::string levelName;
|
|
Shinya Kitaoka |
120a6e |
if (level->getChildLevel()) {
|
|
Shinya Kitaoka |
120a6e |
int index = getChildLevelIndex(level->getChildLevel());
|
|
Shinya Kitaoka |
120a6e |
levelName = index >= 0 ? "Sub" + std::to_string(index + 1) : "";
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
levelName = ::to_string(level->getName());
|
|
Shinya Kitaoka |
120a6e |
os << levelName << " " << cell.m_frameId.getNumber();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
os << "" << endl;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void XsheetWriter::numericCell(ostream &os, int r, int c) {
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP curve = m_numericColumns[c].m_curve;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double v = curve->getValue(r);
|
|
Shinya Kitaoka |
120a6e |
TMeasure *measure = curve->getMeasure();
|
|
Shinya Kitaoka |
120a6e |
if (measure) {
|
|
Shinya Kitaoka |
120a6e |
const TUnit *unit = measure->getCurrentUnit();
|
|
shun-iwasawa |
8fb291 |
if (unit) v = unit->convertTo(v);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
os << "";
|
|
Shinya Kitaoka |
120a6e |
os << v << "" << endl;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void XsheetWriter::write(ostream &os) {
|
|
Shinya Kitaoka |
120a6e |
int rowCount = m_xsh->getFrameCount();
|
|
Shinya Kitaoka |
120a6e |
int colCount = m_xsh->getColumnCount();
|
|
Shinya Kitaoka |
120a6e |
int totColCount = colCount + (int)m_numericColumns.size();
|
|
Shinya Kitaoka |
120a6e |
int c0, c1;
|
|
Shinya Kitaoka |
120a6e |
c0 = 0;
|
|
Shinya Kitaoka |
120a6e |
for (;;) {
|
|
Shinya Kitaoka |
120a6e |
c1 = std::min(totColCount, c0 + columnsPerPage) - 1;
|
|
Shinya Kitaoka |
120a6e |
int ca0 = 0, ca1 = -1, cb0 = 0, cb1 = -1;
|
|
Shinya Kitaoka |
120a6e |
if (c0 < colCount) {
|
|
Shinya Kitaoka |
120a6e |
ca0 = c0;
|
|
Shinya Kitaoka |
120a6e |
ca1 = std::min(colCount - 1, c1);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (c1 >= colCount) {
|
|
Shinya Kitaoka |
120a6e |
cb0 = std::max(c0, colCount);
|
|
Shinya Kitaoka |
120a6e |
cb1 = c1;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int r0, r1, r, c;
|
|
Shinya Kitaoka |
120a6e |
r0 = 0;
|
|
Shinya Kitaoka |
120a6e |
for (;;) {
|
|
Shinya Kitaoka |
120a6e |
r1 = std::min(rowCount, r0 + rowsPerPage) - 1;
|
|
Shinya Kitaoka |
120a6e |
tableCaption(os);
|
|
Shinya Kitaoka |
120a6e |
os << "" << endl << "" << endl;
|
|
Shinya Kitaoka |
120a6e |
if (c0 == 0) os << " Â " << endl;
|
|
Shinya Kitaoka |
120a6e |
for (c = c0; c <= c1; c++) {
|
|
Shinya Kitaoka |
120a6e |
if (c < colCount)
|
|
Shinya Kitaoka |
120a6e |
columnHeader(os, c);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
numericColumnHeader(os, c - colCount);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
os << "" << endl;
|
|
Shinya Kitaoka |
120a6e |
for (r = r0; r <= r1; r++) {
|
|
Shinya Kitaoka |
120a6e |
os << "" << endl;
|
|
Shinya Kitaoka |
120a6e |
os << " " << r + 1 << "" << endl;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (c = ca0; c <= ca1; c++) cell(os, r, c);
|
|
Shinya Kitaoka |
120a6e |
for (c = cb0; c <= cb1; c++) numericCell(os, r, c - colCount);
|
|
Shinya Kitaoka |
120a6e |
os << "" << endl;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
os << "" << endl;
|
|
Shinya Kitaoka |
120a6e |
r0 = r1 + 1;
|
|
Shinya Kitaoka |
120a6e |
if (r0 >= rowCount) break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
c0 = c1 + 1;
|
|
Shinya Kitaoka |
120a6e |
if (c0 >= totColCount) break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
ccd505 |
static void makeHtml(TFilePath fp) {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
ToonzScene *scene = app->getCurrentScene()->getScene();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
std::string sceneName = scene->getScenePath().getName();
|
|
Shinya Kitaoka |
120a6e |
std::string projectName = ::to_string(scene->getProject()->getName());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
Tofstream os(fp);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
os << "
|
|
Shinya Kitaoka |
120a6e |
os << " \"http://www.w3.org/TR/html4/strict.dtd\">" << endl;
|
|
Shinya Kitaoka |
120a6e |
os << "" << endl;
|
|
Shinya Kitaoka |
120a6e |
os << "<title>" << sceneName << "</title>" << endl;
|
|
Shinya Kitaoka |
120a6e |
os << "<meta content="\"text/html;charset=utf-8\"" http-equiv="\"content-type\"">"
|
|
Shinya Kitaoka |
120a6e |
<< endl;
|
|
Shinya Kitaoka |
120a6e |
os << "<meta content="\"text/css\"" http-equiv="\"Content-Style-Type\"">" << endl;
|
|
Shinya Kitaoka |
120a6e |
os << "<meta 5.2\"="" content="\"Toonz" name="\"Generator\"">" << endl;
|
|
Shinya Kitaoka |
120a6e |
os << "<link href="\"xsheet.css\"" rel="\"stylesheet\"" type="\"text/css\"">"
|
|
Shinya Kitaoka |
120a6e |
<< endl;
|
|
Shinya Kitaoka |
120a6e |
os << "" << endl;
|
|
Shinya Kitaoka |
120a6e |
os << "" << endl;
|
|
Shinya Kitaoka |
120a6e |
for (int k = 0; k < (int)infos.size(); k++)
|
|
Shinya Kitaoka |
120a6e |
os << "" << infos[k].first << ":" << infos[k].second
|
|
Shinya Kitaoka |
120a6e |
<< "" << endl;
|
|
Shinya Kitaoka |
120a6e |
os << "Project:" << projectName << "" << endl;
|
|
Shinya Kitaoka |
120a6e |
os << "Scene:" << sceneName << "" << endl;
|
|
Shinya Kitaoka |
120a6e |
os << "Frames:" << scene->getFrameCount() << ""
|
|
Shinya Kitaoka |
120a6e |
<< endl;
|
|
Shinya Kitaoka |
120a6e |
os << "\n";
|
|
Shinya Kitaoka |
120a6e |
os << "Â \n";
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
os << "Main Xsheet\n";
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
XsheetWriter writer(scene);
|
|
Shinya Kitaoka |
120a6e |
writer.write(os);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
std::vector<txsheet *=""> subXsheets;</txsheet>
|
|
Shinya Kitaoka |
120a6e |
writer.getSubXsheets(subXsheets);
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < (int)subXsheets.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
os << "Sub Xsheet " << i + 1 << "\n";
|
|
Shinya Kitaoka |
120a6e |
writer.setXsheet(subXsheets[i]);
|
|
Shinya Kitaoka |
120a6e |
writer.write(os);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
os << "Levels\n";
|
|
Shinya Kitaoka |
120a6e |
std::vector<txshlevel *=""> levels;</txshlevel>
|
|
Shinya Kitaoka |
120a6e |
scene->getLevelSet()->listLevels(levels);
|
|
Shinya Kitaoka |
120a6e |
os << "" << endl;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < (int)levels.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
TXshLevel *level = levels[i];
|
|
Shinya Kitaoka |
120a6e |
if (!level->getSimpleLevel()) continue;
|
|
Shinya Kitaoka |
120a6e |
os << "" << ::to_string(level->getName()) << "" << endl;
|
|
Shinya Kitaoka |
120a6e |
os << "" << endl;
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp = level->getPath();
|
|
Shinya Kitaoka |
120a6e |
os << ::to_string(fp);
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp2 = scene->decodeFilePath(fp);
|
|
Shinya Kitaoka |
120a6e |
if (fp != fp2) os << " " << ::to_string(fp2);
|
|
Shinya Kitaoka |
120a6e |
os << "" << endl;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
os << "" << endl;
|
|
Shinya Kitaoka |
120a6e |
os << "" << endl;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class PrintXsheetCommand final : public MenuItemHandler {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
PrintXsheetCommand() : MenuItemHandler(MI_PrintXsheet) {}
|
|
Shinya Kitaoka |
473e70 |
void execute() override;
|
|
Toshihiro Shimizu |
890ddd |
} printXsheetCommand;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PrintXsheetCommand::execute() {
|
|
Shinya Kitaoka |
120a6e |
ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp = scene->getScenePath().withType("html");
|
|
Shinya Kitaoka |
120a6e |
readParameters();
|
|
Shinya Kitaoka |
120a6e |
makeHtml(fp);
|
|
Shinya Kitaoka |
120a6e |
copyCss(fp);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString str =
|
|
Shinya Kitaoka |
120a6e |
QObject::tr("The %1 file has been generated").arg(toQString(fp));
|
|
Shinya Kitaoka |
120a6e |
DVGui::warning(str);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TSystem::showDocument(fp);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
manongjohn |
31e2ab |
|
|
manongjohn |
31e2ab |
//-----------------------------------------------------------------------------
|
|
manongjohn |
31e2ab |
|
|
manongjohn |
31e2ab |
class ToggleXsheetCameraColumnCommand final : public MenuItemHandler {
|
|
manongjohn |
31e2ab |
public:
|
|
manongjohn |
31e2ab |
ToggleXsheetCameraColumnCommand()
|
|
manongjohn |
31e2ab |
: MenuItemHandler(MI_ToggleXsheetCameraColumn) {}
|
|
manongjohn |
31e2ab |
|
|
manongjohn |
31e2ab |
void execute() override {
|
|
manongjohn |
31e2ab |
Preferences *pref = Preferences::instance();
|
|
manongjohn |
31e2ab |
if (!pref->isShowKeyframesOnXsheetCellAreaEnabled()) {
|
|
manongjohn |
31e2ab |
DVGui::warning(
|
|
manongjohn |
31e2ab |
QObject::tr("Please enable \"Show Keyframes on Cell Area\" to show "
|
|
manongjohn |
31e2ab |
"or hide the camera column."));
|
|
manongjohn |
31e2ab |
return;
|
|
manongjohn |
31e2ab |
}
|
|
manongjohn |
31e2ab |
|
|
shun-iwasawa |
8fb291 |
pref->setValue(showXsheetCameraColumn,
|
|
shun-iwasawa |
8fb291 |
!pref->isXsheetCameraColumnVisible());
|
|
manongjohn |
31e2ab |
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
|
|
manongjohn |
31e2ab |
}
|
|
manongjohn |
31e2ab |
|
|
manongjohn |
31e2ab |
} ToggleXsheetCameraColumnCommand;
|
|
shun-iwasawa |
f84c65 |
|
|
shun-iwasawa |
f84c65 |
//-----------------------------------------------------------------------------
|
|
shun-iwasawa |
f84c65 |
|
|
shun-iwasawa |
f84c65 |
class SetCellMarkCommand final : public MenuItemHandler {
|
|
shun-iwasawa |
f84c65 |
int m_markId;
|
|
shun-iwasawa |
f84c65 |
|
|
shun-iwasawa |
f84c65 |
public:
|
|
shun-iwasawa |
f84c65 |
SetCellMarkCommand(int markId)
|
|
shun-iwasawa |
f84c65 |
: MenuItemHandler(
|
|
shun-iwasawa |
f84c65 |
((std::string)MI_SetCellMark + std::to_string(markId)).c_str())
|
|
shun-iwasawa |
f84c65 |
, m_markId(markId) {}
|
|
shun-iwasawa |
f84c65 |
|
|
shun-iwasawa |
f84c65 |
void execute() override {
|
|
shun-iwasawa |
f84c65 |
TApp *app = TApp::instance();
|
|
shun-iwasawa |
f84c65 |
TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
|
|
shun-iwasawa |
f84c65 |
int currentRow = app->getCurrentFrame()->getFrame();
|
|
shun-iwasawa |
f84c65 |
int currentColumn = app->getCurrentColumn()->getColumnIndex();
|
|
shun-iwasawa |
f84c65 |
if (!xsh->getColumn(currentColumn)) return;
|
|
shun-iwasawa |
f84c65 |
TXshCellColumn *cellColumn = xsh->getColumn(currentColumn)->getCellColumn();
|
|
shun-iwasawa |
f84c65 |
if (!cellColumn) return;
|
|
shun-iwasawa |
f84c65 |
XsheetGUI::SetCellMarkUndo *undo =
|
|
shun-iwasawa |
f84c65 |
new XsheetGUI::SetCellMarkUndo(currentRow, currentColumn, m_markId);
|
|
shun-iwasawa |
f84c65 |
undo->redo();
|
|
shun-iwasawa |
f84c65 |
TUndoManager::manager()->add(undo);
|
|
shun-iwasawa |
f84c65 |
}
|
|
shun-iwasawa |
f84c65 |
};
|
|
shun-iwasawa |
f84c65 |
SetCellMarkCommand CellMarkCommand0(0);
|
|
shun-iwasawa |
f84c65 |
SetCellMarkCommand CellMarkCommand1(1);
|
|
shun-iwasawa |
f84c65 |
SetCellMarkCommand CellMarkCommand2(2);
|
|
shun-iwasawa |
f84c65 |
SetCellMarkCommand CellMarkCommand3(3);
|
|
shun-iwasawa |
f84c65 |
SetCellMarkCommand CellMarkCommand4(4);
|
|
shun-iwasawa |
f84c65 |
SetCellMarkCommand CellMarkCommand5(5);
|
|
shun-iwasawa |
f84c65 |
SetCellMarkCommand CellMarkCommand6(6);
|
|
shun-iwasawa |
f84c65 |
SetCellMarkCommand CellMarkCommand7(7);
|
|
shun-iwasawa |
f84c65 |
SetCellMarkCommand CellMarkCommand8(8);
|
|
shun-iwasawa |
f84c65 |
SetCellMarkCommand CellMarkCommand9(9);
|
|
shun-iwasawa |
f84c65 |
SetCellMarkCommand CellMarkCommand10(10);
|
|
manongjohn |
8404a6 |
SetCellMarkCommand CellMarkCommand11(11);
|
|
manongjohn |
8404a6 |
|
|
manongjohn |
8404a6 |
//============================================================
|
|
manongjohn |
8404a6 |
|
|
manongjohn |
8404a6 |
class ToggleTaggedFrame final : public MenuItemHandler {
|
|
manongjohn |
8404a6 |
public:
|
|
manongjohn |
8404a6 |
ToggleTaggedFrame() : MenuItemHandler(MI_ToggleTaggedFrame) {}
|
|
manongjohn |
8404a6 |
void execute() override {
|
|
manongjohn |
8404a6 |
TApp *app = TApp::instance();
|
|
manongjohn |
8404a6 |
int frame = app->getCurrentFrame()->getFrame();
|
|
manongjohn |
8404a6 |
assert(frame >= 0);
|
|
manongjohn |
8404a6 |
TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
|
|
manongjohn |
8404a6 |
|
|
manongjohn |
8404a6 |
xsh->toggleTaggedFrame(frame);
|
|
manongjohn |
8404a6 |
|
|
manongjohn |
8404a6 |
NavigationTags *navTags = xsh->getNavigationTags();
|
|
manongjohn |
8404a6 |
CommandManager::instance()->enable(MI_EditTaggedFrame,
|
|
manongjohn |
8404a6 |
navTags->isTagged(frame));
|
|
manongjohn |
8404a6 |
CommandManager::instance()->enable(MI_ClearTags, (navTags->getCount() > 0));
|
|
manongjohn |
8404a6 |
|
|
manongjohn |
8404a6 |
TApp::instance()->getCurrentXsheetViewer()->update();
|
|
manongjohn |
8404a6 |
}
|
|
manongjohn |
8404a6 |
} ToggleTaggedFrame;
|
|
manongjohn |
8404a6 |
|
|
manongjohn |
8404a6 |
//============================================================
|
|
manongjohn |
8404a6 |
|
|
manongjohn |
8404a6 |
class EditTaggedFrame final : public MenuItemHandler {
|
|
manongjohn |
8404a6 |
public:
|
|
manongjohn |
8404a6 |
EditTaggedFrame() : MenuItemHandler(MI_EditTaggedFrame) {}
|
|
manongjohn |
8404a6 |
void execute() override {
|
|
manongjohn |
8404a6 |
TApp *app = TApp::instance();
|
|
manongjohn |
8404a6 |
int frame = app->getCurrentFrame()->getFrame();
|
|
manongjohn |
8404a6 |
assert(frame >= 0);
|
|
manongjohn |
8404a6 |
TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
|
|
manongjohn |
8404a6 |
|
|
manongjohn |
8404a6 |
NavigationTags *tags = xsh->getNavigationTags();
|
|
manongjohn |
8404a6 |
QString label = tags->getTagLabel(frame);
|
|
manongjohn |
8404a6 |
QColor color = tags->getTagColor(frame);
|
|
manongjohn |
8404a6 |
NavTagEditorPopup navTagEditor(frame, label, color);
|
|
manongjohn |
8404a6 |
if (navTagEditor.exec() != QDialog::Accepted) return;
|
|
manongjohn |
8404a6 |
tags->setTagLabel(frame, navTagEditor.getLabel());
|
|
manongjohn |
8404a6 |
tags->setTagColor(frame, navTagEditor.getColor());
|
|
manongjohn |
8404a6 |
}
|
|
manongjohn |
8404a6 |
} EditTaggedFrame;
|
|
manongjohn |
8404a6 |
|
|
manongjohn |
8404a6 |
//============================================================
|
|
manongjohn |
8404a6 |
|
|
manongjohn |
8404a6 |
class NextTaggedFrame final : public MenuItemHandler {
|
|
manongjohn |
8404a6 |
public:
|
|
manongjohn |
8404a6 |
NextTaggedFrame() : MenuItemHandler(MI_NextTaggedFrame) {}
|
|
manongjohn |
8404a6 |
void execute() override {
|
|
manongjohn |
8404a6 |
TApp *app = TApp::instance();
|
|
manongjohn |
8404a6 |
int frame = app->getCurrentFrame()->getFrame();
|
|
manongjohn |
8404a6 |
assert(frame >= 0);
|
|
manongjohn |
8404a6 |
TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
|
|
manongjohn |
8404a6 |
|
|
manongjohn |
8404a6 |
NavigationTags *navTags = xsh->getNavigationTags();
|
|
manongjohn |
8404a6 |
int nextFrame = navTags->getNextTag(frame);
|
|
manongjohn |
8404a6 |
if (nextFrame != -1)
|
|
manongjohn |
8404a6 |
app->getCurrentXsheetViewer()->setCurrentRow(nextFrame);
|
|
manongjohn |
8404a6 |
}
|
|
manongjohn |
8404a6 |
} NextTaggedFrame;
|
|
manongjohn |
8404a6 |
|
|
manongjohn |
8404a6 |
//============================================================
|
|
manongjohn |
8404a6 |
|
|
manongjohn |
8404a6 |
class PrevTaggedFrame final : public MenuItemHandler {
|
|
manongjohn |
8404a6 |
public:
|
|
manongjohn |
8404a6 |
PrevTaggedFrame() : MenuItemHandler(MI_PrevTaggedFrame) {}
|
|
manongjohn |
8404a6 |
void execute() override {
|
|
manongjohn |
8404a6 |
TApp *app = TApp::instance();
|
|
manongjohn |
8404a6 |
int frame = app->getCurrentFrame()->getFrame();
|
|
manongjohn |
8404a6 |
assert(frame >= 0);
|
|
manongjohn |
8404a6 |
TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
|
|
manongjohn |
8404a6 |
|
|
manongjohn |
8404a6 |
NavigationTags *navTags = xsh->getNavigationTags();
|
|
manongjohn |
8404a6 |
int prevFrame = navTags->getPrevTag(frame);
|
|
manongjohn |
8404a6 |
if (prevFrame != -1)
|
|
manongjohn |
8404a6 |
app->getCurrentXsheetViewer()->setCurrentRow(prevFrame);
|
|
manongjohn |
8404a6 |
}
|
|
manongjohn |
8404a6 |
} PrevTaggedFrame;
|
|
manongjohn |
8404a6 |
|
|
manongjohn |
8404a6 |
//============================================================
|
|
manongjohn |
8404a6 |
|
|
manongjohn |
8404a6 |
class ClearTags final : public MenuItemHandler {
|
|
manongjohn |
8404a6 |
public:
|
|
manongjohn |
8404a6 |
ClearTags() : MenuItemHandler(MI_ClearTags) {}
|
|
manongjohn |
8404a6 |
void execute() override {
|
|
manongjohn |
8404a6 |
TApp *app = TApp::instance();
|
|
manongjohn |
8404a6 |
int frame = app->getCurrentFrame()->getFrame();
|
|
manongjohn |
8404a6 |
assert(frame >= 0);
|
|
manongjohn |
8404a6 |
TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
|
|
manongjohn |
8404a6 |
|
|
manongjohn |
8404a6 |
NavigationTags *navTags = xsh->getNavigationTags();
|
|
manongjohn |
8404a6 |
navTags->clearTags();
|
|
manongjohn |
8404a6 |
|
|
manongjohn |
8404a6 |
CommandManager::instance()->enable(MI_NextTaggedFrame, false);
|
|
manongjohn |
8404a6 |
CommandManager::instance()->enable(MI_PrevTaggedFrame, false);
|
|
manongjohn |
8404a6 |
CommandManager::instance()->enable(MI_EditTaggedFrame, false);
|
|
manongjohn |
8404a6 |
CommandManager::instance()->enable(MI_ClearTags, false);
|
|
manongjohn |
8404a6 |
|
|
manongjohn |
8404a6 |
TApp::instance()->getCurrentXsheetViewer()->update();
|
|
manongjohn |
8404a6 |
}
|
|
manongjohn |
8404a6 |
} ClearTags;
|