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