1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
// Copyright 2007 Nanorex, Inc. See LICENSE file for details.
#ifndef TRAJECTORYGRAPHICSWINDOW_H
#define TRAJECTORYGRAPHICSWINDOW_H
#include "Nanorex/Interface/NXEntityManager.h"
#include "Nanorex/Interface/NXGraphicsManager.h"
#include "Nanorex/Interface/NXRenderingEngine.h"
#include "Nanorex/Interface/NXSceneGraph.h"
#include "Nanorex/Interface/NXNamedView.h"
#include "DataWindow.h"
using namespace Nanorex;
#include <QWidget>
#include <QButtonGroup>
#include <ui_TrajectoryGraphicsWindow.h>
#include <vector>
// #include "TrajectoryGraphicsWindowPlayback_sm.h"
/* CLASS: TrajectoryGraphicsWindow */
class TrajectoryGraphicsWindow
: public DataWindow, private Ui::TrajectoryGraphicsWindow {
// friend class TrajectoryGraphicsWindowPlaybackContext;
Q_OBJECT;
protected:
enum RepetitionMode {
NO_REPETITION=0, LOOP_REPETITION=1, OSCILLATE_REPETITION=2
};
enum FrameAdvanceMode {AUTO_FRAME_ADVANCE=0, MANUAL_FRAME_ADVANCE=1};
public:
TrajectoryGraphicsWindow(QWidget *parent,
NXEntityManager *entityManager,
NXGraphicsManager *graphicsManager);
~TrajectoryGraphicsWindow();
// void setEntityManager(NXEntityManager* entityManager) {
// this->entityManager = entityManager;
// }
//
// void setGraphicsManager(NXGraphicsManager* graphicsManager) {
// this->graphicsManager = graphicsManager;
// renderingEngine = graphicsManager->newGraphicsInstance(this);
// /// @todo move to .cpp file and initialize plugins in this context
// }
// void setRenderingEngine(NXRenderingEngine *renderingEngine) {
// this->renderingEngine = renderingEngine;
// }
void setFrameSetId(int frameSetId);
void setNamedView(Nanorex::NXNamedView const& view) {
renderingEngine->setNamedView(view);
}
void resetView(void) { renderingEngine->resetView(); }
signals:
void beginFrameChanged(int);
void endFrameChanged(int);
void currentFrameChanged(int);
void beginFrameReached(void);
void endFrameReached(void);
public slots:
void newFrame(int frameSetId, int newFrameIndex,
NXMoleculeSet* newMoleculeSet);
protected slots:
// slots named as per QMetaObject's auto-connection nomenclature
// ** Do not rename **
// ref: Qt Designer manual, section "Using a component in your application"
// widget update slots
void on_beginFrameSpinBox_valueChanged(int);
void on_endFrameSpinBox_valueChanged(int);
void on_currentFrameSpinBox_valueChanged(int);
void on_trajectoryPlusFiveButton_clicked(bool);
void on_trajectoryMinusFiveButton_clicked(bool);
void on_trajectoryFirstButton_clicked(bool);
void on_trajectoryLastButton_clicked(bool);
void on_playbackSpeedSpinBox_valueChanged(int value);
void on_trajectoryPlayRevButton_toggled(bool checked);
// void on_trajectoryPauseButton_toggled(bool checked);
void on_trajectoryStopButton_clicked(bool);
void on_trajectoryPlayButton_toggled(bool checked);
// non-QMetaObject slots: note nomenclature difference
void onFrameAdvanceButtonGroupButtonClicked(int frameAdvanceMode);
void onRepetitionButtonGroupButtonClicked(int repetitionMode);
// slots to handle repetition behavior
void onBeginFrameReached(void);
void onEndFrameReached(void);
// slots extending functionality
// current frame spin box and slider updates to visual
void setCurrentFrameIndex(int frameIndex);
// auto-play timer signals to update visual
void autoPlayFrameAdvance(void);
protected:
// TrajectoryGraphicsWindowPlaybackContext playbackContext;
NXEntityManager* entityManager;
NXGraphicsManager* graphicsManager;
int frameSetId;
///< index of frame-set in entity-manager corresponding to this trajectory
NXRenderingEngine *renderingEngine;
QButtonGroup *repetitionButtonGroup;
QButtonGroup *frameAdvanceButtonGroup;
RepetitionMode repetitionMode;
FrameAdvanceMode frameAdvanceMode;
QTimer *autoPlayTimer;
/// Are we animating backwards at this time?
bool playing; ///< is the animation currently playing?
bool reversed; ///< if playing, is animation being played in reverse?
int beginFrameIndex; ///< index of first frame in user-defined view-interval
int currentFrameIndex; ///< index of frame currently being displayed
int endFrameIndex; ///< index of last frame in user-defined view-interval
int numFrames; ///< Total number of frames
static double const BASE_FPS;
void enablePlayButton(void) { trajectoryPlayButton->setEnabled(true); }
void disablePlayButton(void) { trajectoryPlayButton->setEnabled(false); }
void enablePlayReverseButton(void) { trajectoryPlayRevButton->setEnabled(true); }
void disablePlayReverseButton(void) { trajectoryPlayRevButton->setEnabled(false); }
void releasePlayButton(void) { trajectoryPlayButton->setChecked(false); }
void pressPlayReverseButton(void) { trajectoryPlayButton->setChecked(true); }
void releasePlayReverseButton(void) { trajectoryPlayRevButton->setChecked(false); }
// void releasePauseButton(void) { trajectoryPauseButton->setChecked(false); }
void pausePlay(void) { autoPlayTimer->stop(); }
void pausePlayReverse(void) { autoPlayTimer->stop(); }
void setSpinBoxValues(int beginMin, int beginVal, int beginMax,
int current, int endMin, int endVal, int endMax);
void setMaxFrameNumber(int maxFrameNumber);
private:
void connectSignalsAndSlots(void);
void setupButtonGroups(void);
bool createRenderingEngine(void);
bool createAnimation(void);
};
#endif
|