COPASI API  4.16.103
Public Slots | Signals | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | Private Slots | Private Member Functions | Friends | List of all members
CQExperimentData Class Reference

#include <CQExperimentData.h>

Inheritance diagram for CQExperimentData:
Inheritance graph
[legend]
Collaboration diagram for CQExperimentData:
Collaboration graph
[legend]

Public Slots

virtual void loadTable (CExperiment *pExperiment, const bool &guess)
 

Signals

void experimentChanged ()
 

Public Member Functions

 CQExperimentData (QWidget *parent=0, const char *name=0, bool modal=false, Qt::WindowFlags fl=0)
 
virtual bool load (CExperimentSet *pExperimentSet, CCopasiDataModel *pDataModel)
 
 ~CQExperimentData ()
 

Protected Slots

void slotCancel ()
 
void slotCheckFrom (bool checked)
 
void slotCheckHeader (bool checked)
 
void slotCheckNormalizeWeightsPerExperiment (bool flag)
 
void slotCheckTab (bool checked)
 
void slotCheckTo (bool checked)
 
void slotExperimentAdd ()
 
void slotExperimentChanged (QListWidgetItem *pCurrentItem, QListWidgetItem *pPreviousItem)
 
void slotExperimentDelete ()
 
void slotExprimentType (bool isSteadyState)
 
void slotFileAdd ()
 
void slotFileChanged (QListWidgetItem *pCurrentItem, QListWidgetItem *pPreviousItem)
 
void slotFileDelete ()
 
void slotFirst ()
 
void slotHeader ()
 
void slotLast ()
 
void slotModelObject (const QModelIndex &index)
 
void slotModelObjectDelayed ()
 
void slotOK ()
 
void slotRevert ()
 
void slotSeparator ()
 
void slotTypeChanged (int row, int index)
 
void slotUpdateTable ()
 

Protected Member Functions

void enableEdit (const bool &enable)
 
bool isLikePreviousExperiment (CExperiment *pExperiment)
 
virtual bool loadExperiment (CExperiment *pExperiment)
 
bool saveExperiment (CExperiment *pExperiment, const bool &full)
 
bool saveTable (CExperiment *pExperiment)
 
void syncExperiments ()
 

Protected Attributes

bool mCrossValidation
 
std::map< std::string,
std::string > 
mFileMap
 
std::map< std::string,
std::string > 
mKeyMap
 
int mModelObjectRow
 
unsigned int mOldWeightMethod
 
CQComboDelegatempComboDelegate
 
CCopasiDataModelmpDataModel
 
CExperimentmpExperiment
 
CExperimentSetmpExperimentSet
 
CExperimentSetmpExperimentSetCopy
 
CExperimentFileInfompFileInfo
 
CQExperimentDataValidatormpValidatorFirst
 
CQExperimentDataValidatormpValidatorHeader
 
CQExperimentDataValidatormpValidatorLast
 
CQExperimentDataValidatormpValidatorName
 
bool mShowError
 
int mShown
 
QStringList mTypeItems
 
QStringList mTypeWithoutTimeItems
 

Private Slots

void slotWeightMethod (int weightMethod)
 

Private Member Functions

void destroy ()
 
void init ()
 
void selectModelObject (const int &row)
 
void setTypeItems (const int &timeRow)
 
void updateScales ()
 

Friends

class CQExperimentDataValidator
 

Detailed Description

Definition at line 31 of file CQExperimentData.h.

Constructor & Destructor Documentation

CQExperimentData::CQExperimentData ( QWidget *  parent = 0,
const char *  name = 0,
bool  modal = false,
Qt::WindowFlags  fl = 0 
)

Definition at line 66 of file CQExperimentData.cpp.

References init().

