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

#include <CQAnimationWindow.h>

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

Public Slots

void slotAutoLayout ()
 Slots the auto layout. More...
 
void slotEditSettings ()
 
void slotExportImage ()
 
void slotLayoutStateChanged (QSharedPointer< CLayoutState > state)
 
void slotRandomizeLayout ()
 
void slotShowStep (int)
 
void slotStopLayout ()
 
void slotSwitchAnimation ()
 

Public Member Functions

 CQAnimationWindow (CLayout *layout, CCopasiDataModel *dataModel=NULL)
 
 CQAnimationWindow ()
 
virtual QMenu * getWindowMenu () const
 
void setAnimation (CQCopasiAnimation *animation, CCopasiDataModel *dataModel)
 
void setScene (CQLayoutScene *scene, CCopasiDataModel *dataModel)
 
virtual ~CQAnimationWindow ()
 
- Public Member Functions inherited from CWindowInterface
void addToMainWindow (CopasiUI3Window *window=NULL)
 
 CWindowInterface (QWidget *parent=NULL, Qt::WindowFlags flags=NULL)
 
void removeFromMainWindow (CopasiUI3Window *window=NULL)
 
virtual void saveToFile (const QString &fileName) const
 
virtual ~CWindowInterface ()
 

Protected Member Functions

virtual void closeEvent (QCloseEvent *closeEvent)
 

Protected Attributes

CQCopasiAnimationmAnimation
 
CLayoutmpCopy
 
CQLayoutThreadmpLayoutThread
 
CCopasiDataModelmpModel
 
CQLayoutScenempScene
 
QMenu * mpWindowMenu
 

Private Member Functions

void init ()
 
void toggleUI (bool isPlaying)
 

Detailed Description

Definition at line 25 of file CQAnimationWindow.h.

Constructor & Destructor Documentation

CQAnimationWindow::CQAnimationWindow ( CLayout layout,
CCopasiDataModel dataModel = NULL 
)

Definition at line 263 of file CQAnimationWindow.cpp.

References init(), and setScene().

264  : mpScene(NULL)
265  , mpModel(NULL)
266  , mpWindowMenu(NULL)
267  , mAnimation(NULL)
268  , mpLayoutThread(NULL)
269  , mpCopy(NULL)
270 {
271  init();
272  setScene(new CQLayoutScene(layout, dataModel), dataModel);
273 }
CCopasiDataModel * mpModel
void setScene(CQLayoutScene *scene, CCopasiDataModel *dataModel)
CQLayoutThread * mpLayoutThread
CQLayoutScene * mpScene
CQCopasiAnimation * mAnimation
CQAnimationWindow::CQAnimationWindow ( )

Definition at line 275 of file CQAnimationWindow.cpp.

References init().

276  : mpScene(NULL)
277  , mpModel(NULL)
278  , mpWindowMenu(NULL)
279  , mAnimation(NULL)
280  , mpLayoutThread(NULL)
281  , mpCopy(NULL)
282 {
283  init();
284 }
CCopasiDataModel * mpModel
CQLayoutThread * mpLayoutThread
CQLayoutScene * mpScene
CQCopasiAnimation * mAnimation
CQAnimationWindow::~CQAnimationWindow ( )
virtual

Definition at line 331 of file CQAnimationWindow.cpp.

References mAnimation, mpCopy, mpLayoutThread, mpScene, pdelete, CWindowInterface::removeFromMainWindow(), and CQLayoutThread::terminateLayout().

332 {
334 
335  if (mpCopy != NULL)
336  {
337  delete mpCopy;
338  mpCopy = NULL;
339  }
340 
341  if (mAnimation != NULL)
342  {
343  delete mAnimation;
344  mAnimation = NULL;
345  }
346 
348 
349  pdelete(mpScene);
351 }
void removeFromMainWindow(CopasiUI3Window *window=NULL)
#define pdelete(p)
Definition: copasi.h:215
CQLayoutThread * mpLayoutThread
CQLayoutScene * mpScene
CQCopasiAnimation * mAnimation

Member Function Documentation

void CQAnimationWindow::closeEvent ( QCloseEvent *  closeEvent)
protectedvirtual

Definition at line 431 of file CQAnimationWindow.cpp.

References mpLayoutThread, and CQLayoutThread::stopLayout().

432 {
433  // stop the autolayout
435 }
CQLayoutThread * mpLayoutThread
QMenu * CQAnimationWindow::getWindowMenu ( ) const
virtual

Implements CWindowInterface.

Definition at line 390 of file CQAnimationWindow.cpp.

References mpWindowMenu.

391 {
392  return mpWindowMenu;
393 }
void CQAnimationWindow::init ( )
private

Definition at line 286 of file CQAnimationWindow.cpp.

References CQIconResource::copasi, CQIconResource::fileExport, CQLayoutThread::getParameterWindow(), CQIconResource::icon(), mpLayoutThread, mpWindowMenu, CQIconResource::play, CQIconResource::roll, slotLayoutStateChanged(), slotStopLayout(), and toggleUI().

Referenced by CQAnimationWindow().

287 {
288  setupUi(this);
290  setUnifiedTitleAndToolBarOnMac(true);
291 
292  actionAuto_Layout->setIcon(CQIconResource::icon(CQIconResource::play));
293  actionRandomize_Layout->setIcon(CQIconResource::icon(CQIconResource::roll));
294  actionExport->setIcon(CQIconResource::icon(CQIconResource::fileExport));
295 
296  QMenu* viewMenu = menuBar()->addMenu(tr("&View"));
297  graphicsView->fillZoomMenu(viewMenu);
298 
299  QToolBar* actionToolbar = this->addToolBar("Actions");
300  actionToolbar->addAction(actionExport);
301  actionToolbar->addAction(actionAuto_Layout);
302  actionToolbar->addAction(actionRandomize_Layout);
303 
304  QToolBar* selectToolbar = this->addToolBar("Select");
305  graphicsView->fillSelectionToolBar(selectToolbar);
306 
307  QToolBar* viewToolBar = this->addToolBar("View");
308  graphicsView->fillZoomTooBar(viewToolBar);
309 
310  mpWindowMenu = menuBar()->addMenu(tr("&Window"));
311 
312  mpLayoutThread = new CQLayoutThread(this);
313  connect(mpLayoutThread, SIGNAL(layoutFinished()), this, SLOT(slotStopLayout()));
314  connect(mpLayoutThread, SIGNAL(layoutStateChanged(QSharedPointer<CLayoutState>)), this, SLOT(slotLayoutStateChanged(QSharedPointer<CLayoutState>)));
315 
316  QDockWidget* pParameterWindow = mpLayoutThread->getParameterWindow();
317  addDockWidget(Qt::LeftDockWidgetArea, pParameterWindow);
318  viewMenu->addSeparator();
319  viewMenu->addAction(pParameterWindow->toggleViewAction());
320  toggleUI(false);
321 }
void toggleUI(bool isPlaying)
void slotLayoutStateChanged(QSharedPointer< CLayoutState > state)
CQLayoutThread * mpLayoutThread
static const QIcon & icon(const IconID &id)
QDockWidget * getParameterWindow()
void CQAnimationWindow::setAnimation ( CQCopasiAnimation animation,
CCopasiDataModel dataModel 
)

Definition at line 395 of file CQAnimationWindow.cpp.

References CQCopasiAnimation::getNumSteps(), CQCopasiAnimation::initialize(), mAnimation, mpScene, CQCopasiAnimation::removeFromScene(), and slotShowStep().

Referenced by setScene(), and slotSwitchAnimation().

396 {
397  if (mAnimation != NULL)
398  {
400  delete mAnimation;
401  }
402 
403  mAnimation = animation;
404  mAnimation->initialize(*dataModel);
405  size_t numSteps = mAnimation->getNumSteps();
406 
407  if (numSteps > 0)
408  {
409  mpControls->setVisible(true);
410  mpControls->setNumSteps(numSteps);
411  slotShowStep(0);
412  }
413  else
414  {
415  mpControls->setVisible(false);
416  statusBar()->showMessage("No data for the animation! Run task first, and load data.", 1000);
417  }
418 }
virtual int getNumSteps()
virtual void removeFromScene(CQLayoutScene &scene)
virtual void initialize(const CCopasiDataModel &model)=0
CQLayoutScene * mpScene
CQCopasiAnimation * mAnimation
void CQAnimationWindow::setScene ( CQLayoutScene scene,
CCopasiDataModel dataModel 
)

Definition at line 353 of file CQAnimationWindow.cpp.

References CQLayoutScene::getCurrentLayout(), mpModel, mpScene, pdelete, CQLayoutScene::recreate(), and setAnimation().

Referenced by CQAnimationWindow().

354 {
355  mpModel = dataModel;
356 
357  if (mpScene != NULL && mpScene != scene)
358  pdelete(mpScene);
359 
360  mpScene = scene;
361  this->graphicsView->setScene(mpScene);
362  mpScene->recreate();
363  graphicsView->setDataModel(dataModel, scene->getCurrentLayout());
364  this->graphicsView->invalidateScene();
365  //setAnimation(new QConservedSpeciesAnimation(), dataModel);
366  //setAnimation(new QFluxModeAnimation(), dataModel);
367  setAnimation(new QTimeCourseAnimation(), dataModel);
368 }
const CLayout * getCurrentLayout() const
#define pdelete(p)
Definition: copasi.h:215
CCopasiDataModel * mpModel
void setAnimation(CQCopasiAnimation *animation, CCopasiDataModel *dataModel)
CQLayoutScene * mpScene
void CQAnimationWindow::slotAutoLayout ( )
slot

Slots the auto layout.

Definition at line 500 of file CQAnimationWindow.cpp.

References CQLayoutThread::createSpringLayout(), CQLayoutScene::getCurrentLayout(), mpCopy, mpLayoutThread, mpScene, CQLayoutThread::stopLayout(), CLayoutState::tagLayout(), and toggleUI().

Referenced by CQLayoutsWidget::slotBtnNewClicked().

501 {
502  if (sender() != NULL && !actionAuto_Layout->isChecked())
503  {
505  return;
506  }
507 
508  toggleUI(true);
509 
510  // work on a copy!
512 
513  if (mpCopy != NULL)
514  {
515  delete mpCopy;
516  mpCopy = NULL;
517  }
518 
521 }
const CLayout * getCurrentLayout() const
void createSpringLayout(CLayout *layout, int numIntervals=1000, int updateWait=100)
static void tagLayout(CLayout *layout)
void toggleUI(bool isPlaying)
CQLayoutThread * mpLayoutThread
CQLayoutScene * mpScene
void CQAnimationWindow::slotEditSettings ( )
slot

Definition at line 437 of file CQAnimationWindow.cpp.

References CQAnimationSettingsEditor::initFrom(), mAnimation, and CQAnimationSettingsEditor::saveTo().

438 {
440  editor.initFrom(mAnimation);
441 
442  if (editor.exec() == QDialog::Accepted)
443  {
444  editor.saveTo(mAnimation);
445  }
446 }
void saveTo(CQCopasiAnimation *target)
CQCopasiAnimation * mAnimation
void initFrom(CQCopasiAnimation *other)
void CQAnimationWindow::slotExportImage ( )
slot

Definition at line 323 of file CQAnimationWindow.cpp.

324 {
325  QString fileName = QFileDialog::getSaveFileName(this, tr("Export Image"),
326  "",
327  tr("PDF files (*.pdf);;Images (*.png *.xpm *.jpg);;All files (*.*)"));
328  graphicsView->slotSaveToFile(fileName);
329 }
void CQAnimationWindow::slotLayoutStateChanged ( QSharedPointer< CLayoutState state)
slot

Definition at line 477 of file CQAnimationWindow.cpp.

References CQLayoutScene::getCurrentLayout(), mpScene, and CQLayoutScene::recreate().

Referenced by init().

478 {
479  state->applyTo(mpScene->getCurrentLayout());
480  mpScene->recreate();
481 }
const CLayout * getCurrentLayout() const
CQLayoutScene * mpScene
void CQAnimationWindow::slotRandomizeLayout ( )
slot
void CQAnimationWindow::slotShowStep ( int  step)
slot

Definition at line 420 of file CQAnimationWindow.cpp.

References CQCopasiAnimation::applyToScene(), CQCopasiAnimation::getNumSteps(), mAnimation, and mpScene.

Referenced by setAnimation().

421 {
422  statusBar()->showMessage(QString("Displaying step %1").arg(step + 1), 1000);
423 
424  if (mAnimation == NULL) return;
425 
427  mpControls->setNumSteps(mAnimation->getNumSteps());
428  mpScene->update();
429 }
virtual int getNumSteps()
CQLayoutScene * mpScene
virtual void applyToScene(CQLayoutScene &scene, int step)
CQCopasiAnimation * mAnimation
void CQAnimationWindow::slotStopLayout ( )
slot

Definition at line 464 of file CQAnimationWindow.cpp.

References CQIconResource::icon(), mpCopy, and CQIconResource::play.

Referenced by init().

465 {
466  if (mpCopy != NULL)
467  {
468  delete mpCopy;
469  mpCopy = NULL;
470  }
471 
472  actionAuto_Layout->setChecked(false);
473  actionAuto_Layout->setText("Run Auto Layout");
474  actionAuto_Layout->setIcon(CQIconResource::icon(CQIconResource::play));
475 }
static const QIcon & icon(const IconID &id)
void CQAnimationWindow::slotSwitchAnimation ( )
slot

Definition at line 370 of file CQAnimationWindow.cpp.

References setAnimation().

371 {
372  QAction *action = dynamic_cast<QAction *>(sender());
373 
374  if (action == NULL) return;
375 
376  if (action->text() == "View Time Course")
377  {
378  setAnimation(new QTimeCourseAnimation(), graphicsView->getDataModel());
379  }
380  else if (action->text() == "View Elementary Modes")
381  {
382  setAnimation(new QFluxModeAnimation(), graphicsView->getDataModel());
383  }
384  else if (action->text() == "View Conserved Species")
385  {
386  setAnimation(new QConservedSpeciesAnimation(), graphicsView->getDataModel());
387  }
388 }
void setAnimation(CQCopasiAnimation *animation, CCopasiDataModel *dataModel)
void CQAnimationWindow::toggleUI ( bool  isPlaying)
private

Definition at line 483 of file CQAnimationWindow.cpp.

References CQIconResource::icon(), mpLayoutThread, CQIconResource::pause, and CQLayoutThread::stopLayout().

Referenced by init(), and slotAutoLayout().

484 {
485  if (isPlaying)
486  {
487  actionAuto_Layout->setChecked(true);
488  actionAuto_Layout->setText("Stop Auto Layout");
489  actionAuto_Layout->setIcon(CQIconResource::icon(CQIconResource::pause));
490  }
491  else
492  {
494  }
495 }
CQLayoutThread * mpLayoutThread
static const QIcon & icon(const IconID &id)

Member Data Documentation

CQCopasiAnimation* CQAnimationWindow::mAnimation
protected
CLayout* CQAnimationWindow::mpCopy
protected

Definition at line 55 of file CQAnimationWindow.h.

Referenced by slotAutoLayout(), slotStopLayout(), and ~CQAnimationWindow().

CQLayoutThread* CQAnimationWindow::mpLayoutThread
protected
CCopasiDataModel* CQAnimationWindow::mpModel
protected

Definition at line 51 of file CQAnimationWindow.h.

Referenced by setScene().

CQLayoutScene* CQAnimationWindow::mpScene
protected
QMenu* CQAnimationWindow::mpWindowMenu
protected

Definition at line 52 of file CQAnimationWindow.h.

Referenced by getWindowMenu(), and init().


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