more merge fixes and sgct update

This commit is contained in:
Micah Acinapura
2025-02-03 18:10:45 -05:00
parent b2889f9b8e
commit 1fd62cbe88
12 changed files with 132 additions and 144 deletions
@@ -64,7 +64,7 @@ void checkRenderable(
simp::readValue(message, messageOffset, guiName);
}
catch (const simp::SimpError& err) {
LERROR(fmt::format("Error when reading identifier and guiName from message: {}", err.message));
LERROR(std::format("Error when reading identifier and guiName from message: {}", err.message));
return;
}
@@ -77,7 +77,7 @@ void checkRenderable(
hasCallbacks = callbacks.count(identifier) > 0;
}
if (!r && !hasCallbacks) {
LDEBUG(fmt::format("No renderable with identifier '{}' was found. Creating it.", identifier));
LDEBUG(std::format("No renderable with identifier '{}' was found. Creating it.", identifier));
// Create a renderable, since it didn't exist
using namespace std::string_literals;
@@ -97,16 +97,14 @@ void checkRenderable(
global::scriptEngine->queueScript(
"openspace.addSceneGraphNode(" + ghoul::formatLua(node) + ")"
"openspace.setPropertyValueSingle('Modules.CefWebGui.Reload', nil)", // Reload WebGUI so that SoftwareIntegration GUI appears
scripting::ScriptEngine::RemoteScripting::Yes
"openspace.setPropertyValueSingle('Modules.CefWebGui.Reload', nil)" // Reload WebGUI so that SoftwareIntegration GUI appears
);
auto reanchorCallback = [identifier] {
global::scriptEngine->queueScript(
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil)"
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Anchor', '" + identifier + "')"
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Aim', '')",
scripting::ScriptEngine::RemoteScripting::Yes
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Aim', '')"
);
};
addCallback(identifier, { reanchorCallback, { storage::Key::DataPoints }, "reanchorCallback" });
@@ -239,7 +237,7 @@ void checkAddOnChangeCallback(
{
onChangeCallback,
{},
fmt::format("onChangeCallback on property {}", propertyName),
std::format("onChangeCallback on property {}", propertyName),
}
);
}
@@ -264,7 +262,7 @@ bool handleSingleFloatValue(
simp::readValue(message, offset, newValue);
}
catch (const simp::SimpError& err) {
LERROR(fmt::format(
LERROR(std::format(
"Error when parsing float in {} message: {}",
simp::getStringFromDataKey(dataKey), err.message
));
@@ -284,11 +282,10 @@ bool handleSingleFloatValue(
auto currentValue = std::any_cast<float>(property->get());
if (abs(newValue - currentValue) > std::numeric_limits<float>::epsilon()) {
global::scriptEngine->queueScript(
fmt::format(
std::format(
"openspace.setPropertyValueSingle('Scene.{}.Renderable.{}', {});",
identifier, propertyName, ghoul::to_string(newValue)
),
scripting::ScriptEngine::RemoteScripting::Yes
)
);
}
};
@@ -297,7 +294,7 @@ bool handleSingleFloatValue(
{
setValueCallback,
{},
fmt::format("Callback for {} on property {}", simp::getStringFromDataKey(dataKey), propertyName),
std::format("Callback for {} on property {}", simp::getStringFromDataKey(dataKey), propertyName),
}
);
@@ -343,11 +340,10 @@ bool handleColorValue(
// Update color of renderable
if (glm::any(glm::epsilonNotEqual(newColor, currentColor, std::numeric_limits<float>::epsilon()))) {
global::scriptEngine->queueScript(
fmt::format(
std::format(
"openspace.setPropertyValueSingle('Scene.{}.Renderable.{}', {});",
identifier, propertyName, ghoul::to_string(newColor)
),
scripting::ScriptEngine::RemoteScripting::Yes
)
);
}
};
@@ -356,7 +352,7 @@ bool handleColorValue(
{
setColorCallback,
{},
fmt::format("Callback on property {}", propertyName),
std::format("Callback on property {}", propertyName),
}
);
@@ -403,11 +399,10 @@ bool handleDateValue(
// Update date of renderable
if (glm::any(glm::notEqual(newDate, currentDate))) {
global::scriptEngine->queueScript(
fmt::format(
std::format(
"openspace.setPropertyValueSingle('Scene.{}.Renderable.{}', {});",
identifier, propertyName, ghoul::to_string(newDate)
),
scripting::ScriptEngine::RemoteScripting::Yes
)
);
}
};
@@ -416,7 +411,7 @@ bool handleDateValue(
{
setDateCallback,
{},
fmt::format("Callback on property {}", propertyName),
std::format("Callback on property {}", propertyName),
}
);
@@ -448,7 +443,7 @@ bool handleBoolValue(
simp::readValue(message, offset, newValue);
}
catch (const simp::SimpError& err) {
LERROR(fmt::format(
LERROR(std::format(
"Error when parsing bool in DATA.{} message: {}",
simp::getStringFromDataKey(dataKey), err.message
));
@@ -469,11 +464,10 @@ bool handleBoolValue(
if (newValue != currentValue) {
std::string newValueString = newValue ? "true" : "false";
global::scriptEngine->queueScript(
fmt::format(
std::format(
"openspace.setPropertyValueSingle('Scene.{}.Renderable.{}', {});",
identifier, propertyName, newValueString
),
scripting::ScriptEngine::RemoteScripting::Yes
)
);
}
};
@@ -486,7 +480,7 @@ bool handleBoolValue(
{
setEnabledCallback,
waitFor,
fmt::format("Callback on property {}", propertyName),
std::format("Callback on property {}", propertyName),
}
);
@@ -517,7 +511,7 @@ bool handleStringValue(
simp::readValue(message, offset, newStringValue);
}
catch (const simp::SimpError& err) {
LERROR(fmt::format(
LERROR(std::format(
"Error when parsing string in DATA.{} message: {}",
simp::getStringFromDataKey(dataKey), err.message
));
@@ -537,11 +531,10 @@ bool handleStringValue(
auto currentStringValue = property->stringValue();
if (newStringValue != currentStringValue) {
global::scriptEngine->queueScript(
fmt::format(
std::format(
"openspace.setPropertyValueSingle('Scene.{}.Renderable.{}', \"{}\");",
identifier, propertyName, newStringValue
),
scripting::ScriptEngine::RemoteScripting::Yes
)
);
}
};
@@ -550,7 +543,7 @@ bool handleStringValue(
{
setStringCallback,
{},
fmt::format("Callback for {} on property {}", simp::getStringFromDataKey(dataKey), propertyName),
std::format("Callback for {} on property {}", simp::getStringFromDataKey(dataKey), propertyName),
}
);
@@ -582,10 +575,10 @@ void handleDataMessage(const std::vector<std::byte>& message, std::shared_ptr<So
dataKey = simp::getDataKey(dataKeyStr);
}
catch (const simp::SimpError& err) {
LERROR(fmt::format("Error when reading data message: {}", err.message));
LERROR(std::format("Error when reading data message: {}", err.message));
return;
}
LDEBUG(fmt::format(
LDEBUG(std::format(
"Handling '{}':",
simp::getStringFromDataKey(dataKey)
));
@@ -609,7 +602,7 @@ void handleDataMessage(const std::vector<std::byte>& message, std::shared_ptr<So
try {
simp::readValue(message, offset, nValues);
if (nValues < 0) {
throw simp::SimpError(fmt::format(
throw simp::SimpError(std::format(
"Number of values should be >0. Got {}",
nValues
));
@@ -625,13 +618,13 @@ void handleDataMessage(const std::vector<std::byte>& message, std::shared_ptr<So
}
catch (const simp::SimpError& err) {
if (nValues != -1) {
LERROR(fmt::format(
LERROR(std::format(
"Error when reading {} values in {} message: {}",
nValues, dataKeyStr, err.message
));
}
else {
LERROR(fmt::format(
LERROR(std::format(
"Error when parsing number of values in {} message: {}",
dataKeyStr, err.message
));
@@ -799,7 +792,7 @@ void handleRemoveSGNMessage(const std::vector<std::byte>& message, std::shared_p
simp::readValue(message, messageOffset, identifier);
}
catch (const simp::SimpError& err) {
LERROR(fmt::format("Error when reading message: {}", err.message));
LERROR(std::format("Error when reading message: {}", err.message));
return;
}
@@ -809,18 +802,16 @@ void handleRemoveSGNMessage(const std::vector<std::byte>& message, std::shared_p
// If the deleted node is the current anchor, first change focus to the Sun
global::scriptEngine->queueScript(
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Anchor', 'Sun')"
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Aim', '')",
scripting::ScriptEngine::RemoteScripting::Yes
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Aim', '')"
);
}
global::scriptEngine->queueScript(
"openspace.removeSceneGraphNode('" + identifier + "');",
scripting::ScriptEngine::RemoteScripting::Yes
"openspace.removeSceneGraphNode('" + identifier + "');"
);
connection->removeSceneGraphNode(identifier);
LDEBUG(fmt::format("Scene graph node '{}' removed.", identifier));
LDEBUG(std::format("Scene graph node '{}' removed.", identifier));
}
} // namespace
@@ -839,7 +830,7 @@ void addCallback(const std::string& identifier, const Callback& newCallback) {
void handleMessage(IncomingMessage& incomingMessage) {
if(incomingMessage.connection.expired()) {
LDEBUG(fmt::format("Trying to handle message from disconnected peer. Aborting."));
LDEBUG(std::format("Trying to handle message from disconnected peer. Aborting."));
return;
}
@@ -850,9 +841,9 @@ void handleMessage(IncomingMessage& incomingMessage) {
switch (messageType) {
case simp::MessageType::Connection: {
LDEBUG(fmt::format("Message recieved... Connection: {}", connectionPtr->id()));
LDEBUG(std::format("Message recieved... Connection: {}", connectionPtr->id()));
if (connectionPtr->handshakeHasBeenMade()) {
LERROR(fmt::format("Connection {} is already connected. Can't connect again.", connectionPtr->id()));
LERROR(std::format("Connection {} is already connected. Can't connect again.", connectionPtr->id()));
return;
}
size_t offset = 0;
@@ -861,7 +852,7 @@ void handleMessage(IncomingMessage& incomingMessage) {
simp::readValue(message, offset, software);
}
catch (const simp::SimpError& err) {
LERROR(fmt::format(
LERROR(std::format(
"Error when parsing software name in {} message: {}",
simp::getStringFromMessageType(simp::MessageType::Connection), err.message
));
@@ -875,22 +866,22 @@ void handleMessage(IncomingMessage& incomingMessage) {
simp::toByteBuffer(subject, 0, sendBack);
connectionPtr->sendMessage(messageType, subject);
LINFO(fmt::format("OpenSpace has connected with {} through socket", software));
LINFO(std::format("OpenSpace has connected with {} through socket", software));
connectionPtr->setHandshakeHasBeenMade();
break;
}
case simp::MessageType::Data: {
LINFO(fmt::format("Data message recieved on connection {}.", connectionPtr->id()));
LINFO(std::format("Data message recieved on connection {}.", connectionPtr->id()));
handleDataMessage(message, connectionPtr);
break;
}
case simp::MessageType::RemoveSceneGraphNode: {
LINFO(fmt::format("Remove Scene Graph Node message recieved on connection {}.", connectionPtr->id()));
LINFO(std::format("Remove Scene Graph Node message recieved on connection {}.", connectionPtr->id()));
handleRemoveSGNMessage(message, connectionPtr);
break;
}
default: {
LERROR(fmt::format(
LERROR(std::format(
"Unsupported message type: {}", incomingMessage.rawMessageType
));
break;
@@ -907,7 +898,7 @@ void postSyncCallbacks() {
auto& [identifier, callbackList] = *callbackMapIt;
try {
LDEBUG(fmt::format("Callbacks for {}:", identifier));
LDEBUG(std::format("Callbacks for {}:", identifier));
const SceneGraphNode* sgn = global::renderEngine->scene()->sceneGraphNode(identifier);
if (!sgn) throw std::exception{};
@@ -923,7 +914,7 @@ void postSyncCallbacks() {
try {
for (auto& waitFor : waitForData) {
if (!softwareIntegrationModule->dataLoaded(identifier, waitFor)) {
LINFO(fmt::format(
LINFO(std::format(
"Callback '{}' NOT executed. Waiting for '{}':",
description, storage::getStorageKeyString(waitFor)
));
@@ -933,7 +924,7 @@ void postSyncCallbacks() {
callback();
callbacksIt = callbackList.erase(callbacksIt);
LDEBUG(fmt::format("Callback '{}' executed", description));
LDEBUG(std::format("Callback '{}' executed", description));
}
catch (std::exception&) {
++callbacksIt;
@@ -950,7 +941,7 @@ void postSyncCallbacks() {
catch(std::exception &err) {
++callbacksRetries;
ghoul_assert(callbacksRetries < 10, "Too many callback retries");
LDEBUG(fmt::format("Error when trying to run callback: {}", err.what()));
LDEBUG(std::format("Error when trying to run callback: {}", err.what()));
break;
}
}
@@ -45,7 +45,7 @@ bool handleEnumValue(
simp::readValue(message, offset, newValue);
}
catch (const simp::SimpError& err) {
LERRORC("MessageHandler", fmt::format(
LERRORC("MessageHandler", std::format(
"Error when parsing int32_t in DATA.{} message: {}",
simp::getStringFromDataKey(dataKey), err.message
));
@@ -56,7 +56,7 @@ bool handleEnumValue(
static_cast<T>(newValue);
}
catch (const std::exception& err) {
LERRORC("MessageHandler", fmt::format(
LERRORC("MessageHandler", std::format(
"Error when casting {} to {} in DATA.{} message: {}",
newValue, typeid(T).name(), simp::getStringFromDataKey(dataKey), err.what()
));
@@ -76,11 +76,10 @@ bool handleEnumValue(
auto currentValue = std::any_cast<int>(property->get());
if (newValue != currentValue) {
global::scriptEngine->queueScript(
fmt::format(
std::format(
"openspace.setPropertyValueSingle('Scene.{}.Renderable.{}', {});",
identifier, propertyName, ghoul::to_string(newValue)
),
scripting::ScriptEngine::RemoteScripting::Yes
)
);
}
};
@@ -89,7 +88,7 @@ bool handleEnumValue(
{
setEnumCallback,
{},
fmt::format("Callback on property {}", propertyName),
std::format("Callback on property {}", propertyName),
}
);
@@ -125,7 +125,7 @@ void stopServer(std::shared_ptr<NetworkState> networkState) {
}
SoftwareConnectionLostError::SoftwareConnectionLostError(const std::string& msg)
: ghoul::RuntimeError(fmt::format("{}{}", "Software connection lost", msg), "SoftwareConnection")
: ghoul::RuntimeError(std::format("{}{}", "Software connection lost", msg), "SoftwareConnection")
{}
} // namespace openspace::softwareintegration::network
@@ -44,7 +44,7 @@ SoftwareConnection::SoftwareConnection(std::unique_ptr<ghoul::io::TcpSocket> soc
: _id{ _nextConnectionId++ }, _socket{ std::move(socket) }, _sceneGraphNodes{},
_thread{}, _shouldStopThread{ false }
{
LDEBUG(fmt::format("Adding software connection {}", _id));
LDEBUG(std::format("Adding software connection {}", _id));
}
SoftwareConnection::SoftwareConnection(SoftwareConnection&& sc)
@@ -60,7 +60,7 @@ SoftwareConnection::~SoftwareConnection() {
// shared_ptrs to SoftwareConnection, which can cause
// bugs if not handled properly.
// Tips: use weak_ptr instead of shared_ptr in callbacks.
LDEBUG(fmt::format("Removing software connection {}", _id));
LDEBUG(std::format("Removing software connection {}", _id));
_shouldStopOutgoingMessagesThread = true;
_outgoingMessagesNotifier.notify_all();
@@ -81,7 +81,7 @@ void SoftwareConnection::addPropertySubscription(
// Get renderable
auto r = renderable(identifier);
if (!r) {
LWARNING(fmt::format(
LWARNING(std::format(
"Couldn't add property subscription. Renderable \"{}\" doesn't exist",
identifier
));
@@ -90,7 +90,7 @@ void SoftwareConnection::addPropertySubscription(
auto property = r->property(propertyName);
if (!property) {
LWARNING(fmt::format(
LWARNING(std::format(
"Couldn't add property subscription. Property \"{}\" doesn't exist on \"{}\"",
propertyName, identifier
));
@@ -102,7 +102,7 @@ void SoftwareConnection::addPropertySubscription(
auto propertySubscriptions = _sceneGraphNodes.find(identifier);
if (propertySubscriptions == _sceneGraphNodes.end()) {
LERROR(fmt::format("Couldn't add property subscription. No SceneGraphNode with identifier {} exists.", identifier));
LERROR(std::format("Couldn't add property subscription. No SceneGraphNode with identifier {} exists.", identifier));
return;
}
@@ -130,7 +130,7 @@ bool SoftwareConnection::hasPropertySubscription(
// Get renderable
auto r = renderable(identifier);
if (!r) {
LDEBUG(fmt::format(
LDEBUG(std::format(
"Couldn't check for property subscriptions, renderable {} doesn't exist",
identifier
));
@@ -145,7 +145,7 @@ void SoftwareConnection::removePropertySubscriptions(const std::string& identifi
// Get renderable
auto r = renderable(identifier);
if (!r) {
LWARNING(fmt::format(
LWARNING(std::format(
"Couldn't remove property subscriptions, renderable {} doesn't exist",
identifier
));
@@ -163,7 +163,7 @@ void SoftwareConnection::removePropertySubscriptions(const std::string& identifi
auto property = r->property(propertySubscriptionCopy.first);
if (!property) {
LWARNING(fmt::format(
LWARNING(std::format(
"Couldn't remove property subscription. Property \"{}\" doesn't exist on \"{}\"",
propertySubscriptionCopy.first, identifier
));
@@ -182,7 +182,7 @@ void SoftwareConnection::removePropertySubscription(
// Get renderable
auto r = renderable(identifier);
if (!r) {
LWARNING(fmt::format(
LWARNING(std::format(
"Couldn't remove property subscription. Renderable \"{}\" doesn't exist",
identifier
));
@@ -190,7 +190,7 @@ void SoftwareConnection::removePropertySubscription(
}
if (!r->hasProperty(propertyName)) {
LWARNING(fmt::format(
LWARNING(std::format(
"Couldn't remove property subscription. Property \"{}\" doesn't exist on \"{}\"",
propertyName, identifier
));
@@ -238,7 +238,7 @@ bool SoftwareConnection::shouldSendData(const std::string& identifier, const std
void SoftwareConnection::setShouldNotSendData(const std::string& identifier, const std::string& propertyName) {
auto sgn = _sceneGraphNodes.find(identifier);
if (sgn == _sceneGraphNodes.end()) {
LERROR(fmt::format(
LERROR(std::format(
"Couldn't set shouldNotSendData on property {} on SceneGraphNode {}. SceneGraphNode doesn't exist.",
propertyName, identifier
));
@@ -247,7 +247,7 @@ void SoftwareConnection::setShouldNotSendData(const std::string& identifier, con
auto propertySubscription = sgn->second.propertySubscriptions.find(propertyName);
if (propertySubscription == sgn->second.propertySubscriptions.end()) {
LERROR(fmt::format(
LERROR(std::format(
"Couldn't set shouldNotSendData on property {} on SceneGraphNode {}. No subscription on property.",
propertyName, identifier
));
@@ -259,7 +259,7 @@ void SoftwareConnection::setShouldNotSendData(const std::string& identifier, con
void SoftwareConnection::disconnect() {
_socket->disconnect();
LINFO(fmt::format("OpenSpace has disconnected with external software"));
LINFO(std::format("OpenSpace has disconnected with external software"));
}
bool SoftwareConnection::isConnected() const {
@@ -279,14 +279,14 @@ bool SoftwareConnection::sendMessage(
if (!_socket || !isConnected()) {
throw SoftwareConnectionLostError("Connection lost...");
}
LDEBUG(fmt::format(
LDEBUG(std::format(
"sendMessage: messageType={}, subjectBuffer.size()={}",
simp::getStringFromMessageType(messageType),
subjectBuffer.size()
));
std::vector<std::byte> message{};
std::string header = fmt::format(
std::string header = std::format(
"{}{}{}",
simp::protocolVersion,
simp::getStringFromMessageType(messageType),
@@ -300,13 +300,13 @@ bool SoftwareConnection::sendMessage(
}
}
catch (const SoftwareConnectionLostError& err) {
LERROR(fmt::format("Couldn't send message with type \"{}\", due to: {}", simp::getStringFromMessageType(messageType), err.message));
LERROR(std::format("Couldn't send message with type \"{}\", due to: {}", simp::getStringFromMessageType(messageType), err.message));
}
catch (const std::exception& err) {
LERROR(fmt::format("Couldn't send message with type \"{}\", due to: {}", simp::getStringFromMessageType(messageType), err.what()));
LERROR(std::format("Couldn't send message with type \"{}\", due to: {}", simp::getStringFromMessageType(messageType), err.what()));
}
LDEBUG(fmt::format("Sent message with type {}", simp::getStringFromMessageType(messageType)));
LDEBUG(std::format("Sent message with type {}", simp::getStringFromMessageType(messageType)));
return true;
}
@@ -351,7 +351,7 @@ void SoftwareConnection::addToMessageQueue(
) {
auto sgn = _sceneGraphNodes.find(identifier);
if (sgn == _sceneGraphNodes.end()) {
LERROR(fmt::format(
LERROR(std::format(
"Couldn't add {} to message queue. No SceneGraphNode with identifier {} exists.",
softwareintegration::simp::getStringFromDataKey(dataKey), identifier
));
@@ -370,7 +370,7 @@ void SoftwareConnection::addToMessageQueue(
void SoftwareConnection::removeMessageQueue(const std::string& identifier) {
auto sgn = _sceneGraphNodes.find(identifier);
if (sgn == _sceneGraphNodes.end()) {
LERROR(fmt::format(
LERROR(std::format(
"Couldn't remove message queue. No SceneGraphNode with identifier {} exists.",
identifier
));
@@ -428,7 +428,7 @@ void SoftwareConnection::handleOutgoingMessages() {
size_t subjectBufferOffset = 0;
subjectBuffer.clear();
std::string subjectPrefixString = fmt::format(
std::string subjectPrefixString = std::format(
"{}{}{}{}", identifier, simp::DELIM, guiNameProp->stringValue(), simp::DELIM
);
simp::toByteBuffer(subjectBuffer, subjectBufferOffset, subjectPrefixString);
@@ -438,12 +438,12 @@ void SoftwareConnection::handleOutgoingMessages() {
for (auto& [dataKey, data] : sceneGraphNodeInfo.outgoingMessages) {
auto& [dataBuffer, nValues] = data;
std::string dataKeyString = fmt::format(
std::string dataKeyString = std::format(
"{}{}", simp::getStringFromDataKey(dataKey), simp::DELIM
);
std::string nValuesString = nValues > 1 ? std::to_string(nValues) : "";
LDEBUG(fmt::format("Sending {} {} to OpenSpace", nValuesString, simp::getStringFromDataKey(dataKey)));
LDEBUG(std::format("Sending {} {} to OpenSpace", nValuesString, simp::getStringFromDataKey(dataKey)));
simp::toByteBuffer(subjectBuffer, subjectBufferOffset, dataKeyString);
if (nValues > 1) {
@@ -494,7 +494,7 @@ void eventLoop(
if (!networkStateWeakPtr.expired()
& (!connectionPtr->_shouldStopThread || !connectionPtr->isConnectedOrConnecting())
) {
LDEBUG(fmt::format("Connection lost to {}: {}", connectionPtr->id(), err.message));
LDEBUG(std::format("Connection lost to {}: {}", connectionPtr->id(), err.message));
auto networkState = networkStateWeakPtr.lock();
if (networkState->softwareConnections.count(connectionPtr->id())) {
networkState->softwareConnections.erase(connectionPtr->id());
@@ -523,7 +523,7 @@ IncomingMessage receiveMessageFromSoftware(std::shared_ptr<SoftwareConnection> c
// Make sure that header matches the protocol version
if (protocolVersionIn != softwareintegration::simp::protocolVersion) {
throw SoftwareConnectionLostError(fmt::format(
throw SoftwareConnectionLostError(std::format(
"Protocol versions do not match. Remote version: {}, Local version: {}",
protocolVersionIn,
softwareintegration::simp::protocolVersion
@@ -499,11 +499,11 @@ void RenderablePointsCloud::update(const UpdateData&) {
if (updatedDataSlices) {
if (_vao == 0) {
glGenVertexArrays(1, &_vao);
LDEBUG(fmt::format("Generating Vertex Array id '{}'", _vao));
LDEBUG(std::format("Generating Vertex Array id '{}'", _vao));
}
if (_vbo == 0) {
glGenBuffers(1, &_vbo);
LDEBUG(fmt::format("Generating Vertex Buffer Object id '{}'", _vbo));
LDEBUG(std::format("Generating Vertex Buffer Object id '{}'", _vbo));
}
glBindVertexArray(_vao);
@@ -669,10 +669,9 @@ void RenderablePointsCloud::loadPointData(SoftwareIntegrationModule* softwareInt
pointUnit = distanceUnitFromString(_pointUnit.value().c_str());
}
catch (const ghoul::MissingCaseException& ) {
LERROR(fmt::format(
"Error when parsing point unit."
"OpenSpace doesn't support the distance unit '{}'.",
_pointUnit
LERROR(std::format(
"Error when parsing point unit. OpenSpace doesn't support the distance unit '{}'.",
_pointUnit.stringValue()
));
return;
}
@@ -696,7 +695,7 @@ void RenderablePointsCloud::loadPointData(SoftwareIntegrationModule* softwareInt
pointDataSlice->assign(pointData.begin(), pointData.end());
softwareIntegrationModule->setDataLoaded(_identifier.value(), storage::Key::DataPoints);
LINFO(fmt::format(
LINFO(std::format(
"New point data ({} points) has loaded. {} values are NaN values. "
"Points with at least one NaN value are hidden.",
(pointData.size() / 3), nNans
@@ -714,7 +713,7 @@ void RenderablePointsCloud::loadVelocityData(SoftwareIntegrationModule* software
// Check that velocity data is same length as point data
auto pointDataSlice = getDataSlice(DataSliceKey::Points);
// if (pointDataSlice->size() != velocityData.size()) {
// LWARNING(fmt::format(
// LWARNING(std::format(
// "There is a mismatch in the amount of velocity data ({}) and the amount of points ({})",
// velocityData.size() / 3, pointDataSlice->size() / 3
// ));
@@ -730,11 +729,11 @@ void RenderablePointsCloud::loadVelocityData(SoftwareIntegrationModule* software
velocityTimeUnit = timeUnitFromString(_velocityTimeUnit.value().c_str());
}
catch (const ghoul::MissingCaseException& ) {
LERROR(fmt::format(
LERROR(std::format(
"Error when parsing velocity units."
"OpenSpace doesn't support the velocity unit '{}/{}'.",
_velocityDistanceUnit,
_velocityTimeUnit
_velocityDistanceUnit.stringValue(),
_velocityTimeUnit.stringValue()
));
return;
}
@@ -774,7 +773,7 @@ void RenderablePointsCloud::loadVelocityData(SoftwareIntegrationModule* software
velocityDataSlice->assign(velocityData.begin(), velocityData.end());
LINFO(
fmt::format(
std::format(
"Viewing {} points with velocity ({} points in total). "
"{} points have NaN-value velocity and are hidden or static.",
velocityData.size()/3 - nNans/3,
@@ -828,7 +827,7 @@ void RenderablePointsCloud::loadColormapAttributeData(SoftwareIntegrationModule*
// Check that colormap attribute data is same length as point data
auto pointDataSlice = getDataSlice(DataSliceKey::Points);
// if (pointDataSlice->size() / 3 != colormapAttributeData.size()) {
// LWARNING(fmt::format(
// LWARNING(std::format(
// "There is a mismatch in the amount of colormap attribute scalars ({}) and the amount of points ({})",
// colormapAttributeData.size(), pointDataSlice->size() / 3
// ));
@@ -856,7 +855,7 @@ void RenderablePointsCloud::loadLinearSizeAttributeData(SoftwareIntegrationModul
// Check that linear size attribute data is same length as point data
auto pointDataSlice = getDataSlice(DataSliceKey::Points);
// if (pointDataSlice->size() / 3 != linearSizeAttributeData.size()) {
// LWARNING(fmt::format(
// LWARNING(std::format(
// "There is a mismatch in the amount of linear size attribute scalars ({}) and the amount of points ({})",
// linearSizeAttributeData.size(), pointDataSlice->size() / 3
// ));
@@ -895,11 +894,10 @@ void RenderablePointsCloud::checkIfColormapCanBeEnabled() {
}
global::scriptEngine->queueScript(
fmt::format(
std::format(
"openspace.setPropertyValueSingle('Scene.{}.Renderable.ColormapEnabled', {});",
_identifier.value(), "false"
),
scripting::ScriptEngine::RemoteScripting::Yes
)
);
}
}
@@ -913,11 +911,10 @@ void RenderablePointsCloud::checkIfLinearSizeCanBeEnabled() {
if (_linearSizeEnabled.value() && linearSizeAttributeData->empty()) {
LINFO("Linear size attribute data not loaded. Has it been sent from external software?");
global::scriptEngine->queueScript(
fmt::format(
std::format(
"openspace.setPropertyValueSingle('Scene.{}.Renderable.LinearSizeEnabled', {});",
_identifier.value(), "false"
),
scripting::ScriptEngine::RemoteScripting::Yes
)
);
}
}
@@ -930,11 +927,10 @@ void RenderablePointsCloud::checkIfMotionCanBeEnabled() {
if (_motionEnabled.value() && velocityData->empty()) {
LINFO("Velocity data not loaded. Has it been sent from external software?");
global::scriptEngine->queueScript(
fmt::format(
std::format(
"openspace.setPropertyValueSingle('Scene.{}.Renderable.MotionEnabled', {});",
_identifier.value(), "false"
),
scripting::ScriptEngine::RemoteScripting::Yes
)
);
}
}
@@ -63,7 +63,7 @@ bool writeToFile(std::filesystem::path path, const std::vector<std::byte>& buffe
return true;
}
catch (const std::ofstream::failure& e) {
errorMessage = fmt::format("Could not write to the file \"{}\". {}.", path.string(), e.what());
errorMessage = std::format("Could not write to the file \"{}\". {}.", path.string(), e.what());
return false;
}
}
@@ -83,7 +83,7 @@ bool readFile(std::filesystem::path path, std::vector<std::byte>& buffer, std::s
return true;
}
catch (const std::ifstream::failure& e) {
errorMessage = fmt::format("Couldn't read the file \"{}\". {}.", path.string(), e.what());
errorMessage = std::format("Couldn't read the file \"{}\". {}.", path.string(), e.what());
return false;
}
}
@@ -101,7 +101,7 @@ bool saveSessionData(SyncableStorage& storage,
}
if (std::filesystem::exists(filePath)) {
errorMessage = fmt::format("The file \"{}\" already exists.", filePath.filename().string());
errorMessage = std::format("The file \"{}\" already exists.", filePath.filename().string());
return false;
}
@@ -120,7 +120,7 @@ bool softwareintegration::Session::loadSessionData(SoftwareIntegrationModule* mo
) {
auto filePath = std::filesystem::path{filePathString};
if (!std::filesystem::exists(filePath) || !std::filesystem::is_regular_file(filePath)) {
errorMessage = fmt::format("File {} doesn't exists...", filePathString);
errorMessage = std::format("File {} doesn't exists...", filePathString);
LERROR(errorMessage);
return false;
}
@@ -136,7 +136,7 @@ bool softwareintegration::Session::loadSessionData(SoftwareIntegrationModule* mo
module->_syncableStorage.store(byteStream);
}
catch (const std::exception& e) {
errorMessage = fmt::format("Couldn't store loaded data in Software Integration storage", e.what());
errorMessage = std::format("Couldn't store loaded data in Software Integration storage", e.what());
LERROR(errorMessage);
return false;
}
@@ -155,12 +155,12 @@ bool softwareintegration::Session::saveSession(const std::string& wantedFileName
auto dirPath = absPath("${USER_ASSETS}") / wantedFileName;
if (std::filesystem::exists(dirPath)) {
errorMessage = fmt::format("A saved session with the name \"{}\" already exists.", dirPath.filename().string());
errorMessage = std::format("A saved session with the name \"{}\" already exists.", dirPath.filename().string());
return false;
}
if (!std::filesystem::create_directory(dirPath)) {
errorMessage = fmt::format("Could not create the folder \"{}\" in the user assets folder.", dirPath);
errorMessage = std::format("Could not create the folder \"{}\" in the user assets folder.", dirPath);
return false;
}
@@ -267,7 +267,7 @@ bool softwareintegration::Session::saveSession(const std::string& wantedFileName
<< INDENT << "end\n"
<< "end)\n\n"
<< "asset.meta = {\n"
<< INDENT << fmt::format("Name = \"{} (Software Integration session)\",", wantedFileName)
<< INDENT << std::format("Name = \"{} (Software Integration session)\",", wantedFileName)
<< "\n"
<< INDENT << "Version = \"1.0\",\n"
<< INDENT << "Description = [[]],\n"
@@ -280,7 +280,7 @@ bool softwareintegration::Session::saveSession(const std::string& wantedFileName
return true;
}
catch (std::ifstream::failure& err) {
errorMessage = fmt::format("An error occured when creating the asset file. {}.", err.what());
errorMessage = std::format("An error occured when creating the asset file. {}.", err.what());
return false;
}
}
+11 -11
View File
@@ -121,7 +121,7 @@ int32_t readInt32Value(const std::vector<std::byte>& message, size_t& offset) {
}
catch(std::exception &err) {
throw SimpError(
fmt::format("Error when trying to parse an integer at offset {}", err.what())
std::format("Error when trying to parse an integer at offset {}", err.what())
);
}
@@ -139,7 +139,7 @@ bool readBoolValue(const std::vector<std::byte>& message, size_t& offset) {
}
catch(std::exception &err) {
throw SimpError(
fmt::format("Error when trying to parse a bool at offset {}", err.what())
std::format("Error when trying to parse a bool at offset {}", err.what())
);
}
@@ -162,7 +162,7 @@ float readFloat32Value(const std::vector<std::byte>& message, size_t& offset) {
}
catch(std::exception &err) {
throw SimpError(
fmt::format("Error when trying to parse a float at offset = {}", err.what())
std::format("Error when trying to parse a float at offset = {}", err.what())
);
}
offset += 4;
@@ -206,11 +206,11 @@ std::string readString(const std::vector<std::byte>& message, size_t& offset) {
} // namespace
SimpError::SimpError(const tools::ErrorCode _errorCode, const std::string& msg)
: errorCode{errorCode}, ghoul::RuntimeError(fmt::format("{}: Error Code: {} - {}", "SIMP error", static_cast<uint32_t>(_errorCode), msg), "Software Integration Messaging Protocol error")
: errorCode{errorCode}, ghoul::RuntimeError(std::format("{}: Error Code: {} - {}", "SIMP error", static_cast<uint32_t>(_errorCode), msg), "Software Integration Messaging Protocol error")
{}
SimpError::SimpError(const std::string& msg)
: errorCode{tools::ErrorCode::Generic}, ghoul::RuntimeError(fmt::format("{}: Error Code: {} - {}", "SIMP error", static_cast<uint32_t>(errorCode), msg), "Software Integration Messaging Protocol error")
: errorCode{tools::ErrorCode::Generic}, ghoul::RuntimeError(std::format("{}: Error Code: {} - {}", "SIMP error", static_cast<uint32_t>(errorCode), msg), "Software Integration Messaging Protocol error")
{}
MessageType getMessageType(const std::string& type) {
@@ -275,7 +275,7 @@ std::string yearIntToString(int32_t yearAsInt) {
// (used in RenderablePointsCloud::updateVelocityT0) just converts
// negative values to small values
if (yearAsInt < 0) {
LERROR(fmt::format(
LERROR(std::format(
"The year can't be negative. The provided year: {}",
yearAsInt
));
@@ -311,14 +311,14 @@ std::string monthIntToString(int32_t monthAsInt) {
case 12:
return "DEC";
default:
LERROR(fmt::format("There's no month {}", monthAsInt));
LERROR(std::format("There's no month {}", monthAsInt));
return "";
}
}
std::string dayIntToString(int32_t dayAsInt) {
if (dayAsInt < 0 || dayAsInt > 31) {
LERROR(fmt::format(
LERROR(std::format(
"There was an issue trying to convert the day as int to a string. The provided day as int: {}",
dayAsInt
));
@@ -337,7 +337,7 @@ std::string toDateString(glm::ivec3 dateVec) {
dateString += simp::yearIntToString(dateVec[0]); // Year
dateString += " " + simp::monthIntToString(dateVec[1]); // Month
dateString += " " + simp::dayIntToString(dateVec[2]); // Day
LWARNING(fmt::format("dateString='{}'", dateString));
LWARNING(std::format("dateString='{}'", dateString));
return dateString;
}
@@ -354,7 +354,7 @@ bool readColorChannel(
simp::readValue(message, offset, newChannelValue);
}
catch (const simp::SimpError& err) {
LERROR(fmt::format(
LERROR(std::format(
"Error when parsing float in {} message: {}",
simp::getStringFromDataKey(dataKey), err.message
));
@@ -376,7 +376,7 @@ bool readDateValue(
simp::readValue(message, offset, newTimeValue);
}
catch (const simp::SimpError& err) {
LERROR(fmt::format(
LERROR(std::format(
"Error when parsing int in {} message: {}",
simp::getStringFromDataKey(dataKey), err.message
));
+3 -1
View File
@@ -26,6 +26,8 @@
#define __OPENSPACE_MODULE_SOFTWAREINTEGRATION___SIMP___H__
#include <unordered_map>
#include <cstring>
#include <string>
namespace openspace::softwareintegration::simp {
@@ -37,7 +39,7 @@ const uint8_t _version_patch = 1;
} // namespace
const std::string protocolVersion = fmt::format("{}.{}.{}", _version_major, _version_minor, _version_patch);
const std::string protocolVersion = std::format("{}.{}.{}", _version_major, _version_minor, _version_patch);
const char DELIM = ';';
const std::byte DELIM_BYTES{ DELIM };
@@ -112,7 +112,7 @@ void SyncableStorage::setLoaded(const Identifier& identifier, const storage::Key
auto simpDataKeys = simpDataKeysFromStorageKey(storageKey);
for (auto key : simpDataKeys) {
if (!count(identifier, key)) {
LERROR(fmt::format(
LERROR(std::format(
"SceneGraphNode {} has no data with key '{}' in the syncable data storage",
identifier,
simp::getStringFromDataKey(key)
@@ -142,7 +142,7 @@ void SyncableStorage::store(
const simp::DataKey key,
const std::vector<std::byte>& data
) {
LDEBUG(fmt::format("Storing data in float data storage: {}-{}", identifier, simp::getStringFromDataKey(key)));
LDEBUG(std::format("Storing data in float data storage: {}-{}", identifier, simp::getStringFromDataKey(key)));
std::lock_guard guard(_mutex);
insertAssign(identifier, key, { data });
}
@@ -278,7 +278,7 @@ std::vector<simp::DataKey> SyncableStorage::simpDataKeysFromStorageKey(const sto
return { simp::DataKey::LinearSizeAttributeData };
}
default: { // Unknown
LERROR(fmt::format(
LERROR(std::format(
"There's no storage key '{}'",
storage::getStorageKeyString(key)
));
@@ -302,7 +302,7 @@ bool SyncableStorage::fetchDimFloatData(
size_t nValues = dimDataKeys.size();
if (!count(identifier)) {
LERROR(fmt::format(
LERROR(std::format(
"SceneGraphNode {} is missing from the syncable data storage",
identifier
));
@@ -313,7 +313,7 @@ bool SyncableStorage::fetchDimFloatData(
for (size_t i = 0; i < nDimensions; i++) {
if (!count(identifier, dimDataKeys[i])) {
LERROR(fmt::format(
LERROR(std::format(
"SceneGraphNode {} is missing {} from the syncable data storage",
identifier, simp::getStringFromDataKey(dimDataKeys[i])
));
@@ -324,7 +324,7 @@ bool SyncableStorage::fetchDimFloatData(
// All dimensions must have same length
if (i != 0 && nBytesPerDim != dimValues.size()) {
LERROR(fmt::format(
LERROR(std::format(
"Error while trying to fetch float data."
"The dimensions of values does not have the same length."
));
@@ -356,7 +356,7 @@ bool SyncableStorage::fetchDimFloatData(
);
}
catch (const simp::SimpError& err) {
LERROR(fmt::format(
LERROR(std::format(
"Couldn't parse value on offset {} from storage for {}: {}",
offset, simp::getStringFromDataKey(dimDataKeys[i]), err.message
));
@@ -378,7 +378,7 @@ bool SyncableStorage::fetchDimFloatData(
dataKeysString += prefix + simp::getStringFromDataKey(dimDataKeys[i]);
}
dataKeysString += ")";
LERROR(fmt::format(
LERROR(std::format(
"Mismatch in number of values in syncable storage ({}) and loaded values ({}), when loading {}.",
resultingData.size(), nAddedValues, dataKeysString
));
@@ -32,10 +32,10 @@ bool SyncableStorage::fetch(
const storage::Key storageKey,
T& resultingData
) {
LDEBUGC("SyncableStorage", fmt::format("Loading data from float data storage: {}-{}", identifier, storage::getStorageKeyString(storageKey)));
LDEBUGC("SyncableStorage", std::format("Loading data from float data storage: {}-{}", identifier, storage::getStorageKeyString(storageKey)));
std::lock_guard guard(_mutex);
if (!count(identifier)) {
LERRORC("SyncableStorage", fmt::format(
LERRORC("SyncableStorage", std::format(
"Could not find any data for SceneGraphNode '{}' in the centralized data storage",
identifier
));
@@ -49,7 +49,7 @@ bool SyncableStorage::fetch(
case storage::Key::LinearSizeAttrData:
case storage::Key::VelocityData: {
if (!std::is_same<T, std::vector<float>>::value) {
LERRORC("SyncableStorage", fmt::format(
LERRORC("SyncableStorage", std::format(
"Can't put {} into a {}.",
storage::getStorageKeyString(storageKey), typeid(T).name()
));
@@ -59,7 +59,7 @@ bool SyncableStorage::fetch(
return fetchDimFloatData(identifier, simpDataKeysFromStorageKey(storageKey), resultingData);
}
default: {
LERRORC("SyncableStorage", fmt::format(
LERRORC("SyncableStorage", std::format(
"Could not find data in storage for the key {}",
storage::getStorageKeyString(storageKey)
));