|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tframehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzscene.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshsimplelevel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheet.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshcell.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/sceneproperties.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toutputproperties.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheethandle.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Rozhuk Ivan |
823a31 |
#if 0
|
|
Toshihiro Shimizu |
890ddd |
/* int getCurrentSceneFrameCount()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
120a6e |
return 100; //
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentScene()->getScene()->getFrameCount();
|
|
Toshihiro Shimizu |
890ddd |
}*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*void getCurrentScenePlayRange(int &r0, int &r1, int &step)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
|
|
Toshihiro Shimizu |
890ddd |
scene->getProperties()->getPreviewProperties()->getRange(r0, r1, step);
|
|
Toshihiro Shimizu |
890ddd |
if(r0>r1)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
r0 = 0;
|
|
Toshihiro Shimizu |
890ddd |
r1 = scene->getFrameCount()-1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
/* r0 = 0;
|
|
Toshihiro Shimizu |
890ddd |
r1 = getCurrentSceneFrameCount()-1;
|
|
Toshihiro Shimizu |
890ddd |
}*/
|
|
Rozhuk Ivan |
823a31 |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool getCurrentLevelFids(std::vector<tframeid> &fids) {</tframeid>
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
TXshSimpleLevel *sl = TApp::instance()->getCurrentLevel()->getSimpleLevel();
|
|
Shinya Kitaoka |
120a6e |
if(!sl) return false;
|
|
Shinya Kitaoka |
120a6e |
sl->getFids(fids);
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
fids.push_back(TFrameId(1));
|
|
Shinya Kitaoka |
120a6e |
return !fids.empty();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFrameId getLastLevelFid() { return TFrameId(1); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// TFrameHandle
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFrameHandle::TFrameHandle()
|
|
Shinya Kitaoka |
120a6e |
: m_frame(-1)
|
|
Shinya Kitaoka |
120a6e |
, m_fid()
|
|
Shinya Kitaoka |
120a6e |
, m_timerId(0)
|
|
Shinya Kitaoka |
120a6e |
, m_previewFrameRate(25)
|
|
Shinya Kitaoka |
120a6e |
, m_frameType(SceneFrame)
|
|
Shinya Kitaoka |
120a6e |
, m_looping(false)
|
|
Shinya Kitaoka |
120a6e |
, m_isPlaying(false)
|
|
Shinya Kitaoka |
120a6e |
, m_scrubRange(0, -1)
|
|
Shinya Kitaoka |
120a6e |
, m_audioColumn(0)
|
|
Shinya Kitaoka |
120a6e |
, m_xsheet(0)
|
|
Shinya Kitaoka |
120a6e |
, m_fps(0)
|
|
Shinya Kitaoka |
120a6e |
, m_frame0(-1)
|
|
Shinya Kitaoka |
120a6e |
, m_frame1(-1) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFrameHandle::~TFrameHandle() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TFrameHandle::getFrame() const { return m_frame; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFrameHandle::setCurrentFrame(int frame) {
|
|
Shinya Kitaoka |
120a6e |
if (m_frameType == LevelFrame) {
|
|
Shinya Kitaoka |
120a6e |
// std::vector<tframeid> fids;</tframeid>
|
|
Shinya Kitaoka |
120a6e |
// if(!getCurrentLevelFids(fids)) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_fids.size() <= 0) return;
|
|
Shinya Kitaoka |
120a6e |
if (frame - 1 >= (int)m_fids.size())
|
|
Shinya Kitaoka |
120a6e |
setFid(m_fids.back());
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
setFid(m_fids[frame - 1]);
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
setFrame(frame - 1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFrameHandle::setFrame(int frame) {
|
|
Shinya Kitaoka |
120a6e |
if (m_frame == frame && m_frameType == SceneFrame) return;
|
|
Shinya Kitaoka |
120a6e |
m_frame = frame;
|
|
Shinya Kitaoka |
120a6e |
if (m_frameType != SceneFrame) {
|
|
Shinya Kitaoka |
120a6e |
m_frameType = SceneFrame;
|
|
Shinya Kitaoka |
120a6e |
emit frameTypeChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
emit frameSwitched();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFrameId TFrameHandle::getFid() const { return m_fid; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFrameHandle::setFid(const TFrameId &fid) {
|
|
Shinya Kitaoka |
120a6e |
if (m_fid == fid && m_frameType == LevelFrame) return;
|
|
Shinya Kitaoka |
120a6e |
m_fid = fid;
|
|
Shinya Kitaoka |
120a6e |
if (m_frameType != LevelFrame) {
|
|
Shinya Kitaoka |
120a6e |
m_frameType = LevelFrame;
|
|
Shinya Kitaoka |
120a6e |
emit frameTypeChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
emit frameSwitched();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jeremy Bullock |
3e69f9 |
void TFrameHandle::nextFrame(TFrameId id) {
|
|
Shinya Kitaoka |
120a6e |
if (m_frameType == LevelFrame) {
|
|
Shinya Kitaoka |
120a6e |
// std::vector<tframeid> fids;</tframeid>
|
|
Shinya Kitaoka |
120a6e |
// if(!getCurrentLevelFids(fids)) return;
|
|
Shinya Kitaoka |
120a6e |
if (m_fids.size() <= 0) return;
|
|
Shinya Kitaoka |
120a6e |
std::vector<tframeid>::iterator it;</tframeid>
|
|
Shinya Kitaoka |
120a6e |
it = std::upper_bound(m_fids.begin(), m_fids.end(), m_fid);
|
|
Shinya Kitaoka |
120a6e |
if (it == m_fids.end()) {
|
|
Shinya Kitaoka |
120a6e |
// non c'e' nessun frame del livello oltre m_fid. Non vado oltre al primo
|
|
Shinya Kitaoka |
120a6e |
// frame dopo l'ultimo.
|
|
Shinya Kitaoka |
120a6e |
// TXshSimpleLevel *sl =
|
|
Shinya Kitaoka |
120a6e |
// TApp::instance()->getCurrentLevel()->getSimpleLevel();
|
|
Jeremy Bullock |
3e69f9 |
if (id != 0) {
|
|
Jeremy Bullock |
3e69f9 |
setFid(id);
|
|
Jeremy Bullock |
3e69f9 |
} else {
|
|
Jeremy Bullock |
3e69f9 |
TFrameId fid = m_fids.back(); // sl->index2fid(sl->getFrameCount());
|
|
Jeremy Bullock |
3e69f9 |
setFid(fid);
|
|
Jeremy Bullock |
3e69f9 |
}
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
setFid(*it);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
setFrame(m_frame + 1);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFrameHandle::prevFrame() {
|
|
Shinya Kitaoka |
120a6e |
if (m_frameType == LevelFrame) {
|
|
Shinya Kitaoka |
120a6e |
// std::vector<tframeid> fids;</tframeid>
|
|
Shinya Kitaoka |
120a6e |
if (m_fids.size() <= 0) return;
|
|
Shinya Kitaoka |
120a6e |
std::vector<tframeid>::iterator it;</tframeid>
|
|
Shinya Kitaoka |
120a6e |
it = std::lower_bound(m_fids.begin(), m_fids.end(), m_fid);
|
|
Shinya Kitaoka |
120a6e |
// tornando indietro non vado prima del primo frame del livello
|
|
Shinya Kitaoka |
120a6e |
if (it != m_fids.end() && it != m_fids.begin()) {
|
|
Shinya Kitaoka |
120a6e |
--it;
|
|
Shinya Kitaoka |
120a6e |
setFid(*it);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
// se sono dopo l'ultimo, vado all'ultimo
|
|
Shinya Kitaoka |
120a6e |
if (!m_fids.empty() && m_fid > m_fids.back()) setFid(m_fids.back());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
if (m_frame > 0) setFrame(m_frame - 1);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFrameHandle::firstFrame() {
|
|
Shinya Kitaoka |
120a6e |
if (m_frameType == LevelFrame) {
|
|
Shinya Kitaoka |
120a6e |
// std::vector<tframeid> fids;</tframeid>
|
|
Shinya Kitaoka |
120a6e |
if (m_fids.size() <= 0) return;
|
|
Shinya Kitaoka |
120a6e |
setFid(m_fids.front());
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
/*int r0,r1,step;
|
|
Shinya Kitaoka |
120a6e |
getCurrentScenePlayRange(r0,r1,step);*/
|
|
Shinya Kitaoka |
120a6e |
setFrame(m_frame0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFrameHandle::lastFrame() {
|
|
Shinya Kitaoka |
120a6e |
if (m_frameType == LevelFrame) {
|
|
Shinya Kitaoka |
120a6e |
// std::vector<tframeid> fids;</tframeid>
|
|
Shinya Kitaoka |
120a6e |
if (m_fids.size() <= 0) return;
|
|
Shinya Kitaoka |
120a6e |
setFid(m_fids.back());
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
/*int r0,r1,step;
|
|
Shinya Kitaoka |
120a6e |
getCurrentScenePlayRange(r0,r1,step);*/
|
|
Shinya Kitaoka |
120a6e |
if (m_frame1 > 0) setFrame(m_frame1);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFrameHandle::setPlaying(bool isPlaying) {
|
|
Shinya Kitaoka |
120a6e |
if (m_isPlaying == isPlaying) return;
|
|
Shinya Kitaoka |
120a6e |
m_isPlaying = isPlaying;
|
|
Shinya Kitaoka |
120a6e |
emit isPlayingStatusChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
#ifdef LEVO
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFrameHandle::startPlaying(bool looping) {
|
|
Shinya Kitaoka |
120a6e |
if (m_previewFrameRate == 0) return;
|
|
Shinya Kitaoka |
120a6e |
if (isScrubbing()) stopScrubbing();
|
|
Shinya Kitaoka |
120a6e |
setTimer(m_previewFrameRate);
|
|
Shinya Kitaoka |
120a6e |
m_looping = looping;
|
|
Shinya Kitaoka |
120a6e |
emit playStarted();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFrameHandle::stopPlaying() {
|
|
Shinya Kitaoka |
120a6e |
if (m_timerId != 0) killTimer(m_timerId);
|
|
Shinya Kitaoka |
120a6e |
m_timerId = 0;
|
|
Shinya Kitaoka |
120a6e |
m_looping = false;
|
|
Shinya Kitaoka |
120a6e |
emit playStopped();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFrameHandle::setTimer(int frameRate) {
|
|
Shinya Kitaoka |
120a6e |
m_previewFrameRate = frameRate;
|
|
Shinya Kitaoka |
120a6e |
if (m_timerId != 0) killTimer(m_timerId);
|
|
Shinya Kitaoka |
120a6e |
int interval = troundp(1000.0 / double(m_previewFrameRate));
|
|
Shinya Kitaoka |
120a6e |
m_timerId = startTimer(interval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFrameHandle::timerEvent(QTimerEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
assert(isScrubbing());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int elapsedTime = m_clock.elapsed();
|
|
Shinya Kitaoka |
120a6e |
int frame = m_scrubRange.first + elapsedTime * m_fps / 1000;
|
|
Shinya Kitaoka |
120a6e |
int lastFrame = m_scrubRange.second;
|
|
Shinya Kitaoka |
120a6e |
if (frame >= lastFrame) {
|
|
Shinya Kitaoka |
120a6e |
if (m_frame != lastFrame) setFrame(lastFrame);
|
|
Shinya Kitaoka |
120a6e |
stopScrubbing();
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
setFrame(frame);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TFrameHandle::getMaxFrameIndex() const {
|
|
Shinya Kitaoka |
120a6e |
if (m_frameType == LevelFrame) {
|
|
Shinya Kitaoka |
120a6e |
// std::vector<tframeid> fids;</tframeid>
|
|
Shinya Kitaoka |
120a6e |
if (m_fids.size() <= 0)
|
|
Shinya Kitaoka |
120a6e |
return -1;
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
return m_fids.size() - 1;
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
// return getCurrentSceneFrameCount()-1;
|
|
Shinya Kitaoka |
120a6e |
return m_sceneFrameSize - 1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TFrameHandle::getFrameIndex() const {
|
|
Shinya Kitaoka |
120a6e |
if (m_frameType == LevelFrame) {
|
|
Shinya Kitaoka |
120a6e |
// std::vector<tframeid> fids;</tframeid>
|
|
Shinya Kitaoka |
120a6e |
if (m_fids.size() > 0) {
|
|
Shinya Kitaoka |
120a6e |
std::vector<tframeid>::const_iterator it =</tframeid>
|
|
Shinya Kitaoka |
120a6e |
std::find(m_fids.begin(), m_fids.end(), m_fid);
|
|
Shinya Kitaoka |
120a6e |
if (it != m_fids.end())
|
|
Shinya Kitaoka |
120a6e |
return std::distance(m_fids.begin(), it);
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
if (m_fid > m_fids.back())
|
|
Shinya Kitaoka |
120a6e |
return m_fids.size();
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
return -1;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
return -1;
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
return m_frame;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString TFrameHandle::getFrameIndexName(int index) const {
|
|
Shinya Kitaoka |
120a6e |
if (m_frameType == LevelFrame) {
|
|
Shinya Kitaoka |
120a6e |
if (m_fid.getNumber() <= 0)
|
|
Shinya Kitaoka |
120a6e |
return "";
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
return QString::number(m_fid.getNumber());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
return QString::number(m_frame + 1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFrameHandle::setFrameIndex(int index) {
|
|
Shinya Kitaoka |
120a6e |
if (m_frameType == LevelFrame) {
|
|
Shinya Kitaoka |
120a6e |
// std::vector<tframeid> fids;</tframeid>
|
|
Shinya Kitaoka |
120a6e |
if (m_fids.size() > 0 && 0 <= index && index < (int)m_fids.size())
|
|
Shinya Kitaoka |
120a6e |
setFid(m_fids[index]);
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
setFrame(index);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFrameHandle::setFrameIndexByName(const QString &str) {
|
|
Shinya Kitaoka |
120a6e |
int num = str.toInt();
|
|
Shinya Kitaoka |
120a6e |
if (m_frameType == LevelFrame) {
|
|
Shinya Kitaoka |
120a6e |
setFid(TFrameId(num));
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
setFrame(num - 1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFrameHandle::scrubColumn(int r0, int r1, TXshSoundColumn *audioColumn,
|
|
Shinya Kitaoka |
120a6e |
double framePerSecond) {
|
|
Shinya Kitaoka |
120a6e |
m_audioColumn = audioColumn;
|
|
Shinya Kitaoka |
120a6e |
if (!scrub(r0, r1, framePerSecond)) m_audioColumn = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFrameHandle::scrubXsheet(int r0, int r1, TXsheet *xsheet,
|
|
Shinya Kitaoka |
120a6e |
double framePerSecond) {
|
|
Shinya Kitaoka |
120a6e |
m_xsheet = xsheet;
|
|
Shinya Kitaoka |
120a6e |
if (!scrub(r0, r1, framePerSecond)) m_xsheet = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool TFrameHandle::scrub(int r0, int r1, double framePerSecond) {
|
|
Shinya Kitaoka |
120a6e |
if (isPlaying() || isScrubbing()) return false;
|
|
Shinya Kitaoka |
120a6e |
bool onlyOneFrame = (r0 == r1);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!isScrubbing() || !onlyOneFrame) emit scrubStarted();
|
|
Shinya Kitaoka |
120a6e |
if (!onlyOneFrame) {
|
|
Shinya Kitaoka |
120a6e |
m_fps = framePerSecond;
|
|
Shinya Kitaoka |
120a6e |
m_scrubRange = std::make_pair(r0, r1);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
setFrame(r0);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_audioColumn)
|
|
Shinya Kitaoka |
120a6e |
m_audioColumn->scrub(r0, r1);
|
|
Shinya Kitaoka |
120a6e |
else if (m_xsheet) {
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
manongjohn |
25e6cf |
for (i = r0; i <= r1; i++) m_xsheet->scrub(i, true);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (onlyOneFrame) return false;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_clock.start();
|
|
Shinya Kitaoka |
120a6e |
m_timerId = startTimer(40);
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFrameHandle::stopScrubbing() {
|
|
Shinya Kitaoka |
120a6e |
if (!isScrubbing()) return;
|
|
Shinya Kitaoka |
120a6e |
if (m_timerId > 0) killTimer(m_timerId);
|
|
Shinya Kitaoka |
120a6e |
m_timerId = 0;
|
|
Shinya Kitaoka |
120a6e |
m_scrubRange = std::make_pair(0, -1);
|
|
Shinya Kitaoka |
120a6e |
if (m_audioColumn) m_audioColumn = 0;
|
|
Shinya Kitaoka |
120a6e |
if (m_xsheet) m_xsheet = 0;
|
|
Shinya Kitaoka |
120a6e |
m_fps = 0;
|
|
Shinya Kitaoka |
120a6e |
emit scrubStopped();
|
|
Toshihiro Shimizu |
890ddd |
}
|