COPASI API  4.16.103
Macros | Functions
CQLayoutView.cpp File Reference
#include <QtGui/QApplication>
#include <QtGui/QWheelEvent>
#include <QtGui/QAction>
#include <QtGui/QMenu>
#include <QtGui/QToolBar>
#include <QtCore/QFileInfo>
#include <QtGui/QHBoxLayout>
#include <QtGui/QLabel>
#include <QtGui/QComboBox>
#include <qlayout/CQLayoutScene.h>
#include <qlayout/CQLayoutView.h>
#include <copasi.h>
#include <layout/CLayout.h>
#include <layout/CListOfLayouts.h>
#include <layout/CLDefaultStyles.h>
#include <CopasiDataModel/CCopasiDataModel.h>
#include <resourcesUI/CQIconResource.h>
Include dependency graph for CQLayoutView.cpp:

Go to the source code of this file.

Macros

#define RENDERINFORMATION_TYPE_DEFAULT   2
 
#define RENDERINFORMATION_TYPE_GLOBAL   0
 
#define RENDERINFORMATION_TYPE_LOCAL   1
 

Functions

void updateLayoutList (QComboBox *list, CCopasiDataModel *dataModel)
 
CLRenderInformationBaseupdateRenderInformationList (QComboBox *list, CCopasiDataModel *dataModel, CLayout *layout)
 

Macro Definition Documentation

#define RENDERINFORMATION_TYPE_DEFAULT   2

Definition at line 48 of file CQLayoutView.cpp.

Referenced by updateRenderInformationList().

#define RENDERINFORMATION_TYPE_GLOBAL   0

Definition at line 46 of file CQLayoutView.cpp.

Referenced by updateRenderInformationList().

#define RENDERINFORMATION_TYPE_LOCAL   1

Definition at line 47 of file CQLayoutView.cpp.

Referenced by updateRenderInformationList().

Function Documentation

void updateLayoutList ( QComboBox *  list,
CCopasiDataModel dataModel 
)

Definition at line 30 of file CQLayoutView.cpp.

References CCopasiVector< T >::begin(), CCopasiVector< T >::end(), CCopasiDataModel::getListOfLayouts(), and CCopasiObject::getObjectName().

Referenced by CQLayoutView::setDataModel().

31 {
32  if (list == NULL || dataModel == NULL) return;
33 
34  list->clear();
35  CCopasiVector<CLayout> & layouts = *dataModel->getListOfLayouts();
37 
38  while (it != layouts.end())
39  {
40  const CLayout* layout = *it;
41  list->addItem(layout->getObjectName().c_str());
42  ++it;
43  }
44 }
const std::string & getObjectName() const
iterator begin()
iterator end()
CListOfLayouts * getListOfLayouts()
CLRenderInformationBase* updateRenderInformationList ( QComboBox *  list,
CCopasiDataModel dataModel,
CLayout layout 
)

Definition at line 50 of file CQLayoutView.cpp.

References CCopasiVector< T >::begin(), CCopasiVector< T >::end(), getDefaultStyle(), CLRenderInformationBase::getKey(), CListOfLayouts::getListOfGlobalRenderInformationObjects(), CCopasiDataModel::getListOfLayouts(), CLayout::getListOfLocalRenderInformationObjects(), CLRenderInformationBase::getName(), getNumDefaultStyles(), RENDERINFORMATION_TYPE_DEFAULT, RENDERINFORMATION_TYPE_GLOBAL, RENDERINFORMATION_TYPE_LOCAL, and CCopasiVector< T >::size().

Referenced by CQLayoutView::setDataModel(), and CQLayoutView::slotLayoutChanged().

51 {
52 
53  if (list == NULL || dataModel == NULL) return NULL;
54 
55  bool skipGlobal = list->count() > 0;
56  CLRenderInformationBase* result = NULL;
57 
58  // remove oldItems
59  if (skipGlobal)
60  {
61  for (size_t i = list->count(); i > 0; --i)
62  {
63  QString current = list->itemText(i - 1);
64  int type = list->itemData(i - 1).toInt();
65 
66  if (type == RENDERINFORMATION_TYPE_LOCAL)
67  list->removeItem(i - 1);
68  }
69  }
70 
71  // add local information
72  if (layout != NULL)
73  {
76 
77  while (it != render.end())
78  {
79  CLLocalRenderInformation* current = *it;
80 
81  if (result == NULL) result = current;
82 
83  if (current->getName().empty())
84  list->insertItem(0, current->getKey().c_str(), QVariant::fromValue(RENDERINFORMATION_TYPE_LOCAL));
85  else
86  list->insertItem(0, current->getName().c_str(), QVariant::fromValue(RENDERINFORMATION_TYPE_LOCAL));
87 
88  ++it;
89  }
90  }
91 
92  // bail
93  if (skipGlobal)
94  {
95  if (result == NULL && dataModel->getListOfLayouts()->getListOfGlobalRenderInformationObjects().size() > 0)
97 
98  if (result == NULL && getNumDefaultStyles() > 0)
99  result = getDefaultStyle(0);
100 
101  return result;
102  }
103 
104  // add global ones
105  {
108 
109  while (it != render.end())
110  {
111  CLGlobalRenderInformation* current = *it;
112 
113  if (result == NULL) result = current;
114 
115  if (current->getName().empty())
116  list->addItem(current->getKey().c_str(), QVariant::fromValue(RENDERINFORMATION_TYPE_GLOBAL));
117  else
118  list->addItem(current->getName().c_str(), QVariant::fromValue(RENDERINFORMATION_TYPE_GLOBAL));
119 
120  ++it;
121  }
122 
123  // add default ones
124  {
125  size_t i, iMax = getNumDefaultStyles();
126  CLRenderInformationBase* current = NULL;
127 
128  for (i = 0; i < iMax; ++i)
129  {
130  current = getDefaultStyle(i);
131 
132  if (result == NULL) result = current;
133 
134  std::string text = current->getKey();
135 
136  if (!current->getName().empty())
137  {
138  text = current->getName();
139  }
140 
141  list->addItem(text.c_str(), QVariant::fromValue(RENDERINFORMATION_TYPE_DEFAULT));
142  }
143  }
144  }
145 
146  return result;
147 }
#define RENDERINFORMATION_TYPE_DEFAULT
const CCopasiVector< CLLocalRenderInformation > & getListOfLocalRenderInformationObjects() const
Definition: CLayout.h:149
virtual size_t size() const
iterator begin()
CLGlobalRenderInformation * getDefaultStyle(size_t index)
iterator end()
size_t getNumDefaultStyles()
CListOfLayouts * getListOfLayouts()
#define RENDERINFORMATION_TYPE_GLOBAL
const std::string & getKey() const
const std::string & getName() const
#define RENDERINFORMATION_TYPE_LOCAL
const CCopasiVector< CLGlobalRenderInformation > & getListOfGlobalRenderInformationObjects() const