Cleanup for coding style

Add strict mode to check_style_guide script
This commit is contained in:
Alexander Bock
2017-11-08 10:35:39 -06:00
parent d94408224c
commit b50b52d351
387 changed files with 1907 additions and 2132 deletions
+13 -14
View File
@@ -84,10 +84,10 @@ MainWindow::MainWindow()
setObjectName("MainWindow");
setFixedSize(WindowSize);
//setContentsMargins(0, 0, 0, 0);
QGridLayout* layout = new QGridLayout;
layout->setContentsMargins(0, 0, 0, 0);
QLabel* image = new QLabel;
//image->setContentsMargins(0, 0, 0, 0);
image->setObjectName("Image");
@@ -95,7 +95,6 @@ MainWindow::MainWindow()
image->setPixmap(p);
layout->addWidget(image, 0, 0, 1, 2);
_informationWidget = new QTextEdit(this);
_informationWidget->setReadOnly(true);
//_informationWidget->setEnabled(false);
@@ -107,7 +106,7 @@ MainWindow::MainWindow()
QWidget* container = new QWidget;
{
QGridLayout* innerLayout = new QGridLayout;
//QLabel* shortcutLabel = new QLabel("Keyboard Shortcuts:");
//innerLayout->addWidget(shortcutLabel, 0, 0);
//QPushButton* shortcutButton = new QPushButton("Open...");
@@ -122,47 +121,47 @@ MainWindow::MainWindow()
innerLayout->addWidget(configurationSelectionLabel, 2, 0);
_configurations = new QComboBox;
innerLayout->addWidget(_configurations, 2, 1);
QLabel* sceneSelectionLabel = new QLabel("Scenes:");
innerLayout->addWidget(sceneSelectionLabel, 3, 0);
_scenes = new QComboBox;
innerLayout->addWidget(_scenes, 3, 1);
container->setLayout(innerLayout);
}
layout->addWidget(container, 1, 1);
container = new QWidget;
{
QBoxLayout* innerLayout = new QHBoxLayout;
QPushButton* cancelButton = new QPushButton("Exit");
QObject::connect(
cancelButton, SIGNAL(clicked(bool)),
QApplication::instance(), SLOT(quit())
);
innerLayout->addWidget(cancelButton);
QPushButton* syncButton = new QPushButton("Sync");
QObject::connect(
syncButton, SIGNAL(clicked(bool)),
this, SLOT(syncButtonPressed())
);
innerLayout->addWidget(syncButton);
QPushButton* startButton = new QPushButton("Start");
QObject::connect(
startButton, SIGNAL(clicked(bool)),
this, SLOT(startButtonPressed())
);
innerLayout->addWidget(startButton);
container->setLayout(innerLayout);
}
layout->addWidget(container, 2, 1);
setLayout(layout);
initialize();
}
@@ -244,7 +243,7 @@ void MainWindow::initialize() {
// Get the news information
QNetworkRequest request;
request.setUrl(QUrl(NewsURL));
_newsReply = _networkManager.get(request);
QObject::connect(_newsReply, SIGNAL(finished()),
this, SLOT(newsReadyRead())
+3 -3
View File
@@ -53,7 +53,7 @@ private slots:
void shortcutButtonPressed();
void syncButtonPressed();
void startButtonPressed();
void newsNetworkError();
void newsReadyRead();
@@ -64,7 +64,7 @@ private:
void configureLogging();
QNetworkReply* _newsReply;
QTextEdit* _informationWidget;
QComboBox* _configurations;
@@ -72,7 +72,7 @@ private:
QComboBox* _scenes;
QMap<QString, QString> _sceneFiles;
ShortcutWidget* _shortcutWidget;
SyncWidget* _syncWidget;
+8 -8
View File
@@ -281,7 +281,7 @@ void SyncWidget::handleDirectFiles() {
void SyncWidget::handleFileRequest() {
LDEBUG("File Requests");
for (const FileRequest& f : _fileRequests) {
LDEBUG(f.identifier.toStdString() << " (" << f.version << ") -> " << f.destination.toStdString());
@@ -405,18 +405,18 @@ void SyncWidget::syncButtonPressed() {
for (int i = 1; i <= modules.size(); ++i) {
std::string module = modules.value<std::string>(std::to_string(i));
std::string shortModule = module;
std::string::size_type pos = module.find_last_of(FileSys.PathSeparator);
if (pos != std::string::npos) {
shortModule = module.substr(pos+1);
}
QString m = QString::fromStdString(module);
QString dataFile = sceneDir.absoluteFilePath(
QString::fromStdString(module) + "/" + QString::fromStdString(shortModule) + ".data"
);
if (QFileInfo(dataFile).exists()) {
modulesList.append({
QString::fromStdString(module),
@@ -427,13 +427,13 @@ void SyncWidget::syncButtonPressed() {
else {
QDir metaModuleDir = sceneDir;
metaModuleDir.cd(QString::fromStdString(module));
QDirIterator it(metaModuleDir.absolutePath(), QStringList() << "*.data", QDir::Files, QDirIterator::Subdirectories);
while (it.hasNext()) {
QString v = it.next();
QDir d(v);
d.cdUp();
modulesList.append({
d.dirName(),
v,
@@ -533,7 +533,7 @@ void SyncWidget::syncButtonPressed() {
continue;
}
std::string file = d.value<std::string>(FileKey);
std::string dest;
if (d.hasKeyAndValue<std::string>(DestinationKey))
dest = d.value<std::string>(DestinationKey);
+1 -1
View File
@@ -52,7 +52,7 @@ Q_OBJECT
public:
SyncWidget(QWidget* parent, Qt::WindowFlags f = 0);
~SyncWidget();
void setSceneFiles(QMap<QString, QString> sceneFiles);
private slots:
+32 -34
View File
@@ -66,7 +66,7 @@
#define DEVELOPER_MODE
namespace {
const char* _loggerCat = "main";
sgct::Engine* SgctEngine;
@@ -79,7 +79,6 @@ LONG WINAPI generateMiniDump(EXCEPTION_POINTERS* exceptionPointers) {
SYSTEMTIME stLocalTime;
GetLocalTime(&stLocalTime);
LFATAL("Printing Stack Trace that lead to the crash:");
std::vector<std::string> stackTrace = ghoul::stackTrace();
for (const std::string& s : stackTrace) {
@@ -139,7 +138,7 @@ LONG WINAPI generateMiniDump(EXCEPTION_POINTERS* exceptionPointers) {
}
#endif // WIN32
#ifdef OPENVR_SUPPORT
sgct::SGCTWindow* FirstOpenVRWindow = nullptr;
#endif
@@ -172,7 +171,6 @@ std::vector<SpoutWindow> SpoutWindows;
#endif // OPENSPACE_HAS_SPOUT
std::pair<int, int> supportedOpenGLVersion() {
// Just create a window in order to retrieve the available OpenGL version before we
// create the real window
@@ -188,9 +186,9 @@ std::pair<int, int> supportedOpenGLVersion() {
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#endif
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
// By creating an offscreen window, the user will not know that we created this window
GLFWwindow* offscreen = glfwCreateWindow(128, 128, "", nullptr, nullptr);
glfwMakeContextCurrent(offscreen);
@@ -203,7 +201,7 @@ std::pair<int, int> supportedOpenGLVersion() {
// And get rid of the window again
glfwDestroyWindow(offscreen);
glfwWindowHint(GLFW_VISIBLE, GL_TRUE);
return { major, minor };
}
@@ -217,14 +215,14 @@ void mainInitFunc() {
LDEBUG("Initializing OpenGL in OpenSpace Engine started");
OsEng.initializeGL();
LDEBUG("Initializing OpenGL in OpenSpace Engine finished");
// Find if we have at least one OpenVR window
// Save reference to first OpenVR window, which is the one we will copy to the HMD.
for (size_t i = 0; i < SgctEngine->getNumberOfWindows(); ++i) {
if (SgctEngine->getWindowPtr(i)->checkIfTagExists(OpenVRTag)) {
#ifdef OPENVR_SUPPORT
FirstOpenVRWindow = SgctEngine->getWindowPtr(i);
// If we have an OpenVRWindow, initialize OpenVR.
sgct::SGCTOpenVR::initialize(
SgctEngine->getNearClippingPlane(), SgctEngine->getFarClippingPlane()
@@ -305,7 +303,7 @@ void mainInitFunc() {
LWARNING(
"Spout was requested, but OpenSpace was compiled without Spout support."
);
#endif // OPENSPACE_HAS_SPOUT
}
LTRACE("main::mainInitFunc(end)");
@@ -480,7 +478,7 @@ void mainLogCallback(const char* msg) {
int main_main(int argc, char** argv) {
std::pair<int, int> glVersion = supportedOpenGLVersion();
// Create the OpenSpace engine and get arguments for the SGCT engine
// @CLEANUP: Replace the return valua with throwing an exception --abock
std::vector<std::string> sgctArguments;
@@ -491,37 +489,37 @@ int main_main(int argc, char** argv) {
sgctArguments,
requestQuit
);
if (requestQuit) {
return EXIT_SUCCESS;
}
LINFO("Detected OpenGL version: " << glVersion.first << "." << glVersion.second);
// Create sgct engine c arguments
int newArgc = static_cast<int>(sgctArguments.size());
char** newArgv = new char*[newArgc];
for (int i = 0; i < newArgc; ++i) {
newArgv[i] = const_cast<char*>(sgctArguments.at(i).c_str());
}
// Need to set this before the creation of the sgct::Engine
sgct::MessageHandler::instance()->setLogToConsole(false);
sgct::MessageHandler::instance()->setShowTime(false);
sgct::MessageHandler::instance()->setLogToCallback(true);
sgct::MessageHandler::instance()->setLogCallback(mainLogCallback);
#ifdef __APPLE__
glfwWindowHint(GLFW_STENCIL_BITS, 8);
#endif
LDEBUG("Creating SGCT Engine");
SgctEngine = new sgct::Engine(newArgc, newArgv);
// Deallocate sgct c arguments
delete[] newArgv;
// Bind functions
SgctEngine->setInitOGLFunction(mainInitFunc);
SgctEngine->setPreSyncFunction(mainPreSyncFunc);
@@ -534,17 +532,17 @@ int main_main(int argc, char** argv) {
SgctEngine->setMouseScrollCallbackFunction(mainMouseScrollCallback);
SgctEngine->setExternalControlCallback(mainExternalControlCallback);
SgctEngine->setCharCallbackFunction(mainCharCallback);
// Disable the immediate exit of the application when the ESC key is pressed
SgctEngine->setExitKey(SGCT_KEY_UNKNOWN);
sgct::MessageHandler::instance()->setNotifyLevel(sgct::MessageHandler::NOTIFY_ALL);
// Set encode and decode functions
// NOTE: starts synchronizing before init functions
sgct::SharedData::instance()->setEncodeFunction(mainEncodeFun);
sgct::SharedData::instance()->setDecodeFunction(mainDecodeFun);
// Try to open a window
LDEBUG("Initialize SGCT Engine");
std::map<std::pair<int, int>, sgct::Engine::RunMode> versionMapping = {
@@ -561,17 +559,17 @@ int main_main(int argc, char** argv) {
versionMapping.find(glVersion) != versionMapping.end(),
"Unknown OpenGL version. Missing statement in version mapping map"
);
auto cleanup = [&](){
OsEng.deinitialize();
// Clear function bindings to avoid crash after destroying the OpenSpace Engine
sgct::MessageHandler::instance()->setLogToCallback(false);
sgct::MessageHandler::instance()->setLogCallback(nullptr);
LDEBUG("Destroying OpenSpaceEngine");
openspace::OpenSpaceEngine::destroy();
LDEBUG("Destroying SGCT Engine");
delete SgctEngine;
@@ -594,26 +592,26 @@ int main_main(int argc, char** argv) {
}
#endif // OPENSPACE_HAS_SPOUT
};
bool initSuccess = SgctEngine->init(versionMapping[glVersion]);
if (!initSuccess) {
LFATAL("Initializing failed");
cleanup();
return EXIT_FAILURE;
}
// Main loop
LDEBUG("Starting rendering loop");
SgctEngine->render();
LDEBUG("Ending rendering loop");
cleanup();
// Exit program
exit(EXIT_SUCCESS);
}
} // namespace
int main(int argc, char** argv) {
-1
View File
@@ -177,7 +177,6 @@ ControlWidget::ControlWidget(QWidget* parent)
_setDelta->setObjectName("background");
layout->addWidget(_setDelta, 4, 0, 1, 2);
QWidget* controlContainer = new QWidget;
controlContainer->setObjectName("background");
+2 -2
View File
@@ -228,7 +228,7 @@ void MainWindow::readTcpData() {
fullyConnected();
continuousData.clear();
break;
default:
qDebug() << QString(data);
}
@@ -309,7 +309,7 @@ QByteArray MainWindow::handlePlaybook(QByteArray data) {
image.beginningString = readFromBuffer<std::string>(buffer, currentReadLocation);
image.endingString = readFromBuffer<std::string>(buffer, currentReadLocation);
uint8_t targetId = readFromBuffer<uint8_t>(buffer, currentReadLocation);
uint16_t instrumentId = readFromBuffer<uint16_t>(buffer, currentReadLocation);
image.target = targetMap[targetId];
+1 -1
View File
@@ -65,7 +65,7 @@ private:
ControlWidget* _timeControlWidget;
InformationWidget* _informationWidget;
TimelineWidget* _timelineWidget;
QTcpSocket* _socket;
bool _isConnected = false;
+2 -2
View File
@@ -35,7 +35,7 @@
namespace {
static const int LegendHeight = 105;
static const int TimeWidth = 200;
static const int TextOffset = 5;
QMap<QString, QColor> InstrumentColors = {
@@ -127,7 +127,7 @@ void TimelineWidget::setData(std::vector<Image> images, std::map<uint8_t, std::s
void TimelineWidget::drawContent(QPainter& painter, QRectF rect) {
QRectF timelineRect(0, 0, rect.width() - TimeWidth, rect.height());
QRectF dateRect(rect.width() - TimeWidth, 0, TimeWidth, rect.height());
// Draw background
//painter.setBrush(QBrush(Qt::lightGray)); painter.drawRect(timelineRect);
painter.setBrush(QBrush(QColor(85, 85, 85))); painter.drawRect(timelineRect);