本文整理汇总了C++中SignalData::setAsDomain方法的典型用法代码示例。如果您正苦于以下问题:C++ SignalData::setAsDomain方法的具体用法?C++ SignalData::setAsDomain怎么用?C++ SignalData::setAsDomain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SignalData
的用法示例。
在下文中一共展示了SignalData::setAsDomain方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrepareReplay
DataToReplay PrepareReplay(const QString& file, SignalData& signalData)
{
SignalData data; PlotInfo info;
WorkspaceSerializer::Read(file, data, info);
DataMap toSet;
vector < pair<QString, QVector<qreal>>> toSend;
data.onSignals([&](const Signal& signal){
toSet.emplace(signal.name, Signal{ signal.name, {}, signal.graphic });
toSend.emplace_back(make_pair(signal.name, std::move(signal.y)));
});
for (auto& signal : toSet)
{
signalData.addIfNotExists(std::move(signal.second));
}
signalData.setAsDomain(data.getDomain()->name);
return toSend;
}
示例2: Read
void Read(const QString& fileName, SignalData& data, PlotInfo& plotInfo, std::function<void(Signal&&)> onSignal, std::function<void()> onAfterSignalRead)
{
QFile in(fileName);
if (!in.open(QIODevice::ReadOnly | QFile::Text))
{
auto mex = QString("Cannot open specified file -> %1").arg(fileName);
QMessageBox::critical(nullptr, "Anvedi", mex);
throw std::exception(mex.toUtf8().data());
}
const auto json = QJsonDocument::fromJson(in.readAll()).object();
auto backgroundIt = json.find("background");
if (backgroundIt != json.end())
{
plotInfo.setBackgroundColor(backgroundIt->toString());
}
auto graphIt = json.find("signals");
if ((graphIt != json.end()) && graphIt->isArray())
{
for (const auto& elem : graphIt->toArray())
{
if (elem.isObject())
{
onSignal(ReadGraph(elem.toObject()));
}
}
}
onAfterSignalRead();
auto domainIt = json.find("domain");
if (domainIt != json.end())
{
const auto domainName = domainIt->toString();
try
{
data.setAsDomain(domainName);
}
catch (const std::exception&){}
}
}
示例3: WriteTest
void WorkspaceSerializerTests::WriteTest()
{
DataMap dataMap = {
{ "cubic",
{
"cubic", { 1, 8, 27, 64, 125, 216, 343, 512, 729, 1000 }, { "#008000", true, 1, 1000 }
}
},
{ "line",
{
"line", { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, { "#ffff00", false, 1, 10 }
}
}
};
PlotInfo plot;
plot.setBackgroundColor("red");
SignalData data;
data.add(dataMap);
data.setAsDomain("line");
QString tmpFileName = std::tmpnam(nullptr);
struct guard
{
guard(const QString& fileName)
: fileName(fileName)
{
}
~guard()
{
QFile f(fileName);
f.remove();
}
const QString& fileName;
} fileDeleter(tmpFileName);
WorkspaceSerializer::Write(tmpFileName, data, plot);
VerifyActualDataAndPersistedFile(tmpFileName, dataMap, "line", "red");
}