void SliderDialog::editSlider() { SliderSettingsDialog* pSettingsDialog = new SliderSettingsDialog(this); // set the list of sliders that is already known CCopasiObject* object = (CCopasiObject*)getTaskForFolderId(mCurrentFolderId); if (!object) return; CCopasiDataModel * pDataModel = object->getObjectDataModel(); assert(pDataModel != NULL); pSettingsDialog->setModel(pDataModel->getModel()); std::vector<CSlider*>* pVector = getCSlidersForCurrentFolderId(); pSettingsDialog->setDefinedSliders(*pVector); //pSettingsDialog->disableObjectChoosing(true); pSettingsDialog->setSlider(mpCurrSlider->getCSlider()); if (pSettingsDialog->exec() == QDialog::Accepted) { addSlider(pSettingsDialog->getSlider()); mpCurrSlider->updateSliderData(); /* if ((!mpCurrSlider->isEnabled()) && mpCurrSlider->getCSlider()->compile()) { mpCurrSlider->setEnabled(true); } */ } delete pSettingsDialog; delete pVector; }
std::string SEDMLUtils::getXPathForObject(const CCopasiObject& object) { const std::string& type = object.getObjectName(); const CCopasiDataModel* dm = object.getObjectDataModel(); std::string yAxis = object.getObjectDisplayName(); std::string targetXPathString = getXPathAndName(yAxis, type, dm->getModel(), *dm); return targetXPathString; }
void SliderDialog::createNewSlider() { // allow the user to create more than one slider std::vector<const CCopasiObject*> objects = CCopasiSelectionDialog::getObjectVector(this, CQSimpleSelectionTree::InitialTime | CQSimpleSelectionTree::Parameters); std::vector<CSlider*>* pVector = getCSlidersForCurrentFolderId(); std::vector<const CCopasiObject*>::const_iterator it = objects.begin(), endit = objects.end(); bool yesToAll = false; bool noToAll = false; // create the sliders for all the selected objects // first we need the task object because we need it later to associate the // later with the correct task CCopasiObject* object = (CCopasiObject*)getTaskForFolderId(mCurrentFolderId); if (!object) return; CCopasiObject* pTmpObject = NULL; while (it != endit) { // create a new slider assert((*it) != NULL); pTmpObject = const_cast<CCopasiObject*>(determineCorrectObjectForSlider(*it)); CCopasiDataModel * pDataModel = pTmpObject->getObjectDataModel(); assert(pDataModel != NULL); CSlider* pCSlider = new CSlider("slider", pDataModel); if (pCSlider) { pCSlider->setSliderObject(pTmpObject); pCSlider->setAssociatedEntityKey(object->getKey()); // check if a slider for that object already exists and if so, prompt // the user what to do CSlider* pEquivalentSlider = equivalentSliderExists(pCSlider); if (pEquivalentSlider != NULL) { CopasiSlider* pCopasiSlider = NULL; // if the user has specified yesToAll, we reset the ranges of all // duplicate sliders if (yesToAll) { pEquivalentSlider->resetRange(); // update the slider widget pCopasiSlider = findCopasiSliderForCSlider(pEquivalentSlider); assert(pCopasiSlider != NULL); if (pCopasiSlider != NULL) { pCopasiSlider->updateSliderData(); } } // if the user has not specified noToAll, we need to prompt else if (!noToAll) { QMessageBox::StandardButton result = CQMessageBox::information(NULL, "Slider Exists", "A slider for this object already exists.\n\nDo you want to reset the range of the slider?", QMessageBox::Yes | QMessageBox::No | QMessageBox::YesToAll | QMessageBox::NoToAll, QMessageBox::No); // check the answer and maybe set some flags switch (result) { case QMessageBox::YesToAll: // set the flag yesToAll = true; case QMessageBox::Yes: // reset the range pEquivalentSlider->resetRange(); // update the slider widget pCopasiSlider = findCopasiSliderForCSlider(pEquivalentSlider); assert(pCopasiSlider != NULL); if (pCopasiSlider != NULL) { pCopasiSlider->updateSliderData(); } break; case QMessageBox::NoToAll: // set the flag noToAll = true; break; case QMessageBox::No: // do nothing else break; default: // do nothing break; } } delete pCSlider; } else { CObjectInterface::ContainerList listOfContainers; assert(CCopasiRootContainer::getDatamodelList()->size() > 0); listOfContainers.push_back(pDataModel->getModel()); pCSlider->compile(listOfContainers); pCSlider->resetRange(); addSlider(pCSlider); mChanged = true; } } ++it; } delete pVector; }