Skip to content

Commit

Permalink
Bug 3221: Fixed UI problems in experiment data and event widgets.
Browse files Browse the repository at this point in the history
  • Loading branch information
shoops committed Apr 2, 2024
1 parent 0e8a244 commit 8fd1a60
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 60 deletions.
2 changes: 1 addition & 1 deletion copasi/UI/CQEventWidget1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ void CQEventWidget1::slotSelectObject()
if (pObject == NULL)
return;

if (mAssignments[mCurrentTarget].setTargetCN(pObject->getStringCN()))
if (mAssignments[mCurrentTarget].setTargetCN(pObject->getCN()))
{
// If the target key change was successful we need to update the label.
mpLBTarget->item((int) mCurrentTarget)->setText(FROM_UTF8(pObject->getObjectDisplayName()));
Expand Down
2 changes: 1 addition & 1 deletion copasi/UI/CQExperimentData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,7 @@ bool CQExperimentData::saveTable(CExperiment * pExperiment)

if (ObjectMap.getObjectCN(i) != TO_UTF8(mpTable->item((int) i, COL_OBJECT_HIDDEN)->text()))
{
ObjectMap.setObjectCN(i, TO_UTF8(mpTable->item((int) i, COL_OBJECT_HIDDEN)->text()));
ObjectMap.setObjectCN(i, CRegisteredCommonName(TO_UTF8(mpTable->item((int) i, COL_OBJECT_HIDDEN)->text()), mpDataModel));
Changed = true;
}

Expand Down
2 changes: 1 addition & 1 deletion copasi/UI/CQParameterGroupView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void CQParameterGroupView::modifySelectCNs(CCopasiParameterGroup & group, const

for (; itNew != endNew; ++itNew)
{
group.addParameter("Reaction", CCopasiParameter::Type::CN, (*itNew)->getStringCN());
group.addParameter("Reaction", CCopasiParameter::Type::CN, (*itNew)->getCN());
}

mpParameterGroupDM->endResetModel();
Expand Down
2 changes: 2 additions & 0 deletions copasi/core/CRegisteredCommonName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ CRegisteredCommonName::CRegisteredCommonName()
mSet.insert(this);
}

#ifndef DEPRECATE_CONSTRUCTOR
CRegisteredCommonName::CRegisteredCommonName(const std::string & name)
: CCommonName(name)
, mpDataModel(nullptr)
Expand All @@ -65,6 +66,7 @@ CRegisteredCommonName::CRegisteredCommonName(const std::string & name)

mSet.insert(this);
}
#endif // DEPRECATE_CONSTRUCTOR

CRegisteredCommonName::CRegisteredCommonName(const std::string & name, const CObjectInterface * pObject)
: CCommonName(name)
Expand Down
5 changes: 5 additions & 0 deletions copasi/core/CRegisteredCommonName.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

#include "copasi/core/CCommonName.h"

// Uncomment to disable the deprecated construct from std::string
// #define DEPRECATE_CONSTRUCTOR 1

class CDataModel;
class CObjectInterface;

Expand Down Expand Up @@ -77,11 +80,13 @@ class CRegisteredCommonName: public CCommonName
*/
CRegisteredCommonName();

#ifndef DEPRECATE_CONSTRUCTOR
/**
* Constructor from base class
* @param const std::string & name
*/
CRegisteredCommonName(const std::string & name);
#endif // DEPRECATE_CONSTRUCTOR

