mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-26 14:08:53 -05:00
Merge remote-tracking branch 'origin/master' into feature/loadingscreen-refactor
# Conflicts: # modules/volume/rendering/renderabletimevaryingvolume.cpp
This commit is contained in:
@@ -39,6 +39,7 @@ set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimageonline.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/translation/luatranslation.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/translation/statictranslation.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rotation/fixedrotation.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rotation/luarotation.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rotation/staticrotation.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/scale/luascale.h
|
||||
@@ -61,6 +62,7 @@ set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimageonline.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/translation/luatranslation.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/translation/statictranslation.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rotation/fixedrotation.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rotation/luarotation.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rotation/staticrotation.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/scale/luascale.cpp
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include <modules/base/translation/luatranslation.h>
|
||||
#include <modules/base/translation/statictranslation.h>
|
||||
|
||||
#include <modules/base/rotation/fixedrotation.h>
|
||||
#include <modules/base/rotation/luarotation.h>
|
||||
#include <modules/base/rotation/staticrotation.h>
|
||||
|
||||
@@ -94,6 +95,7 @@ void BaseModule::internalInitialize() {
|
||||
auto fRotation = FactoryManager::ref().factory<Rotation>();
|
||||
ghoul_assert(fRotation, "Rotation factory was not created");
|
||||
|
||||
fRotation->registerClass<FixedRotation>("FixedRotation");
|
||||
fRotation->registerClass<LuaRotation>("LuaRotation");
|
||||
fRotation->registerClass<StaticRotation>("StaticRotation");
|
||||
|
||||
@@ -118,6 +120,7 @@ std::vector<documentation::Documentation> BaseModule::documentations() const {
|
||||
ScreenSpaceFramebuffer::Documentation(),
|
||||
ScreenSpaceImageLocal::Documentation(),
|
||||
ScreenSpaceImageOnline::Documentation(),
|
||||
FixedRotation::Documentation(),
|
||||
LuaRotation::Documentation(),
|
||||
StaticRotation::Documentation(),
|
||||
LuaScale::Documentation(),
|
||||
|
||||
@@ -36,9 +36,12 @@ namespace openspace {
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
/**
|
||||
* @brief Creates a texture by rendering to a framebuffer, this is then used on a screen space plane.
|
||||
* @details This class lets you ass renderfunctions that should render to a framebuffer with an attached texture.
|
||||
* The texture is then used on a screen space plane that works both in fisheye and flat screens.
|
||||
* @brief Creates a texture by rendering to a framebuffer, this is then used on a screen
|
||||
* space plane.
|
||||
* @details This class lets you ass renderfunctions that should render to a framebuffer
|
||||
* with an attached texture.
|
||||
* The texture is then used on a screen space plane that works both in fisheye and flat
|
||||
* screens.
|
||||
*/
|
||||
class ScreenSpaceFramebuffer : public ScreenSpaceRenderable {
|
||||
public:
|
||||
|
||||
@@ -0,0 +1,616 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* 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/base/rotation/fixedrotation.h>
|
||||
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/query/query.h>
|
||||
|
||||
#include <ghoul/misc/assert.h>
|
||||
|
||||
namespace {
|
||||
const char* KeyXAxis = "XAxis";
|
||||
const char* KeyYAxis = "YAxis";
|
||||
const char* KeyZAxis = "ZAxis";
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo TypeInfo = {
|
||||
"Type",
|
||||
"Specification Type",
|
||||
"This value specifies how this axis is being specified, that is whether it is "
|
||||
"referencing another object, specifying an absolute vector, or whether it is "
|
||||
"using the right handed coordinate system completion based off the other two "
|
||||
"vectors."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo ObjectInfo = {
|
||||
"Object",
|
||||
"Focus Object",
|
||||
"This is the object that the axis will focus on. This object must name an "
|
||||
"existing scene graph node in the currently loaded scene and the rotation will "
|
||||
"stay fixed to the current position of that object."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo VectorInfo = {
|
||||
"Vector",
|
||||
"Direction vector",
|
||||
"This value specifies a static direction vector that is used for a fixed "
|
||||
"rotation."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo OrthogonalVectorInfo = {
|
||||
"Orthogonal",
|
||||
"Vector is orthogonal",
|
||||
"This value determines whether the vector specified is used directly, or whether "
|
||||
"it is used together with another non-coordinate system completion vector to "
|
||||
"construct an orthogonal vector instead."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo AttachedInfo = {
|
||||
"Attached",
|
||||
"Attached Node",
|
||||
"This is the name of the node that this rotation is attached to, this value is "
|
||||
"only needed if any of the three axis uses the Object type. In this case, the "
|
||||
"location of the attached node is required to compute the relative direction."
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation FixedRotation::Documentation() {
|
||||
using namespace openspace::documentation;
|
||||
return {
|
||||
"Fixed Rotation",
|
||||
"base_transform_rotation_fixed",
|
||||
{
|
||||
{
|
||||
"Type",
|
||||
new StringEqualVerifier("FixedRotation"),
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
KeyXAxis,
|
||||
new OrVerifier(
|
||||
new StringVerifier,
|
||||
new DoubleVector3Verifier
|
||||
),
|
||||
Optional::Yes,
|
||||
"This value specifies the direction of the new X axis. If this value is "
|
||||
"not specified, it will be computed by completing a right handed "
|
||||
"coordinate system from the Y and Z axis, which must be specified "
|
||||
"instead."
|
||||
},
|
||||
{
|
||||
KeyXAxis + OrthogonalVectorInfo.identifier,
|
||||
new BoolVerifier,
|
||||
Optional::Yes,
|
||||
OrthogonalVectorInfo.description
|
||||
},
|
||||
{
|
||||
KeyYAxis,
|
||||
new OrVerifier(
|
||||
new StringVerifier,
|
||||
new DoubleVector3Verifier
|
||||
),
|
||||
Optional::Yes,
|
||||
"This value specifies the direction of the new Y axis. If this value is "
|
||||
"not specified, it will be computed by completing a right handed "
|
||||
"coordinate system from the X and Z axis, which must be specified "
|
||||
"instead."
|
||||
},
|
||||
{
|
||||
KeyYAxis + OrthogonalVectorInfo.identifier,
|
||||
new BoolVerifier,
|
||||
Optional::Yes,
|
||||
OrthogonalVectorInfo.description
|
||||
},
|
||||
{
|
||||
KeyZAxis,
|
||||
new OrVerifier(
|
||||
new StringVerifier,
|
||||
new DoubleVector3Verifier
|
||||
),
|
||||
Optional::Yes,
|
||||
"This value specifies the direction of the new Z axis. If this value is "
|
||||
"not specified, it will be computed by completing a right handed "
|
||||
"coordinate system from the X and Y axis, which must be specified "
|
||||
"instead."
|
||||
},
|
||||
{
|
||||
KeyZAxis + OrthogonalVectorInfo.identifier,
|
||||
new BoolVerifier,
|
||||
Optional::Yes,
|
||||
OrthogonalVectorInfo.description
|
||||
},
|
||||
{
|
||||
AttachedInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
AttachedInfo.description
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
FixedRotation::FixedRotation(const ghoul::Dictionary& dictionary)
|
||||
: _xAxis{
|
||||
properties::OptionProperty(
|
||||
{
|
||||
"xAxis-" + TypeInfo.identifier,
|
||||
"xAxis:" + TypeInfo.guiName,
|
||||
TypeInfo.description
|
||||
}
|
||||
),
|
||||
properties::StringProperty(
|
||||
{
|
||||
"xAxis-" + ObjectInfo.identifier,
|
||||
"xAxis:" + ObjectInfo.guiName,
|
||||
ObjectInfo.description
|
||||
},
|
||||
""
|
||||
),
|
||||
properties::Vec3Property(
|
||||
{
|
||||
"xAxis-" + VectorInfo.identifier,
|
||||
"xAxis:" + VectorInfo.guiName,
|
||||
VectorInfo.description
|
||||
},
|
||||
glm::vec3(1.f, 0.f, 0.f),
|
||||
glm::vec3(0.f),
|
||||
glm::vec3(1.f)
|
||||
),
|
||||
properties::BoolProperty(
|
||||
{
|
||||
"xAxis-" + OrthogonalVectorInfo.identifier,
|
||||
"xAxis:" + OrthogonalVectorInfo.guiName,
|
||||
OrthogonalVectorInfo.description
|
||||
},
|
||||
false
|
||||
),
|
||||
nullptr
|
||||
}
|
||||
, _yAxis{
|
||||
properties::OptionProperty(
|
||||
{
|
||||
"yAxis-" + TypeInfo.identifier,
|
||||
"yAxis:" + TypeInfo.guiName,
|
||||
"yAxis:" + TypeInfo.description
|
||||
}
|
||||
),
|
||||
properties::StringProperty(
|
||||
{
|
||||
"yAxis-" + ObjectInfo.identifier,
|
||||
"yAxis:" + ObjectInfo.guiName,
|
||||
"yAxis:" + ObjectInfo.description
|
||||
},
|
||||
""
|
||||
),
|
||||
properties::Vec3Property(
|
||||
{
|
||||
"yAxis-" + VectorInfo.identifier,
|
||||
"yAxis:" + VectorInfo.guiName,
|
||||
"yAxis:" + VectorInfo.description
|
||||
},
|
||||
glm::vec3(0.f, 1.f, 0.f),
|
||||
glm::vec3(0.f),
|
||||
glm::vec3(1.f)
|
||||
),
|
||||
properties::BoolProperty(
|
||||
{
|
||||
"yAxis-" + OrthogonalVectorInfo.identifier,
|
||||
"yAxis:" + OrthogonalVectorInfo.guiName,
|
||||
OrthogonalVectorInfo.description
|
||||
},
|
||||
false
|
||||
),
|
||||
nullptr
|
||||
}
|
||||
, _zAxis{
|
||||
properties::OptionProperty(
|
||||
{
|
||||
"zAxis-" + TypeInfo.identifier,
|
||||
"zAxis:" + TypeInfo.guiName,
|
||||
"zAxis:" + TypeInfo.description
|
||||
}
|
||||
),
|
||||
properties::StringProperty(
|
||||
{
|
||||
"zAxis-" + ObjectInfo.identifier,
|
||||
"zAxis:" + ObjectInfo.guiName,
|
||||
"zAxis:" + ObjectInfo.description
|
||||
},
|
||||
""
|
||||
),
|
||||
properties::Vec3Property(
|
||||
{
|
||||
"zAxis-" + VectorInfo.identifier,
|
||||
"zAxis:" + VectorInfo.guiName,
|
||||
"zAxis:" + VectorInfo.description
|
||||
},
|
||||
glm::vec3(0.f, 0.f, 1.f),
|
||||
glm::vec3(0.f),
|
||||
glm::vec3(1.f)
|
||||
),
|
||||
properties::BoolProperty(
|
||||
{
|
||||
"zAxis-" + OrthogonalVectorInfo.identifier,
|
||||
"zAxis:" + OrthogonalVectorInfo.guiName,
|
||||
OrthogonalVectorInfo.description
|
||||
},
|
||||
false
|
||||
),
|
||||
nullptr
|
||||
}
|
||||
, _attachedObject(AttachedInfo, "")
|
||||
, _attachedNode(nullptr)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"FixedRotation"
|
||||
);
|
||||
|
||||
_constructorDictionary = dictionary;
|
||||
|
||||
addProperty(_attachedObject);
|
||||
_attachedObject.onChange([this](){
|
||||
_attachedNode = sceneGraphNode(_attachedObject);
|
||||
});
|
||||
|
||||
|
||||
_xAxis.type.addOptions({
|
||||
{ Axis::Type::Object, "Object" },
|
||||
{ Axis::Type::Vector, "Vector" },
|
||||
{ Axis::Type::OrthogonalVector, "Orthogonal Vector" },
|
||||
{ Axis::Type::CoordinateSystemCompletion, "Coordinate System Completion" }
|
||||
});
|
||||
addProperty(_xAxis.type);
|
||||
addProperty(_xAxis.object);
|
||||
_xAxis.object.onChange([this](){
|
||||
_xAxis.node = sceneGraphNode(_xAxis.object);
|
||||
});
|
||||
addProperty(_xAxis.vector);
|
||||
|
||||
|
||||
_yAxis.type.addOptions({
|
||||
{ Axis::Type::Object, "Object" },
|
||||
{ Axis::Type::Vector, "Vector" },
|
||||
{ Axis::Type::OrthogonalVector, "Orthogonal Vector" },
|
||||
{ Axis::Type::CoordinateSystemCompletion, "Coordinate System Completion" }
|
||||
});
|
||||
addProperty(_yAxis.type);
|
||||
addProperty(_yAxis.object);
|
||||
_yAxis.object.onChange([this](){
|
||||
_yAxis.node = sceneGraphNode(_yAxis.object);
|
||||
});
|
||||
addProperty(_yAxis.vector);
|
||||
|
||||
|
||||
_zAxis.type.addOptions({
|
||||
{ Axis::Type::Object, "Object" },
|
||||
{ Axis::Type::Vector, "Vector" },
|
||||
{ Axis::Type::OrthogonalVector, "Orthogonal Vector" },
|
||||
{ Axis::Type::CoordinateSystemCompletion, "Coordinate System Completion" }
|
||||
});
|
||||
addProperty(_zAxis.type);
|
||||
addProperty(_zAxis.object);
|
||||
_zAxis.object.onChange([this](){
|
||||
_zAxis.node = sceneGraphNode(_zAxis.object);
|
||||
});
|
||||
addProperty(_zAxis.vector);
|
||||
}
|
||||
|
||||
bool FixedRotation::initialize() {
|
||||
// We need to do this in the initialize and not the constructor as the scene graph
|
||||
// nodes referenced in the dictionary might not exist yet at construction time. At
|
||||
// initialization time, however, we know that they already have been created
|
||||
|
||||
bool res = Rotation::initialize();
|
||||
|
||||
if (_constructorDictionary.hasKey(AttachedInfo.identifier)) {
|
||||
_attachedObject = _constructorDictionary.value<std::string>(
|
||||
AttachedInfo.identifier
|
||||
);
|
||||
}
|
||||
|
||||
bool hasXAxis = _constructorDictionary.hasKey(KeyXAxis);
|
||||
if (hasXAxis) {
|
||||
if (_constructorDictionary.hasKeyAndValue<std::string>(KeyXAxis)) {
|
||||
_xAxis.type = Axis::Type::Object;
|
||||
_xAxis.object = _constructorDictionary.value<std::string>(KeyXAxis);
|
||||
}
|
||||
else {
|
||||
// We know it has to be a vector now
|
||||
_xAxis.type = Axis::Type::Vector;
|
||||
_xAxis.vector = _constructorDictionary.value<glm::dvec3>(KeyXAxis);
|
||||
}
|
||||
}
|
||||
|
||||
if (_constructorDictionary.hasKey(KeyXAxis + OrthogonalVectorInfo.identifier)) {
|
||||
_xAxis.isOrthogonal = _constructorDictionary.value<bool>(
|
||||
KeyXAxis + OrthogonalVectorInfo.identifier
|
||||
);
|
||||
}
|
||||
if (_xAxis.isOrthogonal) {
|
||||
_xAxis.type = Axis::Type::OrthogonalVector;
|
||||
}
|
||||
|
||||
bool hasYAxis = _constructorDictionary.hasKey(KeyYAxis);
|
||||
if (hasYAxis) {
|
||||
if (_constructorDictionary.hasKeyAndValue<std::string>(KeyYAxis)) {
|
||||
_yAxis.type = Axis::Type::Object;
|
||||
_yAxis.object = _constructorDictionary.value<std::string>(KeyYAxis);
|
||||
}
|
||||
else {
|
||||
// We know it has to be a vector now
|
||||
_yAxis.type = Axis::Type::Vector;
|
||||
_yAxis.vector = _constructorDictionary.value<glm::dvec3>(KeyYAxis);
|
||||
}
|
||||
}
|
||||
|
||||
if (_constructorDictionary.hasKey(KeyYAxis + OrthogonalVectorInfo.identifier)) {
|
||||
_yAxis.isOrthogonal = _constructorDictionary.value<bool>(
|
||||
KeyYAxis + OrthogonalVectorInfo.identifier
|
||||
);
|
||||
}
|
||||
if (_yAxis.isOrthogonal) {
|
||||
_yAxis.type = Axis::Type::OrthogonalVector;
|
||||
}
|
||||
|
||||
bool hasZAxis = _constructorDictionary.hasKey(KeyZAxis);
|
||||
if (hasZAxis) {
|
||||
if (_constructorDictionary.hasKeyAndValue<std::string>(KeyZAxis)) {
|
||||
_zAxis.type = Axis::Type::Object;
|
||||
_zAxis.object = _constructorDictionary.value<std::string>(KeyZAxis);
|
||||
}
|
||||
else {
|
||||
// We know it has to be a vector now
|
||||
_zAxis.type = Axis::Type::Vector;
|
||||
_zAxis.vector = _constructorDictionary.value<glm::dvec3>(KeyZAxis);
|
||||
}
|
||||
}
|
||||
|
||||
if (_constructorDictionary.hasKey(KeyZAxis + OrthogonalVectorInfo.identifier)) {
|
||||
_zAxis.isOrthogonal = _constructorDictionary.value<bool>(
|
||||
KeyZAxis + OrthogonalVectorInfo.identifier
|
||||
);
|
||||
}
|
||||
if (_zAxis.isOrthogonal) {
|
||||
_zAxis.type = Axis::Type::OrthogonalVector;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!hasXAxis && hasYAxis && hasZAxis) {
|
||||
_xAxis.type = Axis::Type::CoordinateSystemCompletion;
|
||||
}
|
||||
|
||||
if (hasXAxis && !hasYAxis && hasZAxis) {
|
||||
_yAxis.type = Axis::Type::CoordinateSystemCompletion;
|
||||
}
|
||||
|
||||
if (hasXAxis && hasYAxis && !hasZAxis) {
|
||||
_zAxis.type = Axis::Type::CoordinateSystemCompletion;
|
||||
}
|
||||
|
||||
// No need to hold on to the data
|
||||
_constructorDictionary = {};
|
||||
return res;
|
||||
}
|
||||
|
||||
void FixedRotation::update(const UpdateData&) {
|
||||
glm::vec3 x = xAxis();
|
||||
glm::vec3 y = yAxis();
|
||||
glm::vec3 z = zAxis();
|
||||
|
||||
LINFOC("x", x);
|
||||
LINFOC("y", y);
|
||||
LINFOC("z", z);
|
||||
|
||||
static const float Epsilon = 1e-3;
|
||||
|
||||
if (glm::dot(x, y) > 1.f - Epsilon ||
|
||||
glm::dot(y, z) > 1.f - Epsilon ||
|
||||
glm::dot(x, z) > 1.f - Epsilon)
|
||||
{
|
||||
LWARNINGC(
|
||||
"FixedRotation",
|
||||
"Dangerously collinear vectors detected: " <<
|
||||
"x: " << x << " y: " << y << " z: " << z
|
||||
);
|
||||
_matrix = glm::dmat3();
|
||||
}
|
||||
else {
|
||||
_matrix = {
|
||||
x.x, x.y, x.z,
|
||||
y.x, y.y, y.z,
|
||||
z.x, z.y, z.z
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
glm::vec3 FixedRotation::xAxis() const {
|
||||
switch (_xAxis.type) {
|
||||
case Axis::Type::Unspecified:
|
||||
LWARNINGC("FixedRotation", "Unspecified axis type for X axis");
|
||||
return glm::vec3(1.f, 0.f, 0.f);
|
||||
case Axis::Type::Object:
|
||||
if (_xAxis.node && _attachedNode) {
|
||||
return glm::vec3(glm::normalize(
|
||||
glm::dvec3(_xAxis.node->worldPosition()) -
|
||||
glm::dvec3(_attachedNode->worldPosition())
|
||||
));
|
||||
}
|
||||
else {
|
||||
if (_xAxis.node) {
|
||||
LWARNINGC("FixedRotation", "Missing attachment node");
|
||||
return glm::vec3(1.f, 0.f, 0.f);
|
||||
}
|
||||
else {
|
||||
LWARNINGC("FixedRotation", "Missing node for X axis");
|
||||
return glm::vec3(1.f, 0.f, 0.f);
|
||||
}
|
||||
}
|
||||
case Axis::Type::Vector:
|
||||
if (_xAxis.vector.value() == glm::vec3(0.f)) {
|
||||
LWARNINGC("FixedRotation", "Zero vector detected for X Axis");
|
||||
return glm::vec3(1.f, 0.f, 0.f);
|
||||
}
|
||||
else {
|
||||
return glm::normalize(_xAxis.vector.value());
|
||||
}
|
||||
case Axis::Type::OrthogonalVector:
|
||||
if (_xAxis.vector.value() == glm::vec3(0.f)) {
|
||||
LWARNINGC("FixedRotation", "Zero vector detected for X Axis");
|
||||
return glm::vec3(1.f, 0.f, 0.f);
|
||||
}
|
||||
else {
|
||||
if (_yAxis.type != Axis::Type::CoordinateSystemCompletion) {
|
||||
return glm::normalize(
|
||||
glm::cross(_xAxis.vector.value(), yAxis())
|
||||
);
|
||||
}
|
||||
else {
|
||||
return glm::normalize(
|
||||
glm::cross(_xAxis.vector.value(), zAxis())
|
||||
);
|
||||
}
|
||||
}
|
||||
case Axis::Type::CoordinateSystemCompletion:
|
||||
return glm::normalize(-glm::cross(yAxis(), zAxis()));
|
||||
default:
|
||||
throw ghoul::MissingCaseException();
|
||||
}
|
||||
}
|
||||
|
||||
glm::vec3 FixedRotation::yAxis() const {
|
||||
switch (_yAxis.type) {
|
||||
case Axis::Type::Unspecified:
|
||||
LWARNINGC("FixedRotation", "Unspecified axis type for Y axis");
|
||||
return glm::vec3(0.f, 1.f, 0.f);
|
||||
case Axis::Type::Object:
|
||||
if (_yAxis.node && _attachedNode) {
|
||||
return glm::vec3(glm::normalize(
|
||||
glm::dvec3(_yAxis.node->worldPosition()) -
|
||||
glm::dvec3(_attachedNode->worldPosition())
|
||||
));
|
||||
}
|
||||
else {
|
||||
if (_yAxis.node) {
|
||||
LWARNINGC("FixedRotation", "Missing attachment node");
|
||||
return glm::vec3(0.f, 1.f, 0.f);
|
||||
}
|
||||
else {
|
||||
LWARNINGC("FixedRotation", "Missing node for Y axis");
|
||||
return glm::vec3(0.f, 1.f, 0.f);
|
||||
}
|
||||
}
|
||||
case Axis::Type::Vector:
|
||||
if (_yAxis.vector.value() == glm::vec3(0.f)) {
|
||||
LWARNINGC("FixedRotation", "Zero vector detected for Y Axis");
|
||||
return glm::vec3(0.f, 1.f, 0.f);
|
||||
}
|
||||
else {
|
||||
return glm::normalize(_yAxis.vector.value());
|
||||
}
|
||||
case Axis::Type::OrthogonalVector:
|
||||
if (_yAxis.vector.value() == glm::vec3(0.f)) {
|
||||
LWARNINGC("FixedRotation", "Zero vector detected for Y Axis");
|
||||
return glm::vec3(0.f, 1.f, 0.f);
|
||||
}
|
||||
else {
|
||||
if (_zAxis.type != Axis::Type::CoordinateSystemCompletion) {
|
||||
return glm::normalize(
|
||||
glm::cross(_yAxis.vector.value(), zAxis())
|
||||
);
|
||||
}
|
||||
else {
|
||||
return glm::normalize(
|
||||
glm::cross(_yAxis.vector.value(), xAxis())
|
||||
);
|
||||
}
|
||||
}
|
||||
case Axis::Type::CoordinateSystemCompletion:
|
||||
return glm::normalize(glm::cross(xAxis(), -zAxis()));
|
||||
default:
|
||||
throw ghoul::MissingCaseException();
|
||||
}
|
||||
}
|
||||
|
||||
glm::vec3 FixedRotation::zAxis() const {
|
||||
switch (_zAxis.type) {
|
||||
case Axis::Type::Unspecified:
|
||||
LWARNINGC("FixedRotation", "Unspecified axis type for Z axis");
|
||||
return glm::vec3(0.f, 0.f, 1.f);
|
||||
case Axis::Type::Object:
|
||||
if (_zAxis.node && _attachedNode) {
|
||||
return glm::vec3(glm::normalize(
|
||||
glm::dvec3(_zAxis.node->worldPosition()) -
|
||||
glm::dvec3(_attachedNode->worldPosition())
|
||||
));
|
||||
}
|
||||
else {
|
||||
if (_zAxis.node) {
|
||||
LWARNINGC("FixedRotation", "Missing attachment node");
|
||||
return glm::vec3(0.f, 0.f, 1.f);
|
||||
}
|
||||
else {
|
||||
LWARNINGC("FixedRotation", "Missing node for Z axis");
|
||||
return glm::vec3(0.f, 0.f, 1.f);
|
||||
}
|
||||
}
|
||||
case Axis::Type::Vector:
|
||||
if (_zAxis.vector.value() == glm::vec3(0.f)) {
|
||||
LWARNINGC("FixedRotation", "Zero vector detected for Z Axis");
|
||||
return glm::vec3(0.f, 0.f, 1.f);
|
||||
}
|
||||
else {
|
||||
return glm::normalize(_zAxis.vector.value());
|
||||
}
|
||||
case Axis::Type::OrthogonalVector:
|
||||
if (_zAxis.vector.value() == glm::vec3(0.f)) {
|
||||
LWARNINGC("FixedRotation", "Zero vector detected for Z Axis");
|
||||
return glm::vec3(0.f, 0.f, 1.f);
|
||||
}
|
||||
else {
|
||||
if (_xAxis.type != Axis::Type::CoordinateSystemCompletion) {
|
||||
return glm::normalize(
|
||||
glm::cross(_zAxis.vector.value(), xAxis())
|
||||
);
|
||||
}
|
||||
else {
|
||||
return glm::normalize(
|
||||
glm::cross(_zAxis.vector.value(), yAxis())
|
||||
);
|
||||
}
|
||||
}
|
||||
case Axis::Type::CoordinateSystemCompletion:
|
||||
return glm::normalize(glm::cross(xAxis(), yAxis()));
|
||||
default:
|
||||
throw ghoul::MissingCaseException();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
@@ -0,0 +1,87 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* 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_BASE___FIXEDROTATION___H__
|
||||
#define __OPENSPACE_MODULE_BASE___FIXEDROTATION___H__
|
||||
|
||||
#include <openspace/scene/rotation.h>
|
||||
|
||||
#include <openspace/properties/optionproperty.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/properties/vector/vec3property.h>
|
||||
|
||||
#include <ghoul/glm.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class SceneGraphNode;
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
class FixedRotation : public Rotation {
|
||||
public:
|
||||
FixedRotation(const ghoul::Dictionary& dictionary);
|
||||
|
||||
bool initialize() override;
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
private:
|
||||
glm::vec3 xAxis() const;
|
||||
glm::vec3 yAxis() const;
|
||||
glm::vec3 zAxis() const;
|
||||
|
||||
struct Axis {
|
||||
enum Type {
|
||||
Unspecified = 0,
|
||||
Object,
|
||||
Vector,
|
||||
OrthogonalVector,
|
||||
CoordinateSystemCompletion
|
||||
};
|
||||
|
||||
properties::OptionProperty type;
|
||||
properties::StringProperty object;
|
||||
properties::Vec3Property vector;
|
||||
properties::BoolProperty isOrthogonal;
|
||||
|
||||
SceneGraphNode* node;
|
||||
};
|
||||
|
||||
Axis _xAxis;
|
||||
Axis _yAxis;
|
||||
Axis _zAxis;
|
||||
|
||||
properties::StringProperty _attachedObject;
|
||||
SceneGraphNode* _attachedNode;
|
||||
|
||||
ghoul::Dictionary _constructorDictionary;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_MODULE_BASE___FIXEDROTATION___H__
|
||||
@@ -40,7 +40,9 @@
|
||||
|
||||
namespace openspace {
|
||||
|
||||
DigitalUniverseModule::DigitalUniverseModule() : OpenSpaceModule(DigitalUniverseModule::Name) {}
|
||||
DigitalUniverseModule::DigitalUniverseModule()
|
||||
: OpenSpaceModule(DigitalUniverseModule::Name)
|
||||
{}
|
||||
|
||||
void DigitalUniverseModule::internalInitialize() {
|
||||
auto fRenderable = FactoryManager::ref().factory<Renderable>();
|
||||
|
||||
@@ -265,7 +265,10 @@ void RenderableFieldlines::render(const RenderData& data, RendererTasks&) {
|
||||
_program->activate();
|
||||
_program->setUniform("modelViewProjection", data.camera.viewProjectionMatrix());
|
||||
_program->setUniform("modelTransform", glm::mat4(1.0));
|
||||
_program->setUniform("cameraViewDir", glm::vec3(data.camera.viewDirectionWorldSpace()));
|
||||
_program->setUniform(
|
||||
"cameraViewDir",
|
||||
glm::vec3(data.camera.viewDirectionWorldSpace())
|
||||
);
|
||||
glDisable(GL_CULL_FACE);
|
||||
setPscUniforms(*_program, data.camera, data.position);
|
||||
|
||||
@@ -310,7 +313,11 @@ void RenderableFieldlines::update(const UpdateData&) {
|
||||
_lineStart.push_back(prevEnd);
|
||||
_lineCount.push_back(static_cast<int>(fieldlines[j].size()));
|
||||
prevEnd = prevEnd + static_cast<int>(fieldlines[j].size());
|
||||
vertexData.insert(vertexData.end(), fieldlines[j].begin(), fieldlines[j].end());
|
||||
vertexData.insert(
|
||||
vertexData.end(),
|
||||
fieldlines[j].begin(),
|
||||
fieldlines[j].end()
|
||||
);
|
||||
}
|
||||
LDEBUG("Number of vertices : " << vertexData.size());
|
||||
|
||||
@@ -324,15 +331,34 @@ void RenderableFieldlines::update(const UpdateData&) {
|
||||
}
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer);
|
||||
|
||||
glBufferData(GL_ARRAY_BUFFER, vertexData.size()*sizeof(LinePoint), &vertexData.front(), GL_STATIC_DRAW);
|
||||
glBufferData(
|
||||
GL_ARRAY_BUFFER,
|
||||
vertexData.size() * sizeof(LinePoint),
|
||||
&vertexData.front(),
|
||||
GL_STATIC_DRAW
|
||||
);
|
||||
|
||||
GLuint vertexLocation = 0;
|
||||
glEnableVertexAttribArray(vertexLocation);
|
||||
glVertexAttribPointer(vertexLocation, 3, GL_FLOAT, GL_FALSE, sizeof(LinePoint), reinterpret_cast<void*>(0));
|
||||
glVertexAttribPointer(
|
||||
vertexLocation,
|
||||
3,
|
||||
GL_FLOAT,
|
||||
GL_FALSE,
|
||||
sizeof(LinePoint),
|
||||
reinterpret_cast<void*>(0)
|
||||
);
|
||||
|
||||
GLuint colorLocation = 1;
|
||||
glEnableVertexAttribArray(colorLocation);
|
||||
glVertexAttribPointer(colorLocation, 4, GL_FLOAT, GL_FALSE, sizeof(LinePoint), (void*)(sizeof(glm::vec3)));
|
||||
glVertexAttribPointer(
|
||||
colorLocation,
|
||||
4,
|
||||
GL_FLOAT,
|
||||
GL_FALSE,
|
||||
sizeof(LinePoint),
|
||||
(void*)(sizeof(glm::vec3))
|
||||
);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindVertexArray(0);
|
||||
@@ -360,7 +386,9 @@ void RenderableFieldlines::loadSeedPointsFromFile() {
|
||||
|
||||
std::ifstream seedFile(_seedPointSourceFile);
|
||||
if (!seedFile.good())
|
||||
LERROR("Could not open seed points file '" << _seedPointSourceFile.value() << "'");
|
||||
LERROR(
|
||||
"Could not open seed points file '" << _seedPointSourceFile.value() << "'"
|
||||
);
|
||||
else {
|
||||
std::string line;
|
||||
glm::vec3 point;
|
||||
@@ -457,7 +485,13 @@ RenderableFieldlines::generateFieldlinesVolumeKameleon()
|
||||
_vectorFieldInfo.getValue(v3, zVariable);
|
||||
|
||||
KameleonWrapper kw(fileName);
|
||||
return kw.getClassifiedFieldLines(xVariable, yVariable, zVariable, _seedPoints, _stepSize);
|
||||
return kw.getClassifiedFieldLines(
|
||||
xVariable,
|
||||
yVariable,
|
||||
zVariable,
|
||||
_seedPoints,
|
||||
_stepSize
|
||||
);
|
||||
}
|
||||
|
||||
if (lorentzForce) {
|
||||
|
||||
@@ -57,7 +57,6 @@ private:
|
||||
typedef std::vector<LinePoint> Line;
|
||||
|
||||
void initializeDefaultPropertyValues();
|
||||
//std::vector<std::vector<LinePoint> > getFieldlinesData(std::string filename, ghoul::Dictionary hintsDictionary);
|
||||
std::vector<Line> getFieldlinesData();
|
||||
void loadSeedPoints();
|
||||
void loadSeedPointsFromFile();
|
||||
|
||||
@@ -38,10 +38,10 @@ FieldlinesSequenceModule::FieldlinesSequenceModule()
|
||||
: OpenSpaceModule("FieldlinesSequence") {}
|
||||
|
||||
void FieldlinesSequenceModule::internalInitialize() {
|
||||
auto fRenderable = FactoryManager::ref().factory<Renderable>();
|
||||
ghoul_assert(fRenderable, "No renderable factory existed");
|
||||
auto factory = FactoryManager::ref().factory<Renderable>();
|
||||
ghoul_assert(factory, "No renderable factory existed");
|
||||
|
||||
fRenderable->registerClass<RenderableFieldlinesSequence>("RenderableFieldlinesSequence");
|
||||
factory->registerClass<RenderableFieldlinesSequence>("RenderableFieldlinesSequence");
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -78,9 +78,9 @@ void RenderableFieldlinesSequence::render(const RenderData& data, RendererTasks&
|
||||
// Calculate Model View MatrixProjection
|
||||
const glm::dmat4 rotMat = glm::dmat4(data.modelTransform.rotation);
|
||||
const glm::dmat4 modelMat =
|
||||
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) *
|
||||
rotMat *
|
||||
glm::dmat4(glm::scale(glm::dmat4(1), glm::dvec3(data.modelTransform.scale)));
|
||||
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) *
|
||||
rotMat *
|
||||
glm::dmat4(glm::scale(glm::dmat4(1), glm::dvec3(data.modelTransform.scale)));
|
||||
const glm::dmat4 modelViewMat = data.camera.combinedViewMatrix() * modelMat;
|
||||
|
||||
_shaderProgram->setUniform("modelViewProjection",
|
||||
@@ -232,12 +232,15 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
|
||||
}
|
||||
}
|
||||
|
||||
inline bool RenderableFieldlinesSequence::isWithinSequenceInterval(const double currentTime) const {
|
||||
inline bool RenderableFieldlinesSequence::isWithinSequenceInterval(
|
||||
const double currentTime) const
|
||||
{
|
||||
return (currentTime >= _startTimes[0]) && (currentTime < _sequenceEndTime);
|
||||
}
|
||||
|
||||
// Assumes we already know that currentTime is within the sequence interval
|
||||
void RenderableFieldlinesSequence::updateActiveTriggerTimeIndex(const double currentTime) {
|
||||
void RenderableFieldlinesSequence::updateActiveTriggerTimeIndex(const double currentTime)
|
||||
{
|
||||
auto iter = std::upper_bound(_startTimes.begin(), _startTimes.end(), currentTime);
|
||||
if (iter != _startTimes.end()) {
|
||||
if ( iter != _startTimes.begin()) {
|
||||
|
||||
@@ -58,7 +58,8 @@ public:
|
||||
void update(const UpdateData& data) override;
|
||||
private:
|
||||
// ------------------------------------- ENUMS -------------------------------------//
|
||||
enum ColorMethod : int { // Used to determine if lines should be colored UNIFORMLY or by an extraQuantity
|
||||
// Used to determine if lines should be colored UNIFORMLY or by an extraQuantity
|
||||
enum ColorMethod : int {
|
||||
Uniform = 0,
|
||||
ByQuantity
|
||||
};
|
||||
@@ -67,73 +68,139 @@ private:
|
||||
std::string _name; // Name of the Node!
|
||||
|
||||
// ------------------------------------- FLAGS -------------------------------------//
|
||||
std::atomic<bool> _isLoadingStateFromDisk { false}; // Used for 'runtime-states'. True when loading a new state from disk on another thread.
|
||||
bool _isReady = false; // If initialization proved successful
|
||||
bool _loadingStatesDynamically = false; // False => states are stored in RAM (using 'in-RAM-states'), True => states are loaded from disk during runtime (using 'runtime-states')
|
||||
bool _mustLoadNewStateFromDisk = false; // Used for 'runtime-states': True if new 'runtime-state' must be loaded from disk. False => the previous frame's state should still be shown
|
||||
bool _needsUpdate = false; // Used for 'in-RAM-states' : True if new 'in-RAM-state' must be loaded. False => the previous frame's state should still be shown
|
||||
std::atomic<bool> _newStateIsReady { false}; // Used for 'runtime-states'. True when finished loading a new state from disk on another thread.
|
||||
bool _shouldUpdateColorBuffer = false; // True when new state is loaded or user change which quantity to color the lines by
|
||||
bool _shouldUpdateMaskingBuffer = false; // True when new state is loaded or user change which quantity used for masking out line segments
|
||||
// Used for 'runtime-states'. True when loading a new state from disk on another
|
||||
// thread.
|
||||
std::atomic<bool> _isLoadingStateFromDisk { false};
|
||||
// If initialization proved successful
|
||||
bool _isReady = false;
|
||||
// False => states are stored in RAM (using 'in-RAM-states'), True => states are
|
||||
// loaded from disk during runtime (using 'runtime-states')
|
||||
bool _loadingStatesDynamically = false;
|
||||
// Used for 'runtime-states': True if new 'runtime-state' must be loaded from disk.
|
||||
// False => the previous frame's state should still be shown
|
||||
bool _mustLoadNewStateFromDisk = false;
|
||||
// Used for 'in-RAM-states' : True if new 'in-RAM-state' must be loaded.
|
||||
// False => the previous frame's state should still be shown
|
||||
bool _needsUpdate = false;
|
||||
// Used for 'runtime-states'. True when finished loading a new state from disk on
|
||||
// another thread.
|
||||
std::atomic<bool> _newStateIsReady = false;
|
||||
// True when new state is loaded or user change which quantity to color the lines by
|
||||
bool _shouldUpdateColorBuffer = false;
|
||||
// True when new state is loaded or user change which quantity used for masking out
|
||||
// line segments
|
||||
bool _shouldUpdateMaskingBuffer = false;
|
||||
|
||||
// --------------------------------- NUMERICALS ----------------------------------- //
|
||||
int _activeStateIndex = -1; // Active index of _states. If(==-1)=>no state available for current time. Always the same as _activeTriggerTimeIndex if(_loadingStatesDynamically==true), else always = 0
|
||||
int _activeTriggerTimeIndex = -1; // Active index of _startTimes
|
||||
size_t _nStates = 0; // Number of states in the sequence
|
||||
float _scalingFactor = 1.f; // In setup it is used to scale JSON coordinates. During runtime it is used to scale domain limits.
|
||||
double _sequenceEndTime; // Estimated end of sequence.
|
||||
GLuint _vertexArrayObject = 0; // OpenGL Vertex Array Object
|
||||
GLuint _vertexColorBuffer = 0; // OpenGL Vertex Buffer Object containing the extraQuantity values used for coloring the lines
|
||||
GLuint _vertexMaskingBuffer = 0; // OpenGL Vertex Buffer Object containing the extraQuantity values used for masking out segments of the lines
|
||||
GLuint _vertexPositionBuffer = 0; // OpenGL Vertex Buffer Object containing the vertex positions
|
||||
// Active index of _states. If(==-1)=>no state available for current time. Always the
|
||||
// same as _activeTriggerTimeIndex if(_loadingStatesDynamically==true), else
|
||||
// always = 0
|
||||
int _activeStateIndex = -1;
|
||||
// Active index of _startTimes
|
||||
int _activeTriggerTimeIndex = -1;
|
||||
// Number of states in the sequence
|
||||
size_t _nStates = 0;
|
||||
// In setup it is used to scale JSON coordinates. During runtime it is used to scale
|
||||
// domain limits.
|
||||
float _scalingFactor = 1.f;
|
||||
// Estimated end of sequence.
|
||||
double _sequenceEndTime;
|
||||
// OpenGL Vertex Array Object
|
||||
GLuint _vertexArrayObject = 0;
|
||||
// OpenGL Vertex Buffer Object containing the extraQuantity values used for coloring
|
||||
// the lines
|
||||
GLuint _vertexColorBuffer = 0;
|
||||
// OpenGL Vertex Buffer Object containing the extraQuantity values used for masking
|
||||
// out segments of the lines
|
||||
GLuint _vertexMaskingBuffer = 0;
|
||||
// OpenGL Vertex Buffer Object containing the vertex positions
|
||||
GLuint _vertexPositionBuffer = 0;
|
||||
|
||||
// ----------------------------------- POINTERS ------------------------------------//
|
||||
std::unique_ptr<ghoul::Dictionary> _dictionary; // The Lua-Modfile-Dictionary used during initialization
|
||||
std::unique_ptr<FieldlinesState> _newState; // Used for 'runtime-states' when switching out current state to a new state
|
||||
// The Lua-Modfile-Dictionary used during initialization
|
||||
std::unique_ptr<ghoul::Dictionary> _dictionary;
|
||||
// Used for 'runtime-states' when switching out current state to a new state
|
||||
std::unique_ptr<FieldlinesState> _newState;
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _shaderProgram;
|
||||
std::shared_ptr<TransferFunction> _transferFunction; // Transfer function used to color lines when _pColorMethod is set to BY_QUANTITY
|
||||
// Transfer function used to color lines when _pColorMethod is set to BY_QUANTITY
|
||||
std::shared_ptr<TransferFunction> _transferFunction;
|
||||
|
||||
// ------------------------------------ VECTORS ----------------------------------- //
|
||||
std::vector<std::string> _colorTablePaths; // Paths to color tables. One for each 'extraQuantity'
|
||||
std::vector<glm::vec2> _colorTableRanges; // Values represents min & max values represented in the color table
|
||||
std::vector<glm::vec2> _maskingRanges; // Values represents min & max limits for valid masking range
|
||||
std::vector<std::string> _sourceFiles; // Stores the provided source file paths if using 'runtime-states', else emptied after initialization
|
||||
std::vector<double> _startTimes; // Contains the _triggerTimes for all FieldlineStates in the sequence
|
||||
std::vector<FieldlinesState> _states; // Stores the FieldlineStates
|
||||
// Paths to color tables. One for each 'extraQuantity'
|
||||
std::vector<std::string> _colorTablePaths;
|
||||
// Values represents min & max values represented in the color table
|
||||
std::vector<glm::vec2> _colorTableRanges;
|
||||
// Values represents min & max limits for valid masking range
|
||||
std::vector<glm::vec2> _maskingRanges;
|
||||
// Stores the provided source file paths if using 'runtime-states', else emptied after
|
||||
// initialization
|
||||
std::vector<std::string> _sourceFiles;
|
||||
// Contains the _triggerTimes for all FieldlineStates in the sequence
|
||||
std::vector<double> _startTimes;
|
||||
// Stores the FieldlineStates
|
||||
std::vector<FieldlinesState> _states;
|
||||
|
||||
// ---------------------------------- Properties ---------------------------------- //
|
||||
properties::PropertyOwner _pColorGroup; // Group to hold the color properties
|
||||
properties::OptionProperty _pColorMethod; // Uniform/transfer function/topology?
|
||||
properties::OptionProperty _pColorQuantity; // Index of the extra quantity to color lines by
|
||||
properties::StringProperty _pColorQuantityMin; // Color table/transfer function min
|
||||
properties::StringProperty _pColorQuantityMax; // Color table/transfer function max
|
||||
properties::StringProperty _pColorTablePath; // Color table/transfer function for "By Quantity" coloring
|
||||
properties::Vec4Property _pColorUniform; // Uniform Field Line Color
|
||||
properties::BoolProperty _pColorABlendEnabled; // Whether or not to use additive blending
|
||||
// Group to hold the color properties
|
||||
properties::PropertyOwner _pColorGroup;
|
||||
// Uniform/transfer function/topology?
|
||||
properties::OptionProperty _pColorMethod;
|
||||
// Index of the extra quantity to color lines by
|
||||
properties::OptionProperty _pColorQuantity;
|
||||
// Color table/transfer function min
|
||||
properties::StringProperty _pColorQuantityMin;
|
||||
// Color table/transfer function max
|
||||
properties::StringProperty _pColorQuantityMax;
|
||||
// Color table/transfer function for "By Quantity" coloring
|
||||
properties::StringProperty _pColorTablePath;
|
||||
// Uniform Field Line Color
|
||||
properties::Vec4Property _pColorUniform;
|
||||
// Whether or not to use additive blending
|
||||
properties::BoolProperty _pColorABlendEnabled;
|
||||
|
||||
properties::BoolProperty _pDomainEnabled; // Whether or not to use Domain
|
||||
properties::PropertyOwner _pDomainGroup; // Group to hold the Domain properties
|
||||
properties::Vec2Property _pDomainX; // Domain Limits along x-axis
|
||||
properties::Vec2Property _pDomainY; // Domain Limits along y-axis
|
||||
properties::Vec2Property _pDomainZ; // Domain Limits along z-axis
|
||||
properties::Vec2Property _pDomainR; // Domain Limits radially
|
||||
// Whether or not to use Domain
|
||||
properties::BoolProperty _pDomainEnabled;
|
||||
// Group to hold the Domain properties
|
||||
properties::PropertyOwner _pDomainGroup;
|
||||
// Domain Limits along x-axis
|
||||
properties::Vec2Property _pDomainX;
|
||||
// Domain Limits along y-axis
|
||||
properties::Vec2Property _pDomainY;
|
||||
// Domain Limits along z-axis
|
||||
properties::Vec2Property _pDomainZ;
|
||||
// Domain Limits radially
|
||||
properties::Vec2Property _pDomainR;
|
||||
|
||||
properties::Vec4Property _pFlowColor; // Simulated particles' color
|
||||
properties::BoolProperty _pFlowEnabled; // Toggle flow [ON/OFF]
|
||||
properties::PropertyOwner _pFlowGroup; // Group to hold the flow/particle properties
|
||||
properties::IntProperty _pFlowParticleSize; // Size of simulated flow particles
|
||||
properties::IntProperty _pFlowParticleSpacing; // Size of simulated flow particles
|
||||
properties::BoolProperty _pFlowReversed; // Toggle flow direction [FORWARDS/BACKWARDS]
|
||||
properties::IntProperty _pFlowSpeed; // Speed of simulated flow
|
||||
// Simulated particles' color
|
||||
properties::Vec4Property _pFlowColor;
|
||||
// Toggle flow [ON/OFF]
|
||||
properties::BoolProperty _pFlowEnabled;
|
||||
// Group to hold the flow/particle properties
|
||||
properties::PropertyOwner _pFlowGroup;
|
||||
// Size of simulated flow particles
|
||||
properties::IntProperty _pFlowParticleSize;
|
||||
// Size of simulated flow particles
|
||||
properties::IntProperty _pFlowParticleSpacing;
|
||||
// Toggle flow direction [FORWARDS/BACKWARDS]
|
||||
properties::BoolProperty _pFlowReversed;
|
||||
// Speed of simulated flow
|
||||
properties::IntProperty _pFlowSpeed;
|
||||
|
||||
properties::BoolProperty _pMaskingEnabled; // Whether or not to use masking
|
||||
properties::PropertyOwner _pMaskingGroup; // Group to hold the masking properties
|
||||
properties::StringProperty _pMaskingMin; // Lower limit for allowed values
|
||||
properties::StringProperty _pMaskingMax; // Upper limit for allowed values
|
||||
properties::OptionProperty _pMaskingQuantity; // Index of the extra quantity to use for masking
|
||||
// Whether or not to use masking
|
||||
properties::BoolProperty _pMaskingEnabled;
|
||||
// Group to hold the masking properties
|
||||
properties::PropertyOwner _pMaskingGroup;
|
||||
// Lower limit for allowed values
|
||||
properties::StringProperty _pMaskingMin;
|
||||
// Upper limit for allowed values
|
||||
properties::StringProperty _pMaskingMax;
|
||||
// Index of the extra quantity to use for masking
|
||||
properties::OptionProperty _pMaskingQuantity;
|
||||
|
||||
properties::TriggerProperty _pFocusOnOriginBtn; // Button which sets camera focus to parent node of the renderable
|
||||
properties::TriggerProperty _pJumpToStartBtn; // Button which executes a time jump to start of sequence
|
||||
// Button which sets camera focus to parent node of the renderable
|
||||
properties::TriggerProperty _pFocusOnOriginBtn;
|
||||
// Button which executes a time jump to start of sequence
|
||||
properties::TriggerProperty _pJumpToStartBtn;
|
||||
|
||||
// --------------------- FUNCTIONS USED DURING INITIALIZATION --------------------- //
|
||||
void addStateToSequence(FieldlinesState& STATE);
|
||||
@@ -147,7 +214,8 @@ private:
|
||||
bool extractMandatoryInfoFromDictionary(SourceFileType& sourceFileType);
|
||||
void extractOptionalInfoFromDictionary(std::string& outputFolderPath);
|
||||
void extractOsflsInfoFromDictionary();
|
||||
bool extractSeedPointsFromFile(const std::string& path, std::vector<glm::vec3>& outVec);
|
||||
bool extractSeedPointsFromFile(const std::string& path,
|
||||
std::vector<glm::vec3>& outVec);
|
||||
void extractTriggerTimesFromFileNames();
|
||||
bool loadJsonStatesIntoRAM(const std::string& outputFolder);
|
||||
void loadOsflsStatesIntoRAM(const std::string& outputFolder);
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <fstream>
|
||||
|
||||
namespace {
|
||||
std::string _loggerCat = "FieldlinesState";
|
||||
const char* _loggerCat = "FieldlinesState";
|
||||
const int CurrentVersion = 0;
|
||||
using json = nlohmann::json;
|
||||
}
|
||||
@@ -99,7 +99,8 @@ bool FieldlinesState::loadStateFromOsfls(const std::string& pathToOsflsFile) {
|
||||
ifs.read( reinterpret_cast<char*>(&byteSizeAllNames), sizeof(size_t));
|
||||
|
||||
// RESERVE/RESIZE vectors
|
||||
// TODO: Do this without initializing values? Resize is slower than just using reserve, due to initialization of all values
|
||||
// TODO: Do this without initializing values? Resize is slower than just using
|
||||
// reserve, due to initialization of all values
|
||||
_lineStart.resize(nLines);
|
||||
_lineCount.resize(nLines);
|
||||
_vertexPositions.resize(nPoints);
|
||||
@@ -107,9 +108,12 @@ bool FieldlinesState::loadStateFromOsfls(const std::string& pathToOsflsFile) {
|
||||
_extraQuantityNames.reserve(nExtras);
|
||||
|
||||
// Read vertex position data
|
||||
ifs.read( reinterpret_cast<char*>(_lineStart.data()), sizeof(GLint)*nLines);
|
||||
ifs.read( reinterpret_cast<char*>(_lineCount.data()), sizeof(GLsizei)*nLines);
|
||||
ifs.read( reinterpret_cast<char*>(_vertexPositions.data()), sizeof(glm::vec3)*nPoints);
|
||||
ifs.read( reinterpret_cast<char*>(_lineStart.data()), sizeof(GLint) * nLines);
|
||||
ifs.read( reinterpret_cast<char*>(_lineCount.data()), sizeof(GLsizei) * nLines);
|
||||
ifs.read(
|
||||
reinterpret_cast<char*>(_vertexPositions.data()),
|
||||
sizeof(glm::vec3) * nPoints
|
||||
);
|
||||
|
||||
// Read all extra quantities
|
||||
for (std::vector<float>& vec : _extraQuantities) {
|
||||
@@ -168,8 +172,10 @@ bool FieldlinesState::loadStateFromJson(const std::string& pathToJsonFile,
|
||||
const size_t nPosComponents = 3; // x,y,z
|
||||
|
||||
if (nVariables < nPosComponents) {
|
||||
LERROR(pathToJsonFile + ": Each field '" + sColumns +
|
||||
"' must contain the variables: 'x', 'y' and 'z' (order is important).");
|
||||
LERROR(
|
||||
pathToJsonFile + ": Each field '" + sColumns +
|
||||
"' must contain the variables: 'x', 'y' and 'z' (order is important)."
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -215,19 +221,27 @@ bool FieldlinesState::loadStateFromJson(const std::string& pathToJsonFile,
|
||||
* @param absPath must be the path to the file (incl. filename but excl. extension!)
|
||||
* Directory must exist! File is created (or overwritten if already existing).
|
||||
* File is structured like this: (for version 0)
|
||||
* 0. int - version number of binary state file! (in case something needs to be altered in the future, then increase CurrentVersion)
|
||||
* 0. int - version number of binary state file! (in case something
|
||||
* needs to be altered in the future, then increase
|
||||
* CurrentVersion)
|
||||
* 1. double - _triggerTime
|
||||
* 2. int - _model
|
||||
* 3. bool - _isMorphable
|
||||
* 4. size_t - Number of lines in the state == _lineStart.size() == _lineCount.size()
|
||||
* 5. size_t - Total number of vertex points == _vertexPositions.size() == _extraQuantities[i].size()
|
||||
* 6. size_t - Number of extra quantites == _extraQuantities.size() == _extraQuantityNames.size()
|
||||
* 7. site_t - Number of total bytes that ALL _extraQuantityNames consists of (Each such name is stored as a c_str which means it ends with the null char '\0' )
|
||||
* 4. size_t - Number of lines in the state == _lineStart.size()
|
||||
* == _lineCount.size()
|
||||
* 5. size_t - Total number of vertex points == _vertexPositions.size()
|
||||
* == _extraQuantities[i].size()
|
||||
* 6. size_t - Number of extra quantites == _extraQuantities.size()
|
||||
* == _extraQuantityNames.size()
|
||||
* 7. site_t - Number of total bytes that ALL _extraQuantityNames
|
||||
* consists of (Each such name is stored as a c_str which
|
||||
* means it ends with the null char '\0' )
|
||||
* 7. std::vector<GLint> - _lineStart
|
||||
* 8. std::vector<GLsizei> - _lineCount
|
||||
* 9. std::vector<glm::vec3> - _vertexPositions
|
||||
* 10. std::vector<float> - _extraQuantities
|
||||
* 11. array of c_str - Strings naming the extra quantities (elements of _extraQuantityNames). Each string ends with null char '\0'
|
||||
* 11. array of c_str - Strings naming the extra quantities (elements of
|
||||
* _extraQuantityNames). Each string ends with null char '\0'
|
||||
*/
|
||||
void FieldlinesState::saveStateToOsfls(const std::string& absPath) {
|
||||
// ------------------------------- Create the file ------------------------------- //
|
||||
@@ -246,7 +260,7 @@ void FieldlinesState::saveStateToOsfls(const std::string& absPath) {
|
||||
// --------- Add each string of _extraQuantityNames into one long string --------- //
|
||||
std::string allExtraQuantityNamesInOne = "";
|
||||
for (std::string str : _extraQuantityNames) {
|
||||
allExtraQuantityNamesInOne += str + '\0'; // Add the null char '\0' for easier reading
|
||||
allExtraQuantityNamesInOne += str + '\0'; // Add null char '\0' for easier reading
|
||||
}
|
||||
|
||||
const size_t nLines = _lineStart.size();
|
||||
@@ -254,24 +268,27 @@ void FieldlinesState::saveStateToOsfls(const std::string& absPath) {
|
||||
const size_t nExtras = _extraQuantities.size();
|
||||
const size_t nStringBytes = allExtraQuantityNamesInOne.size();
|
||||
|
||||
//------------------------------ WRITE EVERYTHING TO FILE ------------------------------
|
||||
// WHICH VERSION OF BINARY FIELDLINES STATE FILE - IN CASE STRUCTURE CHANGES IN THE FUTURE
|
||||
//----------------------------- WRITE EVERYTHING TO FILE -----------------------------
|
||||
// VERSION OF BINARY FIELDLINES STATE FILE - IN CASE STRUCTURE CHANGES IN THE FUTURE
|
||||
ofs.write( (char*)(&CurrentVersion), sizeof( int ) );
|
||||
|
||||
//-------------------- WRITE META DATA FOR STATE --------------------------------
|
||||
ofs.write( reinterpret_cast<char*>(&_triggerTime), sizeof( _triggerTime ) );
|
||||
ofs.write( reinterpret_cast<char*>(&_model), sizeof( int ) );
|
||||
ofs.write( reinterpret_cast<char*>(&_isMorphable), sizeof( bool ) );
|
||||
ofs.write(reinterpret_cast<char*>(&_triggerTime), sizeof( _triggerTime ));
|
||||
ofs.write(reinterpret_cast<char*>(&_model), sizeof( int ));
|
||||
ofs.write(reinterpret_cast<char*>(&_isMorphable), sizeof( bool ));
|
||||
|
||||
ofs.write( reinterpret_cast<const char*>(&nLines), sizeof( size_t ) );
|
||||
ofs.write( reinterpret_cast<const char*>(&nPoints), sizeof( size_t ) );
|
||||
ofs.write( reinterpret_cast<const char*>(&nExtras), sizeof( size_t ) );
|
||||
ofs.write( reinterpret_cast<const char*>(&nStringBytes), sizeof( size_t ) );
|
||||
ofs.write(reinterpret_cast<const char*>(&nLines), sizeof( size_t ));
|
||||
ofs.write(reinterpret_cast<const char*>(&nPoints), sizeof( size_t ));
|
||||
ofs.write(reinterpret_cast<const char*>(&nExtras), sizeof( size_t ));
|
||||
ofs.write(reinterpret_cast<const char*>(&nStringBytes), sizeof( size_t ));
|
||||
|
||||
//---------------------- WRITE ALL ARRAYS OF DATA --------------------------------
|
||||
ofs.write( reinterpret_cast<char*>(_lineStart.data()), sizeof(GLint) * nLines);
|
||||
ofs.write( reinterpret_cast<char*>(_lineCount.data()), sizeof(GLsizei) * nLines);
|
||||
ofs.write( reinterpret_cast<char*>(_vertexPositions.data()), sizeof(glm::vec3) * nPoints);
|
||||
ofs.write(reinterpret_cast<char*>(_lineStart.data()), sizeof(GLint) * nLines);
|
||||
ofs.write(reinterpret_cast<char*>(_lineCount.data()), sizeof(GLsizei) * nLines);
|
||||
ofs.write(
|
||||
reinterpret_cast<char*>(_vertexPositions.data()),
|
||||
sizeof(glm::vec3) * nPoints
|
||||
);
|
||||
// Write the data for each vector in _extraQuantities
|
||||
for (std::vector<float>& vec : _extraQuantities) {
|
||||
ofs.write( reinterpret_cast<char*>(vec.data()), sizeof(float) * nPoints);
|
||||
@@ -279,23 +296,27 @@ void FieldlinesState::saveStateToOsfls(const std::string& absPath) {
|
||||
ofs.write( allExtraQuantityNamesInOne.c_str(), nStringBytes);
|
||||
}
|
||||
|
||||
// TODO: This should probably be rewritten, but this is the way the files were structured by CCMC
|
||||
// TODO: This should probably be rewritten, but this is the way the files were structured
|
||||
// by CCMC
|
||||
// Structure of File! NO TRAILING COMMAS ALLOWED!
|
||||
// Additional info can be stored within each line as the code only extracts the keys it needs (time, trace & data)
|
||||
// Additional info can be stored within each line as the code only extracts the keys it
|
||||
// needs (time, trace & data)
|
||||
// The key/name of each line ("0" & "1" in the example below) is arbitrary
|
||||
// {
|
||||
// "0":{
|
||||
// "time": "YYYY-MM-DDTHH:MM:SS.XXX",
|
||||
// "trace": {
|
||||
// "columns": ["x","y","z","s","temperature","rho","j_para"],
|
||||
// "data": [[8.694,127.853,115.304,0.0,0.047,9.249,-5e-10],...,[8.698,127.253,114.768,0.800,0.0,9.244,-5e-10]]
|
||||
// "data": [[8.694,127.853,115.304,0.0,0.047,9.249,-5e-10],...,
|
||||
// [8.698,127.253,114.768,0.800,0.0,9.244,-5e-10]]
|
||||
// },
|
||||
// },
|
||||
// "1":{
|
||||
// "time": "YYYY-MM-DDTHH:MM:SS.XXX
|
||||
// "trace": {
|
||||
// "columns": ["x","y","z","s","temperature","rho","j_para"],
|
||||
// "data": [[8.694,127.853,115.304,0.0,0.047,9.249,-5e-10],...,[8.698,127.253,114.768,0.800,0.0,9.244,-5e-10]]
|
||||
// "data": [[8.694,127.853,115.304,0.0,0.047,9.249,-5e-10],...,
|
||||
// [8.698,127.253,114.768,0.800,0.0,9.244,-5e-10]]
|
||||
// },
|
||||
// }
|
||||
// }
|
||||
@@ -343,7 +364,7 @@ void FieldlinesState::saveStateToJson(const std::string& absPath) {
|
||||
};
|
||||
}
|
||||
|
||||
//------------------------------ WRITE EVERYTHING TO FILE ------------------------------
|
||||
//----------------------------- WRITE EVERYTHING TO FILE -----------------------------
|
||||
const int indentationSpaces = 2;
|
||||
ofs << std::setw(indentationSpaces) << jFile << std::endl;
|
||||
|
||||
@@ -351,7 +372,7 @@ void FieldlinesState::saveStateToJson(const std::string& absPath) {
|
||||
}
|
||||
|
||||
// Returns one of the extra quantity vectors, _extraQuantities[index].
|
||||
// If index is out of scope an empty vector is returned and the referenced bool will be false.
|
||||
// If index is out of scope an empty vector is returned and the referenced bool is false.
|
||||
const std::vector<float>& FieldlinesState::extraQuantity(const size_t index,
|
||||
bool& isSuccessful) const {
|
||||
if (index < _extraQuantities.size()) {
|
||||
@@ -364,16 +385,20 @@ const std::vector<float>& FieldlinesState::extraQuantity(const size_t index,
|
||||
return std::vector<float>();
|
||||
}
|
||||
|
||||
/** Moves the points in @param line over to _vertexPositions and updates _lineStart & _lineCount accordingly.
|
||||
*/
|
||||
// Moves the points in @param line over to _vertexPositions and updates
|
||||
// _lineStart & _lineCount accordingly.
|
||||
|
||||
void FieldlinesState::addLine(std::vector<glm::vec3>& line) {
|
||||
const size_t nNewPoints = line.size();
|
||||
const size_t nOldPoints = _vertexPositions.size();
|
||||
_lineStart.push_back(static_cast<GLint>(nOldPoints));
|
||||
_lineCount.push_back(static_cast<GLsizei>(nNewPoints));
|
||||
_vertexPositions.reserve(nOldPoints + nNewPoints);
|
||||
_vertexPositions.insert(_vertexPositions.end(), std::make_move_iterator(line.begin()),
|
||||
std::make_move_iterator(line.end()));
|
||||
_vertexPositions.insert(
|
||||
_vertexPositions.end(),
|
||||
std::make_move_iterator(line.begin()),
|
||||
std::make_move_iterator(line.end())
|
||||
);
|
||||
line.clear();
|
||||
}
|
||||
|
||||
@@ -382,4 +407,37 @@ void FieldlinesState::setExtraQuantityNames(std::vector<std::string>& names) {
|
||||
names.clear();
|
||||
_extraQuantities.resize(_extraQuantityNames.size());
|
||||
}
|
||||
|
||||
const std::vector<std::vector<float>>& FieldlinesState::extraQuantities() const {
|
||||
return _extraQuantities;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& FieldlinesState::extraQuantityNames() const {
|
||||
return _extraQuantityNames;
|
||||
}
|
||||
|
||||
const std::vector<GLsizei>& FieldlinesState::lineCount() const {
|
||||
return _lineCount;
|
||||
}
|
||||
|
||||
const std::vector<GLint>& FieldlinesState::lineStart() const {
|
||||
return _lineStart;
|
||||
}
|
||||
|
||||
fls::Model FieldlinesState::FieldlinesState::model() const {
|
||||
return _model;
|
||||
}
|
||||
|
||||
size_t FieldlinesState::nExtraQuantities() const {
|
||||
return _extraQuantities.size();
|
||||
}
|
||||
|
||||
double FieldlinesState::triggerTime() const {
|
||||
return _triggerTime;
|
||||
}
|
||||
|
||||
const std::vector<glm::vec3>& FieldlinesState::vertexPositions() const {
|
||||
return _vertexPositions;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -54,14 +54,14 @@ public:
|
||||
void saveStateToJson(const std::string& pathToJsonFile);
|
||||
|
||||
// ----------------------------------- GETTERS ----------------------------------- //
|
||||
const std::vector<std::vector<float>>& extraQuantities() const { return _extraQuantities; }
|
||||
const std::vector<std::string>& extraQuantityNames() const { return _extraQuantityNames; }
|
||||
const std::vector<GLsizei>& lineCount() const { return _lineCount; }
|
||||
const std::vector<GLint>& lineStart() const { return _lineStart; }
|
||||
fls::Model model() const { return _model; }
|
||||
size_t nExtraQuantities() const { return _extraQuantities.size(); }
|
||||
double triggerTime() const { return _triggerTime; }
|
||||
const std::vector<glm::vec3>& vertexPositions() const { return _vertexPositions; }
|
||||
const std::vector<std::vector<float>>& extraQuantities() const;
|
||||
const std::vector<std::string>& extraQuantityNames() const;
|
||||
const std::vector<GLsizei>& lineCount() const;
|
||||
const std::vector<GLint>& lineStart() const;
|
||||
fls::Model model() const;
|
||||
size_t nExtraQuantities() const;
|
||||
double triggerTime() const;
|
||||
const std::vector<glm::vec3>& vertexPositions() const;
|
||||
|
||||
// Special getter. Returns extraQuantities[INDEX].
|
||||
const std::vector<float>& extraQuantity(const size_t INDEX, bool& isSuccesful) const;
|
||||
|
||||
@@ -42,7 +42,8 @@ namespace {
|
||||
|
||||
const std::string TAsPOverRho = "T = p/rho";
|
||||
const std::string JParallelB = "Current: mag(J||B)";
|
||||
const float ToKelvin = 72429735.6984f; // <-- [nPa]/[amu/cm^3] * ToKelvin => Temperature in Kelvin
|
||||
// [nPa]/[amu/cm^3] * ToKelvin => Temperature in Kelvin
|
||||
const float ToKelvin = 72429735.6984f;
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
@@ -63,14 +64,20 @@ namespace fls {
|
||||
#endif // OPENSPACE_MODULE_KAMELEON_ENABLED
|
||||
// ----------------------------------------------------------------------------------- //
|
||||
|
||||
/** Traces field lines from the provided cdf file using kameleon and stores the data in the provided FieldlinesState.
|
||||
* Returns `false` if it fails to create a valid state. Requires the kameleon module to be activated!
|
||||
/** Traces field lines from the provided cdf file using kameleon and stores the data in
|
||||
* the provided FieldlinesState.
|
||||
* Returns `false` if it fails to create a valid state. Requires the kameleon module to be
|
||||
* activated!
|
||||
* @param state, FieldlineState which should hold the extracted data
|
||||
* @param cdfPath, std::string of the absolute path to a .cdf file
|
||||
* @param seedPoints, vector of seed points from which to trace field lines
|
||||
* @param tracingVar, which quantity to trace lines from. Typically "b" for magnetic field lines and "u" for velocity flow lines
|
||||
* @param extraVars, extra scalar quantities to be stored in the FieldlinesState; e.g. "T" for temperature, "rho" for density or "P" for pressure
|
||||
* @param extraMagVars, variables which should be used for extracting magnitudes, must be a multiple of 3; e.g. "ux", "uy" & "uz" to get the magnitude of the velocity vector at each line vertex
|
||||
* @param tracingVar, which quantity to trace lines from. Typically "b" for magnetic field
|
||||
* lines and "u" for velocity flow lines
|
||||
* @param extraVars, extra scalar quantities to be stored in the FieldlinesState; e.g. "T"
|
||||
* for temperature, "rho" for density or "P" for pressure
|
||||
* @param extraMagVars, variables which should be used for extracting magnitudes, must be
|
||||
* a multiple of 3; e.g. "ux", "uy" & "uz" to get the magnitude of the velocity
|
||||
* vector at each line vertex
|
||||
*/
|
||||
bool convertCdfToFieldlinesState(FieldlinesState& state, const std::string cdfPath,
|
||||
const std::vector<glm::vec3>& seedPoints,
|
||||
@@ -118,7 +125,8 @@ bool convertCdfToFieldlinesState(FieldlinesState& state, const std::string cdfPa
|
||||
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
|
||||
/**
|
||||
* Traces and adds line vertices to state.
|
||||
* Vertices are not scaled to meters nor converted from spherical into cartesian coordinates.
|
||||
* Vertices are not scaled to meters nor converted from spherical into cartesian
|
||||
* coordinates.
|
||||
* Note that extraQuantities will NOT be set!
|
||||
*/
|
||||
bool addLinesToState(ccmc::Kameleon* kameleon, const std::vector<glm::vec3>& seedPoints,
|
||||
@@ -184,8 +192,9 @@ bool addLinesToState(ccmc::Kameleon* kameleon, const std::vector<glm::vec3>& see
|
||||
* coordinate system)!
|
||||
*
|
||||
* @param kameleon raw pointer to an already opened Kameleon object
|
||||
* @param extraScalarVars vector of strings. Strings should be names of a scalar quantities
|
||||
* to load into _extraQuantites; such as: "T" for temperature or "rho" for density.
|
||||
* @param extraScalarVars vector of strings. Strings should be names of a scalar
|
||||
* quantities to load into _extraQuantites; such as: "T" for temperature or "rho" for
|
||||
* density.
|
||||
* @param extraMagVars vector of strings. Size must be multiple of 3. Strings should be
|
||||
* names of the components needed to calculate magnitude. E.g. {"ux", "uy", "uz"} will
|
||||
* calculate: sqrt(ux*ux + uy*uy + uz*uz). Magnitude will be stored in _extraQuantities
|
||||
@@ -256,8 +265,10 @@ void addExtraQuantities(ccmc::Kameleon* kameleon,
|
||||
* _extraQuantityNames vector.
|
||||
*
|
||||
* @param kameleon, raw pointer to an already opened kameleon object
|
||||
* @param extraScalarVars, names of scalar quantities to add to state; e.g "rho" for density
|
||||
* @param extraMagVars, names of the variables used for calculating magnitudes. Must be multiple of 3.
|
||||
* @param extraScalarVars, names of scalar quantities to add to state; e.g "rho" for
|
||||
* density
|
||||
* @param extraMagVars, names of the variables used for calculating magnitudes. Must be
|
||||
* multiple of 3.
|
||||
*/
|
||||
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
|
||||
void prepareStateAndKameleonForExtras(ccmc::Kameleon* kameleon,
|
||||
@@ -271,7 +282,8 @@ void prepareStateAndKameleonForExtras(ccmc::Kameleon* kameleon,
|
||||
// Remove non-existing variables from vector
|
||||
for (int i = 0; i < extraScalarVars.size(); i++) {
|
||||
std::string& str = extraScalarVars[i];
|
||||
bool isSuccesful = kameleon->doesVariableExist(str) && kameleon->loadVariable(str);
|
||||
bool isSuccesful = kameleon->doesVariableExist(str) &&
|
||||
kameleon->loadVariable(str);
|
||||
if (!isSuccesful &&
|
||||
(model == fls::Model::Batsrus && (str == TAsPOverRho || str == "T" ))) {
|
||||
LDEBUG("BATSRUS doesn't contain variable T for temperature. Trying to "
|
||||
@@ -321,7 +333,10 @@ void prepareStateAndKameleonForExtras(ccmc::Kameleon* kameleon,
|
||||
LWARNING("FAILED TO LOAD AT LEAST ONE OF THE MAGNITUDE VARIABLES: "
|
||||
<< s1 << ", " << s2 << " & " << s3
|
||||
<< ". Removing ability to store corresponding magnitude!");
|
||||
extraMagVars.erase(extraMagVars.begin() + i, extraMagVars.begin() + i + 3);
|
||||
extraMagVars.erase(
|
||||
extraMagVars.begin() + i,
|
||||
extraMagVars.begin() + i + 3
|
||||
);
|
||||
i -= 3;
|
||||
} else {
|
||||
extraQuantityNames.push_back(name);
|
||||
|
||||
@@ -52,11 +52,16 @@ public:
|
||||
virtual ~GalaxyRaycaster();
|
||||
void initialize();
|
||||
void deinitialize();
|
||||
void renderEntryPoints(const RenderData& data, ghoul::opengl::ProgramObject& program) override;
|
||||
void renderExitPoints(const RenderData& data, ghoul::opengl::ProgramObject& program) override;
|
||||
void preRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) override;
|
||||
void postRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) override;
|
||||
bool cameraIsInside(const RenderData& data, glm::vec3& localPosition) override;
|
||||
void renderEntryPoints(const RenderData& data,
|
||||
ghoul::opengl::ProgramObject& program) override;
|
||||
void renderExitPoints(const RenderData& data,
|
||||
ghoul::opengl::ProgramObject& program) override;
|
||||
void preRaycast(const RaycastData& data,
|
||||
ghoul::opengl::ProgramObject& program) override;
|
||||
void postRaycast(const RaycastData& data,
|
||||
ghoul::opengl::ProgramObject& program) override;
|
||||
bool cameraIsInside(const RenderData& data,
|
||||
glm::vec3& localPosition) override;
|
||||
|
||||
|
||||
std::string getBoundsVsPath() const override;
|
||||
|
||||
@@ -51,7 +51,8 @@ std::string MilkywayPointsConversionTask::description()
|
||||
return std::string();
|
||||
}
|
||||
|
||||
void MilkywayPointsConversionTask::perform(const Task::ProgressCallback & progressCallback) {
|
||||
void MilkywayPointsConversionTask::perform(const Task::ProgressCallback& progressCallback)
|
||||
{
|
||||
std::ifstream in(_inFilename, std::ios::in);
|
||||
std::ofstream out(_outFilename, std::ios::out | std::ios::binary);
|
||||
|
||||
|
||||
+3
-1
@@ -75,7 +75,9 @@ ghoul::opengl::Texture* TextureContainer::getTextureIfFree() {
|
||||
return texture;
|
||||
}
|
||||
|
||||
const openspace::globebrowsing::TileTextureInitData& TextureContainer::tileTextureInitData() const {
|
||||
const openspace::globebrowsing::TileTextureInitData&
|
||||
TextureContainer::tileTextureInitData() const
|
||||
{
|
||||
return _initData;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,14 @@ bool Chunk::isVisible() const {
|
||||
Chunk::Status Chunk::update(const RenderData& data) {
|
||||
const auto& savedCamera = _owner.savedCamera();
|
||||
const Camera& camRef = savedCamera != nullptr ? *savedCamera : data.camera;
|
||||
RenderData myRenderData = { camRef, data.position, data.time, data.doPerformanceMeasurement, data.renderBinMask, data.modelTransform };
|
||||
RenderData myRenderData = {
|
||||
camRef,
|
||||
data.position,
|
||||
data.time,
|
||||
data.doPerformanceMeasurement,
|
||||
data.renderBinMask,
|
||||
data.modelTransform
|
||||
};
|
||||
|
||||
_isVisible = true;
|
||||
if (_owner.chunkedLodGlobe()->testIfCullable(*this, myRenderData)) {
|
||||
@@ -100,7 +107,9 @@ Chunk::BoundingHeights Chunk::getBoundingHeights() const {
|
||||
// a single raster image. If it is not we will just use the first raster
|
||||
// (that is channel 0).
|
||||
const size_t HeightChannel = 0;
|
||||
const LayerGroup& heightmaps = layerManager->layerGroup(layergroupid::GroupID::HeightLayers);
|
||||
const LayerGroup& heightmaps = layerManager->layerGroup(
|
||||
layergroupid::GroupID::HeightLayers
|
||||
);
|
||||
std::vector<ChunkTileSettingsPair> chunkTileSettingPairs =
|
||||
tileselector::getTilesAndSettingsUnsorted(
|
||||
heightmaps, _tileIndex);
|
||||
|
||||
@@ -64,7 +64,7 @@ int ProjectedArea::getDesiredLevel(const Chunk& chunk, const RenderData& data) c
|
||||
// oo
|
||||
// [ ]<
|
||||
// *geodetic space*
|
||||
//
|
||||
//
|
||||
// closestCorner
|
||||
// +-----------------+ <-- north east corner
|
||||
// | |
|
||||
|
||||
@@ -38,8 +38,9 @@ bool FrustumCuller::isCullable(const Chunk& chunk, const RenderData& data) {
|
||||
// Calculate the MVP matrix
|
||||
glm::dmat4 modelTransform = chunk.owner().modelTransform();
|
||||
glm::dmat4 viewTransform = glm::dmat4(data.camera.combinedViewMatrix());
|
||||
glm::dmat4 modelViewProjectionTransform = glm::dmat4(data.camera.sgctInternal.projectionMatrix())
|
||||
* viewTransform * modelTransform;
|
||||
glm::dmat4 modelViewProjectionTransform = glm::dmat4(
|
||||
data.camera.sgctInternal.projectionMatrix()
|
||||
) * viewTransform * modelTransform;
|
||||
|
||||
const std::vector<glm::dvec4>& corners = chunk.getBoundingPolyhedronCorners();
|
||||
|
||||
@@ -50,7 +51,9 @@ bool FrustumCuller::isCullable(const Chunk& chunk, const RenderData& data) {
|
||||
glm::dvec4 cornerClippingSpace = modelViewProjectionTransform * corners[i];
|
||||
clippingSpaceCorners[i] = cornerClippingSpace;
|
||||
|
||||
glm::dvec3 ndc = glm::dvec3((1.0f / glm::abs(cornerClippingSpace.w)) * cornerClippingSpace);
|
||||
glm::dvec3 ndc = glm::dvec3(
|
||||
(1.f / glm::abs(cornerClippingSpace.w)) * cornerClippingSpace
|
||||
);
|
||||
bounds.expand(ndc);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,9 @@ glm::dvec3 Ellipsoid::geodeticSurfaceProjection(const glm::dvec3& p) const {
|
||||
return p / d;
|
||||
}
|
||||
|
||||
glm::dvec3 Ellipsoid::geodeticSurfaceNormalForGeocentricallyProjectedPoint(const glm::dvec3& p) const {
|
||||
glm::dvec3 Ellipsoid::geodeticSurfaceNormalForGeocentricallyProjectedPoint(
|
||||
const glm::dvec3& p) const
|
||||
{
|
||||
glm::dvec3 normal = p * _cached._oneOverRadiiSquared;
|
||||
return glm::normalize(normal);
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ namespace openspace::globebrowsing {
|
||||
* This class is based largely on the Ellipsoid class defined in the book
|
||||
* "3D Engine Design for Virtual Globes". Most planets or planetary objects are better
|
||||
* described using ellipsoids than spheres. All inputs and outputs to this class is
|
||||
* based on the WGS84 standard coordinate system where the x-axis points towards geographic
|
||||
* (lat = 0, lon = 0), the y-axis points towards (lat = 0, lon = 90deg) and the
|
||||
* based on the WGS84 standard coordinate system where the x-axis points towards
|
||||
* geographic (lat = 0, lon = 0), the y-axis points towards (lat = 0, lon = 90deg) and the
|
||||
* z-axis points towards the north pole. For other globes than earth of course the radii
|
||||
* can differ.
|
||||
*/
|
||||
@@ -64,7 +64,8 @@ public:
|
||||
*/
|
||||
glm::dvec3 geodeticSurfaceProjection(const glm::dvec3& p) const;
|
||||
|
||||
glm::dvec3 geodeticSurfaceNormalForGeocentricallyProjectedPoint(const glm::dvec3& p) const;
|
||||
glm::dvec3 geodeticSurfaceNormalForGeocentricallyProjectedPoint(
|
||||
const glm::dvec3& p) const;
|
||||
glm::dvec3 geodeticSurfaceNormal(Geodetic2 geodetic2) const;
|
||||
|
||||
const glm::dvec3& radii() const;
|
||||
|
||||
@@ -48,9 +48,14 @@ GeodeticPatch::GeodeticPatch(const GeodeticPatch& patch)
|
||||
{}
|
||||
|
||||
GeodeticPatch::GeodeticPatch(const TileIndex& tileIndex) {
|
||||
double deltaLat = (2 * glm::pi<double>()) / (static_cast<double>(1 << tileIndex.level));
|
||||
double deltaLon = (2 * glm::pi<double>()) / (static_cast<double>(1 << tileIndex.level));
|
||||
Geodetic2 nwCorner(glm::pi<double>() / 2 - deltaLat * tileIndex.y, -glm::pi<double>() + deltaLon * tileIndex.x);
|
||||
double deltaLat = (2 * glm::pi<double>()) /
|
||||
(static_cast<double>(1 << tileIndex.level));
|
||||
double deltaLon = (2 * glm::pi<double>()) /
|
||||
(static_cast<double>(1 << tileIndex.level));
|
||||
Geodetic2 nwCorner(
|
||||
glm::pi<double>() / 2 - deltaLat * tileIndex.y,
|
||||
-glm::pi<double>() + deltaLon * tileIndex.x
|
||||
);
|
||||
_halfSize = Geodetic2(deltaLat / 2, deltaLon / 2);
|
||||
_center = Geodetic2(nwCorner.lat - _halfSize.lat, nwCorner.lon + _halfSize.lon);
|
||||
}
|
||||
@@ -224,14 +229,19 @@ Geodetic2 GeodeticPatch::closestPoint(const Geodetic2& p) const {
|
||||
Ang centerToPointLon = (centerLon - pointLon).normalizeAround(Ang::ZERO);
|
||||
|
||||
// Calculate the longitudinal distance to the closest patch edge
|
||||
Ang longitudeDistanceToClosestPatchEdge = centerToPointLon.abs() - Ang::fromRadians(_halfSize.lon);
|
||||
Ang longitudeDistanceToClosestPatchEdge =
|
||||
centerToPointLon.abs() - Ang::fromRadians(_halfSize.lon);
|
||||
|
||||
// If the longitude distance to the closest patch edge is larger than 90 deg
|
||||
// the latitude will have to be clamped to its closest corner, as explained in
|
||||
// the example above.
|
||||
double clampedLat = longitudeDistanceToClosestPatchEdge > Ang::QUARTER ?
|
||||
clampedLat = glm::clamp((Ang::HALF - pointLat).normalizeAround(centerLat).asRadians(), minLat(), maxLat()) :
|
||||
clampedLat = glm::clamp(pointLat.asRadians(), minLat(), maxLat());
|
||||
double clampedLat =
|
||||
longitudeDistanceToClosestPatchEdge > Ang::QUARTER ?
|
||||
glm::clamp(
|
||||
(Ang::HALF - pointLat).normalizeAround(centerLat).asRadians(),
|
||||
minLat(),
|
||||
maxLat()) :
|
||||
glm::clamp(pointLat.asRadians(), minLat(), maxLat());
|
||||
|
||||
// Longitude is just clamped normally
|
||||
double clampedLon = glm::clamp(pointLon.asRadians(), minLon(), maxLon());
|
||||
|
||||
@@ -66,8 +66,9 @@ namespace {
|
||||
openspace::GlobeBrowsingModule::Capabilities
|
||||
parseSubDatasets(char** subDatasets, int nSubdatasets)
|
||||
{
|
||||
// Idea: Iterate over the list of sublayers keeping a current layer and identify it
|
||||
// by its number. If this number changes, we know that we have a new layer
|
||||
// Idea: Iterate over the list of sublayers keeping a current layer and identify
|
||||
// it by its number. If this number changes, we know that we have a new
|
||||
// layer
|
||||
|
||||
using Layer = openspace::GlobeBrowsingModule::Layer;
|
||||
std::vector<Layer> result;
|
||||
@@ -104,7 +105,9 @@ namespace {
|
||||
currentLayer.url = value;
|
||||
}
|
||||
else {
|
||||
LINFOC("GlobeBrowsingGUI", "Unknown subdataset identifier: " + identifier);
|
||||
LINFOC(
|
||||
"GlobeBrowsingGUI", "Unknown subdataset identifier: " + identifier
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,18 +142,18 @@ void GlobeBrowsingModule::internalInitialize() {
|
||||
// Convert from MB to Bytes
|
||||
GdalWrapper::create(
|
||||
16ULL * 1024ULL * 1024ULL, // 16 MB
|
||||
static_cast<size_t>(CpuCap.installedMainMemory() * 0.25 * 1024 * 1024)); // 25% of total RAM
|
||||
static_cast<size_t>(CpuCap.installedMainMemory() * 0.25 * 1024 * 1024));// 25%
|
||||
addPropertySubOwner(GdalWrapper::ref());
|
||||
#endif // GLOBEBROWSING_USE_GDAL
|
||||
});
|
||||
|
||||
// Render
|
||||
OsEng.registerModuleCallback(OpenSpaceEngine::CallbackOption::Render, [&]{
|
||||
OsEng.registerModuleCallback(OpenSpaceEngine::CallbackOption::Render, [&] {
|
||||
_tileCache->update();
|
||||
});
|
||||
|
||||
// Deinitialize
|
||||
OsEng.registerModuleCallback(OpenSpaceEngine::CallbackOption::Deinitialize, [&]{
|
||||
OsEng.registerModuleCallback(OpenSpaceEngine::CallbackOption::Deinitialize, [&] {
|
||||
#ifdef GLOBEBROWSING_USE_GDAL
|
||||
GdalWrapper::ref().destroy();
|
||||
#endif // GLOBEBROWSING_USE_GDAL
|
||||
@@ -169,21 +172,35 @@ void GlobeBrowsingModule::internalInitialize() {
|
||||
|
||||
// Register TileProvider classes
|
||||
fTileProvider->registerClass<tileprovider::DefaultTileProvider>(
|
||||
layergroupid::LAYER_TYPE_NAMES[static_cast<int>(layergroupid::TypeID::DefaultTileLayer)]);
|
||||
layergroupid::LAYER_TYPE_NAMES[static_cast<int>(
|
||||
layergroupid::TypeID::DefaultTileLayer
|
||||
)]);
|
||||
fTileProvider->registerClass<tileprovider::SingleImageProvider>(
|
||||
layergroupid::LAYER_TYPE_NAMES[static_cast<int>(layergroupid::TypeID::SingleImageTileLayer)]);
|
||||
layergroupid::LAYER_TYPE_NAMES[static_cast<int>(
|
||||
layergroupid::TypeID::SingleImageTileLayer
|
||||
)]);
|
||||
#ifdef GLOBEBROWSING_USE_GDAL
|
||||
fTileProvider->registerClass<tileprovider::TemporalTileProvider>(
|
||||
layergroupid::LAYER_TYPE_NAMES[static_cast<int>(layergroupid::TypeID::TemporalTileLayer)]);
|
||||
layergroupid::LAYER_TYPE_NAMES[static_cast<int>(
|
||||
layergroupid::TypeID::TemporalTileLayer
|
||||
)]);
|
||||
#endif // GLOBEBROWSING_USE_GDAL
|
||||
fTileProvider->registerClass<tileprovider::TileIndexTileProvider>(
|
||||
layergroupid::LAYER_TYPE_NAMES[static_cast<int>(layergroupid::TypeID::TileIndexTileLayer)]);
|
||||
layergroupid::LAYER_TYPE_NAMES[static_cast<int>(
|
||||
layergroupid::TypeID::TileIndexTileLayer
|
||||
)]);
|
||||
fTileProvider->registerClass<tileprovider::SizeReferenceTileProvider>(
|
||||
layergroupid::LAYER_TYPE_NAMES[static_cast<int>(layergroupid::TypeID::SizeReferenceTileLayer)]);
|
||||
layergroupid::LAYER_TYPE_NAMES[static_cast<int>(
|
||||
layergroupid::TypeID::SizeReferenceTileLayer
|
||||
)]);
|
||||
fTileProvider->registerClass<tileprovider::TileProviderByLevel>(
|
||||
layergroupid::LAYER_TYPE_NAMES[static_cast<int>(layergroupid::TypeID::ByLevelTileLayer)]);
|
||||
layergroupid::LAYER_TYPE_NAMES[static_cast<int>(
|
||||
layergroupid::TypeID::ByLevelTileLayer
|
||||
)]);
|
||||
fTileProvider->registerClass<tileprovider::TileProviderByIndex>(
|
||||
layergroupid::LAYER_TYPE_NAMES[static_cast<int>(layergroupid::TypeID::ByIndexTileLayer)]);
|
||||
layergroupid::LAYER_TYPE_NAMES[static_cast<int>(
|
||||
layergroupid::TypeID::ByIndexTileLayer
|
||||
)]);
|
||||
|
||||
FactoryManager::ref().addFactory(std::move(fTileProvider));
|
||||
}
|
||||
@@ -381,7 +398,8 @@ void GlobeBrowsingModule::goToGeodetic3(Camera& camera, globebrowsing::Geodetic3
|
||||
|
||||
glm::dvec3 positionModelSpace = globe->ellipsoid().cartesianPosition(geo3);
|
||||
glm::dmat4 modelTransform = globe->modelTransform();
|
||||
glm::dvec3 positionWorldSpace = glm::dvec3(modelTransform * glm::dvec4(positionModelSpace, 1.0));
|
||||
glm::dvec3 positionWorldSpace = glm::dvec3(modelTransform *
|
||||
glm::dvec4(positionModelSpace, 1.0));
|
||||
camera.setPositionVec3(positionWorldSpace);
|
||||
|
||||
if (resetCameraDirection) {
|
||||
@@ -389,7 +407,8 @@ void GlobeBrowsingModule::goToGeodetic3(Camera& camera, globebrowsing::Geodetic3
|
||||
}
|
||||
}
|
||||
|
||||
void GlobeBrowsingModule::resetCameraDirection(Camera& camera, globebrowsing::Geodetic2 geo2)
|
||||
void GlobeBrowsingModule::resetCameraDirection(Camera& camera,
|
||||
globebrowsing::Geodetic2 geo2)
|
||||
{
|
||||
using namespace globebrowsing;
|
||||
|
||||
@@ -410,7 +429,8 @@ void GlobeBrowsingModule::resetCameraDirection(Camera& camera, globebrowsing::Ge
|
||||
glm::dvec3 lookUpWorldSpace = glm::dmat3(modelTransform) * lookUpModelSpace;
|
||||
|
||||
// Lookat vector
|
||||
glm::dvec3 lookAtWorldSpace = glm::dvec3(modelTransform * glm::dvec4(positionModelSpace, 1.0));
|
||||
glm::dvec3 lookAtWorldSpace = glm::dvec3(modelTransform *
|
||||
glm::dvec4(positionModelSpace, 1.0));
|
||||
|
||||
// Eye position
|
||||
glm::dvec3 eye = camera.positionVec3();
|
||||
@@ -459,10 +479,13 @@ std::string GlobeBrowsingModule::layerGroupNamesList() {
|
||||
std::string GlobeBrowsingModule::layerTypeNamesList() {
|
||||
std::string listLayerTypes;
|
||||
for (int i = 0; i < globebrowsing::layergroupid::NUM_LAYER_TYPES - 1; ++i) {
|
||||
listLayerTypes += std::string(globebrowsing::layergroupid::LAYER_TYPE_NAMES[i]) + ", ";
|
||||
listLayerTypes += std::string(globebrowsing::layergroupid::LAYER_TYPE_NAMES[i]) +
|
||||
", ";
|
||||
}
|
||||
listLayerTypes +=
|
||||
" and " + std::string(globebrowsing::layergroupid::LAYER_TYPE_NAMES[globebrowsing::layergroupid::NUM_LAYER_TYPES - 1]);
|
||||
listLayerTypes += " and " +
|
||||
std::string(globebrowsing::layergroupid::LAYER_TYPE_NAMES[
|
||||
globebrowsing::layergroupid::NUM_LAYER_TYPES - 1
|
||||
]);
|
||||
return listLayerTypes;
|
||||
}
|
||||
|
||||
@@ -489,7 +512,11 @@ void GlobeBrowsingModule::loadWMSCapabilities(std::string name, std::string glob
|
||||
return cap;
|
||||
};
|
||||
|
||||
_inFlightCapabilitiesMap[name] = std::async(std::launch::async, downloadFunction, url);
|
||||
_inFlightCapabilitiesMap[name] = std::async(
|
||||
std::launch::async,
|
||||
downloadFunction,
|
||||
url
|
||||
);
|
||||
|
||||
_urlList.emplace(std::move(globe), UrlInfo{ std::move(name), std::move(url) });
|
||||
}
|
||||
|
||||
@@ -182,9 +182,8 @@ int getGeoPosition(lua_State* L) {
|
||||
if (nArguments != 0) {
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
|
||||
}
|
||||
|
||||
RenderableGlobe* globe =
|
||||
OsEng.moduleEngine().module<GlobeBrowsingModule>()->castFocusNodeRenderableToGlobe();
|
||||
GlobeBrowsingModule* module = OsEng.moduleEngine().module<GlobeBrowsingModule>();
|
||||
RenderableGlobe* globe = module->castFocusNodeRenderableToGlobe();
|
||||
if (!globe) {
|
||||
return luaL_error(L, "Focus node must be a RenderableGlobe");
|
||||
}
|
||||
@@ -197,8 +196,11 @@ int getGeoPosition(lua_State* L) {
|
||||
SurfacePositionHandle posHandle = globe->calculateSurfacePositionHandle(
|
||||
cameraPositionModelSpace);
|
||||
|
||||
Geodetic2 geo2 = globe->ellipsoid().cartesianToGeodetic2(posHandle.centerToReferenceSurface);
|
||||
double altitude = glm::length(cameraPositionModelSpace - posHandle.centerToReferenceSurface);
|
||||
Geodetic2 geo2 = globe->ellipsoid().cartesianToGeodetic2(
|
||||
posHandle.centerToReferenceSurface
|
||||
);
|
||||
double altitude = glm::length(cameraPositionModelSpace -
|
||||
posHandle.centerToReferenceSurface);
|
||||
|
||||
lua_pushnumber(L, Angle<double>::fromRadians(geo2.lat).asDegrees());
|
||||
lua_pushnumber(L, Angle<double>::fromRadians(geo2.lon).asDegrees());
|
||||
|
||||
@@ -133,12 +133,13 @@ int ChunkedLodGlobe::getDesiredLevel(
|
||||
desiredLevel = _chunkEvaluatorByDistance->getDesiredLevel(chunk, renderData);
|
||||
}
|
||||
|
||||
int desiredLevelByAvailableData = _chunkEvaluatorByAvailableTiles->getDesiredLevel(
|
||||
int levelByAvailableData = _chunkEvaluatorByAvailableTiles->getDesiredLevel(
|
||||
chunk, renderData
|
||||
);
|
||||
if (desiredLevelByAvailableData != chunklevelevaluator::Evaluator::UnknownDesiredLevel &&
|
||||
_owner.debugProperties().limitLevelByAvailableData) {
|
||||
desiredLevel = glm::min(desiredLevel, desiredLevelByAvailableData);
|
||||
if (levelByAvailableData != chunklevelevaluator::Evaluator::UnknownDesiredLevel &&
|
||||
_owner.debugProperties().limitLevelByAvailableData)
|
||||
{
|
||||
desiredLevel = glm::min(desiredLevel, levelByAvailableData);
|
||||
}
|
||||
|
||||
desiredLevel = glm::clamp(desiredLevel, minSplitDepth, maxSplitDepth);
|
||||
@@ -291,7 +292,8 @@ void ChunkedLodGlobe::render(const RenderData& data, RendererTasks&) {
|
||||
|
||||
// Calculate the MVP matrix
|
||||
glm::dmat4 viewTransform = glm::dmat4(data.camera.combinedViewMatrix());
|
||||
glm::dmat4 vp = glm::dmat4(data.camera.sgctInternal.projectionMatrix()) * viewTransform;
|
||||
glm::dmat4 vp = glm::dmat4(data.camera.sgctInternal.projectionMatrix()) *
|
||||
viewTransform;
|
||||
glm::dmat4 mvp = vp * _owner.modelTransform();
|
||||
|
||||
// Render function
|
||||
@@ -315,8 +317,8 @@ void ChunkedLodGlobe::render(const RenderData& data, RendererTasks&) {
|
||||
//_rightRoot->reverseBreadthFirst(renderJob);
|
||||
|
||||
auto duration2 = std::chrono::system_clock::now().time_since_epoch();
|
||||
auto millis2 = std::chrono::duration_cast<std::chrono::milliseconds>(duration2).count();
|
||||
stats.i["chunk globe render time"] = millis2 - millis;
|
||||
auto ms2 = std::chrono::duration_cast<std::chrono::milliseconds>(duration2).count();
|
||||
stats.i["chunk globe render time"] = ms2 - millis;
|
||||
}
|
||||
|
||||
void ChunkedLodGlobe::debugRenderChunk(const Chunk& chunk, const glm::dmat4& mvp) const {
|
||||
|
||||
@@ -141,15 +141,16 @@ void PointGlobe::render(const RenderData& data, RendererTasks&) {
|
||||
glm::inverse(rotationTransform) *
|
||||
scaleTransform; // Scale
|
||||
glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform;
|
||||
//glm::vec3 directionToSun = glm::normalize(glm::vec3(0) - glm::vec3(bodyPosition));
|
||||
//glm::vec3 directionToSunViewSpace = glm::mat3(data.camera.combinedViewMatrix()) * directionToSun;
|
||||
|
||||
|
||||
_programObject->setUniform("lightIntensityClamped", lightIntensityClamped);
|
||||
//_programObject->setUniform("lightOverflow", lightOverflow);
|
||||
//_programObject->setUniform("directionToSunViewSpace", directionToSunViewSpace);
|
||||
_programObject->setUniform("modelViewTransform", glm::mat4(modelViewTransform));
|
||||
_programObject->setUniform("projectionTransform", data.camera.sgctInternal.projectionMatrix());
|
||||
_programObject->setUniform(
|
||||
"projectionTransform",
|
||||
data.camera.sgctInternal.projectionMatrix()
|
||||
);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
|
||||
|
||||
@@ -63,8 +63,8 @@ public:
|
||||
protected:
|
||||
/**
|
||||
* Should return the indices of vertices for a grid with size <code>xSegments</code>
|
||||
* <code>ySegments</code>. Where the number of vertices in each direction is the number
|
||||
* of segments + 1.
|
||||
* <code>ySegments</code>. Where the number of vertices in each direction is the
|
||||
* number of segments + 1.
|
||||
*/
|
||||
virtual std::vector<GLuint> createElements(int xSegments, int ySegments) = 0;
|
||||
|
||||
@@ -85,8 +85,8 @@ protected:
|
||||
|
||||
/**
|
||||
* Should return the normals of vertices for a grid with size <code>xSegments</code> *
|
||||
* <code>ySegments</code>. Where the number of vertices in each direction is the number
|
||||
* of segments + 1.
|
||||
* <code>ySegments</code>. Where the number of vertices in each direction is the
|
||||
* number of segments + 1.
|
||||
*/
|
||||
virtual std::vector<glm::vec3> createNormals(int xSegments, int ySegments) = 0;
|
||||
|
||||
|
||||
@@ -45,7 +45,9 @@ SkirtedGrid::SkirtedGrid(unsigned int xSegments, unsigned int ySegments,
|
||||
_geometry->setVertexPositions(createPositions(_xSegments, _ySegments));
|
||||
}
|
||||
if (useTextureCoordinates) {
|
||||
_geometry->setVertexTextureCoordinates(createTextureCoordinates(_xSegments, _ySegments));
|
||||
_geometry->setVertexTextureCoordinates(
|
||||
createTextureCoordinates(_xSegments, _ySegments)
|
||||
);
|
||||
}
|
||||
if (useNormals) {
|
||||
_geometry->setVertexNormals(createNormals(_xSegments, _ySegments));
|
||||
|
||||
@@ -52,7 +52,9 @@ void* PixelBuffer::mapBuffer(Access access) {
|
||||
return dataPtr;
|
||||
}
|
||||
|
||||
void* PixelBuffer::mapBufferRange(GLintptr offset, GLsizeiptr length, BufferAccessMask access) {
|
||||
void* PixelBuffer::mapBufferRange(GLintptr offset, GLsizeiptr length,
|
||||
BufferAccessMask access)
|
||||
{
|
||||
void* dataPtr = glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, offset, length, access);
|
||||
_isMapped = dataPtr ? true : false;
|
||||
return dataPtr;
|
||||
|
||||
@@ -92,8 +92,8 @@ public:
|
||||
bool unMapBuffer(KeyType key);
|
||||
|
||||
/**
|
||||
* \returns the <code>GLuint</code> id of a pixel buffer identified by <code>key</code>
|
||||
* if it currently is mapped.
|
||||
* \returns the <code>GLuint</code> id of a pixel buffer identified by
|
||||
* <code>key</code> if it currently is mapped.
|
||||
*/
|
||||
GLuint idOfMappedBuffer(KeyType key);
|
||||
private:
|
||||
|
||||
@@ -307,7 +307,10 @@ void ChunkRenderer::renderChunkLocally(const Chunk& chunk, const RenderData& dat
|
||||
cornersCameraSpace[Quad::SOUTH_WEST]));
|
||||
|
||||
programObject->setUniform("patchNormalCameraSpace", patchNormalCameraSpace);
|
||||
programObject->setUniform("projectionTransform", data.camera.sgctInternal.projectionMatrix());
|
||||
programObject->setUniform(
|
||||
"projectionTransform",
|
||||
data.camera.sgctInternal.projectionMatrix()
|
||||
);
|
||||
|
||||
if (_layerManager->layerGroup(layergroupid::HeightLayers).activeLayers().size() > 0) {
|
||||
// Apply an extra scaling to the height if the object is scaled
|
||||
|
||||
@@ -46,7 +46,10 @@ void GPULayer::setValue(ghoul::opengl::ProgramObject* programObject, const Layer
|
||||
ChunkTilePile chunkTilePile = layer.getChunkTilePile(tileIndex, pileSize);
|
||||
gpuChunkTilePile.setValue(programObject, chunkTilePile);
|
||||
paddingStartOffset.setValue(programObject, layer.tilePixelStartOffset());
|
||||
paddingSizeDifference.setValue(programObject, layer.tilePixelSizeDifference());
|
||||
paddingSizeDifference.setValue(
|
||||
programObject,
|
||||
layer.tilePixelSizeDifference()
|
||||
);
|
||||
break;
|
||||
}
|
||||
case layergroupid::TypeID::SolidColor:
|
||||
@@ -60,8 +63,16 @@ void GPULayer::setValue(ghoul::opengl::ProgramObject* programObject, const Layer
|
||||
void GPULayer::bind(ghoul::opengl::ProgramObject* programObject, const Layer& layer,
|
||||
const std::string& nameBase, int pileSize)
|
||||
{
|
||||
gpuRenderSettings.bind(layer.renderSettings(), programObject, nameBase + "settings.");
|
||||
gpuLayerAdjustment.bind(layer.layerAdjustment(), programObject, nameBase + "adjustment.");
|
||||
gpuRenderSettings.bind(
|
||||
layer.renderSettings(),
|
||||
programObject,
|
||||
nameBase + "settings."
|
||||
);
|
||||
gpuLayerAdjustment.bind(
|
||||
layer.layerAdjustment(),
|
||||
programObject,
|
||||
nameBase + "adjustment."
|
||||
);
|
||||
|
||||
switch (layer.type()) {
|
||||
// Intentional fall through. Same for all tile layers
|
||||
@@ -74,7 +85,10 @@ void GPULayer::bind(ghoul::opengl::ProgramObject* programObject, const Layer& la
|
||||
case layergroupid::TypeID::ByLevelTileLayer: {
|
||||
gpuChunkTilePile.bind(programObject, nameBase + "pile.", pileSize);
|
||||
paddingStartOffset.bind(programObject, nameBase + "padding.startOffset");
|
||||
paddingSizeDifference.bind(programObject, nameBase + "padding.sizeDifference");
|
||||
paddingSizeDifference.bind(
|
||||
programObject,
|
||||
nameBase + "padding.sizeDifference"
|
||||
);
|
||||
break;
|
||||
}
|
||||
case layergroupid::TypeID::SolidColor:
|
||||
|
||||
@@ -34,8 +34,14 @@ void GPULayerAdjustment::setValue(ghoul::opengl::ProgramObject* programObject,
|
||||
case layergroupid::AdjustmentTypeID::None:
|
||||
break;
|
||||
case layergroupid::AdjustmentTypeID::ChromaKey: {
|
||||
gpuChromaKeyColor.setValue(programObject, layerAdjustment.chromaKeyColor.value());
|
||||
gpuChromaKeyTolerance.setValue(programObject, layerAdjustment.chromaKeyTolerance.value());
|
||||
gpuChromaKeyColor.setValue(
|
||||
programObject,
|
||||
layerAdjustment.chromaKeyColor.value()
|
||||
);
|
||||
gpuChromaKeyTolerance.setValue(
|
||||
programObject,
|
||||
layerAdjustment.chromaKeyTolerance.value()
|
||||
);
|
||||
break;
|
||||
}
|
||||
case layergroupid::AdjustmentTypeID::TransferFunction:
|
||||
|
||||
@@ -53,7 +53,8 @@ public:
|
||||
* with nameBase within the provided shader program.
|
||||
* After this method has been called, users may invoke setValue.
|
||||
*/
|
||||
void bind(const LayerRenderSettings& layerSettings, ghoul::opengl::ProgramObject* programObject, const std::string& nameBase);
|
||||
void bind(const LayerRenderSettings& layerSettings,
|
||||
ghoul::opengl::ProgramObject* programObject, const std::string& nameBase);
|
||||
|
||||
private:
|
||||
GPUData<float> gpuOpacity;
|
||||
|
||||
@@ -91,7 +91,9 @@ Layer::Layer(layergroupid::GroupID id, const ghoul::Dictionary& layerDict,
|
||||
LayerGroup& parent)
|
||||
: properties::PropertyOwner({
|
||||
layerDict.value<std::string>(keyName),
|
||||
layerDict.hasKey(keyDescription) ? layerDict.value<std::string>(keyDescription) : ""
|
||||
layerDict.hasKey(keyDescription) ?
|
||||
layerDict.value<std::string>(keyDescription) :
|
||||
""
|
||||
})
|
||||
, _parent(parent)
|
||||
, _typeOption(TypeInfo, properties::OptionProperty::DisplayType::Dropdown)
|
||||
@@ -315,7 +317,8 @@ glm::ivec2 Layer::tilePixelSizeDifference() const {
|
||||
return _padTilePixelSizeDifference;
|
||||
}
|
||||
|
||||
glm::vec2 Layer::compensateSourceTextureSampling(glm::vec2 startOffset, glm::vec2 sizeDiff,
|
||||
glm::vec2 Layer::compensateSourceTextureSampling(glm::vec2 startOffset,
|
||||
glm::vec2 sizeDiff,
|
||||
glm::uvec2 resolution, glm::vec2 tileUV)
|
||||
{
|
||||
glm::vec2 sourceSize = glm::vec2(resolution) + sizeDiff;
|
||||
@@ -349,7 +352,8 @@ layergroupid::TypeID Layer::parseTypeIdFromDictionary(
|
||||
}
|
||||
}
|
||||
|
||||
void Layer::initializeBasedOnType(layergroupid::TypeID typeId, ghoul::Dictionary initDict) {
|
||||
void Layer::initializeBasedOnType(layergroupid::TypeID typeId, ghoul::Dictionary initDict)
|
||||
{
|
||||
switch (typeId) {
|
||||
// Intentional fall through. Same for all tile layers
|
||||
case layergroupid::TypeID::DefaultTileLayer:
|
||||
@@ -369,7 +373,10 @@ void Layer::initializeBasedOnType(layergroupid::TypeID typeId, ghoul::Dictionary
|
||||
LDEBUG("Initializing tile provider for layer: '" + name + "'");
|
||||
}
|
||||
_tileProvider = std::shared_ptr<tileprovider::TileProvider>(
|
||||
tileprovider::TileProvider::createFromDictionary(typeId, tileProviderInitDict)
|
||||
tileprovider::TileProvider::createFromDictionary(
|
||||
typeId,
|
||||
tileProviderInitDict
|
||||
)
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,8 @@ public:
|
||||
properties::Vec3Property color;
|
||||
};
|
||||
|
||||
Layer(layergroupid::GroupID id, const ghoul::Dictionary& layerDict, LayerGroup& parent);
|
||||
Layer(layergroupid::GroupID id, const ghoul::Dictionary& layerDict,
|
||||
LayerGroup& parent);
|
||||
|
||||
void initialize();
|
||||
void deinitialize();
|
||||
@@ -77,12 +78,14 @@ public:
|
||||
glm::ivec2 tilePixelStartOffset() const;
|
||||
glm::ivec2 tilePixelSizeDifference() const;
|
||||
glm::vec2 compensateSourceTextureSampling(glm::vec2 startOffset, glm::vec2 sizeDiff,
|
||||
glm::uvec2 resolution, glm::vec2 tileUV);
|
||||
glm::uvec2 resolution, glm::vec2 tileUV);
|
||||
glm::vec2 TileUvToTextureSamplePosition(const TileUvTransform& uvTransform,
|
||||
glm::vec2 tileUV, glm::uvec2 resolution);
|
||||
glm::vec2 tileUV, glm::uvec2 resolution);
|
||||
|
||||
private:
|
||||
layergroupid::TypeID parseTypeIdFromDictionary(const ghoul::Dictionary& initDict) const;
|
||||
layergroupid::TypeID parseTypeIdFromDictionary(
|
||||
const ghoul::Dictionary& initDict) const;
|
||||
|
||||
void initializeBasedOnType(layergroupid::TypeID typeId, ghoul::Dictionary initDict);
|
||||
void addVisibleProperties();
|
||||
void removeVisibleProperties();
|
||||
|
||||
@@ -127,7 +127,10 @@ std::shared_ptr<Layer> LayerGroup::addLayer(const ghoul::Dictionary& layerDict)
|
||||
}
|
||||
|
||||
void LayerGroup::deleteLayer(const std::string& layerName) {
|
||||
for (std::vector<std::shared_ptr<Layer>>::iterator it = _layers.begin(); it != _layers.end(); ++it) {
|
||||
for (std::vector<std::shared_ptr<Layer>>::iterator it = _layers.begin();
|
||||
it != _layers.end();
|
||||
++it)
|
||||
{
|
||||
if (it->get()->name() == layerName) {
|
||||
removePropertySubOwner(it->get());
|
||||
(*it)->deinitialize();
|
||||
|
||||
@@ -37,13 +37,15 @@
|
||||
|
||||
namespace openspace::globebrowsing {
|
||||
|
||||
bool LayerShaderManager::LayerShaderPreprocessingData::LayerGroupPreprocessingData::operator==(
|
||||
const LayerGroupPreprocessingData& other) const {
|
||||
bool
|
||||
LayerShaderManager::LayerShaderPreprocessingData::LayerGroupPreprocessingData::operator==(
|
||||
const LayerGroupPreprocessingData& other) const
|
||||
{
|
||||
return layerType == other.layerType &&
|
||||
blendMode == other.blendMode &&
|
||||
layerAdjustmentType == other.layerAdjustmentType &&
|
||||
lastLayerIdx == other.lastLayerIdx &&
|
||||
layerBlendingEnabled == other.layerBlendingEnabled;
|
||||
blendMode == other.blendMode &&
|
||||
layerAdjustmentType == other.layerAdjustmentType &&
|
||||
lastLayerIdx == other.lastLayerIdx &&
|
||||
layerBlendingEnabled == other.layerBlendingEnabled;
|
||||
}
|
||||
|
||||
bool LayerShaderManager::LayerShaderPreprocessingData::operator==(
|
||||
@@ -92,7 +94,9 @@ LayerShaderManager::LayerShaderPreprocessingData
|
||||
for (const std::shared_ptr<Layer>& layer : layers) {
|
||||
layeredTextureInfo.layerType.push_back(layer->type());
|
||||
layeredTextureInfo.blendMode.push_back(layer->blendMode());
|
||||
layeredTextureInfo.layerAdjustmentType.push_back(layer->layerAdjustment().type());
|
||||
layeredTextureInfo.layerAdjustmentType.push_back(
|
||||
layer->layerAdjustment().type()
|
||||
);
|
||||
}
|
||||
|
||||
preprocessingData.layeredTextureInfo[i] = layeredTextureInfo;
|
||||
@@ -173,7 +177,10 @@ void LayerShaderManager::recompileShaderProgram(
|
||||
|
||||
for (int j = 0; j < textureTypes[i].lastLayerIdx + 1; ++j) {
|
||||
std::string key = groupName + std::to_string(j) + "LayerType";
|
||||
shaderDictionary.setValue(key, static_cast<int>(textureTypes[i].layerType[j]));
|
||||
shaderDictionary.setValue(
|
||||
key,
|
||||
static_cast<int>(textureTypes[i].layerType[j])
|
||||
);
|
||||
}
|
||||
|
||||
// This is to avoid errors from shader preprocessor
|
||||
@@ -182,7 +189,10 @@ void LayerShaderManager::recompileShaderProgram(
|
||||
|
||||
for (int j = 0; j < textureTypes[i].lastLayerIdx + 1; ++j) {
|
||||
std::string key = groupName + std::to_string(j) + "BlendMode";
|
||||
shaderDictionary.setValue(key, static_cast<int>(textureTypes[i].blendMode[j]));
|
||||
shaderDictionary.setValue(
|
||||
key,
|
||||
static_cast<int>(textureTypes[i].blendMode[j])
|
||||
);
|
||||
}
|
||||
|
||||
// This is to avoid errors from shader preprocessor
|
||||
@@ -191,7 +201,10 @@ void LayerShaderManager::recompileShaderProgram(
|
||||
|
||||
for (int j = 0; j < textureTypes[i].lastLayerIdx + 1; ++j) {
|
||||
std::string key = groupName + std::to_string(j) + "LayerAdjustmentType";
|
||||
shaderDictionary.setValue(key, static_cast<int>(textureTypes[i].layerAdjustmentType[j]));
|
||||
shaderDictionary.setValue(
|
||||
key,
|
||||
static_cast<int>(textureTypes[i].layerAdjustmentType[j])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,8 +130,10 @@ void GdalRawTileDataReader::initialize() {
|
||||
_gdalDatasetMetaDataCached.offset = _dataset->GetRasterBand(1)->GetOffset();
|
||||
_gdalDatasetMetaDataCached.rasterXSize = _dataset->GetRasterXSize();
|
||||
_gdalDatasetMetaDataCached.rasterYSize = _dataset->GetRasterYSize();
|
||||
_gdalDatasetMetaDataCached.noDataValue = _dataset->GetRasterBand(1)->GetNoDataValue();
|
||||
_gdalDatasetMetaDataCached.dataType = tiledatatype::getGdalDataType(_initData.glType());
|
||||
_gdalDatasetMetaDataCached.noDataValue =
|
||||
_dataset->GetRasterBand(1)->GetNoDataValue();
|
||||
_gdalDatasetMetaDataCached.dataType =
|
||||
tiledatatype::getGdalDataType(_initData.glType());
|
||||
|
||||
CPLErr err = _dataset->GetGeoTransform(&_gdalDatasetMetaDataCached.padfTransform[0]);
|
||||
if (err == CE_Failure) {
|
||||
|
||||
@@ -131,11 +131,13 @@ void RawTileDataReader::readImageData(IODescription& io, RawTile::ReadError& wor
|
||||
for (int i = 0; i < 3; i++) {
|
||||
// The final destination pointer is offsetted by one datum byte size
|
||||
// for every raster (or data channel, i.e. R in RGB)
|
||||
char* dataDestination = imageDataDest + (i * _initData.bytesPerDatum());
|
||||
char* dataDestination = imageDataDest +
|
||||
(i * _initData.bytesPerDatum());
|
||||
|
||||
RawTile::ReadError err = repeatedRasterRead(1, io, dataDestination);
|
||||
|
||||
// CE_None = 0, CE_Debug = 1, CE_Warning = 2, CE_Failure = 3, CE_Fatal = 4
|
||||
// CE_None = 0, CE_Debug = 1, CE_Warning = 2,
|
||||
// CE_Failure = 3, CE_Fatal = 4
|
||||
worstError = std::max(worstError, err);
|
||||
}
|
||||
}
|
||||
@@ -143,11 +145,13 @@ void RawTileDataReader::readImageData(IODescription& io, RawTile::ReadError& wor
|
||||
for (int i = 0; i < 3; i++) {
|
||||
// The final destination pointer is offsetted by one datum byte size
|
||||
// for every raster (or data channel, i.e. R in RGB)
|
||||
char* dataDestination = imageDataDest + (i * _initData.bytesPerDatum());
|
||||
char* dataDestination = imageDataDest +
|
||||
(i * _initData.bytesPerDatum());
|
||||
|
||||
RawTile::ReadError err = repeatedRasterRead(1, io, dataDestination);
|
||||
|
||||
// CE_None = 0, CE_Debug = 1, CE_Warning = 2, CE_Failure = 3, CE_Fatal = 4
|
||||
// CE_None = 0, CE_Debug = 1, CE_Warning = 2,
|
||||
// CE_Failure = 3, CE_Fatal = 4
|
||||
worstError = std::max(worstError, err);
|
||||
}
|
||||
// Last read is the alpha channel
|
||||
@@ -161,11 +165,17 @@ void RawTileDataReader::readImageData(IODescription& io, RawTile::ReadError& wor
|
||||
for (int i = 0; i < nRastersToRead; i++) {
|
||||
// The final destination pointer is offsetted by one datum byte size
|
||||
// for every raster (or data channel, i.e. R in RGB)
|
||||
char* dataDestination = imageDataDest + (i * _initData.bytesPerDatum());
|
||||
char* dataDestination = imageDataDest +
|
||||
(i * _initData.bytesPerDatum());
|
||||
|
||||
RawTile::ReadError err = repeatedRasterRead(i + 1, io, dataDestination);
|
||||
RawTile::ReadError err = repeatedRasterRead(
|
||||
i + 1,
|
||||
io,
|
||||
dataDestination
|
||||
);
|
||||
|
||||
// CE_None = 0, CE_Debug = 1, CE_Warning = 2, CE_Failure = 3, CE_Fatal = 4
|
||||
// CE_None = 0, CE_Debug = 1, CE_Warning = 2,
|
||||
// CE_Failure = 3, CE_Fatal = 4
|
||||
worstError = std::max(worstError, err);
|
||||
}
|
||||
}
|
||||
@@ -177,11 +187,13 @@ void RawTileDataReader::readImageData(IODescription& io, RawTile::ReadError& wor
|
||||
for (int i = 0; i < 3; i++) {
|
||||
// The final destination pointer is offsetted by one datum byte size
|
||||
// for every raster (or data channel, i.e. R in RGB)
|
||||
char* dataDestination = imageDataDest + (i * _initData.bytesPerDatum());
|
||||
char* dataDestination = imageDataDest +
|
||||
(i * _initData.bytesPerDatum());
|
||||
|
||||
RawTile::ReadError err = repeatedRasterRead(1, io, dataDestination);
|
||||
|
||||
// CE_None = 0, CE_Debug = 1, CE_Warning = 2, CE_Failure = 3, CE_Fatal = 4
|
||||
// CE_None = 0, CE_Debug = 1, CE_Warning = 2,
|
||||
// CE_Failure = 3, CE_Fatal = 4
|
||||
worstError = std::max(worstError, err);
|
||||
}
|
||||
}
|
||||
@@ -189,29 +201,38 @@ void RawTileDataReader::readImageData(IODescription& io, RawTile::ReadError& wor
|
||||
for (int i = 0; i < 3; i++) {
|
||||
// The final destination pointer is offsetted by one datum byte size
|
||||
// for every raster (or data channel, i.e. R in RGB)
|
||||
char* dataDestination = imageDataDest + (i * _initData.bytesPerDatum());
|
||||
char* dataDestination = imageDataDest +
|
||||
(i * _initData.bytesPerDatum());
|
||||
|
||||
RawTile::ReadError err = repeatedRasterRead(1, io, dataDestination);
|
||||
|
||||
// CE_None = 0, CE_Debug = 1, CE_Warning = 2, CE_Failure = 3, CE_Fatal = 4
|
||||
// CE_None = 0, CE_Debug = 1, CE_Warning = 2,
|
||||
// CE_Failure = 3, CE_Fatal = 4
|
||||
worstError = std::max(worstError, err);
|
||||
}
|
||||
// Last read is the alpha channel
|
||||
char* dataDestination = imageDataDest + (3 * _initData.bytesPerDatum());
|
||||
RawTile::ReadError err = repeatedRasterRead(2, io, dataDestination);
|
||||
|
||||
// CE_None = 0, CE_Debug = 1, CE_Warning = 2, CE_Failure = 3, CE_Fatal = 4
|
||||
// CE_None = 0, CE_Debug = 1, CE_Warning = 2,
|
||||
// CE_Failure = 3, CE_Fatal = 4
|
||||
worstError = std::max(worstError, err);
|
||||
}
|
||||
else { // Three or more rasters
|
||||
for (int i = 0; i < 3 && i < nRastersToRead; i++) {
|
||||
// The final destination pointer is offsetted by one datum byte size
|
||||
// for every raster (or data channel, i.e. R in RGB)
|
||||
char* dataDestination = imageDataDest + (i * _initData.bytesPerDatum());
|
||||
char* dataDestination = imageDataDest +
|
||||
(i * _initData.bytesPerDatum());
|
||||
|
||||
RawTile::ReadError err = repeatedRasterRead(3 - i, io, dataDestination);
|
||||
RawTile::ReadError err = repeatedRasterRead(
|
||||
3 - i,
|
||||
io,
|
||||
dataDestination
|
||||
);
|
||||
|
||||
// CE_None = 0, CE_Debug = 1, CE_Warning = 2, CE_Failure = 3, CE_Fatal = 4
|
||||
// CE_None = 0, CE_Debug = 1, CE_Warning = 2,
|
||||
// CE_Failure = 3, CE_Fatal = 4
|
||||
worstError = std::max(worstError, err);
|
||||
}
|
||||
}
|
||||
@@ -337,7 +358,8 @@ PixelRegion::PixelCoordinate RawTileDataReader::geodeticToPixel(
|
||||
//ghoul_assert(a[2] != 0.0, "a2 must not be zero!");
|
||||
double P = (a[0] * b[2] - a[2] * b[0] + a[2] * Y - b[2] * X) / divisor;
|
||||
double L = (-a[0] * b[1] + a[1] * b[0] - a[1] * Y + b[1] * X) / divisor;
|
||||
// ref: https://www.wolframalpha.com/input/?i=X+%3D+a0+%2B+a1P+%2B+a2L,+Y+%3D+b0+%2B+b1P+%2B+b2L,+solve+for+P+and+L
|
||||
// ref: https://www.wolframalpha.com/input/?i=X+%3D+a0+%2B+a1P+%2B+a2L,
|
||||
// +Y+%3D+b0+%2B+b1P+%2B+b2L,+solve+for+P+and+L
|
||||
|
||||
double Xp = a[0] + P*a[1] + L*a[2];
|
||||
double Yp = b[0] + P*b[1] + L*b[2];
|
||||
@@ -358,7 +380,9 @@ Geodetic2 RawTileDataReader::pixelToGeodetic(
|
||||
return geodetic;
|
||||
}
|
||||
|
||||
PixelRegion RawTileDataReader::highestResPixelRegion(const GeodeticPatch& geodeticPatch) const {
|
||||
PixelRegion RawTileDataReader::highestResPixelRegion(
|
||||
const GeodeticPatch& geodeticPatch) const
|
||||
{
|
||||
Geodetic2 nwCorner = geodeticPatch.getCorner(Quad::NORTH_WEST);
|
||||
Geodetic2 swCorner = geodeticPatch.getCorner(Quad::SOUTH_EAST);
|
||||
PixelRegion::PixelCoordinate pixelStart = geodeticToPixel(nwCorner);
|
||||
@@ -374,7 +398,7 @@ RawTile::ReadError RawTileDataReader::repeatedRasterRead(
|
||||
RawTile::ReadError worstError = RawTile::ReadError::None;
|
||||
|
||||
// NOTE:
|
||||
// Ascii graphics illustrates the implementation details of this method, for one
|
||||
// Ascii graphics illustrates the implementation details of this method, for one
|
||||
// specific case. Even though the illustrated case is specific, readers can
|
||||
// hopefully find it useful to get the general idea.
|
||||
|
||||
@@ -428,7 +452,9 @@ RawTile::ReadError RawTileDataReader::repeatedRasterRead(
|
||||
|
||||
if (cutoff.read.region.area() > 0) {
|
||||
// Wrap by repeating
|
||||
PixelRegion::Side oppositeSide = static_cast<PixelRegion::Side>((i + 2) % 4);
|
||||
PixelRegion::Side oppositeSide = static_cast<PixelRegion::Side>(
|
||||
(i + 2) % 4
|
||||
);
|
||||
|
||||
cutoff.read.region.align(
|
||||
oppositeSide, io.read.fullRegion.edge(oppositeSide));
|
||||
@@ -516,7 +542,9 @@ std::shared_ptr<TileMetaData> RawTileDataReader::getTileMetaData(
|
||||
}
|
||||
else {
|
||||
preprocessData->hasMissingData[raster] = true;
|
||||
float& floatToRewrite = reinterpret_cast<float&>(rawTile->imageData[yi + i]);
|
||||
float& floatToRewrite = reinterpret_cast<float&>(
|
||||
rawTile->imageData[yi + i]
|
||||
);
|
||||
floatToRewrite = -FLT_MAX;
|
||||
}
|
||||
i += _initData.bytesPerDatum();
|
||||
@@ -541,7 +569,9 @@ float RawTileDataReader::depthScale() const {
|
||||
|
||||
TileDepthTransform RawTileDataReader::calculateTileDepthTransform() {
|
||||
bool isFloat =
|
||||
(_initData.glType() == GL_HALF_FLOAT || _initData.glType() == GL_FLOAT || _initData.glType() == GL_DOUBLE);
|
||||
(_initData.glType() == GL_HALF_FLOAT ||
|
||||
_initData.glType() == GL_FLOAT ||
|
||||
_initData.glType() == GL_DOUBLE);
|
||||
double maximumValue =
|
||||
isFloat ? 1.0 : tiledatatype::getMaximumValue(_initData.glType());
|
||||
|
||||
|
||||
@@ -155,7 +155,8 @@ protected:
|
||||
std::shared_ptr<TileMetaData> getTileMetaData(
|
||||
std::shared_ptr<RawTile> result, const PixelRegion& region) const;
|
||||
TileDepthTransform calculateTileDepthTransform();
|
||||
RawTile::ReadError postProcessErrorCheck(std::shared_ptr<const RawTile> ioResult) const;
|
||||
RawTile::ReadError postProcessErrorCheck(
|
||||
std::shared_ptr<const RawTile> ioResult) const;
|
||||
|
||||
struct Cached {
|
||||
int _maxLevel = -1;
|
||||
|
||||
@@ -187,7 +187,8 @@ RawTile::ReadError SimpleRawTileDataReader::rasterRead(
|
||||
return RawTile::ReadError::None;
|
||||
}
|
||||
|
||||
IODescription SimpleRawTileDataReader::adjustIODescription(const IODescription& io) const {
|
||||
IODescription SimpleRawTileDataReader::adjustIODescription(const IODescription& io) const
|
||||
{
|
||||
// Modify to match OpenGL texture layout
|
||||
IODescription modifiedIO = io;
|
||||
modifiedIO.read.region.start.y =
|
||||
|
||||
@@ -126,8 +126,8 @@ DefaultTileProvider::DefaultTileProvider(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_tilePixelSize);
|
||||
}
|
||||
|
||||
DefaultTileProvider::DefaultTileProvider(std::shared_ptr<AsyncTileDataProvider> tileReader)
|
||||
: _asyncTextureDataProvider(tileReader)
|
||||
DefaultTileProvider::DefaultTileProvider(std::shared_ptr<AsyncTileDataProvider> tr)
|
||||
: _asyncTextureDataProvider(tr)
|
||||
, _filePath(FilePathInfo, "")
|
||||
, _tilePixelSize(TilePixelSizeInfo, 32, 32, 2048)
|
||||
{}
|
||||
@@ -140,10 +140,11 @@ void DefaultTileProvider::update() {
|
||||
initTexturesFromLoadedData();
|
||||
if (_asyncTextureDataProvider->shouldBeDeleted()) {
|
||||
_asyncTextureDataProvider = nullptr;
|
||||
TileTextureInitData initData(
|
||||
LayerManager::getTileTextureInitData(_layerGroupID, _padTiles,
|
||||
_tilePixelSize)
|
||||
);
|
||||
TileTextureInitData initData(LayerManager::getTileTextureInitData(
|
||||
_layerGroupID,
|
||||
_padTiles,
|
||||
_tilePixelSize
|
||||
));
|
||||
initAsyncTileDataReader(initData);
|
||||
}
|
||||
}
|
||||
@@ -155,10 +156,11 @@ void DefaultTileProvider::reset() {
|
||||
_asyncTextureDataProvider->prepairToBeDeleted();
|
||||
}
|
||||
else {
|
||||
TileTextureInitData initData(
|
||||
LayerManager::getTileTextureInitData(_layerGroupID, _padTiles,
|
||||
_tilePixelSize)
|
||||
);
|
||||
TileTextureInitData initData(LayerManager::getTileTextureInitData(
|
||||
_layerGroupID,
|
||||
_padTiles,
|
||||
_tilePixelSize
|
||||
));
|
||||
initAsyncTileDataReader(initData);
|
||||
}
|
||||
}
|
||||
@@ -206,7 +208,8 @@ float DefaultTileProvider::noDataValueAsFloat() {
|
||||
|
||||
void DefaultTileProvider::initTexturesFromLoadedData() {
|
||||
if (_asyncTextureDataProvider) {
|
||||
std::shared_ptr<RawTile> rawTile = _asyncTextureDataProvider->popFinishedRawTile();
|
||||
std::shared_ptr<RawTile> rawTile =
|
||||
_asyncTextureDataProvider->popFinishedRawTile();
|
||||
if (rawTile) {
|
||||
cache::ProviderTileKey key = { rawTile->tileIndex, uniqueIdentifier() };
|
||||
ghoul_assert(!_tileCache->exist(key), "Tile must not be existing in cache");
|
||||
@@ -224,14 +227,24 @@ void DefaultTileProvider::initAsyncTileDataReader(TileTextureInitData initData)
|
||||
|
||||
// Initialize instance variables
|
||||
#ifdef GLOBEBROWSING_USE_GDAL
|
||||
auto tileDataset = std::make_shared<GdalRawTileDataReader>(_filePath, initData,
|
||||
_basePath, preprocess);
|
||||
auto tileDataset = std::make_shared<GdalRawTileDataReader>(
|
||||
_filePath,
|
||||
initData,
|
||||
_basePath,
|
||||
preprocess
|
||||
);
|
||||
#else // GLOBEBROWSING_USE_GDAL
|
||||
auto tileDataset = std::make_shared<SimpleRawTileDataReader>(_filePath, initData,
|
||||
preprocess);
|
||||
auto tileDataset = std::make_shared<SimpleRawTileDataReader>(
|
||||
_filePath,
|
||||
initData,
|
||||
preprocess
|
||||
);
|
||||
#endif // GLOBEBROWSING_USE_GDAL
|
||||
|
||||
_asyncTextureDataProvider = std::make_shared<AsyncTileDataProvider>(_name, tileDataset);
|
||||
_asyncTextureDataProvider = std::make_shared<AsyncTileDataProvider>(
|
||||
_name,
|
||||
tileDataset
|
||||
);
|
||||
|
||||
// Tiles are only available for levels 2 and higher.
|
||||
if (_preCacheLevel >= 2) {
|
||||
|
||||
@@ -106,7 +106,8 @@ int SizeReferenceTileProvider::roundedLongitudalLength(const TileIndex& tileInde
|
||||
return l;
|
||||
}
|
||||
|
||||
TileIndex::TileHashKey SizeReferenceTileProvider::toHash(const TileIndex& tileIndex) const {
|
||||
TileIndex::TileHashKey SizeReferenceTileProvider::toHash(const TileIndex& tileIndex) const
|
||||
{
|
||||
int l = roundedLongitudalLength(tileIndex);
|
||||
TileIndex::TileHashKey key = static_cast<TileIndex::TileHashKey>(l);
|
||||
return key;
|
||||
|
||||
@@ -79,7 +79,9 @@ TemporalTileProvider::TemporalTileProvider(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_filePath);
|
||||
|
||||
if (readFilePath()) {
|
||||
const bool hasStart = dictionary.hasKeyAndValue<std::string>(KeyPreCacheStartTime);
|
||||
const bool hasStart = dictionary.hasKeyAndValue<std::string>(
|
||||
KeyPreCacheStartTime
|
||||
);
|
||||
const bool hasEnd = dictionary.hasKeyAndValue<std::string>(KeyPreCacheEndTime);
|
||||
if (hasStart && hasEnd) {
|
||||
const std::string start = dictionary.value<std::string>(KeyPreCacheStartTime);
|
||||
@@ -276,7 +278,8 @@ void TemporalTileProvider::update() {
|
||||
|
||||
void TemporalTileProvider::reset() {
|
||||
if (_successfulInitialization) {
|
||||
for (std::pair<const TimeKey, std::shared_ptr<TileProvider>>& it : _tileProviderMap) {
|
||||
using T = std::pair<const TimeKey, std::shared_ptr<TileProvider>>;
|
||||
for (T& it : _tileProviderMap) {
|
||||
it.second->reset();
|
||||
}
|
||||
}
|
||||
@@ -299,7 +302,7 @@ std::shared_ptr<TileProvider> TemporalTileProvider::getTileProvider(const Time&
|
||||
std::shared_ptr<TileProvider> TemporalTileProvider::getTileProvider(
|
||||
const TimeKey& timekey)
|
||||
{
|
||||
std::unordered_map<TimeKey, std::shared_ptr<TileProvider>>::iterator it = _tileProviderMap.find(timekey);
|
||||
auto it = _tileProviderMap.find(timekey);
|
||||
if (it != _tileProviderMap.end()) {
|
||||
return it->second;
|
||||
}
|
||||
@@ -467,7 +470,9 @@ double TimeQuantizer::parseTimeResolutionStr(const std::string& resoltutionStr)
|
||||
bool TimeQuantizer::quantize(Time& t, bool clamp) const {
|
||||
double unquantized = t.j2000Seconds();
|
||||
if (_timerange.includes(unquantized)) {
|
||||
double quantized = std::floor((unquantized - _timerange.start) / _resolution) * _resolution + _timerange.start;
|
||||
double quantized = std::floor(
|
||||
(unquantized - _timerange.start) / _resolution) *
|
||||
_resolution + _timerange.start;
|
||||
t.setTime(quantized);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,9 @@ struct TimeIdProviderFactory {
|
||||
*/
|
||||
static void init();
|
||||
|
||||
static std::unordered_map<std::string, std::unique_ptr<TimeFormat>> _timeIdProviderMap;
|
||||
static std::unordered_map<
|
||||
std::string, std::unique_ptr<TimeFormat>
|
||||
> _timeIdProviderMap;
|
||||
static bool initialized;
|
||||
};
|
||||
|
||||
@@ -308,7 +310,8 @@ private:
|
||||
* \param defaultVal value to return if key was not found
|
||||
* \returns the value of the Key, or defaultVal if key was undefined.
|
||||
*/
|
||||
std::string getXMLValue(CPLXMLNode* node, const std::string& key, const std::string& defaultVal);
|
||||
std::string getXMLValue(CPLXMLNode* node, const std::string& key,
|
||||
const std::string& defaultVal);
|
||||
|
||||
/**
|
||||
* Ensures that the TemporalTileProvider is up to date.
|
||||
|
||||
@@ -45,7 +45,9 @@ public:
|
||||
private:
|
||||
TileProvider* indexProvider(const TileIndex& tileIndex) const;
|
||||
|
||||
std::unordered_map<TileIndex::TileHashKey, std::shared_ptr<TileProvider>> _tileProviderMap;
|
||||
std::unordered_map<
|
||||
TileIndex::TileHashKey, std::shared_ptr<TileProvider>
|
||||
> _tileProviderMap;
|
||||
std::shared_ptr<TileProvider> _defaultTileProvider;
|
||||
};
|
||||
|
||||
|
||||
@@ -64,7 +64,8 @@ TileProviderByLevel::TileProviderByLevel(const ghoul::Dictionary& dictionary) {
|
||||
maxLevel = std::round(floatMaxLevel);
|
||||
|
||||
ghoul::Dictionary providerDict;
|
||||
if (!levelProviderDict.getValue<ghoul::Dictionary>(KeyTileProvider, providerDict)) {
|
||||
if (!levelProviderDict.getValue<ghoul::Dictionary>(KeyTileProvider, providerDict))
|
||||
{
|
||||
throw std::runtime_error(
|
||||
"Must define key '" + std::string(KeyTileProvider) + "'"
|
||||
);
|
||||
@@ -86,7 +87,10 @@ TileProviderByLevel::TileProviderByLevel(const ghoul::Dictionary& dictionary) {
|
||||
}
|
||||
|
||||
_levelTileProviders.push_back(
|
||||
std::shared_ptr<TileProvider>(TileProvider::createFromDictionary(typeID, providerDict))
|
||||
std::shared_ptr<TileProvider>(TileProvider::createFromDictionary(
|
||||
typeID,
|
||||
providerDict
|
||||
))
|
||||
);
|
||||
|
||||
std::string providerName;
|
||||
|
||||
@@ -37,7 +37,8 @@ namespace openspace::globebrowsing {
|
||||
|
||||
namespace openspace::globebrowsing::tileselector {
|
||||
|
||||
ChunkTile getHighestResolutionTile(const LayerGroup& layerGroup, const TileIndex& tileIndex);
|
||||
ChunkTile getHighestResolutionTile(const LayerGroup& layerGroup,
|
||||
const TileIndex& tileIndex);
|
||||
|
||||
std::vector<ChunkTile> getTilesSortedByHighestResolution(const LayerGroup& layerGroup,
|
||||
const TileIndex& tileIndex);
|
||||
|
||||
@@ -60,7 +60,10 @@ TileTextureInitData::TileTextureInitData(const TileTextureInitData& original)
|
||||
original.glType(),
|
||||
original.ghoulTextureFormat(),
|
||||
original._padTiles,
|
||||
original.shouldAllocateDataOnCPU() ? ShouldAllocateDataOnCPU::Yes : ShouldAllocateDataOnCPU::No)
|
||||
original.shouldAllocateDataOnCPU() ?
|
||||
ShouldAllocateDataOnCPU::Yes :
|
||||
ShouldAllocateDataOnCPU::No
|
||||
)
|
||||
{}
|
||||
|
||||
glm::ivec3 TileTextureInitData::dimensions() const {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2017 Omar Cornut and ImGui contributors
|
||||
|
||||
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.
|
||||
@@ -3,17 +3,21 @@ dear imgui,
|
||||
[](https://travis-ci.org/ocornut/imgui)
|
||||
[](https://scan.coverity.com/projects/4720)
|
||||
|
||||
(This library is free and will stay free, but needs your support to sustain its development. There are lots of desirable new features and maintenance to do. If you work for a company using ImGui or have the means to do so, please consider financial support)
|
||||
(This library is free but needs your support to sustain its development. There are lots of desirable new features and maintenance to do. If you are an individual using dear imgui, please consider donating via Patreon or PayPal. If your company is using dear imgui, please consider financial support (e.g. sponsoring a few weeks/months of development). I can invoice for private support, custom development etc. E-mail: omarcornut at gmail.)
|
||||
|
||||
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
|
||||
Monthly donations via Patreon:
|
||||
<br>[](http://www.patreon.com/imgui)
|
||||
|
||||
dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
|
||||
One-off donations via PayPal:
|
||||
<br>[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
|
||||
|
||||
ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
|
||||
Dear ImGui is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
|
||||
|
||||
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
|
||||
Dear ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
|
||||
|
||||
ImGui is self-contained within a few files that you can easily copy and compile into your application/engine:
|
||||
Dear ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
|
||||
|
||||
Dear ImGui is self-contained within a few files that you can easily copy and compile into your application/engine:
|
||||
|
||||
- imgui.cpp
|
||||
- imgui.h
|
||||
@@ -27,39 +31,81 @@ ImGui is self-contained within a few files that you can easily copy and compile
|
||||
|
||||
No specific build process is required. You can add the .cpp files to your project or #include them from an existing file.
|
||||
|
||||
Your code passes mouse/keyboard inputs and settings to ImGui (see example applications for more details). After ImGui is setup, you can use it like in this example:
|
||||
Your code passes mouse/keyboard inputs and settings to Dear ImGui (see example applications for more details). After Dear ImGui is setup, you can use it like in this example:
|
||||
|
||||

|
||||

|
||||
|
||||
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate ImGui with your existing codebase.
|
||||
Dear ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate dear imgui with your existing codebase.
|
||||
|
||||
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
|
||||
_A common misunderstanding is to think that immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions are called by the user. This is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are decently optimal and you can render them later, in your app or even remotely._
|
||||
|
||||
Demo
|
||||
----
|
||||
Dear ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! Dear ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, an entire game making editor/framework, etc.
|
||||
|
||||
You should be able to build the examples from sources (tested on Windows/Mac/Linux). If you don't, let me know! If you want to have a quick look at the features of ImGui, you can download Windows binaries of the demo app here.
|
||||
- [imgui-demo-binaries-20160410.zip](http://www.miracleworld.net/imgui/binaries/imgui-demo-binaries-20160410.zip) (Windows binaries, ImGui 1.48+ 2016/04/10, 4 executables, 534 KB)
|
||||
Binaries/Demo
|
||||
-------------
|
||||
|
||||
You should be able to build the examples from sources (tested on Windows/Mac/Linux). If you don't, let me know! If you want to have a quick look at some Dear ImGui features, you can download Windows binaries of the demo app here:
|
||||
- [imgui-demo-binaries-20171013.zip](http://www.miracleworld.net/imgui/binaries/imgui-demo-binaries-20171013.zip) (Windows binaries, Dear ImGui 1.52 WIP built 2017/10/13, 5 executables)
|
||||
|
||||
Bindings
|
||||
--------
|
||||
|
||||
Integrating Dear ImGui within your custom engine is a matter of wiring mouse/keyboard inputs and providing a render function that can bind a texture and render simple textured triangles. The examples/ folder is populated with applications doing just that. If you are an experienced programmer it should take you less than an hour to integrate Dear ImGui in your custom engine, but make sure to spend time reading the FAQ, the comments and other documentation!
|
||||
|
||||
_NB: those third-party bindings may be more or less maintained, more or less close to the spirit of original API and therefore I cannot give much guarantee about them. People who create language bindings sometimes haven't used the C++ API themselves (for the good reason that they aren't C++ users). Dear ImGui was designed with C++ in mind and some of the subtleties may be lost in translation with other languages. If your language supports it, I would suggest replicating the function overloading and default parameters used in the original, else the API may be harder to use. In doubt, please check the original C++ version first!_
|
||||
|
||||
Languages:
|
||||
- C (cimgui): thin c-api wrapper for ImGui https://github.com/Extrawurst/cimgui
|
||||
- C#/.Net (ImGui.NET): An ImGui wrapper for .NET Core https://github.com/mellinoe/ImGui.NET
|
||||
- D (DerelictImgui): Dynamic bindings for the D programming language: https://github.com/Extrawurst/DerelictImgui
|
||||
- Go (go-imgui): https://github.com/Armored-Dragon/go-imgui
|
||||
- Lua: https://github.com/patrickriordan/imgui_lua_bindings
|
||||
- Pascal (imgui-pas) https://github.com/dpethes/imgui-pas
|
||||
- Python (CyImGui): Python bindings for dear imgui using Cython: https://github.com/chromy/cyimgui
|
||||
- Python (pyimgui): Another Python bindings for dear imgui: https://github.com/swistakm/pyimgui
|
||||
- Rust (imgui-rs): Rust bindings for dear imgui https://github.com/Gekkio/imgui-rs
|
||||
|
||||
Frameworks:
|
||||
- Main ImGui repository include examples for DirectX9, DirectX10, DirectX11, OpenGL2/3, Vulkan, Allegro 5, SDL+GL2/3, iOS and Marmalade: https://github.com/ocornut/imgui/tree/master/examples
|
||||
- Unmerged PR: DirectX12: https://github.com/ocornut/imgui/pull/301
|
||||
- Unmerged PR: SDL2 + OpenGLES + Emscripten: https://github.com/ocornut/imgui/pull/336
|
||||
- Unmerged PR: FreeGlut + OpenGL2: https://github.com/ocornut/imgui/pull/801
|
||||
- Unmerged PR: Native Win32 and OSX: https://github.com/ocornut/imgui/pull/281
|
||||
- Unmerged PR: Android: https://github.com/ocornut/imgui/pull/421
|
||||
- Cinder: https://github.com/simongeilfus/Cinder-ImGui
|
||||
- cocos2d-x: https://github.com/c0i/imguix https://github.com/ocornut/imgui/issues/551
|
||||
- Flexium/SFML (FlexGUI): https://github.com/DXsmiley/FlexGUI
|
||||
- Irrlicht (IrrIMGUI): https://github.com/ZahlGraf/IrrIMGUI
|
||||
- Ogre: https://bitbucket.org/LMCrashy/ogreimgui/src
|
||||
- openFrameworks (ofxImGui): https://github.com/jvcleave/ofxImGui
|
||||
- LÖVE: https://github.com/slages/love-imgui
|
||||
- NanoRT (software raytraced) https://github.com/syoyo/imgui/tree/nanort/examples/raytrace_example
|
||||
- Qt3d https://github.com/alpqr/imgui-qt3d
|
||||
- Unreal Engine 4: https://github.com/segross/UnrealImGui or https://github.com/sronsse/UnrealEngine_ImGui
|
||||
- SFML: https://github.com/EliasD/imgui-sfml or https://github.com/Mischa-Alff/imgui-backends
|
||||
|
||||
For other bindings: see [this page](https://github.com/ocornut/imgui/wiki/Links/).
|
||||
Please contact me with the Issues tracker or Twitter to fix/update this list.
|
||||
|
||||
Gallery
|
||||
-------
|
||||
|
||||
See the [Screenshots Thread](https://github.com/ocornut/imgui/issues/123) for some user creations.
|
||||
Also see the [Mega screenshots](https://github.com/ocornut/imgui/issues/1273) for an idea of the available features.
|
||||
|
||||

|
||||
[](https://cloud.githubusercontent.com/assets/8225057/20628927/33e14cac-b329-11e6-80f6-9524e93b048a.png)
|
||||

|
||||
|
||||
[](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v148/profiler.png)
|
||||
[](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v148/profiler.png)
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
ImGui can load TTF fonts. UTF-8 is supported for text display and input. Here using Arial Unicode font to display Japanese. Initialize custom font with:
|
||||
Dear ImGui can load TTF/OTF fonts. UTF-8 is supported for text display and input. Here using Arial Unicode font to display Japanese. Initialize custom font with:
|
||||
```
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.Fonts->AddFontFromFileTTF("ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
|
||||
@@ -77,6 +123,8 @@ The Immediate Mode GUI paradigm may at first appear unusual to some users. This
|
||||
- [A presentation by Rickard Gustafsson and Johannes Algelind](http://www.cse.chalmers.se/edu/year/2011/course/TDA361/Advanced%20Computer%20Graphics/IMGUI.pdf).
|
||||
- [Jari Komppa's tutorial on building an ImGui library](http://iki.fi/sol/imgui/).
|
||||
- [Casey Muratori's original video that popularized the concept](https://mollyrocket.com/861).
|
||||
- [Nicolas Guillemot's CppCon'16 flashtalk about Dear ImGui](https://www.youtube.com/watch?v=LSRJ1jZq90k).
|
||||
- [Thierry Excoffier's Zero Memory Widget](http://perso.univ-lyon1.fr/thierry.excoffier/ZMW/).
|
||||
|
||||
See the [Links page](https://github.com/ocornut/imgui/wiki/Links) for third-party bindings to different languages and frameworks.
|
||||
|
||||
@@ -90,36 +138,41 @@ Frequently Asked Question (FAQ)
|
||||
- Standalone example applications using e.g. OpenGL/DirectX are provided in the examples/ folder.
|
||||
- We obviously needs better documentation! Consider contributing or becoming a [Patron](http://www.patreon.com/imgui) to promote this effort.
|
||||
|
||||
<b>Which version should I get?</b>
|
||||
|
||||
I occasionally tag [Releases](https://github.com/ocornut/imgui/releases) but it is generally safe and recommended to sync to master. The library is fairly stable and regressions tend to be fixed fast when reported. You may also want to checkout the [navigation branch](https://github.com/ocornut/imgui/tree/navigation) if you want to use Dear ImGui with a gamepad (it is also possible to map keyboard inputs to some degree). The Navigation branch is being kept up to date with Master.
|
||||
|
||||
<b>Why the odd dual naming, "dear imgui" vs "ImGui"?</b>
|
||||
|
||||
The library started its life and is best known as "ImGui" only due to the fact that I didn't give it a proper name when I released it. However, the term IMGUI (immediate-mode graphical user interface) was coined before and is being used in variety of other situations. It seemed confusing and unfair to hog the name. To reduce the ambiguity without affecting existing codebases, I have decided on an alternate, longer name "dear imgui" that people can use to refer to this specific library in ambiguous situations.
|
||||
|
||||
<b>How do I update to a newer version of ImGui?</b>
|
||||
<br><b>What is ImTextureID and how do I display an image?</b>
|
||||
<br><b>I integrated ImGui in my engine and the text or lines are blurry..</b>
|
||||
<br><b>I integrated ImGui in my engine and some elements are disappearing when I move windows around..</b>
|
||||
<br><b>How can I have multiple widgets with the same label? Can I have widget without a label? (Yes). A primer on the purpose of labels/IDs.</b>
|
||||
<br><b>How can I tell when ImGui wants my mouse/keyboard inputs and when I can pass them to my application?</b>
|
||||
<b>What is ImTextureID and how do I display an image?</b>
|
||||
<br><b>I integrated Dear ImGui in my engine and the text or lines are blurry..</b>
|
||||
<br><b>I integrated Dear ImGui in my engine and some elements are disappearing when I move windows around..</b>
|
||||
<br><b>How can I have multiple widgets with the same label? Can I have widget without a label? (Yes). A primer on labels/IDs.</b>
|
||||
<br><b>How can I tell when Dear ImGui wants my mouse/keyboard inputs VS when I can pass them to my application?</b>
|
||||
<br><b>How can I load a different font than the default?</b>
|
||||
<br><b>How can I easily use icons in my application?</b>
|
||||
<br><b>How can I load multiple fonts?</b>
|
||||
<br><b>How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?</b>
|
||||
<br><b>How can I use the drawing facilities without an ImGui window? (using ImDrawList API)</b>
|
||||
<br><b>How can I preserve my Dear ImGui context across reloading a DLL? (loss of the global/static variables)</b>
|
||||
<br><b>How can I use the drawing facilities without an Dear ImGui window? (using ImDrawList API)</b>
|
||||
|
||||
See the FAQ in imgui.cpp for answers.
|
||||
|
||||
<b>How do you use ImGui on a platform that may not have a mouse or keyboard?</b>
|
||||
<b>How do you use Dear ImGui on a platform that may not have a mouse or keyboard?</b>
|
||||
|
||||
I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/synergy/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
|
||||
I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. Dear ImGui allows to increase the hit box of widgets (via the _style.TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate. You can also checkout the beta [navigation branch](https://github.com/ocornut/imgui/tree/navigation) which provides support for using Dear ImGui with a game controller.
|
||||
|
||||
<b>Can you create elaborate/serious tools with ImGui?</b>
|
||||
<b>Can you create elaborate/serious tools with Dear ImGui?</b>
|
||||
|
||||
Yes. I have written data browsers, debuggers, profilers and all sort of non-trivial tools with the library. In my experience the simplicity of the API is very empowering. Your UI runs close to your live data. Make the tools always-on and everybody in the team will be inclined to create new tools (as opposed to more "offline" UI toolkits where only a fraction of your team effectively creates tools).
|
||||
Yes. People have written game editors, data browsers, debuggers, profilers and all sort of non-trivial tools with the library. In my experience the simplicity of the API is very empowering. Your UI runs close to your live data. Make the tools always-on and everybody in the team will be inclined to create new tools (as opposed to more "offline" UI toolkits where only a fraction of your team effectively creates tools).
|
||||
|
||||
ImGui is very programmer centric and the immediate-mode GUI paradigm might requires you to readjust some habits before you can realize its full potential. Many programmers have unfortunately been taught by their environment to make unnecessarily complicated things. ImGui is about making things that are simple, efficient and powerful.
|
||||
Dear ImGui is very programmer centric and the immediate-mode GUI paradigm might requires you to readjust some habits before you can realize its full potential. Dear ImGui is about making things that are simple, efficient and powerful.
|
||||
|
||||
<b>Is ImGui fast?</b>
|
||||
<b>Is Dear ImGui fast?</b>
|
||||
|
||||
Probably fast enough for most uses. Down to the fundation of its visual design, ImGui is engineered to be fairly performant both in term of CPU and GPU usage. Running elaborate code and creating elaborate UI will of course have a cost but ImGui aims to minimize it.
|
||||
Probably fast enough for most uses. Down to the foundation of its visual design, Dear ImGui is engineered to be fairly performant both in term of CPU and GPU usage. Running elaborate code and creating elaborate UI will of course have a cost but Dear ImGui aims to minimize it.
|
||||
|
||||
Mileage may vary but the following screenshot can give you a rough idea of the cost of running and rendering UI code (In the case of a trivial demo application like this one, your driver/os setup are likely to be the bottleneck. Testing performance as part of a real application is recommended).
|
||||
|
||||
@@ -127,30 +180,34 @@ Mileage may vary but the following screenshot can give you a rough idea of the c
|
||||
|
||||
This is showing framerate for the full application loop on my 2011 iMac running Windows 7, OpenGL, AMD Radeon HD 6700M with an optimized executable. In contrast, librairies featuring higher-quality rendering and layouting techniques may have a higher resources footprint.
|
||||
|
||||
If you intend to display large lists of items (say, 1000+) it can be beneficial for your code to perform clipping manually - one way is using helpers such as ImGuiListClipper - in order to avoid submitting them to ImGui in the first place. Even though ImGui will discard your clipped items it still needs to calculate their size and that overhead will add up if you have thousands of items. If you can handle clipping and height positionning yourself then browsing a list with millions of items isn't a problem.
|
||||
If you intend to display large lists of items (say, 1000+) it can be beneficial for your code to perform clipping manually - one way is using helpers such as ImGuiListClipper - in order to avoid submitting them to Dear ImGui in the first place. Even though ImGui will discard your clipped items it still needs to calculate their size and that overhead will add up if you have thousands of items. If you can handle clipping and height positionning yourself then browsing a list with millions of items isn't a problem.
|
||||
|
||||
<b>Can you reskin the look of ImGui?</b>
|
||||
<b>Can you reskin the look of Dear ImGui?</b>
|
||||
|
||||
You can alter the look of the interface to some degree: changing colors, sizes, padding, rounding, fonts. However, as ImGui is designed and optimised to create debug tools, the amount of skinning you can apply is limited. There is only so much you can stray away from the default look and feel of the interface.
|
||||
You can alter the look of the interface to some degree: changing colors, sizes, padding, rounding, fonts. However, as Dear ImGui is designed and optimised to create debug tools, the amount of skinning you can apply is limited. There is only so much you can stray away from the default look and feel of the interface. Below is a screenshot from [LumixEngine](https://github.com/nem0/LumixEngine) with custom colors + a docking/tabs extension (both of which you can find in the Issues section and will eventually be merged):
|
||||
|
||||
This is [LumixEngine](https://github.com/nem0/LumixEngine) with a minor skinning hack + a docking/tabs extension (both of which you can find in the Issues section and will eventually be merged).
|
||||
|
||||
[](https://cloud.githubusercontent.com/assets/8225057/13044612/59f07aec-d3cf-11e5-8ccb-39adf2e13e69.png)
|
||||

|
||||
|
||||
<b>Why using C++ (as opposed to C)?</b>
|
||||
|
||||
ImGui takes advantage of a few C++ features for convenience but nothing anywhere Boost-insanity/quagmire. In particular, function overloading and default parameters are used to make the API easier to use and code more terse. Doing so I believe the API is sitting on a sweet spot and giving up on those features would make the API more cumbersome. Other features such as namespace, constructors and templates (in the case of the ImVector<> class) are also relied on as a convenience but could be removed.
|
||||
Dear ImGui takes advantage of a few C++ languages features for convenience but nothing anywhere Boost-insanity/quagmire. Dear ImGui does NOT require C++11 so it can be used with most old C++ compilers. Dear ImGui doesn't use any C++ header file. Language-wise, function overloading and default parameters are used to make the API easier to use and code more terse. Doing so I believe the API is sitting on a sweet spot and giving up on those features would make the API more cumbersome. Other features such as namespace, constructors and templates (in the case of the ImVector<> class) are also relied on as a convenience.
|
||||
|
||||
There is an unofficial but reasonably maintained [c-api for ImGui](https://github.com/Extrawurst/cimgui) by Stephan Dilly. I would suggest using your target language functionality to try replicating the function overloading and default parameters used in C++ else the API may be harder to use. It was really designed with C++ in mind and may not make the same amount of sense with another language. Also see [Links](https://github.com/ocornut/imgui/wiki/Links) for third-party bindings to other languages.
|
||||
There is an reasonably maintained [c-api for ImGui](https://github.com/Extrawurst/cimgui) by Stephan Dilly designed for binding in other languages. I would suggest using your target language functionalities to try replicating the function overloading and default parameters used in C++ else the API may be harder to use. Also see [Links](https://github.com/ocornut/imgui/wiki/Links) for third-party bindings to other languages.
|
||||
|
||||
Donate
|
||||
------
|
||||
Support dear imgui
|
||||
------------------
|
||||
|
||||
<b>Can I donate to support the development of ImGui?</b>
|
||||
<b>How can I help financing further development of Dear ImGui?</b>
|
||||
|
||||
[](http://www.patreon.com/imgui) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
|
||||
Your contributions are keeping the library alive. If you are an individual using dear imgui, please consider donating to enable me to spend more time improving the library.
|
||||
|
||||
I'm currently an independent developer and your contributions are useful. I have setup an [**ImGui Patreon page**](http://www.patreon.com/imgui) if you want to donate and enable me to spend more time improving the library. If your company uses ImGui please consider making a contribution. One-off donations are also greatly appreciated. I am available for hire to work on or with ImGui. Thanks!
|
||||
Monthly donations via Patreon:
|
||||
<br>[](http://www.patreon.com/imgui)
|
||||
|
||||
One-off donations via PayPal:
|
||||
<br>[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
|
||||
|
||||
If your company uses dear imgui, please consider financial support (e.g. sponsoring a few weeks/months of development). I can invoice for private support, custom development etc. E-mail: omarcornut at gmail. Thanks!
|
||||
|
||||
Credits
|
||||
-------
|
||||
@@ -165,18 +222,24 @@ Embeds [stb_textedit.h, stb_truetype.h, stb_rectpack.h](https://github.com/nothi
|
||||
|
||||
Inspiration, feedback, and testing for early versions: Casey Muratori, Atman Binstock, Mikko Mononen, Emmanuel Briney, Stefan Kamoda, Anton Mikhailov, Matt Willis. And everybody posting feedback, questions and patches on the GitHub.
|
||||
|
||||
Ongoing ImGui development is financially supported on [**Patreon**](http://www.patreon.com/imgui).
|
||||
Ongoing dear imgui development is financially supported on [**Patreon**](http://www.patreon.com/imgui).
|
||||
|
||||
Double-chocolate sponsors:
|
||||
- Media Molecule, Mobigame
|
||||
- Media Molecule
|
||||
- Mobigame
|
||||
- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
|
||||
- Aras Pranckevičius
|
||||
- Lizardcube
|
||||
- Greggman
|
||||
|
||||
Salty caramel supporters:
|
||||
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano, Chris Genova, ikrima
|
||||
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Recognition Robotics, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko, Mercury Labs, Singularity Demo Group, Mischa Alff, Sebastien Ronsse.
|
||||
|
||||
Caramel supporters:
|
||||
- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley.
|
||||
- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, Kit framework, Josh Faust, Martin Donlon, Quinton, Felix, Andrew Belt, Codecat, Cort Stratton, Claudio Canepa, Doug McNabb, Emmanuel Julien, Guillaume Chereau, Jeffrey Slutter, Jeremiah Deckard, r-lyeh, Roger Clark, Nekith, Joshua Fisher, Malte Hoffmann, Mustafa Karaalioglu, Merlyn Morgan-Graham, Per Vognsen, Fabian Giesen, Jan Staubach, Matt Hargett, John Shearer, Jesse Chounard, kingcoopa, Miloš Tošić.
|
||||
|
||||
And other supporters; thanks!
|
||||
(Please contact me or PR if you would like to be added or removed from this list)
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
@@ -13,20 +13,27 @@
|
||||
//#define IMGUI_API __declspec( dllexport )
|
||||
//#define IMGUI_API __declspec( dllimport )
|
||||
|
||||
//---- Don't define obsolete functions names. Consider enabling from time to time or when updating to reduce like hood of using already obsolete function/names
|
||||
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
|
||||
//---- Include imgui_user.h at the end of imgui.h
|
||||
//#define IMGUI_INCLUDE_IMGUI_USER_H
|
||||
|
||||
//---- Don't implement default handlers for Windows (so as not to link with OpenClipboard() and others Win32 functions)
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS
|
||||
|
||||
//---- Don't implement help and test window functionality (ShowUserGuide()/ShowStyleEditor()/ShowTestWindow() methods will be empty)
|
||||
//---- Don't implement test window functionality (ShowTestWindow()/ShowStyleEditor()/ShowUserGuide() methods will be empty)
|
||||
//---- It is very strongly recommended to NOT disable the test windows. Please read the comment at the top of imgui_demo.cpp to learn why.
|
||||
//#define IMGUI_DISABLE_TEST_WINDOWS
|
||||
|
||||
//---- Don't define obsolete functions names
|
||||
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
//---- Don't implement ImFormatString(), ImFormatStringV() so you can reimplement them yourself.
|
||||
//#define IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS
|
||||
|
||||
//---- Implement STB libraries in a namespace to avoid conflicts
|
||||
//---- Pack colors to BGRA instead of RGBA (remove need to post process vertex buffer in back ends)
|
||||
//#define IMGUI_USE_BGRA_PACKED_COLOR
|
||||
|
||||
//---- Implement STB libraries in a namespace to avoid linkage conflicts
|
||||
//#define IMGUI_STB_NAMESPACE ImGuiStb
|
||||
|
||||
//---- Define constructor and implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4.
|
||||
@@ -40,6 +47,9 @@
|
||||
operator MyVec4() const { return MyVec4(x,y,z,w); }
|
||||
*/
|
||||
|
||||
//---- Use 32-bit vertex indices (instead of default: 16-bit) to allow meshes with more than 64K vertices
|
||||
//#define ImDrawIdx unsigned int
|
||||
|
||||
//---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files.
|
||||
//---- e.g. create variants of the ImGui::Value() helper for your low-level math types, or your own widgets/helpers.
|
||||
/*
|
||||
|
||||
+3072
-1946
File diff suppressed because it is too large
Load Diff
+446
-308
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,10 @@
|
||||
// dear imgui, v1.49
|
||||
// dear imgui, v1.53 WIP
|
||||
// (internals)
|
||||
|
||||
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
|
||||
// Implement maths operators for ImVec2 (disabled by default to not collide with using IM_VEC2_CLASS_EXTRA along with your own math types+operators)
|
||||
// Set:
|
||||
// #define IMGUI_DEFINE_MATH_OPERATORS
|
||||
// To implement maths operators for ImVec2 (disabled by default to not collide with using IM_VEC2_CLASS_EXTRA along with your own math types+operators)
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -12,7 +13,7 @@
|
||||
#endif
|
||||
|
||||
#include <stdio.h> // FILE*
|
||||
#include <math.h> // sqrtf()
|
||||
#include <math.h> // sqrtf, fabsf, fmodf, powf, floorf, ceilf, cosf, sinf
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (push)
|
||||
@@ -42,10 +43,11 @@ struct ImGuiMouseCursorData;
|
||||
struct ImGuiPopupRef;
|
||||
struct ImGuiWindow;
|
||||
|
||||
typedef int ImGuiLayoutType; // enum ImGuiLayoutType_
|
||||
typedef int ImGuiButtonFlags; // enum ImGuiButtonFlags_
|
||||
typedef int ImGuiTreeNodeFlags; // enum ImGuiTreeNodeFlags_
|
||||
typedef int ImGuiSliderFlags; // enum ImGuiSliderFlags_
|
||||
typedef int ImGuiLayoutType; // enum: horizontal or vertical // enum ImGuiLayoutType_
|
||||
typedef int ImGuiButtonFlags; // flags: for ButtonEx(), ButtonBehavior() // enum ImGuiButtonFlags_
|
||||
typedef int ImGuiItemFlags; // flags: for PushItemFlag() // enum ImGuiItemFlags_
|
||||
typedef int ImGuiSeparatorFlags; // flags: for Separator() - internal // enum ImGuiSeparatorFlags_
|
||||
typedef int ImGuiSliderFlags; // flags: for SliderBehavior() // enum ImGuiSliderFlags_
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// STB libraries
|
||||
@@ -67,14 +69,16 @@ namespace ImGuiStb
|
||||
// Context
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
extern IMGUI_API ImGuiContext* GImGui; // current implicit ImGui context pointer
|
||||
#ifndef GImGui
|
||||
extern IMGUI_API ImGuiContext* GImGui; // Current implicit ImGui context pointer
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR)/sizeof(*_ARR)))
|
||||
#define IM_PI 3.14159265358979323846f
|
||||
#define IM_PI 3.14159265358979323846f
|
||||
#define IM_OFFSETOF(_TYPE,_ELM) ((size_t)&(((_TYPE*)0)->_ELM))
|
||||
|
||||
// Helpers: UTF-8 <> wchar
|
||||
IMGUI_API int ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count
|
||||
@@ -85,20 +89,28 @@ IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, cons
|
||||
|
||||
// Helpers: Misc
|
||||
IMGUI_API ImU32 ImHash(const void* data, int data_size, ImU32 seed = 0); // Pass data_size==0 for zero-terminated strings
|
||||
IMGUI_API void* ImLoadFileToMemory(const char* filename, const char* file_open_mode, int* out_file_size = NULL, int padding_bytes = 0);
|
||||
IMGUI_API bool ImIsPointInTriangle(const ImVec2& p, const ImVec2& a, const ImVec2& b, const ImVec2& c);
|
||||
IMGUI_API void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, int* out_file_size = NULL, int padding_bytes = 0);
|
||||
IMGUI_API FILE* ImFileOpen(const char* filename, const char* file_open_mode);
|
||||
static inline bool ImCharIsSpace(int c) { return c == ' ' || c == '\t' || c == 0x3000; }
|
||||
static inline bool ImIsPowerOfTwo(int v) { return v != 0 && (v & (v - 1)) == 0; }
|
||||
static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; }
|
||||
|
||||
// Helpers: Geometry
|
||||
IMGUI_API ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p);
|
||||
IMGUI_API bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
|
||||
IMGUI_API ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
|
||||
IMGUI_API void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w);
|
||||
|
||||
// Helpers: String
|
||||
IMGUI_API int ImStricmp(const char* str1, const char* str2);
|
||||
IMGUI_API int ImStrnicmp(const char* str1, const char* str2, int count);
|
||||
IMGUI_API void ImStrncpy(char* dst, const char* src, int count);
|
||||
IMGUI_API char* ImStrdup(const char* str);
|
||||
IMGUI_API int ImStrlenW(const ImWchar* str);
|
||||
IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line
|
||||
IMGUI_API const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end);
|
||||
IMGUI_API int ImFormatString(char* buf, int buf_size, const char* fmt, ...) IM_PRINTFARGS(3);
|
||||
IMGUI_API int ImFormatStringV(char* buf, int buf_size, const char* fmt, va_list args);
|
||||
IMGUI_API int ImFormatString(char* buf, int buf_size, const char* fmt, ...) IM_FMTARGS(3);
|
||||
IMGUI_API int ImFormatStringV(char* buf, int buf_size, const char* fmt, va_list args) IM_FMTLIST(3);
|
||||
|
||||
// Helpers: Math
|
||||
// We are keeping those not leaking to the user by default, in the case the user has implicit cast operators between ImVec2 and its own types (when IM_VEC2_CLASS_EXTRA is defined)
|
||||
@@ -113,7 +125,9 @@ static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs)
|
||||
static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs) { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; }
|
||||
static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; }
|
||||
static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; }
|
||||
static inline ImVec4 operator+(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x+rhs.x, lhs.y+rhs.y, lhs.z+rhs.z, lhs.w+rhs.w); }
|
||||
static inline ImVec4 operator-(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x-rhs.x, lhs.y-rhs.y, lhs.z-rhs.z, lhs.w-rhs.w); }
|
||||
static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x*rhs.x, lhs.y*rhs.y, lhs.z*rhs.z, lhs.w*rhs.w); }
|
||||
#endif
|
||||
|
||||
static inline int ImMin(int lhs, int rhs) { return lhs < rhs ? lhs : rhs; }
|
||||
@@ -126,22 +140,28 @@ static inline int ImClamp(int v, int mn, int mx)
|
||||
static inline float ImClamp(float v, float mn, float mx) { return (v < mn) ? mn : (v > mx) ? mx : v; }
|
||||
static inline ImVec2 ImClamp(const ImVec2& f, const ImVec2& mn, ImVec2 mx) { return ImVec2(ImClamp(f.x,mn.x,mx.x), ImClamp(f.y,mn.y,mx.y)); }
|
||||
static inline float ImSaturate(float f) { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
|
||||
static inline void ImSwap(int& a, int& b) { int tmp = a; a = b; b = tmp; }
|
||||
static inline void ImSwap(float& a, float& b) { float tmp = a; a = b; b = tmp; }
|
||||
static inline int ImLerp(int a, int b, float t) { return (int)(a + (b - a) * t); }
|
||||
static inline float ImLerp(float a, float b, float t) { return a + (b - a) * t; }
|
||||
static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, float t) { return ImVec2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); }
|
||||
static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t) { return ImVec2(a.x + (b.x - a.x) * t.x, a.y + (b.y - a.y) * t.y); }
|
||||
static inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, float t) { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); }
|
||||
static inline float ImLengthSqr(const ImVec2& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y; }
|
||||
static inline float ImLengthSqr(const ImVec4& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y + lhs.z*lhs.z + lhs.w*lhs.w; }
|
||||
static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = lhs.x*lhs.x + lhs.y*lhs.y; if (d > 0.0f) return 1.0f / sqrtf(d); return fail_value; }
|
||||
static inline float ImFloor(float f) { return (float)(int)f; }
|
||||
static inline ImVec2 ImFloor(ImVec2 v) { return ImVec2((float)(int)v.x, (float)(int)v.y); }
|
||||
static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2((float)(int)v.x, (float)(int)v.y); }
|
||||
static inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; }
|
||||
static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); }
|
||||
static inline float ImLinearSweep(float current, float target, float speed) { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; }
|
||||
|
||||
// We call C++ constructor on own allocated memory via the placement "new(ptr) Type()" syntax.
|
||||
// Defining a custom placement new() with a dummy parameter allows us to bypass including <new> which on some platforms complains when user has disabled exceptions.
|
||||
#ifdef IMGUI_DEFINE_PLACEMENT_NEW
|
||||
struct ImPlacementNewDummy {};
|
||||
inline void* operator new(size_t, ImPlacementNewDummy, void* ptr) { return ptr; }
|
||||
inline void operator delete(void*, ImPlacementNewDummy, void*) {}
|
||||
#define IM_PLACEMENT_NEW(_PTR) new(ImPlacementNewDummy(), _PTR)
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Types
|
||||
@@ -150,16 +170,17 @@ inline void operator delete(void*, ImPlacementNewDummy, void*) {}
|
||||
enum ImGuiButtonFlags_
|
||||
{
|
||||
ImGuiButtonFlags_Repeat = 1 << 0, // hold to repeat
|
||||
ImGuiButtonFlags_PressedOnClickRelease = 1 << 1, // (default) return pressed on click+release on same item (default if no PressedOn** flag is set)
|
||||
ImGuiButtonFlags_PressedOnClick = 1 << 2, // return pressed on click (default requires click+release)
|
||||
ImGuiButtonFlags_PressedOnRelease = 1 << 3, // return pressed on release (default requires click+release)
|
||||
ImGuiButtonFlags_PressedOnDoubleClick = 1 << 4, // return pressed on double-click (default requires click+release)
|
||||
ImGuiButtonFlags_FlattenChilds = 1 << 5, // allow interaction even if a child window is overlapping
|
||||
ImGuiButtonFlags_DontClosePopups = 1 << 6, // disable automatically closing parent popup on press
|
||||
ImGuiButtonFlags_Disabled = 1 << 7, // disable interaction
|
||||
ImGuiButtonFlags_AlignTextBaseLine = 1 << 8, // vertically align button to match text baseline - ButtonEx() only
|
||||
ImGuiButtonFlags_PressedOnClickRelease = 1 << 1, // return true on click + release on same item [DEFAULT if no PressedOn* flag is set]
|
||||
ImGuiButtonFlags_PressedOnClick = 1 << 2, // return true on click (default requires click+release)
|
||||
ImGuiButtonFlags_PressedOnRelease = 1 << 3, // return true on release (default requires click+release)
|
||||
ImGuiButtonFlags_PressedOnDoubleClick = 1 << 4, // return true on double-click (default requires click+release)
|
||||
ImGuiButtonFlags_FlattenChilds = 1 << 5, // allow interactions even if a child window is overlapping
|
||||
ImGuiButtonFlags_DontClosePopups = 1 << 6, // disable automatically closing parent popup on press // [UNUSED]
|
||||
ImGuiButtonFlags_Disabled = 1 << 7, // disable interactions
|
||||
ImGuiButtonFlags_AlignTextBaseLine = 1 << 8, // vertically align button to match text baseline (ButtonEx() only)
|
||||
ImGuiButtonFlags_NoKeyModifiers = 1 << 9, // disable interaction if a key modifier is held
|
||||
ImGuiButtonFlags_AllowOverlapMode = 1 << 10 // require previous frame HoveredId to either match id or be null before being usable
|
||||
ImGuiButtonFlags_AllowOverlapMode = 1 << 10, // require previous frame HoveredId to either match id or be null before being usable
|
||||
ImGuiButtonFlags_NoHoldingActiveID = 1 << 11 // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
|
||||
};
|
||||
|
||||
enum ImGuiSliderFlags_
|
||||
@@ -167,6 +188,15 @@ enum ImGuiSliderFlags_
|
||||
ImGuiSliderFlags_Vertical = 1 << 0
|
||||
};
|
||||
|
||||
enum ImGuiColumnsFlags_
|
||||
{
|
||||
// Default: 0
|
||||
ImGuiColumnsFlags_NoBorder = 1 << 0, // Disable column dividers
|
||||
ImGuiColumnsFlags_NoResize = 1 << 1, // Disable resizing columns when clicking on the dividers
|
||||
ImGuiColumnsFlags_NoPreserveWidths = 1 << 2, // Disable column width preservation when adjusting columns
|
||||
ImGuiColumnsFlags_NoForceWithinWindow = 1 << 3 // Disable forcing columns to fit within window
|
||||
};
|
||||
|
||||
enum ImGuiSelectableFlagsPrivate_
|
||||
{
|
||||
// NB: need to be in sync with last value of ImGuiSelectableFlags_
|
||||
@@ -176,6 +206,12 @@ enum ImGuiSelectableFlagsPrivate_
|
||||
ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 6
|
||||
};
|
||||
|
||||
enum ImGuiSeparatorFlags_
|
||||
{
|
||||
ImGuiSeparatorFlags_Horizontal = 1 << 0, // Axis default to current layout type, so generally Horizontal unless e.g. in a menu bar
|
||||
ImGuiSeparatorFlags_Vertical = 1 << 1
|
||||
};
|
||||
|
||||
// FIXME: this is in development, not exposed/functional as a generic feature yet.
|
||||
enum ImGuiLayoutType_
|
||||
{
|
||||
@@ -192,7 +228,26 @@ enum ImGuiPlotType
|
||||
enum ImGuiDataType
|
||||
{
|
||||
ImGuiDataType_Int,
|
||||
ImGuiDataType_Float
|
||||
ImGuiDataType_Float,
|
||||
ImGuiDataType_Float2
|
||||
};
|
||||
|
||||
enum ImGuiDir
|
||||
{
|
||||
ImGuiDir_None = -1,
|
||||
ImGuiDir_Left = 0,
|
||||
ImGuiDir_Right = 1,
|
||||
ImGuiDir_Up = 2,
|
||||
ImGuiDir_Down = 3
|
||||
};
|
||||
|
||||
enum ImGuiCorner
|
||||
{
|
||||
ImGuiCorner_TopLeft = 1 << 0, // 1
|
||||
ImGuiCorner_TopRight = 1 << 1, // 2
|
||||
ImGuiCorner_BotRight = 1 << 2, // 4
|
||||
ImGuiCorner_BotLeft = 1 << 3, // 8
|
||||
ImGuiCorner_All = 0x0F
|
||||
};
|
||||
|
||||
// 2D axis aligned bounding-box
|
||||
@@ -222,8 +277,8 @@ struct IMGUI_API ImRect
|
||||
void Add(const ImRect& rhs) { if (Min.x > rhs.Min.x) Min.x = rhs.Min.x; if (Min.y > rhs.Min.y) Min.y = rhs.Min.y; if (Max.x < rhs.Max.x) Max.x = rhs.Max.x; if (Max.y < rhs.Max.y) Max.y = rhs.Max.y; }
|
||||
void Expand(const float amount) { Min.x -= amount; Min.y -= amount; Max.x += amount; Max.y += amount; }
|
||||
void Expand(const ImVec2& amount) { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; }
|
||||
void Reduce(const ImVec2& amount) { Min.x += amount.x; Min.y += amount.y; Max.x -= amount.x; Max.y -= amount.y; }
|
||||
void Clip(const ImRect& clip) { if (Min.x < clip.Min.x) Min.x = clip.Min.x; if (Min.y < clip.Min.y) Min.y = clip.Min.y; if (Max.x > clip.Max.x) Max.x = clip.Max.x; if (Max.y > clip.Max.y) Max.y = clip.Max.y; }
|
||||
void Translate(const ImVec2& v) { Min.x += v.x; Min.y += v.y; Max.x += v.x; Max.y += v.y; }
|
||||
void ClipWith(const ImRect& clip) { if (Min.x < clip.Min.x) Min.x = clip.Min.x; if (Min.y < clip.Min.y) Min.y = clip.Min.y; if (Max.x > clip.Max.x) Max.x = clip.Max.x; if (Max.y > clip.Max.y) Max.y = clip.Max.y; }
|
||||
void Floor() { Min.x = (float)(int)Min.x; Min.y = (float)(int)Min.y; Max.x = (float)(int)Max.x; Max.y = (float)(int)Max.y; }
|
||||
ImVec2 GetClosestPoint(ImVec2 p, bool on_edge) const
|
||||
{
|
||||
@@ -241,14 +296,17 @@ struct IMGUI_API ImRect
|
||||
struct ImGuiColMod
|
||||
{
|
||||
ImGuiCol Col;
|
||||
ImVec4 PreviousValue;
|
||||
ImVec4 BackupValue;
|
||||
};
|
||||
|
||||
// Stacked style modifier, backup of modified data so we can restore it
|
||||
// Stacked style modifier, backup of modified data so we can restore it. Data type inferred from the variable.
|
||||
struct ImGuiStyleMod
|
||||
{
|
||||
ImGuiStyleVar Var;
|
||||
ImVec2 PreviousValue;
|
||||
ImGuiStyleVar VarIdx;
|
||||
union { int BackupInt[2]; float BackupFloat[2]; };
|
||||
ImGuiStyleMod(ImGuiStyleVar idx, int v) { VarIdx = idx; BackupInt[0] = v; }
|
||||
ImGuiStyleMod(ImGuiStyleVar idx, float v) { VarIdx = idx; BackupFloat[0] = v; }
|
||||
ImGuiStyleMod(ImGuiStyleVar idx, ImVec2 v) { VarIdx = idx; BackupFloat[0] = v.x; BackupFloat[1] = v.y; }
|
||||
};
|
||||
|
||||
// Stacked data for BeginGroup()/EndGroup()
|
||||
@@ -257,16 +315,19 @@ struct ImGuiGroupData
|
||||
ImVec2 BackupCursorPos;
|
||||
ImVec2 BackupCursorMaxPos;
|
||||
float BackupIndentX;
|
||||
float BackupGroupOffsetX;
|
||||
float BackupCurrentLineHeight;
|
||||
float BackupCurrentLineTextBaseOffset;
|
||||
float BackupLogLinePosY;
|
||||
bool BackupActiveIdIsAlive;
|
||||
bool AdvanceCursor;
|
||||
};
|
||||
|
||||
// Per column data for Columns()
|
||||
struct ImGuiColumnData
|
||||
{
|
||||
float OffsetNorm; // Column start offset, normalized 0.0 (far left) -> 1.0 (far right)
|
||||
float OffsetNorm; // Column start offset, normalized 0.0 (far left) -> 1.0 (far right)
|
||||
ImRect ClipRect;
|
||||
//float IndentX;
|
||||
};
|
||||
|
||||
@@ -312,7 +373,7 @@ struct IMGUI_API ImGuiTextEditState
|
||||
struct ImGuiIniData
|
||||
{
|
||||
char* Name;
|
||||
ImGuiID ID;
|
||||
ImGuiID Id;
|
||||
ImVec2 Pos;
|
||||
ImVec2 Size;
|
||||
bool Collapsed;
|
||||
@@ -331,13 +392,13 @@ struct ImGuiMouseCursorData
|
||||
// Storage for current popup stack
|
||||
struct ImGuiPopupRef
|
||||
{
|
||||
ImGuiID PopupID; // Set on OpenPopup()
|
||||
ImGuiID PopupId; // Set on OpenPopup()
|
||||
ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
|
||||
ImGuiWindow* ParentWindow; // Set on OpenPopup()
|
||||
ImGuiID ParentMenuSet; // Set on OpenPopup()
|
||||
ImVec2 MousePosOnOpen; // Copy of mouse position at the time of opening popup
|
||||
|
||||
ImGuiPopupRef(ImGuiID id, ImGuiWindow* parent_window, ImGuiID parent_menu_set, const ImVec2& mouse_pos) { PopupID = id; Window = NULL; ParentWindow = parent_window; ParentMenuSet = parent_menu_set; MousePosOnOpen = mouse_pos; }
|
||||
ImGuiPopupRef(ImGuiID id, ImGuiWindow* parent_window, ImGuiID parent_menu_set, const ImVec2& mouse_pos) { PopupId = id; Window = NULL; ParentWindow = parent_window; ParentMenuSet = parent_menu_set; MousePosOnOpen = mouse_pos; }
|
||||
};
|
||||
|
||||
// Main state for ImGui
|
||||
@@ -347,8 +408,8 @@ struct ImGuiContext
|
||||
ImGuiIO IO;
|
||||
ImGuiStyle Style;
|
||||
ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
|
||||
float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize()
|
||||
float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Size of characters.
|
||||
float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
|
||||
float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height.
|
||||
ImVec2 FontTexUvWhitePixel; // (Shortcut) == Font->TexUvWhitePixel
|
||||
|
||||
float Time;
|
||||
@@ -357,23 +418,26 @@ struct ImGuiContext
|
||||
int FrameCountRendered;
|
||||
ImVector<ImGuiWindow*> Windows;
|
||||
ImVector<ImGuiWindow*> WindowsSortBuffer;
|
||||
ImGuiWindow* CurrentWindow; // Being drawn into
|
||||
ImVector<ImGuiWindow*> CurrentWindowStack;
|
||||
ImGuiWindow* FocusedWindow; // Will catch keyboard inputs
|
||||
ImGuiStorage WindowsById;
|
||||
ImGuiWindow* CurrentWindow; // Being drawn into
|
||||
ImGuiWindow* NavWindow; // Nav/focused window for navigation
|
||||
ImGuiWindow* HoveredWindow; // Will catch mouse inputs
|
||||
ImGuiWindow* HoveredRootWindow; // Will catch mouse inputs (for focus/move only)
|
||||
ImGuiID HoveredId; // Hovered widget
|
||||
bool HoveredIdAllowOverlap;
|
||||
ImGuiID HoveredIdPreviousFrame;
|
||||
float HoveredIdTimer;
|
||||
ImGuiID ActiveId; // Active widget
|
||||
ImGuiID ActiveIdPreviousFrame;
|
||||
bool ActiveIdIsAlive;
|
||||
float ActiveIdTimer;
|
||||
bool ActiveIdIsAlive; // Active widget has been seen this frame
|
||||
bool ActiveIdIsJustActivated; // Set at the time of activation for one frame
|
||||
bool ActiveIdAllowOverlap; // Set only by active widget
|
||||
bool ActiveIdAllowOverlap; // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always)
|
||||
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
|
||||
ImGuiWindow* ActiveIdWindow;
|
||||
ImGuiWindow* MovedWindow; // Track the child window we clicked on to move a window.
|
||||
ImGuiID MovedWindowMoveId; // == MovedWindow->RootWindow->MoveId
|
||||
ImGuiWindow* MovingWindow; // Track the child window we clicked on to move a window.
|
||||
ImGuiID MovingWindowMoveId; // == MovingWindow->MoveId
|
||||
ImVector<ImGuiIniData> Settings; // .ini Settings
|
||||
float SettingsDirtyTimer; // Save .ini Settings on disk when time reaches zero
|
||||
ImVector<ImGuiColMod> ColorModifiers; // Stack for PushStyleColor()/PopStyleColor()
|
||||
@@ -384,20 +448,21 @@ struct ImGuiContext
|
||||
|
||||
// Storage for SetNexWindow** and SetNextTreeNode*** functions
|
||||
ImVec2 SetNextWindowPosVal;
|
||||
ImVec2 SetNextWindowPosPivot;
|
||||
ImVec2 SetNextWindowSizeVal;
|
||||
ImVec2 SetNextWindowContentSizeVal;
|
||||
bool SetNextWindowCollapsedVal;
|
||||
ImGuiSetCond SetNextWindowPosCond;
|
||||
ImGuiSetCond SetNextWindowSizeCond;
|
||||
ImGuiSetCond SetNextWindowContentSizeCond;
|
||||
ImGuiSetCond SetNextWindowCollapsedCond;
|
||||
ImGuiCond SetNextWindowPosCond;
|
||||
ImGuiCond SetNextWindowSizeCond;
|
||||
ImGuiCond SetNextWindowContentSizeCond;
|
||||
ImGuiCond SetNextWindowCollapsedCond;
|
||||
ImRect SetNextWindowSizeConstraintRect; // Valid if 'SetNextWindowSizeConstraint' is true
|
||||
ImGuiSizeConstraintCallback SetNextWindowSizeConstraintCallback;
|
||||
void* SetNextWindowSizeConstraintCallbackUserData;
|
||||
void* SetNextWindowSizeConstraintCallbackUserData;
|
||||
bool SetNextWindowSizeConstraint;
|
||||
bool SetNextWindowFocus;
|
||||
bool SetNextTreeNodeOpenVal;
|
||||
ImGuiSetCond SetNextTreeNodeOpenCond;
|
||||
ImGuiCond SetNextTreeNodeOpenCond;
|
||||
|
||||
// Render
|
||||
ImDrawData RenderDrawData; // Main ImDrawData instance to pass render information to the user
|
||||
@@ -411,15 +476,16 @@ struct ImGuiContext
|
||||
ImGuiTextEditState InputTextState;
|
||||
ImFont InputTextPasswordFont;
|
||||
ImGuiID ScalarAsInputTextId; // Temporary text input when CTRL+clicking on a slider, etc.
|
||||
ImGuiStorage ColorEditModeStorage; // Store user selection of color edit mode
|
||||
ImGuiColorEditFlags ColorEditOptions; // Store user options for color edit widgets
|
||||
ImVec4 ColorPickerRef;
|
||||
float DragCurrentValue; // Currently dragged value, always float, not rounded by end-user precision settings
|
||||
ImVec2 DragLastMouseDelta;
|
||||
float DragSpeedDefaultRatio; // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
|
||||
float DragSpeedScaleSlow;
|
||||
float DragSpeedScaleFast;
|
||||
ImVec2 ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage?
|
||||
char Tooltip[1024];
|
||||
char* PrivateClipboard; // If no custom clipboard handler is defined
|
||||
int TooltipOverrideCount;
|
||||
ImVector<char> PrivateClipboard; // If no custom clipboard handler is defined
|
||||
ImVec2 OsImePosRequest, OsImePosSet; // Cursor position request & last passed to the OS Input Method Editor
|
||||
|
||||
// Logging
|
||||
@@ -433,8 +499,9 @@ struct ImGuiContext
|
||||
float FramerateSecPerFrame[120]; // calculate estimate of framerate for user
|
||||
int FramerateSecPerFrameIdx;
|
||||
float FramerateSecPerFrameAccum;
|
||||
int CaptureMouseNextFrame; // explicit capture via CaptureInputs() sets those flags
|
||||
int CaptureKeyboardNextFrame;
|
||||
int WantCaptureMouseNextFrame; // explicit capture via CaptureInputs() sets those flags
|
||||
int WantCaptureKeyboardNextFrame;
|
||||
int WantTextInputNextFrame;
|
||||
char TempBuffer[1024*3+1]; // temporary text buffer
|
||||
|
||||
ImGuiContext()
|
||||
@@ -448,21 +515,23 @@ struct ImGuiContext
|
||||
FrameCount = 0;
|
||||
FrameCountEnded = FrameCountRendered = -1;
|
||||
CurrentWindow = NULL;
|
||||
FocusedWindow = NULL;
|
||||
NavWindow = NULL;
|
||||
HoveredWindow = NULL;
|
||||
HoveredRootWindow = NULL;
|
||||
HoveredId = 0;
|
||||
HoveredIdAllowOverlap = false;
|
||||
HoveredIdPreviousFrame = 0;
|
||||
HoveredIdTimer = 0.0f;
|
||||
ActiveId = 0;
|
||||
ActiveIdPreviousFrame = 0;
|
||||
ActiveIdTimer = 0.0f;
|
||||
ActiveIdIsAlive = false;
|
||||
ActiveIdIsJustActivated = false;
|
||||
ActiveIdAllowOverlap = false;
|
||||
ActiveIdClickOffset = ImVec2(-1,-1);
|
||||
ActiveIdWindow = NULL;
|
||||
MovedWindow = NULL;
|
||||
MovedWindowMoveId = 0;
|
||||
MovingWindow = NULL;
|
||||
MovingWindowMoveId = 0;
|
||||
SettingsDirtyTimer = 0.0f;
|
||||
|
||||
SetNextWindowPosVal = ImVec2(0.0f, 0.0f);
|
||||
@@ -472,21 +541,23 @@ struct ImGuiContext
|
||||
SetNextWindowSizeCond = 0;
|
||||
SetNextWindowContentSizeCond = 0;
|
||||
SetNextWindowCollapsedCond = 0;
|
||||
SetNextWindowFocus = false;
|
||||
SetNextWindowSizeConstraintRect = ImRect();
|
||||
SetNextWindowSizeConstraintCallback = NULL;
|
||||
SetNextWindowSizeConstraintCallbackUserData = NULL;
|
||||
SetNextWindowSizeConstraint = false;
|
||||
SetNextWindowFocus = false;
|
||||
SetNextTreeNodeOpenVal = false;
|
||||
SetNextTreeNodeOpenCond = 0;
|
||||
|
||||
ScalarAsInputTextId = 0;
|
||||
ColorEditOptions = ImGuiColorEditFlags__OptionsDefault;
|
||||
DragCurrentValue = 0.0f;
|
||||
DragLastMouseDelta = ImVec2(0.0f, 0.0f);
|
||||
DragSpeedDefaultRatio = 0.01f;
|
||||
DragSpeedScaleSlow = 0.01f;
|
||||
DragSpeedDefaultRatio = 1.0f / 100.0f;
|
||||
DragSpeedScaleSlow = 1.0f / 100.0f;
|
||||
DragSpeedScaleFast = 10.0f;
|
||||
ScrollbarClickDeltaToGrabCenter = ImVec2(0.0f, 0.0f);
|
||||
memset(Tooltip, 0, sizeof(Tooltip));
|
||||
PrivateClipboard = NULL;
|
||||
TooltipOverrideCount = 0;
|
||||
OsImePosRequest = OsImePosSet = ImVec2(-1.0f, -1.0f);
|
||||
|
||||
ModalWindowDarkeningRatio = 0.0f;
|
||||
@@ -503,11 +574,23 @@ struct ImGuiContext
|
||||
memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame));
|
||||
FramerateSecPerFrameIdx = 0;
|
||||
FramerateSecPerFrameAccum = 0.0f;
|
||||
CaptureMouseNextFrame = CaptureKeyboardNextFrame = -1;
|
||||
WantCaptureMouseNextFrame = WantCaptureKeyboardNextFrame = WantTextInputNextFrame = -1;
|
||||
memset(TempBuffer, 0, sizeof(TempBuffer));
|
||||
}
|
||||
};
|
||||
|
||||
// Transient per-window flags, reset at the beginning of the frame. For child window, inherited from parent on first Begin().
|
||||
enum ImGuiItemFlags_
|
||||
{
|
||||
ImGuiItemFlags_AllowKeyboardFocus = 1 << 0, // true
|
||||
ImGuiItemFlags_ButtonRepeat = 1 << 1, // false // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
|
||||
ImGuiItemFlags_Disabled = 1 << 2, // false // FIXME-WIP: Disable interactions but doesn't affect visuals. Should be: grey out and disable interactions with widgets that affect data + view widgets (WIP)
|
||||
//ImGuiItemFlags_NoNav = 1 << 3, // false
|
||||
//ImGuiItemFlags_NoNavDefaultFocus = 1 << 4, // false
|
||||
ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // MenuItem/Selectable() automatically closes current Popup window
|
||||
ImGuiItemFlags_Default_ = ImGuiItemFlags_AllowKeyboardFocus
|
||||
};
|
||||
|
||||
// Transient per-window data, reset at the beginning of the frame
|
||||
// FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiDrawContext is quite tenuous and could be reconsidered.
|
||||
struct IMGUI_API ImGuiDrawContext
|
||||
@@ -522,10 +605,9 @@ struct IMGUI_API ImGuiDrawContext
|
||||
float PrevLineTextBaseOffset;
|
||||
float LogLinePosY;
|
||||
int TreeDepth;
|
||||
ImGuiID LastItemID;
|
||||
ImGuiID LastItemId;
|
||||
ImRect LastItemRect;
|
||||
bool LastItemHoveredAndUsable; // Item rectangle is hovered, and its window is currently interactable with (not blocked by a popup preventing access to the window)
|
||||
bool LastItemHoveredRect; // Item rectangle is hovered, but its window may or not be currently interactable with (might be blocked by a popup preventing access to the window)
|
||||
bool LastItemRectHoveredRect;
|
||||
bool MenuBarAppending;
|
||||
float MenuBarOffsetX;
|
||||
ImVector<ImGuiWindow*> ChildWindows;
|
||||
@@ -533,29 +615,28 @@ struct IMGUI_API ImGuiDrawContext
|
||||
ImGuiLayoutType LayoutType;
|
||||
|
||||
// We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings.
|
||||
ImGuiItemFlags ItemFlags; // == ItemFlagsStack.back() [empty == ImGuiItemFlags_Default]
|
||||
float ItemWidth; // == ItemWidthStack.back(). 0.0: default, >0.0: width in pixels, <0.0: align xx pixels to the right of window
|
||||
float TextWrapPos; // == TextWrapPosStack.back() [empty == -1.0f]
|
||||
bool AllowKeyboardFocus; // == AllowKeyboardFocusStack.back() [empty == true]
|
||||
bool ButtonRepeat; // == ButtonRepeatStack.back() [empty == false]
|
||||
ImVector<ImGuiItemFlags>ItemFlagsStack;
|
||||
ImVector<float> ItemWidthStack;
|
||||
ImVector<float> TextWrapPosStack;
|
||||
ImVector<bool> AllowKeyboardFocusStack;
|
||||
ImVector<bool> ButtonRepeatStack;
|
||||
ImVector<ImGuiGroupData>GroupStack;
|
||||
ImGuiColorEditMode ColorEditMode;
|
||||
int StackSizesBackup[6]; // Store size of various stacks for asserting
|
||||
|
||||
float IndentX; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
|
||||
float GroupOffsetX;
|
||||
float ColumnsOffsetX; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API.
|
||||
int ColumnsCurrent;
|
||||
int ColumnsCount;
|
||||
float ColumnsMinX;
|
||||
float ColumnsMaxX;
|
||||
float ColumnsStartPosY;
|
||||
float ColumnsStartMaxPosX; // Backup of CursorMaxPos
|
||||
float ColumnsCellMinY;
|
||||
float ColumnsCellMaxY;
|
||||
bool ColumnsShowBorders;
|
||||
ImGuiID ColumnsSetID;
|
||||
ImGuiColumnsFlags ColumnsFlags;
|
||||
ImGuiID ColumnsSetId;
|
||||
ImVector<ImGuiColumnData> ColumnsData;
|
||||
|
||||
ImGuiDrawContext()
|
||||
@@ -565,29 +646,29 @@ struct IMGUI_API ImGuiDrawContext
|
||||
CurrentLineTextBaseOffset = PrevLineTextBaseOffset = 0.0f;
|
||||
LogLinePosY = -1.0f;
|
||||
TreeDepth = 0;
|
||||
LastItemID = 0;
|
||||
LastItemRect = ImRect(0.0f,0.0f,0.0f,0.0f);
|
||||
LastItemHoveredAndUsable = LastItemHoveredRect = false;
|
||||
LastItemId = 0;
|
||||
LastItemRect = ImRect();
|
||||
LastItemRectHoveredRect = false;
|
||||
MenuBarAppending = false;
|
||||
MenuBarOffsetX = 0.0f;
|
||||
StateStorage = NULL;
|
||||
LayoutType = ImGuiLayoutType_Vertical;
|
||||
ItemWidth = 0.0f;
|
||||
ButtonRepeat = false;
|
||||
AllowKeyboardFocus = true;
|
||||
ItemFlags = ImGuiItemFlags_Default_;
|
||||
TextWrapPos = -1.0f;
|
||||
ColorEditMode = ImGuiColorEditMode_RGB;
|
||||
memset(StackSizesBackup, 0, sizeof(StackSizesBackup));
|
||||
|
||||
IndentX = 0.0f;
|
||||
GroupOffsetX = 0.0f;
|
||||
ColumnsOffsetX = 0.0f;
|
||||
ColumnsCurrent = 0;
|
||||
ColumnsCount = 1;
|
||||
ColumnsMinX = ColumnsMaxX = 0.0f;
|
||||
ColumnsStartPosY = 0.0f;
|
||||
ColumnsStartMaxPosX = 0.0f;
|
||||
ColumnsCellMinY = ColumnsCellMaxY = 0.0f;
|
||||
ColumnsShowBorders = true;
|
||||
ColumnsSetID = 0;
|
||||
ColumnsFlags = 0;
|
||||
ColumnsSetId = 0;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -597,7 +678,7 @@ struct IMGUI_API ImGuiWindow
|
||||
char* Name;
|
||||
ImGuiID ID; // == ImHash(Name)
|
||||
ImGuiWindowFlags Flags; // See enum ImGuiWindowFlags_
|
||||
int IndexWithinParent; // Order within immediate parent window, if we are a child window. Otherwise 0.
|
||||
int OrderWithinParent; // Order within immediate parent window, if we are a child window. Otherwise 0.
|
||||
ImVec2 PosFloat;
|
||||
ImVec2 Pos; // Position rounded-up to nearest pixel
|
||||
ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
|
||||
@@ -606,7 +687,7 @@ struct IMGUI_API ImGuiWindow
|
||||
ImVec2 SizeContentsExplicit; // Size of contents explicitly set by the user via SetNextWindowContentSize()
|
||||
ImRect ContentsRegionRect; // Maximum visible content position in window coordinates. ~~ (SizeContentsExplicit ? SizeContentsExplicit : Size - ScrollbarSizes) - CursorStartPos, per axis
|
||||
ImVec2 WindowPadding; // Window padding at the time of begin. We need to lock it, in particular manipulation of the ShowBorder would have an effect
|
||||
ImGuiID MoveID; // == window->GetID("#MOVE")
|
||||
ImGuiID MoveId; // == window->GetID("#MOVE")
|
||||
ImVec2 Scroll;
|
||||
ImVec2 ScrollTarget; // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change)
|
||||
ImVec2 ScrollTargetCenterRatio; // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
|
||||
@@ -617,33 +698,37 @@ struct IMGUI_API ImGuiWindow
|
||||
bool WasActive;
|
||||
bool Accessed; // Set to true when any widget access the current window
|
||||
bool Collapsed; // Set when collapsing window to become only title-bar
|
||||
bool SkipItems; // == Visible && !Collapsed
|
||||
bool SkipItems; // Set when items can safely be all clipped (e.g. window not visible or collapsed)
|
||||
bool Appearing; // Set during the frame where the window is appearing (or re-appearing)
|
||||
int BeginCount; // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
|
||||
ImGuiID PopupID; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
|
||||
ImGuiID PopupId; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
|
||||
int AutoFitFramesX, AutoFitFramesY;
|
||||
bool AutoFitOnlyGrows;
|
||||
int AutoFitChildAxises;
|
||||
int AutoPosLastDirection;
|
||||
int HiddenFrames;
|
||||
int SetWindowPosAllowFlags; // bit ImGuiSetCond_*** specify if SetWindowPos() call will succeed with this particular flag.
|
||||
int SetWindowSizeAllowFlags; // bit ImGuiSetCond_*** specify if SetWindowSize() call will succeed with this particular flag.
|
||||
int SetWindowCollapsedAllowFlags; // bit ImGuiSetCond_*** specify if SetWindowCollapsed() call will succeed with this particular flag.
|
||||
bool SetWindowPosCenterWanted;
|
||||
ImGuiCond SetWindowPosAllowFlags; // store condition flags for next SetWindowPos() call.
|
||||
ImGuiCond SetWindowSizeAllowFlags; // store condition flags for next SetWindowSize() call.
|
||||
ImGuiCond SetWindowCollapsedAllowFlags; // store condition flags for next SetWindowCollapsed() call.
|
||||
ImVec2 SetWindowPosVal; // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size)
|
||||
ImVec2 SetWindowPosPivot; // store window pivot for positioning. ImVec2(0,0) when positioning from top-left corner; ImVec2(0.5f,0.5f) for centering; ImVec2(1,1) for bottom right.
|
||||
|
||||
ImGuiDrawContext DC; // Temporary per-window data, reset at the beginning of the frame
|
||||
ImVector<ImGuiID> IDStack; // ID stack. ID are hashes seeded with the value at the top of the stack
|
||||
ImRect ClipRect; // = DrawList->clip_rect_stack.back(). Scissoring / clipping rectangle. x1, y1, x2, y2.
|
||||
ImRect WindowRectClipped; // = WindowRect just after setup in Begin(). == window->Rect() for root window.
|
||||
ImRect InnerRect;
|
||||
int LastFrameActive;
|
||||
float ItemWidthDefault;
|
||||
ImGuiSimpleColumns MenuColumns; // Simplified columns storage for menu items
|
||||
ImGuiStorage StateStorage;
|
||||
float FontWindowScale; // Scale multiplier per-window
|
||||
ImDrawList* DrawList;
|
||||
ImGuiWindow* RootWindow; // If we are a child window, this is pointing to the first non-child parent window. Else point to ourself.
|
||||
ImGuiWindow* RootNonPopupWindow; // If we are a child window, this is pointing to the first non-child non-popup parent window. Else point to ourself.
|
||||
ImGuiWindow* ParentWindow; // If we are a child window, this is pointing to our parent window. Else point to NULL.
|
||||
ImGuiWindow* ParentWindow; // Immediate parent in the window stack *regardless* of whether this window is a child window or not)
|
||||
ImGuiWindow* RootWindow; // Generally point to ourself. If we are a child window, this is pointing to the first non-child parent window.
|
||||
ImGuiWindow* RootNonPopupWindow; // Generally point to ourself. Used to display TitleBgActive color and for selecting which window to use for NavWindowing
|
||||
|
||||
// Focus
|
||||
// Navigation / Focus
|
||||
int FocusIdxAllCounter; // Start at -1 and increase as assigned via FocusItemRegister()
|
||||
int FocusIdxTabCounter; // (same, but only count widgets which you can Tab through)
|
||||
int FocusIdxAllRequestCurrent; // Item being requested for focus
|
||||
@@ -657,6 +742,7 @@ public:
|
||||
|
||||
ImGuiID GetID(const char* str, const char* str_end = NULL);
|
||||
ImGuiID GetID(const void* ptr);
|
||||
ImGuiID GetIDNoKeepAlive(const char* str, const char* str_end = NULL);
|
||||
|
||||
ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x+Size.x, Pos.y+Size.y); }
|
||||
float CalcFontSize() const { return GImGui->FontBaseSize * FontWindowScale; }
|
||||
@@ -666,6 +752,17 @@ public:
|
||||
ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }
|
||||
};
|
||||
|
||||
// Backup and restore just enough data to be able to use IsItemHovered() on item A after another B in the same window has overwritten the data.
|
||||
struct ImGuiItemHoveredDataBackup
|
||||
{
|
||||
ImGuiID LastItemId;
|
||||
ImRect LastItemRect;
|
||||
bool LastItemRectHoveredRect;
|
||||
|
||||
void Backup() { ImGuiWindow* window = GImGui->CurrentWindow; LastItemId = window->DC.LastItemId; LastItemRect = window->DC.LastItemRect; LastItemRectHoveredRect = window->DC.LastItemRectHoveredRect; }
|
||||
void Restore() { ImGuiWindow* window = GImGui->CurrentWindow; window->DC.LastItemId = LastItemId; window->DC.LastItemRect = LastItemRect; window->DC.LastItemRectHoveredRect = LastItemRectHoveredRect; }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Internal API
|
||||
// No guarantee of forward compatibility here.
|
||||
@@ -683,37 +780,59 @@ namespace ImGui
|
||||
IMGUI_API ImGuiWindow* FindWindowByName(const char* name);
|
||||
IMGUI_API void FocusWindow(ImGuiWindow* window);
|
||||
|
||||
IMGUI_API void Initialize();
|
||||
IMGUI_API void EndFrame(); // Ends the ImGui frame. Automatically called by Render()! you most likely don't need to ever call that yourself directly. If you don't need to render you can call EndFrame() but you'll have wasted CPU already. If you don't need to render, don't create any windows instead!
|
||||
|
||||
IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window);
|
||||
IMGUI_API void ClearActiveID();
|
||||
IMGUI_API void SetHoveredID(ImGuiID id);
|
||||
IMGUI_API void KeepAliveID(ImGuiID id);
|
||||
|
||||
IMGUI_API void ItemSize(const ImVec2& size, float text_offset_y = 0.0f);
|
||||
IMGUI_API void ItemSize(const ImRect& bb, float text_offset_y = 0.0f);
|
||||
IMGUI_API bool ItemAdd(const ImRect& bb, const ImGuiID* id);
|
||||
IMGUI_API bool IsClippedEx(const ImRect& bb, const ImGuiID* id, bool clip_even_when_logged);
|
||||
IMGUI_API bool IsHovered(const ImRect& bb, ImGuiID id, bool flatten_childs = false);
|
||||
IMGUI_API bool FocusableItemRegister(ImGuiWindow* window, bool is_active, bool tab_stop = true); // Return true if focus is requested
|
||||
IMGUI_API bool ItemAdd(const ImRect& bb, ImGuiID id);
|
||||
IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id);
|
||||
IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged);
|
||||
IMGUI_API bool FocusableItemRegister(ImGuiWindow* window, ImGuiID id, bool tab_stop = true); // Return true if focus is requested
|
||||
IMGUI_API void FocusableItemUnregister(ImGuiWindow* window);
|
||||
IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_x, float default_y);
|
||||
IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
|
||||
IMGUI_API void PushMultiItemsWidths(int components, float width_full = 0.0f);
|
||||
IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled);
|
||||
IMGUI_API void PopItemFlag();
|
||||
|
||||
IMGUI_API void OpenPopupEx(const char* str_id, bool reopen_existing);
|
||||
IMGUI_API void OpenPopupEx(ImGuiID id, bool reopen_existing);
|
||||
IMGUI_API void ClosePopup(ImGuiID id);
|
||||
IMGUI_API bool IsPopupOpen(ImGuiID id);
|
||||
IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags);
|
||||
IMGUI_API void BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip = true);
|
||||
|
||||
inline IMGUI_API ImU32 GetColorU32(ImGuiCol idx, float alpha_mul) { ImVec4 c = GImGui->Style.Colors[idx]; c.w *= GImGui->Style.Alpha * alpha_mul; return ImGui::ColorConvertFloat4ToU32(c); }
|
||||
inline IMGUI_API ImU32 GetColorU32(const ImVec4& col) { ImVec4 c = col; c.w *= GImGui->Style.Alpha; return ImGui::ColorConvertFloat4ToU32(c); }
|
||||
IMGUI_API int CalcTypematicPressedRepeatAmount(float t, float t_prev, float repeat_delay, float repeat_rate);
|
||||
|
||||
// NB: All position are in absolute pixels coordinates (not window coordinates)
|
||||
// FIXME: All those functions are a mess and needs to be refactored into something decent. Avoid use outside of imgui.cpp!
|
||||
// We need: a sort of symbol library, preferably baked into font atlas when possible + decent text rendering helpers.
|
||||
IMGUI_API void Scrollbar(ImGuiLayoutType direction);
|
||||
IMGUI_API void VerticalSeparator(); // Vertical separator, for menu bars (use current line height). not exposed because it is misleading what it doesn't have an effect on regular layout.
|
||||
|
||||
// FIXME-WIP: New Columns API
|
||||
IMGUI_API void BeginColumns(const char* id, int count, ImGuiColumnsFlags flags = 0); // setup number of columns. use an identifier to distinguish multiple column sets. close with EndColumns().
|
||||
IMGUI_API void EndColumns(); // close columns
|
||||
IMGUI_API void PushColumnClipRect(int column_index = -1);
|
||||
|
||||
// FIXME-WIP: New Combo API
|
||||
IMGUI_API bool BeginCombo(const char* label, const char* preview_value, ImVec2 popup_size = ImVec2(0.0f,0.0f));
|
||||
IMGUI_API void EndCombo();
|
||||
|
||||
// NB: All position are in absolute pixels coordinates (never using window coordinates internally)
|
||||
// AVOID USING OUTSIDE OF IMGUI.CPP! NOT FOR PUBLIC CONSUMPTION. THOSE FUNCTIONS ARE A MESS. THEIR SIGNATURE AND BEHAVIOR WILL CHANGE, THEY NEED TO BE REFACTORED INTO SOMETHING DECENT.
|
||||
IMGUI_API void RenderText(ImVec2 pos, const char* text, const char* text_end = NULL, bool hide_text_after_hash = true);
|
||||
IMGUI_API void RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width);
|
||||
IMGUI_API void RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, ImGuiAlign align = ImGuiAlign_Default, const ImVec2* clip_min = NULL, const ImVec2* clip_max = NULL);
|
||||
IMGUI_API void RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0,0), const ImRect* clip_rect = NULL);
|
||||
IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
|
||||
IMGUI_API void RenderCollapseTriangle(ImVec2 pos, bool is_open, float scale = 1.0f, bool shadow = false);
|
||||
IMGUI_API void RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding = 0.0f);
|
||||
IMGUI_API void RenderColorRectWithAlphaCheckerboard(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding = 0.0f, int rounding_corners_flags = ~0);
|
||||
IMGUI_API void RenderTriangle(ImVec2 pos, ImGuiDir dir, float scale = 1.0f);
|
||||
IMGUI_API void RenderBullet(ImVec2 pos);
|
||||
IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col);
|
||||
IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col, float sz);
|
||||
IMGUI_API void RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding);
|
||||
IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
|
||||
|
||||
IMGUI_API bool ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0);
|
||||
@@ -734,6 +853,9 @@ namespace ImGui
|
||||
IMGUI_API bool InputScalarEx(const char* label, ImGuiDataType data_type, void* data_ptr, void* step_ptr, void* step_fast_ptr, const char* scalar_format, ImGuiInputTextFlags extra_flags);
|
||||
IMGUI_API bool InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label, ImGuiDataType data_type, void* data_ptr, ImGuiID id, int decimal_precision);
|
||||
|
||||
IMGUI_API void ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags);
|
||||
IMGUI_API void ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags);
|
||||
|
||||
IMGUI_API bool TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL);
|
||||
IMGUI_API bool TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0); // Consume previous SetNextTreeNodeOpened() data, if any. May return true when logging
|
||||
IMGUI_API void TreePushRawID(ImGuiID id);
|
||||
@@ -743,8 +865,21 @@ namespace ImGui
|
||||
IMGUI_API int ParseFormatPrecision(const char* fmt, int default_value);
|
||||
IMGUI_API float RoundScalar(float value, int decimal_precision);
|
||||
|
||||
// Shade functions
|
||||
IMGUI_API void ShadeVertsLinearColorGradientKeepAlpha(ImDrawVert* vert_start, ImDrawVert* vert_end, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1);
|
||||
IMGUI_API void ShadeVertsLinearAlphaGradientForLeftToRightText(ImDrawVert* vert_start, ImDrawVert* vert_end, float gradient_p0_x, float gradient_p1_x);
|
||||
|
||||
} // namespace ImGui
|
||||
|
||||
// ImFontAtlas internals
|
||||
IMGUI_API bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas);
|
||||
IMGUI_API void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas);
|
||||
IMGUI_API void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent);
|
||||
IMGUI_API void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* spc);
|
||||
IMGUI_API void ImFontAtlasBuildFinish(ImFontAtlas* atlas);
|
||||
IMGUI_API void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_multiply_factor);
|
||||
IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride);
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// stb_rect_pack.h - v0.08 - public domain - rectangle packing
|
||||
// stb_rect_pack.h - v0.10 - public domain - rectangle packing
|
||||
// Sean Barrett 2014
|
||||
//
|
||||
// Useful for e.g. packing rectangular textures into an atlas.
|
||||
@@ -32,6 +32,8 @@
|
||||
//
|
||||
// Version history:
|
||||
//
|
||||
// 0.10 (2016-10-25) remove cast-away-const to avoid warnings
|
||||
// 0.09 (2016-08-27) fix compiler warnings
|
||||
// 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0)
|
||||
// 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0)
|
||||
// 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort
|
||||
@@ -41,9 +43,9 @@
|
||||
//
|
||||
// LICENSE
|
||||
//
|
||||
// This software is in the public domain. Where that dedication is not
|
||||
// recognized, you are granted a perpetual, irrevocable license to copy,
|
||||
// distribute, and modify this file as you see fit.
|
||||
// This software is dual-licensed to the public domain and under the following
|
||||
// license: you are granted a perpetual, irrevocable license to copy, modify,
|
||||
// publish, and distribute this file as you see fit.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -198,6 +200,12 @@ struct stbrp_context
|
||||
#define STBRP_ASSERT assert
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define STBRP__NOTUSED(v) (void)(v)
|
||||
#else
|
||||
#define STBRP__NOTUSED(v) (void)sizeof(v)
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
STBRP__INIT_skyline = 1
|
||||
@@ -268,12 +276,14 @@ STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height,
|
||||
}
|
||||
|
||||
// find minimum y position if it starts at x1
|
||||
static int stbrp__skyline_find_min_y(stbrp_context *, stbrp_node *first, int x0, int width, int *pwaste)
|
||||
static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste)
|
||||
{
|
||||
//(void)c;
|
||||
stbrp_node *node = first;
|
||||
int x1 = x0 + width;
|
||||
int min_y, visited_width, waste_area;
|
||||
|
||||
STBRP__NOTUSED(c);
|
||||
|
||||
STBRP_ASSERT(first->x <= x0);
|
||||
|
||||
#if 0
|
||||
@@ -501,8 +511,8 @@ static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, i
|
||||
|
||||
static int rect_height_compare(const void *a, const void *b)
|
||||
{
|
||||
stbrp_rect *p = (stbrp_rect *) a;
|
||||
stbrp_rect *q = (stbrp_rect *) b;
|
||||
const stbrp_rect *p = (const stbrp_rect *) a;
|
||||
const stbrp_rect *q = (const stbrp_rect *) b;
|
||||
if (p->h > q->h)
|
||||
return -1;
|
||||
if (p->h < q->h)
|
||||
@@ -512,8 +522,8 @@ static int rect_height_compare(const void *a, const void *b)
|
||||
|
||||
static int rect_width_compare(const void *a, const void *b)
|
||||
{
|
||||
stbrp_rect *p = (stbrp_rect *) a;
|
||||
stbrp_rect *q = (stbrp_rect *) b;
|
||||
const stbrp_rect *p = (const stbrp_rect *) a;
|
||||
const stbrp_rect *q = (const stbrp_rect *) b;
|
||||
if (p->w > q->w)
|
||||
return -1;
|
||||
if (p->w < q->w)
|
||||
@@ -523,8 +533,8 @@ static int rect_width_compare(const void *a, const void *b)
|
||||
|
||||
static int rect_original_order(const void *a, const void *b)
|
||||
{
|
||||
stbrp_rect *p = (stbrp_rect *) a;
|
||||
stbrp_rect *q = (stbrp_rect *) b;
|
||||
const stbrp_rect *p = (const stbrp_rect *) a;
|
||||
const stbrp_rect *q = (const stbrp_rect *) b;
|
||||
return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
// [ImGui] this is a slightly modified version of stb_truetype.h 1.8
|
||||
// [ImGui] this is a slightly modified version of stb_truetype.h 1.9. Those changes would need to be pushed into nothings/sb
|
||||
// [ImGui] - fixed linestart handler when over last character of multi-line buffer + simplified existing code (#588, #815)
|
||||
// [ImGui] - fixed a state corruption/crash bug in stb_text_redo and stb_textedit_discard_redo (#715)
|
||||
// [ImGui] - fixed a crash bug in stb_textedit_discard_redo (#681)
|
||||
// [ImGui] - fixed some minor warnings
|
||||
// [ImGui] - added STB_TEXTEDIT_MOVEWORDLEFT/STB_TEXTEDIT_MOVEWORDRIGHT custom handler (#473)
|
||||
|
||||
// stb_textedit.h - v1.8 - public domain - Sean Barrett
|
||||
// stb_textedit.h - v1.9 - public domain - Sean Barrett
|
||||
// Development of this library was sponsored by RAD Game Tools
|
||||
//
|
||||
// This C header file implements the guts of a multi-line text-editing
|
||||
@@ -35,6 +37,7 @@
|
||||
//
|
||||
// VERSION HISTORY
|
||||
//
|
||||
// 1.9 (2016-08-27) customizable move-by-word
|
||||
// 1.8 (2016-04-02) better keyboard handling when mouse button is down
|
||||
// 1.7 (2015-09-13) change y range handling in case baseline is non-0
|
||||
// 1.6 (2015-04-15) allow STB_TEXTEDIT_memmove
|
||||
@@ -423,10 +426,9 @@ static int stb_text_locate_coord(STB_TEXTEDIT_STRING *str, float x, float y)
|
||||
// check if it's before the end of the line
|
||||
if (x < r.x1) {
|
||||
// search characters in row for one that straddles 'x'
|
||||
k = i;
|
||||
prev_x = r.x0;
|
||||
for (i=0; i < r.num_chars; ++i) {
|
||||
float w = STB_TEXTEDIT_GETWIDTH(str, k, i);
|
||||
for (k=0; k < r.num_chars; ++k) {
|
||||
float w = STB_TEXTEDIT_GETWIDTH(str, i, k);
|
||||
if (x < prev_x+w) {
|
||||
if (x < prev_x+w/2)
|
||||
return k+i;
|
||||
@@ -616,15 +618,16 @@ static void stb_textedit_move_to_last(STB_TEXTEDIT_STRING *str, STB_TexteditStat
|
||||
}
|
||||
|
||||
#ifdef STB_TEXTEDIT_IS_SPACE
|
||||
static int is_word_boundary( STB_TEXTEDIT_STRING *_str, int _idx )
|
||||
static int is_word_boundary( STB_TEXTEDIT_STRING *str, int idx )
|
||||
{
|
||||
return _idx > 0 ? (STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(_str,_idx-1) ) && !STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(_str, _idx) ) ) : 1;
|
||||
return idx > 0 ? (STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str,idx-1) ) && !STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str, idx) ) ) : 1;
|
||||
}
|
||||
|
||||
#ifndef STB_TEXTEDIT_MOVEWORDLEFT
|
||||
static int stb_textedit_move_to_word_previous( STB_TEXTEDIT_STRING *_str, int c )
|
||||
static int stb_textedit_move_to_word_previous( STB_TEXTEDIT_STRING *str, int c )
|
||||
{
|
||||
while( c >= 0 && !is_word_boundary( _str, c ) )
|
||||
--c; // always move at least one character
|
||||
while( c >= 0 && !is_word_boundary( str, c ) )
|
||||
--c;
|
||||
|
||||
if( c < 0 )
|
||||
@@ -636,10 +639,11 @@ static int stb_textedit_move_to_word_previous( STB_TEXTEDIT_STRING *_str, int c
|
||||
#endif
|
||||
|
||||
#ifndef STB_TEXTEDIT_MOVEWORDRIGHT
|
||||
static int stb_textedit_move_to_word_next( STB_TEXTEDIT_STRING *_str, int c )
|
||||
static int stb_textedit_move_to_word_next( STB_TEXTEDIT_STRING *str, int c )
|
||||
{
|
||||
const int len = STB_TEXTEDIT_STRINGLEN(_str);
|
||||
while( c < len && !is_word_boundary( _str, c ) )
|
||||
const int len = STB_TEXTEDIT_STRINGLEN(str);
|
||||
++c; // always move at least one character
|
||||
while( c < len && !is_word_boundary( str, c ) )
|
||||
++c;
|
||||
|
||||
if( c > len )
|
||||
@@ -776,7 +780,7 @@ retry:
|
||||
if (STB_TEXT_HAS_SELECTION(state))
|
||||
stb_textedit_move_to_first(state);
|
||||
else {
|
||||
state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor-1);
|
||||
state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor);
|
||||
stb_textedit_clamp( str, state );
|
||||
}
|
||||
break;
|
||||
@@ -785,7 +789,7 @@ retry:
|
||||
if( !STB_TEXT_HAS_SELECTION( state ) )
|
||||
stb_textedit_prep_selection_at_cursor(state);
|
||||
|
||||
state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor-1);
|
||||
state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor);
|
||||
state->select_end = state->cursor;
|
||||
|
||||
stb_textedit_clamp( str, state );
|
||||
@@ -797,7 +801,7 @@ retry:
|
||||
if (STB_TEXT_HAS_SELECTION(state))
|
||||
stb_textedit_move_to_last(str, state);
|
||||
else {
|
||||
state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor+1);
|
||||
state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor);
|
||||
stb_textedit_clamp( str, state );
|
||||
}
|
||||
break;
|
||||
@@ -806,7 +810,7 @@ retry:
|
||||
if( !STB_TEXT_HAS_SELECTION( state ) )
|
||||
stb_textedit_prep_selection_at_cursor(state);
|
||||
|
||||
state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor+1);
|
||||
state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor);
|
||||
state->select_end = state->cursor;
|
||||
|
||||
stb_textedit_clamp( str, state );
|
||||
@@ -989,58 +993,58 @@ retry:
|
||||
#ifdef STB_TEXTEDIT_K_LINESTART2
|
||||
case STB_TEXTEDIT_K_LINESTART2:
|
||||
#endif
|
||||
case STB_TEXTEDIT_K_LINESTART: {
|
||||
StbFindState find;
|
||||
case STB_TEXTEDIT_K_LINESTART:
|
||||
stb_textedit_clamp(str, state);
|
||||
stb_textedit_move_to_first(state);
|
||||
stb_textedit_find_charpos(&find, str, state->cursor, state->single_line);
|
||||
state->cursor = find.first_char;
|
||||
if (state->single_line)
|
||||
state->cursor = 0;
|
||||
else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE)
|
||||
--state->cursor;
|
||||
state->has_preferred_x = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef STB_TEXTEDIT_K_LINEEND2
|
||||
case STB_TEXTEDIT_K_LINEEND2:
|
||||
#endif
|
||||
case STB_TEXTEDIT_K_LINEEND: {
|
||||
StbFindState find;
|
||||
int n = STB_TEXTEDIT_STRINGLEN(str);
|
||||
stb_textedit_clamp(str, state);
|
||||
stb_textedit_move_to_first(state);
|
||||
stb_textedit_find_charpos(&find, str, state->cursor, state->single_line);
|
||||
|
||||
if (state->single_line)
|
||||
state->cursor = n;
|
||||
else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE)
|
||||
++state->cursor;
|
||||
state->has_preferred_x = 0;
|
||||
state->cursor = find.first_char + find.length;
|
||||
if (find.length > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) == STB_TEXTEDIT_NEWLINE)
|
||||
--state->cursor;
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef STB_TEXTEDIT_K_LINESTART2
|
||||
case STB_TEXTEDIT_K_LINESTART2 | STB_TEXTEDIT_K_SHIFT:
|
||||
#endif
|
||||
case STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT: {
|
||||
StbFindState find;
|
||||
case STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT:
|
||||
stb_textedit_clamp(str, state);
|
||||
stb_textedit_prep_selection_at_cursor(state);
|
||||
stb_textedit_find_charpos(&find, str, state->cursor, state->single_line);
|
||||
state->cursor = state->select_end = find.first_char;
|
||||
if (state->single_line)
|
||||
state->cursor = 0;
|
||||
else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE)
|
||||
--state->cursor;
|
||||
state->select_end = state->cursor;
|
||||
state->has_preferred_x = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef STB_TEXTEDIT_K_LINEEND2
|
||||
case STB_TEXTEDIT_K_LINEEND2 | STB_TEXTEDIT_K_SHIFT:
|
||||
#endif
|
||||
case STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_SHIFT: {
|
||||
StbFindState find;
|
||||
int n = STB_TEXTEDIT_STRINGLEN(str);
|
||||
stb_textedit_clamp(str, state);
|
||||
stb_textedit_prep_selection_at_cursor(state);
|
||||
stb_textedit_find_charpos(&find, str, state->cursor, state->single_line);
|
||||
state->has_preferred_x = 0;
|
||||
state->cursor = find.first_char + find.length;
|
||||
if (find.length > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) == STB_TEXTEDIT_NEWLINE)
|
||||
--state->cursor;
|
||||
if (state->single_line)
|
||||
state->cursor = n;
|
||||
else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE)
|
||||
++state->cursor;
|
||||
state->select_end = state->cursor;
|
||||
state->has_preferred_x = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1095,13 +1099,13 @@ static void stb_textedit_discard_redo(StbUndoState *state)
|
||||
int n = state->undo_rec[k].insert_length, i;
|
||||
// delete n characters from all other records
|
||||
state->redo_char_point = state->redo_char_point + (short) n; // vsnet05
|
||||
STB_TEXTEDIT_memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((size_t)(STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE)));
|
||||
STB_TEXTEDIT_memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((size_t)(STB_TEXTEDIT_UNDOCHARCOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE)));
|
||||
for (i=state->redo_point; i < k; ++i)
|
||||
if (state->undo_rec[i].char_storage >= 0)
|
||||
state->undo_rec[i].char_storage = state->undo_rec[i].char_storage + (short) n; // vsnet05
|
||||
}
|
||||
STB_TEXTEDIT_memmove(state->undo_rec + state->redo_point, state->undo_rec + state->redo_point-1, (size_t) ((size_t)(STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point)*sizeof(state->undo_rec[0])));
|
||||
++state->redo_point;
|
||||
STB_TEXTEDIT_memmove(state->undo_rec + state->redo_point-1, state->undo_rec + state->redo_point, (size_t) ((size_t)(STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point)*sizeof(state->undo_rec[0])));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1259,6 +1263,7 @@ static void stb_text_redo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||
if (r.insert_length) {
|
||||
// easy case: need to insert n characters
|
||||
STB_TEXTEDIT_INSERTCHARS(str, r.where, &s->undo_char[r.char_storage], r.insert_length);
|
||||
s->redo_char_point += r.insert_length;
|
||||
}
|
||||
|
||||
state->cursor = r.where + r.insert_length;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -86,7 +86,10 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) {
|
||||
[]() {
|
||||
const std::vector<SceneGraphNode*>& nodes =
|
||||
OsEng.renderEngine().scene()->allSceneGraphNodes();
|
||||
return std::vector<properties::PropertyOwner*>(nodes.begin(), nodes.end());
|
||||
return std::vector<properties::PropertyOwner*>(
|
||||
nodes.begin(),
|
||||
nodes.end()
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -111,13 +114,20 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) {
|
||||
nodes.end(),
|
||||
[](SceneGraphNode* n) {
|
||||
const std::vector<std::string>& tags = n->tags();
|
||||
auto it = std::find(tags.begin(), tags.end(), "GUI.Interesting");
|
||||
auto it = std::find(
|
||||
tags.begin(),
|
||||
tags.end(),
|
||||
"GUI.Interesting"
|
||||
);
|
||||
return it == tags.end();
|
||||
}
|
||||
),
|
||||
nodes.end()
|
||||
);
|
||||
return std::vector<properties::PropertyOwner*>(nodes.begin(), nodes.end());
|
||||
return std::vector<properties::PropertyOwner*>(
|
||||
nodes.begin(),
|
||||
nodes.end()
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -128,7 +128,10 @@ static void RenderDrawLists(ImDrawData* drawData) {
|
||||
GL_STREAM_DRAW
|
||||
);
|
||||
|
||||
for (const ImDrawCmd* pcmd = cmdList->CmdBuffer.begin(); pcmd != cmdList->CmdBuffer.end(); pcmd++) {
|
||||
for (const ImDrawCmd* pcmd = cmdList->CmdBuffer.begin();
|
||||
pcmd != cmdList->CmdBuffer.end();
|
||||
pcmd++)
|
||||
{
|
||||
if (pcmd->UserCallback) {
|
||||
pcmd->UserCallback(cmdList, pcmd);
|
||||
}
|
||||
@@ -221,16 +224,25 @@ void addScreenSpaceRenderableLocal(std::string texturePath) {
|
||||
}
|
||||
|
||||
const std::string luaTable =
|
||||
"{Type = 'ScreenSpaceImageLocal', TexturePath = openspace.absPath('" + texturePath + "') }";
|
||||
const std::string script = "openspace.registerScreenSpaceRenderable(" + luaTable + ");";
|
||||
OsEng.scriptEngine().queueScript(script, openspace::scripting::ScriptEngine::RemoteScripting::Yes);
|
||||
"{Type = 'ScreenSpaceImageLocal', TexturePath = openspace.absPath('" +
|
||||
texturePath + "') }";
|
||||
const std::string script = "openspace.registerScreenSpaceRenderable(" +
|
||||
luaTable + ");";
|
||||
OsEng.scriptEngine().queueScript(
|
||||
script,
|
||||
openspace::scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
}
|
||||
|
||||
void addScreenSpaceRenderableOnline(std::string texturePath) {
|
||||
const std::string luaTable =
|
||||
"{Type = 'ScreenSpaceImageOnline', TexturePath = '" + texturePath + "' }";
|
||||
const std::string script = "openspace.registerScreenSpaceRenderable(" + luaTable + ");";
|
||||
OsEng.scriptEngine().queueScript(script, openspace::scripting::ScriptEngine::RemoteScripting::Yes);
|
||||
const std::string script = "openspace.registerScreenSpaceRenderable(" +
|
||||
luaTable + ");";
|
||||
OsEng.scriptEngine().queueScript(
|
||||
script,
|
||||
openspace::scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -152,8 +152,6 @@ void GuiIswaComponent::render() {
|
||||
if (cdfOptionValue != cdfOption) {
|
||||
if (cdfOptionValue >= 0) {
|
||||
groupName = cdfs[cdfOptionValue].group;
|
||||
// std::cout << groupName << std::endl;
|
||||
// OsEng.scriptEngine().queueScript("openspace.iswa.removeGroup('"+groupName+"');");
|
||||
}
|
||||
|
||||
std::string path = cdfs[cdfOption].path;
|
||||
|
||||
@@ -47,7 +47,13 @@ namespace {
|
||||
openspace::MissionPhase::Trace t = mission.phaseTrace(currentTime, 0);
|
||||
|
||||
int treeOption = t.empty() ? 0 : ImGuiTreeNodeFlags_DefaultOpen;
|
||||
if (ImGui::TreeNodeEx(("%s" + missionHashname).c_str(), treeOption, "%s", mission.name().c_str())) {
|
||||
if (ImGui::TreeNodeEx(
|
||||
("%s" + missionHashname).c_str(),
|
||||
treeOption,
|
||||
"%s",
|
||||
mission.name().c_str())
|
||||
)
|
||||
{
|
||||
if (!mission.description().empty()) {
|
||||
ImGui::Text("%s", mission.description().c_str());
|
||||
}
|
||||
@@ -64,7 +70,13 @@ namespace {
|
||||
float s = static_cast<float>(startTime.j2000Seconds());
|
||||
float e = static_cast<float>(endTime.j2000Seconds());
|
||||
|
||||
ImGui::SliderFloat(missionHashname.c_str(), &v, s, e, OsEng.timeManager().time().UTC().c_str());
|
||||
ImGui::SliderFloat(
|
||||
missionHashname.c_str(),
|
||||
&v,
|
||||
s,
|
||||
e,
|
||||
OsEng.timeManager().time().UTC().c_str()
|
||||
);
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("%s", endTime.UTC().c_str());
|
||||
|
||||
|
||||
@@ -78,12 +78,14 @@ void GuiParallelComponent::renderClientWithHost() {
|
||||
ImGui::Text("%s", connectionInfo.c_str());
|
||||
renderClientCommon();
|
||||
|
||||
const size_t nTimeKeyframes = OsEng.timeManager().nKeyframes();
|
||||
const size_t nCameraKeyframes = OsEng.navigationHandler().keyframeNavigator().nKeyframes();
|
||||
size_t nTimeKeyframes = OsEng.timeManager().nKeyframes();
|
||||
size_t nCameraKeyframes = OsEng.navigationHandler().keyframeNavigator().nKeyframes();
|
||||
|
||||
std::string timeKeyframeInfo = "TimeKeyframes : " + std::to_string(nTimeKeyframes);
|
||||
std::string cameraKeyframeInfo = "CameraKeyframes : " + std::to_string(nCameraKeyframes);
|
||||
std::string latencyStandardDeviation = "Latency standard deviation: " + std::to_string(parallel.latencyStandardDeviation()) + " s";
|
||||
std::string cameraKeyframeInfo = "CameraKeyframes : " +
|
||||
std::to_string(nCameraKeyframes);
|
||||
std::string latencyStandardDeviation = "Latency standard deviation: " +
|
||||
std::to_string(parallel.latencyStandardDeviation()) + " s";
|
||||
|
||||
const bool resetTimeOffset = ImGui::Button("Reset time offset");
|
||||
|
||||
|
||||
@@ -100,7 +100,8 @@ void GuiPerformanceComponent::render() {
|
||||
bool v = _isEnabled;
|
||||
ImGui::Begin("Performance", &v);
|
||||
_isEnabled = v;
|
||||
PerformanceLayout* layout = OsEng.renderEngine().performanceManager()->performanceData();
|
||||
RenderEngine& re = OsEng.renderEngine();
|
||||
PerformanceLayout* layout = re.performanceManager()->performanceData();
|
||||
|
||||
v = _sceneGraphIsEnabled;
|
||||
ImGui::Checkbox("SceneGraph", &v);
|
||||
@@ -321,7 +322,8 @@ void GuiPerformanceComponent::render() {
|
||||
indices.begin(),
|
||||
indices.end(),
|
||||
[layout](size_t a, size_t b) {
|
||||
return std::string(layout->sceneGraphEntries[a].name) < std::string(layout->sceneGraphEntries[b].name);
|
||||
return std::string(layout->sceneGraphEntries[a].name) <
|
||||
std::string(layout->sceneGraphEntries[b].name);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -124,7 +124,9 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
void renderTree(const TreeNode& node, const std::function<void (openspace::properties::PropertyOwner*)>& renderFunc) {
|
||||
void renderTree(const TreeNode& node,
|
||||
const std::function<void (openspace::properties::PropertyOwner*)>& renderFunc)
|
||||
{
|
||||
if (node.path.empty() || ImGui::TreeNode(node.path.c_str())) {
|
||||
for (const std::unique_ptr<TreeNode>& c : node.children) {
|
||||
renderTree(*c, renderFunc);
|
||||
@@ -144,7 +146,8 @@ namespace {
|
||||
|
||||
namespace openspace::gui {
|
||||
|
||||
GuiPropertyComponent::GuiPropertyComponent(std::string name, UseTreeLayout useTree, IsTopLevelWindow topLevel)
|
||||
GuiPropertyComponent::GuiPropertyComponent(std::string name, UseTreeLayout useTree,
|
||||
IsTopLevelWindow topLevel)
|
||||
: GuiComponent(std::move(name))
|
||||
, _useTreeLayout(useTree)
|
||||
, _currentUseTreeLayout(useTree)
|
||||
@@ -368,7 +371,9 @@ void GuiPropertyComponent::render() {
|
||||
void GuiPropertyComponent::renderProperty(properties::Property* prop,
|
||||
properties::PropertyOwner* owner)
|
||||
{
|
||||
using Func = std::function<void(properties::Property*, const std::string&, IsRegularProperty)>;
|
||||
using Func = std::function<
|
||||
void(properties::Property*, const std::string&, IsRegularProperty)
|
||||
>;
|
||||
static const std::map<std::string, Func> FunctionMapping = {
|
||||
{ "BoolProperty", &renderBoolProperty },
|
||||
{ "DoubleProperty", &renderDoubleProperty},
|
||||
|
||||
@@ -255,7 +255,14 @@ void GuiSpaceTimeComponent::render() {
|
||||
|
||||
|
||||
float deltaTime = static_cast<float>(OsEng.timeManager().time().deltaTime());
|
||||
bool changed = ImGui::SliderFloat("Delta Time", &deltaTime, -100000.f, 100000.f, "%.3f", 5.f);
|
||||
bool changed = ImGui::SliderFloat(
|
||||
"Delta Time",
|
||||
&deltaTime,
|
||||
-100000.f,
|
||||
100000.f,
|
||||
"%.3f",
|
||||
5.f
|
||||
);
|
||||
if (changed) {
|
||||
OsEng.scriptEngine().queueScript(
|
||||
"openspace.time.setDeltaTime(" + std::to_string(deltaTime) + ")",
|
||||
@@ -273,7 +280,10 @@ void GuiSpaceTimeComponent::render() {
|
||||
|
||||
bool isPaused = OsEng.timeManager().time().paused();
|
||||
|
||||
bool pauseChanged = ImGui::Button(isPaused ? "Resume" : "Pause", { ImGui::GetWindowWidth() - 7.5f, 0.f } );
|
||||
bool pauseChanged = ImGui::Button(
|
||||
isPaused ? "Resume" : "Pause",
|
||||
{ ImGui::GetWindowWidth() - 7.5f, 0.f }
|
||||
);
|
||||
if (pauseChanged) {
|
||||
OsEng.scriptEngine().queueScript(
|
||||
"openspace.time.togglePause()",
|
||||
|
||||
@@ -109,7 +109,8 @@ protected:
|
||||
|
||||
private:
|
||||
bool readyToRender() const override;
|
||||
bool downloadTextureResource(double timestamp = OsEng.timeManager().time().j2000Seconds()) override;
|
||||
bool downloadTextureResource(
|
||||
double timestamp = OsEng.timeManager().time().j2000Seconds()) override;
|
||||
};
|
||||
|
||||
} //namespace openspace
|
||||
|
||||
@@ -103,9 +103,23 @@ bool DataPlane::createGeometry() {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); // bind buffer
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(0));
|
||||
glVertexAttribPointer(
|
||||
0,
|
||||
4,
|
||||
GL_FLOAT,
|
||||
GL_FALSE,
|
||||
sizeof(GLfloat) * 6,
|
||||
reinterpret_cast<void*>(0)
|
||||
);
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(sizeof(GLfloat) * 4));
|
||||
glVertexAttribPointer(
|
||||
1,
|
||||
2,
|
||||
GL_FLOAT,
|
||||
GL_FALSE,
|
||||
sizeof(GLfloat) * 6,
|
||||
reinterpret_cast<void*>(sizeof(GLfloat) * 4)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -155,14 +169,19 @@ std::vector<float*> DataPlane::textureData(){
|
||||
std::chrono::time_point<std::chrono::system_clock> start, end;
|
||||
start = std::chrono::system_clock::now();
|
||||
// ===========
|
||||
std::vector<float*> d = _dataProcessor->processData(_dataBuffer, _dataOptions, _textureDimensions);
|
||||
std::vector<float*> d = _dataProcessor->processData(
|
||||
_dataBuffer,
|
||||
_dataOptions,
|
||||
_textureDimensions
|
||||
);
|
||||
|
||||
// FOR TESTING
|
||||
// ===========
|
||||
end = std::chrono::system_clock::now();
|
||||
_numOfBenchmarks++;
|
||||
std::chrono::duration<double> elapsed_seconds = end-start;
|
||||
_avgBenchmarkTime = ( (_avgBenchmarkTime * (_numOfBenchmarks-1)) + elapsed_seconds.count() ) / _numOfBenchmarks;
|
||||
_avgBenchmarkTime = ((_avgBenchmarkTime * (_numOfBenchmarks - 1))
|
||||
+ elapsed_seconds.count()) / _numOfBenchmarks;
|
||||
std::cout << " processData() " << name() << std::endl;
|
||||
std::cout << "avg elapsed time: " << _avgBenchmarkTime << "s\n";
|
||||
std::cout << "num Benchmarks: " << _numOfBenchmarks << "\n";
|
||||
@@ -171,4 +190,4 @@ std::vector<float*> DataPlane::textureData(){
|
||||
return d;
|
||||
}
|
||||
|
||||
}// namespace openspace
|
||||
} // namespace openspace
|
||||
|
||||
@@ -108,12 +108,18 @@ std::shared_ptr<ghoul::Event<ghoul::Dictionary> > IswaBaseGroup::groupEvent() {
|
||||
void IswaBaseGroup::registerProperties(){
|
||||
_enabled.onChange([this]{
|
||||
LDEBUG("Group " + name() + " published enabledChanged");
|
||||
_groupEvent->publish("enabledChanged", ghoul::Dictionary({{"enabled", _enabled.value()}}));
|
||||
_groupEvent->publish(
|
||||
"enabledChanged",
|
||||
ghoul::Dictionary({{"enabled", _enabled.value()}})
|
||||
);
|
||||
});
|
||||
|
||||
_alpha.onChange([this]{
|
||||
LDEBUG("Group " + name() + " published alphaChanged");
|
||||
_groupEvent->publish("alphaChanged", ghoul::Dictionary({{"alpha", _alpha.value()}}));
|
||||
_groupEvent->publish(
|
||||
"alphaChanged",
|
||||
ghoul::Dictionary({{"alpha", _alpha.value()}})
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -118,7 +118,8 @@ protected:
|
||||
* this should be the data file.
|
||||
* @return true if update was successfull
|
||||
*/
|
||||
virtual bool downloadTextureResource(double timestamp = OsEng.timeManager().time().j2000Seconds()) = 0;
|
||||
virtual bool downloadTextureResource(
|
||||
double timestamp = OsEng.timeManager().time().j2000Seconds()) = 0;
|
||||
virtual bool readyToRender() const = 0;
|
||||
/**
|
||||
* should set all uniforms needed to render
|
||||
|
||||
@@ -122,12 +122,18 @@ void IswaDataGroup::registerProperties(){
|
||||
|
||||
_useLog.onChange([this]{
|
||||
LDEBUG("Group " + name() + " published useLogChanged");
|
||||
_groupEvent->publish("useLogChanged", ghoul::Dictionary({{"useLog", _useLog.value()}}));
|
||||
_groupEvent->publish(
|
||||
"useLogChanged",
|
||||
ghoul::Dictionary({{"useLog", _useLog.value()}})
|
||||
);
|
||||
});
|
||||
|
||||
_useHistogram.onChange([this]{
|
||||
LDEBUG("Group " + name() + " published useHistogramChanged");
|
||||
_groupEvent->publish("useHistogramChanged", ghoul::Dictionary({{"useHistogram", _useHistogram.value()}}));
|
||||
_groupEvent->publish(
|
||||
"useHistogramChanged",
|
||||
ghoul::Dictionary({{"useHistogram", _useHistogram.value()}})
|
||||
);
|
||||
});
|
||||
|
||||
//If autofiler is on, background values property should be hidden
|
||||
@@ -144,22 +150,34 @@ void IswaDataGroup::registerProperties(){
|
||||
_backgroundValues.setVisibility(properties::Property::Visibility::All);
|
||||
//_backgroundValues.setVisible(true);
|
||||
}
|
||||
_groupEvent->publish("autoFilterChanged", ghoul::Dictionary({{"autoFilter", _autoFilter.value()}}));
|
||||
_groupEvent->publish(
|
||||
"autoFilterChanged",
|
||||
ghoul::Dictionary({{"autoFilter", _autoFilter.value()}})
|
||||
);
|
||||
});
|
||||
|
||||
_normValues.onChange([this]{
|
||||
LDEBUG("Group " + name() + " published normValuesChanged");
|
||||
_groupEvent->publish("normValuesChanged", ghoul::Dictionary({{"normValues", _normValues.value()}}));
|
||||
_groupEvent->publish(
|
||||
"normValuesChanged",
|
||||
ghoul::Dictionary({{"normValues", _normValues.value()}})
|
||||
);
|
||||
});
|
||||
|
||||
_backgroundValues.onChange([this]{
|
||||
LDEBUG("Group " + name() + " published backgroundValuesChanged");
|
||||
_groupEvent->publish("backgroundValuesChanged", ghoul::Dictionary({{"backgroundValues", _backgroundValues.value()}}));
|
||||
_groupEvent->publish(
|
||||
"backgroundValuesChanged",
|
||||
ghoul::Dictionary({{"backgroundValues", _backgroundValues.value()}})
|
||||
);
|
||||
});
|
||||
|
||||
_transferFunctionsFile.onChange([this]{
|
||||
LDEBUG("Group " + name() + " published transferFunctionsChanged");
|
||||
_groupEvent->publish("transferFunctionsChanged", ghoul::Dictionary({{"transferFunctions", _transferFunctionsFile.value()}}));
|
||||
_groupEvent->publish(
|
||||
"transferFunctionsChanged",
|
||||
ghoul::Dictionary({{"transferFunctions", _transferFunctionsFile.value()}})
|
||||
);
|
||||
});
|
||||
|
||||
_dataOptions.onChange([this]{
|
||||
@@ -170,29 +188,32 @@ void IswaDataGroup::registerProperties(){
|
||||
});
|
||||
}
|
||||
|
||||
void IswaDataGroup::registerOptions(const std::vector<properties::SelectionProperty::Option>& options){
|
||||
if(!_registered)
|
||||
void IswaDataGroup::registerOptions(
|
||||
const std::vector<properties::SelectionProperty::Option>& options)
|
||||
{
|
||||
if (!_registered) {
|
||||
registerProperties();
|
||||
}
|
||||
|
||||
if(_dataOptions.options().empty()){
|
||||
for(auto option : options){
|
||||
if (_dataOptions.options().empty()) {
|
||||
for (auto option : options) {
|
||||
_dataOptions.addOption({option.value, option.description});
|
||||
}
|
||||
_dataOptions.setValue(std::vector<int>(1,0));
|
||||
}
|
||||
}
|
||||
|
||||
void IswaDataGroup::createDataProcessor(){
|
||||
if(_type == typeid(DataPlane).name()){
|
||||
void IswaDataGroup::createDataProcessor() {
|
||||
if (_type == typeid(DataPlane).name()) {
|
||||
_dataProcessor = std::make_shared<DataProcessorText>();
|
||||
}else if(_type == typeid(DataSphere).name()){
|
||||
}else if (_type == typeid(DataSphere).name()) {
|
||||
_dataProcessor = std::make_shared<DataProcessorJson>();
|
||||
}else if(_type == typeid(KameleonPlane).name()){
|
||||
}else if (_type == typeid(KameleonPlane).name()) {
|
||||
_dataProcessor = std::make_shared<DataProcessorKameleon>();
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<int> IswaDataGroup::dataOptionsValue(){
|
||||
std::vector<int> IswaDataGroup::dataOptionsValue() {
|
||||
return _dataOptions.value();
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@ public:
|
||||
IswaDataGroup(std::string name, std::string type);
|
||||
~IswaDataGroup();
|
||||
|
||||
void registerOptions(const std::vector<properties::SelectionProperty::Option>& options);
|
||||
void registerOptions(
|
||||
const std::vector<properties::SelectionProperty::Option>& options);
|
||||
std::vector<int> dataOptionsValue();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -66,14 +66,14 @@ IswaKameleonGroup::IswaKameleonGroup(std::string name, std::string type)
|
||||
registerProperties();
|
||||
}
|
||||
|
||||
IswaKameleonGroup::~IswaKameleonGroup(){}
|
||||
IswaKameleonGroup::~IswaKameleonGroup() {}
|
||||
|
||||
void IswaKameleonGroup::clearGroup(){
|
||||
void IswaKameleonGroup::clearGroup() {
|
||||
IswaBaseGroup::clearGroup();
|
||||
clearFieldlines();
|
||||
}
|
||||
|
||||
std::vector<int> IswaKameleonGroup::fieldlineValue(){
|
||||
std::vector<int> IswaKameleonGroup::fieldlineValue() {
|
||||
return _fieldlines.value();
|
||||
}
|
||||
|
||||
@@ -148,13 +148,18 @@ void IswaKameleonGroup::readFieldlinePaths(std::string indexFile) {
|
||||
}
|
||||
}
|
||||
|
||||
void IswaKameleonGroup::updateFieldlineSeeds(){
|
||||
void IswaKameleonGroup::updateFieldlineSeeds() {
|
||||
std::vector<int> selectedOptions = _fieldlines.value();
|
||||
|
||||
// SeedPath == map<int selectionValue, tuple< string name, string path, bool active > >
|
||||
for (auto& seedPath: _fieldlineState) {
|
||||
// SeedPath == map<int selectionValue, tuple<string name, string path, bool active>>
|
||||
for (auto& seedPath : _fieldlineState) {
|
||||
// if this option was turned off
|
||||
if (std::find(selectedOptions.begin(), selectedOptions.end(), seedPath.first)==selectedOptions.end() && std::get<2>(seedPath.second)){
|
||||
auto it = std::find(
|
||||
selectedOptions.begin(),
|
||||
selectedOptions.end(),
|
||||
seedPath.first
|
||||
);
|
||||
if (it == selectedOptions.end() && std::get<2>(seedPath.second)) {
|
||||
LDEBUG("Removed fieldlines: " + std::get<0>(seedPath.second));
|
||||
OsEng.scriptEngine().queueScript(
|
||||
"openspace.removeSceneGraphNode('" + std::get<0>(seedPath.second) + "')",
|
||||
@@ -162,17 +167,20 @@ void IswaKameleonGroup::updateFieldlineSeeds(){
|
||||
);
|
||||
std::get<2>(seedPath.second) = false;
|
||||
// if this option was turned on
|
||||
} else if( std::find(selectedOptions.begin(), selectedOptions.end(), seedPath.first)!=selectedOptions.end() && !std::get<2>(seedPath.second)) {
|
||||
} else if (it != selectedOptions.end() && !std::get<2>(seedPath.second)) {
|
||||
LDEBUG("Created fieldlines: " + std::get<0>(seedPath.second));
|
||||
IswaManager::ref().createFieldline(std::get<0>(seedPath.second), _kameleonPath, std::get<1>(seedPath.second));
|
||||
IswaManager::ref().createFieldline(
|
||||
std::get<0>(seedPath.second),
|
||||
_kameleonPath,
|
||||
std::get<1>(seedPath.second)
|
||||
);
|
||||
std::get<2>(seedPath.second) = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IswaKameleonGroup::clearFieldlines(){
|
||||
// SeedPath == map<int selectionValue, tuple< string name, string path, bool active > >
|
||||
for (auto& seedPath: _fieldlineState) {
|
||||
void IswaKameleonGroup::clearFieldlines() {
|
||||
for (auto& seedPath : _fieldlineState) {
|
||||
if(std::get<2>(seedPath.second)){
|
||||
LDEBUG("Removed fieldlines: " + std::get<0>(seedPath.second));
|
||||
OsEng.scriptEngine().queueScript(
|
||||
@@ -184,7 +192,7 @@ void IswaKameleonGroup::clearFieldlines(){
|
||||
}
|
||||
}
|
||||
|
||||
void IswaKameleonGroup::changeCdf(std::string path){
|
||||
void IswaKameleonGroup::changeCdf(std::string path) {
|
||||
_kameleonPath = path;
|
||||
clearFieldlines();
|
||||
updateFieldlineSeeds();
|
||||
|
||||
@@ -164,7 +164,9 @@ void KameleonPlane::initialize() {
|
||||
updateFieldlineSeeds();
|
||||
});
|
||||
|
||||
std::dynamic_pointer_cast<DataProcessorKameleon>(_dataProcessor)->dimensions(_dimensions);
|
||||
std::dynamic_pointer_cast<DataProcessorKameleon>(_dataProcessor)->dimensions(
|
||||
_dimensions
|
||||
);
|
||||
_dataProcessor->addDataValues(_kwPath, _dataOptions);
|
||||
// if this datacygnet has added new values then reload texture
|
||||
// for the whole group, including this datacygnet, and return after.
|
||||
@@ -263,11 +265,19 @@ void KameleonPlane::setUniforms() {
|
||||
void KameleonPlane::updateFieldlineSeeds() {
|
||||
std::vector<int> selectedOptions = _fieldlines.value();
|
||||
|
||||
// SeedPath == map<int selectionValue, tuple< string name, string path, bool active > >
|
||||
for (auto& seedPath: _fieldlineState) {
|
||||
// SeedPath == map<int selectionValue, tuple<string name, string path, bool active>>
|
||||
for (auto& seedPath : _fieldlineState) {
|
||||
// if this option was turned off
|
||||
if (std::find(selectedOptions.begin(), selectedOptions.end(), seedPath.first)==selectedOptions.end() && std::get<2>(seedPath.second)) {
|
||||
if (OsEng.renderEngine().scene()->sceneGraphNode(std::get<0>(seedPath.second)) == nullptr) {
|
||||
auto it = std::find(
|
||||
selectedOptions.begin(),
|
||||
selectedOptions.end(),
|
||||
seedPath.first
|
||||
);
|
||||
if (it == selectedOptions.end() && std::get<2>(seedPath.second)) {
|
||||
SceneGraphNode* n = OsEng.renderEngine().scene()->sceneGraphNode(
|
||||
std::get<0>(seedPath.second)
|
||||
);
|
||||
if (!n) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -278,12 +288,20 @@ void KameleonPlane::updateFieldlineSeeds() {
|
||||
);
|
||||
std::get<2>(seedPath.second) = false;
|
||||
// if this option was turned on
|
||||
} else if (std::find(selectedOptions.begin(), selectedOptions.end(), seedPath.first)!=selectedOptions.end() && !std::get<2>(seedPath.second)) {
|
||||
if (OsEng.renderEngine().scene()->sceneGraphNode(std::get<0>(seedPath.second)) != nullptr) {
|
||||
} else if (it != selectedOptions.end() && !std::get<2>(seedPath.second)) {
|
||||
SceneGraphNode* n = OsEng.renderEngine().scene()->sceneGraphNode(
|
||||
std::get<0>(seedPath.second)
|
||||
);
|
||||
|
||||
if (n) {
|
||||
return;
|
||||
}
|
||||
LDEBUG("Created fieldlines: " + std::get<0>(seedPath.second));
|
||||
IswaManager::ref().createFieldline(std::get<0>(seedPath.second), _kwPath, std::get<1>(seedPath.second));
|
||||
IswaManager::ref().createFieldline(
|
||||
std::get<0>(seedPath.second),
|
||||
_kwPath,
|
||||
std::get<1>(seedPath.second)
|
||||
);
|
||||
std::get<2>(seedPath.second) = true;
|
||||
}
|
||||
}
|
||||
@@ -321,7 +339,10 @@ void KameleonPlane::readFieldlinePaths(std::string indexFile) {
|
||||
i++;
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
LERROR("Error when reading json file with paths to seedpoints: " + std::string(e.what()));
|
||||
LERROR(
|
||||
"Error when reading json file with paths to seedpoints: " +
|
||||
std::string(e.what())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -332,7 +353,7 @@ void KameleonPlane::subscribeToGroup() {
|
||||
|
||||
//Add additional Events specific to KameleonPlane
|
||||
auto groupEvent = _group->groupEvent();
|
||||
groupEvent->subscribe(name(), "resolutionChanged", [&](ghoul::Dictionary dict){
|
||||
groupEvent->subscribe(name(), "resolutionChanged", [&](ghoul::Dictionary dict) {
|
||||
LDEBUG(name() + " Event resolutionChanged");
|
||||
float resolution;
|
||||
bool success = dict.getValue("resolution", resolution);
|
||||
@@ -341,7 +362,7 @@ void KameleonPlane::subscribeToGroup() {
|
||||
}
|
||||
});
|
||||
|
||||
groupEvent->subscribe(name(), "cdfChanged", [&](ghoul::Dictionary dict){
|
||||
groupEvent->subscribe(name(), "cdfChanged", [&](ghoul::Dictionary dict) {
|
||||
LDEBUG(name() + " Event cdfChanged");
|
||||
std::string path;
|
||||
bool success = dict.getValue("path", path);
|
||||
@@ -355,8 +376,8 @@ void KameleonPlane::subscribeToGroup() {
|
||||
void KameleonPlane::setDimensions() {
|
||||
// the cdf files has an offset of 0.5 in normali resolution.
|
||||
// with lower resolution the offset increases.
|
||||
_data->offset = _origOffset - 0.5f*(100.0f/_resolution.value());
|
||||
_dimensions = glm::size3_t(_data->scale*((float)_resolution.value()/100.f));
|
||||
_data->offset = _origOffset - 0.5f* (100.f / _resolution.value());
|
||||
_dimensions = glm::size3_t(_data->scale * ((float)_resolution.value() / 100.f));
|
||||
_dimensions[_cut] = 1;
|
||||
|
||||
if (_cut == 0) {
|
||||
|
||||
@@ -93,8 +93,10 @@ private:
|
||||
|
||||
/**
|
||||
* _fieldlineState maps the checkbox value of each fieldline seedpoint file to a tuple
|
||||
* containing information that is needed to either add or remove a fieldline from the scenegraph.
|
||||
* this is the name, path to seedpoints file and a boolean to determine if it is active or inactive.
|
||||
* containing information that is needed to either add or remove a fieldline from the
|
||||
* scenegraph.
|
||||
* This is the name, path to seedpoints file and a boolean to determine if it is
|
||||
* active or inactive.
|
||||
*/
|
||||
std::map<int, std::tuple<std::string, std::string, bool> > _fieldlineState;
|
||||
std::string _fieldlineIndexFile;
|
||||
|
||||
@@ -53,7 +53,9 @@ ScreenSpaceCygnet::ScreenSpaceCygnet(const ghoul::Dictionary& dictionary)
|
||||
_openSpaceTime = OsEng.timeManager().time().j2000Seconds();
|
||||
_lastUpdateOpenSpaceTime = _openSpaceTime;
|
||||
|
||||
_realTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch());
|
||||
_realTime = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch()
|
||||
);
|
||||
_lastUpdateRealTime = _realTime;
|
||||
_minRealTimeUpdateInterval = 100;
|
||||
|
||||
@@ -67,16 +69,19 @@ ScreenSpaceCygnet::ScreenSpaceCygnet(const ghoul::Dictionary& dictionary)
|
||||
|
||||
}
|
||||
|
||||
ScreenSpaceCygnet::~ScreenSpaceCygnet(){}
|
||||
ScreenSpaceCygnet::~ScreenSpaceCygnet() {}
|
||||
|
||||
void ScreenSpaceCygnet::update(){
|
||||
void ScreenSpaceCygnet::update() {
|
||||
_openSpaceTime = OsEng.timeManager().time().j2000Seconds();
|
||||
_realTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch());
|
||||
_realTime = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch()
|
||||
);
|
||||
|
||||
bool timeToUpdate = (fabs(_openSpaceTime-_lastUpdateOpenSpaceTime) >= _updateTime &&
|
||||
(_realTime.count()-_lastUpdateRealTime.count()) > _minRealTimeUpdateInterval);
|
||||
bool timeToUpdate =
|
||||
(fabs(_openSpaceTime-_lastUpdateOpenSpaceTime) >= _updateTime &&
|
||||
(_realTime.count()-_lastUpdateRealTime.count()) > _minRealTimeUpdateInterval);
|
||||
|
||||
if((OsEng.timeManager().time().timeJumped() || timeToUpdate )){
|
||||
if ((OsEng.timeManager().time().timeJumped() || timeToUpdate )) {
|
||||
_texturePath = IswaManager::ref().iswaUrl(_cygnetId);
|
||||
_lastUpdateRealTime = _realTime;
|
||||
_lastUpdateOpenSpaceTime = _openSpaceTime;
|
||||
|
||||
@@ -50,7 +50,7 @@ bool TextureCygnet::updateTexture() {
|
||||
if (texture) {
|
||||
LDEBUG("Loaded texture from image iswa cygnet with id: '" << _data->id << "'");
|
||||
texture->uploadTexture();
|
||||
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
|
||||
// Textures of planets looks much smoother with AnisotropicMipMap
|
||||
texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
_textures[0] = std::move(texture);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,8 @@ public:
|
||||
protected:
|
||||
|
||||
bool updateTexture() override;
|
||||
bool downloadTextureResource(double timestamp = OsEng.timeManager().time().j2000Seconds()) override;
|
||||
bool downloadTextureResource(
|
||||
double timestamp = OsEng.timeManager().time().j2000Seconds()) override;
|
||||
bool readyToRender() const override;
|
||||
bool updateTextureResource() override;
|
||||
|
||||
|
||||
@@ -83,9 +83,23 @@ bool TexturePlane::createGeometry() {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); // bind buffer
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(0));
|
||||
glVertexAttribPointer(
|
||||
0,
|
||||
4,
|
||||
GL_FLOAT,
|
||||
GL_FALSE,
|
||||
sizeof(GLfloat) * 6,
|
||||
reinterpret_cast<void*>(0)
|
||||
);
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(sizeof(GLfloat) * 4));
|
||||
glVertexAttribPointer(
|
||||
1,
|
||||
2,
|
||||
GL_FLOAT,
|
||||
GL_FALSE,
|
||||
sizeof(GLfloat) * 6,
|
||||
reinterpret_cast<void*>(sizeof(GLfloat) * 4)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -167,8 +167,18 @@ void DataProcessor::calculateFilterValues(std::vector<int> selectedOptions) {
|
||||
filterMid = histogram->highestBinValue(_useHistogram);
|
||||
filterWidth = mean+histogram->binWidth();
|
||||
|
||||
filterMid = normalizeWithStandardScore(filterMid, mean, standardDeviation, _normValues);
|
||||
filterWidth = fabs(0.5-normalizeWithStandardScore(filterWidth, mean, standardDeviation, _normValues));
|
||||
filterMid = normalizeWithStandardScore(
|
||||
filterMid,
|
||||
mean,
|
||||
standardDeviation,
|
||||
_normValues
|
||||
);
|
||||
filterWidth = fabs(0.5-normalizeWithStandardScore(
|
||||
filterWidth,
|
||||
mean,
|
||||
standardDeviation,
|
||||
_normValues)
|
||||
);
|
||||
} else {
|
||||
Histogram hist = _histograms[option]->equalize();
|
||||
filterMid = hist.highestBinValue(true);
|
||||
@@ -208,13 +218,24 @@ void DataProcessor::add(std::vector<std::vector<float>>& optionValues,
|
||||
float oldMean = (1.0f/_numValues[i])*_sum[i];
|
||||
|
||||
_sum[i] += sum[i];
|
||||
_standardDeviation[i] = sqrt(pow(standardDeviation, 2) + pow(_standardDeviation[i], 2));
|
||||
_standardDeviation[i] = sqrt(pow(standardDeviation, 2) +
|
||||
pow(_standardDeviation[i], 2));
|
||||
_numValues[i] += numValues;
|
||||
|
||||
|
||||
mean = (1.0f/_numValues[i])*_sum[i];
|
||||
float min = normalizeWithStandardScore(_min[i], mean, _standardDeviation[i], _histNormValues);
|
||||
float max = normalizeWithStandardScore(_max[i], mean, _standardDeviation[i], _histNormValues);
|
||||
float min = normalizeWithStandardScore(
|
||||
_min[i],
|
||||
mean,
|
||||
_standardDeviation[i],
|
||||
_histNormValues
|
||||
);
|
||||
float max = normalizeWithStandardScore(
|
||||
_max[i],
|
||||
mean,
|
||||
_standardDeviation[i],
|
||||
_histNormValues
|
||||
);
|
||||
|
||||
if (!_histograms[i]) {
|
||||
_histograms[i] = std::make_shared<Histogram>(min, max, 512);
|
||||
@@ -225,20 +246,50 @@ void DataProcessor::add(std::vector<std::vector<float>>& optionValues,
|
||||
float histMax = _histograms[i]->maxValue();
|
||||
int numBins = _histograms[i]->numBins();
|
||||
|
||||
float unNormHistMin = unnormalizeWithStandardScore(histMin, oldMean, oldStandardDeviation, _histNormValues);
|
||||
float unNormHistMax = unnormalizeWithStandardScore(histMax, oldMean, oldStandardDeviation, _histNormValues);
|
||||
float unNormHistMin = unnormalizeWithStandardScore(
|
||||
histMin,
|
||||
oldMean,
|
||||
oldStandardDeviation,
|
||||
_histNormValues
|
||||
);
|
||||
float unNormHistMax = unnormalizeWithStandardScore(
|
||||
histMax,
|
||||
oldMean,
|
||||
oldStandardDeviation,
|
||||
_histNormValues
|
||||
);
|
||||
//unnormalize histMin, histMax
|
||||
// min = std::min(min, histMin)
|
||||
std::shared_ptr<Histogram> newHist = std::make_shared<Histogram>(
|
||||
std::min(min, normalizeWithStandardScore(unNormHistMin, mean, _standardDeviation[i], _histNormValues)),
|
||||
std::min(max, normalizeWithStandardScore(unNormHistMax, mean, _standardDeviation[i], _histNormValues)),
|
||||
std::min(min, normalizeWithStandardScore(
|
||||
unNormHistMin,
|
||||
mean,
|
||||
_standardDeviation[i],
|
||||
_histNormValues
|
||||
)),
|
||||
std::min(max, normalizeWithStandardScore(
|
||||
unNormHistMax,
|
||||
mean,
|
||||
_standardDeviation[i],
|
||||
_histNormValues
|
||||
)),
|
||||
numBins
|
||||
);
|
||||
|
||||
for (int j = 0; j < numBins; j++) {
|
||||
value = j * (histMax-histMin)+histMin;
|
||||
value = unnormalizeWithStandardScore(value, oldMean, oldStandardDeviation, _histNormValues);
|
||||
_histograms[i]->add(normalizeWithStandardScore(value, mean, _standardDeviation[i], _histNormValues), histData[j]);
|
||||
value = unnormalizeWithStandardScore(
|
||||
value,
|
||||
oldMean,
|
||||
oldStandardDeviation,
|
||||
_histNormValues
|
||||
);
|
||||
_histograms[i]->add(normalizeWithStandardScore(
|
||||
value,
|
||||
mean,
|
||||
_standardDeviation[i],
|
||||
_histNormValues
|
||||
), histData[j]);
|
||||
}
|
||||
// _histograms[i]->changeRange(min, max);
|
||||
_histograms[i] = newHist;
|
||||
@@ -246,7 +297,12 @@ void DataProcessor::add(std::vector<std::vector<float>>& optionValues,
|
||||
|
||||
for (int j = 0; j < numValues; j++) {
|
||||
value = values[j];
|
||||
_histograms[i]->add(normalizeWithStandardScore(value, mean, _standardDeviation[i], _histNormValues), 1);
|
||||
_histograms[i]->add(normalizeWithStandardScore(
|
||||
value,
|
||||
mean,
|
||||
_standardDeviation[i],
|
||||
_histNormValues
|
||||
), 1);
|
||||
}
|
||||
|
||||
_histograms[i]->generateEqualizer();
|
||||
|
||||
@@ -39,9 +39,12 @@ public:
|
||||
DataProcessor();
|
||||
virtual ~DataProcessor();
|
||||
|
||||
virtual std::vector<std::string> readMetadata(std::string data, glm::size3_t& dimensions) = 0;
|
||||
virtual void addDataValues(std::string data, properties::SelectionProperty& dataOptions) = 0;
|
||||
virtual std::vector<float*> processData(std::string data, properties::SelectionProperty& dataOptions, glm::size3_t& dimensions) = 0;
|
||||
virtual std::vector<std::string> readMetadata(std::string data,
|
||||
glm::size3_t& dimensions) = 0;
|
||||
virtual void addDataValues(std::string data,
|
||||
properties::SelectionProperty& dataOptions) = 0;
|
||||
virtual std::vector<float*> processData(std::string data,
|
||||
properties::SelectionProperty& dataOptions, glm::size3_t& dimensions) = 0;
|
||||
|
||||
void useLog(bool useLog);
|
||||
void useHistogram(bool useHistogram);
|
||||
@@ -53,8 +56,10 @@ public:
|
||||
|
||||
protected:
|
||||
float processDataPoint(float value, int option);
|
||||
float normalizeWithStandardScore(float value, float mean, float sd, glm::vec2 normalizationValues = glm::vec2(1.0f, 1.0f));
|
||||
float unnormalizeWithStandardScore(float value, float mean, float sd, glm::vec2 normalizationValues = glm::vec2(1.0f, 1.0f));
|
||||
float normalizeWithStandardScore(float value, float mean, float sd,
|
||||
glm::vec2 normalizationValues = glm::vec2(1.0f, 1.0f));
|
||||
float unnormalizeWithStandardScore(float value, float mean, float sd,
|
||||
glm::vec2 normalizationValues = glm::vec2(1.0f, 1.0f));
|
||||
|
||||
void initializeVectors(int numOptions);
|
||||
void calculateFilterValues(std::vector<int> selectedOptions);
|
||||
|
||||
@@ -40,22 +40,24 @@ DataProcessorJson::DataProcessorJson()
|
||||
|
||||
DataProcessorJson::~DataProcessorJson() {}
|
||||
|
||||
std::vector<std::string> DataProcessorJson::readMetadata(std::string data, glm::size3_t& dimensions){
|
||||
std::vector<std::string> DataProcessorJson::readMetadata(std::string data,
|
||||
glm::size3_t& dimensions)
|
||||
{
|
||||
std::vector<std::string> options = std::vector<std::string>();
|
||||
if(!data.empty()){
|
||||
if (!data.empty()) {
|
||||
json j = json::parse(data);
|
||||
json variables = j["variables"];
|
||||
|
||||
for(json::iterator it = variables.begin(); it != variables.end(); ++it){
|
||||
for (json::iterator it = variables.begin(); it != variables.end(); ++it) {
|
||||
std::string option = it.key();
|
||||
if(option == "ep"){
|
||||
if (option == "ep") {
|
||||
json row = it.value();
|
||||
json col = row.at(0);
|
||||
|
||||
dimensions = glm::size3_t(col.size(), row.size(), 1);
|
||||
}
|
||||
|
||||
if(_coordinateVariables.find(option) == _coordinateVariables.end()){
|
||||
if (_coordinateVariables.find(option) == _coordinateVariables.end()) {
|
||||
options.push_back(option);
|
||||
}
|
||||
}
|
||||
@@ -63,11 +65,13 @@ std::vector<std::string> DataProcessorJson::readMetadata(std::string data, glm::
|
||||
return options;
|
||||
}
|
||||
|
||||
void DataProcessorJson::addDataValues(std::string data, properties::SelectionProperty& dataOptions){
|
||||
void DataProcessorJson::addDataValues(std::string data,
|
||||
properties::SelectionProperty& dataOptions)
|
||||
{
|
||||
int numOptions = dataOptions.options().size();
|
||||
initializeVectors(numOptions);
|
||||
|
||||
if(!data.empty()){
|
||||
if (!data.empty()) {
|
||||
json j = json::parse(data);
|
||||
json variables = j["variables"];
|
||||
|
||||
@@ -77,7 +81,7 @@ void DataProcessorJson::addDataValues(std::string data, properties::SelectionPro
|
||||
|
||||
float value;
|
||||
|
||||
for(int i=0; i<numOptions; i++){
|
||||
for (int i=0; i<numOptions; i++) {
|
||||
json row = variables[options[i].description];
|
||||
// int rowsize = row.size();
|
||||
|
||||
@@ -119,7 +123,7 @@ std::vector<float*> DataProcessorJson::processData(std::string data,
|
||||
|
||||
std::vector<float*> dataOptions(numOptions, nullptr);
|
||||
for(int option : selectedOptions){
|
||||
dataOptions[option] = new float[dimensions.x*dimensions.y]{0.0f};
|
||||
dataOptions[option] = new float[dimensions.x*dimensions.y]{0.f};
|
||||
|
||||
json row = variables[options[option].description];
|
||||
rowsize = row.size();
|
||||
|
||||
@@ -34,9 +34,12 @@ public:
|
||||
DataProcessorJson();
|
||||
virtual ~DataProcessorJson();
|
||||
|
||||
virtual std::vector<std::string> readMetadata(std::string data, glm::size3_t& dimensions) override;
|
||||
virtual void addDataValues(std::string data, properties::SelectionProperty& dataOptions) override;
|
||||
virtual std::vector<float*> processData(std::string data, properties::SelectionProperty& dataOptions, glm::size3_t& dimensions) override;
|
||||
virtual std::vector<std::string> readMetadata(std::string data,
|
||||
glm::size3_t& dimensions) override;
|
||||
virtual void addDataValues(std::string data,
|
||||
properties::SelectionProperty& dataOptions) override;
|
||||
virtual std::vector<float*> processData(std::string data,
|
||||
properties::SelectionProperty& dataOptions, glm::size3_t& dimensions) override;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -42,21 +42,25 @@ DataProcessorKameleon::DataProcessorKameleon()
|
||||
|
||||
DataProcessorKameleon::~DataProcessorKameleon(){}
|
||||
|
||||
std::vector<std::string> DataProcessorKameleon::readMetadata(std::string path, glm::size3_t& dimensions){
|
||||
|
||||
if(!path.empty()){
|
||||
if(path != _kwPath || !_kw){
|
||||
|
||||
std::vector<std::string> DataProcessorKameleon::readMetadata(std::string path,
|
||||
glm::size3_t& dimensions)
|
||||
{
|
||||
if (!path.empty()) {
|
||||
if (path != _kwPath || !_kw) {
|
||||
initializeKameleonWrapper(path);
|
||||
}
|
||||
|
||||
std::vector<std::string> opts = _kw->getVariables();
|
||||
opts.erase( std::remove_if(
|
||||
opts.begin(),
|
||||
opts.end(),
|
||||
[this](std::string opt){ return (opt.size() > 3 || _coordinateVariables.find(opt) != _coordinateVariables.end());}
|
||||
opts.erase(
|
||||
std::remove_if(
|
||||
opts.begin(),
|
||||
opts.end(),
|
||||
[this](std::string opt) {
|
||||
return (opt.size() > 3 ||
|
||||
_coordinateVariables.find(opt) != _coordinateVariables.end());
|
||||
}
|
||||
),
|
||||
opts.end()
|
||||
opts.end()
|
||||
);
|
||||
return opts;
|
||||
}
|
||||
@@ -64,13 +68,16 @@ std::vector<std::string> DataProcessorKameleon::readMetadata(std::string path, g
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
|
||||
void DataProcessorKameleon::addDataValues(std::string path, properties::SelectionProperty& dataOptions){
|
||||
void DataProcessorKameleon::addDataValues(std::string path,
|
||||
properties::SelectionProperty& dataOptions)
|
||||
{
|
||||
int numOptions = dataOptions.options().size();
|
||||
initializeVectors(numOptions);
|
||||
|
||||
if(!path.empty()){
|
||||
if(path != _kwPath || !_kw)
|
||||
if (!path.empty()) {
|
||||
if (path != _kwPath || !_kw) {
|
||||
initializeKameleonWrapper(path);
|
||||
}
|
||||
|
||||
std::vector<float> sum(numOptions, 0.0f);
|
||||
std::vector<std::vector<float>> optionValues(numOptions, std::vector<float>());
|
||||
@@ -81,11 +88,15 @@ void DataProcessorKameleon::addDataValues(std::string path, properties::Selectio
|
||||
float* values;
|
||||
float value;
|
||||
|
||||
for(int i=0; i<numOptions; i++){
|
||||
for (int i=0; i<numOptions; i++) {
|
||||
//0.5 to gather interesting values for the normalization/histograms.
|
||||
values = _kw->getUniformSliceValues(options[i].description, _dimensions, 0.5f);
|
||||
values = _kw->getUniformSliceValues(
|
||||
options[i].description,
|
||||
_dimensions,
|
||||
0.5f
|
||||
);
|
||||
|
||||
for(int j=0; j<numValues; j++){
|
||||
for (int j=0; j<numValues; j++) {
|
||||
value = values[j];
|
||||
|
||||
optionValues[i].push_back(value);
|
||||
@@ -98,18 +109,26 @@ void DataProcessorKameleon::addDataValues(std::string path, properties::Selectio
|
||||
add(optionValues, sum);
|
||||
}
|
||||
}
|
||||
std::vector<float*> DataProcessorKameleon::processData(std::string path, properties::SelectionProperty& dataOptions, glm::size3_t& dimensions, float slice){
|
||||
std::vector<float*> DataProcessorKameleon::processData(std::string path,
|
||||
properties::SelectionProperty& dataOptions,
|
||||
glm::size3_t& dimensions,
|
||||
float slice)
|
||||
{
|
||||
_slice = slice;
|
||||
// _dimensions = dimensions;
|
||||
return processData(path, dataOptions, dimensions);
|
||||
}
|
||||
|
||||
std::vector<float*> DataProcessorKameleon::processData(std::string path, properties::SelectionProperty& dataOptions, glm::size3_t& dimensions){
|
||||
std::vector<float*> DataProcessorKameleon::processData(std::string path,
|
||||
properties::SelectionProperty& dataOptions,
|
||||
glm::size3_t& dimensions)
|
||||
{
|
||||
int numOptions = dataOptions.options().size();
|
||||
|
||||
if(!path.empty()){
|
||||
if(path != _kwPath || !_kw)
|
||||
if (!path.empty()) {
|
||||
if (path != _kwPath || !_kw) {
|
||||
initializeKameleonWrapper(path);
|
||||
}
|
||||
|
||||
std::vector<int> selectedOptions = dataOptions.value();
|
||||
// int numSelected = selectedOptions.size();
|
||||
@@ -122,10 +141,14 @@ std::vector<float*> DataProcessorKameleon::processData(std::string path, propert
|
||||
float value;
|
||||
|
||||
std::vector<float*> dataOptions(numOptions, nullptr);
|
||||
for(int option : selectedOptions){
|
||||
dataOptions[option] = _kw->getUniformSliceValues(options[option].description, dimensions, _slice);
|
||||
for (int option : selectedOptions) {
|
||||
dataOptions[option] = _kw->getUniformSliceValues(
|
||||
options[option].description,
|
||||
dimensions,
|
||||
_slice
|
||||
);
|
||||
|
||||
for(int i=0; i<numValues; i++){
|
||||
for (int i=0; i<numValues; i++) {
|
||||
value = dataOptions[option][i];
|
||||
dataOptions[option][i] = processDataPoint(value, option);
|
||||
}
|
||||
@@ -137,6 +160,10 @@ std::vector<float*> DataProcessorKameleon::processData(std::string path, propert
|
||||
return std::vector<float*>(numOptions, nullptr);
|
||||
}
|
||||
|
||||
void DataProcessorKameleon::dimensions(glm::size3_t dimensions) {
|
||||
_dimensions = dimensions;
|
||||
}
|
||||
|
||||
void DataProcessorKameleon::initializeKameleonWrapper(std::string path){
|
||||
const std::string& extension = ghoul::filesystem::File(absPath(path)).fileExtension();
|
||||
if(FileSys.fileExists(absPath(path)) && extension == "cdf"){
|
||||
|
||||
@@ -35,11 +35,16 @@ public:
|
||||
DataProcessorKameleon();
|
||||
~DataProcessorKameleon();
|
||||
|
||||
virtual std::vector<std::string> readMetadata(std::string path, glm::size3_t& dimensions) override;
|
||||
virtual void addDataValues(std::string data, properties::SelectionProperty& dataOptions) override;
|
||||
virtual std::vector<float*> processData(std::string path, properties::SelectionProperty& dataOptions, glm::size3_t& dimensions) override;
|
||||
virtual std::vector<float*> processData(std::string path, properties::SelectionProperty& dataOptions, glm::size3_t& dimensions, float slice);
|
||||
void dimensions(glm::size3_t dimensions){_dimensions = dimensions;}
|
||||
virtual std::vector<std::string> readMetadata(std::string path,
|
||||
glm::size3_t& dimensions) override;
|
||||
virtual void addDataValues(std::string data,
|
||||
properties::SelectionProperty& dataOptions) override;
|
||||
virtual std::vector<float*> processData(std::string path,
|
||||
properties::SelectionProperty& dataOptions, glm::size3_t& dimensions) override;
|
||||
virtual std::vector<float*> processData(std::string path,
|
||||
properties::SelectionProperty& dataOptions, glm::size3_t& dimensions,
|
||||
float slice);
|
||||
void dimensions(glm::size3_t dimensions);
|
||||
|
||||
private:
|
||||
void initializeKameleonWrapper(std::string kwPath);
|
||||
|
||||
@@ -44,13 +44,16 @@ DataProcessorText::DataProcessorText()
|
||||
|
||||
DataProcessorText::~DataProcessorText(){}
|
||||
|
||||
std::vector<std::string> DataProcessorText::readMetadata(std::string data, glm::size3_t& dimensions){
|
||||
std::vector<std::string> DataProcessorText::readMetadata(std::string data,
|
||||
glm::size3_t& dimensions)
|
||||
{
|
||||
//The intresting part of the file looks like this:
|
||||
//# Output data: field with 61x61=3721 elements
|
||||
//# x y z N V_x B_x
|
||||
|
||||
std::vector<std::string> options = std::vector<std::string>();
|
||||
std::string info = "# Output data: field with "; //The string where the interesting data begins
|
||||
// The string where the interesting data begins
|
||||
std::string info = "# Output data: field with ";
|
||||
if(!data.empty()){
|
||||
std::string line;
|
||||
std::stringstream memorystream(data);
|
||||
@@ -85,15 +88,18 @@ std::vector<std::string> DataProcessorText::readMetadata(std::string data, glm::
|
||||
return options;
|
||||
}
|
||||
|
||||
void DataProcessorText::addDataValues(std::string data, properties::SelectionProperty& dataOptions){
|
||||
void DataProcessorText::addDataValues(std::string data,
|
||||
properties::SelectionProperty& dataOptions)
|
||||
{
|
||||
int numOptions = dataOptions.options().size();
|
||||
initializeVectors(numOptions);
|
||||
|
||||
if(!data.empty()){
|
||||
if (!data.empty()) {
|
||||
std::string line;
|
||||
std::stringstream memorystream(data);
|
||||
|
||||
std::vector<float> sum(numOptions, 0.0f); //for standard diviation in the add() function
|
||||
// for standard diviation in the add() function
|
||||
std::vector<float> sum(numOptions, 0.0f);
|
||||
std::vector<std::vector<float>> optionValues(numOptions, std::vector<float>());
|
||||
|
||||
std::vector<float> values;
|
||||
@@ -140,9 +146,11 @@ void DataProcessorText::addDataValues(std::string data, properties::SelectionPro
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<float*> DataProcessorText::processData(std::string data, properties::SelectionProperty& dataOptions, glm::size3_t& dimensions){
|
||||
if(!data.empty()){
|
||||
|
||||
std::vector<float*> DataProcessorText::processData(std::string data,
|
||||
properties::SelectionProperty& dataOptions,
|
||||
glm::size3_t& dimensions)
|
||||
{
|
||||
if (!data.empty()) {
|
||||
std::string line;
|
||||
std::stringstream memorystream(data);
|
||||
|
||||
@@ -178,8 +186,9 @@ std::vector<float*> DataProcessorText::processData(std::string data, properties:
|
||||
// back_inserter(values)
|
||||
// );
|
||||
|
||||
// +3 because options x, y and z in the file
|
||||
// copy(
|
||||
// std::next( std::istream_iterator<float> (ss), 3 ), //+3 because options x, y and z in the file
|
||||
// std::next( std::istream_iterator<float> (ss), 3 ),
|
||||
// std::istream_iterator<float> (),
|
||||
// back_inserter(values)
|
||||
// );
|
||||
|
||||
@@ -34,9 +34,12 @@ public:
|
||||
DataProcessorText();
|
||||
~DataProcessorText();
|
||||
|
||||
virtual std::vector<std::string> readMetadata(std::string data, glm::size3_t& dimensions) override;
|
||||
virtual void addDataValues(std::string data, properties::SelectionProperty& dataOptions) override;
|
||||
virtual std::vector<float*> processData(std::string data, properties::SelectionProperty& dataOptions, glm::size3_t& dimensions) override;
|
||||
virtual std::vector<std::string> readMetadata(std::string data,
|
||||
glm::size3_t& dimensions) override;
|
||||
virtual void addDataValues(std::string data,
|
||||
properties::SelectionProperty& dataOptions) override;
|
||||
virtual std::vector<float*> processData(std::string data,
|
||||
properties::SelectionProperty& dataOptions, glm::size3_t& dimensions) override;
|
||||
|
||||
private:
|
||||
// void initialize(int numOptions);
|
||||
|
||||
@@ -139,35 +139,39 @@ void IswaManager::addIswaCygnet(int id, std::string type, std::string group) {
|
||||
return;
|
||||
}
|
||||
|
||||
// This callback determines what geometry should be used and creates the right cygbet
|
||||
// This callback determines what geometry should be used and creates
|
||||
// the right cygnet
|
||||
auto metadataCallback =
|
||||
[this, metaFuture](const DownloadManager::MemoryFile& file) {
|
||||
//Create a string from downloaded file
|
||||
std::string res;
|
||||
res.append(file.buffer, file.size);
|
||||
//add it to the metafuture object
|
||||
metaFuture->json = res;
|
||||
[this, metaFuture](const DownloadManager::MemoryFile& file) {
|
||||
//Create a string from downloaded file
|
||||
std::string res;
|
||||
res.append(file.buffer, file.size);
|
||||
//add it to the metafuture object
|
||||
metaFuture->json = res;
|
||||
|
||||
//convert to json
|
||||
json j = json::parse(res);
|
||||
//convert to json
|
||||
json j = json::parse(res);
|
||||
|
||||
// Check what kind of geometry here
|
||||
if (j["Coordinate Type"].is_null()) {
|
||||
metaFuture->geom = CygnetGeometry::Sphere;
|
||||
createSphere(metaFuture);
|
||||
} else if (j["Coordinate Type"] == "Cartesian") {
|
||||
metaFuture->geom = CygnetGeometry::Plane;
|
||||
createPlane(metaFuture);
|
||||
}
|
||||
LDEBUG("Download to memory finished");
|
||||
};
|
||||
// Check what kind of geometry here
|
||||
if (j["Coordinate Type"].is_null()) {
|
||||
metaFuture->geom = CygnetGeometry::Sphere;
|
||||
createSphere(metaFuture);
|
||||
} else if (j["Coordinate Type"] == "Cartesian") {
|
||||
metaFuture->geom = CygnetGeometry::Plane;
|
||||
createPlane(metaFuture);
|
||||
}
|
||||
LDEBUG("Download to memory finished");
|
||||
};
|
||||
|
||||
// Download metadata
|
||||
OsEng.downloadManager().fetchFile(
|
||||
_baseUrl + std::to_string(-id),
|
||||
metadataCallback,
|
||||
[id](const std::string& err) {
|
||||
LDEBUG("Download to memory was aborted for data cygnet with id "+ std::to_string(id)+": " + err);
|
||||
LDEBUG(
|
||||
"Download to memory was aborted for data cygnet with id " +
|
||||
std::to_string(id)+": " + err
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -177,7 +181,9 @@ void IswaManager::addKameleonCdf(std::string groupName, int pos) {
|
||||
// auto info = _cdfInformation[group][pos];
|
||||
auto group = iswaGroup(groupName);
|
||||
if (group) {
|
||||
std::dynamic_pointer_cast<IswaKameleonGroup>(group)->changeCdf(_cdfInformation[groupName][pos].path);
|
||||
std::dynamic_pointer_cast<IswaKameleonGroup>(group)->changeCdf(
|
||||
_cdfInformation[groupName][pos].path
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -186,7 +192,9 @@ void IswaManager::addKameleonCdf(std::string groupName, int pos) {
|
||||
createKameleonPlane(_cdfInformation[groupName][pos], "x");
|
||||
}
|
||||
|
||||
std::future<DownloadManager::MemoryFile> IswaManager::fetchImageCygnet(int id, double timestamp) {
|
||||
std::future<DownloadManager::MemoryFile> IswaManager::fetchImageCygnet(int id,
|
||||
double timestamp)
|
||||
{
|
||||
return std::move(OsEng.downloadManager().fetchFile(
|
||||
iswaUrl(id, timestamp, "image"),
|
||||
[id](const DownloadManager::MemoryFile&) {
|
||||
@@ -204,7 +212,9 @@ std::future<DownloadManager::MemoryFile> IswaManager::fetchImageCygnet(int id, d
|
||||
) );
|
||||
}
|
||||
|
||||
std::future<DownloadManager::MemoryFile> IswaManager::fetchDataCygnet(int id, double timestamp) {
|
||||
std::future<DownloadManager::MemoryFile> IswaManager::fetchDataCygnet(int id,
|
||||
double timestamp)
|
||||
{
|
||||
return std::move(OsEng.downloadManager().fetchFile(
|
||||
iswaUrl(id, timestamp, "data"),
|
||||
[id](const DownloadManager::MemoryFile&) {
|
||||
@@ -227,7 +237,8 @@ std::string IswaManager::iswaUrl(int id, double timestamp, std::string type) {
|
||||
if (id < 0) {
|
||||
url = _baseUrl + type+"/" + std::to_string(-id) + "/";
|
||||
} else {
|
||||
url = "http://iswa3.ccmc.gsfc.nasa.gov/IswaSystemWebApp/iSWACygnetStreamer?window=-1&cygnetId="+ std::to_string(id) +"×tamp=";
|
||||
url = "http://iswa3.ccmc.gsfc.nasa.gov/IswaSystemWebApp/iSWACygnetStreamer?"
|
||||
"window=-1&cygnetId="+ std::to_string(id) +"×tamp=";
|
||||
}
|
||||
|
||||
//std::string t = Time::ref().currentTimeUTC();
|
||||
@@ -254,11 +265,20 @@ void IswaManager::registerGroup(std::string groupName, std::string type) {
|
||||
|
||||
bool kameleonGroup = (type == typeid(KameleonPlane).name());
|
||||
if (dataGroup) {
|
||||
_groups.insert(std::pair<std::string, std::shared_ptr<IswaBaseGroup>>(groupName, std::make_shared<IswaDataGroup>(groupName, type)));
|
||||
_groups.insert(std::pair<std::string, std::shared_ptr<IswaBaseGroup>>(
|
||||
groupName,
|
||||
std::make_shared<IswaDataGroup>(groupName, type))
|
||||
);
|
||||
} else if (kameleonGroup) {
|
||||
_groups.insert(std::pair<std::string, std::shared_ptr<IswaBaseGroup>>(groupName, std::make_shared<IswaKameleonGroup>(groupName, type)));
|
||||
_groups.insert(std::pair<std::string, std::shared_ptr<IswaBaseGroup>>(
|
||||
groupName,
|
||||
std::make_shared<IswaKameleonGroup>(groupName, type))
|
||||
);
|
||||
} else {
|
||||
_groups.insert(std::pair<std::string, std::shared_ptr<IswaBaseGroup>>(groupName, std::make_shared<IswaBaseGroup>(groupName, type)));
|
||||
_groups.insert(std::pair<std::string, std::shared_ptr<IswaBaseGroup>>(
|
||||
groupName,
|
||||
std::make_shared<IswaBaseGroup>(groupName, type))
|
||||
);
|
||||
}
|
||||
} else if (!_groups[groupName]->isType(type)) {
|
||||
LWARNING("Can't add cygnet to groups with diffent type");
|
||||
@@ -368,8 +388,10 @@ std::string IswaManager::jsonPlaneToLuaTable(std::shared_ptr<MetadataFuture> dat
|
||||
|
||||
std::string IswaManager::parseKWToLuaTable(CdfInfo info, std::string cut) {
|
||||
if (info.path != "") {
|
||||
const std::string& extension = ghoul::filesystem::File(absPath(info.path)).fileExtension();
|
||||
if(extension == "cdf"){
|
||||
const std::string& extension = ghoul::filesystem::File(
|
||||
absPath(info.path)
|
||||
).fileExtension();
|
||||
if(extension == "cdf") {
|
||||
KameleonWrapper kw = KameleonWrapper(absPath(info.path));
|
||||
|
||||
std::string parent = kw.getParent();
|
||||
@@ -380,8 +402,13 @@ std::string IswaManager::parseKWToLuaTable(CdfInfo info, std::string cut) {
|
||||
glm::vec4 spatialScale;
|
||||
std::string coordinateType;
|
||||
|
||||
std::tuple<std::string, std::string, std::string> gridUnits = kw.getGridUnits();
|
||||
if (std::get<0>(gridUnits) == "R" && std::get<1>(gridUnits) == "R" && std::get<2>(gridUnits) == "R") {
|
||||
std::tuple<std::string, std::string, std::string> gridUnits =
|
||||
kw.getGridUnits();
|
||||
|
||||
if (std::get<0>(gridUnits) == "R" &&
|
||||
std::get<1>(gridUnits) == "R" &&
|
||||
std::get<2>(gridUnits) == "R")
|
||||
{
|
||||
spatialScale.x = 6.371f;
|
||||
spatialScale.y = 6.371f;
|
||||
spatialScale.z = 6.371f;
|
||||
@@ -395,7 +422,7 @@ std::string IswaManager::parseKWToLuaTable(CdfInfo info, std::string cut) {
|
||||
}
|
||||
|
||||
std::string table = "{"
|
||||
"Name = '" +info.name+ "',"
|
||||
"Name = '" + info.name + "',"
|
||||
"Parent = '" + parent + "', "
|
||||
"Renderable = {"
|
||||
"Type = 'KameleonPlane', "
|
||||
@@ -406,11 +433,11 @@ std::string IswaManager::parseKWToLuaTable(CdfInfo info, std::string cut) {
|
||||
"SpatialScale = " + std::to_string(spatialScale) + ", "
|
||||
"UpdateTime = 0, "
|
||||
"kwPath = '" + info.path + "' ,"
|
||||
"axisCut = '"+cut+"',"
|
||||
"axisCut = '" + cut + "',"
|
||||
"CoordinateType = '" + coordinateType + "', "
|
||||
"Group = '"+ info.group + "',"
|
||||
"Group = '" + info.group + "',"
|
||||
// "Group = '',"
|
||||
"fieldlineSeedsIndexFile = '"+info.fieldlineSeedsIndexFile+"'"
|
||||
"fieldlineSeedsIndexFile = '" + info.fieldlineSeedsIndexFile + "'"
|
||||
"}"
|
||||
"}"
|
||||
;
|
||||
@@ -480,7 +507,6 @@ void IswaManager::createScreenSpace(int id) {
|
||||
|
||||
void IswaManager::createPlane(std::shared_ptr<MetadataFuture> data) {
|
||||
// check if this plane already exist
|
||||
|
||||
std::string name = _type[data->type] + _geom[data->geom] + std::to_string(data->id);
|
||||
|
||||
if (!data->group.empty()) {
|
||||
@@ -551,7 +577,9 @@ void IswaManager::createSphere(std::shared_ptr<MetadataFuture> data) {
|
||||
}
|
||||
|
||||
void IswaManager::createKameleonPlane(CdfInfo info, std::string cut) {
|
||||
const std::string& extension = ghoul::filesystem::File(absPath(info.path)).fileExtension();
|
||||
const std::string& extension = ghoul::filesystem::File(
|
||||
absPath(info.path)
|
||||
).fileExtension();
|
||||
if (FileSys.fileExists(absPath(info.path)) && extension == "cdf") {
|
||||
if (!info.group.empty()) {
|
||||
std::string type = typeid(KameleonPlane).name();
|
||||
@@ -646,7 +674,9 @@ void IswaManager::fillCygnetInfo(std::string jsonString) {
|
||||
jCygnet["cygnetUpdateInterval"],
|
||||
false
|
||||
};
|
||||
_cygnetInformation[jCygnet["cygnetID"]] = std::make_shared<CygnetInfo>(info);
|
||||
_cygnetInformation[jCygnet["cygnetID"]] = std::make_shared<CygnetInfo>(
|
||||
info
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,9 @@ struct MetadataFuture {
|
||||
};
|
||||
|
||||
|
||||
class IswaManager : public ghoul::Singleton<IswaManager>, public properties::PropertyOwner {
|
||||
class IswaManager : public ghoul::Singleton<IswaManager>,
|
||||
public properties::PropertyOwner
|
||||
{
|
||||
friend class ghoul::Singleton<IswaManager>;
|
||||
|
||||
public:
|
||||
@@ -108,7 +110,9 @@ public:
|
||||
|
||||
std::future<DownloadManager::MemoryFile> fetchImageCygnet(int id, double timestamp);
|
||||
std::future<DownloadManager::MemoryFile> fetchDataCygnet(int id, double timestamp);
|
||||
std::string iswaUrl(int id, double timestamp = OsEng.timeManager().time().j2000Seconds(), std::string type = "image");
|
||||
std::string iswaUrl(int id,
|
||||
double timestamp = OsEng.timeManager().time().j2000Seconds(),
|
||||
std::string type = "image");
|
||||
|
||||
std::shared_ptr<IswaBaseGroup> iswaGroup(std::string name);
|
||||
|
||||
|
||||
@@ -90,7 +90,9 @@ int iswa_addScreenSpaceCygnet(lua_State* L) {
|
||||
d.setValue("Type", "ScreenSpaceCygnet");
|
||||
d.setValue("UpdateInterval", (float) updateInterval);
|
||||
|
||||
std::shared_ptr<ScreenSpaceRenderable> s( ScreenSpaceRenderable::createFromDictionary(d) );
|
||||
std::shared_ptr<ScreenSpaceRenderable> s(
|
||||
ScreenSpaceRenderable::createFromDictionary(d)
|
||||
);
|
||||
OsEng.renderEngine().registerScreenSpaceRenderable(s);
|
||||
}
|
||||
return 0;
|
||||
@@ -140,7 +142,10 @@ int iswa_removeScrenSpaceCygnet(lua_State* L) {
|
||||
auto info = cygnetInformation[id];
|
||||
info->selected = false;
|
||||
|
||||
std::string script = "openspace.unregisterScreenSpaceRenderable('" + cygnetInformation[id]->name + "');";
|
||||
std::string script =
|
||||
"openspace.unregisterScreenSpaceRenderable('" +
|
||||
cygnetInformation[id]->name + "');";
|
||||
|
||||
OsEng.scriptEngine().queueScript(
|
||||
script,
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
|
||||
@@ -90,38 +90,38 @@ public:
|
||||
void close();
|
||||
|
||||
float* getUniformSampledValues(
|
||||
const std::string& var,
|
||||
const std::string& var,
|
||||
const glm::size3_t& outDimensions);
|
||||
|
||||
float* getUniformSliceValues(
|
||||
const std::string& var,
|
||||
float* getUniformSliceValues(
|
||||
const std::string& var,
|
||||
const glm::size3_t& outDimensions,
|
||||
const float& zSlice);
|
||||
|
||||
float* getUniformSampledVectorValues(
|
||||
const std::string& xVar,
|
||||
const std::string& xVar,
|
||||
const std::string& yVar,
|
||||
const std::string& zVar,
|
||||
const std::string& zVar,
|
||||
const glm::size3_t& outDimensions);
|
||||
|
||||
Fieldlines getClassifiedFieldLines(
|
||||
const std::string& xVar,
|
||||
const std::string& yVar,
|
||||
const std::string& yVar,
|
||||
const std::string& zVar,
|
||||
const std::vector<glm::vec3>& seedPoints,
|
||||
const std::vector<glm::vec3>& seedPoints,
|
||||
float stepSize);
|
||||
|
||||
Fieldlines getFieldLines(
|
||||
const std::string& xVar,
|
||||
const std::string& yVar,
|
||||
const std::string& yVar,
|
||||
const std::string& zVar,
|
||||
const std::vector<glm::vec3>& seedPoints,
|
||||
float stepSize,
|
||||
const std::vector<glm::vec3>& seedPoints,
|
||||
float stepSize,
|
||||
const glm::vec4& color);
|
||||
|
||||
Fieldlines getLorentzTrajectories(
|
||||
const std::vector<glm::vec3>& seedPoints,
|
||||
const glm::vec4& color,
|
||||
const glm::vec4& color,
|
||||
float stepsize);
|
||||
|
||||
glm::vec3 getModelBarycenterOffset();
|
||||
@@ -146,21 +146,21 @@ private:
|
||||
TraceLine traceCartesianFieldline(
|
||||
const std::string& xVar,
|
||||
const std::string& yVar,
|
||||
const std::string& zVar,
|
||||
const std::string& zVar,
|
||||
const glm::vec3& seedPoint,
|
||||
float stepSize,
|
||||
TraceDirection direction,
|
||||
float stepSize,
|
||||
TraceDirection direction,
|
||||
FieldlineEnd& end);
|
||||
|
||||
TraceLine traceLorentzTrajectory(
|
||||
const glm::vec3& seedPoint,
|
||||
float stepsize,
|
||||
float stepsize,
|
||||
float eCharge);
|
||||
|
||||
void getGridVariables(std::string& x, std::string& y, std::string& z);
|
||||
GridType getGridType(
|
||||
const std::string& x,
|
||||
const std::string& y,
|
||||
const std::string& x,
|
||||
const std::string& y,
|
||||
const std::string& z);
|
||||
Model getModelType();
|
||||
glm::vec4 classifyFieldline(FieldlineEnd fEnd, FieldlineEnd bEnd);
|
||||
|
||||
@@ -100,10 +100,6 @@ double getTime(ccmc::Kameleon* kameleon) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// else if (seqStartStr.length() < 19 && kameleon->doesAttributeExist("tim_crstart_cal")) {
|
||||
// seqStartStr =
|
||||
// kameleon->getGlobalAttribute("tim_crstart_cal").getAttributeString();
|
||||
// }
|
||||
} else if (kameleon->doesAttributeExist("tim_obsdate_cal")) {
|
||||
seqStartStr =
|
||||
kameleon->getGlobalAttribute("tim_obsdate_cal").getAttributeString();
|
||||
|
||||
@@ -131,12 +131,18 @@ bool KameleonWrapper::open(const std::string& filename) {
|
||||
LDEBUG("y:" << _yCoordVar);
|
||||
LDEBUG("z:" << _zCoordVar);
|
||||
|
||||
_xMin = _model->getVariableAttribute(_xCoordVar, "actual_min").getAttributeFloat();
|
||||
_xMax = _model->getVariableAttribute(_xCoordVar, "actual_max").getAttributeFloat();
|
||||
_yMin = _model->getVariableAttribute(_yCoordVar, "actual_min").getAttributeFloat();
|
||||
_yMax = _model->getVariableAttribute(_yCoordVar, "actual_max").getAttributeFloat();
|
||||
_zMin = _model->getVariableAttribute(_zCoordVar, "actual_min").getAttributeFloat();
|
||||
_zMax = _model->getVariableAttribute(_zCoordVar, "actual_max").getAttributeFloat();
|
||||
_xMin =
|
||||
_model->getVariableAttribute(_xCoordVar, "actual_min").getAttributeFloat();
|
||||
_xMax =
|
||||
_model->getVariableAttribute(_xCoordVar, "actual_max").getAttributeFloat();
|
||||
_yMin =
|
||||
_model->getVariableAttribute(_yCoordVar, "actual_min").getAttributeFloat();
|
||||
_yMax =
|
||||
_model->getVariableAttribute(_yCoordVar, "actual_max").getAttributeFloat();
|
||||
_zMin =
|
||||
_model->getVariableAttribute(_zCoordVar, "actual_min").getAttributeFloat();
|
||||
_zMax =
|
||||
_model->getVariableAttribute(_zCoordVar, "actual_max").getAttributeFloat();
|
||||
|
||||
/* _xMin = -200.0f;
|
||||
_xMax = 200.0f;
|
||||
@@ -146,12 +152,19 @@ bool KameleonWrapper::open(const std::string& filename) {
|
||||
_zMax = 200.0f;*/
|
||||
|
||||
|
||||
_xValidMin = _model->getVariableAttribute(_xCoordVar, "valid_min").getAttributeFloat();
|
||||
_xValidMax = _model->getVariableAttribute(_xCoordVar, "valid_max").getAttributeFloat();
|
||||
_yValidMin = _model->getVariableAttribute(_yCoordVar, "valid_min").getAttributeFloat();
|
||||
_yValidMax = _model->getVariableAttribute(_yCoordVar, "valid_max").getAttributeFloat();
|
||||
_zValidMin = _model->getVariableAttribute(_zCoordVar, "valid_min").getAttributeFloat();
|
||||
_zValidMax = _model->getVariableAttribute(_zCoordVar, "valid_max").getAttributeFloat();
|
||||
_xValidMin =
|
||||
_model->getVariableAttribute(_xCoordVar, "valid_min").getAttributeFloat();
|
||||
_xValidMax =
|
||||
_model->getVariableAttribute(_xCoordVar, "valid_max").getAttributeFloat();
|
||||
_yValidMin =
|
||||
_model->getVariableAttribute(_yCoordVar, "valid_min").getAttributeFloat();
|
||||
_yValidMax =
|
||||
_model->getVariableAttribute(_yCoordVar, "valid_max").getAttributeFloat();
|
||||
_zValidMin =
|
||||
_model->getVariableAttribute(_zCoordVar, "valid_min").getAttributeFloat();
|
||||
_zValidMax =
|
||||
_model->getVariableAttribute(_zCoordVar, "valid_max").getAttributeFloat();
|
||||
|
||||
LDEBUG("_xMin: " << _xMin);
|
||||
LDEBUG("_xMax: " << _xMax);
|
||||
LDEBUG("_yMin: " << _yMin);
|
||||
@@ -186,14 +199,16 @@ void KameleonWrapper::close() {
|
||||
}
|
||||
|
||||
float* KameleonWrapper::getUniformSampledValues(
|
||||
const std::string& var,
|
||||
const glm::size3_t& outDimensions)
|
||||
const std::string& var,
|
||||
const glm::size3_t& outDimensions)
|
||||
{
|
||||
assert(_model && _interpolator);
|
||||
assert(outDimensions.x > 0 && outDimensions.y > 0 && outDimensions.z > 0);
|
||||
LINFO("Loading variable " << var << " from CDF data with a uniform sampling");
|
||||
|
||||
unsigned int size = static_cast<unsigned int>(outDimensions.x*outDimensions.y*outDimensions.z);
|
||||
unsigned int size = static_cast<unsigned int>(
|
||||
outDimensions.x * outDimensions.y * outDimensions.z
|
||||
);
|
||||
float* data = new float[size];
|
||||
double* doubleData = new double[size];
|
||||
|
||||
@@ -223,20 +238,25 @@ float* KameleonWrapper::getUniformSampledValues(
|
||||
for (int x = 0; x < static_cast<int>(outDimensions.x); ++x) {
|
||||
for (int y = 0; y < static_cast<int>(outDimensions.y); ++y) {
|
||||
for (int z = 0; z < static_cast<int>(outDimensions.z); ++z) {
|
||||
unsigned int index = static_cast<unsigned int>(x + y*outDimensions.x + z*outDimensions.x*outDimensions.y);
|
||||
unsigned int index = static_cast<unsigned int>(
|
||||
x + y * outDimensions.x + z * outDimensions.x * outDimensions.y
|
||||
);
|
||||
|
||||
if (_gridType == GridType::Spherical) {
|
||||
// Put r in the [0..sqrt(3)] range
|
||||
double rNorm = sqrt(3.0) * static_cast<double>(x) / static_cast<double>(outDimensions.x - 1);
|
||||
double rNorm = sqrt(3.0) * static_cast<double>(x) /
|
||||
static_cast<double>(outDimensions.x - 1);
|
||||
|
||||
// Put theta in the [0..PI] range
|
||||
double thetaNorm = M_PI * static_cast<double>(y) / static_cast<double>(outDimensions.y - 1);
|
||||
double thetaNorm = M_PI * static_cast<double>(y) /
|
||||
static_cast<double>(outDimensions.y - 1);
|
||||
|
||||
// Put phi in the [0..2PI] range
|
||||
double phiNorm = 2.0 * M_PI * static_cast<double>(z) / static_cast<double>(outDimensions.z - 1);
|
||||
double phiNorm = 2.0 * M_PI * static_cast<double>(z) /
|
||||
static_cast<double>(outDimensions.z - 1);
|
||||
|
||||
// Go to physical coordinates before sampling
|
||||
double rPh = _xMin + rNorm*(_xMax-_xMin);
|
||||
double rPh = _xMin + rNorm * (_xMax - _xMin);
|
||||
double thetaPh = thetaNorm;
|
||||
// phi range needs to be mapped to the slightly different model
|
||||
// range to avoid gaps in the data Subtract a small term to
|
||||
@@ -256,15 +276,15 @@ float* KameleonWrapper::getUniformSampledValues(
|
||||
// ENLIL CDF specific hacks!
|
||||
// Convert from meters to AU for interpolator
|
||||
rPh /= ccmc::constants::AU_in_meters;
|
||||
// Convert from colatitude [0, pi] rad to latitude [-90, 90] degrees
|
||||
// Convert from colatitude [0, pi] rad to latitude [-90, 90] deg
|
||||
thetaPh = -thetaPh*180.f/M_PI+90.f;
|
||||
// Convert from [0, 2pi] rad to [0, 360] degrees
|
||||
phiPh = phiPh*180.f/M_PI;
|
||||
// Sample
|
||||
value = _interpolator->interpolate(
|
||||
var,
|
||||
static_cast<float>(rPh),
|
||||
static_cast<float>(thetaPh),
|
||||
var,
|
||||
static_cast<float>(rPh),
|
||||
static_cast<float>(thetaPh),
|
||||
static_cast<float>(phiPh));
|
||||
// value = _interpolator->interpolate(var, rPh, phiPh, thetaPh);
|
||||
}
|
||||
@@ -308,7 +328,7 @@ float* KameleonWrapper::getUniformSampledValues(
|
||||
// if(i % 10 == 0)
|
||||
// std::cout << std::endl;
|
||||
//}
|
||||
//
|
||||
//
|
||||
// for(int i = 0; i < bins-1; ++i) {
|
||||
// // sum += histogram[i];
|
||||
// // if(sum + histogram[i+1] > sumuntil) {
|
||||
@@ -360,16 +380,17 @@ float* KameleonWrapper::getUniformSampledValues(
|
||||
return data;
|
||||
}
|
||||
|
||||
float* KameleonWrapper::getUniformSliceValues(
|
||||
const std::string& var,
|
||||
const glm::size3_t& outDimensions,
|
||||
const float& slice)
|
||||
float* KameleonWrapper::getUniformSliceValues(const std::string& var,
|
||||
const glm::size3_t& outDimensions,
|
||||
const float& slice)
|
||||
{
|
||||
assert(_model && _interpolator);
|
||||
assert(outDimensions.x > 0 && outDimensions.y > 0 && outDimensions.z > 0);
|
||||
LINFO("Loading variable " << var << " from CDF data with a uniform sampling");
|
||||
|
||||
unsigned int size = static_cast<unsigned int>(outDimensions.x*outDimensions.y*outDimensions.z);
|
||||
unsigned int size = static_cast<unsigned int>(
|
||||
outDimensions.x * outDimensions.y * outDimensions.z
|
||||
);
|
||||
float* data = new float[size];
|
||||
double* doubleData = new double[size];
|
||||
|
||||
@@ -407,17 +428,22 @@ float* KameleonWrapper::getUniformSliceValues(
|
||||
float zi = (!zSlice)? z : slice;
|
||||
|
||||
double value = 0;
|
||||
unsigned int index = static_cast<unsigned int>(x + y*outDimensions.x + z*outDimensions.x*outDimensions.y);
|
||||
if(_gridType == GridType::Spherical) {
|
||||
// int z = zSlice;
|
||||
unsigned int index = static_cast<unsigned int>(
|
||||
x + y * outDimensions.x + z * outDimensions.x * outDimensions.y
|
||||
);
|
||||
if (_gridType == GridType::Spherical) {
|
||||
// int z = zSlice;
|
||||
// Put r in the [0..sqrt(3)] range
|
||||
double rNorm = sqrt(3.0) * static_cast<double>(xi) / static_cast<double>(xDim);
|
||||
double rNorm = sqrt(3.0) * static_cast<double>(xi) /
|
||||
static_cast<double>(xDim);
|
||||
|
||||
// Put theta in the [0..PI] range
|
||||
double thetaNorm = M_PI * static_cast<double>(yi) / static_cast<double>(yDim);
|
||||
double thetaNorm = M_PI * static_cast<double>(yi) /
|
||||
static_cast<double>(yDim);
|
||||
|
||||
// Put phi in the [0..2PI] range
|
||||
double phiNorm = 2.0 * M_PI * static_cast<double>(zi) / static_cast<double>(zDim);
|
||||
double phiNorm = 2.0 * M_PI * static_cast<double>(zi) /
|
||||
static_cast<double>(zDim);
|
||||
|
||||
// Go to physical coordinates before sampling
|
||||
double rPh = _xMin + rNorm * (_xMax-_xMin);
|
||||
@@ -439,17 +465,16 @@ float* KameleonWrapper::getUniformSliceValues(
|
||||
// ENLIL CDF specific hacks!
|
||||
// Convert from meters to AU for interpolator
|
||||
rPh /= ccmc::constants::AU_in_meters;
|
||||
// Convert from colatitude [0, pi] rad to latitude [-90, 90] degrees
|
||||
thetaPh = -thetaPh*180.f/M_PI+90.f;
|
||||
// Convert from colatitude [0, pi] rad to [-90, 90] deg
|
||||
thetaPh = -thetaPh * 180.f / M_PI + 90.f;
|
||||
// Convert from [0, 2pi] rad to [0, 360] degrees
|
||||
phiPh = phiPh*180.f/M_PI;
|
||||
// Sample
|
||||
value = _interpolator->interpolate(
|
||||
var,
|
||||
static_cast<float>(rPh),
|
||||
static_cast<float>(phiPh),
|
||||
var,
|
||||
static_cast<float>(rPh),
|
||||
static_cast<float>(phiPh),
|
||||
static_cast<float>(thetaPh));
|
||||
// value = _interpolator->interpolate(var, rPh, phiPh, thetaPh);
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -482,29 +507,27 @@ float* KameleonWrapper::getUniformSliceValues(
|
||||
}
|
||||
}
|
||||
}
|
||||
// for(size_t i = 0; i < size; ++i) {
|
||||
// double normalizedVal = (doubleData[i]-minValue)/(maxValue-minValue);
|
||||
// data[i] = glm::clamp(normalizedVal, 0.0, 1.0);
|
||||
// data[i] = 1;
|
||||
// std::cout << minValue << ", " << maxValue << ", " << doubleData[i] << ", " << normalizedVal << ", " << data[i] << std::endl;
|
||||
// }
|
||||
|
||||
delete[] doubleData;
|
||||
return data;
|
||||
}
|
||||
|
||||
float* KameleonWrapper::getUniformSampledVectorValues(
|
||||
const std::string& xVar,
|
||||
const std::string& yVar,
|
||||
const std::string& zVar,
|
||||
const glm::size3_t& outDimensions)
|
||||
float* KameleonWrapper::getUniformSampledVectorValues(const std::string& xVar,
|
||||
const std::string& yVar,
|
||||
const std::string& zVar,
|
||||
const glm::size3_t& outDimensions)
|
||||
{
|
||||
assert(_model && _interpolator);
|
||||
assert(outDimensions.x > 0 && outDimensions.y > 0 && outDimensions.z > 0);
|
||||
LINFO("Loading variables " << xVar << " " << yVar << " " << zVar << " from CDF data with a uniform sampling");
|
||||
LINFO(
|
||||
"Loading variables " << xVar << " " << yVar << " " << zVar <<
|
||||
" from CDF data with a uniform sampling"
|
||||
);
|
||||
|
||||
int channels = 4;
|
||||
unsigned int size = static_cast<unsigned int>(channels*outDimensions.x*outDimensions.y*outDimensions.z);
|
||||
unsigned int size = static_cast<unsigned int>(
|
||||
channels * outDimensions.x * outDimensions.y * outDimensions.z
|
||||
);
|
||||
float* data = new float[size];
|
||||
|
||||
float varXMin = _model->getVariableAttribute(xVar, "actual_min").getAttributeFloat();
|
||||
@@ -532,7 +555,10 @@ float* KameleonWrapper::getUniformSampledVectorValues(
|
||||
for (int y = 0; y < outDimensions.y; ++y) {
|
||||
for (int z = 0; z < outDimensions.z; ++z) {
|
||||
|
||||
unsigned int index = static_cast<unsigned int>(x*channels + y*channels*outDimensions.x + z*channels*outDimensions.x*outDimensions.y);
|
||||
unsigned int index = static_cast<unsigned int>(
|
||||
x * channels + y * channels * outDimensions.x +
|
||||
z * channels * outDimensions.x * outDimensions.y
|
||||
);
|
||||
|
||||
if (_gridType == GridType::Cartesian) {
|
||||
float xPos = _xMin + stepX*x;
|
||||
@@ -548,9 +574,13 @@ float* KameleonWrapper::getUniformSampledVectorValues(
|
||||
data[index] = (xValue-varXMin)/(varXMax-varXMin); // R
|
||||
data[index + 1] = (yValue-varYMin)/(varYMax-varYMin); // G
|
||||
data[index + 2] = (zValue-varZMin)/(varZMax-varZMin); // B
|
||||
data[index + 3] = 1.0; // GL_RGB refuses to work. Workaround by doing a GL_RGBA with hardcoded alpha
|
||||
// GL_RGB refuses to work. Workaround doing a GL_RGBA hardcoded alpha
|
||||
data[index + 3] = 1.0;
|
||||
} else {
|
||||
LERROR("Only cartesian grid supported for getUniformSampledVectorValues (for now)");
|
||||
LERROR(
|
||||
"Only cartesian grid supported for "
|
||||
"getUniformSampledVectorValues (for now)"
|
||||
);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -561,14 +591,17 @@ float* KameleonWrapper::getUniformSampledVectorValues(
|
||||
}
|
||||
|
||||
KameleonWrapper::Fieldlines KameleonWrapper::getClassifiedFieldLines(
|
||||
const std::string& xVar,
|
||||
const std::string& xVar,
|
||||
const std::string& yVar,
|
||||
const std::string& zVar,
|
||||
const std::vector<glm::vec3>& seedPoints,
|
||||
float stepSize )
|
||||
float stepSize )
|
||||
{
|
||||
assert(_model && _interpolator);
|
||||
LINFO("Creating " << seedPoints.size() << " fieldlines from variables " << xVar << " " << yVar << " " << zVar);
|
||||
LINFO(
|
||||
"Creating " << seedPoints.size() << " fieldlines from variables " <<
|
||||
xVar << " " << yVar << " " << zVar
|
||||
);
|
||||
|
||||
std::vector<glm::vec3> fLine, bLine;
|
||||
std::vector<std::vector<LinePoint> > fieldLines;
|
||||
@@ -577,8 +610,24 @@ KameleonWrapper::Fieldlines KameleonWrapper::getClassifiedFieldLines(
|
||||
|
||||
if (_type == Model::BATSRUS) {
|
||||
for (glm::vec3 seedPoint : seedPoints) {
|
||||
fLine = traceCartesianFieldline(xVar, yVar, zVar, seedPoint, stepSize, TraceDirection::FORWARD, forwardEnd);
|
||||
bLine = traceCartesianFieldline(xVar, yVar, zVar, seedPoint, stepSize, TraceDirection::BACK, backEnd);
|
||||
fLine = traceCartesianFieldline(
|
||||
xVar,
|
||||
yVar,
|
||||
zVar,
|
||||
seedPoint,
|
||||
stepSize,
|
||||
TraceDirection::FORWARD,
|
||||
forwardEnd
|
||||
);
|
||||
bLine = traceCartesianFieldline(
|
||||
xVar,
|
||||
yVar,
|
||||
zVar,
|
||||
seedPoint,
|
||||
stepSize,
|
||||
TraceDirection::BACK,
|
||||
backEnd
|
||||
);
|
||||
|
||||
bLine.erase(bLine.begin());
|
||||
bLine.insert(bLine.begin(), fLine.rbegin(), fLine.rend());
|
||||
@@ -601,16 +650,15 @@ KameleonWrapper::Fieldlines KameleonWrapper::getClassifiedFieldLines(
|
||||
return fieldLines;
|
||||
}
|
||||
|
||||
KameleonWrapper::Fieldlines KameleonWrapper::getFieldLines(
|
||||
const std::string& xVar,
|
||||
const std::string& yVar,
|
||||
const std::string& zVar,
|
||||
const std::vector<glm::vec3>& seedPoints,
|
||||
float stepSize,
|
||||
const glm::vec4& color )
|
||||
KameleonWrapper::Fieldlines KameleonWrapper::getFieldLines(const std::string& xVar,
|
||||
const std::string& yVar, const std::string& zVar,
|
||||
const std::vector<glm::vec3>& seedPoints, float stepSize, const glm::vec4& color)
|
||||
{
|
||||
assert(_model && _interpolator);
|
||||
LINFO("Creating " << seedPoints.size() << " fieldlines from variables " << xVar << " " << yVar << " " << zVar);
|
||||
LINFO(
|
||||
"Creating " << seedPoints.size() << " fieldlines from variables " <<
|
||||
xVar << " " << yVar << " " << zVar
|
||||
);
|
||||
|
||||
std::vector<glm::vec3> fLine, bLine;
|
||||
Fieldlines fieldLines;
|
||||
@@ -618,11 +666,27 @@ KameleonWrapper::Fieldlines KameleonWrapper::getFieldLines(
|
||||
|
||||
if (_type == Model::BATSRUS) {
|
||||
for (glm::vec3 seedPoint : seedPoints) {
|
||||
fLine = traceCartesianFieldline(xVar, yVar, zVar, seedPoint, stepSize, TraceDirection::FORWARD, forwardEnd);
|
||||
bLine = traceCartesianFieldline(xVar, yVar, zVar, seedPoint, stepSize, TraceDirection::BACK, backEnd);
|
||||
fLine = traceCartesianFieldline(
|
||||
xVar,
|
||||
yVar,
|
||||
zVar,
|
||||
seedPoint,
|
||||
stepSize,
|
||||
TraceDirection::FORWARD,
|
||||
forwardEnd
|
||||
);
|
||||
bLine = traceCartesianFieldline(
|
||||
xVar,
|
||||
yVar,
|
||||
zVar,
|
||||
seedPoint,
|
||||
stepSize,
|
||||
TraceDirection::BACK,
|
||||
backEnd
|
||||
);
|
||||
|
||||
bLine.erase(bLine.begin());
|
||||
bLine.insert(bLine.begin(), fLine.rbegin(), fLine.rend());
|
||||
bLine.insert(bLine.begin(), fLine.rbegin(), fLine.rend());
|
||||
|
||||
// write colors and convert positions to meter
|
||||
std::vector<LinePoint> line;
|
||||
@@ -640,9 +704,7 @@ KameleonWrapper::Fieldlines KameleonWrapper::getFieldLines(
|
||||
}
|
||||
|
||||
KameleonWrapper::Fieldlines KameleonWrapper::getLorentzTrajectories(
|
||||
const std::vector<glm::vec3>& seedPoints,
|
||||
const glm::vec4& /*color*/,
|
||||
float stepsize)
|
||||
const std::vector<glm::vec3>& seedPoints,const glm::vec4& /*color*/, float stepsize)
|
||||
{
|
||||
LINFO("Creating " << seedPoints.size() << " Lorentz force trajectories");
|
||||
|
||||
@@ -659,11 +721,19 @@ KameleonWrapper::Fieldlines KameleonWrapper::getLorentzTrajectories(
|
||||
|
||||
// write colors and convert positions to meter
|
||||
std::vector<LinePoint> trajectory;
|
||||
for (glm::vec3 position : minusTraj) {
|
||||
if (trajectory.size() < plusNum) // set positive trajectory to pink
|
||||
trajectory.push_back(LinePoint(RE_TO_METER*position, glm::vec4(1, 0, 1, 1)));
|
||||
else // set negative trajectory to cyan
|
||||
trajectory.push_back(LinePoint(RE_TO_METER*position, glm::vec4(0, 1, 1, 1)));
|
||||
for (glm::vec3 position : minusTraj) {
|
||||
if (trajectory.size() < plusNum) {
|
||||
// set positive trajectory to pink
|
||||
trajectory.push_back(
|
||||
LinePoint(RE_TO_METER*position, glm::vec4(1, 0, 1, 1))
|
||||
);
|
||||
}
|
||||
else {
|
||||
// set negative trajectory to cyan
|
||||
trajectory.push_back(
|
||||
LinePoint(RE_TO_METER*position, glm::vec4(0, 1, 1, 1))
|
||||
);
|
||||
}
|
||||
}
|
||||
trajectories.push_back(trajectory);
|
||||
}
|
||||
@@ -678,22 +748,24 @@ glm::vec3 KameleonWrapper::getModelBarycenterOffset() {
|
||||
}
|
||||
|
||||
glm::vec3 offset;
|
||||
offset.x = _xMin+(std::abs(_xMin)+std::abs(_xMax))/2.0f;
|
||||
offset.y = _yMin+(std::abs(_yMin)+std::abs(_yMax))/2.0f;
|
||||
offset.z = _zMin+(std::abs(_zMin)+std::abs(_zMax))/2.0f;
|
||||
offset.x = _xMin + (std::abs(_xMin) + std::abs(_xMax)) / 2.0f;
|
||||
offset.y = _yMin + (std::abs(_yMin) + std::abs(_yMax)) / 2.0f;
|
||||
offset.z = _zMin + (std::abs(_zMin) + std::abs(_zMax)) / 2.0f;
|
||||
return offset;
|
||||
}
|
||||
|
||||
glm::vec4 KameleonWrapper::getModelBarycenterOffsetScaled(){
|
||||
std::tuple < std::string, std::string, std::string > gridUnits = getGridUnits();
|
||||
glm::vec4 KameleonWrapper::getModelBarycenterOffsetScaled() {
|
||||
std::tuple<std::string, std::string, std::string> gridUnits = getGridUnits();
|
||||
glm::vec4 offset = glm::vec4(getModelBarycenterOffset(), 1.0);
|
||||
if(std::get<0>(gridUnits) == "R" && std::get<1>(gridUnits) == "R" && std::get<2>(gridUnits) == "R"){
|
||||
if (std::get<0>(gridUnits) == "R" &&
|
||||
std::get<1>(gridUnits) == "R" &&
|
||||
std::get<2>(gridUnits) == "R")
|
||||
{
|
||||
offset.x *= 6.371f;
|
||||
offset.y *= 6.371f;
|
||||
offset.z *= 6.371f;
|
||||
offset.w = 6;
|
||||
}
|
||||
// else if(std::get<0>(t) == "m" && std::get<1>(t) == "radian" && std::get<2>(t) == "radian"){}
|
||||
return offset;
|
||||
}
|
||||
|
||||
@@ -711,14 +783,20 @@ glm::vec3 KameleonWrapper::getModelScale() {
|
||||
glm::vec4 KameleonWrapper::getModelScaleScaled(){
|
||||
std::tuple < std::string, std::string, std::string > gridUnits = getGridUnits();
|
||||
glm::vec4 scale = glm::vec4(getModelScale(), 1.0);
|
||||
if (std::get<0>(gridUnits) == "R" && std::get<1>(gridUnits) == "R" && std::get<2>(gridUnits) == "R") {
|
||||
if (std::get<0>(gridUnits) == "R" &&
|
||||
std::get<1>(gridUnits) == "R" &&
|
||||
std::get<2>(gridUnits) == "R")
|
||||
{
|
||||
// Earth radius
|
||||
scale.x *= 6.371f;
|
||||
scale.y *= 6.371f;
|
||||
scale.z *= 6.371f;
|
||||
scale.w = 6;
|
||||
}
|
||||
else if (std::get<0>(gridUnits) == "m" && std::get<1>(gridUnits) == "radian" && std::get<2>(gridUnits) == "radian") {
|
||||
else if (std::get<0>(gridUnits) == "m" &&
|
||||
std::get<1>(gridUnits) == "radian" &&
|
||||
std::get<2>(gridUnits) == "radian")
|
||||
{
|
||||
// For spherical coordinate systems the radius is in meter
|
||||
scale.w = -log10(1.0f/_xMax);
|
||||
}
|
||||
@@ -756,13 +834,9 @@ KameleonWrapper::GridType KameleonWrapper::gridType() {
|
||||
}
|
||||
|
||||
KameleonWrapper::TraceLine KameleonWrapper::traceCartesianFieldline(
|
||||
const std::string& xVar,
|
||||
const std::string& yVar,
|
||||
const std::string& zVar,
|
||||
const glm::vec3& seedPoint,
|
||||
float stepSize,
|
||||
TraceDirection direction,
|
||||
FieldlineEnd& end)
|
||||
const std::string& xVar, const std::string& yVar, const std::string& zVar,
|
||||
const glm::vec3& seedPoint, float stepSize, TraceDirection direction,
|
||||
FieldlineEnd& end)
|
||||
{
|
||||
|
||||
glm::vec3 color, pos, k1, k2, k3, k4;
|
||||
@@ -781,7 +855,9 @@ KameleonWrapper::TraceLine KameleonWrapper::traceCartesianFieldline(
|
||||
|
||||
// While we are inside the models boundries and not inside earth
|
||||
while ((pos.x < _xMax && pos.x > _xMin && pos.y < _yMax && pos.y > _yMin &&
|
||||
pos.z < _zMax && pos.z > _zMin) && !(pos.x*pos.x + pos.y*pos.y + pos.z*pos.z < 1.0)) {
|
||||
pos.z < _zMax && pos.z > _zMin) &&
|
||||
!(pos.x*pos.x + pos.y*pos.y + pos.z*pos.z < 1.0))
|
||||
{
|
||||
|
||||
// Save position. Model has +Z as up
|
||||
line.push_back(glm::vec3(pos.x, pos.z, pos.y));
|
||||
@@ -790,25 +866,70 @@ KameleonWrapper::TraceLine KameleonWrapper::traceCartesianFieldline(
|
||||
k1.x = _interpolator->interpolate(xID, pos.x, pos.y, pos.z, stepX, stepY, stepZ);
|
||||
k1.y = _interpolator->interpolate(yID, pos.x, pos.y, pos.z);
|
||||
k1.z = _interpolator->interpolate(zID, pos.x, pos.y, pos.z);
|
||||
k1 = (float)direction*glm::normalize(k1);
|
||||
k1 = static_cast<float>(direction) * glm::normalize(k1);
|
||||
stepX=stepX*stepSize;
|
||||
stepY=stepY*stepSize;
|
||||
stepZ=stepZ*stepSize;
|
||||
k2.x = _interpolator->interpolate(xID, pos.x+(stepX/2.0f)*k1.x, pos.y+(stepY/2.0f)*k1.y, pos.z+(stepZ/2.0f)*k1.z);
|
||||
k2.y = _interpolator->interpolate(yID, pos.x+(stepX/2.0f)*k1.x, pos.y+(stepY/2.0f)*k1.y, pos.z+(stepZ/2.0f)*k1.z);
|
||||
k2.z = _interpolator->interpolate(zID, pos.x+(stepX/2.0f)*k1.x, pos.y+(stepY/2.0f)*k1.y, pos.z+(stepZ/2.0f)*k1.z);
|
||||
k2 = (float)direction*glm::normalize(k2);
|
||||
k3.x = _interpolator->interpolate(xID, pos.x+(stepX/2.0f)*k2.x, pos.y+(stepY/2.0f)*k2.y, pos.z+(stepZ/2.0f)*k2.z);
|
||||
k3.y = _interpolator->interpolate(yID, pos.x+(stepX/2.0f)*k2.x, pos.y+(stepY/2.0f)*k2.y, pos.z+(stepZ/2.0f)*k2.z);
|
||||
k3.z = _interpolator->interpolate(zID, pos.x+(stepX/2.0f)*k2.x, pos.y+(stepY/2.0f)*k2.y, pos.z+(stepZ/2.0f)*k2.z);
|
||||
k3 = (float)direction*glm::normalize(k3);
|
||||
k4.x = _interpolator->interpolate(xID, pos.x+stepX*k3.x, pos.y+stepY*k3.y, pos.z+stepZ*k3.z);
|
||||
k4.y = _interpolator->interpolate(yID, pos.x+stepX*k3.x, pos.y+stepY*k3.y, pos.z+stepZ*k3.z);
|
||||
k4.z = _interpolator->interpolate(zID, pos.x+stepX*k3.x, pos.y+stepY*k3.y, pos.z+stepZ*k3.z);
|
||||
k4 = (float)direction*glm::normalize(k4);
|
||||
pos.x = pos.x + (stepX/6.0f)*(k1.x + 2.0f*k2.x + 2.0f*k3.x + k4.x);
|
||||
pos.y = pos.y + (stepY/6.0f)*(k1.y + 2.0f*k2.y + 2.0f*k3.y + k4.y);
|
||||
pos.z = pos.z + (stepZ/6.0f)*(k1.z + 2.0f*k2.z + 2.0f*k3.z + k4.z);
|
||||
k2.x = _interpolator->interpolate(
|
||||
xID,
|
||||
pos.x + (stepX / 2.0f) * k1.x,
|
||||
pos.y + (stepY / 2.0f) * k1.y,
|
||||
pos.z + (stepZ / 2.0f) * k1.z
|
||||
);
|
||||
k2.y = _interpolator->interpolate(
|
||||
yID,
|
||||
pos.x + (stepX / 2.0f) * k1.x,
|
||||
pos.y + (stepY / 2.0f) * k1.y,
|
||||
pos.z + (stepZ / 2.0f) * k1.z
|
||||
);
|
||||
k2.z = _interpolator->interpolate(
|
||||
zID,
|
||||
pos.x + (stepX / 2.0f) * k1.x,
|
||||
pos.y + (stepY / 2.0f) * k1.y,
|
||||
pos.z + (stepZ / 2.0f) * k1.z
|
||||
);
|
||||
k2 = static_cast<float>(direction) * glm::normalize(k2);
|
||||
k3.x = _interpolator->interpolate(
|
||||
xID,
|
||||
pos.x + (stepX / 2.0f) * k2.x,
|
||||
pos.y + (stepY / 2.0f) * k2.y,
|
||||
pos.z + (stepZ / 2.0f) * k2.z
|
||||
);
|
||||
k3.y = _interpolator->interpolate(
|
||||
yID,
|
||||
pos.x + (stepX / 2.0f) * k2.x,
|
||||
pos.y + (stepY / 2.0f) * k2.y,
|
||||
pos.z + (stepZ / 2.0f) * k2.z
|
||||
);
|
||||
k3.z = _interpolator->interpolate(
|
||||
zID,
|
||||
pos.x + (stepX / 2.0f) * k2.x,
|
||||
pos.y + (stepY / 2.0f) * k2.y,
|
||||
pos.z + (stepZ / 2.0f) * k2.z
|
||||
);
|
||||
k3 = static_cast<float>(direction) * glm::normalize(k3);
|
||||
k4.x = _interpolator->interpolate(
|
||||
xID,
|
||||
pos.x + stepX * k3.x,
|
||||
pos.y + stepY * k3.y,
|
||||
pos.z + stepZ * k3.z
|
||||
);
|
||||
k4.y = _interpolator->interpolate(
|
||||
yID,
|
||||
pos.x + stepX * k3.x,
|
||||
pos.y + stepY * k3.y,
|
||||
pos.z + stepZ * k3.z
|
||||
);
|
||||
k4.z = _interpolator->interpolate(
|
||||
zID,
|
||||
pos.x + stepX * k3.x,
|
||||
pos.y + stepY * k3.y,
|
||||
pos.z + stepZ * k3.z
|
||||
);
|
||||
k4 = static_cast<float>(direction) * glm::normalize(k4);
|
||||
pos.x = pos.x + (stepX / 6.f) * (k1.x + 2.f * k2.x + 2.f * k3.x + k4.x);
|
||||
pos.y = pos.y + (stepY / 6.f) * (k1.y + 2.f * k2.y + 2.f * k3.y + k4.y);
|
||||
pos.z = pos.z + (stepZ / 6.f) * (k1.z + 2.f * k2.z + 2.f * k3.z + k4.z);
|
||||
|
||||
++numSteps;
|
||||
if (numSteps > maxSteps) {
|
||||
@@ -833,9 +954,7 @@ KameleonWrapper::TraceLine KameleonWrapper::traceCartesianFieldline(
|
||||
}
|
||||
|
||||
KameleonWrapper::TraceLine KameleonWrapper::traceLorentzTrajectory(
|
||||
const glm::vec3& seedPoint,
|
||||
float stepsize,
|
||||
float eCharge)
|
||||
const glm::vec3& seedPoint, float stepsize, float eCharge)
|
||||
{
|
||||
glm::vec3 B, E, v0, k1, k2, k3, k4, sPos, tmpV;
|
||||
float stepX = stepsize, stepY = stepsize, stepZ = stepsize;
|
||||
@@ -857,8 +976,9 @@ KameleonWrapper::TraceLine KameleonWrapper::traceLorentzTrajectory(
|
||||
|
||||
// While we are inside the models boundries and not inside earth
|
||||
while ((pos.x < _xMax && pos.x > _xMin && pos.y < _yMax && pos.y > _yMin &&
|
||||
pos.z < _zMax && pos.z > _zMin) && !(pos.x*pos.x + pos.y*pos.y + pos.z*pos.z < 1.0)) {
|
||||
|
||||
pos.z < _zMax && pos.z > _zMin) &&
|
||||
!(pos.x*pos.x + pos.y*pos.y + pos.z*pos.z < 1.0))
|
||||
{
|
||||
// Save position. Model has +Z as up
|
||||
trajectory.push_back(glm::vec3(pos.x, pos.z, pos.y));
|
||||
|
||||
@@ -929,20 +1049,30 @@ KameleonWrapper::TraceLine KameleonWrapper::traceLorentzTrajectory(
|
||||
|
||||
void KameleonWrapper::getGridVariables(std::string& x, std::string& y, std::string& z) {
|
||||
// get the grid system string
|
||||
std::string gridSystem = _model->getGlobalAttribute("grid_system_1").getAttributeString();
|
||||
std::string gridSystem =
|
||||
_model->getGlobalAttribute("grid_system_1").getAttributeString();
|
||||
|
||||
// remove leading and trailing brackets
|
||||
gridSystem = gridSystem.substr(1,gridSystem.length()-2);
|
||||
|
||||
// remove all whitespaces
|
||||
gridSystem.erase(remove_if(gridSystem.begin(), gridSystem.end(), isspace), gridSystem.end());
|
||||
gridSystem.erase(
|
||||
remove_if(
|
||||
gridSystem.begin(),
|
||||
gridSystem.end(),
|
||||
isspace),
|
||||
gridSystem.end()
|
||||
);
|
||||
|
||||
// replace all comma signs with whitespaces
|
||||
std::replace( gridSystem.begin(), gridSystem.end(), ',', ' ');
|
||||
|
||||
// tokenize
|
||||
std::istringstream iss(gridSystem);
|
||||
std::vector<std::string> tokens{std::istream_iterator<std::string>{iss},std::istream_iterator<std::string>{}};
|
||||
std::vector<std::string> tokens{
|
||||
std::istream_iterator<std::string>{iss},
|
||||
std::istream_iterator<std::string>{}
|
||||
};
|
||||
|
||||
// validate
|
||||
if (tokens.size() != 3) LERROR("Something went wrong");
|
||||
@@ -971,10 +1101,8 @@ void KameleonWrapper::getGridVariables(std::string& x, std::string& y, std::stri
|
||||
);
|
||||
}
|
||||
|
||||
KameleonWrapper::GridType KameleonWrapper::getGridType(
|
||||
const std::string& x,
|
||||
const std::string& y,
|
||||
const std::string& z)
|
||||
KameleonWrapper::GridType KameleonWrapper::getGridType(const std::string& x,
|
||||
const std::string& y, const std::string& z)
|
||||
{
|
||||
if (x == "x" && y == "y" && z == "z") {
|
||||
return GridType::Cartesian;
|
||||
@@ -988,7 +1116,8 @@ KameleonWrapper::GridType KameleonWrapper::getGridType(
|
||||
|
||||
KameleonWrapper::Model KameleonWrapper::getModelType() {
|
||||
if(_kameleon->doesAttributeExist("model_name")) {
|
||||
std::string modelName = (_kameleon->getGlobalAttribute("model_name")).getAttributeString();
|
||||
std::string modelName =
|
||||
_kameleon->getGlobalAttribute("model_name").getAttributeString();
|
||||
if (modelName == "open_ggcm" || modelName == "ucla_ggcm") {
|
||||
return Model::OpenGGCM;
|
||||
} else if (modelName == "batsrus") {
|
||||
@@ -1061,18 +1190,18 @@ std::string KameleonWrapper::getFrame() {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> KameleonWrapper::getVariables(){
|
||||
std::vector<std::string> KameleonWrapper::getVariables() {
|
||||
std::vector<std::string> variableNames;
|
||||
|
||||
int numVariables = _model->getNumberOfVariables();
|
||||
|
||||
for(int i=0; i<numVariables; i++){
|
||||
for (int i=0; i<numVariables; i++) {
|
||||
variableNames.push_back(_model->getVariableName(i));;
|
||||
}
|
||||
return variableNames;
|
||||
}
|
||||
|
||||
std::vector<std::string> KameleonWrapper::getLoadedVariables(){
|
||||
std::vector<std::string> KameleonWrapper::getLoadedVariables() {
|
||||
return _kameleon->getLoadedVariables();
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,14 @@ std::unique_ptr<volume::RawVolume<float>> KameleonVolumeReader::readFloatVolume(
|
||||
const glm::vec3 & upperDomainBound) const
|
||||
{
|
||||
float min, max;
|
||||
return readFloatVolume(dimensions, variable, lowerDomainBound, upperDomainBound, min, max);
|
||||
return readFloatVolume(
|
||||
dimensions,
|
||||
variable,
|
||||
lowerDomainBound,
|
||||
upperDomainBound,
|
||||
min,
|
||||
max
|
||||
);
|
||||
}
|
||||
|
||||
std::unique_ptr<volume::RawVolume<float>> KameleonVolumeReader::readFloatVolume(
|
||||
@@ -130,20 +137,30 @@ std::unique_ptr<volume::RawVolume<float>> KameleonVolumeReader::readFloatVolume(
|
||||
|
||||
std::vector<std::string> KameleonVolumeReader::gridVariableNames() const {
|
||||
// get the grid system string
|
||||
std::string gridSystem = _model->getGlobalAttribute("grid_system_1").getAttributeString();
|
||||
std::string gridSystem =
|
||||
_model->getGlobalAttribute("grid_system_1").getAttributeString();
|
||||
|
||||
// remove leading and trailing brackets
|
||||
gridSystem = gridSystem.substr(1, gridSystem.length() - 2);
|
||||
|
||||
// remove all whitespaces
|
||||
gridSystem.erase(remove_if(gridSystem.begin(), gridSystem.end(), isspace), gridSystem.end());
|
||||
gridSystem.erase(
|
||||
remove_if(
|
||||
gridSystem.begin(),
|
||||
gridSystem.end(),
|
||||
isspace),
|
||||
gridSystem.end()
|
||||
);
|
||||
|
||||
// replace all comma signs with whitespaces
|
||||
std::replace(gridSystem.begin(), gridSystem.end(), ',', ' ');
|
||||
|
||||
// tokenize
|
||||
std::istringstream iss(gridSystem);
|
||||
std::vector<std::string> tokens{ std::istream_iterator<std::string>{iss},std::istream_iterator<std::string>{} };
|
||||
std::vector<std::string> tokens{
|
||||
std::istream_iterator<std::string>{iss},
|
||||
std::istream_iterator<std::string>{}
|
||||
};
|
||||
|
||||
// validate
|
||||
if (tokens.size() != 3) {
|
||||
@@ -199,18 +216,21 @@ std::vector<std::string> KameleonVolumeReader::globalAttributeNames() const {
|
||||
return attributeNames;
|
||||
}
|
||||
|
||||
void KameleonVolumeReader::addAttributeToDictionary(ghoul::Dictionary& dictionary, const std::string& key, ccmc::Attribute& attr) {
|
||||
void KameleonVolumeReader::addAttributeToDictionary(ghoul::Dictionary& dictionary,
|
||||
const std::string& key,
|
||||
ccmc::Attribute& attr)
|
||||
{
|
||||
ccmc::Attribute::AttributeType type = attr.getAttributeType();
|
||||
switch (type) {
|
||||
case ccmc::Attribute::AttributeType::FLOAT:
|
||||
dictionary.setValue<float>(key, attr.getAttributeFloat());
|
||||
return;
|
||||
case ccmc::Attribute::AttributeType::INT:
|
||||
dictionary.setValue<int>(key, attr.getAttributeInt());
|
||||
return;
|
||||
case ccmc::Attribute::AttributeType::STRING:
|
||||
dictionary.setValue<std::string>(key, attr.getAttributeString());
|
||||
return;
|
||||
case ccmc::Attribute::AttributeType::FLOAT:
|
||||
dictionary.setValue<float>(key, attr.getAttributeFloat());
|
||||
return;
|
||||
case ccmc::Attribute::AttributeType::INT:
|
||||
dictionary.setValue<int>(key, attr.getAttributeInt());
|
||||
return;
|
||||
case ccmc::Attribute::AttributeType::STRING:
|
||||
dictionary.setValue<std::string>(key, attr.getAttributeString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,15 +246,22 @@ ghoul::Dictionary KameleonVolumeReader::readMetaData() const {
|
||||
for (const std::string& variableName : variableNames()) {
|
||||
ghoul::Dictionary variableAttributesDictionary;
|
||||
for (const std::string& attributeName : varAttrNames) {
|
||||
ccmc::Attribute attribute = _model->getVariableAttribute(variableName, attributeName);
|
||||
addAttributeToDictionary(variableAttributesDictionary, attributeName, attribute);
|
||||
ccmc::Attribute attribute = _model->getVariableAttribute(
|
||||
variableName,
|
||||
attributeName
|
||||
);
|
||||
addAttributeToDictionary(
|
||||
variableAttributesDictionary,
|
||||
attributeName,
|
||||
attribute
|
||||
);
|
||||
}
|
||||
variableDictionary.setValue(variableName, variableAttributesDictionary);
|
||||
}
|
||||
|
||||
return {
|
||||
{"globalAttributes", std::move(globalAttributesDictionary) },
|
||||
{"variableAttributes", std::move(variableDictionary) }
|
||||
{ "globalAttributes", std::move(globalAttributesDictionary) },
|
||||
{ "variableAttributes", std::move(variableDictionary) }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,9 @@ public:
|
||||
std::vector<std::string> globalAttributeNames() const;
|
||||
|
||||
private:
|
||||
static void addAttributeToDictionary(ghoul::Dictionary& dictionary, const std::string& key, ccmc::Attribute& attr);
|
||||
static void addAttributeToDictionary(ghoul::Dictionary& dictionary,
|
||||
const std::string& key, ccmc::Attribute& attr);
|
||||
|
||||
std::string _path;
|
||||
ccmc::Kameleon _kameleon;
|
||||
ccmc::Model* _model;
|
||||
|
||||
@@ -327,7 +327,7 @@ void RenderableKameleonVolume::updateRaycasterModelTransform() {
|
||||
glm::vec3 scale = upperBoundingBoxBound - lowerBoundingBoxBound;
|
||||
glm::vec3 translation = (lowerBoundingBoxBound + upperBoundingBoxBound) * 0.5f;
|
||||
|
||||
glm::mat4 modelTransform = glm::translate(glm::mat4(1.0), translation);
|
||||
glm::mat4 modelTransform = glm::translate(glm::mat4(1.0), translation);
|
||||
modelTransform = glm::scale(modelTransform, scale);
|
||||
_raycaster->setModelTransform(modelTransform);
|
||||
}
|
||||
@@ -339,7 +339,7 @@ bool RenderableKameleonVolume::cachingEnabled() {
|
||||
|
||||
void RenderableKameleonVolume::load() {
|
||||
if (!FileSys.fileExists(_sourcePath)) {
|
||||
LERROR("File " << _sourcePath << " does not exist.");
|
||||
LERROR("File " << _sourcePath << " does not exist.");
|
||||
return;
|
||||
}
|
||||
if (!cachingEnabled()) {
|
||||
@@ -418,7 +418,7 @@ void RenderableKameleonVolume::loadCdf(const std::string& path) {
|
||||
}
|
||||
else {
|
||||
_gridType.setValue(static_cast<int>(volume::VolumeGridType::Cartesian));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ghoul::Dictionary dict = reader.readMetaData();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user