本文整理汇总了C++中CCopasiDataModel::getObject方法的典型用法代码示例。如果您正苦于以下问题:C++ CCopasiDataModel::getObject方法的具体用法?C++ CCopasiDataModel::getObject怎么用?C++ CCopasiDataModel::getObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCopasiDataModel
的用法示例。
在下文中一共展示了CCopasiDataModel::getObject方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initFromScanItem
bool CScanWidgetRandom::initFromScanItem(CCopasiParameterGroup * pg, const CModel* model)
{
if (!model) return false;
mpModel = model;
unsigned C_INT32 * tmp;
if (!(tmp = pg->getValue("Type").pUINT)) return false;
if (*(CScanProblem::Type *) tmp != CScanProblem::SCAN_RANDOM)
return false;
std::string *pString;
if (!(pString = pg->getValue("Object").pSTRING)) return false;
if (*pString == "")
mpObject = NULL;
else
{
assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
assert(pDataModel != NULL);
mpObject = pDataModel->getObject(*pString);
}
if (mpObject)
lineEditObject->setText(FROM_UTF8(mpObject->getObjectDisplayName()));
else
lineEditObject->setText("");
if (!(tmp = pg->getValue("Distribution type").pUINT)) return false;
comboBoxType->setCurrentItem(*tmp);
changeType();
lineEditMin->setText(getParameterValue(pg, "Minimum"));
lineEditMax->setText(getParameterValue(pg, "Maximum"));
bool * pBool;
if (!(pBool = pg->getValue("log").pBOOL)) return false;
checkBoxLog->setChecked(* pBool);
return true;
}
示例2: assert
bool
CQSpectogramWidget::LoadFromCurveSpec(const CPlotItem * pCurve)
{
if (!pCurve)
{
// We need to reset the widget to defaults
mpEditTitle->setText("");
mpObjectX = mpObjectY = mpObjectZ = NULL;
mpEditX->setText("");
mpEditY->setText("");
mpEditZ->setText("");
mpCheckBefore->setChecked(false);
mpCheckDuring->setChecked(true);
mpCheckAfter->setChecked(false);
return true;
}
if (pCurve->getType() != CPlotItem::spectogram) return false;
//if (pCurve->getChannels().getSize != 3) return false;
mpEditTitle->setText(FROM_UTF8(pCurve->getTitle()));
//TODO: check if objects exist....
assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
CCopasiDataModel* pDataModel = &CCopasiRootContainer::getDatamodelList()->operator[](0);
assert(pDataModel != NULL);
mpObjectX = mpObjectY = mpObjectZ = NULL;
if (pCurve->getChannels().size() >= 1)
mpObjectX = dynamic_cast<const CCopasiObject*>(pDataModel->getObject(pCurve->getChannels()[0]));
if (pCurve->getChannels().size() >= 2)
mpObjectY = dynamic_cast<const CCopasiObject*>(pDataModel->getObject(pCurve->getChannels()[1]));
if (pCurve->getChannels().size() >= 3)
{
mpObjectZ = dynamic_cast<const CCopasiObject*>(pDataModel->getObject(pCurve->getChannels()[2]));
if ((mpObjectZ->getObjectDisplayName() == "(CN)Root") && mpObjectY)
mpObjectZ = mpObjectY; // as long as we haven't a second Y-axis chooser, this has to suffice.
}
if (mpObjectX)
mpEditX->setText(FROM_UTF8(mpObjectX->getObjectDisplayName()));
else
mpEditX->clear();
if (mpObjectY)
mpEditY->setText(FROM_UTF8(mpObjectY->getObjectDisplayName()));
else
mpEditY->clear();
if (mpObjectZ)
mpEditZ->setText(FROM_UTF8(mpObjectZ->getObjectDisplayName()));
else
mpEditZ->clear();
CPlotItem* pItem = const_cast<CPlotItem*>(pCurve);
mpLogZ->setChecked(*pItem->assertParameter("logZ", CCopasiParameter::BOOL, false));
mpBilinear->setChecked(*pItem->assertParameter("bilinear", CCopasiParameter::BOOL, true));
std::string *contours = pItem->assertParameter("contours", CCopasiParameter::STRING, std::string(""));
mpContours->setText(FROM_UTF8(*contours));
std::string *maxZ = pItem->assertParameter("maxZ", CCopasiParameter::STRING, std::string(""));
mpMaxZ->setText(FROM_UTF8(*maxZ));
std::string *colorMap = pItem->assertParameter("colorMap", CCopasiParameter::STRING, std::string("Default"));
mpColorMap->setCurrentIndex(mpColorMap->findText(FROM_UTF8(*colorMap)));
mpCheckBefore->setChecked(pCurve->getActivity() & COutputInterface::BEFORE);
mpCheckDuring->setChecked(pCurve->getActivity() & COutputInterface::DURING);
mpCheckAfter->setChecked(pCurve->getActivity() & COutputInterface::AFTER);
return true;
}
示例3: createScanTask
/**
* Creates the simulations for SEDML.
*/
std::string CSEDMLExporter::createScanTask(CCopasiDataModel& dataModel, const std::string & modelId)
{
// need L1V2 to export repeated tasks
if (mpSEDMLDocument->getVersion() != 2) return "";
CScanTask* pTask = dynamic_cast<CScanTask*>((*dataModel.getTaskList())["Scan"]);
if (pTask == NULL) return "";
CScanProblem* pProblem = dynamic_cast<CScanProblem*>(pTask->getProblem());
size_t numItems = pProblem->getNumberOfScanItems();
if (numItems == 0)
return "";
if (pProblem->getSubtask() != CCopasiTask::steadyState &&
pProblem->getSubtask() != CCopasiTask::timeCourse)
{
CCopasiMessage(CCopasiMessage::WARNING, "This version of COPASI only allows the export of time course or steady state scans.");
return "";
}
std::string subTaskId;
if (pProblem->getSubtask() == CCopasiTask::steadyState)
{
subTaskId = createSteadyStateTask(dataModel, modelId);
}
else
{
subTaskId = mpTimecourseTask->getId();
}
SedRepeatedTask* task = mpSEDMLDocument->createRepeatedTask();
std::string taskId = SEDMLUtils::getNextId("task", mpSEDMLDocument->getNumTasks());
task->setId(taskId);
task->setResetModel(!pProblem->getContinueFromCurrentState());
// craete ranges / changes
for (size_t i = 0; i < numItems; ++i)
{
CCopasiParameterGroup* current = pProblem->getScanItem(i);
CScanProblem::Type type = (CScanProblem::Type)(*current->getParameter("Type")->getValue().pUINT);
// ignore random items
if (type == CScanProblem::SCAN_RANDOM)
{
CCopasiMessage(CCopasiMessage::WARNING, "This version of COPASI cannot export random scan items, they will be ignored.");
continue;
}
int numSteps = (*current->getParameter("Number of steps")->getValue().pUINT);
// handle repeats
if (type == CScanProblem::SCAN_REPEAT)
{
SedUniformRange *range = task->createUniformRange();
range->setId(SEDMLUtils::getNextId("range", task->getNumRanges()));
range->setStart(0);
range->setEnd(numSteps);
range->setNumberOfPoints(numSteps);
range->setType("linear");
if (task->isSetRangeId())
task->setRangeId(range->getId());
continue;
}
// handle scans
if (type == CScanProblem::SCAN_LINEAR)
{
double min = (*current->getParameter("Minimum")->getValue().pDOUBLE);
double max = (*current->getParameter("Maximum")->getValue().pDOUBLE);
bool log = (*current->getParameter("log")->getValue().pBOOL);
SedUniformRange *range = task->createUniformRange();
range->setId(SEDMLUtils::getNextId("range", task->getNumRanges()));
range->setStart(min);
range->setEnd(max);
range->setNumberOfPoints(numSteps);
range->setType(log ? "log" : "linear");
const CRegisteredObjectName& cn = (*current->getParameter("Object")->getValue().pCN);
std::string xpath = SEDMLUtils::getXPathForObject(*static_cast<const CCopasiObject*>(dataModel.getObject(cn)));
if (xpath.empty())
{
CCopasiMessage(CCopasiMessage::WARNING, "This version of COPASI cannot export the selected scan object, it will be ignored.");
continue;
}
SedSetValue *change = task->createTaskChange();
change->setModelReference(modelId);
if (xpath == SEDML_TIME_URN)
{
//.........这里部分代码省略.........
示例4: assert
bool
BandedGraphWidget::LoadFromCurveSpec(const CPlotItem * pCurve)
{
if (!pCurve)
{
// We need to reset the widget to defaults
mpEditTitle->setText("");
mpObjectX = mpObjectYone = mpObjectYtwo = NULL;
mpEditX->setText("");
mpEditYone->setText("");
mpEditYtwo->setText("");
mpCheckBefore->setChecked(false);
mpCheckDuring->setChecked(true);
mpCheckAfter->setChecked(false);
return true;
}
if (pCurve->getType() != CPlotItem::bandedGraph) return false;
//if (pCurve->getChannels().getSize != 3) return false;
mpEditTitle->setText(FROM_UTF8(pCurve->getTitle()));
CCopasiDataModel* pDataModel = pCurve->getObjectDataModel();
assert(pDataModel != NULL);
mpObjectX = mpObjectYone = mpObjectYtwo = NULL;
if (pCurve->getChannels().size() >= 1)
mpObjectX = dynamic_cast<const CCopasiObject*>(pDataModel->getObject(pCurve->getChannels()[0]));
if (pCurve->getChannels().size() >= 2)
mpObjectYone = dynamic_cast<const CCopasiObject*>(pDataModel->getObject(pCurve->getChannels()[1]));
if (pCurve->getChannels().size() >= 3)
{
mpObjectYtwo = dynamic_cast<const CCopasiObject*>(pDataModel->getObject(pCurve->getChannels()[2]));
if ((mpObjectYtwo->getObjectDisplayName() == "(CN)Root") && mpObjectYone)
mpObjectYtwo = mpObjectYone; // as long as we haven't a second Y-axis chooser, this has to suffice.
}
if (mpObjectX)
mpEditX->setText(FROM_UTF8(mpObjectX->getObjectDisplayName()));
else
mpEditX->clear();
if (mpObjectYone)
mpEditYone->setText(FROM_UTF8(mpObjectYone->getObjectDisplayName()));
else
mpEditYone->clear();
if (mpObjectYtwo)
mpEditYtwo->setText(FROM_UTF8(mpObjectYtwo->getObjectDisplayName()));
else
mpEditYtwo->clear();
mpCheckBefore->setChecked(pCurve->getActivity() & COutputInterface::BEFORE);
mpCheckDuring->setChecked(pCurve->getActivity() & COutputInterface::DURING);
mpCheckAfter->setChecked(pCurve->getActivity() & COutputInterface::AFTER);
return true;
}
示例5: slotSave
void CQFittingResult::slotSave(void)
{
C_INT32 Answer = QMessageBox::No;
QString fileName;
while (Answer == QMessageBox::No)
{
fileName =
CopasiFileDialog::getSaveFileName(this, "Save File Dialog",
QString::null, "TEXT Files (*.txt);;All Files (*.*);;", "Save to");
if (fileName.isEmpty()) return;
if (!fileName.endsWith(".txt") &&
!fileName.endsWith(".")) fileName += ".txt";
fileName = fileName.remove(QRegExp("\\.$"));
Answer = checkSelection(fileName);
if (Answer == QMessageBox::Cancel) return;
}
std::ofstream file(utf8ToLocale(TO_UTF8(fileName)).c_str());
if (file.fail()) return;
unsigned C_INT32 i, imax;
// The global result and statistics
file << "Objective Value\tRoot Mean Square\tStandard Deviation" << std::endl;
file << mpProblem->getSolutionValue() << "\t";
file << mpProblem->getRMS() << "\t";
file << mpProblem->getStdDeviation() << std::endl;
file << "Function Evaluations\tCPU Time [s]\tEvaluations/second [1/s]" << std::endl;
const unsigned C_INT32 & FunctionEvaluations = mpProblem->getFunctionEvaluations();
const C_FLOAT64 & ExecutionTime = mpProblem->getExecutionTime();
file << FunctionEvaluations << "\t";
file << ExecutionTime << "\t";
file << FunctionEvaluations / ExecutionTime << std::endl;
// Set up the parameters table
file << std::endl << "Parameters:" << std::endl;
file << "Parameter\tValue\tStd. Deviation\tCoeff. of Variation [%]\tGradient" << std::endl;
// Loop over the optimization items
const std::vector< COptItem * > & Items = mpProblem->getOptItemList();
const CVector< C_FLOAT64 > & Solutions = mpProblem->getSolutionVariables();
const CVector< C_FLOAT64 > & StdDeviations = mpProblem->getVariableStdDeviations();
const CVector< C_FLOAT64 > & Gradients = mpProblem->getVariableGradients();
imax = Items.size();
if (mpProblem->getFunctionEvaluations() == 0)
imax = 0;
assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
assert(pDataModel != NULL);
for (i = 0; i != imax; i++)
{
const CCopasiObject *pObject =
pDataModel->getObject(Items[i]->getObjectCN());
if (pObject)
{
std::string Experiments =
static_cast<CFitItem *>(Items[i])->getExperiments();
if (Experiments != "")
Experiments = "; {" + Experiments + "}";
file << pObject->getObjectDisplayName() << Experiments << "\t";
}
else
file << "Not Found\t";
const C_FLOAT64 & Solution = Solutions[i];
file << Solution << "\t";
const C_FLOAT64 & StdDeviation = StdDeviations[i];
file << StdDeviation << "\t";
file << fabs(100.0 * StdDeviation / Solution) << "\t";
file << Gradients[i] << std::endl;
}
// Set up the experiments table
file << std::endl << "Experiments:" << std::endl;
file << "Experiment\tObjective Value\tRoot Mean Square\tError Mean\tError Mean Std. Deviation" << std::endl;
// Loop over the experiments
const CExperimentSet & Experiments = mpProblem->getExperiementSet();
imax = Experiments.getExperimentCount();
if (mpProblem->getFunctionEvaluations() == 0)
imax = 0;
for (i = 0; i != imax; i++)
//.........这里部分代码省略.........
示例6: enterProtected
bool CQFittingResult::enterProtected()
{
assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
assert(pDataModel != NULL);
mpTask =
dynamic_cast<CFitTask *>((*pDataModel->getTaskList())["Parameter Estimation"]);
if (!mpTask) return false;
mpProblem = dynamic_cast<const CFitProblem *>(mpTask->getProblem());
if (!mpProblem) return false;
mpMain->load(mpProblem);
unsigned C_INT32 i, imax;
// Loop over the optimization items
const std::vector< COptItem * > & Items = mpProblem->getOptItemList();
const CVector< C_FLOAT64 > & Solutions = mpProblem->getSolutionVariables();
const CVector< C_FLOAT64 > & StdDeviations = mpProblem->getVariableStdDeviations();
const CVector< C_FLOAT64 > & Gradients = mpProblem->getVariableGradients();
imax = Items.size();
if (mpProblem->getFunctionEvaluations() == 0)
imax = 0;
mpParameters->setNumRows(imax);
for (i = 0; i != imax; i++)
{
const CCopasiObject *pObject =
pDataModel->getObject(Items[i]->getObjectCN());
if (pObject)
{
std::string Experiments =
static_cast<CFitItem *>(Items[i])->getExperiments();
if (Experiments != "")
Experiments = "; {" + Experiments + "}";
mpParameters->setText(i, 0, FROM_UTF8(pObject->getObjectDisplayName() + Experiments));
}
else
mpParameters->setText(i, 0, "Not Found");
const C_FLOAT64 & Solution = Solutions[i];
mpParameters->setText(i, 1, QString::number(Solution));
const C_FLOAT64 & StdDeviation = StdDeviations[i];
mpParameters->setText(i, 2, QString::number(StdDeviation));
mpParameters->setText(i, 3, QString::number(fabs(100.0 * StdDeviation / Solution)));
mpParameters->setText(i, 4, QString::number(Gradients[i]));
}
for (i = 0, imax = mpParameters->numCols(); i != imax; i++)
mpParameters->adjustColumn(i);
// Loop over the experiments
const CExperimentSet & Experiments = mpProblem->getExperiementSet();
imax = Experiments.getExperimentCount();
if (mpProblem->getFunctionEvaluations() == 0)
imax = 0;
mpExperiments->setNumRows(imax);
for (i = 0; i != imax; i++)
{
const CExperiment & Experiment = * Experiments.getExperiment(i);
mpExperiments->setText(i, 0, FROM_UTF8(Experiment.getObjectName()));
mpExperiments->setText(i, 1, QString::number(Experiment.getObjectiveValue()));
mpExperiments->setText(i, 2, QString::number(Experiment.getRMS()));
mpExperiments->setText(i, 3, QString::number(Experiment.getErrorMean()));
mpExperiments->setText(i, 4, QString::number(Experiment.getErrorMeanSD()));
}
for (i = 0, imax = mpExperiments->numCols(); i != imax; i++)
mpExperiments->adjustColumn(i);
// Loop over the dependent objects
imax = Experiments.getDependentObjects().size();
if (mpProblem->getFunctionEvaluations() == 0)
imax = 0;
mpValues->setNumRows(imax);
for (i = 0; i != imax; i++)
{
const CCopasiObject * pObject = Experiments.getDependentObjects()[i];
if (pObject)
mpValues->setText(i, 0, FROM_UTF8(pObject->getObjectDisplayName()));
else
mpValues->setText(i, 0, "Not Found");
//.........这里部分代码省略.........