Commit 3d146e22 authored by hrchilds's avatar hrchilds
Browse files

Update from November 3, 2003

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@110 18c085ea-50e0-402c-830e-de6fd14e8384
parent 356206b7
......@@ -55,6 +55,9 @@
// Allow derived types to specify how many components there are in the
// output.
//
// Hank Childs, Mon Nov 3 16:02:21 PST 2003
// Make use of virtual function CreateArray to create VTK arrays.
//
// ****************************************************************************
vtkDataArray *
......@@ -160,7 +163,7 @@ avtUnaryMathFilter::DeriveVariable(vtkDataSet *in_ds)
int ncomps = data->GetNumberOfComponents();
int nvals = data->GetNumberOfTuples();
vtkDataArray *dv = data->NewInstance();
vtkDataArray *dv = CreateArray(data);
int noutcomps = GetNumberOfComponentsInOutput(ncomps);
dv->SetNumberOfComponents(noutcomps);
dv->SetNumberOfTuples(nvals);
......
......@@ -3,8 +3,12 @@
// ************************************************************************* //
#include <avtConstantCreatorFilter.h>
#include <vtkDataArray.h>
#include <vtkDataSet.h>
#include <vtkFloatArray.h>
#include <vtkUnsignedCharArray.h>
// ****************************************************************************
// Method: avtConstantCreatorFilter::DoOperation
......@@ -33,3 +37,33 @@ avtConstantCreatorFilter::DoOperation(vtkDataArray *, vtkDataArray *out,
for (int i = 0 ; i < ntuples ; i++)
out->SetTuple1(i, value);
}
// ****************************************************************************
// Method: avtConstantCreatorFilter::CreateArray
//
// Purpose:
// Creates an array of constant value. Note that this routine will not
// return uchar arrays. The motivation for this is that most uchar arrays
// come from the conditional expression (if), which uses a uchar as the
// conditional, but really wants floats as the then- and else- variables.
// (ie if(gt(X, 2.), 1., 0.) -- the constant 1. should be a float
// (or whatever X is, not a uchar).
//
// Programmer: Hank Childs
// Creation: November 3, 2003
//
// ****************************************************************************
vtkDataArray *
avtConstantCreatorFilter::CreateArray(vtkDataArray *in)
{
if (in->GetDataType() == VTK_UNSIGNED_CHAR)
{
return vtkFloatArray::New();
}
return in->NewInstance();
}
......@@ -16,6 +16,11 @@
// Programmer: Sean Ahern
// Creation: Fri Feb 21 23:28:13 America/Los_Angeles 2003
//
// Modifications:
//
// Hank Childs, Mon Nov 3 15:15:47 PST 2003
// Override base class' definition of CreateArray.
//
// ****************************************************************************
class EXPRESSION_API avtConstantCreatorFilter : public avtUnaryMathFilter
......@@ -25,13 +30,16 @@ class EXPRESSION_API avtConstantCreatorFilter : public avtUnaryMathFilter
virtual ~avtConstantCreatorFilter() {;}
void SetValue(double v) {value = v;}
virtual const char * GetType(void) { return "avtConstantCreatorFilter"; }
virtual const char * GetDescription(void) { return "Generating constant"; }
virtual const char * GetType(void)
{ return "avtConstantCreatorFilter"; }
virtual const char * GetDescription(void)
{ return "Generating constant"; }
protected:
virtual void DoOperation(vtkDataArray *in, vtkDataArray *out,
int ncomponents, int ntuples);
virtual int GetNumberOfComponentsInOutput(int) { return 1; };
virtual vtkDataArray *CreateArray(vtkDataArray *);
double value;
};
......
......@@ -674,12 +674,18 @@ avtFilter::TrySpatialExtents(double *outexts)
// Programmer: Hank Childs
// Creation: September 4, 2001
//
// Modifications:
//
// Hank Childs, Mon Nov 3 09:49:11 PST 2003
// Setting the extents with the output is a mistake -- the filter may even
// modify those extents. They should be set with the input.
//
// ****************************************************************************
void
avtFilter::GetSpatialExtents(double *outexts)
avtFilter::GetSpatialExtents(double *newexts)
{
if (TrySpatialExtents(outexts))
if (TrySpatialExtents(newexts))
{
//
// We had them lying around -- no parallel communication necessary.
......@@ -688,16 +694,15 @@ avtFilter::GetSpatialExtents(double *outexts)
}
avtDataAttributes &atts = GetInput()->GetInfo().GetAttributes();
atts.GetCumulativeTrueSpatialExtents()->CopyTo(outexts);
atts.GetCumulativeTrueSpatialExtents()->CopyTo(newexts);
UnifyMinMax(outexts, atts.GetSpatialDimension()*2);
UnifyMinMax(newexts, atts.GetSpatialDimension()*2);
//
// We now have determined the true spatial extents, so we may as well set
// them back.
//
GetOutput()->GetInfo().GetAttributes().GetTrueSpatialExtents()
->Set(outexts);
atts.GetTrueSpatialExtents()->Set(newexts);
}
......@@ -747,12 +752,18 @@ avtFilter::TryCurrentDataExtents(double *outexts)
// Programmer: Kathleen Bonnell
// Creation: October 2, 2001
//
// Modifications:
//
// Hank Childs, Mon Nov 3 09:49:11 PST 2003
// Setting the extents with the output is a mistake -- the filter may even
// modify those extents. They should be set with the input.
//
// ****************************************************************************
void
avtFilter::GetCurrentDataExtents(double *outexts)
avtFilter::GetCurrentDataExtents(double *newexts)
{
if (TryCurrentDataExtents(outexts))
if (TryCurrentDataExtents(newexts))
{
//
// We had them lying around -- no parallel communication necessary.
......@@ -761,16 +772,15 @@ avtFilter::GetCurrentDataExtents(double *outexts)
}
avtDataAttributes &atts = GetInput()->GetInfo().GetAttributes();
atts.GetCumulativeCurrentDataExtents()->CopyTo(outexts);
atts.GetCumulativeCurrentDataExtents()->CopyTo(newexts);
UnifyMinMax(outexts, atts.GetVariableDimension()*2);
UnifyMinMax(newexts, atts.GetVariableDimension()*2);
//
// We now have determined the current data extents, so we may as well set
// them back.
//
GetOutput()->GetInfo().GetAttributes().GetCurrentDataExtents()
->Set(outexts);
atts.GetCurrentDataExtents()->Set(newexts);
}
......
......@@ -323,7 +323,7 @@ GUIBase::RestoreCursor()
}
// ****************************************************************************
// Method: GUIBase::OpenDataFile
// Method: GUIBase::SetOpenDataFile
//
// Purpose:
// Opens the specified data file using the file server.
......@@ -331,8 +331,6 @@ GUIBase::RestoreCursor()
// Arguments:
// qf : The qualified file name that we want to open.
// timeState : The time state that we want to open.
// addDefaultPlots : Whether we want to allow the viewer to add default
// plots if the database has them.
// sob : The caller of this method. We pass it if we do not want
// the caller to update as a result of calling this method.
// reOpen : Whether we should reopen the database instead of opening.
......@@ -368,11 +366,16 @@ GUIBase::RestoreCursor()
// I added support for telling the viewer that we don't want to add
// default plots when we open a database.
//
// Brad Whitlock, Mon Nov 3 09:34:03 PDT 2003
// I added code to prevent the file panel from updating prematurely. I also
// renamed the method and ripped out the code that told the viewer to
// open the database. I removed the addDefaultPlots argument.
//
// ****************************************************************************
bool
GUIBase::OpenDataFile(const QualifiedFilename &qf, int timeState,
bool addDefaultPlots, SimpleObserver *sob, bool reOpen)
GUIBase::SetOpenDataFile(const QualifiedFilename &qf, int timeState,
SimpleObserver *sob, bool reOpen)
{
bool retval = true;
GlobalAttributes *globalAtts = viewer->GetGlobalAttributes();
......@@ -404,6 +407,13 @@ GUIBase::OpenDataFile(const QualifiedFilename &qf, int timeState,
// Tell the fileServer to open the file specified by filename.
// This will cause it to read the file's MetaData.
fileServer->OpenFile(qf, timeState);
// Prevent the file panel from updating because the globalAtts
// from the viewer, that the file panel uses to display the right
// database highlight, do not yet contain the right timeState and
// updating the file panel now causes it to switch to the wrong
// time state for a moment.
if(sob)
sob->SetUpdate(false);
fileServer->Notify();
ClearStatus();
......@@ -412,19 +422,6 @@ GUIBase::OpenDataFile(const QualifiedFilename &qf, int timeState,
if(sob)
sob->SetUpdate(false);
globalAtts->Notify();
if(reOpen)
{
// Tell the viewer to replace all of the plots having
// databases that match the file we're re-opening.
viewer->ReOpenDatabase(qf.FullName().c_str(), false);
}
else
{
// Tell the viewer to open the database.
viewer->OpenDatabase(qf.FullName().c_str(), timeState,
addDefaultPlots);
}
}
CATCH2(GetMetaDataException, gmde)
{
......
......@@ -44,6 +44,10 @@ class SimpleObserver;
// Brad Whitlock, Wed Oct 22 12:16:01 PDT 2003
// I added an addDefaultPlots argument to OpenDataFile.
//
// Brad Whitlock, Mon Nov 3 10:44:14 PDT 2003
// Renamed OpenDataFile to SetOpenDataFile and removed its addDefaultPlots
// argument.
//
// ****************************************************************************
class GUI_API GUIBase
......@@ -69,11 +73,10 @@ protected:
void SetWaitCursor();
void RestoreCursor();
bool OpenDataFile(const QualifiedFilename &qf,
int timeState,
bool addDefaultPlots = true,
SimpleObserver *sob = 0,
bool reOpen = false);
bool SetOpenDataFile(const QualifiedFilename &qf,
int timeState,
SimpleObserver *sob = 0,
bool reOpen = false);
protected:
static StatusSubject *statusSubject;
......
......@@ -1300,13 +1300,30 @@ QvisFilePanel::ConnectGlobalAttributes(GlobalAttributes *ga)
// Brad Whitlock, Wed Oct 22 12:18:23 PDT 2003
// I added the addDefaultPlots flag to OpenDataFile.
//
// Brad Whitlock, Mon Nov 3 10:42:23 PDT 2003
// I renamed OpenDataFile to SetOpenDataFile and I moved the code that
// told the viewer to open the data file to here so file replacement would
// no longer do more work than is required.
//
// ****************************************************************************
bool
QvisFilePanel::OpenFile(const QualifiedFilename &qf, int timeState, bool reOpen)
{
// Try and open the data file.
bool retval = OpenDataFile(qf, timeState, true, this, reOpen);
bool retval = SetOpenDataFile(qf, timeState, this, reOpen);
if(reOpen)
{
// Tell the viewer to replace all of the plots having
// databases that match the file we're re-opening.
viewer->ReOpenDatabase(qf.FullName().c_str(), false);
}
else
{
// Tell the viewer to open the database.
viewer->OpenDatabase(qf.FullName().c_str(), timeState, true);
}
// Get a pointer to the file's metadata.
const avtDatabaseMetaData *md = fileServer->GetMetaData(qf);
......@@ -1344,15 +1361,26 @@ QvisFilePanel::OpenFile(const QualifiedFilename &qf, int timeState, bool reOpen)
// Brad Whitlock, Wed Oct 15 15:26:31 PST 2003
// I made it possible to replace a file at a later time state.
//
// Brad Whitlock, Mon Nov 3 10:46:18 PDT 2003
// Rewrote so replace does not first tell the viewer to open the database.
//
// ****************************************************************************
void
QvisFilePanel::ReplaceFile(const QualifiedFilename &filename, int timeState)
{
if(OpenFile(filename, timeState, false))
{
viewer->ReplaceDatabase(filename.FullName().c_str(), timeState);
}
// Try and set the open the data file.
SetOpenDataFile(filename, timeState, this, false);
// Tell the viewer to replace the database.
viewer->ReplaceDatabase(filename.FullName().c_str(), timeState);
// Get a pointer to the file's metadata.
const avtDatabaseMetaData *md = fileServer->GetMetaData(filename);
int nTimeStates = md ? md->GetNumStates() : 1;
replaceButton->setEnabled(nTimeStates > 1);
overlayButton->setEnabled(false);
}
// ****************************************************************************
......@@ -1378,15 +1406,27 @@ QvisFilePanel::ReplaceFile(const QualifiedFilename &filename, int timeState)
// Brad Whitlock, Thu May 15 12:31:13 PDT 2003
// I added time state to OpenFile.
//
// Brad Whitlock, Mon Nov 3 10:50:01 PDT 2003
// I rewrote the routine so it no longer ends up telling the viewer to
// open the database before overlaying.
//
// ****************************************************************************
void
QvisFilePanel::OverlayFile(const QualifiedFilename &filename)
{
if(OpenFile(filename, 0, false))
{
viewer->OverlayDatabase(filename.FullName().c_str());
}
// Try and set the open the data file.
SetOpenDataFile(filename, 0, this, false);
// Tell the viewer to replace the database.
viewer->OverlayDatabase(filename.FullName().c_str());
// Get a pointer to the file's metadata.
const avtDatabaseMetaData *md = fileServer->GetMetaData(filename);
int nTimeStates = md ? md->GetNumStates() : 1;
replaceButton->setEnabled(nTimeStates > 1);
overlayButton->setEnabled(false);
}
// ****************************************************************************
......@@ -2044,6 +2084,11 @@ QvisFilePanel::openFileDblClick(QListViewItem *item)
// Brad Whitlock, Fri Oct 24 14:33:40 PST 2003
// I made it use the new AnimationSetFrame method.
//
// Brad Whitlock, Mon Nov 3 11:33:05 PDT 2003
// I made it always use the ReplaceFile method and I changed the
// ReplaceDatabase functionality in the viewer so changes the animation
// time state if we're replacing with the same database.
//
// ****************************************************************************
void
......@@ -2054,23 +2099,13 @@ QvisFilePanel::replaceFile()
if((fileItem != 0) && fileItem->isFile() && (!fileItem->file.Empty()))
{
if(fileItem->file == fileServer->GetOpenFile())
{
// It must be a database timestep if the time state is not -1 and
// the file item has the same filename as the open file.
if(fileItem->timeState != -1)
AnimationSetFrame(fileItem->timeState, true);
}
else
{
// Make sure that we use a valid time state. Some file items
// have a time state of -1 if they are the parent item of several
// time step items.
int timeState = (fileItem->timeState < 0) ? 0 : fileItem->timeState;
// Make sure that we use a valid time state. Some file items
// have a time state of -1 if they are the parent item of several
// time step items.
int timeState = (fileItem->timeState < 0) ? 0 : fileItem->timeState;
// Try and replace the file.
ReplaceFile(fileItem->file.FullName(), timeState);
}
// Try and replace the file.
ReplaceFile(fileItem->file.FullName(), timeState);
}
}
......
......@@ -2872,6 +2872,10 @@ QvisGUIApplication::RefreshFileListAndNextFrame()
// Brad Whitlock, Wed Oct 22 12:11:18 PDT 2003
// Added a flag that determines whether default plots can be added.
//
// Brad Whitlock, Mon Nov 3 10:56:54 PDT 2003
// I added code that tells the viewer to open a database because I moved
// that code out of SetOpenDataFile.
//
// ****************************************************************************
void
......@@ -2954,7 +2958,11 @@ QvisGUIApplication::LoadFile(bool addDefaultPlots)
viewer->ShowAllWindows();
// Try and open the data file for plotting.
OpenDataFile(loadFile, timeState, addDefaultPlots);
SetOpenDataFile(loadFile, timeState);
// Tell the viewer to open the file too.
viewer->OpenDatabase(loadFile.FullName().c_str(), timeState,
addDefaultPlots);
}
CATCH2(BadHostException, bhe)
{
......
......@@ -667,6 +667,9 @@ LineoutListItem::DisableTool()
// Eric Brugger, Wed Aug 20 10:51:31 PDT 2003
// I removed calls to UpdateScaleFactor since it no longer exists.
//
// Brad Whitlock, Mon Nov 3 10:17:12 PDT 2003
// Changed the interface to ViewerPlotList::ReplaceDatabase.
//
// ****************************************************************************
void
......@@ -683,7 +686,7 @@ LineoutListItem::Update(Subject *TheChangedSubject)
case PlotQueryInfo::Database:
host = origPlot->GetHostName();
db = origPlot->GetDatabaseName();
vpl->ReplaceDatabase(host, db);
vpl->ReplaceDatabase(host, db, 0, false, false);
break;
case PlotQueryInfo::VarName:
vpl->SetPlotVar(origPlot->GetVariableName());
......
......@@ -1807,17 +1807,25 @@ ViewerPlotList::SetPlotOperatorAtts(const int operatorType, bool applyToAll)
// Brad Whitlock, Fri Oct 24 17:40:36 PST 2003
// I made it update the expression list.
//
// Brad Whitlock, Mon Nov 3 10:06:02 PDT 2003
// I added timeState and setTimeState so we can change the animation's
// time state if we need to change time states before updating the frame.
// This lets us change animation time states before having to execute the
// pipeline so it is somewhat cheaper to replace files with a database
// that has a new active time state. This approach also lets us just change
// the animation's time state if we're replacing with the same database.
//
// ****************************************************************************
void
ViewerPlotList::ReplaceDatabase(const std::string &host, const std::string &database,
bool onlyReplaceSame)
int timeState, bool setTimeState, bool onlyReplaceSame)
{
//
// Loop through the list replacing the plot's database.
//
bool defaultChanged = false;
bool updateSIL = false;
bool plotsReplaced = false;
for (int i = 0; i < nPlots; i++)
{
//
......@@ -1871,7 +1879,7 @@ ViewerPlotList::ReplaceDatabase(const std::string &host, const std::string &data
plot->SetHostDatabaseName(host.c_str(), database.c_str());
plot->SetSILRestriction(silr);
plot->ClearActors();
updateSIL = true;
plotsReplaced = true;
//
// If we're not in keyframing mode, then we should set
......@@ -1923,7 +1931,7 @@ ViewerPlotList::ReplaceDatabase(const std::string &host, const std::string &data
//
// Update the SIL restriction attributes if necessary.
//
if (updateSIL)
if (plotsReplaced)
UpdateSILRestrictionAtts();
//
......@@ -1934,7 +1942,10 @@ ViewerPlotList::ReplaceDatabase(const std::string &host, const std::string &data
//
// Update the frame.
//
animation->UpdateFrame();
if(setTimeState)
animation->SetFrameIndex(timeState);
else
animation->UpdateFrame();
}
// ****************************************************************************
......
......@@ -206,7 +206,7 @@ class VIEWER_API ViewerPlotList
void SetPlotAtts(const int plotType);
void SetPlotOperatorAtts(const int operatorType, bool applyToAll = false);
void ReplaceDatabase(const std::string &host, const std::string &database,
bool onlyReplaceSame = false);
int timeState, bool setTimeState, bool onlyReplaceSame);
void OverlayDatabase(const std::string &host, const std::string &database);
void SetActivePlots(const intVector &activePlots,
......
......@@ -2444,191 +2444,6 @@ ViewerSubject::RedrawWindow()
ViewerWindowManager::Instance()->RedrawWindow();
}
// ****************************************************************************
// Method: ViewerSubject::OpenDatabaseHelper
//
// Purpose:
// Opens a database.
//
// Programmer: Eric Brugger
// Creation: August 17, 2000
//
// Modifications:
// Jeremy Meredith, Fri Apr 20 10:33:42 PDT 2001
// Added code to pass "other" options to the engine when starting.
//
// Brad Whitlock, Wed Nov 14 17:08:07 PST 2001
// Added code to set the number of time steps in the animation.
//
// Brad Whitlock, Wed Sep 11 16:29:27 PST 2002
// I changed the code so an engine is only launched when the file can
// be opened.
//
// Brad Whitlock, Tue Dec 10 15:34:17 PST 2002
// I added code to tell the engine to open the database.
//
// Brad Whitlock, Mon Dec 30 14:59:24 PST 2002
// I changed how nFrames and nStates are set.
//
// Brad Whitlock, Fri Jan 17 11:35:29 PDT 2003
// I added code to reset nFrames if there are no plots in the plot list.
//
// Brad Whitlock, Tue Feb 11 11:56:34 PDT 2003
// I made it use STL strings.
//
// Brad Whitlock, Tue Mar 25 14:23:16 PST 2003
// I made it capable of defining a virtual database.
//
// Brad Whitlock, Fri Apr 4 11:10:08 PDT 2003
// I changed how the number of frames in an animation is updated.
//
// Brad Whitlock, Thu May 15 13:34:19 PST 2003
// I added the timeState argument and renamed the method.
//
// Hank Childs, Thu Aug 14 09:10:00 PDT 2003
// Added code to manage expressions from databases.
//
// Walter Herrera, Thu Sep 04 16:13:43 PST 2003
// I made it capable of creating default plots
//
// Brad Whitlock, Fri Oct 3 10:40:49 PDT 2003
// I prevented the addition of default plots if the plot list already
// contains plots from the new database.
//
// Brad Whitlock, Wed Oct 22 12:27:30 PDT 2003
// I made the method actually use the addDefaultPlots argument.
//
// Brad Whitlock, Fri Oct 24 17:07:52 PST 2003
// I moved the code to update the expression list into the plot list.
//
// ****************************************************************************
void
ViewerSubject::OpenDatabaseHelper(const std::string &entireDBName,
int timeState, bool updateNFrames, bool addDefaultPlots)
{
int i;
debug1 << "Opening database " << entireDBName.c_str()
<< ", timeState=" << timeState << endl;
//
// Associate the database with the currently active animation (window).
//
ViewerWindowManager *wM=ViewerWindowManager::Instance();
ViewerPlotList *plotList = wM->GetActiveAnimation()->GetPlotList();
//
// Set the new host/database name into the plot list. This splits it.
//
plotList->SetHostDatabaseName(entireDBName);
std::string host(plotList->GetHostName());
std::string db(plotList->GetDatabaseName());
//
// Expand the database name to its full path just in case.
//
ViewerFileServer *fs = ViewerFileServer::Instance();
std::string expandedDB(fs->ExpandedFileName(host, db));
plotList->SetDatabaseName(expandedDB.c_str());
db = plotList->GetDatabaseName();
//
// Get the number of time states and set that information into the
// active animation.
//
const avtDatabaseMetaData *md = fs->GetMetaData(host, db, timeState);
if (md != NULL)