COPASI API  4.16.103
CQNewMainWindow.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 #ifndef CQNEWMAINWINDOW_H__
7 #define CQNEWMAINWINDOW_H__
8 
9 #include <UI/CWindowInterface.h>
10 #include <QtCore/QString>
11 #include <QtGui/QIcon>
12 #include <QtCore/QRectF>
13 #include <string>
14 #include <vector>
15 #include <set>
16 
17 class CCopasiDataModel;
18 class CLayout;
20 class CLGraphicalObject;
21 class CQLayoutMainWindow;
22 class CQGLLayoutViewer;
23 class QAction;
24 class QActionGroup;
25 class QCloseEvent;
26 class QComboBox;
27 class QLabel;
28 class QMenu;
29 class QStackedWidget;
30 class QToolBar;
31 class CFluxMode;
32 class CReaction;
33 class CMetab;
34 
35 #include "copasi/copasi.h"
39 
40 class CCompartment;
41 class CCopasiObject;
42 class CLayout;
43 class CModel;
44 class CLCompartmentGlyph;
45 class CLMetabGlyph;
46 class CLTextGlyph;
47 class CQLayoutThread;
48 
50 {
51  Q_OBJECT
52 
53 public:
54 
56  {
59  };
60 
61  void setMode(DISPLAY_MODE mode = GRAPH_MODE);
62 
64  {
65  ROLE_UNSPECIFIED = 1 // metab reference glyphs without role
73  , REACTION_GLYPH = 256 // the reaction glyph itself
75  };
76 
77  CQNewMainWindow(CCopasiDataModel* pDatamodel);
78  virtual ~CQNewMainWindow();
79 
80  virtual QMenu *getWindowMenu() const;
81 
82  void updateRenderer();
83 protected:
84 
86 
88 
90 
91  void change_style(bool defaultStyle = false);
92 
93  void resetView();
94 
95 public slots:
96  void slotLayoutChanged(int index);
97 
98  void slotResetView();
99 
100  /**
101  * This slot is called when the "Fit To Screen" menu item
102  * is activated.
103  */
104  void slotFitToScreen();
105 
106  void slotRenderInfoChanged(int index);
107  void slotZoomChanged(int index);
108  void slotZoomMenuItemActivated(QAction*);
109 
110  /**
111  * This slot is called when the selection is changed and
112  * only a single curve is selected.
113  */
114  void slotSingleCurveSelected(bool selected);
115 
116  /**
117  * This slot initiates the export
118  * of the layout as a bitmap.
119  * The user gets to choose which part of the
120  * layout is to be exported and how large the
121  * resulting bitmap is supposed to be.
122  */
123  void slotScreenshot();
124 
125  /**
126  * exports a bit map of the currently displayed image with the given scale.
127  */
128  void export_bitmap(const QString& filename, double scale = 4.0);
129 
130  /**
131  * Exports a bitmap of the given size to
132  * the file with the given name.
133  */
134  void export_bitmap(const QString& filename, double x, double y, double width, double height, unsigned int imageWidth, unsigned int imageHeight, bool drawSelection);
135 
136  /**
137  * Fills the layout dropdown list.
138  */
139  void updateLayoutList();
140 
141  /**
142  * switches the display mode between animation mode and
143  * graph mode.
144  */
145  void switchMode();
146 
147  /**
148  * Change the status message.
149  */
150  void setStatusMessage(const QString& message, int timeout);
151 
152  /**
153  * Selects the given reaction object by selecting all
154  * corresponding CLReactionGlyph objects in the current layout.
155  * The mask determines which parts of the reaction are selected.
156  * With this, it can be specified that only the reaction glyph itself
157  * or the reaction glyph plus several of the associated metab reference glyphs
158  * are selected.
159  * The graphical objects selected by this method are inserted into the
160  * set given as the third element.
161  */
162  void selectReaction(const CReaction* pReaction, unsigned int selectionMask, std::set<const CLGraphicalObject*>& s);
163 
164  /**
165  * Selected the given metabolite object by selecting all
166  * corresponding CLMetabGlyph objects in the current layout.
167  * The graphical objects selected by this method are inserted into the
168  * set given as the third element.
169  */
170  void selectMetabolite(const CMetab* pMetab, std::set<const CLGraphicalObject*>& s);
171 
172  /**
173  * Is called when the menu entry for toggling highlighting
174  * of elementary modes is toggled.
175  */
176  void toggleHighlightSlot(bool checked);
177 
178  /**
179  * Checks for calculated elementary modes.
180  */
182 
183  /**
184  * Checks which elementary mode has been toggled and updates the
185  * highlighted objects list.
186  */
187  void elementaryModeTriggeredSlot(QAction* pAction);
188 
189  /**
190  * This slot is triggered when the user wants to change
191  * the fog or the highlighting color, depending on the current
192  * highlighting mode.
193  */
194  void changeColorSlot(bool);
195 
196  /**
197  * Lets the user change the percentage of fog
198  * that is added to the color.
199  */
200  void fogDensitySlot(bool);
201 
202  virtual void closeEvent(QCloseEvent * event);
203 
204 #ifdef INCLUDE_UNUSED_CODE
205 
206  /**
207  * Creates a CLMetabGlyph for the given CMetab object.
208  * If the creation failed, a NULL pointers is returned.
209  */
210  static CLMetabGlyph* createMetabGlyph(const std::string& modelobjectkey, double width, double height);
211 
212  /**
213  * Creates a CLTextGlyph for the given graphical object keys and size.
214  */
215  static CLTextGlyph* createTextGlyph(const std::string& modelobjectkey, const std::string& objectkey, double width, double height);
216 
217  /**
218  * Creates a CLCompartmentGlyph for the given size and position
219  */
220  static CLCompartmentGlyph* createCompartmentGlyph(const std::string& modelobjectkey, double x, double y, double width, double height);
221 
222  /**
223  * Creates a CLReactionGlyph for the given size and position
224  */
225  static CLReactionGlyph* createReactionGlyph(const std::string& modelobjectkey, double x, double y, double length);
226 
227  /**
228  * Creates a CLMetabReferenceGlyph for the given endpoints.
229  */
230  static CLMetabReferenceGlyph* createMetabReferenceGlyph(const std::string& modelobjectkey,
231  const std::string& metabglyphkey,
233  double x1, double y1, double x2, double y2);
234 #endif //INCLUDE_UNUSED_CODE
235 
236 public slots:
237  void slotRunSpringLayout();
238 
239 protected slots:
240  /**
241  * This slot is called when the stop button is presed.
242  * It notifies the layout method to stop the spring layout iterations.
243  */
244  void slotStopClicked();
245 
246  void slotRunRandomizeLayout();
247 
249 
250 private:
251 
252  void createActions();
253  void createMenus();
254  void createToolBars();
255  void createStatusBar();
256  void setAnimationToolbar();
257  void setGraphToolbar();
258  void setAnimationMenu();
259  void setGraphMenu();
260 
262  QStackedWidget* mpWidgetStack;
263  QMenu *mpFileMenu;
264  QMenu *mpPlayMenu;
265  QMenu *mpLayoutMenu;
266  QMenu *mpViewMenu;
268  QMenu *mpWindowMenu;
269  QMenu *mpZoomMenu;
271  QToolBar *mpFileToolBar;
273  QAction *mpSwitchModeAct;
275  QAction *mpCloseAct;
276  QAction *mpScreenshotAct;
277  QAction *mpLoadDataAct;
278  QAction *mpCircularShape;
280  QAction *mpMimaNodeSizes;
281  QAction *mpSFontSize;
283  QActionGroup* mpZoomActionGroup;
287  QComboBox* mpLayoutDropdown;
288  QComboBox* mpRenderDropdown;
289  QComboBox* mpZoomDropdown;
291  QLabel* mpRenderLabel;
294 
295  static const char* const ZOOM_FACTOR_STRINGS[];
296  static const double ZOOM_FACTORS[];
297 
298  std::string mCurDir;
299 
300  QIcon mGraphIcon;
302 
304  {
305  std::string mReactionKey;
306  unsigned int mSelectionMask;
307 
308  bool operator<(const REACTION_SELECTION_ITEM& other) const
309  {
310  // The reaction key needs to be unique.
311  // There should be no two entries with the same key.
312  bool result = (this->mReactionKey < other.mReactionKey);
313  return result;
314  }
315  };
316 
317  // we need to store the highlighted reactions and the
318  // highlighted metabolites in two different structures
319  // because the reaction highlighting mechanism is a bit
320  // more complicated
321  std::set<std::string> mHighlightedMetabolites;
322  std::set<REACTION_SELECTION_ITEM> mHighlightedReactions;
323 
324  // It does not make sense to update
325  // the elementary flux modes menu each time
326  // because that will delete the information about
327  // selected modes.
328  // We have to remember the modes and only update if necessary.
329  std::vector<const CFluxMode*> mFluxModes;
330 
331  // we need two icons for the fog and
332  // the highlight color
338 
342 
343 public slots:
344  void slotLayoutFinished();
345  void slotLayoutStateChanged(QSharedPointer<CLayoutState> state);
346 
347 public:
348  void redrawNow();
349 
350  void randomizeLayout();
351 
352  /**
353  * Creates a spring layout.
354  * The method takes the number of iterations for the
355  * layout algorithm and an update interval which tells the algorithm
356  * how often to update the display.
357  * A value of -1 means that the update of the display is only done once
358  * at the end.
359  */
360  void createSpringLayout(int numIterations, int updateInterval);
361 
362 protected:
363  /** the layout thread */
365 
366  /** the copy on which the layout operates */
368 };
369 
370 #endif /* CQNEWMAINWINDOW_H__ */
void export_bitmap(const QString &filename, double scale=4.0)
QAction * mpChangeColorAction
void setStatusMessage(const QString &message, int timeout)
QPixmap * mpFogColorPixmap
QAction * mpCloseAct
QAction * mpRevertCurveAct
void slotLayoutChanged(int index)
std::set< std::string > mHighlightedMetabolites
void fogDensitySlot(bool)
QLabel * mpRenderLabel
QComboBox * mpRenderDropdown
void elementaryModeTriggeredSlot(QAction *pAction)
CQNewMainWindow(CCopasiDataModel *pDatamodel)
QAction * mpStopLayoutAction
void slotLayoutStateChanged(QSharedPointer< CLayoutState > state)
QAction * mpRectangularShape
CLayout * mpCurrentLayout
CQLayoutThread * mpLayoutThread
QAction * mpScreenshotAct
void setMode(DISPLAY_MODE mode=GRAPH_MODE)
void selectMetabolite(const CMetab *pMetab, std::set< const CLGraphicalObject * > &s)
std::vector< const CFluxMode * > mFluxModes
bool operator<(const REACTION_SELECTION_ITEM &other) const
void selectReaction(const CReaction *pReaction, unsigned int selectionMask, std::set< const CLGraphicalObject * > &s)
QAction * mpLoadDataAct
Definition: CMetab.h:178
QActionGroup * mpZoomActionGroup
QAction * mpLoopItemAction
QComboBox * mpZoomDropdown
CCopasiDataModel * mpDataModel
CLRenderInformationBase * mpCurrentRenderInformation
virtual void closeEvent(QCloseEvent *event)
virtual ~CQNewMainWindow()
void change_style(bool defaultStyle=false)
QPixmap * mpHighlightColorPixmap
QAction * mpCircularShape
QToolBar * mpSelectionToolBar
QComboBox * mpLayoutDropdown
void slotSingleCurveSelected(bool selected)
CQLayoutMainWindow * mpAnimationWindow
std::set< REACTION_SELECTION_ITEM > mHighlightedReactions
void changeColorSlot(bool)
virtual QMenu * getWindowMenu() const
void slotZoomChanged(int index)
void createSpringLayout(int numIterations, int updateInterval)
void addGlobalRenderInfoItemsToList()
void updateRenderInformationList()
QToolBar * mpFileToolBar
QAction * mpHighlightModeAction
DISPLAY_MODE mMode
void toggleHighlightSlot(bool checked)
QAction * mpSFontSize
void addDefaultRenderInfoItemsToList()
QMenu * mpElementaryModesMenu
std::string mCurDir
QAction * mpRandomizeLayout
QAction * mpFogDensityAction
QAction * mpCalculateDimensions
void slotZoomMenuItemActivated(QAction *)
QAction * mpMimaNodeSizes
Definition: CModel.h:50
CQGLLayoutViewer * mpLayoutViewer
void checkForElementaryModesSlot()
QStackedWidget * mpWidgetStack
static const double ZOOM_FACTORS[]
void slotRenderInfoChanged(int index)
static const char *const ZOOM_FACTOR_STRINGS[]
QAction * mpSwitchModeAct