mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-04 02:29:49 -06:00
Restructure DashboardItems
- Add a new class DashboardTextItem that is a DashboardItem that can render text with font
This commit is contained in:
@@ -28,9 +28,12 @@
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <ghoul/glm.h>
|
||||
|
||||
namespace ghoul { class Dictionary; }
|
||||
namespace ghoul::fontrendering { class Font; }
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -55,6 +58,22 @@ protected:
|
||||
properties::BoolProperty _isEnabled;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class DashboardTextItem : public DashboardItem {
|
||||
public:
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
DashboardTextItem(const ghoul::Dictionary& dictionary, float fontSize = 10.f,
|
||||
const std::string& fontName = "Mono");
|
||||
|
||||
protected:
|
||||
properties::StringProperty _fontName;
|
||||
properties::FloatProperty _fontSize;
|
||||
|
||||
std::shared_ptr<ghoul::fontrendering::Font> _font;
|
||||
};
|
||||
|
||||
} // openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___DASHBOARDITEM___H__
|
||||
|
||||
@@ -195,7 +195,6 @@ std::vector<documentation::Documentation> BaseModule::documentations() const {
|
||||
DashboardItemDistance::Documentation(),
|
||||
DashboardItemFramerate::Documentation(),
|
||||
DashboardItemMission::Documentation(),
|
||||
DashboardItemParallelConnection::Documentation(),
|
||||
DashboardItemSimulationIncrement::Documentation(),
|
||||
DashboardItemSpacing::Documentation(),
|
||||
DashboardItemVelocity::Documentation(),
|
||||
|
||||
@@ -40,23 +40,6 @@
|
||||
#include <ghoul/misc/profiling.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* KeyFontMono = "Mono";
|
||||
|
||||
constexpr const float DefaultFontSize = 10.f;
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontNameInfo = {
|
||||
"FontName",
|
||||
"Font Name",
|
||||
"This value is the name of the font that is used. It can either refer to an "
|
||||
"internal name registered previously, or it can refer to a path that is used."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontSizeInfo = {
|
||||
"FontSize",
|
||||
"Font Size",
|
||||
"This value determines the size of the font that is used to render the date."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo SourceTypeInfo = {
|
||||
"SourceType",
|
||||
"Source Type",
|
||||
@@ -118,18 +101,6 @@ documentation::Documentation DashboardItemAngle::Documentation() {
|
||||
new StringEqualVerifier("DashboardItemAngle"),
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
FontNameInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
FontNameInfo.description
|
||||
},
|
||||
{
|
||||
FontSizeInfo.identifier,
|
||||
new IntVerifier,
|
||||
Optional::Yes,
|
||||
FontSizeInfo.description
|
||||
},
|
||||
{
|
||||
SourceTypeInfo.identifier,
|
||||
new StringInListVerifier({
|
||||
@@ -177,7 +148,7 @@ documentation::Documentation DashboardItemAngle::Documentation() {
|
||||
}
|
||||
|
||||
DashboardItemAngle::DashboardItemAngle(const ghoul::Dictionary& dictionary)
|
||||
: DashboardItem(dictionary)
|
||||
: DashboardTextItem(dictionary)
|
||||
, _source{
|
||||
properties::OptionProperty(
|
||||
SourceTypeInfo,
|
||||
@@ -202,8 +173,6 @@ DashboardItemAngle::DashboardItemAngle(const ghoul::Dictionary& dictionary)
|
||||
properties::StringProperty(DestinationNodeNameInfo),
|
||||
nullptr
|
||||
}
|
||||
, _fontName(FontNameInfo, KeyFontMono)
|
||||
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
@@ -211,23 +180,6 @@ DashboardItemAngle::DashboardItemAngle(const ghoul::Dictionary& dictionary)
|
||||
"DashboardItemAngle"
|
||||
);
|
||||
|
||||
if (dictionary.hasKey(FontNameInfo.identifier)) {
|
||||
_fontName = dictionary.value<std::string>(FontNameInfo.identifier);
|
||||
}
|
||||
if (dictionary.hasKey(FontSizeInfo.identifier)) {
|
||||
_fontSize = static_cast<float>(dictionary.value<double>(FontSizeInfo.identifier));
|
||||
}
|
||||
|
||||
_fontName.onChange([this]() {
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontName);
|
||||
|
||||
_fontSize.onChange([this]() {
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontSize);
|
||||
|
||||
_source.type.addOptions({
|
||||
{ Type::Node, "Node" },
|
||||
{ Type::Focus, "Focus" },
|
||||
@@ -352,7 +304,6 @@ DashboardItemAngle::DashboardItemAngle(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
addProperty(_destination.nodeName);
|
||||
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
_buffer.resize(128);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,18 +29,15 @@
|
||||
|
||||
#include <openspace/properties/optionproperty.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <utility>
|
||||
|
||||
namespace ghoul::fontrendering { class Font; }
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class SceneGraphNode;
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
class DashboardItemAngle : public DashboardItem {
|
||||
class DashboardItemAngle : public DashboardTextItem {
|
||||
public:
|
||||
DashboardItemAngle(const ghoul::Dictionary& dictionary);
|
||||
virtual ~DashboardItemAngle() = default;
|
||||
@@ -70,11 +67,7 @@ private:
|
||||
Component _reference;
|
||||
Component _destination;
|
||||
|
||||
properties::StringProperty _fontName;
|
||||
properties::FloatProperty _fontSize;
|
||||
|
||||
std::vector<char> _buffer;
|
||||
std::shared_ptr<ghoul::fontrendering::Font> _font;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -36,22 +36,6 @@
|
||||
#include <ghoul/misc/profiling.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* KeyFontMono = "Mono";
|
||||
constexpr const float DefaultFontSize = 15.f;
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontNameInfo = {
|
||||
"FontName",
|
||||
"Font Name",
|
||||
"This value is the name of the font that is used. It can either refer to an "
|
||||
"internal name registered previously, or it can refer to a path that is used."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontSizeInfo = {
|
||||
"FontSize",
|
||||
"Font Size",
|
||||
"This value determines the size of the font that is used to render the date."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FormatStringInfo = {
|
||||
"FormatString",
|
||||
"Format String",
|
||||
@@ -82,18 +66,6 @@ documentation::Documentation DashboardItemDate::Documentation() {
|
||||
new StringEqualVerifier("DashboardItemDate"),
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
FontNameInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
FontNameInfo.description
|
||||
},
|
||||
{
|
||||
FontSizeInfo.identifier,
|
||||
new IntVerifier,
|
||||
Optional::Yes,
|
||||
FontSizeInfo.description
|
||||
},
|
||||
{
|
||||
FormatStringInfo.identifier,
|
||||
new StringVerifier,
|
||||
@@ -111,9 +83,7 @@ documentation::Documentation DashboardItemDate::Documentation() {
|
||||
}
|
||||
|
||||
DashboardItemDate::DashboardItemDate(const ghoul::Dictionary& dictionary)
|
||||
: DashboardItem(dictionary)
|
||||
, _fontName(FontNameInfo, KeyFontMono)
|
||||
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
|
||||
: DashboardTextItem(dictionary, 15.f)
|
||||
, _formatString(FormatStringInfo, "Date: {} UTC")
|
||||
, _timeFormat(TimeFormatInfo, "YYYY MON DDTHR:MN:SC.### ::RND")
|
||||
{
|
||||
@@ -123,22 +93,6 @@ DashboardItemDate::DashboardItemDate(const ghoul::Dictionary& dictionary)
|
||||
"DashboardItemDate"
|
||||
);
|
||||
|
||||
if (dictionary.hasKey(FontNameInfo.identifier)) {
|
||||
_fontName = dictionary.value<std::string>(FontNameInfo.identifier);
|
||||
}
|
||||
_fontName.onChange([this](){
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontName);
|
||||
|
||||
if (dictionary.hasKey(FontSizeInfo.identifier)) {
|
||||
_fontSize = static_cast<float>(dictionary.value<double>(FontSizeInfo.identifier));
|
||||
}
|
||||
_fontSize.onChange([this](){
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontSize);
|
||||
|
||||
if (dictionary.hasKey(FormatStringInfo.identifier)) {
|
||||
_formatString = dictionary.value<std::string>(FormatStringInfo.identifier);
|
||||
}
|
||||
@@ -148,8 +102,6 @@ DashboardItemDate::DashboardItemDate(const ghoul::Dictionary& dictionary)
|
||||
_timeFormat = dictionary.value<std::string>(TimeFormatInfo.identifier);
|
||||
}
|
||||
addProperty(_timeFormat);
|
||||
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
}
|
||||
|
||||
void DashboardItemDate::render(glm::vec2& penPosition) {
|
||||
|
||||
@@ -28,15 +28,12 @@
|
||||
#include <openspace/rendering/dashboarditem.h>
|
||||
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
|
||||
namespace ghoul::fontrendering { class Font; }
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
class DashboardItemDate : public DashboardItem {
|
||||
class DashboardItemDate : public DashboardTextItem {
|
||||
public:
|
||||
DashboardItemDate(const ghoul::Dictionary& dictionary);
|
||||
~DashboardItemDate() = default;
|
||||
@@ -48,12 +45,8 @@ public:
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
private:
|
||||
properties::StringProperty _fontName;
|
||||
properties::FloatProperty _fontSize;
|
||||
properties::StringProperty _formatString;
|
||||
properties::StringProperty _timeFormat;
|
||||
|
||||
std::shared_ptr<ghoul::fontrendering::Font> _font;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -41,23 +41,6 @@
|
||||
#include <ghoul/misc/profiling.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* KeyFontMono = "Mono";
|
||||
|
||||
constexpr const float DefaultFontSize = 10.f;
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontNameInfo = {
|
||||
"FontName",
|
||||
"Font Name",
|
||||
"This value is the name of the font that is used. It can either refer to an "
|
||||
"internal name registered previously, or it can refer to a path that is used."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontSizeInfo = {
|
||||
"FontSize",
|
||||
"Font Size",
|
||||
"This value determines the size of the font that is used to render the distance."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo SourceTypeInfo = {
|
||||
"SourceType",
|
||||
"Source Type",
|
||||
@@ -136,18 +119,6 @@ documentation::Documentation DashboardItemDistance::Documentation() {
|
||||
new StringEqualVerifier("DashboardItemDistance"),
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
FontNameInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
FontNameInfo.description
|
||||
},
|
||||
{
|
||||
FontSizeInfo.identifier,
|
||||
new IntVerifier,
|
||||
Optional::Yes,
|
||||
FontSizeInfo.description
|
||||
},
|
||||
{
|
||||
SourceTypeInfo.identifier,
|
||||
new StringInListVerifier({
|
||||
@@ -199,9 +170,7 @@ documentation::Documentation DashboardItemDistance::Documentation() {
|
||||
}
|
||||
|
||||
DashboardItemDistance::DashboardItemDistance(const ghoul::Dictionary& dictionary)
|
||||
: DashboardItem(dictionary)
|
||||
, _fontName(FontNameInfo, KeyFontMono)
|
||||
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
|
||||
: DashboardTextItem(dictionary)
|
||||
, _doSimplification(SimplificationInfo, true)
|
||||
, _requestedUnit(RequestedUnitInfo, properties::OptionProperty::DisplayType::Dropdown)
|
||||
, _source{
|
||||
@@ -228,23 +197,6 @@ DashboardItemDistance::DashboardItemDistance(const ghoul::Dictionary& dictionary
|
||||
"DashboardItemDistance"
|
||||
);
|
||||
|
||||
if (dictionary.hasKey(FontNameInfo.identifier)) {
|
||||
_fontName = dictionary.value<std::string>(FontNameInfo.identifier);
|
||||
}
|
||||
if (dictionary.hasKey(FontSizeInfo.identifier)) {
|
||||
_fontSize = static_cast<float>(dictionary.value<double>(FontSizeInfo.identifier));
|
||||
}
|
||||
|
||||
_fontName.onChange([this]() {
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontName);
|
||||
|
||||
_fontSize.onChange([this]() {
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontSize);
|
||||
|
||||
_source.type.addOptions({
|
||||
{ Type::Node, "Node" },
|
||||
{ Type::NodeSurface, "Node Surface" },
|
||||
@@ -378,8 +330,6 @@ DashboardItemDistance::DashboardItemDistance(const ghoul::Dictionary& dictionary
|
||||
}
|
||||
addProperty(_formatString);
|
||||
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
|
||||
_buffer.resize(256);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,18 +30,15 @@
|
||||
#include <openspace/properties/optionproperty.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <utility>
|
||||
|
||||
namespace ghoul::fontrendering { class Font; }
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class SceneGraphNode;
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
class DashboardItemDistance : public DashboardItem {
|
||||
class DashboardItemDistance : public DashboardTextItem {
|
||||
public:
|
||||
DashboardItemDistance(const ghoul::Dictionary& dictionary);
|
||||
virtual ~DashboardItemDistance() = default;
|
||||
@@ -71,8 +68,6 @@ private:
|
||||
std::pair<glm::dvec3, std::string> positionAndLabel(Component& mainComp,
|
||||
Component& otherComp) const;
|
||||
|
||||
properties::StringProperty _fontName;
|
||||
properties::FloatProperty _fontSize;
|
||||
properties::BoolProperty _doSimplification;
|
||||
properties::OptionProperty _requestedUnit;
|
||||
properties::StringProperty _formatString;
|
||||
@@ -81,8 +76,6 @@ private:
|
||||
Component _destination;
|
||||
|
||||
std::vector<char> _buffer;
|
||||
|
||||
std::shared_ptr<ghoul::fontrendering::Font> _font;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -34,22 +34,6 @@
|
||||
#include <ghoul/misc/profiling.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* KeyFontMono = "Mono";
|
||||
constexpr const float DefaultFontSize = 10.f;
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontNameInfo = {
|
||||
"FontName",
|
||||
"Font Name",
|
||||
"This value is the name of the font that is used. It can either refer to an "
|
||||
"internal name registered previously, or it can refer to a path that is used."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontSizeInfo = {
|
||||
"FontSize",
|
||||
"Font Size",
|
||||
"This value determines the size of the font that is used to render the date."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FrametimeInfo = {
|
||||
"FrametimeType",
|
||||
"Type of the frame time display",
|
||||
@@ -165,18 +149,6 @@ documentation::Documentation DashboardItemFramerate::Documentation() {
|
||||
new StringEqualVerifier("DashboardItemFramerate"),
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
FontNameInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
FontNameInfo.description
|
||||
},
|
||||
{
|
||||
FontSizeInfo.identifier,
|
||||
new IntVerifier,
|
||||
Optional::Yes,
|
||||
FontSizeInfo.description
|
||||
},
|
||||
{
|
||||
FrametimeInfo.identifier,
|
||||
new StringInListVerifier({ ValueDtAvg, ValueDtExtremes,
|
||||
@@ -190,9 +162,7 @@ documentation::Documentation DashboardItemFramerate::Documentation() {
|
||||
}
|
||||
|
||||
DashboardItemFramerate::DashboardItemFramerate(const ghoul::Dictionary& dictionary)
|
||||
: DashboardItem(dictionary)
|
||||
, _fontName(FontNameInfo, KeyFontMono)
|
||||
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
|
||||
: DashboardTextItem(dictionary)
|
||||
, _frametimeType(FrametimeInfo, properties::OptionProperty::DisplayType::Dropdown)
|
||||
, _clearCache(ClearCacheInfo)
|
||||
{
|
||||
@@ -202,24 +172,6 @@ DashboardItemFramerate::DashboardItemFramerate(const ghoul::Dictionary& dictiona
|
||||
"DashboardItemFramerate"
|
||||
);
|
||||
|
||||
if (dictionary.hasKey(FontNameInfo.identifier)) {
|
||||
_fontName = dictionary.value<std::string>(FontNameInfo.identifier);
|
||||
}
|
||||
_fontName.onChange([this]() {
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontName);
|
||||
|
||||
if (dictionary.hasKey(FontSizeInfo.identifier)) {
|
||||
_fontSize = static_cast<float>(
|
||||
dictionary.value<double>(FontSizeInfo.identifier)
|
||||
);
|
||||
}
|
||||
_fontSize.onChange([this](){
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontSize);
|
||||
|
||||
_frametimeType.addOptions({
|
||||
{ static_cast<int>(FrametimeType::DtTimeAvg), ValueDtAvg },
|
||||
{ static_cast<int>(FrametimeType::DtTimeExtremes), ValueDtExtremes },
|
||||
@@ -272,8 +224,6 @@ DashboardItemFramerate::DashboardItemFramerate(const ghoul::Dictionary& dictiona
|
||||
});
|
||||
addProperty(_clearCache);
|
||||
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
|
||||
_buffer.resize(128);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,18 +28,15 @@
|
||||
#include <openspace/rendering/dashboarditem.h>
|
||||
|
||||
#include <openspace/properties/optionproperty.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/triggerproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
|
||||
namespace ghoul { class Dictionary; }
|
||||
namespace ghoul::fontrendering { class Font; }
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
class DashboardItemFramerate : public DashboardItem {
|
||||
class DashboardItemFramerate : public DashboardTextItem {
|
||||
public:
|
||||
enum class FrametimeType {
|
||||
DtTimeAvg = 0,
|
||||
@@ -58,13 +55,9 @@ public:
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
private:
|
||||
properties::StringProperty _fontName;
|
||||
properties::FloatProperty _fontSize;
|
||||
properties::OptionProperty _frametimeType;
|
||||
properties::TriggerProperty _clearCache;
|
||||
|
||||
std::shared_ptr<ghoul::fontrendering::Font> _font;
|
||||
|
||||
double _minDeltaTimeCache = 1.0;
|
||||
double _maxDeltaTimeCache = -1.0;
|
||||
bool _shouldClearCache = true;
|
||||
|
||||
@@ -37,22 +37,6 @@
|
||||
#include <stack>
|
||||
|
||||
namespace {
|
||||
constexpr const char* KeyFontMono = "Mono";
|
||||
constexpr const float DefaultFontSize = 15.f;
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontNameInfo = {
|
||||
"FontName",
|
||||
"Font Name",
|
||||
"This value is the name of the font that is used. It can either refer to an "
|
||||
"internal name registered previously, or it can refer to a path that is used."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontSizeInfo = {
|
||||
"FontSize",
|
||||
"Font Size",
|
||||
"This value determines the size of the font that is used to render the date."
|
||||
};
|
||||
|
||||
std::string progressToStr(int size, double t) {
|
||||
std::string progress = "|";
|
||||
int g = static_cast<int>((t * (size - 1)) + 1);
|
||||
@@ -72,62 +56,9 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation DashboardItemMission::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"DashboardItem Mission",
|
||||
"base_dashboarditem_mission",
|
||||
{
|
||||
{
|
||||
"Type",
|
||||
new StringEqualVerifier("DashboardItemMission"),
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
FontNameInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
FontNameInfo.description
|
||||
},
|
||||
{
|
||||
FontSizeInfo.identifier,
|
||||
new IntVerifier,
|
||||
Optional::Yes,
|
||||
FontSizeInfo.description
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
DashboardItemMission::DashboardItemMission(const ghoul::Dictionary& dictionary)
|
||||
: DashboardItem(dictionary)
|
||||
, _fontName(FontNameInfo, KeyFontMono)
|
||||
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"DashboardItemMission"
|
||||
);
|
||||
|
||||
if (dictionary.hasKey(FontNameInfo.identifier)) {
|
||||
_fontName = dictionary.value<std::string>(FontNameInfo.identifier);
|
||||
}
|
||||
_fontName.onChange([this](){
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontName);
|
||||
|
||||
if (dictionary.hasKey(FontSizeInfo.identifier)) {
|
||||
_fontSize = static_cast<float>(dictionary.value<double>(FontSizeInfo.identifier));
|
||||
}
|
||||
_fontSize.onChange([this](){
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontSize);
|
||||
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
}
|
||||
: DashboardTextItem(dictionary, 15.f)
|
||||
{}
|
||||
|
||||
void DashboardItemMission::render(glm::vec2& penPosition) {
|
||||
ZoneScoped
|
||||
|
||||
@@ -27,16 +27,11 @@
|
||||
|
||||
#include <openspace/rendering/dashboarditem.h>
|
||||
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
|
||||
namespace ghoul::fontrendering { class Font; }
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
class DashboardItemMission : public DashboardItem {
|
||||
class DashboardItemMission : public DashboardTextItem {
|
||||
public:
|
||||
DashboardItemMission(const ghoul::Dictionary& dictionary);
|
||||
virtual ~DashboardItemMission() = default;
|
||||
@@ -44,14 +39,6 @@ public:
|
||||
void render(glm::vec2& penPosition) override;
|
||||
|
||||
glm::vec2 size() const override;
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
private:
|
||||
properties::StringProperty _fontName;
|
||||
properties::FloatProperty _fontSize;
|
||||
|
||||
std::shared_ptr<ghoul::fontrendering::Font> _font;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -36,83 +36,12 @@
|
||||
#include <ghoul/font/fontrenderer.h>
|
||||
#include <ghoul/misc/profiling.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* KeyFontMono = "Mono";
|
||||
constexpr const float DefaultFontSize = 10.f;
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontNameInfo = {
|
||||
"FontName",
|
||||
"Font Name",
|
||||
"This value is the name of the font that is used. It can either refer to an "
|
||||
"internal name registered previously, or it can refer to a path that is used."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontSizeInfo = {
|
||||
"FontSize",
|
||||
"Font Size",
|
||||
"This value determines the size of the font that is used to render the date."
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation DashboardItemParallelConnection::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"DashboardItem Parallel Connection",
|
||||
"base_dashboarditem_parallelconnection",
|
||||
{
|
||||
{
|
||||
"Type",
|
||||
new StringEqualVerifier("DashboardItemParallelConnection"),
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
FontNameInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
FontNameInfo.description
|
||||
},
|
||||
{
|
||||
FontSizeInfo.identifier,
|
||||
new IntVerifier,
|
||||
Optional::Yes,
|
||||
FontSizeInfo.description
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
DashboardItemParallelConnection::DashboardItemParallelConnection(
|
||||
const ghoul::Dictionary& dictionary)
|
||||
: DashboardItem(dictionary)
|
||||
, _fontName(FontNameInfo, KeyFontMono)
|
||||
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"DashboardItemParallelConnection"
|
||||
);
|
||||
|
||||
if (dictionary.hasKey(FontNameInfo.identifier)) {
|
||||
_fontName = dictionary.value<std::string>(FontNameInfo.identifier);
|
||||
}
|
||||
_fontName.onChange([this](){
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontName);
|
||||
|
||||
if (dictionary.hasKey(FontSizeInfo.identifier)) {
|
||||
_fontSize = static_cast<float>(dictionary.value<double>(FontSizeInfo.identifier));
|
||||
}
|
||||
_fontSize.onChange([this](){
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontSize);
|
||||
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
}
|
||||
: DashboardTextItem(dictionary)
|
||||
{}
|
||||
|
||||
void DashboardItemParallelConnection::render(glm::vec2& penPosition) {
|
||||
ZoneScoped
|
||||
|
||||
@@ -27,16 +27,11 @@
|
||||
|
||||
#include <openspace/rendering/dashboarditem.h>
|
||||
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
|
||||
namespace ghoul::fontrendering { class Font; }
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
class DashboardItemParallelConnection : public DashboardItem {
|
||||
class DashboardItemParallelConnection : public DashboardTextItem {
|
||||
public:
|
||||
DashboardItemParallelConnection(const ghoul::Dictionary& dictionary);
|
||||
virtual ~DashboardItemParallelConnection() = default;
|
||||
@@ -44,14 +39,6 @@ public:
|
||||
void render(glm::vec2& penPosition) override;
|
||||
|
||||
glm::vec2 size() const override;
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
private:
|
||||
properties::StringProperty _fontName;
|
||||
properties::FloatProperty _fontSize;
|
||||
|
||||
std::shared_ptr<ghoul::fontrendering::Font> _font;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -35,22 +35,6 @@
|
||||
#include <ghoul/misc/profiling.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* KeyFontMono = "Mono";
|
||||
constexpr const float DefaultFontSize = 10.f;
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontNameInfo = {
|
||||
"FontName",
|
||||
"Font Name",
|
||||
"This value is the name of the font that is used. It can either refer to an "
|
||||
"internal name registered previously, or it can refer to a path that is used."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontSizeInfo = {
|
||||
"FontSize",
|
||||
"Font Size",
|
||||
"This value determines the size of the font that is used to render the date."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo PropertyUriInfo = {
|
||||
"URI",
|
||||
"Property URI",
|
||||
@@ -79,18 +63,6 @@ documentation::Documentation DashboardItemPropertyValue::Documentation() {
|
||||
new StringEqualVerifier("DashboardItemPropertyValue"),
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
FontNameInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
FontNameInfo.description
|
||||
},
|
||||
{
|
||||
FontSizeInfo.identifier,
|
||||
new IntVerifier,
|
||||
Optional::Yes,
|
||||
FontSizeInfo.description
|
||||
},
|
||||
{
|
||||
PropertyUriInfo.identifier,
|
||||
new StringVerifier,
|
||||
@@ -109,9 +81,7 @@ documentation::Documentation DashboardItemPropertyValue::Documentation() {
|
||||
|
||||
DashboardItemPropertyValue::DashboardItemPropertyValue(
|
||||
const ghoul::Dictionary& dictionary)
|
||||
: DashboardItem(dictionary)
|
||||
, _fontName(FontNameInfo, KeyFontMono)
|
||||
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
|
||||
: DashboardTextItem(dictionary)
|
||||
, _propertyUri(PropertyUriInfo)
|
||||
, _displayString(DisplayStringInfo)
|
||||
{
|
||||
@@ -121,22 +91,6 @@ DashboardItemPropertyValue::DashboardItemPropertyValue(
|
||||
"DashboardItemPropertyValue"
|
||||
);
|
||||
|
||||
if (dictionary.hasKey(FontNameInfo.identifier)) {
|
||||
_fontName = dictionary.value<std::string>(FontNameInfo.identifier);
|
||||
}
|
||||
_fontName.onChange([this](){
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontName);
|
||||
|
||||
if (dictionary.hasKey(FontSizeInfo.identifier)) {
|
||||
_fontSize = static_cast<float>(dictionary.value<double>(FontSizeInfo.identifier));
|
||||
}
|
||||
_fontSize.onChange([this](){
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontSize);
|
||||
|
||||
if (dictionary.hasKey(PropertyUriInfo.identifier)) {
|
||||
_propertyUri = dictionary.value<std::string>(PropertyUriInfo.identifier);
|
||||
}
|
||||
@@ -147,8 +101,6 @@ DashboardItemPropertyValue::DashboardItemPropertyValue(
|
||||
_displayString = dictionary.value<std::string>(DisplayStringInfo.identifier);
|
||||
}
|
||||
addProperty(_displayString);
|
||||
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
}
|
||||
|
||||
void DashboardItemPropertyValue::render(glm::vec2& penPosition) {
|
||||
|
||||
@@ -28,9 +28,6 @@
|
||||
#include <openspace/rendering/dashboarditem.h>
|
||||
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
|
||||
namespace ghoul::fontrendering { class Font; }
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -38,7 +35,7 @@ namespace properties { class Property; }
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
class DashboardItemPropertyValue : public DashboardItem {
|
||||
class DashboardItemPropertyValue : public DashboardTextItem {
|
||||
public:
|
||||
DashboardItemPropertyValue(const ghoul::Dictionary& dictionary);
|
||||
~DashboardItemPropertyValue() = default;
|
||||
@@ -50,16 +47,11 @@ public:
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
private:
|
||||
properties::StringProperty _fontName;
|
||||
properties::FloatProperty _fontSize;
|
||||
|
||||
properties::Property* _property = nullptr;
|
||||
bool _propertyIsDirty = true;
|
||||
|
||||
properties::StringProperty _propertyUri;
|
||||
properties::StringProperty _displayString;
|
||||
|
||||
std::shared_ptr<ghoul::fontrendering::Font> _font;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -36,22 +36,6 @@
|
||||
#include <ghoul/misc/profiling.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* KeyFontMono = "Mono";
|
||||
constexpr const float DefaultFontSize = 10.f;
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontNameInfo = {
|
||||
"FontName",
|
||||
"Font Name",
|
||||
"This value is the name of the font that is used. It can either refer to an "
|
||||
"internal name registered previously, or it can refer to a path that is used."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontSizeInfo = {
|
||||
"FontSize",
|
||||
"Font Size",
|
||||
"This value determines the size of the font that is used to render the date."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo SimplificationInfo = {
|
||||
"Simplification",
|
||||
"Time Simplification",
|
||||
@@ -112,18 +96,6 @@ documentation::Documentation DashboardItemSimulationIncrement::Documentation() {
|
||||
new StringEqualVerifier("DashboardItemSimulationIncrement"),
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
FontNameInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
FontNameInfo.description
|
||||
},
|
||||
{
|
||||
FontSizeInfo.identifier,
|
||||
new IntVerifier,
|
||||
Optional::Yes,
|
||||
FontSizeInfo.description
|
||||
},
|
||||
{
|
||||
SimplificationInfo.identifier,
|
||||
new BoolVerifier,
|
||||
@@ -154,9 +126,7 @@ documentation::Documentation DashboardItemSimulationIncrement::Documentation() {
|
||||
|
||||
DashboardItemSimulationIncrement::DashboardItemSimulationIncrement(
|
||||
const ghoul::Dictionary& dictionary)
|
||||
: DashboardItem(dictionary)
|
||||
, _fontName(FontNameInfo, KeyFontMono)
|
||||
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
|
||||
: DashboardTextItem(dictionary)
|
||||
, _doSimplification(SimplificationInfo, true)
|
||||
, _requestedUnit(RequestedUnitInfo, properties::OptionProperty::DisplayType::Dropdown)
|
||||
, _transitionFormat(
|
||||
@@ -171,22 +141,6 @@ DashboardItemSimulationIncrement::DashboardItemSimulationIncrement(
|
||||
"DashboardItemSimulationIncrement"
|
||||
);
|
||||
|
||||
if (dictionary.hasKey(FontNameInfo.identifier)) {
|
||||
_fontName = dictionary.value<std::string>(FontNameInfo.identifier);
|
||||
}
|
||||
_fontName.onChange([this](){
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontName);
|
||||
|
||||
if (dictionary.hasKey(FontSizeInfo.identifier)) {
|
||||
_fontSize = static_cast<float>(dictionary.value<double>(FontSizeInfo.identifier));
|
||||
}
|
||||
_fontSize.onChange([this](){
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontSize);
|
||||
|
||||
if (dictionary.hasKey(SimplificationInfo.identifier)) {
|
||||
_doSimplification = dictionary.value<bool>(SimplificationInfo.identifier);
|
||||
}
|
||||
@@ -222,9 +176,6 @@ DashboardItemSimulationIncrement::DashboardItemSimulationIncrement(
|
||||
_regularFormat = dictionary.value<std::string>(RegularFormatInfo.identifier);
|
||||
}
|
||||
addProperty(_regularFormat);
|
||||
|
||||
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
}
|
||||
|
||||
void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) {
|
||||
|
||||
@@ -30,15 +30,12 @@
|
||||
#include <openspace/properties/optionproperty.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
|
||||
namespace ghoul::fontrendering { class Font; }
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
class DashboardItemSimulationIncrement : public DashboardItem {
|
||||
class DashboardItemSimulationIncrement : public DashboardTextItem {
|
||||
public:
|
||||
DashboardItemSimulationIncrement(const ghoul::Dictionary& dictionary);
|
||||
virtual ~DashboardItemSimulationIncrement() = default;
|
||||
@@ -49,15 +46,11 @@ public:
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
private:
|
||||
properties::StringProperty _fontName;
|
||||
properties::FloatProperty _fontSize;
|
||||
properties::BoolProperty _doSimplification;
|
||||
properties::OptionProperty _requestedUnit;
|
||||
|
||||
properties::StringProperty _transitionFormat;
|
||||
properties::StringProperty _regularFormat;
|
||||
|
||||
std::shared_ptr<ghoul::fontrendering::Font> _font;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -33,22 +33,6 @@
|
||||
#include <ghoul/misc/profiling.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* KeyFontMono = "Mono";
|
||||
constexpr const float DefaultFontSize = 10.f;
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontNameInfo = {
|
||||
"FontName",
|
||||
"Font Name",
|
||||
"This value is the name of the font that is used. It can either refer to an "
|
||||
"internal name registered previously, or it can refer to a path that is used."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontSizeInfo = {
|
||||
"FontSize",
|
||||
"Font Size",
|
||||
"This value determines the size of the font that is used to render the date."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo TextInfo = {
|
||||
"Text",
|
||||
"Text",
|
||||
@@ -69,18 +53,6 @@ documentation::Documentation DashboardItemText::Documentation() {
|
||||
new StringEqualVerifier("DashboardItemText"),
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
FontNameInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
FontNameInfo.description
|
||||
},
|
||||
{
|
||||
FontSizeInfo.identifier,
|
||||
new IntVerifier,
|
||||
Optional::Yes,
|
||||
FontSizeInfo.description
|
||||
},
|
||||
{
|
||||
TextInfo.identifier,
|
||||
new StringVerifier,
|
||||
@@ -92,9 +64,7 @@ documentation::Documentation DashboardItemText::Documentation() {
|
||||
}
|
||||
|
||||
DashboardItemText::DashboardItemText(const ghoul::Dictionary& dictionary)
|
||||
: DashboardItem(dictionary)
|
||||
, _fontName(FontNameInfo, KeyFontMono)
|
||||
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
|
||||
: DashboardTextItem(dictionary)
|
||||
, _text(TextInfo, "")
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
@@ -103,28 +73,10 @@ DashboardItemText::DashboardItemText(const ghoul::Dictionary& dictionary)
|
||||
"DashboardItemText"
|
||||
);
|
||||
|
||||
if (dictionary.hasKey(FontNameInfo.identifier)) {
|
||||
_fontName = dictionary.value<std::string>(FontNameInfo.identifier);
|
||||
}
|
||||
_fontName.onChange([this]() {
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontName);
|
||||
|
||||
if (dictionary.hasKey(FontSizeInfo.identifier)) {
|
||||
_fontSize = static_cast<float>(dictionary.value<double>(FontSizeInfo.identifier));
|
||||
}
|
||||
_fontSize.onChange([this]() {
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontSize);
|
||||
|
||||
if (dictionary.hasKey(TextInfo.identifier)) {
|
||||
_text = dictionary.value<std::string>(TextInfo.identifier);
|
||||
};
|
||||
addProperty(_text);
|
||||
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
}
|
||||
|
||||
void DashboardItemText::render(glm::vec2& penPosition) {
|
||||
|
||||
@@ -28,15 +28,12 @@
|
||||
#include <openspace/rendering/dashboarditem.h>
|
||||
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
|
||||
namespace ghoul::fontrendering { class Font; }
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
class DashboardItemText : public DashboardItem {
|
||||
class DashboardItemText : public DashboardTextItem {
|
||||
public:
|
||||
DashboardItemText(const ghoul::Dictionary& dictionary);
|
||||
virtual ~DashboardItemText() = default;
|
||||
@@ -48,11 +45,7 @@ public:
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
private:
|
||||
properties::StringProperty _fontName;
|
||||
properties::FloatProperty _fontSize;
|
||||
properties::StringProperty _text;
|
||||
|
||||
std::shared_ptr<ghoul::fontrendering::Font> _font;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -41,23 +41,6 @@
|
||||
#include <ghoul/misc/profiling.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* KeyFontMono = "Mono";
|
||||
|
||||
constexpr const float DefaultFontSize = 10.f;
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontNameInfo = {
|
||||
"FontName",
|
||||
"Font Name",
|
||||
"This value is the name of the font that is used. It can either refer to an "
|
||||
"internal name registered previously, or it can refer to a path that is used."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontSizeInfo = {
|
||||
"FontSize",
|
||||
"Font Size",
|
||||
"This value determines the size of the font that is used to render the velocity."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo SimplificationInfo = {
|
||||
"Simplification",
|
||||
"Simplification",
|
||||
@@ -100,18 +83,6 @@ documentation::Documentation DashboardItemVelocity::Documentation() {
|
||||
new StringEqualVerifier("DashboardItemVelocity"),
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
FontNameInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
FontNameInfo.description
|
||||
},
|
||||
{
|
||||
FontSizeInfo.identifier,
|
||||
new IntVerifier,
|
||||
Optional::Yes,
|
||||
FontSizeInfo.description
|
||||
},
|
||||
{
|
||||
SimplificationInfo.identifier,
|
||||
new BoolVerifier,
|
||||
@@ -129,9 +100,7 @@ documentation::Documentation DashboardItemVelocity::Documentation() {
|
||||
}
|
||||
|
||||
DashboardItemVelocity::DashboardItemVelocity(const ghoul::Dictionary& dictionary)
|
||||
: DashboardItem(dictionary)
|
||||
, _fontName(FontNameInfo, KeyFontMono)
|
||||
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
|
||||
: DashboardTextItem(dictionary)
|
||||
, _doSimplification(SimplificationInfo, true)
|
||||
, _requestedUnit(RequestedUnitInfo, properties::OptionProperty::DisplayType::Dropdown)
|
||||
{
|
||||
@@ -141,23 +110,6 @@ DashboardItemVelocity::DashboardItemVelocity(const ghoul::Dictionary& dictionary
|
||||
"DashboardItemVelocity"
|
||||
);
|
||||
|
||||
if (dictionary.hasKey(FontNameInfo.identifier)) {
|
||||
_fontName = dictionary.value<std::string>(FontNameInfo.identifier);
|
||||
}
|
||||
if (dictionary.hasKey(FontSizeInfo.identifier)) {
|
||||
_fontSize = static_cast<float>(dictionary.value<double>(FontSizeInfo.identifier));
|
||||
}
|
||||
|
||||
_fontName.onChange([this]() {
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontName);
|
||||
|
||||
_fontSize.onChange([this]() {
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontSize);
|
||||
|
||||
if (dictionary.hasKey(SimplificationInfo.identifier)) {
|
||||
_doSimplification = dictionary.value<bool>(SimplificationInfo.identifier);
|
||||
}
|
||||
@@ -183,8 +135,6 @@ DashboardItemVelocity::DashboardItemVelocity(const ghoul::Dictionary& dictionary
|
||||
}
|
||||
_requestedUnit.setVisibility(properties::Property::Visibility::Hidden);
|
||||
addProperty(_requestedUnit);
|
||||
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
}
|
||||
|
||||
void DashboardItemVelocity::render(glm::vec2& penPosition) {
|
||||
|
||||
@@ -28,20 +28,16 @@
|
||||
#include <openspace/rendering/dashboarditem.h>
|
||||
|
||||
#include <openspace/properties/optionproperty.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <utility>
|
||||
|
||||
namespace ghoul::fontrendering { class Font; }
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class SceneGraphNode;
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
class DashboardItemVelocity : public DashboardItem {
|
||||
class DashboardItemVelocity : public DashboardTextItem {
|
||||
public:
|
||||
DashboardItemVelocity(const ghoul::Dictionary& dictionary);
|
||||
virtual ~DashboardItemVelocity() = default;
|
||||
@@ -53,14 +49,10 @@ public:
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
private:
|
||||
properties::StringProperty _fontName;
|
||||
properties::FloatProperty _fontSize;
|
||||
properties::BoolProperty _doSimplification;
|
||||
properties::OptionProperty _requestedUnit;
|
||||
|
||||
glm::dvec3 _prevPosition = glm::dvec3(0.0);
|
||||
|
||||
std::shared_ptr<ghoul::fontrendering::Font> _font;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -24,9 +24,11 @@
|
||||
|
||||
#include <openspace/rendering/dashboarditem.h>
|
||||
|
||||
#include <openspace/util/factorymanager.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
#include <ghoul/font/fontmanager.h>
|
||||
#include <ghoul/misc/templatefactory.h>
|
||||
|
||||
namespace {
|
||||
@@ -124,4 +126,67 @@ bool DashboardItem::isEnabled() const {
|
||||
return _isEnabled;
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
constexpr openspace::properties::Property::PropertyInfo FontNameInfo = {
|
||||
"FontName",
|
||||
"Font Name",
|
||||
"This value is the name of the font that is used. It can either refer to an "
|
||||
"internal name registered previously, or it can refer to a path that is used."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FontSizeInfo = {
|
||||
"FontSize",
|
||||
"Font Size",
|
||||
"This value determines the size of the font that is used to render the distance."
|
||||
};
|
||||
} // namespace
|
||||
|
||||
documentation::Documentation DashboardTextItem::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"DashboardTextItem",
|
||||
"dashboardtextitem",
|
||||
{
|
||||
{
|
||||
FontNameInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
FontNameInfo.description
|
||||
},
|
||||
{
|
||||
FontSizeInfo.identifier,
|
||||
new IntVerifier,
|
||||
Optional::Yes,
|
||||
FontSizeInfo.description
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
DashboardTextItem::DashboardTextItem(const ghoul::Dictionary& dictionary, float fontSize,
|
||||
const std::string& fontName)
|
||||
: DashboardItem(dictionary)
|
||||
, _fontName(FontNameInfo, fontName)
|
||||
, _fontSize(FontSizeInfo, fontSize, 6.f, 144.f, 1.f)
|
||||
{
|
||||
if (dictionary.hasKey(FontNameInfo.identifier)) {
|
||||
_fontName = dictionary.value<std::string>(FontNameInfo.identifier);
|
||||
}
|
||||
_fontName.onChange([this]() {
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontName);
|
||||
|
||||
if (dictionary.hasKey(FontSizeInfo.identifier)) {
|
||||
_fontSize = static_cast<float>(dictionary.value<double>(FontSizeInfo.identifier));
|
||||
}
|
||||
_fontSize.onChange([this]() {
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
});
|
||||
addProperty(_fontSize);
|
||||
|
||||
_font = global::fontManager->font(_fontName, _fontSize);
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
Reference in New Issue
Block a user