COPASI API  4.16.103
CQPlotSubwidget.h
Go to the documentation of this file.
1 // Copyright (C) 2012 - 2014 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 #ifndef CQPlotSubwidget_H
7 #define CQPlotSubwidget_H
8 
9 #include <QtCore/QVariant>
10 
11 #include "copasi/plotUI/ui_CQPlotSubwidget.h"
12 
14 
15 class QListWidgetItem;
16 class PlotWindow;
17 class Curve2DWidget;
18 class HistoWidget;
19 class CQPlotEditWidget;
20 
21 #ifdef COPASI_BANDED_GRAPH
22 class BandedGraphWidget;
23 #endif
24 
25 class CQPlotSubwidget : public CopasiWidget, public Ui::CQPlotSubwidget
26 {
27  Q_OBJECT
28 
29 private:
32 #ifdef COPASI_BANDED_GRAPH
33  BandedGraphWidget* mpBandedGraphWidget;
34 #endif
35 
37 
38  void addPlotItem(CPlotItem* item);
39  void selectPlotItem(CPlotItem* item);
40 
41  int getCurrentIndex();
42  void setCurrentIndex(int index);
43  void deleteCurve(int index);
44  void deleteCurve(QListWidgetItem* item);
45  int getRow(QListWidgetItem* item);
46  void deleteCurves();
47 
48  QMap<QString, CPlotItem*> mList;
50  QList<QListWidgetItem*> mLastSelection;
51 
52  bool areOfSameType(QList<QListWidgetItem*>& items);
53 
54  void storeChanges();
55 
57 
58 public:
59  CQPlotSubwidget(QWidget* parent = 0, const char* name = 0, Qt::WFlags fl = 0);
61 
63  ListViews::Action action, const std::string & key);
64  virtual bool leave();
65 
66  /**
67  * creates tabs for histograms from a list of objects. objects[0] is skipped,
68  * so objects.size()-1 histogram descriptions are generated.
69  * incr is used for all of them.
70  * This method is called from HistoWidget, so that when the user chooses several
71  * objects from the object selection widget several histograms can be generated
72  * accordingly.
73  */
74  void createHistograms(std::vector<const CCopasiObject* >objects, const C_FLOAT64 & incr);
75 
76 protected:
77  virtual bool enterProtected();
79  bool saveToPlotSpec();
80 
81  /**
82  * creates curve widget and adds it to the tab bar
83  */
84  void addCurveTab(const std::string & title,
85  const CPlotDataChannelSpec & x,
86  const CPlotDataChannelSpec & y);
87 
88 #ifdef COPASI_BANDED_GRAPH
89  /**
90  * creates banded graph widget and adds it to the tab bar
91  */
92  void addBandedGraphTab(const std::string & title,
93  const CPlotDataChannelSpec & x,
94  const CPlotDataChannelSpec & yone,
96 #endif // COPASI_BANDED_GRAPH
97 
98  /**
99  * creates histogram widget and adds it to the tab bar
100  */
101  void addHisto1DTab(const std::string & title,
102  const CPlotDataChannelSpec & x,
103  const C_FLOAT64 & incr);
104 
106 
107 protected slots:
108 
109  /**
110  * slots that are connected to the buttons for adding curves/histograms
111  */
112  void addCurveSlot();
113 #ifdef COPASI_BANDED_GRAPH
114  void addBandedGraphSlot();
115 #endif // COPASI_BANDED_GRAPH
116  void addHistoSlot();
117 
118  void itemSelectionChanged();
119 
120  /**
121  * deletes the current tab
122  */
123  void removeCurve();
124 
125  /**
126  *
127  */
128  void commitPlot();
129 
130  /**
131  * deletes the current plot spec.
132  */
133  void deletePlot();
134 
135  /**
136  * copy a plot definition
137  */
138  void copyPlot();
139 
140  /**
141  * create a new plot definition
142  */
143  void addPlot();
144 
145  /**
146  * cancels changes to the plot definition
147  */
148  void resetPlot();
149 
150 protected:
151  /**
152  * this specifically handles the creation of a 2d curve. It is called when
153  * the corresponding button is pressed and the plot is actually 2D.
154  * The dialogs for choosing objects for the axes is called from here and one
155  * or several curve descriptions are generated.
156  */
157  void addCurve2D();
158 
159 #ifdef COPASI_BANDED_GRAPH
160  /**
161  * this specifically handles the creation of a banded graph. It is called when
162  * the corresponding button is pressed and the plot is actually a banded graph.
163  * The dialogs for choosing objects for the axes is called from here and one
164  * or several banded graph descriptions are generated.
165  */
166  void addBandedGraph();
167 #endif // COPASI_BANDED_GRAPH
168 
169  /**
170  * this specifically handles the creation of a histogram. It is called when
171  * the corresponding button is pressed and the plot is actually 2D.
172  * An empty histogram description is generated.
173  */
174  void addHisto1D();
175 };
176 
177 #endif // PLOTWIDGET1_H
objectType
void addHisto1DTab(const std::string &title, const CPlotDataChannelSpec &x, const C_FLOAT64 &incr)
CPlotItem * mLastItem
bool areOfSameType(QList< QListWidgetItem * > &items)
HistoWidget * mpHistoWidget
void addCurveTab(const std::string &title, const CPlotDataChannelSpec &x, const CPlotDataChannelSpec &y)
QMap< QString, CPlotItem * > mList
CPlotItem * updateItem(CPlotItem *item)
void setCurrentIndex(int index)
virtual bool leave()
CQPlotSubwidget(QWidget *parent=0, const char *name=0, Qt::WFlags fl=0)
Curve2DWidget * mpCurveWidget
virtual bool enterProtected()
#define C_FLOAT64
Definition: copasi.h:92
CPlotItem::Type mType
QList< QListWidgetItem * > mLastSelection
bool fl(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
void addPlotItem(CPlotItem *item)
bool loadFromPlotSpec(const CPlotSpecification *)
CQPlotEditWidget * selectControl(CPlotItem::Type type)
void selectPlotItem(CPlotItem *item)
void deleteCurve(int index)
int getRow(QListWidgetItem *item)
virtual bool update(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key)
void createHistograms(std::vector< const CCopasiObject * >objects, const C_FLOAT64 &incr)