Feature/cleanup (#837)

* Style guide fixes
* Various cleanups
* Update SGCT
This commit is contained in:
Alexander Bock
2019-05-03 13:27:43 +02:00
committed by GitHub
parent 6a6db9aa78
commit 595cbc4bcf
39 changed files with 78 additions and 74 deletions

View File

@@ -69,7 +69,7 @@ public:
static scripting::LuaLibrary luaLibrary();
void keyboardCallback(Key key, KeyModifier modifier, KeyAction action);
std::string generateJson() const override;
const std::multimap<KeyWithModifier, KeyInformation>& keyBindings() const;

View File

@@ -114,7 +114,7 @@ private:
// Anchor: Node to follow and orbit.
properties::StringProperty _anchor;
// Aim: Node to look at (when camera direction is reset),
// Aim: Node to look at (when camera direction is reset),
// Empty string means same as anchor.
// If these are the same node we call it the `focus` node.
properties::StringProperty _aim;

View File

@@ -95,7 +95,7 @@ public:
ScriptCallback cb = ScriptCallback());
std::vector<std::string> allLuaFunctions() const;
std::string generateJson() const override;
private:

View File

@@ -110,7 +110,7 @@ public:
*/
template <class T>
ghoul::TemplateFactory<T>* factory() const;
std::string generateJson() const override;
private:

View File

@@ -186,8 +186,8 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary)
, _orientation(OrientationInfo, properties::OptionProperty::DisplayType::Dropdown)
, _size(SizeInfo, 1.f, 0.f, 1e35f)
, _segments(SegmentsInfo, 8, 4, 1000)
, _useAdditiveBlending(UseAdditiveBlendingInfo, false)
, _mirrorTexture(MirrorTextureInfo, false)
, _useAdditiveBlending(UseAdditiveBlendingInfo, false)
, _disableFadeInDistance(DisableFadeInOutInfo, true)
, _fadeInThreshold(FadeInThresholdInfo, -1.f, 0.f, 1.f)
, _fadeOutThreshold(FadeOutThresholdInfo, -1.f, 0.f, 1.f)

View File

@@ -38,8 +38,6 @@
#include <ghoul/misc/dictionary.h>
namespace {
constexpr const char* _loggerCat = "CefWebGui";
constexpr openspace::properties::Property::PropertyInfo EnabledInfo = {
"Enabled",
"Is Enabled",
@@ -77,8 +75,8 @@ CefWebGuiModule::CefWebGuiModule()
: OpenSpaceModule(CefWebGuiModule::Name)
, _enabled(EnabledInfo, true)
, _visible(VisibleInfo, true)
, _url(GuiUrlInfo, "")
, _reload(ReloadInfo)
, _url(GuiUrlInfo, "")
, _guiScale(GuiScaleInfo, 1.f, 0.1f, 3.f)
{
addProperty(_enabled);

View File

@@ -140,8 +140,8 @@ std::shared_ptr<TableData<T>> FitsFileReader::readTable(std::string& path,
// Make sure FITS file is not a Primary HDU Object (aka an image).
if (!isPrimaryHDU()) {
ExtHDU& table = _infile->extension(hduIdx);
int numCols = columnNames.size();
int numRowsInTable = table.rows();
int numCols = static_cast<int>(columnNames.size());
int numRowsInTable = static_cast<int>(table.rows());
std::unordered_map<string, std::vector<T>> contents;
//LINFO("Read file: " + _infile->name());
@@ -238,8 +238,8 @@ std::vector<float> FitsFileReader::readFitsFile(std::string filePath, int& nValu
int nStars = table->readRows - firstRow + 1;
int nNullArr = 0;
size_t nColumnsRead = allColumnNames.size();
size_t defaultCols = 17; // Number of columns that are copied by predefined code.
int nColumnsRead = static_cast<int>(allColumnNames.size());
int defaultCols = 17; // Number of columns that are copied by predefined code.
if (nColumnsRead != defaultCols) {
LINFO("Additional columns will be read! Consider add column in code for "
"significant speedup!");
@@ -330,7 +330,7 @@ std::vector<float> FitsFileReader::readFitsFile(std::string filePath, int& nValu
values[idx++] = vecData[i];
}
for (size_t j = 0; j < nValuesPerStar; ++j) {
for (int j = 0; j < nValuesPerStar; ++j) {
// The astronomers in Vienna use -999 as default value. Change it to 0.
if (values[j] == -999) {
values[j] = 0.f;

View File

@@ -232,7 +232,7 @@ private:
* Private help function for <code>printStarsPerNode()</code>. \returns an accumulated
* string containing all descendant nodes.
*/
std::string printStarsPerNode(const OctreeNode& node,
std::string printStarsPerNode(const OctreeNode& node,
const std::string& prefix) const;
/**

View File

@@ -45,7 +45,7 @@ namespace {
namespace openspace {
MilkywayConversionTask::MilkywayConversionTask(const ghoul::Dictionary& dictionary)
MilkywayConversionTask::MilkywayConversionTask(const ghoul::Dictionary& dictionary)
: _inFirstIndex(0)
, _inNSlices(0)
{

View File

@@ -207,8 +207,9 @@ int getGeoPositionForCamera(lua_State* L) {
}
const glm::dvec3 cameraPosition = global::navigationHandler.camera()->positionVec3();
const glm::dmat4 inverseModelTransform =
global::navigationHandler.orbitalNavigator().anchorNode()->inverseModelTransform();
const SceneGraphNode* anchor =
global::navigationHandler.orbitalNavigator().anchorNode();
const glm::dmat4 inverseModelTransform = anchor->inverseModelTransform();
const glm::dvec3 cameraPositionModelSpace =
glm::dvec3(inverseModelTransform * glm::dvec4(cameraPosition, 1.0));
const SurfacePositionHandle posHandle = globe->calculateSurfacePositionHandle(

View File

@@ -1632,7 +1632,7 @@ float RenderableGlobe::getHeight(const glm::dvec3& position) const {
}
void RenderableGlobe::calculateEclipseShadows(ghoul::opengl::ProgramObject& programObject,
const RenderData& data, ShadowCompType stype)
const RenderData& data, ShadowCompType stype)
{
constexpr const double KM_TO_M = 1000.0;
@@ -1757,7 +1757,7 @@ void RenderableGlobe::calculateEclipseShadows(ghoul::opengl::ProgramObject& prog
else if (stype == ShadowCompType::GLOBAL_SHADOW) {
programObject.setUniform("modelTransform", _cachedModelTransform);
}
// JCC: Removed in favor of: #define USE_ECLIPSE_HARD_SHADOWS #{useEclipseHardShadows}
/*programObject.setUniform(
"hardShadows",

View File

@@ -252,7 +252,9 @@ void GuiPropertyComponent::renderPropertyOwner(properties::PropertyOwner* owner)
}
}
for (const std::pair<std::string, std::vector<Property*>>& p : propertiesByGroup) {
using K = std::string;
using V = std::vector<Property*>;
for (const std::pair<const K, V>& p : propertiesByGroup) {
const std::string& groupName = owner->propertyGroupName(p.first);
if (ImGui::TreeNode(groupName.c_str())) {
for (properties::Property* prop : p.second) {

View File

@@ -85,7 +85,7 @@ void GuiShortcutsComponent::render() {
using V = interaction::KeybindingManager::KeyInformation;
const std::multimap<K, V>& binds = global::keybindingManager.keyBindings();
for (const std::pair<K, V>& p : binds) {
for (const std::pair<const K, V>& p : binds) {
if (ImGui::Button(ghoul::to_string(p.first).c_str())) {
global::scriptEngine.queueScript(
p.second.command,

View File

@@ -60,7 +60,7 @@ private:
TcpSocket = 0,
WebSocket
};
enum class Access : int {
Deny = 0,
RequirePassword,

View File

@@ -94,7 +94,7 @@ void ServerModule::internalInitialize(const ghoul::Dictionary& configuration) {
}
_interfaceOwner.addPropertySubOwner(serverInterface.get());
if (serverInterface) {
_interfaces.push_back(std::move(serverInterface));
}

View File

@@ -68,7 +68,8 @@ namespace {
"Ip addresses or domains that should always be allowed access to this interface"
};
constexpr openspace::properties::Property::PropertyInfo RequirePasswordAddressesInfo = {
constexpr openspace::properties::Property::PropertyInfo
RequirePasswordAddressesInfo = {
"RequirePasswordAddresses",
"Require Password Addresses",
"Ip addresses or domains that should be allowed access if they provide a password"
@@ -97,7 +98,7 @@ std::unique_ptr<ServerInterface> ServerInterface::createFromDictionary(
return si;
}
ServerInterface::ServerInterface(const ghoul::Dictionary& config)
ServerInterface::ServerInterface(const ghoul::Dictionary& config)
: properties::PropertyOwner({ "", "", "" })
, _type(TypeInfo)
, _port(PortInfo, 0)
@@ -129,7 +130,7 @@ ServerInterface::ServerInterface(const ghoul::Dictionary& config)
list.set(v);
}
};
readList(AllowAddressesInfo.identifier, _allowAddresses);
readList(DenyAddressesInfo.identifier, _denyAddresses);
readList(RequirePasswordAddressesInfo.identifier, _requirePasswordAddresses);

View File

@@ -40,7 +40,7 @@ namespace {
namespace openspace {
AuthorizationTopic::AuthorizationTopic(std::string password)
AuthorizationTopic::AuthorizationTopic(std::string password)
: _password(std::move(password))
{}

View File

@@ -37,7 +37,6 @@
using nlohmann::json;
namespace {
constexpr const char* _loggerCat = "DocumentationTopic";
constexpr const char* KeyType = "type";
constexpr const char* TypeLua = "lua";
constexpr const char* TypeFactories = "factories";

View File

@@ -37,7 +37,6 @@ namespace {
constexpr const char* KeyFunction = "function";
constexpr const char* KeyArguments = "arguments";
constexpr const char* KeyReturn = "return";
constexpr const char* TypeKey = "type";
constexpr const char* _loggerCat = "LuaScriptTopic";
std::string formatLua(const nlohmann::json::const_iterator& it);

View File

@@ -66,7 +66,8 @@ std::vector<nlohmann::json> ShortcutTopic::shortcutsJson() const {
const std::multimap<KeyWithModifier, KeyInformation>& keyBindings =
global::keybindingManager.keyBindings();
for (const std::pair<KeyWithModifier, KeyInformation>& keyBinding : keyBindings) {
for (const std::pair<const KeyWithModifier, KeyInformation>& keyBinding : keyBindings)
{
const KeyWithModifier& k = keyBinding.first;
const KeyInformation& info = keyBinding.second;

View File

@@ -26,15 +26,9 @@
#include <openspace/engine/globals.h>
#include <openspace/util/spicemanager.h>
#include <ghoul/logging/logmanager.h>
#include <cstring>
namespace {
constexpr const char* _loggerCat = "SequenceParser";
} // namespace
namespace openspace {
std::map<std::string, ImageSubset>& SequenceParser::getSubsetMap() {

View File

@@ -138,13 +138,15 @@ bool BrowserInstance::sendMouseClickEvent(const CefMouseEvent& event,
return hasContent(event.x, event.y);
}
void BrowserInstance::sendTouchPressEvent(const CefMouseEvent &event, CefBrowserHost::MouseButtonType button,
void BrowserInstance::sendTouchPressEvent(const CefMouseEvent& event,
CefBrowserHost::MouseButtonType button,
const int clickCount)
{
_browser->GetHost()->SendMouseClickEvent(event, button, false, clickCount);
}
void BrowserInstance::sendResleasePressEvent(const CefMouseEvent &event, CefBrowserHost::MouseButtonType button,
void BrowserInstance::sendResleasePressEvent(const CefMouseEvent& event,
CefBrowserHost::MouseButtonType button,
const int clickCount)
{
_browser->GetHost()->SendMouseClickEvent(event, button, true, clickCount);

View File

@@ -48,6 +48,9 @@ CefHost::CefHost(const std::string& helperLocation) {
#ifndef __APPLE__
// Apple will always look for helper in a fixed location.
CefString(&settings.browser_subprocess_path).FromString(helperLocation);
#else
// Silence a warning about unused variable
(void)helperLocation;
#endif
settings.windowless_rendering_enabled = true;

View File

@@ -155,10 +155,9 @@ void OpenSpaceEngine::registerPathTokens() {
LTRACE("OpenSpaceEngine::initialize(begin)");
// Registering Path tokens. If the BASE path is set, it is the only one that will
// overwrite the default path of the cfg directory
for (const std::pair<std::string, std::string>& path :
global::configuration.pathTokens)
{
// overwrite the default path of the cfg directory
using T = std::string;
for (const std::pair<const T, T>& path : global::configuration.pathTokens) {
std::string fullKey = ghoul::filesystem::FileSystem::TokenOpeningBraces +
path.first +
ghoul::filesystem::FileSystem::TokenClosingBraces;
@@ -881,7 +880,8 @@ void OpenSpaceEngine::runGlobalCustomizationScripts() {
void OpenSpaceEngine::loadFonts() {
global::fontManager.initialize();
for (const std::pair<std::string, std::string>& font : global::configuration.fonts) {
using T = std::string;
for (const std::pair<const T, T>& font : global::configuration.fonts) {
std::string key = font.first;
std::string fontName = absPath(font.second);

View File

@@ -106,7 +106,7 @@ void ExternInteraction::scriptInteraction(datamessagestructures::ScriptMessage s
datamessagestructures::CameraKeyframe ExternInteraction::generateCameraKeyframe() {
datamessagestructures::CameraKeyframe kf;
const SceneGraphNode* focusNode =
const SceneGraphNode* focusNode =
global::navigationHandler.orbitalNavigator().anchorNode();
if (!focusNode) {

View File

@@ -145,7 +145,7 @@ std::string KeybindingManager::generateJson() const {
std::stringstream json;
json << "[";
bool first = true;
for (const std::pair<KeyWithModifier, KeyInformation>& p : _keyLua) {
for (const std::pair<const KeyWithModifier, KeyInformation>& p : _keyLua) {
if (!first) {
json << ",";
}

View File

@@ -243,7 +243,7 @@ void NavigationHandler::saveCameraStateToFile(const std::string& filepath) {
glm::dquat q = _camera->rotationQuaternion();
ofs << "return {" << std::endl;
ofs << " " << KeyAnchor << " = " << "\"" <<
ofs << " " << KeyAnchor << " = " << "\"" <<
_orbitalNavigator->anchorNode()->identifier() << "\""
<< "," << std::endl;

View File

@@ -146,7 +146,7 @@ namespace {
};
constexpr openspace::properties::Property::PropertyInfo
FollowRotationInterpolationTimeInfo = {
FollowRotationInterpTimeInfo = {
"FollowRotationInterpolationTime",
"Follow rotation interpolation time",
"The interpolation time when toggling following focus node rotation."
@@ -210,7 +210,7 @@ OrbitalNavigator::OrbitalNavigator()
, _staticViewScaleExponent(StaticViewScaleExponentInfo, 0.f, -30, 10)
, _retargetInterpolationTime(RetargetInterpolationTimeInfo, 2.0, 0.0, 10.0)
, _stereoInterpolationTime(StereoInterpolationTimeInfo, 8.0, 0.0, 10.0)
, _followRotationInterpolationTime(FollowRotationInterpolationTimeInfo, 1.0, 0.0, 10.0)
, _followRotationInterpolationTime(FollowRotationInterpTimeInfo, 1.0, 0.0, 10.0)
, _mouseStates(_mouseSensitivity * 0.0001, 1 / (_friction.friction + 0.0000001))
, _joystickStates(_joystickSensitivity * 0.1, 1 / (_friction.friction + 0.0000001))
{
@@ -739,7 +739,7 @@ OrbitalNavigator::CameraPose OrbitalNavigator::followAim(CameraPose pose,
// 2. Adjustment of the camera to account for radial displacement of the aim
// Step 1 (Rotation around anchor based on aim's projection)
// Step 1 (Rotation around anchor based on aim's projection)
glm::dvec3 newAnchorToProjectedAim =
glm::length(anchorToAim.first) * glm::normalize(anchorToAim.second);
const double spinRotationAngle = glm::angle(
@@ -805,7 +805,8 @@ OrbitalNavigator::CameraPose OrbitalNavigator::followAim(CameraPose pose,
const double newCameraAimAngle =
glm::pi<double>() - anchorAimAngle - newCameraAnchorAngle;
double distanceRotationAngle = correctionFactor * (newCameraAimAngle - prevCameraAimAngle);
double distanceRotationAngle = correctionFactor *
(newCameraAimAngle - prevCameraAimAngle);
if (glm::abs(distanceRotationAngle) > AngleEpsilon) {
glm::dvec3 distanceRotationAxis = glm::normalize(
@@ -1041,7 +1042,7 @@ glm::dvec3 OrbitalNavigator::translateHorizontally(double deltaTime,
glm::inverse(globalCameraRotation);
// Rotate and find the difference vector
const glm::dvec3 rotationDiffVec3 =
const glm::dvec3 rotationDiffVec3 =
(distFromCenterToCamera * outDirection) * rotationDiffWorldSpace -
(distFromCenterToCamera * outDirection);

View File

@@ -599,7 +599,7 @@ void ParallelPeer::sendCameraKeyframe() {
global::navigationHandler.orbitalNavigator().followingNodeRotation();
if (kf._followNodeRotation) {
kf._position = glm::inverse(focusNode->worldRotationMatrix()) * kf._position;
kf._rotation =
kf._rotation =
global::navigationHandler.orbitalNavigator().anchorNodeToCameraRotation();
}
else {

View File

@@ -225,6 +225,10 @@ RenderEngine::RenderEngine()
, _applyWarping(ApplyWarpingInfo, false)
, _showFrameNumber(ShowFrameNumberInfo, false)
, _disableMasterRendering(DisableMasterInfo, false)
, _nAaSamples(AaSamplesInfo, 4, 1, 8)
, _hdrExposure(HDRExposureInfo, 0.4f, 0.01f, 10.0f)
, _hdrBackground(BackgroundExposureInfo, 2.8f, 0.01f, 10.0f)
, _gamma(GammaInfo, 2.2f, 0.01f, 10.0f)
, _globalRotation(
GlobalRotationInfo,
glm::vec3(0.f),
@@ -243,10 +247,6 @@ RenderEngine::RenderEngine()
glm::vec3(-glm::pi<float>()),
glm::vec3(glm::pi<float>())
)
, _nAaSamples(AaSamplesInfo, 4, 1, 8)
, _hdrExposure(HDRExposureInfo, 0.4f, 0.01f, 10.0f)
, _hdrBackground(BackgroundExposureInfo, 2.8f, 0.01f, 10.0f)
, _gamma(GammaInfo, 2.2f, 0.01f, 10.0f)
{
_doPerformanceMeasurements.onChange([this](){
global::performanceManager.setEnabled(_doPerformanceMeasurements);

View File

@@ -143,7 +143,7 @@ namespace {
glm::vec3 sphericalToCartesian(glm::vec3 spherical) {
// First convert to ISO convention spherical coordinates according to
// First convert to ISO convention spherical coordinates according to
// https://en.wikipedia.org/wiki/Spherical_coordinate_system
// (radius, theta, phi), where theta is the polar angle from the z axis,
// and phi is the azimuth.
@@ -317,8 +317,8 @@ std::unique_ptr<ScreenSpaceRenderable> ScreenSpaceRenderable::createFromDictiona
ScreenSpaceRenderable::ScreenSpaceRenderable(const ghoul::Dictionary& dictionary)
: properties::PropertyOwner({ "" })
, _enabled(EnabledInfo, true)
, _useRadiusAzimuthElevation(UseRadiusAzimuthElevationInfo, false)
, _usePerspectiveProjection(UsePerspectiveProjectionInfo, false)
, _useRadiusAzimuthElevation(UseRadiusAzimuthElevationInfo, false)
, _faceCamera(FaceCameraInfo, true)
, _cartesianPosition(
CartesianPositionInfo,
@@ -470,7 +470,12 @@ bool ScreenSpaceRenderable::deinitializeGL() {
}
void ScreenSpaceRenderable::render() {
draw(globalRotationMatrix() * translationMatrix() * localRotationMatrix() * scaleMatrix());
draw(
globalRotationMatrix() *
translationMatrix() *
localRotationMatrix() *
scaleMatrix()
);
}
bool ScreenSpaceRenderable::isReady() const {

View File

@@ -143,8 +143,9 @@ void ResourceSynchronization::setState(State state) {
_callbackMutex.lock();
std::vector<StateChangeCallback> callbacks;
callbacks.reserve(_stateChangeCallbacks.size());
for (const std::pair<CallbackHandle, StateChangeCallback>& it : _stateChangeCallbacks)
{
using K = CallbackHandle;
using V = StateChangeCallback;
for (const std::pair<const K, V>& it : _stateChangeCallbacks) {
callbacks.push_back(it.second);
}
_callbackMutex.unlock();

View File

@@ -138,7 +138,7 @@ void TimeManager::preSynchronization(double dt) {
if (newTime != _lastTime) {
using K = const CallbackHandle;
using V = TimeChangeCallback;
for (const std::pair<K, V>& it : _timeChangeCallbacks) {
for (const std::pair<const K, V>& it : _timeChangeCallbacks) {
it.second();
}
}
@@ -148,14 +148,14 @@ void TimeManager::preSynchronization(double dt) {
{
using K = const CallbackHandle;
using V = TimeChangeCallback;
for (const std::pair<K, V>& it : _deltaTimeChangeCallbacks) {
for (const std::pair<const K, V>& it : _deltaTimeChangeCallbacks) {
it.second();
}
}
if (_timelineChanged) {
using K = const CallbackHandle;
using V = TimeChangeCallback;
for (const std::pair<K, V>& it : _timelineChangeCallbacks) {
for (const std::pair<const K, V>& it : _timelineChangeCallbacks) {
it.second();
}
}
@@ -230,7 +230,7 @@ void TimeManager::progressTime(double dt) {
using K = const CallbackHandle;
using V = TimeChangeCallback;
for (const std::pair<K, V>& it : _timeJumpCallbacks) {
for (const std::pair<const K, V>& it : _timeJumpCallbacks) {
it.second();
}
return;

View File

@@ -41,10 +41,6 @@
#endif // WIN32
#endif
namespace {
constexpr const char* _loggerCat = "TransformationManager";
}
namespace openspace {
TransformationManager* TransformationManager::_instance = nullptr;

View File

@@ -1,3 +1,5 @@
# coding=utf-8
"""
OpenSpace

View File

@@ -103,8 +103,8 @@ struct VerboseProduct {
struct VerboseJob : public openspace::Job<VerboseProduct> {
VerboseJob(int jobExecutingTime)
: _product(-1)
, _jobExecutingTime(jobExecutingTime)
: _jobExecutingTime(jobExecutingTime)
, _product(-1)
{
std::cout << "VerboseTestJob constructor" << std::endl;
}

View File

@@ -447,7 +447,6 @@ TEST_F(SpiceManagerTest, getFieldOfView) {
SpiceInt n;
SpiceInt cassini_ID;
double et;
glm::dvec3 boresight;
double bounds_ref[5][3];
char shape_ref[TYPLEN];
char name_ref[FILLEN];