Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ Unlike previous GLVis releases, this version requires a C++17 compiler.
- Color palettes defined in an external file can now also be specified in
scripts and streams using the keyword 'palette_file'.

- Generalized and unified processing of stream commands for glvis-js to support
all commands.


Version 4.4 released on May 1, 2025
===================================

Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ if (NOT EMSCRIPTEN)
endif (GLVIS_USE_EGL)

# Find CGL
if (GLVIS_USE_CGL)
if (GLVIS_USE_CGL AND NOT EMSCRIPTEN)
list(APPEND _glvis_compile_defs "GLVIS_USE_CGL")
endif (GLVIS_USE_CGL)
endif (GLVIS_USE_CGL AND NOT EMSCRIPTEN)

# Find threading library
find_package(Threads REQUIRED)
Expand Down
75 changes: 22 additions & 53 deletions lib/aux_js.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,47 +42,29 @@ namespace js
using namespace mfem;

/// Display a new stream
void display(std::stringstream & commands, const int w, const int h)
void display(StreamCollection streams, const int w, const int h)
{
// reset antialiasing
if (win.wnd)
{
win.wnd->getRenderer().setAntialiasing(0);
}

std::string word, keys;
double minv = 0.0, maxv = 0.0;
while (commands >> word)
{
if (word == "keys")
{
std::cout << "parsing 'keys'" << std::endl;
commands >> keys;
}
else if (word == "valuerange")
{
std::cout << "parsing 'valuerange'" << std::endl;
commands >> minv >> maxv;
}
else
{
std::cout << "unknown command '" << word << "'" << std::endl;
}
}

win.window_title = "glvis";
win.window_x = 0.;
win.window_y = 0.;
win.window_w = w;
win.window_h = h;

if (!win.GLVisInitVis({})) { return; }
if (!win.GLVisInitVis(std::move(streams))) { return; }

CallKeySequence(keys.c_str());

if (minv || maxv)
while (win.comm_thread->process_one())
{
win.vs->SetValueRange(minv, maxv);
if (win.glvis_command->Execute() < 0)
{
// GLVisCommand signalled exit!
break;
}
}

SendExposeEvent();
Expand All @@ -96,61 +78,48 @@ void display(std::stringstream & commands, const int w, const int h)
// each string in streams must start with `parallel <nproc> <rank>'
//
using StringArray = std::vector<std::string>;
void processParallelStreams(DataState & state,
const StringArray & streams,
std::stringstream * commands = nullptr)
StreamCollection processParallelStreams(DataState & state,
const StringArray & streams)
{
// std::cerr << "got " << streams.size() << " streams" << std::endl;
// HACK: match unique_ptr<istream> interface for ReadStreams:
std::vector<std::stringstream> sstreams(streams.size());
StreamCollection istreams(streams.size());
for (int i = 0; i < streams.size(); ++i)
{
sstreams[i] = std::stringstream(streams[i]);
istreams[i] = std::unique_ptr<std::istream>(new std::stringstream(streams[i]));
// pull off the first list
std::string word;
int nproc, rank;
sstreams[i] >> word >> nproc >> rank;
// std::cerr << "packing " << rank+1 << "/" << nproc << std::endl;
istreams[i] = std::unique_ptr<std::istream>(&sstreams[i]);
*istreams[i] >> word >> nproc >> rank;
}

StreamReader reader(state);
reader.ReadStreams(istreams);

if (commands)
{
commands->seekg(istreams[0]->tellg());
}

// HACK: don't let unique_ptr free the data
for (int i = 0; i < streams.size(); ++i)
{
istreams[i].release();
}

last_stream_nproc = streams.size();

return istreams;
}

void displayParallelStreams(const StringArray & streams, const int w,
const int h)
{
std::stringstream commands(streams[0]);
processParallelStreams(win.data_state, streams, &commands);
StreamCollection sc = processParallelStreams(win.data_state, streams);

display(commands, w, h);
display(std::move(sc), w, h);
}

void displayStream(const std::string & stream, const int w, const int h)
{
std::stringstream ss(stream);
std::unique_ptr<std::istream> ss(new std::istringstream(stream));
std::string data_type;
ss >> data_type;
*ss >> data_type;

StreamReader reader(win.data_state);
reader.ReadStream(ss, data_type);
reader.ReadStream(*ss, data_type);

display(ss, w, h);
StreamCollection sc;
sc.emplace_back(std::move(ss));
display(std::move(sc), w, h);
}

//
Expand Down
24 changes: 2 additions & 22 deletions lib/aux_vis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,6 @@ void InitIdleFuncs()
}
}

#ifndef __EMSCRIPTEN__
bool CommunicationIdleFunc()
{
int status = glvis_command->Execute();
Expand All @@ -539,12 +538,11 @@ bool CommunicationIdleFunc()
}
return false;
}
#endif

bool MainIdleFunc()
{
bool sleep = true;
#ifndef __EMSCRIPTEN__

if (glvis_command && visualize == 1
&& !(IdleFuncs.Size() > 0 && use_idle))
{
Expand All @@ -567,24 +565,8 @@ bool MainIdleFunc()
sleep = false;
}
use_idle = !use_idle;
#else
if (IdleFuncs.Size() > 0)
{
LastIdleFunc = (LastIdleFunc + 1) % IdleFuncs.Size();
if (IdleFuncs[LastIdleFunc])
{
(*IdleFuncs[LastIdleFunc])();
}
// Continue executing idle functions
sleep = false;
}
#endif

return sleep;
LastIdleFunc = (LastIdleFunc + 1) % IdleFuncs.Size();
if (IdleFuncs[LastIdleFunc])
{
(*IdleFuncs[LastIdleFunc])();
}
}

void AddIdleFunc(void (*Func)(void))
Expand Down Expand Up @@ -1376,9 +1358,7 @@ void ThreadsPauseFunc(SDL_Keymod state)
{
if (state & KMOD_CTRL)
{
#ifndef __EMSCRIPTEN__
glvis_command->ToggleAutopause();
#endif
}
else
{
Expand Down
5 changes: 4 additions & 1 deletion lib/sdl/sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,10 @@ void SdlWindow::signalLoop()
lock_guard<mutex> evt_guard{event_mutex};
call_idle_func = true;
}
events_available.notify_all();
if (is_multithreaded)
{
events_available.notify_all();
}
}

void SdlWindow::getWindowSize(int& w, int& h) const
Expand Down
Loading
Loading