mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-06 19:39:56 -05:00
Merge branch 'master' of github.com:OpenSpace/OpenSpace into feature/data-management
This commit is contained in:
@@ -58,10 +58,14 @@ namespace {
|
||||
|
||||
void initTextureReaders() {
|
||||
#ifdef GHOUL_USE_DEVIL
|
||||
ghoul::io::TextureReader::ref().addReader(std::make_shared<ghoul::io::TextureReaderDevIL>());
|
||||
ghoul::io::TextureReader::ref().addReader(
|
||||
std::make_shared<ghoul::io::TextureReaderDevIL>()
|
||||
);
|
||||
#endif // GHOUL_USE_DEVIL
|
||||
#ifdef GHOUL_USE_FREEIMAGE
|
||||
ghoul::io::TextureReader::ref().addReader(std::make_shared<ghoul::io::TextureReaderFreeImage>());
|
||||
ghoul::io::TextureReader::ref().addReader(
|
||||
std::make_shared<ghoul::io::TextureReaderFreeImage>()
|
||||
);
|
||||
#endif // GHOUL_USE_FREEIMAGE
|
||||
}
|
||||
|
||||
@@ -81,7 +85,10 @@ void performTasks(const std::string& path) {
|
||||
|
||||
for (size_t i = 0; i < tasks.size(); i++) {
|
||||
Task& task = *tasks[i].get();
|
||||
LINFO("Performing task " << (i + 1) << " out of " << tasks.size() << ": " << task.description());
|
||||
LINFO(
|
||||
"Performing task " << (i + 1) << " out of " <<
|
||||
tasks.size() << ": " << task.description()
|
||||
);
|
||||
ProgressBar progressBar(100);
|
||||
auto onProgress = [&progressBar](float progress) {
|
||||
progressBar.print(progress * 100);
|
||||
|
||||
@@ -253,7 +253,8 @@ void ControlWidget::onDateChange() {
|
||||
QString script =
|
||||
"openspace.time.setTime('" + date + "');\
|
||||
openspace.setPropertyValue('Interaction.origin', '" + focus + "');\
|
||||
openspace.setPropertyValue('Interaction.coordinateSystem', '" + coordinateSystem + "')";
|
||||
openspace.setPropertyValue('Interaction.coordinateSystem', '" +
|
||||
coordinateSystem + "')";
|
||||
emit scriptActivity(script);
|
||||
}
|
||||
_setTime->blockSignals(true);
|
||||
@@ -265,18 +266,28 @@ void ControlWidget::onFocusChange() {
|
||||
int index = _focusNode->currentIndex();
|
||||
QString name = FocusNodes[index].name;
|
||||
QString coordinateSystem = FocusNodes[index].coordinateSystem;
|
||||
QString script = "openspace.setPropertyValue('Interaction.origin', '" + name + "');openspace.setPropertyValue('Interaction.coordinateSystem', '" + coordinateSystem + "');";
|
||||
QString script = "openspace.setPropertyValue('Interaction.origin', '" + name +
|
||||
"');openspace.setPropertyValue('Interaction.coordinateSystem', '" +
|
||||
coordinateSystem + "');";
|
||||
emit scriptActivity(script);
|
||||
}
|
||||
|
||||
void ControlWidget::onFocusToTargetButton() {
|
||||
std::string target = reinterpret_cast<MainWindow*>(parent())->nextTarget();
|
||||
if (!target.empty()) {
|
||||
auto it = std::find_if(std::begin(FocusNodes), std::end(FocusNodes), [target](const FocusNode& n) { return n.guiName.toLower() == QString::fromStdString(target).toLower(); });
|
||||
auto it = std::find_if(
|
||||
std::begin(FocusNodes),
|
||||
std::end(FocusNodes),
|
||||
[target](const FocusNode& n) {
|
||||
return n.guiName.toLower() == QString::fromStdString(target).toLower();
|
||||
});
|
||||
if (it != std::end(FocusNodes)) {
|
||||
QString name = it->name;
|
||||
QString coordinateSystem = it->coordinateSystem;
|
||||
QString script = "openspace.setPropertyValue('Interaction.origin', '" + name + "');openspace.setPropertyValue('Interaction.coordinateSystem', '" + coordinateSystem + "');";
|
||||
QString script =
|
||||
"openspace.setPropertyValue('Interaction.origin', '" + name +
|
||||
"');openspace.setPropertyValue('Interaction.coordinateSystem', '" +
|
||||
coordinateSystem + "');";
|
||||
emit scriptActivity(script);
|
||||
}
|
||||
}
|
||||
@@ -292,7 +303,9 @@ void ControlWidget::onFocusToNewHorizonsButton() {
|
||||
else
|
||||
coordinateSystem = "Pluto";
|
||||
|
||||
QString script = "openspace.setPropertyValue('Interaction.origin', 'NewHorizons');openspace.setPropertyValue('Interaction.coordinateSystem', '" + coordinateSystem + "');";
|
||||
QString script = "openspace.setPropertyValue('Interaction.origin', 'NewHorizons');\
|
||||
openspace.setPropertyValue('Interaction.coordinateSystem', '" + coordinateSystem +
|
||||
"');";
|
||||
emit scriptActivity(script);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,9 @@ QLineEdit {
|
||||
|
||||
QSlider::groove:horizontal {
|
||||
border: 1px solid #999999;
|
||||
height: 8px; /* the groove expands to the size of the slider by default. by giving it a height, it has a fixed size */
|
||||
/* the groove expands to the size of the slider by default. by giving it a height,
|
||||
it has a fixed size */
|
||||
height: 8px;
|
||||
background: qlineargradient(
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #c4c4c4,
|
||||
@@ -72,7 +74,9 @@ QSlider::handle:horizontal {
|
||||
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f);
|
||||
border: 1px solid #5c5c5c;
|
||||
width: 18px;
|
||||
margin: -2px 0; /* handle is placed by default on the contents rect of the groove. Expand outside the groove */
|
||||
/* handle is placed by default on the contents rect of the groove.
|
||||
Expand outside the groove */
|
||||
margin: -2px 0;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
|
||||
@@ -257,17 +257,23 @@ void MainWindow::handleStatusMessage(QByteArray data) {
|
||||
QString::fromStdString(std::string(timeString.begin(), timeString.end())),
|
||||
QString::number(delta.value)
|
||||
);
|
||||
_timelineWidget->setCurrentTime(std::string(timeString.begin(), timeString.end()), et.value);
|
||||
_timelineWidget->setCurrentTime(
|
||||
std::string(timeString.begin(), timeString.end()),
|
||||
et.value
|
||||
);
|
||||
}
|
||||
|
||||
std::vector<std::string> instrumentsFromId(uint16_t instrumentId, std::map<uint16_t, std::string> instrumentMap) {
|
||||
std::vector<std::string> instrumentsFromId(uint16_t instrumentId,
|
||||
std::map<uint16_t, std::string> instrumentMap)
|
||||
{
|
||||
std::vector<std::string> results;
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
uint16_t testValue = 1 << i;
|
||||
if ((testValue & instrumentId) != 0) {
|
||||
std::string t = instrumentMap.at(testValue);
|
||||
if (t.empty())
|
||||
if (t.empty()) {
|
||||
qDebug() << "Empty instrument";
|
||||
}
|
||||
results.push_back(t);
|
||||
}
|
||||
}
|
||||
@@ -318,15 +324,21 @@ QByteArray MainWindow::handlePlaybook(QByteArray data) {
|
||||
qDebug() << "Instruments were empty";
|
||||
images.push_back(image);
|
||||
}
|
||||
_timelineWidget->setData(std::move(images), std::move(targetMap), std::move(instrumentMap));
|
||||
_timelineWidget->setData(
|
||||
std::move(images),
|
||||
std::move(targetMap),
|
||||
std::move(instrumentMap)
|
||||
);
|
||||
|
||||
auto dataSize = data.size();
|
||||
auto readSize = currentReadLocation;
|
||||
auto extraBytes = dataSize - readSize;
|
||||
if (extraBytes > 0)
|
||||
if (extraBytes > 0) {
|
||||
return data.mid(currentReadLocation);
|
||||
else
|
||||
}
|
||||
else {
|
||||
return QByteArray();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::sendScript(QString script) {
|
||||
@@ -361,7 +373,10 @@ std::string MainWindow::nextTarget() const {
|
||||
}
|
||||
|
||||
void MainWindow::fullyConnected() {
|
||||
_informationWidget->logInformation("Connected to " + _socket->peerName() + " on port " + QString::number(_socket->peerPort()) + ".");
|
||||
_informationWidget->logInformation(
|
||||
"Connected to " + _socket->peerName() + " on port " +
|
||||
QString::number(_socket->peerPort()) + "."
|
||||
);
|
||||
|
||||
_configurationWidget->socketConnected();
|
||||
_timeControlWidget->socketConnected();
|
||||
@@ -379,6 +394,5 @@ void MainWindow::printMapping(QByteArray data) {
|
||||
std::string mapping = readFromBuffer<std::string>(buffer, currentReadPosition);
|
||||
|
||||
qDebug() << identifier << ": " << QString::fromStdString(mapping);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,12 @@ void TimelineWidget::paintEvent(QPaintEvent* event) {
|
||||
|
||||
QRectF fullRect = contentsRect();
|
||||
QRectF contentRect(0, 0, fullRect.width() - 1, fullRect.height() - LegendHeight);
|
||||
QRectF legendRect(0, fullRect.bottom() - LegendHeight, fullRect.right(), fullRect.bottom());
|
||||
QRectF legendRect(
|
||||
0,
|
||||
fullRect.bottom() - LegendHeight,
|
||||
fullRect.right(),
|
||||
fullRect.bottom()
|
||||
);
|
||||
|
||||
painter.save();
|
||||
drawContent(painter, contentRect);
|
||||
@@ -101,10 +106,17 @@ void TimelineWidget::paintEvent(QPaintEvent* event) {
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
void TimelineWidget::setData(std::vector<Image> images, std::map<uint8_t, std::string> targetMap, std::map<uint16_t, std::string> instrumentMap) {
|
||||
void TimelineWidget::setData(std::vector<Image> images,
|
||||
std::map<uint8_t, std::string> targetMap,
|
||||
std::map<uint16_t, std::string> instrumentMap)
|
||||
{
|
||||
_images.insert(_images.end(), images.begin(), images.end());
|
||||
|
||||
std::sort(_images.begin(), _images.end(), [](const Image& a, const Image& b) { return a.beginning < b.beginning; });
|
||||
std::sort(
|
||||
_images.begin(),
|
||||
_images.end(),
|
||||
[](const Image& a, const Image& b) { return a.beginning < b.beginning; }
|
||||
);
|
||||
|
||||
_targetMap.insert(targetMap.begin(), targetMap.end());
|
||||
_instrumentMap.insert(instrumentMap.begin(), instrumentMap.end());
|
||||
@@ -148,8 +160,15 @@ void TimelineWidget::drawContent(QPainter& painter, QRectF rect) {
|
||||
// Draw current time
|
||||
painter.setBrush(QBrush(Qt::black));
|
||||
painter.setPen(QPen(Qt::black, 2));
|
||||
painter.drawLine(QPointF(0, timelineRect.height() / 2), QPointF(timelineRect.width(), timelineRect.height() / 2));
|
||||
painter.drawText(timelineRect.width(), timelineRect.height() / 2 + TextOffset, QString::fromStdString(_currentTime.time));
|
||||
painter.drawLine(
|
||||
QPointF(0, timelineRect.height() / 2),
|
||||
QPointF(timelineRect.width(), timelineRect.height() / 2)
|
||||
);
|
||||
painter.drawText(
|
||||
timelineRect.width(),
|
||||
timelineRect.height() / 2 + TextOffset,
|
||||
QString::fromStdString(_currentTime.time)
|
||||
);
|
||||
}
|
||||
|
||||
void TimelineWidget::drawLegend(QPainter& painter, QRectF rect) {
|
||||
@@ -171,14 +190,21 @@ void TimelineWidget::drawLegend(QPainter& painter, QRectF rect) {
|
||||
;
|
||||
painter.setBrush(QBrush(InstrumentColors[QString::fromStdString(instrument)]));
|
||||
painter.setPen(QPen(InstrumentColors[QString::fromStdString(instrument)]));
|
||||
painter.drawRect(currentHorizontalPosition, currentVerticalPosition, BoxSize, BoxSize);
|
||||
painter.drawRect(
|
||||
currentHorizontalPosition,
|
||||
currentVerticalPosition,
|
||||
BoxSize,
|
||||
BoxSize
|
||||
);
|
||||
currentHorizontalPosition += BoxSize + Padding;
|
||||
|
||||
painter.setPen(QPen(QColor(200, 200, 200)));
|
||||
//painter.setPen(QPen(Qt::black));
|
||||
painter.drawText(currentHorizontalPosition, currentVerticalPosition + BoxSize / 2 + TextOffset, InstrumentConversion[QString::fromStdString(instrument)]);
|
||||
// int textWidth = painter.boundingRect(QRect(), QString::fromStdString(instrument)).width();
|
||||
//currentHorizontalPosition += std::max(textWidth, 25) + Padding;
|
||||
painter.drawText(
|
||||
currentHorizontalPosition,
|
||||
currentVerticalPosition + BoxSize / 2 + TextOffset,
|
||||
InstrumentConversion[QString::fromStdString(instrument)]
|
||||
);
|
||||
currentHorizontalPosition += 125;
|
||||
}
|
||||
}
|
||||
@@ -198,11 +224,12 @@ void TimelineWidget::drawImages(
|
||||
{
|
||||
std::set<std::string> instrumentSet;
|
||||
for (Image* i : images) {
|
||||
for (std::string instrument : i->instruments)
|
||||
for (std::string instrument : i->instruments) {
|
||||
instrumentSet.insert(instrument);
|
||||
}
|
||||
}
|
||||
std::map<std::string, int> instruments;
|
||||
for (std::set<std::string>::const_iterator it = instrumentSet.begin(); it != instrumentSet.end(); ++it)
|
||||
for (auto it = instrumentSet.begin(); it != instrumentSet.end(); ++it)
|
||||
instruments[*it] = std::distance(instrumentSet.begin(), it);
|
||||
|
||||
for (Image* i : images) {
|
||||
@@ -215,8 +242,9 @@ void TimelineWidget::drawImages(
|
||||
int height = (timelineRect.top() + timelineRect.height() * tEnd) - loc;
|
||||
height = std::max(height, 5);
|
||||
|
||||
if (loc + height > timelineRect.height())
|
||||
if (loc + height > timelineRect.height()) {
|
||||
height = timelineRect.height() - loc;
|
||||
}
|
||||
|
||||
std::string target = i->target;
|
||||
auto it = std::find(_targets.begin(), _targets.end(), target);
|
||||
@@ -224,10 +252,13 @@ void TimelineWidget::drawImages(
|
||||
|
||||
for (std::string instrument : i->instruments) {
|
||||
auto it = std::find(_instruments.begin(), _instruments.end(), instrument);
|
||||
if (it == _instruments.end())
|
||||
if (it == _instruments.end()) {
|
||||
qDebug() << "Instrument not found";
|
||||
}
|
||||
|
||||
painter.setBrush(QBrush(InstrumentColors[QString::fromStdString(instrument)]));
|
||||
painter.setBrush(
|
||||
QBrush(InstrumentColors[QString::fromStdString(instrument)])
|
||||
);
|
||||
|
||||
double width = timelineRect.width() / instruments.size();
|
||||
double pos = instruments[instrument] * width;
|
||||
@@ -238,7 +269,8 @@ void TimelineWidget::drawImages(
|
||||
if (height >= 5) {
|
||||
painter.setBrush(QBrush(Qt::black));
|
||||
painter.setPen(QPen(Qt::black));
|
||||
QString line = QString::fromStdString(i->beginningString) + QString(" (") + QString::fromStdString(i->target) + QString(")");
|
||||
QString line = QString::fromStdString(i->beginningString) + QString(" (") +
|
||||
QString::fromStdString(i->target) + QString(")");
|
||||
|
||||
painter.drawText(timelineRect.width(), loc + height / 2 + TextOffset, line);
|
||||
}
|
||||
@@ -257,9 +289,16 @@ void TimelineWidget::socketDisconnected() {
|
||||
}
|
||||
|
||||
std::string TimelineWidget::nextTarget() const {
|
||||
auto it = std::lower_bound(_images.begin(), _images.end(), _currentTime.et, [](const Image& i, double et) { return i.beginning < et; });
|
||||
if (it != _images.end())
|
||||
auto it = std::lower_bound(
|
||||
_images.begin(),
|
||||
_images.end(),
|
||||
_currentTime.et,
|
||||
[](const Image& i, double et) { return i.beginning < et; }
|
||||
);
|
||||
if (it != _images.end()) {
|
||||
return it->target;
|
||||
else
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,8 @@ Q_OBJECT
|
||||
public:
|
||||
TimelineWidget(QWidget* parent);
|
||||
|
||||
void setData(std::vector<Image> images, std::map<uint8_t, std::string> targetMap, std::map<uint16_t, std::string> instrumentMap);
|
||||
void setData(std::vector<Image> images, std::map<uint8_t, std::string> targetMap,
|
||||
std::map<uint16_t, std::string> instrumentMap);
|
||||
void setCurrentTime(std::string currentTime, double et);
|
||||
void socketConnected();
|
||||
void socketDisconnected();
|
||||
@@ -51,7 +52,8 @@ protected:
|
||||
void paintEvent(QPaintEvent* event);
|
||||
void drawContent(QPainter& painter, QRectF rect);
|
||||
void drawLegend(QPainter& painter, QRectF rect);
|
||||
void drawImages(QPainter& painter, QRectF timelineRect, std::vector<Image*> images, double minimumTime, double maximumTime);
|
||||
void drawImages(QPainter& painter, QRectF timelineRect, std::vector<Image*> images,
|
||||
double minimumTime, double maximumTime);
|
||||
|
||||
private:
|
||||
std::vector<Image> _images;
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
return {
|
||||
-- Earth barycenter module
|
||||
{
|
||||
Name = "Fixed Rotation",
|
||||
Parent = "EarthBarycenter",
|
||||
Transform = {
|
||||
Rotation = {
|
||||
Type = "FixedRotation",
|
||||
Attached = "Fixed Rotation",
|
||||
XAxis = { 0.0, 1.0, 0.0 },
|
||||
XAxisOrthogonal = true,
|
||||
YAxis = "EarthBarycenter"
|
||||
},
|
||||
Translation = {
|
||||
Type = "SpiceTranslation",
|
||||
Target = "MOON",
|
||||
Observer = "EARTH BARYCENTER",
|
||||
Kernels = "${OPENSPACE_DATA}/spice/de430_1850-2150.bsp"
|
||||
},
|
||||
Scale = {
|
||||
Type = "StaticScale",
|
||||
Scale = 10000000
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableModel",
|
||||
Geometry = {
|
||||
Type = "MultiModelGeometry",
|
||||
GeometryFile = "teapot.obj",
|
||||
-- Magnification = 4,
|
||||
},
|
||||
ColorTexture = "placeholder.png",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ struct TestResult {
|
||||
ExtraKey, ///< The exhaustive documentation contained an extra key
|
||||
WrongType, ///< The key's value was not of the expected type
|
||||
Verification, ///< The value did not pass a necessary non-type verifier
|
||||
UnknownIdentifier ///< If the identifier for a ReferencingVerifier did not exist
|
||||
UnknownIdentifier ///< The identifier for a ReferencingVerifier did not exist
|
||||
};
|
||||
/// The offending key that caused the Offense. In the case of a nested table,
|
||||
/// this value will be the fully qualified name of the key
|
||||
|
||||
@@ -546,7 +546,9 @@ struct GreaterVerifier : public OperatorVerifier<T, std::greater<typename T::Typ
|
||||
* as) BoolVerifier, StringVerifier, TableVerifier, or VectorVerifier.
|
||||
*/
|
||||
template <typename T>
|
||||
struct GreaterEqualVerifier : public OperatorVerifier<T, std::greater_equal<typename T::Type>> {
|
||||
struct GreaterEqualVerifier : public OperatorVerifier<T,
|
||||
std::greater_equal<typename T::Type>>
|
||||
{
|
||||
static_assert(
|
||||
!std::is_base_of<BoolVerifier, T>::value,
|
||||
"T cannot be BoolVerifier"
|
||||
|
||||
@@ -345,7 +345,9 @@ TestResult DeprecatedVerifier<T>::operator()(const ghoul::Dictionary& dict,
|
||||
const std::string& key) const
|
||||
{
|
||||
TestResult res = T::operator()(dict, key);
|
||||
res.warnings.push_back(TestResult::Warning{ key, TestResult::Warning::Reason::Deprecated });
|
||||
res.warnings.push_back(
|
||||
TestResult::Warning{ key, TestResult::Warning::Reason::Deprecated }
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -130,9 +130,9 @@ public:
|
||||
static const std::string PartHttpProxyPort;
|
||||
/// The key that stores the authentication method of the http proxy
|
||||
static const std::string PartHttpProxyAuthentication;
|
||||
/// The key that stores the username to use for authentication to access the http proxy
|
||||
/// Key that stores the username to use for authentication to access the http proxy
|
||||
static const std::string PartHttpProxyUser;
|
||||
/// The key that stores the password to use for authentication to access the http proxy
|
||||
/// Key that stores the password to use for authentication to access the http proxy
|
||||
static const std::string PartHttpProxyPassword;
|
||||
/// The key that stores the dictionary containing information about debug contexts
|
||||
static const std::string KeyOpenGLDebugContext;
|
||||
|
||||
@@ -102,8 +102,10 @@ public:
|
||||
);
|
||||
|
||||
std::future<MemoryFile> fetchFile(
|
||||
const std::string& url,
|
||||
SuccessCallback successCallback = SuccessCallback(), ErrorCallback errorCallback = ErrorCallback());
|
||||
const std::string& url,
|
||||
SuccessCallback successCallback = SuccessCallback(),
|
||||
ErrorCallback errorCallback = ErrorCallback());
|
||||
|
||||
void getFileExtension(const std::string& url,
|
||||
RequestFinishedCallback finishedCallback = RequestFinishedCallback());
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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_CORE___TOUCHBAR___H__
|
||||
#define __OPENSPACE_CORE___TOUCHBAR___H__
|
||||
|
||||
namespace openspace {
|
||||
|
||||
// Initializes the touch bar on MacOS (if available) and creates all the buttons and
|
||||
// callbacks
|
||||
void showTouchbar();
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___TOUCHBAR___H__
|
||||
@@ -52,27 +52,51 @@ struct CameraKeyframe {
|
||||
|
||||
double _timestamp;
|
||||
|
||||
void serialize(std::vector<char> &buffer){
|
||||
void serialize(std::vector<char> &buffer) {
|
||||
// Add position
|
||||
buffer.insert(buffer.end(), reinterpret_cast<char*>(&_position), reinterpret_cast<char*>(&_position) + sizeof(_position));
|
||||
buffer.insert(
|
||||
buffer.end(),
|
||||
reinterpret_cast<char*>(&_position),
|
||||
reinterpret_cast<char*>(&_position) + sizeof(_position)
|
||||
);
|
||||
|
||||
// Add orientation
|
||||
buffer.insert(buffer.end(), reinterpret_cast<char*>(&_rotation), reinterpret_cast<char*>(&_rotation) + sizeof(_rotation));
|
||||
buffer.insert(
|
||||
buffer.end(),
|
||||
reinterpret_cast<char*>(&_rotation),
|
||||
reinterpret_cast<char*>(&_rotation) + sizeof(_rotation)
|
||||
);
|
||||
|
||||
// Follow focus node rotation?
|
||||
buffer.insert(buffer.end(), reinterpret_cast<char*>(&_followNodeRotation), reinterpret_cast<char*>(&_followNodeRotation) + sizeof(_followNodeRotation));
|
||||
buffer.insert(
|
||||
buffer.end(),
|
||||
reinterpret_cast<char*>(&_followNodeRotation),
|
||||
reinterpret_cast<char*>(&_followNodeRotation) + sizeof(_followNodeRotation)
|
||||
);
|
||||
|
||||
int nodeNameLength = static_cast<int>(_focusNode.size());
|
||||
|
||||
// Add focus node
|
||||
buffer.insert(buffer.end(), reinterpret_cast<char*>(&nodeNameLength), reinterpret_cast<char*>(&nodeNameLength) + sizeof(nodeNameLength));
|
||||
buffer.insert(buffer.end(), _focusNode.data(), _focusNode.data() + nodeNameLength);
|
||||
buffer.insert(
|
||||
buffer.end(),
|
||||
reinterpret_cast<char*>(&nodeNameLength),
|
||||
reinterpret_cast<char*>(&nodeNameLength) + sizeof(nodeNameLength)
|
||||
);
|
||||
buffer.insert(
|
||||
buffer.end(),
|
||||
_focusNode.data(),
|
||||
_focusNode.data() + nodeNameLength
|
||||
);
|
||||
|
||||
// Add timestamp
|
||||
buffer.insert(buffer.end(), reinterpret_cast<char*>(&_timestamp), reinterpret_cast<char*>(&_timestamp) + sizeof(_timestamp));
|
||||
buffer.insert(
|
||||
buffer.end(),
|
||||
reinterpret_cast<char*>(&_timestamp),
|
||||
reinterpret_cast<char*>(&_timestamp) + sizeof(_timestamp)
|
||||
);
|
||||
};
|
||||
|
||||
void deserialize(const std::vector<char> &buffer){
|
||||
void deserialize(const std::vector<char> &buffer) {
|
||||
int offset = 0;
|
||||
int size = 0;
|
||||
|
||||
@@ -120,19 +144,39 @@ struct TimeKeyframe {
|
||||
|
||||
void serialize(std::vector<char> &buffer){
|
||||
// Add current time
|
||||
buffer.insert(buffer.end(), reinterpret_cast<char*>(&_time), reinterpret_cast<char*>(&_time) + sizeof(_time));
|
||||
buffer.insert(
|
||||
buffer.end(),
|
||||
reinterpret_cast<char*>(&_time),
|
||||
reinterpret_cast<char*>(&_time) + sizeof(_time)
|
||||
);
|
||||
|
||||
// Add delta time
|
||||
buffer.insert(buffer.end(), reinterpret_cast<char*>(&_dt), reinterpret_cast<char*>(&_dt) + sizeof(_dt));
|
||||
buffer.insert(
|
||||
buffer.end(),
|
||||
reinterpret_cast<char*>(&_dt),
|
||||
reinterpret_cast<char*>(&_dt) + sizeof(_dt)
|
||||
);
|
||||
|
||||
// Add whether time is paused or not
|
||||
buffer.insert(buffer.end(), reinterpret_cast<char*>(&_paused), reinterpret_cast<char*>(&_paused) + sizeof(_paused));
|
||||
buffer.insert(
|
||||
buffer.end(),
|
||||
reinterpret_cast<char*>(&_paused),
|
||||
reinterpret_cast<char*>(&_paused) + sizeof(_paused)
|
||||
);
|
||||
|
||||
// Add whether a time jump is necessary (recompute paths etc)
|
||||
buffer.insert(buffer.end(), reinterpret_cast<char*>(&_requiresTimeJump), reinterpret_cast<char*>(&_requiresTimeJump) + sizeof(_requiresTimeJump));
|
||||
buffer.insert(
|
||||
buffer.end(),
|
||||
reinterpret_cast<char*>(&_requiresTimeJump),
|
||||
reinterpret_cast<char*>(&_requiresTimeJump) + sizeof(_requiresTimeJump)
|
||||
);
|
||||
|
||||
// Add timestamp
|
||||
buffer.insert(buffer.end(), reinterpret_cast<char*>(&_timestamp), reinterpret_cast<char*>(&_timestamp) + sizeof(_timestamp));
|
||||
buffer.insert(
|
||||
buffer.end(),
|
||||
reinterpret_cast<char*>(&_timestamp),
|
||||
reinterpret_cast<char*>(&_timestamp) + sizeof(_timestamp)
|
||||
);
|
||||
};
|
||||
|
||||
void deserialize(const std::vector<char> &buffer){
|
||||
|
||||
@@ -48,7 +48,8 @@ public:
|
||||
void sendMessages();
|
||||
|
||||
// Initial Connection Messages
|
||||
void setInitialConnectionMessage(MessageIdentifier identifier, std::vector<char> message);
|
||||
void setInitialConnectionMessage(MessageIdentifier identifier,
|
||||
std::vector<char> message);
|
||||
void sendInitialInformation();
|
||||
|
||||
// Background
|
||||
|
||||
@@ -53,8 +53,10 @@ public:
|
||||
|
||||
bool isMeasuringPerformance() const;
|
||||
|
||||
void storeIndividualPerformanceMeasurement(std::string identifier, long long nanoseconds);
|
||||
void storeScenePerformanceMeasurements(const std::vector<SceneGraphNode*>& sceneNodes);
|
||||
void storeIndividualPerformanceMeasurement(std::string identifier,
|
||||
long long nanoseconds);
|
||||
void storeScenePerformanceMeasurements(
|
||||
const std::vector<SceneGraphNode*>& sceneNodes);
|
||||
|
||||
void outputLogs();
|
||||
|
||||
|
||||
@@ -37,7 +37,8 @@ class PerformanceManager;
|
||||
|
||||
class PerformanceMeasurement {
|
||||
public:
|
||||
PerformanceMeasurement(std::string identifier, performance::PerformanceManager* manager);
|
||||
PerformanceMeasurement(std::string identifier,
|
||||
performance::PerformanceManager* manager);
|
||||
~PerformanceMeasurement();
|
||||
|
||||
private:
|
||||
|
||||
@@ -34,9 +34,10 @@ class NumericalProperty : public TemplateProperty<T> {
|
||||
public:
|
||||
NumericalProperty(Property::PropertyInfo info);
|
||||
NumericalProperty(Property::PropertyInfo info, T value);
|
||||
NumericalProperty(Property::PropertyInfo info, T value, T minimumValue, T maximumValue);
|
||||
NumericalProperty(Property::PropertyInfo info, T value, T minimumValue, T maximumValue,
|
||||
T steppingValue);
|
||||
NumericalProperty(Property::PropertyInfo info, T value, T minimumValue,
|
||||
T maximumValue);
|
||||
NumericalProperty(Property::PropertyInfo info, T value, T minimumValue,
|
||||
T maximumValue, T steppingValue);
|
||||
|
||||
bool getLuaValue(lua_State* state) const override;
|
||||
bool setLuaValue(lua_State* state) override;
|
||||
|
||||
@@ -63,22 +63,26 @@ std::string PropertyDelegate<TemplateProperty<std::vector<int>>>::className();
|
||||
|
||||
template <>
|
||||
template <>
|
||||
std::vector<int> PropertyDelegate<TemplateProperty<std::vector<int>>>::fromLuaValue(lua_State* state, bool& success);
|
||||
std::vector<int> PropertyDelegate<TemplateProperty<std::vector<int>>>::fromLuaValue(
|
||||
lua_State* state, bool& success);
|
||||
|
||||
template <>
|
||||
template <>
|
||||
bool PropertyDelegate<TemplateProperty<std::vector<int>>>::toLuaValue(lua_State* state, std::vector<int> value);
|
||||
bool PropertyDelegate<TemplateProperty<std::vector<int>>>::toLuaValue(
|
||||
lua_State* state, std::vector<int> value);
|
||||
|
||||
template <>
|
||||
int PropertyDelegate<TemplateProperty<std::vector<int>>>::typeLua();
|
||||
|
||||
template <>
|
||||
template <>
|
||||
std::vector<int> PropertyDelegate<TemplateProperty<std::vector<int>>>::fromString(std::string value, bool& success);
|
||||
std::vector<int> PropertyDelegate<TemplateProperty<std::vector<int>>>::fromString(
|
||||
std::string value, bool& success);
|
||||
|
||||
template <>
|
||||
template <>
|
||||
bool PropertyDelegate<TemplateProperty<std::vector<int>>>::toString(std::string& outValue, std::vector<int> inValue);
|
||||
bool PropertyDelegate<TemplateProperty<std::vector<int>>>::toString(
|
||||
std::string& outValue, std::vector<int> inValue);
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
|
||||
@@ -29,8 +29,8 @@ namespace openspace::properties {
|
||||
// The following macros can be used to quickly generate the necessary PropertyDelegate
|
||||
// specializations required by the TemplateProperty class. Use the
|
||||
// REGISTER_TEMPLATEPROPERTY_HEADER macro in the header file and the
|
||||
// REGISTER_TEMPLATEPROPERTY_SOURCE macro in the source file of your new specialization of
|
||||
// a TemplateProperty
|
||||
// REGISTER_TEMPLATEPROPERTY_SOURCE macro in the source file of your new
|
||||
// specialization of a TemplateProperty
|
||||
|
||||
|
||||
// CLASS_NAME = The string that the Property::className() should return as well as the
|
||||
|
||||
@@ -111,7 +111,9 @@ private:
|
||||
* (id, namespace, etc)
|
||||
*/
|
||||
std::map<VolumeRaycaster*, RaycastData> _raycastData;
|
||||
std::map<VolumeRaycaster*, std::unique_ptr<ghoul::opengl::ProgramObject>> _boundsPrograms;
|
||||
std::map<
|
||||
VolumeRaycaster*, std::unique_ptr<ghoul::opengl::ProgramObject>
|
||||
> _boundsPrograms;
|
||||
std::vector<std::string> _helperPaths;
|
||||
|
||||
ghoul::Dictionary _resolveDictionary;
|
||||
|
||||
@@ -78,9 +78,15 @@ public:
|
||||
|
||||
private:
|
||||
std::map<VolumeRaycaster*, RaycastData> _raycastData;
|
||||
std::map<VolumeRaycaster*, std::unique_ptr<ghoul::opengl::ProgramObject>> _exitPrograms;
|
||||
std::map<VolumeRaycaster*, std::unique_ptr<ghoul::opengl::ProgramObject>> _raycastPrograms;
|
||||
std::map<VolumeRaycaster*, std::unique_ptr<ghoul::opengl::ProgramObject>> _insideRaycastPrograms;
|
||||
std::map<
|
||||
VolumeRaycaster*, std::unique_ptr<ghoul::opengl::ProgramObject>
|
||||
> _exitPrograms;
|
||||
std::map<
|
||||
VolumeRaycaster*, std::unique_ptr<ghoul::opengl::ProgramObject>
|
||||
> _raycastPrograms;
|
||||
std::map<
|
||||
VolumeRaycaster*, std::unique_ptr<ghoul::opengl::ProgramObject>
|
||||
> _insideRaycastPrograms;
|
||||
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _resolveProgram;
|
||||
|
||||
|
||||
@@ -58,7 +58,8 @@ public:
|
||||
Overlay = 8
|
||||
};
|
||||
|
||||
static std::unique_ptr<Renderable> createFromDictionary(const ghoul::Dictionary& dictionary);
|
||||
static std::unique_ptr<Renderable> createFromDictionary(
|
||||
const ghoul::Dictionary& dictionary);
|
||||
|
||||
// constructors & destructor
|
||||
Renderable(const ghoul::Dictionary& dictionary);
|
||||
@@ -89,7 +90,8 @@ public:
|
||||
|
||||
void onEnabledChange(std::function<void(bool)> callback);
|
||||
|
||||
static void setPscUniforms(ghoul::opengl::ProgramObject& program, const Camera& camera, const PowerScaledCoordinate& position);
|
||||
static void setPscUniforms(ghoul::opengl::ProgramObject& program,
|
||||
const Camera& camera, const PowerScaledCoordinate& position);
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
|
||||
@@ -127,7 +127,8 @@ public:
|
||||
|
||||
std::string progressToStr(int size, double t);
|
||||
|
||||
void removeRenderProgram(const std::unique_ptr<ghoul::opengl::ProgramObject>& program);
|
||||
void removeRenderProgram(
|
||||
const std::unique_ptr<ghoul::opengl::ProgramObject>& program);
|
||||
|
||||
/**
|
||||
* Set raycasting uniforms on the program object, and setup raycasting.
|
||||
|
||||
@@ -38,7 +38,8 @@ class TransferFunction {
|
||||
public:
|
||||
typedef std::function<void (const TransferFunction&)> TfChangedCallback;
|
||||
|
||||
TransferFunction(const std::string& filepath, TfChangedCallback tfChangedCallback = TfChangedCallback());
|
||||
TransferFunction(const std::string& filepath,
|
||||
TfChangedCallback tfChangedCallback = TfChangedCallback());
|
||||
void setPath(const std::string& filepath);
|
||||
ghoul::opengl::Texture& getTexture();
|
||||
void bind();
|
||||
|
||||
@@ -50,16 +50,19 @@ public:
|
||||
/**
|
||||
* Render the volume's entry points (front face of the bounding geometry)
|
||||
*/
|
||||
//virtual void renderEntryPoints(const RenderData& data, ghoul::opengl::ProgramObject* program) = 0;
|
||||
//virtual void renderEntryPoints(const RenderData& data,
|
||||
// ghoul::opengl::ProgramObject* program) = 0;
|
||||
|
||||
/**
|
||||
* Render the volume's exit points (back face of the bounding geometry)
|
||||
*/
|
||||
//virtual void renderExitPoints(const RenderData& data, ghoul::opengl::ProgramObject* program) = 0;
|
||||
//virtual void renderExitPoints(const RenderData& data,
|
||||
// ghoul::opengl::ProgramObject* program) = 0;
|
||||
|
||||
/**
|
||||
* Prepare the volume for the ABuffer's resolve step.
|
||||
* Make sure textures are up to date, bind them to texture units, set program uniforms etc.
|
||||
* Make sure textures are up to date, bind them to texture units, set program uniforms
|
||||
* etc.
|
||||
*/
|
||||
//virtual void preRayCast(ghoul::opengl::ProgramObject* program) {};
|
||||
|
||||
@@ -83,8 +86,8 @@ public:
|
||||
//virtual std::string getBoundsVsPath() = 0;
|
||||
|
||||
/*
|
||||
* Return a path to a file with the functions, uniforms and fragment shader in variables
|
||||
* required to generate the fragment color and depth.
|
||||
* Return a path to a file with the functions, uniforms and fragment shader in
|
||||
* variables required to generate the fragment color and depth.
|
||||
*
|
||||
* Should define the function:
|
||||
* Fragment getFragment()
|
||||
@@ -99,7 +102,8 @@ public:
|
||||
* required to perform ray casting through this volume.
|
||||
*
|
||||
* The header should define the following two functions:
|
||||
* vec4 sampler#{id}(vec3 samplePos, vec3 dir, float occludingAlpha, inout float maxStepSize)
|
||||
* vec4 sampler#{id}(vec3 samplePos, vec3 dir, float occludingAlpha,
|
||||
* inout float maxStepSize)
|
||||
* (return color of sample)
|
||||
* float stepSize#{id}(vec3 samplePos, vec3 dir)
|
||||
* (return the preferred step size at this sample position)
|
||||
@@ -117,8 +121,8 @@ public:
|
||||
* regardless of how many volumes say they require the file.
|
||||
* Ideal to avoid redefinitions of helper functions.
|
||||
*
|
||||
* The shader preprocessor will have access to the #{namespace} variable (unique per helper file)
|
||||
* which should be a prefix to all symbols defined by the helper
|
||||
* The shader preprocessor will have access to the #{namespace} variable (unique per
|
||||
* helper file) which should be a prefix to all symbols defined by the helper
|
||||
*/
|
||||
//virtual std::string getHelperPath() = 0;
|
||||
|
||||
|
||||
@@ -49,30 +49,37 @@ public:
|
||||
/**
|
||||
* Render the volume's entry points (front face of the bounding geometry)
|
||||
*/
|
||||
virtual void renderEntryPoints(const RenderData& /*data*/, ghoul::opengl::ProgramObject& /*program*/) = 0;
|
||||
virtual void renderEntryPoints(const RenderData& /*data*/,
|
||||
ghoul::opengl::ProgramObject& /*program*/) = 0;
|
||||
|
||||
/**
|
||||
* Render the volume's exit points (back face of the bounding geometry)
|
||||
*/
|
||||
virtual void renderExitPoints(const RenderData& /*data*/, ghoul::opengl::ProgramObject& /*program*/) = 0;
|
||||
virtual void renderExitPoints(const RenderData& /*data*/,
|
||||
ghoul::opengl::ProgramObject& /*program*/) = 0;
|
||||
|
||||
/**
|
||||
* Prepare the volume for the ABuffer's resolve step.
|
||||
* Make sure textures are up to date, bind them to texture units, set program uniforms etc.
|
||||
* Make sure textures are up to date, bind them to texture units, set program uniforms
|
||||
* etc.
|
||||
*/
|
||||
virtual void preRaycast(const RaycastData& /*data*/, ghoul::opengl::ProgramObject& /*program*/) {};
|
||||
virtual void preRaycast(const RaycastData& /*data*/,
|
||||
ghoul::opengl::ProgramObject& /*program*/) {};
|
||||
|
||||
/**
|
||||
* Clean up for the volume after the ABuffer's resolve step.
|
||||
* Make sure texture units are deinitialized, etc.
|
||||
*/
|
||||
virtual void postRaycast(const RaycastData& /*data*/, ghoul::opengl::ProgramObject& /*program*/) {};
|
||||
virtual void postRaycast(const RaycastData& /*data*/,
|
||||
ghoul::opengl::ProgramObject& /*program*/) {};
|
||||
|
||||
/**
|
||||
* Return true if the camera is inside the volume.
|
||||
* Also set localPosition to the camera position in the volume's local coordainte system.
|
||||
* Also set localPosition to the camera position in the volume's local coordinate
|
||||
* system.
|
||||
*/
|
||||
virtual bool cameraIsInside(const RenderData& /*data*/, glm::vec3& /*localPosition*/) { return false; };
|
||||
virtual bool cameraIsInside(const RenderData& /*data*/,
|
||||
glm::vec3& /*localPosition*/) { return false; };
|
||||
|
||||
/**
|
||||
* Return a path the file to use as vertex shader
|
||||
@@ -83,8 +90,8 @@ public:
|
||||
virtual std::string getBoundsVsPath() const = 0;
|
||||
|
||||
/*
|
||||
* Return a path to a file with the functions, uniforms and fragment shader in variables
|
||||
* required to generate the fragment color and depth.
|
||||
* Return a path to a file with the functions, uniforms and fragment shader in
|
||||
* variables required to generate the fragment color and depth.
|
||||
*
|
||||
* Should define the function:
|
||||
* Fragment getFragment()
|
||||
@@ -99,7 +106,8 @@ public:
|
||||
* required to perform ray casting through this volume.
|
||||
*
|
||||
* The header should define the following two functions:
|
||||
* vec4 sample#{id}(vec3 samplePos, vec3 dir, float occludingAlpha, inout float maxStepSize)
|
||||
* vec4 sample#{id}(vec3 samplePos, vec3 dir, float occludingAlpha,
|
||||
* inout float maxStepSize)
|
||||
* (return color of sample)
|
||||
* float stepSize#{id}(vec3 samplePos, vec3 dir)
|
||||
* (return the preferred step size at this sample position)
|
||||
@@ -117,8 +125,8 @@ public:
|
||||
* regardless of how many volumes say they require the file.
|
||||
* Ideal to avoid redefinitions of helper functions.
|
||||
*
|
||||
* The shader preprocessor will have access to the #{namespace} variable (unique per helper file)
|
||||
* which should be a prefix to all symbols defined by the helper
|
||||
* The shader preprocessor will have access to the #{namespace} variable (unique per
|
||||
* helper file) which should be a prefix to all symbols defined by the helper
|
||||
*/
|
||||
virtual std::string getHelperPath() const = 0;
|
||||
};
|
||||
|
||||
@@ -41,7 +41,8 @@ namespace documentation { struct Documentation; }
|
||||
|
||||
class Rotation : public properties::PropertyOwner {
|
||||
public:
|
||||
static std::unique_ptr<Rotation> createFromDictionary(const ghoul::Dictionary& dictionary);
|
||||
static std::unique_ptr<Rotation> createFromDictionary(
|
||||
const ghoul::Dictionary& dictionary);
|
||||
|
||||
Rotation(const ghoul::Dictionary& dictionary);
|
||||
virtual ~Rotation() = default;
|
||||
|
||||
@@ -41,7 +41,8 @@ namespace documentation { struct Documentation; }
|
||||
|
||||
class Scale : public properties::PropertyOwner {
|
||||
public:
|
||||
static std::unique_ptr<Scale> createFromDictionary(const ghoul::Dictionary& dictionary);
|
||||
static std::unique_ptr<Scale> createFromDictionary(
|
||||
const ghoul::Dictionary& dictionary);
|
||||
|
||||
Scale();
|
||||
virtual ~Scale() = default;
|
||||
|
||||
@@ -60,7 +60,8 @@ public:
|
||||
* \param component The optional compoment that caused this exception to be thrown
|
||||
* \pre message may not be empty
|
||||
*/
|
||||
explicit InvalidSceneError(const std::string& message, const std::string& component = "");
|
||||
explicit InvalidSceneError(const std::string& message,
|
||||
const std::string& component = "");
|
||||
};
|
||||
|
||||
// constructors & destructor
|
||||
|
||||
@@ -73,7 +73,8 @@ public:
|
||||
SceneGraphNode();
|
||||
~SceneGraphNode();
|
||||
|
||||
static std::unique_ptr<SceneGraphNode> createFromDictionary(const ghoul::Dictionary& dictionary);
|
||||
static std::unique_ptr<SceneGraphNode> createFromDictionary(
|
||||
const ghoul::Dictionary& dictionary);
|
||||
|
||||
void initialize();
|
||||
void deinitialize();
|
||||
@@ -95,7 +96,7 @@ public:
|
||||
void setDependencies(const std::vector<SceneGraphNode*>& dependencies);
|
||||
|
||||
SurfacePositionHandle calculateSurfacePositionHandle(
|
||||
const glm::dvec3& targetModelSpace);
|
||||
const glm::dvec3& targetModelSpace);
|
||||
|
||||
const std::vector<SceneGraphNode*>& dependencies() const;
|
||||
const std::vector<SceneGraphNode*>& dependentNodes() const;
|
||||
|
||||
@@ -42,7 +42,8 @@ namespace documentation { struct Documentation; }
|
||||
|
||||
class Translation : public properties::PropertyOwner {
|
||||
public:
|
||||
static std::unique_ptr<Translation> createFromDictionary(const ghoul::Dictionary& dictionary);
|
||||
static std::unique_ptr<Translation> createFromDictionary(
|
||||
const ghoul::Dictionary& dictionary);
|
||||
|
||||
Translation();
|
||||
virtual ~Translation() = default;
|
||||
|
||||
@@ -92,11 +92,6 @@ public:
|
||||
|
||||
std::vector<std::string> allLuaFunctions() const;
|
||||
|
||||
//parallel functions
|
||||
//bool parseLibraryAndFunctionNames(std::string &library, std::string &function, const std::string &script);
|
||||
//bool shouldScriptBeSent(const std::string &library, const std::string &function);
|
||||
//void cacheScript(const std::string &library, const std::string &function, const std::string &script);
|
||||
|
||||
static std::string OpenSpaceLibraryName;
|
||||
|
||||
private:
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
LightTime, ///< One-way light time (<code>LT</code>)
|
||||
LightTimeStellar, ///< One-way light time and stellar (<code>LT+S</code>)
|
||||
ConvergedNewtonian, ///< Converged newtonian light time (<code>CN</code>)
|
||||
ConvergedNewtonianStellar ///< Converged newtonian + stellar (<code>CN+S</code>)
|
||||
ConvergedNewtonianStellar ///< Converged newtonian+stellar (<code>CN+S</code>)
|
||||
};
|
||||
/// The direction of the aberration correct
|
||||
enum class Direction {
|
||||
@@ -896,7 +896,8 @@ private:
|
||||
* position will be retrieved. If the coverage has ended, the last position will be
|
||||
* retrieved. If \p time is in a coverage gap, the position will be interpolated.
|
||||
* \param target The body which is missing SPK data for this time
|
||||
* \param observer The observer. The position will be retrieved in relation to this body
|
||||
* \param observer The observer. The position will be retrieved in relation to this
|
||||
* body
|
||||
* \param referenceFrame The reference frame of the output position vector
|
||||
* \param aberrationCorrection The aberration correction used for the position
|
||||
* calculation
|
||||
|
||||
@@ -52,7 +52,11 @@ public:
|
||||
ghoul_assert(_encodeOffset + size < _n, "");
|
||||
|
||||
int32_t length = static_cast<int32_t>(s.length());
|
||||
memcpy(_dataStream.data() + _encodeOffset, reinterpret_cast<const char*>(&length), sizeof(int32_t));
|
||||
memcpy(
|
||||
_dataStream.data() + _encodeOffset,
|
||||
reinterpret_cast<const char*>(&length),
|
||||
sizeof(int32_t)
|
||||
);
|
||||
_encodeOffset += sizeof(int32_t);
|
||||
memcpy(_dataStream.data() + _encodeOffset, s.c_str(), length);
|
||||
_encodeOffset += length;
|
||||
@@ -69,7 +73,11 @@ public:
|
||||
|
||||
std::string decode() {
|
||||
int32_t length;
|
||||
memcpy(reinterpret_cast<char*>(&length), _dataStream.data() + _decodeOffset, sizeof(int32_t));
|
||||
memcpy(
|
||||
reinterpret_cast<char*>(&length),
|
||||
_dataStream.data() + _decodeOffset,
|
||||
sizeof(int32_t)
|
||||
);
|
||||
char* tmp = new char[length + 1];
|
||||
_decodeOffset += sizeof(int32_t);
|
||||
memcpy(tmp, _dataStream.data() + _decodeOffset, length);
|
||||
|
||||
@@ -33,7 +33,8 @@ namespace openspace {
|
||||
|
||||
class TaskLoader {
|
||||
public:
|
||||
std::vector<std::unique_ptr<Task>> tasksFromDictionary(const ghoul::Dictionary& dictionary);
|
||||
std::vector<std::unique_ptr<Task>> tasksFromDictionary(
|
||||
const ghoul::Dictionary& dictionary);
|
||||
std::vector<std::unique_ptr<Task>> tasksFromFile(const std::string& path);
|
||||
};
|
||||
|
||||
|
||||
@@ -64,7 +64,8 @@ public:
|
||||
void removeKeyframe(size_t id);
|
||||
void removeKeyframesBefore(double timestamp, bool inclusive = false);
|
||||
void removeKeyframesAfter(double timestamp, bool inclusive = false);
|
||||
void removeKeyframesBetween(double begin, double end, bool inclusiveBegin = false, bool inclusiveEnd = false);
|
||||
void removeKeyframesBetween(double begin, double end, bool inclusiveBegin = false,
|
||||
bool inclusiveEnd = false);
|
||||
size_t nKeyframes() const;
|
||||
const Keyframe<T>* firstKeyframeAfter(double timestamp, bool inclusive = false) const;
|
||||
const Keyframe<T>* lastKeyframeBefore(double timestamp, bool inclusive = false) const;
|
||||
|
||||
@@ -35,15 +35,30 @@ Timeline<T>::~Timeline() {}
|
||||
template <typename T>
|
||||
void Timeline<T>::addKeyframe(double timestamp, T data) {
|
||||
Keyframe<T> keyframe(++_nextKeyframeId, timestamp, data);
|
||||
auto iter = std::upper_bound(_keyframes.begin(), _keyframes.end(), keyframe, &compareKeyframeTimes);
|
||||
auto iter = std::upper_bound(
|
||||
_keyframes.begin(),
|
||||
_keyframes.end(),
|
||||
keyframe,
|
||||
&compareKeyframeTimes
|
||||
);
|
||||
_keyframes.insert(iter, keyframe);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Timeline<T>::removeKeyframesAfter(double timestamp, bool inclusive) {
|
||||
auto iter = inclusive
|
||||
? std::lower_bound(_keyframes.begin(), _keyframes.end(), timestamp, &compareKeyframeTimeWithTime)
|
||||
: std::upper_bound(_keyframes.begin(), _keyframes.end(), timestamp, &compareTimeWithKeyframeTime);
|
||||
? std::lower_bound(
|
||||
_keyframes.begin(),
|
||||
_keyframes.end(),
|
||||
timestamp,
|
||||
&compareKeyframeTimeWithTime
|
||||
)
|
||||
: std::upper_bound(
|
||||
_keyframes.begin(),
|
||||
_keyframes.end(),
|
||||
timestamp,
|
||||
&compareTimeWithKeyframeTime
|
||||
);
|
||||
|
||||
_keyframes.erase(iter, _keyframes.end());
|
||||
}
|
||||
@@ -51,21 +66,53 @@ void Timeline<T>::removeKeyframesAfter(double timestamp, bool inclusive) {
|
||||
template <typename T>
|
||||
void Timeline<T>::removeKeyframesBefore(double timestamp, bool inclusive) {
|
||||
auto iter = inclusive
|
||||
? std::upper_bound(_keyframes.begin(), _keyframes.end(), timestamp, &compareTimeWithKeyframeTime)
|
||||
: std::lower_bound(_keyframes.begin(), _keyframes.end(), timestamp, &compareKeyframeTimeWithTime);
|
||||
? std::upper_bound(
|
||||
_keyframes.begin(),
|
||||
_keyframes.end(),
|
||||
timestamp,
|
||||
&compareTimeWithKeyframeTime
|
||||
)
|
||||
: std::lower_bound(
|
||||
_keyframes.begin(),
|
||||
_keyframes.end(),
|
||||
timestamp,
|
||||
&compareKeyframeTimeWithTime)
|
||||
;
|
||||
|
||||
_keyframes.erase(_keyframes.begin(), iter);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Timeline<T>::removeKeyframesBetween(double begin, double end, bool inclusiveBegin, bool inclusiveEnd) {
|
||||
void Timeline<T>::removeKeyframesBetween(double begin, double end, bool inclusiveBegin,
|
||||
bool inclusiveEnd)
|
||||
{
|
||||
auto beginIter = inclusiveBegin
|
||||
? std::lower_bound(_keyframes.begin(), _keyframes.end(), begin, &compareKeyframeTimeWithTime)
|
||||
: std::upper_bound(_keyframes.begin(), _keyframes.end(), begin, &compareTimeWithKeyframeTime);
|
||||
? std::lower_bound(
|
||||
_keyframes.begin(),
|
||||
_keyframes.end(),
|
||||
begin,
|
||||
&compareKeyframeTimeWithTime
|
||||
)
|
||||
: std::upper_bound(
|
||||
_keyframes.begin(),
|
||||
_keyframes.end(),
|
||||
begin,
|
||||
&compareTimeWithKeyframeTime
|
||||
);
|
||||
|
||||
auto endIter = inclusiveEnd
|
||||
? std::upper_bound(beginIter, _keyframes.end(), end, &compareTimeWithKeyframeTime)
|
||||
: std::lower_bound(beginIter, _keyframes.end(), end, &compareKeyframeTimeWithTime);
|
||||
? std::upper_bound(
|
||||
beginIter,
|
||||
_keyframes.end(),
|
||||
end,
|
||||
&compareTimeWithKeyframeTime
|
||||
)
|
||||
: std::lower_bound(
|
||||
beginIter,
|
||||
_keyframes.end(),
|
||||
end,
|
||||
&compareKeyframeTimeWithTime
|
||||
);
|
||||
|
||||
_keyframes.erase(beginIter, endIter);
|
||||
}
|
||||
@@ -77,9 +124,14 @@ void Timeline<T>::clearKeyframes() {
|
||||
|
||||
template <typename T>
|
||||
void Timeline<T>::removeKeyframe(size_t id) {
|
||||
_keyframes.erase(std::remove_if(_keyframes.begin(), _keyframes.end(), [id] (Keyframe<T> keyframe) {
|
||||
return keyframe.id == id;
|
||||
}), _keyframes.end());
|
||||
_keyframes.erase(
|
||||
std::remove_if(
|
||||
_keyframes.begin(),
|
||||
_keyframes.end(),
|
||||
[id] (Keyframe<T> keyframe) { return keyframe.id == id; }
|
||||
),
|
||||
_keyframes.end()
|
||||
);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -88,10 +140,23 @@ size_t Timeline<T>::nKeyframes() const {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const Keyframe<T>* Timeline<T>::firstKeyframeAfter(double timestamp, bool inclusive) const {
|
||||
const Keyframe<T>* Timeline<T>::firstKeyframeAfter(double timestamp,
|
||||
bool inclusive) const
|
||||
{
|
||||
auto it = inclusive
|
||||
? std::lower_bound(_keyframes.begin(), _keyframes.end(), timestamp, &compareKeyframeTimeWithTime)
|
||||
: std::upper_bound(_keyframes.begin(), _keyframes.end(), timestamp, &compareTimeWithKeyframeTime);
|
||||
? std::lower_bound(
|
||||
_keyframes.begin(),
|
||||
_keyframes.end(),
|
||||
timestamp,
|
||||
&compareKeyframeTimeWithTime
|
||||
)
|
||||
: std::upper_bound(
|
||||
_keyframes.begin(),
|
||||
_keyframes.end(),
|
||||
timestamp,
|
||||
&compareTimeWithKeyframeTime
|
||||
);
|
||||
|
||||
if (it == _keyframes.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -99,10 +164,23 @@ const Keyframe<T>* Timeline<T>::firstKeyframeAfter(double timestamp, bool inclus
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const Keyframe<T>* Timeline<T>::lastKeyframeBefore(double timestamp, bool inclusive) const {
|
||||
const Keyframe<T>* Timeline<T>::lastKeyframeBefore(double timestamp,
|
||||
bool inclusive) const
|
||||
{
|
||||
auto it = inclusive
|
||||
? std::upper_bound(_keyframes.begin(), _keyframes.end(), timestamp, &compareTimeWithKeyframeTime)
|
||||
: std::lower_bound(_keyframes.begin(), _keyframes.end(), timestamp, &compareKeyframeTimeWithTime);
|
||||
? std::upper_bound(
|
||||
_keyframes.begin(),
|
||||
_keyframes.end(),
|
||||
timestamp,
|
||||
&compareTimeWithKeyframeTime
|
||||
)
|
||||
: std::lower_bound(
|
||||
_keyframes.begin(),
|
||||
_keyframes.end(),
|
||||
timestamp,
|
||||
&compareKeyframeTimeWithTime
|
||||
);
|
||||
|
||||
if (it == _keyframes.begin()) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -116,6 +194,4 @@ const std::deque<Keyframe<T>>& Timeline<T>::keyframes() const {
|
||||
return _keyframes;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -49,9 +49,11 @@ struct TimeRange {
|
||||
TimeRange(const ghoul::Dictionary& dict);
|
||||
|
||||
/**
|
||||
* \returns true if timeRange could be initialized from the dictionary, false otherwise.
|
||||
* \returns true if timeRange could be initialized from the dictionary,
|
||||
* false otherwise.
|
||||
*/
|
||||
static bool initializeFromDictionary(const ghoul::Dictionary& dict, TimeRange& timeRange);
|
||||
static bool initializeFromDictionary(const ghoul::Dictionary& dict,
|
||||
TimeRange& timeRange);
|
||||
|
||||
void include(double val);
|
||||
|
||||
|
||||
@@ -59,10 +59,12 @@ public:
|
||||
TransformationManager();
|
||||
~TransformationManager();
|
||||
|
||||
glm::dmat3 frameTransformationMatrix(const std::string& from, const std::string& to, double ephemerisTime) const;
|
||||
glm::dmat3 frameTransformationMatrix(const std::string& from, const std::string& to,
|
||||
double ephemerisTime) const;
|
||||
|
||||
private:
|
||||
glm::dmat3 kameleonTransformationMatrix(const std::string& from, const std::string& to, double ephemerisTime) const;
|
||||
glm::dmat3 kameleonTransformationMatrix(const std::string& from,
|
||||
const std::string& to, double ephemerisTime) const;
|
||||
|
||||
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
|
||||
std::shared_ptr<ccmc::Kameleon> _kameleon;
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
@@ -389,7 +406,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) {
|
||||
@@ -397,7 +415,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;
|
||||
|
||||
@@ -418,7 +437,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();
|
||||
@@ -467,10 +487,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;
|
||||
}
|
||||
|
||||
@@ -497,7 +520,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) });
|
||||
}
|
||||
|
||||
@@ -179,9 +179,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");
|
||||
}
|
||||
@@ -194,8 +193,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)
|
||||
@@ -299,7 +301,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;
|
||||
@@ -333,7 +336,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:
|
||||
@@ -353,7 +357,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);
|
||||
|
||||
ChunkTilePile getChunkTilePile(const TileIndex& tileIndex, int pileSize) const;
|
||||
Tile::Status getTileStatus(const TileIndex& index) const;
|
||||
@@ -74,12 +75,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();
|
||||
|
||||
@@ -113,7 +113,10 @@ void 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());
|
||||
_layers.erase(it);
|
||||
|
||||
@@ -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);
|
||||
@@ -266,7 +268,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();
|
||||
}
|
||||
}
|
||||
@@ -289,7 +292,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;
|
||||
}
|
||||
@@ -456,7 +459,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;
|
||||
};
|
||||
|
||||
@@ -306,7 +308,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);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user