Skip to content

Commit

Permalink
add suspend/resume GUI upd
Browse files Browse the repository at this point in the history
  • Loading branch information
markcmiller86 committed Dec 17, 2024
1 parent eaf6313 commit 0184903
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 2 deletions.
46 changes: 46 additions & 0 deletions src/doc/python_scripting/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1889,6 +1889,52 @@ return type : CLI_return_t
DrawPlots()


SuspendGUIUpdates
-----------------

**Synopsis:**

::

SuspendGUIupdates() -> integer

return type : CLI_return_t
The DefineVectorExpression function returns 1 on success and 0 on failure.

**Description:**

SuspendGUIUpdates temporarily suspends updating the GUI after certain CLI
operations such as defining expressions. This is useful when defining many
expressions becuase updating the GUI after each new expression is defined
can really bog down performance. Use ResumeGUIUpdates to resume normal
behavior.

**Example:**

::

OpenDatabase("/usr/gapps/visit/data/rect2d.silo")
SuspendGUIUpdates()
for i in range(1000):
DefineScalarExpression("var%04d" % i, "d*%d" % i)
ResumeGUIUpdates()

ResumeGUIUpdates
----------------

**Synopsis:**

::

ResumeGUIupdates() -> integer

return type : CLI_return_t
The DefineVectorExpression function returns 1 on success and 0 on failure.

**Description:**

Undoes the effect of SuspendGUIUpdates.

DeleteActivePlots
-----------------

Expand Down
49 changes: 49 additions & 0 deletions src/visitpy/common/MethodDoc.C
Original file line number Diff line number Diff line change
Expand Up @@ -1832,6 +1832,55 @@ const char *visit_DefineVectorExpression_doc =
"AddPlot(\"Vector\", \"myvec\")\n"
"DrawPlots()\n"
;
const char *visit_SuspendGUIUpdates_doc =
"SuspendGUIUpdates\n"
"\n"
"\n"
"Synopsis:\n"
"\n"
"SuspendGUIupdates() -> integer\n"
"\n"
"\n"
"Returns:\n"
"\n"
" The DefineVectorExpression function returns 1 on success and 0 on failure.\n"
"\n"
"\n"
"Description:\n"
"\n"
"SuspendGUIUpdates temporarily suspends updating the GUI after certain\n"
"CLI operations such as defining expressions. This is useful when\n"
"defining many expressions becuase updating the GUI after each new\n"
"expression is defined can really bog down performance. Use\n"
"ResumeGUIUpdates to resume normal behavior.\n"
"\n"
"\n"
"Example:\n"
"\n"
"OpenDatabase(\"/usr/gapps/visit/data/rect2d.silo\")\n"
"SuspendGUIUpdates()\n"
"for i in range(1000):\n"
" DefineScalarExpression(\"var%04d\" % i, \"d*%d\" % i)\n"
"ResumeGUIUpdates()\n"
;
const char *visit_ResumeGUIUpdates_doc =
"ResumeGUIUpdates\n"
"\n"
"\n"
"Synopsis:\n"
"\n"
"ResumeGUIupdates() -> integer\n"
"\n"
"\n"
"Returns:\n"
"\n"
" The DefineVectorExpression function returns 1 on success and 0 on failure.\n"
"\n"
"\n"
"Description:\n"
"\n"
"Undoes the effect of SuspendGUIUpdates.\n"
;
const char *visit_DeleteActivePlots_doc =
"DeleteActivePlots\n"
"\n"
Expand Down
2 changes: 2 additions & 0 deletions src/visitpy/common/MethodDoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ extern const char *visit_DefineScalarExpression_doc;
extern const char *visit_DefineSpeciesExpression_doc;
extern const char *visit_DefineTensorExpression_doc;
extern const char *visit_DefineVectorExpression_doc;
extern const char *visit_SuspendGUIUpdates_doc;
extern const char *visit_ResumeGUIUpdates_doc;
extern const char *visit_DeleteActivePlots_doc;
extern const char *visit_DeleteAllPlots_doc;
extern const char *visit_DeleteDatabaseCorrelation_doc;
Expand Down
40 changes: 38 additions & 2 deletions src/visitpy/common/visitmodule.C
Original file line number Diff line number Diff line change
Expand Up @@ -3425,6 +3425,22 @@ ExpressionDefinitionHelper(PyObject *args, const char *name, Expression::ExprTyp
{
ENSURE_VIEWER_EXISTS();

static bool suspendGUIUpdates = false;

if (!strncmp(name, "SuspendGUIUpdates", 17) && t == Expression::Unknown)
{
suspendGUIUpdates = true;
return IntReturnValue(Synchronize());
}
if (!strncmp(name, "ResumeGUIUpdates", 16) && t == Expression::Unknown)
{
suspendGUIUpdates = false;
ExpressionList *list = GetViewerState()->GetExpressionList();
list->Notify();
GetViewerMethods()->ProcessExpressions();
return IntReturnValue(Synchronize());
}

char *exprName;
char *exprDef;
if (!PyArg_ParseTuple(args, "ss", &exprName, &exprDef))
Expand Down Expand Up @@ -3455,8 +3471,11 @@ ExpressionDefinitionHelper(PyObject *args, const char *name, Expression::ExprTyp
}

// Send the new list to the viewer.
list->Notify();
GetViewerMethods()->ProcessExpressions();
if (!suspendGUIUpdates)
{
list->Notify();
GetViewerMethods()->ProcessExpressions();
}
MUTEX_UNLOCK();

return IntReturnValue(Synchronize());
Expand Down Expand Up @@ -3544,6 +3563,18 @@ visit_DefineSpeciesExpression(PyObject *self, PyObject *args)
return ExpressionDefinitionHelper(args, "DefineSpeciesExpression", Expression::Species);
}

STATIC PyObject *
visit_SuspendGUIUpdates(PyObject *self, PyObject *args)
{
return ExpressionDefinitionHelper(args, "SuspendGUIUpdates", Expression::Unknown);
}

STATIC PyObject *
visit_ResumeGUIUpdates(PyObject *self, PyObject *args)
{
return ExpressionDefinitionHelper(args, "ResumeGUIUpdates", Expression::Unknown);
}

// ****************************************************************************
// Function: visit_DeleteExpression
//
Expand Down Expand Up @@ -18681,6 +18712,11 @@ AddProxyMethods()
visit_WriteConfigFile_doc);
AddMethod("ZonePick", visit_ZonePick, visit_ZonePick_doc);

AddMethod("SuspendGUIUpdates", visit_SuspendGUIUpdates,
visit_SuspendGUIUpdates_doc);
AddMethod("ResumeGUIUpdates", visit_ResumeGUIUpdates,
visit_ResumeGUIUpdates_doc);

//
// Extra methods that are not part of the ViewerProxy but allow the
// script writer to do interesting things.
Expand Down

0 comments on commit 0184903

Please sign in to comment.