Commit 991759ee authored by whitlocb's avatar whitlocb

Change export host mechanism so it works.

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@28617 18c085ea-50e0-402c-830e-de6fd14e8384
parent 6946e5fa
......@@ -49,6 +49,12 @@ VISIT_OPTION_DEFAULT(VISIT_PYTHON_DIR ${VISITHOME}/python/2.7.6/${VISITARCH})
##
VISIT_OPTION_DEFAULT(VISIT_QT_BIN ${VISITHOME}/qt/4.8.6/${VISITARCH}/bin)
##
## QWT
##
SETUP_APP_VERSION(QWT 6.1.2)
VISIT_OPTION_DEFAULT(VISIT_QWT_DIR ${VISITHOME}/qwt/${QWT_VERSION}/${VISITARCH})
##
## VTK
##
......@@ -184,6 +190,12 @@ VISIT_OPTION_DEFAULT(VISIT_PYTHON_DIR ${VISITHOME}/python/2.7.6/${VISITARCH})
##
VISIT_OPTION_DEFAULT(VISIT_QT_BIN ${VISITHOME}/qt/4.8.6/${VISITARCH}/bin)
##
## QWT
##
SETUP_APP_VERSION(QWT 6.1.2)
VISIT_OPTION_DEFAULT(VISIT_QWT_DIR ${VISITHOME}/qwt/${QWT_VERSION}/${VISITARCH})
##
## VTK
##
......
......@@ -3513,8 +3513,23 @@ public class ViewerMethods
return Synchronize();
}
/**
* Exports a host profile to a file.
*
* @param profile The nickname of the host profile to save.
* @param filename The name of the file to save the profile to.
* @param saveInUserDir Whether to save in the user's ~/.visit/hosts directory.
* @return true on success; false otherwise.
*/
public boolean ExportHostProfile(String profile, String filename, boolean saveInUserDir)
{
GetViewerState().GetViewerRPC().SetRPCType(ViewerRPC.VIEWERRPCTYPE_EXPORTHOSTPROFILERPC);
GetViewerState().GetViewerRPC().SetStringArg1(profile);
GetViewerState().GetViewerRPC().SetStringArg2(filename);
GetViewerState().GetViewerRPC().SetBoolFlag(saveInUserDir);
GetViewerState().GetViewerRPC().Notify();
return Synchronize();
}
//
// Convenience methods
......
......@@ -264,9 +264,10 @@ public class ViewerRPC extends AttributeSubject
public final static int VIEWERRPCTYPE_RELEASETODDTRPC = 200;
public final static int VIEWERRPCTYPE_PLOTDDTVISPOINTVARIABLESRPC = 201;
public final static int VIEWERRPCTYPE_EXPORTRPC = 202;
public final static int VIEWERRPCTYPE_READHOSTPROFILESFROMDIRECTORYRPC = 203;
public final static int VIEWERRPCTYPE_SETREMOVEDUPLICATENODESRPC = 204;
public final static int VIEWERRPCTYPE_MAXRPC = 205;
public final static int VIEWERRPCTYPE_EXPORTHOSTPROFILERPC = 203;
public final static int VIEWERRPCTYPE_READHOSTPROFILESFROMDIRECTORYRPC = 204;
public final static int VIEWERRPCTYPE_SETREMOVEDUPLICATENODESRPC = 205;
public final static int VIEWERRPCTYPE_MAXRPC = 206;
public ViewerRPC()
......@@ -1344,6 +1345,8 @@ public class ViewerRPC extends AttributeSubject
str = str + "VIEWERRPCTYPE_PLOTDDTVISPOINTVARIABLESRPC";
if(RPCType == VIEWERRPCTYPE_EXPORTRPC)
str = str + "VIEWERRPCTYPE_EXPORTRPC";
if(RPCType == VIEWERRPCTYPE_EXPORTHOSTPROFILERPC)
str = str + "VIEWERRPCTYPE_EXPORTHOSTPROFILERPC";
if(RPCType == VIEWERRPCTYPE_READHOSTPROFILESFROMDIRECTORYRPC)
str = str + "VIEWERRPCTYPE_READHOSTPROFILESFROMDIRECTORYRPC";
if(RPCType == VIEWERRPCTYPE_SETREMOVEDUPLICATENODESRPC)
......
......@@ -268,6 +268,7 @@ ViewerFactory::SetActionManagerLogic(ViewerActionManager *mgr, ViewerWindow *win
mgr->SetLogic(ViewerRPC::ExportColorTableRPC, new ExportColorTableAction(win));
mgr->SetLogic(ViewerRPC::ExportDBRPC, new ExportDBAction(win));
mgr->SetLogic(ViewerRPC::ExportEntireStateRPC, new ExportEntireStateAction(win));
mgr->SetLogic(ViewerRPC::ExportHostProfileRPC, new ExportHostProfileAction(win));
mgr->SetLogic(ViewerRPC::GetProcInfoRPC, new GetProcInfoAction(win));
mgr->SetLogic(ViewerRPC::GetQueryParametersRPC, new GetQueryParametersAction(win));
mgr->SetLogic(ViewerRPC::GetQueryParametersRPC, new GetQueryParametersAction(win));
......
......@@ -50,6 +50,10 @@
#include <ExportDBAttributes.h>
#include <avtColorTables.h>
#include <HostProfileList.h>
#include <MachineProfile.h>
#include <InstallationFunctions.h>
#include <SingleAttributeConfigManager.h>
//
// These methods were adapted from ViewerSubject handlers.
......@@ -303,6 +307,62 @@ ExportEntireStateAction::Execute()
///////////////////////////////////////////////////////////////////////////////
// ****************************************************************************
// Method: ExportHostProfileAction::Execute
//
// Purpose:
// Execute ViewerRPC::ExportHostProfileRPC
//
// Programmer: Brad Whitlock
// Creation: Fri Jun 3 16:27:38 PDT 2016
//
// Modifications:
//
// ****************************************************************************
void
ExportHostProfileAction::Execute()
{
std::string profileName(args.GetStringArg1());
std::string fileName(args.GetStringArg2());
bool saveInUserDir(args.GetBoolFlag());
std::string userdir = GetAndMakeUserVisItHostsDirectory();
HostProfileList *hpl = GetViewerState()->GetHostProfileList();
for (int i = 0; i < hpl->GetNumMachines(); ++i)
{
MachineProfile &pl = hpl->GetMachines(i);
std::string host = pl.GetHostNickname();
if(host != profileName) continue;
std::string name = "";
if(!saveInUserDir)
name = fileName;
else
name = userdir + VISIT_SLASH_STRING + fileName;
GetViewerMessaging()->Status(
TR("Host profile %1 exported to %2").
arg(host).
arg(name));
// Tell the user what happened.
GetViewerMessaging()->Message(
TR("VisIt exported host profile \"%1\" to the file: %2. ").
arg(host).
arg(name));
SingleAttributeConfigManager mgr(&pl);
mgr.Export(name);
break;
}
}
///////////////////////////////////////////////////////////////////////////////
// ****************************************************************************
// Method: ImportEntireStateAction::Execute
//
......@@ -396,3 +456,4 @@ WriteConfigFileAction::Execute()
GetViewerStateManager()->WriteConfigFile();
GetViewerStateManager()->WriteHostProfiles();
}
......@@ -216,4 +216,28 @@ public:
virtual void Execute();
};
// ****************************************************************************
// Class: ExportHostProfileAction
//
// Purpose:
// Handles ViewerRPC::ExportHostProfileRPC
//
// Notes:
//
// Programmer: Brad Whitlock
// Creation: Fri Jun 3 16:14:51 PDT 2016
//
// Modifications:
//
// ****************************************************************************
class VIEWERCORE_API ExportHostProfileAction : public ViewerActionLogic
{
public:
ExportHostProfileAction(ViewerWindow *win) : ViewerActionLogic(win) {}
virtual ~ExportHostProfileAction() {}
virtual void Execute();
};
#endif
......@@ -3137,63 +3137,6 @@ ViewerSubject::ExportWindow()
qatts->ClearVars();
}
// ****************************************************************************
// Method: QvisHostProfileWindow::ExportHostProfile
//
// Purpose:
// Export Selected HostProfile to Directory.
//
// Programmer:
// Creation: September 10, 2013
//
// Modifications:
//
// ****************************************************************************
void
ViewerSubject::ExportHostProfile()
{
JSONNode node;
node.Parse(GetViewerState()->GetViewerRPC()->GetStringArg1());
std::string profileName = node["profileName"].GetString();
std::string fileName = node["fileName"].GetString();
bool saveInUserDir = node["saveInUserDir"].GetBool();
std::string userdir = GetAndMakeUserVisItHostsDirectory();
HostProfileList *hpl = GetViewerState()->GetHostProfileList();
for (int i = 0; i < hpl->GetNumMachines(); ++i)
{
MachineProfile &pl = hpl->GetMachines(i);
std::string host = pl.GetHostNickname();
if(host != profileName) continue;
std::string name = "";
if(!saveInUserDir)
name = fileName;
else
name = userdir + VISIT_SLASH_STRING + fileName;
GetViewerMessaging()->Status(
TR("Host profile %1 exported to %2").
arg(host).
arg(name));
// Tell the user what happened.
GetViewerMessaging()->Message(
TR("VisIt exported host profile \"%1\" to the file: %2. ").
arg(host).
arg(name));
SingleAttributeConfigManager mgr(&pl);
mgr.Export(name);
break;
}
}
// ****************************************************************************
// Method: ViewerSubject::Export
//
......@@ -3254,10 +3197,6 @@ ViewerSubject::Export()
ExportWindow();
}
if(action == "ExportHostProfile") {
ExportHostProfile();
}
if(action == "GetFileList") {
std::string host = node["host"].GetString();
std::string remotePath = node["path"].GetString();
......
......@@ -260,8 +260,7 @@ private:
void BroadcastData(int windowId, int clientId);
void Export();
void ExportWindow();
void ExportHostProfile();
static void RenderEventCallback(int windowId, bool inMotion, void* data);
static void RenderEventCallback(int windowId, bool inMotion, void* data);
static vtkRenderWindowInteractor* CreateGlobalInteractor();
SharedDaemon *shared_viewer_daemon;
......
......@@ -5598,17 +5598,23 @@ ViewerMethods::ExportWindows(const intVector &windowIds, const std::string &form
state->GetViewerRPC()->Notify();
}
// ****************************************************************************
// Method: ViewerMethods::ExportHostProfile
//
// Purpose: Exports a host profile to a file.
//
// Programmer: Brad Whitlock
// Creation: Fri Jun 3 16:08:37 PDT 2016
//
// ****************************************************************************
void
ViewerMethods::ExportHostProfile(const std::string& profile, const std::string& filename, const bool &saveInUserDir)
ViewerMethods::ExportHostProfile(const std::string &profile, const std::string &filename, bool saveInUserDir)
{
JSONNode node;
node["action"] = "ExportHostProfile";
node["profileName"] = profile;
node["fileName"] = filename;
node["saveInUserDir"] = saveInUserDir;
state->GetViewerRPC()->SetRPCType(ViewerRPC::ExportRPC);
state->GetViewerRPC()->SetStringArg1(node.ToString());
state->GetViewerRPC()->SetRPCType(ViewerRPC::ExportHostProfileRPC);
state->GetViewerRPC()->SetStringArg1(profile);
state->GetViewerRPC()->SetStringArg2(filename);
state->GetViewerRPC()->SetBoolFlag(saveInUserDir);
state->GetViewerRPC()->Notify();
}
......
......@@ -458,7 +458,7 @@ public:
/// Experimental features (that are not official yet)
void ExportWindows(const intVector &windowIds, const std::string& format);
void ExportHostProfile(const std::string& profile, const std::string &filename, const bool& saveInUserDir = false);
void ExportHostProfile(const std::string &profile, const std::string &filename, bool saveInUserDir = false);
void UpdateMouseActions(const int& windowId, const std::string& mouseButton, const double &start_dx, const double& start_dy, const double& end_dx, const double &end_dy, const bool &ctrl, const bool &shift);
void GetFileList(const std::string& path);
void ForceRedraw(int windowId);
......
......@@ -112,21 +112,22 @@ static const char *ViewerRPCType_strings[] = {
"MovePlotOrderTowardFirstRPC", "MovePlotOrderTowardLastRPC", "SetPlotOrderToFirstRPC",
"SetPlotOrderToLastRPC", "RenamePickLabelRPC", "GetQueryParametersRPC",
"DDTConnectRPC", "DDTFocusRPC", "ReleaseToDDTRPC",
"PlotDDTVispointVariablesRPC", "ExportRPC", "ReadHostProfilesFromDirectoryRPC",
"SetRemoveDuplicateNodesRPC", "MaxRPC"};
"PlotDDTVispointVariablesRPC", "ExportRPC", "ExportHostProfileRPC",
"ReadHostProfilesFromDirectoryRPC", "SetRemoveDuplicateNodesRPC", "MaxRPC"
};
std::string
ViewerRPC::ViewerRPCType_ToString(ViewerRPC::ViewerRPCType t)
{
int index = int(t);
if(index < 0 || index >= 206) index = 0;
if(index < 0 || index >= 207) index = 0;
return ViewerRPCType_strings[index];
}
std::string
ViewerRPC::ViewerRPCType_ToString(int t)
{
int index = (t < 0 || t >= 206) ? 0 : t;
int index = (t < 0 || t >= 207) ? 0 : t;
return ViewerRPCType_strings[index];
}
......@@ -134,7 +135,7 @@ bool
ViewerRPC::ViewerRPCType_FromString(const std::string &s, ViewerRPC::ViewerRPCType &val)
{
val = ViewerRPC::CloseRPC;
for(int i = 0; i < 206; ++i)
for(int i = 0; i < 207; ++i)
{
if(s == ViewerRPCType_strings[i])
{
......
......@@ -266,6 +266,7 @@ public:
ReleaseToDDTRPC,
PlotDDTVispointVariablesRPC,
ExportRPC,
ExportHostProfileRPC,
ReadHostProfilesFromDirectoryRPC,
SetRemoveDuplicateNodesRPC,
MaxRPC
......
......@@ -204,6 +204,7 @@
ReleaseToDDTRPC
PlotDDTVispointVariablesRPC
ExportRPC
ExportHostProfileRPC
ReadHostProfilesFromDirectoryRPC
SetRemoveDuplicateNodesRPC
MaxRPC
......
......@@ -126,8 +126,8 @@ PyViewerRPC_ToString(const ViewerRPC *atts, const char *prefix)
"InitializeNamedSelectionVariablesRPC, MenuQuitRPC, SetPlotDescriptionRPC, MovePlotOrderTowardFirstRPC, "
"MovePlotOrderTowardLastRPC, SetPlotOrderToFirstRPC, SetPlotOrderToLastRPC, RenamePickLabelRPC, "
"GetQueryParametersRPC, DDTConnectRPC, DDTFocusRPC, ReleaseToDDTRPC, "
"PlotDDTVispointVariablesRPC, ExportRPC, ReadHostProfilesFromDirectoryRPC, SetRemoveDuplicateNodesRPC, "
"MaxRPC";
"PlotDDTVispointVariablesRPC, ExportRPC, ExportHostProfileRPC, ReadHostProfilesFromDirectoryRPC, "
"SetRemoveDuplicateNodesRPC, MaxRPC";
switch (atts->GetRPCType())
{
case ViewerRPC::CloseRPC:
......@@ -942,6 +942,10 @@ PyViewerRPC_ToString(const ViewerRPC *atts, const char *prefix)
SNPRINTF(tmpStr, 1000, "%sRPCType = %sExportRPC # %s\n", prefix, prefix, RPCType_names);
str += tmpStr;
break;
case ViewerRPC::ExportHostProfileRPC:
SNPRINTF(tmpStr, 1000, "%sRPCType = %sExportHostProfileRPC # %s\n", prefix, prefix, RPCType_names);
str += tmpStr;
break;
case ViewerRPC::ReadHostProfilesFromDirectoryRPC:
SNPRINTF(tmpStr, 1000, "%sRPCType = %sReadHostProfilesFromDirectoryRPC # %s\n", prefix, prefix, RPCType_names);
str += tmpStr;
......@@ -1128,12 +1132,12 @@ ViewerRPC_SetRPCType(PyObject *self, PyObject *args)
return NULL;
// Set the RPCType in the object.
if(ival >= 0 && ival < 206)
if(ival >= 0 && ival < 207)
obj->data->SetRPCType(ViewerRPC::ViewerRPCType(ival));
else
{
fprintf(stderr, "An invalid RPCType value was given. "
"Valid values are in the range of [0,205]. "
"Valid values are in the range of [0,206]. "
"You can also use the following names: "
"CloseRPC, DetachRPC, AddWindowRPC, DeleteWindowRPC, SetWindowLayoutRPC, "
"SetActiveWindowRPC, ClearWindowRPC, ClearAllWindowsRPC, OpenDatabaseRPC, "
......@@ -1185,8 +1189,8 @@ ViewerRPC_SetRPCType(PyObject *self, PyObject *args)
"InitializeNamedSelectionVariablesRPC, MenuQuitRPC, SetPlotDescriptionRPC, MovePlotOrderTowardFirstRPC, "
"MovePlotOrderTowardLastRPC, SetPlotOrderToFirstRPC, SetPlotOrderToLastRPC, RenamePickLabelRPC, "
"GetQueryParametersRPC, DDTConnectRPC, DDTFocusRPC, ReleaseToDDTRPC, "
"PlotDDTVispointVariablesRPC, ExportRPC, ReadHostProfilesFromDirectoryRPC, SetRemoveDuplicateNodesRPC, "
"MaxRPC.");
"PlotDDTVispointVariablesRPC, ExportRPC, ExportHostProfileRPC, ReadHostProfilesFromDirectoryRPC, "
"SetRemoveDuplicateNodesRPC, MaxRPC.");
return NULL;
}
......@@ -2652,6 +2656,8 @@ PyViewerRPC_getattr(PyObject *self, char *name)
return PyInt_FromLong(long(ViewerRPC::PlotDDTVispointVariablesRPC));
if(strcmp(name, "ExportRPC") == 0)
return PyInt_FromLong(long(ViewerRPC::ExportRPC));
if(strcmp(name, "ExportHostProfileRPC") == 0)
return PyInt_FromLong(long(ViewerRPC::ExportHostProfileRPC));
if(strcmp(name, "ReadHostProfilesFromDirectoryRPC") == 0)
return PyInt_FromLong(long(ViewerRPC::ReadHostProfilesFromDirectoryRPC));
if(strcmp(name, "SetRemoveDuplicateNodesRPC") == 0)
......
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