mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-08 04:20:14 -05:00
Rename "Pair" to "TargetBrowserPair"
This commit is contained in:
@@ -30,7 +30,7 @@ set(HEADER_FILES
|
||||
include/screenspaceskytarget.h
|
||||
include/wwtdatahandler.h
|
||||
include/utility.h
|
||||
include/pair.h
|
||||
include/targetbrowserpair.h
|
||||
include/wwtcommunicator.h
|
||||
include/browser.h
|
||||
include/screenspaceskybrowser.h
|
||||
@@ -48,7 +48,7 @@ set(SOURCE_FILES
|
||||
src/wwtdatahandler.cpp
|
||||
src/utility.cpp
|
||||
src/renderableskybrowser.cpp
|
||||
src/pair.cpp
|
||||
src/targetbrowserpair.cpp
|
||||
src/wwtcommunicator.cpp
|
||||
src/browser.cpp
|
||||
src/screenspaceskybrowser.cpp
|
||||
|
||||
@@ -1,141 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2021 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_SKYBROWSER___PAIR___H__
|
||||
#define __OPENSPACE_MODULE_SKYBROWSER___PAIR___H__
|
||||
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <deque>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class ScreenSpaceSkyBrowser;
|
||||
class ScreenSpaceSkyTarget;
|
||||
class ScreenSpaceRenderable;
|
||||
class ImageData;
|
||||
|
||||
class Pair {
|
||||
public:
|
||||
|
||||
constexpr static const float FadeThreshold = 0.01f;
|
||||
constexpr static const double AnimationThreshold = 0.0001f;
|
||||
|
||||
Pair(ScreenSpaceSkyBrowser* browser, ScreenSpaceSkyTarget* target);
|
||||
Pair(Pair const&) = default;
|
||||
// user-defined copy assignment (copy-and-swap idiom)
|
||||
Pair& operator=(Pair other);
|
||||
|
||||
// Target & Browser
|
||||
void initialize();
|
||||
// Highlighting
|
||||
void removeHighlight(glm::ivec3 color);
|
||||
void highlight(glm::ivec3 color);
|
||||
// Animation
|
||||
void startAnimation(glm::dvec3 coordsEnd, float fovEnd, bool shouldLockAfter = true);
|
||||
void incrementallyAnimateToCoordinate(double deltaTime);
|
||||
void incrementallyFade(float goalState, float fadeTime, float deltaTime);
|
||||
// Mouse interaction
|
||||
bool checkMouseIntersection(glm::vec2 mousePosition);
|
||||
glm::vec2 selectedScreenSpacePosition();
|
||||
bool isBrowserSelected();
|
||||
bool isTargetSelected();
|
||||
void fineTuneTarget(const glm::vec2& start, const glm::vec2& translation);
|
||||
void translateSelected(const glm::vec2& start, const glm::vec2& translation);
|
||||
void synchronizeAim();
|
||||
|
||||
// Browser
|
||||
void sendIdToBrowser();
|
||||
void updateBrowserSize();
|
||||
|
||||
// Target
|
||||
void centerTargetOnScreen();
|
||||
void lock();
|
||||
void unlock();
|
||||
|
||||
// Boolean functions
|
||||
bool hasFinishedFading(float goalState) const;
|
||||
bool isFacingCamera() const;
|
||||
bool isUsingRadiusAzimuthElevation() const;
|
||||
bool isEnabled() const;
|
||||
bool isLocked() const;
|
||||
|
||||
// Setters
|
||||
void setEnabled(bool enable);
|
||||
void setIsSyncedWithWwt(bool isSynced);
|
||||
void setVerticalFov(float vfov);
|
||||
void setEquatorialAim(const glm::dvec2& aim);
|
||||
void setBorderColor(const glm::ivec3& color);
|
||||
void setScreenSpaceSize(const glm::vec2& dimensions);
|
||||
void setVerticalFovWithScroll(float scroll);
|
||||
|
||||
// Getters by value
|
||||
float verticalFov() const;
|
||||
glm::ivec3 borderColor() const;
|
||||
glm::dvec2 targetDirectionEquatorial() const;
|
||||
glm::dvec3 targetDirectionGalactic() const;
|
||||
std::string browserGuiName() const;
|
||||
std::string browserId() const;
|
||||
std::string targetId() const;
|
||||
glm::vec2 size() const;
|
||||
|
||||
|
||||
// Getters by reference
|
||||
ScreenSpaceSkyTarget* getTarget();
|
||||
ScreenSpaceSkyBrowser* getBrowser();
|
||||
const std::deque<int>& getSelectedImages() const;
|
||||
|
||||
// WorldWide Telescope image handling
|
||||
void setImageOrder(int i, int order);
|
||||
void selectImage(const ImageData& image, int i);
|
||||
void removeSelectedImage(int i);
|
||||
void loadImageCollection(const std::string& collection);
|
||||
void setImageOpacity(int i, float opacity);
|
||||
void hideChromeInterface(bool shouldHide);
|
||||
|
||||
// Comparision operators
|
||||
friend bool operator==(const Pair& lhs,
|
||||
const Pair& rhs);
|
||||
friend bool operator!=(const Pair& lhs,
|
||||
const Pair& rhs);
|
||||
|
||||
private:
|
||||
ScreenSpaceRenderable* _selected;
|
||||
bool _isSelectedBrowser;
|
||||
|
||||
bool isTargetFadeFinished(float goalState) const;
|
||||
bool isBrowserFadeFinished(float goalState) const;
|
||||
|
||||
ScreenSpaceSkyTarget* _target{ nullptr };
|
||||
ScreenSpaceSkyBrowser* _browser{ nullptr };
|
||||
|
||||
// Shared properties between the target and the browser
|
||||
float _verticalFov{ 70.0f };
|
||||
glm::dvec2 _equatorialAim{ 0.0 };
|
||||
glm::ivec3 _borderColor{ 255 };
|
||||
glm::vec2 _dimensions{ 0.5f, 0.5f };
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_MODULE_SKYBROWSER___PAIR___H__
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
#include <modules/skybrowser/include/renderableskybrowser.h>
|
||||
#include <modules/skybrowser/include/screenspaceskybrowser.h>
|
||||
#include <modules/skybrowser/include/pair.h>
|
||||
#include <modules/skybrowser/include/targetbrowserpair.h>
|
||||
#include <modules/skybrowser/include/screenspaceskytarget.h>
|
||||
#include <modules/skybrowser/include/wwtdatahandler.h>
|
||||
#include <modules/base/rendering/screenspaceimagelocal.h>
|
||||
@@ -394,7 +394,7 @@ SkyBrowserModule::SkyBrowserModule()
|
||||
}
|
||||
if (_isCameraInSolarSystem) {
|
||||
std::for_each(std::begin(_targetsBrowsers), std::end(_targetsBrowsers),
|
||||
[&](const std::unique_ptr<Pair>& pair) {
|
||||
[&](const std::unique_ptr<TargetBrowserPair>& pair) {
|
||||
pair->synchronizeAim();
|
||||
});
|
||||
incrementallyAnimateTargets(deltaTime);
|
||||
@@ -440,11 +440,11 @@ void SkyBrowserModule::setSelectedObject()
|
||||
return;
|
||||
}
|
||||
// Save old selection for removing highlight
|
||||
Pair* previousPair = _mouseOnPair;
|
||||
TargetBrowserPair* previousPair = _mouseOnPair;
|
||||
|
||||
// Find and save what mouse is currently hovering on
|
||||
auto it = std::find_if(std::begin(_targetsBrowsers), std::end(_targetsBrowsers),
|
||||
[&] (const std::unique_ptr<Pair> &pair) {
|
||||
[&] (const std::unique_ptr<TargetBrowserPair> &pair) {
|
||||
return pair->checkMouseIntersection(_mousePosition);
|
||||
});
|
||||
|
||||
@@ -480,19 +480,19 @@ void SkyBrowserModule::addTargetBrowserPair(const std::string& targetId, const s
|
||||
|
||||
// Assert pair to have both target and browser
|
||||
if (browser && target) {
|
||||
_targetsBrowsers.push_back(std::make_unique<Pair>(browser, target));
|
||||
_targetsBrowsers.push_back(std::make_unique<TargetBrowserPair>(browser, target));
|
||||
}
|
||||
}
|
||||
|
||||
void SkyBrowserModule::removeTargetBrowserPair(const std::string& id) {
|
||||
|
||||
Pair* found = getPair(id);
|
||||
TargetBrowserPair* found = getPair(id);
|
||||
if (!found) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto it = std::remove_if(std::begin(_targetsBrowsers), std::end(_targetsBrowsers),
|
||||
[&](const std::unique_ptr<Pair>& pair) {
|
||||
[&](const std::unique_ptr<TargetBrowserPair>& pair) {
|
||||
return *found == *(pair.get());
|
||||
});
|
||||
|
||||
@@ -512,7 +512,7 @@ void SkyBrowserModule::set3dBrowser(const std::string& id)
|
||||
|
||||
void SkyBrowserModule::lookAtTarget(std::string id)
|
||||
{
|
||||
Pair* pair = getPair(id);
|
||||
TargetBrowserPair* pair = getPair(id);
|
||||
if (pair) {
|
||||
startRotatingCamera(pair->targetDirectionGalactic());
|
||||
}
|
||||
@@ -567,7 +567,7 @@ int SkyBrowserModule::nLoadedImages()
|
||||
|
||||
void SkyBrowserModule::add2dSelectedImagesTo3d(const std::string& pairId)
|
||||
{
|
||||
Pair* pair = getPair(pairId);
|
||||
TargetBrowserPair* pair = getPair(pairId);
|
||||
|
||||
if (pair && get3dBrowser()) {
|
||||
|
||||
@@ -612,7 +612,7 @@ const std::unique_ptr<WwtDataHandler>& SkyBrowserModule::getWwtDataHandler() {
|
||||
return _dataHandler;
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<Pair>>& SkyBrowserModule::getPairs()
|
||||
std::vector<std::unique_ptr<TargetBrowserPair>>& SkyBrowserModule::getPairs()
|
||||
{
|
||||
return _targetsBrowsers;
|
||||
}
|
||||
@@ -622,10 +622,10 @@ int SkyBrowserModule::nPairs()
|
||||
return static_cast<int>(_targetsBrowsers.size());
|
||||
}
|
||||
|
||||
Pair* SkyBrowserModule::getPair(const std::string& id)
|
||||
TargetBrowserPair* SkyBrowserModule::getPair(const std::string& id)
|
||||
{
|
||||
auto it = std::find_if(std::begin(_targetsBrowsers), std::end(_targetsBrowsers),
|
||||
[&](const std::unique_ptr<Pair>& pair) {
|
||||
[&](const std::unique_ptr<TargetBrowserPair>& pair) {
|
||||
bool foundBrowser = pair->browserId() == id;
|
||||
bool foundTarget = pair->targetId() == id;
|
||||
return foundBrowser || foundTarget;
|
||||
@@ -739,7 +739,7 @@ void SkyBrowserModule::incrementallyFadeBrowserTargets(Transparency goal, float
|
||||
}(goal);
|
||||
|
||||
bool isAllFinished{ false };
|
||||
for (std::unique_ptr<Pair>& pair : _targetsBrowsers) {
|
||||
for (std::unique_ptr<TargetBrowserPair>& pair : _targetsBrowsers) {
|
||||
if (pair->isEnabled()) {
|
||||
bool isPairFinished = pair->hasFinishedFading(transparency);
|
||||
if (!isPairFinished) {
|
||||
@@ -760,7 +760,7 @@ void SkyBrowserModule::incrementallyFadeBrowserTargets(Transparency goal, float
|
||||
|
||||
void SkyBrowserModule::incrementallyAnimateTargets(double deltaTime)
|
||||
{
|
||||
for (std::unique_ptr<Pair>& pair : _targetsBrowsers) {
|
||||
for (std::unique_ptr<TargetBrowserPair>& pair : _targetsBrowsers) {
|
||||
if (pair->isEnabled()) {
|
||||
pair->incrementallyAnimateToCoordinate(deltaTime);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace openspace {
|
||||
class RenderableSkyBrowser;
|
||||
class ScreenSpaceImageLocal;
|
||||
class WwtDataHandler;
|
||||
class Pair;
|
||||
class TargetBrowserPair;
|
||||
class SceneGraphNode;
|
||||
class ImageData;
|
||||
|
||||
@@ -66,9 +66,9 @@ public:
|
||||
virtual ~SkyBrowserModule();
|
||||
|
||||
// Getters
|
||||
std::vector<std::unique_ptr<Pair>>& getPairs();
|
||||
std::vector<std::unique_ptr<TargetBrowserPair>>& getPairs();
|
||||
int nPairs();
|
||||
Pair* getPair(const std::string& id);
|
||||
TargetBrowserPair* getPair(const std::string& id);
|
||||
SceneGraphNode* get3dBrowserNode();
|
||||
RenderableSkyBrowser* get3dBrowser();
|
||||
RenderableSkyBrowser* get3dBrowser(const std::string& id);
|
||||
@@ -126,8 +126,8 @@ private:
|
||||
glm::ivec3 _highlightAddition{ 35 }; // Highlight object when mouse hovers
|
||||
|
||||
// The browsers and targets
|
||||
std::vector<std::unique_ptr<Pair>> _targetsBrowsers;
|
||||
Pair* _mouseOnPair{ nullptr };
|
||||
std::vector<std::unique_ptr<TargetBrowserPair>> _targetsBrowsers;
|
||||
TargetBrowserPair* _mouseOnPair{ nullptr };
|
||||
ScreenSpaceImageLocal* _hoverCircle{ nullptr };
|
||||
SceneGraphNode* _browser3dNode{ nullptr }; // Scene graph node is used for positioning
|
||||
RenderableSkyBrowser* _browser3d{ nullptr };
|
||||
|
||||
@@ -22,7 +22,7 @@ int selectImage(lua_State* L) {
|
||||
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
|
||||
|
||||
if (module->isCameraInSolarSystem()) {
|
||||
Pair* selected = module->getPair(module->selectedBrowserId());
|
||||
TargetBrowserPair* selected = module->getPair(module->selectedBrowserId());
|
||||
if (selected) {
|
||||
|
||||
const ImageData& image = module->getWwtDataHandler()->getImage(i);
|
||||
@@ -168,8 +168,8 @@ int sendOutIdsToBrowsers(lua_State* L) {
|
||||
|
||||
// Send out ID's to the browsers
|
||||
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
|
||||
std::vector<std::unique_ptr<Pair>>& pairs = module->getPairs();
|
||||
for (std::unique_ptr<Pair>& pair : pairs) {
|
||||
std::vector<std::unique_ptr<TargetBrowserPair>>& pairs = module->getPairs();
|
||||
for (std::unique_ptr<TargetBrowserPair>& pair : pairs) {
|
||||
pair->sendIdToBrowser();
|
||||
}
|
||||
if(module->get3dBrowser()) {
|
||||
@@ -345,9 +345,9 @@ int getTargetData(lua_State* L) {
|
||||
|
||||
// Pass data for all the browsers and the corresponding targets
|
||||
if (module->isCameraInSolarSystem()) {
|
||||
std::vector<std::unique_ptr<Pair>>& pairs = module->getPairs();
|
||||
std::vector<std::unique_ptr<TargetBrowserPair>>& pairs = module->getPairs();
|
||||
|
||||
for (std::unique_ptr<Pair>& pair : pairs) {
|
||||
for (std::unique_ptr<TargetBrowserPair>& pair : pairs) {
|
||||
std::string id = pair->browserId();
|
||||
// Convert deque to vector so ghoul can read it
|
||||
std::vector<int> selectedImagesVector;
|
||||
@@ -494,7 +494,7 @@ int centerTargetOnScreen(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::centerTargetOnScreen");
|
||||
const std::string id = ghoul::lua::value<std::string>(L, 1);
|
||||
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
|
||||
Pair* pair = module->getPair(id);
|
||||
TargetBrowserPair* pair = module->getPair(id);
|
||||
if (pair) {
|
||||
pair->centerTargetOnScreen();
|
||||
}
|
||||
@@ -570,7 +570,7 @@ int removeTargetBrowserPair(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::removeTargetBrowserPair");
|
||||
std::string id = ghoul::lua::value<std::string>(L, 1);
|
||||
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
|
||||
Pair* found = module->getPair(id);
|
||||
TargetBrowserPair* found = module->getPair(id);
|
||||
if (found) {
|
||||
std::string browser = found->browserId();
|
||||
std::string target = found->targetId();
|
||||
@@ -615,7 +615,7 @@ int removeSelectedImageInBrowser(lua_State* L) {
|
||||
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
|
||||
const ImageData& image = module->getWwtDataHandler()->getImage(i);
|
||||
|
||||
Pair* pair = module->getPair(id);
|
||||
TargetBrowserPair* pair = module->getPair(id);
|
||||
if (pair) {
|
||||
pair->removeSelectedImage(i);
|
||||
}
|
||||
@@ -635,7 +635,7 @@ int setEquatorialAim(lua_State* L) {
|
||||
// Get module
|
||||
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
|
||||
|
||||
Pair* pair = module->getPair(id);
|
||||
TargetBrowserPair* pair = module->getPair(id);
|
||||
if (pair) {
|
||||
pair->setEquatorialAim(glm::dvec2(ra, dec));
|
||||
}
|
||||
@@ -655,7 +655,7 @@ int setVerticalFov(lua_State* L) {
|
||||
// Get module
|
||||
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
|
||||
|
||||
Pair* pair = module->getPair(id);
|
||||
TargetBrowserPair* pair = module->getPair(id);
|
||||
if (pair) {
|
||||
pair->setVerticalFov(vfov);
|
||||
}
|
||||
@@ -677,7 +677,7 @@ int setBorderColor(lua_State* L) {
|
||||
// Get module
|
||||
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
|
||||
|
||||
Pair* pair = module->getPair(id);
|
||||
TargetBrowserPair* pair = module->getPair(id);
|
||||
if (pair) {
|
||||
pair->setBorderColor(color);
|
||||
}
|
||||
@@ -698,7 +698,7 @@ int setScreenSpaceSize(lua_State* L) {
|
||||
// Get module
|
||||
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
|
||||
|
||||
Pair* pair = module->getPair(id);
|
||||
TargetBrowserPair* pair = module->getPair(id);
|
||||
if (pair) {
|
||||
pair->setScreenSpaceSize(glm::vec2(sizeX, sizeY));
|
||||
}
|
||||
|
||||
@@ -1,388 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2021 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/skybrowser/include/pair.h>
|
||||
|
||||
#include <modules/skybrowser/include/screenspaceskybrowser.h>
|
||||
#include <modules/skybrowser/include/screenspaceskytarget.h>
|
||||
#include <openspace/rendering/screenspacerenderable.h>
|
||||
#include <modules/skybrowser/include/wwtdatahandler.h>
|
||||
#include <modules/skybrowser/include/utility.h>
|
||||
#include <ghoul/misc/assert.h>
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <functional>
|
||||
|
||||
#pragma optimize("", off)
|
||||
|
||||
namespace openspace {
|
||||
|
||||
Pair::Pair(ScreenSpaceSkyBrowser* browser, ScreenSpaceSkyTarget* target)
|
||||
: _target(target), _browser(browser)
|
||||
{
|
||||
ghoul_assert(browser != nullptr, "Sky browser is null pointer!");
|
||||
ghoul_assert(target != nullptr, "Sky target is null pointer!");
|
||||
}
|
||||
|
||||
Pair& Pair::operator=(Pair other)
|
||||
{
|
||||
std::swap(_target, other._target);
|
||||
std::swap(_browser, other._browser);
|
||||
return *this;
|
||||
|
||||
}
|
||||
|
||||
void Pair::lock() {
|
||||
_target->setLock(true);
|
||||
}
|
||||
|
||||
void Pair::unlock() {
|
||||
_target->setLock(false);
|
||||
}
|
||||
|
||||
void Pair::setImageOrder(int i, int order) {
|
||||
_browser->setImageOrder(i, order);
|
||||
}
|
||||
|
||||
void Pair::removeHighlight(glm::ivec3 color)
|
||||
{
|
||||
_target->removeHighlight(color);
|
||||
_browser->removeHighlight(color);
|
||||
}
|
||||
|
||||
void Pair::highlight(glm::ivec3 color)
|
||||
{
|
||||
_browser->highlight(color);
|
||||
_target->highlight(color);
|
||||
}
|
||||
|
||||
bool Pair::isTargetFadeFinished(float goalState) const
|
||||
{
|
||||
// Is fading finished?
|
||||
float targetDiff = abs(_target->opacity() - goalState);
|
||||
|
||||
return targetDiff < FadeThreshold;
|
||||
}
|
||||
|
||||
bool Pair::isBrowserFadeFinished(float goalState) const
|
||||
{
|
||||
float browserDiff = abs(_browser->opacity() - goalState);
|
||||
return browserDiff < FadeThreshold;
|
||||
}
|
||||
|
||||
bool Pair::checkMouseIntersection(glm::vec2 mousePosition)
|
||||
{
|
||||
bool onBrowser = _browser->intersection(mousePosition);
|
||||
bool onTarget = _target->intersection(mousePosition);
|
||||
if (onBrowser) {
|
||||
_selected = _browser;
|
||||
_isSelectedBrowser = true;
|
||||
}
|
||||
else if (onTarget) {
|
||||
_selected = _target;
|
||||
_isSelectedBrowser = false;
|
||||
}
|
||||
else {
|
||||
_selected = nullptr;
|
||||
_isSelectedBrowser = false;
|
||||
}
|
||||
return onBrowser || onTarget;
|
||||
}
|
||||
|
||||
glm::vec2 Pair::selectedScreenSpacePosition()
|
||||
{
|
||||
return _selected->screenSpacePosition();
|
||||
}
|
||||
|
||||
bool Pair::isBrowserSelected()
|
||||
{
|
||||
return _isSelectedBrowser;
|
||||
}
|
||||
|
||||
bool Pair::isTargetSelected()
|
||||
{
|
||||
return _selected && !_isSelectedBrowser;
|
||||
}
|
||||
|
||||
void Pair::fineTuneTarget(const glm::vec2& start, const glm::vec2& translation)
|
||||
{
|
||||
glm::vec2 fineTune = _browser->fineTuneVector(translation);
|
||||
_target->translate(fineTune, start);
|
||||
}
|
||||
|
||||
void Pair::translateSelected(const glm::vec2& start, const glm::vec2& translation)
|
||||
{
|
||||
_selected->translate(translation, start);
|
||||
}
|
||||
|
||||
void Pair::synchronizeAim()
|
||||
{
|
||||
if (!_target->isAnimated()) {
|
||||
glm::dvec2 aim;
|
||||
// To remove the lag effect when moving the camera while having a locked
|
||||
// target, send the locked coordinates to wwt
|
||||
if (_target->isLocked()) {
|
||||
aim = _target->lockedCoordinates();
|
||||
}
|
||||
else {
|
||||
aim = _target->equatorialAim();
|
||||
}
|
||||
|
||||
_browser->setEquatorialAim(aim);
|
||||
_target->setScaleFromVfov(_browser->verticalFov());
|
||||
}
|
||||
}
|
||||
|
||||
void Pair::setEnabled(bool enable)
|
||||
{
|
||||
_browser->setEnabled(enable);
|
||||
_target->setEnabled(enable);
|
||||
}
|
||||
|
||||
bool Pair::isEnabled() const
|
||||
{
|
||||
return _target->isEnabled() && _browser->isEnabled();
|
||||
}
|
||||
|
||||
bool Pair::isLocked() const
|
||||
{
|
||||
return _target->isLocked();
|
||||
}
|
||||
|
||||
void Pair::initialize()
|
||||
{
|
||||
_target->setColor(_browser->borderColor());
|
||||
_target->setDimensions(_browser->browserPixelDimensions());
|
||||
_target->setScaleFromVfov(_browser->verticalFov());
|
||||
_browser->updateBorderColor();
|
||||
}
|
||||
|
||||
glm::ivec3 Pair::borderColor() const
|
||||
{
|
||||
return _browser->borderColor();
|
||||
}
|
||||
|
||||
glm::dvec2 Pair::targetDirectionEquatorial() const
|
||||
{
|
||||
return _target->equatorialAim();
|
||||
}
|
||||
|
||||
glm::dvec3 Pair::targetDirectionGalactic() const
|
||||
{
|
||||
return _target->directionGalactic();
|
||||
}
|
||||
|
||||
std::string Pair::browserGuiName() const
|
||||
{
|
||||
return _browser->guiName();
|
||||
}
|
||||
|
||||
std::string Pair::browserId() const
|
||||
{
|
||||
return _browser->identifier();
|
||||
}
|
||||
|
||||
std::string Pair::targetId() const
|
||||
{
|
||||
return _target->identifier();
|
||||
}
|
||||
|
||||
glm::vec2 Pair::size() const
|
||||
{
|
||||
return _browser->size();
|
||||
}
|
||||
|
||||
float Pair::verticalFov() const
|
||||
{
|
||||
return _browser->verticalFov();
|
||||
}
|
||||
|
||||
const std::deque<int>& Pair::getSelectedImages() const
|
||||
{
|
||||
return _browser->getSelectedImages();
|
||||
}
|
||||
|
||||
void Pair::selectImage(const ImageData& image, int i)
|
||||
{
|
||||
// Load image into browser
|
||||
_browser->displayImage(image.imageUrl, i);
|
||||
|
||||
// If the image has coordinates, move the target
|
||||
if (image.hasCelestialCoords) {
|
||||
|
||||
// Animate the target to the image coordinate position
|
||||
unlock();
|
||||
startAnimation(image.equatorialCartesian, image.fov, true);
|
||||
}
|
||||
}
|
||||
|
||||
void Pair::removeSelectedImage(int i)
|
||||
{
|
||||
_browser->removeSelectedImage(i);
|
||||
}
|
||||
|
||||
void Pair::loadImageCollection(const std::string& collection)
|
||||
{
|
||||
_browser->loadImageCollection(collection);
|
||||
}
|
||||
|
||||
void Pair::setImageOpacity(int i, float opacity)
|
||||
{
|
||||
_browser->setImageOpacity(i, opacity);
|
||||
}
|
||||
|
||||
void Pair::hideChromeInterface(bool shouldHide)
|
||||
{
|
||||
_browser->hideChromeInterface(shouldHide);
|
||||
}
|
||||
|
||||
void Pair::sendIdToBrowser()
|
||||
{
|
||||
_browser->setIdInBrowser();
|
||||
}
|
||||
|
||||
void Pair::updateBrowserSize() {
|
||||
_browser->updateBrowserSize();
|
||||
}
|
||||
|
||||
void Pair::setIsSyncedWithWwt(bool isSynced)
|
||||
{
|
||||
_browser->setIsSyncedWithWwt(isSynced);
|
||||
}
|
||||
|
||||
void Pair::setVerticalFov(float vfov)
|
||||
{
|
||||
_verticalFov = vfov;
|
||||
_browser->setVerticalFov(vfov);
|
||||
_target->setScaleFromVfov(vfov);
|
||||
}
|
||||
|
||||
void Pair::setEquatorialAim(const glm::dvec2& aim)
|
||||
{
|
||||
_equatorialAim = aim;
|
||||
_target->setEquatorialAim(aim);
|
||||
_browser->setEquatorialAim(aim);
|
||||
}
|
||||
|
||||
void Pair::setBorderColor(const glm::ivec3& color)
|
||||
{
|
||||
_borderColor = color;
|
||||
_target->setColor(color);
|
||||
_browser->setBorderColor(color);
|
||||
}
|
||||
|
||||
void Pair::setScreenSpaceSize(const glm::vec2& dimensions)
|
||||
{
|
||||
_dimensions = dimensions;
|
||||
_target->setDimensions(dimensions);
|
||||
_browser->setScreenSpaceSize(dimensions);
|
||||
}
|
||||
|
||||
void Pair::setVerticalFovWithScroll(float scroll)
|
||||
{
|
||||
_browser->setVerticalFovWithScroll(scroll);
|
||||
}
|
||||
|
||||
void Pair::incrementallyAnimateToCoordinate(double deltaTime)
|
||||
{
|
||||
// Animate the target before the field of view starts to animate
|
||||
if (_target->isAnimated()) {
|
||||
_target->incrementallyAnimateToCoordinate(deltaTime);
|
||||
}
|
||||
else if (_browser->isAnimated()) {
|
||||
_browser->incrementallyAnimateToFov(deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
void Pair::startAnimation(glm::dvec3 equatorialCoords, float fovEnd,
|
||||
bool shouldLockAfter)
|
||||
{
|
||||
_target->startAnimation(equatorialCoords, shouldLockAfter);
|
||||
_browser->startFovAnimation(fovEnd);
|
||||
}
|
||||
|
||||
void Pair::centerTargetOnScreen()
|
||||
{
|
||||
// Animate the target to the center of the screen
|
||||
unlock();
|
||||
// Get camera direction in celestial spherical coordinates
|
||||
glm::dvec3 viewDirection = skybrowser::cameraDirectionEquatorial();
|
||||
// Keep the current fov
|
||||
float currentFov = verticalFov();
|
||||
startAnimation(viewDirection, currentFov, false);
|
||||
}
|
||||
|
||||
bool Pair::hasFinishedFading(float goalState) const
|
||||
{
|
||||
return isTargetFadeFinished(goalState) && isBrowserFadeFinished(goalState);
|
||||
}
|
||||
|
||||
bool Pair::isFacingCamera() const
|
||||
{
|
||||
return _browser->isFacingCamera() || _target->isFacingCamera();
|
||||
}
|
||||
|
||||
bool Pair::isUsingRadiusAzimuthElevation() const
|
||||
{
|
||||
return _browser->isUsingRaeCoords() || _target->isUsingRaeCoords();
|
||||
}
|
||||
|
||||
ScreenSpaceSkyTarget* Pair::getTarget() {
|
||||
return _target;
|
||||
}
|
||||
|
||||
ScreenSpaceSkyBrowser* Pair::getBrowser() {
|
||||
return _browser;
|
||||
}
|
||||
|
||||
void Pair::incrementallyFade(float goalState, float fadeTime, float deltaTime)
|
||||
{
|
||||
float opacityDelta = static_cast<float>(deltaTime / fadeTime);
|
||||
if (_target->opacity() > goalState) {
|
||||
opacityDelta *= -1.f;
|
||||
}
|
||||
|
||||
if (!isTargetFadeFinished(goalState)) {
|
||||
_target->setOpacity(_target->opacity() + opacityDelta);
|
||||
}
|
||||
else {
|
||||
_target->setOpacity(goalState);
|
||||
}
|
||||
|
||||
if (!isBrowserFadeFinished(goalState)) {
|
||||
_browser->setOpacity(_browser->opacity() + opacityDelta);
|
||||
}
|
||||
else {
|
||||
_browser->setOpacity(goalState);
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(const Pair& lhs, const Pair& rhs) {
|
||||
return lhs._target == rhs._target && lhs._browser == rhs._browser;
|
||||
}
|
||||
bool operator!=(const Pair& lhs, const Pair& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
} // namespace openspace
|
||||
Reference in New Issue
Block a user