Commit b3443eed authored by camp's avatar camp

Added the ablitiy to save and load Session files from a remote host.

I have added a new dialog that uses the open data base dialog to implement the changes.
I have added new RPC messages to send the session file contents back and forth to the
mdserver.

I also remembered to update the release notes.



git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@27151 18c085ea-50e0-402c-830e-de6fd14e8384
parent 685e5a76
......@@ -116,6 +116,7 @@ QvisExpressionsWindow.C
QvisFileInformationWindow.C
QvisFileOpenDialog.C
QvisFileOpenWindow.C
QvisSessionFileDialog.C
QvisFilePanel.C
QvisFilePanelItem.C
QvisFileSelectionWindow.C
......
......@@ -3594,3 +3594,64 @@ FileServerList::SetFilePlugin(const QualifiedFilename &filename,
{
filePlugins[filename.FullName()] = plugin;
}
// ****************************************************************************
// Method: FileServerList::SaveSessionFile
//
// Purpose:
// Save Session file.
//
// Arguments:
// host - host name.
// filename - Session file name to load.
// contents - contents to write in the session file.
//
// Programmer: David Camp
// Creation: Thu Aug 27 09:40:00 PDT 2015
//
// Modifications:
//
// ****************************************************************************
void
FileServerList::SaveSessionFile(const std::string &host, const std::string &filename, const std::string &contents)
{
typedef MDServerManager::ServerMap ServerMap;
ServerMap& servers = MDServerManager::Instance()->GetServerMap();
ServerMap::iterator info = servers.find(host);
if(info != servers.end())
{
info->second->server->GetMDServerMethods()->SaveSession(filename, contents);
}
}
// ****************************************************************************
// Method: FileServerList::RestoreSessionFile
//
// Purpose:
// Load Remote Session file.
//
// Arguments:
// host - host name.
// filename - Session file name to load.
// contents - location to write session file contents.
//
// Programmer: David Camp
// Creation: Thu Aug 27 09:40:00 PDT 2015
//
// Modifications:
//
// ****************************************************************************
void
FileServerList::RestoreSessionFile(const std::string &host, const std::string &filename, std::string &contents)
{
typedef MDServerManager::ServerMap ServerMap;
ServerMap& servers = MDServerManager::Instance()->GetServerMap();
ServerMap::iterator info = servers.find(host);
if(info != servers.end())
{
info->second->server->GetMDServerMethods()->RestoreSession(filename, contents);
}
}
......@@ -213,6 +213,9 @@ class MessageAttributes;
// Brad Whitlock, Mon Dec 13 10:37:33 PST 2010
// I added "Ex" versions of GetMetaData and GetSIL.
//
// David Camp, Thu Aug 27 09:40:00 PDT 2015
// Added Save and Restore Session functions for remote hosts.
//
// ****************************************************************************
class GUI_API FileServerList : public AttributeSubject
......@@ -271,6 +274,8 @@ public:
void SetFilePlugin(const QualifiedFilename &filename, const std::string &plugin);
void CreateGroupList(const std::string &filename,
const stringVector &groupList);
void SaveSessionFile(const std::string &host, const std::string &filename, const std::string &contents);
void RestoreSessionFile(const std::string &host, const std::string &filename, std::string &contents);
const std::string &GetHost() const;
const std::string &GetPath() const;
......
......@@ -58,6 +58,9 @@
// Added getOpenFileNameWithFallbackPath, and added fallbackPath arg to
// delayedChangePath and getOpenFileNamEx.
//
// David Camp, Thu Aug 27 09:40:00 PDT 2015
// Needed access to private functions for new Session dialog box.
//
// ****************************************************************************
class QvisFileOpenDialog : public QvisFileOpenWindow
......@@ -91,7 +94,7 @@ private slots:
void reject();
void changeThePath();
void userSelectedFile(const QString &s);
private:
protected:
void setResult(int);
int result() const;
void delayedChangePath(const QString &initialFile, const QString &fltr, const QString &fallbackPath);
......@@ -101,6 +104,7 @@ private:
const QString &fallbacKPath = "");
void done(int r);
private:
QString filename;
QString filter;
QString fallbackPath;
......
......@@ -100,6 +100,9 @@ QvisFileOpenWindow::QvisFileOpenWindow(const QString &winCaption) :
QvisFileWindowBase(winCaption)
{
usageMode = OpenFiles;
hideFileFormat = false;
showFilename = false;
}
// ****************************************************************************
......@@ -147,6 +150,29 @@ QvisFileOpenWindow::SetUsageMode(QvisFileOpenWindow::UsageMode m)
usageMode = m;
}
// ****************************************************************************
// Method: QvisFileOpenWindow::SetHideFileFormat
//
// Purpose:
// Sets the flag to hide the data file gui options.
//
// Arguments:
// value : flag to show or hide data file gui options.
//
// Programmer: David Camp
// Creation: Thu Aug 6 09:05:15 PDT 2015
//
// Modifications:
//
// ****************************************************************************
void
QvisFileOpenWindow::SetHideFileFormat(bool value)
{
hideFileFormat = value;
}
// ****************************************************************************
// Method: QvisFileOpenWindow::CreateWindowContents
//
......@@ -181,6 +207,10 @@ QvisFileOpenWindow::SetUsageMode(QvisFileOpenWindow::UsageMode m)
// Brad Whitlock, Fri Jan 11 15:56:08 PST 2013
// Pass central to the progress callback on newer Qt's.
//
// David Camp, Thu Aug 27 09:40:00 PDT 2015
// Added a filename field if showFilename is true. For Session dialog.
// Also hide files if Session dialog.
//
// ****************************************************************************
void
......@@ -188,6 +218,22 @@ QvisFileOpenWindow::CreateWindowContents()
{
CreateHostPathFilterControls();
if(showFilename)
{
QGridLayout *pathLayout = new QGridLayout();
topLayout->addLayout(pathLayout);
pathLayout->setSpacing(10);
// Create the filename
filenameEdit = new QLineEdit(central);
connect(filenameEdit, SIGNAL(returnPressed()), this, SLOT(okClicked()));
connect(filenameEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filenameEditChanged(const QString &)));
QLabel *filenameLabel = new QLabel(tr("Filename"), central);
pathLayout->addWidget(filenameLabel, 3, 0, Qt::AlignRight);
pathLayout->addWidget(filenameEdit, 3, 1);
}
// Add a grid layout for the file and directory lists.
QSplitter *listSplitter = new QSplitter(central);
listSplitter->setOrientation(Qt::Horizontal);
......@@ -235,10 +281,12 @@ QvisFileOpenWindow::CreateWindowContents()
this, SLOT(selectFileChanged()));
fileList->installEventFilter(this);
listSplitter->addWidget(fileWidget);
// Create the file format combo box
QHBoxLayout *fileFormatLayout = new QHBoxLayout();
topLayout->addLayout(fileFormatLayout);
fileFormatLayout->addWidget(new QLabel(tr("Open file as type:")));
QLabel *openFileAsTypeLabel = new QLabel(tr("Open file as type:"));
fileFormatLayout->addWidget(openFileAsTypeLabel);
fileFormatComboBox = new QComboBox(central);
fileFormatLayout->addWidget(fileFormatComboBox, 10);
setDefaultOptionsForFormatButton = new QPushButton(
......@@ -250,6 +298,12 @@ QvisFileOpenWindow::CreateWindowContents()
this, SLOT(fileFormatChanged(const QString&)));
connect(setDefaultOptionsForFormatButton, SIGNAL(clicked()),
this, SLOT(setDefaultOptionsForFormatButtonClicked()));
if(hideFileFormat)
{
openFileAsTypeLabel->hide();
fileFormatComboBox->hide();
setDefaultOptionsForFormatButton->hide();
}
// create the lower button layout
QHBoxLayout *buttonLayout = new QHBoxLayout();
......@@ -495,26 +549,41 @@ QvisFileOpenWindow::ConnectSubjects(HostProfileList *hpl,
// Brad Whitlock, Mon Oct 11 16:26:08 PDT 2010
// Don't open the file if you're just selecting a filename.
//
// David Camp, Thu Aug 27 09:40:00 PDT 2015
// If showFilename is true, then we just want a single filename.
// Added for session dialog.
//
// ****************************************************************************
void
QvisFileOpenWindow::okClicked()
{
// Add all the selected files to the intermediate file list.
QualifiedFilename emitFile;
for (int i = 0; i < fileList->count(); ++i)
if( showFilename )
{
if (!fileList->item(i)->isSelected())
continue;
emitFile.host = fileServer->GetHost();
emitFile.path = fileServer->GetPath();
emitFile.filename = filenameEdit->text().toStdString();
emitFile.separator = fileServer->GetSeparator();
}
else
{
// Add all the selected files to the intermediate file list.
for (int i = 0; i < fileList->count(); ++i)
{
if (!fileList->item(i)->isSelected())
continue;
// Add the file to the list if it's not in it.
QualifiedFilename fn(DecodeQualifiedFilename(fileList->item(i)->
data(Qt::UserRole)));
AddFile(fn);
// Add the file to the list if it's not in it.
QualifiedFilename fn(DecodeQualifiedFilename(fileList->item(i)->
data(Qt::UserRole)));
AddFile(fn);
// Save the name of the first file.
if(emitFile.Empty())
emitFile = fn;
// Save the name of the first file.
if(emitFile.Empty())
emitFile = fn;
}
}
// If we selected a file, open it.
......@@ -632,12 +701,20 @@ QvisFileOpenWindow::cancelClicked()
// Note: Taken largely from QvisFileSelectWindow
//
// Modifications:
// David Camp, Thu Aug 27 09:40:00 PDT 2015
// If showFilename is true, then set the filename field.
// Added for session dialog.
//
// ****************************************************************************
void
QvisFileOpenWindow::selectFileDblClick(QListWidgetItem *item)
{
if( showFilename )
{
filenameEdit->setText(fileList->currentItem()->text());
}
// Make this do an Open action instead of a Select action
okClicked();
}
......@@ -661,6 +738,10 @@ QvisFileOpenWindow::selectFileDblClick(QListWidgetItem *item)
// Cyrus Harrison, Tue Jun 24 11:15:28 PDT 2008
// Initial Qt4 Port.
//
// David Camp, Thu Aug 27 09:40:00 PDT 2015
// If showFilename is true, then set the filename field.
// Added for session dialog.
//
// ****************************************************************************
void
QvisFileOpenWindow::selectFileChanged(void)
......@@ -668,10 +749,21 @@ QvisFileOpenWindow::selectFileChanged(void)
// Count the number of selected files
int count = 0;
for(int i = 0; i < fileList->count(); ++i)
{
if(fileList->item(i)->isSelected())
count++;
{
count = 1;
if(showFilename)
{
hideFileFormat = false;
filenameEdit->setText(fileList->currentItem()->text());
hideFileFormat = true;
}
break;
}
}
if (count >= 1)
if (count)
okButton->setEnabled(true);
else
okButton->setEnabled(false);
......@@ -880,3 +972,53 @@ QvisFileOpenWindow::eventFilter(QObject *o, QEvent *e)
}
return false;
}
// ****************************************************************************
// Method: QvisFileOpenWindow::SetShowFilename
//
// Purpose:
// Set flag to show filename field
//
// Arguments:
// value bool value true to show. Default is false
//
// Programmer: David Camp
// Creation: Thu Aug 27 09:40:00 PDT 2015
//
// Modifications:
//
// ****************************************************************************
void
QvisFileOpenWindow::SetShowFilename(bool value)
{
showFilename = value;
}
// ****************************************************************************
// Method: QvisFileOpenWindow::filenameEditChanged
//
// Purpose:
// Signal for the filename field if the user changes the text.
//
// Arguments:
// text new text in field.
//
// Programmer: David Camp
// Creation: Thu Aug 27 09:40:00 PDT 2015
//
// Modifications:
//
// ****************************************************************************
void
QvisFileOpenWindow::filenameEditChanged(const QString &text)
{
if(hideFileFormat)
fileList->clearSelection();
if(text.isEmpty())
okButton->setEnabled(false);
else
okButton->setEnabled(true);
}
......@@ -72,6 +72,10 @@
// Brad Whitlock, Mon Jul 14 11:38:44 PDT 2008
// Changed inheritance and moved some methods to base class.
//
// David Camp, Thu Aug 27 09:40:00 PDT 2015
// Added filename field if set to show. This is used by the Session dialog.
// Also a flag to hide some fields not needed by the Session dialog
//
// ****************************************************************************
class GUI_API QvisFileOpenWindow : public QvisFileWindowBase
......@@ -92,6 +96,10 @@ public:
} UsageMode;
void SetUsageMode(UsageMode m);
void SetHideFileFormat(bool value);
void SetShowFilename(bool value);
signals:
void selectedFile(const QString &);
void selectCancelled();
......@@ -114,6 +122,7 @@ private slots:
void setDefaultOptionsForFormatButtonClicked();
void fileFormatChanged(const QString&);
void filenameEditChanged(const QString &text);
private:
DBPluginInfoAttributes *dbplugins;
UsageMode usageMode;
......@@ -124,6 +133,13 @@ private:
QPushButton *cancelButton;
QComboBox *fileFormatComboBox;
QPushButton *setDefaultOptionsForFormatButton;
// If true it will hide the fileFormatComboBox and setDefaultOptionsForFormatButton.
// Used for the session dialog to load and save session files.
bool hideFileFormat;
// Flag to show or hide the filename. Used for save session file dialog.
bool showFilename;
QLineEdit *filenameEdit;
};
#endif
......@@ -179,6 +179,8 @@ QvisFileWindowBase::QvisFileWindowBase(const QString &winCaption) :
// Set the progress callback that we want to use while we
// connect to the mdserver.
fileServer->SetProgressCallback(ProgressCallback, (void *)this);
hideOptions = false;
}
// ****************************************************************************
......@@ -425,11 +427,14 @@ QvisFileWindowBase::UpdateComboBox(QComboBox *cb, const stringVector &s,
// Brad Whitlock, Wed Sep 12 15:03:41 PDT 2012
// I added the showDotFiles toggle.
//
// David Camp, Thu Aug 27 09:40:00 PDT 2015
// Added an option to hide field not needed by the Session dialog.
//
// ****************************************************************************
void
QvisFileWindowBase::CreateHostPathFilterControls()
{
{
//
// Create the path, filter
//
......@@ -515,7 +520,8 @@ QvisFileWindowBase::CreateHostPathFilterControls()
connect(fileGroupingComboBox, SIGNAL(activated(int)),
this, SLOT(fileGroupingChanged(int)));
toggleLayout->addStretch(5);
toggleLayout->addWidget(new QLabel(tr("File grouping"), central), 0, Qt::AlignRight);
QLabel *qFileGroupingLabel = new QLabel(tr("File grouping"), central);
toggleLayout->addWidget(qFileGroupingLabel, 0, Qt::AlignRight);
toggleLayout->addWidget(fileGroupingComboBox, 0, Qt::AlignLeft);
toggleLayout->addStretch(5);
......@@ -531,6 +537,17 @@ QvisFileWindowBase::CreateHostPathFilterControls()
connect(recentPathRemovalButton, SIGNAL(clicked()),
recentPathsRemovalWindow, SLOT(show()));
toggleLayout->addWidget(recentPathRemovalButton);
if(hideOptions)
{
sep1->hide();
sep2->hide();
currentDirToggle->hide();
showDotFilesToggle->hide();
fileGroupingComboBox->hide();
qFileGroupingLabel->hide();
recentPathRemovalButton->hide();
}
}
// ****************************************************************************
......@@ -2107,3 +2124,29 @@ DecodeQualifiedFilename(const QVariant &v)
return f;
}
// ****************************************************************************
// Method: QvisFileWindowBase::SetHideOptions
//
// Purpose:
// If true, will tell the window to hide fields not needed by the Session
// dialog.
//
// Arguments:
// value : true or false to show or hide fields.
//
// Returns:
//
// Programmer: David Camp
// Creation: Thu Aug 27 09:40:00 PDT 2015
//
// Modifications:
//
// ****************************************************************************
void
QvisFileWindowBase::SetHideOptions(bool value)
{
hideOptions = value;
}
......@@ -71,6 +71,9 @@ class QvisRecentPathRemovalWindow;
// Brad Whitlock, Fri Jan 11 15:50:56 PST 2013
// Remove setEnabled method.
//
// David Camp, Thu Aug 27 09:40:00 PDT 2015
// Added a flag to hide fields for the session file dialog.
//
// ****************************************************************************
class GUI_API QvisFileWindowBase : public QvisDelayedWindowSimpleObserver
......@@ -112,6 +115,9 @@ protected:
void GetVirtualDatabaseDefinitions(StringStringVectorMap &);
void CheckForNewStates();
void SetHideOptions(bool value);
public slots:
virtual void showMinimized();
virtual void showNormal();
......@@ -146,6 +152,10 @@ protected:
QualifiedFilenameVector intermediateFileList;
StringStringVectorMap currentVirtualDatabaseDefinitions;
stringVector invalidHosts;
// Flag to hide the options, currentDirToggle, showDotFilesToggle, ... from
// showing. This is used in the save and load of session files.
bool hideOptions;
};
// Functions to encode QualifiedFilename into QVariant and back.
......
This diff is collapsed.
......@@ -343,6 +343,10 @@ class SplashScreen;
// Brad Whitlock, Fri Aug 6 16:55:58 PDT 2010
// Added Selections window.
//
// David Camp, Tue Aug 4 11:04:14 PDT 2015
// Added new ablitiy to save session files on remote host.
// This includes a new variable sessionHost.
//
// ****************************************************************************
class GUI_API QvisGUIApplication : public QObject, public ConfigManager, public GUIBase
......@@ -380,10 +384,14 @@ protected:
void InitializeFileServer(DataNode *);
void LoadFile(QualifiedFilename &f, bool addDefaultPlots);
void LoadSessionFile();
void LoadSessionRemoteFile(const std::string& filename, const std::string& host, std::istringstream& sessionGUI);
void MoveAndResizeMainWindow(int orientation);
void ProcessArguments(int &argc, char **argv);
virtual DataNode *ReadConfigFile(const char *filename);
virtual DataNode *ReadConfigFile(std::istream& in);
void ProcessSessionNode(DataNode *node, const std::string &filename,
const stringVector &sources, const std::string &hostname);
void ProcessConfigSettings(DataNode *settings, bool systemConfig);
void ProcessWindowConfigSettings(DataNode *settings);
void SetOrientation(int orientation);
......@@ -402,7 +410,7 @@ protected:
void GetVirtualDatabaseDefinitions(StringStringVectorMap &defs);
void SetSessionNameInWindowTitle(const QString &filename);
QString SaveSessionFile(const QString &s);
QString SaveSessionFile(const QString &s, const std::string &hostname);
// Internal callbacks
static void StartMDServer(const std::string &hostName,
......@@ -414,7 +422,7 @@ protected:
static void UpdateMetaDataAttributes(Subject *subj, void *data);
static void ClientMethodCallback(Subject *subj, void *data);
void RestoreSessionFile(const QString &, const stringVector &);
void RestoreSessionFile(const QString &, const stringVector &, const std::string &);
int GetNumMovieFrames();
void UpdateSessionDir( const std::string &sessionFileName );
......@@ -617,6 +625,7 @@ protected:
QString sessionFile;
int sessionCount;
std::string sessionDir;
std::string sessionHost;
// Movie variables
stringVector movieArguments;
......
......@@ -543,7 +543,8 @@ QvisSaveMovieWizard::WriteTemplateSpecification()
// new template
debug1 << mName << "Telling viewer to export session "
<< sessionFile.c_str() << endl;
GetViewerMethods()->ExportEntireState(sessionFile);
std::string hostname;
GetViewerMethods()->ExportEntireState(sessionFile, hostname);
templateSpec->SetSessionFile(sessionFile);
}
......
/*****************************************************************************
*
* Copyright (c) 2000 - 2014, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the LLNS/LLNL nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
* LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
#include <QvisSessionFileDialog.h>
#include <QComboBox>
// ****************************************************************************
// Method: QvisSessionFileDialog::QvisSessionvisFileDialog
//
// Purpose:
// Constructor for the QvisSessionFileDialog class.
// This dialog is used for both Save and Restore of Session files.
//
// Arguments:
// caption : The name of the window.
//
// Programmer: David Camp
// Creation: Tue Aug 4 11:04:14 PDT 2015
//
// Modifications:
//
// ****************************************************************************
QvisSessionFileDialog::QvisSessionFileDialog(const QString &caption) :
QvisFileOpenDialog(caption)
{
}
// ****************************************************************************
// Method: QvisSessionFileDialog::~QvisSessionFileDialog
//
// Purpose:
// Destructor.
//
// Programmer: David Camp
// Creation: Tue Aug 4 11:04:14 PDT 2015
//
// Modifications:
//
// ****************************************************************************
QvisSessionFileDialog::~QvisSessionFileDialog()
{
}
// ****************************************************************************
// Method: QvisFileDialog::getFileName
//
// Purpose:
// Function for getting the name of an existing file using VisIt's
// File open window or creating a filename if in save mode.
//
// Arguments:
// type : Type of dlg Save or Load.
// initialFile : The host, path, and filename of the initial file.
// caption : The name of the window.
//
// Returns: The name of the file, selected or created, or a null QString if
// the user did not select a file.
//
// Note:
//
// Programmer: David Camp
// Creation: Thu Aug 6 07:32:42 PDT 2015
//
// Modifications:
//
// ****************************************************************************
void
QvisSessionFileDialog::getFileName(DLG_TYPE type,
const QString &initialFile,
QualifiedFilename &filename)
{
QString qfilename;
#if defined(_WIN32)
QString fltr("*.session *.vses");
#else
QString fltr("*.session");
#endif
SetUsageMode(QvisFileOpenDialog::SelectFilename);
SetHideFileFormat(true);
SetHideOptions(true);
if(type == SAVE_DLG)
SetShowFilename(true);
qfilename = getOpenFileNameEx(initialFile, fltr);
if(!qfilename.isEmpty())
{
filename.SetFromString(qfilename.toStdString());
}
}
#ifndef QVIS_SESSION_FILE_OPEN_DIALOG_H
#define QVIS_SESSION_FILE_OPEN_DIALOG_H
/*****************************************************************************
*
* Copyright (c) 2000 - 2015, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* All rights reserved.
*