66  :
67  QDialog(parent, fl),
69  mpValidatorHeader(NULL),
70  mpValidatorLast(NULL),
71  mpExperiment(NULL),
72  mpFileInfo(NULL),
73  mpExperimentSet(NULL),
74  mpExperimentSetCopy(NULL),
75  mKeyMap(),
76  mFileMap(),
78  mShown(-1),
79  mpValidatorName(NULL),
80  mCrossValidation(false),
81  mShowError(true),
82  mpDataModel(NULL),
83  mpComboDelegate(NULL),
84  mTypeItems(),
86  mModelObjectRow(-1)
87 {
88  setObjectName(QString::fromUtf8(name));
89  setModal(modal);
90  setupUi(this);
91 
92  init();
93 }
CQExperimentDataValidator * mpValidatorFirst
CQComboDelegate * mpComboDelegate
std::map< std::string, std::string > mFileMap
CCopasiDataModel * mpDataModel
CQExperimentDataValidator * mpValidatorName
std::map< std::string, std::string > mKeyMap
CExperiment * mpExperiment
unsigned int mOldWeightMethod
CExperimentFileInfo * mpFileInfo
QStringList mTypeWithoutTimeItems
bool fl(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
CExperimentSet * mpExperimentSet
CQExperimentDataValidator * mpValidatorHeader
QStringList mTypeItems
CExperimentSet * mpExperimentSetCopy
CQExperimentDataValidator * mpValidatorLast
CQExperimentData::~CQExperimentData ( )

Definition at line 98 of file CQExperimentData.cpp.

References destroy().

99 {
100  destroy();
101  // no need to delete child widgets, Qt does it all for us
102 }

Member Function Documentation

void CQExperimentData::destroy ( )
private

Definition at line 824 of file CQExperimentData.cpp.

References mpExperimentSetCopy, mpFileInfo, and pdelete.

Referenced by ~CQExperimentData().

825 {
828 }
#define pdelete(p)
Definition: copasi.h:215
CExperimentFileInfo * mpFileInfo
CExperimentSet * mpExperimentSetCopy
void CQExperimentData::enableEdit ( const bool &  enable)
protected

Definition at line 1580 of file CQExperimentData.cpp.

Referenced by slotCheckFrom(), slotExperimentChanged(), and slotExperimentDelete().

1581 {
1582  if (enable)
1583  {
1584  mpBtnSteadystate->setEnabled(true);
1585  mpBtnTimeCourse->setEnabled(true);
1586 
1587  if (mpCheckHeader->isChecked()) mpEditHeader->setEnabled(true);
1588 
1589  mpCheckHeader->setEnabled(true);
1590 
1591  if (!mpCheckTab->isChecked()) mpEditSeparator->setEnabled(true);
1592 
1593  mpCheckTab->setEnabled(true);
1594  mpTable->setEnabled(true);
1595  mpBoxWeightMethod->setEnabled(true);
1596 
1597  mpCheckNormalizeWeightsPerExperiment->setEnabled(true);
1598 
1599  // We need to enable all items in COL_TYPE and some in COL_BTN
1600  // Disable is inheritted but enable not.
1601  /*
1602  if (mpExperiment)
1603  {
1604  size_t i, imax = mpTable->rowCount();
1605 
1606  for (i = 0; i < imax; i++)
1607  {
1608  CExperiment::Type Type = static_cast< CExperiment::Type >(mpTable->item((int) i, COL_TYPE_HIDDEN)->data(Qt::DisplayRole).toInt());
1609 
1610  QTableWidgetItem * pItem = mpTable->item((int) i, COL_BTN);
1611 
1612  if (Type == CExperiment::ignore || Type == CExperiment::time)
1613  {
1614  pItem->setFlags(pItem->flags() & ~Qt::ItemIsEditable & ~Qt::ItemIsEnabled);
1615  mpTable->closePersistentEditor(pItem);
1616  }
1617  else
1618  {
1619  pItem->setFlags(pItem->flags() | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1620  mpTable->openPersistentEditor(pItem);
1621  }
1622  }
1623  }
1624  */
1625  }
1626  else
1627  {
1628  mpBtnSteadystate->setEnabled(false);
1629  mpBtnTimeCourse->setEnabled(false);
1630  mpEditHeader->setEnabled(false);
1631  mpCheckHeader->setEnabled(false);
1632  mpEditSeparator->setEnabled(false);
1633  mpCheckTab->setEnabled(false);
1634  mpTable->setEnabled(false);
1635  mpBoxWeightMethod->setEnabled(false);
1636  mpCheckNormalizeWeightsPerExperiment->setEnabled(false);
1637  }
1638 }
void CQExperimentData::experimentChanged ( )
signal

Referenced by slotOK().

void CQExperimentData::init ( )
private

Definition at line 768 of file CQExperimentData.cpp.

References COL_BTN, COL_OBJECT_HIDDEN, COL_TYPE, COL_TYPE_HIDDEN, CQIconResource::copasi, CQExperimentDataValidator, CQIconResource::editAdd, CQIconResource::editDelete, CQExperimentDataValidator::FirstRow, FROM_UTF8, CQExperimentDataValidator::HeaderRow, CQIconResource::icon(), CQExperimentDataValidator::LastRow, mCrossValidation, mpComboDelegate, mpDataModel, mpExperiment, mpExperimentSetCopy, mpFileInfo, mpValidatorFirst, mpValidatorHeader, mpValidatorLast, mpValidatorName, mShowError, mTypeItems, mTypeWithoutTimeItems, CQExperimentDataValidator::Name, slotModelObject(), slotTypeChanged(), CQPushButtonDelegate::ToolButton, CExperiment::TypeName, and CExperiment::WeightMethodName.

Referenced by CQExperimentData().

769 {
770  mpBtnFileAdd->setIcon(CQIconResource::icon(CQIconResource::editAdd));
771  mpBtnFileDelete->setIcon(CQIconResource::icon(CQIconResource::editDelete));
772  mpBtnExperimentAdd->setIcon(CQIconResource::icon(CQIconResource::editAdd));
773  mpBtnExperimentDelete->setIcon(CQIconResource::icon(CQIconResource::editDelete));
774 
775  mpTable->hideColumn(COL_TYPE_HIDDEN);
776  mpTable->hideColumn(COL_OBJECT_HIDDEN);
777 
778  mpComboDelegate = new CQComboDelegate(NULL, this);
779  mpTable->setItemDelegateForColumn(COL_TYPE, mpComboDelegate);
780  connect(mpComboDelegate, SIGNAL(currentIndexChanged(int, int)), this, SLOT(slotTypeChanged(int, int)));
781 
784  mpTable->setItemDelegateForColumn(COL_BTN, pButtonDelegate);
785  connect(pButtonDelegate, SIGNAL(clicked(const QModelIndex &)), this, SLOT(slotModelObject(const QModelIndex &)));
786 
787  const std::string * pWeightMethod = CExperiment::WeightMethodName;
788 
789  while (*pWeightMethod != "")
790  mpBoxWeightMethod->insertItem(mpBoxWeightMethod->count(), FROM_UTF8(*pWeightMethod++));
791 
792  mpExperimentSetCopy = NULL;
793  mpFileInfo = NULL;
794  mpExperiment = NULL;
795 
797  mpEditName->setValidator(mpValidatorName);
799  mpEditFirst->setValidator(mpValidatorFirst);
801  mpEditLast->setValidator(mpValidatorLast);
803  mpEditHeader->setValidator(mpValidatorHeader);
804 
805  mCrossValidation = false;
806  mShowError = true;
807 
808  mpDataModel = NULL;
809 
810  // Set the combo box items
811  const std::string * pTmp = CExperiment::TypeName;
812 
813  while (*pTmp != "")
814  {
815  mTypeItems.push_back(FROM_UTF8(*pTmp));
816 
817  if (*pTmp != "Time")
818  mTypeWithoutTimeItems.push_back(FROM_UTF8(*pTmp));
819 
820  pTmp++;
821  }
822 }
friend class CQExperimentDataValidator
void slotTypeChanged(int row, int index)
CQExperimentDataValidator * mpValidatorFirst
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
CQComboDelegate * mpComboDelegate
#define COL_BTN
CCopasiDataModel * mpDataModel
#define COL_OBJECT_HIDDEN
CQExperimentDataValidator * mpValidatorName
CExperiment * mpExperiment
static const QIcon & icon(const IconID &id)
CExperimentFileInfo * mpFileInfo
static const std::string WeightMethodName[]
Definition: CExperiment.h:101
#define COL_TYPE_HIDDEN
void slotModelObject(const QModelIndex &index)
QStringList mTypeWithoutTimeItems
#define COL_TYPE
CQExperimentDataValidator * mpValidatorHeader
QStringList mTypeItems
CExperimentSet * mpExperimentSetCopy
static const std::string TypeName[]
Definition: CExperiment.h:79
CQExperimentDataValidator * mpValidatorLast
bool CQExperimentData::isLikePreviousExperiment ( CExperiment pExperiment)
protected

Definition at line 1528 of file CQExperimentData.cpp.

References C_INVALID_INDEX, CExperimentSet::getExperiment(), CExperiment::getExperimentType(), CExperiment::getHeaderRow(), CExperiment::getNormalizeWeightsPerExperiment(), CExperiment::getObjectMap(), CExperiment::getSeparator(), CExperiment::getWeightMethod(), CExperimentSet::keyToIndex(), mOldWeightMethod, mpExperiment, and mpExperimentSetCopy.

Referenced by loadExperiment(), saveExperiment(), slotCheckNormalizeWeightsPerExperiment(), slotExperimentDelete(), and slotWeightMethod().

1529 {
1530  if (!pExperiment) return false;
1531 
1532  size_t Previous =
1533  mpExperimentSetCopy->keyToIndex(pExperiment->CCopasiParameter::getKey()) - 1;
1534 
1535  if (Previous == C_INVALID_INDEX) return false;
1536 
1537  CExperiment * pPrevious = mpExperimentSetCopy->getExperiment(Previous);
1538 
1539  if (pExperiment->getSeparator() != pPrevious->getSeparator()) return false;
1540 
1541  if (pExperiment->getHeaderRow() != pPrevious->getHeaderRow()) return false;
1542 
1543  if (pExperiment->getExperimentType() != pPrevious->getExperimentType()) return false;
1544 
1545  if (mpExperiment != pExperiment)
1546  {
1547  if (pExperiment->getWeightMethod() != (CExperiment::WeightMethod) mOldWeightMethod) return false;
1548 
1549  if (pExperiment->getNormalizeWeightsPerExperiment() != pPrevious->getNormalizeWeightsPerExperiment()) return false;
1550  }
1551  else
1552  {
1553  if ((CExperiment::WeightMethod) mOldWeightMethod != pPrevious->getWeightMethod()) return false;
1554  }
1555 
1556  if (!(pExperiment->getObjectMap() == pPrevious->getObjectMap())) return false;
1557 
1558  return true;
1559 }
#define C_INVALID_INDEX
Definition: copasi.h:222
CExperiment * getExperiment(const size_t &index)
const WeightMethod & getWeightMethod() const
CExperiment * mpExperiment
unsigned int mOldWeightMethod
CExperimentObjectMap & getObjectMap()
const unsigned C_INT32 & getHeaderRow() const
size_t keyToIndex(const std::string &key) const
const CCopasiTask::Type & getExperimentType() const
const std::string & getSeparator() const
CExperimentSet * mpExperimentSetCopy
bool getNormalizeWeightsPerExperiment() const
bool CQExperimentData::load ( CExperimentSet pExperimentSet,
CCopasiDataModel pDataModel 
)
virtual

Definition at line 684 of file CQExperimentData.cpp.

References CCopasiParameterGroup::clear(), CDirEntry::fileName(), FROM_UTF8, CExperimentSet::getExperiment(), CExperimentSet::getExperimentCount(), CExperimentSet::getFileNames(), mCrossValidation, mFileMap, mKeyMap, mpDataModel, mpExperiment, mpExperimentSet, mpExperimentSetCopy, mpFileInfo, mShown, pdelete, slotFileChanged(), and StringPrint().

Referenced by CQFittingWidget::slotCrossValidationData(), CQFittingWidget::slotExperimentData(), and slotRevert().

685 {
686  mpDataModel = pDataModel;
687 
688  mCrossValidation = (dynamic_cast< CCrossValidationSet * >(pExperimentSet) != NULL);
689 
690  if (mCrossValidation)
691  {
692  setWindowTitle("Validation Data");
693  mpLblWeight->show();
694  mpEditWeight->show();
695  mpLblThreshold->show();
696  mpEditThreshold->show();
697  mpLineCrossValidation->show();
698 
699  mpEditWeight->setText(QString::number(static_cast< CCrossValidationSet * >(pExperimentSet)->getWeight()));
700  mpEditThreshold->setText(QString::number(static_cast< CCrossValidationSet * >(pExperimentSet)->getThreshold()));
701  }
702  else
703  {
704  mpLblWeight->hide();
705  mpEditWeight->hide();
706  mpLblThreshold->hide();
707  mpEditThreshold->hide();
708  mpLineCrossValidation->hide();
709  }
710 
711  if (!pExperimentSet) return false;
712 
713  mpExperiment = NULL;
714  mShown = -1;
715 
716  mpExperimentSet = pExperimentSet;
717 
719 
720  mpExperimentSetCopy = new CExperimentSet(*pExperimentSet);
721 
722  if (mCrossValidation)
723  mpExperimentSetCopy = elevate< CCrossValidationSet, CExperimentSet >(mpExperimentSetCopy);
724 
727 
728  // Build the key map so that we are able to update the correct experiments
729  // on OK.
730  mKeyMap.clear();
731  size_t i, imax = mpExperimentSet->getExperimentCount();
732 
733  for (i = 0; i < imax; i++)
734  mKeyMap[mpExperimentSet->getExperiment(i)->CCopasiParameter::getKey()] =
735  mpExperimentSetCopy->getExperiment(i)->CCopasiParameter::getKey();
736 
737  // fill file list box
738  mpBoxFile->clear();
739 
740  std::vector< std::string > FileNames = mpExperimentSetCopy->getFileNames();
741  std::vector< std::string >::const_iterator it = FileNames.begin();
742  std::vector< std::string >::const_iterator end = FileNames.end();
743 
744  std::string FileName;
745  i = 0;
746 
747  mFileMap.clear();
748 
749  for (; it != end; ++it)
750  {
751  FileName = CDirEntry::fileName(*it);
752 
753  while (mFileMap.find(FileName) != mFileMap.end())
754  FileName = StringPrint("%s_%d", CDirEntry::fileName(*it).c_str(), i++);
755 
756  mFileMap[FileName] = *it;
757  mpBoxFile->addItem(FROM_UTF8(FileName));
758  }
759 
760  if (mpBoxFile->count())
761  mpBoxFile->setCurrentRow(0); // This triggers the rest of the update :)
762  else
763  slotFileChanged(NULL, NULL);
764 
765  return true;
766 }
std::vector< std::string > getFileNames() const
#define pdelete(p)
Definition: copasi.h:215
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
std::map< std::string, std::string > mFileMap
void slotFileChanged(QListWidgetItem *pCurrentItem, QListWidgetItem *pPreviousItem)
CCopasiDataModel * mpDataModel
static std::string fileName(const std::string &path)
Definition: CDirEntry.cpp:119
CExperiment * getExperiment(const size_t &index)
std::map< std::string, std::string > mKeyMap
CExperiment * mpExperiment
CExperimentFileInfo * mpFileInfo
std::string StringPrint(const char *format,...)
Definition: utility.cpp:87
CExperimentSet * mpExperimentSet
CExperimentSet * mpExperimentSetCopy
size_t getExperimentCount() const
bool CQExperimentData::loadExperiment ( CExperiment pExperiment)
protectedvirtual

Definition at line 848 of file CQExperimentData.cpp.

References COL_SCALE, FROM_UTF8, CExperimentSet::getExperiment(), CExperiment::getExperimentType(), CExperiment::getFirstRow(), CExperiment::getHeaderRow(), CExperiment::getLastRow(), CExperiment::getNormalizeWeightsPerExperiment(), CCopasiObject::getObjectName(), CExperiment::getSeparator(), CExperiment::getWeightMethod(), InvalidIndex, isLikePreviousExperiment(), CExperimentSet::keyToIndex(), loadTable(), mOldWeightMethod, mpExperimentSetCopy, mpValidatorFirst, mpValidatorHeader, mpValidatorLast, mpValidatorName, CQValidator< Type >::saved(), CExperiment::SD, CCopasiTask::timeCourse, and CExperiment::VALUE_SCALING.

Referenced by slotCheckFrom(), and slotExperimentChanged().

849 {
850 
851  // Temporarily disconnect signals
852  mpCheckTo->blockSignals(true);
853  mpCheckFrom->blockSignals(true);
854  mpBtnSteadystate->blockSignals(true);
855  mpEditSeparator->blockSignals(true);
856  mpCheckTab->blockSignals(true);
857  mpCheckNormalizeWeightsPerExperiment->blockSignals(true);
858 
859  if (!pExperiment)
860  {
861  mpEditName->setText("");
862  mpEditSeparator->setText("");
863  mpCheckTab->setChecked(true);
864  mpEditFirst->setText("");
865  mpEditLast->setText("");
866  mpEditHeader->setText("");
867  mpCheckHeader->setChecked(false);
868  mpBtnTimeCourse->setChecked(true);
869  mpCheckNormalizeWeightsPerExperiment->setChecked(true);
870  mpCheckFrom->setChecked(false);
871  mpCheckTo->setChecked(false);
872  mpBoxWeightMethod->setCurrentIndex(CExperiment::SD);
873  }
874  else
875  {
876  mpEditName->setText(FROM_UTF8(pExperiment->getObjectName()));
877 
878  if (pExperiment->getSeparator() == "\t")
879  {
880  mpEditSeparator->setText("");
881  mpCheckTab->setChecked(true);
882  }
883  else
884  {
885  mpEditSeparator->setText(FROM_UTF8(pExperiment->getSeparator()));
886  mpCheckTab->setChecked(false);
887  }
888 
889  QString Row = (pExperiment->getFirstRow() == InvalidIndex) ?
890  "" : QString::number(pExperiment->getFirstRow());
891  mpEditFirst->setText(Row);
892  Row = (pExperiment->getLastRow() == InvalidIndex) ?
893  "" : QString::number(pExperiment->getLastRow());
894  mpEditLast->setText(Row);
895 
896  if (pExperiment->getHeaderRow() == InvalidIndex)
897  {
898  mpEditHeader->setText("");
899  mpCheckHeader->setChecked(false);
900  }
901  else
902  {
903  mpEditHeader->setText(QString::number(pExperiment->getHeaderRow()));
904  mpCheckHeader->setChecked(true);
905  }
906 
907  if (pExperiment->getExperimentType() == CCopasiTask::timeCourse)
908  mpBtnTimeCourse->setChecked(true);
909  else
910  mpBtnSteadystate->setChecked(true);
911 
912  mOldWeightMethod = pExperiment->getWeightMethod();
913  mpBoxWeightMethod->setCurrentIndex(mOldWeightMethod);
914 
916  {
918  mpTable->horizontalHeaderItem(COL_SCALE)->setText("Epsilon");
919  break;
920 
921  default:
922  mpTable->horizontalHeaderItem(COL_SCALE)->setText("Weight");
923  break;
924  }
925 
926  mpCheckNormalizeWeightsPerExperiment->setChecked(pExperiment->getNormalizeWeightsPerExperiment());
927 
928  size_t Next =
929  mpExperimentSetCopy->keyToIndex(pExperiment->CCopasiParameter::getKey()) + 1;
930 
931  mpCheckFrom->setChecked(isLikePreviousExperiment(pExperiment));
932 
933  if (Next < mpExperimentSetCopy->getExperimentCount())
934  mpCheckTo->setChecked(isLikePreviousExperiment(mpExperimentSetCopy->getExperiment(Next)));
935  else
936  mpCheckTo->setChecked(false);
937  }
938 
943 
944  // Reconnect signals
945  mpCheckTo->blockSignals(false);
946  mpCheckFrom->blockSignals(false);
947  mpBtnSteadystate->blockSignals(false);
948  mpEditSeparator->blockSignals(false);
949  mpCheckTab->blockSignals(false);
950  mpCheckNormalizeWeightsPerExperiment->blockSignals(false);
951 
952  loadTable(pExperiment, false);
953 
954  return true;
955 }
CQExperimentDataValidator * mpValidatorFirst
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const unsigned C_INT32 & getFirstRow() const
bool isLikePreviousExperiment(CExperiment *pExperiment)
const std::string & getObjectName() const
CExperiment * getExperiment(const size_t &index)
const WeightMethod & getWeightMethod() const
CQExperimentDataValidator * mpValidatorName
#define COL_SCALE
virtual void saved() const
Definition: CQValidator.h:71
unsigned int mOldWeightMethod
virtual void loadTable(CExperiment *pExperiment, const bool &guess)
const unsigned C_INT32 & getHeaderRow() const
size_t keyToIndex(const std::string &key) const
const CCopasiTask::Type & getExperimentType() const
#define InvalidIndex
const std::string & getSeparator() const
CQExperimentDataValidator * mpValidatorHeader
CExperimentSet * mpExperimentSetCopy
const unsigned C_INT32 & getLastRow() const
bool getNormalizeWeightsPerExperiment() const
CQExperimentDataValidator * mpValidatorLast
void CQExperimentData::loadTable ( CExperiment pExperiment,
const bool &  guess 
)
virtualslot

Definition at line 1124 of file CQExperimentData.cpp.

References C_FLOAT64, C_INVALID_INDEX, COL_BTN, COL_NAME, COL_OBJECT, COL_OBJECT_HIDDEN, COL_SCALE, COL_TYPE, COL_TYPE_HIDDEN, CExperiment::dependent, FROM_UTF8, CExperiment::getColumnNames(), CCopasiRootContainer::getDatamodelList(), CCopasiDataModel::getDataObject(), CExperimentObjectMap::getDefaultScale(), CExperimentObjectMap::getObjectCN(), CCopasiObject::getObjectDisplayName(), CExperiment::getObjectMap(), CExperimentObjectMap::getRole(), CExperimentObjectMap::getScale(), CExperiment::ignore, CExperiment::readColumnNames(), CExperimentObjectMap::setRole(), setTypeItems(), CExperiment::time, and CExperiment::TypeName.

Referenced by loadExperiment(), slotCheckNormalizeWeightsPerExperiment(), slotExprimentType(), slotSeparator(), slotUpdateTable(), and slotWeightMethod().

1125 {
1126  if (!pExperiment)
1127  {
1128  mpTable->clearContents();
1129  mpTable->setRowCount(0);
1130 
1131  return;
1132  }
1133 
1134  size_t TimeRow = C_INVALID_INDEX;
1135 
1136  pExperiment->readColumnNames();
1137  const std::vector<std::string> & ColumnNames = pExperiment->getColumnNames();
1138 
1139  size_t OldRowCount = mpTable->rowCount();
1140  size_t i, imax = ColumnNames.size();
1141  mpTable->setRowCount((int)(imax));
1142 
1143  CExperimentObjectMap & ObjectMap = pExperiment->getObjectMap();
1144  const CCopasiObject *pObject;
1145  CExperiment::Type Type;
1146  QTableWidgetItem *pItem = NULL;
1147  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
1149  assert(pDataModel != NULL);
1150 
1151  for (i = 0; i < imax; i++)
1152  {
1153  // Check whether we need to allocate table items.
1154  if (OldRowCount <= i)
1155  {
1156  // COL_NAME
1157  pItem = new QTableWidgetItem();
1158  pItem->setFlags(pItem->flags() & ~Qt::ItemIsEditable);
1159  mpTable->setItem((int) i, COL_NAME, pItem);
1160 
1161  // COL_TYPE
1162  pItem = new QTableWidgetItem();
1163  mpTable->setItem((int) i, COL_TYPE, pItem);
1164 
1165  // COL_TYPE_HIDDEN
1166  pItem = new QTableWidgetItem();
1167  pItem->setFlags(pItem->flags() & ~Qt::ItemIsEditable);
1168  mpTable->setItem((int) i, COL_TYPE_HIDDEN, pItem);
1169 
1170  // COL_BTN
1171  pItem = new QTableWidgetItem();
1172  mpTable->setItem(i, COL_BTN, pItem);
1173 
1174  // COL_OBJECT
1175  pItem = new QTableWidgetItem();
1176  pItem->setFlags(pItem->flags() & ~Qt::ItemIsEditable);
1177  mpTable->setItem((int) i, COL_OBJECT, pItem);
1178 
1179  // COL_OBJECT_HIDDEN
1180  pItem = new QTableWidgetItem();
1181  pItem->setFlags(pItem->flags() & ~Qt::ItemIsEditable);
1182  mpTable->setItem((int) i, COL_OBJECT_HIDDEN, pItem);
1183 
1184  // COL_SCALE
1185  pItem = new QTableWidgetItem("");
1186  mpTable->setItem((int) i, COL_SCALE, pItem);
1187  }
1188 
1189  // COL_NAME
1190  mpTable->item((int) i, COL_NAME)->setText(FROM_UTF8(ColumnNames[i]));
1191 
1192  // COL_TYPE
1193  if (guess && TimeRow == C_INVALID_INDEX &&
1194  mpBtnTimeCourse->isChecked() &&
1195  mpTable->item((int) i, COL_NAME)->text().contains("time", Qt::CaseInsensitive))
1196  {
1197  ObjectMap.setRole(i, CExperiment::time);
1198  }
1199 
1200  Type = ObjectMap.getRole(i);
1201 
1202  if (Type == CExperiment::time) TimeRow = i;
1203 
1204  mpTable->item((int) i, COL_TYPE)->setText(FROM_UTF8(CExperiment::TypeName[Type]));
1205 
1206  // COL_TYPE_HIDDEN
1207  mpTable->item((int) i, COL_TYPE_HIDDEN)->setText(QString::number(Type));
1208 
1209  // COL_BTN
1210  pItem = mpTable->item(i, COL_BTN);
1211 
1212  // Show the Button
1213  if (Type == CExperiment::ignore || Type == CExperiment::time)
1214  {
1215  pItem->setFlags(pItem->flags() & ~Qt::ItemIsEditable & ~Qt::ItemIsEnabled);
1216  mpTable->closePersistentEditor(pItem);
1217  }
1218  else
1219  {
1220  pItem->setFlags(pItem->flags() | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1221  mpTable->openPersistentEditor(pItem);
1222  }
1223 
1224  // COL_OBJECT and COL_OBJECT_HIDDEN
1225  QTableWidgetItem * pItem;
1226 
1227  if (ObjectMap.getObjectCN(i) != "")
1228  {
1229  pObject = pDataModel->getDataObject(ObjectMap.getObjectCN(i));
1230 
1231  if (pObject)
1232  mpTable->item((int) i, COL_OBJECT)->setText(FROM_UTF8(pObject->getObjectDisplayName()));
1233  else
1234  mpTable->item((int) i, COL_OBJECT)->setText("not found");
1235 
1236  mpTable->item((int) i, COL_OBJECT_HIDDEN)->setText(FROM_UTF8(ObjectMap.getObjectCN(i)));
1237  }
1238  else
1239  {
1240  mpTable->item((int) i, COL_OBJECT)->setText("");
1241  mpTable->item((int) i, COL_OBJECT_HIDDEN)->setText("");
1242  }
1243 
1244  // COL_SCALE
1245  pItem = mpTable->item((int) i, COL_SCALE);
1246 
1247  if (Type != CExperiment::dependent)
1248  {
1249  pItem->setText("");
1250  pItem->setFlags(pItem->flags() & ~Qt::ItemIsEditable);
1251  }
1252  else
1253  {
1254  C_FLOAT64 DefaultScale = ObjectMap.getDefaultScale(i);
1255  C_FLOAT64 Scale = ObjectMap.getScale(i);
1256 
1257  QString ScaleText;
1258  Qt::ItemFlags FlagMask = Qt::NoItemFlags;
1259 
1260  if ((isnan(DefaultScale) && isnan(Scale)) ||
1261  DefaultScale == Scale)
1262  ScaleText = "(" + QString::number(DefaultScale) + ")";
1263  else
1264  ScaleText = QString::number(Scale);
1265 
1266  pItem->setText(ScaleText);
1267  pItem->setFlags(pItem->flags() & ~FlagMask);
1268  }
1269  }
1270 
1271  setTypeItems(TimeRow);
1272 
1273  mpTable->resizeColumnsToContents();
1274  mpTable->resizeRowsToContents();
1275 }
CCopasiObject * getDataObject(const CCopasiObjectName &CN) const
C_FLOAT64 getScale(const size_t &index) const
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
CExperiment::Type getRole(const size_t &index) const
C_FLOAT64 getDefaultScale(const size_t &index) const
#define COL_BTN
#define COL_OBJECT_HIDDEN
#define C_INVALID_INDEX
Definition: copasi.h:222
const std::vector< std::string > & getColumnNames() const
#define COL_SCALE
bool setRole(const size_t &index, const CExperiment::Type &role)
CExperimentObjectMap & getObjectMap()
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
#define COL_NAME
#define COL_TYPE_HIDDEN
void setTypeItems(const int &timeRow)
#define COL_TYPE
#define C_FLOAT64
Definition: copasi.h:92
std::string getObjectCN(const size_t &index) const
#define COL_OBJECT
bool readColumnNames()
static const std::string TypeName[]
Definition: CExperiment.h:79
bool CQExperimentData::saveExperiment ( CExperiment pExperiment,
const bool &  full 
)
protected

Definition at line 957 of file CQExperimentData.cpp.

References CExperimentSet::getExperiment(), CExperimentFileInfo::getFirstUnusedSection(), CCopasiObject::getObjectName(), InvalidIndex, isLikePreviousExperiment(), CExperimentSet::keyToIndex(), mpExperimentSetCopy, mpFileInfo, mpValidatorFirst, mpValidatorHeader, mpValidatorLast, mpValidatorName, mShown, CQValidator< Type >::saved(), saveTable(), CExperiment::setExperimentType(), CExperiment::setFirstRow(), CExperiment::setHeaderRow(), CExperiment::setLastRow(), CExperiment::setNormalizeWeightsPerExperiment(), CCopasiObject::setObjectName(), CExperiment::setSeparator(), CExperiment::setWeightMethod(), CCopasiTask::steadyState, CExperimentFileInfo::sync(), CCopasiTask::timeCourse, TO_UTF8, and CQExperimentDataValidator::validate().

Referenced by slotCheckTo(), slotExperimentChanged(), and updateScales().

958 {
959  if (!pExperiment) return false;
960 
961  bool success = true;
962 
963  size_t Next =
964  mpExperimentSetCopy->keyToIndex(pExperiment->CCopasiParameter::getKey()) + 1;
965 
966  if (Next < mpExperimentSetCopy->getExperimentCount() && mpCheckTo->isChecked())
967  {
969 
970  if (isLikePreviousExperiment(pNext))
971  success &= saveExperiment(pNext, false);
972  }
973 
974  QString value = mpEditName->text();
975  int pos = value.length();
976 
977  if (full &&
978  pExperiment->getObjectName() != TO_UTF8(value) &&
979  mpValidatorName->validate(value, pos) == QValidator::Acceptable)
980  {
981  int current = mpBoxExperiment->currentRow();
982  mpBoxExperiment->blockSignals(true);
983  mpBoxExperiment->item(mShown)->setText(value);
984  mpBoxExperiment->setCurrentRow(current);
985  mpBoxExperiment->blockSignals(false);
986  pExperiment->setObjectName(TO_UTF8(value));
987  }
988 
989  if (mpCheckTab->isChecked())
990  pExperiment->setSeparator("\t");
991  else
992  pExperiment->setSeparator(TO_UTF8(mpEditSeparator->text()));
993 
994  value = mpEditFirst->text();
995  pos = value.length();
996 
997  if (full &&
998  mpValidatorFirst->validate(value, pos) == QValidator::Acceptable)
999  pExperiment->setFirstRow(value.toULong());
1000 
1001  value = mpEditLast->text();
1002  pos = value.length();
1003 
1004  if (full &&
1005  mpValidatorLast->validate(value, pos) == QValidator::Acceptable)
1006  pExperiment->setLastRow(value.toULong());
1007 
1008  value = mpEditHeader->text();
1009  pos = value.length();
1010 
1011  if (mpCheckHeader->isChecked() &&
1012  mpValidatorHeader->validate(value, pos) == QValidator::Acceptable)
1013  pExperiment->setHeaderRow(value.toULong());
1014  else
1015  {
1016  pExperiment->setHeaderRow(InvalidIndex);
1017  mpCheckHeader->setChecked(false);
1018  }
1019 
1020  if (mpBtnTimeCourse->isChecked())
1022  else
1024 
1025  pExperiment->setWeightMethod((CExperiment::WeightMethod) mpBoxWeightMethod->currentIndex());
1026 
1027  pExperiment->setNormalizeWeightsPerExperiment(mpCheckNormalizeWeightsPerExperiment->isChecked());
1028 
1029  mpFileInfo->sync();
1030 
1031  size_t First, Last;
1032  mpBtnExperimentAdd->setEnabled(mpFileInfo->getFirstUnusedSection(First, Last));
1033 
1038 
1039  saveTable(pExperiment);
1040 
1041  return success;
1042 }
CQExperimentDataValidator * mpValidatorFirst
bool setExperimentType(const CCopasiTask::Type &type)
bool getFirstUnusedSection(size_t &First, size_t &Last)
bool isLikePreviousExperiment(CExperiment *pExperiment)
const std::string & getObjectName() const
bool setHeaderRow(const unsigned C_INT32 &headerRow)
CExperiment * getExperiment(const size_t &index)
CQExperimentDataValidator * mpValidatorName
void setNormalizeWeightsPerExperiment(bool flag)
virtual void saved() const
Definition: CQValidator.h:71
bool setSeparator(const std::string &seperator)
bool saveExperiment(CExperiment *pExperiment, const bool &full)
CExperimentFileInfo * mpFileInfo
virtual State validate(QString &input, int &pos) const
size_t keyToIndex(const std::string &key) const
#define InvalidIndex
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
CQExperimentDataValidator * mpValidatorHeader
bool setFirstRow(const unsigned C_INT32 &firstRow)
CExperimentSet * mpExperimentSetCopy
bool setLastRow(const unsigned C_INT32 &lastRow)
bool setObjectName(const std::string &name)
bool saveTable(CExperiment *pExperiment)
CQExperimentDataValidator * mpValidatorLast
bool setWeightMethod(const WeightMethod &weightMethod)
bool CQExperimentData::saveTable ( CExperiment pExperiment)
protected

Definition at line 1436 of file CQExperimentData.cpp.

References COL_OBJECT_HIDDEN, COL_SCALE, COL_TYPE, CExperiment::dependent, CExperimentObjectMap::getObjectCN(), CExperiment::getObjectMap(), CExperimentObjectMap::getRole(), CExperimentObjectMap::getScale(), CExperiment::ignore, CExperimentObjectMap::setNumCols(), CExperimentObjectMap::setObjectCN(), CExperimentObjectMap::setRole(), CExperimentObjectMap::setScale(), CExperiment::time, TO_UTF8, toEnum(), CExperiment::TypeName, and CExperiment::updateFittedPoints().

Referenced by saveExperiment(), slotCheckNormalizeWeightsPerExperiment(), slotExprimentType(), and slotWeightMethod().

1437 {
1438  CExperimentObjectMap & ObjectMap = pExperiment->getObjectMap();
1439  size_t i, imax = mpTable->rowCount();
1440  bool FoundTime = false;
1441  bool Changed = false;
1442 
1443  ObjectMap.setNumCols(imax);
1444 
1445  for (i = 0; i < imax; i++)
1446  {
1447  CExperiment::Type Type = toEnum(TO_UTF8(mpTable->item((int) i, COL_TYPE)->text()),
1449 
1450  if (Type == CExperiment::time)
1451  FoundTime = true;
1452 
1453  if (ObjectMap.getRole(i) != Type)
1454  {
1455  ObjectMap.setRole(i, Type);
1456  Changed = true;
1457  }
1458 
1459  if (ObjectMap.getObjectCN(i) != TO_UTF8(mpTable->item((int) i, COL_OBJECT_HIDDEN)->text()))
1460  {
1461  ObjectMap.setObjectCN(i, TO_UTF8(mpTable->item((int) i, COL_OBJECT_HIDDEN)->text()));
1462  Changed = true;
1463  }
1464 
1465  QString ScaleText = mpTable->item((int) i, COL_SCALE)->text();
1466 
1467  // Empty fields are treated as default.
1468  if (ScaleText == "")
1469  ScaleText = QString::number(std::numeric_limits<C_FLOAT64>::quiet_NaN());
1470 
1471  if (Type == CExperiment::dependent &&
1472  ScaleText[0] != '(' &&
1473  QString::number(ObjectMap.getScale(i)) != ScaleText)
1474  {
1475  ObjectMap.setScale(i, ScaleText.toDouble());
1476  Changed = true;
1477  }
1478  }
1479 
1480  pExperiment->updateFittedPoints();
1481 
1482  return Changed;
1483 }
C_FLOAT64 getScale(const size_t &index) const
bool setScale(const size_t &index, const C_FLOAT64 &scale)
CExperiment::Type getRole(const size_t &index) const
#define COL_OBJECT_HIDDEN
#define COL_SCALE
bool setRole(const size_t &index, const CExperiment::Type &role)
CExperimentObjectMap & getObjectMap()
CType toEnum(const char *attribute, const char **enumNames, const CType &enumDefault)
Definition: utility.h:107
#define COL_TYPE
void updateFittedPoints()
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
std::string getObjectCN(const size_t &index) const
bool setNumCols(const size_t &numCols)
bool setObjectCN(const size_t &index, const std::string &objectCN)
static const std::string TypeName[]
Definition: CExperiment.h:79
void CQExperimentData::selectModelObject ( const int &  row)
private

Definition at line 1088 of file CQExperimentData.cpp.

References COL_OBJECT, COL_OBJECT_HIDDEN, COL_TYPE_HIDDEN, FROM_UTF8, CCopasiObject::getCN(), CCopasiObject::getObjectDisplayName(), CCopasiSelectionDialog::getObjectSingle(), CExperiment::independent, CQSimpleSelectionTree::InitialTime, CQSimpleSelectionTree::ObservedValues, CQSimpleSelectionTree::Parameters, updateScales(), and CQSimpleSelectionTree::Variables.

Referenced by slotModelObject(), and slotModelObjectDelayed().

1089 {
1091  CExperiment::Type Type = static_cast< CExperiment::Type >(mpTable->item(row, COL_TYPE_HIDDEN)->data(Qt::DisplayRole).toInt());
1092 
1093  if (Type == CExperiment::independent)
1094  Classes =
1097  else
1098  Classes =
1101 
1102  const CCopasiObject * pObject =
1104 
1105  if (pObject)
1106  {
1107  mpTable->item(row, COL_OBJECT)->setText(FROM_UTF8(pObject->getObjectDisplayName()));
1108  mpTable->item(row, COL_OBJECT_HIDDEN)->setText(FROM_UTF8(pObject->getCN()));
1109  }
1110 
1111  updateScales();
1112 }
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
virtual CCopasiObjectName getCN() const
#define COL_OBJECT_HIDDEN
#define COL_TYPE_HIDDEN
#define COL_OBJECT
static const CCopasiObject * getObjectSingle(QWidget *pParent, const CQSimpleSelectionTree::ObjectClasses &classes, const CCopasiObject *pCurrentObject=NULL)
void CQExperimentData::setTypeItems ( const int &  timeRow)
private

Definition at line 830 of file CQExperimentData.cpp.

References mpComboDelegate, mTypeItems, mTypeWithoutTimeItems, and CQComboDelegate::setItems().

Referenced by loadTable(), and slotTypeChanged().

831 {
832  int i, imax = mpTable->rowCount();
833 
834  for (i = 0; i < imax; i++)
835  {
836  if ((timeRow != -1 && timeRow != i) ||
837  mpBtnSteadystate->isChecked())
838  {
840  }
841  else
842  {
844  }
845  }
846 }
CQComboDelegate * mpComboDelegate
QStringList mTypeWithoutTimeItems
QStringList mTypeItems
void setItems(int row, const QStringList *pComboItems)
void CQExperimentData::slotCancel ( )
protectedslot

Definition at line 630 of file CQExperimentData.cpp.

631 {
632  reject();
633 }
void CQExperimentData::slotCheckFrom ( bool  checked)
protectedslot

Definition at line 1485 of file CQExperimentData.cpp.

References C_INT32, C_INVALID_INDEX, enableEdit(), FROM_UTF8, CExperimentFileInfo::getExperiment(), CExperiment::getFirstRow(), CExperiment::getLastRow(), CCopasiObject::getObjectName(), InvalidIndex, loadExperiment(), mOldWeightMethod, mpExperiment, mpFileInfo, mpValidatorFirst, mpValidatorLast, mpValidatorName, CQValidator< Type >::saved(), and TO_UTF8.

Referenced by slotExperimentDelete().

1486 {
1487  mpCheckFrom->setFocus();
1488 
1489  size_t Current = this->mpBoxExperiment->currentRow();
1490 
1491  if (checked && Current && Current != C_INVALID_INDEX)
1492  {
1493  // Load the information from the previous experiment
1494  CExperiment * pPrevious =
1495  mpFileInfo->getExperiment(TO_UTF8(mpBoxExperiment->item((int)(Current - 1))->text()));
1496 
1497  unsigned C_INT32 OldWeightMethod = mOldWeightMethod;
1498  loadExperiment(pPrevious);
1499  mOldWeightMethod = OldWeightMethod;
1500 
1501  // Load the experiment individual information.
1502  mpEditName->setText(FROM_UTF8(mpExperiment->getObjectName()));
1503  QString Row = (mpExperiment->getFirstRow() == InvalidIndex) ?
1504  "" : QString::number(mpExperiment->getFirstRow());
1505  mpEditFirst->setText(Row);
1506  Row = (mpExperiment->getLastRow() == InvalidIndex) ?
1507  "" : QString::number(mpExperiment->getLastRow());
1508  mpEditLast->setText(Row);
1509 
1513  }
1514  else
1515  {
1517  }
1518 
1519  // loadExperiment determines the status of mpCheckFrom and may have overwritten
1520  // the desired setting. We correct that here.
1521  disconnect(mpCheckFrom, SIGNAL(toggled(bool)), this, SLOT(slotCheckFrom(bool)));
1522  mpCheckFrom->setChecked(checked);
1523  connect(mpCheckFrom, SIGNAL(toggled(bool)), this, SLOT(slotCheckFrom(bool)));
1524 
1525  enableEdit(!checked);
1526 }
CQExperimentDataValidator * mpValidatorFirst
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const unsigned C_INT32 & getFirstRow() const
const std::string & getObjectName() const
#define C_INVALID_INDEX
Definition: copasi.h:222
#define C_INT32
Definition: copasi.h:90
CQExperimentDataValidator * mpValidatorName
virtual void saved() const
Definition: CQValidator.h:71
CExperiment * mpExperiment
unsigned int mOldWeightMethod
CExperimentFileInfo * mpFileInfo
void enableEdit(const bool &enable)
#define InvalidIndex
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
virtual bool loadExperiment(CExperiment *pExperiment)
const unsigned C_INT32 & getLastRow() const
CExperiment * getExperiment(const std::string &name)
void slotCheckFrom(bool checked)
CQExperimentDataValidator * mpValidatorLast
void CQExperimentData::slotCheckHeader ( bool  checked)
protectedslot

Definition at line 375 of file CQExperimentData.cpp.

376 {
377  mpEditHeader->setEnabled(checked);
378 
379  if (!checked)
380  {
381  this->mpEditHeader->setText("");
382  }
383 }
void CQExperimentData::slotCheckNormalizeWeightsPerExperiment ( bool  flag)
protectedslot

Definition at line 1640 of file CQExperimentData.cpp.

References CExperiment::calculateWeights(), CExperiment::compile(), CLocaleString::fromUtf8(), CExperimentSet::getExperiment(), CExperiment::getFileName(), isLikePreviousExperiment(), CExperimentSet::keyToIndex(), loadTable(), mpExperiment, mpExperimentSetCopy, CExperiment::read(), saveTable(), and CExperiment::setNormalizeWeightsPerExperiment().

1641 {
1642  if (!mpExperiment) return;
1643 
1644  size_t Current =
1645  mpExperimentSetCopy->keyToIndex(mpExperiment->CCopasiParameter::getKey());
1646  size_t Next = Current + 1;
1647 
1648  // Find all experiments which are like this.
1649  while (Next < mpExperimentSetCopy->getExperimentCount() && mpCheckTo->isChecked())
1650  {
1652 
1653  if (!isLikePreviousExperiment(pNext)) break;
1654 
1655  Next++;
1656  }
1657 
1658  // Update each of them.
1659  while (true)
1660  {
1661  Next--;
1662 
1664 
1665  bool Changed = saveTable(pNext);
1666 
1667  if (Changed)
1668  {
1669  std::ifstream File;
1670  File.open(CLocaleString::fromUtf8(pNext->getFileName()).c_str());
1671 
1672  size_t CurrentLine = 1;
1673  pNext->read(File, CurrentLine);
1674  pNext->compile();
1675  }
1676 
1678  pNext->calculateWeights();
1679 
1680  if (Next == Current) break;
1681  }
1682 
1683  loadTable(mpExperiment, false);
1684 }
const std::string & getFileName() const
bool isLikePreviousExperiment(CExperiment *pExperiment)
CExperiment * getExperiment(const size_t &index)
void setNormalizeWeightsPerExperiment(bool flag)
CExperiment * mpExperiment
virtual void loadTable(CExperiment *pExperiment, const bool &guess)
size_t keyToIndex(const std::string &key) const
long int flag
Definition: f2c.h:52
bool calculateWeights()
bool compile(const std::vector< CCopasiContainer * > listOfContainer=CCopasiContainer::EmptyList)
static CLocaleString fromUtf8(const std::string &utf8)
CExperimentSet * mpExperimentSetCopy
bool saveTable(CExperiment *pExperiment)
bool read(std::istream &in, size_t &currentLine)
void CQExperimentData::slotCheckTab ( bool  checked)
protectedslot

Definition at line 359 of file CQExperimentData.cpp.

References slotSeparator().

360 {
361  mpEditSeparator->setEnabled(!checked);
362 
363  if (checked)
364  mpCheckTab->setFocus();
365  else
366  mpEditSeparator->setFocus();
367 
368  if (mpEditSeparator->isEnabled() &&
369  mpEditSeparator->text().isEmpty())
370  mpEditSeparator->setText(",");
371  else
372  slotSeparator();
373 }
void CQExperimentData::slotCheckTo ( bool  checked)
protectedslot

Definition at line 1561 of file CQExperimentData.cpp.

References C_INT32, CExperimentSet::getExperiment(), CExperiment::getWeightMethod(), CExperimentSet::keyToIndex(), mOldWeightMethod, mpExperiment, mpExperimentSetCopy, and saveExperiment().

Referenced by slotExperimentDelete().

1562 {
1563  mpCheckTo->setFocus();
1564 
1565  if (!checked || !mpExperiment) return;
1566 
1567  size_t Next =
1568  mpExperimentSetCopy->keyToIndex(mpExperiment->CCopasiParameter::getKey()) + 1;
1569 
1570  if (Next < mpExperimentSetCopy->getExperimentCount())
1571  {
1573  unsigned C_INT32 OldWeightMethod = mOldWeightMethod;
1574  mOldWeightMethod = pNext->getWeightMethod();
1576  mOldWeightMethod = OldWeightMethod;
1577  }
1578 }
CExperiment * getExperiment(const size_t &index)
const WeightMethod & getWeightMethod() const
#define C_INT32
Definition: copasi.h:90
CExperiment * mpExperiment
unsigned int mOldWeightMethod
bool saveExperiment(CExperiment *pExperiment, const bool &full)
size_t keyToIndex(const std::string &key) const
CExperimentSet * mpExperimentSetCopy
void CQExperimentData::slotExperimentAdd ( )
protectedslot

Definition at line 385 of file CQExperimentData.cpp.

References CExperimentSet::addExperiment(), C_INT32, FROM_UTF8, CCopasiRootContainer::getConfiguration(), CExperimentFileInfo::getFileName(), CExperimentFileInfo::getFirstUnusedSection(), CCopasiObject::getObjectName(), CExperiment::guessColumnNumber(), mpDataModel, mpExperimentSetCopy, mpFileInfo, mShowError, CExperiment::setFileName(), CExperiment::setFirstRow(), CExperiment::setHeaderRow(), CExperiment::setLastRow(), CExperiment::setNormalizeWeightsPerExperiment(), CExperiment::setNumColumns(), CExperimentFileInfo::sync(), and syncExperiments().

Referenced by slotFileAdd().

386 {
387  mShowError = false;
388 
389  CExperiment Experiment(mpDataModel);
390  CExperiment * pExperiment = mpExperimentSetCopy->addExperiment(Experiment);
391 
392  size_t First, Last;
393  mpFileInfo->getFirstUnusedSection(First, Last);
394  pExperiment->setFirstRow((unsigned C_INT32) First);
395  pExperiment->setLastRow((unsigned C_INT32) Last);
396  pExperiment->setHeaderRow((unsigned C_INT32) First);
397  pExperiment->setFileName(mpFileInfo->getFileName());
398 
399  pExperiment->setNormalizeWeightsPerExperiment(CCopasiRootContainer::getConfiguration()->normalizePerExperiment());
400 
401  pExperiment->setNumColumns((unsigned C_INT32) pExperiment->guessColumnNumber());
402  mpFileInfo->sync();
403 
404  mpBoxExperiment->addItem(FROM_UTF8(pExperiment->getObjectName()));
405  mpBoxExperiment->setCurrentRow(mpBoxExperiment->count() - 1);
406 
407  syncExperiments();
408  mpBtnExperimentAdd->setEnabled(mpFileInfo->getFirstUnusedSection(First, Last));
409 
410  mShowError = true;
411 }
bool getFirstUnusedSection(size_t &First, size_t &Last)
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const std::string & getObjectName() const
const std::string & getFileName() const
CCopasiDataModel * mpDataModel
bool setHeaderRow(const unsigned C_INT32 &headerRow)
bool setFileName(const std::string &fileName)
#define C_INT32
Definition: copasi.h:90
size_t guessColumnNumber() const
void setNormalizeWeightsPerExperiment(bool flag)
static CConfigurationFile * getConfiguration()
CExperiment * addExperiment(const CExperiment &experiment)
CExperimentFileInfo * mpFileInfo
bool setNumColumns(const unsigned C_INT32 &cols)
bool setFirstRow(const unsigned C_INT32 &firstRow)
CExperimentSet * mpExperimentSetCopy
bool setLastRow(const unsigned C_INT32 &lastRow)
void CQExperimentData::slotExperimentChanged ( QListWidgetItem *  pCurrentItem,
QListWidgetItem *  pPreviousItem 
)
protectedslot

Definition at line 413 of file CQExperimentData.cpp.

References CCopasiMessage::clearDeque(), CExperiment::compile(), enableEdit(), FROM_UTF8, CLocaleString::fromUtf8(), CCopasiMessage::getAllMessageText(), CExperimentFileInfo::getExperiment(), CExperiment::getFileName(), CQMessageBox::information(), loadExperiment(), mpExperiment, mpFileInfo, mShowError, mShown, CExperiment::read(), saveExperiment(), CCopasiMessage::size(), and TO_UTF8.

Referenced by slotExperimentDelete(), slotFileChanged(), and slotOK().

414 {
415  std::string Name;
416 
417  if (pCurrentItem != NULL)
418  Name = TO_UTF8(pCurrentItem->text());
419 
421 
422  bool success = true;
423 
425 
426  if (pCurrentItem != NULL)
427  {
429  mShown = mpBoxExperiment->currentRow();
430 
431  std::ifstream File;
432  File.open(CLocaleString::fromUtf8(mpExperiment->getFileName()).c_str());
433 
434  size_t CurrentLine = 1;
435  success &= mpExperiment->read(File, CurrentLine);
436 
437  if (success)
438  success &= mpExperiment->compile();
439  }
440  else
441  {
442  mpExperiment = NULL;
443  mShown = -1;
444  }
445 
447 
448  if (!success && CCopasiMessage::size() > 0 && mShowError)
449  {
451  QMessageBox::Ok, QMessageBox::Ok);
453  }
454 
455  enableEdit(!mpCheckFrom->isChecked());
456 }
const std::string & getFileName() const
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
static std::string getAllMessageText(const bool &chronological=true)
static StandardButton information(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
static void clearDeque()
CExperiment * mpExperiment
static size_t size()
bool saveExperiment(CExperiment *pExperiment, const bool &full)
CExperimentFileInfo * mpFileInfo
void enableEdit(const bool &enable)
bool compile(const std::vector< CCopasiContainer * > listOfContainer=CCopasiContainer::EmptyList)
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
virtual bool loadExperiment(CExperiment *pExperiment)
static CLocaleString fromUtf8(const std::string &utf8)
CExperiment * getExperiment(const std::string &name)
bool read(std::istream &in, size_t &currentLine)
void CQExperimentData::slotExperimentDelete ( )
protectedslot

Definition at line 458 of file CQExperimentData.cpp.

References C_INVALID_INDEX, enableEdit(), CExperimentSet::getExperiment(), CExperimentFileInfo::getExperiment(), CExperimentFileInfo::getFirstUnusedSection(), isLikePreviousExperiment(), CExperimentSet::keyToIndex(), mpExperiment, mpExperimentSetCopy, mpFileInfo, CExperimentSet::removeExperiment(), slotCheckFrom(), slotCheckTo(), slotExperimentChanged(), syncExperiments(), and TO_UTF8.

459 {
460  // Get info from current selection
461  size_t index = mpBoxExperiment->currentRow();
462 
463  if (index == C_INVALID_INDEX) return;
464 
465  std::string key =
466  mpFileInfo->getExperiment(TO_UTF8(mpBoxExperiment->item((int) index)->text()))->CCopasiParameter::getKey();
467 
468  // change selection
469  if (mpBoxExperiment->count() > 1)
470  {
471  if (mpBoxExperiment->count() > (int)index + 1)
472  mpBoxExperiment->setCurrentRow((int)(index + 1));
473  else
474  mpBoxExperiment->setCurrentRow((int)(index - 1));
475  }
476  else
477  slotExperimentChanged(NULL, NULL);
478 
479  // remove experiment
481  syncExperiments();
482 
483  size_t First, Last;
484  mpBtnExperimentAdd->setEnabled(mpFileInfo->getFirstUnusedSection(First, Last));
485 
486  // We need to correct mpCheckFrom and mpCheckTo since the removal of the experiment
487  // may have changed their status.
488  disconnect(mpCheckTo, SIGNAL(toggled(bool)), this, SLOT(slotCheckTo(bool)));
489  disconnect(mpCheckFrom, SIGNAL(toggled(bool)), this, SLOT(slotCheckFrom(bool)));
490 
491  mpCheckFrom->setChecked(isLikePreviousExperiment(mpExperiment));
492  enableEdit(!mpCheckFrom->isChecked());
493 
494  if (mpExperiment)
495  {
496  size_t Next =
497  mpExperimentSetCopy->keyToIndex(mpExperiment->CCopasiParameter::getKey()) + 1;
498 
499  if (Next < mpExperimentSetCopy->size())
500  mpCheckTo->setChecked(isLikePreviousExperiment(mpExperimentSetCopy->getExperiment(Next)));
501  else
502  mpCheckTo->setChecked(false);
503  }
504 
505  connect(mpCheckFrom, SIGNAL(toggled(bool)), this, SLOT(slotCheckFrom(bool)));
506  connect(mpCheckTo, SIGNAL(toggled(bool)), this, SLOT(slotCheckTo(bool)));
507 }
bool getFirstUnusedSection(size_t &First, size_t &Last)
bool isLikePreviousExperiment(CExperiment *pExperiment)
void slotCheckTo(bool checked)
#define C_INVALID_INDEX
Definition: copasi.h:222
CExperiment * getExperiment(const size_t &index)
CExperiment * mpExperiment
void slotExperimentChanged(QListWidgetItem *pCurrentItem, QListWidgetItem *pPreviousItem)
CExperimentFileInfo * mpFileInfo
size_t keyToIndex(const std::string &key) const
void enableEdit(const bool &enable)
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
CExperimentSet * mpExperimentSetCopy
CExperiment * getExperiment(const std::string &name)
void slotCheckFrom(bool checked)
void removeExperiment(const size_t &index)
void CQExperimentData::slotExprimentType ( bool  isSteadyState)
protectedslot

Definition at line 317 of file CQExperimentData.cpp.

References COL_TYPE_HIDDEN, CExperiment::getObjectMap(), CExperiment::ignore, loadTable(), mpExperiment, saveTable(), CExperiment::setExperimentType(), CExperimentObjectMap::setRole(), CCopasiTask::steadyState, CExperiment::time, and CCopasiTask::timeCourse.

318 {
319  if (!mpExperiment) return;
320 
321  if (isSteadyState)
322  {
323  mpBtnSteadystate->setFocus();
325  }
326  else
327  {
328  mpBtnTimeCourse->setFocus();
330  }
331 
333 
334  // Undo the changes so that copy from and to work.
335  if (isSteadyState)
336  {
338  }
339  else
340  {
342  }
343 
344  size_t i, imax = mpTable->rowCount();
345 
346  if (isSteadyState)
347  for (i = 0; i < imax; i++)
348  {
349  CExperiment::Type Type = static_cast< CExperiment::Type >(mpTable->item((int) i, COL_TYPE_HIDDEN)->data(Qt::DisplayRole).toInt());
350 
351  if (Type == CExperiment::time)
353  };
354 
355  loadTable(mpExperiment, true);
356  return;
357 }
bool setExperimentType(const CCopasiTask::Type &type)
CExperiment * mpExperiment
bool setRole(const size_t &index, const CExperiment::Type &role)
CExperimentObjectMap & getObjectMap()
virtual void loadTable(CExperiment *pExperiment, const bool &guess)
#define COL_TYPE_HIDDEN
bool saveTable(CExperiment *pExperiment)
void CQExperimentData::slotFileAdd ( )
protectedslot

Definition at line 509 of file CQExperimentData.cpp.

References CDirEntry::fileName(), FROM_UTF8, CExperimentFileInfo::getFirstUnusedSection(), CopasiFileDialog::getOpenFileName(), mFileMap, mpFileInfo, slotExperimentAdd(), StringPrint(), and TO_UTF8.

510 {
511  QString File =
513  "Open File Dialog",
514  "",
515  "Data Files (*.txt *.csv);;All Files (*)",
516  "Open Data Files");
517 
518  if (File.isNull()) return;
519 
520  std::map<std::string, std::string>::const_iterator it = mFileMap.begin();
521  std::map<std::string, std::string>::const_iterator end = mFileMap.end();
522  int i;
523 
524  for (; it != end; ++it)
525  if (it->second == TO_UTF8(File))
526  {
527  for (i = 0; i < mpBoxFile->count(); i++)
528  if (it->first == TO_UTF8(mpBoxFile->item(i)->text()))
529  {
530  mpBoxFile->setCurrentRow(i);
531  break;
532  }
533 
534  return;
535  }
536 
537  std::string FileName = CDirEntry::fileName(TO_UTF8(File));
538 
539  i = 0;
540 
541  while (mFileMap.find(FileName) != mFileMap.end())
542  FileName = StringPrint("%s_%d", CDirEntry::fileName(TO_UTF8(File)).c_str(), i++);
543 
544  mFileMap[FileName] = TO_UTF8(File);
545  mpBoxFile->addItem(FROM_UTF8(FileName));
546 
547  mpBoxFile->setCurrentRow(mpBoxFile->count() - 1);
548 
549  size_t First, Last;
550 
551  if (mpFileInfo->getFirstUnusedSection(First, Last))
552  {
553  do
554  {
556  }
557  while (mpBtnExperimentAdd->isEnabled());
558 
559  mpBoxExperiment->setCurrentRow(0);
560  }
561 }
bool getFirstUnusedSection(size_t &First, size_t &Last)
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
std::map< std::string, std::string > mFileMap
static std::string fileName(const std::string &path)
Definition: CDirEntry.cpp:119
static QString getOpenFileName(QWidget *parent=0, const char *name=0, const QString &startWith=QString::null, const QString &filter=QString::null, const QString &caption=QString::null, QString *pSelectedFilter=NULL, QFileDialog::Options options=0)
CExperimentFileInfo * mpFileInfo
std::string StringPrint(const char *format,...)
Definition: utility.cpp:87
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
void CQExperimentData::slotFileChanged ( QListWidgetItem *  pCurrentItem,
QListWidgetItem *  pPreviousItem 
)
protectedslot

Definition at line 563 of file CQExperimentData.cpp.

References FROM_UTF8, CExperimentFileInfo::getExperimentNames(), CExperimentFileInfo::getFirstUnusedSection(), mFileMap, mpFileInfo, CExperimentFileInfo::setFileName(), slotExperimentChanged(), and TO_UTF8.

Referenced by load(), and slotFileDelete().

564 {
565  if (pCurrentItem)
566  {
567  slotExperimentChanged(NULL, NULL); // Assure that changes are saved.
568  mpBoxExperiment->clear();
569 
570  if (mpFileInfo->setFileName(mFileMap[TO_UTF8(pCurrentItem->text())]))
571  {
572  // fill experiment list box
573 
574  std::vector< std::string > ExperimentNames = mpFileInfo->getExperimentNames();
575  std::vector< std::string >::const_iterator it = ExperimentNames.begin();
576  std::vector< std::string >::const_iterator end = ExperimentNames.end();
577 
578  for (; it != end; ++it)
579  mpBoxExperiment->addItem(FROM_UTF8((*it)));
580  }
581 
582  if (mpBoxExperiment->count())
583  mpBoxExperiment->setCurrentRow(0);
584  else
585  slotExperimentChanged(NULL, NULL);
586  }
587  else
588  {
589  mpBoxExperiment->clear();
590  }
591 
592  size_t First, Last;
593  mpBtnExperimentAdd->setEnabled(mpFileInfo->getFirstUnusedSection(First, Last));
594 }
bool getFirstUnusedSection(size_t &First, size_t &Last)
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
std::map< std::string, std::string > mFileMap
bool setFileName(const std::string &fileName)
void slotExperimentChanged(QListWidgetItem *pCurrentItem, QListWidgetItem *pPreviousItem)
CExperimentFileInfo * mpFileInfo
std::vector< std::string > getExperimentNames() const
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
void CQExperimentData::slotFileDelete ( )
protectedslot

Definition at line 596 of file CQExperimentData.cpp.

References C_INVALID_INDEX, CExperimentSet::getExperiment(), CExperimentSet::getExperimentCount(), CExperiment::getFileName(), mFileMap, mpExperimentSetCopy, pdelete, CExperimentSet::removeExperiment(), slotFileChanged(), and TO_UTF8.

597 {
598  // Get info from current selection
599  size_t index = mpBoxFile->currentRow();
600 
601  if (index == C_INVALID_INDEX) return;
602 
603  std::string FileName = mFileMap[TO_UTF8(mpBoxFile->item((int) index)->text())];
604 
605  // change selection
606  if (mpBoxFile->count() > 1)
607  {
608  if (mpBoxFile->count() > (int)index + 1)
609  mpBoxFile->setCurrentRow((int)(index + 1));
610  else
611  mpBoxFile->setCurrentRow((int)(index - 1));
612  }
613  else
614  slotFileChanged(NULL, NULL);
615 
616  // remove file
617  mFileMap.erase(TO_UTF8(mpBoxFile->item((int) index)->text()));
618 
619  QListWidgetItem * pItem = mpBoxFile->takeItem((int) index);
620  pdelete(pItem);
621 
622  // delete all experiments in current file.
623  size_t i = mpExperimentSetCopy->getExperimentCount() - 1;
624 
625  for (; i != C_INVALID_INDEX; i--)
626  if (mpExperimentSetCopy->getExperiment(i)->getFileName() == FileName)
628 }
const std::string & getFileName() const
#define pdelete(p)
Definition: copasi.h:215
std::map< std::string, std::string > mFileMap
void slotFileChanged(QListWidgetItem *pCurrentItem, QListWidgetItem *pPreviousItem)
#define C_INVALID_INDEX
Definition: copasi.h:222
CExperiment * getExperiment(const size_t &index)
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
CExperimentSet * mpExperimentSetCopy
size_t getExperimentCount() const
void removeExperiment(const size_t &index)
void CQExperimentData::slotFirst ( )
protectedslot

Definition at line 252 of file CQExperimentData.cpp.

References C_INVALID_INDEX.

253 {
254  qWarning("CQExperimentData::slotFirst(): Not implemented yet");
255 
256  size_t Row = C_INVALID_INDEX;
257 
258  if (mpEditFirst->text() != "")
259  Row = mpEditFirst->text().toULong();
260 
261  if (Row == C_INVALID_INDEX)
262  {
263  // Row = find first non used row in file
264  }
265 
266  // display dialog with table showing file section of First row
267 
268  // if accept
269  // set mpEditFirst
270 }
#define C_INVALID_INDEX
Definition: copasi.h:222
void CQExperimentData::slotHeader ( )
protectedslot

Definition at line 297 of file CQExperimentData.cpp.

298 {
299  qWarning("CQExperimentData::slotHeader(): Not implemented yet");
300 
301  // if header row
302  // display table showing file section of header row inexperiment
303  // if first row
304  // display table showing file section of first row inexperiment
305  // else if last row
306  // display table showing file section of last row inexperiment
307  // else
308  // display table showing file section of first non used row in file
309 
310  // if accept
311  // set mpEditHeader
312  // check mpCheckHeader
313  // else
314  // uncheck mpCheckHeader
315 }
void CQExperimentData::slotLast ( )
protectedslot

Definition at line 272 of file CQExperimentData.cpp.

References C_INVALID_INDEX.

273 {
274  size_t Row = C_INVALID_INDEX;
275 
276  if (mpEditLast->text() != "")
277  Row = mpEditLast->text().toULong();
278 
279  if (Row == C_INVALID_INDEX && mpEditFirst->text() != "")
280  Row = mpEditFirst->text().toULong();
281 
282  // display dialog with table showing file section of First row
283 
284  // if accept
285  // set mpEditFirst
286  // if last row
287  // display table showing file section of last row inexperiment
288  // else if first
289  // display table showing file section of first row in file
290  // else
291  // display table showing file section of last non used row in file
292 
293  // if accept
294  // set mpEditLast
295 }
#define C_INVALID_INDEX
Definition: copasi.h:222
void CQExperimentData::slotModelObject ( const QModelIndex &  index)
protectedslot

Definition at line 1083 of file CQExperimentData.cpp.

References selectModelObject().

Referenced by init().

1084 {
1085  selectModelObject(index.row());
1086 }
void selectModelObject(const int &row)
void CQExperimentData::slotModelObjectDelayed ( )
protectedslot

Definition at line 1114 of file CQExperimentData.cpp.

References mModelObjectRow, and selectModelObject().

Referenced by slotTypeChanged().

1115 {
1116  if (mModelObjectRow != -1)
1117  {
1119  }
1120 
1121  mModelObjectRow = -1;
1122 }
void selectModelObject(const int &row)
void CQExperimentData::slotOK ( )
protectedslot

Definition at line 635 of file CQExperimentData.cpp.

References CExperimentSet::addExperiment(), C_INVALID_INDEX, experimentChanged(), CKeyFactory::get(), CExperimentSet::getExperiment(), CExperimentSet::getExperimentCount(), CCopasiRootContainer::getKeyFactory(), CCopasiObject::getObjectName(), CCrossValidationSet::getThreshold(), CCrossValidationSet::getWeight(), mCrossValidation, mKeyMap, mpExperimentSet, mpExperimentSetCopy, pdelete, CExperimentSet::removeExperiment(), CCopasiParameterGroup::removeParameter(), CCrossValidationSet::setThreshold(), CCrossValidationSet::setWeight(), and slotExperimentChanged().

636 {
637  mpBtnOK->setFocus();
638 
639  // Force the save all current changes.
640  slotExperimentChanged(NULL, NULL);
641 
642  CExperiment * pExperiment;
643 
644  size_t i = mpExperimentSet->getExperimentCount() - 1;
645 
646  for (; i != C_INVALID_INDEX; i--)
647  {
648  pExperiment =
649  dynamic_cast<CExperiment *>(CCopasiRootContainer::getKeyFactory()->get(mKeyMap[mpExperimentSet->getExperiment(i)->CCopasiParameter::getKey()]));
650 
651  if (pExperiment)
652  {
653  *mpExperimentSet->getExperiment(i) = *pExperiment;
655  }
656  else
658  }
659 
660  emit experimentChanged();
661 
662  for (i = 0; i < mpExperimentSetCopy->getExperimentCount(); i++)
664 
665  if (mCrossValidation)
666  {
667  CCrossValidationSet * pSet = static_cast< CCrossValidationSet * >(mpExperimentSet);
668 
669  if (QString::number(pSet->getWeight()) != mpEditWeight->text())
670  {
671  pSet->setWeight(mpEditWeight->text().toDouble());
672  }
673 
674  if (QString::number(pSet->getThreshold()) != mpEditThreshold->text())
675  {
676  pSet->setThreshold(mpEditThreshold->text().toUInt());
677  }
678  }
679 
681  accept();
682 }
#define pdelete(p)
Definition: copasi.h:215
const std::string & getObjectName() const
CCopasiObject * get(const std::string &key)
#define C_INVALID_INDEX
Definition: copasi.h:222
CExperiment * getExperiment(const size_t &index)
std::map< std::string, std::string > mKeyMap
bool removeParameter(const std::string &name)
const C_FLOAT64 & getWeight() const
CExperiment * addExperiment(const CExperiment &experiment)
void setWeight(const C_FLOAT64 &weight)
void slotExperimentChanged(QListWidgetItem *pCurrentItem, QListWidgetItem *pPreviousItem)
static CKeyFactory * getKeyFactory()
void setThreshold(const unsigned C_INT32 &threshold)
const unsigned C_INT32 & getThreshold() const
CExperimentSet * mpExperimentSet
CExperimentSet * mpExperimentSetCopy
size_t getExperimentCount() const
void experimentChanged()
void removeExperiment(const size_t &index)
void CQExperimentData::slotRevert ( )
protectedslot

Definition at line 247 of file CQExperimentData.cpp.

References load(), mpDataModel, and mpExperimentSet.

248 {
250 }
CCopasiDataModel * mpDataModel
virtual bool load(CExperimentSet *pExperimentSet, CCopasiDataModel *pDataModel)
CExperimentSet * mpExperimentSet
void CQExperimentData::slotSeparator ( )
protectedslot

Definition at line 1419 of file CQExperimentData.cpp.

References C_INT32, CExperiment::guessColumnNumber(), loadTable(), mpExperiment, CExperiment::readColumnNames(), CExperiment::setNumColumns(), CExperiment::setSeparator(), and TO_UTF8.

Referenced by slotCheckTab().

1420 {
1421  if (!mpExperiment) return;
1422 
1423  // saveTable(mpExperiment);
1424 
1425  if (mpCheckTab->isChecked())
1426  mpExperiment->setSeparator("\t");
1427  else
1428  mpExperiment->setSeparator(TO_UTF8(mpEditSeparator->text()));
1429 
1432 
1433  loadTable(mpExperiment, true);
1434 }
#define C_INT32
Definition: copasi.h:90
size_t guessColumnNumber() const
CExperiment * mpExperiment
bool setSeparator(const std::string &seperator)
virtual void loadTable(CExperiment *pExperiment, const bool &guess)
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
bool setNumColumns(const unsigned C_INT32 &cols)
bool readColumnNames()
void CQExperimentData::slotTypeChanged ( int  row,
int  index 
)
protectedslot

Definition at line 1277 of file CQExperimentData.cpp.

References COL_BTN, COL_OBJECT_HIDDEN, COL_TYPE, COL_TYPE_HIDDEN, CExperiment::dependent, CQSimpleSelectionTree::filter(), FROM_UTF8, CCopasiRootContainer::getDatamodelList(), CCopasiDataModel::getDataObject(), CExperiment::ignore, CExperiment::independent, CQSimpleSelectionTree::InitialTime, mModelObjectRow, CQSimpleSelectionTree::ObservedValues, CQSimpleSelectionTree::Parameters, setTypeItems(), slotModelObjectDelayed(), CExperiment::time, TO_UTF8, CExperiment::TypeName, updateScales(), and CQSimpleSelectionTree::Variables.

Referenced by init().

1278 {
1279  CExperiment::Type NewType = static_cast<CExperiment::Type>(index);
1280  CExperiment::Type OldType = static_cast<CExperiment::Type>(mpTable->item(row, COL_TYPE_HIDDEN)->data(Qt::DisplayRole).toInt());
1281 
1282  if (OldType == NewType) return;
1283 
1284  bool BtnEnabled = true;
1285  //C_INT32 i, imax = mpTable->rowCount();
1286 
1287  mpTable->item(row, COL_TYPE)->setText(QString(FROM_UTF8(CExperiment::TypeName[NewType])));
1288  mpTable->item(row, COL_TYPE_HIDDEN)->setText(QString::number(NewType));
1289 
1290  CCopasiObjectName CN = CCopasiObjectName(TO_UTF8(mpTable->item(row, COL_OBJECT_HIDDEN)->text()));
1291  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
1293  assert(pDataModel != NULL);
1294 
1295  switch (NewType)
1296  {
1297  case CExperiment::ignore:
1298  BtnEnabled = false;
1299  break;
1300 
1302 
1305  pDataModel->getDataObject(CN)))
1306  {
1307  mModelObjectRow = row;
1308  // slotModelObject(row);
1309  QTimer::singleShot(10, this, SLOT(slotModelObjectDelayed()));
1310  }
1311 
1312  BtnEnabled = true;
1313  break;
1314 
1316 
1319  pDataModel->getDataObject(CN)))
1320  {
1321  mModelObjectRow = row;
1322  // slotModelObject(row);
1323  QTimer::singleShot(10, this, SLOT(slotModelObjectDelayed()));
1324  }
1325 
1326  BtnEnabled = true;
1327  break;
1328 
1329  case CExperiment::time:
1330  BtnEnabled = false;
1331  setTypeItems(row);
1332 
1333  break;
1334  }
1335 
1336  QTableWidgetItem * pItem = mpTable->item(row, COL_BTN);
1337 
1338  if (BtnEnabled)
1339  {
1340  pItem->setFlags(pItem->flags() | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1341  mpTable->openPersistentEditor(pItem);
1342  }
1343  else
1344  {
1345  pItem->setFlags(pItem->flags() & ~Qt::ItemIsEditable & ~Qt::ItemIsEnabled);
1346  mpTable->closePersistentEditor(pItem);
1347  }
1348 
1349  switch (OldType)
1350  {
1351  case CExperiment::ignore:
1354  break;
1355 
1356  case CExperiment::time:
1357  setTypeItems(-1);
1358  break;
1359  }
1360 
1361  // The default weights need to be recalculated and the table updated if the type change
1362  // involves dependent values.
1363  if (OldType == CExperiment::dependent ||
1364  NewType == CExperiment::dependent)
1365  {
1366  updateScales();
1367  }
1368 
1369  return;
1370 }
CCopasiObject * getDataObject(const CCopasiObjectName &CN) const
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
#define COL_BTN
#define COL_OBJECT_HIDDEN
static bool filter(const ObjectClasses &classes, const CCopasiObject *pObject)
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
#define COL_TYPE_HIDDEN
void setTypeItems(const int &timeRow)
#define COL_TYPE
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
static const std::string TypeName[]
Definition: CExperiment.h:79
void CQExperimentData::slotUpdateTable ( )
protectedslot