/**
* Constructor from base class
Expand Down
4 changes: 2 additions & 2 deletions copasi/model/CEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ bool CEventAssignment::applyData(const CData & data, CUndoData::CChangeSet & cha

if (data.isSetProperty(CData::OBJECT_REFERENCE_CN))
{
setTargetCN(data.getProperty(CData::OBJECT_REFERENCE_CN).toString());
setTargetCN(CRegisteredCommonName(data.getProperty(CData::OBJECT_REFERENCE_CN).toString(), this));
compileModel = true;
}

Expand Down Expand Up @@ -211,7 +211,7 @@ CIssue CEventAssignment::compile(CObjectInterface::ContainerList listOfContainer
if (pEntity != nullptr)
{
mpTarget = pEntity->getValueObject();
setTargetCN(mpTarget->getStringCN());
setTargetCN(mpTarget->getCN());
}
else
pEntity = dynamic_cast< const CModelEntity * >(mpTarget->getObjectParent());
Expand Down
2 changes: 1 addition & 1 deletion copasi/model/CModelExpansion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,7 @@ void CModelExpansion::replaceInEvent(CEvent* pX, const ElementsMap & emap)
const CDataObject * pObject = emap.getDuplicateFromObject(pAssignment->getTargetObject());

if (pObject != NULL)
pAssignment->setTargetCN(pObject->getStringCN());
pAssignment->setTargetCN(pObject->getCN());
}
}

Expand Down
18 changes: 9 additions & 9 deletions copasi/parameterFitting/CExperimentObjectMap.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2019 - 2023 by Pedro Mendes, Rector and Visitors of the
// Copyright (C) 2019 - 2024 by Pedro Mendes, Rector and Visitors of the
// University of Virginia, University of Heidelberg, and University
// of Connecticut School of Medicine.
// All rights reserved.
Expand Down Expand Up @@ -200,26 +200,26 @@ CExperiment::Type CExperimentObjectMap::getRole(const size_t & index) const
}

bool CExperimentObjectMap::setObjectCN(const size_t & index,
const std::string & CN)
const CRegisteredCommonName & CN)
{
CDataColumn * pColumn =
dynamic_cast< CDataColumn * >(getGroup(StringPrint("%d", index)));

if (pColumn)
return pColumn->setObjectCN((CCommonName) CN);
return pColumn->setObjectCN(CN);
else
return false;
}

std::string CExperimentObjectMap::getObjectCN(const size_t & index) const
CRegisteredCommonName CExperimentObjectMap::getObjectCN(const size_t & index) const
{
const CDataColumn * pColumn =
dynamic_cast< const CDataColumn * >(getGroup(StringPrint("%d", index)));

if (pColumn)
return pColumn->getObjectCN();
else
return "";
return CRegisteredCommonName();
}

bool CExperimentObjectMap::setScale(const size_t & index,
Expand Down Expand Up @@ -393,7 +393,7 @@ bool CExperimentObjectMap::CDataColumn::setRole(const CExperiment::Type & role)
const CExperiment::Type & CExperimentObjectMap::CDataColumn::getRole() const
{return *mpRole;}

bool CExperimentObjectMap::CDataColumn::setObjectCN(const std::string & objectCN)
bool CExperimentObjectMap::CDataColumn::setObjectCN(const CRegisteredCommonName & objectCN)
{
if (objectCN == "")
{
Expand All @@ -409,18 +409,18 @@ bool CExperimentObjectMap::CDataColumn::setObjectCN(const std::string & objectCN
*mpObjectCN = objectCN;
else
mpObjectCN =
assertParameter("Object CN", CCopasiParameter::Type::CN, (CCommonName) objectCN);
assertParameter("Object CN", CCopasiParameter::Type::CN, objectCN);
}

return true;
}

std::string CExperimentObjectMap::CDataColumn::getObjectCN() const
CRegisteredCommonName CExperimentObjectMap::CDataColumn::getObjectCN() const
{
if (mpObjectCN != NULL)
return *mpObjectCN;
else
return "";
return CRegisteredCommonName();
}

bool CExperimentObjectMap::CDataColumn::setScale(const C_FLOAT64 & weight)
Expand Down
14 changes: 7 additions & 7 deletions copasi/parameterFitting/CExperimentObjectMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ class CExperimentObjectMap: public CCopasiParameterGroup

/**
* Set the object CN of the object mapped to the column
* @param const std::string & objectCN
* @param const CRegisteredCommonName & objectCN
* @return bool success
*/
bool setObjectCN(const std::string & objectCN);
bool setObjectCN(const CRegisteredCommonName & objectCN);

