Commit 33cc5137 authored by hrchilds's avatar hrchilds
Browse files

Update from April 6, 2004

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@214 18c085ea-50e0-402c-830e-de6fd14e8384
parent 479213b4
......@@ -11,6 +11,9 @@
#include <string>
using std::string;
#include <vector>
using std::vector;
#if defined(_WIN32)
#include <windows.h>
#else
......@@ -558,3 +561,43 @@ NumericStringCompare(const std::string &str1, const std::string &str2)
else
return true;
}
// ****************************************************************************
// Function: SplitValues
//
// Purpose:
// Separate a string into a vector of strings using a single char delimiter.
//
// Arguments:
// buff the string to split
// delim the single-character delimiter
//
// Programmer: Jeremy Meredith
// Creation: March 23, 2004
//
// ****************************************************************************
vector<string>
SplitValues(const string &buff, char delim)
{
vector<string> output;
string tmp="";
for (int i=0; i<buff.length(); i++)
{
if (buff[i] == delim)
{
if (!tmp.empty())
output.push_back(tmp);
tmp = "";
}
else
{
tmp += buff[i];
}
}
if (!tmp.empty())
output.push_back(tmp);
return output;
}
......@@ -6,6 +6,7 @@
#define UTILITY_H
#include <utility_exports.h>
#include <string>
#include <vector>
//
// Type definitions
......@@ -28,6 +29,9 @@ bool UTILITY_API WildcardStringMatch(const char *p, const char *s);
bool UTILITY_API WildcardStringMatch(const std::string &p, const std::string &s);
bool UTILITY_API NumericStringCompare(const std::string &str1, const std::string &str2);
std::vector<std::string> UTILITY_API SplitValues(const string &buff,
char delim);
inline char *C_strdup(char const * const);
inline char *CXX_strdup(char const * const);
inline void InlineCopy(char *&, const char * const &, const int &);
......
#include <NameSimplifier.h>
#include <maptypes.h>
#include <Utility.h>
using std::string;
using std::vector;
// ****************************************************************************
// Method: NameSimplifier::NameSimplifier
......@@ -48,19 +52,27 @@ NameSimplifier::~NameSimplifier()
// Creation: Wed Feb 4 13:47:12 PST 2004
//
// Modifications:
//
// Jeremy Meredith, Tue Apr 6 12:19:51 PDT 2004
// Made use of the UniqueFileName construct here.
//
// ****************************************************************************
void
NameSimplifier::AddName(const std::string &n)
{
names.push_back(QualifiedFilename(n));
AddName(QualifiedFilename(n));
}
void
NameSimplifier::AddName(const QualifiedFilename &n)
{
names.push_back(n);
int newindex = names.size();
names.push_back(UniqueFileName(n));
for (int j=0; j<newindex; j++)
{
UniqueFileName::Uniquify(names[newindex],names[j]);
}
}
// ****************************************************************************
......@@ -82,23 +94,171 @@ NameSimplifier::ClearNames()
names.clear();
}
// ****************************************************************************
// Constructor: NameSimplifier::UniqueFileName::UniqueFileName
//
// Arguments:
// qfn a QualifiedFilename to convert
//
// Programmer: Jeremy Meredith
// Creation: April 6, 2004
//
// ****************************************************************************
NameSimplifier::UniqueFileName::UniqueFileName(const QualifiedFilename &qfn)
{
useHost = false;
pathCount = 0;
host = qfn.host;
file = qfn.filename;
separator = qfn.separator;
path = SplitValues(qfn.path, separator);
pathLen = path.size();
}
// ****************************************************************************
// Method: NameSimplifier::UniqueFileName::GetAsString
//
// Purpose:
// Convert into a single string
//
// Arguments:
// none
//
// Programmer: Jeremy Meredith
// Creation: April 6, 2004
//
// ****************************************************************************
string
NameSimplifier::UniqueFileName::GetAsString() const
{
string out;
if (useHost)
out += host + ":";
if (pathCount == pathLen)
out += separator;
for (int i=0; i<pathCount; i++)
out += path[pathLen-pathCount + i] + separator;
out += file;
return out;
}
// ****************************************************************************
// Method: NameSimplifier::UniqueFileName::Unique
//
// Purpose:
// Returns true if we can consider the representations of two
// file names unique.
//
// Arguments:
// a,b the UniqueFileNames to test
//
// Note: This is definitely not an exact equality test.
//
// Programmer: Jeremy Meredith
// Creation: April 6, 2004
//
// ****************************************************************************
bool
NameSimplifier::UniqueFileName::Unique(const UniqueFileName &a,
const UniqueFileName &b)
{
string as = a.GetAsString();
string bs = b.GetAsString();
int al = as.length();
int bl = bs.length();
// Ensure that a string does not exactly match
// the ending piece of the other one
if (as == bs)
return false;
else if ((al < bl) && (as == bs.substr(bl - al)))
return false;
else if ((bl < al) && (bs == as.substr(al - bl)))
return false;
else
return true;
}
// ****************************************************************************
// Method: NameSimplifier::UniqueFileName::Uniquify
//
// Purpose:
// Make two file names unique
//
// Arguments:
// a,b the file names to make unique
//
// Programmer: Jeremy Meredith
// Creation: April 6, 2004
//
// ****************************************************************************
void
NameSimplifier::UniqueFileName::Uniquify(UniqueFileName &a, UniqueFileName &b)
{
// Filenames are often unique already
if (Unique(a, b))
return;
// If we can make them unique by simply adding a host prefix, do it
if (a.host != b.host)
{
a.useHost = true;
b.useHost = true;
// They should now be unique since our host name is prepended.
// Test again for sanity, and return now that they are unique.
if (Unique(a, b))
return;
}
// If two filenames are the same on the same host, we need at
// least one path prefix for both
if (a.pathCount == 0 && b.pathCount != 0 && a.pathLen > 0)
a.pathCount++;
if (b.pathCount == 0 && a.pathCount != 0 && b.pathLen > 0)
b.pathCount++;
// Start adding more path prefix segments as needed
while (!Unique(a,b) &&
(a.pathCount < a.pathLen || b.pathCount < b.pathLen))
{
// Add to the shorter one, or add to both if they are equal
if (a.pathCount < b.pathCount && a.pathCount < a.pathLen)
a.pathCount++;
else if (b.pathCount < a.pathCount && b.pathCount < b.pathLen)
b.pathCount++;
else
{
if (a.pathCount < a.pathLen)
a.pathCount++;
if (b.pathCount < b.pathLen)
b.pathCount++;
}
}
}
// ****************************************************************************
// Method: NameSimplifier::GetSimplifiedNames
//
// Purpose:
// Returns a stringVector of simplified names.
// Uniqueness is now guaranteed as names are added.
//
// Arguments:
// n : The return string vector.
//
// Returns:
//
// Note: This method will still give files that have the entire host
// qualified path. It would be nice if the path was also
// simplified instead of giving up and using the whole filename.
//
// Programmer: Brad Whitlock
// Creation: Wed Feb 4 13:48:00 PST 2004
// Programmer: Jeremy Meredith
// Creation: April 6, 2004
//
// Modifications:
//
......@@ -109,33 +269,8 @@ NameSimplifier::GetSimplifiedNames(stringVector &n) const
{
n.clear();
StringIntMap fileCount, hostCount;
int i;
for(i = 0; i < names.size(); ++i)
{
++fileCount[names[i].filename];
++hostCount[names[i].host];
}
bool needHosts = (hostCount.size() > 1);
for(i = 0; i < names.size(); ++i)
for (int i=0; i<names.size(); i++)
{
if(fileCount[names[i].filename] > 1)
{
if(needHosts)
{
n.push_back(names[i].FullName());
}
else
n.push_back(names[i].PathAndFile());
}
else if(needHosts)
{
n.push_back(names[i].host + ":" + names[i].filename);
}
else
n.push_back(names[i].filename);
n.push_back(names[i].GetAsString());
}
}
......@@ -17,12 +17,40 @@
// Creation: Wed Feb 4 14:22:58 PST 2004
//
// Modifications:
//
// Jeremy Meredith, Tue Apr 6 14:16:54 PDT 2004
// Keep track of the filenames in a way made for adding the minimal amount
// of text needed for ensuring they are unique. Added UniqueFileName.
//
// ****************************************************************************
class GUI_API NameSimplifier
{
public:
private:
// Class: UniqueFileName
//
// Purpose:
// Structure to add a minimal amount of path/host information
// to a filename to ensure it is unique w.r.t. other filenames
class UniqueFileName
{
public:
UniqueFileName(const QualifiedFilename &qfn);
string GetAsString() const;
static bool Unique(const UniqueFileName &a, const UniqueFileName &b);
static void Uniquify(UniqueFileName &a, UniqueFileName &b);
private:
string host; // host name
stringVector path; // path components, split by separator
int pathLen; // length of the 'path' vector
string file; // raw file name without path
char separator; // separator character
bool useHost; // true if we need the host for uniqueness
int pathCount; // number of needed path segment prefixes
};
public:
NameSimplifier();
~NameSimplifier();
......@@ -31,7 +59,7 @@ public:
void ClearNames();
void GetSimplifiedNames(stringVector &n) const;
private:
QualifiedFilenameVector names;
std::vector<UniqueFileName> names;
};
#endif
......@@ -195,6 +195,10 @@
// Kathleen Bonnell, Wed Mar 31 10:13:43 PST 2004
// I added query over time window.
//
// Brad Whitlock, Mon Apr 5 15:28:04 PST 2004
// I added support for putting reopen and close in an "Advanced"
// pullright menu.
//
// ****************************************************************************
QvisMainWindow::QvisMainWindow(int orientation, const char *captionString)
......@@ -253,19 +257,24 @@ QvisMainWindow::QvisMainWindow(int orientation, const char *captionString)
menuBar()->insertItem( tr("&File"), filePopup );
filePopup->insertItem(openIcon, tr("Select &file . . ."), this, SIGNAL(activateFileWindow()), CTRL+Key_F );
// Advanced pull-right menu.
fileAdvancedPopup = new QPopupMenu(filePopup, "fileAdvancedPopup");
fileAdvancedPopupId = filePopup->insertItem(tr("Advanced file options"), fileAdvancedPopup);
advancedMenuShowing = true;
// ReOpen pull-right menu.
reopenPopup = new QPopupMenu(filePopup, "reopenPopup");
reopenPopup = new QPopupMenu(fileAdvancedPopup, "reopenPopup");
connect(reopenPopup, SIGNAL(activated(int)),
this, SLOT(reopenFile(int)));
reopenPopupId = filePopup->insertItem(tr("ReOpen file"), reopenPopup);
filePopup->setItemEnabled(reopenPopupId, false);
reopenPopupId = fileAdvancedPopup->insertItem(tr("ReOpen file"), reopenPopup);
fileAdvancedPopup->setItemEnabled(reopenPopupId, false);
// Close pull-right menu
closePopup = new QPopupMenu(filePopup, "closePopup");
closePopup = new QPopupMenu(fileAdvancedPopup, "closePopup");
connect(closePopup, SIGNAL(activated(int)),
this, SLOT(closeFile(int)));
closePopupId = filePopup->insertItem(tr("Close file"), closePopup);
filePopup->setItemEnabled(closePopupId, false);
closePopupId = fileAdvancedPopup->insertItem(tr("Close file"), closePopup);
fileAdvancedPopup->setItemEnabled(closePopupId, false);
filePopup->insertItem( tr("Refresh file list"), this, SIGNAL(refreshFileList()), CTRL+Key_R);
filePopup->insertItem( tr("File &information . . ."), this, SIGNAL(activateFileInformationWindow()), CTRL+Key_I);
......@@ -825,6 +834,9 @@ QvisMainWindow::Update(Subject *TheChangedSubject)
// I updated the code due to changes in GlobalAttributes. I also added code
// to set the contents of the source list.
//
// Brad Whitlock, Mon Apr 5 16:19:18 PST 2004
// Renamed a method.
//
// ****************************************************************************
void
......@@ -844,8 +856,8 @@ QvisMainWindow::UpdateGlobalArea(bool doAll)
switch(i)
{
case 0: // sources
UpdateFileMenu(reopenPopup, reopenPopupId);
UpdateFileMenu(closePopup, closePopupId);
UpdateFileMenuPopup(reopenPopup, reopenPopupId);
UpdateFileMenuPopup(closePopup, closePopupId);
break;
case 1: // windows
UpdateWindowList(true);
......@@ -900,7 +912,7 @@ QvisMainWindow::UpdateGlobalArea(bool doAll)
}
// ****************************************************************************
// Method: QvisMainWindow::UpdateFileMenu
// Method: QvisMainWindow::UpdateFileMenuPopup
//
// Purpose:
// Updates the contents of the specified file menu.
......@@ -913,11 +925,13 @@ QvisMainWindow::UpdateGlobalArea(bool doAll)
// Creation: Fri Feb 27 10:49:30 PDT 2004
//
// Modifications:
//
// Brad Whitlock, Mon Apr 5 15:33:39 PST 2004
// I renamed the method.
//
// ****************************************************************************
void
QvisMainWindow::UpdateFileMenu(QPopupMenu *m, int menuId)
QvisMainWindow::UpdateFileMenuPopup(QPopupMenu *m, int menuId)
{
stringVector simpleNames;
const stringVector &sources = globalAtts->GetSources();
......@@ -938,8 +952,12 @@ QvisMainWindow::UpdateFileMenu(QPopupMenu *m, int menuId)
// Set the menu's enabled state.
//
bool menuEnabled = (m->count() > 0);
if(filePopup->isItemEnabled(menuId) != menuEnabled)
filePopup->setItemEnabled(menuId, menuEnabled);
if(m->parent()->inherits("QPopupMenu"))
{
QPopupMenu *p = (QPopupMenu *)m->parent();
if(p->isItemEnabled(menuId) != menuEnabled)
p->setItemEnabled(menuId, menuEnabled);
}
}
// ****************************************************************************
......@@ -1660,7 +1678,10 @@ QvisMainWindow::GetTimeStateFormat() const
// Creation: Fri Jan 30 14:36:47 PST 2004
//
// Modifications:
//
// Brad Whitlock, Mon Apr 5 15:50:24 PST 2004
// Added support for menus that hide depending on if the selected files
// are showing.
//
// ****************************************************************************
void
......@@ -1668,6 +1689,71 @@ QvisMainWindow::SetShowSelectedFiles(bool val)
{
filePanel->SetShowSelectedFiles(val);
plotManager->SetSourceVisible(!val);
if(val)
{
if(!advancedMenuShowing)
{
// Show selected files. Put reopen, close in an advanced menu.
filePopup->removeItem(reopenPopupId);
filePopup->removeItem(closePopupId);
fileAdvancedPopup = new QPopupMenu(filePopup, "fileAdvancedPopup");
fileAdvancedPopupId = filePopup->insertItem(tr("Advanced file options"),
fileAdvancedPopup, -1, 1);
// ReOpen pull-right menu.
reopenPopup = new QPopupMenu(fileAdvancedPopup, "reopenPopup");
connect(reopenPopup, SIGNAL(activated(int)),
this, SLOT(reopenFile(int)));
reopenPopupId = fileAdvancedPopup->insertItem(tr("ReOpen file"), reopenPopup);
fileAdvancedPopup->setItemEnabled(reopenPopupId, false);
// Close pull-right menu
closePopup = new QPopupMenu(fileAdvancedPopup, "closePopup");
connect(closePopup, SIGNAL(activated(int)),
this, SLOT(closeFile(int)));
closePopupId = fileAdvancedPopup->insertItem(tr("Close file"), closePopup);
fileAdvancedPopup->setItemEnabled(closePopupId, false);
advancedMenuShowing = true;
//
// Update the new visible menus with the active sources.
//
UpdateFileMenuPopup(reopenPopup, reopenPopupId);
UpdateFileMenuPopup(closePopup, closePopupId);
}
}
else
{
if(advancedMenuShowing)
{
// No selected files. Put reopen and close in the file menu.
filePopup->removeItem(fileAdvancedPopupId);
fileAdvancedPopupId = -1;
// ReOpen pull-right menu.
reopenPopup = new QPopupMenu(filePopup, "reopenPopup");
connect(reopenPopup, SIGNAL(activated(int)),
this, SLOT(reopenFile(int)));
reopenPopupId = filePopup->insertItem(tr("ReOpen file"), reopenPopup, -1, 1);
filePopup->setItemEnabled(reopenPopupId, false);
// Close pull-right menu
closePopup = new QPopupMenu(filePopup, "closePopup");
connect(closePopup, SIGNAL(activated(int)),
this, SLOT(closeFile(int)));
closePopupId = filePopup->insertItem(tr("Close file"), closePopup, -1, 2);
filePopup->setItemEnabled(closePopupId, false);
advancedMenuShowing = false;
//
// Update the new visible menus with the active sources.
//
UpdateFileMenuPopup(reopenPopup, reopenPopupId);
UpdateFileMenuPopup(closePopup, closePopupId);
}
}
}
// ****************************************************************************
......
......@@ -109,7 +109,10 @@ class WindowInformation;
// should be shown.
//
// Kathleen Bonnell, Wed Mar 31 10:13:43 PST 2004
// Added method to activate queryOverTime widnow.
// Added method to activate queryOverTime window.
//
// Brad Whitlock, Mon Apr 5 15:20:29 PST 2004
// Added support for reopen and close coming up under an advanced menu.
//
// ****************************************************************************
......@@ -231,7 +234,7 @@ private slots:
void lockView();
private:
void CreateGlobalArea(QLayout *tl);
void UpdateFileMenu(QPopupMenu *, int);
void UpdateFileMenuPopup(QPopupMenu *, int);
void UpdateGlobalArea(bool doAll);
void UpdateWindowList(bool doList);
void UpdateWindowMenu(bool updateWindowNums);
......@@ -253,10 +256,13 @@ private:
QCheckBox *autoUpdateCheckBox;
QPopupMenu *filePopup;
QPopupMenu *fileAdvancedPopup;
int fileAdvancedPopupId;
QPopupMenu *reopenPopup;
int reopenPopupId;
QPopupMenu *closePopup;
int closePopupId;
bool advancedMenuShowing;
QPopupMenu *winPopup;
QPopupMenu *layoutPopup;
......
......@@ -813,6 +813,10 @@ ViewerPlot::GetMetaData() const
// Brad Whitlock, Fri Mar 26 08:14:28 PDT 2004
// I made it use ViewerPlot::GetMetaData and strings.
//
// Hank Childs, Mon Apr 5 20:41:54 PDT 2004
// If you are changing the SIL, make a copy, because you might be changing
// a SIL that is referenced elsewhere. ['4716]
//
// ****************************************************************************
bool
......@@ -864,15 +868,18 @@ ViewerPlot::SetVariableName(const std::string &name)
// old variable. Set the top set in the SIL restriction.
//
avtSILSet_p current = silr->GetSILSet(silr->GetTopSet());
if(meshName != current->GetName())
if (meshName != current->GetName())
{
avtSILRestriction_p new_sil =
new avtSILRestriction(silr);
int topSet = 0;
for(int i = 0; i < silr->GetWholes().size(); ++i)
for (int i = 0; i < new_sil->GetWholes().size(); i++)
{
current = silr->GetSILSet(silr->GetWholes()[i]);
current =
new_sil->GetSILSet(new_sil->GetWholes()[i]);
if(meshName == current->GetName())
{
topSet = silr->GetWholes()[i];
topSet = new_sil->GetWholes()[i];
break;
}
}
......@@ -882,9 +889,10 @@ ViewerPlot::SetVariableName(const std::string &name)