Commit 55cdf5db authored by lm's avatar lm

Improved and bugfixed window persistence

parent e53a9d6f
......@@ -71,6 +71,18 @@ void UASManager::run()
void UASManager::addUAS(UASInterface* uas)
{
// WARNING: The active uas is set here
// and then announced below. This is necessary
// to make sure the getActiveUAS() function
// returns the UAS once the UASCreated() signal
// is emitted. The code is thus NOT redundant.
bool firstUAS = false;
if (activeUAS == NULL)
{
firstUAS = true;
activeUAS = uas;
}
// Only execute if there is no UAS at this index
if (!systems.contains(uas->getUASID()))
{
......@@ -79,7 +91,7 @@ void UASManager::addUAS(UASInterface* uas)
}
// If there is no active UAS yet, set the first one as the active UAS
if (activeUAS == NULL)
if (firstUAS)
{
setActiveUAS(uas);
}
......
......@@ -205,30 +205,30 @@ void DebugConsole::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
// Update bandwidth
if (holdOn)
{
//qDebug() << "Data rate:" << dataRate/1000.0f << "kB/s";
QString rate("data rate: %1");
rate.arg(dataRate);
QPainter painter(this);
painter.setRenderHint(QPainter::HighQualityAntialiasing);
painter.translate(width()/5.0f, height()/5.0f);
//QFont font("Bitstream Vera Sans");
QFont font = painter.font();
font.setPixelSize((int)(60.0f));
QFontMetrics metrics = QFontMetrics(font);
int border = qMax(4, metrics.leading());
QRect rect = metrics.boundingRect(0, 0, width() - 2*border, int(height()*0.125),
Qt::AlignLeft | Qt::TextWordWrap, rate);
painter.setPen(QColor(255, 50, 50));
painter.setRenderHint(QPainter::TextAntialiasing);
painter.drawText(QRect(QPoint(static_cast<int>(width()/5.0f), static_cast<int>(height()/5.0f)), QPoint(static_cast<int>(width() - width()/5.0f), static_cast<int>(height() - height()/5.0f))), rate);
//Qt::AlignRight | Qt::TextWordWrap
}
// if (holdOn)
// {
// //qDebug() << "Data rate:" << dataRate/1000.0f << "kB/s";
// QString rate("data rate: %1");
// rate.arg(dataRate);
// QPainter painter(this);
// painter.setRenderHint(QPainter::HighQualityAntialiasing);
// painter.translate(width()/5.0f, height()/5.0f);
// //QFont font("Bitstream Vera Sans");
// QFont font = painter.font();
// font.setPixelSize((int)(60.0f));
// QFontMetrics metrics = QFontMetrics(font);
// int border = qMax(4, metrics.leading());
// QRect rect = metrics.boundingRect(0, 0, width() - 2*border, int(height()*0.125),
// Qt::AlignLeft | Qt::TextWordWrap, rate);
// painter.setPen(QColor(255, 50, 50));
// painter.setRenderHint(QPainter::TextAntialiasing);
// painter.drawText(QRect(QPoint(static_cast<int>(width()/5.0f), static_cast<int>(height()/5.0f)), QPoint(static_cast<int>(width() - width()/5.0f), static_cast<int>(height() - height()/5.0f))), rate);
// //Qt::AlignRight | Qt::TextWordWrap
// }
}
void DebugConsole::receiveBytes(LinkInterface* link, QByteArray bytes)
......
......@@ -134,7 +134,7 @@ HDDisplay::HDDisplay(QStringList* plotList, QWidget *parent) :
if(!QFile::exists(fontFileName)) qDebug() << "ERROR! font file: " << fontFileName << " DOES NOT EXIST!";
fontDatabase.addApplicationFont(fontFileName);
font = fontDatabase.font(fontFamilyName, "Roman", (int)(10*scalingFactor*1.2f+0.5f));
font = fontDatabase.font(fontFamilyName, "Roman", qMax(5, (int)(10*scalingFactor*1.2f+0.5f)));
if (font.family() != fontFamilyName) qDebug() << "ERROR! Font not loaded: " << fontFamilyName;
// Connect with UAS
......@@ -151,7 +151,7 @@ HDDisplay::~HDDisplay()
void HDDisplay::enableGLRendering(bool enable)
{
Q_UNUSED(enable)
}
void HDDisplay::triggerUpdate()
......
......@@ -150,8 +150,16 @@ HUD::HUD(int width, int height, QWidget* parent)
if(!QFile::exists(fontFileName)) qDebug() << "ERROR! font file: " << fontFileName << " DOES NOT EXIST!";
fontDatabase.addApplicationFont(fontFileName);
font = fontDatabase.font(fontFamilyName, "Roman", (int)(10*scalingFactor*1.2f+0.5f));
if (font.family() != fontFamilyName) qDebug() << "ERROR! Font not loaded: " << fontFamilyName;
font = fontDatabase.font(fontFamilyName, "Roman", qMax(5,(int)(10.0f*scalingFactor*1.2f+0.5f)));
QFont* fontPtr = &font;
if (!fontPtr)
{
qDebug() << "ERROR! FONT NOT LOADED!";
}
else
{
if (font.family() != fontFamilyName) qDebug() << "ERROR! WRONG FONT LOADED: " << fontFamilyName;
}
// Connect with UAS
UASManager* manager = UASManager::instance();
......
This diff is collapsed.
......@@ -138,17 +138,14 @@ public slots:
/** @brief Reload the CSS style sheet */
void reloadStylesheet();
void closeEvent(QCloseEvent* event);
/*
==========================================================
Potentially Deprecated
==========================================================
*/
void loadPixhawkEngineerView();
/** @brief Load view with all widgets */
void loadAllView();
void loadWidgets();
/** @brief Load data view, allowing to plot flight data */
......@@ -228,13 +225,15 @@ protected:
}TOOLS_WIDGET_NAMES;
typedef enum _SETTINGS_SECTIONS {
typedef enum _SETTINGS_SECTIONS
{
SECTION_MENU,
SUB_SECTION_CHECKED,
SUB_SECTION_LOCATION,
} SETTINGS_SECTIONS;
typedef enum _VIEW_SECTIONS {
typedef enum _VIEW_SECTIONS
{
VIEW_ENGINEER,
VIEW_OPERATOR,
VIEW_PILOT,
......@@ -301,6 +300,7 @@ protected:
/** @brief Keeps track of the current view */
VIEW_SECTIONS currentView;
bool aboutToCloseFlag;
QStatusBar* statusBar;
QStatusBar* createStatusBar();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment