Fix bug with creating a target with an identifier that already exists

This commit is contained in:
Ylva Selling
2022-04-28 11:54:43 -04:00
parent 4692c4d74b
commit 8aec879677
3 changed files with 12 additions and 5 deletions

View File

@@ -239,6 +239,7 @@ void SkyBrowserModule::addTargetBrowserPair(const std::string& targetId,
if (browser && target) {
_targetsBrowsers.push_back(std::make_unique<TargetBrowserPair>(target, browser));
}
_uniqueIdentifierCounter++;
}
void SkyBrowserModule::removeTargetBrowserPair(const std::string& id) {
@@ -425,6 +426,10 @@ glm::ivec3 SkyBrowserModule::highlight() const {
return _highlightAddition;
}
int SkyBrowserModule::uniqueIdentifierCounter() const {
return _uniqueIdentifierCounter;
}
bool SkyBrowserModule::isCameraInSolarSystem() const {
return _isCameraInSolarSystem;
}

View File

@@ -64,6 +64,7 @@ public:
std::string selectedBrowserId() const;
std::string selectedTargetId() const;
glm::ivec3 highlight() const;
int uniqueIdentifierCounter() const;
void setSelectedBrowser(const std::string& id);
void setHoverCircle(SceneGraphNode* circle);
@@ -117,6 +118,7 @@ private:
TargetBrowserPair* _mouseOnPair = nullptr;
SceneGraphNode* _hoverCircle = nullptr;
std::string _selectedBrowser = ""; // Currently selected browser
int _uniqueIdentifierCounter = 0;
// Flags
bool _isCameraInSolarSystem = true; // Visualization modes

View File

@@ -422,11 +422,11 @@ namespace {
SkyBrowserModule* module = global::moduleEngine->module<SkyBrowserModule>();
int noOfPairs = module->nPairs();
std::string nameBrowser = "Sky Browser " + std::to_string(noOfPairs);
std::string nameTarget = "Sky Target " + std::to_string(noOfPairs);
std::string idBrowser = "SkyBrowser" + std::to_string(noOfPairs);
std::string idTarget = "SkyTarget" + std::to_string(noOfPairs);
int uniqueIdentifier = module->uniqueIdentifierCounter();
std::string nameBrowser = "Sky Browser " + std::to_string(uniqueIdentifier);
std::string nameTarget = "Sky Target " + std::to_string(uniqueIdentifier);
std::string idBrowser = "SkyBrowser" + std::to_string(uniqueIdentifier);
std::string idTarget = "SkyTarget" + std::to_string(uniqueIdentifier);
// Determine starting point on screen for the target
glm::vec3 positionBrowser = glm::vec3(0.f, 0.f, -2.1f);
glm::vec3 positionTarget = glm::vec3(0.9f, 0.4f, -2.1f);