本文整理汇总了C++中SyncDocument::createTrack方法的典型用法代码示例。如果您正苦于以下问题:C++ SyncDocument::createTrack方法的具体用法?C++ SyncDocument::createTrack怎么用?C++ SyncDocument::createTrack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyncDocument
的用法示例。
在下文中一共展示了SyncDocument::createTrack方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processCommand
static void processCommand(ClientSocket &sock)
{
SyncDocument *doc = trackView->getDocument();
int strLen, serverIndex, newRow;
std::string trackName;
const sync_track *t;
unsigned char cmd = 0;
if (sock.recv((char*)&cmd, 1)) {
switch (cmd) {
case GET_TRACK:
// read data
sock.recv((char *)&strLen, sizeof(int));
strLen = ntohl(strLen);
if (!sock.connected())
return;
if (!strLen) {
sock.disconnect();
InvalidateRect(trackViewWin, NULL, FALSE);
return;
}
trackName.resize(strLen);
if (!sock.recv(&trackName[0], strLen))
return;
if (int(strlen(trackName.c_str())) != strLen) {
sock.disconnect();
InvalidateRect(trackViewWin, NULL, FALSE);
return;
}
// find track
serverIndex = sync_find_track(doc,
trackName.c_str());
if (0 > serverIndex)
serverIndex =
int(doc->createTrack(trackName));
// setup remap
doc->clientSocket.clientTracks[trackName] = clientIndex++;
// send key-frames
t = doc->tracks[serverIndex];
for (int i = 0; i < (int)t->num_keys; ++i)
doc->clientSocket.sendSetKeyCommand(trackName,
t->keys[i]);
InvalidateRect(trackViewWin, NULL, FALSE);
break;
case SET_ROW:
sock.recv((char*)&newRow, sizeof(int));
trackView->setEditRow(ntohl(newRow));
break;
}
}
}
示例2: processCommand
void processCommand(NetworkSocket &sock)
{
size_t clientIndex = 0;
int strLen, serverIndex, newRow;
std::string trackName;
const sync_track *t;
unsigned char cmd = 0;
if (sock.recv((char*)&cmd, 1, 0)) {
switch (cmd) {
case GET_TRACK:
// read data
sock.recv((char *)&clientIndex, sizeof(int), 0);
sock.recv((char *)&strLen, sizeof(int), 0);
clientIndex = ntohl(clientIndex);
strLen = ntohl(strLen);
if (!sock.connected())
return;
trackName.resize(strLen);
if (!sock.recv(&trackName[0], strLen, 0))
return;
// find track
serverIndex = sync_find_track(&document,
trackName.c_str());
if (0 > serverIndex)
serverIndex =
int(document.createTrack(trackName));
// setup remap
document.clientRemap[serverIndex] = clientIndex;
// send key-frames
t = document.tracks[serverIndex];
for (int i = 0; i < (int)t->num_keys; ++i)
document.sendSetKeyCommand(int(serverIndex),
t->keys[i]);
InvalidateRect(trackViewWin, NULL, FALSE);
break;
case SET_ROW:
sock.recv((char*)&newRow, sizeof(int), 0);
trackView->setEditRow(ntohl(newRow));
break;
}
}
}
示例3: file
SyncDocument *SyncDocument::load(const QString &fileName)
{
SyncDocument *ret = new SyncDocument;
ret->fileName = fileName;
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
QMessageBox::critical(NULL, "Error", file.errorString());
return NULL;
}
QDomDocument doc;
QString err;
if (!doc.setContent(&file, &err)) {
file.close();
QMessageBox::critical(NULL, "Error", err);
return NULL;
}
file.close();
QDomNamedNodeMap attribs = doc.documentElement().attributes();
QDomNode rowsParam = attribs.namedItem("rows");
if (!rowsParam.isNull()) {
QString rowsString = rowsParam.nodeValue();
ret->setRows(rowsString.toInt());
}
QDomNodeList trackNodes =
doc.documentElement().elementsByTagName("track");
for (int i = 0; i < int(trackNodes.length()); ++i) {
QDomNode trackNode = trackNodes.item(i);
QDomNamedNodeMap attribs = trackNode.attributes();
QString name = attribs.namedItem("name").nodeValue();
// look up track-name, create it if it doesn't exist
SyncTrack *t = ret->findTrack(name.toUtf8());
if (!t)
t = ret->createTrack(name.toUtf8().constData());
QDomNodeList rowNodes = trackNode.childNodes();
for (int i = 0; i < int(rowNodes.length()); ++i) {
QDomNode keyNode = rowNodes.item(i);
QString baseName = keyNode.nodeName();
if (baseName == "key") {
QDomNamedNodeMap rowAttribs = keyNode.attributes();
QString rowString = rowAttribs.namedItem("row").nodeValue();
QString valueString = rowAttribs.namedItem("value").nodeValue();
QString interpolationString = rowAttribs.namedItem("interpolation").nodeValue();
SyncTrack::TrackKey k;
k.row = rowString.toInt();
k.value = valueString.toFloat();
k.type = SyncTrack::TrackKey::KeyType(interpolationString.toInt());
Q_ASSERT(!t->isKeyFrame(k.row));
t->setKey(k);
}
}
}
// YUCK: gathers from entire document
QDomNodeList bookmarkNodes =
doc.documentElement().elementsByTagName("bookmark");
for (int i = 0; i < int(bookmarkNodes.length()); ++i) {
QDomNode bookmarkNode =
bookmarkNodes.item(i);
QDomNamedNodeMap bookmarkAttribs =
bookmarkNode.attributes();
QString str =
bookmarkAttribs.namedItem("row").nodeValue();
int row = str.toInt();
ret->toggleRowBookmark(row);
}
return ret;
}