Commit 30348b54 authored by whitlocb's avatar whitlocb

I added support for grouping operator plugins into categories in the operator menus.



git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@9848 18c085ea-50e0-402c-830e-de6fd14e8384
parent 61de1940
......@@ -116,6 +116,9 @@ class ExpressionList;
// internationalize plot names. Added const to strings returned from
// GeneralOperatorPluginInfo.
//
// Brad Whitlock, Thu Feb 4 16:04:19 PST 2010
// I added a GetCategoryName method.
//
// ****************************************************************************
class PLUGIN_API GeneralOperatorPluginInfo
......@@ -126,6 +129,7 @@ class PLUGIN_API GeneralOperatorPluginInfo
virtual const char *GetVersion() const = 0;
virtual const char *GetID() const = 0;
virtual bool EnabledByDefault() const { return true; }
virtual const char *GetCategoryName() const { return ""; }
};
class PLUGIN_API CommonOperatorPluginInfo : public virtual GeneralOperatorPluginInfo
......
......@@ -59,10 +59,13 @@ using std::vector;
// Creation: August 20, 2002
//
// Modifications:
// Brad Whitlock, Fri Feb 5 14:46:00 PST 2010
// I added operatorCategory.
//
// ****************************************************************************
OperatorPluginManager::OperatorPluginManager() : PluginManager("operator")
OperatorPluginManager::OperatorPluginManager() : PluginManager("operator"),
operatorCategory()
{
}
......@@ -121,10 +124,38 @@ OperatorPluginManager::Initialize(const PluginCategory pluginCategory,
{
category = pluginCategory;
parallel = par;
operatorCategory.clear();
SetPluginDir(pluginDir);
ObtainPluginInfo(readInfo, broadcaster);
}
// ****************************************************************************
// Method: OperatorPluginManager::GetOperatorCategoryName
//
// Purpose:
// Return the category name of any operator plugin. This is the name of the
// group in which it wants to be grouped.
//
// Arguments:
// id : The all index id. This method provides data for plugins that were
// loaded as libI.
//
// Returns: The category.
//
// Programmer: Brad Whitlock
// Creation: Fri Feb 5 14:43:23 PST 2010
//
// Modifications:
//
// ****************************************************************************
std::string
OperatorPluginManager::GetOperatorCategoryName(const std::string &id) const
{
std::map<std::string, int>::const_iterator it = allindexmap.find(id);
return (it != allindexmap.end()) ? operatorCategory[it->second] : std::string("");
}
// ****************************************************************************
// Method: OperatorPluginManager::GetCommonPluginInfo
//
......@@ -248,6 +279,30 @@ OperatorPluginManager::GetScriptingPluginInfo(const string &id)
return scriptingPluginInfo[loadedindexmap[id]];
}
// ****************************************************************************
// Method: OperatorPluginManager::BroadcastGeneralInfo
//
// Purpose:
// This method broadcasts the general libI information to other processors
// using a PluginBroadcaster object.
//
// Arguments:
// broadcaster : The broadcaster to use.
//
// Programmer: Brad Whitlock
// Creation: Fri Feb 5 14:40:39 PST 2010
//
// Modifications:
//
// ****************************************************************************
void
OperatorPluginManager::BroadcastGeneralInfo(PluginBroadcaster *broadcaster)
{
PluginManager::BroadcastGeneralInfo(broadcaster);
broadcaster->BroadcastStringVector(operatorCategory);
}
// ****************************************************************************
// Method: OperatorPluginManager::LoadGeneralPluginInfo
//
......@@ -268,6 +323,9 @@ OperatorPluginManager::GetScriptingPluginInfo(const string &id)
// Hank Childs, Tue Mar 22 16:06:15 PST 2005
// Fix memory leak.
//
// Brad Whitlock, Fri Feb 5 14:41:14 PST 2010
// Added category.
//
// ****************************************************************************
bool
......@@ -303,6 +361,7 @@ OperatorPluginManager::LoadGeneralPluginInfo()
names .push_back(info->GetName());
versions.push_back(info->GetVersion());
enabled .push_back(info->EnabledByDefault());
operatorCategory.push_back(info->GetCategoryName());
delete info;
return true;
}
......@@ -551,12 +610,16 @@ OperatorPluginManager::FreeScriptingPluginInfo()
// Jeremy Meredith, Fri Feb 28 12:25:37 PST 2003
// Made it use LoadPluginsNow or LoadPluginsOnDemand as appropriate.
//
// Brad Whitlock, Fri Feb 5 15:04:46 PST 2010
// I added operatorCategories.
//
// ****************************************************************************
void
OperatorPluginManager::ReloadPlugins()
{
vector<void*> new_handles;
vector<string> new_operatorCategory;
vector<CommonOperatorPluginInfo*> new_commonPluginInfo;
vector<GUIOperatorPluginInfo*> new_guiPluginInfo;
vector<ViewerOperatorPluginInfo*> new_viewerPluginInfo;
......@@ -579,6 +642,7 @@ OperatorPluginManager::ReloadPlugins()
if (category == Scripting)
new_scriptingPluginInfo.push_back(scriptingPluginInfo[i]);
new_operatorCategory.push_back(operatorCategory[i]);
new_handles.push_back(loadedhandles[i]);
}
else
......@@ -597,6 +661,7 @@ OperatorPluginManager::ReloadPlugins()
PluginClose();
}
}
operatorCategory = new_operatorCategory;
commonPluginInfo = new_commonPluginInfo;
guiPluginInfo = new_guiPluginInfo;
viewerPluginInfo = new_viewerPluginInfo;
......
......@@ -105,6 +105,10 @@ class ScriptingOperatorPluginInfo;
// Brad Whitlock, Wed Jun 17 10:24:46 PDT 2009
// I added arguments to Initialize.
//
// Brad Whitlock, Fri Feb 5 14:44:32 PST 2010
// I added stuff to enable categories to be accessed for any plugin whose
// libI was loaded.
//
// ****************************************************************************
class PLUGIN_API OperatorPluginManager : public PluginManager
......@@ -121,6 +125,10 @@ class PLUGIN_API OperatorPluginManager : public PluginManager
virtual void ReloadPlugins();
// Methods that return info about all plugins
std::string GetOperatorCategoryName(const std::string &allid) const;
// Methods that return info about loaded plugins
CommonOperatorPluginInfo *GetCommonPluginInfo(const std::string&);
GUIOperatorPluginInfo *GetGUIPluginInfo(const std::string&);
ViewerOperatorPluginInfo *GetViewerPluginInfo(const std::string&);
......@@ -128,6 +136,8 @@ class PLUGIN_API OperatorPluginManager : public PluginManager
ScriptingOperatorPluginInfo *GetScriptingPluginInfo(const std::string&);
private:
virtual void BroadcastGeneralInfo(PluginBroadcaster *);
virtual bool LoadGeneralPluginInfo();
virtual void LoadGUIPluginInfo();
virtual void LoadViewerPluginInfo();
......@@ -140,6 +150,9 @@ class PLUGIN_API OperatorPluginManager : public PluginManager
virtual void FreeEnginePluginInfo();
virtual void FreeScriptingPluginInfo();
// arrays containing all plugins
std::vector<std::string> operatorCategory;
// arrays containing enabled plugins
std::vector<CommonOperatorPluginInfo*> commonPluginInfo;
std::vector<GUIOperatorPluginInfo*> guiPluginInfo;
......
This diff is collapsed.
Function: GetIndexByID
Declaration: int GetIndexByID(const std::string &s);
Code: SetFromNode
Prefix:
Postfix:
// Ensure that the category vector will be at least as long as the id vector.
// This is import for supporting legacy config files.
while(category.size() < id.size())
category.push_back("?");
Function: GetIndexByID
Declaration: int GetIndexByID(const std::string &s) const;
Definition:
// ****************************************************************************
// Method: PluginManagerAttributes::GetIndexByID
......@@ -13,7 +21,7 @@ Definition:
// ****************************************************************************
int
PluginManagerAttributes::GetIndexByID(const std::string &s)
PluginManagerAttributes::GetIndexByID(const std::string &s) const
{
for (size_t i=0; i<id.size(); i++)
{
......@@ -24,8 +32,7 @@ PluginManagerAttributes::GetIndexByID(const std::string &s)
return -1;
}
Function: AddPlugin
Function: AddPlugin
Declaration: void AddPlugin(const std::string &n,const std::string &t,const std::string &v,const std::string &i,bool e);
Definition:
// ****************************************************************************
......@@ -41,6 +48,9 @@ Definition:
// Jeremy Meredith, Wed Nov 5 12:51:11 PST 2003
// Added ability to disable plugins by default.
//
// Brad Whitlock, Thu Feb 4 15:26:46 PST 2010
// I added a category field.
//
// ****************************************************************************
void
......@@ -54,16 +64,16 @@ PluginManagerAttributes::AddPlugin(const std::string &n,
type.push_back(t);
version.push_back(v);
id.push_back(i);
category.push_back("?");
enabled.push_back(e);
SelectAll();
}
Function: RemovePlugin
Function: RemovePlugin
Declaration: void RemovePlugin(const std::string &s);
Definition:
// ****************************************************************************
// Method: PluginManagerAttributes::AddPlugin
// Method: PluginManagerAttributes::RemovePlugin
//
// Purpose:
// Add a new plugin.
......@@ -71,6 +81,10 @@ Definition:
// Programmer: Jeremy Meredith
// Creation: September 27, 2001
//
// Modifications:
// Brad Whitlock, Thu Feb 4 15:27:03 PST 2010
// I added a category.
//
// ****************************************************************************
void
......@@ -80,10 +94,121 @@ PluginManagerAttributes::RemovePlugin(const std::string &s)
if (index<0)
return;
name .erase(name .begin() + index);
type .erase(type .begin() + index);
version.erase(version.begin() + index);
id .erase(id .begin() + index);
enabled.erase(enabled.begin() + index);
name .erase(name .begin() + index);
type .erase(type .begin() + index);
version.erase(version .begin() + index);
id .erase(id .begin() + index);
category.erase(category.begin() + index);
enabled.erase(enabled .begin() + index);
SelectAll();
}
Function: UniqueCategories
Declaration: void UniqueCategories(const std::string &t, stringVector &c) const;
Definition:
// ****************************************************************************
// Method: PluginManagerAttributes::UniqueCategories
//
// Purpose:
// Get the list of unique category names for a given plugin type.
//
// Programmer: Brad Whitlock
// Creation: Thu Feb 4 15:31:40 PST 2010
//
// Modifications:
//
// ****************************************************************************
#include <algorithm>
void
PluginManagerAttributes::UniqueCategories(const std::string &t, stringVector &c) const
{
c.clear();
for(size_t i = 0; i < type.size(); ++i)
{
if(type[i] == t)
{
if(i < category.size() &&
category[i] != "?" &&
std::find(c.begin(), c.end(), category[i]) == c.end())
c.push_back(category[i]);
}
}
std::sort(c.begin(), c.end());
}
Function: GetPluginCategoryName
Declaration: std::string GetPluginCategoryName(const std::string &s) const;
Definition:
// ****************************************************************************
// Method: PluginManagerAttributes::GetPluginCategoryName
//
// Purpose:
// Get the category name for the specified plugin.
//
// Programmer: Brad Whitlock
// Creation: Thu Feb 4 15:31:40 PST 2010
//
// Modifications:
//
// ****************************************************************************
std::string
PluginManagerAttributes::GetPluginCategoryName(const std::string &s) const
{
std::string c("?");
int index = GetIndexByID(s);
if(index >= 0 && index < category.size())
{
c = category[index];
}
return c;
}
Function: SetPluginCategoryName
Declaration: void SetPluginCategoryName(const std::string &s, const std::string &c);
Definition:
// ****************************************************************************
// Method: PluginManagerAttributes::SetPluginCategoryName
//
// Purpose:
// Sets the category name for the specified plugin.
//
// Programmer: Brad Whitlock
// Creation: Thu Feb 4 15:31:40 PST 2010
//
// Modifications:
//
// ****************************************************************************
void
PluginManagerAttributes::SetPluginCategoryName(const std::string &s, const std::string &c)
{
int index = GetIndexByID(s);
if(index >= 0 && index < category.size())
{
category[index] = c;
SelectCategory();
}
}
Function: PluginCategoryNameNotSet
Declaration: bool PluginCategoryNameNotSet(const std::string &s) const;
Definition:
// ****************************************************************************
// Method: PluginManagerAttributes::PluginCategoryNameNotSet
//
// Purpose:
// Returns whether the category name has been set.
//
// Programmer: Brad Whitlock
// Creation: Thu Feb 4 15:31:40 PST 2010
//
// Modifications:
//
// ****************************************************************************
bool
PluginManagerAttributes::PluginCategoryNameNotSet(const std::string &s) const
{
return GetPluginCategoryName(s) == "?";
}
......@@ -42,6 +42,7 @@
#include <string>
#include <AttributeSubject.h>
// ****************************************************************************
// Class: PluginManagerAttributes
//
......@@ -60,13 +61,23 @@
class STATE_API PluginManagerAttributes : public AttributeSubject
{
public:
// These constructors are for objects of this class
PluginManagerAttributes();
PluginManagerAttributes(const PluginManagerAttributes &obj);
protected:
// These constructors are for objects derived from this class
PluginManagerAttributes(private_tmfs_t tmfs);
PluginManagerAttributes(const PluginManagerAttributes &obj, private_tmfs_t tmfs);
public:
virtual ~PluginManagerAttributes();
virtual PluginManagerAttributes& operator = (const PluginManagerAttributes &obj);
virtual bool operator == (const PluginManagerAttributes &obj) const;
virtual bool operator != (const PluginManagerAttributes &obj) const;
private:
void Init();
void Copy(const PluginManagerAttributes &obj);
public:
virtual const std::string TypeName() const;
virtual bool CopyAttributes(const AttributeGroup *);
......@@ -79,6 +90,7 @@ public:
void SelectType();
void SelectVersion();
void SelectId();
void SelectCategory();
void SelectEnabled();
// Property setting methods
......@@ -86,6 +98,7 @@ public:
void SetType(const stringVector &type_);
void SetVersion(const stringVector &version_);
void SetId(const stringVector &id_);
void SetCategory(const stringVector &category_);
void SetEnabled(const intVector &enabled_);
// Property getting methods
......@@ -97,6 +110,8 @@ public:
stringVector &GetVersion();
const stringVector &GetId() const;
stringVector &GetId();
const stringVector &GetCategory() const;
stringVector &GetCategory();
const intVector &GetEnabled() const;
intVector &GetEnabled();
......@@ -112,9 +127,13 @@ public:
virtual bool FieldsEqual(int index, const AttributeGroup *rhs) const;
// User-defined methods
int GetIndexByID(const std::string &s);
int GetIndexByID(const std::string &s) const;
void AddPlugin(const std::string &n,const std::string &t,const std::string &v,const std::string &i,bool e);
void RemovePlugin(const std::string &s);
void UniqueCategories(const std::string &t, stringVector &c) const;
std::string GetPluginCategoryName(const std::string &s) const;
void SetPluginCategoryName(const std::string &s, const std::string &c);
bool PluginCategoryNameNotSet(const std::string &s) const;
// IDs that can be used to identify fields in case statements
enum {
......@@ -122,7 +141,9 @@ public:
ID_type,
ID_version,
ID_id,
ID_enabled
ID_category,
ID_enabled,
ID__LAST
};
private:
......@@ -130,10 +151,13 @@ private:
stringVector type;
stringVector version;
stringVector id;
stringVector category;
intVector enabled;
// Static class format string for type map.
static const char *TypeMapFormatString;
static const private_tmfs_t TmfsStruct;
};
#define PLUGINMANAGERATTRIBUTES_TMFS "s*s*s*s*s*i*"
#endif
<?xml version="1.0"?>
<Attribute name="PluginManagerAttributes" codefile="PluginManagerAttributes.code" purpose="This class contains attributes for managing plugins." exportAPI="STATE_API" exportInclude="state_exports.h">
<Field name="name" type="stringVector"></Field>
<Field name="type" type="stringVector"></Field>
<Field name="version" type="stringVector"></Field>
<Field name="id" type="stringVector"></Field>
<Field name="enabled" type="intVector"></Field>
<Function name="GetIndexByID" user="true"></Function>
<Function name="AddPlugin" user="true"></Function>
<Function name="RemovePlugin" user="true"></Function>
<Attribute name="PluginManagerAttributes" purpose="This class contains attributes for managing plugins." persistent="true" keyframe="true" exportAPI="STATE_API" exportInclude="state_exports.h" codefile="PluginManagerAttributes.code">
<Field name="name" label="name" type="stringVector">
</Field>
<Field name="type" label="type" type="stringVector">
</Field>
<Field name="version" label="version" type="stringVector">
</Field>
<Field name="id" label="id" type="stringVector">
</Field>
<Field name="category" label="category" type="stringVector">
</Field>
<Field name="enabled" label="enabled" type="intVector">
</Field>
<Function name="GetIndexByID" user="true" member="true">
</Function>
<Function name="AddPlugin" user="true" member="true">
</Function>
<Function name="RemovePlugin" user="true" member="true">
</Function>
<Function name="UniqueCategories" user="true" member="true">
</Function>
<Function name="GetPluginCategoryName" user="true" member="true">
</Function>
<Function name="SetPluginCategoryName" user="true" member="true">
</Function>
<Function name="PluginCategoryNameNotSet" user="true" member="true">
</Function>
</Attribute>
......@@ -86,7 +86,7 @@ VISIT_OPTION_DEFAULT(VISIT_H5PART_DIR ${VISITHOME}/h5part/1.4.2/${VISITARCH})
##
## HDF5
##
VISIT_OPTION_DEFAULT(VISIT_HDF5_DIR ${VISITHOME}/hdf5/1.8.2/${VISITARCH})
VISIT_OPTION_DEFAULT(VISIT_HDF5_DIR ${VISITHOME}/hdf5/1.8.4/${VISITARCH})
VISIT_OPTION_DEFAULT(VISIT_HDF5_LIBDEP ${VISITHOME}/szip/2.1/${VISITARCH}/lib sz)
##
......@@ -112,6 +112,6 @@ VISIT_OPTION_DEFAULT(VISIT_CCMIO_DIR ${VISITHOME}/ccmio/2.6.1/${VISITARCH})
##
## Silo
##
VISIT_OPTION_DEFAULT(VISIT_SILO_DIR ${VISITHOME}/silo/4.7/${VISITARCH})
VISIT_OPTION_DEFAULT(VISIT_SILO_DIR ${VISITHOME}/silo/4.7.2/${VISITARCH})
VISIT_OPTION_DEFAULT(VISIT_SILO_LIBDEP HDF5_LIBRARY_DIR hdf5 ${VISIT_HDF5_LIBDEP})
......@@ -129,6 +129,7 @@ QvisPickWindow.C
QvisPlotListBox.C
QvisPlotListBoxItem.C
QvisPlotManagerWidget.C
QvisPluginManagerAttributesDataModel.C
QvisPluginWindow.C
QvisPointControl.C
QvisPostableMainWindow.C
......@@ -242,6 +243,7 @@ QvisOutputWindow.h
QvisPeriodicTableWidget.h
QvisPickWindow.h
QvisPlotListBox.h
QvisPluginManagerAttributesDataModel.h
QvisPointControl.h
QvisPlotManagerWidget.h
QvisPluginWindow.h
......
......@@ -91,6 +91,7 @@
#include <QueryAttributes.h>
#include <PlotList.h>
#include <Plot.h>
#include <PluginManagerAttributes.h>
#include <PrinterAttributes.h>
#include <RenderingAttributes.h>
#include <SILRestrictionAttributes.h>
......@@ -3659,6 +3660,9 @@ QvisGUIApplication::LoadPlugins()
// Brad Whitlock, Tue Jun 24 11:44:57 PDT 2008
// Get the plugin managers from the viewer proxy.
//
// Brad Whitlock, Fri Feb 5 16:36:12 PST 2010
// Pass plugin ids to the plot manager.
//
// ****************************************************************************
void
......@@ -3673,8 +3677,8 @@ QvisGUIApplication::CreatePluginWindows()
for(i = 0; i < plotPluginManager->GetNEnabledPlugins(); ++i)
{
// Get a pointer to the GUI portion of the plot plugin information.
GUIPlotPluginInfo *GUIInfo = plotPluginManager->GetGUIPluginInfo(
plotPluginManager->GetEnabledID(i));
std::string id(plotPluginManager->GetEnabledID(i));
GUIPlotPluginInfo *GUIInfo = plotPluginManager->GetGUIPluginInfo(id);
// Add a NULL window to the list of plot windows. We'll create the
// plugin window later when we need it.
......@@ -3688,7 +3692,7 @@ QvisGUIApplication::CreatePluginWindows()
// Add an option to the main window's plot manager widget's plot list.
QString *menuName = GUIInfo->GetMenuName();
mainWin->GetPlotManager()->AddPlotType(*menuName,
mainWin->GetPlotManager()->AddPlotType(QString(id.c_str()), *menuName,
GUIInfo->GetVariableTypes(),
GUIInfo->XPMIconData());
delete menuName;
......@@ -3701,8 +3705,8 @@ QvisGUIApplication::CreatePluginWindows()
for(i = 0; i < operatorPluginManager->GetNEnabledPlugins(); ++i)
{
// Get a pointer to the GUI portion of the operator plugin information.
GUIOperatorPluginInfo *GUIInfo = operatorPluginManager->GetGUIPluginInfo(
operatorPluginManager->GetEnabledID(i));
std::string id(operatorPluginManager->GetEnabledID(i));
GUIOperatorPluginInfo *GUIInfo = operatorPluginManager->GetGUIPluginInfo(id);
// Add a NULL window to the list of operator windows. We'll create the
// plugin window later when we need it.
......@@ -3711,12 +3715,38 @@ QvisGUIApplication::CreatePluginWindows()
// Add an option to the main window's operator manager widget's
// operator list.
QString *menuName = GUIInfo->GetMenuName();
mainWin->GetPlotManager()->AddOperatorType(*menuName,
mainWin->GetPlotManager()->AddOperatorType(QString(id.c_str()),
*menuName,
GUIInfo->GetVariableTypes(), GUIInfo->GetVariableMask(),
GUIInfo->GetUserSelectable(), GUIInfo->XPMIconData());
delete menuName;
}
mainWin->GetPlotManager()->FinishAddingOperators();
QTimer::singleShot(10, this, SLOT(EnableOperatorMenuGrouping()));
}
// ****************************************************************************
// Method: QvisGUIApplication::EnableOperatorMenuGrouping
//
// Purpose:
// This method must be called from the main event loop and not from an
// update of the plugin manager attributes.
//
// Programmer: Brad Whitlock
// Creation: Mon Feb 8 14:38:02 PST 2010
//
// Modifications:
//
// ****************************************************************************
void
QvisGUIApplication::EnableOperatorMenuGrouping()
{
// Make subsequent changes to the plugin manager attributes cause the
// plot manager's operator menus to update.
mainWin->GetPlotManager()->ConnectPluginManagerAttributes(GetViewerState()->
GetPluginManagerAttributes());
mainWin->GetPlotManager()->UpdateOperatorCategories();
}
// ****************************************************************************
......
......@@ -422,6 +422,7 @@ private slots:
void AboutVisIt();
void CustomizeAppearance(bool notify);
void LoadPlugins();
void EnableOperatorMenuGrouping();
void FinalInitialization();
void SendInterface();
void InterpreterSync();
......
......@@ -120,6 +120,9 @@ public:
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const
{
if(!index.isValid())
return;
QLineEdit *lineEdit = (QLineEdit *)editor;
lineEdit->setText(index.data().toString());
lineEdit->selectAll();
......@@ -127,6 +130,9 @@ public:
virtual