COPASI API  4.16.103
SliderDialog.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2004 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 #ifndef SLIDER_DIALOG_H__
16 #define SLIDER_DIALOG_H__
17 
18 #include <QtGui/QDialog>
19 //Added by qt3to4:
20 #include <QtCore/QEvent>
21 #include <QtGui/QContextMenuEvent>
22 #include <QtGui/QCloseEvent>
23 #include "copasi/copasi.h"
24 #include <vector>
25 #include <map>
28 #include "copasi/UI/ui_SliderDialog.h"
29 
30 class QScrollArea;
31 class QCheckBox;
32 class QPushButton;
33 class QSlider;
34 class CCopasiObject;
35 class QMenu;
36 class QAction;
37 class QFrame;
38 class DataModelGUI;
39 class CopasiSlider;
40 class CCopasiTask;
41 class CSlider;
42 class CopasiUI3Window;
43 
44 class SliderDialog: public CWindowInterface, public Ui::SliderDialog
45 {
46  Q_OBJECT
47 
48 public:
49  SliderDialog(QWidget* parent, const char* name = 0, bool modal = false, Qt::WFlags fl = 0);
50  virtual ~SliderDialog();
51  void addSlider(CSlider* slider);
52  void setCurrentFolderId(size_t id);
54 
55  // sets the framework on the sliders dialog
56  // This leads to changed sliders for metabolites
57  // Because depending on the framework, we only allow sliders
58  // for amount or concentration, but not both for the same metabolite
59  void setFramework(int index);
60 
61  // This methods needs to be called by copasiui3window
62  virtual void updateAllSliders();
63 
64  /**
65  * Deletes all exisiting sliders.
66  */
67  void clear();
68 
69  /**
70  * Resets the SliderDialog to its initial state.
71  * It basically calls clear and readds the Label
72  * for the task widgets that don't support sliders.
73  */
74  void reset();
75 
76  /**
77  * Returns whether the slider dialog contains changes.
78  */
79  bool isChanged() const;
80 
81  /**
82  * Sets the changed state of the SliderDialog.
83  */
84  void setChanged(bool changed);
85 
86  //return a pointer to this plot windows 'window' menu.
87  virtual QMenu *getWindowMenu() const;
88 
89 protected:
90  virtual void changeEvent(QEvent *);
91  virtual void showEvent(QShowEvent * pEvent);
92 
93  /**
94  * Deletes all sliders for the current folder id that
95  * are no longer valid.
96  */
97  void deleteInvalidSliders();
98 
99  size_t mapFolderId2EntryId(size_t folderId) const;
100 
101  void init();
102 
103  static size_t numMappings;
104  static size_t folderMappings[][2];
105 
106  virtual void contextMenuEvent(QContextMenuEvent* e);
107 
108  virtual void runTimeCourse();
109  virtual void runScanTask();
110  virtual void runSteadyStateTask();
111  virtual void runMCATask();
112  virtual void runLNATask();
113  virtual void runParameterEstimationTask();
114  virtual void runOptimizationTask();
115  virtual void runCrossSectionTask();
116  virtual void closeEvent(QCloseEvent* e);
117 
118  virtual CCopasiTask* getTaskForFolderId(size_t folderId);
119  std::vector<CSlider*>* getCSlidersForObject(CCopasiObject* pObject, std::vector<CSlider*>* pVector) const;
122  void clearSliderBox();
123  void createSlidersForFolder(std::vector<QWidget*>& v);
124  CopasiSlider *getCopasiSliderForCSlider(std::vector<QWidget*>& v, CSlider* slider);
125  CSlider *getCSliderForCopasiSlider(std::vector<CSlider*>& v, QWidget* slider);
126  void fillSliderBox();
127  std::vector<CSlider*>* getCSlidersForCurrentFolderId();
128  CopasiSlider* findCopasiSliderAtPosition(const QPoint& p);
129  void setCurrentSlider(CopasiSlider* pSlider);
130  virtual bool eventFilter(QObject*, QEvent* event);
131  bool sliderObjectChanged(CSlider* pSlider) const;
132 
133  // This method check if the given object is a reference to the initial amount or the initial concentration
134  // of a metabolite. Then it checks the current framework and the metabolite if a slider to the object
135  // is actually allowed and if it isn't, it will return the correct object
137 
138  /**
139  * Takes a CopasiSlider object and checks if the associated model object
140  * fits the currently set framework. If not, the slider object and the values are adjusted.
141  *
142  * On success, true is returned.
143  */
144  bool setCorrectSliderObject(CopasiSlider* pSlider);
145 
146 protected slots:
147  void removeSlider(CopasiSlider* slider);
148  void editSlider(CopasiSlider* slider);
149  void removeSlider();
150  void deleteSlider(CopasiSlider* pSlider);
151  void editSlider();
152  void createNewSlider();
153  void runTask();
154  void sliderValueChanged();
155  void sliderReleased();
156  void sliderPressed();
157  void resetValue();
158  void setDefault();
159 
160 protected:
164  QAction* mpaRemoveSlider;
165  QAction* mpaEditSlider;
166  QAction* mpaResetValue;
167  QAction* mpaSetDefault;
169  std::map< size_t, std::vector< QWidget* > > mSliderMap;
170  std::map < size_t, void(SliderDialog::*)() > mTaskMap;
175 
176  // stored whether the sliders have been changed
177  bool mChanged;
178 };
179 
180 #endif
bool mSliderValueChanged
Definition: SliderDialog.h:172
SliderDialog(QWidget *parent, const char *name=0, bool modal=false, Qt::WFlags fl=0)
bool mSliderPressed
Definition: SliderDialog.h:173
virtual void runLNATask()
void setFramework(int index)
CopasiSlider * findCopasiSliderAtPosition(const QPoint &p)
virtual void runParameterEstimationTask()
virtual void showEvent(QShowEvent *pEvent)
void setCurrentSlider(CopasiSlider *pSlider)
QAction * mpaEditSlider
Definition: SliderDialog.h:165
CSlider * equivalentSliderExists(CSlider *pCSlider)
std::map< size_t, void(SliderDialog::*)() > mTaskMap
Definition: SliderDialog.h:170
virtual void runCrossSectionTask()
bool setCorrectSliderObject(CopasiSlider *pSlider)
virtual void runScanTask()
virtual QMenu * getWindowMenu() const
CopasiSlider * mpCurrSlider
Definition: SliderDialog.h:168
QAction * mpaRemoveSlider
Definition: SliderDialog.h:164
virtual ~SliderDialog()
std::vector< CSlider * > * getCSlidersForCurrentFolderId()
std::map< size_t, std::vector< QWidget * > > mSliderMap
Definition: SliderDialog.h:169
virtual void runTimeCourse()
CSlider * getCSliderForCopasiSlider(std::vector< CSlider * > &v, QWidget *slider)
bool sliderObjectChanged(CSlider *pSlider) const
virtual void runMCATask()
size_t mCurrentFolderId
Definition: SliderDialog.h:171
void setCurrentFolderId(size_t id)
void createSlidersForFolder(std::vector< QWidget * > &v)
void sliderReleased()
virtual void closeEvent(QCloseEvent *e)
void deleteSlider(CopasiSlider *pSlider)
void fillSliderBox()
void setChanged(bool changed)
void setParentWindow(CopasiUI3Window *pPW)
void removeSlider()
void clearSliderBox()
bool isChanged() const
virtual void runSteadyStateTask()
QAction * mpaResetValue
Definition: SliderDialog.h:166
void sliderValueChanged()
CopasiUI3Window * mpParentWindow
Definition: SliderDialog.h:161
void deleteInvalidSliders()
QAction * mpaSetDefault
Definition: SliderDialog.h:167
CopasiSlider * findCopasiSliderForCSlider(CSlider *pCSlider)
void sliderPressed()
void createNewSlider()
static size_t numMappings
Definition: SliderDialog.h:103
bool fl(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
size_t mapFolderId2EntryId(size_t folderId) const
virtual CCopasiTask * getTaskForFolderId(size_t folderId)
void addSlider(CSlider *slider)
std::vector< CSlider * > * getCSlidersForObject(CCopasiObject *pObject, std::vector< CSlider * > *pVector) const
virtual void changeEvent(QEvent *)
virtual void updateAllSliders()
virtual void contextMenuEvent(QContextMenuEvent *e)
QAction * mpaCreateNewSlider
Definition: SliderDialog.h:163
const CCopasiObject * determineCorrectObjectForSlider(const CCopasiObject *pObject)
CopasiSlider * getCopasiSliderForCSlider(std::vector< QWidget * > &v, CSlider *slider)
QMenu * mpContextMenu
Definition: SliderDialog.h:162
virtual bool eventFilter(QObject *, QEvent *event)
static size_t folderMappings[][2]
Definition: SliderDialog.h:104
virtual void runOptimizationTask()