// virtual const CEvaluationNode::Data & CEvaluationNodeCall::getData() const { // We determine whether quoting is required here since we can not be sure // that the original infix is correct. std::string Data; if (isKeyword(mData)) { mQuotesRequired = true; } if (mpFunction != NULL) { Data = mpFunction->getObjectName(); mQuotesRequired |= mpFunction->getObjectName() != unQuote(quote(Data)); return mpFunction->getObjectName(); } if (mpExpression != NULL) { Data = mpExpression->getObjectName(); mQuotesRequired |= mpExpression->getObjectName() != unQuote(quote(Data)); return mpExpression->getObjectName(); } return mData; }
void setValue(const QString &value) { //parse to data type Pothos::DType dtype; try { dtype = Pothos::DType(unQuote(value).toStdString()); } catch(...){} const auto name = QString("\"%1\"").arg(QString::fromStdString(dtype.name())); //set combo box with type name int index = -1; for (int i = 0; i < _comboBox->count(); i++) { if (_comboBox->itemData(i).toString() == name) index = i; } if (index < 0) _comboBox->setEditText(name); else _comboBox->setCurrentIndex(index); //set spin box with vector size if (_spinBox != nullptr) { _spinBox->setValue(dtype.dimension()); } }
CEvaluationNodeCall::CEvaluationNodeCall(const SubType & subType, const Data & data): CEvaluationNode((Type)(CEvaluationNode::CALL | subType), data), mpFunction(NULL), mpExpression(NULL), mCallNodes(), mpCallParameters(NULL), mQuotesRequired(false), mBooleanRequired(false) { std::string::size_type len = mData.length(); if (len > 1 && mData[0] == '"' && mData[len - 1] == '"') { mQuotesRequired = true; } mData = unQuote(mData); switch (subType) { case FUNCTION: case EXPRESSION: break; default: fatalError(); break; } mPrecedence = PRECEDENCE_FUNCTION; }
// virtual bool CEvaluationNodeCall::setData(const Data & data) { mData = unQuote(data); // We force quoting if the round trip unquote, quote does not recover the original input if (isKeyword(mData)) { mQuotesRequired = true; } if (mData != data && quote(mData) != data) { mQuotesRequired = true; } mRegisteredFunctionCN = std::string(""); return true; }
CEvaluationNodeCall::CEvaluationNodeCall(const SubType & subType, const Data & data): CEvaluationNode(T_CALL, subType, data), mpFunction(NULL), mpExpression(NULL), mCallNodes(), mpCallParameters(NULL), mQuotesRequired(false), mBooleanRequired(false), mRegisteredFunctionCN() { setData(data); mData = unQuote(mData); // We force quoting if the round trip unquote, quote does not recover the original input if (isKeyword(mData)) { mQuotesRequired = true; } if (mData != data && quote(mData) != data) { mQuotesRequired = true; } switch (subType) { case S_FUNCTION: case S_EXPRESSION: break; default: fatalError(); break; } mPrecedence = PRECEDENCE_FUNCTION; }
static LONG_PTR WINAPI DlgProc(HANDLE hDlg,int Msg,int Param1,LONG_PTR Param2) { static TCHAR Filter[MAX_PATH]; static TCHAR spFilter[MAX_PATH]; static FarListTitles ListTitle; switch(Msg) { case DN_RESIZECONSOLE: { Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,FALSE,0); ResizeDialog(hDlg); Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,TRUE,0); } return TRUE; case DMU_UPDATE: { int OldPos = static_cast<int>(Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,LIST_BOX,0)); if (Param1) UpDateInfo(); ListSize = 0; int NewPos = -1; if (OldPos >= 0 && OldPos < nCount) { if (!*Filter || strstri(p[OldPos].Keys[DisplayName],Filter)) //без учета регистра в OEM кодировке NewPos = OldPos; } for (int i = 0; i < nCount; i++) { const TCHAR* DispName = p[i].Keys[DisplayName], *Find; if (*Filter) Find = strstri(DispName,Filter); else Find = DispName; if (Find != nullptr) //без учета регистра в OEM кодировке { FLI[i].Flags &= ~LIF_HIDDEN; if (Param2 && (i == OldPos)) { if (FLI[i].Flags & LIF_CHECKED) { FLI[i].Flags &= ~LIF_CHECKED; } else { FLI[i].Flags |= LIF_CHECKED; } } //без учета регистра - а кодировка ANSI if (NewPos == -1 && Find == DispName) NewPos = i; ListSize++; } else FLI[i].Flags |= LIF_HIDDEN; } if (Param1 == 0 && Param2) { // Снятие или установка пометки (Ins) if (Param2 == 1) { for (int i = (OldPos+1); i < nCount; i++) { if (!(FLI[i].Flags & LIF_HIDDEN)) { OldPos = i; break; } } NewPos = OldPos; } // Снятие или установка пометки (RClick) else if (Param2 == 2) { NewPos = OldPos; } } else if (NewPos == -1) { NewPos = OldPos; } Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,FALSE,0); Info.SendDlgMessage(hDlg,DM_LISTSET,LIST_BOX,reinterpret_cast<LONG_PTR>(&FL)); StringCchPrintf(spFilter,ARRAYSIZE(spFilter), GetMsg(MFilter),Filter,ListSize,nCount); ListTitle.Title = spFilter; ListTitle.TitleLen = lstrlen(spFilter); Info.SendDlgMessage(hDlg,DM_LISTSETTITLES,LIST_BOX,reinterpret_cast<LONG_PTR>(&ListTitle)); ResizeDialog(hDlg); struct FarListPos FLP; FLP.SelectPos = NewPos; FLP.TopPos = -1; Info.SendDlgMessage(hDlg,DM_LISTSETCURPOS,LIST_BOX,reinterpret_cast<LONG_PTR>(&FLP)); Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,TRUE,0); } break; case DN_INITDIALOG: { StringCchCopy(Filter,ARRAYSIZE(Filter),_T("")); ListTitle.Bottom = const_cast<TCHAR*>(GetMsg(MBottomLine)); ListTitle.BottomLen = lstrlen(GetMsg(MBottomLine)); //подстраиваемся под размеры консоли Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,FALSE,0); ResizeDialog(hDlg); Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,TRUE,0); //заполняем диалог Info.SendDlgMessage(hDlg,DMU_UPDATE,1,0); } break; case DN_MOUSECLICK: { if (Param1 == LIST_BOX) { MOUSE_EVENT_RECORD *mer = (MOUSE_EVENT_RECORD *)Param2; if (mer->dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED) { // find list on-screen coords (excluding frame and border) SMALL_RECT list_rect; Info.SendDlgMessage(hDlg, DM_GETDLGRECT, 0, reinterpret_cast<LONG_PTR>(&list_rect)); list_rect.Left += 2; list_rect.Top += 1; list_rect.Right -= 2; list_rect.Bottom -= 1; if ((mer->dwEventFlags == 0) && (mer->dwMousePosition.X > list_rect.Left) && (mer->dwMousePosition.X < list_rect.Right) && (mer->dwMousePosition.Y > list_rect.Top) && (mer->dwMousePosition.Y < list_rect.Bottom)) { DlgProc(hDlg, DN_KEY, LIST_BOX, KEY_ENTER); return TRUE; } // pass message to scrollbar if needed if ((mer->dwMousePosition.X == list_rect.Right) && (mer->dwMousePosition.Y > list_rect.Top) && (mer->dwMousePosition.Y < list_rect.Bottom)) return FALSE; return TRUE; } else if (mer->dwButtonState == RIGHTMOST_BUTTON_PRESSED) { Info.SendDlgMessage(hDlg,DMU_UPDATE,0,2); return TRUE; } } } break; case DN_KEY: switch (Param2) { case KEY_F8: { if (ListSize) { TCHAR DlgText[MAX_PATH + 200]; StringCchPrintf(DlgText, ARRAYSIZE(DlgText), GetMsg(MConfirm), p[Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,LIST_BOX,NULL)].Keys[DisplayName]); if (EMessage((const TCHAR * const *) DlgText, 0, 2) == 0) { if (!DeleteEntry(static_cast<int>(Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,LIST_BOX,NULL)))) DrawMessage(FMSG_WARNING, 1, "%s",GetMsg(MPlugIn),GetMsg(MDelRegErr),GetMsg(MBtnOk),NULL); Info.SendDlgMessage(hDlg,DMU_UPDATE,1,0); } } } return TRUE; case (KEY_F9|KEY_SHIFT|KEY_ALT): case (KEY_F9): { Configure(0); } return TRUE; case KEY_CTRLR: { Info.SendDlgMessage(hDlg,DMU_UPDATE,1,0); } return TRUE; case KEY_INS: { Info.SendDlgMessage(hDlg,DMU_UPDATE,0,1); } return TRUE; case KEY_ENTER: case KEY_SHIFTENTER: { if (ListSize) { int liChanged = 0; int liSelected = 0, liFirst = -1; for (int i = 0; i < nCount; i++) { if (FLI[i].Flags & LIF_CHECKED) { if (liFirst == -1) liFirst = i; liSelected++; } } if (liSelected <= 1) { int liAction = (Param2 == KEY_ENTER) ? Opt.EnterAction : Opt.ShiftEnterAction; int pos = (liFirst == -1) ? static_cast<int>(Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,LIST_BOX,NULL)) : liFirst; liChanged = ExecuteEntry(pos, liAction, (Opt.RunLowPriority!=0)); } else { int liAction = (Param2 == KEY_ENTER) ? Opt.EnterAction : Opt.ShiftEnterAction; bool LowPriority = (Opt.RunLowPriority!=0); // Обязательно ожидание - два инсталлятора сразу недопускаются if (liAction == Action_Menu) { if (EntryMenu(0, liAction, LowPriority, liSelected) < 0) return TRUE; } else if (liAction == Action_Uninstall) liAction = Action_UninstallWait; else if (liAction == Action_Modify) liAction = Action_ModifyWait; else if (liAction == Action_Repair) liAction = Action_RepairWait; for (int pos = 0; pos < nCount; pos++) { if (!(FLI[pos].Flags & LIF_CHECKED)) continue; struct FarListPos FLP; FLP.SelectPos = pos; FLP.TopPos = -1; Info.SendDlgMessage(hDlg,DM_LISTSETCURPOS,LIST_BOX,reinterpret_cast<LONG_PTR>(&FLP)); int li = ExecuteEntry(pos, liAction, LowPriority); if (li == -1) break; // отмена if (li == 1) liChanged = 1; } } if (liChanged == 1) { Info.SendDlgMessage(hDlg,DMU_UPDATE,1,0); } } } return TRUE; case KEY_SHIFTINS: case KEY_CTRLV: { TCHAR * bufP = FSF.PasteFromClipboard(); static TCHAR bufData[MAX_PATH]; if (bufP) { StringCchCopy(bufData,ARRAYSIZE(bufData),bufP); FSF.DeleteBuffer(bufP); unQuote(bufData); FSF.LStrlwr(bufData); for (int i = lstrlen(bufData); i >= 1; i--) for (int j = 0; j < nCount; j++) if (strnstri(p[j].Keys[DisplayName],bufData,i)) { lstrcpyn(Filter,bufData,i+1); Info.SendDlgMessage(hDlg,DMU_UPDATE,0,0); return TRUE; } } } return TRUE; case KEY_DEL: { if (lstrlen(Filter) > 0) { StringCchCopy(Filter,ARRAYSIZE(Filter),_T("")); Info.SendDlgMessage(hDlg,DMU_UPDATE,0,0); } } return TRUE; case KEY_F3: case KEY_F4: { if (ListSize) { DisplayEntry(static_cast<int>(Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,LIST_BOX,NULL))); Info.SendDlgMessage(hDlg,DM_REDRAW,NULL,NULL); } } return TRUE; case KEY_F2: { Opt.SortByDate = !Opt.SortByDate; Info.SendDlgMessage(hDlg,DMU_UPDATE,1,0); } return TRUE; case KEY_BS: { if (lstrlen(Filter)) { Filter[lstrlen(Filter)-1] = '\0'; Info.SendDlgMessage(hDlg,DMU_UPDATE,0,0); } } return TRUE; default: { if (Param2 >= KEY_SPACE && Param2 < KEY_FKEY_BEGIN) { struct FarListInfo ListInfo; Info.SendDlgMessage(hDlg,DM_LISTINFO,LIST_BOX,reinterpret_cast<LONG_PTR>(&ListInfo)); if ((lstrlen(Filter) < sizeof(Filter)) && ListInfo.ItemsNumber) { int filterL = lstrlen(Filter); Filter[filterL] = FSF.LLower(static_cast<unsigned>(Param2)); Filter[filterL+1] = '\0'; Info.SendDlgMessage(hDlg,DMU_UPDATE,0,0); return TRUE; } } } } return FALSE; case DN_CTLCOLORDIALOG: return Info.AdvControl(Info.ModuleNumber,ACTL_GETCOLOR,(void *)COL_MENUTEXT); case DN_CTLCOLORDLGLIST: if (Param1 == LIST_BOX) { FarListColors *Colors = (FarListColors *)Param2; int ColorIndex[] = { COL_MENUBOX, COL_MENUBOX, COL_MENUTITLE, COL_MENUTEXT, COL_MENUHIGHLIGHT, COL_MENUBOX, COL_MENUSELECTEDTEXT, COL_MENUSELECTEDHIGHLIGHT, COL_MENUSCROLLBAR, COL_MENUDISABLEDTEXT, COL_MENUARROWS, COL_MENUARROWSSELECTED, COL_MENUARROWSDISABLED }; int Count = ARRAYSIZE(ColorIndex); if (Count > Colors->ColorCount) Count = Colors->ColorCount; for (int i = 0; i < Count; i++) Colors->Colors[i] = static_cast<BYTE>(Info.AdvControl(Info.ModuleNumber, ACTL_GETCOLOR, reinterpret_cast<void *>(ColorIndex[i]))); return TRUE; } break; } return Info.DefDlgProc(hDlg,Msg,Param1,Param2); }
int main(int argc, char *argv[]) { // Parse the commandline options // first argument is the SBML filename // second argument is the endtime // third argument is the step number // fourth argument is the filename where the results are to be written // fifth argument is the tmp directory (this is not needed) // the rest of the arguments are species names for the result try { // Create the root container. CCopasiRootContainer::init(0, NULL, false); } catch (copasi::autoexcept &e) {} catch (copasi::option_error &e) {} if (argc < 5) { std::cout << "Usage: stochastic-testsuite METHOD SBMLFILENAME ENDTIME STEPNUMBER REPEATS OUTFILENAME SPECIESID1 SPECIESID2 ..." << std::endl; exit(1); } const char* pMethodType = argv[1]; const char* pSBMLFilename = argv[2]; const char* pEndTime = argv[3]; const char* pStepNumber = argv[4]; const char* pRepeats = argv[5]; const char* pOutputFilename = argv[6]; unsigned int NUMARGS = 7; /* std::cout << "Input : " << pSBMLFilename << std::endl; std::cout << "Endtime : " << pEndTime << std::endl; std::cout << "Stepnumber: " << pStepNumber << std::endl; std::cout << "Repeats : " << pRepeats << std::endl; std::cout << "Output file: " << pOutputFilename << std::endl; */ char** pSBMLSpeciesIds = new char * [argc - NUMARGS]; unsigned int i, iMax = argc; CTrajectoryTask* pTrajectoryTask = NULL; CScanTask* pScanTask = NULL; std::string CWD = COptions::getPWD(); double endTime = strToDouble(pEndTime, &pEndTime); double stepNumber = strToDouble(pStepNumber, &pStepNumber); char** pTmpP = (char**)(&pRepeats); long int repeats = strtol(pRepeats, pTmpP , 10); CCopasiMethod::SubType MethodType; if (!strcmp(pMethodType, "stochastic")) { MethodType = CCopasiMethod::stochastic; } else if (!strcmp(pMethodType, "directMethod")) { MethodType = CCopasiMethod::directMethod; } else if (!strcmp(pMethodType, "tauLeap")) { MethodType = CCopasiMethod::tauLeap; } else if (!strcmp(pMethodType, "adaptiveSA")) { MethodType = CCopasiMethod::adaptiveSA; } else if (!strcmp(pMethodType, "LSODA")) { MethodType = CCopasiMethod::deterministic; } else { std::cerr << "Invalid method type. Valid options are:" << std::endl; std::cerr << " stochastic" << std::endl; std::cerr << " directMethod" << std::endl; std::cerr << " tauLeap" << std::endl; } if (endTime == 0.0) { std::cerr << "Invalid endtime " << pEndTime << std::endl; exit(1); } if (stepNumber == 0.0) { std::cerr << "Invalid step number " << pStepNumber << std::endl; exit(1); } for (i = NUMARGS; i < iMax; ++i) { pSBMLSpeciesIds[i - NUMARGS] = argv[i]; //std::cout << "Copying pointer to " << argv[i] << "." << std::endl; } try { // Create the global data model. CCopasiDataModel* pDataModel = CCopasiRootContainer::addDatamodel(); // Import the SBML File pDataModel->importSBML(pSBMLFilename); //pDataModel->getModel()->forceCompile(); // create a report with the correct filename and all the species against // time. CReportDefinitionVector* pReports = pDataModel->getReportDefinitionList(); CReportDefinition* pReport = pReports->createReportDefinition("Report", "Output for stochastic testsuite run"); pReport->setTaskType(CCopasiTask::timeCourse); pReport->setIsTable(false); CCopasiReportSeparator Separator(std::string(",")); pReport->setSeparator(Separator); std::vector<CRegisteredObjectName> * pHeader = pReport->getHeaderAddr(); std::vector<CRegisteredObjectName> * pBody = pReport->getBodyAddr(); // Add time column pHeader->push_back(CCopasiStaticString("time").getCN()); pBody->push_back(CCopasiObjectName(pDataModel->getModel()->getCN() + ",Reference=Time")); iMax = iMax - NUMARGS; const CCopasiVector<CMetab>& metabolites = pDataModel->getModel()->getMetabolites(); for (i = 0; i < iMax; ++i) { pHeader->push_back(Separator.getCN()); pBody->push_back(Separator.getCN()); unsigned int j, jMax = metabolites.size(); std::string SBMLId = unQuote(pSBMLSpeciesIds[i]); for (j = 0; j < jMax; ++j) { if (metabolites[j]->getSBMLId() == SBMLId) { break; } } if (j == jMax) { std::cerr << "Could not find a metabolite for the SBML id \"" << pSBMLSpeciesIds[i] << "\"" << std::endl; exit(1); } pHeader->push_back(CCopasiStaticString(SBMLId).getCN()); pBody->push_back(metabolites[j]->getObject(CCopasiObjectName("Reference=ParticleNumber"))->getCN()); } // create a trajectory task pTrajectoryTask = new CTrajectoryTask(); pTrajectoryTask->setMethodType(MethodType); pTrajectoryTask->getProblem()->setModel(pDataModel->getModel()); pTrajectoryTask->setScheduled(false); //pTrajectoryTask->getReport().setReportDefinition(pReport); //pTrajectoryTask->getReport().setTarget(CWD + "/" + pOutputFilename); //pTrajectoryTask->getReport().setAppend(false); CTrajectoryProblem* pProblem = dynamic_cast<CTrajectoryProblem*>(pTrajectoryTask->getProblem()); pProblem->setStepNumber((const unsigned C_INT32)stepNumber); pProblem->setDuration((const C_FLOAT64)endTime); pProblem->setTimeSeriesRequested(true); pProblem->setTimeSeriesRequested(false); //pProblem->setInitialState(pDataModel->getModel()->getInitialState()); CCopasiVectorN< CCopasiTask > & TaskList = * pDataModel->getTaskList(); TaskList.remove("Time-Course"); TaskList.add(pTrajectoryTask, true); // create a scan task pScanTask = new CScanTask(pDataModel); CScanProblem* pScanProblem = dynamic_cast<CScanProblem*>(pScanTask->getProblem()); pScanProblem->setModel(pDataModel->getModel()); pScanTask->setScheduled(true); pScanTask->getReport().setReportDefinition(pReport); pScanTask->getReport().setTarget(CWD + "/" + pOutputFilename); pScanTask->getReport().setAppend(false); pScanProblem->setSubtask(CCopasiTask::timeCourse); pScanProblem->createScanItem(CScanProblem::SCAN_REPEAT, repeats); pScanProblem->setOutputInSubtask(true); pScanProblem->setContinueFromCurrentState(false); TaskList.remove("Scan"); TaskList.add(pScanTask, true); // save the file for control purposes std::string saveFilename = pSBMLFilename; saveFilename = saveFilename.substr(0, saveFilename.length() - 4) + ".cps"; pDataModel->saveModel(saveFilename, NULL, true); // Run the trajectory task pScanTask->initialize(CCopasiTask::OUTPUT_SE, pDataModel, NULL); pScanTask->process(true); pScanTask->restore(); // create another report that will write to the directory where the input file came from // this can be used for debugging // create a trajectory task // pScanTask->getReport().setTarget(pOutputFilename); // pScanTask->initialize(CCopasiTask::OUTPUT_SE, pDataModel, NULL); // pScanTask->process(true); // pScanTask->restore(); } catch (CCopasiException Exception) { std::cerr << Exception.getMessage().getText() << std::endl; } CCopasiRootContainer::destroy(); return 0; }
void ParameterTable::updateTable(const CReactionInterface & ri, const CModel & model) { //first get the units strings CFindDimensions units(ri.getFunction(), model.getQuantityUnitEnum() == CModel::dimensionlessQuantity, model.getVolumeUnitEnum() == CModel::dimensionlessVolume, model.getTimeUnitEnum() == CModel::dimensionlessTime, model.getAreaUnitEnum() == CModel::dimensionlessArea, model.getLengthUnitEnum() == CModel::dimensionlessLength ); units.setUseHeuristics(true); units.setMolecularitiesForMassAction(ri.getChemEqInterface().getMolecularity(CFunctionParameter::SUBSTRATE), ri.getChemEqInterface().getMolecularity(CFunctionParameter::PRODUCT)); units.findDimensions(ri.isMulticompartment()); size_t i, imax = ri.size(); size_t j, jmax; size_t rowCounter = 0; QStringList qsl; QColor subsColor(255, 210, 210); QColor prodColor(210, 255, 210); QColor modiColor(250, 250, 190); QColor paraColor(210, 210, 255); QColor volColor(210, 210, 255); QColor timeColor(210, 210, 210); CFunctionParameter::Role usage; QString qUsage; QColor color; const std::vector<std::string> * metabNames; mIndex2Line.resize(imax); mLine2Index.clear(); this->setRowCount(0); this->setRowCount((int)(imax * 2)); for (i = 0; i < imax; ++i) { rowCounter++; mIndex2Line[i] = rowCounter; // set the stuff that is different for the specific usages usage = ri.getUsage(i); qUsage = FROM_UTF8(CFunctionParameter::RoleNameDisplay[usage]); switch (usage) { case CFunctionParameter::SUBSTRATE: color = subsColor; break; case CFunctionParameter::PRODUCT: color = prodColor; break; case CFunctionParameter::MODIFIER: color = modiColor; break; case CFunctionParameter::PARAMETER: color = paraColor; break; case CFunctionParameter::VOLUME: color = volColor; break; case CFunctionParameter::TIME: color = timeColor; break; case CFunctionParameter::VARIABLE: color = QColor(255, 20, 20); break; default: qUsage = "unknown"; color = QColor(255, 20, 20); break; } // add first column QTableWidgetItem * pItem = new ColorTableItem(color, qUsage); if (usage == CFunctionParameter::SUBSTRATE) pItem->setIcon(CQIconResource::icon(CQIconResource::reactionSubstrate)); if (usage == CFunctionParameter::PRODUCT) pItem->setIcon(CQIconResource::icon(CQIconResource::reactionProduct)); if (usage == CFunctionParameter::MODIFIER) pItem->setIcon(CQIconResource::icon(CQIconResource::reactionModifier)); setItem((int) rowCounter, 0, pItem); // add second column pItem = new ColorTableItem(color, FROM_UTF8(ri.getParameterName(i))); if ((usage != CFunctionParameter::PARAMETER) && (usage != CFunctionParameter::VOLUME) && (usage != CFunctionParameter::TIME)) { if (ri.isLocked(i)) pItem->setIcon(CQIconResource::icon(CQIconResource::locked)); else pItem->setIcon(CQIconResource::icon(CQIconResource::unlocked)); } setItem((int) rowCounter, 1, pItem); // add third column pItem = new ColorTableItem(color, ""); if (usage == CFunctionParameter::PARAMETER) { pItem->setFlags(pItem->flags() | Qt::ItemIsUserCheckable); pItem->setCheckState(ri.isLocalValue(i) ? Qt::Unchecked : Qt::Checked); } setItem((int) rowCounter, 2, pItem); // add units column assert(CCopasiRootContainer::getDatamodelList()->size() > 0); CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0]; assert(pDataModel != NULL); pItem = new ColorTableItem(color, FROM_UTF8(" " + units.getDimensions()[i].getDisplayString(pDataModel))); setItem((int) rowCounter, 4, pItem); // add a line for a metabolite Parameter if ((usage == CFunctionParameter::SUBSTRATE) || (usage == CFunctionParameter::PRODUCT) || (usage == CFunctionParameter::MODIFIER)) { // get the list of possible metabs (for the combo box) if (usage == CFunctionParameter::MODIFIER) //get all metabs; modifiers are never locked vectorOfStrings2QStringList(getListOfAllMetabNames(model, ri), qsl); else //only get the modifiers from the ChemEq { if (!ri.isLocked(i)) vectorOfStrings2QStringList(ri.getListOfMetabs(usage), qsl); } metabNames = &(ri.getMappings(i)); if (!ri.isVector(i)) { if (ri.isLocked(i)) { pItem = new ColorTableItem(color, FROM_UTF8((*metabNames)[0])); setItem((int) rowCounter, 3, pItem); } else { QComboBox * pComboBox = new QComboBox(); pComboBox->addItems(qsl); pComboBox->setBackgroundColor(color); pComboBox->setCurrentText(FROM_UTF8(unQuote((*metabNames)[0]))); setCellWidget((int) rowCounter, 3, pComboBox); } } else { if (ri.isLocked(i)) { pItem = new ColorTableItem(color, ""); setItem((int) rowCounter, 3, pItem); } else // this should not happen { QComboBox * pComboBox = new QComboBox(); pComboBox->addItems(qsl); pComboBox->setBackgroundColor(color); pComboBox->setCurrentText("add species"); setCellWidget((int) rowCounter, 3, pComboBox); } // add lines for vector parameters jmax = metabNames->size(); setRowCount(rowCount() + (int) jmax); for (j = 0; j < jmax; ++j) { ++rowCounter; pItem = new ColorTableItem(color, FROM_UTF8((*metabNames)[j])); setItem((int) rowCounter, 3, pItem); } } } // add a line for a kinetic parameter else if (usage == CFunctionParameter::PARAMETER) { if (ri.isLocalValue(i)) { pItem = new ColorTableItem(color, QString::number(ri.getLocalValue(i))); setItem((int) rowCounter, 3, pItem); } else //global parameter { QComboBox * pComboBox = new QComboBox(); pComboBox->addItems(getListOfAllGlobalParameterNames(model)); pComboBox->setBackgroundColor(color); pComboBox->setCurrentText(FROM_UTF8(ri.getMapping(i))); setCellWidget((int) rowCounter, 3, pComboBox); } } // add a line for a kinetic parameter else if (usage == CFunctionParameter::VOLUME) { QComboBox * pComboBox = new QComboBox(); pComboBox->addItems(getListOfAllCompartmentNames(model)); pComboBox->setBackgroundColor(color); pComboBox->setCurrentText(FROM_UTF8(ri.getMapping(i))); setCellWidget((int) rowCounter, 3, pComboBox); } // add a line for time else if (usage == CFunctionParameter::TIME) { pItem = new ColorTableItem(color, ""); setItem((int) rowCounter, 3, pItem); } // add a line for an unknown role else { pItem = new ColorTableItem(color, QString::number(ri.getLocalValue(i))); setItem((int) rowCounter, 3, pItem); } resizeRowToContents((int) rowCounter); //mLine2Index ++rowCounter; } this->resizeColumnsToContents(); }