More coding style conformance

This commit is contained in:
Alexander Bock
2017-11-11 11:25:49 -05:00
parent f29b15a37f
commit 758e26789c
170 changed files with 2585 additions and 1229 deletions
@@ -62,28 +62,114 @@ namespace {
const char* KeyMaxValue = "MaxValue";
const char* KeyTime = "Time";
const float SecondsInOneDay = 60 * 60 * 24;
static const openspace::properties::Property::PropertyInfo StepSizeInfo = {
"stepSize",
"Step Size",
"" // @TODO Missing documentation
};
static const openspace::properties::Property::PropertyInfo GridTypeInfo = {
"gridType",
"Grid Type",
"" // @TODO Missing documentation
};
static const openspace::properties::Property::PropertyInfo SecondsBeforeInfo = {
"secondsBefore",
"Seconds before",
"" // @TODO Missing documentation
};
static const openspace::properties::Property::PropertyInfo SecondsAfterInfo = {
"secondsAfter",
"Seconds after",
"" // @TODO Missing documentation
};
static const openspace::properties::Property::PropertyInfo SourceDirectoryInfo = {
"sourceDirectory",
"Source Directory",
"" // @TODO Missing documentation
};
static const openspace::properties::Property::PropertyInfo TransferFunctionInfo = {
"transferFunctionPath",
"Transfer Function Path",
""
};
static const openspace::properties::Property::PropertyInfo TriggerTimeJumpInfo = {
"triggerTimeJump",
"Jump",
"" // @TODO Missing documentation
};
static const openspace::properties::Property::PropertyInfo JumpToTimestepInfo = {
"jumpToTimestep",
"Jump to timestep",
"" // @TODO Missing documentation
};
static const openspace::properties::Property::PropertyInfo CurrentTimeStepInfo = {
"currentTimestep",
"Current timestep",
"" // @TODO Missing documentation
};
static const openspace::properties::Property::PropertyInfo OpacityInfo = {
"opacity",
"Opacity",
"" // @TODO Missing documentation
};
static const openspace::properties::Property::PropertyInfo rNormalizationInfo = {
"rNormalization",
"Radius normalization",
"" // @TODO Missing documentation
};
static const openspace::properties::Property::PropertyInfo rUpperBoundInfo = {
"rUpperBound",
"Radius upper bound",
"" // @TODO Missing documentation
};
static const openspace::properties::Property::PropertyInfo lowerValueBoundInfo = {
"lowerValueBound",
"Lower value bound",
"" // @TODO Missing documentation
};
static const openspace::properties::Property::PropertyInfo upperValueBoundInfo = {
"upperValueBound",
"Upper value bound",
"" // @TODO Missing documentation
};
} // namespace
namespace openspace {
namespace volume {
RenderableTimeVaryingVolume::RenderableTimeVaryingVolume(const ghoul::Dictionary& dictionary)
RenderableTimeVaryingVolume::RenderableTimeVaryingVolume(
const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _clipPlanes(nullptr)
, _stepSize({ "stepSize", "Step Size", "" }, 0.02, 0.01, 1)
, _gridType({ "gridType", "Grid Type", "" }, properties::OptionProperty::DisplayType::Dropdown)
, _secondsBefore({ "secondsBefore", "Seconds before", "" }, 0.0, 0.01, SecondsInOneDay)
, _secondsAfter({ "secondsAfter", "Seconds after", "" }, 0.0, 0.01, SecondsInOneDay)
, _sourceDirectory({ "sourceDirectory", "Source Directory", "" })
, _transferFunctionPath({"transferFunctionPath", "Transfer Function Path", "" })
, _triggerTimeJump({"triggerTimeJump", "Jump", "" })
, _jumpToTimestep({"jumpToTimestep", "Jump to timestep", "" }, 0, 0, 256)
, _currentTimestep({"currentTimestep", "Current timestep", "" }, 0, 0, 256)
, _opacity({"opacity", "Opacity", "" }, 10.0f, 0.0f, 50.0f)
, _rNormalization({"rNormalization", "Radius normalization", "" }, 0.0f, 0.0f, 2.0f)
, _rUpperBound({"rUpperBound", "Radius upper bound", "" }, 1.0f, 0.0f, 2.0f)
, _lowerValueBound({"lowerValueBound", "Lower value bound", "" }, 0.0f, 0.0f, 1000000.0f)
, _upperValueBound({"upperValueBound", "Upper value bound", "" }, 0.0f, 0.0f, 1000000.0f)
, _stepSize(StepSizeInfo, 0.02, 0.01, 1)
, _gridType(GridTypeInfo, properties::OptionProperty::DisplayType::Dropdown)
, _secondsBefore(SecondsBeforeInfo, 0.0, 0.01, SecondsInOneDay)
, _secondsAfter(SecondsAfterInfo, 0.0, 0.01, SecondsInOneDay)
, _sourceDirectory(SourceDirectoryInfo)
, _transferFunctionPath(TransferFunctionInfo)
, _triggerTimeJump(TriggerTimeJumpInfo)
, _jumpToTimestep(JumpToTimestepInfo, 0, 0, 256)
, _currentTimestep(CurrentTimeStepInfo, 0, 0, 256)
, _opacity(OpacityInfo, 10.0f, 0.0f, 50.0f)
, _rNormalization(rNormalizationInfo, 0.0f, 0.0f, 2.0f)
, _rUpperBound(rUpperBoundInfo, 1.0f, 0.0f, 2.0f)
, _lowerValueBound(lowerValueBoundInfo, 0.0f, 0.0f, 1000000.0f)
, _upperValueBound(upperValueBoundInfo, 0.0f, 0.0f, 1000000.0f)
, _raycaster(nullptr)
, _transferFunction(nullptr)
{
@@ -99,11 +185,12 @@ RenderableTimeVaryingVolume::RenderableTimeVaryingVolume(const ghoul::Dictionary
_upperValueBound = dictionary.value<float>(KeyUpperValueBound);
_transferFunction = std::make_shared<TransferFunction>(_transferFunctionPath);
_gridType.addOption(static_cast<int>(volume::VolumeGridType::Cartesian), "Cartesian grid");
_gridType.addOption(static_cast<int>(volume::VolumeGridType::Spherical), "Spherical grid");
_gridType.addOptions({
{ static_cast<int>(volume::VolumeGridType::Cartesian), "Cartesian grid" },
{ static_cast<int>(volume::VolumeGridType::Spherical), "Spherical grid" },
});
_gridType.setValue(static_cast<int>(volume::VolumeGridType::Cartesian));
if (dictionary.hasValue<float>(KeySecondsBefore)) {
_secondsBefore = dictionary.value<float>(KeySecondsBefore);
}
@@ -115,7 +202,9 @@ RenderableTimeVaryingVolume::RenderableTimeVaryingVolume(const ghoul::Dictionary
_clipPlanes->setName("clipPlanes");
if (dictionary.hasValue<std::string>(KeyGridType)) {
VolumeGridType gridType = volume::parseGridType(dictionary.value<std::string>(KeyGridType));
VolumeGridType gridType = volume::parseGridType(
dictionary.value<std::string>(KeyGridType)
);
_gridType = (gridType == VolumeGridType::Spherical) ? 1 : 0;
}
}
@@ -146,7 +235,9 @@ void RenderableTimeVaryingVolume::initialize() {
// TODO: defer loading of data to later. (separate thread or at least not when loading)
for (auto& p : _volumeTimesteps) {
Timestep& t = p.second;
std::string path = FileSys.pathByAppendingComponent(_sourceDirectory, t.baseName) + ".rawvolume";
std::string path = FileSys.pathByAppendingComponent(
_sourceDirectory, t.baseName
) + ".rawvolume";
RawVolumeReader<float> reader(path, t.dimensions);
t.rawVolume = reader.read();
@@ -168,13 +259,20 @@ void RenderableTimeVaryingVolume::initialize() {
ghoul::opengl::Texture::WrappingMode::Clamp
);
t.texture->setPixelData(reinterpret_cast<void*>(data), ghoul::opengl::Texture::TakeOwnership::No);
t.texture->setPixelData(
reinterpret_cast<void*>(data),
ghoul::opengl::Texture::TakeOwnership::No
);
t.texture->uploadTexture();
}
_clipPlanes->initialize();
_transferFunction->update();
_raycaster = std::make_unique<volume::BasicVolumeRaycaster>(nullptr, _transferFunction, _clipPlanes);
_raycaster = std::make_unique<volume::BasicVolumeRaycaster>(
nullptr,
_transferFunction,
_clipPlanes
);
_raycaster->initialize();
OsEng.renderEngine().raycasterManager().attachRaycaster(*_raycaster.get());
auto onChange = [&](bool enabled) {
@@ -194,7 +292,9 @@ void RenderableTimeVaryingVolume::initialize() {
jumpToTimestep(_jumpToTimestep);
});
const int lastTimestep = (_volumeTimesteps.size() > 0) ? (_volumeTimesteps.size() - 1) : 0;
const int lastTimestep = (_volumeTimesteps.size() > 0) ?
(_volumeTimesteps.size() - 1) :
0;
_currentTimestep.setMaxValue(lastTimestep);
_jumpToTimestep.setMaxValue(lastTimestep);
@@ -211,16 +311,28 @@ void RenderableTimeVaryingVolume::initialize() {
addProperty(_lowerValueBound);
addProperty(_upperValueBound);
_raycaster->setGridType((_gridType.value() == 1) ? VolumeGridType::Spherical : VolumeGridType::Cartesian);
_raycaster->setGridType(
(_gridType.value() == 1) ?
VolumeGridType::Spherical :
VolumeGridType::Cartesian
);
_gridType.onChange([this] {
_raycaster->setGridType((_gridType.value() == 1) ? VolumeGridType::Spherical : VolumeGridType::Cartesian);
_raycaster->setGridType(
(_gridType.value() == 1) ?
VolumeGridType::Spherical :
VolumeGridType::Cartesian
);
});
}
void RenderableTimeVaryingVolume::loadTimestepMetadata(const std::string& path) {
ghoul::Dictionary dictionary = ghoul::lua::loadDictionaryFromFile(path);
try {
documentation::testSpecificationAndThrow(TimestepDocumentation(), dictionary, "TimeVaryingVolumeTimestep");
documentation::testSpecificationAndThrow(
TimestepDocumentation(),
dictionary,
"TimeVaryingVolumeTimestep"
);
} catch (const documentation::SpecificationError& e) {
LERROR(e.message << e.component);
return;
@@ -243,6 +355,7 @@ void RenderableTimeVaryingVolume::loadTimestepMetadata(const std::string& path)
}
RenderableTimeVaryingVolume::Timestep* RenderableTimeVaryingVolume::currentTimestep() {
using TimeStep = RenderableTimeVaryingVolume::Timestep;
if (_volumeTimesteps.size() == 0) {
return nullptr;
}
@@ -252,14 +365,14 @@ RenderableTimeVaryingVolume::Timestep* RenderableTimeVaryingVolume::currentTimes
auto currentTimestepIt = _volumeTimesteps.upper_bound(currentTime);
if (currentTimestepIt == _volumeTimesteps.end()) {
// No such timestep was found: show last timestep if it is within the time margin.
RenderableTimeVaryingVolume::Timestep* lastTimestep = &(_volumeTimesteps.rbegin()->second);
Timestep* lastTimestep = &(_volumeTimesteps.rbegin()->second);
double threshold = lastTimestep->time + static_cast<double>(_secondsAfter);
return currentTime < threshold ? lastTimestep : nullptr;
}
if (currentTimestepIt == _volumeTimesteps.begin()) {
// No such timestep was found: show first timestep if it is within the time margin.
RenderableTimeVaryingVolume::Timestep* firstTimestep = &(_volumeTimesteps.begin()->second);
Timestep* firstTimestep = &(_volumeTimesteps.begin()->second);
double threshold = firstTimestep->time - static_cast<double>(_secondsBefore);
return currentTime >= threshold ? firstTimestep : nullptr;
}
@@ -269,7 +382,9 @@ RenderableTimeVaryingVolume::Timestep* RenderableTimeVaryingVolume::currentTimes
return &(currentTimestepIt->second);
}
int RenderableTimeVaryingVolume::timestepIndex(const RenderableTimeVaryingVolume::Timestep* t) const {
int RenderableTimeVaryingVolume::timestepIndex(
const RenderableTimeVaryingVolume::Timestep* t) const
{
if (!t) {
return -1;
}
@@ -283,8 +398,12 @@ int RenderableTimeVaryingVolume::timestepIndex(const RenderableTimeVaryingVolume
return -1;
}
RenderableTimeVaryingVolume::Timestep* RenderableTimeVaryingVolume::timestepFromIndex(int target) {
if (target < 0) target = 0;
RenderableTimeVaryingVolume::Timestep* RenderableTimeVaryingVolume::timestepFromIndex(
int target)
{
if (target < 0) {
target = 0;
}
int index = 0;
for (auto& it : _volumeTimesteps) {
if (index == target) {
@@ -310,7 +429,8 @@ void RenderableTimeVaryingVolume::update(const UpdateData& data) {
if (t && t->texture) {
if (_raycaster->gridType() == volume::VolumeGridType::Cartesian) {
glm::dvec3 scale = t->upperDomainBound - t->lowerDomainBound;
glm::dvec3 translation = (t->lowerDomainBound + t->upperDomainBound) * 0.5f;
glm::dvec3 translation =
(t->lowerDomainBound + t->upperDomainBound) * 0.5f;
glm::dmat4 modelTransform = glm::translate(glm::dmat4(1.0), translation);
glm::dmat4 scaleMatrix = glm::scale(glm::dmat4(1.0), scale);
@@ -326,12 +446,16 @@ void RenderableTimeVaryingVolume::update(const UpdateData& data) {
}
_raycaster->setVolumeTexture(t->texture);
// Remap volume value to that TF value 0 is sampled for lowerValueBound, and 1 is sampled for upperLowerBound.
// This means that volume values = 0 need to be remapped to how localMin relates to the global range.
float zeroMap = (t->minValue - _lowerValueBound) / (_upperValueBound - _lowerValueBound);
// Remap volume value to that TF value 0 is sampled for lowerValueBound, and 1
// is sampled for upperLowerBound.
// This means that volume values = 0 need to be remapped to how localMin
// relates to the global range.
float zeroMap = (t->minValue - _lowerValueBound) /
(_upperValueBound - _lowerValueBound);
// Volume values = 1 are mapped to how localMax relates to the global range.
float oneMap = (t->maxValue - _lowerValueBound) / (_upperValueBound - _lowerValueBound);
float oneMap = (t->maxValue - _lowerValueBound) /
(_upperValueBound - _lowerValueBound);
_raycaster->setValueRemapping(zeroMap, oneMap);
} else {
_raycaster->setVolumeTexture(nullptr);
@@ -376,14 +500,14 @@ documentation::Documentation RenderableTimeVaryingVolume::Documentation() {
KeyTransferFunction,
new StringVerifier,
Optional::No,
"Specifies the transfer function file path",
"Specifies the transfer function file path"
},
{
KeyLowerValueBound,
new DoubleVerifier,
Optional::No,
"Specifies the lower value bound."
"This number will be mapped to 0 before uploadin to the GPU.",
"This number will be mapped to 0 before uploadin to the GPU."
},
{
KeyUpperValueBound,
@@ -402,15 +526,16 @@ documentation::Documentation RenderableTimeVaryingVolume::Documentation() {
KeySecondsBefore,
new DoubleVerifier,
Optional::Yes,
"Specifies the number of seconds to show the the first timestep before its actual time."
"The default value is 0.",
"Specifies the number of seconds to show the the first timestep before "
"its actual time. The default value is 0."
},
{
KeySecondsAfter,
new DoubleVerifier,
Optional::No,
"Specifies the number of seconds to show the the last timestep after its actual time",
},
"Specifies the number of seconds to show the the last timestep after its "
"actual time"
}
}
};
}