[go: up one dir, main page]

Menu

[6850b1]: / window.h  Maximize  Restore  History

Download this file

192 lines (160 with data), 7.2 kB

  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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#ifndef WINDOW_H
#define WINDOW_H
#include <QDesktopWidget>
#include <QWidget>
#include <QSlider>
#include <QTreeWidget>
#include <QHeaderView>
#include <QLayout>
#include <QLineEdit>
#include <QPushButton>
#include <QStackedWidget>
#include <QSpinBox>
#include <QDoubleSpinBox>
#include <QFrame>
#include <QTabWidget>
#include <QTextBrowser>
#include <QLinearGradient>
#include <QBrush>
#include <QFile>
#include <QLabel>
#include <QSizePolicy>
#include <QTextCursor>
#include <QColor>
#include <QDesktopServices>
#include <QUrl>
#include <QCheckBox>
#include <assert.h>
#include <sstream>
#include <iostream>
#include <iomanip>
#include "glwidget.h"
#include "widgetaddons.h"
#include "tutorial.h"
using namespace std;
class Window : public QWidget //, public QLayout
{
Q_OBJECT
public:
explicit Window(QWidget *parent = 0);
signals:
public slots:
void handleFirstRun(); // on first run of the program, automatically queue tutorial
// a request to advance the tutorial forward
// takes signal emitted by GlWidget when a tutorial stage is complete and needs automatic dialogue advance,
void advanceTutDialogue(bool fromSimulation);
// useful only if we are showing options from the lineedit: this feature is currently not present
void lineReceivedFocus();
// link manager
void linkClicked(const QUrl &link);
// control of buttons (possibly disabled) as GUI changes
void tabChanged(unsigned tabNum);
// handlers for button clicks
void switchToTiles();
void switchToBrush();
void pause();
void resume();
// multiple signals may be connected to this slot (our universal message displayer, if you will)
void displayError(string message);
// spinbox only:
// level of indirection required as spinBox's editingDone signal carries no information
// alternative to this mess is to subclass QSpinBox ... eh
void setXCen();
void setYCen();
void setPacketSpeed();
void setPacketAngle();
void setPacketPrecision();
// echo calls, to display changes back onto widget
void packetCenterChanged(QVector3D center);
void packetSpeedChanged(double speed);
void packetAngleChanged(double angle);
void packetPrecisionChanged(double precision);
// change text to match the tabs
void simulationStarted(); // first time pressing P
void resetOccurred(); // simulation is reset
void updateInfo(); // probability, energy, any useful information on the system...
private:
int previousArea = 0;
int targetHeight; // the height of the window
double scale; // calculated based on targetHeight/800.0
double initialWidth, initialHeight; // measured with dimensions of sideText
int currentTab = 0;
bool initialResize = true;
QVBoxLayout* tabOneLayout;
QVBoxLayout* tabTwoLayout;
QVBoxLayout* simulationTabLayout;
QHBoxLayout* hlayout;
QVector<QPushButton*> buttons; // make it easier to dynamically modify all of them
QColor grayBlue = QColor(39,83,122);
QTimer alarmClock; // rings every once in a while, uploads current probability value
QSlider* simSpeedSlider, *sensitivitySlider, *brushSizeSlider, *brushHeightSlider;
GLWidget* simulation;
LineEdit* editableLine, *probability, *simulationTime;
QTreeWidget* choicesPopup; // top-level popup
QPushButton* playButton, *restartButton, *switchToTilesButton;
QPushButton* switchToBrushButton, *observeButton, *pauseButton, *classicalButton;
QPushButton* observeFiller, *restartFiller; // these buttons don't do anything
// a toggle may be achieved by either pressing the button or moving to a tab that disables it
QStackedWidget* placementTogglers, *pauseTogglers, *observeTogglers, *restartTogglers;
QDoubleSpinBox *speed, *angle, *xCen, *yCen, *precision;
QTabWidget* tabs, *simTabs;
QWidget* tabOne, *tabTwo, *tabThree; // displayed only in setup stage
QWidget* simulationTab; // simulationTab is displayed only after simulation has started
QWidget* buttonPanel;
QTextBrowser* sideText, *tutText;
QWidget* sideTextContainer;
QTimer startTutorialTimer; // will call handlFirstRun upon timeout
// labelled versions (after pairing original widgets with a QLabel)
// I do not approve of the -Widget suffix, but also at lost for a better word ...
// -Labelled perhaps?
QWidget* speedWidget, *angleWidget, *xCenWidget, *yCenWidget, *precisionWidget;
QWidget* simSpeedSliderWidget, *sensitivitySliderWidget, *placementTogglersWidget, *simulationTimeWidget;
QWidget* brushSizeSliderWidget, *brushHeightSliderWidget, *probabilityWidget, *showClassicalWidget;
QHBoxLayout* buttonPanelLayout;
QVBoxLayout* sideBarLayout;
QStackedLayout* sideBarTopLayout; // tabs and simulation panel
QString projectOverview;
QString tabOneHelp, tabTwoHelp, tabThreeHelp, simulationHelp, generalControls;
QString speedTip, angleTip, centerTip, precisionTip, equationTip, brushSizeTip, brushHeightTip;
QString timeTip, probabilityTip, speedupTip, sensitivityTip;
QString observeTip, classicalTip, restartTip, fillerTip, continuousTip, discreteTip;
QString styleSheet;
QString tabOneText, tabTwoText, simulationTabText, credits, accuracy, instructions;
QVector<QString> choices;
QVector<QString*> allHelpText;
// parameters/keywords to replace in css code at run-time
int ttFontSizeVal, sFontSizeVal, msFontSizeVal, mFontSizeVal, lFontSizeVal, xlFontSizeVal;
int ttTableWidthVal, tableWidthVal, sliderHeightVal, borderRadiusVal, handleHeightVal, halfHandleHeightVal, scrollbarWidthVal;
QString ttFontSize, sFontSize, msFontSize, mFontSize, lFontSize, xlFontSize;
QString ttTableWidth, tableWidth, sliderHeight, borderRadius, handleHeight, halfHandleHeight, scrollbarWidth;
Tutorial tutorial;
// functions
void setObjectNames(); // to help link things with stylesheet
void applyExpandingTabsStyle(); // applies to member 'tabs'
void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
void rescaleFonts(double scaling);
void rescaleButtons(double scaling);
void clearLayout(QLayout* layout);
void createSpinBoxes();
void createButtons();
void createSimSpeedSlider();
void createSensitivitySlider();
void createBrushSizeSlider();
void createBrushHeightSlider();
void createEditableLine();
void createInfoAndTimeLine();
//void createChoicesPopup();
void createTabs();
// returns a widget containing current widget + label on its left
QWidget* addLabel(QWidget* noName, string name, QString toolTip = "None");
void initFonts(); // dependent on screen size
void initStrings();
QDoubleSpinBox* createSpinBox(double min, double max, double initial = 0);
void createTextBox();
void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
void setEquation() { simulation->setEquation(editableLine->text());}
//void setShadow(QWidget* target);
};
#endif // WINDOW_H