Commit d84702b2 authored by Cory Quammen's avatar Cory Quammen Committed by Kitware Robot

Merge topic '19240-activate-view-example-vis'

1c703cc6 Set an active view after loading state
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Utkarsh Ayachit's avatarUtkarsh Ayachit <utkarsh.ayachit@kitware.com>
Merge-request: !3505
parents 4ff262e7 1c703cc6
......@@ -4,6 +4,7 @@
#include "pqActiveObjects.h"
#include "pqApplicationCore.h"
#include "pqEventDispatcher.h"
#include "pqLoadStateReaction.h"
#include "vtkPVConfig.h"
#include "vtkPVFileInformation.h"
......@@ -106,6 +107,9 @@ void pqExampleVisualizationsDialog::onButtonPressed()
xmldata.replace("$PARAVIEW_EXAMPLES_DATA", dataPath);
pqApplicationCore::instance()->loadStateFromString(
xmldata.toUtf8().data(), pqActiveObjects::instance().activeServer());
// This is needed since XML state currently does not save active view.
pqLoadStateReaction::activateView();
}
else
{
......
......@@ -116,15 +116,9 @@ void pqLoadStateReaction::loadState(const QString& filename, bool dialogBlocked,
server, filename);
}
pqPVApplicationCore::instance()->setLoadingState(false);
// activate a view in the state.
// this is needed since XML state currently does not save active view.
auto smmodel = pqApplicationCore::instance()->getServerManagerModel();
auto views = smmodel->findItems<pqView*>(server);
if (views.size())
{
pqActiveObjects::instance().setActiveView(views[0]);
}
// This is needed since XML state currently does not save active view.
pqLoadStateReaction::activateView();
}
}
else
......@@ -156,3 +150,15 @@ void pqLoadStateReaction::loadState()
pqLoadStateReaction::loadState(selectedFile);
}
}
//-----------------------------------------------------------------------------
void pqLoadStateReaction::activateView()
{
auto server = pqActiveObjects::instance().activeServer();
auto smmodel = pqApplicationCore::instance()->getServerManagerModel();
auto views = smmodel->findItems<pqView*>(server);
if (views.size())
{
pqActiveObjects::instance().setActiveView(views[0]);
}
}
......@@ -62,6 +62,11 @@ public:
const QString& filename, bool dialogBlocked = false, pqServer* server = NULL);
static void loadState();
/**
* Set default active view after state is loaded. Make the first view active.
*/
static void activateView();
public slots:
/**
* Updates the enabled state. Applications need not explicitly call
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment