Skip to content

Commit

Permalink
Improved and bugfixed window persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
pixhawk-students committed Dec 21, 2010
1 parent e53a9d6 commit 55cdf5d
Show file tree
Hide file tree
Showing 6 changed files with 546 additions and 958 deletions.
14 changes: 13 additions & 1 deletion src/uas/UASManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
{
Expand All @@ -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);
}
Expand Down
48 changes: 24 additions & 24 deletions src/ui/DebugConsole.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/ui/HDDisplay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -151,7 +151,7 @@ HDDisplay::~HDDisplay()

void HDDisplay::enableGLRendering(bool enable)
{

Q_UNUSED(enable)
}

void HDDisplay::triggerUpdate()
Expand Down
12 changes: 10 additions & 2 deletions src/ui/HUD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading

0 comments on commit 55cdf5d

Please sign in to comment.