mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-04 18:11:01 -05:00
Added style sheet to timeline application
Fixed various layout issues
This commit is contained in:
@@ -25,33 +25,41 @@
|
||||
#include "configurationwidget.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
#include <QTimer>
|
||||
#include <QDebug>
|
||||
|
||||
ConfigurationWidget::ConfigurationWidget(QWidget* parent)
|
||||
: QGroupBox("Connection", parent)
|
||||
: QWidget(parent)
|
||||
, _ipAddress(new QLineEdit("localhost"))
|
||||
, _port(new QLineEdit("20500"))
|
||||
, _connect(new QPushButton("Connect"))
|
||||
{
|
||||
_connect->setObjectName("connection");
|
||||
QGroupBox* box = new QGroupBox("Connection", this);
|
||||
|
||||
QGridLayout* layout = new QGridLayout;
|
||||
layout->setVerticalSpacing(0);
|
||||
{
|
||||
QLabel* t = new QLabel("IP Address");
|
||||
t->setObjectName("label");
|
||||
layout->addWidget(t, 0, 0);
|
||||
}
|
||||
layout->addWidget(_ipAddress, 1, 0);
|
||||
|
||||
{
|
||||
QLabel* t = new QLabel("Port");
|
||||
t->setObjectName("label");
|
||||
layout->addWidget(t, 0, 1);
|
||||
}
|
||||
layout->addWidget(_port, 1, 1);
|
||||
layout->addWidget(_connect, 1, 2, 1, 1);
|
||||
|
||||
setLayout(layout);
|
||||
box->setLayout(layout);
|
||||
|
||||
QHBoxLayout* l = new QHBoxLayout;
|
||||
l->addWidget(box);
|
||||
setLayout(l);
|
||||
QObject::connect(_connect, SIGNAL(clicked()), this, SLOT(onConnectButton()));
|
||||
|
||||
QTimer::singleShot(100, this, SLOT(onConnectButton()));
|
||||
|
||||
@@ -25,12 +25,11 @@
|
||||
#ifndef __CONFIGURATIONWIDGET_H__
|
||||
#define __CONFIGURATIONWIDGET_H__
|
||||
|
||||
#include <QGroupBox>
|
||||
//#include <QWidget>
|
||||
#include <QWidget>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
|
||||
class ConfigurationWidget : public QGroupBox {
|
||||
class ConfigurationWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfigurationWidget(QWidget* parent);
|
||||
|
||||
@@ -65,7 +65,6 @@ namespace {
|
||||
{ "Pluto", "PlutoProjection", "Pluto" },
|
||||
{ "Charon", "Charon", "Pluto" },
|
||||
{ "Jupiter", "JupiterProjection", "Jupiter" },
|
||||
{ "New Horizons", "NewHorizons", "" },
|
||||
{ "Nix", "Nix", "Pluto" },
|
||||
{ "Kerberos", "Kerberos", "Pluto" },
|
||||
{ "Hydra", "Hydra", "Pluto" },
|
||||
@@ -74,15 +73,22 @@ namespace {
|
||||
|
||||
ControlWidget::ControlWidget(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, _currentTime(new QLabel("Current Time"))
|
||||
, _currentTime(new QLabel(""))
|
||||
, _setTime(new QComboBox)
|
||||
, _currentDelta(new QLabel("Current Delta"))
|
||||
, _currentDelta(new QLabel(""))
|
||||
, _setDelta(new QSlider(Qt::Horizontal))
|
||||
, _pause(new QPushButton("||"))
|
||||
, _play(new QPushButton("|>"))
|
||||
, _pause(new QPushButton("Pause"))
|
||||
, _play(new QPushButton("Play"))
|
||||
, _focusNode(new QComboBox)
|
||||
, _setFocusToNextTarget(new QPushButton("Set Focus to the next Target"))
|
||||
, _setFocusToNewHorizons(new QPushButton("Set Focus to New Horizons"))
|
||||
{
|
||||
_pause->setObjectName("pause");
|
||||
_play->setObjectName("play");
|
||||
|
||||
_currentTime->setObjectName("value");
|
||||
_currentDelta->setObjectName("value");
|
||||
|
||||
for (const ImportantDate& d : ImportantDates)
|
||||
_setTime->addItem(d.date);
|
||||
QObject::connect(
|
||||
@@ -132,6 +138,13 @@ ControlWidget::ControlWidget(QWidget* parent)
|
||||
SLOT(onFocusToTargetButton())
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
_setFocusToNewHorizons,
|
||||
SIGNAL(clicked()),
|
||||
this,
|
||||
SLOT(onFocusToNewHorizonsButton())
|
||||
);
|
||||
|
||||
QVBoxLayout* mainLayout = new QVBoxLayout;
|
||||
|
||||
{
|
||||
@@ -143,25 +156,30 @@ ControlWidget::ControlWidget(QWidget* parent)
|
||||
|
||||
{
|
||||
QLabel* l = new QLabel("Current Time (UTC):");
|
||||
l->setObjectName("label");
|
||||
layout->addWidget(l, 0, 0, Qt::AlignLeft);
|
||||
layout->addWidget(_currentTime, 0, 1, Qt::AlignRight);
|
||||
}
|
||||
{
|
||||
QLabel* l = new QLabel("Bookmarks:");
|
||||
QLabel* l = new QLabel("Bookmarked Times:");
|
||||
l->setObjectName("label");
|
||||
layout->addWidget(l, 1, 0, Qt::AlignLeft);
|
||||
layout->addWidget(_setTime, 1, 1, Qt::AlignRight);
|
||||
}
|
||||
layout->addItem(new QSpacerItem(0, 7), 2, 0, 1, 2);
|
||||
{
|
||||
QLabel* l = new QLabel("Current Time Increment (seconds per second):");
|
||||
QLabel* l = new QLabel("Current Time Increment\n(seconds per second):");
|
||||
l->setObjectName("label");
|
||||
layout->addWidget(l, 3, 0, Qt::AlignLeft);
|
||||
layout->addWidget(_currentDelta, 3, 1, Qt::AlignRight);
|
||||
}
|
||||
|
||||
_setDelta->setObjectName("background");
|
||||
layout->addWidget(_setDelta, 4, 0, 1, 2);
|
||||
|
||||
|
||||
QWidget* controlContainer = new QWidget;
|
||||
controlContainer->setObjectName("background");
|
||||
QHBoxLayout* controlContainerLayout = new QHBoxLayout;
|
||||
controlContainerLayout->addWidget(_pause);
|
||||
controlContainerLayout->addWidget(_play);
|
||||
@@ -178,11 +196,13 @@ ControlWidget::ControlWidget(QWidget* parent)
|
||||
|
||||
{
|
||||
QLabel* l = new QLabel("Set Focus:");
|
||||
l->setObjectName("label");
|
||||
layout->addWidget(l, 0, 0, Qt::AlignLeft);
|
||||
_focusNode->setMinimumWidth(200);
|
||||
layout->addWidget(_focusNode, 0, 1, Qt::AlignRight);
|
||||
}
|
||||
layout->addWidget(_setFocusToNextTarget, 1, 0, 1, 2);
|
||||
layout->addWidget(_setFocusToNewHorizons, 2, 0, 1, 2);
|
||||
|
||||
mainLayout->addWidget(box);
|
||||
}
|
||||
@@ -191,6 +211,7 @@ ControlWidget::ControlWidget(QWidget* parent)
|
||||
}
|
||||
|
||||
void ControlWidget::update(QString currentTime, QString currentDelta) {
|
||||
currentTime.replace("T", " ");
|
||||
_currentTime->setText(currentTime);
|
||||
_currentDelta->setText(currentDelta);
|
||||
}
|
||||
@@ -244,16 +265,6 @@ void ControlWidget::onFocusChange() {
|
||||
int index = _focusNode->currentIndex();
|
||||
QString name = FocusNodes[index].name;
|
||||
QString coordinateSystem = FocusNodes[index].coordinateSystem;
|
||||
if (coordinateSystem.isEmpty()) {
|
||||
int date = _currentTime->text().left(4).toInt();
|
||||
if (date < 2008)
|
||||
coordinateSystem = "Jupiter";
|
||||
else if (date < 2014)
|
||||
coordinateSystem = "Sun";
|
||||
else
|
||||
coordinateSystem = "Pluto";
|
||||
|
||||
}
|
||||
QString script = "openspace.setOrigin('" + name + "');openspace.changeCoordinateSystem('" + coordinateSystem + "');";
|
||||
emit scriptActivity(script);
|
||||
}
|
||||
@@ -271,6 +282,21 @@ void ControlWidget::onFocusToTargetButton() {
|
||||
}
|
||||
}
|
||||
|
||||
void ControlWidget::onFocusToNewHorizonsButton() {
|
||||
QString coordinateSystem;
|
||||
int date = _currentTime->text().left(4).toInt();
|
||||
if (date < 2008)
|
||||
coordinateSystem = "Jupiter";
|
||||
else if (date < 2014)
|
||||
coordinateSystem = "Sun";
|
||||
else
|
||||
coordinateSystem = "Pluto";
|
||||
|
||||
|
||||
QString script = "openspace.setOrigin('NewHorizons');openspace.changeCoordinateSystem('" + coordinateSystem + "');";
|
||||
emit scriptActivity(script);
|
||||
}
|
||||
|
||||
void ControlWidget::socketConnected() {
|
||||
setDisabled(false);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ private slots:
|
||||
void onPauseButton();
|
||||
void onPlayButton();
|
||||
void onFocusToTargetButton();
|
||||
void onFocusToNewHorizonsButton();
|
||||
|
||||
private:
|
||||
QLabel* _currentTime;
|
||||
@@ -62,6 +63,7 @@ private:
|
||||
QPushButton* _play;
|
||||
QComboBox* _focusNode;
|
||||
QPushButton* _setFocusToNextTarget;
|
||||
QPushButton* _setFocusToNewHorizons;
|
||||
};
|
||||
|
||||
#endif // __CONTROLWIDGET_H__
|
||||
|
||||
+116
-1
@@ -23,15 +23,130 @@
|
||||
****************************************************************************************/
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
//static const QString style = "background: grey";
|
||||
static const QString style = R"style(
|
||||
QWidget {
|
||||
background-color: rgb(100, 100, 100);
|
||||
font-family: Helvetica;
|
||||
}
|
||||
|
||||
QGroupBox {
|
||||
background-color: qlineargradient(
|
||||
x1: 0, y1: 0, x2: 0, y2: 1,
|
||||
stop: 0 #a8a8a8,
|
||||
stop: 1 #d5d5d5);
|
||||
border: 2px solid gray;
|
||||
border-radius: 5px;
|
||||
margin-top: 4ex;
|
||||
font-size: bold 12px;
|
||||
}
|
||||
|
||||
QGroupBox::title {
|
||||
background-color: #E0E0E0;
|
||||
border: 2px solid gray;
|
||||
border-radius: 5px;
|
||||
subcontrol-origin: margin;
|
||||
subcontrol-position: top center;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
QSlider::groove:horizontal {
|
||||
border: 1px solid #999999;
|
||||
height: 8px; /* the groove expands to the size of the slider by default. by giving it a height, it has a fixed size */
|
||||
background: qlineargradient(
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #c4c4c4,
|
||||
stop:0.5 #888888,
|
||||
stop:1 #c4c4c4
|
||||
);
|
||||
margin: 2px 0;
|
||||
}
|
||||
|
||||
QSlider::handle:horizontal {
|
||||
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f);
|
||||
border: 1px solid #5c5c5c;
|
||||
width: 18px;
|
||||
margin: -2px 0; /* handle is placed by default on the contents rect of the groove. Expand outside the groove */
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
QPushButton {
|
||||
background-color: lightgray;
|
||||
border-style: outset;
|
||||
border-width: 0.5px;
|
||||
border-radius: 5px;
|
||||
border-color: black;
|
||||
font: bold 12px;
|
||||
min-width: 10em;
|
||||
}
|
||||
|
||||
QPushButton#connection {
|
||||
background-color: lightgreen;
|
||||
}
|
||||
|
||||
QPushButton#connection:pressed {
|
||||
background-color: green;
|
||||
}
|
||||
|
||||
|
||||
QPushButton#pause, QPushButton#play {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
QPushButton#pause:pressed, QPushButton#play:pressed, QPushButton:pressed {
|
||||
background-color: darkgray;
|
||||
border-style: inset;
|
||||
}
|
||||
|
||||
QCombobox {
|
||||
border: 1px solid gray;
|
||||
border-radius: 3px;
|
||||
padding: 1px 18px 1px 3px;
|
||||
min-width: 6em;
|
||||
}
|
||||
|
||||
QComboBox:editable {
|
||||
background: lightgrey;
|
||||
}
|
||||
|
||||
QComboBox QAbstractItemView {
|
||||
border: 2px solid darkgray;
|
||||
border-radius: 5px;
|
||||
background-color: #a8a8a8;
|
||||
selection-background-color: #a8a8a8;
|
||||
}
|
||||
|
||||
QLabel#label {
|
||||
font-size: 13px;
|
||||
background-color: transparent;
|
||||
font-variant: small-caps;
|
||||
}
|
||||
|
||||
QLabel#value {
|
||||
font-family: monospace;
|
||||
font-weight: bold;
|
||||
font-size: 14px;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
QWidget#background {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
QTextEdit {
|
||||
font-family: monospace;
|
||||
}
|
||||
)style";
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
QApplication app(argc, argv);
|
||||
|
||||
app.setStyleSheet(style);
|
||||
|
||||
std::string s = style.toStdString();
|
||||
|
||||
MainWindow window;
|
||||
window.show();
|
||||
|
||||
|
||||
@@ -70,8 +70,11 @@ MainWindow::MainWindow()
|
||||
setWindowTitle("OpenSpace Timeline");
|
||||
|
||||
_configurationWidget = new ConfigurationWidget(this);
|
||||
_configurationWidget->setMinimumWidth(350);
|
||||
_timeControlWidget = new ControlWidget(this);
|
||||
_timeControlWidget->setMinimumWidth(350);
|
||||
_informationWidget = new InformationWidget(this);
|
||||
_informationWidget->setMinimumWidth(350);
|
||||
_timelineWidget = new TimelineWidget(this);
|
||||
|
||||
QGridLayout* layout = new QGridLayout;
|
||||
@@ -80,6 +83,8 @@ MainWindow::MainWindow()
|
||||
layout->addWidget(_informationWidget, 2, 0);
|
||||
layout->addWidget(_timelineWidget, 0, 1, 3, 1);
|
||||
|
||||
layout->setColumnStretch(1, 5);
|
||||
|
||||
|
||||
QObject::connect(
|
||||
_configurationWidget, SIGNAL(connect(QString, QString)),
|
||||
@@ -160,7 +165,7 @@ void MainWindow::readTcpData() {
|
||||
size_t beginning = 0;
|
||||
uint32_t size = readFromBuffer<uint32_t>(data.mid(2).data(), beginning);
|
||||
|
||||
while (_socket->waitForReadyRead() && data.size() < size) {
|
||||
while (_socket->waitForReadyRead() && data.size() < int(size)) {
|
||||
data = data.append(_socket->readAll());
|
||||
QThread::msleep(50);
|
||||
}
|
||||
|
||||
@@ -50,29 +50,6 @@ namespace {
|
||||
QColor(84, 79, 149),
|
||||
QColor(203, 153, 200),
|
||||
QColor(82, 145, 57)
|
||||
|
||||
//QColor(166, 206, 227),
|
||||
//QColor(31, 120, 180),
|
||||
//QColor(178, 223, 138),
|
||||
//QColor(51, 160, 44),
|
||||
//QColor(251, 154, 153),
|
||||
//QColor(227, 26, 28),
|
||||
//QColor(253, 191, 111),
|
||||
//QColor(255, 127, 0),
|
||||
//QColor(202, 178, 214),
|
||||
//QColor(106, 61, 154),
|
||||
//QColor(255, 255, 153),
|
||||
|
||||
|
||||
//QColor(228, 26, 28),
|
||||
//QColor(55, 126, 184),
|
||||
//QColor(77, 175, 74),
|
||||
//QColor(152, 78, 163),
|
||||
//QColor(255, 127, 0),
|
||||
//QColor(255, 255, 51),
|
||||
//QColor(166, 86, 40),
|
||||
//QColor(247, 129, 191),
|
||||
//QColor(153, 153, 153),
|
||||
};
|
||||
|
||||
QMap<QString, QString> InstrumentConversion = {
|
||||
@@ -144,7 +121,7 @@ void TimelineWidget::drawContent(QPainter& painter, QRectF rect) {
|
||||
QRectF dateRect(rect.width() - TimeWidth, 0, TimeWidth, rect.height());
|
||||
|
||||
// Draw background
|
||||
painter.setBrush(QBrush(Qt::white)); painter.drawRect(timelineRect);
|
||||
painter.setBrush(QBrush(Qt::lightGray)); painter.drawRect(timelineRect);
|
||||
painter.setBrush(QBrush(Qt::gray)); painter.drawRect(dateRect);
|
||||
|
||||
const double lowerTime = _currentTime.et - etSpread;
|
||||
@@ -161,7 +138,7 @@ void TimelineWidget::drawContent(QPainter& painter, QRectF rect) {
|
||||
|
||||
// Draw current time
|
||||
painter.setBrush(QBrush(Qt::black));
|
||||
painter.setPen(QPen(Qt::black));
|
||||
painter.setPen(QPen(Qt::black, 2));
|
||||
painter.drawLine(QPointF(0, timelineRect.height() / 2), QPointF(timelineRect.width(), timelineRect.height() / 2));
|
||||
painter.drawText(timelineRect.width(), timelineRect.height() / 2 + TextOffset, QString::fromStdString(_currentTime.time));
|
||||
}
|
||||
@@ -191,7 +168,8 @@ void TimelineWidget::drawLegend(QPainter& painter, QRectF rect) {
|
||||
painter.drawRect(currentHorizontalPosition, currentVerticalPosition, BoxSize, BoxSize);
|
||||
currentHorizontalPosition += BoxSize + Padding;
|
||||
|
||||
painter.setPen(QPen(Qt::black));
|
||||
painter.setPen(QPen(QColor(200, 200, 200)));
|
||||
//painter.setPen(QPen(Qt::black));
|
||||
painter.drawText(currentHorizontalPosition, currentVerticalPosition + BoxSize / 2 + TextOffset, InstrumentConversion[QString::fromStdString(instrument)]);
|
||||
int textWidth = painter.boundingRect(QRect(), QString::fromStdString(instrument)).width();
|
||||
//currentHorizontalPosition += std::max(textWidth, 25) + Padding;
|
||||
|
||||
+1
-1
Submodule openspace-data updated: 7a680820ed...69cb186f4b
Reference in New Issue
Block a user