Merge branch 'master' into thesis/2018/dsn

This commit is contained in:
Lovisa Hassler
2018-11-16 16:08:58 -05:00
8 changed files with 78 additions and 101 deletions

View File

@@ -129,7 +129,7 @@ openspace.setPropertyValueSingle("RenderEngine.ShowCamera", not isEnabled)]],
Local = false
},
{
Key = "Alt+Tab",
Key = "Alt+R",
Name = "Toggle rendering on master",
Command = propertyHelper.invert('RenderEngine.DisableMasterRendering'),
Documentation = "Toggles the rendering on master",

View File

@@ -76,13 +76,29 @@ public:
* identifier, a GUI name and descriptive text that are both user facing.
*/
struct PropertyInfo {
/// GCC requires an explicit constructor here, as it does not handle the default
/// argument for the struct initialization
constexpr PropertyInfo(const char* ident, const char* gui, const char* desc)
: identifier(ident)
, guiName(gui)
, description(desc)
{}
constexpr PropertyInfo(const char* ident, const char* gui, const char* desc,
Visibility vis)
: identifier(ident)
, guiName(gui)
, description(desc)
, visibility(vis)
{}
/// The unique identifier that is part of the fully qualified URI of this Property
const char* identifier;
/// The name that is displayed in the user interface
const char* guiName;
/// The user facing description of this Property
const char* description;
/// Determins the visibility of this Property in the user interface
/// Determines the visibility of this Property in the user interface
Visibility visibility = Visibility::All;
};

View File

@@ -91,7 +91,9 @@ void CefWebGuiModule::startOrStopGui() {
_instance->initialize();
_instance->loadUrl(_url);
}
webBrowserModule->attachEventHandler(_instance.get());
if (_visible) {
webBrowserModule->attachEventHandler(_instance.get());
}
webBrowserModule->addBrowser(_instance.get());
} else if (_instance) {
_instance->close(true);
@@ -121,6 +123,14 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration)
}
});
_visible.onChange([this, webBrowserModule]() {
if (_visible && _instance) {
webBrowserModule->attachEventHandler(_instance.get());
} else {
webBrowserModule->detachEventHandler();
}
});
_url = configuration.value<std::string>(GuiUrlInfo.identifier);
_enabled = configuration.hasValue<bool>(EnabledInfo.identifier) &&

View File