/**
* Retrieve the object CN of the object mapped to the column
* @return std::string objctCN
*/
std::string getObjectCN() const;
CRegisteredCommonName getObjectCN() const;

/**
* Set the scaling factor for the column
Expand Down Expand Up @@ -145,7 +145,7 @@ class CExperimentObjectMap: public CCopasiParameterGroup
private:
CExperiment::Type *mpRole;

CCommonName *mpObjectCN;
CRegisteredCommonName *mpObjectCN;

C_FLOAT64 *mpScale;
};
Expand Down Expand Up @@ -249,18 +249,18 @@ class CExperimentObjectMap: public CCopasiParameterGroup
/**
* Set the object CN of the object mapped to the indexed column
* @param const size_t & index
* @param const std::string & objectCN
* @param const CRegisteredCommonName & objectCN
* @return bool success
*/
bool setObjectCN(const size_t & index,
const std::string & objectCN);
const CRegisteredCommonName & objectCN);

/**
* Retrieve the object CN of the object mapped to the indexed column
* @param const size_t & index
* @return std::stringobjctCN
*/
std::string getObjectCN(const size_t & index) const;
CRegisteredCommonName getObjectCN(const size_t & index) const;

/**
* Set the scaling factor for the indexed column
Expand Down
2 changes: 1 addition & 1 deletion copasi/scan/CScanMethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ CScanItem::CScanItem(CCopasiParameterGroup* si):
void CScanItem::ensureParameterGroupHasAllElements(CCopasiParameterGroup* pg)
{
pg->assertParameter("Number of steps", CCopasiParameter::Type::UINT, 0);
pg->assertParameter("Object", CCopasiParameter::Type::CN, std::string());
pg->assertParameter("Object", CCopasiParameter::Type::CN, CRegisteredCommonName());
}

size_t CScanItem::getNumSteps() const {return mNumSteps;}
Expand Down
4 changes: 2 additions & 2 deletions copasi/scan/CScanProblem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ CCopasiParameterGroup* CScanProblem::createScanItem(CScanProblem::Type type, siz
tmp->addParameter("Type", CCopasiParameter::Type::UINT, (unsigned C_INT32) type);

if (obj)
tmp->addParameter("Object", CCopasiParameter::Type::CN, obj->getStringCN());
tmp->addParameter("Object", CCopasiParameter::Type::CN, obj->getCN());
else
tmp->addParameter("Object", CCopasiParameter::Type::CN, CCommonName(""));
tmp->addParameter("Object", CCopasiParameter::Type::CN, CRegisteredCommonName());

//create specific parameters
if ((type == SCAN_LINEAR) || (type == SCAN_RANDOM))
Expand Down
39 changes: 17 additions & 22 deletions copasi/timesens/CTimeSensProblem.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2019 by Pedro Mendes, Rector and Visitors of the
// Copyright (C) 2019 - 2024 by Pedro Mendes, Rector and Visitors of the
// University of Virginia, University of Heidelberg, and University
// of Connecticut School of Medicine.
// All rights reserved.
Expand Down Expand Up @@ -99,22 +99,22 @@ bool CTimeSensProblem::elevateChildren()

//**********************************

CCommonName CTimeSensProblem::getParameterCN(size_t index)
CRegisteredCommonName CTimeSensProblem::getParameterCN(size_t index)
{
if (mpParametersGroup == NULL)
return CCommonName();
return CRegisteredCommonName();

size_t numParameters = getNumParameters();

if (index >= numParameters)
return CCommonName();
return CRegisteredCommonName();

CCopasiParameter* current = mpParametersGroup->getParameter(index);

if (current == NULL)
return CCommonName();
return CRegisteredCommonName();

return current->getValue<std::string>();
return current->getValue< CRegisteredCommonName >();
}

void CTimeSensProblem::removeParameterCN(size_t index)
Expand All @@ -129,7 +129,7 @@ void CTimeSensProblem::removeParameterCN(size_t index)
mpParametersGroup->removeParameter(index);
}

void CTimeSensProblem::removeParameterCN(const CCommonName & cn)
void CTimeSensProblem::removeParameterCN(const std::string & cn)
{
if (mpParametersGroup == NULL)
return;
Expand All @@ -138,10 +138,9 @@ void CTimeSensProblem::removeParameterCN(const CCommonName & cn)

for (int i = numParameters - 1; i >= 0 ; --i)
{
CCommonName currentCn = getParameterCN(i);
CCopasiParameter* current = mpParametersGroup->getParameter(i);

if (current && current->getValue<std::string>() == cn)
if (current && current->getValue< CRegisteredCommonName >() == cn)
mpParametersGroup->removeParameter(i);
}
}
Expand All @@ -154,15 +153,14 @@ size_t CTimeSensProblem::getNumParameters()
return mpParametersGroup->size();
}

void CTimeSensProblem::addParameterCN(const CCommonName & cn)
void CTimeSensProblem::addParameterCN(const CRegisteredCommonName & cn)
{
if (mpParametersGroup == NULL)
return;

mpParametersGroup->addParameter("ParameterCN", CCopasiParameter::Type::CN, cn);
}


void CTimeSensProblem::clearParameterCNs()
{
if (mpParametersGroup == NULL)
Expand All @@ -173,22 +171,22 @@ void CTimeSensProblem::clearParameterCNs()

//***********************************

CCommonName CTimeSensProblem::getTargetCN(size_t index)
CRegisteredCommonName CTimeSensProblem::getTargetCN(size_t index)
{
if (mpTargetsGroup == NULL)
return CCommonName();
return CRegisteredCommonName();

size_t numTargets = getNumTargets();

if (index >= numTargets)
return CCommonName();
return CRegisteredCommonName();

CCopasiParameter* current = mpTargetsGroup->getParameter(index);

if (current == NULL)
return CCommonName();
return CRegisteredCommonName();

return current->getValue<std::string>();
return current->getValue< CRegisteredCommonName> ();
}

void CTimeSensProblem::removeTargetCN(size_t index)
Expand All @@ -203,7 +201,7 @@ void CTimeSensProblem::removeTargetCN(size_t index)
mpTargetsGroup->removeParameter(index);
}

void CTimeSensProblem::removeTargetCN(const CCommonName & cn)
void CTimeSensProblem::removeTargetCN(const std::string & cn)
{
if (mpTargetsGroup == NULL)
return;
Expand All @@ -212,10 +210,9 @@ void CTimeSensProblem::removeTargetCN(const CCommonName & cn)

for (int i = numTargets - 1; i >= 0 ; --i)
{
CCommonName currentCn = getTargetCN(i);
CCopasiParameter* current = mpTargetsGroup->getParameter(i);

if (current && current->getValue<std::string>() == cn)
if (current && current->getValue< CRegisteredCommonName >() == cn)
mpTargetsGroup->removeParameter(i);
}
}
Expand All @@ -228,15 +225,14 @@ size_t CTimeSensProblem::getNumTargets()
return mpTargetsGroup->size();
}

void CTimeSensProblem::addTargetCN(const CCommonName & cn)
void CTimeSensProblem::addTargetCN(const CRegisteredCommonName & cn)
{
if (mpTargetsGroup == NULL)
return;

mpTargetsGroup->addParameter("TargetCN", CCopasiParameter::Type::CN, cn);
}


void CTimeSensProblem::clearTargetCNs()
{
if (mpTargetsGroup == NULL)
Expand Down Expand Up @@ -326,4 +322,3 @@ const CDataArray * CTimeSensProblem::getScaledTargetsResultAnnotated() const
{
return mpScaledTargetsResultAnnotation;
}

Loading

0 comments on commit 8fd1a60

Please sign in to comment.