Provide correct error message if the ProfileName is empty

Don't include Voyager and Pioneer in the base asset as it takes too long to load
Ensure that the webgui asset can load without the dashboard
Fix scripting issue in Rosetta scene with trails
Fix issue with Dashboards that would actually render one line too far down causing trouble with multiline text
Set the render option for renderablebillboards to view direction by default as the normal mode has some issues (see #1342)
Set more sensible maximum value for RenderablePlanesCloud
Correctly show the number of significant digits in the altitude
Replace setPropertyValue with setPropertyValueSingle when clicking on the friction "buttons" on screen
Add a new script function hasProperty to check whether a property exits
This commit is contained in:
Alexander Bock
2020-10-17 20:10:15 +02:00
parent 0838973b5a
commit 0779c54a07
21 changed files with 86 additions and 44 deletions

View File

@@ -496,27 +496,27 @@ bool ProfileEdit::isReadOnly(std::string profileSave) {
void ProfileEdit::approved() {
QString profileName = _profileEdit->text();
if (profileName.isEmpty()) {
_errorMsg->setText("Profile name must be specified");
return;
}
if ((profileName.length() > 0) && !isReadOnly(profileName.toStdString())) {
_saveSelected = true;
_errorMsg->setText("");
accept();
}
else {
//QString formatText = "<font color='red'>";
//formatText += ui->label_profile->text();
//formatText += "</font>";
//ui->label_profile->setText(formatText);
QString errorLabel = "<font color='red'>";
errorLabel += "This is a read-only profile. Click 'duplicate' or rename & save.";
errorLabel += "</font>";
_errorMsg->setText(errorLabel);
_errorMsg->setText(
"This is a read-only profile. Click 'duplicate' or rename & save"
);
}
}
void ProfileEdit::keyPressEvent(QKeyEvent *evt)
{
if(evt->key() == Qt::Key_Enter || evt->key() == Qt::Key_Return)
void ProfileEdit::keyPressEvent(QKeyEvent* evt) {
if (evt->key() == Qt::Key_Enter || evt->key() == Qt::Key_Return) {
return;
}
QDialog::keyPressEvent(evt);
}

View File

@@ -15,7 +15,6 @@ asset.require('scene/solarsystem/planets/mars/moons/deimos')
asset.require('scene/solarsystem/dwarf_planets/pluto/system')
asset.require('scene/solarsystem/dwarf_planets/pluto/default_layers')
asset.require('scene/solarsystem/dwarf_planets/pluto/charon/default_layers')
asset.require('scene/solarsystem/missions/voyagerpioneer/voyager1_2__pioneer10_11')
asset.require('scene/milkyway/milkyway/volume')
asset.require('scene/milkyway/constellations/constellation_art')
asset.require('scene/milkyway/constellations/constellation_keybinds')

View File

@@ -40,8 +40,12 @@ asset.onInitialize(function ()
-- The GUI contains date and simulation increment,
-- so let's remove these from the dashboard.
if openspace.getPropertyValue('Modules.CefWebGui.Visible') then
openspace.setPropertyValueSingle('Dashboard.Date.Enabled', false)
openspace.setPropertyValueSingle('Dashboard.SimulationIncrement.Enabled', false)
if openspace.hasProperty('Dashboard.Date.Enabled') then
openspace.setPropertyValueSingle('Dashboard.Date.Enabled', false)
end
if openspace.hasProperty('Dashboard.SimulationIncrement.Enabled') then
openspace.setPropertyValueSingle('Dashboard.SimulationIncrement.Enabled', false)
end
end
end)

View File

@@ -98,7 +98,7 @@
"is_local": false,
"key": "O",
"name": "Toggle Philae trail",
"script": "openspace.setPropertyValueSingle(Scene.PhilaeTrail.Renderable.Enabled', not openspace.getPropertyValue(Scene.PhilaeTrail.Renderable.Enabled'));"
"script": "openspace.setPropertyValueSingle('Scene.PhilaeTrail.Renderable.Enabled', not openspace.getPropertyValue('Scene.PhilaeTrail.Renderable.Enabled'));"
},
{
"documentation": "Enables or disables the image projection on 67P.",
@@ -106,7 +106,7 @@
"is_local": false,
"key": "P",
"name": "Toggle 67P projection",
"script": "openspace.setPropertyValueSingle(Scene.67P.Renderable.ProjectionComponent.PerformProjection', not openspace.getPropertyValue(Scene.67P.Renderable.ProjectionComponent.PerformProjection'));"
"script": "openspace.setPropertyValueSingle('Scene.67P.Renderable.ProjectionComponent.PerformProjection', not openspace.getPropertyValue('Scene.67P.Renderable.ProjectionComponent.PerformProjection'));"
}
],
"mark_nodes": [

View File

@@ -404,7 +404,6 @@ void DashboardItemAngle::render(glm::vec2& penPosition) {
std::fill(_buffer.begin(), _buffer.end(), 0);
if (glm::length(a) == 0.0 || glm::length(b) == 0) {
penPosition.y -= _font->height();
char* end = fmt::format_to(
_buffer.data(),
"Could not compute angle at {} between {} and {}",
@@ -412,13 +411,13 @@ void DashboardItemAngle::render(glm::vec2& penPosition) {
);
std::string_view text = std::string_view(_buffer.data(), end - _buffer.data());
RenderFont(*_font, penPosition, text);
penPosition.y -= _font->height();
}
else {
const double angle = glm::degrees(
glm::acos(glm::dot(a, b) / (glm::length(a) * glm::length(b)))
);
penPosition.y -= _font->height();
char* end = fmt::format_to(
_buffer.data(),
"Angle at {} between {} and {}: {} degrees",
@@ -426,6 +425,7 @@ void DashboardItemAngle::render(glm::vec2& penPosition) {
);
std::string_view text = std::string_view(_buffer.data(), end - _buffer.data());
RenderFont(*_font, penPosition, text);
penPosition.y -= _font->height();
}
}

View File

@@ -113,12 +113,12 @@ DashboardItemDate::DashboardItemDate(const ghoul::Dictionary& dictionary)
void DashboardItemDate::render(glm::vec2& penPosition) {
ZoneScoped
penPosition.y -= _font->height();
RenderFont(
*_font,
penPosition,
fmt::format("Date: {} UTC", global::timeManager.time().UTC())
);
penPosition.y -= _font->height();
}
glm::vec2 DashboardItemDate::size() const {

View File

@@ -444,7 +444,6 @@ void DashboardItemDistance::render(glm::vec2& penPosition) {
dist = { convertedD, nameForDistanceUnit(unit, convertedD != 1.0) };
}
penPosition.y -= _font->height();
std::fill(_buffer.begin(), _buffer.end(), 0);
char* end = fmt::format_to(
_buffer.data(),
@@ -454,6 +453,7 @@ void DashboardItemDistance::render(glm::vec2& penPosition) {
std::string_view text = std::string_view(_buffer.data(), end - _buffer.data());
RenderFont(*_font, penPosition, text);
penPosition.y -= _font->height();
}
glm::vec2 DashboardItemDistance::size() const {

View File

@@ -149,6 +149,21 @@ namespace {
throw ghoul::MissingCaseException();
}
}
[[ nodiscard ]] int nLines(
openspace::DashboardItemFramerate::FrametimeType frametimeType)
{
using FrametimeType = openspace::DashboardItemFramerate::FrametimeType;
switch (frametimeType) {
case FrametimeType::DtTimeAvg: return 1;
case FrametimeType::DtTimeExtremes: return 2;
case FrametimeType::DtStandardDeviation: return 1;
case FrametimeType::DtCoefficientOfVariation: return 1;
case FrametimeType::FPS: return 1;
case FrametimeType::FPSAvg: return 1;
default: throw ghoul::MissingCaseException();
}
}
} // namespace
namespace openspace {
@@ -309,13 +324,12 @@ void DashboardItemFramerate::render(glm::vec2& penPosition) {
int nLines = output.empty() ? 0 :
static_cast<int>((std::count(output.begin(), output.end(), '\n') + 1));
penPosition.y -= _font->height() * static_cast<float>(nLines);
ghoul::fontrendering::FontRenderer::defaultRenderer().render(
*_font,
penPosition,
output
);
penPosition.y -= _font->height() * static_cast<float>(nLines);
}
glm::vec2 DashboardItemFramerate::size() const {

View File

@@ -209,7 +209,6 @@ void DashboardItemMission::render(glm::vec2& penPosition) {
1.0 - remaining / phase->timeRange().duration()
);
const std::string progress = progressToStr(25, t);
penPosition.y -= _font->height();
RenderFont(
*_font,
penPosition,
@@ -219,16 +218,17 @@ void DashboardItemMission::render(glm::vec2& penPosition) {
),
currentMissionColor
);
penPosition.y -= _font->height();
}
else {
if (!phase->name().empty()) {
penPosition.y -= _font->height();
RenderFont(
*_font,
penPosition,
phase->name(),
nonCurrentMissionColor
);
penPosition.y -= _font->height();
}
}
penPosition.x -= depth * PixelIndentation;

View File

@@ -161,8 +161,8 @@ void DashboardItemParallelConnection::render(glm::vec2& penPosition) {
}
if (!connectionInfo.empty()) {
penPosition.y -= _font->height();
RenderFont(*_font, penPosition, connectionInfo);
penPosition.y -= _font->height();
}
}

View File

@@ -163,8 +163,8 @@ void DashboardItemPropertyValue::render(glm::vec2& penPosition) {
std::string value;
_property->getStringValue(value);
penPosition.y -= _font->height();
RenderFont(*_font, penPosition, fmt::format(_displayString.value(), value));
penPosition.y -= _font->height();
}
}

View File

@@ -203,7 +203,6 @@ void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) {
std::string pauseText = global::timeManager.isPaused() ? " (Paused)" : "";
penPosition.y -= _font->height();
if (targetDt != currentDt && !global::timeManager.isPaused()) {
// We are in the middle of a transition
RenderFont(
@@ -227,6 +226,7 @@ void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) {
)
);
}
penPosition.y -= _font->height();
}
glm::vec2 DashboardItemSimulationIncrement::size() const {

View File

@@ -208,7 +208,6 @@ void DashboardItemVelocity::render(glm::vec2& penPosition) {
dist = { convertedD, nameForDistanceUnit(unit, convertedD != 1.0) };
}
penPosition.y -= _font->height();
RenderFont(
*_font,
penPosition,
@@ -216,6 +215,7 @@ void DashboardItemVelocity::render(glm::vec2& penPosition) {
"Camera velocity: {} {}/s", dist.first, dist.second
)
);
penPosition.y -= _font->height();
_prevPosition = currentPos;
}

View File

@@ -481,7 +481,7 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
_renderOption.addOption(RenderOptionViewDirection, "Camera View Direction");
_renderOption.addOption(RenderOptionPositionNormal, "Camera Position Normal");
_renderOption = RenderOptionPositionNormal;
_renderOption = RenderOptionViewDirection;
if (dictionary.hasKeyAndValue<std::string>(RenderOptionInfo.identifier)) {
const std::string o = dictionary.value<std::string>(RenderOptionInfo.identifier);

View File

@@ -299,7 +299,7 @@ documentation::Documentation RenderablePlanesCloud::Documentation() {
RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _scaleFactor(ScaleFactorInfo, 1.f, 0.f, 10000.f)
, _scaleFactor(ScaleFactorInfo, 1.f, 0.f, 100.f)
, _textColor(TextColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f))
, _textOpacity(TextOpacityInfo, 1.f, 0.f, 1.f)
, _textSize(TextSizeInfo, 8.0, 0.5, 24.0)

View File

@@ -139,10 +139,10 @@ DashboardItemGlobeLocation::DashboardItemGlobeLocation(
auto updateFormatString = [this]() {
using namespace fmt::literals;
_formatString =
"Position: {{:03.{0}f}}{{}}, {{:03.{0}f}}{{}} Altitude: {{}} {{}}"_format(
_significantDigits.value()
);
_formatString = fmt::format(
"Position: {{:03.{0}f}}{{}}, {{:03.{0}f}}{{}} Altitude: {{:03.{0}f}} {{}}",
_significantDigits.value()
);
};
_significantDigits.onChange(updateFormatString);
addProperty(_significantDigits);
@@ -199,8 +199,6 @@ void DashboardItemGlobeLocation::render(glm::vec2& penPosition) {
std::pair<double, std::string> dist = simplifyDistance(altitude);
penPosition.y -= _font->height();
std::fill(_buffer.begin(), _buffer.end(), 0);
char* end = fmt::format_to(
_buffer.data(),
@@ -212,7 +210,9 @@ void DashboardItemGlobeLocation::render(glm::vec2& penPosition) {
std::string_view text = std::string_view(_buffer.data(), end - _buffer.data());
RenderFont(*_font, penPosition, text);
penPosition.y -= _font->height();
}
glm::vec2 DashboardItemGlobeLocation::size() const {
ZoneScoped

View File

@@ -52,7 +52,7 @@ Dashboard::Dashboard()
: properties::PropertyOwner({ "Dashboard" })
, _isEnabled(EnabledInfo, true)
, _startPositionOffset(
properties::IVec2Property(StartPositionOffsetInfo, glm::ivec2(10, -10))
properties::IVec2Property(StartPositionOffsetInfo, glm::ivec2(10, -25))
)
{
addProperty(_isEnabled);

View File

@@ -758,7 +758,7 @@ bool RenderEngine::mouseActivationCallback(const glm::dvec2& mousePosition) cons
if (intersects(mousePosition, _cameraButtonLocations.rotation)) {
constexpr const char* ToggleRotationFrictionScript = R"(
local f = 'NavigationHandler.OrbitalNavigator.Friction.RotationalFriction';
openspace.setPropertyValue(f, not openspace.getPropertyValue(f));)";
openspace.setPropertyValueSingle(f, not openspace.getPropertyValue(f));)";
global::scriptEngine.queueScript(
ToggleRotationFrictionScript,
@@ -770,7 +770,7 @@ bool RenderEngine::mouseActivationCallback(const glm::dvec2& mousePosition) cons
if (intersects(mousePosition, _cameraButtonLocations.zoom)) {
constexpr const char* ToggleZoomFrictionScript = R"(
local f = 'NavigationHandler.OrbitalNavigator.Friction.ZoomFriction';
openspace.setPropertyValue(f, not openspace.getPropertyValue(f));)";
openspace.setPropertyValueSingle(f, not openspace.getPropertyValue(f));)";
global::scriptEngine.queueScript(
ToggleZoomFrictionScript,
@@ -782,7 +782,7 @@ bool RenderEngine::mouseActivationCallback(const glm::dvec2& mousePosition) cons
if (intersects(mousePosition, _cameraButtonLocations.roll)) {
constexpr const char* ToggleRollFrictionScript = R"(
local f = 'NavigationHandler.OrbitalNavigator.Friction.RollFriction';
openspace.setPropertyValue(f, not openspace.getPropertyValue(f));)";
openspace.setPropertyValueSingle(f, not openspace.getPropertyValue(f));)";
global::scriptEngine.queueScript(
ToggleRollFrictionScript,

View File

@@ -636,13 +636,19 @@ scripting::LuaLibrary Scene::luaLibrary() {
"This is the same as calling the setValue method and passing 'single' as "
"the fourth argument to setPropertyValue."
},
{
"hasProperty",
&luascriptfunctions::property_hasProperty,
{},
"string",
"Returns whether a property with the given URI exists"
},
{
"getPropertyValue",
&luascriptfunctions::property_getValue,
{},
"string",
"Returns the value the property, identified by "
"the provided URI."
"Returns the value the property, identified by the provided URI."
},
{
"getProperty",

View File

@@ -376,6 +376,25 @@ int property_setValueSingle(lua_State* L) {
return property_setValue(L);
}
/**
* \ingroup LuaScripts
* hasProperty(string):
* Returns whether a property with the given URI exists
*/
int property_hasProperty(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::property_hasProperty");
std::string uri = ghoul::lua::value<std::string>(
L,
1,
ghoul::lua::PopValue::Yes
);
openspace::properties::Property* prop = property(uri);
ghoul::lua::push(L, prop != nullptr);
return 1;
}
/**
* \ingroup LuaScripts
* getPropertyValue(string):
@@ -389,7 +408,7 @@ int property_getValue(lua_State* L) {
L,
1,
ghoul::lua::PopValue::Yes
);
);
openspace::properties::Property* prop = property(uri);
if (!prop) {