Added max text size control for DU objects.

This commit is contained in:
Jonathas Costa
2017-12-11 21:58:33 -05:00
parent 52da2297be
commit 0d83df09bf
11 changed files with 73 additions and 10 deletions
@@ -16,6 +16,7 @@ return {
TextColor = { 0.3, 0.3, 0.8, 1.0 },
TextSize = 14.8,
TextMinSize = 10.0,
TextMaxSize = 200.0,
Unit = "pc"
},
GuiPath = "/Milky Way/Exoplanets"
@@ -13,6 +13,7 @@ return {
DrawLabels = true,
TextSize = 14.7,
TextMinSize = 6.0,
TextMaxSize = 50.0,
Unit = "pc"
},
GuiPath = "/Milky Way/Stars"
@@ -128,6 +128,13 @@ namespace {
"objects being rendered."
};
static const openspace::properties::Property::PropertyInfo LabelMaxSizeInfo = {
"TextMaxSize",
"Text Max Size",
"The maximum size (in pixels) of the text for the labels for the astronomical "
"objects being rendered."
};
static const openspace::properties::Property::PropertyInfo DrawElementsInfo = {
"DrawElements",
"Draw Elements",
@@ -280,6 +287,12 @@ documentation::Documentation RenderableBillboardsCloud::Documentation() {
Optional::Yes,
LabelMinSizeInfo.description
},
{
LabelMaxSizeInfo.identifier,
new DoubleVerifier,
Optional::Yes,
LabelMaxSizeInfo.description
},
{
ColorOptionInfo.identifier,
new StringListVerifier,
@@ -352,6 +365,7 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
)
, _textSize(TextSizeInfo, 8.0, 0.5, 24.0)
, _textMinSize(LabelMinSizeInfo, 8.0, 0.5, 24.0)
, _textMaxSize(LabelMaxSizeInfo, 500.0, 0.0, 1000.0)
, _drawElements(DrawElementsInfo, true)
, _drawLabels(DrawLabelInfo, false)
, _colorOption(ColorOptionInfo, properties::OptionProperty::DisplayType::Dropdown)
@@ -536,6 +550,11 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
_textMinSize = static_cast<int>(dictionary.value<float>(LabelMinSizeInfo.identifier));
}
addProperty(_textMinSize);
if (dictionary.hasKey(LabelMaxSizeInfo.identifier)) {
_textMaxSize = static_cast<int>(dictionary.value<float>(LabelMaxSizeInfo.identifier));
}
addProperty(_textMaxSize);
}
if (dictionary.hasKey(TransformationMatrixInfo.identifier)) {
@@ -595,7 +614,7 @@ void RenderableBillboardsCloud::initializeGL() {
_fontRenderer = std::unique_ptr<ghoul::fontrendering::FontRenderer>(
ghoul::fontrendering::FontRenderer::createProjectionSubjectText());
if (_font == nullptr) {
size_t _fontSize = 30;
size_t _fontSize = 50;
_font = OsEng.fontManager().font("Mono", static_cast<float>(_fontSize),
ghoul::fontrendering::FontManager::Outline::Yes, ghoul::fontrendering::FontManager::LoadGlyphs::No);
}
@@ -775,6 +794,7 @@ void RenderableBillboardsCloud::renderLabels(const RenderData& data, const glm::
textColor,
pow(10.0, _textSize.value()),
_textMinSize,
_textMaxSize,
modelViewProjectionMatrix,
orthoRight,
orthoUp,
@@ -123,6 +123,7 @@ private:
properties::Vec4Property _textColor;
properties::FloatProperty _textSize;
properties::FloatProperty _textMinSize;
properties::FloatProperty _textMaxSize;
properties::BoolProperty _drawElements;
properties::BoolProperty _drawLabels;
properties::OptionProperty _colorOption;
@@ -108,6 +108,13 @@ namespace {
"objects being rendered."
};
static const openspace::properties::Property::PropertyInfo LabelMaxSizeInfo = {
"TextMaxSize",
"Text Max Size",
"The maximum size (in pixels) of the text for the labels for the astronomical "
"objects being rendered."
};
static const openspace::properties::Property::PropertyInfo DrawElementsInfo = {
"DrawElements",
"Draw Elements",
@@ -207,6 +214,12 @@ documentation::Documentation RenderableDUMeshes::Documentation() {
Optional::Yes,
LabelMinSizeInfo.description
},
{
LabelMaxSizeInfo.identifier,
new IntVerifier,
Optional::Yes,
LabelMaxSizeInfo.description
},
{
TransformationMatrixInfo.identifier,
new Matrix4x4Verifier<double>,
@@ -232,6 +245,7 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary)
, _hasLabel(false)
, _labelDataIsDirty(true)
, _textMinSize(0)
, _textMaxSize(200)
, _alphaValue(TransparencyInfo, 1.f, 0.f, 1.f)
, _scaleFactor(ScaleFactorInfo, 1.f, 0.f, 64.f)
//, _pointColor(ColorInfo, glm::vec3(1.f, 0.4f, 0.2f), glm::vec3(0.f, 0.f, 0.f), glm::vec3(1.0f, 1.0f, 1.0f))
@@ -349,6 +363,10 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary)
if (dictionary.hasKey(LabelMinSizeInfo.identifier)) {
_textMinSize = static_cast<int>(dictionary.value<float>(LabelMinSizeInfo.identifier));
}
if (dictionary.hasKey(LabelMaxSizeInfo.identifier)) {
_textMaxSize = static_cast<int>(dictionary.value<float>(LabelMaxSizeInfo.identifier));
}
}
if (dictionary.hasKey(TransformationMatrixInfo.identifier)) {
@@ -529,6 +547,7 @@ void RenderableDUMeshes::renderLabels(const RenderData& data, const glm::dmat4&
_textColor,
pow(10.0, _textSize.value()),
_textMinSize,
_textMaxSize,
modelViewProjectionMatrix,
orthoRight,
orthoUp,
@@ -124,6 +124,7 @@ private:
bool _labelDataIsDirty;
int _textMinSize;
int _textMaxSize;
properties::FloatProperty _alphaValue;
properties::FloatProperty _scaleFactor;
@@ -108,6 +108,13 @@ namespace {
"objects being rendered."
};
static const openspace::properties::Property::PropertyInfo LabelMaxSizeInfo = {
"TextMaxSize",
"Text Max Size",
"The maximum size (in pixels) of the text for the labels for the astronomical "
"objects being rendered."
};
static const openspace::properties::Property::PropertyInfo DrawElementsInfo = {
"DrawElements",
"Draw Elements",
@@ -227,7 +234,13 @@ documentation::Documentation RenderablePlanesCloud::Documentation() {
new IntVerifier,
Optional::Yes,
LabelMinSizeInfo.description
},
},
{
LabelMaxSizeInfo.identifier,
new IntVerifier,
Optional::Yes,
LabelMaxSizeInfo.description
},
{
TransformationMatrixInfo.identifier,
new Matrix4x4Verifier<double>,
@@ -289,6 +302,7 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary
, _hasLabel(false)
, _labelDataIsDirty(true)
, _textMinSize(0)
, _textMaxSize(200)
, _planeStartingIndexPos(0)
, _textureVariableIndex(0)
, _alphaValue(TransparencyInfo, 1.f, 0.f, 1.f)
@@ -411,7 +425,11 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary
if (dictionary.hasKey(LabelMinSizeInfo.identifier)) {
_textMinSize = static_cast<int>(dictionary.value<float>(LabelMinSizeInfo.identifier));
}
}
if (dictionary.hasKey(LabelMaxSizeInfo.identifier)) {
_textMaxSize = static_cast<int>(dictionary.value<float>(LabelMaxSizeInfo.identifier));
}
}
if (dictionary.hasKey(TransformationMatrixInfo.identifier)) {
@@ -685,6 +703,7 @@ void RenderablePlanesCloud::renderLabels(const RenderData& data, const glm::dmat
textColor,
pow(10.0, _textSize.value()),
_textMinSize,
_textMaxSize,
modelViewProjectionMatrix,
orthoRight,
orthoUp,
@@ -111,6 +111,7 @@ namespace openspace {
bool _labelDataIsDirty;
int _textMinSize;
int _textMaxSize;
int _planeStartingIndexPos;
int _textureVariableIndex;
@@ -152,11 +152,11 @@ void main() {
dvec4(dpos.xyz + scaledUp - scaledRight, dpos.w)));
// Fade-out
float maxVar = 2.0f * maxBillboardSize;
float minVar = maxBillboardSize;
ta = 1.0f - ( (var - minVar)/(maxVar - minVar) );
if (ta == 0.0f)
return;
// float maxVar = 2.0f * maxBillboardSize;
// float minVar = maxBillboardSize;
// ta = 1.0f - ( (var - minVar)/(maxVar - minVar) );
// if (ta == 0.0f)
// return;
}
else if (width < 2.0f * minBillboardSize) {
//return;