From 6f63da86b49c4d9901caac427e83b8dda136287c Mon Sep 17 00:00:00 2001 From: Stefan Seibert Date: Tue, 18 Feb 2020 10:39:48 +0100 Subject: [PATCH 1/6] Exposed linear flight factor as property --- include/openspace/interaction/orbitalnavigator.h | 3 ++- src/interaction/orbitalnavigator.cpp | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/openspace/interaction/orbitalnavigator.h b/include/openspace/interaction/orbitalnavigator.h index c6671c8d6f..623cc5fd3f 100644 --- a/include/openspace/interaction/orbitalnavigator.h +++ b/include/openspace/interaction/orbitalnavigator.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -143,8 +144,8 @@ private: properties::FloatProperty _followAnchorNodeRotationDistance; properties::FloatProperty _minimumAllowedDistance; properties::FloatProperty _flightDestinationDistance; + properties::DoubleProperty _flightDestinationFactor; properties::BoolProperty _applyLinearFlight; - properties::FloatProperty _velocitySensitivity; properties::FloatProperty _mouseSensitivity; diff --git a/src/interaction/orbitalnavigator.cpp b/src/interaction/orbitalnavigator.cpp index 773aca85ea..91258ed584 100644 --- a/src/interaction/orbitalnavigator.cpp +++ b/src/interaction/orbitalnavigator.cpp @@ -34,7 +34,6 @@ namespace { constexpr const double AngleEpsilon = 1E-7; constexpr const double DistanceRatioAimThreshold = 1E-4; - constexpr const double FlightDestinationFactor = 1E-4; constexpr const openspace::properties::Property::PropertyInfo AnchorInfo = { "Anchor", @@ -155,6 +154,12 @@ namespace { "The final distance we want to fly to, with regards to the anchor node." }; + constexpr openspace::properties::Property::PropertyInfo FlightDestinationFactorInfo = { + "FlightDestinationFactor", + "Flight Destination Factor", + "The minimal distance factor that we need to reach to end linear flight." + }; + constexpr openspace::properties::Property::PropertyInfo StereoInterpolationTimeInfo = { "StereoInterpolationTime", @@ -232,6 +237,7 @@ OrbitalNavigator::OrbitalNavigator() , _velocitySensitivity(VelocityZoomControlInfo, 0.02f, 0.01f, 0.15f) , _applyLinearFlight(ApplyLinearFlightInfo, false) , _flightDestinationDistance(FlightDestinationDistanceInfo, 2e8f, 0.0f, 1e10f) + , _flightDestinationFactor(FlightDestinationFactorInfo, 1E-4) , _mouseSensitivity(MouseSensitivityInfo, 15.0f, 1.0f, 50.f) , _joystickSensitivity(JoystickSensitivityInfo, 10.0f, 1.0f, 50.f) , _websocketSensitivity(WebsocketSensitivityInfo, 10.0f, 1.0f, 50.f) @@ -362,6 +368,7 @@ OrbitalNavigator::OrbitalNavigator() addProperty(_minimumAllowedDistance); addProperty(_velocitySensitivity); addProperty(_flightDestinationDistance); + addProperty(_flightDestinationFactor); addProperty(_applyLinearFlight); addProperty(_useAdaptiveStereoscopicDepth); @@ -440,7 +447,7 @@ void OrbitalNavigator::updateCameraStateFromStates(double deltaTime) { double distFromCameraToFocus = glm::distance(prevCameraPosition, anchorPos) - nodeRadius; // Make the approximation delta size depending on the flight distance - double arrivalThreshold = _flightDestinationDistance.value() * FlightDestinationFactor; + double arrivalThreshold = _flightDestinationDistance.value() * _flightDestinationFactor; // Fly towards the flight destination distance. When getting closer than arrivalThreshold terminate the flight if (abs(distFromCameraToFocus - _flightDestinationDistance.value()) > arrivalThreshold) { From e94a08f86618eed37fb961e12f03931efa741978 Mon Sep 17 00:00:00 2001 From: Stefan Seibert Date: Tue, 18 Feb 2020 10:52:31 +0100 Subject: [PATCH 2/6] Added min and max --- src/interaction/orbitalnavigator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/interaction/orbitalnavigator.cpp b/src/interaction/orbitalnavigator.cpp index 91258ed584..efcd4bace1 100644 --- a/src/interaction/orbitalnavigator.cpp +++ b/src/interaction/orbitalnavigator.cpp @@ -237,7 +237,7 @@ OrbitalNavigator::OrbitalNavigator() , _velocitySensitivity(VelocityZoomControlInfo, 0.02f, 0.01f, 0.15f) , _applyLinearFlight(ApplyLinearFlightInfo, false) , _flightDestinationDistance(FlightDestinationDistanceInfo, 2e8f, 0.0f, 1e10f) - , _flightDestinationFactor(FlightDestinationFactorInfo, 1E-4) + , _flightDestinationFactor(FlightDestinationFactorInfo, 1E-4, 1E-6, 0.5) , _mouseSensitivity(MouseSensitivityInfo, 15.0f, 1.0f, 50.f) , _joystickSensitivity(JoystickSensitivityInfo, 10.0f, 1.0f, 50.f) , _websocketSensitivity(WebsocketSensitivityInfo, 10.0f, 1.0f, 50.f) From bc1af5e210a5e34ab5684e51314609de9e74dbdd Mon Sep 17 00:00:00 2001 From: PTrottier Date: Mon, 2 Mar 2020 19:08:22 -0500 Subject: [PATCH 3/6] Fix 404s in compiling instructions Add the docs in the path. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d3e3a46182..76dbc82bb2 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,6 @@ The project stems from the same academic collaboration between Sweden’s [Link OpenSpace requires graphics support for [OpenGL](https://www.opengl.org/) version 3.3. -This repository contains the source code and example scenes for OpenSpace, but does not contain any data. To build and install the client, we refer to the [OpenSpace Wiki](http://wiki.openspaceproject.com/), specifically [building](http://wiki.openspaceproject.com/developer/compiling/general) for [Windows](http://wiki.openspaceproject.com/developer/compiling/windows), [Linux (Ubuntu)](http://wiki.openspaceproject.com/developer/compiling/ubuntu), and [MacOS](http://wiki.openspaceproject.com/developer/compiling/macos). Required preexisting dependencies are: [Boost](http://www.boost.org/) and [Qt](http://www.qt.io/download). Feel free to create issues for missing features, bug reports, or compile problems or contact us via [email](mailto:alexander.bock@me.com?subject=OpenSpace:). +This repository contains the source code and example scenes for OpenSpace, but does not contain any data. To build and install the client, we refer to the [OpenSpace Wiki](http://wiki.openspaceproject.com/), specifically [building](http://wiki.openspaceproject.com/docs/developers/compiling/general) for [Windows](http://wiki.openspaceproject.com/docs/developers/compiling/windows), [Linux (Ubuntu)](http://wiki.openspaceproject.com/docs/developers/compiling/ubuntu), and [MacOS](http://wiki.openspaceproject.com/docs/developers/compiling/macos). Required preexisting dependencies are: [Boost](http://www.boost.org/) and [Qt](http://www.qt.io/download). Feel free to create issues for missing features, bug reports, or compile problems or contact us via [email](mailto:alexander.bock@me.com?subject=OpenSpace:). Regarding any issues, you are very welcome on our [Slack support channel](https://openspacesupport.slack.com) to which you can freely [sign-up](https://join.slack.com/t/openspacesupport/shared_invite/enQtMjUxNzUyMTQ1ODQxLTI4YjNmMTY3ZDI1N2Q1NWM1ZjQ1NTQyNzAxM2YyMGQ5Y2NmYWJiNjI1NjU4YTkyNTc5ZDE5NzdhNGM2YmUzYTk). From 38d0f46ca605823c3aaad18ee3f6ddf9b316953f Mon Sep 17 00:00:00 2001 From: stefanseibert Date: Wed, 4 Mar 2020 15:57:34 +0100 Subject: [PATCH 4/6] Added a way to customize renderable distance labels unit --- modules/base/rendering/renderablelabels.cpp | 18 ++++++ modules/base/rendering/renderablelabels.h | 2 + .../rendering/renderabledistancelabel.cpp | 57 +++++++++++++++++-- .../rendering/renderabledistancelabel.h | 2 + 4 files changed, 73 insertions(+), 6 deletions(-) diff --git a/modules/base/rendering/renderablelabels.cpp b/modules/base/rendering/renderablelabels.cpp index e661982bc0..2fa6c17ba4 100644 --- a/modules/base/rendering/renderablelabels.cpp +++ b/modules/base/rendering/renderablelabels.cpp @@ -784,4 +784,22 @@ float RenderableLabels::unit(int unit) const { } } +std::string RenderableLabels::toString(int unit) const { + switch (static_cast(unit)) { + case Meter: return MeterUnit; + case Kilometer: return KilometerUnit; + case Megameter: return MegameterUnit; + case Gigameter: return GigameterUnit; + case AU: return AstronomicalUnit; + case Terameter: return TerameterUnit; + case Petameter: return PetameterUnit; + case Parsec: return ParsecUnit; + case Kiloparsec: return KiloparsecUnit; + case Megaparsec: return MegaparsecUnit; + case Gigaparsec: return GigaparsecUnit; + case GigalightYears: return GigalightyearUnit; + default: throw std::logic_error("Missing case label"); + } +} + } // namespace openspace diff --git a/modules/base/rendering/renderablelabels.h b/modules/base/rendering/renderablelabels.h index 7be35abaef..c35d52d451 100644 --- a/modules/base/rendering/renderablelabels.h +++ b/modules/base/rendering/renderablelabels.h @@ -74,6 +74,8 @@ protected: float unit(int unit) const; + std::string toString(int unit) const; + // Data may require some type of transformation prior the spice transformation being // applied. glm::dmat4 _transformationMatrix = glm::dmat4(1.0); diff --git a/modules/vislab/rendering/renderabledistancelabel.cpp b/modules/vislab/rendering/renderabledistancelabel.cpp index 1d2cac67b8..47508e3114 100644 --- a/modules/vislab/rendering/renderabledistancelabel.cpp +++ b/modules/vislab/rendering/renderabledistancelabel.cpp @@ -42,6 +42,20 @@ namespace { "Property to track a nodeline. When tracking the label text will be updating the " "distance from the nodeline start and end." }; + + constexpr openspace::properties::Property::PropertyInfo DistanceUnitInfo = { + "DistanceUnit", + "Distance Unit", + "Property to define the unit in which the distance should be displayed." + "Defaults to 'km' if not specified." + }; + + constexpr openspace::properties::Property::PropertyInfo CustomUnitDescriptorInfo = { + "CustomUnitDescriptor", + "Custom Unit Descriptor", + "Property to define a custom unit descriptor to use to describe the distance value." + "Defaults to the units SI descriptor if not specified." + }; } namespace openspace { @@ -58,6 +72,18 @@ documentation::Documentation RenderableDistanceLabel::Documentation() { Optional::No, NodeLineInfo.description }, + { + DistanceUnitInfo.identifier, + new IntVerifier, + Optional::Yes, + DistanceUnitInfo.description + }, + { + CustomUnitDescriptorInfo.identifier, + new StringVerifier, + Optional::Yes, + CustomUnitDescriptorInfo.description + } } }; } @@ -65,6 +91,8 @@ documentation::Documentation RenderableDistanceLabel::Documentation() { RenderableDistanceLabel::RenderableDistanceLabel(const ghoul::Dictionary& dictionary) : RenderableLabels(dictionary) , _nodelineId(NodeLineInfo) + , _distanceUnit(DistanceUnitInfo, 1, 0, 11) + , _customUnitDescriptor(CustomUnitDescriptorInfo) { documentation::testSpecificationAndThrow( Documentation(), @@ -76,6 +104,16 @@ RenderableDistanceLabel::RenderableDistanceLabel(const ghoul::Dictionary& dictio _nodelineId = dictionary.value(NodeLineInfo.identifier); addProperty(_nodelineId); } + if (dictionary.hasKey(DistanceUnitInfo.identifier)) { + _distanceUnit = static_cast( + dictionary.value(DistanceUnitInfo.identifier) + ); + addProperty(_distanceUnit); + } + if (dictionary.hasKey(CustomUnitDescriptorInfo.identifier)) { + _customUnitDescriptor = dictionary.value(CustomUnitDescriptorInfo.identifier); + addProperty(_customUnitDescriptor); + } } void RenderableDistanceLabel::update(const UpdateData&) { @@ -87,7 +125,6 @@ void RenderableDistanceLabel::update(const UpdateData&) { SceneGraphNode* nodelineNode = RE.scene()->sceneGraphNode(_nodelineId); if (nodelineNode) { - // Calculate distance RenderableNodeLine* nodeline = dynamic_cast( nodelineNode->renderable() ); @@ -97,15 +134,23 @@ void RenderableDistanceLabel::update(const UpdateData&) { return; } - double myDistance = nodeline->distance(); + // Get used unit scale + const float scale = unit(_distanceUnit); - // Format string - float scale = unit(Kilometer); - std::string distanceText = std::to_string(std::round(myDistance / scale)); + // Get unit descriptor text + std::string unitDescriptor = toString(_distanceUnit); + if (!_customUnitDescriptor.value().empty()) { + unitDescriptor = _customUnitDescriptor.value(); + } + + // Get distance as string and remove fractional part + std::string distanceText = std::to_string(std::round(nodeline->distance() / scale)); int pos = static_cast(distanceText.find(".")); std::string subStr = distanceText.substr(pos); distanceText.erase(pos, subStr.size()); - std::string finalText = distanceText + " Km"; + + // Create final label text and set it + const std::string finalText = distanceText + " " + unitDescriptor; setLabelText(finalText); // Update placement of label with transformation matrix diff --git a/modules/vislab/rendering/renderabledistancelabel.h b/modules/vislab/rendering/renderabledistancelabel.h index 42f0f4165d..effb4efe71 100644 --- a/modules/vislab/rendering/renderabledistancelabel.h +++ b/modules/vislab/rendering/renderabledistancelabel.h @@ -40,6 +40,8 @@ public: private: properties::StringProperty _nodelineId; + properties::IntProperty _distanceUnit; + properties::StringProperty _customUnitDescriptor; bool _errorThrown = false; }; From c46beadcf96dd765f20e2c0dc807cf191acf579c Mon Sep 17 00:00:00 2001 From: stefanseibert Date: Fri, 6 Mar 2020 10:48:01 +0100 Subject: [PATCH 5/6] style change --- modules/vislab/rendering/renderabledistancelabel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vislab/rendering/renderabledistancelabel.cpp b/modules/vislab/rendering/renderabledistancelabel.cpp index 47508e3114..eac120946d 100644 --- a/modules/vislab/rendering/renderabledistancelabel.cpp +++ b/modules/vislab/rendering/renderabledistancelabel.cpp @@ -107,7 +107,7 @@ RenderableDistanceLabel::RenderableDistanceLabel(const ghoul::Dictionary& dictio if (dictionary.hasKey(DistanceUnitInfo.identifier)) { _distanceUnit = static_cast( dictionary.value(DistanceUnitInfo.identifier) - ); + ); addProperty(_distanceUnit); } if (dictionary.hasKey(CustomUnitDescriptorInfo.identifier)) { From 754a7735f9df13e38d0bfdbaae3c384d18f5d32e Mon Sep 17 00:00:00 2001 From: Gene Payne Date: Mon, 9 Mar 2020 10:43:25 -0600 Subject: [PATCH 6/6] Issue/1097 (#1098) * Added pre-2000 date tests to globebrowsing timequantizer * Merge with latest master * Added checks to enforce 0.0 - 360.0 range on angles in JPL Horizons data --- .../space/rendering/renderablesmallbody.cpp | 23 +++++++++++++------ modules/space/rendering/renderablesmallbody.h | 2 ++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/modules/space/rendering/renderablesmallbody.cpp b/modules/space/rendering/renderablesmallbody.cpp index eb486a5035..be5dbf2ba3 100644 --- a/modules/space/rendering/renderablesmallbody.cpp +++ b/modules/space/rendering/renderablesmallbody.cpp @@ -105,8 +105,8 @@ enum Months { December }; -int daysIntoGivenYear(int year, int month, int dayOfMonth) { - //month and dayCount are zero-based +int daysIntoGivenYear(int month, int dayOfMonth) { + //month and dayCount are zero-based. Does NOT account for leap year. month -= 1; int dayCount = dayOfMonth - 1; @@ -140,7 +140,7 @@ double epochFromYMDdSubstring(const std::string& epochString) { // 2.a int monthNum = std::atoi(epochString.substr(4, 2).c_str()); int dayOfMonthNum = std::atoi(epochString.substr(6, 2).c_str()); - int wholeDaysInto = daysIntoGivenYear(year, monthNum, dayOfMonthNum); + int wholeDaysInto = daysIntoGivenYear(monthNum, dayOfMonthNum); double fractionOfDay = std::atof(epochString.substr(9, 7).c_str()); double daysInYear = static_cast(wholeDaysInto) + fractionOfDay; @@ -344,7 +344,7 @@ void RenderableSmallBody::readJplSbDb(const std::string& filename) { throw std::invalid_argument("Unable to read inclination from line" + std::to_string(csvLine + 1)); } - keplerElements.inclination = std::stod(field); + keplerElements.inclination = importAngleValue(field); fieldCount++; // Longitude of ascending node (degrees) @@ -352,7 +352,7 @@ void RenderableSmallBody::readJplSbDb(const std::string& filename) { throw std::invalid_argument("Unable to read ascending node from line" + std::to_string(csvLine + 1)); } - keplerElements.ascendingNode = std::stod(field); + keplerElements.ascendingNode = importAngleValue(field); fieldCount++; // Argument of Periapsis (degrees) @@ -360,7 +360,7 @@ void RenderableSmallBody::readJplSbDb(const std::string& filename) { throw std::invalid_argument("Unable to read arg of periapsis from line" + std::to_string(csvLine + 1)); } - keplerElements.argumentOfPeriapsis = std::stod(field); + keplerElements.argumentOfPeriapsis = importAngleValue(field); fieldCount++; // Mean Anomaly (degrees) @@ -368,7 +368,7 @@ void RenderableSmallBody::readJplSbDb(const std::string& filename) { throw std::invalid_argument("Unable to read mean anomaly from line" + std::to_string(csvLine + 1)); } - keplerElements.meanAnomaly = std::stod(field); + keplerElements.meanAnomaly = importAngleValue(field); fieldCount++; // Period (days) @@ -412,6 +412,15 @@ void RenderableSmallBody::readJplSbDb(const std::string& filename) { file.close(); } +static double importAngleValue(const std::string& angle) { + double output = std::stod(angle); + output = std::fmod(output, 360.0); + if (output < 0.0) { + output += 360.0; + } + return output; +} + void RenderableSmallBody::initializeGL() { glGenVertexArrays(1, &_vertexArray); glGenBuffers(1, &_vertexBuffer); diff --git a/modules/space/rendering/renderablesmallbody.h b/modules/space/rendering/renderablesmallbody.h index a61b56cb74..4e1b87219a 100644 --- a/modules/space/rendering/renderablesmallbody.h +++ b/modules/space/rendering/renderablesmallbody.h @@ -126,6 +126,8 @@ private: const double convertDaysToSecs = 86400.; }; +static double importAngleValue(const std::string& angle); + } // namespace openspace #endif // __OPENSPACE_MODULE_SPACE___RENDERABLESMALLBODY___H__