Definition at line 1080 of file CQExperimentData.cpp.

References loadTable(), and mpExperiment.

1081 {loadTable(mpExperiment, true);}
CExperiment * mpExperiment
virtual void loadTable(CExperiment *pExperiment, const bool &guess)
void CQExperimentData::slotWeightMethod ( int  weightMethod)
privateslot

Definition at line 1686 of file CQExperimentData.cpp.

References CExperiment::calculateWeights(), COL_SCALE, CExperiment::compile(), CLocaleString::fromUtf8(), CExperimentSet::getExperiment(), CExperiment::getFileName(), CExperiment::getWeightMethod(), isLikePreviousExperiment(), CExperimentSet::keyToIndex(), loadTable(), mpExperiment, mpExperimentSetCopy, CExperiment::read(), saveTable(), CExperiment::setWeightMethod(), and CExperiment::VALUE_SCALING.

1687 {
1688  if (mpExperiment == NULL) return;
1689 
1690  if ((CExperiment::WeightMethod) weightMethod ==
1691  mpExperiment->getWeightMethod()) return;
1692 
1693  switch ((CExperiment::WeightMethod) weightMethod)
1694  {
1696  mpTable->horizontalHeaderItem(COL_SCALE)->setText("Epsilon");
1697  break;
1698 
1699  default:
1700  mpTable->horizontalHeaderItem(COL_SCALE)->setText("Weight");
1701  break;
1702  }
1703 
1704  size_t Current =
1705  mpExperimentSetCopy->keyToIndex(mpExperiment->CCopasiParameter::getKey());
1706  size_t Next = Current + 1;
1707 
1708  // Find all experiments which are like this.
1709  while (Next < mpExperimentSetCopy->getExperimentCount() && mpCheckTo->isChecked())
1710  {
1712 
1713  if (!isLikePreviousExperiment(pNext)) break;
1714 
1715  Next++;
1716  }
1717 
1718  // Update each of them.
1719  while (true)
1720  {
1721  Next--;
1722 
1724 
1725  bool Changed = saveTable(pNext);
1726 
1727  if (Changed)
1728  {
1729  std::ifstream File;
1730  File.open(CLocaleString::fromUtf8(pNext->getFileName()).c_str());
1731 
1732  size_t CurrentLine = 1;
1733  pNext->read(File, CurrentLine);
1734  pNext->compile();
1735  }
1736 
1737  pNext->setWeightMethod((CExperiment::WeightMethod) weightMethod);
1738  pNext->calculateWeights();
1739 
1740  if (Next == Current) break;
1741  }
1742 
1743  loadTable(mpExperiment, false);
1744 }
const std::string & getFileName() const
bool isLikePreviousExperiment(CExperiment *pExperiment)
CExperiment * getExperiment(const size_t &index)
const WeightMethod & getWeightMethod() const
#define COL_SCALE
CExperiment * mpExperiment
virtual void loadTable(CExperiment *pExperiment, const bool &guess)
size_t keyToIndex(const std::string &key) const
bool calculateWeights()
bool compile(const std::vector< CCopasiContainer * > listOfContainer=CCopasiContainer::EmptyList)
static CLocaleString fromUtf8(const std::string &utf8)
CExperimentSet * mpExperimentSetCopy
bool saveTable(CExperiment *pExperiment)
bool setWeightMethod(const WeightMethod &weightMethod)
bool read(std::istream &in, size_t &currentLine)
void CQExperimentData::syncExperiments ( )
protected

Definition at line 1044 of file CQExperimentData.cpp.

References FROM_UTF8, CExperimentFileInfo::getExperimentNames(), mpFileInfo, mShown, CExperimentFileInfo::sync(), and TO_UTF8.

Referenced by slotExperimentAdd(), slotExperimentDelete(), and CQExperimentDataValidator::validate().

1045 {
1046  std::string Current = TO_UTF8(mpBoxExperiment->currentItem()->text());
1047  std::string Shown;
1048 
1049  if (mShown != -1)
1050  Shown = TO_UTF8(mpBoxExperiment->item(mShown)->text());
1051 
1052  mpFileInfo->sync();
1053 
1054  mpBoxExperiment->blockSignals(true);
1055  mpBoxExperiment->clear();
1056 
1057  std::vector< std::string > ExperimentNames = mpFileInfo->getExperimentNames();
1058  std::vector< std::string >::const_iterator it = ExperimentNames.begin();
1059  std::vector< std::string >::const_iterator end = ExperimentNames.end();
1060 
1061  int i;
1062 
1063  for (i = 0; it != end; ++it, i++)
1064  {
1065  mpBoxExperiment->addItem(FROM_UTF8((*it)));
1066 
1067  if (*it == Current)
1068  {
1069  mpBoxExperiment->setCurrentRow(mpBoxExperiment->count() - 1);
1070  }
1071 
1072  if (*it == Shown) mShown = i;
1073  }
1074 
1075  mpBoxExperiment->blockSignals(false);
1076 
1077  return;
1078 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
CExperimentFileInfo * mpFileInfo
std::vector< std::string > getExperimentNames() const
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
void CQExperimentData::updateScales ( )
private

Definition at line 1372 of file CQExperimentData.cpp.

References C_FLOAT64, C_INT32, COL_SCALE, CExperiment::compile(), CExperiment::dependent, CLocaleString::fromUtf8(), CExperimentObjectMap::getDefaultScale(), CExperiment::getFileName(), CExperiment::getObjectMap(), CExperimentObjectMap::getRole(), mpExperiment, CExperiment::read(), and saveExperiment().

Referenced by selectModelObject(), and slotTypeChanged().

1373 {
1375 
1376  // Since the interpretation of the data has changed we need read the file again
1377  std::ifstream File;
1378  File.open(CLocaleString::fromUtf8(mpExperiment->getFileName()).c_str());
1379 
1380  size_t CurrentLine = 1;
1381  mpExperiment->read(File, CurrentLine);
1382  mpExperiment->compile();
1383 
1384  // We can not simply use loadTable as this would destroy the two signal maps
1385  // for the buttons and comboboxes leading to crashes in Qt.
1387 
1388  C_INT32 i, imax = mpTable->rowCount();
1389 
1390  for (i = 0; i < imax; i++)
1391  {
1392  QTableWidgetItem * pItem = mpTable->item(i, COL_SCALE);
1393 
1394  // COL_SCALE
1395  if (ObjectMap.getRole(i) != CExperiment::dependent)
1396  {
1397  pItem->setText("");
1398  pItem->setFlags(pItem->flags() & ~Qt::ItemIsEditable);
1399  }
1400  else
1401  {
1402  QString ScaleText = pItem->text();
1403 
1404  // Keep non default values
1405  if (ScaleText == "" || ScaleText[0] == '(')
1406  {
1407 
1408  C_FLOAT64 DefaultWeight = ObjectMap.getDefaultScale(i);
1409 
1410  ScaleText = "(" + QString::number(DefaultWeight) + ")";
1411  pItem->setText(ScaleText);
1412  }
1413 
1414  pItem->setFlags(pItem->flags() | Qt::ItemIsEditable);
1415  }
1416  }
1417 }
const std::string & getFileName() const
CExperiment::Type getRole(const size_t &index) const
C_FLOAT64 getDefaultScale(const size_t &index) const
#define C_INT32
Definition: copasi.h:90
#define COL_SCALE
CExperiment * mpExperiment
bool saveExperiment(CExperiment *pExperiment, const bool &full)
CExperimentObjectMap & getObjectMap()
#define C_FLOAT64
Definition: copasi.h:92
bool compile(const std::vector< CCopasiContainer * > listOfContainer=CCopasiContainer::EmptyList)
static CLocaleString fromUtf8(const std::string &utf8)
bool read(std::istream &in, size_t &currentLine)

Friends And Related Function Documentation

friend class CQExperimentDataValidator
friend

Definition at line 39 of file CQExperimentData.h.

Referenced by init().

Member Data Documentation

bool CQExperimentData::mCrossValidation
protected

Definition at line 62 of file CQExperimentData.h.

Referenced by init(), load(), and slotOK().

std::map<std::string, std::string> CQExperimentData::mFileMap
protected

Definition at line 58 of file CQExperimentData.h.

Referenced by load(), slotFileAdd(), slotFileChanged(), and slotFileDelete().

std::map<std::string, std::string> CQExperimentData::mKeyMap
protected

Definition at line 57 of file CQExperimentData.h.

Referenced by load(), and slotOK().

int CQExperimentData::mModelObjectRow
protected

Definition at line 68 of file CQExperimentData.h.

Referenced by slotModelObjectDelayed(), and slotTypeChanged().

unsigned int CQExperimentData::mOldWeightMethod
protected
CQComboDelegate* CQExperimentData::mpComboDelegate
protected

Definition at line 65 of file CQExperimentData.h.

Referenced by init(), and setTypeItems().

CCopasiDataModel* CQExperimentData::mpDataModel
protected

Definition at line 64 of file CQExperimentData.h.

Referenced by init(), load(), slotExperimentAdd(), and slotRevert().

CExperiment* CQExperimentData::mpExperiment
protected
CExperimentSet* CQExperimentData::mpExperimentSet
protected

Definition at line 55 of file CQExperimentData.h.

Referenced by load(), slotOK(), and slotRevert().

CExperimentSet* CQExperimentData::mpExperimentSetCopy
protected
CExperimentFileInfo* CQExperimentData::mpFileInfo
protected
CQExperimentDataValidator* CQExperimentData::mpValidatorFirst
protected

Definition at line 59 of file CQExperimentData.h.

Referenced by init(), loadExperiment(), saveExperiment(), and slotCheckFrom().

CQExperimentDataValidator* CQExperimentData::mpValidatorHeader
protected

Definition at line 51 of file CQExperimentData.h.

Referenced by init(), loadExperiment(), and saveExperiment().

CQExperimentDataValidator* CQExperimentData::mpValidatorLast
protected
CQExperimentDataValidator* CQExperimentData::mpValidatorName
protected

Definition at line 61 of file CQExperimentData.h.

Referenced by init(), loadExperiment(), saveExperiment(), and slotCheckFrom().

bool CQExperimentData::mShowError
protected

Definition at line 63 of file CQExperimentData.h.

Referenced by init(), slotExperimentAdd(), and slotExperimentChanged().

int CQExperimentData::mShown
protected
QStringList CQExperimentData::mTypeItems
protected

Definition at line 66 of file CQExperimentData.h.

Referenced by init(), and setTypeItems().

QStringList CQExperimentData::mTypeWithoutTimeItems
protected

Definition at line 67 of file CQExperimentData.h.

Referenced by init(), and setTypeItems().


The documentation for this class was generated from the following files: