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

#include <plotwindow.h>

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

Public Member Functions

virtual bool compile (std::vector< CCopasiContainer * > listOfContainer, const CCopasiDataModel *pDataModel)
 
virtual void finish ()
 
virtual const std::set< const
CCopasiObject * > & 
getObjects () const
 
CopasiPlotgetPlot () const
 
virtual QMenu * getWindowMenu () const
 
bool initFromSpec (const CPlotSpecification *ptrSpec)
 
virtual void output (const Activity &activity)
 
 PlotWindow (COutputHandlerPlot *pHandler, const CPlotSpecification *ptrSpec, CopasiUI3Window *pMainWindow)
 
virtual void saveToFile (const QString &fileName) const
 
virtual void separate (const Activity &activity)
 
virtual ~PlotWindow ()
 
- 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 ~CWindowInterface ()
 
- Public Member Functions inherited from COutputInterface
virtual void close ()
 
 COutputInterface ()
 
 COutputInterface (const COutputInterface &src)
 
virtual ~COutputInterface ()
 

Protected Member Functions

virtual void closeEvent (QCloseEvent *closeEvent)
 

Private Slots

void printAsImage ()
 
void printPlot ()
 
void slotCloseWindow ()
 
void slotDeselectAll ()
 
void slotSaveData ()
 Save data into a file. More...
 
void slotSelectAll ()
 
void slotZoomOut ()
 Zoom out. More...
 
void toggleLogX (bool)
 
void toggleLogY (bool)
 

Private Member Functions

void createActions ()
 
void createMenus ()
 
void createToolBar ()
 

Private Attributes

bool initializing
 
QAction * mpaCloseWindow
 
QAction * mpaHideAll
 
QAction * mpaPrint
 
QAction * mpaSaveData
 
QAction * mpaSaveImage
 
QAction * mpaShowAll
 
QAction * mpaToggleLogX
 
QAction * mpaToggleLogY
 
QAction * mpaZoomOut
 
COutputHandlerPlotmpHandler
 
CopasiUI3WindowmpMainWindow
 
CopasiPlotmpPlot
 
QMenu * mpWindowMenu
 

Additional Inherited Members

- Public Types inherited from COutputInterface
enum  Activity { BEFORE = 0x01, DURING = 0x02, AFTER = 0x04 }
 
- Protected Attributes inherited from COutputInterface
std::set< const CCopasiObject * > mObjects
 

Detailed Description

Definition at line 34 of file plotwindow.h.

Constructor & Destructor Documentation

PlotWindow::PlotWindow ( COutputHandlerPlot pHandler,
const CPlotSpecification ptrSpec,
CopasiUI3Window pMainWindow 
)

Definition at line 57 of file plotwindow.cpp.

References CWindowInterface::addToMainWindow(), CQIconResource::copasi, createActions(), createMenus(), createToolBar(), CPlotItem::getTitle(), CQIconResource::icon(), initializing, CPlotSpecification::isLogX(), CPlotSpecification::isLogY(), mpaToggleLogX, mpaToggleLogY, mpMainWindow, and mpPlot.

57  :
59  mpPlot(NULL),
60  mpHandler(pHandler),
61  mpMainWindow(pMainWindow),
62  mpWindowMenu(NULL),
63  mpaCloseWindow(NULL),
64  mpaShowAll(NULL),
65  mpaHideAll(NULL),
66  mpaPrint(NULL),
67  mpaSaveImage(NULL),
68  mpaSaveData(NULL),
69  mpaZoomOut(NULL),
70  mpaToggleLogX(NULL),
71  mpaToggleLogY(NULL),
72  initializing(false)
73 {
74  this->resize(640, 480);
75  this->setWindowTitle(("COPASI Plot: " + ptrSpec->getTitle()).c_str());
76 
77 #ifndef Darwin
79 #endif // not Darwin
80 
81  // set up the GUI - the toolbar
82  createActions();
83  createMenus();
84  createToolBar();
85 
86  mpPlot = new CopasiPlot(ptrSpec, this);
87  setCentralWidget(mpPlot);
88 
89  initializing = true;
90  mpaToggleLogX->setChecked(ptrSpec->isLogX());
91  mpaToggleLogY->setChecked(ptrSpec->isLogY());
92  initializing = false;
93 
95 }
CWindowInterface(QWidget *parent=NULL, Qt::WindowFlags flags=NULL)
QAction * mpaCloseWindow
Definition: plotwindow.h:46
QAction * mpaShowAll
Definition: plotwindow.h:47
bool initializing
Definition: plotwindow.h:56
QAction * mpaSaveData
Definition: plotwindow.h:51
CopasiPlot * mpPlot
Definition: plotwindow.h:41
void createToolBar()
Definition: plotwindow.cpp:171
COutputHandlerPlot * mpHandler
Definition: plotwindow.h:42
static const QIcon & icon(const IconID &id)
QAction * mpaPrint
Definition: plotwindow.h:49
QAction * mpaToggleLogX
Definition: plotwindow.h:53
QAction * mpaZoomOut
Definition: plotwindow.h:52
QAction * mpaToggleLogY
Definition: plotwindow.h:54
QAction * mpaHideAll
Definition: plotwindow.h:48
void createActions()
Definition: plotwindow.cpp:123
CopasiUI3Window * mpMainWindow
Definition: plotwindow.h:43
void createMenus()
Definition: plotwindow.cpp:97
QMenu * mpWindowMenu
Definition: plotwindow.h:44
void addToMainWindow(CopasiUI3Window *window=NULL)
const std::string & getTitle() const
Definition: CPlotItem.cpp:228
QAction * mpaSaveImage
Definition: plotwindow.h:50
PlotWindow::~PlotWindow ( )
virtual

Definition at line 417 of file plotwindow.cpp.

References mpHandler, mpMainWindow, CWindowInterface::removeFromMainWindow(), and COutputHandlerPlot::removeInterface().

418 {
419  if (mpHandler)
420  mpHandler->removeInterface(this);
421 
422  if (mpMainWindow != NULL)
424 }
void removeFromMainWindow(CopasiUI3Window *window=NULL)
COutputHandlerPlot * mpHandler
Definition: plotwindow.h:42
CopasiUI3Window * mpMainWindow
Definition: plotwindow.h:43
virtual void removeInterface(COutputInterface *pInterface)

Member Function Documentation

void PlotWindow::closeEvent ( QCloseEvent *  closeEvent)
protectedvirtual

Definition at line 472 of file plotwindow.cpp.

References mpHandler, mpMainWindow, COutputHandlerPlot::removeInterface(), and CopasiUI3Window::removeWindow().

473 {
474  mpMainWindow->removeWindow(this);
475  mpHandler->removeInterface(this);
476 }
COutputHandlerPlot * mpHandler
Definition: plotwindow.h:42
CopasiUI3Window * mpMainWindow
Definition: plotwindow.h:43
virtual void removeInterface(COutputInterface *pInterface)
void removeWindow(QMainWindow *pWindow)
bool PlotWindow::compile ( std::vector< CCopasiContainer * >  listOfContainer,
const CCopasiDataModel pDataModel 
)
virtual

compile the object list from name vector

Parameters
std::vector<CCopasiContainer * > listOfContainer
constCCopasiDataModel* pDataModel
Returns
bool success

Reimplemented from COutputInterface.

Definition at line 426 of file plotwindow.cpp.

References CopasiPlot::compile(), COutputInterface::mObjects, and mpPlot.

428 {
429  mObjects.clear();
430  bool success = true;
431 
432  if (mpPlot != NULL)
433  success = mpPlot->compile(listOfContainer, pDataModel);
434 
435  return success;
436 };
CopasiPlot * mpPlot
Definition: plotwindow.h:41
virtual bool compile(std::vector< CCopasiContainer * > listOfContainer, const CCopasiDataModel *pDataModel)
std::set< const CCopasiObject * > mObjects
void PlotWindow::createActions ( )
private

Definition at line 123 of file plotwindow.cpp.

References mpaCloseWindow, mpaHideAll, mpaPrint, mpaSaveData, mpaSaveImage, mpaShowAll, mpaToggleLogX, mpaToggleLogY, mpaZoomOut, printAsImage(), printPlot(), slotCloseWindow(), slotDeselectAll(), slotSaveData(), slotSelectAll(), slotZoomOut(), toggleLogX(), and toggleLogY().

Referenced by PlotWindow().

124 {
125  mpaToggleLogX = new QAction("Log &X", this);
126  mpaToggleLogX->setCheckable(true);
127  mpaToggleLogX->setToolTip("Toggle x-axis logscale.");
128  connect(mpaToggleLogX, SIGNAL(toggled(bool)), this, SLOT(toggleLogX(bool)));
129 
130  mpaToggleLogY = new QAction("Log &Y", this);
131  mpaToggleLogY->setCheckable(true);
132  mpaToggleLogY->setToolTip("Toggle y-axis logscale.");
133  connect(mpaToggleLogY, SIGNAL(toggled(bool)), this, SLOT(toggleLogY(bool)));
134 
135  mpaPrint = new QAction("Print", this);
136  mpaPrint ->setToolTip("Print Plot");
137  mpaPrint -> setShortcut(Qt::CTRL + Qt::Key_P);
138  connect(mpaPrint, SIGNAL(triggered()), this, SLOT(printPlot()));
139 
140  mpaSaveImage = new QAction("Save Image", this);
141  mpaSaveImage ->setShortcut(Qt::CTRL + Qt::Key_S);
142  mpaSaveImage ->setToolTip("Save Plot as Image");
143  connect(mpaSaveImage, SIGNAL(triggered()), this, SLOT(printAsImage()));
144 
145  mpaSaveData = new QAction("Save Data", this);
146  mpaSaveData ->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_S);
147  mpaSaveData ->setToolTip("Save Data");
148  connect(mpaSaveData, SIGNAL(triggered()), this, SLOT(slotSaveData()));
149 
150  mpaZoomOut = new QAction("Zoom out", this);
151  mpaZoomOut ->setShortcut(Qt::CTRL + Qt::Key_0);
152  mpaZoomOut ->setToolTip("Zoom out");
153  connect(mpaZoomOut, SIGNAL(triggered()), this, SLOT(slotZoomOut()));
154 
155  mpaShowAll = new QAction("Show All", this);
156  mpaShowAll ->setShortcut(Qt::CTRL + Qt::Key_A);
157  mpaShowAll ->setToolTip("Show all curves");
158  connect(mpaShowAll, SIGNAL(triggered()), this, SLOT(slotSelectAll()));
159 
160  mpaHideAll = new QAction("Hide All", this);
161  mpaHideAll ->setShortcut(Qt::CTRL + Qt::Key_D);
162  mpaHideAll ->setToolTip("Hide all curves");
163  connect(mpaHideAll, SIGNAL(triggered()), this, SLOT(slotDeselectAll()));
164 
165  mpaCloseWindow = new QAction("Close", this);
166  mpaCloseWindow->setObjectName("close");
167  mpaCloseWindow->setShortcut(Qt::CTRL + Qt::Key_W);
168  connect(mpaCloseWindow, SIGNAL(triggered()), this, SLOT(slotCloseWindow()));
169 }
void slotSaveData()
Save data into a file.
Definition: plotwindow.cpp:371
QAction * mpaCloseWindow
Definition: plotwindow.h:46
QAction * mpaShowAll
Definition: plotwindow.h:47
QAction * mpaSaveData
Definition: plotwindow.h:51
void slotCloseWindow()
Definition: plotwindow.cpp:467
void slotSelectAll()
Definition: plotwindow.cpp:455
void printAsImage()
Definition: plotwindow.cpp:311
void toggleLogX(bool)
Definition: plotwindow.cpp:216
QAction * mpaPrint
Definition: plotwindow.h:49
QAction * mpaToggleLogX
Definition: plotwindow.h:53
QAction * mpaZoomOut
Definition: plotwindow.h:52
QAction * mpaToggleLogY
Definition: plotwindow.h:54
QAction * mpaHideAll
Definition: plotwindow.h:48
void slotDeselectAll()
Definition: plotwindow.cpp:461
void printPlot()
Definition: plotwindow.cpp:349
void slotZoomOut()
Zoom out.
Definition: plotwindow.cpp:409
QAction * mpaSaveImage
Definition: plotwindow.h:50
void toggleLogY(bool)
Definition: plotwindow.cpp:236
void PlotWindow::createMenus ( )
private

Definition at line 97 of file plotwindow.cpp.

References mpaCloseWindow, mpaHideAll, mpaPrint, mpaSaveData, mpaSaveImage, mpaShowAll, mpaToggleLogX, mpaToggleLogY, mpaZoomOut, and mpWindowMenu.

Referenced by PlotWindow().

98 {
99  QMenu *fileMenu = menuBar()->addMenu("&File");
100  fileMenu->addAction(mpaSaveImage);
101  fileMenu->addAction(mpaSaveData);
102  fileMenu->addAction(mpaPrint);
103  fileMenu->addSeparator();
104  fileMenu->addAction(mpaCloseWindow);
105 
106  QMenu *viewMenu = menuBar()->addMenu("&View");
107  viewMenu->addAction(mpaShowAll);
108  viewMenu->addAction(mpaHideAll);
109  viewMenu->addSeparator();
110  viewMenu->addAction(mpaToggleLogX);
111  viewMenu->addAction(mpaToggleLogY);
112  viewMenu->addSeparator();
113  viewMenu->addAction(mpaZoomOut);
114 
115  // add a place holder menu, to be filled by the main window
116  mpWindowMenu = menuBar()->addMenu("&Window");
117 }
QAction * mpaCloseWindow
Definition: plotwindow.h:46
QAction * mpaShowAll
Definition: plotwindow.h:47
QAction * mpaSaveData
Definition: plotwindow.h:51
QAction * mpaPrint
Definition: plotwindow.h:49
QAction * mpaToggleLogX
Definition: plotwindow.h:53
QAction * mpaZoomOut
Definition: plotwindow.h:52
QAction * mpaToggleLogY
Definition: plotwindow.h:54
QAction * mpaHideAll
Definition: plotwindow.h:48
QMenu * mpWindowMenu
Definition: plotwindow.h:44
QAction * mpaSaveImage
Definition: plotwindow.h:50
void PlotWindow::createToolBar ( )
private

Definition at line 171 of file plotwindow.cpp.

References mpaCloseWindow, mpaHideAll, mpaPrint, mpaSaveData, mpaSaveImage, mpaShowAll, mpaToggleLogX, mpaToggleLogY, and mpaZoomOut.

Referenced by PlotWindow().

172 {
173  QToolBar * plotTools = addToolBar("plot operations");
174 
175  plotTools->addAction(mpaPrint);
176  plotTools->addAction(mpaSaveImage);
177  plotTools->addAction(mpaSaveData);
178  plotTools->addAction(mpaZoomOut);
179 
180  plotTools->addSeparator();
181  plotTools->addAction(mpaToggleLogX);
182  plotTools->addAction(mpaToggleLogY);
183 
184  plotTools->addSeparator();
185 
186  plotTools->addAction(mpaShowAll);
187  plotTools->addAction(mpaHideAll);
188 
189  plotTools->addSeparator();
190 
191  plotTools->addAction(mpaCloseWindow);
192 
193  //TODO button icons...
194 
195  setUnifiedTitleAndToolBarOnMac(true);
196 // plotTools->setStretchableWidget(new QWidget(plotTools));
197 }
QAction * mpaCloseWindow
Definition: plotwindow.h:46
QAction * mpaShowAll
Definition: plotwindow.h:47
QAction * mpaSaveData
Definition: plotwindow.h:51
QAction * mpaPrint
Definition: plotwindow.h:49
QAction * mpaToggleLogX
Definition: plotwindow.h:53
QAction * mpaZoomOut
Definition: plotwindow.h:52
QAction * mpaToggleLogY
Definition: plotwindow.h:54
QAction * mpaHideAll
Definition: plotwindow.h:48
QAction * mpaSaveImage
Definition: plotwindow.h:50
void PlotWindow::finish ( )
virtual

Finish the output

Reimplemented from COutputInterface.

Definition at line 444 of file plotwindow.cpp.

References CopasiPlot::finish(), and mpPlot.

445 {if (mpPlot) mpPlot->finish();};
CopasiPlot * mpPlot
Definition: plotwindow.h:41
virtual void finish()
const std::set< const CCopasiObject * > & PlotWindow::getObjects ( ) const
virtual

Retrieve the list of objects handled by the interface

Returns
const std::set< const CCopasiObject * > & objects

Reimplemented from COutputInterface.

Definition at line 447 of file plotwindow.cpp.

References COutputInterface::getObjects(), COutputInterface::mObjects, and mpPlot.

448 {
449  if (mpPlot)
450  return mpPlot->getObjects();
451 
452  return mObjects;
453 }
virtual const std::set< const CCopasiObject * > & getObjects() const
CopasiPlot * mpPlot
Definition: plotwindow.h:41
std::set< const CCopasiObject * > mObjects
CopasiPlot * PlotWindow::getPlot ( ) const

Definition at line 478 of file plotwindow.cpp.

References mpPlot.

479 {
480  return mpPlot;
481 }
CopasiPlot * mpPlot
Definition: plotwindow.h:41
QMenu * PlotWindow::getWindowMenu ( ) const
virtual
Returns
a pointer to this plot windows 'window' menu.

Implements CWindowInterface.

Definition at line 118 of file plotwindow.cpp.

References mpWindowMenu.

119 {
120  return mpWindowMenu;
121 }
QMenu * mpWindowMenu
Definition: plotwindow.h:44
bool PlotWindow::initFromSpec ( const CPlotSpecification ptrSpec)

Definition at line 199 of file plotwindow.cpp.

References CPlotItem::getTitle(), CopasiPlot::initFromSpec(), initializing, CPlotSpecification::isLogX(), CPlotSpecification::isLogY(), mpaToggleLogX, mpaToggleLogY, and mpPlot.

200 {
201  this->setWindowTitle(("COPASI Plot: " + ptrSpec->getTitle()).c_str());
202  bool result = mpPlot->initFromSpec(ptrSpec);
203 
204  if (result)
205  {
206  initializing = true;
207  mpaToggleLogX->setChecked(ptrSpec->isLogX());
208  mpaToggleLogY->setChecked(ptrSpec->isLogY());
209  initializing = false;
210  }
211 
212  return result;
213 }
bool initializing
Definition: plotwindow.h:56
CopasiPlot * mpPlot
Definition: plotwindow.h:41
QAction * mpaToggleLogX
Definition: plotwindow.h:53
QAction * mpaToggleLogY
Definition: plotwindow.h:54
bool initFromSpec(const CPlotSpecification *plotspec)
Definition: CopasiPlot.cpp:836
const std::string & getTitle() const
Definition: CPlotItem.cpp:228
void PlotWindow::output ( const Activity activity)
virtual

Perform an output event for the current activity

Parameters
constActivity & activity

Reimplemented from COutputInterface.

Definition at line 438 of file plotwindow.cpp.

References mpPlot, and CopasiPlot::output().

439 {if (mpPlot) mpPlot->output(activity);}
CopasiPlot * mpPlot
Definition: plotwindow.h:41
virtual void output(const Activity &activity)
void PlotWindow::printAsImage ( )
privateslot

Definition at line 311 of file plotwindow.cpp.

References C_INT32, checkSelection(), CopasiFileDialog::getSaveFileName(), and saveToFile().

Referenced by createActions().

312 {
313  // take a name from QFileDialog
314 
315  C_INT32 Answer = QMessageBox::No;
316  QString fileName, extensionName;
317 
318  while (Answer == QMessageBox::No)
319  {
320 
321 // QString userFilter = new QString;
322  /*
323  fileName = CopasiFileDialog::getSaveFileNameAndFilter(filter, this, "Save File Dialog",
324  QString::null, "PNG Files (*.png);;SVG Files (*.svg)", "Save to");
325  */
326  fileName = CopasiFileDialog::getSaveFileName(this, "Save File Dialog",
327  "untitled.png", "PDF Files (*.pdf);;PNG Files (*.png);;SVG Files (*.svg)", "Save Plot as Image", new QString);
328 
329  if (fileName.isEmpty()) return;
330 
331  /*
332  QFileInfo fileInfo(fileName);
333  extensionName = fileInfo.extension();
334  */
335 #ifdef DEBUG_UI
336 // qDebug() << "extensionName = " << extensionName;
337 #endif
338 
339  // check whether the file exists
340  Answer = checkSelection(fileName);
341 
342  if (Answer == QMessageBox::Cancel) return;
343  }
344 
345  // print plot as an image
346  saveToFile(fileName);
347 }
#define C_INT32
Definition: copasi.h:90
C_INT32 checkSelection(const QString &file)
virtual void saveToFile(const QString &fileName) const
Definition: plotwindow.cpp:274
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)
void PlotWindow::printPlot ( )
privateslot

Definition at line 349 of file plotwindow.cpp.

References mpPlot.

Referenced by createActions().

350 {
351  QPrinter printer;
352 
353  QString docName = mpPlot->title().text();
354 
355  if (docName.isEmpty())
356  {
357  //docName.replace (QRegExp (QString::fromLatin1 ("\n")), tr (" -- "));
358  docName = QString::fromLatin1("A plot of selected COPASI output");
359  printer.setDocName(docName);
360  }
361 
362  printer.setCreator("COPASI");
363  printer.setOrientation(QPrinter::Landscape);
364 
365  QPrintDialog dialog(&printer);
366 
367  if (dialog.exec())
368  mpPlot->print(printer, PrintFilter());
369 }
CopasiPlot * mpPlot
Definition: plotwindow.h:41
void PlotWindow::saveToFile ( const QString &  fileName) const
virtual

Saves the current plot to the given filename.

This implementation supports PDF, SVG and PNG

Reimplemented from CWindowInterface.

Definition at line 274 of file plotwindow.cpp.

References mpPlot.

Referenced by printAsImage().

275 {
276  QRect rect;
277  rect.setSize(this->size());
278 
279  if (fileName.endsWith(".png"))
280  {
281  QPixmap pixmap(rect.width(), rect.height());
282  pixmap.fill();
283  QPainter painter(&pixmap);
284  painter.begin(&pixmap);
285  mpPlot->print(&painter, rect, PrintFilter());
286  painter.end();
287 
288  pixmap.save(fileName, "PNG");
289  }
290  else if (fileName.endsWith(".svg"))
291  {
292  QSvgGenerator generator;
293  generator.setFileName(fileName);
294  QPainter painter(&generator);
295  painter.begin(&generator);
296  mpPlot->print(&painter, rect, PrintFilter());
297  painter.end();
298  }
299  else if (fileName.endsWith(".pdf"))
300  {
301  QPrinter printer;
302  printer.setOutputFileName(fileName);
303  printer.setOutputFormat(QPrinter::PdfFormat);
304  QPainter painter(&printer);
305  painter.begin(&printer);
306  mpPlot->print(&painter, rect, PrintFilter());
307  painter.end();
308  }
309 }
CopasiPlot * mpPlot
Definition: plotwindow.h:41
void PlotWindow::separate ( const Activity activity)
virtual

Introduce an additional separator into the output

Parameters
constActivity & activity

Reimplemented from COutputInterface.

Definition at line 441 of file plotwindow.cpp.

References mpPlot, and CopasiPlot::separate().

442 {if (mpPlot) mpPlot->separate(activity);};
virtual void separate(const Activity &activity)
CopasiPlot * mpPlot
Definition: plotwindow.h:41
void PlotWindow::slotCloseWindow ( )
privateslot

Definition at line 467 of file plotwindow.cpp.

Referenced by createActions().

468 {
469  QWidget::close();
470 }
void PlotWindow::slotDeselectAll ( )
privateslot

Hide all curves.

Definition at line 461 of file plotwindow.cpp.

References mpPlot, and CopasiPlot::setCurvesVisibility().

Referenced by createActions().

462 {
463  // We hide all curves in mpPlot
464  mpPlot->setCurvesVisibility(false);
465 }
void setCurvesVisibility(const bool &visibility)
CopasiPlot * mpPlot
Definition: plotwindow.h:41
void PlotWindow::slotSaveData ( )
privateslot

Save data into a file.

Definition at line 371 of file plotwindow.cpp.

References C_INT32, checkSelection(), CQMessageBox::critical(), FROM_UTF8, CopasiFileDialog::getSaveFileName(), mpPlot, CopasiPlot::saveData(), and TO_UTF8.

Referenced by createActions().

372 {
373  C_INT32 Answer = QMessageBox::No;
374  QString fileName;
375 
376  while (Answer == QMessageBox::No)
377  {
378  fileName =
379  CopasiFileDialog::getSaveFileName(this, "Save File Dialog", "untitled.txt", "TEXT Files (*.txt)", "Save Plot Data to");
380 
381  if (fileName.isNull()) return;
382 
383  // Checks whether the file exists
384  Answer = checkSelection(fileName);
385 
386  if (Answer == QMessageBox::Cancel) return;
387  }
388 
389  bool success = false;
390 
391  if (mpPlot)
392  {
393  QCursor oldCursor = cursor();
394  setCursor(Qt::WaitCursor);
395  success = mpPlot->saveData(TO_UTF8(fileName));
396  setCursor(oldCursor);
397  }
398 
399  if (!success)
400  {
401  std::string s = "Could not save data to ";
402  s += TO_UTF8(fileName);
403  CQMessageBox::critical(this, "Save Error", FROM_UTF8(s), QMessageBox::Ok, QMessageBox::NoButton);
404  }
405 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
#define C_INT32
Definition: copasi.h:90
CopasiPlot * mpPlot
Definition: plotwindow.h:41
C_INT32 checkSelection(const QString &file)
static StandardButton critical(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
bool saveData(const std::string &filename)
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)
void PlotWindow::slotSelectAll ( )
privateslot

Show all curves.

Definition at line 455 of file plotwindow.cpp.

References mpPlot, and CopasiPlot::setCurvesVisibility().

Referenced by createActions().

456 {
457  // We show all curves in mpPlot
459 }
void setCurvesVisibility(const bool &visibility)
CopasiPlot * mpPlot
Definition: plotwindow.h:41
void PlotWindow::slotZoomOut ( )
privateslot

Zoom out.

Definition at line 409 of file plotwindow.cpp.

References mpPlot, and CopasiPlot::mpZoomer.

Referenced by createActions().

410 {
411  if (mpPlot && mpPlot->mpZoomer)
412  mpPlot->mpZoomer->zoom(0);
413 }
CopasiPlot * mpPlot
Definition: plotwindow.h:41
QwtPlotZoomer * mpZoomer
Definition: CopasiPlot.h:455
void PlotWindow::toggleLogX ( bool  logX)
privateslot

Definition at line 216 of file plotwindow.cpp.

References initializing, mpPlot, and CopasiPlot::replot().

Referenced by createActions().

217 {
218  if (initializing) return;
219 
220  if (logX)
221  {
222  mpPlot->setAxisScaleEngine(QwtPlot::xBottom, new QwtLog10ScaleEngine());
223  }
224  else
225  {
226  mpPlot->setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine());
227  }
228 
229  mpPlot->setAxisAutoScale(QwtPlot::xBottom);
230  mpPlot->updateAxes();
231  mpPlot->replot();
232  mpPlot->update();
233 }
bool initializing
Definition: plotwindow.h:56
CopasiPlot * mpPlot
Definition: plotwindow.h:41
virtual void replot()
void PlotWindow::toggleLogY ( bool  logY)
privateslot

Definition at line 236 of file plotwindow.cpp.

References initializing, mpPlot, and CopasiPlot::replot().

Referenced by createActions().

237 {
238  if (initializing) return;
239 
240  if (logY)
241  {
242  mpPlot->setAxisScaleEngine(QwtPlot::yLeft, new QwtLog10ScaleEngine());
243  }
244  else
245  {
246  mpPlot->setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine());
247  }
248 
249  mpPlot->setAxisAutoScale(QwtPlot::yLeft);
250  mpPlot->updateAxes();
251  mpPlot->replot();
252  mpPlot->update();
253 }
bool initializing
Definition: plotwindow.h:56
CopasiPlot * mpPlot
Definition: plotwindow.h:41
virtual void replot()

Member Data Documentation

bool PlotWindow::initializing
private

Definition at line 56 of file plotwindow.h.

Referenced by initFromSpec(), PlotWindow(), toggleLogX(), and toggleLogY().

QAction* PlotWindow::mpaCloseWindow
private

Definition at line 46 of file plotwindow.h.

Referenced by createActions(), createMenus(), and createToolBar().

QAction* PlotWindow::mpaHideAll
private

Definition at line 48 of file plotwindow.h.

Referenced by createActions(), createMenus(), and createToolBar().

QAction* PlotWindow::mpaPrint
private

Definition at line 49 of file plotwindow.h.

Referenced by createActions(), createMenus(), and createToolBar().

QAction* PlotWindow::mpaSaveData
private

Definition at line 51 of file plotwindow.h.

Referenced by createActions(), createMenus(), and createToolBar().

QAction* PlotWindow::mpaSaveImage
private

Definition at line 50 of file plotwindow.h.

Referenced by createActions(), createMenus(), and createToolBar().

QAction* PlotWindow::mpaShowAll
private

Definition at line 47 of file plotwindow.h.

Referenced by createActions(), createMenus(), and createToolBar().

QAction* PlotWindow::mpaToggleLogX
private

Definition at line 53 of file plotwindow.h.

Referenced by createActions(), createMenus(), createToolBar(), initFromSpec(), and PlotWindow().

QAction* PlotWindow::mpaToggleLogY
private

Definition at line 54 of file plotwindow.h.

Referenced by createActions(), createMenus(), createToolBar(), initFromSpec(), and PlotWindow().

QAction* PlotWindow::mpaZoomOut
private

Definition at line 52 of file plotwindow.h.

Referenced by createActions(), createMenus(), and createToolBar().

COutputHandlerPlot* PlotWindow::mpHandler
private

Definition at line 42 of file plotwindow.h.

Referenced by closeEvent(), and ~PlotWindow().

CopasiUI3Window* PlotWindow::mpMainWindow
private

Definition at line 43 of file plotwindow.h.

Referenced by closeEvent(), PlotWindow(), and ~PlotWindow().

CopasiPlot* PlotWindow::mpPlot
private
QMenu* PlotWindow::mpWindowMenu
private

Definition at line 44 of file plotwindow.h.

Referenced by createMenus(), and getWindowMenu().


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