COPASI API  4.16.103
ObjectBrowserWidget.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2004 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 /********************************************************
16 Author: Liang Xu
17 Version : 1.xx <first>
18 Description:
19 Date: 04/03
20 Comment : COPASI Object Browser:
21 Contact: Please contact lixu1@vt.edu.
22  *********************************************************/
23 
24 #include <QtGui/QHeaderView>
25 #include <QtGui/QTreeWidget>
26 #include <QtGui/QTextEdit>
27 #include <QtGui/QPushButton>
28 #include <QtGui/QPixmap>
29 #include <QtGui/QGridLayout>
30 #include <QtGui/QHBoxLayout>
31 #include <QtGui/QVBoxLayout>
32 #include <QtGui/QFrame>
33 
34 #include "copasi.h"
35 
36 #include "ObjectBrowserWidget.h"
37 #include "ObjectBrowserItem.h"
38 #include "copasiui3window.h"
39 #include "qtUtilities.h"
40 #include "report/CCopasiObject.h"
46 
47 #include "./icons/objectAll.xpm"
48 #include "./icons/objectParts.xpm"
49 #include "./icons/objectNone.xpm"
50 
51 QPixmap *pObjectAll = 0;
52 QPixmap *pObjectParts = 0;
53 QPixmap *pObjectNone = 0;
54 
55 /*
56  * Constructs a ObjectBrowser which is a child of 'parent', with the
57  * name 'name' and widget flags set to 'f'.
58  */
59 ObjectBrowserWidget::ObjectBrowserWidget(QWidget* parent, const char* name, Qt::WFlags fl, int state)
60  : QWidget(parent, fl),
61  objectItemList(NULL),
62  refreshList(NULL),
63  ObjectBrowserLayout(NULL),
64  clearButton(NULL),
65  toggleViewButton(NULL),
66  commitButton(NULL),
67  ObjectListView(NULL),
68  Line1(NULL),
69  spacer(NULL),
70  ObjectItemText(NULL),
71  mOutputObjectVector(NULL),
72  currentPage(LISTVIEWPAGE)
73 {
74  setObjectName(QString::fromUtf8(name));
75 
76  if (!name)
77  setObjectName("ObjectBrowser");
78 
79  if (state == 0)
80  ObjectBrowserLayout = new QGridLayout(this);
81  else
82  {
83  ObjectBrowserLayout = new QGridLayout(this);
84  ObjectBrowserLayout->setSpacing(6);
85  }
86 
87  ObjectBrowserLayout->setObjectName(QString::fromUtf8("ObjectListView"));
88 
89  ObjectListView = new QTreeWidget(this);
90  ObjectListView->setObjectName("");
91  // ObjectListView->addColumn(trUtf8("Object Browser"));
92  QStringList strList;
93  strList << trUtf8("Name") << trUtf8("Type");
94  ObjectListView->setHeaderLabels(strList);
95  //ObjectListView->header()->setClickEnabled(false, ObjectListView->header()->count() - 1);
96  ObjectListView->setAcceptDrops(false);
97  ObjectListView->setSortingEnabled(true);
98  ObjectListView->sortByColumn(0, Qt::AscendingOrder);
99  ObjectListView->header()->setResizeMode(QHeaderView::ResizeToContents);
100  ObjectListView->setSelectionMode(QAbstractItemView::NoSelection);
101 
102  ObjectItemText = new QTextEdit(this);
103  ObjectItemText->setObjectName("ObjectItemText");
104  ObjectItemText ->hide();
105 
106  ObjectBrowserLayout->addWidget(ObjectListView, 0, 0, 0, 3);
107  ObjectBrowserLayout->addWidget(ObjectItemText, 0, 0, 0, 3);
108 
109  if (state != 0)
110  {
111  Line1 = new QFrame(this);
112  Line1->setObjectName("Line1");
113  Line1->setFrameShape(QFrame::HLine);
114  Line1->setFrameShadow(QFrame::Sunken);
115  Line1->setFrameShape(QFrame::HLine);
116 
117  ObjectBrowserLayout->addWidget(Line1, 1, 1, 0, 3);
118 
119  clearButton = new QPushButton(this);
120  clearButton->setObjectName("clearButton");
121  clearButton->setText(trUtf8("Clear"));
122  ObjectBrowserLayout->addWidget(clearButton, 2, 0);
123 
124  commitButton = new QPushButton(this);
125  commitButton->setObjectName("commitButton");
126  commitButton->setText(trUtf8("Commit"));
127  ObjectBrowserLayout->addWidget(commitButton, 2, 3);
128 
129  toggleViewButton = new QPushButton(this);
130  toggleViewButton->setObjectName("toggleViewButton");
131  toggleViewButton->setText(trUtf8("Selected Items"));
132  ObjectBrowserLayout->addWidget(toggleViewButton, 2, 2);
133 
134  spacer = new QSpacerItem(131, 31, QSizePolicy::Expanding, QSizePolicy::Minimum);
135  ObjectBrowserLayout->addItem(spacer, 2, 1);
136 
137  // signals and slots connections
138  connect(clearButton, SIGNAL(clicked()), this, SLOT(clearClicked()));
139  connect(toggleViewButton, SIGNAL(clicked()), this, SLOT(toggleViewClicked()));
140  connect(commitButton, SIGNAL(clicked()), this, SLOT(commitClicked()));
141 
142  // tab order
143  setTabOrder(ObjectListView, clearButton);
144  setTabOrder(clearButton, toggleViewButton);
145  setTabOrder(toggleViewButton, commitButton);
146  }
147 
148  connect(ObjectListView, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(listviewChecked(QTreeWidgetItem*, int)));
149 
150  pObjectAll = new QPixmap((const char**)ptrObjectAll);
151  pObjectNone = new QPixmap((const char**)ptrObjectNone);
152  pObjectParts = new QPixmap((const char**)ptrObjectParts);
153 
154  objectItemList = new ObjectList();
155  refreshList = new ObjectList();
157  loadData();
159 }
160 
162 {
163  cleanup();
164 }
165 
167 {
168  delete objectItemList;
169  delete refreshList;
170 }
171 
173 {
174  if (!refreshList->getRoot()) return;
175 
176  ObjectBrowserItem* root = static_cast< ObjectBrowserItem * >(refreshList->getRoot()->pItem);
177  setUncheck(root);
178  updateUI();
179  // qWarning("ObjectBrowser::clearClicked(): Not implemented yet!");
180 }
181 
182 void ObjectBrowserWidget::listviewChecked(QTreeWidgetItem* pCurrent, int C_UNUSED(column))
183 {
184  // if ((pCurrent == NULL)||((static_cast< ObjectBrowserItem * >(pCurrent))->getType() == FIELDATTR))
185  if ((pCurrent == NULL) || (pCurrent->text(0) == "Select by attribute"))
186  return;
187 
188  clickToReverseCheck(static_cast< ObjectBrowserItem * >(pCurrent));
189  updateUI();
190  //loadUI();
191 }
192 
194 {
195  refreshList->insert(pCurrent);
196 
197  ObjectBrowserItem* pTmp = pCurrent;
198 
199  while (pTmp->parent() != NULL)
200  {
201  pTmp = static_cast< ObjectBrowserItem * >(pTmp->parent());
202  refreshList->insert(pTmp);
203  }
204 
205  if (pCurrent->isChecked() == ALLCHECKED)
206  {
207  if (pCurrent->isChecked())
208  pCurrent->reverseChecked();
209 
210  setUncheck(static_cast< ObjectBrowserItem * >(pCurrent->child(0)));
211  return;
212  }
213 
214  //else no check or partly checked
215  if (!pCurrent->isChecked())
216  pCurrent->reverseChecked();
217 
218  setCheck(static_cast< ObjectBrowserItem * >(pCurrent->child(0)));
219  return;
220 }
221 
223 {
224  if (pCurrent == NULL)
225  return;
226 
227  refreshList->insert(pCurrent);
228 
229  if (pCurrent->isChecked())
230  pCurrent->reverseChecked();
231 
232  if (pCurrent->child(0) != NULL)
233  setUncheck(static_cast< ObjectBrowserItem * >(pCurrent->child(0)));
234 
235  if (pCurrent->nextSibling() != NULL)
236  setUncheck(static_cast< ObjectBrowserItem * >(pCurrent->nextSibling()));
237 }
238 
240 {
241  if (pCurrent == NULL)
242  return;
243 
244  refreshList->insert(pCurrent);
245 
246  if (!pCurrent->isChecked())
247  pCurrent->reverseChecked();
248 
249  if (pCurrent->child(0) != NULL)
250  setCheck(static_cast< ObjectBrowserItem * >(pCurrent->child(0)));
251 
252  if (pCurrent->nextSibling() != NULL)
253  setCheck(static_cast< ObjectBrowserItem * >(pCurrent->nextSibling()));
254 }
255 
257 {
258  switch (currentPage)
259  {
260  case LISTVIEWPAGE:
263 
264  if (toggleViewButton) toggleViewButton->setText(trUtf8("Tree View"));
265 
266  ObjectListView->hide();
267  ObjectItemText->show();
268  break;
269  case SELECTEDITEMPAGE:
271 
272  if (toggleViewButton) toggleViewButton->setText(trUtf8("Selected Items"));
273 
274  ObjectListView->show();
275  ObjectItemText->hide();
276  break;
277  }
278 }
279 
281 {
282  std::vector< const CCopasiObject * > * outputVector;
283  ObjectBrowserItem* rootItem;
284  unsigned C_INT32 i;
285  rootItem = objectItemList->getRoot()->pItem;
286  outputVector = new std::vector< const CCopasiObject * >();
287  eXport(rootItem, outputVector);
288  // CQMessageBox::information(this, "Output object list done!", "Selected CopasiObject list done!");
289  // ObjectListItem* pHead;
290  ObjectItemText->clear();
291 
292  for (i = 0; i < outputVector->size(); i++)
293  {
294  // if (double(i) / 2 == int(i / 2))
295  // ObjectItemText->setColor(red);
296  // else
297  // ObjectItemText->setColor(blue);
298  if ((*outputVector)[i])
299  {
300  ObjectItemText->append(FROM_UTF8((*outputVector)[i]->getObjectDisplayName()));
301  //ObjectItemText->insertParagraph(pHead->pItem->getObject()->pCopasiObject->getCN()., -1);
302  //ObjectItemText->insertParagraph(FROM_UTF8((*outputVector)[i]->getObjectType()), -1);
303  }
304  }
305 
306  /*
307  for (pHead = outputVector->getRoot(), i = 1; pHead != NULL; pHead = pHead->pNext)
308  {
309  if (double(i) / 2 == int(i / 2))
310  ObjectItemText->setColor(red);
311  else
312  ObjectItemText->setColor(blue);
313  if (pHead->pItem->getObject()->pCopasiObject)
314  {
315  //ObjectItemText->insertParagraph(pHead->pItem->getObject()->pCopasiObject->getCN()., -1);
316  ObjectItemText->insertParagraph(pHead->pItem->getObject()->pCopasiObject->getObjectType()., -1);
317  i++;
318  }
319  }
320  */
321  pdelete(outputVector);
322 }
323 
324 void ObjectBrowserWidget::setOutputVector(std::vector< const CCopasiObject * > * pObjectVector)
325 {
326  mOutputObjectVector = pObjectVector;
327  this->clearClicked();
328 
330 }
331 
333 {
334  ObjectBrowserItem* rootItem;
335  rootItem = objectItemList->getRoot()->pItem;
336 
338 
339  eXport(rootItem, mOutputObjectVector);
340  return;
341 }
342 
343 void ObjectBrowserWidget::eXport(ObjectBrowserItem* pCurrent, std::vector< const CCopasiObject * > * outputVector)
344 {
345  if (!outputVector) return;
346 
347  if (pCurrent->child(0))
348  {
349  ObjectBrowserItem* pChild = static_cast< ObjectBrowserItem * >(pCurrent->child(0));
350 
351  for (; pChild != NULL; pChild = static_cast< ObjectBrowserItem * >(pChild->nextSibling()))
352  if (pChild->getType() != FIELDATTR)
353  eXport(pChild, outputVector);
354  }
355  else //it has no child
356  {
357  if (pCurrent->isChecked() && (pCurrent->getType() != FIELDATTR))
358  {
359  if (pCurrent->getObject())
360  {
361  bool insertFlag = true;
362  unsigned C_INT32 i = 0;
363 
364  for (; i < outputVector->size(); i++)
365  if (pCurrent->getObject()->pCopasiObject->getCN() == (*outputVector)[i]->getCN()) insertFlag = false;
366 
367  if (insertFlag)
368  outputVector->push_back(pCurrent->getObject()->pCopasiObject);
369  }
370  }
371 
372  // else skip current item
373  }
374 }
375 
376 void ObjectBrowserWidget::swap(int first_pos, int second_pos, ObjectBrowserItem** array)
377 {
378  ObjectBrowserItem* tmp = array[first_pos];
379  array[first_pos] = array[second_pos];
380  array[second_pos] = tmp;
381 }
382 
383 int ObjectBrowserWidget::partition(int split_pos, int start_pos, int end_pos, ObjectBrowserItem** quick_sort_array)
384 {
385  const void * tmp = quick_sort_array[split_pos]->getObject()->pCopasiObject;
386 
387  if (split_pos != start_pos)
388  swap(split_pos, start_pos, quick_sort_array);
389 
390  split_pos = start_pos;
391  end_pos++;
392 
393  while (start_pos < end_pos)
394  {
395  while ((++start_pos < end_pos) && (quick_sort_array[start_pos]->getObject()->pCopasiObject <= tmp));
396 
397  while ((--end_pos > start_pos) && (quick_sort_array[end_pos]->getObject()->pCopasiObject > tmp));
398 
399  if (start_pos < end_pos)
400  swap(start_pos, end_pos, quick_sort_array);
401  else
402  break;
403  }
404 
405  start_pos--;
406 
407  if (split_pos != start_pos)
408  swap(split_pos, start_pos, quick_sort_array);
409 
410  return start_pos;
411 }
412 
413 void ObjectBrowserWidget::quick_sort(int m, int n, ObjectBrowserItem** quick_sort_array)
414 {
415  if (m < n)
416  {
417  int medium = (m + n) / 2;
418  medium = partition(medium, m, n, quick_sort_array);
419 
420  if (m < medium - 1)
421  quick_sort(m, medium - 1, quick_sort_array);
422 
423  if (medium + 1 < n)
424  quick_sort(medium + 1, n, quick_sort_array);
425  }
426 }
427 
429 {
431  ObjectBrowserItem * itemRoot = new ObjectBrowserItem(ObjectListView, NULL, root, objectItemList);
432  itemRoot->attachKey();
433  itemRoot->setObjectType(CONTAINERATTR);
434  // itemRoot->setText(0, FROM_UTF8(root->getObjectName()));
435  itemRoot->setText(0, QString("COPASI"));
436  itemRoot->setExpanded(true);
437  loadChild(itemRoot, root, true);
439  loadUI();
440 }
441 
443 {
444  int length = objectItemList->len();
445  ObjectBrowserItem** bufferVector = new ObjectBrowserItem * [length];
446 
447  // copy out the list
448  ObjectListItem* pCurrent = objectItemList->getRoot();
449 
450  for (int i = 0; i < length; i++)
451  {
452  bufferVector[i] = pCurrent->pItem;
453  pCurrent = pCurrent->pNext;
454  }
455 
456  // sort list according to CCopasiObject
457  quick_sort(0, length - 1, bufferVector);
458 
459  int index;
460  CBrowserObject* pBrowserObject = NULL;
461  ObjectBrowserItem* pBrowserItem = NULL;
462 
463  for (index = 0; (index < length) && (!bufferVector[index]->getObject()->pCopasiObject); index++);
464 
465  pBrowserObject = bufferVector[index++]->getObject();
466 
467  for (; index < length; index++)
468  {
469  if (bufferVector[index]->getObject()->pCopasiObject == pBrowserObject->pCopasiObject) //duplicate point
470  {
471  pBrowserItem = bufferVector[index]->getObject()->referenceList->pop();
472  pBrowserObject->referenceList->insert(pBrowserItem);
473  pBrowserItem->setBrowserObject(pBrowserObject);
474  }
475  else
476  pBrowserObject = bufferVector[index]->getObject();
477  }
478 }
479 
481  const CCopasiContainer* copaParent,
482  bool nField)
483 {
484  unsigned int i;
485  ObjectBrowserItem* last = NULL;
486  CCopasiObject* current = NULL;
487 
488  ObjectList* childStack = new ObjectList();
489 
490  const CCopasiContainer::objectMap * pObjectList = & copaParent->getObjects();
491  CCopasiContainer::objectMap::const_iterator it = pObjectList->begin();
492  CCopasiContainer::objectMap::const_iterator end = pObjectList->end();
493 
494  if ((copaParent->isVector()) && (nField))
495  {
496  if ((static_cast< const CCopasiVector < CCopasiObject > * >(copaParent)->size() >= 1) &&
497  ((*static_cast< const CCopasiVector < CCopasiObject > * >(copaParent))[0]->isContainer()))
498  {
499  //add attribute list
500  ObjectBrowserItem* fieldChild = new ObjectBrowserItem(parent, NULL, NULL, objectItemList);
501  fieldChild->setObjectType(FIELDATTR);
502  fieldChild->setText(0, "Select by attribute");
503  //fieldChild->setSelectable(false);
504  loadField(fieldChild, const_cast<CCopasiVector < CCopasiObject > *>(static_cast< const CCopasiVector < CCopasiObject > * >(copaParent)));
505  fieldChild->attachKey();
506  last = fieldChild;
507  }
508  }
509 
510  if (copaParent->isVector())
511  {
512  for (i = 0; i < static_cast< const CCopasiVector < CCopasiObject > * >(copaParent)->size(); i++)
513  {
514  current = (*static_cast< const CCopasiVector < CCopasiObject > * >(copaParent))[i];
515  ObjectBrowserItem* currentItem = new ObjectBrowserItem(parent, last, current, objectItemList);
516  last = currentItem;
517  currentItem->setText(0, FROM_UTF8(current->getObjectName()));
518 
519  if (current->isContainer())
520  {
521  currentItem->setObjectType(CONTAINERATTR);
522  currentItem->attachKey();
523 
524  if (current->isVector())
525  currentItem->setText(0, currentItem->text(0) + "[]");
526 
527  loadChild(currentItem, static_cast< CCopasiContainer * >(current), nField);
528  }
529  else
530  {
531  currentItem->setObjectType(OBJECTATTR);
532  childStack->insert(currentItem); //attach the key later
533  }
534  }
535  }
536  else
537  {
538  while (it != end)
539  {
540  current = it->second;
541 
542  // Skip all strings
543  if (dynamic_cast<CCopasiStaticString *>(current))
544  {
545  it++;
546  continue;
547  }
548 
549  ObjectBrowserItem* currentItem = new ObjectBrowserItem(parent, last, current, objectItemList);
550  last = currentItem;
551  currentItem->setText(0, FROM_UTF8(current->getObjectName()));
552 
553  if (current->isContainer())
554  {
555  currentItem->setObjectType(CONTAINERATTR);
556  currentItem->attachKey();
557 
558  if (current->isVector())
559  currentItem->setText(0, currentItem->text(0) + "[]");
560 
561  loadChild(currentItem, static_cast< CCopasiContainer * >(current), nField);
562  }
563  else
564  {
565  currentItem->setObjectType(OBJECTATTR);
566  childStack->insert(currentItem); //attach the key later
567  }
568 
569  it++;
570  }
571  }
572 
573  ObjectBrowserItem* pCurrent;
574 
575  while (childStack->len() > 0)
576  {
577  pCurrent = childStack->pop();
578  pCurrent->attachKey();
579  }
580 
581  pdelete(childStack);
582 }
583 
585 {
586  unsigned int i;
587  ObjectBrowserItem* lastFieldItem = NULL;
588  CCopasiObject* currentFieldObject = NULL;
589  ObjectBrowserItem* lastObjectItem = NULL;
590  CCopasiObject* currentObject = NULL;
591 
592  if ((copaParent->size() < 1) || (!(*copaParent)[0]->isContainer())) return; //empty list
593 
594  const CCopasiContainer::objectMap * pFieldList =
595  &(static_cast< CCopasiContainer * >((*copaParent)[0])->getObjects());
596 
597  CCopasiContainer::objectMap::const_iterator fieldIt = pFieldList->begin();
598  CCopasiContainer::objectMap::const_iterator fieldEnd = pFieldList->end();
599 
600  while (fieldIt != fieldEnd)
601  {
602  currentFieldObject = fieldIt->second;
603  ObjectBrowserItem* currentFieldItem = new ObjectBrowserItem(parent, lastFieldItem, NULL, objectItemList);
604  currentFieldItem->attachKey();
605  currentFieldItem->setObjectType(FIELDATTR);
606  currentFieldItem->setText(0, FROM_UTF8(currentFieldObject->getObjectName()));
607  lastFieldItem = currentFieldItem;
608  lastObjectItem = NULL;
609 
610  for (i = 0; i < copaParent->size(); i++)
611  {
612  CCopasiObject* pSubField;
613  currentObject = (*static_cast< CCopasiVector < CCopasiObject > * >(copaParent))[i];
614 
615  if (currentObject->isContainer())
616  pSubField =
617  getFieldCopasiObject(static_cast< CCopasiContainer * >(currentObject),
618  currentFieldObject->getObjectName().c_str());
619  else
620  {
621  pSubField = NULL; // this shall be an exception error
622  }
623 
624  ObjectBrowserItem* currentItem = new ObjectBrowserItem(currentFieldItem, lastObjectItem, pSubField, objectItemList);
625  currentItem->setText(0, FROM_UTF8(currentObject->getObjectName()));
626  // if ((pSubField)&&(pSubField->isVector()))
627  // currentItem->setText(0, currentItem->text(0) + "[]");
628  currentItem->setObjectType(FIELDATTR);
629  currentItem->attachKey();
630 
631  if (pSubField)
632  if (pSubField->isContainer()) //container field recursively to find all possible items
633  {
634  loadChild(currentItem, static_cast< CCopasiContainer * >(pSubField), false); // wont show the attribute and field list
635  }
636 
637  lastObjectItem = currentItem;
638  }
639 
640  fieldIt++;
641  }
642 }
643 
645 {
646  //refresh List stores all affected items,
647 
648  refreshList->createBucketIndex((int)ObjectBrowserItem::getKeySpace()); //construct index to do binary search
649 
650  for (ObjectListItem* pCurrent = refreshList->getRoot(); pCurrent != NULL; pCurrent = pCurrent->pNext)
651  {
652  ObjectListItem * pHead = pCurrent->pItem->getObject()->referenceList->getRoot();
653 
654  while (pHead != NULL)
655  {
656  ObjectBrowserItem * pCurrentLevel = pHead->pItem;
657 
658  if (pCurrent != pHead)
659  for (; (pCurrentLevel != NULL); pCurrentLevel =
660  static_cast< ObjectBrowserItem * >(pCurrentLevel->parent()))
661  refreshList->insertBucket(pCurrentLevel);
662 
663  pHead = pHead->pNext;
664  }
665  }
666 
667  int cursor = 0;
668 
669  for (ObjectBrowserItem* pUpdate = refreshList->bucketPop(cursor); pUpdate != NULL; pUpdate = refreshList->bucketPop(cursor))
670  setCheckMark(pUpdate);
671 
673 
675 }
676 
678 {
679  if (pCurrent->text(0) == "Select by attribute")
680  {
681  pCurrent->setIcon(0, QIcon());
682  return;
683  }
684 
685  switch (pCurrent->nUserChecked())
686  {
687  case NOCHECKED:
688  pCurrent->setIcon(0, QIcon(*pObjectNone));
689  break;
690  case ALLCHECKED:
691  pCurrent->setIcon(0, QIcon(*pObjectAll));
692  break;
693  case PARTCHECKED:
694  pCurrent->setIcon(0, QIcon(*pObjectParts));
695  break;
696  }
697 }
698 
700 {
701  ObjectListItem* pCurrent = objectItemList->getRoot();
702  setCheckMark(pCurrent->pItem);
703 
704  for (; pCurrent != NULL; pCurrent = pCurrent->pNext)
705  setCheckMark(pCurrent->pItem);
706 }
707 
709 {
710  const CCopasiContainer::objectMap * pObjectList = & pCurrent->getObjects();
711  CCopasiContainer::objectMap::const_iterator it = pObjectList->begin();
712  CCopasiContainer::objectMap::const_iterator end = pObjectList->end();
713 
714  // CCopasiObject* pResult;
715  while (it != end)
716  {
717  // if (it->second->isContainer())
718  // {
719  // pResult = getFieldCopasiObject((CCopasiContainer *)it->second, name);
720  // if (pResult)
721  // return pResult;
722  //}
723  if (FROM_UTF8(it->second->getObjectName()) == name)
724  return it->second;
725 
726  it++;
727  }
728 
729  return NULL;
730 }
731 
732 void ObjectBrowserWidget::selectObjects(std::vector< const CCopasiObject * > * pObjectVector)
733 {
734  unsigned int i;
735  ObjectBrowserItem* rootItem;
736 
737  rootItem = objectItemList->getRoot()->pItem;
738 
739  for (i = 0; i < pObjectVector->size(); i++)
740  {
741  if ((*pObjectVector)[i]) selectObjects(rootItem, (*pObjectVector)[i]);
742  }
743 
744  updateUI();
745 }
746 
748  const CCopasiObject * selectObject)
749 {
750  ObjectBrowserItem* pCurrent;
751  pCurrent = browserItem;
752 
753  if (pCurrent->child(0))
754  {
755  ObjectBrowserItem* pChild = static_cast< ObjectBrowserItem * >(pCurrent->child(0));
756 
757  for (; pChild != NULL; pChild = static_cast< ObjectBrowserItem * >(pChild->nextSibling()))
758  if (pChild->getType() != FIELDATTR)
759  selectObjects(pChild, selectObject);
760  }
761  else
762  {
763  //it has no child
764  if (pCurrent->getType() != FIELDATTR)
765  {
766  if (pCurrent->getObject() && (pCurrent->getObject()->pCopasiObject == selectObject))
767  {
768  refreshList->insert(pCurrent);
769 
770  ObjectBrowserItem* pTmp = pCurrent;
771 
772  while (pTmp->parent() != NULL)
773  {
774  pTmp = static_cast< ObjectBrowserItem * >(pTmp->parent());
775  refreshList->insert(pTmp);
776  }
777 
778  pCurrent->getObject()->mChecked = ALLCHECKED;
779  setCheck(static_cast< ObjectBrowserItem * >(pCurrent->child(0)));
780  }
781 
782  // else skip current item
783  }
784  }
785 }
bool isContainer() const
CBrowserObject * getObject()
#define pdelete(p)
Definition: copasi.h:215
void insert(ObjectBrowserItem *pItem)
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
void createBucketIndex(int max)
ObjectBrowserItem * bucketPop(int &cursor)
QTreeWidgetItem * nextSibling()
virtual CCopasiObjectName getCN() const
#define NOCHECKED
QGridLayout * ObjectBrowserLayout
const std::string & getObjectName() const
void setUncheck(ObjectBrowserItem *pCurrent)
QPixmap * pObjectAll
virtual size_t size() const
void removeDuplicate(ObjectList *objectItemList)
void setObjectType(objectType newType)
const CCopasiObject * pCopasiObject
ObjectListItem * pNext
virtual const objectMap & getObjects() const
void setCheck(ObjectBrowserItem *pCurrent)
void clickToReverseCheck(ObjectBrowserItem *pCurrent)
void eXport(ObjectBrowserItem *pCurrent, std::vector< const CCopasiObject * > *outputVector)
ObjectList * referenceList
void insertBucket(ObjectBrowserItem *pItem)
#define C_UNUSED(p)
Definition: copasi.h:220
#define C_INT32
Definition: copasi.h:90
void setBrowserObject(CBrowserObject *updateObject)
void setCheckMark(ObjectBrowserItem *pCurrent)
virtual void listviewChecked(QTreeWidgetItem *, int)
std::multimap< std::string, CCopasiObject * > objectMap
void swap(int, int, ObjectBrowserItem **)
void loadField(ObjectBrowserItem *parent, CCopasiVector< CCopasiObject > *copaParent)
QPixmap * pObjectParts
ObjectBrowserItem * pItem
Header file of class CCopasiContainer.
void loadChild(ObjectBrowserItem *parent, const CCopasiContainer *copaParent, bool nField)
QPixmap * pObjectNone
#define PARTCHECKED
void setOutputVector(std::vector< const CCopasiObject * > *pObjectVector)
QTreeWidget * ObjectListView
virtual void toggleViewClicked()
bool fl(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
bool isVector() const
static void resetKeySpace()
std::vector< const CCopasiObject * > * mOutputObjectVector
static long getKeySpace()
#define ALLCHECKED
void selectObjects(std::vector< const CCopasiObject * > *pObjectVector)
static const CCopasiContainer * getRoot()
void quick_sort(int, int, ObjectBrowserItem **)
ObjectBrowserWidget(QWidget *parent=0, const char *name=0, Qt::WFlags fl=0, int state=0)
QPushButton * commitButton
ObjectListItem * getRoot()
ObjectBrowserItem * pop()
int partition(int, int, int, ObjectBrowserItem **)
CCopasiObject * getFieldCopasiObject(CCopasiContainer *pCurrent, const char *name)
QPushButton * toggleViewButton