OpenSpace and Glue can both send and receive messages, and update their properties.

This commit is contained in:
aniisaaden
2020-09-18 13:39:41 +02:00
parent 3282dc80b2
commit 424e99ebed
5 changed files with 79 additions and 78 deletions

View File

@@ -141,77 +141,5 @@ namespace openspace {
return true;
}
void SoftwareConnection::handleProperties(std::string identifier) {
const Renderable* myRenderable = renderable(identifier);
properties::Property* colorProperty = myRenderable->property("Color");
properties::Property* opacityProperty = myRenderable->property("Opacity");
properties::Property* sizeProperty = myRenderable->property("Size");
// Update color of renderable
auto updateColor = [colorProperty, identifier]() {
std::string lengthOfIdentifier = std::to_string(identifier.length());
std::string propertyValue = colorProperty->getStringValue();
std::string lengthOfValue = std::to_string(propertyValue.length());
std::string messageType = "UPCO";
std::string subject = lengthOfIdentifier + identifier + lengthOfValue + propertyValue;
// Format length of subject to always be 4 digits
std::ostringstream os;
os << std::setfill('0') << std::setw(4) << subject.length();
std::string lengthOfSubject = os.str();
std::string message = messageType + lengthOfSubject + subject;
SoftwareConnection send;
send.sendMessage(message);
LERROR(fmt::format("Meddelandet som skickas {}", message));
};
colorProperty->onChange(updateColor);
/*
// Update opacity of renderable
auto updateOpacity = [opacityProperty, identifier]() {
std::string lengthOfIdentifier = std::to_string(identifier.length());
std::string propertyValue = opacityProperty->getStringValue();
std::string lengthOfValue = std::to_string(propertyValue.length());
std::string messageType = "UPOP";
std::string subject = lengthOfIdentifier + identifier + lengthOfValue + propertyValue;
// Format length of subject to always be 4 digits
std::ostringstream os;
os << std::setfill('0') << std::setw(4) << subject.length();
std::string lengthOfSubject = os.str();
std::string message = messageType + lengthOfSubject + subject;
SoftwareConnection send;
send.sendMessage(message);
LERROR(fmt::format("Meddelandet som skickas {}", message));
};
opacityProperty->onChange(updateOpacity);
// Update size of renderable
auto updateSize = [sizeProperty, identifier]() {
std::string lengthOfIdentifier = std::to_string(identifier.length());
std::string propertyValue = sizeProperty->getStringValue();
std::string lengthOfValue = std::to_string(propertyValue.length());
std::string messageType = "UPSI";
std::string subject = lengthOfIdentifier + identifier + lengthOfValue + propertyValue;
// Format length of subject to always be 4 digits
std::ostringstream os;
os << std::setfill('0') << std::setw(4) << subject.length();
std::string lengthOfSubject = os.str();
std::string message = messageType + lengthOfSubject + subject;
SoftwareConnection send;
send.sendMessage(message);
LERROR(fmt::format("Meddelandet som skickas {}", message));
};
sizeProperty->onChange(updateSize);
*/
}
} // namespace openspace