Remove all remaining virtual property related code

This commit is contained in:
Emma Broman
2022-02-10 13:40:56 +01:00
parent 0e49606706
commit f45b782234
12 changed files with 2 additions and 286 deletions

View File

@@ -49,7 +49,6 @@ class ScreenSpaceRenderable;
class SyncEngine;
class TimeManager;
class VersionChecker;
class VirtualPropertyManager;
struct WindowDelegate;
namespace configuration { struct Configuration; }
namespace interaction {
@@ -88,7 +87,6 @@ inline std::vector<std::unique_ptr<ScreenSpaceRenderable>>* screenSpaceRenderabl
inline SyncEngine* syncEngine;
inline TimeManager* timeManager;
inline VersionChecker* versionChecker;
inline VirtualPropertyManager* virtualPropertyManager;
inline WindowDelegate* windowDelegate;
inline configuration::Configuration* configuration;
inline interaction::ActionManager* actionManager;

View File

@@ -1,50 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2022 *
* *
* 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_CORE___VIRTUALPROPERTYMANAGER___H__
#define __OPENSPACE_CORE___VIRTUALPROPERTYMANAGER___H__
#include <openspace/properties/propertyowner.h>
#include <memory>
#include <vector>
namespace openspace {
class Property;
class VirtualPropertyManager : public properties::PropertyOwner {
public:
VirtualPropertyManager();
void addProperty(std::unique_ptr<properties::Property> prop);
void removeProperty(properties::Property* prop);
private:
std::vector<std::unique_ptr<properties::Property>> _properties;
};
} // namespace openspace
#endif // __OPENSPACE_CORE___VIRTUALPROPERTYMANAGER___H__

View File

@@ -26,7 +26,6 @@
#include <openspace/engine/globals.h>
#include <openspace/engine/globalscallbacks.h>
#include <openspace/engine/virtualpropertymanager.h>
#include <openspace/engine/windowdelegate.h>
#include <openspace/engine/moduleengine.h>
#include <openspace/interaction/sessionrecording.h>
@@ -91,16 +90,6 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) {
}
);
gui._virtualProperty.setSource(
[]() {
std::vector<properties::PropertyOwner*> res = {
global::virtualPropertyManager
};
return res;
}
);
gui._featuredProperties.setSource(
[]() {
std::vector<SceneGraphNode*> nodes =

View File

@@ -63,7 +63,7 @@ namespace openspace::gui {
namespace detail {
constexpr int nComponents() {
const int nRegularComponents = 16;
const int nRegularComponents = 15;
int totalComponents = nRegularComponents;
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
@@ -113,7 +113,6 @@ public:
GuiPropertyComponent _moduleProperty;
GuiMemoryComponent _memoryComponent;
GuiPropertyComponent _virtualProperty;
GuiSpaceTimeComponent _spaceTime;
GuiMissionComponent _mission;
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
@@ -136,11 +135,9 @@ private:
&_sceneProperty,
&_screenSpaceProperty,
&_featuredProperties,
&_virtualProperty,
&_globalProperty,
&_moduleProperty,
&_memoryComponent,
&_spaceTime,
&_mission,
&_parallel,
@@ -149,15 +146,12 @@ private:
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
&_iswa,
#endif
&_actions,
&_joystick,
&_filePath,
&_help
};
GLuint vao = 0;
GLuint vbo = 0;
GLuint vboElements = 0;

View File

@@ -150,7 +150,6 @@ GUI::GUI()
)
, _screenSpaceProperty("ScreenSpaceProperties", "ScreenSpace Properties")
, _moduleProperty("ModuleProperties", "Module Properties")
, _virtualProperty("VirtualProperties", "Virtual Properties")
, _featuredProperties(
"FeaturedProperties",
"Featured Properties",
@@ -796,7 +795,6 @@ void GUI::renderAndUpdatePropertyVisibility() {
_moduleProperty.setVisibility(_currentVisibility);
_sceneProperty.setVisibility(_currentVisibility);
_screenSpaceProperty.setVisibility(_currentVisibility);
_virtualProperty.setVisibility(_currentVisibility);
_featuredProperties.setVisibility(_currentVisibility);
}

View File

@@ -28,7 +28,6 @@
#include <modules/server/include/jsonconverters.h>
#include <modules/volume/transferfunctionhandler.h>
#include <openspace/engine/globals.h>
#include <openspace/engine/virtualpropertymanager.h>
#include <openspace/engine/windowdelegate.h>
#include <openspace/navigation/navigationhandler.h>
#include <openspace/network/parallelpeer.h>
@@ -88,8 +87,7 @@ json GetPropertyTopic::allProperties() {
global::renderEngine,
global::luaConsole,
global::parallelPeer,
global::navigationHandler,
global::virtualPropertyManager,
global::navigationHandler
}
}
};

View File

@@ -42,7 +42,6 @@ set(OPENSPACE_SOURCE
${OPENSPACE_BASE_DIR}/src/engine/openspaceengine.cpp
${OPENSPACE_BASE_DIR}/src/engine/openspaceengine_lua.inl
${OPENSPACE_BASE_DIR}/src/engine/syncengine.cpp
${OPENSPACE_BASE_DIR}/src/engine/virtualpropertymanager.cpp
${OPENSPACE_BASE_DIR}/src/events/event.cpp
${OPENSPACE_BASE_DIR}/src/events/eventengine.cpp
${OPENSPACE_BASE_DIR}/src/events/eventengine_lua.inl
@@ -223,7 +222,6 @@ set(OPENSPACE_HEADER
${OPENSPACE_BASE_DIR}/include/openspace/engine/moduleengine.inl
${OPENSPACE_BASE_DIR}/include/openspace/engine/openspaceengine.h
${OPENSPACE_BASE_DIR}/include/openspace/engine/syncengine.h
${OPENSPACE_BASE_DIR}/include/openspace/engine/virtualpropertymanager.h
${OPENSPACE_BASE_DIR}/include/openspace/engine/windowdelegate.h
${OPENSPACE_BASE_DIR}/include/openspace/events/event.h
${OPENSPACE_BASE_DIR}/include/openspace/events/eventengine.h

View File

@@ -30,7 +30,6 @@
#include <openspace/engine/moduleengine.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/syncengine.h>
#include <openspace/engine/virtualpropertymanager.h>
#include <openspace/engine/windowdelegate.h>
#include <openspace/events/eventengine.h>
#include <openspace/interaction/actionmanager.h>
@@ -89,7 +88,6 @@ namespace {
sizeof(SyncEngine) +
sizeof(TimeManager) +
sizeof(VersionChecker) +
sizeof(VirtualPropertyManager) +
sizeof(WindowDelegate) +
sizeof(configuration::Configuration) +
sizeof(interaction::ActionManager) +
@@ -258,14 +256,6 @@ void create() {
versionChecker = new VersionChecker;
#endif // WIN32
#ifdef WIN32
virtualPropertyManager = new (currentPos) VirtualPropertyManager;
ghoul_assert(virtualPropertyManager, "No virtualPropertyManager");
currentPos += sizeof(VirtualPropertyManager);
#else // ^^^ WIN32 / !WIN32 vvv
virtualPropertyManager = new VirtualPropertyManager;
#endif // WIN32
#ifdef WIN32
windowDelegate = new (currentPos) WindowDelegate;
ghoul_assert(windowDelegate, "No windowDelegate");
@@ -507,13 +497,6 @@ void destroy() {
delete windowDelegate;
#endif // WIN32
LDEBUGC("Globals", "Destroying 'VirtualPropertyManager'");
#ifdef WIN32
virtualPropertyManager->~VirtualPropertyManager();
#else // ^^^ WIN32 / !WIN32 vvv
delete virtualPropertyManager;
#endif // WIN32
LDEBUGC("Globals", "Destroying 'VersionChecker'");
#ifdef WIN32
versionChecker->~VersionChecker();

View File

@@ -34,7 +34,6 @@
#include <openspace/engine/logfactory.h>
#include <openspace/engine/moduleengine.h>
#include <openspace/engine/syncengine.h>
#include <openspace/engine/virtualpropertymanager.h>
#include <openspace/engine/windowdelegate.h>
#include <openspace/events/event.h>
#include <openspace/events/eventengine.h>
@@ -1811,25 +1810,6 @@ scripting::LuaLibrary OpenSpaceEngine::luaLibrary() {
"",
"Downloads a file from Lua scope"
},
{
"addVirtualProperty",
&luascriptfunctions::addVirtualProperty,
"type, name, identifier,"
"[description, value, minimumValue, maximumValue]",
"Adds a virtual property that will set a group of properties"
},
{
"removeVirtualProperty",
&luascriptfunctions::removeVirtualProperty,
"string",
"Removes a previously added virtual property"
},
{
"removeAllVirtualProperties",
&luascriptfunctions::removeAllVirtualProperties,
"",
"Remove all registered virtual properties"
},
{
"setScreenshotFolder",
&luascriptfunctions::setScreenshotFolder,

View File

@@ -59,108 +59,6 @@ int writeDocumentation(lua_State* L) {
return 0;
}
/**
* \ingroup LuaScripts
* addVirtualProperty():
* Adds a virtual property that will set a group of properties
*/
int addVirtualProperty(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, { 5, 7 }, "lua::addVirtualProperty");
auto [type, name, identifier, description] =
ghoul::lua::values<std::string, std::string, std::string, std::string>(L);
std::unique_ptr<properties::Property> prop;
if (type == "BoolProperty") {
const bool v = ghoul::lua::value<bool>(L);
prop = std::make_unique<properties::BoolProperty>(
properties::Property::PropertyInfo {
identifier.c_str(),
name.c_str(),
description.c_str()
},
v
);
}
else if (type == "IntProperty") {
auto [v, min, max] = ghoul::lua::values<int, int, int>(L);
prop = std::make_unique<properties::IntProperty>(
properties::Property::PropertyInfo {
identifier.c_str(),
name.c_str(),
description.c_str()
},
v,
min,
max
);
}
else if (type == "FloatProperty") {
auto [v, min, max] = ghoul::lua::values<float, float, float>(L);
prop = std::make_unique<properties::FloatProperty>(
properties::Property::PropertyInfo {
identifier.c_str(),
name.c_str(),
description.c_str()
},
v,
min,
max
);
}
else if (type == "TriggerProperty") {
prop = std::make_unique<properties::TriggerProperty>(
properties::Property::PropertyInfo {
identifier.c_str(),
name.c_str(),
description.c_str()
}
);
}
else {
return ghoul::lua::luaError(L, fmt::format("Unknown property type '{}'", type));
}
global::virtualPropertyManager->addProperty(std::move(prop));
return 0;
}
/**
* \ingroup LuaScripts
* removeVirtualProperty():
* Removes a previously added virtual property
*/
int removeVirtualProperty(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::removeVirtualProperty");
const std::string name = ghoul::lua::value<std::string>(L);
properties::Property* p = global::virtualPropertyManager->property(name);
if (p) {
global::virtualPropertyManager->removeProperty(p);
}
else {
LWARNINGC(
"removeVirtualProperty",
fmt::format("Virtual Property with name '{}' did not exist", name)
);
}
return 0;
}
/**
* \ingroup LuaScripts
* removeAllVirtualProperties():
* Remove all registered virtual properties
*/
int removeAllVirtualProperties(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::removeAllVirtualProperties");
for (properties::Property* p : global::virtualPropertyManager->properties()) {
global::virtualPropertyManager->removeProperty(p);
delete p;
}
return 0;
}
int setScreenshotFolder(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::setScreenshotFolder");
const std::string arg = ghoul::lua::value<std::string>(L);

View File

@@ -1,62 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2022 *
* *
* 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 <openspace/engine/virtualpropertymanager.h>
#include <openspace/properties/property.h>
#include <algorithm>
namespace openspace {
// The VirtualPropertyManager cannot have an identifier (and thus cannot be part of
// another PropertyOwner) as otherwise the regex-as-name trick would no longer work. I
// don't particular like this implementation, but it's what we got for now; I'm open to
// replacing it with a better mechanism
VirtualPropertyManager::VirtualPropertyManager()
: properties::PropertyOwner({ "" })
{}
void VirtualPropertyManager::addProperty(std::unique_ptr<properties::Property> prop) {
// PropertyOwner does not take the ownership of the pointer
properties::PropertyOwner::addProperty(prop.get());
// So we store the pointer locally instead
_properties.push_back(std::move(prop));
}
void VirtualPropertyManager::removeProperty(properties::Property* prop) {
properties::PropertyOwner::removeProperty(prop);
_properties.erase(
std::remove_if(
_properties.begin(),
_properties.end(),
[prop](const std::unique_ptr<properties::Property>& p) {
return p.get() == prop;
}
),
_properties.end()
);
}
} // namespace openspace

View File

@@ -25,7 +25,6 @@
#include <openspace/query/query.h>
#include <openspace/engine/globals.h>
#include <openspace/engine/virtualpropertymanager.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/scene/scene.h>
@@ -64,13 +63,6 @@ std::vector<properties::Property*> allProperties() {
properties.insert(properties.end(), p.begin(), p.end());
// The virtual property manager is not part of the rootProperty owner since it cannot
// have an identifier or the "regex as identifier" trick would not work
std::vector<properties::Property*> p2 =
global::virtualPropertyManager->propertiesRecursive();
properties.insert(properties.end(), p2.begin(), p2.end());
return properties;
}