@@ -170,21 +170,23 @@ openspace.globebrowsing.createGibsGdalXml = function (layerName, date, resolutio
end
openspace.globebrowsing.parseInfoFile = function (file)
Name = nil
Identifier = nil
Description = nil
ColorFile = nil
HeightFile = nil
local dir = openspace.directoryForPath(file)
dofile(file)
local name = nil
if Name then
name = Name
end
local identifier = Identifier
local name = Name or Identifier
local identifier = Identifier or Name
local color = nil
if ColorFile then
color = {
Identifier = Identifier,
Name = Name or Identifier,
Identifier = identifier,
Name = name,
Description = Description or "",
FilePath = dir .. '/' .. ColorFile,
BlendMode = "Color"
@@ -194,8 +196,8 @@ openspace.globebrowsing.parseInfoFile = function (file)
local height = nil
if HeightFile then
height = {
Identifier = Identifier,
Name = Name or Identifier,
Identifier = identifier,
Name = name,
Description = Description or "",
FilePath = dir .. '/' .. HeightFile,
TilePixelSize = 90

View File

@@ -40,6 +40,8 @@ public:
bool isDone() const override;
private:
void resetCallbacks();
const int UnsetCallbackHandle = -1;
bool _requestedResourceIsSubscribable = false;

View File

@@ -46,34 +46,44 @@ using nlohmann::json;
namespace openspace {
SubscriptionTopic::~SubscriptionTopic() {
if (_prop && _onChangeHandle != UnsetCallbackHandle) {
_prop->removeOnChange(_onChangeHandle);
_onChangeHandle = UnsetCallbackHandle;
}
if (_prop && !_onDeleteHandle) {
_prop->removeOnDelete(_onDeleteHandle);
_onDeleteHandle = UnsetCallbackHandle;
}
resetCallbacks();
}
bool SubscriptionTopic::isDone() const {
return !_requestedResourceIsSubscribable || !_isSubscribedTo;
}
void SubscriptionTopic::resetCallbacks() {
if (!_prop) {
return;
}
if (_onChangeHandle != UnsetCallbackHandle) {
_prop->removeOnChange(_onChangeHandle);
_onChangeHandle = UnsetCallbackHandle;
}
if (_onDeleteHandle != UnsetCallbackHandle) {
_prop->removeOnDelete(_onDeleteHandle);
_onDeleteHandle = UnsetCallbackHandle;
}
}
void SubscriptionTopic::handleJson(const nlohmann::json& json) {
std::string key = json.at(PropertyKey).get<std::string>();
const std::string& event = json.at(EventKey).get<std::string>();
if (event == StartSubscription) {
_prop = property(key);
resetCallbacks();
if (_prop) {
_requestedResourceIsSubscribable = true;
_isSubscribedTo = true;
auto onChange = [this, k = std::move(key)]() {
_connection->sendJson(wrappedPayload(_prop));
};
_onChangeHandle = _prop->onChange(onChange);
_prop->onDelete([this]() {
_onDeleteHandle = _prop->onDelete([this]() {
_onChangeHandle = UnsetCallbackHandle;
_onDeleteHandle = UnsetCallbackHandle;
_isSubscribedTo = false;

View File

@@ -49,23 +49,20 @@ namespace {
} // namespace
namespace {
constexpr const char* KeyDimensions = "Dimensions";
constexpr const char* KeyStepSize = "StepSize";
constexpr const char* KeyTransferFunction = "TransferFunction";
constexpr const char* KeySourceDirectory = "SourceDirectory";
constexpr const char* KeyLowerDomainBound = "LowerDomainBound";
constexpr const char* KeyUpperDomainBound = "UpperDomainBound";
constexpr const char* KeyClipPlanes = "ClipPlanes";
constexpr const char* KeySecondsBefore = "SecondsBefore";
constexpr const char* KeySecondsAfter = "SecondsAfter";
constexpr const char* KeyGridType = "GridType";
constexpr const char* KeyMinValue = "MinValue";
constexpr const char* KeyMaxValue = "MaxValue";
constexpr const char* KeyTime = "Time";
constexpr const char* KeyUnit = "VisUnit";
constexpr const float SecondsInOneDay = 60 * 60 * 24;
constexpr openspace::properties::Property::PropertyInfo StepSizeInfo = {
const char* KeyStepSize = "StepSize";
const char* KeyGridType = "GridType";
const char* KeyTransferFunction = "TransferFunction";
const char* KeySourceDirectory = "SourceDirectory";
const char* KeyClipPlanes = "ClipPlanes";
const char* KeySecondsBefore = "SecondsBefore";
const char* KeySecondsAfter = "SecondsAfter";
const float SecondsInOneDay = 60 * 60 * 24;
constexpr const float VolumeMaxOpacity = 500;
static const openspace::properties::Property::PropertyInfo StepSizeInfo = {
"stepSize",
"Step Size",
"" // @TODO Missing documentation
@@ -119,12 +116,6 @@ namespace {
"" // @TODO Missing documentation
};
constexpr openspace::properties::Property::PropertyInfo OpacityInfo = {
"opacity",
"Opacity",
"" // @TODO Missing documentation
};
constexpr openspace::properties::Property::PropertyInfo rNormalizationInfo = {
"rNormalization",
"Radius normalization",
@@ -176,59 +167,11 @@ namespace openspace::volume {
};
}
//documentation::Documentation RenderableTimeVaryingVolume::TimestepDocumentation() {
// using namespace documentation;
// return {
// "TimevaryingVolumeTimestep",
// "volume_timevaryingvolumetimestep",
// {
// {
// KeyLowerDomainBound,
// new Vector3Verifier<float>,
// Optional::No,
// "Specifies the lower domain bounds in the model coordinate system",
// },
// {
// KeyUpperDomainBound,
// new Vector3Verifier<float>,
// Optional::No,
// "Specifies the upper domain bounds in the model coordinate system",
// },
// {
// KeyDimensions,
// new Vector3Verifier<float>,
// Optional::No,
// "Specifies the number of grid cells in each dimension",
// },
// {
// KeyTime,
// new StringVerifier,
// Optional::No,
// "Specifies the time on the format YYYY-MM-DDTHH:MM:SS.000Z",
// },
// {
// KeyMinValue,
// new DoubleVerifier,
// Optional::No,
// "Specifies the minimum value stored in the volume"
// },
// {
// KeyMaxValue,
// new DoubleVerifier,
// Optional::No,
// "Specifies the maximum value stored in the volume"
// }
// }
// };
//}
RenderableTimeVaryingVolume::RenderableTimeVaryingVolume(
const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _gridType(GridTypeInfo, properties::OptionProperty::DisplayType::Dropdown)
, _stepSize(StepSizeInfo, 0.02f, 0.001f, 1.f)
, _opacity(OpacityInfo, 10.f, 0.f, 500.f)
, _rNormalization(rNormalizationInfo, 0.f, 0.f, 2.f)
, _rUpperBound(rUpperBoundInfo, 1.f, 0.f, 2.f)
, _secondsBefore(SecondsBeforeInfo, 0.f, 0.01f, SecondsInOneDay)
@@ -343,7 +286,6 @@ void RenderableTimeVaryingVolume::initializeGL() {
t.texture->uploadTexture();
}
//_transferFunction->initialize();
_clipPlanes->initialize();
_raycaster = std::make_unique<volume::BasicVolumeRaycaster>(
@@ -381,7 +323,6 @@ void RenderableTimeVaryingVolume::initializeGL() {
addProperty(_triggerTimeJump);
addProperty(_jumpToTimestep);
addProperty(_currentTimestep);
addProperty(_opacity);
addProperty(_rNormalization);
addProperty(_rUpperBound);
addProperty(_gridType);
@@ -488,6 +429,8 @@ void RenderableTimeVaryingVolume::jumpToTimestep(int target) {
}
void RenderableTimeVaryingVolume::update(const UpdateData&) {
_transferFunction->update();
if (_raycaster) {
Timestep* t = currentTimestep();
_currentTimestep = timestepIndex(t);
@@ -517,16 +460,11 @@ void RenderableTimeVaryingVolume::update(const UpdateData&) {
);
}
_raycaster->setVolumeTexture(t->texture);
//_transferFunctionHandler->setUnit(t->metadata.valueUnit);
//_transferFunctionHandler->setMinAndMaxValue(
// t->metadata.minValue, t->metadata.maxValue);
//_transferFunctionHandler->setHistogramProperty(t->histogram);
} else {
_raycaster->setVolumeTexture(nullptr);
}
_raycaster->setStepSize(_stepSize);
_raycaster->setOpacity(_opacity);
_raycaster->setOpacity(_opacity * VolumeMaxOpacity);
_raycaster->setRNormalization(_rNormalization);
_raycaster->setRUpperBound(_rUpperBound);
}

View File

@@ -89,7 +89,6 @@ private:
std::shared_ptr<VolumeClipPlanes> _clipPlanes;
properties::FloatProperty _stepSize;
properties::FloatProperty _opacity;
properties::FloatProperty _rNormalization;
properties::FloatProperty _rUpperBound;
properties::FloatProperty _secondsBefore;