Skip to content

Commit

Permalink
Updates to layers UI and test earth files
Browse files Browse the repository at this point in the history
  • Loading branch information
gwaldron committed Oct 19, 2023
1 parent 7c9e9b3 commit b581b49
Show file tree
Hide file tree
Showing 24 changed files with 223 additions and 632 deletions.
27 changes: 20 additions & 7 deletions src/osgEarth/ImGui/EnvironmentGUI
Original file line number Diff line number Diff line change
Expand Up @@ -185,23 +185,36 @@ namespace osgEarth
ImGui::SameLine();
if (ImGui::Checkbox("Details", &_showDetails)) dirtySettings();

ImGui::SameLine();
if (ImGui::Button("Now")) {
_skyNode->setDateTime(DateTime());
dirtySettings();
}

ImGui::Separator();
if (ImGuiLTable::Begin("Environment"))
{
ImGuiLTable::Section("Date & Time:");

if (ImGuiLTable::SliderFloat("Hour", &_hour, 0.0f, 24.0f))
auto mark = _skyNode->getDateTime();
auto day = mark.day();
auto month = mark.month();
auto year = mark.year();
auto hour = mark.hours();

if (ImGuiLTable::SliderDouble("Hour", &hour, 0.0f, 24.0f))
dirtySettings();

if (_showDetails)
{
if (ImGuiLTable::SliderInt("Day", &_day, 1, 31)) dirtySettings();
if (ImGuiLTable::SliderInt("Month", &_month, 1, 12)) dirtySettings();
if (ImGuiLTable::SliderInt("Year", &_year, 1970, 2061)) dirtySettings();
if (ImGuiLTable::SliderInt("Day", &day, 1, 31))
dirtySettings();
if (ImGuiLTable::SliderInt("Month", &month, 1, 12))
dirtySettings();
if (ImGuiLTable::SliderInt("Year", &year, 1970, 2061))
dirtySettings();
}

DateTime mark(_year, _month, _day, _hour);
_skyNode->setDateTime(mark);
_skyNode->setDateTime(DateTime(year, month, day, hour));

if (lighting)
{
Expand Down
9 changes: 9 additions & 0 deletions src/osgEarth/ImGui/ImGui
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,15 @@ namespace ImGuiLTable

namespace ImGuiUtil
{
template<typename... Args>
static void TextCentered(const char* format, Args&&... args)
{
char buf[1024];
sprintf(buf, format, args...);
ImGui::SetCursorPosX((ImGui::GetWindowSize().x - ImGui::CalcTextSize(buf).x) * 0.5f);
ImGui::Text(buf);
}

static void Texture(osg::Texture2D* texture, osg::RenderInfo& renderInfo, unsigned int width = 0, unsigned int height = 0)
{
// Get the context id
Expand Down
300 changes: 153 additions & 147 deletions src/osgEarth/ImGui/LayersGUI

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/osgEarth/Layer
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace osgDB {
SUPERCLASS ::mergeConfig(conf); \
fromConfig(conf); \
} \
using super = SUPERCLASS; \
public: \
OE_COMMENT("Construct empty layer options") \
MYCLASS () : SUPERCLASS() { fromConfig(_conf); } \
Expand All @@ -66,6 +67,7 @@ namespace osgDB {
const OPTIONS * _options0; \
const OPTIONS _optionsConcrete0; \
MYCLASS ( const MYCLASS& rhs, const osg::CopyOp& op ) { } \
using super = SUPERCLASS; \
protected: \
OE_COMMENT("Construct a new layer with default options") \
MYCLASS (OPTIONS* optr, const OPTIONS* optr0) : \
Expand Down Expand Up @@ -125,6 +127,7 @@ namespace osgDB {
_options(optr), \
_options0(optr0) { } \
MYCLASS () : SUPERCLASS () { } \
using super = SUPERCLASS; \
public: \
OE_COMMENT("Mutable options for this layer") \
OPTIONS& options() { return *_options; } \
Expand Down
3 changes: 3 additions & 0 deletions src/osgEarth/Status
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,7 @@ namespace osgEarth
};
}

#define OE_RETURN_STATUS_ON_ERROR(F) \
{ osgEarth::Status s = F; if (s.isError()) return s; }

#endif // OSGEARTH_STATUS_H
14 changes: 8 additions & 6 deletions src/osgEarth/TerrainMeshLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void TerrainMeshLayer::Options::fromConfig(const Config& conf)
Config
TerrainMeshLayer::Options::getConfig() const
{
Config conf = TileLayer::Options::getConfig();
Config conf = super::getConfig();
conf.set("url", uri());
conf.set("invert_y", invertY());
return conf;
Expand All @@ -56,31 +56,33 @@ TerrainMeshLayer::Options::getConfig() const
void
TerrainMeshLayer::init()
{
TileLayer::init();
super::init();

setRenderType(RENDERTYPE_NONE);

// layer is always visible:
_canSetVisible = false;
}

Status
TerrainMeshLayer::openImplementation()
{
auto s = TileLayer::openImplementation();
if (s.isError()) return s;
OE_RETURN_STATUS_ON_ERROR(super::openImplementation());

return STATUS_OK;
}

void
TerrainMeshLayer::addedToMap(const Map* map)
{
TileLayer::addedToMap(map);
super::addedToMap(map);
_map = map;
}

void
TerrainMeshLayer::removedFromMap(const Map* map)
{
TileLayer::removedFromMap(map);
super::removedFromMap(map);
_map = nullptr;
}

Expand Down
1 change: 1 addition & 0 deletions src/osgEarth/VisibleLayer
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ namespace osgEarth
void fireCallback(VisibleLayerCallback::MethodPtr);

bool _visibleTiedToOpen = false;
bool _canSetVisible = true;

private:
osg::ref_ptr<osg::Uniform> _opacityU;
Expand Down
22 changes: 12 additions & 10 deletions src/osgEarth/VisibleLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ VisibleLayer::init()
VirtualProgram* vp = VirtualProgram::getOrCreate(getOrCreateStateSet());
vp->setName(className());
vp->setFunction("oe_VisibleLayer_setOpacity", opacityInterpolateFS, VirtualProgram::LOCATION_FRAGMENT_COLORING, 1.1f);
//vp->setFunction("oe_VisibleLayer_setOpacity", opacityInterpolateFS, VirtualProgram::LOCATION_FRAGMENT_COLORING, FLT_MAX);
}
}

Expand Down Expand Up @@ -240,18 +239,21 @@ VisibleLayer::prepareForRendering(TerrainEngine* engine)
void
VisibleLayer::setVisible(bool value)
{
options().visible() = value;
if (_canSetVisible)
{
options().visible() = value;

updateNodeMasks();
updateNodeMasks();

fireCallback(&VisibleLayerCallback::onVisibleChanged);
fireCallback(&VisibleLayerCallback::onVisibleChanged);

if (_visibleTiedToOpen)
{
if (value && !isOpen())
open();
else if (!value && isOpen())
close();
if (_visibleTiedToOpen)
{
if (value && !isOpen())
open();
else if (!value && isOpen())
close();
}
}
}

Expand Down
4 changes: 0 additions & 4 deletions tests/boston_viewpoints.xml

This file was deleted.

28 changes: 0 additions & 28 deletions tests/bumpmap.earth

This file was deleted.

8 changes: 0 additions & 8 deletions tests/copernicus_land_cover.xml

This file was deleted.

45 changes: 0 additions & 45 deletions tests/copernicus_splat.earth

This file was deleted.

3 changes: 1 addition & 2 deletions tests/day_night.earth
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
<url>http://readymap.org/readymap/tiles/1.0.0/26/</url>
<shader>
<![CDATA[
#pragma vp_entryPoint dayNight
#pragma vp_location fragment_coloring
#pragma vp_function dayNight, fragment
#pragma import_defines(OE_NUM_LIGHTS)
#ifndef OE_NUM_LIGHTS
#define OE_NUM_LIGHTS 1
Expand Down
20 changes: 0 additions & 20 deletions tests/detail_texture.earth

This file was deleted.

11 changes: 0 additions & 11 deletions tests/esa_land_cover.xml

This file was deleted.

75 changes: 0 additions & 75 deletions tests/fractal_elevation.earth

This file was deleted.

Loading

0 comments on commit b581b49

Please sign in to comment.