COPASI API  4.16.103
CQNewMainWindow.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 // Qt includes
7 #include <QtCore/QAbstractEventDispatcher>
8 #include <QtGui/QAction>
9 #include <QtGui/QActionGroup>
10 #include <QtGui/QCloseEvent>
11 #include <QtGui/QColor>
12 #include <QtGui/QColorDialog>
13 #include <QtGui/QComboBox>
14 #include <QtCore/QFileInfo>
15 #include <QtGui/QHBoxLayout>
16 #include <QtGui/QIcon>
17 #include <QtGui/QImage>
18 #include <QtGui/QLabel>
19 #include <QtGui/QPixmap>
20 #include <QtGui/QMenuBar>
21 #include <QtGui/QStackedWidget>
22 #include <QtGui/QStatusBar>
23 #include <QtGui/QToolBar>
24 #include <QtGui/QVBoxLayout>
25 
26 #include <QtCore/QTimer>
27 
28 // local includes
29 #include "CQGLLayoutPainter.h"
30 #include "CQGLLayoutViewer.h"
31 #include "CQNewMainWindow.h"
32 #include "CQPlayerControlWidget.h"
34 
35 #include "CQGLLayoutViewer.h"
36 #include "CQLayoutMainWindow.h"
37 
38 #include "UI/CQMessageBox.h"
39 #include "UI/CopasiFileDialog.h"
40 #include <string.h>
41 
42 // COPASI includes
45 #include "copasi/model/CModel.h"
46 #include "copasi/layout/CLayout.h"
49 
54 #include "copasi/model/CReaction.h"
55 #include "copasi/model/CChemEq.h"
57 #include "copasi/model/CMetab.h"
58 
59 //#include "copasi/layout/CCopasiSpringLayout.h"
61 #include "copasi/layout/CLayout.h"
62 #include "copasi/layout/CLGlyphs.h"
63 #include "copasi/layout/CLBase.h"
64 #include "copasi/layout/CLCurve.h"
68 
69 #include "../UI/icons/photo.xpm"
71 #include "revert_curve.xpm"
72 #include "film_strip.xpm"
73 #include "graph.xpm"
74 #include "load_data.xpm"
75 #include <QtGui/QDockWidget>
76 #include "layout_start.xpm"
77 #include "layout_stop.xpm"
78 
79 const char* const CQNewMainWindow::ZOOM_FACTOR_STRINGS[] = {"1%", "2%", "3%", "4%", "5%", "10%", "20%", "25%", "30%", "40%", "50%", "75%", "100%", "150%", "200%", "300%", "400%", "500%", "1000%"};
80 const double CQNewMainWindow::ZOOM_FACTORS[] = {0.01, 0.02, 0.03, 0.04, 0.05, 0.1, 0.2, 0.25, 0.3, 0.4, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 10.0};
81 
82 // TODO implement signals that allow enabling and disabling the save and save as actions.
83 
85 {
86  // ensure layout is terminated
88 
89  // delete layout copy
90  if (mpCopy != NULL)
91  {
92  delete mpCopy;
93  mpCopy = NULL;
94  }
95 
96  // remove from window menu
98 }
99 
102  mMode(CQNewMainWindow::GRAPH_MODE),
103  mpWidgetStack(NULL),
104  mpLayoutViewer(NULL),
105  mpAnimationWindow(NULL),
106  mpDataModel(pDatamodel),
107  mpCurrentLayout(NULL),
108  mpCurrentRenderInformation(NULL),
109  mDocumentChanged(false),
110  mCurDir(""),
111  mGraphIcon(QPixmap(graph_xpm)),
112  mAnimationIcon(QPixmap(film_strip_xpm))
113  , mpFogColorPixmap(new QPixmap(32, 32))
114  , mpHighlightColorPixmap(new QPixmap(32, 32))
115  , mpHighlightModeAction(NULL)
116  , mpChangeColorAction(NULL)
117  , mpStopLayoutAction(NULL)
118  , mpRandomizeLayout(NULL)
119  , mpCalculateDimensions(NULL)
120  , mpLayoutThread(NULL)
121  , mpCopy(NULL)
122 {
123 
124 #ifndef Darwin
126 #endif // not Darwin
127 
128  // first we load the default styles if they don't already exist
129  if (DEFAULT_STYLES == NULL)
130  {
132  }
133 
134  this->mCurDir = pDatamodel->getReferenceDirectory();
135  this->mpWidgetStack = new QStackedWidget(this);
136  this->mpLayoutViewer = new CQGLLayoutViewer(this->mpWidgetStack);
137  // add the first page
138  this->mpWidgetStack->addWidget(this->mpLayoutViewer);
140  this->mpWidgetStack->addWidget(this->mpAnimationWindow);
141  connect(this->mpLayoutViewer, SIGNAL(singleCurveSelected(bool)), this, SLOT(slotSingleCurveSelected(bool)));
142  connect(this->mpLayoutViewer->getPainter(), SIGNAL(status_message(const QString&, int)), this, SLOT(setStatusMessage(const QString&, int)));
143  createActions();
144  createMenus();
145  createToolBars();
146  createStatusBar();
147 
148  this->setCentralWidget(this->mpWidgetStack);
149  setUnifiedTitleAndToolBarOnMac(true);
152  this->updateLayoutList();
153  // fill the two pixmaps with the current fog and highlight color
154  // We have to do that after the call to updateLayoutList because before that call
155  // the rnederer does not exist yet.
156  const GLfloat* c = this->mpLayoutViewer->getPainter()->getFogColor();
157  this->mpFogColorPixmap->fill(QColor((int)(c[0] * 255.0), (int)(c[1] * 255.0), (int)(c[2] * 255.0), (int)(c[3] * 255.0)));
159  this->mpHighlightColorPixmap->fill(QColor((int)(c[0] * 255.0), (int)(c[1] * 255.0), (int)(c[2] * 255.0), (int)(c[3] * 255.0)));
160  this->mpChangeColorAction->setIcon(QIcon(*this->mpHighlightColorPixmap));
161 
162  mpLayoutThread = new CQLayoutThread(this);
163  connect(mpLayoutThread, SIGNAL(layoutFinished()), this, SLOT(slotLayoutFinished()));
164  connect(mpLayoutThread, SIGNAL(layoutStateChanged(QSharedPointer<CLayoutState>)),
165  this, SLOT(slotLayoutStateChanged(QSharedPointer<CLayoutState>)));
166 
167  QDockWidget* pParameterWindow = mpLayoutThread->getParameterWindow();
168 
169  addDockWidget(Qt::LeftDockWidgetArea, pParameterWindow);
170  mpViewMenu->addSeparator();
171  mpViewMenu->addAction(pParameterWindow->toggleViewAction());
172 }
173 
175 {
176  return mpWindowMenu;
177 }
178 
180 {
181 
182  mpSwitchModeAct = new QAction(mAnimationIcon, tr("Animation Mode"), this);
183  mpSwitchModeAct->setStatusTip(tr("Switch to animation mode."));
184  mpSwitchModeAct->setShortcut(Qt::CTRL + Qt::Key_M);
185  mpSwitchModeAct->setEnabled(true);
186  connect(mpSwitchModeAct, SIGNAL(triggered()), this, SLOT(switchMode()));
187  mpRevertCurveAct = new QAction(QPixmap(revert_curve_xpm), tr("Revert curve"), this);
188  mpRevertCurveAct->setStatusTip(tr("Reverts the currently selected curve."));
189  mpRevertCurveAct->setEnabled(false);
190  connect(mpRevertCurveAct, SIGNAL(triggered()), this->mpLayoutViewer, SLOT(slotRevertCurve()));
191 
192  mpScreenshotAct = new QAction(QPixmap(photo), tr("Export bitmap..."), this);
193  mpScreenshotAct->setStatusTip(tr("Export diagram as bitmap."));
194  mpScreenshotAct->setShortcut(Qt::CTRL + Qt::Key_E);
195  mpScreenshotAct->setEnabled(true);
196  connect(mpScreenshotAct, SIGNAL(triggered()), this, SLOT(slotScreenshot()));
197 
198  mpCloseAct = new QAction(tr("Close"), this);
199  mpCloseAct->setShortcut(tr("Ctrl+W"));
200  mpCloseAct->setStatusTip(tr("Close Diagram"));
201  connect(mpCloseAct, SIGNAL(triggered()), this, SLOT(close()));
202 
203  mpLoadDataAct = new QAction(QPixmap(load_data_xpm), tr("Update Trajectory Data"), this);
204  mpLoadDataAct->setStatusTip(tr("Update time course data"));
205  mpLoadDataAct->setEnabled(true);
206  connect(this->mpLoadDataAct, SIGNAL(activated()), this->mpAnimationWindow, SLOT(loadData()));
207 
208  mpRectangularShape = new QAction("Rectangle", this);
209  //mpRectangularShape->setShortcut(Qt::CTRL + Qt::Key_R);
210  mpRectangularShape->setStatusTip("Show labels as rectangles");
211  connect(mpRectangularShape, SIGNAL(activated()), this->mpAnimationWindow, SLOT(mapLabelsToRectangles()));
212 
213  mpCircularShape = new QAction("Circle", this);
214  //mpCircularShape->setShortcut(Qt::CTRL + Qt::Key_C);
215  mpCircularShape->setStatusTip("Show labels as circles");
216  connect(mpCircularShape, SIGNAL(activated()), this->mpAnimationWindow, SLOT(mapLabelsToCircles()));
217 
218  mpMimaNodeSizes = new QAction("Set Min/Max Node Sizes", this);
219  //mpMimaNodeSizes->setShortcut(Qt::CTRL + Qt::Key_M);
220  mpMimaNodeSizes->setToolTip("Change Min/Max for node sizes within animation");
221  connect(mpMimaNodeSizes, SIGNAL(activated()), this->mpAnimationWindow, SLOT(changeMinMaxNodeSizes()));
222 
223  mpSFontSize = new QAction("Set Font Size", this);
224  //mpSFontSize->setShortcut(Qt::CTRL + Qt::Key_F);
225  mpSFontSize->setToolTip("Change the font size of the node labels in the graph view");
226  connect(mpSFontSize, SIGNAL(activated()), this->mpAnimationWindow, SLOT(changeFontSize()));
227 
228  this->mpStopLayoutAction = new QAction(QPixmap(layout_start_xpm), tr("Stop"), this);
229  this->mpStopLayoutAction->setEnabled(true);
230  this->mpStopLayoutAction->setToolTip("Run Spring Layout Algorithm");
231  connect(this->mpStopLayoutAction, SIGNAL(triggered()), this, SLOT(slotRunSpringLayout()));
232 
233  mpRandomizeLayout = new QAction(CQIconResource::icon(CQIconResource::roll), tr("Randomize Layout"), this);
234  mpRandomizeLayout->setToolTip("Randomize current Layout");
235  mpRandomizeLayout->setShortcut(Qt::CTRL + Qt::Key_F5);
236  connect(this->mpRandomizeLayout, SIGNAL(triggered()), this, SLOT(slotRunRandomizeLayout()));
237 
238  mpCalculateDimensions = new QAction(tr("&Calculate Dimensions"), this);
239  mpCalculateDimensions->setToolTip("Calculates Dimensions of this Layout.");
240  connect(this->mpCalculateDimensions, SIGNAL(triggered()), this, SLOT(slotCalculateDimensions()));
241 }
242 
244 {
245  mpFileMenu = menuBar()->addMenu(tr("&File"));
246  mpFileMenu->addAction(mpSwitchModeAct);
247  mpFileMenu->addSeparator();
248  mpFileMenu->addAction(this->mpScreenshotAct);
249  mpFileMenu->addSeparator();
250  mpFileMenu->addAction(mpCloseAct);
251 
252  mpLayoutMenu = menuBar()->addMenu(tr("&Layout"));
253  mpLayoutMenu->addAction(mpStopLayoutAction);
254  mpLayoutMenu->addAction(mpRandomizeLayout);
255  mpLayoutMenu->addSeparator();
257 
258  // play menu
259  mpPlayMenu = menuBar()->addMenu(tr("&Play"));
260  mpPlayMenu->setVisible(false);
261  this->mpPlayMenu->addAction(this->mpAnimationWindow->getControlWidget()->getPlayAction());
262  this->mpPlayMenu->addAction(this->mpAnimationWindow->getControlWidget()->getPauseAction());
263  this->mpPlayMenu->addAction(this->mpAnimationWindow->getControlWidget()->getStopAction());
264  this->mpPlayMenu->addAction(this->mpAnimationWindow->getControlWidget()->getForwardAction());
265  this->mpPlayMenu->addAction(this->mpAnimationWindow->getControlWidget()->getBackwardAction());
268  this->mpPlayMenu->addSeparator();
269  this->mpLoopItemAction = this->mpPlayMenu->addAction(tr("Loop Animation"));
270  this->mpLoopItemAction->setCheckable(true);
271  this->mpLoopItemAction->setChecked(false);
272  connect(this->mpLoopItemAction, SIGNAL(toggled(bool)) , this->mpAnimationWindow, SLOT(slotLoopActivated(bool)));
273  this->mpPlayMenu->addSeparator();
274  this->mpPlayMenu->addAction(this->mpLoadDataAct);
275 
276  // view menu
277  mpViewMenu = menuBar()->addMenu(tr("&View"));
278  mpViewMenu->addAction(tr("&Reset View"), this, SLOT(slotResetView()));
279  mpViewMenu->addAction(tr("&Fit to Screen"), this, SLOT(slotFitToScreen()));
280  this->mpZoomMenu = this->mpViewMenu->addMenu(tr("&Zoom"));
281  this->mpZoomActionGroup = new QActionGroup(this);
282  QAction* pAction = this->mpZoomActionGroup->addAction("1%");
283  pAction->setCheckable(true);
284  pAction = this->mpZoomActionGroup->addAction("2%");
285  pAction->setCheckable(true);
286  pAction = this->mpZoomActionGroup->addAction("3%");
287  pAction->setCheckable(true);
288  pAction = this->mpZoomActionGroup->addAction("4%");
289  pAction->setCheckable(true);
290  pAction = this->mpZoomActionGroup->addAction("5%");
291  pAction->setCheckable(true);
292  pAction = this->mpZoomActionGroup->addAction("10%");
293  pAction->setCheckable(true);
294  pAction = this->mpZoomActionGroup->addAction("20%");
295  pAction->setCheckable(true);
296  pAction = this->mpZoomActionGroup->addAction("30%");
297  pAction->setCheckable(true);
298  pAction = this->mpZoomActionGroup->addAction("40%");
299  pAction->setCheckable(true);
300  pAction = this->mpZoomActionGroup->addAction("50%");
301  pAction->setCheckable(true);
302  pAction = this->mpZoomActionGroup->addAction("100%");
303  pAction->setCheckable(true);
304  pAction->setChecked(true);
305  pAction = this->mpZoomActionGroup->addAction("150%");
306  pAction->setCheckable(true);
307  pAction = this->mpZoomActionGroup->addAction("200%");
308  pAction->setCheckable(true);
309  pAction = this->mpZoomActionGroup->addAction("300%");
310  pAction->setCheckable(true);
311  pAction = this->mpZoomActionGroup->addAction("400%");
312  pAction->setCheckable(true);
313  pAction = this->mpZoomActionGroup->addAction("500%");
314  pAction->setCheckable(true);
315  pAction = this->mpZoomActionGroup->addAction("1000%");
316  pAction->setCheckable(true);
317  connect(this->mpZoomActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(slotZoomMenuItemActivated(QAction*)));
318  this->mpZoomMenu->addActions(this->mpZoomActionGroup->actions());
319  this->mpViewMenu->addSeparator();
320  this->mpHighlightModeAction = this->mpViewMenu->addAction(tr("Highlight"));
321  this->mpHighlightModeAction->setCheckable(true);
322  this->mpHighlightModeAction->setChecked(true);
323  this->mpHighlightModeAction->setToolTip(tr("Toggle whether selected elements are highlighted or unselected items toned down."));
324  connect(this->mpHighlightModeAction, SIGNAL(toggled(bool)), this, SLOT(toggleHighlightSlot(bool)));
325  this->mpFogDensityAction = this->mpViewMenu->addAction(tr("Fog Density ..."));
326  connect(this->mpFogDensityAction, SIGNAL(triggered(bool)), this, SLOT(fogDensitySlot(bool)));
327  this->mpChangeColorAction = this->mpViewMenu->addAction(tr("Highlight Color ..."));
328  connect(this->mpChangeColorAction, SIGNAL(triggered(bool)), this, SLOT(changeColorSlot(bool)));
329  this->mpChangeColorAction->setToolTip(tr("When higlighted, sets the highlight color, or the toned down one otherwise."));
330  this->mpElementaryModesMenu = this->mpViewMenu->addMenu("Elementary Modes");
331  this->mpElementaryModesMenu->setToolTip(tr("Displays a list of elementary modes when they have been calculated and lets you select one or more that are emphasized in the layout displayed."));
332  this->mpElementaryModesMenu->addAction(tr("None"));
333  connect(this->mpElementaryModesMenu, SIGNAL(aboutToShow()), this, SLOT(checkForElementaryModesSlot()));
334 
335  // options menu
336  mpOptionsMenu = menuBar()->addMenu(tr("Options"));
337  mpOptionsMenu->setVisible(false);
338  QMenu* pM = this->mpOptionsMenu->addMenu(tr("Shape of Label"));
339  pM->addAction(this->mpRectangularShape);
340  pM->addAction(this->mpCircularShape);
341  this->mpOptionsMenu->addAction(this->mpMimaNodeSizes);
342  this->mpOptionsMenu->addAction(this->mpSFontSize);
343 
344  menuBar()->addSeparator();
345 
346  mpWindowMenu = menuBar()->addMenu(tr("&Window"));
347 }
348 
350 {
351  this->mpFileToolBar = addToolBar(tr("File"));
352  this->mpFileToolBar->addAction(this->mpSwitchModeAct);
353  this->mpFileToolBar->addAction(this->mpRevertCurveAct);
354  this->mpFileToolBar->addAction(this->mpLoadDataAct);
355  this->mpLoadDataAct->setVisible(false);
356  this->mpFileToolBar->addAction(this->mpScreenshotAct);
357  this->mpFileToolBar->addSeparator();
358  this->mpFileToolBar->addAction(this->mpStopLayoutAction);
359  this->mpFileToolBar->addAction(this->mpRandomizeLayout);
360 
361  // add a toolbar for the selection widgets
362  mpSelectionToolBar = addToolBar(tr("Select"));
363  QFrame* pFrame1 = new QFrame;
364  QHBoxLayout* pLayout = new QHBoxLayout;
365  pLayout->setSpacing(3);
366  QLabel* pLabel = new QLabel(tr("Layout:"));
367  pLayout->addWidget(pLabel);
368  this->mpLayoutDropdown = new QComboBox;
369  this->mpLayoutDropdown->setSizeAdjustPolicy(QComboBox::AdjustToContentsOnFirstShow);
370  pFrame1->setLayout(pLayout);
371  pLayout->addWidget(this->mpLayoutDropdown);
372 
373  QFrame* pFrame2 = new QFrame;
374  pLayout = new QHBoxLayout;
375  pLayout->setSpacing(3);
376  pFrame2->setLayout(pLayout);
377  this->mpRenderLabel = new QLabel(tr("Render Information:"));
378  pLayout->addWidget(this->mpRenderLabel);
379  this->mpRenderDropdown = new QComboBox;
380  this->mpRenderDropdown->setSizeAdjustPolicy(QComboBox::AdjustToContentsOnFirstShow);
381  pLayout->addWidget(this->mpRenderDropdown);
382 
383  QFrame* pFrame3 = new QFrame;
384  pLayout = new QHBoxLayout;
385  pLayout->setSpacing(3);
386  pFrame3->setLayout(pLayout);
387  pLabel = new QLabel(tr("Zoom Factor:"));
388  pLayout->addWidget(pLabel);
389  this->mpZoomDropdown = new QComboBox;
390  pLayout->addWidget(this->mpZoomDropdown);
391  // fill the zoom factor box
392  unsigned int i, iMax = sizeof(CQNewMainWindow::ZOOM_FACTOR_STRINGS) / sizeof(char*);
393  int defaultIndex = -1;
394 
395  for (i = 0; i < iMax; ++i)
396  {
397  this->mpZoomDropdown->addItem(QString(CQNewMainWindow::ZOOM_FACTOR_STRINGS[i]));
398 
399  if (std::string(CQNewMainWindow::ZOOM_FACTOR_STRINGS[i]) == std::string("100%"))
400  {
401  defaultIndex = i;
402  }
403  }
404 
405  this->mpZoomDropdown->setSizeAdjustPolicy(QComboBox::AdjustToContentsOnFirstShow);
406 
407  // set 100% as the default zoom factor
408  assert(defaultIndex != -1);
409  this->mpZoomDropdown->setCurrentIndex(defaultIndex);
410  this->mpSelectionToolBar->addWidget(pFrame1);
411  this->mpSelectionToolBar->addWidget(pFrame2);
412  this->mpSelectionToolBar->addWidget(pFrame3);
413  // connect the combobox signals
414  connect(this->mpLayoutDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotLayoutChanged(int)));
415  connect(this->mpRenderDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotRenderInfoChanged(int)));
416  connect(this->mpZoomDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotZoomChanged(int)));
417 }
418 
420 {
421  statusBar()->showMessage(tr("Ready"));
422 }
424 {
425  // be sure to disconnect screenshot action
426  if (mMode == GRAPH_MODE)
427  disconnect(mpScreenshotAct, SIGNAL(triggered()), this, SLOT(slotScreenshot()));
428  else
429  disconnect(this->mpScreenshotAct, SIGNAL(triggered()), this->mpAnimationWindow, SLOT(saveImage()));
430 
431  // need to invert to have the toggle work
433  switchMode();
434 }
436 {
437  // pass the datamodel, the layout and the render info to the
438  // LayoutViewer
439  this->resetView();
440  this->mpLayoutViewer->update(this->mpDataModel, this->mpCurrentLayout, this->mpCurrentRenderInformation, QString(this->mCurDir.c_str()));
442 
444  {
446  }
447 }
448 
450 {
451  unsigned int i, iMax = sizeof(CQNewMainWindow::ZOOM_FACTOR_STRINGS) / sizeof(char*);
452  int defaultIndex = -1;
453 
454  for (i = 0; i < iMax; ++i)
455  {
456  if (std::string(CQNewMainWindow::ZOOM_FACTOR_STRINGS[i]) == std::string("100%"))
457  {
458  defaultIndex = i;
459  }
460  }
461 
462  // set 100% as the default zoom factor
463  assert(defaultIndex != -1);
464  disconnect(this->mpZoomDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotZoomChanged(int)));
465  this->mpZoomDropdown->setCurrentIndex(defaultIndex);
466  connect(this->mpZoomDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotZoomChanged(int)));
467 }
468 
470 {
471  this->resetView();
472  // if we are not in animation mode, we have to repaint
473  this->mpLayoutViewer->setZoomFactor(1.0);
475 }
476 
477 /**
478  * This slot is called when the "Fit To Screen" menu item
479  * is activated.
480  */
482 {
483  double zoom = 1.0;
484 
486  {
487  zoom = this->mpAnimationWindow->slotFitToScreen();
488  // set the zoom factor on the other GL window
489  this->mpLayoutViewer->setZoomFactor(zoom);
490  }
491  else
492  {
493  zoom = this->mpLayoutViewer->fitToScreen();
494  // set the zoom factor on the other GL window
495  this->mpAnimationWindow->setZoomFactor(zoom);
496  }
497 
498  // uncheck the zoom entry in the menu
499  QList<QAction*> actions = this->mpZoomActionGroup->actions();
500  QList<QAction*>::iterator it = actions.begin(), endit = actions.end();
501 
502  while (it != endit)
503  {
504  if ((*it)->isChecked())
505  {
506  (*it)->setChecked(false);
507  // only one can be checked
508  break;
509  }
510 
511  ++it;
512  }
513 
514  // add a new entry for the current zoom factor to the zoom dropdown list
515  disconnect(this->mpZoomDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotZoomChanged(int)));
516  // add a new entry for the zoom factor
517  QString s = QString("%1").arg(zoom * 100);
518  s.append("%");
519  const size_t n = sizeof(CQNewMainWindow::ZOOM_FACTOR_STRINGS) / sizeof(char*);
520 
521  if ((size_t)this->mpZoomDropdown->count() > n)
522  {
523  this->mpZoomDropdown->setItemText(0, s);
524  }
525  else
526  {
527  this->mpZoomDropdown->insertItem(0, s);
528  }
529 
530  this->mpZoomDropdown->setCurrentIndex(0);
531  connect(this->mpZoomDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotZoomChanged(int)));
532 }
533 
535 {
536  //std::cout << "new layout " << index << std::endl;
537  CLayout* pTmpLayout = (*this->mpDataModel->getListOfLayouts())[index];
538 
539  if (pTmpLayout != this->mpCurrentLayout)
540  {
541  this->mpCurrentLayout = pTmpLayout;
542  // update the corresponding render information list
544  this->updateRenderer();
545  }
546 }
547 
549 {
550  // check if a local or a global render information has been selected
551  CLRenderInformationBase* pRenderInfo = NULL;
552 
553  // the local render information is first in the list
554  if (index == -1)
555  {
556  //std::cout << "index is -1" << std::endl;
557  return;
558  }
559 
560  size_t Index = (size_t) index;
561 
562  size_t numLocalRenderInfo = this->mpCurrentLayout->getListOfLocalRenderInformationObjects().size();
563  size_t numFileRenderInfo = numLocalRenderInfo + this->mpDataModel->getListOfLayouts()->getListOfGlobalRenderInformationObjects().size();
564 
565  if (Index >= numLocalRenderInfo)
566  {
567  // it is a global render information or a default render info
568  if (Index >= numFileRenderInfo)
569  {
570  // it must be a default render information
571  pRenderInfo = getDefaultStyle(Index - numFileRenderInfo);
572 
573  if (pRenderInfo != this->mpCurrentRenderInformation)
574  {
575  this->mpCurrentRenderInformation = pRenderInfo;
576  this->change_style(true);
577  }
578  }
579  else
580  {
581  pRenderInfo = this->mpDataModel->getListOfLayouts()->getRenderInformation(Index - numLocalRenderInfo);
582 
583  if (pRenderInfo != this->mpCurrentRenderInformation)
584  {
585  this->mpCurrentRenderInformation = pRenderInfo;
586  this->change_style();
587  }
588  }
589  }
590  else
591  {
592  // it is a local render information
593  pRenderInfo = this->mpCurrentLayout->getRenderInformation(Index);
594 
595  if (pRenderInfo != this->mpCurrentRenderInformation)
596  {
597  this->mpCurrentRenderInformation = pRenderInfo;
598  this->change_style();
599  }
600  }
601 }
602 
604 {
605  // disconnect the slot
606  disconnect(this->mpRenderDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotRenderInfoChanged(int)));
607  // remove the local render information items
609 
610  while ((size_t) this->mpRenderDropdown->count() > num)
611  {
612  this->mpRenderDropdown->removeItem(0);
613  }
614 
615  // add the new local render information items
616  if (this->mpCurrentLayout)
617  {
619  size_t i;
620  CLRenderInformationBase* pTmpRenderInfo = NULL;
621 
622  for (i = num; i > 0; --i)
623  {
624  pTmpRenderInfo = this->mpCurrentLayout->getRenderInformation(i - 1);
625  std::string text = pTmpRenderInfo->getKey();
626 
627  if (!pTmpRenderInfo->getName().empty())
628  {
629  text = pTmpRenderInfo->getName();
630  //text += " (";
631  //text += pTmpRenderInfo->getName();
632  //text += ")";
633  }
634 
635  this->mpRenderDropdown->insertItem(0, QString(text.c_str()));
636  }
637  }
638 
639  // if the current render information is a global render information, keep
640  // the selection
641  // otherwise select the first render information if there is one
642  if (dynamic_cast<const CLGlobalRenderInformation*>(this->mpCurrentRenderInformation))
643  {
644  // find the correct index
646 
647  for (i = 0; i < iMax; ++i)
648  {
650  {
651  break;
652  }
653  }
654 
655  if (i == iMax)
656  {
657  // it must be a default style
658  num += i;
659  iMax = getNumDefaultStyles();
660 
661  for (i = 0; i < iMax; ++i)
662  {
664  {
665  break;
666  }
667  }
668 
669  assert(i != iMax);
670  this->mpRenderDropdown->setCurrentIndex((int)(num + i));
671  }
672  else
673  {
674  this->mpRenderDropdown->setCurrentIndex((int)(num + i));
675  }
676  }
677  else
678  {
679  if (this->mpRenderDropdown->count() > 0)
680  {
681  if (num > 0)
682  {
683  // take the first local render information
684  if (this->mpCurrentLayout != NULL)
685  {
687  }
688  else
689  {
690  this->mpCurrentRenderInformation = NULL;
691  }
692 
693  this->mpRenderDropdown->setCurrentIndex(0);
694  }
696  {
697  // take the first global render information
699  this->mpRenderDropdown->setCurrentIndex((int) num);
700  }
701  else if (getNumDefaultStyles() > 0)
702  {
704  }
705  else
706  {
707  this->mpCurrentRenderInformation = NULL;
708  }
709  }
710  else
711  {
712  this->mpCurrentRenderInformation = NULL;
713  }
714  }
715 
716  // reconnect the slot
717  connect(this->mpRenderDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotRenderInfoChanged(int)));
718 }
719 
721 {
722  // disconnect the slot
723  disconnect(this->mpRenderDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotRenderInfoChanged(int)));
724  this->mpRenderDropdown->clear();
726  CLRenderInformationBase* pTmpRenderInfo = NULL;
727 
728  for (i = 0; i < iMax; ++i)
729  {
730  pTmpRenderInfo = this->mpDataModel->getListOfLayouts()->getRenderInformation(i);
731  std::string text = pTmpRenderInfo->getKey();
732 
733  if (!pTmpRenderInfo->getName().empty())
734  {
735  text = pTmpRenderInfo->getName();
736  //text += " (";
737  //text += pTmpRenderInfo->getName();
738  //text += ")";
739  }
740 
741  this->mpRenderDropdown->addItem(QString(text.c_str()));
742  }
743 
744  // reconnect the slot
745  connect(this->mpRenderDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotRenderInfoChanged(int)));
746 }
747 
749 {
750  // disconnect the slot
751  disconnect(this->mpRenderDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotRenderInfoChanged(int)));
752  size_t i, iMax = getNumDefaultStyles();
753  CLRenderInformationBase* pTmpRenderInfo = NULL;
754 
755  for (i = 0; i < iMax; ++i)
756  {
757  pTmpRenderInfo = getDefaultStyle(i);
758  std::string text = pTmpRenderInfo->getKey();
759 
760  if (!pTmpRenderInfo->getName().empty())
761  {
762  text = pTmpRenderInfo->getName();
763  //text += " (";
764  //text += pTmpRenderInfo->getName();
765  //text += ")";
766  }
767 
768  this->mpRenderDropdown->addItem(QString(text.c_str()));
769  }
770 
771  // reconnect the slot
772  connect(this->mpRenderDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotRenderInfoChanged(int)));
773 }
774 
776 {
777  // check if the number of zoom factors in the combobox is greater than
778  // the numbers of items in the zoom combo box
779  //
780  // if so, delete the first entry from the list and reduce the index by 1 because the first entry must be
781  // the item that has been added by fitToScreen.
782  const size_t n = sizeof(CQNewMainWindow::ZOOM_FACTOR_STRINGS) / sizeof(char*);
783 
784  if ((size_t)this->mpZoomDropdown->count() > n && index != 0)
785  {
786  --index;
787  disconnect(this->mpZoomDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotZoomChanged(int)));
788  this->mpZoomDropdown->removeItem(0);
789  this->mpZoomDropdown->setCurrentIndex(index);
790  connect(this->mpZoomDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotZoomChanged(int)));
791  }
792 
793  this->mpLayoutViewer->setZoomFactor(CQNewMainWindow::ZOOM_FACTORS[index]);
794  // also change the zoom factor for the animation window
795  this->mpAnimationWindow->setZoomFactor(this->mpZoomDropdown->currentText());
796 
797  // also set the zoom factor in the menu
798  if ((int) index < this->mpZoomActionGroup->actions().size())
799  {
800  this->mpZoomActionGroup->actions().at(index)->setChecked(true);
801  }
802 }
803 
805 {
806  int index = this->mpZoomActionGroup->actions().indexOf(pAction);
807  // check if the number of zoom factors in the combobox is greater than
808  // the number of items in the combobox
809  //
810  // if so, delete the first entry from the list because this
811  // item that has been added by fitToScreen.
812  const size_t n = sizeof(CQNewMainWindow::ZOOM_FACTOR_STRINGS) / sizeof(char*);
813 
814  if ((size_t)this->mpZoomDropdown->count() > n)
815  {
816  disconnect(this->mpZoomDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotZoomChanged(int)));
817  this->mpZoomDropdown->removeItem(0);
818  connect(this->mpZoomDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotZoomChanged(int)));
819  }
820 
821  this->mpLayoutViewer->setZoomFactor(CQNewMainWindow::ZOOM_FACTORS[index]);
822  // also set the zoom factor in the combobox
823  disconnect(this->mpZoomDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotZoomChanged(int)));
824 
825  if (index < this->mpZoomDropdown->count())
826  {
827  this->mpZoomDropdown->setCurrentIndex(index);
828  }
829 
830  connect(this->mpZoomDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotZoomChanged(int)));
831 
832  // also change the zoom factor for the animation window
833  this->mpAnimationWindow->setZoomFactor(this->mpZoomDropdown->currentText());
834 }
835 
836 void CQNewMainWindow::change_style(bool defaultStyle)
837 {
838  this->mpLayoutViewer->change_style(this->mpCurrentRenderInformation, defaultStyle);
839 }
840 
841 /**
842  * This slot is called when something in the document changes.
843  */
845 {
846  // check if a single curve is selected
847  if (selected)
848  {
849  this->mpRevertCurveAct->setEnabled(true);
850  }
851  else
852  {
853  this->mpRevertCurveAct->setEnabled(false);
854  }
855 }
856 
857 /**
858  * This slot initiates the export
859  * of the layout as a bitmap.
860  * The user gets to choose which part of the
861  * layout is to be exported and how large the
862  * resulting bitmap is supposed to be.
863  */
865 {
866  CQGLLayoutPainter* pPainter = this->mpLayoutViewer->getPainter();
867 
868  if (pPainter == NULL)
869  return;
870 
871 #ifndef USE_SCREENSHOT_OPTIONS
872 
873  QString fileName = CopasiFileDialog::getSaveFileName(this, "Export to", "", QString("PNG (*.png);;All files (*)"));
874 
875  if (!fileName.isEmpty())
876  export_bitmap(fileName, 2.0);
877 
878 #else
879 
880  double layoutX = pPainter->minX();
881  double layoutY = pPainter->minY();
882  double layoutWidth = pPainter->maxX() - layoutX;
883  double layoutHeight = pPainter->maxY() - layoutY;
884  double x = pPainter->getCurrentPositionX();
885  double y = pPainter->getCurrentPositionY();
886  double width = pPainter->getCurrentWidth();
887  double height = pPainter->getCurrentHeight();
888 
889  CQScreenshotOptionsDialog* pDialog = new CQScreenshotOptionsDialog(layoutX, layoutY, layoutWidth, layoutHeight,
890  x, y, width, height, pPainter->width() , pPainter->height(), -1, this);
891 
892  if (pDialog->exec() == QDialog::Accepted)
893  {
894 
895  // ask for the filename
896  QString fileName = CopasiFileDialog::getSaveFileName(this, QString("Export to"), "", QString("PNG (*.png);;All files (*)"));
897 
898  if (!fileName.isEmpty())
899  {
900  export_bitmap(fileName, pDialog->getX(), pDialog->getY(), pDialog->getWidth(), pDialog->getHeight(), pDialog->getImageWidth(), pDialog->getImageHeight(), pDialog->isSetDrawSelectionDecoration());
901  }
902  }
903 
904  delete pDialog;
905 #endif
906 }
907 
908 void CQNewMainWindow::export_bitmap(const QString& filename, double scale /*= 4.0*/)
909 {
910  CQGLLayoutPainter* pPainter = this->mpLayoutViewer->getPainter();
911 
912  if (pPainter == NULL)
913  return;
914 
915  double layoutX = pPainter->minX();
916  double layoutY = pPainter->minY();
917  double layoutWidth = pPainter->maxX() - layoutX;
918  double layoutHeight = pPainter->maxY() - layoutY;
919 
920  export_bitmap(filename, layoutX, layoutY, layoutWidth, layoutHeight, layoutWidth * scale, layoutHeight * scale, false);
921 }
922 
923 /**
924  * Exports a bitmap of the given size to
925  * the file with the given name.
926  */
927 void CQNewMainWindow::export_bitmap(const QString& filename, double x, double y, double width, double height, unsigned int imageWidth, unsigned int imageHeight, bool drawSelection)
928 {
929  // check if the size of the final image is ok.
930  double size = imageWidth * imageHeight * 4;
931 
932  // TODO: not sure we really need to restrict this, if the user *needs* a higher resolution image
933  // TODO: what speeks against it? (Though in praxis resolutions above 4320p are unlikely)
934  // I don't think we should write images that are larger than 500MB
935  if (size > 5e8)
936  {
937  // give an error message that the image is to large
938  CQMessageBox::critical(this, tr("Image too large"),
939  tr("Sorry, refusing to create images that are larger than 500MB."));
940  }
941 
942  //
943  // before we even start, we check if the file can be written to at all
944  // if not, we don't have to do anything
945  QFileInfo info(filename);
946 
947  if (info.exists())
948  {
949  if (!info.isFile())
950  {
951  // create an error message and cancel saving
952  CQMessageBox::critical(this, tr("Not a file"),
953  tr("Path exists, but it is not a file."));
954  return;
955  }
956  else
957  {
958  if (!info.isWritable())
959  {
960  // create an error message and cancel saving
961  CQMessageBox::critical(this, tr("Not writable"),
962  tr("Can't write to file."));
963  return;
964  }
965  }
966  }
967 
968  // now we try to create the image
969  CQGLLayoutPainter* pPainter = this->mpLayoutViewer->getPainter();
970 
971  if (pPainter == NULL)
972  return;
973 
974  GLubyte* pImageData = pPainter->export_bitmap(x, y, width, height, imageWidth, imageHeight, drawSelection);
975 
976  if (pImageData == NULL)
977  return;
978 
979  // create QImage for buffer
980  QImage* pImage = new QImage(pImageData, imageWidth, imageHeight, 4 * imageWidth, QImage::Format_ARGB32);
981  bool result = pImage->save(filename, "PNG");
982 
983  if (result == false)
984  {
985  CQMessageBox::critical(this, tr("Save error"),
986  tr("An error occured while saving the file.\nThe file might be invalid."));
987  }
988 
989  delete pImage;
990  delete[] pImageData;
991 }
992 
994 {
995  if (this->mpDataModel == NULL) return;
996 
997  disconnect(this->mpLayoutDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotLayoutChanged(int)));
998  this->mpLayoutDropdown->clear();
999  const CLayout* pTmpLayout = NULL;
1000  size_t i, iMax = this->mpDataModel->getListOfLayouts()->size();
1001 
1002  for (i = 0; i < iMax; ++i)
1003  {
1004  pTmpLayout = (*this->mpDataModel->getListOfLayouts())[i];
1005  std::string text = pTmpLayout->getKey();
1006 
1007  if (!pTmpLayout->getObjectName().empty())
1008  {
1009  text = pTmpLayout->getObjectName();
1010  //text += "(";
1011  //text += pTmpLayout->getObjectName();
1012  //text += ")";
1013  }
1014 
1015  this->mpLayoutDropdown->addItem(text.c_str());
1016  }
1017 
1018  if (iMax > 0)
1019  {
1020  this->mpCurrentLayout = (*this->mpDataModel->getListOfLayouts())[0];
1021  }
1022 
1024 
1025  if (this->mpCurrentLayout && this->mpCurrentRenderInformation)
1026  {
1027  this->updateRenderer();
1028  }
1029 
1030  connect(this->mpLayoutDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(slotLayoutChanged(int)));
1031 }
1032 
1033 /**
1034  * switches the display mode between animation mode and
1035  * graph mode.
1036  */
1038 {
1039  switch (this->mMode)
1040  {
1042  disconnect(mpScreenshotAct, SIGNAL(triggered()), this, SLOT(slotScreenshot()));
1043  connect(this->mpScreenshotAct, SIGNAL(triggered()), this->mpAnimationWindow, SLOT(saveImage()));
1044  this->mpSwitchModeAct->setIcon(mGraphIcon);
1045  this->mpSwitchModeAct->setStatusTip(tr("Switch to graph mode."));
1046  this->mpSwitchModeAct->setText(tr("Graph Mode"));
1048  this->setAnimationToolbar();
1049  this->setAnimationMenu();
1050  this->mpWidgetStack->setCurrentIndex(1);
1051  this->mpElementaryModesMenu->setEnabled(false);
1052  this->mpHighlightModeAction->setEnabled(false);
1053  this->mpChangeColorAction->setEnabled(false);
1054 
1055  updateLayoutList();
1056  // reset current displayed layout, so we can get the updates displayed
1057  this->mpAnimationWindow->setLayout(NULL);
1058  // update with the new layout
1060  // and fit it too screen
1061  slotFitToScreen();
1062  break;
1063 
1065  disconnect(this->mpScreenshotAct, SIGNAL(triggered()), this->mpAnimationWindow, SLOT(saveImage()));
1066  connect(mpScreenshotAct, SIGNAL(triggered()), this, SLOT(slotScreenshot()));
1067  this->mpSwitchModeAct->setIcon(mAnimationIcon);
1068  this->mpSwitchModeAct->setStatusTip(tr("Switch to animation mode."));
1069  this->mpSwitchModeAct->setText(tr("Animation Mode"));
1071  this->setGraphToolbar();
1072  this->setGraphMenu();
1073  this->mpWidgetStack->setCurrentIndex(0);
1074  this->mpElementaryModesMenu->setEnabled(true);
1075  this->mpHighlightModeAction->setEnabled(true);
1076  this->mpChangeColorAction->setEnabled(true);
1077  break;
1078  }
1079 }
1080 
1082 {
1083  // remove revert curve action
1084  this->mpRevertCurveAct->setVisible(false);
1085  // add load data action
1086  this->mpLoadDataAct->setVisible(true);
1087  // hide the render information box
1088  this->mpRenderLabel->hide();
1089  this->mpRevertCurveAct->setVisible(false);
1090  this->mpRenderDropdown->hide();
1091 }
1092 
1094 {
1095  // remove load data action
1096  this->mpLoadDataAct->setVisible(false);
1097  // add revert curve action
1098  this->mpRevertCurveAct->setVisible(true);
1099  // show the render information box
1100  this->mpRenderLabel->show();
1101  this->mpRevertCurveAct->setVisible(false);
1102  this->mpRenderDropdown->show();
1103 }
1104 
1106 {
1107  this->mpPlayMenu->menuAction()->setVisible(true);
1108  this->mpLayoutMenu->menuAction()->setVisible(false);
1109  this->mpOptionsMenu->menuAction()->setVisible(true);
1110 }
1111 
1113 {
1114  this->mpPlayMenu->menuAction()->setVisible(false);
1115  this->mpLayoutMenu->menuAction()->setVisible(true);
1116  this->mpOptionsMenu->menuAction()->setVisible(false);
1117 }
1118 
1119 void CQNewMainWindow::setStatusMessage(const QString& message, int timeout)
1120 {
1121  this->statusBar()->showMessage(message, timeout);
1122 }
1123 
1124 /**
1125  * Checks for calculated elementary modes.
1126  */
1128 {
1129  bool fluxModesChanged = false;
1130 
1131  if (this->mpDataModel != NULL)
1132  {
1133  const CCopasiVectorN< CCopasiTask >* pTaskList = this->mpDataModel->getTaskList();
1134  assert(pTaskList != NULL);
1135 
1136  if (pTaskList != NULL)
1137  {
1138  // get the metabolic control analysis task object
1139  const CEFMTask* pTask = dynamic_cast<const CEFMTask*>((*pTaskList)["Elementary Flux Modes"]);
1140 
1141  if (pTask != NULL)
1142  {
1143  const CEFMProblem* pProblem = dynamic_cast<const CEFMProblem*>(pTask->getProblem());
1144 
1145  if (pProblem != NULL && !pProblem->getFluxModes().empty())
1146  {
1147  const std::vector< CFluxMode >& fluxModes = pProblem->getFluxModes();
1148  size_t iMax = fluxModes.size();
1149 
1150  if (this->mFluxModes.size() != iMax)
1151  {
1152  fluxModesChanged = true;
1153  }
1154  else
1155  {
1156  unsigned int i = 0;
1157 
1158  while (i < iMax && fluxModesChanged == false)
1159  {
1160  if (&(fluxModes[i]) != this->mFluxModes[i])
1161  {
1162  fluxModesChanged = true;
1163  }
1164 
1165  ++i;
1166  }
1167  }
1168 
1169  if (fluxModesChanged)
1170  {
1171  this->mpElementaryModesMenu->clear();
1172  this->mFluxModes.clear();
1173 
1174  if (fluxModes.empty())
1175  {
1176  this->mpElementaryModesMenu->addAction("None");
1177  disconnect(this->mpElementaryModesMenu, SIGNAL(triggered(QAction*)), this, SLOT(elementaryModeTriggeredSlot(QAction*)));
1178  }
1179  else
1180  {
1181  unsigned int i = 0;
1182  const CFluxMode* pFluxMode = NULL;
1183 
1184  while (i < iMax)
1185  {
1186  pFluxMode = &(fluxModes[i]);
1187  this->mFluxModes.push_back(pFluxMode);
1188  std::string desc = pTask->getFluxModeDescription(*pFluxMode);
1189  QAction* pAction = this->mpElementaryModesMenu->addAction(QString(desc.c_str()));
1190  pAction->setCheckable(true);
1191  ++i;
1192  }
1193 
1194  connect(this->mpElementaryModesMenu, SIGNAL(triggered(QAction*)), this, SLOT(elementaryModeTriggeredSlot(QAction*)));
1195  }
1196  }
1197  }
1198  }
1199  }
1200  }
1201 }
1202 
1203 /**
1204  * Checks which elementary mode has been toggled and updates the
1205  * highlighted objects list.
1206  */
1208 {
1209  CQGLLayoutPainter* pPainter = this->mpLayoutViewer->getPainter();
1210 
1211  if (pPainter == NULL) return;
1212 
1213  // determine the index of the flux mode
1214  unsigned int index = this->mpElementaryModesMenu->actions().indexOf(pAction);
1215  // if the action is checked, we need to add all the reactions of the flux mode
1216  // to the highlighted objects
1218 
1219  if (pAction->isChecked())
1220  {
1221  const CFluxMode* pFlux = this->mFluxModes[index];
1222  CFluxMode::const_iterator it = pFlux->begin(), endit = pFlux->end();
1223  const CReaction* pReaction = NULL;
1224  assert(this->mpDataModel != NULL && this->mpDataModel->getModel() != NULL);
1225  const CEFMProblem* pProblem = NULL;
1226  const CCopasiVectorN< CCopasiTask >* pTaskList = this->mpDataModel->getTaskList();
1227  assert(pTaskList != NULL);
1228 
1229  if (pTaskList != NULL)
1230  {
1231  // get the metabolic control analysis task object
1232  const CEFMTask* pTask = dynamic_cast<const CEFMTask*>((*pTaskList)["Elementary Flux Modes"]);
1233 
1234  if (pTask != NULL)
1235  {
1236  pProblem = dynamic_cast<const CEFMProblem*>(pTask->getProblem());
1237  }
1238  }
1239 
1240  while (it != endit && pProblem != NULL)
1241  {
1242  assert(this->mpDataModel->getModel()->getReactions().size() > it->first);
1243 
1244  // the index is the index of the reordered fluxes from the problem, so in order
1245  // to find the correct reaction, we need to get the reaction from the problem
1246  if (pProblem != NULL)
1247  {
1248  pReaction = pProblem->getReorderedReactions()[it->first];
1249  assert(pReaction != NULL);
1250  this->selectReaction(pReaction, mask, pPainter->getHighlightedObjects());
1251  }
1252 
1253  ++it;
1254  }
1255  }
1256  // if the node is unchecked, we need to remove all the reactions from the
1257  // highlighted objects, but only those that are not part of another selected flux mode
1258  else
1259  {
1260  // we first need to find all objects that belong to other flux modes
1261  const QList<QAction*>& actions = this->mpElementaryModesMenu->actions();
1262  QList<QAction*>::const_iterator ait = actions.begin(), aendit = actions.end();
1263  unsigned int i;
1264  const CFluxMode* pFlux = NULL;
1265 
1266  // we remove all highlighted objects
1267  std::set<const CLGraphicalObject*>& s = pPainter->getHighlightedObjects();
1268  s.clear();
1269  this->mHighlightedReactions.clear();
1270 
1271  // and readd the ones that remain
1272  while (ait != aendit)
1273  {
1274  if ((*ait)->isChecked())
1275  {
1276  i = actions.indexOf(*ait);
1277  assert(i < this->mFluxModes.size());
1278  pFlux = this->mFluxModes[i];
1279  CFluxMode::const_iterator it = pFlux->begin(), endit = pFlux->end();
1280  const CReaction* pReaction = NULL;
1281  assert(this->mpDataModel != NULL && this->mpDataModel->getModel() != NULL);
1282  //const CModel* pModel = this->mpDataModel->getModel();
1283 
1284  while (it != endit)
1285  {
1286  assert(this->mpDataModel->getModel()->getReactions().size() > it->first);
1287  pReaction = this->mpDataModel->getModel()->getReactions()[it->first];
1288  assert(pReaction != NULL);
1289  this->selectReaction(pReaction, mask, s);
1290  ++it;
1291  }
1292  }
1293 
1294  ++ait;
1295  }
1296  }
1297 
1298  // redraw the GL window
1299  if (this->mMode == GRAPH_MODE)
1300  {
1301  this->mpLayoutViewer->getPainter()->update();
1302  }
1303 }
1304 
1305 /**
1306  * Selects the given reaction object by selecting all
1307  * corresponding CLReactionGlyph objects in the current layout.
1308  * The mask determines which parts of the reaction are selected.
1309  * With this, it can be specified that only the reaction glyph itself
1310  * or the reaction glyph plus several of the associated metab reference glyphs
1311  * are selected.
1312  * The graphical objects selected by this method are inserted into the
1313  * set given as the third element.
1314  */
1315 void CQNewMainWindow::selectReaction(const CReaction* pReaction, unsigned int selectionMask, std::set<const CLGraphicalObject*>& s)
1316 {
1317  // we need a reaction and something to select in that
1318  // reaction
1319  if (pReaction != NULL && selectionMask != 0 && this->mpCurrentLayout != NULL)
1320  {
1322  item.mReactionKey = pReaction->getKey();
1323  item.mSelectionMask = selectionMask;
1324  this->mHighlightedReactions.insert(item);
1325  // go through the metabolite glyphs and select
1326  // all metabolite glyphs that are associated
1329 
1330  while (it != endit)
1331  {
1332  if ((*it)->getModelObject() == pReaction)
1333  {
1334  if (selectionMask & CQNewMainWindow::REACTION_GLYPH)
1335  {
1336  s.insert((*it));
1337  }
1338 
1339  const CCopasiVector<CLMetabReferenceGlyph>& mrgv = (*it)->getListOfMetabReferenceGlyphs();
1340 
1341  CCopasiVector<CLMetabReferenceGlyph>::const_iterator it2 = mrgv.begin(), endit2 = mrgv.end();
1342 
1343  std::string key;
1344 
1345  const CCopasiObject* pObject = NULL;
1346 
1347  while (it2 != endit2)
1348  {
1349  // check the role
1350  switch ((*it2)->getRole())
1351  {
1353 
1354  if (selectionMask & CQNewMainWindow::ROLE_UNSPECIFIED)
1355  {
1356  s.insert(*it2);
1357  key = (*it2)->getMetabGlyphKey();
1358  pObject = CCopasiRootContainer::getKeyFactory()->get(key);
1359 
1360  if (pObject != NULL && dynamic_cast<const CLMetabGlyph*>(pObject) != NULL && (selectionMask & CQNewMainWindow::ASSOCIATED_SPECIES_GLYPHS))
1361  {
1362  s.insert(static_cast<const CLMetabGlyph*>(pObject));
1363  }
1364  }
1365 
1366  break;
1367 
1369 
1370  if (selectionMask & CQNewMainWindow::ROLE_SUBSTRATE)
1371  {
1372  s.insert(*it2);
1373  key = (*it2)->getMetabGlyphKey();
1374  pObject = CCopasiRootContainer::getKeyFactory()->get(key);
1375 
1376  if (pObject != NULL && dynamic_cast<const CLMetabGlyph*>(pObject) != NULL && (selectionMask & CQNewMainWindow::ASSOCIATED_SPECIES_GLYPHS))
1377  {
1378  s.insert(static_cast<const CLMetabGlyph*>(pObject));
1379  }
1380  }
1381 
1382  break;
1383 
1385 
1386  if (selectionMask & CQNewMainWindow::ROLE_PRODUCT)
1387  {
1388  s.insert(*it2);
1389  key = (*it2)->getMetabGlyphKey();
1390  pObject = CCopasiRootContainer::getKeyFactory()->get(key);
1391 
1392  if (pObject != NULL && dynamic_cast<const CLMetabGlyph*>(pObject) != NULL && (selectionMask & CQNewMainWindow::ASSOCIATED_SPECIES_GLYPHS))
1393  {
1394  s.insert(static_cast<const CLMetabGlyph*>(pObject));
1395  }
1396  }
1397 
1398  break;
1399 
1401 
1402  if (selectionMask & CQNewMainWindow::ROLE_SIDESUBSTRATE)
1403  {
1404  s.insert(*it2);
1405  key = (*it2)->getMetabGlyphKey();
1406  pObject = CCopasiRootContainer::getKeyFactory()->get(key);
1407 
1408  if (pObject != NULL && dynamic_cast<const CLMetabGlyph*>(pObject) != NULL && (selectionMask & CQNewMainWindow::ASSOCIATED_SPECIES_GLYPHS))
1409  {
1410  s.insert(static_cast<const CLMetabGlyph*>(pObject));
1411  }
1412  }
1413 
1414  break;
1415 
1417 
1418  if (selectionMask & CQNewMainWindow::ROLE_SIDEPRODUCT)
1419  {
1420  s.insert(*it2);
1421  key = (*it2)->getMetabGlyphKey();
1422  pObject = CCopasiRootContainer::getKeyFactory()->get(key);
1423 
1424  if (pObject != NULL && dynamic_cast<const CLMetabGlyph*>(pObject) != NULL && (selectionMask & CQNewMainWindow::ASSOCIATED_SPECIES_GLYPHS))
1425  {
1426  s.insert(static_cast<const CLMetabGlyph*>(pObject));
1427  }
1428  }
1429 
1430  break;
1431 
1433 
1434  if (selectionMask & CQNewMainWindow::ROLE_MODIFIER)
1435  {
1436  s.insert(*it2);
1437  key = (*it2)->getMetabGlyphKey();
1438  pObject = CCopasiRootContainer::getKeyFactory()->get(key);
1439 
1440  if (pObject != NULL && dynamic_cast<const CLMetabGlyph*>(pObject) != NULL && (selectionMask & CQNewMainWindow::ASSOCIATED_SPECIES_GLYPHS))
1441  {
1442  s.insert(static_cast<const CLMetabGlyph*>(pObject));
1443  }
1444  }
1445 
1446  break;
1447 
1449 
1450  if (selectionMask & CQNewMainWindow::ROLE_ACTIVATOR)
1451  {
1452  s.insert(*it2);
1453  key = (*it2)->getMetabGlyphKey();
1454  pObject = CCopasiRootContainer::getKeyFactory()->get(key);
1455 
1456  if (pObject != NULL && dynamic_cast<const CLMetabGlyph*>(pObject) != NULL && (selectionMask & CQNewMainWindow::ASSOCIATED_SPECIES_GLYPHS))
1457  {
1458  s.insert(static_cast<const CLMetabGlyph*>(pObject));
1459  }
1460  }
1461 
1462  break;
1463 
1465 
1466  if (selectionMask & CQNewMainWindow::ROLE_INHIBITOR)
1467  {
1468  s.insert(*it2);
1469  key = (*it2)->getMetabGlyphKey();
1470  pObject = CCopasiRootContainer::getKeyFactory()->get(key);
1471 
1472  if (pObject != NULL && dynamic_cast<const CLMetabGlyph*>(pObject) != NULL && (selectionMask & CQNewMainWindow::ASSOCIATED_SPECIES_GLYPHS))
1473  {
1474  s.insert(static_cast<const CLMetabGlyph*>(pObject));
1475  }
1476  }
1477 
1478  break;
1479  }
1480 
1481  ++it2;
1482  }
1483  }
1484 
1485  ++it;
1486  }
1487  }
1488 }
1489 
1490 /**
1491  * Selected the given metabolite object by selecting all
1492  * corresponding CLMetabGlyph objects in the current layout.
1493  * The graphical objects selected by this method are inserted into the
1494  * set given as the third element.
1495  */
1496 void CQNewMainWindow::selectMetabolite(const CMetab* pMetab, std::set<const CLGraphicalObject*>& s)
1497 {
1498  if (pMetab != NULL && this->mpCurrentLayout != NULL)
1499  {
1500  this->mHighlightedMetabolites.insert(pMetab->getKey());
1501  // go through the metabolite glyphs and select
1502  // all metabolite glyphs that are associated
1505 
1506  while (it != endit)
1507  {
1508  if ((*it)->getModelObject() == pMetab)
1509  {
1510  s.insert((*it));
1511  }
1512 
1513  ++it;
1514  }
1515  }
1516 }
1517 
1518 /**
1519  * Is called when the menu entry for toggling highlighting
1520  * of elementary modes is toggled.
1521  */
1523 {
1524  this->mpLayoutViewer->getPainter()->setHighlightFlag(checked);
1525 
1526  // update the icon and the text
1527  if (checked)
1528  {
1529  this->mpChangeColorAction->setText(tr("highlight color ..."));
1530  this->mpChangeColorAction->setIcon(QIcon(*this->mpHighlightColorPixmap));
1531  }
1532  else
1533  {
1534  this->mpChangeColorAction->setText(tr("fog color ..."));
1535  this->mpChangeColorAction->setIcon(QIcon(*this->mpFogColorPixmap));
1536  }
1537 
1538  // we need to redraw the gl window
1539  if (this->mMode == GRAPH_MODE)
1540  {
1541  this->mpLayoutViewer->getPainter()->update();
1542  }
1543 }
1544 
1545 /**
1546  * Lets the user change the percentage of fog
1547  * that is added to the color.
1548  */
1550 {
1551  // show a dialog with a spin box that goes from 0 to 1.0
1552  // it is filled with the fog density value from the renderer
1553  GLfloat c = this->mpLayoutViewer->getPainter()->getFogDensity();
1554 
1555  QDialog* pDialog = new QDialog;
1556  pDialog->setLayout(new QVBoxLayout(pDialog));
1557  pDialog->layout()->addWidget(new QLabel("Set the fog density:", pDialog));
1558  QDoubleSpinBox* pSpinBox = new QDoubleSpinBox(pDialog);
1559  pSpinBox->setRange(0.0, 1.0);
1560  pSpinBox->setSingleStep(0.01);
1561  pSpinBox->setValue(c);
1562  pDialog->layout()->addWidget(pSpinBox);
1563  QDialogButtonBox* pBBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, pDialog);
1564  pDialog->layout()->addWidget(pBBox);
1565  // connect the buttons
1566  connect(pBBox, SIGNAL(accepted()), pDialog, SLOT(accept()));
1567  connect(pBBox, SIGNAL(rejected()), pDialog, SLOT(reject()));
1568 
1569  if (pDialog->exec() == QDialog::Accepted)
1570  {
1571  c = pSpinBox->value();
1573 
1574  // redraw the GL window
1575  if (this->mMode == GRAPH_MODE)
1576  {
1577  this->mpLayoutViewer->getPainter()->update();
1578  }
1579  }
1580 
1581  delete pDialog;
1582 }
1583 
1584 /**
1585  * This slot is triggered when the user wants to change
1586  * the fog or the highlighting color, depending on the current
1587  * highlighting mode.
1588  */
1590 {
1591  // find the correct color for the current mode
1592  const GLfloat* c = NULL;
1593 
1594  if (this->mpHighlightModeAction->isChecked())
1595  {
1597  }
1598  else
1599  {
1600  c = this->mpLayoutViewer->getPainter()->getFogColor();
1601  }
1602 
1603  // open a color selection dialog
1604  QColorDialog* pDialog = new QColorDialog(QColor((int)(c[0] * 255.0), (int)(c[1] * 255.0), (int)(c[2] * 255.0), (int)(c[3] * 255.0)), this);
1605 
1606  if (pDialog->exec() == QDialog::Accepted)
1607  {
1608  // the dialog has been closed with the OK button
1609  // so we need to get the new color
1610  QColor color = pDialog->selectedColor();
1611  GLfloat newColor[4] = {static_cast<GLfloat>(color.red()) / 255.0f, static_cast<GLfloat>(color.green()) / 255.0f, static_cast<GLfloat>(color.blue()) / 255.0f, static_cast<GLfloat>(color.alpha()) / 255.0f};
1612 
1613  // update the pixmap and the icon for the mpHighlightModeAction
1614  if (this->mpHighlightModeAction->isChecked())
1615  {
1616  this->mpLayoutViewer->getPainter()->setHighlightColor(newColor);
1617  this->mpHighlightColorPixmap->fill(color);
1618  this->mpChangeColorAction->setIcon(QIcon(*this->mpHighlightColorPixmap));
1619  }
1620  else
1621  {
1622  this->mpLayoutViewer->getPainter()->setFogColor(newColor);
1623  this->mpFogColorPixmap->fill(color);
1624  this->mpChangeColorAction->setIcon(QIcon(*this->mpFogColorPixmap));
1625  }
1626 
1627  // redraw the GL window
1628  if (this->mMode == GRAPH_MODE)
1629  {
1630  this->mpLayoutViewer->getPainter()->update();
1631  }
1632  }
1633 }
1634 
1636 {
1637  this->mpLayoutViewer->getPainter()->update();
1638 }
1639 
1640 #ifdef INCLUDE_UNUSED_CODE
1641 
1642 /**
1643  * Creates a CLMetabGlyph for the given CMetab object.
1644  * If the creation failed, NULL is returned.
1645  */
1646 CLMetabGlyph* CQNewMainWindow::createMetabGlyph(const std::string& modelobjectkey, double width, double height)
1647 {
1648  CLMetabGlyph* pResult = new CLMetabGlyph;
1649  pResult->setDimensions(CLDimensions(width, height));
1650  pResult->setModelObjectKey(modelobjectkey);
1651  return pResult;
1652 }
1653 
1654 /**
1655  * Creates a CLCompartmentGlyph for the given size and position
1656  */
1657 CLCompartmentGlyph* CQNewMainWindow::createCompartmentGlyph(const std::string& modelobjectkey, double x, double y, double width, double height)
1658 {
1659  CLCompartmentGlyph* pResult = new CLCompartmentGlyph;
1660  pResult->setPosition(CLPoint(x, y));
1661  pResult->setDimensions(CLDimensions(width, height));
1662  pResult->setModelObjectKey(modelobjectkey);
1663  return pResult;
1664 }
1665 
1666 /**
1667  * Creates a new reaction glyph with the given size.
1668  */
1669 CLReactionGlyph* CQNewMainWindow::createReactionGlyph(const std::string& modelobjectkey, double x, double y, double length)
1670 {
1671  CLReactionGlyph* pResult = new CLReactionGlyph;
1672  //pResult->setPosition(CLPoint(x,y));
1673  //pResult->setDimensions(CLDimensions(width, height));
1674  pResult->setModelObjectKey(modelobjectkey);
1675  pResult->getCurve().addCurveSegment(CLLineSegment(CLPoint(x, y), CLPoint(x + length, y)));
1676  return pResult;
1677 }
1678 
1679 /**
1680  * Creates a CLTextGlyph for the given graphical object keys and size.
1681  */
1682 CLTextGlyph* CQNewMainWindow::createTextGlyph(const std::string& modelobjectkey, const std::string& objectkey, double width, double height)
1683 {
1684  CLTextGlyph* pResult = new CLTextGlyph;
1685  pResult->setDimensions(CLDimensions(width, height));
1686  pResult->setGraphicalObjectKey(objectkey);
1687  pResult->setModelObjectKey(modelobjectkey);
1688  return pResult;
1689 }
1690 
1691 /**
1692  * Creates a CLMetabReferenceGlyph for the given endpoints.
1693  */
1694 CLMetabReferenceGlyph* CQNewMainWindow::createMetabReferenceGlyph(const std::string& modelobjectkey, const std::string& metabglyphkey, CLMetabReferenceGlyph::Role role, double x1, double y1, double x2, double y2)
1695 {
1697  pResult->setModelObjectKey(modelobjectkey);
1698  pResult->setMetabGlyphKey(metabglyphkey);
1699  pResult->setRole(role);
1700  // set the curve
1701  pResult->getCurve().addCurveSegment(CLLineSegment(CLPoint(x1, y1), CLPoint(x2, y2)));
1702  return pResult;
1703 }
1704 
1705 #endif //INCLUDE_UNUSED_CODE
1706 
1708 {
1710  mpLayoutThread->wait();
1712 }
1713 
1714 /**
1715  * Creates a spring layout.
1716  * The method takes the number of iterations for the
1717  * layout algorithm and an update interval which tells the algorithm
1718  * how often to update the display.
1719  * A value of -1 means that the update of the display is only done once
1720  * at the end.
1721  */
1722 void CQNewMainWindow::createSpringLayout(int numIterations, int updateInterval)
1723 {
1724  if (mpCurrentLayout == NULL)
1725  return;
1726 
1727  // reset the stop flag
1728  disconnect(this->mpStopLayoutAction, SIGNAL(triggered()), this, SLOT(slotRunSpringLayout()));
1729  this->mpStopLayoutAction->setToolTip("stop spring layout algorithm");
1730  connect(this->mpStopLayoutAction, SIGNAL(triggered()), this, SLOT(slotStopClicked()));
1731  // enable the stop button
1732  this->mpStopLayoutAction->setEnabled(true);
1733  this->mpStopLayoutAction->setIcon(QPixmap(layout_stop_xpm));
1734 
1736 
1737  if (mpCopy != NULL)
1738  {
1739  delete mpCopy;
1740  mpCopy = NULL;
1741  }
1742 
1743  mpCopy = new CLayout(*mpCurrentLayout);
1744 
1745  mpLayoutThread->createSpringLayout(mpCopy, numIterations);
1746 }
1747 
1749 {
1750  disconnect(this->mpStopLayoutAction, SIGNAL(triggered()), this, SLOT(slotStopClicked()));
1751  connect(this->mpStopLayoutAction, SIGNAL(triggered()), this, SLOT(slotRunSpringLayout()));
1752  this->mpStopLayoutAction->setIcon(QPixmap(layout_start_xpm));
1753  this->mpStopLayoutAction->setToolTip("Run Spring Layout Algorithm");
1754 
1755  if (mpCopy != NULL)
1756  {
1757  delete mpCopy;
1758  mpCopy = NULL;
1759  }
1760 
1761  redrawNow();
1762 }
1763 
1764 /**
1765  * This slot is called when the stop button is presed.
1766  * It notifies the layout method to stop the spring layout iterations.
1767  */
1769 {
1770  this->mpLayoutThread->stopLayout();
1771 }
1772 
1774 {
1775  this->createSpringLayout(1000, 1);
1776 }
1777 
1778 QRectF getBounds(const std::vector<CCopasiSpringLayout::UpdateAction>& updates)
1779 {
1780  QRectF result(1000, 1000, -1000, -1000);
1781  std::vector<CCopasiSpringLayout::UpdateAction>::const_iterator it, itEnd = updates.end();
1782 
1783  for (it = updates.begin(); it != itEnd; ++it)
1784  {
1785  switch (it->mAction)
1786  {
1788  {
1789  CLCompartmentGlyph* current = ((CLCompartmentGlyph*)(it->mpTarget));
1790  result.setLeft(qMin(result.left(), current->getX()));
1791  result.setTop(qMin(result.top(), current->getY()));
1792  result.setRight(qMax(result.right(), current->getX() + current->getWidth()));
1793  result.setBottom(qMax(result.bottom(), current->getY() + current->getHeight()));
1794  }
1795  break;
1796 
1798  {
1799  CLGraphicalObject* current = ((CLGraphicalObject*)(it->mpTarget));
1800  result.setLeft(qMin(result.left(), current->getX()));
1801  result.setTop(qMin(result.top(), current->getY()));
1802  result.setRight(qMax(result.right(), current->getX() + current->getWidth()));
1803  result.setBottom(qMax(result.bottom(), current->getY() + current->getHeight()));
1804  }
1805  break;
1806 
1808  {
1809  CLReactionGlyph* current = ((CLReactionGlyph*)(it->mpTarget));
1810  result.setLeft(qMin(result.left(), current->getX()));
1811  result.setTop(qMin(result.top(), current->getY()));
1812  result.setRight(qMax(result.right(), current->getX() + current->getWidth()));
1813  result.setBottom(qMax(result.bottom(), current->getY() + current->getHeight()));
1814  }
1815  break;
1816 
1817  default:
1818  break;
1819  };
1820  }
1821 
1822  return result;
1823 }
1824 
1826 {
1827  if (this->mpCurrentLayout == NULL ||
1829  return;
1830 
1832  // redraw
1833  this->redrawNow();
1834 }
1835 
1837 {
1838  if (this->mpCurrentLayout == NULL ||
1840  return;
1841 
1842  randomizeLayout();
1843 
1845 }
1846 
1847 void CQNewMainWindow::slotLayoutStateChanged(QSharedPointer<CLayoutState> state)
1848 {
1849  state->applyTo(mpCurrentLayout);
1850  redrawNow();
1851 }
1852 
1853 void CQNewMainWindow::closeEvent(QCloseEvent * event)
1854 {
1855  this->slotStopClicked();
1857  this->QMainWindow::closeEvent(event);
1858 }
void export_bitmap(const QString &filename, double scale=4.0)
QAction * mpChangeColorAction
double minX() const
void setStatusMessage(const QString &message, int timeout)
double getCurrentHeight() const
void createSpringLayout(CLayout *layout, int numIntervals=1000, int updateWait=100)
QPixmap * mpFogColorPixmap
CQPlayerControlWidget * getControlWidget()
static void tagLayout(CLayout *layout)
double getCurrentPositionY() const
QAction * mpCloseAct
QAction * mpRevertCurveAct
void removeFromMainWindow(CopasiUI3Window *window=NULL)
void slotLayoutChanged(int index)
const GLfloat * getHighlightColor() const
std::set< std::string > mHighlightedMetabolites
void fogDensitySlot(bool)
QLabel * mpRenderLabel
QComboBox * mpRenderDropdown
void elementaryModeTriggeredSlot(QAction *pAction)
CQGLLayoutPainter * getPainter()
CQNewMainWindow(CCopasiDataModel *pDatamodel)
void update(const CCopasiDataModel *pDataModel, CLayout *pLayout, const CLRenderInformationBase *pRenderInfo, const QString &baseDir)
CCopasiProblem * getProblem()
std::string getFluxModeDescription(const CFluxMode &fluxMode) const
Definition: CEFMTask.cpp:132
GLfloat getFogDensity() const
const std::string & getObjectName() const
QAction * mpStopLayoutAction
void slotLayoutStateChanged(QSharedPointer< CLayoutState > state)
QAction * mpRectangularShape
const CCopasiVector< CLLocalRenderInformation > & getListOfLocalRenderInformationObjects() const
Definition: CLayout.h:149
CLayout * mpCurrentLayout
virtual size_t size() const
double maxY() const
CQLayoutThread * mpLayoutThread
const std::set< const CLGraphicalObject * > & getHighlightedObjects() const
void setZoomFactor(double zoom)
CCopasiObject * get(const std::string &key)
QAction * mpScreenshotAct
virtual const std::string & getKey() const
Definition: CReaction.cpp:190
void setMode(DISPLAY_MODE mode=GRAPH_MODE)
const C_FLOAT64 & getX() const
iterator begin()
void selectMetabolite(const CMetab *pMetab, std::set< const CLGraphicalObject * > &s)
void setDimensions(const CLDimensions &d)
void setZoomFactor(QString s)
std::vector< const CFluxMode * > mFluxModes
void setHighlightColor(const GLfloat c[4])
void selectReaction(const CReaction *pReaction, unsigned int selectionMask, std::set< const CLGraphicalObject * > &s)
void calculateAndAssignBounds(CLayout *pLayout)
double getCurrentPositionX() const
QAction * mpLoadDataAct
CCopasiVector< CLGlobalRenderInformation > * DEFAULT_STYLES
const CLLocalRenderInformation * getRenderInformation(size_t index) const
Definition: CLayout.cpp:658
Definition: CMetab.h:178
QActionGroup * mpZoomActionGroup
QAction * mpLoopItemAction
const CCopasiVector< CLCompartmentGlyph > & getListOfCompartmentGlyphs() const
Definition: CLayout.h:81
void setFogDensity(GLfloat dens)
QComboBox * mpZoomDropdown
double getCurrentWidth() const
CCopasiDataModel * mpDataModel
CLRenderInformationBase * mpCurrentRenderInformation
virtual void closeEvent(QCloseEvent *event)
CLGlobalRenderInformation * getDefaultStyle(size_t index)
void setModelObjectKey(const std::string &k)
virtual ~CQNewMainWindow()
void change_style(bool defaultStyle=false)
CTSSATask * pTask
const std::string & getReferenceDirectory() const
iterator end()
CCopasiVector< CLGlobalRenderInformation > * loadDefaultStyles()
QPixmap * mpHighlightColorPixmap
QAction * mpCircularShape
const std::vector< CFluxMode > & getFluxModes() const
Definition: CEFMProblem.cpp:80
QToolBar * mpSelectionToolBar
QRectF getBounds(const std::vector< CCopasiSpringLayout::UpdateAction > &updates)
QComboBox * mpLayoutDropdown
size_t getNumDefaultStyles()
void slotSingleCurveSelected(bool selected)
Definition: CLBase.h:54
CQLayoutMainWindow * mpAnimationWindow
virtual const std::string & getKey() const
std::set< REACTION_SELECTION_ITEM > mHighlightedReactions
void changeColorSlot(bool)
virtual QMenu * getWindowMenu() const
static const QIcon & icon(const IconID &id)
CCopasiVectorN< CCopasiTask > * getTaskList()
void slotZoomChanged(int index)
const CCopasiVector< CLMetabGlyph > & getListOfMetaboliteGlyphs() const
Definition: CLayout.h:94
const_iterator begin() const
Definition: CFluxMode.cpp:69
void createSpringLayout(int numIterations, int updateInterval)
void addCurveSegment(const CLLineSegment &ls)
Definition: CLCurve.cpp:101
void setGraphicalObjectKey(const std::string &k)
Definition: CLGlyphs.cpp:338
void setFogColor(const GLfloat c[4])
void addGlobalRenderInfoItemsToList()
GLubyte * export_bitmap(double x, double y, double width, double height, unsigned int imageWidth, unsigned int imageHeight, bool drawSelection)
CListOfLayouts * getListOfLayouts()
virtual const std::string & getKey() const
Definition: CLayout.h:71
void updateRenderInformationList()
QToolBar * mpFileToolBar
void setPosition(const CLPoint &p)
QAction * mpHighlightModeAction
DISPLAY_MODE mMode
const CArrayAnnotation * pResult
void setLayout(CLayout *pLayout)
const C_FLOAT64 & getWidth() const
void toggleHighlightSlot(bool checked)
void randomizeLayout(CLayout *layout)
void setMetabGlyphKey(const std::string &k)
QAction * mpSFontSize
const C_FLOAT64 & getY() const
double maxX() const
const GLfloat * getFogColor() const
void addDefaultRenderInfoItemsToList()
static CKeyFactory * getKeyFactory()
QMenu * mpElementaryModesMenu
static StandardButton critical(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
CLGlobalRenderInformation * getRenderInformation(size_t index)
std::string mCurDir
QAction * mpRandomizeLayout
const std::string & getKey() const
QDockWidget * getParameterWindow()
QAction * mpFogDensityAction
std::map< size_t, C_FLOAT64 >::const_iterator const_iterator
Definition: CFluxMode.h:43
QAction * mpCalculateDimensions
void change_style(const CLRenderInformationBase *pRenderInfo, bool defaultStyle=false)
CCopasiVectorNS< CReaction > & getReactions()
Definition: CModel.cpp:1039
const std::string & getName() const
void setHighlightFlag(bool flag)
double minY() const
void slotZoomMenuItemActivated(QAction *)
QAction * mpMimaNodeSizes
CQGLLayoutViewer * mpLayoutViewer
void checkForElementaryModesSlot()
QStackedWidget * mpWidgetStack
static const double ZOOM_FACTORS[]
const C_FLOAT64 & getHeight() const
const CLCurve & getCurve() const
void slotRenderInfoChanged(int index)
const CCopasiVector< CLReactionGlyph > & getListOfReactionGlyphs() const
Definition: CLayout.h:107
static const char *const ZOOM_FACTOR_STRINGS[]
QAction * mpSwitchModeAct
const_iterator end() const
Definition: CFluxMode.cpp:74
static QString getSaveFileName(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)
const CCopasiVector< CLGlobalRenderInformation > & getListOfGlobalRenderInformationObjects() const